rowvia 0.3.1 → 0.3.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.
@@ -1,37 +1,37 @@
1
- (function(X,Ge){typeof exports=="object"&&typeof module<"u"?Ge(exports):typeof define=="function"&&define.amd?define(["exports"],Ge):(X=typeof globalThis<"u"?globalThis:X||self,Ge(X.Rowvia={}))})(this,function(X){"use strict";var br=Object.defineProperty;var Cr=(X,Ge,wt)=>Ge in X?br(X,Ge,{enumerable:!0,configurable:!0,writable:!0,value:wt}):X[Ge]=wt;var w=(X,Ge,wt)=>Cr(X,typeof Ge!="symbol"?Ge+"":Ge,wt);function D(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let fs=0;function Ut(s="id"){return`${s}-${++fs}`}function _e(s,e){if(typeof s!="number"||isNaN(s))return String(s??"");const t=e??0,n=s.toFixed(t),[i,o]=n.split("."),a=i.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${a}.${o}`:a}function jt(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function gs(s,e){if(s===e)return 0;if(s==null)return-1;if(e==null)return 1;if(typeof s=="number"&&typeof e=="number")return s-e;if(s instanceof Date&&e instanceof Date)return s.getTime()-e.getTime();const t=String(s).toLowerCase(),n=String(e).toLowerCase();return t<n?-1:t>n?1:0}function ms(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ve extends Error{constructor(e){super(e),this.code=e}}const vs=/^\$?[A-Za-z]{1,3}\$?\d+$/;function Tn(s){const e=[];let t=0;for(;t<s.length;){const n=s[t];if(n===" "||n===" "||n===`
2
- `||n==="\r"){t++;continue}if(n==='"'||n==="'"){const o=n;let a="";for(t++;t<s.length&&s[t]!==o;)a+=s[t++];t++,e.push({type:"string",value:a});continue}if(/[0-9]/.test(n)||n==="."&&/[0-9]/.test(s[t+1]||"")){let o="";for(;t<s.length&&/[0-9.]/.test(s[t]);)o+=s[t++];if(s[t]==="e"||s[t]==="E")for(o+=s[t++],(s[t]==="+"||s[t]==="-")&&(o+=s[t++]);t<s.length&&/[0-9]/.test(s[t]);)o+=s[t++];e.push({type:"number",value:o});continue}if(/[A-Za-z_$]/.test(n)){let o="";for(;t<s.length&&/[A-Za-z0-9_$.]/.test(s[t]);)o+=s[t++];vs.test(o)?e.push({type:"cell",value:o.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:o});continue}if(n==="("){e.push({type:"lparen",value:n}),t++;continue}if(n===")"){e.push({type:"rparen",value:n}),t++;continue}if(n===","||n===";"){e.push({type:"comma",value:","}),t++;continue}const i=s.slice(t,t+2);if(["<=",">=","<>"].includes(i)){e.push({type:"op",value:i}),t+=2;continue}if("+-*/^%&=<>,:".includes(n)){e.push({type:"op",value:n}),t++;continue}throw new Ve("#NAME?")}return e}const Nn={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function In(s){let e=0;const t=()=>s[e],n=()=>s[e++];function i(r=0){let d=o();for(;t()&&t().type==="op"&&Nn[t().value]>=r;){const c=n().value,p=i(Nn[c]+1);d={type:"binary",operator:c,left:d,right:p}}return d}function o(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){n();const d=o();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return a()}function a(){const r=n();if(!r)throw new Ve("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=t();if(c&&c.type==="lparen"){n();const p=[];if(t()&&t().type!=="rparen")for(p.push(i());t()&&t().type==="comma";)n(),p.push(i());if(!t()||t().type!=="rparen")throw new Ve("#ERROR!");return n(),{type:"call",name:d,args:p}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=i();if(!t()||t().type!=="rparen")throw new Ve("#ERROR!");return n(),d}throw new Ve("#ERROR!")}const l=i();if(e<s.length)throw new Ve("#ERROR!");return l}function ye(s){if(s==null||s==="")return 0;if(typeof s=="number")return s;if(typeof s=="boolean")return s?1:0;if(s instanceof Date)return s.getTime();const e=Number(s);return isNaN(e)?0:e}function at(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...at(t));else if(t!=null&&t!==""){const n=typeof t=="number"?t:Number(t);isNaN(n)||e.push(n)}return e}const Nt={SUM:s=>at(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=at(s);return e.length?e.reduce((t,n)=>t+n,0)/e.length:0},AVG:s=>Nt.AVERAGE(s,{}),MIN:s=>{const e=at(s);return e.length?Math.min(...e):0},MAX:s=>{const e=at(s);return e.length?Math.max(...e):0},COUNT:s=>at(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(ye(s[0])),ROUND:s=>{const e=s.length>1?ye(s[1]):0,t=Math.pow(10,e);return Math.round(ye(s[0])*t)/t},FLOOR:s=>Math.floor(ye(s[0])),CEIL:s=>Math.ceil(ye(s[0])),CEILING:s=>Math.ceil(ye(s[0])),SQRT:s=>{const e=ye(s[0]);return e<0?(()=>{throw new Ve("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(ye(s[0]),ye(s[1])),POW:s=>Math.pow(ye(s[0]),ye(s[1])),MOD:s=>{const e=ye(s[1]);if(e===0)throw new Ve("#DIV/0!");return ye(s[0])%e},CONCAT:s=>s.map(e=>e==null?"":String(e)).join(""),CONCATENATE:s=>s.map(e=>e==null?"":String(e)).join(""),UPPER:s=>String(s[0]??"").toUpperCase(),LOWER:s=>String(s[0]??"").toLowerCase(),LEN:s=>String(s[0]??"").length,LEFT:s=>String(s[0]??"").slice(0,s.length>1?ye(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?ye(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,ye(s[1])-1),n=s.length>2?ye(s[2]):e.length-t;return e.slice(t,t+n)},TRIM:s=>String(s[0]??"").trim(),IF:s=>s[0]?s[1]??!0:s[2]??!1,IFS:s=>{for(let e=0;e<s.length-1;e+=2)if(s[e])return s[e+1];return s.length%2===1?s[s.length-1]:!1},AND:s=>s.every(e=>!!e),OR:s=>s.some(e=>!!e),NOT:s=>!s[0],IFERROR:s=>{try{return s[0]===null||s[0]===void 0?s[1]:s[0]}catch{return s[1]}},ISNUMBER:s=>typeof s[0]=="number"||s[0]!==null&&s[0]!==""&&!isNaN(Number(s[0])),ISBLANK:s=>s[0]===null||s[0]===void 0||s[0]==="",ISTEXT:s=>typeof s[0]=="string",PI:()=>Math.PI,RAND:()=>Math.random(),TODAY:()=>new Date().toISOString().slice(0,10),NOW:()=>new Date().toISOString(),YEAR:s=>new Date(s[0]).getFullYear(),MONTH:s=>new Date(s[0]).getMonth()+1,DAY:s=>new Date(s[0]).getDate(),TEXT:s=>String(s[0]??""),VALUE:s=>ye(s[0]),NUMBER:s=>ye(s[0]),BETWEEN:s=>ye(s[0])>=ye(s[1])&&ye(s[0])<=ye(s[2])},It=Object.keys(Nt);function ws(s,e){Nt[s.toUpperCase()]=e,It.includes(s.toUpperCase())||It.push(s.toUpperCase())}function ys(s,e){const t=/^([A-Za-z]{1,3})(\d+)$/.exec(s);if(t&&e.a1Lookup)return e.a1Lookup(t[1].toUpperCase(),Number(t[2]))}function bs(s,e){const t=e.data||{};if(s in t)return t[s];const n=s.toLowerCase();for(const i of Object.keys(t))if(i.toLowerCase()===n)return t[i]}function yt(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return bs(s.value,e);case"cell":return ys(s.value,e);case"unary":return-ye(yt(s.operand,e));case"call":{const t=Nt[s.name];if(!t)throw new Ve("#NAME?");const n=s.args.map(i=>yt(i,e));return t(n,e)}case"binary":{const t=yt(s.left,e),n=yt(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof n=="string"?`${t??""}${n??""}`:ye(t)+ye(n);case"-":return ye(t)-ye(n);case"*":return ye(t)*ye(n);case"/":{const i=ye(n);if(i===0)throw new Ve("#DIV/0!");return ye(t)/i}case"^":return Math.pow(ye(t),ye(n));case"%":{const i=ye(n);if(i===0)throw new Ve("#DIV/0!");return ye(t)%i}case"&":return`${t??""}${n??""}`;case"=":return t===n;case"<>":return t!==n;case"<":return ye(t)<ye(n);case"<=":return ye(t)<=ye(n);case">":return ye(t)>ye(n);case">=":return ye(t)>=ye(n);default:throw new Ve("#ERROR!")}}default:throw new Ve("#ERROR!")}}function bt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,n=In(Tn(t));return yt(n,e)}function Kt(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function Yt(s,e){if(s==null)return;if(e in s)return s[e];const t=e.split(".");let n=s;for(const i of t){if(n==null)return;n=n[i]}return n}function Ee(s,e,t){const n=s.colDef,i=(e.group||e.footer)&&!!e.groupData&&e.groupData[s.colId]!==void 0,o=i?e.groupData:e.data,a=s.valueGetter??n.valueGetter;if(a)return(typeof a=="string"?r=>Kt(a)?bt(a,{data:r.data}):Yt(r.data,a):a)({data:i?e.groupData:e.data,node:e,column:s,api:t,colDef:n,getValue:r=>Yt(i?e.groupData:e.data,r)});if(s.field&&Kt(s.field))return bt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return bt(`=${s.field}`,{data:e.data});if(s.field)return Yt(o,s.field)}function At(s,e,t){var o;const n=Ee(s,e,t),i=s.colDef;if(i.showValueAs&&typeof n=="number"&&t){const a=(o=t.__columnTotalCache)==null?void 0:o.get(s.colId);if(a!==void 0&&a!==0)return`${(i.showValueAs==="percentOfParent"?n/(a||1)*100:n/a*100).toFixed(1)}%`}return i.valueFormatter?(typeof i.valueFormatter=="string"?l=>Cs(l.colDef.valueFormatter,l.value,l):i.valueFormatter)({value:n,data:e.data,node:e,column:s,api:t,colDef:i}):Ss(s,n)}function Cs(s,e,t={}){var n,i,o;if(e==null)return"";switch(s){case"number":return _e(e,((n=t.column)==null?void 0:n.decimals)??0);case"currency":return`$${_e(e,((i=t.column)==null?void 0:i.decimals)??2)}`;case"percent":return`${_e(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return An(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function An(s){const e=s instanceof Date?s:new Date(s);return isNaN(e.getTime())?String(s):`${e.getDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()]} ${e.getFullYear()}`}function Ss(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?_e(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?An(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function $n(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?n=>Fn(n.colDef.valueParser,n.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Fn(s.type,e)}function Fn(s,e){if(s==="numberColumn")return jt(e);if(s==="dateColumn"){if(e instanceof Date)return e;const t=new Date(e);return isNaN(t.getTime())?e:t}return s==="booleanColumn"?e===!0||e==="true":e}function Dn(s){const t=s.colDef.comparator,n=s.type;return(i,o)=>{const a=Ee(s,i,null),l=Ee(s,o,null);if(t)return t(a,l,i,o);if(n==="numberColumn"){const r=typeof a=="number"?a:jt(a),d=typeof l=="number"?l:jt(l);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(n==="dateColumn"){const r=a instanceof Date?a.getTime():new Date(a).getTime(),d=l instanceof Date?l.getTime():new Date(l).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return gs(a,l)}}function Ct(s,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:s,rowNode:null,data:null});const n=t.filter(i=>typeof i=="number"&&!isNaN(i));switch(e){case"sum":return n.reduce((i,o)=>i+o,0);case"count":return t.length;case"avg":return n.length?n.reduce((i,o)=>i+o,0)/n.length:null;case"min":return n.length?Math.min(...n):null;case"max":return n.length?Math.max(...n):null;case"first":return t.length?t[0]:null;case"last":return t.length?t[t.length-1]:null;default:return null}}function Es(s){const e={onInteraction:s.onInteraction,setRowData:n=>s.setRowData(n),applyTransaction:n=>s.applyTransaction(n),getRowNode:n=>s.getRowNode(n),getDisplayedRowCount:()=>s.getDisplayedRowCount(),getDisplayedRowAtIndex:n=>s.getDisplayedRowAtIndex(n),getFirstDisplayedRow:()=>s.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>s.getDisplayedRowAtIndex(s.getDisplayedRowCount()-1),forEachNode:n=>{const i=s.getRowModel();for(let o=0;o<i.getRowCount();o++){const a=i.getRow(o);a&&n(a,o)}},forEachLeafNode:n=>{s.getRowModel().forEachLeafNode(n)},getModel:()=>s.getRowModel(),getValue:(n,i)=>{const o=typeof n=="string"?s.getColumn(n):n;if(!(!o||!i))return Ee(o,i,s.getApi())},getSelectedRows:()=>s.getSelectionService().getSelectedRows(),getSelectedNodes:()=>s.getSelectionService().getSelectedNodes(),selectAll:()=>s.getSelectionService().selectAll(),deselectAll:()=>s.getSelectionService().deselectAll(),selectAllFiltered:()=>s.getSelectionService().selectAllFiltered(),deselectAllFiltered:()=>s.getSelectionService().deselectAll(),selectNode:(n,i)=>s.getSelectionService().selectNode(n,i??!1),deselectNode:n=>s.getSelectionService().deselectNode(n),setQuickFilter:n=>s.setQuickFilter(n),isQuickFilterPresent:()=>s.getQuickFilter().length>0,resetQuickFilter:()=>s.setQuickFilter(""),getSortModel:()=>s.getSortService().getSortModel(),setSortModel:n=>s.getSortService().setSortModel(n),getFilterModel:()=>s.getFilterService().getFilterModel(),setFilterModel:n=>s.getFilterService().setFilterModel(n),getColumnFilterModel:n=>{const i=typeof n=="string"?n:n.colId;return s.getFilterService().getFilterInstance(i)??null},setColumnFilterModel:(n,i)=>s.getFilterService().setColumnFilterModel(n,i),getAdvancedFilterModel:()=>s.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:n=>s.getFilterService().setAdvancedFilterModel(n),onFilterChanged:()=>s.getFilterService().onFilterChanged("api"),onSortChanged:()=>s.getSortService().onSortChanged("api"),expandAll:()=>s.getRowModel().expandAll(),collapseAll:()=>s.getRowModel().collapseAll(),onGroupExpandedOrCollapsed:()=>s.refreshModel("expand"),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),setRowNodePinned:(n,i)=>s.setRowNodePinned(n,i),getColumnDefs:()=>s.getColumnModel().getColumnDefs(),setColumnDefs:(n,i)=>{s.getColumnModel().setColumnDefs(n),s.onGridSizeChanged()},updateGridOptions:n=>s.updateGridOptions(n),setGridOption:(n,i)=>s.updateGridOptions({[n]:i}),sizeColumnsToFit:()=>{const n=s.getSideBarService().isVisible()?s.getSideBarService().getElement().offsetWidth:0;s.getColumnModel().sizeColumnsToFit(s.getGridDiv().clientWidth-n),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:n=>{s.getColumnModel().autoSizeAllColumns()},moveColumn:(n,i)=>s.getColumnModel().moveColumn(n,i),moveColumnByIndex:(n,i)=>s.getColumnModel().moveColumnByIndex(n,i),setColumnVisible:(n,i)=>s.getColumnApi().setColumnVisible(n,i),setColumnsPinned:(n,i)=>s.getColumnApi().setColumnsPinned(n,i),setColumnsVisible:(n,i)=>s.getColumnApi().setColumnsVisible(n,i),getAllColumns:()=>s.getAllColumns(),getColumns:()=>[...s.getColumns().left,...s.getColumns().center,...s.getColumns().right],getColumn:n=>s.getColumn(n)??null,getDisplayedLeftColumns:()=>s.getColumns().left,getDisplayedCenterColumns:()=>s.getColumns().center,getDisplayedRightColumns:()=>s.getColumns().right,getColumnState:()=>s.getColumnApi().getColumnState(),applyColumnState:(n,i)=>s.getColumnApi().applyColumnState(n,i),resetColumnState:()=>s.getColumnApi().resetColumnState(),openColumnMenu:n=>{const i=typeof n=="string"?s.getColumn(n):n;i!=null&&i.eHeaderCell&&s.getHeaderView().getHeaderCell(i)},setSideBarVisible:n=>{s.getSideBarService().setVisible(n),s.onGridSizeChanged()},isSideBarVisible:()=>s.getSideBarService().isVisible(),setSideBarPosition:n=>{s.getSideBarService().setPosition(n),s.onGridSizeChanged()},openToolPanel:n=>{s.getSideBarService().setVisible(!0),s.getSideBarService().openPanel(n),s.onGridSizeChanged()},closeToolPanel:()=>{s.getSideBarService().setVisible(!1),s.onGridSizeChanged()},getToolPanel:()=>s.getSideBarService().getActivePanel(),setStatusBarVisible:n=>s.getSideBarService()&&s.getOptions(),getSideBar:()=>s.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.isLastPageFound())??!0},paginationGetPageSize:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getPageSize())??0},paginationGetCurrentPage:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getCurrentPage())??0},paginationGetTotalPages:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getTotalPages())??1},paginationGetRowCount:()=>s.getDisplayedRowCount(),paginationGoToPage:n=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToPage(n)},paginationGoToNextPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToNextPage()},paginationGoToPreviousPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToPreviousPage()},paginationGoToFirstPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToFirstPage()},paginationGoToLastPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToLastPage()},paginationSetPageSize:n=>{var i;return(i=s.getPaginationService())==null?void 0:i.setPageSize(n)},startEditingCell:n=>s.getEditService().startEditingCell(n),stopEditing:n=>s.getEditService().stopEditing(n),getEditingCells:()=>s.getEditService().getEditingCells(),setFocusedCell:(n,i)=>{const o=typeof i=="string"?s.getColumn(i):i;o&&s.getEditService().setFocusedCell(n,o)},getFocusedCell:()=>{const n=s.getEditService().getFocusedCell();return n?{rowIndex:n.rowIndex,column:n.column,rowNode:n.rowNode}:null},clearFocusedCell:()=>s.getEditService().clearFocusedCell(),tabToNextCell:()=>s.getEditService().tabToNextCell(),tabToPreviousCell:()=>s.getEditService().tabToPreviousCell(),refreshCells:n=>s.getRowRenderer().refreshCells(n),redrawRows:n=>s.getRowRenderer().redrawRows(n),flashCells:n=>s.getRowRenderer().flashCells(n||{}),ensureIndexVisible:(n,i)=>s.getRowRenderer().ensureIndexVisible(n,i),ensureNodeVisible:n=>{let i=-1;s.getRowModel().forEachNode((o,a)=>{o.id===n.id&&(i=a)}),i>=0&&s.getRowRenderer().ensureIndexVisible(i)},ensureColumnVisible:n=>{const i=typeof n=="string"?s.getColumn(n):n;i&&s.getRowRenderer().ensureColumnVisible(i)},copyToClipboard:n=>s.getExportService().copyToClipboard(n),cutToClipboard:n=>s.getExportService().cutToClipboard(n),pasteFromClipboard:()=>s.getExportService().pasteFromClipboard(),exportToCsv:n=>s.getExportService().exportToCsv(n||{}),exportToExcel:n=>s.getExportService().exportToExcel(n||{}),exportToPdf:n=>s.getExportService().exportToPdf(n||{}),importExcel:(n,i)=>s.getExportService().importExcel(n,i||{}),getDataAsPdf:n=>s.getExportService().getDataAsPdf(n||{}),getDataAsCsv:n=>s.getExportService().getDataAsCsv(n||{}),getDataAsExcel:n=>s.getExportService().getDataAsExcel(n||{}),getChartData:n=>s.getChartService().getChartData(n||{}),getChartModels:()=>s.getChartService().getChartModels(),createChart:()=>s.getChartService().createChart(),getCellRanges:()=>s.getRangeSelectionService().getRanges(),clearRangeSelection:()=>s.getRangeSelectionService().clearRanges(),addCellRange:n=>{const i=s.getRangeSelectionService();i.ranges=[n],i.applyHighlight(),i.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>s.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>s.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>s.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>s.getOverlayService().hideOverlay(),setServerSideDatasource:n=>{const i=s.getServerSideRowModel();i&&i.setDatasource(n)},setDatasource:n=>{var o;const i=s.getInfiniteRowModel();i?i.setDatasource(n):(o=s.getServerSideRowModel())==null||o.setDatasource(n)},setViewportDatasource:n=>{var i;(i=s.getViewportRowModel())==null||i.setViewportDatasource(n)},setViewportRange:(n,i)=>{var o;(o=s.getViewportRowModel())==null||o.setViewportRange(n,i)},refreshServerSide:n=>{const i=s.getServerSideRowModel();i&&(n!=null&&n.purge?i.purgeCache():i.onSortOrFilterChanged())},purgeServerSideCache:()=>{var n,i;(n=s.getServerSideRowModel())==null||n.purgeCache(),(i=s.getInfiniteRowModel())==null||i.onSortOrFilterChanged()},getServerSideStoreState:()=>{const n=s.getServerSideRowModel();if(!n)return[];const i=[];for(const[o,a]of n.stores)i.push({groupPath:o,rowCount:a.rows.length,lastRow:a.lastRow,loading:a.loading});return i},setRowCount:(n,i)=>{const o=s.getServerSideRowModel();if(!o)return;const a=o.getStore("");if(a)for(a.lastRow=i?n:null;a.rows.length<n;)a.rows.push(null);o.refreshModel("everything")},isServerSideStoreLoading:()=>s.isRemoteLoading(),undoCellEditing:()=>s.getUndoRedoService().undo(),redoCellEditing:()=>s.getUndoRedoService().redo(),canUndo:()=>s.getUndoRedoService().canUndo(),canRedo:()=>s.getUndoRedoService().canRedo(),getUndoRedoStackSize:()=>({undo:s.getUndoRedoService().getUndoStackSize(),redo:s.getUndoRedoService().getRedoStackSize()}),startBatchEdit:()=>s.getUndoRedoService().startBatchEdit(),endBatchEdit:n=>s.getUndoRedoService().endBatchEdit(n),cancelBatchEdit:()=>s.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>s.getUndoRedoService().isBatchEditing(),getState:()=>{const n=s.getColumnApi(),i=s.getSelectionService(),o=s.getPaginationService();return{columns:n.getColumnState(),sort:s.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(s.getFilterService().getFilterModel())),quickFilter:s.getQuickFilter(),selectedRowIds:i.getSelectedNodes().map(a=>a.id),pagination:o!=null&&o.isEnabled()?{page:o.getCurrentPage(),pageSize:o.getPageSize()}:null,rowGroupColumns:s.getColumnModel().getRowGroupColumns().map(a=>a.colId),pivotMode:s.getColumnModel().isPivotMode()}},setState:n=>{if(!n)return;const i=s.getColumnApi();if(n.columns&&i.applyColumnState(n.columns,!0),n.sort&&s.getSortService().setSortModel(n.sort),n.filter&&s.getFilterService().setFilterModel(n.filter),n.quickFilter!==void 0&&s.setQuickFilter(n.quickFilter),n.rowGroupColumns&&s.getColumnModel().setRowGroupColumns(n.rowGroupColumns),n.pivotMode!==void 0&&s.getColumnModel().setPivotMode(n.pivotMode),n.selectedRowIds){s.getSelectionService().deselectAll();for(const a of n.selectedRowIds){const l=s.getRowNode(a);l&&s.getSelectionService().selectNode(l,!1)}}const o=s.getPaginationService();o&&n.pagination&&(o.setPageSize(n.pagination.pageSize),o.goToPage(n.pagination.page))},setNote:(n,i,o)=>{const a=typeof i=="string"?i:i.colId;s.getNotesService().setNote(n.id,a,o)},getNote:(n,i)=>{const o=typeof i=="string"?i:i.colId,a=s.getColumn(o);return s.getNotesService().getNote(n.id,o,a==null?void 0:a.colDef.note,{data:n.data,node:n,column:a,api:s.getApi()})},getGridId:()=>"rowvia",destroy:()=>s.destroy(),refreshClientSideRowModel:()=>s.refreshModel("everything"),setPivotMode:n=>s.getColumnModel().setPivotMode(n),isPivotMode:()=>s.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>s.getAllColumns(),getColumn:n=>s.getColumn(n)??null,getColumnState:()=>s.getColumnModel().getColumnState(),applyColumnState:(n,i)=>{s.getColumnModel().applyColumnState(n,i),s.refreshModel("group")},resetColumnState:()=>{s.getColumnModel().resetColumnState(),s.refreshModel("group")},setColumnVisible:(n,i)=>s.getColumnModel().setColumnVisible(n,i),setColumnsVisible:(n,i)=>s.getColumnModel().setColumnsVisible(n,i),setColumnPinned:(n,i)=>s.getColumnModel().setColumnPinned(n,i),setColumnsPinned:(n,i)=>s.getColumnModel().setColumnsPinned(n,i),moveColumn:(n,i)=>s.getColumnModel().moveColumn(n,i),moveColumnByIndex:(n,i)=>s.getColumnModel().moveColumnByIndex(n,i),autoSizeColumn:n=>{s.getColumnModel().autoSizeColumn(n),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:n=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(n,i)=>s.getColumnModel().setRowGroupColumns(n,i),removeRowGroupColumns:n=>{for(const i of n)s.getColumnModel().removeRowGroupColumn(i)},addRowGroupColumn:n=>s.getColumnModel().addRowGroupColumn(n),setPivotColumns:n=>s.getColumnModel().setPivotColumns(n),removePivotColumns:n=>s.getColumnModel().setPivotColumns(n.map(()=>"").filter(i=>i!=="")),setValueColumns:n=>s.getColumnModel().setValueColumns(n),removeValueColumn:n=>s.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),getValueColumns:()=>s.getColumnModel().getValueColumns(),getPivotColumns:()=>s.getColumnModel().getPivotColumns(),setPivotMode:(n,i)=>s.getColumnModel().setPivotMode(n,i),isPivotMode:()=>s.getColumnModel().isPivotMode()}}}class Ze{constructor(e,t,n){w(this,"id");w(this,"__id");w(this,"data");w(this,"parent",null);w(this,"children",null);w(this,"group",!1);w(this,"key",null);w(this,"level",0);w(this,"uiLevel",0);w(this,"rowGroupIndex");w(this,"expanded",!1);w(this,"selectable",!0);w(this,"selected",!1);w(this,"rowPinned",null);w(this,"detailNode",null);w(this,"masterNode",null);w(this,"footer",!1);w(this,"groupData",null);w(this,"rowHeight",null);w(this,"allChildrenCount",null);w(this,"stub",!1);w(this,"rowIndex",null);w(this,"__displayIndex");w(this,"services");w(this,"__passesFilter",!0);w(this,"__childCount",0);w(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=Ut("row"),this.id=n??this.__id}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,t=!1,n="api"){return e?this.services.selectNode(this,t):this.services.deselectNode(this),0}isSelected(){return this.selected}setData(e){this.data=e}setDataValue(e,t){const n=typeof e=="string"?e:e.field;if(n&&this.data){const i=n.split(".");let o=this.data;for(;i.length>1;){const a=i.shift();o[a]===void 0&&(o[a]={}),o=o[a]}o[i[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class xs{constructor(e){w(this,"options");w(this,"eventService");w(this,"columns");w(this,"getFilterModel");w(this,"getQuickFilter");w(this,"isPaginationEnabled");w(this,"getPageSize");w(this,"getCurrentPage");w(this,"rowHeightProvider");w(this,"rowNodeServices");w(this,"rowData",[]);w(this,"rootRowNodes",[]);w(this,"dataRows",[]);w(this,"rowsToDisplay",[]);w(this,"rowNodeMap",new Map);w(this,"expandedGroups",new Set);w(this,"groupDefaultExpandedApplied",!1);w(this,"pinnedTopRows",[]);w(this,"pinnedBottomRows",[]);w(this,"totalRowCount",0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getFilterModel=e.getFilterModel,this.getQuickFilter=e.getQuickFilter,this.isPaginationEnabled=e.isPaginationEnabled,this.getPageSize=e.getPageSize,this.getCurrentPage=e.getCurrentPage,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices}getType(){return"clientSide"}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.rootRowNodes}getRowCount(){return this.rowsToDisplay.length}getTotalRowCount(){return this.totalRowCount}getRow(e){return this.rowsToDisplay[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.rowsToDisplay.forEach((t,n)=>e(t,n))}forEachLeafNode(e){let t=0;const n=i=>{for(const o of i)o.group?o.children&&n(o.children):o.footer||e(o,t++)};n(this.rootRowNodes)}getPinnedTopRowCount(){return this.pinnedTopRows.length}getPinnedBottomRowCount(){return this.pinnedBottomRows.length}getPinnedTopRow(e){return this.pinnedTopRows[e]}getPinnedBottomRow(e){return this.pinnedBottomRows[e]}getRowIndexAtPixel(e){return Math.floor(e/this.rowHeightProvider())}updateRowData(e){this.rowData=e||[],this.rebuildRows()}rebuildRows(){const e=new Map;this.options.treeData&&this.rowNodeMap.forEach(i=>{i.group&&e.set(i.id,i.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,n=this.rowData;if(this.options.treeData){const i=this.buildTreeData(n,t);this.rootRowNodes=i,this.rowNodeMap.forEach(o=>{o.group&&e.has(o.id)&&(o.expanded=e.get(o.id))})}else{const i=[];for(let o=0;o<n.length;o++){const a=n[o],l=t?t({data:a,level:0}):void 0,r=this.createRowNode(a,l);r.rowIndex=o,i.push(r)}this.rootRowNodes=i,this.dataRows=i}if(this.options.masterDetail&&!this.options.treeData){const i=this.options.isRowMaster||(()=>!0);for(const o of this.rootRowNodes){if(o.detailNode||!i({data:o.data,node:o}))continue;const a=this.createRowNode(null,`${o.id}|detail`,o,1);a.masterNode=o,a.selectable=!1,o.detailNode=a,o.expanded=!1}}this.refreshModel(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.gridApi})}createRowNode(e,t,n=null,i=0){const o=new Ze(e,this.rowNodeServices,t);return o.parent=n,o.level=i,o.uiLevel=i,o.__id=o.id,this.rowNodeMap.set(o.id,o),o}buildTreeData(e,t){const n=this.options.getDataPath||(d=>String(d.id??d.key).split("/")),i=this.options.treeDataChildrenField||"children",o=new Map,a=[],l=(d,c,p)=>{const h=n(d),u=h.join("/"),f=t?t({data:d,level:p}):u,g=this.createRowNode(d,f,c,p);g.key=h[h.length-1],o.set(u,g);const v=d[i];if(Array.isArray(v)&&v.length){g.children=[],g.group=!0,g.expanded=!0;for(const m of v){const y=l(m,g,p+1);g.children.push(y)}g.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(g),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||a.push(g),g},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const p of d.children)c+=r(p);return d.allChildrenCount=c,c};for(const d of a)r(d);for(const d of e){if(!d)continue;const p=n(d).slice(0,-1).join("/"),h=p&&o.get(p)||null;l(d,h??null,h?h.level+1:0)}return a}applyTransaction(e){const t=this.options.getRowId,n={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const i=new Set;for(const o of e.remove){const a=t?t({data:o,level:0}):o.id;a!==void 0?i.add(String(a)):i.add(o)}this.rowData=this.rowData.filter(o=>{const a=t?t({data:o,level:0}):o.id;return!i.has(String(a))&&!i.has(o)});for(const o of i){const a=this.rowNodeMap.get(String(o));a&&(this.rowNodeMap.delete(a.id),n.remove.push(a))}}if(e.update&&e.update.length)for(const i of e.update){const o=t?t({data:i,level:0}):i.id,a=o!==void 0?this.rowNodeMap.get(String(o)):void 0;if(a)this.rowData=this.rowData.map(l=>{const r=t?t({data:l,level:0}):l.id;return String(r)===String(o)?i:l}),a.data=i,n.update.push(a);else{const l=this.createRowNode(i,o!==void 0?String(o):void 0);this.rowData.push(i),n.add.push(l)}}if(e.add&&e.add.length){const i=e.addIndex;for(const o of e.add){const a=t?t({data:o,level:0}):void 0,l=this.createRowNode(o,a);n.add.push(l),i===void 0||i<0?this.rowData.push(o):this.rowData.splice(Math.min(i,this.rowData.length),0,o)}}return this.rebuildRows(),n}refreshModel(e){const t=this.columns().filter(n=>n.rowGroup);(!e||e==="everything"||e==="filter"||e==="group")&&this.doFilter(),(!e||e==="everything"||e==="sort"||e==="group")&&this.doSort(t),(!e||e==="everything"||e==="group")&&this.doGroup(t),this.buildDisplayRows(t),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}doFilter(){const e=this.getFilterModel(),t=this.getQuickFilter(),n=Object.keys(e).length>0,i=t&&t.trim().length>0,o=this.columns(),a=!!this.options.treeData,l=f=>{for(const[g,v]of Object.entries(e)){const m=o.find(y=>y.colId===g);if(m&&!this.doesNodePassFilter(f,m,v))return!1}return!0},r=f=>{const g=this.options.__advancedFilterPass;return g?g(f):!0},d=Object.entries(e).some(([f,g])=>{const v=o.find(m=>m.colId===f);return!v||!v.aggFunc?!1:g.filterType==="multi"?(g.filterModels||[]).length>0:!0}),c=f=>{if(f.__passesFilter=!0,f.children)for(const g of f.children)c(g)},p=f=>{const g=this.options;return typeof g.isExternalFilterPresent!="function"||!g.isExternalFilterPresent()||typeof g.doesExternalFilterPass!="function"?!0:g.doesExternalFilterPass(f)},h=f=>{if(!i)return!0;const g=t.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of v){const y=Ee(m,f,null);if(ms(g,y))return!0}return!1},u=f=>{let g=!0;if(!f.group||f.footer||a?g=(!n||l(f))&&h(f)&&p(f)&&r(f):d&&(g=(!n||l(f))&&r(f)),f.__passesFilter=g,f.children){let v=!1;for(const m of f.children)u(m)&&(v=!0);return f.group&&!f.footer&&(d?(f.__passesFilter=g,g&&c(f)):(f.__passesFilter=a?v||g:v,a&&g&&c(f))),f.__passesFilter}return g};for(const f of this.rootRowNodes)u(f)}doesNodePassFilterModel(e,t,n){return this.doesNodePassFilter(e,t,n)}doesNodePassFilter(e,t,n){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const c=[];Ft(e,c);const p=c.map(h=>Ee(t,h,null));r=Ct(t,t.aggFunc,p)}const d={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,t,n)}if(n.filterType==="multi"){const r=n.filterModels||[];if(r.length===0)return!0;const d=n.operator||"AND",c=r.map(p=>this.doesNodePassFilter(e,t,p));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(n.condition1||n.condition2){const{condition1:r,condition2:d,...c}=n,p=[this.doesNodePassFilter(e,t,{...c,...r||{}})];return d&&p.push(this.doesNodePassFilter(e,t,{...c,...d})),(n.operator||"AND")==="OR"?p.some(Boolean):p.every(Boolean)}const i=Ee(t,e,null),o=Ms(t,i),a=i,l=n.filterType||"text";if(l==="text"){const r=String(n.filter??"").toLowerCase();if(!r)return!0;const d=(a==null?"":String(a)).toLowerCase();switch(n.type){case"equals":return d===r;case"notEqual":return d!==r;case"startsWith":return d.startsWith(r);case"endsWith":return d.endsWith(r);case"contains":default:return d.includes(r)}}if(l==="number"){const r=typeof a=="number"?a:Number(a);if(isNaN(r))return!1;const d=Number(n.filter),c=n.filterTo!==void 0&&n.filterTo!==null&&n.filterTo!==""?Number(n.filterTo):null;switch(n.type){case"equals":return r===d;case"notEqual":return r!==d;case"lessThan":return r<d;case"lessThanOrEqual":return r<=d;case"greaterThan":return r>d;case"greaterThanOrEqual":return r>=d;case"inRange":return c!==null?r>=Math.min(d,c)&&r<=Math.max(d,c):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(l==="date"){const r=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(r))return!1;const d=n.dateFrom?new Date(n.dateFrom).getTime():null,c=n.dateTo?new Date(n.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return l==="boolean"?!!a==!!n.filter:l==="set"?(n.values||[]).map(d=>String(d)).includes(String(a)):!0}doSort(e){const t=[],n=this.columns();for(const a of n)a.sort&&a.sortIndex!==null&&t.push({column:a,direction:a.sort});t.sort((a,l)=>(a.column.sortIndex??0)-(l.column.sortIndex??0));const i=(a,l)=>{for(const{column:c,direction:p}of t){const h=Dn(c)(a,l)*(p==="asc"?1:-1);if(h!==0)return h}const r=a.rowIndex??0,d=l.rowIndex??0;return r-d},o=a=>{a.sort(i);for(const l of a)l.children&&o(l.children)};if(e.length===0)o(this.rootRowNodes);else for(const a of this.rootRowNodes)a.children&&o(a.children)}doGroup(e){if(e.length===0)return;const t=this.columns().filter(d=>d.aggFunc&&!d.rowGroup),n=(d,c,p,h)=>{if(c>=e.length)return d;const u=e[c],f=new Map,g=[];for(const m of d){if(!m.__passesFilter)continue;const y=Ee(u,m,null),x=ks(y);f.has(x)||(f.set(x,[]),g.push(x)),f.get(x).push(m)}const v=[];for(const m of g){const y=f.get(m),x=`${h}|${u.colId}:${m}`,C=this.rowNodeMap.get(x),b=C||new Ze({[u.colId]:m},this.rowNodeServices,x);b.group=!0,b.key=m,b.level=p,b.uiLevel=p,b.parent=null,b.children=n(y,c+1,p+1,x);for(const S of b.children)S.parent=b;b.allChildrenCount=Pn(b),b.data={...b.data};const I=[];Ft(b,I);const A={};for(const S of t){const G=I.map(E=>Ee(S,E,null));A[S.colId]=Ct(S,S.aggFunc,G)}A[u.colId]=m,b.groupData=A,C||this.rowNodeMap.set(x,b),v.push(b)}return v},i=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=n(o,0,0,""),l=d=>{for(const c of d){if(!c.group)continue;const p=$t(c),h=this.expandedGroups.has(p);i===-1||h?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<i,c.expanded&&this.expandedGroups.add(p),c.children&&l(c.children)}};l(a),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const p=e[c],h=p.sort==="desc"?-1:1,u=Dn(p);d.sort((f,g)=>{const v=Ee(p,f,null),m=Ee(p,g,null);return u({...f,data:{[p.colId]:v}},{...g,data:{[p.colId]:m}})*h})};e[0].sort&&r(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],n=!!this.options.treeData,i=(a,l)=>{if(a.uiLevel=l,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||n)){const r=a.group?a.children.filter(d=>d.__passesFilter||d.group):a.children;if(a.expanded){for(const d of r)i(d,l+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const d=this.createFooterNode(a,l+1);t.push(d)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&i(a,0);if(this.options.groupIncludeTotalFooter&&e.length>0){const a=this.createGrandTotalNode(e);t.push(a)}this.pinnedTopRows=t.filter(a=>a.rowPinned==="top"),this.pinnedBottomRows=t.filter(a=>a.rowPinned==="bottom");const o=t.filter(a=>a.rowPinned!=="top"&&a.rowPinned!=="bottom");if(this.totalRowCount=o.filter(a=>!a.masterNode).length,this.isPaginationEnabled()){const a=this.getPageSize(),l=this.getCurrentPage();let r=0,d=-1;for(let p=0;p<o.length;p++)if(!o[p].masterNode){if(r===l*a){d=p;break}r++}d<0&&(d=o.length);let c=d;for(r=0;c<o.length&&r<a;)o[c].masterNode||r++,c++;for(;c<o.length&&o[c].masterNode;)c++;this.rowsToDisplay=o.slice(d,c)}else this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,l)=>a.__displayIndex=l)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const n=`${e.id}|footer`;let i=this.rowNodeMap.get(n);return i||(i=new Ze(e.data,this.rowNodeServices,n),this.rowNodeMap.set(n,i)),i.group=!1,i.footer=!0,i.level=e.level,i.uiLevel=t,i.parent=e,i.selected=!1,i.selectable=!1,i.groupData={...e.groupData,__footerFor:e.id},i}createGrandTotalNode(e){const t="ag-grid-grand-total";let n=this.rowNodeMap.get(t);n||(n=new Ze(null,this.rowNodeServices,t),this.rowNodeMap.set(t,n)),n.group=!1,n.footer=!0,n.level=0,n.uiLevel=0,n.selected=!1,n.selectable=!1;const i=this.columns().filter(l=>l.aggFunc&&!l.rowGroup),o=[];for(const l of this.rootRowNodes)l.group?Ft(l,o):l.__passesFilter&&o.push(l);const a={};for(const l of i){const r=o.map(d=>Ee(l,d,null));a[l.colId]=Ct(l,l.aggFunc,r)}return a.__grandTotal=!0,n.groupData=a,n}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add($t(t)),t.children&&t.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}collapseAll(){this.expandedGroups.clear();const e=t=>{t.group&&(t.expanded=!1,t.children&&t.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}setNodeExpanded(e,t){e.group&&(e.expanded=t,t?this.expandedGroups.add($t(e)):this.expandedGroups.delete($t(e)),this.buildDisplayRows(this.columns().filter(n=>n.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function ks(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function $t(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Pn(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Pn(t),0)}function Ft(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Ft(t,e)}function Ms(s,e){return e}const Rs={textColumn:{filter:"text",editable:!0},numberColumn:{filter:"number",editable:!0,headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},dateColumn:{filter:"date",editable:!0},dateStringColumn:{filter:"date"},booleanColumn:{filter:"boolean",cellRenderer:"agCheckboxCellRenderer"},rightAligned:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},numericColumn:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"}};function Ls(s){if(s===void 0||s===!0)return"text";if(s===!1)return!1;switch(s){case"agTextColumnFilter":return"text";case"agNumberColumnFilter":return"number";case"agDateColumnFilter":case"agDateColumnFilterString":return"date";case"agSetColumnFilter":return"set";default:return s}}function Ts(s){return!!s.treeData}function Ns(){return{applyAggregate:Ct}}class Hn{constructor(e,t,n){w(this,"options");w(this,"eventService");w(this,"gridApi");w(this,"measureCtx",null);w(this,"gridColumnDefs",[]);w(this,"columns",[]);w(this,"displayOrder",[]);w(this,"autoGroupColumnDef");w(this,"pivotMode",!1);w(this,"columnGroups",[]);w(this,"openGroups",new Set);w(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=n,this.autoGroupColumnDef={headerName:"",minWidth:200,width:250,sortable:!1,filter:!1,resizable:!0,suppressMovable:!0,cellRenderer:"agGroupCellRenderer",...e.autoGroupColumnDef||{}}}setGridApi(e){this.gridApi=e}getAutoGroupColumnDef(){return this.autoGroupColumnDef}getOptions(){return this.options}setPivotMode(e,t="api"){this.pivotMode!==e&&(this.pivotMode=e,this.eventService.dispatchEvent("columnPivotModeChanged",{api:this.gridApi,source:t}),this.refreshAll())}isPivotMode(){return this.pivotMode}setColumnDefs(e){this.gridColumnDefs=e||[],this.buildColumns()}static generateColumnDefs(e,t=On){if(!e||e.length===0)return[];const n=e[0];if(!n||typeof n!="object")return[];const i=new Set(["children","detail","__proto__"]),o=[];for(const a of Object.keys(n)){if(i.has(a)||a.startsWith("__"))continue;const l=n[a],r={field:a,headerName:t(a)};typeof l=="number"?(r.type="numberColumn",r.filter="number"):typeof l=="boolean"?r.type="booleanColumn":l instanceof Date&&(r.type="dateColumn"),o.push(r)}return o}getColumnGroups(){return this.columnGroups}getGroupDepth(){return this.columnGroups.reduce((e,t)=>Math.max(e,t.depth),0)}isGroupOpen(e){return this.openGroups.has(e)}setGroupOpen(e,t){t?this.openGroups.add(e):this.openGroups.delete(e),this.updateVisible(),this.refreshAll()}getColumnDefs(){return this.gridColumnDefs}buildColumns(){const e=this.columns,t=new Map;for(const c of e)t.set(c.colId,c);const n=this.options.defaultColDef||{},i={...Rs,...this.options.columnTypes||{}},o=[],a=[];let l=0;const r=(c,p)=>{const h=c.colId||c.field||Ut("col"),u={...n,...c};if(u.type&&i[u.type]){const f=i[u.type],g=new Set(Object.keys(c));for(const[v,m]of Object.entries(f))!g.has(v)&&!(v in n)&&(u[v]=m)}this.pushColumnInto(o,u,h,l++,t,p)},d=(c,p,h)=>{for(const u of c)if(u.children&&u.children.length){const f=u.groupId||Ut("group"),g={id:f,headerName:u.headerName??"",openByDefault:u.openByDefault===!0||u.columnGroupShow==="open",parentId:p,depth:h,childColumnIds:[]};a.push(g),this.groupsInitialised||(g.openByDefault?this.openGroups.add(f):this.openGroups.delete(f)),d(u.children,f,h+1)}else r(u,p)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,this.options.rowNumbers){const c={colId:"__rowNumber",headerName:"",width:60,pinned:"left",sortable:!1,filter:!1,resizable:!1,suppressMovable:!0,cellRenderer:"agRowNumberCellRenderer",cellClass:"ag-row-number-cell"};this.pushColumnInto(o,{...n,...c},"__rowNumber",-1,t,null)}for(const c of o){if(!c.groupId)continue;const p=a.find(h=>h.id===c.groupId);p&&p.childColumnIds.push(c.colId)}this.columns=o,this.displayOrder=o.map(c=>c.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,n,i,o){return this.buildColumn(e,t,n,i,o)}pushColumnInto(e,t,n,i,o,a){e.push(this.buildColumn(t,n,i,o,a))}buildColumn(e,t,n,i,o){const a=i.get(t),l=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?On(e.field):""),headerTooltip:e.headerTooltip,colDef:e,width:e.width??e.minWidth??(e.flex?200:100),minWidth:e.minWidth??20,maxWidth:e.maxWidth??Number.MAX_SAFE_INTEGER,flex:e.flex??null,pinned:e.pinned??null,hide:l,visible:!l,lockPosition:e.lockPosition??!1,type:e.type,sortable:e.sortable??!!e.field,sort:e.sort??null,sortIndex:e.sortIndex??null,resizable:e.resizable??!0,filter:Ls(e.filter),floatingFilter:e.floatingFilter??!1,filterParams:e.filterParams||{},editable:e.editable??!1,cellEditor:e.cellEditor,cellEditorParams:e.cellEditorParams||{},singleClickEdit:e.singleClickEdit??this.options.singleClickEdit??!1,valueSetter:e.valueSetter,valueGetter:e.valueGetter,valueFormatter:e.valueFormatter,valueParser:e.valueParser,comparator:e.comparator,aggFunc:e.aggFunc,allowedAggFuncs:e.allowedAggFuncs??["sum","min","max","count","avg"],rowGroup:e.rowGroup??!1,rowGroupIndex:e.rowGroupIndex??null,pivot:e.pivot??!1,pivotIndex:e.pivotIndex??null,enableRowGroup:e.enableRowGroup??!0,enablePivot:e.enablePivot??!0,enableValue:e.enableValue??!0,cellRenderer:e.cellRenderer,cellRendererParams:e.cellRendererParams,cellClass:e.cellClass,cellStyle:e.cellStyle,cellDataType:e.cellDataType===!0,cellClassRules:e.cellClassRules,rowDrag:e.rowDrag===!0,headerClass:e.headerClass,checkboxSelection:e.checkboxSelection??!1,headerCheckboxSelection:e.headerCheckboxSelection??!1,headerCheckboxSelectionFilteredOnly:e.headerCheckboxSelectionFilteredOnly??!1,headerCheckboxSelectionCurrentPageOnly:e.headerCheckboxSelectionCurrentPageOnly??!1,menuTabs:e.menuTabs??["filterMenuTab","generalMenuTab","columnsMenuTab"],suppressMenu:e.suppressMenu??this.options.suppressMenu??!1,suppressMovable:e.suppressMovable??this.options.suppressMovableColumns??!1,wrapText:e.wrapText??!1,autoHeight:e.autoHeight??!1,tooltipField:e.tooltipField,tooltipValueGetter:e.tooltipValueGetter,decimals:e.decimals??0,defIndex:n,filterActive:!1,left:0,groupId:o};return a&&(r.pinned=a.pinned,r.visible=a.visible,r.width=a.width,r.flex=a.flex,r.sort=a.sort,r.sortIndex=a.sortIndex,r.rowGroup=a.rowGroup,r.rowGroupIndex=a.rowGroupIndex,r.pivot=a.pivot,r.pivotIndex=a.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const n=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),i=[];for(const r of t){const d=[],c=new Set;for(const p of e){const h=p==null?void 0:p[r.field],u=String(h);c.has(u)||(c.add(u),d.push(h))}d.sort((p,h)=>p===h?0:String(p)<String(h)?-1:1);for(const p of n){for(const f of d){const g=`__pivot_${r.colId}_${p.colId}_${f}`,v=this.createColumn({colId:g,headerName:`${String(f)}`,width:130,type:p.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:p.cellClass,cellDataType:p.cellDataType},g,-1,new Map,null);v.aggFunc=p.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:f,valueColumnId:p.colId,valueField:p.field},v.valueGetter=m=>this.evaluatePivotValue(v,m.node),i.push(v)}const h=`__pivot_${r.colId}_${p.colId}_total`,u=this.createColumn({colId:h,headerName:"Total",width:130,type:p.type,sortable:!1,filter:!1,cellDataType:p.cellDataType},h,-1,new Map,null);u.aggFunc=p.aggFunc,u.groupId=r.colId,u.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:p.colId,valueField:p.field},u.valueGetter=f=>this.evaluatePivotValue(u,f.node),i.push(u)}}const o=new Set(t.map(r=>r.colId)),a=this.columns.reduce((r,d,c)=>o.has(d.groupId??"")?r:c,0);this.columns.splice(a+1,0,...i);for(const r of i)this.displayOrder.push(r.colId);const l=new Set(this.columnGroups.map(r=>r.id));for(const r of t)l.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const n=e.__pivot;if(!n||!t)return;const i=[],o=c=>{if(!c.children||c.children.length===0){i.push(c);return}for(const p of c.children)o(p)};o(t);const l=(n.pivotValue===void 0?i:i.filter(c=>{var p;return String((p=c.data)==null?void 0:p[n.pivotField])===String(n.pivotValue)})).map(c=>{var p;return(p=c.data)==null?void 0:p[n.valueField]}).filter(c=>typeof c=="number");if(l.length===0)return null;const r=this.columns.find(c=>c.colId===n.valueColumnId),{applyAggregate:d}=Ns();return d(r,e.aggFunc,l)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,n=this.getRowGroupColumns(),i=this.options.groupDisplayType||"singleColumn",o=t||n.length>0&&i!=="multipleColumns";for(const c of n)i==="multipleColumns"?(c.cellRenderer="agGroupCellRenderer",c.cellRendererParams={...c.cellRendererParams||{},suppressCount:!0}):c.cellRenderer==="agGroupCellRenderer"&&!c.colDef.cellRenderer&&(c.cellRenderer=void 0,c.cellRendererParams=void 0);const a=this.columns.find(c=>c.colId===e);if(!o){a&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const l={...this.autoGroupColumnDef};if(l.colId=e,a)a.headerName=l.headerName??"",a.colDef=l,a.cellRenderer=l.cellRenderer,a.cellRendererParams=l.cellRendererParams,a.width=l.width??a.width,a.minWidth=l.minWidth??a.minWidth,a.pinned=l.pinned??"left";else{const c=this.createColumn(l,e,-2,new Map,null);this.columns.unshift(c),this.displayOrder.unshift(e)}const r=this.columns.find(c=>c.colId===e),d=()=>this.getRowGroupColumns()[0];r.valueGetter=c=>{const p=c.node;if(!p)return"";if(p.key!==null&&p.key!==void 0)return p.key;if(Ts(this.options))return"";const h=d();return h!=null&&h.field&&p.data?p.data[h.field]??"":""}}updateVisible(){for(const e of this.columns)e.visible=!e.hide&&this.isGroupChainOpen(e.groupId)}isGroupChainOpen(e){let t=e;for(;t;){if(!this.openGroups.has(t))return!1;const n=this.columnGroups.find(i=>i.id===t);t=(n==null?void 0:n.parentId)??null}return!0}refreshAll(){this.eventService.dispatchEvent("columnEverythingChanged",{api:this.gridApi,source:"gridOptionsChanged"}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi})}getAllColumns(){return this.columns.slice()}getColumn(e){const t=typeof e=="string"?e:e.colId;return this.columns.find(n=>n.colId===t)}getColumns(){return this.displayOrder.map(e=>this.getColumn(e)).filter(Boolean)}getDisplayedColumns(){return this.getColumns().filter(e=>e.visible)}getDisplayedLeftColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="left")}getDisplayedCenterColumns(){return this.getDisplayedColumns().filter(e=>e.pinned!=="left"&&e.pinned!=="right")}getDisplayedRightColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="right")}getDisplayedColumnsByType(){return{left:this.getDisplayedLeftColumns(),center:this.getDisplayedCenterColumns(),right:this.getDisplayedRightColumns()}}getRowGroupColumns(){return this.getColumns().filter(e=>e.rowGroup).sort((e,t)=>(e.rowGroupIndex??0)-(t.rowGroupIndex??0))}getPivotColumns(){return this.getColumns().filter(e=>e.pivot).sort((e,t)=>(e.pivotIndex??0)-(t.pivotIndex??0))}getValueColumns(){return this.pivotMode?this.getColumns().filter(e=>e.aggFunc&&!e.rowGroup&&!e.pivot):this.getColumns().filter(e=>!!e.aggFunc)}isRowGroupActive(){return this.getRowGroupColumns().length>0}setRowGroupColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())n.includes(i)||(i.rowGroup=!1,i.rowGroupIndex=null);n.forEach((i,o)=>{i.rowGroup=!0,i.rowGroupIndex=o,i.pivot=!1,i.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:n}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,t="api"){const n=this.getColumn(e);if(!n)return;const i=this.getRowGroupColumns();n.rowGroup=!0,n.rowGroupIndex=i.length,n.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[n]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,t="api"){const n=this.getColumn(e);if(!n)return;n.rowGroup=!1,n.rowGroupIndex=null,this.getRowGroupColumns().forEach((o,a)=>o.rowGroupIndex=a),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[n]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())n.includes(i)?i.aggFunc||(i.aggFunc="sum"):i.aggFunc&&!i.rowGroup&&(i.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:n}),this.refreshAll()}addValueColumn(e,t="sum",n="api"){const i=this.getColumn(e);i&&(i.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:n,columns:[i]}),this.refreshAll())}setPivotColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())i.pivot=n.includes(i),i.pivotIndex=n.includes(i)?n.indexOf(i):null;this.refreshAll()}setColumnVisible(e,t,n="api"){const i=this.getColumn(e);!i||i.visible===t||(i.hide=!t,i.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:i,visible:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll())}setColumnsVisible(e,t,n="api"){for(const i of e)this.setColumnVisible(i,t,n)}setColumnPinned(e,t,n="api"){const i=this.getColumn(e);i&&(i.lockPosition&&t!==i.pinned||(i.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:i,pinned:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll()))}setColumnsPinned(e,t,n="api"){for(const i of e)this.setColumnPinned(i,t,n)}moveColumn(e,t,n="api"){const i=this.getColumn(e);i&&this.moveColumnByIndex(this.displayOrder.indexOf(i.colId),t,n)}moveColumnByIndex(e,t,n="api"){const i=this.displayOrder.slice();if(e<0||e>=i.length)return;const[o]=i.splice(e,1);i.splice(Math.max(0,Math.min(i.length,t)),0,o),this.displayOrder=i;const a=this.getColumn(o);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:a,toIndex:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll()}getColumnState(){return this.getColumns().map(e=>({colId:e.colId,hide:e.hide,pinned:e.pinned,width:e.width,flex:e.flex??void 0,sort:e.sort,sortIndex:e.sortIndex,rowGroupIndex:e.rowGroupIndex,pivotIndex:e.pivotIndex,aggFunc:e.aggFunc}))}applyColumnState(e,t=!1){for(const n of e){const i=this.getColumn(n.colId);i&&(n.hide!==void 0&&(i.hide=n.hide,i.visible=!n.hide),n.pinned!==void 0&&(i.pinned=n.pinned),n.width!==void 0&&(i.width=n.width),n.flex!==void 0&&(i.flex=n.flex),n.sort!==void 0&&(i.sort=n.sort),n.sortIndex!==void 0&&(i.sortIndex=n.sortIndex),n.rowGroupIndex!==void 0&&(i.rowGroup=n.rowGroupIndex!==null,i.rowGroupIndex=n.rowGroupIndex),n.pivotIndex!==void 0&&(i.pivot=n.pivotIndex!==null,i.pivotIndex=n.pivotIndex),n.aggFunc!==void 0&&(i.aggFunc=n.aggFunc))}if(t){const n=new Map(e.map(o=>[o.colId,o.colId])),i=this.displayOrder.filter(o=>!n.has(o));this.displayOrder=[...e.map(o=>o.colId).filter(o=>this.getColumn(o)),...i]}this.refreshAll()}resetColumnState(){this.buildColumns()}getMeasureContext(){if(this.measureCtx)return this.measureCtx;const e=document.createElement("canvas");return this.measureCtx=e.getContext("2d"),this.measureCtx&&(this.measureCtx.font='400 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'),this.measureCtx}measureTextWidth(e){const t=this.getMeasureContext();return t?t.measureText(e).width:e.length*8}sizeColumnsToFit(e,t=[]){const n=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const i of n){let a=0,l=0;for(const d of i)t.includes(d.colId)?l+=d.width:d.flex!==null&&d.flex>0?a+=d.flex:l+=d.width;const r=Math.max(0,e-l-32);if(a>0){for(const d of i)if(d.flex!==null&&d.flex>0&&!t.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/a));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var l,r,d,c,p,h;const n=this.getColumn(e);if(!n)return;let i=this.measureTextWidth(n.headerName)+32;t||(i+=16);const o=((r=(l=this.gridApi)==null?void 0:l.getDisplayedRowCount)==null?void 0:r.call(l))??0,a=Math.min(o,300);for(let u=0;u<a;u++){const f=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,u);if(!f)continue;const g=(h=(p=this.gridApi)==null?void 0:p.getCellText)==null?void 0:h.call(p,n,f);g&&(i=Math.max(i,this.measureTextWidth(g)+32))}n.width=Math.max(n.minWidth,Math.min(n.maxWidth,Math.ceil(i))),n.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:n,finished:!0})}autoSizeAllColumns(e=!1){for(const t of this.getDisplayedColumns())this.autoSizeColumn(t,e)}}function On(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class Is{constructor(){w(this,"listeners",new Map)}addEventListener(e,t){let n=this.listeners.get(e);n||(n=[],this.listeners.set(e,n)),n.push(t)}removeEventListener(e,t){const n=this.listeners.get(e);if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}dispatchEvent(e,t){const n=this.listeners.get(e);if(!n||n.length===0)return;const i={type:e,...t||{}};for(const o of n.slice())o(i)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const Bn={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应本列宽度",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多条件筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"显示/隐藏",hideColumn:"隐藏本列",chooseColumns:"选择列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",sortAsc:"升序",sortDesc:"降序",sortNone:"无",copy:"复制",copyWithHeaders:"连同表头复制",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应容器宽度",expandAll:"展开全部",collapseAll:"折叠全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",search:"搜索…",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"全部清除",join:"条件组合:",and:"并且",or:"或者",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",conditionsUnit:"个条件",addCondition:"+ 添加条件",condTrue:"真",condFalse:"假",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"页码",pageSize:"每页行数:",pageNumber:"输入页码",find:"在表格中查找…",matchCase:"区分大小写",prevMatch:"上一个匹配",nextMatch:"下一个匹配",of:"/",rangeTo:"至",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity",dataGrid:"数据表格",dragRow:"拖拽行",expandGroup:"展开分组",close:"关闭",save:"保存",delete:"删除",totalRows:"总行数",rows:"行数",filtered:"筛选后",selected:"已选中",average:"平均",count:"计数",min:"最小",max:"最大",sum:"合计",note:"便签",writeNote:"写便签…",formulaPreview:"预览(第 1 行)",formulaError:"错误",invalidFormula:"公式无效",functions:"函数",integratedCharts:"集成图表",chart:"图表",chartType:"图表类型",chartCategory:"类目",chartSeries:"数据系列",chartGroup:"分组",createChart:"创建图表",noChartsCreated:"暂无图表",downloadPng:"下载 PNG",chartLine:"折线图",chartArea:"面积图",chartColumn:"柱状图",chartBar:"条形图",chartPie:"饼图",chartScatter:"散点图"},As={contains:"contains",notEqual:"notEqual",startsWith:"startsWith",endsWith:"endsWith",equals:"equals",blank:"blank",notBlank:"notBlank",greaterThan:"greaterThan",greaterThanOrEqual:"greaterThanOrEqual",lessThan:"lessThan",lessThanOrEqual:"lessThanOrEqual",inRange:"inRange",true:"condTrue",false:"condFalse"};class $s{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Bn[e]??e}}function Fs(s){return new $s(s??{})}function Ds(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class Ps{constructor(e){w(this,"eventService");w(this,"columns");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"stores",new Map);w(this,"rowNodeMap",new Map);w(this,"displayRows",[]);w(this,"blockSize");this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"serverSide"}setDatasource(e){this.datasource=e,this.purgeCache()}getStore(e){return this.stores.get(e)}getOrCreateStore(e){let t=this.stores.get(e);return t||(t={rows:[],lastRow:null,loading:!1,failed:!1},this.stores.set(e,t)),t}isLoading(){for(const e of this.stores.values())if(e.loading)return!0;return!1}loadBlock(e,t,n){if(!this.datasource)return;const i=this.getOrCreateStore(e);if(i.loading)return;for(let a=i.rows.length;a<n;a++)i.rows.push(null);i.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const o={startRow:t,endRow:n,rowGroupCols:this.columns().filter(a=>a.rowGroup),valueCols:this.columns().filter(a=>a.aggFunc&&!a.rowGroup),pivotCols:this.columns().filter(a=>a.pivot),groupKeys:e?e.split("|"):[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(a,l)=>{i.loading=!1,this.onBlockLoaded(e,a,l??null)},failCallback:()=>{i.loading=!1,i.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(o)}onBlockLoaded(e,t,n){const i=this.getOrCreateStore(e);i.lastRow=n,i.failed=!1;for(let o=0;o<t.length;o++){const a=t[o],l=(i.rows.length>0,o),r=this.createNode(a,e,o,l);i.rows[l]=r}for(;i.rows.length&&i.rows[i.rows.length-1]===null;)i.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,n,i){const o=Ds(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${i}`,l=this.rowNodeMap.get(a),r=l instanceof Ze?l:new Ze(e,this.rowNodeServices,a);return r.data=e,r.rowIndex=n,o&&(r.group=!0,r.key=String(Ee(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(a,r),r}buildDisplayRows(){const e=[],t=(n,i)=>{const o=this.stores.get(n);if(o){for(const a of o.rows)if(a&&(a.uiLevel=i,e.push(a),a.group&&a.expanded)){const l=`${n?n+"|":""}${a.key}`;t(l,i+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((n,i)=>n.__displayIndex=i)}ensureLoaded(e,t){let n=0;const i=a=>{const l=this.stores.get(a);if(l){for(const r of l.rows)if(r){if(n>=e&&n<=t){const d=Math.floor(n/this.blockSize)*this.blockSize,c=d+this.blockSize,p=l.lastRow,h=p!==null?Math.min(p,c):c;n<(l.rows.length||0)&&d<(l.rows.length||0)||(l.lastRow===null||c<=l.lastRow)&&this.loadBlock(a,d,h)}n++,r.group&&r.expanded&&i(`${a?a+"|":""}${r.key}`)}}};i("");const o=this.stores.get("");(!o||o.rows.length===0&&o.lastRow===null)&&this.loadBlock("",0,this.blockSize)}refreshModel(e){this.ensureLoaded(0,this.blockSize),this.eventService.dispatchEvent("modelUpdated",{})}onViewportChanged(e,t){this.ensureLoaded(e,t)}setNodeExpanded(e,t){if(e.group){if(e.expanded=t,t){const n=this.groupPathFor(e);this.stores.has(n)||this.loadBlock(n,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const t=[];let n=e;for(;n&&n.group;)t.unshift(n.key??""),n=n.parent??null;return t.join("|")}purgeCache(){this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[],this.refreshModel("everything")}onSortOrFilterChanged(){this.purgeCache()}getRowCount(){return this.displayRows.length}getTotalRowCount(){const e=this.stores.get("");return(e==null?void 0:e.lastRow)??0}getRow(e){return this.displayRows[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.displayRows.forEach((t,n)=>e(t,n))}forEachLeafNode(e){let t=0;for(const n of this.displayRows)!n.group&&!n.footer&&e(n,t++)}isEmpty(){return this.displayRows.length===0}getTopLevelRows(){const e=this.stores.get("");return(e==null?void 0:e.rows.filter(Boolean))||[]}updateRowData(e){this.refreshModel("everything")}applyTransaction(e){const t={add:[],remove:[],update:[]};for(const n of e.update||[]){const i=(n==null?void 0:n.id)!==void 0?String(n.id):void 0,o=i?this.rowNodeMap.get(i):void 0;o&&(o.data=n,t.update.push(o))}return this.eventService.dispatchEvent("modelUpdated",{}),t}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[]}expandAll(){for(const e of this.rowNodeMap.values())if(e.group){e.expanded=!0;const t=this.groupPathFor(e);this.stores.has(t)||this.loadBlock(t,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}collapseAll(){for(const e of this.rowNodeMap.values())e.group&&(e.expanded=!1);this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class Hs{constructor(e){w(this,"eventService");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"blockSize");w(this,"loading",!1);this.eventService=e.eventService,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"infinite"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let n=this.nodes.length;n<t;n++)this.nodes.push(null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(n,i)=>{this.loading=!1,n.forEach((o,a)=>{const l=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let r=this.rowNodeMap.get(l);r||(r=new Ze(o,this.rowNodeServices,l),this.rowNodeMap.set(l,r)),r.data=o,r.rowIndex=e+a,this.nodes[e+a]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const n=Math.floor(e/this.blockSize)*this.blockSize;n+this.blockSize>this.nodes.length&&this.loadBlock(n,n+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.loadBlock(0,this.blockSize)}isLoading(){return this.loading}getRowCount(){return this.nodes.length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,n)=>{t&&e(t,n)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.nodes.filter(Boolean).length===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){this.onSortOrFilterChanged()}applyTransaction(){return null}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class Os{constructor(e){w(this,"eventService");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"loading",!1);this.eventService=e.eventService,this.rowNodeServices=e.rowNodeServices}getType(){return"viewport"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}setViewportRange(e,t){if(!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((n,i)=>i>=e&&i<=t);for(let n=e;n<=t;n++)this.nodes[n-e]||(this.nodes[n-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:n=>{this.loading=!1,n.forEach((i,o)=>{const a=(i==null?void 0:i.id)!==void 0?String(i.id):`vrow-${e+o}`;let l=this.rowNodeMap.get(a);l||(l=new Ze(i,this.rowNodeServices,a),this.rowNodeMap.set(a,l)),l.data=i,l.rowIndex=e+o,this.nodes[e+o-e]=l}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}setViewportDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}onViewportChanged(e,t){this.setViewportRange(e,t)}isLoading(){return this.loading}getRowCount(){return this.nodes.filter(Boolean).length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,n)=>{t&&e(t,n)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){}applyTransaction(){return null}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}function Vn(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Qe=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class Bs{constructor(e,t){w(this,"charts",new Map);w(this,"chartCounter",0);w(this,"currentType","line");w(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),n=t.getRowGroupColumns();let i=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(r=>r.aggFunc),a=[],l=o.map(()=>[]);if(n.length>0)((d,c)=>{for(const p of d)if(p.group){const h=n[0]?String(Ee(n[0],p,this.grid.getApi())??""):p.key??"";a.push(h);for(let u=0;u<o.length;u++){const f=[];Gn(p,o[u],f),l[u].push(Number(Ct(o[u],o[u].aggFunc,f))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(i||(i=this.grid.getColumns().center.find(r=>r.field&&r.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(r=>{if(r.group||r.footer)return;const d=i?Ee(i,r,this.grid.getApi()):"";a.push(String(d??""));for(let c=0;c<o.length;c++){const p=Ee(o[c],r,this.grid.getApi());l[c].push(typeof p=="number"?p:Number(p)||0)}}),a.length>200){const r=Math.ceil(a.length/200),d=[],c=l.map(()=>[]);for(let p=0;p<a.length;p+=r){d.push(a[p]);for(let h=0;h<l.length;h++)c[h].push(l[h][p])}return{categories:d,series:o.map((p,h)=>({title:p.headerName,data:c[h]}))}}return{categories:a,series:o.map((r,d)=>({title:r.headerName,data:l[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const t=document.createElement("div");t.className="ag-side-bar-section-title",t.textContent=this.grid.t("integratedCharts"),e.appendChild(t);const n=document.createElement("div");n.className="ag-chart-panel-label",n.textContent=this.grid.t("chartType"),e.appendChild(n);const i=document.createElement("select");i.className="ag-chart-panel-select";const o=[{value:"line",label:this.grid.t("chartLine")},{value:"area",label:this.grid.t("chartArea")},{value:"column",label:this.grid.t("chartColumn")},{value:"bar",label:this.grid.t("chartBar")},{value:"pie",label:this.grid.t("chartPie")},{value:"scatter",label:this.grid.t("chartScatter")}];for(const v of o){const m=document.createElement("option");m.value=v.value,m.textContent=v.label,v.value===this.currentType&&(m.selected=!0),i.appendChild(m)}i.addEventListener("change",()=>{this.currentType=i.value}),e.appendChild(i);const a=document.createElement("div");a.className="ag-chart-panel-label",a.textContent=this.grid.t("chartCategory"),e.appendChild(a);const l=document.createElement("select");l.className="ag-chart-panel-select";const r=this.grid.getColumnModel().getRowGroupColumns(),d=r.length>0?r:this.grid.getColumns().center.filter(v=>v.field);for(const v of d){const m=document.createElement("option");m.value=v.colId,m.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${v.headerName}`:v.headerName,l.appendChild(m)}e.appendChild(l);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent=this.grid.t("chartSeries"),e.appendChild(c);const p=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),h=document.createElement("div");h.className="ag-chart-panel-series";const u=new Set(p.slice(0,3).map(v=>v.colId));for(const v of this.grid.getColumns().center.filter(m=>m.field)){const m=document.createElement("label");m.className="ag-chart-panel-series-item";const y=document.createElement("input");y.type="checkbox",y.checked=u.has(v.colId),y.addEventListener("change",()=>{y.checked?u.add(v.colId):u.delete(v.colId)}),m.appendChild(y);const x=document.createElement("span");x.textContent=v.headerName,m.appendChild(x),h.appendChild(m)}e.appendChild(h);const f=document.createElement("button");f.className="ag-button ag-button-primary ag-chart-panel-create",f.textContent=this.grid.t("createChart"),f.addEventListener("click",()=>{const v=this.grid.getColumn(l.value)||void 0,m=[...u].map(y=>this.grid.getColumn(y)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:m})}),e.appendChild(f);const g=document.createElement("div");if(g.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent=this.grid.t("noChartsCreated"),g.appendChild(v)}for(const[v,m]of this.charts){const y=document.createElement("div");y.className="ag-chart-panel-list-item";const x=document.createElement("span");x.textContent=m.title,y.appendChild(x);const C=document.createElement("button");C.className="ag-column-group-remove",C.textContent="×",C.addEventListener("click",()=>this.destroyChart(v)),y.appendChild(C),g.appendChild(y)}return e.appendChild(g),e}createChart(e={}){var v,m,y,x;const t=e.type||this.currentType,n=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),i=`chart-${++this.chartCounter}`,o=e.title||`${this.grid.t(`chart${t.charAt(0).toUpperCase()}${t.slice(1)}`)}`,{ePopup:a}=this.popupService.createPopup(640,"ag-chart-window");a.innerHTML="";const l=document.createElement("div");l.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=o,l.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent=this.grid.t("downloadPng"),l.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title=this.grid.t("close"),c.addEventListener("click",()=>this.destroyChart(i)),l.appendChild(c),a.appendChild(l);const p=document.createElement("div");p.className="ag-chart-window-body";const h=document.createElement("canvas");h.className="ag-chart-canvas",h.width=600,h.height=360,p.appendChild(h);const u=document.createElement("div");u.className="ag-chart-tooltip",u.style.display="none",p.appendChild(u),h.addEventListener("mousemove",C=>this.onChartHover({id:i,ePopup:a,canvas:h,type:t,data:n,title:o},C,u)),h.addEventListener("mouseleave",()=>{u.style.display="none"});const f=document.createElement("div");f.className="ag-chart-legend",p.appendChild(f),a.appendChild(p),this.timeSeries=n.categories.length>0&&n.categories.every(C=>!isNaN(Date.parse(String(C)))&&isNaN(Number(C)));const g={id:i,ePopup:a,canvas:h,type:t,data:n,title:o};return this.charts.set(i,g),d.addEventListener("click",()=>{const C=h.toDataURL("image/png"),b=document.createElement("a");b.href=C,b.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,b.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(g),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:i,chartTitle:o,api:this.grid.getApi()}),(m=(v=this.grid.getOptions()).onChartCreated)==null||m.call(v,{chartId:i,chartTitle:o,api:this.grid.getApi()}),((y=this.grid.getSideBarService())==null?void 0:y.getActivePanel())==="charts"&&((x=this.grid.getSideBarService())==null||x.refresh()),i}destroyChart(e){var n,i,o,a;const t=this.charts.get(e);t&&(t.ePopup.remove(),this.charts.delete(e),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartDestroyed",{chartId:e,api:this.grid.getApi()}),(i=(n=this.grid.getOptions()).onChartDestroyed)==null||i.call(n,{chartId:e,api:this.grid.getApi()}),((o=this.grid.getSideBarService())==null?void 0:o.getActivePanel())==="charts"&&((a=this.grid.getSideBarService())==null||a.refresh()))}getChartModels(){return[...this.charts.values()].map(e=>({chartId:e.id,chartType:e.type,title:e.title}))}refreshCharts(){for(const e of this.charts.values())e.data=this.getChartData(),this.renderChart(e)}onChartHover(e,t,n){const o=e.canvas.getBoundingClientRect(),a=600/(o.width||1),l=360/(o.height||1),r=(t.clientX-o.left)*a,d=(t.clientY-o.top)*l,c={top:20,right:20,bottom:34,left:56},p=600-c.left-c.right,h=360-c.top-c.bottom;if(r<c.left||r>c.left+p||d<c.top||d>c.top+h){n.style.display="none";return}if(e.type==="pie"){n.style.display="none";return}const u=e.type==="bar",f=Math.max(1,e.data.categories.length),g=(u?h:p)/f,v=Math.floor((u?d-c.top:r-c.left)/g);if(v<0||v>=e.data.categories.length){n.style.display="none";return}const m=e.data.series.map(y=>`${y.title}: ${this.formatTick(y.data[v]??0)}`);n.innerHTML=`<div class="ag-chart-tooltip-title">${Vn(e.data.categories[v])}</div>`+m.map(y=>`<div>${Vn(y)}</div>`).join(""),n.style.display="block",n.style.left=`${t.clientX-o.left+12}px`,n.style.top=`${t.clientY-o.top+12}px`}storageKey(){const t=this.grid.getOptions().chartStorageKey;return t?`rowvia-charts:${t}`:null}saveCharts(){const e=this.storageKey();if(!e)return;const t=[...this.charts.values()].map(n=>({id:n.id,type:n.type,title:n.title,data:n.data}));try{localStorage.setItem(e,JSON.stringify(t))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let t=[];try{const n=localStorage.getItem(e);n&&(t=JSON.parse(n))}catch{return}for(const n of t)this.restoreChart(n)}restoreChart(e){const t=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(t))return;const{ePopup:n}=this.popupService.createPopup(640,"ag-chart-window");n.innerHTML="";const i=document.createElement("div");i.className="ag-chart-window-header";const o=document.createElement("span");o.className="ag-chart-window-title",o.textContent=e.title||this.grid.t("chart"),i.appendChild(o);const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="×",a.addEventListener("click",()=>this.destroyChart(t)),i.appendChild(a),n.appendChild(i);const l=document.createElement("div");l.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,l.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",l.appendChild(d),n.appendChild(l);const c={id:t,ePopup:n,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,c),this.popupService.positionAt(n,this.grid.getRootElement()),n.style.top="60px",this.renderChart(c)}renderChart(e){var G;const t=e.canvas,n=t.getContext("2d");if(!n)return;const i=window.devicePixelRatio||1,o=t.width,a=t.height;t.width=o*i,t.height=a*i,t.style.width=`${o}px`,t.style.height=`${a}px`,n.scale(i,i),n.clearRect(0,0,o,a);const l=getComputedStyle(this.grid.getRootElement()),r=l.getPropertyValue("--ag-chart-text-color")||"#666",d=l.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},p=o-c.left-c.right,h=a-c.top-c.bottom;n.font="11px sans-serif",n.fillStyle=r,n.strokeStyle=d,n.lineWidth=1;const u=(G=e.canvas.parentElement)==null?void 0:G.querySelector(".ag-chart-legend");if(u&&(u.innerHTML="",e.data.series.forEach((E,k)=>{const T=document.createElement("span");T.className="ag-chart-legend-item";const H=document.createElement("span");H.className="ag-chart-legend-swatch",H.style.backgroundColor=Qe[k%Qe.length],T.appendChild(H),T.appendChild(document.createTextNode(E.title)),u.appendChild(T)})),e.type==="pie"){this.renderPie(n,e.data,o,a,r);return}const f=e.data.series.flatMap(E=>E.data);let g=Math.max(0,...f),v=Math.min(0,...f);e.type==="scatter"&&(v=Math.min(...f),g=Math.max(...f));const m=g-v||1;g+=m*.08,v-=v<0?m*.08:0;const y=g-v||1,x=E=>c.top+h-(E-v)/y*h,C=5;n.textAlign="right",n.textBaseline="middle";for(let E=0;E<=C;E++){const k=v+y*E/C,T=x(k);n.beginPath(),n.moveTo(c.left,T),n.lineTo(o-c.right,T),n.stroke(),n.fillText(this.formatTick(k),c.left-6,T)}const b=e.data.categories,I=e.type==="bar",A=Math.max(1,b.length),S=(I?h:p)/A;if(I){n.textAlign="left",b.forEach((k,T)=>{const H=c.top+T*S,W=Math.max(2,S*.7/e.data.series.length);e.data.series.forEach((R,O)=>{const L=R.data[T]||0,M=Math.abs(L)/y*p,$=c.left+(0-v)/y*p;n.fillStyle=Qe[O%Qe.length],n.fillRect($,H+O*W,Math.max(1,M),W-1)}),n.fillStyle=r,n.fillText(this.truncate(k,18),c.left+4,H+S/2)});const E=c.left+(0-v)/y*p;n.beginPath(),n.moveTo(E,c.top),n.lineTo(E,c.top+h),n.strokeStyle=r,n.stroke()}else{const E=Math.max(1,Math.ceil(A/12));n.textAlign="center",n.textBaseline="top",b.forEach((H,W)=>{if(W%E!==0)return;const R=c.left+S*(W+.5);n.fillStyle=r,n.fillText(this.truncate(H,10),R,c.top+h+6)});const k=e.data.series.length,T=Math.max(1,S*.7/Math.max(1,k));e.data.series.forEach((H,W)=>{const R=Qe[W%Qe.length];if(e.type==="column")n.fillStyle=R,H.data.forEach((O,L)=>{const M=c.left+S*L+(S-T*k)/2+W*T,$=x(O);n.fillRect(M,$,T-1,c.top+h-$)});else if(e.type==="area"){n.beginPath(),H.data.forEach((L,M)=>{const $=c.left+S*(M+.5),_=x(L);M===0?n.moveTo($,_):n.lineTo($,_)});const O=c.left+S*(H.data.length-.5);n.lineTo(O,c.top+h),n.lineTo(c.left+S*.5,c.top+h),n.closePath(),n.globalAlpha=.25,n.fillStyle=R,n.fill(),n.globalAlpha=1,n.beginPath(),H.data.forEach((L,M)=>{const $=c.left+S*(M+.5),_=x(L);M===0?n.moveTo($,_):n.lineTo($,_)}),n.strokeStyle=R,n.lineWidth=2,n.stroke()}else e.type==="scatter"?(n.fillStyle=R,H.data.forEach((O,L)=>{const M=c.left+S*(L+.5),$=x(O);n.beginPath(),n.arc(M,$,3,0,Math.PI*2),n.fill()})):(n.beginPath(),H.data.forEach((O,L)=>{const M=c.left+S*(L+.5),$=x(O);L===0?n.moveTo(M,$):n.lineTo(M,$)}),n.strokeStyle=R,n.lineWidth=2,n.stroke())})}}renderPie(e,t,n,i,o){const a=t.series[0];if(!a)return;const l=a.data.reduce((h,u)=>h+Math.abs(u),0)||1,r=n/2,d=i/2,c=Math.min(n,i)/2-30;let p=-Math.PI/2;a.data.forEach((h,u)=>{const f=Math.abs(h)/l*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,p,p+f),e.closePath(),e.fillStyle=Qe[u%Qe.length],e.fill();const g=p+f/2,v=r+Math.cos(g)*(c*.7),m=d+Math.sin(g)*(c*.7),y=Math.round(Math.abs(h)/l*100);y>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${y}%`,v,m)),p+=f}),e.fillStyle=o}formatTick(e){if(this.timeSeries){const n=new Date(e);if(!isNaN(n.getTime()))return n.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}const t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(1)}B`:t>=1e6?`${(e/1e6).toFixed(1)}M`:t>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(1)}truncate(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}}function Gn(s,e,t){const n=s.children;if(!n||n.length===0){const i=Ee(e,s,null);typeof i=="number"&&!isNaN(i)&&t.push(i);return}for(const i of n)Gn(i,e,t)}class Vs{constructor(e){w(this,"eGui");var d,c,p;const t=e.node,n=!!t.group,i=!!t.detailNode,o=n||i,a=t.expanded,l=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${l}px`,o){const h=document.createElement("span");h.className="ag-group-value-expanded-icon",h.classList.add(a?"ag-expanded":"ag-contracted"),h.innerHTML=a?so:io,r.appendChild(h);const u=document.createElement("span");u.className="ag-group-value";const f=(d=e.colDef.cellRendererParams)==null?void 0:d.innerRenderer;if(typeof f=="function"){const g=f({...e,value:e.value,valueFormatted:e.valueFormatted});g instanceof HTMLElement?u.appendChild(g):typeof g=="string"&&(u.innerHTML=g)}else u.textContent=Ks(e.value);if(r.appendChild(u),n&&t.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const g=document.createElement("span");g.className="ag-group-child-count",g.textContent=` (${t.allChildrenCount})`,r.appendChild(g)}}else{const h=document.createElement("span");h.className="ag-group-value";const u=(p=e.colDef.cellRendererParams)==null?void 0:p.innerRenderer;if(typeof u=="function"){const f=u({...e,value:e.value,valueFormatted:e.valueFormatted});f instanceof HTMLElement?h.appendChild(f):typeof f=="string"&&(h.innerHTML=f)}else h.textContent=e.valueFormatted??String(e.value??"");r.appendChild(h)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Gs{constructor(e){w(this,"eGui");w(this,"eCheckbox");this.eGui=document.createElement("span"),this.eGui.className="ag-cell-checkbox";const t=document.createElement("input");t.type="checkbox",t.className="ag-native-checkbox",t.checked=!!e.node.selected,t.addEventListener("click",n=>n.stopPropagation()),t.addEventListener("change",()=>{e.node.setSelected(t.checked,!1,"uiSelectChanged")}),this.eCheckbox=t,this.eGui.appendChild(t)}getGui(){return this.eGui}refresh(e){return this.eCheckbox.checked=!!e.node.selected,!0}}const qs='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',zs='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class _s{constructor(e){w(this,"eGui");w(this,"eArrow");w(this,"eOld");w(this,"eNew");w(this,"lastValue");w(this,"flashTimer",null);this.eGui=document.createElement("span"),this.eGui.className="ag-animate-show-change-cell-renderer",this.eArrow=document.createElement("span"),this.eArrow.className="ag-value-change-arrow",this.eArrow.style.display="none",this.eOld=document.createElement("span"),this.eOld.className="ag-value-change-old",this.eOld.style.display="none",this.eNew=document.createElement("span"),this.eNew.className="ag-value-change-new",this.eGui.appendChild(this.eArrow),this.eGui.appendChild(this.eOld),this.eGui.appendChild(this.eNew),this.eNew.textContent=this.formatValue(e),this.lastValue=e.value}formatValue(e){const t=e.valueFormatted??e.value;return t==null?"":String(t)}getGui(){return this.eGui}refresh(e){const t=e.value;if(t!==this.lastValue){const n=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),i=this.eNew.textContent??"";this.eArrow.innerHTML=n?qs:zs,this.eArrow.style.display="",this.eArrow.classList.add(n?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=i,this.eOld.style.display="",this.eNew.textContent=this.formatValue(e),this.lastValue=t,this.eGui.classList.remove("ag-value-change-value-highlight"),this.eGui.offsetWidth,this.eGui.classList.add("ag-value-change-value-highlight",n?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.flashTimer&&clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this.eGui.classList.remove("ag-value-change-value-highlight","ag-value-change-delta-up","ag-value-change-delta-down"),this.eArrow.style.display="none",this.eOld.style.display="none"},1e3)}return!0}destroy(){this.flashTimer&&clearTimeout(this.flashTimer)}}class Ws{constructor(e){w(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-number-cell",this.eGui.textContent=String(e.rowIndex+1)}getGui(){return this.eGui}refresh(e){return this.eGui.textContent=String(e.rowIndex+1),!0}}class Us{constructor(e){w(this,"eGui");var r,d;const t=document.createElement("span");t.className="ag-sparkline-cell";const n=e.value||[],i=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},o=e.column.width||100,a=i.height||24,l=Xt(n,Math.max(20,o-16),a,i);t.appendChild(l),this.eGui=t}getGui(){return this.eGui}refresh(e){var l,r;const t=e.value||[],n=e.sparklineOptions||((r=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:r.sparklineOptions)||{},i=e.column.width||100,o=n.height||24;this.eGui.innerHTML="";const a=Xt(t,Math.max(20,i-16),o,{type:n.type,direction:n.direction});return this.eGui.appendChild(a),!0}}function Xt(s,e,t,n={}){var m,y,x;const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",String(Math.max(20,e))),i.setAttribute("height",String(t)),i.setAttribute("class","ag-sparkline");const o=(s||[]).map(C=>typeof C=="number"?C:Number((C==null?void 0:C.value)??0));if(!o||o.length<1)return i;const a=n.type||"line",l=Math.min(...o,0),d=Math.max(...o,0)-l||1,c=((m=n.tooltip)==null?void 0:m.enabled)===!0,p=((y=n.axis)==null?void 0:y.type)||"number",h=((x=n.pointsOfInterest)==null?void 0:x.show)===!0,u=(C,b)=>p==="category"?`${C+1}: ${b}`:String(b);if(h&&o.length>1){const C=o.indexOf(Math.min(...o)),b=o.indexOf(Math.max(...o)),I=e/Math.max(1,o.length-1),A=G=>t-2-(G-l)/d*(t-4),S=(G,E)=>{const k=document.createElementNS("http://www.w3.org/2000/svg","circle");k.setAttribute("cx",String(G*I)),k.setAttribute("cy",String(A(o[G]))),k.setAttribute("r","2.5"),k.setAttribute("fill",E),i.appendChild(k)};S(0,"#4caf50"),S(o.length-1,"#f44336"),S(C,"#2196f3"),S(b,"#ff9800")}if(c){const C=document.createElementNS("http://www.w3.org/2000/svg","title");C.textContent=o.map((b,I)=>u(I,b)).join(`
3
- `),i.appendChild(C),i.style.cursor="default"}if(a==="bar"){const C=n.direction==="vertical",b=o.length;if(C){const I=Math.max(1,e/b-1),A=t-2-(0-l)/d*(t-4);o.forEach((S,G)=>{const E=G*(e/b),k=t-2-(S-l)/d*(t-4),T=document.createElementNS("http://www.w3.org/2000/svg","rect");T.setAttribute("x",String(E)),T.setAttribute("width",String(I)),T.setAttribute("y",String(Math.min(k,A))),T.setAttribute("height",String(Math.max(1,Math.abs(A-k)))),T.setAttribute("fill","currentColor"),i.appendChild(T)})}else{const I=Math.max(1,t/b-1),A=2+(0-l)/d*(e-4);o.forEach((S,G)=>{const E=G*(t/b),k=2+(S-l)/d*(e-4),T=document.createElementNS("http://www.w3.org/2000/svg","rect");T.setAttribute("y",String(E)),T.setAttribute("height",String(I)),T.setAttribute("x",String(Math.min(k,A))),T.setAttribute("width",String(Math.max(1,Math.abs(A-k)))),T.setAttribute("fill","currentColor"),i.appendChild(T)})}return i}const f=e/Math.max(1,o.length-1),g=o.map((C,b)=>{const I=b*f,A=t-2-(C-l)/d*(t-4);return`${I.toFixed(1)},${A.toFixed(1)}`});if(a==="area"){const C=document.createElementNS("http://www.w3.org/2000/svg","polygon");C.setAttribute("points",`0,${t} ${g.join(" ")} ${e},${t}`),C.setAttribute("fill","currentColor"),C.setAttribute("opacity","0.2"),i.appendChild(C)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",g.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),i.appendChild(v),i}class js{constructor(e){w(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=qn,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const Dt={agGroupCellRenderer:s=>new Vs(s),agCheckboxCellRenderer:s=>new Gs(s),agSparklineCellRenderer:s=>new Us(s),agAnimateShowChangeCellRenderer:s=>new _s(s),agRowNumberCellRenderer:s=>new Ws(s),agRowDragComp:s=>new js(s)};function Ks(s){return s==null?"":String(s)}class Ys{constructor(e){w(this,"eGui");w(this,"cancelled",!1);this.eGui=document.createElement("input"),this.eGui.type="text",this.eGui.className="ag-cell-editor-input",this.eGui.value=e.value??"",this.eGui.addEventListener("keydown",t=>{var n;return(n=e.onKeyDown)==null?void 0:n.call(e,t)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class Xs{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"cancelled",!1);var i,o;const t=document.createElement("div");t.className="ag-cell-editor-number";const n=document.createElement("input");if(n.type="text",n.className="ag-cell-editor-input",n.value=e.value??"",(o=(i=e.column)==null?void 0:i.cellEditorParams)!=null&&o.showStepperButtons){const a=document.createElement("span");a.className="ag-cell-editor-stepper ag-cell-editor-stepper-up",a.innerHTML="▲",a.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),r.preventDefault(),n.value=String(Number(n.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const l=document.createElement("span");l.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",l.innerHTML="▼",l.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),n.value=String(Number(n.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),t.appendChild(a),t.appendChild(n),t.appendChild(l)}else t.appendChild(n);this.eGui=t,this.eInput=n,this.eInput.addEventListener("keydown",a=>{var l;return(l=e.onKeyDown)==null?void 0:l.call(e,a)})}getGui(){return this.eGui}getValue(){if(this.cancelled)return;const e=Number(this.eInput.value);return isNaN(e)?null:e}focusIn(){this.eInput.focus(),this.eInput.select()}}class Zs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);var n,i;this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((i=(n=e.column)==null?void 0:n.cellEditorParams)==null?void 0:i.values)||[];for(const o of t){const a=document.createElement("option");a.value=String(o),a.textContent=String(o),this.eGui.appendChild(a)}this.eGui.value=String(e.value??""),this.eGui.addEventListener("keydown",o=>{var a;return(a=e.onKeyDown)==null?void 0:a.call(e,o)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus()}}class Qs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);this.eGui=document.createElement("input"),this.eGui.type="date",this.eGui.className="ag-cell-editor-input";const t=e.value instanceof Date?e.value:e.value?new Date(e.value):null;t&&!isNaN(t.getTime())&&(this.eGui.value=t.toISOString().slice(0,10))}getGui(){return this.eGui}getValue(){if(!this.cancelled)return this.eGui.value?new Date(this.eGui.value):null}focusIn(){this.eGui.focus()}}class Js{constructor(e){w(this,"eGui");w(this,"cancelled",!1);this.eGui=document.createElement("textarea"),this.eGui.className="ag-cell-editor-textarea",this.eGui.value=e.value??""}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}function eo(s,e){if(!e)return D(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?D(s):D(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+D(s.slice(t,t+e.length))+"</span>"+D(s.slice(t+e.length))}class to{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"ePopup",null);w(this,"eList",null);w(this,"values",[]);w(this,"filtered",[]);w(this,"activeIndex",0);w(this,"selectedValue");w(this,"cancelled",!1);var t,n;this.params=e,this.values=e.values||((n=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:n.values)||[],this.selectedValue=e.value,this.eGui=document.createElement("div"),this.eGui.className="ag-rich-select",this.eInput=document.createElement("input"),this.eInput.type="text",this.eInput.className="ag-rich-select-input",this.eInput.value=e.value===null||e.value===void 0?"":String(e.value),this.eInput.readOnly=e.allowTyping!==!0,this.eGui.appendChild(this.eInput),this.eGui.addEventListener("mousedown",i=>{i.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",i=>this.onKeyDown(i))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var a,l;if(this.ePopup)return;const e=document.createElement("div");e.className="ag-rich-select-popup";const t=this.eGui.getBoundingClientRect();if(e.style.position="fixed",e.style.left=`${t.left}px`,e.style.top=`${t.bottom}px`,e.style.minWidth=`${Math.max(t.width,180)}px`,e.style.zIndex="1000",(this.eGui.closest(".ag-root")||document.body).appendChild(e),this.ePopup=e,no(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((l=(a=this.params).t)==null?void 0:l.call(a,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const i=document.createElement("div");i.className="ag-rich-select-list",e.appendChild(i),this.eList=i,this.renderList();const o=r=>{!e.contains(r.target)&&!this.eGui.contains(r.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var n,i;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(o=>{if(!e)return!0;const a=String(o).toLowerCase(),l=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?l.every(r=>a.includes(r)):l.some(r=>a.includes(r))}),this.filtered.forEach((o,a)=>{const l=document.createElement("div");l.className="ag-rich-select-item",a===this.activeIndex&&l.classList.add("ag-active"),String(o)===String(this.selectedValue)&&l.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const d=r({value:o,valueFormatted:String(o)});d instanceof HTMLElement?l.appendChild(d):l.textContent=String(d)}else l.innerHTML=eo(String(o),e);l.addEventListener("click",d=>{d.stopPropagation(),this.commit(o)}),l.addEventListener("mousedown",d=>d.preventDefault()),this.eList.appendChild(l)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((i=(n=this.params).t)==null?void 0:i.call(n,"noMatches"))??"无匹配项",this.eList.appendChild(o)}const t=this.eList.children[this.activeIndex];t&&typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"nearest"})}onKeyDown(e){if(e.key==="ArrowDown")e.preventDefault(),this.activeIndex=Math.min(this.filtered.length-1,this.activeIndex+1),this.renderList();else if(e.key==="ArrowUp")e.preventDefault(),this.activeIndex=Math.max(0,this.activeIndex-1),this.renderList();else if(e.key==="Enter"){e.preventDefault();const t=this.filtered[this.activeIndex];t!==void 0?this.commit(t):this.closePopup()}else if(e.key==="Escape")e.preventDefault(),this.cancelled=!0,this.closePopup();else if(e.key==="Tab"){e.preventDefault();const t=this.filtered[this.activeIndex];t!==void 0?this.commit(t):this.closePopup()}}commit(e){this.selectedValue=e,this.eInput.value=String(e),this.closePopup(),setTimeout(()=>{var t,n;return(n=(t=this.params).onKeyDown)==null?void 0:n.call(t,{key:"Enter",preventDefault:()=>{},keyCode:13})},0)}closePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,this.eList=null}getValue(){return this.cancelled?void 0:this.selectedValue}isCancelAfterEnd(){return this.cancelled}destroy(){this.closePopup()}}function no(s){var e,t;return(s==null?void 0:s.allowTyping)===!0||((t=(e=s==null?void 0:s.column)==null?void 0:e.cellEditorParams)==null?void 0:t.allowTyping)===!0}const Je={agTextCellEditor:s=>new Ys(s),agNumberCellEditor:s=>new Xs(s),agSelectCellEditor:s=>new Zs(s),agDateCellEditor:s=>new Qs(s),agLargeTextCellEditor:s=>new Js(s),agRichSelectCellEditor:s=>new to(s)},io='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',so='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',qn='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="5" cy="3" r="1.4"/><circle cx="11" cy="3" r="1.4"/><circle cx="5" cy="8" r="1.4"/><circle cx="11" cy="8" r="1.4"/><circle cx="5" cy="13" r="1.4"/><circle cx="11" cy="13" r="1.4"/></svg>',oo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="3" cy="8" r="1.4"/><circle cx="8" cy="8" r="1.4"/><circle cx="13" cy="8" r="1.4"/></svg>',ao='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',ro='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',lo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',zn='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>';class co{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:n,close:i}=this.popupService.createPopup(220,"ag-column-menu");n.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=e.headerName||e.field||e.colId,n.appendChild(o);const a=(r,d)=>{const c=document.createElement("div");c.className="ag-menu-item",d.disabled&&c.classList.add("ag-menu-item-disabled"),d.checked&&c.classList.add("ag-menu-item-active");const p=document.createElement("span");p.className="ag-menu-item-check",d.checked&&(p.innerHTML=zn),c.appendChild(p);const h=document.createElement("span");if(h.className="ag-menu-item-label",h.textContent=r,c.appendChild(h),d.shortcut){const u=document.createElement("span");u.className="ag-menu-item-shortcut",u.textContent=d.shortcut,c.appendChild(u)}return!d.disabled&&d.onClick&&c.addEventListener("click",()=>{d.onClick(),i()}),n.appendChild(c),c},l=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,n.appendChild(d)};e.sortable&&(l(this.grid.t("sort")),a(this.grid.t("sortAscending"),{checked:e.sort==="asc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"asc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}}),a(this.grid.t("sortDescending"),{checked:e.sort==="desc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"desc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}})),e.resizable&&(l(this.grid.t("columnSize")),a(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),a(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(l(this.grid.t("pinColumn")),a(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),a(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),a(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(l(this.grid.t("filter")),a(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,t)}),e.filter!=="multi"&&a(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,t)}),this.grid.getOptions().enableAdvancedFilter&&a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)}),a(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(l(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),l(this.grid.t("formula")),a(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,t)}),l(this.grid.t("visibility")),a(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),a(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(n,t)}}const _n={copy:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 2h7v2h2v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-2H3V4a2 2 0 0 1 1-2zm1 2v8h1V4H5z"/></svg>',copyWithHeaders:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M2 1h12v2H2V1zm2 3h8v9H4V4z"/></svg>',paste:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M5 2h6v2H5V2zM3 4h10v10H3V4z"/></svg>',csv:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',excel:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',reset:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 2a6 6 0 1 0 5.7 4H11l3 3 3-3h-2.3A7 7 0 1 1 8 1v1z"/></svg>',pin:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M9 1l6 6-2 1-1 4-3-3-4 4v-3l3-3-1-3 4-1z"/></svg>'};class uo{constructor(e,t){this.grid=e,this.popupService=t}getDefaultItems(e){return[{name:"copy",label:this.grid.t("copy"),icon:"copy",shortcut:"Ctrl+C",action:()=>this.grid.getApi().copyToClipboard()},{name:"copyWithHeaders",label:this.grid.t("copyWithHeaders"),icon:"copyWithHeaders",action:()=>this.grid.getApi().copyToClipboard({includeHeaders:!0})},{name:"paste",label:this.grid.t("paste"),icon:"paste",shortcut:"Ctrl+V",action:()=>this.grid.getApi().pasteFromClipboard()},{name:"sep1",separator:!0},{name:"export",label:this.grid.t("export"),icon:"excel",subMenu:[{name:"csvExport",label:this.grid.t("csvExport"),icon:"csv",action:()=>this.grid.getApi().exportToCsv({fileName:"export.csv"})},{name:"excelExport",label:this.grid.t("excelExport"),icon:"excel",action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx"})},{name:"excelExportSelected",label:"Excel Export (Selected)",icon:"excel",disabled:!this.hasSelection(),action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx",onlySelected:!0})}]},{name:"sep2",separator:!0},{name:"resetColumns",label:this.grid.t("resetColumns"),icon:"reset",action:()=>this.grid.getColumnApi().resetColumnState()},{name:"autoSizeAll",label:"Auto-size All Columns",action:()=>this.grid.getColumnApi().autoSizeAllColumns()},{name:"sizeToFit",label:this.grid.t("sizeToFit"),action:()=>this.grid.getApi().sizeColumnsToFit()},{name:"sep3",separator:!0},{name:"expandAll",label:this.grid.t("expandAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().expandAll()},{name:"collapseAll",label:this.grid.t("collapseAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().collapseAll()},{name:"pinRow",label:this.grid.t("pinRow"),icon:"pin",disabled:!e.node||e.node.group===!0,subMenu:[{name:"pinTop",label:this.grid.t("pinToTop"),action:()=>this.grid.setRowNodePinned(e.node,"top")},{name:"pinBottom",label:this.grid.t("pinToBottom"),action:()=>this.grid.setRowNodePinned(e.node,"bottom")},{name:"unpin",label:this.grid.t("unpin"),action:()=>this.grid.setRowNodePinned(e.node,null)}]}]}hasSelection(){return this.grid.getApi().getSelectedNodes().length>0}isGroupActive(){return this.grid.getColumnModel().isRowGroupActive()}openContextMenu(e,t){if(this.grid.getOptions().suppressContextMenu)return;const n=this.grid.getOptions().contextMenuItems;let i;typeof n=="function"?i=n({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(n)?i=n:i=this.getDefaultItems(t);const{ePopup:o,close:a}=this.popupService.createPopup(220,"ag-context-menu");o.innerHTML="",this.buildMenu(o,i,a),this.popupService.positionAt(o,e)}buildMenu(e,t,n){for(const i of t){if(typeof i=="string")continue;if(i.separator){const r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);continue}const o=document.createElement("div");o.className="ag-menu-item",i.disabled&&o.classList.add("ag-menu-item-disabled"),i.cssClasses&&o.classList.add(...i.cssClasses);const a=document.createElement("span");a.className="ag-menu-item-icon",i.icon&&_n[i.icon]&&(a.innerHTML=_n[i.icon]),o.appendChild(a);const l=document.createElement("span");if(l.className="ag-menu-item-label",l.textContent=i.label??i.name,o.appendChild(l),i.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=i.shortcut,o.appendChild(r)}if(i.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",o.appendChild(r),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,i.subMenu,n),e.appendChild(c)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;o.matches(":hover")||((c=o.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove())},200)})}else!i.disabled&&i.action&&o.addEventListener("click",()=>{i.action(),n()});e.appendChild(o)}}}class ho{constructor(e,t){w(this,"editing",null);w(this,"fullRowEditors",null);w(this,"fullRowNode",null);w(this,"focusedCell",null);this.grid=e,this.eventService=t}getFocusedCell(){return this.focusedCell}setFocusedCell(e,t){this.focusedCell={rowIndex:e,column:t,rowNode:this.grid.getDisplayedRowAtIndex(e)},this.clearFocusClass();const n=this.findCellElement(t,e);n==null||n.classList.add("ag-cell-focus"),n&&typeof n.scrollIntoView=="function"&&n.scrollIntoView({block:"nearest",inline:"nearest"}),this.eventService.dispatchEvent("cellFocused",{rowIndex:e,column:t,api:this.grid.getApi(),forceBrowserFocus:!0})}clearFocusedCell(){this.focusedCell=null,this.clearFocusClass(),this.grid.getRowRenderer().refreshCells({force:!0})}clearFocusClass(){const e=this.grid.getRootElement();for(const t of e.querySelectorAll(".ag-cell-focus"))t.classList.remove("ag-cell-focus")}findCellElement(e,t){const n=this.grid.getDisplayedRowAtIndex(t);if(!n)return null;const o=this.grid.getRowRenderer().getRowComps().get(n.id);return o&&o.getCellElements().find(a=>a.dataset.colid===e.colId)||null}isEditing(){return this.editing!==null||this.fullRowEditors!==null}getEditingCells(){return this.editing?[{rowIndex:this.editing.rowIndex,colId:this.editing.column.colId}]:[]}startEditingCell(e){var d;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const n=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!n||!this.grid.isCellEditable(t,n))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,n,e.charPress);return}const i=this.findCellElement(t,e.rowIndex);if(!i)return;const o=Ee(t,n,this.grid.getApi()),a={value:e.charPress!==void 0?e.charPress:o,oldValue:o,data:n.data,node:n,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=t.cellEditorParams)==null?void 0:d.values,...t.cellEditorParams};let l;if(typeof t.cellEditor=="string")l=(Je[t.cellEditor]||Je.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const c=t.cellEditor(a);l=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";l=Je[c](a)}if(!l)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:n,eCell:i,editor:l,startedValue:o},i.classList.add("ag-cell-inline-editing");const r=l.getGui();r.classList.add("ag-cell-editor"),i.appendChild(r),i.classList.add("ag-cell-editing"),l.focusIn&&l.focusIn(),l.afterGuiAttached&&l.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:n,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,n){const i=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(o=>this.grid.isCellEditable(o,t));this.fullRowEditors=[],this.fullRowNode=t;for(const o of i){const a=this.findCellElement(o,e);if(!a)continue;const l=Ee(o,t,this.grid.getApi()),r=this.createEditor(o,t,e,l,n);if(!r)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),a.appendChild(d),this.fullRowEditors.push({column:o,editor:r,eCell:a,startedValue:l})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,n,i,o){var r;const a={value:o!==void 0?o:i,oldValue:i,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:n,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(Je[e.cellEditor]||Je.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const d=e.cellEditor(a);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const l=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return Je[l](a)}stopEditing(e=!1){var d,c,p,h;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:n,rowNode:i,eCell:o,editor:a,startedValue:l}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?l:a.getValue();if(r===void 0&&!e)return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:n,node:i,api:this.grid.getApi()}),!1;if(!e){r=$n(n,r);const u=this.applyValueSetter(n,i,r);if(u===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:n}),!1;r=u}return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:n,node:i,api:this.grid.getApi()}),!e&&!Wn(r,l)&&(this.grid.setCellValue(n,i,r,"edit",l),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l,newValue:r,value:r,data:i.data,node:i,column:n,colDef:n.colDef,api:this.grid.getApi(),source:"edit"}),(h=(p=this.grid.getOptions()).onCellValueChanged)==null||h.call(p,{oldValue:l,newValue:r,value:r,data:i.data,node:i,column:n,colDef:n.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[i],columns:[n],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,n){if(e.valueSetter){if(e.valueSetter({oldValue:Ee(e,t,this.grid.getApi()),newValue:n,data:t.data,node:t,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else t.setDataValue(e.colId,n);return n}stopFullRowEditing(e){var o,a,l;const t=this.fullRowEditors,n=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=r.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const i=[];for(const r of t){if(!n)break;let d=r.editor.getValue();d!==void 0&&(d=$n(r.column,d),Wn(d,r.startedValue)||i.push({column:r.column,rowNode:n,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:n==null?void 0:n.data});for(const r of i)this.grid.setCellValue(r.column,r.rowNode,r.newValue,"edit",r.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi(),source:"edit"}),(l=(a=this.grid.getOptions()).onCellValueChanged)==null||l.call(a,{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[r.rowNode],columns:[r.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===13){e.preventDefault();const t=this.editing;this.stopEditing(),t&&this.grid.getOptions().enterNavigatesVerticallyAfterEdit!==!1&&this.moveFocus(1,0)}else if(e.key==="Escape"||e.keyCode===27)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===9){e.preventDefault(),this.stopEditing(),this.moveFocus(0,e.shiftKey?-1:1);const t=this.focusedCell;t&&this.grid.isCellEditable(t.column,t.rowNode)&&this.startEditingCell({rowIndex:t.rowIndex,colKey:t.column})}}onGridKeyDown(e){const t=e.key;if(this.editing){t==="Escape"&&this.stopEditing(!0);return}const n=this.focusedCell;switch(e.keyCode){case 13:e.preventDefault(),n&&(this.grid.isCellEditable(n.column,n.rowNode)?this.startEditingCell({rowIndex:n.rowIndex,colKey:n.column}):this.moveFocus(1,0));break;case 9:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case 8:case 46:n&&this.grid.isCellEditable(n.column,n.rowNode)&&(e.preventDefault(),this.grid.setCellValue(n.column,n.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[n.rowNode],columns:[n.column],flash:!0}));break;case 37:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,-1));break;case 39:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,1));break;case 38:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1,0));break;case 40:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1,0));break;case 36:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case 35:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1/0,0));break;case 33:e.preventDefault(),this.moveFocus(-this.getPageJump(),0);break;case 34:e.preventDefault(),this.moveFocus(this.getPageJump(),0);break;case 70:(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.grid.openFind());break;default:if((t==="f"||t==="F")&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.grid.openFind();return}n&&t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(n.column,n.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:n.rowIndex,colKey:n.column,charPress:t}));break}}isTextInput(e){if(!e)return!1;const t=e;return t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable}getPageJump(){const e=this.grid.getRowRenderer().getViewport();return Math.max(1,Math.floor(e.clientHeight/(this.grid.getOptions().rowHeight??42))-1)}moveFocus(e,t){const n=this.focusedCell;if(!n){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let i=n.rowIndex;if(e===-1/0?i=0:e===1/0?i=this.grid.getDisplayedRowCount()-1:i=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,i+e)),t!==0){const o=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let l=o.findIndex(r=>r.colId===n.column.colId)+t;for(;l>=0&&l<o.length&&!o[l].visible;)l+=t;l<0&&(l=0),l>=o.length&&(l=o.length-1),this.setFocusedCell(i,o[l])}else this.setFocusedCell(i,n.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:n}=e;if(this.setFocusedCell(e.rowIndex,n),n.checkboxSelection)return;const i=this.grid.isCellEditable(n,t),o=n.singleClickEdit||this.grid.getOptions().singleClickEdit;i&&o&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:n})}onCellDoubleClicked(e){const{node:t,column:n}=e;this.setFocusedCell(e.rowIndex,n),this.grid.isCellEditable(n,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:n})}destroy(){this.editing=null,this.focusedCell=null}}function Wn(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}const po={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function Un(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function fo(s,e,t){const n=Math.max(1,Math.floor(e/(t*.5)));return s.length>n?`${s.slice(0,Math.max(1,n-1))}…`:s}function go(){return new TextEncoder}function mo(s,e={}){const[t,n]=po[e.pageSize||"a4-landscape"],i=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,l=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=go(),c=[],p=y=>(c.push(y),c.length);p(""),p("");const h=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),u=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),f=[];for(const y of s){let x="";const C=y.columnWidths.reduce((H,W)=>H+W,0),b=Math.min(1,(t-i*2)/(C||1)),I=y.columnWidths.map(H=>H*b),A=i;let S=n-i-(e.title?24:0);e.title&&(x+=`BT /F2 ${o+4} Tf ${A} ${S} Td (${Un(e.title)}) Tj ET
4
- `,S-=18),y.rows.forEach((H,W)=>{var M;const R=W===0,O=((M=y.rowFill)==null?void 0:M[W])??(R?l:void 0);O&&(x+=`${O[0]} ${O[1]} ${O[2]} rg ${A} ${(S-a+4).toFixed(2)} ${C*b} ${a} re f
5
- `);let L=A;H.forEach(($,_)=>{const U=I[_]??0,ee=Un(fo($.text??"",U-6,o)),ae=$.bold||R?u:h,he=($.text??"").length*o*.5;let be=L+3;$.align==="right"||!$.align&&_>0&&/^-?[\d,.%$£€\s]+$/.test($.text??"")?be=L+U-3-Math.min(he,U-6):$.align==="center"&&(be=L+(U-Math.min(he,U-6))/2),x+=`BT /F${ae===u?2:1} ${o} Tf ${be.toFixed(2)} ${(S-o+2).toFixed(2)} Td (${ee}) Tj ET
6
- `,L+=U}),x+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${A} ${(S-a+4).toFixed(2)} m ${(A+C*b).toFixed(2)} ${(S-a+4).toFixed(2)} l S
7
- `,S-=a});const G=y.rows.length*a;x+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${A} ${(S+a-4).toFixed(2)} m ${A} ${(S+G+a-4).toFixed(2)} l ${(A+C*b).toFixed(2)} ${(S+G+a-4).toFixed(2)} l ${(A+C*b).toFixed(2)} ${(S+a-4).toFixed(2)} l S
8
- `;const E=d.encode(x),k=p(`<< /Length ${E.length} >>
1
+ (function(K,ze){typeof exports=="object"&&typeof module<"u"?ze(exports):typeof define=="function"&&define.amd?define(["exports"],ze):(K=typeof globalThis<"u"?globalThis:K||self,ze(K.Rowvia={}))})(this,function(K){"use strict";var Sr=Object.defineProperty;var Er=(K,ze,St)=>ze in K?Sr(K,ze,{enumerable:!0,configurable:!0,writable:!0,value:St}):K[ze]=St;var y=(K,ze,St)=>Er(K,typeof ze!="symbol"?ze+"":ze,St);function D(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let ws=0;function Xt(s="id"){return`${s}-${++ws}`}function Ue(s,e){if(typeof s!="number"||isNaN(s))return String(s??"");const t=e??0,n=s.toFixed(t),[i,o]=n.split("."),a=i.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${a}.${o}`:a}function Zt(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function ys(s,e){if(s===e)return 0;if(s==null)return-1;if(e==null)return 1;if(typeof s=="number"&&typeof e=="number")return s-e;if(s instanceof Date&&e instanceof Date)return s.getTime()-e.getTime();const t=String(s).toLowerCase(),n=String(e).toLowerCase();return t<n?-1:t>n?1:0}function bs(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ge extends Error{constructor(e){super(e),this.code=e}}const Cs=/^\$?[A-Za-z]{1,3}\$?\d+$/;function Dn(s){const e=[];let t=0;for(;t<s.length;){const n=s[t];if(n===" "||n===" "||n===`
2
+ `||n==="\r"){t++;continue}if(n==='"'||n==="'"){const o=n;let a="";for(t++;t<s.length&&s[t]!==o;)a+=s[t++];t++,e.push({type:"string",value:a});continue}if(/[0-9]/.test(n)||n==="."&&/[0-9]/.test(s[t+1]||"")){let o="";for(;t<s.length&&/[0-9.]/.test(s[t]);)o+=s[t++];if(s[t]==="e"||s[t]==="E")for(o+=s[t++],(s[t]==="+"||s[t]==="-")&&(o+=s[t++]);t<s.length&&/[0-9]/.test(s[t]);)o+=s[t++];e.push({type:"number",value:o});continue}if(/[A-Za-z_$]/.test(n)){let o="";for(;t<s.length&&/[A-Za-z0-9_$.]/.test(s[t]);)o+=s[t++];Cs.test(o)?e.push({type:"cell",value:o.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:o});continue}if(n==="("){e.push({type:"lparen",value:n}),t++;continue}if(n===")"){e.push({type:"rparen",value:n}),t++;continue}if(n===","||n===";"){e.push({type:"comma",value:","}),t++;continue}const i=s.slice(t,t+2);if(["<=",">=","<>"].includes(i)){e.push({type:"op",value:i}),t+=2;continue}if("+-*/^%&=<>,:".includes(n)){e.push({type:"op",value:n}),t++;continue}throw new Ge("#NAME?")}return e}const Pn={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function Hn(s){let e=0;const t=()=>s[e],n=()=>s[e++];function i(r=0){let d=o();for(;t()&&t().type==="op"&&Pn[t().value]>=r;){const c=n().value,p=i(Pn[c]+1);d={type:"binary",operator:c,left:d,right:p}}return d}function o(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){n();const d=o();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return a()}function a(){const r=n();if(!r)throw new Ge("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=t();if(c&&c.type==="lparen"){n();const p=[];if(t()&&t().type!=="rparen")for(p.push(i());t()&&t().type==="comma";)n(),p.push(i());if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return n(),{type:"call",name:d,args:p}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=i();if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return n(),d}throw new Ge("#ERROR!")}const l=i();if(e<s.length)throw new Ge("#ERROR!");return l}function ye(s){if(s==null||s==="")return 0;if(typeof s=="number")return s;if(typeof s=="boolean")return s?1:0;if(s instanceof Date)return s.getTime();const e=Number(s);return isNaN(e)?0:e}function ct(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...ct(t));else if(t!=null&&t!==""){const n=typeof t=="number"?t:Number(t);isNaN(n)||e.push(n)}return e}const Dt={SUM:s=>ct(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=ct(s);return e.length?e.reduce((t,n)=>t+n,0)/e.length:0},AVG:s=>Dt.AVERAGE(s,{}),MIN:s=>{const e=ct(s);return e.length?Math.min(...e):0},MAX:s=>{const e=ct(s);return e.length?Math.max(...e):0},COUNT:s=>ct(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(ye(s[0])),ROUND:s=>{const e=s.length>1?ye(s[1]):0,t=Math.pow(10,e);return Math.round(ye(s[0])*t)/t},FLOOR:s=>Math.floor(ye(s[0])),CEIL:s=>Math.ceil(ye(s[0])),CEILING:s=>Math.ceil(ye(s[0])),SQRT:s=>{const e=ye(s[0]);return e<0?(()=>{throw new Ge("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(ye(s[0]),ye(s[1])),POW:s=>Math.pow(ye(s[0]),ye(s[1])),MOD:s=>{const e=ye(s[1]);if(e===0)throw new Ge("#DIV/0!");return ye(s[0])%e},CONCAT:s=>s.map(e=>e==null?"":String(e)).join(""),CONCATENATE:s=>s.map(e=>e==null?"":String(e)).join(""),UPPER:s=>String(s[0]??"").toUpperCase(),LOWER:s=>String(s[0]??"").toLowerCase(),LEN:s=>String(s[0]??"").length,LEFT:s=>String(s[0]??"").slice(0,s.length>1?ye(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?ye(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,ye(s[1])-1),n=s.length>2?ye(s[2]):e.length-t;return e.slice(t,t+n)},TRIM:s=>String(s[0]??"").trim(),IF:s=>s[0]?s[1]??!0:s[2]??!1,IFS:s=>{for(let e=0;e<s.length-1;e+=2)if(s[e])return s[e+1];return s.length%2===1?s[s.length-1]:!1},AND:s=>s.every(e=>!!e),OR:s=>s.some(e=>!!e),NOT:s=>!s[0],IFERROR:s=>{try{return s[0]===null||s[0]===void 0?s[1]:s[0]}catch{return s[1]}},ISNUMBER:s=>typeof s[0]=="number"||s[0]!==null&&s[0]!==""&&!isNaN(Number(s[0])),ISBLANK:s=>s[0]===null||s[0]===void 0||s[0]==="",ISTEXT:s=>typeof s[0]=="string",PI:()=>Math.PI,RAND:()=>Math.random(),TODAY:()=>new Date().toISOString().slice(0,10),NOW:()=>new Date().toISOString(),YEAR:s=>new Date(s[0]).getFullYear(),MONTH:s=>new Date(s[0]).getMonth()+1,DAY:s=>new Date(s[0]).getDate(),TEXT:s=>String(s[0]??""),VALUE:s=>ye(s[0]),NUMBER:s=>ye(s[0]),BETWEEN:s=>ye(s[0])>=ye(s[1])&&ye(s[0])<=ye(s[2])},Pt=Object.keys(Dt);function Ss(s,e){Dt[s.toUpperCase()]=e,Pt.includes(s.toUpperCase())||Pt.push(s.toUpperCase())}function Es(s,e){const t=/^([A-Za-z]{1,3})(\d+)$/.exec(s);if(t&&e.a1Lookup)return e.a1Lookup(t[1].toUpperCase(),Number(t[2]))}function xs(s,e){const t=e.data||{};if(s in t)return t[s];const n=s.toLowerCase();for(const i of Object.keys(t))if(i.toLowerCase()===n)return t[i]}function Et(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return xs(s.value,e);case"cell":return Es(s.value,e);case"unary":return-ye(Et(s.operand,e));case"call":{const t=Dt[s.name];if(!t)throw new Ge("#NAME?");const n=s.args.map(i=>Et(i,e));return t(n,e)}case"binary":{const t=Et(s.left,e),n=Et(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof n=="string"?`${t??""}${n??""}`:ye(t)+ye(n);case"-":return ye(t)-ye(n);case"*":return ye(t)*ye(n);case"/":{const i=ye(n);if(i===0)throw new Ge("#DIV/0!");return ye(t)/i}case"^":return Math.pow(ye(t),ye(n));case"%":{const i=ye(n);if(i===0)throw new Ge("#DIV/0!");return ye(t)%i}case"&":return`${t??""}${n??""}`;case"=":return t===n;case"<>":return t!==n;case"<":return ye(t)<ye(n);case"<=":return ye(t)<=ye(n);case">":return ye(t)>ye(n);case">=":return ye(t)>=ye(n);default:throw new Ge("#ERROR!")}}default:throw new Ge("#ERROR!")}}function xt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,n=Hn(Dn(t));return Et(n,e)}function Qt(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function Jt(s,e){if(s==null)return;if(e in s)return s[e];const t=e.split(".");let n=s;for(const i of t){if(n==null)return;n=n[i]}return n}function Ce(s,e,t){const n=s.colDef,i=(e.group||e.footer)&&!!e.groupData&&e.groupData[s.colId]!==void 0,o=i?e.groupData:e.data,a=s.valueGetter??n.valueGetter;if(a)return(typeof a=="string"?r=>Qt(a)?xt(a,{data:r.data}):Jt(r.data,a):a)({data:i?e.groupData:e.data,node:e,column:s,api:t,colDef:n,getValue:r=>Jt(i?e.groupData:e.data,r)});if(s.field&&Qt(s.field))return xt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return xt(`=${s.field}`,{data:e.data});if(s.field)return Jt(o,s.field)}function Ht(s,e,t){var o;const n=Ce(s,e,t),i=s.colDef;if(i.showValueAs&&typeof n=="number"&&t){const a=(o=t.__columnTotalCache)==null?void 0:o.get(s.colId);if(a!==void 0&&a!==0)return`${(i.showValueAs==="percentOfParent"?n/(a||1)*100:n/a*100).toFixed(1)}%`}return i.valueFormatter?(typeof i.valueFormatter=="string"?l=>ks(l.colDef.valueFormatter,l.value,l):i.valueFormatter)({value:n,data:e.data,node:e,column:s,api:t,colDef:i}):Ms(s,n)}function ks(s,e,t={}){var n,i,o;if(e==null)return"";switch(s){case"number":return Ue(e,((n=t.column)==null?void 0:n.decimals)??0);case"currency":return`$${Ue(e,((i=t.column)==null?void 0:i.decimals)??2)}`;case"percent":return`${Ue(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return On(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function On(s){const e=s instanceof Date?s:new Date(s);return isNaN(e.getTime())?String(s):`${e.getDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()]} ${e.getFullYear()}`}function Ms(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?Ue(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?On(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Bn(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?n=>Vn(n.colDef.valueParser,n.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Vn(s.type,e)}function Vn(s,e){if(s==="numberColumn")return Zt(e);if(s==="dateColumn"){if(e instanceof Date)return e;const t=new Date(e);return isNaN(t.getTime())?e:t}return s==="booleanColumn"?e===!0||e==="true":e}function Gn(s){const t=s.colDef.comparator,n=s.type;return(i,o)=>{const a=Ce(s,i,null),l=Ce(s,o,null);if(t)return t(a,l,i,o);if(n==="numberColumn"){const r=typeof a=="number"?a:Zt(a),d=typeof l=="number"?l:Zt(l);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(n==="dateColumn"){const r=a instanceof Date?a.getTime():new Date(a).getTime(),d=l instanceof Date?l.getTime():new Date(l).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return ys(a,l)}}function kt(s,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:s,rowNode:null,data:null});const n=t.filter(i=>typeof i=="number"&&!isNaN(i));switch(e){case"sum":return n.reduce((i,o)=>i+o,0);case"count":return t.length;case"avg":return n.length?n.reduce((i,o)=>i+o,0)/n.length:null;case"min":return n.length?Math.min(...n):null;case"max":return n.length?Math.max(...n):null;case"first":return t.length?t[0]:null;case"last":return t.length?t[t.length-1]:null;default:return null}}function Rs(s){const e={onInteraction:s.onInteraction,setRowData:n=>s.setRowData(n),applyTransaction:n=>s.applyTransaction(n),getRowNode:n=>s.getRowNode(n),getDisplayedRowCount:()=>s.getDisplayedRowCount(),getDisplayedRowAtIndex:n=>s.getDisplayedRowAtIndex(n),getFirstDisplayedRow:()=>s.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>s.getDisplayedRowAtIndex(s.getDisplayedRowCount()-1),forEachNode:n=>{const i=s.getRowModel();for(let o=0;o<i.getRowCount();o++){const a=i.getRow(o);a&&n(a,o)}},forEachLeafNode:n=>{s.getRowModel().forEachLeafNode(n)},getModel:()=>s.getRowModel(),getValue:(n,i)=>{const o=typeof n=="string"?s.getColumn(n):n;if(!(!o||!i))return Ce(o,i,s.getApi())},getSelectedRows:()=>s.getSelectionService().getSelectedRows(),getSelectedNodes:()=>s.getSelectionService().getSelectedNodes(),selectAll:()=>s.getSelectionService().selectAll(),deselectAll:()=>s.getSelectionService().deselectAll(),selectAllFiltered:()=>s.getSelectionService().selectAllFiltered(),deselectAllFiltered:()=>s.getSelectionService().deselectAll(),selectNode:(n,i)=>s.getSelectionService().selectNode(n,i??!1),deselectNode:n=>s.getSelectionService().deselectNode(n),setQuickFilter:n=>s.setQuickFilter(n),isQuickFilterPresent:()=>s.getQuickFilter().length>0,resetQuickFilter:()=>s.setQuickFilter(""),getSortModel:()=>s.getSortService().getSortModel(),setSortModel:n=>s.getSortService().setSortModel(n),getFilterModel:()=>s.getFilterService().getFilterModel(),setFilterModel:n=>s.getFilterService().setFilterModel(n),getColumnFilterModel:n=>{const i=typeof n=="string"?n:n.colId;return s.getFilterService().getFilterInstance(i)??null},setColumnFilterModel:(n,i)=>s.getFilterService().setColumnFilterModel(n,i),getAdvancedFilterModel:()=>s.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:n=>s.getFilterService().setAdvancedFilterModel(n),onFilterChanged:()=>s.getFilterService().onFilterChanged("api"),onSortChanged:()=>s.getSortService().onSortChanged("api"),expandAll:()=>s.getRowModel().expandAll(),collapseAll:()=>s.getRowModel().collapseAll(),onGroupExpandedOrCollapsed:()=>s.refreshModel("expand"),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),setRowNodePinned:(n,i)=>s.setRowNodePinned(n,i),getColumnDefs:()=>s.getColumnModel().getColumnDefs(),setColumnDefs:(n,i)=>{s.getColumnModel().setColumnDefs(n),s.onGridSizeChanged()},updateGridOptions:n=>s.updateGridOptions(n),setGridOption:(n,i)=>s.updateGridOptions({[n]:i}),sizeColumnsToFit:()=>{const n=s.getSideBarService().isVisible()?s.getSideBarService().getElement().offsetWidth:0;s.getColumnModel().sizeColumnsToFit(s.getGridDiv().clientWidth-n),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:n=>{s.getColumnModel().autoSizeAllColumns()},moveColumn:(n,i)=>s.getColumnModel().moveColumn(n,i),moveColumnByIndex:(n,i)=>s.getColumnModel().moveColumnByIndex(n,i),setColumnVisible:(n,i)=>s.getColumnApi().setColumnVisible(n,i),setColumnsPinned:(n,i)=>s.getColumnApi().setColumnsPinned(n,i),setColumnsVisible:(n,i)=>s.getColumnApi().setColumnsVisible(n,i),getAllColumns:()=>s.getAllColumns(),getColumns:()=>[...s.getColumns().left,...s.getColumns().center,...s.getColumns().right],getColumn:n=>s.getColumn(n)??null,getDisplayedLeftColumns:()=>s.getColumns().left,getDisplayedCenterColumns:()=>s.getColumns().center,getDisplayedRightColumns:()=>s.getColumns().right,getColumnState:()=>s.getColumnApi().getColumnState(),applyColumnState:(n,i)=>s.getColumnApi().applyColumnState(n,i),resetColumnState:()=>s.getColumnApi().resetColumnState(),openColumnMenu:n=>{const i=typeof n=="string"?s.getColumn(n):n;i!=null&&i.eHeaderCell&&s.getHeaderView().getHeaderCell(i)},setSideBarVisible:n=>{s.getSideBarService().setVisible(n),s.onGridSizeChanged()},isSideBarVisible:()=>s.getSideBarService().isVisible(),setSideBarPosition:n=>{s.getSideBarService().setPosition(n),s.onGridSizeChanged()},openToolPanel:n=>{s.getSideBarService().setVisible(!0),s.getSideBarService().openPanel(n),s.onGridSizeChanged()},closeToolPanel:()=>{s.getSideBarService().setVisible(!1),s.onGridSizeChanged()},getToolPanel:()=>s.getSideBarService().getActivePanel(),setStatusBarVisible:n=>s.getSideBarService()&&s.getOptions(),getSideBar:()=>s.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.isLastPageFound())??!0},paginationGetPageSize:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getPageSize())??0},paginationGetCurrentPage:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getCurrentPage())??0},paginationGetTotalPages:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getTotalPages())??1},paginationGetRowCount:()=>s.getDisplayedRowCount(),paginationGoToPage:n=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToPage(n)},paginationGoToNextPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToNextPage()},paginationGoToPreviousPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToPreviousPage()},paginationGoToFirstPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToFirstPage()},paginationGoToLastPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToLastPage()},paginationSetPageSize:n=>{var i;return(i=s.getPaginationService())==null?void 0:i.setPageSize(n)},startEditingCell:n=>s.getEditService().startEditingCell(n),stopEditing:n=>s.getEditService().stopEditing(n),getEditingCells:()=>s.getEditService().getEditingCells(),setFocusedCell:(n,i)=>{const o=typeof i=="string"?s.getColumn(i):i;o&&s.getEditService().setFocusedCell(n,o)},getFocusedCell:()=>{const n=s.getEditService().getFocusedCell();return n?{rowIndex:n.rowIndex,column:n.column,rowNode:n.rowNode}:null},clearFocusedCell:()=>s.getEditService().clearFocusedCell(),tabToNextCell:()=>s.getEditService().tabToNextCell(),tabToPreviousCell:()=>s.getEditService().tabToPreviousCell(),refreshCells:n=>s.getRowRenderer().refreshCells(n),redrawRows:n=>s.getRowRenderer().redrawRows(n),flashCells:n=>s.getRowRenderer().flashCells(n||{}),ensureIndexVisible:(n,i)=>s.getRowRenderer().ensureIndexVisible(n,i),ensureNodeVisible:n=>{let i=-1;s.getRowModel().forEachNode((o,a)=>{o.id===n.id&&(i=a)}),i>=0&&s.getRowRenderer().ensureIndexVisible(i)},ensureColumnVisible:n=>{const i=typeof n=="string"?s.getColumn(n):n;i&&s.getRowRenderer().ensureColumnVisible(i)},copyToClipboard:n=>s.getExportService().copyToClipboard(n),cutToClipboard:n=>s.getExportService().cutToClipboard(n),pasteFromClipboard:()=>s.getExportService().pasteFromClipboard(),exportToCsv:n=>s.getExportService().exportToCsv(n||{}),exportToExcel:n=>s.getExportService().exportToExcel(n||{}),exportToPdf:n=>s.getExportService().exportToPdf(n||{}),importExcel:(n,i)=>s.getExportService().importExcel(n,i||{}),getDataAsPdf:n=>s.getExportService().getDataAsPdf(n||{}),getDataAsCsv:n=>s.getExportService().getDataAsCsv(n||{}),getDataAsExcel:n=>s.getExportService().getDataAsExcel(n||{}),getChartData:n=>s.getChartService().getChartData(n||{}),getChartModels:()=>s.getChartService().getChartModels(),createChart:()=>s.getChartService().createChart(),getCellRanges:()=>s.getRangeSelectionService().getRanges(),clearRangeSelection:()=>s.getRangeSelectionService().clearRanges(),addCellRange:n=>{const i=s.getRangeSelectionService();i.ranges=[n],i.applyHighlight(),i.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>s.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>s.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>s.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>s.getOverlayService().hideOverlay(),setServerSideDatasource:n=>{const i=s.getServerSideRowModel();i&&i.setDatasource(n)},setDatasource:n=>{var o;const i=s.getInfiniteRowModel();i?i.setDatasource(n):(o=s.getServerSideRowModel())==null||o.setDatasource(n)},setViewportDatasource:n=>{var i;(i=s.getViewportRowModel())==null||i.setViewportDatasource(n)},setViewportRange:(n,i)=>{var o;(o=s.getViewportRowModel())==null||o.setViewportRange(n,i)},refreshServerSide:n=>{const i=s.getServerSideRowModel();i&&(n!=null&&n.purge?i.purgeCache():i.onSortOrFilterChanged())},purgeServerSideCache:()=>{var n,i;(n=s.getServerSideRowModel())==null||n.purgeCache(),(i=s.getInfiniteRowModel())==null||i.onSortOrFilterChanged()},getServerSideStoreState:()=>{const n=s.getServerSideRowModel();if(!n)return[];const i=[];for(const[o,a]of n.stores)i.push({groupPath:o,rowCount:a.rows.length,lastRow:a.lastRow,loading:a.loading});return i},setRowCount:(n,i)=>{const o=s.getServerSideRowModel();if(!o)return;const a=o.getStore("");if(a)for(a.lastRow=i?n:null;a.rows.length<n;)a.rows.push(null);o.refreshModel("everything")},isServerSideStoreLoading:()=>s.isRemoteLoading(),undoCellEditing:()=>s.getUndoRedoService().undo(),redoCellEditing:()=>s.getUndoRedoService().redo(),canUndo:()=>s.getUndoRedoService().canUndo(),canRedo:()=>s.getUndoRedoService().canRedo(),getUndoRedoStackSize:()=>({undo:s.getUndoRedoService().getUndoStackSize(),redo:s.getUndoRedoService().getRedoStackSize()}),startBatchEdit:()=>s.getUndoRedoService().startBatchEdit(),endBatchEdit:n=>s.getUndoRedoService().endBatchEdit(n),cancelBatchEdit:()=>s.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>s.getUndoRedoService().isBatchEditing(),getState:()=>{const n=s.getColumnApi(),i=s.getSelectionService(),o=s.getPaginationService();return{columns:n.getColumnState(),sort:s.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(s.getFilterService().getFilterModel())),quickFilter:s.getQuickFilter(),selectedRowIds:i.getSelectedNodes().map(a=>a.id),pagination:o!=null&&o.isEnabled()?{page:o.getCurrentPage(),pageSize:o.getPageSize()}:null,rowGroupColumns:s.getColumnModel().getRowGroupColumns().map(a=>a.colId),pivotMode:s.getColumnModel().isPivotMode()}},setState:n=>{if(!n)return;const i=s.getColumnApi();if(n.columns&&i.applyColumnState(n.columns,!0),n.sort&&s.getSortService().setSortModel(n.sort),n.filter&&s.getFilterService().setFilterModel(n.filter),n.quickFilter!==void 0&&s.setQuickFilter(n.quickFilter),n.rowGroupColumns&&s.getColumnModel().setRowGroupColumns(n.rowGroupColumns),n.pivotMode!==void 0&&s.getColumnModel().setPivotMode(n.pivotMode),n.selectedRowIds){s.getSelectionService().deselectAll();for(const a of n.selectedRowIds){const l=s.getRowNode(a);l&&s.getSelectionService().selectNode(l,!1)}}const o=s.getPaginationService();o&&n.pagination&&(o.setPageSize(n.pagination.pageSize),o.goToPage(n.pagination.page))},setNote:(n,i,o)=>{const a=typeof i=="string"?i:i.colId;s.getNotesService().setNote(n.id,a,o)},getNote:(n,i)=>{const o=typeof i=="string"?i:i.colId,a=s.getColumn(o);return s.getNotesService().getNote(n.id,o,a==null?void 0:a.colDef.note,{data:n.data,node:n,column:a,api:s.getApi()})},getGridId:()=>"rowvia",destroy:()=>s.destroy(),refreshClientSideRowModel:()=>s.refreshModel("everything"),setPivotMode:n=>s.getColumnModel().setPivotMode(n),isPivotMode:()=>s.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>s.getAllColumns(),getColumn:n=>s.getColumn(n)??null,getColumnState:()=>s.getColumnModel().getColumnState(),applyColumnState:(n,i)=>{s.getColumnModel().applyColumnState(n,i),s.refreshModel("group")},resetColumnState:()=>{s.getColumnModel().resetColumnState(),s.refreshModel("group")},setColumnVisible:(n,i)=>s.getColumnModel().setColumnVisible(n,i),setColumnsVisible:(n,i)=>s.getColumnModel().setColumnsVisible(n,i),setColumnPinned:(n,i)=>s.getColumnModel().setColumnPinned(n,i),setColumnsPinned:(n,i)=>s.getColumnModel().setColumnsPinned(n,i),moveColumn:(n,i)=>s.getColumnModel().moveColumn(n,i),moveColumnByIndex:(n,i)=>s.getColumnModel().moveColumnByIndex(n,i),autoSizeColumn:n=>{s.getColumnModel().autoSizeColumn(n),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:n=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(n,i)=>s.getColumnModel().setRowGroupColumns(n,i),removeRowGroupColumns:n=>{for(const i of n)s.getColumnModel().removeRowGroupColumn(i)},addRowGroupColumn:n=>s.getColumnModel().addRowGroupColumn(n),setPivotColumns:n=>s.getColumnModel().setPivotColumns(n),removePivotColumns:n=>s.getColumnModel().setPivotColumns(n.map(()=>"").filter(i=>i!=="")),setValueColumns:n=>s.getColumnModel().setValueColumns(n),removeValueColumn:n=>s.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),getValueColumns:()=>s.getColumnModel().getValueColumns(),getPivotColumns:()=>s.getColumnModel().getPivotColumns(),setPivotMode:(n,i)=>s.getColumnModel().setPivotMode(n,i),isPivotMode:()=>s.getColumnModel().isPivotMode()}}}class Qe{constructor(e,t,n){y(this,"id");y(this,"__id");y(this,"data");y(this,"parent",null);y(this,"children",null);y(this,"group",!1);y(this,"key",null);y(this,"level",0);y(this,"uiLevel",0);y(this,"rowGroupIndex");y(this,"expanded",!1);y(this,"selectable",!0);y(this,"selected",!1);y(this,"rowPinned",null);y(this,"detailNode",null);y(this,"masterNode",null);y(this,"footer",!1);y(this,"groupData",null);y(this,"rowHeight",null);y(this,"allChildrenCount",null);y(this,"stub",!1);y(this,"rowIndex",null);y(this,"__displayIndex");y(this,"services");y(this,"__passesFilter",!0);y(this,"__childCount",0);y(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=Xt("row"),this.id=n??this.__id}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,t=!1,n="api"){return e?this.services.selectNode(this,t):this.services.deselectNode(this),0}isSelected(){return this.selected}setData(e){this.data=e}setDataValue(e,t){const n=typeof e=="string"?e:e.field;if(n&&this.data){const i=n.split(".");let o=this.data;for(;i.length>1;){const a=i.shift();o[a]===void 0&&(o[a]={}),o=o[a]}o[i[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class Ls{constructor(e){y(this,"options");y(this,"eventService");y(this,"columns");y(this,"getFilterModel");y(this,"getQuickFilter");y(this,"isPaginationEnabled");y(this,"getPageSize");y(this,"getCurrentPage");y(this,"rowHeightProvider");y(this,"rowNodeServices");y(this,"rowData",[]);y(this,"rootRowNodes",[]);y(this,"dataRows",[]);y(this,"rowsToDisplay",[]);y(this,"rowNodeMap",new Map);y(this,"expandedGroups",new Set);y(this,"groupDefaultExpandedApplied",!1);y(this,"pinnedTopRows",[]);y(this,"pinnedBottomRows",[]);y(this,"totalRowCount",0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getFilterModel=e.getFilterModel,this.getQuickFilter=e.getQuickFilter,this.isPaginationEnabled=e.isPaginationEnabled,this.getPageSize=e.getPageSize,this.getCurrentPage=e.getCurrentPage,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices}getType(){return"clientSide"}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.rootRowNodes}getRowCount(){return this.rowsToDisplay.length}getTotalRowCount(){return this.totalRowCount}getRow(e){return this.rowsToDisplay[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.rowsToDisplay.forEach((t,n)=>e(t,n))}forEachLeafNode(e){let t=0;const n=i=>{for(const o of i)o.group?o.children&&n(o.children):o.footer||e(o,t++)};n(this.rootRowNodes)}getPinnedTopRowCount(){return this.pinnedTopRows.length}getPinnedBottomRowCount(){return this.pinnedBottomRows.length}getPinnedTopRow(e){return this.pinnedTopRows[e]}getPinnedBottomRow(e){return this.pinnedBottomRows[e]}getRowIndexAtPixel(e){return Math.floor(e/this.rowHeightProvider())}updateRowData(e){this.rowData=e||[],this.rebuildRows()}rebuildRows(){const e=new Map;this.options.treeData&&this.rowNodeMap.forEach(i=>{i.group&&e.set(i.id,i.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,n=this.rowData;if(this.options.treeData){const i=this.buildTreeData(n,t);this.rootRowNodes=i,this.rowNodeMap.forEach(o=>{o.group&&e.has(o.id)&&(o.expanded=e.get(o.id))})}else{const i=[];for(let o=0;o<n.length;o++){const a=n[o],l=t?t({data:a,level:0}):void 0,r=this.createRowNode(a,l);r.rowIndex=o,i.push(r)}this.rootRowNodes=i,this.dataRows=i}if(this.options.masterDetail&&!this.options.treeData){const i=this.options.isRowMaster||(()=>!0);for(const o of this.rootRowNodes){if(o.detailNode||!i({data:o.data,node:o}))continue;const a=this.createRowNode(null,`${o.id}|detail`,o,1);a.masterNode=o,a.selectable=!1,o.detailNode=a,o.expanded=!1}}this.refreshModel(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.gridApi})}createRowNode(e,t,n=null,i=0){const o=new Qe(e,this.rowNodeServices,t);return o.parent=n,o.level=i,o.uiLevel=i,o.__id=o.id,this.rowNodeMap.set(o.id,o),o}buildTreeData(e,t){const n=this.options.getDataPath||(d=>String(d.id??d.key).split("/")),i=this.options.treeDataChildrenField||"children",o=new Map,a=[],l=(d,c,p)=>{const h=n(d),u=h.join("/"),f=t?t({data:d,level:p}):u,g=this.createRowNode(d,f,c,p);g.key=h[h.length-1],o.set(u,g);const v=d[i];if(Array.isArray(v)&&v.length){g.children=[],g.group=!0,g.expanded=!0;for(const m of v){const w=l(m,g,p+1);g.children.push(w)}g.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(g),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||a.push(g),g},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const p of d.children)c+=r(p);return d.allChildrenCount=c,c};for(const d of a)r(d);for(const d of e){if(!d)continue;const p=n(d).slice(0,-1).join("/"),h=p&&o.get(p)||null;l(d,h??null,h?h.level+1:0)}return a}applyTransaction(e){const t=this.options.getRowId,n={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const i=new Set;for(const o of e.remove){const a=t?t({data:o,level:0}):o.id;a!==void 0?i.add(String(a)):i.add(o)}this.rowData=this.rowData.filter(o=>{const a=t?t({data:o,level:0}):o.id;return!i.has(String(a))&&!i.has(o)});for(const o of i){const a=this.rowNodeMap.get(String(o));a&&(this.rowNodeMap.delete(a.id),n.remove.push(a))}}if(e.update&&e.update.length)for(const i of e.update){const o=t?t({data:i,level:0}):i.id,a=o!==void 0?this.rowNodeMap.get(String(o)):void 0;if(a)this.rowData=this.rowData.map(l=>{const r=t?t({data:l,level:0}):l.id;return String(r)===String(o)?i:l}),a.data=i,n.update.push(a);else{const l=this.createRowNode(i,o!==void 0?String(o):void 0);this.rowData.push(i),n.add.push(l)}}if(e.add&&e.add.length){const i=e.addIndex;for(const o of e.add){const a=t?t({data:o,level:0}):void 0,l=this.createRowNode(o,a);n.add.push(l),i===void 0||i<0?this.rowData.push(o):this.rowData.splice(Math.min(i,this.rowData.length),0,o)}}return this.rebuildRows(),n}refreshModel(e){const t=this.columns().filter(n=>n.rowGroup);(!e||e==="everything"||e==="filter"||e==="group")&&this.doFilter(),(!e||e==="everything"||e==="sort"||e==="group")&&this.doSort(t),(!e||e==="everything"||e==="group")&&this.doGroup(t),this.buildDisplayRows(t),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}doFilter(){const e=this.getFilterModel(),t=this.getQuickFilter(),n=Object.keys(e).length>0,i=t&&t.trim().length>0,o=this.columns(),a=!!this.options.treeData,l=f=>{for(const[g,v]of Object.entries(e)){const m=o.find(w=>w.colId===g);if(m&&!this.doesNodePassFilter(f,m,v))return!1}return!0},r=f=>{const g=this.options.__advancedFilterPass;return g?g(f):!0},d=Object.entries(e).some(([f,g])=>{const v=o.find(m=>m.colId===f);return!v||!v.aggFunc?!1:g.filterType==="multi"?(g.filterModels||[]).length>0:!0}),c=f=>{if(f.__passesFilter=!0,f.children)for(const g of f.children)c(g)},p=f=>{const g=this.options;return typeof g.isExternalFilterPresent!="function"||!g.isExternalFilterPresent()||typeof g.doesExternalFilterPass!="function"?!0:g.doesExternalFilterPass(f)},h=f=>{if(!i)return!0;const g=t.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of v){const w=Ce(m,f,null);if(bs(g,w))return!0}return!1},u=f=>{let g=!0;if(!f.group||f.footer||a?g=(!n||l(f))&&h(f)&&p(f)&&r(f):d&&(g=(!n||l(f))&&r(f)),f.__passesFilter=g,f.children){let v=!1;for(const m of f.children)u(m)&&(v=!0);return f.group&&!f.footer&&(d?(f.__passesFilter=g,g&&c(f)):(f.__passesFilter=a?v||g:v,a&&g&&c(f))),f.__passesFilter}return g};for(const f of this.rootRowNodes)u(f)}doesNodePassFilterModel(e,t,n){return this.doesNodePassFilter(e,t,n)}doesNodePassFilter(e,t,n){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const c=[];Bt(e,c);const p=c.map(h=>Ce(t,h,null));r=kt(t,t.aggFunc,p)}const d={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,t,n)}if(n.filterType==="multi"){const r=n.filterModels||[];if(r.length===0)return!0;const d=n.operator||"AND",c=r.map(p=>this.doesNodePassFilter(e,t,p));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(n.condition1||n.condition2){const{condition1:r,condition2:d,...c}=n,p=[this.doesNodePassFilter(e,t,{...c,...r||{}})];return d&&p.push(this.doesNodePassFilter(e,t,{...c,...d})),(n.operator||"AND")==="OR"?p.some(Boolean):p.every(Boolean)}const i=Ce(t,e,null),o=Ns(t,i),a=i,l=n.filterType||"text";if(l==="text"){const r=String(n.filter??"").toLowerCase();if(!r)return!0;const d=(a==null?"":String(a)).toLowerCase();switch(n.type){case"equals":return d===r;case"notEqual":return d!==r;case"startsWith":return d.startsWith(r);case"endsWith":return d.endsWith(r);case"contains":default:return d.includes(r)}}if(l==="number"){const r=typeof a=="number"?a:Number(a);if(isNaN(r))return!1;const d=Number(n.filter),c=n.filterTo!==void 0&&n.filterTo!==null&&n.filterTo!==""?Number(n.filterTo):null;switch(n.type){case"equals":return r===d;case"notEqual":return r!==d;case"lessThan":return r<d;case"lessThanOrEqual":return r<=d;case"greaterThan":return r>d;case"greaterThanOrEqual":return r>=d;case"inRange":return c!==null?r>=Math.min(d,c)&&r<=Math.max(d,c):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(l==="date"){const r=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(r))return!1;const d=n.dateFrom?new Date(n.dateFrom).getTime():null,c=n.dateTo?new Date(n.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return l==="boolean"?!!a==!!n.filter:l==="set"?(n.values||[]).map(d=>String(d)).includes(String(a)):!0}doSort(e){const t=[],n=this.columns();for(const a of n)a.sort&&a.sortIndex!==null&&t.push({column:a,direction:a.sort});t.sort((a,l)=>(a.column.sortIndex??0)-(l.column.sortIndex??0));const i=(a,l)=>{for(const{column:c,direction:p}of t){const h=Gn(c)(a,l)*(p==="asc"?1:-1);if(h!==0)return h}const r=a.rowIndex??0,d=l.rowIndex??0;return r-d},o=a=>{a.sort(i);for(const l of a)l.children&&o(l.children)};if(e.length===0)o(this.rootRowNodes);else for(const a of this.rootRowNodes)a.children&&o(a.children)}doGroup(e){if(e.length===0)return;const t=this.columns().filter(d=>d.aggFunc&&!d.rowGroup),n=(d,c,p,h)=>{if(c>=e.length)return d;const u=e[c],f=new Map,g=[];for(const m of d){if(!m.__passesFilter)continue;const w=Ce(u,m,null),k=Ts(w);f.has(k)||(f.set(k,[]),g.push(k)),f.get(k).push(m)}const v=[];for(const m of g){const w=f.get(m),k=`${h}|${u.colId}:${m}`,C=this.rowNodeMap.get(k),b=C||new Qe({[u.colId]:m},this.rowNodeServices,k);b.group=!0,b.key=m,b.level=p,b.uiLevel=p,b.parent=null,b.children=n(w,c+1,p+1,k);for(const E of b.children)E.parent=b;b.allChildrenCount=qn(b),b.data={...b.data};const N=[];Bt(b,N);const I={};for(const E of t){const G=N.map(x=>Ce(E,x,null));I[E.colId]=kt(E,E.aggFunc,G)}I[u.colId]=m,b.groupData=I,C||this.rowNodeMap.set(k,b),v.push(b)}return v},i=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=n(o,0,0,""),l=d=>{for(const c of d){if(!c.group)continue;const p=Ot(c),h=this.expandedGroups.has(p);i===-1||h?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<i,c.expanded&&this.expandedGroups.add(p),c.children&&l(c.children)}};l(a),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const p=e[c],h=p.sort==="desc"?-1:1,u=Gn(p);d.sort((f,g)=>{const v=Ce(p,f,null),m=Ce(p,g,null);return u({...f,data:{[p.colId]:v}},{...g,data:{[p.colId]:m}})*h})};e[0].sort&&r(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],n=!!this.options.treeData,i=(a,l)=>{if(a.uiLevel=l,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||n)){const r=a.group?a.children.filter(d=>d.__passesFilter||d.group):a.children;if(a.expanded){for(const d of r)i(d,l+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const d=this.createFooterNode(a,l+1);t.push(d)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&i(a,0);if(this.options.groupIncludeTotalFooter&&e.length>0){const a=this.createGrandTotalNode(e);t.push(a)}this.pinnedTopRows=t.filter(a=>a.rowPinned==="top"),this.pinnedBottomRows=t.filter(a=>a.rowPinned==="bottom");const o=t.filter(a=>a.rowPinned!=="top"&&a.rowPinned!=="bottom");if(this.totalRowCount=o.filter(a=>!a.masterNode).length,this.isPaginationEnabled()){const a=this.getPageSize(),l=this.getCurrentPage();let r=0,d=-1;for(let p=0;p<o.length;p++)if(!o[p].masterNode){if(r===l*a){d=p;break}r++}d<0&&(d=o.length);let c=d;for(r=0;c<o.length&&r<a;)o[c].masterNode||r++,c++;for(;c<o.length&&o[c].masterNode;)c++;this.rowsToDisplay=o.slice(d,c)}else this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,l)=>a.__displayIndex=l)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const n=`${e.id}|footer`;let i=this.rowNodeMap.get(n);return i||(i=new Qe(e.data,this.rowNodeServices,n),this.rowNodeMap.set(n,i)),i.group=!1,i.footer=!0,i.level=e.level,i.uiLevel=t,i.parent=e,i.selected=!1,i.selectable=!1,i.groupData={...e.groupData,__footerFor:e.id},i}createGrandTotalNode(e){const t="ag-grid-grand-total";let n=this.rowNodeMap.get(t);n||(n=new Qe(null,this.rowNodeServices,t),this.rowNodeMap.set(t,n)),n.group=!1,n.footer=!0,n.level=0,n.uiLevel=0,n.selected=!1,n.selectable=!1;const i=this.columns().filter(l=>l.aggFunc&&!l.rowGroup),o=[];for(const l of this.rootRowNodes)l.group?Bt(l,o):l.__passesFilter&&o.push(l);const a={};for(const l of i){const r=o.map(d=>Ce(l,d,null));a[l.colId]=kt(l,l.aggFunc,r)}return a.__grandTotal=!0,n.groupData=a,n}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Ot(t)),t.children&&t.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}collapseAll(){this.expandedGroups.clear();const e=t=>{t.group&&(t.expanded=!1,t.children&&t.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}setNodeExpanded(e,t){e.group&&(e.expanded=t,t?this.expandedGroups.add(Ot(e)):this.expandedGroups.delete(Ot(e)),this.buildDisplayRows(this.columns().filter(n=>n.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function Ts(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Ot(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function qn(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+qn(t),0)}function Bt(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Bt(t,e)}function Ns(s,e){return e}const Is={textColumn:{filter:"text",editable:!0},numberColumn:{filter:"number",editable:!0,headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},dateColumn:{filter:"date",editable:!0},dateStringColumn:{filter:"date"},booleanColumn:{filter:"boolean",cellRenderer:"agCheckboxCellRenderer"},rightAligned:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},numericColumn:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"}};function As(s){if(s===void 0||s===!0)return"text";if(s===!1)return!1;switch(s){case"agTextColumnFilter":return"text";case"agNumberColumnFilter":return"number";case"agDateColumnFilter":case"agDateColumnFilterString":return"date";case"agSetColumnFilter":return"set";default:return s}}function $s(s){return!!s.treeData}function Fs(){return{applyAggregate:kt}}class zn{constructor(e,t,n){y(this,"options");y(this,"eventService");y(this,"gridApi");y(this,"measureCtx",null);y(this,"gridColumnDefs",[]);y(this,"columns",[]);y(this,"displayOrder",[]);y(this,"autoGroupColumnDef");y(this,"pivotMode",!1);y(this,"columnGroups",[]);y(this,"openGroups",new Set);y(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=n,this.autoGroupColumnDef={headerName:"",minWidth:200,width:250,sortable:!1,filter:!1,resizable:!0,suppressMovable:!0,cellRenderer:"agGroupCellRenderer",...e.autoGroupColumnDef||{}}}setGridApi(e){this.gridApi=e}getAutoGroupColumnDef(){return this.autoGroupColumnDef}getOptions(){return this.options}setPivotMode(e,t="api"){this.pivotMode!==e&&(this.pivotMode=e,this.eventService.dispatchEvent("columnPivotModeChanged",{api:this.gridApi,source:t}),this.refreshAll())}isPivotMode(){return this.pivotMode}setColumnDefs(e){this.gridColumnDefs=e||[],this.buildColumns()}static generateColumnDefs(e,t=_n){if(!e||e.length===0)return[];const n=e[0];if(!n||typeof n!="object")return[];const i=new Set(["children","detail","__proto__"]),o=[];for(const a of Object.keys(n)){if(i.has(a)||a.startsWith("__"))continue;const l=n[a],r={field:a,headerName:t(a)};typeof l=="number"?(r.type="numberColumn",r.filter="number"):typeof l=="boolean"?r.type="booleanColumn":l instanceof Date&&(r.type="dateColumn"),o.push(r)}return o}getColumnGroups(){return this.columnGroups}getGroupDepth(){return this.columnGroups.reduce((e,t)=>Math.max(e,t.depth),0)}isGroupOpen(e){return this.openGroups.has(e)}setGroupOpen(e,t){t?this.openGroups.add(e):this.openGroups.delete(e),this.updateVisible(),this.refreshAll()}getColumnDefs(){return this.gridColumnDefs}buildColumns(){const e=this.columns,t=new Map;for(const c of e)t.set(c.colId,c);const n=this.options.defaultColDef||{},i={...Is,...this.options.columnTypes||{}},o=[],a=[];let l=0;const r=(c,p)=>{const h=c.colId||c.field||Xt("col"),u={...n,...c};if(u.type&&i[u.type]){const f=i[u.type],g=new Set(Object.keys(c));for(const[v,m]of Object.entries(f))!g.has(v)&&!(v in n)&&(u[v]=m)}this.pushColumnInto(o,u,h,l++,t,p)},d=(c,p,h)=>{for(const u of c)if(u.children&&u.children.length){const f=u.groupId||Xt("group"),g={id:f,headerName:u.headerName??"",openByDefault:u.openByDefault===!0||u.columnGroupShow==="open",parentId:p,depth:h,childColumnIds:[]};a.push(g),this.groupsInitialised||(g.openByDefault?this.openGroups.add(f):this.openGroups.delete(f)),d(u.children,f,h+1)}else r(u,p)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,this.options.rowNumbers){const c={colId:"__rowNumber",headerName:"",width:60,pinned:"left",sortable:!1,filter:!1,resizable:!1,suppressMovable:!0,cellRenderer:"agRowNumberCellRenderer",cellClass:"ag-row-number-cell"};this.pushColumnInto(o,{...n,...c},"__rowNumber",-1,t,null)}for(const c of o){if(!c.groupId)continue;const p=a.find(h=>h.id===c.groupId);p&&p.childColumnIds.push(c.colId)}this.columns=o,this.displayOrder=o.map(c=>c.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,n,i,o){return this.buildColumn(e,t,n,i,o)}pushColumnInto(e,t,n,i,o,a){e.push(this.buildColumn(t,n,i,o,a))}buildColumn(e,t,n,i,o){const a=i.get(t),l=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?_n(e.field):""),headerTooltip:e.headerTooltip,colDef:e,width:e.width??e.minWidth??(e.flex?200:100),minWidth:e.minWidth??20,maxWidth:e.maxWidth??Number.MAX_SAFE_INTEGER,flex:e.flex??null,pinned:e.pinned??null,hide:l,visible:!l,lockPosition:e.lockPosition??!1,type:e.type,sortable:e.sortable??!!e.field,sort:e.sort??null,sortIndex:e.sortIndex??null,resizable:e.resizable??!0,filter:As(e.filter),floatingFilter:e.floatingFilter??!1,filterParams:e.filterParams||{},editable:e.editable??!1,cellEditor:e.cellEditor,cellEditorParams:e.cellEditorParams||{},singleClickEdit:e.singleClickEdit??this.options.singleClickEdit??!1,valueSetter:e.valueSetter,valueGetter:e.valueGetter,valueFormatter:e.valueFormatter,valueParser:e.valueParser,comparator:e.comparator,aggFunc:e.aggFunc,allowedAggFuncs:e.allowedAggFuncs??["sum","min","max","count","avg"],rowGroup:e.rowGroup??!1,rowGroupIndex:e.rowGroupIndex??null,pivot:e.pivot??!1,pivotIndex:e.pivotIndex??null,enableRowGroup:e.enableRowGroup??!0,enablePivot:e.enablePivot??!0,enableValue:e.enableValue??!0,cellRenderer:e.cellRenderer,cellRendererParams:e.cellRendererParams,cellClass:e.cellClass,cellStyle:e.cellStyle,cellDataType:e.cellDataType===!0,cellClassRules:e.cellClassRules,rowDrag:e.rowDrag===!0,headerClass:e.headerClass,checkboxSelection:e.checkboxSelection??!1,headerCheckboxSelection:e.headerCheckboxSelection??!1,headerCheckboxSelectionFilteredOnly:e.headerCheckboxSelectionFilteredOnly??!1,headerCheckboxSelectionCurrentPageOnly:e.headerCheckboxSelectionCurrentPageOnly??!1,menuTabs:e.menuTabs??["filterMenuTab","generalMenuTab","columnsMenuTab"],suppressMenu:e.suppressMenu??this.options.suppressMenu??!1,suppressMovable:e.suppressMovable??this.options.suppressMovableColumns??!1,wrapText:e.wrapText??!1,autoHeight:e.autoHeight??!1,tooltipField:e.tooltipField,tooltipValueGetter:e.tooltipValueGetter,decimals:e.decimals??0,defIndex:n,filterActive:!1,left:0,groupId:o};return a&&(r.pinned=a.pinned,r.visible=a.visible,r.width=a.width,r.flex=a.flex,r.sort=a.sort,r.sortIndex=a.sortIndex,r.rowGroup=a.rowGroup,r.rowGroupIndex=a.rowGroupIndex,r.pivot=a.pivot,r.pivotIndex=a.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const n=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),i=[];for(const r of t){const d=[],c=new Set;for(const p of e){const h=p==null?void 0:p[r.field],u=String(h);c.has(u)||(c.add(u),d.push(h))}d.sort((p,h)=>p===h?0:String(p)<String(h)?-1:1);for(const p of n){for(const f of d){const g=`__pivot_${r.colId}_${p.colId}_${f}`,v=this.createColumn({colId:g,headerName:`${String(f)}`,width:130,type:p.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:p.cellClass,cellDataType:p.cellDataType},g,-1,new Map,null);v.aggFunc=p.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:f,valueColumnId:p.colId,valueField:p.field},v.valueGetter=m=>this.evaluatePivotValue(v,m.node),i.push(v)}const h=`__pivot_${r.colId}_${p.colId}_total`,u=this.createColumn({colId:h,headerName:"Total",width:130,type:p.type,sortable:!1,filter:!1,cellDataType:p.cellDataType},h,-1,new Map,null);u.aggFunc=p.aggFunc,u.groupId=r.colId,u.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:p.colId,valueField:p.field},u.valueGetter=f=>this.evaluatePivotValue(u,f.node),i.push(u)}}const o=new Set(t.map(r=>r.colId)),a=this.columns.reduce((r,d,c)=>o.has(d.groupId??"")?r:c,0);this.columns.splice(a+1,0,...i);for(const r of i)this.displayOrder.push(r.colId);const l=new Set(this.columnGroups.map(r=>r.id));for(const r of t)l.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const n=e.__pivot;if(!n||!t)return;const i=[],o=c=>{if(!c.children||c.children.length===0){i.push(c);return}for(const p of c.children)o(p)};o(t);const l=(n.pivotValue===void 0?i:i.filter(c=>{var p;return String((p=c.data)==null?void 0:p[n.pivotField])===String(n.pivotValue)})).map(c=>{var p;return(p=c.data)==null?void 0:p[n.valueField]}).filter(c=>typeof c=="number");if(l.length===0)return null;const r=this.columns.find(c=>c.colId===n.valueColumnId),{applyAggregate:d}=Fs();return d(r,e.aggFunc,l)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,n=this.getRowGroupColumns(),i=this.options.groupDisplayType||"singleColumn",o=t||n.length>0&&i!=="multipleColumns";for(const c of n)i==="multipleColumns"?(c.cellRenderer="agGroupCellRenderer",c.cellRendererParams={...c.cellRendererParams||{},suppressCount:!0}):c.cellRenderer==="agGroupCellRenderer"&&!c.colDef.cellRenderer&&(c.cellRenderer=void 0,c.cellRendererParams=void 0);const a=this.columns.find(c=>c.colId===e);if(!o){a&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const l={...this.autoGroupColumnDef};if(l.colId=e,a)a.headerName=l.headerName??"",a.colDef=l,a.cellRenderer=l.cellRenderer,a.cellRendererParams=l.cellRendererParams,a.width=l.width??a.width,a.minWidth=l.minWidth??a.minWidth,a.pinned=l.pinned??"left";else{const c=this.createColumn(l,e,-2,new Map,null);this.columns.unshift(c),this.displayOrder.unshift(e)}const r=this.columns.find(c=>c.colId===e),d=()=>this.getRowGroupColumns()[0];r.valueGetter=c=>{const p=c.node;if(!p)return"";if(p.key!==null&&p.key!==void 0)return p.key;if($s(this.options))return"";const h=d();return h!=null&&h.field&&p.data?p.data[h.field]??"":""}}updateVisible(){for(const e of this.columns)e.visible=!e.hide&&this.isGroupChainOpen(e.groupId)}isGroupChainOpen(e){let t=e;for(;t;){if(!this.openGroups.has(t))return!1;const n=this.columnGroups.find(i=>i.id===t);t=(n==null?void 0:n.parentId)??null}return!0}refreshAll(){this.eventService.dispatchEvent("columnEverythingChanged",{api:this.gridApi,source:"gridOptionsChanged"}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi})}getAllColumns(){return this.columns.slice()}getColumn(e){const t=typeof e=="string"?e:e.colId;return this.columns.find(n=>n.colId===t)}getColumns(){return this.displayOrder.map(e=>this.getColumn(e)).filter(Boolean)}getDisplayedColumns(){return this.getColumns().filter(e=>e.visible)}getDisplayedLeftColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="left")}getDisplayedCenterColumns(){return this.getDisplayedColumns().filter(e=>e.pinned!=="left"&&e.pinned!=="right")}getDisplayedRightColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="right")}getDisplayedColumnsByType(){return{left:this.getDisplayedLeftColumns(),center:this.getDisplayedCenterColumns(),right:this.getDisplayedRightColumns()}}getRowGroupColumns(){return this.getColumns().filter(e=>e.rowGroup).sort((e,t)=>(e.rowGroupIndex??0)-(t.rowGroupIndex??0))}getPivotColumns(){return this.getColumns().filter(e=>e.pivot).sort((e,t)=>(e.pivotIndex??0)-(t.pivotIndex??0))}getValueColumns(){return this.pivotMode?this.getColumns().filter(e=>e.aggFunc&&!e.rowGroup&&!e.pivot):this.getColumns().filter(e=>!!e.aggFunc)}isRowGroupActive(){return this.getRowGroupColumns().length>0}setRowGroupColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())n.includes(i)||(i.rowGroup=!1,i.rowGroupIndex=null);n.forEach((i,o)=>{i.rowGroup=!0,i.rowGroupIndex=o,i.pivot=!1,i.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:n}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,t="api"){const n=this.getColumn(e);if(!n)return;const i=this.getRowGroupColumns();n.rowGroup=!0,n.rowGroupIndex=i.length,n.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[n]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,t="api"){const n=this.getColumn(e);if(!n)return;n.rowGroup=!1,n.rowGroupIndex=null,this.getRowGroupColumns().forEach((o,a)=>o.rowGroupIndex=a),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[n]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())n.includes(i)?i.aggFunc||(i.aggFunc="sum"):i.aggFunc&&!i.rowGroup&&(i.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:n}),this.refreshAll()}addValueColumn(e,t="sum",n="api"){const i=this.getColumn(e);i&&(i.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:n,columns:[i]}),this.refreshAll())}setPivotColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())i.pivot=n.includes(i),i.pivotIndex=n.includes(i)?n.indexOf(i):null;this.refreshAll()}setColumnVisible(e,t,n="api"){const i=this.getColumn(e);!i||i.visible===t||(i.hide=!t,i.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:i,visible:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll())}setColumnsVisible(e,t,n="api"){for(const i of e)this.setColumnVisible(i,t,n)}setColumnPinned(e,t,n="api"){const i=this.getColumn(e);i&&(i.lockPosition&&t!==i.pinned||(i.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:i,pinned:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll()))}setColumnsPinned(e,t,n="api"){for(const i of e)this.setColumnPinned(i,t,n)}moveColumn(e,t,n="api"){const i=this.getColumn(e);i&&this.moveColumnByIndex(this.displayOrder.indexOf(i.colId),t,n)}moveColumnByIndex(e,t,n="api"){const i=this.displayOrder.slice();if(e<0||e>=i.length)return;const[o]=i.splice(e,1);i.splice(Math.max(0,Math.min(i.length,t)),0,o),this.displayOrder=i;const a=this.getColumn(o);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:a,toIndex:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll()}getColumnState(){return this.getColumns().map(e=>({colId:e.colId,hide:e.hide,pinned:e.pinned,width:e.width,flex:e.flex??void 0,sort:e.sort,sortIndex:e.sortIndex,rowGroupIndex:e.rowGroupIndex,pivotIndex:e.pivotIndex,aggFunc:e.aggFunc}))}applyColumnState(e,t=!1){for(const n of e){const i=this.getColumn(n.colId);i&&(n.hide!==void 0&&(i.hide=n.hide,i.visible=!n.hide),n.pinned!==void 0&&(i.pinned=n.pinned),n.width!==void 0&&(i.width=n.width),n.flex!==void 0&&(i.flex=n.flex),n.sort!==void 0&&(i.sort=n.sort),n.sortIndex!==void 0&&(i.sortIndex=n.sortIndex),n.rowGroupIndex!==void 0&&(i.rowGroup=n.rowGroupIndex!==null,i.rowGroupIndex=n.rowGroupIndex),n.pivotIndex!==void 0&&(i.pivot=n.pivotIndex!==null,i.pivotIndex=n.pivotIndex),n.aggFunc!==void 0&&(i.aggFunc=n.aggFunc))}if(t){const n=new Map(e.map(o=>[o.colId,o.colId])),i=this.displayOrder.filter(o=>!n.has(o));this.displayOrder=[...e.map(o=>o.colId).filter(o=>this.getColumn(o)),...i]}this.refreshAll()}resetColumnState(){this.buildColumns()}getMeasureContext(){if(this.measureCtx)return this.measureCtx;const e=document.createElement("canvas");return this.measureCtx=e.getContext("2d"),this.measureCtx&&(this.measureCtx.font='400 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'),this.measureCtx}measureTextWidth(e){const t=this.getMeasureContext();return t?t.measureText(e).width:e.length*8}sizeColumnsToFit(e,t=[]){const n=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const i of n){let a=0,l=0;for(const d of i)t.includes(d.colId)?l+=d.width:d.flex!==null&&d.flex>0?a+=d.flex:l+=d.width;const r=Math.max(0,e-l-32);if(a>0){for(const d of i)if(d.flex!==null&&d.flex>0&&!t.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/a));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var l,r,d,c,p,h;const n=this.getColumn(e);if(!n)return;let i=this.measureTextWidth(n.headerName)+32;t||(i+=16);const o=((r=(l=this.gridApi)==null?void 0:l.getDisplayedRowCount)==null?void 0:r.call(l))??0,a=Math.min(o,300);for(let u=0;u<a;u++){const f=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,u);if(!f)continue;const g=(h=(p=this.gridApi)==null?void 0:p.getCellText)==null?void 0:h.call(p,n,f);g&&(i=Math.max(i,this.measureTextWidth(g)+32))}n.width=Math.max(n.minWidth,Math.min(n.maxWidth,Math.ceil(i))),n.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:n,finished:!0})}autoSizeAllColumns(e=!1){for(const t of this.getDisplayedColumns())this.autoSizeColumn(t,e)}}function _n(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class Ds{constructor(){y(this,"listeners",new Map)}addEventListener(e,t){let n=this.listeners.get(e);n||(n=[],this.listeners.set(e,n)),n.push(t)}removeEventListener(e,t){const n=this.listeners.get(e);if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}dispatchEvent(e,t){const n=this.listeners.get(e);if(!n||n.length===0)return;const i={type:e,...t||{}};for(const o of n.slice())o(i)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const Wn={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应本列宽度",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多条件筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"显示/隐藏",hideColumn:"隐藏本列",chooseColumns:"选择列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",sortAsc:"升序",sortDesc:"降序",sortNone:"无",copy:"复制",copyWithHeaders:"连同表头复制",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应容器宽度",expandAll:"展开全部",collapseAll:"折叠全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",search:"搜索…",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"全部清除",join:"条件组合:",and:"并且",or:"或者",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",conditionsUnit:"个条件",addCondition:"+ 添加条件",condTrue:"真",condFalse:"假",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"页码",pageSize:"每页行数:",pageNumber:"输入页码",find:"在表格中查找…",matchCase:"区分大小写",prevMatch:"上一个匹配",nextMatch:"下一个匹配",of:"/",rangeTo:"至",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity",dataGrid:"数据表格",dragRow:"拖拽行",expandGroup:"展开分组",close:"关闭",save:"保存",delete:"删除",totalRows:"总行数",rows:"行数",filtered:"筛选后",selected:"已选中",average:"平均",count:"计数",min:"最小",max:"最大",sum:"合计",note:"便签",writeNote:"写便签…",formulaPreview:"预览(第 1 行)",formulaError:"错误",invalidFormula:"公式无效",functions:"函数",integratedCharts:"集成图表",chart:"图表",chartType:"图表类型",chartCategory:"类目",chartSeries:"数据系列",chartGroup:"分组",createChart:"创建图表",noChartsCreated:"暂无图表",downloadPng:"下载 PNG",chartLine:"折线图",chartArea:"面积图",chartColumn:"柱状图",chartBar:"条形图",chartPie:"饼图",chartScatter:"散点图"},Ps={contains:"contains",notEqual:"notEqual",startsWith:"startsWith",endsWith:"endsWith",equals:"equals",blank:"blank",notBlank:"notBlank",greaterThan:"greaterThan",greaterThanOrEqual:"greaterThanOrEqual",lessThan:"lessThan",lessThanOrEqual:"lessThanOrEqual",inRange:"inRange",true:"condTrue",false:"condFalse"};class Hs{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Wn[e]??e}}function Os(s){return new Hs(s??{})}function Bs(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class Vs{constructor(e){y(this,"eventService");y(this,"columns");y(this,"getSortModel");y(this,"getFilterModel");y(this,"rowNodeServices");y(this,"datasource",null);y(this,"stores",new Map);y(this,"rowNodeMap",new Map);y(this,"displayRows",[]);y(this,"blockSize");this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"serverSide"}setDatasource(e){this.datasource=e,this.purgeCache()}getStore(e){return this.stores.get(e)}getOrCreateStore(e){let t=this.stores.get(e);return t||(t={rows:[],lastRow:null,loading:!1,failed:!1},this.stores.set(e,t)),t}isLoading(){for(const e of this.stores.values())if(e.loading)return!0;return!1}loadBlock(e,t,n){if(!this.datasource)return;const i=this.getOrCreateStore(e);if(i.loading)return;for(let a=i.rows.length;a<n;a++)i.rows.push(null);i.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const o={startRow:t,endRow:n,rowGroupCols:this.columns().filter(a=>a.rowGroup),valueCols:this.columns().filter(a=>a.aggFunc&&!a.rowGroup),pivotCols:this.columns().filter(a=>a.pivot),groupKeys:e?e.split("|"):[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(a,l)=>{i.loading=!1,this.onBlockLoaded(e,a,l??null)},failCallback:()=>{i.loading=!1,i.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(o)}onBlockLoaded(e,t,n){const i=this.getOrCreateStore(e);i.lastRow=n,i.failed=!1;for(let o=0;o<t.length;o++){const a=t[o],l=(i.rows.length>0,o),r=this.createNode(a,e,o,l);i.rows[l]=r}for(;i.rows.length&&i.rows[i.rows.length-1]===null;)i.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,n,i){const o=Bs(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${i}`,l=this.rowNodeMap.get(a),r=l instanceof Qe?l:new Qe(e,this.rowNodeServices,a);return r.data=e,r.rowIndex=n,o&&(r.group=!0,r.key=String(Ce(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(a,r),r}buildDisplayRows(){const e=[],t=(n,i)=>{const o=this.stores.get(n);if(o){for(const a of o.rows)if(a&&(a.uiLevel=i,e.push(a),a.group&&a.expanded)){const l=`${n?n+"|":""}${a.key}`;t(l,i+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((n,i)=>n.__displayIndex=i)}ensureLoaded(e,t){let n=0;const i=a=>{const l=this.stores.get(a);if(l){for(const r of l.rows)if(r){if(n>=e&&n<=t){const d=Math.floor(n/this.blockSize)*this.blockSize,c=d+this.blockSize,p=l.lastRow,h=p!==null?Math.min(p,c):c;n<(l.rows.length||0)&&d<(l.rows.length||0)||(l.lastRow===null||c<=l.lastRow)&&this.loadBlock(a,d,h)}n++,r.group&&r.expanded&&i(`${a?a+"|":""}${r.key}`)}}};i("");const o=this.stores.get("");(!o||o.rows.length===0&&o.lastRow===null)&&this.loadBlock("",0,this.blockSize)}refreshModel(e){this.ensureLoaded(0,this.blockSize),this.eventService.dispatchEvent("modelUpdated",{})}onViewportChanged(e,t){this.ensureLoaded(e,t)}setNodeExpanded(e,t){if(e.group){if(e.expanded=t,t){const n=this.groupPathFor(e);this.stores.has(n)||this.loadBlock(n,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const t=[];let n=e;for(;n&&n.group;)t.unshift(n.key??""),n=n.parent??null;return t.join("|")}purgeCache(){this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[],this.refreshModel("everything")}onSortOrFilterChanged(){this.purgeCache()}getRowCount(){return this.displayRows.length}getTotalRowCount(){const e=this.stores.get("");return(e==null?void 0:e.lastRow)??0}getRow(e){return this.displayRows[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.displayRows.forEach((t,n)=>e(t,n))}forEachLeafNode(e){let t=0;for(const n of this.displayRows)!n.group&&!n.footer&&e(n,t++)}isEmpty(){return this.displayRows.length===0}getTopLevelRows(){const e=this.stores.get("");return(e==null?void 0:e.rows.filter(Boolean))||[]}updateRowData(e){this.refreshModel("everything")}applyTransaction(e){const t={add:[],remove:[],update:[]};for(const n of e.update||[]){const i=(n==null?void 0:n.id)!==void 0?String(n.id):void 0,o=i?this.rowNodeMap.get(i):void 0;o&&(o.data=n,t.update.push(o))}return this.eventService.dispatchEvent("modelUpdated",{}),t}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[]}expandAll(){for(const e of this.rowNodeMap.values())if(e.group){e.expanded=!0;const t=this.groupPathFor(e);this.stores.has(t)||this.loadBlock(t,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}collapseAll(){for(const e of this.rowNodeMap.values())e.group&&(e.expanded=!1);this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class Gs{constructor(e){y(this,"eventService");y(this,"getSortModel");y(this,"getFilterModel");y(this,"rowNodeServices");y(this,"datasource",null);y(this,"nodes",[]);y(this,"rowNodeMap",new Map);y(this,"blockSize");y(this,"loading",!1);this.eventService=e.eventService,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"infinite"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let n=this.nodes.length;n<t;n++)this.nodes.push(null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(n,i)=>{this.loading=!1,n.forEach((o,a)=>{const l=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let r=this.rowNodeMap.get(l);r||(r=new Qe(o,this.rowNodeServices,l),this.rowNodeMap.set(l,r)),r.data=o,r.rowIndex=e+a,this.nodes[e+a]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const n=Math.floor(e/this.blockSize)*this.blockSize;n+this.blockSize>this.nodes.length&&this.loadBlock(n,n+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.loadBlock(0,this.blockSize)}isLoading(){return this.loading}getRowCount(){return this.nodes.length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,n)=>{t&&e(t,n)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.nodes.filter(Boolean).length===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){this.onSortOrFilterChanged()}applyTransaction(){return null}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class qs{constructor(e){y(this,"eventService");y(this,"rowNodeServices");y(this,"datasource",null);y(this,"nodes",[]);y(this,"rowNodeMap",new Map);y(this,"loading",!1);this.eventService=e.eventService,this.rowNodeServices=e.rowNodeServices}getType(){return"viewport"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}setViewportRange(e,t){if(!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((n,i)=>i>=e&&i<=t);for(let n=e;n<=t;n++)this.nodes[n-e]||(this.nodes[n-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:n=>{this.loading=!1,n.forEach((i,o)=>{const a=(i==null?void 0:i.id)!==void 0?String(i.id):`vrow-${e+o}`;let l=this.rowNodeMap.get(a);l||(l=new Qe(i,this.rowNodeServices,a),this.rowNodeMap.set(a,l)),l.data=i,l.rowIndex=e+o,this.nodes[e+o-e]=l}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}setViewportDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}onViewportChanged(e,t){this.setViewportRange(e,t)}isLoading(){return this.loading}getRowCount(){return this.nodes.filter(Boolean).length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,n)=>{t&&e(t,n)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){}applyTransaction(){return null}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}function Un(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Je=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class zs{constructor(e,t){y(this,"charts",new Map);y(this,"chartCounter",0);y(this,"currentType","line");y(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),n=t.getRowGroupColumns();let i=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(r=>r.aggFunc),a=[],l=o.map(()=>[]);if(n.length>0)((d,c)=>{for(const p of d)if(p.group){const h=n[0]?String(Ce(n[0],p,this.grid.getApi())??""):p.key??"";a.push(h);for(let u=0;u<o.length;u++){const f=[];jn(p,o[u],f),l[u].push(Number(kt(o[u],o[u].aggFunc,f))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(i||(i=this.grid.getColumns().center.find(r=>r.field&&r.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(r=>{if(r.group||r.footer)return;const d=i?Ce(i,r,this.grid.getApi()):"";a.push(String(d??""));for(let c=0;c<o.length;c++){const p=Ce(o[c],r,this.grid.getApi());l[c].push(typeof p=="number"?p:Number(p)||0)}}),a.length>200){const r=Math.ceil(a.length/200),d=[],c=l.map(()=>[]);for(let p=0;p<a.length;p+=r){d.push(a[p]);for(let h=0;h<l.length;h++)c[h].push(l[h][p])}return{categories:d,series:o.map((p,h)=>({title:p.headerName,data:c[h]}))}}return{categories:a,series:o.map((r,d)=>({title:r.headerName,data:l[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const t=document.createElement("div");t.className="ag-side-bar-section-title",t.textContent=this.grid.t("integratedCharts"),e.appendChild(t);const n=document.createElement("div");n.className="ag-chart-panel-label",n.textContent=this.grid.t("chartType"),e.appendChild(n);const i=document.createElement("select");i.className="ag-chart-panel-select";const o=[{value:"line",label:this.grid.t("chartLine")},{value:"area",label:this.grid.t("chartArea")},{value:"column",label:this.grid.t("chartColumn")},{value:"bar",label:this.grid.t("chartBar")},{value:"pie",label:this.grid.t("chartPie")},{value:"scatter",label:this.grid.t("chartScatter")}];for(const v of o){const m=document.createElement("option");m.value=v.value,m.textContent=v.label,v.value===this.currentType&&(m.selected=!0),i.appendChild(m)}i.addEventListener("change",()=>{this.currentType=i.value}),e.appendChild(i);const a=document.createElement("div");a.className="ag-chart-panel-label",a.textContent=this.grid.t("chartCategory"),e.appendChild(a);const l=document.createElement("select");l.className="ag-chart-panel-select";const r=this.grid.getColumnModel().getRowGroupColumns(),d=r.length>0?r:this.grid.getColumns().center.filter(v=>v.field);for(const v of d){const m=document.createElement("option");m.value=v.colId,m.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${v.headerName}`:v.headerName,l.appendChild(m)}e.appendChild(l);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent=this.grid.t("chartSeries"),e.appendChild(c);const p=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),h=document.createElement("div");h.className="ag-chart-panel-series";const u=new Set(p.slice(0,3).map(v=>v.colId));for(const v of this.grid.getColumns().center.filter(m=>m.field)){const m=document.createElement("label");m.className="ag-chart-panel-series-item";const w=document.createElement("input");w.type="checkbox",w.checked=u.has(v.colId),w.addEventListener("change",()=>{w.checked?u.add(v.colId):u.delete(v.colId)}),m.appendChild(w);const k=document.createElement("span");k.textContent=v.headerName,m.appendChild(k),h.appendChild(m)}e.appendChild(h);const f=document.createElement("button");f.className="ag-button ag-button-primary ag-chart-panel-create",f.textContent=this.grid.t("createChart"),f.addEventListener("click",()=>{const v=this.grid.getColumn(l.value)||void 0,m=[...u].map(w=>this.grid.getColumn(w)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:m})}),e.appendChild(f);const g=document.createElement("div");if(g.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent=this.grid.t("noChartsCreated"),g.appendChild(v)}for(const[v,m]of this.charts){const w=document.createElement("div");w.className="ag-chart-panel-list-item";const k=document.createElement("span");k.textContent=m.title,w.appendChild(k);const C=document.createElement("button");C.className="ag-column-group-remove",C.textContent="×",C.addEventListener("click",()=>this.destroyChart(v)),w.appendChild(C),g.appendChild(w)}return e.appendChild(g),e}createChart(e={}){var v,m,w,k;const t=e.type||this.currentType,n=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),i=`chart-${++this.chartCounter}`,o=e.title||`${this.grid.t(`chart${t.charAt(0).toUpperCase()}${t.slice(1)}`)}`,{ePopup:a}=this.popupService.createPopup(640,"ag-chart-window");a.innerHTML="";const l=document.createElement("div");l.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=o,l.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent=this.grid.t("downloadPng"),l.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title=this.grid.t("close"),c.addEventListener("click",()=>this.destroyChart(i)),l.appendChild(c),a.appendChild(l);const p=document.createElement("div");p.className="ag-chart-window-body";const h=document.createElement("canvas");h.className="ag-chart-canvas",h.width=600,h.height=360,p.appendChild(h);const u=document.createElement("div");u.className="ag-chart-tooltip",u.style.display="none",p.appendChild(u),h.addEventListener("mousemove",C=>this.onChartHover({id:i,ePopup:a,canvas:h,type:t,data:n,title:o},C,u)),h.addEventListener("mouseleave",()=>{u.style.display="none"});const f=document.createElement("div");f.className="ag-chart-legend",p.appendChild(f),a.appendChild(p),this.timeSeries=n.categories.length>0&&n.categories.every(C=>!isNaN(Date.parse(String(C)))&&isNaN(Number(C)));const g={id:i,ePopup:a,canvas:h,type:t,data:n,title:o};return this.charts.set(i,g),d.addEventListener("click",()=>{const C=h.toDataURL("image/png"),b=document.createElement("a");b.href=C,b.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,b.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(g),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:i,chartTitle:o,api:this.grid.getApi()}),(m=(v=this.grid.getOptions()).onChartCreated)==null||m.call(v,{chartId:i,chartTitle:o,api:this.grid.getApi()}),((w=this.grid.getSideBarService())==null?void 0:w.getActivePanel())==="charts"&&((k=this.grid.getSideBarService())==null||k.refresh()),i}destroyChart(e){var n,i,o,a;const t=this.charts.get(e);t&&(t.ePopup.remove(),this.charts.delete(e),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartDestroyed",{chartId:e,api:this.grid.getApi()}),(i=(n=this.grid.getOptions()).onChartDestroyed)==null||i.call(n,{chartId:e,api:this.grid.getApi()}),((o=this.grid.getSideBarService())==null?void 0:o.getActivePanel())==="charts"&&((a=this.grid.getSideBarService())==null||a.refresh()))}getChartModels(){return[...this.charts.values()].map(e=>({chartId:e.id,chartType:e.type,title:e.title}))}refreshCharts(){for(const e of this.charts.values())e.data=this.getChartData(),this.renderChart(e)}onChartHover(e,t,n){const o=e.canvas.getBoundingClientRect(),a=600/(o.width||1),l=360/(o.height||1),r=(t.clientX-o.left)*a,d=(t.clientY-o.top)*l,c={top:20,right:20,bottom:34,left:56},p=600-c.left-c.right,h=360-c.top-c.bottom;if(r<c.left||r>c.left+p||d<c.top||d>c.top+h){n.style.display="none";return}if(e.type==="pie"){n.style.display="none";return}const u=e.type==="bar",f=Math.max(1,e.data.categories.length),g=(u?h:p)/f,v=Math.floor((u?d-c.top:r-c.left)/g);if(v<0||v>=e.data.categories.length){n.style.display="none";return}const m=e.data.series.map(w=>`${w.title}: ${this.formatTick(w.data[v]??0)}`);n.innerHTML=`<div class="ag-chart-tooltip-title">${Un(e.data.categories[v])}</div>`+m.map(w=>`<div>${Un(w)}</div>`).join(""),n.style.display="block",n.style.left=`${t.clientX-o.left+12}px`,n.style.top=`${t.clientY-o.top+12}px`}storageKey(){const t=this.grid.getOptions().chartStorageKey;return t?`rowvia-charts:${t}`:null}saveCharts(){const e=this.storageKey();if(!e)return;const t=[...this.charts.values()].map(n=>({id:n.id,type:n.type,title:n.title,data:n.data}));try{localStorage.setItem(e,JSON.stringify(t))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let t=[];try{const n=localStorage.getItem(e);n&&(t=JSON.parse(n))}catch{return}for(const n of t)this.restoreChart(n)}restoreChart(e){const t=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(t))return;const{ePopup:n}=this.popupService.createPopup(640,"ag-chart-window");n.innerHTML="";const i=document.createElement("div");i.className="ag-chart-window-header";const o=document.createElement("span");o.className="ag-chart-window-title",o.textContent=e.title||this.grid.t("chart"),i.appendChild(o);const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="×",a.addEventListener("click",()=>this.destroyChart(t)),i.appendChild(a),n.appendChild(i);const l=document.createElement("div");l.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,l.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",l.appendChild(d),n.appendChild(l);const c={id:t,ePopup:n,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,c),this.popupService.positionAt(n,this.grid.getRootElement()),n.style.top="60px",this.renderChart(c)}renderChart(e){var G;const t=e.canvas,n=t.getContext("2d");if(!n)return;const i=window.devicePixelRatio||1,o=t.width,a=t.height;t.width=o*i,t.height=a*i,t.style.width=`${o}px`,t.style.height=`${a}px`,n.scale(i,i),n.clearRect(0,0,o,a);const l=getComputedStyle(this.grid.getRootElement()),r=l.getPropertyValue("--ag-chart-text-color")||"#666",d=l.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},p=o-c.left-c.right,h=a-c.top-c.bottom;n.font="11px sans-serif",n.fillStyle=r,n.strokeStyle=d,n.lineWidth=1;const u=(G=e.canvas.parentElement)==null?void 0:G.querySelector(".ag-chart-legend");if(u&&(u.innerHTML="",e.data.series.forEach((x,T)=>{const A=document.createElement("span");A.className="ag-chart-legend-item";const H=document.createElement("span");H.className="ag-chart-legend-swatch",H.style.backgroundColor=Je[T%Je.length],A.appendChild(H),A.appendChild(document.createTextNode(x.title)),u.appendChild(A)})),e.type==="pie"){this.renderPie(n,e.data,o,a,r);return}const f=e.data.series.flatMap(x=>x.data);let g=Math.max(0,...f),v=Math.min(0,...f);e.type==="scatter"&&(v=Math.min(...f),g=Math.max(...f));const m=g-v||1;g+=m*.08,v-=v<0?m*.08:0;const w=g-v||1,k=x=>c.top+h-(x-v)/w*h,C=5;n.textAlign="right",n.textBaseline="middle";for(let x=0;x<=C;x++){const T=v+w*x/C,A=k(T);n.beginPath(),n.moveTo(c.left,A),n.lineTo(o-c.right,A),n.stroke(),n.fillText(this.formatTick(T),c.left-6,A)}const b=e.data.categories,N=e.type==="bar",I=Math.max(1,b.length),E=(N?h:p)/I;if(N){n.textAlign="left",b.forEach((T,A)=>{const H=c.top+A*E,q=Math.max(2,E*.7/e.data.series.length);e.data.series.forEach((R,P)=>{const L=R.data[A]||0,M=Math.abs(L)/w*p,$=c.left+(0-v)/w*p;n.fillStyle=Je[P%Je.length],n.fillRect($,H+P*q,Math.max(1,M),q-1)}),n.fillStyle=r,n.fillText(this.truncate(T,18),c.left+4,H+E/2)});const x=c.left+(0-v)/w*p;n.beginPath(),n.moveTo(x,c.top),n.lineTo(x,c.top+h),n.strokeStyle=r,n.stroke()}else{const x=Math.max(1,Math.ceil(I/12));n.textAlign="center",n.textBaseline="top",b.forEach((H,q)=>{if(q%x!==0)return;const R=c.left+E*(q+.5);n.fillStyle=r,n.fillText(this.truncate(H,10),R,c.top+h+6)});const T=e.data.series.length,A=Math.max(1,E*.7/Math.max(1,T));e.data.series.forEach((H,q)=>{const R=Je[q%Je.length];if(e.type==="column")n.fillStyle=R,H.data.forEach((P,L)=>{const M=c.left+E*L+(E-A*T)/2+q*A,$=k(P);n.fillRect(M,$,A-1,c.top+h-$)});else if(e.type==="area"){n.beginPath(),H.data.forEach((L,M)=>{const $=c.left+E*(M+.5),z=k(L);M===0?n.moveTo($,z):n.lineTo($,z)});const P=c.left+E*(H.data.length-.5);n.lineTo(P,c.top+h),n.lineTo(c.left+E*.5,c.top+h),n.closePath(),n.globalAlpha=.25,n.fillStyle=R,n.fill(),n.globalAlpha=1,n.beginPath(),H.data.forEach((L,M)=>{const $=c.left+E*(M+.5),z=k(L);M===0?n.moveTo($,z):n.lineTo($,z)}),n.strokeStyle=R,n.lineWidth=2,n.stroke()}else e.type==="scatter"?(n.fillStyle=R,H.data.forEach((P,L)=>{const M=c.left+E*(L+.5),$=k(P);n.beginPath(),n.arc(M,$,3,0,Math.PI*2),n.fill()})):(n.beginPath(),H.data.forEach((P,L)=>{const M=c.left+E*(L+.5),$=k(P);L===0?n.moveTo(M,$):n.lineTo(M,$)}),n.strokeStyle=R,n.lineWidth=2,n.stroke())})}}renderPie(e,t,n,i,o){const a=t.series[0];if(!a)return;const l=a.data.reduce((h,u)=>h+Math.abs(u),0)||1,r=n/2,d=i/2,c=Math.min(n,i)/2-30;let p=-Math.PI/2;a.data.forEach((h,u)=>{const f=Math.abs(h)/l*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,p,p+f),e.closePath(),e.fillStyle=Je[u%Je.length],e.fill();const g=p+f/2,v=r+Math.cos(g)*(c*.7),m=d+Math.sin(g)*(c*.7),w=Math.round(Math.abs(h)/l*100);w>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${w}%`,v,m)),p+=f}),e.fillStyle=o}formatTick(e){if(this.timeSeries){const n=new Date(e);if(!isNaN(n.getTime()))return n.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}const t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(1)}B`:t>=1e6?`${(e/1e6).toFixed(1)}M`:t>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(1)}truncate(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}}function jn(s,e,t){const n=s.children;if(!n||n.length===0){const i=Ce(e,s,null);typeof i=="number"&&!isNaN(i)&&t.push(i);return}for(const i of n)jn(i,e,t)}class _s{constructor(e){y(this,"eGui");var d,c,p;const t=e.node,n=!!t.group,i=!!t.detailNode,o=n||i,a=t.expanded,l=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${l}px`,o){const h=document.createElement("span");h.className="ag-group-value-expanded-icon",h.classList.add(a?"ag-expanded":"ag-contracted"),h.innerHTML=a?lo:ro,r.appendChild(h);const u=document.createElement("span");u.className="ag-group-value";const f=(d=e.colDef.cellRendererParams)==null?void 0:d.innerRenderer;if(typeof f=="function"){const g=f({...e,value:e.value,valueFormatted:e.valueFormatted});g instanceof HTMLElement?u.appendChild(g):typeof g=="string"&&(u.innerHTML=g)}else u.textContent=Qs(e.value);if(r.appendChild(u),n&&t.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const g=document.createElement("span");g.className="ag-group-child-count",g.textContent=` (${t.allChildrenCount})`,r.appendChild(g)}}else{const h=document.createElement("span");h.className="ag-group-value";const u=(p=e.colDef.cellRendererParams)==null?void 0:p.innerRenderer;if(typeof u=="function"){const f=u({...e,value:e.value,valueFormatted:e.valueFormatted});f instanceof HTMLElement?h.appendChild(f):typeof f=="string"&&(h.innerHTML=f)}else h.textContent=e.valueFormatted??String(e.value??"");r.appendChild(h)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Ws{constructor(e){y(this,"eGui");y(this,"eCheckbox");this.eGui=document.createElement("span"),this.eGui.className="ag-cell-checkbox";const t=document.createElement("input");t.type="checkbox",t.className="ag-native-checkbox",t.checked=!!e.node.selected,t.addEventListener("click",n=>n.stopPropagation()),t.addEventListener("change",()=>{e.node.setSelected(t.checked,!1,"uiSelectChanged")}),this.eCheckbox=t,this.eGui.appendChild(t)}getGui(){return this.eGui}refresh(e){return this.eCheckbox.checked=!!e.node.selected,!0}}const Us='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',js='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class Ks{constructor(e){y(this,"eGui");y(this,"eArrow");y(this,"eOld");y(this,"eNew");y(this,"lastValue");y(this,"flashTimer",null);this.eGui=document.createElement("span"),this.eGui.className="ag-animate-show-change-cell-renderer",this.eArrow=document.createElement("span"),this.eArrow.className="ag-value-change-arrow",this.eArrow.style.display="none",this.eOld=document.createElement("span"),this.eOld.className="ag-value-change-old",this.eOld.style.display="none",this.eNew=document.createElement("span"),this.eNew.className="ag-value-change-new",this.eGui.appendChild(this.eArrow),this.eGui.appendChild(this.eOld),this.eGui.appendChild(this.eNew),this.eNew.textContent=this.formatValue(e),this.lastValue=e.value}formatValue(e){const t=e.valueFormatted??e.value;return t==null?"":String(t)}getGui(){return this.eGui}refresh(e){const t=e.value;if(t!==this.lastValue){const n=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),i=this.eNew.textContent??"";this.eArrow.innerHTML=n?Us:js,this.eArrow.style.display="",this.eArrow.classList.add(n?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=i,this.eOld.style.display="",this.eNew.textContent=this.formatValue(e),this.lastValue=t,this.eGui.classList.remove("ag-value-change-value-highlight"),this.eGui.offsetWidth,this.eGui.classList.add("ag-value-change-value-highlight",n?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.flashTimer&&clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this.eGui.classList.remove("ag-value-change-value-highlight","ag-value-change-delta-up","ag-value-change-delta-down"),this.eArrow.style.display="none",this.eOld.style.display="none"},1e3)}return!0}destroy(){this.flashTimer&&clearTimeout(this.flashTimer)}}class Ys{constructor(e){y(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-number-cell",this.eGui.textContent=String(e.rowIndex+1)}getGui(){return this.eGui}refresh(e){return this.eGui.textContent=String(e.rowIndex+1),!0}}class Xs{constructor(e){y(this,"eGui");var r,d;const t=document.createElement("span");t.className="ag-sparkline-cell";const n=e.value||[],i=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},o=e.column.width||100,a=i.height||24,l=en(n,Math.max(20,o-16),a,i);t.appendChild(l),this.eGui=t}getGui(){return this.eGui}refresh(e){var l,r;const t=e.value||[],n=e.sparklineOptions||((r=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:r.sparklineOptions)||{},i=e.column.width||100,o=n.height||24;this.eGui.innerHTML="";const a=en(t,Math.max(20,i-16),o,{type:n.type,direction:n.direction});return this.eGui.appendChild(a),!0}}function en(s,e,t,n={}){var m,w,k;const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",String(Math.max(20,e))),i.setAttribute("height",String(t)),i.setAttribute("class","ag-sparkline");const o=(s||[]).map(C=>typeof C=="number"?C:Number((C==null?void 0:C.value)??0));if(!o||o.length<1)return i;const a=n.type||"line",l=Math.min(...o,0),d=Math.max(...o,0)-l||1,c=((m=n.tooltip)==null?void 0:m.enabled)===!0,p=((w=n.axis)==null?void 0:w.type)||"number",h=((k=n.pointsOfInterest)==null?void 0:k.show)===!0,u=(C,b)=>p==="category"?`${C+1}: ${b}`:String(b);if(h&&o.length>1){const C=o.indexOf(Math.min(...o)),b=o.indexOf(Math.max(...o)),N=e/Math.max(1,o.length-1),I=G=>t-2-(G-l)/d*(t-4),E=(G,x)=>{const T=document.createElementNS("http://www.w3.org/2000/svg","circle");T.setAttribute("cx",String(G*N)),T.setAttribute("cy",String(I(o[G]))),T.setAttribute("r","2.5"),T.setAttribute("fill",x),i.appendChild(T)};E(0,"#4caf50"),E(o.length-1,"#f44336"),E(C,"#2196f3"),E(b,"#ff9800")}if(c){const C=document.createElementNS("http://www.w3.org/2000/svg","title");C.textContent=o.map((b,N)=>u(N,b)).join(`
3
+ `),i.appendChild(C),i.style.cursor="default"}if(a==="bar"){const C=n.direction==="vertical",b=o.length;if(C){const N=Math.max(1,e/b-1),I=t-2-(0-l)/d*(t-4);o.forEach((E,G)=>{const x=G*(e/b),T=t-2-(E-l)/d*(t-4),A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("x",String(x)),A.setAttribute("width",String(N)),A.setAttribute("y",String(Math.min(T,I))),A.setAttribute("height",String(Math.max(1,Math.abs(I-T)))),A.setAttribute("fill","currentColor"),i.appendChild(A)})}else{const N=Math.max(1,t/b-1),I=2+(0-l)/d*(e-4);o.forEach((E,G)=>{const x=G*(t/b),T=2+(E-l)/d*(e-4),A=document.createElementNS("http://www.w3.org/2000/svg","rect");A.setAttribute("y",String(x)),A.setAttribute("height",String(N)),A.setAttribute("x",String(Math.min(T,I))),A.setAttribute("width",String(Math.max(1,Math.abs(I-T)))),A.setAttribute("fill","currentColor"),i.appendChild(A)})}return i}const f=e/Math.max(1,o.length-1),g=o.map((C,b)=>{const N=b*f,I=t-2-(C-l)/d*(t-4);return`${N.toFixed(1)},${I.toFixed(1)}`});if(a==="area"){const C=document.createElementNS("http://www.w3.org/2000/svg","polygon");C.setAttribute("points",`0,${t} ${g.join(" ")} ${e},${t}`),C.setAttribute("fill","currentColor"),C.setAttribute("opacity","0.2"),i.appendChild(C)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",g.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),i.appendChild(v),i}class Zs{constructor(e){y(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Kn,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const Vt={agGroupCellRenderer:s=>new _s(s),agCheckboxCellRenderer:s=>new Ws(s),agSparklineCellRenderer:s=>new Xs(s),agAnimateShowChangeCellRenderer:s=>new Ks(s),agRowNumberCellRenderer:s=>new Ys(s),agRowDragComp:s=>new Zs(s)};function Qs(s){return s==null?"":String(s)}class Js{constructor(e){y(this,"eGui");y(this,"cancelled",!1);this.eGui=document.createElement("input"),this.eGui.type="text",this.eGui.className="ag-cell-editor-input",this.eGui.value=e.value??"",this.eGui.addEventListener("keydown",t=>{var n;return(n=e.onKeyDown)==null?void 0:n.call(e,t)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class eo{constructor(e){y(this,"eGui");y(this,"eInput");y(this,"cancelled",!1);var i,o;const t=document.createElement("div");t.className="ag-cell-editor-number";const n=document.createElement("input");if(n.type="text",n.className="ag-cell-editor-input",n.value=e.value??"",(o=(i=e.column)==null?void 0:i.cellEditorParams)!=null&&o.showStepperButtons){const a=document.createElement("span");a.className="ag-cell-editor-stepper ag-cell-editor-stepper-up",a.innerHTML="▲",a.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),r.preventDefault(),n.value=String(Number(n.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const l=document.createElement("span");l.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",l.innerHTML="▼",l.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),n.value=String(Number(n.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),t.appendChild(a),t.appendChild(n),t.appendChild(l)}else t.appendChild(n);this.eGui=t,this.eInput=n,this.eInput.addEventListener("keydown",a=>{var l;return(l=e.onKeyDown)==null?void 0:l.call(e,a)})}getGui(){return this.eGui}getValue(){if(this.cancelled)return;const e=Number(this.eInput.value);return isNaN(e)?null:e}focusIn(){this.eInput.focus(),this.eInput.select()}}class to{constructor(e){y(this,"eGui");y(this,"cancelled",!1);var n,i;this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((i=(n=e.column)==null?void 0:n.cellEditorParams)==null?void 0:i.values)||[];for(const o of t){const a=document.createElement("option");a.value=String(o),a.textContent=String(o),this.eGui.appendChild(a)}this.eGui.value=String(e.value??""),this.eGui.addEventListener("keydown",o=>{var a;return(a=e.onKeyDown)==null?void 0:a.call(e,o)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus()}}class no{constructor(e){y(this,"eGui");y(this,"cancelled",!1);this.eGui=document.createElement("input"),this.eGui.type="date",this.eGui.className="ag-cell-editor-input";const t=e.value instanceof Date?e.value:e.value?new Date(e.value):null;t&&!isNaN(t.getTime())&&(this.eGui.value=t.toISOString().slice(0,10))}getGui(){return this.eGui}getValue(){if(!this.cancelled)return this.eGui.value?new Date(this.eGui.value):null}focusIn(){this.eGui.focus()}}class io{constructor(e){y(this,"eGui");y(this,"cancelled",!1);this.eGui=document.createElement("textarea"),this.eGui.className="ag-cell-editor-textarea",this.eGui.value=e.value??""}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}function so(s,e){if(!e)return D(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?D(s):D(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+D(s.slice(t,t+e.length))+"</span>"+D(s.slice(t+e.length))}class oo{constructor(e){y(this,"eGui");y(this,"eInput");y(this,"ePopup",null);y(this,"eList",null);y(this,"values",[]);y(this,"filtered",[]);y(this,"activeIndex",0);y(this,"selectedValue");y(this,"cancelled",!1);var t,n;this.params=e,this.values=e.values||((n=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:n.values)||[],this.selectedValue=e.value,this.eGui=document.createElement("div"),this.eGui.className="ag-rich-select",this.eInput=document.createElement("input"),this.eInput.type="text",this.eInput.className="ag-rich-select-input",this.eInput.value=e.value===null||e.value===void 0?"":String(e.value),this.eInput.readOnly=e.allowTyping!==!0,this.eGui.appendChild(this.eInput),this.eGui.addEventListener("mousedown",i=>{i.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",i=>this.onKeyDown(i))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var a,l;if(this.ePopup)return;const e=document.createElement("div");e.className="ag-rich-select-popup";const t=this.eGui.getBoundingClientRect();if(e.style.position="fixed",e.style.left=`${t.left}px`,e.style.top=`${t.bottom}px`,e.style.minWidth=`${Math.max(t.width,180)}px`,e.style.zIndex="1000",(this.eGui.closest(".ag-root")||document.body).appendChild(e),this.ePopup=e,ao(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((l=(a=this.params).t)==null?void 0:l.call(a,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const i=document.createElement("div");i.className="ag-rich-select-list",e.appendChild(i),this.eList=i,this.renderList();const o=r=>{!e.contains(r.target)&&!this.eGui.contains(r.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var n,i;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(o=>{if(!e)return!0;const a=String(o).toLowerCase(),l=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?l.every(r=>a.includes(r)):l.some(r=>a.includes(r))}),this.filtered.forEach((o,a)=>{const l=document.createElement("div");l.className="ag-rich-select-item",a===this.activeIndex&&l.classList.add("ag-active"),String(o)===String(this.selectedValue)&&l.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const d=r({value:o,valueFormatted:String(o)});d instanceof HTMLElement?l.appendChild(d):l.textContent=String(d)}else l.innerHTML=so(String(o),e);l.addEventListener("click",d=>{d.stopPropagation(),this.commit(o)}),l.addEventListener("mousedown",d=>d.preventDefault()),this.eList.appendChild(l)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((i=(n=this.params).t)==null?void 0:i.call(n,"noMatches"))??"无匹配项",this.eList.appendChild(o)}const t=this.eList.children[this.activeIndex];t&&typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"nearest"})}onKeyDown(e){if(e.key==="ArrowDown")e.preventDefault(),this.activeIndex=Math.min(this.filtered.length-1,this.activeIndex+1),this.renderList();else if(e.key==="ArrowUp")e.preventDefault(),this.activeIndex=Math.max(0,this.activeIndex-1),this.renderList();else if(e.key==="Enter"){e.preventDefault();const t=this.filtered[this.activeIndex];t!==void 0?this.commit(t):this.closePopup()}else if(e.key==="Escape")e.preventDefault(),this.cancelled=!0,this.closePopup();else if(e.key==="Tab"){e.preventDefault();const t=this.filtered[this.activeIndex];t!==void 0?this.commit(t):this.closePopup()}}commit(e){this.selectedValue=e,this.eInput.value=String(e),this.closePopup(),setTimeout(()=>{var t,n;return(n=(t=this.params).onKeyDown)==null?void 0:n.call(t,{key:"Enter",preventDefault:()=>{},keyCode:13})},0)}closePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,this.eList=null}getValue(){return this.cancelled?void 0:this.selectedValue}isCancelAfterEnd(){return this.cancelled}destroy(){this.closePopup()}}function ao(s){var e,t;return(s==null?void 0:s.allowTyping)===!0||((t=(e=s==null?void 0:s.column)==null?void 0:e.cellEditorParams)==null?void 0:t.allowTyping)===!0}const et={agTextCellEditor:s=>new Js(s),agNumberCellEditor:s=>new eo(s),agSelectCellEditor:s=>new to(s),agDateCellEditor:s=>new no(s),agLargeTextCellEditor:s=>new io(s),agRichSelectCellEditor:s=>new oo(s)},ro='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',lo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Kn='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="5" cy="3" r="1.4"/><circle cx="11" cy="3" r="1.4"/><circle cx="5" cy="8" r="1.4"/><circle cx="11" cy="8" r="1.4"/><circle cx="5" cy="13" r="1.4"/><circle cx="11" cy="13" r="1.4"/></svg>',co='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="3" cy="8" r="1.4"/><circle cx="8" cy="8" r="1.4"/><circle cx="13" cy="8" r="1.4"/></svg>',uo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',ho='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',po='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Yn='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>';class fo{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:n,close:i}=this.popupService.createPopup(220,"ag-column-menu");n.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=e.headerName||e.field||e.colId,n.appendChild(o);const a=(r,d)=>{const c=document.createElement("div");c.className="ag-menu-item",d.disabled&&c.classList.add("ag-menu-item-disabled"),d.checked&&c.classList.add("ag-menu-item-active");const p=document.createElement("span");p.className="ag-menu-item-check",d.checked&&(p.innerHTML=Yn),c.appendChild(p);const h=document.createElement("span");if(h.className="ag-menu-item-label",h.textContent=r,c.appendChild(h),d.shortcut){const u=document.createElement("span");u.className="ag-menu-item-shortcut",u.textContent=d.shortcut,c.appendChild(u)}return!d.disabled&&d.onClick&&c.addEventListener("click",()=>{d.onClick(),i()}),n.appendChild(c),c},l=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,n.appendChild(d)};e.sortable&&(l(this.grid.t("sort")),a(this.grid.t("sortAscending"),{checked:e.sort==="asc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"asc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}}),a(this.grid.t("sortDescending"),{checked:e.sort==="desc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"desc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}})),e.resizable&&(l(this.grid.t("columnSize")),a(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),a(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(l(this.grid.t("pinColumn")),a(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),a(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),a(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(l(this.grid.t("filter")),a(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,t)}),e.filter!=="multi"&&a(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,t)}),this.grid.getOptions().enableAdvancedFilter&&a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)}),a(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(l(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),l(this.grid.t("formula")),a(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,t)}),l(this.grid.t("visibility")),a(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),a(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(n,t)}}const Xn={copy:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 2h7v2h2v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-2H3V4a2 2 0 0 1 1-2zm1 2v8h1V4H5z"/></svg>',copyWithHeaders:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M2 1h12v2H2V1zm2 3h8v9H4V4z"/></svg>',paste:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M5 2h6v2H5V2zM3 4h10v10H3V4z"/></svg>',csv:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',excel:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',reset:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 2a6 6 0 1 0 5.7 4H11l3 3 3-3h-2.3A7 7 0 1 1 8 1v1z"/></svg>',pin:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M9 1l6 6-2 1-1 4-3-3-4 4v-3l3-3-1-3 4-1z"/></svg>'};class go{constructor(e,t){this.grid=e,this.popupService=t}getDefaultItems(e){return[{name:"copy",label:this.grid.t("copy"),icon:"copy",shortcut:"Ctrl+C",action:()=>this.grid.getApi().copyToClipboard()},{name:"copyWithHeaders",label:this.grid.t("copyWithHeaders"),icon:"copyWithHeaders",action:()=>this.grid.getApi().copyToClipboard({includeHeaders:!0})},{name:"paste",label:this.grid.t("paste"),icon:"paste",shortcut:"Ctrl+V",action:()=>this.grid.getApi().pasteFromClipboard()},{name:"sep1",separator:!0},{name:"export",label:this.grid.t("export"),icon:"excel",subMenu:[{name:"csvExport",label:this.grid.t("csvExport"),icon:"csv",action:()=>this.grid.getApi().exportToCsv({fileName:"export.csv"})},{name:"excelExport",label:this.grid.t("excelExport"),icon:"excel",action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx"})},{name:"excelExportSelected",label:"Excel Export (Selected)",icon:"excel",disabled:!this.hasSelection(),action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx",onlySelected:!0})}]},{name:"sep2",separator:!0},{name:"resetColumns",label:this.grid.t("resetColumns"),icon:"reset",action:()=>this.grid.getColumnApi().resetColumnState()},{name:"autoSizeAll",label:"Auto-size All Columns",action:()=>this.grid.getColumnApi().autoSizeAllColumns()},{name:"sizeToFit",label:this.grid.t("sizeToFit"),action:()=>this.grid.getApi().sizeColumnsToFit()},{name:"sep3",separator:!0},{name:"expandAll",label:this.grid.t("expandAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().expandAll()},{name:"collapseAll",label:this.grid.t("collapseAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().collapseAll()},{name:"pinRow",label:this.grid.t("pinRow"),icon:"pin",disabled:!e.node||e.node.group===!0,subMenu:[{name:"pinTop",label:this.grid.t("pinToTop"),action:()=>this.grid.setRowNodePinned(e.node,"top")},{name:"pinBottom",label:this.grid.t("pinToBottom"),action:()=>this.grid.setRowNodePinned(e.node,"bottom")},{name:"unpin",label:this.grid.t("unpin"),action:()=>this.grid.setRowNodePinned(e.node,null)}]}]}hasSelection(){return this.grid.getApi().getSelectedNodes().length>0}isGroupActive(){return this.grid.getColumnModel().isRowGroupActive()}openContextMenu(e,t){if(this.grid.getOptions().suppressContextMenu)return;const n=this.grid.getOptions().contextMenuItems;let i;typeof n=="function"?i=n({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(n)?i=n:i=this.getDefaultItems(t);const{ePopup:o,close:a}=this.popupService.createPopup(220,"ag-context-menu");o.innerHTML="",this.buildMenu(o,i,a),this.popupService.positionAt(o,e)}buildMenu(e,t,n){for(const i of t){if(typeof i=="string")continue;if(i.separator){const r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);continue}const o=document.createElement("div");o.className="ag-menu-item",i.disabled&&o.classList.add("ag-menu-item-disabled"),i.cssClasses&&o.classList.add(...i.cssClasses);const a=document.createElement("span");a.className="ag-menu-item-icon",i.icon&&Xn[i.icon]&&(a.innerHTML=Xn[i.icon]),o.appendChild(a);const l=document.createElement("span");if(l.className="ag-menu-item-label",l.textContent=i.label??i.name,o.appendChild(l),i.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=i.shortcut,o.appendChild(r)}if(i.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",o.appendChild(r),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,i.subMenu,n),e.appendChild(c)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;o.matches(":hover")||((c=o.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove())},200)})}else!i.disabled&&i.action&&o.addEventListener("click",()=>{i.action(),n()});e.appendChild(o)}}}class mo{constructor(e,t){y(this,"editing",null);y(this,"fullRowEditors",null);y(this,"fullRowNode",null);y(this,"focusedCell",null);this.grid=e,this.eventService=t}getFocusedCell(){return this.focusedCell}setFocusedCell(e,t){this.focusedCell={rowIndex:e,column:t,rowNode:this.grid.getDisplayedRowAtIndex(e)},this.clearFocusClass();const n=this.findCellElement(t,e);n==null||n.classList.add("ag-cell-focus"),n&&typeof n.scrollIntoView=="function"&&n.scrollIntoView({block:"nearest",inline:"nearest"}),this.eventService.dispatchEvent("cellFocused",{rowIndex:e,column:t,api:this.grid.getApi(),forceBrowserFocus:!0})}clearFocusedCell(){this.focusedCell=null,this.clearFocusClass(),this.grid.getRowRenderer().refreshCells({force:!0})}clearFocusClass(){const e=this.grid.getRootElement();for(const t of e.querySelectorAll(".ag-cell-focus"))t.classList.remove("ag-cell-focus")}findCellElement(e,t){const n=this.grid.getDisplayedRowAtIndex(t);if(!n)return null;const o=this.grid.getRowRenderer().getRowComps().get(n.id);return o&&o.getCellElements().find(a=>a.dataset.colid===e.colId)||null}isEditing(){return this.editing!==null||this.fullRowEditors!==null}getEditingCells(){return this.editing?[{rowIndex:this.editing.rowIndex,colId:this.editing.column.colId}]:[]}startEditingCell(e){var d;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const n=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!n||!this.grid.isCellEditable(t,n))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,n,e.charPress);return}const i=this.findCellElement(t,e.rowIndex);if(!i)return;const o=Ce(t,n,this.grid.getApi()),a={value:e.charPress!==void 0?e.charPress:o,oldValue:o,data:n.data,node:n,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=t.cellEditorParams)==null?void 0:d.values,...t.cellEditorParams};let l;if(typeof t.cellEditor=="string")l=(et[t.cellEditor]||et.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const c=t.cellEditor(a);l=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";l=et[c](a)}if(!l)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:n,eCell:i,editor:l,startedValue:o},i.classList.add("ag-cell-inline-editing");const r=l.getGui();r.classList.add("ag-cell-editor"),i.appendChild(r),i.classList.add("ag-cell-editing"),l.focusIn&&l.focusIn(),l.afterGuiAttached&&l.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:n,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,n){const i=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(o=>this.grid.isCellEditable(o,t));this.fullRowEditors=[],this.fullRowNode=t;for(const o of i){const a=this.findCellElement(o,e);if(!a)continue;const l=Ce(o,t,this.grid.getApi()),r=this.createEditor(o,t,e,l,n);if(!r)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),a.appendChild(d),this.fullRowEditors.push({column:o,editor:r,eCell:a,startedValue:l})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,n,i,o){var r;const a={value:o!==void 0?o:i,oldValue:i,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:n,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(et[e.cellEditor]||et.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const d=e.cellEditor(a);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const l=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return et[l](a)}stopEditing(e=!1){var d,c,p,h;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:n,rowNode:i,eCell:o,editor:a,startedValue:l}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?l:a.getValue();if(r===void 0&&!e)return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:n,node:i,api:this.grid.getApi()}),!1;if(!e){r=Bn(n,r);const u=this.applyValueSetter(n,i,r);if(u===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:n}),!1;r=u}return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:n,node:i,api:this.grid.getApi()}),!e&&!Zn(r,l)&&(this.grid.setCellValue(n,i,r,"edit",l),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l,newValue:r,value:r,data:i.data,node:i,column:n,colDef:n.colDef,api:this.grid.getApi(),source:"edit"}),(h=(p=this.grid.getOptions()).onCellValueChanged)==null||h.call(p,{oldValue:l,newValue:r,value:r,data:i.data,node:i,column:n,colDef:n.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[i],columns:[n],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,n){if(e.valueSetter){if(e.valueSetter({oldValue:Ce(e,t,this.grid.getApi()),newValue:n,data:t.data,node:t,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else t.setDataValue(e.colId,n);return n}stopFullRowEditing(e){var o,a,l;const t=this.fullRowEditors,n=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=r.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const i=[];for(const r of t){if(!n)break;let d=r.editor.getValue();d!==void 0&&(d=Bn(r.column,d),Zn(d,r.startedValue)||i.push({column:r.column,rowNode:n,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:n==null?void 0:n.data});for(const r of i)this.grid.setCellValue(r.column,r.rowNode,r.newValue,"edit",r.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi(),source:"edit"}),(l=(a=this.grid.getOptions()).onCellValueChanged)==null||l.call(a,{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[r.rowNode],columns:[r.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===13){e.preventDefault();const t=this.editing;this.stopEditing(),t&&this.grid.getOptions().enterNavigatesVerticallyAfterEdit!==!1&&this.moveFocus(1,0)}else if(e.key==="Escape"||e.keyCode===27)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===9){e.preventDefault(),this.stopEditing(),this.moveFocus(0,e.shiftKey?-1:1);const t=this.focusedCell;t&&this.grid.isCellEditable(t.column,t.rowNode)&&this.startEditingCell({rowIndex:t.rowIndex,colKey:t.column})}}onGridKeyDown(e){const t=e.key;if(this.editing){t==="Escape"&&this.stopEditing(!0);return}const n=this.focusedCell;switch(e.keyCode){case 13:e.preventDefault(),n&&(this.grid.isCellEditable(n.column,n.rowNode)?this.startEditingCell({rowIndex:n.rowIndex,colKey:n.column}):this.moveFocus(1,0));break;case 9:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case 8:case 46:n&&this.grid.isCellEditable(n.column,n.rowNode)&&(e.preventDefault(),this.grid.setCellValue(n.column,n.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[n.rowNode],columns:[n.column],flash:!0}));break;case 37:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,-1));break;case 39:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,1));break;case 38:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1,0));break;case 40:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1,0));break;case 36:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case 35:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1/0,0));break;case 33:e.preventDefault(),this.moveFocus(-this.getPageJump(),0);break;case 34:e.preventDefault(),this.moveFocus(this.getPageJump(),0);break;case 70:(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.grid.openFind());break;default:if((t==="f"||t==="F")&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.grid.openFind();return}n&&t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(n.column,n.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:n.rowIndex,colKey:n.column,charPress:t}));break}}isTextInput(e){if(!e)return!1;const t=e;return t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable}getPageJump(){const e=this.grid.getRowRenderer().getViewport();return Math.max(1,Math.floor(e.clientHeight/(this.grid.getOptions().rowHeight??42))-1)}moveFocus(e,t){const n=this.focusedCell;if(!n){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let i=n.rowIndex;if(e===-1/0?i=0:e===1/0?i=this.grid.getDisplayedRowCount()-1:i=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,i+e)),t!==0){const o=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let l=o.findIndex(r=>r.colId===n.column.colId)+t;for(;l>=0&&l<o.length&&!o[l].visible;)l+=t;l<0&&(l=0),l>=o.length&&(l=o.length-1),this.setFocusedCell(i,o[l])}else this.setFocusedCell(i,n.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:n}=e;if(this.setFocusedCell(e.rowIndex,n),n.checkboxSelection)return;const i=this.grid.isCellEditable(n,t),o=n.singleClickEdit||this.grid.getOptions().singleClickEdit;i&&o&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:n})}onCellDoubleClicked(e){const{node:t,column:n}=e;this.setFocusedCell(e.rowIndex,n),this.grid.isCellEditable(n,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:n})}destroy(){this.editing=null,this.focusedCell=null}}function Zn(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}const vo={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function Qn(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function wo(s,e,t){const n=Math.max(1,Math.floor(e/(t*.5)));return s.length>n?`${s.slice(0,Math.max(1,n-1))}…`:s}function yo(){return new TextEncoder}function bo(s,e={}){const[t,n]=vo[e.pageSize||"a4-landscape"],i=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,l=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=yo(),c=[],p=w=>(c.push(w),c.length);p(""),p("");const h=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),u=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),f=[];for(const w of s){let k="";const C=w.columnWidths.reduce((H,q)=>H+q,0),b=Math.min(1,(t-i*2)/(C||1)),N=w.columnWidths.map(H=>H*b),I=i;let E=n-i-(e.title?24:0);e.title&&(k+=`BT /F2 ${o+4} Tf ${I} ${E} Td (${Qn(e.title)}) Tj ET
4
+ `,E-=18),w.rows.forEach((H,q)=>{var M;const R=q===0,P=((M=w.rowFill)==null?void 0:M[q])??(R?l:void 0);P&&(k+=`${P[0]} ${P[1]} ${P[2]} rg ${I} ${(E-a+4).toFixed(2)} ${C*b} ${a} re f
5
+ `);let L=I;H.forEach(($,z)=>{const j=N[z]??0,te=Qn(wo($.text??"",j-6,o)),ue=$.bold||R?u:h,ge=($.text??"").length*o*.5;let be=L+3;$.align==="right"||!$.align&&z>0&&/^-?[\d,.%$£€\s]+$/.test($.text??"")?be=L+j-3-Math.min(ge,j-6):$.align==="center"&&(be=L+(j-Math.min(ge,j-6))/2),k+=`BT /F${ue===u?2:1} ${o} Tf ${be.toFixed(2)} ${(E-o+2).toFixed(2)} Td (${te}) Tj ET
6
+ `,L+=j}),k+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${I} ${(E-a+4).toFixed(2)} m ${(I+C*b).toFixed(2)} ${(E-a+4).toFixed(2)} l S
7
+ `,E-=a});const G=w.rows.length*a;k+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${I} ${(E+a-4).toFixed(2)} m ${I} ${(E+G+a-4).toFixed(2)} l ${(I+C*b).toFixed(2)} ${(E+G+a-4).toFixed(2)} l ${(I+C*b).toFixed(2)} ${(E+a-4).toFixed(2)} l S
8
+ `;const x=d.encode(k),T=p(`<< /Length ${x.length} >>
9
9
  stream
10
- ${x}
11
- endstream`),T=p(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${n}] /Resources << /Font << /F1 ${h} 0 R /F2 ${u} 0 R >> >> /Contents ${k} 0 R >>`);f.push(T)}c[0]="<< /Type /Catalog /Pages 2 0 R >>",c[1]=`<< /Type /Pages /Kids [${f.map(y=>`${y} 0 R`).join(" ")}] /Count ${f.length} >>`;let g=`%PDF-1.4
12
- `;const v=[];c.forEach((y,x)=>{const C=x+1;v.push(d.encode(g).length),g+=`${C} 0 obj
13
- ${y}
10
+ ${k}
11
+ endstream`),A=p(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${n}] /Resources << /Font << /F1 ${h} 0 R /F2 ${u} 0 R >> >> /Contents ${T} 0 R >>`);f.push(A)}c[0]="<< /Type /Catalog /Pages 2 0 R >>",c[1]=`<< /Type /Pages /Kids [${f.map(w=>`${w} 0 R`).join(" ")}] /Count ${f.length} >>`;let g=`%PDF-1.4
12
+ `;const v=[];c.forEach((w,k)=>{const C=k+1;v.push(d.encode(g).length),g+=`${C} 0 obj
13
+ ${w}
14
14
  endobj
15
15
  `});const m=d.encode(g).length;g+=`xref
16
16
  0 ${c.length+1}
17
17
  0000000000 65535 f
18
- `;for(const y of v)g+=`${String(y).padStart(10,"0")} 00000 n
18
+ `;for(const w of v)g+=`${String(w).padStart(10,"0")} 00000 n
19
19
  `;return g+=`trailer
20
20
  << /Size ${c.length+1} /Root 1 0 R >>
21
21
  startxref
22
22
  ${m}
23
23
  %%EOF
24
- `,new Blob([d.encode(g)],{type:"application/pdf"})}function rt(s,e){return s.getUint32(e,!0)}function it(s,e){return s.getUint16(e,!0)}async function vo(s){var i;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(i=new Response(s).body)==null?void 0:i.pipeThrough(new DecompressionStream("deflate-raw"));if(!t)throw new Error("Failed to create a decompression stream");const n=await new Response(t).arrayBuffer();return new Uint8Array(n)}function wo(s){const e=new DataView(s),t=new Uint8Array(s);let n=-1;for(let l=t.length-22;l>=0;l--)if(rt(e,l)===101010256){n=l;break}if(n<0)throw new Error("Not a valid XLSX (ZIP) file");const i=it(e,n+10);let o=rt(e,n+16);const a=[];for(let l=0;l<i&&rt(e,o)===33639248;l++){const r=it(e,o+10),d=rt(e,o+20),c=rt(e,o+24),p=it(e,o+28),h=it(e,o+30),u=it(e,o+32),f=rt(e,o+42),g=new TextDecoder().decode(t.subarray(o+46,o+46+p));a.push({name:g,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:f}),o+=46+p+h+u}return a}async function Zt(s,e){const t=new DataView(s),n=new Uint8Array(s),i=it(t,e.localHeaderOffset+26),o=it(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+i+o,l=n.subarray(a,a+e.compressedSize);return e.compressionMethod===0?l:vo(l)}function Qt(s){return new DOMParser().parseFromString(s,"application/xml")}function yo(s){const e=s.replace(/\d+/g,"");let t=0;for(const n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}async function bo(s){const e=wo(s),t=e.find(d=>d.name==="xl/workbook.xml"),n=[];if(t){const c=Qt(new TextDecoder().decode(await Zt(s,t))).getElementsByTagName("sheet");for(let p=0;p<c.length;p++)n.push(c[p].getAttribute("name")||`Sheet${p+1}`),c[p].getAttribute("r:id")||c[p].getAttribute("id")}const i=[],o=e.find(d=>d.name==="xl/sharedStrings.xml");if(o){const c=Qt(new TextDecoder().decode(await Zt(s,o))).getElementsByTagName("si");for(let p=0;p<c.length;p++){const h=c[p].getElementsByTagName("t");let u="";for(let f=0;f<h.length;f++)u+=h[f].textContent||"";i.push(u)}}const l=e.filter(d=>/^xl\/worksheets\/sheet\d+\.xml$/.test(d.name)).sort((d,c)=>d.name.localeCompare(c.name,void 0,{numeric:!0})),r=[];for(let d=0;d<l.length;d++){const p=Qt(new TextDecoder().decode(await Zt(s,l[d]))).getElementsByTagName("row"),h=[];for(let u=0;u<p.length;u++){const f=p[u],g=[],v=f.getElementsByTagName("c");for(let m=0;m<v.length;m++){const y=v[m],x=y.getAttribute("r")||"",C=y.getAttribute("t")||"";let b="";if(C==="s"){const A=y.getElementsByTagName("v")[0],S=Number((A==null?void 0:A.textContent)||"0");b=i[S]??""}else if(C==="inlineStr"){const A=y.getElementsByTagName("t");for(let S=0;S<A.length;S++)b+=A[S].textContent||""}else{const A=y.getElementsByTagName("v")[0];b=(A==null?void 0:A.textContent)??""}const I=x?yo(x):m;g[I]=b}h.push(g.map(m=>m??""))}r.push({name:n[d]||`Sheet${d+1}`,rows:h})}return r}const Co=(()=>{const s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function So(s){let e=4294967295;for(let t=0;t<s.length;t++)e=Co[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function jn(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function Eo(s){let e="",t=s+1;for(;t>0;){const n=(t-1)%26;e=String.fromCharCode(65+n)+e,t=Math.floor((t-1)/26)}return e}function xo(s){const e=new TextEncoder,t=[],n=[];let i=0;for(const p of s){const h=e.encode(p.name),u=So(p.data),f=new Uint8Array(30+h.length),g=new DataView(f.buffer);g.setUint32(0,67324752,!0),g.setUint16(4,20,!0),g.setUint16(6,2048,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,8585,!0),g.setUint32(14,u,!0),g.setUint32(18,p.data.length,!0),g.setUint32(22,p.data.length,!0),g.setUint16(26,h.length,!0),g.setUint16(28,0,!0),f.set(h,30),t.push(f,p.data);const v=new Uint8Array(46+h.length),m=new DataView(v.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,2048,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,u,!0),m.setUint32(20,p.data.length,!0),m.setUint32(24,p.data.length,!0),m.setUint16(28,h.length,!0),m.setUint32(42,i,!0),v.set(h,46),n.push(v),i+=f.length+p.data.length}const o=n.reduce((p,h)=>p+h.length,0),a=new Uint8Array(22),l=new DataView(a.buffer);l.setUint32(0,101010256,!0),l.setUint16(8,s.length,!0),l.setUint16(10,s.length,!0),l.setUint32(12,o,!0),l.setUint32(16,i,!0);const r=t.reduce((p,h)=>p+h.length,0)+o+a.length,d=new Uint8Array(r);let c=0;for(const p of t)d.set(p,c),c+=p.length;for(const p of n)d.set(p,c),c+=p.length;return d.set(a,c),d}function ko(s){let e='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';return e+='<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>',s.forEach((t,n)=>{const i=n+1,a=t.some(l=>l.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${i}"${a}>`,t.forEach((l,r)=>{const d=`${Eo(r)}${i}`,c=l.bold?' s="1"':"";if(l.value===null||l.value===void 0||l.value===""){e+=`<c r="${d}"${c}/>`;return}typeof l.value=="number"&&isFinite(l.value)?e+=`<c r="${d}"${c}><v>${l.value}</v></c>`:typeof l.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${l.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${jn(String(l.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const Mo='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>';function Ro(s){const e=new TextEncoder,t=(p,h)=>p.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${h+1}`;let n="",i="",o="";s.forEach((p,h)=>{const u=t(p.name,h),f=h+1;n+=`<sheet name="${jn(u)}" sheetId="${f}" r:id="rId${f}"/>`,i+=`<Relationship Id="rId${f}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${f}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${f}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const a='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+o+"</Types>",l='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${n}</sheets></workbook>`,d='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+i+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(l)},{name:"xl/workbook.xml",data:e.encode(r)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(d)},{name:"xl/styles.xml",data:e.encode(Mo)}];return s.forEach((p,h)=>{c.push({name:`xl/worksheets/sheet${h+1}.xml`,data:e.encode(ko(p.rows))})}),new Blob([xo(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}class Lo{constructor(e){w(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(i=>typeof i=="string"?this.grid.getColumn(i):i).filter(i=>!!i);if(e.allColumns)return t.filter(i=>i.field||i.valueGetter);const n=this.grid.getColumns();return[...n.center,...n.left,...n.right]}getExportRows(e){const t=this.grid.getRowModel(),n=[],i=e.onlySelected===!0,o=e.skipGroups!==!1,a=e.skipFooters!==!1;return t.forEachNode(l=>{l.rowPinned==="top"&&e.skipPinnedTop!==!1||l.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&l.group&&!l.footer||a&&l.footer||i&&!l.selected||n.push(l)}),i&&n.length===0?this.getExportRows({...e,onlySelected:!1}):n}getCellValueForExport(e,t,n){let i=Ee(e,t,this.grid.getApi()),o=At(e,t,this.grid.getApi());if(n.processCellCallback){const l=n.processCellCallback({value:i,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(l!=null)return String(l)}const a=this.groupValue(e,t);return a!==void 0&&(i=a,o=i===null?"":String(i)),i instanceof Date?i.toISOString().slice(0,10):o??(i==null?"":String(i))}groupValue(e,t){var n;return t.group||t.footer?(n=t.groupData)==null?void 0:n[e.colId]:void 0}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),n=this.getExportRows(e),i=e.columnSeparator??",",o=[];if(!e.skipHeader){const l=t.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),i,e.suppressQuotes)),o.push(this.csvRow(l,i,e.suppressQuotes))}for(const l of n){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:l,api:this.grid.getApi()}))continue;const r=t.map(d=>this.getCellValueForExport(d,l,e));o.push(this.csvRow(r,i,e.suppressQuotes))}return o.join(`\r
24
+ `,new Blob([d.encode(g)],{type:"application/pdf"})}function ut(s,e){return s.getUint32(e,!0)}function ot(s,e){return s.getUint16(e,!0)}async function Co(s){var i;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(i=new Response(s).body)==null?void 0:i.pipeThrough(new DecompressionStream("deflate-raw"));if(!t)throw new Error("Failed to create a decompression stream");const n=await new Response(t).arrayBuffer();return new Uint8Array(n)}function So(s){const e=new DataView(s),t=new Uint8Array(s);let n=-1;for(let l=t.length-22;l>=0;l--)if(ut(e,l)===101010256){n=l;break}if(n<0)throw new Error("Not a valid XLSX (ZIP) file");const i=ot(e,n+10);let o=ut(e,n+16);const a=[];for(let l=0;l<i&&ut(e,o)===33639248;l++){const r=ot(e,o+10),d=ut(e,o+20),c=ut(e,o+24),p=ot(e,o+28),h=ot(e,o+30),u=ot(e,o+32),f=ut(e,o+42),g=new TextDecoder().decode(t.subarray(o+46,o+46+p));a.push({name:g,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:f}),o+=46+p+h+u}return a}async function tn(s,e){const t=new DataView(s),n=new Uint8Array(s),i=ot(t,e.localHeaderOffset+26),o=ot(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+i+o,l=n.subarray(a,a+e.compressedSize);return e.compressionMethod===0?l:Co(l)}function nn(s){return new DOMParser().parseFromString(s,"application/xml")}function Eo(s){const e=s.replace(/\d+/g,"");let t=0;for(const n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}async function xo(s){const e=So(s),t=e.find(d=>d.name==="xl/workbook.xml"),n=[];if(t){const c=nn(new TextDecoder().decode(await tn(s,t))).getElementsByTagName("sheet");for(let p=0;p<c.length;p++)n.push(c[p].getAttribute("name")||`Sheet${p+1}`),c[p].getAttribute("r:id")||c[p].getAttribute("id")}const i=[],o=e.find(d=>d.name==="xl/sharedStrings.xml");if(o){const c=nn(new TextDecoder().decode(await tn(s,o))).getElementsByTagName("si");for(let p=0;p<c.length;p++){const h=c[p].getElementsByTagName("t");let u="";for(let f=0;f<h.length;f++)u+=h[f].textContent||"";i.push(u)}}const l=e.filter(d=>/^xl\/worksheets\/sheet\d+\.xml$/.test(d.name)).sort((d,c)=>d.name.localeCompare(c.name,void 0,{numeric:!0})),r=[];for(let d=0;d<l.length;d++){const p=nn(new TextDecoder().decode(await tn(s,l[d]))).getElementsByTagName("row"),h=[];for(let u=0;u<p.length;u++){const f=p[u],g=[],v=f.getElementsByTagName("c");for(let m=0;m<v.length;m++){const w=v[m],k=w.getAttribute("r")||"",C=w.getAttribute("t")||"";let b="";if(C==="s"){const I=w.getElementsByTagName("v")[0],E=Number((I==null?void 0:I.textContent)||"0");b=i[E]??""}else if(C==="inlineStr"){const I=w.getElementsByTagName("t");for(let E=0;E<I.length;E++)b+=I[E].textContent||""}else{const I=w.getElementsByTagName("v")[0];b=(I==null?void 0:I.textContent)??""}const N=k?Eo(k):m;g[N]=b}h.push(g.map(m=>m??""))}r.push({name:n[d]||`Sheet${d+1}`,rows:h})}return r}const ko=(()=>{const s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function Mo(s){let e=4294967295;for(let t=0;t<s.length;t++)e=ko[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Jn(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function Ro(s){let e="",t=s+1;for(;t>0;){const n=(t-1)%26;e=String.fromCharCode(65+n)+e,t=Math.floor((t-1)/26)}return e}function Lo(s){const e=new TextEncoder,t=[],n=[];let i=0;for(const p of s){const h=e.encode(p.name),u=Mo(p.data),f=new Uint8Array(30+h.length),g=new DataView(f.buffer);g.setUint32(0,67324752,!0),g.setUint16(4,20,!0),g.setUint16(6,2048,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,8585,!0),g.setUint32(14,u,!0),g.setUint32(18,p.data.length,!0),g.setUint32(22,p.data.length,!0),g.setUint16(26,h.length,!0),g.setUint16(28,0,!0),f.set(h,30),t.push(f,p.data);const v=new Uint8Array(46+h.length),m=new DataView(v.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,2048,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,u,!0),m.setUint32(20,p.data.length,!0),m.setUint32(24,p.data.length,!0),m.setUint16(28,h.length,!0),m.setUint32(42,i,!0),v.set(h,46),n.push(v),i+=f.length+p.data.length}const o=n.reduce((p,h)=>p+h.length,0),a=new Uint8Array(22),l=new DataView(a.buffer);l.setUint32(0,101010256,!0),l.setUint16(8,s.length,!0),l.setUint16(10,s.length,!0),l.setUint32(12,o,!0),l.setUint32(16,i,!0);const r=t.reduce((p,h)=>p+h.length,0)+o+a.length,d=new Uint8Array(r);let c=0;for(const p of t)d.set(p,c),c+=p.length;for(const p of n)d.set(p,c),c+=p.length;return d.set(a,c),d}function To(s){let e='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';return e+='<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>',s.forEach((t,n)=>{const i=n+1,a=t.some(l=>l.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${i}"${a}>`,t.forEach((l,r)=>{const d=`${Ro(r)}${i}`,c=l.bold?' s="1"':"";if(l.value===null||l.value===void 0||l.value===""){e+=`<c r="${d}"${c}/>`;return}typeof l.value=="number"&&isFinite(l.value)?e+=`<c r="${d}"${c}><v>${l.value}</v></c>`:typeof l.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${l.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${Jn(String(l.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const No='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>';function Io(s){const e=new TextEncoder,t=(p,h)=>p.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${h+1}`;let n="",i="",o="";s.forEach((p,h)=>{const u=t(p.name,h),f=h+1;n+=`<sheet name="${Jn(u)}" sheetId="${f}" r:id="rId${f}"/>`,i+=`<Relationship Id="rId${f}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${f}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${f}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const a='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+o+"</Types>",l='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${n}</sheets></workbook>`,d='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+i+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(l)},{name:"xl/workbook.xml",data:e.encode(r)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(d)},{name:"xl/styles.xml",data:e.encode(No)}];return s.forEach((p,h)=>{c.push({name:`xl/worksheets/sheet${h+1}.xml`,data:e.encode(To(p.rows))})}),new Blob([Lo(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}class Ao{constructor(e){y(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(i=>typeof i=="string"?this.grid.getColumn(i):i).filter(i=>!!i);if(e.allColumns)return t.filter(i=>i.field||i.valueGetter);const n=this.grid.getColumns();return[...n.center,...n.left,...n.right]}getExportRows(e){const t=this.grid.getRowModel(),n=[],i=e.onlySelected===!0,o=e.skipGroups!==!1,a=e.skipFooters!==!1;return t.forEachNode(l=>{l.rowPinned==="top"&&e.skipPinnedTop!==!1||l.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&l.group&&!l.footer||a&&l.footer||i&&!l.selected||n.push(l)}),i&&n.length===0?this.getExportRows({...e,onlySelected:!1}):n}getCellValueForExport(e,t,n){let i=Ce(e,t,this.grid.getApi()),o=Ht(e,t,this.grid.getApi());if(n.processCellCallback){const l=n.processCellCallback({value:i,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(l!=null)return String(l)}const a=this.groupValue(e,t);return a!==void 0&&(i=a,o=i===null?"":String(i)),i instanceof Date?i.toISOString().slice(0,10):o??(i==null?"":String(i))}groupValue(e,t){var n;return t.group||t.footer?(n=t.groupData)==null?void 0:n[e.colId]:void 0}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),n=this.getExportRows(e),i=e.columnSeparator??",",o=[];if(!e.skipHeader){const l=t.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),i,e.suppressQuotes)),o.push(this.csvRow(l,i,e.suppressQuotes))}for(const l of n){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:l,api:this.grid.getApi()}))continue;const r=t.map(d=>this.getCellValueForExport(d,l,e));o.push(this.csvRow(r,i,e.suppressQuotes))}return o.join(`\r
25
25
  `)}csvRow(e,t,n){return e.map(i=>{const o=i==null?"":String(i);return!n&&(o.includes(t)||o.includes('"')||o.includes(`
26
- `))?`"${o.replace(/"/g,'""')}"`:o}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),n=this.getExportRows(e),i=[];e.skipHeader||i.push(t.map(o=>({value:o.headerName||o.field||o.colId,bold:!0})));for(const o of n)i.push(t.map(a=>{let l=Ee(a,o,this.grid.getApi());const r=this.groupValue(a,o);return r!==void 0&&(l=r),l instanceof Date&&(l=l.toISOString().slice(0,10)),{value:l}}));return Ro([{name:e.sheetName||"Sheet1",rows:i}])}exportToCsv(e={}){const t=this.getDataAsCsv(e);this.download(new Blob([t],{type:"text/csv;charset=utf-8;"}),this.fileName(e,"csv"))}exportToExcel(e={}){const t=this.getDataAsExcel(e);this.download(t,this.fileName(e,"xlsx"))}getDataAsPdf(e={}){var f;const t=this.getExportColumns(e),n=this.getExportRows(e),i=t.map(g=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(g.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(g=>({text:e.processHeaderCallback?e.processHeaderCallback({column:g,api:this.grid.getApi()}):g.headerName||g.field||g.colId,bold:!0,align:g.type==="numberColumn"||g.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const g of n)(f=e.shouldRowBeSkipped)!=null&&f.call(e,{node:g,api:this.grid.getApi()})||(o.push(t.map(v=>{let m=this.getCellValueForExport(v,g,e);if(e.processCellCallback){const y=e.processCellCallback({value:Ee(v,g,this.grid.getApi()),formattedValue:m,node:g,column:v,api:this.grid.getApi()});y!=null&&(m=String(y))}return{text:m,align:v.type==="numberColumn"||v.cellDataType===!0?"right":"left"}})),a.push(void 0));const l=18,r=e.pageSize||"a4-landscape",[d,c]=r.includes("portrait")?[595,842]:[842,595],p=c-64-(e.title?24:0),h=Math.max(5,Math.floor(p/l)),u=[];o.length===0&&u.push({columnWidths:i,rows:[],rowFill:[]});for(let g=0;g<o.length;g+=h)u.push({columnWidths:i,rows:o.slice(g,g+h),rowFill:a.slice(g,g+h)});return mo(u,{pageSize:r,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const n=e instanceof ArrayBuffer?e:await e.arrayBuffer(),o=(await bo(n))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],l=o.rows.slice(1).map(r=>{const d={};return a.forEach((c,p)=>{const h=c||`col${p+1}`,u=r[p]??"",f=String(u).trim();d[h]=f!==""&&!isNaN(Number(f))&&!/^0\d/.test(f)?Number(f):u}),d});return t.onSuccess?t.onSuccess(l):this.grid.getApi().setRowData(l),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:l}),l}fileName(e,t){const n=e.fileName||this.grid.getOptions().fileName||"export";return n.endsWith(`.${t}`)?n:`${n}.${t}`}download(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),1e3)}copyToClipboard(e={}){const t={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},n=this.getDataAsCsv(t);this.lastCopied=n,this.writeToClipboard(n),this.grid.getEventService().dispatchEvent("pasteStart",{}),this.grid.getEventService().dispatchEvent("pasteEnd",{})}cutToClipboard(e={}){this.copyToClipboard(e);const t=this.getExportRows({onlySelected:!0,skipGroups:!0,skipFooters:!0,...e});t.length&&this.grid.getApi().applyTransaction({remove:t.map(n=>n.data)})}pasteFromClipboard(){navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(e=>this.pasteText(e),()=>{this.lastCopied&&this.pasteText(this.lastCopied)}):this.lastCopied&&this.pasteText(this.lastCopied)}pasteText(e){const t=this.grid.getEditService().getFocusedCell(),n=this.grid.getRangeSelectionService().getRanges();let i,o;if(n.length>0){const p=n[0];i=p.rowStartIndex;const h=this.grid.getColumns().center,u=h.findIndex(f=>f.colId===p.colStartId);o=h[u]??h[0]}else if(t)i=t.rowIndex,o=t.column;else return;const a=e.replace(/\r/g,"").split(`
27
- `);a.length&&a[a.length-1]===""&&a.pop();const l=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=l.findIndex(p=>p.colId===o.colId),d=[],c=[];a.forEach((p,h)=>{const u=p.split(" "),f=i+h,g=this.grid.getDisplayedRowAtIndex(f);if(!g){const v={};u.forEach((m,y)=>{const x=l[r+y];x!=null&&x.field&&(v[x.field]=m)}),c.push(v);return}u.forEach((v,m)=>{const y=l[r+m];y&&this.grid.setCellValue(y,g,v,"paste")}),d.push(g)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const t=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t,()=>this.fallbackCopy(e,t)):this.fallbackCopy(e,t)}fallbackCopy(e,t){const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();try{document.execCommand("copy")}catch{}document.body.removeChild(n),t()}}const St=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Et=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class To{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var g,v;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const n=e.filter===!0?"text":e.filter,i=this.grid.getFilterService().getFilterInstance(e.colId),o=n==="set"?260:240,{ePopup:a}=this.popupService.createPopup(o,"ag-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=`Search ${e.headerName||e.field||""}`,a.appendChild(l);const r=i?{...i}:this.getDefaultModel(n);let d=i?{...i}:null;const c=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),close()},p=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),close()};if(n==="set")a.appendChild(this.buildSetFilter(e,r,m=>{d=m}));else if(n==="boolean"){const m=this.buildConditionSelect(["true","false"],String(r.filter??""),y=>{d={filterType:"boolean",filter:y==="true"}});a.appendChild(m)}else{const m=n==="number"?Et:St,y=this.buildConditionSelect(m,r.type||m[0],x=>{r.type=x,d={...r}});if(a.appendChild(y),r.type!=="blank"&&r.type!=="notBlank")if(n==="number"&&r.type==="inRange"){const x=document.createElement("div");x.className="ag-filter-inputs";const C=document.createElement("input");C.type="number",C.className="ag-filter-input",C.value=r.filter??"",C.placeholder=this.grid.t("from"),C.addEventListener("input",()=>{d={...r,filter:C.value,filterTo:b.value}});const b=document.createElement("input");b.type="number",b.className="ag-filter-input",b.value=r.filterTo??"",b.placeholder=this.grid.t("to"),b.addEventListener("input",()=>{d={...r,filter:C.value,filterTo:b.value}}),x.appendChild(C),x.appendChild(b),a.appendChild(x)}else if(n==="date"){const x=document.createElement("div");x.className="ag-filter-inputs";const C=document.createElement("input");C.type="date",C.className="ag-filter-input",C.value=r.dateFrom??"",C.addEventListener("input",()=>{d={...r,dateFrom:C.value,dateTo:b.value}});const b=document.createElement("input");b.type="date",b.className="ag-filter-input",b.value=r.dateTo??"",b.addEventListener("input",()=>{d={...r,dateFrom:C.value,dateTo:b.value}}),x.appendChild(C),x.appendChild(b),a.appendChild(x)}else{const x=document.createElement("input");x.type=n==="number"?"number":"text",x.className="ag-filter-input",x.value=r.filter??"",x.placeholder=this.grid.t("filterOoo"),x.addEventListener("input",()=>{d={...r,filter:x.value}}),x.addEventListener("keydown",C=>{C.key==="Enter"&&c()}),a.appendChild(x),setTimeout(()=>x.focus(),0)}else d={...r}}if(n==="text"||n==="number"){const m=document.createElement("div");m.className="ag-filter-second-condition";const y=document.createElement("select");y.className="ag-filter-condition",y.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,y.value=r.operator||"AND",m.appendChild(y);const x=this.buildConditionSelect(n==="number"?Et:St,((g=r.condition2)==null?void 0:g.type)||(n==="number"?Et:St)[0],b=>{d||(d={...r}),d.condition2={...d.condition2,type:b}});m.appendChild(x);const C=document.createElement("input");C.type=n==="number"?"number":"text",C.className="ag-filter-input",C.placeholder=this.grid.t("secondValue"),C.value=((v=r.condition2)==null?void 0:v.filter)??"",C.addEventListener("input",()=>{d||(d={...r}),d.condition2={...d.condition2,filter:C.value}}),m.appendChild(C),a.appendChild(m),y.addEventListener("change",()=>{d||(d={...r}),d.operator=y.value})}const h=document.createElement("div");h.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",c);const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",p),h.appendChild(f),h.appendChild(u),a.appendChild(h),this.popupService.positionAt(a,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,n){const i=document.createElement("div");i.className="ag-set-filter";const o=document.createElement("input");o.type="text",o.className="ag-filter-input",o.placeholder=this.grid.t("search"),i.appendChild(o);const a=new Set;this.grid.getRowModel().forEachNode(g=>{!g.group&&!g.footer&&a.add(Ee(e,g,this.grid.getApi()))});const r=[...a].sort((g,v)=>g===v?0:g<v?-1:1),d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((t.values||[]).map(g=>String(g))),p=()=>{d.innerHTML="";const g=o.value.toLowerCase();let v=0;for(const m of r){const y=m==null?"(Blanks)":String(m);if(g&&!y.toLowerCase().includes(g))continue;v++;const x=document.createElement("label");x.className="ag-set-filter-item";const C=document.createElement("input");C.type="checkbox",C.checked=c.has(String(m)),C.addEventListener("change",()=>{C.checked?c.add(String(m)):c.delete(String(m)),n({filterType:"set",values:[...c]})});const b=document.createElement("span");b.textContent=y,x.appendChild(C),x.appendChild(b),d.appendChild(x)}if(v===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),d.appendChild(m)}};o.addEventListener("input",p),p();const h=document.createElement("div");h.className="ag-set-filter-actions";const u=document.createElement("button");u.className="ag-button ag-button-small",u.textContent=this.grid.t("selectAll"),u.addEventListener("click",()=>{c.clear();for(const g of r)c.add(String(g));p(),n({filterType:"set",values:[...c]})});const f=document.createElement("button");return f.className="ag-button ag-button-small",f.textContent=this.grid.t("clearAll"),f.addEventListener("click",()=>{c.clear(),p(),n({filterType:"set",values:[]})}),h.appendChild(u),h.appendChild(f),i.appendChild(d),i.appendChild(h),n({filterType:"set",values:[...c]}),i}buildConditionSelect(e,t,n){const i=document.createElement("select");i.className="ag-filter-condition";for(const o of e){const a=document.createElement("option");a.value=o;const l=As[o];a.textContent=l?this.grid.t(l):o,o===t&&(a.selected=!0),i.appendChild(a)}return i.addEventListener("change",()=>n(i.value)),i}openMultiFilter(e,t){var x;const n=this.grid.getFilterService().getFilterInstance(e.colId),i=n&&n.filterType==="multi"?n:null,o=(x=i==null?void 0:i.filterModels)!=null&&x.length?i.filterModels.map(C=>({...C})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(i==null?void 0:i.operator)||"AND";const{ePopup:l,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,l.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const p=document.createElement("span");p.textContent=this.grid.t("join");const h=document.createElement("select");h.className="ag-filter-condition",h.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',h.value=a,h.addEventListener("change",()=>{a=h.value}),c.appendChild(p),c.appendChild(h),l.appendChild(c);const u=document.createElement("div");u.className="ag-multi-filter-list",l.appendChild(u);const f=()=>{u.innerHTML="",o.forEach((C,b)=>{const I=document.createElement("div");I.className="ag-multi-filter-row";const A=document.createElement("select");A.className="ag-filter-condition";const S=["text","number","date","set","boolean"];for(const T of S){const H=document.createElement("option");H.value=T,H.textContent=T.charAt(0).toUpperCase()+T.slice(1),T===C.filterType&&(H.selected=!0),A.appendChild(H)}A.addEventListener("change",()=>{o[b]={...this.getDefaultModel(A.value)},f()}),I.appendChild(A);const G=C.filterType==="number"?Et:St,E=this.buildConditionSelect(G,C.type||G[0],T=>{o[b].type=T});if(I.appendChild(E),C.filterType!=="blank"&&C.type!=="blank"&&C.type!=="notBlank"){const T=document.createElement("input");T.type=C.filterType==="number"?"number":"text",T.className="ag-filter-input",T.value=C.filter??"",T.placeholder=this.grid.t("value"),T.addEventListener("input",()=>{o[b].filter=T.value}),I.appendChild(T)}const k=document.createElement("button");k.className="ag-button ag-button-small",k.textContent="×",k.title=this.grid.t("removeFilter"),k.addEventListener("click",()=>{o.splice(b,1),f()}),I.appendChild(k),u.appendChild(I)})};f();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addFilter"),g.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),f()}),l.appendChild(g);const v=document.createElement("div");v.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",()=>{o.filter(b=>b.filter!==void 0&&b.filter!==""||b.type==="blank"||b.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(y),v.appendChild(m),l.appendChild(v),this.popupService.positionAt(l,t)}openAdvancedFilter(e){var x,C;const t=this.grid.getFilterService(),n=t.getAdvancedFilterModel(),i=(x=n==null?void 0:n.conditions)!=null&&x.length?n.conditions.map(b=>({...b})):[{colId:((C=this.grid.getColumns().center[0])==null?void 0:C.colId)??"",type:"contains",filter:""}];let o=(n==null?void 0:n.operator)||"AND";const{ePopup:a,close:l}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),a.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",a.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(b=>b.filter),p=()=>{d.innerHTML="",i.forEach((b,I)=>{const A=document.createElement("div");A.className="ag-advanced-filter-row";const S=document.createElement("select");S.className="ag-filter-condition";for(const R of c()){const O=document.createElement("option");O.value=R.colId,O.textContent=R.headerName||R.field||R.colId,R.colId===b.colId&&(O.selected=!0),S.appendChild(O)}S.addEventListener("change",()=>{i[I].colId=S.value}),A.appendChild(S);const G=this.grid.getColumn(b.colId),E=G&&G.filter!==!1?String(G.filter):"text",k=E==="number"?Et:St,T=this.buildConditionSelect(k,b.type||"contains",R=>{i[I].type=R});A.appendChild(T);const H=document.createElement("input");H.type=E==="number"?"number":"text",H.className="ag-filter-input",H.value=b.filter??"",H.placeholder=this.grid.t("value"),H.addEventListener("input",()=>{i[I].filter=H.value}),A.appendChild(H);const W=document.createElement("button");W.className="ag-button ag-button-small",W.textContent="×",W.addEventListener("click",()=>{i.splice(I,1),p()}),A.appendChild(W),d.appendChild(A)})};p();const h=document.createElement("button");h.className="ag-button ag-button-small",h.textContent="+ "+this.grid.t("addCondition"),h.addEventListener("click",()=>{var b;i.push({colId:((b=c()[0])==null?void 0:b.colId)??"",type:"contains",filter:""}),p()}),a.appendChild(h);const u=document.createElement("div");u.className="ag-multi-filter-operator";const f=document.createElement("span");f.textContent=this.grid.t("join");const g=document.createElement("select");g.className="ag-filter-condition",g.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',g.value=o,g.addEventListener("change",()=>{o=g.value}),u.appendChild(f),u.appendChild(g),a.appendChild(u);const v=document.createElement("div");v.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",()=>{const b=i.filter(I=>I.filter!==void 0&&I.filter!=="");b.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:b}):t.setAdvancedFilterModel(null),l()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{t.setAdvancedFilterModel(null),l()}),v.appendChild(y),v.appendChild(m),a.appendChild(v),this.popupService.positionAt(a,e)}openCustomFilter(e,t){const n=e.colDef.filterComponent;if(typeof n!="function")return;const i=this.grid.getFilterService(),o=n({column:e,colDef:e.colDef,api:this.grid.getApi(),model:i.getFilterInstance(e.colId)??null,onModelChange:r=>i.setColumnFilterModel(e,r),onGuiAttached:()=>{}}),{ePopup:a}=this.popupService.createPopup(260,"ag-filter-popup");a.innerHTML="";const l=typeof(o==null?void 0:o.getGui)=="function"?o.getGui():o;l instanceof HTMLElement&&a.appendChild(l),typeof(o==null?void 0:o.afterGuiAttached)=="function"&&o.afterGuiAttached(),this.popupService.positionAt(a,t)}getDefaultModel(e){return e==="number"?{filterType:"number",type:"equals",filter:""}:e==="date"?{filterType:"date",dateFrom:"",dateTo:""}:e==="set"?{filterType:"set",values:[]}:e==="boolean"?{filterType:"boolean",filter:!0}:{filterType:"text",type:"contains",filter:""}}isMeaningful(e){return e.filterType==="text"?!!e.filter||e.type==="blank"||e.type==="notBlank":e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0:!1}}class No{constructor(e){w(this,"filterModel",{});w(this,"advancedFilterModel",null);this.grid=e}getAdvancedFilterModel(){return this.advancedFilterModel}setAdvancedFilterModel(e){this.advancedFilterModel=e,this.onFilterChanged("api")}isAdvancedFilterEnabled(){return!!this.grid.getOptions().enableAdvancedFilter}doesNodePassAdvancedFilter(e){const t=this.advancedFilterModel;if(!t||!t.conditions||t.conditions.length===0)return!0;const n=this.grid.getRowModel(),i=typeof n.doesNodePassFilterModel=="function"?n.doesNodePassFilterModel.bind(n):null,o=t.conditions.map(a=>{const l=this.grid.getColumn(a.colId);return!l||!i?!0:i(e,l,{...a,filterType:l.filter===!0?"text":l.filter})});return t.operator==="OR"?o.some(Boolean):o.every(Boolean)}getFilterModel(){return this.filterModel}getFilterInstance(e){return this.filterModel[e]}setFilterModel(e){this.filterModel=e||{},this.onFilterChanged("api")}setColumnFilterModel(e,t){const n=typeof e=="string"?e:e.colId;t==null?delete this.filterModel[n]:this.filterModel[n]=t,this.onFilterChanged("api")}isFilterActive(e){const t=this.filterModel[e.colId];return t?t.filterType==="multi"?(t.filterModels||[]).some(i=>this.isModelMeaningful(i)):this.isModelMeaningful(t):!1}isModelMeaningful(e){return e.filterType==="text"?!!e.filter:e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":!1}handleFloatingFilterChange(e,t){if(t===""||t===null||t===void 0){delete this.filterModel[e.colId],this.onFilterChanged("uiFilterModified");return}switch(e.filter){case"number":this.filterModel[e.colId]={filterType:"number",type:"equals",filter:t};break;case"date":this.filterModel[e.colId]={filterType:"date",dateFrom:t,dateTo:t};break;case"boolean":this.filterModel[e.colId]={filterType:"boolean",filter:t==="true"};break;case"set":this.filterModel[e.colId]={filterType:"set",values:[t]};break;default:this.filterModel[e.colId]={filterType:"text",type:"contains",filter:t};break}this.onFilterChanged("uiFilterModified")}resetFilters(){this.filterModel={},this.onFilterChanged("api")}onFilterChanged(e){var n,i;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(i=(n=this.grid.getOptions()).onFilterChanged)==null||i.call(n,{api:t,source:e})}}class Io{constructor(e,t){w(this,"matches",[]);w(this,"activeMatch",0);w(this,"searchText","");w(this,"matchCase",!1);w(this,"ePopup",null);w(this,"eCount",null);w(this,"eInput",null);w(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const n=document.createElement("input");n.type="text",n.className="ag-find-input",n.placeholder=this.grid.translate("find","Find in grid..."),n.value=this.searchText,this.eInput=n,e.appendChild(n);const i=document.createElement("label");i.className="ag-find-case";const o=document.createElement("input");o.type="checkbox",o.checked=this.matchCase,o.addEventListener("change",()=>{this.matchCase=o.checked,this.find(this.searchText)}),i.appendChild(o),i.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(i);const a=document.createElement("span");a.className="ag-find-count",this.eCount=a,e.appendChild(a);const l=(c,p,h)=>{const u=document.createElement("button");return u.className="ag-button ag-button-small",u.textContent=c,u.title=p,u.addEventListener("click",h),e.appendChild(u),u};l("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),l("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),l("×",this.grid.translate("close","关闭"),()=>this.close()),n.addEventListener("input",()=>this.find(n.value)),n.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),c.shiftKey?this.findPrevious():this.findNext()):c.key==="Escape"&&this.close()}),this.grid.getRootElement(),e.style.position="absolute",e.style.left="50%",e.style.top="8px",e.style.transform="translateX(-50%)",e.style.display="flex",setTimeout(()=>n.focus(),0)}close(){var e;(e=this.closePopup)==null||e.call(this),this.ePopup=null,this.closePopup=null,this.eInput=null,this.eCount=null,this.matches=[],this.applyHighlight()}setFindText(e){this.searchText=e,this.eInput&&(this.eInput.value=e),this.find(e)}getFindText(){return this.searchText}getNumMatches(){return this.matches.length}getActiveMatch(){return this.activeMatch}find(e){if(this.searchText=e,this.matches=[],this.activeMatch=0,e){const t=this.grid.getColumns().center;this.grid.getRowModel().forEachNode((n,i)=>{if(!(n.group||n.footer))for(const o of t){const a=At(o,n,this.grid.getApi())??"",l=this.matchCase?a:a.toLowerCase(),r=this.matchCase?e:e.toLowerCase();l.includes(r)&&this.matches.push({rowIndex:i,colId:o.colId})}})}this.eCount&&(this.eCount.textContent=this.matches.length?`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`:this.grid.translate("noMatches","No matches")),this.applyHighlight()}findNext(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch+1)%this.matches.length,this.goToActive(),!0)}findPrevious(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch-1+this.matches.length)%this.matches.length,this.goToActive(),!0)}goToActive(){var o,a;const e=this.matches[this.activeMatch];if(!e)return;this.eCount&&(this.eCount.textContent=`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`);const t=(a=(o=this.grid).getPaginationService)==null?void 0:a.call(o);if(t!=null&&t.isEnabled()){const l=t.getPageSize(),r=Math.floor(e.rowIndex/l);r!==t.getCurrentPage()&&t.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const n=this.grid.getDisplayedRowAtIndex(e.rowIndex),i=this.grid.getColumn(e.colId);n&&i&&this.grid.getEditService().setFocusedCell(e.rowIndex,i)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,n]of e){let i=-1;this.grid.getRowModel().forEachNode((o,a)=>{o.id===t&&(i=a)});for(const o of n.getCellElements()){const a=o.dataset.colid,l=this.matches.findIndex(r=>r.rowIndex===i&&r.colId===a);o.classList.toggle("ag-find-match",l>=0),o.classList.toggle("ag-find-active-match",l>=0&&l===this.activeMatch)}}}}class Ao{constructor(e,t){this.grid=e,this.popupService=t}isFormulaColumn(e){return typeof e.field=="string"&&e.field.trimStart().startsWith("=")}openFormulaEditor(e,t){const{ePopup:n,close:i}=this.popupService.createPopup(460,"ag-formula-editor");n.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,n.appendChild(o);const a=document.createElement("textarea");a.className="ag-formula-input",a.rows=3,a.value=this.isFormulaColumn(e)?e.field:"=",a.placeholder=this.grid.t("formulaPlaceholder"),n.appendChild(a);const l=document.createElement("div");l.className="ag-formula-preview";const r=()=>{const g=this.grid.getDisplayedRowAtIndex(0);if(!g){l.textContent="";return}try{const v=bt(a.value,{data:g.data});l.textContent=`${this.grid.t("formulaPreview")}: ${v==null?"":String(v)}`,l.classList.remove("ag-formula-error")}catch(v){l.textContent=`${this.grid.t("formulaError")}: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||this.grid.t("invalidFormula")}`,l.classList.add("ag-formula-error")}};a.addEventListener("input",r),n.appendChild(l);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent=this.grid.t("functions"),d.appendChild(c);const p=document.createElement("div");p.className="ag-formula-functions-list";for(const g of It){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=g,v.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${g}()`,a.focus(),r()}),p.appendChild(v)}d.appendChild(p),n.appendChild(d);const h=document.createElement("div");h.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",()=>{const g=a.value.trim(),v=this.grid.getColumnModel(),m=v.getColumn(e.colId);m&&(m.field=g==="="||g===""?e.field:g,m.colDef={...m.colDef,field:m.field},g!=="="&&g!==""&&(m.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),i()});const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",()=>{a.value="=",r()}),h.appendChild(f),h.appendChild(u),n.appendChild(h),this.popupService.positionAt(n,t),r()}}class $o{constructor(e,t){w(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,n,i){const o=this.runtimeNotes.get(this.keyOf(e,t));if(o!==void 0)return o;if(typeof n=="function")return n(i);if(typeof n=="string")return n}setNote(e,t,n){const i=this.keyOf(e,t);n==null||n===""?this.runtimeNotes.delete(i):this.runtimeNotes.set(i,n),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,n){const i=this.grid.getColumn(t),o=this.grid.getRowNode(e),a=this.getNote(e,t,i==null?void 0:i.colDef.note,{data:o==null?void 0:o.data,node:o,column:i,api:this.grid.getApi()})??"",{ePopup:l,close:r}=this.popupService.createPopup(280,"ag-note-editor");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`${this.grid.t("note")} — ${(i==null?void 0:i.headerName)||t}`,l.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=a,c.placeholder=this.grid.t("writeNote"),l.appendChild(c);const p=document.createElement("div");p.className="ag-popup-buttons";const h=document.createElement("button");h.className="ag-button ag-button-primary",h.textContent=this.grid.t("save"),h.addEventListener("click",()=>{this.setNote(e,t,c.value.trim()||void 0),r()});const u=document.createElement("button");u.className="ag-button",u.textContent=this.grid.t("delete"),u.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),p.appendChild(u),p.appendChild(h),l.appendChild(p),this.popupService.positionAt(l,n),setTimeout(()=>c.focus(),0)}}class Fo{constructor(e){w(this,"eOverlayWrapper");w(this,"current",null);this.grid=e,this.eOverlayWrapper=document.createElement("div"),this.eOverlayWrapper.className="ag-overlay",this.eOverlayWrapper.style.display="none";const t=e.getRowRenderer().getViewport();t.style.position="relative",this.eOverlayWrapper.style.position="absolute",this.eOverlayWrapper.style.inset="0",this.eOverlayWrapper.style.zIndex="10",t.appendChild(this.eOverlayWrapper)}show(e,t){this.current=e,this.eOverlayWrapper.innerHTML="";const n=document.createElement("div");n.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const i=document.createElement("div");if(i.className="ag-overlay-text",i.textContent=t,e==="loading"){const o=document.createElement("div");o.className="ag-overlay-loading-spinner",n.appendChild(o)}n.appendChild(i),this.eOverlayWrapper.appendChild(n),this.eOverlayWrapper.style.display="flex"}showLoadingOverlay(){this.show("loading",this.grid.translate("loadingOoo","Loading..."))}showNoRowsOverlay(){this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show"))}hideOverlay(){this.current=null,this.eOverlayWrapper.style.display="none",this.eOverlayWrapper.innerHTML=""}updateAuto(){const e=this.grid.getRowModel();if(!!this.grid.getOptions().__loadingRows){this.showLoadingOverlay();return}e.getRowCount()===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}class Kn{constructor(e,t){w(this,"enabled");w(this,"pageSize");w(this,"currentPage",0);w(this,"pageSizeSelector");w(this,"ePanel");w(this,"ePageInfo");w(this,"ePageInput");w(this,"ePageSizeContainer");w(this,"eFromToContainer");this.grid=e,this.eventService=t;const n=e.getOptions();this.enabled=n.pagination===!0,this.pageSize=n.paginationPageSize??100,this.pageSizeSelector=n.paginationPageSizeSelector??[20,50,100,500,1e3],this.ePanel=document.createElement("div"),this.ePanel.className="ag-pagination-panel",this.enabled||(this.ePanel.style.display="none");const i=document.createElement("div");i.className="ag-pagination-buttons",this.ePanel.appendChild(i),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",i.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",i.appendChild(this.eFromToContainer);const o=document.createElement("span");if(o.className="ag-pagination-page-label",o.textContent=`${this.grid.translate("page","Page")}`,i.appendChild(o),this.ePageInput=document.createElement("input"),this.ePageInput.className="ag-pagination-page-input",this.ePageInput.type="number",this.ePageInput.min="1",this.ePageInput.value="1",this.ePageInput.title=this.grid.translate("pageNumber","输入页码"),this.ePageInput.addEventListener("change",()=>{const a=parseInt(this.ePageInput.value,10);isNaN(a)||this.goToPage(a-1)}),i.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",i.appendChild(this.ePageInfo),this.pageSizeSelector){const a=this.ePageSizeContainer,l=document.createElement("span");l.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(l);const r=document.createElement("select");r.className="ag-pagination-page-size-select";const d=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const c of d){const p=document.createElement("option");p.value=String(c),p.textContent=String(c),c===this.pageSize&&(p.selected=!0),r.appendChild(p)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),a.appendChild(r)}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),n=Math.max(0,Math.min(t-1,e));if(n===this.currentPage){this.update();return}this.currentPage=n,this.grid.refreshModel("everything"),this.update(),this.grid.getRowRenderer().setVerticalScrollTop(0)}goToNextPage(){this.goToPage(this.currentPage+1)}goToPreviousPage(){this.goToPage(this.currentPage-1)}goToFirstPage(){this.goToPage(0)}goToLastPage(){this.goToPage(this.getTotalPages()-1)}update(){var l,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),n=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),i=n===0?0:this.currentPage*this.pageSize+1,o=Math.min(n,(this.currentPage+1)*this.pageSize);this.ePageInfo.textContent=`${this.grid.translate("of","/")} ${e}`,this.ePageInput.value=String(this.currentPage+1),this.ePageInput.max=String(e);const a=this.grid.translate("rangeTo","至");this.eFromToContainer.textContent=n===0?`0 ${a} 0 ${this.grid.translate("of","/")} 0`:`${i.toLocaleString()} ${a} ${o.toLocaleString()} ${this.grid.translate("of","/")} ${n.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:n}),(r=(l=this.grid.getOptions()).onPaginationChanged)==null||r.call(l,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Do{constructor(e){w(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,t=""){const n=document.createElement("div");n.className=`ag-popup ${t}`.trim(),n.style.width=`${e}px`,n.style.display="none";const i={ePopup:n},o=()=>{var d;this.openPopups.has(i)&&(this.openPopups.delete(i),n.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",r,!0),(d=i.onClose)==null||d.call(i))},a=d=>{i.onClose=d},l=d=>{if(!n.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){o();return}n.contains(d.target)||o()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),o())};return this.getParent().appendChild(n),this.openPopups.add(i),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",r,!0),{ePopup:n,close:o,onClose:a}}positionAt(e,t,n=0){const i=this.grid.getRootElement().getBoundingClientRect(),o=t.getBoundingClientRect(),a=e.offsetWidth||220;let l=o.left-i.left+n;const r=i.width-a-4;l>r&&(l=r),l<4&&(l=4);const d=o.bottom-i.top+2;e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}class Po{constructor(e,t){w(this,"ranges",[]);w(this,"currentRange",null);w(this,"eOverlay");w(this,"eHandle");w(this,"dragState",null);this.grid=e,this.eventService=t;const n=e.getRowRenderer().getContainer();n.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",n.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",n.appendChild(this.eHandle),document.addEventListener("mousemove",this.onMouseMove.bind(this)),document.addEventListener("mouseup",this.onMouseUp.bind(this)),t.addEventListener("bodyScroll",()=>this.updateOverlay())}isEnabled(){return!!this.grid.getOptions().enableRangeSelection}getRanges(){return this.ranges}clearRanges(){this.ranges=[],this.currentRange=null,this.updateOverlay(),this.applyHighlight(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0})}onCellMouseDown(e){if(!this.isEnabled())return;const{event:t,column:n,rowIndex:i}=e;if(t.button!==0)return;if(t.shiftKey&&this.ranges.length>0){const a=this.ranges[this.ranges.length-1];this.currentRange={...a,rowEndIndex:i,colEndId:n.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const o={rowStartIndex:i,rowEndIndex:i,colStartId:n.colId,colEndId:n.colId};this.currentRange=o,this.dragState={startRange:o,mode:"create"},this.updateOverlay()}onHandleMouseDown(e){this.currentRange&&(e.stopPropagation(),this.dragState={startRange:{...this.currentRange},mode:"handle"})}onMouseMove(e){if(!this.dragState||!this.currentRange)return;const t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;const n=t.closest(".ag-cell");if(!(n!=null&&n.dataset.colid))return;const i=n.closest(".ag-row");if(!(i!=null&&i.dataset.rowid))return;const o=this.grid.getRowModel().getRowNode(i.dataset.rowid);if(!o)return;let a=-1;if(this.grid.getRowModel().forEachNode((r,d)=>{r.id===o.id&&(a=d)}),a<0)return;const l=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(l.rowStartIndex,a),rowEndIndex:Math.max(l.rowStartIndex,a),colStartId:l.colStartId,colEndId:n.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(l.rowStartIndex,a),this.currentRange.colEndId=n.dataset.colid),this.updateOverlay()}onMouseUp(){!this.dragState||!this.currentRange||(this.dragState=null,this.ranges=[this.currentRange],this.applyHighlight(),this.updateOverlay(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0}))}getCenterColumns(){return this.grid.getColumns().center}getRangeBounds(e){const t=this.getCenterColumns(),n=t.findIndex(g=>g.colId===e.colStartId),i=t.findIndex(g=>g.colId===e.colEndId);if(n<0||i<0)return null;const o=Math.min(n,i),a=Math.max(n,i);let l=0,r=0;for(let g=0;g<=a;g++)g<o?l+=t[g].width:r+=t[g].width;const c=this.grid.getRowRenderer().getRowOffsets(),p=Math.min(e.rowStartIndex,e.rowEndIndex),h=Math.max(e.rowStartIndex,e.rowEndIndex),u=c[p]??p*(this.grid.getOptions().rowHeight??42);let f=0;for(let g=p;g<=h;g++){const v=this.grid.getDisplayedRowAtIndex(g);f+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:u,left:l,width:r,height:f}}updateOverlay(){const e=this.currentRange;if(!e||!this.isEnabled()){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}const t=this.getRangeBounds(e);if(!t){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}this.eOverlay.style.display="block",this.eOverlay.style.top=`${t.top}px`,this.eOverlay.style.left=`${t.left}px`,this.eOverlay.style.width=`${t.width}px`,this.eOverlay.style.height=`${t.height}px`,this.eHandle.style.display="block",this.eHandle.style.top=`${t.top+t.height-4}px`,this.eHandle.style.left=`${t.left+t.width-4}px`,this.eHandle.onmousedown=n=>this.onHandleMouseDown(n)}applyHighlight(){const e=this.ranges,t=this.grid.getRowRenderer().getRowComps(),n=this.getCenterColumns();for(const[i,o]of t){let a=-1;if(this.grid.getRowModel().forEachNode((l,r)=>{l.id===i&&(a=r)}),!(a<0))for(const l of o.getCellElements()){const r=l.dataset.colid,d=n.findIndex(h=>h.colId===r);let c=!1,p=!1;for(const h of e){const u=n.findIndex(x=>x.colId===h.colStartId),f=n.findIndex(x=>x.colId===h.colEndId),g=Math.min(h.rowStartIndex,h.rowEndIndex),v=Math.max(h.rowStartIndex,h.rowEndIndex),m=Math.min(u,f),y=Math.max(u,f);a>=g&&a<=v&&d>=m&&d<=y&&(c=!0,a===h.rowStartIndex&&d===u&&(p=!0))}l.classList.toggle("ag-cell-range-selected",c),l.classList.toggle("ag-cell-range-anchor",p)}}}getRangeCells(e){const t=this.getCenterColumns(),n=t.findIndex(c=>c.colId===e.colStartId),i=t.findIndex(c=>c.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),l=Math.min(n,i),r=Math.max(n,i),d=[];for(let c=o;c<=a;c++){const p=this.grid.getDisplayedRowAtIndex(c);if(p)for(let h=l;h<=r;h++)t[h]&&d.push({node:p,column:t[h]})}return d}getCurrentRange(){return this.currentRange}onGridKeyDown(e){if(this.isEnabled()){if((e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().copyToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="x"||e.key==="X")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().cutToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().pasteFromClipboard());return}if((e.keyCode===46||e.keyCode===8)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const n of this.getRangeCells(t))this.grid.setCellValue(n.column,n.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}class Ho{constructor(e,t){w(this,"dragState",null);w(this,"onMouseMoveBind",e=>this.onMouseMove(e));w(this,"onMouseUpBind",e=>this.onMouseUp(e));this.grid=e,this.eventService=t}isEnabled(){const e=this.grid.getOptions();return!!e.rowDragManaged||!!e.rowDragEnt||this.hasDragHandle()}hasDragHandle(){return this.grid.getAllColumns().some(e=>e.rowDrag)}startDrag(e,t){if(!this.isEnabled()||this.dragState)return;t.preventDefault();const n=document.createElement("div");n.className="ag-row-drag-ghost",n.textContent=this.rowLabel(e),document.body.appendChild(n);const i=document.createElement("div");i.className="ag-row-drop-indicator",i.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(i),this.dragState={rowNode:e,ghost:n,startY:t.clientY,overIndex:null,indicator:i},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var i;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],n=t!=null&&t.field?(i=e.data)==null?void 0:i[t.field]:"";return String(n??e.id)}onMouseMove(e){const t=this.dragState;if(!t)return;t.ghost.style.left=`${e.clientX+8}px`,t.ghost.style.top=`${e.clientY+8}px`;const n=document.elementFromPoint(e.clientX,e.clientY),i=n==null?void 0:n.closest(".ag-row");if(!(i!=null&&i.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let o=-1;if(this.grid.getRowModel().forEachNode((a,l)=>{a.id===i.dataset.rowid&&(o=l)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),l=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),r=e.clientY>i.getBoundingClientRect().top+l/2,d=(a[o]??0)+(r?l:0);t.indicator.style.display="block",t.indicator.style.top=`${d-1}px`}else t.indicator.style.display="none"}onMouseUp(e){const t=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!t)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),t.ghost.remove(),t.indicator.remove();const n=this.grid.getApi(),i=this.grid.getOptions(),o=t.overIndex,a=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:n,node:t.rowNode,overIndex:o,overNode:o!==null?this.grid.getDisplayedRowAtIndex(o):void 0,y:e.clientY}),i.rowDragManaged&&a>=0&&o!==null&&o!==a&&this.moveRow(a,o,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((n,i)=>{n.id===e.id&&(t=i)}),t}moveRow(e,t,n){const i=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=i.length)return;const[o]=i.splice(e,1),a=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),i.splice(Math.max(0,Math.min(i.length,a+1)),0,o),this.grid.getApi().setRowData(i),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:o}})}}class Oo{constructor(e){w(this,"ePanel");w(this,"eChips");this.grid=e,this.ePanel=document.createElement("div"),this.ePanel.className="ag-row-group-panel";const t=document.createElement("span");t.className="ag-row-group-panel-label",t.textContent=this.grid.t("rowGroups"),this.ePanel.appendChild(t),this.eChips=document.createElement("div"),this.eChips.className="ag-row-group-panel-chips",this.ePanel.appendChild(this.eChips),this.eChips.addEventListener("dragover",o=>{o.preventDefault(),this.eChips.classList.add("ag-drag-over")}),this.eChips.addEventListener("dragleave",()=>this.eChips.classList.remove("ag-drag-over")),this.eChips.addEventListener("drop",o=>{var l;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(l=o.dataTransfer)==null?void 0:l.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const n=e.getOptions();(n.rowGroupPanelShow==="always"||n.rowGroupPanelShow==="onlyWhenGrouping")&&e.getMainElement().insertBefore(this.ePanel,e.getHeaderElement()),this.refresh(),e.getEventService().addEventListener("columnRowGroupChanged",()=>this.refresh()),e.getEventService().addEventListener("modelUpdated",()=>this.refreshVisibility())}refresh(){this.eChips.innerHTML="";const e=this.grid.getColumnModel().getRowGroupColumns();for(const t of e){const n=document.createElement("div");n.className="ag-row-group-chip",n.draggable=!0,n.addEventListener("dragstart",a=>{var l;(l=a.dataTransfer)==null||l.setData("text/plain",t.colId)});const i=document.createElement("span");i.textContent=t.headerName,n.appendChild(i);const o=document.createElement("button");o.className="ag-row-group-chip-remove",o.textContent="×",o.title=this.grid.t("remove"),o.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(t)),n.appendChild(o),this.eChips.appendChild(n)}if(e.length===0){const t=document.createElement("span");t.className="ag-column-group-hint",t.textContent=this.grid.t("dragColumnsHere"),this.eChips.appendChild(t)}this.refreshVisibility()}refreshVisibility(){const e=this.grid.getOptions().rowGroupPanelShow;if(e==="always")this.ePanel.style.display="";else if(e==="onlyWhenGrouping"){const t=this.grid.getColumnModel().isRowGroupActive();this.ePanel.style.display=t?"":"none"}}}class Bo{constructor(e,t,n){w(this,"selectedNodes",new Set);w(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=t,this.isNodeSelectable=n}isEnabled(){return!!this.getOptions().rowSelection}getSelectedNodes(){return[...this.selectedNodes]}getSelectedRows(){return[...this.selectedNodes].map(e=>e.data)}getSelectedCount(){return this.selectedNodes.size}isNodeSelected(e){return this.selectedNodes.has(e)}selectNode(e,t=!1){this.isEnabled()&&this.isNodeSelectable(e)&&(t&&this.getOptions().rowSelection==="multiple"?this.deselectAll():t&&this.deselectAll(),!this.selectedNodes.has(e)&&(this.selectedNodes.add(e),e.selected=!0,this.lastSelectedNode=e,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!0),this.dispatchChanged()))}deselectNode(e){this.selectedNodes.has(e)&&(this.selectedNodes.delete(e),e.selected=!1,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!1),this.dispatchChanged())}selectChildrenRecursively(e,t){if(e.children)for(const n of e.children)n.footer||n.detailNode||(t?this.isNodeSelectable(n)&&(this.selectedNodes.add(n),n.selected=!0):(this.selectedNodes.delete(n),n.selected=!1),this.selectChildrenRecursively(n,t))}selectAll(){!this.isEnabled()||this.getOptions().rowSelection!=="multiple"||this.selectAllFiltered()}selectAllFiltered(){if(!this.isEnabled())return;const e=this.getOptions().__rowModel;e!=null&&e.forEachNode&&e.forEachNode(t=>{this.isNodeSelectable(t)&&!t.footer&&(this.selectedNodes.add(t),t.selected=!0)}),this.dispatchChanged()}deselectAll(){for(const e of this.selectedNodes)e.selected=!1;this.selectedNodes.clear(),this.lastSelectedNode=null,this.dispatchChanged()}toggleNode(e){this.selectedNodes.has(e)?this.deselectNode(e):this.selectNode(e,!1)}handleRowClick(e,t){if(!this.isEnabled()||this.getOptions().suppressRowClickSelection)return!1;const n=this.getOptions().rowSelection==="multiple",i=t.ctrlKey||t.metaKey,o=t.shiftKey;return n?o&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):i?(this.toggleNode(e),!0):(this.getOptions().rowMultiSelectWithClick?this.selectNode(e,!1):this.selectNode(e,!0),!0):(this.selectNode(e,!0),!0)}selectRange(e,t){const n=this.getOptions().__rowModel;if(!(n!=null&&n.forEachNode))return;let i=-1,o=-1,a=0;if(n.forEachNode(d=>{d===e&&(i=a),d===t&&(o=a),a++}),i<0||o<0)return;const l=Math.min(i,o),r=Math.max(i,o);a=0,n.forEachNode(d=>{a>=l&&a<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(i=>t.add(i));let n=!1;for(const i of this.selectedNodes)t.has(i)?i.selected=!0:n=!0;if(n){for(const i of[...this.selectedNodes])t.has(i)||this.selectedNodes.delete(i);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let t=0,n=0;return e!=null&&e.forEachNode&&e.forEachNode(i=>{i.footer||!this.isNodeSelectable(i)||(t++,i.selected&&n++)}),{checked:t>0&&n===t,indeterminate:n>0&&n<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Vo{constructor(e){w(this,"eBar");w(this,"eButtons");w(this,"ePanel");w(this,"panels",[]);w(this,"activePanelId",null);w(this,"visible",!1);w(this,"position");var n,i;this.grid=e;const t=e.getOptions();if(this.position=typeof t.sideBar=="object"&&((n=t.sideBar)!=null&&n.position)?t.sideBar.position:"right",this.eBar=document.createElement("div"),this.eBar.className=`ag-side-bar ag-side-bar-${this.position}`,this.eButtons=document.createElement("div"),this.eButtons.className="ag-side-buttons",this.ePanel=document.createElement("div"),this.ePanel.className="ag-side-bar-panel",this.eBar.appendChild(this.eButtons),this.eBar.appendChild(this.ePanel),t.sideBar){const o=typeof t.sideBar=="object"?t.sideBar:null;o!=null&&o.toolPanels?this.panels=o.toolPanels.map(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const l=(o==null?void 0:o.defaultToolPanel)||((i=this.panels[0])==null?void 0:i.id)||"columns";this.buildButtons(),this.openPanel(l)}else this.eBar.style.display="none"}defaultLabel(e){switch(e){case"columns":return this.grid.t("columns");case"filters":return this.grid.t("filters");case"charts":return this.grid.t("charts");default:return e}}buildButtons(){this.eButtons.innerHTML="";for(const e of this.panels){const t=document.createElement("button");t.className="ag-side-button",t.textContent=e.label,t.title=e.label,t.dataset.panelId=e.id,e.id===this.activePanelId&&t.classList.add("ag-selected"),t.addEventListener("click",()=>{this.activePanelId===e.id&&this.visible?this.setVisible(!1):(this.visible=!0,this.eBar.style.display="",this.openPanel(e.id)),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"sideBarButtonClicked",api:this.grid.getApi()})}),this.eButtons.appendChild(t)}}getElement(){return this.eBar}setPosition(e){this.position=e,this.eBar.classList.remove("ag-side-bar-left","ag-side-bar-right"),this.eBar.classList.add(`ag-side-bar-${e}`)}setVisible(e){this.visible=e,this.eBar.style.display=e?"":"none",this.grid.onGridSizeChanged(),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"api",api:this.grid.getApi()})}isVisible(){return this.visible}openPanel(e){this.activePanelId=e;for(const t of this.eButtons.querySelectorAll(".ag-side-button"))t.classList.toggle("ag-selected",t.dataset.panelId===e);switch(this.ePanel.innerHTML="",e){case"columns":this.ePanel.appendChild(this.buildColumnsPanel());break;case"filters":this.ePanel.appendChild(this.buildFiltersPanel());break;case"charts":this.ePanel.appendChild(this.grid.getChartService().buildChartPanel());break;default:{const t=document.createElement("div");t.className="ag-side-bar-empty",t.textContent=e,this.ePanel.appendChild(t)}}}getActivePanel(){return this.activePanelId}refresh(){this.activePanelId&&this.openPanel(this.activePanelId)}buildColumnsPanel(){const e=document.createElement("div");e.className="ag-column-panel";const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const n=document.createElement("div");n.className="ag-column-panel-columns",e.appendChild(n);const i=()=>{const d=t.value.toLowerCase();n.innerHTML="";const c=this.grid.getColumnModel().getColumns(),p=c.filter(h=>h.pinned!=="left"&&h.pinned!=="right").concat(c.filter(h=>h.pinned==="left"||h.pinned==="right"));for(const h of p)d&&!h.headerName.toLowerCase().includes(d)&&!h.colId.toLowerCase().includes(d)||n.appendChild(this.buildColumnItem(h));if(!n.children.length){const h=document.createElement("div");h.className="ag-side-bar-empty",h.textContent=this.grid.t("noMatchingColumns"),n.appendChild(h)}};t.addEventListener("input",i),i();const o=document.createElement("div");o.className="ag-column-panel-groups";const a=document.createElement("div");a.className="ag-column-panel-section-title",a.textContent=this.grid.t("rowGroups"),o.appendChild(a);const l=document.createElement("div");l.className="ag-column-group-list",o.appendChild(l);const r=()=>{l.innerHTML="";const d=this.grid.getColumnModel().getRowGroupColumns();if(d.length===0){const c=document.createElement("div");c.className="ag-column-group-hint",c.textContent=this.grid.t("dragColumnsHere"),l.appendChild(c)}for(const c of d){const p=document.createElement("div");p.className="ag-column-group-item",p.draggable=!0,p.addEventListener("dragstart",f=>{var g;(g=f.dataTransfer)==null||g.setData("text/plain",c.colId)}),p.addEventListener("dragover",f=>f.preventDefault()),p.addEventListener("drop",f=>{var v;f.preventDefault();const g=(v=f.dataTransfer)==null?void 0:v.getData("text/plain");g&&this.grid.getColumnModel().setRowGroupColumns([...d.map(m=>m.colId),g])});const h=document.createElement("span");h.textContent=c.headerName,p.appendChild(h);const u=document.createElement("button");u.className="ag-column-group-remove",u.textContent="×",u.title=this.grid.t("remove"),u.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(c)),p.appendChild(u),l.appendChild(p)}};return r(),l.addEventListener("dragover",d=>d.preventDefault()),l.addEventListener("drop",d=>{var p;d.preventDefault();const c=(p=d.dataTransfer)==null?void 0:p.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&i()}),e}buildColumnItem(e){const t=document.createElement("div");t.className="ag-column-select-column",t.draggable=!0,t.dataset.colid=e.colId;const n=document.createElement("input");n.type="checkbox",n.className="ag-column-select-checkbox",n.checked=e.visible,n.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,n.checked)}),t.appendChild(n);const i=document.createElement("span");i.className="ag-column-select-label",i.textContent=e.headerName||e.colId,t.appendChild(i);const o=document.createElement("span");if(o.className="ag-column-select-actions",e.enableRowGroup&&e.field){const l=document.createElement("button");l.className="ag-column-select-action",l.title=this.grid.t("groupByThisColumn"),l.textContent="≡",l.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(l)}const a=document.createElement("button");return a.className="ag-column-select-action",a.title=this.grid.t("pinColumnTitle"),a.textContent="📌",a.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),o.appendChild(a),t.appendChild(o),t}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent=`${this.grid.t("advancedFilter")}…`,o.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(o)),e.appendChild(o);const a=this.grid.getFilterService().getAdvancedFilterModel();if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(l)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const n=document.createElement("div");n.className="ag-filters-panel-list",e.appendChild(n);const i=()=>{const o=t.value.toLowerCase();n.innerHTML="";const a=this.grid.getColumns().center.filter(l=>l.filter);for(const l of a)o&&!l.headerName.toLowerCase().includes(o)||n.appendChild(this.buildFilterItem(l));if(!n.children.length){const l=document.createElement("div");l.className="ag-side-bar-empty",l.textContent=this.grid.t("noMatchingColumns"),n.appendChild(l)}};return t.addEventListener("input",i),i(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&i()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),n=document.createElement("div");n.className="ag-filters-tool-panel-item";const i=document.createElement("div");i.className="ag-filters-tool-panel-item-header";const o=document.createElement("span");o.className="ag-filters-tool-panel-item-label",o.textContent=e.headerName||e.colId,i.appendChild(o);const a=t.isFilterActive(e);if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.innerHTML=zn,i.appendChild(l)}if(n.appendChild(i),e.filter==="set"){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=a?"Edit filter":"Add filter",l.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,l)),n.appendChild(l)}else if(e.filter==="date"){const l=document.createElement("input");l.type="date",l.className="ag-filter-input";const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.dateFrom)??"",l.addEventListener("change",()=>{t.setColumnFilterModel(e,l.value?{filterType:"date",dateFrom:l.value,dateTo:l.value}:null)}),n.appendChild(l)}else{const l=document.createElement("input");l.type=e.filter==="number"?"number":"text",l.className="ag-filter-input",l.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.filter)??"",l.addEventListener("input",()=>{t.handleFloatingFilterChange(e,l.value)}),n.appendChild(l)}if(a){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=this.grid.t("clear"),l.addEventListener("click",()=>t.setColumnFilterModel(e,null)),n.appendChild(l)}return n}}class Go{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,n){const i=this.grid.getOptions().suppressMultiSort,o=n&&!i&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,a=this.getSortingOrder(),l=e.sort;let r=a.indexOf(l)+1;r>=a.length&&(r=0);const d=a[r];if(!o)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,n)=>(t.sortIndex??99)-(n.sortIndex??99)).forEach((t,n)=>t.sortIndex=n)}getSortModel(){return this.grid.getAllColumns().filter(e=>e.sort).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).map(e=>({colId:e.colId,sort:e.sort}))}setSortModel(e){for(const t of this.grid.getAllColumns())t.sort=null,t.sortIndex=null;e.forEach((t,n)=>{const i=this.grid.getColumn(t.colId);i&&(i.sort=t.sort,i.sortIndex=n)}),this.onSortChanged("api")}onSortChanged(e){var n,i;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(i=(n=this.grid.getOptions()).onSortChanged)==null||i.call(n,{api:t,source:e})}}class qo{constructor(e,t){w(this,"eBar");w(this,"panels",[]);this.grid=e,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const i=e.getOptions().statusBar;(!i||!i.statusPanels||i.statusPanels.length===0)&&(this.eBar.style.display="none");const o=((i==null?void 0:i.statusPanels)||[]).map(a=>typeof a=="string"?{key:a,label:a}:{key:a.key||a.statusPanel,label:a.key||a.statusPanel,align:a.align});for(const a of o){const l=document.createElement("div");l.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(l);const r={def:a,ePanel:l,render:()=>this.renderPanel(a.key,l)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const n=this.grid.getApi(),i=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,l=n.getSelectedNodes().length,r=[],d=this.grid.getColumnModel().getValueColumns().filter(c=>c.aggFunc);switch(this.grid.getRowModel().forEachNode(c=>{!c.footer&&c.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${_e(a)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${_e(i)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${_e(i)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${_e(l)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=n.getSelectedNodes().filter(h=>!h.group&&!h.footer),p=[];for(const h of d){const f=c.map(y=>Ee(h,y,n)).filter(y=>typeof y=="number"&&!isNaN(y)),g=f.reduce((y,x)=>y+x,0),v=y=>y===null?"":_e(y,h.decimals),m=[[this.grid.translate("average","Average"),f.length?g/f.length:null],[this.grid.translate("count","Count"),f.length],[this.grid.translate("min","Min"),f.length?Math.min(...f):null],[this.grid.translate("max","Max"),f.length?Math.max(...f):null],[this.grid.translate("sum","Sum"),f.length?g:null]];for(const[y,x]of m)p.push(`${y}${h.headerName?` (${h.headerName})`:""} : ${v(x)}`)}p.length&&r.push(p.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class zo{constructor(e,t){w(this,"undoStack",[]);w(this,"redoStack",[]);w(this,"limit",50);w(this,"batchDepth",0);w(this,"batchBuffer",[]);w(this,"batchCounter",0);w(this,"currentBatchId",0);this.grid=e,this.eventService=t;const n=e.getOptions();n.undoRedoCellEditing&&(this.limit=typeof n.undoRedoCellEditing=="number"?n.undoRedoCellEditing:50)}isEnabled(){return!!this.grid.getOptions().undoRedoCellEditing}pushAction(e){if(this.isEnabled()){if(this.batchDepth>0){this.batchBuffer.push(e);return}this.undoStack.push({...e,batchId:this.currentBatchId}),this.undoStack.length>this.limit&&this.undoStack.shift(),this.redoStack=[]}}canUndo(){return this.isEnabled()&&this.undoStack.length>0}canRedo(){return this.isEnabled()&&this.redoStack.length>0}getUndoStackSize(){return this.undoStack.length}getRedoStackSize(){return this.redoStack.length}undo(){if(!this.canUndo())return 0;const e=[this.undoStack.pop()];for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].rowNodeId===e[0].rowNodeId&&this.undoStack[this.undoStack.length-1].colId===e[0].colId;)e.push(this.undoStack.pop());if(e[0].batchId!==0)for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].batchId===e[0].batchId;)e.push(this.undoStack.pop());let t=0;for(const n of e)this.applyValue(n,n.oldValue),this.redoStack.push(n),t++;return this.eventService.dispatchEvent("undoEnded",{api:this.grid.getApi(),numberOfActions:t}),t}redo(){if(!this.canRedo())return 0;let e=0;for(;this.redoStack.length>0;){const t=this.redoStack.pop();if(this.applyValue(t,t.newValue),this.undoStack.push(t),e++,this.redoStack.length===0||this.redoStack[this.redoStack.length-1].colId!==t.colId)break}return this.eventService.dispatchEvent("redoEnded",{api:this.grid.getApi(),numberOfActions:e}),e}applyValue(e,t){const n=this.grid.getRowNode(e.rowNodeId);if(!n)return;const i=this.grid.getColumn(e.colId);i&&(this.grid.setCellValue(i,n,t,"undoRedo"),this.grid.refreshCells({rowNodes:[n],columns:[i],flash:!0}))}startBatchEdit(){this.batchDepth++,this.batchDepth===1&&(this.currentBatchId=++this.batchCounter)}endBatchEdit(e=!1){if(this.batchDepth=Math.max(0,this.batchDepth-1),this.batchDepth>0)return;if(e){this.batchBuffer=[];return}const t=this.currentBatchId;for(const n of this.batchBuffer)this.undoStack.push({...n,batchId:t}),this.undoStack.length>this.limit&&this.undoStack.shift();this.redoStack=[],this.batchBuffer=[],this.eventService.dispatchEvent("batchEditEnded",{api:this.grid.getApi()})}isBatchEditing(){return this.batchDepth>0}clear(){this.undoStack=[],this.redoStack=[],this.batchBuffer=[]}}class _o{constructor(e,t){w(this,"ctx");w(this,"eHeader");w(this,"ePinnedLeftHeader");w(this,"ePinnedRightHeader");w(this,"eHeaderViewport");w(this,"eHeaderContainer");w(this,"eHeaderRow");w(this,"eFloatingFiltersRow",null);w(this,"eGroupRows");w(this,"headerCells",new Map);w(this,"customHeaderComponents",new Map);w(this,"resizeState",null);w(this,"dragState",null);w(this,"lastWidths",new Map);this.ctx=t,this.eHeader=e,e.classList.add("ag-header"),e.style.height=`${t.headerHeight}px`,this.ePinnedLeftHeader=document.createElement("div"),this.ePinnedLeftHeader.className="ag-pinned-left-header",e.appendChild(this.ePinnedLeftHeader),this.eHeaderViewport=document.createElement("div"),this.eHeaderViewport.className="ag-header-viewport",e.appendChild(this.eHeaderViewport),this.eHeaderContainer=document.createElement("div"),this.eHeaderContainer.className="ag-header-container",this.eHeaderViewport.appendChild(this.eHeaderContainer),this.eGroupRows=document.createElement("div"),this.eGroupRows.className="ag-group-header-rows",this.eHeaderContainer.appendChild(this.eGroupRows),this.eHeaderRow=document.createElement("div"),this.eHeaderRow.className="ag-header-row",this.eHeaderContainer.appendChild(this.eHeaderRow),this.ePinnedRightHeader=document.createElement("div"),this.ePinnedRightHeader.className="ag-pinned-right-header",e.appendChild(this.ePinnedRightHeader),this.refresh()}refresh(){this.headerCells.clear(),this.renderGroupRows();const{left:e,center:t,right:n}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,t,"center"),this.renderSection(this.ePinnedRightHeader,n,"right");const i=[...e,...t,...n].some(o=>o.floatingFilter);i&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!i&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var l;const e=this.ctx.getColumnModel(),t=((l=e==null?void 0:e.getColumnGroups)==null?void 0:l.call(e))||[];this.eGroupRows.innerHTML="";const n=t.reduce((r,d)=>Math.max(r,d.depth),0),i=this.ctx.options.groupHeaderHeight??30;let o=0;for(let r=1;r<=n;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${i}px`;const c=this.ctx.getColumns().center;let p=0,h,u=0,f=0;const g=(m,y)=>{let x=m.groupId;for(;x;){const C=t.find(b=>b.id===x);if(!C)return null;if(C.depth===y)return C.id;x=C.parentId}return null},v=()=>{if(h==null)return;const m=t.find(b=>b.id===h);if(!m)return;const y=document.createElement("div");y.className="ag-header-group-cell",y.style.left=`${u}px`,y.style.width=`${f}px`,y.style.height=`${i}px`;const x=e.isGroupOpen(m.id),C=document.createElement("div");if(C.className="ag-header-group-cell-label",C.textContent=m.headerName,y.appendChild(C),!x){const b=document.createElement("span");b.className="ag-header-group-expand",b.textContent="▸",b.title=this.ctx.t("expandGroup"),y.appendChild(b)}y.addEventListener("click",()=>{e.setGroupOpen(m.id,!x)}),d.appendChild(y)};c.forEach(m=>{const y=g(m,r);y!==h&&(v(),h=y,u=p,f=0),f+=m.width,p+=m.width}),v(),d.style.width=`${p}px`,this.eGroupRows.appendChild(d),o+=i}this.eGroupRows.style.display=n>0?"":"none";const a=this.ctx.headerHeight;this.eHeader.style.height=`${o+a}px`}renderSection(e,t,n){e.innerHTML="";let i=0;for(const o of t){const a=this.createHeaderCell(o);if(a.style.left=`${i}px`,a.style.width=`${o.width}px`,a.style.height=`${this.ctx.headerHeight}px`,i+=o.width,e.appendChild(a),this.headerCells.set(o.colId,a),o.eHeaderCell=a,this.eFloatingFiltersRow&&e===this.eHeaderRow&&o.floatingFilter){const l=this.createFloatingFilter(o);l.style.left=`${i-o.width}px`,l.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(l)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${i}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${i}px`)}createHeaderCell(e){var a,l;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const n=e.colDef.headerComponent;if(typeof n=="function"){const r=n({column:e,colDef:e.colDef,api:((l=(a=this.ctx).getApi)==null?void 0:l.call(a))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),t.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const i=document.createElement("div");if(i.className="ag-header-cell-label",e.headerTooltip&&(i.title=e.headerTooltip),e.headerCheckboxSelection){const r=document.createElement("input");r.type="checkbox",r.className="ag-native-checkbox ag-header-select-all",r.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,r.checked)),r.addEventListener("click",d=>d.stopPropagation()),i.appendChild(r)}const o=document.createElement("span");if(o.className="ag-header-cell-text",o.textContent=e.headerName,i.appendChild(o),t.appendChild(i),e.sortable){const r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=ao,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=oo,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const d=t.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=h=>{if(!this.resizeState)return;const u=h.clientX-this.resizeState.startX;let f=this.resizeState.startWidth+u;f=Math.max(e.minWidth,Math.min(e.maxWidth,f)),this.ctx.onColumnResized(e,Math.round(f),!1)},p=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",p),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",p)}),t.appendChild(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=t.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),t}createFloatingFilter(e){const t=document.createElement("div");if(t.className="ag-header-cell ag-floating-filter-cell",t.dataset.colid=e.colId,t.style.position="absolute",t.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const i=document.createElement("select");return i.className="ag-floating-filter-input",i.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',i.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,i.value)),t.appendChild(i),e.floatingFilterComp=i,t}const n=document.createElement("input");return n.className="ag-floating-filter-input",n.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",n.placeholder=this.ctx.t("filterOoo"),n.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),n.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,n.value)),t.appendChild(n),e.floatingFilterComp=n,t}updateSortIndicator(e,t,n){if(e.innerHTML="",t==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=ro):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=lo),t&&n!==null&&n>0){const i=document.createElement("span");i.className="ag-sort-order",i.textContent=String(n+1),e.appendChild(i)}}updateIndicators(){const{left:e,center:t,right:n}=this.ctx.getColumns();for(const i of[...e,...t,...n]){const o=this.headerCells.get(i.colId);if(!o)continue;const a=o.querySelector(".ag-sort-indicator");a&&this.updateSortIndicator(a,i.sort,i.sortIndex);const l=o.querySelector(".ag-filter-icon");l&&l.classList.toggle("ag-filter-active",this.ctx.isFilterActive(i)),o.style.width=`${i.width}px`,this.lastWidths.get(i.colId)!==i.width&&this.lastWidths.set(i.colId,i.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(n=>n.colId===e.colId)+1}layoutPositions(){const{left:e,center:t,right:n}=this.ctx.getColumns();let i=0;for(const o of e){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}this.ePinnedLeftHeader.style.width=`${i}px`,i=0;for(const o of t){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}this.eHeaderContainer.style.width=`${i}px`,i=0;for(const o of n){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}if(this.ePinnedRightHeader.style.width=`${i}px`,this.eFloatingFiltersRow){i=0;for(const o of t){const a=this.eFloatingFiltersRow.querySelector(`[data-colid="${o.colId}"]`);a&&(a.style.left=`${i}px`,a.style.width=`${o.width}px`),i+=o.width}}}setScrollLeft(e,t=0){this.eHeaderViewport.style.marginInlineEnd=`${t}px`,this.eHeaderViewport.scrollLeft=e}getHeaderCell(e){return this.headerCells.get(e.colId)}getHeaderRow(){return this.eHeaderRow}}class Pt{constructor(e,t,n,i,o,a,l){w(this,"eLeft",null);w(this,"eCenter",null);w(this,"eRight",null);w(this,"cellComps",[]);w(this,"pinned",!1);var r,d,c,p,h,u,f,g,v;if(this.ctx=e,this.node=t,this.rowHeight=a,t.masterNode){const m=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(m){const y=document.createElement("div");y.className="ag-row ag-row-detail-row",y.dataset.rowid=t.id,y.style.height=`${m.height}px`,y.style.width="100%",y.appendChild(m.eDetail),this.eCenter=y,this.eLeft=null,this.eRight=null}return}n.length&&(this.eLeft=this.createRowElement(t,n,"left"),this.eLeft.classList.add("ag-row-pinned")),(i.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,i,"center")),o.length&&(this.eRight=this.createRowElement(t,o,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),t.group&&((p=this.eCenter)==null||p.classList.add("ag-row-group"),(h=this.eLeft)==null||h.classList.add("ag-row-group"),(u=this.eRight)==null||u.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((f=this.eCenter)==null||f.classList.add("ag-row-selected"),(g=this.eLeft)==null||g.classList.add("ag-row-selected"),(v=this.eRight)==null||v.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,n,i;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(n=this.eCenter)==null||n.classList.toggle("ag-row-sticky-group",e),(i=this.eRight)==null||i.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,n,i;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(n=this.eCenter)==null||n.classList.toggle("ag-row-hover",e),(i=this.eRight)==null||i.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,n){var r;const i=document.createElement("div");i.className="ag-row",i.dataset.rowid=e.id,i.setAttribute("role","row"),i.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),i.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&i.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&i.classList.add("ag-row-even"),i.style.height=`${this.rowHeight}px`,i.style.position="absolute",i.style.top="0px";const o=this.ctx.getRowClass(e);o&&i.classList.add(...o.split(" ").filter(Boolean));const a=this.ctx.getRowStyle(e);a&&Object.assign(i.style,a),e.footer&&((r=e.groupData)!=null&&r.__grandTotal)&&(i.classList.add("ag-row-full-width"),i.style.width="100%",i.style.right="0",i.style.left="0");let l=0;for(let d=0;d<t.length;d++){const c=t[d],p=this.createCell(c,e);let h=1;typeof c.colDef.colSpan=="function"&&(h=Math.max(1,Math.round(c.colDef.colSpan({value:Ee(c,e,null),data:e.data,node:e,column:c,rowIndex:e.__displayIndex??0,api:null}))));let u=c.width;for(let f=1;f<h&&d+f<t.length;f++)u+=t[d+f].width;p.eCell.style.left=`${l}px`,p.eCell.style.width=`${u}px`,p.eCell.style.position="absolute",p.eCell.style.top="0",p.eCell.style.height=`${this.rowHeight}px`,h>1&&p.eCell.classList.add("ag-cell-col-span"),l+=u,d+=h-1,i.appendChild(p.eCell),this.cellComps.push(p)}return i.style.width=`${l}px`,i}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(n=>n.colId===e.colId)+1}createCell(e,t){var c,p;const n=document.createElement("div");n.className="ag-cell",n.dataset.colid=e.colId;const i=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");i&&n.classList.add(`ag-col-${i}`);const o={value:Ee(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const h=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof h=="string"?n.classList.add(...h.split(" ").filter(Boolean)):Array.isArray(h)&&n.classList.add(...h)}if(e.cellClassRules)for(const[h,u]of Object.entries(e.cellClassRules))u(o)&&n.classList.add(h);if(e.cellStyle){const h=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(n.style,h)}(e.type==="numberColumn"||e.cellDataType===!0)&&n.classList.add("ag-right-aligned-cell"),e.rowDrag&&n.classList.add("ag-cell-row-drag");const a=document.createElement("span");a.className="ag-cell-value",n.appendChild(a),this.ctx.options.enableCellTextSelection&&(n.style.userSelect="text",n.style.cursor="text"),n.setAttribute("role","gridcell"),n.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const l=(p=(c=this.ctx).getNote)==null?void 0:p.call(c,t.id,e.colId,e.colDef.note,{value:Ee(e,t,null),data:t.data,node:t,column:e,api:null});if(l){const h=document.createElement("span");h.className="ag-cell-note-marker",h.title=l,h.addEventListener("click",u=>{var f,g;u.stopPropagation(),(g=(f=this.ctx).onNoteClick)==null||g.call(f,t.id,e.colId,h)}),n.appendChild(h)}if(e.rowDrag){const h=document.createElement("span");h.className="ag-row-drag-handle",h.innerHTML=qn,h.title=this.ctx.t("dragRow"),h.addEventListener("mousedown",u=>{var f,g;u.button===0&&(u.stopPropagation(),(g=(f=this.ctx).onRowDragStart)==null||g.call(f,t,h,u))}),n.appendChild(h)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?n.title=String(t.data[r]):e.tooltipValueGetter&&(n.title=String(e.tooltipValueGetter({value:Ee(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:n,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:t,node:n}={column:e.column,node:this.node},i=Ee(t,n,null),o=At(t,n,null);e.lastValue=i,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,l=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||l){e.custom=!0;const c=a||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const p={value:i,valueFormatted:o,data:n.data,node:n,column:t,rowIndex:n.__displayIndex??0,api:null,colDef:t.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...t.cellRendererParams||{}};let h=null;if(a&&Dt[a]){const u=Dt[a](p);u instanceof HTMLElement?h=u:(e.rendererInstance=u,h=u.getGui())}else if(l){const u=l(p);u instanceof HTMLElement?h=u:u&&typeof u.getGui=="function"?(e.rendererInstance=u,h=u.getGui()):typeof u=="string"&&(e.eValue.innerHTML=u)}h&&e.eValue.appendChild(h)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=o??"";if((n.group||n.footer)&&n.groupData){const c=n.groupData[t.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,n){var a,l,r,d;const i=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(i&&!i.has(c.column.colId))continue;const p=Ee(c.column,this.node,null),h=t||p!==c.lastValue;if(!h&&!n)continue;const u=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:p,valueFormatted:At(c.column,this.node,null),data:this.node.data,node:this.node,column:c.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:c.column.colDef,eGridCell:c.eCell,...c.column.cellRendererParams||{}})===!1&&this.updateCellContent(c),c.lastValue=p,n&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(h||n)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=p,n&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(n||h&&u!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"))}const o=this.ctx.isNodeSelected(this.node);(a=this.eCenter)==null||a.classList.toggle("ag-row-selected",o),(l=this.eLeft)==null||l.classList.toggle("ag-row-selected",o),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",o),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,n){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&n.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const i=this.ctx.renderDetailRow(this.node,this.eCenter);i&&t.appendChild(i.eDetail)}}setTop(e){const t=`${e}px`;this.eLeft&&this.eLeft.style.top!==t&&(this.eLeft.style.top=t),this.eCenter&&this.eCenter.style.top!==t&&(this.eCenter.style.top=t),this.eRight&&this.eRight.style.top!==t&&(this.eRight.style.top=t)}getCenterElement(){return this.eCenter}getCellElements(){return this.cellComps.map(e=>e.eCell)}destroy(){var e,t,n,i;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(t=this.eCenter)!=null&&t.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(n=this.eRight)!=null&&n.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const o of this.cellComps)(i=o.rendererInstance)!=null&&i.destroy&&o.rendererInstance.destroy();this.cellComps=[]}}function Yn(s,e,t){const n=s.length;if(n===0||t<=0)return[];let i=0,o=n-1;for(;i<o;){const c=i+o>>1;s[c]>=t?o=c:i=c+1}const a=s[i]>=t?i:n-1,l=e[a];if(!l||l.level===0)return[];const r=[];let d=l.level;for(let c=a-1;c>=0;c--){const p=e[c];if(!(!p||p.level>=d)&&(d=p.level,p.group&&s[c]<t&&r.push(c),p.level===0))break}return r.reverse()}class Wo{constructor(e,t,n){w(this,"ctx");w(this,"eRoot");w(this,"eHeader");w(this,"eBody");w(this,"ePinnedLeft");w(this,"ePinnedRight");w(this,"ePinnedLeftInner");w(this,"ePinnedRightInner");w(this,"eViewport");w(this,"eContainer");w(this,"eFloatingTop");w(this,"eFloatingBottom");w(this,"eFloatingTopLeft");w(this,"eFloatingTopRight");w(this,"eFloatingBottomLeft");w(this,"eFloatingBottomRight");w(this,"eStickyTop");w(this,"eStickyLeft");w(this,"eStickyCenter");w(this,"eStickyRight");w(this,"rowComps",new Map);w(this,"stickyComps",new Map);w(this,"hoveredRowId",null);w(this,"rowOffsets",[]);w(this,"rowIndices",new Map);w(this,"rowInfos",[]);w(this,"totalHeight",0);w(this,"lastScrollTop",-1);w(this,"lastRange",[-1,-1]);w(this,"heightVersion",0);w(this,"scrollFrame",null);w(this,"onSectionWheel",e=>{if(e.ctrlKey||!e.cancelable)return;const t=e.target;if(t!=null&&t.closest('input, textarea, select, [contenteditable="true"]'))return;const n=this.eViewport;let i=e.deltaY,o=e.deltaX;e.deltaMode===1?(i*=33,o*=33):e.deltaMode===2&&(i*=n.clientHeight,o*=n.clientWidth),e.shiftKey&&!o&&(o=i,i=0),i&&(n.scrollTop+=i),o&&(n.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});w(this,"onBodyMouseOver",e=>{var o;const t=e.target,n=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,".ag-row"),i=(n==null?void 0:n.dataset.rowid)??null;if(i===this.hoveredRowId){i&&this.setRowHovered(i,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=i,i&&this.setRowHovered(i,!0)});w(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=n,this.eRoot=e,this.eHeader=t,this.eBody=document.createElement("div"),this.eBody.className="ag-body",this.eRoot.appendChild(this.eBody),this.ePinnedLeft=document.createElement("div"),this.ePinnedLeft.className="ag-pinned-left-cols-viewport",this.eBody.appendChild(this.ePinnedLeft),this.ePinnedLeftInner=document.createElement("div"),this.ePinnedLeftInner.className="ag-pinned-cols-inner",this.ePinnedLeft.appendChild(this.ePinnedLeftInner);const i=document.createElement("div");i.className="ag-body-viewport-wrapper",this.eBody.appendChild(i),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",i.appendChild(this.eFloatingTop),this.eViewport=document.createElement("div"),this.eViewport.className="ag-body-viewport",this.eViewport.tabIndex=0,this.eViewport.addEventListener("scroll",this.onScroll.bind(this)),this.eViewport.addEventListener("keydown",o=>this.ctx.onViewportKeyDown(o)),i.appendChild(this.eViewport),this.eContainer=document.createElement("div"),this.eContainer.className="ag-body-container",this.eViewport.appendChild(this.eContainer),this.eFloatingBottom=document.createElement("div"),this.eFloatingBottom.className="ag-floating-bottom",i.appendChild(this.eFloatingBottom),this.ePinnedRight=document.createElement("div"),this.ePinnedRight.className="ag-pinned-right-cols-viewport",this.eBody.appendChild(this.ePinnedRight),this.ePinnedRightInner=document.createElement("div"),this.ePinnedRightInner.className="ag-pinned-cols-inner",this.ePinnedRight.appendChild(this.ePinnedRightInner),this.eFloatingTopLeft=document.createElement("div"),this.eFloatingTopLeft.className="ag-floating-pinned-cols ag-floating-pinned-left",this.eBody.appendChild(this.eFloatingTopLeft),this.eFloatingTopRight=document.createElement("div"),this.eFloatingTopRight.className="ag-floating-pinned-cols ag-floating-pinned-right",this.eBody.appendChild(this.eFloatingTopRight),this.eFloatingBottomLeft=document.createElement("div"),this.eFloatingBottomLeft.className="ag-floating-pinned-cols ag-floating-pinned-bottom-left",this.eBody.appendChild(this.eFloatingBottomLeft),this.eFloatingBottomRight=document.createElement("div"),this.eFloatingBottomRight.className="ag-floating-pinned-cols ag-floating-pinned-bottom-right",this.eBody.appendChild(this.eFloatingBottomRight),this.eStickyTop=document.createElement("div"),this.eStickyTop.className="ag-sticky-group-rows",this.eBody.appendChild(this.eStickyTop),this.eStickyLeft=document.createElement("div"),this.eStickyLeft.className="ag-sticky-group-rows-left",this.eStickyTop.appendChild(this.eStickyLeft),this.eStickyCenter=document.createElement("div"),this.eStickyCenter.className="ag-sticky-group-rows-center",this.eStickyTop.appendChild(this.eStickyCenter),this.eStickyRight=document.createElement("div"),this.eStickyRight.className="ag-sticky-group-rows-right",this.eStickyTop.appendChild(this.eStickyRight);for(const o of[this.eFloatingTopLeft,this.eFloatingTopRight,this.eFloatingBottomLeft,this.eFloatingBottomRight,this.eStickyLeft,this.eStickyCenter,this.eStickyRight])o.addEventListener("click",this.onClick.bind(this)),o.addEventListener("dblclick",this.onDoubleClick.bind(this)),o.addEventListener("mousedown",this.onMouseDown.bind(this)),o.addEventListener("contextmenu",this.onContextMenu.bind(this)),o.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.ePinnedLeft.addEventListener("click",this.onClick.bind(this)),this.ePinnedLeft.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedLeft.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedLeft.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eContainer.addEventListener("click",this.onClick.bind(this)),this.eContainer.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eContainer.addEventListener("mousedown",this.onMouseDown.bind(this)),this.eContainer.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.ePinnedRight.addEventListener("click",this.onClick.bind(this)),this.ePinnedRight.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedRight.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedRight.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingTop.addEventListener("click",this.onClick.bind(this)),this.eFloatingTop.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingTop.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingBottom.addEventListener("click",this.onClick.bind(this)),this.eFloatingBottom.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingBottom.addEventListener("contextmenu",this.onContextMenu.bind(this));for(const o of[this.eViewport,this.ePinnedLeft,this.ePinnedRight,this.eFloatingTop,this.eFloatingBottom,this.eHeader])o.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.eBody.addEventListener("mouseover",this.onBodyMouseOver),this.eBody.addEventListener("mouseleave",this.onBodyMouseLeave)}setRowHovered(e,t){for(const n of this.rowComps.values())n.getNode().id===e&&n.setHovered(t);for(const n of this.stickyComps.values())n.getNode().id===e&&n.setHovered(t)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount();this.rowIndices.clear();const t=new Array(e),n=new Array(e);let i=0;if(this.hasVariableHeights()){for(let a=0;a<e;a++)t[a]=i,n[a]=this.rowInfoAt(a),i+=this.getRowHeightForIndex(a);this.totalHeight=i}else{const a=this.getFixedRowHeight();for(let l=0;l<e;l++)t[l]=l*a,n[l]=this.rowInfoAt(l);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=n}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?(this.rowIndices.set(t.id,e),{level:t.uiLevel??t.level??0,group:!!t.group}):{level:0,group:!1}}hasVariableHeights(){return!!(this.ctx.options.detailRowAutoHeight||this.ctx.options.getRowHeight)}getFixedRowHeight(){return this.ctx.options.rowHeight??42}getRowHeightForIndex(e){const t=this.ctx.rowModel.getRow(e);return t?this.ctx.getRowHeight(t):this.getFixedRowHeight()}refreshRows(){this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`;const e=this.ctx.getColumns().center.reduce((i,o)=>i+o.width,0),t=this.ctx.getColumns().left.reduce((i,o)=>i+o.width,0),n=this.ctx.getColumns().right.reduce((i,o)=>i+o.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${t}px`,this.ePinnedRight.style.width=`${n}px`,this.ePinnedLeft.style.height=`${this.totalHeight}px`,this.ePinnedRight.style.height=`${this.totalHeight}px`,this.eFloatingTopLeft.style.width=`${t}px`,this.eFloatingTopRight.style.width=`${n}px`,this.eFloatingBottomLeft.style.width=`${t}px`,this.eFloatingBottomRight.style.width=`${n}px`,this.eStickyLeft.style.width=`${t}px`,this.eStickyRight.style.width=`${n}px`,this.eStickyCenter.style.left=`${t}px`,this.eStickyCenter.style.right=`${n}px`,this.redrawAllRows()}invalidateRowHeights(){this.heightVersion++,this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`,this.redrawAllRows()}redrawAllRows(){for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear(),this.lastRange=[-1,-1],this.renderPinnedRows(),this.renderVisibleRows(!0)}renderPinnedRows(){var n,i;const e=(o,a,l,r,d)=>{o.innerHTML="",a.innerHTML="",l.innerHTML="";const{left:c,center:p,right:h}=this.ctx.getColumns();let u=0;for(let f=0;f<r;f++){const g=d(f);if(!g)continue;const v=this.ctx.getRowHeight(g),m=new Pt(this.ctx,g,c,p,h,v,this.heightVersion);m.appendTo(a,o,l),m.setTop(u),u+=v,this.rowComps.set(`${g.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${u}px`,o.style.display=r>0?"":"none",a.style.height=`${u}px`,l.style.height=`${u}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((n=t.getPinnedTopRowCount)==null?void 0:n.call(t))??0,o=>{var a;return(a=t.getPinnedTopRow)==null?void 0:a.call(t,o)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((i=t.getPinnedBottomRowCount)==null?void 0:i.call(t))??0,o=>{var a;return(a=t.getPinnedBottomRow)==null?void 0:a.call(t,o)})}refreshCells(e){const t=e==null?void 0:e.rowNodes;let n;e!=null&&e.columns&&(n=e.columns.map(i=>typeof i=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(o=>o.colId===i):i).filter(Boolean));for(const[i,o]of this.rowComps)t&&!t.includes(o.getNode())||o.refreshCells(n,e==null?void 0:e.force,e==null?void 0:e.flash);for(const i of this.stickyComps.values())t&&!t.includes(i.getNode())||i.refreshCells(n,e==null?void 0:e.force,e==null?void 0:e.flash)}flashCells(e){this.refreshCells({...e,force:!0,flash:!0})}redrawRows(e){if(!(e!=null&&e.rowNodes)){this.redrawAllRows();return}for(const t of this.rowComps.values())if(e.rowNodes.includes(t.getNode())){const n=t.getNode(),i=this.findRowIndex(n);if(t.destroy(),this.rowComps.delete(this.rowCompKey(n)),i>=0){const{left:o,center:a,right:l}=this.ctx.getColumns(),r=new Pt(this.ctx,n,o,a,l,this.getRowHeightForIndex(i),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[i]??0),this.rowComps.set(this.rowCompKey(n),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){return this.rowIndices.get(e.id)??-1}scheduleScrollRender(){this.scrollFrame===null&&(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=null,this.renderVisibleRows()}))}onScroll(){this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),this.ctx.eventService.dispatchEvent("bodyScroll",{direction:"vertical",top:this.eViewport.scrollTop,left:this.eViewport.scrollLeft})}syncPinnedScroll(){const e=`translateY(${-this.eViewport.scrollTop}px)`;this.ePinnedLeftInner.style.transform=e,this.ePinnedRightInner.style.transform=e,this.ePinnedLeft.scrollTop=this.eViewport.scrollTop,this.ePinnedRight.scrollTop=this.eViewport.scrollTop,this.syncStickyHorizontal()}syncStickyHorizontal(){const n=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const i of this.stickyComps.values()){const o=i.getCenterElement();o&&(o.style.transform=n)}}getVerticalScrollTop(){return this.eViewport.scrollTop}setVerticalScrollTop(e){this.eViewport.scrollTop=e,this.syncPinnedScroll(),this.renderVisibleRows()}getHorizontalScrollLeft(){return this.eViewport.scrollLeft}getVerticalScrollbarWidth(){return Math.max(0,this.eViewport.offsetWidth-this.eViewport.clientWidth)}setHorizontalScrollLeft(e){var t,n;this.eViewport.scrollLeft=e,this.syncPinnedScroll(),(n=(t=this.ctx).onViewportScroll)==null||n.call(t)}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Yn(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:n,right:i}=this.ctx.getColumns(),o=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${o}px`;const a=new Set;let l=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;a.add(c.id);let p=this.stickyComps.get(c.id);if(!p){const h=this.rowComps.get(c.id);h&&(h.destroy(),this.rowComps.delete(c.id)),p=new Pt(this.ctx,c,t,n,i,this.getRowHeightForIndex(d),this.heightVersion),p.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),p.setSticky(!0),this.stickyComps.set(c.id,p)}p.setTop(l),l+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)a.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${l}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),n=this.eViewport.scrollTop,i=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a,l;if(this.hasVariableHeights())a=this.findIndexAtPixel(n)-o,l=this.findIndexAtPixel(n+i)+o;else{const v=this.getFixedRowHeight();a=Math.floor(n/v)-o,l=Math.ceil((n+i)/v)+o}if(a=Math.max(0,a),l=Math.min(t-1,l),!e&&this.lastRange[0]===a&&this.lastRange[1]===l&&this.lastScrollTop===n)return;const r=this.lastRange[0]!==a||this.lastRange[1]!==l;this.lastRange=[a,l],this.lastScrollTop=n;const d=new Set(this.stickyComps.keys()),c=this.syncStickyGroupRows(),p=d.size!==c.size||[...d].some(v=>!c.has(v));if(!e&&!r&&!p)return;const h=new Set(c),{left:u,center:f,right:g}=this.ctx.getColumns();for(let v=a;v<=l;v++){const m=this.ctx.rowModel.getRow(v);if(!m||(h.add(m.id),c.has(m.id)))continue;let y=this.rowComps.get(m.id);y||(y=new Pt(this.ctx,m,u,f,g,this.getRowHeightForIndex(v),this.heightVersion),y.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,y)),y.setTop(this.rowOffsets[v]??v*this.getFixedRowHeight())}for(const[v,m]of this.rowComps)!h.has(v)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(v))}findIndexAtPixel(e){const t=this.rowOffsets;let n=0,i=t.length-1;for(;n<i;){const o=n+i+1>>1;t[o]<=e?n=o:i=o-1}return n}ensureIndexVisible(e,t="top"){const n=this.rowOffsets[e]??e*this.getFixedRowHeight(),i=this.getRowHeightForIndex(e),o=this.eViewport.clientHeight;let a;t==="top"?a=n:t==="bottom"?a=n+i-o:a=n-(o-i)/2,this.eViewport.scrollTop=Math.max(0,a),this.renderVisibleRows()}getFirstVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop))}getLastVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop+this.eViewport.clientHeight))}ensureColumnVisible(e,t="end"){const n=this.eViewport.clientWidth,i=this.eViewport.scrollLeft,o=e.left-this.ctx.getColumns().left.reduce((a,l)=>a+l.width,0);o<i?this.eViewport.scrollLeft=Math.max(0,t==="middle"?o-(n-e.width)/2:o):o+e.width>i+n&&(this.eViewport.scrollLeft=o+e.width-n),this.renderVisibleRows()}getCellPosition(e,t){return{top:this.rowOffsets[e]??e*this.getFixedRowHeight(),left:t.left,height:this.getRowHeightForIndex(e),width:t.width}}getRowOffsets(){return this.rowOffsets}getTotalHeight(){return this.totalHeight}findCellFromEvent(e){const n=e.target.closest(".ag-cell");if(!n)return null;const i=n.dataset.colid;if(!i)return null;const o=n.closest(".ag-row"),a=o==null?void 0:o.dataset.rowid;if(!a)return null;const l=this.ctx.rowModel.getRowNode(a);if(!l)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===i);return d?{node:l,column:d,eCell:n,rowIndex:this.findRowIndex(l)}:null}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:Ee(t.column,t.node,null),rowIndex:this.findRowIndex(t.node),colDef:t.column.colDef});return}const n=e.target.closest(".ag-row");if(n!=null&&n.dataset.rowid){const i=this.ctx.rowModel.getRowNode(n.dataset.rowid);i&&this.ctx.onRowClicked({event:e,node:i,data:i.data,rowIndex:this.findRowIndex(i)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:Ee(t.column,t.node,null),rowIndex:this.findRowIndex(t.node),colDef:t.column.colDef});return}const n=e.target.closest(".ag-row");if(n!=null&&n.dataset.rowid){const i=this.ctx.rowModel.getRowNode(n.dataset.rowid);i&&this.ctx.onRowDoubleClicked({event:e,node:i,data:i.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:Ee(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:Ee(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}destroy(){this.scrollFrame!==null&&cancelAnimationFrame(this.scrollFrame),this.scrollFrame=null;for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear()}}class je{constructor(){w(this,"cleanups",new Set);w(this,"stopped",!1)}get destroyed(){return this.stopped}add(e){return this.stopped?e():this.cleanups.add(e),()=>{this.cleanups.delete(e)&&e()}}listen(e,t,n,i){return e.addEventListener(t,n,i),this.add(()=>e.removeEventListener(t,n,i))}timeout(e,t){if(this.stopped)return 0;const n=window.setTimeout(()=>{i(),this.stopped||e()},t),i=this.add(()=>window.clearTimeout(n));return n}interval(e,t){if(this.stopped)return 0;const n=window.setInterval(()=>{this.stopped||e()},t);return this.add(()=>window.clearInterval(n)),n}destroy(){if(this.stopped)return;this.stopped=!0;const e=[...this.cleanups].reverse();this.cleanups.clear();let t;for(const n of e)try{n()}catch(i){t??(t=i)}if(t!==void 0)throw t}}function $e(s,e,t={},n=[]){const i=new je,o=new Set,a=h=>[...o].some(u=>u.contains(h)),l=new Set,r=new WeakMap,d=h=>{const u=h.target;if(!(u!=null&&u.closest))return;const f=u.closest('button,input,select,textarea,a,[data-action],[contenteditable],[role="button"],[role="tab"],[data-node-id],[data-rowid],[data-viewport],canvas');if(!f||!a(f))return;const g={};for(let m=f;m&&a(m);m=m.parentElement)for(const[y,x]of Object.entries(m.dataset))x!==void 0&&!(y in g)&&(g[y]=x);const v=f;r.has(h)||(r.set(h,{component:e,type:h.type,action:g.action??g.control,value:"value"in f?v.value:void 0,checked:v.type==="checkbox"||v.type==="radio"?v.checked:void 0,data:g,originalEvent:h}),queueMicrotask(()=>c(h)))},c=h=>{var g;const u=r.get(h);if(!u||i.destroyed)return;r.delete(h),(g=t.onInteraction)==null||g.call(t,u);for(const v of[...l])v(u);const f=s.ownerDocument.defaultView.CustomEvent;s.dispatchEvent(new f("rowvia:interaction",{detail:u,bubbles:!0}))},p=h=>{if(i.destroyed||o.has(h))return()=>{};o.add(h);const u=[];for(const f of["click","dblclick","contextmenu","input","change","submit","keydown","pointerdown","pointerup","wheel"])u.push(i.listen(h,f,d,{capture:!0,passive:!0}));return()=>{o.delete(h),u.forEach(f=>f())}};for(const h of[s,...n])p(h);return{addRoot:p,onInteraction(h){return i.destroyed?()=>{}:(l.add(h),()=>{l.delete(h)})},destroy(){i.destroy(),l.clear(),o.clear()}}}const Uo={rowHeight:42,headerHeight:48,floatingFiltersHeight:24,groupHeaderHeight:48,pivotHeaderHeight:48,rowBuffer:10,detailRowHeight:200,animateRows:!0,enableCellChangeFlash:!0,rowSelection:void 0,sortingOrder:["asc","desc",null],enterNavigatesVerticallyAfterEdit:!0,treeDataChildrenField:"children",suppressClickEdit:!1};class lt{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eventService",new Is);w(this,"columnModel");w(this,"rowModel");w(this,"clientSideRowModel",null);w(this,"serverSideRowModel",null);w(this,"infiniteRowModel",null);w(this,"viewportRowModel",null);w(this,"rowRenderer");w(this,"headerView");w(this,"selectionService");w(this,"editService");w(this,"filterService");w(this,"sortService");w(this,"paginationService",null);w(this,"popupService");w(this,"filterGui");w(this,"contextMenuService");w(this,"columnMenuService");w(this,"statusBarService");w(this,"sideBarService");w(this,"findService");w(this,"rangeSelectionService");w(this,"chartService");w(this,"overlayService");w(this,"exportService");w(this,"rowGroupPanel",null);w(this,"undoRedoService");w(this,"formulaEditorService");w(this,"notesService");w(this,"rowDragService");w(this,"api");w(this,"columnApi");w(this,"localeText");w(this,"rowNodeServices");w(this,"eGridDiv");w(this,"eRoot");w(this,"eMain");w(this,"eHeader");w(this,"quickFilter","");w(this,"resizeObserver",null);w(this,"destroyed",!1);w(this,"gridReadyDispatched",!1);w(this,"context");w(this,"onWindowResize",()=>{this.onGridSizeChanged()});w(this,"onDocumentMouseDown",e=>{var n;const t=e.target;if(t&&this.eRoot.contains(t)){const i=(n=t.closest)==null?void 0:n.call(t,".ag-cell");if(!i){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!i.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var d,c,p,h;this.eGridDiv=e,this.options={...Uo,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Fs(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const n=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(n),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),this.interactions=$e(this.eRoot,"grid",this.options),this.onInteraction=this.interactions.onInteraction,this.eMain=document.createElement("div"),this.eMain.className="ag-main",this.eRoot.appendChild(this.eMain),this.eHeader=document.createElement("div"),this.eHeader.className="ag-header-wrapper",this.eMain.appendChild(this.eHeader),this.rowNodeServices={selectNode:(u,f)=>this.selectionService.selectNode(u,f),deselectNode:u=>this.selectionService.deselectNode(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u)},this.columnModel=new Hn(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new Bo(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),u=>this.isNodeSelectable(u)),this.filterService=new No(this),this.sortService=new Go(this),this.popupService=new Do(this),this.filterGui=new To(this,this.popupService),this.contextMenuService=new uo(this,this.popupService),this.columnMenuService=new co(this,this.popupService),this.editService=new ho(this,this.eventService),this.undoRedoService=new zo(this,this.eventService),this.formulaEditorService=new Ao(this,this.popupService),this.notesService=new $o(this,this.popupService),this.rowDragService=new Ho(this,this.eventService),this.chartService=new Bs(this,this.popupService),this.findService=new Io(this,this.popupService),this.exportService=new Lo(this);const i={options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getSortModel:()=>this.sortService.getSortModel(),getFilterModel:()=>this.filterService.getFilterModel(),rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices},o=this.options.rowModelType||"clientSide";o==="serverSide"?(this.serverSideRowModel=new Ps(i),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new Hs(i),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new Os(i),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new xs({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var u;return!!((u=this.paginationService)!=null&&u.isEnabled())},getPageSize:()=>{var u;return((u=this.paginationService)==null?void 0:u.getPageSize())??100},getCurrentPage:()=>{var u;return((u=this.paginationService)==null?void 0:u.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(c=(d=this.rowModel).setGridApi)==null||c.call(d,null)),this.headerView=new _o(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(u=>u.sort)}),onSortRequested:(u,f,g)=>this.sortService.onSortRequested(u,f,g),onColumnResized:(u,f,g)=>this.onColumnResized(u,f,g),onColumnMoved:(u,f)=>this.onColumnMoved(u,f),onColumnMenuClicked:(u,f)=>this.columnMenuService.openColumnMenu(u,f),onFilterOpened:(u,f)=>this.filterGui.openFilter(u,f),isFilterActive:u=>this.filterService.isFilterActive(u),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(u,f)=>this.filterService.handleFloatingFilterChange(u,f),onHeaderCheckboxChanged:(u,f)=>this.onHeaderCheckboxChanged(u,f),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:u=>this.t(u),getApi:()=>this.api,getFilterModel:u=>this.filterService.getFilterInstance(u)??null,onFilterModelChange:(u,f)=>this.filterService.setColumnFilterModel(u,f)}),this.rowRenderer=new Wo(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:u=>this.t(u),getColumns:()=>this.getColumns(),getRowHeight:u=>this.getRowHeight(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u),isRowSelectable:u=>this.isNodeSelectable(u),getRowClass:u=>this.getRowClass(u),getRowStyle:u=>this.getRowStyle(u),onCellClicked:u=>this.onCellClicked(u),onCellDoubleClicked:u=>this.editService.onCellDoubleClicked(u),onCellMouseDown:u=>this.onCellMouseDown(u),onCellContextMenu:u=>this.onCellContextMenu(u),onRowClicked:u=>this.onRowClicked(u),onRowDoubleClicked:u=>this.onRowDoubleClicked(u),onRowGroupClicked:u=>this.onRowGroupClicked(u),onViewportKeyDown:u=>this.onViewportKeyDown(u),onViewportScroll:()=>{var g,v,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const u=this.rowRenderer.getFirstVisibleRowIndex(),f=this.rowRenderer.getLastVisibleRowIndex();(g=this.serverSideRowModel)==null||g.onViewportChanged(u,f),(v=this.infiniteRowModel)==null||v.onViewportChanged(u,f),(m=this.viewportRowModel)==null||m.onViewportChanged(u,f)},getCellText:(u,f)=>{const g=Ee(u,f,this.api);return g==null?"":String(g)},renderDetailRow:u=>this.renderDetailRow(u),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(u,f,g)=>this.rowDragService.startDrag(u,g),getNote:(u,f,g,v)=>this.notesService.getNote(u,f,g,v),onNoteClick:(u,f,g)=>this.notesService.openNoteEditor(u,f,g),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new Po(this,this.eventService),this.statusBarService=new qo(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Fo(this),this.sideBarService=new Vo(this),this.sideBarService.getElement().classList.contains("ag-side-bar-left")?this.eRoot.insertBefore(this.sideBarService.getElement(),this.eMain):this.eRoot.appendChild(this.sideBarService.getElement()),this.options.pagination&&(this.paginationService=new Kn(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Oo(this));const{api:a,columnApi:l}=Es(this);this.api=a,this.columnApi=l,this.columnModel.setGridApi(this.api),(h=(p=this.rowModel).setGridApi)==null||h.call(p,this.api),this.selectionService.gridApiRef=this.api,this.eventService.addEventListener("columnEverythingChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("displayedColumnsChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("columnRowGroupChanged",()=>{this.serverSideRowModel||this.infiniteRowModel?this.onRemoteModelChanged():this.rowModel.refreshModel("group")}),this.options.__advancedFilterPass=u=>this.filterService.doesNodePassAdvancedFilter(u),this.eventService.addEventListener("columnPivotModeChanged",()=>this.refreshPivotColumns()),this.eventService.addEventListener("modelUpdated",()=>{this.columnModel.isPivotMode()&&this.refreshPivotColumns()}),this.eventService.addEventListener("sortChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("filterChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("columnValueChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("columnPivotModeChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("modelUpdated",()=>this.onModelUpdated()),this.eventService.addEventListener("selectionChanged",()=>{var u,f;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(f=(u=this.options).onSelectionChanged)==null||f.call(u,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let r=this.options.columnDefs||[];(!r||r.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(r=Hn.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const n=this.localeText.t(e);return n===e?t:n}getContext(){return this.context}getEventService(){return this.eventService}getColumnModel(){return this.columnModel}getRowModel(){return this.rowModel}getRowRenderer(){return this.rowRenderer}getHeaderView(){return this.headerView}getSelectionService(){return this.selectionService}getEditService(){return this.editService}getFilterService(){return this.filterService}getSortService(){return this.sortService}getFilterGui(){return this.filterGui}getPaginationService(){return this.paginationService}getSideBarService(){return this.sideBarService}getChartService(){return this.chartService}getFindService(){return this.findService}getRangeSelectionService(){return this.rangeSelectionService}getExportService(){return this.exportService}getPopupService(){return this.popupService}getOverlayService(){return this.overlayService}getRowGroupPanel(){return this.rowGroupPanel}getUndoRedoService(){return this.undoRedoService}getFormulaEditorService(){return this.formulaEditorService}getNotesService(){return this.notesService}getRowDragService(){return this.rowDragService}getServerSideRowModel(){return this.serverSideRowModel}getInfiniteRowModel(){return this.infiniteRowModel}getViewportRowModel(){return this.viewportRowModel}updateColumnTotalCache(){var n,i;const e=new Map,t=this.getAllColumns().filter(o=>o.colDef.showValueAs);if(t.length>0){const o=new Map;(i=(n=this.rowModel).forEachLeafNode)==null||i.call(n,a=>{for(const l of t){const r=Ee(l,a,this.api);typeof r=="number"&&!isNaN(r)&&o.set(l.colId,(o.get(l.colId)??0)+r)}});for(const a of t)e.set(a.colId,o.get(a.colId)??0)}this.api.__columnTotalCache=e}refreshPivotColumns(){this.columnModel.updatePivotColumns(this.options.rowData||[])}onRemoteModelChanged(){this.serverSideRowModel?this.serverSideRowModel.onSortOrFilterChanged():this.infiniteRowModel?this.infiniteRowModel.onSortOrFilterChanged():this.viewportRowModel&&this.viewportRowModel.setViewportDatasource(this.viewportRowModel.datasource)}isRemoteLoading(){var e,t,n;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(t=this.infiniteRowModel)!=null&&t.isLoading()||(n=this.viewportRowModel)!=null&&n.isLoading())}getApi(){return this.api}getColumnApi(){return this.columnApi}getRootElement(){return this.eRoot}getMainElement(){return this.eMain}getHeaderElement(){return this.eHeader}getGridDiv(){return this.eGridDiv}getColumns(){return this.columnModel.getDisplayedColumnsByType()}getAllColumns(){return this.columnModel.getAllColumns()}getColumn(e){return this.columnModel.getColumn(e)}getDisplayedRowCount(){return this.rowModel.getRowCount()}getDisplayedRowAtIndex(e){return this.rowModel.getRow(e)}getRowNode(e){return this.rowModel.getRowNode(e)}getRowHeight(e){if(e.rowHeight!==null)return e.rowHeight;const t=this.options.getRowHeight;if(typeof t=="function"){const n=t({data:e.data,node:e,api:this.api});if(n)return n}return this.options.rowHeight??42}getRowClass(e){const t=[];if(this.options.rowClass&&t.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const n=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof n=="string"?t.push(n):Array.isArray(n)&&t.push(...n)}return e.footer&&t.push("ag-row-footer"),t.join(" ")}getRowStyle(e){const t={};return this.options.rowStyle&&Object.assign(t,this.options.rowStyle),typeof this.options.getRowStyle=="function"&&Object.assign(t,this.options.getRowStyle({data:e.data,node:e,api:this.api})),t}isNodeSelectable(e){if(e.footer||e.masterNode)return!1;const t=this.options.isRowSelectable;return!(t&&!t(e))}isCellEditable(e,t){return this.options.readOnlyEdit||t.group||t.footer||t.masterNode?!1:typeof e.editable=="function"?e.editable({data:t.data,node:t,column:e,colDef:e.colDef,api:this.api}):e.editable===!0}setRowData(e,t=!1){var n,i,o;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),t||(this.overlayService.updateAuto(),this.statusBarService.update(),(n=this.paginationService)==null||n.update(),this.chartService.refreshCharts(),(o=(i=this.options).onRowDataChanged)==null||o.call(i,{api:this.api}))}applyTransaction(e){var n;const t=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(n=this.paginationService)==null||n.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),t}setCellValue(e,t,n,i="api",o){const a=o!==void 0?o:Ee(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:Ee(e,t,this.api),newValue:n,data:t.data,node:t,column:e,api:this.api,colDef:e.colDef})===!1)return}else t.setDataValue(e.colId,n);e.rowGroup&&this.rowModel.refreshModel("group"),(i==="edit"||i==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:a,newValue:n,batchId:0}),i!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:n,value:n,data:t.data,node:t,column:e,colDef:e.colDef,api:this.api,source:i})}refreshModel(e){var t;this.rowModel.refreshModel(e),(t=this.paginationService)==null||t.update()}refreshCells(e){this.rowRenderer.refreshCells(e)}setQuickFilter(e){this.quickFilter=e||"",this.refreshModel("filter"),this.findService.applyHighlight()}getQuickFilter(){return this.quickFilter}setRowNodePinned(e,t){e.rowPinned=t,this.rowModel.refreshModel("everything")}openFind(){this.findService.open()}closeFind(){this.findService.close()}onCellClicked(e){var a,l,r,d;const{node:t,column:n,event:i}=e;if(this.options.enableRangeSelection,n.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(l=(a=this.options).onCellClicked)==null||l.call(a,{...e,api:this.api,colDef:n.colDef,value:Ee(n,t,this.api)});return}if(i.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,i),this.editService.onCellClicked(e),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:n.colDef,value:Ee(n,t,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var t,n;this.selectionService.handleRowClick(e.node,e.event),(n=(t=this.options).onRowClicked)==null||n.call(t,{...e,api:this.api})}onRowDoubleClicked(e){var t,n;(n=(t=this.options).onRowDoubleClicked)==null||n.call(t,{...e,api:this.api})}onCellContextMenu(e){var n,i;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(i=(n=this.options).onCellContextMenu)==null||i.call(n,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,n,i,o,a;if(e.group){const l=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);l&&l(e,!e.expanded),globalThis.__dbgLogs.push(["after-toggle",e.id,"expanded=",e.expanded]),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(i=(n=this.options).onRowGroupOpened)==null||i.call(n,{node:e,expanded:e.expanded,api:this.api})}else e.detailNode?(e.expanded=!e.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(a=(o=this.options).onRowGroupOpened)==null||a.call(o,{node:e,expanded:e.expanded,api:this.api})):e.masterNode&&(e.masterNode.expanded=!e.masterNode.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e.masterNode,expanded:e.masterNode.expanded,api:this.api}))}onHeaderCheckboxChanged(e,t){var n;if(e.headerCheckboxSelectionCurrentPageOnly&&((n=this.paginationService)!=null&&n.isEnabled())){const i=this.rowModel.getRowCount();if(t)for(let o=0;o<i;o++){const a=this.rowModel.getRow(o);a&&this.isNodeSelectable(a)&&this.selectionService.selectNode(a,!1)}else for(let o=0;o<i;o++){const a=this.rowModel.getRow(o);a&&this.selectionService.deselectNode(a)}}else this.selectionService.setSelectAllCheckboxState(t);this.updateHeaderCheckboxes()}updateHeaderCheckboxes(){for(const e of this.getAllColumns()){if(!e.headerCheckboxSelection)continue;const t=e.eHeaderCell;if(!t)continue;const n=t.querySelector(".ag-header-select-all");if(!n)continue;const i=this.selectionService.getSelectAllState();n.checked=i.checked,n.indeterminate=i.indeterminate}}onViewportKeyDown(e){if(this.editService.onGridKeyDown(e),this.rangeSelectionService.onGridKeyDown(e),(e.ctrlKey||e.metaKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?this.undoRedoService.redo():this.undoRedoService.undo();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),this.undoRedoService.redo();return}(e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")&&this.rangeSelectionService.getRanges().length===0&&this.selectionService.getSelectedNodes().length>0&&(e.preventDefault(),this.api.copyToClipboard()),(e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")&&this.rangeSelectionService.getRanges().length===0&&(e.preventDefault(),this.api.pasteFromClipboard())}onColumnResized(e,t,n){e.width=t,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),n&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,t){const n=this.columnModel.getColumns(),i=n.findIndex(a=>a.colId===e);if(i<0)return;let o=n.length;t&&(o=n.findIndex(a=>a.colId===t)),this.columnModel.moveColumnByIndex(i,o,"uiColumnMoved")}onColumnsChanged(){var e,t;this.headerView.refresh(),this.rowRenderer.refreshRows(),this.updateHeaderCheckboxes(),(t=(e=this.options).onDisplayedColumnsChanged)==null||t.call(e,{api:this.api})}onModelUpdated(){var e,t,n,i,o,a,l;this.updateColumnTotalCache(),this.rowRenderer.refreshRows(),this.options.__loadingRows=this.isRemoteLoading(),this.overlayService.updateAuto(),this.statusBarService.update(),(e=this.paginationService)==null||e.update(),this.rangeSelectionService.applyHighlight(),this.findService.applyHighlight(),this.chartService.refreshCharts(),this.gridReadyDispatched||(this.gridReadyDispatched=!0,this.eventService.dispatchEvent("firstDataRendered",{api:this.api}),(n=(t=this.options).onFirstDataRendered)==null||n.call(t,{api:this.api})),(o=(i=this.options).onModelUpdated)==null||o.call(i,{api:this.api}),(l=(a=this.options).onRowDataChanged)==null||l.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,l;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),n=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,i=Math.max(0,e-n);(t||((o=this.options.autoSizeStrategy)==null?void 0:o.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(i),this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows()),this.rowRenderer.renderVisibleRows(!0),this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth()),this.eventService.dispatchEvent("gridSizeChanged",{clientWidth:this.eGridDiv.clientWidth,clientHeight:this.eGridDiv.clientHeight,api:this.api}),(l=(a=this.options).onGridSizeChanged)==null||l.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const t=e.masterNode;if(!t)return null;const n=this.options.detailRowAutoHeight===!0,i=n?this.options.detailRowHeight??200:this.options.detailRowHeight??200,o=document.createElement("div");o.className="ag-row-detail",o.style.height=`${i}px`,o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0";const a=this.options.detailCellRenderer,l=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(l&&r){const p=r({data:t.data,node:t,api:this.api}),h=document.createElement("div");h.style.height="100%",h.style.padding="8px 16px",o.appendChild(h),setTimeout(()=>{new lt(h,{...l,rowData:p,theme:this.options.theme})},0)}else if(typeof a=="function"){const p=a({data:t.data,node:t,api:this.api,context:this.context});p instanceof HTMLElement?o.appendChild(p):o.textContent=String(p??"")}else typeof a=="string"&&(o.textContent=a);if(n){const p=Math.max(40,o.scrollHeight||i);return e.rowHeight=p,o.style.height=`${p}px`,{eDetail:o,height:p}}return e.rowHeight=i,{eDetail:o,height:i}}dispatchGridReady(){var e,t;this.eventService.dispatchEvent("gridReady",{api:this.api,columnApi:this.columnApi}),(t=(e=this.options).onGridReady)==null||t.call(e,{api:this.api,columnApi:this.columnApi,context:this.context})}updateGridOptions(e){const t=this.options.theme,n=e.rowData!==void 0&&e.rowData!==this.options.rowData,i=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),n&&this.setRowData(e.rowData),i&&this.columnModel.setColumnDefs(this.options.columnDefs||[]),e.sideBar!==void 0&&(this.sideBarService.setVisible(!!e.sideBar),this.onGridSizeChanged()),e.quickFilterText!==void 0&&this.setQuickFilter(e.quickFilterText),e.theme!==void 0&&e.theme!==t&&(this.eGridDiv.classList.remove(t||"ag-theme-alpine"),this.eGridDiv.classList.add(e.theme)),e.pagination!==void 0&&(e.pagination&&!this.paginationService?this.paginationService=new Kn(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,this.interactions.destroy(),window.removeEventListener("resize",this.onWindowResize),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0),(e=this.resizeObserver)==null||e.disconnect(),this.rowRenderer.destroy(),this.editService.destroy(),this.popupService.closeAll(),this.eRoot.remove(),this.eGridDiv.classList.remove("ag-grid-root","ag-theme-alpine","ag-theme-quartz","ag-theme-balham"),this.eventService.dispatchEvent("gridReady",{}))}}function Xn(s,e){const t=new lt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function Zn(s,e={}){const t=document.createElement("dialog");t.className="rowvia-detail-dialog";const n=$e(t,"detail-dialog",e),i=()=>{var d;return(d=e.onClose)==null?void 0:d.call(e)};t.addEventListener("close",i);const o=document.createElement("h2"),a=document.createElement("dl"),l=document.createElement("button");l.type="button",l.textContent="关闭";const r=()=>t.close();return l.addEventListener("click",r),t.append(o,a,l),s.append(t),{onInteraction:n.onInteraction,open(d){var c;o.textContent=d.title,t.setAttribute("aria-label",d.title),a.replaceChildren();for(const p of d.fields){const h=document.createElement("dt"),u=document.createElement("dd");h.textContent=p.label,u.textContent=p.value,a.append(h,u)}t.open||t.showModal(),(c=e.onOpen)==null||c.call(e,d)},close:r,destroy(){t.open&&t.close(),l.removeEventListener("click",r),t.removeEventListener("close",i),n.destroy(),t.remove()}}}const jo=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Ko=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Yo=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Ie(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function dt(s,e,t){const n=document.createElement("button");return n.type="button",n.className=e,n.textContent=s,n.addEventListener("click",i=>{i.stopPropagation(),t()}),n}class Xo{constructor(e,t,n,i){w(this,"filterFields");w(this,"sortFields");w(this,"filterRows",[]);w(this,"sorts",[]);w(this,"filterPanel",null);w(this,"sortPanel",null);w(this,"filterAnchor",null);w(this,"sortAnchor",null);w(this,"onDocumentMouseDown",e=>{var n,i;const t=e.target;this.filterPanel&&!this.filterPanel.contains(t)&&!((n=this.filterAnchor)!=null&&n.contains(t))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(t)&&!((i=this.sortAnchor)!=null&&i.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=i,this.filterFields=n.filter,this.sortFields=n.sort,document.addEventListener("mousedown",this.onDocumentMouseDown,!0)}openFilterPanel(e){if(this.filterPanel){this.closeFilterPanel();return}this.closeSortPanel();const t=Ie("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",d=>d.stopPropagation());const n=Ie("div","gt-panel-title");n.textContent="筛选",t.appendChild(n);const i=Ie("div","gt-filter-rows");t.appendChild(i);const o=()=>{if(i.textContent="",!this.filterRows.length){const d=Ie("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",i.appendChild(d)}for(const d of this.filterRows)i.appendChild(this.renderFilterRow(d,o))},a=Ie("div","gt-filter-add");for(const d of this.filterFields)a.appendChild(dt(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const l=Ie("div","gt-panel-hint");l.textContent="多个条件同时满足(且)",t.appendChild(l);const r=Ie("div","gt-panel-actions");r.append(dt("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),dt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const n=Ie("div","gt-filter-row"),i=this.filterFields.find(d=>d.colId===e.colId),o=document.createElement("select");o.className="gt-panel-select";for(const d of this.filterFields){const c=document.createElement("option");c.value=d.colId,c.textContent=d.label,d.colId===e.colId&&(c.selected=!0),o.appendChild(c)}o.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===o.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),n.appendChild(o);const a=e.kind==="number"?Ko:e.kind==="date"?Yo:jo,l=document.createElement("select");l.className="gt-panel-select gt-panel-select-cond";for(const d of a){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),l.appendChild(c)}if(l.addEventListener("change",()=>{e.type=l.value,t()}),n.appendChild(l),e.type!=="blank")if(i!=null&&i.options){const d=document.createElement("select");d.className="gt-panel-select";const c=document.createElement("option");c.value="",c.textContent="请选择",d.appendChild(c);for(const p of i.options){const h=document.createElement("option");h.value=p.value,h.textContent=p.label,p.value===e.value&&(h.selected=!0),d.appendChild(h)}d.addEventListener("change",()=>{e.value=d.value}),n.appendChild(d)}else if(e.kind==="date"){const d=document.createElement("input");if(d.type="date",d.className="gt-panel-input",d.value=e.value,d.addEventListener("change",()=>{e.value=d.value}),n.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="date",c.className="gt-panel-input",c.value=e.valueTo,c.addEventListener("change",()=>{e.valueTo=c.value}),n.appendChild(c)}}else if(e.kind==="number"){const d=document.createElement("input");if(d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="数值",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),n.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="至",c.value=e.valueTo,c.addEventListener("input",()=>{e.valueTo=c.value}),n.appendChild(c)}}else{const d=document.createElement("input");d.type="text",d.className="gt-panel-input",d.placeholder="文本",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),n.appendChild(d)}const r=dt("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),t()});return r.title="移除条件",n.appendChild(r),n}applyFilter(){const e={};for(const t of this.filterRows){if(t.type==="blank"){e[t.colId]={filterType:t.kind==="number"?"number":"text",type:"blank",filter:""};continue}if(t.kind==="date"){const n=(t.type==="after",t.value),i=t.type==="before"?t.value:t.valueTo;if(t.type==="before"&&!t.value||t.type==="after"&&!t.value||t.type==="inRange"&&!t.value&&!t.valueTo)continue;e[t.colId]={filterType:"date",dateFrom:n||void 0,dateTo:i||void 0};continue}if(t.value)if(t.kind==="number"){const n={filterType:"number",type:t.type,filter:Number(t.value)};t.type==="inRange"&&(n.filterTo=Number(t.valueTo||t.value)),e[t.colId]=n}else e[t.colId]={filterType:"text",type:t.type,filter:t.value}}this.api.setFilterModel(e),this.hooks.onFilterButton(Object.keys(e).length>0,Object.keys(e).length)}closeFilterPanel(){var e;(e=this.filterPanel)==null||e.remove(),this.filterPanel=null}openSortPanel(e){if(this.sortPanel){this.closeSortPanel();return}this.closeFilterPanel();const t=Ie("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",l=>l.stopPropagation());const n=Ie("div","gt-panel-title");n.textContent="排序",t.appendChild(n);const i=Ie("div","gt-sort-list");t.appendChild(i);const o=()=>{var l;i.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(u=>u.colId===r.colId),c=d>=0,p=Ie("div","gt-sort-item");c&&p.classList.add("gt-sort-item-active");const h=Ie("span","gt-sort-label");if(h.textContent=r.label,p.appendChild(h),c){const u=Ie("span","gt-sort-badge");u.textContent=String(d+1),p.appendChild(u);const f=Ie("span","gt-sort-dir");f.textContent=((l=this.sorts[d])==null?void 0:l.sort)==="asc"?"↑ 升序":"↓ 降序",p.appendChild(f)}p.addEventListener("click",()=>{var u;c?((u=this.sorts[d])==null?void 0:u.sort)==="asc"?this.sorts[d]={colId:r.colId,sort:"desc"}:this.sorts=this.sorts.filter(f=>f.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),o()}),i.appendChild(p)}},a=Ie("div","gt-panel-actions");a.append(dt("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),dt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applySort(),this.closeSortPanel()})),t.appendChild(a),this.mount(t,e),this.sortPanel=t,this.sortAnchor=e,o()}applySort(){this.api.setSortModel(this.sorts.map(e=>({colId:e.colId,sort:e.sort}))),this.hooks.onSortButton(this.sorts.length>0,this.sorts.length)}closeSortPanel(){var e;(e=this.sortPanel)==null||e.remove(),this.sortPanel=null}mount(e,t){this.host.appendChild(e);const n=t.getBoundingClientRect();e.style.top=`${n.bottom+6}px`;const i=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(n.left,i))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const Qn=864e5;function et(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${n}`}function Pe(s){return new Date(`${s}T00:00:00`)}function Fe(s,e){return new Date(s.getTime()+e*Qn)}function We(s,e){const t=typeof s=="string"?Pe(s):s,n=typeof e=="string"?Pe(e):e;return Math.round((n.getTime()-t.getTime())/Qn)}function xt(){return et(new Date)}function Zo(s){return s.status!=="done"&&s.end&&s.end<xt()&&s.progress<100?"delayed":s.status}function Jt(s){const e=Pe(s);return`${e.getMonth()+1}月${e.getDate()}日`}const Jn=["day","week","biweek","month","bimonth","quarter","halfyear","year"],Ht={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Qo={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2};function en(s){const e=(s.getDay()+6)%7;return Fe(s,-e)}function Jo(s,e){const t=Math.max(1,We(s,e)+1);let n=0;for(let i=0;i<t;i++){const o=Fe(s,i).getDay();o!==0&&o!==6&&n++}return Math.max(1,n)}function ea(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function ei(s,e,t){const n=[];if(s==="day"){let r=new Date(e);for(;r<t;){const d=Fe(r,1);n.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return n}if(s==="week"||s==="biweek"){let r=en(e);for(;r<t;){const d=Fe(r,s==="biweek"?14:7);n.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return n}const i=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/i)*i,1),a=r=>s==="month"||s==="bimonth"?`${r.getMonth()+1}月`:s==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let l=o(e);for(;l<t;){const r=ea(l,i);n.push({start:new Date(l),end:r,primary:a(l),secondary:""}),l=r}return n}const Re={accent:"#4555e5",text:"#1f2329",textTertiary:"#8f959e",border:"#dee0e3",groupRow:"transparent",weekend:"rgba(31, 35, 41, 0.04)",gridline:"rgba(31, 35, 41, 0.10)",gridlineMonth:"rgba(31, 35, 41, 0.12)",rowLine:"transparent",hover:"rgba(51, 112, 255, 0.05)",selected:"rgba(51, 112, 255, 0.09)"},Ot={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},ta=4,ti=6,qe=28;class ni{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eRoot");w(this,"eHeader");w(this,"eRuler");w(this,"rulerCtx");w(this,"eRulerTools");w(this,"eStepLabel");w(this,"eZoomValue");w(this,"eStepMenu",null);w(this,"eScroll");w(this,"eSpacer");w(this,"eCanvas");w(this,"ctx");w(this,"eTooltip");w(this,"eTodayBadge");w(this,"ePopup",null);w(this,"tasks",[]);w(this,"tasksById",new Map);w(this,"rows",[]);w(this,"selectedId",null);w(this,"hoverId",null);w(this,"unit","day");w(this,"zoom",1);w(this,"theme","content");w(this,"epochStart",new Date);w(this,"totalDays",1);w(this,"hits",[]);w(this,"hitsByRow",new Map);w(this,"drag",null);w(this,"ghost",null);w(this,"dirty",!0);w(this,"lastLeft",-1);w(this,"lastTop",-1);w(this,"timer");w(this,"observer",null);w(this,"resizeHandler",()=>this.resizeCanvases());w(this,"showChildren",!0);w(this,"milestonesOnly",!1);w(this,"locateHits",[]);w(this,"tick",()=>{const e=this.eScroll.scrollLeft,t=this.eScroll.scrollTop;(e!==this.lastLeft||t!==this.lastTop||this.dirty)&&(this.lastLeft=e,this.lastTop=t,this.eCanvas.style.transform=`translate(${e}px, ${t}px)`,this.draw(),this.dirty=!1)});w(this,"onScroll",()=>{this.tick()});w(this,"todayLabelX",-1);w(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:n,onAvatar:i}=this.hitAt(e.clientX,e.clientY),o=this.rows[n];i?this.eCanvas.style.cursor="pointer":t&&t.mode!=="move"?this.eCanvas.style.cursor="ew-resize":t?this.eCanvas.style.cursor="grab":this.eCanvas.style.cursor="default";const a=t?t.id:(o==null?void 0:o.id)??null;a!==this.hoverId&&(this.hoverId=a,this.options.onHover(a),this.markDirty())});w(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),n=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-t.left))<12&&Math.abs(d.y-(e.clientY-t.top))<12);if(n){this.scrollToTask(n.id);return}const{hit:i,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),l=this.rows[o];if(i){const d=this.tasksById.get(i.id);if(!d)return;if(a){e.stopPropagation(),this.openAssigneePopup(i.id,i);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(i.id);return}e.preventDefault(),this.drag={id:i.id,mode:i.mode,startX:e.clientX,startY:e.clientY,originStart:d.start,originEnd:d.end,start:d.start,end:d.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(i.id);return}if(!l)return;const r=this.tasksById.get(l.id);if(r){if(r.kind==="task"&&(!r.start||!r.end)){const d=this.pointAt(e.clientX,e.clientY),c=Math.floor(d.x/this.dayWidth),p=et(Fe(this.epochStart,c));this.options.onTaskChange({...r,start:p,end:et(Fe(Pe(p),4)),progress:0,status:"not-started"}),this.options.onSelect(l.id);return}this.options.onSelect(l.id)}});w(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const n=this.tasksById.get(t.id);if(!n||!t.moved&&Math.abs(e.clientX-t.startX)<ta)return;t.moved=!0;const i=this.dayWidth,o=Math.round((e.clientX-t.startX)/i),a=Pe(t.originStart),l=Pe(t.originEnd),r=We(a,l);let d,c;t.mode==="resize-l"?(d=Fe(a,Math.min(o,r)),c=l):t.mode==="resize-r"?(d=a,c=Fe(l,Math.max(o,-r))):(d=Fe(a,o),c=Fe(l,o)),n.milestone&&(d=c),t.start=et(d),t.end=et(c),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=n.milestone?Jt(t.start):`${Jt(t.start)} → ${Jt(t.end)}`;const p=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-p.left+12}px`,this.eTooltip.style.top=`${e.clientY-p.top+16}px`});w(this,"endDrag",()=>{window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.eTooltip.style.display="none";const e=this.drag;if(this.drag=null,this.ghost=null,this.markDirty(),!(e!=null&&e.moved)||e.start===e.originStart&&e.end===e.originEnd)return;const t=this.tasksById.get(e.id);t&&this.options.onTaskChange({...t,start:e.start,end:e.end})});w(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});w(this,"onDocumentMouseDown",e=>{const t=e.target;this.ePopup&&!this.ePopup.contains(t)&&this.closeAssigneePopup(),this.eStepMenu&&!this.eStepMenu.contains(t)&&!this.eRulerTools.contains(t)&&this.closeStepMenu()});this.options=t,this.eRoot=document.createElement("div"),this.interactions=$e(this.eRoot,"gantt-chart",t),this.onInteraction=this.interactions.onInteraction,this.eRoot.className="gt-root",e.appendChild(this.eRoot),this.eHeader=document.createElement("div"),this.eHeader.className="gt-header",this.eRuler=document.createElement("canvas"),this.eRuler.className="gt-ruler",this.eHeader.appendChild(this.eRuler),this.eRoot.appendChild(this.eHeader),this.rulerCtx=this.eRuler.getContext("2d"),this.buildRulerTools(),this.eScroll=document.createElement("div"),this.eScroll.className="gt-scroll",this.eSpacer=document.createElement("div"),this.eSpacer.className="gt-spacer",this.eCanvas=document.createElement("canvas"),this.eCanvas.className="gt-canvas",this.eScroll.append(this.eSpacer,this.eCanvas),this.eRoot.appendChild(this.eScroll),this.ctx=this.eCanvas.getContext("2d"),this.eTooltip=document.createElement("div"),this.eTooltip.className="gt-tooltip",this.eTooltip.style.display="none",this.eRoot.appendChild(this.eTooltip),this.eTodayBadge=document.createElement("div"),this.eTodayBadge.className="gt-today-badge",this.eRoot.appendChild(this.eTodayBadge),this.eScroll.addEventListener("scroll",this.onScroll),this.eCanvas.addEventListener("mousedown",this.onCanvasMouseDown),this.eCanvas.addEventListener("mousemove",this.onCanvasMouseMove),this.eRoot.addEventListener("mouseleave",this.onRootMouseLeave);const n=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(n),this.observer.observe(this.eScroll),this.observer.observe(this.eHeader)),window.addEventListener("resize",this.resizeHandler),this.timer=setInterval(this.tick,40),this.resizeCanvases()}destroy(){var e;this.interactions.destroy(),clearInterval(this.timer),(e=this.observer)==null||e.disconnect(),window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.closeAssigneePopup(),this.closeStepMenu(),this.eRoot.remove()}setHover(e){this.hoverId!==e&&(this.hoverId=e,this.markDirty())}setShowChildren(e){this.showChildren=e,this.markDirty()}setMilestonesOnly(e){this.milestonesOnly=e,this.markDirty()}scrollToTask(e){const t=this.tasksById.get(e);t!=null&&t.start&&(this.eScroll.scrollLeft=Math.max(0,this.dateX(t.start)-this.eScroll.clientWidth*.12),this.markDirty())}setTasks(e){this.tasks=e,this.tasksById=new Map(e.map(t=>[t.id,t])),this.computeDomain(),this.markDirty()}setRows(e){e.length===this.rows.length&&e.every((t,n)=>{const i=this.rows[n];return t.id===i.id&&t.group===i.group&&t.expanded===i.expanded})||(this.rows=e,this.markDirty())}setSelected(e){this.selectedId=e,this.markDirty()}setUnit(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.unit=e,this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setZoom(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.zoom=Math.max(.5,Math.min(3,e)),this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setTheme(e){this.theme=e,this.markDirty()}get dayWidth(){return Qo[this.unit]*this.zoom}get scrollElement(){return this.eScroll}setScrollTop(e){this.eScroll.scrollTop=e}redraw(){this.markDirty()}markDirty(){this.dirty=!0,this.tick()}scrollToToday(e=.32){const t=this.dateX(xt()),n=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=n}computeDomain(){let e=null,t=null;for(const o of this.tasks)!o.start||!o.end||((!e||o.start<e)&&(e=o.start),(!t||o.end>t)&&(t=o.end));const n=xt();(!e||e>n)&&(e=n),(!t||t<n)&&(t=n);const i=en(Fe(Pe(e),-7));this.epochStart=i,this.totalDays=Math.max(We(i,Pe(t))+730,1095)}dateX(e){return We(this.epochStart,e)*this.dayWidth}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[t,n]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const i=t===this.eRuler?this.eHeader.clientWidth:this.eScroll.clientWidth,o=t===this.eRuler?this.eHeader.clientHeight:this.eScroll.clientHeight;t.width=Math.max(1,Math.round(i*e)),t.height=Math.max(1,Math.round(o*e)),t.style.width=`${i}px`,t.style.height=`${o}px`,n.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,n=this.totalDays*e,i=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${n}px`,this.eSpacer.style.height=`${i}px`,this.drawRuler(e,n),this.drawBody(e,n,i,t)}drawRuler(e,t){const n=this.rulerCtx,i=this.eHeader.clientWidth,o=this.eHeader.clientHeight,a=this.eScroll.scrollLeft;n.clearRect(0,0,i,o),n.fillStyle="#fff",n.fillRect(0,0,i,o);const l=Fe(this.epochStart,this.totalDays),r=(p,h,u,f)=>{for(const g of p){const v=this.dateX(et(g.start))-a,m=We(g.start,g.end)*e;if(v+m<=0||v>=i)continue;const y=Math.max(0,Math.min(v+m,i)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const b=g.start.getDay();(b===0||b===6)&&(n.fillStyle=Re.weekend,n.fillRect(Math.max(0,v),h,y,u))}const x=n.measureText(g.primary).width;if(x+8<y){const b=Math.max(0,v)+y/2-x/2,I=h+u/2+5;n.fillStyle=Re.text,n.font="11px "+Ke,n.textAlign="left",n.textBaseline="alphabetic",n.fillText(g.primary,b,I),g.secondary&&(n.fillStyle=Re.textTertiary,n.font="10px "+Ke,n.fillText(g.secondary,b,I+12))}}},d=40,c=Fe(this.epochStart,Math.floor(a/e));n.fillStyle=Re.text,n.font="14px "+Ke,n.textAlign="left",n.textBaseline="middle",n.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(ei(this.unit,this.epochStart,l),d+1,o-d-1),n.strokeStyle=Re.border,n.beginPath(),n.moveTo(0,o-.5),n.lineTo(i,o-.5),n.stroke()}drawBody(e,t,n,i){const o=this.ctx,a=this.eScroll.clientWidth,l=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;o.clearRect(0,0,a,l),o.fillStyle="#fff",o.fillRect(0,0,a,l),o.save(),o.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(n,d+l)),this.drawGridlines(e,t,Math.max(n,d+l)),this.drawRowBackgrounds(t,i);const c=this.rows.findIndex(h=>h.id===this.hoverId),p=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(p==null?void 0:p.kind)==="task"&&!p.start){const h=c*i+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,ct(o,r+4,h,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Re.textTertiary,o.font="14px "+Ke,o.textAlign="center",o.fillText("新建排期",r+a/2,h+19)}this.drawDependencies(i),this.drawBars(i),this.drawTodayLine(t,Math.max(n,d+l)),o.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,n){if(this.unit!=="day"&&this.unit!=="week")return;const i=this.ctx;i.fillStyle=Re.weekend;let o=en(this.epochStart);for(;We(this.epochStart,o)<this.totalDays;){const a=this.dateX(et(o))+5*e;a<t&&i.fillRect(Math.max(0,a),0,e*2,n),o=Fe(o,7)}}drawGridlines(e,t,n){const i=this.ctx,o=Fe(this.epochStart,this.totalDays);for(const a of ei(this.unit,this.epochStart,o)){const l=Math.round(this.dateX(et(a.start)))+.5;if(l<0||l>t)continue;const r=this.unit==="day"&&a.start.getDate()===1;i.strokeStyle=r?Re.gridlineMonth:Re.gridline,i.beginPath(),i.moveTo(l,0),i.lineTo(l,n),i.stroke()}}drawRowBackgrounds(e,t){const n=this.ctx;n.strokeStyle=Re.rowLine,n.lineWidth=1,n.beginPath();for(let i=1;i<this.rows.length;i++){const o=Math.round(i*t)+.5;n.moveTo(0,o),n.lineTo(e,o)}n.stroke(),this.rows.forEach((i,o)=>{const a=this.selectedId===i.id,l=this.hoverId===i.id;(a||l)&&(n.fillStyle=a?Re.selected:l?Re.hover:Re.groupRow,n.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const n=this.ctx,i=Math.round(this.dateX(xt())+this.dayWidth/2)+.5;i<0||i>e||(n.strokeStyle=Re.accent,n.lineWidth=1.5,n.beginPath(),n.moveTo(i,0),n.lineTo(i,t),n.stroke(),this.todayLabelX=i-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=xt().slice(5),this.eTodayBadge.style.left=`${this.todayLabelX-25}px`,this.eTodayBadge.style.top=`${this.eHeader.clientHeight-10}px`}drawDependencies(e){const t=new Map(this.rows.map((i,o)=>[i.id,o])),n=this.ctx;n.strokeStyle=Re.accent,n.lineWidth=1.2;for(const i of this.rows){const o=this.tasksById.get(i.id);if(!o||o.kind!=="task"||!o.start||!o.end)continue;const a=t.get(i.id);if(a!==void 0)for(const l of o.dependsOn){const r=this.tasksById.get(l),d=t.get(l);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),p=r.milestone?this.dayWidth:Math.max(We(Pe(r.start),Pe(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),h=c+p,u=d*e+e/2,f=this.dateX(o.start),g=Math.max(We(Pe(o.start),Pe(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=a*e+e/2,m=h+10;if(f-4>m)ii(n,h,u,m,v,f-5,v);else{const y=f+g+10;ii(n,h,u,m,v,y,v)}ia(n,f-5,v)}}}drawBars(e){this.rows.forEach((t,n)=>{const i=this.tasksById.get(t.id);if(!i||!i.start||i.path.length>1&&(!this.showChildren||this.milestonesOnly&&!i.milestone))return;const o=n*e+(e-qe)/2;if(t.group){this.drawSummaryBar(i,n,o);return}if(i.milestone){this.drawMilestone(i,n,o);return}i.end&&this.drawTaskBar(i,n,o)})}drawTaskBar(e,t,n){var u;const i=this.ctx,o=((u=this.ghost)==null?void 0:u.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,l=(o==null?void 0:o.end)??e.end,r=this.dateX(a),d=Math.max(28,(We(a,l)+1)*this.dayWidth),c=Ot[e.status];i.save(),i.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,i.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",i.strokeStyle=this.selectedId===e.id?Re.accent:"#dee0e3",i.lineWidth=1,ct(i,r,n,d,qe,4),i.fill(),i.stroke(),i.save(),ct(i,r,n,d,qe,4),i.clip(),i.beginPath(),i.arc(r+14,n+14,6,0,Math.PI*2),i.fillStyle=c,i.fill(),i.font="12px "+Ke,i.textBaseline="middle",i.textAlign="left",i.fillStyle=Re.text;const p=this.options.members.find(f=>f.id===e.owner),h=i.measureText(e.name).width;d>h+58?(i.fillText(e.name,r+26,n+14),p&&tn(i,r+h+42,n+14,7,Bt(p.id),p.name.slice(0,1))):p&&d>46&&tn(i,r+38,n+14,7,Bt(p.id),p.name.slice(0,1)),d>100&&(i.fillStyle=Re.textTertiary,i.textAlign="right",i.fillText(String(Jo(Pe(a),Pe(l))),r+d-8,n+14)),i.restore(),i.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:n,w:d,h:qe,mode:"move",avatar:p?{x:r+(d>h+58?h+42:38),y:n+14,r:7}:void 0})}drawSummaryBar(e,t,n){if(!e.start||!e.end)return;const i=this.tasks.filter(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),o=i[0],a=this.ctx,l=this.dateX(e.start),r=Math.max(92,(We(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?Re.accent:"#dee0e3",a.lineWidth=1,ct(a,l,n,r,qe,4),a.fill(),a.stroke(),a.fillStyle=o?Ot[o.status]:Ot[e.status],a.beginPath(),a.arc(l+14,n+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Re.text,a.font="11px "+Ke,a.textAlign="left",a.textBaseline="middle";const d=((o==null?void 0:o.name)??e.name)+(i.length>1?` +${i.length-1}`:"");a.fillText(na(a,d,r-32),l+25,n+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:l,y:n,w:r,h:qe,mode:"move"})}drawMilestone(e,t,n){var v;const i=this.ctx,o=this.dayWidth,a=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,l=a?a.start:e.start,r=Zo(e),d=Ot[r],c=this.dateX(l)+o/2;i.font="12px "+Ke;const p=i.measureText(e.name).width,h=e.owner?24:0,u=19+p+h+14,f=c-u/2;i.fillStyle="#fff",i.strokeStyle=d,i.lineWidth=1.5,ct(i,f,n,u,qe,4),i.fill(),i.stroke(),i.fillStyle=d,i.beginPath(),i.arc(f+7+3,n+qe/2,3,0,Math.PI*2),i.fill(),i.fillStyle=Re.text,i.textAlign="left",i.textBaseline="middle",i.fillText(e.name,f+14+5,n+qe/2+1);let g;if(e.owner){const m=this.options.members.find(y=>y.id===e.owner);m&&(tn(i,f+u-12,n+qe/2,9,Bt(m.id),m.name.slice(0,1)),g={x:f+u-12,y:n+qe/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:f,y:n,w:u,h:qe,mode:"move",avatar:g})}pushHit(e){this.hits.push(e);const t=this.hitsByRow.get(e.rowIndex);t?t.push(e):this.hitsByRow.set(e.rowIndex,[e])}drawLocateButtons(){this.locateHits=[];const e=this.ctx,t=this.eScroll.scrollLeft,n=this.eScroll.clientWidth;this.rows.forEach((i,o)=>{const a=this.tasksById.get(i.id);if(!(a!=null&&a.start)||!a.end||a.path.length>1&&(!this.showChildren||this.milestonesOnly&&!a.milestone))return;const l=this.dateX(a.start),r=this.dateX(a.end)+this.dayWidth;if(r>=t&&l<=t+n)return;const d=r<t?10:n-18,c=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",ct(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+Ke,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<t?"‹":"›",d+1,c),this.locateHits.push({id:a.id,x:d+1,y:c}))})}pointAt(e,t){const n=this.eScroll.getBoundingClientRect();return{x:e-n.left+this.eScroll.scrollLeft,y:t-n.top+this.eScroll.scrollTop}}hitAt(e,t){const n=this.pointAt(e,t),i=Math.floor(n.y/this.options.rowHeight),o=this.hitsByRow.get(i)??[];for(const a of o){if(a.avatar){const l=n.x-a.avatar.x,r=n.y-a.avatar.y;if(l*l+r*r<=a.avatar.r*a.avatar.r)return{hit:a,rowIndex:i,onAvatar:!0}}if(n.x>=a.x&&n.x<=a.x+a.w&&n.y>=a.y&&n.y<=a.y+a.h){const l=a.kind==="task"&&n.x<=a.x+ti,r=a.kind==="task"&&n.x>=a.x+a.w-ti;return{hit:{...a,mode:l?"resize-l":r?"resize-r":"move"},rowIndex:i,onAvatar:!1}}}return{hit:null,rowIndex:i,onAvatar:!1}}buildRulerTools(){this.eRulerTools=document.createElement("div"),this.eRulerTools.className="gt-ruler-tools",this.eHeader.appendChild(this.eRulerTools);const e=document.createElement("button");e.type="button",e.className="gt-ruler-btn gt-ruler-step",this.eStepLabel=document.createElement("span"),this.eStepLabel.className="gt-ruler-step-label",this.eStepLabel.textContent=Ht[this.unit];const t=document.createElement("span");t.className="gt-ruler-caret",t.textContent="▾",e.append(this.eStepLabel,t),e.addEventListener("click",o=>{o.stopPropagation(),this.toggleStepMenu()}),this.eRulerTools.appendChild(e);const n=this.toolButton("−","缩小",()=>this.zoomBy(-.25));this.eZoomValue=document.createElement("span"),this.eZoomValue.className="gt-ruler-zoom-value",this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`;const i=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(n,i),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,n){const i=document.createElement("button");return i.type="button",i.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(i.className="gt-ruler-btn gt-ruler-today"),i.textContent=e,i.title=t,i.addEventListener("click",o=>{o.stopPropagation(),n()}),i}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const t=this.totalDays*this.dayWidth-this.eScroll.clientWidth,n=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(t,n))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const i of Jn){const o=document.createElement("div");o.className="gt-step-item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(i===this.unit)),o.tabIndex=0,o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.setUnit(i),this.closeStepMenu())}),i===this.unit&&o.classList.add("gt-step-item-active"),o.textContent=Ht[i],o.addEventListener("click",a=>{a.stopPropagation(),this.setUnit(i),this.closeStepMenu()}),e.appendChild(o)}const t=this.eRulerTools.getBoundingClientRect(),n=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,n.right-t.right)}px`,e.style.top=`${t.bottom-n.top+4}px`,this.eRoot.appendChild(e),this.eStepMenu=e,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeStepMenu(){var e;(e=this.eStepMenu)==null||e.remove(),this.eStepMenu=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}updateRulerTools(){this.eStepLabel.textContent=Ht[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,t){this.closeAssigneePopup();const n=this.tasksById.get(e);if(!n)return;const i=document.createElement("div");i.className="gt-popup";const o=document.createElement("div");o.className="gt-popup-title",o.textContent="更换负责人",i.appendChild(o);for(const d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",n.owner===d.id&&c.classList.add("gt-popup-item-active");const p=document.createElement("span");p.className="gt-avatar",p.textContent=d.name.slice(0,1),p.style.backgroundColor=Bt(d.id);const h=document.createElement("span");h.textContent=d.name,c.append(p,h),c.addEventListener("click",u=>{u.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),i.appendChild(c)}if(n.owner){const d=document.createElement("div");d.className="gt-popup-item gt-popup-clear",d.textContent="取消负责人",d.addEventListener("click",c=>{c.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),i.appendChild(d)}const a=this.eRoot.getBoundingClientRect(),l=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;i.style.left=`${Math.min(a.width-150,Math.max(0,l-40))}px`,i.style.top=`${r+t.h+6}px`,this.eRoot.appendChild(i),this.ePopup=i,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const Ke="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function ct(s,e,t,n,i,o){const a=Math.max(0,n),l=Math.max(0,i);if(a===0||l===0)return;const r=Math.max(0,Math.min(o,a/2,l/2));s.beginPath(),s.moveTo(e+r,t),s.lineTo(e+a-r,t),s.arcTo(e+a,t,e+a,t+r,r),s.lineTo(e+a,t+l-r),s.arcTo(e+a,t+l,e+a-r,t+l,r),s.lineTo(e+r,t+l),s.arcTo(e,t+l,e,t+l-r,r),s.lineTo(e,t+r),s.arcTo(e,t,e+r,t,r),s.closePath()}function tn(s,e,t,n,i,o){s.beginPath(),s.arc(e,t,n,0,Math.PI*2),s.fillStyle=i,s.fill(),s.lineWidth=1.5,s.strokeStyle="#fff",s.stroke(),s.fillStyle="#fff",s.font=`10px ${Ke}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function na(s,e,t){if(t<=0)return"";if(s.measureText(e).width<=t)return e;let n=e.length;for(;n>1;){n--;const i=`${e.slice(0,n)}…`;if(s.measureText(i).width<=t)return i}return"…"}function ii(s,e,t,n,i,o,a){const r=i>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(n-5,t),s.quadraticCurveTo(n,t,n,t+5*r),s.lineTo(n,i-5*r),s.quadraticCurveTo(n,i,n+5*r,i),s.lineTo(o,a),s.stroke()}function ia(s,e,t){s.fillStyle=Re.accent,s.beginPath(),s.moveTo(e+5,t),s.lineTo(e-1,t-3.5),s.lineTo(e-1,t+3.5),s.closePath(),s.fill()}const si=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function Bt(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return si[e%si.length]}const sa={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应列宽",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多选筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"列显示",hideColumn:"隐藏此列",chooseColumns:"选择显示的列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",copy:"复制",copyWithHeaders:"复制(含表头)",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应宽度",expandAll:"展开全部",collapseAll:"收起全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"清除全部",join:"组合方式:",and:"且",or:"或",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",addCondition:"+ 添加条件",condTrue:"是",condFalse:"否",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"第",pageSize:"每页条数:",find:"在表格中查找…",matchCase:"区分大小写",of:"/",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity"};function oa(s,e){const t=document.createElement("section");t.className="rowvia-gantt",t.innerHTML=`<div class="gantt-app">
26
+ `))?`"${o.replace(/"/g,'""')}"`:o}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),n=this.getExportRows(e),i=[];e.skipHeader||i.push(t.map(o=>({value:o.headerName||o.field||o.colId,bold:!0})));for(const o of n)i.push(t.map(a=>{let l=Ce(a,o,this.grid.getApi());const r=this.groupValue(a,o);return r!==void 0&&(l=r),l instanceof Date&&(l=l.toISOString().slice(0,10)),{value:l}}));return Io([{name:e.sheetName||"Sheet1",rows:i}])}exportToCsv(e={}){const t=this.getDataAsCsv(e);this.download(new Blob([t],{type:"text/csv;charset=utf-8;"}),this.fileName(e,"csv"))}exportToExcel(e={}){const t=this.getDataAsExcel(e);this.download(t,this.fileName(e,"xlsx"))}getDataAsPdf(e={}){var f;const t=this.getExportColumns(e),n=this.getExportRows(e),i=t.map(g=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(g.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(g=>({text:e.processHeaderCallback?e.processHeaderCallback({column:g,api:this.grid.getApi()}):g.headerName||g.field||g.colId,bold:!0,align:g.type==="numberColumn"||g.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const g of n)(f=e.shouldRowBeSkipped)!=null&&f.call(e,{node:g,api:this.grid.getApi()})||(o.push(t.map(v=>{let m=this.getCellValueForExport(v,g,e);if(e.processCellCallback){const w=e.processCellCallback({value:Ce(v,g,this.grid.getApi()),formattedValue:m,node:g,column:v,api:this.grid.getApi()});w!=null&&(m=String(w))}return{text:m,align:v.type==="numberColumn"||v.cellDataType===!0?"right":"left"}})),a.push(void 0));const l=18,r=e.pageSize||"a4-landscape",[d,c]=r.includes("portrait")?[595,842]:[842,595],p=c-64-(e.title?24:0),h=Math.max(5,Math.floor(p/l)),u=[];o.length===0&&u.push({columnWidths:i,rows:[],rowFill:[]});for(let g=0;g<o.length;g+=h)u.push({columnWidths:i,rows:o.slice(g,g+h),rowFill:a.slice(g,g+h)});return bo(u,{pageSize:r,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const n=e instanceof ArrayBuffer?e:await e.arrayBuffer(),o=(await xo(n))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],l=o.rows.slice(1).map(r=>{const d={};return a.forEach((c,p)=>{const h=c||`col${p+1}`,u=r[p]??"",f=String(u).trim();d[h]=f!==""&&!isNaN(Number(f))&&!/^0\d/.test(f)?Number(f):u}),d});return t.onSuccess?t.onSuccess(l):this.grid.getApi().setRowData(l),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:l}),l}fileName(e,t){const n=e.fileName||this.grid.getOptions().fileName||"export";return n.endsWith(`.${t}`)?n:`${n}.${t}`}download(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),1e3)}copyToClipboard(e={}){const t={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},n=this.getDataAsCsv(t);this.lastCopied=n,this.writeToClipboard(n),this.grid.getEventService().dispatchEvent("pasteStart",{}),this.grid.getEventService().dispatchEvent("pasteEnd",{})}cutToClipboard(e={}){this.copyToClipboard(e);const t=this.getExportRows({onlySelected:!0,skipGroups:!0,skipFooters:!0,...e});t.length&&this.grid.getApi().applyTransaction({remove:t.map(n=>n.data)})}pasteFromClipboard(){navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(e=>this.pasteText(e),()=>{this.lastCopied&&this.pasteText(this.lastCopied)}):this.lastCopied&&this.pasteText(this.lastCopied)}pasteText(e){const t=this.grid.getEditService().getFocusedCell(),n=this.grid.getRangeSelectionService().getRanges();let i,o;if(n.length>0){const p=n[0];i=p.rowStartIndex;const h=this.grid.getColumns().center,u=h.findIndex(f=>f.colId===p.colStartId);o=h[u]??h[0]}else if(t)i=t.rowIndex,o=t.column;else return;const a=e.replace(/\r/g,"").split(`
27
+ `);a.length&&a[a.length-1]===""&&a.pop();const l=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=l.findIndex(p=>p.colId===o.colId),d=[],c=[];a.forEach((p,h)=>{const u=p.split(" "),f=i+h,g=this.grid.getDisplayedRowAtIndex(f);if(!g){const v={};u.forEach((m,w)=>{const k=l[r+w];k!=null&&k.field&&(v[k.field]=m)}),c.push(v);return}u.forEach((v,m)=>{const w=l[r+m];w&&this.grid.setCellValue(w,g,v,"paste")}),d.push(g)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const t=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t,()=>this.fallbackCopy(e,t)):this.fallbackCopy(e,t)}fallbackCopy(e,t){const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();try{document.execCommand("copy")}catch{}document.body.removeChild(n),t()}}const Mt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Rt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class $o{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var g,v;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const n=e.filter===!0?"text":e.filter,i=this.grid.getFilterService().getFilterInstance(e.colId),o=n==="set"?260:240,{ePopup:a}=this.popupService.createPopup(o,"ag-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=`Search ${e.headerName||e.field||""}`,a.appendChild(l);const r=i?{...i}:this.getDefaultModel(n);let d=i?{...i}:null;const c=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),close()},p=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),close()};if(n==="set")a.appendChild(this.buildSetFilter(e,r,m=>{d=m}));else if(n==="boolean"){const m=this.buildConditionSelect(["true","false"],String(r.filter??""),w=>{d={filterType:"boolean",filter:w==="true"}});a.appendChild(m)}else{const m=n==="number"?Rt:Mt,w=this.buildConditionSelect(m,r.type||m[0],k=>{r.type=k,d={...r}});if(a.appendChild(w),r.type!=="blank"&&r.type!=="notBlank")if(n==="number"&&r.type==="inRange"){const k=document.createElement("div");k.className="ag-filter-inputs";const C=document.createElement("input");C.type="number",C.className="ag-filter-input",C.value=r.filter??"",C.placeholder=this.grid.t("from"),C.addEventListener("input",()=>{d={...r,filter:C.value,filterTo:b.value}});const b=document.createElement("input");b.type="number",b.className="ag-filter-input",b.value=r.filterTo??"",b.placeholder=this.grid.t("to"),b.addEventListener("input",()=>{d={...r,filter:C.value,filterTo:b.value}}),k.appendChild(C),k.appendChild(b),a.appendChild(k)}else if(n==="date"){const k=document.createElement("div");k.className="ag-filter-inputs";const C=document.createElement("input");C.type="date",C.className="ag-filter-input",C.value=r.dateFrom??"",C.addEventListener("input",()=>{d={...r,dateFrom:C.value,dateTo:b.value}});const b=document.createElement("input");b.type="date",b.className="ag-filter-input",b.value=r.dateTo??"",b.addEventListener("input",()=>{d={...r,dateFrom:C.value,dateTo:b.value}}),k.appendChild(C),k.appendChild(b),a.appendChild(k)}else{const k=document.createElement("input");k.type=n==="number"?"number":"text",k.className="ag-filter-input",k.value=r.filter??"",k.placeholder=this.grid.t("filterOoo"),k.addEventListener("input",()=>{d={...r,filter:k.value}}),k.addEventListener("keydown",C=>{C.key==="Enter"&&c()}),a.appendChild(k),setTimeout(()=>k.focus(),0)}else d={...r}}if(n==="text"||n==="number"){const m=document.createElement("div");m.className="ag-filter-second-condition";const w=document.createElement("select");w.className="ag-filter-condition",w.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,w.value=r.operator||"AND",m.appendChild(w);const k=this.buildConditionSelect(n==="number"?Rt:Mt,((g=r.condition2)==null?void 0:g.type)||(n==="number"?Rt:Mt)[0],b=>{d||(d={...r}),d.condition2={...d.condition2,type:b}});m.appendChild(k);const C=document.createElement("input");C.type=n==="number"?"number":"text",C.className="ag-filter-input",C.placeholder=this.grid.t("secondValue"),C.value=((v=r.condition2)==null?void 0:v.filter)??"",C.addEventListener("input",()=>{d||(d={...r}),d.condition2={...d.condition2,filter:C.value}}),m.appendChild(C),a.appendChild(m),w.addEventListener("change",()=>{d||(d={...r}),d.operator=w.value})}const h=document.createElement("div");h.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",c);const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",p),h.appendChild(f),h.appendChild(u),a.appendChild(h),this.popupService.positionAt(a,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,n){const i=document.createElement("div");i.className="ag-set-filter";const o=document.createElement("input");o.type="text",o.className="ag-filter-input",o.placeholder=this.grid.t("search"),i.appendChild(o);const a=new Set;this.grid.getRowModel().forEachNode(g=>{!g.group&&!g.footer&&a.add(Ce(e,g,this.grid.getApi()))});const r=[...a].sort((g,v)=>g===v?0:g<v?-1:1),d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((t.values||[]).map(g=>String(g))),p=()=>{d.innerHTML="";const g=o.value.toLowerCase();let v=0;for(const m of r){const w=m==null?"(Blanks)":String(m);if(g&&!w.toLowerCase().includes(g))continue;v++;const k=document.createElement("label");k.className="ag-set-filter-item";const C=document.createElement("input");C.type="checkbox",C.checked=c.has(String(m)),C.addEventListener("change",()=>{C.checked?c.add(String(m)):c.delete(String(m)),n({filterType:"set",values:[...c]})});const b=document.createElement("span");b.textContent=w,k.appendChild(C),k.appendChild(b),d.appendChild(k)}if(v===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),d.appendChild(m)}};o.addEventListener("input",p),p();const h=document.createElement("div");h.className="ag-set-filter-actions";const u=document.createElement("button");u.className="ag-button ag-button-small",u.textContent=this.grid.t("selectAll"),u.addEventListener("click",()=>{c.clear();for(const g of r)c.add(String(g));p(),n({filterType:"set",values:[...c]})});const f=document.createElement("button");return f.className="ag-button ag-button-small",f.textContent=this.grid.t("clearAll"),f.addEventListener("click",()=>{c.clear(),p(),n({filterType:"set",values:[]})}),h.appendChild(u),h.appendChild(f),i.appendChild(d),i.appendChild(h),n({filterType:"set",values:[...c]}),i}buildConditionSelect(e,t,n){const i=document.createElement("select");i.className="ag-filter-condition";for(const o of e){const a=document.createElement("option");a.value=o;const l=Ps[o];a.textContent=l?this.grid.t(l):o,o===t&&(a.selected=!0),i.appendChild(a)}return i.addEventListener("change",()=>n(i.value)),i}openMultiFilter(e,t){var k;const n=this.grid.getFilterService().getFilterInstance(e.colId),i=n&&n.filterType==="multi"?n:null,o=(k=i==null?void 0:i.filterModels)!=null&&k.length?i.filterModels.map(C=>({...C})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(i==null?void 0:i.operator)||"AND";const{ePopup:l,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,l.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const p=document.createElement("span");p.textContent=this.grid.t("join");const h=document.createElement("select");h.className="ag-filter-condition",h.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',h.value=a,h.addEventListener("change",()=>{a=h.value}),c.appendChild(p),c.appendChild(h),l.appendChild(c);const u=document.createElement("div");u.className="ag-multi-filter-list",l.appendChild(u);const f=()=>{u.innerHTML="",o.forEach((C,b)=>{const N=document.createElement("div");N.className="ag-multi-filter-row";const I=document.createElement("select");I.className="ag-filter-condition";const E=["text","number","date","set","boolean"];for(const A of E){const H=document.createElement("option");H.value=A,H.textContent=A.charAt(0).toUpperCase()+A.slice(1),A===C.filterType&&(H.selected=!0),I.appendChild(H)}I.addEventListener("change",()=>{o[b]={...this.getDefaultModel(I.value)},f()}),N.appendChild(I);const G=C.filterType==="number"?Rt:Mt,x=this.buildConditionSelect(G,C.type||G[0],A=>{o[b].type=A});if(N.appendChild(x),C.filterType!=="blank"&&C.type!=="blank"&&C.type!=="notBlank"){const A=document.createElement("input");A.type=C.filterType==="number"?"number":"text",A.className="ag-filter-input",A.value=C.filter??"",A.placeholder=this.grid.t("value"),A.addEventListener("input",()=>{o[b].filter=A.value}),N.appendChild(A)}const T=document.createElement("button");T.className="ag-button ag-button-small",T.textContent="×",T.title=this.grid.t("removeFilter"),T.addEventListener("click",()=>{o.splice(b,1),f()}),N.appendChild(T),u.appendChild(N)})};f();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addFilter"),g.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),f()}),l.appendChild(g);const v=document.createElement("div");v.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",()=>{o.filter(b=>b.filter!==void 0&&b.filter!==""||b.type==="blank"||b.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(w),v.appendChild(m),l.appendChild(v),this.popupService.positionAt(l,t)}openAdvancedFilter(e){var k,C;const t=this.grid.getFilterService(),n=t.getAdvancedFilterModel(),i=(k=n==null?void 0:n.conditions)!=null&&k.length?n.conditions.map(b=>({...b})):[{colId:((C=this.grid.getColumns().center[0])==null?void 0:C.colId)??"",type:"contains",filter:""}];let o=(n==null?void 0:n.operator)||"AND";const{ePopup:a,close:l}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),a.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",a.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(b=>b.filter),p=()=>{d.innerHTML="",i.forEach((b,N)=>{const I=document.createElement("div");I.className="ag-advanced-filter-row";const E=document.createElement("select");E.className="ag-filter-condition";for(const R of c()){const P=document.createElement("option");P.value=R.colId,P.textContent=R.headerName||R.field||R.colId,R.colId===b.colId&&(P.selected=!0),E.appendChild(P)}E.addEventListener("change",()=>{i[N].colId=E.value}),I.appendChild(E);const G=this.grid.getColumn(b.colId),x=G&&G.filter!==!1?String(G.filter):"text",T=x==="number"?Rt:Mt,A=this.buildConditionSelect(T,b.type||"contains",R=>{i[N].type=R});I.appendChild(A);const H=document.createElement("input");H.type=x==="number"?"number":"text",H.className="ag-filter-input",H.value=b.filter??"",H.placeholder=this.grid.t("value"),H.addEventListener("input",()=>{i[N].filter=H.value}),I.appendChild(H);const q=document.createElement("button");q.className="ag-button ag-button-small",q.textContent="×",q.addEventListener("click",()=>{i.splice(N,1),p()}),I.appendChild(q),d.appendChild(I)})};p();const h=document.createElement("button");h.className="ag-button ag-button-small",h.textContent="+ "+this.grid.t("addCondition"),h.addEventListener("click",()=>{var b;i.push({colId:((b=c()[0])==null?void 0:b.colId)??"",type:"contains",filter:""}),p()}),a.appendChild(h);const u=document.createElement("div");u.className="ag-multi-filter-operator";const f=document.createElement("span");f.textContent=this.grid.t("join");const g=document.createElement("select");g.className="ag-filter-condition",g.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',g.value=o,g.addEventListener("change",()=>{o=g.value}),u.appendChild(f),u.appendChild(g),a.appendChild(u);const v=document.createElement("div");v.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",()=>{const b=i.filter(N=>N.filter!==void 0&&N.filter!=="");b.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:b}):t.setAdvancedFilterModel(null),l()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{t.setAdvancedFilterModel(null),l()}),v.appendChild(w),v.appendChild(m),a.appendChild(v),this.popupService.positionAt(a,e)}openCustomFilter(e,t){const n=e.colDef.filterComponent;if(typeof n!="function")return;const i=this.grid.getFilterService(),o=n({column:e,colDef:e.colDef,api:this.grid.getApi(),model:i.getFilterInstance(e.colId)??null,onModelChange:r=>i.setColumnFilterModel(e,r),onGuiAttached:()=>{}}),{ePopup:a}=this.popupService.createPopup(260,"ag-filter-popup");a.innerHTML="";const l=typeof(o==null?void 0:o.getGui)=="function"?o.getGui():o;l instanceof HTMLElement&&a.appendChild(l),typeof(o==null?void 0:o.afterGuiAttached)=="function"&&o.afterGuiAttached(),this.popupService.positionAt(a,t)}getDefaultModel(e){return e==="number"?{filterType:"number",type:"equals",filter:""}:e==="date"?{filterType:"date",dateFrom:"",dateTo:""}:e==="set"?{filterType:"set",values:[]}:e==="boolean"?{filterType:"boolean",filter:!0}:{filterType:"text",type:"contains",filter:""}}isMeaningful(e){return e.filterType==="text"?!!e.filter||e.type==="blank"||e.type==="notBlank":e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0:!1}}class Fo{constructor(e){y(this,"filterModel",{});y(this,"advancedFilterModel",null);this.grid=e}getAdvancedFilterModel(){return this.advancedFilterModel}setAdvancedFilterModel(e){this.advancedFilterModel=e,this.onFilterChanged("api")}isAdvancedFilterEnabled(){return!!this.grid.getOptions().enableAdvancedFilter}doesNodePassAdvancedFilter(e){const t=this.advancedFilterModel;if(!t||!t.conditions||t.conditions.length===0)return!0;const n=this.grid.getRowModel(),i=typeof n.doesNodePassFilterModel=="function"?n.doesNodePassFilterModel.bind(n):null,o=t.conditions.map(a=>{const l=this.grid.getColumn(a.colId);return!l||!i?!0:i(e,l,{...a,filterType:l.filter===!0?"text":l.filter})});return t.operator==="OR"?o.some(Boolean):o.every(Boolean)}getFilterModel(){return this.filterModel}getFilterInstance(e){return this.filterModel[e]}setFilterModel(e){this.filterModel=e||{},this.onFilterChanged("api")}setColumnFilterModel(e,t){const n=typeof e=="string"?e:e.colId;t==null?delete this.filterModel[n]:this.filterModel[n]=t,this.onFilterChanged("api")}isFilterActive(e){const t=this.filterModel[e.colId];return t?t.filterType==="multi"?(t.filterModels||[]).some(i=>this.isModelMeaningful(i)):this.isModelMeaningful(t):!1}isModelMeaningful(e){return e.filterType==="text"?!!e.filter:e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":!1}handleFloatingFilterChange(e,t){if(t===""||t===null||t===void 0){delete this.filterModel[e.colId],this.onFilterChanged("uiFilterModified");return}switch(e.filter){case"number":this.filterModel[e.colId]={filterType:"number",type:"equals",filter:t};break;case"date":this.filterModel[e.colId]={filterType:"date",dateFrom:t,dateTo:t};break;case"boolean":this.filterModel[e.colId]={filterType:"boolean",filter:t==="true"};break;case"set":this.filterModel[e.colId]={filterType:"set",values:[t]};break;default:this.filterModel[e.colId]={filterType:"text",type:"contains",filter:t};break}this.onFilterChanged("uiFilterModified")}resetFilters(){this.filterModel={},this.onFilterChanged("api")}onFilterChanged(e){var n,i;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(i=(n=this.grid.getOptions()).onFilterChanged)==null||i.call(n,{api:t,source:e})}}class Do{constructor(e,t){y(this,"matches",[]);y(this,"activeMatch",0);y(this,"searchText","");y(this,"matchCase",!1);y(this,"ePopup",null);y(this,"eCount",null);y(this,"eInput",null);y(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const n=document.createElement("input");n.type="text",n.className="ag-find-input",n.placeholder=this.grid.translate("find","Find in grid..."),n.value=this.searchText,this.eInput=n,e.appendChild(n);const i=document.createElement("label");i.className="ag-find-case";const o=document.createElement("input");o.type="checkbox",o.checked=this.matchCase,o.addEventListener("change",()=>{this.matchCase=o.checked,this.find(this.searchText)}),i.appendChild(o),i.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(i);const a=document.createElement("span");a.className="ag-find-count",this.eCount=a,e.appendChild(a);const l=(c,p,h)=>{const u=document.createElement("button");return u.className="ag-button ag-button-small",u.textContent=c,u.title=p,u.addEventListener("click",h),e.appendChild(u),u};l("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),l("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),l("×",this.grid.translate("close","关闭"),()=>this.close()),n.addEventListener("input",()=>this.find(n.value)),n.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),c.shiftKey?this.findPrevious():this.findNext()):c.key==="Escape"&&this.close()}),this.grid.getRootElement(),e.style.position="absolute",e.style.left="50%",e.style.top="8px",e.style.transform="translateX(-50%)",e.style.display="flex",setTimeout(()=>n.focus(),0)}close(){var e;(e=this.closePopup)==null||e.call(this),this.ePopup=null,this.closePopup=null,this.eInput=null,this.eCount=null,this.matches=[],this.applyHighlight()}setFindText(e){this.searchText=e,this.eInput&&(this.eInput.value=e),this.find(e)}getFindText(){return this.searchText}getNumMatches(){return this.matches.length}getActiveMatch(){return this.activeMatch}find(e){if(this.searchText=e,this.matches=[],this.activeMatch=0,e){const t=this.grid.getColumns().center;this.grid.getRowModel().forEachNode((n,i)=>{if(!(n.group||n.footer))for(const o of t){const a=Ht(o,n,this.grid.getApi())??"",l=this.matchCase?a:a.toLowerCase(),r=this.matchCase?e:e.toLowerCase();l.includes(r)&&this.matches.push({rowIndex:i,colId:o.colId})}})}this.eCount&&(this.eCount.textContent=this.matches.length?`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`:this.grid.translate("noMatches","No matches")),this.applyHighlight()}findNext(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch+1)%this.matches.length,this.goToActive(),!0)}findPrevious(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch-1+this.matches.length)%this.matches.length,this.goToActive(),!0)}goToActive(){var o,a;const e=this.matches[this.activeMatch];if(!e)return;this.eCount&&(this.eCount.textContent=`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`);const t=(a=(o=this.grid).getPaginationService)==null?void 0:a.call(o);if(t!=null&&t.isEnabled()){const l=t.getPageSize(),r=Math.floor(e.rowIndex/l);r!==t.getCurrentPage()&&t.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const n=this.grid.getDisplayedRowAtIndex(e.rowIndex),i=this.grid.getColumn(e.colId);n&&i&&this.grid.getEditService().setFocusedCell(e.rowIndex,i)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,n]of e){let i=-1;this.grid.getRowModel().forEachNode((o,a)=>{o.id===t&&(i=a)});for(const o of n.getCellElements()){const a=o.dataset.colid,l=this.matches.findIndex(r=>r.rowIndex===i&&r.colId===a);o.classList.toggle("ag-find-match",l>=0),o.classList.toggle("ag-find-active-match",l>=0&&l===this.activeMatch)}}}}class Po{constructor(e,t){this.grid=e,this.popupService=t}isFormulaColumn(e){return typeof e.field=="string"&&e.field.trimStart().startsWith("=")}openFormulaEditor(e,t){const{ePopup:n,close:i}=this.popupService.createPopup(460,"ag-formula-editor");n.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,n.appendChild(o);const a=document.createElement("textarea");a.className="ag-formula-input",a.rows=3,a.value=this.isFormulaColumn(e)?e.field:"=",a.placeholder=this.grid.t("formulaPlaceholder"),n.appendChild(a);const l=document.createElement("div");l.className="ag-formula-preview";const r=()=>{const g=this.grid.getDisplayedRowAtIndex(0);if(!g){l.textContent="";return}try{const v=xt(a.value,{data:g.data});l.textContent=`${this.grid.t("formulaPreview")}: ${v==null?"":String(v)}`,l.classList.remove("ag-formula-error")}catch(v){l.textContent=`${this.grid.t("formulaError")}: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||this.grid.t("invalidFormula")}`,l.classList.add("ag-formula-error")}};a.addEventListener("input",r),n.appendChild(l);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent=this.grid.t("functions"),d.appendChild(c);const p=document.createElement("div");p.className="ag-formula-functions-list";for(const g of Pt){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=g,v.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${g}()`,a.focus(),r()}),p.appendChild(v)}d.appendChild(p),n.appendChild(d);const h=document.createElement("div");h.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",()=>{const g=a.value.trim(),v=this.grid.getColumnModel(),m=v.getColumn(e.colId);m&&(m.field=g==="="||g===""?e.field:g,m.colDef={...m.colDef,field:m.field},g!=="="&&g!==""&&(m.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),i()});const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",()=>{a.value="=",r()}),h.appendChild(f),h.appendChild(u),n.appendChild(h),this.popupService.positionAt(n,t),r()}}class Ho{constructor(e,t){y(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,n,i){const o=this.runtimeNotes.get(this.keyOf(e,t));if(o!==void 0)return o;if(typeof n=="function")return n(i);if(typeof n=="string")return n}setNote(e,t,n){const i=this.keyOf(e,t);n==null||n===""?this.runtimeNotes.delete(i):this.runtimeNotes.set(i,n),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,n){const i=this.grid.getColumn(t),o=this.grid.getRowNode(e),a=this.getNote(e,t,i==null?void 0:i.colDef.note,{data:o==null?void 0:o.data,node:o,column:i,api:this.grid.getApi()})??"",{ePopup:l,close:r}=this.popupService.createPopup(280,"ag-note-editor");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`${this.grid.t("note")} — ${(i==null?void 0:i.headerName)||t}`,l.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=a,c.placeholder=this.grid.t("writeNote"),l.appendChild(c);const p=document.createElement("div");p.className="ag-popup-buttons";const h=document.createElement("button");h.className="ag-button ag-button-primary",h.textContent=this.grid.t("save"),h.addEventListener("click",()=>{this.setNote(e,t,c.value.trim()||void 0),r()});const u=document.createElement("button");u.className="ag-button",u.textContent=this.grid.t("delete"),u.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),p.appendChild(u),p.appendChild(h),l.appendChild(p),this.popupService.positionAt(l,n),setTimeout(()=>c.focus(),0)}}class Oo{constructor(e){y(this,"eOverlayWrapper");y(this,"current",null);this.grid=e,this.eOverlayWrapper=document.createElement("div"),this.eOverlayWrapper.className="ag-overlay",this.eOverlayWrapper.style.display="none";const t=e.getRowRenderer().getViewport();t.style.position="relative",this.eOverlayWrapper.style.position="absolute",this.eOverlayWrapper.style.inset="0",this.eOverlayWrapper.style.zIndex="10",t.appendChild(this.eOverlayWrapper)}show(e,t){this.current=e,this.eOverlayWrapper.innerHTML="";const n=document.createElement("div");n.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const i=document.createElement("div");if(i.className="ag-overlay-text",i.textContent=t,e==="loading"){const o=document.createElement("div");o.className="ag-overlay-loading-spinner",n.appendChild(o)}n.appendChild(i),this.eOverlayWrapper.appendChild(n),this.eOverlayWrapper.style.display="flex"}showLoadingOverlay(){this.show("loading",this.grid.translate("loadingOoo","Loading..."))}showNoRowsOverlay(){this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show"))}hideOverlay(){this.current=null,this.eOverlayWrapper.style.display="none",this.eOverlayWrapper.innerHTML=""}updateAuto(){const e=this.grid.getRowModel();if(!!this.grid.getOptions().__loadingRows){this.showLoadingOverlay();return}e.getRowCount()===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}class ei{constructor(e,t){y(this,"enabled");y(this,"pageSize");y(this,"currentPage",0);y(this,"pageSizeSelector");y(this,"ePanel");y(this,"ePageInfo");y(this,"ePageInput");y(this,"ePageSizeContainer");y(this,"eFromToContainer");this.grid=e,this.eventService=t;const n=e.getOptions();this.enabled=n.pagination===!0,this.pageSize=n.paginationPageSize??100,this.pageSizeSelector=n.paginationPageSizeSelector??[20,50,100,500,1e3],this.ePanel=document.createElement("div"),this.ePanel.className="ag-pagination-panel",this.enabled||(this.ePanel.style.display="none");const i=document.createElement("div");i.className="ag-pagination-buttons",this.ePanel.appendChild(i),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",i.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",i.appendChild(this.eFromToContainer);const o=document.createElement("span");if(o.className="ag-pagination-page-label",o.textContent=`${this.grid.translate("page","Page")}`,i.appendChild(o),this.ePageInput=document.createElement("input"),this.ePageInput.className="ag-pagination-page-input",this.ePageInput.type="number",this.ePageInput.min="1",this.ePageInput.value="1",this.ePageInput.title=this.grid.translate("pageNumber","输入页码"),this.ePageInput.addEventListener("change",()=>{const a=parseInt(this.ePageInput.value,10);isNaN(a)||this.goToPage(a-1)}),i.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",i.appendChild(this.ePageInfo),this.pageSizeSelector){const a=this.ePageSizeContainer,l=document.createElement("span");l.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(l);const r=document.createElement("select");r.className="ag-pagination-page-size-select";const d=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const c of d){const p=document.createElement("option");p.value=String(c),p.textContent=String(c),c===this.pageSize&&(p.selected=!0),r.appendChild(p)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),a.appendChild(r)}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),n=Math.max(0,Math.min(t-1,e));if(n===this.currentPage){this.update();return}this.currentPage=n,this.grid.refreshModel("everything"),this.update(),this.grid.getRowRenderer().setVerticalScrollTop(0)}goToNextPage(){this.goToPage(this.currentPage+1)}goToPreviousPage(){this.goToPage(this.currentPage-1)}goToFirstPage(){this.goToPage(0)}goToLastPage(){this.goToPage(this.getTotalPages()-1)}update(){var l,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),n=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),i=n===0?0:this.currentPage*this.pageSize+1,o=Math.min(n,(this.currentPage+1)*this.pageSize);this.ePageInfo.textContent=`${this.grid.translate("of","/")} ${e}`,this.ePageInput.value=String(this.currentPage+1),this.ePageInput.max=String(e);const a=this.grid.translate("rangeTo","至");this.eFromToContainer.textContent=n===0?`0 ${a} 0 ${this.grid.translate("of","/")} 0`:`${i.toLocaleString()} ${a} ${o.toLocaleString()} ${this.grid.translate("of","/")} ${n.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:n}),(r=(l=this.grid.getOptions()).onPaginationChanged)==null||r.call(l,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Bo{constructor(e){y(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,t=""){const n=document.createElement("div");n.className=`ag-popup ${t}`.trim(),n.style.width=`${e}px`,n.style.display="none";const i={ePopup:n},o=()=>{var d;this.openPopups.has(i)&&(this.openPopups.delete(i),n.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",r,!0),(d=i.onClose)==null||d.call(i))},a=d=>{i.onClose=d},l=d=>{if(!n.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){o();return}n.contains(d.target)||o()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),o())};return this.getParent().appendChild(n),this.openPopups.add(i),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",r,!0),{ePopup:n,close:o,onClose:a}}positionAt(e,t,n=0){const i=this.grid.getRootElement().getBoundingClientRect(),o=t.getBoundingClientRect(),a=e.offsetWidth||220;let l=o.left-i.left+n;const r=i.width-a-4;l>r&&(l=r),l<4&&(l=4);const d=o.bottom-i.top+2;e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}class Vo{constructor(e,t){y(this,"ranges",[]);y(this,"currentRange",null);y(this,"eOverlay");y(this,"eHandle");y(this,"dragState",null);this.grid=e,this.eventService=t;const n=e.getRowRenderer().getContainer();n.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",n.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",n.appendChild(this.eHandle),document.addEventListener("mousemove",this.onMouseMove.bind(this)),document.addEventListener("mouseup",this.onMouseUp.bind(this)),t.addEventListener("bodyScroll",()=>this.updateOverlay())}isEnabled(){return!!this.grid.getOptions().enableRangeSelection}getRanges(){return this.ranges}clearRanges(){this.ranges=[],this.currentRange=null,this.updateOverlay(),this.applyHighlight(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0})}onCellMouseDown(e){if(!this.isEnabled())return;const{event:t,column:n,rowIndex:i}=e;if(t.button!==0)return;if(t.shiftKey&&this.ranges.length>0){const a=this.ranges[this.ranges.length-1];this.currentRange={...a,rowEndIndex:i,colEndId:n.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const o={rowStartIndex:i,rowEndIndex:i,colStartId:n.colId,colEndId:n.colId};this.currentRange=o,this.dragState={startRange:o,mode:"create"},this.updateOverlay()}onHandleMouseDown(e){this.currentRange&&(e.stopPropagation(),this.dragState={startRange:{...this.currentRange},mode:"handle"})}onMouseMove(e){if(!this.dragState||!this.currentRange)return;const t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;const n=t.closest(".ag-cell");if(!(n!=null&&n.dataset.colid))return;const i=n.closest(".ag-row");if(!(i!=null&&i.dataset.rowid))return;const o=this.grid.getRowModel().getRowNode(i.dataset.rowid);if(!o)return;let a=-1;if(this.grid.getRowModel().forEachNode((r,d)=>{r.id===o.id&&(a=d)}),a<0)return;const l=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(l.rowStartIndex,a),rowEndIndex:Math.max(l.rowStartIndex,a),colStartId:l.colStartId,colEndId:n.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(l.rowStartIndex,a),this.currentRange.colEndId=n.dataset.colid),this.updateOverlay()}onMouseUp(){!this.dragState||!this.currentRange||(this.dragState=null,this.ranges=[this.currentRange],this.applyHighlight(),this.updateOverlay(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0}))}getCenterColumns(){return this.grid.getColumns().center}getRangeBounds(e){const t=this.getCenterColumns(),n=t.findIndex(g=>g.colId===e.colStartId),i=t.findIndex(g=>g.colId===e.colEndId);if(n<0||i<0)return null;const o=Math.min(n,i),a=Math.max(n,i);let l=0,r=0;for(let g=0;g<=a;g++)g<o?l+=t[g].width:r+=t[g].width;const c=this.grid.getRowRenderer().getRowOffsets(),p=Math.min(e.rowStartIndex,e.rowEndIndex),h=Math.max(e.rowStartIndex,e.rowEndIndex),u=c[p]??p*(this.grid.getOptions().rowHeight??42);let f=0;for(let g=p;g<=h;g++){const v=this.grid.getDisplayedRowAtIndex(g);f+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:u,left:l,width:r,height:f}}updateOverlay(){const e=this.currentRange;if(!e||!this.isEnabled()){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}const t=this.getRangeBounds(e);if(!t){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}this.eOverlay.style.display="block",this.eOverlay.style.top=`${t.top}px`,this.eOverlay.style.left=`${t.left}px`,this.eOverlay.style.width=`${t.width}px`,this.eOverlay.style.height=`${t.height}px`,this.eHandle.style.display="block",this.eHandle.style.top=`${t.top+t.height-4}px`,this.eHandle.style.left=`${t.left+t.width-4}px`,this.eHandle.onmousedown=n=>this.onHandleMouseDown(n)}applyHighlight(){const e=this.ranges,t=this.grid.getRowRenderer().getRowComps(),n=this.getCenterColumns();for(const[i,o]of t){let a=-1;if(this.grid.getRowModel().forEachNode((l,r)=>{l.id===i&&(a=r)}),!(a<0))for(const l of o.getCellElements()){const r=l.dataset.colid,d=n.findIndex(h=>h.colId===r);let c=!1,p=!1;for(const h of e){const u=n.findIndex(k=>k.colId===h.colStartId),f=n.findIndex(k=>k.colId===h.colEndId),g=Math.min(h.rowStartIndex,h.rowEndIndex),v=Math.max(h.rowStartIndex,h.rowEndIndex),m=Math.min(u,f),w=Math.max(u,f);a>=g&&a<=v&&d>=m&&d<=w&&(c=!0,a===h.rowStartIndex&&d===u&&(p=!0))}l.classList.toggle("ag-cell-range-selected",c),l.classList.toggle("ag-cell-range-anchor",p)}}}getRangeCells(e){const t=this.getCenterColumns(),n=t.findIndex(c=>c.colId===e.colStartId),i=t.findIndex(c=>c.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),l=Math.min(n,i),r=Math.max(n,i),d=[];for(let c=o;c<=a;c++){const p=this.grid.getDisplayedRowAtIndex(c);if(p)for(let h=l;h<=r;h++)t[h]&&d.push({node:p,column:t[h]})}return d}getCurrentRange(){return this.currentRange}onGridKeyDown(e){if(this.isEnabled()){if((e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().copyToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="x"||e.key==="X")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().cutToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().pasteFromClipboard());return}if((e.keyCode===46||e.keyCode===8)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const n of this.getRangeCells(t))this.grid.setCellValue(n.column,n.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}class Go{constructor(e,t){y(this,"dragState",null);y(this,"onMouseMoveBind",e=>this.onMouseMove(e));y(this,"onMouseUpBind",e=>this.onMouseUp(e));this.grid=e,this.eventService=t}isEnabled(){const e=this.grid.getOptions();return!!e.rowDragManaged||!!e.rowDragEnt||this.hasDragHandle()}hasDragHandle(){return this.grid.getAllColumns().some(e=>e.rowDrag)}startDrag(e,t){if(!this.isEnabled()||this.dragState)return;t.preventDefault();const n=document.createElement("div");n.className="ag-row-drag-ghost",n.textContent=this.rowLabel(e),document.body.appendChild(n);const i=document.createElement("div");i.className="ag-row-drop-indicator",i.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(i),this.dragState={rowNode:e,ghost:n,startY:t.clientY,overIndex:null,indicator:i},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var i;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],n=t!=null&&t.field?(i=e.data)==null?void 0:i[t.field]:"";return String(n??e.id)}onMouseMove(e){const t=this.dragState;if(!t)return;t.ghost.style.left=`${e.clientX+8}px`,t.ghost.style.top=`${e.clientY+8}px`;const n=document.elementFromPoint(e.clientX,e.clientY),i=n==null?void 0:n.closest(".ag-row");if(!(i!=null&&i.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let o=-1;if(this.grid.getRowModel().forEachNode((a,l)=>{a.id===i.dataset.rowid&&(o=l)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),l=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),r=e.clientY>i.getBoundingClientRect().top+l/2,d=(a[o]??0)+(r?l:0);t.indicator.style.display="block",t.indicator.style.top=`${d-1}px`}else t.indicator.style.display="none"}onMouseUp(e){const t=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!t)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),t.ghost.remove(),t.indicator.remove();const n=this.grid.getApi(),i=this.grid.getOptions(),o=t.overIndex,a=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:n,node:t.rowNode,overIndex:o,overNode:o!==null?this.grid.getDisplayedRowAtIndex(o):void 0,y:e.clientY}),i.rowDragManaged&&a>=0&&o!==null&&o!==a&&this.moveRow(a,o,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((n,i)=>{n.id===e.id&&(t=i)}),t}moveRow(e,t,n){const i=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=i.length)return;const[o]=i.splice(e,1),a=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),i.splice(Math.max(0,Math.min(i.length,a+1)),0,o),this.grid.getApi().setRowData(i),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:o}})}}class qo{constructor(e){y(this,"ePanel");y(this,"eChips");this.grid=e,this.ePanel=document.createElement("div"),this.ePanel.className="ag-row-group-panel";const t=document.createElement("span");t.className="ag-row-group-panel-label",t.textContent=this.grid.t("rowGroups"),this.ePanel.appendChild(t),this.eChips=document.createElement("div"),this.eChips.className="ag-row-group-panel-chips",this.ePanel.appendChild(this.eChips),this.eChips.addEventListener("dragover",o=>{o.preventDefault(),this.eChips.classList.add("ag-drag-over")}),this.eChips.addEventListener("dragleave",()=>this.eChips.classList.remove("ag-drag-over")),this.eChips.addEventListener("drop",o=>{var l;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(l=o.dataTransfer)==null?void 0:l.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const n=e.getOptions();(n.rowGroupPanelShow==="always"||n.rowGroupPanelShow==="onlyWhenGrouping")&&e.getMainElement().insertBefore(this.ePanel,e.getHeaderElement()),this.refresh(),e.getEventService().addEventListener("columnRowGroupChanged",()=>this.refresh()),e.getEventService().addEventListener("modelUpdated",()=>this.refreshVisibility())}refresh(){this.eChips.innerHTML="";const e=this.grid.getColumnModel().getRowGroupColumns();for(const t of e){const n=document.createElement("div");n.className="ag-row-group-chip",n.draggable=!0,n.addEventListener("dragstart",a=>{var l;(l=a.dataTransfer)==null||l.setData("text/plain",t.colId)});const i=document.createElement("span");i.textContent=t.headerName,n.appendChild(i);const o=document.createElement("button");o.className="ag-row-group-chip-remove",o.textContent="×",o.title=this.grid.t("remove"),o.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(t)),n.appendChild(o),this.eChips.appendChild(n)}if(e.length===0){const t=document.createElement("span");t.className="ag-column-group-hint",t.textContent=this.grid.t("dragColumnsHere"),this.eChips.appendChild(t)}this.refreshVisibility()}refreshVisibility(){const e=this.grid.getOptions().rowGroupPanelShow;if(e==="always")this.ePanel.style.display="";else if(e==="onlyWhenGrouping"){const t=this.grid.getColumnModel().isRowGroupActive();this.ePanel.style.display=t?"":"none"}}}class zo{constructor(e,t,n){y(this,"selectedNodes",new Set);y(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=t,this.isNodeSelectable=n}isEnabled(){return!!this.getOptions().rowSelection}getSelectedNodes(){return[...this.selectedNodes]}getSelectedRows(){return[...this.selectedNodes].map(e=>e.data)}getSelectedCount(){return this.selectedNodes.size}isNodeSelected(e){return this.selectedNodes.has(e)}selectNode(e,t=!1){this.isEnabled()&&this.isNodeSelectable(e)&&(t&&this.getOptions().rowSelection==="multiple"?this.deselectAll():t&&this.deselectAll(),!this.selectedNodes.has(e)&&(this.selectedNodes.add(e),e.selected=!0,this.lastSelectedNode=e,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!0),this.dispatchChanged()))}deselectNode(e){this.selectedNodes.has(e)&&(this.selectedNodes.delete(e),e.selected=!1,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!1),this.dispatchChanged())}selectChildrenRecursively(e,t){if(e.children)for(const n of e.children)n.footer||n.detailNode||(t?this.isNodeSelectable(n)&&(this.selectedNodes.add(n),n.selected=!0):(this.selectedNodes.delete(n),n.selected=!1),this.selectChildrenRecursively(n,t))}selectAll(){!this.isEnabled()||this.getOptions().rowSelection!=="multiple"||this.selectAllFiltered()}selectAllFiltered(){if(!this.isEnabled())return;const e=this.getOptions().__rowModel;e!=null&&e.forEachNode&&e.forEachNode(t=>{this.isNodeSelectable(t)&&!t.footer&&(this.selectedNodes.add(t),t.selected=!0)}),this.dispatchChanged()}deselectAll(){for(const e of this.selectedNodes)e.selected=!1;this.selectedNodes.clear(),this.lastSelectedNode=null,this.dispatchChanged()}toggleNode(e){this.selectedNodes.has(e)?this.deselectNode(e):this.selectNode(e,!1)}handleRowClick(e,t){if(!this.isEnabled()||this.getOptions().suppressRowClickSelection)return!1;const n=this.getOptions().rowSelection==="multiple",i=t.ctrlKey||t.metaKey,o=t.shiftKey;return n?o&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):i?(this.toggleNode(e),!0):(this.getOptions().rowMultiSelectWithClick?this.selectNode(e,!1):this.selectNode(e,!0),!0):(this.selectNode(e,!0),!0)}selectRange(e,t){const n=this.getOptions().__rowModel;if(!(n!=null&&n.forEachNode))return;let i=-1,o=-1,a=0;if(n.forEachNode(d=>{d===e&&(i=a),d===t&&(o=a),a++}),i<0||o<0)return;const l=Math.min(i,o),r=Math.max(i,o);a=0,n.forEachNode(d=>{a>=l&&a<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(i=>t.add(i));let n=!1;for(const i of this.selectedNodes)t.has(i)?i.selected=!0:n=!0;if(n){for(const i of[...this.selectedNodes])t.has(i)||this.selectedNodes.delete(i);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let t=0,n=0;return e!=null&&e.forEachNode&&e.forEachNode(i=>{i.footer||!this.isNodeSelectable(i)||(t++,i.selected&&n++)}),{checked:t>0&&n===t,indeterminate:n>0&&n<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class _o{constructor(e){y(this,"eBar");y(this,"eButtons");y(this,"ePanel");y(this,"panels",[]);y(this,"activePanelId",null);y(this,"visible",!1);y(this,"position");var n,i;this.grid=e;const t=e.getOptions();if(this.position=typeof t.sideBar=="object"&&((n=t.sideBar)!=null&&n.position)?t.sideBar.position:"right",this.eBar=document.createElement("div"),this.eBar.className=`ag-side-bar ag-side-bar-${this.position}`,this.eButtons=document.createElement("div"),this.eButtons.className="ag-side-buttons",this.ePanel=document.createElement("div"),this.ePanel.className="ag-side-bar-panel",this.eBar.appendChild(this.eButtons),this.eBar.appendChild(this.ePanel),t.sideBar){const o=typeof t.sideBar=="object"?t.sideBar:null;o!=null&&o.toolPanels?this.panels=o.toolPanels.map(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const l=(o==null?void 0:o.defaultToolPanel)||((i=this.panels[0])==null?void 0:i.id)||"columns";this.buildButtons(),this.openPanel(l)}else this.eBar.style.display="none"}defaultLabel(e){switch(e){case"columns":return this.grid.t("columns");case"filters":return this.grid.t("filters");case"charts":return this.grid.t("charts");default:return e}}buildButtons(){this.eButtons.innerHTML="";for(const e of this.panels){const t=document.createElement("button");t.className="ag-side-button",t.textContent=e.label,t.title=e.label,t.dataset.panelId=e.id,e.id===this.activePanelId&&t.classList.add("ag-selected"),t.addEventListener("click",()=>{this.activePanelId===e.id&&this.visible?this.setVisible(!1):(this.visible=!0,this.eBar.style.display="",this.openPanel(e.id)),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"sideBarButtonClicked",api:this.grid.getApi()})}),this.eButtons.appendChild(t)}}getElement(){return this.eBar}setPosition(e){this.position=e,this.eBar.classList.remove("ag-side-bar-left","ag-side-bar-right"),this.eBar.classList.add(`ag-side-bar-${e}`)}setVisible(e){this.visible=e,this.eBar.style.display=e?"":"none",this.grid.onGridSizeChanged(),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"api",api:this.grid.getApi()})}isVisible(){return this.visible}openPanel(e){this.activePanelId=e;for(const t of this.eButtons.querySelectorAll(".ag-side-button"))t.classList.toggle("ag-selected",t.dataset.panelId===e);switch(this.ePanel.innerHTML="",e){case"columns":this.ePanel.appendChild(this.buildColumnsPanel());break;case"filters":this.ePanel.appendChild(this.buildFiltersPanel());break;case"charts":this.ePanel.appendChild(this.grid.getChartService().buildChartPanel());break;default:{const t=document.createElement("div");t.className="ag-side-bar-empty",t.textContent=e,this.ePanel.appendChild(t)}}}getActivePanel(){return this.activePanelId}refresh(){this.activePanelId&&this.openPanel(this.activePanelId)}buildColumnsPanel(){const e=document.createElement("div");e.className="ag-column-panel";const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const n=document.createElement("div");n.className="ag-column-panel-columns",e.appendChild(n);const i=()=>{const d=t.value.toLowerCase();n.innerHTML="";const c=this.grid.getColumnModel().getColumns(),p=c.filter(h=>h.pinned!=="left"&&h.pinned!=="right").concat(c.filter(h=>h.pinned==="left"||h.pinned==="right"));for(const h of p)d&&!h.headerName.toLowerCase().includes(d)&&!h.colId.toLowerCase().includes(d)||n.appendChild(this.buildColumnItem(h));if(!n.children.length){const h=document.createElement("div");h.className="ag-side-bar-empty",h.textContent=this.grid.t("noMatchingColumns"),n.appendChild(h)}};t.addEventListener("input",i),i();const o=document.createElement("div");o.className="ag-column-panel-groups";const a=document.createElement("div");a.className="ag-column-panel-section-title",a.textContent=this.grid.t("rowGroups"),o.appendChild(a);const l=document.createElement("div");l.className="ag-column-group-list",o.appendChild(l);const r=()=>{l.innerHTML="";const d=this.grid.getColumnModel().getRowGroupColumns();if(d.length===0){const c=document.createElement("div");c.className="ag-column-group-hint",c.textContent=this.grid.t("dragColumnsHere"),l.appendChild(c)}for(const c of d){const p=document.createElement("div");p.className="ag-column-group-item",p.draggable=!0,p.addEventListener("dragstart",f=>{var g;(g=f.dataTransfer)==null||g.setData("text/plain",c.colId)}),p.addEventListener("dragover",f=>f.preventDefault()),p.addEventListener("drop",f=>{var v;f.preventDefault();const g=(v=f.dataTransfer)==null?void 0:v.getData("text/plain");g&&this.grid.getColumnModel().setRowGroupColumns([...d.map(m=>m.colId),g])});const h=document.createElement("span");h.textContent=c.headerName,p.appendChild(h);const u=document.createElement("button");u.className="ag-column-group-remove",u.textContent="×",u.title=this.grid.t("remove"),u.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(c)),p.appendChild(u),l.appendChild(p)}};return r(),l.addEventListener("dragover",d=>d.preventDefault()),l.addEventListener("drop",d=>{var p;d.preventDefault();const c=(p=d.dataTransfer)==null?void 0:p.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&i()}),e}buildColumnItem(e){const t=document.createElement("div");t.className="ag-column-select-column",t.draggable=!0,t.dataset.colid=e.colId;const n=document.createElement("input");n.type="checkbox",n.className="ag-column-select-checkbox",n.checked=e.visible,n.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,n.checked)}),t.appendChild(n);const i=document.createElement("span");i.className="ag-column-select-label",i.textContent=e.headerName||e.colId,t.appendChild(i);const o=document.createElement("span");if(o.className="ag-column-select-actions",e.enableRowGroup&&e.field){const l=document.createElement("button");l.className="ag-column-select-action",l.title=this.grid.t("groupByThisColumn"),l.textContent="≡",l.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(l)}const a=document.createElement("button");return a.className="ag-column-select-action",a.title=this.grid.t("pinColumnTitle"),a.textContent="📌",a.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),o.appendChild(a),t.appendChild(o),t}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent=`${this.grid.t("advancedFilter")}…`,o.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(o)),e.appendChild(o);const a=this.grid.getFilterService().getAdvancedFilterModel();if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(l)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const n=document.createElement("div");n.className="ag-filters-panel-list",e.appendChild(n);const i=()=>{const o=t.value.toLowerCase();n.innerHTML="";const a=this.grid.getColumns().center.filter(l=>l.filter);for(const l of a)o&&!l.headerName.toLowerCase().includes(o)||n.appendChild(this.buildFilterItem(l));if(!n.children.length){const l=document.createElement("div");l.className="ag-side-bar-empty",l.textContent=this.grid.t("noMatchingColumns"),n.appendChild(l)}};return t.addEventListener("input",i),i(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&i()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),n=document.createElement("div");n.className="ag-filters-tool-panel-item";const i=document.createElement("div");i.className="ag-filters-tool-panel-item-header";const o=document.createElement("span");o.className="ag-filters-tool-panel-item-label",o.textContent=e.headerName||e.colId,i.appendChild(o);const a=t.isFilterActive(e);if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.innerHTML=Yn,i.appendChild(l)}if(n.appendChild(i),e.filter==="set"){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=a?"Edit filter":"Add filter",l.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,l)),n.appendChild(l)}else if(e.filter==="date"){const l=document.createElement("input");l.type="date",l.className="ag-filter-input";const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.dateFrom)??"",l.addEventListener("change",()=>{t.setColumnFilterModel(e,l.value?{filterType:"date",dateFrom:l.value,dateTo:l.value}:null)}),n.appendChild(l)}else{const l=document.createElement("input");l.type=e.filter==="number"?"number":"text",l.className="ag-filter-input",l.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.filter)??"",l.addEventListener("input",()=>{t.handleFloatingFilterChange(e,l.value)}),n.appendChild(l)}if(a){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=this.grid.t("clear"),l.addEventListener("click",()=>t.setColumnFilterModel(e,null)),n.appendChild(l)}return n}}class Wo{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,n){const i=this.grid.getOptions().suppressMultiSort,o=n&&!i&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,a=this.getSortingOrder(),l=e.sort;let r=a.indexOf(l)+1;r>=a.length&&(r=0);const d=a[r];if(!o)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,n)=>(t.sortIndex??99)-(n.sortIndex??99)).forEach((t,n)=>t.sortIndex=n)}getSortModel(){return this.grid.getAllColumns().filter(e=>e.sort).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).map(e=>({colId:e.colId,sort:e.sort}))}setSortModel(e){for(const t of this.grid.getAllColumns())t.sort=null,t.sortIndex=null;e.forEach((t,n)=>{const i=this.grid.getColumn(t.colId);i&&(i.sort=t.sort,i.sortIndex=n)}),this.onSortChanged("api")}onSortChanged(e){var n,i;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(i=(n=this.grid.getOptions()).onSortChanged)==null||i.call(n,{api:t,source:e})}}class Uo{constructor(e,t){y(this,"eBar");y(this,"panels",[]);this.grid=e,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const i=e.getOptions().statusBar;(!i||!i.statusPanels||i.statusPanels.length===0)&&(this.eBar.style.display="none");const o=((i==null?void 0:i.statusPanels)||[]).map(a=>typeof a=="string"?{key:a,label:a}:{key:a.key||a.statusPanel,label:a.key||a.statusPanel,align:a.align});for(const a of o){const l=document.createElement("div");l.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(l);const r={def:a,ePanel:l,render:()=>this.renderPanel(a.key,l)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const n=this.grid.getApi(),i=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,l=n.getSelectedNodes().length,r=[],d=this.grid.getColumnModel().getValueColumns().filter(c=>c.aggFunc);switch(this.grid.getRowModel().forEachNode(c=>{!c.footer&&c.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${Ue(a)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${Ue(i)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${Ue(i)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${Ue(l)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=n.getSelectedNodes().filter(h=>!h.group&&!h.footer),p=[];for(const h of d){const f=c.map(w=>Ce(h,w,n)).filter(w=>typeof w=="number"&&!isNaN(w)),g=f.reduce((w,k)=>w+k,0),v=w=>w===null?"":Ue(w,h.decimals),m=[[this.grid.translate("average","Average"),f.length?g/f.length:null],[this.grid.translate("count","Count"),f.length],[this.grid.translate("min","Min"),f.length?Math.min(...f):null],[this.grid.translate("max","Max"),f.length?Math.max(...f):null],[this.grid.translate("sum","Sum"),f.length?g:null]];for(const[w,k]of m)p.push(`${w}${h.headerName?` (${h.headerName})`:""} : ${v(k)}`)}p.length&&r.push(p.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class jo{constructor(e,t){y(this,"undoStack",[]);y(this,"redoStack",[]);y(this,"limit",50);y(this,"batchDepth",0);y(this,"batchBuffer",[]);y(this,"batchCounter",0);y(this,"currentBatchId",0);this.grid=e,this.eventService=t;const n=e.getOptions();n.undoRedoCellEditing&&(this.limit=typeof n.undoRedoCellEditing=="number"?n.undoRedoCellEditing:50)}isEnabled(){return!!this.grid.getOptions().undoRedoCellEditing}pushAction(e){if(this.isEnabled()){if(this.batchDepth>0){this.batchBuffer.push(e);return}this.undoStack.push({...e,batchId:this.currentBatchId}),this.undoStack.length>this.limit&&this.undoStack.shift(),this.redoStack=[]}}canUndo(){return this.isEnabled()&&this.undoStack.length>0}canRedo(){return this.isEnabled()&&this.redoStack.length>0}getUndoStackSize(){return this.undoStack.length}getRedoStackSize(){return this.redoStack.length}undo(){if(!this.canUndo())return 0;const e=[this.undoStack.pop()];for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].rowNodeId===e[0].rowNodeId&&this.undoStack[this.undoStack.length-1].colId===e[0].colId;)e.push(this.undoStack.pop());if(e[0].batchId!==0)for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].batchId===e[0].batchId;)e.push(this.undoStack.pop());let t=0;for(const n of e)this.applyValue(n,n.oldValue),this.redoStack.push(n),t++;return this.eventService.dispatchEvent("undoEnded",{api:this.grid.getApi(),numberOfActions:t}),t}redo(){if(!this.canRedo())return 0;let e=0;for(;this.redoStack.length>0;){const t=this.redoStack.pop();if(this.applyValue(t,t.newValue),this.undoStack.push(t),e++,this.redoStack.length===0||this.redoStack[this.redoStack.length-1].colId!==t.colId)break}return this.eventService.dispatchEvent("redoEnded",{api:this.grid.getApi(),numberOfActions:e}),e}applyValue(e,t){const n=this.grid.getRowNode(e.rowNodeId);if(!n)return;const i=this.grid.getColumn(e.colId);i&&(this.grid.setCellValue(i,n,t,"undoRedo"),this.grid.refreshCells({rowNodes:[n],columns:[i],flash:!0}))}startBatchEdit(){this.batchDepth++,this.batchDepth===1&&(this.currentBatchId=++this.batchCounter)}endBatchEdit(e=!1){if(this.batchDepth=Math.max(0,this.batchDepth-1),this.batchDepth>0)return;if(e){this.batchBuffer=[];return}const t=this.currentBatchId;for(const n of this.batchBuffer)this.undoStack.push({...n,batchId:t}),this.undoStack.length>this.limit&&this.undoStack.shift();this.redoStack=[],this.batchBuffer=[],this.eventService.dispatchEvent("batchEditEnded",{api:this.grid.getApi()})}isBatchEditing(){return this.batchDepth>0}clear(){this.undoStack=[],this.redoStack=[],this.batchBuffer=[]}}class Ko{constructor(e,t){y(this,"ctx");y(this,"eHeader");y(this,"ePinnedLeftHeader");y(this,"ePinnedRightHeader");y(this,"eHeaderViewport");y(this,"eHeaderContainer");y(this,"eHeaderRow");y(this,"eFloatingFiltersRow",null);y(this,"eGroupRows");y(this,"headerCells",new Map);y(this,"customHeaderComponents",new Map);y(this,"resizeState",null);y(this,"dragState",null);y(this,"lastWidths",new Map);this.ctx=t,this.eHeader=e,e.classList.add("ag-header"),e.style.height=`${t.headerHeight}px`,this.ePinnedLeftHeader=document.createElement("div"),this.ePinnedLeftHeader.className="ag-pinned-left-header",e.appendChild(this.ePinnedLeftHeader),this.eHeaderViewport=document.createElement("div"),this.eHeaderViewport.className="ag-header-viewport",e.appendChild(this.eHeaderViewport),this.eHeaderContainer=document.createElement("div"),this.eHeaderContainer.className="ag-header-container",this.eHeaderViewport.appendChild(this.eHeaderContainer),this.eGroupRows=document.createElement("div"),this.eGroupRows.className="ag-group-header-rows",this.eHeaderContainer.appendChild(this.eGroupRows),this.eHeaderRow=document.createElement("div"),this.eHeaderRow.className="ag-header-row",this.eHeaderContainer.appendChild(this.eHeaderRow),this.ePinnedRightHeader=document.createElement("div"),this.ePinnedRightHeader.className="ag-pinned-right-header",e.appendChild(this.ePinnedRightHeader),this.refresh()}refresh(){this.headerCells.clear(),this.renderGroupRows();const{left:e,center:t,right:n}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,t,"center"),this.renderSection(this.ePinnedRightHeader,n,"right");const i=[...e,...t,...n].some(o=>o.floatingFilter);i&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!i&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var l;const e=this.ctx.getColumnModel(),t=((l=e==null?void 0:e.getColumnGroups)==null?void 0:l.call(e))||[];this.eGroupRows.innerHTML="";const n=t.reduce((r,d)=>Math.max(r,d.depth),0),i=this.ctx.options.groupHeaderHeight??30;let o=0;for(let r=1;r<=n;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${i}px`;const c=this.ctx.getColumns().center;let p=0,h,u=0,f=0;const g=(m,w)=>{let k=m.groupId;for(;k;){const C=t.find(b=>b.id===k);if(!C)return null;if(C.depth===w)return C.id;k=C.parentId}return null},v=()=>{if(h==null)return;const m=t.find(b=>b.id===h);if(!m)return;const w=document.createElement("div");w.className="ag-header-group-cell",w.style.left=`${u}px`,w.style.width=`${f}px`,w.style.height=`${i}px`;const k=e.isGroupOpen(m.id),C=document.createElement("div");if(C.className="ag-header-group-cell-label",C.textContent=m.headerName,w.appendChild(C),!k){const b=document.createElement("span");b.className="ag-header-group-expand",b.textContent="▸",b.title=this.ctx.t("expandGroup"),w.appendChild(b)}w.addEventListener("click",()=>{e.setGroupOpen(m.id,!k)}),d.appendChild(w)};c.forEach(m=>{const w=g(m,r);w!==h&&(v(),h=w,u=p,f=0),f+=m.width,p+=m.width}),v(),d.style.width=`${p}px`,this.eGroupRows.appendChild(d),o+=i}this.eGroupRows.style.display=n>0?"":"none";const a=this.ctx.headerHeight;this.eHeader.style.height=`${o+a}px`}renderSection(e,t,n){e.innerHTML="";let i=0;for(const o of t){const a=this.createHeaderCell(o);if(a.style.left=`${i}px`,a.style.width=`${o.width}px`,a.style.height=`${this.ctx.headerHeight}px`,i+=o.width,e.appendChild(a),this.headerCells.set(o.colId,a),o.eHeaderCell=a,this.eFloatingFiltersRow&&e===this.eHeaderRow&&o.floatingFilter){const l=this.createFloatingFilter(o);l.style.left=`${i-o.width}px`,l.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(l)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${i}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${i}px`)}createHeaderCell(e){var a,l;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const n=e.colDef.headerComponent;if(typeof n=="function"){const r=n({column:e,colDef:e.colDef,api:((l=(a=this.ctx).getApi)==null?void 0:l.call(a))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),t.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const i=document.createElement("div");if(i.className="ag-header-cell-label",e.headerTooltip&&(i.title=e.headerTooltip),e.headerCheckboxSelection){const r=document.createElement("input");r.type="checkbox",r.className="ag-native-checkbox ag-header-select-all",r.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,r.checked)),r.addEventListener("click",d=>d.stopPropagation()),i.appendChild(r)}const o=document.createElement("span");if(o.className="ag-header-cell-text",o.textContent=e.headerName,i.appendChild(o),t.appendChild(i),e.sortable){const r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=uo,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=co,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const d=t.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=h=>{if(!this.resizeState)return;const u=h.clientX-this.resizeState.startX;let f=this.resizeState.startWidth+u;f=Math.max(e.minWidth,Math.min(e.maxWidth,f)),this.ctx.onColumnResized(e,Math.round(f),!1)},p=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",p),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",p)}),t.appendChild(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=t.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),t}createFloatingFilter(e){const t=document.createElement("div");if(t.className="ag-header-cell ag-floating-filter-cell",t.dataset.colid=e.colId,t.style.position="absolute",t.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const i=document.createElement("select");return i.className="ag-floating-filter-input",i.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',i.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,i.value)),t.appendChild(i),e.floatingFilterComp=i,t}const n=document.createElement("input");return n.className="ag-floating-filter-input",n.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",n.placeholder=this.ctx.t("filterOoo"),n.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),n.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,n.value)),t.appendChild(n),e.floatingFilterComp=n,t}updateSortIndicator(e,t,n){if(e.innerHTML="",t==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=ho):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=po),t&&n!==null&&n>0){const i=document.createElement("span");i.className="ag-sort-order",i.textContent=String(n+1),e.appendChild(i)}}updateIndicators(){const{left:e,center:t,right:n}=this.ctx.getColumns();for(const i of[...e,...t,...n]){const o=this.headerCells.get(i.colId);if(!o)continue;const a=o.querySelector(".ag-sort-indicator");a&&this.updateSortIndicator(a,i.sort,i.sortIndex);const l=o.querySelector(".ag-filter-icon");l&&l.classList.toggle("ag-filter-active",this.ctx.isFilterActive(i)),o.style.width=`${i.width}px`,this.lastWidths.get(i.colId)!==i.width&&this.lastWidths.set(i.colId,i.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(n=>n.colId===e.colId)+1}layoutPositions(){const{left:e,center:t,right:n}=this.ctx.getColumns();let i=0;for(const o of e){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}this.ePinnedLeftHeader.style.width=`${i}px`,i=0;for(const o of t){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}this.eHeaderContainer.style.width=`${i}px`,i=0;for(const o of n){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}if(this.ePinnedRightHeader.style.width=`${i}px`,this.eFloatingFiltersRow){i=0;for(const o of t){const a=this.eFloatingFiltersRow.querySelector(`[data-colid="${o.colId}"]`);a&&(a.style.left=`${i}px`,a.style.width=`${o.width}px`),i+=o.width}}}setScrollLeft(e,t=0){this.eHeaderViewport.style.marginInlineEnd=`${t}px`,this.eHeaderViewport.scrollLeft=e}getHeaderCell(e){return this.headerCells.get(e.colId)}getHeaderRow(){return this.eHeaderRow}}class Gt{constructor(e,t,n,i,o,a,l){y(this,"eLeft",null);y(this,"eCenter",null);y(this,"eRight",null);y(this,"cellComps",[]);y(this,"pinned",!1);var r,d,c,p,h,u,f,g,v;if(this.ctx=e,this.node=t,this.rowHeight=a,t.masterNode){const m=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(m){const w=document.createElement("div");w.className="ag-row ag-row-detail-row",w.dataset.rowid=t.id,w.style.height=`${m.height}px`,w.style.width="100%",w.appendChild(m.eDetail),this.eCenter=w,this.eLeft=null,this.eRight=null}return}n.length&&(this.eLeft=this.createRowElement(t,n,"left"),this.eLeft.classList.add("ag-row-pinned")),(i.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,i,"center")),o.length&&(this.eRight=this.createRowElement(t,o,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),t.group&&((p=this.eCenter)==null||p.classList.add("ag-row-group"),(h=this.eLeft)==null||h.classList.add("ag-row-group"),(u=this.eRight)==null||u.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((f=this.eCenter)==null||f.classList.add("ag-row-selected"),(g=this.eLeft)==null||g.classList.add("ag-row-selected"),(v=this.eRight)==null||v.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,n,i;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(n=this.eCenter)==null||n.classList.toggle("ag-row-sticky-group",e),(i=this.eRight)==null||i.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,n,i;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(n=this.eCenter)==null||n.classList.toggle("ag-row-hover",e),(i=this.eRight)==null||i.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,n){var r;const i=document.createElement("div");i.className="ag-row",i.dataset.rowid=e.id,i.setAttribute("role","row"),i.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),i.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&i.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&i.classList.add("ag-row-even"),i.style.height=`${this.rowHeight}px`,i.style.position="absolute",i.style.top="0px";const o=this.ctx.getRowClass(e);o&&i.classList.add(...o.split(" ").filter(Boolean));const a=this.ctx.getRowStyle(e);a&&Object.assign(i.style,a),e.footer&&((r=e.groupData)!=null&&r.__grandTotal)&&(i.classList.add("ag-row-full-width"),i.style.width="100%",i.style.right="0",i.style.left="0");let l=0;for(let d=0;d<t.length;d++){const c=t[d],p=this.createCell(c,e);let h=1;typeof c.colDef.colSpan=="function"&&(h=Math.max(1,Math.round(c.colDef.colSpan({value:Ce(c,e,null),data:e.data,node:e,column:c,rowIndex:e.__displayIndex??0,api:null}))));let u=c.width;for(let f=1;f<h&&d+f<t.length;f++)u+=t[d+f].width;p.eCell.style.left=`${l}px`,p.eCell.style.width=`${u}px`,p.eCell.style.position="absolute",p.eCell.style.top="0",p.eCell.style.height=`${this.rowHeight}px`,h>1&&p.eCell.classList.add("ag-cell-col-span"),l+=u,d+=h-1,i.appendChild(p.eCell),this.cellComps.push(p)}return i.style.width=`${l}px`,i}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(n=>n.colId===e.colId)+1}createCell(e,t){var c,p;const n=document.createElement("div");n.className="ag-cell",n.dataset.colid=e.colId;const i=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");i&&n.classList.add(`ag-col-${i}`);const o={value:Ce(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const h=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof h=="string"?n.classList.add(...h.split(" ").filter(Boolean)):Array.isArray(h)&&n.classList.add(...h)}if(e.cellClassRules)for(const[h,u]of Object.entries(e.cellClassRules))u(o)&&n.classList.add(h);if(e.cellStyle){const h=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(n.style,h)}(e.type==="numberColumn"||e.cellDataType===!0)&&n.classList.add("ag-right-aligned-cell"),e.rowDrag&&n.classList.add("ag-cell-row-drag");const a=document.createElement("span");a.className="ag-cell-value",n.appendChild(a),this.ctx.options.enableCellTextSelection&&(n.style.userSelect="text",n.style.cursor="text"),n.setAttribute("role","gridcell"),n.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const l=(p=(c=this.ctx).getNote)==null?void 0:p.call(c,t.id,e.colId,e.colDef.note,{value:Ce(e,t,null),data:t.data,node:t,column:e,api:null});if(l){const h=document.createElement("span");h.className="ag-cell-note-marker",h.title=l,h.addEventListener("click",u=>{var f,g;u.stopPropagation(),(g=(f=this.ctx).onNoteClick)==null||g.call(f,t.id,e.colId,h)}),n.appendChild(h)}if(e.rowDrag){const h=document.createElement("span");h.className="ag-row-drag-handle",h.innerHTML=Kn,h.title=this.ctx.t("dragRow"),h.addEventListener("mousedown",u=>{var f,g;u.button===0&&(u.stopPropagation(),(g=(f=this.ctx).onRowDragStart)==null||g.call(f,t,h,u))}),n.appendChild(h)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?n.title=String(t.data[r]):e.tooltipValueGetter&&(n.title=String(e.tooltipValueGetter({value:Ce(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:n,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:t,node:n}={column:e.column,node:this.node},i=Ce(t,n,null),o=Ht(t,n,null);e.lastValue=i,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,l=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||l){e.custom=!0;const c=a||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const p={value:i,valueFormatted:o,data:n.data,node:n,column:t,rowIndex:n.__displayIndex??0,api:null,colDef:t.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...t.cellRendererParams||{}};let h=null;if(a&&Vt[a]){const u=Vt[a](p);u instanceof HTMLElement?h=u:(e.rendererInstance=u,h=u.getGui())}else if(l){const u=l(p);u instanceof HTMLElement?h=u:u&&typeof u.getGui=="function"?(e.rendererInstance=u,h=u.getGui()):typeof u=="string"&&(e.eValue.innerHTML=u)}h&&e.eValue.appendChild(h)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=o??"";if((n.group||n.footer)&&n.groupData){const c=n.groupData[t.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,n){var a,l,r,d;const i=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(i&&!i.has(c.column.colId))continue;const p=Ce(c.column,this.node,null),h=t||p!==c.lastValue;if(!h&&!n)continue;const u=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:p,valueFormatted:Ht(c.column,this.node,null),data:this.node.data,node:this.node,column:c.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:c.column.colDef,eGridCell:c.eCell,...c.column.cellRendererParams||{}})===!1&&this.updateCellContent(c),c.lastValue=p,n&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(h||n)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=p,n&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(n||h&&u!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"))}const o=this.ctx.isNodeSelected(this.node);(a=this.eCenter)==null||a.classList.toggle("ag-row-selected",o),(l=this.eLeft)==null||l.classList.toggle("ag-row-selected",o),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",o),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,n){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&n.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const i=this.ctx.renderDetailRow(this.node,this.eCenter);i&&t.appendChild(i.eDetail)}}setTop(e){const t=`${e}px`;this.eLeft&&this.eLeft.style.top!==t&&(this.eLeft.style.top=t),this.eCenter&&this.eCenter.style.top!==t&&(this.eCenter.style.top=t),this.eRight&&this.eRight.style.top!==t&&(this.eRight.style.top=t)}getCenterElement(){return this.eCenter}getCellElements(){return this.cellComps.map(e=>e.eCell)}destroy(){var e,t,n,i;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(t=this.eCenter)!=null&&t.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(n=this.eRight)!=null&&n.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const o of this.cellComps)(i=o.rendererInstance)!=null&&i.destroy&&o.rendererInstance.destroy();this.cellComps=[]}}function ti(s,e,t){const n=s.length;if(n===0||t<=0)return[];let i=0,o=n-1;for(;i<o;){const c=i+o>>1;s[c]>=t?o=c:i=c+1}const a=s[i]>=t?i:n-1,l=e[a];if(!l||l.level===0)return[];const r=[];let d=l.level;for(let c=a-1;c>=0;c--){const p=e[c];if(!(!p||p.level>=d)&&(d=p.level,p.group&&s[c]<t&&r.push(c),p.level===0))break}return r.reverse()}class Yo{constructor(e,t,n){y(this,"ctx");y(this,"eRoot");y(this,"eHeader");y(this,"eBody");y(this,"ePinnedLeft");y(this,"ePinnedRight");y(this,"ePinnedLeftInner");y(this,"ePinnedRightInner");y(this,"eViewport");y(this,"eContainer");y(this,"eFloatingTop");y(this,"eFloatingBottom");y(this,"eFloatingTopLeft");y(this,"eFloatingTopRight");y(this,"eFloatingBottomLeft");y(this,"eFloatingBottomRight");y(this,"eStickyTop");y(this,"eStickyLeft");y(this,"eStickyCenter");y(this,"eStickyRight");y(this,"rowComps",new Map);y(this,"stickyComps",new Map);y(this,"hoveredRowId",null);y(this,"rowOffsets",[]);y(this,"rowIndices",new Map);y(this,"rowInfos",[]);y(this,"totalHeight",0);y(this,"lastScrollTop",-1);y(this,"lastRange",[-1,-1]);y(this,"heightVersion",0);y(this,"scrollFrame",null);y(this,"onSectionWheel",e=>{if(e.ctrlKey||!e.cancelable)return;const t=e.target;if(t!=null&&t.closest('input, textarea, select, [contenteditable="true"]'))return;const n=this.eViewport;let i=e.deltaY,o=e.deltaX;e.deltaMode===1?(i*=33,o*=33):e.deltaMode===2&&(i*=n.clientHeight,o*=n.clientWidth),e.shiftKey&&!o&&(o=i,i=0),i&&(n.scrollTop+=i),o&&(n.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});y(this,"onBodyMouseOver",e=>{var o;const t=e.target,n=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,".ag-row"),i=(n==null?void 0:n.dataset.rowid)??null;if(i===this.hoveredRowId){i&&this.setRowHovered(i,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=i,i&&this.setRowHovered(i,!0)});y(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=n,this.eRoot=e,this.eHeader=t,this.eBody=document.createElement("div"),this.eBody.className="ag-body",this.eRoot.appendChild(this.eBody),this.ePinnedLeft=document.createElement("div"),this.ePinnedLeft.className="ag-pinned-left-cols-viewport",this.eBody.appendChild(this.ePinnedLeft),this.ePinnedLeftInner=document.createElement("div"),this.ePinnedLeftInner.className="ag-pinned-cols-inner",this.ePinnedLeft.appendChild(this.ePinnedLeftInner);const i=document.createElement("div");i.className="ag-body-viewport-wrapper",this.eBody.appendChild(i),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",i.appendChild(this.eFloatingTop),this.eViewport=document.createElement("div"),this.eViewport.className="ag-body-viewport",this.eViewport.tabIndex=0,this.eViewport.addEventListener("scroll",this.onScroll.bind(this)),this.eViewport.addEventListener("keydown",o=>this.ctx.onViewportKeyDown(o)),i.appendChild(this.eViewport),this.eContainer=document.createElement("div"),this.eContainer.className="ag-body-container",this.eViewport.appendChild(this.eContainer),this.eFloatingBottom=document.createElement("div"),this.eFloatingBottom.className="ag-floating-bottom",i.appendChild(this.eFloatingBottom),this.ePinnedRight=document.createElement("div"),this.ePinnedRight.className="ag-pinned-right-cols-viewport",this.eBody.appendChild(this.ePinnedRight),this.ePinnedRightInner=document.createElement("div"),this.ePinnedRightInner.className="ag-pinned-cols-inner",this.ePinnedRight.appendChild(this.ePinnedRightInner),this.eFloatingTopLeft=document.createElement("div"),this.eFloatingTopLeft.className="ag-floating-pinned-cols ag-floating-pinned-left",this.eBody.appendChild(this.eFloatingTopLeft),this.eFloatingTopRight=document.createElement("div"),this.eFloatingTopRight.className="ag-floating-pinned-cols ag-floating-pinned-right",this.eBody.appendChild(this.eFloatingTopRight),this.eFloatingBottomLeft=document.createElement("div"),this.eFloatingBottomLeft.className="ag-floating-pinned-cols ag-floating-pinned-bottom-left",this.eBody.appendChild(this.eFloatingBottomLeft),this.eFloatingBottomRight=document.createElement("div"),this.eFloatingBottomRight.className="ag-floating-pinned-cols ag-floating-pinned-bottom-right",this.eBody.appendChild(this.eFloatingBottomRight),this.eStickyTop=document.createElement("div"),this.eStickyTop.className="ag-sticky-group-rows",this.eBody.appendChild(this.eStickyTop),this.eStickyLeft=document.createElement("div"),this.eStickyLeft.className="ag-sticky-group-rows-left",this.eStickyTop.appendChild(this.eStickyLeft),this.eStickyCenter=document.createElement("div"),this.eStickyCenter.className="ag-sticky-group-rows-center",this.eStickyTop.appendChild(this.eStickyCenter),this.eStickyRight=document.createElement("div"),this.eStickyRight.className="ag-sticky-group-rows-right",this.eStickyTop.appendChild(this.eStickyRight);for(const o of[this.eFloatingTopLeft,this.eFloatingTopRight,this.eFloatingBottomLeft,this.eFloatingBottomRight,this.eStickyLeft,this.eStickyCenter,this.eStickyRight])o.addEventListener("click",this.onClick.bind(this)),o.addEventListener("dblclick",this.onDoubleClick.bind(this)),o.addEventListener("mousedown",this.onMouseDown.bind(this)),o.addEventListener("contextmenu",this.onContextMenu.bind(this)),o.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.ePinnedLeft.addEventListener("click",this.onClick.bind(this)),this.ePinnedLeft.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedLeft.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedLeft.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eContainer.addEventListener("click",this.onClick.bind(this)),this.eContainer.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eContainer.addEventListener("mousedown",this.onMouseDown.bind(this)),this.eContainer.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.ePinnedRight.addEventListener("click",this.onClick.bind(this)),this.ePinnedRight.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedRight.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedRight.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingTop.addEventListener("click",this.onClick.bind(this)),this.eFloatingTop.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingTop.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingBottom.addEventListener("click",this.onClick.bind(this)),this.eFloatingBottom.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingBottom.addEventListener("contextmenu",this.onContextMenu.bind(this));for(const o of[this.eViewport,this.ePinnedLeft,this.ePinnedRight,this.eFloatingTop,this.eFloatingBottom,this.eHeader])o.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.eBody.addEventListener("mouseover",this.onBodyMouseOver),this.eBody.addEventListener("mouseleave",this.onBodyMouseLeave)}setRowHovered(e,t){for(const n of this.rowComps.values())n.getNode().id===e&&n.setHovered(t);for(const n of this.stickyComps.values())n.getNode().id===e&&n.setHovered(t)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount();this.rowIndices.clear();const t=new Array(e),n=new Array(e);let i=0;if(this.hasVariableHeights()){for(let a=0;a<e;a++)t[a]=i,n[a]=this.rowInfoAt(a),i+=this.getRowHeightForIndex(a);this.totalHeight=i}else{const a=this.getFixedRowHeight();for(let l=0;l<e;l++)t[l]=l*a,n[l]=this.rowInfoAt(l);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=n}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?(this.rowIndices.set(t.id,e),{level:t.uiLevel??t.level??0,group:!!t.group}):{level:0,group:!1}}hasVariableHeights(){return!!(this.ctx.options.detailRowAutoHeight||this.ctx.options.getRowHeight)}getFixedRowHeight(){return this.ctx.options.rowHeight??42}getRowHeightForIndex(e){const t=this.ctx.rowModel.getRow(e);return t?this.ctx.getRowHeight(t):this.getFixedRowHeight()}refreshRows(){this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`;const e=this.ctx.getColumns().center.reduce((i,o)=>i+o.width,0),t=this.ctx.getColumns().left.reduce((i,o)=>i+o.width,0),n=this.ctx.getColumns().right.reduce((i,o)=>i+o.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${t}px`,this.ePinnedRight.style.width=`${n}px`,this.ePinnedLeft.style.height=`${this.totalHeight}px`,this.ePinnedRight.style.height=`${this.totalHeight}px`,this.eFloatingTopLeft.style.width=`${t}px`,this.eFloatingTopRight.style.width=`${n}px`,this.eFloatingBottomLeft.style.width=`${t}px`,this.eFloatingBottomRight.style.width=`${n}px`,this.eStickyLeft.style.width=`${t}px`,this.eStickyRight.style.width=`${n}px`,this.eStickyCenter.style.left=`${t}px`,this.eStickyCenter.style.right=`${n}px`,this.redrawAllRows()}invalidateRowHeights(){this.heightVersion++,this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`,this.redrawAllRows()}redrawAllRows(){for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear(),this.lastRange=[-1,-1],this.renderPinnedRows(),this.renderVisibleRows(!0)}renderPinnedRows(){var n,i;const e=(o,a,l,r,d)=>{o.innerHTML="",a.innerHTML="",l.innerHTML="";const{left:c,center:p,right:h}=this.ctx.getColumns();let u=0;for(let f=0;f<r;f++){const g=d(f);if(!g)continue;const v=this.ctx.getRowHeight(g),m=new Gt(this.ctx,g,c,p,h,v,this.heightVersion);m.appendTo(a,o,l),m.setTop(u),u+=v,this.rowComps.set(`${g.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${u}px`,o.style.display=r>0?"":"none",a.style.height=`${u}px`,l.style.height=`${u}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((n=t.getPinnedTopRowCount)==null?void 0:n.call(t))??0,o=>{var a;return(a=t.getPinnedTopRow)==null?void 0:a.call(t,o)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((i=t.getPinnedBottomRowCount)==null?void 0:i.call(t))??0,o=>{var a;return(a=t.getPinnedBottomRow)==null?void 0:a.call(t,o)})}refreshCells(e){const t=e==null?void 0:e.rowNodes;let n;e!=null&&e.columns&&(n=e.columns.map(i=>typeof i=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(o=>o.colId===i):i).filter(Boolean));for(const[i,o]of this.rowComps)t&&!t.includes(o.getNode())||o.refreshCells(n,e==null?void 0:e.force,e==null?void 0:e.flash);for(const i of this.stickyComps.values())t&&!t.includes(i.getNode())||i.refreshCells(n,e==null?void 0:e.force,e==null?void 0:e.flash)}flashCells(e){this.refreshCells({...e,force:!0,flash:!0})}redrawRows(e){if(!(e!=null&&e.rowNodes)){this.redrawAllRows();return}for(const t of this.rowComps.values())if(e.rowNodes.includes(t.getNode())){const n=t.getNode(),i=this.findRowIndex(n);if(t.destroy(),this.rowComps.delete(this.rowCompKey(n)),i>=0){const{left:o,center:a,right:l}=this.ctx.getColumns(),r=new Gt(this.ctx,n,o,a,l,this.getRowHeightForIndex(i),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[i]??0),this.rowComps.set(this.rowCompKey(n),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){return this.rowIndices.get(e.id)??-1}scheduleScrollRender(){this.scrollFrame===null&&(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=null,this.renderVisibleRows()}))}onScroll(){this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),this.ctx.eventService.dispatchEvent("bodyScroll",{direction:"vertical",top:this.eViewport.scrollTop,left:this.eViewport.scrollLeft})}syncPinnedScroll(){const e=`translateY(${-this.eViewport.scrollTop}px)`;this.ePinnedLeftInner.style.transform=e,this.ePinnedRightInner.style.transform=e,this.ePinnedLeft.scrollTop=this.eViewport.scrollTop,this.ePinnedRight.scrollTop=this.eViewport.scrollTop,this.syncStickyHorizontal()}syncStickyHorizontal(){const n=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const i of this.stickyComps.values()){const o=i.getCenterElement();o&&(o.style.transform=n)}}getVerticalScrollTop(){return this.eViewport.scrollTop}setVerticalScrollTop(e){this.eViewport.scrollTop=e,this.syncPinnedScroll(),this.renderVisibleRows()}getHorizontalScrollLeft(){return this.eViewport.scrollLeft}getVerticalScrollbarWidth(){return Math.max(0,this.eViewport.offsetWidth-this.eViewport.clientWidth)}setHorizontalScrollLeft(e){var t,n;this.eViewport.scrollLeft=e,this.syncPinnedScroll(),(n=(t=this.ctx).onViewportScroll)==null||n.call(t)}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:ti(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:n,right:i}=this.ctx.getColumns(),o=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${o}px`;const a=new Set;let l=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;a.add(c.id);let p=this.stickyComps.get(c.id);if(!p){const h=this.rowComps.get(c.id);h&&(h.destroy(),this.rowComps.delete(c.id)),p=new Gt(this.ctx,c,t,n,i,this.getRowHeightForIndex(d),this.heightVersion),p.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),p.setSticky(!0),this.stickyComps.set(c.id,p)}p.setTop(l),l+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)a.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${l}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),n=this.eViewport.scrollTop,i=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a,l;if(this.hasVariableHeights())a=this.findIndexAtPixel(n)-o,l=this.findIndexAtPixel(n+i)+o;else{const v=this.getFixedRowHeight();a=Math.floor(n/v)-o,l=Math.ceil((n+i)/v)+o}if(a=Math.max(0,a),l=Math.min(t-1,l),!e&&this.lastRange[0]===a&&this.lastRange[1]===l&&this.lastScrollTop===n)return;const r=this.lastRange[0]!==a||this.lastRange[1]!==l;this.lastRange=[a,l],this.lastScrollTop=n;const d=new Set(this.stickyComps.keys()),c=this.syncStickyGroupRows(),p=d.size!==c.size||[...d].some(v=>!c.has(v));if(!e&&!r&&!p)return;const h=new Set(c),{left:u,center:f,right:g}=this.ctx.getColumns();for(let v=a;v<=l;v++){const m=this.ctx.rowModel.getRow(v);if(!m||(h.add(m.id),c.has(m.id)))continue;let w=this.rowComps.get(m.id);w||(w=new Gt(this.ctx,m,u,f,g,this.getRowHeightForIndex(v),this.heightVersion),w.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,w)),w.setTop(this.rowOffsets[v]??v*this.getFixedRowHeight())}for(const[v,m]of this.rowComps)!h.has(v)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(v))}findIndexAtPixel(e){const t=this.rowOffsets;let n=0,i=t.length-1;for(;n<i;){const o=n+i+1>>1;t[o]<=e?n=o:i=o-1}return n}ensureIndexVisible(e,t="top"){const n=this.rowOffsets[e]??e*this.getFixedRowHeight(),i=this.getRowHeightForIndex(e),o=this.eViewport.clientHeight;let a;t==="top"?a=n:t==="bottom"?a=n+i-o:a=n-(o-i)/2,this.eViewport.scrollTop=Math.max(0,a),this.renderVisibleRows()}getFirstVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop))}getLastVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop+this.eViewport.clientHeight))}ensureColumnVisible(e,t="end"){const n=this.eViewport.clientWidth,i=this.eViewport.scrollLeft,o=e.left-this.ctx.getColumns().left.reduce((a,l)=>a+l.width,0);o<i?this.eViewport.scrollLeft=Math.max(0,t==="middle"?o-(n-e.width)/2:o):o+e.width>i+n&&(this.eViewport.scrollLeft=o+e.width-n),this.renderVisibleRows()}getCellPosition(e,t){return{top:this.rowOffsets[e]??e*this.getFixedRowHeight(),left:t.left,height:this.getRowHeightForIndex(e),width:t.width}}getRowOffsets(){return this.rowOffsets}getTotalHeight(){return this.totalHeight}findCellFromEvent(e){const n=e.target.closest(".ag-cell");if(!n)return null;const i=n.dataset.colid;if(!i)return null;const o=n.closest(".ag-row"),a=o==null?void 0:o.dataset.rowid;if(!a)return null;const l=this.ctx.rowModel.getRowNode(a);if(!l)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===i);return d?{node:l,column:d,eCell:n,rowIndex:this.findRowIndex(l)}:null}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:Ce(t.column,t.node,null),rowIndex:this.findRowIndex(t.node),colDef:t.column.colDef});return}const n=e.target.closest(".ag-row");if(n!=null&&n.dataset.rowid){const i=this.ctx.rowModel.getRowNode(n.dataset.rowid);i&&this.ctx.onRowClicked({event:e,node:i,data:i.data,rowIndex:this.findRowIndex(i)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:Ce(t.column,t.node,null),rowIndex:this.findRowIndex(t.node),colDef:t.column.colDef});return}const n=e.target.closest(".ag-row");if(n!=null&&n.dataset.rowid){const i=this.ctx.rowModel.getRowNode(n.dataset.rowid);i&&this.ctx.onRowDoubleClicked({event:e,node:i,data:i.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:Ce(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:Ce(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}destroy(){this.scrollFrame!==null&&cancelAnimationFrame(this.scrollFrame),this.scrollFrame=null;for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear()}}class Ke{constructor(){y(this,"cleanups",new Set);y(this,"stopped",!1)}get destroyed(){return this.stopped}add(e){return this.stopped?e():this.cleanups.add(e),()=>{this.cleanups.delete(e)&&e()}}listen(e,t,n,i){return e.addEventListener(t,n,i),this.add(()=>e.removeEventListener(t,n,i))}timeout(e,t){if(this.stopped)return 0;const n=window.setTimeout(()=>{i(),this.stopped||e()},t),i=this.add(()=>window.clearTimeout(n));return n}interval(e,t){if(this.stopped)return 0;const n=window.setInterval(()=>{this.stopped||e()},t);return this.add(()=>window.clearInterval(n)),n}destroy(){if(this.stopped)return;this.stopped=!0;const e=[...this.cleanups].reverse();this.cleanups.clear();let t;for(const n of e)try{n()}catch(i){t??(t=i)}if(t!==void 0)throw t}}function De(s,e,t={},n=[]){const i=new Ke,o=new Set,a=h=>[...o].some(u=>u.contains(h)),l=new Set,r=new WeakMap,d=h=>{const u=h.target;if(!(u!=null&&u.closest))return;const f=u.closest('button,input,select,textarea,a,[data-action],[contenteditable],[role="button"],[role="tab"],[data-node-id],[data-rowid],[data-viewport],canvas');if(!f||!a(f))return;const g={};for(let m=f;m&&a(m);m=m.parentElement)for(const[w,k]of Object.entries(m.dataset))k!==void 0&&!(w in g)&&(g[w]=k);const v=f;r.has(h)||(r.set(h,{component:e,type:h.type,action:g.action??g.control,value:"value"in f?v.value:void 0,checked:v.type==="checkbox"||v.type==="radio"?v.checked:void 0,data:g,originalEvent:h}),queueMicrotask(()=>c(h)))},c=h=>{var g;const u=r.get(h);if(!u||i.destroyed)return;r.delete(h),(g=t.onInteraction)==null||g.call(t,u);for(const v of[...l])v(u);const f=s.ownerDocument.defaultView.CustomEvent;s.dispatchEvent(new f("rowvia:interaction",{detail:u,bubbles:!0}))},p=h=>{if(i.destroyed||o.has(h))return()=>{};o.add(h);const u=[];for(const f of["click","dblclick","contextmenu","input","change","submit","keydown","pointerdown","pointerup","wheel"])u.push(i.listen(h,f,d,{capture:!0,passive:!0}));return()=>{o.delete(h),u.forEach(f=>f())}};for(const h of[s,...n])p(h);return{addRoot:p,onInteraction(h){return i.destroyed?()=>{}:(l.add(h),()=>{l.delete(h)})},destroy(){i.destroy(),l.clear(),o.clear()}}}const Xo={rowHeight:42,headerHeight:48,floatingFiltersHeight:24,groupHeaderHeight:48,pivotHeaderHeight:48,rowBuffer:10,detailRowHeight:200,animateRows:!0,enableCellChangeFlash:!0,rowSelection:void 0,sortingOrder:["asc","desc",null],enterNavigatesVerticallyAfterEdit:!0,treeDataChildrenField:"children",suppressClickEdit:!1};class ht{constructor(e,t){y(this,"interactions");y(this,"onInteraction");y(this,"options");y(this,"eventService",new Ds);y(this,"columnModel");y(this,"rowModel");y(this,"clientSideRowModel",null);y(this,"serverSideRowModel",null);y(this,"infiniteRowModel",null);y(this,"viewportRowModel",null);y(this,"rowRenderer");y(this,"headerView");y(this,"selectionService");y(this,"editService");y(this,"filterService");y(this,"sortService");y(this,"paginationService",null);y(this,"popupService");y(this,"filterGui");y(this,"contextMenuService");y(this,"columnMenuService");y(this,"statusBarService");y(this,"sideBarService");y(this,"findService");y(this,"rangeSelectionService");y(this,"chartService");y(this,"overlayService");y(this,"exportService");y(this,"rowGroupPanel",null);y(this,"undoRedoService");y(this,"formulaEditorService");y(this,"notesService");y(this,"rowDragService");y(this,"api");y(this,"columnApi");y(this,"localeText");y(this,"rowNodeServices");y(this,"eGridDiv");y(this,"eRoot");y(this,"eMain");y(this,"eHeader");y(this,"quickFilter","");y(this,"resizeObserver",null);y(this,"destroyed",!1);y(this,"gridReadyDispatched",!1);y(this,"context");y(this,"onWindowResize",()=>{this.onGridSizeChanged()});y(this,"onDocumentMouseDown",e=>{var n;const t=e.target;if(t&&this.eRoot.contains(t)){const i=(n=t.closest)==null?void 0:n.call(t,".ag-cell");if(!i){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!i.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var d,c,p,h;this.eGridDiv=e,this.options={...Xo,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Os(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const n=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(n),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),this.interactions=De(this.eRoot,"grid",this.options),this.onInteraction=this.interactions.onInteraction,this.eMain=document.createElement("div"),this.eMain.className="ag-main",this.eRoot.appendChild(this.eMain),this.eHeader=document.createElement("div"),this.eHeader.className="ag-header-wrapper",this.eMain.appendChild(this.eHeader),this.rowNodeServices={selectNode:(u,f)=>this.selectionService.selectNode(u,f),deselectNode:u=>this.selectionService.deselectNode(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u)},this.columnModel=new zn(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new zo(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),u=>this.isNodeSelectable(u)),this.filterService=new Fo(this),this.sortService=new Wo(this),this.popupService=new Bo(this),this.filterGui=new $o(this,this.popupService),this.contextMenuService=new go(this,this.popupService),this.columnMenuService=new fo(this,this.popupService),this.editService=new mo(this,this.eventService),this.undoRedoService=new jo(this,this.eventService),this.formulaEditorService=new Po(this,this.popupService),this.notesService=new Ho(this,this.popupService),this.rowDragService=new Go(this,this.eventService),this.chartService=new zs(this,this.popupService),this.findService=new Do(this,this.popupService),this.exportService=new Ao(this);const i={options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getSortModel:()=>this.sortService.getSortModel(),getFilterModel:()=>this.filterService.getFilterModel(),rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices},o=this.options.rowModelType||"clientSide";o==="serverSide"?(this.serverSideRowModel=new Vs(i),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new Gs(i),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new qs(i),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new Ls({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var u;return!!((u=this.paginationService)!=null&&u.isEnabled())},getPageSize:()=>{var u;return((u=this.paginationService)==null?void 0:u.getPageSize())??100},getCurrentPage:()=>{var u;return((u=this.paginationService)==null?void 0:u.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(c=(d=this.rowModel).setGridApi)==null||c.call(d,null)),this.headerView=new Ko(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(u=>u.sort)}),onSortRequested:(u,f,g)=>this.sortService.onSortRequested(u,f,g),onColumnResized:(u,f,g)=>this.onColumnResized(u,f,g),onColumnMoved:(u,f)=>this.onColumnMoved(u,f),onColumnMenuClicked:(u,f)=>this.columnMenuService.openColumnMenu(u,f),onFilterOpened:(u,f)=>this.filterGui.openFilter(u,f),isFilterActive:u=>this.filterService.isFilterActive(u),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(u,f)=>this.filterService.handleFloatingFilterChange(u,f),onHeaderCheckboxChanged:(u,f)=>this.onHeaderCheckboxChanged(u,f),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:u=>this.t(u),getApi:()=>this.api,getFilterModel:u=>this.filterService.getFilterInstance(u)??null,onFilterModelChange:(u,f)=>this.filterService.setColumnFilterModel(u,f)}),this.rowRenderer=new Yo(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:u=>this.t(u),getColumns:()=>this.getColumns(),getRowHeight:u=>this.getRowHeight(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u),isRowSelectable:u=>this.isNodeSelectable(u),getRowClass:u=>this.getRowClass(u),getRowStyle:u=>this.getRowStyle(u),onCellClicked:u=>this.onCellClicked(u),onCellDoubleClicked:u=>this.editService.onCellDoubleClicked(u),onCellMouseDown:u=>this.onCellMouseDown(u),onCellContextMenu:u=>this.onCellContextMenu(u),onRowClicked:u=>this.onRowClicked(u),onRowDoubleClicked:u=>this.onRowDoubleClicked(u),onRowGroupClicked:u=>this.onRowGroupClicked(u),onViewportKeyDown:u=>this.onViewportKeyDown(u),onViewportScroll:()=>{var g,v,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const u=this.rowRenderer.getFirstVisibleRowIndex(),f=this.rowRenderer.getLastVisibleRowIndex();(g=this.serverSideRowModel)==null||g.onViewportChanged(u,f),(v=this.infiniteRowModel)==null||v.onViewportChanged(u,f),(m=this.viewportRowModel)==null||m.onViewportChanged(u,f)},getCellText:(u,f)=>{const g=Ce(u,f,this.api);return g==null?"":String(g)},renderDetailRow:u=>this.renderDetailRow(u),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(u,f,g)=>this.rowDragService.startDrag(u,g),getNote:(u,f,g,v)=>this.notesService.getNote(u,f,g,v),onNoteClick:(u,f,g)=>this.notesService.openNoteEditor(u,f,g),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new Vo(this,this.eventService),this.statusBarService=new Uo(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Oo(this),this.sideBarService=new _o(this),this.sideBarService.getElement().classList.contains("ag-side-bar-left")?this.eRoot.insertBefore(this.sideBarService.getElement(),this.eMain):this.eRoot.appendChild(this.sideBarService.getElement()),this.options.pagination&&(this.paginationService=new ei(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new qo(this));const{api:a,columnApi:l}=Rs(this);this.api=a,this.columnApi=l,this.columnModel.setGridApi(this.api),(h=(p=this.rowModel).setGridApi)==null||h.call(p,this.api),this.selectionService.gridApiRef=this.api,this.eventService.addEventListener("columnEverythingChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("displayedColumnsChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("columnRowGroupChanged",()=>{this.serverSideRowModel||this.infiniteRowModel?this.onRemoteModelChanged():this.rowModel.refreshModel("group")}),this.options.__advancedFilterPass=u=>this.filterService.doesNodePassAdvancedFilter(u),this.eventService.addEventListener("columnPivotModeChanged",()=>this.refreshPivotColumns()),this.eventService.addEventListener("modelUpdated",()=>{this.columnModel.isPivotMode()&&this.refreshPivotColumns()}),this.eventService.addEventListener("sortChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("filterChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("columnValueChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("columnPivotModeChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("modelUpdated",()=>this.onModelUpdated()),this.eventService.addEventListener("selectionChanged",()=>{var u,f;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(f=(u=this.options).onSelectionChanged)==null||f.call(u,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let r=this.options.columnDefs||[];(!r||r.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(r=zn.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const n=this.localeText.t(e);return n===e?t:n}getContext(){return this.context}getEventService(){return this.eventService}getColumnModel(){return this.columnModel}getRowModel(){return this.rowModel}getRowRenderer(){return this.rowRenderer}getHeaderView(){return this.headerView}getSelectionService(){return this.selectionService}getEditService(){return this.editService}getFilterService(){return this.filterService}getSortService(){return this.sortService}getFilterGui(){return this.filterGui}getPaginationService(){return this.paginationService}getSideBarService(){return this.sideBarService}getChartService(){return this.chartService}getFindService(){return this.findService}getRangeSelectionService(){return this.rangeSelectionService}getExportService(){return this.exportService}getPopupService(){return this.popupService}getOverlayService(){return this.overlayService}getRowGroupPanel(){return this.rowGroupPanel}getUndoRedoService(){return this.undoRedoService}getFormulaEditorService(){return this.formulaEditorService}getNotesService(){return this.notesService}getRowDragService(){return this.rowDragService}getServerSideRowModel(){return this.serverSideRowModel}getInfiniteRowModel(){return this.infiniteRowModel}getViewportRowModel(){return this.viewportRowModel}updateColumnTotalCache(){var n,i;const e=new Map,t=this.getAllColumns().filter(o=>o.colDef.showValueAs);if(t.length>0){const o=new Map;(i=(n=this.rowModel).forEachLeafNode)==null||i.call(n,a=>{for(const l of t){const r=Ce(l,a,this.api);typeof r=="number"&&!isNaN(r)&&o.set(l.colId,(o.get(l.colId)??0)+r)}});for(const a of t)e.set(a.colId,o.get(a.colId)??0)}this.api.__columnTotalCache=e}refreshPivotColumns(){this.columnModel.updatePivotColumns(this.options.rowData||[])}onRemoteModelChanged(){this.serverSideRowModel?this.serverSideRowModel.onSortOrFilterChanged():this.infiniteRowModel?this.infiniteRowModel.onSortOrFilterChanged():this.viewportRowModel&&this.viewportRowModel.setViewportDatasource(this.viewportRowModel.datasource)}isRemoteLoading(){var e,t,n;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(t=this.infiniteRowModel)!=null&&t.isLoading()||(n=this.viewportRowModel)!=null&&n.isLoading())}getApi(){return this.api}getColumnApi(){return this.columnApi}getRootElement(){return this.eRoot}getMainElement(){return this.eMain}getHeaderElement(){return this.eHeader}getGridDiv(){return this.eGridDiv}getColumns(){return this.columnModel.getDisplayedColumnsByType()}getAllColumns(){return this.columnModel.getAllColumns()}getColumn(e){return this.columnModel.getColumn(e)}getDisplayedRowCount(){return this.rowModel.getRowCount()}getDisplayedRowAtIndex(e){return this.rowModel.getRow(e)}getRowNode(e){return this.rowModel.getRowNode(e)}getRowHeight(e){if(e.rowHeight!==null)return e.rowHeight;const t=this.options.getRowHeight;if(typeof t=="function"){const n=t({data:e.data,node:e,api:this.api});if(n)return n}return this.options.rowHeight??42}getRowClass(e){const t=[];if(this.options.rowClass&&t.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const n=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof n=="string"?t.push(n):Array.isArray(n)&&t.push(...n)}return e.footer&&t.push("ag-row-footer"),t.join(" ")}getRowStyle(e){const t={};return this.options.rowStyle&&Object.assign(t,this.options.rowStyle),typeof this.options.getRowStyle=="function"&&Object.assign(t,this.options.getRowStyle({data:e.data,node:e,api:this.api})),t}isNodeSelectable(e){if(e.footer||e.masterNode)return!1;const t=this.options.isRowSelectable;return!(t&&!t(e))}isCellEditable(e,t){return this.options.readOnlyEdit||t.group||t.footer||t.masterNode?!1:typeof e.editable=="function"?e.editable({data:t.data,node:t,column:e,colDef:e.colDef,api:this.api}):e.editable===!0}setRowData(e,t=!1){var n,i,o;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),t||(this.overlayService.updateAuto(),this.statusBarService.update(),(n=this.paginationService)==null||n.update(),this.chartService.refreshCharts(),(o=(i=this.options).onRowDataChanged)==null||o.call(i,{api:this.api}))}applyTransaction(e){var n;const t=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(n=this.paginationService)==null||n.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),t}setCellValue(e,t,n,i="api",o){const a=o!==void 0?o:Ce(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:Ce(e,t,this.api),newValue:n,data:t.data,node:t,column:e,api:this.api,colDef:e.colDef})===!1)return}else t.setDataValue(e.colId,n);e.rowGroup&&this.rowModel.refreshModel("group"),(i==="edit"||i==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:a,newValue:n,batchId:0}),i!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:n,value:n,data:t.data,node:t,column:e,colDef:e.colDef,api:this.api,source:i})}refreshModel(e){var t;this.rowModel.refreshModel(e),(t=this.paginationService)==null||t.update()}refreshCells(e){this.rowRenderer.refreshCells(e)}setQuickFilter(e){this.quickFilter=e||"",this.refreshModel("filter"),this.findService.applyHighlight()}getQuickFilter(){return this.quickFilter}setRowNodePinned(e,t){e.rowPinned=t,this.rowModel.refreshModel("everything")}openFind(){this.findService.open()}closeFind(){this.findService.close()}onCellClicked(e){var a,l,r,d;const{node:t,column:n,event:i}=e;if(this.options.enableRangeSelection,n.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(l=(a=this.options).onCellClicked)==null||l.call(a,{...e,api:this.api,colDef:n.colDef,value:Ce(n,t,this.api)});return}if(i.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,i),this.editService.onCellClicked(e),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:n.colDef,value:Ce(n,t,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var t,n;this.selectionService.handleRowClick(e.node,e.event),(n=(t=this.options).onRowClicked)==null||n.call(t,{...e,api:this.api})}onRowDoubleClicked(e){var t,n;(n=(t=this.options).onRowDoubleClicked)==null||n.call(t,{...e,api:this.api})}onCellContextMenu(e){var n,i;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(i=(n=this.options).onCellContextMenu)==null||i.call(n,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,n,i,o,a;if(e.group){const l=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);l&&l(e,!e.expanded),globalThis.__dbgLogs.push(["after-toggle",e.id,"expanded=",e.expanded]),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(i=(n=this.options).onRowGroupOpened)==null||i.call(n,{node:e,expanded:e.expanded,api:this.api})}else e.detailNode?(e.expanded=!e.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(a=(o=this.options).onRowGroupOpened)==null||a.call(o,{node:e,expanded:e.expanded,api:this.api})):e.masterNode&&(e.masterNode.expanded=!e.masterNode.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e.masterNode,expanded:e.masterNode.expanded,api:this.api}))}onHeaderCheckboxChanged(e,t){var n;if(e.headerCheckboxSelectionCurrentPageOnly&&((n=this.paginationService)!=null&&n.isEnabled())){const i=this.rowModel.getRowCount();if(t)for(let o=0;o<i;o++){const a=this.rowModel.getRow(o);a&&this.isNodeSelectable(a)&&this.selectionService.selectNode(a,!1)}else for(let o=0;o<i;o++){const a=this.rowModel.getRow(o);a&&this.selectionService.deselectNode(a)}}else this.selectionService.setSelectAllCheckboxState(t);this.updateHeaderCheckboxes()}updateHeaderCheckboxes(){for(const e of this.getAllColumns()){if(!e.headerCheckboxSelection)continue;const t=e.eHeaderCell;if(!t)continue;const n=t.querySelector(".ag-header-select-all");if(!n)continue;const i=this.selectionService.getSelectAllState();n.checked=i.checked,n.indeterminate=i.indeterminate}}onViewportKeyDown(e){if(this.editService.onGridKeyDown(e),this.rangeSelectionService.onGridKeyDown(e),(e.ctrlKey||e.metaKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?this.undoRedoService.redo():this.undoRedoService.undo();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),this.undoRedoService.redo();return}(e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")&&this.rangeSelectionService.getRanges().length===0&&this.selectionService.getSelectedNodes().length>0&&(e.preventDefault(),this.api.copyToClipboard()),(e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")&&this.rangeSelectionService.getRanges().length===0&&(e.preventDefault(),this.api.pasteFromClipboard())}onColumnResized(e,t,n){e.width=t,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),n&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,t){const n=this.columnModel.getColumns(),i=n.findIndex(a=>a.colId===e);if(i<0)return;let o=n.length;t&&(o=n.findIndex(a=>a.colId===t)),this.columnModel.moveColumnByIndex(i,o,"uiColumnMoved")}onColumnsChanged(){var e,t;this.headerView.refresh(),this.rowRenderer.refreshRows(),this.updateHeaderCheckboxes(),(t=(e=this.options).onDisplayedColumnsChanged)==null||t.call(e,{api:this.api})}onModelUpdated(){var e,t,n,i,o,a,l;this.updateColumnTotalCache(),this.rowRenderer.refreshRows(),this.options.__loadingRows=this.isRemoteLoading(),this.overlayService.updateAuto(),this.statusBarService.update(),(e=this.paginationService)==null||e.update(),this.rangeSelectionService.applyHighlight(),this.findService.applyHighlight(),this.chartService.refreshCharts(),this.gridReadyDispatched||(this.gridReadyDispatched=!0,this.eventService.dispatchEvent("firstDataRendered",{api:this.api}),(n=(t=this.options).onFirstDataRendered)==null||n.call(t,{api:this.api})),(o=(i=this.options).onModelUpdated)==null||o.call(i,{api:this.api}),(l=(a=this.options).onRowDataChanged)==null||l.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,l;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),n=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,i=Math.max(0,e-n);(t||((o=this.options.autoSizeStrategy)==null?void 0:o.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(i),this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows()),this.rowRenderer.renderVisibleRows(!0),this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth()),this.eventService.dispatchEvent("gridSizeChanged",{clientWidth:this.eGridDiv.clientWidth,clientHeight:this.eGridDiv.clientHeight,api:this.api}),(l=(a=this.options).onGridSizeChanged)==null||l.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const t=e.masterNode;if(!t)return null;const n=this.options.detailRowAutoHeight===!0,i=n?this.options.detailRowHeight??200:this.options.detailRowHeight??200,o=document.createElement("div");o.className="ag-row-detail",o.style.height=`${i}px`,o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0";const a=this.options.detailCellRenderer,l=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(l&&r){const p=r({data:t.data,node:t,api:this.api}),h=document.createElement("div");h.style.height="100%",h.style.padding="8px 16px",o.appendChild(h),setTimeout(()=>{new ht(h,{...l,rowData:p,theme:this.options.theme})},0)}else if(typeof a=="function"){const p=a({data:t.data,node:t,api:this.api,context:this.context});p instanceof HTMLElement?o.appendChild(p):o.textContent=String(p??"")}else typeof a=="string"&&(o.textContent=a);if(n){const p=Math.max(40,o.scrollHeight||i);return e.rowHeight=p,o.style.height=`${p}px`,{eDetail:o,height:p}}return e.rowHeight=i,{eDetail:o,height:i}}dispatchGridReady(){var e,t;this.eventService.dispatchEvent("gridReady",{api:this.api,columnApi:this.columnApi}),(t=(e=this.options).onGridReady)==null||t.call(e,{api:this.api,columnApi:this.columnApi,context:this.context})}updateGridOptions(e){const t=this.options.theme,n=e.rowData!==void 0&&e.rowData!==this.options.rowData,i=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),n&&this.setRowData(e.rowData),i&&this.columnModel.setColumnDefs(this.options.columnDefs||[]),e.sideBar!==void 0&&(this.sideBarService.setVisible(!!e.sideBar),this.onGridSizeChanged()),e.quickFilterText!==void 0&&this.setQuickFilter(e.quickFilterText),e.theme!==void 0&&e.theme!==t&&(this.eGridDiv.classList.remove(t||"ag-theme-alpine"),this.eGridDiv.classList.add(e.theme)),e.pagination!==void 0&&(e.pagination&&!this.paginationService?this.paginationService=new ei(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,this.interactions.destroy(),window.removeEventListener("resize",this.onWindowResize),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0),(e=this.resizeObserver)==null||e.disconnect(),this.rowRenderer.destroy(),this.editService.destroy(),this.popupService.closeAll(),this.eRoot.remove(),this.eGridDiv.classList.remove("ag-grid-root","ag-theme-alpine","ag-theme-quartz","ag-theme-balham"),this.eventService.dispatchEvent("gridReady",{}))}}function ni(s,e){const t=new ht(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function ii(s,e={}){const t=document.createElement("dialog");t.className="rowvia-detail-dialog";const n=De(t,"detail-dialog",e),i=()=>{var d;return(d=e.onClose)==null?void 0:d.call(e)};t.addEventListener("close",i);const o=document.createElement("h2"),a=document.createElement("dl"),l=document.createElement("button");l.type="button",l.textContent="关闭";const r=()=>t.close();return l.addEventListener("click",r),t.append(o,a,l),s.append(t),{onInteraction:n.onInteraction,open(d){var c;o.textContent=d.title,t.setAttribute("aria-label",d.title),a.replaceChildren();for(const p of d.fields){const h=document.createElement("dt"),u=document.createElement("dd");h.textContent=p.label,u.textContent=p.value,a.append(h,u)}t.open||t.showModal(),(c=e.onOpen)==null||c.call(e,d)},close:r,destroy(){t.open&&t.close(),l.removeEventListener("click",r),t.removeEventListener("close",i),n.destroy(),t.remove()}}}const Zo=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Qo=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Jo=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function $e(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function pt(s,e,t){const n=document.createElement("button");return n.type="button",n.className=e,n.textContent=s,n.addEventListener("click",i=>{i.stopPropagation(),t()}),n}class ea{constructor(e,t,n,i){y(this,"filterFields");y(this,"sortFields");y(this,"filterRows",[]);y(this,"sorts",[]);y(this,"filterPanel",null);y(this,"sortPanel",null);y(this,"filterAnchor",null);y(this,"sortAnchor",null);y(this,"onDocumentMouseDown",e=>{var n,i;const t=e.target;this.filterPanel&&!this.filterPanel.contains(t)&&!((n=this.filterAnchor)!=null&&n.contains(t))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(t)&&!((i=this.sortAnchor)!=null&&i.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=i,this.filterFields=n.filter,this.sortFields=n.sort,document.addEventListener("mousedown",this.onDocumentMouseDown,!0)}openFilterPanel(e){if(this.filterPanel){this.closeFilterPanel();return}this.closeSortPanel();const t=$e("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",d=>d.stopPropagation());const n=$e("div","gt-panel-title");n.textContent="筛选",t.appendChild(n);const i=$e("div","gt-filter-rows");t.appendChild(i);const o=()=>{if(i.textContent="",!this.filterRows.length){const d=$e("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",i.appendChild(d)}for(const d of this.filterRows)i.appendChild(this.renderFilterRow(d,o))},a=$e("div","gt-filter-add");for(const d of this.filterFields)a.appendChild(pt(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const l=$e("div","gt-panel-hint");l.textContent="多个条件同时满足(且)",t.appendChild(l);const r=$e("div","gt-panel-actions");r.append(pt("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),pt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const n=$e("div","gt-filter-row"),i=this.filterFields.find(d=>d.colId===e.colId),o=document.createElement("select");o.className="gt-panel-select";for(const d of this.filterFields){const c=document.createElement("option");c.value=d.colId,c.textContent=d.label,d.colId===e.colId&&(c.selected=!0),o.appendChild(c)}o.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===o.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),n.appendChild(o);const a=e.kind==="number"?Qo:e.kind==="date"?Jo:Zo,l=document.createElement("select");l.className="gt-panel-select gt-panel-select-cond";for(const d of a){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),l.appendChild(c)}if(l.addEventListener("change",()=>{e.type=l.value,t()}),n.appendChild(l),e.type!=="blank")if(i!=null&&i.options){const d=document.createElement("select");d.className="gt-panel-select";const c=document.createElement("option");c.value="",c.textContent="请选择",d.appendChild(c);for(const p of i.options){const h=document.createElement("option");h.value=p.value,h.textContent=p.label,p.value===e.value&&(h.selected=!0),d.appendChild(h)}d.addEventListener("change",()=>{e.value=d.value}),n.appendChild(d)}else if(e.kind==="date"){const d=document.createElement("input");if(d.type="date",d.className="gt-panel-input",d.value=e.value,d.addEventListener("change",()=>{e.value=d.value}),n.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="date",c.className="gt-panel-input",c.value=e.valueTo,c.addEventListener("change",()=>{e.valueTo=c.value}),n.appendChild(c)}}else if(e.kind==="number"){const d=document.createElement("input");if(d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="数值",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),n.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="至",c.value=e.valueTo,c.addEventListener("input",()=>{e.valueTo=c.value}),n.appendChild(c)}}else{const d=document.createElement("input");d.type="text",d.className="gt-panel-input",d.placeholder="文本",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),n.appendChild(d)}const r=pt("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),t()});return r.title="移除条件",n.appendChild(r),n}applyFilter(){const e={};for(const t of this.filterRows){if(t.type==="blank"){e[t.colId]={filterType:t.kind==="number"?"number":"text",type:"blank",filter:""};continue}if(t.kind==="date"){const n=(t.type==="after",t.value),i=t.type==="before"?t.value:t.valueTo;if(t.type==="before"&&!t.value||t.type==="after"&&!t.value||t.type==="inRange"&&!t.value&&!t.valueTo)continue;e[t.colId]={filterType:"date",dateFrom:n||void 0,dateTo:i||void 0};continue}if(t.value)if(t.kind==="number"){const n={filterType:"number",type:t.type,filter:Number(t.value)};t.type==="inRange"&&(n.filterTo=Number(t.valueTo||t.value)),e[t.colId]=n}else e[t.colId]={filterType:"text",type:t.type,filter:t.value}}this.api.setFilterModel(e),this.hooks.onFilterButton(Object.keys(e).length>0,Object.keys(e).length)}closeFilterPanel(){var e;(e=this.filterPanel)==null||e.remove(),this.filterPanel=null}openSortPanel(e){if(this.sortPanel){this.closeSortPanel();return}this.closeFilterPanel();const t=$e("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",l=>l.stopPropagation());const n=$e("div","gt-panel-title");n.textContent="排序",t.appendChild(n);const i=$e("div","gt-sort-list");t.appendChild(i);const o=()=>{var l;i.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(u=>u.colId===r.colId),c=d>=0,p=$e("div","gt-sort-item");c&&p.classList.add("gt-sort-item-active");const h=$e("span","gt-sort-label");if(h.textContent=r.label,p.appendChild(h),c){const u=$e("span","gt-sort-badge");u.textContent=String(d+1),p.appendChild(u);const f=$e("span","gt-sort-dir");f.textContent=((l=this.sorts[d])==null?void 0:l.sort)==="asc"?"↑ 升序":"↓ 降序",p.appendChild(f)}p.addEventListener("click",()=>{var u;c?((u=this.sorts[d])==null?void 0:u.sort)==="asc"?this.sorts[d]={colId:r.colId,sort:"desc"}:this.sorts=this.sorts.filter(f=>f.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),o()}),i.appendChild(p)}},a=$e("div","gt-panel-actions");a.append(pt("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),pt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applySort(),this.closeSortPanel()})),t.appendChild(a),this.mount(t,e),this.sortPanel=t,this.sortAnchor=e,o()}applySort(){this.api.setSortModel(this.sorts.map(e=>({colId:e.colId,sort:e.sort}))),this.hooks.onSortButton(this.sorts.length>0,this.sorts.length)}closeSortPanel(){var e;(e=this.sortPanel)==null||e.remove(),this.sortPanel=null}mount(e,t){this.host.appendChild(e);const n=t.getBoundingClientRect();e.style.top=`${n.bottom+6}px`;const i=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(n.left,i))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const si=864e5;function tt(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${n}`}function He(s){return new Date(`${s}T00:00:00`)}function Pe(s,e){return new Date(s.getTime()+e*si)}function je(s,e){const t=typeof s=="string"?He(s):s,n=typeof e=="string"?He(e):e;return Math.round((n.getTime()-t.getTime())/si)}function Lt(){return tt(new Date)}function ta(s){return s.status!=="done"&&s.end&&s.end<Lt()&&s.progress<100?"delayed":s.status}function sn(s){const e=He(s);return`${e.getMonth()+1}月${e.getDate()}日`}const oi=["day","week","biweek","month","bimonth","quarter","halfyear","year"],qt={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},na={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2};function on(s){const e=(s.getDay()+6)%7;return Pe(s,-e)}function ia(s,e){const t=Math.max(1,je(s,e)+1);let n=0;for(let i=0;i<t;i++){const o=Pe(s,i).getDay();o!==0&&o!==6&&n++}return Math.max(1,n)}function sa(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function ai(s,e,t){const n=[];if(s==="day"){let r=new Date(e);for(;r<t;){const d=Pe(r,1);n.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return n}if(s==="week"||s==="biweek"){let r=on(e);for(;r<t;){const d=Pe(r,s==="biweek"?14:7);n.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return n}const i=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/i)*i,1),a=r=>s==="month"||s==="bimonth"?`${r.getMonth()+1}月`:s==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let l=o(e);for(;l<t;){const r=sa(l,i);n.push({start:new Date(l),end:r,primary:a(l),secondary:""}),l=r}return n}const Le={accent:"#4555e5",text:"#1f2329",textTertiary:"#8f959e",border:"#dee0e3",groupRow:"transparent",weekend:"rgba(31, 35, 41, 0.04)",gridline:"rgba(31, 35, 41, 0.10)",gridlineMonth:"rgba(31, 35, 41, 0.12)",rowLine:"transparent",hover:"rgba(51, 112, 255, 0.05)",selected:"rgba(51, 112, 255, 0.09)"},zt={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},oa=4,ri=6,_e=28;class li{constructor(e,t){y(this,"interactions");y(this,"onInteraction");y(this,"options");y(this,"eRoot");y(this,"eHeader");y(this,"eRuler");y(this,"rulerCtx");y(this,"eRulerTools");y(this,"eStepLabel");y(this,"eZoomValue");y(this,"eStepMenu",null);y(this,"eScroll");y(this,"eSpacer");y(this,"eCanvas");y(this,"ctx");y(this,"eTooltip");y(this,"eTodayBadge");y(this,"ePopup",null);y(this,"tasks",[]);y(this,"tasksById",new Map);y(this,"rows",[]);y(this,"selectedId",null);y(this,"hoverId",null);y(this,"unit","day");y(this,"zoom",1);y(this,"theme","content");y(this,"epochStart",new Date);y(this,"totalDays",1);y(this,"hits",[]);y(this,"hitsByRow",new Map);y(this,"drag",null);y(this,"ghost",null);y(this,"dirty",!0);y(this,"lastLeft",-1);y(this,"lastTop",-1);y(this,"timer");y(this,"observer",null);y(this,"resizeHandler",()=>this.resizeCanvases());y(this,"showChildren",!0);y(this,"milestonesOnly",!1);y(this,"locateHits",[]);y(this,"tick",()=>{const e=this.eScroll.scrollLeft,t=this.eScroll.scrollTop;(e!==this.lastLeft||t!==this.lastTop||this.dirty)&&(this.lastLeft=e,this.lastTop=t,this.eCanvas.style.transform=`translate(${e}px, ${t}px)`,this.draw(),this.dirty=!1)});y(this,"onScroll",()=>{this.tick()});y(this,"todayLabelX",-1);y(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:n,onAvatar:i}=this.hitAt(e.clientX,e.clientY),o=this.rows[n];i?this.eCanvas.style.cursor="pointer":t&&t.mode!=="move"?this.eCanvas.style.cursor="ew-resize":t?this.eCanvas.style.cursor="grab":this.eCanvas.style.cursor="default";const a=t?t.id:(o==null?void 0:o.id)??null;a!==this.hoverId&&(this.hoverId=a,this.options.onHover(a),this.markDirty())});y(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),n=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-t.left))<12&&Math.abs(d.y-(e.clientY-t.top))<12);if(n){this.scrollToTask(n.id);return}const{hit:i,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),l=this.rows[o];if(i){const d=this.tasksById.get(i.id);if(!d)return;if(a){e.stopPropagation(),this.openAssigneePopup(i.id,i);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(i.id);return}e.preventDefault(),this.drag={id:i.id,mode:i.mode,startX:e.clientX,startY:e.clientY,originStart:d.start,originEnd:d.end,start:d.start,end:d.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(i.id);return}if(!l)return;const r=this.tasksById.get(l.id);if(r){if(r.kind==="task"&&(!r.start||!r.end)){const d=this.pointAt(e.clientX,e.clientY),c=Math.floor(d.x/this.dayWidth),p=tt(Pe(this.epochStart,c));this.options.onTaskChange({...r,start:p,end:tt(Pe(He(p),4)),progress:0,status:"not-started"}),this.options.onSelect(l.id);return}this.options.onSelect(l.id)}});y(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const n=this.tasksById.get(t.id);if(!n||!t.moved&&Math.abs(e.clientX-t.startX)<oa)return;t.moved=!0;const i=this.dayWidth,o=Math.round((e.clientX-t.startX)/i),a=He(t.originStart),l=He(t.originEnd),r=je(a,l);let d,c;t.mode==="resize-l"?(d=Pe(a,Math.min(o,r)),c=l):t.mode==="resize-r"?(d=a,c=Pe(l,Math.max(o,-r))):(d=Pe(a,o),c=Pe(l,o)),n.milestone&&(d=c),t.start=tt(d),t.end=tt(c),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=n.milestone?sn(t.start):`${sn(t.start)} → ${sn(t.end)}`;const p=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-p.left+12}px`,this.eTooltip.style.top=`${e.clientY-p.top+16}px`});y(this,"endDrag",()=>{window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.eTooltip.style.display="none";const e=this.drag;if(this.drag=null,this.ghost=null,this.markDirty(),!(e!=null&&e.moved)||e.start===e.originStart&&e.end===e.originEnd)return;const t=this.tasksById.get(e.id);t&&this.options.onTaskChange({...t,start:e.start,end:e.end})});y(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});y(this,"onDocumentMouseDown",e=>{const t=e.target;this.ePopup&&!this.ePopup.contains(t)&&this.closeAssigneePopup(),this.eStepMenu&&!this.eStepMenu.contains(t)&&!this.eRulerTools.contains(t)&&this.closeStepMenu()});this.options=t,this.eRoot=document.createElement("div"),this.interactions=De(this.eRoot,"gantt-chart",t),this.onInteraction=this.interactions.onInteraction,this.eRoot.className="gt-root",e.appendChild(this.eRoot),this.eHeader=document.createElement("div"),this.eHeader.className="gt-header",this.eRuler=document.createElement("canvas"),this.eRuler.className="gt-ruler",this.eHeader.appendChild(this.eRuler),this.eRoot.appendChild(this.eHeader),this.rulerCtx=this.eRuler.getContext("2d"),this.buildRulerTools(),this.eScroll=document.createElement("div"),this.eScroll.className="gt-scroll",this.eSpacer=document.createElement("div"),this.eSpacer.className="gt-spacer",this.eCanvas=document.createElement("canvas"),this.eCanvas.className="gt-canvas",this.eScroll.append(this.eSpacer,this.eCanvas),this.eRoot.appendChild(this.eScroll),this.ctx=this.eCanvas.getContext("2d"),this.eTooltip=document.createElement("div"),this.eTooltip.className="gt-tooltip",this.eTooltip.style.display="none",this.eRoot.appendChild(this.eTooltip),this.eTodayBadge=document.createElement("div"),this.eTodayBadge.className="gt-today-badge",this.eRoot.appendChild(this.eTodayBadge),this.eScroll.addEventListener("scroll",this.onScroll),this.eCanvas.addEventListener("mousedown",this.onCanvasMouseDown),this.eCanvas.addEventListener("mousemove",this.onCanvasMouseMove),this.eRoot.addEventListener("mouseleave",this.onRootMouseLeave);const n=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(n),this.observer.observe(this.eScroll),this.observer.observe(this.eHeader)),window.addEventListener("resize",this.resizeHandler),this.timer=setInterval(this.tick,40),this.resizeCanvases()}destroy(){var e;this.interactions.destroy(),clearInterval(this.timer),(e=this.observer)==null||e.disconnect(),window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.closeAssigneePopup(),this.closeStepMenu(),this.eRoot.remove()}setHover(e){this.hoverId!==e&&(this.hoverId=e,this.markDirty())}setShowChildren(e){this.showChildren=e,this.markDirty()}setMilestonesOnly(e){this.milestonesOnly=e,this.markDirty()}scrollToTask(e){const t=this.tasksById.get(e);t!=null&&t.start&&(this.eScroll.scrollLeft=Math.max(0,this.dateX(t.start)-this.eScroll.clientWidth*.12),this.markDirty())}setTasks(e){this.tasks=e,this.tasksById=new Map(e.map(t=>[t.id,t])),this.computeDomain(),this.markDirty()}setRows(e){e.length===this.rows.length&&e.every((t,n)=>{const i=this.rows[n];return t.id===i.id&&t.group===i.group&&t.expanded===i.expanded})||(this.rows=e,this.markDirty())}setSelected(e){this.selectedId=e,this.markDirty()}setUnit(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.unit=e,this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setZoom(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.zoom=Math.max(.5,Math.min(3,e)),this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setTheme(e){this.theme=e,this.markDirty()}get dayWidth(){return na[this.unit]*this.zoom}get scrollElement(){return this.eScroll}setScrollTop(e){this.eScroll.scrollTop=e}redraw(){this.markDirty()}markDirty(){this.dirty=!0,this.tick()}scrollToToday(e=.32){const t=this.dateX(Lt()),n=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=n}computeDomain(){let e=null,t=null;for(const o of this.tasks)!o.start||!o.end||((!e||o.start<e)&&(e=o.start),(!t||o.end>t)&&(t=o.end));const n=Lt();(!e||e>n)&&(e=n),(!t||t<n)&&(t=n);const i=on(Pe(He(e),-7));this.epochStart=i,this.totalDays=Math.max(je(i,He(t))+730,1095)}dateX(e){return je(this.epochStart,e)*this.dayWidth}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[t,n]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const i=t===this.eRuler?this.eHeader.clientWidth:this.eScroll.clientWidth,o=t===this.eRuler?this.eHeader.clientHeight:this.eScroll.clientHeight;t.width=Math.max(1,Math.round(i*e)),t.height=Math.max(1,Math.round(o*e)),t.style.width=`${i}px`,t.style.height=`${o}px`,n.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,n=this.totalDays*e,i=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${n}px`,this.eSpacer.style.height=`${i}px`,this.drawRuler(e,n),this.drawBody(e,n,i,t)}drawRuler(e,t){const n=this.rulerCtx,i=this.eHeader.clientWidth,o=this.eHeader.clientHeight,a=this.eScroll.scrollLeft;n.clearRect(0,0,i,o),n.fillStyle="#fff",n.fillRect(0,0,i,o);const l=Pe(this.epochStart,this.totalDays),r=(p,h,u,f)=>{for(const g of p){const v=this.dateX(tt(g.start))-a,m=je(g.start,g.end)*e;if(v+m<=0||v>=i)continue;const w=Math.max(0,Math.min(v+m,i)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const b=g.start.getDay();(b===0||b===6)&&(n.fillStyle=Le.weekend,n.fillRect(Math.max(0,v),h,w,u))}const k=n.measureText(g.primary).width;if(k+8<w){const b=Math.max(0,v)+w/2-k/2,N=h+u/2+5;n.fillStyle=Le.text,n.font="11px "+Ye,n.textAlign="left",n.textBaseline="alphabetic",n.fillText(g.primary,b,N),g.secondary&&(n.fillStyle=Le.textTertiary,n.font="10px "+Ye,n.fillText(g.secondary,b,N+12))}}},d=40,c=Pe(this.epochStart,Math.floor(a/e));n.fillStyle=Le.text,n.font="14px "+Ye,n.textAlign="left",n.textBaseline="middle",n.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(ai(this.unit,this.epochStart,l),d+1,o-d-1),n.strokeStyle=Le.border,n.beginPath(),n.moveTo(0,o-.5),n.lineTo(i,o-.5),n.stroke()}drawBody(e,t,n,i){const o=this.ctx,a=this.eScroll.clientWidth,l=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;o.clearRect(0,0,a,l),o.fillStyle="#fff",o.fillRect(0,0,a,l),o.save(),o.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(n,d+l)),this.drawGridlines(e,t,Math.max(n,d+l)),this.drawRowBackgrounds(t,i);const c=this.rows.findIndex(h=>h.id===this.hoverId),p=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(p==null?void 0:p.kind)==="task"&&!p.start){const h=c*i+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,ft(o,r+4,h,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Le.textTertiary,o.font="14px "+Ye,o.textAlign="center",o.fillText("新建排期",r+a/2,h+19)}this.drawDependencies(i),this.drawBars(i),this.drawTodayLine(t,Math.max(n,d+l)),o.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,n){if(this.unit!=="day"&&this.unit!=="week")return;const i=this.ctx;i.fillStyle=Le.weekend;let o=on(this.epochStart);for(;je(this.epochStart,o)<this.totalDays;){const a=this.dateX(tt(o))+5*e;a<t&&i.fillRect(Math.max(0,a),0,e*2,n),o=Pe(o,7)}}drawGridlines(e,t,n){const i=this.ctx,o=Pe(this.epochStart,this.totalDays);for(const a of ai(this.unit,this.epochStart,o)){const l=Math.round(this.dateX(tt(a.start)))+.5;if(l<0||l>t)continue;const r=this.unit==="day"&&a.start.getDate()===1;i.strokeStyle=r?Le.gridlineMonth:Le.gridline,i.beginPath(),i.moveTo(l,0),i.lineTo(l,n),i.stroke()}}drawRowBackgrounds(e,t){const n=this.ctx;n.strokeStyle=Le.rowLine,n.lineWidth=1,n.beginPath();for(let i=1;i<this.rows.length;i++){const o=Math.round(i*t)+.5;n.moveTo(0,o),n.lineTo(e,o)}n.stroke(),this.rows.forEach((i,o)=>{const a=this.selectedId===i.id,l=this.hoverId===i.id;(a||l)&&(n.fillStyle=a?Le.selected:l?Le.hover:Le.groupRow,n.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const n=this.ctx,i=Math.round(this.dateX(Lt())+this.dayWidth/2)+.5;i<0||i>e||(n.strokeStyle=Le.accent,n.lineWidth=1.5,n.beginPath(),n.moveTo(i,0),n.lineTo(i,t),n.stroke(),this.todayLabelX=i-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=Lt().slice(5),this.eTodayBadge.style.left=`${this.todayLabelX-25}px`,this.eTodayBadge.style.top=`${this.eHeader.clientHeight-10}px`}drawDependencies(e){const t=new Map(this.rows.map((i,o)=>[i.id,o])),n=this.ctx;n.strokeStyle=Le.accent,n.lineWidth=1.2;for(const i of this.rows){const o=this.tasksById.get(i.id);if(!o||o.kind!=="task"||!o.start||!o.end)continue;const a=t.get(i.id);if(a!==void 0)for(const l of o.dependsOn){const r=this.tasksById.get(l),d=t.get(l);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),p=r.milestone?this.dayWidth:Math.max(je(He(r.start),He(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),h=c+p,u=d*e+e/2,f=this.dateX(o.start),g=Math.max(je(He(o.start),He(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=a*e+e/2,m=h+10;if(f-4>m)di(n,h,u,m,v,f-5,v);else{const w=f+g+10;di(n,h,u,m,v,w,v)}ra(n,f-5,v)}}}drawBars(e){this.rows.forEach((t,n)=>{const i=this.tasksById.get(t.id);if(!i||!i.start||i.path.length>1&&(!this.showChildren||this.milestonesOnly&&!i.milestone))return;const o=n*e+(e-_e)/2;if(t.group){this.drawSummaryBar(i,n,o);return}if(i.milestone){this.drawMilestone(i,n,o);return}i.end&&this.drawTaskBar(i,n,o)})}drawTaskBar(e,t,n){var u;const i=this.ctx,o=((u=this.ghost)==null?void 0:u.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,l=(o==null?void 0:o.end)??e.end,r=this.dateX(a),d=Math.max(28,(je(a,l)+1)*this.dayWidth),c=zt[e.status];i.save(),i.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,i.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",i.strokeStyle=this.selectedId===e.id?Le.accent:"#dee0e3",i.lineWidth=1,ft(i,r,n,d,_e,4),i.fill(),i.stroke(),i.save(),ft(i,r,n,d,_e,4),i.clip(),i.beginPath(),i.arc(r+14,n+14,6,0,Math.PI*2),i.fillStyle=c,i.fill(),i.font="12px "+Ye,i.textBaseline="middle",i.textAlign="left",i.fillStyle=Le.text;const p=this.options.members.find(f=>f.id===e.owner),h=i.measureText(e.name).width;d>h+58?(i.fillText(e.name,r+26,n+14),p&&an(i,r+h+42,n+14,7,_t(p.id),p.name.slice(0,1))):p&&d>46&&an(i,r+38,n+14,7,_t(p.id),p.name.slice(0,1)),d>100&&(i.fillStyle=Le.textTertiary,i.textAlign="right",i.fillText(String(ia(He(a),He(l))),r+d-8,n+14)),i.restore(),i.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:n,w:d,h:_e,mode:"move",avatar:p?{x:r+(d>h+58?h+42:38),y:n+14,r:7}:void 0})}drawSummaryBar(e,t,n){if(!e.start||!e.end)return;const i=this.tasks.filter(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),o=i[0],a=this.ctx,l=this.dateX(e.start),r=Math.max(92,(je(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?Le.accent:"#dee0e3",a.lineWidth=1,ft(a,l,n,r,_e,4),a.fill(),a.stroke(),a.fillStyle=o?zt[o.status]:zt[e.status],a.beginPath(),a.arc(l+14,n+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Le.text,a.font="11px "+Ye,a.textAlign="left",a.textBaseline="middle";const d=((o==null?void 0:o.name)??e.name)+(i.length>1?` +${i.length-1}`:"");a.fillText(aa(a,d,r-32),l+25,n+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:l,y:n,w:r,h:_e,mode:"move"})}drawMilestone(e,t,n){var v;const i=this.ctx,o=this.dayWidth,a=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,l=a?a.start:e.start,r=ta(e),d=zt[r],c=this.dateX(l)+o/2;i.font="12px "+Ye;const p=i.measureText(e.name).width,h=e.owner?24:0,u=19+p+h+14,f=c-u/2;i.fillStyle="#fff",i.strokeStyle=d,i.lineWidth=1.5,ft(i,f,n,u,_e,4),i.fill(),i.stroke(),i.fillStyle=d,i.beginPath(),i.arc(f+7+3,n+_e/2,3,0,Math.PI*2),i.fill(),i.fillStyle=Le.text,i.textAlign="left",i.textBaseline="middle",i.fillText(e.name,f+14+5,n+_e/2+1);let g;if(e.owner){const m=this.options.members.find(w=>w.id===e.owner);m&&(an(i,f+u-12,n+_e/2,9,_t(m.id),m.name.slice(0,1)),g={x:f+u-12,y:n+_e/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:f,y:n,w:u,h:_e,mode:"move",avatar:g})}pushHit(e){this.hits.push(e);const t=this.hitsByRow.get(e.rowIndex);t?t.push(e):this.hitsByRow.set(e.rowIndex,[e])}drawLocateButtons(){this.locateHits=[];const e=this.ctx,t=this.eScroll.scrollLeft,n=this.eScroll.clientWidth;this.rows.forEach((i,o)=>{const a=this.tasksById.get(i.id);if(!(a!=null&&a.start)||!a.end||a.path.length>1&&(!this.showChildren||this.milestonesOnly&&!a.milestone))return;const l=this.dateX(a.start),r=this.dateX(a.end)+this.dayWidth;if(r>=t&&l<=t+n)return;const d=r<t?10:n-18,c=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",ft(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+Ye,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<t?"‹":"›",d+1,c),this.locateHits.push({id:a.id,x:d+1,y:c}))})}pointAt(e,t){const n=this.eScroll.getBoundingClientRect();return{x:e-n.left+this.eScroll.scrollLeft,y:t-n.top+this.eScroll.scrollTop}}hitAt(e,t){const n=this.pointAt(e,t),i=Math.floor(n.y/this.options.rowHeight),o=this.hitsByRow.get(i)??[];for(const a of o){if(a.avatar){const l=n.x-a.avatar.x,r=n.y-a.avatar.y;if(l*l+r*r<=a.avatar.r*a.avatar.r)return{hit:a,rowIndex:i,onAvatar:!0}}if(n.x>=a.x&&n.x<=a.x+a.w&&n.y>=a.y&&n.y<=a.y+a.h){const l=a.kind==="task"&&n.x<=a.x+ri,r=a.kind==="task"&&n.x>=a.x+a.w-ri;return{hit:{...a,mode:l?"resize-l":r?"resize-r":"move"},rowIndex:i,onAvatar:!1}}}return{hit:null,rowIndex:i,onAvatar:!1}}buildRulerTools(){this.eRulerTools=document.createElement("div"),this.eRulerTools.className="gt-ruler-tools",this.eHeader.appendChild(this.eRulerTools);const e=document.createElement("button");e.type="button",e.className="gt-ruler-btn gt-ruler-step",this.eStepLabel=document.createElement("span"),this.eStepLabel.className="gt-ruler-step-label",this.eStepLabel.textContent=qt[this.unit];const t=document.createElement("span");t.className="gt-ruler-caret",t.textContent="▾",e.append(this.eStepLabel,t),e.addEventListener("click",o=>{o.stopPropagation(),this.toggleStepMenu()}),this.eRulerTools.appendChild(e);const n=this.toolButton("−","缩小",()=>this.zoomBy(-.25));this.eZoomValue=document.createElement("span"),this.eZoomValue.className="gt-ruler-zoom-value",this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`;const i=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(n,i),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,n){const i=document.createElement("button");return i.type="button",i.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(i.className="gt-ruler-btn gt-ruler-today"),i.textContent=e,i.title=t,i.addEventListener("click",o=>{o.stopPropagation(),n()}),i}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const t=this.totalDays*this.dayWidth-this.eScroll.clientWidth,n=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(t,n))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const i of oi){const o=document.createElement("div");o.className="gt-step-item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(i===this.unit)),o.tabIndex=0,o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.setUnit(i),this.closeStepMenu())}),i===this.unit&&o.classList.add("gt-step-item-active"),o.textContent=qt[i],o.addEventListener("click",a=>{a.stopPropagation(),this.setUnit(i),this.closeStepMenu()}),e.appendChild(o)}const t=this.eRulerTools.getBoundingClientRect(),n=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,n.right-t.right)}px`,e.style.top=`${t.bottom-n.top+4}px`,this.eRoot.appendChild(e),this.eStepMenu=e,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeStepMenu(){var e;(e=this.eStepMenu)==null||e.remove(),this.eStepMenu=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}updateRulerTools(){this.eStepLabel.textContent=qt[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,t){this.closeAssigneePopup();const n=this.tasksById.get(e);if(!n)return;const i=document.createElement("div");i.className="gt-popup";const o=document.createElement("div");o.className="gt-popup-title",o.textContent="更换负责人",i.appendChild(o);for(const d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",n.owner===d.id&&c.classList.add("gt-popup-item-active");const p=document.createElement("span");p.className="gt-avatar",p.textContent=d.name.slice(0,1),p.style.backgroundColor=_t(d.id);const h=document.createElement("span");h.textContent=d.name,c.append(p,h),c.addEventListener("click",u=>{u.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),i.appendChild(c)}if(n.owner){const d=document.createElement("div");d.className="gt-popup-item gt-popup-clear",d.textContent="取消负责人",d.addEventListener("click",c=>{c.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),i.appendChild(d)}const a=this.eRoot.getBoundingClientRect(),l=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;i.style.left=`${Math.min(a.width-150,Math.max(0,l-40))}px`,i.style.top=`${r+t.h+6}px`,this.eRoot.appendChild(i),this.ePopup=i,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const Ye="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function ft(s,e,t,n,i,o){const a=Math.max(0,n),l=Math.max(0,i);if(a===0||l===0)return;const r=Math.max(0,Math.min(o,a/2,l/2));s.beginPath(),s.moveTo(e+r,t),s.lineTo(e+a-r,t),s.arcTo(e+a,t,e+a,t+r,r),s.lineTo(e+a,t+l-r),s.arcTo(e+a,t+l,e+a-r,t+l,r),s.lineTo(e+r,t+l),s.arcTo(e,t+l,e,t+l-r,r),s.lineTo(e,t+r),s.arcTo(e,t,e+r,t,r),s.closePath()}function an(s,e,t,n,i,o){s.beginPath(),s.arc(e,t,n,0,Math.PI*2),s.fillStyle=i,s.fill(),s.lineWidth=1.5,s.strokeStyle="#fff",s.stroke(),s.fillStyle="#fff",s.font=`10px ${Ye}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function aa(s,e,t){if(t<=0)return"";if(s.measureText(e).width<=t)return e;let n=e.length;for(;n>1;){n--;const i=`${e.slice(0,n)}…`;if(s.measureText(i).width<=t)return i}return"…"}function di(s,e,t,n,i,o,a){const r=i>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(n-5,t),s.quadraticCurveTo(n,t,n,t+5*r),s.lineTo(n,i-5*r),s.quadraticCurveTo(n,i,n+5*r,i),s.lineTo(o,a),s.stroke()}function ra(s,e,t){s.fillStyle=Le.accent,s.beginPath(),s.moveTo(e+5,t),s.lineTo(e-1,t-3.5),s.lineTo(e-1,t+3.5),s.closePath(),s.fill()}const ci=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function _t(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return ci[e%ci.length]}const la={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应列宽",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多选筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"列显示",hideColumn:"隐藏此列",chooseColumns:"选择显示的列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",copy:"复制",copyWithHeaders:"复制(含表头)",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应宽度",expandAll:"展开全部",collapseAll:"收起全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"清除全部",join:"组合方式:",and:"且",or:"或",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",addCondition:"+ 添加条件",condTrue:"是",condFalse:"否",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"第",pageSize:"每页条数:",find:"在表格中查找…",matchCase:"区分大小写",of:"/",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity"};function da(s,e){const t=document.createElement("section");t.className="rowvia-gantt",t.innerHTML=`<div class="gantt-app">
28
28
  <header class="gantt-toolbar"><div class="gantt-title"><span class="gantt-title-name"></span><span class="gantt-title-sub">条件视图</span></div></header>
29
29
  <div class="gt-view-toolbar"><button class="gt-btn" data-action="filter">筛选</button><button class="gt-btn" data-action="sort">排序</button><span class="gt-toolbar-spacer"></span><span>甘特图</span><button class="gt-btn" data-action="settings" aria-label="甘特图设置" aria-expanded="false">设置</button></div>
30
30
  <div class="gt-quick"><input aria-label="搜索工作项" placeholder="搜索工作项" type="search"></div>
31
31
  <div class="gantt-body"><div class="gantt-left"><div class="grid ag-theme-quartz"></div></div><div class="gantt-right"></div></div>
32
32
  <div class="gantt-status" aria-live="polite"></div>
33
33
  <div class="gt-settings" hidden><div class="gt-settings-title">甘特条样式</div><label><input type="checkbox" data-setting="children" checked>甘特条显示子节点</label><label class="gt-indented"><input type="radio" name="nodes" value="all" checked>显示全部节点</label><label class="gt-indented"><input type="radio" name="nodes" value="milestones">显示里程碑节点</label><div class="gt-theme-options"><label><input type="radio" name="theme" value="content" checked>内容优先</label><label><input type="radio" name="theme" value="color">颜色优先</label></div></div>
34
- </div>`,s.append(t);const n=$e(t,"gantt",e),i=e.onTaskOpen?null:Zn(t),o=R=>t.querySelector(R);o(".gantt-title-name").textContent=e.title??"甘特图";let a=structuredClone(e.tasks),l=new Map(a.map(R=>[R.id,R])),r=null,d,c=!0,p=!1;const h=o(".gantt-left");h.style.width=`${e.tableWidth??280}px`;const u=new AbortController,f=u.signal,g=o(".gantt-status");function v(){if(!d||p)return;r!==a&&(y.setTasks(a),r=a);const R=Array.from({length:d.getDisplayedRowCount()},(M,$)=>d.getDisplayedRowAtIndex($)).filter(Boolean);y.setRows(R.map(M=>({id:M.id,group:!!M.group,expanded:!!M.expanded})));const O=a.filter(M=>M.path.length===1),L=O.filter(M=>M.status==="done").length;g.textContent=`总工作项数 ${O.length} 完成进度 ${O.length?Math.round(L/O.length*100):0}%`}function m(R){var M;a=a.map($=>$.id===R.id?{...R}:$),l=new Map(a.map($=>[$.id,$]));const O=[R];let L=R.path.slice(0,-1);for(;L.length;){const $=a.find(ae=>ae.path.join("/")===L.join("/"));if(!$)break;const _=a.filter(ae=>ae.path.length===L.length+1&&ae.path.slice(0,-1).join("/")===L.join("/")),U=_.flatMap(ae=>ae.start?[ae.start]:[]).sort(),ee=_.flatMap(ae=>ae.end?[ae.end]:[]).sort();$.start=U[0]??null,$.end=ee[ee.length-1]??null,O.push($),L=L.slice(0,-1)}d.applyTransaction({update:O}),v(),(M=e.onTaskChange)==null||M.call(e,structuredClone(R))}const y=new ni(o(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:R=>{var L;y.setSelected(R);const O=R?d==null?void 0:d.getRowNode(R):null;O&&((L=d.selectNode)==null||L.call(d,O,!0))},onHover:R=>{var O;t.querySelectorAll(".ag-row-hover").forEach(L=>L.classList.remove("ag-row-hover")),R&&((O=Array.from(t.querySelectorAll(".ag-row")).find(L=>L.dataset.rowid===R))==null||O.classList.add("ag-row-hover"))},onTaskChange:m,onAssign:(R,O)=>{const L=l.get(R);L&&m({...L,owner:O})}});function x(R){const O=R.data,L=document.createElement("span");if(L.className="gt-task-name",O.path.length>1?L.classList.add("gt-child-name"):R.node.group||L.classList.add("gt-root-leaf"),O.path.length>1){const $=document.createElement("span");$.className=`gt-node-dot gt-node-${O.status}`,L.append($)}const M=document.createElement("button");return M.className="gt-title-link",M.textContent=O.name,M.title=O.name,M.addEventListener("click",()=>{y.scrollToTask(O.id),e.onTaskOpen?e.onTaskOpen(structuredClone(O)):i==null||i.open({title:O.name,fields:[{label:"排期",value:`${O.start??"未设置"} — ${O.end??"未设置"}`}]})}),L.append(M),L}const C=document.createElement("button");C.className="gt-tree-toggle",C.textContent="▾",C.title="收起全部子层级",C.setAttribute("aria-label",C.title);function b(R){c=R,R?d.expandAll():d.collapseAll(),C.textContent=R?"▾":"▸",C.title=R?"收起全部子层级":"展开全部子层级",C.setAttribute("aria-label",C.title),v()}C.addEventListener("click",()=>b(!c));const I=["name","status","start","end","owner","progress"].map(R=>({field:R,hide:!0,filter:!0})),A=new lt(o(".grid"),{columnDefs:I,rowData:a,treeData:!0,getDataPath:R=>R.path,getRowId:R=>R.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:sa,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const R=document.createElement("div");return R.className="gt-title-header",R.append(C,document.createTextNode("标题")),R},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:x}},onGridReady:R=>{d=R.api,v()},onModelUpdated:R=>{d=R.api,v()},onRowGroupOpened:v,onRowClicked:R=>{var O;return y.setSelected(((O=R.node)==null?void 0:O.id)??null)}});d=A.getApi();const S=o(".ag-body-viewport");let G=!1;const E=(R,O)=>{G||(G=!0,O.scrollTop=R.scrollTop,G=!1)};S.addEventListener("scroll",()=>E(S,y.scrollElement),{signal:f}),y.scrollElement.addEventListener("scroll",()=>E(y.scrollElement,S),{signal:f}),S.addEventListener("mousemove",R=>{const O=R.target.closest(".ag-row");y.setHover((O==null?void 0:O.dataset.rowid)??null)},{signal:f}),S.addEventListener("mouseleave",()=>y.setHover(null),{signal:f});const k=new Xo(d,t,{filter:[{colId:"name",label:"标题",kind:"text"},{colId:"status",label:"状态",kind:"text",options:[{value:"not-started",label:"未开始"},{value:"in-progress",label:"进行中"},{value:"done",label:"已完成"}]},{colId:"start",label:"开始日期",kind:"date"}],sort:[{colId:"name",label:"标题"},{colId:"start",label:"开始日期"},{colId:"end",label:"结束日期"}]},{onFilterButton:R=>o('[data-action="filter"]').classList.toggle("gt-btn-active",R),onSortButton:R=>o('[data-action="sort"]').classList.toggle("gt-btn-active",R)});o('[data-action="filter"]').addEventListener("click",R=>k.openFilterPanel(R.currentTarget),{signal:f}),o('[data-action="sort"]').addEventListener("click",R=>k.openSortPanel(R.currentTarget),{signal:f}),o('[type="search"]').addEventListener("input",R=>d.setQuickFilter(R.target.value),{signal:f});const T=o(".gt-settings"),H=o('[data-action="settings"]');H.addEventListener("click",()=>{T.hidden=!T.hidden,H.setAttribute("aria-expanded",String(!T.hidden))},{signal:f}),document.addEventListener("pointerdown",R=>{!T.contains(R.target)&&!H.contains(R.target)&&(T.hidden=!0,H.setAttribute("aria-expanded","false"))},{signal:f});const W=Math.random().toString(36).slice(2);return T.querySelectorAll('[type="radio"]').forEach(R=>{const O=R.name;R.name=O+W,R.addEventListener("change",()=>{O==="theme"?y.setTheme(R.value):y.setMilestonesOnly(R.value==="milestones")},{signal:f})}),o('[data-setting="children"]').addEventListener("change",R=>y.setShowChildren(R.target.checked),{signal:f}),t.addEventListener("keydown",R=>{R.key==="Escape"&&(T.hidden=!0,k.closeAll())},{signal:f}),v(),e.unit&&y.setUnit(e.unit),y.scrollToToday(.5),{onInteraction:n.onInteraction,grid:d,chart:y,expandAll:()=>b(!0),collapseAll:()=>b(!1),scrollToTask:R=>y.scrollToTask(R),setTasks(R){a=structuredClone(R),l=new Map(a.map(O=>[O.id,O])),d.setRowData(a),v()},destroy(){p||(p=!0,u.abort(),k.destroy(),i==null||i.destroy(),y.destroy(),A.destroy(),n.destroy(),t.remove())}}}const ut={pending:{key:"pending",label:"未开始",className:"pending"},inProgress:{key:"inProgress",label:"进行中",className:"in-progress"},done:{key:"done",label:"已完成",className:"done"},failed:{key:"failed",label:"未通过",className:"failed"}},oi={auto:"自动完成",and:"单人确认(并签)",or:"多人确认(会签)"};function nn(s){const e=[{id:"owner",label:"已填写节点负责人",met:!!s.owner,fixLabel:"去填写",detail:"对应配置:节点字段必填 › 完成负责人"},{id:"schedule",label:"已填写排期与估分",met:!!(s.schedule&&s.estimate),fixLabel:"去填写",detail:s.milestone?"里程碑节点只需截止时间":"对应配置:节点字段必填 › 完成节点排期与估分"}];for(const t of s.form??[])t.required&&e.push({id:`form:${t.id}`,label:`节点表单「${t.label}」已填写`,met:!!(t.value&&String(t.value).trim()),fixLabel:"去填写",detail:"对应配置:完成表单"});for(const t of s.gates??[])e.push(t);return e}const ai=s=>s.every(e=>e.met);function ri(s){const e=s.nodes.length,t=s.nodes.filter(a=>a.status==="done").length,n=s.nodes.filter(a=>a.status==="failed").length,i=s.nodes.filter(a=>a.status==="inProgress").length,o=Math.max(1,s.nodes.findIndex(a=>a.status==="inProgress")+1);return{total:e,done:t,current:i,failed:n,index:o}}function aa(s,e){const t=s.filter(i=>i.groupId===e.id);return{done:t.filter(i=>i.status==="done").length,total:t.length}}function li(s){var t;const e=new Map;for(const n of s.groups)e.set(n.id,[]);for(const n of s.nodes){const i=n.groupId??((t=s.groups[0])==null?void 0:t.id);e.has(i)||e.set(i,[]),e.get(i).push(n)}return s.groups.map(n=>({group:n,nodes:e.get(n.id)??[]})).filter(n=>n.nodes.length>0)}function sn(s,e){const t=e.trim().toLowerCase();return t?new Set(s.nodes.filter(n=>n.name.toLowerCase().includes(t)).map(n=>n.id)):new Set(s.nodes.map(n=>n.id))}const ra=.4,la=1.8,di=.2;function ci(s,e){const t=document.createElement("div"),n=new je;t.className="rowvia-nf-canvas",t.innerHTML=`
34
+ </div>`,s.append(t);const n=De(t,"gantt",e),i=e.onTaskOpen?null:ii(t),o=R=>t.querySelector(R);o(".gantt-title-name").textContent=e.title??"甘特图";let a=structuredClone(e.tasks),l=new Map(a.map(R=>[R.id,R])),r=null,d,c=!0,p=!1;const h=o(".gantt-left");h.style.width=`${e.tableWidth??280}px`;const u=new AbortController,f=u.signal,g=o(".gantt-status");function v(){if(!d||p)return;r!==a&&(w.setTasks(a),r=a);const R=Array.from({length:d.getDisplayedRowCount()},(M,$)=>d.getDisplayedRowAtIndex($)).filter(Boolean);w.setRows(R.map(M=>({id:M.id,group:!!M.group,expanded:!!M.expanded})));const P=a.filter(M=>M.path.length===1),L=P.filter(M=>M.status==="done").length;g.textContent=`总工作项数 ${P.length} 完成进度 ${P.length?Math.round(L/P.length*100):0}%`}function m(R){var M;a=a.map($=>$.id===R.id?{...R}:$),l=new Map(a.map($=>[$.id,$]));const P=[R];let L=R.path.slice(0,-1);for(;L.length;){const $=a.find(ue=>ue.path.join("/")===L.join("/"));if(!$)break;const z=a.filter(ue=>ue.path.length===L.length+1&&ue.path.slice(0,-1).join("/")===L.join("/")),j=z.flatMap(ue=>ue.start?[ue.start]:[]).sort(),te=z.flatMap(ue=>ue.end?[ue.end]:[]).sort();$.start=j[0]??null,$.end=te[te.length-1]??null,P.push($),L=L.slice(0,-1)}d.applyTransaction({update:P}),v(),(M=e.onTaskChange)==null||M.call(e,structuredClone(R))}const w=new li(o(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:R=>{var L;w.setSelected(R);const P=R?d==null?void 0:d.getRowNode(R):null;P&&((L=d.selectNode)==null||L.call(d,P,!0))},onHover:R=>{var P;t.querySelectorAll(".ag-row-hover").forEach(L=>L.classList.remove("ag-row-hover")),R&&((P=Array.from(t.querySelectorAll(".ag-row")).find(L=>L.dataset.rowid===R))==null||P.classList.add("ag-row-hover"))},onTaskChange:m,onAssign:(R,P)=>{const L=l.get(R);L&&m({...L,owner:P})}});function k(R){const P=R.data,L=document.createElement("span");if(L.className="gt-task-name",P.path.length>1?L.classList.add("gt-child-name"):R.node.group||L.classList.add("gt-root-leaf"),P.path.length>1){const $=document.createElement("span");$.className=`gt-node-dot gt-node-${P.status}`,L.append($)}const M=document.createElement("button");return M.className="gt-title-link",M.textContent=P.name,M.title=P.name,M.addEventListener("click",()=>{w.scrollToTask(P.id),e.onTaskOpen?e.onTaskOpen(structuredClone(P)):i==null||i.open({title:P.name,fields:[{label:"排期",value:`${P.start??"未设置"} — ${P.end??"未设置"}`}]})}),L.append(M),L}const C=document.createElement("button");C.className="gt-tree-toggle",C.textContent="▾",C.title="收起全部子层级",C.setAttribute("aria-label",C.title);function b(R){c=R,R?d.expandAll():d.collapseAll(),C.textContent=R?"▾":"▸",C.title=R?"收起全部子层级":"展开全部子层级",C.setAttribute("aria-label",C.title),v()}C.addEventListener("click",()=>b(!c));const N=["name","status","start","end","owner","progress"].map(R=>({field:R,hide:!0,filter:!0})),I=new ht(o(".grid"),{columnDefs:N,rowData:a,treeData:!0,getDataPath:R=>R.path,getRowId:R=>R.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:la,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const R=document.createElement("div");return R.className="gt-title-header",R.append(C,document.createTextNode("标题")),R},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:k}},onGridReady:R=>{d=R.api,v()},onModelUpdated:R=>{d=R.api,v()},onRowGroupOpened:v,onRowClicked:R=>{var P;return w.setSelected(((P=R.node)==null?void 0:P.id)??null)}});d=I.getApi();const E=o(".ag-body-viewport");let G=!1;const x=(R,P)=>{G||(G=!0,P.scrollTop=R.scrollTop,G=!1)};E.addEventListener("scroll",()=>x(E,w.scrollElement),{signal:f}),w.scrollElement.addEventListener("scroll",()=>x(w.scrollElement,E),{signal:f}),E.addEventListener("mousemove",R=>{const P=R.target.closest(".ag-row");w.setHover((P==null?void 0:P.dataset.rowid)??null)},{signal:f}),E.addEventListener("mouseleave",()=>w.setHover(null),{signal:f});const T=new ea(d,t,{filter:[{colId:"name",label:"标题",kind:"text"},{colId:"status",label:"状态",kind:"text",options:[{value:"not-started",label:"未开始"},{value:"in-progress",label:"进行中"},{value:"done",label:"已完成"}]},{colId:"start",label:"开始日期",kind:"date"}],sort:[{colId:"name",label:"标题"},{colId:"start",label:"开始日期"},{colId:"end",label:"结束日期"}]},{onFilterButton:R=>o('[data-action="filter"]').classList.toggle("gt-btn-active",R),onSortButton:R=>o('[data-action="sort"]').classList.toggle("gt-btn-active",R)});o('[data-action="filter"]').addEventListener("click",R=>T.openFilterPanel(R.currentTarget),{signal:f}),o('[data-action="sort"]').addEventListener("click",R=>T.openSortPanel(R.currentTarget),{signal:f}),o('[type="search"]').addEventListener("input",R=>d.setQuickFilter(R.target.value),{signal:f});const A=o(".gt-settings"),H=o('[data-action="settings"]');H.addEventListener("click",()=>{A.hidden=!A.hidden,H.setAttribute("aria-expanded",String(!A.hidden))},{signal:f}),document.addEventListener("pointerdown",R=>{!A.contains(R.target)&&!H.contains(R.target)&&(A.hidden=!0,H.setAttribute("aria-expanded","false"))},{signal:f});const q=Math.random().toString(36).slice(2);return A.querySelectorAll('[type="radio"]').forEach(R=>{const P=R.name;R.name=P+q,R.addEventListener("change",()=>{P==="theme"?w.setTheme(R.value):w.setMilestonesOnly(R.value==="milestones")},{signal:f})}),o('[data-setting="children"]').addEventListener("change",R=>w.setShowChildren(R.target.checked),{signal:f}),t.addEventListener("keydown",R=>{R.key==="Escape"&&(A.hidden=!0,T.closeAll())},{signal:f}),v(),e.unit&&w.setUnit(e.unit),w.scrollToToday(.5),{onInteraction:n.onInteraction,grid:d,chart:w,expandAll:()=>b(!0),collapseAll:()=>b(!1),scrollToTask:R=>w.scrollToTask(R),setTasks(R){a=structuredClone(R),l=new Map(a.map(P=>[P.id,P])),d.setRowData(a),v()},destroy(){p||(p=!0,u.abort(),T.destroy(),i==null||i.destroy(),w.destroy(),I.destroy(),n.destroy(),t.remove())}}}const gt={pending:{key:"pending",label:"未开始",className:"pending"},inProgress:{key:"inProgress",label:"进行中",className:"in-progress"},done:{key:"done",label:"已完成",className:"done"},failed:{key:"failed",label:"未通过",className:"failed"}},ui={auto:"自动完成",and:"单人确认(并签)",or:"多人确认(会签)"};function rn(s){const e=[{id:"owner",label:"已填写节点负责人",met:!!s.owner,fixLabel:"去填写",detail:"对应配置:节点字段必填 › 完成负责人"},{id:"schedule",label:"已填写排期与估分",met:!!(s.schedule&&s.estimate),fixLabel:"去填写",detail:s.milestone?"里程碑节点只需截止时间":"对应配置:节点字段必填 › 完成节点排期与估分"}];for(const t of s.form??[])t.required&&e.push({id:`form:${t.id}`,label:`节点表单「${t.label}」已填写`,met:!!(t.value&&String(t.value).trim()),fixLabel:"去填写",detail:"对应配置:完成表单"});for(const t of s.gates??[])e.push(t);return e}const hi=s=>s.every(e=>e.met);function pi(s){const e=s.nodes.length,t=s.nodes.filter(a=>a.status==="done").length,n=s.nodes.filter(a=>a.status==="failed").length,i=s.nodes.filter(a=>a.status==="inProgress").length,o=Math.max(1,s.nodes.findIndex(a=>a.status==="inProgress")+1);return{total:e,done:t,current:i,failed:n,index:o}}function ca(s,e){const t=s.filter(i=>i.groupId===e.id);return{done:t.filter(i=>i.status==="done").length,total:t.length}}function fi(s){var t;const e=new Map;for(const n of s.groups)e.set(n.id,[]);for(const n of s.nodes){const i=n.groupId??((t=s.groups[0])==null?void 0:t.id);e.has(i)||e.set(i,[]),e.get(i).push(n)}return s.groups.map(n=>({group:n,nodes:e.get(n.id)??[]})).filter(n=>n.nodes.length>0)}function ln(s,e){const t=e.trim().toLowerCase();return t?new Set(s.nodes.filter(n=>n.name.toLowerCase().includes(t)).map(n=>n.id)):new Set(s.nodes.map(n=>n.id))}const ua=.4,ha=1.8,gi=.2;function mi(s,e){const t=document.createElement("div"),n=new Ke;t.className="rowvia-nf-canvas",t.innerHTML=`
35
35
  <div class="rowvia-nf-canvas-toolbar">
36
36
  <span class="rowvia-nf-legend" data-legend></span>
37
37
  <span class="rowvia-nf-space"></span>
@@ -44,31 +44,31 @@ ${m}
44
44
  <div class="rowvia-nf-canvas-sizer" data-sizer>
45
45
  <div class="rowvia-nf-canvas-surface" data-surface></div>
46
46
  </div>
47
- </div>`,s.append(t);const i=$e(t,"flow-canvas",e),o=t.querySelector("[data-viewport]"),a=t.querySelector("[data-sizer]"),l=t.querySelector("[data-surface]"),r=t.querySelector("[data-zoom]"),d=t.querySelector("[data-legend]");let c=e.flow,p=e.selectedNodeId,h=e.query??"",u=1;const f=(E,k,T)=>{if(E.hiddenReason)return`<span class="rowvia-nf-node is-hidden" title="${D(E.hiddenReason)}">
48
- <span class="rowvia-nf-node-name">${D(E.name)}</span>
49
- <span class="rowvia-nf-node-note">未显示 · ${D(E.hiddenReason)}</span>
50
- </span>`;const H=ut[E.status],W=T==="right"&&E.info?`<span class="rowvia-nf-node-info">${D(E.info)}</span>`:"",R=T!=="none"&&(E.progress!==void 0||E.delayed)?[`
47
+ </div>`,s.append(t);const i=De(t,"flow-canvas",e),o=t.querySelector("[data-viewport]"),a=t.querySelector("[data-sizer]"),l=t.querySelector("[data-surface]"),r=t.querySelector("[data-zoom]"),d=t.querySelector("[data-legend]");let c=e.flow,p=e.selectedNodeId,h=e.query??"",u=1;const f=(x,T,A)=>{if(x.hiddenReason)return`<span class="rowvia-nf-node is-hidden" title="${D(x.hiddenReason)}">
48
+ <span class="rowvia-nf-node-name">${D(x.name)}</span>
49
+ <span class="rowvia-nf-node-note">未显示 · ${D(x.hiddenReason)}</span>
50
+ </span>`;const H=gt[x.status],q=A==="right"&&x.info?`<span class="rowvia-nf-node-info">${D(x.info)}</span>`:"",R=A!=="none"&&(x.progress!==void 0||x.delayed)?[`
51
51
  <span class="rowvia-nf-node-sub">
52
- ${E.progress!==void 0?`<span class="rowvia-nf-progress"><i style="width:${E.progress}%"></i></span>${E.progress}%`:""}
53
- ${E.delayed?'<em class="rowvia-nf-delay">延期</em>':""}
52
+ ${x.progress!==void 0?`<span class="rowvia-nf-progress"><i style="width:${x.progress}%"></i></span>${x.progress}%`:""}
53
+ ${x.delayed?'<em class="rowvia-nf-delay">延期</em>':""}
54
54
  </span>`].join(""):"";return`<button type="button"
55
- class="rowvia-nf-node status-${H.className} ${p===E.id?"is-selected":""} ${k?"is-dimmed":""} ${E.milestone?"is-milestone":""}"
56
- data-node-id="${D(E.id)}"
57
- aria-pressed="${p===E.id}"
58
- title="${D(E.name)} · ${D(H.label)}${E.milestone?" · 里程碑":""}">
55
+ class="rowvia-nf-node status-${H.className} ${p===x.id?"is-selected":""} ${T?"is-dimmed":""} ${x.milestone?"is-milestone":""}"
56
+ data-node-id="${D(x.id)}"
57
+ aria-pressed="${p===x.id}"
58
+ title="${D(x.name)} · ${D(H.label)}${x.milestone?" · 里程碑":""}">
59
59
  <span class="rowvia-nf-node-dot" aria-hidden="true"></span>
60
- <span class="rowvia-nf-node-name">${D(E.name)}</span>
61
- ${E.milestone?'<span class="rowvia-nf-node-flag" title="里程碑:仅可填写截止时间">◆</span>':""}
62
- ${W}
60
+ <span class="rowvia-nf-node-name">${D(x.name)}</span>
61
+ ${x.milestone?'<span class="rowvia-nf-node-flag" title="里程碑:仅可填写截止时间">◆</span>':""}
62
+ ${q}
63
63
  ${R}
64
- </button>`},g=()=>{var T;const E=sn(c,h),k=((T=c.infoField)==null?void 0:T.position)??"none";d.textContent=c.infoField?`显示:${c.infoField.label} · 位置:${k==="right"?"右侧":k==="below"?"下方":"不显示"}`:"未配置流程图展示信息",l.innerHTML=li(c).map(({group:H,nodes:W})=>{const R=aa(c.nodes,H),O=H.layout==="parallel",L=W.map((_,U)=>{const ee=f(_,!E.has(_.id),k);return O?ee:`${U?'<i class="rowvia-nf-edge" aria-hidden="true"></i>':""}${ee}`}).join(""),M=c.groups[c.groups.indexOf(H)+1],$=O?`<div class="rowvia-nf-fan"><span>并行 ${W.length} 路</span><span>全部完成 → ${D((M==null?void 0:M.name)??"结束")}</span></div>`:"";return`<section class="rowvia-nf-group" data-group="${D(H.id)}">
64
+ </button>`},g=()=>{var A;const x=ln(c,h),T=((A=c.infoField)==null?void 0:A.position)??"none";d.textContent=c.infoField?`显示:${c.infoField.label} · 位置:${T==="right"?"右侧":T==="below"?"下方":"不显示"}`:"未配置流程图展示信息",l.innerHTML=fi(c).map(({group:H,nodes:q})=>{const R=ca(c.nodes,H),P=H.layout==="parallel",L=q.map((z,j)=>{const te=f(z,!x.has(z.id),T);return P?te:`${j?'<i class="rowvia-nf-edge" aria-hidden="true"></i>':""}${te}`}).join(""),M=c.groups[c.groups.indexOf(H)+1],$=P?`<div class="rowvia-nf-fan"><span>并行 ${q.length} 路</span><span>全部完成 → ${D((M==null?void 0:M.name)??"结束")}</span></div>`:"";return`<section class="rowvia-nf-group" data-group="${D(H.id)}">
65
65
  <header class="rowvia-nf-group-head">
66
66
  <strong>${D(H.name)}</strong>
67
67
  <em>${R.done}/${R.total}</em>
68
68
  </header>
69
- <div class="rowvia-nf-lane ${O?"is-parallel":"is-sequence"}">${L}</div>
69
+ <div class="rowvia-nf-lane ${P?"is-parallel":"is-sequence"}">${L}</div>
70
70
  ${$}
71
- </section>`}).join(""),v()},v=()=>{l.style.transform=`scale(${u})`,r.textContent=`${Math.round(u*100)}%`,a.style.width=`${l.scrollWidth*u}px`,a.style.height=`${l.scrollHeight*u}px`},m=E=>{var k;u=Math.min(la,Math.max(ra,Math.round(E*100)/100)),v(),(k=e.onZoomChange)==null||k.call(e,u)},y=()=>{const E=l.scrollWidth||1,k=o.clientWidth-8;m(k/E),o.scrollTo({left:0,top:0})},x=E=>{var T;const k=E.target.closest("[data-node-id],[data-action]");if(!(!k||!t.contains(k))){if(k.dataset.nodeId){(T=e.onSelectNode)==null||T.call(e,k.dataset.nodeId);return}k.dataset.action==="fit"&&y(),k.dataset.action==="zoom-in"&&m(u+di),k.dataset.action==="zoom-out"&&m(u-di)}};t.addEventListener("click",x);const C=E=>{!E.ctrlKey&&!E.metaKey||(E.preventDefault(),m(u+(E.deltaY<0?.1:-.1)))};o.addEventListener("wheel",C,{passive:!1});let b=null;const I=E=>{E.target.closest("button")||(b={x:E.clientX,y:E.clientY,left:o.scrollLeft,top:o.scrollTop},o.setPointerCapture(E.pointerId),o.classList.add("is-panning"))},A=E=>{b&&(o.scrollLeft=b.left-(E.clientX-b.x),o.scrollTop=b.top-(E.clientY-b.y))},S=()=>{b=null,o.classList.remove("is-panning")};o.addEventListener("pointerdown",I),o.addEventListener("pointermove",A),o.addEventListener("pointerup",S),o.addEventListener("pointercancel",S);const G=typeof ResizeObserver<"u"?new ResizeObserver(v):null;return G==null||G.observe(o),g(),{onInteraction:i.onInteraction,update(E){const k=E.flow!==void 0||E.hiddenHints!==void 0;if(E.flow&&(c=E.flow),E.selectedNodeId!==void 0&&(p=E.selectedNodeId),E.query!==void 0&&(h=E.query),E.hiddenHints&&(e.hiddenHints=E.hiddenHints),E.onZoomChange!==void 0&&(e.onZoomChange=E.onZoomChange),E.onSelectNode!==void 0&&(e.onSelectNode=E.onSelectNode),k)g();else{const T=sn(c,h);for(const H of l.querySelectorAll("[data-node-id]")){const W=H.dataset.nodeId===p;H.classList.toggle("is-selected",W),H.classList.toggle("is-dimmed",!T.has(H.dataset.nodeId)),H.setAttribute("aria-pressed",String(W))}}},focusNode(E){const k=Array.from(l.querySelectorAll("[data-node-id]")).find(T=>T.dataset.nodeId===E);k==null||k.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}),k==null||k.classList.add("is-pulsing"),n.timeout(()=>k==null?void 0:k.classList.remove("is-pulsing"),900)},fit:y,getZoom:()=>u,destroy(){G==null||G.disconnect(),t.removeEventListener("click",x),o.removeEventListener("wheel",C),i.destroy(),n.destroy(),t.remove()}}}function da(s){const e=[{id:"schedule",label:"总排期",value:s.schedule,source:"系统字段 · 排期",permission:"节点负责人、管理员"},{id:"estimate",label:"估分",value:s.estimate,source:"系统字段 · 估分",permission:"节点负责人、管理员"},{id:"worklog",label:"实际工时",value:s.worklog??"—",source:"系统字段 · 实际工时"}],t=s.progress!==void 0?[{id:"progress",label:"进度",value:s.progress+"%",percent:s.progress,writeMode:s.progressMode,group:"progress",source:"节点进度"}]:[],n=[{id:"conclusion",label:"整体完成结论",value:s.conclusion,source:"节点完成结论与意见",permission:"独立填写或按负责人结论汇总"},{id:"opinion",label:"整体完成意见",value:s.opinion,source:"节点完成结论与意见"}],i=(s.fields??[]).filter(a=>a.group!=="schedule");return[{key:"schedule",title:"排期与工作量",fields:e},{key:"progress",title:"进度",fields:t},{key:"conclusion",title:"结论与意见",fields:n},{key:"custom",title:"自定义字段",fields:i}].filter(a=>a.fields.length>0)}function ca(s,e,t){var a;const n=!t&&!e.readonly,i=[];e.group==="progress"?(i.push('<span class="rowvia-nf-progress is-large"><i style="width:'+(e.percent??0)+'%"></i></span>',"<b>"+D(e.value)+"</b>"),e.writeMode&&i.push('<em class="rowvia-nf-mode">'+D(e.writeMode)+"</em>")):n&&e.id==="conclusion"&&((a=s.conclusionOptions)!=null&&a.length)?i.push('<select data-field="'+D(e.id)+'" aria-label="'+D(e.label)+'"><option value="">请选择</option>'+s.conclusionOptions.map(l=>"<option"+(l===e.value?" selected":"")+">"+D(l)+"</option>").join("")+"</select>"):n?i.push('<input data-field="'+D(e.id)+'" value="'+D(e.value??"")+'" placeholder="待填" aria-label="'+D(e.label)+'">'):i.push('<span class="rowvia-nf-value'+(e.value?"":" is-empty")+'">'+D(e.value||"待填")+"</span>");const o=[e.source,e.permission?"可编辑:"+e.permission:""].filter(Boolean).join(" · ");return'<div class="rowvia-nf-field"><label>'+D(e.label)+'</label><div class="rowvia-nf-field-control">'+i.join("")+'</div><button type="button" class="rowvia-nf-info" data-info="'+D(o)+'" aria-label="字段来源">ⓘ</button></div>'}function ua(s){const e=s.filter(n=>n.met).length,t=s.map(n=>{const i=n.met?"":'<button type="button" class="rowvia-nf-fix" data-'+(n.viewLink?'gate-view="'+D(n.id)+'"':'gate-fix="'+D(n.id)+'"')+">"+D(n.fixLabel??"去填写")+"</button>";return'<li class="'+(n.met?"is-met":"is-unmet")+'"><i aria-hidden="true">'+(n.met?"✓":"✕")+"</i><span>"+D(n.label)+(n.detail?"<small>"+D(n.detail)+"</small>":"")+"</span>"+i+"</li>"}).join("");return'<section class="rowvia-nf-gates" data-gates><h4>完成前需满足 <em>'+e+"/"+s.length+"</em></h4><ul>"+t+"</ul></section>"}function ha(s,e){const t=s.tasks??[],n=e?"":'<button type="button" class="rowvia-nf-link" data-action="add-task">+ 新增任务</button>';if(!t.length)return'<section class="rowvia-nf-tasks is-empty"><h4>全部任务 (0/0)</h4><p>暂无子任务'+(e?"":'<button type="button" data-action="add-task">+ 新增任务</button>')+"</p></section>";const i=t.filter(a=>a.done).length,o=t.map(a=>{const l=a.deliverable?'<span class="rowvia-nf-deliverable">📎 '+D(a.deliverable)+"</span>":'<span class="rowvia-nf-value is-empty">暂无</span>';return'<tr class="'+(a.done?"is-done":"")+'"><td><label class="rowvia-nf-check"><input type="checkbox" data-task="'+D(a.id)+'"'+(a.done?" checked":"")+(e?" disabled":"")+"><span>"+D(a.name)+"</span></label>"+(a.blocking?'<em class="rowvia-nf-blocker" title="未完成前主节点无法流转">阻塞项</em>':"")+"</td><td>"+l+"</td><td>"+D(a.owner||"暂无")+"</td><td>"+D(a.estimate||"暂无")+"</td><td>"+D(a.schedule||"暂无")+"</td></tr>"}).join("");return'<section class="rowvia-nf-tasks"><h4>全部任务 ('+i+"/"+t.length+")"+n+"</h4><table><thead><tr><th>名称</th><th>交付物</th><th>当前负责人</th><th>估分</th><th>排期</th></tr></thead><tbody>"+o+"</tbody></table></section>"}function pa(s,e){const t=s.form??[];if(!t.length)return"";const n=t.filter(r=>r.required).length,i=t.filter(r=>r.required&&!r.value).length,o=t.map(r=>{var c;let d;return!e&&r.type==="select"&&((c=r.options)!=null&&c.length)?d='<select data-form="'+D(r.id)+'" aria-label="'+D(r.label)+'"><option value="">请选择</option>'+r.options.map(p=>"<option"+(p===r.value?" selected":"")+">"+D(p)+"</option>").join("")+"</select>":!e&&r.type==="date"?d='<input type="date" data-form="'+D(r.id)+'" value="'+D(r.value??"")+'" aria-label="'+D(r.label)+'">':e?d='<span class="rowvia-nf-value'+(r.value?"":" is-empty")+'">'+D(r.value||"待填")+"</span>":d='<input data-form="'+D(r.id)+'" value="'+D(r.value??"")+'" placeholder="'+D(r.placeholder??"待填")+'" aria-label="'+D(r.label)+'">','<div class="rowvia-nf-form-row"><label>'+D(r.label)+(r.required?"<b>*</b>":"")+'</label><div class="rowvia-nf-field-control">'+d+"</div></div>"}).join(""),a=i?'<em class="rowvia-nf-warn">'+i+" 项必填未完成</em>":"",l="节点表单 · "+t.length+" 项"+(n?"("+n+" 必填)":"")+a;return'<section class="rowvia-nf-form'+(i?" has-pending":"")+'"><h4>'+l+"</h4>"+o+"</section>"}function fa(s){const e=s.events??[];if(!e.length)return"";const t=(o,a)=>a.length?"<span><b>"+o+"</b>"+a.map(l=>D(l.text)).join(";")+"</span>":"",n=e.filter(o=>o.trigger==="arrive"),i=e.filter(o=>o.trigger==="complete");return'<section class="rowvia-nf-events"><details><summary>ℹ 节点事件('+e.length+' 条规则已生效)</summary><div class="rowvia-nf-events-body">'+t("到达本节点时:",n)+t("完成本节点时:",i)+"<p>事件规则由流程模板配置,回滚节点至到达/完成之前的状态可解除限制。</p></div></details></section>"}function ui(s,e){const t=document.createElement("div"),n=new je;t.className="rowvia-nf-card",s.append(t);const i=$e(t,"node-card",e);let o=e.node??null,a={...e},l=!1;const r=()=>{var E;if(!o){t.innerHTML='<div class="rowvia-nf-empty">在上方流程画布中选择一个节点,查看它的字段、表单与通行条件。</div>';return}const h=!!a.readonly,u=ut[o.status],f=nn(o),g=o.completionMode?oi[o.completionMode]:"",v=da(o),m=(o.buttons??[]).filter(k=>(k.placement??"inline")==="inline"),y=(o.buttons??[]).filter(k=>k.placement==="more"),x=(k,T,H="")=>'<span class="rowvia-nf-chip '+T+'"'+(H?' title="'+D(H)+'"':"")+">"+D(k)+"</span>",C=(k,T,H,W="",R=!1)=>'<button type="button" class="rowvia-nf-btn '+H+'" data-action="'+D(k)+'"'+(W?' title="'+D(W)+'"':"")+(R?" disabled":"")+">"+D(T)+"</button>",b=[];if(!h){o.status==="inProgress"&&b.push(C("complete","完成","is-primary")),o.status==="failed"&&b.push(C("resubmit","重新提交","is-primary")),(o.status==="done"||o.status==="failed")&&b.push(C("rollback","回滚","is-ghost","将节点状态回退至进行中")),b.push(C("transfer","转办","is-ghost","将负责人转交他人"));for(const k of m){const T=[k.hint,(E=k.roles)!=null&&E.length?"授权:"+k.roles.join("、"):""].filter(Boolean).join(" · "),H=k.variant==="primary"?"is-primary":k.variant==="warning"?"is-warning":"is-ghost";b.push(C("custom:"+k.id,k.label,H,T))}b.push('<button type="button" class="rowvia-nf-btn is-icon" data-action="more" aria-haspopup="menu" aria-expanded="'+String(l)+'">···</button>')}const I='<span class="rowvia-nf-owner">负责人 '+D(o.owner||"待填")+(o.ownerSource?"<em>"+D(o.ownerSource)+"</em>":"")+"</span>",A='<div class="rowvia-nf-menu" data-menu'+(l?"":" hidden")+' role="menu"><button type="button" role="menuitem" data-action="estimate">填写估分</button><button type="button" role="menuitem" data-action="group-chat">节点建群</button>'+y.map(k=>'<button type="button" role="menuitem" data-action="custom:'+D(k.id)+'">'+D(k.label)+"</button>").join("")+'<button type="button" role="menuitem" class="is-danger" data-action="delete-node"'+(o.deleteRoles?' title="允许删除:'+D(o.deleteRoles.join("、"))+'"':"")+">删除节点</button></div>",S='<header class="rowvia-nf-card-head"><span class="rowvia-nf-dot status-'+u.className+'" aria-hidden="true"></span><h3>'+D(o.name)+"</h3>"+x(u.label,"status-"+u.className)+(g?x(g,"is-mode","对应配置:完成方式"):"")+(o.milestone?x("◆ 里程碑"+(o.deadline?" · "+o.deadline:""),"is-milestone","里程碑:仅可填写截止时间"):"")+I+'<span class="rowvia-nf-space"></span><div class="rowvia-nf-actions">'+b.join("")+"</div>"+A+"</header>",G=v.map(k=>'<div class="rowvia-nf-field-group" data-section="'+k.key+'"><h5>'+D(k.title)+"</h5>"+k.fields.map(T=>ca(o,T,h)).join("")+"</div>").join("");t.innerHTML=S+ua(f)+'<details class="rowvia-nf-section" open><summary>节点字段 <em>'+v.length+" 组</em></summary>"+G+"</details>"+pa(o,h)+ha(o,h)+fa(o)},d=h=>{var g,v,m,y,x;const u=h.target.closest("[data-action],[data-gate-fix],[data-gate-view],[data-info]");if(!u||!t.contains(u))return;if(u.dataset.info){n.add(hi(u,u.dataset.info));return}if(u.dataset.gateFix||u.dataset.gateView){p(),(g=a.onAction)==null||g.call(a,u.dataset.gateView?"open-gate-view":"fix-gate",(o==null?void 0:o.id)??"");return}const f=u.dataset.action;if(f){if(f==="more"){const C=t.querySelector("[data-menu]");if(!C)return;l=C.hidden,C.hidden=!l,u.setAttribute("aria-expanded",String(l));return}if(f==="complete"){const C=o?nn(o):[];if(!ai(C)){p(),(v=a.onAction)==null||v.call(a,"complete-blocked",(o==null?void 0:o.id)??"");return}if(((m=a.onComplete)==null?void 0:m.call(a,(o==null?void 0:o.id)??"",C))===!1)return;(y=a.onAction)==null||y.call(a,"complete",(o==null?void 0:o.id)??"");return}(x=a.onAction)==null||x.call(a,f,(o==null?void 0:o.id)??"")}},c=h=>{var f,g,v,m,y;const u=h.target;if(u instanceof HTMLInputElement){u.dataset.task?(f=a.onTaskToggle)==null||f.call(a,(o==null?void 0:o.id)??"",u.dataset.task,u.checked):u.dataset.field?(g=a.onFieldChange)==null||g.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((v=a.onFormChange)==null||v.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value));return}u instanceof HTMLSelectElement&&(u.dataset.field?(m=a.onFieldChange)==null||m.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((y=a.onFormChange)==null||y.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value)))};function p(){const h=t.querySelector(".rowvia-nf-gates");h&&(h.classList.add("is-shaking"),n.timeout(()=>h.classList.remove("is-shaking"),700))}return t.addEventListener("click",d),t.addEventListener("change",c),r(),{onInteraction:i.onInteraction,update(h,u){o=h,u&&(a={...a,...u}),r()},destroy(){t.removeEventListener("click",d),t.removeEventListener("change",c),i.destroy(),n.destroy(),t.remove()}}}function hi(s,e){const t=document.createElement("div");t.className="rowvia-nf-tip",t.textContent=e,document.body.append(t);const n=s.getBoundingClientRect();t.style.left=Math.max(8,Math.min(window.innerWidth-260,n.left))+"px",t.style.top=n.bottom+6+"px";const i=window.setTimeout(()=>t.remove(),2600);return()=>{window.clearTimeout(i),t.remove()}}function pi(s,e){const t=document.createElement("div"),n=new je;t.className="rowvia-nf-contextbar",s.append(t);const i=$e(t,"flow-context",e);let o=e.flow,a=e.query??"",l=!1;const r=()=>{const c=ri(o),p=!!(o.templateVersion&&o.latestTemplateVersion&&o.templateVersion!==o.latestTemplateVersion);t.innerHTML=`
71
+ </section>`}).join(""),v()},v=()=>{l.style.transform=`scale(${u})`,r.textContent=`${Math.round(u*100)}%`,a.style.width=`${l.scrollWidth*u}px`,a.style.height=`${l.scrollHeight*u}px`},m=x=>{var T;u=Math.min(ha,Math.max(ua,Math.round(x*100)/100)),v(),(T=e.onZoomChange)==null||T.call(e,u)},w=()=>{const x=l.scrollWidth||1,T=o.clientWidth-8;m(T/x),o.scrollTo({left:0,top:0})},k=x=>{var A;const T=x.target.closest("[data-node-id],[data-action]");if(!(!T||!t.contains(T))){if(T.dataset.nodeId){(A=e.onSelectNode)==null||A.call(e,T.dataset.nodeId);return}T.dataset.action==="fit"&&w(),T.dataset.action==="zoom-in"&&m(u+gi),T.dataset.action==="zoom-out"&&m(u-gi)}};t.addEventListener("click",k);const C=x=>{!x.ctrlKey&&!x.metaKey||(x.preventDefault(),m(u+(x.deltaY<0?.1:-.1)))};o.addEventListener("wheel",C,{passive:!1});let b=null;const N=x=>{x.target.closest("button")||(b={x:x.clientX,y:x.clientY,left:o.scrollLeft,top:o.scrollTop},o.setPointerCapture(x.pointerId),o.classList.add("is-panning"))},I=x=>{b&&(o.scrollLeft=b.left-(x.clientX-b.x),o.scrollTop=b.top-(x.clientY-b.y))},E=()=>{b=null,o.classList.remove("is-panning")};o.addEventListener("pointerdown",N),o.addEventListener("pointermove",I),o.addEventListener("pointerup",E),o.addEventListener("pointercancel",E);const G=typeof ResizeObserver<"u"?new ResizeObserver(v):null;return G==null||G.observe(o),g(),{onInteraction:i.onInteraction,update(x){const T=x.flow!==void 0||x.hiddenHints!==void 0;if(x.flow&&(c=x.flow),x.selectedNodeId!==void 0&&(p=x.selectedNodeId),x.query!==void 0&&(h=x.query),x.hiddenHints&&(e.hiddenHints=x.hiddenHints),x.onZoomChange!==void 0&&(e.onZoomChange=x.onZoomChange),x.onSelectNode!==void 0&&(e.onSelectNode=x.onSelectNode),T)g();else{const A=ln(c,h);for(const H of l.querySelectorAll("[data-node-id]")){const q=H.dataset.nodeId===p;H.classList.toggle("is-selected",q),H.classList.toggle("is-dimmed",!A.has(H.dataset.nodeId)),H.setAttribute("aria-pressed",String(q))}}},focusNode(x){const T=Array.from(l.querySelectorAll("[data-node-id]")).find(A=>A.dataset.nodeId===x);T==null||T.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}),T==null||T.classList.add("is-pulsing"),n.timeout(()=>T==null?void 0:T.classList.remove("is-pulsing"),900)},fit:w,getZoom:()=>u,destroy(){G==null||G.disconnect(),t.removeEventListener("click",k),o.removeEventListener("wheel",C),i.destroy(),n.destroy(),t.remove()}}}function pa(s){const e=[{id:"schedule",label:"总排期",value:s.schedule,source:"系统字段 · 排期",permission:"节点负责人、管理员"},{id:"estimate",label:"估分",value:s.estimate,source:"系统字段 · 估分",permission:"节点负责人、管理员"},{id:"worklog",label:"实际工时",value:s.worklog??"—",source:"系统字段 · 实际工时"}],t=s.progress!==void 0?[{id:"progress",label:"进度",value:s.progress+"%",percent:s.progress,writeMode:s.progressMode,group:"progress",source:"节点进度"}]:[],n=[{id:"conclusion",label:"整体完成结论",value:s.conclusion,source:"节点完成结论与意见",permission:"独立填写或按负责人结论汇总"},{id:"opinion",label:"整体完成意见",value:s.opinion,source:"节点完成结论与意见"}],i=(s.fields??[]).filter(a=>a.group!=="schedule");return[{key:"schedule",title:"排期与工作量",fields:e},{key:"progress",title:"进度",fields:t},{key:"conclusion",title:"结论与意见",fields:n},{key:"custom",title:"自定义字段",fields:i}].filter(a=>a.fields.length>0)}function fa(s,e,t){var a;const n=!t&&!e.readonly,i=[];e.group==="progress"?(i.push('<span class="rowvia-nf-progress is-large"><i style="width:'+(e.percent??0)+'%"></i></span>',"<b>"+D(e.value)+"</b>"),e.writeMode&&i.push('<em class="rowvia-nf-mode">'+D(e.writeMode)+"</em>")):n&&e.id==="conclusion"&&((a=s.conclusionOptions)!=null&&a.length)?i.push('<select data-field="'+D(e.id)+'" aria-label="'+D(e.label)+'"><option value="">请选择</option>'+s.conclusionOptions.map(l=>"<option"+(l===e.value?" selected":"")+">"+D(l)+"</option>").join("")+"</select>"):n?i.push('<input data-field="'+D(e.id)+'" value="'+D(e.value??"")+'" placeholder="待填" aria-label="'+D(e.label)+'">'):i.push('<span class="rowvia-nf-value'+(e.value?"":" is-empty")+'">'+D(e.value||"待填")+"</span>");const o=[e.source,e.permission?"可编辑:"+e.permission:""].filter(Boolean).join(" · ");return'<div class="rowvia-nf-field"><label>'+D(e.label)+'</label><div class="rowvia-nf-field-control">'+i.join("")+'</div><button type="button" class="rowvia-nf-info" data-info="'+D(o)+'" aria-label="字段来源">ⓘ</button></div>'}function ga(s){const e=s.filter(n=>n.met).length,t=s.map(n=>{const i=n.met?"":'<button type="button" class="rowvia-nf-fix" data-'+(n.viewLink?'gate-view="'+D(n.id)+'"':'gate-fix="'+D(n.id)+'"')+">"+D(n.fixLabel??"去填写")+"</button>";return'<li class="'+(n.met?"is-met":"is-unmet")+'"><i aria-hidden="true">'+(n.met?"✓":"✕")+"</i><span>"+D(n.label)+(n.detail?"<small>"+D(n.detail)+"</small>":"")+"</span>"+i+"</li>"}).join("");return'<section class="rowvia-nf-gates" data-gates><h4>完成前需满足 <em>'+e+"/"+s.length+"</em></h4><ul>"+t+"</ul></section>"}function ma(s,e){const t=s.tasks??[],n=e?"":'<button type="button" class="rowvia-nf-link" data-action="add-task">+ 新增任务</button>';if(!t.length)return'<section class="rowvia-nf-tasks is-empty"><h4>全部任务 (0/0)</h4><p>暂无子任务'+(e?"":'<button type="button" data-action="add-task">+ 新增任务</button>')+"</p></section>";const i=t.filter(a=>a.done).length,o=t.map(a=>{const l=a.deliverable?'<span class="rowvia-nf-deliverable">📎 '+D(a.deliverable)+"</span>":'<span class="rowvia-nf-value is-empty">暂无</span>';return'<tr class="'+(a.done?"is-done":"")+'"><td><label class="rowvia-nf-check"><input type="checkbox" data-task="'+D(a.id)+'"'+(a.done?" checked":"")+(e?" disabled":"")+"><span>"+D(a.name)+"</span></label>"+(a.blocking?'<em class="rowvia-nf-blocker" title="未完成前主节点无法流转">阻塞项</em>':"")+"</td><td>"+l+"</td><td>"+D(a.owner||"暂无")+"</td><td>"+D(a.estimate||"暂无")+"</td><td>"+D(a.schedule||"暂无")+"</td></tr>"}).join("");return'<section class="rowvia-nf-tasks"><h4>全部任务 ('+i+"/"+t.length+")"+n+"</h4><table><thead><tr><th>名称</th><th>交付物</th><th>当前负责人</th><th>估分</th><th>排期</th></tr></thead><tbody>"+o+"</tbody></table></section>"}function va(s,e){const t=s.form??[];if(!t.length)return"";const n=t.filter(r=>r.required).length,i=t.filter(r=>r.required&&!r.value).length,o=t.map(r=>{var c;let d;return!e&&r.type==="select"&&((c=r.options)!=null&&c.length)?d='<select data-form="'+D(r.id)+'" aria-label="'+D(r.label)+'"><option value="">请选择</option>'+r.options.map(p=>"<option"+(p===r.value?" selected":"")+">"+D(p)+"</option>").join("")+"</select>":!e&&r.type==="date"?d='<input type="date" data-form="'+D(r.id)+'" value="'+D(r.value??"")+'" aria-label="'+D(r.label)+'">':e?d='<span class="rowvia-nf-value'+(r.value?"":" is-empty")+'">'+D(r.value||"待填")+"</span>":d='<input data-form="'+D(r.id)+'" value="'+D(r.value??"")+'" placeholder="'+D(r.placeholder??"待填")+'" aria-label="'+D(r.label)+'">','<div class="rowvia-nf-form-row"><label>'+D(r.label)+(r.required?"<b>*</b>":"")+'</label><div class="rowvia-nf-field-control">'+d+"</div></div>"}).join(""),a=i?'<em class="rowvia-nf-warn">'+i+" 项必填未完成</em>":"",l="节点表单 · "+t.length+" 项"+(n?"("+n+" 必填)":"")+a;return'<section class="rowvia-nf-form'+(i?" has-pending":"")+'"><h4>'+l+"</h4>"+o+"</section>"}function wa(s){const e=s.events??[];if(!e.length)return"";const t=(o,a)=>a.length?"<span><b>"+o+"</b>"+a.map(l=>D(l.text)).join(";")+"</span>":"",n=e.filter(o=>o.trigger==="arrive"),i=e.filter(o=>o.trigger==="complete");return'<section class="rowvia-nf-events"><details><summary>ℹ 节点事件('+e.length+' 条规则已生效)</summary><div class="rowvia-nf-events-body">'+t("到达本节点时:",n)+t("完成本节点时:",i)+"<p>事件规则由流程模板配置,回滚节点至到达/完成之前的状态可解除限制。</p></div></details></section>"}function vi(s,e){const t=document.createElement("div"),n=new Ke;t.className="rowvia-nf-card",s.append(t);const i=De(t,"node-card",e);let o=e.node??null,a={...e},l=!1;const r=()=>{var x;if(!o){t.innerHTML='<div class="rowvia-nf-empty">在上方流程画布中选择一个节点,查看它的字段、表单与通行条件。</div>';return}const h=!!a.readonly,u=gt[o.status],f=rn(o),g=o.completionMode?ui[o.completionMode]:"",v=pa(o),m=(o.buttons??[]).filter(T=>(T.placement??"inline")==="inline"),w=(o.buttons??[]).filter(T=>T.placement==="more"),k=(T,A,H="")=>'<span class="rowvia-nf-chip '+A+'"'+(H?' title="'+D(H)+'"':"")+">"+D(T)+"</span>",C=(T,A,H,q="",R=!1)=>'<button type="button" class="rowvia-nf-btn '+H+'" data-action="'+D(T)+'"'+(q?' title="'+D(q)+'"':"")+(R?" disabled":"")+">"+D(A)+"</button>",b=[];if(!h){o.status==="inProgress"&&b.push(C("complete","完成","is-primary")),o.status==="failed"&&b.push(C("resubmit","重新提交","is-primary")),(o.status==="done"||o.status==="failed")&&b.push(C("rollback","回滚","is-ghost","将节点状态回退至进行中")),b.push(C("transfer","转办","is-ghost","将负责人转交他人"));for(const T of m){const A=[T.hint,(x=T.roles)!=null&&x.length?"授权:"+T.roles.join("、"):""].filter(Boolean).join(" · "),H=T.variant==="primary"?"is-primary":T.variant==="warning"?"is-warning":"is-ghost";b.push(C("custom:"+T.id,T.label,H,A))}b.push('<button type="button" class="rowvia-nf-btn is-icon" data-action="more" aria-haspopup="menu" aria-expanded="'+String(l)+'">···</button>')}const N='<span class="rowvia-nf-owner">负责人 '+D(o.owner||"待填")+(o.ownerSource?"<em>"+D(o.ownerSource)+"</em>":"")+"</span>",I='<div class="rowvia-nf-menu" data-menu'+(l?"":" hidden")+' role="menu"><button type="button" role="menuitem" data-action="estimate">填写估分</button><button type="button" role="menuitem" data-action="group-chat">节点建群</button>'+w.map(T=>'<button type="button" role="menuitem" data-action="custom:'+D(T.id)+'">'+D(T.label)+"</button>").join("")+'<button type="button" role="menuitem" class="is-danger" data-action="delete-node"'+(o.deleteRoles?' title="允许删除:'+D(o.deleteRoles.join("、"))+'"':"")+">删除节点</button></div>",E='<header class="rowvia-nf-card-head"><span class="rowvia-nf-dot status-'+u.className+'" aria-hidden="true"></span><h3>'+D(o.name)+"</h3>"+k(u.label,"status-"+u.className)+(g?k(g,"is-mode","对应配置:完成方式"):"")+(o.milestone?k("◆ 里程碑"+(o.deadline?" · "+o.deadline:""),"is-milestone","里程碑:仅可填写截止时间"):"")+N+'<span class="rowvia-nf-space"></span><div class="rowvia-nf-actions">'+b.join("")+"</div>"+I+"</header>",G=v.map(T=>'<div class="rowvia-nf-field-group" data-section="'+T.key+'"><h5>'+D(T.title)+"</h5>"+T.fields.map(A=>fa(o,A,h)).join("")+"</div>").join("");t.innerHTML=E+ga(f)+'<details class="rowvia-nf-section" open><summary>节点字段 <em>'+v.length+" 组</em></summary>"+G+"</details>"+va(o,h)+ma(o,h)+wa(o)},d=h=>{var g,v,m,w,k;const u=h.target.closest("[data-action],[data-gate-fix],[data-gate-view],[data-info]");if(!u||!t.contains(u))return;if(u.dataset.info){n.add(wi(u,u.dataset.info));return}if(u.dataset.gateFix||u.dataset.gateView){p(),(g=a.onAction)==null||g.call(a,u.dataset.gateView?"open-gate-view":"fix-gate",(o==null?void 0:o.id)??"");return}const f=u.dataset.action;if(f){if(f==="more"){const C=t.querySelector("[data-menu]");if(!C)return;l=C.hidden,C.hidden=!l,u.setAttribute("aria-expanded",String(l));return}if(f==="complete"){const C=o?rn(o):[];if(!hi(C)){p(),(v=a.onAction)==null||v.call(a,"complete-blocked",(o==null?void 0:o.id)??"");return}if(((m=a.onComplete)==null?void 0:m.call(a,(o==null?void 0:o.id)??"",C))===!1)return;(w=a.onAction)==null||w.call(a,"complete",(o==null?void 0:o.id)??"");return}(k=a.onAction)==null||k.call(a,f,(o==null?void 0:o.id)??"")}},c=h=>{var f,g,v,m,w;const u=h.target;if(u instanceof HTMLInputElement){u.dataset.task?(f=a.onTaskToggle)==null||f.call(a,(o==null?void 0:o.id)??"",u.dataset.task,u.checked):u.dataset.field?(g=a.onFieldChange)==null||g.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((v=a.onFormChange)==null||v.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value));return}u instanceof HTMLSelectElement&&(u.dataset.field?(m=a.onFieldChange)==null||m.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((w=a.onFormChange)==null||w.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value)))};function p(){const h=t.querySelector(".rowvia-nf-gates");h&&(h.classList.add("is-shaking"),n.timeout(()=>h.classList.remove("is-shaking"),700))}return t.addEventListener("click",d),t.addEventListener("change",c),r(),{onInteraction:i.onInteraction,update(h,u){o=h,u&&(a={...a,...u}),r()},destroy(){t.removeEventListener("click",d),t.removeEventListener("change",c),i.destroy(),n.destroy(),t.remove()}}}function wi(s,e){const t=document.createElement("div");t.className="rowvia-nf-tip",t.textContent=e,document.body.append(t);const n=s.getBoundingClientRect();t.style.left=Math.max(8,Math.min(window.innerWidth-260,n.left))+"px",t.style.top=n.bottom+6+"px";const i=window.setTimeout(()=>t.remove(),2600);return()=>{window.clearTimeout(i),t.remove()}}function yi(s,e){const t=document.createElement("div"),n=new Ke;t.className="rowvia-nf-contextbar",s.append(t);const i=De(t,"flow-context",e);let o=e.flow,a=e.query??"",l=!1;const r=()=>{const c=pi(o),p=!!(o.templateVersion&&o.latestTemplateVersion&&o.templateVersion!==o.latestTemplateVersion);t.innerHTML=`
72
72
  <div class="rowvia-nf-context-main">
73
73
  <label class="rowvia-nf-flowtype">
74
74
  <span class="rowvia-nf-label">流程类型</span>
@@ -84,28 +84,28 @@ ${m}
84
84
  </div>
85
85
  <button type="button" class="rowvia-nf-ghost" data-action="rules" title="只读展示该流程的完成方式、节点事件与状态计算规则">⚙ 规则</button>
86
86
  </div>
87
- ${p?`<div class="rowvia-nf-banner">当前使用的不是最新流程模板(${D(o.templateVersion)} → ${D(o.latestTemplateVersion)})<button type="button" data-action="diff">查看差异</button></div>`:""}`;const h=t.querySelector('[data-action="search"]'),u=t.querySelector("[data-suggestions]"),f=()=>{if(!u)return;const g=h.value.trim().toLowerCase(),v=g?o.nodes.filter(m=>m.name.toLowerCase().includes(g)).slice(0,8):[];u.hidden=!l||v.length===0,u.innerHTML=v.map(m=>`<button type="button" data-node="${D(m.id)}">${D(m.name)}<em>${D(ut[m.status].label)}</em></button>`).join("")};h.addEventListener("focus",()=>{l=!0,f()}),h.addEventListener("blur",()=>{l=!1,n.timeout(f,120)}),h.addEventListener("input",()=>{var g;a=h.value,f(),(g=e.onQuery)==null||g.call(e,a)}),u==null||u.addEventListener("click",g=>{var m;const v=g.target.closest("[data-node]");v&&(l=!1,u.hidden=!0,(m=e.onFocusNode)==null||m.call(e,v.dataset.node))}),a&&f()},d=c=>{var h,u;const p=c.target.closest("[data-action]");!p||!t.contains(p)||(p.dataset.action==="rules"&&((h=e.onOpenRules)==null||h.call(e)),p.dataset.action==="diff"&&((u=e.onOpenDiff)==null||u.call(e)))};return t.addEventListener("click",d),r(),{onInteraction:i.onInteraction,update(c,p){o=c,p!==void 0&&(a=p),r()},getQuery:()=>a,destroy(){t.removeEventListener("click",d),i.destroy(),n.destroy(),t.remove()}}}function fi(s,e){const t=document.createElement("div");t.className="rowvia-nf-timeline",s.append(t);const n=$e(t,"node-timeline",e);let i=e.flow,o=e.selectedNodeId,a="timeline",l="all",r=null;const d=[{key:"all",label:"全部状态"},{key:"done",label:"已完成"},{key:"inProgress",label:"进行中"},{key:"pending",label:"未开始"},{key:"failed",label:"未通过"}],c=f=>[f.owner?"负责人 "+f.owner:"负责人待填",f.schedule?"排期 "+f.schedule:"排期待填",f.estimate?"估分 "+f.estimate:"估分待填",f.progress!==void 0?"进度 "+f.progress+"%":"",(f.tasks??[]).length?"任务 "+(f.tasks??[]).filter(v=>v.done).length+"/"+(f.tasks??[]).length:"",(f.form??[]).length?"表单 "+(f.form??[]).filter(v=>v.value).length+"/"+(f.form??[]).length:""].filter(Boolean).join(" · "),p=f=>{const g=ut[f.status],v=r===f.id,m=v?'<div class="rowvia-nf-tl-detail"><p>'+D(c(f))+"</p>"+((f.events??[]).length?'<p class="rowvia-nf-tl-events">'+f.events.map(y=>(y.trigger==="arrive"?"到达:":"完成:")+D(y.text)).join(" · ")+"</p>":"")+'<button type="button" class="rowvia-nf-ghost" data-action="edit" data-node="'+D(f.id)+'">回到操作卡编辑</button></div>':"";return'<div class="rowvia-nf-tl-row'+(o===f.id?" is-selected":"")+(f.milestone?" is-milestone":"")+'" data-row="'+D(f.id)+'"><button type="button" class="rowvia-nf-tl-toggle" data-action="toggle" data-node="'+D(f.id)+'" aria-expanded="'+String(v)+'" aria-label="展开">'+(v?"▾":"▸")+'</button><span class="rowvia-nf-dot status-'+g.className+'" aria-hidden="true"></span><button type="button" class="rowvia-nf-tl-name" data-action="edit" data-node="'+D(f.id)+'">'+D(f.name)+(f.milestone?'<em title="里程碑">◆</em>':"")+'</button><span class="rowvia-nf-chip status-'+g.className+'">'+D(g.label)+'</span><span class="rowvia-nf-tl-cell">'+D(f.owner||"待填")+'</span><span class="rowvia-nf-tl-cell">'+D(f.schedule||(f.deadline?"截止 "+f.deadline:"待填"))+'</span><span class="rowvia-nf-tl-cell">'+D(f.estimate||"待填")+'</span><span class="rowvia-nf-tl-cell is-progress">'+(f.progress!==void 0?'<span class="rowvia-nf-progress"><i style="width:'+f.progress+'%"></i></span>'+f.progress+"%":"—")+"</span></div>"+m},h=()=>{const f=i.nodes.filter(v=>l==="all"||v.status===l).map(p).join(""),g="<span>节点</span><span>状态</span><span>负责人</span><span>排期</span><span>估分</span><span>进度</span>";t.innerHTML='<div class="rowvia-nf-tl-toolbar"><div class="rowvia-nf-tl-filters">'+d.map(v=>'<button type="button" class="'+(l===v.key?"is-active":"")+'" data-action="filter" data-filter="'+v.key+'">'+v.label+"</button>").join("")+'</div><span class="rowvia-nf-space"></span><div class="rowvia-nf-seg" role="tablist"><button type="button" role="tab" class="'+(a==="timeline"?"is-active":"")+'" data-action="view" data-view="timeline">节点时间线</button><button type="button" role="tab" class="'+(a==="schedule"?"is-active":"")+'" data-action="view" data-view="schedule">排期信息</button></div></div><div class="rowvia-nf-tl-head">'+g+"</div>"+(f||'<div class="rowvia-nf-empty">没有符合筛选条件的节点</div>')},u=f=>{var m;const g=f.target.closest("[data-action]");if(!g||!t.contains(g))return;const v=g.dataset.action;if(v==="filter")l=g.dataset.filter??"all",h();else if(v==="view")a=g.dataset.view??"timeline",h();else if(v==="toggle"){const y=g.dataset.node;r=r===y?null:y,h()}else if(v==="edit"){const y=g.dataset.node;(m=e.onSelectNode)==null||m.call(e,y)}};return t.addEventListener("click",u),h(),{onInteraction:n.onInteraction,update(f){const g=f.flow!==void 0;if(f.flow&&(i=f.flow),f.selectedNodeId!==void 0&&(o=f.selectedNodeId),f.onSelectNode&&(e.onSelectNode=f.onSelectNode),g)h();else for(const v of t.querySelectorAll("[data-row]"))v.classList.toggle("is-selected",v.dataset.row===o)},destroy(){t.removeEventListener("click",u),n.destroy(),t.remove()}}}const ga=["schedule","estimate","worklog","conclusion","opinion"];function ma(s){const e={};for(const t of s){const n=ut[t.status].label;e[n]=(e[n]??0)+1}return Object.entries(e).map(([t,n])=>t+" "+n).join(" · ")}function va(s,e){let t=e.flow,n=e.selectedNodeId??"",i="",o=!1;const a=E=>{var k,T;return((k=E.nodes.find(H=>H.status==="inProgress"))==null?void 0:k.id)??((T=E.nodes[0])==null?void 0:T.id)??""};n||(n=a(t));const l=document.createElement("section");if(l.className="rowvia-nf",e.title){const E=document.createElement("header");E.className="rowvia-nf-title",E.innerHTML="<strong>"+D(e.title)+"</strong>",l.append(E)}const r=document.createElement("div");r.className="rowvia-nf-body",r.innerHTML='<div data-region="context"></div><div data-region="canvas"></div><div data-region="card"></div><div data-region="timeline"></div><aside class="rowvia-nf-rules" data-region="rules" hidden></aside>',l.append(r),s.append(l);const d=$e(l,"node-flow",e),c=E=>r.querySelector('[data-region="'+E+'"]'),p=E=>t.nodes.find(k=>k.id===E)??null,h=pi(c("context"),{flow:t,query:i,onQuery:E=>{i=E,u.update({query:i})},onFocusNode:E=>y(E,!0),onOpenRules:()=>S(),onOpenDiff:()=>{var E;return(E=e.onAction)==null?void 0:E.call(e,"open-template-diff",n)}}),u=ci(c("canvas"),{flow:t,selectedNodeId:n,query:i,onSelectNode:E=>y(E)}),f=fi(c("timeline"),{flow:t,selectedNodeId:n,onSelectNode:E=>y(E,!0)}),g=c("rules"),v=ui(c("card"),{node:p(n),readonly:e.readonly,onComplete:(E,k)=>{var T;return(T=e.onComplete)==null?void 0:T.call(e,E,k)},onAction:(E,k)=>x(E,k),onFieldChange:(E,k,T)=>b(E,k,T),onFormChange:(E,k,T)=>I(E,k,T),onTaskToggle:(E,k,T)=>A(E,k,T)});function m(){v.update(p(n),{readonly:e.readonly})}function y(E,k=!1){var T;p(E)&&(n=E,u.update({selectedNodeId:E}),f.update({selectedNodeId:E}),m(),k&&u.focusNode(E),(T=e.onSelectNode)==null||T.call(e,E))}function x(E,k){var T;(E==="complete"||E==="rollback"||E==="resubmit")&&C(k,{status:E==="complete"?"done":"inProgress"}),(T=e.onAction)==null||T.call(e,E,k)}function C(E,k){t={...t,nodes:t.nodes.map(T=>T.id===E?{...T,...k}:T)},u.update({flow:t}),f.update({flow:t}),h.update(t,i),m()}function b(E,k,T){var W;const H=p(E);H&&(k==="conclusion"?C(E,{conclusion:T}):k==="opinion"?C(E,{opinion:T}):ga.includes(k)?C(E,{[k]:T}):C(E,{fields:(H.fields??[]).map(R=>R.id===k?{...R,value:T}:R)}),(W=e.onFieldChange)==null||W.call(e,E,k,T))}function I(E,k,T){var W;const H=p(E);H&&C(E,{form:(H.form??[]).map(R=>R.id===k?{...R,value:T}:R)}),(W=e.onFormChange)==null||W.call(e,E,k,T)}function A(E,k,T){var W;const H=p(E);H&&C(E,{tasks:(H.tasks??[]).map(R=>R.id===k?{...R,done:T}:R)}),(W=e.onTaskToggle)==null||W.call(e,E,k,T)}function S(){var T;if(!g.hidden){g.hidden=!0;return}const E=Array.from(new Set(t.nodes.map(H=>H.completionMode).filter(Boolean))),k=t.nodes.flatMap(H=>H.events??[]);g.innerHTML='<div class="rowvia-nf-rules-head"><strong>流程规则(只读)</strong><button type="button" class="rowvia-nf-ghost" data-action="close-rules">关闭</button></div><dl><dt>流程类型</dt><dd>'+D(t.name)+"</dd><dt>完成方式</dt><dd>"+(E.length?E.map(H=>D(String(H))).join("、"):"未配置")+"</dd><dt>状态计算规则</dt><dd>"+((T=t.statusRules)!=null&&T.length?t.statusRules.map(H=>D(H)).join("<br>"):"未命中规则时按节点流转事件配置显示")+"</dd><dt>节点事件</dt><dd>"+(k.length?k.slice(0,6).map(H=>(H.trigger==="arrive"?"到达:":"完成:")+D(H.text)).join("<br>"):"无")+"</dd><dt>节点状态分布</dt><dd>"+D(ma(t.nodes))+"</dd></dl>",g.hidden=!1}const G=E=>{E.target.closest('[data-action="close-rules"]')&&(g.hidden=!0)};return g.addEventListener("click",G),{onInteraction:d.onInteraction,selectNode(E){y(E,!0)},getSelectedNode:()=>p(n),setFlow(E){t=E,p(n)||(n=a(t)),h.update(t,i),u.update({flow:t,selectedNodeId:n,query:i}),f.update({flow:t,selectedNodeId:n}),m(),g.hidden=!0},updateNode(E,k){C(E,k)},focusNode(E){y(E,!0)},destroy(){o||(o=!0,g.removeEventListener("click",G),h.destroy(),u.destroy(),v.destroy(),f.destroy(),d.destroy(),l.remove())}}}const wa=(s,e,t={})=>({id:s,name:e,...t});function He(s){return{groupId:"g1",completionMode:"and",...s}}function ya(){const s=(t,n,i)=>He({id:t,name:n,status:"pending",groupId:"g4",owner:i,ownerSource:"来源:角色联动",schedule:"09-02 ~ 09-06",estimate:"2d"}),e=[He({id:"n-start",name:"开始",status:"done",owner:"系统",ownerSource:"来源:自动创建",schedule:"08-11",estimate:"0d",conclusion:"通过",events:[{trigger:"arrive",text:"需求状态 → 选题"}]}),He({id:"n-meeting",name:"选题会",status:"inProgress",owner:"林小满",ownerSource:"来源:自行添加",schedule:"08-12 ~ 08-14",estimate:"3d",worklog:"1.5d",progress:40,progressMode:"按排期自动计算",conclusionOptions:["通过","不通过","有条件通过"],form:[{id:"f-entry",label:"选题入围",required:!0,placeholder:"请填写选题入围(至少五个主题)"}],tasks:[wa("t-1","请填写选题入围",{blocking:!0,deliverable:"选题清单",owner:"林小满",estimate:"1d",schedule:"08-12"})],fields:[{id:"cf-risk",label:"节点风险",value:"中风险",group:"custom",source:"节点字段 · 单选"}],events:[{trigger:"arrive",text:"需求状态 → 选题"},{trigger:"complete",text:"「选题状态」字段 → 已定稿"}],buttons:[{id:"pass",label:"通过评审",variant:"primary",roles:["节点负责人","管理员"],hint:"数据赋值:整体完成结论 → 已通过"},{id:"reject",label:"不通过",variant:"warning",placement:"more"}],actionRoles:["节点负责人","管理员"],deleteRoles:["管理员"]}),He({id:"n-topic",name:"确定选题",status:"pending",groupId:"g1",owner:"周野",schedule:"08-15 ~ 08-16",estimate:"2d",progress:0,progressMode:"手动填写",predecessors:["选题会"]}),He({id:"n-ads",name:"广告植入",status:"pending",owner:"商务组",schedule:"08-17",estimate:"1d",predecessors:["确定选题"]}),He({id:"n-script",name:"脚本制作",status:"pending",groupId:"g2",owner:"周野",schedule:"08-18 ~ 08-20",estimate:"3d"}),He({id:"n-review",name:"脚本评审",status:"pending",groupId:"g2",completionMode:"or",owner:"内容总监",schedule:"08-21",estimate:"1d",conclusionOptions:["通过","不通过"],events:[{trigger:"complete",text:"「脚本状态」字段 → 已评审"}]}),He({id:"n-plan",name:"制定计划表",status:"pending",groupId:"g3",owner:"制片人",schedule:"08-22 ~ 08-23",estimate:"2d"}),s("n-shoot","拍摄","导演组"),s("n-edit","剪辑","剪辑师"),s("n-art","美术","美术组"),s("n-audio","收音","录音师"),s("n-dit","DIT","DIT"),s("n-motion","动效","动效师"),s("n-color","调色","调色师"),s("n-mix","混音","混音师"),s("n-cover","封面","设计师"),He({id:"n-final",name:"成片",status:"pending",groupId:"g5",milestone:!0,deadline:"09-08",owner:"制片人",schedule:"09-08",estimate:"0d",predecessors:["全部并行节点"]}),He({id:"n-final-review",name:"成片评审会",status:"pending",groupId:"g5",completionMode:"or",owner:"内容总监",schedule:"09-09",estimate:"1d",conclusionOptions:["通过","不通过"],form:[{id:"f-pass",label:"成片评审是否通过",required:!0,type:"select",options:["是","否"]},{id:"f-publish",label:"预计发布时间",required:!0,type:"date"}],gates:[{id:"g-conclusion",label:"自定义条件:整体结论 = 通过",met:!1,fixLabel:"查看规则",detail:"完成流转条件 · 校验当前工作项",viewLink:"gates"},{id:"g-linked",label:"关联缺陷全部关闭",met:!1,fixLabel:"查看 3 条",detail:"完成流转条件 · 校验关联工作项",viewLink:"gates"}],events:[{trigger:"complete",text:"需求状态 → 待发布"}]}),He({id:"n-publish",name:"发布",status:"pending",groupId:"g5",owner:"运营",schedule:"09-10",estimate:"1d"}),He({id:"n-monitor",name:"数据监控",status:"pending",groupId:"g6",completionMode:"auto",owner:"数据组",schedule:"09-11 ~ 09-17",estimate:"5d",progress:0,progressMode:"同步自计算字段",delayed:!1}),He({id:"n-retro",name:"项目复盘",status:"pending",groupId:"g6",owner:"制片人",schedule:"09-18",estimate:"1d",delayed:!0,info:"09-18"}),He({id:"n-end",name:"结束",status:"pending",groupId:"g6",owner:"系统",estimate:"0d"})];for(const t of e)t.info||(t.info=t.schedule?t.schedule.split(" ~ ")[0]:"");return{id:"video",name:"视频流程",templateVersion:"v3",latestTemplateVersion:"v4",infoField:{label:"排期",position:"right"},statusRules:["整体结论 = 未通过 → 节点状态显示「未通过」","里程碑截止时间早于今天 → 节点状态显示「延期」"],groups:[{id:"g1",name:"前期策划"},{id:"g2",name:"脚本"},{id:"g3",name:"排期"},{id:"g4",name:"制作",layout:"parallel"},{id:"g5",name:"交付"},{id:"g6",name:"复盘"}],nodes:e}}const De=s=>Date.parse(`${s}T00:00:00Z`)/864e5,ze=s=>new Date(s*864e5).toISOString().slice(0,10),gi=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(De(s))&&ze(De(s))===s,on=s=>!!s.start&&!!s.end;function an(s,e){const t=new Set(s.map(n=>n.id));if(t.size!==s.length||new Set(e.map(n=>n.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const n of e){if(!t.has(n.personId))throw new Error(`Unknown person: ${n.personId}`);if(!Number.isFinite(n.estimate)||n.estimate<0)throw new Error("Invalid estimate");if(!!n.start!=!!n.end||n.start&&n.end&&(!gi(n.start)||!gi(n.end)||n.end<n.start))throw new Error("Invalid date range")}}function ba(s,e=!1){const t=[];return s.filter(on).slice().sort((n,i)=>n.start.localeCompare(i.start)||n.id.localeCompare(i.id)).map(n=>{let i=e?t.length:t.findIndex(o=>o<De(n.start));return i<0&&(i=t.length),t[i]=De(n.end),{item:n,lane:i}})}function mi(s){let e=0,t=0;for(const n of s)on(n)&&e++,t+=n.estimate;return{scheduled:e,unscheduled:s.length-e,estimate:t}}const vi=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function Ca(s,e){const{people:t,items:n,today:i,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:h,children:u,loose:f,colorFirst:g,from:v,days:m,rangeStart:y,rangeEnd:x}=e,C=$=>s.querySelector($),b=C(".ps-rows"),I=()=>[22,43,64,86,120][p],A=()=>n.filter($=>(!l||$.name.includes(l))&&(!r||$.status===r)&&(u||!$.parentId)),S=I(),G=m*S;C(".ps-table").style.width=`${G+200}px`;const E=`${y.slice(0,4)}年 第${Number(y.slice(5,7))}-${Number(x.slice(5,7))}月`;C(".ps-date-label").textContent=E,C('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,C(".ps-zoom").value=String(p);const k=C(".ps-weeks");k.replaceChildren();for(let $=0;$<m;$+=7){const _=document.createElement("span");_.style.width=`${Math.min(7,m-$)*S}px`,_.textContent=`${ze(v+$).slice(5).replace("-","/")}~${ze(v+$+6).slice(5).replace("-","/")}`,k.append(_)}b.replaceChildren();const T=A(),H=new Map;for(const $ of T){const _=H.get($.personId);_?_.push($):H.set($.personId,[$])}const W=new Map(t.map($=>[$.id,mi(H.get($.id)??[])])),R=t.filter($=>o.has($.id)&&(!a||W.get($.id).scheduled>0));d&&R.sort(($,_)=>{const U=W.get($.id),ee=W.get(_.id);return(d==="estimate"?U.estimate-ee.estimate:U.scheduled-ee.scheduled)*(c?-1:1)});const O=document.createElement("div");for(let $=0;$<m;$++){const _=new Date((v+$)*864e5).getUTCDay();if(_!==0&&_!==6)continue;const U=document.createElement("i");U.className="ps-weekend",U.style.left=`${$*S}px`,U.style.width=`${S}px`,O.append(U)}for(const $ of R){const _=H.get($.id)??[],U=W.get($.id),ee=ba(_,h),ae=Math.max(0,...ee.map(P=>P.lane)),he=Math.max(f?154:126,60+(ae+1)*(f?48:36)),be=document.createElement("div");be.className="ps-person-row",be.style.height=`${he}px`,be.dataset.person=$.id;const fe=document.createElement("div");fe.className="ps-person",fe.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${D($.name)}</strong></div><div>已排期项 <b>${U.scheduled}</b></div><div>总估分 <b>${U.estimate.toFixed(2)}</b></div><div>未排期·${U.unscheduled}<button data-action="unplanned" data-person="${D($.id)}">查看</button></div>`;const ve=fe.querySelector(".ps-avatar");ve.textContent=$.name.slice(-2),ve.style.background=$.color||vi[t.indexOf($)%vi.length];const xe=document.createElement("div");xe.className="ps-timeline",xe.style.width=`${G}px`,xe.style.setProperty("--day",`${S}px`);for(const P of O.children)xe.append(P.cloneNode(!0));const me=De(i)-v;if(me>=0&&me<m){const P=document.createElement("i");P.className="ps-today",P.style.left=`${(me+.5)*S}px`,xe.append(P)}for(const{item:P,lane:z}of ee){const j=De(P.start),Y=De(P.end);if(Y<v||j>=v+m)continue;const re=Math.max(0,j-v)*S,Ce=Math.min(m,Y-v+1)*S,N=document.createElement("button");N.className=`ps-bar ${g?"ps-color":"ps-content"}`,N.dataset.item=P.id,N.setAttribute("aria-label",`${P.name},${P.start} 至 ${P.end}`),N.style.left=`${re}px`,N.style.width=`${Ce-re}px`,N.style.top=`${52+z*(f?48:36)}px`,N.style.setProperty("--bar-color",P.color||"#8cafeb"),N.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${D(P.name)}</span><span class="ps-status">${D(P.status)}</span><span class="ps-node">● ${D(P.node)}</span><span class="ps-effort">${P.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,xe.append(N)}if(!ee.length){const P=document.createElement("span");P.className="ps-no-schedule",P.textContent="暂无排期",xe.append(P)}be.append(fe,xe),b.append(be)}R.length||(b.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const L=new Set(R.map($=>$.id)),M=T.filter($=>L.has($.personId));C(".ps-total").textContent=`ⓘ 总人数 ${R.length} 总估分 ${mi(M).estimate.toFixed(2)} pd ···`}function Sa(s,e){an(e.people,e.items);let t=structuredClone(e.people),n=structuredClone(e.items);const i=e.today??new Date().toISOString().slice(0,10);let o=new Set(t.map(P=>P.id)),a=!1,l="",r="",d="",c=!1,p=1,h=!1,u=!1,f=!1,g=!0,v=De(i)-new Date(`${i}T00:00:00Z`).getUTCDay(),m=90,y=`${i.slice(0,7)}-01`,x=ze(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7))+1,0)/864e5),C=!1,b=!1;const I=document.createElement("section");I.className="personnel-schedule",I.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${D(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
87
+ ${p?`<div class="rowvia-nf-banner">当前使用的不是最新流程模板(${D(o.templateVersion)} → ${D(o.latestTemplateVersion)})<button type="button" data-action="diff">查看差异</button></div>`:""}`;const h=t.querySelector('[data-action="search"]'),u=t.querySelector("[data-suggestions]"),f=()=>{if(!u)return;const g=h.value.trim().toLowerCase(),v=g?o.nodes.filter(m=>m.name.toLowerCase().includes(g)).slice(0,8):[];u.hidden=!l||v.length===0,u.innerHTML=v.map(m=>`<button type="button" data-node="${D(m.id)}">${D(m.name)}<em>${D(gt[m.status].label)}</em></button>`).join("")};h.addEventListener("focus",()=>{l=!0,f()}),h.addEventListener("blur",()=>{l=!1,n.timeout(f,120)}),h.addEventListener("input",()=>{var g;a=h.value,f(),(g=e.onQuery)==null||g.call(e,a)}),u==null||u.addEventListener("click",g=>{var m;const v=g.target.closest("[data-node]");v&&(l=!1,u.hidden=!0,(m=e.onFocusNode)==null||m.call(e,v.dataset.node))}),a&&f()},d=c=>{var h,u;const p=c.target.closest("[data-action]");!p||!t.contains(p)||(p.dataset.action==="rules"&&((h=e.onOpenRules)==null||h.call(e)),p.dataset.action==="diff"&&((u=e.onOpenDiff)==null||u.call(e)))};return t.addEventListener("click",d),r(),{onInteraction:i.onInteraction,update(c,p){o=c,p!==void 0&&(a=p),r()},getQuery:()=>a,destroy(){t.removeEventListener("click",d),i.destroy(),n.destroy(),t.remove()}}}function bi(s,e){const t=document.createElement("div");t.className="rowvia-nf-timeline",s.append(t);const n=De(t,"node-timeline",e);let i=e.flow,o=e.selectedNodeId,a="timeline",l="all",r=null;const d=[{key:"all",label:"全部状态"},{key:"done",label:"已完成"},{key:"inProgress",label:"进行中"},{key:"pending",label:"未开始"},{key:"failed",label:"未通过"}],c=f=>[f.owner?"负责人 "+f.owner:"负责人待填",f.schedule?"排期 "+f.schedule:"排期待填",f.estimate?"估分 "+f.estimate:"估分待填",f.progress!==void 0?"进度 "+f.progress+"%":"",(f.tasks??[]).length?"任务 "+(f.tasks??[]).filter(v=>v.done).length+"/"+(f.tasks??[]).length:"",(f.form??[]).length?"表单 "+(f.form??[]).filter(v=>v.value).length+"/"+(f.form??[]).length:""].filter(Boolean).join(" · "),p=f=>{const g=gt[f.status],v=r===f.id,m=v?'<div class="rowvia-nf-tl-detail"><p>'+D(c(f))+"</p>"+((f.events??[]).length?'<p class="rowvia-nf-tl-events">'+f.events.map(w=>(w.trigger==="arrive"?"到达:":"完成:")+D(w.text)).join(" · ")+"</p>":"")+'<button type="button" class="rowvia-nf-ghost" data-action="edit" data-node="'+D(f.id)+'">回到操作卡编辑</button></div>':"";return'<div class="rowvia-nf-tl-row'+(o===f.id?" is-selected":"")+(f.milestone?" is-milestone":"")+'" data-row="'+D(f.id)+'"><button type="button" class="rowvia-nf-tl-toggle" data-action="toggle" data-node="'+D(f.id)+'" aria-expanded="'+String(v)+'" aria-label="展开">'+(v?"▾":"▸")+'</button><span class="rowvia-nf-dot status-'+g.className+'" aria-hidden="true"></span><button type="button" class="rowvia-nf-tl-name" data-action="edit" data-node="'+D(f.id)+'">'+D(f.name)+(f.milestone?'<em title="里程碑">◆</em>':"")+'</button><span class="rowvia-nf-chip status-'+g.className+'">'+D(g.label)+'</span><span class="rowvia-nf-tl-cell">'+D(f.owner||"待填")+'</span><span class="rowvia-nf-tl-cell">'+D(f.schedule||(f.deadline?"截止 "+f.deadline:"待填"))+'</span><span class="rowvia-nf-tl-cell">'+D(f.estimate||"待填")+'</span><span class="rowvia-nf-tl-cell is-progress">'+(f.progress!==void 0?'<span class="rowvia-nf-progress"><i style="width:'+f.progress+'%"></i></span>'+f.progress+"%":"—")+"</span></div>"+m},h=()=>{const f=i.nodes.filter(v=>l==="all"||v.status===l).map(p).join(""),g="<span>节点</span><span>状态</span><span>负责人</span><span>排期</span><span>估分</span><span>进度</span>";t.innerHTML='<div class="rowvia-nf-tl-toolbar"><div class="rowvia-nf-tl-filters">'+d.map(v=>'<button type="button" class="'+(l===v.key?"is-active":"")+'" data-action="filter" data-filter="'+v.key+'">'+v.label+"</button>").join("")+'</div><span class="rowvia-nf-space"></span><div class="rowvia-nf-seg" role="tablist"><button type="button" role="tab" class="'+(a==="timeline"?"is-active":"")+'" data-action="view" data-view="timeline">节点时间线</button><button type="button" role="tab" class="'+(a==="schedule"?"is-active":"")+'" data-action="view" data-view="schedule">排期信息</button></div></div><div class="rowvia-nf-tl-head">'+g+"</div>"+(f||'<div class="rowvia-nf-empty">没有符合筛选条件的节点</div>')},u=f=>{var m;const g=f.target.closest("[data-action]");if(!g||!t.contains(g))return;const v=g.dataset.action;if(v==="filter")l=g.dataset.filter??"all",h();else if(v==="view")a=g.dataset.view??"timeline",h();else if(v==="toggle"){const w=g.dataset.node;r=r===w?null:w,h()}else if(v==="edit"){const w=g.dataset.node;(m=e.onSelectNode)==null||m.call(e,w)}};return t.addEventListener("click",u),h(),{onInteraction:n.onInteraction,update(f){const g=f.flow!==void 0;if(f.flow&&(i=f.flow),f.selectedNodeId!==void 0&&(o=f.selectedNodeId),f.onSelectNode&&(e.onSelectNode=f.onSelectNode),g)h();else for(const v of t.querySelectorAll("[data-row]"))v.classList.toggle("is-selected",v.dataset.row===o)},destroy(){t.removeEventListener("click",u),n.destroy(),t.remove()}}}const ya=["schedule","estimate","worklog","conclusion","opinion"];function ba(s){const e={};for(const t of s){const n=gt[t.status].label;e[n]=(e[n]??0)+1}return Object.entries(e).map(([t,n])=>t+" "+n).join(" · ")}function Ca(s,e){let t=e.flow,n=e.selectedNodeId??"",i="",o=!1;const a=x=>{var T,A;return((T=x.nodes.find(H=>H.status==="inProgress"))==null?void 0:T.id)??((A=x.nodes[0])==null?void 0:A.id)??""};n||(n=a(t));const l=document.createElement("section");if(l.className="rowvia-nf",e.title){const x=document.createElement("header");x.className="rowvia-nf-title",x.innerHTML="<strong>"+D(e.title)+"</strong>",l.append(x)}const r=document.createElement("div");r.className="rowvia-nf-body",r.innerHTML='<div data-region="context"></div><div data-region="canvas"></div><div data-region="card"></div><div data-region="timeline"></div><aside class="rowvia-nf-rules" data-region="rules" hidden></aside>',l.append(r),s.append(l);const d=De(l,"node-flow",e),c=x=>r.querySelector('[data-region="'+x+'"]'),p=x=>t.nodes.find(T=>T.id===x)??null,h=yi(c("context"),{flow:t,query:i,onQuery:x=>{i=x,u.update({query:i})},onFocusNode:x=>w(x,!0),onOpenRules:()=>E(),onOpenDiff:()=>{var x;return(x=e.onAction)==null?void 0:x.call(e,"open-template-diff",n)}}),u=mi(c("canvas"),{flow:t,selectedNodeId:n,query:i,onSelectNode:x=>w(x)}),f=bi(c("timeline"),{flow:t,selectedNodeId:n,onSelectNode:x=>w(x,!0)}),g=c("rules"),v=vi(c("card"),{node:p(n),readonly:e.readonly,onComplete:(x,T)=>{var A;return(A=e.onComplete)==null?void 0:A.call(e,x,T)},onAction:(x,T)=>k(x,T),onFieldChange:(x,T,A)=>b(x,T,A),onFormChange:(x,T,A)=>N(x,T,A),onTaskToggle:(x,T,A)=>I(x,T,A)});function m(){v.update(p(n),{readonly:e.readonly})}function w(x,T=!1){var A;p(x)&&(n=x,u.update({selectedNodeId:x}),f.update({selectedNodeId:x}),m(),T&&u.focusNode(x),(A=e.onSelectNode)==null||A.call(e,x))}function k(x,T){var A;(x==="complete"||x==="rollback"||x==="resubmit")&&C(T,{status:x==="complete"?"done":"inProgress"}),(A=e.onAction)==null||A.call(e,x,T)}function C(x,T){t={...t,nodes:t.nodes.map(A=>A.id===x?{...A,...T}:A)},u.update({flow:t}),f.update({flow:t}),h.update(t,i),m()}function b(x,T,A){var q;const H=p(x);H&&(T==="conclusion"?C(x,{conclusion:A}):T==="opinion"?C(x,{opinion:A}):ya.includes(T)?C(x,{[T]:A}):C(x,{fields:(H.fields??[]).map(R=>R.id===T?{...R,value:A}:R)}),(q=e.onFieldChange)==null||q.call(e,x,T,A))}function N(x,T,A){var q;const H=p(x);H&&C(x,{form:(H.form??[]).map(R=>R.id===T?{...R,value:A}:R)}),(q=e.onFormChange)==null||q.call(e,x,T,A)}function I(x,T,A){var q;const H=p(x);H&&C(x,{tasks:(H.tasks??[]).map(R=>R.id===T?{...R,done:A}:R)}),(q=e.onTaskToggle)==null||q.call(e,x,T,A)}function E(){var A;if(!g.hidden){g.hidden=!0;return}const x=Array.from(new Set(t.nodes.map(H=>H.completionMode).filter(Boolean))),T=t.nodes.flatMap(H=>H.events??[]);g.innerHTML='<div class="rowvia-nf-rules-head"><strong>流程规则(只读)</strong><button type="button" class="rowvia-nf-ghost" data-action="close-rules">关闭</button></div><dl><dt>流程类型</dt><dd>'+D(t.name)+"</dd><dt>完成方式</dt><dd>"+(x.length?x.map(H=>D(String(H))).join("、"):"未配置")+"</dd><dt>状态计算规则</dt><dd>"+((A=t.statusRules)!=null&&A.length?t.statusRules.map(H=>D(H)).join("<br>"):"未命中规则时按节点流转事件配置显示")+"</dd><dt>节点事件</dt><dd>"+(T.length?T.slice(0,6).map(H=>(H.trigger==="arrive"?"到达:":"完成:")+D(H.text)).join("<br>"):"无")+"</dd><dt>节点状态分布</dt><dd>"+D(ba(t.nodes))+"</dd></dl>",g.hidden=!1}const G=x=>{x.target.closest('[data-action="close-rules"]')&&(g.hidden=!0)};return g.addEventListener("click",G),{onInteraction:d.onInteraction,selectNode(x){w(x,!0)},getSelectedNode:()=>p(n),setFlow(x){t=x,p(n)||(n=a(t)),h.update(t,i),u.update({flow:t,selectedNodeId:n,query:i}),f.update({flow:t,selectedNodeId:n}),m(),g.hidden=!0},updateNode(x,T){C(x,T)},focusNode(x){w(x,!0)},destroy(){o||(o=!0,g.removeEventListener("click",G),h.destroy(),u.destroy(),v.destroy(),f.destroy(),d.destroy(),l.remove())}}}const Sa=(s,e,t={})=>({id:s,name:e,...t});function Oe(s){return{groupId:"g1",completionMode:"and",...s}}function Ea(){const s=(t,n,i)=>Oe({id:t,name:n,status:"pending",groupId:"g4",owner:i,ownerSource:"来源:角色联动",schedule:"09-02 ~ 09-06",estimate:"2d"}),e=[Oe({id:"n-start",name:"开始",status:"done",owner:"系统",ownerSource:"来源:自动创建",schedule:"08-11",estimate:"0d",conclusion:"通过",events:[{trigger:"arrive",text:"需求状态 → 选题"}]}),Oe({id:"n-meeting",name:"选题会",status:"inProgress",owner:"林小满",ownerSource:"来源:自行添加",schedule:"08-12 ~ 08-14",estimate:"3d",worklog:"1.5d",progress:40,progressMode:"按排期自动计算",conclusionOptions:["通过","不通过","有条件通过"],form:[{id:"f-entry",label:"选题入围",required:!0,placeholder:"请填写选题入围(至少五个主题)"}],tasks:[Sa("t-1","请填写选题入围",{blocking:!0,deliverable:"选题清单",owner:"林小满",estimate:"1d",schedule:"08-12"})],fields:[{id:"cf-risk",label:"节点风险",value:"中风险",group:"custom",source:"节点字段 · 单选"}],events:[{trigger:"arrive",text:"需求状态 → 选题"},{trigger:"complete",text:"「选题状态」字段 → 已定稿"}],buttons:[{id:"pass",label:"通过评审",variant:"primary",roles:["节点负责人","管理员"],hint:"数据赋值:整体完成结论 → 已通过"},{id:"reject",label:"不通过",variant:"warning",placement:"more"}],actionRoles:["节点负责人","管理员"],deleteRoles:["管理员"]}),Oe({id:"n-topic",name:"确定选题",status:"pending",groupId:"g1",owner:"周野",schedule:"08-15 ~ 08-16",estimate:"2d",progress:0,progressMode:"手动填写",predecessors:["选题会"]}),Oe({id:"n-ads",name:"广告植入",status:"pending",owner:"商务组",schedule:"08-17",estimate:"1d",predecessors:["确定选题"]}),Oe({id:"n-script",name:"脚本制作",status:"pending",groupId:"g2",owner:"周野",schedule:"08-18 ~ 08-20",estimate:"3d"}),Oe({id:"n-review",name:"脚本评审",status:"pending",groupId:"g2",completionMode:"or",owner:"内容总监",schedule:"08-21",estimate:"1d",conclusionOptions:["通过","不通过"],events:[{trigger:"complete",text:"「脚本状态」字段 → 已评审"}]}),Oe({id:"n-plan",name:"制定计划表",status:"pending",groupId:"g3",owner:"制片人",schedule:"08-22 ~ 08-23",estimate:"2d"}),s("n-shoot","拍摄","导演组"),s("n-edit","剪辑","剪辑师"),s("n-art","美术","美术组"),s("n-audio","收音","录音师"),s("n-dit","DIT","DIT"),s("n-motion","动效","动效师"),s("n-color","调色","调色师"),s("n-mix","混音","混音师"),s("n-cover","封面","设计师"),Oe({id:"n-final",name:"成片",status:"pending",groupId:"g5",milestone:!0,deadline:"09-08",owner:"制片人",schedule:"09-08",estimate:"0d",predecessors:["全部并行节点"]}),Oe({id:"n-final-review",name:"成片评审会",status:"pending",groupId:"g5",completionMode:"or",owner:"内容总监",schedule:"09-09",estimate:"1d",conclusionOptions:["通过","不通过"],form:[{id:"f-pass",label:"成片评审是否通过",required:!0,type:"select",options:["是","否"]},{id:"f-publish",label:"预计发布时间",required:!0,type:"date"}],gates:[{id:"g-conclusion",label:"自定义条件:整体结论 = 通过",met:!1,fixLabel:"查看规则",detail:"完成流转条件 · 校验当前工作项",viewLink:"gates"},{id:"g-linked",label:"关联缺陷全部关闭",met:!1,fixLabel:"查看 3 条",detail:"完成流转条件 · 校验关联工作项",viewLink:"gates"}],events:[{trigger:"complete",text:"需求状态 → 待发布"}]}),Oe({id:"n-publish",name:"发布",status:"pending",groupId:"g5",owner:"运营",schedule:"09-10",estimate:"1d"}),Oe({id:"n-monitor",name:"数据监控",status:"pending",groupId:"g6",completionMode:"auto",owner:"数据组",schedule:"09-11 ~ 09-17",estimate:"5d",progress:0,progressMode:"同步自计算字段",delayed:!1}),Oe({id:"n-retro",name:"项目复盘",status:"pending",groupId:"g6",owner:"制片人",schedule:"09-18",estimate:"1d",delayed:!0,info:"09-18"}),Oe({id:"n-end",name:"结束",status:"pending",groupId:"g6",owner:"系统",estimate:"0d"})];for(const t of e)t.info||(t.info=t.schedule?t.schedule.split(" ~ ")[0]:"");return{id:"video",name:"视频流程",templateVersion:"v3",latestTemplateVersion:"v4",infoField:{label:"排期",position:"right"},statusRules:["整体结论 = 未通过 → 节点状态显示「未通过」","里程碑截止时间早于今天 → 节点状态显示「延期」"],groups:[{id:"g1",name:"前期策划"},{id:"g2",name:"脚本"},{id:"g3",name:"排期"},{id:"g4",name:"制作",layout:"parallel"},{id:"g5",name:"交付"},{id:"g6",name:"复盘"}],nodes:e}}const Ae=s=>Date.parse(`${s}T00:00:00Z`)/864e5,qe=s=>new Date(s*864e5).toISOString().slice(0,10),Ci=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Ae(s))&&qe(Ae(s))===s,dn=s=>!!s.start&&!!s.end;function cn(s,e){const t=new Set(s.map(n=>n.id));if(t.size!==s.length||new Set(e.map(n=>n.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const n of e){if(!t.has(n.personId))throw new Error(`Unknown person: ${n.personId}`);if(!Number.isFinite(n.estimate)||n.estimate<0)throw new Error("Invalid estimate");if(!!n.start!=!!n.end||n.start&&n.end&&(!Ci(n.start)||!Ci(n.end)||n.end<n.start))throw new Error("Invalid date range")}}function xa(s,e=!1){const t=[];return s.filter(dn).slice().sort((n,i)=>n.start.localeCompare(i.start)||n.id.localeCompare(i.id)).map(n=>{let i=e?t.length:t.findIndex(o=>o<Ae(n.start));return i<0&&(i=t.length),t[i]=Ae(n.end),{item:n,lane:i}})}function Si(s){let e=0,t=0;for(const n of s)dn(n)&&e++,t+=n.estimate;return{scheduled:e,unscheduled:s.length-e,estimate:t}}const Ei=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function ka(s,e){const{people:t,items:n,today:i,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:h,children:u,loose:f,colorFirst:g,from:v,days:m,rangeStart:w,rangeEnd:k}=e,C=$=>s.querySelector($),b=C(".ps-rows"),N=()=>[22,43,64,86,120][p],I=()=>n.filter($=>(!l||$.name.includes(l))&&(!r||$.status===r)&&(u||!$.parentId)),E=N(),G=m*E;C(".ps-table").style.width=`${G+200}px`;const x=`${w.slice(0,4)}年 第${Number(w.slice(5,7))}-${Number(k.slice(5,7))}月`;C(".ps-date-label").textContent=x,C('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,C(".ps-zoom").value=String(p);const T=C(".ps-weeks");T.replaceChildren();for(let $=0;$<m;$+=7){const z=document.createElement("span");z.style.width=`${Math.min(7,m-$)*E}px`,z.textContent=`${qe(v+$).slice(5).replace("-","/")}~${qe(v+$+6).slice(5).replace("-","/")}`,T.append(z)}b.replaceChildren();const A=I(),H=new Map;for(const $ of A){const z=H.get($.personId);z?z.push($):H.set($.personId,[$])}const q=new Map(t.map($=>[$.id,Si(H.get($.id)??[])])),R=t.filter($=>o.has($.id)&&(!a||q.get($.id).scheduled>0));d&&R.sort(($,z)=>{const j=q.get($.id),te=q.get(z.id);return(d==="estimate"?j.estimate-te.estimate:j.scheduled-te.scheduled)*(c?-1:1)});const P=document.createElement("div");for(let $=0;$<m;$++){const z=new Date((v+$)*864e5).getUTCDay();if(z!==0&&z!==6)continue;const j=document.createElement("i");j.className="ps-weekend",j.style.left=`${$*E}px`,j.style.width=`${E}px`,P.append(j)}for(const $ of R){const z=H.get($.id)??[],j=q.get($.id),te=xa(z,h),ue=Math.max(0,...te.map(U=>U.lane)),ge=Math.max(f?154:126,60+(ue+1)*(f?48:36)),be=document.createElement("div");be.className="ps-person-row",be.style.height=`${ge}px`,be.dataset.person=$.id;const fe=document.createElement("div");fe.className="ps-person",fe.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${D($.name)}</strong></div><div>已排期项 <b>${j.scheduled}</b></div><div>总估分 <b>${j.estimate.toFixed(2)}</b></div><div>未排期·${j.unscheduled}<button data-action="unplanned" data-person="${D($.id)}">查看</button></div>`;const me=fe.querySelector(".ps-avatar");me.textContent=$.name.slice(-2),me.style.background=$.color||Ei[t.indexOf($)%Ei.length];const Ee=document.createElement("div");Ee.className="ps-timeline",Ee.style.width=`${G}px`,Ee.style.setProperty("--day",`${E}px`);for(const U of P.children)Ee.append(U.cloneNode(!0));const Me=Ae(i)-v;if(Me>=0&&Me<m){const U=document.createElement("i");U.className="ps-today",U.style.left=`${(Me+.5)*E}px`,Ee.append(U)}for(const{item:U,lane:se}of te){const Z=Ae(U.start),W=Ae(U.end);if(W<v||Z>=v+m)continue;const Q=Math.max(0,Z-v)*E,ae=Math.min(m,W-v+1)*E,S=document.createElement("button");S.className=`ps-bar ${g?"ps-color":"ps-content"}`,S.dataset.item=U.id,S.setAttribute("aria-label",`${U.name},${U.start} 至 ${U.end}`),S.style.left=`${Q}px`,S.style.width=`${ae-Q}px`,S.style.top=`${52+se*(f?48:36)}px`,S.style.setProperty("--bar-color",U.color||"#8cafeb"),S.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${D(U.name)}</span><span class="ps-status">${D(U.status)}</span><span class="ps-node">● ${D(U.node)}</span><span class="ps-effort">${U.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,Ee.append(S)}if(!te.length){const U=document.createElement("span");U.className="ps-no-schedule",U.textContent="暂无排期",Ee.append(U)}be.append(fe,Ee),b.append(be)}R.length||(b.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const L=new Set(R.map($=>$.id)),M=A.filter($=>L.has($.personId));C(".ps-total").textContent=`ⓘ 总人数 ${R.length} 总估分 ${Si(M).estimate.toFixed(2)} pd ···`}function Ma(s,e){cn(e.people,e.items);let t=structuredClone(e.people),n=structuredClone(e.items);const i=e.today??new Date().toISOString().slice(0,10);let o=new Set(t.map(W=>W.id)),a=!1,l="",r="",d="",c=!1,p=1,h=!1,u=!1,f=!1,g=!0,v=Ae(i)-new Date(`${i}T00:00:00Z`).getUTCDay(),m=90,w=`${i.slice(0,7)}-01`,k=qe(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7))+1,0)/864e5),C=!1,b=!1;const N=document.createElement("section");N.className="personnel-schedule",N.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${D(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
88
88
  <div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${D(e.workItemLabel??"工作项")}</button><button data-action="sort">☷ 人员排序</button><span class="ps-space"></span><button class="ps-round" data-action="minus" aria-label="缩小">−</button><input class="ps-zoom" type="range" min="0" max="4" step="1" value="1" aria-label="时间缩放"><button class="ps-round" data-action="plus" aria-label="放大">+</button><button class="ps-save" data-action="save">▣ 存为视图</button><button data-action="settings" aria-label="显示设置">⚙</button></div>
89
89
  <div class="ps-scroll"><div class="ps-table"><div class="ps-time-header"><div class="ps-date-nav"><button data-action="date" class="ps-date-label"></button><button data-action="prev" aria-label="上一时间段">‹</button><button data-action="today" aria-label="回到今天">•</button><button data-action="next" aria-label="下一时间段">›</button></div><div class="ps-weeks"></div></div><div class="ps-rows"></div></div></div>
90
- <footer class="ps-total"></footer><div class="ps-popover" hidden></div><aside class="ps-detail" hidden></aside><div class="ps-toast" role="status" hidden></div>`,s.append(I);const A=$e(I,"personnel",e),S=P=>I.querySelector(P),G=S(".ps-scroll"),E=S(".ps-rows"),k=S(".ps-popover"),T=S(".ps-detail"),H=new AbortController,W=H.signal;let R;const O=()=>[22,43,64,86,120][p];function L(P){const z=S(".ps-toast");z.textContent=P,z.hidden=!1,clearTimeout(R),R=setTimeout(()=>z.hidden=!0,2200)}function M(){C||Ca(I,{people:t,items:n,today:i,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:h,children:u,loose:f,colorFirst:g,from:v,days:m,rangeStart:y,rangeEnd:x})}function $(P,z){if(!k.hidden&&k.dataset.kind===P){k.hidden=!0;return}k.dataset.kind=P,k.hidden=!1;const j=I.getBoundingClientRect(),Y=z==null?void 0:z.getBoundingClientRect();if(k.style.left=`${Math.max(12,Math.min(((Y==null?void 0:Y.left)??j.left)-j.left,I.clientWidth-(P==="unplanned"?760:420)-16))}px`,k.style.top=`${Y?Y.bottom-j.top+6:96}px`,k.className=`ps-popover ps-panel-${P}`,P==="people")k.innerHTML=`<div class="ps-panel-title">包含 ${o.size} 人<label><input type="checkbox" data-control="only" ${a?"checked":""}>仅查看有排期的用户</label></div><div class="ps-person-filter"><span>甘特图显示人员</span><span>包含</span><span>全部排期人员</span></div><input class="ps-person-search" placeholder="搜索人员" aria-label="搜索人员"><div class="ps-person-options">${t.map(re=>`<label><input type="checkbox" data-person="${D(re.id)}" ${o.has(re.id)?"checked":""}>${D(re.name)}</label>`).join("")}</div>`;else if(P==="sort")k.innerHTML=`<div class="ps-panel-title">设置排序条件 ⓘ</div><div class="ps-sort-fields"><select aria-label="排序字段" data-control="sort"><option value="">请选择排序项</option><option value="estimate">总估分</option><option value="scheduled">已排期项</option></select><button data-action="asc" class="${c?"":"selected"}">小 → 大</button><button data-action="desc" class="${c?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,k.querySelector("select").value=d;else if(P==="filter")k.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${D(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${D(l)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(n.map(re=>re.status))].map(re=>`<option>${D(re)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,k.querySelector("select").value=r;else if(P==="settings")k.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${h?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${u?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${f?"":"selected"}">紧凑</button><button data-action="loose" class="${f?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${g?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${g?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(P==="date")ee();else if(P==="save")k.innerHTML='<div class="ps-panel-title">存为视图</div><input data-view-name placeholder="视图名称" aria-label="视图名称"><button class="ps-primary" data-action="save-view">保存</button>';else if(P==="views"){const re=xe();k.innerHTML=`<div class="ps-panel-title">视图列表</div>${re.length?re.map((Ce,N)=>`<button class="ps-view" data-view="${N}">▦ ${D(Ce.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let _=new Date(`${y}T00:00:00Z`),U=!1;function ee(){let P=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${y}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${x}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let z=0;z<2;z++){const j=new Date(Date.UTC(_.getUTCFullYear(),_.getUTCMonth()+z,1));P+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${j.getUTCFullYear()}年 ${j.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(re=>`<span>${re}</span>`).join("")}`;for(let re=0;re<j.getUTCDay();re++)P+="<span></span>";const Y=new Date(Date.UTC(j.getUTCFullYear(),j.getUTCMonth()+1,0)).getUTCDate();for(let re=1;re<=Y;re++){const Ce=ze(Date.UTC(j.getUTCFullYear(),j.getUTCMonth(),re)/864e5);P+=`<button data-date="${Ce}" class="${Ce>=y&&Ce<=x?"in-range":""} ${Ce===y||Ce===x?"selected":""}">${re}</button>`}P+="</div></div>"}k.innerHTML=P+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((z,j)=>`<button data-preset="${j}">${z}</button>`).join("")}</div>`}function ae(){x<y&&([y,x]=[x,y]),v=De(y),v-=new Date(v*864e5).getUTCDay(),m=Math.max(35,De(x)-v+8),G.scrollLeft=0,M()}function he(P,z){var re;if(!n.some(Ce=>Ce.id===P))throw new Error(`Unknown schedule item: ${P}`);const j=n.map(Ce=>Ce.id===P?{...Ce,...z}:Ce);an(t,j),n=j,M();const Y=n.find(Ce=>Ce.id===P);Y&&((re=e.onItemChange)==null||re.call(e,structuredClone(Y)))}function be(P){var j;const z=n.find(Y=>Y.id===P);(j=e.onItemOpen)==null||j.call(e,structuredClone(z)),T.hidden=!1,T.dataset.item=P,T.innerHTML=`<header><strong>${D(z.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${D(z.status)}</span><h3>● ${D(z.node)}</h3><form><label>名称<input name="name" required value="${D(z.name)}"></label><label>负责人<select name="personId">${t.map(Y=>`<option value="${D(Y.id)}" ${Y.id===z.personId?"selected":""}>${D(Y.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${z.estimate}" required></label><label>开始日期<input type="date" name="start" value="${z.start||""}"></label><label>结束日期<input type="date" name="end" value="${z.end||""}"></label><p class="ps-error" role="alert"></p><button class="ps-primary" type="submit">保存排期</button><button type="button" data-action="unschedule">移至未排期</button></form></div>`}function fe(P,z){$("unplanned",z),k.hidden=!1;const j=t.find(Y=>Y.id===P);k.innerHTML=`<div class="ps-panel-title">未排期工作项 ${D(j.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${n.filter(Y=>Y.personId===P&&!on(Y)).map(Y=>`<tr><td><button data-open="${D(Y.id)}">${D(Y.name)}</button></td><td>● ${D(Y.node)}</td><td><input type="number" min="0" step="0.1" value="${Y.estimate||""}" placeholder="待填" data-estimate="${D(Y.id)}" aria-label="${D(Y.name)}估分"></td><td><button class="ps-link" data-open="${D(Y.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const ve=e.viewStorageKey??"rowvia-personnel-views-v1";function xe(){try{const P=JSON.parse(localStorage.getItem(ve)||"[]");return Array.isArray(P)?P:[]}catch{return[]}}I.addEventListener("click",P=>{const z=P.target,j=z.closest("button");if(!j)return;if(j.dataset.open){k.hidden=!0,be(j.dataset.open);return}if(j.dataset.item){b||be(j.dataset.item);return}if(j.dataset.date){U?(x=j.dataset.date,U=!1,ae()):(y=j.dataset.date,x=y,U=!0),ee();return}if(j.dataset.preset){const re=Number(j.dataset.preset),Ce=De(i),N=new Date(Ce*864e5);y=ze(re<2?Ce-N.getUTCDay():re<4?Date.UTC(N.getUTCFullYear(),N.getUTCMonth(),1)/864e5:Ce),x=ze(re===2||re===3?Date.UTC(N.getUTCFullYear(),N.getUTCMonth()+(re===2?1:2),0)/864e5:De(y)+[6,13,29,60,13,59,364][re]),U=!1,ae(),k.hidden=!0;return}if(j.dataset.view){const re=xe()[Number(j.dataset.view)];re&&(o=new Set(re.selected.filter(Ce=>t.some(N=>N.id===Ce))),{query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:y,rangeEnd:x,expanded:h,children:u,loose:f,colorFirst:g,onlyScheduled:a}=re,M(),k.hidden=!0,L(`已打开 ${re.name}`));return}const Y=j.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(Y||"")){$(Y,j);return}if(Y==="unplanned"){fe(j.dataset.person,j);return}if(Y==="close-detail"&&(T.hidden=!0),Y==="unschedule"&&(he(T.dataset.item,{start:null,end:null}),T.hidden=!0),(Y==="plus"||Y==="minus")&&(p=Math.max(0,Math.min(4,p+(Y==="plus"?1:-1))),M()),(Y==="prev"||Y==="next"||Y==="today")&&(v=Y==="today"?De(i)-new Date(`${i}T00:00:00Z`).getUTCDay():v+(Y==="prev"?-14:14),y=ze(v),x=ze(v+59),G.scrollLeft=0,M()),(Y==="asc"||Y==="desc"||Y==="clear-sort")&&(c=Y==="desc",Y==="clear-sort"&&(d=""),M(),k.hidden=!0),Y==="clear-filter"&&(l="",r="",M(),k.hidden=!0),["compact","loose","content","color"].includes(Y||"")&&(Y==="compact"||Y==="loose"?f=Y==="loose":g=Y==="color",M(),k.hidden=!0,$("settings",S('[data-action="settings"]'))),(Y==="cal-prev"||Y==="cal-next")&&(_=new Date(Date.UTC(_.getUTCFullYear(),_.getUTCMonth()+(Y==="cal-prev"?-1:1),1)),ee()),Y==="save-view"){const re=k.querySelector("[data-view-name]").value.trim();if(!re)return;const Ce=xe();Ce.push({name:re,selected:[...o],query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:y,rangeEnd:x,expanded:h,children:u,loose:f,colorFirst:g,onlyScheduled:a});try{localStorage.setItem(ve,JSON.stringify(Ce)),k.hidden=!0,L("视图已保存")}catch{L("浏览器存储不可用,视图未保存")}}Y==="schedule"&&(k.hidden=!0,T.hidden=!0)},{signal:W}),I.addEventListener("input",P=>{const z=P.target;z.classList.contains("ps-zoom")&&(p=Number(z.value),M()),z.classList.contains("ps-person-search")&&k.querySelectorAll(".ps-person-options label").forEach(j=>{var Y;return j.hidden=!((Y=j.textContent)!=null&&Y.includes(z.value))}),z.dataset.control==="query"&&(l=z.value,M())},{signal:W}),I.addEventListener("change",P=>{const z=P.target;if(z.dataset.person&&(z.checked?o.add(z.dataset.person):o.delete(z.dataset.person),M()),z.dataset.estimate){const j=Number(z.value);Number.isFinite(j)&&j>=0&&he(z.dataset.estimate,{estimate:j});return}switch(z.dataset.control){case"only":a=z.checked;break;case"sort":d=z.value;break;case"status":r=z.value;break;case"expanded":h=z.checked;break;case"children":u=z.checked;break;case"range-start":z.value&&(y=z.value,ae(),ee());return;case"range-end":z.value&&(x=z.value,ae(),ee());return}M()},{signal:W}),T.addEventListener("submit",P=>{P.preventDefault();const z=new FormData(P.target),j=String(z.get("start")||"")||null,Y=String(z.get("end")||"")||null;if(!!j!=!!Y||j&&Y&&j>Y){T.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}he(T.dataset.item,{name:String(z.get("name")),personId:String(z.get("personId")),estimate:Number(z.get("estimate")),start:j,end:Y}),T.hidden=!0,L("排期已更新")},{signal:W}),document.addEventListener("pointerdown",P=>{I.contains(P.target)?!k.contains(P.target)&&!P.target.closest("[data-action]")&&(k.hidden=!0):k.hidden=!0},{signal:W}),I.addEventListener("keydown",P=>{P.key==="Escape"&&(k.hidden=!0,T.hidden=!0)},{signal:W});let me=null;return E.addEventListener("pointerdown",P=>{const z=P.target,j=z.closest(".ps-bar");if(!j||P.button!==0)return;const Y=n.find(re=>re.id===j.dataset.item);b=!1,me={id:Y.id,x:P.clientX,start:De(Y.start),end:De(Y.end),edge:z.dataset.edge||"move",bar:j,left:parseFloat(j.style.left),size:parseFloat(j.style.width),delta:0,scroll:G.scrollLeft}},{signal:W}),document.addEventListener("pointermove",P=>{if(!me)return;const z=Math.round((P.clientX-me.x+G.scrollLeft-me.scroll)/O());me.delta=me.edge==="start"?Math.min(z,me.end-me.start):me.edge==="end"?Math.max(z,me.start-me.end):z,Math.abs(P.clientX-me.x)>4&&(b=!0),b&&(me.bar.style.opacity=".8",me.edge==="move"?me.bar.style.transform=`translateX(${me.delta*O()}px)`:(me.bar.style.left=`${me.left+(me.edge==="start"?me.delta*O():0)}px`,me.bar.style.width=`${me.size+(me.edge==="start"?-1:1)*me.delta*O()}px`))},{signal:W}),document.addEventListener("pointerup",()=>{if(!me)return;const P=me;me=null,b&&(he(P.id,{start:ze(P.start+(P.edge==="end"?0:P.delta)),end:ze(P.end+(P.edge==="start"?0:P.delta))}),L("排期已更新"))},{signal:W}),M(),{onInteraction:A.onInteraction,setData(P,z){an(P,z),t=structuredClone(P),n=structuredClone(z),o=new Set(t.map(j=>j.id)),k.hidden=!0,T.hidden=!0,M()},getItems:()=>structuredClone(n),updateItem:he,setPeople(P){o=new Set(P.filter(z=>t.some(j=>j.id===z))),M()},destroy(){C=!0,H.abort(),clearTimeout(R),A.destroy(),I.remove()}}}const wi={pencil:'<path d="m15 3 6 6-12 12H3v-6ZM13 5l6 6"/>',transition:'<path d="M4 8h14l-4-4m4 4-4 4M20 16H6l4-4m-4 4 4 4"/>',expand:'<path d="M15 3h6v6m0-6-7 7M9 21H3v-6m0 6 7-7"/>',check:'<circle cx="12" cy="12" r="8"/><path d="m8 12 3 3 5-6"/>',plus:'<circle cx="12" cy="12" r="9"/><path d="M12 7v10M7 12h10"/>',add:'<path d="M12 4v16M4 12h16"/>',close:'<path d="m6 6 12 12M6 18 18 6"/>',back:'<path d="m15 18-6-6 6-6"/>',filter:'<path d="M3 4h18l-7 8v7l-4 2v-9Z"/>',sort:'<path d="M4 5h16M4 11h11M4 17h6"/>',group:'<path d="m3 13 10-10h8v8L11 21Z"/><circle cx="17" cy="7" r="1"/>',color:'<path d="m10 3 10 10-8 8L2 11Z M4 13h14M10 3 7 0"/><path d="M21 17q4 5 0 5q-4 0 0-5"/>',search:'<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6M2 3h5M2 9h2M2 16h5"/>',save:'<path d="M4 3h13l4 4v14H3V3h1ZM8 3v7h8V3M7 21v-7h10v7"/>',down:'<path d="m6 9 6 6 6-6"/>',up:'<path d="m6 15 6-6 6 6"/>',link:'<path d="m10 14 4-4M8 16l-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0M16 8l1-1a4 4 0 0 1 6 6l-5 5a4 4 0 0 1-6 0"/>',edit:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><path d="M14 17h8m-4-4v8"/>',book:'<path d="M6 3h12v18l-6-4-6 4Z"/>',people:'<circle cx="9" cy="8" r="3"/><path d="M3 21v-3a6 6 0 0 1 12 0v3ZM17 4a3 3 0 0 1 0 6M18 14q4 1 4 7"/>',table:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M3 14h18M9 9v11M15 9v11"/>',chart:'<circle cx="12" cy="12" r="9"/><path d="M12 3v9h9"/>',menu:'<path d="M4 6h16M4 12h12M4 18h16"/>',more:'<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',inbox:'<path d="m5 4-3 10v6h20v-6L19 4ZM2 14h6l2 3h4l2-3h6"/>'},Me=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${wi[s]||wi.check}</svg>`,Te=(s,e,t="",n="")=>`<button type="button" data-action="${s}" class="${n}" aria-label="${D(e)}">${t?Me(t):""}${e?`<span>${D(e)}</span>`:""}</button>`,Vt=(s,e,t="")=>`<select ${t}>${s.map(([n,i])=>`<option value="${D(n)}" ${n===e?"selected":""}>${D(i)}</option>`).join("")}</select>`;function Ea(s){var c,p;const e=s.detail,t=new Set(s.nodes.filter(h=>h.hiddenReason).map(h=>h.id));for(const h of(e==null?void 0:e.tags)??[])h.enabled===!1&&((c=h.nodeIds)==null||c.forEach(u=>t.add(u)));for(const h of(e==null?void 0:e.switches)??[])h.checked||(p=h.nodeIds)==null||p.forEach(u=>t.add(u));const n=s.nodes.filter(h=>!t.has(h.id)),i=new Set(n.map(h=>h.id)),o=(e==null?void 0:e.connections)??xa(s),a=(h,u=new Set)=>u.has(h)?[]:(u.add(h),i.has(h)?[h]:(o[h]??[]).flatMap(f=>a(f,new Set(u)))),l=n.flatMap(h=>[...new Set((o[h.id]??[]).flatMap(u=>a(u)))].map(u=>({from:h.id,to:u}))),r=(h,u,f,g=new Set)=>h===u?!0:g.has(h)?!1:(g.add(h),l.some(v=>v!==f&&v.from===h&&r(v.to,u,f,g))),d=l.filter(h=>!r(h.from,h.to,h));return{controls:{roles:(e==null?void 0:e.tags)??[],switches:(e==null?void 0:e.switches)??[]},graph:{nodes:n,edges:d},nodeList:n,node:h=>{var f,g,v;const u=(f=e==null?void 0:e.nodes)==null?void 0:f[h.id];return{data:h,form:((g=h.form)==null?void 0:g.filter(m=>{var y,x;return!m.visibleWhen||((x=(y=h.form)==null?void 0:y.find(C=>C.id===m.visibleWhen.fieldId))==null?void 0:x.value)===m.visibleWhen.value}))??[],fields:(u==null?void 0:u.fields)??(e==null?void 0:e.fields)??[{key:"owner",label:"负责人"},{key:"schedule",label:"总排期"}],sections:(u==null?void 0:u.sections)??((v=h.form)!=null&&v.length?["form","tasks"]:["tasks"]),completeLabel:(u==null?void 0:u.completeLabel)??"完成",deletable:(u==null?void 0:u.deletable)!==!1}}}}function xa(s){const e=[];for(const t of s.groups){const n=s.nodes.filter(i=>i.groupId===t.id);t.layout==="parallel"?e.push(n):e.push(...n.map(i=>[i]))}return e.push(...s.nodes.filter(t=>!s.groups.some(n=>n.id===t.groupId)).map(t=>[t])),Object.fromEntries(e.flatMap((t,n)=>t.map(i=>{var o;return[i.id,((o=e[n+1])==null?void 0:o.map(a=>a.id))??[]]})))}function ka(s){const e=new Map(s.nodes.map(l=>[l.id,0]));for(let l=0;l<s.nodes.length;l++){let r=!1;for(const d of s.edges){const c=Math.min(s.nodes.length-1,(e.get(d.from)??0)+1);(e.get(d.to)??0)<c&&(e.set(d.to,c),r=!0)}if(!r)break}const t=[...new Set(e.values())].sort((l,r)=>l-r).map(l=>s.nodes.filter(r=>e.get(r.id)===l));let n=64;const i=t.flatMap(l=>{const r=Math.max(...l.map(c=>Math.max(55,c.name.length*13+27))),d=l.map((c,p)=>({node:c,x:n,y:196+(p-(l.length-1)/2)*40,width:r}));return n+=r+48,d}),o=new Map(i.map(l=>[l.node.id,l])),a=s.edges.flatMap(l=>{const r=o.get(l.from),d=o.get(l.to);if(!r||!d)return[];const c=r.x+r.width,p=r.y+14,h=d.y+14;return[`M ${c} ${p} C ${c+24} ${p} ${d.x-24} ${h} ${d.x} ${h}`]});return{nodes:i,paths:a,width:n+16}}const Ae=s=>`<svg class="wf-icon" viewBox="0 0 16 16" aria-hidden="true">${{caret:'<path d="M13.706 6.437 8.503 12.421a.667.667 0 0 1-1.006 0L2.293 6.437a.667.667 0 0 1 .503-1.104h10.407a.667.667 0 0 1 .503 1.104Z" fill="currentColor"/>',chevron:'<path d="m4 6 4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5"/>',more:'<g fill="currentColor"><circle cx="3" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="13" cy="8" r="1.5"/></g>',expand:'<path d="M6 2H2v4m8-4h4v4M2 10v4h4m8-4v4h-4" fill="none" stroke="currentColor" stroke-width="1.3"/>',filter:'<path d="M2 3h12L9 8v5l-2-1V8Z" fill="none" stroke="currentColor" stroke-width="1.3"/>',list:'<path d="M6 4h8M6 8h8M6 12h8M2 4h1M2 8h1M2 12h1" stroke="currentColor" stroke-width="1.4"/>',detail:'<rect x="2" y="2" width="12" height="12" rx="2" fill="none" stroke="currentColor"/><path d="M5 6h6M5 9h6" stroke="currentColor"/>',plus:'<path d="M8 2v12M2 8h12" stroke="currentColor" stroke-width="1.5"/>'}[s]}</svg>`,Gt={pending:"未开始",inProgress:"进行中",done:"已完成",failed:"未通过"},yi={estimate:"填写估分","group-chat":"节点建群","delete-node":"删除节点"};function Ma(s){var le,Se;let e={...s},t=s.flow,n=t.detail,i=!1,o=!1,a=0;const l=new Map,r=document.createElement("section");r.className="workitem-module-detail-workflow rv-workflow-detail",r.dataset.module="detail:workflow";const d=document.createElement("section");d.className="workflow-node-details rv-workflow-detail",d.dataset.module="detail:tabs:schedule";const c=new AbortController;let p=s.selectedNodeId??((le=t.nodes.find(F=>F.status==="inProgress"))==null?void 0:le.id)??((Se=t.nodes[0])==null?void 0:Se.id)??"";const h=new Set([p]);let u="details",f="",g=1;const v=new Set,m=new Set,y=new Set,x=new Map,C=F=>t.nodes.find(B=>B.id===F),b=F=>{var B,q,Z;return((Z=(q=(B=e.context)==null?void 0:B.people)==null?void 0:q.find(ne=>ne.id===F))==null?void 0:Z.name)??F??""},I=F=>`<i class="wf-dot ${F.status}" aria-hidden="true"></i>`,A=F=>`${I(F)}<strong>${D(F.name)}</strong><span class="wf-status ${F.status}">${Gt[F.status]}</span>`,S=()=>Ea(t);function G(F,B,q){var ne;const Z=e.onCommand||(F==="configure"?e.onFlowChange:F==="action"?e.onAction:F==="create-task"?e.onCreateTask||e.onChange:F==="delete"?e.onDelete:F==="complete"&&e.onComplete||e.onChange);return!i&&!o&&!e.readonly&&!!Z&&((ne=e.can)==null?void 0:ne.call(e,F,B,q))!==!1}function E(F){var B;if(F.type==="delete-node")return"delete";if(F.type==="update-flow")return"configure";if(F.type==="action")return F.actionId==="__create-task"?"create-task":"action";if(F.patch.status)return"complete";if(F.patch.tasks){const q=C(F.nodeId);return F.patch.tasks.length>(((B=q==null?void 0:q.tasks)==null?void 0:B.length)??0)?"create-task":"toggle-task"}return"edit"}function k(F){var q,Z,ne,Q;const B={flow:t,signal:c.signal};return e.onCommand?e.onCommand(F,B):F.type==="delete-node"?(q=e.onDelete)==null?void 0:q.call(e,F.nodeId,B):F.type==="update-flow"?(Z=e.onFlowChange)==null?void 0:Z.call(e,F.detail,B):F.type==="action"?F.actionId==="__create-task"&&e.onCreateTask?e.onCreateTask(F.nodeId,B):(ne=e.onAction)==null?void 0:ne.call(e,F.nodeId,F.actionId,B):F.patch.status==="done"&&e.onComplete?e.onComplete(F.nodeId,B):(Q=e.onChange)==null?void 0:Q.call(e,F.nodeId,F.patch,F.detail,B)}async function T(F){var J;const B="nodeId"in F?C(F.nodeId):void 0,q=F.type==="action"?F.actionId:F.type==="update-node"?Object.keys(F.patch)[0]:void 0,Z=F.type!=="update-node"||Object.keys(F.patch).every(ie=>G(E({...F,patch:{[ie]:F.patch[ie]}}),B,ie)),ne=F.type!=="update-node"||[...(F.patch.form??[]).filter(ie=>{var se,de;return ie.value!==((de=(se=B==null?void 0:B.form)==null?void 0:se.find(ue=>ue.id===ie.id))==null?void 0:de.value)}),...(F.patch.fields??[]).filter(ie=>{var se,de;return ie.value!==((de=(se=B==null?void 0:B.fields)==null?void 0:se.find(ue=>ue.id===ie.id))==null?void 0:de.value)})].every(ie=>{var se,de,ue;return((se=e.can)==null?void 0:se.call(e,"edit",B,ie.id))!==!1&&!((ue=(de=B==null?void 0:B.fields)==null?void 0:de.find(ke=>ke.id===ie.id))!=null&&ue.readonly)});if(!G(E(F),B,q)||!Z||!ne||F.type==="delete-node"&&B&&!S().node(B).deletable)return i||xe(),!1;const Q=a;o=!0,r.querySelectorAll(".wf-error").forEach(ie=>ie.remove()),O(r),O(d);let oe,te=!1;try{const ie=k(F),se=ie instanceof Promise?await ie:ie;return i?!1:(se&&a===Q&&(t=se,n=se.detail,a++),!0)}catch(ie){return oe=ie,te=!0,!1}finally{if(o=!1,!i&&(xe(),te)){const ie=document.createElement("p");ie.className="wf-error",ie.role="alert",ie.textContent=oe instanceof Error?oe.message:"保存失败,请重试",r.querySelector(".wf-card-area").prepend(ie),(J=e.onError)==null||J.call(e,oe,F)}}}function H(F){var B;(B=l.get(F))==null||B.forEach(q=>q()),l.delete(F)}function W(F,B){return{node:F,surface:B===r?"selected":"list",readonly:!G("edit",F),pending:o,signal:c.signal,context:e.context??{currentUser:e.currentUser,workItems:e.workItems},can:(q,Z)=>G(q,F,Z),commit:(q,Z="更新节点字段")=>P(F,q,Z),action:q=>T({type:"action",nodeId:F.id,actionId:q})}}function R(F){const B=[];l.set(F,B),F.querySelectorAll("[data-node]").forEach(q=>{var J,ie;const Z=C(q.dataset.node);if(!Z)return;const ne=W(Z,F);e.renderTaskField&&q.querySelectorAll("[data-task-cell]").forEach(se=>{var ge,ce;const de=(ge=Z.tasks)==null?void 0:ge.find(Le=>Le.id===se.dataset.taskCell),ue=(ce=e.taskColumns)==null?void 0:ce.call(e,Z).find(Le=>Le.key===se.dataset.taskColumn);if(!de||!ue)return;const ke=e.renderTaskField(se,de,ue,ne);ke&&B.push(ke)});const Q=(F===r?"selected:":"list:")+Z.id;if(m.has(Q)){const se=q.querySelector(".wf-card-body"),de=q.querySelector(".wf-node-schedule");se&&(se.hidden=!0),de&&(de.hidden=!0),(J=q.querySelector('[data-wf="collapse-card"]'))==null||J.setAttribute("aria-expanded","false")}if(y.has(Q)){const se=q.querySelector(".wf-task-table");se&&(se.hidden=!0),(ie=q.querySelector('[data-wf="toggle-tasks"]'))==null||ie.setAttribute("aria-expanded","false")}const oe=q.querySelector("[data-node-fields-slot]");if(oe&&e.renderNodeFields){const se=e.renderNodeFields(Z,oe,ne);se&&B.push(se)}const te=q.querySelector("[data-node-form-slot]");if(te&&e.renderNodeForm){const se=e.renderNodeForm(Z,te,ne);se&&B.push(se)}if(e.renderField&&q.querySelectorAll("[data-field-slot]").forEach(se=>{var ke;const de=[...S().node(Z).form,...Z.fields??[]].find(ge=>ge.id===se.dataset.fieldSlot);if(!de)return;const ue=e.renderField(se,de,{...ne,readonly:ne.readonly||((ke=e.can)==null?void 0:ke.call(e,"edit",Z,de.id))===!1||"readonly"in de&&!!de.readonly});ue&&B.push(ue)}),e.renderSystemField&&q.querySelectorAll("[data-system-slot]").forEach(se=>{var ke;const de=S().node(Z).fields.find(ge=>ge.key===se.dataset.systemSlot);if(!de)return;const ue=e.renderSystemField(se,de,{...ne,readonly:ne.readonly||((ke=e.can)==null?void 0:ke.call(e,"edit",Z,de.key))===!1});ue&&B.push(ue)}),e.renderActions){const se=q.querySelector("[data-actions-slot]");if(se){const de=e.renderActions(se,Z.buttons??[],ne);de&&B.push(de)}}}),O(F)}function O(F){F.setAttribute("aria-busy",String(o)),F.querySelectorAll("input,button,select").forEach(B=>{var oe,te,J;const q=C(((oe=B.closest("[data-node]"))==null?void 0:oe.dataset.node)??""),Z=B.dataset.wf;let ne,Q;(B.dataset.field||B.dataset.form||B.dataset.nodeField||Z==="edit-reference"||Z==="estimate")&&(ne="edit",Q=B.dataset.field??B.dataset.form??B.dataset.nodeField??B.dataset.referenceField??"estimate"),B.dataset.task&&(ne="toggle-task"),Z==="add-task"&&(ne="create-task"),Z==="complete"&&(ne="complete"),(Z==="delete-node"||Z==="confirm-delete")&&(ne="delete"),(B.dataset.switch||B.dataset.removeTag)&&(ne="configure"),(B.dataset.action||Z==="group-chat")&&(ne="action",Q=B.dataset.action??Z),ne&&(B.disabled=!G(ne,q,Q)||ne==="delete"&&!!q&&!S().node(q).deletable||!!B.dataset.nodeField&&!!((J=(te=q==null?void 0:q.fields)==null?void 0:te.find(ie=>ie.id===B.dataset.nodeField))!=null&&J.readonly))})}function L(F){var B;return!((B=F.fields)!=null&&B.length)||e.renderNodeForm?"":'<div class="wf-node-form"><div class="wf-form-fields">'+F.fields.map(q=>e.renderField?'<div data-field-slot="'+D(q.id)+'"></div>':"<label><span>"+D(q.label)+'</span><input data-node-field="'+D(q.id)+'" aria-label="'+D(q.label)+'" value="'+D(q.value??"")+'"></label>').join("")+"</div></div>"}function M(F,B){return e.renderActions?B==="inline"?"<span data-actions-slot></span>":"":(F.buttons??[]).filter(q=>(q.placement??"inline")===B).map(q=>'<button type="button" data-action="'+D(q.id)+'" class="wf-custom-action '+D(q.variant??"normal")+'" title="'+D(q.hint??"")+'">'+D(q.label)+"</button>").join("")}function $(F,B){var ke;const q=`${B}:${F.id}`,Z=F.tasks??[],ne=x.get(q)??0,Q=Z.filter(ge=>{var ce;return ne===2?!ge.done:ne===3?ge.done:ne===1?ge.owner===(((ce=e.context)==null?void 0:ce.currentUser)??e.currentUser??"体验官"):!0}),oe=v.has(q),te=((ke=e.taskColumns)==null?void 0:ke.call(e,F))??[],ie=[...(oe?["name","owner","estimate","schedule","deliverable"]:["name","deliverable","owner","estimate","schedule"]).filter(ge=>!te.some(ce=>ce.key===ge)),...te.map(ge=>ge.key)],se={name:"名称",deliverable:"交付物",owner:"当前负责人",estimate:"估分",schedule:"排期",...Object.fromEntries(te.map(ge=>[ge.key,ge.label]))},de=(ge,ce)=>String(ge[ce]??""),ue=te.length?' style="grid-template-columns:repeat('+ie.length+",minmax(120px,1fr));min-width:"+ie.length*120+'px"':"";return`<section class="wf-tasks" data-module="node:task"><div class="wf-section-head"><div class="wf-task-title"><button type="button" data-wf="toggle-tasks" aria-label="折叠任务" aria-expanded="true"><span class="wf-caret">${Ae("caret")}</span></button><button type="button" data-wf="task-filter">${["全部任务","我参与的","未完成","已完成"][ne]} (${Z.filter(ge=>ge.done).length}/${Z.length}) ${Ae("chevron")}</button></div><button type="button" data-wf="expand-tasks">${Ae(oe?"list":"expand")} ${oe?"列表模式":"展开模式"}</button></div><div class="wf-task-table ${oe?"is-expanded":""}"><div class="wf-task-row wf-task-heading"${ue}>${ie.map(ge=>`<span>${se[ge]}</span>`).join("")}</div>${Q.map(ge=>`<div class="wf-task-row"${ue}>${ie.map(ce=>ce==="name"?`<label><input type="checkbox" data-task="${D(ge.id)}" aria-label="完成任务:${D(ge.name)}" ${ge.done?"checked":""}><span title="${D(ge.name)}">${D(ge.name)}</span></label>`:te.some(Le=>Le.key===ce)?`<span data-task-cell="${D(ge.id)}" data-task-column="${D(ce)}"></span>`:`<span class="${ce==="deliverable"?"wf-task-deliverable":""}" title="${D((ce==="owner"?b(de(ge,ce)):de(ge,ce))||"暂无")}">${D((ce==="owner"?b(de(ge,ce)):de(ge,ce))||(oe?"待填":"暂无"))}</span>`).join("")}</div>`).join("")}<button type="button" class="wf-add-task" data-wf="add-task">${Ae("plus")} 新增任务</button></div></section>`}function _(F){return e.renderNodeFields?'<div class="wf-fields" data-module="node:schedule" data-node-fields-slot></div>':'<div class="wf-fields" data-module="node:schedule">'+S().node(F).fields.map(B=>{var Q;const q=F[B.key]??"",Z=(Q=e.context)==null?void 0:Q.people,ne=e.renderSystemField?'<span data-system-slot="'+B.key+'"></span>':B.key==="owner"&&Z?'<select data-field="owner" aria-label="'+D(B.label)+'"><option value="">待填</option>'+(q&&!Z.some(oe=>oe.id===q)?'<option selected value="'+D(q)+'">'+D(q)+"</option>":"")+Z.map(oe=>'<option value="'+D(oe.id)+'"'+(oe.id===q?" selected":"")+">"+D(oe.name)+"</option>").join("")+"</select>":'<input data-field="'+B.key+'" aria-label="'+D(B.label)+'" placeholder="待填" value="'+D(q)+'">';return'<label class="wf-field-'+B.key+'"><span>'+D(B.label)+"</span>"+ne+"</label>"}).join("")+"</div>"}function U(F){if(e.renderNodeForm)return'<details class="wf-node-form" data-module="node:form" open><summary><span class="wf-caret">'+Ae("caret")+'</span>节点表单</summary><div class="wf-form-fields" data-node-form-slot></div></details>';const B=S().node(F).form;return B.length?`<details class="wf-node-form" data-module="node:form" open><summary><span class="wf-caret">${Ae("caret")}</span>节点表单</summary><div class="wf-form-fields">${B.map(q=>`<div class="wf-form-row"><label><span>${D(q.label)}${q.required?"<b> *</b>":""}</span>${e.renderField?`<span data-field-slot="${D(q.id)}"></span>`:q.control==="workItemSelect"?`<button type="button" class="wf-reference-field ${q.value?"":"is-empty"}" data-wf="edit-reference" data-reference-field="${D(q.id)}" aria-label="${D(q.label)}"><span>${q.value?q.value.split(",").map(Z=>{var ne,Q,oe;return D(((oe=(Q=((ne=e.context)==null?void 0:ne.workItems)??e.workItems)==null?void 0:Q.find(te=>te.id===Z))==null?void 0:oe.name)??Z)}).join("、"):"待填"}</span>${Ae("chevron")}</button>`:q.type==="select"?`<select data-form="${D(q.id)}" aria-label="${D(q.label)}"><option value="">待填</option>${(q.options??[]).map(Z=>`<option ${Z===q.value?"selected":""}>${D(Z)}</option>`).join("")}</select>`:`<input data-form="${D(q.id)}" type="${q.type==="date"?"date":q.type==="number"?"number":"text"}" aria-label="${D(q.label)}" placeholder="待填" value="${D(q.value||"")}">`}</label></div>`).join("")}</div></details>`:""}function ee(F,B){return B?"":`<div class="wf-card-actions" data-module="node:button-group">${F.status==="inProgress"?`<button type="button" class="wf-complete" data-wf="complete">${D(S().node(F).completeLabel)}</button>`:`<span class="wf-state-hint">${Gt[F.status]}</span>`}${M(F,"inline")}<button type="button" data-wf="more" class="wf-more" aria-label="节点更多操作" aria-expanded="false">${Ae("more")}</button></div>`}function ae(F,B=!1,q="selected"){const ne=S().node(F).sections.map(Q=>Q==="form"?B?"":U(F):$(F,q)).join("");return`<article class="wf-card" data-module="workflow:node" data-surface="${q}" data-node="${D(F.id)}"><div class="wf-node-basic" data-module="node:basic"><header class="wf-card-head"><button type="button" class="wf-card-title" data-wf="collapse-card" aria-expanded="true"><span class="wf-caret">${Ae("caret")}</span>${A(F)}</button>${ee(F,B)}</header><div class="wf-node-schedule">${_(F)}</div></div><div class="wf-card-body wf-node-sections">${B?"":L(F)}${ne}</div></article>`}function he(){r.querySelector(".wf-meta").innerHTML=`<div class="wf-roles">${((n==null?void 0:n.tags)??[]).filter(F=>F.enabled!==!1).map(F=>`<span class="wf-role" style="background:${D(F.color||"#eff0f1")}">${D(F.label)}<button type="button" data-remove-tag="${D(F.id)}" aria-label="移除${D(F.label)}">×</button></span>`).join("")}</div>${n!=null&&n.tags.length&&n.switches.length?'<i class="wf-meta-divider"></i>':""}${((n==null?void 0:n.switches)??[]).map(F=>`<label class="wf-switch"><input type="checkbox" data-switch="${D(F.id)}" ${F.checked?"checked":""}>${D(F.label)}</label>`).join("")}`,O(r)}function be(){const F=r.querySelector(".wf-canvas-viewport"),B=F.scrollLeft,{nodes:q,paths:Z,width:ne}=ka(S().graph);F.innerHTML=`<div class="wf-graph-size" style="width:${ne*g}px;height:${420*g}px"><div class="wf-graph" style="width:${ne}px;transform:scale(${g})"><svg width="${ne}" height="420" aria-hidden="true">${Z.map(Q=>`<path d="${Q}"/>`).join("")}</svg>${q.map(({node:Q,x:oe,y:te,width:J})=>`<button type="button" class="wf-node ${Q.id===p?"is-selected":""}" data-select-node="${D(Q.id)}" aria-pressed="${Q.id===p}" style="left:${oe}px;top:${te}px;width:${J}px">${I(Q)}<span>${D(Q.name)}</span></button>`).join("")}</div></div>`,F.scrollLeft=B}function fe(){H(r);const F=C(p);r.querySelector(".wf-card-area").innerHTML=F?ae(F):'<p class="wf-empty">暂无节点</p>',R(r)}function ve(){H(d),d.innerHTML=`<div class="wf-list-toolbar"><div class="wf-filter-wrap"><button type="button" data-wf="filter" class="wf-filter-button">${Ae("filter")} 筛选 ${Ae("chevron")}</button><div class="wf-filter-menu" hidden><label>节点状态<select data-status-filter aria-label="筛选节点状态"><option value="">全部状态</option>${Object.entries(Gt).map(([F,B])=>`<option value="${F}" ${f===F?"selected":""}>${B}</option>`).join("")}</select></label></div></div><div class="wf-views" role="tablist" aria-label="节点视图"><button type="button" role="tab" data-view="details" aria-selected="${u==="details"}">${Ae("detail")} 节点详情</button><button type="button" role="tab" data-view="schedule" aria-selected="${u==="schedule"}">${Ae("list")} 排期信息</button></div></div><div class="wf-list-rows">${S().nodeList.filter(F=>!f||F.status===f).map(F=>h.has(F.id)?ae(F,u==="schedule","list"):`<div class="wf-list-row" data-node="${D(F.id)}"><button type="button" data-wf="expand-card" class="wf-row-title" aria-expanded="false"><span class="wf-caret is-folded">${Ae("caret")}</span>${A(F)}</button><span>${D(b(F.owner)||"待填")}</span><span>${D(F.estimate||"待填")}</span><span>${D(F.schedule||"待填")}</span>${u==="details"?`<span class="wf-state-hint">${Gt[F.status]}</span><button type="button" data-wf="more" class="wf-more" aria-label="节点更多操作">${Ae("more")}</button>`:""}</div>`).join("")||'<p class="wf-empty">暂无匹配节点</p>'}</div>`,R(d)}function xe(){var F;S().graph.nodes.some(B=>B.id===p)||(p=((F=S().graph.nodes[0])==null?void 0:F.id)??""),he(),be(),fe(),ve()}function me(F){var B;i||!S().graph.nodes.some(q=>q.id===F)||(p=F,(B=e.onSelectNode)==null||B.call(e,F),be(),fe())}function P(F,B,q){return T({type:"update-node",nodeId:F.id,patch:B,detail:q})}function z(F,B,q,Z){var te;(te=F.querySelector(".wf-inline-editor"))==null||te.remove();const ne=document.createElement("div");ne.className="wf-inline-editor",ne.innerHTML=`<input aria-label="${D(B)}" placeholder="${D(B)}" value="${D(q)}"><button type="button" data-save>保存</button><button type="button" data-cancel>取消</button>`,F.append(ne);const Q=ne.querySelector("input"),oe=()=>{Q.value.trim()?Z(Q.value.trim()):Q.focus()};ne.querySelector("[data-save]").addEventListener("click",oe),ne.querySelector("[data-cancel]").addEventListener("click",()=>ne.remove()),Q.addEventListener("keydown",J=>{J.key==="Enter"&&(J.preventDefault(),oe()),J.key==="Escape"&&ne.remove()}),Q.focus()}function j(F,B,q){var ie,se,de,ue;const Z=(ie=B.form)==null?void 0:ie.find(ke=>ke.id===q);if(!Z)return;(se=F.querySelector(".wf-reference-picker"))==null||se.remove();const ne=new Set(((de=Z.value)==null?void 0:de.split(",").filter(Boolean))??[]),Q=document.createElement("div");Q.className="wf-reference-picker",Q.setAttribute("role","dialog"),Q.setAttribute("aria-label",`选择${Z.label}`),Q.innerHTML='<input aria-label="查找工作项" placeholder="搜索工作项"><div class="wf-reference-options"></div><footer><button type="button" data-cancel>取消</button><button type="button" data-save>确定</button></footer>',(ue=Array.from(F.querySelectorAll("[data-reference-field]")).find(ke=>ke.dataset.referenceField===q))==null||ue.after(Q);const oe=Q.querySelector("input"),te=Q.querySelector(".wf-reference-options"),J=()=>{var ge;const ke=(((ge=e.context)==null?void 0:ge.workItems)??e.workItems??[]).filter(ce=>ce.name.includes(oe.value)).slice(0,50);te.innerHTML=ke.map(ce=>`<label><input type="checkbox" value="${D(ce.id)}" ${ne.has(ce.id)?"checked":""}><span>${D(ce.name)}</span></label>`).join("")||"<p>暂无匹配工作项</p>"};te.addEventListener("change",ke=>{const ge=ke.target;ge.checked?ne.add(ge.value):ne.delete(ge.value)}),oe.addEventListener("input",J),Q.querySelector("[data-cancel]").addEventListener("click",()=>Q.remove()),Q.querySelector("[data-save]").addEventListener("click",()=>{var ke;return P(B,{form:(ke=B.form)==null?void 0:ke.map(ge=>ge.id===q?{...ge,value:[...ne].join(",")}:ge)},`更新${Z.label}`)}),Q.addEventListener("keydown",ke=>{ke.key==="Escape"&&Q.remove()}),J(),oe.focus()}function Y(F,B){var Q,oe,te,J;const q=[...S().node(F).form,...F.fields??[]].find(ie=>{var se;return ie.required&&!((se=ie.value)!=null&&se.trim())}),Z=(Q=F.tasks)==null?void 0:Q.find(ie=>ie.blocking&&!ie.done);(oe=B.querySelector(".wf-error"))==null||oe.remove();const ne=(te=F.gates)==null?void 0:te.find(ie=>!ie.met);if(q||Z||ne){const ie=document.createElement("p");ie.className="wf-error",ie.role="alert",ie.textContent=q?`请先填写${q.label}`:Z?`请先完成任务:${Z.name}`:ne.label,(J=B.querySelector(".wf-card-head"))==null||J.after(ie);return}P(F,{status:"done"},"完成节点")}function re(F){var de,ue,ke,ge;const B=F.target;if(B.closest("button:disabled"))return;const q=B.closest("[data-action]");if(q){const ce=(de=q.closest("[data-node]"))==null?void 0:de.dataset.node;ce&&T({type:"action",nodeId:ce,actionId:q.dataset.action});return}const Z=B.closest("[data-select-node]");if(Z){me(Z.dataset.selectNode);return}const ne=B.closest("[data-view]");if(ne){u=ne.dataset.view,ve();return}const Q=B.closest("[data-remove-tag]");if(Q&&n){T({type:"update-flow",detail:{...n,tags:n.tags.map(ce=>ce.id===Q.dataset.removeTag?{...ce,enabled:!1}:ce)}});return}const oe=B.closest("[data-wf]");if(!oe)return;const te=oe.dataset.wf,J=oe.closest("[data-node]"),ie=C((J==null?void 0:J.dataset.node)??p);if(te==="legend"){const ce=oe.closest(".wf-legend-wrap");ce.classList.toggle("is-open"),oe.setAttribute("aria-expanded",String(ce.classList.contains("is-open")));return}if(te==="filter"){const ce=d.querySelector(".wf-filter-menu");ce.hidden=!ce.hidden;return}if(!ie||!J)return;const se=`${J.dataset.surface??"list"}:${ie.id}`;if(te==="edit-reference"){j(J,ie,oe.dataset.referenceField);return}if(te==="collapse-card")if(m.has(se)?m.delete(se):m.add(se),d.contains(J))h.delete(ie.id),ve();else{const ce=J.querySelector(".wf-card-body");ce.hidden=!ce.hidden,J.querySelector(".wf-node-schedule").hidden=ce.hidden,oe.setAttribute("aria-expanded",String(!ce.hidden))}else if(te==="expand-card")m.delete(se),h.add(ie.id),ve();else if(te==="toggle-tasks"){y.has(se)?y.delete(se):y.add(se);const ce=J.querySelector(".wf-task-table");ce.hidden=!ce.hidden,oe.setAttribute("aria-expanded",String(!ce.hidden))}else if(te==="task-filter"){const ce=J.querySelector(".wf-task-filter-menu");if(ce){ce.remove();return}oe.insertAdjacentHTML("afterend",'<div class="wf-task-filter-menu" role="menu">'+["全部任务","我参与的","未完成","已完成"].map((Le,Wt)=>`<button type="button" role="menuitem" data-wf="task-filter-option" data-task-filter="${Wt}">${Le}</button>`).join("")+"</div>")}else if(te==="task-filter-option")x.set(se,Number(oe.dataset.taskFilter)),fe(),ve();else if(te==="expand-tasks")v.has(se)?v.delete(se):v.add(se),fe(),ve();else if(te==="add-task"&&e.onCreateTask)T({type:"action",nodeId:ie.id,actionId:"__create-task"});else if(te==="add-task")z(J.querySelector(".wf-task-table"),"任务名称","",ce=>P(ie,{tasks:[...ie.tasks??[],{id:crypto.randomUUID(),name:ce,done:!1}]},"新增任务"));else if(te==="complete")Y(ie,J);else if(te==="more"){const ce=J.querySelector(".wf-menu");r.querySelectorAll(".wf-menu").forEach(Le=>Le.remove()),d.querySelectorAll(".wf-menu").forEach(Le=>Le.remove()),ce||J.insertAdjacentHTML("beforeend",`<div class="wf-menu" role="menu">${((n==null?void 0:n.menu)??[]).map(Le=>`<button type="button" role="menuitem" data-wf="${Le}" ${Le==="delete-node"&&!S().node(ie).deletable?"disabled":""}>${Le==="delete-node"&&!S().node(ie).deletable?'<span title="流程配置不允许删除该节点">'+yi[Le]+"</span>":yi[Le]}</button>`).join("")}${M(ie,"more")}</div>`),O(J)}else te==="estimate"?((ue=J.querySelector(".wf-menu"))==null||ue.remove(),z(J,"节点估分",ie.estimate??"",ce=>P(ie,{estimate:ce},"填写估分"))):te==="group-chat"?T({type:"action",nodeId:ie.id,actionId:"group-chat"}):te==="delete-node"?((ke=J.querySelector(".wf-menu"))==null||ke.remove(),J.insertAdjacentHTML("beforeend",'<div class="wf-delete-confirm" role="alertdialog" aria-label="删除节点"><span>删除此节点?</span><button type="button" data-wf="cancel-delete">取消</button><button type="button" data-wf="confirm-delete">删除</button></div>')):te==="cancel-delete"?(ge=J.querySelector(".wf-delete-confirm"))==null||ge.remove():te==="confirm-delete"&&T({type:"delete-node",nodeId:ie.id})}function Ce(F){var Z,ne,Q,oe,te,J,ie;const B=F.target;if(!(B instanceof HTMLInputElement||B instanceof HTMLSelectElement)||B.closest("[data-node-fields-slot],[data-node-form-slot],[data-field-slot],[data-system-slot],[data-actions-slot],[data-task-cell]"))return;if(B.dataset.statusFilter!==void 0){f=B.value,ve();return}if(B.dataset.switch&&n&&B instanceof HTMLInputElement){const se=B.checked;T({type:"update-flow",detail:{...n,switches:n.switches.map(de=>de.id===B.dataset.switch?{...de,checked:se}:de)}});return}const q=C(((Z=B.closest("[data-node]"))==null?void 0:Z.dataset.node)??"");if(q){if(B.dataset.nodeField){const se=(ne=q.fields)==null?void 0:ne.find(de=>de.id===B.dataset.nodeField);if(se!=null&&se.readonly||((Q=e.can)==null?void 0:Q.call(e,"edit",q,B.dataset.nodeField))===!1){xe();return}P(q,{fields:(oe=q.fields)==null?void 0:oe.map(de=>de.id===B.dataset.nodeField?{...de,value:B.value}:de)},"更新节点字段")}if(B.dataset.form&&((te=e.can)==null?void 0:te.call(e,"edit",q,B.dataset.form))===!1){xe();return}B.dataset.field&&P(q,{[B.dataset.field]:B.value},`更新${B.ariaLabel}`),B.dataset.form&&P(q,{form:(J=q.form)==null?void 0:J.map(se=>se.id===B.dataset.form?{...se,value:B.value}:se)},"填写节点表单"),B.dataset.task&&B instanceof HTMLInputElement&&P(q,{tasks:(ie=q.tasks)==null?void 0:ie.map(se=>se.id===B.dataset.task?{...se,done:B.checked}:se)},"更新节点任务")}}r.innerHTML=`<div class="wf-workflow-graph" data-module="workflow:graph"><div class="wf-meta" data-module="workflow:graph:controls"></div><div class="wf-canvas" data-module="workflow:graph:canvas"><div class="wf-legend-wrap"><button type="button" class="wf-legend-trigger" data-wf="legend" aria-label="节点图例" aria-expanded="false">${Ae("list")}</button><div class="wf-legend" role="tooltip"><strong>节点图例</strong><span>○ 节点</span><span>◇ 里程碑</span><span>⊙ 含未完成子任务</span><span><i class="wf-dot pending"></i>未开始</span><span><i class="wf-dot inProgress"></i>进行中</span><span><i class="wf-dot done"></i>已完成</span></div></div><div class="wf-canvas-viewport" aria-label="节点流程图"></div></div></div><div class="wf-card-area" data-module="workflow:selected-node"></div>`;for(const F of[r,d])F.addEventListener("click",re,{signal:c.signal}),F.addEventListener("change",Ce,{signal:c.signal});document.addEventListener("pointerdown",F=>{F.target.closest(".wf-task-title")||(r.querySelectorAll(".wf-task-filter-menu").forEach(B=>B.remove()),d.querySelectorAll(".wf-task-filter-menu").forEach(B=>B.remove())),F.target.closest(".wf-menu,.wf-more")||(r.querySelectorAll(".wf-menu").forEach(B=>B.remove()),d.querySelectorAll(".wf-menu").forEach(B=>B.remove()))},{signal:c.signal});const N=r.querySelector(".wf-canvas-viewport");let K=null;N.addEventListener("pointerdown",F=>{F.target.closest("button")||(K={x:F.clientX,y:F.clientY,left:N.scrollLeft,top:N.scrollTop},N.setPointerCapture(F.pointerId))},{signal:c.signal}),N.addEventListener("pointermove",F=>{K&&(N.scrollLeft=K.left+K.x-F.clientX,N.scrollTop=K.top+K.y-F.clientY)},{signal:c.signal});const pe=()=>{K=null};return N.addEventListener("pointerup",pe,{signal:c.signal}),N.addEventListener("pointercancel",pe,{signal:c.signal}),N.addEventListener("wheel",F=>{(F.ctrlKey||F.metaKey)&&(F.preventDefault(),g=Math.max(.5,Math.min(1.5,g+(F.deltaY<0?.1:-.1))),be())},{passive:!1,signal:c.signal}),xe(),{element:r,nodeListElement:d,renderNodeDetails:()=>d,selectNode:me,getSelectedNode:()=>C(p),setFlow(F){i||(t=F,n=F.detail,a++,xe())},update(F){i||(e={...e,...F},F.flow&&(t=F.flow,n=F.flow.detail,a++),F.selectedNodeId!==void 0&&(p=F.selectedNodeId),xe())},destroy(){i=!0,c.abort(),H(r),H(d),r.remove(),d.remove()}}}function V(s,e="",t){const n=document.createElement(s);return n.className=e,t!==void 0&&(n.textContent=t),n}const ht=new Map;function Ye(s,e){if(!s)return!1;const t=e?[e]:[],n=new Set;for(let i=0;i<Math.max(1,t.length);i++)for(const[o,a]of ht)if(!(n.has(o)||e&&!t[i].contains(a))){if(o.element.contains(s))return!0;n.add(o),t.push(o.element)}return!1}function Ra(s){for(const[e,t]of[...ht])(!s||s.contains(t))&&e.close()}function kt(s){const{anchor:e,content:t,width:n="anchor",gap:i=4,onDismiss:o}=s,a=e.ownerDocument,l=a.defaultView||window,r=s.anchorMode==="element"?e:e.closest(".fc-focus-body")||e,d=a.createElement("div");d.className="rowvia-field-scope rowvia-field-popup-layer";const c=a.createElement("div");c.className="rowvia-field-popup",c.append(t),d.append(c),(a.body||a.documentElement).append(d);let p=!1;const h=()=>{if(p||!d.isConnected)return;const m=r.getBoundingClientRect(),y=a.documentElement.clientWidth||l.innerWidth,x=a.documentElement.clientHeight||l.innerHeight,C=n==="anchor"?m.width+2:n==="auto"?c.getBoundingClientRect().width:n;c.style.width=n==="auto"?"max-content":C+"px";const b=c.getBoundingClientRect().height;let I=m.bottom+i;const A=m.top-i-b;I+b>x-8&&A>=8&&(I=A),I=Math.max(8,Math.min(I,Math.max(8,x-b-8)));const S=Math.max(8,Math.min(s.align==="end"?m.right-C:m.left,Math.max(8,y-C-8)));d.style.top=Math.round(I)+"px",d.style.left=Math.round(S)+"px"},u=()=>{p||(p=!0,Ra(d),ht.delete(v),a.removeEventListener("pointerdown",f,!0),a.removeEventListener("keydown",g,!0),l.removeEventListener("resize",h),l.removeEventListener("scroll",h,!0),d.remove(),o==null||o())},f=m=>{const y=m.target;y&&(d.contains(y)||r.contains(y)||e.contains(y)||Ye(y,d))||u()},g=m=>{if(m.key!=="Escape"||[...ht.keys()][ht.size-1]!==v)return;if(m.preventDefault(),m.stopPropagation(),u(),s.onEscape){s.onEscape();return}const y=a.defaultView.CustomEvent;e.dispatchEvent(new y("fc-collapse",{bubbles:!0,detail:{reason:"escape"}}))},v={element:d,reposition:h,close:u};return ht.set(v,e),a.addEventListener("pointerdown",f,!0),a.addEventListener("keydown",g,!0),l.addEventListener("resize",h),l.addEventListener("scroll",h,!0),h(),v}const Ue=s=>s.choices??(s.options||[]).map(e=>({id:e,label:e})),bi=["rgba(61, 188, 47, 0.2)","rgba(0, 184, 159, 0.2)","rgba(244, 118, 189, 0.2)","rgba(149, 155, 238, 0.2)","rgba(184, 143, 255, 0.2)"],rn=(s,e)=>{var t,n;return((t=Ue(s).find(i=>i.id===e))==null?void 0:t.color)||((n=s.colors)==null?void 0:n[e])||bi[Math.max(0,Ue(s).findIndex(i=>i.id===e))%bi.length]},Ci=s=>(Array.isArray(s)?s:s==null||s===""?[]:[s]).map(String);function La(s,e){var t;return((t=Ue(s).find(n=>n.id===e))==null?void 0:t.label)||e}function Ta(s,e="choice"){const t=V("div","fc-tags");for(const n of Ci(s.value)){const i=La(s.field,n),o=V(e==="relation"?"button":"span","fc-tag fc-tag--"+e);e==="choice"&&(o.style.backgroundColor=rn(s.field,n)),e==="person"&&o.append(V("span","fc-avatar",i.slice(0,1))),o.append(V("span","fc-tag-label",i)),o.tagName==="BUTTON"&&(o.type="button",o.onclick=a=>{var l;a.stopPropagation(),(l=s.onAction)==null||l.call(s,{type:"open",value:n})}),t.append(o)}return t.children.length||t.append(V("span","fc-empty","待填")),t}function Si(s,e,t="choice"){var L;const n=V("div","fc-choice fc-choice--"+t);let i=Ci(e.value).slice(0,s?void 0:1);const o=new Map(Ue(e.field).map(M=>[M.id,M]));let a=Ue(e.field);const l=s&&(e.field.maxSelections??0)>0?e.field.maxSelections:1/0,r=V("select","fc-select");r.hidden=!0,r.multiple=s,r.disabled=e.readonly,r.required=!!e.field.required,r.ariaLabel=e.field.label;const d=V("div","fc-choice-head"),c=V("div","fc-choice-selection"),p=V("span","fc-empty fc-choice-placeholder","待填"),h=V("input","fc-choice-search");h.placeholder="",h.autocomplete="off",h.ariaLabel="输入以搜索"+e.field.label,h.disabled=e.readonly;const u=()=>{h.size=Math.max(1,[...h.value].length+1)};u();const f=V("div","fc-option-list");f.setAttribute("role",t==="radio"?"radiogroup":"group"),f.ariaLabel=e.field.label;const g=V("div","fc-error fc-choice-feedback");g.setAttribute("role","status");const v=V("div","fc-picker-status");v.setAttribute("role","status");const m=V("button","fc-retry","重试");m.type="button",m.hidden=!0;let y,x=0,C=!1,b=!1;const I=t!=="radio"&&!!((L=e.services)!=null&&L.searchOptions),A=t!=="radio"&&e.layout!=="compact"&&!e.readonly;let S;const G=()=>{const M=S;S=void 0,M==null||M.close()},E=()=>{!A||C||S||e.readonly||(S=kt({anchor:d,content:f,width:"anchor",onDismiss:()=>{S=void 0}}))},k=()=>{!A||!S||(G(),n.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},T=()=>{var M;(M=e.onSelectedOptions)==null||M.call(e,i.map($=>o.get($)).filter($=>!!$)),n.dispatchEvent(new Event("change",{bubbles:!0}))},H=()=>{var M;if(r.replaceChildren(),!s){const $=V("option");$.value="",r.append($)}for(const $ of new Set([...a.map(_=>_.id),...i])){const _=V("option","",((M=o.get($))==null?void 0:M.label)||$);_.value=$,_.selected=i.includes($),r.append(_)}s||(r.value=i[0]||"")},W=()=>{c.replaceChildren(),f.replaceChildren(),H(),!i.length&&!h.value&&c.append(p);for(const _ of i){const U=o.get(_),ee=V("span","fc-tag fc-tag--"+t);(t==="choice"||t==="radio")&&(ee.style.backgroundColor=rn(e.field,_)),t==="person"&&ee.append(V("span","fc-avatar",((U==null?void 0:U.label)||_).slice(0,1))),ee.append(V("span","fc-tag-label",((U==null?void 0:U.label)||_)+(U!=null&&U.disabled?"(已停用)":"")));const ae=V("span","fc-tag-slot"),he=V("button","fc-choice-remove","×");he.type="button",he.disabled=e.readonly,he.ariaLabel="移除"+((U==null?void 0:U.label)||_),he.onclick=be=>{be.stopPropagation(),i=i.filter(fe=>fe!==_),g.textContent="",W(),h.focus(),T()},ae.append(he),ee.append(ae),c.append(ee)}const M=h.value.trim().toLocaleLowerCase(),$=a.filter(_=>!_.disabled&&(I||(_.label+" "+_.id+" "+(_.description||"")).toLocaleLowerCase().includes(M)));for(const _ of $){const U=V("button","fc-option");U.type="button",U.dataset.value=_.id,U.disabled=e.readonly||b;const ee=i.includes(_.id);U.classList.toggle("selected",ee),U.setAttribute(t==="radio"?"aria-checked":"aria-pressed",String(ee)),t==="radio"&&U.setAttribute("role","radio");const ae=V("span","fc-option-label"+(t==="choice"?" fc-tag":""),_.label);t==="choice"&&(ae.style.backgroundColor=rn(e.field,_.id)),t==="person"&&U.append(V("span","fc-avatar",_.label.slice(0,1))),t==="relation"&&U.append(V("span","fc-relation-icon","↗"));const he=V("span","fc-option-copy");he.append(ae),_.description&&he.append(V("small","fc-option-description",_.description)),U.append(he,V("span","fc-option-mark",ee?"✓":"")),U.onclick=be=>{if(be.stopPropagation(),!e.readonly){if(!s)i=[_.id];else if(ee)i=i.filter(fe=>fe!==_.id);else{const fe=_.exclusive?[]:i.filter(ve=>{var xe;return!((xe=o.get(ve))!=null&&xe.exclusive)});if(fe.length>=l){g.textContent="最多可选择 "+l+" 项";return}i=[...fe,_.id]}g.textContent="",s||(h.value="",u()),W(),f.querySelectorAll("button").forEach(fe=>{fe.dataset.value===_.id&&fe.focus()}),T(),!s&&A&&k()}},f.append(U)}!$.length&&!b&&f.append(V("p","fc-empty fc-choice-empty","暂无匹配选项"))},R=async()=>{y==null||y.abort();const M=++x;y=new AbortController,b=!0,m.hidden=!0,v.textContent="加载中…",n.setAttribute("aria-busy","true"),W();try{const $=await e.services.searchOptions(e.field,h.value.trim(),y.signal);if(C||M!==x)return;a=$,$.forEach(_=>o.set(_.id,_)),v.textContent=""}catch{if(C||M!==x)return;a=[],v.textContent="加载失败,请重试",m.hidden=!1}finally{!C&&M===x&&(b=!1,n.setAttribute("aria-busy","false"),W())}};h.oninput=()=>{u(),I?R():W()},h.onfocus=()=>E(),d.onclick=M=>{M.target.closest("button")||h.focus()},m.onclick=()=>void R();const O=M=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(M.key))return;const $=[...f.querySelectorAll("button:not(:disabled)")];if(!$.length)return;M.preventDefault();const _=$.indexOf(document.activeElement),U=M.key==="Home"?0:M.key==="End"?$.length-1:(_+(M.key==="ArrowUp"||M.key==="ArrowLeft"?-1:1)+$.length)%$.length;$[U].focus()};if(f.onkeydown=O,h.onkeydown=M=>{M.key==="ArrowDown"&&(E(),O(M))},r.onchange=()=>{i=[...r.selectedOptions].map(M=>M.value).filter(Boolean),W()},d.append(c),t!=="radio"&&d.append(h),A){const M=V("span","fc-field-chevron");M.setAttribute("aria-hidden","true"),d.append(M),n.append(r,d,v,m,g)}else n.append(r,d,v,f,m,g);return W(),I&&!e.readonly&&R(),{element:n,content:A?f:void 0,read:()=>s?[...i]:i[0]||"",validate:()=>e.field.required&&!i.length?"请选择一个选项":i.length>l?"最多可选择 "+l+" 项":void 0,focus:()=>{var M;if(t==="radio"){(M=f.querySelector("button"))==null||M.focus();return}h.focus(),E()},deactivate:()=>{h.value="",u(),G()},destroy:()=>{C=!0,++x,y==null||y.abort(),G()}}}const Na=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),Ei=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function pt(s){const e=document.createElement("template");e.innerHTML=String(s??"");const t=n=>{for(const i of[...n.childNodes]){if(i.nodeType!==1)continue;const o=i;if(["SCRIPT","STYLE","IFRAME","OBJECT","SVG","MATH"].includes(o.tagName)){o.remove();continue}if(t(o),!Na.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",l=o.getAttribute("src")||"",r=o.getAttribute("alt")||"",d=o.getAttribute("data-person-id"),c=o.hasAttribute("checked"),p=o.getAttribute("data-task")==="true",h=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(f=>[f,o.style.getPropertyValue(f)]),u=o.tagName==="FONT"?o.getAttribute("color"):null;for(const f of[...o.attributes])o.removeAttribute(f.name);for(const[f,g]of h)(f==="color"||f==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(g):f==="text-align"?/^(left|center|right|justify)$/.test(g):f==="margin-left"?/^\d{1,3}px$/.test(g):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(g))&&o.style.setProperty(f,g);if(u&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(u)&&(o.style.color=u),o.tagName==="A"&&Ei(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="IMG"){if(!/^https?:\/\//i.test(l.trim())){o.remove();continue}o.setAttribute("src",l.trim()),o.setAttribute("alt",r),o.setAttribute("loading","lazy"),o.setAttribute("referrerpolicy","no-referrer")}o.tagName==="SPAN"&&d&&(o.setAttribute("data-person-id",d),o.setAttribute("contenteditable","false")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),c&&o.setAttribute("checked","")),p&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const ln={undo:'<path d="M9 5 4 10l5 5M4 10h10a6 6 0 0 1 0 12"/>',redo:'<path d="m15 5 5 5-5 5m5-5H10a6 6 0 0 0 0 12"/>',expand:'<path d="M14 3h7v7m0-7-7 7M10 21H3v-7m0 7 7-7"/>',collapse:'<path d="M21 3l-7 7m0-7v7h7M3 21l7-7m-7 0h7v7"/>',paint:'<path d="M3 3h14v7H3zM17 6h4v8h-9v7"/>',quote:'<path d="M4 12h5v7H2v-7l5-7m10 7h5v7h-7v-7l5-7"/>',table:'<rect x="3" y="3" width="18" height="18" rx="1"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/>',link:'<path d="m10 14 4-4m-7 7-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0m2 10 5-5a4 4 0 0 0-6-6l-1 1"/>',task:'<rect x="3" y="3" width="18" height="18" rx="1"/><path d="m7 12 3 3 7-7"/>',indent:'<path d="M10 5h11M10 12h11M10 19h11M2 8l4 4-4 4"/>',line:'<path d="M3 12h18M3 5h3m3 0h3m3 0h3M3 19h3m3 0h3m3 0h3"/>'};function xi(s){const e=V("div",`fc-rich${s.layout==="compact"?" fc-rich-compact":""}`),t=V("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const n=V("div","fc-rich-tools");t.append(n);const i=V("div","fc-rich-content");i.contentEditable=String(!s.readonly),i.setAttribute("role","textbox"),i.setAttribute("aria-multiline","true"),i.ariaLabel=s.field.label,i.tabIndex=s.readonly?-1:0,i.innerHTML=pt(s.value);const o=V("div","fc-rich-menu");o.hidden=!0;let a=null,l=!1,r=[i.innerHTML],d=0,c=!1,p=null,h,u;const f=()=>{const L=window.getSelection();L!=null&&L.rangeCount&&i.contains(L.anchorNode)&&i.contains(L.focusNode)&&(a=L.getRangeAt(0).cloneRange())},g=()=>{i.focus();const L=window.getSelection();if(!L)return;const M=a&&i.contains(a.commonAncestorContainer)?a:document.createRange();M!==a&&(M.selectNodeContents(i),M.collapse(!1)),L.removeAllRanges(),L.addRange(M),a=M},v=()=>{var M;const L=u;u=void 0,L==null||L.close(),(M=h==null?void 0:h.destroy)==null||M.call(h),h=void 0,o.hidden=!0,o.replaceChildren()},m=new Map,y=()=>{var L;m.get("撤销").disabled=s.readonly||d===0,m.get("重做").disabled=s.readonly||d===r.length-1;for(const[M,$]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const _=m.get(M);if(!_)continue;const U=!!((L=document.queryCommandState)!=null&&L.call(document,$));_.classList.toggle("active",U),_.setAttribute("aria-pressed",String(U))}},x=()=>{c||(i.innerHTML!==r[d]&&(r=r.slice(0,d+1),r.push(i.innerHTML),r.length>100&&r.shift(),d=r.length-1),f(),y())},C=()=>{x(),i.dispatchEvent(new Event("change",{bubbles:!0}))},b=L=>{const M=d+L;M<0||M>=r.length||(d=M,c=!0,i.innerHTML=r[d],a=null,g(),c=!1,y(),i.dispatchEvent(new Event("change",{bubbles:!0})))},I=(L,M)=>{s.readonly||(g(),document.execCommand(L,!1,M),f(),v(),C())},A=L=>{if(s.readonly)return;g();const M=window.getSelection().getRangeAt(0);M.deleteContents(),M.insertNode(L),M.setStartAfter(L),M.collapse(!0),a=M.cloneRange(),v(),C()},S=(L,M,$,_=!0)=>{const U=V("button",_?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return U.type="button",U.ariaLabel=L,U.title=L,U.disabled=s.readonly,ln[M]?U.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ln[M]}</svg>`:U.textContent=M,U.onmousedown=ee=>{ee.preventDefault(),f()},U.onclick=ee=>{ee.stopPropagation(),$()},n.append(U),m.set(L,U),U},G=(L,M)=>{if(!s.readonly){if(f(),!o.hidden&&o.ariaLabel===L){v();return}v(),o.className="fc-rich-menu",o.ariaLabel=L,o.hidden=!1,u=kt({anchor:m.get(L),anchorMode:"element",content:o,width:"auto",onDismiss:v,onEscape:g}),M(),u==null||u.reposition()}},E=(L,M)=>{const $=V("button","fc-rich-menu-option",L);return $.type="button",$.onmousedown=_=>_.preventDefault(),$.onclick=_=>{_.stopPropagation(),M()},o.append($),$};S("撤销","undo",()=>b(-1),!1),S("重做","redo",()=>b(1),!1),S("格式刷","paint",()=>{f();const L=a==null?void 0:a.startContainer,M=(L==null?void 0:L.nodeType)===1?L:L==null?void 0:L.parentElement;!M||!i.contains(M)||(p={tag:/^(B|STRONG|I|EM|U|S)$/.test(M.tagName)?M.tagName.toLowerCase():"span",css:M.getAttribute("style")||""},m.get("格式刷").classList.add("active"))}),S("正文样式","Aa⌄",()=>G("正文样式",()=>{for(const[L,M]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])E(L,()=>I("formatBlock",M))}));const k=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[L,M,$]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])S(L,M,()=>G(L,()=>{o.classList.add("fc-rich-colors");for(const _ of k){const U=E(_,()=>I($,_));U.textContent="",U.style.backgroundColor=_,U.ariaLabel=`${L} ${_}`}E("清除",()=>I($,$==="foreColor"?"#1f2329":"transparent"))}));for(const[L,M,$]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])S(L,M,()=>I($));S("对齐","☰⌄",()=>G("对齐",()=>{for(const[L,M]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])E(L,()=>I(M))})),S("有序列表","1≡",()=>I("insertOrderedList")),S("无序列表","•≡",()=>I("insertUnorderedList")),S("任务列表","task",()=>{g();const L=window.getSelection().getRangeAt(0),M=V("ul"),$=V("li");$.dataset.task="true";const _=V("input");_.type="checkbox",_.contentEditable="false",$.append(_,L.extractContents()),$.textContent||$.append(document.createTextNode("待办事项")),M.append($),A(M)}),S("引用","quote",()=>I("formatBlock","blockquote")),S("缩进","indent",()=>G("缩进",()=>{E("增加缩进",()=>I("indent")),E("减少缩进",()=>I("outdent"))})),S("分隔线","line",()=>A(V("hr"))),S("表格","table",()=>G("表格",()=>{const L=V("p","","选择行列"),M=V("div","fc-rich-table-grid");o.append(L,M);for(let $=1;$<=6;$++)for(let _=1;_<=6;_++){const U=V("button");U.type="button",U.ariaLabel=`${$}行${_}列表格`,U.dataset.row=String($),U.dataset.col=String(_),U.onmousedown=ee=>ee.preventDefault(),U.onmouseenter=()=>{L.textContent=`${$} × ${_}`,M.querySelectorAll("button").forEach(ee=>ee.classList.toggle("active",Number(ee.dataset.row)<=$&&Number(ee.dataset.col)<=_))},U.onclick=()=>{const ee=V("table"),ae=V("tbody");for(let be=0;be<$;be++){const fe=V("tr");for(let ve=0;ve<_;ve++){const xe=V("td");xe.append(V("br")),fe.append(xe)}ae.append(fe)}ee.append(ae),A(ee);const he=document.createRange();he.selectNodeContents(ee.querySelector("td")),he.collapse(!0),a=he,g()},M.append(U)}}));const T=()=>G("链接",()=>{const L=V("input","fc-input");L.ariaLabel="链接文本",L.placeholder="输入文本",L.value=(a==null?void 0:a.toString())||"";const M=V("input","fc-input");M.ariaLabel="链接地址",M.placeholder="粘贴或输入超链接";const $=V("div","fc-error"),_=V("button","primary","确定");_.type="button",_.onclick=()=>{const U=M.value.trim();if(!Ei(U)){$.textContent="请输入 http、https 或 mailto 链接";return}const ee=V("a","",L.value||U);ee.href=U,ee.target="_blank",ee.rel="noopener noreferrer",A(ee)},o.append(V("span","","文本"),L,V("span","","链接"),M,$,_),L.focus()});S("链接","link",T),S("插入图片","▧",()=>G("插入图片",()=>{const L=V("input","fc-input");L.type="url",L.ariaLabel="图片地址",L.placeholder="https:// 图片地址";const M=V("input","fc-input");M.ariaLabel="图片说明",M.placeholder="图片说明";const $=V("div","fc-error"),_=V("button","primary","插入");_.type="button",_.onclick=()=>{if(!/^https?:\/\//i.test(L.value.trim())||!L.checkValidity()){$.textContent="请输入有效的 http 或 https 图片地址";return}const U=V("img");U.src=L.value.trim(),U.alt=M.value,U.referrerPolicy="no-referrer",A(U)},o.append(L,M,$,_),L.focus()})),S("提及人员","@",()=>G("提及人员",()=>{var M;const L=Si(!1,{...s,value:"",field:{...s.field,label:"人员"}},"person");h=L,o.append(L.element),L.element.addEventListener("change",$=>{var ee,ae;$.stopPropagation();const _=String(L.read());if(!_)return;const U=V("span","","@"+(((ee=Ue(s.field).find(he=>he.id===_))==null?void 0:ee.label)||((ae=L.element.querySelector("option:checked"))==null?void 0:ae.textContent)||_));U.dataset.personId=_,U.contentEditable="false",A(U)}),(M=L.focus)==null||M.call(L)})),S("代码块","{ }",()=>I("formatBlock","pre")),S("表情","☺",()=>G("表情",()=>{o.classList.add("fc-rich-emojis");for(const L of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])E(L,()=>A(document.createTextNode(L)))}));const H=S("全屏编辑","expand",()=>{f(),l=!l,e.classList.toggle("is-fullscreen",l),v(),H.ariaLabel=H.title=l?"收起全屏":"全屏编辑",H.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${ln[l?"collapse":"expand"]}</svg>`,g()},!1);H.disabled=!1,H.classList.add("fc-rich-expand"),t.append(H);const W=()=>{for(const L of n.children)L.inert=L.offsetTop>=n.clientHeight},R=typeof ResizeObserver>"u"?void 0:new ResizeObserver(W);R==null||R.observe(n);const O=L=>{const M=L.target;i.contains(M)||M.closest("input,textarea,select,[contenteditable=true]")||(L.preventDefault(),!e.contains(document.activeElement)&&!o.contains(document.activeElement)&&g())};return e.addEventListener("mousedown",O),o.addEventListener("mousedown",O),i.addEventListener("input",x),i.addEventListener("mouseup",()=>{if(f(),y(),p&&a&&!a.collapsed){const L=a,M=V(p.tag);M.style.cssText=p.css,M.append(L.extractContents()),L.insertNode(M),p=null,m.get("格式刷").classList.remove("active"),C()}}),i.addEventListener("keyup",()=>{f(),y()}),i.addEventListener("click",L=>{const M=L.target;if(M.tagName==="A"&&L.preventDefault(),M instanceof HTMLInputElement&&M.type==="checkbox"){if(s.readonly){L.preventDefault();return}M.toggleAttribute("checked",M.checked),C()}v()}),i.addEventListener("drop",L=>L.preventDefault()),i.addEventListener("paste",L=>{var $,_;if(s.readonly){L.preventDefault();return}L.preventDefault(),f();const M=($=L.clipboardData)==null?void 0:$.getData("text/html");if(M){const U=document.createElement("template");U.innerHTML=pt(M);const ee=U.content,ae=document.createTextNode("");ee.append(ae),g();const he=window.getSelection().getRangeAt(0);he.deleteContents(),he.insertNode(ee),he.setStartAfter(ae),he.collapse(!0),a=he.cloneRange(),C()}else A(document.createTextNode(((_=L.clipboardData)==null?void 0:_.getData("text/plain"))||""))}),e.addEventListener("keydown",L=>{L.key==="Escape"&&!o.hidden?(L.preventDefault(),L.stopPropagation(),v(),g()):L.key==="Escape"&&l?(L.preventDefault(),L.stopPropagation(),H.click()):!s.readonly&&(L.metaKey||L.ctrlKey)&&L.key.toLowerCase()==="z"?(L.preventDefault(),b(L.shiftKey?1:-1)):(L.metaKey||L.ctrlKey)&&L.key.toLowerCase()==="k"&&(L.preventDefault(),f(),T())}),e.append(t,i),y(),{element:e,content:o,inputRoot:e,read:()=>pt(i.innerHTML),validate:()=>{var L;return s.field.required&&!((L=i.textContent)!=null&&L.trim())&&!i.querySelector("img")?"请填写内容":void 0},focus:()=>i.focus(),deactivate:()=>{v(),l=!1,e.classList.remove("is-fullscreen"),H.ariaLabel=H.title="全屏编辑"},destroy:()=>{R==null||R.disconnect(),v()}}}const ki="请输入评论(Enter 换行,⌘ + Enter 发送)",Ia={reply:'<path d="M4 4h16v13h-5l-3 3-3-3H4zM8 10h8"/>',edit:'<path d="m5 15 10-10 4 4L9 19H5zM13 7l4 4M4 22h17"/>',sort:'<path d="M6 20V4m-3 3 3-3 3 3M13 6h8M13 12h6M13 18h3"/>'},dn=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Ia[s]}</svg>`,Mi=s=>`<span class="detail-comment-avatar" aria-hidden="true">${D(s.slice(0,1))}</span>`,Ri=s=>s.html===void 0?D(s.content).replace(/\n/g,"<br>"):pt(s.html);function Aa(s){let e={...s};const t=typeof e.author=="string"?e.author:e.author.display;let n=e.data||e.comments||[],i,o,a=!1,l=0;const r=new AbortController,d=new Set,c=[],p=()=>{c.splice(0).forEach(R=>R())},h=(R,O)=>{var M;if(A||!(e.onSave||(R==="edit"?e.onEdit:e.onPublish))||R!=="create"&&!O)return!1;const L=(M=e.permissions)==null?void 0:M[R];return typeof L=="function"?!!O&&L(O):L===!0},u=document.createElement("section");u.className="detail-comments rowvia-field-scope rowvia-detail-module",u.dataset.module="detail:tabs:comment",u.ariaLabel="评论/备注";const f=document.createElement("ul");f.className="detail-comment-list",u.append(f);const g=document.createElement("button");g.type="button",g.className="detail-comment-load-more",g.textContent="加载更多";const v=document.createElement("div");v.setAttribute("role","alert"),u.append(g,v);let m=!1;g.onclick=async()=>{if(!(A||m||!e.hasMore||!e.onLoadMore)){m=!0,g.disabled=!0,v.textContent="";try{await e.onLoadMore(r.signal)}catch(R){A||(v.textContent=R instanceof Error?R.message:"加载失败,请重试")}finally{m=!1,A||(g.disabled=!1,g.hidden=!e.hasMore)}}};const y=document.createElement("div");y.className="detail-comment-composer rowvia-field-scope rowvia-detail-module",y.dataset.module="detail:comment:composer",y.innerHTML=`${Mi(t)}<div class="detail-comment-compose-main"></div>`;const x=y.lastElementChild;let C,b,I=!1,A=!1;const S=()=>n.map((R,O)=>typeof R=="string"?{id:`legacy-${O}`,author:t,content:R,createdAt:""}:R);function G(R,O,L,M){var me;const $=xi({field:{key:"comment",label:"评论",kind:"richText",required:!0,choices:(me=e.people)!=null&&me.length?e.people:[{id:t,label:t}]},value:R,readonly:!1,layout:"form",services:e.services});$.element.classList.add("detail-comment-editor");const _=$.element.querySelector(".fc-rich-tools");for(const P of["插入图片","提及人员"])_.append(_.querySelector(`[aria-label="${P}"]`));const U=$.element.querySelector(".fc-rich-content");U.dataset.placeholder=ki;const ee=document.createElement("div");ee.className="detail-comment-editor-actions",ee.innerHTML='<button type="button" data-cancel-comment>取消</button><button type="button" class="primary" data-publish-comment>发布评论</button>',$.element.append(ee);const ae=ee.querySelector("[data-publish-comment]"),he=document.createElement("div");he.className="detail-comment-error",he.setAttribute("role","alert"),$.element.append(he);const be=ee.querySelector("[data-cancel-comment]"),fe=()=>h(O.action==="edit"?"edit":O.action==="reply"?"reply":"create",S().find(P=>P.id===(O.id||O.replyTo))),ve=()=>{var z;const P=!((z=U.textContent)!=null&&z.replace(/[\u200b\u00a0]/g," ").trim())&&!U.querySelector("img,table,hr");U.classList.toggle("is-empty",P),ae.disabled=P||a||!fe(),be.disabled=a,$.element.inert=a,U.contentEditable=String(!a&&fe()),$.element.querySelector(".fc-rich-toolbar").inert=a||!fe()},xe=()=>{if(ve(),ae.disabled||A)return;const P=String($.read()),z=document.createElement("div");z.innerHTML=P,a=!0,he.textContent="",$.element.setAttribute("aria-busy","true"),ve();const j=l,Y=()=>{a=!1,!A&&($.element.setAttribute("aria-busy","false"),ve())},re=N=>{if(!A){if(N!==!0&&!Array.isArray(N)){Ce(new Error("保存失败,请重试"));return}Array.isArray(N)&&j===l&&(n=N),Y(),L()}},Ce=N=>{A||(Y(),he.textContent=N instanceof Error?N.message:"保存失败,请重试")};try{const N={...O,html:P,content:(z.innerText||z.textContent||"").trim()},K=e.onSave?e.onSave(N,r.signal):O.action==="edit"?e.onEdit(O.id,N,r.signal):e.onPublish(N,r.signal);typeof K=="object"&&K!==null&&"then"in K?Promise.resolve(K).then(re,Ce):re(K)}catch(N){Ce(N)}};return ee.querySelector("[data-cancel-comment]").onclick=()=>{!a&&!A&&M()},ae.onclick=xe,$.element.addEventListener("input",ve),$.element.addEventListener("change",ve),U.addEventListener("keydown",P=>{P.key==="Enter"&&(P.metaKey||P.ctrlKey)&&!P.isComposing&&(P.preventDefault(),P.stopPropagation(),xe())}),ve(),$}function E(){var R;(R=C==null?void 0:C.destroy)==null||R.call(C),C=void 0,o=void 0,y.classList.remove("is-editing"),y.hidden=!h("create"),x.innerHTML=`<button type="button" class="detail-comment-placeholder">${ki}</button>`,x.querySelector("button").onclick=()=>k()}function k(R){var _,U,ee,ae,he,be;if(a||!h(R?"reply":"create",R))return;const O=R==null?void 0:R.author;o=R==null?void 0:R.id;const L=`${(C==null?void 0:C.read())||""}${O?`<span data-person-id="${D(((U=(_=e.people)==null?void 0:_.find(fe=>fe.label===O))==null?void 0:U.id)||O)}">@${D(O)}</span>&nbsp;`:""}`;(ee=C==null?void 0:C.destroy)==null||ee.call(C),C=G(L,{action:o?"reply":"create",replyTo:o},()=>{E(),T()},E),y.hidden=!1,y.classList.add("is-editing"),x.replaceChildren(C.element),(ae=C.focus)==null||ae.call(C);const M=C.element.querySelector(".fc-rich-content"),$=document.createRange();$.selectNodeContents(M),$.collapse(!1),(he=window.getSelection())==null||he.removeAllRanges(),(be=window.getSelection())==null||be.addRange($)}function T(){if(A)return;p(),g.hidden=!e.hasMore||!e.onLoadMore;const R=S().map((O,L)=>({comment:O,index:L}));I&&R.reverse(),f.innerHTML=R.length?R.map(({comment:O,index:L})=>`
90
+ <footer class="ps-total"></footer><div class="ps-popover" hidden></div><aside class="ps-detail" hidden></aside><div class="ps-toast" role="status" hidden></div>`,s.append(N);const I=De(N,"personnel",e),E=W=>N.querySelector(W),G=E(".ps-scroll"),x=E(".ps-rows"),T=E(".ps-popover"),A=E(".ps-detail"),H=new AbortController,q=H.signal;let R;const P=()=>[22,43,64,86,120][p];function L(W){const Q=E(".ps-toast");Q.textContent=W,Q.hidden=!1,clearTimeout(R),R=setTimeout(()=>Q.hidden=!0,2200)}function M(){C||ka(N,{people:t,items:n,today:i,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:h,children:u,loose:f,colorFirst:g,from:v,days:m,rangeStart:w,rangeEnd:k})}function $(W,Q){if(!T.hidden&&T.dataset.kind===W){T.hidden=!0;return}T.dataset.kind=W,T.hidden=!1;const ae=N.getBoundingClientRect(),S=Q==null?void 0:Q.getBoundingClientRect();if(T.style.left=`${Math.max(12,Math.min(((S==null?void 0:S.left)??ae.left)-ae.left,N.clientWidth-(W==="unplanned"?760:420)-16))}px`,T.style.top=`${S?S.bottom-ae.top+6:96}px`,T.className=`ps-popover ps-panel-${W}`,W==="people")T.innerHTML=`<div class="ps-panel-title">包含 ${o.size} 人<label><input type="checkbox" data-control="only" ${a?"checked":""}>仅查看有排期的用户</label></div><div class="ps-person-filter"><span>甘特图显示人员</span><span>包含</span><span>全部排期人员</span></div><input class="ps-person-search" placeholder="搜索人员" aria-label="搜索人员"><div class="ps-person-options">${t.map(V=>`<label><input type="checkbox" data-person="${D(V.id)}" ${o.has(V.id)?"checked":""}>${D(V.name)}</label>`).join("")}</div>`;else if(W==="sort")T.innerHTML=`<div class="ps-panel-title">设置排序条件 ⓘ</div><div class="ps-sort-fields"><select aria-label="排序字段" data-control="sort"><option value="">请选择排序项</option><option value="estimate">总估分</option><option value="scheduled">已排期项</option></select><button data-action="asc" class="${c?"":"selected"}">小 → 大</button><button data-action="desc" class="${c?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,T.querySelector("select").value=d;else if(W==="filter")T.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${D(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${D(l)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(n.map(V=>V.status))].map(V=>`<option>${D(V)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,T.querySelector("select").value=r;else if(W==="settings")T.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${h?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${u?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${f?"":"selected"}">紧凑</button><button data-action="loose" class="${f?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${g?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${g?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(W==="date")te();else if(W==="save")T.innerHTML='<div class="ps-panel-title">存为视图</div><input data-view-name placeholder="视图名称" aria-label="视图名称"><button class="ps-primary" data-action="save-view">保存</button>';else if(W==="views"){const V=se();T.innerHTML=`<div class="ps-panel-title">视图列表</div>${V.length?V.map((oe,de)=>`<button class="ps-view" data-view="${de}">▦ ${D(oe.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let z=new Date(`${w}T00:00:00Z`),j=!1;function te(){let W=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${w}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${k}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let Q=0;Q<2;Q++){const ae=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+Q,1));W+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${ae.getUTCFullYear()}年 ${ae.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(V=>`<span>${V}</span>`).join("")}`;for(let V=0;V<ae.getUTCDay();V++)W+="<span></span>";const S=new Date(Date.UTC(ae.getUTCFullYear(),ae.getUTCMonth()+1,0)).getUTCDate();for(let V=1;V<=S;V++){const oe=qe(Date.UTC(ae.getUTCFullYear(),ae.getUTCMonth(),V)/864e5);W+=`<button data-date="${oe}" class="${oe>=w&&oe<=k?"in-range":""} ${oe===w||oe===k?"selected":""}">${V}</button>`}W+="</div></div>"}T.innerHTML=W+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((Q,ae)=>`<button data-preset="${ae}">${Q}</button>`).join("")}</div>`}let ue=`${w}/${k}`;function ge(){var Q;const W=`${w}/${k}`;W!==ue&&(ue=W,(Q=e.onRangeChange)==null||Q.call(e,{from:w,to:k}))}function be(W){for(const Q of[W.from,W.to])if(!/^\d{4}-\d{2}-\d{2}$/.test(Q)||!Number.isFinite(Ae(Q))||qe(Ae(Q))!==Q)throw new Error("Invalid schedule date range");if(W.to<W.from)throw new Error("Invalid schedule date range");w=W.from,k=W.to,z=new Date(`${w}T00:00:00Z`),ue=`${w}/${k}`,fe(!1)}function fe(W=!0){k<w&&([w,k]=[k,w]),v=Ae(w),v-=new Date(v*864e5).getUTCDay(),m=Math.max(35,Ae(k)-v+8),G.scrollLeft=0,M(),W&&ge()}function me(W,Q){var V;if(!n.some(oe=>oe.id===W))throw new Error(`Unknown schedule item: ${W}`);const ae=n.map(oe=>oe.id===W?{...oe,...Q}:oe);cn(t,ae),n=ae,M();const S=n.find(oe=>oe.id===W);S&&((V=e.onItemChange)==null||V.call(e,structuredClone(S)))}function Ee(W){var ae;const Q=n.find(S=>S.id===W);(ae=e.onItemOpen)==null||ae.call(e,structuredClone(Q)),A.hidden=!1,A.dataset.item=W,A.innerHTML=`<header><strong>${D(Q.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${D(Q.status)}</span><h3>● ${D(Q.node)}</h3><form><label>名称<input name="name" required value="${D(Q.name)}"></label><label>负责人<select name="personId">${t.map(S=>`<option value="${D(S.id)}" ${S.id===Q.personId?"selected":""}>${D(S.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${Q.estimate}" required></label><label>开始日期<input type="date" name="start" value="${Q.start||""}"></label><label>结束日期<input type="date" name="end" value="${Q.end||""}"></label><p class="ps-error" role="alert"></p><button class="ps-primary" type="submit">保存排期</button><button type="button" data-action="unschedule">移至未排期</button></form></div>`}function Me(W,Q){$("unplanned",Q),T.hidden=!1;const ae=t.find(S=>S.id===W);T.innerHTML=`<div class="ps-panel-title">未排期工作项 ${D(ae.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${n.filter(S=>S.personId===W&&!dn(S)).map(S=>`<tr><td><button data-open="${D(S.id)}">${D(S.name)}</button></td><td>● ${D(S.node)}</td><td><input type="number" min="0" step="0.1" value="${S.estimate||""}" placeholder="待填" data-estimate="${D(S.id)}" aria-label="${D(S.name)}估分"></td><td><button class="ps-link" data-open="${D(S.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const U=e.viewStorageKey??"rowvia-personnel-views-v1";function se(){try{const W=JSON.parse(localStorage.getItem(U)||"[]");return Array.isArray(W)?W:[]}catch{return[]}}N.addEventListener("click",W=>{const Q=W.target,ae=Q.closest("button");if(!ae)return;if(ae.dataset.open){T.hidden=!0,Ee(ae.dataset.open);return}if(ae.dataset.item){b||Ee(ae.dataset.item);return}if(ae.dataset.date){j?(k=ae.dataset.date,j=!1,fe()):(w=ae.dataset.date,k=w,j=!0),te();return}if(ae.dataset.preset){const V=Number(ae.dataset.preset),oe=Ae(i),de=new Date(oe*864e5);w=qe(V<2?oe-de.getUTCDay():V<4?Date.UTC(de.getUTCFullYear(),de.getUTCMonth(),1)/864e5:oe),k=qe(V===2||V===3?Date.UTC(de.getUTCFullYear(),de.getUTCMonth()+(V===2?1:2),0)/864e5:Ae(w)+[6,13,29,60,13,59,364][V]),j=!1,fe(),T.hidden=!0;return}if(ae.dataset.view){const V=se()[Number(ae.dataset.view)];V&&(o=new Set(V.selected.filter(oe=>t.some(de=>de.id===oe))),{query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:w,rangeEnd:k,expanded:h,children:u,loose:f,colorFirst:g,onlyScheduled:a}=V,M(),ge(),T.hidden=!0,L(`已打开 ${V.name}`));return}const S=ae.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(S||"")){$(S,ae);return}if(S==="unplanned"){Me(ae.dataset.person,ae);return}if(S==="close-detail"&&(A.hidden=!0),S==="unschedule"&&(me(A.dataset.item,{start:null,end:null}),A.hidden=!0),(S==="plus"||S==="minus")&&(p=Math.max(0,Math.min(4,p+(S==="plus"?1:-1))),M()),(S==="prev"||S==="next"||S==="today")&&(v=S==="today"?Ae(i)-new Date(`${i}T00:00:00Z`).getUTCDay():v+(S==="prev"?-14:14),w=qe(v),k=qe(v+59),G.scrollLeft=0,M(),ge()),(S==="asc"||S==="desc"||S==="clear-sort")&&(c=S==="desc",S==="clear-sort"&&(d=""),M(),T.hidden=!0),S==="clear-filter"&&(l="",r="",M(),T.hidden=!0),["compact","loose","content","color"].includes(S||"")&&(S==="compact"||S==="loose"?f=S==="loose":g=S==="color",M(),T.hidden=!0,$("settings",E('[data-action="settings"]'))),(S==="cal-prev"||S==="cal-next")&&(z=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+(S==="cal-prev"?-1:1),1)),te()),S==="save-view"){const V=T.querySelector("[data-view-name]").value.trim();if(!V)return;const oe=se();oe.push({name:V,selected:[...o],query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:w,rangeEnd:k,expanded:h,children:u,loose:f,colorFirst:g,onlyScheduled:a});try{localStorage.setItem(U,JSON.stringify(oe)),T.hidden=!0,L("视图已保存")}catch{L("浏览器存储不可用,视图未保存")}}S==="schedule"&&(T.hidden=!0,A.hidden=!0)},{signal:q}),N.addEventListener("input",W=>{const Q=W.target;Q.classList.contains("ps-zoom")&&(p=Number(Q.value),M()),Q.classList.contains("ps-person-search")&&T.querySelectorAll(".ps-person-options label").forEach(ae=>{var S;return ae.hidden=!((S=ae.textContent)!=null&&S.includes(Q.value))}),Q.dataset.control==="query"&&(l=Q.value,M())},{signal:q}),N.addEventListener("change",W=>{const Q=W.target;if(Q.dataset.person&&(Q.checked?o.add(Q.dataset.person):o.delete(Q.dataset.person),M()),Q.dataset.estimate){const ae=Number(Q.value);Number.isFinite(ae)&&ae>=0&&me(Q.dataset.estimate,{estimate:ae});return}switch(Q.dataset.control){case"only":a=Q.checked;break;case"sort":d=Q.value;break;case"status":r=Q.value;break;case"expanded":h=Q.checked;break;case"children":u=Q.checked;break;case"range-start":Q.value&&(w=Q.value,fe(),te());return;case"range-end":Q.value&&(k=Q.value,fe(),te());return}M()},{signal:q}),A.addEventListener("submit",W=>{W.preventDefault();const Q=new FormData(W.target),ae=String(Q.get("start")||"")||null,S=String(Q.get("end")||"")||null;if(!!ae!=!!S||ae&&S&&ae>S){A.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}me(A.dataset.item,{name:String(Q.get("name")),personId:String(Q.get("personId")),estimate:Number(Q.get("estimate")),start:ae,end:S}),A.hidden=!0,L("排期已更新")},{signal:q}),document.addEventListener("pointerdown",W=>{N.contains(W.target)?!T.contains(W.target)&&!W.target.closest("[data-action]")&&(T.hidden=!0):T.hidden=!0},{signal:q}),N.addEventListener("keydown",W=>{W.key==="Escape"&&(T.hidden=!0,A.hidden=!0)},{signal:q});let Z=null;return x.addEventListener("pointerdown",W=>{const Q=W.target,ae=Q.closest(".ps-bar");if(!ae||W.button!==0)return;const S=n.find(V=>V.id===ae.dataset.item);b=!1,Z={id:S.id,x:W.clientX,start:Ae(S.start),end:Ae(S.end),edge:Q.dataset.edge||"move",bar:ae,left:parseFloat(ae.style.left),size:parseFloat(ae.style.width),delta:0,scroll:G.scrollLeft}},{signal:q}),document.addEventListener("pointermove",W=>{if(!Z)return;const Q=Math.round((W.clientX-Z.x+G.scrollLeft-Z.scroll)/P());Z.delta=Z.edge==="start"?Math.min(Q,Z.end-Z.start):Z.edge==="end"?Math.max(Q,Z.start-Z.end):Q,Math.abs(W.clientX-Z.x)>4&&(b=!0),b&&(Z.bar.style.opacity=".8",Z.edge==="move"?Z.bar.style.transform=`translateX(${Z.delta*P()}px)`:(Z.bar.style.left=`${Z.left+(Z.edge==="start"?Z.delta*P():0)}px`,Z.bar.style.width=`${Z.size+(Z.edge==="start"?-1:1)*Z.delta*P()}px`))},{signal:q}),document.addEventListener("pointerup",()=>{if(!Z)return;const W=Z;Z=null,b&&(me(W.id,{start:qe(W.start+(W.edge==="end"?0:W.delta)),end:qe(W.end+(W.edge==="start"?0:W.delta))}),L("排期已更新"))},{signal:q}),e.initialRange?be(e.initialRange):M(),{setRange:be,onInteraction:I.onInteraction,setData(W,Q){cn(W,Q),t=structuredClone(W),n=structuredClone(Q),o=new Set(t.map(ae=>ae.id)),T.hidden=!0,A.hidden=!0,M()},getItems:()=>structuredClone(n),updateItem:me,setPeople(W){o=new Set(W.filter(Q=>t.some(ae=>ae.id===Q))),M()},destroy(){C=!0,H.abort(),clearTimeout(R),I.destroy(),N.remove()}}}const xi={pencil:'<path d="m15 3 6 6-12 12H3v-6ZM13 5l6 6"/>',transition:'<path d="M4 8h14l-4-4m4 4-4 4M20 16H6l4-4m-4 4 4 4"/>',expand:'<path d="M15 3h6v6m0-6-7 7M9 21H3v-6m0 6 7-7"/>',check:'<circle cx="12" cy="12" r="8"/><path d="m8 12 3 3 5-6"/>',plus:'<circle cx="12" cy="12" r="9"/><path d="M12 7v10M7 12h10"/>',add:'<path d="M12 4v16M4 12h16"/>',close:'<path d="m6 6 12 12M6 18 18 6"/>',back:'<path d="m15 18-6-6 6-6"/>',filter:'<path d="M3 4h18l-7 8v7l-4 2v-9Z"/>',sort:'<path d="M4 5h16M4 11h11M4 17h6"/>',group:'<path d="m3 13 10-10h8v8L11 21Z"/><circle cx="17" cy="7" r="1"/>',color:'<path d="m10 3 10 10-8 8L2 11Z M4 13h14M10 3 7 0"/><path d="M21 17q4 5 0 5q-4 0 0-5"/>',search:'<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6M2 3h5M2 9h2M2 16h5"/>',save:'<path d="M4 3h13l4 4v14H3V3h1ZM8 3v7h8V3M7 21v-7h10v7"/>',down:'<path d="m6 9 6 6 6-6"/>',up:'<path d="m6 15 6-6 6 6"/>',link:'<path d="m10 14 4-4M8 16l-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0M16 8l1-1a4 4 0 0 1 6 6l-5 5a4 4 0 0 1-6 0"/>',edit:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><path d="M14 17h8m-4-4v8"/>',book:'<path d="M6 3h12v18l-6-4-6 4Z"/>',people:'<circle cx="9" cy="8" r="3"/><path d="M3 21v-3a6 6 0 0 1 12 0v3ZM17 4a3 3 0 0 1 0 6M18 14q4 1 4 7"/>',table:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M3 14h18M9 9v11M15 9v11"/>',chart:'<circle cx="12" cy="12" r="9"/><path d="M12 3v9h9"/>',menu:'<path d="M4 6h16M4 12h12M4 18h16"/>',more:'<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',inbox:'<path d="m5 4-3 10v6h20v-6L19 4ZM2 14h6l2 3h4l2-3h6"/>'},Re=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${xi[s]||xi.check}</svg>`,Ie=(s,e,t="",n="")=>`<button type="button" data-action="${s}" class="${n}" aria-label="${D(e)}">${t?Re(t):""}${e?`<span>${D(e)}</span>`:""}</button>`,Wt=(s,e,t="")=>`<select ${t}>${s.map(([n,i])=>`<option value="${D(n)}" ${n===e?"selected":""}>${D(i)}</option>`).join("")}</select>`;function Ra(s){var c,p;const e=s.detail,t=new Set(s.nodes.filter(h=>h.hiddenReason).map(h=>h.id));for(const h of(e==null?void 0:e.tags)??[])h.enabled===!1&&((c=h.nodeIds)==null||c.forEach(u=>t.add(u)));for(const h of(e==null?void 0:e.switches)??[])h.checked||(p=h.nodeIds)==null||p.forEach(u=>t.add(u));const n=s.nodes.filter(h=>!t.has(h.id)),i=new Set(n.map(h=>h.id)),o=(e==null?void 0:e.connections)??La(s),a=(h,u=new Set)=>u.has(h)?[]:(u.add(h),i.has(h)?[h]:(o[h]??[]).flatMap(f=>a(f,new Set(u)))),l=n.flatMap(h=>[...new Set((o[h.id]??[]).flatMap(u=>a(u)))].map(u=>({from:h.id,to:u}))),r=(h,u,f,g=new Set)=>h===u?!0:g.has(h)?!1:(g.add(h),l.some(v=>v!==f&&v.from===h&&r(v.to,u,f,g))),d=l.filter(h=>!r(h.from,h.to,h));return{controls:{roles:(e==null?void 0:e.tags)??[],switches:(e==null?void 0:e.switches)??[]},graph:{nodes:n,edges:d},nodeList:n,node:h=>{var f,g,v;const u=(f=e==null?void 0:e.nodes)==null?void 0:f[h.id];return{data:h,form:((g=h.form)==null?void 0:g.filter(m=>{var w,k;return!m.visibleWhen||((k=(w=h.form)==null?void 0:w.find(C=>C.id===m.visibleWhen.fieldId))==null?void 0:k.value)===m.visibleWhen.value}))??[],fields:(u==null?void 0:u.fields)??(e==null?void 0:e.fields)??[{key:"owner",label:"负责人"},{key:"schedule",label:"总排期"}],sections:(u==null?void 0:u.sections)??((v=h.form)!=null&&v.length?["form","tasks"]:["tasks"]),completeLabel:(u==null?void 0:u.completeLabel)??"完成",deletable:(u==null?void 0:u.deletable)!==!1}}}}function La(s){const e=[];for(const t of s.groups){const n=s.nodes.filter(i=>i.groupId===t.id);t.layout==="parallel"?e.push(n):e.push(...n.map(i=>[i]))}return e.push(...s.nodes.filter(t=>!s.groups.some(n=>n.id===t.groupId)).map(t=>[t])),Object.fromEntries(e.flatMap((t,n)=>t.map(i=>{var o;return[i.id,((o=e[n+1])==null?void 0:o.map(a=>a.id))??[]]})))}function Ta(s){const e=new Map(s.nodes.map(l=>[l.id,0]));for(let l=0;l<s.nodes.length;l++){let r=!1;for(const d of s.edges){const c=Math.min(s.nodes.length-1,(e.get(d.from)??0)+1);(e.get(d.to)??0)<c&&(e.set(d.to,c),r=!0)}if(!r)break}const t=[...new Set(e.values())].sort((l,r)=>l-r).map(l=>s.nodes.filter(r=>e.get(r.id)===l));let n=64;const i=t.flatMap(l=>{const r=Math.max(...l.map(c=>Math.max(55,c.name.length*13+27))),d=l.map((c,p)=>({node:c,x:n,y:196+(p-(l.length-1)/2)*40,width:r}));return n+=r+48,d}),o=new Map(i.map(l=>[l.node.id,l])),a=s.edges.flatMap(l=>{const r=o.get(l.from),d=o.get(l.to);if(!r||!d)return[];const c=r.x+r.width,p=r.y+14,h=d.y+14;return[`M ${c} ${p} C ${c+24} ${p} ${d.x-24} ${h} ${d.x} ${h}`]});return{nodes:i,paths:a,width:n+16}}const Fe=s=>`<svg class="wf-icon" viewBox="0 0 16 16" aria-hidden="true">${{caret:'<path d="M13.706 6.437 8.503 12.421a.667.667 0 0 1-1.006 0L2.293 6.437a.667.667 0 0 1 .503-1.104h10.407a.667.667 0 0 1 .503 1.104Z" fill="currentColor"/>',chevron:'<path d="m4 6 4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5"/>',more:'<g fill="currentColor"><circle cx="3" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="13" cy="8" r="1.5"/></g>',expand:'<path d="M6 2H2v4m8-4h4v4M2 10v4h4m8-4v4h-4" fill="none" stroke="currentColor" stroke-width="1.3"/>',filter:'<path d="M2 3h12L9 8v5l-2-1V8Z" fill="none" stroke="currentColor" stroke-width="1.3"/>',list:'<path d="M6 4h8M6 8h8M6 12h8M2 4h1M2 8h1M2 12h1" stroke="currentColor" stroke-width="1.4"/>',detail:'<rect x="2" y="2" width="12" height="12" rx="2" fill="none" stroke="currentColor"/><path d="M5 6h6M5 9h6" stroke="currentColor"/>',plus:'<path d="M8 2v12M2 8h12" stroke="currentColor" stroke-width="1.5"/>'}[s]}</svg>`,Ut={pending:"未开始",inProgress:"进行中",done:"已完成",failed:"未通过"},ki={estimate:"填写估分","group-chat":"节点建群","delete-node":"删除节点"};function Na(s){var de,xe;let e={...s},t=s.flow,n=t.detail,i=!1,o=!1,a=0;const l=new Map,r=document.createElement("section");r.className="workitem-module-detail-workflow rv-workflow-detail",r.dataset.module="detail:workflow";const d=document.createElement("section");d.className="workflow-node-details rv-workflow-detail",d.dataset.module="detail:tabs:schedule";const c=new AbortController;let p=s.selectedNodeId??((de=t.nodes.find(F=>F.status==="inProgress"))==null?void 0:de.id)??((xe=t.nodes[0])==null?void 0:xe.id)??"";const h=new Set([p]);let u="details",f="",g=1;const v=new Set,m=new Set,w=new Set,k=new Map,C=F=>t.nodes.find(B=>B.id===F),b=F=>{var B,_,X;return((X=(_=(B=e.context)==null?void 0:B.people)==null?void 0:_.find(Y=>Y.id===F))==null?void 0:X.name)??F??""},N=F=>`<i class="wf-dot ${F.status}" aria-hidden="true"></i>`,I=F=>`${N(F)}<strong>${D(F.name)}</strong><span class="wf-status ${F.status}">${Ut[F.status]}</span>`,E=()=>Ra(t);function G(F,B,_){var Y;const X=e.onCommand||(F==="configure"?e.onFlowChange:F==="action"?e.onAction:F==="create-task"?e.onCreateTask||e.onChange:F==="delete"?e.onDelete:F==="complete"&&e.onComplete||e.onChange);return!i&&!o&&!e.readonly&&!!X&&((Y=e.can)==null?void 0:Y.call(e,F,B,_))!==!1}function x(F){var B;if(F.type==="delete-node")return"delete";if(F.type==="update-flow")return"configure";if(F.type==="action")return F.actionId==="__create-task"?"create-task":"action";if(F.patch.status)return"complete";if(F.patch.tasks){const _=C(F.nodeId);return F.patch.tasks.length>(((B=_==null?void 0:_.tasks)==null?void 0:B.length)??0)?"create-task":"toggle-task"}return"edit"}function T(F){var _,X,Y,ee;const B={flow:t,signal:c.signal};return e.onCommand?e.onCommand(F,B):F.type==="delete-node"?(_=e.onDelete)==null?void 0:_.call(e,F.nodeId,B):F.type==="update-flow"?(X=e.onFlowChange)==null?void 0:X.call(e,F.detail,B):F.type==="action"?F.actionId==="__create-task"&&e.onCreateTask?e.onCreateTask(F.nodeId,B):(Y=e.onAction)==null?void 0:Y.call(e,F.nodeId,F.actionId,B):F.patch.status==="done"&&e.onComplete?e.onComplete(F.nodeId,B):(ee=e.onChange)==null?void 0:ee.call(e,F.nodeId,F.patch,F.detail,B)}async function A(F){var ie;const B="nodeId"in F?C(F.nodeId):void 0,_=F.type==="action"?F.actionId:F.type==="update-node"?Object.keys(F.patch)[0]:void 0,X=F.type!=="update-node"||Object.keys(F.patch).every(J=>G(x({...F,patch:{[J]:F.patch[J]}}),B,J)),Y=F.type!=="update-node"||[...(F.patch.form??[]).filter(J=>{var ne,he;return J.value!==((he=(ne=B==null?void 0:B.form)==null?void 0:ne.find(pe=>pe.id===J.id))==null?void 0:he.value)}),...(F.patch.fields??[]).filter(J=>{var ne,he;return J.value!==((he=(ne=B==null?void 0:B.fields)==null?void 0:ne.find(pe=>pe.id===J.id))==null?void 0:he.value)})].every(J=>{var ne,he,pe;return((ne=e.can)==null?void 0:ne.call(e,"edit",B,J.id))!==!1&&!((pe=(he=B==null?void 0:B.fields)==null?void 0:he.find(Se=>Se.id===J.id))!=null&&pe.readonly)});if(!G(x(F),B,_)||!X||!Y||F.type==="delete-node"&&B&&!E().node(B).deletable)return i||Ee(),!1;const ee=a;o=!0,r.querySelectorAll(".wf-error").forEach(J=>J.remove()),P(r),P(d);let ce,re=!1;try{const J=T(F),ne=J instanceof Promise?await J:J;return i?!1:(ne&&a===ee&&(t=ne,n=ne.detail,a++),!0)}catch(J){return ce=J,re=!0,!1}finally{if(o=!1,!i&&(Ee(),re)){const J=document.createElement("p");J.className="wf-error",J.role="alert",J.textContent=ce instanceof Error?ce.message:"保存失败,请重试",r.querySelector(".wf-card-area").prepend(J),(ie=e.onError)==null||ie.call(e,ce,F)}}}function H(F){var B;(B=l.get(F))==null||B.forEach(_=>_()),l.delete(F)}function q(F,B){return{node:F,surface:B===r?"selected":"list",readonly:!G("edit",F),pending:o,signal:c.signal,context:e.context??{currentUser:e.currentUser,workItems:e.workItems},can:(_,X)=>G(_,F,X),commit:(_,X="更新节点字段")=>U(F,_,X),action:_=>A({type:"action",nodeId:F.id,actionId:_})}}function R(F){const B=[];l.set(F,B),F.querySelectorAll("[data-node]").forEach(_=>{var ie,J;const X=C(_.dataset.node);if(!X)return;const Y=q(X,F);e.renderTaskField&&_.querySelectorAll("[data-task-cell]").forEach(ne=>{var ke,ve;const he=(ke=X.tasks)==null?void 0:ke.find(Ne=>Ne.id===ne.dataset.taskCell),pe=(ve=e.taskColumns)==null?void 0:ve.call(e,X).find(Ne=>Ne.key===ne.dataset.taskColumn);if(!he||!pe)return;const Se=e.renderTaskField(ne,he,pe,Y);Se&&B.push(Se)}),e.renderTaskActions&&_.querySelectorAll("[data-task-actions]").forEach(ne=>{var Se;const he=(Se=X.tasks)==null?void 0:Se.find(ke=>ke.id===ne.dataset.taskActions);if(!he)return;const pe=e.renderTaskActions(ne,he,Y);pe&&B.push(pe)});const ee=(F===r?"selected:":"list:")+X.id;if(m.has(ee)){const ne=_.querySelector(".wf-card-body"),he=_.querySelector(".wf-node-schedule");ne&&(ne.hidden=!0),he&&(he.hidden=!0),(ie=_.querySelector('[data-wf="collapse-card"]'))==null||ie.setAttribute("aria-expanded","false")}if(w.has(ee)){const ne=_.querySelector(".wf-task-table");ne&&(ne.hidden=!0),(J=_.querySelector('[data-wf="toggle-tasks"]'))==null||J.setAttribute("aria-expanded","false")}const ce=_.querySelector("[data-node-fields-slot]");if(ce&&e.renderNodeFields){const ne=e.renderNodeFields(X,ce,Y);ne&&B.push(ne)}const re=_.querySelector("[data-node-form-slot]");if(re&&e.renderNodeForm){const ne=e.renderNodeForm(X,re,Y);ne&&B.push(ne)}if(e.renderField&&_.querySelectorAll("[data-field-slot]").forEach(ne=>{var Se;const he=[...E().node(X).form,...X.fields??[]].find(ke=>ke.id===ne.dataset.fieldSlot);if(!he)return;const pe=e.renderField(ne,he,{...Y,readonly:Y.readonly||((Se=e.can)==null?void 0:Se.call(e,"edit",X,he.id))===!1||"readonly"in he&&!!he.readonly});pe&&B.push(pe)}),e.renderSystemField&&_.querySelectorAll("[data-system-slot]").forEach(ne=>{var Se;const he=E().node(X).fields.find(ke=>ke.key===ne.dataset.systemSlot);if(!he)return;const pe=e.renderSystemField(ne,he,{...Y,readonly:Y.readonly||((Se=e.can)==null?void 0:Se.call(e,"edit",X,he.key))===!1});pe&&B.push(pe)}),e.renderActions){const ne=_.querySelector("[data-actions-slot]");if(ne){const he=e.renderActions(ne,X.buttons??[],Y);he&&B.push(he)}}}),P(F)}function P(F){F.setAttribute("aria-busy",String(o)),F.querySelectorAll("input,button,select").forEach(B=>{var ce,re,ie;const _=C(((ce=B.closest("[data-node]"))==null?void 0:ce.dataset.node)??""),X=B.dataset.wf;let Y,ee;(B.dataset.field||B.dataset.form||B.dataset.nodeField||X==="edit-reference"||X==="estimate")&&(Y="edit",ee=B.dataset.field??B.dataset.form??B.dataset.nodeField??B.dataset.referenceField??"estimate"),B.dataset.task&&(Y="toggle-task"),X==="add-task"&&(Y="create-task"),X==="complete"&&(Y="complete"),(X==="delete-node"||X==="confirm-delete")&&(Y="delete"),(B.dataset.switch||B.dataset.removeTag)&&(Y="configure"),(B.dataset.action||X==="group-chat")&&(Y="action",ee=B.dataset.action??X),Y&&(B.disabled=!G(Y,_,ee)||Y==="delete"&&!!_&&!E().node(_).deletable||!!B.dataset.nodeField&&!!((ie=(re=_==null?void 0:_.fields)==null?void 0:re.find(J=>J.id===B.dataset.nodeField))!=null&&ie.readonly))})}function L(F){var B;return!((B=F.fields)!=null&&B.length)||e.renderNodeForm?"":'<div class="wf-node-form"><div class="wf-form-fields">'+F.fields.map(_=>e.renderField?'<div data-field-slot="'+D(_.id)+'"></div>':"<label><span>"+D(_.label)+'</span><input data-node-field="'+D(_.id)+'" aria-label="'+D(_.label)+'" value="'+D(_.value??"")+'"></label>').join("")+"</div></div>"}function M(F,B){return e.renderActions?B==="inline"?"<span data-actions-slot></span>":"":(F.buttons??[]).filter(_=>(_.placement??"inline")===B).map(_=>'<button type="button" data-action="'+D(_.id)+'" class="wf-custom-action '+D(_.variant??"normal")+'" title="'+D(_.hint??"")+'">'+D(_.label)+"</button>").join("")}function $(F,B){var At,$t;const _=`${B}:${F.id}`,X=F.tasks??[],Y=k.get(_)??0,ee=X.filter(we=>{var le;return Y===2?!we.done:Y===3?we.done:Y===1?we.owner===(((le=e.context)==null?void 0:le.currentUser)??e.currentUser??"体验官"):!0}),ce=((At=e.taskColumns)==null?void 0:At.call(e,F))??[],re=[{key:"name",label:"名称",width:250},{key:"owner",label:"当前负责人",width:150},{key:"deliverable",label:"交付物",expanded:!0},{key:"estimate",label:"估分"},{key:"schedule",label:"排期",width:190}],ie=e.taskColumnsMode==="replace"?ce:[...re.filter(we=>!ce.some(le=>le.key===we.key)),...ce],J=we=>we.expanded??!["name","owner","estimate","actual","schedule","dependency"].includes(we.key),ne=(($t=e.taskCanExpand)==null?void 0:$t.call(e,F))??(ce.some(J)||X.some(we=>!!we.deliverable)),he=ne&&v.has(_),pe=he?ie.filter(J):[],Se=he?ie.filter(we=>!J(we)&&!("hideWhenExpanded"in we&&we.hideWhenExpanded)):ie,ke=' style="grid-template-columns:'+Se.map(we=>we.key==="name"?"minmax(250px,1fr)":Math.max(80,we.width??140)+"px").join(" ")+";min-width:"+Se.reduce((we,le)=>we+(le.width??(le.key==="name"?250:140)),0)+'px"',ve=(we,le)=>String(we[le]??""),Ne=(we,le)=>{if(le==="name")return`<label><input type="checkbox" data-task="${D(we.id)}" aria-label="完成任务:${D(we.name)}" ${we.done?"checked":""}><span title="${D(we.name)}">${D(we.name)}</span>${he&&we.done?'<b class="wf-task-status">已完成</b>':""}${e.renderTaskActions?`<span class="wf-task-actions" data-task-actions="${D(we.id)}"></span>`:""}</label>`;if(ce.some(dt=>dt.key===le))return`<div class="wf-task-value" data-task-cell="${D(we.id)}" data-task-column="${D(le)}"></div>`;const Te=le==="owner"?b(ve(we,le)):ve(we,le);return`<span class="${le==="deliverable"?"wf-task-deliverable":""}" title="${D(Te||"暂无")}">${D(Te||(he?"待填":"暂无"))}</span>`},st=ee.map(we=>`<div class="wf-task-row"${ke}>${Se.map(le=>Ne(we,le.key)).join("")}</div>${pe.length?`<div class="wf-task-details" data-task-details="${D(we.id)}">${pe.map(le=>`<div class="wf-task-detail"><span class="wf-task-detail-label">${D(le.label)}</span>${Ne(we,le.key)}</div>`).join("")}</div>`:""}`).join("");return`<section class="wf-tasks" data-module="node:task"><div class="wf-section-head"><div class="wf-task-title"><button type="button" data-wf="toggle-tasks" aria-label="折叠任务" aria-expanded="true"><span class="wf-caret">${Fe("caret")}</span></button><button type="button" data-wf="task-filter">${["全部任务","我参与的","未完成","已完成"][Y]} (${X.filter(we=>we.done).length}/${X.length}) ${Fe("chevron")}</button></div>${ne?`<button type="button" data-wf="expand-tasks">${Fe(he?"list":"expand")} ${he?"列表模式":"展开模式"}</button>`:""}</div><div class="wf-task-table ${he?"is-expanded":""}"><div class="wf-task-row wf-task-heading"${ke}>${Se.map(we=>`<span>${D(he?we.expandedLabel??we.label:we.label)}</span>`).join("")}</div>${st}<button type="button" class="wf-add-task" data-wf="add-task">${Fe("plus")} 新增任务</button></div></section>`}function z(F){return e.renderNodeFields?'<div class="wf-fields" data-module="node:schedule" data-node-fields-slot></div>':'<div class="wf-fields" data-module="node:schedule">'+E().node(F).fields.map(B=>{var ee;const _=F[B.key]??"",X=(ee=e.context)==null?void 0:ee.people,Y=e.renderSystemField?'<span data-system-slot="'+B.key+'"></span>':B.key==="owner"&&X?'<select data-field="owner" aria-label="'+D(B.label)+'"><option value="">待填</option>'+(_&&!X.some(ce=>ce.id===_)?'<option selected value="'+D(_)+'">'+D(_)+"</option>":"")+X.map(ce=>'<option value="'+D(ce.id)+'"'+(ce.id===_?" selected":"")+">"+D(ce.name)+"</option>").join("")+"</select>":'<input data-field="'+B.key+'" aria-label="'+D(B.label)+'" placeholder="待填" value="'+D(_)+'">';return'<label class="wf-field-'+B.key+'"><span>'+D(B.label)+"</span>"+Y+"</label>"}).join("")+"</div>"}function j(F){if(e.renderNodeForm)return'<details class="wf-node-form" data-module="node:form" open><summary><span class="wf-caret">'+Fe("caret")+'</span>节点表单</summary><div class="wf-form-fields" data-node-form-slot></div></details>';const B=E().node(F).form;return B.length?`<details class="wf-node-form" data-module="node:form" open><summary><span class="wf-caret">${Fe("caret")}</span>节点表单</summary><div class="wf-form-fields">${B.map(_=>`<div class="wf-form-row"><label><span>${D(_.label)}${_.required?"<b> *</b>":""}</span>${e.renderField?`<span data-field-slot="${D(_.id)}"></span>`:_.control==="workItemSelect"?`<button type="button" class="wf-reference-field ${_.value?"":"is-empty"}" data-wf="edit-reference" data-reference-field="${D(_.id)}" aria-label="${D(_.label)}"><span>${_.value?_.value.split(",").map(X=>{var Y,ee,ce;return D(((ce=(ee=((Y=e.context)==null?void 0:Y.workItems)??e.workItems)==null?void 0:ee.find(re=>re.id===X))==null?void 0:ce.name)??X)}).join("、"):"待填"}</span>${Fe("chevron")}</button>`:_.type==="select"?`<select data-form="${D(_.id)}" aria-label="${D(_.label)}"><option value="">待填</option>${(_.options??[]).map(X=>`<option ${X===_.value?"selected":""}>${D(X)}</option>`).join("")}</select>`:`<input data-form="${D(_.id)}" type="${_.type==="date"?"date":_.type==="number"?"number":"text"}" aria-label="${D(_.label)}" placeholder="待填" value="${D(_.value||"")}">`}</label></div>`).join("")}</div></details>`:""}function te(F,B){return B?"":`<div class="wf-card-actions" data-module="node:button-group">${F.status==="inProgress"?`<button type="button" class="wf-complete" data-wf="complete">${D(E().node(F).completeLabel)}</button>`:`<span class="wf-state-hint">${Ut[F.status]}</span>`}${M(F,"inline")}<button type="button" data-wf="more" class="wf-more" aria-label="节点更多操作" aria-expanded="false">${Fe("more")}</button></div>`}function ue(F,B=!1,_="selected"){const Y=E().node(F).sections.map(ee=>ee==="form"?B?"":j(F):$(F,_)).join("");return`<article class="wf-card" data-module="workflow:node" data-surface="${_}" data-node="${D(F.id)}"><div class="wf-node-basic" data-module="node:basic"><header class="wf-card-head"><button type="button" class="wf-card-title" data-wf="collapse-card" aria-expanded="true"><span class="wf-caret">${Fe("caret")}</span>${I(F)}</button>${te(F,B)}</header><div class="wf-node-schedule">${z(F)}</div></div><div class="wf-card-body wf-node-sections">${B?"":L(F)}${Y}</div></article>`}function ge(){r.querySelector(".wf-meta").innerHTML=`<div class="wf-roles">${((n==null?void 0:n.tags)??[]).filter(F=>F.enabled!==!1).map(F=>`<span class="wf-role" style="background:${D(F.color||"#eff0f1")}">${D(F.label)}<button type="button" data-remove-tag="${D(F.id)}" aria-label="移除${D(F.label)}">×</button></span>`).join("")}</div>${n!=null&&n.tags.length&&n.switches.length?'<i class="wf-meta-divider"></i>':""}${((n==null?void 0:n.switches)??[]).map(F=>`<label class="wf-switch"><input type="checkbox" data-switch="${D(F.id)}" ${F.checked?"checked":""}>${D(F.label)}</label>`).join("")}`,P(r)}function be(){const F=r.querySelector(".wf-canvas-viewport"),B=F.scrollLeft,{nodes:_,paths:X,width:Y}=Ta(E().graph);F.innerHTML=`<div class="wf-graph-size" style="width:${Y*g}px;height:${420*g}px"><div class="wf-graph" style="width:${Y}px;transform:scale(${g})"><svg width="${Y}" height="420" aria-hidden="true">${X.map(ee=>`<path d="${ee}"/>`).join("")}</svg>${_.map(({node:ee,x:ce,y:re,width:ie})=>`<button type="button" class="wf-node ${ee.id===p?"is-selected":""}" data-select-node="${D(ee.id)}" aria-pressed="${ee.id===p}" style="left:${ce}px;top:${re}px;width:${ie}px">${N(ee)}<span>${D(ee.name)}</span></button>`).join("")}</div></div>`,F.scrollLeft=B}function fe(){H(r);const F=C(p);r.querySelector(".wf-card-area").innerHTML=F?ue(F):'<p class="wf-empty">暂无节点</p>',R(r)}function me(){H(d),d.innerHTML=`<div class="wf-list-toolbar"><div class="wf-filter-wrap"><button type="button" data-wf="filter" class="wf-filter-button">${Fe("filter")} 筛选 ${Fe("chevron")}</button><div class="wf-filter-menu" hidden><label>节点状态<select data-status-filter aria-label="筛选节点状态"><option value="">全部状态</option>${Object.entries(Ut).map(([F,B])=>`<option value="${F}" ${f===F?"selected":""}>${B}</option>`).join("")}</select></label></div></div><div class="wf-views" role="tablist" aria-label="节点视图"><button type="button" role="tab" data-view="details" aria-selected="${u==="details"}">${Fe("detail")} 节点详情</button><button type="button" role="tab" data-view="schedule" aria-selected="${u==="schedule"}">${Fe("list")} 排期信息</button></div></div><div class="wf-list-rows">${E().nodeList.filter(F=>!f||F.status===f).map(F=>h.has(F.id)?ue(F,u==="schedule","list"):`<div class="wf-list-row" data-node="${D(F.id)}"><button type="button" data-wf="expand-card" class="wf-row-title" aria-expanded="false"><span class="wf-caret is-folded">${Fe("caret")}</span>${I(F)}</button><span>${D(b(F.owner)||"待填")}</span><span>${D(F.estimate||"待填")}</span><span>${D(F.schedule||"待填")}</span>${u==="details"?`<span class="wf-state-hint">${Ut[F.status]}</span><button type="button" data-wf="more" class="wf-more" aria-label="节点更多操作">${Fe("more")}</button>`:""}</div>`).join("")||'<p class="wf-empty">暂无匹配节点</p>'}</div>`,R(d)}function Ee(){var F;E().graph.nodes.some(B=>B.id===p)||(p=((F=E().graph.nodes[0])==null?void 0:F.id)??""),ge(),be(),fe(),me()}function Me(F){var B;i||!E().graph.nodes.some(_=>_.id===F)||(p=F,(B=e.onSelectNode)==null||B.call(e,F),be(),fe())}function U(F,B,_){return A({type:"update-node",nodeId:F.id,patch:B,detail:_})}function se(F,B,_,X){var re;(re=F.querySelector(".wf-inline-editor"))==null||re.remove();const Y=document.createElement("div");Y.className="wf-inline-editor",Y.innerHTML=`<input aria-label="${D(B)}" placeholder="${D(B)}" value="${D(_)}"><button type="button" data-save>保存</button><button type="button" data-cancel>取消</button>`,F.append(Y);const ee=Y.querySelector("input"),ce=()=>{ee.value.trim()?X(ee.value.trim()):ee.focus()};Y.querySelector("[data-save]").addEventListener("click",ce),Y.querySelector("[data-cancel]").addEventListener("click",()=>Y.remove()),ee.addEventListener("keydown",ie=>{ie.key==="Enter"&&(ie.preventDefault(),ce()),ie.key==="Escape"&&Y.remove()}),ee.focus()}function Z(F,B,_){var J,ne,he,pe;const X=(J=B.form)==null?void 0:J.find(Se=>Se.id===_);if(!X)return;(ne=F.querySelector(".wf-reference-picker"))==null||ne.remove();const Y=new Set(((he=X.value)==null?void 0:he.split(",").filter(Boolean))??[]),ee=document.createElement("div");ee.className="wf-reference-picker",ee.setAttribute("role","dialog"),ee.setAttribute("aria-label",`选择${X.label}`),ee.innerHTML='<input aria-label="查找工作项" placeholder="搜索工作项"><div class="wf-reference-options"></div><footer><button type="button" data-cancel>取消</button><button type="button" data-save>确定</button></footer>',(pe=Array.from(F.querySelectorAll("[data-reference-field]")).find(Se=>Se.dataset.referenceField===_))==null||pe.after(ee);const ce=ee.querySelector("input"),re=ee.querySelector(".wf-reference-options"),ie=()=>{var ke;const Se=(((ke=e.context)==null?void 0:ke.workItems)??e.workItems??[]).filter(ve=>ve.name.includes(ce.value)).slice(0,50);re.innerHTML=Se.map(ve=>`<label><input type="checkbox" value="${D(ve.id)}" ${Y.has(ve.id)?"checked":""}><span>${D(ve.name)}</span></label>`).join("")||"<p>暂无匹配工作项</p>"};re.addEventListener("change",Se=>{const ke=Se.target;ke.checked?Y.add(ke.value):Y.delete(ke.value)}),ce.addEventListener("input",ie),ee.querySelector("[data-cancel]").addEventListener("click",()=>ee.remove()),ee.querySelector("[data-save]").addEventListener("click",()=>{var Se;return U(B,{form:(Se=B.form)==null?void 0:Se.map(ke=>ke.id===_?{...ke,value:[...Y].join(",")}:ke)},`更新${X.label}`)}),ee.addEventListener("keydown",Se=>{Se.key==="Escape"&&ee.remove()}),ie(),ce.focus()}function W(F,B){var ee,ce,re,ie;const _=[...E().node(F).form,...F.fields??[]].find(J=>{var ne;return J.required&&!((ne=J.value)!=null&&ne.trim())}),X=(ee=F.tasks)==null?void 0:ee.find(J=>J.blocking&&!J.done);(ce=B.querySelector(".wf-error"))==null||ce.remove();const Y=(re=F.gates)==null?void 0:re.find(J=>!J.met);if(_||X||Y){const J=document.createElement("p");J.className="wf-error",J.role="alert",J.textContent=_?`请先填写${_.label}`:X?`请先完成任务:${X.name}`:Y.label,(ie=B.querySelector(".wf-card-head"))==null||ie.after(J);return}U(F,{status:"done"},"完成节点")}function Q(F){var he,pe,Se,ke;const B=F.target;if(B.closest("button:disabled"))return;const _=B.closest("[data-action]");if(_){const ve=(he=_.closest("[data-node]"))==null?void 0:he.dataset.node;ve&&A({type:"action",nodeId:ve,actionId:_.dataset.action});return}const X=B.closest("[data-select-node]");if(X){Me(X.dataset.selectNode);return}const Y=B.closest("[data-view]");if(Y){u=Y.dataset.view,me();return}const ee=B.closest("[data-remove-tag]");if(ee&&n){A({type:"update-flow",detail:{...n,tags:n.tags.map(ve=>ve.id===ee.dataset.removeTag?{...ve,enabled:!1}:ve)}});return}const ce=B.closest("[data-wf]");if(!ce)return;const re=ce.dataset.wf,ie=ce.closest("[data-node]"),J=C((ie==null?void 0:ie.dataset.node)??p);if(re==="legend"){const ve=ce.closest(".wf-legend-wrap");ve.classList.toggle("is-open"),ce.setAttribute("aria-expanded",String(ve.classList.contains("is-open")));return}if(re==="filter"){const ve=d.querySelector(".wf-filter-menu");ve.hidden=!ve.hidden;return}if(!J||!ie)return;const ne=`${ie.dataset.surface??"list"}:${J.id}`;if(re==="edit-reference"){Z(ie,J,ce.dataset.referenceField);return}if(re==="collapse-card")if(m.has(ne)?m.delete(ne):m.add(ne),d.contains(ie))h.delete(J.id),me();else{const ve=ie.querySelector(".wf-card-body");ve.hidden=!ve.hidden,ie.querySelector(".wf-node-schedule").hidden=ve.hidden,ce.setAttribute("aria-expanded",String(!ve.hidden))}else if(re==="expand-card")m.delete(ne),h.add(J.id),me();else if(re==="toggle-tasks"){w.has(ne)?w.delete(ne):w.add(ne);const ve=ie.querySelector(".wf-task-table");ve.hidden=!ve.hidden,ce.setAttribute("aria-expanded",String(!ve.hidden))}else if(re==="task-filter"){const ve=ie.querySelector(".wf-task-filter-menu");if(ve){ve.remove();return}ce.insertAdjacentHTML("afterend",'<div class="wf-task-filter-menu" role="menu">'+["全部任务","我参与的","未完成","已完成"].map((Ne,st)=>`<button type="button" role="menuitem" data-wf="task-filter-option" data-task-filter="${st}">${Ne}</button>`).join("")+"</div>")}else if(re==="task-filter-option")k.set(ne,Number(ce.dataset.taskFilter)),fe(),me();else if(re==="expand-tasks")v.has(ne)?v.delete(ne):v.add(ne),fe(),me();else if(re==="add-task"&&e.onCreateTask)A({type:"action",nodeId:J.id,actionId:"__create-task"});else if(re==="add-task")se(ie.querySelector(".wf-task-table"),"任务名称","",ve=>U(J,{tasks:[...J.tasks??[],{id:crypto.randomUUID(),name:ve,done:!1}]},"新增任务"));else if(re==="complete")W(J,ie);else if(re==="more"){const ve=ie.querySelector(".wf-menu");r.querySelectorAll(".wf-menu").forEach(Ne=>Ne.remove()),d.querySelectorAll(".wf-menu").forEach(Ne=>Ne.remove()),ve||ie.insertAdjacentHTML("beforeend",`<div class="wf-menu" role="menu">${((n==null?void 0:n.menu)??[]).map(Ne=>`<button type="button" role="menuitem" data-wf="${Ne}" ${Ne==="delete-node"&&!E().node(J).deletable?"disabled":""}>${Ne==="delete-node"&&!E().node(J).deletable?'<span title="流程配置不允许删除该节点">'+ki[Ne]+"</span>":ki[Ne]}</button>`).join("")}${M(J,"more")}</div>`),P(ie)}else re==="estimate"?((pe=ie.querySelector(".wf-menu"))==null||pe.remove(),se(ie,"节点估分",J.estimate??"",ve=>U(J,{estimate:ve},"填写估分"))):re==="group-chat"?A({type:"action",nodeId:J.id,actionId:"group-chat"}):re==="delete-node"?((Se=ie.querySelector(".wf-menu"))==null||Se.remove(),ie.insertAdjacentHTML("beforeend",'<div class="wf-delete-confirm" role="alertdialog" aria-label="删除节点"><span>删除此节点?</span><button type="button" data-wf="cancel-delete">取消</button><button type="button" data-wf="confirm-delete">删除</button></div>')):re==="cancel-delete"?(ke=ie.querySelector(".wf-delete-confirm"))==null||ke.remove():re==="confirm-delete"&&A({type:"delete-node",nodeId:J.id})}function ae(F){var X,Y,ee,ce,re,ie,J;const B=F.target;if(!(B instanceof HTMLInputElement||B instanceof HTMLSelectElement)||B.closest("[data-node-fields-slot],[data-node-form-slot],[data-field-slot],[data-system-slot],[data-actions-slot],[data-task-cell]"))return;if(B.dataset.statusFilter!==void 0){f=B.value,me();return}if(B.dataset.switch&&n&&B instanceof HTMLInputElement){const ne=B.checked;A({type:"update-flow",detail:{...n,switches:n.switches.map(he=>he.id===B.dataset.switch?{...he,checked:ne}:he)}});return}const _=C(((X=B.closest("[data-node]"))==null?void 0:X.dataset.node)??"");if(_){if(B.dataset.nodeField){const ne=(Y=_.fields)==null?void 0:Y.find(he=>he.id===B.dataset.nodeField);if(ne!=null&&ne.readonly||((ee=e.can)==null?void 0:ee.call(e,"edit",_,B.dataset.nodeField))===!1){Ee();return}U(_,{fields:(ce=_.fields)==null?void 0:ce.map(he=>he.id===B.dataset.nodeField?{...he,value:B.value}:he)},"更新节点字段")}if(B.dataset.form&&((re=e.can)==null?void 0:re.call(e,"edit",_,B.dataset.form))===!1){Ee();return}B.dataset.field&&U(_,{[B.dataset.field]:B.value},`更新${B.ariaLabel}`),B.dataset.form&&U(_,{form:(ie=_.form)==null?void 0:ie.map(ne=>ne.id===B.dataset.form?{...ne,value:B.value}:ne)},"填写节点表单"),B.dataset.task&&B instanceof HTMLInputElement&&U(_,{tasks:(J=_.tasks)==null?void 0:J.map(ne=>ne.id===B.dataset.task?{...ne,done:B.checked}:ne)},"更新节点任务")}}r.innerHTML=`<div class="wf-workflow-graph" data-module="workflow:graph"><div class="wf-meta" data-module="workflow:graph:controls"></div><div class="wf-canvas" data-module="workflow:graph:canvas"><div class="wf-legend-wrap"><button type="button" class="wf-legend-trigger" data-wf="legend" aria-label="节点图例" aria-expanded="false">${Fe("list")}</button><div class="wf-legend" role="tooltip"><strong>节点图例</strong><span>○ 节点</span><span>◇ 里程碑</span><span>⊙ 含未完成子任务</span><span><i class="wf-dot pending"></i>未开始</span><span><i class="wf-dot inProgress"></i>进行中</span><span><i class="wf-dot done"></i>已完成</span></div></div><div class="wf-canvas-viewport" aria-label="节点流程图"></div></div></div><div class="wf-card-area" data-module="workflow:selected-node"></div>`;for(const F of[r,d])F.addEventListener("click",Q,{signal:c.signal}),F.addEventListener("change",ae,{signal:c.signal});document.addEventListener("pointerdown",F=>{F.target.closest(".wf-task-title")||(r.querySelectorAll(".wf-task-filter-menu").forEach(B=>B.remove()),d.querySelectorAll(".wf-task-filter-menu").forEach(B=>B.remove())),F.target.closest(".wf-menu,.wf-more")||(r.querySelectorAll(".wf-menu").forEach(B=>B.remove()),d.querySelectorAll(".wf-menu").forEach(B=>B.remove()))},{signal:c.signal});const S=r.querySelector(".wf-canvas-viewport");let V=null;S.addEventListener("pointerdown",F=>{F.target.closest("button")||(V={x:F.clientX,y:F.clientY,left:S.scrollLeft,top:S.scrollTop},S.setPointerCapture(F.pointerId))},{signal:c.signal}),S.addEventListener("pointermove",F=>{V&&(S.scrollLeft=V.left+V.x-F.clientX,S.scrollTop=V.top+V.y-F.clientY)},{signal:c.signal});const oe=()=>{V=null};return S.addEventListener("pointerup",oe,{signal:c.signal}),S.addEventListener("pointercancel",oe,{signal:c.signal}),S.addEventListener("wheel",F=>{(F.ctrlKey||F.metaKey)&&(F.preventDefault(),g=Math.max(.5,Math.min(1.5,g+(F.deltaY<0?.1:-.1))),be())},{passive:!1,signal:c.signal}),Ee(),{element:r,nodeListElement:d,renderNodeDetails:()=>d,selectNode:Me,getSelectedNode:()=>C(p),setFlow(F){i||(t=F,n=F.detail,a++,Ee())},update(F){i||(e={...e,...F},F.flow&&(t=F.flow,n=F.flow.detail,a++),F.selectedNodeId!==void 0&&(p=F.selectedNodeId),Ee())},destroy(){i=!0,c.abort(),H(r),H(d),r.remove(),d.remove()}}}function O(s,e="",t){const n=document.createElement(s);return n.className=e,t!==void 0&&(n.textContent=t),n}const mt=new Map;function Xe(s,e){if(!s)return!1;const t=e?[e]:[],n=new Set;for(let i=0;i<Math.max(1,t.length);i++)for(const[o,a]of mt)if(!(n.has(o)||e&&!t[i].contains(a))){if(o.element.contains(s))return!0;n.add(o),t.push(o.element)}return!1}function Ia(s){for(const[e,t]of[...mt])(!s||s.contains(t))&&e.close()}function vt(s){const{anchor:e,content:t,width:n="anchor",gap:i=4,onDismiss:o}=s,a=e.ownerDocument,l=a.defaultView||window,r=s.anchorMode==="element"?e:e.closest(".fc-focus-body")||e,d=a.createElement("div");d.className="rowvia-field-scope rowvia-field-popup-layer";const c=a.createElement("div");c.className="rowvia-field-popup",c.append(t),d.append(c),(e.closest("dialog[open]")||a.body||a.documentElement).append(d);let p=!1;const h=()=>{if(p||!d.isConnected)return;const m=r.getBoundingClientRect(),w=a.documentElement.clientWidth||l.innerWidth,k=a.documentElement.clientHeight||l.innerHeight,C=n==="anchor"?m.width+2:n==="auto"?c.getBoundingClientRect().width:n;c.style.width=n==="auto"?"max-content":C+"px";const b=c.getBoundingClientRect().height;let N=m.bottom+i;const I=m.top-i-b;N+b>k-8&&I>=8&&(N=I),N=Math.max(8,Math.min(N,Math.max(8,k-b-8)));const E=Math.max(8,Math.min(s.align==="end"?m.right-C:m.left,Math.max(8,w-C-8)));d.style.top=Math.round(N)+"px",d.style.left=Math.round(E)+"px"},u=()=>{p||(p=!0,Ia(d),mt.delete(v),a.removeEventListener("pointerdown",f,!0),a.removeEventListener("keydown",g,!0),l.removeEventListener("resize",h),l.removeEventListener("scroll",h,!0),d.remove(),o==null||o())},f=m=>{const w=m.target;w&&(d.contains(w)||r.contains(w)||e.contains(w)||Xe(w,d))||u()},g=m=>{if(m.key!=="Escape"||[...mt.keys()][mt.size-1]!==v)return;if(m.preventDefault(),m.stopPropagation(),u(),s.onEscape){s.onEscape();return}const w=a.defaultView.CustomEvent;e.dispatchEvent(new w("fc-collapse",{bubbles:!0,detail:{reason:"escape"}}))},v={element:d,reposition:h,close:u};return mt.set(v,e),a.addEventListener("pointerdown",f,!0),a.addEventListener("keydown",g,!0),l.addEventListener("resize",h),l.addEventListener("scroll",h,!0),h(),v}const We=s=>s.choices??(s.options||[]).map(e=>({id:e,label:e})),Mi=["rgba(61, 188, 47, 0.2)","rgba(0, 184, 159, 0.2)","rgba(244, 118, 189, 0.2)","rgba(149, 155, 238, 0.2)","rgba(184, 143, 255, 0.2)"],un=(s,e)=>{var t,n;return((t=We(s).find(i=>i.id===e))==null?void 0:t.color)||((n=s.colors)==null?void 0:n[e])||Mi[Math.max(0,We(s).findIndex(i=>i.id===e))%Mi.length]},Ri=s=>(Array.isArray(s)?s:s==null||s===""?[]:[s]).map(String);function Aa(s,e){var t;return((t=We(s).find(n=>n.id===e))==null?void 0:t.label)||e}function Li(s,e="choice"){const t=O("div","fc-tags");for(const n of Ri(s.value)){const i=Aa(s.field,n),o=O(e==="relation"?"button":"span","fc-tag fc-tag--"+e);e==="choice"&&(o.style.backgroundColor=un(s.field,n)),e==="person"&&o.append(O("span","fc-avatar",i.slice(0,1))),o.append(O("span","fc-tag-label",i)),o.tagName==="BUTTON"&&(o.type="button",o.onclick=a=>{var l;a.stopPropagation(),(l=s.onAction)==null||l.call(s,{type:"open",value:n})}),t.append(o)}return t.children.length||t.append(O("span","fc-empty","待填")),t}function hn(s,e,t="choice"){var L;const n=O("div","fc-choice fc-choice--"+t);let i=Ri(e.value).slice(0,s?void 0:1);const o=new Map(We(e.field).map(M=>[M.id,M]));let a=We(e.field);const l=s&&(e.field.maxSelections??0)>0?e.field.maxSelections:1/0,r=O("select","fc-select");r.hidden=!0,r.multiple=s,r.disabled=e.readonly,r.required=!!e.field.required,r.ariaLabel=e.field.label;const d=O("div","fc-choice-head"),c=O("div","fc-choice-selection"),p=O("span","fc-empty fc-choice-placeholder","待填"),h=O("input","fc-choice-search");h.placeholder="",h.autocomplete="off",h.ariaLabel="输入以搜索"+e.field.label,h.disabled=e.readonly;const u=()=>{h.size=Math.max(1,[...h.value].length+1)};u();const f=O("div","fc-option-list");f.setAttribute("role",t==="radio"?"radiogroup":"group"),f.ariaLabel=e.field.label;const g=O("div","fc-error fc-choice-feedback");g.setAttribute("role","status");const v=O("div","fc-picker-status");v.setAttribute("role","status");const m=O("button","fc-retry","重试");m.type="button",m.hidden=!0;let w,k=0,C=!1,b=!1;const N=t!=="radio"&&!!((L=e.services)!=null&&L.searchOptions),I=t!=="radio"&&e.layout!=="compact"&&!e.readonly;let E;const G=()=>{const M=E;E=void 0,M==null||M.close()},x=()=>{!I||C||E||e.readonly||(E=vt({anchor:d,content:f,width:"anchor",onDismiss:()=>{E=void 0}}))},T=()=>{!I||!E||(G(),n.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},A=()=>{var M;(M=e.onSelectedOptions)==null||M.call(e,i.map($=>o.get($)).filter($=>!!$)),n.dispatchEvent(new Event("change",{bubbles:!0}))},H=()=>{var M;if(r.replaceChildren(),!s){const $=O("option");$.value="",r.append($)}for(const $ of new Set([...a.map(z=>z.id),...i])){const z=O("option","",((M=o.get($))==null?void 0:M.label)||$);z.value=$,z.selected=i.includes($),r.append(z)}s||(r.value=i[0]||"")},q=()=>{c.replaceChildren(),f.replaceChildren(),H(),!i.length&&!h.value&&c.append(p);for(const z of i){const j=o.get(z),te=O("span","fc-tag fc-tag--"+t);(t==="choice"||t==="radio")&&(te.style.backgroundColor=un(e.field,z)),t==="person"&&te.append(O("span","fc-avatar",((j==null?void 0:j.label)||z).slice(0,1))),te.append(O("span","fc-tag-label",((j==null?void 0:j.label)||z)+(j!=null&&j.disabled?"(已停用)":"")));const ue=O("span","fc-tag-slot"),ge=O("button","fc-choice-remove","×");ge.type="button",ge.disabled=e.readonly,ge.ariaLabel="移除"+((j==null?void 0:j.label)||z),ge.onclick=be=>{be.stopPropagation(),i=i.filter(fe=>fe!==z),g.textContent="",q(),h.focus(),A()},ue.append(ge),te.append(ue),c.append(te)}const M=h.value.trim().toLocaleLowerCase(),$=a.filter(z=>!z.disabled&&(N||(z.label+" "+z.id+" "+(z.description||"")).toLocaleLowerCase().includes(M)));for(const z of $){const j=O("button","fc-option");j.type="button",j.dataset.value=z.id,j.disabled=e.readonly||b;const te=i.includes(z.id);j.classList.toggle("selected",te),j.setAttribute(t==="radio"?"aria-checked":"aria-pressed",String(te)),t==="radio"&&j.setAttribute("role","radio");const ue=O("span","fc-option-label"+(t==="choice"?" fc-tag":""),z.label);t==="choice"&&(ue.style.backgroundColor=un(e.field,z.id)),t==="person"&&j.append(O("span","fc-avatar",z.label.slice(0,1))),t==="relation"&&j.append(O("span","fc-relation-icon","↗"));const ge=O("span","fc-option-copy");ge.append(ue),z.description&&ge.append(O("small","fc-option-description",z.description)),j.append(ge,O("span","fc-option-mark",te?"✓":"")),j.onclick=be=>{if(be.stopPropagation(),!e.readonly){if(!s)i=[z.id];else if(te)i=i.filter(fe=>fe!==z.id);else{const fe=z.exclusive?[]:i.filter(me=>{var Ee;return!((Ee=o.get(me))!=null&&Ee.exclusive)});if(fe.length>=l){g.textContent="最多可选择 "+l+" 项";return}i=[...fe,z.id]}g.textContent="",s||(h.value="",u()),q(),f.querySelectorAll("button").forEach(fe=>{fe.dataset.value===z.id&&fe.focus()}),A(),!s&&I&&T()}},f.append(j)}!$.length&&!b&&f.append(O("p","fc-empty fc-choice-empty","暂无匹配选项"))},R=async()=>{w==null||w.abort();const M=++k;w=new AbortController,b=!0,m.hidden=!0,v.textContent="加载中…",n.setAttribute("aria-busy","true"),q();try{const $=await e.services.searchOptions(e.field,h.value.trim(),w.signal);if(C||M!==k)return;a=$,$.forEach(z=>o.set(z.id,z)),v.textContent=""}catch{if(C||M!==k)return;a=[],v.textContent="加载失败,请重试",m.hidden=!1}finally{!C&&M===k&&(b=!1,n.setAttribute("aria-busy","false"),q())}};h.oninput=()=>{u(),N?R():q()},h.onfocus=()=>x(),d.onclick=M=>{M.target.closest("button")||h.focus()},m.onclick=()=>void R();const P=M=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(M.key))return;const $=[...f.querySelectorAll("button:not(:disabled)")];if(!$.length)return;M.preventDefault();const z=$.indexOf(document.activeElement),j=M.key==="Home"?0:M.key==="End"?$.length-1:(z+(M.key==="ArrowUp"||M.key==="ArrowLeft"?-1:1)+$.length)%$.length;$[j].focus()};if(f.onkeydown=P,h.onkeydown=M=>{M.key==="ArrowDown"&&(x(),P(M))},r.onchange=()=>{i=[...r.selectedOptions].map(M=>M.value).filter(Boolean),q()},d.append(c),t!=="radio"&&d.append(h),I){const M=O("span","fc-field-chevron");M.setAttribute("aria-hidden","true"),d.append(M),n.append(r,d,v,m,g)}else n.append(r,d,v,f,m,g);return q(),N&&!e.readonly&&R(),{element:n,content:I?f:void 0,read:()=>s?[...i]:i[0]||"",validate:()=>e.field.required&&!i.length?"请选择一个选项":i.length>l?"最多可选择 "+l+" 项":void 0,focus:()=>{var M;if(t==="radio"){(M=f.querySelector("button"))==null||M.focus();return}h.focus(),x()},deactivate:()=>{h.value="",u(),G()},destroy:()=>{C=!0,++k,w==null||w.abort(),G()}}}const $a=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),Ti=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function wt(s){const e=document.createElement("template");e.innerHTML=String(s??"");const t=n=>{for(const i of[...n.childNodes]){if(i.nodeType!==1)continue;const o=i;if(["SCRIPT","STYLE","IFRAME","OBJECT","SVG","MATH"].includes(o.tagName)){o.remove();continue}if(t(o),!$a.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",l=o.getAttribute("src")||"",r=o.getAttribute("alt")||"",d=o.getAttribute("data-person-id"),c=o.hasAttribute("checked"),p=o.getAttribute("data-task")==="true",h=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(f=>[f,o.style.getPropertyValue(f)]),u=o.tagName==="FONT"?o.getAttribute("color"):null;for(const f of[...o.attributes])o.removeAttribute(f.name);for(const[f,g]of h)(f==="color"||f==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(g):f==="text-align"?/^(left|center|right|justify)$/.test(g):f==="margin-left"?/^\d{1,3}px$/.test(g):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(g))&&o.style.setProperty(f,g);if(u&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(u)&&(o.style.color=u),o.tagName==="A"&&Ti(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="IMG"){if(!/^https?:\/\//i.test(l.trim())){o.remove();continue}o.setAttribute("src",l.trim()),o.setAttribute("alt",r),o.setAttribute("loading","lazy"),o.setAttribute("referrerpolicy","no-referrer")}o.tagName==="SPAN"&&d&&(o.setAttribute("data-person-id",d),o.setAttribute("contenteditable","false")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),c&&o.setAttribute("checked","")),p&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const pn={undo:'<path d="M9 5 4 10l5 5M4 10h10a6 6 0 0 1 0 12"/>',redo:'<path d="m15 5 5 5-5 5m5-5H10a6 6 0 0 0 0 12"/>',expand:'<path d="M14 3h7v7m0-7-7 7M10 21H3v-7m0 7 7-7"/>',collapse:'<path d="M21 3l-7 7m0-7v7h7M3 21l7-7m-7 0h7v7"/>',paint:'<path d="M3 3h14v7H3zM17 6h4v8h-9v7"/>',quote:'<path d="M4 12h5v7H2v-7l5-7m10 7h5v7h-7v-7l5-7"/>',table:'<rect x="3" y="3" width="18" height="18" rx="1"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/>',link:'<path d="m10 14 4-4m-7 7-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0m2 10 5-5a4 4 0 0 0-6-6l-1 1"/>',task:'<rect x="3" y="3" width="18" height="18" rx="1"/><path d="m7 12 3 3 7-7"/>',indent:'<path d="M10 5h11M10 12h11M10 19h11M2 8l4 4-4 4"/>',line:'<path d="M3 12h18M3 5h3m3 0h3m3 0h3M3 19h3m3 0h3m3 0h3"/>'};function Ni(s){const e=O("div",`fc-rich${s.layout==="compact"?" fc-rich-compact":""}`),t=O("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const n=O("div","fc-rich-tools");t.append(n);const i=O("div","fc-rich-content");i.contentEditable=String(!s.readonly),i.setAttribute("role","textbox"),i.setAttribute("aria-multiline","true"),i.ariaLabel=s.field.label,i.tabIndex=s.readonly?-1:0,i.innerHTML=wt(s.value);const o=O("div","fc-rich-menu");o.hidden=!0;let a=null,l=!1,r=[i.innerHTML],d=0,c=!1,p=null,h,u;const f=()=>{const L=window.getSelection();L!=null&&L.rangeCount&&i.contains(L.anchorNode)&&i.contains(L.focusNode)&&(a=L.getRangeAt(0).cloneRange())},g=()=>{i.focus();const L=window.getSelection();if(!L)return;const M=a&&i.contains(a.commonAncestorContainer)?a:document.createRange();M!==a&&(M.selectNodeContents(i),M.collapse(!1)),L.removeAllRanges(),L.addRange(M),a=M},v=()=>{var M;const L=u;u=void 0,L==null||L.close(),(M=h==null?void 0:h.destroy)==null||M.call(h),h=void 0,o.hidden=!0,o.replaceChildren()},m=new Map,w=()=>{var L;m.get("撤销").disabled=s.readonly||d===0,m.get("重做").disabled=s.readonly||d===r.length-1;for(const[M,$]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=m.get(M);if(!z)continue;const j=!!((L=document.queryCommandState)!=null&&L.call(document,$));z.classList.toggle("active",j),z.setAttribute("aria-pressed",String(j))}},k=()=>{c||(i.innerHTML!==r[d]&&(r=r.slice(0,d+1),r.push(i.innerHTML),r.length>100&&r.shift(),d=r.length-1),f(),w())},C=()=>{k(),i.dispatchEvent(new Event("change",{bubbles:!0}))},b=L=>{const M=d+L;M<0||M>=r.length||(d=M,c=!0,i.innerHTML=r[d],a=null,g(),c=!1,w(),i.dispatchEvent(new Event("change",{bubbles:!0})))},N=(L,M)=>{s.readonly||(g(),document.execCommand(L,!1,M),f(),v(),C())},I=L=>{if(s.readonly)return;g();const M=window.getSelection().getRangeAt(0);M.deleteContents(),M.insertNode(L),M.setStartAfter(L),M.collapse(!0),a=M.cloneRange(),v(),C()},E=(L,M,$,z=!0)=>{const j=O("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return j.type="button",j.ariaLabel=L,j.title=L,j.disabled=s.readonly,pn[M]?j.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${pn[M]}</svg>`:j.textContent=M,j.onmousedown=te=>{te.preventDefault(),f()},j.onclick=te=>{te.stopPropagation(),$()},n.append(j),m.set(L,j),j},G=(L,M)=>{if(!s.readonly){if(f(),!o.hidden&&o.ariaLabel===L){v();return}v(),o.className="fc-rich-menu",o.ariaLabel=L,o.hidden=!1,u=vt({anchor:m.get(L),anchorMode:"element",content:o,width:"auto",onDismiss:v,onEscape:g}),M(),u==null||u.reposition()}},x=(L,M)=>{const $=O("button","fc-rich-menu-option",L);return $.type="button",$.onmousedown=z=>z.preventDefault(),$.onclick=z=>{z.stopPropagation(),M()},o.append($),$};E("撤销","undo",()=>b(-1),!1),E("重做","redo",()=>b(1),!1),E("格式刷","paint",()=>{f();const L=a==null?void 0:a.startContainer,M=(L==null?void 0:L.nodeType)===1?L:L==null?void 0:L.parentElement;!M||!i.contains(M)||(p={tag:/^(B|STRONG|I|EM|U|S)$/.test(M.tagName)?M.tagName.toLowerCase():"span",css:M.getAttribute("style")||""},m.get("格式刷").classList.add("active"))}),E("正文样式","Aa⌄",()=>G("正文样式",()=>{for(const[L,M]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])x(L,()=>N("formatBlock",M))}));const T=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[L,M,$]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])E(L,M,()=>G(L,()=>{o.classList.add("fc-rich-colors");for(const z of T){const j=x(z,()=>N($,z));j.textContent="",j.style.backgroundColor=z,j.ariaLabel=`${L} ${z}`}x("清除",()=>N($,$==="foreColor"?"#1f2329":"transparent"))}));for(const[L,M,$]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])E(L,M,()=>N($));E("对齐","☰⌄",()=>G("对齐",()=>{for(const[L,M]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])x(L,()=>N(M))})),E("有序列表","1≡",()=>N("insertOrderedList")),E("无序列表","•≡",()=>N("insertUnorderedList")),E("任务列表","task",()=>{g();const L=window.getSelection().getRangeAt(0),M=O("ul"),$=O("li");$.dataset.task="true";const z=O("input");z.type="checkbox",z.contentEditable="false",$.append(z,L.extractContents()),$.textContent||$.append(document.createTextNode("待办事项")),M.append($),I(M)}),E("引用","quote",()=>N("formatBlock","blockquote")),E("缩进","indent",()=>G("缩进",()=>{x("增加缩进",()=>N("indent")),x("减少缩进",()=>N("outdent"))})),E("分隔线","line",()=>I(O("hr"))),E("表格","table",()=>G("表格",()=>{const L=O("p","","选择行列"),M=O("div","fc-rich-table-grid");o.append(L,M);for(let $=1;$<=6;$++)for(let z=1;z<=6;z++){const j=O("button");j.type="button",j.ariaLabel=`${$}行${z}列表格`,j.dataset.row=String($),j.dataset.col=String(z),j.onmousedown=te=>te.preventDefault(),j.onmouseenter=()=>{L.textContent=`${$} × ${z}`,M.querySelectorAll("button").forEach(te=>te.classList.toggle("active",Number(te.dataset.row)<=$&&Number(te.dataset.col)<=z))},j.onclick=()=>{const te=O("table"),ue=O("tbody");for(let be=0;be<$;be++){const fe=O("tr");for(let me=0;me<z;me++){const Ee=O("td");Ee.append(O("br")),fe.append(Ee)}ue.append(fe)}te.append(ue),I(te);const ge=document.createRange();ge.selectNodeContents(te.querySelector("td")),ge.collapse(!0),a=ge,g()},M.append(j)}}));const A=()=>G("链接",()=>{const L=O("input","fc-input");L.ariaLabel="链接文本",L.placeholder="输入文本",L.value=(a==null?void 0:a.toString())||"";const M=O("input","fc-input");M.ariaLabel="链接地址",M.placeholder="粘贴或输入超链接";const $=O("div","fc-error"),z=O("button","primary","确定");z.type="button",z.onclick=()=>{const j=M.value.trim();if(!Ti(j)){$.textContent="请输入 http、https 或 mailto 链接";return}const te=O("a","",L.value||j);te.href=j,te.target="_blank",te.rel="noopener noreferrer",I(te)},o.append(O("span","","文本"),L,O("span","","链接"),M,$,z),L.focus()});E("链接","link",A),E("插入图片","▧",()=>G("插入图片",()=>{const L=O("input","fc-input");L.type="url",L.ariaLabel="图片地址",L.placeholder="https:// 图片地址";const M=O("input","fc-input");M.ariaLabel="图片说明",M.placeholder="图片说明";const $=O("div","fc-error"),z=O("button","primary","插入");z.type="button",z.onclick=()=>{if(!/^https?:\/\//i.test(L.value.trim())||!L.checkValidity()){$.textContent="请输入有效的 http 或 https 图片地址";return}const j=O("img");j.src=L.value.trim(),j.alt=M.value,j.referrerPolicy="no-referrer",I(j)},o.append(L,M,$,z),L.focus()})),E("提及人员","@",()=>G("提及人员",()=>{var M;const L=hn(!1,{...s,value:"",field:{...s.field,label:"人员"}},"person");h=L,o.append(L.element),L.element.addEventListener("change",$=>{var te,ue;$.stopPropagation();const z=String(L.read());if(!z)return;const j=O("span","","@"+(((te=We(s.field).find(ge=>ge.id===z))==null?void 0:te.label)||((ue=L.element.querySelector("option:checked"))==null?void 0:ue.textContent)||z));j.dataset.personId=z,j.contentEditable="false",I(j)}),(M=L.focus)==null||M.call(L)})),E("代码块","{ }",()=>N("formatBlock","pre")),E("表情","☺",()=>G("表情",()=>{o.classList.add("fc-rich-emojis");for(const L of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])x(L,()=>I(document.createTextNode(L)))}));const H=E("全屏编辑","expand",()=>{f(),l=!l,e.classList.toggle("is-fullscreen",l),v(),H.ariaLabel=H.title=l?"收起全屏":"全屏编辑",H.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${pn[l?"collapse":"expand"]}</svg>`,g()},!1);H.disabled=!1,H.classList.add("fc-rich-expand"),t.append(H);const q=()=>{for(const L of n.children)L.inert=L.offsetTop>=n.clientHeight},R=typeof ResizeObserver>"u"?void 0:new ResizeObserver(q);R==null||R.observe(n);const P=L=>{const M=L.target;i.contains(M)||M.closest("input,textarea,select,[contenteditable=true]")||(L.preventDefault(),!e.contains(document.activeElement)&&!o.contains(document.activeElement)&&g())};return e.addEventListener("mousedown",P),o.addEventListener("mousedown",P),i.addEventListener("input",k),i.addEventListener("mouseup",()=>{if(f(),w(),p&&a&&!a.collapsed){const L=a,M=O(p.tag);M.style.cssText=p.css,M.append(L.extractContents()),L.insertNode(M),p=null,m.get("格式刷").classList.remove("active"),C()}}),i.addEventListener("keyup",()=>{f(),w()}),i.addEventListener("click",L=>{const M=L.target;if(M.tagName==="A"&&L.preventDefault(),M instanceof HTMLInputElement&&M.type==="checkbox"){if(s.readonly){L.preventDefault();return}M.toggleAttribute("checked",M.checked),C()}v()}),i.addEventListener("drop",L=>L.preventDefault()),i.addEventListener("paste",L=>{var $,z;if(s.readonly){L.preventDefault();return}L.preventDefault(),f();const M=($=L.clipboardData)==null?void 0:$.getData("text/html");if(M){const j=document.createElement("template");j.innerHTML=wt(M);const te=j.content,ue=document.createTextNode("");te.append(ue),g();const ge=window.getSelection().getRangeAt(0);ge.deleteContents(),ge.insertNode(te),ge.setStartAfter(ue),ge.collapse(!0),a=ge.cloneRange(),C()}else I(document.createTextNode(((z=L.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",L=>{L.key==="Escape"&&!o.hidden?(L.preventDefault(),L.stopPropagation(),v(),g()):L.key==="Escape"&&l?(L.preventDefault(),L.stopPropagation(),H.click()):!s.readonly&&(L.metaKey||L.ctrlKey)&&L.key.toLowerCase()==="z"?(L.preventDefault(),b(L.shiftKey?1:-1)):(L.metaKey||L.ctrlKey)&&L.key.toLowerCase()==="k"&&(L.preventDefault(),f(),A())}),e.append(t,i),w(),{element:e,content:o,inputRoot:e,read:()=>wt(i.innerHTML),validate:()=>{var L;return s.field.required&&!((L=i.textContent)!=null&&L.trim())&&!i.querySelector("img")?"请填写内容":void 0},focus:()=>i.focus(),deactivate:()=>{v(),l=!1,e.classList.remove("is-fullscreen"),H.ariaLabel=H.title="全屏编辑"},destroy:()=>{R==null||R.disconnect(),v()}}}const Ii="请输入评论(Enter 换行,⌘ + Enter 发送)",Fa={reply:'<path d="M4 4h16v13h-5l-3 3-3-3H4zM8 10h8"/>',edit:'<path d="m5 15 10-10 4 4L9 19H5zM13 7l4 4M4 22h17"/>',sort:'<path d="M6 20V4m-3 3 3-3 3 3M13 6h8M13 12h6M13 18h3"/>'},fn=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Fa[s]}</svg>`,Ai=s=>`<span class="detail-comment-avatar" aria-hidden="true">${D(s.slice(0,1))}</span>`,$i=s=>s.html===void 0?D(s.content).replace(/\n/g,"<br>"):wt(s.html);function Da(s){let e={...s};const t=typeof e.author=="string"?e.author:e.author.display;let n=e.data||e.comments||[],i,o,a=!1,l=0;const r=new AbortController,d=new Set,c=[],p=()=>{c.splice(0).forEach(R=>R())},h=(R,P)=>{var M;if(I||!(e.onSave||(R==="edit"?e.onEdit:e.onPublish))||R!=="create"&&!P)return!1;const L=(M=e.permissions)==null?void 0:M[R];return typeof L=="function"?!!P&&L(P):L===!0},u=document.createElement("section");u.className="detail-comments rowvia-field-scope rowvia-detail-module",u.dataset.module="detail:tabs:comment",u.ariaLabel="评论/备注";const f=document.createElement("ul");f.className="detail-comment-list",u.append(f);const g=document.createElement("button");g.type="button",g.className="detail-comment-load-more",g.textContent="加载更多";const v=document.createElement("div");v.setAttribute("role","alert"),u.append(g,v);let m=!1;g.onclick=async()=>{if(!(I||m||!e.hasMore||!e.onLoadMore)){m=!0,g.disabled=!0,v.textContent="";try{await e.onLoadMore(r.signal)}catch(R){I||(v.textContent=R instanceof Error?R.message:"加载失败,请重试")}finally{m=!1,I||(g.disabled=!1,g.hidden=!e.hasMore)}}};const w=document.createElement("div");w.className="detail-comment-composer rowvia-field-scope rowvia-detail-module",w.dataset.module="detail:comment:composer",w.innerHTML=`${Ai(t)}<div class="detail-comment-compose-main"></div>`;const k=w.lastElementChild;let C,b,N=!1,I=!1;const E=()=>n.map((R,P)=>typeof R=="string"?{id:`legacy-${P}`,author:t,content:R,createdAt:""}:R);function G(R,P,L,M){var Me;const $=Ni({field:{key:"comment",label:"评论",kind:"richText",required:!0,choices:(Me=e.people)!=null&&Me.length?e.people:[{id:t,label:t}]},value:R,readonly:!1,layout:"form",services:e.services});$.element.classList.add("detail-comment-editor");const z=$.element.querySelector(".fc-rich-tools");for(const U of["插入图片","提及人员"])z.append(z.querySelector(`[aria-label="${U}"]`));const j=$.element.querySelector(".fc-rich-content");j.dataset.placeholder=Ii;const te=document.createElement("div");te.className="detail-comment-editor-actions",te.innerHTML='<button type="button" data-cancel-comment>取消</button><button type="button" class="primary" data-publish-comment>发布评论</button>',$.element.append(te);const ue=te.querySelector("[data-publish-comment]"),ge=document.createElement("div");ge.className="detail-comment-error",ge.setAttribute("role","alert"),$.element.append(ge);const be=te.querySelector("[data-cancel-comment]"),fe=()=>h(P.action==="edit"?"edit":P.action==="reply"?"reply":"create",E().find(U=>U.id===(P.id||P.replyTo))),me=()=>{var se;const U=!((se=j.textContent)!=null&&se.replace(/[\u200b\u00a0]/g," ").trim())&&!j.querySelector("img,table,hr");j.classList.toggle("is-empty",U),ue.disabled=U||a||!fe(),be.disabled=a,$.element.inert=a,j.contentEditable=String(!a&&fe()),$.element.querySelector(".fc-rich-toolbar").inert=a||!fe()},Ee=()=>{if(me(),ue.disabled||I)return;const U=String($.read()),se=document.createElement("div");se.innerHTML=U,a=!0,ge.textContent="",$.element.setAttribute("aria-busy","true"),me();const Z=l,W=()=>{a=!1,!I&&($.element.setAttribute("aria-busy","false"),me())},Q=S=>{if(!I){if(S!==!0&&!Array.isArray(S)){ae(new Error("保存失败,请重试"));return}Array.isArray(S)&&Z===l&&(n=S),W(),L()}},ae=S=>{I||(W(),ge.textContent=S instanceof Error?S.message:"保存失败,请重试")};try{const S={...P,html:U,content:(se.innerText||se.textContent||"").trim()},V=e.onSave?e.onSave(S,r.signal):P.action==="edit"?e.onEdit(P.id,S,r.signal):e.onPublish(S,r.signal);typeof V=="object"&&V!==null&&"then"in V?Promise.resolve(V).then(Q,ae):Q(V)}catch(S){ae(S)}};return te.querySelector("[data-cancel-comment]").onclick=()=>{!a&&!I&&M()},ue.onclick=Ee,$.element.addEventListener("input",me),$.element.addEventListener("change",me),j.addEventListener("keydown",U=>{U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!U.isComposing&&(U.preventDefault(),U.stopPropagation(),Ee())}),me(),$}function x(){var R;(R=C==null?void 0:C.destroy)==null||R.call(C),C=void 0,o=void 0,w.classList.remove("is-editing"),w.hidden=!h("create"),k.innerHTML=`<button type="button" class="detail-comment-placeholder">${Ii}</button>`,k.querySelector("button").onclick=()=>T()}function T(R){var z,j,te,ue,ge,be;if(a||!h(R?"reply":"create",R))return;const P=R==null?void 0:R.author;o=R==null?void 0:R.id;const L=`${(C==null?void 0:C.read())||""}${P?`<span data-person-id="${D(((j=(z=e.people)==null?void 0:z.find(fe=>fe.label===P))==null?void 0:j.id)||P)}">@${D(P)}</span>&nbsp;`:""}`;(te=C==null?void 0:C.destroy)==null||te.call(C),C=G(L,{action:o?"reply":"create",replyTo:o},()=>{x(),A()},x),w.hidden=!1,w.classList.add("is-editing"),k.replaceChildren(C.element),(ue=C.focus)==null||ue.call(C);const M=C.element.querySelector(".fc-rich-content"),$=document.createRange();$.selectNodeContents(M),$.collapse(!1),(ge=window.getSelection())==null||ge.removeAllRanges(),(be=window.getSelection())==null||be.addRange($)}function A(){if(I)return;p(),g.hidden=!e.hasMore||!e.onLoadMore;const R=E().map((P,L)=>({comment:P,index:L}));N&&R.reverse(),f.innerHTML=R.length?R.map(({comment:P,index:L})=>`
91
91
  <li class="detail-comment" data-comment-index="${L}">
92
- ${Mi(O.author)}
92
+ ${Ai(P.author)}
93
93
  <div class="detail-comment-main">
94
- <div class="detail-comment-meta"><strong>${D(O.author)}</strong><time>${O.createdAt?`于 ${D(O.createdAt)} 评论`:"历史评论"}</time></div>
94
+ <div class="detail-comment-meta"><strong>${D(P.author)}</strong><time>${P.createdAt?`于 ${D(P.createdAt)} 评论`:"历史评论"}</time></div>
95
95
  <div class="detail-comment-content-wrapper">
96
- <div class="detail-comment-bubble"><div class="detail-comment-content fc-value">${Ri(O)}</div></div>
97
- <div class="detail-comment-actions">${h("reply",O)?`<button type="button" data-comment-action="reply" aria-label="回复评论" title="回复">${dn("reply")}</button>`:""}${h("edit",O)?`<button type="button" data-comment-action="edit" aria-label="编辑评论" title="编辑">${dn("edit")}</button>`:""}</div>
96
+ <div class="detail-comment-bubble"><div class="detail-comment-content fc-value">${$i(P)}</div></div>
97
+ <div class="detail-comment-actions">${h("reply",P)?`<button type="button" data-comment-action="reply" aria-label="回复评论" title="回复">${fn("reply")}</button>`:""}${h("edit",P)?`<button type="button" data-comment-action="edit" aria-label="编辑评论" title="编辑">${fn("edit")}</button>`:""}</div>
98
98
  </div>
99
99
  </div>
100
- </li>`).join(""):'<li class="detail-empty">暂无评论</li>';for(const O of f.querySelectorAll("[data-comment-index]")){const L=S()[Number(O.dataset.commentIndex)];if(e.renderActions){const M=e.renderActions(O.querySelector(".detail-comment-actions"),L);M&&c.push(M)}if(e.renderAttachments){const M=document.createElement("div");M.className="detail-comment-attachments",O.querySelector(".detail-comment-main").append(M);const $=e.renderAttachments(M,L);$&&c.push($)}}if(b&&i){const O=[...f.querySelectorAll("[data-comment-index]")].find(M=>{var $;return(($=S()[Number(M.dataset.commentIndex)])==null?void 0:$.id)===i}),L=O==null?void 0:O.querySelector(".detail-comment-content-wrapper");L?(L.classList.add("is-editing"),L.replaceChildren(b.element)):H()}f.querySelectorAll(".detail-comment-content input").forEach(O=>{O.disabled=!0})}function H(){var R;(R=b==null?void 0:b.destroy)==null||R.call(b),b=void 0,i=void 0}u.onclick=R=>{var U;if(a||A)return;const O=R.target.closest("[data-comment-action]");if(!O)return;const L=O.closest("[data-comment-index]"),M=Number(L.dataset.commentIndex),$=S()[M];if(O.dataset.commentAction==="reply"){k($);return}if(!h("edit",$))return;H(),T(),i=$.id;const _=f.querySelector(`[data-comment-index="${M}"] .detail-comment-content-wrapper`);b=G(Ri($),{action:"edit",id:$.id},()=>{H(),T()},()=>{H(),T()}),_.classList.add("is-editing"),_.replaceChildren(b.element),(U=b.focus)==null||U.call(b)};function W(R){if(A)return;const O=R.querySelector('[data-detail-tab="评论/备注"]');if(!O||O.querySelector(".detail-comment-sort"))return;const L=document.createElement("span");L.className="detail-comment-sort",L.setAttribute("role","button"),L.tabIndex=0,L.ariaLabel=I?"当前最新在前,切换最早在前":"当前最早在前,切换最新在前",L.title=L.ariaLabel,L.innerHTML=dn("sort"),L.classList.toggle("newest-first",I);const M=$=>{A||a||($.stopPropagation(),I=!I,T(),L.remove(),d.delete(L),W(R))};L.onclick=M,L.onkeydown=$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),M($))},O.append(L),d.add(L)}return E(),T(),{element:u,composer:y,decorateTab:W,update:R=>{A||(e={...e,...R},(R.data||R.comments)&&(n=R.data||R.comments,++l),T(),C&&C.element.dispatchEvent(new Event("change")),b&&b.element.dispatchEvent(new Event("change")),C||(y.hidden=!h("create")))},deactivate:()=>{var R,O;(R=C==null?void 0:C.deactivate)==null||R.call(C),(O=b==null?void 0:b.deactivate)==null||O.call(b)},destroy:()=>{var R;A=!0,r.abort(),(R=C==null?void 0:C.destroy)==null||R.call(C),H(),p(),d.forEach(O=>O.remove()),d.clear(),u.onclick=null,g.onclick=null,u.replaceChildren(),y.replaceChildren()}}}const tt=s=>String(s).padStart(2,"0"),cn=s=>`${s.getFullYear()}-${tt(s.getMonth()+1)}-${tt(s.getDate())}`;function qt(s){if(!/^(\d{4})-(\d{2})-(\d{2})$/.exec(s))return!1;const t=new Date(`${s}T12:00:00`);return!Number.isNaN(t.getTime())&&cn(t)===s}const Li=s=>{var e,t,n;return{time:((e=s.field.dateOptions)==null?void 0:e.showTime)??s.field.kind!=="date",range:((t=s.field.dateOptions)==null?void 0:t.showRange)??!1,seconds:((n=s.field.dateOptions)==null?void 0:n.showSeconds)??s.field.kind==="datetime"}};function Ti(s){const{time:e,range:t,seconds:n}=Li(s),o=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(a=>e?String(a).slice(0,n?19:16).replace("T"," "):String(a).slice(0,10)).join(" 至 ");return V("div",`fc-value fc-${s.className||""}${o?"":" fc-empty"}`,o||"待填")}function Ni(s){const{time:e,range:t,seconds:n}=Li(s),i=V("div","fc-calendar"),o=Array.isArray(s.value)?s.value:[s.value],a=[0,1].map(P=>String(o[P]||"").slice(0,10)),l=[0,1].map(P=>(String(o[P]||"").slice(11,16)||"00:00")+(n?":"+(String(o[P]||"").slice(17,19)||"00"):""));let r=0,d=!1,c=qt(a[0])?new Date(`${a[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const p=V("div","fc-calendar-panel"),h=V("div","fc-calendar-inputs"),u=[],f=()=>i.dispatchEvent(new Event("change",{bubbles:!0})),g=V("div","fc-error");g.setAttribute("role","status");const v=()=>{if(a.some(P=>P&&!qt(P)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!a[0])return"请选择日期";if(t&&!!a[0]!=!!a[1])return"请选择完整的日期范围";if(e&&l.slice(0,t?2:1).some(P=>!(n?/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/:/^([01]\d|2[0-3]):[0-5]\d$/).test(P)))return"请输入有效时间";if(t&&a[0]&&`${a[0]}T${e?l[0]:""}`>`${a[1]}T${e?l[1]:""}`)return"结束日期时间不能早于开始日期时间"},m=()=>{g.textContent=v()||"",g.textContent||f()};for(let P=0;P<(t?2:1);P++){const z=V("input","fc-input fc-calendar-date");z.type="text",z.value=a[P],z.placeholder=t?P?"结束日期":"开始日期":"YYYY-MM-DD",z.ariaLabel=t?z.placeholder:s.field.label,z.disabled=s.readonly,z.onfocus=()=>{if(r=P,d=P===1,qt(a[P])){const j=new Date(`${a[P]}T12:00:00`);c=new Date(j.getFullYear(),j.getMonth(),1)}$()},z.addEventListener("change",j=>{if(j.stopPropagation(),a[P]=z.value.trim(),qt(a[P])){const Y=new Date(`${a[P]}T12:00:00`);c=new Date(Y.getFullYear(),Y.getMonth(),1)}$(),m()}),h.append(z),u.push(z)}const y=V("div","fc-calendar-header"),x=V("button","fc-calendar-month");x.type="button",x.ariaLabel="选择年份和月份",x.setAttribute("aria-expanded","false"),x.setAttribute("aria-live","polite");const C=(P,z,j)=>{const Y=V("button","fc-calendar-nav");return Y.type="button",Y.ariaLabel=P,Y.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${j?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,z>0&&Y.classList.add("next"),Y.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+z,1),$()},Y};y.append(C("上一年",-12,!0),C("上个月",-1,!1),x,C("下个月",1,!1),C("下一年",12,!0));const b=V("div","fc-calendar-weekdays");for(const P of["日","一","二","三","四","五","六"])b.append(V("span","",P));const I=V("div","fc-calendar-days");I.setAttribute("role","group"),I.ariaLabel="选择日期";const A=V("div","fc-calendar-period");A.hidden=!0;const S=V("button","fc-calendar-back","‹ 返回选择日期");S.type="button";const G=V("div","fc-calendar-period-columns"),E=V("div","fc-calendar-period-list");E.setAttribute("role","group"),E.ariaLabel="年份";const k=V("div","fc-calendar-period-list");k.setAttribute("role","group"),k.ariaLabel="月份";const T=V("div","fc-calendar-period-list");T.ariaLabel="秒",T.hidden=!0,G.append(E,k,T),A.append(S,G);let H="period",W=0;const R=[],O=(P=!1)=>{const z=l[W].split(":").map(Number),j=H==="period"?[[E,c.getFullYear(),"年"],[k,c.getMonth()+1,"月"]]:[[E,z[0],"时"],[k,z[1],"分"],[T,z[2],"秒"]];for(const[Y,re,Ce]of j)for(const N of Y.querySelectorAll("button")){const K=Number(N.dataset.value)===re;N.classList.toggle("selected",K),N.setAttribute("aria-pressed",String(K)),N.textContent=`${H==="time"?tt(Number(N.dataset.value)):N.dataset.value}${K?Ce:""}`,K&&P&&(Y.scrollTop=Math.max(0,N.offsetTop-108))}},L=(P,z)=>{const j=V("button","fc-calendar-period-option",String(P));return j.type="button",j.dataset.value=String(P),j.ariaLabel=`${H==="time"?tt(P):P}${H==="time"?z?"时":"分":z?"年":"月"}`,j.disabled=H==="time"&&s.readonly,j.onclick=()=>{if(H==="time"){const Y=l[W].split(":");Y[z?0:1]=tt(P),l[W]=Y.join(":"),R[W].textContent=l[W],O(),m();return}c.setFullYear(z?P:c.getFullYear(),z?c.getMonth():P-1,1),O(),$()},j},M=(P,z=0)=>{if(H=P,W=z,E.replaceChildren(),k.replaceChildren(),T.replaceChildren(),T.hidden=P!=="time"||!n,E.ariaLabel=P==="period"?"年份":"小时",k.ariaLabel=P==="period"?"月份":"分钟",P==="period"){for(let j=Math.max(1,c.getFullYear()-100);j<=Math.min(9999,c.getFullYear()+100);j++)E.append(L(j,!0));for(let j=1;j<=12;j++)k.append(L(j,!1))}else{for(let j=0;j<24;j++)E.append(L(j,!0));for(let j=0;j<60;j++)k.append(L(j,!1));if(n)for(let j=0;j<60;j++){const Y=V("button","fc-calendar-period-option",tt(j));Y.type="button",Y.dataset.value=String(j),Y.ariaLabel=tt(j)+"秒",Y.disabled=s.readonly,Y.onclick=()=>{const re=l[W].split(":");re[2]=tt(j),l[W]=re.join(":"),R[W].textContent=l[W],O(),m()},T.append(Y)}}i.classList.add("choosing-period"),A.hidden=!1,(P==="period"?x:R[z]).setAttribute("aria-expanded","true"),O(!0),S.focus()};x.onclick=()=>M("period"),S.onclick=()=>{i.classList.remove("choosing-period"),A.hidden=!0;const P=H==="period"?x:R[W];P.setAttribute("aria-expanded","false"),$(),P.focus()},A.addEventListener("keydown",P=>{if(P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),S.click()),!["ArrowUp","ArrowDown","Home","End"].includes(P.key))return;const z=P.target,j=z.closest(".fc-calendar-period-list");if(!j)return;const Y=[...j.querySelectorAll("button")],re=Y.indexOf(z),Ce=P.key==="Home"?0:P.key==="End"?Y.length-1:Math.max(0,Math.min(Y.length-1,re+(P.key==="ArrowDown"?1:-1)));P.preventDefault(),Y[Ce].focus()});function $(){x.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((z,j)=>z.classList.toggle("active",j===r)),I.replaceChildren();for(let z=0;z<c.getDay();z++)I.append(V("span","fc-calendar-blank"));const P=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let z=1;z<=P;z++){const j=cn(new Date(c.getFullYear(),c.getMonth(),z)),Y=V("button","fc-calendar-day",String(z));Y.type="button",Y.ariaLabel=j,Y.disabled=s.readonly;const re=a[0]===j||t&&a[1]===j;Y.classList.toggle("selected",re),Y.setAttribute("aria-pressed",String(re)),Y.classList.toggle("in-range",t&&!!a[0]&&!!a[1]&&j>a[0]&&j<a[1]),j===cn(new Date)&&(Y.classList.add("today"),Y.setAttribute("aria-current","date")),Y.onclick=()=>{var Ce;t?d?(a[1]=j,a[0]&&a[1]<a[0]&&([a[0],a[1]]=[a[1],a[0]]),r=0,d=!1):(a[0]=j,a[1]="",r=1,d=!0):a[0]=j,u.forEach((N,K)=>N.value=a[K]),$(),!t||a[1]?m():g.textContent="",(Ce=I.querySelector(`[aria-label="${j}"]`))==null||Ce.focus(),(!t||a[1])&&i.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))},I.append(Y)}}p.append(y,b,I,A);const _=V("div","fc-calendar-time");if(e){for(let P=0;P<(t?2:1);P++){const z=V("div","fc-calendar-time-field"),j=t?P?"结束时间":"开始时间":"时间",Y=V("button","fc-input fc-calendar-time-trigger",l[P]);Y.type="button",Y.disabled=s.readonly,Y.ariaLabel=j,Y.setAttribute("aria-expanded","false"),Y.onclick=()=>M("time",P),R.push(Y),z.append(V("span","",j),Y),_.append(z)}p.append(_)}const U=V("button","fc-calendar-clear","清空");U.type="button",U.disabled=s.readonly,U.onclick=()=>{a.fill(""),u.forEach(P=>P.value=""),r=0,d=!1,$(),m()},i.append(h,p,U,g);const ee=()=>{const P=a.slice(0,t?2:1).map((z,j)=>z?z+(e?`T${l[j]}`:""):"");return t?P.some(Boolean)?P:[]:P[0]};if(s.layout==="compact"||s.readonly)return $(),{element:i,read:ee,validate:v,focus:()=>{u[0].focus()},deactivate:()=>{i.classList.remove("choosing-period"),A.hidden=!0}};const ae=V("div","fc-date-mirror"),he=()=>ae.replaceChildren(Ti({...s,value:ee()})),be=V("span","fc-field-chevron");be.setAttribute("aria-hidden","true");const fe=V("div","fc-date-trigger");fe.tabIndex=0,fe.setAttribute("role","button"),fe.ariaLabel=`编辑${s.field.label}`,fe.append(ae,be);let ve;const xe=()=>{const P=ve;ve=void 0;const z=!!P&&P.element.contains(document.activeElement);P==null||P.close(),be.classList.remove("is-open"),z&&queueMicrotask(()=>{ve||!fe.isConnected||fe.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))})},me=()=>{ve||s.readonly||(he(),ve=kt({anchor:fe,content:i,width:320,gap:4,onDismiss:()=>{ve=void 0,be.classList.remove("is-open")}}),be.classList.add("is-open"))};return fe.onclick=()=>me(),fe.onkeydown=P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),me())},i.addEventListener("focusout",P=>{const z=P.relatedTarget;if(z&&(i.contains(z)||fe.contains(z)||Ye(z)))return;const j=new Event("focusout",{bubbles:!0});z&&Object.defineProperty(j,"relatedTarget",{value:z}),fe.dispatchEvent(j)}),i.addEventListener("change",()=>fe.dispatchEvent(new Event("change",{bubbles:!0}))),$(),he(),{element:fe,content:i,inputRoot:fe,read:ee,validate:v,focus:()=>{me(),u[0].focus()},deactivate:xe,destroy:xe}}const un=[{key:"wit_node",label:"节点"},{key:"wit_subtask",label:"任务"},{key:"wit_field",label:"字段"},{key:"wit_role_and_user",label:"角色与人员"},{key:"wit_schedule",label:"计划表"},{key:"ai_run",label:"AI 操作"},{key:"wit",label:"工作项"}];function Ii(s,e){return s.history.map((t,n)=>{var o;const i=typeof t=="string"?{actor:e,module:t.startsWith("关联素材")?"素材管理":"工作项",detail:t,createdAt:""}:t;return{...i,id:i.id||`legacy-${n}`,actorId:i.actorId||i.actor,actorKind:i.actorKind||"user",moduleKey:i.moduleKey||(i.module==="节点流程"?"wit_node":"")||((o=un.find(a=>a.label===i.module))==null?void 0:o.key)||i.module}}).sort((t,n)=>n.createdAt.localeCompare(t.createdAt))}function $a(s){return s.map(e=>{var t,n;return{id:e.id,actorId:(t=e.operator)==null?void 0:t.user_key,actor:((n=e.operator)==null?void 0:n.name)||"系统",actorKind:e.operator_type===0?"user":"system",moduleKey:e.op_record_type_key,module:e.op_record_type_name,detail:e.content,createdAt:new Date(e.created_at).toLocaleString("sv-SE")}})}function Ai(s,e){const t=e.keyword.trim().toLocaleLowerCase(),n=s.filter(d=>e.operatorKinds.has(d.actorKind||"user")&&(!e.operators.size||d.actorKind!=="user"||e.operators.has(d.actorId||d.actor))&&(!e.modules.size||e.modules.has(d.moduleKey||d.module))&&(!e.start||d.createdAt>=e.start.replace("T"," "))&&(!e.end||!!d.createdAt&&d.createdAt<=e.end.replace("T"," "))),i=d=>[d.actor,d.module,d.detail,d.createdAt].some(c=>c.toLocaleLowerCase().includes(t)),o=t?n.filter(i):n,a=t&&e.keywordFilter?o:n,l=Math.max(1,Math.ceil(a.length/20)),r=Math.max(1,Math.min(e.page,l));return{rows:a.slice((r-1)*20,r*20),total:n.length,matching:o.length,filteredTotal:a.length,page:r,pageCount:l}}const hn=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${s}</svg>`,pn=hn('<path d="M3 4h18l-7 8v7l-4 2v-9z"/>'),Fa=hn('<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6"/>'),Da=hn('<path d="m6 6 12 12M6 18 18 6"/>'),Pa=[["user","用户"],["computed","计算字段"],["automation","自动化规则"],["system","其它系统操作"]];function Ha(s){let e={...s},t=e.page||{rows:e.rows||(e.records||[]).filter(S=>typeof S!="string"),nextCursor:e.nextCursor,previousCursor:e.previousCursor},n=!1,i=!1,o=0,a;const l=[],r=()=>{l.splice(0).forEach(S=>S())},d=()=>Ii({history:e.rows||e.records||[]},e.actor||""),c=()=>e.mode==="local",p=document.createElement("section");p.className="detail-history rowvia-detail-module",p.dataset.module="detail:tabs:log";const h={keyword:"",keywordFilter:!1,operatorKinds:new Set(["user","automation","system"]),operators:new Set,modules:new Set,start:"",end:"",page:1,...e.query},u=()=>({...h,operatorKinds:new Set(h.operatorKinds),operators:new Set(h.operators),modules:new Set(h.modules)});Object.assign(h,u());let f;p.innerHTML=`<div class="detail-history-search"><span>${Fa}</span><input type="search" placeholder="搜索" aria-label="搜索操作记录"><div class="detail-history-search-actions" hidden><span data-match-count aria-live="polite"></span><label><input type="checkbox" data-keyword-filter>过滤</label><button type="button" data-clear-search aria-label="清空搜索">${Da}</button></div></div><div class="detail-history-table-wrap"><table class="detail-history-table" aria-label="操作记录"><colgroup><col style="width:172px"><col style="width:140px"><col><col style="width:252px"></colgroup><thead><tr><th scope="col"><span>操作人</span><button type="button" data-history-filter="actor" aria-label="筛选操作人" aria-haspopup="dialog" aria-expanded="false">${pn}</button></th><th scope="col"><span>操作模块</span><button type="button" data-history-filter="module" aria-label="筛选操作模块" aria-haspopup="dialog" aria-expanded="false">${pn}</button></th><th scope="col">操作详情</th><th scope="col"><span>操作时间</span><button type="button" data-history-filter="time" aria-label="筛选操作时间" aria-haspopup="dialog" aria-expanded="false">${pn}</button></th></tr></thead><tbody></tbody></table></div><div class="detail-history-pagination"></div>`;const g=document.createElement("div");g.className="detail-history-status",g.setAttribute("role","status"),p.append(g);const v=p.querySelector("input[type=search]"),m=p.querySelector("tbody"),y=S=>{const G=h.keyword.trim();if(!G)return D(S);let E=0,k="";for(let T=S.toLocaleLowerCase().indexOf(G.toLocaleLowerCase());T>=0;T=S.toLocaleLowerCase().indexOf(G.toLocaleLowerCase(),E))k+=D(S.slice(E,T))+`<mark>${D(S.slice(T,T+G.length))}</mark>`,E=T+G.length;return k+D(S.slice(E))};function x(){if(n)return;r();const S=c()?Ai(d(),h):{rows:t.rows,total:t.total,matching:t.matching,filteredTotal:t.total,page:h.page,pageCount:1};c()&&(h.page=S.page),v.value=h.keyword,p.querySelector("[data-keyword-filter]").checked=h.keywordFilter,p.setAttribute("aria-busy",String(i)),p.querySelector(".detail-history-search-actions").hidden=!h.keyword.trim(),p.querySelector("[data-match-count]").textContent=`${S.matching??"—"} / ${S.total??"—"}`,m.innerHTML=S.rows.length?S.rows.map(E=>`<tr><td><span class="detail-history-actor" title="${D(E.actor)}"><span class="detail-history-avatar" aria-hidden="true">${D(E.actor.slice(0,1))}</span><span>${y(E.actor)}</span></span></td><td title="${D(E.module)}">${y(E.module)}</td><td class="detail-history-description"><span>${y(E.detail)}</span></td><td><time>${y(E.createdAt||"历史记录")}</time></td></tr>`).join(""):'<tr><td colspan="4" class="detail-history-empty">暂无数据</td></tr>',e.renderDetail&&m.querySelectorAll(".detail-history-description > span").forEach((E,k)=>{const T=e.renderDetail(E,S.rows[k]);T&&l.push(T)}),p.querySelector("[data-history-filter=actor]").classList.toggle("active",h.operatorKinds.size!==4||!!h.operators.size),p.querySelector("[data-history-filter=module]").classList.toggle("active",!!h.modules.size);const G=p.querySelector("[data-history-filter=time]");G.classList.toggle("active",!!h.start||!!h.end),G.title=h.start?`${h.start} 至 ${h.end}`:"筛选操作时间",p.querySelector(".detail-history-pagination").innerHTML=c()?S.pageCount>1?`<span>共 ${S.filteredTotal} 条</span><button type="button" data-page="-1" ${S.page===1?"disabled":""} aria-label="上一页">‹</button><span>${S.page} / ${S.pageCount}</span><button type="button" data-page="1" ${S.page===S.pageCount?"disabled":""} aria-label="下一页">›</button>`:"":`<span>${t.total===void 0?"":`共 ${t.total} 条`}</span><button type="button" data-page="-1" ${i||!e.onQuery||t.previousCursor==null?"disabled":""} aria-label="上一页">‹</button><button type="button" data-page="1" ${i||!(e.onQuery||e.onLoadMore)||t.nextCursor==null?"disabled":""} aria-label="下一页">›</button>`}function C(S=!1){if(n)return;if(c()){x();return}if(!(S?e.onLoadMore:e.onQuery)){x();return}a==null||a.abort(),a=new AbortController;const G=++o;i=!0,g.textContent="加载中…",x();const E=u(),k=H=>{n||G!==o||(H&&(t=H,e.records=H.rows,e.rows=H.rows),i=!1,g.textContent="",x())},T=H=>{if(n||G!==o)return;i=!1,g.textContent=H instanceof Error?H.message:"加载失败,请重试";const W=document.createElement("button");W.type="button",W.textContent="重试",W.onclick=()=>C(S),g.append(W),x()};try{const H=S?e.onLoadMore(h.cursor,E,a.signal):e.onQuery(E,a.signal);H instanceof Promise||H&&"then"in H?Promise.resolve(H).then(k,T):k(H)}catch(H){T(H)}}const b=()=>{h.page=1,h.cursor=void 0,C()},I=()=>{const S=f;f=void 0,S==null||S.close()};function A(S){if(S.getAttribute("aria-expanded")==="true"){I();return}I();const G=document.createElement("div");G.className="detail-history-filter-panel",G.setAttribute("role","dialog"),G.ariaLabel=S.ariaLabel;const E=S.dataset.historyFilter,k=[],T=(H,W,R)=>{const O=document.createElement("label");return O.className="detail-history-filter-option",O.innerHTML=`<input type="checkbox" value="${D(W)}" ${R.has(W)?"checked":""}><span>${D(H)}</span>`,O.querySelector("input").onchange=L=>{L.target.checked?R.add(W):R.delete(W),b()},O};if(E==="module"){const H=d(),W=e.modules?[...e.modules]:un.filter(R=>e.nodeFlow||!["wit_node","wit_subtask"].includes(R.key));for(const R of H)W.some(O=>O.key===R.moduleKey)||W.push({key:R.moduleKey,label:R.module});W.forEach(R=>G.append(T(R.label,R.key,h.modules)))}else if(E==="actor"){for(const[H,W]of Pa)if(G.append(T(W,H,h.operatorKinds)),H==="user"){const R=document.createElement("details");R.className="detail-history-users",R.innerHTML='<summary>请选择用户</summary><input type="search" aria-label="搜索用户" placeholder="搜索用户"><div></div>';const O=e.operators?e.operators.map($=>[$.id,$.label]):[...new Map(d().filter($=>$.actorKind==="user").map($=>[$.actorId,$.actor])).entries()],L=R.querySelector("input"),M=()=>R.querySelector("div").replaceChildren(...O.filter(([,$])=>$.includes(L.value)).map(([$,_])=>T(_,$,h.operators)));L.oninput=M,M(),G.append(R)}}else{G.classList.add("detail-history-date-panel");const H=document.createElement("div");H.className="detail-history-date-range",G.append(H);const W=["开始","结束"].map((M,$)=>Ni({field:{key:`log-date-${$}`,label:`${M}日期`,kind:"dateTime",dateOptions:{showTime:!0,showSeconds:!0}},readonly:!1,layout:"compact",value:$?h.end:h.start})),R=document.createElement("div");R.className="detail-history-filter-error",R.setAttribute("role","status");const O=()=>{const[M,$]=W.map(_=>String(_.read()));R.textContent=W.map(_=>{var U;return(U=_.validate)==null?void 0:U.call(_)}).find(Boolean)||(M&&$&&M>$?"结束日期时间不能早于开始日期时间":""),!R.textContent&&(!M&&!$?(h.start="",h.end="",b()):M&&$&&(h.start=M,h.end=$,b()))};W.forEach((M,$)=>{var ae,he;const _=document.createElement("div");_.className="detail-history-date-column",_.setAttribute("aria-label",$?"结束日期时间":"开始日期时间");const U=M.element.querySelector(".fc-calendar-date");U.placeholder="yyyy-MM-dd";const ee=M.element.querySelector(".fc-calendar-time-trigger");M.element.querySelector(".fc-calendar-inputs").append(ee),(ae=M.element.querySelector(".fc-calendar-time"))==null||ae.remove(),(he=M.element.querySelector(".fc-calendar-clear"))==null||he.remove(),_.append(M.element),H.append(_),M.element.addEventListener("change",O),k.push(()=>{var be;return(be=M.destroy)==null?void 0:be.call(M)})}),h.end||W[1].element.querySelector('[aria-label="下个月"]').click();const L=document.createElement("button");L.type="button",L.className="detail-history-clear-dates",L.textContent="清空",L.onclick=()=>{h.start="",h.end="",b(),I()},G.append(R,L)}S.setAttribute("aria-expanded","true"),f=kt({anchor:S,anchorMode:"element",content:G,align:E==="time"?"end":"start",width:E==="time"?570:E==="actor"?240:190,onDismiss:()=>{f=void 0,S.setAttribute("aria-expanded","false"),k.forEach(H=>H())},onEscape:()=>S.focus()})}return v.oninput=()=>{h.keyword=v.value,b()},p.querySelector("[data-keyword-filter]").onchange=S=>{h.keywordFilter=S.target.checked,b()},p.onclick=S=>{if(n)return;const G=S.target.closest("button");G&&(G.dataset.historyFilter?A(G):G.hasAttribute("data-clear-search")?(v.value="",h.keyword="",b(),v.focus()):G.dataset.page&&!G.disabled&&(c()?h.page+=Number(G.dataset.page):h.cursor=(G.dataset.page==="1"?t.nextCursor:t.previousCursor)??void 0,C(!c()&&G.dataset.page==="1"&&!!e.onLoadMore)))},x(),{element:p,refresh:C,deactivate:I,update:S=>{n||(++o,a==null||a.abort(),i=!1,g.textContent="",e={...e,...S},S.query&&(Object.assign(h,S.query),Object.assign(h,u())),S.page?(t=S.page,e.records=S.page.rows,e.rows=S.page.rows):(S.rows||S.records)&&(t={...t,rows:S.rows||S.records.filter(G=>typeof G!="string")},e.rows=t.rows),"nextCursor"in S&&(t.nextCursor=S.nextCursor),"previousCursor"in S&&(t.previousCursor=S.previousCursor),I(),x())},destroy:()=>{n||(n=!0,++o,a==null||a.abort(),I(),r(),v.oninput=null,p.querySelector("[data-keyword-filter]").onchange=null,p.onclick=null,p.replaceChildren())}}}const Oa=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1});function $i(s,e){return e.every(t=>{const n=String(s[t.field]??"").toLocaleLowerCase(),i=t.value.toLocaleLowerCase();switch(t.operator){case"equals":return n===i;case"notEqual":return n!==i;case"blank":return!n;case"notBlank":return!!n;default:return n.includes(i)}})}const fn=new WeakMap;function Fi(s){let e=fn.get(s);e||(e={owners:0,added:!s.classList.contains("rowvia-work-items"),fieldAdded:!s.classList.contains("rowvia-field-scope")},fn.set(s,e),s.classList.add("rowvia-work-items","rowvia-field-scope")),e.owners++;let t=!1;return()=>{t||(t=!0,!--e.owners&&(e.added&&s.classList.remove("rowvia-work-items"),e.fieldAdded&&s.classList.remove("rowvia-field-scope"),fn.delete(s)))}}function gn(s,e,t,n){const i=document.createElement("div");i.className=e,i.innerHTML=t;const o=Fi(s);s.append(i);const a=new je,l=$e(i,e,n);return a.listen(i,"click",r=>{var p;const d=r.target.closest("[data-action]");if(!d||!i.contains(d)||d.matches(":disabled"))return;const c={action:d.dataset.action,anchor:d,originalEvent:r};(p=n.onAction)==null||p.call(n,c),i.dispatchEvent(new CustomEvent("rowvia:action",{detail:c,bubbles:!0}))}),{element:i,lifecycle:a,onInteraction:l.onInteraction,destroy(){a.destroy(),l.destroy(),i.remove(),o()}}}function Ba(s,e){const t=gn(s,"list-tabs",e.tabs.map(o=>`<button class="list-tab" role="tab" data-tab="${D(o)}">${D(o)}</button>`).join("")+`<div class="create-button">${Te("create","新建","plus","primary")}${Te("create-menu","","down","primary")}</div>`,e);t.element.setAttribute("role","tablist");let n=e.value??e.tabs[0]??"";const i=o=>{n=o,t.element.querySelectorAll("[data-tab]").forEach(a=>{const l=a.dataset.tab===n;a.classList.toggle("active",l),a.setAttribute("aria-selected",String(l))})};return t.lifecycle.listen(t.element,"click",o=>{var l;const a=o.target.closest("[data-tab]");!a||a.dataset.tab===n||(i(a.dataset.tab),(l=e.onChange)==null||l.call(e,n),t.element.dispatchEvent(new CustomEvent("rowvia:tab-change",{detail:n,bubbles:!0})))}),t.element.querySelectorAll("[data-action]").forEach(o=>{o.disabled=e.canCreate===!1}),i(n),{element:t.element,onInteraction:t.onInteraction,setValue:i,getValue:()=>n,destroy:t.destroy}}const mn={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};function Va(s,e={}){const t=gn(s,"toolbar",Object.entries(mn).map(([a,l])=>Te(a,l,a)).join("")+`<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${Te("previous-match","","up")}${Te("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${Te("close-search","","close")}</div>${Te("search","查找","search")}<div class="right">${Te("reset","重置","","hidden")}${Te("saved-views","切换视图","down")}${Te("save-view","存为视图","save","outline")}</div>`,e),n=t.element.querySelector("#search"),i=t.element.querySelector("#filter-search"),o=()=>{var a;(a=e.onSearch)==null||a.call(e,n.value,i.checked),t.element.dispatchEvent(new CustomEvent("rowvia:search",{detail:{query:n.value,filter:i.checked},bubbles:!0}))};return t.lifecycle.listen(n,"input",o),t.lifecycle.listen(i,"change",o),{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setRuleCounts(a){for(const l of Object.keys(mn)){const r=t.element.querySelector(`[data-action="${l}"]`);r.classList.toggle("is-set",!!a[l]),r.querySelector("span").textContent=mn[l]+(a[l]?` · ${a[l]}`:"")}t.element.querySelector('[data-action="reset"]').classList.toggle("hidden",!Object.values(a).some(Boolean))}}}function Ga(s,e={}){const t=gn(s,"selection-bar hidden",`${Te("deselect","","close")}<span data-selection-count></span>${Te("batch-status","更新状态")}${Te("batch-owner","更新负责人")}${Te("batch-export","导出")}${Te("batch-archive","终止")}${Te("deselect","取消选择")}`,e),n=t.element.querySelector("[data-selection-count]");return{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setCount(i){t.element.classList.toggle("hidden",i===0),n.textContent=`已选择 ${i} 项`}}}function qa(s,e){const t=Fi(s),n=Xn(s,{getRowId:({data:i})=>i.id,rowHeight:37,headerHeight:32,theme:"ag-theme-quartz",rowSelection:"multiple",defaultColDef:{resizable:!0,sortable:!1,filter:!1},suppressRowClickSelection:!0,groupDefaultExpanded:-1,autoGroupColumnDef:{headerName:"分组",width:180,pinned:"left"},suppressContextMenu:!0,enableRangeSelection:!1,undoRedoCellEditing:!0,stopEditingWhenCellsLoseFocus:!0,localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"},...e});return{...n,onInteraction:n.grid.onInteraction,destroy(){n.grid.destroy(),t()}}}function za(s){const{config:e,controls:t,fieldConfig:n,options:i,$:o,tag:a,activateCell:l,controlContext:r,openDetail:d,colorRuleMatches:c}=s;function p(u){if(u.node.group)return"";const f=u.data,g=u.colDef.field,v=document.createElement("div");v.className="rendered-cell";const m=n(g);if(m&&(m.control||!["title","status"].includes(m.kind||"text")))v.append(t.resolve(m).render(r(m,f,"cell")));else if((m==null?void 0:m.kind)==="title"){const y=document.createElement("a");y.className="item-name",y.href=`#item/${f.id}`,y.textContent=f[g],y.title=f[g],y.addEventListener("click",C=>{C.preventDefault(),clearTimeout(s.detailClickTimer.get()),C.detail===0?d(f):C.detail===1&&s.detailClickTimer.set(window.setTimeout(()=>d(f),280))}),v.append(y);const x=document.createElement("button");x.className="inline-edit",x.innerHTML=Me("pencil"),x.ariaLabel="编辑选题概要",x.onclick=C=>{C.stopPropagation(),l(v,g,f,u.rowIndex)},(m==null?void 0:m.editable)!==!1&&v.append(x)}else(m==null?void 0:m.kind)==="status"?(v.innerHTML=`${a(f.status,g)}<span class="status-days">20 天</span>`,(m==null?void 0:m.editable)!==!1&&(v.onclick=y=>{y.stopPropagation(),l(v,g,f,u.rowIndex)})):i[g]?(v.innerHTML=["creator","owner","space"].includes(g)?D(f[g]):a(f[g],g),(m==null?void 0:m.editable)!==!1&&(v.onclick=y=>{y.stopPropagation(),l(v,g,f,u.rowIndex)})):(v.innerHTML=`<span class="cell-text">${D(f[g]||"暂无")}</span>`,f[g]||v.classList.add("placeholder"));if(m&&m.editable!==!1&&!t.resolve(m).readonly&&m.kind!=="title"){const y=document.createElement("button");y.className="inline-edit field-control",y.ariaLabel=`${m.kind==="status"?"流转":"编辑"}${m.label}`,y.innerHTML=Me(m.kind==="status"?"transition":["select","multiSelect","person"].includes(m.kind||"")?"down":"pencil"),y.onclick=x=>{x.stopPropagation(),l(v,g,f,u.rowIndex)},v.append(y)}return v.title=String(f[g]??""),v}function h(){return[{colId:"_select",headerName:"",width:64,minWidth:64,maxWidth:64,pinned:"left",sortable:!1,resizable:!1,suppressMovable:!0,suppressMenu:!0,checkboxSelection:!0,headerCheckboxSelection:!0,rowDrag:!0,cellRenderer:u=>{if(u.node.group)return"";const f=document.createElement("div");return f.className="row-controls",f.innerHTML=`<span class="row-number">${u.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${u.rowIndex+1} 行" ${u.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${Me("expand")}</button>`,o("input",f).onclick=g=>g.stopPropagation(),o("input",f).onchange=g=>u.node.setSelected(g.target.checked),o("button",f).onclick=g=>{g.stopPropagation(),d(u.data)},f}},...e.fields.map(u=>({field:u.key,headerName:u.label,width:u.width??120,minWidth:u.minWidth??80,pinned:u.pinned,hide:u.hidden,enableRowGroup:!0,editable:!1,valueSetter:f=>u.required&&!String(f.newValue??"").trim()?!1:(f.data[u.key]=f.newValue,!0),comparator:u.options?(f,g)=>u.options.indexOf(f)-u.options.indexOf(g):void 0,sortable:!1,suppressMenu:!0,cellRenderer:p,cellStyle:({data:f})=>{const g=f&&s.view().colors.find(v=>!!v.scope&&v.scope!=="row"&&v.field===u.key&&c(f,v));return g?{backgroundColor:g.color}:{}},tooltipField:u.key,cellClass:u.kind==="title"?"name-cell":void 0,...u.column})),...s.customColumns(),{colId:"_add",hide:e.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}return{cell:p,columnDefs:h}}function _a(s){const{config:e,data:t,fields:n,fieldConfig:i,options:o,controls:a,$:l,showPopup:r,closePopup:d,applyView:c,save:p,resizeGrid:h,decorateHeaders:u}=s;function f(y,x,C={}){e.container.querySelectorAll(".field-picker").forEach(G=>G.remove());const b=document.createElement("div");b.className="field-picker",b.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(G=>`<button data-kind="${G}">${G}</button>`).join("")}</div><div class="field-options"></div>`,e.container.append(b);const I=y.getBoundingClientRect();b.style.left=`${Math.max(12,Math.min(I.left,innerWidth-410))}px`,b.style.top=`${Math.max(12,Math.min(I.bottom+4,innerHeight-340))}px`;let A="推荐";const S=(G="推荐",E="")=>{l(".field-options",b).innerHTML=n.filter(([k,T])=>{var H,W,R,O,L,M;return(!C.available||C.available(k))&&T.includes(E)&&(G==="推荐"||G==="文本"&&["title","text","longText","richText"].includes(((H=i(k))==null?void 0:H.kind)||"text")||G==="选择"&&["status","select","multiSelect"].includes(((W=i(k))==null?void 0:W.kind)||"")||G==="人员"&&((R=i(k))==null?void 0:R.kind)==="person"||G==="时间"&&["date","dateTime"].includes(((O=i(k))==null?void 0:O.kind)||"")||G==="关系"&&((L=i(k))==null?void 0:L.kind)==="relation"||G==="其他"&&((M=i(k))==null?void 0:M.kind)==="vote")}).map(([k,T])=>`<button data-field="${D(k)}" ${C.onCreate?`data-insert="${D(k)}"`:""} class="menu-option">${Me("table")}${D(T)}</button>`).join(""),C.onCreate&&l(".field-options",b).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${Me("add")}添加字段</button>`),b.querySelectorAll("[data-kind]").forEach(k=>{k.classList.toggle("active",k.dataset.kind===G),k.setAttribute("aria-pressed",String(k.dataset.kind===G))})};S(),l("input",b).oninput=G=>S(A,G.target.value),b.onclick=G=>{var k;const E=G.target.closest("button");E&&(G.stopPropagation(),E.dataset.kind&&(A=E.dataset.kind,S(A,l("input",b).value)),E.dataset.field&&(b.remove(),x(E.dataset.field)),E.hasAttribute("data-create-field")&&(b.remove(),(k=C.onCreate)==null||k.call(C)))}}function g(y){const x=s.instance(),C=r(y,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${x.api.getAllColumns().filter(b=>!b.colId.startsWith("_")).map(b=>`<label class="column-option"><input type="checkbox" data-column="${b.colId}" ${b.visible?"checked":""}><span>${D(b.headerName)}</span><button type="button" data-pin="${b.colId}">${b.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);C.onchange=b=>{const I=b.target;I.dataset.column&&x.columnApi.setColumnVisible(I.dataset.column,I.checked)},C.onclick=b=>{const I=b.target.closest("[data-pin]");if(I){b.preventDefault();const A=x.columnApi.getColumn(I.dataset.pin);x.columnApi.setColumnPinned(A,A.pinned?null:"left"),g(y)}},l("input",C).oninput=b=>{const I=b.target.value;C.querySelectorAll(".column-option").forEach(A=>A.hidden=!A.textContent.includes(I))}}function v(y,x,C){const b=s.instance();d();const I=S=>{var k;const E=b.columnApi.getColumnState().findIndex(T=>T.colId===x)+(C?1:0);b.columnApi.setColumnVisible(S,!0),b.columnApi.setColumnPinned(S,x==="_add"?null:((k=b.columnApi.getColumn(x))==null?void 0:k.pinned)??null),b.columnApi.moveColumn(S,Math.max(1,E)),d(),h(),u()};f(y,I,{available:S=>{var G;return!((G=b.columnApi.getColumn(S))!=null&&G.visible)},onCreate:()=>{const S=r(y,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${a.list().map(M=>`<option value="${D(M.id)}">${D(M.label)}</option>`).join("")}</select></label><label>选项(每行一个)<textarea name="options" aria-label="字段选项"></textarea></label><label class="choice-limit hidden">最多可选数量<input name="maxSelections" type="number" min="1" step="1" placeholder="不限" aria-label="最多可选数量"></label><button class="primary" type="submit">确认创建</button></form>`,320),G=l('[name="kind"]',S),E=l('[name="options"]',S),k=E.closest("label"),T=document.createElement("div");T.className="fc-field-schema",T.hidden=!0,T.innerHTML='<p class="hint">每组记录包含以下子字段</p><div class="fc-field-schema-rows"></div><button type="button" class="fc-composite-add">+ 添加子字段</button>';const H=a.list().filter(M=>!M.readonly&&!["composite","multiPersonComposite","attitudeVote","singleVote","multiVote","detail"].includes(M.id)),W=()=>{const M=document.createElement("div");M.className="fc-field-schema-row",M.innerHTML='<input class="fc-input" aria-label="子字段名称" placeholder="子字段名称"><select class="fc-input" aria-label="子字段类型">'+H.map($=>'<option value="'+D($.id)+'">'+D($.label)+"</option>").join("")+'</select><button type="button" aria-label="移除子字段">×</button>',M.querySelector("button").onclick=()=>M.remove(),T.querySelector(".fc-field-schema-rows").append(M)};T.querySelector("button").onclick=W,W();const R=document.createElement("p");R.className="fc-service-note";const O=document.createElement("p");O.className="fc-error",O.setAttribute("role","status"),l("form",S).insertBefore(T,l('button[type="submit"]',S)),l("form",S).insertBefore(R,l('button[type="submit"]',S)),l("form",S).insertBefore(O,l('button[type="submit"]',S));const L=()=>{const M=G.value,$=M==="cascadeSingle"||M==="cascadeMulti";k.hidden=!$&&!["select","multiSelect","radio","singleVote","multiVote","person","multiPerson","relation","multiRelation"].includes(M),E.placeholder=$?"每行一条路径,例如:产品 / 设计 / 交互":"每行一个选项",l(".choice-limit",S).classList.toggle("hidden",!["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(M)),T.hidden=!["composite","multiPersonComposite"].includes(M),R.textContent=$?"用 / 分隔层级;同名上级会合并。":M==="attachment"?"上传操作由宿主上传服务提供。":M.endsWith("Vote")?"投票操作由宿主投票服务提供。":"",O.textContent=""};G.onchange=L,L(),l("form",S).onsubmit=M=>{M.preventDefault();const $=new FormData(M.target),_=String($.get("label")||"").trim();if(!_)return;const U=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,ee=String($.get("kind")),ae={key:U,label:_,kind:ee,editable:!a.resolve({key:U,label:_,kind:ee}).readonly,width:160};["select","multiSelect","person","multiPerson","radio","singleVote","multiVote","relation","multiRelation"].includes(ee)&&(ae.options=[...new Set(String($.get("options")||"").split(`
101
- `).map(fe=>fe.trim()).filter(Boolean))]);const he=Number($.get("maxSelections"));if(["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(ee)&&Number.isInteger(he)&&he>0&&(ae.maxSelections=he),ee==="dateTime"&&(ae.dateOptions={showTime:!0,showSeconds:!0}),ee==="cascadeSingle"||ee==="cascadeMulti"){ae.choices=[];for(const fe of E.value.split(`
102
- `).filter(ve=>ve.trim())){let ve=ae.choices;const xe=fe.split("/").map(me=>me.trim()).filter(Boolean);xe.forEach((me,P)=>{let z=ve.find(j=>j.id===me);z||(z={id:me,label:me},ve.push(z)),P<xe.length-1&&(z.children??(z.children=[]),ve=z.children)})}if(!ae.choices.length){O.textContent="请至少填写一条分类路径";return}}if(ee==="composite"||ee==="multiPersonComposite"){const fe=[...T.querySelectorAll(".fc-field-schema-row")];if(!fe.length||fe.some(ve=>!ve.querySelector("input").value.trim())){O.textContent="请填写子字段名称";return}ae.compositeFields=fe.map((ve,xe)=>({key:"sub_"+xe,label:ve.querySelector("input").value.trim(),kind:ve.querySelector("select").value})),ee==="multiPersonComposite"&&ae.compositeFields.unshift({key:"owner",label:"填写人",kind:"person",required:!0})}e.fields.push(ae),n.push([U,_]),ae.options&&(o[U]=ae.options),t.customFields.push(ae);const be=b.columnApi.getColumnState();b.api.setColumnDefs(s.columnDefs()),b.columnApi.applyColumnState(be,!0),I(U),p(),c()}}})}function m(y,x){const C=s.instance(),b=s.view(),I=C.columnApi.getColumn(x);if(!I||x==="_select")return;if(x==="_add"){v(y,x,!1);return}const A=["向左插入列","向右插入列",o[x]?"以 首项 → 末项 排序":"以 A → Z 排序",o[x]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",I.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],S=r(y,"",[[0,1],[2,3],[4,8],[5,6,7]].map(G=>G.map(E=>`<button class="menu-option${E===7?" destructive":""}" data-col-menu="${E}" ${E===7&&x==="name"?"disabled":""}>${A[E]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");S.dataset.headerMenu="true",S.onclick=G=>{const E=G.target.closest("[data-col-menu]");if(!E)return;const k=+E.dataset.colMenu;d(),(k===0||k===1)&&v(y,x,k===1),(k===2||k===3)&&(b.sorts=[{colId:x,sort:k===2?"asc":"desc"}],c()),k===4&&(b.filters.push({field:x,operator:"contains",value:""}),s.rulePanel("filter",l('[data-action="filter"]'))),k===5&&C.columnApi.setColumnPinned(x,I.pinned?null:"left"),k===6&&s.textDialog("编辑列",I.headerName,T=>{const H=i(x);H&&(H.label=T);const W=C.api.getColumnDefs(),R=W.find(L=>L.field===x);R&&(R.headerName=T);const O=C.columnApi.getColumnState();C.api.setColumnDefs(W),C.columnApi.applyColumnState(O,!0),u()}),k===7&&C.columnApi.setColumnVisible(x,!1),k===8&&(b.groups.includes(x)||b.groups.push(x),c())}}return{fieldPicker:f,showColumns:g,showInsertField:v,showColumnMenu:m}}function Wa(s){const{root:e,view:t,fieldConfig:n,showInsertField:i,showColumnMenu:o,applyView:a}=s,l=r=>e.querySelector(r);return function(){l("#grid").querySelectorAll(".ag-header-cell").forEach(d=>{var f,g;const c=d.dataset.colid;if(c==="_add"){if(!d.querySelector(".work-add-column")){const v=d.querySelector(".ag-header-cell-label"),m=document.createElement("button");m.type="button",m.className="work-add-column",m.ariaLabel="新增字段",m.title="新增字段",m.innerHTML=Me("add"),m.onmousedown=y=>y.stopPropagation(),m.onclick=y=>{y.stopPropagation(),i(m,"_add",!1)},v.replaceChildren(m)}return}if(!n(c))return;if(!d.querySelector(".work-header-sort")){const v=document.createElement("span");v.className="work-header-sort",(f=d.querySelector(".ag-header-cell-label"))==null||f.append(v);const m=document.createElement("button");m.className="work-header-menu",m.ariaLabel=`${n(c).label}操作`,m.innerHTML=Me("more"),m.onclick=x=>{x.stopPropagation(),o(m,c)},m.onmousedown=x=>x.stopPropagation(),d.append(m);for(const x of["right","left"]){const C=document.createElement("button");C.className="work-header-add",C.dataset.insertSide=x,C.ariaLabel=`在${n(c).label}${x==="right"?"右":"左"}侧插入列`,C.title="插入列",C.innerHTML=Me("add"),C.onclick=b=>{b.stopPropagation(),i(C,c,x==="right")},C.onmousedown=b=>b.stopPropagation(),d.append(C)}const y=()=>{const x=d.getBoundingClientRect(),C=l(".grid-wrap").getBoundingClientRect(),I=d.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();d.querySelectorAll(".work-header-add").forEach(A=>{const S=A.dataset.insertSide==="left"?x.left:x.right;A.style.left=`${S-12}px`,A.style.top=`${x.top-20}px`,A.style.setProperty("--insert-line-height",`${Math.max(0,C.bottom-x.top+8)}px`),A.style.display=S<Math.max(C.left,I.left)-1||S>Math.min(C.right,I.right)+1?"none":""}),d.classList.add("insert-points-ready")};d.addEventListener("mouseenter",y),d.addEventListener("focusin",y),d.addEventListener("click",x=>{var b;if(x.target.closest("button,.ag-header-cell-resize"))return;x.stopImmediatePropagation();const C=(b=t().sorts.find(I=>I.colId===c))==null?void 0:b.sort;t().sorts=C==="desc"?[]:[{colId:c,sort:C==="asc"?"desc":"asc"}],a()},{capture:!0})}const p=(g=t().sorts.find(v=>v.colId===c))==null?void 0:g.sort,h=d.querySelector(".work-header-sort"),u=p==="asc"?"↑":p==="desc"?"↓":"↕";h.textContent!==u&&(h.textContent=u),h.classList.toggle("sorted",!!p),d.setAttribute("aria-sort",p==="asc"?"ascending":p==="desc"?"descending":"none")})}}function Ua(s){const{fields:e,fieldConfig:t,options:n,controls:i,newItem:o,fieldPicker:a,showPopup:l,applyView:r}=s;function d(h,u){return!!u.field&&(!!u.value||["blank","notBlank"].includes(u.operator))&&$i(h,[u])}function c(h){const u=s.view(),f=u.colors.map((I,A)=>{var T;const S=(T=t(I.field))==null?void 0:T.label,G=I.field?[["contains",n[I.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],E=!I.field||["blank","notBlank"].includes(I.operator),k=n[I.field]?Vt([["","请选择目标值"],...n[I.field].map(H=>[H,H])],I.value,`data-rule-value="${A}" aria-label="目标值" ${E?"disabled":""}`):`<input data-rule-value="${A}" aria-label="目标值" placeholder="请选择目标值" value="${D(I.value)}" ${E?"disabled":""}>`;return`<div class="color-condition" data-color-row="${A}">
100
+ </li>`).join(""):'<li class="detail-empty">暂无评论</li>';for(const P of f.querySelectorAll("[data-comment-index]")){const L=E()[Number(P.dataset.commentIndex)];if(e.renderActions){const M=e.renderActions(P.querySelector(".detail-comment-actions"),L);M&&c.push(M)}if(e.renderAttachments){const M=document.createElement("div");M.className="detail-comment-attachments",P.querySelector(".detail-comment-main").append(M);const $=e.renderAttachments(M,L);$&&c.push($)}}if(b&&i){const P=[...f.querySelectorAll("[data-comment-index]")].find(M=>{var $;return(($=E()[Number(M.dataset.commentIndex)])==null?void 0:$.id)===i}),L=P==null?void 0:P.querySelector(".detail-comment-content-wrapper");L?(L.classList.add("is-editing"),L.replaceChildren(b.element)):H()}f.querySelectorAll(".detail-comment-content input").forEach(P=>{P.disabled=!0})}function H(){var R;(R=b==null?void 0:b.destroy)==null||R.call(b),b=void 0,i=void 0}u.onclick=R=>{var j;if(a||I)return;const P=R.target.closest("[data-comment-action]");if(!P)return;const L=P.closest("[data-comment-index]"),M=Number(L.dataset.commentIndex),$=E()[M];if(P.dataset.commentAction==="reply"){T($);return}if(!h("edit",$))return;H(),A(),i=$.id;const z=f.querySelector(`[data-comment-index="${M}"] .detail-comment-content-wrapper`);b=G($i($),{action:"edit",id:$.id},()=>{H(),A()},()=>{H(),A()}),z.classList.add("is-editing"),z.replaceChildren(b.element),(j=b.focus)==null||j.call(b)};function q(R){if(I)return;const P=R.querySelector('[data-detail-tab="评论/备注"]');if(!P||P.querySelector(".detail-comment-sort"))return;const L=document.createElement("span");L.className="detail-comment-sort",L.setAttribute("role","button"),L.tabIndex=0,L.ariaLabel=N?"当前最新在前,切换最早在前":"当前最早在前,切换最新在前",L.title=L.ariaLabel,L.innerHTML=fn("sort"),L.classList.toggle("newest-first",N);const M=$=>{I||a||($.stopPropagation(),N=!N,A(),L.remove(),d.delete(L),q(R))};L.onclick=M,L.onkeydown=$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),M($))},P.append(L),d.add(L)}return x(),A(),{element:u,composer:w,decorateTab:q,update:R=>{I||(e={...e,...R},(R.data||R.comments)&&(n=R.data||R.comments,++l),A(),C&&C.element.dispatchEvent(new Event("change")),b&&b.element.dispatchEvent(new Event("change")),C||(w.hidden=!h("create")))},deactivate:()=>{var R,P;(R=C==null?void 0:C.deactivate)==null||R.call(C),(P=b==null?void 0:b.deactivate)==null||P.call(b)},destroy:()=>{var R;I=!0,r.abort(),(R=C==null?void 0:C.destroy)==null||R.call(C),H(),p(),d.forEach(P=>P.remove()),d.clear(),u.onclick=null,g.onclick=null,u.replaceChildren(),w.replaceChildren()}}}const nt=s=>String(s).padStart(2,"0"),gn=s=>`${s.getFullYear()}-${nt(s.getMonth()+1)}-${nt(s.getDate())}`;function jt(s){if(!/^(\d{4})-(\d{2})-(\d{2})$/.exec(s))return!1;const t=new Date(`${s}T12:00:00`);return!Number.isNaN(t.getTime())&&gn(t)===s}const Fi=s=>{var e,t,n;return{time:((e=s.field.dateOptions)==null?void 0:e.showTime)??s.field.kind!=="date",range:((t=s.field.dateOptions)==null?void 0:t.showRange)??!1,seconds:((n=s.field.dateOptions)==null?void 0:n.showSeconds)??s.field.kind==="datetime"}};function Di(s){const{time:e,range:t,seconds:n}=Fi(s),o=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(a=>e?String(a).slice(0,n?19:16).replace("T"," "):String(a).slice(0,10)).join(" 至 ");return O("div",`fc-value fc-${s.className||""}${o?"":" fc-empty"}`,o||"待填")}function Pi(s){const{time:e,range:t,seconds:n}=Fi(s),i=O("div","fc-calendar"),o=Array.isArray(s.value)?s.value:[s.value],a=[0,1].map(U=>String(o[U]||"").slice(0,10)),l=[0,1].map(U=>(String(o[U]||"").slice(11,16)||"00:00")+(n?":"+(String(o[U]||"").slice(17,19)||"00"):""));let r=0,d=!1,c=jt(a[0])?new Date(`${a[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const p=O("div","fc-calendar-panel"),h=O("div","fc-calendar-inputs"),u=[],f=()=>i.dispatchEvent(new Event("change",{bubbles:!0})),g=O("div","fc-error");g.setAttribute("role","status");const v=()=>{if(a.some(U=>U&&!jt(U)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!a[0])return"请选择日期";if(t&&!!a[0]!=!!a[1])return"请选择完整的日期范围";if(e&&l.slice(0,t?2:1).some(U=>!(n?/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/:/^([01]\d|2[0-3]):[0-5]\d$/).test(U)))return"请输入有效时间";if(t&&a[0]&&`${a[0]}T${e?l[0]:""}`>`${a[1]}T${e?l[1]:""}`)return"结束日期时间不能早于开始日期时间"},m=()=>{g.textContent=v()||"",g.textContent||f()};for(let U=0;U<(t?2:1);U++){const se=O("input","fc-input fc-calendar-date");se.type="text",se.value=a[U],se.placeholder=t?U?"结束日期":"开始日期":"YYYY-MM-DD",se.ariaLabel=t?se.placeholder:s.field.label,se.disabled=s.readonly,se.onfocus=()=>{if(r=U,d=U===1,jt(a[U])){const Z=new Date(`${a[U]}T12:00:00`);c=new Date(Z.getFullYear(),Z.getMonth(),1)}$()},se.addEventListener("change",Z=>{if(Z.stopPropagation(),a[U]=se.value.trim(),jt(a[U])){const W=new Date(`${a[U]}T12:00:00`);c=new Date(W.getFullYear(),W.getMonth(),1)}$(),m()}),h.append(se),u.push(se)}const w=O("div","fc-calendar-header"),k=O("button","fc-calendar-month");k.type="button",k.ariaLabel="选择年份和月份",k.setAttribute("aria-expanded","false"),k.setAttribute("aria-live","polite");const C=(U,se,Z)=>{const W=O("button","fc-calendar-nav");return W.type="button",W.ariaLabel=U,W.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${Z?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,se>0&&W.classList.add("next"),W.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+se,1),$()},W};w.append(C("上一年",-12,!0),C("上个月",-1,!1),k,C("下个月",1,!1),C("下一年",12,!0));const b=O("div","fc-calendar-weekdays");for(const U of["日","一","二","三","四","五","六"])b.append(O("span","",U));const N=O("div","fc-calendar-days");N.setAttribute("role","group"),N.ariaLabel="选择日期";const I=O("div","fc-calendar-period");I.hidden=!0;const E=O("button","fc-calendar-back","‹ 返回选择日期");E.type="button";const G=O("div","fc-calendar-period-columns"),x=O("div","fc-calendar-period-list");x.setAttribute("role","group"),x.ariaLabel="年份";const T=O("div","fc-calendar-period-list");T.setAttribute("role","group"),T.ariaLabel="月份";const A=O("div","fc-calendar-period-list");A.ariaLabel="秒",A.hidden=!0,G.append(x,T,A),I.append(E,G);let H="period",q=0;const R=[],P=(U=!1)=>{const se=l[q].split(":").map(Number),Z=H==="period"?[[x,c.getFullYear(),"年"],[T,c.getMonth()+1,"月"]]:[[x,se[0],"时"],[T,se[1],"分"],[A,se[2],"秒"]];for(const[W,Q,ae]of Z)for(const S of W.querySelectorAll("button")){const V=Number(S.dataset.value)===Q;S.classList.toggle("selected",V),S.setAttribute("aria-pressed",String(V)),S.textContent=`${H==="time"?nt(Number(S.dataset.value)):S.dataset.value}${V?ae:""}`,V&&U&&(W.scrollTop=Math.max(0,S.offsetTop-108))}},L=(U,se)=>{const Z=O("button","fc-calendar-period-option",String(U));return Z.type="button",Z.dataset.value=String(U),Z.ariaLabel=`${H==="time"?nt(U):U}${H==="time"?se?"时":"分":se?"年":"月"}`,Z.disabled=H==="time"&&s.readonly,Z.onclick=()=>{if(H==="time"){const W=l[q].split(":");W[se?0:1]=nt(U),l[q]=W.join(":"),R[q].textContent=l[q],P(),m();return}c.setFullYear(se?U:c.getFullYear(),se?c.getMonth():U-1,1),P(),$()},Z},M=(U,se=0)=>{if(H=U,q=se,x.replaceChildren(),T.replaceChildren(),A.replaceChildren(),A.hidden=U!=="time"||!n,x.ariaLabel=U==="period"?"年份":"小时",T.ariaLabel=U==="period"?"月份":"分钟",U==="period"){for(let Z=Math.max(1,c.getFullYear()-100);Z<=Math.min(9999,c.getFullYear()+100);Z++)x.append(L(Z,!0));for(let Z=1;Z<=12;Z++)T.append(L(Z,!1))}else{for(let Z=0;Z<24;Z++)x.append(L(Z,!0));for(let Z=0;Z<60;Z++)T.append(L(Z,!1));if(n)for(let Z=0;Z<60;Z++){const W=O("button","fc-calendar-period-option",nt(Z));W.type="button",W.dataset.value=String(Z),W.ariaLabel=nt(Z)+"秒",W.disabled=s.readonly,W.onclick=()=>{const Q=l[q].split(":");Q[2]=nt(Z),l[q]=Q.join(":"),R[q].textContent=l[q],P(),m()},A.append(W)}}i.classList.add("choosing-period"),I.hidden=!1,(U==="period"?k:R[se]).setAttribute("aria-expanded","true"),P(!0),E.focus()};k.onclick=()=>M("period"),E.onclick=()=>{i.classList.remove("choosing-period"),I.hidden=!0;const U=H==="period"?k:R[q];U.setAttribute("aria-expanded","false"),$(),U.focus()},I.addEventListener("keydown",U=>{if(U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),E.click()),!["ArrowUp","ArrowDown","Home","End"].includes(U.key))return;const se=U.target,Z=se.closest(".fc-calendar-period-list");if(!Z)return;const W=[...Z.querySelectorAll("button")],Q=W.indexOf(se),ae=U.key==="Home"?0:U.key==="End"?W.length-1:Math.max(0,Math.min(W.length-1,Q+(U.key==="ArrowDown"?1:-1)));U.preventDefault(),W[ae].focus()});function $(){k.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((se,Z)=>se.classList.toggle("active",Z===r)),N.replaceChildren();for(let se=0;se<c.getDay();se++)N.append(O("span","fc-calendar-blank"));const U=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let se=1;se<=U;se++){const Z=gn(new Date(c.getFullYear(),c.getMonth(),se)),W=O("button","fc-calendar-day",String(se));W.type="button",W.ariaLabel=Z,W.disabled=s.readonly;const Q=a[0]===Z||t&&a[1]===Z;W.classList.toggle("selected",Q),W.setAttribute("aria-pressed",String(Q)),W.classList.toggle("in-range",t&&!!a[0]&&!!a[1]&&Z>a[0]&&Z<a[1]),Z===gn(new Date)&&(W.classList.add("today"),W.setAttribute("aria-current","date")),W.onclick=()=>{var ae;t?d?(a[1]=Z,a[0]&&a[1]<a[0]&&([a[0],a[1]]=[a[1],a[0]]),r=0,d=!1):(a[0]=Z,a[1]="",r=1,d=!0):a[0]=Z,u.forEach((S,V)=>S.value=a[V]),$(),!t||a[1]?m():g.textContent="",(ae=N.querySelector(`[aria-label="${Z}"]`))==null||ae.focus(),(!t||a[1])&&i.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))},N.append(W)}}p.append(w,b,N,I);const z=O("div","fc-calendar-time");if(e){for(let U=0;U<(t?2:1);U++){const se=O("div","fc-calendar-time-field"),Z=t?U?"结束时间":"开始时间":"时间",W=O("button","fc-input fc-calendar-time-trigger",l[U]);W.type="button",W.disabled=s.readonly,W.ariaLabel=Z,W.setAttribute("aria-expanded","false"),W.onclick=()=>M("time",U),R.push(W),se.append(O("span","",Z),W),z.append(se)}p.append(z)}const j=O("button","fc-calendar-clear","清空");j.type="button",j.disabled=s.readonly,j.onclick=()=>{a.fill(""),u.forEach(U=>U.value=""),r=0,d=!1,$(),m()},i.append(h,p,j,g);const te=()=>{const U=a.slice(0,t?2:1).map((se,Z)=>se?se+(e?`T${l[Z]}`:""):"");return t?U.some(Boolean)?U:[]:U[0]};if(s.layout==="compact"||s.readonly)return $(),{element:i,read:te,validate:v,focus:()=>{u[0].focus()},deactivate:()=>{i.classList.remove("choosing-period"),I.hidden=!0}};const ue=O("div","fc-date-mirror"),ge=()=>ue.replaceChildren(Di({...s,value:te()})),be=O("span","fc-field-chevron");be.setAttribute("aria-hidden","true");const fe=O("div","fc-date-trigger");fe.tabIndex=0,fe.setAttribute("role","button"),fe.ariaLabel=`编辑${s.field.label}`,fe.append(ue,be);let me;const Ee=()=>{const U=me;me=void 0;const se=!!U&&U.element.contains(document.activeElement);U==null||U.close(),be.classList.remove("is-open"),se&&queueMicrotask(()=>{me||!fe.isConnected||fe.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))})},Me=()=>{me||s.readonly||(ge(),me=vt({anchor:fe,content:i,width:320,gap:4,onDismiss:()=>{me=void 0,be.classList.remove("is-open")}}),be.classList.add("is-open"))};return fe.onclick=()=>Me(),fe.onkeydown=U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),Me())},i.addEventListener("focusout",U=>{const se=U.relatedTarget;if(se&&(i.contains(se)||fe.contains(se)||Xe(se)))return;const Z=new Event("focusout",{bubbles:!0});se&&Object.defineProperty(Z,"relatedTarget",{value:se}),fe.dispatchEvent(Z)}),i.addEventListener("change",()=>fe.dispatchEvent(new Event("change",{bubbles:!0}))),$(),ge(),{element:fe,content:i,inputRoot:fe,read:te,validate:v,focus:()=>{Me(),u[0].focus()},deactivate:Ee,destroy:Ee}}const mn=[{key:"wit_node",label:"节点"},{key:"wit_subtask",label:"任务"},{key:"wit_field",label:"字段"},{key:"wit_role_and_user",label:"角色与人员"},{key:"wit_schedule",label:"计划表"},{key:"ai_run",label:"AI 操作"},{key:"wit",label:"工作项"}];function Hi(s,e){return s.history.map((t,n)=>{var o;const i=typeof t=="string"?{actor:e,module:t.startsWith("关联素材")?"素材管理":"工作项",detail:t,createdAt:""}:t;return{...i,id:i.id||`legacy-${n}`,actorId:i.actorId||i.actor,actorKind:i.actorKind||"user",moduleKey:i.moduleKey||(i.module==="节点流程"?"wit_node":"")||((o=mn.find(a=>a.label===i.module))==null?void 0:o.key)||i.module}}).sort((t,n)=>n.createdAt.localeCompare(t.createdAt))}function Pa(s){return s.map(e=>{var t,n;return{id:e.id,actorId:(t=e.operator)==null?void 0:t.user_key,actor:((n=e.operator)==null?void 0:n.name)||"系统",actorKind:e.operator_type===0?"user":"system",moduleKey:e.op_record_type_key,module:e.op_record_type_name,detail:e.content,createdAt:new Date(e.created_at).toLocaleString("sv-SE")}})}function Oi(s,e){const t=e.keyword.trim().toLocaleLowerCase(),n=s.filter(d=>e.operatorKinds.has(d.actorKind||"user")&&(!e.operators.size||d.actorKind!=="user"||e.operators.has(d.actorId||d.actor))&&(!e.modules.size||e.modules.has(d.moduleKey||d.module))&&(!e.start||d.createdAt>=e.start.replace("T"," "))&&(!e.end||!!d.createdAt&&d.createdAt<=e.end.replace("T"," "))),i=d=>[d.actor,d.module,d.detail,d.createdAt].some(c=>c.toLocaleLowerCase().includes(t)),o=t?n.filter(i):n,a=t&&e.keywordFilter?o:n,l=Math.max(1,Math.ceil(a.length/20)),r=Math.max(1,Math.min(e.page,l));return{rows:a.slice((r-1)*20,r*20),total:n.length,matching:o.length,filteredTotal:a.length,page:r,pageCount:l}}const vn=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${s}</svg>`,wn=vn('<path d="M3 4h18l-7 8v7l-4 2v-9z"/>'),Ha=vn('<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6"/>'),Oa=vn('<path d="m6 6 12 12M6 18 18 6"/>'),Ba=[["user","用户"],["computed","计算字段"],["automation","自动化规则"],["system","其它系统操作"]];function Va(s){let e={...s},t=e.page||{rows:e.rows||(e.records||[]).filter(E=>typeof E!="string"),nextCursor:e.nextCursor,previousCursor:e.previousCursor},n=!1,i=!1,o=0,a;const l=[],r=()=>{l.splice(0).forEach(E=>E())},d=()=>Hi({history:e.rows||e.records||[]},e.actor||""),c=()=>e.mode==="local",p=document.createElement("section");p.className="detail-history rowvia-detail-module",p.dataset.module="detail:tabs:log";const h={keyword:"",keywordFilter:!1,operatorKinds:new Set(["user","automation","system"]),operators:new Set,modules:new Set,start:"",end:"",page:1,...e.query},u=()=>({...h,operatorKinds:new Set(h.operatorKinds),operators:new Set(h.operators),modules:new Set(h.modules)});Object.assign(h,u());let f;p.innerHTML=`<div class="detail-history-search"><span>${Ha}</span><input type="search" placeholder="搜索" aria-label="搜索操作记录"><div class="detail-history-search-actions" hidden><span data-match-count aria-live="polite"></span><label><input type="checkbox" data-keyword-filter>过滤</label><button type="button" data-clear-search aria-label="清空搜索">${Oa}</button></div></div><div class="detail-history-table-wrap"><table class="detail-history-table" aria-label="操作记录"><colgroup><col style="width:172px"><col style="width:140px"><col><col style="width:252px"></colgroup><thead><tr><th scope="col"><span>操作人</span><button type="button" data-history-filter="actor" aria-label="筛选操作人" aria-haspopup="dialog" aria-expanded="false">${wn}</button></th><th scope="col"><span>操作模块</span><button type="button" data-history-filter="module" aria-label="筛选操作模块" aria-haspopup="dialog" aria-expanded="false">${wn}</button></th><th scope="col">操作详情</th><th scope="col"><span>操作时间</span><button type="button" data-history-filter="time" aria-label="筛选操作时间" aria-haspopup="dialog" aria-expanded="false">${wn}</button></th></tr></thead><tbody></tbody></table></div><div class="detail-history-pagination"></div>`;const g=document.createElement("div");g.className="detail-history-status",g.setAttribute("role","status"),p.append(g);const v=p.querySelector("input[type=search]"),m=p.querySelector("tbody"),w=E=>{const G=h.keyword.trim();if(!G)return D(E);let x=0,T="";for(let A=E.toLocaleLowerCase().indexOf(G.toLocaleLowerCase());A>=0;A=E.toLocaleLowerCase().indexOf(G.toLocaleLowerCase(),x))T+=D(E.slice(x,A))+`<mark>${D(E.slice(A,A+G.length))}</mark>`,x=A+G.length;return T+D(E.slice(x))};function k(){if(n)return;r();const E=c()?Oi(d(),h):{rows:t.rows,total:t.total,matching:t.matching,filteredTotal:t.total,page:h.page,pageCount:1};c()&&(h.page=E.page),v.value=h.keyword,p.querySelector("[data-keyword-filter]").checked=h.keywordFilter,p.setAttribute("aria-busy",String(i)),p.querySelector(".detail-history-search-actions").hidden=!h.keyword.trim(),p.querySelector("[data-match-count]").textContent=`${E.matching??"—"} / ${E.total??"—"}`,m.innerHTML=E.rows.length?E.rows.map(x=>`<tr><td><span class="detail-history-actor" title="${D(x.actor)}"><span class="detail-history-avatar" aria-hidden="true">${D(x.actor.slice(0,1))}</span><span>${w(x.actor)}</span></span></td><td title="${D(x.module)}">${w(x.module)}</td><td class="detail-history-description"><span>${w(x.detail)}</span></td><td><time>${w(x.createdAt||"历史记录")}</time></td></tr>`).join(""):'<tr><td colspan="4" class="detail-history-empty">暂无数据</td></tr>',e.renderDetail&&m.querySelectorAll(".detail-history-description > span").forEach((x,T)=>{const A=e.renderDetail(x,E.rows[T]);A&&l.push(A)}),p.querySelector("[data-history-filter=actor]").classList.toggle("active",h.operatorKinds.size!==4||!!h.operators.size),p.querySelector("[data-history-filter=module]").classList.toggle("active",!!h.modules.size);const G=p.querySelector("[data-history-filter=time]");G.classList.toggle("active",!!h.start||!!h.end),G.title=h.start?`${h.start} 至 ${h.end}`:"筛选操作时间",p.querySelector(".detail-history-pagination").innerHTML=c()?E.pageCount>1?`<span>共 ${E.filteredTotal} 条</span><button type="button" data-page="-1" ${E.page===1?"disabled":""} aria-label="上一页">‹</button><span>${E.page} / ${E.pageCount}</span><button type="button" data-page="1" ${E.page===E.pageCount?"disabled":""} aria-label="下一页">›</button>`:"":`<span>${t.total===void 0?"":`共 ${t.total} 条`}</span><button type="button" data-page="-1" ${i||!e.onQuery||t.previousCursor==null?"disabled":""} aria-label="上一页">‹</button><button type="button" data-page="1" ${i||!(e.onQuery||e.onLoadMore)||t.nextCursor==null?"disabled":""} aria-label="下一页">›</button>`}function C(E=!1){if(n)return;if(c()){k();return}if(!(E?e.onLoadMore:e.onQuery)){k();return}a==null||a.abort(),a=new AbortController;const G=++o;i=!0,g.textContent="加载中…",k();const x=u(),T=H=>{n||G!==o||(H&&(t=H,e.records=H.rows,e.rows=H.rows),i=!1,g.textContent="",k())},A=H=>{if(n||G!==o)return;i=!1,g.textContent=H instanceof Error?H.message:"加载失败,请重试";const q=document.createElement("button");q.type="button",q.textContent="重试",q.onclick=()=>C(E),g.append(q),k()};try{const H=E?e.onLoadMore(h.cursor,x,a.signal):e.onQuery(x,a.signal);H instanceof Promise||H&&"then"in H?Promise.resolve(H).then(T,A):T(H)}catch(H){A(H)}}const b=()=>{h.page=1,h.cursor=void 0,C()},N=()=>{const E=f;f=void 0,E==null||E.close()};function I(E){if(E.getAttribute("aria-expanded")==="true"){N();return}N();const G=document.createElement("div");G.className="detail-history-filter-panel",G.setAttribute("role","dialog"),G.ariaLabel=E.ariaLabel;const x=E.dataset.historyFilter,T=[],A=(H,q,R)=>{const P=document.createElement("label");return P.className="detail-history-filter-option",P.innerHTML=`<input type="checkbox" value="${D(q)}" ${R.has(q)?"checked":""}><span>${D(H)}</span>`,P.querySelector("input").onchange=L=>{L.target.checked?R.add(q):R.delete(q),b()},P};if(x==="module"){const H=d(),q=e.modules?[...e.modules]:mn.filter(R=>e.nodeFlow||!["wit_node","wit_subtask"].includes(R.key));for(const R of H)q.some(P=>P.key===R.moduleKey)||q.push({key:R.moduleKey,label:R.module});q.forEach(R=>G.append(A(R.label,R.key,h.modules)))}else if(x==="actor"){for(const[H,q]of Ba)if(G.append(A(q,H,h.operatorKinds)),H==="user"){const R=document.createElement("details");R.className="detail-history-users",R.innerHTML='<summary>请选择用户</summary><input type="search" aria-label="搜索用户" placeholder="搜索用户"><div></div>';const P=e.operators?e.operators.map($=>[$.id,$.label]):[...new Map(d().filter($=>$.actorKind==="user").map($=>[$.actorId,$.actor])).entries()],L=R.querySelector("input"),M=()=>R.querySelector("div").replaceChildren(...P.filter(([,$])=>$.includes(L.value)).map(([$,z])=>A(z,$,h.operators)));L.oninput=M,M(),G.append(R)}}else{G.classList.add("detail-history-date-panel");const H=document.createElement("div");H.className="detail-history-date-range",G.append(H);const q=["开始","结束"].map((M,$)=>Pi({field:{key:`log-date-${$}`,label:`${M}日期`,kind:"dateTime",dateOptions:{showTime:!0,showSeconds:!0}},readonly:!1,layout:"compact",value:$?h.end:h.start})),R=document.createElement("div");R.className="detail-history-filter-error",R.setAttribute("role","status");const P=()=>{const[M,$]=q.map(z=>String(z.read()));R.textContent=q.map(z=>{var j;return(j=z.validate)==null?void 0:j.call(z)}).find(Boolean)||(M&&$&&M>$?"结束日期时间不能早于开始日期时间":""),!R.textContent&&(!M&&!$?(h.start="",h.end="",b()):M&&$&&(h.start=M,h.end=$,b()))};q.forEach((M,$)=>{var ue,ge;const z=document.createElement("div");z.className="detail-history-date-column",z.setAttribute("aria-label",$?"结束日期时间":"开始日期时间");const j=M.element.querySelector(".fc-calendar-date");j.placeholder="yyyy-MM-dd";const te=M.element.querySelector(".fc-calendar-time-trigger");M.element.querySelector(".fc-calendar-inputs").append(te),(ue=M.element.querySelector(".fc-calendar-time"))==null||ue.remove(),(ge=M.element.querySelector(".fc-calendar-clear"))==null||ge.remove(),z.append(M.element),H.append(z),M.element.addEventListener("change",P),T.push(()=>{var be;return(be=M.destroy)==null?void 0:be.call(M)})}),h.end||q[1].element.querySelector('[aria-label="下个月"]').click();const L=document.createElement("button");L.type="button",L.className="detail-history-clear-dates",L.textContent="清空",L.onclick=()=>{h.start="",h.end="",b(),N()},G.append(R,L)}E.setAttribute("aria-expanded","true"),f=vt({anchor:E,anchorMode:"element",content:G,align:x==="time"?"end":"start",width:x==="time"?570:x==="actor"?240:190,onDismiss:()=>{f=void 0,E.setAttribute("aria-expanded","false"),T.forEach(H=>H())},onEscape:()=>E.focus()})}return v.oninput=()=>{h.keyword=v.value,b()},p.querySelector("[data-keyword-filter]").onchange=E=>{h.keywordFilter=E.target.checked,b()},p.onclick=E=>{if(n)return;const G=E.target.closest("button");G&&(G.dataset.historyFilter?I(G):G.hasAttribute("data-clear-search")?(v.value="",h.keyword="",b(),v.focus()):G.dataset.page&&!G.disabled&&(c()?h.page+=Number(G.dataset.page):h.cursor=(G.dataset.page==="1"?t.nextCursor:t.previousCursor)??void 0,C(!c()&&G.dataset.page==="1"&&!!e.onLoadMore)))},k(),{element:p,refresh:C,deactivate:N,update:E=>{n||(++o,a==null||a.abort(),i=!1,g.textContent="",e={...e,...E},E.query&&(Object.assign(h,E.query),Object.assign(h,u())),E.page?(t=E.page,e.records=E.page.rows,e.rows=E.page.rows):(E.rows||E.records)&&(t={...t,rows:E.rows||E.records.filter(G=>typeof G!="string")},e.rows=t.rows),"nextCursor"in E&&(t.nextCursor=E.nextCursor),"previousCursor"in E&&(t.previousCursor=E.previousCursor),N(),k())},destroy:()=>{n||(n=!0,++o,a==null||a.abort(),N(),r(),v.oninput=null,p.querySelector("[data-keyword-filter]").onchange=null,p.onclick=null,p.replaceChildren())}}}const Ga=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1});function Bi(s,e){return e.every(t=>{const n=String(s[t.field]??"").toLocaleLowerCase(),i=t.value.toLocaleLowerCase();switch(t.operator){case"equals":return n===i;case"notEqual":return n!==i;case"blank":return!n;case"notBlank":return!!n;default:return n.includes(i)}})}const yn=new WeakMap;function Vi(s){let e=yn.get(s);e||(e={owners:0,added:!s.classList.contains("rowvia-work-items"),fieldAdded:!s.classList.contains("rowvia-field-scope")},yn.set(s,e),s.classList.add("rowvia-work-items","rowvia-field-scope")),e.owners++;let t=!1;return()=>{t||(t=!0,!--e.owners&&(e.added&&s.classList.remove("rowvia-work-items"),e.fieldAdded&&s.classList.remove("rowvia-field-scope"),yn.delete(s)))}}function bn(s,e,t,n){const i=document.createElement("div");i.className=e,i.innerHTML=t;const o=Vi(s);s.append(i);const a=new Ke,l=De(i,e,n);return a.listen(i,"click",r=>{var p;const d=r.target.closest("[data-action]");if(!d||!i.contains(d)||d.matches(":disabled"))return;const c={action:d.dataset.action,anchor:d,originalEvent:r};(p=n.onAction)==null||p.call(n,c),i.dispatchEvent(new CustomEvent("rowvia:action",{detail:c,bubbles:!0}))}),{element:i,lifecycle:a,onInteraction:l.onInteraction,destroy(){a.destroy(),l.destroy(),i.remove(),o()}}}function qa(s,e){const t=bn(s,"list-tabs",e.tabs.map(o=>`<button class="list-tab" role="tab" data-tab="${D(o)}">${D(o)}</button>`).join("")+`<div class="create-button">${Ie("create","新建","plus","primary")}${Ie("create-menu","","down","primary")}</div>`,e);t.element.setAttribute("role","tablist");let n=e.value??e.tabs[0]??"";const i=o=>{n=o,t.element.querySelectorAll("[data-tab]").forEach(a=>{const l=a.dataset.tab===n;a.classList.toggle("active",l),a.setAttribute("aria-selected",String(l))})};return t.lifecycle.listen(t.element,"click",o=>{var l;const a=o.target.closest("[data-tab]");!a||a.dataset.tab===n||(i(a.dataset.tab),(l=e.onChange)==null||l.call(e,n),t.element.dispatchEvent(new CustomEvent("rowvia:tab-change",{detail:n,bubbles:!0})))}),t.element.querySelectorAll("[data-action]").forEach(o=>{o.disabled=e.canCreate===!1}),i(n),{element:t.element,onInteraction:t.onInteraction,setValue:i,getValue:()=>n,destroy:t.destroy}}const Cn={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};function za(s,e={}){const t=bn(s,"toolbar",Object.entries(Cn).map(([a,l])=>Ie(a,l,a)).join("")+`<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${Ie("previous-match","","up")}${Ie("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${Ie("close-search","","close")}</div>${Ie("search","查找","search")}<div class="right">${Ie("reset","重置","","hidden")}${Ie("saved-views","切换视图","down")}${Ie("save-view","存为视图","save","outline")}</div>`,e),n=t.element.querySelector("#search"),i=t.element.querySelector("#filter-search"),o=()=>{var a;(a=e.onSearch)==null||a.call(e,n.value,i.checked),t.element.dispatchEvent(new CustomEvent("rowvia:search",{detail:{query:n.value,filter:i.checked},bubbles:!0}))};return t.lifecycle.listen(n,"input",o),t.lifecycle.listen(i,"change",o),{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setRuleCounts(a){for(const l of Object.keys(Cn)){const r=t.element.querySelector(`[data-action="${l}"]`);r.classList.toggle("is-set",!!a[l]),r.querySelector("span").textContent=Cn[l]+(a[l]?` · ${a[l]}`:"")}t.element.querySelector('[data-action="reset"]').classList.toggle("hidden",!Object.values(a).some(Boolean))}}}function _a(s,e={}){const t=bn(s,"selection-bar hidden",`${Ie("deselect","","close")}<span data-selection-count></span>${Ie("batch-status","更新状态")}${Ie("batch-owner","更新负责人")}${Ie("batch-export","导出")}${Ie("batch-archive","终止")}${Ie("deselect","取消选择")}`,e),n=t.element.querySelector("[data-selection-count]");return{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setCount(i){t.element.classList.toggle("hidden",i===0),n.textContent=`已选择 ${i} 项`}}}function Wa(s,e){const t=Vi(s),n=ni(s,{getRowId:({data:i})=>i.id,rowHeight:37,headerHeight:32,theme:"ag-theme-quartz",rowSelection:"multiple",defaultColDef:{resizable:!0,sortable:!1,filter:!1},suppressRowClickSelection:!0,groupDefaultExpanded:-1,autoGroupColumnDef:{headerName:"分组",width:180,pinned:"left"},suppressContextMenu:!0,enableRangeSelection:!1,undoRedoCellEditing:!0,stopEditingWhenCellsLoseFocus:!0,localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"},...e});return{...n,onInteraction:n.grid.onInteraction,destroy(){n.grid.destroy(),t()}}}function Ua(s){const{config:e,controls:t,fieldConfig:n,options:i,$:o,tag:a,activateCell:l,controlContext:r,openDetail:d,colorRuleMatches:c}=s;function p(u){if(u.node.group)return"";const f=u.data,g=u.colDef.field,v=document.createElement("div");v.className="rendered-cell";const m=n(g);if(m&&(m.control||!["title","status"].includes(m.kind||"text")))v.append(t.resolve(m).render(r(m,f,"cell")));else if((m==null?void 0:m.kind)==="title"){const w=document.createElement("a");w.className="item-name",w.href=`#item/${f.id}`,w.textContent=f[g],w.title=f[g],w.addEventListener("click",C=>{C.preventDefault(),clearTimeout(s.detailClickTimer.get()),C.detail===0?d(f):C.detail===1&&s.detailClickTimer.set(window.setTimeout(()=>d(f),280))}),v.append(w);const k=document.createElement("button");k.className="inline-edit",k.innerHTML=Re("pencil"),k.ariaLabel="编辑选题概要",k.onclick=C=>{C.stopPropagation(),l(v,g,f,u.rowIndex)},(m==null?void 0:m.editable)!==!1&&v.append(k)}else(m==null?void 0:m.kind)==="status"?(v.innerHTML=`${a(f.status,g)}<span class="status-days">20 天</span>`,(m==null?void 0:m.editable)!==!1&&(v.onclick=w=>{w.stopPropagation(),l(v,g,f,u.rowIndex)})):i[g]?(v.innerHTML=["creator","owner","space"].includes(g)?D(f[g]):a(f[g],g),(m==null?void 0:m.editable)!==!1&&(v.onclick=w=>{w.stopPropagation(),l(v,g,f,u.rowIndex)})):(v.innerHTML=`<span class="cell-text">${D(f[g]||"暂无")}</span>`,f[g]||v.classList.add("placeholder"));if(m&&m.editable!==!1&&!t.resolve(m).readonly&&m.kind!=="title"){const w=document.createElement("button");w.className="inline-edit field-control",w.ariaLabel=`${m.kind==="status"?"流转":"编辑"}${m.label}`,w.innerHTML=Re(m.kind==="status"?"transition":["radio","select","multiSelect","person"].includes(t.resolve(m).id)?"down":"pencil"),w.onclick=k=>{k.stopPropagation(),l(v,g,f,u.rowIndex)},v.append(w)}return v.title=String(f[g]??""),v}function h(){return[{colId:"_select",headerName:"",width:64,minWidth:64,maxWidth:64,pinned:"left",sortable:!1,resizable:!1,suppressMovable:!0,suppressMenu:!0,checkboxSelection:!0,headerCheckboxSelection:!0,rowDrag:!0,cellRenderer:u=>{if(u.node.group)return"";const f=document.createElement("div");return f.className="row-controls",f.innerHTML=`<span class="row-number">${u.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${u.rowIndex+1} 行" ${u.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${Re("expand")}</button>`,o("input",f).onclick=g=>g.stopPropagation(),o("input",f).onchange=g=>u.node.setSelected(g.target.checked),o("button",f).onclick=g=>{g.stopPropagation(),d(u.data)},f}},...e.fields.map(u=>({field:u.key,headerName:u.label,width:u.width??120,minWidth:u.minWidth??80,pinned:u.pinned,hide:u.hidden,enableRowGroup:!0,editable:!1,valueSetter:f=>u.required&&!String(f.newValue??"").trim()?!1:(f.data[u.key]=f.newValue,!0),comparator:u.options?(f,g)=>u.options.indexOf(f)-u.options.indexOf(g):void 0,sortable:!1,suppressMenu:!0,cellRenderer:p,cellStyle:({data:f})=>{const g=f&&s.view().colors.find(v=>!!v.scope&&v.scope!=="row"&&v.field===u.key&&c(f,v));return g?{backgroundColor:g.color}:{}},tooltipField:u.key,cellClass:u.kind==="title"?"name-cell":void 0,...u.column})),...s.customColumns(),{colId:"_add",hide:e.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}return{cell:p,columnDefs:h}}function ja(s){const{config:e,data:t,fields:n,fieldConfig:i,options:o,controls:a,$:l,showPopup:r,closePopup:d,applyView:c,save:p,resizeGrid:h,decorateHeaders:u}=s;function f(w,k,C={}){e.container.querySelectorAll(".field-picker").forEach(G=>G.remove());const b=document.createElement("div");b.className="field-picker",b.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(G=>`<button data-kind="${G}">${G}</button>`).join("")}</div><div class="field-options"></div>`,e.container.append(b);const N=w.getBoundingClientRect();b.style.left=`${Math.max(12,Math.min(N.left,innerWidth-410))}px`,b.style.top=`${Math.max(12,Math.min(N.bottom+4,innerHeight-340))}px`;let I="推荐";const E=(G="推荐",x="")=>{l(".field-options",b).innerHTML=n.filter(([T,A])=>{var H,q,R,P,L,M;return(!C.available||C.available(T))&&A.includes(x)&&(G==="推荐"||G==="文本"&&["title","text","longText","richText"].includes(((H=i(T))==null?void 0:H.kind)||"text")||G==="选择"&&["status","select","multiSelect"].includes(((q=i(T))==null?void 0:q.kind)||"")||G==="人员"&&((R=i(T))==null?void 0:R.kind)==="person"||G==="时间"&&["date","dateTime"].includes(((P=i(T))==null?void 0:P.kind)||"")||G==="关系"&&((L=i(T))==null?void 0:L.kind)==="relation"||G==="其他"&&((M=i(T))==null?void 0:M.kind)==="vote")}).map(([T,A])=>`<button data-field="${D(T)}" ${C.onCreate?`data-insert="${D(T)}"`:""} class="menu-option">${Re("table")}${D(A)}</button>`).join(""),C.onCreate&&l(".field-options",b).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${Re("add")}添加字段</button>`),b.querySelectorAll("[data-kind]").forEach(T=>{T.classList.toggle("active",T.dataset.kind===G),T.setAttribute("aria-pressed",String(T.dataset.kind===G))})};E(),l("input",b).oninput=G=>E(I,G.target.value),b.onclick=G=>{var T;const x=G.target.closest("button");x&&(G.stopPropagation(),x.dataset.kind&&(I=x.dataset.kind,E(I,l("input",b).value)),x.dataset.field&&(b.remove(),k(x.dataset.field)),x.hasAttribute("data-create-field")&&(b.remove(),(T=C.onCreate)==null||T.call(C)))}}function g(w){const k=s.instance(),C=r(w,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${k.api.getAllColumns().filter(b=>!b.colId.startsWith("_")).map(b=>`<label class="column-option"><input type="checkbox" data-column="${b.colId}" ${b.visible?"checked":""}><span>${D(b.headerName)}</span><button type="button" data-pin="${b.colId}">${b.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);C.onchange=b=>{const N=b.target;N.dataset.column&&k.columnApi.setColumnVisible(N.dataset.column,N.checked)},C.onclick=b=>{const N=b.target.closest("[data-pin]");if(N){b.preventDefault();const I=k.columnApi.getColumn(N.dataset.pin);k.columnApi.setColumnPinned(I,I.pinned?null:"left"),g(w)}},l("input",C).oninput=b=>{const N=b.target.value;C.querySelectorAll(".column-option").forEach(I=>I.hidden=!I.textContent.includes(N))}}function v(w,k,C){const b=s.instance();d();const N=E=>{var T;const x=b.columnApi.getColumnState().findIndex(A=>A.colId===k)+(C?1:0);b.columnApi.setColumnVisible(E,!0),b.columnApi.setColumnPinned(E,k==="_add"?null:((T=b.columnApi.getColumn(k))==null?void 0:T.pinned)??null),b.columnApi.moveColumn(E,Math.max(1,x)),d(),h(),u()};f(w,N,{available:E=>{var G;return!((G=b.columnApi.getColumn(E))!=null&&G.visible)},onCreate:()=>{const E=r(w,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${a.list().map(M=>`<option value="${D(M.id)}">${D(M.label)}</option>`).join("")}</select></label><label>选项(每行一个)<textarea name="options" aria-label="字段选项"></textarea></label><label class="choice-limit hidden">最多可选数量<input name="maxSelections" type="number" min="1" step="1" placeholder="不限" aria-label="最多可选数量"></label><button class="primary" type="submit">确认创建</button></form>`,320),G=l('[name="kind"]',E),x=l('[name="options"]',E),T=x.closest("label"),A=document.createElement("div");A.className="fc-field-schema",A.hidden=!0,A.innerHTML='<p class="hint">每组记录包含以下子字段</p><div class="fc-field-schema-rows"></div><button type="button" class="fc-composite-add">+ 添加子字段</button>';const H=a.list().filter(M=>!M.readonly&&!["composite","multiPersonComposite","attitudeVote","singleVote","multiVote","detail"].includes(M.id)),q=()=>{const M=document.createElement("div");M.className="fc-field-schema-row",M.innerHTML='<input class="fc-input" aria-label="子字段名称" placeholder="子字段名称"><select class="fc-input" aria-label="子字段类型">'+H.map($=>'<option value="'+D($.id)+'">'+D($.label)+"</option>").join("")+'</select><button type="button" aria-label="移除子字段">×</button>',M.querySelector("button").onclick=()=>M.remove(),A.querySelector(".fc-field-schema-rows").append(M)};A.querySelector("button").onclick=q,q();const R=document.createElement("p");R.className="fc-service-note";const P=document.createElement("p");P.className="fc-error",P.setAttribute("role","status"),l("form",E).insertBefore(A,l('button[type="submit"]',E)),l("form",E).insertBefore(R,l('button[type="submit"]',E)),l("form",E).insertBefore(P,l('button[type="submit"]',E));const L=()=>{const M=G.value,$=M==="cascadeSingle"||M==="cascadeMulti";T.hidden=!$&&!["select","multiSelect","radio","singleVote","multiVote","person","multiPerson","relation","multiRelation"].includes(M),x.placeholder=$?"每行一条路径,例如:产品 / 设计 / 交互":"每行一个选项",l(".choice-limit",E).classList.toggle("hidden",!["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(M)),A.hidden=!["composite","multiPersonComposite"].includes(M),R.textContent=$?"用 / 分隔层级;同名上级会合并。":M==="attachment"?"上传操作由宿主上传服务提供。":M.endsWith("Vote")?"投票操作由宿主投票服务提供。":"",P.textContent=""};G.onchange=L,L(),l("form",E).onsubmit=M=>{M.preventDefault();const $=new FormData(M.target),z=String($.get("label")||"").trim();if(!z)return;const j=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,te=String($.get("kind")),ue={key:j,label:z,kind:te,editable:!a.resolve({key:j,label:z,kind:te}).readonly,width:160};["select","multiSelect","person","multiPerson","radio","singleVote","multiVote","relation","multiRelation"].includes(te)&&(ue.options=[...new Set(String($.get("options")||"").split(`
101
+ `).map(fe=>fe.trim()).filter(Boolean))]);const ge=Number($.get("maxSelections"));if(["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(te)&&Number.isInteger(ge)&&ge>0&&(ue.maxSelections=ge),te==="dateTime"&&(ue.dateOptions={showTime:!0,showSeconds:!0}),te==="cascadeSingle"||te==="cascadeMulti"){ue.choices=[];for(const fe of x.value.split(`
102
+ `).filter(me=>me.trim())){let me=ue.choices;const Ee=fe.split("/").map(Me=>Me.trim()).filter(Boolean);Ee.forEach((Me,U)=>{let se=me.find(Z=>Z.id===Me);se||(se={id:Me,label:Me},me.push(se)),U<Ee.length-1&&(se.children??(se.children=[]),me=se.children)})}if(!ue.choices.length){P.textContent="请至少填写一条分类路径";return}}if(te==="composite"||te==="multiPersonComposite"){const fe=[...A.querySelectorAll(".fc-field-schema-row")];if(!fe.length||fe.some(me=>!me.querySelector("input").value.trim())){P.textContent="请填写子字段名称";return}ue.compositeFields=fe.map((me,Ee)=>({key:"sub_"+Ee,label:me.querySelector("input").value.trim(),kind:me.querySelector("select").value})),te==="multiPersonComposite"&&ue.compositeFields.unshift({key:"owner",label:"填写人",kind:"person",required:!0})}e.fields.push(ue),n.push([j,z]),ue.options&&(o[j]=ue.options),t.customFields.push(ue);const be=b.columnApi.getColumnState();b.api.setColumnDefs(s.columnDefs()),b.columnApi.applyColumnState(be,!0),N(j),p(),c()}}})}function m(w,k){const C=s.instance(),b=s.view(),N=C.columnApi.getColumn(k);if(!N||k==="_select")return;if(k==="_add"){v(w,k,!1);return}const I=["向左插入列","向右插入列",o[k]?"以 首项 → 末项 排序":"以 A → Z 排序",o[k]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",N.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],E=r(w,"",[[0,1],[2,3],[4,8],[5,6,7]].map(G=>G.map(x=>`<button class="menu-option${x===7?" destructive":""}" data-col-menu="${x}" ${x===7&&k==="name"?"disabled":""}>${I[x]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");E.dataset.headerMenu="true",E.onclick=G=>{const x=G.target.closest("[data-col-menu]");if(!x)return;const T=+x.dataset.colMenu;d(),(T===0||T===1)&&v(w,k,T===1),(T===2||T===3)&&(b.sorts=[{colId:k,sort:T===2?"asc":"desc"}],c()),T===4&&(b.filters.push({field:k,operator:"contains",value:""}),s.rulePanel("filter",l('[data-action="filter"]'))),T===5&&C.columnApi.setColumnPinned(k,N.pinned?null:"left"),T===6&&s.textDialog("编辑列",N.headerName,A=>{const H=i(k);H&&(H.label=A);const q=C.api.getColumnDefs(),R=q.find(L=>L.field===k);R&&(R.headerName=A);const P=C.columnApi.getColumnState();C.api.setColumnDefs(q),C.columnApi.applyColumnState(P,!0),u()}),T===7&&C.columnApi.setColumnVisible(k,!1),T===8&&(b.groups.includes(k)||b.groups.push(k),c())}}return{fieldPicker:f,showColumns:g,showInsertField:v,showColumnMenu:m}}function Ka(s){const{root:e,view:t,fieldConfig:n,showInsertField:i,showColumnMenu:o,applyView:a}=s,l=r=>e.querySelector(r);return function(){l("#grid").querySelectorAll(".ag-header-cell").forEach(d=>{var f,g;const c=d.dataset.colid;if(c==="_add"){if(!d.querySelector(".work-add-column")){const v=d.querySelector(".ag-header-cell-label"),m=document.createElement("button");m.type="button",m.className="work-add-column",m.ariaLabel="新增字段",m.title="新增字段",m.innerHTML=Re("add"),m.onmousedown=w=>w.stopPropagation(),m.onclick=w=>{w.stopPropagation(),i(m,"_add",!1)},v.replaceChildren(m)}return}if(!n(c))return;if(!d.querySelector(".work-header-sort")){const v=document.createElement("span");v.className="work-header-sort",(f=d.querySelector(".ag-header-cell-label"))==null||f.append(v);const m=document.createElement("button");m.className="work-header-menu",m.ariaLabel=`${n(c).label}操作`,m.innerHTML=Re("more"),m.onclick=k=>{k.stopPropagation(),o(m,c)},m.onmousedown=k=>k.stopPropagation(),d.append(m);for(const k of["right","left"]){const C=document.createElement("button");C.className="work-header-add",C.dataset.insertSide=k,C.ariaLabel=`在${n(c).label}${k==="right"?"右":"左"}侧插入列`,C.title="插入列",C.innerHTML=Re("add"),C.onclick=b=>{b.stopPropagation(),i(C,c,k==="right")},C.onmousedown=b=>b.stopPropagation(),d.append(C)}const w=()=>{const k=d.getBoundingClientRect(),C=l(".grid-wrap").getBoundingClientRect(),N=d.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();d.querySelectorAll(".work-header-add").forEach(I=>{const E=I.dataset.insertSide==="left"?k.left:k.right;I.style.left=`${E-12}px`,I.style.top=`${k.top-20}px`,I.style.setProperty("--insert-line-height",`${Math.max(0,C.bottom-k.top+8)}px`),I.style.display=E<Math.max(C.left,N.left)-1||E>Math.min(C.right,N.right)+1?"none":""}),d.classList.add("insert-points-ready")};d.addEventListener("mouseenter",w),d.addEventListener("focusin",w),d.addEventListener("click",k=>{var b;if(k.target.closest("button,.ag-header-cell-resize"))return;k.stopImmediatePropagation();const C=(b=t().sorts.find(N=>N.colId===c))==null?void 0:b.sort;t().sorts=C==="desc"?[]:[{colId:c,sort:C==="asc"?"desc":"asc"}],a()},{capture:!0})}const p=(g=t().sorts.find(v=>v.colId===c))==null?void 0:g.sort,h=d.querySelector(".work-header-sort"),u=p==="asc"?"↑":p==="desc"?"↓":"↕";h.textContent!==u&&(h.textContent=u),h.classList.toggle("sorted",!!p),d.setAttribute("aria-sort",p==="asc"?"ascending":p==="desc"?"descending":"none")})}}function Ya(s){const{fields:e,fieldConfig:t,options:n,controls:i,newItem:o,fieldPicker:a,showPopup:l,applyView:r}=s;function d(h,u){return!!u.field&&(!!u.value||["blank","notBlank"].includes(u.operator))&&Bi(h,[u])}function c(h){const u=s.view(),f=u.colors.map((N,I)=>{var A;const E=(A=t(N.field))==null?void 0:A.label,G=N.field?[["contains",n[N.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],x=!N.field||["blank","notBlank"].includes(N.operator),T=n[N.field]?Wt([["","请选择目标值"],...n[N.field].map(H=>[H,H])],N.value,`data-rule-value="${I}" aria-label="目标值" ${x?"disabled":""}`):`<input data-rule-value="${I}" aria-label="目标值" placeholder="请选择目标值" value="${D(N.value)}" ${x?"disabled":""}>`;return`<div class="color-condition" data-color-row="${I}">
103
103
  <button class="color-drag" draggable="true" title="拖动调整条件优先级" aria-label="拖动条件">⠿</button>
104
- <button type="button" class="color-swatch" data-color="${A}" style="background-color:${D(I.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
105
- <button type="button" class="field-select" data-color-scope="${A}" aria-label="着色范围" aria-expanded="false">${!I.scope||I.scope==="row"?"整行":"单元格"}${Me("down")}</button>
106
- <button class="field-select ${S?"":"empty"}" data-pick="${A}">${D(S||"请选择筛选项")}${Me("down")}</button>
107
- ${Vt(G,I.field?I.operator:"",`data-operator="${A}" aria-label="运算符" ${I.field?"":"disabled"}`)}
108
- ${k}
109
- <button class="color-remove" data-remove="${A}" aria-label="删除条件" title="删除条件">${Me("close")}</button>
110
- <div class="color-more-wrap"><button class="color-more" data-color-more="${A}" aria-label="更多条件操作" aria-expanded="false">${Me("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${A}">复制条件</button><button data-color-up="${A}" ${A===0?"disabled":""}>上移</button><button data-color-down="${A}" ${A===u.colors.length-1?"disabled":""}>下移</button></div></div>
111
- </div>`}).join(""),g=l(h,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${f}</div><div class="color-panel-footer"><button class="add-condition">${Me("plus")}添加着色条件</button><button class="clear-rules" ${u.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");g.ariaLabel="设置颜色条件",s.setActiveRulePanel("color");const v=()=>c(h),m=()=>{r(),v()},y=["#ffe5e5","#ffe7d4","#f9e8d2","#fff5d6","#ecf3d3","#daf2d5","#d6f1ec","#d4efff","#e4eaff","#ebe9fe","#f2e8ff","#f7e4fb","#ffe3f2","#ffc8c8","#ffceaa","#f3d3a4","#ffeaa5","#d9e8a7","#b6e4af","#ace4db","#acdffc","#c9d8ff","#d7d5fb","#e3d0ff","#efc9f5","#fbc5e7"],x=()=>{var I;(I=g.querySelector(".color-palette"))==null||I.remove(),g.querySelectorAll("[data-color]").forEach(A=>A.setAttribute("aria-expanded","false"))},C=()=>{var I,A,S;(I=g.querySelector(".color-scope-picker"))==null||I.remove(),(S=(A=s.getPopupEditor())==null?void 0:A.destroy)==null||S.call(A),s.setPopupEditor(null),g.querySelectorAll("[data-color-scope]").forEach(G=>G.setAttribute("aria-expanded","false"))};let b=-1;g.querySelectorAll(".color-condition").forEach((I,A)=>{I.ondragstart=S=>{var G;b=A,(G=S.dataTransfer)==null||G.setData("text/plain",String(A))},I.ondragover=S=>S.preventDefault(),I.ondrop=S=>{if(S.preventDefault(),b<0||b===A)return;const[G]=u.colors.splice(b,1);u.colors.splice(A,0,G),m()}}),g.onclick=I=>{var G,E,k;I.stopPropagation();const A=I.target.closest("button");if(I.target.closest(".color-scope-picker"))return;const S=(A==null?void 0:A.getAttribute("aria-expanded"))==="true";if(C(),!A||A.disabled){x();return}if(A.dataset.colorScope!==void 0){if(x(),S)return;const T=Number(A.dataset.colorScope),H=u.colors[T],W={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},R=i.resolve(W).createEditor({field:W,value:!H.scope||H.scope==="row"?"整行":"单元格",item:o(),surface:"cell",readonly:!1,openDetail:()=>{}});s.setPopupEditor(R);const O=document.createElement("div");O.className="popup fc-popup fc-choice-popup color-scope-picker",O.style.width="272px",O.append(R.element),g.append(O);const L=A.getBoundingClientRect();O.style.left=`${Math.max(8,Math.min(L.left,innerWidth-280))}px`,O.style.top=`${Math.max(8,Math.min(L.bottom+6,innerHeight-O.offsetHeight-8))}px`,A.setAttribute("aria-expanded","true"),R.element.addEventListener("change",M=>{var $,_,U;M.stopPropagation(),!(($=R.validate)!=null&&$.call(R))&&(H.scope=R.read()==="整行"?"row":"cell",m(),(U=(_=s.popup())==null?void 0:_.querySelector(`[data-color-scope="${T}"]`))==null||U.focus())}),O.onkeydown=M=>{M.key==="Escape"&&(M.stopPropagation(),C(),A.focus())},(G=R.focus)==null||G.call(R);return}if(A.dataset.paletteColor!==void 0){const T=Number(A.closest(".color-palette").dataset.ruleIndex);u.colors[T].color=A.dataset.paletteColor,m(),(k=(E=s.popup())==null?void 0:E.querySelector(`[data-color="${T}"]`))==null||k.focus();return}if(A.dataset.color!==void 0){const T=A.getAttribute("aria-expanded")==="true";if(x(),T)return;const H=Number(A.dataset.color),W=document.createElement("div");W.className="color-palette",W.dataset.ruleIndex=String(H),W.setAttribute("role","group"),W.ariaLabel="选择着色颜色",W.innerHTML=y.map(O=>`<button type="button" class="color-palette-option" data-palette-color="${O}" style="background-color:${O}" aria-label="颜色 ${O}" aria-pressed="${O===u.colors[H].color.toLowerCase()}"></button>`).join(""),g.append(W);const R=A.getBoundingClientRect();W.style.left=`${Math.max(8,Math.min(R.left,innerWidth-W.offsetWidth-8))}px`,W.style.top=`${Math.max(8,Math.min(R.bottom+6,innerHeight-W.offsetHeight-8))}px`,A.setAttribute("aria-expanded","true"),W.onkeydown=O=>{O.key==="Escape"&&(O.stopPropagation(),x(),A.focus())};return}if(x(),A.classList.contains("add-condition"))u.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),m();else if(A.dataset.pick!==void 0){const T=+A.dataset.pick;a(A,H=>{u.colors[T].field=H,u.colors[T].value="",u.colors[T].operator="contains",m()})}else if(A.dataset.remove!==void 0)u.colors.splice(+A.dataset.remove,1),m();else if(A.classList.contains("clear-rules"))u.colors=[],m();else if(A.dataset.colorMore!==void 0){const T=A.nextElementSibling,H=T.classList.contains("hidden");g.querySelectorAll(".color-rule-menu").forEach(W=>W.classList.add("hidden")),g.querySelectorAll("[data-color-more]").forEach(W=>W.setAttribute("aria-expanded","false")),T.classList.toggle("hidden",!H),A.setAttribute("aria-expanded",String(H))}else if(A.dataset.colorCopy!==void 0){const T=+A.dataset.colorCopy;u.colors.splice(T+1,0,structuredClone(u.colors[T])),m()}else if(A.dataset.colorUp!==void 0||A.dataset.colorDown!==void 0){const T=Number(A.dataset.colorUp??A.dataset.colorDown),[H]=u.colors.splice(T,1);u.colors.splice(T+(A.dataset.colorUp!==void 0?-1:1),0,H),m()}},g.onchange=I=>{const A=I.target;if(A.dataset.operator!==void 0){u.colors[+A.dataset.operator].operator=A.value,m();return}A.dataset.ruleValue!==void 0&&(u.colors[+A.dataset.ruleValue].value=A.value),r()},g.oninput=I=>{const A=I.target;if(A.dataset.ruleValue!==void 0)u.colors[+A.dataset.ruleValue].value=A.value;else return;r()}}function p(h,u){if(h==="color"){c(u);return}const f=s.view(),g={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[h],v=h==="filter"?f.filters:h==="sort"?f.sorts:h==="group"?f.groups:f.colors,m=v.map((b,I)=>{var T;const A=h==="sort"?b.colId:h==="group"?b:b.field,S=((T=e.find(([H])=>H===A))==null?void 0:T[1])||A,G=`<button class="field-select" data-pick="${I}">${D(S)}${Me("down")}</button>`;if(h==="sort")return`<div class="condition">${G}<button class="sort-direction ${b.sort==="asc"?"selected":""}" data-dir="asc" data-index="${I}">首项 → 末项</button><button class="sort-direction ${b.sort==="desc"?"selected":""}" data-dir="desc" data-index="${I}">末项 → 首项</button><button data-remove="${I}" aria-label="删除条件">${Me("close")}</button></div>`;if(h==="group")return`<div class="condition">${G}<span class="spacer"></span><button data-remove="${I}" aria-label="删除条件">${Me("close")}</button></div>`;const E=Vt([["contains",n[A]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],b.operator,`data-operator="${I}" aria-label="运算符"`),k=["blank","notBlank"].includes(b.operator)?"":n[A]?Vt([["","请选择目标值"],...n[A].map(H=>[H,H])],b.value,`data-rule-value="${I}" aria-label="目标值"`):`<input data-rule-value="${I}" aria-label="目标值" value="${D(b.value)}" placeholder="请选择目标值">`;return`<div class="condition">${G}${E}${k}${h==="color"?`<input type="color" data-color="${I}" value="${b.color}" aria-label="行颜色">`:""}<button data-remove="${I}" aria-label="删除条件">${Me("close")}</button></div>`}).join(""),y=l(u,`设置${g}条件`,`${h==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${f.showTerminated?"checked":""}>显示已终止数据</label>`:""}${m}<button class="add-condition">${Me("plus")}添加${h==="color"?"着色":g}条件</button>${v.length?'<button class="clear-rules">清空全部条件</button>':""}`,h==="color"?650:560);s.setActiveRulePanel(h);const x=()=>p(h,u);let C=-1;y.querySelectorAll(".condition").forEach((b,I)=>{b.draggable=!0,b.ondragstart=A=>{var S;C=I,(S=A.dataTransfer)==null||S.setData("text/plain",String(I))},b.ondragover=A=>A.preventDefault(),b.ondrop=A=>{if(A.preventDefault(),C<0||C===I)return;const[S]=v.splice(C,1);v.splice(I,0,S),r(),x()}}),y.onclick=b=>{const I=b.target.closest("button");I&&(I.classList.contains("add-condition")&&a(I,A=>{h==="filter"&&f.filters.push({field:A,operator:"contains",value:""}),h==="sort"&&f.sorts.push({colId:A,sort:"asc"}),h==="group"&&!f.groups.includes(A)&&f.groups.push(A),h==="color"&&f.colors.push({field:A,operator:"contains",value:"",color:"#e9f2ff"}),r(),x()}),I.dataset.pick!==void 0&&a(I,A=>{const S=+I.dataset.pick;h==="sort"?f.sorts[S].colId=A:h==="group"?f.groups[S]=A:(v[S].field=A,v[S].value=""),r(),x()}),I.dataset.remove!==void 0&&(v.splice(+I.dataset.remove,1),r(),x()),I.classList.contains("clear-rules")&&(v.splice(0),r(),x()),I.dataset.dir&&(f.sorts[+I.dataset.index].sort=I.dataset.dir,r(),x()))},y.onchange=b=>{const I=b.target;I.id==="terminated"&&(f.showTerminated=I.checked),I.dataset.operator!==void 0&&(v[+I.dataset.operator].operator=I.value,x()),I.dataset.ruleValue!==void 0&&(v[+I.dataset.ruleValue].value=I.value),I.dataset.color!==void 0&&(f.colors[+I.dataset.color].color=I.value),r()},y.oninput=b=>{const I=b.target;I.tagName==="INPUT"&&I.dataset.ruleValue!==void 0&&(v[+I.dataset.ruleValue].value=I.value,r())}}return{colorRuleMatches:d,colorPanel:c,rulePanel:p}}function ja(s={}){var d;const e=document.createElement("section");e.className="rowvia-work-items detail-header-surface";const t=document.createElement("div");t.className="detail-meta-row";const n=s.tags??[];t.innerHTML=`${n.map(c=>`<span class="detail-meta-tag">${D(c)}</span>`).join("")}<button type="button" class="detail-meta-add" data-detail-action="add-tag" aria-label="添加标签">${Me("add")}</button><span class="detail-meta-divider"></span>${(s.signals||[]).map(c=>`<button type="button" class="detail-signal${c.checked?" checked":""}" data-detail-action="toggle-signal"><span class="detail-signal-dot">${c.checked?"✓":""}</span>${D(c.label)}</button>`).join("")}`,e.append(t);const i=s.stages??[],o=s.activeStage||((d=i.find(c=>c.state==="active"))==null?void 0:d.id),a=document.createElement("div");a.className="detail-process-strip",a.setAttribute("aria-label","工作项流程"),a.innerHTML=i.map((c,p)=>`<div class="detail-stage-wrap"><button type="button" class="detail-stage ${c.id===o?"active":""} ${c.state||""}" data-detail-action="stage" data-stage="${D(c.id)}"><span class="detail-stage-dot"></span>${D(c.label)}</button>${p<i.length-1?'<span class="detail-stage-line"></span>':""}</div>`).join(""),e.append(a);const l=document.createElement("div");l.className="detail-stage-card";const r=i.find(c=>c.id===o)||i[0];return r&&(l.innerHTML=`<div class="detail-stage-card-head"><div><span class="detail-stage-chevron">⌄</span><span class="detail-stage-card-dot ${r.state||""}"></span><strong>${D(r.label)}</strong><span class="detail-stage-status">进行中</span></div><div class="detail-stage-card-actions"><button type="button" class="primary" data-detail-action="complete-stage">完成</button><button type="button" class="icon-button" data-detail-action="stage-more" aria-label="节点更多">${Me("more")}</button></div></div><div class="detail-stage-card-body"><span>负责人</span><strong>${D(s.owner||"待填")}</strong></div><div class="detail-dependency"><span>⌄</span> 依赖项</div>`),r&&e.append(l),e.onclick=c=>{var u;const p=c.target.closest("[data-detail-action]");if(!p)return;const h=p.dataset.detailAction||"";(u=s.onAction)==null||u.call(s,h),e.dispatchEvent(new CustomEvent("rowvia:detail-action",{detail:{action:h,stage:p.dataset.stage},bubbles:!0}))},e}function Ka(s={}){const e=ja(s),t=$e(e,"work-item-detail-header",s);return{element:e,onInteraction:t.onInteraction,destroy(){t.destroy(),e.onclick=null,e.remove()}}}function Ya(s,e={}){const t=document.createElement("div");t.className="rowvia-work-items rowvia-field-scope",t.style.display="contents",s.append(t);const n=new je,i=$e(t,"work-item-layers",e);let o=null,a=null,l=null,r,d=null;const c=(u,f,g)=>{var v,m;u==="open"?(v=e.onOpen)==null||v.call(e,f,g):(m=e.onClose)==null||m.call(e,f),t.dispatchEvent(new CustomEvent(`rowvia:layer-${u}`,{detail:{kind:f,element:g},bubbles:!0}))};function p(){o&&(o.remove(),o=null,c("close","popup"))}function h(){a&&(a.remove(),a=null,l==null||l.focus(),l=null,c("close","overlay"))}return n.listen(t,"click",u=>{var m;const f=u.target,g=(m=f.closest("[data-action]"))==null?void 0:m.dataset.action,v=g==="close-popup"?"popup":g==="close-overlay"||f===a?"overlay":void 0;v&&(u.stopPropagation(),e.onCloseRequest?e.onCloseRequest(v):v==="popup"?p():h())}),{element:t,onInteraction:i.onInteraction,closePopup:p,closeOverlay:h,showPopup(u,f,g,v=460,m=""){if(n.destroyed)throw new Error("Cannot open a destroyed layer host");p(),o=document.createElement("section"),o.className=`popup ${m}`,o.setAttribute("role","dialog"),o.ariaLabel=f||"列操作",o.style.width=`${v}px`,o.innerHTML=`${f?`<div class="popup-head"><span>${D(f)}</span>${Te("close-popup","","close")}</div>`:""}${g}`,t.append(o);const y=u.getBoundingClientRect();return o.style.left=`${Math.max(12,Math.min(y.left,innerWidth-v-16))}px`,o.style.top=`${Math.min(y.bottom+8,Math.max(12,innerHeight-o.offsetHeight-16))}px`,c("open","popup",o),o},showOverlay(u,f="dialog-overlay"){if(n.destroyed)throw new Error("Cannot open a destroyed layer host");return a?(a.remove(),c("close","overlay")):l=document.activeElement,a=document.createElement("div"),a.className=`overlay ${f}`,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),typeof u=="string"?a.innerHTML=u:a.append(u),t.append(a),c("open","overlay",a),a},toast(u){if(n.destroyed)return;r==null||r(),d==null||d.remove();const f=document.createElement("div");f.className="toast",f.setAttribute("role","status"),f.innerHTML=Me("check")+D(u),t.append(f),d=f;const g=window.setTimeout(()=>{f.remove(),r==null||r()},2500);r=n.add(()=>window.clearTimeout(g))},destroy(){n.destroyed||(n.destroy(),i.destroy(),p(),h(),t.remove())}}}const vn=new WeakMap;function Di(s,e){let t=vn.get(s);if(!t){const i=new Set,o=a=>{for(const l of[...i])i.has(l)&&!l.contains(a.target,a)&&l.leave(a)};s.addEventListener("pointerdown",o,!0),s.addEventListener("focusin",o,!0),t={boundaries:i,stop:()=>{s.removeEventListener("pointerdown",o,!0),s.removeEventListener("focusin",o,!0)}},vn.set(s,t)}t.boundaries.add(e);const n=t;return()=>{!n.boundaries.delete(e)||n.boundaries.size||(n.stop(),vn.delete(s))}}class Oe{constructor(e){w(this,"root");w(this,"destroying",!1);w(this,"feedback");w(this,"options");w(this,"value");w(this,"committedValue");w(this,"state");w(this,"view");w(this,"viewLife",new je);w(this,"life",new je);w(this,"listeners",new Set);w(this,"interactions");w(this,"interactionListeners",new Set);w(this,"mounted",!1);w(this,"handled",new WeakSet);this.options={...e},this.value=e.value,this.committedValue=e.value,this.state=e.readonly||e.canEdit===!1?"display":e.state??"display"}get element(){if(this.root)return this.root;const e=document.createElement("div");return e.className="rowvia-field",e.tabIndex=0,e.setAttribute("aria-label",this.options.field.label),this.root=e,e}bindRoot(){this.life.listen(this.element,"pointerenter",()=>{this.state==="display"&&this.setState("hover","user")}),this.life.listen(this.element,"pointerleave",()=>{this.state==="hover"&&this.setState("display","user")}),this.life.listen(this.element,"click",e=>{e.target.closest("button,a,input,textarea,select,[contenteditable]")||this.edit("user")}),this.life.listen(this.element,"keydown",e=>{const t=e.key;t==="Escape"&&this.state==="editing"?(e.preventDefault(),this.cancel("user")):(t==="Enter"||t===" ")&&this.state!=="editing"&&e.target===this.element&&(e.preventDefault(),this.edit("user"))}),this.life.listen(this.element,"fc-collapse",e=>{var t;((t=e.detail)==null?void 0:t.reason)==="escape"?this.cancel("user"):this.commit("user")}),this.life.listen(this.element,"focusout",()=>{queueMicrotask(()=>{var t,n;if(this.life.destroyed||!this.element.isConnected||this.state!=="editing")return;const e=this.element.ownerDocument.activeElement;this.element.contains(e)||(n=(t=this.view)==null?void 0:t.content)!=null&&n.contains(e)||Ye(e,this.element)||this.commit("user")})})}renderHover(e){return this.renderDisplay(e)}beforeInput(e){return e}beforeCommit(e){return!0}beforeCancel(e){return!0}beforeStateChange(e){return!0}validateValue(e){}isReadonly(){return!!this.options.readonly||this.options.canEdit===!1||this.options.field.editable===!1}onOutput(e){}get snapshot(){return{key:this.options.field.key,value:this.read(),committedValue:this.committedValue,state:this.state,readonly:this.isReadonly()}}mount(e){if(this.life.destroyed)throw new Error("Cannot mount a destroyed field");return this.mounted||(this.mounted=!0,this.bindRoot(),this.draw()),e==null||e.append(this.element),this}read(){var e;return this.state==="editing"&&((e=this.view)!=null&&e.read)?this.view.read():this.value}on(e){return this.life.destroyed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)})}onInteraction(e){return this.life.destroyed?()=>{}:(this.interactionListeners.add(e),()=>{this.interactionListeners.delete(e)})}input(e,t="api",n){var l;if(this.life.destroyed||this.snapshot.readonly)return;const i=this.value,o=this.snapshot,a=this.beforeInput(e);this.value=(l=this.options.hooks)!=null&&l.beforeInput?this.options.hooks.beforeInput(a,o):a,(t==="api"||!Object.is(e,this.value))&&this.draw(),this.emit("input",t,{previousValue:i,originalEvent:n})}setValue(e){if(this.life.destroyed)return;const t=this.read();this.value=e,this.committedValue=e,this.draw(),this.emit("change","api",{previousValue:t})}update(e){this.life.destroyed||(this.value=this.read(),this.options={...this.options,...e},"value"in e&&(this.value=this.committedValue=e.value),e.state&&(this.state=e.state),this.isReadonly()&&(this.state="display"),this.draw())}validate(){var n,i,o,a;const e=this.read(),t=e==null||e===""||Array.isArray(e)&&e.length===0;return(this.options.field.required&&t?"此项必填":void 0)||this.validateValue(e)||((i=(n=this.view)==null?void 0:n.validate)==null?void 0:i.call(n))||((a=(o=this.options.hooks)==null?void 0:o.validate)==null?void 0:a.call(o,e))}commit(e="api"){var i,o;if(this.life.destroyed||this.snapshot.readonly)return!1;const t=this.validate();if(this.showValidation(t),t)return this.emit("invalid",e,{message:t}),!1;const n=this.event("commit",e,{previousValue:this.committedValue});return!this.beforeCommit(n)||((o=(i=this.options.hooks)==null?void 0:i.beforeCommit)==null?void 0:o.call(i,n))===!1?!1:(this.value=this.read(),this.committedValue=this.value,this.element.removeAttribute("aria-invalid"),this.emit("commit",e,{previousValue:n.previousValue}),this.setState("display",e),!0)}cancel(e="api"){var i,o,a,l;if(this.life.destroyed)return;const t=this.event("cancel",e);if(!this.beforeCancel(t)||((o=(i=this.options.hooks)==null?void 0:i.beforeCancel)==null?void 0:o.call(i,t))===!1)return;const n=this.event("state",e,{previousState:this.state,state:"display",value:this.committedValue});this.state!=="display"&&(!this.beforeStateChange(n)||((l=(a=this.options.hooks)==null?void 0:a.beforeStateChange)==null?void 0:l.call(a,n))===!1)||(this.value=this.committedValue,this.disposeView(),this.state="display",this.draw(),this.emit("cancel",e),n.previousState!=="display"&&this.publish(n))}edit(e="api"){var t,n;this.life.destroyed||(this.setState("editing",e),this.state==="editing"&&((n=(t=this.view)==null?void 0:t.focus)==null||n.call(t)))}setState(e,t="api"){var o,a,l,r;if(this.life.destroyed||e===this.state||e==="editing"&&this.snapshot.readonly)return;const n=this.event("state",t,{previousState:this.state});if(n.state=e,!this.beforeStateChange(n)||((a=(o=this.options.hooks)==null?void 0:o.beforeStateChange)==null?void 0:a.call(o,n))===!1)return;const i=this.state!=="editing"&&e!=="editing"&&!((l=this.options.renderers)!=null&&l.display)&&!((r=this.options.renderers)!=null&&r.hover)&&this.renderHover===Oe.prototype.renderHover;this.value=this.read(),this.state=e,i&&this.view?this.element.dataset.state=e:this.draw(),this.publish(n)}action(e,t){var i,o;if(this.life.destroyed)return;const n={type:e,value:t};(o=(i=this.options).onAction)==null||o.call(i,n),this.emit("action","api",{action:n})}destroy(){var e,t;if(!(this.life.destroyed||this.destroying)){this.destroying=!0,this.value=this.read();try{this.emit("destroy","api")}finally{try{this.disposeView()}finally{(e=this.interactions)==null||e.destroy(),this.life.destroy(),this.listeners.clear(),this.interactionListeners.clear(),(t=this.root)==null||t.remove()}}}}createEditor(){if(this.life.destroyed)throw new Error("Cannot edit a destroyed field");this.disposeView(),this.state="editing";const e=this.renderEditing(this.context());return this.view=e,this.watch(e),{...e,read:()=>this.read(),validate:()=>this.validate(),onInteraction:t=>this.onInteraction(t),destroy:()=>this.destroy()}}render(){if(this.life.destroyed)throw new Error("Cannot render a destroyed field");return this.disposeView(),this.view=this.renderDisplay(this.context()),{...this.view,destroy:()=>this.destroy()}}context(){return{...this.options,readonly:this.isReadonly(),value:this.value,onAction:e=>this.action(e.type,e.value)}}showValidation(e){var t;if(this.mounted){if(!e){this.element.removeAttribute("aria-invalid"),(t=this.feedback)==null||t.remove();return}this.feedback??(this.feedback=this.element.ownerDocument.createElement("div")),this.feedback.className="fc-error",this.feedback.setAttribute("role","status"),this.feedback.textContent=e,this.element.setAttribute("aria-invalid","true"),this.element.append(this.feedback)}}draw(){var c,p,h,u,f,g,v;if(!this.mounted||this.life.destroyed)return;const e=this.element.ownerDocument.activeElement,t=this.state==="editing"&&!!e&&(!!((c=this.view)!=null&&c.element.contains(e))||!!((h=(p=this.view)==null?void 0:p.content)!=null&&h.contains(e))),n=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:void 0;this.disposeView(),this.isReadonly()&&(this.state="display");const i=this.snapshot,o=this.options.content,a=typeof o=="function"?o(i):o??{kind:"text",text:this.value==null?"":String(this.value)},l=this.context(),r=()=>this.state==="editing"?this.renderEditing(l):o?wn(a):this.state==="hover"?this.renderHover(l):this.renderDisplay(l),d={...i,element:this.element,field:this.options.field,content:a,renderDefault:r,input:m=>this.input(m),commit:()=>this.commit(),cancel:()=>this.cancel(),edit:()=>this.edit(),action:(m,y)=>this.action(m,y)};if(this.view=((f=(u=this.options.renderers)==null?void 0:u[this.state])==null?void 0:f.call(u,d))??r(),this.element.setAttribute("aria-label",this.options.field.label),this.element.dataset.state=this.state,this.element.dataset.readonly=String(i.readonly),this.element.replaceChildren(this.view.element),this.element.removeAttribute("aria-invalid"),this.watch(this.view),t){(v=(g=this.view).focus)==null||v.call(g);const m=this.element.ownerDocument.activeElement;if((n==null?void 0:n.start)!=null&&n.end!=null&&(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement))try{m.setSelectionRange(n.start,n.end)}catch{}}}watch(e){if(this.mounted&&this.state==="editing"){const n=()=>[this.element,e.content,this.options.focusBoundary].filter(i=>!!i);this.viewLife.add(Di(this.element.ownerDocument,{contains:(i,o)=>n().some(a=>o.composedPath().includes(a)||!!i&&a.contains(i)||Ye(i,a)),leave:()=>{this.element.isConnected&&this.commit("user")}}))}this.interactions??(this.interactions=$e(this.mounted?this.element:e.element,`field:${this.options.field.key}`,{onInteraction:n=>{var i,o;(o=(i=this.options).onInteraction)==null||o.call(i,n);for(const a of this.interactionListeners)a(n)}}));const t=[...new Set([e.element,e.content].filter(n=>!!n))];for(const n of t)this.viewLife.add(this.interactions.addRoot(n));for(const n of e.inputRoot?[e.inputRoot]:t)for(const i of["input","change"])this.viewLife.listen(n,i,o=>{var a;this.handled.has(o)||(this.handled.add(o),this.input(((a=e.read)==null?void 0:a.call(e))??this.value,"user",o),i==="change"&&this.emit("change","user",{originalEvent:o}))})}disposeView(){var t;this.viewLife.destroy(),this.viewLife=new je;const e=this.view;this.view=void 0,(t=e==null?void 0:e.destroy)==null||t.call(e)}event(e,t,n={}){return{...this.snapshot,type:e,source:t,...n}}emit(e,t,n={}){this.publish(this.event(e,t,n))}publish(e){var i,o,a;this.onOutput(e),(o=(i=this.options).onEvent)==null||o.call(i,e);for(const l of[...this.listeners])l(e);const t=this.mounted?this.element:(a=this.view)==null?void 0:a.element;if(!t)return;const n=t.ownerDocument.defaultView.CustomEvent;t.dispatchEvent(new n(`field:${e.type}`,{detail:e,bubbles:!0}))}}function wn(s){if(s.kind==="node")return{element:s.node,destroy:s.destroy};const e=document.createElement("div");if(e.className=s.className??"",s.kind==="text")return e.textContent=s.text,{element:e};const t=s.children.map(wn);return e.append(...t.map(n=>n.element)),{element:e,destroy:()=>t.forEach(n=>{var i;return(i=n.destroy)==null?void 0:i.call(n)})}}function Pi(s,e=312){s.rows=1,s.style.resize="none";const t=()=>{s.style.height="auto";const n=s.scrollHeight;n>0&&(s.style.height=Math.min(n,e)+"px"),s.style.overflowY=n>e?"auto":"hidden"};return s.addEventListener("input",t),s.addEventListener("focus",t),queueMicrotask(t),t}const Hi=s=>s==null?"":String(s);function Xa(s){var t;const e=V("div",`fc-value fc-${s.className||""}`);if(s.field.kind==="richText"||s.field.kind==="richtext"||s.field.kind==="longText"||s.field.control==="richText")e.innerHTML=pt(s.value);else if(s.field.kind==="number"&&typeof s.value=="number"){const n=s.field.numberOptions;e.textContent=s.value.toLocaleString("zh-CN",{useGrouping:(n==null?void 0:n.thousandsSeparator)??!1,maximumFractionDigits:(n==null?void 0:n.decimals)??10})+((n==null?void 0:n.suffix)||""),e.classList.add("fc-plain")}else e.textContent=Hi(s.value),e.classList.add("fc-plain");return(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function Oi(s,e){const n=s==="text"&&e.layout!=="compact"?V("textarea","fc-input fc-textarea"):V("input","fc-input");if(n instanceof HTMLInputElement&&(n.type=s),n.value=Hi(e.value),n.disabled=e.readonly,n.required=!!e.field.required,n.ariaLabel=e.field.label,n.placeholder=e.field.placeholder||(e.layout!=="compact"?"待填":`请输入${e.field.label}`),e.field.maxLength!==void 0&&(n.maxLength=e.field.maxLength),s==="number"&&n instanceof HTMLInputElement){const i=e.field.numberOptions;n.step=String((i==null?void 0:i.step)??"any"),(i==null?void 0:i.min)!==void 0&&(n.min=String(i.min)),(i==null?void 0:i.max)!==void 0&&(n.max=String(i.max))}return n instanceof HTMLTextAreaElement&&Pi(n),s==="text"&&e.layout!=="compact"&&n.addEventListener("keydown",i=>{i.key==="Enter"&&(i.preventDefault(),n.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))}),{element:n,read:()=>s==="number"?n.value===""?null:Number(n.value):n.value,validate:()=>e.field.required&&!n.value.trim()?"此项必填":n.checkValidity()?void 0:n.validationMessage||"请填写有效值",focus:()=>n.focus()}}const Bi=s=>!Array.isArray(s)||!s.length?[]:Array.isArray(s[0])?s.map(e=>e.map(String)):[s.map(String)];function Mt(s,e){const t=[];for(const n of e){const i=s.find(o=>o.id===n);t.push((i==null?void 0:i.label)||n),s=(i==null?void 0:i.children)||[]}return t.join(" / ")}function Za(s){const e=V("div","fc-tags");for(const t of Bi(s.value)){const n=V("span","fc-tag");n.append(V("span","fc-tag-label",Mt(Ue(s.field),t))),e.append(n)}return e.children.length||e.append(V("span","fc-empty","待填")),e}function Qa(s,e){const t=V("div","fc-cascade"),n=V("div","fc-choice-selection"),i=V("input","fc-choice-search");i.placeholder="",i.autocomplete="off",i.ariaLabel="输入以搜索"+e.field.label,i.disabled=e.readonly;const o=()=>{i.size=Math.max(1,[...i.value].length+1)};o();const a=V("div","fc-cascade-columns"),l=V("div","fc-error");l.setAttribute("role","status");const r=Ue(e.field);let d=Bi(e.value),c=[];const p=[],h=(b,I,A=!1)=>b.forEach(S=>{var G;(G=S.children)!=null&&G.length?h(S.children,[...I,S.id],A||!!S.disabled):p.push({path:[...I,S.id],disabled:A||!!S.disabled})});h(r,[]);const u=(b,I)=>JSON.stringify(b)===JSON.stringify(I),f=e.layout!=="compact"&&!e.readonly;let g;const v=()=>{const b=g;g=void 0,b==null||b.close()},m=()=>{!f||g||e.readonly||(g=kt({anchor:i.parentElement||t,content:a,width:"anchor",gap:4,onDismiss:()=>{g=void 0}}))},y=()=>{!f||!g||(v(),t.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},x=b=>{if(e.readonly)return;const I=d.findIndex(A=>u(A,b));if(s&&I>=0)d.splice(I,1);else{if(s&&e.field.maxSelections&&d.length>=e.field.maxSelections){l.textContent="最多可选择 "+e.field.maxSelections+" 项";return}d=s?[...d,b]:[b]}l.textContent="",C(),t.dispatchEvent(new Event("change",{bubbles:!0})),s||y()},C=()=>{var S,G;if(n.replaceChildren(),a.replaceChildren(),d.forEach(E=>{const k=V("span","fc-tag");k.append(V("span","fc-tag-label",Mt(r,E)));const T=V("span","fc-tag-slot"),H=V("button","fc-choice-remove","×");H.type="button",H.disabled=e.readonly,H.ariaLabel="移除"+Mt(r,E),H.onclick=()=>{d=d.filter(W=>!u(E,W)),C(),t.dispatchEvent(new Event("change",{bubbles:!0}))},T.append(H),k.append(T),n.append(k)}),i.value.trim()){const E=p.filter(k=>!k.disabled&&Mt(r,k.path).toLocaleLowerCase().includes(i.value.trim().toLocaleLowerCase()));for(const{path:k}of E){const T=V("button","fc-option",Mt(r,k));T.type="button",T.disabled=e.readonly,T.setAttribute("aria-pressed",String(d.some(H=>u(H,k)))),T.onclick=()=>x(k),a.append(T)}a.classList.add("is-search"),E.length||a.append(V("p","fc-empty","暂无匹配路径"));return}a.classList.remove("is-search");let b=r,I=[],A=0;for(;b.length;){const E=V("div","fc-cascade-column");E.setAttribute("role","group"),E.ariaLabel="第"+(A+1)+"级";for(const T of b.filter(H=>!H.disabled)){const H=[...I,T.id],W=!!((S=T.children)!=null&&S.length),R=V("button","fc-option",T.label+(W?" ›":""));R.type="button",R.disabled=e.readonly,R.classList.toggle("selected",W?c[A]===T.id:d.some(O=>u(O,H))),R.setAttribute(W?"aria-expanded":"aria-pressed",String(W?c[A]===T.id:d.some(O=>u(O,H)))),R.onclick=()=>{var O,L;W?(c=H,C(),(L=(O=a.lastElementChild)==null?void 0:O.querySelector("button"))==null||L.focus()):x(H)},E.append(R)}a.append(E);const k=b.find(T=>T.id===c[A]&&!T.disabled);if(!((G=k==null?void 0:k.children)!=null&&G.length))break;I=[...I,k.id],b=k.children,A++}r.length||a.append(V("p","fc-empty","暂无可选分类"))};if(i.oninput=()=>{o(),C()},i.onfocus=m,a.onkeydown=b=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(b.key))return;const I=b.target,S=[...(I.closest(".fc-cascade-column")||a).querySelectorAll("button:not(:disabled)")];if(!S.length)return;b.preventDefault();const G=S.indexOf(I);S[b.key==="Home"?0:b.key==="End"?S.length-1:(G+(b.key==="ArrowDown"?1:-1)+S.length)%S.length].focus()},t.append(n,i,l),f){const b=V("span","fc-field-chevron");b.setAttribute("aria-hidden","true"),t.append(b),t.addEventListener("click",()=>m())}else t.append(a);return C(),{element:t,content:f?a:void 0,read:()=>s?d.map(b=>[...b]):[...d[0]||[]],focus:()=>{i.focus(),m()},deactivate:()=>{i.value="",o(),v()},destroy:()=>v(),validate:()=>e.field.required&&!d.length?"请选择分类":void 0}}const st=s=>s==null?"":String(s),ft=s=>s.dispatchEvent(new Event("change",{bubbles:!0}));function yn(s){try{const e=new URL(st(s));return["http:","https:"].includes(e.protocol)?e.href:void 0}catch{return}}function Rt(s){return V("div","fc-value fc-plain fc-"+(s.className||"")+(s.value==null||s.value===""?" fc-empty":""),st(s.value)||"待填")}function zt(s,e){const t=e==="textarea"?V("textarea","fc-input fc-textarea"):V("input","fc-input");return t instanceof HTMLInputElement&&(t.type=e),t instanceof HTMLTextAreaElement&&Pi(t),t.value=st(s.value),t.disabled=s.readonly,t.required=!!s.field.required,t.ariaLabel=s.field.label,t.placeholder=s.field.placeholder||"请输入"+s.field.label,s.field.maxLength!==void 0&&(t.maxLength=s.field.maxLength),{element:t,read:()=>t.value,focus:()=>t.focus(),validate:()=>e==="url"&&t.value&&!yn(t.value)?"请输入 http 或 https 链接":t.checkValidity()?void 0:"请填写有效的"+s.field.label}}function Ja(s){const e=V("div","fc-link-value"),t=yn(s.value);if(!t)return Rt(s);const n=V("a","fc-link",st(s.value));return n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.onclick=i=>i.stopPropagation(),e.append(V("span","fc-link-icon","↗"),n),e}function Vi(s){let e=s.value===!0;const t=V("div","fc-switch-field"),n=V("button","fc-switch");n.type="button",n.setAttribute("role","switch"),n.ariaLabel=s.field.label,n.disabled=s.readonly;const i=V("span"),o=()=>{n.setAttribute("aria-checked",String(e)),i.textContent=e?"是":"否"};return n.onclick=()=>{s.readonly||(e=!e,o(),ft(t))},t.append(n,i),o(),{element:t,read:()=>e,focus:()=>n.focus()}}function er(s){return Vi({...s,readonly:!0}).element}function tr(s){const e=V("div","fc-signals"),t=Array.isArray(s.value)?s.value:[s.value];for(const n of t.filter(i=>i!=null&&i!=="")){const i=typeof n=="object"?n:{status:n},o=i.status??i.value,a=o===!0||o==="passed"||o==="success",l=V("span","fc-signal "+(a?"is-success":"is-pending"),(a?"● ":"○ ")+st(i.label||i.name||(a?"已满足":o===!1?"未满足":o||"等待信号")));e.append(l)}return e.children.length||e.append(V("span","fc-empty","等待外部信号")),e}function nr(s){const e=s.value&&typeof s.value=="object"?s.value.display??s.value.value:s.value;return Rt({...s,value:e!=null&&typeof e!="object"?e:""})}function ir(s,e){const t=V("div","fc-readonly");return t.append(e(s),V("small","fc-service-note","由系统更新 · 只读")),{element:t,read:()=>s.value}}function Gi(s){var f,g,v;let e=Array.isArray(s.value)?structuredClone(s.value):[];const t=V("div","fc-attachments"),n=V("div","fc-file-list"),i=V("label","fc-upload-zone","+ 上传附件"),o=V("input");o.type="file",o.multiple=!0,o.ariaLabel="上传"+s.field.label,o.accept=((f=s.field.attachmentOptions)==null?void 0:f.accept)||"",o.disabled=s.readonly||!((g=s.services)!=null&&g.upload);const a=V("p","fc-error");a.setAttribute("role","status");const l=V("button","fc-retry","重试上传");l.type="button",l.hidden=!0;let r=[],d=!1,c=!1,p;const h=()=>{n.replaceChildren(),e.forEach((m,y)=>{const x=V("div","fc-file-row"),C=yn(m.url),b=C?V("a","fc-link",m.name):V("span","",m.name);if(b.tagName==="A"){const I=b;I.href=C,I.target="_blank",I.rel="noopener noreferrer"}if(x.append(V("span","fc-file-icon","▤"),b),m.size!=null&&x.append(V("small","fc-file-size",Math.ceil(m.size/1024)+" KB")),!s.readonly){const I=V("button","fc-file-remove","×");I.type="button",I.disabled=d,I.ariaLabel="移除"+m.name,I.onclick=()=>{e.splice(y,1),h(),ft(t)},x.append(I)}n.append(x)}),e.length||n.append(V("span","fc-empty","暂无附件"))},u=async()=>{var x;if(!((x=s.services)!=null&&x.upload)||s.readonly||d||!r.length)return;const m=s.field.attachmentOptions;if(m!=null&&m.maxFiles&&e.length+r.length>m.maxFiles){a.textContent="最多上传 "+m.maxFiles+" 个文件";return}if(m!=null&&m.maxBytes&&r.some(C=>C.size>m.maxBytes)){a.textContent="文件大小超过限制";return}const y=((m==null?void 0:m.accept)||"").split(",").map(C=>C.trim().toLowerCase()).filter(Boolean);if(y.length&&r.some(C=>!y.some(b=>b.startsWith(".")?C.name.toLowerCase().endsWith(b):b.endsWith("/*")?C.type.toLowerCase().startsWith(b.slice(0,-1)):C.type.toLowerCase()===b))){a.textContent="文件类型不符合要求";return}p=new AbortController,d=!0,o.disabled=!0,l.hidden=!0,a.textContent="上传中…",t.setAttribute("aria-busy","true"),h();try{const C=await s.services.upload(s.field,r,p.signal);if(c)return;if(C.length!==r.length||C.some(b=>!b.id||!b.name))throw new Error("Invalid file references");e=[...e,...C],r=[],a.textContent="",o.value=""}catch{c||(a.textContent="上传失败,已保留原有附件",l.hidden=!1)}finally{c||(d=!1,o.disabled=!1,t.setAttribute("aria-busy","false"),h(),r.length||ft(t))}};return o.onchange=m=>{m.stopPropagation(),r=Array.from(o.files||[]),u()},l.onclick=()=>void u(),i.append(o),t.append(n),s.readonly||(t.append(i),(v=s.services)!=null&&v.upload||t.append(V("p","fc-service-note","上传服务未接入"))),t.append(a,l),h(),{element:t,read:()=>structuredClone(e),focus:()=>o.focus(),validate:()=>d?"请等待上传完成":r.length?"请完成或重新选择上传文件":s.field.required&&!e.length?"请上传附件":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function qi(s){if(s&&typeof s=="object"&&!Array.isArray(s)){const e=s;return{selected:Array.isArray(e.selected)?[...e.selected]:[],counts:{...e.counts},total:e.total}}return{selected:[],counts:{}}}function zi(s,e){var u;let t=qi(s.value),n=[...t.selected];const i=e==="attitude"?[{id:"like",label:"赞同"}]:Ue(s.field),o=V("div","fc-vote"),a=V("div","fc-vote-list"),l=V("p","fc-error");l.setAttribute("role","status");const r=V("button","fc-vote-submit","提交投票");r.type="button";let d=!1,c=!1,p;const h=()=>{var g,v;a.replaceChildren();const f=Math.max(1,...Object.values(t.counts));for(const m of i){const y=V("button","fc-vote-option");y.type="button",y.disabled=s.readonly||d||!((g=s.services)!=null&&g.vote)||!!m.disabled,y.classList.toggle("selected",n.includes(m.id)),y.setAttribute("aria-pressed",String(n.includes(m.id)));const x=V("span","fc-vote-bar");x.style.width=(t.counts[m.id]||0)/f*100+"%",y.append(x,V("span","",(e==="attitude"?"♡ ":"")+m.label),V("strong","",String(t.counts[m.id]||0))),y.onclick=()=>{n=n.includes(m.id)?n.filter(C=>C!==m.id):e==="multi"?[...n,m.id]:[m.id],h()},a.append(y)}i.length||a.append(V("p","fc-empty","暂无投票选项")),r.disabled=d||!((v=s.services)!=null&&v.vote)||!i.length,r.textContent=d?"提交中…":"提交投票"};return r.onclick=async()=>{var f;if(!(d||s.readonly||!((f=s.services)!=null&&f.vote))){d=!0,l.textContent="",p=new AbortController,o.setAttribute("aria-busy","true"),h();try{const g=await s.services.vote(s.field,n,p.signal);if(c)return;t=qi(g),n=[...t.selected]}catch{c||(l.textContent="投票失败,请重试")}finally{c||(d=!1,o.setAttribute("aria-busy","false"),h(),l.textContent||ft(o))}}},o.append(a),s.readonly||(o.append(r),(u=s.services)!=null&&u.vote||o.append(V("p","fc-service-note","投票服务未接入"))),o.append(l),h(),{element:o,read:()=>structuredClone(t),validate:()=>d?"请等待投票完成":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function sr(s){const e=s.value&&typeof s.value=="object"?s.value:{},t=V("div","fc-location"),i=[["address","地址","text"],["longitude","经度","number"],["latitude","纬度","number"]].map(([a,l,r])=>{const d=V("label","fc-location-part",l),c=V("input","fc-input");return c.type=r,c.value=st(e[a]),c.disabled=s.readonly,c.ariaLabel=l,c.placeholder=l,r==="number"&&(c.step="any",c.min=a==="longitude"?"-180":"-90",c.max=a==="longitude"?"180":"90"),d.append(c),t.append(d),c}),o=()=>i.every(a=>!a.value)?null:{address:i[0].value,longitude:i[1].value?Number(i[1].value):null,latitude:i[2].value?Number(i[2].value):null};return{element:t,read:o,focus:()=>i[0].focus(),validate:()=>{if(!o())return s.field.required?"请填写位置":void 0;if(i.slice(1).some(a=>a.value===""||!a.checkValidity()))return"请填写有效的经纬度"}}}function or(s){const e=s.value;return Rt({...s,value:e&&typeof e=="object"?st(e.address)||[e.longitude,e.latitude].filter(t=>t!=null).join(", "):""})}function ar(s,e){const t=V("div","fc-composite"),n=V("div","fc-composite-rows"),i=V("button","fc-composite-add","+ 添加一组");i.type="button";const o=s.field.compositeFields||[],a=[];let l=!1;const r=u=>({...u.value,...Object.fromEntries(u.editors.map(({field:f,editor:g})=>[f.key,g.read()]))}),d=u=>{u.editors.forEach(({editor:f})=>{var g;return(g=f.destroy)==null?void 0:g.call(f)}),u.remove&&(u.remove.onclick=null),u.element.remove()},c=V("p","fc-empty","暂无记录"),p=()=>{a.forEach((u,f)=>{u.legend.textContent="第 "+(f+1)+" 组"}),i.disabled=s.readonly||!o.length||a.length>=(s.field.maxRows||100),a.length?c.remove():n.append(c)},h=u=>{const f=V("fieldset","fc-composite-row"),g=V("legend");f.append(g);const v=o.map(y=>{const x=e(y),C=x.createEditor({...s,field:y,value:u[y.key],readonly:s.readonly||y.editable===!1||!!x.readonly,focusBoundary:void 0,onSelectedOptions:I=>{var A;(A=s.services)!=null&&A.searchOptions&&(y.choices=[...new Map([...Ue(y),...I].map(S=>[S.id,S])).values()])}}),b=V("div","fc-composite-field");return b.append(V("label","",y.label+(y.required?" *":"")),C.element),f.append(b),{field:y,editor:C}}),m={value:u,element:f,legend:g,editors:v};if(!s.readonly){const y=V("button","fc-composite-remove","删除此组");y.type="button",y.onclick=()=>{if(l)return;const x=a.indexOf(m);x<0||(d(m),a.splice(x,1),p(),ft(t))},m.remove=y,f.append(y)}a.push(m),n.append(f),p()};for(const u of Array.isArray(s.value)?s.value:[])h(structuredClone(u));return i.onclick=()=>{l||i.disabled||(h({}),ft(t))},t.append(n),s.readonly||t.append(i),o.length||t.append(V("p","fc-service-note","请配置复合子字段")),p(),{element:t,read:()=>a.map(r),validate:()=>{var u;if(s.field.required&&!a.length)return"请至少添加一组";for(const[f,g]of a.entries())for(const{field:v,editor:m}of g.editors){const y=(u=m.validate)==null?void 0:u.call(m);if(y)return"第 "+(f+1)+" 组 · "+v.label+":"+y}},destroy:()=>{l||(l=!0,i.onclick=null,a.forEach(d))}}}class Xe extends Oe{renderDisplay(e){return{element:Xa(e)}}renderEditing(e){return Oi("text",e)}}class _i extends Xe{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,kind:"number"}})}renderEditing(e){return Oi("number",e)}}class Wi extends Xe{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,control:"richText"}})}renderEditing(e){return xi(e)}}class Ui extends Xe{renderDisplay(e){return{element:Rt(e)}}renderEditing(e){return zt(e,"textarea")}}class bn extends Xe{renderDisplay(e){return{element:Ja(e)}}renderEditing(e){return zt(e,"url")}}class ji extends Xe{renderEditing(e){return zt(e,"email")}}class Ki extends Xe{renderEditing(e){return zt(e,"tel")}}class gt extends Oe{constructor(){super(...arguments);w(this,"multiple",!1);w(this,"variant","choice")}renderDisplay(t){return{element:Ta(t,this.variant==="radio"?"choice":this.variant)}}renderEditing(t){return Si(this.multiple,t,this.variant)}}class Yi extends gt{constructor(){super(...arguments);w(this,"multiple",!0)}}class Xi extends gt{constructor(){super(...arguments);w(this,"variant","radio")}}class Cn extends gt{constructor(){super(...arguments);w(this,"variant","person")}}class Zi extends Cn{constructor(){super(...arguments);w(this,"multiple",!0)}}class Sn extends gt{constructor(){super(...arguments);w(this,"variant","relation")}}class Qi extends Sn{constructor(){super(...arguments);w(this,"multiple",!0)}}class En extends Oe{constructor(){super(...arguments);w(this,"multiple",!1)}renderDisplay(t){return{element:Za(t)}}renderEditing(t){return Qa(this.multiple,t)}}class Ji extends En{constructor(){super(...arguments);w(this,"multiple",!0)}}class xn extends Oe{normalize(e){return e}renderDisplay(e){return{element:Ti(this.normalize(e))}}renderEditing(e){return Ni(this.normalize(e))}}class kn extends xn{constructor(){super(...arguments);w(this,"range",!1)}normalize(t){return{...t,field:{...t.field,dateOptions:{showTime:!1,showRange:this.range,...t.field.dateOptions}}}}}class es extends kn{constructor(){super(...arguments);w(this,"range",!0)}}class ts extends Oe{renderDisplay(e){return{element:er(e)}}renderEditing(e){return Vi(e)}}class ns extends Oe{renderDisplay(e){return Gi({...e,readonly:!0})}renderEditing(e){return Gi(e)}}class is extends Oe{renderDisplay(e){return{element:or(e)}}renderEditing(e){return sr(e)}}class _t extends Oe{constructor(){super(...arguments);w(this,"mode","attitude")}renderDisplay(t){return zi({...t,readonly:!0},this.mode)}renderEditing(t){return zi(t,this.mode)}}class ss extends _t{constructor(){super(...arguments);w(this,"mode","single")}}class os extends _t{constructor(){super(...arguments);w(this,"mode","multi")}}class mt extends Oe{isReadonly(){return!0}constructor(e){super({...e,readonly:!0})}renderDisplay(e){return{element:nr(e)}}renderEditing(e){return ir(e,t=>this.renderDisplay(t).element)}}class Mn extends mt{renderDisplay(e){return{element:tr(e)}}}class as extends Xe{renderDisplay(e){const t=document.createElement("button");return t.type="button",t.className="fc-detail-link",t.textContent=e.field.label,t.onclick=n=>{var i;n.stopPropagation(),(i=e.onAction)==null||i.call(e,{type:"open",value:e.value})},{element:t,destroy:()=>{t.onclick=null}}}}class rs extends Oe{constructor(e,t){super(e),this.resolve=t}renderDisplay(e){var i;if(e.layout==="compact")return{element:Rt({...e,value:Array.isArray(e.value)&&e.value.length?e.value.length+" 组记录":""})};const t=document.createElement("div");t.className="fc-composite";const n=[];for(const o of Array.isArray(e.value)?e.value:[]){const a=document.createElement("fieldset");a.className="fc-composite-row";for(const l of e.field.compositeFields??[]){const r=document.createElement("label");r.textContent=l.label;const d={...e,field:l,value:o[l.key],readonly:!0},c=this.resolve(l),p=((i=c.renderView)==null?void 0:i.call(c,d))??{element:c.render(d)};n.push(p),a.append(r,p.element)}t.append(a)}return{element:t,destroy:()=>n.forEach(o=>{var a;return(a=o.destroy)==null?void 0:a.call(o)})}}renderEditing(e){return ar(e,this.resolve)}}const rr={textarea:"保留换行的纯文本,支持长度限制",radio:"平铺选项,一次选择一项",cascadeSingle:"逐级浏览分类,选择完整路径",cascadeMulti:"逐级浏览并选择多条路径",person:"按姓名搜索,以稳定人员 ID 保存",multiPerson:"按姓名搜索,以稳定人员 ID 保存",date:"日历选择和直接输入,支持清空",dateRange:"连续选择起止日期,校验完整范围",url:"填写网址并在新窗口安全打开",cloudDocument:"添加云文档链接,点击打开原文档",email:"邮箱输入与格式校验",phone:"支持国家区号的电话输入",switch:"以是或否记录布尔状态",attachment:"文件列表、上传与删除,支持上传失败重试",location:"填写地址和经纬度,校验坐标边界",relation:"按名称或编号搜索工作项,点击名称打开详情",multiRelation:"按名称或编号搜索工作项,点击名称打开详情",attitudeVote:"选择并提交投票,结果以宿主服务回读为准",singleVote:"选择并提交投票,结果以宿主服务回读为准",multiVote:"选择并提交投票,结果以宿主服务回读为准",externalSignal:"由外部系统更新,系统内只读",externalMultiSignal:"由外部系统更新,系统内只读",formula:"展示服务端计算结果,不可手工覆盖",aggregate:"展示服务端计算结果,不可手工覆盖",ai:"展示服务端计算结果,不可手工覆盖",system:"展示服务端计算结果,不可手工覆盖",composite:"可重复字段组,复用已注册子控件并逐组校验",multiPersonComposite:"可重复字段组,复用已注册子控件并逐组校验",text:"单行输入,支持清空和必填校验",richText:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",select:"从字段配置中选择一个选项",multiSelect:"点击标签选择多项,保存为数组",number:"支持小数和负数,空值与零分别保存",dateTime:"日历、时间与日期范围",detail:"由调用方处理关联内容导航"},lr={title:"text",longText:"richText",status:"select",richtext:"richText",single_select:"select",multi_select:"multiSelect",user:"person",multi_user:"multiPerson",multi_person:"multiPerson",cascade_select:"cascadeSingle",cascade_single:"cascadeSingle",cascade_multi:"cascadeMulti",daterange:"dateRange",date_range:"dateRange",datetime:"dateTime",multi_relation:"multiRelation",attitude_vote:"attitudeVote",single_vote:"singleVote",multi_vote:"multiVote",vote:"attitudeVote",external_signal:"externalSignal",external_multi_signal:"externalMultiSignal",multi_person_composite:"multiPersonComposite",cloud_document:"cloudDocument"},dr=[["text","单行文本",Xe,"文本","T"],["richText","富文本",Wi,"文本","¶"],["select","单选",gt,"选择","◉"],["multiSelect","多选",Yi,"选择","☑"],["number","数字",_i,"其他","#"],["dateTime","日期时间",xn,"日期","◷"],["detail","详情页查看",as,"关联工作项","↗"],["textarea","多行文本",Ui,"文本","≡"],["radio","单选按钮",Xi,"选择","◉"],["cascadeSingle","级联单选",En,"选择","⑂"],["cascadeMulti","级联多选",Ji,"选择","⑂"],["person","单选人员",Cn,"人员","♙"],["multiPerson","多选人员",Zi,"人员","♙"],["date","日期",kn,"日期","▦"],["dateRange","日期区间",es,"日期","▦"],["url","URL 链接",bn,"其他","↗"],["cloudDocument","关联云文档",bn,"其他","▤"],["email","邮箱",ji,"其他","@"],["phone","电话",Ki,"其他","☎"],["switch","开关",ts,"其他","◐"],["attachment","附件",ns,"其他","⌑"],["location","地理位置",is,"其他","⌖"],["relation","单选关联工作项",Sn,"关联工作项","↗"],["multiRelation","多选关联工作项",Qi,"关联工作项","↗"],["attitudeVote","表态投票",_t,"投票","♡"],["singleVote","单选投票",ss,"投票","♡"],["multiVote","多选投票",os,"投票","♡"],["externalSignal","系统外信号",Mn,"系统","◌",!0],["externalMultiSignal","多值系统外信号",Mn,"系统","◌",!0],["formula","公式计算",mt,"系统","ƒ",!0],["aggregate","聚合计算",mt,"系统","ƒ",!0],["ai","AI 字段",mt,"系统","ƒ",!0],["system","系统字段",mt,"系统","ƒ",!0]];function ls(s=[]){const e=new Map,t=a=>{if(!/^[A-Za-z][\w-]*$/.test(a.id))throw new Error("Invalid control id");if(e.has(a.id))throw new Error(`Control already registered: ${a.id}`);e.set(a.id,a)},n=a=>{const l=a.control||lr[a.kind||"text"]||a.kind||"text",r=e.get(l);if(!r)throw new Error(`Unknown control: ${l}`);return r},i=a=>n(a.field).create(a),o=a=>{const l=n(a);return{...l,render:r=>l.create(r).render().element,renderView:r=>l.create(r).render(),createEditor:r=>l.create(r).createEditor()}};for(const[a,l,r,d,c,p]of dr)t({id:a,label:l,description:rr[a]||l,glyph:c,group:d,readonly:p,action:a==="detail"?"view":a==="select"||a==="multiSelect"?"select":void 0,create:h=>new r({...h,readonly:p||h.readonly})});for(const[a,l]of[["composite","复合字段"],["multiPersonComposite","多人复合字段"]])t({id:a,label:l,description:"组合多个已注册字段",glyph:"▦",group:"其他",create:r=>new rs(r,o)});return s.forEach(t),{register:t,resolve:n,create:i,list:()=>[...e.values()]}}class Rn extends Oe{constructor(e,t){super(e),this.control=t}renderDisplay(e){return{element:this.control.render(e)}}renderEditing(e){return this.control.createEditor(e)}}const nt={page(s){return s.page||(s.surface==="cell"?"table":"basic")},render(s,e){const t=V("div","fc-base-control"),n=nt.page(s);return t.dataset.page=n,t.dataset.mode=s.mode||"default",t.dataset.editable=String(s.canEdit??!s.readonly),t.dataset.readonly=String(s.readonly),t.setAttribute("data-field-control",s.field.control||s.field.kind||"text"),t.append(e),t}},cr=new Set(["select","multiSelect","person","multiPerson","relation","multiRelation","cascadeSingle","cascadeMulti","date","dateRange","dateTime","detail","composite","multiPersonComposite"]);function Lt(s){return s.id==="richText"?"rich":cr.has(s.id)?"select":"text"}function ds(s,e,t){if(nt.page(e)==="table"||e.readonly||s.readonly||e.canEdit===!1)return t;const n=document.createElement("div");n.className="fc-base-control fc-focus-editor",n.dataset.expanded="true",n.tabIndex=-1;const i=nt.page(e);n.dataset.page=i,n.dataset.mode=i==="table"?"editing":"expanded",n.dataset.controlKey=s.id,n.dataset.box=Lt(s);const o=document.createElement("div");o.className="fc-focus-body",o.dataset.box=Lt(s),o.append(t.element);const a=document.createElement("div");a.className="fc-focus-trigger",a.tabIndex=0,a.setAttribute("role","button"),a.ariaLabel="编辑"+e.field.label,a.setAttribute("aria-expanded","true"),a.hidden=!0;const l=document.createElement("span");l.className="fc-error fc-focus-error",l.setAttribute("role","status"),n.append(o,a,l);const r=n.ownerDocument,d=e.focusBoundary||n,c=m=>!!m&&(d.contains(m)||Ye(m,n));let p=!1;const h=()=>{p||(o.hidden=!1,a.hidden=!0,n.dataset.expanded="true",n.dataset.mode="editing",a.setAttribute("aria-expanded","true"),l.textContent="",t.focus&&t.focus(),!o.contains(r.activeElement)&&!Ye(r.activeElement,n)&&(Array.from(o.querySelectorAll('input:not([type=hidden]):not(:disabled),textarea:not(:disabled),[contenteditable=true],button:not(:disabled),[tabindex="0"]')).find(y=>!y.closest("[hidden]"))||n).focus())},u=()=>{var C,b,I;if(p||!n.isConnected||n.dataset.expanded==="false")return;const m=(C=t.validate)==null?void 0:C.call(t),y={...e,readonly:!0,canEdit:!1,mode:"default",value:m?e.value:t.read()},x=nt.render(y,s.render(y));x.inert=!0,a.replaceChildren(x),l.textContent=m?"尚未保存:"+m:"",(b=t.deactivate)==null||b.call(t),n.dataset.expanded="false",n.dataset.mode="default",o.hidden=!0,a.hidden=!1,a.setAttribute("aria-expanded","false"),(I=e.onDeactivate)==null||I.call(e)},f=m=>{if(m.relatedTarget instanceof Node&&c(m.relatedTarget))return;const y=m.target;queueMicrotask(()=>{p||!n.isConnected||c(r.activeElement)||(y&&!y.isConnected&&r.activeElement===r.body?n.focus():u())})},g=()=>{queueMicrotask(()=>{!p&&n.isConnected&&n.dataset.expanded==="true"&&(!r.activeElement||r.activeElement===r.body)&&n.focus()})};a.onclick=m=>{m.stopPropagation(),h()},a.onkeydown=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),h())},d.addEventListener("focusout",f),n.addEventListener("click",g,!0),n.addEventListener("fc-collapse",u);const v=Di(r,{contains:(m,y)=>y.composedPath().includes(d)||c(m),leave:u});return{...t,element:n,focus:h,destroy:()=>{var m;p||(p=!0,v(),d.removeEventListener("focusout",f),n.removeEventListener("click",g,!0),n.removeEventListener("fc-collapse",u),(m=t.destroy)==null||m.call(t))}}}function Ln(s){return{...s,context:s,layout:nt.page(s)==="table"?"compact":"form",className:s.surface,services:s.services?{searchOptions:s.services.searchOptions,upload:s.services.upload,vote:s.services.vote?(e,t,n)=>s.services.vote(e,s.item,t,n):void 0}:void 0,onAction:e=>{e.type==="open"&&s.openDetail(String(e.value||s.item.id))}}}function cs(s=[]){const e=ls(),t=new Map;for(const i of e.list()){const o={...i,render(a){const l=e.create(Ln(a));return nt.render(a,l.render().element)},createEditor(a){const l=e.create(Ln(a));return ds(o,a,l.createEditor())}};t.set(i.id,o)}const n=i=>{e.register({...i,create:a=>new Rn(a,{render:l=>i.render({...l.context,field:l.field,value:l.value,readonly:l.readonly}),createEditor:l=>i.createEditor({...l.context,field:l.field,value:l.value,readonly:l.readonly})})});const o={...i,render:a=>nt.render(a,i.render(a)),createEditor(a){const l=new Rn(Ln(a),{render:r=>i.render({...a,value:r.value}),createEditor:r=>i.createEditor({...a,value:r.value})});return ds(i,a,l.createEditor())}};t.set(i.id,o)};return s.forEach(n),{register:n,list:()=>[...t.values()],resolve:i=>t.get(e.resolve(i).id)}}function ur(s,e){const t=e[s.field],n=s.value,i=Array.isArray(t)?t.map(String):t==null||t===""?[]:[String(t)];switch(s.op){case"equals":return Array.isArray(t)?i.includes(String(n)):String(t??"")===String(n??"");case"notEqual":return Array.isArray(t)?!i.includes(String(n)):String(t??"")!==String(n??"");case"contains":return i.some(o=>o.includes(String(n??"")));case"notContains":return!i.some(o=>o.includes(String(n??"")));case"in":return(Array.isArray(n)?n.map(String):[String(n??"")]).some(o=>i.includes(o));case"notIn":return!(Array.isArray(n)?n.map(String):[String(n??"")]).some(o=>i.includes(o));case"blank":return i.length===0;case"notBlank":return i.length>0;default:return!0}}function Be(s,e,t={}){return s?"all"in s?s.all.every(n=>Be(n,e,t)):"any"in s?s.any.some(n=>Be(n,e,t)):"not"in s?!Be(s.not,e,t):ur(s,e):!0}function ot(s,e={}){var t,n,i,o,a,l;return!s||s.all||(t=s.members)!=null&&t.length&&s.members.includes(e.currentUser||"")||(n=s.teams)!=null&&n.length&&(e.teams||[]).some(r=>s.teams.includes(r))||(i=s.roles)!=null&&i.length&&(e.roles||[]).some(r=>s.roles.includes(r))?!0:!((o=s.members)!=null&&o.length||(a=s.teams)!=null&&a.length||(l=s.roles)!=null&&l.length)}const hr={empty:"待填",required:"此项必填",simpleMode:"简洁模式",continuous:"连续创建",cancel:"取消",draft:"存草稿",submit:"确认创建",addRole:"添加角色",addMeeting:"添加一组进入选题会"};function pr(s){return s.items!==void 0}function fr(s,e={}){var Ce;const t=s.variant,n=s.presentation||(t==="create"?"modal":"drawer"),i={...hr,...s.labels},o=e.controls||cs(),a=s.events||{},l={...s.data||{}};let r={...s.context||{}},d=s.fields.map(N=>({...N})),c=(s.tabs||[]).map(N=>({...N})),p=s.items?[...s.items]:d.map(N=>({field:N.key})),h=s.blocks?[...s.blocks]:[],u=s.actions?[...s.actions]:C();const f=t==="create"?"new":"detail";let g=s.fieldState||"display",v=s.simpleMode??!1;const m=s.simpleKeep&&s.simpleKeep.length?new Set(s.simpleKeep):new Set(d.slice(0,1).map(N=>N.key));let y=s.open??!0,x=!1;function C(){return t==="create"?[{id:"continuous",kind:"checkbox",label:i.continuous},{id:"close-overlay",label:i.cancel,variant:"outline"},{id:"save-draft",label:i.draft,variant:"outline"},{id:"submit",kind:"submit",label:i.submit,variant:"primary"}]:[]}const b=N=>d.find(K=>K.key===N);function I(N,K,pe){var B,q,Z;const le=Be(N.visibleWhen,l,r)&&ot((B=N.permission)==null?void 0:B.view,r)&&(!K||Be(K.visibleWhen,l,r))&&(!pe||Be(pe.visibleWhen,l,r)&&ot(pe.visibleScope,r))&&(t!=="create"||N.createVisible!==!1),Se=!!N.required||(N.requiredWhen?Be(N.requiredWhen,l,r):!1)||(K!=null&&K.requiredWhen?Be(K.requiredWhen,l,r):!1)||((q=N.permission)!=null&&q.required?ot(N.permission.required,r):!1),F=N.editable!==!1&&ot((Z=N.permission)==null?void 0:Z.edit,r);return{visible:le,required:!!Se,editable:F}}function A(N){if(l[N.key]===void 0&&(N.defaultMode==="always"&&N.defaultValue!==void 0&&(l[N.key]=N.defaultValue),N.defaultMode==="conditional")){for(const K of N.defaultWhen||[])if(Be(K.when,l,r)){l[N.key]=K.value;return}}}const S=document.createElement(t==="create"?"form":"article");t==="create"&&(S.noValidate=!0);const G=$e(S,"form-surface",s);S.className=t==="create"?"rowvia-work-items rowvia-field-scope create-dialog form-surface":`rowvia-work-items rowvia-field-scope drawer form-surface${n==="fullscreen"?" is-fullscreen":""}`,S.dataset.variant=t,S.dataset.presentation=n,S.dataset.fieldState=g;let E=[];function k(){var Se,F,B,q,Z,ne;for(const Q of E)Q.destroy();E=[],S.innerHTML="";const N=document.createElement("div");if(N.className="drawer-header",(Se=s.slots)!=null&&Se.leading){const Q=document.createElement("div");Q.className="drawer-leading",T(Q,s.slots.leading),N.append(Q)}if(N.insertAdjacentHTML("beforeend",`<span class="page-logo">${Me("check")}</span><strong>${D(s.title||"")}</strong>`),(F=s.slots)!=null&&F.header&&T(N,s.slots.header),S.append(N),(B=s.slots)!=null&&B.subHeader){const Q=document.createElement("div");Q.className="detail-sub-header",T(Q,s.slots.subHeader),S.append(Q)}if((q=s.slots)!=null&&q.navigation){const Q=document.createElement("div");Q.className="detail-navigation",T(Q,s.slots.navigation),S.append(Q)}const K=R();if(t==="detail"&&K.length){const Q=document.createElement("div");Q.className="detail-tabs",Q.setAttribute("role","tablist");for(const te of K){const J=document.createElement("button");J.type="button",J.className=`detail-tab${te.id===O?" active":""}`,J.dataset.tabId=te.id,J.dataset.detailTab=te.label,J.setAttribute("role","tab"),J.setAttribute("aria-selected",String(te.id===O)),J.textContent=te.label,J.onclick=()=>z(te.id),Q.append(J)}const oe=document.createElement("div");oe.className="spacer",Q.append(oe),(Z=s.slots)!=null&&Z.tabSuffix&&T(Q,s.slots.tabSuffix),S.append(Q)}const pe=document.createElement("div");pe.className=t==="create"?"create-body":"drawer-body",t==="create"&&s.simpleMode!==void 0&&pe.append(H());const le=K.find(Q=>Q.id===O);if(pe.append(L(le)),S.append(pe),(ne=s.slots)!=null&&ne.footer){const Q=document.createElement("div");Q.className="form-surface-slot-footer",T(Q,s.slots.footer),S.append(Q)}u.length&&S.append(W()),t==="create"&&(S.onsubmit=Q=>{var te,J;if(Q.preventDefault(),x)return;const oe=xe();if(oe){(te=a.onInvalid)==null||te.call(a,oe);return}(J=a.onSubmit)==null||J.call(a,ve())})}function T(N,K){typeof K=="string"?N.insertAdjacentHTML("beforeend",K):N.append(K)}function H(){const N=document.createElement("div");return N.className="simple-mode",N.innerHTML=`<label><input type="checkbox" id="simple-mode"${v?" checked":""}>${D(i.simpleMode)}</label>`,N.querySelector("input").onchange=K=>j(K.target.checked),N}function W(){const N=document.createElement("div");N.className=t==="create"?"drawer-footer":"drawer-footer form-surface-actions";for(const K of u){if(!Be(K.visibleWhen,l,r))continue;if(K.kind==="checkbox"){const le=document.createElement("label");le.className="continuous",le.innerHTML=`<input id="${D(K.id)}" type="checkbox"${K.checked?" checked":""}>${D(K.label||"")}`,N.append(le);continue}if(K.kind==="submit"){const le=document.createElement("button");le.type="submit",le.className=K.variant||"primary",le.dataset.action=K.id,le.textContent=K.label||i.submit,N.append(le);continue}N.insertAdjacentHTML("beforeend",Te(K.id,K.label||"",K.glyph||"",K.variant||""));const pe=N.lastElementChild;pe.onclick=()=>{var le;x||N.parentElement!==S||pe.disabled||((K.id==="close-overlay"||K.id==="cancel")&&a.onCancel?a.onCancel():K.id==="save-draft"&&a.onSaveDraft?a.onSaveDraft(ve()):(le=a.onAction)==null||le.call(a,K.id,ve()))}}return N}function R(){return c.filter(K=>Be(K.visibleWhen,l,r)&&ot(K.visibleScope,r)).map((K,pe)=>({...K,order:K.order??pe})).sort((K,pe)=>K.order-pe.order)}let O=s.defaultTab||((Ce=c[0])==null?void 0:Ce.id);function L(N){var F;const K={data:l,context:r,variant:t,tab:N},pe=document.createElement("div");if(pe.className=t==="create"?"form-surface-body":"detail-fields form-surface-body",!N||N.kind==="form"){const B=(N==null?void 0:N.items)??p;for(const Z of B){const ne=M(Z,K);ne&&pe.append(ne)}const q=(N==null?void 0:N.blocks)??h;for(const Z of q){const ne=U(Z,K);ne&&pe.append(ne)}return pe}const le=N.kind==="custom"?N.render:((F=e.renderers)==null?void 0:F[N.kind])||N.render,Se=le?le(K):"";return typeof Se=="string"?pe.innerHTML=Se:Se&&pe.append(Se),pe}function M(N,K){if("field"in N)return _(N);const pe=pr(N)?$(N,K):U(N,K);return pe&&N.span!==1&&(pe.style.gridColumn="1 / -1"),pe}function $(N,K){var F;const pe=Be(N.visibleWhen,l,r),le=[];for(const B of N.items){const q=M(B,K);q&&le.push(q)}if(!pe||!le.length)return null;const Se=document.createElement("section");if(Se.className="form-group",Se.dataset.group=N.id,N.columns===2&&!v){const B=(F=N.columnRatio)!=null&&F.every(q=>Number.isFinite(q)&&q>0)?N.columnRatio:[1,1];Se.style.display="grid",Se.style.gridTemplateColumns=B.map(q=>`minmax(0, ${q}fr)`).join(" "),Se.style.columnGap="24px"}return Se.innerHTML=`<p class="form-group-title">${D(N.label)}</p>`,Se.firstElementChild.style.gridColumn="1 / -1",Se.append(...le),Se}function _(N){var Z;const K=b(N.field);if(!K)return null;const pe=I(K,N,ae());if(!pe.visible||v&&!m.has(K.key))return null;A(K);const le=document.createElement("div");le.className=t==="create"?"create-field":"detail-row",le.dataset.field=K.key,N.span===2&&(le.classList.add("span-2"),le.style.gridColumn="1 / -1"),(N.labelPosition||((Z=s.layout)==null?void 0:Z.labelPosition)||"side")==="top"&&le.classList.add("label-top");const F=pe.required,B=t==="create"?"<em>*</em>":" *";le.innerHTML=`<label for="${f}-${D(K.key)}">${D(K.label)}${F?B:""}</label><div class="field-value"><div class="fc-host" data-control-field="${D(K.key)}" data-control-mode="${t}"></div>`+(K.description?`<small class="field-description">${D(K.description)}</small>`:"")+"</div>";const q=le.querySelector(".fc-host");return be(q,{...K,required:F},F),le}function U(N,K){var Se;if(!Be(N.visibleWhen,l,r)||v&&!m.has(N.id))return null;const pe=(Se=e.renderers)!=null&&Se.block?e.renderers.block({...K,block:N}):N.render?N.render(K):ee(N,K),le=document.createElement("div");return le.className=`form-surface-block block-${N.kind}`,le.dataset.block=N.id,typeof pe=="string"?le.innerHTML=pe:pe&&le.append(pe),le}function ee(N,K){var pe,le;if(N.kind==="roles"){const Se=document.createElement("div");Se.className=t==="create"?"create-field":"detail-row",Se.innerHTML=`<label>${D(N.label||"角色与人员")}${(pe=N.requiredRoles)!=null&&pe.length?"<em>*</em>":""}</label><div class="role-body"><div class="role-rows"></div><div class="role-actions">${Te("add-role",i.addRole,"","outline")}</div></div>`;const F=Se.querySelector(".role-rows"),B=(le=N.roleOptions)!=null&&le.length?N.roleOptions:["提报人"],q=N.people??[],Z=()=>{const oe=Array.isArray(l.roles)?l.roles:[];return oe.length||oe.push({name:B[0],person:String(l.owner??K.context.currentUser??"")}),l.roles=oe,oe};let ne=[];const Q=()=>{for(const te of ne)te.destroy(),E=E.filter(J=>J!==te);ne=[],F.replaceChildren();const oe=Z();oe.forEach((te,J)=>{const ie=document.createElement("div");ie.className="role-line";const se=document.createElement("div");se.className="fc-host role-select";const de=document.createElement("div");if(de.className="fc-host role-person",ie.append(se,de),oe.length>1){const ue=document.createElement("button");ue.type="button",ue.className="role-remove",ue.dataset.roleRemove=String(J),ue.setAttribute("aria-label","移除角色"),ue.textContent="×",ie.append(ue)}F.append(ie),ne.push(be(se,{key:`role-${J}`,label:"角色",kind:"select",options:B,editable:!0},!1,{get:()=>te.name,set:ue=>{te.name=String(ue??"")},notify:()=>{var ue;return(ue=a.onCommit)==null?void 0:ue.call(a,"roles",Z(),l)}}),be(de,{key:`role-person-${J}`,label:"人员",kind:"person",options:q.map(ue=>ue.id),choices:q,editable:!0},()=>{var ue;return!!((ue=N.requiredRoles)!=null&&ue.includes(te.name))},{get:()=>te.person,set:ue=>{te.person=String(ue??"")},notify:()=>{var ue,ke;J===0&&(l.owner=te.person,(ue=a.onCommit)==null||ue.call(a,"owner",te.person,l)),(ke=a.onCommit)==null||ke.call(a,"roles",Z(),l)}}))})};return Q(),Se.addEventListener("click",oe=>{var ie,se,de;const te=oe.target,J=te.closest("[data-role-remove]");if(J){const ue=Z();ue.splice(Number(J.dataset.roleRemove),1),ue.length||ue.push({name:B[0],person:""}),l.owner=((ie=ue[0])==null?void 0:ie.person)??"",Q(),(se=a.onChange)==null||se.call(a,"roles",ue,l);return}if(te.closest('[data-action="add-role"]')){const ue=Z();ue.push({name:B.find(ke=>!ue.some(ge=>ge.name===ke))??B[0],person:""}),Q(),(de=a.onChange)==null||de.call(a,"roles",ue,l)}}),Se}if(N.kind==="meetings"){const Se=document.createElement("section");return Se.className="detail-section",Se.innerHTML=`<p>${D(N.label||"进入选题会")}</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${Te("add-meeting",i.addMeeting,"add")}</div>`,Se}return""}function ae(){return R().find(N=>N.id===O)}function he(N,K,pe){return{field:N,value:pe?pe.get():l[N.key]??N.defaultValue??"",item:l,surface:t==="create"?"create":"detail",page:"basic",mode:"default",canEdit:K,readonly:!K,services:e.services,onSelectedOptions:Se=>{(B=>{B.choices=[...new Map([...B.choices||(B.options||[]).map(q=>({id:q,label:q})),...Se].map(q=>[q.id,q])).values()]})(N)},openDetail:Se=>{var F;return(F=a.onOpenDetail)==null?void 0:F.call(a,Se)}}}function be(N,K,pe,le){var hs;const Se=()=>typeof pe=="function"?pe():pe,F=K.editable!==!1&&ot((hs=K.permission)==null?void 0:hs.edit,r),B=he(K,F,le),q=o.resolve(K),Z=q.createEditor(B),ne="input,select,textarea,[role=textbox]",Q=[Z.content,Z.element].filter(we=>!!we).map(we=>we.matches(ne)?we:we.querySelector(ne)).find(Boolean);Q&&(Q.id=`${f}-${K.key}`);const oe=document.createElement("div");oe.className="fc-error",oe.setAttribute("role","status");const te=document.createElement("div");te.className="fc-detail-editor",te.dataset.mode="editing",te.dataset.box=Lt(q),te.append(Z.element),N.classList.add("fc-detail-host"),N.dataset.page="basic",N.dataset.mode="default",N.dataset.surface=t==="create"?"create":"detail",N.append(te,oe);const J=document.createElement("div");J.className="fc-detail-preview",J.dataset.box=Lt(q),J.dataset.editable=String(F),J.dataset.surface=t==="create"?"create":"detail",N.prepend(J);const ie=()=>{if(!N.classList.contains("editing")){N.style.minHeight="";return}N.style.minHeight=`${te.offsetHeight}px`},se=we=>{te.style.minHeight=`${we}px`,te.style.maxHeight=`${we}px`},de=()=>{te.style.maxHeight="",ie()},ue=Lt(q)==="rich",ke=()=>{var Ne,Tt;if(!F||N.classList.contains("editing"))return;const we=J.offsetHeight;N.classList.add("editing"),N.dataset.mode="editing",ue||se(we),ie(),(Ne=Z.focus)==null||Ne.call(Z),(Tt=a.onFieldStateChange)==null||Tt.call(a,K.key,"edit")},ge=()=>{if(J.replaceChildren(q.render({...he(K,F,le),readonly:!0,canEdit:!1,mode:"default",value:le?le.get():l[K.key]??""})),J.dataset.box==="select"){const we=document.createElement("span");we.className="fc-field-chevron",we.setAttribute("aria-hidden","true"),J.append(we)}if(F){J.tabIndex=0,J.setAttribute("role","button"),J.setAttribute("aria-label",`编辑${K.label}`),J.onclick=Ne=>{Ne.target.closest("a,button,input,textarea,select")||ke()},J.onkeydown=Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),ke())};const we=document.createElement("button");we.type="button",we.className="fc-detail-edit",we.tabIndex=-1,we.textContent="编辑",we.ariaLabel=`编辑${K.label}`,we.onclick=Ne=>{Ne.stopPropagation(),ke()},J.append(we)}else J.removeAttribute("role"),J.removeAttribute("tabindex"),J.onclick=null,J.onkeydown=null};ge();const ce=()=>{var Ne;const we=Se()&&!fe(Z.read())?i.required:(Ne=Z.validate)==null?void 0:Ne.call(Z);return oe.textContent=we||"",N.classList.toggle("is-error",!!we),we},Le=()=>{var Ne,Tt,ps;if(!F)return!0;const we=ce();if(we&&de(),!we){const vt=Z.read(),yr=le?le.get():l[K.key];JSON.stringify(yr)!==JSON.stringify(vt)&&(le?(le.set(vt),(Ne=le.notify)==null||Ne.call(le,vt)):(l[K.key]=vt,(Tt=a.onCommit)==null||Tt.call(a,K.key,vt,l))),(ps=a.onChange)==null||ps.call(a,K.key,vt,l),ge()}return!we},Wt=()=>{var we;N.classList.remove("editing"),N.dataset.mode="default",N.style.minHeight="",te.style.minHeight="",te.style.maxHeight="",(we=a.onFieldStateChange)==null||we.call(a,K.key,"display")};N.addEventListener("input",()=>{var we;de(),(we=a.onChange)==null||we.call(a,K.key,Z.read(),l)}),N.addEventListener("pointerdown",()=>{N.classList.contains("editing")&&de()},!0),N.addEventListener("mousedown",we=>{var Ne;q.id!=="richText"||!N.classList.contains("editing")||we.target.closest("button,a,input,textarea,select,[contenteditable=true]")||(we.preventDefault(),!N.contains(document.activeElement)&&!Ye(document.activeElement,N)&&((Ne=Z.focus)==null||Ne.call(Z)))}),N.addEventListener("change",()=>{de(),Le()}),N.addEventListener("fc-collapse",()=>{Le(),Wt(),ge()}),N.addEventListener("focusout",we=>{we.relatedTarget instanceof Node&&(N.contains(we.relatedTarget)||Ye(we.relatedTarget,N))||queueMicrotask(()=>{if(!(x||!N.isConnected)){if(N.contains(document.activeElement)||Ye(document.activeElement,N)){ie();return}Le(),Wt(),ge()}})}),(K.defaultState||g)==="edit"&&F&&queueMicrotask(()=>{x||ke()});const us={key:K.key,host:N,editor:Z,editable:F,check:ce,commit:Le,beginEdit:ke,write:we=>{le?le.set(we):l[K.key]=we},destroy:()=>{var we;return(we=Z.destroy)==null?void 0:we.call(Z)}};return E.push(us),us}const fe=N=>Array.isArray(N)?N.length>0:N!=null&&String(N).trim()!=="";function ve(){for(const N of E)N.editable&&N.write(N.editor.read());return{...l}}function xe(){let N;for(const K of E){if(!K.editable)continue;const pe=K.check();pe&&N===void 0&&(N=pe,K.beginEdit())}return N}function me(N){y=N,S.hidden=!N,S.dataset.open=String(N)}function P(N){g=N,S.dataset.fieldState=N;for(const K of E)N==="edit"?K.beginEdit():K.host.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))}function z(N){var pe;if(N===O||!R().some(le=>le.id===N))return;O=N;const K=ae();k(),K&&((pe=a.onTabChange)==null||pe.call(a,N,K))}function j(N){ve(),v=N,k()}function Y(N){N.data&&Object.assign(l,N.data),N.fields&&(d=N.fields.map(K=>({...K}))),N.tabs&&(c=N.tabs.map(K=>({...K}))),N.items&&(p=[...N.items]),N.blocks&&(h=[...N.blocks]),N.actions&&(u=[...N.actions]),N.context&&(r={...N.context}),k()}function re(){var N;if(!x){x=!0,(N=a.onDestroy)==null||N.call(a),G.destroy(),S.onsubmit=null;for(const K of E)K.destroy();E=[],S.remove()}}return k(),me(y),{element:S,onInteraction:G.onInteraction,read:ve,validate:xe,setOpen:me,setFieldState:P,setTab:z,setSimpleMode:j,activeTab:()=>O,update:Y,destroy:re}}function gr(s){const e=V("div",s.className??"tag");return s.marker?e.append(s.marker):s.markerClassName&&e.append(V("span",s.markerClassName)),e.append(V("span","",s.label)),e}function mr(s){const e=V("div",s.className);if(s.leading)e.append(s.leading);else if(s.image){const n=V("img");n.src=s.image.src,n.alt=s.image.alt,e.append(n)}const t=s.inline?e:V("div",s.contentClassName);return t.append(V(s.titleTag??"span",s.titleClassName,s.title)),s.description!==void 0&&t.append(V(s.descriptionTag??"span",s.descriptionClassName,s.description)),s.inline||e.append(t),e}function vr(s,e){Dt[s]=e}function wr(s,e){Je[s]=e}X.ActionField=as,X.AttachmentField=ns,X.BaseField=Oe,X.BaseFieldControl=nt,X.CELL_EDITORS=Je,X.CELL_RENDERERS=Dt,X.COMPLETION_LABEL=oi,X.CascadeField=En,X.ChoiceField=gt,X.CompositeField=rs,X.ComputedField=mt,X.CustomField=Rn,X.DEFAULT_LOCALE_TEXT=Bn,X.DateField=kn,X.DateRangeField=es,X.DateTimeField=xn,X.EmailField=ji,X.FORMULA_FUNCTIONS=It,X.GANTT_UNITS=Jn,X.GanttChart=ni,X.Grid=lt,X.LinkField=bn,X.LocationField=is,X.MultiCascadeField=Ji,X.MultiChoiceField=Yi,X.MultiPersonField=Zi,X.MultiRelationField=Qi,X.MultiVoteField=os,X.NumberField=_i,X.PersonField=Cn,X.PhoneField=Ki,X.RadioField=Xi,X.RelationField=Sn,X.RichTextField=Wi,X.STATUS_META=ut,X.SignalField=Mn,X.SingleVoteField=ss,X.SwitchField=ts,X.TextField=Xe,X.TextareaField=Ui,X.UNIT_LABEL=Ht,X.VoteField=_t,X.adaptOperationRecords=$a,X.allGatesMet=ai,X.computeStickyGroupRows=Yn,X.createControlRegistry=cs,X.createDetailComments=Aa,X.createDetailDialog=Zn,X.createDetailHistory=Ha,X.createFieldRegistry=ls,X.createFlowCanvas=ci,X.createFlowContextBar=pi,X.createGantt=oa,X.createGrid=Xn,X.createMediaCell=mr,X.createNodeCard=ui,X.createNodeFlow=va,X.createNodeTimeline=fi,X.createPersonnelSchedule=Sa,X.createSparklineSvg=Xt,X.createTagCell=gr,X.createWorkItemColumnPanels=_a,X.createWorkItemColumns=za,X.createWorkItemDetailHeader=Ka,X.createWorkItemFormSurface=fr,X.createWorkItemHeaderDecorator=Wa,X.createWorkItemLayers=Ya,X.createWorkItemRulePanels=Ua,X.createWorkItemSelectionBar=Ga,X.createWorkItemTable=qa,X.createWorkItemTabs=Ba,X.createWorkItemToolbar=Va,X.createWorkflowDetail=Ma,X.default=lt,X.emptyView=Oa,X.escapeHtml=D,X.evalFormCondition=Be,X.evalFormScope=ot,X.evaluateFormula=bt,X.evaluateGates=nn,X.formatNumberCommas=_e,X.groupNodes=li,X.historyModules=un,X.isFormula=Kt,X.matchNodes=sn,X.matches=$i,X.normalizeHistory=Ii,X.parse=In,X.queryHistory=Ai,X.registerEditor=wr,X.registerFormulaFunction=ws,X.registerRenderer=vr,X.renderContent=wn,X.sanitizeRichText=pt,X.showTip=hi,X.summarize=ri,X.tokenize=Tn,X.videoFlow=ya,Object.defineProperties(X,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
104
+ <button type="button" class="color-swatch" data-color="${I}" style="background-color:${D(N.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
105
+ <button type="button" class="field-select" data-color-scope="${I}" aria-label="着色范围" aria-expanded="false">${!N.scope||N.scope==="row"?"整行":"单元格"}${Re("down")}</button>
106
+ <button class="field-select ${E?"":"empty"}" data-pick="${I}">${D(E||"请选择筛选项")}${Re("down")}</button>
107
+ ${Wt(G,N.field?N.operator:"",`data-operator="${I}" aria-label="运算符" ${N.field?"":"disabled"}`)}
108
+ ${T}
109
+ <button class="color-remove" data-remove="${I}" aria-label="删除条件" title="删除条件">${Re("close")}</button>
110
+ <div class="color-more-wrap"><button class="color-more" data-color-more="${I}" aria-label="更多条件操作" aria-expanded="false">${Re("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${I}">复制条件</button><button data-color-up="${I}" ${I===0?"disabled":""}>上移</button><button data-color-down="${I}" ${I===u.colors.length-1?"disabled":""}>下移</button></div></div>
111
+ </div>`}).join(""),g=l(h,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${f}</div><div class="color-panel-footer"><button class="add-condition">${Re("plus")}添加着色条件</button><button class="clear-rules" ${u.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");g.ariaLabel="设置颜色条件",s.setActiveRulePanel("color");const v=()=>c(h),m=()=>{r(),v()},w=["#ffe5e5","#ffe7d4","#f9e8d2","#fff5d6","#ecf3d3","#daf2d5","#d6f1ec","#d4efff","#e4eaff","#ebe9fe","#f2e8ff","#f7e4fb","#ffe3f2","#ffc8c8","#ffceaa","#f3d3a4","#ffeaa5","#d9e8a7","#b6e4af","#ace4db","#acdffc","#c9d8ff","#d7d5fb","#e3d0ff","#efc9f5","#fbc5e7"],k=()=>{var N;(N=g.querySelector(".color-palette"))==null||N.remove(),g.querySelectorAll("[data-color]").forEach(I=>I.setAttribute("aria-expanded","false"))},C=()=>{var N,I,E;(N=g.querySelector(".color-scope-picker"))==null||N.remove(),(E=(I=s.getPopupEditor())==null?void 0:I.destroy)==null||E.call(I),s.setPopupEditor(null),g.querySelectorAll("[data-color-scope]").forEach(G=>G.setAttribute("aria-expanded","false"))};let b=-1;g.querySelectorAll(".color-condition").forEach((N,I)=>{N.ondragstart=E=>{var G;b=I,(G=E.dataTransfer)==null||G.setData("text/plain",String(I))},N.ondragover=E=>E.preventDefault(),N.ondrop=E=>{if(E.preventDefault(),b<0||b===I)return;const[G]=u.colors.splice(b,1);u.colors.splice(I,0,G),m()}}),g.onclick=N=>{var G,x,T;N.stopPropagation();const I=N.target.closest("button");if(N.target.closest(".color-scope-picker"))return;const E=(I==null?void 0:I.getAttribute("aria-expanded"))==="true";if(C(),!I||I.disabled){k();return}if(I.dataset.colorScope!==void 0){if(k(),E)return;const A=Number(I.dataset.colorScope),H=u.colors[A],q={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},R=i.resolve(q).createEditor({field:q,value:!H.scope||H.scope==="row"?"整行":"单元格",item:o(),surface:"cell",readonly:!1,openDetail:()=>{}});s.setPopupEditor(R);const P=document.createElement("div");P.className="popup fc-popup fc-choice-popup color-scope-picker",P.style.width="272px",P.append(R.element),g.append(P);const L=I.getBoundingClientRect();P.style.left=`${Math.max(8,Math.min(L.left,innerWidth-280))}px`,P.style.top=`${Math.max(8,Math.min(L.bottom+6,innerHeight-P.offsetHeight-8))}px`,I.setAttribute("aria-expanded","true"),R.element.addEventListener("change",M=>{var $,z,j;M.stopPropagation(),!(($=R.validate)!=null&&$.call(R))&&(H.scope=R.read()==="整行"?"row":"cell",m(),(j=(z=s.popup())==null?void 0:z.querySelector(`[data-color-scope="${A}"]`))==null||j.focus())}),P.onkeydown=M=>{M.key==="Escape"&&(M.stopPropagation(),C(),I.focus())},(G=R.focus)==null||G.call(R);return}if(I.dataset.paletteColor!==void 0){const A=Number(I.closest(".color-palette").dataset.ruleIndex);u.colors[A].color=I.dataset.paletteColor,m(),(T=(x=s.popup())==null?void 0:x.querySelector(`[data-color="${A}"]`))==null||T.focus();return}if(I.dataset.color!==void 0){const A=I.getAttribute("aria-expanded")==="true";if(k(),A)return;const H=Number(I.dataset.color),q=document.createElement("div");q.className="color-palette",q.dataset.ruleIndex=String(H),q.setAttribute("role","group"),q.ariaLabel="选择着色颜色",q.innerHTML=w.map(P=>`<button type="button" class="color-palette-option" data-palette-color="${P}" style="background-color:${P}" aria-label="颜色 ${P}" aria-pressed="${P===u.colors[H].color.toLowerCase()}"></button>`).join(""),g.append(q);const R=I.getBoundingClientRect();q.style.left=`${Math.max(8,Math.min(R.left,innerWidth-q.offsetWidth-8))}px`,q.style.top=`${Math.max(8,Math.min(R.bottom+6,innerHeight-q.offsetHeight-8))}px`,I.setAttribute("aria-expanded","true"),q.onkeydown=P=>{P.key==="Escape"&&(P.stopPropagation(),k(),I.focus())};return}if(k(),I.classList.contains("add-condition"))u.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),m();else if(I.dataset.pick!==void 0){const A=+I.dataset.pick;a(I,H=>{u.colors[A].field=H,u.colors[A].value="",u.colors[A].operator="contains",m()})}else if(I.dataset.remove!==void 0)u.colors.splice(+I.dataset.remove,1),m();else if(I.classList.contains("clear-rules"))u.colors=[],m();else if(I.dataset.colorMore!==void 0){const A=I.nextElementSibling,H=A.classList.contains("hidden");g.querySelectorAll(".color-rule-menu").forEach(q=>q.classList.add("hidden")),g.querySelectorAll("[data-color-more]").forEach(q=>q.setAttribute("aria-expanded","false")),A.classList.toggle("hidden",!H),I.setAttribute("aria-expanded",String(H))}else if(I.dataset.colorCopy!==void 0){const A=+I.dataset.colorCopy;u.colors.splice(A+1,0,structuredClone(u.colors[A])),m()}else if(I.dataset.colorUp!==void 0||I.dataset.colorDown!==void 0){const A=Number(I.dataset.colorUp??I.dataset.colorDown),[H]=u.colors.splice(A,1);u.colors.splice(A+(I.dataset.colorUp!==void 0?-1:1),0,H),m()}},g.onchange=N=>{const I=N.target;if(I.dataset.operator!==void 0){u.colors[+I.dataset.operator].operator=I.value,m();return}I.dataset.ruleValue!==void 0&&(u.colors[+I.dataset.ruleValue].value=I.value),r()},g.oninput=N=>{const I=N.target;if(I.dataset.ruleValue!==void 0)u.colors[+I.dataset.ruleValue].value=I.value;else return;r()}}function p(h,u){if(h==="color"){c(u);return}const f=s.view(),g={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[h],v=h==="filter"?f.filters:h==="sort"?f.sorts:h==="group"?f.groups:f.colors,m=v.map((b,N)=>{var A;const I=h==="sort"?b.colId:h==="group"?b:b.field,E=((A=e.find(([H])=>H===I))==null?void 0:A[1])||I,G=`<button class="field-select" data-pick="${N}">${D(E)}${Re("down")}</button>`;if(h==="sort")return`<div class="condition">${G}<button class="sort-direction ${b.sort==="asc"?"selected":""}" data-dir="asc" data-index="${N}">首项 → 末项</button><button class="sort-direction ${b.sort==="desc"?"selected":""}" data-dir="desc" data-index="${N}">末项 → 首项</button><button data-remove="${N}" aria-label="删除条件">${Re("close")}</button></div>`;if(h==="group")return`<div class="condition">${G}<span class="spacer"></span><button data-remove="${N}" aria-label="删除条件">${Re("close")}</button></div>`;const x=Wt([["contains",n[I]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],b.operator,`data-operator="${N}" aria-label="运算符"`),T=["blank","notBlank"].includes(b.operator)?"":n[I]?Wt([["","请选择目标值"],...n[I].map(H=>[H,H])],b.value,`data-rule-value="${N}" aria-label="目标值"`):`<input data-rule-value="${N}" aria-label="目标值" value="${D(b.value)}" placeholder="请选择目标值">`;return`<div class="condition">${G}${x}${T}${h==="color"?`<input type="color" data-color="${N}" value="${b.color}" aria-label="行颜色">`:""}<button data-remove="${N}" aria-label="删除条件">${Re("close")}</button></div>`}).join(""),w=l(u,`设置${g}条件`,`${h==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${f.showTerminated?"checked":""}>显示已终止数据</label>`:""}${m}<button class="add-condition">${Re("plus")}添加${h==="color"?"着色":g}条件</button>${v.length?'<button class="clear-rules">清空全部条件</button>':""}`,h==="color"?650:560);s.setActiveRulePanel(h);const k=()=>p(h,u);let C=-1;w.querySelectorAll(".condition").forEach((b,N)=>{b.draggable=!0,b.ondragstart=I=>{var E;C=N,(E=I.dataTransfer)==null||E.setData("text/plain",String(N))},b.ondragover=I=>I.preventDefault(),b.ondrop=I=>{if(I.preventDefault(),C<0||C===N)return;const[E]=v.splice(C,1);v.splice(N,0,E),r(),k()}}),w.onclick=b=>{const N=b.target.closest("button");N&&(N.classList.contains("add-condition")&&a(N,I=>{h==="filter"&&f.filters.push({field:I,operator:"contains",value:""}),h==="sort"&&f.sorts.push({colId:I,sort:"asc"}),h==="group"&&!f.groups.includes(I)&&f.groups.push(I),h==="color"&&f.colors.push({field:I,operator:"contains",value:"",color:"#e9f2ff"}),r(),k()}),N.dataset.pick!==void 0&&a(N,I=>{const E=+N.dataset.pick;h==="sort"?f.sorts[E].colId=I:h==="group"?f.groups[E]=I:(v[E].field=I,v[E].value=""),r(),k()}),N.dataset.remove!==void 0&&(v.splice(+N.dataset.remove,1),r(),k()),N.classList.contains("clear-rules")&&(v.splice(0),r(),k()),N.dataset.dir&&(f.sorts[+N.dataset.index].sort=N.dataset.dir,r(),k()))},w.onchange=b=>{const N=b.target;N.id==="terminated"&&(f.showTerminated=N.checked),N.dataset.operator!==void 0&&(v[+N.dataset.operator].operator=N.value,k()),N.dataset.ruleValue!==void 0&&(v[+N.dataset.ruleValue].value=N.value),N.dataset.color!==void 0&&(f.colors[+N.dataset.color].color=N.value),r()},w.oninput=b=>{const N=b.target;N.tagName==="INPUT"&&N.dataset.ruleValue!==void 0&&(v[+N.dataset.ruleValue].value=N.value,r())}}return{colorRuleMatches:d,colorPanel:c,rulePanel:p}}function Xa(s={}){var d;const e=document.createElement("section");e.className="rowvia-work-items detail-header-surface";const t=document.createElement("div");t.className="detail-meta-row";const n=s.tags??[];t.innerHTML=`${n.map(c=>`<span class="detail-meta-tag">${D(c)}</span>`).join("")}<button type="button" class="detail-meta-add" data-detail-action="add-tag" aria-label="添加标签">${Re("add")}</button><span class="detail-meta-divider"></span>${(s.signals||[]).map(c=>`<button type="button" class="detail-signal${c.checked?" checked":""}" data-detail-action="toggle-signal"><span class="detail-signal-dot">${c.checked?"✓":""}</span>${D(c.label)}</button>`).join("")}`,e.append(t);const i=s.stages??[],o=s.activeStage||((d=i.find(c=>c.state==="active"))==null?void 0:d.id),a=document.createElement("div");a.className="detail-process-strip",a.setAttribute("aria-label","工作项流程"),a.innerHTML=i.map((c,p)=>`<div class="detail-stage-wrap"><button type="button" class="detail-stage ${c.id===o?"active":""} ${c.state||""}" data-detail-action="stage" data-stage="${D(c.id)}"><span class="detail-stage-dot"></span>${D(c.label)}</button>${p<i.length-1?'<span class="detail-stage-line"></span>':""}</div>`).join(""),e.append(a);const l=document.createElement("div");l.className="detail-stage-card";const r=i.find(c=>c.id===o)||i[0];return r&&(l.innerHTML=`<div class="detail-stage-card-head"><div><span class="detail-stage-chevron">⌄</span><span class="detail-stage-card-dot ${r.state||""}"></span><strong>${D(r.label)}</strong><span class="detail-stage-status">进行中</span></div><div class="detail-stage-card-actions"><button type="button" class="primary" data-detail-action="complete-stage">完成</button><button type="button" class="icon-button" data-detail-action="stage-more" aria-label="节点更多">${Re("more")}</button></div></div><div class="detail-stage-card-body"><span>负责人</span><strong>${D(s.owner||"待填")}</strong></div><div class="detail-dependency"><span>⌄</span> 依赖项</div>`),r&&e.append(l),e.onclick=c=>{var u;const p=c.target.closest("[data-detail-action]");if(!p)return;const h=p.dataset.detailAction||"";(u=s.onAction)==null||u.call(s,h),e.dispatchEvent(new CustomEvent("rowvia:detail-action",{detail:{action:h,stage:p.dataset.stage},bubbles:!0}))},e}function Za(s={}){const e=Xa(s),t=De(e,"work-item-detail-header",s);return{element:e,onInteraction:t.onInteraction,destroy(){t.destroy(),e.onclick=null,e.remove()}}}function Qa(s,e={}){const t=document.createElement("div");t.className="rowvia-work-items rowvia-field-scope",t.style.display="contents",s.append(t);const n=new Ke,i=De(t,"work-item-layers",e);let o=null,a=null,l=null,r,d=null;const c=(u,f,g)=>{var v,m;u==="open"?(v=e.onOpen)==null||v.call(e,f,g):(m=e.onClose)==null||m.call(e,f),t.dispatchEvent(new CustomEvent(`rowvia:layer-${u}`,{detail:{kind:f,element:g},bubbles:!0}))};function p(){o&&(o.remove(),o=null,c("close","popup"))}function h(){a&&(a.remove(),a=null,l==null||l.focus(),l=null,c("close","overlay"))}return n.listen(t,"click",u=>{var m;const f=u.target,g=(m=f.closest("[data-action]"))==null?void 0:m.dataset.action,v=g==="close-popup"?"popup":g==="close-overlay"||f===a?"overlay":void 0;v&&(u.stopPropagation(),e.onCloseRequest?e.onCloseRequest(v):v==="popup"?p():h())}),{element:t,onInteraction:i.onInteraction,closePopup:p,closeOverlay:h,showPopup(u,f,g,v=460,m=""){if(n.destroyed)throw new Error("Cannot open a destroyed layer host");p(),o=document.createElement("section"),o.className=`popup ${m}`,o.setAttribute("role","dialog"),o.ariaLabel=f||"列操作",o.style.width=`${v}px`,o.innerHTML=`${f?`<div class="popup-head"><span>${D(f)}</span>${Ie("close-popup","","close")}</div>`:""}${g}`,t.append(o);const w=u.getBoundingClientRect();return o.style.left=`${Math.max(12,Math.min(w.left,innerWidth-v-16))}px`,o.style.top=`${Math.min(w.bottom+8,Math.max(12,innerHeight-o.offsetHeight-16))}px`,c("open","popup",o),o},showOverlay(u,f="dialog-overlay"){if(n.destroyed)throw new Error("Cannot open a destroyed layer host");return a?(a.remove(),c("close","overlay")):l=document.activeElement,a=document.createElement("div"),a.className=`overlay ${f}`,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),typeof u=="string"?a.innerHTML=u:a.append(u),t.append(a),c("open","overlay",a),a},toast(u){if(n.destroyed)return;r==null||r(),d==null||d.remove();const f=document.createElement("div");f.className="toast",f.setAttribute("role","status"),f.innerHTML=Re("check")+D(u),t.append(f),d=f;const g=window.setTimeout(()=>{f.remove(),r==null||r()},2500);r=n.add(()=>window.clearTimeout(g))},destroy(){n.destroyed||(n.destroy(),i.destroy(),p(),h(),t.remove())}}}const Sn=new WeakMap;function Gi(s,e){let t=Sn.get(s);if(!t){const i=new Set,o=a=>{for(const l of[...i])i.has(l)&&!l.contains(a.target,a)&&l.leave(a)};s.addEventListener("pointerdown",o,!0),s.addEventListener("focusin",o,!0),t={boundaries:i,stop:()=>{s.removeEventListener("pointerdown",o,!0),s.removeEventListener("focusin",o,!0)}},Sn.set(s,t)}t.boundaries.add(e);const n=t;return()=>{!n.boundaries.delete(e)||n.boundaries.size||(n.stop(),Sn.delete(s))}}class Be{constructor(e){y(this,"root");y(this,"destroying",!1);y(this,"feedback");y(this,"options");y(this,"value");y(this,"committedValue");y(this,"state");y(this,"view");y(this,"viewLife",new Ke);y(this,"life",new Ke);y(this,"listeners",new Set);y(this,"interactions");y(this,"interactionListeners",new Set);y(this,"mounted",!1);y(this,"handled",new WeakSet);this.options={...e},this.value=e.value,this.committedValue=e.value,this.state=e.readonly||e.canEdit===!1?"display":e.state??"display"}get element(){if(this.root)return this.root;const e=document.createElement("div");return e.className="rowvia-field",e.tabIndex=0,e.setAttribute("aria-label",this.options.field.label),this.root=e,e}bindRoot(){this.life.listen(this.element,"pointerenter",()=>{this.state==="display"&&this.setState("hover","user")}),this.life.listen(this.element,"pointerleave",()=>{this.state==="hover"&&this.setState("display","user")}),this.life.listen(this.element,"click",e=>{e.target.closest("button,a,input,textarea,select,[contenteditable]")||this.edit("user")}),this.life.listen(this.element,"keydown",e=>{const t=e.key;t==="Escape"&&this.state==="editing"?(e.preventDefault(),this.cancel("user")):(t==="Enter"||t===" ")&&this.state!=="editing"&&e.target===this.element&&(e.preventDefault(),this.edit("user"))}),this.life.listen(this.element,"fc-collapse",e=>{var t;((t=e.detail)==null?void 0:t.reason)==="escape"?this.cancel("user"):this.commit("user")}),this.life.listen(this.element,"focusout",()=>{queueMicrotask(()=>{var t,n;if(this.life.destroyed||!this.element.isConnected||this.state!=="editing")return;const e=this.element.ownerDocument.activeElement;this.element.contains(e)||(n=(t=this.view)==null?void 0:t.content)!=null&&n.contains(e)||Xe(e,this.element)||this.commit("user")})})}renderHover(e){return this.renderDisplay(e)}beforeInput(e){return e}beforeCommit(e){return!0}beforeCancel(e){return!0}beforeStateChange(e){return!0}validateValue(e){}isReadonly(){return!!this.options.readonly||this.options.canEdit===!1||this.options.field.editable===!1}onOutput(e){}get snapshot(){return{key:this.options.field.key,value:this.read(),committedValue:this.committedValue,state:this.state,readonly:this.isReadonly()}}mount(e){if(this.life.destroyed)throw new Error("Cannot mount a destroyed field");return this.mounted||(this.mounted=!0,this.bindRoot(),this.draw()),e==null||e.append(this.element),this}read(){var e;return this.state==="editing"&&((e=this.view)!=null&&e.read)?this.view.read():this.value}on(e){return this.life.destroyed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)})}onInteraction(e){return this.life.destroyed?()=>{}:(this.interactionListeners.add(e),()=>{this.interactionListeners.delete(e)})}input(e,t="api",n){var l;if(this.life.destroyed||this.snapshot.readonly)return;const i=this.value,o=this.snapshot,a=this.beforeInput(e);this.value=(l=this.options.hooks)!=null&&l.beforeInput?this.options.hooks.beforeInput(a,o):a,(t==="api"||!Object.is(e,this.value))&&this.draw(),this.emit("input",t,{previousValue:i,originalEvent:n})}setValue(e){if(this.life.destroyed)return;const t=this.read();this.value=e,this.committedValue=e,this.draw(),this.emit("change","api",{previousValue:t})}update(e){this.life.destroyed||(this.value=this.read(),this.options={...this.options,...e},"value"in e&&(this.value=this.committedValue=e.value),e.state&&(this.state=e.state),this.isReadonly()&&(this.state="display"),this.draw())}validate(){var n,i,o,a;const e=this.read(),t=e==null||e===""||Array.isArray(e)&&e.length===0;return(this.options.field.required&&t?"此项必填":void 0)||this.validateValue(e)||((i=(n=this.view)==null?void 0:n.validate)==null?void 0:i.call(n))||((a=(o=this.options.hooks)==null?void 0:o.validate)==null?void 0:a.call(o,e))}commit(e="api"){var i,o;if(this.life.destroyed||this.snapshot.readonly)return!1;const t=this.validate();if(this.showValidation(t),t)return this.emit("invalid",e,{message:t}),!1;const n=this.event("commit",e,{previousValue:this.committedValue});return!this.beforeCommit(n)||((o=(i=this.options.hooks)==null?void 0:i.beforeCommit)==null?void 0:o.call(i,n))===!1?!1:(this.value=this.read(),this.committedValue=this.value,this.element.removeAttribute("aria-invalid"),this.emit("commit",e,{previousValue:n.previousValue}),this.setState("display",e),!0)}cancel(e="api"){var i,o,a,l;if(this.life.destroyed)return;const t=this.event("cancel",e);if(!this.beforeCancel(t)||((o=(i=this.options.hooks)==null?void 0:i.beforeCancel)==null?void 0:o.call(i,t))===!1)return;const n=this.event("state",e,{previousState:this.state,state:"display",value:this.committedValue});this.state!=="display"&&(!this.beforeStateChange(n)||((l=(a=this.options.hooks)==null?void 0:a.beforeStateChange)==null?void 0:l.call(a,n))===!1)||(this.value=this.committedValue,this.disposeView(),this.state="display",this.draw(),this.emit("cancel",e),n.previousState!=="display"&&this.publish(n))}edit(e="api"){var t,n;this.life.destroyed||(this.setState("editing",e),this.state==="editing"&&((n=(t=this.view)==null?void 0:t.focus)==null||n.call(t)))}setState(e,t="api"){var o,a,l,r;if(this.life.destroyed||e===this.state||e==="editing"&&this.snapshot.readonly)return;const n=this.event("state",t,{previousState:this.state});if(n.state=e,!this.beforeStateChange(n)||((a=(o=this.options.hooks)==null?void 0:o.beforeStateChange)==null?void 0:a.call(o,n))===!1)return;const i=this.state!=="editing"&&e!=="editing"&&!((l=this.options.renderers)!=null&&l.display)&&!((r=this.options.renderers)!=null&&r.hover)&&this.renderHover===Be.prototype.renderHover;this.value=this.read(),this.state=e,i&&this.view?this.element.dataset.state=e:this.draw(),this.publish(n)}action(e,t){var i,o;if(this.life.destroyed)return;const n={type:e,value:t};(o=(i=this.options).onAction)==null||o.call(i,n),this.emit("action","api",{action:n})}destroy(){var e,t;if(!(this.life.destroyed||this.destroying)){this.destroying=!0,this.value=this.read();try{this.emit("destroy","api")}finally{try{this.disposeView()}finally{(e=this.interactions)==null||e.destroy(),this.life.destroy(),this.listeners.clear(),this.interactionListeners.clear(),(t=this.root)==null||t.remove()}}}}createEditor(){if(this.life.destroyed)throw new Error("Cannot edit a destroyed field");this.disposeView(),this.state="editing";const e=this.renderEditing(this.context());return this.view=e,this.watch(e),{...e,read:()=>this.read(),validate:()=>this.validate(),onInteraction:t=>this.onInteraction(t),destroy:()=>this.destroy()}}render(){if(this.life.destroyed)throw new Error("Cannot render a destroyed field");return this.disposeView(),this.view=this.renderDisplay(this.context()),{...this.view,destroy:()=>this.destroy()}}context(){return{...this.options,readonly:this.isReadonly(),value:this.value,onAction:e=>this.action(e.type,e.value)}}showValidation(e){var t;if(this.mounted){if(!e){this.element.removeAttribute("aria-invalid"),(t=this.feedback)==null||t.remove();return}this.feedback??(this.feedback=this.element.ownerDocument.createElement("div")),this.feedback.className="fc-error",this.feedback.setAttribute("role","status"),this.feedback.textContent=e,this.element.setAttribute("aria-invalid","true"),this.element.append(this.feedback)}}draw(){var c,p,h,u,f,g,v;if(!this.mounted||this.life.destroyed)return;const e=this.element.ownerDocument.activeElement,t=this.state==="editing"&&!!e&&(!!((c=this.view)!=null&&c.element.contains(e))||!!((h=(p=this.view)==null?void 0:p.content)!=null&&h.contains(e))),n=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:void 0;this.disposeView(),this.isReadonly()&&(this.state="display");const i=this.snapshot,o=this.options.content,a=typeof o=="function"?o(i):o??{kind:"text",text:this.value==null?"":String(this.value)},l=this.context(),r=()=>this.state==="editing"?this.renderEditing(l):o?En(a):this.state==="hover"?this.renderHover(l):this.renderDisplay(l),d={...i,element:this.element,field:this.options.field,content:a,renderDefault:r,input:m=>this.input(m),commit:()=>this.commit(),cancel:()=>this.cancel(),edit:()=>this.edit(),action:(m,w)=>this.action(m,w)};if(this.view=((f=(u=this.options.renderers)==null?void 0:u[this.state])==null?void 0:f.call(u,d))??r(),this.element.setAttribute("aria-label",this.options.field.label),this.element.dataset.state=this.state,this.element.dataset.readonly=String(i.readonly),this.element.replaceChildren(this.view.element),this.element.removeAttribute("aria-invalid"),this.watch(this.view),t){(v=(g=this.view).focus)==null||v.call(g);const m=this.element.ownerDocument.activeElement;if((n==null?void 0:n.start)!=null&&n.end!=null&&(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement))try{m.setSelectionRange(n.start,n.end)}catch{}}}watch(e){if(this.mounted&&this.state==="editing"){const n=()=>[this.element,e.content,this.options.focusBoundary].filter(i=>!!i);this.viewLife.add(Gi(this.element.ownerDocument,{contains:(i,o)=>n().some(a=>o.composedPath().includes(a)||!!i&&a.contains(i)||Xe(i,a)),leave:()=>{this.element.isConnected&&this.commit("user")}}))}this.interactions??(this.interactions=De(this.mounted?this.element:e.element,`field:${this.options.field.key}`,{onInteraction:n=>{var i,o;(o=(i=this.options).onInteraction)==null||o.call(i,n);for(const a of this.interactionListeners)a(n)}}));const t=[...new Set([e.element,e.content].filter(n=>!!n))];for(const n of t)this.viewLife.add(this.interactions.addRoot(n));for(const n of e.inputRoot?[e.inputRoot]:t)for(const i of["input","change"])this.viewLife.listen(n,i,o=>{var a;this.handled.has(o)||(this.handled.add(o),this.input(((a=e.read)==null?void 0:a.call(e))??this.value,"user",o),i==="change"&&this.emit("change","user",{originalEvent:o}))})}disposeView(){var t;this.viewLife.destroy(),this.viewLife=new Ke;const e=this.view;this.view=void 0,(t=e==null?void 0:e.destroy)==null||t.call(e)}event(e,t,n={}){return{...this.snapshot,type:e,source:t,...n}}emit(e,t,n={}){this.publish(this.event(e,t,n))}publish(e){var i,o,a;this.onOutput(e),(o=(i=this.options).onEvent)==null||o.call(i,e);for(const l of[...this.listeners])l(e);const t=this.mounted?this.element:(a=this.view)==null?void 0:a.element;if(!t)return;const n=t.ownerDocument.defaultView.CustomEvent;t.dispatchEvent(new n(`field:${e.type}`,{detail:e,bubbles:!0}))}}function En(s){if(s.kind==="node")return{element:s.node,destroy:s.destroy};const e=document.createElement("div");if(e.className=s.className??"",s.kind==="text")return e.textContent=s.text,{element:e};const t=s.children.map(En);return e.append(...t.map(n=>n.element)),{element:e,destroy:()=>t.forEach(n=>{var i;return(i=n.destroy)==null?void 0:i.call(n)})}}function qi(s,e=312){s.rows=1,s.style.resize="none";const t=()=>{s.style.height="auto";const n=s.scrollHeight;n>0&&(s.style.height=Math.min(n,e)+"px"),s.style.overflowY=n>e?"auto":"hidden"};return s.addEventListener("input",t),s.addEventListener("focus",t),queueMicrotask(t),t}const zi=s=>s==null?"":String(s);function Ja(s){var t;const e=O("div",`fc-value fc-${s.className||""}`);if(s.field.kind==="richText"||s.field.kind==="richtext"||s.field.kind==="longText"||s.field.control==="richText")e.innerHTML=wt(s.value);else if(s.field.kind==="number"&&typeof s.value=="number"){const n=s.field.numberOptions;e.textContent=s.value.toLocaleString("zh-CN",{useGrouping:(n==null?void 0:n.thousandsSeparator)??!1,maximumFractionDigits:(n==null?void 0:n.decimals)??10})+((n==null?void 0:n.suffix)||""),e.classList.add("fc-plain")}else e.textContent=zi(s.value),e.classList.add("fc-plain");return(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function _i(s,e){const n=s==="text"&&e.layout!=="compact"?O("textarea","fc-input fc-textarea"):O("input","fc-input");if(n instanceof HTMLInputElement&&(n.type=s),n.value=zi(e.value),n.disabled=e.readonly,n.required=!!e.field.required,n.ariaLabel=e.field.label,n.placeholder=e.field.placeholder||(e.layout!=="compact"?"待填":`请输入${e.field.label}`),e.field.maxLength!==void 0&&(n.maxLength=e.field.maxLength),s==="number"&&n instanceof HTMLInputElement){const i=e.field.numberOptions;n.step=String((i==null?void 0:i.step)??"any"),(i==null?void 0:i.min)!==void 0&&(n.min=String(i.min)),(i==null?void 0:i.max)!==void 0&&(n.max=String(i.max))}return n instanceof HTMLTextAreaElement&&qi(n),s==="text"&&e.layout!=="compact"&&n.addEventListener("keydown",i=>{i.key==="Enter"&&(i.preventDefault(),n.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))}),{element:n,read:()=>s==="number"?n.value===""?null:Number(n.value):n.value,validate:()=>e.field.required&&!n.value.trim()?"此项必填":n.checkValidity()?void 0:n.validationMessage||"请填写有效值",focus:()=>n.focus()}}const at=s=>s==null?"":String(s),rt=s=>s.dispatchEvent(new Event("change",{bubbles:!0}));function xn(s){try{const e=new URL(at(s));return["http:","https:"].includes(e.protocol)?e.href:void 0}catch{return}}function Tt(s){return O("div","fc-value fc-plain fc-"+(s.className||"")+(s.value==null||s.value===""?" fc-empty":""),at(s.value)||"待填")}function Kt(s,e){const t=e==="textarea"?O("textarea","fc-input fc-textarea"):O("input","fc-input");return t instanceof HTMLInputElement&&(t.type=e),t instanceof HTMLTextAreaElement&&qi(t),t.value=at(s.value),t.disabled=s.readonly,t.required=!!s.field.required,t.ariaLabel=s.field.label,t.placeholder=s.field.placeholder||"请输入"+s.field.label,s.field.maxLength!==void 0&&(t.maxLength=s.field.maxLength),{element:t,read:()=>t.value,focus:()=>t.focus(),validate:()=>e==="url"&&t.value&&!xn(t.value)?"请输入 http 或 https 链接":t.checkValidity()?void 0:"请填写有效的"+s.field.label}}function er(s){const e=O("div","fc-link-value"),t=xn(s.value);if(!t)return Tt(s);const n=O("a","fc-link",at(s.value));return n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.onclick=i=>i.stopPropagation(),e.append(O("span","fc-link-icon","↗"),n),e}function Wi(s){let e=s.value==null||s.value===""?null:s.value===!0;const t=O("div","fc-switch-field"),n=O("button","fc-switch");n.type="button",n.setAttribute("role","switch"),n.ariaLabel=s.field.label,n.disabled=s.readonly;const i=O("span"),o=()=>{n.setAttribute("aria-checked",String(e===!0)),t.dataset.empty=String(e===null),i.textContent=e===null?"待填":e?"是":"否"};return n.onclick=()=>{s.readonly||(e=!e,o(),rt(t))},t.append(n,i),o(),{element:t,read:()=>e,focus:()=>n.focus()}}function tr(s){return Wi({...s,readonly:!0}).element}function nr(s){const e=O("div","fc-signals"),t=Array.isArray(s.value)?s.value:[s.value];for(const n of t.filter(i=>i!=null&&i!=="")){const i=typeof n=="object"?n:{status:n},o=i.status??i.value,a=o===!0||o==="passed"||o==="success",l=O("span","fc-signal "+(a?"is-success":"is-pending"),(a?"● ":"○ ")+at(i.label||i.name||(a?"已满足":o===!1?"未满足":o||"等待信号")));e.append(l)}return e.children.length||e.append(O("span","fc-empty","等待外部信号")),e}function ir(s){const e=s.value&&typeof s.value=="object"?s.value.display??s.value.value:s.value;return Tt({...s,value:e!=null&&typeof e!="object"?e:""})}function sr(s,e){const t=O("div","fc-readonly");return t.append(e(s),O("small","fc-service-note","由系统更新 · 只读")),{element:t,read:()=>s.value}}function Ui(s){const e=s.field.radioValueType==="boolean";let t=s.value==null?"":String(s.value);const n=O("div","fc-radio-group fc-choice--radio");n.setAttribute("role","radiogroup"),n.ariaLabel=s.field.label;const i=[],o=()=>{const a=i.find(l=>l.dataset.value===t&&!l.disabled)??i.find(l=>!l.disabled);for(const l of i){const r=l.dataset.value===t;l.setAttribute("aria-checked",String(r)),l.classList.toggle("selected",r),l.tabIndex=l===a?0:-1}};for(const a of We(s.field)){const l=O("button","fc-option fc-radio-option");l.type="button",l.dataset.value=a.id,l.setAttribute("role","radio"),l.disabled=s.readonly||!!a.disabled;const r=O("span","fc-radio-dot");r.ariaHidden="true",l.append(r,O("span","fc-option-label",a.label)),l.onclick=d=>{d.stopPropagation(),!(l.disabled||t===a.id)&&(t=a.id,o(),rt(n))},l.onkeydown=d=>{var f,g;if(!["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"].includes(d.key)||s.readonly)return;d.preventDefault(),d.stopPropagation();const p=i.filter(v=>!v.disabled),h=p.indexOf(l),u=d.key==="Home"?0:d.key==="End"?p.length-1:(h+(["ArrowLeft","ArrowUp"].includes(d.key)?-1:1)+p.length)%p.length;(f=p[u])==null||f.focus(),(g=p[u])==null||g.click()},i.push(l),n.append(l)}return i.length?t&&!i.some(a=>a.dataset.value===t)&&n.append(O("span","fc-empty","已选选项不可用")):n.append(O("span","fc-empty","暂无选项")),o(),{element:n,read:()=>e?t===""?null:t==="true":t,focus:()=>{var a;return(a=i.find(l=>l.tabIndex===0))==null?void 0:a.focus()},validate:()=>s.field.required&&!t?"请选择一个选项":void 0}}const ji=s=>!Array.isArray(s)||!s.length?[]:Array.isArray(s[0])?s.map(e=>e.map(String)):[s.map(String)];function Nt(s,e){const t=[];for(const n of e){const i=s.find(o=>o.id===n);t.push((i==null?void 0:i.label)||n),s=(i==null?void 0:i.children)||[]}return t.join(" / ")}function or(s){const e=O("div","fc-tags");for(const t of ji(s.value)){const n=O("span","fc-tag");n.append(O("span","fc-tag-label",Nt(We(s.field),t))),e.append(n)}return e.children.length||e.append(O("span","fc-empty","待填")),e}function ar(s,e){const t=O("div","fc-cascade"),n=O("div","fc-choice-selection"),i=O("input","fc-choice-search");i.placeholder="",i.autocomplete="off",i.ariaLabel="输入以搜索"+e.field.label,i.disabled=e.readonly;const o=()=>{i.size=Math.max(1,[...i.value].length+1)};o();const a=O("div","fc-cascade-columns"),l=O("div","fc-error");l.setAttribute("role","status");const r=We(e.field);let d=ji(e.value),c=[];const p=[],h=(b,N,I=!1)=>b.forEach(E=>{var G;(G=E.children)!=null&&G.length?h(E.children,[...N,E.id],I||!!E.disabled):p.push({path:[...N,E.id],disabled:I||!!E.disabled})});h(r,[]);const u=(b,N)=>JSON.stringify(b)===JSON.stringify(N),f=e.layout!=="compact"&&!e.readonly;let g;const v=()=>{const b=g;g=void 0,b==null||b.close()},m=()=>{!f||g||e.readonly||(g=vt({anchor:i.parentElement||t,content:a,width:"anchor",gap:4,onDismiss:()=>{g=void 0}}))},w=()=>{!f||!g||(v(),t.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},k=b=>{if(e.readonly)return;const N=d.findIndex(I=>u(I,b));if(s&&N>=0)d.splice(N,1);else{if(s&&e.field.maxSelections&&d.length>=e.field.maxSelections){l.textContent="最多可选择 "+e.field.maxSelections+" 项";return}d=s?[...d,b]:[b]}l.textContent="",C(),t.dispatchEvent(new Event("change",{bubbles:!0})),s||w()},C=()=>{var E,G;if(n.replaceChildren(),a.replaceChildren(),d.forEach(x=>{const T=O("span","fc-tag");T.append(O("span","fc-tag-label",Nt(r,x)));const A=O("span","fc-tag-slot"),H=O("button","fc-choice-remove","×");H.type="button",H.disabled=e.readonly,H.ariaLabel="移除"+Nt(r,x),H.onclick=()=>{d=d.filter(q=>!u(x,q)),C(),t.dispatchEvent(new Event("change",{bubbles:!0}))},A.append(H),T.append(A),n.append(T)}),i.value.trim()){const x=p.filter(T=>!T.disabled&&Nt(r,T.path).toLocaleLowerCase().includes(i.value.trim().toLocaleLowerCase()));for(const{path:T}of x){const A=O("button","fc-option",Nt(r,T));A.type="button",A.disabled=e.readonly,A.setAttribute("aria-pressed",String(d.some(H=>u(H,T)))),A.onclick=()=>k(T),a.append(A)}a.classList.add("is-search"),x.length||a.append(O("p","fc-empty","暂无匹配路径"));return}a.classList.remove("is-search");let b=r,N=[],I=0;for(;b.length;){const x=O("div","fc-cascade-column");x.setAttribute("role","group"),x.ariaLabel="第"+(I+1)+"级";for(const A of b.filter(H=>!H.disabled)){const H=[...N,A.id],q=!!((E=A.children)!=null&&E.length),R=O("button","fc-option",A.label+(q?" ›":""));R.type="button",R.disabled=e.readonly,R.classList.toggle("selected",q?c[I]===A.id:d.some(P=>u(P,H))),R.setAttribute(q?"aria-expanded":"aria-pressed",String(q?c[I]===A.id:d.some(P=>u(P,H)))),R.onclick=()=>{var P,L;q?(c=H,C(),(L=(P=a.lastElementChild)==null?void 0:P.querySelector("button"))==null||L.focus()):k(H)},x.append(R)}a.append(x);const T=b.find(A=>A.id===c[I]&&!A.disabled);if(!((G=T==null?void 0:T.children)!=null&&G.length))break;N=[...N,T.id],b=T.children,I++}r.length||a.append(O("p","fc-empty","暂无可选分类"))};if(i.oninput=()=>{o(),C()},i.onfocus=m,a.onkeydown=b=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(b.key))return;const N=b.target,E=[...(N.closest(".fc-cascade-column")||a).querySelectorAll("button:not(:disabled)")];if(!E.length)return;b.preventDefault();const G=E.indexOf(N);E[b.key==="Home"?0:b.key==="End"?E.length-1:(G+(b.key==="ArrowDown"?1:-1)+E.length)%E.length].focus()},t.append(n,i,l),f){const b=O("span","fc-field-chevron");b.setAttribute("aria-hidden","true"),t.append(b),t.addEventListener("click",()=>m())}else t.append(a);return C(),{element:t,content:f?a:void 0,read:()=>s?d.map(b=>[...b]):[...d[0]||[]],focus:()=>{i.focus(),m()},deactivate:()=>{i.value="",o(),v()},destroy:()=>v(),validate:()=>e.field.required&&!d.length?"请选择分类":void 0}}function Ki(s){var f,g,v;let e=Array.isArray(s.value)?structuredClone(s.value):[];const t=O("div","fc-attachments"),n=O("div","fc-file-list"),i=O("label","fc-upload-zone","+ 上传附件"),o=O("input");o.type="file",o.multiple=!0,o.ariaLabel="上传"+s.field.label,o.accept=((f=s.field.attachmentOptions)==null?void 0:f.accept)||"",o.disabled=s.readonly||!((g=s.services)!=null&&g.upload);const a=O("p","fc-error");a.setAttribute("role","status");const l=O("button","fc-retry","重试上传");l.type="button",l.hidden=!0;let r=[],d=!1,c=!1,p;const h=()=>{n.replaceChildren(),e.forEach((m,w)=>{const k=O("div","fc-file-row"),C=xn(m.url),b=C?O("a","fc-link",m.name):O("span","",m.name);if(b.tagName==="A"){const N=b;N.href=C,N.target="_blank",N.rel="noopener noreferrer"}if(k.append(O("span","fc-file-icon","▤"),b),m.size!=null&&k.append(O("small","fc-file-size",Math.ceil(m.size/1024)+" KB")),!s.readonly){const N=O("button","fc-file-remove","×");N.type="button",N.disabled=d,N.ariaLabel="移除"+m.name,N.onclick=()=>{e.splice(w,1),h(),rt(t)},k.append(N)}n.append(k)}),e.length||n.append(O("span","fc-empty","暂无附件"))},u=async()=>{var k;if(!((k=s.services)!=null&&k.upload)||s.readonly||d||!r.length)return;const m=s.field.attachmentOptions;if(m!=null&&m.maxFiles&&e.length+r.length>m.maxFiles){a.textContent="最多上传 "+m.maxFiles+" 个文件";return}if(m!=null&&m.maxBytes&&r.some(C=>C.size>m.maxBytes)){a.textContent="文件大小超过限制";return}const w=((m==null?void 0:m.accept)||"").split(",").map(C=>C.trim().toLowerCase()).filter(Boolean);if(w.length&&r.some(C=>!w.some(b=>b.startsWith(".")?C.name.toLowerCase().endsWith(b):b.endsWith("/*")?C.type.toLowerCase().startsWith(b.slice(0,-1)):C.type.toLowerCase()===b))){a.textContent="文件类型不符合要求";return}p=new AbortController,d=!0,o.disabled=!0,l.hidden=!0,a.textContent="上传中…",t.setAttribute("aria-busy","true"),h();try{const C=await s.services.upload(s.field,r,p.signal);if(c)return;if(C.length!==r.length||C.some(b=>!b.id||!b.name))throw new Error("Invalid file references");e=[...e,...C],r=[],a.textContent="",o.value=""}catch{c||(a.textContent="上传失败,已保留原有附件",l.hidden=!1)}finally{c||(d=!1,o.disabled=!1,t.setAttribute("aria-busy","false"),h(),r.length||rt(t))}};return o.onchange=m=>{m.stopPropagation(),r=Array.from(o.files||[]),u()},l.onclick=()=>void u(),i.append(o),t.append(n),s.readonly||(t.append(i),(v=s.services)!=null&&v.upload||t.append(O("p","fc-service-note","上传服务未接入"))),t.append(a,l),h(),{element:t,read:()=>structuredClone(e),focus:()=>o.focus(),validate:()=>d?"请等待上传完成":r.length?"请完成或重新选择上传文件":s.field.required&&!e.length?"请上传附件":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function kn(s){if(s&&typeof s=="object"&&!Array.isArray(s)){const e=s;return{selected:Array.isArray(e.selected)?[...e.selected]:[],counts:{...e.counts},total:e.total}}return{selected:[],counts:{}}}function Yi(s,e){var A,H;let t=kn(s.value),n=[...t.selected];const i=e==="attitude"?[{id:"like",label:"赞同"}]:We(s.field),o=O("div","fc-vote"),a=O("button","fc-vote-trigger");a.type="button",a.setAttribute("aria-haspopup","dialog"),a.setAttribute("aria-expanded","false");const l=O("span","fc-vote-icon","+");l.ariaHidden="true";const r=O("span");a.append(l,r);const d=O("section","fc-vote-panel");d.setAttribute("role","dialog"),d.ariaLabel=s.field.label;const c=O("div","fc-vote-header"),p=O("span","fc-vote-total");c.append(O("strong","",e==="attitude"?"表态投票":e==="multi"?"投票-多选":"投票-单选"),p);const h=O("div","fc-vote-list");h.setAttribute("role",e==="multi"?"group":"radiogroup"),h.ariaLabel=s.field.label;const u=O("p","fc-error");u.setAttribute("role","status");const f=O("button","fc-vote-submit","确认投票");f.type="button";const g=O("button","fc-vote-withdraw","撤回投票");g.type="button";const v=O("button","fc-vote-withdraw","重新加载");v.type="button",v.hidden=!0;const m=O("div","fc-vote-actions");m.append(f,g);let w=!1,k=!1,C=!1,b=!((A=s.services)!=null&&A.loadVote),N,I;const E=()=>{var q,R,P;r.textContent=t.selected.length?"已投票":"投票",a.classList.toggle("is-voted",!!t.selected.length),a.ariaLabel=`${s.field.label},${r.textContent}`,p.textContent=k?"加载中…":b?`${t.total??Object.values(t.counts).reduce((L,M)=>L+M,0)}人已投`:"待加载",d.setAttribute("aria-busy",String(w||k)),h.replaceChildren();for(const L of i){const M=O("button","fc-vote-option");M.type="button",M.dataset.value=L.id,M.disabled=s.readonly||w||k||!b||!((q=s.services)!=null&&q.vote)||!!L.disabled;const $=n.includes(L.id);M.classList.toggle("selected",$),M.setAttribute("role",e==="multi"?"checkbox":"radio"),M.setAttribute("aria-checked",String($));const z=O("span",e==="multi"?"fc-vote-check":"fc-radio-dot");z.ariaHidden="true",M.append(z,O("span","fc-vote-label",L.label)),b&&Object.keys(t.counts).length&&M.append(O("span","fc-vote-count",`${t.counts[L.id]??0} 票`)),M.onclick=()=>{var j;M.disabled||(n=e==="multi"?$?n.filter(te=>te!==L.id):[...n,L.id]:[L.id],E(),(j=h.querySelector(`[data-index="${i.indexOf(L)}"]`))==null||j.focus())},M.dataset.index=String(i.indexOf(L)),h.append(M)}i.length||h.append(O("p","fc-empty","暂无投票选项")),f.disabled=w||k||!b||!((R=s.services)!=null&&R.vote)||!n.length,f.textContent=w?"提交中…":t.selected.length?"确认改票":"确认投票",g.hidden=!t.selected.length,g.disabled=w||k||!b,m.hidden=s.readonly||!((P=s.services)!=null&&P.vote),I==null||I.reposition()};h.onkeydown=q=>{if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"].includes(q.key))return;const R=[...h.querySelectorAll("button:not(:disabled)")];if(!R.length)return;q.preventDefault(),q.stopPropagation();const P=R.indexOf(document.activeElement),L=q.key==="Home"?0:q.key==="End"?R.length-1:(P+(["ArrowUp","ArrowLeft"].includes(q.key)?-1:1)+R.length)%R.length;R[L].focus(),e!=="multi"&&R[L].click()};const G=()=>{I==null||I.close(),I=void 0},x=async()=>{var q;if(!(!((q=s.services)!=null&&q.loadVote)||k||w)){k=!0,u.textContent="",v.hidden=!0,N=new AbortController,E();try{const R=await s.services.loadVote(s.field,N.signal);if(C||N.signal.aborted)return;t=kn(R),n=[...t.selected],b=!0}catch{C||(b=!1,u.textContent="加载失败,请重试",v.hidden=!1)}finally{C||(k=!1,E())}}},T=async q=>{var R;if(!(w||k||!b||s.readonly||!((R=s.services)!=null&&R.vote))){w=!0,u.textContent="",N=new AbortController,E();try{const P=await s.services.vote(s.field,[...q],N.signal);if(C||N.signal.aborted)return;t=kn(P),n=[...t.selected],w=!1,rt(o),G(),a.focus()}catch{C||(u.textContent="投票失败,请重试")}finally{C||(w=!1,E())}}};return a.onclick=q=>{if(q.stopPropagation(),I){G();return}n=[...t.selected],u.textContent="",E(),I=vt({anchor:a,anchorMode:"element",content:d,width:360,onDismiss:()=>{I=void 0,a.setAttribute("aria-expanded","false"),w||(n=[...t.selected])},onEscape:()=>a.focus()}),a.setAttribute("aria-expanded","true"),d.tabIndex=-1,d.focus(),x()},f.onclick=()=>{n.length&&T(n)},g.onclick=()=>void T([]),v.onclick=()=>void x(),d.append(c,h,u,v,m),!s.readonly&&!((H=s.services)!=null&&H.vote)&&d.append(O("p","fc-service-note","创建工作项后可投票")),o.append(a),E(),{element:o,content:d,read:()=>structuredClone(t),focus:()=>a.focus(),validate:()=>w?"请等待投票完成":void 0,deactivate:G,destroy:()=>{C=!0,N==null||N.abort(),G()}}}function rr(s){const e=s.value&&typeof s.value=="object"?s.value:{},t=O("div","fc-location"),i=[["address","地址","text"],["longitude","经度","number"],["latitude","纬度","number"]].map(([a,l,r])=>{const d=O("label","fc-location-part",l),c=O("input","fc-input");return c.type=r,c.value=at(e[a]),c.disabled=s.readonly,c.ariaLabel=l,c.placeholder=l,r==="number"&&(c.step="any",c.min=a==="longitude"?"-180":"-90",c.max=a==="longitude"?"180":"90"),d.append(c),t.append(d),c}),o=()=>i.every(a=>!a.value)?null:{address:i[0].value,longitude:i[1].value?Number(i[1].value):null,latitude:i[2].value?Number(i[2].value):null};return{element:t,read:o,focus:()=>i[0].focus(),validate:()=>{if(!o())return s.field.required?"请填写位置":void 0;if(i.slice(1).some(a=>a.value===""||!a.checkValidity()))return"请填写有效的经纬度"}}}function lr(s){const e=s.value;return Tt({...s,value:e&&typeof e=="object"?at(e.address)||[e.longitude,e.latitude].filter(t=>t!=null).join(", "):""})}function dr(s,e){const t=O("div","fc-composite"),n=O("div","fc-composite-rows"),i=O("button","fc-composite-add","+ 添加一组");i.type="button";const o=s.field.compositeFields||[],a=[];let l=!1;const r=u=>({...u.value,...Object.fromEntries(u.editors.map(({field:f,editor:g})=>[f.key,g.read()]))}),d=u=>{u.editors.forEach(({editor:f})=>{var g;return(g=f.destroy)==null?void 0:g.call(f)}),u.remove&&(u.remove.onclick=null),u.element.remove()},c=O("p","fc-empty","暂无记录"),p=()=>{a.forEach((u,f)=>{u.legend.textContent="第 "+(f+1)+" 组"}),i.disabled=s.readonly||!o.length||a.length>=(s.field.maxRows||100),a.length?c.remove():n.append(c)},h=u=>{const f=O("fieldset","fc-composite-row"),g=O("legend");f.append(g);const v=o.map(w=>{const k=e(w),C=k.createEditor({...s,field:w,value:u[w.key],readonly:s.readonly||w.editable===!1||!!k.readonly,focusBoundary:void 0,onSelectedOptions:N=>{var I;(I=s.services)!=null&&I.searchOptions&&(w.choices=[...new Map([...We(w),...N].map(E=>[E.id,E])).values()])}}),b=O("div","fc-composite-field");return b.append(O("label","",w.label+(w.required?" *":"")),C.element),f.append(b),{field:w,editor:C}}),m={value:u,element:f,legend:g,editors:v};if(!s.readonly){const w=O("button","fc-composite-remove","删除此组");w.type="button",w.onclick=()=>{if(l)return;const k=a.indexOf(m);k<0||(d(m),a.splice(k,1),p(),rt(t))},m.remove=w,f.append(w)}a.push(m),n.append(f),p()};for(const u of Array.isArray(s.value)?s.value:[])h(structuredClone(u));return i.onclick=()=>{l||i.disabled||(h({}),rt(t))},t.append(n),s.readonly||t.append(i),o.length||t.append(O("p","fc-service-note","请配置复合子字段")),p(),{element:t,read:()=>a.map(r),validate:()=>{var u;if(s.field.required&&!a.length)return"请至少添加一组";for(const[f,g]of a.entries())for(const{field:v,editor:m}of g.editors){const w=(u=m.validate)==null?void 0:u.call(m);if(w)return"第 "+(f+1)+" 组 · "+v.label+":"+w}},destroy:()=>{l||(l=!0,i.onclick=null,a.forEach(d))}}}class Ze extends Be{renderDisplay(e){return{element:Ja(e)}}renderEditing(e){return _i("text",e)}}class Xi extends Ze{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,kind:"number"}})}renderEditing(e){return _i("number",e)}}class Zi extends Ze{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,control:"richText"}})}renderEditing(e){return Ni(e)}}class Qi extends Ze{renderDisplay(e){return{element:Tt(e)}}renderEditing(e){return Kt(e,"textarea")}}class Mn extends Ze{renderDisplay(e){return{element:er(e)}}renderEditing(e){return Kt(e,"url")}}class Ji extends Ze{renderEditing(e){return Kt(e,"email")}}class es extends Ze{renderEditing(e){return Kt(e,"tel")}}class yt extends Be{constructor(){super(...arguments);y(this,"multiple",!1);y(this,"variant","choice")}renderDisplay(t){return{element:Li(t,this.variant==="radio"?"choice":this.variant)}}renderEditing(t){return hn(this.multiple,t,this.variant)}}class ts extends yt{constructor(){super(...arguments);y(this,"multiple",!0)}}class ns extends yt{constructor(){super(...arguments);y(this,"variant","radio")}renderDisplay(t){return t.layout==="compact"?{element:Li(t)}:Ui({...t,readonly:!0})}renderEditing(t){if(t.layout!=="compact")return Ui(t);const n=hn(!1,t,"choice");return t.field.radioValueType!=="boolean"?n:{...n,read:()=>{const i=n.read();return i===""?null:i==="true"}}}}class Rn extends yt{constructor(){super(...arguments);y(this,"variant","person")}}class is extends Rn{constructor(){super(...arguments);y(this,"multiple",!0)}}class Ln extends yt{constructor(){super(...arguments);y(this,"variant","relation")}}class ss extends Ln{constructor(){super(...arguments);y(this,"multiple",!0)}}class Tn extends Be{constructor(){super(...arguments);y(this,"multiple",!1)}renderDisplay(t){return{element:or(t)}}renderEditing(t){return ar(this.multiple,t)}}class os extends Tn{constructor(){super(...arguments);y(this,"multiple",!0)}}class Nn extends Be{normalize(e){return e}renderDisplay(e){return{element:Di(this.normalize(e))}}renderEditing(e){return Pi(this.normalize(e))}}class In extends Nn{constructor(){super(...arguments);y(this,"range",!1)}normalize(t){return{...t,field:{...t.field,dateOptions:{showTime:!1,showRange:this.range,...t.field.dateOptions}}}}}class as extends In{constructor(){super(...arguments);y(this,"range",!0)}}class rs extends Be{renderDisplay(e){return{element:tr(e)}}renderEditing(e){return Wi(e)}}class ls extends Be{renderDisplay(e){return Ki({...e,readonly:!0})}renderEditing(e){return Ki(e)}}class ds extends Be{renderDisplay(e){return{element:lr(e)}}renderEditing(e){return rr(e)}}class Yt extends Be{constructor(){super(...arguments);y(this,"mode","attitude")}renderDisplay(t){return Yi({...t,readonly:!0},this.mode)}renderEditing(t){return Yi(t,this.mode)}}class cs extends Yt{constructor(){super(...arguments);y(this,"mode","single")}}class us extends Yt{constructor(){super(...arguments);y(this,"mode","multi")}}class bt extends Be{isReadonly(){return!0}constructor(e){super({...e,readonly:!0})}renderDisplay(e){return{element:ir(e)}}renderEditing(e){return sr(e,t=>this.renderDisplay(t).element)}}class An extends bt{renderDisplay(e){return{element:nr(e)}}}class hs extends Ze{renderDisplay(e){const t=document.createElement("button");return t.type="button",t.className="fc-detail-link",t.textContent=e.field.label,t.onclick=n=>{var i;n.stopPropagation(),(i=e.onAction)==null||i.call(e,{type:"open",value:e.value})},{element:t,destroy:()=>{t.onclick=null}}}}class ps extends Be{constructor(e,t){super(e),this.resolve=t}renderDisplay(e){var i;if(e.layout==="compact")return{element:Tt({...e,value:Array.isArray(e.value)&&e.value.length?e.value.length+" 组记录":""})};const t=document.createElement("div");t.className="fc-composite";const n=[];for(const o of Array.isArray(e.value)?e.value:[]){const a=document.createElement("fieldset");a.className="fc-composite-row";for(const l of e.field.compositeFields??[]){const r=document.createElement("label");r.textContent=l.label;const d={...e,field:l,value:o[l.key],readonly:!0},c=this.resolve(l),p=((i=c.renderView)==null?void 0:i.call(c,d))??{element:c.render(d)};n.push(p),a.append(r,p.element)}t.append(a)}return{element:t,destroy:()=>n.forEach(o=>{var a;return(a=o.destroy)==null?void 0:a.call(o)})}}renderEditing(e){return dr(e,this.resolve)}}const cr={textarea:"保留换行的纯文本,支持长度限制",radio:"平铺选项,一次选择一项",cascadeSingle:"逐级浏览分类,选择完整路径",cascadeMulti:"逐级浏览并选择多条路径",person:"按姓名搜索,以稳定人员 ID 保存",multiPerson:"按姓名搜索,以稳定人员 ID 保存",date:"日历选择和直接输入,支持清空",dateRange:"连续选择起止日期,校验完整范围",url:"填写网址并在新窗口安全打开",cloudDocument:"添加云文档链接,点击打开原文档",email:"邮箱输入与格式校验",phone:"支持国家区号的电话输入",switch:"以是或否记录布尔状态",attachment:"文件列表、上传与删除,支持上传失败重试",location:"填写地址和经纬度,校验坐标边界",relation:"按名称或编号搜索工作项,点击名称打开详情",multiRelation:"按名称或编号搜索工作项,点击名称打开详情",attitudeVote:"选择并提交投票,结果以宿主服务回读为准",singleVote:"选择并提交投票,结果以宿主服务回读为准",multiVote:"选择并提交投票,结果以宿主服务回读为准",externalSignal:"由外部系统更新,系统内只读",externalMultiSignal:"由外部系统更新,系统内只读",formula:"展示服务端计算结果,不可手工覆盖",aggregate:"展示服务端计算结果,不可手工覆盖",ai:"展示服务端计算结果,不可手工覆盖",system:"展示服务端计算结果,不可手工覆盖",composite:"可重复字段组,复用已注册子控件并逐组校验",multiPersonComposite:"可重复字段组,复用已注册子控件并逐组校验",text:"单行输入,支持清空和必填校验",richText:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",select:"从字段配置中选择一个选项",multiSelect:"点击标签选择多项,保存为数组",number:"支持小数和负数,空值与零分别保存",dateTime:"日历、时间与日期范围",detail:"由调用方处理关联内容导航"},ur={title:"text",longText:"richText",status:"select",richtext:"richText",single_select:"select",multi_select:"multiSelect",user:"person",multi_user:"multiPerson",multi_person:"multiPerson",cascade_select:"cascadeSingle",cascade_single:"cascadeSingle",cascade_multi:"cascadeMulti",daterange:"dateRange",date_range:"dateRange",datetime:"dateTime",multi_relation:"multiRelation",attitude_vote:"attitudeVote",single_vote:"singleVote",multi_vote:"multiVote",vote:"attitudeVote",external_signal:"externalSignal",external_multi_signal:"externalMultiSignal",multi_person_composite:"multiPersonComposite",cloud_document:"cloudDocument"},hr=[["text","单行文本",Ze,"文本","T"],["richText","富文本",Zi,"文本","¶"],["select","单选",yt,"选择","◉"],["multiSelect","多选",ts,"选择","☑"],["number","数字",Xi,"其他","#"],["dateTime","日期时间",Nn,"日期","◷"],["detail","详情页查看",hs,"关联工作项","↗"],["textarea","多行文本",Qi,"文本","≡"],["radio","单选按钮",ns,"选择","◉"],["cascadeSingle","级联单选",Tn,"选择","⑂"],["cascadeMulti","级联多选",os,"选择","⑂"],["person","单选人员",Rn,"人员","♙"],["multiPerson","多选人员",is,"人员","♙"],["date","日期",In,"日期","▦"],["dateRange","日期区间",as,"日期","▦"],["url","URL 链接",Mn,"其他","↗"],["cloudDocument","关联云文档",Mn,"其他","▤"],["email","邮箱",Ji,"其他","@"],["phone","电话",es,"其他","☎"],["switch","开关",rs,"其他","◐"],["attachment","附件",ls,"其他","⌑"],["location","地理位置",ds,"其他","⌖"],["relation","单选关联工作项",Ln,"关联工作项","↗"],["multiRelation","多选关联工作项",ss,"关联工作项","↗"],["attitudeVote","表态投票",Yt,"投票","♡"],["singleVote","单选投票",cs,"投票","♡"],["multiVote","多选投票",us,"投票","♡"],["externalSignal","系统外信号",An,"系统","◌",!0],["externalMultiSignal","多值系统外信号",An,"系统","◌",!0],["formula","公式计算",bt,"系统","ƒ",!0],["aggregate","聚合计算",bt,"系统","ƒ",!0],["ai","AI 字段",bt,"系统","ƒ",!0],["system","系统字段",bt,"系统","ƒ",!0]];function fs(s=[]){const e=new Map,t=a=>{if(!/^[A-Za-z][\w-]*$/.test(a.id))throw new Error("Invalid control id");if(e.has(a.id))throw new Error(`Control already registered: ${a.id}`);e.set(a.id,a)},n=a=>{const l=a.control||ur[a.kind||"text"]||a.kind||"text",r=e.get(l);if(!r)throw new Error(`Unknown control: ${l}`);return r},i=a=>n(a.field).create(a),o=a=>{const l=n(a);return{...l,render:r=>l.create(r).render().element,renderView:r=>l.create(r).render(),createEditor:r=>l.create(r).createEditor()}};for(const[a,l,r,d,c,p]of hr)t({id:a,label:l,description:cr[a]||l,glyph:c,group:d,readonly:p,action:a==="detail"?"view":a==="select"||a==="multiSelect"?"select":void 0,create:h=>new r({...h,readonly:p||h.readonly})});for(const[a,l]of[["composite","复合字段"],["multiPersonComposite","多人复合字段"]])t({id:a,label:l,description:"组合多个已注册字段",glyph:"▦",group:"其他",create:r=>new ps(r,o)});return s.forEach(t),{register:t,resolve:n,create:i,list:()=>[...e.values()]}}class $n extends Be{constructor(e,t){super(e),this.control=t}renderDisplay(e){return{element:this.control.render(e)}}renderEditing(e){return this.control.createEditor(e)}}const it={page(s){return s.page||(s.surface==="cell"?"table":"basic")},render(s,e){const t=O("div","fc-base-control"),n=it.page(s);return t.dataset.page=n,t.dataset.mode=s.mode||"default",t.dataset.editable=String(s.canEdit??!s.readonly),t.dataset.readonly=String(s.readonly),t.setAttribute("data-field-control",s.field.control||s.field.kind||"text"),t.append(e),t}},pr=new Set(["radio","select","multiSelect","person","multiPerson","relation","multiRelation","cascadeSingle","cascadeMulti","date","dateRange","dateTime","detail","composite","multiPersonComposite"]);function It(s){return s.id==="richText"?"rich":pr.has(s.id)?"select":"text"}function gs(s,e,t){if(["radio","switch","attitudeVote","singleVote","multiVote"].includes(s.id)||it.page(e)==="table"||e.readonly||s.readonly||e.canEdit===!1)return t;const n=document.createElement("div");n.className="fc-base-control fc-focus-editor",n.dataset.expanded="true",n.tabIndex=-1;const i=it.page(e);n.dataset.page=i,n.dataset.mode=i==="table"?"editing":"expanded",n.dataset.controlKey=s.id,n.dataset.box=It(s);const o=document.createElement("div");o.className="fc-focus-body",o.dataset.box=It(s),o.append(t.element);const a=document.createElement("div");a.className="fc-focus-trigger",a.tabIndex=0,a.setAttribute("role","button"),a.ariaLabel="编辑"+e.field.label,a.setAttribute("aria-expanded","true"),a.hidden=!0;const l=document.createElement("span");l.className="fc-error fc-focus-error",l.setAttribute("role","status"),n.append(o,a,l);const r=n.ownerDocument,d=e.focusBoundary||n,c=m=>!!m&&(d.contains(m)||Xe(m,n));let p=!1;const h=()=>{p||(o.hidden=!1,a.hidden=!0,n.dataset.expanded="true",n.dataset.mode="editing",a.setAttribute("aria-expanded","true"),l.textContent="",t.focus&&t.focus(),!o.contains(r.activeElement)&&!Xe(r.activeElement,n)&&(Array.from(o.querySelectorAll('input:not([type=hidden]):not(:disabled),textarea:not(:disabled),[contenteditable=true],button:not(:disabled),[tabindex="0"]')).find(w=>!w.closest("[hidden]"))||n).focus())},u=()=>{var C,b,N;if(p||!n.isConnected||n.dataset.expanded==="false")return;const m=(C=t.validate)==null?void 0:C.call(t),w={...e,readonly:!0,canEdit:!1,mode:"default",value:m?e.value:t.read()},k=it.render(w,s.render(w));k.inert=!0,a.replaceChildren(k),l.textContent=m?"尚未保存:"+m:"",(b=t.deactivate)==null||b.call(t),n.dataset.expanded="false",n.dataset.mode="default",o.hidden=!0,a.hidden=!1,a.setAttribute("aria-expanded","false"),(N=e.onDeactivate)==null||N.call(e)},f=m=>{if(m.relatedTarget instanceof Node&&c(m.relatedTarget))return;const w=m.target;queueMicrotask(()=>{p||!n.isConnected||c(r.activeElement)||(w&&!w.isConnected&&r.activeElement===r.body?n.focus():u())})},g=()=>{queueMicrotask(()=>{!p&&n.isConnected&&n.dataset.expanded==="true"&&(!r.activeElement||r.activeElement===r.body)&&n.focus()})};a.onclick=m=>{m.stopPropagation(),h()},a.onkeydown=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),h())},d.addEventListener("focusout",f),n.addEventListener("click",g,!0),n.addEventListener("fc-collapse",u);const v=Gi(r,{contains:(m,w)=>w.composedPath().includes(d)||c(m),leave:u});return{...t,element:n,focus:h,destroy:()=>{var m;p||(p=!0,v(),d.removeEventListener("focusout",f),n.removeEventListener("click",g,!0),n.removeEventListener("fc-collapse",u),(m=t.destroy)==null||m.call(t))}}}function Fn(s){return{...s,context:s,layout:it.page(s)==="table"?"compact":"form",className:s.surface,services:s.services?{searchOptions:s.services.searchOptions,upload:s.services.upload,vote:s.services.vote?(e,t,n)=>s.services.vote(e,s.item,t,n):void 0,loadVote:s.services.loadVote?(e,t)=>s.services.loadVote(e,s.item,t):void 0}:void 0,onAction:e=>{e.type==="open"&&s.openDetail(String(e.value||s.item.id))}}}function ms(s=[]){const e=fs(),t=new Map;for(const i of e.list()){const o={...i,render(a){const l=e.create(Fn(a));return it.render(a,l.render().element)},createEditor(a){const l=e.create(Fn(a));return gs(o,a,l.createEditor())}};t.set(i.id,o)}const n=i=>{e.register({...i,create:a=>new $n(a,{render:l=>i.render({...l.context,field:l.field,value:l.value,readonly:l.readonly}),createEditor:l=>i.createEditor({...l.context,field:l.field,value:l.value,readonly:l.readonly})})});const o={...i,render:a=>it.render(a,i.render(a)),createEditor(a){const l=new $n(Fn(a),{render:r=>i.render({...a,value:r.value}),createEditor:r=>i.createEditor({...a,value:r.value})});return gs(i,a,l.createEditor())}};t.set(i.id,o)};return s.forEach(n),{register:n,list:()=>[...t.values()],resolve:i=>t.get(e.resolve(i).id)}}function fr(s,e){const t=e[s.field],n=s.value,i=Array.isArray(t)?t.map(String):t==null||t===""?[]:[String(t)];switch(s.op){case"equals":return Array.isArray(t)?i.includes(String(n)):String(t??"")===String(n??"");case"notEqual":return Array.isArray(t)?!i.includes(String(n)):String(t??"")!==String(n??"");case"contains":return i.some(o=>o.includes(String(n??"")));case"notContains":return!i.some(o=>o.includes(String(n??"")));case"in":return(Array.isArray(n)?n.map(String):[String(n??"")]).some(o=>i.includes(o));case"notIn":return!(Array.isArray(n)?n.map(String):[String(n??"")]).some(o=>i.includes(o));case"blank":return i.length===0;case"notBlank":return i.length>0;default:return!0}}function Ve(s,e,t={}){return s?"all"in s?s.all.every(n=>Ve(n,e,t)):"any"in s?s.any.some(n=>Ve(n,e,t)):"not"in s?!Ve(s.not,e,t):fr(s,e):!0}function lt(s,e={}){var t,n,i,o,a,l;return!s||s.all||(t=s.members)!=null&&t.length&&s.members.includes(e.currentUser||"")||(n=s.teams)!=null&&n.length&&(e.teams||[]).some(r=>s.teams.includes(r))||(i=s.roles)!=null&&i.length&&(e.roles||[]).some(r=>s.roles.includes(r))?!0:!((o=s.members)!=null&&o.length||(a=s.teams)!=null&&a.length||(l=s.roles)!=null&&l.length)}const gr={empty:"待填",required:"此项必填",simpleMode:"简洁模式",continuous:"连续创建",cancel:"取消",draft:"存草稿",submit:"确认创建",addRole:"添加角色",addMeeting:"添加一组进入选题会"};function vs(s){return s.items!==void 0}function mr(s,e={}){var ae;const t=s.variant,n=s.presentation||(t==="create"?"modal":"drawer"),i={...gr,...s.labels},o=e.controls||ms(),a=s.events||{},l={...s.data||{}};let r={...s.context||{}},d=s.fields.map(S=>({...S})),c=(s.tabs||[]).map(S=>({...S})),p=s.items?[...s.items]:d.map(S=>({field:S.key})),h=s.blocks?[...s.blocks]:[],u=s.actions?[...s.actions]:C();const f=t==="create"?"new":"detail";let g=s.fieldState||"display",v=s.simpleMode??!1;const m=s.simpleKeep&&s.simpleKeep.length?new Set(s.simpleKeep):new Set(d.slice(0,1).map(S=>S.key));let w=s.open??!0,k=!1;function C(){return t==="create"?[{id:"continuous",kind:"checkbox",label:i.continuous},{id:"close-overlay",label:i.cancel,variant:"outline"},{id:"save-draft",label:i.draft,variant:"outline"},{id:"submit",kind:"submit",label:i.submit,variant:"primary"}]:[]}const b=S=>d.find(V=>V.key===S);function N(S,V,oe){var B,_,X;const de=Ve(S.visibleWhen,l,r)&&lt((B=S.permission)==null?void 0:B.view,r)&&(!V||Ve(V.visibleWhen,l,r))&&(!oe||Ve(oe.visibleWhen,l,r)&&lt(oe.visibleScope,r))&&(t!=="create"||S.createVisible!==!1),xe=!!S.required||(S.requiredWhen?Ve(S.requiredWhen,l,r):!1)||(V!=null&&V.requiredWhen?Ve(V.requiredWhen,l,r):!1)||((_=S.permission)!=null&&_.required?lt(S.permission.required,r):!1),F=S.editable!==!1&&lt((X=S.permission)==null?void 0:X.edit,r);return{visible:de,required:!!xe,editable:F}}function I(S){if(l[S.key]===void 0&&(S.defaultMode==="always"&&S.defaultValue!==void 0&&(l[S.key]=S.defaultValue),S.defaultMode==="conditional")){for(const V of S.defaultWhen||[])if(Ve(V.when,l,r)){l[S.key]=V.value;return}}}const E=document.createElement(t==="create"?"form":"article");t==="create"&&(E.noValidate=!0);const G=De(E,"form-surface",s);E.className=t==="create"?"rowvia-work-items rowvia-field-scope create-dialog form-surface":`rowvia-work-items rowvia-field-scope drawer form-surface${n==="fullscreen"?" is-fullscreen":""}`,E.dataset.variant=t,E.dataset.presentation=n,E.dataset.fieldState=g;let x=[];function T(){var xe,F,B,_,X,Y;for(const ee of x)ee.destroy();x=[],E.innerHTML="";const S=document.createElement("div");if(S.className="drawer-header",(xe=s.slots)!=null&&xe.leading){const ee=document.createElement("div");ee.className="drawer-leading",A(ee,s.slots.leading),S.append(ee)}if(S.insertAdjacentHTML("beforeend",`<span class="page-logo">${Re("check")}</span><strong>${D(s.title||"")}</strong>`),(F=s.slots)!=null&&F.header&&A(S,s.slots.header),E.append(S),(B=s.slots)!=null&&B.subHeader){const ee=document.createElement("div");ee.className="detail-sub-header",A(ee,s.slots.subHeader),E.append(ee)}if((_=s.slots)!=null&&_.navigation){const ee=document.createElement("div");ee.className="detail-navigation",A(ee,s.slots.navigation),E.append(ee)}const V=R();if(t==="detail"&&V.length){const ee=document.createElement("div");ee.className="detail-tabs",ee.setAttribute("role","tablist");for(const re of V){const ie=document.createElement("button");ie.type="button",ie.className=`detail-tab${re.id===P?" active":""}`,ie.dataset.tabId=re.id,ie.dataset.detailTab=re.label,ie.setAttribute("role","tab"),ie.setAttribute("aria-selected",String(re.id===P)),ie.textContent=re.label,ie.onclick=()=>se(re.id),ee.append(ie)}const ce=document.createElement("div");ce.className="spacer",ee.append(ce),(X=s.slots)!=null&&X.tabSuffix&&A(ee,s.slots.tabSuffix),E.append(ee)}const oe=document.createElement("div");oe.className=t==="create"?"create-body":"drawer-body",t==="create"&&s.simpleMode!==void 0&&oe.append(H());const de=V.find(ee=>ee.id===P);if(oe.append(L(de)),E.append(oe),(Y=s.slots)!=null&&Y.footer){const ee=document.createElement("div");ee.className="form-surface-slot-footer",A(ee,s.slots.footer),E.append(ee)}u.length&&E.append(q()),t==="create"&&(E.onsubmit=ee=>{var re,ie;if(ee.preventDefault(),k)return;const ce=Ee();if(ce){(re=a.onInvalid)==null||re.call(a,ce);return}(ie=a.onSubmit)==null||ie.call(a,me())})}function A(S,V){typeof V=="string"?S.insertAdjacentHTML("beforeend",V):S.append(V)}function H(){const S=document.createElement("div");return S.className="simple-mode",S.innerHTML=`<label><input type="checkbox" id="simple-mode"${v?" checked":""}>${D(i.simpleMode)}</label>`,S.querySelector("input").onchange=V=>Z(V.target.checked),S}function q(){const S=document.createElement("div");S.className=t==="create"?"drawer-footer":"drawer-footer form-surface-actions";for(const V of u){if(!Ve(V.visibleWhen,l,r))continue;if(V.kind==="checkbox"){const de=document.createElement("label");de.className="continuous",de.innerHTML=`<input id="${D(V.id)}" type="checkbox"${V.checked?" checked":""}>${D(V.label||"")}`,S.append(de);continue}if(V.kind==="submit"){const de=document.createElement("button");de.type="submit",de.className=V.variant||"primary",de.dataset.action=V.id,de.textContent=V.label||i.submit,S.append(de);continue}S.insertAdjacentHTML("beforeend",Ie(V.id,V.label||"",V.glyph||"",V.variant||""));const oe=S.lastElementChild;oe.onclick=()=>{var de;k||S.parentElement!==E||oe.disabled||((V.id==="close-overlay"||V.id==="cancel")&&a.onCancel?a.onCancel():V.id==="save-draft"&&a.onSaveDraft?a.onSaveDraft(me()):(de=a.onAction)==null||de.call(a,V.id,me()))}}return S}function R(){return c.filter(V=>Ve(V.visibleWhen,l,r)&&lt(V.visibleScope,r)).map((V,oe)=>({...V,order:V.order??oe})).sort((V,oe)=>V.order-oe.order)}let P=s.defaultTab||((ae=c[0])==null?void 0:ae.id);function L(S){var F;const V={data:l,context:r,variant:t,tab:S},oe=document.createElement("div");if(oe.className=t==="create"?"form-surface-body":"detail-fields form-surface-body",!S||S.kind==="form"){const B=(S==null?void 0:S.items)??p;for(const X of B){const Y=M(X,V);Y&&oe.append(Y)}const _=(S==null?void 0:S.blocks)??h;for(const X of _){const Y=j(X,V);Y&&oe.append(Y)}return oe}const de=S.kind==="custom"?S.render:((F=e.renderers)==null?void 0:F[S.kind])||S.render,xe=de?de(V):"";return typeof xe=="string"?oe.innerHTML=xe:xe&&oe.append(xe),oe}function M(S,V){if("field"in S)return z(S);const oe=vs(S)?$(S,V):j(S,V);return oe&&S.span!==1&&!(vs(S)&&S.layoutRole==="column")&&(oe.style.gridColumn="1 / -1"),oe}function $(S,V){var B;const oe=Ve(S.visibleWhen,l,r),de=S.layoutRole==="column";if(!oe&&!de)return null;const xe=[];for(const _ of oe?S.items:[]){const X=M(_,V);X&&xe.push(X)}if(!de&&!xe.some(_=>_.dataset.layoutRole!=="column"||_.childElementCount>0))return null;const F=document.createElement("section");if(F.className="form-group",F.dataset.group=S.id,de)return F.className="form-layout-column",F.dataset.layoutRole="column",F.append(...xe),F;if(S.columns===2&&!v){F.classList.add("form-group--columns");const _=((B=S.columnRatio)==null?void 0:B.length)===2&&S.columnRatio.every(X=>Number.isFinite(X)&&X>0)?S.columnRatio:[1,1];F.style.display="grid",F.style.gridTemplateColumns=_.map(X=>`minmax(0, ${X}fr)`).join(" "),F.style.columnGap="24px"}return F.innerHTML=`<p class="form-group-title">${D(S.label)}</p>`,F.firstElementChild.style.gridColumn="1 / -1",F.append(...xe),F}function z(S){var X;const V=b(S.field);if(!V)return null;const oe=N(V,S,ue());if(!oe.visible||v&&!m.has(V.key))return null;I(V);const de=document.createElement("div");de.className=t==="create"?"create-field":"detail-row",de.dataset.field=V.key,S.span===2&&(de.classList.add("span-2"),de.style.gridColumn="1 / -1"),(S.labelPosition||((X=s.layout)==null?void 0:X.labelPosition)||"side")==="top"&&de.classList.add("label-top");const F=oe.required,B=t==="create"?"<em>*</em>":" *";de.innerHTML=`<label for="${f}-${D(V.key)}">${D(V.label)}${F?B:""}</label><div class="field-value"><div class="fc-host" data-control-field="${D(V.key)}" data-control-mode="${t}"></div>`+(V.description?`<small class="field-description">${D(V.description)}</small>`:"")+"</div>";const _=de.querySelector(".fc-host");return be(_,{...V,required:F},F),de}function j(S,V){var xe;if(!Ve(S.visibleWhen,l,r)||v&&!m.has(S.id))return null;const oe=(xe=e.renderers)!=null&&xe.block?e.renderers.block({...V,block:S}):S.render?S.render(V):te(S,V),de=document.createElement("div");return de.className=`form-surface-block block-${S.kind}`,de.dataset.block=S.id,typeof oe=="string"?de.innerHTML=oe:oe&&de.append(oe),de}function te(S,V){var oe,de;if(S.kind==="roles"){const xe=document.createElement("div");xe.className=t==="create"?"create-field":"detail-row",xe.innerHTML=`<label>${D(S.label||"角色与人员")}${(oe=S.requiredRoles)!=null&&oe.length?"<em>*</em>":""}</label><div class="role-body"><div class="role-rows"></div><div class="role-actions">${Ie("add-role",i.addRole,"","outline")}</div></div>`;const F=xe.querySelector(".role-rows"),B=(de=S.roleOptions)!=null&&de.length?S.roleOptions:["提报人"],_=S.people??[],X=()=>{const ce=Array.isArray(l.roles)?l.roles:[];return ce.length||ce.push({name:B[0],person:String(l.owner??V.context.currentUser??"")}),l.roles=ce,ce};let Y=[];const ee=()=>{for(const re of Y)re.destroy(),x=x.filter(ie=>ie!==re);Y=[],F.replaceChildren();const ce=X();ce.forEach((re,ie)=>{const J=document.createElement("div");J.className="role-line";const ne=document.createElement("div");ne.className="fc-host role-select";const he=document.createElement("div");if(he.className="fc-host role-person",J.append(ne,he),ce.length>1){const pe=document.createElement("button");pe.type="button",pe.className="role-remove",pe.dataset.roleRemove=String(ie),pe.setAttribute("aria-label","移除角色"),pe.textContent="×",J.append(pe)}F.append(J),Y.push(be(ne,{key:`role-${ie}`,label:"角色",kind:"select",options:B,editable:!0},!1,{get:()=>re.name,set:pe=>{re.name=String(pe??"")},notify:()=>{var pe;return(pe=a.onCommit)==null?void 0:pe.call(a,"roles",X(),l)}}),be(he,{key:`role-person-${ie}`,label:"人员",kind:"person",options:_.map(pe=>pe.id),choices:_,editable:!0},()=>{var pe;return!!((pe=S.requiredRoles)!=null&&pe.includes(re.name))},{get:()=>re.person,set:pe=>{re.person=String(pe??"")},notify:()=>{var pe,Se;ie===0&&(l.owner=re.person,(pe=a.onCommit)==null||pe.call(a,"owner",re.person,l)),(Se=a.onCommit)==null||Se.call(a,"roles",X(),l)}}))})};return ee(),xe.addEventListener("click",ce=>{var J,ne,he;const re=ce.target,ie=re.closest("[data-role-remove]");if(ie){const pe=X();pe.splice(Number(ie.dataset.roleRemove),1),pe.length||pe.push({name:B[0],person:""}),l.owner=((J=pe[0])==null?void 0:J.person)??"",ee(),(ne=a.onChange)==null||ne.call(a,"roles",pe,l);return}if(re.closest('[data-action="add-role"]')){const pe=X();pe.push({name:B.find(Se=>!pe.some(ke=>ke.name===Se))??B[0],person:""}),ee(),(he=a.onChange)==null||he.call(a,"roles",pe,l)}}),xe}if(S.kind==="meetings"){const xe=document.createElement("section");return xe.className="detail-section",xe.innerHTML=`<p>${D(S.label||"进入选题会")}</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${Ie("add-meeting",i.addMeeting,"add")}</div>`,xe}return""}function ue(){return R().find(S=>S.id===P)}function ge(S,V,oe){return{field:S,value:oe?oe.get():l[S.key]??S.defaultValue??"",item:l,surface:t==="create"?"create":"detail",page:"basic",mode:"default",canEdit:V,readonly:!V,services:e.services,onSelectedOptions:xe=>{(B=>{B.choices=[...new Map([...B.choices||(B.options||[]).map(_=>({id:_,label:_})),...xe].map(_=>[_.id,_])).values()]})(S)},openDetail:xe=>{var F;return(F=a.onOpenDetail)==null?void 0:F.call(a,xe)}}}function be(S,V,oe,de){var we;const xe=()=>typeof oe=="function"?oe():oe,F=V.editable!==!1&&lt((we=V.permission)==null?void 0:we.edit,r),B=ge(V,F,de),_=o.resolve(V),X=["radio","switch","attitudeVote","singleVote","multiVote"].includes(_.id),Y=_.createEditor(B),ee="input,select,textarea,[role=textbox]",ce=[Y.content,Y.element].filter(le=>!!le).map(le=>le.matches(ee)?le:le.querySelector(ee)).find(Boolean);ce&&(ce.id=`${f}-${V.key}`);const re=document.createElement("div");re.className="fc-error",re.setAttribute("role","status");const ie=document.createElement("div");ie.className="fc-detail-editor",ie.dataset.mode="editing",ie.dataset.box=It(_),ie.append(Y.element),S.classList.add("fc-detail-host"),S.classList.toggle("fc-direct-control",X),S.dataset.page="basic",S.dataset.mode="default",S.dataset.surface=t==="create"?"create":"detail",S.append(ie,re);const J=document.createElement("div");J.className="fc-detail-preview",J.dataset.box=It(_),J.dataset.editable=String(F),J.dataset.surface=t==="create"?"create":"detail",S.prepend(J);const ne=()=>{if(!S.classList.contains("editing")){S.style.minHeight="";return}S.style.minHeight=`${ie.offsetHeight}px`},he=le=>{ie.style.minHeight=`${le}px`,ie.style.maxHeight=`${le}px`},pe=()=>{ie.style.maxHeight="",ne()},Se=It(_)==="rich",ke=()=>{var Te,dt,Ft;if(X){(Te=Y.focus)==null||Te.call(Y);return}if(!F||S.classList.contains("editing"))return;const le=J.offsetHeight;S.classList.add("editing"),S.dataset.mode="editing",Se||he(le),ne(),(dt=Y.focus)==null||dt.call(Y),(Ft=a.onFieldStateChange)==null||Ft.call(a,V.key,"edit")},ve=()=>{if(X){J.hidden=!0;return}if(J.replaceChildren(_.render({...ge(V,F,de),readonly:!0,canEdit:!1,mode:"default",value:de?de.get():l[V.key]??""})),J.dataset.box==="select"){const le=document.createElement("span");le.className="fc-field-chevron",le.setAttribute("aria-hidden","true"),J.append(le)}if(F){J.tabIndex=0,J.setAttribute("role","button"),J.setAttribute("aria-label",`编辑${V.label}`),J.onclick=Te=>{Te.target.closest("a,button,input,textarea,select")||ke()},J.onkeydown=Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),ke())};const le=document.createElement("button");le.type="button",le.className="fc-detail-edit",le.tabIndex=-1,le.textContent="编辑",le.ariaLabel=`编辑${V.label}`,le.onclick=Te=>{Te.stopPropagation(),ke()},J.append(le)}else J.removeAttribute("role"),J.removeAttribute("tabindex"),J.onclick=null,J.onkeydown=null};ve();const Ne=()=>{var Te;const le=xe()&&!fe(Y.read())?i.required:(Te=Y.validate)==null?void 0:Te.call(Y);return re.textContent=le||"",S.classList.toggle("is-error",!!le),le},st=()=>{var Te,dt,Ft;if(!F)return!0;const le=Ne();if(le&&pe(),!le){const Ct=Y.read(),Cr=de?de.get():l[V.key];JSON.stringify(Cr)!==JSON.stringify(Ct)&&(de?(de.set(Ct),(Te=de.notify)==null||Te.call(de,Ct)):(l[V.key]=Ct,(dt=a.onCommit)==null||dt.call(a,V.key,Ct,l))),(Ft=a.onChange)==null||Ft.call(a,V.key,Ct,l),ve()}return!le},At=()=>{var le;S.classList.remove("editing"),S.dataset.mode="default",S.style.minHeight="",ie.style.minHeight="",ie.style.maxHeight="",(le=a.onFieldStateChange)==null||le.call(a,V.key,"display")};S.addEventListener("input",()=>{var le;pe(),(le=a.onChange)==null||le.call(a,V.key,Y.read(),l)}),S.addEventListener("pointerdown",()=>{S.classList.contains("editing")&&pe()},!0),S.addEventListener("mousedown",le=>{var Te;_.id!=="richText"||!S.classList.contains("editing")||le.target.closest("button,a,input,textarea,select,[contenteditable=true]")||(le.preventDefault(),!S.contains(document.activeElement)&&!Xe(document.activeElement,S)&&((Te=Y.focus)==null||Te.call(Y)))}),S.addEventListener("change",()=>{pe(),st()}),S.addEventListener("fc-collapse",()=>{st(),At(),ve()}),S.addEventListener("focusout",le=>{X||le.relatedTarget instanceof Node&&(S.contains(le.relatedTarget)||Xe(le.relatedTarget,S))||queueMicrotask(()=>{if(!(k||!S.isConnected)){if(S.contains(document.activeElement)||Xe(document.activeElement,S)){ne();return}st(),At(),ve()}})}),(V.defaultState||g)==="edit"&&F&&queueMicrotask(()=>{k||ke()});const $t={key:V.key,host:S,editor:Y,editable:F,check:Ne,commit:st,beginEdit:ke,write:le=>{de?de.set(le):l[V.key]=le},destroy:()=>{var le;return(le=Y.destroy)==null?void 0:le.call(Y)}};return x.push($t),$t}const fe=S=>Array.isArray(S)?S.length>0:S!=null&&String(S).trim()!=="";function me(){for(const S of x)S.editable&&S.write(S.editor.read());return{...l}}function Ee(){let S;for(const V of x){if(!V.editable)continue;const oe=V.check();oe&&S===void 0&&(S=oe,V.beginEdit())}return S}function Me(S){w=S,E.hidden=!S,E.dataset.open=String(S)}function U(S){g=S,E.dataset.fieldState=S;for(const V of x)S==="edit"?V.beginEdit():V.host.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))}function se(S){var oe;if(S===P||!R().some(de=>de.id===S))return;P=S;const V=ue();T(),V&&((oe=a.onTabChange)==null||oe.call(a,S,V))}function Z(S){me(),v=S,T()}function W(S){S.data&&Object.assign(l,S.data),S.fields&&(d=S.fields.map(V=>({...V}))),S.tabs&&(c=S.tabs.map(V=>({...V}))),S.items&&(p=[...S.items]),S.blocks&&(h=[...S.blocks]),S.actions&&(u=[...S.actions]),S.context&&(r={...S.context}),T()}function Q(){var S;if(!k){k=!0,(S=a.onDestroy)==null||S.call(a),G.destroy(),E.onsubmit=null;for(const V of x)V.destroy();x=[],E.remove()}}return T(),Me(w),{element:E,onInteraction:G.onInteraction,read:me,validate:Ee,setOpen:Me,setFieldState:U,setTab:se,setSimpleMode:Z,activeTab:()=>P,update:W,destroy:Q}}function vr(s){const e=O("div",s.className??"tag");return s.marker?e.append(s.marker):s.markerClassName&&e.append(O("span",s.markerClassName)),e.append(O("span","",s.label)),e}function wr(s){const e=O("div",s.className);if(s.leading)e.append(s.leading);else if(s.image){const n=O("img");n.src=s.image.src,n.alt=s.image.alt,e.append(n)}const t=s.inline?e:O("div",s.contentClassName);return t.append(O(s.titleTag??"span",s.titleClassName,s.title)),s.description!==void 0&&t.append(O(s.descriptionTag??"span",s.descriptionClassName,s.description)),s.inline||e.append(t),e}function yr(s,e){Vt[s]=e}function br(s,e){et[s]=e}K.ActionField=hs,K.AttachmentField=ls,K.BaseField=Be,K.BaseFieldControl=it,K.CELL_EDITORS=et,K.CELL_RENDERERS=Vt,K.COMPLETION_LABEL=ui,K.CascadeField=Tn,K.ChoiceField=yt,K.CompositeField=ps,K.ComputedField=bt,K.CustomField=$n,K.DEFAULT_LOCALE_TEXT=Wn,K.DateField=In,K.DateRangeField=as,K.DateTimeField=Nn,K.EmailField=Ji,K.FORMULA_FUNCTIONS=Pt,K.GANTT_UNITS=oi,K.GanttChart=li,K.Grid=ht,K.LinkField=Mn,K.LocationField=ds,K.MultiCascadeField=os,K.MultiChoiceField=ts,K.MultiPersonField=is,K.MultiRelationField=ss,K.MultiVoteField=us,K.NumberField=Xi,K.PersonField=Rn,K.PhoneField=es,K.RadioField=ns,K.RelationField=Ln,K.RichTextField=Zi,K.STATUS_META=gt,K.SignalField=An,K.SingleVoteField=cs,K.SwitchField=rs,K.TextField=Ze,K.TextareaField=Qi,K.UNIT_LABEL=qt,K.VoteField=Yt,K.adaptOperationRecords=Pa,K.allGatesMet=hi,K.computeStickyGroupRows=ti,K.createControlRegistry=ms,K.createDetailComments=Da,K.createDetailDialog=ii,K.createDetailHistory=Va,K.createFieldRegistry=fs,K.createFlowCanvas=mi,K.createFlowContextBar=yi,K.createGantt=da,K.createGrid=ni,K.createMediaCell=wr,K.createNodeCard=vi,K.createNodeFlow=Ca,K.createNodeTimeline=bi,K.createPersonnelSchedule=Ma,K.createSparklineSvg=en,K.createTagCell=vr,K.createWorkItemColumnPanels=ja,K.createWorkItemColumns=Ua,K.createWorkItemDetailHeader=Za,K.createWorkItemFormSurface=mr,K.createWorkItemHeaderDecorator=Ka,K.createWorkItemLayers=Qa,K.createWorkItemRulePanels=Ya,K.createWorkItemSelectionBar=_a,K.createWorkItemTable=Wa,K.createWorkItemTabs=qa,K.createWorkItemToolbar=za,K.createWorkflowDetail=Na,K.default=ht,K.emptyView=Ga,K.escapeHtml=D,K.evalFormCondition=Ve,K.evalFormScope=lt,K.evaluateFormula=xt,K.evaluateGates=rn,K.formatNumberCommas=Ue,K.groupNodes=fi,K.historyModules=mn,K.isFormula=Qt,K.matchNodes=ln,K.matches=Bi,K.normalizeHistory=Hi,K.parse=Hn,K.queryHistory=Oi,K.registerEditor=br,K.registerFormulaFunction=Ss,K.registerRenderer=yr,K.renderContent=En,K.sanitizeRichText=wt,K.showTip=wi,K.summarize=pi,K.tokenize=Dn,K.videoFlow=Ea,Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});