e-virt-table 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/index.cjs.js +16 -16
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.es.js +2309 -1946
  4. package/dist/index.es.js.map +1 -1
  5. package/dist/index.umd.js +16 -16
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/lib/BaseCell.js +3 -2
  8. package/dist/lib/BaseCell.js.map +1 -1
  9. package/dist/lib/Body.js +33 -24
  10. package/dist/lib/Body.js.map +1 -1
  11. package/dist/lib/BorderStyle.d.ts +9 -0
  12. package/dist/lib/BorderStyle.js +29 -0
  13. package/dist/lib/BorderStyle.js.map +1 -0
  14. package/dist/lib/Cell.d.ts +1 -0
  15. package/dist/lib/Cell.js +16 -9
  16. package/dist/lib/Cell.js.map +1 -1
  17. package/dist/lib/CellHeader.js +3 -2
  18. package/dist/lib/CellHeader.js.map +1 -1
  19. package/dist/lib/CellImage.js +2 -2
  20. package/dist/lib/CellImage.js.map +1 -1
  21. package/dist/lib/Config.d.ts +13 -1
  22. package/dist/lib/Config.js +35 -0
  23. package/dist/lib/Config.js.map +1 -1
  24. package/dist/lib/Context.d.ts +11 -0
  25. package/dist/lib/Context.js +49 -3
  26. package/dist/lib/Context.js.map +1 -1
  27. package/dist/lib/Database.js +2 -2
  28. package/dist/lib/Database.js.map +1 -1
  29. package/dist/lib/EVirtTable.d.ts +7 -0
  30. package/dist/lib/EVirtTable.js +20 -2
  31. package/dist/lib/EVirtTable.js.map +1 -1
  32. package/dist/lib/Editor.js +27 -20
  33. package/dist/lib/Editor.js.map +1 -1
  34. package/dist/lib/Empty.js +1 -1
  35. package/dist/lib/Empty.js.map +1 -1
  36. package/dist/lib/EventBrowser.js +10 -2
  37. package/dist/lib/EventBrowser.js.map +1 -1
  38. package/dist/lib/EventTable.js +5 -3
  39. package/dist/lib/EventTable.js.map +1 -1
  40. package/dist/lib/Footer.js +18 -5
  41. package/dist/lib/Footer.js.map +1 -1
  42. package/dist/lib/Header.js +25 -16
  43. package/dist/lib/Header.js.map +1 -1
  44. package/dist/lib/Overlayer.js +14 -17
  45. package/dist/lib/Overlayer.js.map +1 -1
  46. package/dist/lib/Paint.d.ts +1 -1
  47. package/dist/lib/Paint.js +3 -2
  48. package/dist/lib/Paint.js.map +1 -1
  49. package/dist/lib/Row.d.ts +2 -0
  50. package/dist/lib/Row.js +10 -0
  51. package/dist/lib/Row.js.map +1 -1
  52. package/dist/lib/ScrollbarMode.d.ts +21 -0
  53. package/dist/lib/ScrollbarMode.js +38 -0
  54. package/dist/lib/ScrollbarMode.js.map +1 -0
  55. package/dist/lib/Scroller.d.ts +1 -0
  56. package/dist/lib/Scroller.js +263 -70
  57. package/dist/lib/Scroller.js.map +1 -1
  58. package/dist/lib/Selector.js +4 -2
  59. package/dist/lib/Selector.js.map +1 -1
  60. package/dist/lib/TextSelector.d.ts +13 -16
  61. package/dist/lib/TextSelector.js +150 -119
  62. package/dist/lib/TextSelector.js.map +1 -1
  63. package/dist/lib/Tooltip.js +7 -13
  64. package/dist/lib/Tooltip.js.map +1 -1
  65. package/dist/lib/ZoomScale.d.ts +55 -0
  66. package/dist/lib/ZoomScale.js +137 -0
  67. package/dist/lib/ZoomScale.js.map +1 -0
  68. package/dist/lib/types.d.ts +1 -0
  69. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -1,18 +1,18 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.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-body-bg-color: #fff;--evt-stripe-color: #fafafa;--evt-placeholder-color: #cdd0dc;--evt-header-bg-color: #f8faff;--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-required-color: #f56c6c;--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: rgba(82, 146, 247, .1);--evt-autofill-point-border-color: #fff;--evt-edit-bg-color: #fcf6ed;--evt-checkbox-color: var(--evt-color-primary);--evt-checkbox-uncheck-color: #dde0ea;--evt-checkbox-disabled-color: #f1f2f4;--evt-checkbox-check-disabled-color: #dde0ea;--evt-icon-edit-color: #4e5969;--evt-icon-select-color: #4e5969;--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-text-color: #fff;--evt-resize-column-text-bg-color: var(--evt-color-primary);--evt-resize-column-line-color: #e1e6eb;--evt-tree-line-color: #e1e6eb;--evt-sort-icon-color: var(--evt-color-primary);--evt-drag-tip-bg-color: rgba(82, 146, 247, .1);--evt-drag-tip-line-color: var(--evt-color-primary);--evt-context-menu-min-width: 150px;--evt-context-menu-max-width: 220px;--evt-context-menu-item-padding: 8px 12px;--evt-context-menu-bg-color: #fff;--evt-context-menu-text-color: #333;--evt-context-menu-item-hover-text-color: var(--evt-color-primary);--evt-context-menu-item-hover-bg-color: #f5f5f5;--evt-context-menu-text-size: 13px}.dark{--evt-border-color: #363637;--evt-header-bg-color: #141414;--evt-body-bg-color: #141414;--evt-header-text-color: #a3a6ad;--evt-body-text-color: #cfd3dc;--evt-readonly-text-color: #cfd3dc;--evt-footer-text-color: #cfd3dc;--evt-scroller-color: #414243;--evt-scroller-track-color: #141414;--evt-scroller-focus-color: #a3a6ad;--evt-edit-bg-color: #141414;--evt-footer-bg-color: #262727;--evt-autofill-point-border-color: #fff;--evt-editor-bg-color: #434343;--evt-editor-text-color: #cfd3dc;--evt-context-menu-bg-color: #141414;--evt-context-menu-text-color: #cfd3dc;--evt-context-menu-item-hover-text-color: var(--evt-color-primary);--evt-context-menu-item-hover-bg-color: #414243}.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;background-color:var(--evt-body-bg-color);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:6px 24px;color:var(--evt-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--evt-color-primary);background-color:#f5f7fa}.e-virt-table-loading{display:none;position:absolute;left:0;top:0;right:0;bottom:0;width:100%;height:100%;z-index:2000;background-color:#fff6;display:flex;align-items:center;justify-content:center}.e-virt-table-loading-spinner{opacity:1;display:flex;flex-direction:column;align-items:center;justify-content:center}.e-virt-table-loading-spinner svg{color:var(--evt-text-color-regular);animation:rotate 1s linear infinite}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.e-virt-table-loading-text{margin:0;font-size:12px;color:var(--evt-text-color-regular)}.e-virt-table-main-menu,.e-virt-table-submenu{position:absolute;background:var(--evt-context-menu-bg-color);border-radius:4px;box-shadow:0 2px 8px #0000001a;min-width:var(--evt-context-menu-min-width);max-width:var(--evt-context-menu-max-width);color:var(--evt-text-color-primary)}.e-virt-table-main-menu{border:1px solid var(--evt-border-color);z-index:3000;left:-99999px;top:-99999px;display:none;position:fixed;background-color:var(--evt-body-bg-color)}.e-virt-table-submenu{border:1px solid var(--evt-border-color);z-index:1000;max-height:350px;overflow-y:auto;opacity:0;visibility:hidden;transform:translate(-10px);transition:opacity .2s,visibility .2s,transform .2s;-ms-overflow-style:none;scrollbar-width:none}.e-virt-table-submenu::-webkit-scrollbar{display:none}.e-virt-table-submenu.show{opacity:1;visibility:visible;transform:translate(0)}.e-virt-table-submenu:not(.show){transition:none}.e-virt-table-menu-item,.e-virt-table-submenu-item{position:relative;-webkit-user-select:none;user-select:none;padding:var(--evt-context-menu-item-padding);cursor:pointer;display:flex;justify-content:space-between;align-items:center;transition:background .2s,color .2s;color:var(--evt-context-menu-text-color);font-size:var(--evt-context-menu-text-size)}.e-virt-table-menu-item:last-child,.e-virt-table-submenu-item:last-child{border-bottom:none}.e-virt-table-menu-item:has(.e-virt-table-menu-item-icon){padding-left:8px}.e-virt-table-menu-item-content{display:flex;align-items:center;flex:1;min-width:0}.e-virt-table-menu-item-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;margin-right:8px;flex-shrink:0}.e-virt-table-menu-item-icon svg{width:100%;height:100%;fill:currentColor}.e-virt-table-menu-item-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.e-virt-table-menu-arrow{display:inline-flex;align-items:center;justify-content:center;color:var(--evt-text-color-regular);transition:color .2s}.e-virt-table-menu-arrow svg{width:20px;height:20px;fill:currentColor}.e-virt-table-submenu-item:hover,.e-virt-table-menu-item:hover,.e-virt-table-menu-item.active{background:var(--evt-context-menu-item-hover-bg-color);color:var(--evt-context-menu-item-hover-text-color)}.e-virt-table-menu-item.disabled,.e-virt-table-submenu-item.disabled{cursor:not-allowed}.e-virt-table-finder-bar{position:absolute;top:8px;right:16px;display:none;z-index:10000;background:#fff;border:1px solid #dadce0;border-radius:12px;box-shadow:0 2px 6px #0003;padding:0 8px;height:48px;min-width:250px;align-items:center;font-size:12px}.e-virt-table-finder-bar.show{display:flex}.e-virt-table-finder-bar-input-wrapper{display:flex;align-items:center;flex:1;padding:0 8px;position:relative}.e-virt-table-finder-bar-input{border:none;outline:none;flex:1;font-size:12px;background:transparent;color:#333;min-width:150px;padding-left:0;position:relative}.e-virt-table-finder-bar-nav{display:flex;flex-direction:row;gap:8px;margin:0 8px;align-items:center}.e-virt-table-finder-bar-nav-btn{border:none;background:transparent;cursor:pointer;padding:0;color:#666;border-radius:50%;display:flex;align-items:center;justify-content:center}.e-virt-table-finder-bar-nav-btn svg{width:24px;height:24px}.e-virt-table-finder-bar-nav-btn.prev-btn{transform:rotate(-90deg)}.e-virt-table-finder-bar-nav-btn.next-btn{transform:rotate(90deg)}.e-virt-table-finder-bar-nav-btn.close-btn{font-size:24px;color:#666;line-height:1;width:24px;height:24px}.e-virt-table-finder-bar-nav-btn:hover{color:#666;background-color:#f0f0f0}.e-virt-table-finder-bar-count{color:#666;font-size:12px;margin:0 8px;white-space:nowrap;flex-shrink:0}.e-virt-table-finder-bar-count.no-results{color:#999}.e-virt-table-finder-bar-loading{display:none;position:absolute;left:8px;top:0;width:16px;height:16px;flex-shrink:0;pointer-events:none;z-index:0}.e-virt-table-finder-bar-loading.show{display:block}.e-virt-table-finder-bar-loading svg{width:100%;height:100%;color:#666;animation:rotate 1s linear infinite}.e-virt-table-empty{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:14px;color:#666;z-index:15}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- "use strict";var we=Object.defineProperty;var me=(h,t,e)=>t in h?we(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var r=(h,t,e)=>me(h,typeof t!="symbol"?t+"":t,e);class Ee{constructor(t){r(this,"rules");this.rules=t}validate(t){const e=[],{column:i,row:s,key:o,rowKey:n,colIndex:a,rowIndex:l,value:c,field:d,fieldValue:f}=t;Array.isArray(this.rules)||(this.rules=[this.rules]);for(const u of this.rules){if(u.validator){const x={field:d,fieldValue:f,value:c,column:i,colIndex:a,rowIndex:l,row:s,key:o,rowKey:n,...u};u.validator(x,c,g=>{g&&e.push({...x,message:g})})}if(!u.required&&(c==null||c===""))return e;u.pattern&&!u.pattern.test(c)&&e.push({value:c,column:i,row:s,key:o,rowKey:n,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is pattern validation error`}),u.required&&(c==null||c==="")&&e.push({value:c,column:i,row:s,key:o,rowKey:n,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is required`})}return e}}function qt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(h){const t=Math.random()*16|0;return(h==="x"?t:t&3|8).toString(16)})}function St(h,t){let e=0,i;return function(...s){const o=new Date().getTime(),n=o-e,a=typeof t=="function"?t():t;!e||n>=a?(h.apply(this,s),e=o):i||(i=setTimeout(()=>{h.apply(this,s),e=new Date().getTime(),i=void 0},a-n))}}function rt(h=[]){return h.length?h.map(t=>rt(t.children)+1).sort((t,e)=>e-t)[0]:0}function pe(h=[]){let t=[],e=[],i=[];return h.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,o)=>(s.sort??0)-(o.sort??0)),...e.sort((s,o)=>(s.sort??0)-(o.sort??0)),...i.sort((s,o)=>(s.sort??0)-(o.sort??0))]}function at(h=[],t=1,e=0,i=""){return h.sort((s,o)=>(s.sort??0)-(o.sort??0)).map(s=>{if(s.children){let o=0,n=s.fixed;s.children.forEach(l=>{l.fixed=n});const a=at(s.children,t-1,e+1,s.key);return a&&a.forEach(l=>{o+=l.colspan??0}),{...s,width:s.width,level:e,rowspan:1,colspan:o,parentKey:i,children:a.sort((l,c)=>(l.sort??0)-(c.sort??0))}}return{...s,level:e,rowspan:t,colspan:1,parentKey:i}})}function tt(h=[]){let t=[];return h.forEach(e=>{e.children?t=t.concat(tt(e.children)):t.push(e)}),t}function Jt(h){return h.filter(t=>!t.hide).map(t=>Array.isArray(t.children)&&t.children.length>0?{...t,children:Jt(t.children)}:{...t})}const kt=/^(\r\n|\n\r|\r|\n)/,ye=/^[^\t\r\n]+/,Bt=/^\t/;function Ce(h){let t=[[""]];if(h.length===0)return t;let e=0,i=0,s;for(;h.length>0&&s!==h.length;)if(s=h.length,h.match(Bt))h=h.replace(Bt,""),e+=1,t[i][e]="";else if(h.match(kt))h=h.replace(kt,""),e=0,i+=1,t[i]=[""];else{let o="";if(h.startsWith('"')){let n=0,a=!0;for(;a;){const l=h.slice(0,1);l==='"'&&(n+=1),o+=l,h=h.slice(1),(h.length===0||h.match(/^[\t\r\n]/)&&n%2===0)&&(a=!1)}o=o.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const n=h.match(ye);o=n?n[0]:"",h=h.slice(o.length)}t[i][e]=o}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 be(h){let t,e,i,s,o="",n;for(t=0,e=h.length;t<e;t+=1){for(s=h[t].length,i=0;i<s;i+=1)i>0&&(o+=" "),n=h[t][i],typeof n=="string"?n.indexOf(`
3
- `)>-1?o+=`"${n.replace(/"/g,'""')}"`:o+=n:n==null?o+="":o+=n;t!==e-1&&(o+=`
4
- `)}return o}function Qt(h,t,e=[]){let i=0;const s=[];return h.forEach((o,n)=>{if(n===0)s.push(1);else{const a=e.reduce((c,d)=>`${c}${o[d]??""}`,"")||o[t],l=e.reduce((c,d)=>`${c}${h[n-1][d]??""}`,"")||h[n-1][t];a===l?(s[i]+=1,s.push(0)):(s.push(1),i=n)}}),s}function te(h,t){let e="",i="";const s={};return t.forEach((o,n)=>{n===0?(e=o.key,i=o.key,s[o.key]=1):h[o.key]===h[e]?(s[o.key]=0,s[i]+=1):(s[o.key]=1,e=o.key,i=o.key)}),s}function Re(h,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=h,n=Qt(i,t,e);return n[s-o]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:n[s-o],colspan:1,relationRowKeys:e,mergeRow:!0}}function Ie(h,t=[]){const{column:e,row:i,visibleLeafColumns:s}=h,o=s.filter(n=>t.includes(n.key));if(t.includes(e.key)){const n=te(i,o);return n[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:n[e.key],relationColKeys:t,mergeCol:!0}}}function ve(h,t=document.documentElement){const e=h.startsWith("--")?h:`--${h}`;return getComputedStyle(t).getPropertyValue(e).trim()}function Xt(h){if(!h)return new Date(0);if(typeof h=="number")return new Date(h);const t=String(h).trim(),e=new Date(t);if(!isNaN(e.getTime()))return e;const i=[/^(\d{4})-(\d{1,2})-(\d{1,2})$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/,/^(\d{4})\.(\d{1,2})\.(\d{1,2})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{4})(\d{2})(\d{2})$/,/^(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/];for(const s of i){const o=t.match(s);if(o){const n=o.slice(1).map(Number);if(s.source.includes("YYYY-MM-DD")||s.source.includes("YYYY/MM/DD")||s.source.includes("YYYY.MM.DD")){const[a,l,c,d=0,f=0,u=0]=n;return new Date(a,l-1,c,d,f,u)}else if(s.source.includes("DD-MM-YYYY")||s.source.includes("DD/MM/YYYY")||s.source.includes("DD.MM.YYYY")){const[a,l,c,d=0,f=0,u=0]=n;return new Date(c,l-1,a,d,f,u)}else if(s.source.includes("MM-DD-YYYY")||s.source.includes("MM/DD/YYYY")||s.source.includes("MM.DD.YYYY")){const[a,l,c,d=0,f=0,u=0]=n;return new Date(c,a-1,l,d,f,u)}else if(s.source.includes("YYYYMMDD")){const[a,l,c]=n;return new Date(a,l-1,c)}}}return new Date(NaN)}function _e(h,t){const e=Xt(h),i=Xt(t);return isNaN(e.getTime())&&isNaN(i.getTime())?0:isNaN(e.getTime())?-1:isNaN(i.getTime())?1:e.getTime()-i.getTime()}function Te(h){const t=String(h).match(/\.(\d+)/);return(t==null?void 0:t[1].length)??0}class ee{constructor(t,e,i,s,o,n,a){r(this,"ctx");r(this,"x",0);r(this,"y",0);r(this,"width",0);r(this,"height",0);r(this,"visibleWidth",0);r(this,"visibleHeight",0);r(this,"fixed");r(this,"cellType");r(this,"drawX",0);r(this,"drawY",0);r(this,"cellImages",new Map);this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=o,this.fixed=a,this.cellType=n}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,o=t;return!(this.x+this.width-e-i<=0||this.x-i>=o-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}isInside(t,e){return t>=this.drawX&&t<=this.drawX+this.width&&e>=this.drawY&&e<=this.drawY+this.height}isInsideVisible(t,e){return t>=this.drawX&&t<=this.drawX+this.visibleWidth&&e>=this.drawY&&e<=this.drawY+this.visibleHeight&&this.isInside(t,e)}setImage(t,e){this.cellImages.set(t,e)}getImages(){return this.cellImages}getImage(t){return this.cellImages.get(t)}isImageInside(t,e){const{offsetX:i,offsetY:s}=this.ctx.getOffset(e),o=this.getImage(t);return o?o.isInside(i,s):!1}}class j{constructor(t,e,i,s,o,n){r(this,"source");r(this,"name");r(this,"x");r(this,"y");r(this,"width");r(this,"height");r(this,"visible",!0);this.source=n,this.name=t,this.x=e,this.y=i,this.width=s,this.height=o}drawWrapper(t,e){t.paint.drawRect(this.x-2,this.y-2,this.width+4,this.height+4,{radius:4,borderWidth:1,...e})}setVisible(t){this.visible=t}isInside(t,e){return this.visible?!!(this.source&&t>this.x&&t<this.x+this.width&&e>this.y&&e<this.y+this.height):!1}}class ie extends ee{constructor(e,i,s,o,n,a,l,c,d,f="body",u=!0){super(e,o,n,a,l,f,c.fixed);r(this,"parentRowKey","");r(this,"parentRowKeys",[]);r(this,"formatter");r(this,"formatterFooter");r(this,"hoverIconName","");r(this,"operation",!1);r(this,"align");r(this,"verticalAlign");r(this,"fixed");r(this,"type");r(this,"editorType");r(this,"editorProps");r(this,"cellType");r(this,"level");r(this,"colspan",1);r(this,"rowspan",1);r(this,"mergeRow",!1);r(this,"mergeCol",!1);r(this,"relationRowKeys",[]);r(this,"relationColKeys",[]);r(this,"key");r(this,"column");r(this,"rowIndex");r(this,"colIndex");r(this,"rowKey");r(this,"row");r(this,"value");r(this,"render");r(this,"renderFooter");r(this,"style",{});r(this,"domDataset",{});r(this,"rules",[]);r(this,"message","");r(this,"text","");r(this,"displayText","");r(this,"visibleWidth",0);r(this,"visibleHeight",0);r(this,"isHasChanged",!1);r(this,"drawX",0);r(this,"drawY",0);r(this,"drawCellBgColor","");r(this,"drawCellSkyBgColor","");r(this,"drawTextColor","");r(this,"drawTextFont","");r(this,"drawTextX",0);r(this,"drawTextY",0);r(this,"drawTextWidth",0);r(this,"drawTextHeight",0);r(this,"autoRowHeight",!1);r(this,"calculatedHeight",0);r(this,"ellipsis",!1);r(this,"rowExpand",!1);r(this,"rowHasChildren",!1);r(this,"overflowTooltipShow",!0);r(this,"selectorCellValueType","value");r(this,"overflowTooltipMaxWidth",500);r(this,"overflowTooltipPlacement","top");r(this,"maxLineClamp","auto");r(this,"precision");r(this,"min");r(this,"max");r(this,"maxlength");r(this,"mixedRender",!1);r(this,"renderType","default");r(this,"renderFooterType","default");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.selectorCellValueType=c.selectorCellValueType||this.ctx.config.SELECTOR_CELL_VALUE_TYPE||"value",this.editorProps=c.editorProps||{},this.cellType=f,this.align=c.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=c.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,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.autoRowHeight=c.autoRowHeight!==void 0?c.autoRowHeight:this.ctx.config.AUTO_ROW_HEIGHT,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.maxLineClamp=c.maxLineClamp||"auto",this.precision=c.precision,this.min=c.min,this.max=c.max,this.maxlength=c.maxlength,this.mixedRender=c.mixedRender||!1,this.renderType=c.renderType||"default",this.renderFooterType=c.renderFooterType||"default";const x=this.ctx.database.getRowForRowKey(this.rowKey);this.cellType==="body"&&x&&(this.parentRowKey=x.parentRowKey,this.parentRowKeys=x.parentRowKeys),u&&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.updateSpan(),this.updateDragImage();const e=this.getImage("drag"),i=e?e.width:0;this.drawTextX=this.drawX+i,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.drawTextWidth=this.visibleWidth-i,this.drawTextHeight=this.visibleHeight,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:o=1,relationRowKeys:n,relationColKeys:a,mergeRow:l=!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(n)&&n.length>0?this.relationRowKeys=n:this.relationRowKeys=[this.key],Array.isArray(a)&&a.length>0?this.relationColKeys=a:this.relationColKeys=[this.key],this.mergeCol=c,this.mergeRow=l,this.colspan=s,this.rowspan=o,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:o,props:n={}}=s;this.editorType=o,this.editorProps=n}}}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.autoRowHeight&&(this.domDataset={"data-auto-height":!0,"data-row-index":this.rowIndex,"data-col-index":this.colIndex}),this.style=this.getOverlayerViewsStyle()}isInsideVisible(e,i){return e>=this.drawX&&e<=this.drawX+this.visibleWidth&&i>=this.drawY&&i<=this.drawY+this.visibleHeight}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,n=0,a="";if(!(["tree","selection-tree","tree-selection"].includes(this.type)&&s==="body"))return;const l=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:d=!1,expandLoading:f=!1,level:u=0}=l||{};this.rowExpand=c,this.rowHasChildren=d;const{TREE_INDENT:x=16,CHECKBOX_SIZE:g,TREE_ICON_SIZE:E}=this.ctx.config;if(n=u*x,f){const _=this.ctx.icons.get("loading");a="loading",o=_}else if(d){const _=this.ctx.icons.get("expand"),R=this.ctx.icons.get("shrink");o=c?R:_,a=c?"shrink":"expand"}let w=E,m=E,y=this.drawX;(this.align==="center"||this.align==="right")&&(y=this.drawX+(this.visibleWidth-w-2*e)/2,this.align="left");let b=y+n+e,p=this.drawY+(this.visibleHeight-m)/2,C=n+this.drawX+w-.5;const I=this.getImage("selection"),v=this.getImage("drag"),T=v?v.width:0;if(this.type==="selection-tree"&&I){const _=I.x,R=I.width;b=n+_+R,C=b+w-e/2}else this.type==="tree-selection"?(b+=T,C=b+g+w-e/2):(b+=T,C=b+w-e/2);this.drawTextX=C,this.drawTextWidth=this.drawX+this.visibleWidth-C,!(b+w+e>this.drawX+this.visibleWidth)&&(p+m+e>this.drawY+this.visibleHeight||this.setImage("tree",new j(a,b,p,w,m,o)))}updateDragImage(){if(this.cellType==="body"&&this.column.dragRow){const{DRAG_ROW_ICON_SIZE:e,CELL_PADDING:i}=this.ctx.config,s=this.drawX+i/2,o=this.drawY+(this.visibleHeight-e)/2,n=new j("drag",s,o,e,e,this.ctx.icons.get("drag"));this.rowspan===0&&n.setVisible(!1),this.setImage("drag",n)}}drawTreeLine(){const{TREE_LINE:e,TREE_INDENT:i=16,TREE_ICON_SIZE:s=16,TREE_LINE_COLOR:o="#e1e6eb"}=this.ctx.config;if(!e||this.cellType!=="body"||!["tree","selection-tree","tree-selection"].includes(this.type)||this.rowspan===0||this.colspan===0)return;const n=this.ctx.database.getRowForRowKey(this.rowKey)||{},a=n.level??0,l=this.getImage("tree");if(!l)return;const c=l.x,d=l.y,f=l.width,u=l.height,x=c+f/2,g=d+u/2;let E=c-a*i;const w=Array.isArray(n.parentRowKeys)?n.parentRowKeys:[];if(a>0){for(let C=0;C<a-1;C+=1){const I=w[C+1];if(!!(I?this.ctx.database.getRowForRowKey(I)||{}:{}).isLastChild)continue;const _=Math.round(c-(a-C)*i+s/2);this.ctx.paint.drawLine([_,this.drawY,_,this.drawY+this.visibleHeight],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}const m=Math.round(c-i+s/2),b=!!n.isLastChild?g:this.drawY+this.visibleHeight;this.ctx.paint.drawLine([m,this.drawY,m,b],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0});const p=Math.round(E+(a-1)*i+s/2);this.ctx.paint.drawLine([p,g,x,g],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}if(n.hasChildren&&n.expand){const m=d+u,y=this.drawY+this.visibleHeight;this.ctx.paint.drawLine([x,m,x,y],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:o,READONLY_TEXT_COLOR:n,BODY_TEXT_COLOR:a,FOOTER_TEXT_COLOR:l,FOOTER_BG_COLOR:c,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:u,HIGHLIGHT_HOVER_ROW_COLOR:x,STRIPE:g,STRIPE_COLOR:E,FINDER_CELL_BG_COLOR:w}=this.ctx.config;if(this.cellType==="footer"){let S=c,O=l;if(typeof o=="function"){const M=o,{backgroundColor:L,color:H,font:D}=M({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};L&&(S=L),H&&(O=H),D&&(this.drawTextFont=D)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=S,this.drawTextColor=O;return}let m="transparent";const y=this.ctx.hoverCell,b=this.ctx.currentCell;let p=this.rowIndex,C=this.rowIndex;if(this.rowspan!==1&&(u||d)){const S=this.getSpanInfo(),{yArr:O}=S;p=O[0],C=O[1]}u&&y&&!this.ctx.dragRowIng&&(y.rowKey===this.rowKey&&(m=x),y.rowIndex>=p&&y.rowIndex<=C&&(m=x)),d&&b&&!this.ctx.dragRowIng&&(b.rowKey===this.rowKey&&(m=f),b.rowIndex>=p&&b.rowIndex<=C&&(m=f)),this.drawCellSkyBgColor=m;let I=e,v=a;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(I=i,v=n),g&&(this.rowIndex%2?I=E:I=e),typeof s=="function"){const S=s,{backgroundColor:O,color:M,font:L}=S({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};O&&(I=O),M&&(v=M),L&&(this.drawTextFont=L)}const{rowIndex:T,colIndex:_,type:R}=this.ctx.finderBar;T===this.rowIndex&&_===this.colIndex&&R==="body"&&(I=w),this.drawCellBgColor=I,this.drawTextColor=v}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:n,type:a,rowIndex:l,rowKey:c}=this;if(s===0||o===0||n==="footer"||!["index-selection","selection","selection-tree","tree-selection"].includes(a))return;const d=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:f=0,CELL_PADDING:u}=this.ctx.config;let x=this.drawX+u;(this.align==="center"||this.align==="right")&&(x=this.drawX+(e-f)/2);let g=x,E=this.drawY+(i-f)/2;if(a!=="selection-tree"){if(a==="tree-selection"){const{TREE_INDENT:C=16,TREE_ICON_SIZE:I}=this.ctx.config,v=this.ctx.database.getRowForRowKey(c),{level:T=0}=v||{},_=T*C;g=x+I+_}}let w=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck";if(a==="selection-tree"||a==="tree-selection"){const C=this.ctx.database.getTreeSelectionState(c);C.indeterminate&&d?(w=this.ctx.icons.get("checkbox-indeterminate"),m="checkbox-indeterminate"):C.checked&&d?(w=this.ctx.icons.get("checkbox-check"),m="checkbox-check"):!C.checked&&d?(w=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck"):(w=this.ctx.icons.get("checkbox-disabled"),m="checkbox-disabled")}else{const C=this.ctx.database.getRowSelection(c);C&&d?(w=this.ctx.icons.get("checkbox-check"),m="checkbox-check"):C&&!d?(w=this.ctx.icons.get("checkbox-check-disabled"),m="checkbox-check-disabled"):!C&&d?(w=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck"):(w=this.ctx.icons.get("checkbox-disabled"),m="checkbox-disabled")}const y=this.getImage("drag"),b=y?y.width:0;if(g+=b,g+f+u>this.drawX+this.visibleWidth||E+f+u>this.drawY+this.visibleHeight)return;const p=new j(m,g,E,f,f,w);if(a==="index-selection"){p.setVisible(!1),(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(m))&&p.setVisible(!0);let C=this.rowIndex,I=this.rowIndex;const v=this.ctx.hoverCell,T=this.getSpanInfo(),{yArr:_}=T;C=_[0],I=_[1],v&&v.rowIndex>=C&&v.rowIndex<=I&&p.setVisible(!0)}this.setImage("selection",p)}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:o,ENABLE_MERGE_CELL_LINK:n}=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:a}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&!this.ctx.dragRowIng&&a){let l=0,c=0;if(a.rowKey===this.rowKey&&(l=this.drawX+this.width-s-o,c=this.drawY+(this.height-s)/2),this.rowspan!==1&&n){const u=this.getSpanInfo(),{yArr:x}=u,g=x[0],E=x[1];if(a.rowIndex>=g&&a.rowIndex<=E){const{width:w,height:m,offsetTop:y,offsetLeft:b}=u;l=this.drawX-b+w-s-o,c=this.drawY-y+(m-s)/2}}const d=this.ctx.icons.get(this.hoverIconName),f=new j(this.hoverIconName,l,c,s,s,d);(this.rowspan===0||this.colspan===0)&&f.setVisible(!1),this.setImage("hover",f)}}getAutoHeight(){if(this.cellType!=="body"||!this.autoRowHeight||this.rowspan===0)return 0;if(this.render){const a=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);return this.rowspan>1?a<this.visibleHeight?0:Math.round(a-(this.visibleHeight-this.height)):Math.round(a)}if(!(this.displayText&&typeof this.displayText=="string"))return 0;const{BODY_FONT:e,CELL_PADDING:i,CELL_LINE_HEIGHT:s}=this.ctx.config,o=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`,n=this.ctx.paint.calculateTextHeight(this.displayText,this.drawTextWidth,{font:this.drawTextFont||e,padding:i,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor,autoRowHeight:this.autoRowHeight,lineHeight:s,maxLineClamp:this.maxLineClamp,cacheTextKey:o});return this.rowspan>1?n<this.visibleHeight?0:Math.round(n-(this.visibleHeight-this.height)):Math.round(n)}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){if(this.cellType==="footer")return this.renderFooter&&this.renderFooterType==="default"||this.text===null||this.text===void 0?"":this.text;{if(this.rowspan===0||this.colspan===0||this.render&&this.renderType==="default"&&!this.mixedRender)return"";const e=this.getImage("selection");return this.type==="index-selection"&&e&&e.visible||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,i=this.drawY-this.ctx.body.y;if(this.fixed==="left"?e=this.drawX:this.fixed==="right"&&(e=this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=this.drawY-this.ctx.footer.y),this.autoRowHeight&&this.render&&this.verticalAlign==="middle"){const o=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);if(o<this.visibleHeight&&o>0){const n=(this.visibleHeight-o)/2;i=i+n}}this.autoRowHeight&&this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex)===0&&(e=-99999,i=-99999);let s={};return this.rowspan===0&&(s={display:"none"}),{position:"absolute",overflow:"hidden",left:`${Math.round(e-1)}px`,top:`${Math.round(i-1)}px`,width:`${this.visibleWidth}px`,height:this.autoRowHeight&&this.renderType==="default"?"auto":`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none",...s}}drawContainer(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx,{drawX:o,drawY:n}=this;e.drawRect(o,n,this.visibleWidth,this.visibleHeight,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor}),e.drawRect(o,n,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor}),s||this.ctx.paint.drawLine([o,n+this.visibleHeight,o+this.visibleWidth,n+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:o}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:n,yArr:a}=this.ctx.selector,l=n[1],c=a[1],{colIndex:d,rowIndex:f,drawX:u,drawY:x}=this;if(d===l&&f===c){const E=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(u+this.width-E,x+this.height-E,6,6,{borderColor:o,fillColor:e})}}draw(){this.drawTreeLine(),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let o=e;o<e+i;o++){const n=this.ctx.header.leafCellHeaders[o];s+=n.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s,CELL_LINE_HEIGHT:o}=this.ctx.config,{placeholder:n}=this.column;let a=this.displayText,l=this.drawTextColor;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&n&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=n,l=s),["",null,void 0].includes(a))return!1;typeof a!="string"&&(a=`${a}`);const d=`${a}_${this.drawTextWidth}_${this.drawTextFont}`;return this.ellipsis=this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:l,autoRowHeight:this.autoRowHeight,lineHeight:o,maxLineClamp:this.maxLineClamp,cacheTextKey:d,layoutCallback:f=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.rowIndex}-${this.colIndex}`,f)}}),this.ellipsis}drawImage(){this.getImages().forEach((e,i)=>{if(e.visible&&e.source){if(i==="hover"){const{CELL_HOVER_ICON_BG_COLOR:s,CELL_HOVER_ICON_BORDER_COLOR:o}=this.ctx.config;e.drawWrapper(this.ctx,{borderColor:o,fillColor:s})}this.ctx.paint.drawImage(e.source,e.x,e.y,e.width,e.height)}})}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:o,yArrCopy:n}=this.ctx.selector;this.drawBorder({xArr:o,yArr:n,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[a,l]=i,[c,d]=s;!(a===l&&c===d)&&this.colIndex>=a&&this.colIndex<=l&&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,o=this.drawX,n=this.drawY,a=[o+s-e-.5,n,o+s-.5,n,o+s-.5,n+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:n,height:a,width:l}=this;let c=i,d=s;const{xArr:f,yArr:u,lineDash:x=[],borderWidth:g=1,borderColor:E,fillColor:w}=e,m=f[0],y=f[1],b=u[0],p=u[1];if(n>=m&&n<=y&&o===b){const C=n===y?1:0,I=n===m?1:0;this.ctx.paint.drawLine([c+I,d+1,c+l-C,d+1],{borderColor:E,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(n===y&&o>=b&&o<=p){const C=o===b?1:0,I=o===p?1:0;this.ctx.paint.drawLine([c+l-1,d+C,c+l-1,d+a-I],{borderColor:E,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(n>=m&&n<=y&&o===p){const C=n===y?1:0,I=n===m?1:0;this.ctx.paint.drawLine([c+I,d+a-1,c+l-C,d+a-1],{borderColor:E,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(n===m&&o>=b&&o<=p){const C=o===p?1:0,I=o===b?1:0;this.ctx.paint.drawLine([c+1,d+I,c+1,d+a-C],{borderColor:E,fillColor:w,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}}}class Se{constructor(t,e){r(this,"ctx");r(this,"data");r(this,"columns");r(this,"footerData",[]);r(this,"rowKeyMap",new Map);r(this,"colIndexKeyMap",new Map);r(this,"headerMap",new Map);r(this,"rowIndexRowKeyMap",new Map);r(this,"rowKeyRowIndexMap",new Map);r(this,"checkboxKeyMap",new Map);r(this,"selectionMap",new Map);r(this,"expandMap",new Map);r(this,"originalDataMap",new Map);r(this,"changedDataMap",new Map);r(this,"validationErrorMap",new Map);r(this,"itemRowKeyMap",new WeakMap);r(this,"bufferData",[]);r(this,"customHeader",{fixedData:{},sortData:{},hideData:{},resizableData:{}});r(this,"overlayerAutoHeightMap",new Map);r(this,"maxRowHeightCellMap",new Map);r(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});r(this,"sumHeight",0);r(this,"filterMethod");r(this,"positions",[]);r(this,"sortState",new Map);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.init()}init(t=!0){this.ctx.paint.clearTextCache(),this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear(),this.maxRowHeightCellMap.clear();const e=this.getColumns(),i=tt(e);if(this.ctx.hasSelection=i.some(s=>s.type==="selection"),this.ctx.hasTree=i.some(s=>{var o;return(o=s.type)==null?void 0:o.includes("tree")}),t){this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear();const{ROW_KEY:s}=this.ctx.config;s?(this.ctx.hasSelection||this.selectionMap.clear(),this.ctx.hasTree||this.expandMap.clear()):(this.selectionMap.clear(),this.expandMap.clear())}this.itemRowKeyMap=new WeakMap,this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}initData(t,e=0,i=[]){const s=t.length,{ROW_KEY:o="",DEFAULT_EXPAND_ALL:n,CELL_HEIGHT:a,SELECTABLE_METHOD:l,CHECKBOX_KEY:c,TREE_CHILDREN_KEY:d}=this.ctx.config;t.forEach((f,u)=>{var b;d!=="children"&&(f.children=f[d]);const x=f[o],g=x??qt();this.itemRowKeyMap.set(f,g);const E=f._height||a,w=f._readonly;let m=!0;if(typeof l=="function"&&(m=l),c){const p=f[c];if(this.checkboxKeyMap.has(p)){const C=this.checkboxKeyMap.get(p)||[];C.push(g),this.checkboxKeyMap.set(p,C)}else this.checkboxKeyMap.set(p,[g])}this.selectionMap.set(g,{key:c?f[c]:g,row:f,check:((b=this.selectionMap.get(g))==null?void 0:b.check)||!1});const y=n||this.expandMap.get(g)||f._expand||!1;this.expandMap.set(g,y),this.rowKeyMap.set(g,{readonly:w,index:u,rowIndex:u,level:e,height:E,calculatedHeight:-1,check:!1,selectable:m,expand:y,expandLazy:!1,hasChildren:f._hasChildren||(Array.isArray(f.children)?f.children.length>0:!1),expandLoading:!1,item:f,parentRowKeys:i,parentRowKey:i[i.length-1]||"",isLastChild:u===s-1}),Array.isArray(f.children)&&f.children.length&&this.initData(f.children,e+1,[...i,g])})}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()}setBatchRowHeight(t){t.forEach(({rowIndex:e,height:i})=>{const s=this.rowIndexRowKeyMap.get(e);if(s){const o=this.rowKeyMap.get(s);o.height=i,o.item._height=i}}),this.clearBufferData()}setBatchCalculatedRowHeight(t){return t.every(({height:i,rowIndex:s})=>this.getPositionForRowIndex(s).calculatedHeight===i)?!1:(t.forEach(({rowIndex:i,height:s})=>{const o=this.rowIndexRowKeyMap.get(i);if(o){const n=this.rowKeyMap.get(o),{height:a=-1}=this.getMaxRowHeightItem(o)||{};n.calculatedHeight=Math.max(s,a)}}),this.clearBufferData(),this.getData(),!0)}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}generateColumns(t){const e=i=>i.map(s=>{var c,d,f,u,x,g,E,w;const o=s.children&&Array.isArray(s.children)?e(s.children):void 0,n={hide:(d=(c=this.customHeader)==null?void 0:c.hideData)==null?void 0:d[s.key],fixed:(u=(f=this.customHeader)==null?void 0:f.fixedData)==null?void 0:u[s.key],sort:(g=(x=this.customHeader)==null?void 0:x.sortData)==null?void 0:g[s.key],width:(w=(E=this.customHeader)==null?void 0:E.resizableData)==null?void 0:w[s.key]},a={};for(const[m,y]of Object.entries(n))y!==void 0&&(a[m]=y);const l=o&&o.every(m=>m.hide);return{...s,children:o,hide:l||(typeof s.hide=="function"?s.hide(s):s.hide),...a}});return e(t)}getColumns(){return this.generateColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.init()}getOriginalData(){return this.data}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=o=>{o==null||o.forEach(n=>{t.push(n);const a=this.itemRowKeyMap.get(n),{expand:l,hasChildren:c,height:d,calculatedHeight:f}=this.rowKeyMap.get(a),u=this.sumHeight,x=Math.max(f,d);this.sumHeight+=x,this.rowIndexRowKeyMap.set(e,a),this.rowKeyRowIndexMap.set(a,e),this.positions.push({top:u,height:x,bottom:this.sumHeight,calculatedHeight:f}),e+=1,l&&c&&i(n.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;if(typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),this.sortState.size){const o=Array.from(this.sortState.entries()).sort((n,a)=>n[1].timestamp-a[1].timestamp);s=this.sortDataRecursive(s,o)}return 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}getSortState(t){return this.sortState.get(t)||{direction:"none",timestamp:0}}setSortState(t,e){const i=Date.now();this.ctx.config.SORT_STRICTLY&&this.sortState.clear(),e==="none"?this.sortState.delete(t):this.sortState.set(t,{direction:e,timestamp:i}),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}clearSort(){this.sortState.clear(),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}sortDataRecursive(t,e){let i=[...t];for(const[s,{direction:o}]of e){if(o==="none")continue;const n=this.getColumnByKey(s);!n||!n.column.sortBy||(i=this.applySingleColumnSort(i,s,o,n.column.sortBy))}return i.map(s=>(s.children&&Array.isArray(s.children)&&(s.children=this.sortDataRecursive(s.children,e)),s))}applySingleColumnSort(t,e,i,s){return t.sort((o,n)=>{const a=o[e],l=n[e];let c=0;if(typeof s=="function")c=s(o,n);else if(s==="number"){const d=Number(a)||0,f=Number(l)||0;c=d-f}else if(s==="string"){const d=String(a||""),f=String(l||"");c=d.localeCompare(f)}else s==="date"&&(c=_e(a,l));return i==="asc"?c:-c})}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.expandMap.set(t,e),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){this.expandMap.clear(),t.forEach(i=>{const s=this.rowKeyMap.get(i);this.expandMap.set(i,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.expandMap.clear(),this.rowKeyMap.forEach(e=>{e.expand=t,this.expandMap.set(e.key,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,!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),o=this.colIndexKeyMap.get(e);return s===void 0||o===void 0?null:{rowKey:s,key:o,value:this.getItemValue(s,o)}}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,i=!0,s="none"){let o=[],n=i;const a=new Map,l=[];let c=[];for(const g of t){const{rowKey:E,key:w}=g;let m=g.value;const y=this.getRowDataItemForRowKey(E),b=this.getItemValue(E,w),p=this.getVirtualBodyCellByKey(E,w),C={...g,oldValue:b,row:y};if((p==null?void 0:p.type)==="number")if(["",void 0,null].includes(m))m=null;else if(/^-?\d+(\.\d+)?$/.test(String(m))){const I=Te(m);if(typeof p.precision=="number"&&p.precision>=0&&I>p.precision){const v=10**p.precision;m=Math.round(Number(m)*v)/v;const T=this.ctx.locale.getText("numberTruncated",{precision:p.precision});l.push({...C,column:p==null?void 0:p.column,code:"ERR_NUMBER_PRECISION",message:T})}else if(typeof p.min=="number"&&Number(m)<p.min){const v=this.ctx.locale.getText("numberMin",{min:p.min});m=p.min,l.push({...C,column:p==null?void 0:p.column,code:"ERR_NUMBER_MIN",message:v})}else if(typeof p.max=="number"&&Number(m)>p.max){const v=this.ctx.locale.getText("numberMax",{max:p.max});m=p.max,l.push({...C,column:p==null?void 0:p.column,code:"ERR_NUMBER_MAX",message:v})}else m=Number(m)}else m=b,l.push({...C,column:p==null?void 0:p.column,code:"ERR_INVALID_NUMBER",message:this.ctx.locale.getText("invalidNumber")});else if((p==null?void 0:p.editorType)==="text"&&typeof p.maxlength=="number"&&String(m).length>p.maxlength){m=String(m).slice(0,p.maxlength);const I=this.ctx.locale.getText("stringMaxlength",{maxlength:p.maxlength});l.push({...C,column:p==null?void 0:p.column,code:"ERR_STRING_MAXLENGTH",message:I})}m!==b&&c.push({...g,value:m,oldValue:b,row:y})}if(l.length){const g={code:"ERR_BATCH_SET_ITEM_VALUE",message:this.ctx.locale.getText("batchSetItemValueError"),data:l};this.ctx.emit("error",g)}if(!c.length)return;const{BEFORE_VALUE_CHANGE_METHOD:d}=this.ctx.config;s==="none"&&typeof d=="function"&&(c=await d(c),n=!1);const f=[];c.forEach(g=>{f.push(this.getValidator(g.rowKey,g.key));const{value:E,rowKey:w,key:m,row:y}=g,b=this.getItemValue(w,m);a.set(w,y),this.setItemValue(w,m,E,!1,!1,!1,n),o.push({rowKey:w,key:m,oldValue:b,newValue:E})});const u=Array.from(a.values());await Promise.all(f),this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData());const x=c.map(g=>{const E=!!this.getValidationError(g.rowKey,g.key).length;return{...g,errorTip:E}});this.ctx.emit("change",x,u),e&&this.ctx.history.pushState({changeList:o,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,o=!1,n=!1,a=!0){if(!this.rowKeyMap.has(t))return{};const{item:l}=this.rowKeyMap.get(t);let c=l[e],d=i;if(a&&this.ctx.database.getReadonly(t,e))return{oldValue:c,newValue:c};l[e]!==null&&typeof l[e]=="object"&&(c=JSON.parse(JSON.stringify(l[e])));const f=`${t}​_${e}`;this.originalDataMap.has(f)||this.originalDataMap.set(f,c);const u=this.originalDataMap.get(f),x=this.getRowDataItemForRowKey(t),g={rowKey:t,key:e,value:d,oldValue:c,row:x};if(n){if(d===c)return{oldValue:c,newValue:c};this.batchSetItemValue([g],s,!1),this.ctx.emit("editChange",{...g,originalValue:u})}else this.changedDataMap.set(f,d),l[e]=d;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{...g,originalValue:u}),o&&this.ctx.emit("draw"),{oldValue:c,newValue:d}}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),o=s[i];this.checkboxKeyMap.has(o)&&(this.checkboxKeyMap.get(o)||[]).forEach(a=>{const l=this.selectionMap.get(a);l&&(l.check=e)})}}toggleRowSelection(t,e){const i=this.rowKeyMap.get(t),s=this.selectionMap.get(t);if(!s)return;e==="selection-tree"||e==="tree-selection"?this.toggleTreeSelection(t):(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check)),this.ctx.emit("toggleRowSelection",i);const o=this.getSelectionRows();this.ctx.emit("selectionChange",o),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}toggleTreeSelection(t){const e=this.getTreeSelectionState(t),i=this.ctx.config.TREE_SELECT_MODE;if(i==="auto")e.checked&&!e.indeterminate?(this.clearTreeSelectionRecursive(t),this.setRowSelection(t,!1,!1)):(this.selectTreeSelectionRecursive(t),this.setRowSelection(t,!0,!1));else if(i==="cautious")e.checked&&!e.indeterminate?(this.clearTreeSelectionRecursive(t),this.setRowSelection(t,!1,!1)):(this.selectTreeSelectionRecursive(t),this.setRowSelection(t,!0,!1));else if(i==="strictly"){const s=this.selectionMap.get(t);s&&(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check))}this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}selectTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelectionByParent(i,!0),this.selectTreeSelectionRecursive(i)})}clearTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelectionByParent(i,!1),this.clearTreeSelectionRecursive(i)})}updateParentTreeSelection(t){const e=this.getTreeParent(t);if(!e)return;const s=this.getTreeChildren(e).map(c=>this.selectionMap.get(c)),o=s.filter(c=>c==null?void 0:c.check).length,n=s.length;let a=!1;n>0&&(o===0?a=!1:o===n||this.ctx.config.TREE_SELECT_MODE==="auto"?a=!0:this.ctx.config.TREE_SELECT_MODE==="cautious"&&(a=!1));const l=this.selectionMap.get(e);l&&l.check!==a&&(l.check=a,this.setRowSelectionByCheckboxKey(e,a),this.updateParentTreeSelection(e))}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),(this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious")&&this.updateParentTreeSelection(t),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}setRowSelectionByParent(t,e){const i=this.selectionMap.get(t);i&&(i.check=e,this.setRowSelectionByCheckboxKey(t,i.check))}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}getTreeSelectionState(t){if(!this.getRowForRowKey(t))return{checked:!1,indeterminate:!1};const i=this.selectionMap.get(t),s=(i==null?void 0:i.check)||!1;if(this.getTreeChildren(t).length===0)return{checked:s,indeterminate:!1};let n=!1,a=s;if(this.ctx.config.TREE_SELECT_MODE==="auto"){const c=w=>{const m=this.getTreeChildren(w);let y=[];for(const b of m)y.push(b),y.push(...c(b));return y},f=c(t).map(w=>this.selectionMap.get(w)),u=f.filter(w=>w==null?void 0:w.check).length,x=f.length,g=u>0;n=g&&!(u===x),a=s||g,s&&x>0&&u===0&&(a=!1,n=!1)}else if(this.ctx.config.TREE_SELECT_MODE==="cautious"){const c=w=>{const m=this.getTreeChildren(w);let y=[];for(const b of m)y.push(b),y.push(...c(b));return y},f=c(t).map(w=>this.selectionMap.get(w)),u=f.filter(w=>w==null?void 0:w.check).length,x=f.length,g=u>0,E=u===x;n=g&&!E,a=s||E,s&&x>0&&u===0&&(a=!1,n=!1)}else this.ctx.config.TREE_SELECT_MODE==="strictly"&&(n=!1,a=s);return{checked:a,indeterminate:n}}getTreeChildren(t){const e=this.getRowForRowKey(t);if(!e||!e.item||!e.item.children)return[];const i=[],s=o=>{for(const n of o){const a=this.getRowKeyByItem(n);a&&i.push(a),n.children&&n.children.length>0&&s(n.children)}};return s(e.item.children),i}getTreeParent(t){const e=(i,s)=>{for(const o of i){const n=this.getRowKeyByItem(o);if(o.children)for(const a of o.children){if(this.getRowKeyByItem(a)===s)return n;const c=e(o.children,s);if(c)return c}}return null};return e(this.data,t)}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.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious"?this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;if(typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o){const n=this.selectionMap.get(s);n&&(n.check=!0,this.setRowSelectionByCheckboxKey(s,!0))}}):this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o&&this.setRowSelection(s,!0,!1)});const e=this.getSelectionRows();this.ctx.emit("toggleAllSelection",e),this.ctx.emit("selectionChange",e),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){const e=this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious";t?e?this.rowKeyMap.forEach((s,o)=>{const n=this.selectionMap.get(o);n&&(n.check=!1,this.setRowSelectionByCheckboxKey(o,!1))}):this.rowKeyMap.forEach((s,o)=>{this.setRowSelection(o,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((s,o)=>{this.selectionMap.set(o,{check:!1,row:s.item,key:o})}));const i=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",i),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,o=0;const n=this.selectionMap.size,a=Array.from(this.selectionMap.values()).some(u=>u.check);this.rowKeyMap.forEach((u,x)=>{var E;(E=this.selectionMap.get(x))!=null&&E.check&&(s+=1);let g=u.selectable;typeof g=="function"&&(g=g({row:u.item,rowIndex:u.rowIndex})),g&&(o+=1)});const l=n>i&&s===0&&a,c=o&&o>s&&s>0||l,d=o!==0,f=!!o&&o===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),o=i.split("​_")[0],n=i.split("​_")[1];s!==e&&t.push({rowKey:o,colKey:n,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(o),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const o=this.originalDataMap.get(s),n=s.split("​_")[0];o!==i&&t.add(n)});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),o=this.changedDataMap.get(i);return s!==o}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0,calculatedHeight: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),o=this.headerMap.get(e);if(!s||!o)return!0;const n=s.readonly,a=o.readonly,{BODY_CELL_READONLY_METHOD:l}=this.ctx.config;if(typeof l=="function"&&o){const d=l({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:o.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return a||n}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return this.ctx.database.getReadonly(t,e)?new Promise(s=>{s([])}):new Promise(s=>{const o=this.rowKeyMap.get(t),n=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:a}=this.ctx.config;if(o===void 0||n===void 0)return s([]);const l=n.column;let c=l.rules;if(typeof a=="function"){const f=a({row:o.item,rowIndex:o.rowIndex,colIndex:n.colIndex,column:l,value:this.getItemValue(t,e)});f&&(c=f)}if(c){const d={row:o.item,rowIndex:o.rowIndex,colIndex:n.colIndex,column:l,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},u=new Ee(c).validate(d);this.setValidationError(t,e,u),s(u)}else this.clearValidationError(t,e),s([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const o=this.positions[t+s];o&&(i+=o.height)}return i}getSpanInfo(t){const{rowIndex:e,key:i,rowKey:s,row:o,value:n,colIndex:a,relationRowKeys:l,relationColKeys:c,rowspan:d,height:f,width:u,colspan:x,mergeRow:g,mergeCol:E}=t;if(d===1&&x===1)return{xArr:[a,a],yArr:[e,e],rowspan:d,colspan:x,height:f,width:u,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:o,value:n}]};let w=e,m=e,y=a,b=a,p=[],C=0,I=0,v=0,T=0;if(d!==1&&g){T=u;const _=l.reduce((R,S)=>{const O=this.getItemValue(s,S)??"";return`${R}${O}`},"");for(let R=e-1;R>=0;R--){const S=this.rowIndexRowKeyMap.get(R)||"",O=l.reduce((M,L)=>{const H=this.getItemValue(S,L)??"";return`${M}${H}`},"");if(_===O)w=R;else break}for(let R=e;R<=this.ctx.maxRowIndex;R++){const S=this.rowIndexRowKeyMap.get(R)||"",O=l.reduce((M,L)=>{const H=this.getItemValue(S,L)??"";return`${M}${H}`},"");if(_===O)m=R;else break}for(let R=w;R<e;R++){const{height:S}=this.positions[R];C+=S}for(let R=w;R<=m;R++){const{height:S}=this.positions[R];v+=S;const O=this.rowIndexRowKeyMap.get(R)||"",{item:M}=this.rowKeyMap.get(O),L=this.getItemValue(O,i);p.push({rowKey:O,key:i,value:L,row:M})}}if(x!==1&&E){v=f;for(let _=a-1;_>=0;_--){const R=this.getColumnByColIndex(_);if(!R)break;const S=this.getItemValue(s,i),O=this.getItemValue(s,R.key);if(S===O&&c.includes(R.key))y=_;else break}for(let _=a;_<=this.ctx.maxColIndex;_++){const R=this.getColumnByColIndex(_);if(!R)break;const S=this.getItemValue(s,i),O=this.getItemValue(s,R.key);if(S===O&&c.includes(R.key))b=_;else break}for(let _=y;_<a;_++){const R=this.getColumnByColIndex(_);if(!R)break;I+=R.width||100}for(let _=y;_<=b;_++){const R=this.getColumnByColIndex(_);if(!R)break;T+=R.width||100,p.push({rowKey:s,key:R.key,value:this.getItemValue(s,R.key),row:o})}}return{xArr:[y,b],yArr:[w,m],rowspan:d,colspan:x,height:v,width:T,offsetTop:C,offsetLeft:I,dataList:p}}setValidationErrorByRowKey(t,e,i){const s=`${t}​_${e}`,o=this.getRowForRowKey(t),n=o==null?void 0:o.rowIndex,a=this.getColumnByKey(e);if(!t||!a||!o)return;const l=this.getItemValue(t,e),c=[{key:e,rowKey:t,rowIndex:n,colIndex:a.colIndex,column:a.column,row:o,value:l,message:i,field:e,fieldValue:l}];this.validationErrorMap.set(s,c)}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,i=!0){const s=this.getColumnByColIndex(e),o=this.getRowForRowIndex(t);return!s||!o?void 0:new ie(this.ctx,t,e,0,0,0,0,s,o.item,"body",i)}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 o=t[0];o<=t[1];o++){const n=this.getVirtualBodyCell(s,o);if(n&&(n.rowspan!==1||n.colspan!==1)){i=!0;break}}return i}calculateMaxTreeDepth(t,e=0){let i=e;return t.forEach(s=>{if(Array.isArray(s.children)&&s.children.length>0){const o=this.calculateMaxTreeDepth(s.children,e+1);i=Math.max(i,o)}}),i}setOverlayerAutoHeightMap(t){this.overlayerAutoHeightMap=t}getOverlayerAutoHeightMap(){return this.overlayerAutoHeightMap}getOverlayerAutoHeight(t,e){const i=`${t}​_${e}`;return this.overlayerAutoHeightMap.get(i)||0}setCustomHeader(t,e=!1){if(["fixedData","sortData","hideData","resizableData"].forEach(i=>{const s=t[i];s!==void 0&&(this.customHeader[i]=s)}),!e){const i=this.clearCustomHeaderInvalidValues(this.columns);this.ctx.emit("customHeaderChange",i)}}resetCustomHeader(){this.customHeader={},this.ctx.emit("resetHeader"),this.ctx.emit("customHeaderChange",this.customHeader)}getCustomHeader(){return this.customHeader}setCustomHeaderResizableData(t,e){let{resizableData:i={}}=this.customHeader;i[t]=e,this.setCustomHeader({resizableData:i})}setCustomHeaderHideData(t,e){let{hideData:i={}}=this.customHeader;t.forEach(s=>{i[s]=e}),this.setCustomHeader({hideData:i}),this.ctx.emit("resetHeader")}setCustomHeaderFixedData(t,e){let{fixedData:i={}}=this.customHeader;t.forEach(s=>{i[s]=e}),this.setCustomHeader({fixedData:i}),this.ctx.emit("resetHeader")}clearCustomHeaderInvalidValues(t){const e=(s,o={})=>{s.forEach(n=>{n.children&&n.children.length>0&&e(n.children,o);const a=(l,c)=>{var f,u;const d=(f=this.customHeader[l])==null?void 0:f[n.key];d!==void 0&&d!==c&&(o[l]||(o[l]={}),o[l][n.key]=d,l==="fixedData"&&!d&&!c&&((u=o[l])==null||delete u[n.key]))};a("fixedData",n.fixed),a("sortData",n.sort),a("hideData",n.hide),a("resizableData",n.width)})};let i={};return e(t,i),i}setMaxRowHeightItem(t,e,i){this.maxRowHeightCellMap.set(t,{key:e,height:i})}getMaxRowHeightItem(t){return this.maxRowHeightCellMap.get(t)}clearChangeData(){this.changedDataMap.clear()}}class Oe{constructor(t){r(this,"ctx");r(this,"history",[]);r(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(o=>({rowKey:o.rowKey,key:o.key,value:o.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1,!1,"back"),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,!1,"forward")}}clear(){this.history=[],this.historyIndex=-1}}class Le{constructor(t){r(this,"eventTasks",new Set);r(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)),this.bind(document,"selectionchange",this.selectionchange.bind(this))}selectionchange(){this.ctx.domSelectionStr="";const t=window.getSelection();t&&t.toString()&&(this.ctx.domSelectionStr=t.toString())}clearDomSelection(){const t=window.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()}destroy(){Array.from(this.eventTasks).forEach(({target:e,name:i,fn:s,options:o})=>{this.unbind(e,i,s,o)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){this.clearDomSelection(),t.button===0&&(this.ctx.mousedown=!0),this.ctx.emit("mousedown",t)}handleMousemove(t){const e=t,i=this.ctx.containerElement.getBoundingClientRect(),s=e.clientX-i.left,o=e.clientY-i.top;this.ctx.mouseX=s,this.ctx.mouseY=o,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.dragHeaderIng||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.add({target:t,name:e,fn:i,options:s})}unbind(t,e,i,s){t.removeEventListener(e,i,s);for(const o of this.eventTasks)if(o.target===t&&o.name===e&&o.fn===i){this.eventTasks.delete(o);break}}}class Me{constructor(){r(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 Ae{constructor(t){r(this,"ctx");r(this,"textCacheMap",new Map);const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}getCtx(){return this.ctx}clearTextCache(){this.textCacheMap.clear()}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,o){const{fillColor:n,side:a,shadowWidth:l,colorStart:c,colorEnd:d}=o;this.ctx.save(),n&&(this.ctx.fillStyle=n,this.ctx.fillRect(t,e,i,s));let f;switch(a){case"left":f=this.ctx.createLinearGradient(t-l,e,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-l,e,l,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+l,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,l,s);break;case"top":f=this.ctx.createLinearGradient(t,e-l,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-l,i,l);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+l),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,l);break;default:console.error("Invalid side specified for shadow");break}this.ctx.restore()}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 o=2;o<t.length;o+=2)this.ctx.lineTo(t[o]-.5,t[o+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=e.lineDashOffset??0,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,o){this.ctx.save(),this.ctx.drawImage(t,e,i,s,o),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:o=1,borderColor:n,fillColor:a,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),a!==void 0&&(this.ctx.fillStyle=a),n!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=n),l===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[c,d,f,u]=typeof l=="number"?[l,l,l,l]:l;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)}a!==void 0&&this.ctx.fill(),n!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,n={}){var b,p,C;this.ctx.save();const{font:a="12px Arial",align:l="center",color:c="#495060",padding:d=0,verticalAlign:f="middle",maxLineClamp:u=1,autoRowHeight:x=!1,offsetLeft:g=0,offsetRight:E=0}=n;if(this.ctx.font=a,this.ctx.fillStyle=c,["",null,void 0].includes(t))return this.ctx.restore(),!1;const m=parseInt(((b=a.match(/\d+/))==null?void 0:b[0])||"12")*(n.lineHeight||1.2),y=this.buildTextLayout(t,e,i,s,o,{font:a,color:c,align:l,padding:d,verticalAlign:f,maxLineClamp:u,autoRowHeight:x,lineHeight:m,offsetLeft:g,offsetRight:E});if(this.ctx.textBaseline="top",this.ctx.textAlign="left",y.lines.forEach(I=>{this.ctx.fillText(I.text,I.drawX,I.drawY)}),n.textCallback&&y.lines.length){const I=y.lines.reduce((S,O)=>Math.max(S,O.width),0),v=Math.round(I);let T=((p=y.lines[0])==null?void 0:p.drawX)??e+d+g,_=T+v;l==="center"?(T=e+s/2-v/2,_=e+s/2+v/2):l==="right"&&(T=e+s-d-E-v,_=e+s-d-E);const R={x:((C=y.lines[0])==null?void 0:C.drawX)??T,y:y.contentY,width:v,height:y.lines.length*m,left:T,right:_,top:y.contentY,bottom:y.contentY+y.lines.length*m};n.textCallback(R)}return n.layoutCallback&&n.layoutCallback(y),this.ctx.restore(),y.ellipsis}buildTextLayout(t,e,i,s,o,n){const{font:a,color:l,align:c,padding:d,verticalAlign:f,maxLineClamp:u,autoRowHeight:x,lineHeight:g,offsetLeft:E,offsetRight:w}=n;this.ctx.save(),this.ctx.font=a;const m=s-d*2-E-w,y=m,b=o-d*2,p=Array.from(t);let C=this.wrapTextToLines(t,m);const I=Math.round(b/g);let v=Math.min(C.length,Math.max(I,1));u==="auto"&&x?v=C.length:typeof u=="number"&&u<v&&u!==1?v=u:(u===1&&(C=[{items:p.map((M,L)=>({char:M,sourceIndex:L})),text:t,caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}],v=1),u==="auto"&&I===1&&(C=[{items:p.map((M,L)=>({char:M,sourceIndex:L})),text:t,caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}],v=1));let T=!1;const _=C.slice(0,v);if(C.length>v){T=!0;const M=C.slice(v-1),L=this.buildEllipsisLine(M,s,d);L.lineIndex=v-1,_[v-1]=L}else if(v>0){const M=v-1,L=C.slice(M),H=L.map(A=>A.text).join(""),{ellipsis:D}=this.handleEllipsis(H,s,d,a);if(D){T=!0;const A=this.buildEllipsisLine(L,s,d);A.lineIndex=M,_[M]=A}}const R=_.length*g;let S=i+d;f==="middle"?S=i+(o-R)/2:f==="bottom"&&(S=i+o-R-d);const O=[];return _.forEach((M,L)=>{M.lineIndex=L;const H=this.buildLineSegments(M),D=H.reduce((N,Ct)=>N+Ct.width,0);let A=e+d+E;c==="center"?A=e+(s-D)/2:c==="right"&&(A=e+s-d-w-D);const k=S+L*g;M.drawX=A,M.drawY=k,M.width=D,M.segments=H,H.forEach(N=>{N.sourceIndex<0||O.push({char:N.char,index:N.sourceIndex,line:L,x:A+N.x,y:k,width:N.width,height:g})})}),this.ctx.restore(),{text:t,chars:p,glyphs:O,lines:_,box:{x:e,y:i,width:s,height:o},contentBox:{x:e+d+E,y:i+d,width:y,height:b},contentY:S,lineHeight:g,font:a,color:l,align:c,ellipsis:T}}wrapTextToLines(t,e){if(!t)return[{items:[],text:"",caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}];const i=Array.from(t),s=[];let o=[],n=0,a=0;const l=c=>{const d=o.map(f=>f.char).join("");s.push({items:o,text:d,caretIndex:a,lineIndex:s.length,drawX:0,drawY:0,width:0,segments:[]}),o=[],n=0,a=c};for(let c=0;c<i.length;c++){const d=i[c];if(d===`
5
- `){l(c+1);continue}const f=this.ctx.measureText(d).width;if(n+f>e&&o.length>0){l(o[o.length-1].sourceIndex+1),o.push({char:d,sourceIndex:c}),n=f;continue}o.push({char:d,sourceIndex:c}),n+=f}return(o.length>0||s.length===0)&&l(i.length),s}buildEllipsisLine(t,e,i){var d;const s=t.flatMap(f=>f.items),o=s.map(f=>f.char).join(""),{_text:n,ellipsis:a}=this.handleEllipsis(o,e,i,this.ctx.font),l=a?n.slice(0,-3):n,c=[];for(let f=0;f<l.length;f++){const u=s[f];if(!u)break;c.push({char:u.char,sourceIndex:u.sourceIndex})}return a&&c.push({char:".",sourceIndex:-1,ellipsis:!0},{char:".",sourceIndex:-1,ellipsis:!0},{char:".",sourceIndex:-1,ellipsis:!0}),{items:c,text:n,caretIndex:((d=t[0])==null?void 0:d.caretIndex)??0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}}buildLineSegments(t){const e=[];let i=0;return t.items.forEach((s,o)=>{const n=this.ctx.measureText(s.char).width;e.push({char:s.char,itemIndex:o,sourceIndex:s.sourceIndex,x:i,width:n}),i+=n}),e}wrapText(t,e,i=""){if(!t)return[""];if(i&&this.textCacheMap.has(i))return this.textCacheMap.get(i)||[""];const s=[],o=t.split(`
6
- `);for(const a of o){if(a===""){s.push("");continue}const l=a.split("");let c="";for(const d of l){const f=c+d;this.ctx.measureText(f).width<=e?c=f:c?(s.push(c),c=d):(s.push(d),c="")}c&&s.push(c)}const n=s.length>0?s:[""];return i&&this.textCacheMap.set(i,n),n}calculateTextHeight(t="",e,i={}){var E;const{font:s="12px Arial",padding:o=0,align:n="center",color:a="#495060",maxLineClamp:l=1,cacheTextKey:c=""}=i;this.ctx.save(),this.ctx.font=s,this.ctx.fillStyle=a,this.ctx.textAlign=n;const d=parseInt(((E=s.match(/\d+/))==null?void 0:E[0])||"12"),f=d*(i.lineHeight||1.2),u=e-o*2,x=this.wrapText(t,u,c);let g=1;return l==="auto"?g=x.length:x.length>l?g=l:g=x.length,this.ctx.restore(),Math.max(Math.floor(g*f+o*2),Math.floor(d+o*2))}handleEllipsis(t,e,i=0,s="12px Arial"){this.ctx.save();let o=!1,n=t;if(this.ctx.font=s,t==null||t==="")return this.ctx.restore(),{_text:"",ellipsis:o};const a=this.ctx.measureText("...").width;if(e<=a+i*2)return this.ctx.restore(),{_text:"",ellipsis:!0};const l=this.ctx.measureText(t).width,c=e-i*2;if(l&&l>=c){o=!0;let d=0;for(let f=0;f<t.length;f++)if(d+=this.ctx.measureText(t[f]).width,d>=c-a){n=t.slice(0,f)+"...",o=!0;break}}return this.ctx.restore(),{_text:n,ellipsis:o}}}class Kt{constructor(t){r(this,"_config",{});r(this,"CSS_PREFIX","e-virt-table");r(this,"ICONS",[]);r(this,"ROW_KEY","");r(this,"DISABLED",!1);r(this,"HEADER_FONT","12px normal Arial");r(this,"BODY_FONT","12px normal Arial");r(this,"BORDER",!0);r(this,"STRIPE",!1);r(this,"STRIPE_COLOR","#fafafa");r(this,"BORDER_COLOR","#e1e6eb");r(this,"HEIGHT",0);r(this,"PLACEHOLDER_COLOR","#CDD0DC");r(this,"EMPTY_BODY_HEIGHT",120);r(this,"EMPTY_CUSTOM_STYLE",{});r(this,"EMPTY_TEXT","");r(this,"LOADING_TEXT","");r(this,"MAX_HEIGHT",1e3);r(this,"BORDER_RADIUS",8);r(this,"ENABLE_OFFSET_HEIGHT",!1);r(this,"OFFSET_HEIGHT",0);r(this,"HEADER_HEIGHT",36);r(this,"ENABLE_HEADER_STICKY",!1);r(this,"HEADER_BG_COLOR","#F8FAFF");r(this,"BODY_BG_COLOR","#FFF");r(this,"HEADER_TEXT_COLOR","#1D2129");r(this,"REQUIRED_COLOR","#F56C6C");r(this,"BODY_TEXT_COLOR","#4E5969");r(this,"FOOTER_TEXT_COLOR","#4E5969");r(this,"LOADING_ICON_SVG","");r(this,"LOADING_ICON_COLOR","#4E5969");r(this,"EXPAND_ICON_SVG","");r(this,"SHRINK_ICON_SVG","");r(this,"EXPAND_ICON_COLOR","#4E5969");r(this,"SHRINK_ICON_COLOR","#4E5969");r(this,"ERROR_TIP_ICON_COLOR","red");r(this,"ERROR_TIP_ICON_SIZE",6);r(this,"COLUMNS_ALIGN","left");r(this,"COLUMNS_VERTICAL_ALIGN","middle");r(this,"EXPAND_LAZY",!0);r(this,"DEFAULT_EXPAND_ALL",!1);r(this,"CELL_WIDTH",100);r(this,"CELL_HEIGHT",36);r(this,"CELL_PADDING",8);r(this,"CELL_HOVER_ICON_SIZE",14);r(this,"CELL_HOVER_ICON_BG_COLOR","#fff");r(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA");r(this,"SCROLLER_TRACK_SIZE",14);r(this,"SCROLLER_SIZE",8);r(this,"SCROLLER_COLOR","#dee0e3");r(this,"SCROLLER_TRACK_COLOR","#fff");r(this,"SCROLLER_FOCUS_COLOR","#bbbec4");r(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");r(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");r(this,"SELECT_ROW_COL_BG_COLOR","transparent");r(this,"AUTOFILL_POINT_BORDER_COLOR","#fff");r(this,"EDIT_BG_COLOR","#fcf6ed");r(this,"CHECKBOX_KEY","");r(this,"CHECKBOX_COLOR","rgb(82,146,247)");r(this,"FINDER_CELL_BG_COLOR","rgb(255,229,144)");r(this,"ENABLE_FINDER",!0);r(this,"CHECKBOX_SIZE",20);r(this,"CHECKBOX_DISABLED_SVG","");r(this,"CHECKBOX_DISABLED_COLOR","#F1F2F4");r(this,"CHECKBOX_CHECK_SVG","");r(this,"CHECKBOX_UNCHECK_SVG","");r(this,"CHECKBOX_UNCHECK_COLOR","#DDE0EA");r(this,"CHECKBOX_INDETERMINATE_SVG","");r(this,"CHECKBOX_CHECK_DISABLED_SVG","");r(this,"CHECKBOX_CHECK_DISABLED_COLOR","#DDE0EA");r(this,"ICON_EDIT_SVG","");r(this,"ICON_EDIT_COLOR","#4E5969");r(this,"ICON_SELECT_SVG","");r(this,"ICON_SELECT_COLOR","#4E5969");r(this,"SORT_STRICTLY",!0);r(this,"SORT_ASC_ICON_SVG","");r(this,"SORT_DESC_ICON_SVG","");r(this,"SORTABLE_ICON_SVG","");r(this,"SORT_ICON_COLOR","rgb(82,146,247)");r(this,"READONLY_COLOR","#fff");r(this,"READONLY_TEXT_COLOR","#4E5969");r(this,"ERROR_TIP_COLOR","#ED3F14");r(this,"FOOTER_BG_COLOR","#fafafa");r(this,"FOOTER_FIXED",!0);r(this,"FOOTER_POSITION","bottom");r(this,"CELL_FOOTER_HEIGHT",36);r(this,"ENABLE_SELECTOR",!0);r(this,"TREE_SELECT_MODE","auto");r(this,"TREE_CHILDREN_KEY","children");r(this,"TREE_INDENT",20);r(this,"TREE_ICON_SIZE",20);r(this,"TREE_LINE",!1);r(this,"TREE_LINE_COLOR","#e1e6eb");r(this,"ENABLE_EDIT_SINGLE_CLICK",!1);r(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);r(this,"SELECTOR_AREA_MIN_X",0);r(this,"SELECTOR_AREA_MAX_X_OFFSET",0);r(this,"SELECTOR_AREA_MAX_X",0);r(this,"SELECTOR_AREA_MIN_Y",0);r(this,"SELECTOR_AREA_MAX_Y",0);r(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);r(this,"SELECTOR_CELL_VALUE_TYPE","value");r(this,"ENABLE_AUTO_THEME",!0);r(this,"ENABLE_SELECTOR_SINGLE",!1);r(this,"ENABLE_SELECTOR_SPAN_COL",!0);r(this,"ENABLE_SELECTOR_SPAN_ROW",!0);r(this,"ENABLE_SELECTOR_ALL_ROWS",!0);r(this,"ENABLE_SELECTOR_ALL_COLS",!0);r(this,"ENABLE_MERGE_CELL_LINK",!1);r(this,"ENABLE_AUTOFILL",!1);r(this,"ENABLE_AUTOFILL_SPAN_COL",!0);r(this,"ENABLE_AUTOFILL_SPAN_ROW",!0);r(this,"ENABLE_CONTEXT_MENU",!1);r(this,"ENABLE_HEADER_CONTEXT_MENU",!1);r(this,"ENABLE_TEXT_SELECTION",!0);r(this,"ENABLE_COPY",!0);r(this,"ENABLE_PASTER",!0);r(this,"ENABLE_RESIZE_ROW",!0);r(this,"ENABLE_RESIZE_COLUMN",!0);r(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");r(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");r(this,"ENABLE_RESIZE_COLUMN_TEXT",!0);r(this,"RESIZE_COLUMN_TEXT_COLOR","#fff");r(this,"RESIZE_COLUMN_TEXT_BG_COLOR","rgb(82,146,247)");r(this,"RESIZE_ROW_MIN_HEIGHT",36);r(this,"RESIZE_COLUMN_MIN_WIDTH",40);r(this,"DRAG_TIP_BG_COLOR","rgba(82,146,247,0.1)");r(this,"DRAG_TIP_LINE_COLOR","rgb(82,146,247)");r(this,"ENABLE_KEYBOARD",!0);r(this,"ENABLE_HISTORY",!1);r(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);r(this,"HISTORY_NUM",50);r(this,"HIGHLIGHT_HOVER_ROW",!1);r(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");r(this,"HIGHLIGHT_SELECTED_ROW",!1);r(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");r(this,"TOOLTIP_BG_COLOR","#303133");r(this,"TOOLTIP_TEXT_COLOR","#fff");r(this,"TOOLTIP_ZINDEX",3e3);r(this,"TOOLTIP_CUSTOM_STYLE",{});r(this,"CONTEXT_MENU",[{value:"copy"},{value:"cut"},{value:"paste"},{value:"clearSelected"}]);r(this,"CUSTOM_BODY_CONTEXT_MENU",[]);r(this,"HEADER_CONTEXT_MENU",[{value:"fixedLeft"},{value:"fixedRight"},{value:"fixedNone"},{value:"hide"},{value:"visible"},{value:"resetHeader"}]);r(this,"CUSTOM_HEADER_CONTEXT_MENU",[]);r(this,"CELL_LINE_HEIGHT",1.2);r(this,"AUTO_ROW_HEIGHT",!1);r(this,"ENABLE_DRAG_COLUMN",!1);r(this,"ENABLE_DRAG_ROW",!1);r(this,"ENABLE_DRAG_ROW_CROSS_LEVEL",!1);r(this,"ENABLE_DRAG_ROW_CUSTOM",!1);r(this,"DRAG_ROW_TIP_LINE_COLOR","rgb(82,146,247)");r(this,"DRAG_ROW_ICON_SVG","");r(this,"DRAG_ROW_ICON_SIZE",18);r(this,"DRAG_ROW_ICON_COLOR","#bec4c7");r(this,"HEADER_CELL_STYLE_METHOD");r(this,"BODY_CELL_STYLE_METHOD");r(this,"FOOTER_CELL_STYLE_METHOD");r(this,"BODY_CELL_READONLY_METHOD");r(this,"BODY_CELL_FORMATTER_METHOD");r(this,"BODY_CELL_RULES_METHOD");r(this,"BODY_CELL_TYPE_METHOD");r(this,"BODY_CELL_EDITOR_METHOD");r(this,"BODY_CELL_RENDER_METHOD");r(this,"BODY_CELL_HOVER_ICON_METHOD");r(this,"SPAN_METHOD");r(this,"SELECTABLE_METHOD");r(this,"EXPAND_LAZY_METHOD");r(this,"BEFORE_VALUE_CHANGE_METHOD");r(this,"BEFORE_PASTE_DATA_METHOD");r(this,"BEFORE_AUTOFILL_DATA_METHOD");r(this,"BEFORE_SET_SELECTOR_METHOD");r(this,"BEFORE_SET_AUTOFILL_METHOD");r(this,"BEFORE_HEADER_CONTEXT_MENU_METHOD");r(this,"BEFORE_BODY_CONTEXT_MENU_METHOD");r(this,"BEFORE_COPY_METHOD");r(this,"BEFORE_DRAG_ROW_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=ve(i);s&&(t[e]=s)}}),Object.assign(this,t,this._config)}}const lt=`<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>\r
7
- `,Yt=`<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>
8
- `,Ft=`<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>
9
- `,Ot=`<svg t="1755138507987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5079" width="200" height="200"><path d="M512 938.688a42.688 42.688 0 0 1-35.072-18.432l-192-277.312A42.56 42.56 0 0 1 320 576h384a42.752 42.752 0 0 1 35.072 66.944l-192 277.312a42.688 42.688 0 0 1-35.072 18.432" fill="currentColor" p-id="2016"></path><path d="M704 448H320a42.752 42.752 0 0 1-35.072-66.944l192-277.312c16-23.04 54.208-23.04 70.144 0l192 277.312A42.56 42.56 0 0 1 704 448" fill="currentColor" p-id="2015"></path></svg>
10
- `,se=`<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>
11
- `,He=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2s.9-2 2-2s2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2s-2 .9-2 2s.9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2z" fill="currentColor"></path></svg>
12
- `,De=`<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" p-id="4709"></path></svg>
13
- `,Ne=`<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>
14
- `,ke=`<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" 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>
15
- `,Be=`<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>
16
- `,Xe=Ot.replace('fill="currentColor" p-id="2016"','fill="#bec4c7" p-id="2016"'),Ke=Ot.replace('fill="currentColor" p-id="2015"','fill="#bec4c7" p-id="2015"');class Ye{constructor(t){r(this,"ctx");r(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:se,color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:lt,color:"#4E5969"},{name:"shrink",configName:"SHRINK_ICON_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Ft,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_UNCHECK_COLOR",svg:De,color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:Yt,color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:Ne,color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_DISABLED_SVG",svg:Yt,color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",configColorName:"CHECKBOX_DISABLED_COLOR",svg:ke,color:"#F1F2F4"},{name:"icon-edit",configName:"ICON_EDIT_SVG",configColorName:"ICON_EDIT_COLOR",svg:Be,color:"#4E5969"},{name:"icon-select",configName:"ICON_SELECT_SVG",configColorName:"ICON_SELECT_COLOR",svg:Ft,color:"#4E5969"},{name:"sort-asc",configName:"SORT_ASC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:Xe,color:"rgb(82,146,247)"},{name:"sort-desc",configName:"SORT_DESC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:Ke,color:"rgb(82,146,247)"},{name:"sort-default",configName:"SORTABLE_ICON_SVG",svg:Ot,color:"#bec4c7"},{name:"drag",configName:"DRAG_ROW_ICON_SVG",svg:He,color:"#4E5969"}]);r(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,o=i.svg;if(i.configColorName){const a=this.ctx.config[i.configColorName];a&&(s=a)}if(i.configName){const a=this.ctx.config[i.configName];a&&(o=a)}const n=this.createImageFromSVG(o,s).then(a=>{this.icons.set(i.name,a)});t.push(n)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const o=this.createImageFromSVG(i.svg,s,i.isBlob).then(n=>{this.icons.set(i.name,n)});t.push(o)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){const n=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&n.querySelectorAll("*").forEach(c=>{const d=c.getAttribute("fill");(d==="currentColor"||d===null)&&c.setAttribute("fill",e)});const a=new Image;let l="";if(i){const c=new Blob([new XMLSerializer().serializeToString(n)],{type:"image/svg+xml"});l=URL.createObjectURL(c)}else l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(n));return a.src=l,new Promise((c,d)=>{a.onerror=()=>d(new Error("Failed to load image:"+t)),a.onload=()=>{c(a)}})}get(t){return this.icons.get(t)}getSvg(t){return this.list.find(e=>e.name===t)}}class Fe{constructor(t){r(this,"ctx");r(this,"visibleHoverCell");r(this,"resizeObserver");r(this,"mutationObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(t=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver",t),this.ctx.emit("containerResize",this.ctx.containerElement)}),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(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.isInsideBody(o,s)||this.ctx.emit("mousedownBodyOutside",t),t.button===0&&(this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,n=>{this.ctx.focusCellHeader=n,this.ctx.focusCell=void 0,this.ctx.emit("cellHeaderMousedown",n,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,n=>{this.ctx.setFocusCell(n),this.ctx.focusCellHeader=void 0,this.ctx.emit("cellMousedown",n,t)},!0))}),this.ctx.on("mouseup",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,n=>{this.ctx.emit("cellHeaderMouseup",n,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,n=>{this.ctx.emit("cellMouseup",n,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.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t);const o=s.getImage("hover");!this.ctx.disableHoverIconClick&&o&&o.isInside(i,e)&&this.ctx.emit("hoverIconClick",s)},!0)}),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,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,n=>{this.ctx.emit("cellHeaderContextMenuClick",n,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,n=>{this.ctx.emit("cellContextMenuClick",n,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.mousedown&&this.ctx.stageElement.style.cursor!=="default"&&(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.imageEnterAndLeave(s,t),this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.visibleHoverCell=void 0,this.ctx.emit("cellHeaderHoverChange",s,t))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.imageEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.hoverCellHeader=void 0,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var o;this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",s,t),this.ctx.hoverCell!==s&&(((o=this.ctx.hoverCell)==null?void 0:o.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(n=>n.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("draw")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))}),this.handleFooterEvent(i,e,this.ctx.footer.renderRows,s=>{this.ctx.emit("cellFooterMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellFooterMouseleave",s,t),this.ctx.emit("cellFooterHoverChange",s,t)})})}imageEnterAndLeave(t,e){if(this.ctx.dragRowIng||this.ctx.dragHeaderIng||this.ctx.selectColsIng||this.ctx.selectRowsIng||this.ctx.selectorMove||this.ctx.autofillMove)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,n=s;t.cellImages.forEach((a,l)=>{a.isInside(n,o)&&(l==="drag"?this.ctx.stageElement.style.cursor="grab":this.ctx.stageElement.style.cursor="pointer")})}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;if(this.ctx.loading||!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:n}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-n||o>this.ctx.stageWidth-n)}handleBodyEvent(t,e,i,s,o=!1){if(this.isInsideBody(t,e))for(const n of i){const a=n.fixedCells.concat(n.noFixedCells);for(const l of a)if(o?l.isInsideVisible(t,e):l.isInside(t,e)){s(l);return}}}handleHeaderEvent(t,e,i,s){for(const o of i)if(o.isInside(t,e)){s(o);return}}handleFooterEvent(t,e,i,s){for(const o of i){const n=o.fixedCells.concat(o.noFixedCells);for(const a of n)if(a.isInside(t,e)){s(a);return}}}isInsideBody(t,e){const{body:{y:i,visibleHeight:s,height:o,visibleWidth:n}}=this.ctx,a=Math.min(o,s);return t>0&&t<n&&e>i&&e<i+a}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}const We={numberErrorTip:"只允许输入数字",emptyText:"暂无数据",loadingText:"加载中...",copy:"复制",cut:"剪切",paste:"粘贴",clearSelected:"清空选中内容",fixedLeft:"左固定",fixedRight:"右固定",fixedNone:"取消固定",hide:"隐藏",visible:"显示",resetHeader:"恢复默认",invalidNumber:"请输入数字类型",mergeCellNoFill:"合并单元格不能填充",mergeCellNoCopy:"合并单元格不能复制",mergeCellNoPaste:"合并单元格不能粘贴",numberTruncated:"输入的数字已截取至小数点后{precision}位",batchSetItemValueError:"批量赋值错误",numberMin:"输入值小于{min},已自动调整为{min}",numberMax:"输入值大于{max},已自动调整为{max}",stringMaxlength:"输入值超过{maxlength}个字符,已自动截取"};class Ve{constructor(){r(this,"langConfig")}use(t){this.langConfig=t}getText(t,e){const i={...We};Object.assign(i,gt.locale,this.langConfig);const s=i[t];return s?s.replace(/{(\w+)}/g,(o,n)=>(e==null?void 0:e[n])||o):""}}class Pe{constructor(t,e){r(this,"eventBus");r(this,"eventBrowser");r(this,"eventTable");r(this,"locale",new Ve);r(this,"containerElement");r(this,"stageElement");r(this,"canvasElement");r(this,"overlayerElement");r(this,"editorElement");r(this,"emptyElement");r(this,"contextMenuElement");r(this,"loadingElement");r(this,"stageWidth",0);r(this,"stageHeight",0);r(this,"paint");r(this,"icons");r(this,"domSelectionStr","");r(this,"textSelectionStr","");r(this,"textSelecting",!1);r(this,"isMouseoverTargetContainer",!1);r(this,"mousedown",!1);r(this,"isEmpty",!1);r(this,"rowResizing",!1);r(this,"columnResizing",!1);r(this,"scrollerMove",!1);r(this,"scrollerFocus",!1);r(this,"autofillMove",!1);r(this,"selectorMove",!1);r(this,"disableHoverIconClick",!1);r(this,"selectColsIng",!1);r(this,"selectRowsIng",!1);r(this,"dragHeaderIng",!1);r(this,"dragRowIng",!1);r(this,"finding",!1);r(this,"contextMenuIng",!1);r(this,"editing",!1);r(this,"loading",!1);r(this,"onlyMergeCell",!1);r(this,"selectOnlyOne",!1);r(this,"hasSelection",!1);r(this,"hasTree",!1);r(this,"scrollY",0);r(this,"scrollX",0);r(this,"fixedLeftWidth",0);r(this,"fixedRightWidth",0);r(this,"lastCenterColIndex",0);r(this,"maxColIndex",0);r(this,"maxRowIndex",0);r(this,"hoverRow");r(this,"clickCell");r(this,"focusCell");r(this,"currentCell");r(this,"hoverCell");r(this,"clickCellHeader");r(this,"focusCellHeader");r(this,"hoverCellHeader");r(this,"mouseX",0);r(this,"mouseY",0);r(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});r(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});r(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],allCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});r(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});r(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});r(this,"finderBar",{text:"",rowIndex:-1,colIndex:-1,type:"body"});r(this,"database");r(this,"history");r(this,"config");const{containerElement:i,stageElement:s,canvasElement:o,overlayerElement:n,editorElement:a,emptyElement:l,loadingElement:c,contextMenuElement:d}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=o,this.overlayerElement=n,this.editorElement=a,this.emptyElement=l,this.loadingElement=c,this.contextMenuElement=d,this.config=new Kt(e.config||{}),this.eventBus=new Me,this.eventBrowser=new Le(this),this.eventTable=new Fe(this),this.paint=new Ae(this.canvasElement),this.database=new Se(this,e),this.history=new Oe(this),this.icons=new Ye(this)}setConfig(t){this.config=new Kt(t)}setItemValueByEditor(t,e,i,s=!0,o=!0,n=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const a=this.database.getVirtualBodyCellByKey(t,e);if(a&&(a.mergeRow||a.mergeCol)){const{dataList:l}=a.getSpanInfo(),c=l.map(d=>({...d,value:i}));this.database.batchSetItemValue(c,s,n);return}}this.database.setItemValue(t,e,i,s,o,!0,n)}batchSetItemValueByEditor(t,e=!0,i=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const s=[];t.forEach(o=>{const n=this.database.getRowIndexForRowKey(o.rowKey),a=this.database.getColIndexForKey(o.key);if(n===void 0||a===void 0)return;const l=this.database.getVirtualBodyCell(n,a);if(l){const{dataList:c}=l.getSpanInfo(),d=c.map(f=>({...f,value:o.value}));s.push(...d)}}),this.database.batchSetItemValue(s,e,i)}else this.database.batchSetItemValue(t,e,i)}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 o=0;o<=e[1]-e[0];o++){const n=[];for(let a=0;a<=i[1]-i[0];a++){const l=o+e[0],c=a+i[0],d=this.database.getVirtualBodyCell(l,c);d&&(d.selectorCellValueType==="displayText"?n.push(d.displayText):n.push(d.getValue()))}s+=`${n.join(" ")}\r`,t.push(n)}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 o=Math.floor(e),n=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(n=this.body.height+this.footer.height-this.body.visibleHeight),o<0?o=0:o>n&&(o=n),this.emit("setScroll",i,o)}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)}startAdjustPosition(t){this.emit("startAdjustPosition",t)}stopAdjustPosition(){this.emit("stopAdjustPosition")}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 Wt{constructor(t,e){r(this,"ctx");r(this,"type");r(this,"isFocus",!1);r(this,"trackX",0);r(this,"trackY",0);r(this,"trackWidth",0);r(this,"trackHeight",0);r(this,"splitPoints",[]);r(this,"barX",0);r(this,"barY",0);r(this,"barWidth",0);r(this,"barHeight",0);r(this,"distance",0);r(this,"visibleDistance",0);r(this,"clientX",0);r(this,"clientY",0);r(this,"dragStart",0);r(this,"isDragging",!1);r(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,o=i-this.clientX;let n=0;this.type==="vertical"?(n=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(n===0&&s>0||n===this.distance&&s<0)&&t.preventDefault()):this.type==="horizontal"&&(n=Math.max(0,Math.min(this.dragStart-o,this.distance))),this.scroll=n}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:o}=t;if(!(s==this.clientX&&o==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=o,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(e,i)){let n=0;this.type==="vertical"?n=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:n=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(n,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:o,buttons:n}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,n===0||s==this.clientX&&o==this.clientY)return;let a=0;if(this.type==="horizontal"?a=s-this.clientX:a=o-this.clientY,this.isDragging&&a!==0){let l=0;this.type==="vertical"?l=this.dragStart+a/(this.visibleDistance-this.barHeight)*this.distance:l=this.dragStart+a/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(l,this.distance))}}isPointInElement(t,e,i,s,o,n){return t>=i&&t<=i+o&&e>=s&&e<=s+n}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:o=0,SCROLLER_SIZE:n=0,BORDER:a}}=this.ctx,l=s,c=i,d=e.height,f=e.width,u=t.height,x=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=c-o-d,this.distance=u-this.visibleDistance+x,this.trackX=l-o,this.trackY=0,this.splitPoints=[this.trackX,d,this.trackX+o,d],this.trackWidth=o,this.trackHeight=c,this.barX=this.trackX-1+(o-n)/2,this.barWidth=n;const g=this.distance?this.visibleDistance/(u+x):0;let E=Math.floor(g*this.visibleDistance);E<30?E=30:E>this.visibleDistance&&(E=0),this.barHeight=E,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=l-o,this.distance=f-this.visibleDistance,this.splitPoints=[l-o,c-o,l-o,c];const g=a?0:.5;this.trackX=0,this.trackY=c-o+g,this.trackWidth=l,this.trackHeight=o;const E=this.distance?this.visibleDistance/f:0;let w=Math.floor(E*this.visibleDistance);this.barY=this.trackY-1+(o-n)/2,w<30?w=30:w>=this.visibleDistance&&(w=0),this.barWidth=w,this.barHeight=n,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:o}}=this.ctx;this.updatedSize();let n=i;s||(n="transparent"),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:n,fillColor:o}),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:n,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class ze{constructor(t){r(this,"ctx");r(this,"verticalScrollbar");r(this,"horizontalScrollbar");r(this,"mousedownHeader",!1);r(this,"adjustPositionX","");r(this,"adjustPositionY","");r(this,"timerX",0);r(this,"timerY",0);this.ctx=t,this.verticalScrollbar=new Wt(t,"vertical"),this.horizontalScrollbar=new Wt(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)}),this.ctx.on("scrollToIndex",(e,i)=>{this.scrollToIndex(e,i)}),this.ctx.on("cellHeaderMousedown",()=>{this.mousedownHeader=!0}),this.ctx.on("startAdjustPosition",e=>{this.startAdjustPosition(e)}),this.ctx.on("stopAdjustPosition",()=>{this.stopAdjustPosition()})}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.mousedownHeader=!1,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&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);this.setScrollY(s-e.visibleHeight/2)}scrollToIndex(t,e){this.scrollToRowIndex(t),this.scrollToColIndex(e)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(s===void 0)return;const{top:o}=i.getPositionForRowIndex(s);this.setScrollY(o-e.visibleHeight/2)}startAdjustPosition(t){var n,a;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",o="";if(((n=this.ctx.focusCell)==null?void 0:n.fixed)!=="left"&&e<this.ctx.fixedLeftWidth?s="left":((a=this.ctx.focusCell)==null?void 0:a.fixed)!=="right"&&e>this.ctx.body.visibleWidth-this.ctx.fixedRightWidth?s="right":(s="",this.stopAdjustPosition(!0,!1)),!this.mousedownHeader&&i<this.ctx.header.visibleHeight?o="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight?o="bottom":(o="",this.stopAdjustPosition(!1,!0)),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let c=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{c*=1.5;const{scrollX:d}=this.ctx,f=d+c;(f<0||f>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(f)},100)}if(o&&this.adjustPositionY!==o){this.adjustPositionY=o;let c=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{c*=1.5;const{scrollY:d}=this.ctx,f=d+c;(f<0||f>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(f)},100)}}stopAdjustPosition(t=!0,e=!0){t&&(this.adjustPositionX="",this.timerX&&(clearInterval(this.timerX),this.timerX=0)),e&&(this.adjustPositionY="",this.timerY&&(clearInterval(this.timerY),this.timerY=0))}}class $e extends ee{constructor(e,i,s,o,n,a,l){super(e,s,o,n,a,"header",l.fixed);r(this,"align");r(this,"hideHeaderSelection",!1);r(this,"verticalAlign","middle");r(this,"fixed");r(this,"minWidth");r(this,"maxWidth");r(this,"widthFillDisable");r(this,"type");r(this,"operation",!1);r(this,"editorType");r(this,"level");r(this,"text");r(this,"hide",!1);r(this,"displayText","");r(this,"colspan");r(this,"rowspan");r(this,"row");r(this,"key");r(this,"required",!1);r(this,"readonly",!1);r(this,"ellipsis",!1);r(this,"overflowTooltipShow",!0);r(this,"children",[]);r(this,"column");r(this,"colIndex");r(this,"rowKey");r(this,"rules");r(this,"hasChildren");r(this,"render");r(this,"style",{});r(this,"drawX",0);r(this,"drawY",0);r(this,"sortIconName","sort-default");r(this,"sortAscIconName","sort-asc");r(this,"sortDescIconName","sort-desc");r(this,"visibleWidth",0);r(this,"visibleHeight",0);r(this,"maxLineClampHeader","auto");r(this,"domDataset",{});r(this,"textOffsetRight",0);r(this,"textOffsetLeft",0);r(this,"textInfo");r(this,"drawTextX",0);r(this,"drawTextY",0);r(this,"drawTextWidth",0);r(this,"drawTextHeight",0);r(this,"drawCellBgColor","");r(this,"drawTextColor","");r(this,"drawTextFont","");r(this,"drawSelectionImageX",0);r(this,"drawSelectionImageY",0);r(this,"drawSelectionImageWidth",0);r(this,"drawSelectionImageHeight",0);r(this,"drawSelectionImageName","");r(this,"drawSelectionImageSource");r(this,"drawSortImageX",0);r(this,"drawSortImageY",0);r(this,"drawSortImageWidth",0);r(this,"drawSortImageHeight",0);r(this,"drawSortImageName","");r(this,"drawSortImageSource");r(this,"renderHeaderType","default");this.ctx=e,this.x=s,this.y=o,this.width=n,this.height=a,this.visibleWidth=n,this.visibleHeight=a,this.colIndex=i,this.key=l.key,this.minWidth=l.minWidth,this.maxWidth=l.maxWidth,this.hide=(typeof l.hide=="function"?l.hide(l):l.hide)||!1,this.type=l.type||"",this.editorType=l.editorType||"text",this.hideHeaderSelection=l.hideHeaderSelection||!1,this.align=l.headerAlign||l.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=l.headerVerticalAlign||l.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=l.fixed||"",this.level=l.level||0,this.operation=l.operation||!1,this.text=l.title,this.column=l,this.colspan=l.colspan||1,this.widthFillDisable=l.widthFillDisable||!1,this.rowspan=l.rowspan||1,this.rules=l.rules,this.readonly=l.readonly||!1,this.required=l.required||!1,this.sortIconName=l.sortIconName||"sort-default",this.sortAscIconName=l.sortAscIconName||"sort-asc",this.sortDescIconName=l.sortDescIconName||"sort-desc",this.rowKey=qt(),this.overflowTooltipShow=l.overflowTooltipHeaderShow!==!1,this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader,this.maxLineClampHeader=l.maxLineClampHeader||"auto",this.renderHeaderType=l.renderHeaderType||"default"}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 o=i,n=s;if(typeof e=="function"){const c=e,{backgroundColor:d,color:f,font:u}=c({colIndex:this.colIndex,column:this.column})||{};d&&(o=d),f&&(n=f),u&&(this.drawTextFont=u)}const{colKey:a,type:l}=this.ctx.finderBar;l==="header"&&a===this.key&&(o=this.ctx.config.FINDER_CELL_BG_COLOR),this.drawCellBgColor=o,this.drawTextColor=n}updateOffset(){this.column.sortBy&&(this.textOffsetRight=16),this.required&&(this.textOffsetLeft=12)}update(){this.updateContainer(),this.updateOffset(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateSelection(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.drawTextWidth=this.width,this.drawTextHeight=this.height,this.updateStyle()}draw(){this.drawEdge(),this.drawText(),this.drawBg(),this.updateSortIcon(),this.drawImages(),this.drawRequired()}drawImages(){this.getImages().forEach(e=>{e.visible&&e.source&&this.ctx.paint.drawImage(e.source,e.x,e.y,e.width,e.height)})}drawEdge(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx;e.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor})}drawText(){const{paint:e,config:{HEADER_FONT:i,CELL_PADDING:s}}=this.ctx,o=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`;this.ellipsis=e.drawText(this.displayText,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||i,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign,maxLineClamp:this.maxLineClampHeader,offsetRight:this.textOffsetRight,offsetLeft:this.textOffsetLeft,cacheTextKey:o,textCallback:n=>{this.textInfo=n},layoutCallback:n=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.colIndex}-${this.level}`,n)}})}drawRequired(){if(!this.required||!this.textInfo)return;const{left:e,top:i,height:s}=this.textInfo,{paint:o,config:{REQUIRED_COLOR:n}}=this.ctx;o.drawText("*",e-18,i+(s-12)/2,24,24,{color:n,font:"18px Arial",align:"center",verticalAlign:"middle",padding:0})}drawBg(){if(this.ctx.dragHeaderIng)return;const{ENABLE_SELECTOR:e,ENABLE_SELECTOR_SINGLE:i}=this.ctx.config;let s=-1,o=-1;if(this.ctx.focusCellHeader&&(s=this.ctx.focusCellHeader.colIndex,o=this.ctx.focusCellHeader.colIndex+this.ctx.focusCellHeader.colspan-1),e&&!i){const{xArr:a}=this.ctx.selector;s=a[0],o=a[1]}const n=this.colspan+this.colIndex-1;this.colIndex>=s&&this.colIndex<=o&&n<=o&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}updateSelection(){if(["index-selection","selection","selection-tree","tree-selection"].includes(this.type)){const{indeterminate:e,check:i,selectable:s}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:o=0,CELL_PADDING:n}=this.ctx.config;let a=this.drawX+(this.width-o)/2,l=this.drawY+(this.height-o)/2;this.drawTextX=a+o-n/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX,(this.align==="left"||this.align==="right")&&(a=this.drawX+n,this.drawTextX=a+o-n/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX),this.verticalAlign==="top"?l=this.drawY+n/2:this.verticalAlign==="bottom"&&(l=this.drawY+this.height-o-n/2),this.column.dragRow&&(a+=this.ctx.config.DRAG_ROW_ICON_SIZE,this.drawTextX+=this.ctx.config.DRAG_ROW_ICON_SIZE,this.drawTextWidth-=this.ctx.config.DRAG_ROW_ICON_SIZE);let c=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck";e?(c=this.ctx.icons.get("checkbox-indeterminate"),d="checkbox-indeterminate"):i&&s?(c=this.ctx.icons.get("checkbox-check"),d="checkbox-check"):i&&!s?(c=this.ctx.icons.get("checkbox-check-disabled"),d="checkbox-check-disabled"):!i&&s?(c=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck"):(c=this.ctx.icons.get("checkbox-disabled"),d="checkbox-disabled");const f=new j(d,a,l,o,o,c);f.setVisible(!this.hideHeaderSelection),this.setImage("selection",f)}}updateSortIcon(){if(!this.column.sortBy||!this.textInfo)return;const{right:e,top:i,height:s}=this.textInfo,o=e+4,n=i+(s-16)/2,a=16;let l=this.sortIconName;const c=this.ctx.database.getSortState(this.key);c.direction==="asc"?l=this.sortAscIconName:c.direction==="desc"&&(l=this.sortDescIconName);const d=this.ctx.icons.get(l),f=new j(l,o,n,a,a,d);this.setImage("sort",f)}getText(){return this.render&&this.renderHeaderType==="default"||["",null,void 0].includes(this.text)?"":`${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 oe{constructor(t,e){r(this,"root");r(this,"key");r(this,"childrenKey");this.root=t,this.key=(e==null?void 0:e.key)||"key",this.childrenKey=(e==null?void 0:e.childrenKey)||"children"}getTree(){return this.root}treeMove(t,e,i){if(i==="none"||t===e)return;const s=this.findNodeWithParent(this.root,t);if(!s)return;const o=this.findNodeWithParent(this.root,e);if(!o)return;const{parent:n,index:a,node:l}=s,{parent:c,index:d,node:f}=o;if(this.isDescendant(l,e))return;const u=n?n[this.childrenKey]:this.root;if(u.splice(a,1),n&&u.length===0&&delete n[this.childrenKey],i==="inside"){Array.isArray(f[this.childrenKey])||(f[this.childrenKey]=[]),f[this.childrenKey].push(l);return}const x=c?c[this.childrenKey]:this.root;let g=d;n===c&&a<d&&g--,i==="after"&&g++,x.splice(g,0,l)}findNodeWithParent(t,e,i=null){for(let s=0;s<t.length;s++){const o=t[s];if(o[this.key]===e)return{parent:i,index:s,node:o};const n=o[this.childrenKey];if(Array.isArray(n)){const a=this.findNodeWithParent(n,e,o);if(a)return a}}return null}isDescendant(t,e){const i=t[this.childrenKey];if(!Array.isArray(i))return!1;for(const s of i)if(s[this.key]===e||this.isDescendant(s,e))return!0;return!1}}class Ge{constructor(t){r(this,"ctx");r(this,"x",0);r(this,"y",0);r(this,"width",0);r(this,"height",0);r(this,"resizeTarget",null);r(this,"dragTarget",null);r(this,"dragingCell");r(this,"dragCellDiff",0);r(this,"resizeNum",0);r(this,"isResizing",!1);r(this,"clientX",0);r(this,"resizeDiff",0);r(this,"columnIndex",0);r(this,"isMouseDown",!1);r(this,"columns");r(this,"visibleColumns");r(this,"visibleLeafColumns",[]);r(this,"visibleHeight",0);r(this,"visibleWidth",0);r(this,"allCellHeaders",[]);r(this,"leafCellHeaders",[]);r(this,"renderLeafCellHeaders",[]);r(this,"fixedLeftCellHeaders",[]);r(this,"centerCellHeaders",[]);r(this,"fixedRightCellHeaders",[]);r(this,"renderCenterCellHeaders",[]);r(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",St(()=>{this.init(),this.ctx.clearSelector(),this.ctx.emit("draw")},100)),this.init(),this.initSelection(),this.initSort(),this.initResizeColumn(),this.initDragColumn()}init(t=!1){const{config:{HEADER_HEIGHT:e,SCROLLER_TRACK_SIZE:i}}=this.ctx;if(!t){const f=this.ctx.database.getColumns();this.columns=f}this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[],this.visibleColumns=Jt(this.columns);const s=rt(this.visibleColumns),o=tt(this.visibleColumns);this.height=e*s,this.visibleHeight=this.height,this.width=o.reduce((f,u)=>{const x=u.width||100,{maxWidth:g,minWidth:E}=u;return g&&x>g?f+g:E&&x<E?f+E:f+x},0),this.columnIndex=0,this.resizeNum=0;const n=pe(at(this.visibleColumns,s));this.render(n,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const a=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(a.width):this.ctx.stageWidth=Math.min(Math.floor(this.width+i),Math.floor(a.width)),this.ctx.stageElement.style.width=this.ctx.stageWidth+"px",this.visibleWidth=this.ctx.stageWidth-i;const l=this.visibleWidth-this.width;if(this.resizeNum&&l>0){const f=Math.floor(l/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,i),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.allCellHeaders=this.allCellHeaders,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initSort(){this.ctx.on("cellHeaderClick",(t,e)=>{if(!t.isImageInside("sort",e))return;const i=this.ctx.database.getSortState(t.key);let s;i.direction==="none"?s="asc":i.direction==="asc"?s="desc":s="none",this.ctx.database.setSortState(t.key,s)})}initSelection(){this.ctx.on("cellHeaderClick",(t,e)=>{if(this.ctx.stageElement.style.cursor!=="pointer"||!t.isImageInside("selection",e))return;const i=t.getImage("selection");["checkbox-uncheck","checkbox-indeterminate"].includes(i.name)?this.ctx.database.toggleAllSelection():i.name==="checkbox-check"&&this.ctx.database.clearSelection(!0)})}initResizeColumn(){this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&this.ctx.isTarget(t)&&(this.clientX=t.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&(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",t=>{if(!this.ctx.config.ENABLE_RESIZE_COLUMN||this.ctx.editing)return;const{stageWidth:e,config:{RESIZE_COLUMN_MIN_WIDTH:i}}=this.ctx;if(this.isResizing&&this.resizeTarget){const s=this.resizeTarget.width,o=this.resizeTarget.minWidth,n=this.resizeTarget.maxWidth;let a=t.clientX-this.clientX;a+s<i&&(a=-(s-i)),o&&a+s<o&&(a=-(s-o)),n&&a+s>n&&(a=n-s),this.resizeDiff=a,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(t.offsetX<0||t.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 s=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of s){const{offsetX:n,offsetY:a}=this.ctx.getOffset(t),l=n,c=a,d=o.getDrawX(),f=o.getDrawY();if(l>d+o.width-5&&l<d+o.width+4&&l<e-4&&c>f){const u=o.colIndex+o.colspan-1,x=this.leafCellHeaders.find(g=>g.colIndex===u);if(!x||!x.fixed&&this.ctx.stageWidth-this.ctx.fixedRightWidth<d+o.width)return;this.ctx.isTarget(t)&&a<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=x)}}}})}initDragColumn(){this.ctx.on("cellHeaderMousedown",t=>{this.ctx.stageElement.style.cursor==="default"&&this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragTarget===t?(this.ctx.dragHeaderIng=!0,this.dragCellDiff=this.ctx.mouseX-t.drawX,this.ctx.stageElement.style.cursor="grabbing"):(this.dragTarget=t,this.ctx.dragHeaderIng=!1)))}),this.ctx.on("cellMousedown",()=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(this.dragTarget=null,this.ctx.dragHeaderIng=!1)}),this.ctx.on("mouseup",()=>{if(this.ctx.config.ENABLE_DRAG_COLUMN){if(this.dragingCell&&this.dragTarget){const t=(c,d={})=>(c.forEach((f,u)=>{f.children&&t(f.children,d),d[f.key]=u}),d),e=this.ctx.database.getColumns(),i=at(e,rt(e)),s=new oe(i,{key:"key",childrenKey:"children"}),o=this.dragTarget.colIndex>this.dragingCell.colIndex?"before":"after";s.treeMove(this.dragTarget.column.key,this.dragingCell.column.key,o);const n=s.getTree(),a=t(n);this.ctx.database.setCustomHeader({sortData:a}),this.init();const l={source:this.dragTarget,target:this.dragingCell,columns:i};this.ctx.emit("columnDragChange",l)}this.ctx.dragHeaderIng&&this.dragTarget&&(this.ctx.stageElement.style.cursor==="grabbing"&&(this.ctx.stageElement.style.cursor="default"),this.ctx.dragHeaderIng=!1,this.dragTarget=null,this.dragingCell=void 0,this.dragCellDiff=0,this.ctx.clearSelector(),this.ctx.focusCellHeader=void 0,this.ctx.emit("draw"))}}),this.ctx.on("mousemove",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(!this.ctx.dragHeaderIng||!this.dragTarget||(this.dragTarget.fixed||this.ctx.startAdjustPosition(t),this.ctx.emit("draw")))}),this.ctx.on("cellHoverChange",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(t.colIndex)))}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(t.colIndex)))})}getDragCellHeader(t){if(!this.dragTarget||!this.ctx.dragHeaderIng)return;const{column:{parentKey:e},key:i,level:s,fixed:o}=this.dragTarget,n=this.allCellHeaders.find(a=>a.key!==i&&a.fixed===o&&a.column.level===s&&a.column.parentKey===e&&a.colIndex<=t&&a.colIndex+a.colspan-1>=t);if(this.ctx.dragHeaderIng){const a=n?"grabbing":"not-allowed";this.ctx.stageElement.style.cursor=a}return n}resizeColumn(t,e){const i=n=>{n.forEach(a=>{if(a.children&&a.children.length>0&&i(a.children),a.key===t.key){const l=a.width||100;a.width=l+e}})};i(this.columns);let s=0;if(this.width<this.visibleWidth){const n=this.visibleWidth-this.width;s=Math.floor(n/this.resizeNum*100)/100,this.resizeAllColumn(s)}const o=t.width+e+s;this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:o,column:t.column,columns:this.columns}),this.ctx.database.setCustomHeaderResizableData(t.key,o),this.init(!0),this.ctx.emit("draw")}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const o of this.allCellHeaders)if(o.widthFillDisable)e.set(o.key,o.width);else{const n=o.width+t*o.colspan;e.set(o.key,n),n<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=o=>{o.forEach(n=>{e.has(n.key)&&(n.width=e.get(n.key)),n.children&&n.children.length>0&&s(n.children)})};s(this.columns),this.init(!0),this.ctx.emit("draw")}getCustomHeader(){const t=this.ctx.database.getColumns(),e=this.ctx.database.getCustomHeader(),{sortData:i={}}=e;return Object.keys(i).length===0?{columns:t,customHeader:e}:{columns:at(t,rt(t)),customHeader:e}}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:o=0}=this.ctx.config;for(let n=0;n<i;n++){const a=t[n],l=o*(a.rowspan||0),c=o*(a.level||0);let{minWidth:d,maxWidth:f}=a,u=a.width||100;d&&u<d&&(u=d),f&&u>f&&(u=f),a.children&&(u=tt(a.children).reduce((E,w)=>E+((w==null?void 0:w.width)||100),0));const x=new $e(this.ctx,this.columnIndex,s,c,u,l,a);this.ctx.database.setHeader(a.key,x),this.allCellHeaders.push(x),a.children||(this.leafCellHeaders.push(x),x.column.widthFillDisable||this.resizeNum++),a.fixed==="left"?this.fixedLeftCellHeaders.push(x):a.fixed==="right"?this.fixedRightCellHeaders.push(x):this.centerCellHeaders.push(x),!a.children&&this.columnIndex++,a.children&&this.render(a.children,s),s+=u}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e,RESIZE_COLUMN_TEXT_COLOR:i,RESIZE_COLUMN_TEXT_BG_COLOR:s,ENABLE_RESIZE_COLUMN_TEXT:o}}=this.ctx,n=this.resizeTarget.getDrawX(),a=this.resizeTarget.width,l=n+a+this.resizeDiff-.5,c=[l-.5,0,l-.5,t];if(this.ctx.paint.drawLine(c,{borderColor:e}),o){const f=`${Math.floor(a+this.resizeDiff)}px`,u=45,x=24;this.ctx.paint.drawRect(l+u/2,this.ctx.mouseY-x/2,u,x,{fillColor:s,borderWidth:0,borderColor:"transparent"}),this.ctx.paint.drawText(f,l+u/2,this.ctx.mouseY-x/2,u,x+2,{padding:0,color:i,align:"center",verticalAlign:"middle"})}}}drawDragTip(){if(this.dragTarget&&this.ctx.dragHeaderIng){const{DRAG_TIP_BG_COLOR:t,DRAG_TIP_LINE_COLOR:e}=this.ctx.config,i=this.dragTarget.width;if(this.ctx.paint.drawRect(this.ctx.mouseX-this.dragCellDiff,this.visibleHeight,i,this.ctx.body.visibleHeight,{fillColor:t,borderWidth:0,borderColor:"transparent"}),this.dragingCell){const{drawX:s,drawY:o,visibleWidth:n,colIndex:a}=this.dragingCell;let l=s,c=o;a>this.dragTarget.colIndex&&(l=s+n),a===0&&(l=l+1),a===this.ctx.maxColIndex&&(l=l-1);const d=[l,c,l,this.ctx.stageHeight],f=[l-4,c,l+4,c,l,c+6,l-4,c];this.ctx.paint.drawLine(f,{borderColor:e,borderWidth:1.2,fillColor:e}),this.ctx.paint.drawLine(d,{borderColor:e,borderWidth:1.2})}}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:n,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:n,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:n,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,o)=>s.x-o.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.drawBottomLine(),this.drawTipLine(),this.drawDragTip()}}class ne{constructor(t,e,i=0,s=0,o=0,n=0,a,l="body"){r(this,"ctx");r(this,"x",0);r(this,"y",0);r(this,"width",0);r(this,"height");r(this,"cells",[]);r(this,"fixedCells",[]);r(this,"noFixedCells",[]);r(this,"calculatedHeightCells",[]);r(this,"rowIndex",0);r(this,"rowKey","");r(this,"rowType","body");r(this,"data");r(this,"calculatedHeight",-1);this.ctx=t,this.x=i,this.y=s,this.width=o,this.height=n,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=l,this.data=a,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[],o=[];t.renderLeafCellHeaders.forEach(n=>{const a=new ie(this.ctx,this.rowIndex,n.colIndex,n.x,this.y,n.width,this.height,n.column,this.data,this.rowType);a.fixed?i.push(a):s.push(a),e.push(a),a.autoRowHeight&&o.push(a)}),this.cells=e,this.calculatedHeightCells=o,this.fixedCells=i,this.noFixedCells=s}updateCalculatedHeight(){const t=this.calculatedHeightCells.map(e=>{const i=e.getAutoHeight(),{key:s,height:o=-1}=this.ctx.database.getMaxRowHeightItem(this.rowKey)||{};return i>o?this.ctx.database.setMaxRowHeightItem(this.rowKey,e.key,i):e.key===s&&i<o&&this.ctx.database.setMaxRowHeightItem(this.rowKey,e.key,i),i});return this.calculatedHeight=t.length?Math.max(...t):-1,this.calculatedHeight}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 Ue{constructor(t){r(this,"resizeTarget",null);r(this,"dragSource",null);r(this,"dragTarget",null);r(this,"dragRowDiff",0);r(this,"dragPosition","none");r(this,"isMouseDown",!1);r(this,"resizeDiff",0);r(this,"clientY",0);r(this,"ctx");r(this,"x",0);r(this,"y",0);r(this,"width",0);r(this,"height",0);r(this,"headIndex",0);r(this,"tailIndex",0);r(this,"isResizing",!1);r(this,"renderRows",[]);r(this,"visibleRows",[]);r(this,"visibleHeight",0);r(this,"visibleWidth",0);r(this,"containerRect");r(this,"data",[]);this.ctx=t,this.init(),this.initTree(),this.initSelection(),this.initResizeRow(),this.initDragRow()}init(){const{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:o,SCROLLER_TRACK_SIZE:n=0,HEIGHT:a,EMPTY_BODY_HEIGHT:l=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"&&o?this.y=e.height+i.height:this.y=e.height;const{data:x,sumHeight:g}=s.getData();this.height=g,this.data=x,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-n;const E=this.ctx.footer.height;this.ctx.isEmpty=!this.data.length,!this.data.length&&!a?this.height=l:!this.data.length&&a&&(this.height=a-e.height-E-n);let w=this.height+e.height+n;w+=E;let m=w;const y=window.innerHeight,{top:b}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(y>b&&d&&!a){const O=y-b-f;O>e.height+n?m=O:w>c&&(m=c)}else this.data.length&&a?m=a: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 p=this.ctx.stageHeight-e.height-n;o?this.visibleHeight=p-E:this.visibleHeight=p,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=x;const C=window.devicePixelRatio||1,I=this.ctx.stageWidth*C,v=this.ctx.stageHeight*C;t.width=Math.round(I),t.height=Math.round(v);const T=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:T,type:T,headerHeight:e.height,bodyHeight:this.height,footerHeight:E,width:this.width,height:this.data.length?0:l+E});const _=Math.round(t.width/C*1e4)/1e4,R=Math.round(t.height/C*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${R}px;width:${_}px;`),this.ctx.paint.scale(C)}initTree(){this.ctx.on("cellClick",(t,e)=>{if(this.ctx.stageElement.style.cursor!=="pointer"||!t.isImageInside("tree",e))return;const i=this.ctx.database.getRowForRowKey(t.rowKey),{expand:s=!1,expandLazy:o=!1}=i||{},{EXPAND_LAZY:n,EXPAND_LAZY_METHOD:a}=this.ctx.config;if(n&&a&&!s&&!o)typeof a=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),a({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(c=>{this.ctx.database.setExpandChildren(t.rowKey,c),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(c=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(c)}));else{const l=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!l),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}})}initSelection(){this.ctx.on("cellClick",(t,e)=>{this.ctx.stageElement.style.cursor!=="pointer"||!t.isImageInside("selection",e)||!this.ctx.database.getRowSelectable(t.rowKey)||this.ctx.database.toggleRowSelection(t.rowKey,t.type)})}initResizeRow(){this.ctx.on("resize",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("resizeObserver",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(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",t=>{this.ctx.config.ENABLE_RESIZE_ROW&&this.ctx.isTarget(t)&&(this.clientY=t.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_ROW||this.ctx.editing)return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i,n=t.clientY,{stageHeight:a,scrollY:l,config:{RESIZE_ROW_MIN_HEIGHT:c=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const d=this.resizeTarget.height;let f=n-this.clientY;const{calculatedHeight:u}=this.resizeTarget,x=u===-1?c:u;f+d<x&&(f=-(d-x)),this.resizeDiff=f,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(o<0||o>this.ctx.body.visibleWidth||s<0||s>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 d=0;d<this.renderRows.length;d++){const f=this.renderRows[d];if(s>f.y-l+f.height-1.5&&s<f.y-l+f.height+1.5&&s<a-4)for(let x=0;x<f.cells.length;x++){const g=f.cells[x];o>g.drawX+10&&o<g.drawX+g.width-10&&g.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=f)}}}})}initDragRow(){this.ctx.on("cellMousedown",(t,e)=>{this.ctx.config.ENABLE_DRAG_ROW&&t.isImageInside("drag",e)&&(this.dragSource=t,this.ctx.database.expandItem(t.rowKey,!1),this.ctx.dragRowIng=!0,this.dragRowDiff=this.ctx.mouseY-t.drawY,this.ctx.stageElement.style.cursor="grabbing",this.ctx.clearSelector(),this.ctx.emit("dragRowMouseDown",t),this.ctx.emit("draw"))}),this.ctx.on("mouseup",async()=>{if(this.ctx.dragRowIng){if(this.dragSource&&this.dragTarget&&this.ctx.stageElement.style.cursor!=="not-allowed"){const t=this.dragSource,e=this.dragTarget,i={source:t,target:e,position:this.dragPosition};this.ctx.emit("dragRowChange",i);let s=!0;const{BEFORE_DRAG_ROW_METHOD:o}=this.ctx.config;if(typeof o=="function"&&(s=await o(i)),s&&!this.ctx.config.ENABLE_DRAG_ROW_CUSTOM){const n=this.ctx.database.getOriginalData(),{TREE_CHILDREN_KEY:a,ROW_KEY:l}=this.ctx.config,c=new oe(n,{key:l,childrenKey:a});c.treeMove(t.rowKey,e.rowKey,this.dragPosition),this.ctx.emit("loadData",c.getTree())}}this.dragTarget||(this.ctx.stageElement.style.cursor="grab"),this.ctx.dragRowIng=!1,this.dragSource=null,this.dragTarget=null,this.dragPosition="after",this.dragRowDiff=0,this.ctx.emit("draw")}}),this.ctx.on("mousemove",t=>{if(!this.ctx.dragRowIng)return;const{offsetY:e}=this.ctx.getOffset(t),{drawY:i}=this.dragTarget;i<e||i>e?this.ctx.startAdjustPosition(t):this.ctx.stopAdjustPosition()}),this.ctx.on("cellMouseenter",t=>{if(!this.ctx.dragRowIng)return;this.dragTarget=t;const{ENABLE_DRAG_ROW_CROSS_LEVEL:e}=this.ctx.config,i=this.dragSource,s=this.dragTarget;if(!e&&i&&s&&i.parentRowKey!==s.parentRowKey){this.ctx.stageElement.style.cursor="not-allowed";return}this.ctx.stageElement.style.cursor="grabbing",this.dragTarget=t;const{drawY:o,visibleHeight:n}=t,a=e?n/3:n/2;this.ctx.mouseY<=o+a?this.dragPosition="before":this.ctx.mouseY>o+n-a?this.dragPosition="after":this.dragPosition="inside";const l={dragSource:this.dragSource,dragTarget:this.dragTarget,dragPosition:this.dragPosition};this.ctx.emit("dragRowMove",l),this.ctx.emit("draw")})}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:o,data:n}=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:o,row:n,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,o=this.resizeTarget.height,n=s+o+this.resizeDiff-.5,a=[0,n-.5,t,n-.5];this.ctx.paint.drawLine(a,{borderColor:i,borderWidth:1})}}drawDragRowTip(){if(this.ctx.dragRowIng&&this.dragTarget&&this.dragSource){const{stageWidth:t,config:{DRAG_ROW_TIP_LINE_COLOR:e,DRAG_TIP_BG_COLOR:i}}=this.ctx,s=this.dragSource.visibleHeight;this.ctx.paint.drawRect(0,this.ctx.mouseY-this.dragRowDiff,this.visibleWidth,s,{fillColor:i,borderWidth:0,borderColor:"transparent"});const o=this.dragTarget.drawY,n=this.dragTarget.height;let a=o;if(["before","after"].includes(this.dragPosition)){this.dragPosition==="after"&&(a=o+n);const c=[0,a-.5,t,a-.5];this.ctx.paint.drawLine(c,{borderColor:e,borderWidth:1.2})}["inside"].includes(this.dragPosition)&&(a=o+n/2);const l=[0,a-4,6,a,0,a+4,0,a-4];this.ctx.paint.drawLine(l,{borderColor:e,borderWidth:1.2,fillColor:e})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:n,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&!this.ctx.isEmpty&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:n,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a&&!this.ctx.isEmpty){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:n,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,o=-1;for(;i<=s;){let n=Math.floor((i+s)/2),a=t[n].bottom;if(a===e)return n;a<e?i=n+1:(o=n,s=n-1)}return o}update(){this.init();const{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,o=i,{data:n,positions:a}=e.getData();this.ctx.maxRowIndex=n.length-1;let l=this.binarySearch(a,o),c=this.binarySearch(a,o+this.visibleHeight);if(c===-1&&(c=this.ctx.maxRowIndex),l===-1&&c===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);l=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,l),this.tailIndex=Math.min(this.ctx.maxRowIndex,c+1),this.visibleRows=n.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,x=this.visibleRows[f],{height:g,top:E}=this.ctx.database.getPositionForRowIndex(u),w=new ne(this.ctx,u,0,E+this.y,t.width,g,x);d.push(w)}this.renderRows=d,this.ctx.body.renderRows=d}updateAutoHeight(){const t=this.ctx.body.renderRows;if(!t.some(s=>s.calculatedHeightCells.length>0))return!1;t.forEach(s=>{s.updateCalculatedHeight()});const i=t.map(s=>({height:s.calculatedHeight,rowIndex:s.rowIndex}));return this.ctx.database.setBatchCalculatedRowHeight(i)}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 je{constructor(t){r(this,"ctx");r(this,"renderRows",[]);r(this,"data",[]);r(this,"x",0);r(this,"y",0);r(this,"width",0);r(this,"height",0);r(this,"visibleWidth",0);r(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:o,FOOTER_POSITION:n}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(a=>a+i,0),this.visibleHeight=this.height,s?n==="top"?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-o: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:o,config:{HEADER_BG_COLOR:n,SCROLLER_TRACK_SIZE:a}}=this.ctx;let l=this.y;if(this.ctx.config.FOOTER_FIXED||(l=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,l,t,this.height,{fillColor:n,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const c=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(c,l,e,this.height,{fillColor:n,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,o)=>{const n=new ne(this.ctx,o,0,e,this.width,t,s,"footer");e+=t,i.push(n)}),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 Ze{constructor(t){r(this,"isCut",!1);r(this,"isMultipleRow",!1);r(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",St(t=>{var e;(e=this.ctx.focusCellHeader)!=null&&e.fixed||!this.ctx.dragHeaderIng&&this.ctx.selectorMove&&this.ctx.startAdjustPosition(t)},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("cellClick",()=>{this.adjustBoundaryPosition()}),this.ctx.on("cellMousedown",(t,e)=>{if(!this.ctx.isTarget(e)||this.ctx.stageElement.style.cursor==="pointer"||this.ctx.stageElement.style.cursor==="crosshair")return;if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.ctx.stopAdjustPosition(),setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHoverChange",t=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{if(this.ctx.stageElement.style.cursor==="pointer")return;window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.ctx.clearSelector(),t.operation?this.selectAll():this.selectCols(t)}),this.ctx.on("keydown",t=>{if(!this.ctx.editing&&!this.ctx.finding){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.adjustBoundaryPosition()}),this.ctx.on("selectCols",t=>{this.selectCols(t)})}setSelector(t,e){if(this.ctx.dragHeaderIng||this.ctx.dragRowIng)return;const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let o=t,n=e;if(!s){const[a]=n;n=[a,a]}if(!i){const[a]=o;o=[a,a]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(n)){this.ctx.mousedown&&(this.ctx.selectorMove=!0,this.ctx.disableHoverIconClick=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:l,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,x=a,g=l||this.ctx.maxColIndex-f,E=c,w=d||this.ctx.maxRowIndex-u;let[m,y]=o,[b,p]=n;if(m<x||y>g||b<E||p>w)return;if(this.ctx.config.ENABLE_MERGE_CELL_LINK){const I=this.adjustMergeCells(o,n);b=I.yArr[0],p=I.yArr[1],m=I.xArr[0],y=I.xArr[1],this.ctx.onlyMergeCell=I.onlyMergeCell}m===y&&b===p?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,o=[Math.max(x,m),Math.min(g,y)],n=[Math.max(E,b),Math.min(w,p)];const{BEFORE_SET_SELECTOR_METHOD:C}=this.ctx.config;if(typeof C=="function"){const v=C({focusCell:this.ctx.focusCell,xArr:o,yArr:n});if(!v)return;o=v.xArr,n=v.yArr}this.ctx.selector.xArr=o,this.ctx.selector.yArr=n,p===this.ctx.maxRowIndex&&b===0?this.ctx.selectColsIng=!0:this.ctx.selectColsIng=!1,y===this.ctx.maxColIndex&&m===0?this.ctx.selectRowsIng=!0:this.ctx.selectRowsIng=!1,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var g;const[i,s]=e,[o,n]=t;if(s===this.ctx.maxRowIndex&&i===0||n===this.ctx.maxColIndex&&o===0)return{xArr:t,yArr:e,onlyMergeCell:!1};let a=[],l=[];for(let E=0;E<=e[1]-e[0];E++)for(let w=0;w<=t[1]-t[0];w++){const m=E+e[0],y=w+t[0],b=this.ctx.database.getVirtualBodyCell(m,y);b&&((m===i||m===s)&&a.push(b),(y===o||y===n)&&l.push(b))}const c=a.reduce((E,w)=>{const{yArr:m}=w.getSpanInfo(),[y,b]=m;return E.minY=Math.min(E.minY,y),E.maxY=Math.max(E.maxY,b),E},{minY:i,maxY:s}),d=l.reduce((E,w)=>{const{xArr:m}=w.getSpanInfo(),[y,b]=m;return E.minX=Math.min(E.minX,y),E.maxX=Math.max(E.maxX,b),E},{minX:o,maxX:n}),f=[d.minX,d.maxX],u=[c.minY,c.maxY];let x=!1;if(d.minX!==d.maxX||c.minY!==c.maxY){const E=JSON.stringify(f)+JSON.stringify(u),w=(g=this.ctx.focusCell)==null?void 0:g.getSpanInfo();x=(w&&JSON.stringify(w.xArr)+JSON.stringify(w.yArr))===E}return{xArr:f,yArr:u,onlyMergeCell:x}}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;const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,o=e,n=i||this.ctx.maxRowIndex-s;if(this.ctx.focusCellHeader){const{colIndex:a}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),this.ctx.mousedown&&t.colIndex>=a){const l=[a,t.colIndex+t.colspan-1],c=[o,n];this.setSelector(l,c)}else{const l=[t.colIndex,a+t.colspan-1],c=[o,n];this.setSelector(l,c)}}}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:o,SELECTOR_AREA_MAX_Y:n,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-a,f=o,u=n||this.ctx.maxRowIndex-l,x=[c,d],g=[f,u];this.setSelector(x,g)}}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:o}=this.ctx.config,n=s||this.ctx.maxColIndex-o,a=i;if(e){this.ctx.setFocusCell(t);const l=[a,n],c=[t.rowIndex,t.rowIndex];this.setSelector(l,c)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const c=[a,n],d=[l,t.rowIndex];this.setSelector(c,d)}else{const c=[a,n],d=[t.rowIndex,l];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:o}=e,n=Math.min(i.colIndex,o),a=Math.max(i.colIndex,o),l=Math.min(i.rowIndex,s),c=Math.max(i.rowIndex,s),d=[n,a],f=[l,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:o}=i,{colIndex:n,rowIndex:a}=e,l=Math.min(n,s),c=Math.max(n,s),d=Math.min(a,o),f=Math.max(a,o),u=[l,c],x=[d,f];this.setSelector(u,x)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],o=[e.rowIndex,e.rowIndex];this.setSelector(s,o)}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(o=>o.rowIndex===t);return i==null?void 0:i.cells.find(o=>o.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY||this.ctx.domSelectionStr||this.ctx.textSelectionStr)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 n=this.ctx.focusCell;t=[[n.getValue()]],e=[n.colIndex,n.colIndex],i=[n.rowIndex,n.rowIndex]}else{const n={code:"ERR_MERGED_CELLS_COPY",message:this.ctx.locale.getText("mergeCellNoCopy")};this.ctx.hasEvent("error")?this.ctx.emit("error",n):console.error(n.message);return}const{BEFORE_COPY_METHOD:s}=this.ctx.config;if(typeof s=="function"){const a=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!a)return;t=a.data}const o=be(t);navigator.clipboard?navigator.clipboard.writeText(o).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(n=>console.error("Copy Failure:",n)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1,s=null){let o=[];const n=new Set;for(let l=0;l<=e[1]-e[0];l++)for(let c=0;c<=t[1]-t[0];c++){const d=l+e[0],f=c+t[0],u=this.ctx.database.getItemValueForRowIndexAndColIndex(d,f);if(u){const{rowKey:x,key:g}=u;this.ctx.database.getReadonly(x,g)||(n.add(x),o.push({rowKey:x,key:g,value:s,row:{}}))}}if(!o.length)return[];if(i)return o;this.ctx.database.batchSetItemValue(o,!0);let a=[];return n.forEach(l=>{a.push(this.ctx.database.getRowDataItemForRowKey(l))}),this.ctx.emit("clearSelectedDataChange",o,a),o}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 o=>{let n=Ce(o);const a=[i,i+n[0].length-1],l=[e,e+n.length-1],[c,d]=l,[f,u]=a,x=d-this.ctx.maxRowIndex,g=u-this.ctx.maxColIndex;(x>0||g>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:u,minY:c,minX:f,overflowRowCount:x,overflowColCount:g,textArr:n});const E=n.length===1&&n[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!E){const b={code:"ERR_MERGED_CELLS_PASTE",message:this.ctx.locale.getText("mergeCellNoPaste"),data:[]};this.ctx.hasEvent("error")?this.ctx.emit("error",b):console.error(b.message);return}let w=[];for(let b=0;b<=n.length-1;b++){const p=n[b].length;for(let C=0;C<=p-1;C++){const I=b+e,v=C+i,T=n[b][C],_=this.ctx.database.getItemValueForRowIndexAndColIndex(I,v);if(_){const{rowKey:R,key:S}=_;this.ctx.database.getReadonly(R,S)||(s.add(R),w.push({rowKey:R,key:S,value:T,row:{}}))}}}if(this.isCut){const b=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),p=w.map(C=>`${C.rowKey}-${C.key}`);b.forEach(C=>{p.includes(`${C.rowKey}-${C.key}`)||w.unshift(C)}),this.isCut=!1}if(!w.length)return;const{BEFORE_PASTE_DATA_METHOD:m}=this.ctx.config;if(typeof m=="function"){const b=m,p=w.map(C=>({rowKey:C.rowKey,key:C.key,value:C.value,oldValue:this.ctx.database.getItemValue(C.rowKey,C.key),row:this.ctx.database.getRowDataItemForRowKey(C.rowKey)}));if(w=await b(p,a,l,n),w&&!w.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(w,!0);let y=[];s.forEach(b=>{y.push(this.ctx.database.getRowDataItemForRowKey(b))}),this.ctx.emit("pasteChange",w,y),this.ctx.emit("draw")}).catch(o=>{console.error("Failed to get the clipboard content:",o)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const o=0,n=0,a=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>n&&s--;break;case"RIGHT":i<a&&i++;break;case"BOTTOM":s<l&&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")))}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:o,SELECTOR_AREA_MAX_Y:n,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-a,f=o,u=n||this.ctx.maxRowIndex-l;return!(e<c||e>d||t<f||t>u)}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:o,header:n,footer:a,body:l,scrollX:c,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:u,FOOTER_POSITION:x,ENABLE_MERGE_CELL_LINK:g}}=this.ctx;if(!i)return;g&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:E,drawY:w,width:m,height:y,fixed:b}=i,p=o-E+1,C=i.drawX+m-(e-s)+1;let I=n.height-w,v=y;v>l.visibleHeight&&(v=l.visibleHeight);let T=0;u&&(x==="top"?I=n.height+a.height-w:T=a.visibleHeight);const _=w+v-(t-T-f);let R=c,S=d;C>0&&!b?R=Math.floor(c+C):p>0&&!b&&(R=Math.floor(c-p)),I>0?S=Math.floor(d-I):_>0&&(S=Math.floor(d+_)),(Math.abs(c-R)>2.5||Math.abs(d-S)>2.5)&&this.ctx.setScroll(R,S)}destroy(){}}class qe{constructor(t){r(this,"ctx");r(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:o,drawX:n,drawY:a,width:l,height:c}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||o===this.ctx.maxRowIndex?0:2,u=n+l-d+f,x=a+c-d+f;e>u&&i>x&&e<u+d&&i<x+d&&(this.ctx.stageElement.style.cursor="crosshair"),this.ctx.autofillMove&&this.ctx.startAdjustPosition(t)}),this.ctx.on("cellMouseenter",t=>{const{xArr:e,yArr:i}=this.ctx.selector,s=e[1],o=i[1],{colIndex:n,rowIndex:a}=t;this.ctx.config.ENABLE_AUTOFILL&&n===s&&a===o&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp(),this.ctx.stopAdjustPosition()})}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,this.ctx.disableHoverIconClick=!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],setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0)}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_AUTOFILL_SPAN_COL:s,ENABLE_AUTOFILL_SPAN_ROW:o}=this.ctx.config;if(!i)return;let n=t,a=e;const l=this.ctx.selector.xArr,c=this.ctx.selector.yArr;if(!(!o&&JSON.stringify(c)!==JSON.stringify(a))&&!(!s&&JSON.stringify(l)!==JSON.stringify(n))&&(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(n)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(a))){const{SELECTOR_AREA_MIN_X:d,SELECTOR_AREA_MAX_X:f,SELECTOR_AREA_MIN_Y:u,SELECTOR_AREA_MAX_Y:x,SELECTOR_AREA_MAX_X_OFFSET:g,SELECTOR_AREA_MAX_Y_OFFSET:E}=this.ctx.config,w=d,m=f||this.ctx.maxColIndex-g,y=u,b=x||this.ctx.maxRowIndex-E;let[p,C]=n,[I,v]=a;if(p<w||I<y)return;n=[Math.max(w,p),Math.min(m,C)],a=[Math.max(y,I),Math.min(b,v)];const{BEFORE_SET_AUTOFILL_METHOD:T}=this.ctx.config;if(typeof T=="function"){const R=T({focusCell:this.ctx.focusCell,xArr:n,yArr:a});if(!R)return;n=R.xArr,a=R.yArr}this.ctx.autofill.xArr=n,this.ctx.autofill.yArr=a,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 x=0;x<=e.yArr[1]-e.yArr[0];x++)for(let g=0;g<=e.xArr[1]-e.xArr[0];g++){const E=x+e.yArr[0],w=g+e.xArr[0];i.set(`${E}-${w}`,!0)}const{value:s}=e,o=s[0].length,n=s.length,a=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr,c=o===1&&n===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!c){const x={code:"ERR_MERGED_CELLS_AUTOFILL",message:this.ctx.locale.getText("mergeCellNoFill"),data:[]};this.ctx.hasEvent("error")?this.ctx.emit("error",x):console.error(x.message);return}let d=[];for(let x=0;x<=l[1]-l[0];x++)for(let g=0;g<=a[1]-a[0];g++){const E=g+a[0],w=x+l[0],m=s[x%n][g%o],y=this.ctx.database.getItemValueForRowIndexAndColIndex(w,E),b=`${w}-${E}`;if(y&&!i.has(b)){const{rowKey:p,key:C}=y;this.ctx.database.getReadonly(p,C)||(t.add(p),d.push({rowKey:p,key:C,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 x=f,g=d.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(d=await x(g,a,l),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let u=[];t.forEach(x=>{u.push(this.ctx.database.getRowDataItemForRowKey(x))}),this.ctx.emit("autofillChange",d,u),this.ctx.emit("draw")}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:o}=t,n=e.xArr.slice(),a=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?o>e.xArr[1]?n.splice(1,1,o):o<e.xArr[0]&&n.splice(0,1,o):s>e.yArr[1]?a.splice(1,1,s):s<e.yArr[0]&&a.splice(0,1,s),this.setAutofill(n,a)}}destroy(){}}const q=Math.min,$=Math.max,ct=Math.round,nt=Math.floor,Y=h=>({x:h,y:h}),Je={left:"right",right:"left",bottom:"top",top:"bottom"};function It(h,t,e){return $(h,q(t,e))}function it(h,t){return typeof h=="function"?h(t):h}function G(h){return h.split("-")[0]}function st(h){return h.split("-")[1]}function re(h){return h==="x"?"y":"x"}function Lt(h){return h==="y"?"height":"width"}function V(h){const t=h[0];return t==="t"||t==="b"?"y":"x"}function Mt(h){return re(V(h))}function Qe(h,t,e){e===void 0&&(e=!1);const i=st(h),s=Mt(h),o=Lt(s);let n=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(n=ht(n)),[n,ht(n)]}function ti(h){const t=ht(h);return[vt(h),t,vt(t)]}function vt(h){return h.includes("start")?h.replace("start","end"):h.replace("end","start")}const Vt=["left","right"],Pt=["right","left"],ei=["top","bottom"],ii=["bottom","top"];function si(h,t,e){switch(h){case"top":case"bottom":return e?t?Pt:Vt:t?Vt:Pt;case"left":case"right":return t?ei:ii;default:return[]}}function oi(h,t,e,i){const s=st(h);let o=si(G(h),e==="start",i);return s&&(o=o.map(n=>n+"-"+s),t&&(o=o.concat(o.map(vt)))),o}function ht(h){const t=G(h);return Je[t]+h.slice(t.length)}function ni(h){return{top:0,right:0,bottom:0,left:0,...h}}function ae(h){return typeof h!="number"?ni(h):{top:h,right:h,bottom:h,left:h}}function dt(h){const{x:t,y:e,width:i,height:s}=h;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function zt(h,t,e){let{reference:i,floating:s}=h;const o=V(t),n=Mt(t),a=Lt(n),l=G(t),c=o==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,u=i[a]/2-s[a]/2;let x;switch(l){case"top":x={x:d,y:i.y-s.height};break;case"bottom":x={x:d,y:i.y+i.height};break;case"right":x={x:i.x+i.width,y:f};break;case"left":x={x:i.x-s.width,y:f};break;default:x={x:i.x,y:i.y}}switch(st(t)){case"start":x[n]-=u*(e&&c?-1:1);break;case"end":x[n]+=u*(e&&c?-1:1);break}return x}async function ri(h,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:n,elements:a,strategy:l}=h,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:u=!1,padding:x=0}=it(t,h),g=ae(x),w=a[u?f==="floating"?"reference":"floating":f],m=dt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(w)))==null||e?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),y=f==="floating"?{x:i,y:s,width:n.floating.width,height:n.floating.height}:n.reference,b=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),p=await(o.isElement==null?void 0:o.isElement(b))?await(o.getScale==null?void 0:o.getScale(b))||{x:1,y:1}:{x:1,y:1},C=dt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:l}):y);return{top:(m.top-C.top+g.top)/p.y,bottom:(C.bottom-m.bottom+g.bottom)/p.y,left:(m.left-C.left+g.left)/p.x,right:(C.right-m.right+g.right)/p.x}}const ai=50,li=async(h,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:n}=e,a=n.detectOverflow?n:{...n,detectOverflow:ri},l=await(n.isRTL==null?void 0:n.isRTL(t));let c=await n.getElementRects({reference:h,floating:t,strategy:s}),{x:d,y:f}=zt(c,i,l),u=i,x=0;const g={};for(let E=0;E<o.length;E++){const w=o[E];if(!w)continue;const{name:m,fn:y}=w,{x:b,y:p,data:C,reset:I}=await y({x:d,y:f,initialPlacement:i,placement:u,strategy:s,middlewareData:g,rects:c,platform:a,elements:{reference:h,floating:t}});d=b??d,f=p??f,g[m]={...g[m],...C},I&&x<ai&&(x++,typeof I=="object"&&(I.placement&&(u=I.placement),I.rects&&(c=I.rects===!0?await n.getElementRects({reference:h,floating:t,strategy:s}):I.rects),{x:d,y:f}=zt(c,u,l)),E=-1)}return{x:d,y:f,placement:u,strategy:s,middlewareData:g}},ci=h=>({name:"arrow",options:h,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:n,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=it(h,t)||{};if(c==null)return{};const f=ae(d),u={x:e,y:i},x=Mt(s),g=Lt(x),E=await n.getDimensions(c),w=x==="y",m=w?"top":"left",y=w?"bottom":"right",b=w?"clientHeight":"clientWidth",p=o.reference[g]+o.reference[x]-u[x]-o.floating[g],C=u[x]-o.reference[x],I=await(n.getOffsetParent==null?void 0:n.getOffsetParent(c));let v=I?I[b]:0;(!v||!await(n.isElement==null?void 0:n.isElement(I)))&&(v=a.floating[b]||o.floating[g]);const T=p/2-C/2,_=v/2-E[g]/2-1,R=q(f[m],_),S=q(f[y],_),O=R,M=v-E[g]-S,L=v/2-E[g]/2+T,H=It(O,L,M),D=!l.arrow&&st(s)!=null&&L!==H&&o.reference[g]/2-(L<O?R:S)-E[g]/2<0,A=D?L<O?L-O:L-M:0;return{[x]:u[x]+A,data:{[x]:H,centerOffset:L-H-A,...D&&{alignmentOffset:A}},reset:D}}}),hi=function(h){return h===void 0&&(h={}),{name:"flip",options:h,async fn(t){var e,i;const{placement:s,middlewareData:o,rects:n,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:u,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:E=!0,...w}=it(h,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const m=G(s),y=V(a),b=G(a)===a,p=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=u||(b||!E?[ht(a)]:ti(a)),I=g!=="none";!u&&I&&C.push(...oi(a,E,g,p));const v=[a,...C],T=await l.detectOverflow(t,w),_=[];let R=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&_.push(T[m]),f){const L=Qe(s,n,p);_.push(T[L[0]],T[L[1]])}if(R=[...R,{placement:s,overflows:_}],!_.every(L=>L<=0)){var S,O;const L=(((S=o.flip)==null?void 0:S.index)||0)+1,H=v[L];if(H&&(!(f==="alignment"?y!==V(H):!1)||R.every(k=>V(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:L,overflows:R},reset:{placement:H}};let D=(O=R.filter(A=>A.overflows[0]<=0).sort((A,k)=>A.overflows[1]-k.overflows[1])[0])==null?void 0:O.placement;if(!D)switch(x){case"bestFit":{var M;const A=(M=R.filter(k=>{if(I){const N=V(k.placement);return N===y||N==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(N=>N>0).reduce((N,Ct)=>N+Ct,0)]).sort((k,N)=>k[1]-N[1])[0])==null?void 0:M[0];A&&(D=A);break}case"initialPlacement":D=a;break}if(s!==D)return{reset:{placement:D}}}return{}}}},di=new Set(["left","top"]);async function fi(h,t){const{placement:e,platform:i,elements:s}=h,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),n=G(e),a=st(e),l=V(e)==="y",c=di.has(n)?-1:1,d=o&&l?-1:1,f=it(t,h);let{mainAxis:u,crossAxis:x,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(x=a==="end"?g*-1:g),l?{x:x*d,y:u*c}:{x:u*c,y:x*d}}const ui=function(h){return h===void 0&&(h=0),{name:"offset",options:h,async fn(t){var e,i;const{x:s,y:o,placement:n,middlewareData:a}=t,l=await fi(t,h);return n===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:n}}}}},xi=function(h){return h===void 0&&(h={}),{name:"shift",options:h,async fn(t){const{x:e,y:i,placement:s,platform:o}=t,{mainAxis:n=!0,crossAxis:a=!1,limiter:l={fn:m=>{let{x:y,y:b}=m;return{x:y,y:b}}},...c}=it(h,t),d={x:e,y:i},f=await o.detectOverflow(t,c),u=V(G(s)),x=re(u);let g=d[x],E=d[u];if(n){const m=x==="y"?"top":"left",y=x==="y"?"bottom":"right",b=g+f[m],p=g-f[y];g=It(b,g,p)}if(a){const m=u==="y"?"top":"left",y=u==="y"?"bottom":"right",b=E+f[m],p=E-f[y];E=It(b,E,p)}const w=l.fn({...t,[x]:g,[u]:E});return{...w,data:{x:w.x-e,y:w.y-i,enabled:{[x]:n,[u]:a}}}}}};function mt(){return typeof window<"u"}function Q(h){return le(h)?(h.nodeName||"").toLowerCase():"#document"}function B(h){var t;return(h==null||(t=h.ownerDocument)==null?void 0:t.defaultView)||window}function F(h){var t;return(t=(le(h)?h.ownerDocument:h.document)||window.document)==null?void 0:t.documentElement}function le(h){return mt()?h instanceof Node||h instanceof B(h).Node:!1}function X(h){return mt()?h instanceof Element||h instanceof B(h).Element:!1}function W(h){return mt()?h instanceof HTMLElement||h instanceof B(h).HTMLElement:!1}function $t(h){return!mt()||typeof ShadowRoot>"u"?!1:h instanceof ShadowRoot||h instanceof B(h).ShadowRoot}function ot(h){const{overflow:t,overflowX:e,overflowY:i,display:s}=K(h);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&s!=="inline"&&s!=="contents"}function gi(h){return/^(table|td|th)$/.test(Q(h))}function Et(h){try{if(h.matches(":popover-open"))return!0}catch{}try{return h.matches(":modal")}catch{return!1}}const wi=/transform|translate|scale|rotate|perspective|filter/,mi=/paint|layout|strict|content/,z=h=>!!h&&h!=="none";let bt;function At(h){const t=X(h)?K(h):h;return z(t.transform)||z(t.translate)||z(t.scale)||z(t.rotate)||z(t.perspective)||!Ht()&&(z(t.backdropFilter)||z(t.filter))||wi.test(t.willChange||"")||mi.test(t.contain||"")}function Ei(h){let t=P(h);for(;W(t)&&!J(t);){if(At(t))return t;if(Et(t))return null;t=P(t)}return null}function Ht(){return bt==null&&(bt=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),bt}function J(h){return/^(html|body|#document)$/.test(Q(h))}function K(h){return B(h).getComputedStyle(h)}function pt(h){return X(h)?{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop}:{scrollLeft:h.scrollX,scrollTop:h.scrollY}}function P(h){if(Q(h)==="html")return h;const t=h.assignedSlot||h.parentNode||$t(h)&&h.host||F(h);return $t(t)?t.host:t}function ce(h){const t=P(h);return J(t)?h.ownerDocument?h.ownerDocument.body:h.body:W(t)&&ot(t)?t:ce(t)}function et(h,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=ce(h),o=s===((i=h.ownerDocument)==null?void 0:i.body),n=B(s);if(o){const a=_t(n);return t.concat(n,n.visualViewport||[],ot(s)?s:[],a&&e?et(a):[])}else return t.concat(s,et(s,[],e))}function _t(h){return h.parent&&Object.getPrototypeOf(h.parent)?h.frameElement:null}function he(h){const t=K(h);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=W(h),o=s?h.offsetWidth:e,n=s?h.offsetHeight:i,a=ct(e)!==o||ct(i)!==n;return a&&(e=o,i=n),{width:e,height:i,$:a}}function Dt(h){return X(h)?h:h.contextElement}function Z(h){const t=Dt(h);if(!W(t))return Y(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=he(t);let n=(o?ct(e.width):e.width)/i,a=(o?ct(e.height):e.height)/s;return(!n||!Number.isFinite(n))&&(n=1),(!a||!Number.isFinite(a))&&(a=1),{x:n,y:a}}const pi=Y(0);function de(h){const t=B(h);return!Ht()||!t.visualViewport?pi:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function yi(h,t,e){return t===void 0&&(t=!1),!e||t&&e!==B(h)?!1:t}function U(h,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=h.getBoundingClientRect(),o=Dt(h);let n=Y(1);t&&(i?X(i)&&(n=Z(i)):n=Z(h));const a=yi(o,e,i)?de(o):Y(0);let l=(s.left+a.x)/n.x,c=(s.top+a.y)/n.y,d=s.width/n.x,f=s.height/n.y;if(o){const u=B(o),x=i&&X(i)?B(i):i;let g=u,E=_t(g);for(;E&&i&&x!==g;){const w=Z(E),m=E.getBoundingClientRect(),y=K(E),b=m.left+(E.clientLeft+parseFloat(y.paddingLeft))*w.x,p=m.top+(E.clientTop+parseFloat(y.paddingTop))*w.y;l*=w.x,c*=w.y,d*=w.x,f*=w.y,l+=b,c+=p,g=B(E),E=_t(g)}}return dt({width:d,height:f,x:l,y:c})}function yt(h,t){const e=pt(h).scrollLeft;return t?t.left+e:U(F(h)).left+e}function fe(h,t){const e=h.getBoundingClientRect(),i=e.left+t.scrollLeft-yt(h,e),s=e.top+t.scrollTop;return{x:i,y:s}}function Ci(h){let{elements:t,rect:e,offsetParent:i,strategy:s}=h;const o=s==="fixed",n=F(i),a=t?Et(t.floating):!1;if(i===n||a&&o)return e;let l={scrollLeft:0,scrollTop:0},c=Y(1);const d=Y(0),f=W(i);if((f||!f&&!o)&&((Q(i)!=="body"||ot(n))&&(l=pt(i)),f)){const x=U(i);c=Z(i),d.x=x.x+i.clientLeft,d.y=x.y+i.clientTop}const u=n&&!f&&!o?fe(n,l):Y(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+d.x+u.x,y:e.y*c.y-l.scrollTop*c.y+d.y+u.y}}function bi(h){return Array.from(h.getClientRects())}function Ri(h){const t=F(h),e=pt(h),i=h.ownerDocument.body,s=$(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=$(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let n=-e.scrollLeft+yt(h);const a=-e.scrollTop;return K(i).direction==="rtl"&&(n+=$(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:n,y:a}}const Gt=25;function Ii(h,t){const e=B(h),i=F(h),s=e.visualViewport;let o=i.clientWidth,n=i.clientHeight,a=0,l=0;if(s){o=s.width,n=s.height;const d=Ht();(!d||d&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=yt(i);if(c<=0){const d=i.ownerDocument,f=d.body,u=getComputedStyle(f),x=d.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(i.clientWidth-f.clientWidth-x);g<=Gt&&(o-=g)}else c<=Gt&&(o+=c);return{width:o,height:n,x:a,y:l}}function vi(h,t){const e=U(h,!0,t==="fixed"),i=e.top+h.clientTop,s=e.left+h.clientLeft,o=W(h)?Z(h):Y(1),n=h.clientWidth*o.x,a=h.clientHeight*o.y,l=s*o.x,c=i*o.y;return{width:n,height:a,x:l,y:c}}function Ut(h,t,e){let i;if(t==="viewport")i=Ii(h,e);else if(t==="document")i=Ri(F(h));else if(X(t))i=vi(t,e);else{const s=de(h);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return dt(i)}function ue(h,t){const e=P(h);return e===t||!X(e)||J(e)?!1:K(e).position==="fixed"||ue(e,t)}function _i(h,t){const e=t.get(h);if(e)return e;let i=et(h,[],!1).filter(a=>X(a)&&Q(a)!=="body"),s=null;const o=K(h).position==="fixed";let n=o?P(h):h;for(;X(n)&&!J(n);){const a=K(n),l=At(n);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ot(n)&&!l&&ue(h,n))?i=i.filter(d=>d!==n):s=a,n=P(n)}return t.set(h,i),i}function Ti(h){let{element:t,boundary:e,rootBoundary:i,strategy:s}=h;const n=[...e==="clippingAncestors"?Et(t)?[]:_i(t,this._c):[].concat(e),i],a=Ut(t,n[0],s);let l=a.top,c=a.right,d=a.bottom,f=a.left;for(let u=1;u<n.length;u++){const x=Ut(t,n[u],s);l=$(x.top,l),c=q(x.right,c),d=q(x.bottom,d),f=$(x.left,f)}return{width:c-f,height:d-l,x:f,y:l}}function Si(h){const{width:t,height:e}=he(h);return{width:t,height:e}}function Oi(h,t,e){const i=W(t),s=F(t),o=e==="fixed",n=U(h,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=Y(0);function c(){l.x=yt(s)}if(i||!i&&!o)if((Q(t)!=="body"||ot(s))&&(a=pt(t)),i){const x=U(t,!0,o,t);l.x=x.x+t.clientLeft,l.y=x.y+t.clientTop}else s&&c();o&&!i&&s&&c();const d=s&&!i&&!o?fe(s,a):Y(0),f=n.left+a.scrollLeft-l.x-d.x,u=n.top+a.scrollTop-l.y-d.y;return{x:f,y:u,width:n.width,height:n.height}}function Rt(h){return K(h).position==="static"}function jt(h,t){if(!W(h)||K(h).position==="fixed")return null;if(t)return t(h);let e=h.offsetParent;return F(h)===e&&(e=e.ownerDocument.body),e}function xe(h,t){const e=B(h);if(Et(h))return e;if(!W(h)){let s=P(h);for(;s&&!J(s);){if(X(s)&&!Rt(s))return s;s=P(s)}return e}let i=jt(h,t);for(;i&&gi(i)&&Rt(i);)i=jt(i,t);return i&&J(i)&&Rt(i)&&!At(i)?e:i||Ei(h)||e}const Li=async function(h){const t=this.getOffsetParent||xe,e=this.getDimensions,i=await e(h.floating);return{reference:Oi(h.reference,await t(h.floating),h.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Mi(h){return K(h).direction==="rtl"}const Ai={convertOffsetParentRelativeRectToViewportRelativeRect:Ci,getDocumentElement:F,getClippingRect:Ti,getOffsetParent:xe,getElementRects:Li,getClientRects:bi,getDimensions:Si,getScale:Z,isElement:X,isRTL:Mi};function ge(h,t){return h.x===t.x&&h.y===t.y&&h.width===t.width&&h.height===t.height}function Hi(h,t){let e=null,i;const s=F(h);function o(){var a;clearTimeout(i),(a=e)==null||a.disconnect(),e=null}function n(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();const c=h.getBoundingClientRect(),{left:d,top:f,width:u,height:x}=c;if(a||t(),!u||!x)return;const g=nt(f),E=nt(s.clientWidth-(d+u)),w=nt(s.clientHeight-(f+x)),m=nt(d),b={rootMargin:-g+"px "+-E+"px "+-w+"px "+-m+"px",threshold:$(0,q(1,l))||1};let p=!0;function C(I){const v=I[0].intersectionRatio;if(v!==l){if(!p)return n();v?n(!1,v):i=setTimeout(()=>{n(!1,1e-7)},1e3)}v===1&&!ge(c,h.getBoundingClientRect())&&n(),p=!1}try{e=new IntersectionObserver(C,{...b,root:s.ownerDocument})}catch{e=new IntersectionObserver(C,b)}e.observe(h)}return n(!0),o}function Tt(h,t,e,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=Dt(h),d=s||o?[...c?et(c):[],...t?et(t):[]]:[];d.forEach(m=>{s&&m.addEventListener("scroll",e,{passive:!0}),o&&m.addEventListener("resize",e)});const f=c&&a?Hi(c,e):null;let u=-1,x=null;n&&(x=new ResizeObserver(m=>{let[y]=m;y&&y.target===c&&x&&t&&(x.unobserve(t),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var b;(b=x)==null||b.observe(t)})),e()}),c&&!l&&x.observe(c),t&&x.observe(t));let g,E=l?U(h):null;l&&w();function w(){const m=U(h);E&&!ge(E,m)&&e(),E=m,g=requestAnimationFrame(w)}return e(),()=>{var m;d.forEach(y=>{s&&y.removeEventListener("scroll",e),o&&y.removeEventListener("resize",e)}),f==null||f(),(m=x)==null||m.disconnect(),x=null,l&&cancelAnimationFrame(g)}}const ft=ui,ut=xi,Nt=hi,Di=ci,xt=(h,t,e)=>{const i=new Map,s={platform:Ai,...e},o={...s.platform,_c:i};return li(h,t,{...s,platform:o})};let Ni=class{constructor(t){r(this,"ctx");r(this,"enable",!1);r(this,"contentEl");r(this,"floatingEl");r(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:o,CSS_PREFIX:n}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${n}-tooltip`,this.contentEl.className=`${n}-tooltip-content`,this.arrowEl.className=`${n}-tooltip-arrow`;const a={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},l={position:"absolute",width:"10px",height:"10px",background:a.background,backgroundColor:a.backgroundColor,transform:"rotate(45deg)",zIndex:a.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,a),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.floatingEl.addEventListener("mouseleave",()=>{this.hide()}),this.ctx.on("mouseout",t=>{this.floatingEl.contains(t.relatedTarget)||this.hide()}),this.ctx.on("onScroll",()=>{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()}),this.ctx.on("cellHeaderMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellHeaderHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)}),this.ctx.on("cellFooterMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellFooterHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)}),this.ctx.on("cellShowTooltip",(t,e)=>{this.show(t,e)}),this.ctx.on("cellHideTooltip",()=>{this.hide()})}show(t,e){if(this.ctx.contextMenuIng||!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let i=t.getText();t.message&&(i=t.message),e&&(i=e);const s=this.ctx.containerElement.getBoundingClientRect();if(!s)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=i;const o=t.drawX+s.x,n=t.drawY+s.y;xt({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:o,y:n,left:o,right:o+t.visibleWidth,top:n,bottom:n+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[ut(),Nt(),ft(6),Di({element:this.arrowEl})]}).then(l=>{const{x:c,y:d,placement:f,middlewareData:u}=l;if(Object.assign(this.floatingEl.style,{top:`${d}px`,left:`${c}px`}),u.arrow){const x=u.arrow;["left","left-start","left-end"].includes(f)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(f)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(f)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${x.x}px`,right:""}):["top","top-start","top-end"].includes(f)&&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 ki{constructor(t){r(this,"editorEl");r(this,"inputEl");r(this,"enable",!1);r(this,"cellTarget",null);r(this,"selectorArrStr","");r(this,"ctx");r(this,"drawY",0);r(this,"drawX",0);r(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,this.resetEditorStyle();const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i),this.focusInput()}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("hoverIconClick",t=>{this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell||this.ctx.finding)return;const{focusCell:e}=this.ctx;if(t.code==="Escape"&&this.ctx.editing){this.cancel=!0;const{focusCell:d}=this.ctx;d&&(this.ctx.emit("setSelectorCell",d),this.cellTarget=d),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.key==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const d=this.inputEl.selectionStart,f=this.inputEl.value.substring(0,d),u=this.inputEl.value.substring(d);this.inputEl.value=f+`
17
- `+u,this.inputEl.selectionStart=this.inputEl.selectionEnd=d+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.key==="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.key==="Enter"&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}const i=t.key,s=t.ctrlKey,o=t.altKey,n=t.shiftKey,a=t.metaKey;if(s||o||n||a||["Enter","CapsLock","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(i))return;if(!(document.activeElement===this.inputEl)&&e.editorType==="text"){t.preventDefault();return}this.startEdit(!0)}),this.ctx.on("cellClick",t=>{if(this.ctx.stageElement.style.cursor==="pointer"||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;const{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.focusInput(),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.resetEditorStyle(),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()}})}isTextSelectionActive(){return this.ctx.config.ENABLE_TEXT_SELECTION&&(this.ctx.textSelecting||!!this.ctx.textSelectionStr)}isInSelectorRange(t,e){const{xArr:i,yArr:s}=this.ctx.selector,[o,n]=i,[a,l]=s;return!(e<o||e>n||t<a||t>l)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.id="e-virt-table-editor-textarea",this.inputEl.setAttribute("rows","1"),this.inputEl.setAttribute("tabindex","-1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),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(){if(!this.ctx.editing)return;const t=this.inputEl.value;if(this.cellTarget&&this.cellTarget.type==="number"&&t!==""&&(this.ctx.emit("cellHideTooltip"),!/^-?\d+(\.\d+)?$/.test(t))){const c=this.ctx.locale.getText("numberErrorTip");this.ctx.emit("cellShowTooltip",this.cellTarget,c)}this.inputEl.style.height="auto";let e=this.inputEl.scrollHeight,i=this.ctx.body.visibleHeight;e>i&&(e=i);const{stageHeight:s,footer:o,header:n,config:{SCROLLER_TRACK_SIZE:a}}=this.ctx,l=s-o.height-a;this.editorEl.style.bottom="auto",this.drawY<n.height&&(this.editorEl.style.top=`${n.height-1}px`),this.drawY+e>l&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${s-l}px`),this.inputEl.style.height=`${e}px`}startEditByInput(t,e=!1){const i=e?null:t.getValue(),{editorType:s}=t;if(s==="none")return;t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:o,width:n,drawY:a,drawX:l}=t;this.drawX=l,this.drawY=a;const{config:{CELL_PADDING:c},header:d}=this.ctx;let f=this.ctx.body.visibleHeight;o>f&&(o=f),this.editorEl.style.zIndex="100",this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top=`${this.drawY}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxWidth="none",this.editorEl.style.maxHeight=`${f}px`,["text"].includes(s)?(this.inputEl.style.opacity="1",this.inputEl.style.position="relative",this.inputEl.style.minWidth=`${n-1}px`,this.inputEl.style.minHeight=`${o-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${n}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${c}px`,this.inputEl.value="",i!==null&&(this.inputEl.value=i),(this.inputEl.scrollHeight>o||this.drawY<d.height)&&this.autoSize()):(this.inputEl.style.opacity="0",this.inputEl.style.width="1px",this.inputEl.style.height="1px",this.inputEl.style.position="absolute",this.inputEl.style.left="0px",this.inputEl.style.top="0px")}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)}}focusInput(){document.activeElement!==this.inputEl&&this.inputEl.focus({preventScroll:!0})}startEdit(t=!1){if(this.isTextSelectionActive())return;this.cancel=!1;const{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;const i=this.ctx.focusCell;if(!i)return;i.isVerticalVisible()&&i.isHorizontalVisible()||this.ctx.emit("scrollToIndex",i.rowIndex,i.colIndex),this.editCell(i.rowIndex,i.colIndex,t)}editCell(t,e,i=!1){const s=this.ctx.body.renderRows.find(f=>f.rowIndex===t);if(!s)return;const o=s.cells.find(f=>f.colIndex===e);if(!o||!(o.isVerticalVisible()&&o.isHorizontalVisible()))return;this.ctx.emit("setSelectorCell",o);const a=this.ctx.focusCell;if(!a||["index","index-selection","selection"].includes(a.type)||this.enable)return;const{rowKey:l,key:c}=a,d=this.ctx.database.getReadonly(l,c);a&&!d&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=a,this.startEditByInput(this.cellTarget,i),this.ctx.emit("startEdit",this.cellTarget),this.ctx.emit("draw"))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("cellHideTooltip"),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.resetEditorStyle(),setTimeout(()=>{this.focusInput()},0),this.ctx.emit("draw"))}resetEditorStyle(){const t=this.cellTarget;t&&(this.editorEl.style.left=`${t.drawX}px`,this.editorEl.style.top=`${t.drawY}px`,this.editorEl.style.maxWidth="1px",this.editorEl.style.maxHeight="1px",this.editorEl.style.zIndex="-1")}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.inputEl.blur(),this.ctx.emit("draw")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}let Bi=class{constructor(t){r(this,"ctx");r(this,"emptyEl");this.ctx=t;const{EMPTY_CUSTOM_STYLE:e}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=this.getText()),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:i,headerHeight:s,bodyHeight:o,footerHeight:n})=>{const a=s+(o+n)/2,l={display:i==="empty"?"block":"none",top:`${a}px`,...e};Object.assign(this.emptyEl.style,l)})}getText(){return this.ctx.config.EMPTY_TEXT||this.ctx.locale.getText("emptyText")}draw(){this.ctx.emptyElement||(this.emptyEl.innerText=this.getText())}destroy(){this.emptyEl.remove()}};class Xi{constructor(t){r(this,"ctx");r(this,"observer");this.ctx=t,this.init()}arerMapsEqual(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t)if(!e.has(i)||e.get(i)!==s)return!1;return!0}init(){this.observer=new MutationObserver(St(()=>{const t=this.ctx.overlayerElement.querySelectorAll('[data-auto-height="true"]'),e=new Map;t.forEach(o=>{const n=Number(o.getAttribute("data-row-index")),a=Number(o.getAttribute("data-col-index"));if(isNaN(n)||isNaN(a))return;const l=o.getBoundingClientRect(),c=`${n}​_${a}`;e.set(c,Math.round(l.height))});const i=this.ctx.database.getOverlayerAutoHeightMap();if(!this.arerMapsEqual(i,e)){if(this.ctx.database.setOverlayerAutoHeightMap(e),i.size===0&&e.size===0)return;this.ctx.emit("draw")}},16.67)),this.observer.observe(this.ctx.overlayerElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.ctx.overlayerElement.getAttribute("data-overlayer")==="default"&&this.ctx.on("overlayerChange",t=>{const e=this.ctx.overlayerElement;e.replaceChildren(),Object.assign(e.style,t.style),t.views.forEach(i=>{const s=document.createElement("div");s.className=i.class,Object.assign(s.style,i.style),i.views.forEach(o=>{const n=document.createElement("div");Object.assign(n.style,o.style),o.cells.forEach(a=>{const l=document.createElement("div");Object.assign(l.style,a.style),Object.keys(a.domDataset).forEach(c=>{l.setAttribute(c,a.domDataset[c])}),typeof a.render=="function"&&a.render(l,a),n.appendChild(l)}),s.appendChild(n)}),e.appendChild(s)})})}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.observer&&this.observer.disconnect(),this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[];const{FOOTER_FIXED:o,FOOTER_POSITION:n}=this.ctx.config;return o?n==="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:o,visibleHeight:n,renderCellHeaders:a}=this.ctx.header;let l=[],c=[],d=[];a.forEach(w=>{w.render&&(w.fixed==="left"?c.push(w):w.fixed==="right"?d.push(w):l.push(w))});const f=e-i,u={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${n}px`},cells:c},x={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-f+1}px`,height:`${n}px`},cells:l},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f+1}px`,height:`${n}px`},cells:d};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${o}px`,height:`${n}px`},views:[u,x,g]}}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:o,fixedRightWidth:n,config:{SCROLLER_TRACK_SIZE:a,CSS_PREFIX:l}}=this.ctx,{visibleWidth:c,visibleHeight:d}=this.ctx.body,f=n-a,u={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${d}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o-.5}px`,overflow:"hidden",width:`${c-o-f}px`,height:`${d}px`},cells:t},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${l}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${c}px`,height:`${d}px`},views:[u,x,g]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(E=>{E.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:o,config:{SCROLLER_TRACK_SIZE:n,CSS_PREFIX:a}}=this.ctx,{visibleWidth:l,visibleHeight:c}=this.ctx.footer,d=o-n,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:`${l-s-d}px`,height:`${c}px`},cells:t},x={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:`${a}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${c}px`},views:[f,u,x]}}}class Zt{constructor(t,e=[],i={}){r(this,"container");r(this,"menuData");r(this,"onClick");r(this,"activeSubmenus",new Set);r(this,"boundMouseEnterHandler");r(this,"boundMouseLeaveHandler");r(this,"boundClickHandler");this.container=t,this.menuData=e,this.onClick=i.onClick,this.boundMouseEnterHandler=s=>this.handleMouseEvent(s,"enter"),this.boundMouseLeaveHandler=s=>this.handleMouseEvent(s,"leave"),this.boundClickHandler=s=>this.handleClick(s),this.createMenu(),this.bindEvents()}createMenu(){this.container.className="e-virt-table-main-menu",this.container.style.display="block";const t=document.createDocumentFragment();this.menuData.forEach(e=>{t.appendChild(this.createMenuItem(e))}),this.container.appendChild(t)}createMenuItem(t,e=!1){var n;const i=this.createElement("div",e?"e-virt-table-submenu-item":"e-virt-table-menu-item");i.setAttribute(e?"data-submenu":"data-menu",t.value),t.disabled&&i.classList.add("disabled");const s=this.createElement("div","e-virt-table-menu-item-content");if(t.icon){const a=this.createElement("span","e-virt-table-menu-item-icon");a.innerHTML=t.icon,s.appendChild(a)}else s.classList.add("menu-item-no-icon");const o=this.createElement("span","e-virt-table-menu-item-text");if(o.textContent=t.label||"",s.appendChild(o),i.appendChild(s),(n=t.children)!=null&&n.length){const a=this.createElement("span","e-virt-table-menu-arrow");a.innerHTML=lt,i.appendChild(a);const l=this.createSubmenu(t.children);i._submenu=l,this.container.appendChild(l)}return i}createSubmenu(t){const e=this.createElement("div","e-virt-table-submenu");return t.forEach(i=>{e.appendChild(this.createMenuItem(i,!0))}),e}createElement(t,e=""){const i=document.createElement(t);return e&&(i.className=e),i}bindEvents(){this.container.addEventListener("mouseenter",this.boundMouseEnterHandler,!0),this.container.addEventListener("mouseleave",this.boundMouseLeaveHandler,!0),this.container.addEventListener("click",this.boundClickHandler)}handleMouseEvent(t,e){t.stopPropagation();const s=t.target.closest(".e-virt-table-menu-item, .e-virt-table-submenu-item");s&&(this.container.contains(s)||s.classList.contains("e-virt-table-submenu-item"))&&(e==="enter"?this.handleHover(s):this.handleLeave(s))}handleHover(t){t.classList.contains("e-virt-table-menu-item")&&(this.container.querySelectorAll(".e-virt-table-menu-item").forEach(i=>i.classList.remove("active")),t.classList.contains("disabled")||t.classList.add("active"));const e=t._submenu||t.querySelector(".e-virt-table-submenu");e&&(this.hideSiblingSubmenus(t),this.showSubmenu(t,e))}handleLeave(t){const e=t._submenu||t.querySelector(".e-virt-table-submenu");setTimeout(()=>{const i=e;i&&!i.matches(":hover")&&!t.matches(":hover")&&(this.hideSubmenu(i),t.classList.contains("e-virt-table-menu-item")&&t.classList.remove("active"))},150)}hideSiblingSubmenus(t){let e;if(t.classList.contains("e-virt-table-menu-item"))e=this.container.querySelectorAll(".e-virt-table-menu-item");else{const i=t.closest(".e-virt-table-submenu");if(i)e=i.querySelectorAll(".e-virt-table-submenu-item");else return}e.forEach(i=>{i!==t&&i._submenu&&this.hideSubmenu(i._submenu)})}async showSubmenu(t,e){if(this.activeSubmenus.has(e))return;this.activeSubmenus.add(e),e.classList.add("show");const i=Tt(t,e,async()=>{const s=this.container.getBoundingClientRect(),o=window.innerWidth,n=e.offsetWidth||200,a=o-s.right,l=s.left,c=a>=n||a>=l?"right-start":"left-start",{x:d,y:f}=await xt(t,e,{placement:c,middleware:[ft(8),ut({padding:8})]});Object.assign(e.style,{left:`${d}px`,top:`${f}px`})});e._cleanup=i}hideSubmenu(t){if(!this.activeSubmenus.has(t))return;this.activeSubmenus.delete(t),t.classList.remove("show"),this.hideAllChildSubmenus(t);const e=t;e._cleanup&&(e._cleanup(),delete e._cleanup)}hideAllChildSubmenus(t){t.querySelectorAll(".e-virt-table-submenu-item").forEach(i=>{if(i._submenu){const s=i._submenu;if(this.activeSubmenus.has(s)){this.activeSubmenus.delete(s),s.classList.remove("show");const o=s;o._cleanup&&(o._cleanup(),delete o._cleanup),this.hideAllChildSubmenus(s)}}})}handleClick(t){t.stopPropagation();const e=t.target.closest(".e-virt-table-menu-item, .e-virt-table-submenu-item");if(!e||e.classList.contains("disabled"))return;if(e.classList.contains("e-virt-table-menu-item")){const o=e._submenu||e.querySelector(".e-virt-table-submenu");if(o){this.showSubmenu(e,o);return}}const i=e.getAttribute("data-menu")||(e==null?void 0:e.getAttribute("data-submenu")),s=this.findMenuItem(i||"");s&&this.onClick&&this.onClick(s,i||"")}findMenuItem(t,e=this.menuData){for(const i of e){if(i.value===t)return i;if(i.children){const s=this.findMenuItem(t,i.children);if(s)return s}}return null}positionMenu(t){const e={getBoundingClientRect:()=>({width:0,height:0,top:t.clientY,left:t.clientX,right:t.clientX,bottom:t.clientY,x:t.clientX,y:t.clientY}),contextElement:document.body};Tt(e,this.container,()=>{xt(e,this.container,{placement:"right-start",middleware:[ft(),ut(),Nt()]}).then(({x:i,y:s})=>{this.container&&Object.assign(this.container.style,{left:`${i}px`,top:`${s}px`})})})}destroy(){this.container.removeEventListener("mouseenter",this.boundMouseEnterHandler,!0),this.container.removeEventListener("mouseleave",this.boundMouseLeaveHandler,!0),this.container.removeEventListener("click",this.boundClickHandler),this.cleanupAllSubmenus(this.container),this.container.style.display="none",this.container.replaceChildren()}removeMenuItem(t){const e=this.container.querySelector(`[data-menu="${t}"]`);if(!e)return!1;const i=e.querySelector(".e-virt-table-submenu");return i&&this.cleanupSubmenuRecursively(i),e.remove(),!0}removeSubMenuItem(t){const e=this.container.querySelector(`[data-submenu="${t}"]`);if(!e)return!1;const i=e.closest(".e-virt-table-submenu"),s=e._submenu;if(s&&this.cleanupSubmenuRecursively(s),e.remove(),i&&i.querySelectorAll(".e-virt-table-submenu-item").length===0){const n=this.container.querySelector("[data-menu]");if(n&&n._submenu===i)this.removeMenuItem(n.getAttribute("data-menu")||"");else{const a=this.container.querySelectorAll("[data-menu], [data-submenu]");for(const l of a)if(l._submenu===i){const c=l.getAttribute("data-menu")||l.getAttribute("data-submenu");c&&(l.hasAttribute("data-menu")?this.removeMenuItem(c):this.removeSubMenuItem(c));break}}}return!0}cleanupAllSubmenus(t){t.querySelectorAll(".e-virt-table-menu-item").forEach(i=>{i._submenu&&(this.cleanupSubmenuRecursively(i._submenu),i._submenu=void 0)})}cleanupSubmenuRecursively(t){const e=t;e._cleanup&&(e._cleanup(),delete e._cleanup),t.querySelectorAll(".e-virt-table-submenu-item").forEach(s=>{s._submenu&&this.cleanupSubmenuRecursively(s._submenu)}),t.remove()}}class Ki{constructor(t){r(this,"ctx");r(this,"contextMenuEl");r(this,"currentDOMTreeMenu");r(this,"isCustom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.contextMenuEl=this.ctx.contextMenuElement,this.contextMenuEl.className="e-virt-table-main-menu",this.isCustom=!0):(this.contextMenuEl=document.createElement("div"),this.isCustom=!1),this.ctx.containerElement.appendChild(this.contextMenuEl),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.hide()}),this.ctx.on("cellContextMenuClick",async(t,e)=>{if(this.isCustom){this.contextMenuEl.style.display="block",this.positionMenu(e);return}const{ENABLE_CONTEXT_MENU:i,CUSTOM_BODY_CONTEXT_MENU:s,CONTEXT_MENU:o,BEFORE_BODY_CONTEXT_MENU_METHOD:n}=this.ctx.config;let a=o.map(m=>({...m,label:m.label||this.ctx.locale.getText(m.value)}));if(a=[...a,...s],n&&(a=await n({list:a,cell:t,hide:this.hide.bind(this)})),!i||a.length===0)return;e.preventDefault();const{xArr:l,yArr:c}=this.ctx.selector,[d,f]=l,[u,x]=c,{rowIndex:g,colIndex:E}=t;g>=u&&g<=x&&E>=d&&E<=f||this.ctx.emit("setSelectorCell",t,e),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy(),this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new Zt(this.contextMenuEl,a,{onClick:(m,y)=>{y==="copy"?(this.ctx.emit("contextMenuCopy"),this.hide()):y==="paste"?(this.ctx.emit("contextMenuPaste"),this.hide()):y==="cut"?(this.ctx.emit("contextMenuCut"),this.hide()):y==="clearSelected"?(this.ctx.emit("contextMenuClearSelected"),this.hide()):m.event&&m.event(e,{hide:this.hide.bind(this),cell:t})}}),this.currentDOMTreeMenu.positionMenu(e)}),this.ctx.on("cellHeaderContextMenuClick",async(t,e)=>{if(this.isCustom){this.contextMenuEl.style.display="block",this.positionMenu(e);return}const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:o,BEFORE_HEADER_CONTEXT_MENU_METHOD:n}=this.ctx.config,a=i,l=s||this.ctx.maxColIndex-o;if(t.colIndex<a||t.colIndex>l)return;const{HEADER_CONTEXT_MENU:c,CUSTOM_HEADER_CONTEXT_MENU:d,ENABLE_HEADER_CONTEXT_MENU:f}=this.ctx.config;let u=c.map(p=>({...p,label:p.label||this.ctx.locale.getText(p.value)}));if(u=[...u,...d],n&&(u=await n({list:u,cell:t,hide:this.hide.bind(this)})),!f||u.length===0)return;e.preventDefault();const{xArr:x}=this.ctx.selector,[g,E]=x,{colIndex:w}=t;w>=g&&w<=E||(this.ctx.focusCellHeader=t,this.ctx.emit("selectCols",t)),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy();const y=this.ctx.database.getColumns(),b=u.map(p=>p.value==="visible"?{...p,children:this.filterColumns(y)}:p);this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new Zt(this.contextMenuEl,b,{onClick:(p,C)=>{const{xArr:I}=this.ctx.selector,[v,T]=I;if(C==="fixedLeft"||C==="fixedRight"||C==="fixedNone"){const _=this.ctx.header.allCellHeaders.filter(R=>R.colIndex>=v&&R.colIndex<=T).filter(R=>R.level===0).filter(R=>!R.column.fixedDisabled).map(R=>R.key);this.ctx.database.setCustomHeaderFixedData(_,C==="fixedLeft"?"left":C==="fixedRight"?"right":""),this.hide()}else if(C==="hide"){const _=this.ctx.header.leafCellHeaders.filter(R=>R.colIndex>=v&&R.colIndex<=T).filter(R=>!R.children.length).filter(R=>!R.column.hideDisabled).map(R=>R.key);_.length>0&&this.ctx.database.setCustomHeaderHideData(_,!0),this.hide()}else if(C!=="visible")if(C.startsWith("visible_")){if(!p.key)return;if(p.children){const O=this.getLeafKeys(p.children);this.ctx.database.setCustomHeaderHideData(O,!1)}else this.ctx.database.setCustomHeaderHideData([p.key],!1);this.currentDOMTreeMenu&&this.currentDOMTreeMenu.removeSubMenuItem(C);const _=this.ctx.database.getColumns();tt(_).filter(O=>O.hide).length===0&&this.hide()}else C==="resetHeader"?(this.ctx.database.resetCustomHeader(),this.hide()):p.event&&p.event(e,{hide:this.hide.bind(this),cell:t})}}),this.positionMenu(e)}),this.ctx.on("click",()=>{this.hide()}),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}positionMenu(t){const e={getBoundingClientRect:()=>({width:0,height:0,top:t.clientY,left:t.clientX,right:t.clientX,bottom:t.clientY,x:t.clientX,y:t.clientY}),contextElement:document.body};Tt(e,this.contextMenuEl,()=>{xt(e,this.contextMenuEl,{placement:"right-start",middleware:[ft(),ut(),Nt()]}).then(({x:i,y:s})=>{this.contextMenuEl&&Object.assign(this.contextMenuEl.style,{left:`${i}px`,top:`${s}px`})})})}filterColumns(t){const e=[];for(const i of t)if(i.children&&i.children.length>0){const s=this.filterColumns(i.children);s.length>0&&e.push({label:i.title,key:i.key,value:`visible_${i.key}`,children:s})}else i.hide&&e.push({label:i.title,value:`visible_${i.key}`,key:i.key});return e}getLeafKeys(t){return t.reduce((e,i)=>(!i.children||i.children.length===0?e.push(String(i.key)):e.push(...this.getLeafKeys(i.children)),e),[])}hide(){this.currentDOMTreeMenu&&(this.currentDOMTreeMenu.destroy(),this.currentDOMTreeMenu=void 0),this.contextMenuEl.style.display="none",this.ctx.contextMenuIng=!1}destroy(){var t;this.hide(),(t=this.contextMenuEl)==null||t.remove()}}class Yi{constructor(t){r(this,"ctx");r(this,"loadingEl");r(this,"textEl",document.createElement("p"));if(this.ctx=t,this.ctx.loadingElement)this.loadingEl=this.ctx.loadingElement;else{this.loadingEl=document.createElement("div");const e=document.createElement("div");e.className="e-virt-table-loading-spinner";const i=this.ctx.icons.getSvg("loading");if(i){const n=new DOMParser().parseFromString(i.svg,"image/svg+xml").documentElement;e.appendChild(n)}this.textEl.className="e-virt-table-loading-text",this.textEl.innerText=this.getText(),e.appendChild(this.textEl),this.loadingEl.appendChild(e)}this.loadingEl.className="e-virt-table-loading",this.loadingEl.style.display="none",this.ctx.containerElement.appendChild(this.loadingEl)}getText(){return this.ctx.config.LOADING_TEXT||this.ctx.locale.getText("loadingText")}show(){this.loadingEl.style.display="flex"}hide(){this.loadingEl.style.display="none"}draw(){this.ctx.loadingElement||(this.textEl.innerText=this.getText())}destroy(){this.loadingEl.remove()}}class Fi{constructor(t){r(this,"ctx");r(this,"container");r(this,"input");r(this,"prevBtn");r(this,"nextBtn");r(this,"closeBtn");r(this,"countEl");r(this,"loadingEl");r(this,"isVisible",!1);r(this,"searchResults",[]);r(this,"currentIndex",-1);r(this,"searchData",[]);r(this,"isComposing",!1);this.ctx=t,this.container=this.createContainer(),this.ctx.containerElement.appendChild(this.container),this.bindEvents(),this.ctx.on("keydown",e=>{if(this.ctx.config.ENABLE_FINDER&&!this.ctx.editing){if((e.ctrlKey||e.metaKey)&&e.code==="KeyF"){e.preventDefault(),this.show();return}if(this.ctx.finding){if(e.code==="Escape"){e.preventDefault(),this.hide();return}if(e.code==="ArrowUp"||e.shiftKey&&e.key==="Enter"){e.preventDefault(),this.navigatePrevious();return}if(e.code==="ArrowDown"||e.key==="Enter"){e.preventDefault(),this.navigateNext();return}}}}),this.ctx.on("setSelector",()=>{this.hide()}),this.ctx.on("outsideMousedown",()=>{this.hide()})}async initSearchData(){this.showLoading(),this.searchData=[],setTimeout(()=>{const{allCellHeaders:t}=this.ctx.header;for(let s=0;s<t.length;s++){const o=t[s];o&&["string","number"].includes(typeof o.text)&&this.searchData.push({rowIndex:0,colIndex:o.colIndex,text:`${o.text}`,type:"header",colKey:o.key})}const{maxColIndex:e,maxRowIndex:i}=this.ctx;for(let s=0;s<=i;s++)for(let o=0;o<=e;o++){const n=this.ctx.database.getVirtualBodyCell(s,o,!1),a=n==null?void 0:n.getText();["string","number"].includes(typeof a)&&this.searchData.push({rowIndex:s,colIndex:o,text:`${a}`,type:"body"})}this.hideLoading()},0)}createContainer(){const t=document.createElement("div");t.className="e-virt-table-finder-bar";const e=document.createElement("div");e.className="e-virt-table-finder-bar-input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="e-virt-table-finder-bar-input",this.input.placeholder="",e.appendChild(this.input),this.loadingEl=document.createElement("div"),this.loadingEl.className="e-virt-table-finder-bar-loading";const i=se;this.loadingEl.innerHTML=i,e.appendChild(this.loadingEl),this.countEl=document.createElement("span"),this.countEl.className="e-virt-table-finder-bar-count";const s=document.createElement("div");return s.className="e-virt-table-finder-bar-nav",this.prevBtn=document.createElement("button"),this.prevBtn.className="e-virt-table-finder-bar-nav-btn prev-btn",this.prevBtn.innerHTML=lt,this.nextBtn=document.createElement("button"),this.nextBtn.className="e-virt-table-finder-bar-nav-btn next-btn",this.nextBtn.innerHTML=lt,s.appendChild(this.prevBtn),s.appendChild(this.nextBtn),this.closeBtn=document.createElement("button"),this.closeBtn.className="e-virt-table-finder-bar-nav-btn close-btn",this.closeBtn.innerHTML="×",t.appendChild(e),t.appendChild(this.countEl),t.appendChild(s),t.appendChild(this.closeBtn),t}bindEvents(){this.input.addEventListener("input",()=>{this.isComposing||this.performSearch()}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,this.performSearch()}),this.prevBtn.addEventListener("click",()=>{this.navigatePrevious()}),this.nextBtn.addEventListener("click",()=>{this.navigateNext()}),this.closeBtn.addEventListener("click",()=>{this.hide()})}performSearch(){const t=this.input.value.trim();if(this.searchResults=[],this.currentIndex=-1,!t){this.cearFinderBar(),this.updateCount();return}this.showLoading(),setTimeout(()=>{this.searchResults=this.searchData.filter(e=>e.text.toLowerCase().includes(t.toLowerCase())),this.searchResults.length>0?(this.currentIndex=0,this.scrollToCurrentResult()):this.cearFinderBar(),this.updateCount(),this.hideLoading()},0)}scrollToCurrentResult(){if(this.currentIndex<0||this.currentIndex>=this.searchResults.length)return;const t=this.searchResults[this.currentIndex];this.ctx.finderBar=t;const{rowIndex:e,colIndex:i}=t;this.ctx.emit("scrollToIndex",e,i)}navigateNext(){this.searchResults.length!==0&&(this.currentIndex=(this.currentIndex+1)%this.searchResults.length,this.scrollToCurrentResult(),this.updateCount())}navigatePrevious(){this.searchResults.length!==0&&(this.currentIndex=this.currentIndex<=0?this.searchResults.length-1:this.currentIndex-1,this.scrollToCurrentResult(),this.updateCount())}updateCount(){if(this.searchResults.length===0)this.input.value.trim()?(this.countEl.textContent="0/0",this.countEl.classList.add("no-results")):(this.countEl.textContent="",this.countEl.classList.remove("no-results"));else{const t=this.currentIndex+1,e=this.searchResults.length;this.countEl.textContent=`${t}/${e}`,this.countEl.classList.remove("no-results")}}show(){this.isVisible||(this.isVisible=!0,this.ctx.finding=!0,this.container.classList.add("show"),this.input.focus(),this.initSearchData())}showLoading(){var t;this.loadingEl.classList.add("show"),(t=this.loadingEl.parentElement)==null||t.classList.add("loading"),this.input.readOnly=!0}hideLoading(){var t;this.loadingEl.classList.remove("show"),(t=this.loadingEl.parentElement)==null||t.classList.remove("loading"),this.input.readOnly=!1}cearFinderBar(){this.ctx.finderBar={rowIndex:-1,colIndex:-1,text:"",type:"header"},this.ctx.emit("draw")}hide(){this.isVisible&&(this.isVisible=!1,this.container.classList.remove("show"),this.ctx.finding=!1,this.input.value="",this.searchResults=[],this.searchData=[],this.currentIndex=-1,this.hideLoading(),this.ctx.finderBar={rowIndex:-1,colIndex:-1,text:"",type:"header"},this.updateCount(),this.ctx.emit("draw"))}destroy(){this.hide(),this.container.remove()}}class Wi{constructor(t){r(this,"ctx");r(this,"layouts",new Map);r(this,"activeCellKey","");r(this,"selectionStart",null);r(this,"selectionEnd",null);r(this,"dragging",!1);this.ctx=t,this.init()}get canSelect(){return this.ctx.config.ENABLE_TEXT_SELECTION&&!this.ctx.editing&&!this.ctx.finding}hitTestLayouts(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s=null;for(const[o,n]of this.layouts){const a=this.hitTestText(n,e,i);a!==null&&(s={cellKey:o,index:a})}return s}syncSelection(){this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.emit("drawView")}init(){this.ctx.on("registerTextLayout",(t,e)=>{this.registerLayout(t,e)}),this.ctx.on("mousedown",t=>{if(!this.canSelect||!this.ctx.isTarget(t))return;this.ctx.containerElement.contains(document.activeElement)||this.ctx.containerElement.focus({preventScroll:!0});const e=this.hitTestLayouts(t);if(!e){this.clearSelection();return}this.activeCellKey=e.cellKey,this.selectionStart=e.index,this.selectionEnd=e.index,this.dragging=!0,this.ctx.textSelecting=!0,this.syncSelection()}),this.ctx.on("mousemove",t=>{if(!this.canSelect||!this.dragging)return;const e=this.layouts.get(this.activeCellKey);if(!e)return;const{offsetX:i,offsetY:s}=this.ctx.getOffset(t),o=this.hitTestText(e,i,s);o!==null&&(this.selectionEnd=o,this.syncSelection())}),this.ctx.on("mouseup",()=>{this.dragging=!1,this.ctx.textSelecting=!1,this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.textSelectionStr&&this.ctx.emit("drawView")}),this.ctx.on("keydown",t=>{var i;if(console.log("keydown"),!this.canSelect||!((t.ctrlKey||t.metaKey)&&t.code==="KeyC"))return;const e=this.getSelectedText();e&&(t.preventDefault(),(i=navigator.clipboard)==null||i.writeText(e).catch(s=>console.error("Copy Failure:",s)))}),this.ctx.on("outsideMousedown",()=>{this.clearSelection()})}hitTestText(t,e,i){const{contentBox:s,lines:o,glyphs:n,contentY:a,lineHeight:l}=t;if(e<s.x||e>s.x+s.width||i<s.y||i>s.y+s.height)return null;const c=i-a,d=Math.max(0,Math.min(Math.floor(c/l),o.length-1)),f=o[d],u=n.filter(x=>x.line===d);if(!u.length)return f.caretIndex;if(e<=u[0].x)return u[0].index;for(const x of u)if(e<x.x+x.width/2)return x.index;return u[u.length-1].index+1}registerLayout(t,e){this.layouts.set(t,e)}clearLayouts(){this.layouts.clear()}draw(){if(!this.ctx.config.ENABLE_TEXT_SELECTION)return;const t=this.getSelectionRange();if(!t)return;const e=this.layouts.get(this.activeCellKey);e&&this.drawTextSelection(e,t)}drawTextSelection(t,e,i="#fff",s="#3b82f6"){if(e.start>=e.end)return;const o=new Map;for(const a of t.glyphs){if(a.index<e.start||a.index>=e.end)continue;const l=o.get(a.line);l?l.push(a):o.set(a.line,[a])}if(!o.size)return;const n=this.ctx.paint.getCtx();n.save(),n.font=t.font,n.textBaseline="top",n.textAlign="left",o.forEach(a=>{const l=a[0],c=a[a.length-1];n.fillStyle=s,n.fillRect(l.x,l.y,c.x+c.width-l.x,l.height),n.fillStyle=i;for(const d of a)n.fillText(d.char,d.x,d.y)}),n.restore()}getSelectionRange(){return this.selectionStart===null||this.selectionEnd===null?null:{start:Math.min(this.selectionStart,this.selectionEnd),end:Math.max(this.selectionStart,this.selectionEnd)}}getSelectedText(){const t=this.getSelectionRange();if(!t||t.start>=t.end)return"";const e=this.layouts.get(this.activeCellKey);return e?e.chars.slice(t.start,t.end).join(""):""}clearSelection(){this.activeCellKey="",this.selectionStart=null,this.selectionEnd=null,this.dragging=!1,this.ctx.textSelectionStr=""}destroy(){this.layouts.clear(),this.clearSelection()}}const wt=class wt{constructor(t,e){r(this,"options");r(this,"scroller");r(this,"header");r(this,"body");r(this,"footer");r(this,"selector");r(this,"autofill");r(this,"tooltip");r(this,"editor");r(this,"empty");r(this,"overlayer");r(this,"contextMenu");r(this,"loading");r(this,"finderBar");r(this,"textSelector");r(this,"animationFrameId");r(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:o,contextMenuElement:n}=this.options,a=this.createContainer(t,i,s,o,n);this.ctx=new Pe(a,this.options),this.header=new Ge(this.ctx),this.footer=new je(this.ctx),this.body=new Ue(this.ctx),this.scroller=new ze(this.ctx),this.selector=new Ze(this.ctx),this.autofill=new qe(this.ctx),this.tooltip=new Ni(this.ctx),this.empty=new Bi(this.ctx),this.editor=new ki(this.ctx),this.overlayer=new Xi(this.ctx),this.contextMenu=new Ki(this.ctx),this.loading=new Yi(this.ctx),this.finderBar=new Fi(this.ctx),this.ctx.on("loadData",l=>{this.loadData(l)}),this.textSelector=new Wi(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}static useLocale(t){wt.locale=t}createContainer(t,e,i,s,o){t.className="e-virt-table-container";const n=document.createElement("div"),a=document.createElement("canvas"),l=e||document.createElement("div");n.className="e-virt-table-stage",t.tabIndex=0,a.className="e-virt-table-canvas",l.className="e-virt-table-overlayer",l.setAttribute("data-overlayer",e?"custom":"default");const c=i||document.createElement("div");c.className="e-virt-table-editor";const d=s,f=o;return n.appendChild(a),n.appendChild(l),t.appendChild(n),{containerElement:t,stageElement:n,canvasElement:a,overlayerElement:l,editorElement:c,emptyElement:d,contextMenuElement:f}}doDraw(t=!1){this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.textSelector.clearLayouts(),this.body.draw(),this.footer.draw(),this.header.draw(),this.textSelector.draw(),this.body.drawDragRowTip(),this.scroller.draw(),this.empty.draw(),this.loading.draw(),t||this.overlayer.draw()}draw(t=!1){this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=requestAnimationFrame(()=>{this.doDraw(t),this.body.updateAutoHeight()&&this.doDraw(t)})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(!1),this.header.init(),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.tooltip.hide(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setCustomHeader(t,e=!0){this.ctx.database.setCustomHeader(t,e),this.header.init(),this.ctx.emit("draw")}getCustomHeader(){return this.header.getCustomHeader()}showColumns(t,e=!0){this.ctx.database.setCustomHeaderHideData(t,!e),this.header.init(),this.ctx.emit("draw")}fixedColumns(t,e){this.ctx.database.setCustomHeaderFixedData(t,e),this.header.init(),this.ctx.emit("draw")}setLoading(t){this.ctx.loading=t,t?this.loading.show():this.loading.hide()}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.ctx.database.setFilterMethod(t),this.ctx.database.init(!1),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,o=!0,n=!1){this.ctx.database.setItemValue(t,e,i,s,o,n)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,o=!0){this.ctx.setItemValueByEditor(t,e,i,s,o),this.editor.doneEdit()}clearEditableData(t=null){const e=[0,this.ctx.maxColIndex],i=[0,this.ctx.maxRowIndex];return this.selector.clearSelectedData(e,i,!1,t)}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 o=[];for(let n=0;n<t.length;n++){const{rowKey:a,key:l}=t[n],c=await this.ctx.database.getValidator(a,l);Array.isArray(c)&&c.length&&o.push(c)}if(o.length){if(s(o),e){const[n]=o;if(Array.isArray(n)&&n.length){const[a]=n,{rowKey:l,key:c}=a;this.scrollToRowkey(l),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[o]=s;if(Array.isArray(o)&&o.length){const[n]=o,{rowKey:a,key:l}=n,c=this.ctx.database.getRowForRowKey(a);if(c){const{parentRowKeys:d=[]}=c;d&&d.length&&this.setExpandRowKeys(d,!0)}this.scrollToRowkey(a),this.scrollToColkey(l)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:o,rowKey:n}=e;if(i!==void 0&&n===void 0){const a=this.ctx.database.getRowKeyForRowIndex(i);this.ctx.database.setValidationErrorByRowKey(a,s,o)}n&&this.ctx.database.setValidationErrorByRowKey(n,s,o)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowKey)this.scrollToRowkey(e.rowKey),this.scrollToColkey(e.key);else if(e&&e.rowIndex!==void 0&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return this.ctx.config.DISABLED?new Promise(t=>{t([])}):new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let o=[];for(let n=0;n<i.length;n++)for(let a=0;a<s.length;a++){const l=this.ctx.database.getRowKeyByItem(i[n]),d=s[a].key,f=await this.ctx.database.getValidator(l,d);Array.isArray(f)&&f.length&&o.push(f)}o.length?(e(o),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)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:Ie,mergeRowCell:Re,getSpanArrByRow:Qt,getSpanObjByColumn:te}}getColumnByKey(t){var e;return(e=this.ctx.database.getColumnByKey(t))==null?void 0:e.column}clearChangeData(){this.ctx.database.clearChangeData(),this.ctx.emit("draw")}getReadonly(t,e){return this.ctx.database.getReadonly(t,e)}useLocale(t){this.ctx.locale.use(t)}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.loading.destroy(),this.finderBar.destroy(),this.textSelector.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}};r(wt,"locale");let gt=wt;module.exports=gt;
2
+ "use strict";var Te=Object.defineProperty;var Se=(h,t,e)=>t in h?Te(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var n=(h,t,e)=>Se(h,typeof t!="symbol"?t+"":t,e);class Oe{constructor(t){n(this,"rules");this.rules=t}validate(t){const e=[],{column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,value:c,field:d,fieldValue:f}=t;Array.isArray(this.rules)||(this.rules=[this.rules]);for(const u of this.rules){if(u.validator){const x={field:d,fieldValue:f,value:c,column:i,colIndex:a,rowIndex:l,row:s,key:o,rowKey:r,...u};u.validator(x,c,g=>{g&&e.push({...x,message:g})})}if(!u.required&&(c==null||c===""))return e;u.pattern&&!u.pattern.test(c)&&e.push({value:c,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is pattern validation error`}),u.required&&(c==null||c==="")&&e.push({value:c,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is required`})}return e}}function ae(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(h){const t=Math.random()*16|0;return(h==="x"?t:t&3|8).toString(16)})}function Nt(h,t){let e=0,i;return function(...s){const o=new Date().getTime(),r=o-e,a=typeof t=="function"?t():t;!e||r>=a?(h.apply(this,s),e=o):i||(i=setTimeout(()=>{h.apply(this,s),e=new Date().getTime(),i=void 0},a-r))}}function ht(h=[]){return h.length?h.map(t=>ht(t.children)+1).sort((t,e)=>e-t)[0]:0}function Le(h=[]){let t=[],e=[],i=[];return h.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,o)=>(s.sort??0)-(o.sort??0)),...e.sort((s,o)=>(s.sort??0)-(o.sort??0)),...i.sort((s,o)=>(s.sort??0)-(o.sort??0))]}function dt(h=[],t=1,e=0,i=""){return h.sort((s,o)=>(s.sort??0)-(o.sort??0)).map(s=>{if(s.children){let o=0,r=s.fixed;s.children.forEach(l=>{l.fixed=r});const a=dt(s.children,t-1,e+1,s.key);return a&&a.forEach(l=>{o+=l.colspan??0}),{...s,width:s.width,level:e,rowspan:1,colspan:o,parentKey:i,children:a.sort((l,c)=>(l.sort??0)-(c.sort??0))}}return{...s,level:e,rowspan:t,colspan:1,parentKey:i}})}function st(h=[]){let t=[];return h.forEach(e=>{e.children?t=t.concat(st(e.children)):t.push(e)}),t}function le(h){return h.filter(t=>!t.hide).map(t=>Array.isArray(t.children)&&t.children.length>0?{...t,children:le(t.children)}:{...t})}const Pt=/^(\r\n|\n\r|\r|\n)/,Me=/^[^\t\r\n]+/,zt=/^\t/;function Ae(h){let t=[[""]];if(h.length===0)return t;let e=0,i=0,s;for(;h.length>0&&s!==h.length;)if(s=h.length,h.match(zt))h=h.replace(zt,""),e+=1,t[i][e]="";else if(h.match(Pt))h=h.replace(Pt,""),e=0,i+=1,t[i]=[""];else{let o="";if(h.startsWith('"')){let r=0,a=!0;for(;a;){const l=h.slice(0,1);l==='"'&&(r+=1),o+=l,h=h.slice(1),(h.length===0||h.match(/^[\t\r\n]/)&&r%2===0)&&(a=!1)}o=o.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const r=h.match(Me);o=r?r[0]:"",h=h.slice(o.length)}t[i][e]=o}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 He(h){let t,e,i,s,o="",r;for(t=0,e=h.length;t<e;t+=1){for(s=h[t].length,i=0;i<s;i+=1)i>0&&(o+=" "),r=h[t][i],typeof r=="string"?r.indexOf(`
3
+ `)>-1?o+=`"${r.replace(/"/g,'""')}"`:o+=r:r==null?o+="":o+=r;t!==e-1&&(o+=`
4
+ `)}return o}function ce(h,t,e=[]){let i=0;const s=[];return h.forEach((o,r)=>{if(r===0)s.push(1);else{const a=e.reduce((c,d)=>`${c}${o[d]??""}`,"")||o[t],l=e.reduce((c,d)=>`${c}${h[r-1][d]??""}`,"")||h[r-1][t];a===l?(s[i]+=1,s.push(0)):(s.push(1),i=r)}}),s}function he(h,t){let e="",i="";const s={};return t.forEach((o,r)=>{r===0?(e=o.key,i=o.key,s[o.key]=1):h[o.key]===h[e]?(s[o.key]=0,s[i]+=1):(s[o.key]=1,e=o.key,i=o.key)}),s}function De(h,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=h,r=ce(i,t,e);return r[s-o]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:r[s-o],colspan:1,relationRowKeys:e,mergeRow:!0}}function Ne(h,t=[]){const{column:e,row:i,visibleLeafColumns:s}=h,o=s.filter(r=>t.includes(r.key));if(t.includes(e.key)){const r=he(i,o);return r[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:r[e.key],relationColKeys:t,mergeCol:!0}}}function ke(h,t=document.documentElement){const e=h.startsWith("--")?h:`--${h}`;return getComputedStyle(t).getPropertyValue(e).trim()}function Gt(h){if(!h)return new Date(0);if(typeof h=="number")return new Date(h);const t=String(h).trim(),e=new Date(t);if(!isNaN(e.getTime()))return e;const i=[/^(\d{4})-(\d{1,2})-(\d{1,2})$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/,/^(\d{4})\.(\d{1,2})\.(\d{1,2})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{4})(\d{2})(\d{2})$/,/^(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/];for(const s of i){const o=t.match(s);if(o){const r=o.slice(1).map(Number);if(s.source.includes("YYYY-MM-DD")||s.source.includes("YYYY/MM/DD")||s.source.includes("YYYY.MM.DD")){const[a,l,c,d=0,f=0,u=0]=r;return new Date(a,l-1,c,d,f,u)}else if(s.source.includes("DD-MM-YYYY")||s.source.includes("DD/MM/YYYY")||s.source.includes("DD.MM.YYYY")){const[a,l,c,d=0,f=0,u=0]=r;return new Date(c,l-1,a,d,f,u)}else if(s.source.includes("MM-DD-YYYY")||s.source.includes("MM/DD/YYYY")||s.source.includes("MM.DD.YYYY")){const[a,l,c,d=0,f=0,u=0]=r;return new Date(c,a-1,l,d,f,u)}else if(s.source.includes("YYYYMMDD")){const[a,l,c]=r;return new Date(a,l-1,c)}}}return new Date(NaN)}function Be(h,t){const e=Gt(h),i=Gt(t);return isNaN(e.getTime())&&isNaN(i.getTime())?0:isNaN(e.getTime())?-1:isNaN(i.getTime())?1:e.getTime()-i.getTime()}function Xe(h){const t=String(h).match(/\.(\d+)/);return(t==null?void 0:t[1].length)??0}function Ye(h){return(h.scrollbarMode??h.SCROLLBAR_MODE)==="inner"?"inner":"outer"}function V(h){return Ye(h)==="inner"}function B(h){return V(h)?0:h.SCROLLER_TRACK_SIZE||0}function de(h){return h.SCROLLER_TRACK_SIZE||0}function $t(h,t){return!V(h)||!t?0:de(h)}function Ke(h){return V(h)?1:0}function Fe(h){return!V(h)}function We(h){return!V(h)}function Ve(h,t){return V(h)&&t}function Pe(h,t){return V(h)?t.innerVisible||t.isFocus||t.isDragging:!0}class fe{constructor(t,e,i,s,o,r,a){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"fixed");n(this,"cellType");n(this,"drawX",0);n(this,"drawY",0);n(this,"cellImages",new Map);this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=o,this.fixed=a,this.cellType=r}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,o=t;return!(this.x+this.width-e-i<=0||this.x-i>=o-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}=this.ctx;return t-(this.ctx.header.width-this.x)-B(this.ctx.config)}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}isInside(t,e){return t>=this.drawX&&t<=this.drawX+this.width&&e>=this.drawY&&e<=this.drawY+this.height}isInsideVisible(t,e){return t>=this.drawX&&t<=this.drawX+this.visibleWidth&&e>=this.drawY&&e<=this.drawY+this.visibleHeight&&this.isInside(t,e)}setImage(t,e){this.cellImages.set(t,e)}getImages(){return this.cellImages}getImage(t){return this.cellImages.get(t)}isImageInside(t,e){const{offsetX:i,offsetY:s}=this.ctx.getOffset(e),o=this.getImage(t);return o?o.isInside(i,s):!1}}class q{constructor(t,e,i,s,o,r){n(this,"source");n(this,"name");n(this,"x");n(this,"y");n(this,"width");n(this,"height");n(this,"visible",!0);this.source=r,this.name=t,this.x=e-1,this.y=i-1,this.width=s,this.height=o}drawWrapper(t,e){t.paint.drawRect(this.x-2,this.y-2,this.width+4,this.height+4,{radius:4,borderWidth:1,...e})}setVisible(t){this.visible=t}isInside(t,e){return this.visible?!!(this.source&&t>this.x&&t<this.x+this.width&&e>this.y&&e<this.y+this.height):!1}}function rt(h){return h===!0?"default":h===!1?"inner":h}function St(h){return rt(h)==="default"}function kt(h){const t=rt(h);return t==="default"||t==="inner"}function ze(h){const t=rt(h);return t==="default"||t==="outer"}function Ot(h){return rt(h)==="default"}function Ge(h,t){return Ot(h)||t}class ue extends fe{constructor(e,i,s,o,r,a,l,c,d,f="body",u=!0){super(e,o,r,a,l,f,c.fixed);n(this,"parentRowKey","");n(this,"parentRowKeys",[]);n(this,"formatter");n(this,"formatterFooter");n(this,"hoverIconName","");n(this,"operation",!1);n(this,"align");n(this,"verticalAlign");n(this,"fixed");n(this,"type");n(this,"editorType");n(this,"editorProps");n(this,"cellType");n(this,"level");n(this,"colspan",1);n(this,"rowspan",1);n(this,"mergeRow",!1);n(this,"mergeCol",!1);n(this,"relationRowKeys",[]);n(this,"relationColKeys",[]);n(this,"key");n(this,"column");n(this,"rowIndex");n(this,"colIndex");n(this,"rowKey");n(this,"row");n(this,"value");n(this,"render");n(this,"renderFooter");n(this,"style",{});n(this,"domDataset",{});n(this,"rules",[]);n(this,"message","");n(this,"text","");n(this,"displayText","");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"isHasChanged",!1);n(this,"drawX",0);n(this,"drawY",0);n(this,"drawCellBgColor","");n(this,"drawCellSkyBgColor","");n(this,"drawTextColor","");n(this,"drawTextFont","");n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"autoRowHeight",!1);n(this,"calculatedHeight",0);n(this,"ellipsis",!1);n(this,"rowExpand",!1);n(this,"rowHasChildren",!1);n(this,"overflowTooltipShow",!0);n(this,"selectorCellValueType","value");n(this,"overflowTooltipMaxWidth",500);n(this,"overflowTooltipPlacement","top");n(this,"maxLineClamp","auto");n(this,"precision");n(this,"min");n(this,"max");n(this,"maxlength");n(this,"mixedRender",!1);n(this,"renderType","default");n(this,"renderFooterType","default");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.selectorCellValueType=c.selectorCellValueType||this.ctx.config.SELECTOR_CELL_VALUE_TYPE||"value",this.editorProps=c.editorProps||{},this.cellType=f,this.align=c.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=c.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,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.autoRowHeight=c.autoRowHeight!==void 0?c.autoRowHeight:this.ctx.config.AUTO_ROW_HEIGHT,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.maxLineClamp=c.maxLineClamp||"auto",this.precision=c.precision,this.min=c.min,this.max=c.max,this.maxlength=c.maxlength,this.mixedRender=c.mixedRender||!1,this.renderType=c.renderType||"default",this.renderFooterType=c.renderFooterType||"default";const x=this.ctx.database.getRowForRowKey(this.rowKey);this.cellType==="body"&&x&&(this.parentRowKey=x.parentRowKey,this.parentRowKeys=x.parentRowKeys),u&&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.updateSpan(),this.updateDragImage();const e=this.getImage("drag"),i=e?e.width:0;this.drawTextX=this.drawX+i,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.drawTextWidth=this.visibleWidth-i,this.drawTextHeight=this.visibleHeight,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:o=1,relationRowKeys:r,relationColKeys:a,mergeRow:l=!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(r)&&r.length>0?this.relationRowKeys=r:this.relationRowKeys=[this.key],Array.isArray(a)&&a.length>0?this.relationColKeys=a:this.relationColKeys=[this.key],this.mergeCol=c,this.mergeRow=l,this.colspan=s,this.rowspan=o,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:o,props:r={}}=s;this.editorType=o,this.editorProps=r}}}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.autoRowHeight&&(this.domDataset={"data-auto-height":!0,"data-row-index":this.rowIndex,"data-col-index":this.colIndex}),this.style=this.getOverlayerViewsStyle()}isInsideVisible(e,i){return e>=this.drawX&&e<=this.drawX+this.visibleWidth&&i>=this.drawY&&i<=this.drawY+this.visibleHeight}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,r=0,a="";if(!(["tree","selection-tree","tree-selection"].includes(this.type)&&s==="body"))return;const l=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:d=!1,expandLoading:f=!1,level:u=0}=l||{};this.rowExpand=c,this.rowHasChildren=d;const{TREE_INDENT:x=16,CHECKBOX_SIZE:g,TREE_ICON_SIZE:E}=this.ctx.config;if(r=u*x,f){const _=this.ctx.icons.get("loading");a="loading",o=_}else if(d){const _=this.ctx.icons.get("expand"),R=this.ctx.icons.get("shrink");o=c?R:_,a=c?"shrink":"expand"}let m=E,w=E,y=this.drawX;(this.align==="center"||this.align==="right")&&(y=this.drawX+(this.visibleWidth-m-2*e)/2,this.align="left");let b=y+r+e,p=this.drawY+(this.visibleHeight-w)/2,C=r+this.drawX+m-.5;const v=this.getImage("selection"),I=this.getImage("drag"),T=I?I.width:0;if(this.type==="selection-tree"&&v){const _=v.x,R=v.width;b=r+_+R,C=b+m-e/2}else this.type==="tree-selection"?(b+=T,C=b+g+m-e/2):(b+=T,C=b+m-e/2);this.drawTextX=C,this.drawTextWidth=this.drawX+this.visibleWidth-C,!(b+m+e>this.drawX+this.visibleWidth)&&(p+w+e>this.drawY+this.visibleHeight||this.setImage("tree",new q(a,b,p,m,w,o)))}updateDragImage(){if(this.cellType==="body"&&this.column.dragRow){const{DRAG_ROW_ICON_SIZE:e,CELL_PADDING:i}=this.ctx.config,s=this.drawX+i/2,o=this.drawY+(this.visibleHeight-e)/2,r=new q("drag",s,o,e,e,this.ctx.icons.get("drag"));this.rowspan===0&&r.setVisible(!1),this.setImage("drag",r)}}drawTreeLine(){const{TREE_LINE:e,TREE_INDENT:i=16,TREE_ICON_SIZE:s=16,TREE_LINE_COLOR:o="#e1e6eb"}=this.ctx.config;if(!e||this.cellType!=="body"||!["tree","selection-tree","tree-selection"].includes(this.type)||this.rowspan===0||this.colspan===0)return;const r=this.ctx.database.getRowForRowKey(this.rowKey)||{},a=r.level??0,l=this.getImage("tree");if(!l)return;const c=l.x,d=l.y,f=l.width,u=l.height,x=c+f/2,g=d+u/2;let E=c-a*i;const m=Array.isArray(r.parentRowKeys)?r.parentRowKeys:[];if(a>0){for(let C=0;C<a-1;C+=1){const v=m[C+1];if(!!(v?this.ctx.database.getRowForRowKey(v)||{}:{}).isLastChild)continue;const _=Math.round(c-(a-C)*i+s/2);this.ctx.paint.drawLine([_,this.drawY,_,this.drawY+this.visibleHeight],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}const w=Math.round(c-i+s/2),b=!!r.isLastChild?g:this.drawY+this.visibleHeight;this.ctx.paint.drawLine([w,this.drawY,w,b],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0});const p=Math.round(E+(a-1)*i+s/2);this.ctx.paint.drawLine([p,g,x,g],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}if(r.hasChildren&&r.expand){const w=d+u,y=this.drawY+this.visibleHeight;this.ctx.paint.drawLine([x,w,x,y],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:o,READONLY_TEXT_COLOR:r,BODY_TEXT_COLOR:a,FOOTER_TEXT_COLOR:l,FOOTER_BG_COLOR:c,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:u,HIGHLIGHT_HOVER_ROW_COLOR:x,STRIPE:g,STRIPE_COLOR:E,FINDER_CELL_BG_COLOR:m}=this.ctx.config;if(this.cellType==="footer"){let S=c,O=l;if(typeof o=="function"){const M=o,{backgroundColor:L,color:H,font:D}=M({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};L&&(S=L),H&&(O=H),D&&(this.drawTextFont=D)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=S,this.drawTextColor=O;return}let w="transparent";const y=this.ctx.hoverCell,b=this.ctx.currentCell;let p=this.rowIndex,C=this.rowIndex;if(this.rowspan!==1&&(u||d)){const S=this.getSpanInfo(),{yArr:O}=S;p=O[0],C=O[1]}u&&y&&!this.ctx.dragRowIng&&(y.rowKey===this.rowKey&&(w=x),y.rowIndex>=p&&y.rowIndex<=C&&(w=x)),d&&b&&!this.ctx.dragRowIng&&(b.rowKey===this.rowKey&&(w=f),b.rowIndex>=p&&b.rowIndex<=C&&(w=f)),this.drawCellSkyBgColor=w;let v=e,I=a;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(v=i,I=r),g&&(this.rowIndex%2?v=E:v=e),typeof s=="function"){const S=s,{backgroundColor:O,color:M,font:L}=S({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};O&&(v=O),M&&(I=M),L&&(this.drawTextFont=L)}const{rowIndex:T,colIndex:_,type:R}=this.ctx.finderBar;T===this.rowIndex&&_===this.colIndex&&R==="body"&&(v=m),this.drawCellBgColor=v,this.drawTextColor=I}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:a,rowIndex:l,rowKey:c}=this;if(s===0||o===0||r==="footer"||!["index-selection","selection","selection-tree","tree-selection"].includes(a))return;const d=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:f=0,CELL_PADDING:u}=this.ctx.config;let x=this.drawX+u;(this.align==="center"||this.align==="right")&&(x=this.drawX+(e-f)/2);let g=x,E=this.drawY+(i-f)/2;if(a!=="selection-tree"){if(a==="tree-selection"){const{TREE_INDENT:C=16,TREE_ICON_SIZE:v}=this.ctx.config,I=this.ctx.database.getRowForRowKey(c),{level:T=0}=I||{},_=T*C;g=x+v+_}}let m=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";if(a==="selection-tree"||a==="tree-selection"){const C=this.ctx.database.getTreeSelectionState(c);C.indeterminate&&d?(m=this.ctx.icons.get("checkbox-indeterminate"),w="checkbox-indeterminate"):C.checked&&d?(m=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):!C.checked&&d?(m=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(m=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled")}else{const C=this.ctx.database.getRowSelection(c);C&&d?(m=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):C&&!d?(m=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!C&&d?(m=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(m=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled")}const y=this.getImage("drag"),b=y?y.width:0;if(g+=b,g+f+u>this.drawX+this.visibleWidth||E+f+u>this.drawY+this.visibleHeight)return;const p=new q(w,g,E,f,f,m);if(a==="index-selection"){p.setVisible(!1),(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(w))&&p.setVisible(!0);let C=this.rowIndex,v=this.rowIndex;const I=this.ctx.hoverCell,T=this.getSpanInfo(),{yArr:_}=T;C=_[0],v=_[1],I&&I.rowIndex>=C&&I.rowIndex<=v&&p.setVisible(!0)}this.setImage("selection",p)}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:o,ENABLE_MERGE_CELL_LINK:r}=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:a}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&!this.ctx.dragRowIng&&a){let l=0,c=0;if(a.rowKey===this.rowKey&&(l=this.drawX+this.width-s-o,c=this.drawY+(this.height-s)/2),this.rowspan!==1&&r){const u=this.getSpanInfo(),{yArr:x}=u,g=x[0],E=x[1];if(a.rowIndex>=g&&a.rowIndex<=E){const{width:m,height:w,offsetTop:y,offsetLeft:b}=u;l=this.drawX-b+m-s-o,c=this.drawY-y+(w-s)/2}}const d=this.ctx.icons.get(this.hoverIconName),f=new q(this.hoverIconName,l,c,s,s,d);(this.rowspan===0||this.colspan===0)&&f.setVisible(!1),this.setImage("hover",f)}}getAutoHeight(){if(this.cellType!=="body"||!this.autoRowHeight||this.rowspan===0)return 0;if(this.render){const a=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);return this.rowspan>1?a<this.visibleHeight?0:Math.round(a-(this.visibleHeight-this.height)):Math.round(a)}if(!(this.displayText&&typeof this.displayText=="string"))return 0;const{BODY_FONT:e,CELL_PADDING:i,CELL_LINE_HEIGHT:s}=this.ctx.config,o=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`,r=this.ctx.paint.calculateTextHeight(this.displayText,this.drawTextWidth,{font:this.drawTextFont||e,padding:i,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor,autoRowHeight:this.autoRowHeight,lineHeight:s,maxLineClamp:this.maxLineClamp,cacheTextKey:o});return this.rowspan>1?r<this.visibleHeight?0:Math.round(r-(this.visibleHeight-this.height)):Math.round(r)}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){if(this.cellType==="footer")return this.renderFooter&&this.renderFooterType==="default"||this.text===null||this.text===void 0?"":this.text;{if(this.rowspan===0||this.colspan===0||this.render&&this.renderType==="default"&&!this.mixedRender)return"";const e=this.getImage("selection");return this.type==="index-selection"&&e&&e.visible||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,i=this.drawY-this.ctx.body.y;if(this.fixed==="left"?e=this.drawX:this.fixed==="right"&&(e=this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=this.drawY-this.ctx.footer.y),this.autoRowHeight&&this.render&&this.verticalAlign==="middle"){const o=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);if(o<this.visibleHeight&&o>0){const r=(this.visibleHeight-o)/2;i=i+r}}this.autoRowHeight&&this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex)===0&&(e=-99999,i=-99999);let s={};return this.rowspan===0&&(s={display:"none"}),{position:"absolute",overflow:"hidden",left:`${Math.round(e-1)}px`,top:`${Math.round(i-1)}px`,width:`${this.visibleWidth}px`,height:this.autoRowHeight&&this.renderType==="default"?"auto":`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none",...s}}drawContainer(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx,{drawX:o,drawY:r}=this,a=St(s);e.drawRect(o,r,this.visibleWidth,this.visibleHeight,{borderColor:a?i:"transparent",fillColor:this.drawCellBgColor}),e.drawRect(o,r,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor})}drawHorizontalBorder(){const{config:{BORDER_COLOR:e,BORDER:i}}=this.ctx;if(St(i)||!kt(i))return;const{drawX:s,drawY:o}=this;this.ctx.paint.drawLine([s,o+this.visibleHeight,s+this.visibleWidth,o+this.visibleHeight],{borderColor:e,fillColor:e,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:o}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:r,yArr:a}=this.ctx.selector,l=r[1],c=a[1],{colIndex:d,rowIndex:f,drawX:u,drawY:x}=this;if(d===l&&f===c){const E=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(u+this.width-E,x+this.height-E,6,6,{borderColor:o,fillColor:e})}}draw(){this.drawTreeLine(),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let o=e;o<e+i;o++){const r=this.ctx.header.leafCellHeaders[o];s+=r.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s,CELL_LINE_HEIGHT:o}=this.ctx.config,{placeholder:r}=this.column;let a=this.displayText,l=this.drawTextColor;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&r&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=r,l=s),["",null,void 0].includes(a))return!1;typeof a!="string"&&(a=`${a}`);const d=`${a}_${this.drawTextWidth}_${this.drawTextFont}`;return this.ellipsis=this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:l,autoRowHeight:this.autoRowHeight,lineHeight:o,maxLineClamp:this.maxLineClamp,cacheTextKey:d,layoutCallback:f=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.rowIndex}-${this.colIndex}`,f)}}),this.ellipsis}drawImage(){this.getImages().forEach((e,i)=>{if(e.visible&&e.source){if(i==="hover"){const{CELL_HOVER_ICON_BG_COLOR:s,CELL_HOVER_ICON_BORDER_COLOR:o}=this.ctx.config;e.drawWrapper(this.ctx,{borderColor:o,fillColor:s})}this.ctx.paint.drawImage(e.source,e.x,e.y,e.width,e.height)}})}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:o,yArrCopy:r}=this.ctx.selector;this.drawBorder({xArr:o,yArr:r,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[a,l]=i,[c,d]=s;!(a===l&&c===d)&&this.colIndex>=a&&this.colIndex<=l&&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,o=this.drawX,r=this.drawY,a=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:r,height:a,width:l}=this;let c=i,d=s;const{xArr:f,yArr:u,lineDash:x=[],borderWidth:g=1,borderColor:E,fillColor:m}=e,w=f[0],y=f[1],b=u[0],p=u[1];if(r>=w&&r<=y&&o===b){const C=r===y?1:0,v=r===w?1:0;this.ctx.paint.drawLine([c+v,d+1,c+l-C,d+1],{borderColor:E,fillColor:m,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===y&&o>=b&&o<=p){const C=o===b?1:0,v=o===p?1:0;this.ctx.paint.drawLine([c+l-1,d+C,c+l-1,d+a-v],{borderColor:E,fillColor:m,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(r>=w&&r<=y&&o===p){const C=r===y?1:0,v=r===w?1:0;this.ctx.paint.drawLine([c+v,d+a-1,c+l-C,d+a-1],{borderColor:E,fillColor:m,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===w&&o>=b&&o<=p){const C=o===p?1:0,v=o===b?1:0;this.ctx.paint.drawLine([c+1,d+v,c+1,d+a-C],{borderColor:E,fillColor:m,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:x})}}}class $e{constructor(t,e){n(this,"ctx");n(this,"data");n(this,"columns");n(this,"footerData",[]);n(this,"rowKeyMap",new Map);n(this,"colIndexKeyMap",new Map);n(this,"headerMap",new Map);n(this,"rowIndexRowKeyMap",new Map);n(this,"rowKeyRowIndexMap",new Map);n(this,"checkboxKeyMap",new Map);n(this,"selectionMap",new Map);n(this,"expandMap",new Map);n(this,"originalDataMap",new Map);n(this,"changedDataMap",new Map);n(this,"validationErrorMap",new Map);n(this,"itemRowKeyMap",new WeakMap);n(this,"bufferData",[]);n(this,"customHeader",{fixedData:{},sortData:{},hideData:{},resizableData:{}});n(this,"overlayerAutoHeightMap",new Map);n(this,"maxRowHeightCellMap",new Map);n(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});n(this,"sumHeight",0);n(this,"filterMethod");n(this,"positions",[]);n(this,"sortState",new Map);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.init()}init(t=!0){this.ctx.paint.clearTextCache(),this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear(),this.maxRowHeightCellMap.clear();const e=this.getColumns(),i=st(e);if(this.ctx.hasSelection=i.some(s=>s.type==="selection"),this.ctx.hasTree=i.some(s=>{var o;return(o=s.type)==null?void 0:o.includes("tree")}),t){this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear();const{ROW_KEY:s}=this.ctx.config;s?(this.ctx.hasSelection||this.selectionMap.clear(),this.ctx.hasTree||this.expandMap.clear()):(this.selectionMap.clear(),this.expandMap.clear())}this.itemRowKeyMap=new WeakMap,this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}initData(t,e=0,i=[]){const s=t.length,{ROW_KEY:o="",DEFAULT_EXPAND_ALL:r,CELL_HEIGHT:a,SELECTABLE_METHOD:l,CHECKBOX_KEY:c,TREE_CHILDREN_KEY:d}=this.ctx.config;t.forEach((f,u)=>{var b;d!=="children"&&(f.children=f[d]);const x=f[o],g=x??ae();this.itemRowKeyMap.set(f,g);const E=f._height||a,m=f._readonly;let w=!0;if(typeof l=="function"&&(w=l),c){const p=f[c];if(this.checkboxKeyMap.has(p)){const C=this.checkboxKeyMap.get(p)||[];C.push(g),this.checkboxKeyMap.set(p,C)}else this.checkboxKeyMap.set(p,[g])}this.selectionMap.set(g,{key:c?f[c]:g,row:f,check:((b=this.selectionMap.get(g))==null?void 0:b.check)||!1});const y=r||this.expandMap.get(g)||f._expand||!1;this.expandMap.set(g,y),this.rowKeyMap.set(g,{readonly:m,index:u,rowIndex:u,level:e,height:E,calculatedHeight:-1,check:!1,selectable:w,expand:y,expandLazy:!1,hasChildren:f._hasChildren||(Array.isArray(f.children)?f.children.length>0:!1),expandLoading:!1,item:f,parentRowKeys:i,parentRowKey:i[i.length-1]||"",isLastChild:u===s-1}),Array.isArray(f.children)&&f.children.length&&this.initData(f.children,e+1,[...i,g])})}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()}setBatchRowHeight(t){t.forEach(({rowIndex:e,height:i})=>{const s=this.rowIndexRowKeyMap.get(e);if(s){const o=this.rowKeyMap.get(s);o.height=i,o.item._height=i}}),this.clearBufferData()}setBatchCalculatedRowHeight(t){return t.every(({height:i,rowIndex:s})=>this.getPositionForRowIndex(s).calculatedHeight===i)?!1:(t.forEach(({rowIndex:i,height:s})=>{const o=this.rowIndexRowKeyMap.get(i);if(o){const r=this.rowKeyMap.get(o),{height:a=-1}=this.getMaxRowHeightItem(o)||{};r.calculatedHeight=Math.max(s,a)}}),this.clearBufferData(),this.getData(),!0)}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}generateColumns(t){const e=i=>i.map(s=>{var c,d,f,u,x,g,E,m;const o=s.children&&Array.isArray(s.children)?e(s.children):void 0,r={hide:(d=(c=this.customHeader)==null?void 0:c.hideData)==null?void 0:d[s.key],fixed:(u=(f=this.customHeader)==null?void 0:f.fixedData)==null?void 0:u[s.key],sort:(g=(x=this.customHeader)==null?void 0:x.sortData)==null?void 0:g[s.key],width:(m=(E=this.customHeader)==null?void 0:E.resizableData)==null?void 0:m[s.key]},a={};for(const[w,y]of Object.entries(r))y!==void 0&&(a[w]=y);const l=o&&o.every(w=>w.hide);return{...s,children:o,hide:l||(typeof s.hide=="function"?s.hide(s):s.hide),...a}});return e(t)}getColumns(){return this.generateColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.init()}getOriginalData(){return this.data}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=o=>{o==null||o.forEach(r=>{t.push(r);const a=this.itemRowKeyMap.get(r),{expand:l,hasChildren:c,height:d,calculatedHeight:f}=this.rowKeyMap.get(a),u=this.sumHeight,x=Math.max(f,d);this.sumHeight+=x,this.rowIndexRowKeyMap.set(e,a),this.rowKeyRowIndexMap.set(a,e),this.positions.push({top:u,height:x,bottom:this.sumHeight,calculatedHeight:f}),e+=1,l&&c&&i(r.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;if(typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),this.sortState.size){const o=Array.from(this.sortState.entries()).sort((r,a)=>r[1].timestamp-a[1].timestamp);s=this.sortDataRecursive(s,o)}return 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}getSortState(t){return this.sortState.get(t)||{direction:"none",timestamp:0}}setSortState(t,e){const i=Date.now();this.ctx.config.SORT_STRICTLY&&this.sortState.clear(),e==="none"?this.sortState.delete(t):this.sortState.set(t,{direction:e,timestamp:i}),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}clearSort(){this.sortState.clear(),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}sortDataRecursive(t,e){let i=[...t];for(const[s,{direction:o}]of e){if(o==="none")continue;const r=this.getColumnByKey(s);!r||!r.column.sortBy||(i=this.applySingleColumnSort(i,s,o,r.column.sortBy))}return i.map(s=>(s.children&&Array.isArray(s.children)&&(s.children=this.sortDataRecursive(s.children,e)),s))}applySingleColumnSort(t,e,i,s){return t.sort((o,r)=>{const a=o[e],l=r[e];let c=0;if(typeof s=="function")c=s(o,r);else if(s==="number"){const d=Number(a)||0,f=Number(l)||0;c=d-f}else if(s==="string"){const d=String(a||""),f=String(l||"");c=d.localeCompare(f)}else s==="date"&&(c=Be(a,l));return i==="asc"?c:-c})}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.expandMap.set(t,e),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){this.expandMap.clear(),t.forEach(i=>{const s=this.rowKeyMap.get(i);this.expandMap.set(i,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.expandMap.clear(),this.rowKeyMap.forEach((e,i)=>{e.expand=t,this.expandMap.set(i,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,!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),o=this.colIndexKeyMap.get(e);return s===void 0||o===void 0?null:{rowKey:s,key:o,value:this.getItemValue(s,o)}}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,i=!0,s="none"){let o=[],r=i;const a=new Map,l=[];let c=[];for(const g of t){const{rowKey:E,key:m}=g;let w=g.value;const y=this.getRowDataItemForRowKey(E),b=this.getItemValue(E,m),p=this.getVirtualBodyCellByKey(E,m),C={...g,oldValue:b,row:y};if((p==null?void 0:p.type)==="number")if(["",void 0,null].includes(w))w=null;else if(/^-?\d+(\.\d+)?$/.test(String(w))){const v=Xe(w);if(typeof p.precision=="number"&&p.precision>=0&&v>p.precision){const I=10**p.precision;w=Math.round(Number(w)*I)/I;const T=this.ctx.locale.getText("numberTruncated",{precision:p.precision});l.push({...C,column:p==null?void 0:p.column,code:"ERR_NUMBER_PRECISION",message:T})}else if(typeof p.min=="number"&&Number(w)<p.min){const I=this.ctx.locale.getText("numberMin",{min:p.min});w=p.min,l.push({...C,column:p==null?void 0:p.column,code:"ERR_NUMBER_MIN",message:I})}else if(typeof p.max=="number"&&Number(w)>p.max){const I=this.ctx.locale.getText("numberMax",{max:p.max});w=p.max,l.push({...C,column:p==null?void 0:p.column,code:"ERR_NUMBER_MAX",message:I})}else w=Number(w)}else w=b,l.push({...C,column:p==null?void 0:p.column,code:"ERR_INVALID_NUMBER",message:this.ctx.locale.getText("invalidNumber")});else if((p==null?void 0:p.editorType)==="text"&&typeof p.maxlength=="number"&&String(w).length>p.maxlength){w=String(w).slice(0,p.maxlength);const v=this.ctx.locale.getText("stringMaxlength",{maxlength:p.maxlength});l.push({...C,column:p==null?void 0:p.column,code:"ERR_STRING_MAXLENGTH",message:v})}w!==b&&c.push({...g,value:w,oldValue:b,row:y})}if(l.length){const g={code:"ERR_BATCH_SET_ITEM_VALUE",message:this.ctx.locale.getText("batchSetItemValueError"),data:l};this.ctx.emit("error",g)}if(!c.length)return;const{BEFORE_VALUE_CHANGE_METHOD:d}=this.ctx.config;s==="none"&&typeof d=="function"&&(c=await d(c),r=!1);const f=[];c.forEach(g=>{f.push(this.getValidator(g.rowKey,g.key));const{value:E,rowKey:m,key:w,row:y}=g,b=this.getItemValue(m,w);a.set(m,y),this.setItemValue(m,w,E,!1,!1,!1,r),o.push({rowKey:m,key:w,oldValue:b,newValue:E})});const u=Array.from(a.values());await Promise.all(f),this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData());const x=c.map(g=>{const E=!!this.getValidationError(g.rowKey,g.key).length;return{...g,errorTip:E}});this.ctx.emit("change",x,u),e&&this.ctx.history.pushState({changeList:o,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,o=!1,r=!1,a=!0){if(!this.rowKeyMap.has(t))return{};const{item:l}=this.rowKeyMap.get(t);let c=l[e],d=i;if(a&&this.ctx.database.getReadonly(t,e))return{oldValue:c,newValue:c};l[e]!==null&&typeof l[e]=="object"&&(c=JSON.parse(JSON.stringify(l[e])));const f=`${t}​_${e}`;this.originalDataMap.has(f)||this.originalDataMap.set(f,c);const u=this.originalDataMap.get(f),x=this.getRowDataItemForRowKey(t),g={rowKey:t,key:e,value:d,oldValue:c,row:x};if(r){if(d===c)return{oldValue:c,newValue:c};this.batchSetItemValue([g],s,!1),this.ctx.emit("editChange",{...g,originalValue:u})}else this.changedDataMap.set(f,d),l[e]=d;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{...g,originalValue:u}),o&&this.ctx.emit("draw"),{oldValue:c,newValue:d}}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),o=s[i];this.checkboxKeyMap.has(o)&&(this.checkboxKeyMap.get(o)||[]).forEach(a=>{const l=this.selectionMap.get(a);l&&(l.check=e)})}}toggleRowSelection(t,e){const i=this.rowKeyMap.get(t),s=this.selectionMap.get(t);if(!s)return;e==="selection-tree"||e==="tree-selection"?this.toggleTreeSelection(t):(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check)),this.ctx.emit("toggleRowSelection",i);const o=this.getSelectionRows();this.ctx.emit("selectionChange",o),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}toggleTreeSelection(t){const e=this.getTreeSelectionState(t),i=this.ctx.config.TREE_SELECT_MODE;if(i==="auto")e.checked&&!e.indeterminate?(this.clearTreeSelectionRecursive(t),this.setRowSelection(t,!1,!1)):(this.selectTreeSelectionRecursive(t),this.setRowSelection(t,!0,!1));else if(i==="cautious")e.checked&&!e.indeterminate?(this.clearTreeSelectionRecursive(t),this.setRowSelection(t,!1,!1)):(this.selectTreeSelectionRecursive(t),this.setRowSelection(t,!0,!1));else if(i==="strictly"){const s=this.selectionMap.get(t);s&&(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check))}this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}selectTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelectionByParent(i,!0),this.selectTreeSelectionRecursive(i)})}clearTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelectionByParent(i,!1),this.clearTreeSelectionRecursive(i)})}updateParentTreeSelection(t){const e=this.getTreeParent(t);if(!e)return;const s=this.getTreeChildren(e).map(c=>this.selectionMap.get(c)),o=s.filter(c=>c==null?void 0:c.check).length,r=s.length;let a=!1;r>0&&(o===0?a=!1:o===r||this.ctx.config.TREE_SELECT_MODE==="auto"?a=!0:this.ctx.config.TREE_SELECT_MODE==="cautious"&&(a=!1));const l=this.selectionMap.get(e);l&&l.check!==a&&(l.check=a,this.setRowSelectionByCheckboxKey(e,a),this.updateParentTreeSelection(e))}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),(this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious")&&this.updateParentTreeSelection(t),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}setRowSelectionByParent(t,e){const i=this.selectionMap.get(t);i&&(i.check=e,this.setRowSelectionByCheckboxKey(t,i.check))}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}getTreeSelectionState(t){if(!this.getRowForRowKey(t))return{checked:!1,indeterminate:!1};const i=this.selectionMap.get(t),s=(i==null?void 0:i.check)||!1;if(this.getTreeChildren(t).length===0)return{checked:s,indeterminate:!1};let r=!1,a=s;if(this.ctx.config.TREE_SELECT_MODE==="auto"){const c=m=>{const w=this.getTreeChildren(m);let y=[];for(const b of w)y.push(b),y.push(...c(b));return y},f=c(t).map(m=>this.selectionMap.get(m)),u=f.filter(m=>m==null?void 0:m.check).length,x=f.length,g=u>0;r=g&&!(u===x),a=s||g,s&&x>0&&u===0&&(a=!1,r=!1)}else if(this.ctx.config.TREE_SELECT_MODE==="cautious"){const c=m=>{const w=this.getTreeChildren(m);let y=[];for(const b of w)y.push(b),y.push(...c(b));return y},f=c(t).map(m=>this.selectionMap.get(m)),u=f.filter(m=>m==null?void 0:m.check).length,x=f.length,g=u>0,E=u===x;r=g&&!E,a=s||E,s&&x>0&&u===0&&(a=!1,r=!1)}else this.ctx.config.TREE_SELECT_MODE==="strictly"&&(r=!1,a=s);return{checked:a,indeterminate:r}}getTreeChildren(t){const e=this.getRowForRowKey(t);if(!e||!e.item||!e.item.children)return[];const i=[],s=o=>{for(const r of o){const a=this.getRowKeyByItem(r);a&&i.push(a),r.children&&r.children.length>0&&s(r.children)}};return s(e.item.children),i}getTreeParent(t){const e=(i,s)=>{for(const o of i){const r=this.getRowKeyByItem(o);if(o.children)for(const a of o.children){if(this.getRowKeyByItem(a)===s)return r;const c=e(o.children,s);if(c)return c}}return null};return e(this.data,t)}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.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious"?this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;if(typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o){const r=this.selectionMap.get(s);r&&(r.check=!0,this.setRowSelectionByCheckboxKey(s,!0))}}):this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o&&this.setRowSelection(s,!0,!1)});const e=this.getSelectionRows();this.ctx.emit("toggleAllSelection",e),this.ctx.emit("selectionChange",e),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){const e=this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious";t?e?this.rowKeyMap.forEach((s,o)=>{const r=this.selectionMap.get(o);r&&(r.check=!1,this.setRowSelectionByCheckboxKey(o,!1))}):this.rowKeyMap.forEach((s,o)=>{this.setRowSelection(o,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((s,o)=>{this.selectionMap.set(o,{check:!1,row:s.item,key:o})}));const i=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",i),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,o=0;const r=this.selectionMap.size,a=Array.from(this.selectionMap.values()).some(u=>u.check);this.rowKeyMap.forEach((u,x)=>{var E;(E=this.selectionMap.get(x))!=null&&E.check&&(s+=1);let g=u.selectable;typeof g=="function"&&(g=g({row:u.item,rowIndex:u.rowIndex})),g&&(o+=1)});const l=r>i&&s===0&&a,c=o&&o>s&&s>0||l,d=o!==0,f=!!o&&o===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),o=i.split("​_")[0],r=i.split("​_")[1];s!==e&&t.push({rowKey:o,colKey:r,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(o),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const o=this.originalDataMap.get(s),r=s.split("​_")[0];o!==i&&t.add(r)});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),o=this.changedDataMap.get(i);return s!==o}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0,calculatedHeight: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),o=this.headerMap.get(e);if(!s||!o)return!0;const r=s.readonly,a=o.readonly,{BODY_CELL_READONLY_METHOD:l}=this.ctx.config;if(typeof l=="function"&&o){const d=l({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:o.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return a||r}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return this.ctx.database.getReadonly(t,e)?new Promise(s=>{s([])}):new Promise(s=>{const o=this.rowKeyMap.get(t),r=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:a}=this.ctx.config;if(o===void 0||r===void 0)return s([]);const l=r.column;let c=l.rules;if(typeof a=="function"){const f=a({row:o.item,rowIndex:o.rowIndex,colIndex:r.colIndex,column:l,value:this.getItemValue(t,e)});f&&(c=f)}if(c){const d={row:o.item,rowIndex:o.rowIndex,colIndex:r.colIndex,column:l,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},u=new Oe(c).validate(d);this.setValidationError(t,e,u),s(u)}else this.clearValidationError(t,e),s([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const o=this.positions[t+s];o&&(i+=o.height)}return i}getSpanInfo(t){const{rowIndex:e,key:i,rowKey:s,row:o,value:r,colIndex:a,relationRowKeys:l,relationColKeys:c,rowspan:d,height:f,width:u,colspan:x,mergeRow:g,mergeCol:E}=t;if(d===1&&x===1)return{xArr:[a,a],yArr:[e,e],rowspan:d,colspan:x,height:f,width:u,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:o,value:r}]};let m=e,w=e,y=a,b=a,p=[],C=0,v=0,I=0,T=0;if(d!==1&&g){T=u;const _=l.reduce((R,S)=>{const O=this.getItemValue(s,S)??"";return`${R}${O}`},"");for(let R=e-1;R>=0;R--){const S=this.rowIndexRowKeyMap.get(R)||"",O=l.reduce((M,L)=>{const H=this.getItemValue(S,L)??"";return`${M}${H}`},"");if(_===O)m=R;else break}for(let R=e;R<=this.ctx.maxRowIndex;R++){const S=this.rowIndexRowKeyMap.get(R)||"",O=l.reduce((M,L)=>{const H=this.getItemValue(S,L)??"";return`${M}${H}`},"");if(_===O)w=R;else break}for(let R=m;R<e;R++){const{height:S}=this.positions[R];C+=S}for(let R=m;R<=w;R++){const{height:S}=this.positions[R];I+=S;const O=this.rowIndexRowKeyMap.get(R)||"",{item:M}=this.rowKeyMap.get(O),L=this.getItemValue(O,i);p.push({rowKey:O,key:i,value:L,row:M})}}if(x!==1&&E){I=f;for(let _=a-1;_>=0;_--){const R=this.getColumnByColIndex(_);if(!R)break;const S=this.getItemValue(s,i),O=this.getItemValue(s,R.key);if(S===O&&c.includes(R.key))y=_;else break}for(let _=a;_<=this.ctx.maxColIndex;_++){const R=this.getColumnByColIndex(_);if(!R)break;const S=this.getItemValue(s,i),O=this.getItemValue(s,R.key);if(S===O&&c.includes(R.key))b=_;else break}for(let _=y;_<a;_++){const R=this.getColumnByColIndex(_);if(!R)break;v+=R.width||100}for(let _=y;_<=b;_++){const R=this.getColumnByColIndex(_);if(!R)break;T+=R.width||100,p.push({rowKey:s,key:R.key,value:this.getItemValue(s,R.key),row:o})}}return{xArr:[y,b],yArr:[m,w],rowspan:d,colspan:x,height:I,width:T,offsetTop:C,offsetLeft:v,dataList:p}}setValidationErrorByRowKey(t,e,i){const s=`${t}​_${e}`,o=this.getRowForRowKey(t),r=o==null?void 0:o.rowIndex,a=this.getColumnByKey(e);if(!t||!a||!o)return;const l=this.getItemValue(t,e),c=[{key:e,rowKey:t,rowIndex:r,colIndex:a.colIndex,column:a.column,row:o,value:l,message:i,field:e,fieldValue:l}];this.validationErrorMap.set(s,c)}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,i=!0){const s=this.getColumnByColIndex(e),o=this.getRowForRowIndex(t);return!s||!o?void 0:new ue(this.ctx,t,e,0,0,0,0,s,o.item,"body",i)}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 o=t[0];o<=t[1];o++){const r=this.getVirtualBodyCell(s,o);if(r&&(r.rowspan!==1||r.colspan!==1)){i=!0;break}}return i}calculateMaxTreeDepth(t,e=0){let i=e;return t.forEach(s=>{if(Array.isArray(s.children)&&s.children.length>0){const o=this.calculateMaxTreeDepth(s.children,e+1);i=Math.max(i,o)}}),i}setOverlayerAutoHeightMap(t){this.overlayerAutoHeightMap=t}getOverlayerAutoHeightMap(){return this.overlayerAutoHeightMap}getOverlayerAutoHeight(t,e){const i=`${t}​_${e}`;return this.overlayerAutoHeightMap.get(i)||0}setCustomHeader(t,e=!1){if(["fixedData","sortData","hideData","resizableData"].forEach(i=>{const s=t[i];s!==void 0&&(this.customHeader[i]=s)}),!e){const i=this.clearCustomHeaderInvalidValues(this.columns);this.ctx.emit("customHeaderChange",i)}}resetCustomHeader(){this.customHeader={},this.ctx.emit("resetHeader"),this.ctx.emit("customHeaderChange",this.customHeader)}getCustomHeader(){return this.customHeader}setCustomHeaderResizableData(t,e){let{resizableData:i={}}=this.customHeader;i[t]=e,this.setCustomHeader({resizableData:i})}setCustomHeaderHideData(t,e){let{hideData:i={}}=this.customHeader;t.forEach(s=>{i[s]=e}),this.setCustomHeader({hideData:i}),this.ctx.emit("resetHeader")}setCustomHeaderFixedData(t,e){let{fixedData:i={}}=this.customHeader;t.forEach(s=>{i[s]=e}),this.setCustomHeader({fixedData:i}),this.ctx.emit("resetHeader")}clearCustomHeaderInvalidValues(t){const e=(s,o={})=>{s.forEach(r=>{r.children&&r.children.length>0&&e(r.children,o);const a=(l,c)=>{var f,u;const d=(f=this.customHeader[l])==null?void 0:f[r.key];d!==void 0&&d!==c&&(o[l]||(o[l]={}),o[l][r.key]=d,l==="fixedData"&&!d&&!c&&((u=o[l])==null||delete u[r.key]))};a("fixedData",r.fixed),a("sortData",r.sort),a("hideData",r.hide),a("resizableData",r.width)})};let i={};return e(t,i),i}setMaxRowHeightItem(t,e,i){this.maxRowHeightCellMap.set(t,{key:e,height:i})}getMaxRowHeightItem(t){return this.maxRowHeightCellMap.get(t)}clearChangeData(){this.changedDataMap.clear()}}class Ue{constructor(t){n(this,"ctx");n(this,"history",[]);n(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(o=>({rowKey:o.rowKey,key:o.key,value:o.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1,!1,"back"),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,!1,"forward")}}clear(){this.history=[],this.historyIndex=-1}}class je{constructor(t){n(this,"eventTasks",new Set);n(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)),this.bind(document,"selectionchange",this.selectionchange.bind(this))}selectionchange(){this.ctx.domSelectionStr="";const t=window.getSelection();t&&t.toString()&&(this.ctx.domSelectionStr=t.toString())}clearDomSelection(){const t=window.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()}destroy(){Array.from(this.eventTasks).forEach(({target:e,name:i,fn:s,options:o})=>{this.unbind(e,i,s,o)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){this.clearDomSelection(),t.button===0&&(this.ctx.mousedown=!0),this.ctx.emit("mousedown",t)}handleMousemove(t){const e=t,i=this.ctx.containerElement.getBoundingClientRect(),s=this.ctx.zoomScale.toLogical(e.clientX-i.left),o=this.ctx.zoomScale.toLogical(e.clientY-i.top);this.ctx.mouseX=s,this.ctx.mouseY=o,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.dragHeaderIng||this.ctx.emit("keydown",t))}handleWheel(t){const e=t,{ENABLE_ZOOM_WHEEL:i}=this.ctx.config;if(i&&(e.ctrlKey||e.metaKey)){t.preventDefault();const s=e.deltaY>0?-.1:.1;this.ctx.setZoom(this.ctx.getZoom()+s);return}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.add({target:t,name:e,fn:i,options:s})}unbind(t,e,i,s){t.removeEventListener(e,i,s);for(const o of this.eventTasks)if(o.target===t&&o.name===e&&o.fn===i){this.eventTasks.delete(o);break}}}class Ze{constructor(){n(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 qe{constructor(t){n(this,"ctx");n(this,"textCacheMap",new Map);const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}getCtx(){return this.ctx}clearTextCache(){this.textCacheMap.clear()}scale(t,e=1){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(t*e,t*e)}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,o){const{fillColor:r,side:a,shadowWidth:l,colorStart:c,colorEnd:d}=o;this.ctx.save(),r&&(this.ctx.fillStyle=r,this.ctx.fillRect(t,e,i,s));let f;switch(a){case"left":f=this.ctx.createLinearGradient(t-l,e,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-l,e,l,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+l,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,l,s);break;case"top":f=this.ctx.createLinearGradient(t,e-l,t,e),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-l,i,l);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+l),f.addColorStop(0,c),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,l);break;default:console.error("Invalid side specified for shadow");break}this.ctx.restore()}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 o=2;o<t.length;o+=2)this.ctx.lineTo(t[o]-.5,t[o+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=e.lineDashOffset??0,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,o){this.ctx.save(),this.ctx.drawImage(t,e,i,s,o),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:o=1,borderColor:r,fillColor:a,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),a!==void 0&&(this.ctx.fillStyle=a),r!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=r),l===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[c,d,f,u]=typeof l=="number"?[l,l,l,l]:l;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)}a!==void 0&&this.ctx.fill(),r!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,r={}){var b,p,C;this.ctx.save();const{font:a="12px Arial",align:l="center",color:c="#495060",padding:d=0,verticalAlign:f="middle",maxLineClamp:u=1,autoRowHeight:x=!1,offsetLeft:g=0,offsetRight:E=0}=r;if(this.ctx.font=a,this.ctx.fillStyle=c,["",null,void 0].includes(t))return this.ctx.restore(),!1;const w=parseInt(((b=a.match(/\d+/))==null?void 0:b[0])||"12")*(r.lineHeight||1.2),y=this.buildTextLayout(t,e,i,s,o,{font:a,color:c,align:l,padding:d,verticalAlign:f,maxLineClamp:u,autoRowHeight:x,lineHeight:w,offsetLeft:g,offsetRight:E});if(this.ctx.textBaseline="top",this.ctx.textAlign="left",y.lines.forEach(v=>{this.ctx.fillText(v.text,v.drawX,v.drawY)}),r.textCallback&&y.lines.length){const v=y.lines.reduce((S,O)=>Math.max(S,O.width),0),I=Math.round(v);let T=((p=y.lines[0])==null?void 0:p.drawX)??e+d+g,_=T+I;l==="center"?(T=e+s/2-I/2,_=e+s/2+I/2):l==="right"&&(T=e+s-d-E-I,_=e+s-d-E);const R={x:((C=y.lines[0])==null?void 0:C.drawX)??T,y:y.contentY,width:I,height:y.lines.length*w,left:T,right:_,top:y.contentY,bottom:y.contentY+y.lines.length*w};r.textCallback(R)}return r.layoutCallback&&r.layoutCallback(y),this.ctx.restore(),y.ellipsis}buildTextLayout(t,e,i,s,o,r){const{font:a,color:l,align:c,padding:d,verticalAlign:f,maxLineClamp:u,autoRowHeight:x,lineHeight:g,offsetLeft:E,offsetRight:m}=r;this.ctx.save(),this.ctx.font=a;const w=s-d*2-E-m,y=w,b=o-d*2,p=Array.from(t);let C=this.wrapTextToLines(t,w);const v=Math.round(b/g);let I=Math.min(C.length,Math.max(v,1));u==="auto"&&x?I=C.length:typeof u=="number"&&u<I&&u!==1?I=u:(u===1&&(C=[{items:p.map((M,L)=>({char:M,sourceIndex:L})),text:t,caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}],I=1),u==="auto"&&v===1&&(C=[{items:p.map((M,L)=>({char:M,sourceIndex:L})),text:t,caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}],I=1));let T=!1;const _=C.slice(0,I);if(C.length>I){T=!0;const M=C.slice(I-1),L=this.buildEllipsisLine(M,s,d);L.lineIndex=I-1,_[I-1]=L}else if(I>0){const M=I-1,L=C.slice(M),H=L.map(A=>A.text).join(""),{ellipsis:D}=this.handleEllipsis(H,s,d,a);if(D){T=!0;const A=this.buildEllipsisLine(L,s,d);A.lineIndex=M,_[M]=A}}const R=_.length*g;let S=i+d;f==="middle"?S=i+(o-R)/2:f==="bottom"&&(S=i+o-R-d);const O=[];return _.forEach((M,L)=>{M.lineIndex=L;const H=this.buildLineSegments(M),D=H.reduce((N,It)=>N+It.width,0);let A=e+d+E;c==="center"?A=e+(s-D)/2:c==="right"&&(A=e+s-d-m-D);const k=S+L*g;M.drawX=A,M.drawY=k,M.width=D,M.segments=H,H.forEach(N=>{N.sourceIndex<0||O.push({char:N.char,index:N.sourceIndex,line:L,x:A+N.x,y:k,width:N.width,height:g})})}),this.ctx.restore(),{text:t,chars:p,glyphs:O,lines:_,box:{x:e,y:i,width:s,height:o},contentBox:{x:e+d+E,y:i+d,width:y,height:b},contentY:S,lineHeight:g,font:a,color:l,align:c,ellipsis:T}}wrapTextToLines(t,e){if(!t)return[{items:[],text:"",caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}];const i=Array.from(t),s=[];let o=[],r=0,a=0;const l=c=>{const d=o.map(f=>f.char).join("");s.push({items:o,text:d,caretIndex:a,lineIndex:s.length,drawX:0,drawY:0,width:0,segments:[]}),o=[],r=0,a=c};for(let c=0;c<i.length;c++){const d=i[c];if(d===`
5
+ `){l(c+1);continue}const f=this.ctx.measureText(d).width;if(r+f>e&&o.length>0){l(o[o.length-1].sourceIndex+1),o.push({char:d,sourceIndex:c}),r=f;continue}o.push({char:d,sourceIndex:c}),r+=f}return(o.length>0||s.length===0)&&l(i.length),s}buildEllipsisLine(t,e,i){var d;const s=t.flatMap(f=>f.items),o=s.map(f=>f.char).join(""),{_text:r,ellipsis:a}=this.handleEllipsis(o,e,i,this.ctx.font),l=a?r.slice(0,-3):r,c=[];for(let f=0;f<l.length;f++){const u=s[f];if(!u)break;c.push({char:u.char,sourceIndex:u.sourceIndex})}return a&&c.push({char:".",sourceIndex:-1,ellipsis:!0},{char:".",sourceIndex:-1,ellipsis:!0},{char:".",sourceIndex:-1,ellipsis:!0}),{items:c,text:r,caretIndex:((d=t[0])==null?void 0:d.caretIndex)??0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}}buildLineSegments(t){const e=[];let i=0;return t.items.forEach((s,o)=>{const r=this.ctx.measureText(s.char).width;e.push({char:s.char,itemIndex:o,sourceIndex:s.sourceIndex,x:i,width:r}),i+=r}),e}wrapText(t,e,i=""){if(!t)return[""];if(i&&this.textCacheMap.has(i))return this.textCacheMap.get(i)||[""];const s=[],o=t.split(`
6
+ `);for(const a of o){if(a===""){s.push("");continue}const l=a.split("");let c="";for(const d of l){const f=c+d;this.ctx.measureText(f).width<=e?c=f:c?(s.push(c),c=d):(s.push(d),c="")}c&&s.push(c)}const r=s.length>0?s:[""];return i&&this.textCacheMap.set(i,r),r}calculateTextHeight(t="",e,i={}){var E;const{font:s="12px Arial",padding:o=0,align:r="center",color:a="#495060",maxLineClamp:l=1,cacheTextKey:c=""}=i;this.ctx.save(),this.ctx.font=s,this.ctx.fillStyle=a,this.ctx.textAlign=r;const d=parseInt(((E=s.match(/\d+/))==null?void 0:E[0])||"12"),f=d*(i.lineHeight||1.2),u=e-o*2,x=this.wrapText(t,u,c);let g=1;return l==="auto"?g=x.length:x.length>l?g=l:g=x.length,this.ctx.restore(),Math.max(Math.floor(g*f+o*2),Math.floor(d+o*2))}handleEllipsis(t,e,i=0,s="12px Arial"){this.ctx.save();let o=!1,r=t;if(this.ctx.font=s,t==null||t==="")return this.ctx.restore(),{_text:"",ellipsis:o};const a=this.ctx.measureText("...").width;if(e<=a+i*2)return this.ctx.restore(),{_text:"",ellipsis:!0};const l=this.ctx.measureText(t).width,c=e-i*2;if(l&&l>=c){o=!0;let d=0;for(let f=0;f<t.length;f++)if(d+=this.ctx.measureText(t[f]).width,d>=c-a){r=t.slice(0,f)+"...",o=!0;break}}return this.ctx.restore(),{_text:r,ellipsis:o}}}class Ut{constructor(t){n(this,"_config",{});n(this,"CSS_PREFIX","e-virt-table");n(this,"ICONS",[]);n(this,"ROW_KEY","");n(this,"DISABLED",!1);n(this,"HEADER_FONT","12px normal Arial");n(this,"BODY_FONT","12px normal Arial");n(this,"BORDER",!0);n(this,"STRIPE",!1);n(this,"STRIPE_COLOR","#fafafa");n(this,"BORDER_COLOR","#e1e6eb");n(this,"HEIGHT",0);n(this,"PLACEHOLDER_COLOR","#CDD0DC");n(this,"EMPTY_BODY_HEIGHT",120);n(this,"EMPTY_CUSTOM_STYLE",{});n(this,"EMPTY_TEXT","");n(this,"LOADING_TEXT","");n(this,"MAX_HEIGHT",1e3);n(this,"BORDER_RADIUS",8);n(this,"ENABLE_OFFSET_HEIGHT",!1);n(this,"OFFSET_HEIGHT",0);n(this,"HEADER_HEIGHT",36);n(this,"ENABLE_HEADER_STICKY",!1);n(this,"HEADER_BG_COLOR","#F8FAFF");n(this,"BODY_BG_COLOR","#FFF");n(this,"HEADER_TEXT_COLOR","#1D2129");n(this,"REQUIRED_COLOR","#F56C6C");n(this,"BODY_TEXT_COLOR","#4E5969");n(this,"FOOTER_TEXT_COLOR","#4E5969");n(this,"LOADING_ICON_SVG","");n(this,"LOADING_ICON_COLOR","#4E5969");n(this,"EXPAND_ICON_SVG","");n(this,"SHRINK_ICON_SVG","");n(this,"EXPAND_ICON_COLOR","#4E5969");n(this,"SHRINK_ICON_COLOR","#4E5969");n(this,"ERROR_TIP_ICON_COLOR","red");n(this,"ERROR_TIP_ICON_SIZE",6);n(this,"COLUMNS_ALIGN","left");n(this,"COLUMNS_VERTICAL_ALIGN","middle");n(this,"EXPAND_LAZY",!0);n(this,"DEFAULT_EXPAND_ALL",!1);n(this,"CELL_WIDTH",100);n(this,"CELL_HEIGHT",36);n(this,"CELL_PADDING",8);n(this,"CELL_HOVER_ICON_SIZE",14);n(this,"CELL_HOVER_ICON_BG_COLOR","#fff");n(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA");n(this,"MIN_ZOOM",.5);n(this,"MAX_ZOOM",2);n(this,"ENABLE_ZOOM_WHEEL",!0);n(this,"SCROLLER_TRACK_SIZE",14);n(this,"scrollbarMode","outer");n(this,"SCROLLBAR_SHOW_DELAY",300);n(this,"SCROLLER_SIZE",8);n(this,"SCROLLER_COLOR","#dee0e3");n(this,"SCROLLER_TRACK_COLOR","#fff");n(this,"SCROLLER_FOCUS_COLOR","#bbbec4");n(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");n(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");n(this,"SELECT_ROW_COL_BG_COLOR","transparent");n(this,"AUTOFILL_POINT_BORDER_COLOR","#fff");n(this,"EDIT_BG_COLOR","#fcf6ed");n(this,"CHECKBOX_KEY","");n(this,"CHECKBOX_COLOR","rgb(82,146,247)");n(this,"FINDER_CELL_BG_COLOR","rgb(255,229,144)");n(this,"ENABLE_FINDER",!0);n(this,"CHECKBOX_SIZE",20);n(this,"CHECKBOX_DISABLED_SVG","");n(this,"CHECKBOX_DISABLED_COLOR","#F1F2F4");n(this,"CHECKBOX_CHECK_SVG","");n(this,"CHECKBOX_UNCHECK_SVG","");n(this,"CHECKBOX_UNCHECK_COLOR","#DDE0EA");n(this,"CHECKBOX_INDETERMINATE_SVG","");n(this,"CHECKBOX_CHECK_DISABLED_SVG","");n(this,"CHECKBOX_CHECK_DISABLED_COLOR","#DDE0EA");n(this,"ICON_EDIT_SVG","");n(this,"ICON_EDIT_COLOR","#4E5969");n(this,"ICON_SELECT_SVG","");n(this,"ICON_SELECT_COLOR","#4E5969");n(this,"SORT_STRICTLY",!0);n(this,"SORT_ASC_ICON_SVG","");n(this,"SORT_DESC_ICON_SVG","");n(this,"SORTABLE_ICON_SVG","");n(this,"SORT_ICON_COLOR","rgb(82,146,247)");n(this,"READONLY_COLOR","#fff");n(this,"READONLY_TEXT_COLOR","#4E5969");n(this,"ERROR_TIP_COLOR","#ED3F14");n(this,"FOOTER_BG_COLOR","#fafafa");n(this,"FOOTER_FIXED",!0);n(this,"FOOTER_POSITION","bottom");n(this,"CELL_FOOTER_HEIGHT",36);n(this,"ENABLE_SELECTOR",!0);n(this,"TREE_SELECT_MODE","auto");n(this,"TREE_CHILDREN_KEY","children");n(this,"TREE_INDENT",20);n(this,"TREE_ICON_SIZE",20);n(this,"TREE_LINE",!1);n(this,"TREE_LINE_COLOR","#e1e6eb");n(this,"ENABLE_EDIT_SINGLE_CLICK",!1);n(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);n(this,"SELECTOR_AREA_MIN_X",0);n(this,"SELECTOR_AREA_MAX_X_OFFSET",0);n(this,"SELECTOR_AREA_MAX_X",0);n(this,"SELECTOR_AREA_MIN_Y",0);n(this,"SELECTOR_AREA_MAX_Y",0);n(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);n(this,"SELECTOR_CELL_VALUE_TYPE","value");n(this,"ENABLE_AUTO_THEME",!0);n(this,"ENABLE_SELECTOR_SINGLE",!1);n(this,"ENABLE_SELECTOR_SPAN_COL",!0);n(this,"ENABLE_SELECTOR_SPAN_ROW",!0);n(this,"ENABLE_SELECTOR_ALL_ROWS",!0);n(this,"ENABLE_SELECTOR_ALL_COLS",!0);n(this,"ENABLE_MERGE_CELL_LINK",!1);n(this,"ENABLE_AUTOFILL",!1);n(this,"ENABLE_AUTOFILL_SPAN_COL",!0);n(this,"ENABLE_AUTOFILL_SPAN_ROW",!0);n(this,"ENABLE_CONTEXT_MENU",!1);n(this,"ENABLE_HEADER_CONTEXT_MENU",!1);n(this,"ENABLE_TEXT_SELECTION",!0);n(this,"ENABLE_COPY",!0);n(this,"ENABLE_PASTER",!0);n(this,"ENABLE_RESIZE_ROW",!0);n(this,"ENABLE_RESIZE_COLUMN",!0);n(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");n(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");n(this,"ENABLE_RESIZE_COLUMN_TEXT",!0);n(this,"RESIZE_COLUMN_TEXT_COLOR","#fff");n(this,"RESIZE_COLUMN_TEXT_BG_COLOR","rgb(82,146,247)");n(this,"RESIZE_ROW_MIN_HEIGHT",36);n(this,"RESIZE_COLUMN_MIN_WIDTH",40);n(this,"DRAG_TIP_BG_COLOR","rgba(82,146,247,0.1)");n(this,"DRAG_TIP_LINE_COLOR","rgb(82,146,247)");n(this,"ENABLE_KEYBOARD",!0);n(this,"ENABLE_HISTORY",!1);n(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);n(this,"HISTORY_NUM",50);n(this,"HIGHLIGHT_HOVER_ROW",!1);n(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");n(this,"HIGHLIGHT_SELECTED_ROW",!1);n(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");n(this,"TOOLTIP_BG_COLOR","#303133");n(this,"TOOLTIP_TEXT_COLOR","#fff");n(this,"TOOLTIP_ZINDEX",3e3);n(this,"TOOLTIP_CUSTOM_STYLE",{});n(this,"CONTEXT_MENU",[{value:"copy"},{value:"cut"},{value:"paste"},{value:"clearSelected"}]);n(this,"CUSTOM_BODY_CONTEXT_MENU",[]);n(this,"HEADER_CONTEXT_MENU",[{value:"fixedLeft"},{value:"fixedRight"},{value:"fixedNone"},{value:"hide"},{value:"visible"},{value:"resetHeader"}]);n(this,"CUSTOM_HEADER_CONTEXT_MENU",[]);n(this,"CELL_LINE_HEIGHT",1.2);n(this,"AUTO_ROW_HEIGHT",!1);n(this,"ENABLE_DRAG_COLUMN",!1);n(this,"ENABLE_DRAG_ROW",!1);n(this,"ENABLE_DRAG_ROW_CROSS_LEVEL",!1);n(this,"ENABLE_DRAG_ROW_CUSTOM",!1);n(this,"DRAG_ROW_TIP_LINE_COLOR","rgb(82,146,247)");n(this,"DRAG_ROW_ICON_SVG","");n(this,"DRAG_ROW_ICON_SIZE",18);n(this,"DRAG_ROW_ICON_COLOR","#bec4c7");n(this,"HEADER_CELL_STYLE_METHOD");n(this,"BODY_CELL_STYLE_METHOD");n(this,"FOOTER_CELL_STYLE_METHOD");n(this,"BODY_CELL_READONLY_METHOD");n(this,"BODY_CELL_FORMATTER_METHOD");n(this,"BODY_CELL_RULES_METHOD");n(this,"BODY_CELL_TYPE_METHOD");n(this,"BODY_CELL_EDITOR_METHOD");n(this,"BODY_CELL_RENDER_METHOD");n(this,"BODY_CELL_HOVER_ICON_METHOD");n(this,"SPAN_METHOD");n(this,"SELECTABLE_METHOD");n(this,"EXPAND_LAZY_METHOD");n(this,"BEFORE_VALUE_CHANGE_METHOD");n(this,"BEFORE_PASTE_DATA_METHOD");n(this,"BEFORE_AUTOFILL_DATA_METHOD");n(this,"BEFORE_SET_SELECTOR_METHOD");n(this,"BEFORE_SET_AUTOFILL_METHOD");n(this,"BEFORE_HEADER_CONTEXT_MENU_METHOD");n(this,"BEFORE_BODY_CONTEXT_MENU_METHOD");n(this,"BEFORE_COPY_METHOD");n(this,"BEFORE_DRAG_ROW_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=ke(i);s&&(t[e]=s)}}),Object.assign(this,t,this._config)}}const ft=`<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>\r
7
+ `,jt=`<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>
8
+ `,Zt=`<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>
9
+ `,Bt=`<svg t="1755138507987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5079" width="200" height="200"><path d="M512 938.688a42.688 42.688 0 0 1-35.072-18.432l-192-277.312A42.56 42.56 0 0 1 320 576h384a42.752 42.752 0 0 1 35.072 66.944l-192 277.312a42.688 42.688 0 0 1-35.072 18.432" fill="currentColor" p-id="2016"></path><path d="M704 448H320a42.752 42.752 0 0 1-35.072-66.944l192-277.312c16-23.04 54.208-23.04 70.144 0l192 277.312A42.56 42.56 0 0 1 704 448" fill="currentColor" p-id="2015"></path></svg>
10
+ `,xe=`<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>
11
+ `,Je=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2s.9-2 2-2s2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2s-2 .9-2 2s.9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2z" fill="currentColor"></path></svg>
12
+ `,Qe=`<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" p-id="4709"></path></svg>
13
+ `,ti=`<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>
14
+ `,ei=`<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" 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>
15
+ `,ii=`<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>
16
+ `,si=Bt.replace('fill="currentColor" p-id="2016"','fill="#bec4c7" p-id="2016"'),oi=Bt.replace('fill="currentColor" p-id="2015"','fill="#bec4c7" p-id="2015"');class ri{constructor(t){n(this,"ctx");n(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:xe,color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:ft,color:"#4E5969"},{name:"shrink",configName:"SHRINK_ICON_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Zt,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_UNCHECK_COLOR",svg:Qe,color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:jt,color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:ti,color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_DISABLED_SVG",svg:jt,color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",configColorName:"CHECKBOX_DISABLED_COLOR",svg:ei,color:"#F1F2F4"},{name:"icon-edit",configName:"ICON_EDIT_SVG",configColorName:"ICON_EDIT_COLOR",svg:ii,color:"#4E5969"},{name:"icon-select",configName:"ICON_SELECT_SVG",configColorName:"ICON_SELECT_COLOR",svg:Zt,color:"#4E5969"},{name:"sort-asc",configName:"SORT_ASC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:si,color:"rgb(82,146,247)"},{name:"sort-desc",configName:"SORT_DESC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:oi,color:"rgb(82,146,247)"},{name:"sort-default",configName:"SORTABLE_ICON_SVG",svg:Bt,color:"#bec4c7"},{name:"drag",configName:"DRAG_ROW_ICON_SVG",svg:Je,color:"#4E5969"}]);n(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,o=i.svg;if(i.configColorName){const a=this.ctx.config[i.configColorName];a&&(s=a)}if(i.configName){const a=this.ctx.config[i.configName];a&&(o=a)}const r=this.createImageFromSVG(o,s).then(a=>{this.icons.set(i.name,a)});t.push(r)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const o=this.createImageFromSVG(i.svg,s,i.isBlob).then(r=>{this.icons.set(i.name,r)});t.push(o)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&r.querySelectorAll("*").forEach(c=>{const d=c.getAttribute("fill");(d==="currentColor"||d===null)&&c.setAttribute("fill",e)});const a=new Image;let l="";if(i){const c=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"});l=URL.createObjectURL(c)}else l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r));return a.src=l,new Promise((c,d)=>{a.onerror=()=>d(new Error("Failed to load image:"+t)),a.onload=()=>{c(a)}})}get(t){return this.icons.get(t)}getSvg(t){return this.list.find(e=>e.name===t)}}class ni{constructor(t){n(this,"ctx");n(this,"visibleHoverCell");n(this,"resizeObserver");n(this,"mutationObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(t=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver",t),this.ctx.emit("containerResize",this.ctx.containerElement)}),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(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.isInsideBody(o,s)||this.ctx.emit("mousedownBodyOutside",t),t.button===0&&(this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.focusCellHeader=r,this.ctx.focusCell=void 0,this.ctx.emit("cellHeaderMousedown",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.setFocusCell(r),this.ctx.focusCellHeader=void 0,this.ctx.emit("cellMousedown",r,t)},!0))}),this.ctx.on("mouseup",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.emit("cellHeaderMouseup",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.emit("cellMouseup",r,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.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t);const o=s.getImage("hover");!this.ctx.disableHoverIconClick&&o&&o.isInside(i,e)&&this.ctx.emit("hoverIconClick",s)},!0)}),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,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.emit("cellHeaderContextMenuClick",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.emit("cellContextMenuClick",r,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.mousedown&&this.ctx.stageElement.style.cursor!=="default"&&(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.imageEnterAndLeave(s,t),this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.visibleHoverCell=void 0,this.ctx.emit("cellHeaderHoverChange",s,t))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.imageEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.hoverCellHeader=void 0,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var o;this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",s,t),this.ctx.hoverCell!==s&&(((o=this.ctx.hoverCell)==null?void 0:o.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(r=>r.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("draw")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))}),this.handleFooterEvent(i,e,this.ctx.footer.renderRows,s=>{this.ctx.emit("cellFooterMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellFooterMouseleave",s,t),this.ctx.emit("cellFooterHoverChange",s,t)})})}imageEnterAndLeave(t,e){if(this.ctx.dragRowIng||this.ctx.dragHeaderIng||this.ctx.selectorMove||this.ctx.autofillMove)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;t.cellImages.forEach((a,l)=>{a.isInside(r,o)&&(l==="drag"?this.ctx.stageElement.style.cursor="grab":this.ctx.stageElement.style.cursor="pointer")})}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;if(this.ctx.loading||!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:r}=this.ctx.config,a=V(this.ctx.config);return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||!a&&s>this.ctx.stageHeight-r||!a&&o>this.ctx.stageWidth-r)}handleBodyEvent(t,e,i,s,o=!1){if(this.isInsideBody(t,e))for(const r of i){const a=r.fixedCells.concat(r.noFixedCells);for(const l of a)if(o?l.isInsideVisible(t,e):l.isInside(t,e)){s(l);return}}}handleHeaderEvent(t,e,i,s){for(const o of i)if(o.isInside(t,e)){s(o);return}}handleFooterEvent(t,e,i,s){for(const o of i){const r=o.fixedCells.concat(o.noFixedCells);for(const a of r)if(a.isInside(t,e)){s(a);return}}}isInsideBody(t,e){const{body:{y:i,visibleHeight:s,height:o,visibleWidth:r}}=this.ctx,a=Math.min(o,s);return t>0&&t<r&&e>i&&e<i+a}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}const ai={numberErrorTip:"只允许输入数字",emptyText:"暂无数据",loadingText:"加载中...",copy:"复制",cut:"剪切",paste:"粘贴",clearSelected:"清空选中内容",fixedLeft:"左固定",fixedRight:"右固定",fixedNone:"取消固定",hide:"隐藏",visible:"显示",resetHeader:"恢复默认",invalidNumber:"请输入数字类型",mergeCellNoFill:"合并单元格不能填充",mergeCellNoCopy:"合并单元格不能复制",mergeCellNoPaste:"合并单元格不能粘贴",numberTruncated:"输入的数字已截取至小数点后{precision}位",batchSetItemValueError:"批量赋值错误",numberMin:"输入值小于{min},已自动调整为{min}",numberMax:"输入值大于{max},已自动调整为{max}",stringMaxlength:"输入值超过{maxlength}个字符,已自动截取"};class li{constructor(){n(this,"langConfig")}use(t){this.langConfig=t}getText(t,e){const i={...ai};Object.assign(i,pt.locale,this.langConfig);const s=i[t];return s?s.replace(/{(\w+)}/g,(o,r)=>(e==null?void 0:e[r])||o):""}}const ci=/^-?\d*\.?\d+px$/;class hi{constructor(){n(this,"value",1)}get isDefault(){return this.value===1}clamp(t,e,i){return Math.min(i,Math.max(e,t))}set(t,e,i){const s=this.clamp(t,e,i);return Math.abs(s-this.value)<1e-4?!1:(this.value=s,!0)}toVisual(t){return t*this.value}toLogical(t){return t/this.value}toPx(t){return`${this.toVisual(t)}px`}domHeightToLogical(t){return Math.round(t/this.value)}contentToPhysical(t){return t*this.value}scaleStyle(t){if(this.isDefault)return t;const e={...t};for(const i of Object.keys(e)){const s=e[i];typeof s=="string"&&ci.test(s)&&(e[i]=`${parseFloat(s)*this.value}px`)}return e}assignScaledStyle(t,e){Object.assign(t.style,this.scaleStyle(e))}containerWidth(t){return Math.floor(t/this.value)}resolveStageWidth(t){const e=this.containerWidth(t.containerPhysicalWidth),i=t.fillContainer?e:Math.min(Math.floor(t.contentWidth+t.scrollerTrackSize),e),s=Math.min(Math.round(this.toVisual(i)),Math.floor(t.containerPhysicalWidth));return{stageWidth:i,stagePhysicalWidth:s}}applyStageHeight(t,e){const i=Math.floor(e),s=Math.floor(i/this.value);return t.style.height=`${i}px`,{stageHeight:s,stagePhysicalHeight:i}}getViewportRect(t,e){const i=this.toVisual(t.x)+e.x,s=this.toVisual(t.y)+e.y,o=this.toVisual(t.width),r=this.toVisual(t.height);return{x:i,y:s,left:i,top:s,right:i+o,bottom:s+r,width:o,height:r}}createOverlayerCellElement(t,e){const i=document.createElement("div");if(this.assignScaledStyle(i,t.style),Object.keys(t.domDataset||{}).forEach(l=>{i.setAttribute(l,t.domDataset[l])}),typeof t.render!="function")return i;if(this.isDefault)return t.render(i,t),i;const s="visibleWidth"in t?t.visibleWidth:t.width,o="visibleHeight"in t?t.visibleHeight:t.height,r="autoRowHeight"in t&&t.autoRowHeight&&"renderType"in t&&t.renderType==="default",a=document.createElement("div");return a.className=`${e}-overlayer-cell-content`,a.style.width=`${s}px`,a.style.boxSizing="border-box",r?(a.style.height="auto",a.style.minHeight=`${o}px`,i.style.height="auto"):(a.style.height=`${o}px`,i.style.height=this.toPx(o)),a.style.zoom=String(this.value),i.style.width=this.toPx(s),i.appendChild(a),t.render(a,t),i}}class di{constructor(t,e){n(this,"eventBus");n(this,"eventBrowser");n(this,"eventTable");n(this,"locale",new li);n(this,"containerElement");n(this,"stageElement");n(this,"canvasElement");n(this,"overlayerElement");n(this,"editorElement");n(this,"emptyElement");n(this,"contextMenuElement");n(this,"loadingElement");n(this,"stageWidth",0);n(this,"stageHeight",0);n(this,"stagePhysicalWidth",0);n(this,"stagePhysicalHeight",0);n(this,"zoomScale");n(this,"paint");n(this,"icons");n(this,"domSelectionStr","");n(this,"textSelectionStr","");n(this,"textSelecting",!1);n(this,"isMouseoverTargetContainer",!1);n(this,"mousedown",!1);n(this,"isEmpty",!1);n(this,"rowResizing",!1);n(this,"columnResizing",!1);n(this,"scrollerMove",!1);n(this,"scrollerFocus",!1);n(this,"autofillMove",!1);n(this,"selectorMove",!1);n(this,"disableHoverIconClick",!1);n(this,"selectColsIng",!1);n(this,"selectRowsIng",!1);n(this,"dragHeaderIng",!1);n(this,"dragRowIng",!1);n(this,"finding",!1);n(this,"contextMenuIng",!1);n(this,"editing",!1);n(this,"loading",!1);n(this,"onlyMergeCell",!1);n(this,"selectOnlyOne",!1);n(this,"hasSelection",!1);n(this,"hasTree",!1);n(this,"scrollY",0);n(this,"scrollX",0);n(this,"fixedLeftWidth",0);n(this,"fixedRightWidth",0);n(this,"lastCenterColIndex",0);n(this,"maxColIndex",0);n(this,"maxRowIndex",0);n(this,"hoverRow");n(this,"clickCell");n(this,"focusCell");n(this,"currentCell");n(this,"hoverCell");n(this,"clickCellHeader");n(this,"focusCellHeader");n(this,"hoverCellHeader");n(this,"mouseX",0);n(this,"mouseY",0);n(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});n(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});n(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],allCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});n(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});n(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});n(this,"finderBar",{text:"",rowIndex:-1,colIndex:-1,type:"body"});n(this,"database");n(this,"history");n(this,"config");const{containerElement:i,stageElement:s,canvasElement:o,overlayerElement:r,editorElement:a,emptyElement:l,loadingElement:c,contextMenuElement:d}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=o,this.overlayerElement=r,this.editorElement=a,this.emptyElement=l,this.loadingElement=c,this.contextMenuElement=d,this.config=new Ut(e.config||{}),this.eventBus=new Ze,this.eventBrowser=new je(this),this.eventTable=new ni(this),this.paint=new qe(this.canvasElement),this.database=new $e(this,e),this.history=new Ue(this),this.icons=new ri(this),this.zoomScale=new hi}get zoom(){return this.zoomScale.value}setConfig(t){this.config=new Ut(t)}setItemValueByEditor(t,e,i,s=!0,o=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const a=this.database.getVirtualBodyCellByKey(t,e);if(a&&(a.mergeRow||a.mergeCol)){const{dataList:l}=a.getSpanInfo(),c=l.map(d=>({...d,value:i}));this.database.batchSetItemValue(c,s,r);return}}this.database.setItemValue(t,e,i,s,o,!0,r)}batchSetItemValueByEditor(t,e=!0,i=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const s=[];t.forEach(o=>{const r=this.database.getRowIndexForRowKey(o.rowKey),a=this.database.getColIndexForKey(o.key);if(r===void 0||a===void 0)return;const l=this.database.getVirtualBodyCell(r,a);if(l){const{dataList:c}=l.getSpanInfo(),d=c.map(f=>({...f,value:o.value}));s.push(...d)}}),this.database.batchSetItemValue(s,e,i)}else this.database.batchSetItemValue(t,e,i)}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 o=0;o<=e[1]-e[0];o++){const r=[];for(let a=0;a<=i[1]-i[0];a++){const l=o+e[0],c=a+i[0],d=this.database.getVirtualBodyCell(l,c);d&&(d.selectorCellValueType==="displayText"?r.push(d.displayText):r.push(d.getValue()))}s+=`${r.join(" ")}\r`,t.push(r)}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 o=Math.floor(e),r=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(r=this.body.height+this.footer.height-this.body.visibleHeight),o<0?o=0:o>r&&(o=r),this.emit("setScroll",i,o)}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)}startAdjustPosition(t){this.emit("startAdjustPosition",t)}stopAdjustPosition(){this.emit("stopAdjustPosition")}isTarget(t){return!!this.containerElement.contains(t.target)}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:this.zoomScale.toLogical(t.clientX-e),offsetY:this.zoomScale.toLogical(t.clientY-i)}}toVisual(t){return this.zoomScale.toVisual(t)}toLogical(t){return this.zoomScale.toLogical(t)}toVisualPx(t){return this.zoomScale.toPx(t)}scaleStyle(t){return this.zoomScale.scaleStyle(t)}setZoom(t){const{MIN_ZOOM:e,MAX_ZOOM:i}=this.config;this.zoomScale.set(t,e,i)&&(this.emit("zoomChange",this.zoomScale.value),this.emit("resetHeader"))}getZoom(){return this.zoomScale.value}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()}}function qt(h,t,e,i=t,s=30){if(h<=0||t<=0||e<=0||i<=0)return 0;const o=Math.floor(t/e*i);return o<s?Math.min(s,i):o>i?0:o}class Jt{constructor(t,e){n(this,"ctx");n(this,"type");n(this,"isFocus",!1);n(this,"trackX",0);n(this,"trackY",0);n(this,"trackWidth",0);n(this,"trackHeight",0);n(this,"splitPoints",[]);n(this,"barX",0);n(this,"barY",0);n(this,"barWidth",0);n(this,"barHeight",0);n(this,"distance",0);n(this,"visibleDistance",0);n(this,"thumbTrackDistance",0);n(this,"thumbTravelDistance",0);n(this,"clientX",0);n(this,"clientY",0);n(this,"dragStart",0);n(this,"innerVisible",!1);n(this,"innerShowTimer",0);n(this,"isDragging",!1);n(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=this.ctx.zoomScale.toLogical(e-this.clientY),o=this.ctx.zoomScale.toLogical(i-this.clientX);let r=0;this.type==="vertical"?(r=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(r===0&&s>0||r===this.distance&&s<0)&&t.preventDefault()):this.type==="horizontal"&&(r=Math.max(0,Math.min(this.dragStart-o,this.distance))),this.scroll=r}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{clientX:e,clientY:i}=t,s=this.ctx.zoomScale.toLogical(t.offsetX),o=this.ctx.zoomScale.toLogical(t.offsetY);if(!(e==this.clientX&&i==this.clientY)&&!(this.isInnerMode()&&!this.canInteractWithScrollbar())){if(this.isOnScrollbar(s,o))this.clientX=e,this.clientY=i,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(s,o)){let r=0;this.type==="vertical"?r=(o-this.ctx.header.height-this.barHeight/2)/this.thumbTravelDistance*this.distance:r=(s-this.barWidth/2)/this.thumbTravelDistance*this.distance,this.scroll=Math.max(0,Math.min(r,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t,e){const{clientX:i,clientY:s,buttons:o}=t,r=this.ctx.zoomScale.toLogical(t.offsetX),a=this.ctx.zoomScale.toLogical(t.offsetY);let l=!1;if(Ve(this.ctx.config,e)?this.startInnerShowTimer():l=this.hideInnerScrollbar(),this.canInteractWithScrollbar()&&(this.isOnScrollbar(r,a)||this.isOnTrack(r,a))&&t.target===this.ctx.canvasElement?(this.isFocus=!0,this.ctx.stageElement.style.cursor="pointer"):this.isFocus=!1,o===0||i==this.clientX&&s==this.clientY)return l;let d=0;if(this.type==="horizontal"?d=i-this.clientX:d=s-this.clientY,d=this.ctx.zoomScale.toLogical(d),this.isDragging&&d!==0){let f=0;this.type==="vertical"?f=this.dragStart+d/this.thumbTravelDistance*this.distance:f=this.dragStart+d/this.thumbTravelDistance*this.distance,this.scroll=Math.max(0,Math.min(f,this.distance))}return l}isPointInElement(t,e,i,s,o,r){return t>=i&&t<=i+o&&e>=s&&e<=s+r}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)}isInnerMode(){return V(this.ctx.config)}shouldDrawInnerScrollbar(){return Pe(this.ctx.config,{innerVisible:this.innerVisible,isFocus:this.isFocus,isDragging:this.isDragging})}canInteractWithScrollbar(){return!this.isInnerMode()||this.shouldDrawInnerScrollbar()}startInnerShowTimer(){if(!this.isInnerMode()||this.innerVisible||this.innerShowTimer)return;const t=Math.max(0,this.ctx.config.SCROLLBAR_SHOW_DELAY||0);this.innerShowTimer=window.setTimeout(()=>{this.innerVisible=!0,this.innerShowTimer=0,this.ctx.emit("draw")},t)}cancelInnerShowTimer(){this.innerShowTimer&&(clearTimeout(this.innerShowTimer),this.innerShowTimer=0)}hideInnerScrollbar(){if(!this.isInnerMode()||this.isDragging)return!1;const t=this.innerVisible||this.isFocus;return this.cancelInnerShowTimer(),this.innerVisible=!1,this.isFocus=!1,t}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_SIZE:o=0,BORDER:r}}=this.ctx,a=B(this.ctx.config),l=de(this.ctx.config),c=s,d=i,f=e.height,u=e.width,x=t.height,g=this.ctx.footer.height,E=d-a-f,m=c-a,w=Math.max(0,x-E+g),y=Math.max(0,u-m),b=Ke(this.ctx.config);if(this.type==="vertical"){this.visibleDistance=E,this.distance=w;const p=$t(this.ctx.config,y>0);this.thumbTrackDistance=Math.max(0,this.visibleDistance-p),this.trackX=c-l,this.trackY=0,this.splitPoints=[this.trackX,f,this.trackX+l,f],this.trackWidth=l,this.trackHeight=Math.max(0,d-p),this.barX=this.trackX-1+(l-o)/2,this.barWidth=o,this.barHeight=qt(this.distance,this.visibleDistance,x+g,this.thumbTrackDistance),this.thumbTravelDistance=Math.max(0,this.thumbTrackDistance-this.barHeight-b);const C=this.distance?this.scroll/this.distance:0;this.barY=f+C*this.thumbTravelDistance,this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=m,this.distance=y;const p=$t(this.ctx.config,w>0);this.thumbTrackDistance=Math.max(0,this.visibleDistance-p),this.splitPoints=[c-l,d-l,c-l,d];const C=Ot(r)?0:.5;this.trackX=0,this.trackY=d-l+C,this.trackWidth=Math.max(0,c-p),this.trackHeight=l,this.barWidth=qt(this.distance,this.visibleDistance,u,this.thumbTrackDistance),this.thumbTravelDistance=Math.max(0,this.thumbTrackDistance-this.barWidth-b),this.barY=this.trackY-1+(l-o)/2,this.barHeight=o;const v=this.distance?this.scroll/this.distance:0;this.barX=v*this.thumbTravelDistance,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:o}}=this.ctx;if(this.updatedSize(),this.isInnerMode()&&!this.shouldDrawInnerScrollbar())return this.isFocus||this.isDragging;const r=Fe(this.ctx.config),a=We(this.ctx.config),l=r&&Ot(s)?i:"transparent",c=this.hasScrollbar(),d=Ge(s,c);return a&&d?(this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{fillColor:o}),this.drawTrackHeaderBackground(),r&&(this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:l}),this.drawRightBoundaryBorder())):a&&this.drawInactiveTrackBackground(),c&&this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),r&&d&&this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:l,borderWidth:1}),this.isFocus||this.isDragging}drawTrackHeaderBackground(){if(this.type!=="vertical"||this.trackWidth<=0)return;const{header:t,config:{HEADER_BG_COLOR:e}}=this.ctx,i=Math.max(0,Math.min(t.height,this.trackHeight));i<=0||this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,i,{fillColor:e})}drawInactiveTrackBackground(){if(this.type!=="vertical")return;const{footer:t,header:e,scrollY:i,stageHeight:s,config:{BODY_BG_COLOR:o,FOOTER_BG_COLOR:r,FOOTER_FIXED:a,FOOTER_POSITION:l,HEADER_BG_COLOR:c,SCROLLER_TRACK_SIZE:d=0}}=this.ctx,f=Math.max(0,s-d);if(f<=0||this.trackWidth<=0||(this.ctx.paint.drawRect(this.trackX,0,this.trackWidth,f,{fillColor:o}),this.ctx.paint.drawRect(this.trackX,0,this.trackWidth,e.height,{fillColor:c}),!t.height))return;const u=a?l==="top"?e.height:f-t.height:t.y-i,x=Math.max(e.height,Math.min(u,f)),g=Math.max(0,Math.min(t.height,f-x));g>0&&this.ctx.paint.drawRect(this.trackX,x,this.trackWidth,g,{fillColor:r})}drawRightBoundaryBorder(){const{stageHeight:t,config:{BORDER:e,BORDER_COLOR:i,SCROLLER_TRACK_SIZE:s=0}}=this.ctx;this.type}}class fi{constructor(t){n(this,"ctx");n(this,"verticalScrollbar");n(this,"horizontalScrollbar");n(this,"mousedownHeader",!1);n(this,"adjustPositionX","");n(this,"adjustPositionY","");n(this,"timerX",0);n(this,"timerY",0);this.ctx=t,this.verticalScrollbar=new Jt(t,"vertical"),this.horizontalScrollbar=new Jt(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("mouseout",e=>this.onMouseOut(e)),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)}),this.ctx.on("scrollToIndex",(e,i)=>{this.scrollToIndex(e,i)}),this.ctx.on("cellHeaderMousedown",()=>{this.mousedownHeader=!0}),this.ctx.on("startAdjustPosition",e=>{this.startAdjustPosition(e)}),this.ctx.on("stopAdjustPosition",()=>{this.stopAdjustPosition()})}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){const e=this.ctx.containerElement.getBoundingClientRect(),i=t.clientX>=e.left&&t.clientX<=e.right&&t.clientY>=e.top&&t.clientY<=e.bottom,s=this.verticalScrollbar.onMouseMove(t,i),o=this.horizontalScrollbar.onMouseMove(t,i);s||o?this.ctx.emit("draw"):this.draw()}onMouseUp(){this.mousedownHeader=!1,this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}onMouseOut(t){this.ctx.containerElement.contains(t.relatedTarget)||(this.verticalScrollbar.hideInnerScrollbar(),this.horizontalScrollbar.hideInnerScrollbar(),this.ctx.emit("draw"))}draw(){const t=this.verticalScrollbar.draw(),e=this.horizontalScrollbar.draw();this.ctx.scrollerFocus=t||e;const i=Math.floor(this.horizontalScrollbar.scroll),s=Math.floor(this.verticalScrollbar.scroll);(i!==this.ctx.scrollX||s!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",i,s),i!==this.ctx.scrollX&&this.ctx.emit("onScrollX",i),s!==this.ctx.scrollY&&this.ctx.emit("onScrollY",s),this.ctx.scrollX=i,this.ctx.scrollY=s,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&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);this.setScrollY(s-e.visibleHeight/2)}scrollToIndex(t,e){this.scrollToRowIndex(t),this.scrollToColIndex(e)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(s===void 0)return;const{top:o}=i.getPositionForRowIndex(s);this.setScrollY(o-e.visibleHeight/2)}startAdjustPosition(t){var r,a;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",o="";if(((r=this.ctx.focusCell)==null?void 0:r.fixed)!=="left"&&e<this.ctx.fixedLeftWidth?s="left":((a=this.ctx.focusCell)==null?void 0:a.fixed)!=="right"&&e>this.ctx.body.visibleWidth-this.ctx.fixedRightWidth?s="right":(s="",this.stopAdjustPosition(!0,!1)),!this.mousedownHeader&&i<this.ctx.header.visibleHeight?o="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight?o="bottom":(o="",this.stopAdjustPosition(!1,!0)),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let c=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{c*=1.5;const{scrollX:d}=this.ctx,f=d+c;(f<0||f>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(f)},100)}if(o&&this.adjustPositionY!==o){this.adjustPositionY=o;let c=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{c*=1.5;const{scrollY:d}=this.ctx,f=d+c;(f<0||f>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(f)},100)}}stopAdjustPosition(t=!0,e=!0){t&&(this.adjustPositionX="",this.timerX&&(clearInterval(this.timerX),this.timerX=0)),e&&(this.adjustPositionY="",this.timerY&&(clearInterval(this.timerY),this.timerY=0))}}class ui extends fe{constructor(e,i,s,o,r,a,l){super(e,s,o,r,a,"header",l.fixed);n(this,"align");n(this,"hideHeaderSelection",!1);n(this,"verticalAlign","middle");n(this,"fixed");n(this,"minWidth");n(this,"maxWidth");n(this,"widthFillDisable");n(this,"type");n(this,"operation",!1);n(this,"editorType");n(this,"level");n(this,"text");n(this,"hide",!1);n(this,"displayText","");n(this,"colspan");n(this,"rowspan");n(this,"row");n(this,"key");n(this,"required",!1);n(this,"readonly",!1);n(this,"ellipsis",!1);n(this,"overflowTooltipShow",!0);n(this,"children",[]);n(this,"column");n(this,"colIndex");n(this,"rowKey");n(this,"rules");n(this,"hasChildren");n(this,"render");n(this,"style",{});n(this,"drawX",0);n(this,"drawY",0);n(this,"sortIconName","sort-default");n(this,"sortAscIconName","sort-asc");n(this,"sortDescIconName","sort-desc");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"maxLineClampHeader","auto");n(this,"domDataset",{});n(this,"textOffsetRight",0);n(this,"textOffsetLeft",0);n(this,"textInfo");n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"drawCellBgColor","");n(this,"drawTextColor","");n(this,"drawTextFont","");n(this,"drawSelectionImageX",0);n(this,"drawSelectionImageY",0);n(this,"drawSelectionImageWidth",0);n(this,"drawSelectionImageHeight",0);n(this,"drawSelectionImageName","");n(this,"drawSelectionImageSource");n(this,"drawSortImageX",0);n(this,"drawSortImageY",0);n(this,"drawSortImageWidth",0);n(this,"drawSortImageHeight",0);n(this,"drawSortImageName","");n(this,"drawSortImageSource");n(this,"renderHeaderType","default");this.ctx=e,this.x=s,this.y=o,this.width=r,this.height=a,this.visibleWidth=r,this.visibleHeight=a,this.colIndex=i,this.key=l.key,this.minWidth=l.minWidth,this.maxWidth=l.maxWidth,this.hide=(typeof l.hide=="function"?l.hide(l):l.hide)||!1,this.type=l.type||"",this.editorType=l.editorType||"text",this.hideHeaderSelection=l.hideHeaderSelection||!1,this.align=l.headerAlign||l.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=l.headerVerticalAlign||l.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=l.fixed||"",this.level=l.level||0,this.operation=l.operation||!1,this.text=l.title,this.column=l,this.colspan=l.colspan||1,this.widthFillDisable=l.widthFillDisable||!1,this.rowspan=l.rowspan||1,this.rules=l.rules,this.readonly=l.readonly||!1,this.required=l.required||!1,this.sortIconName=l.sortIconName||"sort-default",this.sortAscIconName=l.sortAscIconName||"sort-asc",this.sortDescIconName=l.sortDescIconName||"sort-desc",this.rowKey=ae(),this.overflowTooltipShow=l.overflowTooltipHeaderShow!==!1,this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader,this.maxLineClampHeader=l.maxLineClampHeader||"auto",this.renderHeaderType=l.renderHeaderType||"default"}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 o=i,r=s;if(typeof e=="function"){const c=e,{backgroundColor:d,color:f,font:u}=c({colIndex:this.colIndex,column:this.column})||{};d&&(o=d),f&&(r=f),u&&(this.drawTextFont=u)}const{colKey:a,type:l}=this.ctx.finderBar;l==="header"&&a===this.key&&(o=this.ctx.config.FINDER_CELL_BG_COLOR),this.drawCellBgColor=o,this.drawTextColor=r}updateOffset(){this.column.sortBy&&(this.textOffsetRight=16),this.required&&(this.textOffsetLeft=12)}update(){this.updateContainer(),this.updateOffset(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.drawTextWidth=this.width,this.drawTextHeight=this.height,this.updateSelection(),this.updateStyle()}draw(){this.drawEdge(),this.drawText(),this.drawBg(),this.updateSortIcon(),this.drawImages(),this.drawRequired()}drawImages(){this.getImages().forEach(e=>{e.visible&&e.source&&this.ctx.paint.drawImage(e.source,e.x,e.y,e.width,e.height)})}drawEdge(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx;e.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:St(s)?i:"transparent",fillColor:this.drawCellBgColor})}drawText(){const{paint:e,config:{HEADER_FONT:i,CELL_PADDING:s}}=this.ctx,o=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`;this.ellipsis=e.drawText(this.displayText,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||i,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign,maxLineClamp:this.maxLineClampHeader,offsetRight:this.textOffsetRight,offsetLeft:this.textOffsetLeft,cacheTextKey:o,textCallback:r=>{this.textInfo=r},layoutCallback:r=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.colIndex}-${this.level}`,r)}})}drawRequired(){if(!this.required||!this.textInfo)return;const{left:e,top:i,height:s}=this.textInfo,{paint:o,config:{REQUIRED_COLOR:r}}=this.ctx;o.drawText("*",e-18,i+(s-12)/2,24,24,{color:r,font:"18px Arial",align:"center",verticalAlign:"middle",padding:0})}drawBg(){if(this.ctx.dragHeaderIng)return;const{ENABLE_SELECTOR:e,ENABLE_SELECTOR_SINGLE:i}=this.ctx.config;let s=-1,o=-1;if(this.ctx.focusCellHeader&&(s=this.ctx.focusCellHeader.colIndex,o=this.ctx.focusCellHeader.colIndex+this.ctx.focusCellHeader.colspan-1),e&&!i){const{xArr:a}=this.ctx.selector;s=a[0],o=a[1]}const r=this.colspan+this.colIndex-1;this.colIndex>=s&&this.colIndex<=o&&r<=o&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}updateSelection(){if(["index-selection","selection","selection-tree","tree-selection"].includes(this.type)){const{indeterminate:e,check:i,selectable:s}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:o=0,CELL_PADDING:r}=this.ctx.config;let a=this.drawX+(this.width-o)/2,l=this.drawY+(this.height-o)/2;this.drawTextX=a+o-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX,(this.align==="left"||this.align==="right")&&(a=this.drawX+r,this.drawTextX=a+o-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX),this.verticalAlign==="top"?l=this.drawY+r/2:this.verticalAlign==="bottom"&&(l=this.drawY+this.height-o-r/2),this.column.dragRow&&(a+=this.ctx.config.DRAG_ROW_ICON_SIZE,this.drawTextX+=this.ctx.config.DRAG_ROW_ICON_SIZE,this.drawTextWidth-=this.ctx.config.DRAG_ROW_ICON_SIZE);let c=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck";e?(c=this.ctx.icons.get("checkbox-indeterminate"),d="checkbox-indeterminate"):i&&s?(c=this.ctx.icons.get("checkbox-check"),d="checkbox-check"):i&&!s?(c=this.ctx.icons.get("checkbox-check-disabled"),d="checkbox-check-disabled"):!i&&s?(c=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck"):(c=this.ctx.icons.get("checkbox-disabled"),d="checkbox-disabled");const f=new q(d,a,l,o,o,c);f.setVisible(!this.hideHeaderSelection),this.setImage("selection",f)}}updateSortIcon(){if(!this.column.sortBy||!this.textInfo)return;const{right:e,top:i,height:s}=this.textInfo,o=e+4,r=i+(s-16)/2,a=16;let l=this.sortIconName;const c=this.ctx.database.getSortState(this.key);c.direction==="asc"?l=this.sortAscIconName:c.direction==="desc"&&(l=this.sortDescIconName);const d=this.ctx.icons.get(l),f=new q(l,o,r,a,a,d);this.setImage("sort",f)}getText(){return this.render&&this.renderHeaderType==="default"||["",null,void 0].includes(this.text)?"":`${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 ge{constructor(t,e){n(this,"root");n(this,"key");n(this,"childrenKey");this.root=t,this.key=(e==null?void 0:e.key)||"key",this.childrenKey=(e==null?void 0:e.childrenKey)||"children"}getTree(){return this.root}treeMove(t,e,i){if(i==="none"||t===e)return;const s=this.findNodeWithParent(this.root,t);if(!s)return;const o=this.findNodeWithParent(this.root,e);if(!o)return;const{parent:r,index:a,node:l}=s,{parent:c,index:d,node:f}=o;if(this.isDescendant(l,e))return;const u=r?r[this.childrenKey]:this.root;if(u.splice(a,1),r&&u.length===0&&delete r[this.childrenKey],i==="inside"){Array.isArray(f[this.childrenKey])||(f[this.childrenKey]=[]),f[this.childrenKey].push(l);return}const x=c?c[this.childrenKey]:this.root;let g=d;r===c&&a<d&&g--,i==="after"&&g++,x.splice(g,0,l)}findNodeWithParent(t,e,i=null){for(let s=0;s<t.length;s++){const o=t[s];if(o[this.key]===e)return{parent:i,index:s,node:o};const r=o[this.childrenKey];if(Array.isArray(r)){const a=this.findNodeWithParent(r,e,o);if(a)return a}}return null}isDescendant(t,e){const i=t[this.childrenKey];if(!Array.isArray(i))return!1;for(const s of i)if(s[this.key]===e||this.isDescendant(s,e))return!0;return!1}}class xi{constructor(t){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"resizeTarget",null);n(this,"dragTarget",null);n(this,"dragingCell");n(this,"dragCellDiff",0);n(this,"resizeNum",0);n(this,"isResizing",!1);n(this,"clientX",0);n(this,"resizeDiff",0);n(this,"columnIndex",0);n(this,"isMouseDown",!1);n(this,"columns");n(this,"visibleColumns");n(this,"visibleLeafColumns",[]);n(this,"visibleHeight",0);n(this,"visibleWidth",0);n(this,"allCellHeaders",[]);n(this,"leafCellHeaders",[]);n(this,"renderLeafCellHeaders",[]);n(this,"fixedLeftCellHeaders",[]);n(this,"centerCellHeaders",[]);n(this,"fixedRightCellHeaders",[]);n(this,"renderCenterCellHeaders",[]);n(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",Nt(()=>{this.init(),this.ctx.clearSelector(),this.ctx.emit("draw")},100)),this.init(),this.initSelection(),this.initSort(),this.initResizeColumn(),this.initDragColumn()}init(t=!1){const{config:{HEADER_HEIGHT:e}}=this.ctx,i=B(this.ctx.config);if(!t){const x=this.ctx.database.getColumns();this.columns=x}this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[],this.visibleColumns=le(this.columns);const s=ht(this.visibleColumns),o=st(this.visibleColumns);this.height=e*s,this.visibleHeight=this.height,this.width=o.reduce((x,g)=>{const E=g.width||100,{maxWidth:m,minWidth:w}=g;return m&&E>m?x+m:w&&E<w?x+w:x+E},0),this.columnIndex=0,this.resizeNum=0;const r=Le(dt(this.visibleColumns,s));this.render(r,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const a=this.ctx.containerElement.getBoundingClientRect(),{stageWidth:l,stagePhysicalWidth:c}=this.ctx.zoomScale.resolveStageWidth({containerPhysicalWidth:a.width,contentWidth:this.width,scrollerTrackSize:i,fillContainer:this.resizeNum>0});this.ctx.stageWidth=l,this.ctx.stagePhysicalWidth=c,this.ctx.stageElement.style.width=`${c}px`,this.visibleWidth=this.ctx.stageWidth-i;const d=this.visibleWidth-this.width;if(this.resizeNum&&d>0){const x=Math.floor(d/this.resizeNum*100)/100;this.resizeAllColumn(x)}const f=this.fixedLeftCellHeaders.filter(x=>!x.hasChildren);this.ctx.fixedLeftWidth=f.reduce((x,g)=>x+g.width,0);const u=this.fixedRightCellHeaders.filter(x=>!x.hasChildren);this.ctx.fixedRightWidth=u.reduce((x,g)=>x+g.width,i),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.allCellHeaders=this.allCellHeaders,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initSort(){this.ctx.on("cellHeaderClick",(t,e)=>{if(!t.isImageInside("sort",e))return;const i=this.ctx.database.getSortState(t.key);let s;i.direction==="none"?s="asc":i.direction==="asc"?s="desc":s="none",this.ctx.database.setSortState(t.key,s)})}initSelection(){this.ctx.on("cellHeaderClick",(t,e)=>{if(this.ctx.stageElement.style.cursor!=="pointer"||!t.isImageInside("selection",e))return;const i=t.getImage("selection");["checkbox-uncheck","checkbox-indeterminate"].includes(i.name)?this.ctx.database.toggleAllSelection():i.name==="checkbox-check"&&this.ctx.database.clearSelection(!0)})}initResizeColumn(){this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&this.ctx.isTarget(t)&&(this.clientX=t.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&(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",t=>{if(!this.ctx.config.ENABLE_RESIZE_COLUMN||this.ctx.editing)return;const{stageWidth:e,config:{RESIZE_COLUMN_MIN_WIDTH:i}}=this.ctx;if(this.isResizing&&this.resizeTarget){const s=this.resizeTarget.width,o=this.resizeTarget.minWidth,r=this.resizeTarget.maxWidth;let a=t.clientX-this.clientX;a+s<i&&(a=-(s-i)),o&&a+s<o&&(a=-(s-o)),r&&a+s>r&&(a=r-s),this.resizeDiff=a,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;const{offsetX:s}=this.ctx.getOffset(t);if(s<0||s>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 o=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const r of o){const{offsetX:a,offsetY:l}=this.ctx.getOffset(t),c=a,d=l,f=r.getDrawX(),u=r.getDrawY();if(c>f+r.width-5&&c<f+r.width+4&&c<e-4&&d>u){const x=r.colIndex+r.colspan-1,g=this.leafCellHeaders.find(E=>E.colIndex===x);if(!g||!g.fixed&&this.ctx.stageWidth-this.ctx.fixedRightWidth<f+r.width)return;this.ctx.isTarget(t)&&l<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=g)}}}})}initDragColumn(){this.ctx.on("cellHeaderMousedown",t=>{this.ctx.stageElement.style.cursor==="default"&&this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragTarget===t?(this.ctx.dragHeaderIng=!0,this.dragCellDiff=this.ctx.mouseX-t.drawX,this.ctx.stageElement.style.cursor="grabbing"):(this.dragTarget=t,this.ctx.dragHeaderIng=!1)))}),this.ctx.on("cellMousedown",()=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(this.dragTarget=null,this.ctx.dragHeaderIng=!1)}),this.ctx.on("mouseup",()=>{if(this.ctx.config.ENABLE_DRAG_COLUMN){if(this.dragingCell&&this.dragTarget){const t=(c,d={})=>(c.forEach((f,u)=>{f.children&&t(f.children,d),d[f.key]=u}),d),e=this.ctx.database.getColumns(),i=dt(e,ht(e)),s=new ge(i,{key:"key",childrenKey:"children"}),o=this.dragTarget.colIndex>this.dragingCell.colIndex?"before":"after";s.treeMove(this.dragTarget.column.key,this.dragingCell.column.key,o);const r=s.getTree(),a=t(r);this.ctx.database.setCustomHeader({sortData:a}),this.init();const l={source:this.dragTarget,target:this.dragingCell,columns:i};this.ctx.emit("columnDragChange",l)}this.ctx.dragHeaderIng&&this.dragTarget&&(this.ctx.stageElement.style.cursor==="grabbing"&&(this.ctx.stageElement.style.cursor="default"),this.ctx.dragHeaderIng=!1,this.dragTarget=null,this.dragingCell=void 0,this.dragCellDiff=0,this.ctx.clearSelector(),this.ctx.focusCellHeader=void 0,this.ctx.emit("draw"))}}),this.ctx.on("mousemove",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(!this.ctx.dragHeaderIng||!this.dragTarget||(this.dragTarget.fixed||this.ctx.startAdjustPosition(t),this.ctx.emit("draw")))}),this.ctx.on("cellHoverChange",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(t.colIndex)))}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(t.colIndex)))})}getDragCellHeader(t){if(!this.dragTarget||!this.ctx.dragHeaderIng)return;const{column:{parentKey:e},key:i,level:s,fixed:o}=this.dragTarget,r=this.allCellHeaders.find(a=>a.key!==i&&a.fixed===o&&a.column.level===s&&a.column.parentKey===e&&a.colIndex<=t&&a.colIndex+a.colspan-1>=t);if(this.ctx.dragHeaderIng){const a=r?"grabbing":"not-allowed";this.ctx.stageElement.style.cursor=a}return r}resizeColumn(t,e){const i=r=>{r.forEach(a=>{if(a.children&&a.children.length>0&&i(a.children),a.key===t.key){const l=a.width||100;a.width=l+e}})};i(this.columns);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)}const o=t.width+e+s;this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:o,column:t.column,columns:this.columns}),this.ctx.database.setCustomHeaderResizableData(t.key,o),this.init(!0),this.ctx.emit("draw")}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const o of this.allCellHeaders)if(o.widthFillDisable)e.set(o.key,o.width);else{const r=o.width+t*o.colspan;e.set(o.key,r),r<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=o=>{o.forEach(r=>{e.has(r.key)&&(r.width=e.get(r.key)),r.children&&r.children.length>0&&s(r.children)})};s(this.columns),this.init(!0),this.ctx.emit("draw")}getCustomHeader(){const t=this.ctx.database.getColumns(),e=this.ctx.database.getCustomHeader(),{sortData:i={}}=e;return Object.keys(i).length===0?{columns:t,customHeader:e}:{columns:dt(t,ht(t)),customHeader:e}}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:o=0}=this.ctx.config;for(let r=0;r<i;r++){const a=t[r],l=o*(a.rowspan||0),c=o*(a.level||0);let{minWidth:d,maxWidth:f}=a,u=a.width||100;d&&u<d&&(u=d),f&&u>f&&(u=f),a.children&&(u=st(a.children).reduce((E,m)=>E+((m==null?void 0:m.width)||100),0));const x=new ui(this.ctx,this.columnIndex,s,c,u,l,a);this.ctx.database.setHeader(a.key,x),this.allCellHeaders.push(x),a.children||(this.leafCellHeaders.push(x),x.column.widthFillDisable||this.resizeNum++),a.fixed==="left"?this.fixedLeftCellHeaders.push(x):a.fixed==="right"?this.fixedRightCellHeaders.push(x):this.centerCellHeaders.push(x),!a.children&&this.columnIndex++,a.children&&this.render(a.children,s),s+=u}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e,RESIZE_COLUMN_TEXT_COLOR:i,RESIZE_COLUMN_TEXT_BG_COLOR:s,ENABLE_RESIZE_COLUMN_TEXT:o}}=this.ctx,r=this.resizeTarget.getDrawX(),a=this.resizeTarget.width,l=r+a+this.resizeDiff-.5,c=[l-.5,0,l-.5,t];if(this.ctx.paint.drawLine(c,{borderColor:e}),o){const f=`${Math.floor(a+this.resizeDiff)}px`,u=45,x=24;this.ctx.paint.drawRect(l+u/2,this.ctx.mouseY-x/2,u,x,{fillColor:s,borderWidth:0,borderColor:"transparent"}),this.ctx.paint.drawText(f,l+u/2,this.ctx.mouseY-x/2,u,x+2,{padding:0,color:i,align:"center",verticalAlign:"middle"})}}}drawDragTip(){if(this.dragTarget&&this.ctx.dragHeaderIng){const{DRAG_TIP_BG_COLOR:t,DRAG_TIP_LINE_COLOR:e}=this.ctx.config,i=this.dragTarget.width;if(this.ctx.paint.drawRect(this.ctx.mouseX-this.dragCellDiff,this.visibleHeight,i,this.ctx.body.visibleHeight,{fillColor:t,borderWidth:0,borderColor:"transparent"}),this.dragingCell){const{drawX:s,drawY:o,visibleWidth:r,colIndex:a}=this.dragingCell;let l=s,c=o;a>this.dragTarget.colIndex&&(l=s+r),a===0&&(l=l+1),a===this.ctx.maxColIndex&&(l=l-1);const d=[l,c,l,this.ctx.stageHeight],f=[l-4,c,l+4,c,l,c+6,l-4,c];this.ctx.paint.drawLine(f,{borderColor:e,borderWidth:1.2,fillColor:e}),this.ctx.paint.drawLine(d,{borderColor:e,borderWidth:1.2})}}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r}}=this.ctx,a=B(this.ctx.config);if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:r,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,o)=>s.x-o.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,BORDER:i}}=this.ctx;if(!kt(i))return;const s=[0,this.height,t,this.height];this.ctx.paint.drawLine(s,{borderColor:e,borderWidth:1})}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFixedShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawBottomLine(),this.drawTipLine(),this.drawDragTip()}}class me{constructor(t,e,i=0,s=0,o=0,r=0,a,l="body"){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height");n(this,"cells",[]);n(this,"fixedCells",[]);n(this,"noFixedCells",[]);n(this,"calculatedHeightCells",[]);n(this,"rowIndex",0);n(this,"rowKey","");n(this,"rowType","body");n(this,"data");n(this,"calculatedHeight",-1);this.ctx=t,this.x=i,this.y=s,this.width=o,this.height=r,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=l,this.data=a,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[],o=[];t.renderLeafCellHeaders.forEach(r=>{const a=new ue(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);a.fixed?i.push(a):s.push(a),e.push(a),a.autoRowHeight&&o.push(a)}),this.cells=e,this.calculatedHeightCells=o,this.fixedCells=i,this.noFixedCells=s}updateCalculatedHeight(){const t=this.calculatedHeightCells.map(e=>{const i=e.getAutoHeight(),{key:s,height:o=-1}=this.ctx.database.getMaxRowHeightItem(this.rowKey)||{};return i>o?this.ctx.database.setMaxRowHeightItem(this.rowKey,e.key,i):e.key===s&&i<o&&this.ctx.database.setMaxRowHeightItem(this.rowKey,e.key,i),i});return this.calculatedHeight=t.length?Math.max(...t):-1,this.calculatedHeight}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()})}drawHorizontalBorder(){this.noFixedCells.forEach(t=>{t.drawHorizontalBorder()})}drawFixedHorizontalBorder(){this.fixedCells.forEach(t=>{t.drawHorizontalBorder()})}}class gi{constructor(t){n(this,"resizeTarget",null);n(this,"dragSource",null);n(this,"dragTarget",null);n(this,"dragRowDiff",0);n(this,"dragPosition","none");n(this,"isMouseDown",!1);n(this,"resizeDiff",0);n(this,"clientY",0);n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"headIndex",0);n(this,"tailIndex",0);n(this,"isResizing",!1);n(this,"renderRows",[]);n(this,"visibleRows",[]);n(this,"visibleHeight",0);n(this,"visibleWidth",0);n(this,"containerRect");n(this,"data",[]);this.ctx=t,this.init(),this.initTree(),this.initSelection(),this.initResizeRow(),this.initDragRow()}init(){const{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:o,HEIGHT:r,EMPTY_BODY_HEIGHT:a=0,MAX_HEIGHT:l=0,ENABLE_OFFSET_HEIGHT:c=0,OFFSET_HEIGHT:d=0,FOOTER_POSITION:f}}=this.ctx,u=B(this.ctx.config);if(!e.width)return;this.x=0,f==="top"&&o?this.y=e.height+i.height:this.y=e.height;const{data:x,sumHeight:g}=s.getData();this.height=g,this.data=x,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-u;const E=this.ctx.footer.height;this.ctx.isEmpty=!this.data.length,!this.data.length&&!r?this.height=a:!this.data.length&&r&&(this.height=r-e.height-E-u);const{zoomScale:m}=this.ctx;let w=this.height+e.height+u;w+=E;let y=m.contentToPhysical(w);const b=window.innerHeight,{top:p}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(b>p&&c&&!r){const M=b-p-d;M>m.contentToPhysical(e.height+u)?y=M:m.contentToPhysical(w)>l&&(y=l)}else this.data.length&&r?y=r:this.data.length&&l&&m.contentToPhysical(w)>l&&(y=l);if(y>0){const{stageHeight:O,stagePhysicalHeight:M}=m.applyStageHeight(this.ctx.stageElement,y);this.ctx.stageHeight=O,this.ctx.stagePhysicalHeight=M}let C=this.ctx.stageHeight-e.height-u;o?this.visibleHeight=C-E: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=x;const v=window.devicePixelRatio||1,I=this.ctx.stagePhysicalWidth*v,T=this.ctx.stagePhysicalHeight*v;t.width=Math.round(I),t.height=Math.round(T);const _=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:_,type:_,headerHeight:e.height,bodyHeight:this.height,footerHeight:E,width:this.width,height:this.data.length?0:a+E});const R=Math.round(t.width/v*1e4)/1e4,S=Math.round(t.height/v*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${S}px;width:${R}px;`),this.ctx.paint.scale(v,this.ctx.zoomScale.value)}initTree(){this.ctx.on("cellClick",(t,e)=>{if(this.ctx.stageElement.style.cursor!=="pointer"||!t.isImageInside("tree",e))return;const i=this.ctx.database.getRowForRowKey(t.rowKey),{expand:s=!1,expandLazy:o=!1}=i||{},{EXPAND_LAZY:r,EXPAND_LAZY_METHOD:a}=this.ctx.config;if(r&&a&&!s&&!o)typeof a=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),a({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(c=>{this.ctx.database.setExpandChildren(t.rowKey,c),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(c=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(c)}));else{const l=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!l),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}})}initSelection(){this.ctx.on("cellClick",(t,e)=>{this.ctx.stageElement.style.cursor!=="pointer"||!t.isImageInside("selection",e)||!this.ctx.database.getRowSelectable(t.rowKey)||this.ctx.database.toggleRowSelection(t.rowKey,t.type)})}initResizeRow(){this.ctx.on("resize",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("resizeObserver",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(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",t=>{this.ctx.config.ENABLE_RESIZE_ROW&&this.ctx.isTarget(t)&&(this.clientY=t.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_ROW||this.ctx.editing)return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i,r=t.clientY,{stageHeight:a,scrollY:l,config:{RESIZE_ROW_MIN_HEIGHT:c=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const d=this.resizeTarget.height;let f=r-this.clientY;const{calculatedHeight:u}=this.resizeTarget,x=u===-1?c:u;f+d<x&&(f=-(d-x)),this.resizeDiff=f,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(o<0||o>this.ctx.body.visibleWidth||s<0||s>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 d=0;d<this.renderRows.length;d++){const f=this.renderRows[d];if(s>f.y-l+f.height-1.5&&s<f.y-l+f.height+1.5&&s<a-4)for(let x=0;x<f.cells.length;x++){const g=f.cells[x];o>g.drawX+10&&o<g.drawX+g.width-10&&g.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=f)}}}})}initDragRow(){this.ctx.on("cellMousedown",(t,e)=>{this.ctx.config.ENABLE_DRAG_ROW&&t.isImageInside("drag",e)&&(this.dragSource=t,this.ctx.database.expandItem(t.rowKey,!1),this.ctx.dragRowIng=!0,this.dragRowDiff=this.ctx.mouseY-t.drawY,this.ctx.stageElement.style.cursor="grabbing",this.ctx.clearSelector(),this.ctx.emit("dragRowMouseDown",t),this.ctx.emit("draw"))}),this.ctx.on("mouseup",async()=>{if(this.ctx.dragRowIng){if(this.dragSource&&this.dragTarget&&this.ctx.stageElement.style.cursor!=="not-allowed"){const t=this.dragSource,e=this.dragTarget,i={source:t,target:e,position:this.dragPosition};this.ctx.emit("dragRowChange",i);let s=!0;const{BEFORE_DRAG_ROW_METHOD:o}=this.ctx.config;if(typeof o=="function"&&(s=await o(i)),s&&!this.ctx.config.ENABLE_DRAG_ROW_CUSTOM){const r=this.ctx.database.getOriginalData(),{TREE_CHILDREN_KEY:a,ROW_KEY:l}=this.ctx.config,c=new ge(r,{key:l,childrenKey:a});c.treeMove(t.rowKey,e.rowKey,this.dragPosition),this.ctx.emit("loadData",c.getTree())}}this.dragTarget||(this.ctx.stageElement.style.cursor="grab"),this.ctx.dragRowIng=!1,this.dragSource=null,this.dragTarget=null,this.dragPosition="after",this.dragRowDiff=0,this.ctx.emit("draw")}}),this.ctx.on("mousemove",t=>{if(!this.ctx.dragRowIng)return;const{offsetY:e}=this.ctx.getOffset(t),{drawY:i}=this.dragTarget;i<e||i>e?this.ctx.startAdjustPosition(t):this.ctx.stopAdjustPosition()}),this.ctx.on("cellMouseenter",t=>{if(!this.ctx.dragRowIng)return;this.dragTarget=t;const{ENABLE_DRAG_ROW_CROSS_LEVEL:e}=this.ctx.config,i=this.dragSource,s=this.dragTarget;if(!e&&i&&s&&i.parentRowKey!==s.parentRowKey){this.ctx.stageElement.style.cursor="not-allowed";return}this.ctx.stageElement.style.cursor="grabbing",this.dragTarget=t;const{drawY:o,visibleHeight:r}=t,a=e?r/3:r/2;this.ctx.mouseY<=o+a?this.dragPosition="before":this.ctx.mouseY>o+r-a?this.dragPosition="after":this.dragPosition="inside";const l={dragSource:this.dragSource,dragTarget:this.dragTarget,dragPosition:this.dragPosition};this.ctx.emit("dragRowMove",l),this.ctx.emit("draw")})}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:o,data:r}=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:o,row:r,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,o=this.resizeTarget.height,r=s+o+this.resizeDiff-.5,a=[0,r-.5,t,r-.5];this.ctx.paint.drawLine(a,{borderColor:i,borderWidth:1})}}drawDragRowTip(){if(this.ctx.dragRowIng&&this.dragTarget&&this.dragSource){const{stageWidth:t,config:{DRAG_ROW_TIP_LINE_COLOR:e,DRAG_TIP_BG_COLOR:i}}=this.ctx,s=this.dragSource.visibleHeight;this.ctx.paint.drawRect(0,this.ctx.mouseY-this.dragRowDiff,this.visibleWidth,s,{fillColor:i,borderWidth:0,borderColor:"transparent"});const o=this.dragTarget.drawY,r=this.dragTarget.height;let a=o;if(["before","after"].includes(this.dragPosition)){this.dragPosition==="after"&&(a=o+r);const c=[0,a-.5,t,a-.5];this.ctx.paint.drawLine(c,{borderColor:e,borderWidth:1.2})}["inside"].includes(this.dragPosition)&&(a=o+r/2);const l=[0,a-4,6,a,0,a+4,0,a-4];this.ctx.paint.drawLine(l,{borderColor:e,borderWidth:1.2,fillColor:e})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r}}=this.ctx,a=B(this.ctx.config);if(i>0&&t!==0&&!this.ctx.isEmpty&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a&&!this.ctx.isEmpty){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:r,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,o=-1;for(;i<=s;){let r=Math.floor((i+s)/2),a=t[r].bottom;if(a===e)return r;a<e?i=r+1:(o=r,s=r-1)}return o}update(){this.init();const{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,o=i,{data:r,positions:a}=e.getData();this.ctx.maxRowIndex=r.length-1;let l=this.binarySearch(a,o),c=this.binarySearch(a,o+this.visibleHeight);if(c===-1&&(c=this.ctx.maxRowIndex),l===-1&&c===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);l=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,l),this.tailIndex=Math.min(this.ctx.maxRowIndex,c+1),this.visibleRows=r.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,x=this.visibleRows[f],{height:g,top:E}=this.ctx.database.getPositionForRowIndex(u),m=new me(this.ctx,u,0,E+this.y,t.width,g,x);d.push(m)}this.renderRows=d,this.ctx.body.renderRows=d}updateAutoHeight(){const t=this.ctx.body.renderRows;if(!t.some(s=>s.calculatedHeightCells.length>0))return!1;t.forEach(s=>{s.updateCalculatedHeight()});const i=t.map(s=>({height:s.calculatedHeight,rowIndex:s.rowIndex}));return this.ctx.database.setBatchCalculatedRowHeight(i)}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawHorizontalBorder()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixedHorizontalBorder()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class mi{constructor(t){n(this,"ctx");n(this,"renderRows",[]);n(this,"data",[]);n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"visibleWidth",0);n(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,FOOTER_POSITION:o}}=this.ctx,r=B(this.ctx.config);this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(a=>a+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:o,config:{HEADER_BG_COLOR:r}}=this.ctx,a=B(this.ctx.config);let l=this.y;if(this.ctx.config.FOOTER_FIXED||(l=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,l,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const c=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(c,l,e,this.height,{fillColor:r,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,o)=>{const r=new me(this.ctx,o,0,e,this.width,t,s,"footer");e+=t,i.push(r)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){const{stageWidth:t,config:{BORDER_COLOR:e,BORDER:i}}=this.ctx;if(!kt(i))return;const s=[0,this.y,t,this.y];this.ctx.paint.drawLine(s,{borderColor:e,borderWidth:1})}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawHorizontalBorder()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixedHorizontalBorder()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTopLine()}}class wi{constructor(t){n(this,"isCut",!1);n(this,"isMultipleRow",!1);n(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",Nt(t=>{var e;(e=this.ctx.focusCellHeader)!=null&&e.fixed||!this.ctx.dragHeaderIng&&this.ctx.selectorMove&&this.ctx.startAdjustPosition(t)},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("cellClick",()=>{this.adjustBoundaryPosition()}),this.ctx.on("cellMousedown",(t,e)=>{if(!this.ctx.isTarget(e)||this.ctx.stageElement.style.cursor==="pointer"||this.ctx.stageElement.style.cursor==="crosshair")return;if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.ctx.stopAdjustPosition(),setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHoverChange",t=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{if(this.ctx.stageElement.style.cursor==="pointer")return;window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.ctx.clearSelector(),t.operation?this.selectAll():this.selectCols(t)}),this.ctx.on("keydown",t=>{if(!this.ctx.editing&&!this.ctx.finding){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.adjustBoundaryPosition()}),this.ctx.on("selectCols",t=>{this.selectCols(t)})}setSelector(t,e){if(this.ctx.dragHeaderIng||this.ctx.dragRowIng)return;const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let o=t,r=e;if(!s){const[a]=r;r=[a,a]}if(!i){const[a]=o;o=[a,a]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(r)){this.ctx.mousedown&&(this.ctx.selectorMove=!0,this.ctx.disableHoverIconClick=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:l,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,x=a,g=l||this.ctx.maxColIndex-f,E=c,m=d||this.ctx.maxRowIndex-u;let[w,y]=o,[b,p]=r;if(w<x||y>g||b<E||p>m)return;if(this.ctx.config.ENABLE_MERGE_CELL_LINK){const v=this.adjustMergeCells(o,r);b=v.yArr[0],p=v.yArr[1],w=v.xArr[0],y=v.xArr[1],this.ctx.onlyMergeCell=v.onlyMergeCell}w===y&&b===p?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,o=[Math.max(x,w),Math.min(g,y)],r=[Math.max(E,b),Math.min(m,p)];const{BEFORE_SET_SELECTOR_METHOD:C}=this.ctx.config;if(typeof C=="function"){const I=C({focusCell:this.ctx.focusCell,xArr:o,yArr:r});if(!I)return;o=I.xArr,r=I.yArr}this.ctx.selector.xArr=o,this.ctx.selector.yArr=r,p===this.ctx.maxRowIndex&&b===0?this.ctx.selectColsIng=!0:this.ctx.selectColsIng=!1,y===this.ctx.maxColIndex&&w===0?this.ctx.selectRowsIng=!0:this.ctx.selectRowsIng=!1,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var g;const[i,s]=e,[o,r]=t;if(s===this.ctx.maxRowIndex&&i===0||r===this.ctx.maxColIndex&&o===0)return{xArr:t,yArr:e,onlyMergeCell:!1};let a=[],l=[];for(let E=0;E<=e[1]-e[0];E++)for(let m=0;m<=t[1]-t[0];m++){const w=E+e[0],y=m+t[0],b=this.ctx.database.getVirtualBodyCell(w,y);b&&((w===i||w===s)&&a.push(b),(y===o||y===r)&&l.push(b))}const c=a.reduce((E,m)=>{const{yArr:w}=m.getSpanInfo(),[y,b]=w;return E.minY=Math.min(E.minY,y),E.maxY=Math.max(E.maxY,b),E},{minY:i,maxY:s}),d=l.reduce((E,m)=>{const{xArr:w}=m.getSpanInfo(),[y,b]=w;return E.minX=Math.min(E.minX,y),E.maxX=Math.max(E.maxX,b),E},{minX:o,maxX:r}),f=[d.minX,d.maxX],u=[c.minY,c.maxY];let x=!1;if(d.minX!==d.maxX||c.minY!==c.maxY){const E=JSON.stringify(f)+JSON.stringify(u),m=(g=this.ctx.focusCell)==null?void 0:g.getSpanInfo();x=(m&&JSON.stringify(m.xArr)+JSON.stringify(m.yArr))===E}return{xArr:f,yArr:u,onlyMergeCell:x}}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;const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,o=e,r=i||this.ctx.maxRowIndex-s;if(this.ctx.focusCellHeader){const{colIndex:a}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),this.ctx.mousedown&&t.colIndex>=a){const l=[a,t.colIndex+t.colspan-1],c=[o,r];this.setSelector(l,c)}else{const l=[t.colIndex,a+t.colspan-1],c=[o,r];this.setSelector(l,c)}}}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:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-a,f=o,u=r||this.ctx.maxRowIndex-l,x=[c,d],g=[f,u];this.setSelector(x,g)}}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:o}=this.ctx.config,r=s||this.ctx.maxColIndex-o,a=i;if(e){this.ctx.setFocusCell(t);const l=[a,r],c=[t.rowIndex,t.rowIndex];this.setSelector(l,c)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const c=[a,r],d=[l,t.rowIndex];this.setSelector(c,d)}else{const c=[a,r],d=[t.rowIndex,l];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:o}=e,r=Math.min(i.colIndex,o),a=Math.max(i.colIndex,o),l=Math.min(i.rowIndex,s),c=Math.max(i.rowIndex,s),d=[r,a],f=[l,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:o}=i,{colIndex:r,rowIndex:a}=e,l=Math.min(r,s),c=Math.max(r,s),d=Math.min(a,o),f=Math.max(a,o),u=[l,c],x=[d,f];this.setSelector(u,x)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],o=[e.rowIndex,e.rowIndex];this.setSelector(s,o)}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(o=>o.rowIndex===t);return i==null?void 0:i.cells.find(o=>o.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY||this.ctx.domSelectionStr||this.ctx.textSelectionStr)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 r=this.ctx.focusCell;t=[[r.getValue()]],e=[r.colIndex,r.colIndex],i=[r.rowIndex,r.rowIndex]}else{const r={code:"ERR_MERGED_CELLS_COPY",message:this.ctx.locale.getText("mergeCellNoCopy")};this.ctx.hasEvent("error")?this.ctx.emit("error",r):console.error(r.message);return}const{BEFORE_COPY_METHOD:s}=this.ctx.config;if(typeof s=="function"){const a=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!a)return;t=a.data}const o=He(t);navigator.clipboard?navigator.clipboard.writeText(o).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(r=>console.error("Copy Failure:",r)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1,s=null){let o=[];const r=new Set;for(let l=0;l<=e[1]-e[0];l++)for(let c=0;c<=t[1]-t[0];c++){const d=l+e[0],f=c+t[0],u=this.ctx.database.getItemValueForRowIndexAndColIndex(d,f);if(u){const{rowKey:x,key:g}=u;this.ctx.database.getReadonly(x,g)||(r.add(x),o.push({rowKey:x,key:g,value:s,row:{}}))}}if(!o.length)return[];if(i)return o;this.ctx.database.batchSetItemValue(o,!0);let a=[];return r.forEach(l=>{a.push(this.ctx.database.getRowDataItemForRowKey(l))}),this.ctx.emit("clearSelectedDataChange",o,a),o}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 o=>{let r=Ae(o);const a=[i,i+r[0].length-1],l=[e,e+r.length-1],[c,d]=l,[f,u]=a,x=d-this.ctx.maxRowIndex,g=u-this.ctx.maxColIndex;(x>0||g>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:u,minY:c,minX:f,overflowRowCount:x,overflowColCount:g,textArr:r});const E=r.length===1&&r[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!E){const b={code:"ERR_MERGED_CELLS_PASTE",message:this.ctx.locale.getText("mergeCellNoPaste"),data:[]};this.ctx.hasEvent("error")?this.ctx.emit("error",b):console.error(b.message);return}let m=[];for(let b=0;b<=r.length-1;b++){const p=r[b].length;for(let C=0;C<=p-1;C++){const v=b+e,I=C+i,T=r[b][C],_=this.ctx.database.getItemValueForRowIndexAndColIndex(v,I);if(_){const{rowKey:R,key:S}=_;this.ctx.database.getReadonly(R,S)||(s.add(R),m.push({rowKey:R,key:S,value:T,row:{}}))}}}if(this.isCut){const b=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),p=m.map(C=>`${C.rowKey}-${C.key}`);b.forEach(C=>{p.includes(`${C.rowKey}-${C.key}`)||m.unshift(C)}),this.isCut=!1}if(!m.length)return;const{BEFORE_PASTE_DATA_METHOD:w}=this.ctx.config;if(typeof w=="function"){const b=w,p=m.map(C=>({rowKey:C.rowKey,key:C.key,value:C.value,oldValue:this.ctx.database.getItemValue(C.rowKey,C.key),row:this.ctx.database.getRowDataItemForRowKey(C.rowKey)}));if(m=await b(p,a,l,r),m&&!m.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(m,!0);let y=[];s.forEach(b=>{y.push(this.ctx.database.getRowDataItemForRowKey(b))}),this.ctx.emit("pasteChange",m,y),this.ctx.emit("draw")}).catch(o=>{console.error("Failed to get the clipboard content:",o)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const o=0,r=0,a=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>r&&s--;break;case"RIGHT":i<a&&i++;break;case"BOTTOM":s<l&&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")))}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,c=i,d=s||this.ctx.maxColIndex-a,f=o,u=r||this.ctx.maxRowIndex-l;return!(e<c||e>d||t<f||t>u)}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:o,header:r,footer:a,body:l,scrollX:c,scrollY:d,config:{FOOTER_FIXED:f,FOOTER_POSITION:u,ENABLE_MERGE_CELL_LINK:x}}=this.ctx,g=B(this.ctx.config);if(!i)return;x&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:E,drawY:m,width:w,height:y,fixed:b}=i,p=o-E+1,C=i.drawX+w-(e-s)+1;let v=r.height-m,I=y;I>l.visibleHeight&&(I=l.visibleHeight);let T=0;f&&(u==="top"?v=r.height+a.height-m:T=a.visibleHeight);const _=m+I-(t-T-g);let R=c,S=d;C>0&&!b?R=Math.floor(c+C):p>0&&!b&&(R=Math.floor(c-p)),v>0?S=Math.floor(d-v):_>0&&(S=Math.floor(d+_)),(Math.abs(c-R)>2.5||Math.abs(d-S)>2.5)&&this.ctx.setScroll(R,S)}destroy(){}}class Ei{constructor(t){n(this,"ctx");n(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:o,drawX:r,drawY:a,width:l,height:c}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||o===this.ctx.maxRowIndex?0:2,u=r+l-d+f,x=a+c-d+f;e>u&&i>x&&e<u+d&&i<x+d&&(this.ctx.stageElement.style.cursor="crosshair"),this.ctx.autofillMove&&this.ctx.startAdjustPosition(t)}),this.ctx.on("cellMouseenter",t=>{const{xArr:e,yArr:i}=this.ctx.selector,s=e[1],o=i[1],{colIndex:r,rowIndex:a}=t;this.ctx.config.ENABLE_AUTOFILL&&r===s&&a===o&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp(),this.ctx.stopAdjustPosition()})}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,this.ctx.disableHoverIconClick=!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],setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0)}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_AUTOFILL_SPAN_COL:s,ENABLE_AUTOFILL_SPAN_ROW:o}=this.ctx.config;if(!i)return;let r=t,a=e;const l=this.ctx.selector.xArr,c=this.ctx.selector.yArr;if(!(!o&&JSON.stringify(c)!==JSON.stringify(a))&&!(!s&&JSON.stringify(l)!==JSON.stringify(r))&&(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(a))){const{SELECTOR_AREA_MIN_X:d,SELECTOR_AREA_MAX_X:f,SELECTOR_AREA_MIN_Y:u,SELECTOR_AREA_MAX_Y:x,SELECTOR_AREA_MAX_X_OFFSET:g,SELECTOR_AREA_MAX_Y_OFFSET:E}=this.ctx.config,m=d,w=f||this.ctx.maxColIndex-g,y=u,b=x||this.ctx.maxRowIndex-E;let[p,C]=r,[v,I]=a;if(p<m||v<y)return;r=[Math.max(m,p),Math.min(w,C)],a=[Math.max(y,v),Math.min(b,I)];const{BEFORE_SET_AUTOFILL_METHOD:T}=this.ctx.config;if(typeof T=="function"){const R=T({focusCell:this.ctx.focusCell,xArr:r,yArr:a});if(!R)return;r=R.xArr,a=R.yArr}this.ctx.autofill.xArr=r,this.ctx.autofill.yArr=a,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 x=0;x<=e.yArr[1]-e.yArr[0];x++)for(let g=0;g<=e.xArr[1]-e.xArr[0];g++){const E=x+e.yArr[0],m=g+e.xArr[0];i.set(`${E}-${m}`,!0)}const{value:s}=e,o=s[0].length,r=s.length,a=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr,c=o===1&&r===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!c){const x={code:"ERR_MERGED_CELLS_AUTOFILL",message:this.ctx.locale.getText("mergeCellNoFill"),data:[]};this.ctx.hasEvent("error")?this.ctx.emit("error",x):console.error(x.message);return}let d=[];for(let x=0;x<=l[1]-l[0];x++)for(let g=0;g<=a[1]-a[0];g++){const E=g+a[0],m=x+l[0],w=s[x%r][g%o],y=this.ctx.database.getItemValueForRowIndexAndColIndex(m,E),b=`${m}-${E}`;if(y&&!i.has(b)){const{rowKey:p,key:C}=y;this.ctx.database.getReadonly(p,C)||(t.add(p),d.push({rowKey:p,key:C,value:w,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 x=f,g=d.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(d=await x(g,a,l),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let u=[];t.forEach(x=>{u.push(this.ctx.database.getRowDataItemForRowKey(x))}),this.ctx.emit("autofillChange",d,u),this.ctx.emit("draw")}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:o}=t,r=e.xArr.slice(),a=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?o>e.xArr[1]?r.splice(1,1,o):o<e.xArr[0]&&r.splice(0,1,o):s>e.yArr[1]?a.splice(1,1,s):s<e.yArr[0]&&a.splice(0,1,s),this.setAutofill(r,a)}}destroy(){}}const Q=Math.min,U=Math.max,ut=Math.round,ct=Math.floor,F=h=>({x:h,y:h}),pi={left:"right",right:"left",bottom:"top",top:"bottom"};function Lt(h,t,e){return U(h,Q(t,e))}function nt(h,t){return typeof h=="function"?h(t):h}function j(h){return h.split("-")[0]}function at(h){return h.split("-")[1]}function we(h){return h==="x"?"y":"x"}function Xt(h){return h==="y"?"height":"width"}function z(h){const t=h[0];return t==="t"||t==="b"?"y":"x"}function Yt(h){return we(z(h))}function yi(h,t,e){e===void 0&&(e=!1);const i=at(h),s=Yt(h),o=Xt(s);let r=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=xt(r)),[r,xt(r)]}function Ci(h){const t=xt(h);return[Mt(h),t,Mt(t)]}function Mt(h){return h.includes("start")?h.replace("start","end"):h.replace("end","start")}const Qt=["left","right"],te=["right","left"],bi=["top","bottom"],Ri=["bottom","top"];function vi(h,t,e){switch(h){case"top":case"bottom":return e?t?te:Qt:t?Qt:te;case"left":case"right":return t?bi:Ri;default:return[]}}function Ii(h,t,e,i){const s=at(h);let o=vi(j(h),e==="start",i);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(Mt)))),o}function xt(h){const t=j(h);return pi[t]+h.slice(t.length)}function _i(h){return{top:0,right:0,bottom:0,left:0,...h}}function Ee(h){return typeof h!="number"?_i(h):{top:h,right:h,bottom:h,left:h}}function gt(h){const{x:t,y:e,width:i,height:s}=h;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function ee(h,t,e){let{reference:i,floating:s}=h;const o=z(t),r=Yt(t),a=Xt(r),l=j(t),c=o==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,u=i[a]/2-s[a]/2;let x;switch(l){case"top":x={x:d,y:i.y-s.height};break;case"bottom":x={x:d,y:i.y+i.height};break;case"right":x={x:i.x+i.width,y:f};break;case"left":x={x:i.x-s.width,y:f};break;default:x={x:i.x,y:i.y}}switch(at(t)){case"start":x[r]-=u*(e&&c?-1:1);break;case"end":x[r]+=u*(e&&c?-1:1);break}return x}async function Ti(h,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:r,elements:a,strategy:l}=h,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:u=!1,padding:x=0}=nt(t,h),g=Ee(x),m=a[u?f==="floating"?"reference":"floating":f],w=gt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(m)))==null||e?m:m.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),y=f==="floating"?{x:i,y:s,width:r.floating.width,height:r.floating.height}:r.reference,b=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),p=await(o.isElement==null?void 0:o.isElement(b))?await(o.getScale==null?void 0:o.getScale(b))||{x:1,y:1}:{x:1,y:1},C=gt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:l}):y);return{top:(w.top-C.top+g.top)/p.y,bottom:(C.bottom-w.bottom+g.bottom)/p.y,left:(w.left-C.left+g.left)/p.x,right:(C.right-w.right+g.right)/p.x}}const Si=50,Oi=async(h,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,a=r.detectOverflow?r:{...r,detectOverflow:Ti},l=await(r.isRTL==null?void 0:r.isRTL(t));let c=await r.getElementRects({reference:h,floating:t,strategy:s}),{x:d,y:f}=ee(c,i,l),u=i,x=0;const g={};for(let E=0;E<o.length;E++){const m=o[E];if(!m)continue;const{name:w,fn:y}=m,{x:b,y:p,data:C,reset:v}=await y({x:d,y:f,initialPlacement:i,placement:u,strategy:s,middlewareData:g,rects:c,platform:a,elements:{reference:h,floating:t}});d=b??d,f=p??f,g[w]={...g[w],...C},v&&x<Si&&(x++,typeof v=="object"&&(v.placement&&(u=v.placement),v.rects&&(c=v.rects===!0?await r.getElementRects({reference:h,floating:t,strategy:s}):v.rects),{x:d,y:f}=ee(c,u,l)),E=-1)}return{x:d,y:f,placement:u,strategy:s,middlewareData:g}},Li=h=>({name:"arrow",options:h,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:r,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=nt(h,t)||{};if(c==null)return{};const f=Ee(d),u={x:e,y:i},x=Yt(s),g=Xt(x),E=await r.getDimensions(c),m=x==="y",w=m?"top":"left",y=m?"bottom":"right",b=m?"clientHeight":"clientWidth",p=o.reference[g]+o.reference[x]-u[x]-o.floating[g],C=u[x]-o.reference[x],v=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c));let I=v?v[b]:0;(!I||!await(r.isElement==null?void 0:r.isElement(v)))&&(I=a.floating[b]||o.floating[g]);const T=p/2-C/2,_=I/2-E[g]/2-1,R=Q(f[w],_),S=Q(f[y],_),O=R,M=I-E[g]-S,L=I/2-E[g]/2+T,H=Lt(O,L,M),D=!l.arrow&&at(s)!=null&&L!==H&&o.reference[g]/2-(L<O?R:S)-E[g]/2<0,A=D?L<O?L-O:L-M:0;return{[x]:u[x]+A,data:{[x]:H,centerOffset:L-H-A,...D&&{alignmentOffset:A}},reset:D}}}),Mi=function(h){return h===void 0&&(h={}),{name:"flip",options:h,async fn(t){var e,i;const{placement:s,middlewareData:o,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:u,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:E=!0,...m}=nt(h,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const w=j(s),y=z(a),b=j(a)===a,p=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=u||(b||!E?[xt(a)]:Ci(a)),v=g!=="none";!u&&v&&C.push(...Ii(a,E,g,p));const I=[a,...C],T=await l.detectOverflow(t,m),_=[];let R=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&_.push(T[w]),f){const L=yi(s,r,p);_.push(T[L[0]],T[L[1]])}if(R=[...R,{placement:s,overflows:_}],!_.every(L=>L<=0)){var S,O;const L=(((S=o.flip)==null?void 0:S.index)||0)+1,H=I[L];if(H&&(!(f==="alignment"?y!==z(H):!1)||R.every(k=>z(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:L,overflows:R},reset:{placement:H}};let D=(O=R.filter(A=>A.overflows[0]<=0).sort((A,k)=>A.overflows[1]-k.overflows[1])[0])==null?void 0:O.placement;if(!D)switch(x){case"bestFit":{var M;const A=(M=R.filter(k=>{if(v){const N=z(k.placement);return N===y||N==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(N=>N>0).reduce((N,It)=>N+It,0)]).sort((k,N)=>k[1]-N[1])[0])==null?void 0:M[0];A&&(D=A);break}case"initialPlacement":D=a;break}if(s!==D)return{reset:{placement:D}}}return{}}}},Ai=new Set(["left","top"]);async function Hi(h,t){const{placement:e,platform:i,elements:s}=h,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),r=j(e),a=at(e),l=z(e)==="y",c=Ai.has(r)?-1:1,d=o&&l?-1:1,f=nt(t,h);let{mainAxis:u,crossAxis:x,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(x=a==="end"?g*-1:g),l?{x:x*d,y:u*c}:{x:u*c,y:x*d}}const Di=function(h){return h===void 0&&(h=0),{name:"offset",options:h,async fn(t){var e,i;const{x:s,y:o,placement:r,middlewareData:a}=t,l=await Hi(t,h);return r===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:r}}}}},Ni=function(h){return h===void 0&&(h={}),{name:"shift",options:h,async fn(t){const{x:e,y:i,placement:s,platform:o}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:y,y:b}=w;return{x:y,y:b}}},...c}=nt(h,t),d={x:e,y:i},f=await o.detectOverflow(t,c),u=z(j(s)),x=we(u);let g=d[x],E=d[u];if(r){const w=x==="y"?"top":"left",y=x==="y"?"bottom":"right",b=g+f[w],p=g-f[y];g=Lt(b,g,p)}if(a){const w=u==="y"?"top":"left",y=u==="y"?"bottom":"right",b=E+f[w],p=E-f[y];E=Lt(b,E,p)}const m=l.fn({...t,[x]:g,[u]:E});return{...m,data:{x:m.x-e,y:m.y-i,enabled:{[x]:r,[u]:a}}}}}};function Ct(){return typeof window<"u"}function et(h){return pe(h)?(h.nodeName||"").toLowerCase():"#document"}function X(h){var t;return(h==null||(t=h.ownerDocument)==null?void 0:t.defaultView)||window}function W(h){var t;return(t=(pe(h)?h.ownerDocument:h.document)||window.document)==null?void 0:t.documentElement}function pe(h){return Ct()?h instanceof Node||h instanceof X(h).Node:!1}function Y(h){return Ct()?h instanceof Element||h instanceof X(h).Element:!1}function P(h){return Ct()?h instanceof HTMLElement||h instanceof X(h).HTMLElement:!1}function ie(h){return!Ct()||typeof ShadowRoot>"u"?!1:h instanceof ShadowRoot||h instanceof X(h).ShadowRoot}function lt(h){const{overflow:t,overflowX:e,overflowY:i,display:s}=K(h);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&s!=="inline"&&s!=="contents"}function ki(h){return/^(table|td|th)$/.test(et(h))}function bt(h){try{if(h.matches(":popover-open"))return!0}catch{}try{return h.matches(":modal")}catch{return!1}}const Bi=/transform|translate|scale|rotate|perspective|filter/,Xi=/paint|layout|strict|content/,$=h=>!!h&&h!=="none";let _t;function Kt(h){const t=Y(h)?K(h):h;return $(t.transform)||$(t.translate)||$(t.scale)||$(t.rotate)||$(t.perspective)||!Ft()&&($(t.backdropFilter)||$(t.filter))||Bi.test(t.willChange||"")||Xi.test(t.contain||"")}function Yi(h){let t=G(h);for(;P(t)&&!tt(t);){if(Kt(t))return t;if(bt(t))return null;t=G(t)}return null}function Ft(){return _t==null&&(_t=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),_t}function tt(h){return/^(html|body|#document)$/.test(et(h))}function K(h){return X(h).getComputedStyle(h)}function Rt(h){return Y(h)?{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop}:{scrollLeft:h.scrollX,scrollTop:h.scrollY}}function G(h){if(et(h)==="html")return h;const t=h.assignedSlot||h.parentNode||ie(h)&&h.host||W(h);return ie(t)?t.host:t}function ye(h){const t=G(h);return tt(t)?h.ownerDocument?h.ownerDocument.body:h.body:P(t)&&lt(t)?t:ye(t)}function ot(h,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=ye(h),o=s===((i=h.ownerDocument)==null?void 0:i.body),r=X(s);if(o){const a=At(r);return t.concat(r,r.visualViewport||[],lt(s)?s:[],a&&e?ot(a):[])}else return t.concat(s,ot(s,[],e))}function At(h){return h.parent&&Object.getPrototypeOf(h.parent)?h.frameElement:null}function Ce(h){const t=K(h);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=P(h),o=s?h.offsetWidth:e,r=s?h.offsetHeight:i,a=ut(e)!==o||ut(i)!==r;return a&&(e=o,i=r),{width:e,height:i,$:a}}function Wt(h){return Y(h)?h:h.contextElement}function J(h){const t=Wt(h);if(!P(t))return F(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=Ce(t);let r=(o?ut(e.width):e.width)/i,a=(o?ut(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}const Ki=F(0);function be(h){const t=X(h);return!Ft()||!t.visualViewport?Ki:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Fi(h,t,e){return t===void 0&&(t=!1),!e||t&&e!==X(h)?!1:t}function Z(h,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=h.getBoundingClientRect(),o=Wt(h);let r=F(1);t&&(i?Y(i)&&(r=J(i)):r=J(h));const a=Fi(o,e,i)?be(o):F(0);let l=(s.left+a.x)/r.x,c=(s.top+a.y)/r.y,d=s.width/r.x,f=s.height/r.y;if(o){const u=X(o),x=i&&Y(i)?X(i):i;let g=u,E=At(g);for(;E&&i&&x!==g;){const m=J(E),w=E.getBoundingClientRect(),y=K(E),b=w.left+(E.clientLeft+parseFloat(y.paddingLeft))*m.x,p=w.top+(E.clientTop+parseFloat(y.paddingTop))*m.y;l*=m.x,c*=m.y,d*=m.x,f*=m.y,l+=b,c+=p,g=X(E),E=At(g)}}return gt({width:d,height:f,x:l,y:c})}function vt(h,t){const e=Rt(h).scrollLeft;return t?t.left+e:Z(W(h)).left+e}function Re(h,t){const e=h.getBoundingClientRect(),i=e.left+t.scrollLeft-vt(h,e),s=e.top+t.scrollTop;return{x:i,y:s}}function Wi(h){let{elements:t,rect:e,offsetParent:i,strategy:s}=h;const o=s==="fixed",r=W(i),a=t?bt(t.floating):!1;if(i===r||a&&o)return e;let l={scrollLeft:0,scrollTop:0},c=F(1);const d=F(0),f=P(i);if((f||!f&&!o)&&((et(i)!=="body"||lt(r))&&(l=Rt(i)),f)){const x=Z(i);c=J(i),d.x=x.x+i.clientLeft,d.y=x.y+i.clientTop}const u=r&&!f&&!o?Re(r,l):F(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+d.x+u.x,y:e.y*c.y-l.scrollTop*c.y+d.y+u.y}}function Vi(h){return Array.from(h.getClientRects())}function Pi(h){const t=W(h),e=Rt(h),i=h.ownerDocument.body,s=U(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=U(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let r=-e.scrollLeft+vt(h);const a=-e.scrollTop;return K(i).direction==="rtl"&&(r+=U(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:r,y:a}}const se=25;function zi(h,t){const e=X(h),i=W(h),s=e.visualViewport;let o=i.clientWidth,r=i.clientHeight,a=0,l=0;if(s){o=s.width,r=s.height;const d=Ft();(!d||d&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}const c=vt(i);if(c<=0){const d=i.ownerDocument,f=d.body,u=getComputedStyle(f),x=d.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,g=Math.abs(i.clientWidth-f.clientWidth-x);g<=se&&(o-=g)}else c<=se&&(o+=c);return{width:o,height:r,x:a,y:l}}function Gi(h,t){const e=Z(h,!0,t==="fixed"),i=e.top+h.clientTop,s=e.left+h.clientLeft,o=P(h)?J(h):F(1),r=h.clientWidth*o.x,a=h.clientHeight*o.y,l=s*o.x,c=i*o.y;return{width:r,height:a,x:l,y:c}}function oe(h,t,e){let i;if(t==="viewport")i=zi(h,e);else if(t==="document")i=Pi(W(h));else if(Y(t))i=Gi(t,e);else{const s=be(h);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return gt(i)}function ve(h,t){const e=G(h);return e===t||!Y(e)||tt(e)?!1:K(e).position==="fixed"||ve(e,t)}function $i(h,t){const e=t.get(h);if(e)return e;let i=ot(h,[],!1).filter(a=>Y(a)&&et(a)!=="body"),s=null;const o=K(h).position==="fixed";let r=o?G(h):h;for(;Y(r)&&!tt(r);){const a=K(r),l=Kt(r);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||lt(r)&&!l&&ve(h,r))?i=i.filter(d=>d!==r):s=a,r=G(r)}return t.set(h,i),i}function Ui(h){let{element:t,boundary:e,rootBoundary:i,strategy:s}=h;const r=[...e==="clippingAncestors"?bt(t)?[]:$i(t,this._c):[].concat(e),i],a=oe(t,r[0],s);let l=a.top,c=a.right,d=a.bottom,f=a.left;for(let u=1;u<r.length;u++){const x=oe(t,r[u],s);l=U(x.top,l),c=Q(x.right,c),d=Q(x.bottom,d),f=U(x.left,f)}return{width:c-f,height:d-l,x:f,y:l}}function ji(h){const{width:t,height:e}=Ce(h);return{width:t,height:e}}function Zi(h,t,e){const i=P(t),s=W(t),o=e==="fixed",r=Z(h,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=F(0);function c(){l.x=vt(s)}if(i||!i&&!o)if((et(t)!=="body"||lt(s))&&(a=Rt(t)),i){const x=Z(t,!0,o,t);l.x=x.x+t.clientLeft,l.y=x.y+t.clientTop}else s&&c();o&&!i&&s&&c();const d=s&&!i&&!o?Re(s,a):F(0),f=r.left+a.scrollLeft-l.x-d.x,u=r.top+a.scrollTop-l.y-d.y;return{x:f,y:u,width:r.width,height:r.height}}function Tt(h){return K(h).position==="static"}function re(h,t){if(!P(h)||K(h).position==="fixed")return null;if(t)return t(h);let e=h.offsetParent;return W(h)===e&&(e=e.ownerDocument.body),e}function Ie(h,t){const e=X(h);if(bt(h))return e;if(!P(h)){let s=G(h);for(;s&&!tt(s);){if(Y(s)&&!Tt(s))return s;s=G(s)}return e}let i=re(h,t);for(;i&&ki(i)&&Tt(i);)i=re(i,t);return i&&tt(i)&&Tt(i)&&!Kt(i)?e:i||Yi(h)||e}const qi=async function(h){const t=this.getOffsetParent||Ie,e=this.getDimensions,i=await e(h.floating);return{reference:Zi(h.reference,await t(h.floating),h.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ji(h){return K(h).direction==="rtl"}const Qi={convertOffsetParentRelativeRectToViewportRelativeRect:Wi,getDocumentElement:W,getClippingRect:Ui,getOffsetParent:Ie,getElementRects:qi,getClientRects:Vi,getDimensions:ji,getScale:J,isElement:Y,isRTL:Ji};function _e(h,t){return h.x===t.x&&h.y===t.y&&h.width===t.width&&h.height===t.height}function ts(h,t){let e=null,i;const s=W(h);function o(){var a;clearTimeout(i),(a=e)==null||a.disconnect(),e=null}function r(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();const c=h.getBoundingClientRect(),{left:d,top:f,width:u,height:x}=c;if(a||t(),!u||!x)return;const g=ct(f),E=ct(s.clientWidth-(d+u)),m=ct(s.clientHeight-(f+x)),w=ct(d),b={rootMargin:-g+"px "+-E+"px "+-m+"px "+-w+"px",threshold:U(0,Q(1,l))||1};let p=!0;function C(v){const I=v[0].intersectionRatio;if(I!==l){if(!p)return r();I?r(!1,I):i=setTimeout(()=>{r(!1,1e-7)},1e3)}I===1&&!_e(c,h.getBoundingClientRect())&&r(),p=!1}try{e=new IntersectionObserver(C,{...b,root:s.ownerDocument})}catch{e=new IntersectionObserver(C,b)}e.observe(h)}return r(!0),o}function Ht(h,t,e,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=Wt(h),d=s||o?[...c?ot(c):[],...t?ot(t):[]]:[];d.forEach(w=>{s&&w.addEventListener("scroll",e,{passive:!0}),o&&w.addEventListener("resize",e)});const f=c&&a?ts(c,e):null;let u=-1,x=null;r&&(x=new ResizeObserver(w=>{let[y]=w;y&&y.target===c&&x&&t&&(x.unobserve(t),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var b;(b=x)==null||b.observe(t)})),e()}),c&&!l&&x.observe(c),t&&x.observe(t));let g,E=l?Z(h):null;l&&m();function m(){const w=Z(h);E&&!_e(E,w)&&e(),E=w,g=requestAnimationFrame(m)}return e(),()=>{var w;d.forEach(y=>{s&&y.removeEventListener("scroll",e),o&&y.removeEventListener("resize",e)}),f==null||f(),(w=x)==null||w.disconnect(),x=null,l&&cancelAnimationFrame(g)}}const mt=Di,wt=Ni,Vt=Mi,es=Li,Et=(h,t,e)=>{const i=new Map,s={platform:Qi,...e},o={...s.platform,_c:i};return Oi(h,t,{...s,platform:o})};let is=class{constructor(t){n(this,"ctx");n(this,"enable",!1);n(this,"contentEl");n(this,"floatingEl");n(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:o,CSS_PREFIX:r}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${r}-tooltip`,this.contentEl.className=`${r}-tooltip-content`,this.arrowEl.className=`${r}-tooltip-arrow`;const a={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},l={position:"absolute",width:"10px",height:"10px",background:a.background,backgroundColor:a.backgroundColor,transform:"rotate(45deg)",zIndex:a.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,a),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.floatingEl.addEventListener("mouseleave",()=>{this.hide()}),this.ctx.on("mouseout",t=>{this.floatingEl.contains(t.relatedTarget)||this.hide()}),this.ctx.on("onScroll",()=>{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()}),this.ctx.on("cellHeaderMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellHeaderHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)}),this.ctx.on("cellFooterMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellFooterHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)}),this.ctx.on("cellShowTooltip",(t,e)=>{this.show(t,e)}),this.ctx.on("cellHideTooltip",()=>{this.hide()})}show(t,e){if(this.ctx.contextMenuIng||!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let i=t.getText();t.message&&(i=t.message),e&&(i=e);const s=this.ctx.containerElement.getBoundingClientRect();if(!s)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=i;const o=this.ctx.zoomScale.getViewportRect({x:t.drawX,y:t.drawY,width:t.visibleWidth,height:t.visibleHeight},s);Et({getBoundingClientRect(){return o}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[wt(),Vt(),mt(6),es({element:this.arrowEl})]}).then(a=>{const{x:l,y:c,placement:d,middlewareData:f}=a;if(Object.assign(this.floatingEl.style,{top:`${c}px`,left:`${l}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 ss{constructor(t){n(this,"editorEl");n(this,"inputEl");n(this,"enable",!1);n(this,"cellTarget",null);n(this,"selectorArrStr","");n(this,"ctx");n(this,"drawY",0);n(this,"drawX",0);n(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,this.resetEditorStyle();const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i),this.focusInput()}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("hoverIconClick",t=>{this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell||this.ctx.finding)return;const{focusCell:e}=this.ctx;if(t.code==="Escape"&&this.ctx.editing){this.cancel=!0;const{focusCell:d}=this.ctx;d&&(this.ctx.emit("setSelectorCell",d),this.cellTarget=d),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.key==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const d=this.inputEl.selectionStart,f=this.inputEl.value.substring(0,d),u=this.inputEl.value.substring(d);this.inputEl.value=f+`
17
+ `+u,this.inputEl.selectionStart=this.inputEl.selectionEnd=d+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.key==="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.key==="Enter"&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}const i=t.key,s=t.ctrlKey,o=t.altKey,r=t.shiftKey,a=t.metaKey;if(s||o||r||a||["Enter","CapsLock","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(i))return;if(!(document.activeElement===this.inputEl)&&e.editorType==="text"){t.preventDefault();return}this.startEdit(!0)}),this.ctx.on("cellClick",t=>{if(this.ctx.stageElement.style.cursor==="pointer"||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;const{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.focusInput(),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.resetEditorStyle(),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()}})}isTextSelectionActive(){return this.ctx.config.ENABLE_TEXT_SELECTION&&(this.ctx.textSelecting||!!this.ctx.textSelectionStr)}isInSelectorRange(t,e){const{xArr:i,yArr:s}=this.ctx.selector,[o,r]=i,[a,l]=s;return!(e<o||e>r||t<a||t>l)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.id="e-virt-table-editor-textarea",this.inputEl.setAttribute("rows","1"),this.inputEl.setAttribute("tabindex","-1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),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(){if(!this.ctx.editing)return;const t=this.inputEl.value;if(this.cellTarget&&this.cellTarget.type==="number"&&t!==""&&(this.ctx.emit("cellHideTooltip"),!/^-?\d+(\.\d+)?$/.test(t))){const c=this.ctx.locale.getText("numberErrorTip");this.ctx.emit("cellShowTooltip",this.cellTarget,c)}this.inputEl.style.height="auto";let e=this.inputEl.scrollHeight;const i=this.ctx.toLogical(e);let s=this.ctx.body.visibleHeight;i>s&&(e=this.ctx.toVisual(s));const{stageHeight:o,footer:r,header:a}=this.ctx,l=o-r.height-B(this.ctx.config);this.editorEl.style.bottom="auto",this.drawY<a.height&&(this.editorEl.style.top=this.ctx.toVisualPx(a.height-1)),this.drawY+this.ctx.toLogical(e)>l&&(this.editorEl.style.left=this.ctx.toVisualPx(this.drawX-1),this.editorEl.style.top="auto",this.editorEl.style.bottom=this.ctx.toVisualPx(o-l)),this.inputEl.style.height=`${e}px`}startEditByInput(t,e=!1){const i=e?null:t.getValue(),{editorType:s}=t;if(s==="none")return;t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:o,width:r,drawY:a,drawX:l}=t;this.drawX=l,this.drawY=a;const{config:{CELL_PADDING:c},header:d}=this.ctx;let f=this.ctx.body.visibleHeight;o>f&&(o=f);const u=this.ctx.toVisual(f);this.editorEl.style.zIndex="100",this.editorEl.style.left=this.ctx.toVisualPx(this.drawX-1),this.editorEl.style.top=this.ctx.toVisualPx(this.drawY),this.editorEl.style.bottom="auto",this.editorEl.style.maxWidth="none",this.editorEl.style.border="",this.editorEl.style.maxHeight=`${u}px`,["text"].includes(s)?(this.inputEl.style.opacity="1",this.inputEl.style.position="relative",this.inputEl.style.minWidth=this.ctx.toVisualPx(r-1),this.inputEl.style.minHeight=this.ctx.toVisualPx(o-1),this.inputEl.style.maxHeight=`${u}px`,this.inputEl.style.width=this.ctx.toVisualPx(r),this.inputEl.style.height="auto",this.inputEl.style.padding=this.ctx.toVisualPx(c),this.inputEl.value="",i!==null&&(this.inputEl.value=i),(this.ctx.toLogical(this.inputEl.scrollHeight)>o||this.drawY<d.height)&&this.autoSize()):(this.inputEl.style.opacity="0",this.inputEl.style.width="1px",this.inputEl.style.height="1px",this.inputEl.style.position="absolute",this.inputEl.style.left="0px",this.inputEl.style.top="0px")}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)}}focusInput(){document.activeElement!==this.inputEl&&this.inputEl.focus({preventScroll:!0})}startEdit(t=!1){if(this.isTextSelectionActive())return;this.cancel=!1;const{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;const i=this.ctx.focusCell;if(!i)return;i.isVerticalVisible()&&i.isHorizontalVisible()||this.ctx.emit("scrollToIndex",i.rowIndex,i.colIndex),this.editCell(i.rowIndex,i.colIndex,t)}editCell(t,e,i=!1){const s=this.ctx.body.renderRows.find(f=>f.rowIndex===t);if(!s)return;const o=s.cells.find(f=>f.colIndex===e);if(!o||!(o.isVerticalVisible()&&o.isHorizontalVisible()))return;this.ctx.emit("setSelectorCell",o);const a=this.ctx.focusCell;if(!a||["index","index-selection","selection"].includes(a.type)||this.enable)return;const{rowKey:l,key:c}=a,d=this.ctx.database.getReadonly(l,c);a&&!d&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=a,this.startEditByInput(this.cellTarget,i),this.ctx.emit("startEdit",this.cellTarget),this.ctx.emit("draw"))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("cellHideTooltip"),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.resetEditorStyle(),setTimeout(()=>{this.focusInput()},0),this.ctx.emit("draw"))}resetEditorStyle(){const t=this.cellTarget;t&&(this.editorEl.style.left=this.ctx.toVisualPx(t.drawX),this.editorEl.style.top=this.ctx.toVisualPx(t.drawY),this.editorEl.style.maxWidth="1px",this.editorEl.style.maxHeight="1px",this.editorEl.style.zIndex="-1",this.editorEl.style.border="none")}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.inputEl.blur(),this.ctx.emit("draw")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}let os=class{constructor(t){n(this,"ctx");n(this,"emptyEl");this.ctx=t;const{EMPTY_CUSTOM_STYLE:e}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=this.getText()),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:i,headerHeight:s,bodyHeight:o,footerHeight:r})=>{const a=s+(o+r)/2,l={display:i==="empty"?"block":"none",top:this.ctx.toVisualPx(a),...e};Object.assign(this.emptyEl.style,l)})}getText(){return this.ctx.config.EMPTY_TEXT||this.ctx.locale.getText("emptyText")}draw(){this.ctx.emptyElement||(this.emptyEl.innerText=this.getText())}destroy(){this.emptyEl.remove()}};class rs{constructor(t){n(this,"ctx");n(this,"observer");this.ctx=t,this.init()}arerMapsEqual(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t)if(!e.has(i)||e.get(i)!==s)return!1;return!0}init(){this.observer=new MutationObserver(Nt(()=>{const t=this.ctx.overlayerElement.querySelectorAll('[data-auto-height="true"]'),e=new Map;t.forEach(o=>{const r=Number(o.getAttribute("data-row-index")),a=Number(o.getAttribute("data-col-index"));if(isNaN(r)||isNaN(a))return;const l=o.getBoundingClientRect(),c=`${r}​_${a}`;e.set(c,this.ctx.zoomScale.domHeightToLogical(l.height))});const i=this.ctx.database.getOverlayerAutoHeightMap();if(!this.arerMapsEqual(i,e)){if(this.ctx.database.setOverlayerAutoHeightMap(e),i.size===0&&e.size===0)return;this.ctx.emit("draw")}},16.67)),this.observer.observe(this.ctx.overlayerElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.ctx.overlayerElement.getAttribute("data-overlayer")==="default"&&this.ctx.on("overlayerChange",t=>{const e=this.ctx.overlayerElement;e.replaceChildren(),Object.assign(e.style,t.style),t.views.forEach(i=>{const s=document.createElement("div");s.className=i.class,this.ctx.zoomScale.assignScaledStyle(s,i.style),i.views.forEach(o=>{const r=document.createElement("div");this.ctx.zoomScale.assignScaledStyle(r,o.style),o.cells.forEach(a=>{const l=this.ctx.zoomScale.createOverlayerCellElement(a,this.ctx.config.CSS_PREFIX);r.appendChild(l)}),s.appendChild(r)}),e.appendChild(s)})})}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.observer&&this.observer.disconnect(),this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[];const{FOOTER_FIXED:o,FOOTER_POSITION:r}=this.ctx.config;return o?r==="top"?s=[t,i,e]:s=[t,e,i]:s=[t,e],{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{CSS_PREFIX:i}}=this.ctx,s=B(this.ctx.config),{visibleWidth:o,visibleHeight:r,renderCellHeaders:a}=this.ctx.header;let l=[],c=[],d=[];a.forEach(m=>{m.render&&(m.fixed==="left"?c.push(m):m.fixed==="right"?d.push(m):l.push(m))});const f=e-s,u={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${r}px`},cells:c},x={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-f+1}px`,height:`${r}px`},cells:l},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f+1}px`,height:`${r}px`},cells:d};return{type:"header",class:`${i}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${o}px`,height:`${r}px`},views:[u,x,g]}}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(m=>{m.cells.forEach(w=>{w.cellType==="footer"&&(w.render=w.renderFooter),w.render&&(w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:o,fixedRightWidth:r,config:{CSS_PREFIX:a}}=this.ctx,l=B(this.ctx.config),{visibleWidth:c,visibleHeight:d}=this.ctx.body,f=r-l,u={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${d}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o-.5}px`,overflow:"hidden",width:`${c-o-f}px`,height:`${d}px`},cells:t},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${a}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${c}px`,height:`${d}px`},views:[u,x,g]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(E=>{E.cells.forEach(m=>{m.cellType==="footer"&&m.renderFooter&&(m.render=m.renderFooter,m.fixed==="left"?e.push(m):m.fixed==="right"?i.push(m):t.push(m))})});const{fixedLeftWidth:s,fixedRightWidth:o,config:{CSS_PREFIX:r}}=this.ctx,a=B(this.ctx.config),{visibleWidth:l,visibleHeight:c}=this.ctx.footer,d=o-a,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:`${l-s-d}px`,height:`${c}px`},cells:t},x={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:`${r}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${c}px`},views:[f,u,x]}}}class ne{constructor(t,e=[],i={}){n(this,"container");n(this,"menuData");n(this,"onClick");n(this,"activeSubmenus",new Set);n(this,"boundMouseEnterHandler");n(this,"boundMouseLeaveHandler");n(this,"boundClickHandler");this.container=t,this.menuData=e,this.onClick=i.onClick,this.boundMouseEnterHandler=s=>this.handleMouseEvent(s,"enter"),this.boundMouseLeaveHandler=s=>this.handleMouseEvent(s,"leave"),this.boundClickHandler=s=>this.handleClick(s),this.createMenu(),this.bindEvents()}createMenu(){this.container.className="e-virt-table-main-menu",this.container.style.display="block";const t=document.createDocumentFragment();this.menuData.forEach(e=>{t.appendChild(this.createMenuItem(e))}),this.container.appendChild(t)}createMenuItem(t,e=!1){var r;const i=this.createElement("div",e?"e-virt-table-submenu-item":"e-virt-table-menu-item");i.setAttribute(e?"data-submenu":"data-menu",t.value),t.disabled&&i.classList.add("disabled");const s=this.createElement("div","e-virt-table-menu-item-content");if(t.icon){const a=this.createElement("span","e-virt-table-menu-item-icon");a.innerHTML=t.icon,s.appendChild(a)}else s.classList.add("menu-item-no-icon");const o=this.createElement("span","e-virt-table-menu-item-text");if(o.textContent=t.label||"",s.appendChild(o),i.appendChild(s),(r=t.children)!=null&&r.length){const a=this.createElement("span","e-virt-table-menu-arrow");a.innerHTML=ft,i.appendChild(a);const l=this.createSubmenu(t.children);i._submenu=l,this.container.appendChild(l)}return i}createSubmenu(t){const e=this.createElement("div","e-virt-table-submenu");return t.forEach(i=>{e.appendChild(this.createMenuItem(i,!0))}),e}createElement(t,e=""){const i=document.createElement(t);return e&&(i.className=e),i}bindEvents(){this.container.addEventListener("mouseenter",this.boundMouseEnterHandler,!0),this.container.addEventListener("mouseleave",this.boundMouseLeaveHandler,!0),this.container.addEventListener("click",this.boundClickHandler)}handleMouseEvent(t,e){t.stopPropagation();const s=t.target.closest(".e-virt-table-menu-item, .e-virt-table-submenu-item");s&&(this.container.contains(s)||s.classList.contains("e-virt-table-submenu-item"))&&(e==="enter"?this.handleHover(s):this.handleLeave(s))}handleHover(t){t.classList.contains("e-virt-table-menu-item")&&(this.container.querySelectorAll(".e-virt-table-menu-item").forEach(i=>i.classList.remove("active")),t.classList.contains("disabled")||t.classList.add("active"));const e=t._submenu||t.querySelector(".e-virt-table-submenu");e&&(this.hideSiblingSubmenus(t),this.showSubmenu(t,e))}handleLeave(t){const e=t._submenu||t.querySelector(".e-virt-table-submenu");setTimeout(()=>{const i=e;i&&!i.matches(":hover")&&!t.matches(":hover")&&(this.hideSubmenu(i),t.classList.contains("e-virt-table-menu-item")&&t.classList.remove("active"))},150)}hideSiblingSubmenus(t){let e;if(t.classList.contains("e-virt-table-menu-item"))e=this.container.querySelectorAll(".e-virt-table-menu-item");else{const i=t.closest(".e-virt-table-submenu");if(i)e=i.querySelectorAll(".e-virt-table-submenu-item");else return}e.forEach(i=>{i!==t&&i._submenu&&this.hideSubmenu(i._submenu)})}async showSubmenu(t,e){if(this.activeSubmenus.has(e))return;this.activeSubmenus.add(e),e.classList.add("show");const i=Ht(t,e,async()=>{const s=this.container.getBoundingClientRect(),o=window.innerWidth,r=e.offsetWidth||200,a=o-s.right,l=s.left,c=a>=r||a>=l?"right-start":"left-start",{x:d,y:f}=await Et(t,e,{placement:c,middleware:[mt(8),wt({padding:8})]});Object.assign(e.style,{left:`${d}px`,top:`${f}px`})});e._cleanup=i}hideSubmenu(t){if(!this.activeSubmenus.has(t))return;this.activeSubmenus.delete(t),t.classList.remove("show"),this.hideAllChildSubmenus(t);const e=t;e._cleanup&&(e._cleanup(),delete e._cleanup)}hideAllChildSubmenus(t){t.querySelectorAll(".e-virt-table-submenu-item").forEach(i=>{if(i._submenu){const s=i._submenu;if(this.activeSubmenus.has(s)){this.activeSubmenus.delete(s),s.classList.remove("show");const o=s;o._cleanup&&(o._cleanup(),delete o._cleanup),this.hideAllChildSubmenus(s)}}})}handleClick(t){t.stopPropagation();const e=t.target.closest(".e-virt-table-menu-item, .e-virt-table-submenu-item");if(!e||e.classList.contains("disabled"))return;if(e.classList.contains("e-virt-table-menu-item")){const o=e._submenu||e.querySelector(".e-virt-table-submenu");if(o){this.showSubmenu(e,o);return}}const i=e.getAttribute("data-menu")||(e==null?void 0:e.getAttribute("data-submenu")),s=this.findMenuItem(i||"");s&&this.onClick&&this.onClick(s,i||"")}findMenuItem(t,e=this.menuData){for(const i of e){if(i.value===t)return i;if(i.children){const s=this.findMenuItem(t,i.children);if(s)return s}}return null}positionMenu(t){const e={getBoundingClientRect:()=>({width:0,height:0,top:t.clientY,left:t.clientX,right:t.clientX,bottom:t.clientY,x:t.clientX,y:t.clientY}),contextElement:document.body};Ht(e,this.container,()=>{Et(e,this.container,{placement:"right-start",middleware:[mt(),wt(),Vt()]}).then(({x:i,y:s})=>{this.container&&Object.assign(this.container.style,{left:`${i}px`,top:`${s}px`})})})}destroy(){this.container.removeEventListener("mouseenter",this.boundMouseEnterHandler,!0),this.container.removeEventListener("mouseleave",this.boundMouseLeaveHandler,!0),this.container.removeEventListener("click",this.boundClickHandler),this.cleanupAllSubmenus(this.container),this.container.style.display="none",this.container.replaceChildren()}removeMenuItem(t){const e=this.container.querySelector(`[data-menu="${t}"]`);if(!e)return!1;const i=e.querySelector(".e-virt-table-submenu");return i&&this.cleanupSubmenuRecursively(i),e.remove(),!0}removeSubMenuItem(t){const e=this.container.querySelector(`[data-submenu="${t}"]`);if(!e)return!1;const i=e.closest(".e-virt-table-submenu"),s=e._submenu;if(s&&this.cleanupSubmenuRecursively(s),e.remove(),i&&i.querySelectorAll(".e-virt-table-submenu-item").length===0){const r=this.container.querySelector("[data-menu]");if(r&&r._submenu===i)this.removeMenuItem(r.getAttribute("data-menu")||"");else{const a=this.container.querySelectorAll("[data-menu], [data-submenu]");for(const l of a)if(l._submenu===i){const c=l.getAttribute("data-menu")||l.getAttribute("data-submenu");c&&(l.hasAttribute("data-menu")?this.removeMenuItem(c):this.removeSubMenuItem(c));break}}}return!0}cleanupAllSubmenus(t){t.querySelectorAll(".e-virt-table-menu-item").forEach(i=>{i._submenu&&(this.cleanupSubmenuRecursively(i._submenu),i._submenu=void 0)})}cleanupSubmenuRecursively(t){const e=t;e._cleanup&&(e._cleanup(),delete e._cleanup),t.querySelectorAll(".e-virt-table-submenu-item").forEach(s=>{s._submenu&&this.cleanupSubmenuRecursively(s._submenu)}),t.remove()}}class ns{constructor(t){n(this,"ctx");n(this,"contextMenuEl");n(this,"currentDOMTreeMenu");n(this,"isCustom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.contextMenuEl=this.ctx.contextMenuElement,this.contextMenuEl.className="e-virt-table-main-menu",this.isCustom=!0):(this.contextMenuEl=document.createElement("div"),this.isCustom=!1),this.ctx.containerElement.appendChild(this.contextMenuEl),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.hide()}),this.ctx.on("cellContextMenuClick",async(t,e)=>{if(this.isCustom){this.contextMenuEl.style.display="block",this.positionMenu(e);return}const{ENABLE_CONTEXT_MENU:i,CUSTOM_BODY_CONTEXT_MENU:s,CONTEXT_MENU:o,BEFORE_BODY_CONTEXT_MENU_METHOD:r}=this.ctx.config;let a=o.map(w=>({...w,label:w.label||this.ctx.locale.getText(w.value)}));if(a=[...a,...s],r&&(a=await r({list:a,cell:t,hide:this.hide.bind(this)})),!i||a.length===0)return;e.preventDefault();const{xArr:l,yArr:c}=this.ctx.selector,[d,f]=l,[u,x]=c,{rowIndex:g,colIndex:E}=t;g>=u&&g<=x&&E>=d&&E<=f||this.ctx.emit("setSelectorCell",t,e),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy(),this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new ne(this.contextMenuEl,a,{onClick:(w,y)=>{y==="copy"?(this.ctx.emit("contextMenuCopy"),this.hide()):y==="paste"?(this.ctx.emit("contextMenuPaste"),this.hide()):y==="cut"?(this.ctx.emit("contextMenuCut"),this.hide()):y==="clearSelected"?(this.ctx.emit("contextMenuClearSelected"),this.hide()):w.event&&w.event(e,{hide:this.hide.bind(this),cell:t})}}),this.currentDOMTreeMenu.positionMenu(e)}),this.ctx.on("cellHeaderContextMenuClick",async(t,e)=>{if(this.isCustom){this.contextMenuEl.style.display="block",this.positionMenu(e);return}const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:o,BEFORE_HEADER_CONTEXT_MENU_METHOD:r}=this.ctx.config,a=i,l=s||this.ctx.maxColIndex-o;if(t.colIndex<a||t.colIndex>l)return;const{HEADER_CONTEXT_MENU:c,CUSTOM_HEADER_CONTEXT_MENU:d,ENABLE_HEADER_CONTEXT_MENU:f}=this.ctx.config;let u=c.map(p=>({...p,label:p.label||this.ctx.locale.getText(p.value)}));if(u=[...u,...d],r&&(u=await r({list:u,cell:t,hide:this.hide.bind(this)})),!f||u.length===0)return;e.preventDefault();const{xArr:x}=this.ctx.selector,[g,E]=x,{colIndex:m}=t;m>=g&&m<=E||(this.ctx.focusCellHeader=t,this.ctx.emit("selectCols",t)),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy();const y=this.ctx.database.getColumns(),b=u.map(p=>p.value==="visible"?{...p,children:this.filterColumns(y)}:p);this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new ne(this.contextMenuEl,b,{onClick:(p,C)=>{const{xArr:v}=this.ctx.selector,[I,T]=v;if(C==="fixedLeft"||C==="fixedRight"||C==="fixedNone"){const _=this.ctx.header.allCellHeaders.filter(R=>R.colIndex>=I&&R.colIndex<=T).filter(R=>R.level===0).filter(R=>!R.column.fixedDisabled).map(R=>R.key);this.ctx.database.setCustomHeaderFixedData(_,C==="fixedLeft"?"left":C==="fixedRight"?"right":""),this.hide()}else if(C==="hide"){const _=this.ctx.header.leafCellHeaders.filter(R=>R.colIndex>=I&&R.colIndex<=T).filter(R=>!R.children.length).filter(R=>!R.column.hideDisabled).map(R=>R.key);_.length>0&&this.ctx.database.setCustomHeaderHideData(_,!0),this.hide()}else if(C!=="visible")if(C.startsWith("visible_")){if(!p.key)return;if(p.children){const O=this.getLeafKeys(p.children);this.ctx.database.setCustomHeaderHideData(O,!1)}else this.ctx.database.setCustomHeaderHideData([p.key],!1);this.currentDOMTreeMenu&&this.currentDOMTreeMenu.removeSubMenuItem(C);const _=this.ctx.database.getColumns();st(_).filter(O=>O.hide).length===0&&this.hide()}else C==="resetHeader"?(this.ctx.database.resetCustomHeader(),this.hide()):p.event&&p.event(e,{hide:this.hide.bind(this),cell:t})}}),this.positionMenu(e)}),this.ctx.on("click",()=>{this.hide()}),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}positionMenu(t){const e={getBoundingClientRect:()=>({width:0,height:0,top:t.clientY,left:t.clientX,right:t.clientX,bottom:t.clientY,x:t.clientX,y:t.clientY}),contextElement:document.body};Ht(e,this.contextMenuEl,()=>{Et(e,this.contextMenuEl,{placement:"right-start",middleware:[mt(),wt(),Vt()]}).then(({x:i,y:s})=>{this.contextMenuEl&&Object.assign(this.contextMenuEl.style,{left:`${i}px`,top:`${s}px`})})})}filterColumns(t){const e=[];for(const i of t)if(i.children&&i.children.length>0){const s=this.filterColumns(i.children);s.length>0&&e.push({label:i.title,key:i.key,value:`visible_${i.key}`,children:s})}else i.hide&&e.push({label:i.title,value:`visible_${i.key}`,key:i.key});return e}getLeafKeys(t){return t.reduce((e,i)=>(!i.children||i.children.length===0?e.push(String(i.key)):e.push(...this.getLeafKeys(i.children)),e),[])}hide(){this.currentDOMTreeMenu&&(this.currentDOMTreeMenu.destroy(),this.currentDOMTreeMenu=void 0),this.contextMenuEl.style.display="none",this.ctx.contextMenuIng=!1}destroy(){var t;this.hide(),(t=this.contextMenuEl)==null||t.remove()}}class as{constructor(t){n(this,"ctx");n(this,"loadingEl");n(this,"textEl",document.createElement("p"));if(this.ctx=t,this.ctx.loadingElement)this.loadingEl=this.ctx.loadingElement;else{this.loadingEl=document.createElement("div");const e=document.createElement("div");e.className="e-virt-table-loading-spinner";const i=this.ctx.icons.getSvg("loading");if(i){const r=new DOMParser().parseFromString(i.svg,"image/svg+xml").documentElement;e.appendChild(r)}this.textEl.className="e-virt-table-loading-text",this.textEl.innerText=this.getText(),e.appendChild(this.textEl),this.loadingEl.appendChild(e)}this.loadingEl.className="e-virt-table-loading",this.loadingEl.style.display="none",this.ctx.containerElement.appendChild(this.loadingEl)}getText(){return this.ctx.config.LOADING_TEXT||this.ctx.locale.getText("loadingText")}show(){this.loadingEl.style.display="flex"}hide(){this.loadingEl.style.display="none"}draw(){this.ctx.loadingElement||(this.textEl.innerText=this.getText())}destroy(){this.loadingEl.remove()}}class ls{constructor(t){n(this,"ctx");n(this,"container");n(this,"input");n(this,"prevBtn");n(this,"nextBtn");n(this,"closeBtn");n(this,"countEl");n(this,"loadingEl");n(this,"isVisible",!1);n(this,"searchResults",[]);n(this,"currentIndex",-1);n(this,"searchData",[]);n(this,"isComposing",!1);this.ctx=t,this.container=this.createContainer(),this.ctx.containerElement.appendChild(this.container),this.bindEvents(),this.ctx.on("keydown",e=>{if(this.ctx.config.ENABLE_FINDER&&!this.ctx.editing){if((e.ctrlKey||e.metaKey)&&e.code==="KeyF"){e.preventDefault(),this.show();return}if(this.ctx.finding){if(e.code==="Escape"){e.preventDefault(),this.hide();return}if(e.code==="ArrowUp"||e.shiftKey&&e.key==="Enter"){e.preventDefault(),this.navigatePrevious();return}if(e.code==="ArrowDown"||e.key==="Enter"){e.preventDefault(),this.navigateNext();return}}}}),this.ctx.on("setSelector",()=>{this.hide()}),this.ctx.on("outsideMousedown",()=>{this.hide()})}async initSearchData(){this.showLoading(),this.searchData=[],setTimeout(()=>{const{allCellHeaders:t}=this.ctx.header;for(let s=0;s<t.length;s++){const o=t[s];o&&["string","number"].includes(typeof o.text)&&this.searchData.push({rowIndex:0,colIndex:o.colIndex,text:`${o.text}`,type:"header",colKey:o.key})}const{maxColIndex:e,maxRowIndex:i}=this.ctx;for(let s=0;s<=i;s++)for(let o=0;o<=e;o++){const r=this.ctx.database.getVirtualBodyCell(s,o,!1),a=r==null?void 0:r.getText();["string","number"].includes(typeof a)&&this.searchData.push({rowIndex:s,colIndex:o,text:`${a}`,type:"body"})}this.hideLoading()},0)}createContainer(){const t=document.createElement("div");t.className="e-virt-table-finder-bar";const e=document.createElement("div");e.className="e-virt-table-finder-bar-input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="e-virt-table-finder-bar-input",this.input.placeholder="",e.appendChild(this.input),this.loadingEl=document.createElement("div"),this.loadingEl.className="e-virt-table-finder-bar-loading";const i=xe;this.loadingEl.innerHTML=i,e.appendChild(this.loadingEl),this.countEl=document.createElement("span"),this.countEl.className="e-virt-table-finder-bar-count";const s=document.createElement("div");return s.className="e-virt-table-finder-bar-nav",this.prevBtn=document.createElement("button"),this.prevBtn.className="e-virt-table-finder-bar-nav-btn prev-btn",this.prevBtn.innerHTML=ft,this.nextBtn=document.createElement("button"),this.nextBtn.className="e-virt-table-finder-bar-nav-btn next-btn",this.nextBtn.innerHTML=ft,s.appendChild(this.prevBtn),s.appendChild(this.nextBtn),this.closeBtn=document.createElement("button"),this.closeBtn.className="e-virt-table-finder-bar-nav-btn close-btn",this.closeBtn.innerHTML="×",t.appendChild(e),t.appendChild(this.countEl),t.appendChild(s),t.appendChild(this.closeBtn),t}bindEvents(){this.input.addEventListener("input",()=>{this.isComposing||this.performSearch()}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,this.performSearch()}),this.prevBtn.addEventListener("click",()=>{this.navigatePrevious()}),this.nextBtn.addEventListener("click",()=>{this.navigateNext()}),this.closeBtn.addEventListener("click",()=>{this.hide()})}performSearch(){const t=this.input.value.trim();if(this.searchResults=[],this.currentIndex=-1,!t){this.cearFinderBar(),this.updateCount();return}this.showLoading(),setTimeout(()=>{this.searchResults=this.searchData.filter(e=>e.text.toLowerCase().includes(t.toLowerCase())),this.searchResults.length>0?(this.currentIndex=0,this.scrollToCurrentResult()):this.cearFinderBar(),this.updateCount(),this.hideLoading()},0)}scrollToCurrentResult(){if(this.currentIndex<0||this.currentIndex>=this.searchResults.length)return;const t=this.searchResults[this.currentIndex];this.ctx.finderBar=t;const{rowIndex:e,colIndex:i}=t;this.ctx.emit("scrollToIndex",e,i)}navigateNext(){this.searchResults.length!==0&&(this.currentIndex=(this.currentIndex+1)%this.searchResults.length,this.scrollToCurrentResult(),this.updateCount())}navigatePrevious(){this.searchResults.length!==0&&(this.currentIndex=this.currentIndex<=0?this.searchResults.length-1:this.currentIndex-1,this.scrollToCurrentResult(),this.updateCount())}updateCount(){if(this.searchResults.length===0)this.input.value.trim()?(this.countEl.textContent="0/0",this.countEl.classList.add("no-results")):(this.countEl.textContent="",this.countEl.classList.remove("no-results"));else{const t=this.currentIndex+1,e=this.searchResults.length;this.countEl.textContent=`${t}/${e}`,this.countEl.classList.remove("no-results")}}show(){this.isVisible||(this.isVisible=!0,this.ctx.finding=!0,this.container.classList.add("show"),this.input.focus(),this.initSearchData())}showLoading(){var t;this.loadingEl.classList.add("show"),(t=this.loadingEl.parentElement)==null||t.classList.add("loading"),this.input.readOnly=!0}hideLoading(){var t;this.loadingEl.classList.remove("show"),(t=this.loadingEl.parentElement)==null||t.classList.remove("loading"),this.input.readOnly=!1}cearFinderBar(){this.ctx.finderBar={rowIndex:-1,colIndex:-1,text:"",type:"header"},this.ctx.emit("draw")}hide(){this.isVisible&&(this.isVisible=!1,this.container.classList.remove("show"),this.ctx.finding=!1,this.input.value="",this.searchResults=[],this.searchData=[],this.currentIndex=-1,this.hideLoading(),this.ctx.finderBar={rowIndex:-1,colIndex:-1,text:"",type:"header"},this.updateCount(),this.ctx.emit("draw"))}destroy(){this.hide(),this.container.remove()}}const it=class it{constructor(t){n(this,"ctx");n(this,"layouts",new Map);n(this,"activeCellKey","");n(this,"selectionStart",null);n(this,"selectionEnd",null);n(this,"pending",null);this.ctx=t,this.ctx.on("registerTextLayout",(e,i)=>this.layouts.set(e,i)),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("cellHeaderHoverChange",e=>this.yieldToColumnDrag(e)),this.ctx.on("cellHoverChange",()=>this.yieldToColumnDrag()),this.ctx.on("keydown",e=>this.onCopyKeydown(e)),this.ctx.on("outsideMousedown",()=>this.resetSelection())}get canSelect(){return this.ctx.config.ENABLE_TEXT_SELECTION&&!this.ctx.editing&&!this.ctx.finding}yieldToColumnDrag(t){const e=this.ctx.focusCellHeader;if(!(!this.ctx.textSelecting||!e)){if(t){const i=e.colIndex,s=e.colIndex+e.colspan-1,o=t.colIndex,r=t.colIndex+t.colspan-1;if(o>=i&&r<=s)return}this.resetSelection()}}onMouseDown(t){if(!this.canSelect||!this.ctx.isTarget(t))return;this.ctx.containerElement.contains(document.activeElement)||this.ctx.containerElement.focus({preventScroll:!0});const e=this.hitTest(t);if(!e){this.resetSelection();return}const{offsetX:i,offsetY:s}=this.ctx.getOffset(t);this.pending={cellKey:e.cellKey,index:e.index,startX:i,startY:s}}onMouseMove(t){if(!this.canSelect||(this.ctx.textSelecting||this.tryStartDrag(t),!this.ctx.textSelecting))return;const e=this.layouts.get(this.activeCellKey);if(!e)return;const{offsetX:i,offsetY:s}=this.ctx.getOffset(t),o=this.hitTestText(e,i,s);o!==null&&(this.selectionEnd=o,this.updateSelection())}tryStartDrag(t){if(!this.pending||!this.ctx.mousedown)return;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t),s=Math.abs(e-this.pending.startX),o=Math.abs(i-this.pending.startY);if(s<it.DRAG_THRESHOLD&&o<it.DRAG_THRESHOLD)return;const r=this.hitTest(t);if(!r||r.cellKey!==this.pending.cellKey){this.pending=null;return}this.activeCellKey=this.pending.cellKey,this.selectionStart=this.pending.index,this.selectionEnd=r.index,this.pending=null,this.ctx.textSelecting=!0,this.updateSelection()}onMouseUp(){this.pending=null,this.ctx.textSelecting=!1,this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.textSelectionStr&&this.ctx.emit("drawView")}onCopyKeydown(t){var i;if(!this.canSelect||!((t.ctrlKey||t.metaKey)&&t.code==="KeyC"))return;const e=this.getSelectedText();e&&(t.preventDefault(),(i=navigator.clipboard)==null||i.writeText(e).catch(s=>console.error("Copy Failure:",s)))}hitTest(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s=null;for(const[o,r]of this.layouts){const a=this.hitTestText(r,e,i);a!==null&&(s={cellKey:o,index:a})}return s}updateSelection(){this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.emit("drawView")}hitTestText(t,e,i){const{glyphs:s,contentY:o,lineHeight:r,lines:a}=t;if(!s.length)return null;const l=Math.floor((i-o)/r);if(l<0||l>=a.length)return null;const c=s.filter(g=>g.line===l);if(!c.length)return null;const d=2,f=o+l*r;if(i<f-d||i>=f+r+d)return null;const u=c[0],x=c[c.length-1];if(e<u.x-d||e>x.x+x.width+d)return null;if(e<=u.x)return u.index;for(const g of c)if(e<g.x+g.width/2)return g.index;return x.index+1}clearLayouts(){this.layouts.clear()}draw(){if(!this.ctx.config.ENABLE_TEXT_SELECTION)return;const t=this.getSelectionRange(),e=t&&this.layouts.get(this.activeCellKey);e&&this.drawTextSelection(e,t)}drawTextSelection(t,e,i="#fff",s="#3b82f6"){if(e.start>=e.end)return;const o=new Map;for(const a of t.glyphs){if(a.index<e.start||a.index>=e.end)continue;const l=o.get(a.line)??[];l.push(a),o.set(a.line,l)}if(!o.size)return;const r=this.ctx.paint.getCtx();r.save(),r.font=t.font,r.textBaseline="top",r.textAlign="left",o.forEach(a=>{const l=a[0],c=a[a.length-1];r.fillStyle=s,r.fillRect(l.x,l.y-1,c.x+c.width-l.x,l.height),r.fillStyle=i;for(const d of a)r.fillText(d.char,d.x,d.y)}),r.restore()}getSelectionRange(){return this.selectionStart===null||this.selectionEnd===null?null:{start:Math.min(this.selectionStart,this.selectionEnd),end:Math.max(this.selectionStart,this.selectionEnd)}}getSelectedText(){const t=this.getSelectionRange(),e=t&&this.layouts.get(this.activeCellKey);return!e||t.start>=t.end?"":e.chars.slice(t.start,t.end).join("")}resetSelection(){this.activeCellKey="",this.selectionStart=null,this.selectionEnd=null,this.pending=null,this.ctx.textSelecting=!1,this.ctx.textSelectionStr="",this.ctx.emit("drawView")}destroy(){this.layouts.clear(),this.resetSelection()}};n(it,"DRAG_THRESHOLD",4);let Dt=it;const yt=class yt{constructor(t,e){n(this,"options");n(this,"scroller");n(this,"header");n(this,"body");n(this,"footer");n(this,"selector");n(this,"autofill");n(this,"tooltip");n(this,"editor");n(this,"empty");n(this,"overlayer");n(this,"contextMenu");n(this,"loading");n(this,"finderBar");n(this,"textSelector");n(this,"animationFrameId");n(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:o,contextMenuElement:r}=this.options,a=this.createContainer(t,i,s,o,r);this.ctx=new di(a,this.options),this.textSelector=new Dt(this.ctx),this.header=new xi(this.ctx),this.footer=new mi(this.ctx),this.body=new gi(this.ctx),this.scroller=new fi(this.ctx),this.selector=new wi(this.ctx),this.autofill=new Ei(this.ctx),this.tooltip=new is(this.ctx),this.empty=new os(this.ctx),this.editor=new ss(this.ctx),this.overlayer=new rs(this.ctx),this.contextMenu=new ns(this.ctx),this.loading=new as(this.ctx),this.finderBar=new ls(this.ctx),this.ctx.on("loadData",l=>{this.loadData(l)}),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}static useLocale(t){yt.locale=t}createContainer(t,e,i,s,o){t.className="e-virt-table-container";const r=document.createElement("div"),a=document.createElement("canvas"),l=e||document.createElement("div");r.className="e-virt-table-stage",t.tabIndex=0,a.className="e-virt-table-canvas",l.className="e-virt-table-overlayer",l.setAttribute("data-overlayer",e?"custom":"default");const c=i||document.createElement("div");c.className="e-virt-table-editor";const d=s,f=o;return r.appendChild(a),r.appendChild(l),t.appendChild(r),{containerElement:t,stageElement:r,canvasElement:a,overlayerElement:l,editorElement:c,emptyElement:d,contextMenuElement:f}}doDraw(t=!1){this.updateStageBorder(),this.header.update(),this.body.update(),this.footer.update(),this.ctx.paint.clear(),this.textSelector.clearLayouts(),this.body.draw(),this.footer.draw(),this.header.draw(),this.textSelector.draw(),this.body.drawDragRowTip(),this.scroller.draw(),this.empty.draw(),this.loading.draw(),t||this.overlayer.draw()}updateStageBorder(){const{BORDER:t,BORDER_COLOR:e,BORDER_RADIUS:i}=this.ctx.config;this.ctx.stageElement.dataset.borderStyle=rt(t),this.ctx.stageElement.style.borderColor=ze(t)?e:"transparent",this.ctx.stageElement.style.borderRadius=`${i}px`}draw(t=!1){this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=requestAnimationFrame(()=>{this.doDraw(t),this.body.updateAutoHeight()&&this.doDraw(t)})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(!1),this.header.init(),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.tooltip.hide(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setCustomHeader(t,e=!0){this.ctx.database.setCustomHeader(t,e),this.header.init(),this.ctx.emit("draw")}getCustomHeader(){return this.header.getCustomHeader()}showColumns(t,e=!0){this.ctx.database.setCustomHeaderHideData(t,!e),this.header.init(),this.ctx.emit("draw")}fixedColumns(t,e){this.ctx.database.setCustomHeaderFixedData(t,e),this.header.init(),this.ctx.emit("draw")}setLoading(t){this.ctx.loading=t,t?this.loading.show():this.loading.hide()}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.ctx.database.setFilterMethod(t),this.ctx.database.init(!1),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,o=!0,r=!1){this.ctx.database.setItemValue(t,e,i,s,o,r)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,o=!0){this.ctx.setItemValueByEditor(t,e,i,s,o),this.editor.doneEdit()}clearEditableData(t=null){const e=[0,this.ctx.maxColIndex],i=[0,this.ctx.maxRowIndex];return this.selector.clearSelectedData(e,i,!1,t)}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit("draw")}setZoom(t){this.ctx.setZoom(t)}getZoom(){return this.ctx.getZoom()}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 o=[];for(let r=0;r<t.length;r++){const{rowKey:a,key:l}=t[r],c=await this.ctx.database.getValidator(a,l);Array.isArray(c)&&c.length&&o.push(c)}if(o.length){if(s(o),e){const[r]=o;if(Array.isArray(r)&&r.length){const[a]=r,{rowKey:l,key:c}=a;this.scrollToRowkey(l),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[o]=s;if(Array.isArray(o)&&o.length){const[r]=o,{rowKey:a,key:l}=r,c=this.ctx.database.getRowForRowKey(a);if(c){const{parentRowKeys:d=[]}=c;d&&d.length&&this.setExpandRowKeys(d,!0)}this.scrollToRowkey(a),this.scrollToColkey(l)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:o,rowKey:r}=e;if(i!==void 0&&r===void 0){const a=this.ctx.database.getRowKeyForRowIndex(i);this.ctx.database.setValidationErrorByRowKey(a,s,o)}r&&this.ctx.database.setValidationErrorByRowKey(r,s,o)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowKey)this.scrollToRowkey(e.rowKey),this.scrollToColkey(e.key);else if(e&&e.rowIndex!==void 0&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return this.ctx.config.DISABLED?new Promise(t=>{t([])}):new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let o=[];for(let r=0;r<i.length;r++)for(let a=0;a<s.length;a++){const l=this.ctx.database.getRowKeyByItem(i[r]),d=s[a].key,f=await this.ctx.database.getValidator(l,d);Array.isArray(f)&&f.length&&o.push(f)}o.length?(e(o),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)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:Ne,mergeRowCell:De,getSpanArrByRow:ce,getSpanObjByColumn:he}}getColumnByKey(t){var e;return(e=this.ctx.database.getColumnByKey(t))==null?void 0:e.column}clearChangeData(){this.ctx.database.clearChangeData(),this.ctx.emit("draw")}getReadonly(t,e){return this.ctx.database.getReadonly(t,e)}useLocale(t){this.ctx.locale.use(t)}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.loading.destroy(),this.finderBar.destroy(),this.textSelector.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}};n(yt,"locale");let pt=yt;module.exports=pt;
18
18
  //# sourceMappingURL=index.cjs.js.map