@vue-ui-kit/ant 2.5.2 → 2.5.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.
- package/dist/ant.css +2 -0
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.js +1571 -1441
- package/dist/style.css +57 -0
- package/dist/style.scss +2 -0
- package/package.json +1 -1
- package/src/packages/components/PCanvasGrid.vue +142 -78
- package/src/packages/components/PCanvasTable.vue +12 -1
- package/src/packages/styles/canvas-theme.scss +57 -0
- package/src/packages/styles/index.scss +2 -0
- package/src/packages/utils/canvasTableTheme.ts +111 -0
package/dist/ant.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
:root{--evt-border-color:var(--p-border-color,#d9d9d9);--evt-header-bg-color:var(--p-table-thead-bg-color,#f2f3f6);--evt-body-bg-color:var(--p-table-row-bg-color,#fff);--evt-stripe-color:var(--p-striped-bg-color,#f2f3f6);--evt-highlight-hover-row-color:var(--p-table-row-hover-bg-color,#e6e7ea);--evt-select-border-color:var(--p-primary-color,#4096ff);--evt-sort-icon-color:var(--p-primary-color,#4096ff);--evt-required-color:var(--p-danger-color,#f5222d);--evt-error-tip-color:var(--p-danger-color,#f5222d);--evt-error-tip-icon-color:var(--p-danger-color,#f5222d);--evt-readonly-color:var(--p-table-row-bg-color,#fff);--evt-scroller-track-color:var(--p-table-row-bg-color,#fff);--evt-header-text-color:#1d2129;--evt-body-text-color:#4e5969;--evt-footer-text-color:#4e5969;--evt-readonly-text-color:#4e5969;--evt-scroller-color:#dee0e3;--evt-scroller-focus-color:#bbbec4;--evt-edit-bg-color:#fcf6ed;--evt-footer-bg-color:#fafafa;--evt-autofill-point-border-color:#fff;--evt-editor-bg-color:#fff;--evt-editor-text-color:#333;--evt-context-menu-bg-color:#fff;--evt-context-menu-text-color:#333;--evt-context-menu-item-hover-bg-color:#f5f5f5}html[theme-mode=dark],:root[data-theme=dark],:root.dark{--evt-header-text-color:#a3a6ad;--evt-body-text-color:#cfd3dc;--evt-footer-text-color:#cfd3dc;--evt-readonly-text-color:#a3a6ad;--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:#a3a6ad;--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-bg-color:#414243}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,4 +14,4 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
14
14
|
`,color:`#4E5969`},{name:`icon-select`,configName:`ICON_SELECT_SVG`,configColorName:`ICON_SELECT_COLOR`,svg:P,color:`#4E5969`},{name:`sort-asc`,configName:`SORT_ASC_ICON_SVG`,configColorName:`SORT_ICON_COLOR`,svg:te,color:`rgb(82,146,247)`},{name:`sort-desc`,configName:`SORT_DESC_ICON_SVG`,configColorName:`SORT_ICON_COLOR`,svg:I,color:`rgb(82,146,247)`},{name:`sort-default`,configName:`SORTABLE_ICON_SVG`,svg:F,color:`#bec4c7`},{name:`drag`,configName:`DRAG_ROW_ICON_SVG`,svg:`<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>
|
|
15
15
|
`,color:`#4E5969`}]),n(this,`icons`,new Map),this.ctx=e,this.init()}async init(){let e=[];for(let t=0;t<this.list.length;t++){let n=this.list[t],r=n.color,i=n.svg;if(n.configColorName){let e=this.ctx.config[n.configColorName];e&&(r=e)}if(n.configName){let e=this.ctx.config[n.configName];e&&(i=e)}let a=this.createImageFromSVG(i,r).then(e=>{this.icons.set(n.name,e)});e.push(a)}for(let t=0;t<this.ctx.config.ICONS.length;t++){let n=this.ctx.config.ICONS[t],r=n.color,i=this.createImageFromSVG(n.svg,r,n.isBlob).then(e=>{this.icons.set(n.name,e)});e.push(i)}await Promise.all(e),this.ctx.emit(`draw`)}async createImageFromSVG(e,t,n=!1){let r=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement;t&&r.querySelectorAll(`*`).forEach(e=>{let n=e.getAttribute(`fill`);(n===`currentColor`||n===null)&&e.setAttribute(`fill`,t)});let i=new Image,a=``;if(n){let e=new Blob([new XMLSerializer().serializeToString(r)],{type:`image/svg+xml`});a=URL.createObjectURL(e)}else a=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(new XMLSerializer().serializeToString(r));return i.src=a,new Promise((t,n)=>{i.onerror=()=>n(Error(`Failed to load image:`+e)),i.onload=()=>{t(i)}})}get(e){return this.icons.get(e)}getSvg(e){return this.list.find(t=>t.name===e)}}class re{constructor(e){n(this,`ctx`),n(this,`visibleHoverCell`),n(this,`resizeObserver`),n(this,`mutationObserver`),this.ctx=e,this.init()}init(){this.resizeObserver=new ResizeObserver(e=>{this.ctx.emit(`resetHeader`),this.ctx.emit(`resizeObserver`,e),this.ctx.emit(`containerResize`,this.ctx.containerElement)}),this.resizeObserver.observe(this.ctx.containerElement),this.mutationObserver=new MutationObserver(e=>{for(let t of e)t.type===`attributes`&&t.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`,e=>{if(this.isBusy(e))return;let{offsetY:t,offsetX:n}=this.ctx.getOffset(e),r=t,i=n;this.isInsideBody(i,r)||this.ctx.emit(`mousedownBodyOutside`,e),e.button===0&&(this.handleHeaderEvent(i,r,this.ctx.header.renderCellHeaders,t=>{this.ctx.focusCellHeader=t,this.ctx.focusCell=void 0,this.ctx.emit(`cellHeaderMousedown`,t,e)}),this.handleBodyEvent(i,r,this.ctx.body.renderRows,t=>{this.ctx.setFocusCell(t),this.ctx.focusCellHeader=void 0,this.ctx.emit(`cellMousedown`,t,e)},!0))}),this.ctx.on(`mouseup`,e=>{if(e.button!==0||this.isBusy(e))return;let{offsetY:t,offsetX:n}=this.ctx.getOffset(e),r=t,i=n;this.handleHeaderEvent(i,r,this.ctx.header.renderCellHeaders,t=>{this.ctx.emit(`cellHeaderMouseup`,t,e)}),this.handleBodyEvent(i,r,this.ctx.body.renderRows,t=>{this.ctx.emit(`cellMouseup`,t,e)})}),this.ctx.on(`click`,e=>{if(e.button!==0||this.isBusy(e))return;let t=this.ctx.getOffset(e).offsetY,n=this.ctx.getOffset(e).offsetX;this.handleHeaderEvent(n,t,this.ctx.header.renderCellHeaders,t=>{this.ctx.clickCellHeader=t,this.ctx.emit(`cellHeaderClick`,t,e)}),this.handleBodyEvent(n,t,this.ctx.body.renderRows,r=>{this.ctx.clickCell=r,this.ctx.emit(`cellClick`,r,e);let i=r.getImage(`hover`);!this.ctx.disableHoverIconClick&&i&&i.isInside(n,t)&&this.ctx.emit(`hoverIconClick`,r)},!0)}),this.ctx.on(`dblclick`,e=>{if(e.button!==0||this.isBusy(e))return;let t=this.ctx.getOffset(e).offsetY,n=this.ctx.getOffset(e).offsetX;this.handleHeaderEvent(n,t,this.ctx.header.renderCellHeaders,t=>{this.ctx.emit(`cellHeaderDblclick`,t,e)}),this.handleBodyEvent(n,t,this.ctx.body.renderRows,t=>{this.ctx.clickCell=t,this.ctx.emit(`cellDblclick`,t,e)})}),this.ctx.on(`contextMenu`,e=>{if(this.isBusy(e))return;let{offsetY:t,offsetX:n}=this.ctx.getOffset(e),r=t,i=n;this.handleHeaderEvent(i,r,this.ctx.header.renderCellHeaders,t=>{this.ctx.emit(`cellHeaderContextMenuClick`,t,e)}),this.handleBodyEvent(i,r,this.ctx.body.renderRows,t=>{this.ctx.emit(`cellContextMenuClick`,t,e)})}),this.ctx.on(`mouseout`,e=>{!this.ctx.containerElement.contains(e.relatedTarget)&&this.ctx.hoverCell!==void 0&&(this.ctx.hoverRow=void 0,this.ctx.hoverCell=void 0,this.ctx.emit(`draw`))}),this.ctx.on(`mousemove`,e=>{if(this.isBusy(e))return;!this.ctx.mousedown&&this.ctx.stageElement.style.cursor!=="default"&&(this.ctx.stageElement.style.cursor=`default`);let t=this.ctx.getOffset(e).offsetY,n=this.ctx.getOffset(e).offsetX;this.handleHeaderEvent(n,t,this.ctx.header.renderCellHeaders,t=>{this.imageEnterAndLeave(t,e),this.ctx.emit(`cellHeaderMouseenter`,t,e),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==t&&this.ctx.emit(`cellHeaderMouseleave`,this.ctx.hoverCellHeader,e),this.ctx.hoverCellHeader!==t&&(this.ctx.hoverCellHeader=t,this.visibleHoverCell=void 0,this.ctx.emit(`cellHeaderHoverChange`,t,e))}),this.handleBodyEvent(n,t,this.ctx.body.renderRows,t=>{this.imageEnterAndLeave(t,e),this.visibleHoverCell!==t&&(this.ctx.emit(`visibleCellMouseleave`,t,e),this.visibleHoverCell=t,this.ctx.hoverCellHeader=void 0,this.ctx.emit(`visibleCellHoverChange`,t,e))},!0),this.handleBodyEvent(n,t,this.ctx.body.renderRows,t=>{this.ctx.emit(`cellMouseenter`,t,e),this.ctx.hoverCell&&this.ctx.hoverCell!==t&&this.ctx.emit(`cellMouseleave`,t,e),this.ctx.hoverCell!==t&&(this.ctx.hoverCell?.rowKey!==t.rowKey&&(this.ctx.hoverCell=t,this.ctx.hoverRow=this.ctx.body.renderRows.find(e=>e.rowKey===t.rowKey),this.ctx.emit(`rowHoverChange`,this.ctx.hoverRow,t,e),this.ctx.emit(`draw`)),this.ctx.hoverCell=t,this.ctx.emit(`cellHoverChange`,t,e))}),this.handleFooterEvent(n,t,this.ctx.footer.renderRows,t=>{this.ctx.emit(`cellFooterMouseenter`,t,e),this.ctx.hoverCell&&this.ctx.hoverCell!==t&&this.ctx.emit(`cellFooterMouseleave`,t,e),this.ctx.emit(`cellFooterHoverChange`,t,e)})})}imageEnterAndLeave(e,t){if(this.ctx.dragRowIng||this.ctx.dragHeaderIng||this.ctx.selectColsIng||this.ctx.selectRowsIng||this.ctx.selectorMove||this.ctx.autofillMove)return;let{offsetY:n,offsetX:r}=this.ctx.getOffset(t),i=n,a=r;e.cellImages.forEach((e,t)=>{e.isInside(a,i)&&(t===`drag`?this.ctx.stageElement.style.cursor=`grab`:this.ctx.stageElement.style.cursor=`pointer`)})}isBusy(e){let{offsetY:t,offsetX:n}=this.ctx.getOffset(e),r=t,i=n;if(this.ctx.loading||!this.ctx.isTarget(e)||this.ctx.stageElement.style.cursor===`row-resize`||this.ctx.stageElement.style.cursor===`col-resize`||this.ctx.columnResizing||this.ctx.rowResizing)return!0;let{SCROLLER_TRACK_SIZE:a}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||r>this.ctx.stageHeight-a||i>this.ctx.stageWidth-a)}handleBodyEvent(e,t,n,r,i=!1){if(this.isInsideBody(e,t))for(let a of n){let n=a.fixedCells.concat(a.noFixedCells);for(let a of n)if(i?a.isInsideVisible(e,t):a.isInside(e,t)){r(a);return}}}handleHeaderEvent(e,t,n,r){for(let i of n)if(i.isInside(e,t)){r(i);return}}handleFooterEvent(e,t,n,r){for(let i of n){let n=i.fixedCells.concat(i.noFixedCells);for(let i of n)if(i.isInside(e,t)){r(i);return}}}isInsideBody(e,t){let{body:{y:n,visibleHeight:r,height:i,visibleWidth:a}}=this.ctx;return e>0&&e<a&&t>n&&t<n+Math.min(i,r)}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}let ie={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 ae{constructor(){n(this,`langConfig`)}use(e){this.langConfig=e}getText(e,t){let n={...ie};Object.assign(n,an.locale,this.langConfig);let r=n[e];return r?r.replace(/{(\w+)}/g,(e,n)=>t?.[n]||e):``}}let oe=/^-?\d*\.?\d+px$/;class L{constructor(){n(this,`value`,1)}get isDefault(){return this.value===1}clamp(e,t,n){return Math.min(n,Math.max(t,e))}set(e,t,n){let r=this.clamp(e,t,n);return Math.abs(r-this.value)<1e-4?!1:(this.value=r,!0)}toVisual(e){return e*this.value}toLogical(e){return e/this.value}toPx(e){return`${this.toVisual(e)}px`}domHeightToLogical(e){return Math.round(e/this.value)}contentToPhysical(e){return e*this.value}scaleStyle(e){if(this.isDefault)return e;let t={...e};for(let e of Object.keys(t)){let n=t[e];typeof n==`string`&&oe.test(n)&&(t[e]=`${parseFloat(n)*this.value}px`)}return t}assignScaledStyle(e,t){Object.assign(e.style,this.scaleStyle(t))}containerWidth(e){return Math.floor(e/this.value)}resolveStageWidth(e){let t=this.containerWidth(e.containerPhysicalWidth),n=e.fillContainer?t:Math.min(Math.floor(e.contentWidth+e.scrollerTrackSize),t);return{stageWidth:n,stagePhysicalWidth:Math.min(Math.round(this.toVisual(n)),Math.floor(e.containerPhysicalWidth))}}applyStageHeight(e,t){let n=Math.floor(t),r=Math.floor(n/this.value);return e.style.height=`${n}px`,{stageHeight:r,stagePhysicalHeight:n}}getViewportRect(e,t){let n=this.toVisual(e.x)+t.x,r=this.toVisual(e.y)+t.y,i=this.toVisual(e.width),a=this.toVisual(e.height);return{x:n,y:r,left:n,top:r,right:n+i,bottom:r+a,width:i,height:a}}createOverlayerCellElement(e,t){let n=document.createElement(`div`);if(this.assignScaledStyle(n,e.style),Object.keys(e.domDataset||{}).forEach(t=>{n.setAttribute(t,e.domDataset[t])}),typeof e.render!=`function`)return n;if(this.isDefault)return e.render(n,e),n;let r=`visibleWidth`in e?e.visibleWidth:e.width,i=`visibleHeight`in e?e.visibleHeight:e.height,a=`autoRowHeight`in e&&e.autoRowHeight&&`renderType`in e&&e.renderType==="default",o=document.createElement(`div`);return o.className=`${t}-overlayer-cell-content`,o.style.width=`${r}px`,o.style.boxSizing=`border-box`,a?(o.style.height=`auto`,o.style.minHeight=`${i}px`,n.style.height=`auto`):(o.style.height=`${i}px`,n.style.height=this.toPx(i)),o.style.zoom=String(this.value),n.style.width=this.toPx(r),n.appendChild(o),e.render(o,e),n}}class se{constructor(e,t){n(this,`eventBus`),n(this,`eventBrowser`),n(this,`eventTable`),n(this,`locale`,new ae),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`);let{containerElement:r,stageElement:i,canvasElement:a,overlayerElement:o,editorElement:s,emptyElement:c,loadingElement:l,contextMenuElement:u}=e;this.containerElement=r,i.tabIndex=0,this.stageElement=i,this.canvasElement=a,this.overlayerElement=o,this.editorElement=s,this.emptyElement=c,this.loadingElement=l,this.contextMenuElement=u,this.config=new M(t.config||{}),this.eventBus=new A,this.eventBrowser=new k(this),this.eventTable=new re(this),this.paint=new j(this.canvasElement),this.database=new D(this,t),this.history=new O(this),this.icons=new ne(this),this.zoomScale=new L}get zoom(){return this.zoomScale.value}setConfig(e){this.config=new M(e)}setItemValueByEditor(e,t,n,r=!0,i=!0,a=!0){if(this.config.ENABLE_MERGE_CELL_LINK){let i=this.database.getVirtualBodyCellByKey(e,t);if(i&&(i.mergeRow||i.mergeCol)){let{dataList:e}=i.getSpanInfo(),t=e.map(e=>({...e,value:n}));this.database.batchSetItemValue(t,r,a);return}}this.database.setItemValue(e,t,n,r,i,!0,a)}batchSetItemValueByEditor(e,t=!0,n=!0){if(this.config.ENABLE_MERGE_CELL_LINK){let r=[];e.forEach(e=>{let t=this.database.getRowIndexForRowKey(e.rowKey),n=this.database.getColIndexForKey(e.key);if(t===void 0||n===void 0)return;let i=this.database.getVirtualBodyCell(t,n);if(i){let{dataList:t}=i.getSpanInfo(),n=t.map(t=>({...t,value:e.value}));r.push(...n)}}),this.database.batchSetItemValue(r,t,n)}else this.database.batchSetItemValue(e,t,n)}setFocusCell(e){if(this.focusCell!==e){if(this.focusCell?.rowKey!==e.rowKey){this.currentCell=e,this.emit(`rowFocusChange`,e);let t={rowIndex:e.rowIndex,rowKey:e.rowKey,row:e.row};this.emit(`currentRowChange`,t)}this.focusCell=e,this.emit(`cellFocusChange`,e)}}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(){let e=[],t=this.selector.yArr,n=this.selector.xArr,r=``;for(let i=0;i<=t[1]-t[0];i++){let a=[];for(let e=0;e<=n[1]-n[0];e++){let r=i+t[0],o=e+n[0],s=this.database.getVirtualBodyCell(r,o);s&&(s.selectorCellValueType===`displayText`?a.push(s.displayText):a.push(s.getValue()))}r+=`${a.join(` `)}\r`,e.push(a)}return r=r?r.replace(/\r$/,``):` `,{xArr:n,yArr:t,text:r,value:e}}setScroll(e,t){let n=Math.floor(e),r=this.body.width-this.body.visibleWidth;n<0?n=0:n>r&&(n=r);let i=Math.floor(t),a=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(a=this.body.height+this.footer.height-this.body.visibleHeight),i<0?i=0:i>a&&(i=a),this.emit(`setScroll`,n,i)}setScrollX(e){let t=Math.floor(e),n=this.body.width-this.body.visibleWidth;t<0?t=0:t>n&&(t=n),this.emit(`setScrollX`,t)}setScrollY(e){let t=Math.floor(e),n=0;this.config.FOOTER_FIXED||(n=this.footer.height);let r=this.body.height-this.body.visibleHeight+n;t<0?t=0:t>r&&(t=r),this.emit(`setScrollY`,t)}startAdjustPosition(e){this.emit(`startAdjustPosition`,e)}stopAdjustPosition(){this.emit(`stopAdjustPosition`)}isTarget(e){return!!this.containerElement.contains(e.target)}getOffset(e){let{left:t,top:n}=this.containerElement.getBoundingClientRect();return{offsetX:this.zoomScale.toLogical(e.clientX-t),offsetY:this.zoomScale.toLogical(e.clientY-n)}}toVisual(e){return this.zoomScale.toVisual(e)}toLogical(e){return this.zoomScale.toLogical(e)}toVisualPx(e){return this.zoomScale.toPx(e)}scaleStyle(e){return this.zoomScale.scaleStyle(e)}setZoom(e){let{MIN_ZOOM:t,MAX_ZOOM:n}=this.config;this.zoomScale.set(e,t,n)&&(this.emit(`zoomChange`,this.zoomScale.value),this.emit(`resetHeader`))}getZoom(){return this.zoomScale.value}hasEvent(e){return this.eventBus.has(e)}on(e,t){this.eventBus.on(e,t)}once(e,t){this.eventBus.once(e,t)}off(e,t){this.eventBus.off(e,t)}emit(e,...t){this.eventBus.emit(e,...t)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class ce{constructor(e,t){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,`clientX`,0),n(this,`clientY`,0),n(this,`dragStart`,0),n(this,`isDragging`,!1),n(this,`scroll`,0),this.ctx=e,this.type=t,this.type===`vertical`?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(e){this.updateScroll(e)}onTouchmove(e){let{clientY:t,clientX:n}=e.touches[0],r=this.ctx.zoomScale.toLogical(t-this.clientY),i=this.ctx.zoomScale.toLogical(n-this.clientX),a=0;this.type===`vertical`?(a=Math.max(0,Math.min(this.dragStart-r,this.distance)),this.hasScrollbar()&&!(a===0&&r>0||a===this.distance&&r<0)&&e.preventDefault()):this.type===`horizontal`&&(a=Math.max(0,Math.min(this.dragStart-i,this.distance))),this.scroll=a}onTouchstart(e){let{clientY:t,clientX:n}=e.touches[0];this.clientX=n,this.clientY=t,this.dragStart=this.scroll}onMouseDown(e){if(!(e.target instanceof Element)||!this.ctx.isTarget(e))return;if(this.ctx.stageElement.style.cursor===`row-resize`||this.ctx.stageElement.style.cursor===`col-resize`)return!0;let{clientX:t,clientY:n}=e,r=this.ctx.zoomScale.toLogical(e.offsetX),i=this.ctx.zoomScale.toLogical(e.offsetY);if(!(t==this.clientX&&n==this.clientY)){if(this.isOnScrollbar(r,i))this.clientX=t,this.clientY=n,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,e.preventDefault();else if(this.isOnTrack(r,i)){let e=0;e=this.type===`vertical`?(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:(r-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(e,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(e){let{clientX:t,clientY:n,buttons:r}=e,i=this.ctx.zoomScale.toLogical(e.offsetX),a=this.ctx.zoomScale.toLogical(e.offsetY);if(this.isOnScrollbar(i,a)&&e.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,r===0||t==this.clientX&&n==this.clientY)return;let o=0;if(o=this.type===`horizontal`?t-this.clientX:n-this.clientY,o=this.ctx.zoomScale.toLogical(o),this.isDragging&&o!==0){let e=0;e=this.type===`vertical`?this.dragStart+o/(this.visibleDistance-this.barHeight)*this.distance:this.dragStart+o/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(e,this.distance))}}isPointInElement(e,t,n,r,i,a){return e>=n&&e<=n+i&&t>=r&&t<=r+a}hasScrollbar(){return this.type===`vertical`?this.barHeight>0:this.type===`horizontal`?this.barWidth>0:!1}isOnScrollbar(e,t){return this.isPointInElement(e,t,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(e,t){return this.isPointInElement(e,t,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(e){let t=e.deltaX,n=e.deltaY;this.type===`vertical`&&e.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&n<0||this.scroll===this.distance&&n>0)&&e.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+n,this.distance))):this.type===`horizontal`&&(e.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+n,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+t,this.distance)))}updatedSize(){let{body:e,header:t,stageHeight:n,stageWidth:r,config:{SCROLLER_TRACK_SIZE:i=0,SCROLLER_SIZE:a=0,BORDER:o}}=this.ctx,s=r,c=n,l=t.height,u=t.width,d=e.height,f=this.ctx.footer.height;if(this.type===`vertical`){this.visibleDistance=c-i-l,this.distance=d-this.visibleDistance+f,this.trackX=s-i,this.trackY=0,this.splitPoints=[this.trackX,l,this.trackX+i,l],this.trackWidth=i,this.trackHeight=c,this.barX=this.trackX-1+(i-a)/2,this.barWidth=a;let e=this.distance?this.visibleDistance/(d+f):0,t=Math.floor(e*this.visibleDistance);t<30?t=30:t>this.visibleDistance&&(t=0),this.barHeight=t,this.barY=l+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=s-i,this.distance=u-this.visibleDistance,this.splitPoints=[s-i,c-i,s-i,c];let e=o?0:.5;this.trackX=0,this.trackY=c-i+e,this.trackWidth=s,this.trackHeight=i;let t=this.distance?this.visibleDistance/u:0,n=Math.floor(t*this.visibleDistance);this.barY=this.trackY-1+(i-a)/2,n<30?n=30:n>=this.visibleDistance&&(n=0),this.barWidth=n,this.barHeight=a,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){let{config:{SCROLLER_FOCUS_COLOR:e,SCROLLER_COLOR:t,BORDER_COLOR:n,BORDER:r,SCROLLER_TRACK_COLOR:i}}=this.ctx;this.updatedSize();let a=n;r||(a=`transparent`),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:a,fillColor:i}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?e:t,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:a,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class le{constructor(e){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=e,this.verticalScrollbar=new ce(e,`vertical`),this.horizontalScrollbar=new ce(e,`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,t)=>{this.setScroll(e,t)}),this.ctx.on(`setScrollX`,e=>{this.setScrollX(e)}),this.ctx.on(`setScrollY`,e=>{this.setScrollY(e)}),this.ctx.on(`scrollToIndex`,(e,t)=>{this.scrollToIndex(e,t)}),this.ctx.on(`cellHeaderMousedown`,()=>{this.mousedownHeader=!0}),this.ctx.on(`startAdjustPosition`,e=>{this.startAdjustPosition(e)}),this.ctx.on(`stopAdjustPosition`,()=>{this.stopAdjustPosition()})}onWheel(e){this.verticalScrollbar.onWheel(e),this.horizontalScrollbar.onWheel(e),this.draw()}onTouchmove(e){this.verticalScrollbar.onTouchmove(e),this.horizontalScrollbar.onTouchmove(e),this.draw()}onTouchstart(e){this.verticalScrollbar.onTouchstart(e),this.horizontalScrollbar.onTouchstart(e),this.draw()}onMouseDown(e){this.verticalScrollbar.onMouseDown(e),this.horizontalScrollbar.onMouseDown(e),this.draw()}onMouseMove(e){this.verticalScrollbar.onMouseMove(e),this.horizontalScrollbar.onMouseMove(e),this.draw()}onMouseUp(){this.mousedownHeader=!1,this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();let e=Math.floor(this.horizontalScrollbar.scroll),t=Math.floor(this.verticalScrollbar.scroll);(e!==this.ctx.scrollX||t!==this.ctx.scrollY)&&(this.ctx.emit(`onScroll`,e,t),e!==this.ctx.scrollX&&this.ctx.emit(`onScrollX`,e),t!==this.ctx.scrollY&&this.ctx.emit(`onScrollY`,t),this.ctx.scrollX=e,this.ctx.scrollY=t,this.ctx.emit(`draw`))}setScroll(e,t){this.horizontalScrollbar.scroll=e,this.verticalScrollbar.scroll=t,this.ctx.emit(`draw`),this.ctx.emit(`onScroll`,e,t)}setScrollX(e){this.horizontalScrollbar.scroll=e,this.ctx.emit(`draw`)}setScrollY(e){this.verticalScrollbar.scroll=e,this.ctx.emit(`draw`)}scrollToColkey(e){let{header:t}=this.ctx,n=t.leafCellHeaders.find(t=>t.key===e);n&&this.setScrollX(n.x-t.visibleWidth/2)}scrollToColIndex(e){let{header:t}=this.ctx,n=t.leafCellHeaders.find(t=>t.colIndex===e);n&&this.setScrollX(n.x-t.visibleWidth/2)}scrollToRowIndex(e){let{body:t,database:n}=this.ctx,{top:r}=n.getPositionForRowIndex(e);this.setScrollY(r-t.visibleHeight/2)}scrollToIndex(e,t){this.scrollToRowIndex(e),this.scrollToColIndex(t)}scrollToRowKey(e){let{body:t,database:n}=this.ctx,r=n.getRowIndexForRowKey(e);if(r===void 0)return;let{top:i}=n.getPositionForRowIndex(r);this.setScrollY(i-t.visibleHeight/2)}startAdjustPosition(e){let{offsetX:t,offsetY:n}=this.ctx.getOffset(e),r=``,i=``;if(this.ctx.focusCell?.fixed!==`left`&&t<this.ctx.fixedLeftWidth?r=`left`:this.ctx.focusCell?.fixed!==`right`&&t>this.ctx.body.visibleWidth-this.ctx.fixedRightWidth?r=`right`:(r=``,this.stopAdjustPosition(!0,!1)),!this.mousedownHeader&&n<this.ctx.header.visibleHeight?i=`top`:n>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight?i=`bottom`:(i=``,this.stopAdjustPosition(!1,!0)),r&&this.adjustPositionX!==r){this.adjustPositionX=r;let e=10*(r===`left`?-1:1);this.timerX&&=(clearInterval(this.timerX),0),this.timerX=setInterval(()=>{e*=1.5;let{scrollX:t}=this.ctx,n=t+e;(n<0||n>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(n)},100)}if(i&&this.adjustPositionY!==i){this.adjustPositionY=i;let e=10*(i===`top`?-1:1);this.timerY&&=(clearInterval(this.timerY),0),this.timerY=setInterval(()=>{e*=1.5;let{scrollY:t}=this.ctx,n=t+e;(n<0||n>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(n)},100)}}stopAdjustPosition(e=!0,t=!0){e&&(this.adjustPositionX=``,this.timerX&&=(clearInterval(this.timerX),0)),t&&(this.adjustPositionY=``,this.timerY&&=(clearInterval(this.timerY),0))}}class ue extends w{constructor(e,t,r,a,o,s,c){super(e,r,a,o,s,`header`,c.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=r,this.y=a,this.width=o,this.height=s,this.visibleWidth=o,this.visibleHeight=s,this.colIndex=t,this.key=c.key,this.minWidth=c.minWidth,this.maxWidth=c.maxWidth,this.hide=(typeof c.hide==`function`?c.hide(c):c.hide)||!1,this.type=c.type||``,this.editorType=c.editorType||`text`,this.hideHeaderSelection=c.hideHeaderSelection||!1,this.align=c.headerAlign||c.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=c.headerVerticalAlign||c.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=c.fixed||``,this.level=c.level||0,this.operation=c.operation||!1,this.text=c.title,this.column=c,this.colspan=c.colspan||1,this.widthFillDisable=c.widthFillDisable||!1,this.rowspan=c.rowspan||1,this.rules=c.rules,this.readonly=c.readonly||!1,this.required=c.required||!1,this.sortIconName=c.sortIconName||`sort-default`,this.sortAscIconName=c.sortAscIconName||`sort-asc`,this.sortDescIconName=c.sortDescIconName||`sort-desc`,this.rowKey=i(),this.overflowTooltipShow=c.overflowTooltipHeaderShow!==!1,this.hasChildren=c.children&&c.children.length>0||!1,this.render=c.renderHeader,this.maxLineClampHeader=c.maxLineClampHeader||`auto`,this.renderHeaderType=c.renderHeaderType||`default`}isVerticalVisible(){let{stageHeight:e}=this.ctx,t=e;return!(this.y+this.height<=0||this.y>=t)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){let{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:t,HEADER_TEXT_COLOR:n}=this.ctx.config,r=t,i=n;if(typeof e==`function`){let{backgroundColor:t,color:n,font:a}=e({colIndex:this.colIndex,column:this.column})||{};t&&(r=t),n&&(i=n),a&&(this.drawTextFont=a)}let{colKey:a,type:o}=this.ctx.finderBar;o===`header`&&a===this.key&&(r=this.ctx.config.FINDER_CELL_BG_COLOR),this.drawCellBgColor=r,this.drawTextColor=i}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(){let{paint:e,config:{BORDER_COLOR:t,BORDER:n}}=this.ctx;e.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:n?t:`transparent`,fillColor:this.drawCellBgColor})}drawText(){let{paint:e,config:{HEADER_FONT:t,CELL_PADDING:n}}=this.ctx,r=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`;this.ellipsis=e.drawText(this.displayText,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||t,padding:n,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign,maxLineClamp:this.maxLineClampHeader,offsetRight:this.textOffsetRight,offsetLeft:this.textOffsetLeft,cacheTextKey:r,textCallback:e=>{this.textInfo=e},layoutCallback:e=>{this.ctx.emit(`registerTextLayout`,`${this.cellType}-${this.colIndex}-${this.level}`,e)}})}drawRequired(){if(!this.required||!this.textInfo)return;let{left:e,top:t,height:n}=this.textInfo,{paint:r,config:{REQUIRED_COLOR:i}}=this.ctx;r.drawText(`*`,e-18,t+(n-12)/2,24,24,{color:i,font:`18px Arial`,align:`center`,verticalAlign:`middle`,padding:0})}drawBg(){if(this.ctx.dragHeaderIng)return;let{ENABLE_SELECTOR:e,ENABLE_SELECTOR_SINGLE:t}=this.ctx.config,n=-1,r=-1;if(this.ctx.focusCellHeader&&(n=this.ctx.focusCellHeader.colIndex,r=this.ctx.focusCellHeader.colIndex+this.ctx.focusCellHeader.colspan-1),e&&!t){let{xArr:e}=this.ctx.selector;n=e[0],r=e[1]}let i=this.colspan+this.colIndex-1;this.colIndex>=n&&this.colIndex<=r&&i<=r&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:`transparent`,fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||`transparent`})}updateSelection(){if([`index-selection`,`selection`,`selection-tree`,`tree-selection`].includes(this.type)){let{indeterminate:e,check:t,selectable:n}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:r=0,CELL_PADDING:i}=this.ctx.config,a=this.drawX+(this.width-r)/2,o=this.drawY+(this.height-r)/2;this.drawTextX=a+r-i/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX,(this.align===`left`||this.align===`right`)&&(a=this.drawX+i,this.drawTextX=a+r-i/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX),this.verticalAlign===`top`?o=this.drawY+i/2:this.verticalAlign===`bottom`&&(o=this.drawY+this.height-r-i/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 s=this.ctx.icons.get(`checkbox-uncheck`),c=`checkbox-uncheck`;e?(s=this.ctx.icons.get(`checkbox-indeterminate`),c=`checkbox-indeterminate`):t&&n?(s=this.ctx.icons.get(`checkbox-check`),c=`checkbox-check`):t&&!n?(s=this.ctx.icons.get(`checkbox-check-disabled`),c=`checkbox-check-disabled`):!t&&n?(s=this.ctx.icons.get(`checkbox-uncheck`),c=`checkbox-uncheck`):(s=this.ctx.icons.get(`checkbox-disabled`),c=`checkbox-disabled`);let l=new T(c,a,o,r,r,s);l.setVisible(!this.hideHeaderSelection),this.setImage(`selection`,l)}}updateSortIcon(){if(!this.column.sortBy||!this.textInfo)return;let{right:e,top:t,height:n}=this.textInfo,r=e+4,i=t+(n-16)/2,a=this.sortIconName,o=this.ctx.database.getSortState(this.key);o.direction===`asc`?a=this.sortAscIconName:o.direction===`desc`&&(a=this.sortDescIconName);let s=this.ctx.icons.get(a),c=new T(a,r,i,16,16,s);this.setImage(`sort`,c)}getText(){return this.render&&this.renderHeaderType==="default"||[``,null,void 0].includes(this.text)?``:`${this.text}`}getOverlayerViewsStyle(){let e=``;return e=this.fixed===`left`?`${this.drawX}px`:this.fixed===`right`?`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:`${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 de{constructor(e,t){n(this,`root`),n(this,`key`),n(this,`childrenKey`),this.root=e,this.key=t?.key||`key`,this.childrenKey=t?.childrenKey||`children`}getTree(){return this.root}treeMove(e,t,n){if(n===`none`||e===t)return;let r=this.findNodeWithParent(this.root,e);if(!r)return;let i=this.findNodeWithParent(this.root,t);if(!i)return;let{parent:a,index:o,node:s}=r,{parent:c,index:l,node:u}=i;if(this.isDescendant(s,t))return;let d=a?a[this.childrenKey]:this.root;if(d.splice(o,1),a&&d.length===0&&delete a[this.childrenKey],n===`inside`){Array.isArray(u[this.childrenKey])||(u[this.childrenKey]=[]),u[this.childrenKey].push(s);return}let f=c?c[this.childrenKey]:this.root,p=l;a===c&&o<l&&p--,n===`after`&&p++,f.splice(p,0,s)}findNodeWithParent(e,t,n=null){for(let r=0;r<e.length;r++){let i=e[r];if(i[this.key]===t)return{parent:n,index:r,node:i};let a=i[this.childrenKey];if(Array.isArray(a)){let e=this.findNodeWithParent(a,t,i);if(e)return e}}return null}isDescendant(e,t){let n=e[this.childrenKey];if(!Array.isArray(n))return!1;for(let e of n)if(e[this.key]===t||this.isDescendant(e,t))return!0;return!1}}class fe{constructor(e){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=e,this.ctx.on(`resetHeader`,a(()=>{this.init(),this.ctx.clearSelector(),this.ctx.emit(`draw`)},100)),this.init(),this.initSelection(),this.initSort(),this.initResizeColumn(),this.initDragColumn()}init(e=!1){let{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(!e){let e=this.ctx.database.getColumns();this.columns=e}this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[],this.visibleColumns=u(this.columns);let r=o(this.visibleColumns),i=l(this.visibleColumns);this.height=t*r,this.visibleHeight=this.height,this.width=i.reduce((e,t)=>{let n=t.width||100,{maxWidth:r,minWidth:i}=t;return r&&n>r?e+r:i&&n<i?e+i:e+n},0),this.columnIndex=0,this.resizeNum=0;let a=s(c(this.visibleColumns,r));this.render(a,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);let d=this.ctx.containerElement.getBoundingClientRect(),{stageWidth:f,stagePhysicalWidth:p}=this.ctx.zoomScale.resolveStageWidth({containerPhysicalWidth:d.width,contentWidth:this.width,scrollerTrackSize:n,fillContainer:this.resizeNum>0});this.ctx.stageWidth=f,this.ctx.stagePhysicalWidth=p,this.ctx.stageElement.style.width=`${p}px`,this.visibleWidth=this.ctx.stageWidth-n;let m=this.visibleWidth-this.width;if(this.resizeNum&&m>0){let e=Math.floor(m/this.resizeNum*100)/100;this.resizeAllColumn(e)}let h=this.fixedLeftCellHeaders.filter(e=>!e.hasChildren);this.ctx.fixedLeftWidth=h.reduce((e,t)=>e+t.width,0);let g=this.fixedRightCellHeaders.filter(e=>!e.hasChildren);this.ctx.fixedRightWidth=g.reduce((e,t)=>e+t.width,n),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`,(e,t)=>{if(!e.isImageInside(`sort`,t))return;let n=this.ctx.database.getSortState(e.key),r;r=n.direction===`none`?`asc`:n.direction===`asc`?`desc`:`none`,this.ctx.database.setSortState(e.key,r)})}initSelection(){this.ctx.on(`cellHeaderClick`,(e,t)=>{if(this.ctx.stageElement.style.cursor!==`pointer`||!e.isImageInside(`selection`,t))return;let n=e.getImage(`selection`);[`checkbox-uncheck`,`checkbox-indeterminate`].includes(n.name)?this.ctx.database.toggleAllSelection():n.name===`checkbox-check`&&this.ctx.database.clearSelection(!0)})}initResizeColumn(){this.ctx.on(`mousedown`,e=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&this.ctx.isTarget(e)&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on(`mouseup`,()=>{this.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`,e=>{if(!this.ctx.config.ENABLE_RESIZE_COLUMN||this.ctx.editing)return;let{stageWidth:t,config:{RESIZE_COLUMN_MIN_WIDTH:n}}=this.ctx;if(this.isResizing&&this.resizeTarget){let t=this.resizeTarget.width,r=this.resizeTarget.minWidth,i=this.resizeTarget.maxWidth,a=e.clientX-this.clientX;a+t<n&&(a=-(t-n)),r&&a+t<r&&(a=-(t-r)),i&&a+t>i&&(a=i-t),this.resizeDiff=a,this.ctx.emit(`draw`)}else{if(this.resizeTarget=null,this.isMouseDown)return;let{offsetX:n}=this.ctx.getOffset(e);if(n<0||n>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`);let r=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(let n of r){let{offsetX:r,offsetY:i}=this.ctx.getOffset(e),a=r,o=i,s=n.getDrawX(),c=n.getDrawY();if(a>s+n.width-5&&a<s+n.width+4&&a<t-4&&o>c){let t=n.colIndex+n.colspan-1,r=this.leafCellHeaders.find(e=>e.colIndex===t);if(!r||!r.fixed&&this.ctx.stageWidth-this.ctx.fixedRightWidth<s+n.width)return;this.ctx.isTarget(e)&&i<=this.height&&(this.ctx.stageElement.style.cursor=`col-resize`,this.resizeTarget=r)}}}})}initDragColumn(){this.ctx.on(`cellHeaderMousedown`,e=>{this.ctx.stageElement.style.cursor==="default"&&this.ctx.config.ENABLE_DRAG_COLUMN&&(e.column.dragDisabled||(this.dragTarget===e?(this.ctx.dragHeaderIng=!0,this.dragCellDiff=this.ctx.mouseX-e.drawX,this.ctx.stageElement.style.cursor=`grabbing`):(this.dragTarget=e,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){let e=(t,n={})=>(t.forEach((t,r)=>{t.children&&e(t.children,n),n[t.key]=r}),n),t=this.ctx.database.getColumns(),n=c(t,o(t)),r=new de(n,{key:`key`,childrenKey:`children`}),i=this.dragTarget.colIndex>this.dragingCell.colIndex?`before`:`after`;r.treeMove(this.dragTarget.column.key,this.dragingCell.column.key,i);let a=e(r.getTree());this.ctx.database.setCustomHeader({sortData:a}),this.init();let s={source:this.dragTarget,target:this.dragingCell,columns:n};this.ctx.emit(`columnDragChange`,s)}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`,e=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(!this.ctx.dragHeaderIng||!this.dragTarget||(this.dragTarget.fixed||this.ctx.startAdjustPosition(e),this.ctx.emit(`draw`)))}),this.ctx.on(`cellHoverChange`,e=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(e.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(e.colIndex)))}),this.ctx.on(`cellHeaderHoverChange`,e=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(e.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(e.colIndex)))})}getDragCellHeader(e){if(!this.dragTarget||!this.ctx.dragHeaderIng)return;let{column:{parentKey:t},key:n,level:r,fixed:i}=this.dragTarget,a=this.allCellHeaders.find(a=>a.key!==n&&a.fixed===i&&a.column.level===r&&a.column.parentKey===t&&a.colIndex<=e&&a.colIndex+a.colspan-1>=e);if(this.ctx.dragHeaderIng){let e=a?`grabbing`:`not-allowed`;this.ctx.stageElement.style.cursor=e}return a}resizeColumn(e,t){let n=r=>{r.forEach(r=>{r.children&&r.children.length>0&&n(r.children),r.key===e.key&&(r.width=(r.width||100)+t)})};n(this.columns);let r=0;if(this.width<this.visibleWidth){let e=this.visibleWidth-this.width;r=Math.floor(e/this.resizeNum*100)/100,this.resizeAllColumn(r)}let i=e.width+t+r;this.ctx.emit(`resizeColumnChange`,{colIndex:e.colIndex,key:e.key,oldWidth:e.width,width:i,column:e.column,columns:this.columns}),this.ctx.database.setCustomHeaderResizableData(e.key,i),this.init(!0),this.ctx.emit(`draw`)}resizeAllColumn(e){if(e===0)return;let t=new Map,n=!0;for(let r of this.allCellHeaders)if(r.widthFillDisable)t.set(r.key,r.width);else{let i=r.width+e*r.colspan;t.set(r.key,i),i<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(n=!1)}if(!n)return;let r=e=>{e.forEach(e=>{t.has(e.key)&&(e.width=t.get(e.key)),e.children&&e.children.length>0&&r(e.children)})};r(this.columns),this.init(!0),this.ctx.emit(`draw`)}getCustomHeader(){let e=this.ctx.database.getColumns(),t=this.ctx.database.getCustomHeader(),{sortData:n={}}=t;return Object.keys(n).length===0?{columns:e,customHeader:t}:{columns:c(e,o(e)),customHeader:t}}render(e,t){let n=e.length,r=t,{HEADER_HEIGHT:i=0}=this.ctx.config;for(let t=0;t<n;t++){let n=e[t],a=i*(n.rowspan||0),o=i*(n.level||0),{minWidth:s,maxWidth:c}=n,u=n.width||100;s&&u<s&&(u=s),c&&u>c&&(u=c),n.children&&(u=l(n.children).reduce((e,t)=>e+(t?.width||100),0));let d=new ue(this.ctx,this.columnIndex,r,o,u,a,n);this.ctx.database.setHeader(n.key,d),this.allCellHeaders.push(d),n.children||(this.leafCellHeaders.push(d),d.column.widthFillDisable||this.resizeNum++),n.fixed===`left`?this.fixedLeftCellHeaders.push(d):n.fixed===`right`?this.fixedRightCellHeaders.push(d):this.centerCellHeaders.push(d),!n.children&&this.columnIndex++,n.children&&this.render(n.children,r),r+=u}}drawTipLine(){if(this.isResizing&&this.resizeTarget){let{stageHeight:e,config:{RESIZE_COLUMN_LINE_COLOR:t,RESIZE_COLUMN_TEXT_COLOR:n,RESIZE_COLUMN_TEXT_BG_COLOR:r,ENABLE_RESIZE_COLUMN_TEXT:i}}=this.ctx,a=this.resizeTarget.getDrawX(),o=this.resizeTarget.width,s=a+o+this.resizeDiff-.5,c=[s-.5,0,s-.5,e];if(this.ctx.paint.drawLine(c,{borderColor:t}),i){let e=`${Math.floor(o+this.resizeDiff)}px`;this.ctx.paint.drawRect(s+45/2,this.ctx.mouseY-24/2,45,24,{fillColor:r,borderWidth:0,borderColor:`transparent`}),this.ctx.paint.drawText(e,s+45/2,this.ctx.mouseY-24/2,45,26,{padding:0,color:n,align:`center`,verticalAlign:`middle`})}}}drawDragTip(){if(this.dragTarget&&this.ctx.dragHeaderIng){let{DRAG_TIP_BG_COLOR:e,DRAG_TIP_LINE_COLOR:t}=this.ctx.config,n=this.dragTarget.width;if(this.ctx.paint.drawRect(this.ctx.mouseX-this.dragCellDiff,this.visibleHeight,n,this.ctx.body.visibleHeight,{fillColor:e,borderWidth:0,borderColor:`transparent`}),this.dragingCell){let{drawX:e,drawY:n,visibleWidth:r,colIndex:i}=this.dragingCell,a=e,o=n;i>this.dragTarget.colIndex&&(a=e+r),i===0&&(a+=1),i===this.ctx.maxColIndex&&--a;let s=[a,o,a,this.ctx.stageHeight],c=[a-4,o,a+4,o,a,o+6,a-4,o];this.ctx.paint.drawLine(c,{borderColor:t,borderWidth:1.2,fillColor:t}),this.ctx.paint.drawLine(s,{borderColor:t,borderWidth:1.2})}}}drawFixedShadow(){let{fixedLeftWidth:e,fixedRightWidth:t,scrollX:n,header:r,stageWidth:i,config:{HEADER_BG_COLOR:a,SCROLLER_TRACK_SIZE:o}}=this.ctx;if(n>0&&e!==0&&this.ctx.paint.drawShadow(this.x,this.y,e,this.height,{fillColor:a,side:`right`,shadowWidth:4,colorStart:`rgba(0,0,0,0.1)`,colorEnd:`rgba(0,0,0,0)`}),n<Math.floor(r.width-i-1)&&t!==o){let e=r.width-(this.x+this.width)+i-t;this.ctx.paint.drawShadow(e,this.y,t,this.height,{fillColor:a,side:`left`,shadowWidth:4,colorStart:`rgba(0,0,0,0)`,colorEnd:`rgba(0,0,0,0.1)`})}}update(){let e=[],t=[],n=[];if(this.centerCellHeaders.length){let e=this.centerCellHeaders[this.centerCellHeaders.length-1];this.ctx.lastCenterColIndex=e.colIndex}this.centerCellHeaders.forEach(n=>{n.isHorizontalVisible()&&n.isVerticalVisible()&&(t.push(n),n.hasChildren||e.push(n))}),this.fixedLeftCellHeaders.forEach(t=>{n.push(t),t.hasChildren||e.push(t)}),this.fixedRightCellHeaders.forEach(t=>{n.push(t),t.hasChildren||e.push(t)}),this.renderCenterCellHeaders=t,this.renderFixedCellHeaders=n,this.renderLeafCellHeaders=e.sort((e,t)=>e.x-t.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(e=>e.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(){let{stageWidth:e,config:{BORDER_COLOR:t}}=this.ctx,n=[0,this.height,e,this.height];this.ctx.paint.drawLine(n,{borderColor:t,borderWidth:1})}draw(){this.renderCenterCellHeaders.forEach(e=>{e.update(),e.draw()}),this.drawFixedShadow(),this.renderFixedCellHeaders.forEach(e=>{e.update(),e.draw()}),this.drawBottomLine(),this.drawTipLine(),this.drawDragTip()}}class pe{constructor(e,t,r=0,i=0,a=0,o=0,s,c=`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=e,this.x=r,this.y=i,this.width=a,this.height=o,this.rowIndex=t,this.rowKey=e.database.getRowKeyForRowIndex(t)||``,this.rowType=c,this.data=s,this.update()}update(){let{header:e}=this.ctx,t=[],n=[],r=[],i=[];e.renderLeafCellHeaders.forEach(e=>{let a=new E(this.ctx,this.rowIndex,e.colIndex,e.x,this.y,e.width,this.height,e.column,this.data,this.rowType);a.fixed?n.push(a):r.push(a),t.push(a),a.autoRowHeight&&i.push(a)}),this.cells=t,this.calculatedHeightCells=i,this.fixedCells=n,this.noFixedCells=r}updateCalculatedHeight(){let e=this.calculatedHeightCells.map(e=>{let t=e.getAutoHeight(),{key:n,height:r=-1}=this.ctx.database.getMaxRowHeightItem(this.rowKey)||{};return(t>r||e.key===n&&t<r)&&this.ctx.database.setMaxRowHeightItem(this.rowKey,e.key,t),t});return this.calculatedHeight=e.length?Math.max(...e):-1,this.calculatedHeight}drawCenter(){this.noFixedCells.forEach(e=>{e.draw()})}drawFixed(){this.fixedCells.forEach(e=>{e.draw()})}drawContainer(){this.noFixedCells.forEach(e=>{e.drawContainer()})}drawFixedContainer(){this.fixedCells.forEach(e=>{e.drawContainer()})}}class me{constructor(e){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=e,this.init(),this.initTree(),this.initSelection(),this.initResizeRow(),this.initDragRow()}init(){let{canvasElement:e,header:t,footer:n,database:r,config:{FOOTER_FIXED:i,SCROLLER_TRACK_SIZE:a=0,HEIGHT:o,EMPTY_BODY_HEIGHT:s=0,MAX_HEIGHT:c=0,ENABLE_OFFSET_HEIGHT:l=0,OFFSET_HEIGHT:u=0,FOOTER_POSITION:d}}=this.ctx;if(!t.width)return;this.x=0,d===`top`&&i?this.y=t.height+n.height:this.y=t.height;let{data:f,sumHeight:p}=r.getData();this.height=p,this.data=f,this.width=t.width,this.visibleWidth=this.ctx.stageWidth-a;let m=this.ctx.footer.height;this.ctx.isEmpty=!this.data.length,!this.data.length&&!o?this.height=s:!this.data.length&&o&&(this.height=o-t.height-m-a);let{zoomScale:h}=this.ctx,g=this.height+t.height+a;g+=m;let _=h.contentToPhysical(g),v=window.innerHeight,{top:y}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(v>y&&l&&!o){let e=v-y-u;e>h.contentToPhysical(t.height+a)?_=e:h.contentToPhysical(g)>c&&(_=c)}else this.data.length&&o?_=o:this.data.length&&c&&h.contentToPhysical(g)>c&&(_=c);if(_>0){let{stageHeight:e,stagePhysicalHeight:t}=h.applyStageHeight(this.ctx.stageElement,_);this.ctx.stageHeight=e,this.ctx.stagePhysicalHeight=t}let b=this.ctx.stageHeight-t.height-a;i?this.visibleHeight=b-m:this.visibleHeight=b,this.data.length||(this.height=this.visibleHeight),this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=f;let x=window.devicePixelRatio||1,S=this.ctx.stagePhysicalWidth*x,C=this.ctx.stagePhysicalHeight*x;e.width=Math.round(S),e.height=Math.round(C);let w=this.data.length?`not-empty`:`empty`;this.ctx.emit(`emptyChange`,{isEmpty:w,type:w,headerHeight:t.height,bodyHeight:this.height,footerHeight:m,width:this.width,height:this.data.length?0:s+m});let T=Math.round(e.width/x*1e4)/1e4,E=Math.round(e.height/x*1e4)/1e4;this.ctx.canvasElement.setAttribute(`style`,`height:${E}px;width:${T}px;`),this.ctx.paint.scale(x,this.ctx.zoomScale.value)}initTree(){this.ctx.on(`cellClick`,(e,t)=>{if(this.ctx.stageElement.style.cursor!==`pointer`||!e.isImageInside(`tree`,t))return;let{expand:n=!1,expandLazy:r=!1}=this.ctx.database.getRowForRowKey(e.rowKey)||{},{EXPAND_LAZY:i,EXPAND_LAZY_METHOD:a}=this.ctx.config;if(i&&a&&!n&&!r)typeof a==`function`&&(this.ctx.database.expandLoading(e.rowKey,!0),a({row:e.row,rowIndex:e.rowIndex,colIndex:e.colIndex,column:e.column,value:e.getValue()}).then(t=>{this.ctx.database.setExpandChildren(e.rowKey,t),this.ctx.database.expandLoading(e.rowKey,!1),this.ctx.emit(`expandChange`,this.ctx.database.getExpandRowKeys())}).catch(t=>{this.ctx.database.expandLoading(e.rowKey,!1),console.error(t)}));else{let t=this.ctx.database.getIsExpand(e.rowKey);this.ctx.database.expandItem(e.rowKey,!t),this.ctx.emit(`expandChange`,this.ctx.database.getExpandRowKeys())}})}initSelection(){this.ctx.on(`cellClick`,(e,t)=>{this.ctx.stageElement.style.cursor!==`pointer`||!e.isImageInside(`selection`,t)||!this.ctx.database.getRowSelectable(e.rowKey)||this.ctx.database.toggleRowSelection(e.rowKey,e.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`,e=>{this.ctx.config.ENABLE_RESIZE_ROW&&this.ctx.isTarget(e)&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on(`mousemove`,e=>{if(!this.ctx.config.ENABLE_RESIZE_ROW||this.ctx.editing)return;let{offsetY:t,offsetX:n}=this.ctx.getOffset(e),r=t,i=n,a=e.clientY,{stageHeight:o,scrollY:s,config:{RESIZE_ROW_MIN_HEIGHT:c=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){let e=this.resizeTarget.height,t=a-this.clientY,{calculatedHeight:n}=this.resizeTarget,r=n===-1?c:n;t+e<r&&(t=-(e-r)),this.resizeDiff=t,this.ctx.emit(`draw`)}else{if(this.resizeTarget=null,this.isMouseDown)return;if(i<0||i>this.ctx.body.visibleWidth||r<0||r>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight){this.ctx.stageElement.style.cursor===`row-resize`&&(this.ctx.stageElement.style.cursor=`default`);return}if(this.ctx.stageElement.style.cursor===`crosshair`)return;this.ctx.stageElement.style.cursor===`row-resize`&&(this.ctx.stageElement.style.cursor=`default`);for(let e=0;e<this.renderRows.length;e++){let t=this.renderRows[e];if(r>t.y-s+t.height-1.5&&r<t.y-s+t.height+1.5&&r<o-4)for(let e=0;e<t.cells.length;e++){let n=t.cells[e];i>n.drawX+10&&i<n.drawX+n.width-10&&n.rowspan===1&&(this.ctx.stageElement.style.cursor=`row-resize`,this.resizeTarget=t)}}}})}initDragRow(){this.ctx.on(`cellMousedown`,(e,t)=>{this.ctx.config.ENABLE_DRAG_ROW&&e.isImageInside(`drag`,t)&&(this.dragSource=e,this.ctx.database.expandItem(e.rowKey,!1),this.ctx.dragRowIng=!0,this.dragRowDiff=this.ctx.mouseY-e.drawY,this.ctx.stageElement.style.cursor=`grabbing`,this.ctx.clearSelector(),this.ctx.emit(`dragRowMouseDown`,e),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`){let e=this.dragSource,t=this.dragTarget,n={source:e,target:t,position:this.dragPosition};this.ctx.emit(`dragRowChange`,n);let r=!0,{BEFORE_DRAG_ROW_METHOD:i}=this.ctx.config;if(typeof i==`function`&&(r=await i(n)),r&&!this.ctx.config.ENABLE_DRAG_ROW_CUSTOM){let n=this.ctx.database.getOriginalData(),{TREE_CHILDREN_KEY:r,ROW_KEY:i}=this.ctx.config,a=new de(n,{key:i,childrenKey:r});a.treeMove(e.rowKey,t.rowKey,this.dragPosition),this.ctx.emit(`loadData`,a.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`,e=>{if(!this.ctx.dragRowIng)return;let{offsetY:t}=this.ctx.getOffset(e),{drawY:n}=this.dragTarget;n<t||n>t?this.ctx.startAdjustPosition(e):this.ctx.stopAdjustPosition()}),this.ctx.on(`cellMouseenter`,e=>{if(!this.ctx.dragRowIng)return;this.dragTarget=e;let{ENABLE_DRAG_ROW_CROSS_LEVEL:t}=this.ctx.config,n=this.dragSource,r=this.dragTarget;if(!t&&n&&r&&n.parentRowKey!==r.parentRowKey){this.ctx.stageElement.style.cursor=`not-allowed`;return}this.ctx.stageElement.style.cursor=`grabbing`,this.dragTarget=e;let{drawY:i,visibleHeight:a}=e,o=t?a/3:a/2;this.ctx.mouseY<=i+o?this.dragPosition=`before`:this.ctx.mouseY>i+a-o?this.dragPosition=`after`:this.dragPosition=`inside`;let s={dragSource:this.dragSource,dragTarget:this.dragTarget,dragPosition:this.dragPosition};this.ctx.emit(`dragRowMove`,s),this.ctx.emit(`draw`)})}resizeRow(e,t){let{rowIndex:n,height:r,rowKey:i,data:a}=e;this.ctx.database.setRowHeight(n,r+t),this.init(),this.ctx.emit(`draw`),this.ctx.emit(`resizeRowChange`,{rowIndex:n,oldHeight:r,height:r+t,rowKey:i,row:a,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){let{stageWidth:e,scrollY:t,config:{RESIZE_ROW_LINE_COLOR:n}}=this.ctx,r=this.resizeTarget.y-t+this.resizeTarget.height+this.resizeDiff-.5,i=[0,r-.5,e,r-.5];this.ctx.paint.drawLine(i,{borderColor:n,borderWidth:1})}}drawDragRowTip(){if(this.ctx.dragRowIng&&this.dragTarget&&this.dragSource){let{stageWidth:e,config:{DRAG_ROW_TIP_LINE_COLOR:t,DRAG_TIP_BG_COLOR:n}}=this.ctx,r=this.dragSource.visibleHeight;this.ctx.paint.drawRect(0,this.ctx.mouseY-this.dragRowDiff,this.visibleWidth,r,{fillColor:n,borderWidth:0,borderColor:`transparent`});let i=this.dragTarget.drawY,a=this.dragTarget.height,o=i;if([`before`,`after`].includes(this.dragPosition)){this.dragPosition===`after`&&(o=i+a);let n=[0,o-.5,e,o-.5];this.ctx.paint.drawLine(n,{borderColor:t,borderWidth:1.2})}[`inside`].includes(this.dragPosition)&&(o=i+a/2);let s=[0,o-4,6,o,0,o+4,0,o-4];this.ctx.paint.drawLine(s,{borderColor:t,borderWidth:1.2,fillColor:t})}}drawFixedShadow(){let{fixedLeftWidth:e,fixedRightWidth:t,scrollX:n,header:r,stageWidth:i,config:{HEADER_BG_COLOR:a,SCROLLER_TRACK_SIZE:o}}=this.ctx;if(n>0&&e!==0&&!this.ctx.isEmpty&&this.ctx.paint.drawShadow(this.x,this.y,e,this.height,{fillColor:a,side:`right`,shadowWidth:4,colorStart:`rgba(0,0,0,0.1)`,colorEnd:`rgba(0,0,0,0)`}),n<Math.floor(r.width-i-1)&&t!==o&&!this.ctx.isEmpty){let e=r.width-(this.x+this.width)+i-t;this.ctx.paint.drawShadow(e,this.y,t,this.height,{fillColor:a,side:`left`,shadowWidth:4,colorStart:`rgba(0,0,0,0)`,colorEnd:`rgba(0,0,0,0.1)`})}}binarySearch(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a].bottom;if(o===t)return a;o<t?n=a+1:(i=a,r=a-1)}return i}update(){this.init();let{header:e,database:t,scrollY:n,config:{CELL_HEIGHT:r}}=this.ctx,i=n,{data:a,positions:o}=t.getData();this.ctx.maxRowIndex=a.length-1;let s=this.binarySearch(o,i),c=this.binarySearch(o,i+this.visibleHeight);if(c===-1&&(c=this.ctx.maxRowIndex),s===-1&&c===this.ctx.maxRowIndex){let e=Math.floor(this.visibleHeight/r);s=this.ctx.maxRowIndex-e}this.headIndex=Math.max(0,s),this.tailIndex=Math.min(this.ctx.maxRowIndex,c+1),this.visibleRows=a.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;let l=[];for(let t=0;t<this.visibleRows.length;t++){let n=this.headIndex+t,r=this.visibleRows[t],{height:i,top:a}=this.ctx.database.getPositionForRowIndex(n),o=new pe(this.ctx,n,0,a+this.y,e.width,i,r);l.push(o)}this.renderRows=l,this.ctx.body.renderRows=l}updateAutoHeight(){let e=this.ctx.body.renderRows;if(!e.some(e=>e.calculatedHeightCells.length>0))return!1;e.forEach(e=>{e.updateCalculatedHeight()});let t=e.map(e=>({height:e.calculatedHeight,rowIndex:e.rowIndex}));return this.ctx.database.setBatchCalculatedRowHeight(t)}draw(){this.renderRows.forEach(e=>{e.drawContainer()}),this.renderRows.forEach(e=>{e.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(e=>{e.drawFixedContainer()}),this.renderRows.forEach(e=>{e.drawFixed()}),this.drawTipLine()}}class he{constructor(e){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=e,this.init()}init(){this.data=this.ctx.database.getFooterData();let{header:e,body:t,config:{CELL_FOOTER_HEIGHT:n,FOOTER_FIXED:r,SCROLLER_TRACK_SIZE:i,FOOTER_POSITION:a}}=this.ctx;this.width=e.width,this.visibleWidth=e.visibleWidth,this.height=this.data.reduce(e=>e+n,0),this.visibleHeight=this.height,r?a===`top`?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-i:this.y=t.y+t.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(){let{fixedLeftWidth:e,fixedRightWidth:t,scrollX:n,header:r,stageWidth:i,config:{HEADER_BG_COLOR:a,SCROLLER_TRACK_SIZE:o}}=this.ctx,s=this.y;if(this.ctx.config.FOOTER_FIXED||(s=this.y-this.ctx.scrollY),n>0&&e!==0&&this.ctx.paint.drawShadow(this.x,s,e,this.height,{fillColor:a,side:`right`,shadowWidth:4,colorStart:`rgba(0,0,0,0.1)`,colorEnd:`rgba(0,0,0,0)`}),n<Math.floor(r.width-i-1)&&t!==o){let e=r.width-(this.x+this.width)+i-t;this.ctx.paint.drawShadow(e,s,t,this.height,{fillColor:a,side:`left`,shadowWidth:4,colorStart:`rgba(0,0,0,0)`,colorEnd:`rgba(0,0,0,0.1)`})}}update(){this.init();let{CELL_FOOTER_HEIGHT:e}=this.ctx.config,t=this.y,n=[];this.data.forEach((r,i)=>{let a=new pe(this.ctx,i,0,t,this.width,e,r,`footer`);t+=e,n.push(a)}),this.renderRows=n,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){let{stageWidth:e,config:{BORDER_COLOR:t}}=this.ctx,n=[0,this.y,e,this.y];this.ctx.paint.drawLine(n,{borderColor:t,borderWidth:1})}draw(){this.renderRows.forEach(e=>{e.drawContainer()}),this.renderRows.forEach(e=>{e.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(e=>{e.drawFixedContainer()}),this.renderRows.forEach(e=>{e.drawFixed()}),this.drawTopLine()}}class ge{constructor(e){n(this,`isCut`,!1),n(this,`isMultipleRow`,!1),n(this,`ctx`),this.ctx=e,this.init()}init(){this.ctx.on(`setMoveFocus`,e=>{this.moveFocus(e)}),this.ctx.on(`mousemove`,a(e=>{var t;(t=this.ctx.focusCellHeader)!=null&&t.fixed||!this.ctx.dragHeaderIng&&this.ctx.selectorMove&&this.ctx.startAdjustPosition(e)},100)),this.ctx.on(`cellHoverChange`,e=>{if(!this.ctx.autofillMove){if(e.operation){this.selectRows(e,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on(`cellClick`,()=>{this.adjustBoundaryPosition()}),this.ctx.on(`cellMousedown`,(e,t)=>{if(!(!this.ctx.isTarget(t)||this.ctx.stageElement.style.cursor===`pointer`||this.ctx.stageElement.style.cursor===`crosshair`)){if(e.operation){this.isMultipleRow=!0,this.selectRows(e);return}window.getComputedStyle(t.target).userSelect!==`text`&&t.preventDefault(),this.isMultipleRow=!1,this.click(t.shiftKey),this.ctx.emit(`selectorClick`,e)}}),this.ctx.on(`mouseup`,()=>{this.ctx.selectorMove=!1,this.ctx.stopAdjustPosition(),setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0)}),this.ctx.on(`cellHeaderHoverChange`,e=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(e)}),this.ctx.on(`cellHoverChange`,e=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(e)}),this.ctx.on(`cellHeaderMousedown`,(e,t)=>{this.ctx.stageElement.style.cursor!==`pointer`&&(window.getComputedStyle(t.target).userSelect!==`text`&&t.preventDefault(),this.ctx.clearSelector(),e.operation?this.selectAll():this.selectCols(e))}),this.ctx.on(`keydown`,e=>{if(!this.ctx.editing&&!this.ctx.finding){if(e.ctrlKey&&e.code===`KeyV`||e.metaKey&&e.code===`KeyV`){this.paste();return}if(e.ctrlKey&&e.code===`KeyC`||e.metaKey&&e.code===`KeyC`){this.copy(),this.isCut=!1;return}if(e.ctrlKey&&e.code===`KeyX`||e.metaKey&&e.code===`KeyX`){this.isCut=!0,this.copy();return}if((e.ctrlKey&&e.code===`KeyA`||e.metaKey&&e.code===`KeyA`)&&(e.preventDefault(),this.selectAll()),e.code===`ArrowLeft`||e.shiftKey&&e.code===`Tab`){e.preventDefault(),this.moveFocus(`LEFT`);return}if(e.code===`ArrowUp`){e.preventDefault(),this.moveFocus(`TOP`);return}if(e.code===`ArrowRight`||e.code===`Tab`){e.preventDefault(),this.moveFocus(`RIGHT`);return}if(e.code===`ArrowDown`){e.preventDefault(),this.moveFocus(`BOTTOM`);return}if(e.code===`Delete`||e.code===`Backspace`){e.preventDefault();let{xArr:t,yArr:n}=this.ctx.selector;this.clearSelectedData(t,n);return}}}),this.ctx.on(`contextMenuClearSelected`,()=>{let{xArr:e,yArr:t}=this.ctx.selector;this.clearSelectedData(e,t)}),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`,e=>{this.ctx.setFocusCell(e),this.click(),this.adjustBoundaryPosition()}),this.ctx.on(`selectCols`,e=>{this.selectCols(e)})}setSelector(e,t){if(this.ctx.dragHeaderIng||this.ctx.dragRowIng)return;let{ENABLE_SELECTOR_SPAN_COL:n,ENABLE_SELECTOR_SPAN_ROW:r}=this.ctx.config,i=e,a=t;if(!r){let[e]=a;a=[e,e]}if(!n){let[e]=i;i=[e,e]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(i)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(a)){this.ctx.mousedown&&(this.ctx.selectorMove=!0,this.ctx.disableHoverIconClick=!0),this.ctx.selector.enable=!0;let{SELECTOR_AREA_MIN_X:e,SELECTOR_AREA_MAX_X:t,SELECTOR_AREA_MIN_Y:n,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:o,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,c=e,l=t||this.ctx.maxColIndex-o,u=n,d=r||this.ctx.maxRowIndex-s,[f,p]=i,[m,h]=a;if(f<c||p>l||m<u||h>d)return;if(this.ctx.config.ENABLE_MERGE_CELL_LINK){let e=this.adjustMergeCells(i,a);m=e.yArr[0],h=e.yArr[1],f=e.xArr[0],p=e.xArr[1],this.ctx.onlyMergeCell=e.onlyMergeCell}f===p&&m===h?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,i=[Math.max(c,f),Math.min(l,p)],a=[Math.max(u,m),Math.min(d,h)];let{BEFORE_SET_SELECTOR_METHOD:g}=this.ctx.config;if(typeof g==`function`){let e=g({focusCell:this.ctx.focusCell,xArr:i,yArr:a});if(!e)return;i=e.xArr,a=e.yArr}this.ctx.selector.xArr=i,this.ctx.selector.yArr=a,h===this.ctx.maxRowIndex&&m===0?this.ctx.selectColsIng=!0:this.ctx.selectColsIng=!1,p===this.ctx.maxColIndex&&f===0?this.ctx.selectRowsIng=!0:this.ctx.selectRowsIng=!1,this.ctx.emit(`setSelector`,this.ctx.selector),this.ctx.emit(`drawView`)}}adjustMergeCells(e,t){let[n,r]=t,[i,a]=e;if(r===this.ctx.maxRowIndex&&n===0||a===this.ctx.maxColIndex&&i===0)return{xArr:e,yArr:t,onlyMergeCell:!1};let o=[],s=[];for(let c=0;c<=t[1]-t[0];c++)for(let l=0;l<=e[1]-e[0];l++){let u=c+t[0],d=l+e[0],f=this.ctx.database.getVirtualBodyCell(u,d);f&&((u===n||u===r)&&o.push(f),(d===i||d===a)&&s.push(f))}let c=o.reduce((e,t)=>{let{yArr:n}=t.getSpanInfo(),[r,i]=n;return e.minY=Math.min(e.minY,r),e.maxY=Math.max(e.maxY,i),e},{minY:n,maxY:r}),l=s.reduce((e,t)=>{let{xArr:n}=t.getSpanInfo(),[r,i]=n;return e.minX=Math.min(e.minX,r),e.maxX=Math.max(e.maxX,i),e},{minX:i,maxX:a}),u=[l.minX,l.maxX],d=[c.minY,c.maxY],f=!1;if(l.minX!==l.maxX||c.minY!==c.maxY){let e=JSON.stringify(u)+JSON.stringify(d),t=this.ctx.focusCell?.getSpanInfo();f=(t&&JSON.stringify(t.xArr)+JSON.stringify(t.yArr))===e}return{xArr:u,yArr:d,onlyMergeCell:f}}selectCols(e){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;let{SELECTOR_AREA_MIN_Y:t,SELECTOR_AREA_MAX_Y:n,SELECTOR_AREA_MAX_Y_OFFSET:r}=this.ctx.config,i=t,a=n||this.ctx.maxRowIndex-r;if(this.ctx.focusCellHeader){let{colIndex:t}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),this.ctx.mousedown&&e.colIndex>=t){let n=[t,e.colIndex+e.colspan-1],r=[i,a];this.setSelector(n,r)}else{let n=[e.colIndex,t+e.colspan-1],r=[i,a];this.setSelector(n,r)}}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;let{ENABLE_SELECTOR_ALL_ROWS:e,ENABLE_SELECTOR_ALL_COLS:t}=this.ctx.config;if(e&&t){let{SELECTOR_AREA_MIN_X:e,SELECTOR_AREA_MAX_X:t,SELECTOR_AREA_MIN_Y:n,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:i,SELECTOR_AREA_MAX_Y_OFFSET:a}=this.ctx.config,o=e,s=t||this.ctx.maxColIndex-i,c=n,l=r||this.ctx.maxRowIndex-a,u=[o,s],d=[c,l];this.setSelector(u,d)}}selectRows(e,t=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;let{SELECTOR_AREA_MIN_X:n,SELECTOR_AREA_MAX_X:r,SELECTOR_AREA_MAX_X_OFFSET:i}=this.ctx.config,a=r||this.ctx.maxColIndex-i,o=n;if(t){this.ctx.setFocusCell(e);let t=[o,a],n=[e.rowIndex,e.rowIndex];this.setSelector(t,n)}if(this.ctx.focusCell&&this.ctx.mousedown){let{rowIndex:t}=this.ctx.focusCell;if(e.rowIndex>=t){let n=[o,a],r=[t,e.rowIndex];this.setSelector(n,r)}else{let n=[o,a],r=[e.rowIndex,t];this.setSelector(n,r)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;let{mousedown:e,focusCell:t,hoverCell:n}=this.ctx;if(e&&t&&n){let{rowIndex:e,colIndex:r}=t,i=Math.min(n.colIndex,r),a=Math.max(n.colIndex,r),o=Math.min(n.rowIndex,e),s=Math.max(n.rowIndex,e),c=[i,a],l=[o,s];this.setSelector(c,l)}}click(e=!1){let{focusCell:t,clickCell:n}=this.ctx;if(t&&this.isInSettingRange(t.rowIndex,t.colIndex))if(this.ctx.selector.enable=!0,n&&e){if(this.ctx.config.ENABLE_SELECTOR_SINGLE)return;let{colIndex:e,rowIndex:r}=n,{colIndex:i,rowIndex:a}=t,o=Math.min(i,e),s=Math.max(i,e),c=Math.min(a,r),l=Math.max(a,r),u=[o,s],d=[c,l];this.setSelector(u,d)}else{this.ctx.emit(`cellSelectedClick`,t);let e=[t.colIndex,t.colIndex],n=[t.rowIndex,t.rowIndex];this.setSelector(e,n)}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(e,t){return this.ctx.body.renderRows.find(t=>t.rowIndex===e)?.cells.find(e=>e.colIndex===t)}copy(){if(!this.ctx.config.ENABLE_COPY||this.ctx.domSelectionStr||this.ctx.textSelectionStr)return;let{value:e,xArr:t,yArr:n}=this.ctx.getSelectedData();if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(t,n))if(this.ctx.onlyMergeCell&&this.ctx.focusCell){let r=this.ctx.focusCell;e=[[r.getValue()]],t=[r.colIndex,r.colIndex],n=[r.rowIndex,r.rowIndex]}else{let e={code:`ERR_MERGED_CELLS_COPY`,message:this.ctx.locale.getText(`mergeCellNoCopy`)};this.ctx.hasEvent(`error`)?this.ctx.emit(`error`,e):console.error(e.message);return}let{BEFORE_COPY_METHOD:r}=this.ctx.config;if(typeof r==`function`){let i=r({focusCell:this.ctx.focusCell,data:e,xArr:t,yArr:n});if(!i)return;e=i.data}let i=h(e);navigator.clipboard?navigator.clipboard.writeText(i).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:e}),this.ctx.emit(`draw`)}).catch(e=>console.error(`Copy Failure:`,e)):console.error(`current browser does not support the Clipboard API`)}clearSelectedData(e,t,n=!1,r=null){let i=[],a=new Set;for(let n=0;n<=t[1]-t[0];n++)for(let o=0;o<=e[1]-e[0];o++){let s=n+t[0],c=o+e[0],l=this.ctx.database.getItemValueForRowIndexAndColIndex(s,c);if(l){let{rowKey:e,key:t}=l;this.ctx.database.getReadonly(e,t)||(a.add(e),i.push({rowKey:e,key:t,value:r,row:{}}))}}if(!i.length)return[];if(n)return i;this.ctx.database.batchSetItemValue(i,!0);let o=[];return a.forEach(e=>{o.push(this.ctx.database.getRowDataItemForRowKey(e))}),this.ctx.emit(`clearSelectedDataChange`,i,o),i}paste(){if(!navigator.clipboard){console.error(`current browser does not support the Clipboard API`);return}let{ENABLE_PASTER:e}=this.ctx.config;if(this.ctx.selector.enable&&e){let e=this.ctx.selector.yArr[0],t=this.ctx.selector.xArr[0],n=new Set;navigator.clipboard.readText().then(async r=>{let i=m(r),a=[t,t+i[0].length-1],o=[e,e+i.length-1],[s,c]=o,[l,u]=a,d=c-this.ctx.maxRowIndex,f=u-this.ctx.maxColIndex;(d>0||f>0)&&this.ctx.emit(`onPastedDataOverflow`,{maxY:c,maxX:u,minY:s,minX:l,overflowRowCount:d,overflowColCount:f,textArr:i});let p=i.length===1&&i[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,o)&&!p){let e={code:`ERR_MERGED_CELLS_PASTE`,message:this.ctx.locale.getText(`mergeCellNoPaste`),data:[]};this.ctx.hasEvent(`error`)?this.ctx.emit(`error`,e):console.error(e.message);return}let h=[];for(let r=0;r<=i.length-1;r++){let a=i[r].length;for(let o=0;o<=a-1;o++){let a=r+e,s=o+t,c=i[r][o],l=this.ctx.database.getItemValueForRowIndexAndColIndex(a,s);if(l){let{rowKey:e,key:t}=l;this.ctx.database.getReadonly(e,t)||(n.add(e),h.push({rowKey:e,key:t,value:c,row:{}}))}}}if(this.isCut){let e=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),t=h.map(e=>`${e.rowKey}-${e.key}`);e.forEach(e=>{t.includes(`${e.rowKey}-${e.key}`)||h.unshift(e)}),this.isCut=!1}if(!h.length)return;let{BEFORE_PASTE_DATA_METHOD:g}=this.ctx.config;if(typeof g==`function`&&(h=await g(h.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)})),a,o,i),h&&!h.length))return;this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(h,!0);let _=[];n.forEach(e=>{_.push(this.ctx.database.getRowDataItemForRowKey(e))}),this.ctx.emit(`pasteChange`,h,_),this.ctx.emit(`draw`)}).catch(e=>{console.error(`Failed to get the clipboard content:`,e)})}}moveFocus(e){if(this.ctx.editing)return;let{focusCell:t}=this.ctx;if(!t)return;let{colIndex:n=0,rowIndex:r=0}=t,i=this.ctx.maxColIndex,a=this.ctx.maxRowIndex;switch(e){case`LEFT`:n>0&&n--;break;case`TOP`:r>0&&r--;break;case`RIGHT`:n<i&&n++;break;case`BOTTOM`:r<a&&r++;break}let o=[n,n],s=[r,r],c=this.getCell(r,n);c&&(c.operation||this.isInSettingRange(c.rowIndex,c.colIndex)&&(this.ctx.setFocusCell(c),this.setSelector(o,s),this.adjustBoundaryPosition(),this.ctx.emit(`moveFocus`,c),this.ctx.emit(`draw`)))}isInSettingRange(e,t){let{SELECTOR_AREA_MIN_X:n,SELECTOR_AREA_MAX_X:r,SELECTOR_AREA_MIN_Y:i,SELECTOR_AREA_MAX_Y:a,SELECTOR_AREA_MAX_X_OFFSET:o,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,c=n,l=r||this.ctx.maxColIndex-o,u=i,d=a||this.ctx.maxRowIndex-s;return!(t<c||t>l||e<u||e>d)}adjustBoundaryPosition(){let{stageHeight:e,stageWidth:t,focusCell:n,fixedRightWidth:r,fixedLeftWidth:i,header:a,footer:o,body:s,scrollX:c,scrollY:l,config:{SCROLLER_TRACK_SIZE:u,FOOTER_FIXED:d,FOOTER_POSITION:f,ENABLE_MERGE_CELL_LINK:p}}=this.ctx;if(!n)return;p&&this.ctx.onlyMergeCell&&n.updateSpanInfo();let{drawX:m,drawY:h,width:g,height:_,fixed:v}=n,y=i-m+1,b=n.drawX+g-(t-r)+1,x=a.height-h,S=_;S>s.visibleHeight&&(S=s.visibleHeight);let C=0;d&&(f===`top`?x=a.height+o.height-h:C=o.visibleHeight);let w=h+S-(e-C-u),T=c,E=l;b>0&&!v?T=Math.floor(c+b):y>0&&!v&&(T=Math.floor(c-y)),x>0?E=Math.floor(l-x):w>0&&(E=Math.floor(l+w)),(Math.abs(c-T)>2.5||Math.abs(l-E)>2.5)&&this.ctx.setScroll(T,E)}destroy(){}}class _e{constructor(e){n(this,`ctx`),n(this,`maxColRowCell`),this.ctx=e,this.init()}init(){this.ctx.on(`mousemove`,e=>{if(this.ctx.stageElement.style.cursor===`crosshair`&&(this.ctx.stageElement.style.cursor=`default`),this.ctx.editing||!this.ctx.focusCell||!this.maxColRowCell)return;let{offsetX:t,offsetY:n}=this.ctx.getOffset(e),{colIndex:r,rowIndex:i,drawX:a,drawY:o,width:s,height:c}=this.maxColRowCell,l=r===this.ctx.maxColIndex||i===this.ctx.maxRowIndex?0:2,u=a+s-6+l,d=o+c-6+l;t>u&&n>d&&t<u+6&&n<d+6&&(this.ctx.stageElement.style.cursor=`crosshair`),this.ctx.autofillMove&&this.ctx.startAdjustPosition(e)}),this.ctx.on(`cellMouseenter`,e=>{let{xArr:t,yArr:n}=this.ctx.selector,r=t[1],i=n[1],{colIndex:a,rowIndex:o}=e;this.ctx.config.ENABLE_AUTOFILL&&a===r&&o===i&&(this.maxColRowCell=e),this.mouseenter(e)}),this.ctx.on(`mousedown`,()=>{this.ctx.stageElement.style.cursor===`crosshair`&&this.setMousedown()}),this.ctx.on(`mouseup`,()=>{this.setMouseUp(),this.ctx.stopAdjustPosition()})}isAutofillIng(){let{xArr:e,yArr:t}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(e)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(t))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0,this.ctx.disableHoverIconClick=!0}setMouseUp(){this.ctx.autofill.enable&&(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(e,t){let{ENABLE_AUTOFILL:n,ENABLE_AUTOFILL_SPAN_COL:r,ENABLE_AUTOFILL_SPAN_ROW:i}=this.ctx.config;if(!n)return;let a=e,o=t,s=this.ctx.selector.xArr,c=this.ctx.selector.yArr;if(!(!i&&JSON.stringify(c)!==JSON.stringify(o))&&!(!r&&JSON.stringify(s)!==JSON.stringify(a))&&(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(a)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(o))){let{SELECTOR_AREA_MIN_X:e,SELECTOR_AREA_MAX_X:t,SELECTOR_AREA_MIN_Y:n,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,c=e,l=t||this.ctx.maxColIndex-i,u=n,d=r||this.ctx.maxRowIndex-s,[f,p]=a,[m,h]=o;if(f<c||m<u)return;a=[Math.max(c,f),Math.min(l,p)],o=[Math.max(u,m),Math.min(d,h)];let{BEFORE_SET_AUTOFILL_METHOD:g}=this.ctx.config;if(typeof g==`function`){let e=g({focusCell:this.ctx.focusCell,xArr:a,yArr:o});if(!e)return;a=e.xArr,o=e.yArr}this.ctx.autofill.xArr=a,this.ctx.autofill.yArr=o,this.ctx.emit(`setAutofill`,this.ctx.autofill),this.ctx.emit(`draw`)}}async autofillData(){let e=new Set,t=this.ctx.getSelectedData(),n=new Map;for(let e=0;e<=t.yArr[1]-t.yArr[0];e++)for(let r=0;r<=t.xArr[1]-t.xArr[0];r++){let i=e+t.yArr[0],a=r+t.xArr[0];n.set(`${i}-${a}`,!0)}let{value:r}=t,i=r[0].length,a=r.length,o=this.ctx.autofill.xArr,s=this.ctx.autofill.yArr,c=i===1&&a===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(o,s)&&!c){let e={code:`ERR_MERGED_CELLS_AUTOFILL`,message:this.ctx.locale.getText(`mergeCellNoFill`),data:[]};this.ctx.hasEvent(`error`)?this.ctx.emit(`error`,e):console.error(e.message);return}let l=[];for(let t=0;t<=s[1]-s[0];t++)for(let c=0;c<=o[1]-o[0];c++){let u=c+o[0],d=t+s[0],f=r[t%a][c%i],p=this.ctx.database.getItemValueForRowIndexAndColIndex(d,u),m=`${d}-${u}`;if(p&&!n.has(m)){let{rowKey:t,key:n}=p;this.ctx.database.getReadonly(t,n)||(e.add(t),l.push({rowKey:t,key:n,value:f,row:{}}))}}if(!l.length)return;this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr;let{BEFORE_AUTOFILL_DATA_METHOD:u}=this.ctx.config;if(typeof u==`function`&&(l=await u(l.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)})),o,s),l&&!l.length))return;this.ctx.batchSetItemValueByEditor(l,!0);let d=[];e.forEach(e=>{d.push(this.ctx.database.getRowDataItemForRowKey(e))}),this.ctx.emit(`autofillChange`,l,d),this.ctx.emit(`draw`)}mouseenter(e){if([`index`,`selection`,`index-selection`].includes(e.type))return;let{selector:t,autofill:n}=this.ctx;if(this.ctx.mousedown&&t.enable&&n.enable){let{rowIndex:n,colIndex:r}=e,i=t.xArr.slice(),a=t.yArr.slice();n>=t.yArr[0]&&n<=t.yArr[1]?r>t.xArr[1]?i.splice(1,1,r):r<t.xArr[0]&&i.splice(0,1,r):n>t.yArr[1]?a.splice(1,1,n):n<t.yArr[0]&&a.splice(0,1,n),this.setAutofill(i,a)}}destroy(){}}let ve=Math.min,R=Math.max,z=Math.round,ye=Math.floor,B=e=>({x:e,y:e}),be={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function xe(e,t,n){return R(e,ve(t,n))}function V(e,t){return typeof e==`function`?e(t):e}function H(e){return e.split(`-`)[0]}function U(e){return e.split(`-`)[1]}function Se(e){return e===`x`?`y`:`x`}function W(e){return e===`y`?`height`:`width`}function G(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ce(e){return Se(G(e))}function we(e,t,n){n===void 0&&(n=!1);let r=U(e),i=Ce(e),a=W(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Me(o)),[o,Me(o)]}function Te(e){let t=Me(e);return[Ee(e),t,Ee(t)]}function Ee(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}let K=[`left`,`right`],De=[`right`,`left`],Oe=[`top`,`bottom`],ke=[`bottom`,`top`];function Ae(e,t,n){switch(e){case`top`:case`bottom`:return n?t?De:K:t?K:De;case`left`:case`right`:return t?Oe:ke;default:return[]}}function je(e,t,n,r){let i=U(e),a=Ae(H(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ee)))),a}function Me(e){let t=H(e);return be[t]+e.slice(t.length)}function Ne(e){return{top:0,right:0,bottom:0,left:0,...e}}function Pe(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ne(e)}function Fe(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ie(e,t,n){let{reference:r,floating:i}=e,a=G(t),o=Ce(t),s=W(o),c=H(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(U(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function Le(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:a,rects:o,elements:s,strategy:c}=e,{boundary:l=`clippingAncestors`,rootBoundary:u=`viewport`,elementContext:d=`floating`,altBoundary:f=!1,padding:p=0}=V(t,e),m=Pe(p),h=s[f?d===`floating`?`reference`:`floating`:d],g=Fe(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(h)))==null||n?h:h.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),_=d===`floating`?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,v=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),y=await(a.isElement==null?void 0:a.isElement(v))&&await(a.getScale==null?void 0:a.getScale(v))||{x:1,y:1},b=Fe(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:_,offsetParent:v,strategy:c}):_);return{top:(g.top-b.top+m.top)/y.y,bottom:(b.bottom-g.bottom+m.bottom)/y.y,left:(g.left-b.left+m.left)/y.x,right:(b.right-g.right+m.right)/y.x}}let Re=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Le},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Ie(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<50&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Ie(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ze=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=V(e,t)||{};if(l==null)return{};let d=Pe(u),f={x:n,y:r},p=Ce(i),m=W(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=ve(d[_],T),D=ve(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=xe(O,A,k),M=!c.arrow&&U(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Be=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=V(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=H(r),_=G(o),v=H(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Me(o)]:Te(o)),x=p!==`none`;!d&&x&&b.push(...je(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=we(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==G(t))||T.every(e=>G(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=G(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}},Ve=new Set([`left`,`top`]);async function He(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=H(n),s=U(n),c=G(n)===`y`,l=Ve.has(o)?-1:1,u=a&&c?-1:1,d=V(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}let Ue=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await He(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},We=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=V(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=G(H(i)),p=Se(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=xe(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=xe(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}};function Ge(){return typeof window<`u`}function Ke(e){return J(e)?(e.nodeName||``).toLowerCase():`#document`}function q(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qe(e){return((J(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function J(e){return Ge()?e instanceof Node||e instanceof q(e).Node:!1}function Y(e){return Ge()?e instanceof Element||e instanceof q(e).Element:!1}function Je(e){return Ge()?e instanceof HTMLElement||e instanceof q(e).HTMLElement:!1}function Ye(e){return!Ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof q(e).ShadowRoot}function Xe(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=st(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Ze(e){return/^(table|td|th)$/.test(Ke(e))}function Qe(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}let $e=/transform|translate|scale|rotate|perspective|filter/,et=/paint|layout|strict|content/,tt=e=>!!e&&e!==`none`,nt;function rt(e){let t=Y(e)?st(e):e;return tt(t.transform)||tt(t.translate)||tt(t.scale)||tt(t.rotate)||tt(t.perspective)||!at()&&(tt(t.backdropFilter)||tt(t.filter))||$e.test(t.willChange||``)||et.test(t.contain||``)}function it(e){let t=lt(e);for(;Je(t)&&!ot(t);){if(rt(t))return t;if(Qe(t))return null;t=lt(t)}return null}function at(){return nt??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),nt}function ot(e){return/^(html|body|#document)$/.test(Ke(e))}function st(e){return q(e).getComputedStyle(e)}function ct(e){return Y(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lt(e){if(Ke(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ye(e)&&e.host||qe(e);return Ye(t)?t.host:t}function ut(e){let t=lt(e);return ot(t)?e.ownerDocument?e.ownerDocument.body:e.body:Je(t)&&Xe(t)?t:ut(t)}function dt(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ut(e),i=r===e.ownerDocument?.body,a=q(r);if(i){let e=ft(a);return t.concat(a,a.visualViewport||[],Xe(r)?r:[],e&&n?dt(e):[])}else return t.concat(r,dt(r,[],n))}function ft(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pt(e){let t=st(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Je(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=z(n)!==a||z(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function mt(e){return Y(e)?e:e.contextElement}function ht(e){let t=mt(e);if(!Je(t))return B(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=pt(t),o=(a?z(n.width):n.width)/r,s=(a?z(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}let gt=B(0);function _t(e){let t=q(e);return!at()||!t.visualViewport?gt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vt(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==q(e)?!1:t}function yt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=mt(e),o=B(1);t&&(r?Y(r)&&(o=ht(r)):o=ht(e));let s=vt(a,n,r)?_t(a):B(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=q(a),t=r&&Y(r)?q(r):r,n=e,i=ft(n);for(;i&&r&&t!==n;){let e=ht(i),t=i.getBoundingClientRect(),r=st(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=q(i),i=ft(n)}}return Fe({width:u,height:d,x:c,y:l})}function bt(e,t){let n=ct(e).scrollLeft;return t?t.left+n:yt(qe(e)).left+n}function xt(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-bt(e,n),y:n.top+t.scrollTop}}function St(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=qe(r),s=t?Qe(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=B(1),u=B(0),d=Je(r);if((d||!d&&!a)&&((Ke(r)!==`body`||Xe(o))&&(c=ct(r)),d)){let e=yt(r);l=ht(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?xt(o,c):B(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ct(e){return Array.from(e.getClientRects())}function wt(e){let t=qe(e),n=ct(e),r=e.ownerDocument.body,i=R(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=R(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+bt(e),s=-n.scrollTop;return st(r).direction===`rtl`&&(o+=R(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}function Tt(e,t){let n=q(e),r=qe(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=at();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=bt(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=25&&(a-=o)}else l<=25&&(a+=l);return{width:a,height:o,x:s,y:c}}function Et(e,t){let n=yt(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Je(e)?ht(e):B(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Dt(e,t,n){let r;if(t===`viewport`)r=Tt(e,n);else if(t===`document`)r=wt(qe(e));else if(Y(t))r=Et(t,n);else{let n=_t(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Fe(r)}function Ot(e,t){let n=lt(e);return n===t||!Y(n)||ot(n)?!1:st(n).position===`fixed`||Ot(n,t)}function kt(e,t){let n=t.get(e);if(n)return n;let r=dt(e,[],!1).filter(e=>Y(e)&&Ke(e)!==`body`),i=null,a=st(e).position===`fixed`,o=a?lt(e):e;for(;Y(o)&&!ot(o);){let t=st(o),n=rt(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Xe(o)&&!n&&Ot(e,o))?r=r.filter(e=>e!==o):i=t,o=lt(o)}return t.set(e,r),r}function At(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Qe(t)?[]:kt(t,this._c):[].concat(n),r],o=Dt(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Dt(t,a[e],i);s=R(n.top,s),c=ve(n.right,c),l=ve(n.bottom,l),u=R(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function jt(e){let{width:t,height:n}=pt(e);return{width:t,height:n}}function Mt(e,t,n){let r=Je(t),i=qe(t),a=n===`fixed`,o=yt(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=B(0);function l(){c.x=bt(i)}if(r||!r&&!a)if((Ke(t)!==`body`||Xe(i))&&(s=ct(t)),r){let e=yt(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?xt(i,s):B(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Nt(e){return st(e).position===`static`}function Pt(e,t){if(!Je(e)||st(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return qe(e)===n&&(n=n.ownerDocument.body),n}function Ft(e,t){let n=q(e);if(Qe(e))return n;if(!Je(e)){let t=lt(e);for(;t&&!ot(t);){if(Y(t)&&!Nt(t))return t;t=lt(t)}return n}let r=Pt(e,t);for(;r&&Ze(r)&&Nt(r);)r=Pt(r,t);return r&&ot(r)&&Nt(r)&&!rt(r)?n:r||it(e)||n}let It=async function(e){let t=this.getOffsetParent||Ft,n=this.getDimensions,r=await n(e.floating);return{reference:Mt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lt(e){return st(e).direction===`rtl`}let Rt={convertOffsetParentRelativeRectToViewportRelativeRect:St,getDocumentElement:qe,getClippingRect:At,getOffsetParent:Ft,getElementRects:It,getClientRects:Ct,getDimensions:jt,getScale:ht,isElement:Y,isRTL:Lt};function zt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bt(e,t){let n=null,r,i=qe(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=ye(d),h=ye(i.clientWidth-(u+f)),g=ye(i.clientHeight-(d+p)),_=ye(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:R(0,ve(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!zt(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Vt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=mt(e),u=i||a?[...l?dt(l):[],...t?dt(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Bt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?yt(e):null;c&&g();function g(){let t=yt(e);h&&!zt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}let Ht=Ue,Ut=We,Wt=Be,Gt=ze,Kt=(e,t,n)=>{let r=new Map,i={platform:Rt,...n},a={...i.platform,_c:r};return Re(e,t,{...i,platform:a})},qt=class{constructor(e){n(this,`ctx`),n(this,`enable`,!1),n(this,`contentEl`),n(this,`floatingEl`),n(this,`arrowEl`),this.ctx=e;let{TOOLTIP_BG_COLOR:t,TOOLTIP_TEXT_COLOR:r,TOOLTIP_ZINDEX:i,TOOLTIP_CUSTOM_STYLE:a,CSS_PREFIX:o}=this.ctx.config;this.contentEl=document.createElement(`div`),this.arrowEl=document.createElement(`div`),this.floatingEl=document.createElement(`div`),this.floatingEl.className=`${o}-tooltip`,this.contentEl.className=`${o}-tooltip-content`,this.arrowEl.className=`${o}-tooltip-arrow`;let s={display:`none`,position:`absolute`,background:t,color:r,boxSizing:`border-box`,zIndex:i,padding:`8px`,borderRadius:`4px`,fontSize:`12px`,...a},c={position:`absolute`,width:`10px`,height:`10px`,background:s.background,backgroundColor:s.backgroundColor,transform:`rotate(45deg)`,zIndex:s.zIndex};Object.assign(this.arrowEl.style,c),Object.assign(this.floatingEl.style,s),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`,e=>{this.floatingEl.contains(e.relatedTarget)||this.hide()}),this.ctx.on(`onScroll`,()=>{this.hide()}),this.ctx.on(`startEdit`,()=>{this.hide()}),this.ctx.on(`visibleCellHoverChange`,(e,t)=>{this.floatingEl.contains(t.target)||(e.ellipsis||e.message)&&this.show(e)}),this.ctx.on(`visibleCellMouseleave`,(e,t)=>{this.floatingEl.contains(t.target)||this.hide()}),this.ctx.on(`cellHeaderMouseleave`,(e,t)=>{this.floatingEl.contains(t.target)||this.hide()}),this.ctx.on(`cellHeaderHoverChange`,(e,t)=>{this.floatingEl.contains(t.target)||e.ellipsis&&this.show(e)}),this.ctx.on(`cellFooterMouseleave`,(e,t)=>{this.floatingEl.contains(t.target)||this.hide()}),this.ctx.on(`cellFooterHoverChange`,(e,t)=>{this.floatingEl.contains(t.target)||e.ellipsis&&this.show(e)}),this.ctx.on(`cellShowTooltip`,(e,t)=>{this.show(e,t)}),this.ctx.on(`cellHideTooltip`,()=>{this.hide()})}show(e,t){if(this.ctx.contextMenuIng||!e.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display=`block`;let n=e.getText();e.message&&(n=e.message),t&&(n=t);let r=this.ctx.containerElement.getBoundingClientRect();if(!r)return;this.enable=!0,this.contentEl.style.maxWidth=`${e.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=n;let i=this.ctx.zoomScale.getViewportRect({x:e.drawX,y:e.drawY,width:e.visibleWidth,height:e.visibleHeight},r);Kt({getBoundingClientRect(){return i}},this.floatingEl,{placement:e.overflowTooltipPlacement,middleware:[Ut(),Wt(),Ht(6),Gt({element:this.arrowEl})]}).then(e=>{let{x:t,y:n,placement:r,middlewareData:i}=e;if(Object.assign(this.floatingEl.style,{top:`${n}px`,left:`${t}px`}),i.arrow){let e=i.arrow;[`left`,`left-start`,`left-end`].includes(r)?Object.assign(this.arrowEl.style,{top:`${e.y}px`,bottom:``,left:``,right:`-5px`}):[`right`,`right-start`,`right-end`].includes(r)?Object.assign(this.arrowEl.style,{top:`${e.y}px`,bottom:``,left:`-5px`,right:``}):[`bottom`,`bottom-start`,`bottom-end`].includes(r)?Object.assign(this.arrowEl.style,{top:`-5px`,bottom:``,left:`${e.x}px`,right:``}):[`top`,`top-start`,`top-end`].includes(r)&&Object.assign(this.arrowEl.style,{top:``,bottom:`-5px`,left:`${e.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 Jt{constructor(e){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=e,this.initTextEditor(),this.init()}init(){this.ctx.on(`outsideMousedown`,()=>{this.cellTarget&&this.cellTarget.editorType===`text`&&this.clearEditor()}),this.ctx.on(`moveFocus`,e=>{this.cellTarget=e,this.resetEditorStyle();let{xArr:t,yArr:n}=this.ctx.selector;this.selectorArrStr=JSON.stringify(t)+JSON.stringify(n),this.focusInput()}),this.ctx.on(`onScroll`,()=>{this.enable&&this.doneEdit()}),this.ctx.on(`hoverIconClick`,e=>{this.editCell(e.rowIndex,e.colIndex)}),this.ctx.on(`keydown`,e=>{if(!this.ctx.isTarget(e)||!this.ctx.focusCell||this.ctx.finding)return;let{focusCell:t}=this.ctx;if(e.code===`Escape`&&this.ctx.editing){this.cancel=!0;let{focusCell:e}=this.ctx;e&&(this.ctx.emit(`setSelectorCell`,e),this.cellTarget=e),this.doneEdit();return}if((e.altKey||e.metaKey)&&e.key===`Enter`&&this.ctx.editing&&this.inputEl){e.preventDefault();let t=this.inputEl.selectionStart,n=this.inputEl.value.substring(0,t),r=this.inputEl.value.substring(t);this.inputEl.value=n+`
|
|
16
16
|
`+r,this.inputEl.selectionStart=this.inputEl.selectionEnd=t+1,this.autoSize();return}if(e.code===`Tab`&&this.ctx.editing){if(e.preventDefault(),this.doneEdit(),e.shiftKey){this.ctx.emit(`setMoveFocus`,`LEFT`);return}this.ctx.emit(`setMoveFocus`,`RIGHT`);return}if(e.key===`Enter`&&this.ctx.editing){if(e.preventDefault(),this.doneEdit(),e.shiftKey){this.ctx.emit(`setMoveFocus`,`TOP`);return}this.ctx.emit(`setMoveFocus`,`BOTTOM`);return}if(e.key===`Enter`&&!this.ctx.editing){e.preventDefault(),this.startEdit();return}let n=e.key,r=e.ctrlKey,i=e.altKey,a=e.shiftKey,o=e.metaKey;if(!(r||i||a||o||`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`.split(`.`).includes(n))){if(document.activeElement!==this.inputEl&&t.editorType===`text`){e.preventDefault();return}this.startEdit(!0)}}),this.ctx.on(`cellClick`,e=>{if(this.ctx.stageElement.style.cursor===`pointer`||!this.isInSelectorRange(e.rowIndex,e.colIndex))return;let{xArr:t,yArr:n}=this.ctx.selector,r=JSON.stringify(t)+JSON.stringify(n);if(this.focusInput(),this.selectorArrStr===r&&this.cellTarget){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}if(this.ctx.selectOnlyOne&&e.rowKey===this.cellTarget.rowKey&&e.key===this.cellTarget.key){this.startEdit();return}}if(this.selectorArrStr=r,this.doneEdit(),this.cellTarget=e,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(e,t){let{xArr:n,yArr:r}=this.ctx.selector,[i,a]=n,[o,s]=r;return!(t<i||t>a||e<o||e>s)}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;let e=this.inputEl.value;if(this.cellTarget&&this.cellTarget.type===`number`&&e!==``&&(this.ctx.emit(`cellHideTooltip`),!/^-?\d+(\.\d+)?$/.test(e))){let e=this.ctx.locale.getText(`numberErrorTip`);this.ctx.emit(`cellShowTooltip`,this.cellTarget,e)}this.inputEl.style.height=`auto`;let t=this.inputEl.scrollHeight,n=this.ctx.toLogical(t),r=this.ctx.body.visibleHeight;n>r&&(t=this.ctx.toVisual(r));let{stageHeight:i,footer:a,header:o,config:{SCROLLER_TRACK_SIZE:s}}=this.ctx,c=i-a.height-s;this.editorEl.style.bottom=`auto`,this.drawY<o.height&&(this.editorEl.style.top=this.ctx.toVisualPx(o.height-1)),this.drawY+this.ctx.toLogical(t)>c&&(this.editorEl.style.left=this.ctx.toVisualPx(this.drawX-1),this.editorEl.style.top=`auto`,this.editorEl.style.bottom=this.ctx.toVisualPx(i-c)),this.inputEl.style.height=`${t}px`}startEditByInput(e,t=!1){let n=t?null:e.getValue(),{editorType:r}=e;if(r===`none`)return;e.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&e.updateSpanInfo();let{height:i,width:a,drawY:o,drawX:s}=e;this.drawX=s,this.drawY=o;let{config:{CELL_PADDING:c},header:l}=this.ctx,u=this.ctx.body.visibleHeight;i>u&&(i=u);let d=this.ctx.toVisual(u);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.maxHeight=`${d}px`,[`text`].includes(r)?(this.inputEl.style.opacity=`1`,this.inputEl.style.position=`relative`,this.inputEl.style.minWidth=this.ctx.toVisualPx(a-1),this.inputEl.style.minHeight=this.ctx.toVisualPx(i-1),this.inputEl.style.maxHeight=`${d}px`,this.inputEl.style.width=this.ctx.toVisualPx(a),this.inputEl.style.height=`auto`,this.inputEl.style.padding=this.ctx.toVisualPx(c),this.inputEl.value=``,n!==null&&(this.inputEl.value=n),(this.ctx.toLogical(this.inputEl.scrollHeight)>i||this.drawY<l.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`){let{rowKey:e,key:t}=this.cellTarget,n=this.cellTarget.getValue(),r=this.inputEl.value;r!==n&&!(r===``&&n===null)&&!this.cancel&&this.ctx.setItemValueByEditor(e,t,r,!0)}}focusInput(){document.activeElement!==this.inputEl&&this.inputEl.focus({preventScroll:!0})}startEdit(e=!1){if(this.isTextSelectionActive())return;this.cancel=!1;let{ENABLE_EDIT_CLICK_SELECTOR:t}=this.ctx.config;if(!t)return;let n=this.ctx.focusCell;n&&(n.isVerticalVisible()&&n.isHorizontalVisible()||this.ctx.emit(`scrollToIndex`,n.rowIndex,n.colIndex),this.editCell(n.rowIndex,n.colIndex,e))}editCell(e,t,n=!1){let r=this.ctx.body.renderRows.find(t=>t.rowIndex===e);if(!r)return;let i=r.cells.find(e=>e.colIndex===t);if(!i||!(i.isVerticalVisible()&&i.isHorizontalVisible()))return;this.ctx.emit(`setSelectorCell`,i);let a=this.ctx.focusCell;if(!a||[`index`,`index-selection`,`selection`].includes(a.type)||this.enable)return;let{rowKey:o,key:s}=a,c=this.ctx.database.getReadonly(o,s);a&&!c&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=a,this.startEditByInput(this.cellTarget,n),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(){let e=this.cellTarget;e&&(this.editorEl.style.left=this.ctx.toVisualPx(e.drawX),this.editorEl.style.top=this.ctx.toVisualPx(e.drawY),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 e;(e=this.editorEl)==null||e.remove()}}let Yt=class{constructor(e){n(this,`ctx`),n(this,`emptyEl`),this.ctx=e;let{EMPTY_CUSTOM_STYLE:t}=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:e,headerHeight:n,bodyHeight:r,footerHeight:i})=>{let a=n+(r+i)/2,o={display:e===`empty`?`block`:`none`,top:this.ctx.toVisualPx(a),...t};Object.assign(this.emptyEl.style,o)})}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 Xt{constructor(e){n(this,`ctx`),n(this,`observer`),this.ctx=e,this.init()}arerMapsEqual(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0}init(){this.observer=new MutationObserver(a(()=>{let e=this.ctx.overlayerElement.querySelectorAll(`[data-auto-height="true"]`),t=new Map;e.forEach(e=>{let n=Number(e.getAttribute(`data-row-index`)),r=Number(e.getAttribute(`data-col-index`));if(isNaN(n)||isNaN(r))return;let i=e.getBoundingClientRect(),a=`${n}_${r}`;t.set(a,this.ctx.zoomScale.domHeightToLogical(i.height))});let n=this.ctx.database.getOverlayerAutoHeightMap();if(!this.arerMapsEqual(n,t)){if(this.ctx.database.setOverlayerAutoHeightMap(t),n.size===0&&t.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`,e=>{let t=this.ctx.overlayerElement;t.replaceChildren(),Object.assign(t.style,e.style),e.views.forEach(e=>{let n=document.createElement(`div`);n.className=e.class,this.ctx.zoomScale.assignScaledStyle(n,e.style),e.views.forEach(e=>{let t=document.createElement(`div`);this.ctx.zoomScale.assignScaledStyle(t,e.style),e.cells.forEach(e=>{let n=this.ctx.zoomScale.createOverlayerCellElement(e,this.ctx.config.CSS_PREFIX);t.appendChild(n)}),n.appendChild(t)}),t.appendChild(n)})})}draw(){let e=this.getContainer();this.ctx.emit(`overlayerChange`,e)}destroy(){this.observer&&this.observer.disconnect(),this.ctx.emit(`overlayerChange`,{style:{},views:[]})}getContainer(){let e=this.getHeader(),t=this.getBody(),n=this.getFooter(),r=[],{FOOTER_FIXED:i,FOOTER_POSITION:a}=this.ctx.config;return r=i?a===`top`?[e,n,t]:[e,t,n]:[e,t],{views:r}}getHeader(){let{fixedLeftWidth:e,fixedRightWidth:t,config:{SCROLLER_TRACK_SIZE:n,CSS_PREFIX:r}}=this.ctx,{visibleWidth:i,visibleHeight:a,renderCellHeaders:o}=this.ctx.header,s=[],c=[],l=[];o.forEach(e=>{e.render&&(e.fixed===`left`?c.push(e):e.fixed===`right`?l.push(e):s.push(e))});let u=t-n,d={key:`left`,style:{position:`absolute`,top:`0px`,left:`0px`,overflow:`hidden`,width:`${e}px`,height:`${a}px`},cells:c},f={key:`center`,style:{position:`absolute`,top:`0px`,left:`${e}px`,overflow:`hidden`,width:`${i-e-u+1}px`,height:`${a}px`},cells:s},p={key:`right`,style:{position:`absolute`,top:`0px`,right:`0px`,overflow:`hidden`,width:`${u+1}px`,height:`${a}px`},cells:l};return{type:`header`,class:`${r}-overlayer-header`,style:{position:`relative`,overflow:`hidden`,width:`${i}px`,height:`${a}px`},views:[d,f,p]}}getBody(){let e=[],t=[],n=[],r=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(r=r.concat(this.ctx.footer.renderRows)),r.forEach(r=>{r.cells.forEach(r=>{r.cellType===`footer`&&(r.render=r.renderFooter),r.render&&(r.fixed===`left`?t.push(r):r.fixed===`right`?n.push(r):e.push(r))})});let{fixedLeftWidth:i,fixedRightWidth:a,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:s}}=this.ctx,{visibleWidth:c,visibleHeight:l}=this.ctx.body,u=a-o,d={key:`left`,style:{position:`absolute`,top:`0.5px`,left:`0.5px`,overflow:`hidden`,width:`${i}px`,height:`${l}px`},cells:t},f={key:`center`,style:{position:`absolute`,top:`0.5px`,left:`${i-.5}px`,overflow:`hidden`,width:`${c-i-u}px`,height:`${l}px`},cells:e},p={key:`right`,style:{position:`absolute`,top:`0px`,right:`0px`,overflow:`hidden`,width:`${u}px`,height:`${l}px`},cells:n};return{type:`body`,class:`${s}-overlayer-body`,style:{position:`relative`,overflow:`hidden`,width:`${c}px`,height:`${l}px`},views:[d,f,p]}}getFooter(){let e=[],t=[],n=[];this.ctx.footer.renderRows.forEach(r=>{r.cells.forEach(r=>{r.cellType===`footer`&&r.renderFooter&&(r.render=r.renderFooter,r.fixed===`left`?t.push(r):r.fixed===`right`?n.push(r):e.push(r))})});let{fixedLeftWidth:r,fixedRightWidth:i,config:{SCROLLER_TRACK_SIZE:a,CSS_PREFIX:o}}=this.ctx,{visibleWidth:s,visibleHeight:c}=this.ctx.footer,l=i-a,u={key:`left`,style:{position:`absolute`,top:`0.5px`,left:`0.5px`,overflow:`hidden`,width:`${r}px`,height:`${c}px`},cells:t},d={key:`center`,style:{position:`absolute`,top:`0.5px`,left:`${r-.5}px`,overflow:`hidden`,width:`${s-r-l}px`,height:`${c}px`},cells:e},f={key:`right`,style:{position:`absolute`,top:`0.5px`,right:`0.5px`,overflow:`hidden`,width:`${l}px`,height:`${c}px`},cells:n};return{type:`footer`,class:`${o}-overlayer-footer`,style:{position:`relative`,overflow:`hidden`,width:`${s}px`,height:`${c}px`},views:[u,d,f]}}}class Zt{constructor(e,t=[],r={}){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=e,this.menuData=t,this.onClick=r.onClick,this.boundMouseEnterHandler=e=>this.handleMouseEvent(e,`enter`),this.boundMouseLeaveHandler=e=>this.handleMouseEvent(e,`leave`),this.boundClickHandler=e=>this.handleClick(e),this.createMenu(),this.bindEvents()}createMenu(){this.container.className=`e-virt-table-main-menu`,this.container.style.display=`block`;let e=document.createDocumentFragment();this.menuData.forEach(t=>{e.appendChild(this.createMenuItem(t))}),this.container.appendChild(e)}createMenuItem(e,t=!1){var n;let r=this.createElement(`div`,t?`e-virt-table-submenu-item`:`e-virt-table-menu-item`);r.setAttribute(t?`data-submenu`:`data-menu`,e.value),e.disabled&&r.classList.add(`disabled`);let i=this.createElement(`div`,`e-virt-table-menu-item-content`);if(e.icon){let t=this.createElement(`span`,`e-virt-table-menu-item-icon`);t.innerHTML=e.icon,i.appendChild(t)}else i.classList.add(`menu-item-no-icon`);let a=this.createElement(`span`,`e-virt-table-menu-item-text`);if(a.textContent=e.label||``,i.appendChild(a),r.appendChild(i),(n=e.children)!=null&&n.length){let t=this.createElement(`span`,`e-virt-table-menu-arrow`);t.innerHTML=N,r.appendChild(t);let n=this.createSubmenu(e.children);r._submenu=n,this.container.appendChild(n)}return r}createSubmenu(e){let t=this.createElement(`div`,`e-virt-table-submenu`);return e.forEach(e=>{t.appendChild(this.createMenuItem(e,!0))}),t}createElement(e,t=``){let n=document.createElement(e);return t&&(n.className=t),n}bindEvents(){this.container.addEventListener(`mouseenter`,this.boundMouseEnterHandler,!0),this.container.addEventListener(`mouseleave`,this.boundMouseLeaveHandler,!0),this.container.addEventListener(`click`,this.boundClickHandler)}handleMouseEvent(e,t){e.stopPropagation();let n=e.target.closest(`.e-virt-table-menu-item, .e-virt-table-submenu-item`);n&&(this.container.contains(n)||n.classList.contains(`e-virt-table-submenu-item`))&&(t===`enter`?this.handleHover(n):this.handleLeave(n))}handleHover(e){e.classList.contains(`e-virt-table-menu-item`)&&(this.container.querySelectorAll(`.e-virt-table-menu-item`).forEach(e=>e.classList.remove(`active`)),e.classList.contains(`disabled`)||e.classList.add(`active`));let t=e._submenu||e.querySelector(`.e-virt-table-submenu`);t&&(this.hideSiblingSubmenus(e),this.showSubmenu(e,t))}handleLeave(e){let t=e._submenu||e.querySelector(`.e-virt-table-submenu`);setTimeout(()=>{let n=t;n&&!n.matches(`:hover`)&&!e.matches(`:hover`)&&(this.hideSubmenu(n),e.classList.contains(`e-virt-table-menu-item`)&&e.classList.remove(`active`))},150)}hideSiblingSubmenus(e){let t;if(e.classList.contains(`e-virt-table-menu-item`))t=this.container.querySelectorAll(`.e-virt-table-menu-item`);else{let n=e.closest(`.e-virt-table-submenu`);if(n)t=n.querySelectorAll(`.e-virt-table-submenu-item`);else return}t.forEach(t=>{t!==e&&t._submenu&&this.hideSubmenu(t._submenu)})}async showSubmenu(e,t){this.activeSubmenus.has(t)||(this.activeSubmenus.add(t),t.classList.add(`show`),t._cleanup=Vt(e,t,async()=>{let n=this.container.getBoundingClientRect(),r=window.innerWidth,i=t.offsetWidth||200,a=r-n.right,o=n.left,{x:s,y:c}=await Kt(e,t,{placement:a>=i||a>=o?`right-start`:`left-start`,middleware:[Ht(8),Ut({padding:8})]});Object.assign(t.style,{left:`${s}px`,top:`${c}px`})}))}hideSubmenu(e){if(!this.activeSubmenus.has(e))return;this.activeSubmenus.delete(e),e.classList.remove(`show`),this.hideAllChildSubmenus(e);let t=e;t._cleanup&&(t._cleanup(),delete t._cleanup)}hideAllChildSubmenus(e){e.querySelectorAll(`.e-virt-table-submenu-item`).forEach(e=>{if(e._submenu){let t=e._submenu;if(this.activeSubmenus.has(t)){this.activeSubmenus.delete(t),t.classList.remove(`show`);let e=t;e._cleanup&&(e._cleanup(),delete e._cleanup),this.hideAllChildSubmenus(t)}}})}handleClick(e){e.stopPropagation();let t=e.target.closest(`.e-virt-table-menu-item, .e-virt-table-submenu-item`);if(!t||t.classList.contains(`disabled`))return;if(t.classList.contains(`e-virt-table-menu-item`)){let e=t._submenu||t.querySelector(`.e-virt-table-submenu`);if(e){this.showSubmenu(t,e);return}}let n=t.getAttribute(`data-menu`)||t?.getAttribute(`data-submenu`),r=this.findMenuItem(n||``);r&&this.onClick&&this.onClick(r,n||``)}findMenuItem(e,t=this.menuData){for(let n of t){if(n.value===e)return n;if(n.children){let t=this.findMenuItem(e,n.children);if(t)return t}}return null}positionMenu(e){let t={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};Vt(t,this.container,()=>{Kt(t,this.container,{placement:`right-start`,middleware:[Ht(),Ut(),Wt()]}).then(({x:e,y:t})=>{this.container&&Object.assign(this.container.style,{left:`${e}px`,top:`${t}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(e){let t=this.container.querySelector(`[data-menu="${e}"]`);if(!t)return!1;let n=t.querySelector(`.e-virt-table-submenu`);return n&&this.cleanupSubmenuRecursively(n),t.remove(),!0}removeSubMenuItem(e){let t=this.container.querySelector(`[data-submenu="${e}"]`);if(!t)return!1;let n=t.closest(`.e-virt-table-submenu`),r=t._submenu;if(r&&this.cleanupSubmenuRecursively(r),t.remove(),n&&n.querySelectorAll(`.e-virt-table-submenu-item`).length===0){let e=this.container.querySelector(`[data-menu]`);if(e&&e._submenu===n)this.removeMenuItem(e.getAttribute(`data-menu`)||``);else{let e=this.container.querySelectorAll(`[data-menu], [data-submenu]`);for(let t of e)if(t._submenu===n){let e=t.getAttribute(`data-menu`)||t.getAttribute(`data-submenu`);e&&(t.hasAttribute(`data-menu`)?this.removeMenuItem(e):this.removeSubMenuItem(e));break}}}return!0}cleanupAllSubmenus(e){e.querySelectorAll(`.e-virt-table-menu-item`).forEach(e=>{e._submenu&&=(this.cleanupSubmenuRecursively(e._submenu),void 0)})}cleanupSubmenuRecursively(e){let t=e;t._cleanup&&(t._cleanup(),delete t._cleanup),e.querySelectorAll(`.e-virt-table-submenu-item`).forEach(e=>{e._submenu&&this.cleanupSubmenuRecursively(e._submenu)}),e.remove()}}class Qt{constructor(e){n(this,`ctx`),n(this,`contextMenuEl`),n(this,`currentDOMTreeMenu`),n(this,`isCustom`,!1),this.ctx=e,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(e,t)=>{if(this.isCustom){this.contextMenuEl.style.display=`block`,this.positionMenu(t);return}let{ENABLE_CONTEXT_MENU:n,CUSTOM_BODY_CONTEXT_MENU:r,CONTEXT_MENU:i,BEFORE_BODY_CONTEXT_MENU_METHOD:a}=this.ctx.config,o=i.map(e=>({...e,label:e.label||this.ctx.locale.getText(e.value)}));if(o=[...o,...r],a&&(o=await a({list:o,cell:e,hide:this.hide.bind(this)})),!n||o.length===0)return;t.preventDefault();let{xArr:s,yArr:c}=this.ctx.selector,[l,u]=s,[d,f]=c,{rowIndex:p,colIndex:m}=e;p>=d&&p<=f&&m>=l&&m<=u||this.ctx.emit(`setSelectorCell`,e,t),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy(),this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new Zt(this.contextMenuEl,o,{onClick:(n,r)=>{r===`copy`?(this.ctx.emit(`contextMenuCopy`),this.hide()):r===`paste`?(this.ctx.emit(`contextMenuPaste`),this.hide()):r===`cut`?(this.ctx.emit(`contextMenuCut`),this.hide()):r===`clearSelected`?(this.ctx.emit(`contextMenuClearSelected`),this.hide()):n.event&&n.event(t,{hide:this.hide.bind(this),cell:e})}}),this.currentDOMTreeMenu.positionMenu(t)}),this.ctx.on(`cellHeaderContextMenuClick`,async(e,t)=>{if(this.isCustom){this.contextMenuEl.style.display=`block`,this.positionMenu(t);return}let{SELECTOR_AREA_MIN_X:n,SELECTOR_AREA_MAX_X:r,SELECTOR_AREA_MAX_X_OFFSET:i,BEFORE_HEADER_CONTEXT_MENU_METHOD:a}=this.ctx.config,o=n,s=r||this.ctx.maxColIndex-i;if(e.colIndex<o||e.colIndex>s)return;let{HEADER_CONTEXT_MENU:c,CUSTOM_HEADER_CONTEXT_MENU:u,ENABLE_HEADER_CONTEXT_MENU:d}=this.ctx.config,f=c.map(e=>({...e,label:e.label||this.ctx.locale.getText(e.value)}));if(f=[...f,...u],a&&(f=await a({list:f,cell:e,hide:this.hide.bind(this)})),!d||f.length===0)return;t.preventDefault();let{xArr:p}=this.ctx.selector,[m,h]=p,{colIndex:g}=e;g>=m&&g<=h||(this.ctx.focusCellHeader=e,this.ctx.emit(`selectCols`,e)),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy();let _=this.ctx.database.getColumns(),v=f.map(e=>e.value===`visible`?{...e,children:this.filterColumns(_)}:e);this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new Zt(this.contextMenuEl,v,{onClick:(n,r)=>{let{xArr:i}=this.ctx.selector,[a,o]=i;if(r===`fixedLeft`||r===`fixedRight`||r===`fixedNone`){let e=this.ctx.header.allCellHeaders.filter(e=>e.colIndex>=a&&e.colIndex<=o).filter(e=>e.level===0).filter(e=>!e.column.fixedDisabled).map(e=>e.key);this.ctx.database.setCustomHeaderFixedData(e,r===`fixedLeft`?`left`:r===`fixedRight`?`right`:``),this.hide()}else if(r===`hide`){let e=this.ctx.header.leafCellHeaders.filter(e=>e.colIndex>=a&&e.colIndex<=o).filter(e=>!e.children.length).filter(e=>!e.column.hideDisabled).map(e=>e.key);e.length>0&&this.ctx.database.setCustomHeaderHideData(e,!0),this.hide()}else if(r!==`visible`)if(r.startsWith(`visible_`)){if(!n.key)return;if(n.children){let e=this.getLeafKeys(n.children);this.ctx.database.setCustomHeaderHideData(e,!1)}else this.ctx.database.setCustomHeaderHideData([n.key],!1);this.currentDOMTreeMenu&&this.currentDOMTreeMenu.removeSubMenuItem(r),l(this.ctx.database.getColumns()).filter(e=>e.hide).length===0&&this.hide()}else r===`resetHeader`?(this.ctx.database.resetCustomHeader(),this.hide()):n.event&&n.event(t,{hide:this.hide.bind(this),cell:e})}}),this.positionMenu(t)}),this.ctx.on(`click`,()=>{this.hide()}),this.ctx.on(`onScroll`,this.hide.bind(this)),this.ctx.on(`resize`,this.hide.bind(this))}positionMenu(e){let t={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};Vt(t,this.contextMenuEl,()=>{Kt(t,this.contextMenuEl,{placement:`right-start`,middleware:[Ht(),Ut(),Wt()]}).then(({x:e,y:t})=>{this.contextMenuEl&&Object.assign(this.contextMenuEl.style,{left:`${e}px`,top:`${t}px`})})})}filterColumns(e){let t=[];for(let n of e)if(n.children&&n.children.length>0){let e=this.filterColumns(n.children);e.length>0&&t.push({label:n.title,key:n.key,value:`visible_${n.key}`,children:e})}else n.hide&&t.push({label:n.title,value:`visible_${n.key}`,key:n.key});return t}getLeafKeys(e){return e.reduce((e,t)=>(!t.children||t.children.length===0?e.push(String(t.key)):e.push(...this.getLeafKeys(t.children)),e),[])}hide(){this.currentDOMTreeMenu&&=(this.currentDOMTreeMenu.destroy(),void 0),this.contextMenuEl.style.display=`none`,this.ctx.contextMenuIng=!1}destroy(){var e;this.hide(),(e=this.contextMenuEl)==null||e.remove()}}class $t{constructor(e){if(n(this,`ctx`),n(this,`loadingEl`),n(this,`textEl`,document.createElement(`p`)),this.ctx=e,this.ctx.loadingElement)this.loadingEl=this.ctx.loadingElement;else{this.loadingEl=document.createElement(`div`);let e=document.createElement(`div`);e.className=`e-virt-table-loading-spinner`;let t=this.ctx.icons.getSvg(`loading`);if(t){let n=new DOMParser().parseFromString(t.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 en{constructor(e){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=e,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(()=>{let{allCellHeaders:e}=this.ctx.header;for(let t=0;t<e.length;t++){let n=e[t];n&&[`string`,`number`].includes(typeof n.text)&&this.searchData.push({rowIndex:0,colIndex:n.colIndex,text:`${n.text}`,type:`header`,colKey:n.key})}let{maxColIndex:t,maxRowIndex:n}=this.ctx;for(let e=0;e<=n;e++)for(let n=0;n<=t;n++){let t=this.ctx.database.getVirtualBodyCell(e,n,!1)?.getText();[`string`,`number`].includes(typeof t)&&this.searchData.push({rowIndex:e,colIndex:n,text:`${t}`,type:`body`})}this.hideLoading()},0)}createContainer(){let e=document.createElement(`div`);e.className=`e-virt-table-finder-bar`;let t=document.createElement(`div`);t.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=``,t.appendChild(this.input),this.loadingEl=document.createElement(`div`),this.loadingEl.className=`e-virt-table-finder-bar-loading`,this.loadingEl.innerHTML=`<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>
|
|
17
|
-
`,t.appendChild(this.loadingEl),this.countEl=document.createElement(`span`),this.countEl.className=`e-virt-table-finder-bar-count`;let n=document.createElement(`div`);return n.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=N,this.nextBtn=document.createElement(`button`),this.nextBtn.className=`e-virt-table-finder-bar-nav-btn next-btn`,this.nextBtn.innerHTML=N,n.appendChild(this.prevBtn),n.appendChild(this.nextBtn),this.closeBtn=document.createElement(`button`),this.closeBtn.className=`e-virt-table-finder-bar-nav-btn close-btn`,this.closeBtn.innerHTML=`×`,e.appendChild(t),e.appendChild(this.countEl),e.appendChild(n),e.appendChild(this.closeBtn),e}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(){let e=this.input.value.trim();if(this.searchResults=[],this.currentIndex=-1,!e){this.cearFinderBar(),this.updateCount();return}this.showLoading(),setTimeout(()=>{this.searchResults=this.searchData.filter(t=>t.text.toLowerCase().includes(e.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;let e=this.searchResults[this.currentIndex];this.ctx.finderBar=e;let{rowIndex:t,colIndex:n}=e;this.ctx.emit(`scrollToIndex`,t,n)}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{let e=this.currentIndex+1,t=this.searchResults.length;this.countEl.textContent=`${e}/${t}`,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 e;this.loadingEl.classList.add(`show`),(e=this.loadingEl.parentElement)==null||e.classList.add(`loading`),this.input.readOnly=!0}hideLoading(){var e;this.loadingEl.classList.remove(`show`),(e=this.loadingEl.parentElement)==null||e.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()}}let tn=class e{constructor(e){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=e,this.ctx.on(`registerTextLayout`,(e,t)=>this.layouts.set(e,t)),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(e){let t=this.ctx.focusCellHeader;if(!(!this.ctx.textSelecting||!t)){if(e){let n=t.colIndex,r=t.colIndex+t.colspan-1,i=e.colIndex,a=e.colIndex+e.colspan-1;if(i>=n&&a<=r)return}this.resetSelection()}}onMouseDown(e){if(!this.canSelect||!this.ctx.isTarget(e))return;this.ctx.containerElement.contains(document.activeElement)||this.ctx.containerElement.focus({preventScroll:!0});let t=this.hitTest(e);if(!t){this.resetSelection();return}let{offsetX:n,offsetY:r}=this.ctx.getOffset(e);this.pending={cellKey:t.cellKey,index:t.index,startX:n,startY:r}}onMouseMove(e){if(!this.canSelect||(this.ctx.textSelecting||this.tryStartDrag(e),!this.ctx.textSelecting))return;let t=this.layouts.get(this.activeCellKey);if(!t)return;let{offsetX:n,offsetY:r}=this.ctx.getOffset(e),i=this.hitTestText(t,n,r);i!==null&&(this.selectionEnd=i,this.updateSelection())}tryStartDrag(t){if(!this.pending||!this.ctx.mousedown)return;let{offsetX:n,offsetY:r}=this.ctx.getOffset(t),i=Math.abs(n-this.pending.startX),a=Math.abs(r-this.pending.startY);if(i<e.DRAG_THRESHOLD&&a<e.DRAG_THRESHOLD)return;let o=this.hitTest(t);if(!o||o.cellKey!==this.pending.cellKey){this.pending=null;return}this.activeCellKey=this.pending.cellKey,this.selectionStart=this.pending.index,this.selectionEnd=o.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(e){var t;if(!this.canSelect||!((e.ctrlKey||e.metaKey)&&e.code===`KeyC`))return;let n=this.getSelectedText();n&&(e.preventDefault(),(t=navigator.clipboard)==null||t.writeText(n).catch(e=>console.error(`Copy Failure:`,e)))}hitTest(e){let{offsetX:t,offsetY:n}=this.ctx.getOffset(e),r=null;for(let[e,i]of this.layouts){let a=this.hitTestText(i,t,n);a!==null&&(r={cellKey:e,index:a})}return r}updateSelection(){this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.emit(`drawView`)}hitTestText(e,t,n){let{glyphs:r,contentY:i,lineHeight:a,lines:o}=e;if(!r.length)return null;let s=Math.floor((n-i)/a);if(s<0||s>=o.length)return null;let c=r.filter(e=>e.line===s);if(!c.length)return null;let l=i+s*a;if(n<l-2||n>=l+a+2)return null;let u=c[0],d=c[c.length-1];if(t<u.x-2||t>d.x+d.width+2)return null;if(t<=u.x)return u.index;for(let e of c)if(t<e.x+e.width/2)return e.index;return d.index+1}clearLayouts(){this.layouts.clear()}draw(){if(!this.ctx.config.ENABLE_TEXT_SELECTION)return;let e=this.getSelectionRange(),t=e&&this.layouts.get(this.activeCellKey);t&&this.drawTextSelection(t,e)}drawTextSelection(e,t,n=`#fff`,r=`#3b82f6`){if(t.start>=t.end)return;let i=new Map;for(let n of e.glyphs){if(n.index<t.start||n.index>=t.end)continue;let e=i.get(n.line)??[];e.push(n),i.set(n.line,e)}if(!i.size)return;let a=this.ctx.paint.getCtx();a.save(),a.font=e.font,a.textBaseline=`top`,a.textAlign=`left`,i.forEach(e=>{let t=e[0],i=e[e.length-1];a.fillStyle=r,a.fillRect(t.x,t.y-1,i.x+i.width-t.x,t.height),a.fillStyle=n;for(let t of e)a.fillText(t.char,t.x,t.y)}),a.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(){let e=this.getSelectionRange(),t=e&&this.layouts.get(this.activeCellKey);return!t||e.start>=e.end?``:t.chars.slice(e.start,e.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(tn,`DRAG_THRESHOLD`,4);let nn=tn,rn=class e{constructor(e,t){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=t;let{overlayerElement:r,editorElement:i,emptyElement:a,contextMenuElement:o}=this.options,s=this.createContainer(e,r,i,a,o);this.ctx=new se(s,this.options),this.textSelector=new nn(this.ctx),this.header=new fe(this.ctx),this.footer=new he(this.ctx),this.body=new me(this.ctx),this.scroller=new le(this.ctx),this.selector=new ge(this.ctx),this.autofill=new _e(this.ctx),this.tooltip=new qt(this.ctx),this.empty=new Yt(this.ctx),this.editor=new Jt(this.ctx),this.overlayer=new Xt(this.ctx),this.contextMenu=new Qt(this.ctx),this.loading=new $t(this.ctx),this.finderBar=new en(this.ctx),this.ctx.on(`loadData`,e=>{this.loadData(e)}),this.ctx.on(`draw`,()=>{this.draw()}),this.ctx.on(`drawView`,()=>{this.draw(!0)}),this.draw()}static useLocale(t){e.locale=t}createContainer(e,t,n,r,i){e.className=`e-virt-table-container`;let a=document.createElement(`div`),o=document.createElement(`canvas`),s=t||document.createElement(`div`);a.className=`e-virt-table-stage`,e.tabIndex=0,o.className=`e-virt-table-canvas`,s.className=`e-virt-table-overlayer`,s.setAttribute(`data-overlayer`,t?`custom`:`default`);let c=n||document.createElement(`div`);c.className=`e-virt-table-editor`;let l=r,u=i;return a.appendChild(o),a.appendChild(s),e.appendChild(a),{containerElement:e,stageElement:a,canvasElement:o,overlayerElement:s,editorElement:c,emptyElement:l,contextMenuElement:u}}doDraw(e=!1){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(),e||this.overlayer.draw()}draw(e=!1){this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=requestAnimationFrame(()=>{this.doDraw(e),this.body.updateAutoHeight()&&this.doDraw(e)})}loadConfig(e){this.ctx.config.init(e),this.ctx.database.init(!1),this.header.init(),this.ctx.emit(`draw`)}loadColumns(e){this.editor.doneEdit(),this.ctx.database.setColumns(e),this.header.init(),this.ctx.emit(`draw`)}loadData(e){this.editor.doneEdit(),this.ctx.database.setData(e),this.header.init(),this.tooltip.hide(),this.ctx.emit(`draw`)}loadFooterData(e){this.ctx.database.setFooterData(e),this.ctx.emit(`draw`)}setCustomHeader(e,t=!0){this.ctx.database.setCustomHeader(e,t),this.header.init(),this.ctx.emit(`draw`)}getCustomHeader(){return this.header.getCustomHeader()}showColumns(e,t=!0){this.ctx.database.setCustomHeaderHideData(e,!t),this.header.init(),this.ctx.emit(`draw`)}fixedColumns(e,t){this.ctx.database.setCustomHeaderFixedData(e,t),this.header.init(),this.ctx.emit(`draw`)}setLoading(e){this.ctx.loading=e,e?this.loading.show():this.loading.hide()}on(e,t){this.ctx.on(e,t)}emit(e,...t){this.ctx.emit(e,...t)}off(e,t){this.ctx.off(e,t)}filterMethod(e){this.ctx.database.setFilterMethod(e),this.ctx.database.init(!1),this.header.init(),this.ctx.emit(`draw`)}editCell(e,t){this.editor.editCell(e,t)}setItemValue(e,t,n,r=!0,i=!0,a=!1){this.ctx.database.setItemValue(e,t,n,r,i,a)}batchSetItemValue(e,t=!0){this.ctx.database.batchSetItemValue(e,t)}setItemValueByEditor(e,t,n,r=!0,i=!0){this.ctx.setItemValueByEditor(e,t,n,r,i),this.editor.doneEdit()}clearEditableData(e=null){let t=[0,this.ctx.maxColIndex],n=[0,this.ctx.maxRowIndex];return this.selector.clearSelectedData(t,n,!1,e)}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit(`draw`)}setZoom(e){this.ctx.setZoom(e)}getZoom(){return this.ctx.getZoom()}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}setCurrentRowByRowIndex(e){this.ctx.currentCell=this.ctx.database.getVirtualBodyCell(e,0),this.ctx.emit(`draw`)}setCurrentRow(e){let t=this.ctx.database.getColumnByColIndex(0);t&&(this.ctx.currentCell=this.ctx.database.getVirtualBodyCellByKey(e,t.key),this.ctx.emit(`draw`))}getCurrentRow(){let e=this.ctx.currentCell;return e?{row:e.row,rowIndex:e.rowIndex,rowKey:e.rowKey}:void 0}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit(`draw`)}validateFields(e,t=!0){return new Promise(async(n,r)=>{let i=[];for(let t=0;t<e.length;t++){let{rowKey:n,key:r}=e[t],a=await this.ctx.database.getValidator(n,r);Array.isArray(a)&&a.length&&i.push(a)}if(i.length){if(r(i),t){let[e]=i;if(Array.isArray(e)&&e.length){let[t]=e,{rowKey:n,key:r}=t;this.scrollToRowkey(n),this.scrollToColkey(r)}}this.ctx.emit(`draw`)}else n([]),this.ctx.emit(`draw`)})}async validate(e=!0){return new Promise(async(t,n)=>{try{t(await this.getValidations())}catch(t){if(e&&Array.isArray(t)&&t.length){let[e]=t;if(Array.isArray(e)&&e.length){let[t]=e,{rowKey:n,key:r}=t,i=this.ctx.database.getRowForRowKey(n);if(i){let{parentRowKeys:e=[]}=i;e&&e.length&&this.setExpandRowKeys(e,!0)}this.scrollToRowkey(n),this.scrollToColkey(r)}}n(t)}})}setValidations(e){if(e.forEach(e=>{let{rowIndex:t,key:n,message:r,rowKey:i}=e;if(t!==void 0&&i===void 0){let e=this.ctx.database.getRowKeyForRowIndex(t);this.ctx.database.setValidationErrorByRowKey(e,n,r)}i&&this.ctx.database.setValidationErrorByRowKey(i,n,r)}),e&&Array.isArray(e)&&e.length){let[t]=e;if(t&&t.rowKey)this.scrollToRowkey(t.rowKey),this.scrollToColkey(t.key);else if(t&&t.rowIndex!==void 0&&t.rowIndex>=0&&t.key){let{rowIndex:e,key:n}=t;this.scrollToRowIndex(e),this.scrollToColkey(n)}}}getValidations(){return this.ctx.config.DISABLED?new Promise(e=>{e([])}):new Promise(async(e,t)=>{let n=this.ctx.database.getAllRowsData(),r=this.ctx.header.leafCellHeaders,i=[];for(let e=0;e<n.length;e++)for(let t=0;t<r.length;t++){let a=this.ctx.database.getRowKeyByItem(n[e]),o=r[t].key,s=await this.ctx.database.getValidator(a,o);Array.isArray(s)&&s.length&&i.push(s)}i.length?(t(i),this.ctx.emit(`draw`)):(e([]),this.ctx.emit(`draw`))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(e,t){this.scroller.setScroll(e,t)}scrollXTo(e){this.scroller.setScrollX(e)}scrollToColkey(e){this.scroller.scrollToColkey(e)}scrollToRowkey(e){this.scroller.scrollToRowKey(e)}scrollToColIndex(e){this.scroller.scrollToColIndex(e)}scrollToRowIndex(e){this.scroller.scrollToRowIndex(e)}scrollYTo(e){this.scroller.setScrollY(e)}setExpandRowKeys(e,t=!0){this.ctx.database.setExpandRowKeys(e,t)}getExpandRowKeys(){return this.ctx.database.getExpandRowKeys()}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit(`draw`)}toggleRowSelection(e){let t=this.ctx.database.getRowKeyByItem(e);this.ctx.database.toggleRowSelection(t),this.ctx.emit(`draw`)}setSelectionByRows(e,t=!0){e.forEach(e=>{let n=this.ctx.database.getRowKeyByItem(e);this.ctx.database.setRowSelection(n,t,!1)}),this.ctx.emit(`selectionChange`,this.getSelectionRows()),this.ctx.emit(`draw`)}setSelectionByRowKeys(e,t=!0){e.forEach(e=>{this.ctx.database.setRowSelection(e,t,!1)}),this.ctx.emit(`selectionChange`,this.getSelectionRows()),this.ctx.emit(`draw`)}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit(`draw`)}toggleRowExpand(e,t){this.ctx.database.expandItem(e,t),this.ctx.emit(`draw`)}toggleExpandAll(e){this.ctx.database.expandAll(e),this.ctx.emit(`draw`)}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(e){return this.ctx.database.getPositionForRowIndex(e)}getCellValue(e,t){return this.ctx.database.getItemValue(e,t)}getCellValueByIndex(e,t){return this.ctx.database.getItemValueForRowIndexAndColIndex(e,t)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:y,mergeRowCell:v,getSpanArrByRow:g,getSpanObjByColumn:_}}getColumnByKey(e){return this.ctx.database.getColumnByKey(e)?.column}clearChangeData(){this.ctx.database.clearChangeData(),this.ctx.emit(`draw`)}getReadonly(e,t){return this.ctx.database.getReadonly(e,t)}useLocale(e){this.ctx.locale.use(e)}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(rn,`locale`);let an=rn;return an}))}))(),1),Yi=(0,l.defineComponent)((e,{emit:t})=>{let{cellRender:n,renderTableParams:r}=e,{row:i,field:a}=r;if(a){let e=(0,l.ref)(i[a]);return()=>vi.renders[n.name]?.renderEdit?.(e,n,r,t)??null}else return()=>null},{name:`RenderEditCell`,props:[`cellRender`,`renderTableParams`],emits:[`blur`]}),Xi=(0,l.defineComponent)({__name:`PCanvasTable`,props:{columns:{},data:{},config:{default:()=>({})},footerData:{},loading:{type:Boolean}},emits:[`change`,`selectionChange`,`ready`],setup(e,{expose:t,emit:n}){let r=n,i=(0,l.ref)([]),a=e,o=Kr(),s=(0,l.computed)(()=>({...a,config:{AUTO_ROW_HEIGHT:!0,DISABLED:!0,...o,...a.config}})),c=null,u=(0,l.useAttrs)(),d=(0,l.ref)(null),f=(0,l.ref)(null),p=(0,l.ref)(null),m=(0,l.ref)(null),h=(0,l.ref)(),g=(0,l.ref)(`text`),_=(0,l.ref)(),v={},y={},b=(0,l.computed)(()=>{let e=h.value;return e?{width:`${e.width}px`,height:`${e.height}px`}:{}}),x=e=>ri[e]||(({cellValue:e})=>e),S=e=>vi.renders[e]?.renderDefault,C=(e,...t)=>({row:n,rowIndex:r,value:i})=>e({row:n,rowIndex:r,cellValue:i},...t),w=e=>{if(e.slots?.default&&(0,Z.isFunction)(e.slots?.default))return t=>e.slots?.default?.({row:t.row,column:e,rowIndex:t.rowIndex});if(e.slots?.default&&(0,Z.isString)(e.slots?.default))return`slot:${e.slots?.default}`;if(e.cellRender&&e.cellRender.name)return t=>S(e.cellRender.name)?.(e.cellRender,{data:a.data,row:t.row,rowIndex:t.rowIndex,field:e.field||t.column.key,title:t.column?.title??``},{})},T=e=>{if(e.slots?.title&&(0,Z.isFunction)(e.slots?.title))return t=>e.slots?.title?.({column:e})},E=e=>(e.slots?.edit&&(e.field||e.key)&&(0,Z.isFunction)(e.slots?.edit)?v[`__slot:${e.field||e.key}`]=e:e.editRender?.name&&(e.field||e.key)&&(y[e.field||e.key]=e.editRender),{...(0,Z.omit)(e,[`formatter`]),key:e.key||e.field||Nr(),formatter:(0,Z.isString)(e.formatter)?C(x(e.formatter)):(0,Z.isArray)(e.formatter)&&(0,Z.isString)(e.formatter[0])?C(x(e.formatter[0]),...e.formatter.slice(1)):(0,Z.isFunction)(e.formatter)?C(e.formatter):void 0,editorType:e.editorType??(e.slots?.edit&&(e.field||e.key)&&(0,Z.isFunction)(e.slots?.edit)?`__slot:${e.field||e.key}`:e.editRender?.name?e.editRender.name:void 0),render:w(e),renderHeader:T(e),children:e.children?.map(e=>E(e))});(0,l.onMounted)(()=>{d.value&&(c=new Ji.default(d.value,{config:s.value.config,columns:a.columns.map(e=>E(e)),data:a.data,footerData:a.footerData,emptyElement:p.value||void 0,overlayerElement:m.value||void 0,editorElement:f.value||void 0}),Object.keys(u).forEach(e=>{let t=u[e];if(typeof t==`function`&&e.startsWith(`on`)){let n=e.charAt(2).toLowerCase()+e.slice(3);c?.on(n,t)}}),c.on(`change`,e=>{r(`change`,e)}),c.on(`overlayerChange`,e=>{_.value=e,console.log(`overlayerChange`,e)}),c.on(`startEdit`,e=>{h.value=e,g.value=e.editorType,g.value}),c.on(`doneEdit`,()=>{g.value=`text`}),c.on(`selectionChange`,e=>{i.value=e,r(`selectionChange`,e)}),r(`ready`,c))});function D(e){if(!c||!h.value)return;let{rowKey:t,key:n}=h.value;c?.setItemValueByEditor(t,n,e)}let O=()=>document.body;return(0,l.watch)(()=>a.data,e=>{c?.loadData(e)},{deep:!0}),ti(()=>a.columns,(e,t)=>{(0,Z.isEqual)(e,t)||c?.loadColumns(e.map(e=>E(e)))},{deep:!0}),(0,l.watch)(()=>s.value.config,e=>{c?.loadConfig(e)},{deep:!0}),(0,l.watch)(()=>a.footerData,e=>{c?.loadFooterData(e||[])},{deep:!0}),(0,l.watch)(()=>a.loading,(e,t)=>{e!==t&&c?.setLoading(e)},{immediate:!0}),t({$table:c,selectedRecords:(0,l.computed)(()=>i.value),reloadData:()=>{c?.loadData(a.data)}}),(t,n)=>{let r=(0,l.resolveComponent)(`a-empty`),i=(0,l.resolveComponent)(`a-spin`);return(0,l.openBlock)(),(0,l.createBlock)(i,{spinning:e.loading},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableRef`,ref:d},[(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableEditorRef`,ref:f},[g.value.startsWith(`__slot:`)?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(v[g.value].slots.edit({row:h.value.row,column:v[g.value],rowIndex:h.value.rowIndex})),{key:0,bordered:!1,style:(0,l.normalizeStyle)(b.value),class:`ev-editor-wrapper`,"get-popup-container":O,value:h.value.value,"onUpdate:value":n[0]||=e=>h.value.value=e,cell:h.value,onBlur:D},null,40,[`style`,`value`,`cell`])):(0,l.unref)(vi).renders[g.value]?.renderEdit?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(Yi),{key:1,"cell-render":y[h.value.key],class:`ev-editor-wrapper`,style:(0,l.normalizeStyle)(b.value),"render-table-params":{data:a.data,row:h.value?.row,rowIndex:h.value?.rowIndex??-1,field:h.value?.key??``,title:h.value?.column?.title??``},bordered:!1,"get-popup-container":O,onBlur:D},null,8,[`cell-render`,`style`,`render-table-params`])):(0,l.createCommentVNode)(``,!0)],512),(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableEmptyRef`,ref:p},[(0,l.renderSlot)(t.$slots,`empty`,{},()=>[(0,l.createVNode)(r,{description:`空数据`})])],512),(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableOverlayerRef`,ref:m},[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(_.value?.views||[],e=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{class:(0,l.normalizeClass)(e.class),style:(0,l.normalizeStyle)(e.style),key:e.type},[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.views,e=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{style:(0,l.normalizeStyle)(e.style),key:e.key},[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.cells,e=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,(0,l.mergeProps)({class:`canvas-cell`,key:`${e.rowKey}_${e.key}`,style:{...e.style}},{ref_for:!0},e.domDataset),[typeof e.render==`function`?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(e.render(e)),{key:0,bordered:!1})):typeof e.render==`string`&&e.render.startsWith(`slot:`)?(0,l.renderSlot)(t.$slots,e.render.replace(`slot:`,``),(0,l.mergeProps)({key:1,ref_for:!0},e,{cell:e})):(0,l.createCommentVNode)(``,!0)],16))),128))],4))),128))],6))),128))],512)],512)]),_:3},8,[`spinning`])}}}),Zi={key:0},Qi={key:1,class:`p-canvas-toolbar-wrapper flex items-center w-full justify-between p-theme-bg pt-8px px-16px`},$i={class:`flex items-center flex-1 gap-4px`},ea={class:`flex items-center gap-4px`},ta={class:`flex items-center gap-4px`},na={key:2},ra={class:`flex items-center gap-4px`},ia={class:`flex items-center gap-4px`},aa={key:0,class:`w-full text-slate-5 pl-4`},oa=(0,l.defineComponent)({__name:`PCanvasGrid`,props:{staticConfig:{},manualFetch:{type:Boolean},formConfig:{},columns:{},toolbarConfig:{},pageConfig:{},proxyConfig:{},config:{},lazyReset:{type:Boolean,default:()=>Gr().lazyReset??!1},fitHeight:{default:()=>Gr().fitCanvasHeight??0},autoBoxSize:{type:Boolean,default:!1},autoBoxSizeOffset:{}},emits:[`toolbarButtonClick`,`toolbarToolClick`,`pick`,`resetQuery`],setup(e,{expose:t,emit:n}){let r=e,i=(0,l.useAttrs)(),a=n,{formConfig:o,pageConfig:s,columns:c,toolbarConfig:f,proxyConfig:p,config:m,staticConfig:h}=(0,l.toRefs)(r),g=Kr(),_=(0,l.computed)(()=>r.autoBoxSizeOffset??Gr().autoBoxSizeOffset),v=(0,l.ref)(Nr()),y=(0,l.ref)({}),b=(0,l.computed)(()=>({...r,config:{...g,...r.config}})),x=(0,l.computed)(()=>p.value&&p.value.ajax?s.value?`pagination`:`list`:`bad`);(0,l.computed)(()=>x.value===`pagination`?{current:w.page,total:E.value,pageSize:w.size,responsive:!1,showSizeChanger:!0,showTotal:e=>`共${e}条数据`}:!1);let S=(0,l.computed)(()=>(0,Z.omit)({labelCol:Xr,...o.value},[`items`])),C=(0,l.reactive)({toolbar:!1,form:!1,table:!1}),w=(0,l.reactive)({page:1,size:s.value?.pageSize??10}),T=(0,l.ref)(0),E=(0,l.ref)(0),D=(0,l.ref)([]),O=(0,l.ref)(),k=(0,l.ref)(),A=(0,l.ref)(),j=(0,l.ref)(),M=(0,l.ref)(),N=(0,l.ref)(),ee=(0,l.ref)(),P=(0,l.ref)(500),F=(0,l.ref)({}),te=e=>{F.value[w.page]=e},I=(0,l.reactive)([...(r.toolbarConfig?.buttons?.map(e=>e.code)??[]).filter(e=>e),...(r.toolbarConfig?.tools?.map(e=>e.code)??[]).filter(e=>e)].reduce((e,t)=>(e[t]=!1,e),{})),ne=(e,t)=>{I[e]=t},re=e=>{(0,Z.isObject)(e)?(Object.prototype.hasOwnProperty.call(e,`toolbar`)&&(C.toolbar=e.toolbar),Object.prototype.hasOwnProperty.call(e,`form`)&&(C.form=e.form),Object.prototype.hasOwnProperty.call(e,`table`)&&(C.table=e.table)):(0,Z.isBoolean)(e)&&(C.form=e,C.toolbar=e,C.table=e)},ie=(0,l.computed)(()=>(0,Z.uniq)(Object.values(F.value).flat(),e=>e[b.value.config?.ROW_KEY??`id`])),ae=()=>{fe()},oe=(0,l.computed)(()=>ie.value.map(e=>e[b.value.config?.ROW_KEY??`id`])),L=(e,t)=>t?{list:(0,Z.isString)(t.list)?(0,Z.get)(e,t.list):(0,Z.isFunction)(t.list)?t.list(e):void 0,total:(0,Z.isString)(t.total)?(0,Z.get)(e,t.total):(0,Z.isFunction)(t.total)?t.total(e):void 0,result:(0,Z.isString)(t.result)?(0,Z.get)(e,t.result):(0,Z.isFunction)(t.result)?t.result(e):void 0,message:(0,Z.isString)(t.message)?(0,Z.get)(e,t.message):(0,Z.isFunction)(t.message)?t.message(e):void 0}:{list:e},se=(0,Z.debounce)(e=>{a(`toolbarButtonClick`,{data:D.value,code:e,selectedKeys:oe.value,records:ie.value}),ge(e)},100),ce=({key:e})=>se(e),le=(0,Z.debounce)(e=>{a(`toolbarToolClick`,{data:D.value,code:e,selectedKeys:oe.value,records:ie.value}),ge(e)},100),ue=()=>new Promise(e=>{if(x.value!==`bad`){re({table:!0,form:!0});let{ajax:t}=p.value;t.query({form:y.value,page:w}).then(t=>{let{list:n,total:r,result:i,message:a}=L(t,p.value.response);n?(D.value=n,T.value++):i?(D.value=i,E.value=r??i.length,T.value++):(D.value=[],T.value++,a&&ki(a)),e(D.value)}).catch(t=>{console.error(`fetchData error`,t),e([])}).finally(()=>{re({table:!1,form:!1})})}}),de=(e,t)=>(w.page=e,w.size=t,ue()),fe=()=>(w.page=1,F.value={},ue()),pe=(0,Z.debounce)(ue,160),me=(e,t)=>(Object.assign(y.value,e),w.page=1,t?Promise.resolve():pe()),he=(e,t)=>(y.value=e,w.page=1,t?Promise.resolve():pe()),ge=e=>{let{ajax:t}=p.value;switch(e){case`multiDelete`:t.multiDelete&&(oe.value.length>0?Ei({title:`警告`,content:`确认删除选中的数据吗?`}).then(()=>{re({table:!0,toolbar:!0}),t.multiDelete(oe.value).then(()=>{Di(`删除成功`),fe()}).catch(()=>{Oi(`删除失败`)}).finally(()=>{re({table:!1,toolbar:!1}),I.multiDelete=!1})}):ki(`请选择要删除的数据`));break}},_e=(0,l.computed)(()=>!h.value||!h.value.selectable&&!h.value.tree?c.value:[h.value.selectable&&h.value.tree?{type:`selection-tree`,width:40,widthFillDisable:!0,title:``}:h.value.selectable?{type:`selection`,width:40,widthFillDisable:!0,title:``}:h.value.tree?{type:`tree`,width:40,widthFillDisable:!0,title:``}:{type:`index`,width:40,widthFillDisable:!0,title:``},...c.value]),ve=e=>{if(o.value&&o.value.items.length>0){if(o.value.customReset)o.value.customReset();else{let e={};zr(o.value.items,t=>{t.field&&t.itemRender?Ir(t.itemRender.defaultValue)?e[t.field]=t.itemRender.defaultValue:e[t.field]=void 0:t.field&&t.slots&&(Ir(t.slots.defaultValue)?e[t.field]=t.slots.defaultValue:e[t.field]=void 0)}),y.value=e}a(`resetQuery`)}w.page=1,e||pe()},R=()=>(F.value={},ve()),z=e=>(0,Z.isFunction)(e)?e():e,ye=e=>(0,Z.isString)(e),B=null,be=()=>{B?.destroy(),B=null},xe=()=>{be(),!(!r.autoBoxSize||!A.value)&&(B=Fi(()=>A.value??void 0,()=>ji(_.value),{onLayout:()=>{(0,l.nextTick)(()=>H())}}),B.attach())};(0,l.watch)(()=>r.autoBoxSize,e=>{e?(0,l.nextTick)(()=>xe()):be()}),(0,l.watch)(_,()=>{r.autoBoxSize&&B?.update()},{deep:!0});let V=null,H=()=>{V&&cancelAnimationFrame(V),V=requestAnimationFrame(()=>{if(V=null,!N.value)return;let e=N.value.clientHeight,t=r.fitHeight??0;P.value=Math.max(e-t,100)})},U=null;(0,l.watch)(j,e=>{U?.disconnect(),U=null,e&&(U=new ResizeObserver(()=>H()),U.observe(e))},{immediate:!0}),(0,l.watch)(x,()=>(0,l.nextTick)(()=>H()));let Se,W=null,G=null;return(0,l.onMounted)(()=>{if(H(),window.addEventListener(`resize`,H),Se=new MutationObserver(e=>{e.forEach(e=>{if(e.type===`attributes`&&e.attributeName===`style`){let t=e.target;window.getComputedStyle(t).display!==`none`&&H()}})}),A.value){Se.observe(A.value,{attributes:!0,attributeFilter:[`style`]}),W=new ResizeObserver(()=>H());let e=A.value.parentElement;for(let t=0;t<5&&e&&e!==document.body;t++)W.observe(e),e=e.parentElement}G=new ResizeObserver(()=>H()),N.value&&G.observe(N.value),ve(r.manualFetch),(0,l.nextTick)(()=>{r.autoBoxSize&&xe(),H()})}),(0,l.onBeforeUnmount)(()=>{V&&cancelAnimationFrame(V),window.removeEventListener(`resize`,H),Se.disconnect(),U?.disconnect(),W?.disconnect(),G?.disconnect(),be()}),t({commitProxy:{query:pe,reload:R,reloadPage:fe,passQuery:me,forcePassQuery:he},$canvasTable:(0,l.computed)(()=>k.value),selectedRowKeys:oe,setBtnLoading:ne,selectedRecords:ie,$form:(0,l.computed)(()=>O.value),getFormData:()=>y.value,setLoadings:re,resizeTable:H}),(t,n)=>{let a=(0,l.resolveComponent)(`a-menu-item`),s=(0,l.resolveComponent)(`a-menu`),c=(0,l.resolveComponent)(`a-dropdown`);return(0,l.openBlock)(),(0,l.createElementBlock)(`div`,(0,l.mergeProps)({ref_key:`boxEl`,ref:A,class:[`p-wrapper flex flex-col gap-8px overflow-y-auto`,e.autoBoxSize?`min-h-0 min-w-0 flex-1 w-full`:`h-full`]},(0,l.unref)(i)),[x.value===`bad`?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,Zi,`请检查配置`)):((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.unref)(o)?.items?.some(e=>e.field&&e.itemRender)?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{key:0,class:`p-pane p-form-wrapper`,ref_key:`pFormWrapper`,ref:j},[(0,l.createVNode)((0,l.unref)(u.Spin),{spinning:C.form},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Form),(0,l.mergeProps)({key:v.value,ref_key:`formEl`,ref:O,model:y.value},S.value,{onSubmit:ae}),{default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(u.Row),{gutter:[6,12]},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)((0,l.unref)(o).items,(e,t)=>((0,l.openBlock)(),(0,l.createBlock)(Si,{key:`_col_${e.field||t}`,"form-data":y.value,item:e,onReset:n[0]||=e=>ve(r.lazyReset)},null,8,[`form-data`,`item`]))),128))]),_:1})]),_:1},16,[`model`]))]),_:1},8,[`spinning`])],512)):(0,l.createCommentVNode)(``,!0),(0,l.unref)(f)?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,Qi,[(0,l.createElementVNode)(`div`,$i,[(0,l.unref)(f).buttons&&(0,l.unref)(f).buttons.length>0?((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,{key:0},(0,l.renderList)((0,l.unref)(f).buttons,(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:t},[e.dropdowns&&e.dropdowns.length?((0,l.openBlock)(),(0,l.createBlock)(c,{key:0},{overlay:(0,l.withCtx)(()=>[(0,l.createVNode)(s,{onClick:ce},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.dropdowns,e=>((0,l.openBlock)(),(0,l.createBlock)(a,{key:e.code},{default:(0,l.withCtx)(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.content),1)]),_:2},1024))),128))]),_:2},1024)]),default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(u.Button),{type:e.type,size:e.size??`middle`,disabled:(0,l.unref)(f).disabled||e.disabled,loading:C.toolbar||!!e.code&&I[e.code],danger:e.danger,shape:e.shape,ghost:e.ghost,block:e.block},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,ea,[e.icon?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(ui),{key:0,icon:e.icon},null,8,[`icon`])):(0,l.createCommentVNode)(``,!0),e.content&&ye(z(e.content))?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createTextVNode)((0,l.toDisplayString)(z(e.content)),1)],64)):e.content?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(z(e.content)),{key:2})):(0,l.createCommentVNode)(``,!0),(0,l.createVNode)((0,l.unref)(d.DownOutlined))])]),_:2},1032,[`type`,`size`,`disabled`,`loading`,`danger`,`shape`,`ghost`,`block`])]),_:2},1024)):e.code?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Button),{key:1,type:e.type,size:e.size??`middle`,disabled:(0,l.unref)(f).disabled||e.disabled,loading:C.toolbar||!!e.code&&I[e.code],danger:e.danger,shape:e.shape,ghost:e.ghost,block:e.block,onClick:t=>(0,l.unref)(se)(e.code)},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,ta,[e.icon?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(ui),{key:0,icon:e.icon},null,8,[`icon`])):(0,l.createCommentVNode)(``,!0),e.content&&ye(z(e.content))?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createTextVNode)((0,l.toDisplayString)(z(e.content)),1)],64)):e.content?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(z(e.content)),{key:2})):(0,l.createCommentVNode)(``,!0)])]),_:2},1032,[`type`,`size`,`disabled`,`loading`,`danger`,`shape`,`ghost`,`block`,`onClick`])):((0,l.openBlock)(),(0,l.createElementBlock)(`div`,na))],64))),128)):(0,l.createCommentVNode)(``,!0)]),(0,l.createElementVNode)(`span`,ra,[(0,l.unref)(f).tools&&(0,l.unref)(f).tools.length>0?((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,{key:0},(0,l.renderList)((0,l.unref)(f).tools,(e,t)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Button),{key:t,type:e.type,size:e.size??`middle`,disabled:(0,l.unref)(f).disabled||e.disabled,danger:e.danger,shape:e.shape,ghost:e.ghost,block:e.block,onClick:t=>(0,l.unref)(le)(e.code),loading:C.toolbar||!!e.code&&I[e.code]},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,ia,[e.icon?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(ui),{key:0,icon:e.icon},null,8,[`icon`])):(0,l.createCommentVNode)(``,!0),e.content&&ye(z(e.content))?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createTextVNode)((0,l.toDisplayString)(z(e.content)),1)],64)):e.content?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(z(e.content)),{key:2})):(0,l.createCommentVNode)(``,!0)])]),_:2},1032,[`type`,`size`,`disabled`,`danger`,`shape`,`ghost`,`block`,`onClick`,`loading`]))),128)):(0,l.createCommentVNode)(``,!0)])])):(0,l.createCommentVNode)(``,!0),(0,l.createElementVNode)(`div`,{ref_key:`tableWrapperEl`,ref:M,class:`flex-1 h-0 min-h-0 flex flex-col p-inner-scroll`},[(0,l.createElementVNode)(`div`,{ref_key:`tableBodyEl`,ref:N,class:`flex-1 min-h-0 overflow-hidden`},[(0,l.createVNode)(Xi,{ref_key:`canvasTableRef`,ref:k,columns:_e.value,config:{...b.value.config,HEIGHT:P.value},data:D.value,loading:C.table,onSelectionChange:te},(0,l.createSlots)({_:2},[(0,l.renderList)(t.$slots,(e,n)=>({name:n,fn:(0,l.withCtx)(e=>[(0,l.renderSlot)(t.$slots,n,(0,l.normalizeProps)((0,l.guardReactiveProps)(e)))])}))]),1032,[`columns`,`config`,`data`,`loading`])],512),(0,l.createElementVNode)(`div`,{ref_key:`tableFooterEl`,ref:ee,class:`flex-shrink-0`},[(0,l.unref)(h)?.selectable&&(0,l.unref)(h).showCount?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,aa,` 已选:`+(0,l.toDisplayString)(oe.value.length),1)):(0,l.createCommentVNode)(``,!0),x.value===`pagination`?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Pagination),{key:1,class:`p-canvas-pagination`,size:`small`,current:w.page,"page-size":w.size,total:E.value,onChange:de},null,8,[`current`,`page-size`,`total`])):(0,l.createCommentVNode)(``,!0)],512)],512)],64))],16)}}}),sa=(0,l.defineComponent)({__name:`PGroupBlock`,props:{name:{},getFormSetting:{type:Function},source:{}},setup(e,{expose:t}){let n=e,r=(0,l.ref)(),{source:i}=(0,l.toRefs)(n),a=(0,l.computed)(()=>r.value?.$form),o=(0,l.computed)(()=>n.getFormSetting(i.value));return t({$form:a}),(t,n)=>((0,l.openBlock)(),(0,l.createBlock)(wi,(0,l.mergeProps)({name:e.name,ref_key:`formEl`,ref:r},o.value,{data:(0,l.unref)(i)}),null,16,[`name`,`data`]))}}),ca=(0,l.defineComponent)({__name:`CollapseCard`,props:{defaultCollapsed:{type:Boolean,default:!1},title:{default:void 0},collapsible:{type:Boolean,default:!1}},setup(e,{expose:t}){let n=(0,l.ref)(e.defaultCollapsed?[]:[`content`]);return t({collapse:()=>{n.value=[]},expand:()=>{n.value=[`content`]}}),(t,r)=>{let i=(0,l.resolveComponent)(`a-collapse-panel`),a=(0,l.resolveComponent)(`a-collapse`),o=(0,l.resolveComponent)(`a-card`);return e.collapsible?((0,l.openBlock)(),(0,l.createBlock)(a,{key:0,"active-key":n.value,"onUpdate:activeKey":r[0]||=e=>n.value=e,class:`collapsible-card`},{default:(0,l.withCtx)(()=>[(0,l.createVNode)(i,{key:`content`,"force-render":``,header:e.title},(0,l.createSlots)({_:2},[(0,l.renderList)(t.$slots,(e,n)=>({name:n,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,n)])}))]),1032,[`header`])]),_:3},8,[`active-key`])):((0,l.openBlock)(),(0,l.createBlock)(o,{key:1,size:`small`,title:e.title},(0,l.createSlots)({_:2},[(0,l.renderList)(t.$slots,(e,n)=>({name:n,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,n)])}))]),1032,[`title`]))}}}),la=(0,l.defineComponent)({__name:`PFormGroup`,props:(0,l.mergeModels)({name:{},getFormSetting:{type:Function},title:{},tabLabel:{},getTabLabel:{type:Function},editAble:{type:Boolean},showAdd:{type:Boolean},collapsible:{type:Boolean},defaultCollapsed:{type:Boolean},lazyErrorMark:{type:Boolean},forceRender:{type:Boolean},keepSerial:{type:Boolean},loading:{type:Boolean},itemMenus:{},createItem:{type:Function},max:{},menuHandler:{type:Function}},{modelValue:{type:Array,default:()=>[]},modelModifiers:{}}),emits:[`update:modelValue`],setup(e,{expose:t}){let n=u.Form.useForm,r=(0,l.ref)(),i=e,a=(0,l.ref)(),o=(0,l.useModel)(e,`modelValue`),s=(0,l.ref)(0),c=(0,l.ref)([]),f=(0,l.ref)([]),p=e=>{s.value=e},m=(0,l.computed)(()=>i.max??1/0),h=e=>{(i.createItem??(()=>Promise.resolve({})))({list:o.value}).then(t=>{o.value=[...o.value,{...t,__index:((0,Z.max)(o.value,e=>e.__index??-1)?.__index??-1)+1}],s.value=e})},g=i.itemMenus??[{content:`复制`,code:`copy`},{content:`删除`,code:`delete`}],_=e=>e?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement??a.value?.$el??document.body,v=(0,l.computed)(()=>i.forceRender||o.value.length<=5),y=e=>{let t=o.value.find((t,n)=>n===e)?.__index;Q(t)&&(c.value=c.value.filter(e=>e!==t))},b=()=>{(0,l.nextTick)().then(()=>{y(s.value),f.value[s.value]?.$form?.validate()})},x=(e,t)=>i.getTabLabel?.(e,t)??`${i.tabLabel} ${i.keepSerial?t+1:(e.__index??0)+1}`;(0,l.watch)(()=>o.value,()=>{if(!i.keepSerial){let e=o.value.filter(e=>!Q(e.__index));e.length>0&&e.forEach(e=>{e.__index=((0,Z.max)(o.value,e=>e.__index??-1)?.__index??-1)+1})}},{immediate:!0});let S=(0,Z.debounce)(({key:e},t,n)=>{if(i.menuHandler&&(0,Z.isFunction)(i.menuHandler))i.menuHandler({code:(0,Z.toString)(e),data:t,index:n});else switch(e){case`delete`:o.value=o.value.filter((e,t)=>t!==n),(0,l.nextTick)(()=>{f.value=f.value.filter(e=>!!e),n<=s.value&&s.value>0&&s.value--});break;case`copy`:if(o.value.length>=m.value){ki(`已达到最大数量`);return}o.value=[...o.value,(0,Z.clone)({...(0,Z.omit)(t,[`id`,`__index`]),__index:((0,Z.max)(o.value,e=>e.__index??-1)?.__index??-1)+1})];break}},100);(0,l.watchEffect)(()=>{o.value.length===0?s.value=0:s.value>=o.value.length&&(s.value=o.value.length-1)});let C=(0,Z.debounce)(y,50);(0,l.watchEffect)(()=>{let e=o.value.map((e,t)=>c.value.includes(e.__index)?t:void 0).filter(Q),t=r.value?.$el;t&&t.querySelectorAll(`:scope >.ant-tabs-nav>.ant-tabs-nav-wrap>.ant-tabs-nav-list>.ant-tabs-tab>.ant-tabs-tab-btn`).forEach((t,n)=>{e.includes(n)?t.classList.add(`p-error-group-tab`):t.classList.remove(`p-error-group-tab`)})}),t({collapse:()=>{a.value?.collapse?.()},expand:()=>{a.value?.expand?.()},activeKey:(0,l.computed)(()=>s.value),setActiveKey:p,validateAll:()=>{let e=v.value?f.value.map(e=>e.$form?.validate()):o.value.map(e=>n(e,i.getFormSetting(e).rules)?.validate()??Promise.resolve());return Promise.allSettled(e).then(e=>{if(c.value=e.map((e,t)=>e.status===`rejected`&&typeof o.value[t]?.__index==`number`?o.value[t].__index:void 0).filter(e=>typeof e==`number`),!i.lazyErrorMark&&c.value.length){let e=c.value[0],t=o.value.findIndex(t=>t.__index===e);t!==-1&&(s.value=t)}return c.value.length?Promise.reject({error_indexes:c.value,results:e}):Promise.resolve(e)})},validate:async(e,t)=>{let r=o.value.findIndex(t=>t.__index===e);try{return await(v.value?f.value[r]?.$form?.validate()??Promise.resolve():n(o.value[r],i.getFormSetting(o.value[r]).rules)?.validate()??Promise.resolve()),c.value=c.value.filter(t=>t!==e),Promise.resolve()}catch(n){return!c.value.includes(e)&&!t&&(c.value=[...c.value,e]),Promise.reject(n)}},validateFields:async(e,t,r)=>{let a=o.value.findIndex(t=>t.__index===e),s=i.getFormSetting(o.value[a]).rules,l=n(o.value[a],s);try{return await(v.value?f.value[a]?.$form?.validateFields(t)??Promise.resolve():Promise.allSettled(t.map(e=>l.validateField(e,o.value[a][e],s[e]??[])))),Promise.resolve()}catch(t){return!c.value.includes(e)&&!r&&(c.value=[...c.value,e]),Promise.reject(t)}}});let w=(0,l.useSlots)(),T=(0,l.computed)(()=>Object.keys(w).filter(e=>e.startsWith(`group-`)).map(e=>({original:e,target:e.replace(`group-`,``)})));return(t,n)=>{let i=(0,l.resolveComponent)(`a-spin`);return(0,l.openBlock)(),(0,l.createBlock)(ca,{ref_key:`rootRef`,ref:a,title:e.title,size:`small`,collapsible:e.collapsible,"default-collapsed":e.defaultCollapsed},(0,l.createSlots)({default:(0,l.withCtx)(()=>[e.loading?((0,l.openBlock)(),(0,l.createBlock)(i,{key:0,class:`w-full`})):((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Tabs),{key:1,ref_key:`tabsRef`,ref:r,type:`editable-card`,activeKey:s.value,"onUpdate:activeKey":n[1]||=e=>s.value=e,"hide-add":``,onChange:b},{rightExtra:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,`rightExtra`,{},()=>[e.showAdd&&o.value.length<m.value?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Button),{key:0,type:`link`,onClick:n[0]||=e=>h(o.value.length)},{default:(0,l.withCtx)(()=>[...n[2]||=[(0,l.createTextVNode)(` + 新增 `,-1)]]),_:1})):(0,l.createCommentVNode)(``,!0)])]),default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(o.value,(t,n)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.TabPane),{key:n,tab:x(t,n),"force-render":v.value},{closeIcon:(0,l.withCtx)(()=>[e.editAble&&(0,l.unref)(g)?.length?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Dropdown),{key:0,"get-popup-container":_},{overlay:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(u.Menu),{onClick:e=>(0,l.unref)(S)(e,t,n)},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)((0,l.unref)(g).filter(e=>e.visibleMethod?.({data:t,index:n})??!0),e=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.MenuItem),{key:e.code},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,null,(0,l.toDisplayString)(e.content),1)]),_:2},1024))),128))]),_:2},1032,[`onClick`])]),default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(d.MoreOutlined))]),_:2},1024)):(0,l.createCommentVNode)(``,!0)]),default:(0,l.withCtx)(()=>[((0,l.openBlock)(),(0,l.createBlock)(sa,{ref_for:!0,ref_key:`blockInstance`,ref:f,key:n,source:t,name:e.name?`${e.name}_${n}`:void 0,"get-form-setting":e.getFormSetting,onFocusCapture:e=>(0,l.unref)(C)(n),onClickCapture:e=>(0,l.unref)(C)(n)},null,8,[`source`,`name`,`get-form-setting`,`onFocusCapture`,`onClickCapture`]))]),_:2},1032,[`tab`,`force-render`]))),128))]),_:3},8,[`activeKey`]))]),_:2},[(0,l.renderList)(T.value,e=>({name:e.target,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,e.original)])}))]),1032,[`title`,`collapsible`,`default-collapsed`])}}}),ua={class:`w-full text-right p-2`},da=(0,l.defineComponent)({__name:`PromisePicker`,props:{gridSetting:{},title:{default:`数据选择`},width:{default:`70%`},multipleAllowEmpty:{type:Boolean,default:!1},bodyStyle:{default:()=>({})},beforePick:{type:Function,default:()=>Promise.resolve()}},setup(e,{expose:t}){let n=(0,l.ref)(),r=e,i=(0,l.computed)(()=>r.gridSetting.selectConfig?.multiple),a=(0,l.computed)(()=>({fitContent:!0,...r.gridSetting})),o={display:`flex`,flexDirection:`column`,minHeight:0,maxHeight:`min(80dvh, calc(100dvh - 200px))`,overflow:`hidden`},s,c,d,f=(0,l.reactive)({modal:!1}),p=()=>{d&&d()},m=()=>{f.modal=!1,d&&d()},h=({row:e,field:t})=>{s&&!i.value&&r.beforePick(e).then(()=>{f.modal=!1,s({row:e,field:t})})},g=()=>{let e=n.value?.selectedRecords??[];e.length===0&&!r.multipleAllowEmpty?ki(`请选择数据`):r.beforePick(e).then(()=>{f.modal=!1,c(e)})};return t({pick:()=>new Promise((e,t)=>{s=e,d=t,f.modal=!0}),pickMultiple:()=>new Promise((e,t)=>{c=e,d=t,f.modal=!0}),grid:n,hide:()=>{f.modal=!1}}),(t,r)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Modal),{open:f.modal,"onUpdate:open":r[0]||=e=>f.modal=e,"destroy-on-close":``,title:e.title,width:e.width,footer:i.value?void 0:null,onCancel:p,"body-style":e.bodyStyle},(0,l.createSlots)({default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,{style:o},[(0,l.createVNode)(qi,(0,l.mergeProps)(a.value,{ref_key:`gridEl`,ref:n,onPick:h}),null,16)])]),_:2},[i.value?{name:`footer`,fn:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,ua,[(0,l.createElementVNode)(`span`,null,[(0,l.createVNode)((0,l.unref)(u.Button),{class:`mr-4`,onClick:m},{default:(0,l.withCtx)(()=>[...r[1]||=[(0,l.createTextVNode)(` 取消 `,-1)]]),_:1}),(0,l.createVNode)((0,l.unref)(u.Button),{type:`primary`,onClick:g},{default:(0,l.withCtx)(()=>[...r[2]||=[(0,l.createTextVNode)(` 确定 `,-1)]]),_:1})])])]),key:`0`}:void 0]),1032,[`open`,`title`,`width`,`footer`,`body-style`]))}}),fa=(0,l.defineComponent)(e=>()=>{let{item:t,data:n,emptyText:r}=e;if(t.slots?.default)return t.slots.default({data:n,field:t.field});if(t.readonlyRender?.name){let e=t.readonlyRender,r=vi.renders[e.name]?.renderReadonly?.(e,{data:n,field:t.field,title:t.label},{})??null;if(r!==null)return r}if(!t.field)return r;let i=n?.[t.field];return Ir(i)?i:r},{name:`PDescriptionContent`,props:[`item`,`data`,`emptyText`]}),pa=(0,l.defineComponent)({__name:`PDescription`,props:{data:{},items:{},title:{},extra:{},bordered:{type:Boolean,default:!1},size:{default:`default`},column:{default:3},layout:{default:`horizontal`},colon:{type:Boolean,default:!0},labelStyle:{},contentStyle:{},emptyText:{default:`-`}},setup(e){let t=e,n=(0,l.computed)(()=>({title:t.title,extra:t.extra,bordered:t.bordered,size:t.size,column:t.column,layout:t.layout,colon:t.colon,labelStyle:t.labelStyle,contentStyle:t.contentStyle}));return(t,r)=>{let i=(0,l.resolveComponent)(`a-descriptions-item`),a=(0,l.resolveComponent)(`a-descriptions`);return(0,l.openBlock)(),(0,l.createBlock)(a,(0,l.mergeProps)(n.value,{class:`p-description`}),(0,l.createSlots)({default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.items,(t,n)=>((0,l.openBlock)(),(0,l.createBlock)(i,{key:`_desc_${t.field??n}`,label:t.label,span:t.span,"label-style":t.labelStyle,"content-style":t.contentStyle},(0,l.createSlots)({default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(fa),{item:t,data:e.data,"empty-text":e.emptyText||`-`},null,8,[`item`,`data`,`empty-text`])]),_:2},[t.slots?.label?{name:`label`,fn:(0,l.withCtx)(()=>[((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(t.slots.label)))]),key:`0`}:void 0]),1032,[`label`,`span`,`label-style`,`content-style`]))),128))]),_:2},[t.$slots.title||e.title?{name:`title`,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,`title`,{},()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.title),1)])]),key:`0`}:void 0,t.$slots.extra||e.extra?{name:`extra`,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,`extra`,{},()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.extra),1)])]),key:`1`}:void 0]),1040)}}});function ma(e){e&&Vr(e)}var ha={install(e){e.component(`PForm`,wi),e.component(`PGrid`,qi),e.component(`PCanvasTable`,Xi),e.component(`PCanvasGrid`,oa),e.component(`PFormGroup`,la),e.component(`PGroupBlock`,sa),e.component(`PromisePicker`,da),e.component(`PDescription`,pa)},addFormatter:ai,addRender:_i,setup:ma};exports.PCanvasGrid=oa,exports.PCanvasTable=Xi,exports.PDescription=pa,exports.PForm=wi,exports.PFormGroup=la,exports.PGrid=qi,exports.PGroupBlock=sa,exports.PromisePicker=da,exports.addFormatter=ai,exports.addRender=_i,exports.applyViewportRestSize=Ni,exports.cleanCol=Jr,exports.createAutoViewportBoxController=Fi,exports.default=ha,exports.defaultItemResponsive=Yr,exports.defaultLabelCol=Xr,exports.get24rest=Qr,exports.getButtonResponsive=ei,exports.getTooltipRenderer=Hr,exports.getUIKitConfig=Ur,exports.labelColDict=Zr,exports.parseAutoViewportBoxOffset=ji,exports.resetUIKitConfig=qr,exports.setUIKitConfig=Vr,exports.setup=ma,exports.watchPreviousDeep=ti;
|
|
17
|
+
`,t.appendChild(this.loadingEl),this.countEl=document.createElement(`span`),this.countEl.className=`e-virt-table-finder-bar-count`;let n=document.createElement(`div`);return n.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=N,this.nextBtn=document.createElement(`button`),this.nextBtn.className=`e-virt-table-finder-bar-nav-btn next-btn`,this.nextBtn.innerHTML=N,n.appendChild(this.prevBtn),n.appendChild(this.nextBtn),this.closeBtn=document.createElement(`button`),this.closeBtn.className=`e-virt-table-finder-bar-nav-btn close-btn`,this.closeBtn.innerHTML=`×`,e.appendChild(t),e.appendChild(this.countEl),e.appendChild(n),e.appendChild(this.closeBtn),e}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(){let e=this.input.value.trim();if(this.searchResults=[],this.currentIndex=-1,!e){this.cearFinderBar(),this.updateCount();return}this.showLoading(),setTimeout(()=>{this.searchResults=this.searchData.filter(t=>t.text.toLowerCase().includes(e.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;let e=this.searchResults[this.currentIndex];this.ctx.finderBar=e;let{rowIndex:t,colIndex:n}=e;this.ctx.emit(`scrollToIndex`,t,n)}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{let e=this.currentIndex+1,t=this.searchResults.length;this.countEl.textContent=`${e}/${t}`,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 e;this.loadingEl.classList.add(`show`),(e=this.loadingEl.parentElement)==null||e.classList.add(`loading`),this.input.readOnly=!0}hideLoading(){var e;this.loadingEl.classList.remove(`show`),(e=this.loadingEl.parentElement)==null||e.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()}}let tn=class e{constructor(e){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=e,this.ctx.on(`registerTextLayout`,(e,t)=>this.layouts.set(e,t)),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(e){let t=this.ctx.focusCellHeader;if(!(!this.ctx.textSelecting||!t)){if(e){let n=t.colIndex,r=t.colIndex+t.colspan-1,i=e.colIndex,a=e.colIndex+e.colspan-1;if(i>=n&&a<=r)return}this.resetSelection()}}onMouseDown(e){if(!this.canSelect||!this.ctx.isTarget(e))return;this.ctx.containerElement.contains(document.activeElement)||this.ctx.containerElement.focus({preventScroll:!0});let t=this.hitTest(e);if(!t){this.resetSelection();return}let{offsetX:n,offsetY:r}=this.ctx.getOffset(e);this.pending={cellKey:t.cellKey,index:t.index,startX:n,startY:r}}onMouseMove(e){if(!this.canSelect||(this.ctx.textSelecting||this.tryStartDrag(e),!this.ctx.textSelecting))return;let t=this.layouts.get(this.activeCellKey);if(!t)return;let{offsetX:n,offsetY:r}=this.ctx.getOffset(e),i=this.hitTestText(t,n,r);i!==null&&(this.selectionEnd=i,this.updateSelection())}tryStartDrag(t){if(!this.pending||!this.ctx.mousedown)return;let{offsetX:n,offsetY:r}=this.ctx.getOffset(t),i=Math.abs(n-this.pending.startX),a=Math.abs(r-this.pending.startY);if(i<e.DRAG_THRESHOLD&&a<e.DRAG_THRESHOLD)return;let o=this.hitTest(t);if(!o||o.cellKey!==this.pending.cellKey){this.pending=null;return}this.activeCellKey=this.pending.cellKey,this.selectionStart=this.pending.index,this.selectionEnd=o.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(e){var t;if(!this.canSelect||!((e.ctrlKey||e.metaKey)&&e.code===`KeyC`))return;let n=this.getSelectedText();n&&(e.preventDefault(),(t=navigator.clipboard)==null||t.writeText(n).catch(e=>console.error(`Copy Failure:`,e)))}hitTest(e){let{offsetX:t,offsetY:n}=this.ctx.getOffset(e),r=null;for(let[e,i]of this.layouts){let a=this.hitTestText(i,t,n);a!==null&&(r={cellKey:e,index:a})}return r}updateSelection(){this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.emit(`drawView`)}hitTestText(e,t,n){let{glyphs:r,contentY:i,lineHeight:a,lines:o}=e;if(!r.length)return null;let s=Math.floor((n-i)/a);if(s<0||s>=o.length)return null;let c=r.filter(e=>e.line===s);if(!c.length)return null;let l=i+s*a;if(n<l-2||n>=l+a+2)return null;let u=c[0],d=c[c.length-1];if(t<u.x-2||t>d.x+d.width+2)return null;if(t<=u.x)return u.index;for(let e of c)if(t<e.x+e.width/2)return e.index;return d.index+1}clearLayouts(){this.layouts.clear()}draw(){if(!this.ctx.config.ENABLE_TEXT_SELECTION)return;let e=this.getSelectionRange(),t=e&&this.layouts.get(this.activeCellKey);t&&this.drawTextSelection(t,e)}drawTextSelection(e,t,n=`#fff`,r=`#3b82f6`){if(t.start>=t.end)return;let i=new Map;for(let n of e.glyphs){if(n.index<t.start||n.index>=t.end)continue;let e=i.get(n.line)??[];e.push(n),i.set(n.line,e)}if(!i.size)return;let a=this.ctx.paint.getCtx();a.save(),a.font=e.font,a.textBaseline=`top`,a.textAlign=`left`,i.forEach(e=>{let t=e[0],i=e[e.length-1];a.fillStyle=r,a.fillRect(t.x,t.y-1,i.x+i.width-t.x,t.height),a.fillStyle=n;for(let t of e)a.fillText(t.char,t.x,t.y)}),a.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(){let e=this.getSelectionRange(),t=e&&this.layouts.get(this.activeCellKey);return!t||e.start>=e.end?``:t.chars.slice(e.start,e.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(tn,`DRAG_THRESHOLD`,4);let nn=tn,rn=class e{constructor(e,t){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=t;let{overlayerElement:r,editorElement:i,emptyElement:a,contextMenuElement:o}=this.options,s=this.createContainer(e,r,i,a,o);this.ctx=new se(s,this.options),this.textSelector=new nn(this.ctx),this.header=new fe(this.ctx),this.footer=new he(this.ctx),this.body=new me(this.ctx),this.scroller=new le(this.ctx),this.selector=new ge(this.ctx),this.autofill=new _e(this.ctx),this.tooltip=new qt(this.ctx),this.empty=new Yt(this.ctx),this.editor=new Jt(this.ctx),this.overlayer=new Xt(this.ctx),this.contextMenu=new Qt(this.ctx),this.loading=new $t(this.ctx),this.finderBar=new en(this.ctx),this.ctx.on(`loadData`,e=>{this.loadData(e)}),this.ctx.on(`draw`,()=>{this.draw()}),this.ctx.on(`drawView`,()=>{this.draw(!0)}),this.draw()}static useLocale(t){e.locale=t}createContainer(e,t,n,r,i){e.className=`e-virt-table-container`;let a=document.createElement(`div`),o=document.createElement(`canvas`),s=t||document.createElement(`div`);a.className=`e-virt-table-stage`,e.tabIndex=0,o.className=`e-virt-table-canvas`,s.className=`e-virt-table-overlayer`,s.setAttribute(`data-overlayer`,t?`custom`:`default`);let c=n||document.createElement(`div`);c.className=`e-virt-table-editor`;let l=r,u=i;return a.appendChild(o),a.appendChild(s),e.appendChild(a),{containerElement:e,stageElement:a,canvasElement:o,overlayerElement:s,editorElement:c,emptyElement:l,contextMenuElement:u}}doDraw(e=!1){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(),e||this.overlayer.draw()}draw(e=!1){this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=requestAnimationFrame(()=>{this.doDraw(e),this.body.updateAutoHeight()&&this.doDraw(e)})}loadConfig(e){this.ctx.config.init(e),this.ctx.database.init(!1),this.header.init(),this.ctx.emit(`draw`)}loadColumns(e){this.editor.doneEdit(),this.ctx.database.setColumns(e),this.header.init(),this.ctx.emit(`draw`)}loadData(e){this.editor.doneEdit(),this.ctx.database.setData(e),this.header.init(),this.tooltip.hide(),this.ctx.emit(`draw`)}loadFooterData(e){this.ctx.database.setFooterData(e),this.ctx.emit(`draw`)}setCustomHeader(e,t=!0){this.ctx.database.setCustomHeader(e,t),this.header.init(),this.ctx.emit(`draw`)}getCustomHeader(){return this.header.getCustomHeader()}showColumns(e,t=!0){this.ctx.database.setCustomHeaderHideData(e,!t),this.header.init(),this.ctx.emit(`draw`)}fixedColumns(e,t){this.ctx.database.setCustomHeaderFixedData(e,t),this.header.init(),this.ctx.emit(`draw`)}setLoading(e){this.ctx.loading=e,e?this.loading.show():this.loading.hide()}on(e,t){this.ctx.on(e,t)}emit(e,...t){this.ctx.emit(e,...t)}off(e,t){this.ctx.off(e,t)}filterMethod(e){this.ctx.database.setFilterMethod(e),this.ctx.database.init(!1),this.header.init(),this.ctx.emit(`draw`)}editCell(e,t){this.editor.editCell(e,t)}setItemValue(e,t,n,r=!0,i=!0,a=!1){this.ctx.database.setItemValue(e,t,n,r,i,a)}batchSetItemValue(e,t=!0){this.ctx.database.batchSetItemValue(e,t)}setItemValueByEditor(e,t,n,r=!0,i=!0){this.ctx.setItemValueByEditor(e,t,n,r,i),this.editor.doneEdit()}clearEditableData(e=null){let t=[0,this.ctx.maxColIndex],n=[0,this.ctx.maxRowIndex];return this.selector.clearSelectedData(t,n,!1,e)}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit(`draw`)}setZoom(e){this.ctx.setZoom(e)}getZoom(){return this.ctx.getZoom()}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}setCurrentRowByRowIndex(e){this.ctx.currentCell=this.ctx.database.getVirtualBodyCell(e,0),this.ctx.emit(`draw`)}setCurrentRow(e){let t=this.ctx.database.getColumnByColIndex(0);t&&(this.ctx.currentCell=this.ctx.database.getVirtualBodyCellByKey(e,t.key),this.ctx.emit(`draw`))}getCurrentRow(){let e=this.ctx.currentCell;return e?{row:e.row,rowIndex:e.rowIndex,rowKey:e.rowKey}:void 0}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit(`draw`)}validateFields(e,t=!0){return new Promise(async(n,r)=>{let i=[];for(let t=0;t<e.length;t++){let{rowKey:n,key:r}=e[t],a=await this.ctx.database.getValidator(n,r);Array.isArray(a)&&a.length&&i.push(a)}if(i.length){if(r(i),t){let[e]=i;if(Array.isArray(e)&&e.length){let[t]=e,{rowKey:n,key:r}=t;this.scrollToRowkey(n),this.scrollToColkey(r)}}this.ctx.emit(`draw`)}else n([]),this.ctx.emit(`draw`)})}async validate(e=!0){return new Promise(async(t,n)=>{try{t(await this.getValidations())}catch(t){if(e&&Array.isArray(t)&&t.length){let[e]=t;if(Array.isArray(e)&&e.length){let[t]=e,{rowKey:n,key:r}=t,i=this.ctx.database.getRowForRowKey(n);if(i){let{parentRowKeys:e=[]}=i;e&&e.length&&this.setExpandRowKeys(e,!0)}this.scrollToRowkey(n),this.scrollToColkey(r)}}n(t)}})}setValidations(e){if(e.forEach(e=>{let{rowIndex:t,key:n,message:r,rowKey:i}=e;if(t!==void 0&&i===void 0){let e=this.ctx.database.getRowKeyForRowIndex(t);this.ctx.database.setValidationErrorByRowKey(e,n,r)}i&&this.ctx.database.setValidationErrorByRowKey(i,n,r)}),e&&Array.isArray(e)&&e.length){let[t]=e;if(t&&t.rowKey)this.scrollToRowkey(t.rowKey),this.scrollToColkey(t.key);else if(t&&t.rowIndex!==void 0&&t.rowIndex>=0&&t.key){let{rowIndex:e,key:n}=t;this.scrollToRowIndex(e),this.scrollToColkey(n)}}}getValidations(){return this.ctx.config.DISABLED?new Promise(e=>{e([])}):new Promise(async(e,t)=>{let n=this.ctx.database.getAllRowsData(),r=this.ctx.header.leafCellHeaders,i=[];for(let e=0;e<n.length;e++)for(let t=0;t<r.length;t++){let a=this.ctx.database.getRowKeyByItem(n[e]),o=r[t].key,s=await this.ctx.database.getValidator(a,o);Array.isArray(s)&&s.length&&i.push(s)}i.length?(t(i),this.ctx.emit(`draw`)):(e([]),this.ctx.emit(`draw`))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(e,t){this.scroller.setScroll(e,t)}scrollXTo(e){this.scroller.setScrollX(e)}scrollToColkey(e){this.scroller.scrollToColkey(e)}scrollToRowkey(e){this.scroller.scrollToRowKey(e)}scrollToColIndex(e){this.scroller.scrollToColIndex(e)}scrollToRowIndex(e){this.scroller.scrollToRowIndex(e)}scrollYTo(e){this.scroller.setScrollY(e)}setExpandRowKeys(e,t=!0){this.ctx.database.setExpandRowKeys(e,t)}getExpandRowKeys(){return this.ctx.database.getExpandRowKeys()}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit(`draw`)}toggleRowSelection(e){let t=this.ctx.database.getRowKeyByItem(e);this.ctx.database.toggleRowSelection(t),this.ctx.emit(`draw`)}setSelectionByRows(e,t=!0){e.forEach(e=>{let n=this.ctx.database.getRowKeyByItem(e);this.ctx.database.setRowSelection(n,t,!1)}),this.ctx.emit(`selectionChange`,this.getSelectionRows()),this.ctx.emit(`draw`)}setSelectionByRowKeys(e,t=!0){e.forEach(e=>{this.ctx.database.setRowSelection(e,t,!1)}),this.ctx.emit(`selectionChange`,this.getSelectionRows()),this.ctx.emit(`draw`)}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit(`draw`)}toggleRowExpand(e,t){this.ctx.database.expandItem(e,t),this.ctx.emit(`draw`)}toggleExpandAll(e){this.ctx.database.expandAll(e),this.ctx.emit(`draw`)}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(e){return this.ctx.database.getPositionForRowIndex(e)}getCellValue(e,t){return this.ctx.database.getItemValue(e,t)}getCellValueByIndex(e,t){return this.ctx.database.getItemValueForRowIndexAndColIndex(e,t)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:y,mergeRowCell:v,getSpanArrByRow:g,getSpanObjByColumn:_}}getColumnByKey(e){return this.ctx.database.getColumnByKey(e)?.column}clearChangeData(){this.ctx.database.clearChangeData(),this.ctx.emit(`draw`)}getReadonly(e,t){return this.ctx.database.getReadonly(e,t)}useLocale(e){this.ctx.locale.use(e)}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(rn,`locale`);let an=rn;return an}))}))(),1),Yi=(0,l.defineComponent)((e,{emit:t})=>{let{cellRender:n,renderTableParams:r}=e,{row:i,field:a}=r;if(a){let e=(0,l.ref)(i[a]);return()=>vi.renders[n.name]?.renderEdit?.(e,n,r,t)??null}else return()=>null},{name:`RenderEditCell`,props:[`cellRender`,`renderTableParams`],emits:[`blur`]}),Xi=[[`--evt-border-color`,`--p-border-color`,`#d9d9d9`],[`--evt-header-bg-color`,`--p-table-thead-bg-color`,`#f2f3f6`],[`--evt-body-bg-color`,`--p-table-row-bg-color`,`#fff`],[`--evt-stripe-color`,`--p-striped-bg-color`,`#f2f3f6`],[`--evt-highlight-hover-row-color`,`--p-table-row-hover-bg-color`,`#e6e7ea`],[`--evt-select-border-color`,`--p-primary-color`,`#4096ff`],[`--evt-sort-icon-color`,`--p-primary-color`,`#4096ff`],[`--evt-required-color`,`--p-danger-color`,`#f5222d`],[`--evt-error-tip-color`,`--p-danger-color`,`#f5222d`],[`--evt-error-tip-icon-color`,`--p-danger-color`,`#f5222d`],[`--evt-readonly-color`,`--p-table-row-bg-color`,`#fff`],[`--evt-scroller-track-color`,`--p-table-row-bg-color`,`#fff`]],Zi={"--evt-header-text-color":`#1d2129`,"--evt-body-text-color":`#4e5969`,"--evt-footer-text-color":`#4e5969`,"--evt-readonly-text-color":`#4e5969`,"--evt-scroller-color":`#dee0e3`,"--evt-scroller-focus-color":`#bbbec4`,"--evt-edit-bg-color":`#fcf6ed`,"--evt-footer-bg-color":`#fafafa`,"--evt-autofill-point-border-color":`#fff`,"--evt-editor-bg-color":`#fff`,"--evt-editor-text-color":`#333`,"--evt-context-menu-bg-color":`#fff`,"--evt-context-menu-text-color":`#333`,"--evt-context-menu-item-hover-bg-color":`#f5f5f5`},Qi={"--evt-header-text-color":`#a3a6ad`,"--evt-body-text-color":`#cfd3dc`,"--evt-footer-text-color":`#cfd3dc`,"--evt-readonly-text-color":`#a3a6ad`,"--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":`#a3a6ad`,"--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-bg-color":`#414243`};function $i(e=document.documentElement){return e.getAttribute(`theme-mode`)===`dark`||e.getAttribute(`data-theme`)===`dark`||e.classList.contains(`dark`)}function ea(e=document.documentElement){let t=getComputedStyle(e);for(let[n,r,i]of Xi){let a=t.getPropertyValue(r).trim()||i;e.style.setProperty(n,a)}let n=$i(e)?Qi:Zi;for(let[t,r]of Object.entries(n))e.style.setProperty(t,r)}function ta(e){let t=()=>{ea();let t=e.getTable();t&&t.loadConfig(e.getConfig())},n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:[`theme-mode`,`class`,`data-theme`]}),t(),{sync:t,disconnect:()=>n.disconnect()}}var na=(0,l.defineComponent)({__name:`PCanvasTable`,props:{columns:{},data:{},config:{default:()=>({})},footerData:{},loading:{type:Boolean}},emits:[`change`,`selectionChange`,`ready`],setup(e,{expose:t,emit:n}){let r=n,i=(0,l.ref)([]),a=e,o=Kr(),s=(0,l.computed)(()=>({...a,config:{AUTO_ROW_HEIGHT:!0,DISABLED:!0,...o,...a.config}})),c=null,u=null,d=(0,l.useAttrs)(),f=(0,l.ref)(null),p=(0,l.ref)(null),m=(0,l.ref)(null),h=(0,l.ref)(null),g=(0,l.ref)(),_=(0,l.ref)(`text`),v=(0,l.ref)(),y={},b={},x=(0,l.computed)(()=>{let e=g.value;return e?{width:`${e.width}px`,height:`${e.height}px`}:{}}),S=e=>ri[e]||(({cellValue:e})=>e),C=e=>vi.renders[e]?.renderDefault,w=(e,...t)=>({row:n,rowIndex:r,value:i})=>e({row:n,rowIndex:r,cellValue:i},...t),T=e=>{if(e.slots?.default&&(0,Z.isFunction)(e.slots?.default))return t=>e.slots?.default?.({row:t.row,column:e,rowIndex:t.rowIndex});if(e.slots?.default&&(0,Z.isString)(e.slots?.default))return`slot:${e.slots?.default}`;if(e.cellRender&&e.cellRender.name)return t=>C(e.cellRender.name)?.(e.cellRender,{data:a.data,row:t.row,rowIndex:t.rowIndex,field:e.field||t.column.key,title:t.column?.title??``},{})},E=e=>{if(e.slots?.title&&(0,Z.isFunction)(e.slots?.title))return t=>e.slots?.title?.({column:e})},D=e=>(e.slots?.edit&&(e.field||e.key)&&(0,Z.isFunction)(e.slots?.edit)?y[`__slot:${e.field||e.key}`]=e:e.editRender?.name&&(e.field||e.key)&&(b[e.field||e.key]=e.editRender),{...(0,Z.omit)(e,[`formatter`]),key:e.key||e.field||Nr(),formatter:(0,Z.isString)(e.formatter)?w(S(e.formatter)):(0,Z.isArray)(e.formatter)&&(0,Z.isString)(e.formatter[0])?w(S(e.formatter[0]),...e.formatter.slice(1)):(0,Z.isFunction)(e.formatter)?w(e.formatter):void 0,editorType:e.editorType??(e.slots?.edit&&(e.field||e.key)&&(0,Z.isFunction)(e.slots?.edit)?`__slot:${e.field||e.key}`:e.editRender?.name?e.editRender.name:void 0),render:T(e),renderHeader:E(e),children:e.children?.map(e=>D(e))});(0,l.onMounted)(()=>{f.value&&(ea(),c=new Ji.default(f.value,{config:s.value.config,columns:a.columns.map(e=>D(e)),data:a.data,footerData:a.footerData,emptyElement:m.value||void 0,overlayerElement:h.value||void 0,editorElement:p.value||void 0}),Object.keys(d).forEach(e=>{let t=d[e];if(typeof t==`function`&&e.startsWith(`on`)){let n=e.charAt(2).toLowerCase()+e.slice(3);c?.on(n,t)}}),c.on(`change`,e=>{r(`change`,e)}),c.on(`overlayerChange`,e=>{v.value=e,console.log(`overlayerChange`,e)}),c.on(`startEdit`,e=>{g.value=e,_.value=e.editorType,_.value}),c.on(`doneEdit`,()=>{_.value=`text`}),c.on(`selectionChange`,e=>{i.value=e,r(`selectionChange`,e)}),r(`ready`,c),u=ta({getTable:()=>c,getConfig:()=>s.value.config}))}),(0,l.onUnmounted)(()=>{u?.disconnect()});function O(e){if(!c||!g.value)return;let{rowKey:t,key:n}=g.value;c?.setItemValueByEditor(t,n,e)}let k=()=>document.body;return(0,l.watch)(()=>a.data,e=>{c?.loadData(e)},{deep:!0}),ti(()=>a.columns,(e,t)=>{(0,Z.isEqual)(e,t)||c?.loadColumns(e.map(e=>D(e)))},{deep:!0}),(0,l.watch)(()=>s.value.config,e=>{c?.loadConfig(e)},{deep:!0}),(0,l.watch)(()=>a.footerData,e=>{c?.loadFooterData(e||[])},{deep:!0}),(0,l.watch)(()=>a.loading,(e,t)=>{e!==t&&c?.setLoading(e)},{immediate:!0}),t({$table:c,selectedRecords:(0,l.computed)(()=>i.value),reloadData:()=>{c?.loadData(a.data)}}),(t,n)=>{let r=(0,l.resolveComponent)(`a-empty`),i=(0,l.resolveComponent)(`a-spin`);return(0,l.openBlock)(),(0,l.createBlock)(i,{spinning:e.loading},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableRef`,ref:f},[(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableEditorRef`,ref:p},[_.value.startsWith(`__slot:`)?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(y[_.value].slots.edit({row:g.value.row,column:y[_.value],rowIndex:g.value.rowIndex})),{key:0,bordered:!1,style:(0,l.normalizeStyle)(x.value),class:`ev-editor-wrapper`,"get-popup-container":k,value:g.value.value,"onUpdate:value":n[0]||=e=>g.value.value=e,cell:g.value,onBlur:O},null,40,[`style`,`value`,`cell`])):(0,l.unref)(vi).renders[_.value]?.renderEdit?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(Yi),{key:1,"cell-render":b[g.value.key],class:`ev-editor-wrapper`,style:(0,l.normalizeStyle)(x.value),"render-table-params":{data:a.data,row:g.value?.row,rowIndex:g.value?.rowIndex??-1,field:g.value?.key??``,title:g.value?.column?.title??``},bordered:!1,"get-popup-container":k,onBlur:O},null,8,[`cell-render`,`style`,`render-table-params`])):(0,l.createCommentVNode)(``,!0)],512),(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableEmptyRef`,ref:m},[(0,l.renderSlot)(t.$slots,`empty`,{},()=>[(0,l.createVNode)(r,{description:`空数据`})])],512),(0,l.createElementVNode)(`div`,{ref_key:`eVirtTableOverlayerRef`,ref:h},[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(v.value?.views||[],e=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{class:(0,l.normalizeClass)(e.class),style:(0,l.normalizeStyle)(e.style),key:e.type},[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.views,e=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{style:(0,l.normalizeStyle)(e.style),key:e.key},[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.cells,e=>((0,l.openBlock)(),(0,l.createElementBlock)(`div`,(0,l.mergeProps)({class:`canvas-cell`,key:`${e.rowKey}_${e.key}`,style:{...e.style}},{ref_for:!0},e.domDataset),[typeof e.render==`function`?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(e.render(e)),{key:0,bordered:!1})):typeof e.render==`string`&&e.render.startsWith(`slot:`)?(0,l.renderSlot)(t.$slots,e.render.replace(`slot:`,``),(0,l.mergeProps)({key:1,ref_for:!0},e,{cell:e})):(0,l.createCommentVNode)(``,!0)],16))),128))],4))),128))],6))),128))],512)],512)]),_:3},8,[`spinning`])}}}),ra={key:0},ia={key:1,class:`p-canvas-toolbar-wrapper flex items-center w-full justify-between p-theme-bg pt-8px px-16px`},aa={class:`flex items-center flex-1 gap-4px`},oa={class:`flex items-center gap-4px`},sa={class:`flex items-center gap-4px`},ca={key:2},la={class:`flex items-center gap-4px`},ua={class:`flex items-center gap-4px`},da={key:0,class:`w-full text-slate-5 pl-4`},fa=(0,l.defineComponent)({__name:`PCanvasGrid`,props:{staticConfig:{},manualFetch:{type:Boolean},formConfig:{},columns:{},toolbarConfig:{},pageConfig:{},proxyConfig:{},config:{},lazyReset:{type:Boolean,default:()=>Gr().lazyReset??!1},fitHeight:{default:()=>Gr().fitCanvasHeight??0},autoBoxSize:{type:Boolean,default:!1},autoBoxSizeOffset:{}},emits:[`toolbarButtonClick`,`toolbarToolClick`,`pick`,`resetQuery`],setup(e,{expose:t,emit:n}){let r=e,i=(0,l.useAttrs)(),a=n,{formConfig:o,pageConfig:s,columns:c,toolbarConfig:f,proxyConfig:p,config:m,staticConfig:h}=(0,l.toRefs)(r),g=Kr(),_=(0,l.computed)(()=>r.autoBoxSizeOffset??Gr().autoBoxSizeOffset),v=(0,l.ref)(Nr()),y=(0,l.ref)({}),b=(0,l.computed)(()=>({...r,config:{...g,...r.config}})),x=(0,l.computed)(()=>p.value&&p.value.ajax?s.value?`pagination`:`list`:`bad`);(0,l.computed)(()=>x.value===`pagination`?{current:w.page,total:E.value,pageSize:w.size,responsive:!1,showSizeChanger:!0,showTotal:e=>`共${e}条数据`}:!1);let S=(0,l.computed)(()=>(0,Z.omit)({labelCol:Xr,...o.value},[`items`])),C=(0,l.reactive)({toolbar:!1,form:!1,table:!1}),w=(0,l.reactive)({page:1,size:s.value?.pageSize??10}),T=(0,l.ref)(0),E=(0,l.ref)(0),D=(0,l.ref)([]),O=(0,l.ref)(),k=(0,l.ref)(),A=(0,l.ref)(),j=(0,l.ref)(),M=(0,l.ref)(),N=(0,l.ref)(),ee=(0,l.ref)(),P=(0,l.ref)(500),F=(0,l.ref)({}),te=e=>{F.value[w.page]=e},I=(0,l.reactive)([...(r.toolbarConfig?.buttons?.map(e=>e.code)??[]).filter(e=>e),...(r.toolbarConfig?.tools?.map(e=>e.code)??[]).filter(e=>e)].reduce((e,t)=>(e[t]=!1,e),{})),ne=(e,t)=>{I[e]=t},re=e=>{(0,Z.isObject)(e)?(Object.prototype.hasOwnProperty.call(e,`toolbar`)&&(C.toolbar=e.toolbar),Object.prototype.hasOwnProperty.call(e,`form`)&&(C.form=e.form),Object.prototype.hasOwnProperty.call(e,`table`)&&(C.table=e.table)):(0,Z.isBoolean)(e)&&(C.form=e,C.toolbar=e,C.table=e)},ie=(0,l.computed)(()=>(0,Z.uniq)(Object.values(F.value).flat(),e=>e[b.value.config?.ROW_KEY??`id`])),ae=()=>{fe()},oe=(0,l.computed)(()=>ie.value.map(e=>e[b.value.config?.ROW_KEY??`id`])),L=(e,t)=>t?{list:(0,Z.isString)(t.list)?(0,Z.get)(e,t.list):(0,Z.isFunction)(t.list)?t.list(e):void 0,total:(0,Z.isString)(t.total)?(0,Z.get)(e,t.total):(0,Z.isFunction)(t.total)?t.total(e):void 0,result:(0,Z.isString)(t.result)?(0,Z.get)(e,t.result):(0,Z.isFunction)(t.result)?t.result(e):void 0,message:(0,Z.isString)(t.message)?(0,Z.get)(e,t.message):(0,Z.isFunction)(t.message)?t.message(e):void 0}:{list:e},se=(0,Z.debounce)(e=>{a(`toolbarButtonClick`,{data:D.value,code:e,selectedKeys:oe.value,records:ie.value}),ge(e)},100),ce=({key:e})=>se(e),le=(0,Z.debounce)(e=>{a(`toolbarToolClick`,{data:D.value,code:e,selectedKeys:oe.value,records:ie.value}),ge(e)},100),ue=()=>new Promise(e=>{if(x.value!==`bad`){re({table:!0,form:!0});let{ajax:t}=p.value;t.query({form:y.value,page:w}).then(t=>{let{list:n,total:r,result:i,message:a}=L(t,p.value.response);n?(D.value=n,T.value++):i?(D.value=i,E.value=r??i.length,T.value++):(D.value=[],T.value++,a&&ki(a)),e(D.value)}).catch(t=>{console.error(`fetchData error`,t),e([])}).finally(()=>{re({table:!1,form:!1})})}}),de=(e,t)=>(w.page=e,w.size=t,ue()),fe=()=>(w.page=1,F.value={},ue()),pe=(0,Z.debounce)(ue,160),me=(e,t)=>(Object.assign(y.value,e),w.page=1,t?Promise.resolve():pe()),he=(e,t)=>(y.value=e,w.page=1,t?Promise.resolve():pe()),ge=e=>{let{ajax:t}=p.value;switch(e){case`multiDelete`:t.multiDelete&&(oe.value.length>0?Ei({title:`警告`,content:`确认删除选中的数据吗?`}).then(()=>{re({table:!0,toolbar:!0}),t.multiDelete(oe.value).then(()=>{Di(`删除成功`),fe()}).catch(()=>{Oi(`删除失败`)}).finally(()=>{re({table:!1,toolbar:!1}),I.multiDelete=!1})}):ki(`请选择要删除的数据`));break}},_e=(0,l.computed)(()=>!h.value||!h.value.selectable&&!h.value.tree?c.value:[h.value.selectable&&h.value.tree?{type:`selection-tree`,width:40,widthFillDisable:!0,title:``}:h.value.selectable?{type:`selection`,width:40,widthFillDisable:!0,title:``}:h.value.tree?{type:`tree`,width:40,widthFillDisable:!0,title:``}:{type:`index`,width:40,widthFillDisable:!0,title:``},...c.value]),ve=e=>{if(o.value&&o.value.items.length>0){if(o.value.customReset)o.value.customReset();else{let e={};zr(o.value.items,t=>{t.field&&t.itemRender?Ir(t.itemRender.defaultValue)?e[t.field]=t.itemRender.defaultValue:e[t.field]=void 0:t.field&&t.slots&&(Ir(t.slots.defaultValue)?e[t.field]=t.slots.defaultValue:e[t.field]=void 0)}),y.value=e}a(`resetQuery`)}w.page=1,e||pe()},R=()=>(F.value={},ve()),z=e=>(0,Z.isFunction)(e)?e():e,ye=e=>(0,Z.isString)(e),B=null,be=()=>{B?.destroy(),B=null},xe=()=>{be(),!(!r.autoBoxSize||!A.value)&&(B=Fi(()=>A.value??void 0,()=>ji(_.value),{onLayout:()=>{(0,l.nextTick)(()=>H())}}),B.attach())};(0,l.watch)(()=>r.autoBoxSize,e=>{e?(0,l.nextTick)(()=>xe()):be()}),(0,l.watch)(_,()=>{r.autoBoxSize&&B?.update()},{deep:!0});let V=null,H=()=>{V&&cancelAnimationFrame(V),V=requestAnimationFrame(()=>{if(V=null,!N.value)return;let e=N.value.clientHeight,t=r.fitHeight??0;P.value=Math.max(e-t,100)})},U=null;(0,l.watch)(j,e=>{U?.disconnect(),U=null,e&&(U=new ResizeObserver(()=>H()),U.observe(e))},{immediate:!0}),(0,l.watch)(x,()=>(0,l.nextTick)(()=>H()));let Se,W=null,G=null;return(0,l.onMounted)(()=>{if(H(),window.addEventListener(`resize`,H),Se=new MutationObserver(e=>{e.forEach(e=>{if(e.type===`attributes`&&e.attributeName===`style`){let t=e.target;window.getComputedStyle(t).display!==`none`&&H()}})}),A.value){Se.observe(A.value,{attributes:!0,attributeFilter:[`style`]}),W=new ResizeObserver(()=>H());let e=A.value.parentElement;for(let t=0;t<5&&e&&e!==document.body;t++)W.observe(e),e=e.parentElement}G=new ResizeObserver(()=>H()),N.value&&G.observe(N.value),ve(r.manualFetch),(0,l.nextTick)(()=>{r.autoBoxSize&&xe(),H()})}),(0,l.onBeforeUnmount)(()=>{V&&cancelAnimationFrame(V),window.removeEventListener(`resize`,H),Se.disconnect(),U?.disconnect(),W?.disconnect(),G?.disconnect(),be()}),t({commitProxy:{query:pe,reload:R,reloadPage:fe,passQuery:me,forcePassQuery:he},$canvasTable:(0,l.computed)(()=>k.value),selectedRowKeys:oe,setBtnLoading:ne,selectedRecords:ie,$form:(0,l.computed)(()=>O.value),getFormData:()=>y.value,setLoadings:re,resizeTable:H}),(t,n)=>{let a=(0,l.resolveComponent)(`a-menu-item`),s=(0,l.resolveComponent)(`a-menu`),c=(0,l.resolveComponent)(`a-dropdown`);return(0,l.openBlock)(),(0,l.createElementBlock)(`div`,(0,l.mergeProps)({ref_key:`boxEl`,ref:A,class:[`p-wrapper flex flex-col gap-8px overflow-y-auto`,e.autoBoxSize?`min-h-0 min-w-0 flex-1 w-full`:`h-full`]},(0,l.unref)(i)),[x.value===`bad`?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,ra,`请检查配置`)):((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.unref)(o)?.items?.some(e=>e.field&&e.itemRender)?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,{key:0,class:`p-pane p-form-wrapper`,ref_key:`pFormWrapper`,ref:j},[(0,l.createVNode)((0,l.unref)(u.Spin),{spinning:C.form},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Form),(0,l.mergeProps)({key:v.value,ref_key:`formEl`,ref:O,model:y.value},S.value,{onSubmit:ae}),{default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(u.Row),{gutter:[6,12]},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)((0,l.unref)(o).items,(e,t)=>((0,l.openBlock)(),(0,l.createBlock)(Si,{key:`_col_${e.field||t}`,"form-data":y.value,item:e,onReset:n[0]||=e=>ve(r.lazyReset)},null,8,[`form-data`,`item`]))),128))]),_:1})]),_:1},16,[`model`]))]),_:1},8,[`spinning`])],512)):(0,l.createCommentVNode)(``,!0),(0,l.unref)(f)?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,ia,[(0,l.createElementVNode)(`div`,aa,[(0,l.unref)(f).buttons&&(0,l.unref)(f).buttons.length>0?((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,{key:0},(0,l.renderList)((0,l.unref)(f).buttons,(e,t)=>((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:t},[e.dropdowns&&e.dropdowns.length?((0,l.openBlock)(),(0,l.createBlock)(c,{key:0},{overlay:(0,l.withCtx)(()=>[(0,l.createVNode)(s,{onClick:ce},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.dropdowns,e=>((0,l.openBlock)(),(0,l.createBlock)(a,{key:e.code},{default:(0,l.withCtx)(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.content),1)]),_:2},1024))),128))]),_:2},1024)]),default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(u.Button),{type:e.type,size:e.size??`middle`,disabled:(0,l.unref)(f).disabled||e.disabled,loading:C.toolbar||!!e.code&&I[e.code],danger:e.danger,shape:e.shape,ghost:e.ghost,block:e.block},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,oa,[e.icon?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(ui),{key:0,icon:e.icon},null,8,[`icon`])):(0,l.createCommentVNode)(``,!0),e.content&&ye(z(e.content))?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createTextVNode)((0,l.toDisplayString)(z(e.content)),1)],64)):e.content?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(z(e.content)),{key:2})):(0,l.createCommentVNode)(``,!0),(0,l.createVNode)((0,l.unref)(d.DownOutlined))])]),_:2},1032,[`type`,`size`,`disabled`,`loading`,`danger`,`shape`,`ghost`,`block`])]),_:2},1024)):e.code?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Button),{key:1,type:e.type,size:e.size??`middle`,disabled:(0,l.unref)(f).disabled||e.disabled,loading:C.toolbar||!!e.code&&I[e.code],danger:e.danger,shape:e.shape,ghost:e.ghost,block:e.block,onClick:t=>(0,l.unref)(se)(e.code)},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,sa,[e.icon?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(ui),{key:0,icon:e.icon},null,8,[`icon`])):(0,l.createCommentVNode)(``,!0),e.content&&ye(z(e.content))?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createTextVNode)((0,l.toDisplayString)(z(e.content)),1)],64)):e.content?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(z(e.content)),{key:2})):(0,l.createCommentVNode)(``,!0)])]),_:2},1032,[`type`,`size`,`disabled`,`loading`,`danger`,`shape`,`ghost`,`block`,`onClick`])):((0,l.openBlock)(),(0,l.createElementBlock)(`div`,ca))],64))),128)):(0,l.createCommentVNode)(``,!0)]),(0,l.createElementVNode)(`span`,la,[(0,l.unref)(f).tools&&(0,l.unref)(f).tools.length>0?((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,{key:0},(0,l.renderList)((0,l.unref)(f).tools,(e,t)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Button),{key:t,type:e.type,size:e.size??`middle`,disabled:(0,l.unref)(f).disabled||e.disabled,danger:e.danger,shape:e.shape,ghost:e.ghost,block:e.block,onClick:t=>(0,l.unref)(le)(e.code),loading:C.toolbar||!!e.code&&I[e.code]},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,ua,[e.icon?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(ui),{key:0,icon:e.icon},null,8,[`icon`])):(0,l.createCommentVNode)(``,!0),e.content&&ye(z(e.content))?((0,l.openBlock)(),(0,l.createElementBlock)(l.Fragment,{key:1},[(0,l.createTextVNode)((0,l.toDisplayString)(z(e.content)),1)],64)):e.content?((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(z(e.content)),{key:2})):(0,l.createCommentVNode)(``,!0)])]),_:2},1032,[`type`,`size`,`disabled`,`danger`,`shape`,`ghost`,`block`,`onClick`,`loading`]))),128)):(0,l.createCommentVNode)(``,!0)])])):(0,l.createCommentVNode)(``,!0),(0,l.createElementVNode)(`div`,{ref_key:`tableWrapperEl`,ref:M,class:`flex-1 h-0 min-h-0 flex flex-col p-inner-scroll`},[(0,l.createElementVNode)(`div`,{ref_key:`tableBodyEl`,ref:N,class:`flex-1 min-h-0 overflow-hidden`},[(0,l.createVNode)(na,{ref_key:`canvasTableRef`,ref:k,columns:_e.value,config:{...b.value.config,HEIGHT:P.value},data:D.value,loading:C.table,onSelectionChange:te},(0,l.createSlots)({_:2},[(0,l.renderList)(t.$slots,(e,n)=>({name:n,fn:(0,l.withCtx)(e=>[(0,l.renderSlot)(t.$slots,n,(0,l.normalizeProps)((0,l.guardReactiveProps)(e)))])}))]),1032,[`columns`,`config`,`data`,`loading`])],512),(0,l.createElementVNode)(`div`,{ref_key:`tableFooterEl`,ref:ee,class:`flex-shrink-0`},[(0,l.unref)(h)?.selectable&&(0,l.unref)(h).showCount?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,da,` 已选:`+(0,l.toDisplayString)(oe.value.length),1)):(0,l.createCommentVNode)(``,!0),x.value===`pagination`?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Pagination),{key:1,class:`p-canvas-pagination`,size:`small`,current:w.page,"page-size":w.size,total:E.value,onChange:de},null,8,[`current`,`page-size`,`total`])):(0,l.createCommentVNode)(``,!0)],512)],512)],64))],16)}}}),pa=(0,l.defineComponent)({__name:`PGroupBlock`,props:{name:{},getFormSetting:{type:Function},source:{}},setup(e,{expose:t}){let n=e,r=(0,l.ref)(),{source:i}=(0,l.toRefs)(n),a=(0,l.computed)(()=>r.value?.$form),o=(0,l.computed)(()=>n.getFormSetting(i.value));return t({$form:a}),(t,n)=>((0,l.openBlock)(),(0,l.createBlock)(wi,(0,l.mergeProps)({name:e.name,ref_key:`formEl`,ref:r},o.value,{data:(0,l.unref)(i)}),null,16,[`name`,`data`]))}}),ma=(0,l.defineComponent)({__name:`CollapseCard`,props:{defaultCollapsed:{type:Boolean,default:!1},title:{default:void 0},collapsible:{type:Boolean,default:!1}},setup(e,{expose:t}){let n=(0,l.ref)(e.defaultCollapsed?[]:[`content`]);return t({collapse:()=>{n.value=[]},expand:()=>{n.value=[`content`]}}),(t,r)=>{let i=(0,l.resolveComponent)(`a-collapse-panel`),a=(0,l.resolveComponent)(`a-collapse`),o=(0,l.resolveComponent)(`a-card`);return e.collapsible?((0,l.openBlock)(),(0,l.createBlock)(a,{key:0,"active-key":n.value,"onUpdate:activeKey":r[0]||=e=>n.value=e,class:`collapsible-card`},{default:(0,l.withCtx)(()=>[(0,l.createVNode)(i,{key:`content`,"force-render":``,header:e.title},(0,l.createSlots)({_:2},[(0,l.renderList)(t.$slots,(e,n)=>({name:n,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,n)])}))]),1032,[`header`])]),_:3},8,[`active-key`])):((0,l.openBlock)(),(0,l.createBlock)(o,{key:1,size:`small`,title:e.title},(0,l.createSlots)({_:2},[(0,l.renderList)(t.$slots,(e,n)=>({name:n,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,n)])}))]),1032,[`title`]))}}}),ha=(0,l.defineComponent)({__name:`PFormGroup`,props:(0,l.mergeModels)({name:{},getFormSetting:{type:Function},title:{},tabLabel:{},getTabLabel:{type:Function},editAble:{type:Boolean},showAdd:{type:Boolean},collapsible:{type:Boolean},defaultCollapsed:{type:Boolean},lazyErrorMark:{type:Boolean},forceRender:{type:Boolean},keepSerial:{type:Boolean},loading:{type:Boolean},itemMenus:{},createItem:{type:Function},max:{},menuHandler:{type:Function}},{modelValue:{type:Array,default:()=>[]},modelModifiers:{}}),emits:[`update:modelValue`],setup(e,{expose:t}){let n=u.Form.useForm,r=(0,l.ref)(),i=e,a=(0,l.ref)(),o=(0,l.useModel)(e,`modelValue`),s=(0,l.ref)(0),c=(0,l.ref)([]),f=(0,l.ref)([]),p=e=>{s.value=e},m=(0,l.computed)(()=>i.max??1/0),h=e=>{(i.createItem??(()=>Promise.resolve({})))({list:o.value}).then(t=>{o.value=[...o.value,{...t,__index:((0,Z.max)(o.value,e=>e.__index??-1)?.__index??-1)+1}],s.value=e})},g=i.itemMenus??[{content:`复制`,code:`copy`},{content:`删除`,code:`delete`}],_=e=>e?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement??a.value?.$el??document.body,v=(0,l.computed)(()=>i.forceRender||o.value.length<=5),y=e=>{let t=o.value.find((t,n)=>n===e)?.__index;Q(t)&&(c.value=c.value.filter(e=>e!==t))},b=()=>{(0,l.nextTick)().then(()=>{y(s.value),f.value[s.value]?.$form?.validate()})},x=(e,t)=>i.getTabLabel?.(e,t)??`${i.tabLabel} ${i.keepSerial?t+1:(e.__index??0)+1}`;(0,l.watch)(()=>o.value,()=>{if(!i.keepSerial){let e=o.value.filter(e=>!Q(e.__index));e.length>0&&e.forEach(e=>{e.__index=((0,Z.max)(o.value,e=>e.__index??-1)?.__index??-1)+1})}},{immediate:!0});let S=(0,Z.debounce)(({key:e},t,n)=>{if(i.menuHandler&&(0,Z.isFunction)(i.menuHandler))i.menuHandler({code:(0,Z.toString)(e),data:t,index:n});else switch(e){case`delete`:o.value=o.value.filter((e,t)=>t!==n),(0,l.nextTick)(()=>{f.value=f.value.filter(e=>!!e),n<=s.value&&s.value>0&&s.value--});break;case`copy`:if(o.value.length>=m.value){ki(`已达到最大数量`);return}o.value=[...o.value,(0,Z.clone)({...(0,Z.omit)(t,[`id`,`__index`]),__index:((0,Z.max)(o.value,e=>e.__index??-1)?.__index??-1)+1})];break}},100);(0,l.watchEffect)(()=>{o.value.length===0?s.value=0:s.value>=o.value.length&&(s.value=o.value.length-1)});let C=(0,Z.debounce)(y,50);(0,l.watchEffect)(()=>{let e=o.value.map((e,t)=>c.value.includes(e.__index)?t:void 0).filter(Q),t=r.value?.$el;t&&t.querySelectorAll(`:scope >.ant-tabs-nav>.ant-tabs-nav-wrap>.ant-tabs-nav-list>.ant-tabs-tab>.ant-tabs-tab-btn`).forEach((t,n)=>{e.includes(n)?t.classList.add(`p-error-group-tab`):t.classList.remove(`p-error-group-tab`)})}),t({collapse:()=>{a.value?.collapse?.()},expand:()=>{a.value?.expand?.()},activeKey:(0,l.computed)(()=>s.value),setActiveKey:p,validateAll:()=>{let e=v.value?f.value.map(e=>e.$form?.validate()):o.value.map(e=>n(e,i.getFormSetting(e).rules)?.validate()??Promise.resolve());return Promise.allSettled(e).then(e=>{if(c.value=e.map((e,t)=>e.status===`rejected`&&typeof o.value[t]?.__index==`number`?o.value[t].__index:void 0).filter(e=>typeof e==`number`),!i.lazyErrorMark&&c.value.length){let e=c.value[0],t=o.value.findIndex(t=>t.__index===e);t!==-1&&(s.value=t)}return c.value.length?Promise.reject({error_indexes:c.value,results:e}):Promise.resolve(e)})},validate:async(e,t)=>{let r=o.value.findIndex(t=>t.__index===e);try{return await(v.value?f.value[r]?.$form?.validate()??Promise.resolve():n(o.value[r],i.getFormSetting(o.value[r]).rules)?.validate()??Promise.resolve()),c.value=c.value.filter(t=>t!==e),Promise.resolve()}catch(n){return!c.value.includes(e)&&!t&&(c.value=[...c.value,e]),Promise.reject(n)}},validateFields:async(e,t,r)=>{let a=o.value.findIndex(t=>t.__index===e),s=i.getFormSetting(o.value[a]).rules,l=n(o.value[a],s);try{return await(v.value?f.value[a]?.$form?.validateFields(t)??Promise.resolve():Promise.allSettled(t.map(e=>l.validateField(e,o.value[a][e],s[e]??[])))),Promise.resolve()}catch(t){return!c.value.includes(e)&&!r&&(c.value=[...c.value,e]),Promise.reject(t)}}});let w=(0,l.useSlots)(),T=(0,l.computed)(()=>Object.keys(w).filter(e=>e.startsWith(`group-`)).map(e=>({original:e,target:e.replace(`group-`,``)})));return(t,n)=>{let i=(0,l.resolveComponent)(`a-spin`);return(0,l.openBlock)(),(0,l.createBlock)(ma,{ref_key:`rootRef`,ref:a,title:e.title,size:`small`,collapsible:e.collapsible,"default-collapsed":e.defaultCollapsed},(0,l.createSlots)({default:(0,l.withCtx)(()=>[e.loading?((0,l.openBlock)(),(0,l.createBlock)(i,{key:0,class:`w-full`})):((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Tabs),{key:1,ref_key:`tabsRef`,ref:r,type:`editable-card`,activeKey:s.value,"onUpdate:activeKey":n[1]||=e=>s.value=e,"hide-add":``,onChange:b},{rightExtra:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,`rightExtra`,{},()=>[e.showAdd&&o.value.length<m.value?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Button),{key:0,type:`link`,onClick:n[0]||=e=>h(o.value.length)},{default:(0,l.withCtx)(()=>[...n[2]||=[(0,l.createTextVNode)(` + 新增 `,-1)]]),_:1})):(0,l.createCommentVNode)(``,!0)])]),default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(o.value,(t,n)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.TabPane),{key:n,tab:x(t,n),"force-render":v.value},{closeIcon:(0,l.withCtx)(()=>[e.editAble&&(0,l.unref)(g)?.length?((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Dropdown),{key:0,"get-popup-container":_},{overlay:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(u.Menu),{onClick:e=>(0,l.unref)(S)(e,t,n)},{default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)((0,l.unref)(g).filter(e=>e.visibleMethod?.({data:t,index:n})??!0),e=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.MenuItem),{key:e.code},{default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,null,(0,l.toDisplayString)(e.content),1)]),_:2},1024))),128))]),_:2},1032,[`onClick`])]),default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(d.MoreOutlined))]),_:2},1024)):(0,l.createCommentVNode)(``,!0)]),default:(0,l.withCtx)(()=>[((0,l.openBlock)(),(0,l.createBlock)(pa,{ref_for:!0,ref_key:`blockInstance`,ref:f,key:n,source:t,name:e.name?`${e.name}_${n}`:void 0,"get-form-setting":e.getFormSetting,onFocusCapture:e=>(0,l.unref)(C)(n),onClickCapture:e=>(0,l.unref)(C)(n)},null,8,[`source`,`name`,`get-form-setting`,`onFocusCapture`,`onClickCapture`]))]),_:2},1032,[`tab`,`force-render`]))),128))]),_:3},8,[`activeKey`]))]),_:2},[(0,l.renderList)(T.value,e=>({name:e.target,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,e.original)])}))]),1032,[`title`,`collapsible`,`default-collapsed`])}}}),ga={class:`w-full text-right p-2`},_a=(0,l.defineComponent)({__name:`PromisePicker`,props:{gridSetting:{},title:{default:`数据选择`},width:{default:`70%`},multipleAllowEmpty:{type:Boolean,default:!1},bodyStyle:{default:()=>({})},beforePick:{type:Function,default:()=>Promise.resolve()}},setup(e,{expose:t}){let n=(0,l.ref)(),r=e,i=(0,l.computed)(()=>r.gridSetting.selectConfig?.multiple),a=(0,l.computed)(()=>({fitContent:!0,...r.gridSetting})),o={display:`flex`,flexDirection:`column`,minHeight:0,maxHeight:`min(80dvh, calc(100dvh - 200px))`,overflow:`hidden`},s,c,d,f=(0,l.reactive)({modal:!1}),p=()=>{d&&d()},m=()=>{f.modal=!1,d&&d()},h=({row:e,field:t})=>{s&&!i.value&&r.beforePick(e).then(()=>{f.modal=!1,s({row:e,field:t})})},g=()=>{let e=n.value?.selectedRecords??[];e.length===0&&!r.multipleAllowEmpty?ki(`请选择数据`):r.beforePick(e).then(()=>{f.modal=!1,c(e)})};return t({pick:()=>new Promise((e,t)=>{s=e,d=t,f.modal=!0}),pickMultiple:()=>new Promise((e,t)=>{c=e,d=t,f.modal=!0}),grid:n,hide:()=>{f.modal=!1}}),(t,r)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Modal),{open:f.modal,"onUpdate:open":r[0]||=e=>f.modal=e,"destroy-on-close":``,title:e.title,width:e.width,footer:i.value?void 0:null,onCancel:p,"body-style":e.bodyStyle},(0,l.createSlots)({default:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,{style:o},[(0,l.createVNode)(qi,(0,l.mergeProps)(a.value,{ref_key:`gridEl`,ref:n,onPick:h}),null,16)])]),_:2},[i.value?{name:`footer`,fn:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,ga,[(0,l.createElementVNode)(`span`,null,[(0,l.createVNode)((0,l.unref)(u.Button),{class:`mr-4`,onClick:m},{default:(0,l.withCtx)(()=>[...r[1]||=[(0,l.createTextVNode)(` 取消 `,-1)]]),_:1}),(0,l.createVNode)((0,l.unref)(u.Button),{type:`primary`,onClick:g},{default:(0,l.withCtx)(()=>[...r[2]||=[(0,l.createTextVNode)(` 确定 `,-1)]]),_:1})])])]),key:`0`}:void 0]),1032,[`open`,`title`,`width`,`footer`,`body-style`]))}}),va=(0,l.defineComponent)(e=>()=>{let{item:t,data:n,emptyText:r}=e;if(t.slots?.default)return t.slots.default({data:n,field:t.field});if(t.readonlyRender?.name){let e=t.readonlyRender,r=vi.renders[e.name]?.renderReadonly?.(e,{data:n,field:t.field,title:t.label},{})??null;if(r!==null)return r}if(!t.field)return r;let i=n?.[t.field];return Ir(i)?i:r},{name:`PDescriptionContent`,props:[`item`,`data`,`emptyText`]}),ya=(0,l.defineComponent)({__name:`PDescription`,props:{data:{},items:{},title:{},extra:{},bordered:{type:Boolean,default:!1},size:{default:`default`},column:{default:3},layout:{default:`horizontal`},colon:{type:Boolean,default:!0},labelStyle:{},contentStyle:{},emptyText:{default:`-`}},setup(e){let t=e,n=(0,l.computed)(()=>({title:t.title,extra:t.extra,bordered:t.bordered,size:t.size,column:t.column,layout:t.layout,colon:t.colon,labelStyle:t.labelStyle,contentStyle:t.contentStyle}));return(t,r)=>{let i=(0,l.resolveComponent)(`a-descriptions-item`),a=(0,l.resolveComponent)(`a-descriptions`);return(0,l.openBlock)(),(0,l.createBlock)(a,(0,l.mergeProps)(n.value,{class:`p-description`}),(0,l.createSlots)({default:(0,l.withCtx)(()=>[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(e.items,(t,n)=>((0,l.openBlock)(),(0,l.createBlock)(i,{key:`_desc_${t.field??n}`,label:t.label,span:t.span,"label-style":t.labelStyle,"content-style":t.contentStyle},(0,l.createSlots)({default:(0,l.withCtx)(()=>[(0,l.createVNode)((0,l.unref)(va),{item:t,data:e.data,"empty-text":e.emptyText||`-`},null,8,[`item`,`data`,`empty-text`])]),_:2},[t.slots?.label?{name:`label`,fn:(0,l.withCtx)(()=>[((0,l.openBlock)(),(0,l.createBlock)((0,l.resolveDynamicComponent)(t.slots.label)))]),key:`0`}:void 0]),1032,[`label`,`span`,`label-style`,`content-style`]))),128))]),_:2},[t.$slots.title||e.title?{name:`title`,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,`title`,{},()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.title),1)])]),key:`0`}:void 0,t.$slots.extra||e.extra?{name:`extra`,fn:(0,l.withCtx)(()=>[(0,l.renderSlot)(t.$slots,`extra`,{},()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.extra),1)])]),key:`1`}:void 0]),1040)}}});function ba(e){e&&Vr(e)}var xa={install(e){e.component(`PForm`,wi),e.component(`PGrid`,qi),e.component(`PCanvasTable`,na),e.component(`PCanvasGrid`,fa),e.component(`PFormGroup`,ha),e.component(`PGroupBlock`,pa),e.component(`PromisePicker`,_a),e.component(`PDescription`,ya)},addFormatter:ai,addRender:_i,setup:ba};exports.PCanvasGrid=fa,exports.PCanvasTable=na,exports.PDescription=ya,exports.PForm=wi,exports.PFormGroup=ha,exports.PGrid=qi,exports.PGroupBlock=pa,exports.PromisePicker=_a,exports.addFormatter=ai,exports.addRender=_i,exports.applyViewportRestSize=Ni,exports.cleanCol=Jr,exports.createAutoViewportBoxController=Fi,exports.default=xa,exports.defaultItemResponsive=Yr,exports.defaultLabelCol=Xr,exports.get24rest=Qr,exports.getButtonResponsive=ei,exports.getTooltipRenderer=Hr,exports.getUIKitConfig=Ur,exports.labelColDict=Zr,exports.parseAutoViewportBoxOffset=ji,exports.resetUIKitConfig=qr,exports.setUIKitConfig=Vr,exports.setup=ba,exports.watchPreviousDeep=ti;
|