rowvia 0.2.1 → 0.2.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,46 +1,46 @@
1
- (function(re,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(re=typeof globalThis<"u"?globalThis:re||self,$e(re.Rowvia={}))})(this,function(re){"use strict";var fa=Object.defineProperty;var ma=(re,$e,rt)=>$e in re?fa(re,$e,{enumerable:!0,configurable:!0,writable:!0,value:rt}):re[$e]=rt;var v=(re,$e,rt)=>ma(re,typeof $e!="symbol"?$e+"":$e,rt);class $e{constructor(){v(this,"listeners",new Map)}addEventListener(e,t){let i=this.listeners.get(e);i||(i=[],this.listeners.set(e,i)),i.push(t)}removeEventListener(e,t){const i=this.listeners.get(e);if(!i)return;const n=i.indexOf(t);n>=0&&i.splice(n,1)}dispatchEvent(e,t){const i=this.listeners.get(e);if(!i||i.length===0)return;const n={type:e,...t||{}};for(const o of i.slice())o(n)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const rt=13,Dn=27,Ri=9,Mi=8,ki=46,An=36,Fn=35;function Et(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let Pn=0;function ti(s="id"){return`${s}-${++Pn}`}function Ke(s,e){if(typeof s!="number"||isNaN(s))return String(s??"");const t=e??0,i=s.toFixed(t),[n,o]=i.split("."),a=n.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${a}.${o}`:a}function ii(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function $n(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(),i=String(e).toLowerCase();return t<i?-1:t>i?1:0}function Gn(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ge extends Error{constructor(e){super(e),this.code=e}}const Hn=/^\$?[A-Za-z]{1,3}\$?\d+$/;function Ti(s){const e=[];let t=0;for(;t<s.length;){const i=s[t];if(i===" "||i===" "||i===`
2
- `||i==="\r"){t++;continue}if(i==='"'||i==="'"){const o=i;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(i)||i==="."&&/[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(i)){let o="";for(;t<s.length&&/[A-Za-z0-9_$.]/.test(s[t]);)o+=s[t++];Hn.test(o)?e.push({type:"cell",value:o.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:o});continue}if(i==="("){e.push({type:"lparen",value:i}),t++;continue}if(i===")"){e.push({type:"rparen",value:i}),t++;continue}if(i===","||i===";"){e.push({type:"comma",value:","}),t++;continue}const n=s.slice(t,t+2);if(["<=",">=","<>"].includes(n)){e.push({type:"op",value:n}),t+=2;continue}if("+-*/^%&=<>,:".includes(i)){e.push({type:"op",value:i}),t++;continue}throw new Ge("#NAME?")}return e}const Ni={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function Ii(s){let e=0;const t=()=>s[e],i=()=>s[e++];function n(l=0){let c=o();for(;t()&&t().type==="op"&&Ni[t().value]>=l;){const d=i().value,u=n(Ni[d]+1);c={type:"binary",operator:d,left:c,right:u}}return c}function o(){const l=t();if(l&&l.type==="op"&&(l.value==="-"||l.value==="+")){i();const c=o();return l.value==="-"?{type:"unary",operator:"-",operand:c}:c}return a()}function a(){const l=i();if(!l)throw new Ge("#ERROR!");if(l.type==="number")return{type:"number",value:Number(l.value)};if(l.type==="string")return{type:"string",value:l.value};if(l.type==="cell")return{type:"cell",value:l.value};if(l.type==="ident"){const c=l.value.toUpperCase();if(c==="TRUE")return{type:"boolean",value:!0};if(c==="FALSE")return{type:"boolean",value:!1};const d=t();if(d&&d.type==="lparen"){i();const u=[];if(t()&&t().type!=="rparen")for(u.push(n());t()&&t().type==="comma";)i(),u.push(n());if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return i(),{type:"call",name:c,args:u}}return{type:"ref",value:l.value}}if(l.type==="lparen"){const c=n();if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return i(),c}throw new Ge("#ERROR!")}const r=n();if(e<s.length)throw new Ge("#ERROR!");return r}function ce(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 ft(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...ft(t));else if(t!=null&&t!==""){const i=typeof t=="number"?t:Number(t);isNaN(i)||e.push(i)}return e}const Gt={SUM:s=>ft(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=ft(s);return e.length?e.reduce((t,i)=>t+i,0)/e.length:0},AVG:s=>Gt.AVERAGE(s,{}),MIN:s=>{const e=ft(s);return e.length?Math.min(...e):0},MAX:s=>{const e=ft(s);return e.length?Math.max(...e):0},COUNT:s=>ft(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(ce(s[0])),ROUND:s=>{const e=s.length>1?ce(s[1]):0,t=Math.pow(10,e);return Math.round(ce(s[0])*t)/t},FLOOR:s=>Math.floor(ce(s[0])),CEIL:s=>Math.ceil(ce(s[0])),CEILING:s=>Math.ceil(ce(s[0])),SQRT:s=>{const e=ce(s[0]);return e<0?(()=>{throw new Ge("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(ce(s[0]),ce(s[1])),POW:s=>Math.pow(ce(s[0]),ce(s[1])),MOD:s=>{const e=ce(s[1]);if(e===0)throw new Ge("#DIV/0!");return ce(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?ce(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?ce(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,ce(s[1])-1),i=s.length>2?ce(s[2]):e.length-t;return e.slice(t,t+i)},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=>ce(s[0]),NUMBER:s=>ce(s[0]),BETWEEN:s=>ce(s[0])>=ce(s[1])&&ce(s[0])<=ce(s[2])},Ht=Object.keys(Gt);function On(s,e){Gt[s.toUpperCase()]=e,Ht.includes(s.toUpperCase())||Ht.push(s.toUpperCase())}function Bn(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 Vn(s,e){const t=e.data||{};if(s in t)return t[s];const i=s.toLowerCase();for(const n of Object.keys(t))if(n.toLowerCase()===i)return t[n]}function Rt(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return Vn(s.value,e);case"cell":return Bn(s.value,e);case"unary":return-ce(Rt(s.operand,e));case"call":{const t=Gt[s.name];if(!t)throw new Ge("#NAME?");const i=s.args.map(n=>Rt(n,e));return t(i,e)}case"binary":{const t=Rt(s.left,e),i=Rt(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:ce(t)+ce(i);case"-":return ce(t)-ce(i);case"*":return ce(t)*ce(i);case"/":{const n=ce(i);if(n===0)throw new Ge("#DIV/0!");return ce(t)/n}case"^":return Math.pow(ce(t),ce(i));case"%":{const n=ce(i);if(n===0)throw new Ge("#DIV/0!");return ce(t)%n}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return ce(t)<ce(i);case"<=":return ce(t)<=ce(i);case">":return ce(t)>ce(i);case">=":return ce(t)>=ce(i);default:throw new Ge("#ERROR!")}}default:throw new Ge("#ERROR!")}}function Mt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,i=Ii(Ti(t));return Rt(i,e)}function ni(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function oi(s,e){if(s==null)return;if(e in s)return s[e];const t=e.split(".");let i=s;for(const n of t){if(i==null)return;i=i[n]}return i}function de(s,e,t){const i=s.colDef,n=(e.group||e.footer)&&!!e.groupData&&e.groupData[s.colId]!==void 0,o=n?e.groupData:e.data,a=s.valueGetter??i.valueGetter;if(a)return(typeof a=="string"?l=>ni(a)?Mt(a,{data:l.data}):oi(l.data,a):a)({data:n?e.groupData:e.data,node:e,column:s,api:t,colDef:i,getValue:l=>oi(n?e.groupData:e.data,l)});if(s.field&&ni(s.field))return Mt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return Mt(`=${s.field}`,{data:e.data});if(s.field)return oi(o,s.field)}function Ot(s,e,t){var o;let i=de(s,e,t);const n=s.colDef;if(n.showValueAs&&typeof i=="number"&&t){const a=(o=t.__columnTotalCache)==null?void 0:o.get(s.colId);if(a!==void 0&&a!==0)return`${(n.showValueAs==="percentOfParent"?i/(a||1)*100:i/a*100).toFixed(1)}%`}return n.valueFormatter?(typeof n.valueFormatter=="string"?r=>zn(r.colDef.valueFormatter,r.value,r):n.valueFormatter)({value:i,data:e.data,node:e,column:s,api:t,colDef:n}):Wn(s,i)}function zn(s,e,t={}){var i,n,o;if(e==null)return"";switch(s){case"number":return Ke(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${Ke(e,((n=t.column)==null?void 0:n.decimals)??2)}`;case"percent":return`${Ke(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Li(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Li(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 Wn(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?Ke(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Li(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Di(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?i=>Ai(i.colDef.valueParser,i.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Ai(s.type,e)}function Ai(s,e){if(s==="numberColumn")return ii(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 Fi(s){const t=s.colDef.comparator,i=s.type;return(n,o)=>{const a=de(s,n,null),r=de(s,o,null);if(t)return t(a,r,n,o);if(i==="numberColumn"){const l=typeof a=="number"?a:ii(a),c=typeof r=="number"?r:ii(r);return l!==null&&c!==null?l-c:l===null&&c===null?0:l===null?-1:1}if(i==="dateColumn"){const l=a instanceof Date?a.getTime():new Date(a).getTime(),c=r instanceof Date?r.getTime():new Date(r).getTime();if(!isNaN(l)&&!isNaN(c))return l-c}return $n(a,r)}}function kt(s,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:s,rowNode:null,data:null});const i=t.filter(n=>typeof n=="number"&&!isNaN(n));switch(e){case"sum":return i.reduce((n,o)=>n+o,0);case"count":return t.length;case"avg":return i.length?i.reduce((n,o)=>n+o,0)/i.length:null;case"min":return i.length?Math.min(...i):null;case"max":return i.length?Math.max(...i):null;case"first":return t.length?t[0]:null;case"last":return t.length?t[t.length-1]:null;default:return null}}const Un={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 _n(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 qn(s){return!!s.treeData}function Kn(){return{applyAggregate:kt}}class Pi{constructor(e,t,i){v(this,"options");v(this,"eventService");v(this,"gridApi");v(this,"measureCtx",null);v(this,"gridColumnDefs",[]);v(this,"columns",[]);v(this,"displayOrder",[]);v(this,"autoGroupColumnDef");v(this,"pivotMode",!1);v(this,"columnGroups",[]);v(this,"openGroups",new Set);v(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=i,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=$i){if(!e||e.length===0)return[];const i=e[0];if(!i||typeof i!="object")return[];const n=new Set(["children","detail","__proto__"]),o=[];for(const a of Object.keys(i)){if(n.has(a)||a.startsWith("__"))continue;const r=i[a],l={field:a,headerName:t(a)};typeof r=="number"?(l.type="numberColumn",l.filter="number"):typeof r=="boolean"?l.type="booleanColumn":r instanceof Date&&(l.type="dateColumn"),o.push(l)}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 d of e)t.set(d.colId,d);const i=this.options.defaultColDef||{},n={...Un,...this.options.columnTypes||{}},o=[],a=[];let r=0;const l=(d,u)=>{const f=d.colId||d.field||ti("col"),g={...i,...d};if(g.type&&n[g.type]){const p=n[g.type],C=new Set(Object.keys(d));for(const[h,m]of Object.entries(p))!C.has(h)&&!(h in i)&&(g[h]=m)}this.pushColumnInto(o,g,f,r++,t,u)},c=(d,u,f)=>{for(const g of d)if(g.children&&g.children.length){const p=g.groupId||ti("group"),C={id:p,headerName:g.headerName??"",openByDefault:g.openByDefault===!0||g.columnGroupShow==="open",parentId:u,depth:f,childColumnIds:[]};a.push(C),this.groupsInitialised||(C.openByDefault?this.openGroups.add(p):this.openGroups.delete(p)),c(g.children,p,f+1)}else l(g,u)};if(c(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,this.options.rowNumbers){const d={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,{...i,...d},"__rowNumber",-1,t,null)}for(const d of o){if(!d.groupId)continue;const u=a.find(f=>f.id===d.groupId);u&&u.childColumnIds.push(d.colId)}this.columns=o,this.displayOrder=o.map(d=>d.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,i,n,o){return this.buildColumn(e,t,i,n,o)}pushColumnInto(e,t,i,n,o,a){e.push(this.buildColumn(t,i,n,o,a))}buildColumn(e,t,i,n,o){const a=n.get(t),r=e.hide===!0||e.initialHide===!0,l={colId:t,field:e.field,headerName:e.headerName??(e.field?$i(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:r,visible:!r,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:_n(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:i,filterActive:!1,left:0,groupId:o};return a&&(l.pinned=a.pinned,l.visible=a.visible,l.width=a.width,l.flex=a.flex,l.sort=a.sort,l.sortIndex=a.sortIndex,l.rowGroup=a.rowGroup,l.rowGroupIndex=a.rowGroupIndex,l.pivot=a.pivot,l.pivotIndex=a.pivotIndex),l}updatePivotColumns(e){if(this.columns=this.columns.filter(l=>!l.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(l=>!l.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const i=this.getColumns().filter(l=>l.aggFunc&&!l.rowGroup&&!l.pivot),n=[];for(const l of t){const c=[],d=new Set;for(const u of e){const f=u==null?void 0:u[l.field],g=String(f);d.has(g)||(d.add(g),c.push(f))}c.sort((u,f)=>u===f?0:String(u)<String(f)?-1:1);for(const u of i){for(const p of c){const C=`__pivot_${l.colId}_${u.colId}_${p}`,h=this.createColumn({colId:C,headerName:`${String(p)}`,width:130,type:u.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:u.cellClass,cellDataType:u.cellDataType},C,-1,new Map,null);h.aggFunc=u.aggFunc,h.groupId=l.colId,h.__pivot={pivotColumnId:l.colId,pivotField:l.field,pivotValue:p,valueColumnId:u.colId,valueField:u.field},h.valueGetter=m=>this.evaluatePivotValue(h,m.node),n.push(h)}const f=`__pivot_${l.colId}_${u.colId}_total`,g=this.createColumn({colId:f,headerName:"Total",width:130,type:u.type,sortable:!1,filter:!1,cellDataType:u.cellDataType},f,-1,new Map,null);g.aggFunc=u.aggFunc,g.groupId=l.colId,g.__pivot={pivotColumnId:l.colId,pivotField:l.field,pivotValue:void 0,valueColumnId:u.colId,valueField:u.field},g.valueGetter=p=>this.evaluatePivotValue(g,p.node),n.push(g)}}const o=new Set(t.map(l=>l.colId)),a=this.columns.reduce((l,c,d)=>o.has(c.groupId??"")?l:d,0);this.columns.splice(a+1,0,...n);for(const l of n)this.displayOrder.push(l.colId);const r=new Set(this.columnGroups.map(l=>l.id));for(const l of t)r.has(l.colId)||this.columnGroups.push({id:l.colId,headerName:l.headerName||l.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const i=e.__pivot;if(!i||!t)return;const n=[],o=d=>{if(!d.children||d.children.length===0){n.push(d);return}for(const u of d.children)o(u)};o(t);const r=(i.pivotValue===void 0?n:n.filter(d=>{var u;return String((u=d.data)==null?void 0:u[i.pivotField])===String(i.pivotValue)})).map(d=>{var u;return(u=d.data)==null?void 0:u[i.valueField]}).filter(d=>typeof d=="number");if(r.length===0)return null;const l=this.columns.find(d=>d.colId===i.valueColumnId),{applyAggregate:c}=Kn();return c(l,e.aggFunc,r)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,i=this.getRowGroupColumns(),n=this.options.groupDisplayType||"singleColumn",o=t||i.length>0&&n!=="multipleColumns";for(const d of i)n==="multipleColumns"?(d.cellRenderer="agGroupCellRenderer",d.cellRendererParams={...d.cellRendererParams||{},suppressCount:!0}):d.cellRenderer==="agGroupCellRenderer"&&!d.colDef.cellRenderer&&(d.cellRenderer=void 0,d.cellRendererParams=void 0);const a=this.columns.find(d=>d.colId===e);if(!o){a&&(this.columns=this.columns.filter(d=>d.colId!==e),this.displayOrder=this.displayOrder.filter(d=>d!==e));return}const r={...this.autoGroupColumnDef};if(r.colId=e,a)a.headerName=r.headerName??"",a.colDef=r,a.cellRenderer=r.cellRenderer,a.cellRendererParams=r.cellRendererParams,a.width=r.width??a.width,a.minWidth=r.minWidth??a.minWidth,a.pinned=r.pinned??"left";else{const d=this.createColumn(r,e,-2,new Map,null);this.columns.unshift(d),this.displayOrder.unshift(e)}const l=this.columns.find(d=>d.colId===e),c=()=>this.getRowGroupColumns()[0];l.valueGetter=d=>{const u=d.node;if(!u)return"";if(u.key!==null&&u.key!==void 0)return u.key;if(qn(this.options))return"";const f=c();return f!=null&&f.field&&u.data?u.data[f.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 i=this.columnGroups.find(n=>n.id===t);t=(i==null?void 0:i.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(i=>i.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 i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())i.includes(n)||(n.rowGroup=!1,n.rowGroupIndex=null);i.forEach((n,o)=>{n.rowGroup=!0,n.rowGroupIndex=o,n.pivot=!1,n.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:i}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,t="api"){const i=this.getColumn(e);if(!i)return;const n=this.getRowGroupColumns();i.rowGroup=!0,i.rowGroupIndex=n.length,i.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,t="api"){const i=this.getColumn(e);if(!i)return;i.rowGroup=!1,i.rowGroupIndex=null,this.getRowGroupColumns().forEach((o,a)=>o.rowGroupIndex=a),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())i.includes(n)?n.aggFunc||(n.aggFunc="sum"):n.aggFunc&&!n.rowGroup&&(n.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:i}),this.refreshAll()}addValueColumn(e,t="sum",i="api"){const n=this.getColumn(e);n&&(n.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:i,columns:[n]}),this.refreshAll())}setPivotColumns(e,t="api"){const i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())n.pivot=i.includes(n),n.pivotIndex=i.includes(n)?i.indexOf(n):null;this.refreshAll()}setColumnVisible(e,t,i="api"){const n=this.getColumn(e);!n||n.visible===t||(n.hide=!t,n.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:n,visible:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll())}setColumnsVisible(e,t,i="api"){for(const n of e)this.setColumnVisible(n,t,i)}setColumnPinned(e,t,i="api"){const n=this.getColumn(e);n&&(n.lockPosition&&t!==n.pinned||(n.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:n,pinned:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll()))}setColumnsPinned(e,t,i="api"){for(const n of e)this.setColumnPinned(n,t,i)}moveColumn(e,t,i="api"){const n=this.getColumn(e);n&&this.moveColumnByIndex(this.displayOrder.indexOf(n.colId),t,i)}moveColumnByIndex(e,t,i="api"){const n=this.displayOrder.slice();if(e<0||e>=n.length)return;const[o]=n.splice(e,1);n.splice(Math.max(0,Math.min(n.length,t)),0,o),this.displayOrder=n;const a=this.getColumn(o);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:a,toIndex:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),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 i of e){const n=this.getColumn(i.colId);n&&(i.hide!==void 0&&(n.hide=i.hide,n.visible=!i.hide),i.pinned!==void 0&&(n.pinned=i.pinned),i.width!==void 0&&(n.width=i.width),i.flex!==void 0&&(n.flex=i.flex),i.sort!==void 0&&(n.sort=i.sort),i.sortIndex!==void 0&&(n.sortIndex=i.sortIndex),i.rowGroupIndex!==void 0&&(n.rowGroup=i.rowGroupIndex!==null,n.rowGroupIndex=i.rowGroupIndex),i.pivotIndex!==void 0&&(n.pivot=i.pivotIndex!==null,n.pivotIndex=i.pivotIndex),i.aggFunc!==void 0&&(n.aggFunc=i.aggFunc))}if(t){const i=new Map(e.map(o=>[o.colId,o.colId])),n=this.displayOrder.filter(o=>!i.has(o));this.displayOrder=[...e.map(o=>o.colId).filter(o=>this.getColumn(o)),...n]}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 i=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const n of i){let a=0,r=0;for(const c of n)t.includes(c.colId)?r+=c.width:c.flex!==null&&c.flex>0?a+=c.flex:r+=c.width;const l=Math.max(0,e-r-32);if(a>0){for(const c of n)if(c.flex!==null&&c.flex>0&&!t.includes(c.colId)){const d=Math.max(c.minWidth,Math.floor(l*c.flex/a));c.width=Math.min(c.maxWidth,d)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var r,l,c,d,u,f;const i=this.getColumn(e);if(!i)return;let n=this.measureTextWidth(i.headerName)+32;t||(n+=16);const o=((l=(r=this.gridApi)==null?void 0:r.getDisplayedRowCount)==null?void 0:l.call(r))??0,a=Math.min(o,300);for(let g=0;g<a;g++){const p=(d=(c=this.gridApi)==null?void 0:c.getDisplayedRowAtIndex)==null?void 0:d.call(c,g);if(!p)continue;const C=(f=(u=this.gridApi)==null?void 0:u.getCellText)==null?void 0:f.call(u,i,p);C&&(n=Math.max(n,this.measureTextWidth(C)+32))}i.width=Math.max(i.minWidth,Math.min(i.maxWidth,Math.ceil(n))),i.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:i,finished:!0})}autoSizeAllColumns(e=!1){for(const t of this.getDisplayedColumns())this.autoSizeColumn(t,e)}}function $i(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class tt{constructor(e,t,i){v(this,"id");v(this,"__id");v(this,"data");v(this,"parent",null);v(this,"children",null);v(this,"group",!1);v(this,"key",null);v(this,"level",0);v(this,"uiLevel",0);v(this,"rowGroupIndex");v(this,"expanded",!1);v(this,"selectable",!0);v(this,"selected",!1);v(this,"rowPinned",null);v(this,"detailNode",null);v(this,"masterNode",null);v(this,"footer",!1);v(this,"groupData",null);v(this,"rowHeight",null);v(this,"allChildrenCount",null);v(this,"stub",!1);v(this,"rowIndex",null);v(this,"__displayIndex");v(this,"services");v(this,"_id",null);v(this,"__passesFilter",!0);v(this,"__childCount",0);v(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=ti("row"),this.id=i??this.__id,i&&(this._id=i)}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,t=!1,i="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 i=typeof e=="string"?e:e.field;if(i&&this.data){const n=i.split(".");let o=this.data;for(;n.length>1;){const a=n.shift();o[a]===void 0&&(o[a]={}),o=o[a]}o[n[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class jn{constructor(e){v(this,"options");v(this,"eventService");v(this,"columns");v(this,"getFilterModel");v(this,"getQuickFilter");v(this,"isPaginationEnabled");v(this,"getPageSize");v(this,"getCurrentPage");v(this,"rowHeightProvider");v(this,"rowNodeServices");v(this,"rowData",[]);v(this,"rootRowNodes",[]);v(this,"dataRows",[]);v(this,"rowsToDisplay",[]);v(this,"rowNodeMap",new Map);v(this,"expandedGroups",new Set);v(this,"groupDefaultExpandedApplied",!1);v(this,"pinnedTopRows",[]);v(this,"pinnedBottomRows",[]);v(this,"displayStartIndex",0);v(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,i)=>e(t,i))}forEachLeafNode(e){let t=0;const i=n=>{for(const o of n)o.group?o.children&&i(o.children):o.footer||e(o,t++)};i(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(n=>{n.group&&e.set(n.id,n.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,i=this.rowData;if(this.options.treeData){const n=this.buildTreeData(i,t);this.rootRowNodes=n,this.rowNodeMap.forEach(o=>{o.group&&e.has(o.id)&&(o.expanded=e.get(o.id))})}else{const n=[];for(let o=0;o<i.length;o++){const a=i[o],r=t?t({data:a,level:0}):void 0,l=this.createRowNode(a,r);l.rowIndex=o,n.push(l)}this.rootRowNodes=n,this.dataRows=n}if(this.options.masterDetail&&!this.options.treeData){const n=this.options.isRowMaster||(()=>!0);for(const o of this.rootRowNodes){if(o.detailNode||!n({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,i=null,n=0){const o=new tt(e,this.rowNodeServices,t);return o.parent=i,o.level=n,o.uiLevel=n,o.__id=o.id,this.rowNodeMap.set(o.id,o),o}buildTreeData(e,t){const i=this.options.getDataPath||(c=>String(c.id??c.key).split("/")),n=this.options.treeDataChildrenField||"children",o=new Map,a=[],r=(c,d,u)=>{const f=i(c),g=f.join("/"),p=t?t({data:c,level:u}):g,C=this.createRowNode(c,p,d,u);C.key=f[f.length-1],o.set(g,C);const h=c[n];if(Array.isArray(h)&&h.length){C.children=[],C.group=!0,C.expanded=!0;for(const m of h){const y=r(m,C,u+1);C.children.push(y)}C.allChildrenCount=h.length}else d&&(d.children||(d.children=[],d.group=!0,d.expanded=!0),d.children.push(C),d.allChildrenCount=(d.allChildrenCount??0)+1);return d||a.push(C),C},l=c=>{if(!c.children||c.children.length===0)return 1;let d=0;for(const u of c.children)d+=l(u);return c.allChildrenCount=d,d};for(const c of a)l(c);for(const c of e){if(!c)continue;const u=i(c).slice(0,-1).join("/"),f=u&&o.get(u)||null;r(c,f??null,f?f.level+1:0)}return a}applyTransaction(e){const t=this.options.getRowId,i={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const n=new Set;for(const o of e.remove){const a=t?t({data:o,level:0}):o.id;a!==void 0?n.add(String(a)):n.add(o)}this.rowData=this.rowData.filter(o=>{const a=t?t({data:o,level:0}):o.id;return!n.has(String(a))&&!n.has(o)});for(const o of n){const a=this.rowNodeMap.get(String(o));a&&(this.rowNodeMap.delete(a.id),i.remove.push(a))}}if(e.update&&e.update.length)for(const n of e.update){const o=t?t({data:n,level:0}):n.id,a=o!==void 0?this.rowNodeMap.get(String(o)):void 0;if(a)this.rowData=this.rowData.map(r=>{const l=t?t({data:r,level:0}):r.id;return String(l)===String(o)?n:r}),a.data=n,i.update.push(a);else{const r=this.createRowNode(n,o!==void 0?String(o):void 0);this.rowData.push(n),i.add.push(r)}}if(e.add&&e.add.length){const n=e.addIndex;for(const o of e.add){const a=t?t({data:o,level:0}):void 0,r=this.createRowNode(o,a);i.add.push(r),n===void 0||n<0?this.rowData.push(o):this.rowData.splice(Math.min(n,this.rowData.length),0,o)}}return this.rebuildRows(),i}refreshModel(e){const t=this.columns().filter(i=>i.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(),i=Object.keys(e).length>0,n=t&&t.trim().length>0,o=this.columns(),a=!!this.options.treeData,r=p=>{for(const[C,h]of Object.entries(e)){const m=o.find(y=>y.colId===C);if(m&&!this.doesNodePassFilter(p,m,h))return!1}return!0},l=p=>{const C=this.options.__advancedFilterPass;return C?C(p):!0},c=Object.entries(e).some(([p,C])=>{const h=o.find(m=>m.colId===p);return!h||!h.aggFunc?!1:C.filterType==="multi"?(C.filterModels||[]).length>0:!0}),d=p=>{if(p.__passesFilter=!0,p.children)for(const C of p.children)d(C)},u=p=>{const C=this.options;return typeof C.isExternalFilterPresent!="function"||!C.isExternalFilterPresent()||typeof C.doesExternalFilterPass!="function"?!0:C.doesExternalFilterPass(p)},f=p=>{if(!n)return!0;const C=t.toLowerCase(),h=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of h){const y=de(m,p,null);if(Gn(C,y))return!0}return!1},g=p=>{let C=!0;if(!p.group||p.footer||a?C=(!i||r(p))&&f(p)&&u(p)&&l(p):c&&(C=(!i||r(p))&&l(p)),p.__passesFilter=C,p.children){let h=!1;for(const m of p.children)g(m)&&(h=!0);return p.group&&!p.footer&&(c?(p.__passesFilter=C,C&&d(p)):(p.__passesFilter=a?h||C:h,a&&C&&d(p))),p.__passesFilter}return C};for(const p of this.rootRowNodes)g(p)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let l;if(e.groupData&&e.groupData[t.colId]!==void 0)l=e.groupData[t.colId];else{const d=[];Vt(e,d);const u=d.map(f=>de(t,f,null));l=kt(t,t.aggFunc,u)}const c={...e,data:{[t.colId]:l},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(c,t,i)}if(i.filterType==="multi"){const l=i.filterModels||[];if(l.length===0)return!0;const c=i.operator||"AND",d=l.map(u=>this.doesNodePassFilter(e,t,u));return c==="OR"?d.some(Boolean):d.every(Boolean)}if(i.condition1||i.condition2){const{condition1:l,condition2:c,...d}=i,u=[this.doesNodePassFilter(e,t,{...d,...l||{}})];return c&&u.push(this.doesNodePassFilter(e,t,{...d,...c})),(i.operator||"AND")==="OR"?u.some(Boolean):u.every(Boolean)}const n=de(t,e,null),o=Yn(t,n),a=n,r=i.filterType||"text";if(r==="text"){const l=String(i.filter??"").toLowerCase();if(!l)return!0;const c=(a==null?"":String(a)).toLowerCase();switch(i.type){case"equals":return c===l;case"notEqual":return c!==l;case"startsWith":return c.startsWith(l);case"endsWith":return c.endsWith(l);case"contains":default:return c.includes(l)}}if(r==="number"){const l=typeof a=="number"?a:Number(a);if(isNaN(l))return!1;const c=Number(i.filter),d=i.filterTo!==void 0&&i.filterTo!==null&&i.filterTo!==""?Number(i.filterTo):null;switch(i.type){case"equals":return l===c;case"notEqual":return l!==c;case"lessThan":return l<c;case"lessThanOrEqual":return l<=c;case"greaterThan":return l>c;case"greaterThanOrEqual":return l>=c;case"inRange":return d!==null?l>=Math.min(c,d)&&l<=Math.max(c,d):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(r==="date"){const l=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(l))return!1;const c=i.dateFrom?new Date(i.dateFrom).getTime():null,d=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(c!==null&&l<c||d!==null&&l>d)}return r==="boolean"?!!a==!!i.filter:r==="set"?(i.values||[]).map(c=>String(c)).includes(String(a)):!0}doSort(e){const t=[],i=this.columns();for(const a of i)a.sort&&a.sortIndex!==null&&t.push({column:a,direction:a.sort});t.sort((a,r)=>(a.column.sortIndex??0)-(r.column.sortIndex??0));const n=(a,r)=>{for(const{column:d,direction:u}of t){const f=Fi(d)(a,r)*(u==="asc"?1:-1);if(f!==0)return f}const l=a.rowIndex??0,c=r.rowIndex??0;return l-c},o=a=>{a.sort(n);for(const r of a)r.children&&o(r.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(c=>c.aggFunc&&!c.rowGroup),i=(c,d,u,f)=>{if(d>=e.length)return c;const g=e[d],p=new Map,C=[];for(const m of c){if(!m.__passesFilter)continue;const y=de(g,m,null),E=Xn(y);p.has(E)||(p.set(E,[]),C.push(E)),p.get(E).push(m)}const h=[];for(const m of C){const y=p.get(m),E=`${f}|${g.colId}:${m}`,R=this.rowNodeMap.get(E),S=R||new tt({[g.colId]:m},this.rowNodeServices,E);S.group=!0,S.key=m,S.level=u,S.uiLevel=u,S.parent=null,S.children=i(y,d+1,u+1,E);for(const L of S.children)L.parent=S;S.allChildrenCount=Gi(S),S.data={...S.data};const A=[];Vt(S,A);const B={};for(const L of t){const j=A.map(W=>de(L,W,null));B[L.colId]=kt(L,L.aggFunc,j)}B[g.colId]=m,S.groupData=B,R||this.rowNodeMap.set(E,S),h.push(S)}return h},n=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=i(o,0,0,""),r=c=>{for(const d of c){if(!d.group)continue;const u=Bt(d),f=this.expandedGroups.has(u);n===-1||f?d.expanded=!0:this.groupDefaultExpandedApplied?d.expanded=!1:d.expanded=d.level<n,d.expanded&&this.expandedGroups.add(u),d.children&&r(d.children)}};r(a),this.groupDefaultExpandedApplied=!0;const l=(c,d)=>{const u=e[d],f=u.sort==="desc"?-1:1,g=Fi(u);c.sort((p,C)=>{const h=de(u,p,null),m=de(u,C,null);return g({...p,data:{[u.colId]:h}},{...C,data:{[u.colId]:m}})*f})};e[0].sort&&l(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],i=!!this.options.treeData,n=(a,r)=>{if(a.uiLevel=r,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||i)){const l=a.group?a.children.filter(c=>c.__passesFilter||c.group):a.children;if(a.expanded){for(const c of l)n(c,r+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const c=this.createFooterNode(a,r+1);t.push(c)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&n(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(),r=this.getCurrentPage();let l=0,c=-1;for(let u=0;u<o.length;u++)if(!o[u].masterNode){if(l===r*a){c=u;break}l++}c<0&&(c=o.length);let d=c;for(l=0;d<o.length&&l<a;)o[d].masterNode||l++,d++;for(;d<o.length&&o[d].masterNode;)d++;this.displayStartIndex=c,this.rowsToDisplay=o.slice(c,d)}else this.displayStartIndex=0,this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,r)=>a.__displayIndex=r)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const i=`${e.id}|footer`;let n=this.rowNodeMap.get(i);return n||(n=new tt(e.data,this.rowNodeServices,i),this.rowNodeMap.set(i,n)),n.group=!1,n.footer=!0,n.level=e.level,n.uiLevel=t,n.parent=e,n.selected=!1,n.selectable=!1,n.groupData={...e.groupData,__footerFor:e.id},n}createGrandTotalNode(e){const t="ag-grid-grand-total";let i=this.rowNodeMap.get(t);i||(i=new tt(null,this.rowNodeServices,t),this.rowNodeMap.set(t,i)),i.group=!1,i.footer=!0,i.level=0,i.uiLevel=0,i.selected=!1,i.selectable=!1;const n=this.columns().filter(r=>r.aggFunc&&!r.rowGroup),o=[];for(const r of this.rootRowNodes)r.group?Vt(r,o):r.__passesFilter&&o.push(r);const a={};for(const r of n){const l=o.map(c=>de(r,c,null));a[r.colId]=kt(r,r.aggFunc,l)}return a.__grandTotal=!0,i.groupData=a,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Bt(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(Bt(e)):this.expandedGroups.delete(Bt(e)),this.buildDisplayRows(this.columns().filter(i=>i.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function Xn(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Bt(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Gi(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Gi(t),0)}function Vt(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Vt(t,e)}function Yn(s,e){return e}const Hi={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:"散点图"},Qn={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 Jn{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Hi[e]??e}}function Zn(s){return new Jn(s??{})}function eo(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class to{constructor(e){v(this,"options");v(this,"eventService");v(this,"columns");v(this,"getSortModel");v(this,"getFilterModel");v(this,"rowHeightProvider");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"stores",new Map);v(this,"rowNodeMap",new Map);v(this,"displayRows",[]);v(this,"blockSize");v(this,"pureLoad",!0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100,this.pureLoad=e.options.serverSideStoreType!=="partial"}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,i){if(!this.datasource)return;const n=this.getOrCreateStore(e);if(n.loading)return;for(let a=n.rows.length;a<i;a++)n.rows.push(null);n.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const o={startRow:t,endRow:i,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,r)=>{n.loading=!1,this.onBlockLoaded(e,a,r??null)},failCallback:()=>{n.loading=!1,n.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(o)}onBlockLoaded(e,t,i){const n=this.getOrCreateStore(e);n.lastRow=i,n.failed=!1;for(let o=0;o<t.length;o++){const a=t[o],r=(n.rows.length>0,o),l=this.createNode(a,e,o,r);n.rows[r]=l}for(;n.rows.length&&n.rows[n.rows.length-1]===null;)n.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,i,n){const o=eo(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${n}`,r=this.rowNodeMap.get(a),l=r instanceof tt?r:new tt(e,this.rowNodeServices,a);return l.data=e,l.rowIndex=i,o&&(l.group=!0,l.key=String(de(this.columns().find(c=>c.rowGroup),l,null)??""),l.level=t?t.split("|").length:0,l.uiLevel=l.level,l.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,l.expanded=this.stores.has(`${t?t+"|":""}${l.key}`)),this.rowNodeMap.set(a,l),l}buildDisplayRows(){const e=[],t=(i,n)=>{const o=this.stores.get(i);if(o){for(const a of o.rows)if(a&&(a.uiLevel=n,e.push(a),a.group&&a.expanded)){const r=`${i?i+"|":""}${a.key}`;t(r,n+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((i,n)=>i.__displayIndex=n)}ensureLoaded(e,t){let i=0;const n=a=>{const r=this.stores.get(a);if(r){for(const l of r.rows)if(l){if(i>=e&&i<=t){const c=Math.floor(i/this.blockSize)*this.blockSize,d=c+this.blockSize,u=r.lastRow,f=u!==null?Math.min(u,d):d;i<(r.rows.length||0)&&c<(r.rows.length||0)||(r.lastRow===null||d<=r.lastRow)&&this.loadBlock(a,c,f)}i++,l.group&&l.expanded&&n(`${a?a+"|":""}${l.key}`)}}};n("");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 i=this.groupPathFor(e);this.stores.has(i)||this.loadBlock(i,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const t=[];let i=e;for(;i&&i.group;)t.unshift(i.key??""),i=i.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,i)=>e(t,i))}forEachLeafNode(e){let t=0;for(const i of this.displayRows)!i.group&&!i.footer&&e(i,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 i of e.update||[]){const n=(i==null?void 0:i.id)!==void 0?String(i.id):void 0,o=n?this.rowNodeMap.get(n):void 0;o&&(o.data=i,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 io{constructor(e){v(this,"options");v(this,"eventService");v(this,"getSortModel");v(this,"getFilterModel");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"nodes",[]);v(this,"rowNodeMap",new Map);v(this,"blockSize");v(this,"lastRow",null);v(this,"loading",!1);this.options=e.options,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.lastRow=null,this.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let i=this.nodes.length;i<t;i++)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:(i,n)=>{this.loading=!1,this.lastRow=n??null,i.forEach((o,a)=>{const r=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let l=this.rowNodeMap.get(r);l||(l=new tt(o,this.rowNodeServices,r),this.rowNodeMap.set(r,l)),l.data=o,l.rowIndex=e+a,this.nodes[e+a]=l}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const i=Math.floor(e/this.blockSize)*this.blockSize;i+this.blockSize>this.nodes.length&&this.loadBlock(i,i+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.lastRow=null,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,i)=>{t&&e(t,i)})}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 no{constructor(e){v(this,"options");v(this,"eventService");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"nodes",[]);v(this,"rowNodeMap",new Map);v(this,"firstRow",0);v(this,"lastRow",0);v(this,"loading",!1);this.options=e.options,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.firstRow=e,this.lastRow=t,!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((i,n)=>n>=e&&n<=t);for(let i=e;i<=t;i++)this.nodes[i-e]||(this.nodes[i-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:i=>{this.loading=!1,i.forEach((n,o)=>{const a=(n==null?void 0:n.id)!==void 0?String(n.id):`vrow-${e+o}`;let r=this.rowNodeMap.get(a);r||(r=new tt(n,this.rowNodeServices,a),this.rowNodeMap.set(a,r)),r.data=n,r.rowIndex=e+o,this.nodes[e+o-e]=r}),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,i)=>{t&&e(t,i)})}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}}class oo{constructor(e){v(this,"eGui");var c,d,u;this.params=e;const t=e.node,i=!!t.group,n=!!t.detailNode,o=i||n,a=t.expanded,r=t.uiLevel*24,l=document.createElement("span");if(l.className="ag-group-cell-renderer",l.style.paddingLeft=`${r}px`,o){const f=document.createElement("span");f.className="ag-group-value-expanded-icon",f.classList.add(a?"ag-expanded":"ag-contracted"),f.innerHTML=a?xo:So,l.appendChild(f);const g=document.createElement("span");g.className="ag-group-value";const p=(c=e.colDef.cellRendererParams)==null?void 0:c.innerRenderer;if(typeof p=="function"){const C=p({...e,value:e.value,valueFormatted:e.valueFormatted});C instanceof HTMLElement?g.appendChild(C):typeof C=="string"&&(g.innerHTML=C)}else g.textContent=po(e.value);if(l.appendChild(g),i&&t.allChildrenCount!==null&&!((d=e.colDef.cellRendererParams)!=null&&d.suppressCount)){const C=document.createElement("span");C.className="ag-group-child-count",C.textContent=` (${t.allChildrenCount})`,l.appendChild(C)}}else{const f=document.createElement("span");f.className="ag-group-value";const g=(u=e.colDef.cellRendererParams)==null?void 0:u.innerRenderer;if(typeof g=="function"){const p=g({...e,value:e.value,valueFormatted:e.valueFormatted});p instanceof HTMLElement?f.appendChild(p):typeof p=="string"&&(f.innerHTML=p)}else f.textContent=e.valueFormatted??String(e.value??"");l.appendChild(f)}this.eGui=l}getGui(){return this.eGui}refresh(e){return!1}}class so{constructor(e){v(this,"eGui");v(this,"eCheckbox");this.params=e,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",i=>i.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.params=e,this.eCheckbox.checked=!!e.node.selected,!0}}const ao='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',lo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class ro{constructor(e){v(this,"eGui");v(this,"eArrow");v(this,"eOld");v(this,"eNew");v(this,"lastValue");v(this,"flashTimer",null);this.params=e,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 i=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),n=this.eNew.textContent??"";this.eArrow.innerHTML=i?ao:lo,this.eArrow.style.display="",this.eArrow.classList.add(i?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=n,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",i?"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 co{constructor(e){v(this,"eGui");this.params=e,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.params=e,this.eGui.textContent=String(e.rowIndex+1),!0}}class uo{constructor(e){v(this,"eGui");var l,c;this.params=e;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],n=e.sparklineOptions||((c=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:c.sparklineOptions)||{},o=e.column.width||100,a=n.height||24,r=si(i,Math.max(20,o-16),a,n);t.appendChild(r),this.eGui=t}getGui(){return this.eGui}refresh(e){var r,l;const t=e.value||[],i=e.sparklineOptions||((l=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:l.sparklineOptions)||{},n=e.column.width||100,o=i.height||24;this.eGui.innerHTML="";const a=si(t,Math.max(20,n-16),o,{type:i.type,direction:i.direction});return this.eGui.appendChild(a),!0}}function si(s,e,t,i={}){var m,y,E;const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",String(Math.max(20,e))),n.setAttribute("height",String(t)),n.setAttribute("class","ag-sparkline");const o=(s||[]).map(R=>typeof R=="number"?R:Number((R==null?void 0:R.value)??0));if(!o||o.length<1)return n;const a=i.type||"line",r=Math.min(...o,0),c=Math.max(...o,0)-r||1,d=((m=i.tooltip)==null?void 0:m.enabled)===!0,u=((y=i.axis)==null?void 0:y.type)||"number",f=((E=i.pointsOfInterest)==null?void 0:E.show)===!0,g=(R,S)=>u==="category"?`${R+1}: ${S}`:String(S);if(f&&o.length>1){const R=o.indexOf(Math.min(...o)),S=o.indexOf(Math.max(...o)),A=e/Math.max(1,o.length-1),B=j=>t-2-(j-r)/c*(t-4),L=(j,W)=>{const M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(j*A)),M.setAttribute("cy",String(B(o[j]))),M.setAttribute("r","2.5"),M.setAttribute("fill",W),n.appendChild(M)};L(0,"#4caf50"),L(o.length-1,"#f44336"),L(R,"#2196f3"),L(S,"#ff9800")}if(d){const R=document.createElementNS("http://www.w3.org/2000/svg","title");R.textContent=o.map((S,A)=>g(A,S)).join(`
3
- `),n.appendChild(R),n.style.cursor="default"}if(a==="bar"){const R=i.direction==="vertical",S=o.length;if(R){const A=Math.max(1,e/S-1),B=t-2-(0-r)/c*(t-4);o.forEach((L,j)=>{const W=j*(e/S),M=t-2-(L-r)/c*(t-4),D=document.createElementNS("http://www.w3.org/2000/svg","rect");D.setAttribute("x",String(W)),D.setAttribute("width",String(A)),D.setAttribute("y",String(Math.min(M,B))),D.setAttribute("height",String(Math.max(1,Math.abs(B-M)))),D.setAttribute("fill","currentColor"),n.appendChild(D)})}else{const A=Math.max(1,t/S-1),B=2+(0-r)/c*(e-4);o.forEach((L,j)=>{const W=j*(t/S),M=2+(L-r)/c*(e-4),D=document.createElementNS("http://www.w3.org/2000/svg","rect");D.setAttribute("y",String(W)),D.setAttribute("height",String(A)),D.setAttribute("x",String(Math.min(M,B))),D.setAttribute("width",String(Math.max(1,Math.abs(B-M)))),D.setAttribute("fill","currentColor"),n.appendChild(D)})}return n}const p=e/Math.max(1,o.length-1),C=o.map((R,S)=>{const A=S*p,B=t-2-(R-r)/c*(t-4);return`${A.toFixed(1)},${B.toFixed(1)}`});if(a==="area"){const R=document.createElementNS("http://www.w3.org/2000/svg","polygon");R.setAttribute("points",`0,${t} ${C.join(" ")} ${e},${t}`),R.setAttribute("fill","currentColor"),R.setAttribute("opacity","0.2"),n.appendChild(R)}const h=document.createElementNS("http://www.w3.org/2000/svg","polyline");return h.setAttribute("points",C.join(" ")),h.setAttribute("fill","none"),h.setAttribute("stroke","currentColor"),h.setAttribute("stroke-width","1.5"),n.appendChild(h),n}class ho{constructor(e){v(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Oi,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const zt={agGroupCellRenderer:s=>new oo(s),agCheckboxCellRenderer:s=>new so(s),agSparklineCellRenderer:s=>new uo(s),agAnimateShowChangeCellRenderer:s=>new ro(s),agRowNumberCellRenderer:s=>new co(s),agRowDragComp:s=>new ho(s)};function po(s){return s==null?"":String(s)}class go{constructor(e){v(this,"eGui");v(this,"cancelled",!1);this.params=e,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 i;return(i=e.onKeyDown)==null?void 0:i.call(e,t)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class fo{constructor(e){v(this,"eGui");v(this,"eInput");v(this,"cancelled",!1);var n,o;this.params=e;const t=document.createElement("div");t.className="ag-cell-editor-number";const i=document.createElement("input");if(i.type="text",i.className="ag-cell-editor-input",i.value=e.value??"",(o=(n=e.column)==null?void 0:n.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",l=>{var c,d;l.preventDefault(),l.preventDefault(),i.value=String(Number(i.value||0)+(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))});const r=document.createElement("span");r.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",r.innerHTML="▼",r.addEventListener("mousedown",l=>{var c,d;l.preventDefault(),i.value=String(Number(i.value||0)-(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))}),t.appendChild(a),t.appendChild(i),t.appendChild(r)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",a=>{var r;return(r=e.onKeyDown)==null?void 0:r.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 mo{constructor(e){v(this,"eGui");v(this,"cancelled",!1);var i,n;this.params=e,this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((n=(i=e.column)==null?void 0:i.cellEditorParams)==null?void 0:n.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 vo{constructor(e){v(this,"eGui");v(this,"cancelled",!1);this.params=e,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 Co{constructor(e){v(this,"eGui");v(this,"cancelled",!1);this.params=e,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 wo(s,e){if(!e)return Et(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?Et(s):Et(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+Et(s.slice(t,t+e.length))+"</span>"+Et(s.slice(t+e.length))}class yo{constructor(e){v(this,"eGui");v(this,"eInput");v(this,"ePopup",null);v(this,"eList",null);v(this,"values",[]);v(this,"filtered",[]);v(this,"activeIndex",0);v(this,"selectedValue");v(this,"cancelled",!1);var t,i;this.params=e,this.values=e.values||((i=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:i.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",n=>{n.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",n=>this.onKeyDown(n))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var a,r;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,bo(this.params)){const l=document.createElement("input");l.type="text",l.className="ag-rich-select-search",l.placeholder=((r=(a=this.params).t)==null?void 0:r.call(a,"search"))??"搜索…",l.value="",l.addEventListener("input",()=>this.renderList(l.value)),e.appendChild(l),setTimeout(()=>l.focus(),0)}const n=document.createElement("div");n.className="ag-rich-select-list",e.appendChild(n),this.eList=n,this.renderList();const o=l=>{!e.contains(l.target)&&!this.eGui.contains(l.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var i,n;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(o=>{if(!e)return!0;const a=String(o).toLowerCase(),r=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?r.every(l=>a.includes(l)):r.some(l=>a.includes(l))}),this.filtered.forEach((o,a)=>{const r=document.createElement("div");r.className="ag-rich-select-item",a===this.activeIndex&&r.classList.add("ag-active"),String(o)===String(this.selectedValue)&&r.classList.add("ag-selected");const l=this.params.cellRenderer;if(typeof l=="function"){const c=l({value:o,valueFormatted:String(o)});c instanceof HTMLElement?r.appendChild(c):r.textContent=String(c)}else r.innerHTML=wo(String(o),e);r.addEventListener("click",c=>{c.stopPropagation(),this.commit(o)}),r.addEventListener("mousedown",c=>c.preventDefault()),this.eList.appendChild(r)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((n=(i=this.params).t)==null?void 0:n.call(i,"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,i;return(i=(t=this.params).onKeyDown)==null?void 0:i.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 bo(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 it={agTextCellEditor:s=>new go(s),agNumberCellEditor:s=>new fo(s),agSelectCellEditor:s=>new mo(s),agDateCellEditor:s=>new vo(s),agLargeTextCellEditor:s=>new Co(s),agRichSelectCellEditor:s=>new yo(s)},So='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',xo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Oi='<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>',Eo='<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>',Ro='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Mo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',ko='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Bi='<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>';function Vi(s,e,t){const i=s.length;if(i===0||t<=0)return[];let n=0,o=i-1;for(;n<o;){const d=n+o>>1;s[d]>=t?o=d:n=d+1}const a=s[n]>=t?n:i-1,r=e[a];if(!r||r.level===0)return[];const l=[];let c=r.level;for(let d=a-1;d>=0;d--){const u=e[d];if(!(!u||u.level>=c)&&(c=u.level,u.group&&s[d]<t&&l.push(d),u.level===0))break}return l.reverse()}class To{constructor(e,t,i){v(this,"ctx");v(this,"eRoot");v(this,"eHeader");v(this,"eBody");v(this,"ePinnedLeft");v(this,"ePinnedRight");v(this,"ePinnedLeftInner");v(this,"ePinnedRightInner");v(this,"eViewport");v(this,"eContainer");v(this,"eFloatingTop");v(this,"eFloatingBottom");v(this,"eFloatingTopLeft");v(this,"eFloatingTopRight");v(this,"eFloatingBottomLeft");v(this,"eFloatingBottomRight");v(this,"eStickyTop");v(this,"eStickyLeft");v(this,"eStickyCenter");v(this,"eStickyRight");v(this,"eRangeOverlay",null);v(this,"rowComps",new Map);v(this,"stickyComps",new Map);v(this,"hoveredRowId",null);v(this,"rowOffsets",[]);v(this,"rowInfos",[]);v(this,"totalHeight",0);v(this,"lastScrollTop",-1);v(this,"lastRange",[-1,-1]);v(this,"firstRendered",!1);v(this,"heightVersion",0);v(this,"scrollFrame",null);v(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 i=this.eViewport;let n=e.deltaY,o=e.deltaX;e.deltaMode===1?(n*=33,o*=33):e.deltaMode===2&&(n*=i.clientHeight,o*=i.clientWidth),n&&(i.scrollTop+=n),o&&(i.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});v(this,"onBodyMouseOver",e=>{var o;const t=e.target,i=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,".ag-row"),n=(i==null?void 0:i.dataset.rowid)??null;if(n===this.hoveredRowId){n&&this.setRowHovered(n,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=n,n&&this.setRowHovered(n,!0)});v(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=i,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 n=document.createElement("div");n.className="ag-body-viewport-wrapper",this.eBody.appendChild(n),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",n.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)),n.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",n.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 i of this.rowComps.values())i.getNode().id===e&&i.setHovered(t);for(const i of this.stickyComps.values())i.getNode().id===e&&i.setHovered(t)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}setRangeOverlay(e){this.eRangeOverlay=e}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount(),t=new Array(e),i=new Array(e);let n=0;if(this.hasVariableHeights()){for(let a=0;a<e;a++)t[a]=n,i[a]=this.rowInfoAt(a),n+=this.getRowHeightForIndex(a);this.totalHeight=n}else{const a=this.getFixedRowHeight();for(let r=0;r<e;r++)t[r]=r*a,i[r]=this.rowInfoAt(r);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=i}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?{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((n,o)=>n+o.width,0),t=this.ctx.getColumns().left.reduce((n,o)=>n+o.width,0),i=this.ctx.getColumns().right.reduce((n,o)=>n+o.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${t}px`,this.ePinnedRight.style.width=`${i}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=`${i}px`,this.eFloatingBottomLeft.style.width=`${t}px`,this.eFloatingBottomRight.style.width=`${i}px`,this.eStickyLeft.style.width=`${t}px`,this.eStickyRight.style.width=`${i}px`,this.eStickyCenter.style.left=`${t}px`,this.eStickyCenter.style.right=`${i}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 i,n;const e=(o,a,r,l,c)=>{o.innerHTML="",a.innerHTML="",r.innerHTML="";const{left:d,center:u,right:f}=this.ctx.getColumns();let g=0;for(let p=0;p<l;p++){const C=c(p);if(!C)continue;const h=this.ctx.getRowHeight(C),m=new Wt(this.ctx,C,d,u,f,h,this.heightVersion);m.appendTo(a,o,r),m.setTop(g),g+=h,this.rowComps.set(`${C.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${g}px`,o.style.display=l>0?"":"none",a.style.height=`${g}px`,r.style.height=`${g}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((i=t.getPinnedTopRowCount)==null?void 0:i.call(t))??0,o=>{var a;return(a=t.getPinnedTopRow)==null?void 0:a.call(t,o)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((n=t.getPinnedBottomRowCount)==null?void 0:n.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 i;e!=null&&e.columns&&(i=e.columns.map(n=>typeof n=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(o=>o.colId===n):n).filter(Boolean));for(const[n,o]of this.rowComps)t&&!t.includes(o.getNode())||o.refreshCells(i,e==null?void 0:e.force,e==null?void 0:e.flash);for(const n of this.stickyComps.values())t&&!t.includes(n.getNode())||n.refreshCells(i,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 i=t.getNode(),n=this.findRowIndex(i);if(t.destroy(),this.rowComps.delete(this.rowCompKey(i)),n>=0){const{left:o,center:a,right:r}=this.ctx.getColumns(),l=new Wt(this.ctx,i,o,a,r,this.getRowHeightForIndex(n),this.heightVersion);l.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),l.setTop(this.rowOffsets[n]??0),this.rowComps.set(this.rowCompKey(i),l)}}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){var t;for(let i=0;i<this.ctx.rowModel.getRowCount();i++)if(((t=this.ctx.rowModel.getRow(i))==null?void 0:t.id)===e.id)return i;return-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 i=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const n of this.stickyComps.values()){const o=n.getCenterElement();o&&(o.style.transform=i)}}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){this.eViewport.scrollLeft=e,this.eHeader.scrollLeft=e,this.syncPinnedScroll()}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Vi(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:i,right:n}=this.ctx.getColumns(),o=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${o}px`;const a=new Set;let r=0;for(const c of e){const d=this.ctx.rowModel.getRow(c);if(!d||!d.group)continue;a.add(d.id);let u=this.stickyComps.get(d.id);if(!u){const f=this.rowComps.get(d.id);f&&(f.destroy(),this.rowComps.delete(d.id)),u=new Wt(this.ctx,d,t,i,n,this.getRowHeightForIndex(c),this.heightVersion),u.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),u.setSticky(!0),this.stickyComps.set(d.id,u)}u.setTop(r),r+=this.getRowHeightForIndex(c)}for(const[c,d]of this.stickyComps)a.has(c)||(d.destroy(),this.stickyComps.delete(c));const l=`${r}px`;return this.eStickyTop.style.height=l,this.eStickyLeft.style.height=l,this.eStickyCenter.style.height=l,this.eStickyRight.style.height=l,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),i=this.eViewport.scrollTop,n=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a=0,r=t-1;if(this.hasVariableHeights())a=this.findIndexAtPixel(i)-o,r=this.findIndexAtPixel(i+n)+o;else{const h=this.getFixedRowHeight();a=Math.floor(i/h)-o,r=Math.ceil((i+n)/h)+o}if(a=Math.max(0,a),r=Math.min(t-1,r),!e&&this.lastRange[0]===a&&this.lastRange[1]===r&&this.lastScrollTop===i)return;const l=this.lastRange[0]!==a||this.lastRange[1]!==r;this.lastRange=[a,r],this.lastScrollTop=i;const c=new Set(this.stickyComps.keys()),d=this.syncStickyGroupRows(),u=c.size!==d.size||[...c].some(h=>!d.has(h));if(!e&&!l&&!u)return;const f=new Set(d),{left:g,center:p,right:C}=this.ctx.getColumns();for(let h=a;h<=r;h++){const m=this.ctx.rowModel.getRow(h);if(!m||(f.add(m.id),d.has(m.id)))continue;let y=this.rowComps.get(m.id);y||(y=new Wt(this.ctx,m,g,p,C,this.getRowHeightForIndex(h),this.heightVersion),y.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,y)),y.setTop(this.rowOffsets[h]??h*this.getFixedRowHeight())}for(const[h,m]of this.rowComps)!f.has(h)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(h))}findIndexAtPixel(e){const t=this.rowOffsets;let i=0,n=t.length-1;for(;i<n;){const o=i+n+1>>1;t[o]<=e?i=o:n=o-1}return i}ensureIndexVisible(e,t="top"){const i=this.rowOffsets[e]??e*this.getFixedRowHeight(),n=this.getRowHeightForIndex(e),o=this.eViewport.clientHeight;let a=this.eViewport.scrollTop;t==="top"?a=i:t==="bottom"?a=i+n-o:a=i-(o-n)/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 i=this.eViewport.clientWidth,n=this.eViewport.scrollLeft,o=e.left-this.ctx.getColumns().left.reduce((a,r)=>a+r.width,0);o<n?this.eViewport.scrollLeft=Math.max(0,t==="middle"?o-(i-e.width)/2:o):o+e.width>n+i&&(this.eViewport.scrollLeft=o+e.width-i),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 i=e.target.closest(".ag-cell");if(!i)return null;const n=i.dataset.colid;if(!n)return null;const o=i.closest(".ag-row"),a=o==null?void 0:o.dataset.rowid;if(!a)return null;const r=this.ctx.rowModel.getRowNode(a);if(!r)return null;const c=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(d=>d.colId===n);return c?(this.ctx.rowModel.getRowCount(),{node:r,column:c,eCell:i,rowIndex:0}):null}getRowIndexForNode(e){var t;for(let i=0;i<this.ctx.rowModel.getRowCount();i++)if(((t=this.ctx.rowModel.getRow(i))==null?void 0:t.id)===e.id)return i;return-1}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:de(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node),colDef:t.column.colDef});return}const i=e.target.closest(".ag-row");if(i!=null&&i.dataset.rowid){const n=this.ctx.rowModel.getRowNode(i.dataset.rowid);n&&this.ctx.onRowClicked({event:e,node:n,data:n.data,rowIndex:this.getRowIndexForNode(n)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:de(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node),colDef:t.column.colDef});return}const i=e.target.closest(".ag-row");if(i!=null&&i.dataset.rowid){const n=this.ctx.rowModel.getRowNode(i.dataset.rowid);n&&this.ctx.onRowDoubleClicked({event:e,node:n,data:n.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:de(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:de(t.column,t.node,null),rowIndex:this.getRowIndexForNode(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 Wt{constructor(e,t,i,n,o,a,r){v(this,"eLeft",null);v(this,"eCenter",null);v(this,"eRight",null);v(this,"cellComps",[]);v(this,"pinned",!1);var l,c,d,u,f,g,p,C,h;if(this.ctx=e,this.node=t,this.rowHeight=a,this.heightVersion=r,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}i.length&&(this.eLeft=this.createRowElement(t,i,"left"),this.eLeft.classList.add("ag-row-pinned")),(n.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,n,"center")),o.length&&(this.eRight=this.createRowElement(t,o,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((l=this.eCenter)==null||l.classList.add("ag-row-footer"),(c=this.eLeft)==null||c.classList.add("ag-row-footer"),(d=this.eRight)==null||d.classList.add("ag-row-footer")),t.group&&((u=this.eCenter)==null||u.classList.add("ag-row-group"),(f=this.eLeft)==null||f.classList.add("ag-row-group"),(g=this.eRight)==null||g.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((p=this.eCenter)==null||p.classList.add("ag-row-selected"),(C=this.eLeft)==null||C.classList.add("ag-row-selected"),(h=this.eRight)==null||h.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,i,n;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-sticky-group",e),(n=this.eRight)==null||n.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,i,n;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-hover",e),(n=this.eRight)==null||n.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,i){var l;const n=document.createElement("div");n.className="ag-row",n.dataset.rowid=e.id,n.setAttribute("role","row"),n.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),n.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&n.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&n.classList.add("ag-row-even"),n.style.height=`${this.rowHeight}px`,n.style.position="absolute",n.style.top="0px";const o=this.ctx.getRowClass(e);o&&n.classList.add(...o.split(" ").filter(Boolean));const a=this.ctx.getRowStyle(e);a&&Object.assign(n.style,a),e.footer&&((l=e.groupData)!=null&&l.__grandTotal)&&(n.classList.add("ag-row-full-width"),n.style.width="100%",n.style.right="0",n.style.left="0");let r=0;for(let c=0;c<t.length;c++){const d=t[c],u=this.createCell(d,e);let f=1;typeof d.colDef.colSpan=="function"&&(f=Math.max(1,Math.round(d.colDef.colSpan({value:de(d,e,null),data:e.data,node:e,column:d,rowIndex:e.__displayIndex??0,api:null}))));let g=d.width;for(let p=1;p<f&&c+p<t.length;p++)g+=t[c+p].width;u.eCell.style.left=`${r}px`,u.eCell.style.width=`${g}px`,u.eCell.style.position="absolute",u.eCell.style.top="0",u.eCell.style.height=`${this.rowHeight}px`,f>1&&u.eCell.classList.add("ag-cell-col-span"),r+=g,c+=f-1,n.appendChild(u.eCell),this.cellComps.push(u)}return n.style.width=`${r}px`,n}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(i=>i.colId===e.colId)+1}createCell(e,t){var d,u;const i=document.createElement("div");i.className="ag-cell",i.dataset.colid=e.colId;const n=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");n&&i.classList.add(`ag-col-${n}`);const o={value:de(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const f=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof f=="string"?i.classList.add(...f.split(" ").filter(Boolean)):Array.isArray(f)&&i.classList.add(...f)}if(e.cellClassRules)for(const[f,g]of Object.entries(e.cellClassRules))g(o)&&i.classList.add(f);if(e.cellStyle){const f=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(i.style,f)}(e.type==="numberColumn"||e.cellDataType===!0)&&i.classList.add("ag-right-aligned-cell"),e.rowDrag&&i.classList.add("ag-cell-row-drag");const a=document.createElement("span");a.className="ag-cell-value",i.appendChild(a),this.ctx.options.enableCellTextSelection&&(i.style.userSelect="text",i.style.cursor="text"),i.setAttribute("role","gridcell"),i.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const r=(u=(d=this.ctx).getNote)==null?void 0:u.call(d,t.id,e.colId,e.colDef.note,{value:de(e,t,null),data:t.data,node:t,column:e,api:null});if(r){const f=document.createElement("span");f.className="ag-cell-note-marker",f.title=r,f.addEventListener("click",g=>{var p,C;g.stopPropagation(),(C=(p=this.ctx).onNoteClick)==null||C.call(p,t.id,e.colId,f)}),i.appendChild(f)}if(e.rowDrag){const f=document.createElement("span");f.className="ag-row-drag-handle",f.innerHTML=Oi,f.title=this.ctx.t("dragRow"),f.addEventListener("mousedown",g=>{var p,C;g.button===0&&(g.stopPropagation(),(C=(p=this.ctx).onRowDragStart)==null||C.call(p,t,f,g))}),i.appendChild(f)}const l=e.tooltipField;l&&t.data&&t.data[l]!==void 0?i.title=String(t.data[l]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:de(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const c={column:e,eCell:i,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(c),c}updateCellContent(e){var c;const{column:t,node:i}={column:e.column,node:this.node},n=de(t,i,null),o=Ot(t,i,null);e.lastValue=n,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,r=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||r){e.custom=!0;const d=a||"func";if(e.rendererKey!==d){e.eValue.innerHTML="",e.rendererKey=d;const u={value:n,valueFormatted:o,data:i.data,node:i,column:t,rowIndex:i.__displayIndex??0,api:null,colDef:t.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...t.cellRendererParams||{}};let f=null;if(a&&zt[a]){const g=zt[a](u);g instanceof HTMLElement?f=g:(e.rendererInstance=g,f=g.getGui())}else if(r){const g=r(u);g instanceof HTMLElement?f=g:g&&typeof g.getGui=="function"?(e.rendererInstance=g,f=g.getGui()):typeof g=="string"&&(e.eValue.innerHTML=g)}f&&e.eValue.appendChild(f)}return}e.rendererKey="",e.custom=!1,(c=e.rendererInstance)!=null&&c.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let l=o??"";if((i.group||i.footer)&&i.groupData){const d=i.groupData[t.colId];l=d==null?"":String(d)}e.eValue.textContent!==l&&(e.eValue.textContent=l)}refreshCells(e,t,i){var a,r,l,c;const n=e&&e.length?new Set(e.map(d=>d.colId)):null;for(const d of this.cellComps){if(n&&!n.has(d.column.colId))continue;const u=de(d.column,this.node,null),f=t||u!==d.lastValue;if(!f&&!i)continue;const g=d.eValue.textContent;if(d.rendererInstance&&typeof d.rendererInstance.refresh=="function"){d.rendererInstance.refresh({value:u,valueFormatted:Ot(d.column,this.node,null),data:this.node.data,node:this.node,column:d.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:d.column.colDef,eGridCell:d.eCell,...d.column.cellRendererParams||{}})===!1&&this.updateCellContent(d),d.lastValue=u,i&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"));continue}if(d.rendererKey){(f||i)&&(d.rendererKey="",this.updateCellContent(d)),d.lastValue=u,i&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(d),(i||f&&g!==d.eValue.textContent)&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.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),(r=this.eLeft)==null||r.classList.toggle("ag-row-selected",o),(l=this.eRight)==null||l.classList.toggle("ag-row-selected",o),this.node.group&&((c=this.eCenter)==null||c.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,i){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&i.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const n=this.ctx.renderDetailRow(this.node,this.eCenter);n&&t.appendChild(n.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,i,n;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(t=this.eCenter)!=null&&t.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(i=this.eRight)!=null&&i.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const o of this.cellComps)(n=o.rendererInstance)!=null&&n.destroy&&o.rendererInstance.destroy();this.cellComps=[]}}class No{constructor(e,t){v(this,"ctx");v(this,"eHeader");v(this,"ePinnedLeftHeader");v(this,"ePinnedRightHeader");v(this,"eHeaderViewport");v(this,"eHeaderContainer");v(this,"eHeaderRow");v(this,"eFloatingFiltersRow",null);v(this,"eGroupRows");v(this,"headerCells",new Map);v(this,"customHeaderComponents",new Map);v(this,"resizeState",null);v(this,"dragState",null);v(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:i}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,t,"center"),this.renderSection(this.ePinnedRightHeader,i,"right");const n=[...e,...t,...i].some(o=>o.floatingFilter);n&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!n&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var r;const e=this.ctx.getColumnModel(),t=((r=e==null?void 0:e.getColumnGroups)==null?void 0:r.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((l,c)=>Math.max(l,c.depth),0),n=this.ctx.options.groupHeaderHeight??30;let o=0;for(let l=1;l<=i;l++){const c=document.createElement("div");c.className="ag-header-row ag-group-header-row",c.style.height=`${n}px`;const d=this.ctx.getColumns().center;let u=0,f,g=0,p=0;const C=(m,y)=>{let E=m.groupId;for(;E;){const R=t.find(S=>S.id===E);if(!R)return null;if(R.depth===y)return R.id;E=R.parentId}return null},h=()=>{if(f==null)return;const m=t.find(S=>S.id===f);if(!m)return;const y=document.createElement("div");y.className="ag-header-group-cell",y.style.left=`${g}px`,y.style.width=`${p}px`,y.style.height=`${n}px`;const E=e.isGroupOpen(m.id),R=document.createElement("div");if(R.className="ag-header-group-cell-label",R.textContent=m.headerName,y.appendChild(R),!E){const S=document.createElement("span");S.className="ag-header-group-expand",S.textContent="▸",S.title=this.ctx.t("expandGroup"),y.appendChild(S)}y.addEventListener("click",()=>{e.setGroupOpen(m.id,!E)}),c.appendChild(y)};d.forEach(m=>{const y=C(m,l);y!==f&&(h(),f=y,g=u,p=0),p+=m.width,u+=m.width}),h(),c.style.width=`${u}px`,this.eGroupRows.appendChild(c),o+=n}this.eGroupRows.style.display=i>0?"":"none";const a=this.ctx.headerHeight;this.eHeader.style.height=`${o+a}px`}renderSection(e,t,i){e.innerHTML="";let n=0;for(const o of t){const a=this.createHeaderCell(o);if(a.style.left=`${n}px`,a.style.width=`${o.width}px`,a.style.height=`${this.ctx.headerHeight}px`,n+=o.width,e.appendChild(a),this.headerCells.set(o.colId,a),o.eHeaderCell=a,this.eFloatingFiltersRow&&e===this.eHeaderRow&&o.floatingFilter){const r=this.createFloatingFilter(o);r.style.left=`${n-o.width}px`,r.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(r)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${n}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${n}px`)}createHeaderCell(e){var a,r;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 l=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(l).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const l=i({column:e,colDef:e.colDef,api:((r=(a=this.ctx).getApi)==null?void 0:r.call(a))??null,displayName:e.headerName}),c=l&&typeof l.getGui=="function"?l.getGui():l;if(c instanceof HTMLElement)return c.classList.add("ag-header-component"),t.appendChild(c),typeof(l==null?void 0:l.refresh)=="function"&&this.customHeaderComponents.set(e.colId,l),t}const n=document.createElement("div");if(n.className="ag-header-cell-label",e.headerTooltip&&(n.title=e.headerTooltip),e.headerCheckboxSelection){const l=document.createElement("input");l.type="checkbox",l.className="ag-native-checkbox ag-header-select-all",l.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,l.checked)),l.addEventListener("click",c=>c.stopPropagation()),n.appendChild(l)}const o=document.createElement("span");if(o.className="ag-header-cell-text",o.textContent=e.headerName,n.appendChild(o),t.appendChild(n),e.sortable){const l=document.createElement("span");l.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(l,e.sort,e.sortIndex),t.appendChild(l)}if(e.filter){const l=document.createElement("span");l.className="ag-header-icon ag-filter-icon";const c=this.ctx.isFilterActive(e);l.classList.toggle("ag-filter-active",c),l.innerHTML=Ro,l.title=this.ctx.t("openFilterTitle"),l.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onFilterOpened(e,l)}),t.appendChild(l)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const l=document.createElement("span");l.className="ag-header-icon ag-menu-icon",l.innerHTML=Eo,l.title=this.ctx.t("openMenuTitle"),l.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onColumnMenuClicked(e,l)}),t.appendChild(l)}if(t.addEventListener("click",l=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,l,l.shiftKey||l.ctrlKey||l.metaKey)}),t.addEventListener("contextmenu",l=>{l.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:l}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",l=>{const c=t.getBoundingClientRect();l.clientX>c.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const l=document.createElement("div");l.className="ag-header-cell-resize",l.addEventListener("mousedown",c=>{c.stopPropagation(),c.preventDefault(),this.resizeState={column:e,startX:c.clientX,startWidth:e.width};const d=f=>{if(!this.resizeState)return;const g=f.clientX-this.resizeState.startX;let p=this.resizeState.startWidth+g;p=Math.max(e.minWidth,Math.min(e.maxWidth,p)),this.ctx.onColumnResized(e,Math.round(p),!1)},u=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",d),document.addEventListener("mouseup",u)}),t.appendChild(l)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",l=>{if(!l.dataTransfer)return;l.dataTransfer.setData("text/plain",e.colId),l.dataTransfer.effectAllowed="move";const c=t.cloneNode(!0);c.classList.add("ag-header-cell-drag-ghost"),c.style.position="absolute",c.style.top="-1000px",c.style.width=`${e.width}px`,c.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(c),l.dataTransfer.setDragImage(c,20,20),this.dragState={colId:e.colId,ghost:c,startX:l.clientX,startY:l.clientY},setTimeout(()=>c.remove(),0)}),t.addEventListener("dragend",()=>{var l;(l=this.dragState)!=null&&l.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",l=>{l.preventDefault()}),t.addEventListener("drop",l=>{var d;l.preventDefault();const c=(d=l.dataTransfer)==null?void 0:d.getData("text/plain");c&&c!==e.colId&&this.ctx.onColumnMoved(c,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 n=document.createElement("select");return n.className="ag-floating-filter-input",n.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',n.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,n.value)),t.appendChild(n),e.floatingFilterComp=n,t}const i=document.createElement("input");return i.className="ag-floating-filter-input",i.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",i.placeholder=this.ctx.t("filterOoo"),i.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),i.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,i.value)),t.appendChild(i),e.floatingFilterComp=i,t}updateSortIndicator(e,t,i){if(e.innerHTML="",t==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=Mo):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=ko),t&&i!==null&&i>0){const n=document.createElement("span");n.className="ag-sort-order",n.textContent=String(i+1),e.appendChild(n)}}updateIndicators(){const{left:e,center:t,right:i}=this.ctx.getColumns();for(const n of[...e,...t,...i]){const o=this.headerCells.get(n.colId);if(!o)continue;const a=o.querySelector(".ag-sort-indicator");a&&this.updateSortIndicator(a,n.sort,n.sortIndex);const r=o.querySelector(".ag-filter-icon");r&&r.classList.toggle("ag-filter-active",this.ctx.isFilterActive(n)),o.style.width=`${n.width}px`,this.lastWidths.get(n.colId)!==n.width&&this.lastWidths.set(n.colId,n.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(i=>i.colId===e.colId)+1}layoutPositions(){const{left:e,center:t,right:i}=this.ctx.getColumns();let n=0;for(const o of e){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}this.ePinnedLeftHeader.style.width=`${n}px`,n=0;for(const o of t){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}this.eHeaderContainer.style.width=`${n}px`,n=0;for(const o of i){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}if(this.ePinnedRightHeader.style.width=`${n}px`,this.eFloatingFiltersRow){n=0;for(const o of t){const a=this.eFloatingFiltersRow.querySelector(`[data-colid="${o.colId}"]`);a&&(a.style.left=`${n}px`,a.style.width=`${o.width}px`),n+=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 Io{constructor(e,t,i){v(this,"selectedNodes",new Set);v(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=t,this.isNodeSelectable=i}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 i of e.children)i.footer||i.detailNode||(t?this.isNodeSelectable(i)&&(this.selectedNodes.add(i),i.selected=!0):(this.selectedNodes.delete(i),i.selected=!1),this.selectChildrenRecursively(i,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 i=this.getOptions().rowSelection==="multiple",n=t.ctrlKey||t.metaKey,o=t.shiftKey;return i?o&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):n?(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 i=this.getOptions().__rowModel;if(!(i!=null&&i.forEachNode))return;let n=-1,o=-1,a=0;if(i.forEachNode(c=>{c===e&&(n=a),c===t&&(o=a),a++}),n<0||o<0)return;const r=Math.min(n,o),l=Math.max(n,o);a=0,i.forEachNode(c=>{a>=r&&a<=l&&this.isNodeSelectable(c)&&!c.footer&&(this.selectedNodes.add(c),c.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(n=>t.add(n));let i=!1;for(const n of this.selectedNodes)t.has(n)?n.selected=!0:i=!0;if(i){for(const n of[...this.selectedNodes])t.has(n)||this.selectedNodes.delete(n);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let t=0,i=0;return e!=null&&e.forEachNode&&e.forEachNode(n=>{n.footer||!this.isNodeSelectable(n)||(t++,n.selected&&i++)}),{checked:t>0&&i===t,indeterminate:i>0&&i<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Lo{constructor(e,t){v(this,"editing",null);v(this,"fullRowEditors",null);v(this,"fullRowNode",null);v(this,"focusedCell",null);v(this,"suppressClickEdit",!1);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.grid.getRowRenderer().refreshCells({force:!0}),this.clearFocusClass();const i=this.findCellElement(t,e);i==null||i.classList.add("ag-cell-focus"),i&&typeof i.scrollIntoView=="function"&&i.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 i=this.grid.getDisplayedRowAtIndex(t);if(!i)return null;const o=this.grid.getRowRenderer().getRowComps().get(i.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 c;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const i=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!i||!this.grid.isCellEditable(t,i))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,i,e.charPress);return}const n=this.findCellElement(t,e.rowIndex);if(!n)return;const o=de(t,i,this.grid.getApi()),a={value:e.charPress!==void 0?e.charPress:o,oldValue:o,data:i.data,node:i,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(c=t.cellEditorParams)==null?void 0:c.values,...t.cellEditorParams};let r=null;if(typeof t.cellEditor=="string")r=(it[t.cellEditor]||it.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const d=t.cellEditor(a);r=d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}else{const d=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";r=it[d](a)}if(!r)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:n,editor:r,startedValue:o},n.classList.add("ag-cell-inline-editing");const l=r.getGui();l.classList.add("ag-cell-editor"),n.appendChild(l),n.classList.add("ag-cell-editing"),r.focusIn&&r.focusIn(),r.afterGuiAttached&&r.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:i,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,i){const n=[...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 n){const a=this.findCellElement(o,e);if(!a)continue;const r=de(o,t,this.grid.getApi()),l=this.createEditor(o,t,e,r,i);if(!l)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const c=l.getGui();c.classList.add("ag-cell-editor"),a.appendChild(c),this.fullRowEditors.push({column:o,editor:l,eCell:a,startedValue:r})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,n,o){var l;const a={value:o!==void 0?o:n,oldValue:n,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:i,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(l=e.cellEditorParams)==null?void 0:l.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(it[e.cellEditor]||it.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const c=e.cellEditor(a);return c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}const r=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return it[r](a)}stopEditing(e=!1){var c,d,u,f;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:i,rowNode:n,eCell:o,editor:a,startedValue:r}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let l=e?r:a.getValue();if(l===void 0&&!e)return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!1;if(!e){l=Di(i,l);const g=this.applyValueSetter(i,n,l);if(g===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:i}),!1;l=g}return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!e&&!zi(l,r)&&(this.grid.setCellValue(i,n,l,"edit",r),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r,newValue:l,value:l,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(f=(u=this.grid.getOptions()).onCellValueChanged)==null||f.call(u,{oldValue:r,newValue:l,value:l,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[n],columns:[i],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,i){if(e.valueSetter){if(e.valueSetter({oldValue:de(e,t,this.grid.getApi()),newValue:i,data:t.data,node:t,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else t.setDataValue(e.colId,i);return i}stopFullRowEditing(e){var o,a,r;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const l of t)l.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=l.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),l.editor.destroy&&l.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const n=[];for(const l of t){if(!i)break;let c=l.editor.getValue();c!==void 0&&(c=Di(l.column,c),zi(c,l.startedValue)||n.push({column:l.column,rowNode:i,newValue:c,oldValue:l.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const l of n)this.grid.setCellValue(l.column,l.rowNode,l.newValue,"edit",l.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l.oldValue,newValue:l.newValue,value:l.newValue,data:l.rowNode.data,node:l.rowNode,column:l.column,colDef:l.column.colDef,api:this.grid.getApi(),source:"edit"}),(r=(a=this.grid.getOptions()).onCellValueChanged)==null||r.call(a,{oldValue:l.oldValue,newValue:l.newValue,value:l.newValue,data:l.rowNode.data,node:l.rowNode,column:l.column,colDef:l.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[l.rowNode],columns:[l.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===rt){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===Dn)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===Ri){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 i=this.focusedCell;switch(e.keyCode){case rt:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case Ri:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case Mi:case ki:i&&this.grid.isCellEditable(i.column,i.rowNode)&&(e.preventDefault(),this.grid.setCellValue(i.column,i.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[i.rowNode],columns:[i.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 An:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case Fn: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}i&&t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(i.column,i.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:i.rowIndex,colKey:i.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 i=this.focusedCell;if(!i){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let n=i.rowIndex;if(e===-1/0?n=0:e===1/0?n=this.grid.getDisplayedRowCount()-1:n=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,n+e)),t!==0){const o=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let r=o.findIndex(l=>l.colId===i.column.colId)+t;for(;r>=0&&r<o.length&&!o[r].visible;)r+=t;r<0&&(r=0),r>=o.length&&(r=o.length-1),this.setFocusedCell(n,o[r])}else this.setFocusedCell(n,i.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:i,event:n}=e;if(this.setFocusedCell(e.rowIndex,i),i.checkboxSelection)return;const o=this.grid.isCellEditable(i,t),a=i.singleClickEdit||this.grid.getOptions().singleClickEdit;o&&a&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}onCellDoubleClicked(e){const{node:t,column:i}=e;this.setFocusedCell(e.rowIndex,i),this.grid.isCellEditable(i,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}destroy(){this.editing=null,this.focusedCell=null}}function zi(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}class Do{constructor(e){v(this,"filterModel",{});v(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 i=this.grid.getRowModel(),n=typeof i.doesNodePassFilterModel=="function"?i.doesNodePassFilterModel.bind(i):null,o=t.conditions.map(a=>{const r=this.grid.getColumn(a.colId);return!r||!n?!0:n(e,r,{...a,filterType:r.filter===!0?"text":r.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 i=typeof e=="string"?e:e.colId;t==null?delete this.filterModel[i]:this.filterModel[i]=t,this.onFilterChanged("api")}isFilterActive(e){const t=this.filterModel[e.colId];return t?t.filterType==="multi"?(t.filterModels||[]).some(n=>this.isModelMeaningful(n)):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 i,n;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(n=(i=this.grid.getOptions()).onFilterChanged)==null||n.call(i,{api:t,source:e})}}class Ao{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,i){const n=this.grid.getOptions().suppressMultiSort,o=i&&!n&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,a=this.getSortingOrder(),r=e.sort;let l=a.indexOf(r)+1;l>=a.length&&(l=0);const c=a[l];if(!o)for(const d of this.grid.getAllColumns())d.colId!==e.colId&&(d.sort=null,d.sortIndex=null);e.sort=c,c===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,i)=>(t.sortIndex??99)-(i.sortIndex??99)).forEach((t,i)=>t.sortIndex=i)}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,i)=>{const n=this.grid.getColumn(t.colId);n&&(n.sort=t.sort,n.sortIndex=i)}),this.onSortChanged("api")}onSortChanged(e){var i,n;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(n=(i=this.grid.getOptions()).onSortChanged)==null||n.call(i,{api:t,source:e})}}class Wi{constructor(e,t){v(this,"enabled");v(this,"pageSize");v(this,"currentPage",0);v(this,"pageSizeSelector");v(this,"ePanel");v(this,"ePageInfo");v(this,"ePageInput");v(this,"ePageSizeSelect",null);v(this,"ePageSizeContainer");v(this,"eFromToContainer");this.grid=e,this.eventService=t;const i=e.getOptions();this.enabled=i.pagination===!0,this.pageSize=i.paginationPageSize??100,this.pageSizeSelector=i.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 n=document.createElement("div");n.className="ag-pagination-buttons",this.ePanel.appendChild(n),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",n.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",n.appendChild(this.eFromToContainer);const o=document.createElement("span");if(o.className="ag-pagination-page-label",o.textContent=`${this.grid.translate("page","Page")}`,n.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)}),n.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",n.appendChild(this.ePageInfo),this.pageSizeSelector){const a=this.ePageSizeContainer,r=document.createElement("span");r.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(r);const l=document.createElement("select");l.className="ag-pagination-page-size-select";const c=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const d of c){const u=document.createElement("option");u.value=String(d),u.textContent=String(d),d===this.pageSize&&(u.selected=!0),l.appendChild(u)}l.addEventListener("change",()=>this.setPageSize(parseInt(l.value,10))),a.appendChild(l),this.ePageSizeSelect=l}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(),i=Math.max(0,Math.min(t-1,e));if(i===this.currentPage){this.update();return}this.currentPage=i,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 r,l;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(),i=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),n=i===0?0:this.currentPage*this.pageSize+1,o=Math.min(i,(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=i===0?`0 ${a} 0 ${this.grid.translate("of","/")} 0`:`${n.toLocaleString()} ${a} ${o.toLocaleString()} ${this.grid.translate("of","/")} ${i.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:i}),(l=(r=this.grid.getOptions()).onPaginationChanged)==null||l.call(r,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Fo{constructor(e){v(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,t=""){const i=document.createElement("div");i.className=`ag-popup ${t}`.trim(),i.style.width=`${e}px`,i.style.display="none";const n={ePopup:i},o=()=>{var c;this.openPopups.has(n)&&(this.openPopups.delete(n),i.remove(),document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l,!0),(c=n.onClose)==null||c.call(n))},a=c=>{n.onClose=c},r=c=>{if(!i.contains(c.target)&&!this.grid.getRootElement().contains(c.target)){o();return}i.contains(c.target)||o()},l=c=>{c.key==="Escape"&&(c.stopPropagation(),o())};return this.getParent().appendChild(i),this.openPopups.add(n),document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l,!0),{ePopup:i,close:o,onClose:a}}positionAt(e,t,i=0){const n=this.grid.getRootElement().getBoundingClientRect(),o=t.getBoundingClientRect(),a=e.offsetWidth||220;let r=o.left-n.left+i;const l=n.width-a-4;r>l&&(r=l),r<4&&(r=4);const c=o.bottom-n.top+2;e.style.left=`${r}px`,e.style.top=`${c}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}const Tt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Nt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class Po{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var h,m;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const i=e.filter===!0?"text":e.filter,n=this.grid.getFilterService().getFilterInstance(e.colId),o=i==="set"?260:240,{ePopup:a,close:r}=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);let c=n?{...n}:this.getDefaultModel(i),d=n?{...n}:null;const u=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),r()},f=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()};if(i==="set")a.appendChild(this.buildSetFilter(e,c,y=>{d=y}));else if(i==="boolean"){const y=this.buildConditionSelect(["true","false"],String(c.filter??""),E=>{d={filterType:"boolean",filter:E==="true"}});a.appendChild(y)}else{const y=i==="number"?Nt:Tt,E=this.buildConditionSelect(y,c.type||y[0],R=>{c.type=R,d={...c}});if(a.appendChild(E),c.type!=="blank"&&c.type!=="notBlank")if(i==="number"&&c.type==="inRange"){const R=document.createElement("div");R.className="ag-filter-inputs";const S=document.createElement("input");S.type="number",S.className="ag-filter-input",S.value=c.filter??"",S.placeholder=this.grid.t("from"),S.addEventListener("input",()=>{d={...c,filter:S.value,filterTo:A.value}});const A=document.createElement("input");A.type="number",A.className="ag-filter-input",A.value=c.filterTo??"",A.placeholder=this.grid.t("to"),A.addEventListener("input",()=>{d={...c,filter:S.value,filterTo:A.value}}),R.appendChild(S),R.appendChild(A),a.appendChild(R)}else if(i==="date"){const R=document.createElement("div");R.className="ag-filter-inputs";const S=document.createElement("input");S.type="date",S.className="ag-filter-input",S.value=c.dateFrom??"",S.addEventListener("input",()=>{d={...c,dateFrom:S.value,dateTo:A.value}});const A=document.createElement("input");A.type="date",A.className="ag-filter-input",A.value=c.dateTo??"",A.addEventListener("input",()=>{d={...c,dateFrom:S.value,dateTo:A.value}}),R.appendChild(S),R.appendChild(A),a.appendChild(R)}else{const R=document.createElement("input");R.type=i==="number"?"number":"text",R.className="ag-filter-input",R.value=c.filter??"",R.placeholder=this.grid.t("filterOoo"),R.addEventListener("input",()=>{d={...c,filter:R.value}}),R.addEventListener("keydown",S=>{S.key==="Enter"&&u()}),a.appendChild(R),setTimeout(()=>R.focus(),0)}else d={...c}}if(i==="text"||i==="number"){const y=document.createElement("div");y.className="ag-filter-second-condition";const E=document.createElement("select");E.className="ag-filter-condition",E.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,E.value=c.operator||"AND",y.appendChild(E);const R=this.buildConditionSelect(i==="number"?Nt:Tt,((h=c.condition2)==null?void 0:h.type)||(i==="number"?Nt:Tt)[0],A=>{d||(d={...c}),d.condition2={...d.condition2,type:A}});y.appendChild(R);const S=document.createElement("input");S.type=i==="number"?"number":"text",S.className="ag-filter-input",S.placeholder=this.grid.t("secondValue"),S.value=((m=c.condition2)==null?void 0:m.filter)??"",S.addEventListener("input",()=>{d||(d={...c}),d.condition2={...d.condition2,filter:S.value}}),y.appendChild(S),a.appendChild(y),E.addEventListener("change",()=>{d||(d={...c}),d.operator=E.value})}const g=document.createElement("div");g.className="ag-popup-buttons";const p=document.createElement("button");p.className="ag-button ag-button-primary",p.textContent=this.grid.t("apply"),p.addEventListener("click",u);const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",f),g.appendChild(C),g.appendChild(p),a.appendChild(g),this.popupService.positionAt(a,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,i){const n=document.createElement("div");n.className="ag-set-filter";const o=document.createElement("input");o.type="text",o.className="ag-filter-input",o.placeholder=this.grid.t("search"),n.appendChild(o);const a=new Set;this.grid.getRowModel().forEachNode(C=>{!C.group&&!C.footer&&a.add(de(e,C,this.grid.getApi()))});let l=[...a].sort((C,h)=>C===h?0:C<h?-1:1);const c=document.createElement("div");c.className="ag-set-filter-list";const d=new Set((t.values||[]).map(C=>String(C))),u=()=>{c.innerHTML="";const C=o.value.toLowerCase();let h=0;for(const m of l){const y=m==null?"(Blanks)":String(m);if(C&&!y.toLowerCase().includes(C))continue;h++;const E=document.createElement("label");E.className="ag-set-filter-item";const R=document.createElement("input");R.type="checkbox",R.checked=d.has(String(m)),R.addEventListener("change",()=>{R.checked?d.add(String(m)):d.delete(String(m)),i({filterType:"set",values:[...d]})});const S=document.createElement("span");S.textContent=y,E.appendChild(R),E.appendChild(S),c.appendChild(E)}if(h===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),c.appendChild(m)}};o.addEventListener("input",u),u();const f=document.createElement("div");f.className="ag-set-filter-actions";const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent=this.grid.t("selectAll"),g.addEventListener("click",()=>{d.clear();for(const C of l)d.add(String(C));u(),i({filterType:"set",values:[...d]})});const p=document.createElement("button");return p.className="ag-button ag-button-small",p.textContent=this.grid.t("clearAll"),p.addEventListener("click",()=>{d.clear(),u(),i({filterType:"set",values:[]})}),f.appendChild(g),f.appendChild(p),n.appendChild(c),n.appendChild(f),i({filterType:"set",values:[...d]}),n}buildConditionSelect(e,t,i){const n=document.createElement("select");n.className="ag-filter-condition";for(const o of e){const a=document.createElement("option");a.value=o;const r=Qn[o];a.textContent=r?this.grid.t(r):o,o===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n}openMultiFilter(e,t){var E;const i=this.grid.getFilterService().getFilterInstance(e.colId),n=i&&i.filterType==="multi"?i:null,o=(E=n==null?void 0:n.filterModels)!=null&&E.length?n.filterModels.map(R=>({...R})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(n==null?void 0:n.operator)||"AND";const{ePopup:r,close:l}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");r.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`Filters for ${e.headerName||e.field||""}`,r.appendChild(c);const d=document.createElement("div");d.className="ag-multi-filter-operator";const u=document.createElement("span");u.textContent=this.grid.t("join");const f=document.createElement("select");f.className="ag-filter-condition",f.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',f.value=a,f.addEventListener("change",()=>{a=f.value}),d.appendChild(u),d.appendChild(f),r.appendChild(d);const g=document.createElement("div");g.className="ag-multi-filter-list",r.appendChild(g);const p=()=>{g.innerHTML="",o.forEach((R,S)=>{const A=document.createElement("div");A.className="ag-multi-filter-row";const B=document.createElement("select");B.className="ag-filter-condition";const L=["text","number","date","set","boolean"];for(const D of L){const k=document.createElement("option");k.value=D,k.textContent=D.charAt(0).toUpperCase()+D.slice(1),D===R.filterType&&(k.selected=!0),B.appendChild(k)}B.addEventListener("change",()=>{o[S]={...this.getDefaultModel(B.value)},p()}),A.appendChild(B);const j=R.filterType==="number"?Nt:Tt,W=this.buildConditionSelect(j,R.type||j[0],D=>{o[S].type=D});if(A.appendChild(W),R.filterType!=="blank"&&R.type!=="blank"&&R.type!=="notBlank"){const D=document.createElement("input");D.type=R.filterType==="number"?"number":"text",D.className="ag-filter-input",D.value=R.filter??"",D.placeholder=this.grid.t("value"),D.addEventListener("input",()=>{o[S].filter=D.value}),A.appendChild(D)}const M=document.createElement("button");M.className="ag-button ag-button-small",M.textContent="×",M.title=this.grid.t("removeFilter"),M.addEventListener("click",()=>{o.splice(S,1),p()}),A.appendChild(M),g.appendChild(A)})};p();const C=document.createElement("button");C.className="ag-button ag-button-small",C.textContent="+ "+this.grid.t("addFilter"),C.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),p()}),r.appendChild(C);const h=document.createElement("div");h.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(S=>S.filter!==void 0&&S.filter!==""||S.type==="blank"||S.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),l()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),l()}),h.appendChild(y),h.appendChild(m),r.appendChild(h),this.popupService.positionAt(r,t)}openAdvancedFilter(e){var E,R;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),n=(E=i==null?void 0:i.conditions)!=null&&E.length?i.conditions.map(S=>({...S})):[{colId:((R=this.grid.getColumns().center[0])==null?void 0:R.colId)??"",type:"contains",filter:""}];let o=(i==null?void 0:i.operator)||"AND";const{ePopup:a,close:r}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=this.grid.t("advancedFilter"),a.appendChild(l);const c=document.createElement("div");c.className="ag-advanced-filter-list",a.appendChild(c);const d=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(S=>S.filter),u=()=>{c.innerHTML="",n.forEach((S,A)=>{const B=document.createElement("div");B.className="ag-advanced-filter-row";const L=document.createElement("select");L.className="ag-filter-condition";for(const _ of d()){const Q=document.createElement("option");Q.value=_.colId,Q.textContent=_.headerName||_.field||_.colId,_.colId===S.colId&&(Q.selected=!0),L.appendChild(Q)}L.addEventListener("change",()=>{n[A].colId=L.value}),B.appendChild(L);const j=this.grid.getColumn(S.colId),W=j&&j.filter!==!1?String(j.filter):"text",M=W==="number"?Nt:Tt,D=this.buildConditionSelect(M,S.type||"contains",_=>{n[A].type=_});B.appendChild(D);const k=document.createElement("input");k.type=W==="number"?"number":"text",k.className="ag-filter-input",k.value=S.filter??"",k.placeholder=this.grid.t("value"),k.addEventListener("input",()=>{n[A].filter=k.value}),B.appendChild(k);const z=document.createElement("button");z.className="ag-button ag-button-small",z.textContent="×",z.addEventListener("click",()=>{n.splice(A,1),u()}),B.appendChild(z),c.appendChild(B)})};u();const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent="+ "+this.grid.t("addCondition"),f.addEventListener("click",()=>{var S;n.push({colId:((S=d()[0])==null?void 0:S.colId)??"",type:"contains",filter:""}),u()}),a.appendChild(f);const g=document.createElement("div");g.className="ag-multi-filter-operator";const p=document.createElement("span");p.textContent=this.grid.t("join");const C=document.createElement("select");C.className="ag-filter-condition",C.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',C.value=o,C.addEventListener("change",()=>{o=C.value}),g.appendChild(p),g.appendChild(C),a.appendChild(g);const h=document.createElement("div");h.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 S=n.filter(A=>A.filter!==void 0&&A.filter!=="");S.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:S}):t.setAdvancedFilterModel(null),r()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{t.setAdvancedFilterModel(null),r()}),h.appendChild(y),h.appendChild(m),a.appendChild(h),this.popupService.positionAt(a,e)}openCustomFilter(e,t){const i=e.colDef.filterComponent;if(typeof i!="function")return;const n=this.grid.getFilterService(),o=i({column:e,colDef:e.colDef,api:this.grid.getApi(),model:n.getFilterInstance(e.colId)??null,onModelChange:c=>n.setColumnFilterModel(e,c),onGuiAttached:()=>{}}),{ePopup:a,close:r}=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}}const Ui={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 $o{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 i=this.grid.getOptions().contextMenuItems;let n;typeof i=="function"?n=i({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(i)?n=i:n=this.getDefaultItems(t);const{ePopup:o,close:a}=this.popupService.createPopup(220,"ag-context-menu");o.innerHTML="",this.buildMenu(o,n,a),this.popupService.positionAt(o,e)}buildMenu(e,t,i){for(const n of t){if(typeof n=="string")continue;if(n.separator){const l=document.createElement("div");l.className="ag-menu-separator",e.appendChild(l);continue}const o=document.createElement("div");o.className="ag-menu-item",n.disabled&&o.classList.add("ag-menu-item-disabled"),n.cssClasses&&o.classList.add(...n.cssClasses);const a=document.createElement("span");a.className="ag-menu-item-icon",n.icon&&Ui[n.icon]&&(a.innerHTML=Ui[n.icon]),o.appendChild(a);const r=document.createElement("span");if(r.className="ag-menu-item-label",r.textContent=n.label??n.name,o.appendChild(r),n.shortcut){const l=document.createElement("span");l.className="ag-menu-item-shortcut",l.textContent=n.shortcut,o.appendChild(l)}if(n.subMenu){const l=document.createElement("span");l.className="ag-menu-item-arrow",l.textContent="›",o.appendChild(l),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(u=>u.remove());const d=document.createElement("div");d.className="ag-menu-popup-sub",this.buildMenu(d,n.subMenu,i),e.appendChild(d)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var d;o.matches(":hover")||((d=o.parentElement)==null?void 0:d.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(u=>u.remove())},200)})}else!n.disabled&&n.action&&o.addEventListener("click",()=>{n.action(),i()});e.appendChild(o)}}}class Go{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:i,close:n}=this.popupService.createPopup(220,"ag-column-menu");i.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=e.headerName||e.field||e.colId,i.appendChild(o);const a=(l,c)=>{const d=document.createElement("div");d.className="ag-menu-item",c.disabled&&d.classList.add("ag-menu-item-disabled"),c.checked&&d.classList.add("ag-menu-item-active");const u=document.createElement("span");u.className="ag-menu-item-check",c.checked&&(u.innerHTML=Bi),d.appendChild(u);const f=document.createElement("span");if(f.className="ag-menu-item-label",f.textContent=l,d.appendChild(f),c.shortcut){const g=document.createElement("span");g.className="ag-menu-item-shortcut",g.textContent=c.shortcut,d.appendChild(g)}return!c.disabled&&c.onClick&&d.addEventListener("click",()=>{c.onClick(),n()}),i.appendChild(d),d},r=l=>{const c=document.createElement("div");c.className="ag-menu-section",c.textContent=l,i.appendChild(c)};e.sortable&&(r(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&&(r(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||(r(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?(r(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&&(r(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),r(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)}),r(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(i,t)}}class Ho{constructor(e,t){v(this,"eBar");v(this,"panels",[]);this.grid=e,this.eventService=t,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const n=e.getOptions().statusBar;(!n||!n.statusPanels||n.statusPanels.length===0)&&(this.eBar.style.display="none");const o=((n==null?void 0:n.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 r=document.createElement("div");r.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(r);const l={def:a,ePanel:r,render:()=>this.renderPanel(a.key,r)};this.panels.push(l)}}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 i=this.grid.getApi(),n=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,r=i.getSelectedNodes().length,l=[],c=this.grid.getColumnModel().getValueColumns().filter(d=>d.aggFunc);switch(this.grid.getRowModel().forEachNode(d=>{!d.footer&&d.group}),e){case"agTotalRowCountComponent":l.push(`${this.grid.translate("totalRows","Total Rows")} : ${Ke(a)}`);break;case"agTotalAndFilteredRowCountComponent":l.push(`${this.grid.translate("rows","Rows")} : ${Ke(n)}`);break;case"agFilteredRowCountComponent":l.push(`${this.grid.translate("filtered","Filtered")} : ${Ke(n)}`);break;case"agSelectedRowCountComponent":l.push(`${this.grid.translate("selected","Selected")} : ${Ke(r)}`);break;case"agAggregationComponent":{if(c.length===0)break;const d=i.getSelectedNodes().filter(f=>!f.group&&!f.footer),u=[];for(const f of c){const p=d.map(y=>de(f,y,i)).filter(y=>typeof y=="number"&&!isNaN(y)),C=p.reduce((y,E)=>y+E,0),h=y=>y===null?"":Ke(y,f.decimals),m=[[this.grid.translate("average","Average"),p.length?C/p.length:null],[this.grid.translate("count","Count"),p.length],[this.grid.translate("min","Min"),p.length?Math.min(...p):null],[this.grid.translate("max","Max"),p.length?Math.max(...p):null],[this.grid.translate("sum","Sum"),p.length?C:null]];for(const[y,E]of m)u.push(`${y}${f.headerName?` (${f.headerName})`:""} : ${h(E)}`)}u.length&&l.push(u.join(" "));break}default:l.push(e);break}t.textContent=l.join(" "),t.style.display=l.length?"":"none"}}class Oo{constructor(e){v(this,"eBar");v(this,"eButtons");v(this,"ePanel");v(this,"panels",[]);v(this,"activePanelId",null);v(this,"visible",!1);v(this,"position");var i,n;this.grid=e;const t=e.getOptions();if(this.position=typeof t.sideBar=="object"&&((i=t.sideBar)!=null&&i.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(l=>typeof l=="string"?{id:l,label:this.defaultLabel(l)}:{id:l.id,label:l.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 r=(o==null?void 0:o.defaultToolPanel)||((n=this.panels[0])==null?void 0:n.id)||"columns";this.buildButtons(),this.openPanel(r)}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 i=document.createElement("div");i.className="ag-column-panel-columns",e.appendChild(i);const n=()=>{const c=t.value.toLowerCase();i.innerHTML="";const d=this.grid.getColumnModel().getColumns(),u=d.filter(f=>f.pinned!=="left"&&f.pinned!=="right").concat(d.filter(f=>f.pinned==="left"||f.pinned==="right"));for(const f of u)c&&!f.headerName.toLowerCase().includes(c)&&!f.colId.toLowerCase().includes(c)||i.appendChild(this.buildColumnItem(f));if(!i.children.length){const f=document.createElement("div");f.className="ag-side-bar-empty",f.textContent=this.grid.t("noMatchingColumns"),i.appendChild(f)}};t.addEventListener("input",n),n();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 r=document.createElement("div");r.className="ag-column-group-list",o.appendChild(r);const l=()=>{r.innerHTML="";const c=this.grid.getColumnModel().getRowGroupColumns();if(c.length===0){const d=document.createElement("div");d.className="ag-column-group-hint",d.textContent=this.grid.t("dragColumnsHere"),r.appendChild(d)}for(const d of c){const u=document.createElement("div");u.className="ag-column-group-item",u.draggable=!0,u.addEventListener("dragstart",p=>{var C;(C=p.dataTransfer)==null||C.setData("text/plain",d.colId)}),u.addEventListener("dragover",p=>p.preventDefault()),u.addEventListener("drop",p=>{var h;p.preventDefault();const C=(h=p.dataTransfer)==null?void 0:h.getData("text/plain");C&&this.grid.getColumnModel().setRowGroupColumns([...c.map(m=>m.colId),C])});const f=document.createElement("span");f.textContent=d.headerName,u.appendChild(f);const g=document.createElement("button");g.className="ag-column-group-remove",g.textContent="×",g.title=this.grid.t("remove"),g.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(d)),u.appendChild(g),r.appendChild(u)}};return l(),r.addEventListener("dragover",c=>c.preventDefault()),r.addEventListener("drop",c=>{var u;c.preventDefault();const d=(u=c.dataTransfer)==null?void 0:u.getData("text/plain");d&&this.grid.getColumnModel().addRowGroupColumn(d)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&l()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&n()}),e}buildColumnItem(e){const t=document.createElement("div");t.className="ag-column-select-column",t.draggable=!0,t.dataset.colid=e.colId;const i=document.createElement("input");i.type="checkbox",i.className="ag-column-select-checkbox",i.checked=e.visible,i.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,i.checked)}),t.appendChild(i);const n=document.createElement("span");n.className="ag-column-select-label",n.textContent=e.headerName||e.colId,t.appendChild(n);const o=document.createElement("span");if(o.className="ag-column-select-actions",e.enableRowGroup&&e.field){const r=document.createElement("button");r.className="ag-column-select-action",r.title=this.grid.t("groupByThisColumn"),r.textContent="≡",r.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(r)}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 r=document.createElement("span");r.className="ag-filters-tool-panel-item-badge",r.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(r)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const i=document.createElement("div");i.className="ag-filters-panel-list",e.appendChild(i);const n=()=>{const o=t.value.toLowerCase();i.innerHTML="";const a=this.grid.getColumns().center.filter(r=>r.filter);for(const r of a)o&&!r.headerName.toLowerCase().includes(o)||i.appendChild(this.buildFilterItem(r));if(!i.children.length){const r=document.createElement("div");r.className="ag-side-bar-empty",r.textContent=this.grid.t("noMatchingColumns"),i.appendChild(r)}};return t.addEventListener("input",n),n(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&n()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),i=document.createElement("div");i.className="ag-filters-tool-panel-item";const n=document.createElement("div");n.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,n.appendChild(o);const a=t.isFilterActive(e);if(a){const r=document.createElement("span");r.className="ag-filters-tool-panel-item-badge",r.innerHTML=Bi,n.appendChild(r)}if(i.appendChild(n),e.filter==="set"){const r=document.createElement("button");r.className="ag-button ag-button-small",r.textContent=a?"Edit filter":"Add filter",r.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,r)),i.appendChild(r)}else if(e.filter==="date"){const r=document.createElement("input");r.type="date",r.className="ag-filter-input";const l=t.getFilterInstance(e.colId);r.value=(l==null?void 0:l.dateFrom)??"",r.addEventListener("change",()=>{t.setColumnFilterModel(e,r.value?{filterType:"date",dateFrom:r.value,dateTo:r.value}:null)}),i.appendChild(r)}else{const r=document.createElement("input");r.type=e.filter==="number"?"number":"text",r.className="ag-filter-input",r.placeholder=this.grid.t("filterOoo");const l=t.getFilterInstance(e.colId);r.value=(l==null?void 0:l.filter)??"",r.addEventListener("input",()=>{t.handleFloatingFilterChange(e,r.value)}),i.appendChild(r)}if(a){const r=document.createElement("button");r.className="ag-button ag-button-small",r.textContent=this.grid.t("clear"),r.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(r)}return i}}class Bo{constructor(e,t){v(this,"matches",[]);v(this,"activeMatch",0);v(this,"searchText","");v(this,"matchCase",!1);v(this,"ePopup",null);v(this,"eCount",null);v(this,"eInput",null);v(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var l,c;if(this.ePopup){(l=this.eInput)==null||l.focus(),(c=this.eInput)==null||c.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const i=document.createElement("input");i.type="text",i.className="ag-find-input",i.placeholder=this.grid.translate("find","Find in grid..."),i.value=this.searchText,this.eInput=i,e.appendChild(i);const n=document.createElement("label");n.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)}),n.appendChild(o),n.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(n);const a=document.createElement("span");a.className="ag-find-count",this.eCount=a,e.appendChild(a);const r=(d,u,f)=>{const g=document.createElement("button");return g.className="ag-button ag-button-small",g.textContent=d,g.title=u,g.addEventListener("click",f),e.appendChild(g),g};r("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),r("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),r("×",this.grid.translate("close","关闭"),()=>this.close()),i.addEventListener("input",()=>this.find(i.value)),i.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),d.shiftKey?this.findPrevious():this.findNext()):d.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(()=>i.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((i,n)=>{if(!(i.group||i.footer))for(const o of t){de(o,i,this.grid.getApi());const a=Ot(o,i,this.grid.getApi())??"",r=this.matchCase?a:a.toLowerCase(),l=this.matchCase?e:e.toLowerCase();r.includes(l)&&this.matches.push({rowIndex:n,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 r=t.getPageSize(),l=Math.floor(e.rowIndex/r);l!==t.getCurrentPage()&&t.goToPage(l)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const i=this.grid.getDisplayedRowAtIndex(e.rowIndex),n=this.grid.getColumn(e.colId);i&&n&&this.grid.getEditService().setFocusedCell(e.rowIndex,n)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,i]of e){let n=-1;this.grid.getRowModel().forEachNode((o,a)=>{o.id===t&&(n=a)});for(const o of i.getCellElements()){const a=o.dataset.colid,r=this.matches.findIndex(l=>l.rowIndex===n&&l.colId===a);o.classList.toggle("ag-find-match",r>=0),o.classList.toggle("ag-find-active-match",r>=0&&r===this.activeMatch)}}}}class Vo{constructor(e,t){v(this,"ranges",[]);v(this,"currentRange",null);v(this,"eOverlay");v(this,"eHandle");v(this,"dragState",null);this.grid=e,this.eventService=t;const i=e.getRowRenderer().getContainer();i.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",i.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",i.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:i,rowIndex:n}=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:n,colEndId:i.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const o={rowStartIndex:n,rowEndIndex:n,colStartId:i.colId,colEndId:i.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 i=t.closest(".ag-cell");if(!(i!=null&&i.dataset.colid))return;const n=i.closest(".ag-row");if(!(n!=null&&n.dataset.rowid))return;const o=this.grid.getRowModel().getRowNode(n.dataset.rowid);if(!o)return;let a=-1;if(this.grid.getRowModel().forEachNode((l,c)=>{l.id===o.id&&(a=c)}),a<0)return;const r=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(r.rowStartIndex,a),rowEndIndex:Math.max(r.rowStartIndex,a),colStartId:r.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(r.rowStartIndex,a),this.currentRange.colEndId=i.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(),i=t.findIndex(C=>C.colId===e.colStartId),n=t.findIndex(C=>C.colId===e.colEndId);if(i<0||n<0)return null;const o=Math.min(i,n),a=Math.max(i,n);let r=0,l=0;for(let C=0;C<=a;C++)C<o?r+=t[C].width:l+=t[C].width;const d=this.grid.getRowRenderer().getRowOffsets(),u=Math.min(e.rowStartIndex,e.rowEndIndex),f=Math.max(e.rowStartIndex,e.rowEndIndex),g=d[u]??u*(this.grid.getOptions().rowHeight??42);let p=0;for(let C=u;C<=f;C++){const h=this.grid.getDisplayedRowAtIndex(C);p+=h?this.grid.getRowHeight(h):this.grid.getOptions().rowHeight??42}return{top:g,left:r,width:l,height:p}}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=i=>this.onHandleMouseDown(i)}applyHighlight(){const e=this.ranges,t=this.grid.getRowRenderer().getRowComps(),i=this.getCenterColumns();for(const[n,o]of t){let a=-1;if(this.grid.getRowModel().forEachNode((r,l)=>{r.id===n&&(a=l)}),!(a<0))for(const r of o.getCellElements()){const l=r.dataset.colid,c=i.findIndex(f=>f.colId===l);let d=!1,u=!1;for(const f of e){const g=i.findIndex(E=>E.colId===f.colStartId),p=i.findIndex(E=>E.colId===f.colEndId),C=Math.min(f.rowStartIndex,f.rowEndIndex),h=Math.max(f.rowStartIndex,f.rowEndIndex),m=Math.min(g,p),y=Math.max(g,p);a>=C&&a<=h&&c>=m&&c<=y&&(d=!0,a===f.rowStartIndex&&c===g&&(u=!0))}r.classList.toggle("ag-cell-range-selected",d),r.classList.toggle("ag-cell-range-anchor",u)}}}getRangeCells(e){const t=this.getCenterColumns(),i=t.findIndex(d=>d.colId===e.colStartId),n=t.findIndex(d=>d.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),r=Math.min(i,n),l=Math.max(i,n),c=[];for(let d=o;d<=a;d++){const u=this.grid.getDisplayedRowAtIndex(d);if(u)for(let f=r;f<=l;f++)t[f]&&c.push({node:u,column:t[f]})}return c}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===ki||e.keyCode===Mi)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const i of this.getRangeCells(t))this.grid.setCellValue(i.column,i.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}function _i(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const nt=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class zo{constructor(e,t){v(this,"charts",new Map);v(this,"chartCounter",0);v(this,"currentType","line");v(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),i=t.getRowGroupColumns();let n=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(l=>l.aggFunc),a=[],r=o.map(()=>[]);if(i.length>0)((c,d)=>{for(const u of c)if(u.group){const f=i[0]?String(de(i[0],u,this.grid.getApi())??""):u.key??"";a.push(f);for(let g=0;g<o.length;g++){const p=[];qi(u,o[g],p),r[g].push(Number(kt(o[g],o[g].aggFunc,p))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(n||(n=this.grid.getColumns().center.find(l=>l.field&&l.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(l=>{if(l.group||l.footer)return;const c=n?de(n,l,this.grid.getApi()):"";a.push(String(c??""));for(let d=0;d<o.length;d++){const u=de(o[d],l,this.grid.getApi());r[d].push(typeof u=="number"?u:Number(u)||0)}}),a.length>200){const l=Math.ceil(a.length/200),c=[],d=r.map(()=>[]);for(let u=0;u<a.length;u+=l){c.push(a[u]);for(let f=0;f<r.length;f++)d[f].push(r[f][u])}return{categories:c,series:o.map((u,f)=>({title:u.headerName,data:d[f]}))}}return{categories:a,series:o.map((l,c)=>({title:l.headerName,data:r[c]}))}}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 i=document.createElement("div");i.className="ag-chart-panel-label",i.textContent=this.grid.t("chartType"),e.appendChild(i);const n=document.createElement("select");n.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 h of o){const m=document.createElement("option");m.value=h.value,m.textContent=h.label,h.value===this.currentType&&(m.selected=!0),n.appendChild(m)}n.addEventListener("change",()=>{this.currentType=n.value}),e.appendChild(n);const a=document.createElement("div");a.className="ag-chart-panel-label",a.textContent=this.grid.t("chartCategory"),e.appendChild(a);const r=document.createElement("select");r.className="ag-chart-panel-select";const l=this.grid.getColumnModel().getRowGroupColumns(),c=l.length>0?l:this.grid.getColumns().center.filter(h=>h.field);for(const h of c){const m=document.createElement("option");m.value=h.colId,m.textContent=l.length>0?`${this.grid.t("chartGroup")}: ${h.headerName}`:h.headerName,r.appendChild(m)}e.appendChild(r);const d=document.createElement("div");d.className="ag-chart-panel-label",d.textContent=this.grid.t("chartSeries"),e.appendChild(d);const u=this.grid.getColumnModel().getValueColumns().filter(h=>h.aggFunc),f=document.createElement("div");f.className="ag-chart-panel-series";const g=new Set(u.slice(0,3).map(h=>h.colId));for(const h 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=g.has(h.colId),y.addEventListener("change",()=>{y.checked?g.add(h.colId):g.delete(h.colId)}),m.appendChild(y);const E=document.createElement("span");E.textContent=h.headerName,m.appendChild(E),f.appendChild(m)}e.appendChild(f);const p=document.createElement("button");p.className="ag-button ag-button-primary ag-chart-panel-create",p.textContent=this.grid.t("createChart"),p.addEventListener("click",()=>{const h=this.grid.getColumn(r.value)||void 0,m=[...g].map(y=>this.grid.getColumn(y)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:h,valueColumns:m})}),e.appendChild(p);const C=document.createElement("div");if(C.className="ag-chart-panel-list",this.charts.size===0){const h=document.createElement("div");h.className="ag-side-bar-empty",h.textContent=this.grid.t("noChartsCreated"),C.appendChild(h)}for(const[h,m]of this.charts){const y=document.createElement("div");y.className="ag-chart-panel-list-item";const E=document.createElement("span");E.textContent=m.title,y.appendChild(E);const R=document.createElement("button");R.className="ag-column-group-remove",R.textContent="×",R.addEventListener("click",()=>this.destroyChart(h)),y.appendChild(R),C.appendChild(y)}return e.appendChild(C),e}createChart(e={}){var h,m,y,E;const t=e.type||this.currentType,i=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),n=`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 r=document.createElement("div");r.className="ag-chart-window-header";const l=document.createElement("span");l.className="ag-chart-window-title",l.textContent=o,r.appendChild(l);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent=this.grid.t("downloadPng"),r.appendChild(c);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent="×",d.title=this.grid.t("close"),d.addEventListener("click",()=>this.destroyChart(n)),r.appendChild(d),a.appendChild(r);const u=document.createElement("div");u.className="ag-chart-window-body";const f=document.createElement("canvas");f.className="ag-chart-canvas",f.width=600,f.height=360,u.appendChild(f);const g=document.createElement("div");g.className="ag-chart-tooltip",g.style.display="none",u.appendChild(g),f.addEventListener("mousemove",R=>this.onChartHover({id:n,ePopup:a,canvas:f,type:t,data:i,title:o},R,g)),f.addEventListener("mouseleave",()=>{g.style.display="none"});const p=document.createElement("div");p.className="ag-chart-legend",u.appendChild(p),a.appendChild(u),this.timeSeries=i.categories.length>0&&i.categories.every(R=>!isNaN(Date.parse(String(R)))&&isNaN(Number(R)));const C={id:n,ePopup:a,canvas:f,type:t,data:i,title:o};return this.charts.set(n,C),c.addEventListener("click",()=>{const R=f.toDataURL("image/png"),S=document.createElement("a");S.href=R,S.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,S.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(C),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:n,chartTitle:o,api:this.grid.getApi()}),(m=(h=this.grid.getOptions()).onChartCreated)==null||m.call(h,{chartId:n,chartTitle:o,api:this.grid.getApi()}),((y=this.grid.getSideBarService())==null?void 0:y.getActivePanel())==="charts"&&((E=this.grid.getSideBarService())==null||E.refresh()),n}destroyChart(e){var i,n,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()}),(n=(i=this.grid.getOptions()).onChartDestroyed)==null||n.call(i,{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,i){const o=e.canvas.getBoundingClientRect(),a=600/(o.width||1),r=360/(o.height||1),l=(t.clientX-o.left)*a,c=(t.clientY-o.top)*r,d={top:20,right:20,bottom:34,left:56},u=600-d.left-d.right,f=360-d.top-d.bottom;if(l<d.left||l>d.left+u||c<d.top||c>d.top+f){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const g=e.type==="bar",p=Math.max(1,e.data.categories.length),C=(g?f:u)/p,h=Math.floor((g?c-d.top:l-d.left)/C);if(h<0||h>=e.data.categories.length){i.style.display="none";return}const m=e.data.series.map(y=>`${y.title}: ${this.formatTick(y.data[h]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${_i(e.data.categories[h])}</div>`+m.map(y=>`<div>${_i(y)}</div>`).join(""),i.style.display="block",i.style.left=`${t.clientX-o.left+12}px`,i.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(i=>({id:i.id,type:i.type,title:i.title,data:i.data}));try{localStorage.setItem(e,JSON.stringify(t))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let t=[];try{const i=localStorage.getItem(e);i&&(t=JSON.parse(i))}catch{return}for(const i of t)this.restoreChart(i)}restoreChart(e){const t=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(t))return;const{ePopup:i}=this.popupService.createPopup(640,"ag-chart-window");i.innerHTML="";const n=document.createElement("div");n.className="ag-chart-window-header";const o=document.createElement("span");o.className="ag-chart-window-title",o.textContent=e.title||this.grid.t("chart"),n.appendChild(o);const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="×",a.addEventListener("click",()=>this.destroyChart(t)),n.appendChild(a),i.appendChild(n);const r=document.createElement("div");r.className="ag-chart-window-body";const l=document.createElement("canvas");l.className="ag-chart-canvas",l.width=600,l.height=360,r.appendChild(l);const c=document.createElement("div");c.className="ag-chart-legend",r.appendChild(c),i.appendChild(r);const d={id:t,ePopup:i,canvas:l,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,d),this.popupService.positionAt(i,this.grid.getRootElement()),i.style.top="60px",this.renderChart(d)}renderChart(e){var j;const t=e.canvas,i=t.getContext("2d");if(!i)return;const n=window.devicePixelRatio||1,o=t.width,a=t.height;t.width=o*n,t.height=a*n,t.style.width=`${o}px`,t.style.height=`${a}px`,i.scale(n,n),i.clearRect(0,0,o,a);const r=getComputedStyle(this.grid.getRootElement()),l=r.getPropertyValue("--ag-chart-text-color")||"#666",c=r.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",d={top:20,right:20,bottom:34,left:56},u=o-d.left-d.right,f=a-d.top-d.bottom;i.font="11px sans-serif",i.fillStyle=l,i.strokeStyle=c,i.lineWidth=1;const g=(j=e.canvas.parentElement)==null?void 0:j.querySelector(".ag-chart-legend");if(g&&(g.innerHTML="",e.data.series.forEach((W,M)=>{const D=document.createElement("span");D.className="ag-chart-legend-item";const k=document.createElement("span");k.className="ag-chart-legend-swatch",k.style.backgroundColor=nt[M%nt.length],D.appendChild(k),D.appendChild(document.createTextNode(W.title)),g.appendChild(D)})),e.type==="pie"){this.renderPie(i,e.data,o,a,l);return}const p=e.data.series.flatMap(W=>W.data);let C=Math.max(0,...p),h=Math.min(0,...p);e.type==="scatter"&&(h=Math.min(...p),C=Math.max(...p));const m=C-h||1;C+=m*.08,h-=h<0?m*.08:0;const y=C-h||1,E=W=>d.top+f-(W-h)/y*f,R=5;i.textAlign="right",i.textBaseline="middle";for(let W=0;W<=R;W++){const M=h+y*W/R,D=E(M);i.beginPath(),i.moveTo(d.left,D),i.lineTo(o-d.right,D),i.stroke(),i.fillText(this.formatTick(M),d.left-6,D)}const S=e.data.categories,A=e.type==="bar",B=Math.max(1,S.length),L=(A?f:u)/B;if(A){i.textAlign="left",S.forEach((M,D)=>{const k=d.top+D*L,z=Math.max(2,L*.7/e.data.series.length);e.data.series.forEach((_,Q)=>{const ne=_.data[D]||0,U=Math.abs(ne)/y*u,F=d.left+(0-h)/y*u;i.fillStyle=nt[Q%nt.length],i.fillRect(F,k+Q*z,Math.max(1,U),z-1)}),i.fillStyle=l,i.fillText(this.truncate(M,18),d.left+4,k+L/2)});const W=d.left+(0-h)/y*u;i.beginPath(),i.moveTo(W,d.top),i.lineTo(W,d.top+f),i.strokeStyle=l,i.stroke()}else{const W=Math.max(1,Math.ceil(B/12));i.textAlign="center",i.textBaseline="top",S.forEach((k,z)=>{if(z%W!==0)return;const _=d.left+L*(z+.5);i.fillStyle=l,i.fillText(this.truncate(k,10),_,d.top+f+6)});const M=e.data.series.length,D=Math.max(1,L*.7/Math.max(1,M));e.data.series.forEach((k,z)=>{const _=nt[z%nt.length];if(e.type==="column")i.fillStyle=_,k.data.forEach((Q,ne)=>{const U=d.left+L*ne+(L-D*M)/2+z*D,F=E(Q);i.fillRect(U,F,D-1,d.top+f-F)});else if(e.type==="area"){i.beginPath(),k.data.forEach((ne,U)=>{const F=d.left+L*(U+.5),q=E(ne);U===0?i.moveTo(F,q):i.lineTo(F,q)});const Q=d.left+L*(k.data.length-.5);i.lineTo(Q,d.top+f),i.lineTo(d.left+L*.5,d.top+f),i.closePath(),i.globalAlpha=.25,i.fillStyle=_,i.fill(),i.globalAlpha=1,i.beginPath(),k.data.forEach((ne,U)=>{const F=d.left+L*(U+.5),q=E(ne);U===0?i.moveTo(F,q):i.lineTo(F,q)}),i.strokeStyle=_,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=_,k.data.forEach((Q,ne)=>{const U=d.left+L*(ne+.5),F=E(Q);i.beginPath(),i.arc(U,F,3,0,Math.PI*2),i.fill()})):(i.beginPath(),k.data.forEach((Q,ne)=>{const U=d.left+L*(ne+.5),F=E(Q);ne===0?i.moveTo(U,F):i.lineTo(U,F)}),i.strokeStyle=_,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,n,o){const a=t.series[0];if(!a)return;const r=a.data.reduce((f,g)=>f+Math.abs(g),0)||1,l=i/2,c=n/2,d=Math.min(i,n)/2-30;let u=-Math.PI/2;a.data.forEach((f,g)=>{const p=Math.abs(f)/r*Math.PI*2;e.beginPath(),e.moveTo(l,c),e.arc(l,c,d,u,u+p),e.closePath(),e.fillStyle=nt[g%nt.length],e.fill();const C=u+p/2,h=l+Math.cos(C)*(d*.7),m=c+Math.sin(C)*(d*.7),y=Math.round(Math.abs(f)/r*100);y>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${y}%`,h,m)),u+=p}),e.fillStyle=o}formatTick(e){if(this.timeSeries){const i=new Date(e);if(!isNaN(i.getTime()))return i.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 qi(s,e,t){const i=s.children;if(!i||i.length===0){const n=de(e,s,null);typeof n=="number"&&!isNaN(n)&&t.push(n);return}for(const n of i)qi(n,e,t)}class Wo{constructor(e){v(this,"eOverlayWrapper");v(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 i=document.createElement("div");i.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const n=document.createElement("div");if(n.className="ag-overlay-text",n.textContent=t,e==="loading"){const o=document.createElement("div");o.className="ag-overlay-loading-spinner",i.appendChild(o)}i.appendChild(n),this.eOverlayWrapper.appendChild(i),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}const i=e.getRowCount(),n=this.grid.getOptions().rowData;Array.isArray(n)&&n.length>0,i===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}const Uo=(()=>{const s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function _o(s){let e=4294967295;for(let t=0;t<s.length;t++)e=Uo[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Ki(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 qo(s){let e="",t=s+1;for(;t>0;){const i=(t-1)%26;e=String.fromCharCode(65+i)+e,t=Math.floor((t-1)/26)}return e}function Ko(s){const e=new TextEncoder,t=[],i=[];let n=0;for(const u of s){const f=e.encode(u.name),g=_o(u.data),p=new Uint8Array(30+f.length),C=new DataView(p.buffer);C.setUint32(0,67324752,!0),C.setUint16(4,20,!0),C.setUint16(6,2048,!0),C.setUint16(8,0,!0),C.setUint16(10,0,!0),C.setUint16(12,8585,!0),C.setUint32(14,g,!0),C.setUint32(18,u.data.length,!0),C.setUint32(22,u.data.length,!0),C.setUint16(26,f.length,!0),C.setUint16(28,0,!0),p.set(f,30),t.push(p,u.data);const h=new Uint8Array(46+f.length),m=new DataView(h.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,g,!0),m.setUint32(20,u.data.length,!0),m.setUint32(24,u.data.length,!0),m.setUint16(28,f.length,!0),m.setUint32(42,n,!0),h.set(f,46),i.push(h),n+=p.length+u.data.length}const o=i.reduce((u,f)=>u+f.length,0),a=new Uint8Array(22),r=new DataView(a.buffer);r.setUint32(0,101010256,!0),r.setUint16(8,s.length,!0),r.setUint16(10,s.length,!0),r.setUint32(12,o,!0),r.setUint32(16,n,!0);const l=t.reduce((u,f)=>u+f.length,0)+o+a.length,c=new Uint8Array(l);let d=0;for(const u of t)c.set(u,d),d+=u.length;for(const u of i)c.set(u,d),d+=u.length;return c.set(a,d),c}function jo(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,i)=>{const n=i+1,a=t.some(r=>r.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${n}"${a}>`,t.forEach((r,l)=>{const c=`${qo(l)}${n}`,d=r.bold?' s="1"':"";if(r.value===null||r.value===void 0||r.value===""){e+=`<c r="${c}"${d}/>`;return}typeof r.value=="number"&&isFinite(r.value)?e+=`<c r="${c}"${d}><v>${r.value}</v></c>`:typeof r.value=="boolean"?e+=`<c r="${c}"${d} t="b"><v>${r.value?1:0}</v></c>`:e+=`<c r="${c}"${d} t="inlineStr"><is><t xml:space="preserve">${Ki(String(r.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const Xo='<?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 Yo(s){const e=new TextEncoder,t=(u,f)=>u.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${f+1}`;let i="",n="",o="";s.forEach((u,f)=>{const g=t(u.name,f),p=f+1;i+=`<sheet name="${Ki(g)}" sheetId="${p}" r:id="rId${p}"/>`,n+=`<Relationship Id="rId${p}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${p}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${p}.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>",r='<?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>',l=`<?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>${i}</sheets></workbook>`,c='<?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"/>'+n+"</Relationships>",d=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(r)},{name:"xl/workbook.xml",data:e.encode(l)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(c)},{name:"xl/styles.xml",data:e.encode(Xo)}];return s.forEach((u,f)=>{d.push({name:`xl/worksheets/sheet${f+1}.xml`,data:e.encode(jo(u.rows))})}),new Blob([Ko(d)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const Qo={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function ji(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function Jo(s,e,t){const i=Math.max(1,Math.floor(e/(t*.5)));return s.length>i?`${s.slice(0,Math.max(1,i-1))}…`:s}function Zo(){return new TextEncoder}function es(s,e={}){const[t,i]=Qo[e.pageSize||"a4-landscape"],n=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,r=e.headerColor??[.94,.95,.97],l=e.borderColor??[.85,.87,.9],c=Zo(),d=[],u=y=>(d.push(y),d.length);u(""),u("");const f=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),g=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),p=[];for(const y of s){let E="";const R=y.columnWidths.reduce((k,z)=>k+z,0),S=Math.min(1,(t-n*2)/(R||1)),A=y.columnWidths.map(k=>k*S),B=n;let L=i-n-(e.title?24:0);e.title&&(E+=`BT /F2 ${o+4} Tf ${B} ${L} Td (${ji(e.title)}) Tj ET
4
- `,L-=18),y.rows.forEach((k,z)=>{var U;const _=z===0,Q=((U=y.rowFill)==null?void 0:U[z])??(_?r:void 0);Q&&(E+=`${Q[0]} ${Q[1]} ${Q[2]} rg ${B} ${(L-a+4).toFixed(2)} ${R*S} ${a} re f
5
- `);let ne=B;k.forEach((F,q)=>{const Z=A[q]??0,ie=ji(Jo(F.text??"",Z-6,o)),be=F.bold||_?g:f,fe=(F.text??"").length*o*.5;let ue=ne+3;F.align==="right"||!F.align&&q>0&&/^-?[\d,.%$£€\s]+$/.test(F.text??"")?ue=ne+Z-3-Math.min(fe,Z-6):F.align==="center"&&(ue=ne+(Z-Math.min(fe,Z-6))/2),E+=`BT /F${be===g?2:1} ${o} Tf ${ue.toFixed(2)} ${(L-o+2).toFixed(2)} Td (${ie}) Tj ET
6
- `,ne+=Z}),E+=`${l[0]} ${l[1]} ${l[2]} RG 0.5 w ${B} ${(L-a+4).toFixed(2)} m ${(B+R*S).toFixed(2)} ${(L-a+4).toFixed(2)} l S
7
- `,L-=a});const j=y.rows.length*a;E+=`${l[0]} ${l[1]} ${l[2]} RG 0.5 w ${B} ${(L+a-4).toFixed(2)} m ${B} ${(L+j+a-4).toFixed(2)} l ${(B+R*S).toFixed(2)} ${(L+j+a-4).toFixed(2)} l ${(B+R*S).toFixed(2)} ${(L+a-4).toFixed(2)} l S
8
- `;const W=c.encode(E),M=u(`<< /Length ${W.length} >>
1
+ (function(le,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(le=typeof globalThis<"u"?globalThis:le||self,$e(le.Rowvia={}))})(this,function(le){"use strict";var fa=Object.defineProperty;var ma=(le,$e,dt)=>$e in le?fa(le,$e,{enumerable:!0,configurable:!0,writable:!0,value:dt}):le[$e]=dt;var v=(le,$e,dt)=>ma(le,typeof $e!="symbol"?$e+"":$e,dt);class $e{constructor(){v(this,"listeners",new Map)}addEventListener(e,t){let i=this.listeners.get(e);i||(i=[],this.listeners.set(e,i)),i.push(t)}removeEventListener(e,t){const i=this.listeners.get(e);if(!i)return;const n=i.indexOf(t);n>=0&&i.splice(n,1)}dispatchEvent(e,t){const i=this.listeners.get(e);if(!i||i.length===0)return;const n={type:e,...t||{}};for(const o of i.slice())o(n)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const dt=13,Ln=27,Ri=9,Mi=8,ki=46,Dn=36,An=35;function Et(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let Fn=0;function ti(s="id"){return`${s}-${++Fn}`}function Ke(s,e){if(typeof s!="number"||isNaN(s))return String(s??"");const t=e??0,i=s.toFixed(t),[n,o]=i.split("."),a=n.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${a}.${o}`:a}function ii(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function Pn(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(),i=String(e).toLowerCase();return t<i?-1:t>i?1:0}function $n(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ge extends Error{constructor(e){super(e),this.code=e}}const Gn=/^\$?[A-Za-z]{1,3}\$?\d+$/;function Ti(s){const e=[];let t=0;for(;t<s.length;){const i=s[t];if(i===" "||i===" "||i===`
2
+ `||i==="\r"){t++;continue}if(i==='"'||i==="'"){const o=i;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(i)||i==="."&&/[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(i)){let o="";for(;t<s.length&&/[A-Za-z0-9_$.]/.test(s[t]);)o+=s[t++];Gn.test(o)?e.push({type:"cell",value:o.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:o});continue}if(i==="("){e.push({type:"lparen",value:i}),t++;continue}if(i===")"){e.push({type:"rparen",value:i}),t++;continue}if(i===","||i===";"){e.push({type:"comma",value:","}),t++;continue}const n=s.slice(t,t+2);if(["<=",">=","<>"].includes(n)){e.push({type:"op",value:n}),t+=2;continue}if("+-*/^%&=<>,:".includes(i)){e.push({type:"op",value:i}),t++;continue}throw new Ge("#NAME?")}return e}const Ni={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function Ii(s){let e=0;const t=()=>s[e],i=()=>s[e++];function n(l=0){let c=o();for(;t()&&t().type==="op"&&Ni[t().value]>=l;){const d=i().value,u=n(Ni[d]+1);c={type:"binary",operator:d,left:c,right:u}}return c}function o(){const l=t();if(l&&l.type==="op"&&(l.value==="-"||l.value==="+")){i();const c=o();return l.value==="-"?{type:"unary",operator:"-",operand:c}:c}return a()}function a(){const l=i();if(!l)throw new Ge("#ERROR!");if(l.type==="number")return{type:"number",value:Number(l.value)};if(l.type==="string")return{type:"string",value:l.value};if(l.type==="cell")return{type:"cell",value:l.value};if(l.type==="ident"){const c=l.value.toUpperCase();if(c==="TRUE")return{type:"boolean",value:!0};if(c==="FALSE")return{type:"boolean",value:!1};const d=t();if(d&&d.type==="lparen"){i();const u=[];if(t()&&t().type!=="rparen")for(u.push(n());t()&&t().type==="comma";)i(),u.push(n());if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return i(),{type:"call",name:c,args:u}}return{type:"ref",value:l.value}}if(l.type==="lparen"){const c=n();if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return i(),c}throw new Ge("#ERROR!")}const r=n();if(e<s.length)throw new Ge("#ERROR!");return r}function re(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 mt(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...mt(t));else if(t!=null&&t!==""){const i=typeof t=="number"?t:Number(t);isNaN(i)||e.push(i)}return e}const Gt={SUM:s=>mt(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=mt(s);return e.length?e.reduce((t,i)=>t+i,0)/e.length:0},AVG:s=>Gt.AVERAGE(s,{}),MIN:s=>{const e=mt(s);return e.length?Math.min(...e):0},MAX:s=>{const e=mt(s);return e.length?Math.max(...e):0},COUNT:s=>mt(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(re(s[0])),ROUND:s=>{const e=s.length>1?re(s[1]):0,t=Math.pow(10,e);return Math.round(re(s[0])*t)/t},FLOOR:s=>Math.floor(re(s[0])),CEIL:s=>Math.ceil(re(s[0])),CEILING:s=>Math.ceil(re(s[0])),SQRT:s=>{const e=re(s[0]);return e<0?(()=>{throw new Ge("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(re(s[0]),re(s[1])),POW:s=>Math.pow(re(s[0]),re(s[1])),MOD:s=>{const e=re(s[1]);if(e===0)throw new Ge("#DIV/0!");return re(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?re(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?re(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,re(s[1])-1),i=s.length>2?re(s[2]):e.length-t;return e.slice(t,t+i)},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=>re(s[0]),NUMBER:s=>re(s[0]),BETWEEN:s=>re(s[0])>=re(s[1])&&re(s[0])<=re(s[2])},Ht=Object.keys(Gt);function Hn(s,e){Gt[s.toUpperCase()]=e,Ht.includes(s.toUpperCase())||Ht.push(s.toUpperCase())}function On(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 Bn(s,e){const t=e.data||{};if(s in t)return t[s];const i=s.toLowerCase();for(const n of Object.keys(t))if(n.toLowerCase()===i)return t[n]}function Rt(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return Bn(s.value,e);case"cell":return On(s.value,e);case"unary":return-re(Rt(s.operand,e));case"call":{const t=Gt[s.name];if(!t)throw new Ge("#NAME?");const i=s.args.map(n=>Rt(n,e));return t(i,e)}case"binary":{const t=Rt(s.left,e),i=Rt(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:re(t)+re(i);case"-":return re(t)-re(i);case"*":return re(t)*re(i);case"/":{const n=re(i);if(n===0)throw new Ge("#DIV/0!");return re(t)/n}case"^":return Math.pow(re(t),re(i));case"%":{const n=re(i);if(n===0)throw new Ge("#DIV/0!");return re(t)%n}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return re(t)<re(i);case"<=":return re(t)<=re(i);case">":return re(t)>re(i);case">=":return re(t)>=re(i);default:throw new Ge("#ERROR!")}}default:throw new Ge("#ERROR!")}}function Mt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,i=Ii(Ti(t));return Rt(i,e)}function ni(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function oi(s,e){if(s==null)return;if(e in s)return s[e];const t=e.split(".");let i=s;for(const n of t){if(i==null)return;i=i[n]}return i}function ue(s,e,t){const i=s.colDef,n=(e.group||e.footer)&&!!e.groupData&&e.groupData[s.colId]!==void 0,o=n?e.groupData:e.data,a=s.valueGetter??i.valueGetter;if(a)return(typeof a=="string"?l=>ni(a)?Mt(a,{data:l.data}):oi(l.data,a):a)({data:n?e.groupData:e.data,node:e,column:s,api:t,colDef:i,getValue:l=>oi(n?e.groupData:e.data,l)});if(s.field&&ni(s.field))return Mt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return Mt(`=${s.field}`,{data:e.data});if(s.field)return oi(o,s.field)}function Ot(s,e,t){var o;let i=ue(s,e,t);const n=s.colDef;if(n.showValueAs&&typeof i=="number"&&t){const a=(o=t.__columnTotalCache)==null?void 0:o.get(s.colId);if(a!==void 0&&a!==0)return`${(n.showValueAs==="percentOfParent"?i/(a||1)*100:i/a*100).toFixed(1)}%`}return n.valueFormatter?(typeof n.valueFormatter=="string"?r=>Vn(r.colDef.valueFormatter,r.value,r):n.valueFormatter)({value:i,data:e.data,node:e,column:s,api:t,colDef:n}):zn(s,i)}function Vn(s,e,t={}){var i,n,o;if(e==null)return"";switch(s){case"number":return Ke(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${Ke(e,((n=t.column)==null?void 0:n.decimals)??2)}`;case"percent":return`${Ke(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Li(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Li(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 zn(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?Ke(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Li(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Di(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?i=>Ai(i.colDef.valueParser,i.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Ai(s.type,e)}function Ai(s,e){if(s==="numberColumn")return ii(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 Fi(s){const t=s.colDef.comparator,i=s.type;return(n,o)=>{const a=ue(s,n,null),r=ue(s,o,null);if(t)return t(a,r,n,o);if(i==="numberColumn"){const l=typeof a=="number"?a:ii(a),c=typeof r=="number"?r:ii(r);return l!==null&&c!==null?l-c:l===null&&c===null?0:l===null?-1:1}if(i==="dateColumn"){const l=a instanceof Date?a.getTime():new Date(a).getTime(),c=r instanceof Date?r.getTime():new Date(r).getTime();if(!isNaN(l)&&!isNaN(c))return l-c}return Pn(a,r)}}function kt(s,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:s,rowNode:null,data:null});const i=t.filter(n=>typeof n=="number"&&!isNaN(n));switch(e){case"sum":return i.reduce((n,o)=>n+o,0);case"count":return t.length;case"avg":return i.length?i.reduce((n,o)=>n+o,0)/i.length:null;case"min":return i.length?Math.min(...i):null;case"max":return i.length?Math.max(...i):null;case"first":return t.length?t[0]:null;case"last":return t.length?t[t.length-1]:null;default:return null}}const Wn={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 Un(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 _n(s){return!!s.treeData}function qn(){return{applyAggregate:kt}}class Pi{constructor(e,t,i){v(this,"options");v(this,"eventService");v(this,"gridApi");v(this,"measureCtx",null);v(this,"gridColumnDefs",[]);v(this,"columns",[]);v(this,"displayOrder",[]);v(this,"autoGroupColumnDef");v(this,"pivotMode",!1);v(this,"columnGroups",[]);v(this,"openGroups",new Set);v(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=i,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=$i){if(!e||e.length===0)return[];const i=e[0];if(!i||typeof i!="object")return[];const n=new Set(["children","detail","__proto__"]),o=[];for(const a of Object.keys(i)){if(n.has(a)||a.startsWith("__"))continue;const r=i[a],l={field:a,headerName:t(a)};typeof r=="number"?(l.type="numberColumn",l.filter="number"):typeof r=="boolean"?l.type="booleanColumn":r instanceof Date&&(l.type="dateColumn"),o.push(l)}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 d of e)t.set(d.colId,d);const i=this.options.defaultColDef||{},n={...Wn,...this.options.columnTypes||{}},o=[],a=[];let r=0;const l=(d,u)=>{const f=d.colId||d.field||ti("col"),g={...i,...d};if(g.type&&n[g.type]){const w=n[g.type],h=new Set(Object.keys(d));for(const[p,m]of Object.entries(w))!h.has(p)&&!(p in i)&&(g[p]=m)}this.pushColumnInto(o,g,f,r++,t,u)},c=(d,u,f)=>{for(const g of d)if(g.children&&g.children.length){const w=g.groupId||ti("group"),h={id:w,headerName:g.headerName??"",openByDefault:g.openByDefault===!0||g.columnGroupShow==="open",parentId:u,depth:f,childColumnIds:[]};a.push(h),this.groupsInitialised||(h.openByDefault?this.openGroups.add(w):this.openGroups.delete(w)),c(g.children,w,f+1)}else l(g,u)};if(c(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,this.options.rowNumbers){const d={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,{...i,...d},"__rowNumber",-1,t,null)}for(const d of o){if(!d.groupId)continue;const u=a.find(f=>f.id===d.groupId);u&&u.childColumnIds.push(d.colId)}this.columns=o,this.displayOrder=o.map(d=>d.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,i,n,o){return this.buildColumn(e,t,i,n,o)}pushColumnInto(e,t,i,n,o,a){e.push(this.buildColumn(t,i,n,o,a))}buildColumn(e,t,i,n,o){const a=n.get(t),r=e.hide===!0||e.initialHide===!0,l={colId:t,field:e.field,headerName:e.headerName??(e.field?$i(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:r,visible:!r,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:Un(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:i,filterActive:!1,left:0,groupId:o};return a&&(l.pinned=a.pinned,l.visible=a.visible,l.width=a.width,l.flex=a.flex,l.sort=a.sort,l.sortIndex=a.sortIndex,l.rowGroup=a.rowGroup,l.rowGroupIndex=a.rowGroupIndex,l.pivot=a.pivot,l.pivotIndex=a.pivotIndex),l}updatePivotColumns(e){if(this.columns=this.columns.filter(l=>!l.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(l=>!l.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const i=this.getColumns().filter(l=>l.aggFunc&&!l.rowGroup&&!l.pivot),n=[];for(const l of t){const c=[],d=new Set;for(const u of e){const f=u==null?void 0:u[l.field],g=String(f);d.has(g)||(d.add(g),c.push(f))}c.sort((u,f)=>u===f?0:String(u)<String(f)?-1:1);for(const u of i){for(const w of c){const h=`__pivot_${l.colId}_${u.colId}_${w}`,p=this.createColumn({colId:h,headerName:`${String(w)}`,width:130,type:u.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:u.cellClass,cellDataType:u.cellDataType},h,-1,new Map,null);p.aggFunc=u.aggFunc,p.groupId=l.colId,p.__pivot={pivotColumnId:l.colId,pivotField:l.field,pivotValue:w,valueColumnId:u.colId,valueField:u.field},p.valueGetter=m=>this.evaluatePivotValue(p,m.node),n.push(p)}const f=`__pivot_${l.colId}_${u.colId}_total`,g=this.createColumn({colId:f,headerName:"Total",width:130,type:u.type,sortable:!1,filter:!1,cellDataType:u.cellDataType},f,-1,new Map,null);g.aggFunc=u.aggFunc,g.groupId=l.colId,g.__pivot={pivotColumnId:l.colId,pivotField:l.field,pivotValue:void 0,valueColumnId:u.colId,valueField:u.field},g.valueGetter=w=>this.evaluatePivotValue(g,w.node),n.push(g)}}const o=new Set(t.map(l=>l.colId)),a=this.columns.reduce((l,c,d)=>o.has(c.groupId??"")?l:d,0);this.columns.splice(a+1,0,...n);for(const l of n)this.displayOrder.push(l.colId);const r=new Set(this.columnGroups.map(l=>l.id));for(const l of t)r.has(l.colId)||this.columnGroups.push({id:l.colId,headerName:l.headerName||l.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const i=e.__pivot;if(!i||!t)return;const n=[],o=d=>{if(!d.children||d.children.length===0){n.push(d);return}for(const u of d.children)o(u)};o(t);const r=(i.pivotValue===void 0?n:n.filter(d=>{var u;return String((u=d.data)==null?void 0:u[i.pivotField])===String(i.pivotValue)})).map(d=>{var u;return(u=d.data)==null?void 0:u[i.valueField]}).filter(d=>typeof d=="number");if(r.length===0)return null;const l=this.columns.find(d=>d.colId===i.valueColumnId),{applyAggregate:c}=qn();return c(l,e.aggFunc,r)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,i=this.getRowGroupColumns(),n=this.options.groupDisplayType||"singleColumn",o=t||i.length>0&&n!=="multipleColumns";for(const d of i)n==="multipleColumns"?(d.cellRenderer="agGroupCellRenderer",d.cellRendererParams={...d.cellRendererParams||{},suppressCount:!0}):d.cellRenderer==="agGroupCellRenderer"&&!d.colDef.cellRenderer&&(d.cellRenderer=void 0,d.cellRendererParams=void 0);const a=this.columns.find(d=>d.colId===e);if(!o){a&&(this.columns=this.columns.filter(d=>d.colId!==e),this.displayOrder=this.displayOrder.filter(d=>d!==e));return}const r={...this.autoGroupColumnDef};if(r.colId=e,a)a.headerName=r.headerName??"",a.colDef=r,a.cellRenderer=r.cellRenderer,a.cellRendererParams=r.cellRendererParams,a.width=r.width??a.width,a.minWidth=r.minWidth??a.minWidth,a.pinned=r.pinned??"left";else{const d=this.createColumn(r,e,-2,new Map,null);this.columns.unshift(d),this.displayOrder.unshift(e)}const l=this.columns.find(d=>d.colId===e),c=()=>this.getRowGroupColumns()[0];l.valueGetter=d=>{const u=d.node;if(!u)return"";if(u.key!==null&&u.key!==void 0)return u.key;if(_n(this.options))return"";const f=c();return f!=null&&f.field&&u.data?u.data[f.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 i=this.columnGroups.find(n=>n.id===t);t=(i==null?void 0:i.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(i=>i.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 i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())i.includes(n)||(n.rowGroup=!1,n.rowGroupIndex=null);i.forEach((n,o)=>{n.rowGroup=!0,n.rowGroupIndex=o,n.pivot=!1,n.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:i}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,t="api"){const i=this.getColumn(e);if(!i)return;const n=this.getRowGroupColumns();i.rowGroup=!0,i.rowGroupIndex=n.length,i.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,t="api"){const i=this.getColumn(e);if(!i)return;i.rowGroup=!1,i.rowGroupIndex=null,this.getRowGroupColumns().forEach((o,a)=>o.rowGroupIndex=a),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())i.includes(n)?n.aggFunc||(n.aggFunc="sum"):n.aggFunc&&!n.rowGroup&&(n.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:i}),this.refreshAll()}addValueColumn(e,t="sum",i="api"){const n=this.getColumn(e);n&&(n.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:i,columns:[n]}),this.refreshAll())}setPivotColumns(e,t="api"){const i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())n.pivot=i.includes(n),n.pivotIndex=i.includes(n)?i.indexOf(n):null;this.refreshAll()}setColumnVisible(e,t,i="api"){const n=this.getColumn(e);!n||n.visible===t||(n.hide=!t,n.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:n,visible:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll())}setColumnsVisible(e,t,i="api"){for(const n of e)this.setColumnVisible(n,t,i)}setColumnPinned(e,t,i="api"){const n=this.getColumn(e);n&&(n.lockPosition&&t!==n.pinned||(n.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:n,pinned:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll()))}setColumnsPinned(e,t,i="api"){for(const n of e)this.setColumnPinned(n,t,i)}moveColumn(e,t,i="api"){const n=this.getColumn(e);n&&this.moveColumnByIndex(this.displayOrder.indexOf(n.colId),t,i)}moveColumnByIndex(e,t,i="api"){const n=this.displayOrder.slice();if(e<0||e>=n.length)return;const[o]=n.splice(e,1);n.splice(Math.max(0,Math.min(n.length,t)),0,o),this.displayOrder=n;const a=this.getColumn(o);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:a,toIndex:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),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 i of e){const n=this.getColumn(i.colId);n&&(i.hide!==void 0&&(n.hide=i.hide,n.visible=!i.hide),i.pinned!==void 0&&(n.pinned=i.pinned),i.width!==void 0&&(n.width=i.width),i.flex!==void 0&&(n.flex=i.flex),i.sort!==void 0&&(n.sort=i.sort),i.sortIndex!==void 0&&(n.sortIndex=i.sortIndex),i.rowGroupIndex!==void 0&&(n.rowGroup=i.rowGroupIndex!==null,n.rowGroupIndex=i.rowGroupIndex),i.pivotIndex!==void 0&&(n.pivot=i.pivotIndex!==null,n.pivotIndex=i.pivotIndex),i.aggFunc!==void 0&&(n.aggFunc=i.aggFunc))}if(t){const i=new Map(e.map(o=>[o.colId,o.colId])),n=this.displayOrder.filter(o=>!i.has(o));this.displayOrder=[...e.map(o=>o.colId).filter(o=>this.getColumn(o)),...n]}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 i=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const n of i){let a=0,r=0;for(const c of n)t.includes(c.colId)?r+=c.width:c.flex!==null&&c.flex>0?a+=c.flex:r+=c.width;const l=Math.max(0,e-r-32);if(a>0){for(const c of n)if(c.flex!==null&&c.flex>0&&!t.includes(c.colId)){const d=Math.max(c.minWidth,Math.floor(l*c.flex/a));c.width=Math.min(c.maxWidth,d)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var r,l,c,d,u,f;const i=this.getColumn(e);if(!i)return;let n=this.measureTextWidth(i.headerName)+32;t||(n+=16);const o=((l=(r=this.gridApi)==null?void 0:r.getDisplayedRowCount)==null?void 0:l.call(r))??0,a=Math.min(o,300);for(let g=0;g<a;g++){const w=(d=(c=this.gridApi)==null?void 0:c.getDisplayedRowAtIndex)==null?void 0:d.call(c,g);if(!w)continue;const h=(f=(u=this.gridApi)==null?void 0:u.getCellText)==null?void 0:f.call(u,i,w);h&&(n=Math.max(n,this.measureTextWidth(h)+32))}i.width=Math.max(i.minWidth,Math.min(i.maxWidth,Math.ceil(n))),i.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:i,finished:!0})}autoSizeAllColumns(e=!1){for(const t of this.getDisplayedColumns())this.autoSizeColumn(t,e)}}function $i(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class tt{constructor(e,t,i){v(this,"id");v(this,"__id");v(this,"data");v(this,"parent",null);v(this,"children",null);v(this,"group",!1);v(this,"key",null);v(this,"level",0);v(this,"uiLevel",0);v(this,"rowGroupIndex");v(this,"expanded",!1);v(this,"selectable",!0);v(this,"selected",!1);v(this,"rowPinned",null);v(this,"detailNode",null);v(this,"masterNode",null);v(this,"footer",!1);v(this,"groupData",null);v(this,"rowHeight",null);v(this,"allChildrenCount",null);v(this,"stub",!1);v(this,"rowIndex",null);v(this,"__displayIndex");v(this,"services");v(this,"_id",null);v(this,"__passesFilter",!0);v(this,"__childCount",0);v(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=ti("row"),this.id=i??this.__id,i&&(this._id=i)}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,t=!1,i="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 i=typeof e=="string"?e:e.field;if(i&&this.data){const n=i.split(".");let o=this.data;for(;n.length>1;){const a=n.shift();o[a]===void 0&&(o[a]={}),o=o[a]}o[n[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class Kn{constructor(e){v(this,"options");v(this,"eventService");v(this,"columns");v(this,"getFilterModel");v(this,"getQuickFilter");v(this,"isPaginationEnabled");v(this,"getPageSize");v(this,"getCurrentPage");v(this,"rowHeightProvider");v(this,"rowNodeServices");v(this,"rowData",[]);v(this,"rootRowNodes",[]);v(this,"dataRows",[]);v(this,"rowsToDisplay",[]);v(this,"rowNodeMap",new Map);v(this,"expandedGroups",new Set);v(this,"groupDefaultExpandedApplied",!1);v(this,"pinnedTopRows",[]);v(this,"pinnedBottomRows",[]);v(this,"displayStartIndex",0);v(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,i)=>e(t,i))}forEachLeafNode(e){let t=0;const i=n=>{for(const o of n)o.group?o.children&&i(o.children):o.footer||e(o,t++)};i(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(n=>{n.group&&e.set(n.id,n.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,i=this.rowData;if(this.options.treeData){const n=this.buildTreeData(i,t);this.rootRowNodes=n,this.rowNodeMap.forEach(o=>{o.group&&e.has(o.id)&&(o.expanded=e.get(o.id))})}else{const n=[];for(let o=0;o<i.length;o++){const a=i[o],r=t?t({data:a,level:0}):void 0,l=this.createRowNode(a,r);l.rowIndex=o,n.push(l)}this.rootRowNodes=n,this.dataRows=n}if(this.options.masterDetail&&!this.options.treeData){const n=this.options.isRowMaster||(()=>!0);for(const o of this.rootRowNodes){if(o.detailNode||!n({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,i=null,n=0){const o=new tt(e,this.rowNodeServices,t);return o.parent=i,o.level=n,o.uiLevel=n,o.__id=o.id,this.rowNodeMap.set(o.id,o),o}buildTreeData(e,t){const i=this.options.getDataPath||(c=>String(c.id??c.key).split("/")),n=this.options.treeDataChildrenField||"children",o=new Map,a=[],r=(c,d,u)=>{const f=i(c),g=f.join("/"),w=t?t({data:c,level:u}):g,h=this.createRowNode(c,w,d,u);h.key=f[f.length-1],o.set(g,h);const p=c[n];if(Array.isArray(p)&&p.length){h.children=[],h.group=!0,h.expanded=!0;for(const m of p){const y=r(m,h,u+1);h.children.push(y)}h.allChildrenCount=p.length}else d&&(d.children||(d.children=[],d.group=!0,d.expanded=!0),d.children.push(h),d.allChildrenCount=(d.allChildrenCount??0)+1);return d||a.push(h),h},l=c=>{if(!c.children||c.children.length===0)return 1;let d=0;for(const u of c.children)d+=l(u);return c.allChildrenCount=d,d};for(const c of a)l(c);for(const c of e){if(!c)continue;const u=i(c).slice(0,-1).join("/"),f=u&&o.get(u)||null;r(c,f??null,f?f.level+1:0)}return a}applyTransaction(e){const t=this.options.getRowId,i={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const n=new Set;for(const o of e.remove){const a=t?t({data:o,level:0}):o.id;a!==void 0?n.add(String(a)):n.add(o)}this.rowData=this.rowData.filter(o=>{const a=t?t({data:o,level:0}):o.id;return!n.has(String(a))&&!n.has(o)});for(const o of n){const a=this.rowNodeMap.get(String(o));a&&(this.rowNodeMap.delete(a.id),i.remove.push(a))}}if(e.update&&e.update.length)for(const n of e.update){const o=t?t({data:n,level:0}):n.id,a=o!==void 0?this.rowNodeMap.get(String(o)):void 0;if(a)this.rowData=this.rowData.map(r=>{const l=t?t({data:r,level:0}):r.id;return String(l)===String(o)?n:r}),a.data=n,i.update.push(a);else{const r=this.createRowNode(n,o!==void 0?String(o):void 0);this.rowData.push(n),i.add.push(r)}}if(e.add&&e.add.length){const n=e.addIndex;for(const o of e.add){const a=t?t({data:o,level:0}):void 0,r=this.createRowNode(o,a);i.add.push(r),n===void 0||n<0?this.rowData.push(o):this.rowData.splice(Math.min(n,this.rowData.length),0,o)}}return this.rebuildRows(),i}refreshModel(e){const t=this.columns().filter(i=>i.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(),i=Object.keys(e).length>0,n=t&&t.trim().length>0,o=this.columns(),a=!!this.options.treeData,r=w=>{for(const[h,p]of Object.entries(e)){const m=o.find(y=>y.colId===h);if(m&&!this.doesNodePassFilter(w,m,p))return!1}return!0},l=w=>{const h=this.options.__advancedFilterPass;return h?h(w):!0},c=Object.entries(e).some(([w,h])=>{const p=o.find(m=>m.colId===w);return!p||!p.aggFunc?!1:h.filterType==="multi"?(h.filterModels||[]).length>0:!0}),d=w=>{if(w.__passesFilter=!0,w.children)for(const h of w.children)d(h)},u=w=>{const h=this.options;return typeof h.isExternalFilterPresent!="function"||!h.isExternalFilterPresent()||typeof h.doesExternalFilterPass!="function"?!0:h.doesExternalFilterPass(w)},f=w=>{if(!n)return!0;const h=t.toLowerCase(),p=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of p){const y=ue(m,w,null);if($n(h,y))return!0}return!1},g=w=>{let h=!0;if(!w.group||w.footer||a?h=(!i||r(w))&&f(w)&&u(w)&&l(w):c&&(h=(!i||r(w))&&l(w)),w.__passesFilter=h,w.children){let p=!1;for(const m of w.children)g(m)&&(p=!0);return w.group&&!w.footer&&(c?(w.__passesFilter=h,h&&d(w)):(w.__passesFilter=a?p||h:p,a&&h&&d(w))),w.__passesFilter}return h};for(const w of this.rootRowNodes)g(w)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let l;if(e.groupData&&e.groupData[t.colId]!==void 0)l=e.groupData[t.colId];else{const d=[];Vt(e,d);const u=d.map(f=>ue(t,f,null));l=kt(t,t.aggFunc,u)}const c={...e,data:{[t.colId]:l},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(c,t,i)}if(i.filterType==="multi"){const l=i.filterModels||[];if(l.length===0)return!0;const c=i.operator||"AND",d=l.map(u=>this.doesNodePassFilter(e,t,u));return c==="OR"?d.some(Boolean):d.every(Boolean)}if(i.condition1||i.condition2){const{condition1:l,condition2:c,...d}=i,u=[this.doesNodePassFilter(e,t,{...d,...l||{}})];return c&&u.push(this.doesNodePassFilter(e,t,{...d,...c})),(i.operator||"AND")==="OR"?u.some(Boolean):u.every(Boolean)}const n=ue(t,e,null),o=Xn(t,n),a=n,r=i.filterType||"text";if(r==="text"){const l=String(i.filter??"").toLowerCase();if(!l)return!0;const c=(a==null?"":String(a)).toLowerCase();switch(i.type){case"equals":return c===l;case"notEqual":return c!==l;case"startsWith":return c.startsWith(l);case"endsWith":return c.endsWith(l);case"contains":default:return c.includes(l)}}if(r==="number"){const l=typeof a=="number"?a:Number(a);if(isNaN(l))return!1;const c=Number(i.filter),d=i.filterTo!==void 0&&i.filterTo!==null&&i.filterTo!==""?Number(i.filterTo):null;switch(i.type){case"equals":return l===c;case"notEqual":return l!==c;case"lessThan":return l<c;case"lessThanOrEqual":return l<=c;case"greaterThan":return l>c;case"greaterThanOrEqual":return l>=c;case"inRange":return d!==null?l>=Math.min(c,d)&&l<=Math.max(c,d):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(r==="date"){const l=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(l))return!1;const c=i.dateFrom?new Date(i.dateFrom).getTime():null,d=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(c!==null&&l<c||d!==null&&l>d)}return r==="boolean"?!!a==!!i.filter:r==="set"?(i.values||[]).map(c=>String(c)).includes(String(a)):!0}doSort(e){const t=[],i=this.columns();for(const a of i)a.sort&&a.sortIndex!==null&&t.push({column:a,direction:a.sort});t.sort((a,r)=>(a.column.sortIndex??0)-(r.column.sortIndex??0));const n=(a,r)=>{for(const{column:d,direction:u}of t){const f=Fi(d)(a,r)*(u==="asc"?1:-1);if(f!==0)return f}const l=a.rowIndex??0,c=r.rowIndex??0;return l-c},o=a=>{a.sort(n);for(const r of a)r.children&&o(r.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(c=>c.aggFunc&&!c.rowGroup),i=(c,d,u,f)=>{if(d>=e.length)return c;const g=e[d],w=new Map,h=[];for(const m of c){if(!m.__passesFilter)continue;const y=ue(g,m,null),E=jn(y);w.has(E)||(w.set(E,[]),h.push(E)),w.get(E).push(m)}const p=[];for(const m of h){const y=w.get(m),E=`${f}|${g.colId}:${m}`,R=this.rowNodeMap.get(E),S=R||new tt({[g.colId]:m},this.rowNodeServices,E);S.group=!0,S.key=m,S.level=u,S.uiLevel=u,S.parent=null,S.children=i(y,d+1,u+1,E);for(const A of S.children)A.parent=S;S.allChildrenCount=Gi(S),S.data={...S.data};const P=[];Vt(S,P);const B={};for(const A of t){const j=P.map(W=>ue(A,W,null));B[A.colId]=kt(A,A.aggFunc,j)}B[g.colId]=m,S.groupData=B,R||this.rowNodeMap.set(E,S),p.push(S)}return p},n=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=i(o,0,0,""),r=c=>{for(const d of c){if(!d.group)continue;const u=Bt(d),f=this.expandedGroups.has(u);n===-1||f?d.expanded=!0:this.groupDefaultExpandedApplied?d.expanded=!1:d.expanded=d.level<n,d.expanded&&this.expandedGroups.add(u),d.children&&r(d.children)}};r(a),this.groupDefaultExpandedApplied=!0;const l=(c,d)=>{const u=e[d],f=u.sort==="desc"?-1:1,g=Fi(u);c.sort((w,h)=>{const p=ue(u,w,null),m=ue(u,h,null);return g({...w,data:{[u.colId]:p}},{...h,data:{[u.colId]:m}})*f})};e[0].sort&&l(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],i=!!this.options.treeData,n=(a,r)=>{if(a.uiLevel=r,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||i)){const l=a.group?a.children.filter(c=>c.__passesFilter||c.group):a.children;if(a.expanded){for(const c of l)n(c,r+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const c=this.createFooterNode(a,r+1);t.push(c)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&n(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(),r=this.getCurrentPage();let l=0,c=-1;for(let u=0;u<o.length;u++)if(!o[u].masterNode){if(l===r*a){c=u;break}l++}c<0&&(c=o.length);let d=c;for(l=0;d<o.length&&l<a;)o[d].masterNode||l++,d++;for(;d<o.length&&o[d].masterNode;)d++;this.displayStartIndex=c,this.rowsToDisplay=o.slice(c,d)}else this.displayStartIndex=0,this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,r)=>a.__displayIndex=r)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const i=`${e.id}|footer`;let n=this.rowNodeMap.get(i);return n||(n=new tt(e.data,this.rowNodeServices,i),this.rowNodeMap.set(i,n)),n.group=!1,n.footer=!0,n.level=e.level,n.uiLevel=t,n.parent=e,n.selected=!1,n.selectable=!1,n.groupData={...e.groupData,__footerFor:e.id},n}createGrandTotalNode(e){const t="ag-grid-grand-total";let i=this.rowNodeMap.get(t);i||(i=new tt(null,this.rowNodeServices,t),this.rowNodeMap.set(t,i)),i.group=!1,i.footer=!0,i.level=0,i.uiLevel=0,i.selected=!1,i.selectable=!1;const n=this.columns().filter(r=>r.aggFunc&&!r.rowGroup),o=[];for(const r of this.rootRowNodes)r.group?Vt(r,o):r.__passesFilter&&o.push(r);const a={};for(const r of n){const l=o.map(c=>ue(r,c,null));a[r.colId]=kt(r,r.aggFunc,l)}return a.__grandTotal=!0,i.groupData=a,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Bt(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(Bt(e)):this.expandedGroups.delete(Bt(e)),this.buildDisplayRows(this.columns().filter(i=>i.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function jn(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Bt(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Gi(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Gi(t),0)}function Vt(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Vt(t,e)}function Xn(s,e){return e}const Hi={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:"散点图"},Yn={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 Qn{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Hi[e]??e}}function Jn(s){return new Qn(s??{})}function Zn(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class eo{constructor(e){v(this,"options");v(this,"eventService");v(this,"columns");v(this,"getSortModel");v(this,"getFilterModel");v(this,"rowHeightProvider");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"stores",new Map);v(this,"rowNodeMap",new Map);v(this,"displayRows",[]);v(this,"blockSize");v(this,"pureLoad",!0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100,this.pureLoad=e.options.serverSideStoreType!=="partial"}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,i){if(!this.datasource)return;const n=this.getOrCreateStore(e);if(n.loading)return;for(let a=n.rows.length;a<i;a++)n.rows.push(null);n.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const o={startRow:t,endRow:i,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,r)=>{n.loading=!1,this.onBlockLoaded(e,a,r??null)},failCallback:()=>{n.loading=!1,n.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(o)}onBlockLoaded(e,t,i){const n=this.getOrCreateStore(e);n.lastRow=i,n.failed=!1;for(let o=0;o<t.length;o++){const a=t[o],r=(n.rows.length>0,o),l=this.createNode(a,e,o,r);n.rows[r]=l}for(;n.rows.length&&n.rows[n.rows.length-1]===null;)n.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,i,n){const o=Zn(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${n}`,r=this.rowNodeMap.get(a),l=r instanceof tt?r:new tt(e,this.rowNodeServices,a);return l.data=e,l.rowIndex=i,o&&(l.group=!0,l.key=String(ue(this.columns().find(c=>c.rowGroup),l,null)??""),l.level=t?t.split("|").length:0,l.uiLevel=l.level,l.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,l.expanded=this.stores.has(`${t?t+"|":""}${l.key}`)),this.rowNodeMap.set(a,l),l}buildDisplayRows(){const e=[],t=(i,n)=>{const o=this.stores.get(i);if(o){for(const a of o.rows)if(a&&(a.uiLevel=n,e.push(a),a.group&&a.expanded)){const r=`${i?i+"|":""}${a.key}`;t(r,n+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((i,n)=>i.__displayIndex=n)}ensureLoaded(e,t){let i=0;const n=a=>{const r=this.stores.get(a);if(r){for(const l of r.rows)if(l){if(i>=e&&i<=t){const c=Math.floor(i/this.blockSize)*this.blockSize,d=c+this.blockSize,u=r.lastRow,f=u!==null?Math.min(u,d):d;i<(r.rows.length||0)&&c<(r.rows.length||0)||(r.lastRow===null||d<=r.lastRow)&&this.loadBlock(a,c,f)}i++,l.group&&l.expanded&&n(`${a?a+"|":""}${l.key}`)}}};n("");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 i=this.groupPathFor(e);this.stores.has(i)||this.loadBlock(i,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const t=[];let i=e;for(;i&&i.group;)t.unshift(i.key??""),i=i.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,i)=>e(t,i))}forEachLeafNode(e){let t=0;for(const i of this.displayRows)!i.group&&!i.footer&&e(i,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 i of e.update||[]){const n=(i==null?void 0:i.id)!==void 0?String(i.id):void 0,o=n?this.rowNodeMap.get(n):void 0;o&&(o.data=i,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 to{constructor(e){v(this,"options");v(this,"eventService");v(this,"getSortModel");v(this,"getFilterModel");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"nodes",[]);v(this,"rowNodeMap",new Map);v(this,"blockSize");v(this,"lastRow",null);v(this,"loading",!1);this.options=e.options,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.lastRow=null,this.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let i=this.nodes.length;i<t;i++)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:(i,n)=>{this.loading=!1,this.lastRow=n??null,i.forEach((o,a)=>{const r=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let l=this.rowNodeMap.get(r);l||(l=new tt(o,this.rowNodeServices,r),this.rowNodeMap.set(r,l)),l.data=o,l.rowIndex=e+a,this.nodes[e+a]=l}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const i=Math.floor(e/this.blockSize)*this.blockSize;i+this.blockSize>this.nodes.length&&this.loadBlock(i,i+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.lastRow=null,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,i)=>{t&&e(t,i)})}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 io{constructor(e){v(this,"options");v(this,"eventService");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"nodes",[]);v(this,"rowNodeMap",new Map);v(this,"firstRow",0);v(this,"lastRow",0);v(this,"loading",!1);this.options=e.options,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.firstRow=e,this.lastRow=t,!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((i,n)=>n>=e&&n<=t);for(let i=e;i<=t;i++)this.nodes[i-e]||(this.nodes[i-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:i=>{this.loading=!1,i.forEach((n,o)=>{const a=(n==null?void 0:n.id)!==void 0?String(n.id):`vrow-${e+o}`;let r=this.rowNodeMap.get(a);r||(r=new tt(n,this.rowNodeServices,a),this.rowNodeMap.set(a,r)),r.data=n,r.rowIndex=e+o,this.nodes[e+o-e]=r}),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,i)=>{t&&e(t,i)})}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}}class no{constructor(e){v(this,"eGui");var c,d,u;this.params=e;const t=e.node,i=!!t.group,n=!!t.detailNode,o=i||n,a=t.expanded,r=t.uiLevel*24,l=document.createElement("span");if(l.className="ag-group-cell-renderer",l.style.paddingLeft=`${r}px`,o){const f=document.createElement("span");f.className="ag-group-value-expanded-icon",f.classList.add(a?"ag-expanded":"ag-contracted"),f.innerHTML=a?So:bo,l.appendChild(f);const g=document.createElement("span");g.className="ag-group-value";const w=(c=e.colDef.cellRendererParams)==null?void 0:c.innerRenderer;if(typeof w=="function"){const h=w({...e,value:e.value,valueFormatted:e.valueFormatted});h instanceof HTMLElement?g.appendChild(h):typeof h=="string"&&(g.innerHTML=h)}else g.textContent=ho(e.value);if(l.appendChild(g),i&&t.allChildrenCount!==null&&!((d=e.colDef.cellRendererParams)!=null&&d.suppressCount)){const h=document.createElement("span");h.className="ag-group-child-count",h.textContent=` (${t.allChildrenCount})`,l.appendChild(h)}}else{const f=document.createElement("span");f.className="ag-group-value";const g=(u=e.colDef.cellRendererParams)==null?void 0:u.innerRenderer;if(typeof g=="function"){const w=g({...e,value:e.value,valueFormatted:e.valueFormatted});w instanceof HTMLElement?f.appendChild(w):typeof w=="string"&&(f.innerHTML=w)}else f.textContent=e.valueFormatted??String(e.value??"");l.appendChild(f)}this.eGui=l}getGui(){return this.eGui}refresh(e){return!1}}class oo{constructor(e){v(this,"eGui");v(this,"eCheckbox");this.params=e,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",i=>i.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.params=e,this.eCheckbox.checked=!!e.node.selected,!0}}const so='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',ao='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class lo{constructor(e){v(this,"eGui");v(this,"eArrow");v(this,"eOld");v(this,"eNew");v(this,"lastValue");v(this,"flashTimer",null);this.params=e,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 i=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),n=this.eNew.textContent??"";this.eArrow.innerHTML=i?so:ao,this.eArrow.style.display="",this.eArrow.classList.add(i?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=n,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",i?"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 ro{constructor(e){v(this,"eGui");this.params=e,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.params=e,this.eGui.textContent=String(e.rowIndex+1),!0}}class co{constructor(e){v(this,"eGui");var l,c;this.params=e;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],n=e.sparklineOptions||((c=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:c.sparklineOptions)||{},o=e.column.width||100,a=n.height||24,r=si(i,Math.max(20,o-16),a,n);t.appendChild(r),this.eGui=t}getGui(){return this.eGui}refresh(e){var r,l;const t=e.value||[],i=e.sparklineOptions||((l=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:l.sparklineOptions)||{},n=e.column.width||100,o=i.height||24;this.eGui.innerHTML="";const a=si(t,Math.max(20,n-16),o,{type:i.type,direction:i.direction});return this.eGui.appendChild(a),!0}}function si(s,e,t,i={}){var m,y,E;const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",String(Math.max(20,e))),n.setAttribute("height",String(t)),n.setAttribute("class","ag-sparkline");const o=(s||[]).map(R=>typeof R=="number"?R:Number((R==null?void 0:R.value)??0));if(!o||o.length<1)return n;const a=i.type||"line",r=Math.min(...o,0),c=Math.max(...o,0)-r||1,d=((m=i.tooltip)==null?void 0:m.enabled)===!0,u=((y=i.axis)==null?void 0:y.type)||"number",f=((E=i.pointsOfInterest)==null?void 0:E.show)===!0,g=(R,S)=>u==="category"?`${R+1}: ${S}`:String(S);if(f&&o.length>1){const R=o.indexOf(Math.min(...o)),S=o.indexOf(Math.max(...o)),P=e/Math.max(1,o.length-1),B=j=>t-2-(j-r)/c*(t-4),A=(j,W)=>{const T=document.createElementNS("http://www.w3.org/2000/svg","circle");T.setAttribute("cx",String(j*P)),T.setAttribute("cy",String(B(o[j]))),T.setAttribute("r","2.5"),T.setAttribute("fill",W),n.appendChild(T)};A(0,"#4caf50"),A(o.length-1,"#f44336"),A(R,"#2196f3"),A(S,"#ff9800")}if(d){const R=document.createElementNS("http://www.w3.org/2000/svg","title");R.textContent=o.map((S,P)=>g(P,S)).join(`
3
+ `),n.appendChild(R),n.style.cursor="default"}if(a==="bar"){const R=i.direction==="vertical",S=o.length;if(R){const P=Math.max(1,e/S-1),B=t-2-(0-r)/c*(t-4);o.forEach((A,j)=>{const W=j*(e/S),T=t-2-(A-r)/c*(t-4),F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("x",String(W)),F.setAttribute("width",String(P)),F.setAttribute("y",String(Math.min(T,B))),F.setAttribute("height",String(Math.max(1,Math.abs(B-T)))),F.setAttribute("fill","currentColor"),n.appendChild(F)})}else{const P=Math.max(1,t/S-1),B=2+(0-r)/c*(e-4);o.forEach((A,j)=>{const W=j*(t/S),T=2+(A-r)/c*(e-4),F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("y",String(W)),F.setAttribute("height",String(P)),F.setAttribute("x",String(Math.min(T,B))),F.setAttribute("width",String(Math.max(1,Math.abs(B-T)))),F.setAttribute("fill","currentColor"),n.appendChild(F)})}return n}const w=e/Math.max(1,o.length-1),h=o.map((R,S)=>{const P=S*w,B=t-2-(R-r)/c*(t-4);return`${P.toFixed(1)},${B.toFixed(1)}`});if(a==="area"){const R=document.createElementNS("http://www.w3.org/2000/svg","polygon");R.setAttribute("points",`0,${t} ${h.join(" ")} ${e},${t}`),R.setAttribute("fill","currentColor"),R.setAttribute("opacity","0.2"),n.appendChild(R)}const p=document.createElementNS("http://www.w3.org/2000/svg","polyline");return p.setAttribute("points",h.join(" ")),p.setAttribute("fill","none"),p.setAttribute("stroke","currentColor"),p.setAttribute("stroke-width","1.5"),n.appendChild(p),n}class uo{constructor(e){v(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Oi,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const zt={agGroupCellRenderer:s=>new no(s),agCheckboxCellRenderer:s=>new oo(s),agSparklineCellRenderer:s=>new co(s),agAnimateShowChangeCellRenderer:s=>new lo(s),agRowNumberCellRenderer:s=>new ro(s),agRowDragComp:s=>new uo(s)};function ho(s){return s==null?"":String(s)}class po{constructor(e){v(this,"eGui");v(this,"cancelled",!1);this.params=e,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 i;return(i=e.onKeyDown)==null?void 0:i.call(e,t)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class go{constructor(e){v(this,"eGui");v(this,"eInput");v(this,"cancelled",!1);var n,o;this.params=e;const t=document.createElement("div");t.className="ag-cell-editor-number";const i=document.createElement("input");if(i.type="text",i.className="ag-cell-editor-input",i.value=e.value??"",(o=(n=e.column)==null?void 0:n.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",l=>{var c,d;l.preventDefault(),l.preventDefault(),i.value=String(Number(i.value||0)+(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))});const r=document.createElement("span");r.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",r.innerHTML="▼",r.addEventListener("mousedown",l=>{var c,d;l.preventDefault(),i.value=String(Number(i.value||0)-(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))}),t.appendChild(a),t.appendChild(i),t.appendChild(r)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",a=>{var r;return(r=e.onKeyDown)==null?void 0:r.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 fo{constructor(e){v(this,"eGui");v(this,"cancelled",!1);var i,n;this.params=e,this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((n=(i=e.column)==null?void 0:i.cellEditorParams)==null?void 0:n.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 mo{constructor(e){v(this,"eGui");v(this,"cancelled",!1);this.params=e,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 vo{constructor(e){v(this,"eGui");v(this,"cancelled",!1);this.params=e,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 Co(s,e){if(!e)return Et(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?Et(s):Et(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+Et(s.slice(t,t+e.length))+"</span>"+Et(s.slice(t+e.length))}class wo{constructor(e){v(this,"eGui");v(this,"eInput");v(this,"ePopup",null);v(this,"eList",null);v(this,"values",[]);v(this,"filtered",[]);v(this,"activeIndex",0);v(this,"selectedValue");v(this,"cancelled",!1);var t,i;this.params=e,this.values=e.values||((i=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:i.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",n=>{n.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",n=>this.onKeyDown(n))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var a,r;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,yo(this.params)){const l=document.createElement("input");l.type="text",l.className="ag-rich-select-search",l.placeholder=((r=(a=this.params).t)==null?void 0:r.call(a,"search"))??"搜索…",l.value="",l.addEventListener("input",()=>this.renderList(l.value)),e.appendChild(l),setTimeout(()=>l.focus(),0)}const n=document.createElement("div");n.className="ag-rich-select-list",e.appendChild(n),this.eList=n,this.renderList();const o=l=>{!e.contains(l.target)&&!this.eGui.contains(l.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var i,n;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(o=>{if(!e)return!0;const a=String(o).toLowerCase(),r=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?r.every(l=>a.includes(l)):r.some(l=>a.includes(l))}),this.filtered.forEach((o,a)=>{const r=document.createElement("div");r.className="ag-rich-select-item",a===this.activeIndex&&r.classList.add("ag-active"),String(o)===String(this.selectedValue)&&r.classList.add("ag-selected");const l=this.params.cellRenderer;if(typeof l=="function"){const c=l({value:o,valueFormatted:String(o)});c instanceof HTMLElement?r.appendChild(c):r.textContent=String(c)}else r.innerHTML=Co(String(o),e);r.addEventListener("click",c=>{c.stopPropagation(),this.commit(o)}),r.addEventListener("mousedown",c=>c.preventDefault()),this.eList.appendChild(r)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((n=(i=this.params).t)==null?void 0:n.call(i,"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,i;return(i=(t=this.params).onKeyDown)==null?void 0:i.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 yo(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 it={agTextCellEditor:s=>new po(s),agNumberCellEditor:s=>new go(s),agSelectCellEditor:s=>new fo(s),agDateCellEditor:s=>new mo(s),agLargeTextCellEditor:s=>new vo(s),agRichSelectCellEditor:s=>new wo(s)},bo='<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>',Oi='<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>',xo='<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>',Eo='<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>',Mo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Bi='<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>';function Vi(s,e,t){const i=s.length;if(i===0||t<=0)return[];let n=0,o=i-1;for(;n<o;){const d=n+o>>1;s[d]>=t?o=d:n=d+1}const a=s[n]>=t?n:i-1,r=e[a];if(!r||r.level===0)return[];const l=[];let c=r.level;for(let d=a-1;d>=0;d--){const u=e[d];if(!(!u||u.level>=c)&&(c=u.level,u.group&&s[d]<t&&l.push(d),u.level===0))break}return l.reverse()}class ko{constructor(e,t,i){v(this,"ctx");v(this,"eRoot");v(this,"eHeader");v(this,"eBody");v(this,"ePinnedLeft");v(this,"ePinnedRight");v(this,"ePinnedLeftInner");v(this,"ePinnedRightInner");v(this,"eViewport");v(this,"eContainer");v(this,"eFloatingTop");v(this,"eFloatingBottom");v(this,"eFloatingTopLeft");v(this,"eFloatingTopRight");v(this,"eFloatingBottomLeft");v(this,"eFloatingBottomRight");v(this,"eStickyTop");v(this,"eStickyLeft");v(this,"eStickyCenter");v(this,"eStickyRight");v(this,"eRangeOverlay",null);v(this,"rowComps",new Map);v(this,"stickyComps",new Map);v(this,"hoveredRowId",null);v(this,"rowOffsets",[]);v(this,"rowInfos",[]);v(this,"totalHeight",0);v(this,"lastScrollTop",-1);v(this,"lastRange",[-1,-1]);v(this,"firstRendered",!1);v(this,"heightVersion",0);v(this,"scrollFrame",null);v(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 i=this.eViewport;let n=e.deltaY,o=e.deltaX;e.deltaMode===1?(n*=33,o*=33):e.deltaMode===2&&(n*=i.clientHeight,o*=i.clientWidth),e.shiftKey&&!o&&(o=n,n=0),n&&(i.scrollTop+=n),o&&(i.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});v(this,"onBodyMouseOver",e=>{var o;const t=e.target,i=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,".ag-row"),n=(i==null?void 0:i.dataset.rowid)??null;if(n===this.hoveredRowId){n&&this.setRowHovered(n,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=n,n&&this.setRowHovered(n,!0)});v(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=i,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 n=document.createElement("div");n.className="ag-body-viewport-wrapper",this.eBody.appendChild(n),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",n.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)),n.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",n.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 i of this.rowComps.values())i.getNode().id===e&&i.setHovered(t);for(const i of this.stickyComps.values())i.getNode().id===e&&i.setHovered(t)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}setRangeOverlay(e){this.eRangeOverlay=e}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount(),t=new Array(e),i=new Array(e);let n=0;if(this.hasVariableHeights()){for(let a=0;a<e;a++)t[a]=n,i[a]=this.rowInfoAt(a),n+=this.getRowHeightForIndex(a);this.totalHeight=n}else{const a=this.getFixedRowHeight();for(let r=0;r<e;r++)t[r]=r*a,i[r]=this.rowInfoAt(r);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=i}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?{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((n,o)=>n+o.width,0),t=this.ctx.getColumns().left.reduce((n,o)=>n+o.width,0),i=this.ctx.getColumns().right.reduce((n,o)=>n+o.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${t}px`,this.ePinnedRight.style.width=`${i}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=`${i}px`,this.eFloatingBottomLeft.style.width=`${t}px`,this.eFloatingBottomRight.style.width=`${i}px`,this.eStickyLeft.style.width=`${t}px`,this.eStickyRight.style.width=`${i}px`,this.eStickyCenter.style.left=`${t}px`,this.eStickyCenter.style.right=`${i}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 i,n;const e=(o,a,r,l,c)=>{o.innerHTML="",a.innerHTML="",r.innerHTML="";const{left:d,center:u,right:f}=this.ctx.getColumns();let g=0;for(let w=0;w<l;w++){const h=c(w);if(!h)continue;const p=this.ctx.getRowHeight(h),m=new Wt(this.ctx,h,d,u,f,p,this.heightVersion);m.appendTo(a,o,r),m.setTop(g),g+=p,this.rowComps.set(`${h.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${g}px`,o.style.display=l>0?"":"none",a.style.height=`${g}px`,r.style.height=`${g}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((i=t.getPinnedTopRowCount)==null?void 0:i.call(t))??0,o=>{var a;return(a=t.getPinnedTopRow)==null?void 0:a.call(t,o)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((n=t.getPinnedBottomRowCount)==null?void 0:n.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 i;e!=null&&e.columns&&(i=e.columns.map(n=>typeof n=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(o=>o.colId===n):n).filter(Boolean));for(const[n,o]of this.rowComps)t&&!t.includes(o.getNode())||o.refreshCells(i,e==null?void 0:e.force,e==null?void 0:e.flash);for(const n of this.stickyComps.values())t&&!t.includes(n.getNode())||n.refreshCells(i,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 i=t.getNode(),n=this.findRowIndex(i);if(t.destroy(),this.rowComps.delete(this.rowCompKey(i)),n>=0){const{left:o,center:a,right:r}=this.ctx.getColumns(),l=new Wt(this.ctx,i,o,a,r,this.getRowHeightForIndex(n),this.heightVersion);l.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),l.setTop(this.rowOffsets[n]??0),this.rowComps.set(this.rowCompKey(i),l)}}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){var t;for(let i=0;i<this.ctx.rowModel.getRowCount();i++)if(((t=this.ctx.rowModel.getRow(i))==null?void 0:t.id)===e.id)return i;return-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 i=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const n of this.stickyComps.values()){const o=n.getCenterElement();o&&(o.style.transform=i)}}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,i;this.eViewport.scrollLeft=e,this.syncPinnedScroll(),(i=(t=this.ctx).onViewportScroll)==null||i.call(t)}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Vi(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:i,right:n}=this.ctx.getColumns(),o=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${o}px`;const a=new Set;let r=0;for(const c of e){const d=this.ctx.rowModel.getRow(c);if(!d||!d.group)continue;a.add(d.id);let u=this.stickyComps.get(d.id);if(!u){const f=this.rowComps.get(d.id);f&&(f.destroy(),this.rowComps.delete(d.id)),u=new Wt(this.ctx,d,t,i,n,this.getRowHeightForIndex(c),this.heightVersion),u.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),u.setSticky(!0),this.stickyComps.set(d.id,u)}u.setTop(r),r+=this.getRowHeightForIndex(c)}for(const[c,d]of this.stickyComps)a.has(c)||(d.destroy(),this.stickyComps.delete(c));const l=`${r}px`;return this.eStickyTop.style.height=l,this.eStickyLeft.style.height=l,this.eStickyCenter.style.height=l,this.eStickyRight.style.height=l,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),i=this.eViewport.scrollTop,n=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a=0,r=t-1;if(this.hasVariableHeights())a=this.findIndexAtPixel(i)-o,r=this.findIndexAtPixel(i+n)+o;else{const p=this.getFixedRowHeight();a=Math.floor(i/p)-o,r=Math.ceil((i+n)/p)+o}if(a=Math.max(0,a),r=Math.min(t-1,r),!e&&this.lastRange[0]===a&&this.lastRange[1]===r&&this.lastScrollTop===i)return;const l=this.lastRange[0]!==a||this.lastRange[1]!==r;this.lastRange=[a,r],this.lastScrollTop=i;const c=new Set(this.stickyComps.keys()),d=this.syncStickyGroupRows(),u=c.size!==d.size||[...c].some(p=>!d.has(p));if(!e&&!l&&!u)return;const f=new Set(d),{left:g,center:w,right:h}=this.ctx.getColumns();for(let p=a;p<=r;p++){const m=this.ctx.rowModel.getRow(p);if(!m||(f.add(m.id),d.has(m.id)))continue;let y=this.rowComps.get(m.id);y||(y=new Wt(this.ctx,m,g,w,h,this.getRowHeightForIndex(p),this.heightVersion),y.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,y)),y.setTop(this.rowOffsets[p]??p*this.getFixedRowHeight())}for(const[p,m]of this.rowComps)!f.has(p)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(p))}findIndexAtPixel(e){const t=this.rowOffsets;let i=0,n=t.length-1;for(;i<n;){const o=i+n+1>>1;t[o]<=e?i=o:n=o-1}return i}ensureIndexVisible(e,t="top"){const i=this.rowOffsets[e]??e*this.getFixedRowHeight(),n=this.getRowHeightForIndex(e),o=this.eViewport.clientHeight;let a=this.eViewport.scrollTop;t==="top"?a=i:t==="bottom"?a=i+n-o:a=i-(o-n)/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 i=this.eViewport.clientWidth,n=this.eViewport.scrollLeft,o=e.left-this.ctx.getColumns().left.reduce((a,r)=>a+r.width,0);o<n?this.eViewport.scrollLeft=Math.max(0,t==="middle"?o-(i-e.width)/2:o):o+e.width>n+i&&(this.eViewport.scrollLeft=o+e.width-i),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 i=e.target.closest(".ag-cell");if(!i)return null;const n=i.dataset.colid;if(!n)return null;const o=i.closest(".ag-row"),a=o==null?void 0:o.dataset.rowid;if(!a)return null;const r=this.ctx.rowModel.getRowNode(a);if(!r)return null;const c=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(d=>d.colId===n);return c?(this.ctx.rowModel.getRowCount(),{node:r,column:c,eCell:i,rowIndex:0}):null}getRowIndexForNode(e){var t;for(let i=0;i<this.ctx.rowModel.getRowCount();i++)if(((t=this.ctx.rowModel.getRow(i))==null?void 0:t.id)===e.id)return i;return-1}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:ue(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node),colDef:t.column.colDef});return}const i=e.target.closest(".ag-row");if(i!=null&&i.dataset.rowid){const n=this.ctx.rowModel.getRowNode(i.dataset.rowid);n&&this.ctx.onRowClicked({event:e,node:n,data:n.data,rowIndex:this.getRowIndexForNode(n)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:ue(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node),colDef:t.column.colDef});return}const i=e.target.closest(".ag-row");if(i!=null&&i.dataset.rowid){const n=this.ctx.rowModel.getRowNode(i.dataset.rowid);n&&this.ctx.onRowDoubleClicked({event:e,node:n,data:n.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:ue(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:ue(t.column,t.node,null),rowIndex:this.getRowIndexForNode(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 Wt{constructor(e,t,i,n,o,a,r){v(this,"eLeft",null);v(this,"eCenter",null);v(this,"eRight",null);v(this,"cellComps",[]);v(this,"pinned",!1);var l,c,d,u,f,g,w,h,p;if(this.ctx=e,this.node=t,this.rowHeight=a,this.heightVersion=r,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}i.length&&(this.eLeft=this.createRowElement(t,i,"left"),this.eLeft.classList.add("ag-row-pinned")),(n.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,n,"center")),o.length&&(this.eRight=this.createRowElement(t,o,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((l=this.eCenter)==null||l.classList.add("ag-row-footer"),(c=this.eLeft)==null||c.classList.add("ag-row-footer"),(d=this.eRight)==null||d.classList.add("ag-row-footer")),t.group&&((u=this.eCenter)==null||u.classList.add("ag-row-group"),(f=this.eLeft)==null||f.classList.add("ag-row-group"),(g=this.eRight)==null||g.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((w=this.eCenter)==null||w.classList.add("ag-row-selected"),(h=this.eLeft)==null||h.classList.add("ag-row-selected"),(p=this.eRight)==null||p.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,i,n;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-sticky-group",e),(n=this.eRight)==null||n.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,i,n;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-hover",e),(n=this.eRight)==null||n.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,i){var l;const n=document.createElement("div");n.className="ag-row",n.dataset.rowid=e.id,n.setAttribute("role","row"),n.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),n.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&n.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&n.classList.add("ag-row-even"),n.style.height=`${this.rowHeight}px`,n.style.position="absolute",n.style.top="0px";const o=this.ctx.getRowClass(e);o&&n.classList.add(...o.split(" ").filter(Boolean));const a=this.ctx.getRowStyle(e);a&&Object.assign(n.style,a),e.footer&&((l=e.groupData)!=null&&l.__grandTotal)&&(n.classList.add("ag-row-full-width"),n.style.width="100%",n.style.right="0",n.style.left="0");let r=0;for(let c=0;c<t.length;c++){const d=t[c],u=this.createCell(d,e);let f=1;typeof d.colDef.colSpan=="function"&&(f=Math.max(1,Math.round(d.colDef.colSpan({value:ue(d,e,null),data:e.data,node:e,column:d,rowIndex:e.__displayIndex??0,api:null}))));let g=d.width;for(let w=1;w<f&&c+w<t.length;w++)g+=t[c+w].width;u.eCell.style.left=`${r}px`,u.eCell.style.width=`${g}px`,u.eCell.style.position="absolute",u.eCell.style.top="0",u.eCell.style.height=`${this.rowHeight}px`,f>1&&u.eCell.classList.add("ag-cell-col-span"),r+=g,c+=f-1,n.appendChild(u.eCell),this.cellComps.push(u)}return n.style.width=`${r}px`,n}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(i=>i.colId===e.colId)+1}createCell(e,t){var d,u;const i=document.createElement("div");i.className="ag-cell",i.dataset.colid=e.colId;const n=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");n&&i.classList.add(`ag-col-${n}`);const o={value:ue(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const f=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof f=="string"?i.classList.add(...f.split(" ").filter(Boolean)):Array.isArray(f)&&i.classList.add(...f)}if(e.cellClassRules)for(const[f,g]of Object.entries(e.cellClassRules))g(o)&&i.classList.add(f);if(e.cellStyle){const f=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(i.style,f)}(e.type==="numberColumn"||e.cellDataType===!0)&&i.classList.add("ag-right-aligned-cell"),e.rowDrag&&i.classList.add("ag-cell-row-drag");const a=document.createElement("span");a.className="ag-cell-value",i.appendChild(a),this.ctx.options.enableCellTextSelection&&(i.style.userSelect="text",i.style.cursor="text"),i.setAttribute("role","gridcell"),i.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const r=(u=(d=this.ctx).getNote)==null?void 0:u.call(d,t.id,e.colId,e.colDef.note,{value:ue(e,t,null),data:t.data,node:t,column:e,api:null});if(r){const f=document.createElement("span");f.className="ag-cell-note-marker",f.title=r,f.addEventListener("click",g=>{var w,h;g.stopPropagation(),(h=(w=this.ctx).onNoteClick)==null||h.call(w,t.id,e.colId,f)}),i.appendChild(f)}if(e.rowDrag){const f=document.createElement("span");f.className="ag-row-drag-handle",f.innerHTML=Oi,f.title=this.ctx.t("dragRow"),f.addEventListener("mousedown",g=>{var w,h;g.button===0&&(g.stopPropagation(),(h=(w=this.ctx).onRowDragStart)==null||h.call(w,t,f,g))}),i.appendChild(f)}const l=e.tooltipField;l&&t.data&&t.data[l]!==void 0?i.title=String(t.data[l]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:ue(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const c={column:e,eCell:i,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(c),c}updateCellContent(e){var c;const{column:t,node:i}={column:e.column,node:this.node},n=ue(t,i,null),o=Ot(t,i,null);e.lastValue=n,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,r=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||r){e.custom=!0;const d=a||"func";if(e.rendererKey!==d){e.eValue.innerHTML="",e.rendererKey=d;const u={value:n,valueFormatted:o,data:i.data,node:i,column:t,rowIndex:i.__displayIndex??0,api:null,colDef:t.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...t.cellRendererParams||{}};let f=null;if(a&&zt[a]){const g=zt[a](u);g instanceof HTMLElement?f=g:(e.rendererInstance=g,f=g.getGui())}else if(r){const g=r(u);g instanceof HTMLElement?f=g:g&&typeof g.getGui=="function"?(e.rendererInstance=g,f=g.getGui()):typeof g=="string"&&(e.eValue.innerHTML=g)}f&&e.eValue.appendChild(f)}return}e.rendererKey="",e.custom=!1,(c=e.rendererInstance)!=null&&c.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let l=o??"";if((i.group||i.footer)&&i.groupData){const d=i.groupData[t.colId];l=d==null?"":String(d)}e.eValue.textContent!==l&&(e.eValue.textContent=l)}refreshCells(e,t,i){var a,r,l,c;const n=e&&e.length?new Set(e.map(d=>d.colId)):null;for(const d of this.cellComps){if(n&&!n.has(d.column.colId))continue;const u=ue(d.column,this.node,null),f=t||u!==d.lastValue;if(!f&&!i)continue;const g=d.eValue.textContent;if(d.rendererInstance&&typeof d.rendererInstance.refresh=="function"){d.rendererInstance.refresh({value:u,valueFormatted:Ot(d.column,this.node,null),data:this.node.data,node:this.node,column:d.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:d.column.colDef,eGridCell:d.eCell,...d.column.cellRendererParams||{}})===!1&&this.updateCellContent(d),d.lastValue=u,i&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"));continue}if(d.rendererKey){(f||i)&&(d.rendererKey="",this.updateCellContent(d)),d.lastValue=u,i&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(d),(i||f&&g!==d.eValue.textContent)&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.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),(r=this.eLeft)==null||r.classList.toggle("ag-row-selected",o),(l=this.eRight)==null||l.classList.toggle("ag-row-selected",o),this.node.group&&((c=this.eCenter)==null||c.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,i){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&i.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const n=this.ctx.renderDetailRow(this.node,this.eCenter);n&&t.appendChild(n.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,i,n;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(t=this.eCenter)!=null&&t.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(i=this.eRight)!=null&&i.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const o of this.cellComps)(n=o.rendererInstance)!=null&&n.destroy&&o.rendererInstance.destroy();this.cellComps=[]}}class To{constructor(e,t){v(this,"ctx");v(this,"eHeader");v(this,"ePinnedLeftHeader");v(this,"ePinnedRightHeader");v(this,"eHeaderViewport");v(this,"eHeaderContainer");v(this,"eHeaderRow");v(this,"eFloatingFiltersRow",null);v(this,"eGroupRows");v(this,"headerCells",new Map);v(this,"customHeaderComponents",new Map);v(this,"resizeState",null);v(this,"dragState",null);v(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:i}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,t,"center"),this.renderSection(this.ePinnedRightHeader,i,"right");const n=[...e,...t,...i].some(o=>o.floatingFilter);n&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!n&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var r;const e=this.ctx.getColumnModel(),t=((r=e==null?void 0:e.getColumnGroups)==null?void 0:r.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((l,c)=>Math.max(l,c.depth),0),n=this.ctx.options.groupHeaderHeight??30;let o=0;for(let l=1;l<=i;l++){const c=document.createElement("div");c.className="ag-header-row ag-group-header-row",c.style.height=`${n}px`;const d=this.ctx.getColumns().center;let u=0,f,g=0,w=0;const h=(m,y)=>{let E=m.groupId;for(;E;){const R=t.find(S=>S.id===E);if(!R)return null;if(R.depth===y)return R.id;E=R.parentId}return null},p=()=>{if(f==null)return;const m=t.find(S=>S.id===f);if(!m)return;const y=document.createElement("div");y.className="ag-header-group-cell",y.style.left=`${g}px`,y.style.width=`${w}px`,y.style.height=`${n}px`;const E=e.isGroupOpen(m.id),R=document.createElement("div");if(R.className="ag-header-group-cell-label",R.textContent=m.headerName,y.appendChild(R),!E){const S=document.createElement("span");S.className="ag-header-group-expand",S.textContent="▸",S.title=this.ctx.t("expandGroup"),y.appendChild(S)}y.addEventListener("click",()=>{e.setGroupOpen(m.id,!E)}),c.appendChild(y)};d.forEach(m=>{const y=h(m,l);y!==f&&(p(),f=y,g=u,w=0),w+=m.width,u+=m.width}),p(),c.style.width=`${u}px`,this.eGroupRows.appendChild(c),o+=n}this.eGroupRows.style.display=i>0?"":"none";const a=this.ctx.headerHeight;this.eHeader.style.height=`${o+a}px`}renderSection(e,t,i){e.innerHTML="";let n=0;for(const o of t){const a=this.createHeaderCell(o);if(a.style.left=`${n}px`,a.style.width=`${o.width}px`,a.style.height=`${this.ctx.headerHeight}px`,n+=o.width,e.appendChild(a),this.headerCells.set(o.colId,a),o.eHeaderCell=a,this.eFloatingFiltersRow&&e===this.eHeaderRow&&o.floatingFilter){const r=this.createFloatingFilter(o);r.style.left=`${n-o.width}px`,r.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(r)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${n}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${n}px`)}createHeaderCell(e){var a,r;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 l=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(l).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const l=i({column:e,colDef:e.colDef,api:((r=(a=this.ctx).getApi)==null?void 0:r.call(a))??null,displayName:e.headerName}),c=l&&typeof l.getGui=="function"?l.getGui():l;if(c instanceof HTMLElement)return c.classList.add("ag-header-component"),t.appendChild(c),typeof(l==null?void 0:l.refresh)=="function"&&this.customHeaderComponents.set(e.colId,l),t}const n=document.createElement("div");if(n.className="ag-header-cell-label",e.headerTooltip&&(n.title=e.headerTooltip),e.headerCheckboxSelection){const l=document.createElement("input");l.type="checkbox",l.className="ag-native-checkbox ag-header-select-all",l.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,l.checked)),l.addEventListener("click",c=>c.stopPropagation()),n.appendChild(l)}const o=document.createElement("span");if(o.className="ag-header-cell-text",o.textContent=e.headerName,n.appendChild(o),t.appendChild(n),e.sortable){const l=document.createElement("span");l.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(l,e.sort,e.sortIndex),t.appendChild(l)}if(e.filter){const l=document.createElement("span");l.className="ag-header-icon ag-filter-icon";const c=this.ctx.isFilterActive(e);l.classList.toggle("ag-filter-active",c),l.innerHTML=Eo,l.title=this.ctx.t("openFilterTitle"),l.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onFilterOpened(e,l)}),t.appendChild(l)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const l=document.createElement("span");l.className="ag-header-icon ag-menu-icon",l.innerHTML=xo,l.title=this.ctx.t("openMenuTitle"),l.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onColumnMenuClicked(e,l)}),t.appendChild(l)}if(t.addEventListener("click",l=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,l,l.shiftKey||l.ctrlKey||l.metaKey)}),t.addEventListener("contextmenu",l=>{l.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:l}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",l=>{const c=t.getBoundingClientRect();l.clientX>c.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const l=document.createElement("div");l.className="ag-header-cell-resize",l.addEventListener("mousedown",c=>{c.stopPropagation(),c.preventDefault(),this.resizeState={column:e,startX:c.clientX,startWidth:e.width};const d=f=>{if(!this.resizeState)return;const g=f.clientX-this.resizeState.startX;let w=this.resizeState.startWidth+g;w=Math.max(e.minWidth,Math.min(e.maxWidth,w)),this.ctx.onColumnResized(e,Math.round(w),!1)},u=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",d),document.addEventListener("mouseup",u)}),t.appendChild(l)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",l=>{if(!l.dataTransfer)return;l.dataTransfer.setData("text/plain",e.colId),l.dataTransfer.effectAllowed="move";const c=t.cloneNode(!0);c.classList.add("ag-header-cell-drag-ghost"),c.style.position="absolute",c.style.top="-1000px",c.style.width=`${e.width}px`,c.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(c),l.dataTransfer.setDragImage(c,20,20),this.dragState={colId:e.colId,ghost:c,startX:l.clientX,startY:l.clientY},setTimeout(()=>c.remove(),0)}),t.addEventListener("dragend",()=>{var l;(l=this.dragState)!=null&&l.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",l=>{l.preventDefault()}),t.addEventListener("drop",l=>{var d;l.preventDefault();const c=(d=l.dataTransfer)==null?void 0:d.getData("text/plain");c&&c!==e.colId&&this.ctx.onColumnMoved(c,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 n=document.createElement("select");return n.className="ag-floating-filter-input",n.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',n.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,n.value)),t.appendChild(n),e.floatingFilterComp=n,t}const i=document.createElement("input");return i.className="ag-floating-filter-input",i.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",i.placeholder=this.ctx.t("filterOoo"),i.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),i.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,i.value)),t.appendChild(i),e.floatingFilterComp=i,t}updateSortIndicator(e,t,i){if(e.innerHTML="",t==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=Ro):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=Mo),t&&i!==null&&i>0){const n=document.createElement("span");n.className="ag-sort-order",n.textContent=String(i+1),e.appendChild(n)}}updateIndicators(){const{left:e,center:t,right:i}=this.ctx.getColumns();for(const n of[...e,...t,...i]){const o=this.headerCells.get(n.colId);if(!o)continue;const a=o.querySelector(".ag-sort-indicator");a&&this.updateSortIndicator(a,n.sort,n.sortIndex);const r=o.querySelector(".ag-filter-icon");r&&r.classList.toggle("ag-filter-active",this.ctx.isFilterActive(n)),o.style.width=`${n.width}px`,this.lastWidths.get(n.colId)!==n.width&&this.lastWidths.set(n.colId,n.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(i=>i.colId===e.colId)+1}layoutPositions(){const{left:e,center:t,right:i}=this.ctx.getColumns();let n=0;for(const o of e){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}this.ePinnedLeftHeader.style.width=`${n}px`,n=0;for(const o of t){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}this.eHeaderContainer.style.width=`${n}px`,n=0;for(const o of i){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}if(this.ePinnedRightHeader.style.width=`${n}px`,this.eFloatingFiltersRow){n=0;for(const o of t){const a=this.eFloatingFiltersRow.querySelector(`[data-colid="${o.colId}"]`);a&&(a.style.left=`${n}px`,a.style.width=`${o.width}px`),n+=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 No{constructor(e,t,i){v(this,"selectedNodes",new Set);v(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=t,this.isNodeSelectable=i}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 i of e.children)i.footer||i.detailNode||(t?this.isNodeSelectable(i)&&(this.selectedNodes.add(i),i.selected=!0):(this.selectedNodes.delete(i),i.selected=!1),this.selectChildrenRecursively(i,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 i=this.getOptions().rowSelection==="multiple",n=t.ctrlKey||t.metaKey,o=t.shiftKey;return i?o&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):n?(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 i=this.getOptions().__rowModel;if(!(i!=null&&i.forEachNode))return;let n=-1,o=-1,a=0;if(i.forEachNode(c=>{c===e&&(n=a),c===t&&(o=a),a++}),n<0||o<0)return;const r=Math.min(n,o),l=Math.max(n,o);a=0,i.forEachNode(c=>{a>=r&&a<=l&&this.isNodeSelectable(c)&&!c.footer&&(this.selectedNodes.add(c),c.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(n=>t.add(n));let i=!1;for(const n of this.selectedNodes)t.has(n)?n.selected=!0:i=!0;if(i){for(const n of[...this.selectedNodes])t.has(n)||this.selectedNodes.delete(n);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let t=0,i=0;return e!=null&&e.forEachNode&&e.forEachNode(n=>{n.footer||!this.isNodeSelectable(n)||(t++,n.selected&&i++)}),{checked:t>0&&i===t,indeterminate:i>0&&i<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Io{constructor(e,t){v(this,"editing",null);v(this,"fullRowEditors",null);v(this,"fullRowNode",null);v(this,"focusedCell",null);v(this,"suppressClickEdit",!1);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.grid.getRowRenderer().refreshCells({force:!0}),this.clearFocusClass();const i=this.findCellElement(t,e);i==null||i.classList.add("ag-cell-focus"),i&&typeof i.scrollIntoView=="function"&&i.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 i=this.grid.getDisplayedRowAtIndex(t);if(!i)return null;const o=this.grid.getRowRenderer().getRowComps().get(i.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 c;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const i=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!i||!this.grid.isCellEditable(t,i))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,i,e.charPress);return}const n=this.findCellElement(t,e.rowIndex);if(!n)return;const o=ue(t,i,this.grid.getApi()),a={value:e.charPress!==void 0?e.charPress:o,oldValue:o,data:i.data,node:i,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(c=t.cellEditorParams)==null?void 0:c.values,...t.cellEditorParams};let r=null;if(typeof t.cellEditor=="string")r=(it[t.cellEditor]||it.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const d=t.cellEditor(a);r=d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}else{const d=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";r=it[d](a)}if(!r)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:n,editor:r,startedValue:o},n.classList.add("ag-cell-inline-editing");const l=r.getGui();l.classList.add("ag-cell-editor"),n.appendChild(l),n.classList.add("ag-cell-editing"),r.focusIn&&r.focusIn(),r.afterGuiAttached&&r.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:i,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,i){const n=[...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 n){const a=this.findCellElement(o,e);if(!a)continue;const r=ue(o,t,this.grid.getApi()),l=this.createEditor(o,t,e,r,i);if(!l)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const c=l.getGui();c.classList.add("ag-cell-editor"),a.appendChild(c),this.fullRowEditors.push({column:o,editor:l,eCell:a,startedValue:r})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,n,o){var l;const a={value:o!==void 0?o:n,oldValue:n,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:i,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(l=e.cellEditorParams)==null?void 0:l.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(it[e.cellEditor]||it.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const c=e.cellEditor(a);return c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}const r=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return it[r](a)}stopEditing(e=!1){var c,d,u,f;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:i,rowNode:n,eCell:o,editor:a,startedValue:r}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let l=e?r:a.getValue();if(l===void 0&&!e)return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!1;if(!e){l=Di(i,l);const g=this.applyValueSetter(i,n,l);if(g===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:i}),!1;l=g}return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!e&&!zi(l,r)&&(this.grid.setCellValue(i,n,l,"edit",r),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r,newValue:l,value:l,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(f=(u=this.grid.getOptions()).onCellValueChanged)==null||f.call(u,{oldValue:r,newValue:l,value:l,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[n],columns:[i],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,i){if(e.valueSetter){if(e.valueSetter({oldValue:ue(e,t,this.grid.getApi()),newValue:i,data:t.data,node:t,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else t.setDataValue(e.colId,i);return i}stopFullRowEditing(e){var o,a,r;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const l of t)l.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=l.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),l.editor.destroy&&l.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const n=[];for(const l of t){if(!i)break;let c=l.editor.getValue();c!==void 0&&(c=Di(l.column,c),zi(c,l.startedValue)||n.push({column:l.column,rowNode:i,newValue:c,oldValue:l.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const l of n)this.grid.setCellValue(l.column,l.rowNode,l.newValue,"edit",l.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l.oldValue,newValue:l.newValue,value:l.newValue,data:l.rowNode.data,node:l.rowNode,column:l.column,colDef:l.column.colDef,api:this.grid.getApi(),source:"edit"}),(r=(a=this.grid.getOptions()).onCellValueChanged)==null||r.call(a,{oldValue:l.oldValue,newValue:l.newValue,value:l.newValue,data:l.rowNode.data,node:l.rowNode,column:l.column,colDef:l.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[l.rowNode],columns:[l.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===dt){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===Ln)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===Ri){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 i=this.focusedCell;switch(e.keyCode){case dt:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case Ri:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case Mi:case ki:i&&this.grid.isCellEditable(i.column,i.rowNode)&&(e.preventDefault(),this.grid.setCellValue(i.column,i.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[i.rowNode],columns:[i.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 Dn:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case An: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}i&&t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(i.column,i.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:i.rowIndex,colKey:i.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 i=this.focusedCell;if(!i){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let n=i.rowIndex;if(e===-1/0?n=0:e===1/0?n=this.grid.getDisplayedRowCount()-1:n=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,n+e)),t!==0){const o=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let r=o.findIndex(l=>l.colId===i.column.colId)+t;for(;r>=0&&r<o.length&&!o[r].visible;)r+=t;r<0&&(r=0),r>=o.length&&(r=o.length-1),this.setFocusedCell(n,o[r])}else this.setFocusedCell(n,i.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:i,event:n}=e;if(this.setFocusedCell(e.rowIndex,i),i.checkboxSelection)return;const o=this.grid.isCellEditable(i,t),a=i.singleClickEdit||this.grid.getOptions().singleClickEdit;o&&a&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}onCellDoubleClicked(e){const{node:t,column:i}=e;this.setFocusedCell(e.rowIndex,i),this.grid.isCellEditable(i,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}destroy(){this.editing=null,this.focusedCell=null}}function zi(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}class Lo{constructor(e){v(this,"filterModel",{});v(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 i=this.grid.getRowModel(),n=typeof i.doesNodePassFilterModel=="function"?i.doesNodePassFilterModel.bind(i):null,o=t.conditions.map(a=>{const r=this.grid.getColumn(a.colId);return!r||!n?!0:n(e,r,{...a,filterType:r.filter===!0?"text":r.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 i=typeof e=="string"?e:e.colId;t==null?delete this.filterModel[i]:this.filterModel[i]=t,this.onFilterChanged("api")}isFilterActive(e){const t=this.filterModel[e.colId];return t?t.filterType==="multi"?(t.filterModels||[]).some(n=>this.isModelMeaningful(n)):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 i,n;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(n=(i=this.grid.getOptions()).onFilterChanged)==null||n.call(i,{api:t,source:e})}}class Do{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,i){const n=this.grid.getOptions().suppressMultiSort,o=i&&!n&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,a=this.getSortingOrder(),r=e.sort;let l=a.indexOf(r)+1;l>=a.length&&(l=0);const c=a[l];if(!o)for(const d of this.grid.getAllColumns())d.colId!==e.colId&&(d.sort=null,d.sortIndex=null);e.sort=c,c===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,i)=>(t.sortIndex??99)-(i.sortIndex??99)).forEach((t,i)=>t.sortIndex=i)}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,i)=>{const n=this.grid.getColumn(t.colId);n&&(n.sort=t.sort,n.sortIndex=i)}),this.onSortChanged("api")}onSortChanged(e){var i,n;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(n=(i=this.grid.getOptions()).onSortChanged)==null||n.call(i,{api:t,source:e})}}class Wi{constructor(e,t){v(this,"enabled");v(this,"pageSize");v(this,"currentPage",0);v(this,"pageSizeSelector");v(this,"ePanel");v(this,"ePageInfo");v(this,"ePageInput");v(this,"ePageSizeSelect",null);v(this,"ePageSizeContainer");v(this,"eFromToContainer");this.grid=e,this.eventService=t;const i=e.getOptions();this.enabled=i.pagination===!0,this.pageSize=i.paginationPageSize??100,this.pageSizeSelector=i.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 n=document.createElement("div");n.className="ag-pagination-buttons",this.ePanel.appendChild(n),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",n.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",n.appendChild(this.eFromToContainer);const o=document.createElement("span");if(o.className="ag-pagination-page-label",o.textContent=`${this.grid.translate("page","Page")}`,n.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)}),n.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",n.appendChild(this.ePageInfo),this.pageSizeSelector){const a=this.ePageSizeContainer,r=document.createElement("span");r.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(r);const l=document.createElement("select");l.className="ag-pagination-page-size-select";const c=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const d of c){const u=document.createElement("option");u.value=String(d),u.textContent=String(d),d===this.pageSize&&(u.selected=!0),l.appendChild(u)}l.addEventListener("change",()=>this.setPageSize(parseInt(l.value,10))),a.appendChild(l),this.ePageSizeSelect=l}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(),i=Math.max(0,Math.min(t-1,e));if(i===this.currentPage){this.update();return}this.currentPage=i,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 r,l;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(),i=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),n=i===0?0:this.currentPage*this.pageSize+1,o=Math.min(i,(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=i===0?`0 ${a} 0 ${this.grid.translate("of","/")} 0`:`${n.toLocaleString()} ${a} ${o.toLocaleString()} ${this.grid.translate("of","/")} ${i.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:i}),(l=(r=this.grid.getOptions()).onPaginationChanged)==null||l.call(r,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Ao{constructor(e){v(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,t=""){const i=document.createElement("div");i.className=`ag-popup ${t}`.trim(),i.style.width=`${e}px`,i.style.display="none";const n={ePopup:i},o=()=>{var c;this.openPopups.has(n)&&(this.openPopups.delete(n),i.remove(),document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l,!0),(c=n.onClose)==null||c.call(n))},a=c=>{n.onClose=c},r=c=>{if(!i.contains(c.target)&&!this.grid.getRootElement().contains(c.target)){o();return}i.contains(c.target)||o()},l=c=>{c.key==="Escape"&&(c.stopPropagation(),o())};return this.getParent().appendChild(i),this.openPopups.add(n),document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l,!0),{ePopup:i,close:o,onClose:a}}positionAt(e,t,i=0){const n=this.grid.getRootElement().getBoundingClientRect(),o=t.getBoundingClientRect(),a=e.offsetWidth||220;let r=o.left-n.left+i;const l=n.width-a-4;r>l&&(r=l),r<4&&(r=4);const c=o.bottom-n.top+2;e.style.left=`${r}px`,e.style.top=`${c}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}const Tt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Nt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class Fo{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var p,m;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const i=e.filter===!0?"text":e.filter,n=this.grid.getFilterService().getFilterInstance(e.colId),o=i==="set"?260:240,{ePopup:a,close:r}=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);let c=n?{...n}:this.getDefaultModel(i),d=n?{...n}:null;const u=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),r()},f=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()};if(i==="set")a.appendChild(this.buildSetFilter(e,c,y=>{d=y}));else if(i==="boolean"){const y=this.buildConditionSelect(["true","false"],String(c.filter??""),E=>{d={filterType:"boolean",filter:E==="true"}});a.appendChild(y)}else{const y=i==="number"?Nt:Tt,E=this.buildConditionSelect(y,c.type||y[0],R=>{c.type=R,d={...c}});if(a.appendChild(E),c.type!=="blank"&&c.type!=="notBlank")if(i==="number"&&c.type==="inRange"){const R=document.createElement("div");R.className="ag-filter-inputs";const S=document.createElement("input");S.type="number",S.className="ag-filter-input",S.value=c.filter??"",S.placeholder=this.grid.t("from"),S.addEventListener("input",()=>{d={...c,filter:S.value,filterTo:P.value}});const P=document.createElement("input");P.type="number",P.className="ag-filter-input",P.value=c.filterTo??"",P.placeholder=this.grid.t("to"),P.addEventListener("input",()=>{d={...c,filter:S.value,filterTo:P.value}}),R.appendChild(S),R.appendChild(P),a.appendChild(R)}else if(i==="date"){const R=document.createElement("div");R.className="ag-filter-inputs";const S=document.createElement("input");S.type="date",S.className="ag-filter-input",S.value=c.dateFrom??"",S.addEventListener("input",()=>{d={...c,dateFrom:S.value,dateTo:P.value}});const P=document.createElement("input");P.type="date",P.className="ag-filter-input",P.value=c.dateTo??"",P.addEventListener("input",()=>{d={...c,dateFrom:S.value,dateTo:P.value}}),R.appendChild(S),R.appendChild(P),a.appendChild(R)}else{const R=document.createElement("input");R.type=i==="number"?"number":"text",R.className="ag-filter-input",R.value=c.filter??"",R.placeholder=this.grid.t("filterOoo"),R.addEventListener("input",()=>{d={...c,filter:R.value}}),R.addEventListener("keydown",S=>{S.key==="Enter"&&u()}),a.appendChild(R),setTimeout(()=>R.focus(),0)}else d={...c}}if(i==="text"||i==="number"){const y=document.createElement("div");y.className="ag-filter-second-condition";const E=document.createElement("select");E.className="ag-filter-condition",E.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,E.value=c.operator||"AND",y.appendChild(E);const R=this.buildConditionSelect(i==="number"?Nt:Tt,((p=c.condition2)==null?void 0:p.type)||(i==="number"?Nt:Tt)[0],P=>{d||(d={...c}),d.condition2={...d.condition2,type:P}});y.appendChild(R);const S=document.createElement("input");S.type=i==="number"?"number":"text",S.className="ag-filter-input",S.placeholder=this.grid.t("secondValue"),S.value=((m=c.condition2)==null?void 0:m.filter)??"",S.addEventListener("input",()=>{d||(d={...c}),d.condition2={...d.condition2,filter:S.value}}),y.appendChild(S),a.appendChild(y),E.addEventListener("change",()=>{d||(d={...c}),d.operator=E.value})}const g=document.createElement("div");g.className="ag-popup-buttons";const w=document.createElement("button");w.className="ag-button ag-button-primary",w.textContent=this.grid.t("apply"),w.addEventListener("click",u);const h=document.createElement("button");h.className="ag-button",h.textContent=this.grid.t("clear"),h.addEventListener("click",f),g.appendChild(h),g.appendChild(w),a.appendChild(g),this.popupService.positionAt(a,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,i){const n=document.createElement("div");n.className="ag-set-filter";const o=document.createElement("input");o.type="text",o.className="ag-filter-input",o.placeholder=this.grid.t("search"),n.appendChild(o);const a=new Set;this.grid.getRowModel().forEachNode(h=>{!h.group&&!h.footer&&a.add(ue(e,h,this.grid.getApi()))});let l=[...a].sort((h,p)=>h===p?0:h<p?-1:1);const c=document.createElement("div");c.className="ag-set-filter-list";const d=new Set((t.values||[]).map(h=>String(h))),u=()=>{c.innerHTML="";const h=o.value.toLowerCase();let p=0;for(const m of l){const y=m==null?"(Blanks)":String(m);if(h&&!y.toLowerCase().includes(h))continue;p++;const E=document.createElement("label");E.className="ag-set-filter-item";const R=document.createElement("input");R.type="checkbox",R.checked=d.has(String(m)),R.addEventListener("change",()=>{R.checked?d.add(String(m)):d.delete(String(m)),i({filterType:"set",values:[...d]})});const S=document.createElement("span");S.textContent=y,E.appendChild(R),E.appendChild(S),c.appendChild(E)}if(p===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),c.appendChild(m)}};o.addEventListener("input",u),u();const f=document.createElement("div");f.className="ag-set-filter-actions";const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent=this.grid.t("selectAll"),g.addEventListener("click",()=>{d.clear();for(const h of l)d.add(String(h));u(),i({filterType:"set",values:[...d]})});const w=document.createElement("button");return w.className="ag-button ag-button-small",w.textContent=this.grid.t("clearAll"),w.addEventListener("click",()=>{d.clear(),u(),i({filterType:"set",values:[]})}),f.appendChild(g),f.appendChild(w),n.appendChild(c),n.appendChild(f),i({filterType:"set",values:[...d]}),n}buildConditionSelect(e,t,i){const n=document.createElement("select");n.className="ag-filter-condition";for(const o of e){const a=document.createElement("option");a.value=o;const r=Yn[o];a.textContent=r?this.grid.t(r):o,o===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n}openMultiFilter(e,t){var E;const i=this.grid.getFilterService().getFilterInstance(e.colId),n=i&&i.filterType==="multi"?i:null,o=(E=n==null?void 0:n.filterModels)!=null&&E.length?n.filterModels.map(R=>({...R})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(n==null?void 0:n.operator)||"AND";const{ePopup:r,close:l}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");r.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`Filters for ${e.headerName||e.field||""}`,r.appendChild(c);const d=document.createElement("div");d.className="ag-multi-filter-operator";const u=document.createElement("span");u.textContent=this.grid.t("join");const f=document.createElement("select");f.className="ag-filter-condition",f.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',f.value=a,f.addEventListener("change",()=>{a=f.value}),d.appendChild(u),d.appendChild(f),r.appendChild(d);const g=document.createElement("div");g.className="ag-multi-filter-list",r.appendChild(g);const w=()=>{g.innerHTML="",o.forEach((R,S)=>{const P=document.createElement("div");P.className="ag-multi-filter-row";const B=document.createElement("select");B.className="ag-filter-condition";const A=["text","number","date","set","boolean"];for(const F of A){const N=document.createElement("option");N.value=F,N.textContent=F.charAt(0).toUpperCase()+F.slice(1),F===R.filterType&&(N.selected=!0),B.appendChild(N)}B.addEventListener("change",()=>{o[S]={...this.getDefaultModel(B.value)},w()}),P.appendChild(B);const j=R.filterType==="number"?Nt:Tt,W=this.buildConditionSelect(j,R.type||j[0],F=>{o[S].type=F});if(P.appendChild(W),R.filterType!=="blank"&&R.type!=="blank"&&R.type!=="notBlank"){const F=document.createElement("input");F.type=R.filterType==="number"?"number":"text",F.className="ag-filter-input",F.value=R.filter??"",F.placeholder=this.grid.t("value"),F.addEventListener("input",()=>{o[S].filter=F.value}),P.appendChild(F)}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(S,1),w()}),P.appendChild(T),g.appendChild(P)})};w();const h=document.createElement("button");h.className="ag-button ag-button-small",h.textContent="+ "+this.grid.t("addFilter"),h.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),w()}),r.appendChild(h);const p=document.createElement("div");p.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(S=>S.filter!==void 0&&S.filter!==""||S.type==="blank"||S.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),l()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),l()}),p.appendChild(y),p.appendChild(m),r.appendChild(p),this.popupService.positionAt(r,t)}openAdvancedFilter(e){var E,R;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),n=(E=i==null?void 0:i.conditions)!=null&&E.length?i.conditions.map(S=>({...S})):[{colId:((R=this.grid.getColumns().center[0])==null?void 0:R.colId)??"",type:"contains",filter:""}];let o=(i==null?void 0:i.operator)||"AND";const{ePopup:a,close:r}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=this.grid.t("advancedFilter"),a.appendChild(l);const c=document.createElement("div");c.className="ag-advanced-filter-list",a.appendChild(c);const d=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(S=>S.filter),u=()=>{c.innerHTML="",n.forEach((S,P)=>{const B=document.createElement("div");B.className="ag-advanced-filter-row";const A=document.createElement("select");A.className="ag-filter-condition";for(const _ of d()){const Q=document.createElement("option");Q.value=_.colId,Q.textContent=_.headerName||_.field||_.colId,_.colId===S.colId&&(Q.selected=!0),A.appendChild(Q)}A.addEventListener("change",()=>{n[P].colId=A.value}),B.appendChild(A);const j=this.grid.getColumn(S.colId),W=j&&j.filter!==!1?String(j.filter):"text",T=W==="number"?Nt:Tt,F=this.buildConditionSelect(T,S.type||"contains",_=>{n[P].type=_});B.appendChild(F);const N=document.createElement("input");N.type=W==="number"?"number":"text",N.className="ag-filter-input",N.value=S.filter??"",N.placeholder=this.grid.t("value"),N.addEventListener("input",()=>{n[P].filter=N.value}),B.appendChild(N);const z=document.createElement("button");z.className="ag-button ag-button-small",z.textContent="×",z.addEventListener("click",()=>{n.splice(P,1),u()}),B.appendChild(z),c.appendChild(B)})};u();const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent="+ "+this.grid.t("addCondition"),f.addEventListener("click",()=>{var S;n.push({colId:((S=d()[0])==null?void 0:S.colId)??"",type:"contains",filter:""}),u()}),a.appendChild(f);const g=document.createElement("div");g.className="ag-multi-filter-operator";const w=document.createElement("span");w.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=o,h.addEventListener("change",()=>{o=h.value}),g.appendChild(w),g.appendChild(h),a.appendChild(g);const p=document.createElement("div");p.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 S=n.filter(P=>P.filter!==void 0&&P.filter!=="");S.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:S}):t.setAdvancedFilterModel(null),r()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{t.setAdvancedFilterModel(null),r()}),p.appendChild(y),p.appendChild(m),a.appendChild(p),this.popupService.positionAt(a,e)}openCustomFilter(e,t){const i=e.colDef.filterComponent;if(typeof i!="function")return;const n=this.grid.getFilterService(),o=i({column:e,colDef:e.colDef,api:this.grid.getApi(),model:n.getFilterInstance(e.colId)??null,onModelChange:c=>n.setColumnFilterModel(e,c),onGuiAttached:()=>{}}),{ePopup:a,close:r}=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}}const Ui={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 Po{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 i=this.grid.getOptions().contextMenuItems;let n;typeof i=="function"?n=i({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(i)?n=i:n=this.getDefaultItems(t);const{ePopup:o,close:a}=this.popupService.createPopup(220,"ag-context-menu");o.innerHTML="",this.buildMenu(o,n,a),this.popupService.positionAt(o,e)}buildMenu(e,t,i){for(const n of t){if(typeof n=="string")continue;if(n.separator){const l=document.createElement("div");l.className="ag-menu-separator",e.appendChild(l);continue}const o=document.createElement("div");o.className="ag-menu-item",n.disabled&&o.classList.add("ag-menu-item-disabled"),n.cssClasses&&o.classList.add(...n.cssClasses);const a=document.createElement("span");a.className="ag-menu-item-icon",n.icon&&Ui[n.icon]&&(a.innerHTML=Ui[n.icon]),o.appendChild(a);const r=document.createElement("span");if(r.className="ag-menu-item-label",r.textContent=n.label??n.name,o.appendChild(r),n.shortcut){const l=document.createElement("span");l.className="ag-menu-item-shortcut",l.textContent=n.shortcut,o.appendChild(l)}if(n.subMenu){const l=document.createElement("span");l.className="ag-menu-item-arrow",l.textContent="›",o.appendChild(l),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(u=>u.remove());const d=document.createElement("div");d.className="ag-menu-popup-sub",this.buildMenu(d,n.subMenu,i),e.appendChild(d)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var d;o.matches(":hover")||((d=o.parentElement)==null?void 0:d.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(u=>u.remove())},200)})}else!n.disabled&&n.action&&o.addEventListener("click",()=>{n.action(),i()});e.appendChild(o)}}}class $o{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:i,close:n}=this.popupService.createPopup(220,"ag-column-menu");i.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=e.headerName||e.field||e.colId,i.appendChild(o);const a=(l,c)=>{const d=document.createElement("div");d.className="ag-menu-item",c.disabled&&d.classList.add("ag-menu-item-disabled"),c.checked&&d.classList.add("ag-menu-item-active");const u=document.createElement("span");u.className="ag-menu-item-check",c.checked&&(u.innerHTML=Bi),d.appendChild(u);const f=document.createElement("span");if(f.className="ag-menu-item-label",f.textContent=l,d.appendChild(f),c.shortcut){const g=document.createElement("span");g.className="ag-menu-item-shortcut",g.textContent=c.shortcut,d.appendChild(g)}return!c.disabled&&c.onClick&&d.addEventListener("click",()=>{c.onClick(),n()}),i.appendChild(d),d},r=l=>{const c=document.createElement("div");c.className="ag-menu-section",c.textContent=l,i.appendChild(c)};e.sortable&&(r(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&&(r(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||(r(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?(r(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&&(r(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),r(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)}),r(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(i,t)}}class Go{constructor(e,t){v(this,"eBar");v(this,"panels",[]);this.grid=e,this.eventService=t,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const n=e.getOptions().statusBar;(!n||!n.statusPanels||n.statusPanels.length===0)&&(this.eBar.style.display="none");const o=((n==null?void 0:n.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 r=document.createElement("div");r.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(r);const l={def:a,ePanel:r,render:()=>this.renderPanel(a.key,r)};this.panels.push(l)}}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 i=this.grid.getApi(),n=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,r=i.getSelectedNodes().length,l=[],c=this.grid.getColumnModel().getValueColumns().filter(d=>d.aggFunc);switch(this.grid.getRowModel().forEachNode(d=>{!d.footer&&d.group}),e){case"agTotalRowCountComponent":l.push(`${this.grid.translate("totalRows","Total Rows")} : ${Ke(a)}`);break;case"agTotalAndFilteredRowCountComponent":l.push(`${this.grid.translate("rows","Rows")} : ${Ke(n)}`);break;case"agFilteredRowCountComponent":l.push(`${this.grid.translate("filtered","Filtered")} : ${Ke(n)}`);break;case"agSelectedRowCountComponent":l.push(`${this.grid.translate("selected","Selected")} : ${Ke(r)}`);break;case"agAggregationComponent":{if(c.length===0)break;const d=i.getSelectedNodes().filter(f=>!f.group&&!f.footer),u=[];for(const f of c){const w=d.map(y=>ue(f,y,i)).filter(y=>typeof y=="number"&&!isNaN(y)),h=w.reduce((y,E)=>y+E,0),p=y=>y===null?"":Ke(y,f.decimals),m=[[this.grid.translate("average","Average"),w.length?h/w.length:null],[this.grid.translate("count","Count"),w.length],[this.grid.translate("min","Min"),w.length?Math.min(...w):null],[this.grid.translate("max","Max"),w.length?Math.max(...w):null],[this.grid.translate("sum","Sum"),w.length?h:null]];for(const[y,E]of m)u.push(`${y}${f.headerName?` (${f.headerName})`:""} : ${p(E)}`)}u.length&&l.push(u.join(" "));break}default:l.push(e);break}t.textContent=l.join(" "),t.style.display=l.length?"":"none"}}class Ho{constructor(e){v(this,"eBar");v(this,"eButtons");v(this,"ePanel");v(this,"panels",[]);v(this,"activePanelId",null);v(this,"visible",!1);v(this,"position");var i,n;this.grid=e;const t=e.getOptions();if(this.position=typeof t.sideBar=="object"&&((i=t.sideBar)!=null&&i.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(l=>typeof l=="string"?{id:l,label:this.defaultLabel(l)}:{id:l.id,label:l.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 r=(o==null?void 0:o.defaultToolPanel)||((n=this.panels[0])==null?void 0:n.id)||"columns";this.buildButtons(),this.openPanel(r)}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 i=document.createElement("div");i.className="ag-column-panel-columns",e.appendChild(i);const n=()=>{const c=t.value.toLowerCase();i.innerHTML="";const d=this.grid.getColumnModel().getColumns(),u=d.filter(f=>f.pinned!=="left"&&f.pinned!=="right").concat(d.filter(f=>f.pinned==="left"||f.pinned==="right"));for(const f of u)c&&!f.headerName.toLowerCase().includes(c)&&!f.colId.toLowerCase().includes(c)||i.appendChild(this.buildColumnItem(f));if(!i.children.length){const f=document.createElement("div");f.className="ag-side-bar-empty",f.textContent=this.grid.t("noMatchingColumns"),i.appendChild(f)}};t.addEventListener("input",n),n();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 r=document.createElement("div");r.className="ag-column-group-list",o.appendChild(r);const l=()=>{r.innerHTML="";const c=this.grid.getColumnModel().getRowGroupColumns();if(c.length===0){const d=document.createElement("div");d.className="ag-column-group-hint",d.textContent=this.grid.t("dragColumnsHere"),r.appendChild(d)}for(const d of c){const u=document.createElement("div");u.className="ag-column-group-item",u.draggable=!0,u.addEventListener("dragstart",w=>{var h;(h=w.dataTransfer)==null||h.setData("text/plain",d.colId)}),u.addEventListener("dragover",w=>w.preventDefault()),u.addEventListener("drop",w=>{var p;w.preventDefault();const h=(p=w.dataTransfer)==null?void 0:p.getData("text/plain");h&&this.grid.getColumnModel().setRowGroupColumns([...c.map(m=>m.colId),h])});const f=document.createElement("span");f.textContent=d.headerName,u.appendChild(f);const g=document.createElement("button");g.className="ag-column-group-remove",g.textContent="×",g.title=this.grid.t("remove"),g.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(d)),u.appendChild(g),r.appendChild(u)}};return l(),r.addEventListener("dragover",c=>c.preventDefault()),r.addEventListener("drop",c=>{var u;c.preventDefault();const d=(u=c.dataTransfer)==null?void 0:u.getData("text/plain");d&&this.grid.getColumnModel().addRowGroupColumn(d)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&l()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&n()}),e}buildColumnItem(e){const t=document.createElement("div");t.className="ag-column-select-column",t.draggable=!0,t.dataset.colid=e.colId;const i=document.createElement("input");i.type="checkbox",i.className="ag-column-select-checkbox",i.checked=e.visible,i.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,i.checked)}),t.appendChild(i);const n=document.createElement("span");n.className="ag-column-select-label",n.textContent=e.headerName||e.colId,t.appendChild(n);const o=document.createElement("span");if(o.className="ag-column-select-actions",e.enableRowGroup&&e.field){const r=document.createElement("button");r.className="ag-column-select-action",r.title=this.grid.t("groupByThisColumn"),r.textContent="≡",r.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(r)}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 r=document.createElement("span");r.className="ag-filters-tool-panel-item-badge",r.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(r)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const i=document.createElement("div");i.className="ag-filters-panel-list",e.appendChild(i);const n=()=>{const o=t.value.toLowerCase();i.innerHTML="";const a=this.grid.getColumns().center.filter(r=>r.filter);for(const r of a)o&&!r.headerName.toLowerCase().includes(o)||i.appendChild(this.buildFilterItem(r));if(!i.children.length){const r=document.createElement("div");r.className="ag-side-bar-empty",r.textContent=this.grid.t("noMatchingColumns"),i.appendChild(r)}};return t.addEventListener("input",n),n(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&n()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),i=document.createElement("div");i.className="ag-filters-tool-panel-item";const n=document.createElement("div");n.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,n.appendChild(o);const a=t.isFilterActive(e);if(a){const r=document.createElement("span");r.className="ag-filters-tool-panel-item-badge",r.innerHTML=Bi,n.appendChild(r)}if(i.appendChild(n),e.filter==="set"){const r=document.createElement("button");r.className="ag-button ag-button-small",r.textContent=a?"Edit filter":"Add filter",r.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,r)),i.appendChild(r)}else if(e.filter==="date"){const r=document.createElement("input");r.type="date",r.className="ag-filter-input";const l=t.getFilterInstance(e.colId);r.value=(l==null?void 0:l.dateFrom)??"",r.addEventListener("change",()=>{t.setColumnFilterModel(e,r.value?{filterType:"date",dateFrom:r.value,dateTo:r.value}:null)}),i.appendChild(r)}else{const r=document.createElement("input");r.type=e.filter==="number"?"number":"text",r.className="ag-filter-input",r.placeholder=this.grid.t("filterOoo");const l=t.getFilterInstance(e.colId);r.value=(l==null?void 0:l.filter)??"",r.addEventListener("input",()=>{t.handleFloatingFilterChange(e,r.value)}),i.appendChild(r)}if(a){const r=document.createElement("button");r.className="ag-button ag-button-small",r.textContent=this.grid.t("clear"),r.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(r)}return i}}class Oo{constructor(e,t){v(this,"matches",[]);v(this,"activeMatch",0);v(this,"searchText","");v(this,"matchCase",!1);v(this,"ePopup",null);v(this,"eCount",null);v(this,"eInput",null);v(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var l,c;if(this.ePopup){(l=this.eInput)==null||l.focus(),(c=this.eInput)==null||c.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const i=document.createElement("input");i.type="text",i.className="ag-find-input",i.placeholder=this.grid.translate("find","Find in grid..."),i.value=this.searchText,this.eInput=i,e.appendChild(i);const n=document.createElement("label");n.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)}),n.appendChild(o),n.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(n);const a=document.createElement("span");a.className="ag-find-count",this.eCount=a,e.appendChild(a);const r=(d,u,f)=>{const g=document.createElement("button");return g.className="ag-button ag-button-small",g.textContent=d,g.title=u,g.addEventListener("click",f),e.appendChild(g),g};r("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),r("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),r("×",this.grid.translate("close","关闭"),()=>this.close()),i.addEventListener("input",()=>this.find(i.value)),i.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),d.shiftKey?this.findPrevious():this.findNext()):d.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(()=>i.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((i,n)=>{if(!(i.group||i.footer))for(const o of t){ue(o,i,this.grid.getApi());const a=Ot(o,i,this.grid.getApi())??"",r=this.matchCase?a:a.toLowerCase(),l=this.matchCase?e:e.toLowerCase();r.includes(l)&&this.matches.push({rowIndex:n,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 r=t.getPageSize(),l=Math.floor(e.rowIndex/r);l!==t.getCurrentPage()&&t.goToPage(l)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const i=this.grid.getDisplayedRowAtIndex(e.rowIndex),n=this.grid.getColumn(e.colId);i&&n&&this.grid.getEditService().setFocusedCell(e.rowIndex,n)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,i]of e){let n=-1;this.grid.getRowModel().forEachNode((o,a)=>{o.id===t&&(n=a)});for(const o of i.getCellElements()){const a=o.dataset.colid,r=this.matches.findIndex(l=>l.rowIndex===n&&l.colId===a);o.classList.toggle("ag-find-match",r>=0),o.classList.toggle("ag-find-active-match",r>=0&&r===this.activeMatch)}}}}class Bo{constructor(e,t){v(this,"ranges",[]);v(this,"currentRange",null);v(this,"eOverlay");v(this,"eHandle");v(this,"dragState",null);this.grid=e,this.eventService=t;const i=e.getRowRenderer().getContainer();i.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",i.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",i.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:i,rowIndex:n}=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:n,colEndId:i.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const o={rowStartIndex:n,rowEndIndex:n,colStartId:i.colId,colEndId:i.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 i=t.closest(".ag-cell");if(!(i!=null&&i.dataset.colid))return;const n=i.closest(".ag-row");if(!(n!=null&&n.dataset.rowid))return;const o=this.grid.getRowModel().getRowNode(n.dataset.rowid);if(!o)return;let a=-1;if(this.grid.getRowModel().forEachNode((l,c)=>{l.id===o.id&&(a=c)}),a<0)return;const r=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(r.rowStartIndex,a),rowEndIndex:Math.max(r.rowStartIndex,a),colStartId:r.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(r.rowStartIndex,a),this.currentRange.colEndId=i.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(),i=t.findIndex(h=>h.colId===e.colStartId),n=t.findIndex(h=>h.colId===e.colEndId);if(i<0||n<0)return null;const o=Math.min(i,n),a=Math.max(i,n);let r=0,l=0;for(let h=0;h<=a;h++)h<o?r+=t[h].width:l+=t[h].width;const d=this.grid.getRowRenderer().getRowOffsets(),u=Math.min(e.rowStartIndex,e.rowEndIndex),f=Math.max(e.rowStartIndex,e.rowEndIndex),g=d[u]??u*(this.grid.getOptions().rowHeight??42);let w=0;for(let h=u;h<=f;h++){const p=this.grid.getDisplayedRowAtIndex(h);w+=p?this.grid.getRowHeight(p):this.grid.getOptions().rowHeight??42}return{top:g,left:r,width:l,height:w}}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=i=>this.onHandleMouseDown(i)}applyHighlight(){const e=this.ranges,t=this.grid.getRowRenderer().getRowComps(),i=this.getCenterColumns();for(const[n,o]of t){let a=-1;if(this.grid.getRowModel().forEachNode((r,l)=>{r.id===n&&(a=l)}),!(a<0))for(const r of o.getCellElements()){const l=r.dataset.colid,c=i.findIndex(f=>f.colId===l);let d=!1,u=!1;for(const f of e){const g=i.findIndex(E=>E.colId===f.colStartId),w=i.findIndex(E=>E.colId===f.colEndId),h=Math.min(f.rowStartIndex,f.rowEndIndex),p=Math.max(f.rowStartIndex,f.rowEndIndex),m=Math.min(g,w),y=Math.max(g,w);a>=h&&a<=p&&c>=m&&c<=y&&(d=!0,a===f.rowStartIndex&&c===g&&(u=!0))}r.classList.toggle("ag-cell-range-selected",d),r.classList.toggle("ag-cell-range-anchor",u)}}}getRangeCells(e){const t=this.getCenterColumns(),i=t.findIndex(d=>d.colId===e.colStartId),n=t.findIndex(d=>d.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),r=Math.min(i,n),l=Math.max(i,n),c=[];for(let d=o;d<=a;d++){const u=this.grid.getDisplayedRowAtIndex(d);if(u)for(let f=r;f<=l;f++)t[f]&&c.push({node:u,column:t[f]})}return c}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===ki||e.keyCode===Mi)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const i of this.getRangeCells(t))this.grid.setCellValue(i.column,i.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}function _i(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const nt=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class Vo{constructor(e,t){v(this,"charts",new Map);v(this,"chartCounter",0);v(this,"currentType","line");v(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),i=t.getRowGroupColumns();let n=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(l=>l.aggFunc),a=[],r=o.map(()=>[]);if(i.length>0)((c,d)=>{for(const u of c)if(u.group){const f=i[0]?String(ue(i[0],u,this.grid.getApi())??""):u.key??"";a.push(f);for(let g=0;g<o.length;g++){const w=[];qi(u,o[g],w),r[g].push(Number(kt(o[g],o[g].aggFunc,w))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(n||(n=this.grid.getColumns().center.find(l=>l.field&&l.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(l=>{if(l.group||l.footer)return;const c=n?ue(n,l,this.grid.getApi()):"";a.push(String(c??""));for(let d=0;d<o.length;d++){const u=ue(o[d],l,this.grid.getApi());r[d].push(typeof u=="number"?u:Number(u)||0)}}),a.length>200){const l=Math.ceil(a.length/200),c=[],d=r.map(()=>[]);for(let u=0;u<a.length;u+=l){c.push(a[u]);for(let f=0;f<r.length;f++)d[f].push(r[f][u])}return{categories:c,series:o.map((u,f)=>({title:u.headerName,data:d[f]}))}}return{categories:a,series:o.map((l,c)=>({title:l.headerName,data:r[c]}))}}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 i=document.createElement("div");i.className="ag-chart-panel-label",i.textContent=this.grid.t("chartType"),e.appendChild(i);const n=document.createElement("select");n.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 p of o){const m=document.createElement("option");m.value=p.value,m.textContent=p.label,p.value===this.currentType&&(m.selected=!0),n.appendChild(m)}n.addEventListener("change",()=>{this.currentType=n.value}),e.appendChild(n);const a=document.createElement("div");a.className="ag-chart-panel-label",a.textContent=this.grid.t("chartCategory"),e.appendChild(a);const r=document.createElement("select");r.className="ag-chart-panel-select";const l=this.grid.getColumnModel().getRowGroupColumns(),c=l.length>0?l:this.grid.getColumns().center.filter(p=>p.field);for(const p of c){const m=document.createElement("option");m.value=p.colId,m.textContent=l.length>0?`${this.grid.t("chartGroup")}: ${p.headerName}`:p.headerName,r.appendChild(m)}e.appendChild(r);const d=document.createElement("div");d.className="ag-chart-panel-label",d.textContent=this.grid.t("chartSeries"),e.appendChild(d);const u=this.grid.getColumnModel().getValueColumns().filter(p=>p.aggFunc),f=document.createElement("div");f.className="ag-chart-panel-series";const g=new Set(u.slice(0,3).map(p=>p.colId));for(const p 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=g.has(p.colId),y.addEventListener("change",()=>{y.checked?g.add(p.colId):g.delete(p.colId)}),m.appendChild(y);const E=document.createElement("span");E.textContent=p.headerName,m.appendChild(E),f.appendChild(m)}e.appendChild(f);const w=document.createElement("button");w.className="ag-button ag-button-primary ag-chart-panel-create",w.textContent=this.grid.t("createChart"),w.addEventListener("click",()=>{const p=this.grid.getColumn(r.value)||void 0,m=[...g].map(y=>this.grid.getColumn(y)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:p,valueColumns:m})}),e.appendChild(w);const h=document.createElement("div");if(h.className="ag-chart-panel-list",this.charts.size===0){const p=document.createElement("div");p.className="ag-side-bar-empty",p.textContent=this.grid.t("noChartsCreated"),h.appendChild(p)}for(const[p,m]of this.charts){const y=document.createElement("div");y.className="ag-chart-panel-list-item";const E=document.createElement("span");E.textContent=m.title,y.appendChild(E);const R=document.createElement("button");R.className="ag-column-group-remove",R.textContent="×",R.addEventListener("click",()=>this.destroyChart(p)),y.appendChild(R),h.appendChild(y)}return e.appendChild(h),e}createChart(e={}){var p,m,y,E;const t=e.type||this.currentType,i=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),n=`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 r=document.createElement("div");r.className="ag-chart-window-header";const l=document.createElement("span");l.className="ag-chart-window-title",l.textContent=o,r.appendChild(l);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent=this.grid.t("downloadPng"),r.appendChild(c);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent="×",d.title=this.grid.t("close"),d.addEventListener("click",()=>this.destroyChart(n)),r.appendChild(d),a.appendChild(r);const u=document.createElement("div");u.className="ag-chart-window-body";const f=document.createElement("canvas");f.className="ag-chart-canvas",f.width=600,f.height=360,u.appendChild(f);const g=document.createElement("div");g.className="ag-chart-tooltip",g.style.display="none",u.appendChild(g),f.addEventListener("mousemove",R=>this.onChartHover({id:n,ePopup:a,canvas:f,type:t,data:i,title:o},R,g)),f.addEventListener("mouseleave",()=>{g.style.display="none"});const w=document.createElement("div");w.className="ag-chart-legend",u.appendChild(w),a.appendChild(u),this.timeSeries=i.categories.length>0&&i.categories.every(R=>!isNaN(Date.parse(String(R)))&&isNaN(Number(R)));const h={id:n,ePopup:a,canvas:f,type:t,data:i,title:o};return this.charts.set(n,h),c.addEventListener("click",()=>{const R=f.toDataURL("image/png"),S=document.createElement("a");S.href=R,S.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,S.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(h),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:n,chartTitle:o,api:this.grid.getApi()}),(m=(p=this.grid.getOptions()).onChartCreated)==null||m.call(p,{chartId:n,chartTitle:o,api:this.grid.getApi()}),((y=this.grid.getSideBarService())==null?void 0:y.getActivePanel())==="charts"&&((E=this.grid.getSideBarService())==null||E.refresh()),n}destroyChart(e){var i,n,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()}),(n=(i=this.grid.getOptions()).onChartDestroyed)==null||n.call(i,{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,i){const o=e.canvas.getBoundingClientRect(),a=600/(o.width||1),r=360/(o.height||1),l=(t.clientX-o.left)*a,c=(t.clientY-o.top)*r,d={top:20,right:20,bottom:34,left:56},u=600-d.left-d.right,f=360-d.top-d.bottom;if(l<d.left||l>d.left+u||c<d.top||c>d.top+f){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const g=e.type==="bar",w=Math.max(1,e.data.categories.length),h=(g?f:u)/w,p=Math.floor((g?c-d.top:l-d.left)/h);if(p<0||p>=e.data.categories.length){i.style.display="none";return}const m=e.data.series.map(y=>`${y.title}: ${this.formatTick(y.data[p]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${_i(e.data.categories[p])}</div>`+m.map(y=>`<div>${_i(y)}</div>`).join(""),i.style.display="block",i.style.left=`${t.clientX-o.left+12}px`,i.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(i=>({id:i.id,type:i.type,title:i.title,data:i.data}));try{localStorage.setItem(e,JSON.stringify(t))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let t=[];try{const i=localStorage.getItem(e);i&&(t=JSON.parse(i))}catch{return}for(const i of t)this.restoreChart(i)}restoreChart(e){const t=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(t))return;const{ePopup:i}=this.popupService.createPopup(640,"ag-chart-window");i.innerHTML="";const n=document.createElement("div");n.className="ag-chart-window-header";const o=document.createElement("span");o.className="ag-chart-window-title",o.textContent=e.title||this.grid.t("chart"),n.appendChild(o);const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="×",a.addEventListener("click",()=>this.destroyChart(t)),n.appendChild(a),i.appendChild(n);const r=document.createElement("div");r.className="ag-chart-window-body";const l=document.createElement("canvas");l.className="ag-chart-canvas",l.width=600,l.height=360,r.appendChild(l);const c=document.createElement("div");c.className="ag-chart-legend",r.appendChild(c),i.appendChild(r);const d={id:t,ePopup:i,canvas:l,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,d),this.popupService.positionAt(i,this.grid.getRootElement()),i.style.top="60px",this.renderChart(d)}renderChart(e){var j;const t=e.canvas,i=t.getContext("2d");if(!i)return;const n=window.devicePixelRatio||1,o=t.width,a=t.height;t.width=o*n,t.height=a*n,t.style.width=`${o}px`,t.style.height=`${a}px`,i.scale(n,n),i.clearRect(0,0,o,a);const r=getComputedStyle(this.grid.getRootElement()),l=r.getPropertyValue("--ag-chart-text-color")||"#666",c=r.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",d={top:20,right:20,bottom:34,left:56},u=o-d.left-d.right,f=a-d.top-d.bottom;i.font="11px sans-serif",i.fillStyle=l,i.strokeStyle=c,i.lineWidth=1;const g=(j=e.canvas.parentElement)==null?void 0:j.querySelector(".ag-chart-legend");if(g&&(g.innerHTML="",e.data.series.forEach((W,T)=>{const F=document.createElement("span");F.className="ag-chart-legend-item";const N=document.createElement("span");N.className="ag-chart-legend-swatch",N.style.backgroundColor=nt[T%nt.length],F.appendChild(N),F.appendChild(document.createTextNode(W.title)),g.appendChild(F)})),e.type==="pie"){this.renderPie(i,e.data,o,a,l);return}const w=e.data.series.flatMap(W=>W.data);let h=Math.max(0,...w),p=Math.min(0,...w);e.type==="scatter"&&(p=Math.min(...w),h=Math.max(...w));const m=h-p||1;h+=m*.08,p-=p<0?m*.08:0;const y=h-p||1,E=W=>d.top+f-(W-p)/y*f,R=5;i.textAlign="right",i.textBaseline="middle";for(let W=0;W<=R;W++){const T=p+y*W/R,F=E(T);i.beginPath(),i.moveTo(d.left,F),i.lineTo(o-d.right,F),i.stroke(),i.fillText(this.formatTick(T),d.left-6,F)}const S=e.data.categories,P=e.type==="bar",B=Math.max(1,S.length),A=(P?f:u)/B;if(P){i.textAlign="left",S.forEach((T,F)=>{const N=d.top+F*A,z=Math.max(2,A*.7/e.data.series.length);e.data.series.forEach((_,Q)=>{const ie=_.data[F]||0,U=Math.abs(ie)/y*u,$=d.left+(0-p)/y*u;i.fillStyle=nt[Q%nt.length],i.fillRect($,N+Q*z,Math.max(1,U),z-1)}),i.fillStyle=l,i.fillText(this.truncate(T,18),d.left+4,N+A/2)});const W=d.left+(0-p)/y*u;i.beginPath(),i.moveTo(W,d.top),i.lineTo(W,d.top+f),i.strokeStyle=l,i.stroke()}else{const W=Math.max(1,Math.ceil(B/12));i.textAlign="center",i.textBaseline="top",S.forEach((N,z)=>{if(z%W!==0)return;const _=d.left+A*(z+.5);i.fillStyle=l,i.fillText(this.truncate(N,10),_,d.top+f+6)});const T=e.data.series.length,F=Math.max(1,A*.7/Math.max(1,T));e.data.series.forEach((N,z)=>{const _=nt[z%nt.length];if(e.type==="column")i.fillStyle=_,N.data.forEach((Q,ie)=>{const U=d.left+A*ie+(A-F*T)/2+z*F,$=E(Q);i.fillRect(U,$,F-1,d.top+f-$)});else if(e.type==="area"){i.beginPath(),N.data.forEach((ie,U)=>{const $=d.left+A*(U+.5),q=E(ie);U===0?i.moveTo($,q):i.lineTo($,q)});const Q=d.left+A*(N.data.length-.5);i.lineTo(Q,d.top+f),i.lineTo(d.left+A*.5,d.top+f),i.closePath(),i.globalAlpha=.25,i.fillStyle=_,i.fill(),i.globalAlpha=1,i.beginPath(),N.data.forEach((ie,U)=>{const $=d.left+A*(U+.5),q=E(ie);U===0?i.moveTo($,q):i.lineTo($,q)}),i.strokeStyle=_,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=_,N.data.forEach((Q,ie)=>{const U=d.left+A*(ie+.5),$=E(Q);i.beginPath(),i.arc(U,$,3,0,Math.PI*2),i.fill()})):(i.beginPath(),N.data.forEach((Q,ie)=>{const U=d.left+A*(ie+.5),$=E(Q);ie===0?i.moveTo(U,$):i.lineTo(U,$)}),i.strokeStyle=_,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,n,o){const a=t.series[0];if(!a)return;const r=a.data.reduce((f,g)=>f+Math.abs(g),0)||1,l=i/2,c=n/2,d=Math.min(i,n)/2-30;let u=-Math.PI/2;a.data.forEach((f,g)=>{const w=Math.abs(f)/r*Math.PI*2;e.beginPath(),e.moveTo(l,c),e.arc(l,c,d,u,u+w),e.closePath(),e.fillStyle=nt[g%nt.length],e.fill();const h=u+w/2,p=l+Math.cos(h)*(d*.7),m=c+Math.sin(h)*(d*.7),y=Math.round(Math.abs(f)/r*100);y>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${y}%`,p,m)),u+=w}),e.fillStyle=o}formatTick(e){if(this.timeSeries){const i=new Date(e);if(!isNaN(i.getTime()))return i.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 qi(s,e,t){const i=s.children;if(!i||i.length===0){const n=ue(e,s,null);typeof n=="number"&&!isNaN(n)&&t.push(n);return}for(const n of i)qi(n,e,t)}class zo{constructor(e){v(this,"eOverlayWrapper");v(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 i=document.createElement("div");i.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const n=document.createElement("div");if(n.className="ag-overlay-text",n.textContent=t,e==="loading"){const o=document.createElement("div");o.className="ag-overlay-loading-spinner",i.appendChild(o)}i.appendChild(n),this.eOverlayWrapper.appendChild(i),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}const i=e.getRowCount(),n=this.grid.getOptions().rowData;Array.isArray(n)&&n.length>0,i===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}const Wo=(()=>{const s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function Uo(s){let e=4294967295;for(let t=0;t<s.length;t++)e=Wo[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Ki(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 _o(s){let e="",t=s+1;for(;t>0;){const i=(t-1)%26;e=String.fromCharCode(65+i)+e,t=Math.floor((t-1)/26)}return e}function qo(s){const e=new TextEncoder,t=[],i=[];let n=0;for(const u of s){const f=e.encode(u.name),g=Uo(u.data),w=new Uint8Array(30+f.length),h=new DataView(w.buffer);h.setUint32(0,67324752,!0),h.setUint16(4,20,!0),h.setUint16(6,2048,!0),h.setUint16(8,0,!0),h.setUint16(10,0,!0),h.setUint16(12,8585,!0),h.setUint32(14,g,!0),h.setUint32(18,u.data.length,!0),h.setUint32(22,u.data.length,!0),h.setUint16(26,f.length,!0),h.setUint16(28,0,!0),w.set(f,30),t.push(w,u.data);const p=new Uint8Array(46+f.length),m=new DataView(p.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,g,!0),m.setUint32(20,u.data.length,!0),m.setUint32(24,u.data.length,!0),m.setUint16(28,f.length,!0),m.setUint32(42,n,!0),p.set(f,46),i.push(p),n+=w.length+u.data.length}const o=i.reduce((u,f)=>u+f.length,0),a=new Uint8Array(22),r=new DataView(a.buffer);r.setUint32(0,101010256,!0),r.setUint16(8,s.length,!0),r.setUint16(10,s.length,!0),r.setUint32(12,o,!0),r.setUint32(16,n,!0);const l=t.reduce((u,f)=>u+f.length,0)+o+a.length,c=new Uint8Array(l);let d=0;for(const u of t)c.set(u,d),d+=u.length;for(const u of i)c.set(u,d),d+=u.length;return c.set(a,d),c}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,i)=>{const n=i+1,a=t.some(r=>r.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${n}"${a}>`,t.forEach((r,l)=>{const c=`${_o(l)}${n}`,d=r.bold?' s="1"':"";if(r.value===null||r.value===void 0||r.value===""){e+=`<c r="${c}"${d}/>`;return}typeof r.value=="number"&&isFinite(r.value)?e+=`<c r="${c}"${d}><v>${r.value}</v></c>`:typeof r.value=="boolean"?e+=`<c r="${c}"${d} t="b"><v>${r.value?1:0}</v></c>`:e+=`<c r="${c}"${d} t="inlineStr"><is><t xml:space="preserve">${Ki(String(r.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const jo='<?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 Xo(s){const e=new TextEncoder,t=(u,f)=>u.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${f+1}`;let i="",n="",o="";s.forEach((u,f)=>{const g=t(u.name,f),w=f+1;i+=`<sheet name="${Ki(g)}" sheetId="${w}" r:id="rId${w}"/>`,n+=`<Relationship Id="rId${w}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${w}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${w}.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>",r='<?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>',l=`<?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>${i}</sheets></workbook>`,c='<?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"/>'+n+"</Relationships>",d=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(r)},{name:"xl/workbook.xml",data:e.encode(l)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(c)},{name:"xl/styles.xml",data:e.encode(jo)}];return s.forEach((u,f)=>{d.push({name:`xl/worksheets/sheet${f+1}.xml`,data:e.encode(Ko(u.rows))})}),new Blob([qo(d)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const Yo={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function ji(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function Qo(s,e,t){const i=Math.max(1,Math.floor(e/(t*.5)));return s.length>i?`${s.slice(0,Math.max(1,i-1))}…`:s}function Jo(){return new TextEncoder}function Zo(s,e={}){const[t,i]=Yo[e.pageSize||"a4-landscape"],n=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,r=e.headerColor??[.94,.95,.97],l=e.borderColor??[.85,.87,.9],c=Jo(),d=[],u=y=>(d.push(y),d.length);u(""),u("");const f=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),g=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),w=[];for(const y of s){let E="";const R=y.columnWidths.reduce((N,z)=>N+z,0),S=Math.min(1,(t-n*2)/(R||1)),P=y.columnWidths.map(N=>N*S),B=n;let A=i-n-(e.title?24:0);e.title&&(E+=`BT /F2 ${o+4} Tf ${B} ${A} Td (${ji(e.title)}) Tj ET
4
+ `,A-=18),y.rows.forEach((N,z)=>{var U;const _=z===0,Q=((U=y.rowFill)==null?void 0:U[z])??(_?r:void 0);Q&&(E+=`${Q[0]} ${Q[1]} ${Q[2]} rg ${B} ${(A-a+4).toFixed(2)} ${R*S} ${a} re f
5
+ `);let ie=B;N.forEach(($,q)=>{const Z=P[q]??0,te=ji(Qo($.text??"",Z-6,o)),be=$.bold||_?g:f,me=($.text??"").length*o*.5;let ce=ie+3;$.align==="right"||!$.align&&q>0&&/^-?[\d,.%$£€\s]+$/.test($.text??"")?ce=ie+Z-3-Math.min(me,Z-6):$.align==="center"&&(ce=ie+(Z-Math.min(me,Z-6))/2),E+=`BT /F${be===g?2:1} ${o} Tf ${ce.toFixed(2)} ${(A-o+2).toFixed(2)} Td (${te}) Tj ET
6
+ `,ie+=Z}),E+=`${l[0]} ${l[1]} ${l[2]} RG 0.5 w ${B} ${(A-a+4).toFixed(2)} m ${(B+R*S).toFixed(2)} ${(A-a+4).toFixed(2)} l S
7
+ `,A-=a});const j=y.rows.length*a;E+=`${l[0]} ${l[1]} ${l[2]} RG 0.5 w ${B} ${(A+a-4).toFixed(2)} m ${B} ${(A+j+a-4).toFixed(2)} l ${(B+R*S).toFixed(2)} ${(A+j+a-4).toFixed(2)} l ${(B+R*S).toFixed(2)} ${(A+a-4).toFixed(2)} l S
8
+ `;const W=c.encode(E),T=u(`<< /Length ${W.length} >>
9
9
  stream
10
10
  ${E}
11
- endstream`),D=u(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${i}] /Resources << /Font << /F1 ${f} 0 R /F2 ${g} 0 R >> >> /Contents ${M} 0 R >>`);p.push(D)}d[0]="<< /Type /Catalog /Pages 2 0 R >>",d[1]=`<< /Type /Pages /Kids [${p.map(y=>`${y} 0 R`).join(" ")}] /Count ${p.length} >>`;let C=`%PDF-1.4
12
- `;const h=[];d.forEach((y,E)=>{const R=E+1;h.push(c.encode(C).length),C+=`${R} 0 obj
11
+ endstream`),F=u(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${i}] /Resources << /Font << /F1 ${f} 0 R /F2 ${g} 0 R >> >> /Contents ${T} 0 R >>`);w.push(F)}d[0]="<< /Type /Catalog /Pages 2 0 R >>",d[1]=`<< /Type /Pages /Kids [${w.map(y=>`${y} 0 R`).join(" ")}] /Count ${w.length} >>`;let h=`%PDF-1.4
12
+ `;const p=[];d.forEach((y,E)=>{const R=E+1;p.push(c.encode(h).length),h+=`${R} 0 obj
13
13
  ${y}
14
14
  endobj
15
- `});const m=c.encode(C).length;C+=`xref
15
+ `});const m=c.encode(h).length;h+=`xref
16
16
  0 ${d.length+1}
17
17
  0000000000 65535 f
18
- `;for(const y of h)C+=`${String(y).padStart(10,"0")} 00000 n
19
- `;return C+=`trailer
18
+ `;for(const y of p)h+=`${String(y).padStart(10,"0")} 00000 n
19
+ `;return h+=`trailer
20
20
  << /Size ${d.length+1} /Root 1 0 R >>
21
21
  startxref
22
22
  ${m}
23
23
  %%EOF
24
- `,new Blob([c.encode(C)],{type:"application/pdf"})}function mt(s,e){return s.getUint32(e,!0)}function ct(s,e){return s.getUint16(e,!0)}async function ts(s){var n;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(n=new Response(s).body)==null?void 0:n.pipeThrough(new DecompressionStream("deflate-raw"));if(!t)throw new Error("Failed to create a decompression stream");const i=await new Response(t).arrayBuffer();return new Uint8Array(i)}function is(s){const e=new DataView(s),t=new Uint8Array(s);let i=-1;for(let r=t.length-22;r>=0;r--)if(mt(e,r)===101010256){i=r;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const n=ct(e,i+10);let o=mt(e,i+16);const a=[];for(let r=0;r<n&&mt(e,o)===33639248;r++){const l=ct(e,o+10),c=mt(e,o+20),d=mt(e,o+24),u=ct(e,o+28),f=ct(e,o+30),g=ct(e,o+32),p=mt(e,o+42),C=new TextDecoder().decode(t.subarray(o+46,o+46+u));a.push({name:C,compressionMethod:l,compressedSize:c,uncompressedSize:d,localHeaderOffset:p}),o+=46+u+f+g}return a}async function ai(s,e){const t=new DataView(s),i=new Uint8Array(s),n=ct(t,e.localHeaderOffset+26),o=ct(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+n+o,r=i.subarray(a,a+e.compressedSize);return e.compressionMethod===0?r:ts(r)}function li(s){return new DOMParser().parseFromString(s,"application/xml")}function ns(s){const e=s.replace(/\d+/g,"");let t=0;for(const i of e)t=t*26+(i.charCodeAt(0)-64);return t-1}async function os(s){const e=is(s),t=e.find(c=>c.name==="xl/workbook.xml"),i=[];if(t){const d=li(new TextDecoder().decode(await ai(s,t))).getElementsByTagName("sheet");for(let u=0;u<d.length;u++)i.push(d[u].getAttribute("name")||`Sheet${u+1}`),d[u].getAttribute("r:id")||d[u].getAttribute("id")}const n=[],o=e.find(c=>c.name==="xl/sharedStrings.xml");if(o){const d=li(new TextDecoder().decode(await ai(s,o))).getElementsByTagName("si");for(let u=0;u<d.length;u++){const f=d[u].getElementsByTagName("t");let g="";for(let p=0;p<f.length;p++)g+=f[p].textContent||"";n.push(g)}}const r=e.filter(c=>/^xl\/worksheets\/sheet\d+\.xml$/.test(c.name)).sort((c,d)=>c.name.localeCompare(d.name,void 0,{numeric:!0})),l=[];for(let c=0;c<r.length;c++){const u=li(new TextDecoder().decode(await ai(s,r[c]))).getElementsByTagName("row"),f=[];for(let g=0;g<u.length;g++){const p=u[g],C=[],h=p.getElementsByTagName("c");for(let m=0;m<h.length;m++){const y=h[m],E=y.getAttribute("r")||"",R=y.getAttribute("t")||"";let S="";if(R==="s"){const B=y.getElementsByTagName("v")[0],L=Number((B==null?void 0:B.textContent)||"0");S=n[L]??""}else if(R==="inlineStr"){const B=y.getElementsByTagName("t");for(let L=0;L<B.length;L++)S+=B[L].textContent||""}else{const B=y.getElementsByTagName("v")[0];S=(B==null?void 0:B.textContent)??""}const A=E?ns(E):m;C[A]=S}f.push(C.map(m=>m??""))}l.push({name:i[c]||`Sheet${c+1}`,rows:f})}return l}class ss{constructor(e){v(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(n=>typeof n=="string"?this.grid.getColumn(n):n).filter(n=>!!n);if(e.allColumns)return t.filter(n=>n.field||n.valueGetter);const i=this.grid.getColumns();return[...i.center,...i.left,...i.right]}getExportRows(e){const t=this.grid.getRowModel(),i=[],n=e.onlySelected===!0,o=e.skipGroups!==!1,a=e.skipFooters!==!1;return t.forEachNode(r=>{r.rowPinned==="top"&&e.skipPinnedTop!==!1||r.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&r.group&&!r.footer||a&&r.footer||n&&!r.selected||i.push(r)}),n&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let n=de(e,t,this.grid.getApi()),o=Ot(e,t,this.grid.getApi());if(i.processCellCallback){const a=i.processCellCallback({value:n,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(a!=null)return String(a)}return t.footer&&t.groupData&&t.groupData[e.colId]!==void 0&&(n=t.groupData[e.colId],o=n===null?"":String(n)),t.group&&t.groupData&&t.groupData[e.colId]!==void 0&&(n=t.groupData[e.colId],o=n===null?"":String(n)),n instanceof Date?n.toISOString().slice(0,10):o??(n==null?"":String(n))}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),i=this.getExportRows(e),n=e.columnSeparator??",",o=[];if(!e.skipHeader){const r=t.map(l=>{const c=l.headerName||l.field||l.colId;return e.processHeaderCallback?e.processHeaderCallback({column:l,api:this.grid.getApi()}):c});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(l=>l.headerName),n,e.suppressQuotes)),o.push(this.csvRow(r,n,e.suppressQuotes))}for(const r of i){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:r,api:this.grid.getApi()}))continue;const l=t.map(c=>this.getCellValueForExport(c,r,e));o.push(this.csvRow(l,n,e.suppressQuotes))}return o.join(`\r
24
+ `,new Blob([c.encode(h)],{type:"application/pdf"})}function vt(s,e){return s.getUint32(e,!0)}function ut(s,e){return s.getUint16(e,!0)}async function es(s){var n;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(n=new Response(s).body)==null?void 0:n.pipeThrough(new DecompressionStream("deflate-raw"));if(!t)throw new Error("Failed to create a decompression stream");const i=await new Response(t).arrayBuffer();return new Uint8Array(i)}function ts(s){const e=new DataView(s),t=new Uint8Array(s);let i=-1;for(let r=t.length-22;r>=0;r--)if(vt(e,r)===101010256){i=r;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const n=ut(e,i+10);let o=vt(e,i+16);const a=[];for(let r=0;r<n&&vt(e,o)===33639248;r++){const l=ut(e,o+10),c=vt(e,o+20),d=vt(e,o+24),u=ut(e,o+28),f=ut(e,o+30),g=ut(e,o+32),w=vt(e,o+42),h=new TextDecoder().decode(t.subarray(o+46,o+46+u));a.push({name:h,compressionMethod:l,compressedSize:c,uncompressedSize:d,localHeaderOffset:w}),o+=46+u+f+g}return a}async function ai(s,e){const t=new DataView(s),i=new Uint8Array(s),n=ut(t,e.localHeaderOffset+26),o=ut(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+n+o,r=i.subarray(a,a+e.compressedSize);return e.compressionMethod===0?r:es(r)}function li(s){return new DOMParser().parseFromString(s,"application/xml")}function is(s){const e=s.replace(/\d+/g,"");let t=0;for(const i of e)t=t*26+(i.charCodeAt(0)-64);return t-1}async function ns(s){const e=ts(s),t=e.find(c=>c.name==="xl/workbook.xml"),i=[];if(t){const d=li(new TextDecoder().decode(await ai(s,t))).getElementsByTagName("sheet");for(let u=0;u<d.length;u++)i.push(d[u].getAttribute("name")||`Sheet${u+1}`),d[u].getAttribute("r:id")||d[u].getAttribute("id")}const n=[],o=e.find(c=>c.name==="xl/sharedStrings.xml");if(o){const d=li(new TextDecoder().decode(await ai(s,o))).getElementsByTagName("si");for(let u=0;u<d.length;u++){const f=d[u].getElementsByTagName("t");let g="";for(let w=0;w<f.length;w++)g+=f[w].textContent||"";n.push(g)}}const r=e.filter(c=>/^xl\/worksheets\/sheet\d+\.xml$/.test(c.name)).sort((c,d)=>c.name.localeCompare(d.name,void 0,{numeric:!0})),l=[];for(let c=0;c<r.length;c++){const u=li(new TextDecoder().decode(await ai(s,r[c]))).getElementsByTagName("row"),f=[];for(let g=0;g<u.length;g++){const w=u[g],h=[],p=w.getElementsByTagName("c");for(let m=0;m<p.length;m++){const y=p[m],E=y.getAttribute("r")||"",R=y.getAttribute("t")||"";let S="";if(R==="s"){const B=y.getElementsByTagName("v")[0],A=Number((B==null?void 0:B.textContent)||"0");S=n[A]??""}else if(R==="inlineStr"){const B=y.getElementsByTagName("t");for(let A=0;A<B.length;A++)S+=B[A].textContent||""}else{const B=y.getElementsByTagName("v")[0];S=(B==null?void 0:B.textContent)??""}const P=E?is(E):m;h[P]=S}f.push(h.map(m=>m??""))}l.push({name:i[c]||`Sheet${c+1}`,rows:f})}return l}class os{constructor(e){v(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(n=>typeof n=="string"?this.grid.getColumn(n):n).filter(n=>!!n);if(e.allColumns)return t.filter(n=>n.field||n.valueGetter);const i=this.grid.getColumns();return[...i.center,...i.left,...i.right]}getExportRows(e){const t=this.grid.getRowModel(),i=[],n=e.onlySelected===!0,o=e.skipGroups!==!1,a=e.skipFooters!==!1;return t.forEachNode(r=>{r.rowPinned==="top"&&e.skipPinnedTop!==!1||r.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&r.group&&!r.footer||a&&r.footer||n&&!r.selected||i.push(r)}),n&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let n=ue(e,t,this.grid.getApi()),o=Ot(e,t,this.grid.getApi());if(i.processCellCallback){const a=i.processCellCallback({value:n,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(a!=null)return String(a)}return t.footer&&t.groupData&&t.groupData[e.colId]!==void 0&&(n=t.groupData[e.colId],o=n===null?"":String(n)),t.group&&t.groupData&&t.groupData[e.colId]!==void 0&&(n=t.groupData[e.colId],o=n===null?"":String(n)),n instanceof Date?n.toISOString().slice(0,10):o??(n==null?"":String(n))}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),i=this.getExportRows(e),n=e.columnSeparator??",",o=[];if(!e.skipHeader){const r=t.map(l=>{const c=l.headerName||l.field||l.colId;return e.processHeaderCallback?e.processHeaderCallback({column:l,api:this.grid.getApi()}):c});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(l=>l.headerName),n,e.suppressQuotes)),o.push(this.csvRow(r,n,e.suppressQuotes))}for(const r of i){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:r,api:this.grid.getApi()}))continue;const l=t.map(c=>this.getCellValueForExport(c,r,e));o.push(this.csvRow(l,n,e.suppressQuotes))}return o.join(`\r
25
25
  `)}csvRow(e,t,i){return e.map(n=>{const o=n==null?"":String(n);return!i&&(o.includes(t)||o.includes('"')||o.includes(`
26
- `))?`"${o.replace(/"/g,'""')}"`:o}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),i=this.getExportRows(e),n=[];e.skipHeader||n.push(t.map(o=>({value:o.headerName||o.field||o.colId,bold:!0})));for(const o of i)n.push(t.map(a=>{let r=de(a,o,this.grid.getApi());return o.footer&&o.groupData&&o.groupData[a.colId]!==void 0&&(r=o.groupData[a.colId]),o.group&&o.groupData&&o.groupData[a.colId]!==void 0&&(r=o.groupData[a.colId]),r instanceof Date&&(r=r.toISOString().slice(0,10)),{value:r}}));return Yo([{name:e.sheetName||"Sheet1",rows:n}])}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 p;const t=this.getExportColumns(e),i=this.getExportRows(e),n=t.map(C=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(C.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(C=>({text:e.processHeaderCallback?e.processHeaderCallback({column:C,api:this.grid.getApi()}):C.headerName||C.field||C.colId,bold:!0,align:C.type==="numberColumn"||C.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const C of i)(p=e.shouldRowBeSkipped)!=null&&p.call(e,{node:C,api:this.grid.getApi()})||(o.push(t.map(h=>{let m=this.getCellValueForExport(h,C,e);if(e.processCellCallback){const y=e.processCellCallback({value:de(h,C,this.grid.getApi()),formattedValue:m,node:C,column:h,api:this.grid.getApi()});y!=null&&(m=String(y))}return{text:m,align:h.type==="numberColumn"||h.cellDataType===!0?"right":"left"}})),a.push(void 0));const r=18,l=e.pageSize||"a4-landscape",[c,d]=l.includes("portrait")?[595,842]:[842,595],u=d-64-(e.title?24:0),f=Math.max(5,Math.floor(u/r)),g=[];o.length===0&&g.push({columnWidths:n,rows:[],rowFill:[]});for(let C=0;C<o.length;C+=f)g.push({columnWidths:n,rows:o.slice(C,C+f),rowFill:a.slice(C,C+f)});return es(g,{pageSize:l,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const i=e instanceof ArrayBuffer?e:await e.arrayBuffer(),o=(await os(i))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],r=o.rows.slice(1).map(l=>{const c={};return a.forEach((d,u)=>{const f=d||`col${u+1}`,g=l[u]??"",p=String(g).trim();c[f]=p!==""&&!isNaN(Number(p))&&!/^0\d/.test(p)?Number(p):g}),c});return t.onSuccess?t.onSuccess(r):this.grid.getApi().setRowData(r),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:r}),r}fileName(e,t){const i=e.fileName||this.grid.getOptions().fileName||"export";return i.endsWith(`.${t}`)?i:`${i}.${t}`}download(e,t){const i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(i),1e3)}copyToClipboard(e={}){const t={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},i=this.getDataAsCsv(t);this.lastCopied=i,this.writeToClipboard(i),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(i=>i.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(),i=this.grid.getRangeSelectionService().getRanges();let n,o;if(i.length>0){const u=i[0];n=u.rowStartIndex;const f=this.grid.getColumns().center,g=f.findIndex(p=>p.colId===u.colStartId);o=f[g]??f[0]}else if(t)n=t.rowIndex,o=t.column;else return;const a=e.replace(/\r/g,"").split(`
27
- `);a.length&&a[a.length-1]===""&&a.pop();const r=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],l=r.findIndex(u=>u.colId===o.colId),c=[],d=[];this.grid.getDisplayedRowCount(),a.forEach((u,f)=>{const g=u.split(" "),p=n+f;let C=this.grid.getDisplayedRowAtIndex(p);if(!C){const h={};g.forEach((m,y)=>{const E=r[l+y];E!=null&&E.field&&(h[E.field]=m)}),d.push(h);return}g.forEach((h,m)=>{const y=r[l+m];y&&this.grid.setCellValue(y,C,h,"paste")}),c.push(C)}),d.length&&this.grid.getApi().applyTransaction({add:d}),c.length&&this.grid.refreshCells({rowNodes:c,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 i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();try{document.execCommand("copy")}catch{}document.body.removeChild(i),t()}}class as{constructor(e){v(this,"ePanel");v(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 r;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(r=o.dataTransfer)==null?void 0:r.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const i=e.getOptions();(i.rowGroupPanelShow==="always"||i.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 i=document.createElement("div");i.className="ag-row-group-chip",i.draggable=!0,i.addEventListener("dragstart",a=>{var r;(r=a.dataTransfer)==null||r.setData("text/plain",t.colId)});const n=document.createElement("span");n.textContent=t.headerName,i.appendChild(n);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)),i.appendChild(o),this.eChips.appendChild(i)}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 ls{constructor(e,t){v(this,"undoStack",[]);v(this,"redoStack",[]);v(this,"limit",50);v(this,"batchDepth",0);v(this,"batchBuffer",[]);v(this,"batchCounter",0);v(this,"currentBatchId",0);this.grid=e,this.eventService=t;const i=e.getOptions();i.undoRedoCellEditing&&(this.limit=typeof i.undoRedoCellEditing=="number"?i.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 i of e)this.applyValue(i,i.oldValue),this.redoStack.push(i),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 i=this.grid.getRowNode(e.rowNodeId);if(!i)return;const n=this.grid.getColumn(e.colId);n&&(this.grid.setCellValue(n,i,t,"undoRedo"),this.grid.refreshCells({rowNodes:[i],columns:[n],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 i of this.batchBuffer)this.undoStack.push({...i,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 rs{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:i,close:n}=this.popupService.createPopup(460,"ag-formula-editor");i.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,i.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"),i.appendChild(a);const r=document.createElement("div");r.className="ag-formula-preview";const l=()=>{const C=this.grid.getDisplayedRowAtIndex(0);if(!C){r.textContent="";return}try{const h=Mt(a.value,{data:C.data});r.textContent=`${this.grid.t("formulaPreview")}: ${h==null?"":String(h)}`,r.classList.remove("ag-formula-error")}catch(h){r.textContent=`${this.grid.t("formulaError")}: ${(h==null?void 0:h.code)||(h==null?void 0:h.message)||this.grid.t("invalidFormula")}`,r.classList.add("ag-formula-error")}};a.addEventListener("input",l),i.appendChild(r);const c=document.createElement("div");c.className="ag-formula-functions";const d=document.createElement("div");d.className="ag-formula-functions-title",d.textContent=this.grid.t("functions"),c.appendChild(d);const u=document.createElement("div");u.className="ag-formula-functions-list";for(const C of Ht){const h=document.createElement("button");h.className="ag-button ag-button-small",h.textContent=C,h.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${C}()`,a.focus(),l()}),u.appendChild(h)}c.appendChild(u),i.appendChild(c);const f=document.createElement("div");f.className="ag-popup-buttons";const g=document.createElement("button");g.className="ag-button ag-button-primary",g.textContent=this.grid.t("apply"),g.addEventListener("click",()=>{const C=a.value.trim(),h=this.grid.getColumnModel(),m=h.getColumn(e.colId);m&&(m.field=C==="="||C===""?e.field:C,m.colDef={...m.colDef,field:m.field},C!=="="&&C!==""&&(m.editable=!1)),h.refreshAll(),this.grid.refreshCells({force:!0}),n()});const p=document.createElement("button");p.className="ag-button",p.textContent=this.grid.t("clear"),p.addEventListener("click",()=>{a.value="=",l()}),f.appendChild(p),f.appendChild(g),i.appendChild(f),this.popupService.positionAt(i,t),l()}}class cs{constructor(e,t){v(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,i,n){const o=this.runtimeNotes.get(this.keyOf(e,t));if(o!==void 0)return o;if(typeof i=="function")return i(n);if(typeof i=="string")return i}setNote(e,t,i){const n=this.keyOf(e,t);i==null||i===""?this.runtimeNotes.delete(n):this.runtimeNotes.set(n,i),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,i){const n=this.grid.getColumn(t),o=this.grid.getRowNode(e),a=this.getNote(e,t,n==null?void 0:n.colDef.note,{data:o==null?void 0:o.data,node:o,column:n,api:this.grid.getApi()})??"",{ePopup:r,close:l}=this.popupService.createPopup(280,"ag-note-editor");r.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`${this.grid.t("note")} — ${(n==null?void 0:n.headerName)||t}`,r.appendChild(c);const d=document.createElement("textarea");d.className="ag-formula-input",d.rows=4,d.value=a,d.placeholder=this.grid.t("writeNote"),r.appendChild(d);const u=document.createElement("div");u.className="ag-popup-buttons";const f=document.createElement("button");f.className="ag-button ag-button-primary",f.textContent=this.grid.t("save"),f.addEventListener("click",()=>{this.setNote(e,t,d.value.trim()||void 0),l()});const g=document.createElement("button");g.className="ag-button",g.textContent=this.grid.t("delete"),g.addEventListener("click",()=>{this.setNote(e,t,void 0),l()}),u.appendChild(g),u.appendChild(f),r.appendChild(u),this.popupService.positionAt(r,i),setTimeout(()=>d.focus(),0)}}class ds{constructor(e,t){v(this,"dragState",null);v(this,"onMouseMoveBind",e=>this.onMouseMove(e));v(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 i=document.createElement("div");i.className="ag-row-drag-ghost",i.textContent=this.rowLabel(e),document.body.appendChild(i);const n=document.createElement("div");n.className="ag-row-drop-indicator",n.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(n),this.dragState={rowNode:e,ghost:i,startY:t.clientY,overIndex:null,indicator:n},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var n;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],i=t!=null&&t.field?(n=e.data)==null?void 0:n[t.field]:"";return String(i??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 i=document.elementFromPoint(e.clientX,e.clientY),n=i==null?void 0:i.closest(".ag-row");if(!(n!=null&&n.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let o=-1;if(this.grid.getRowModel().forEachNode((a,r)=>{a.id===n.dataset.rowid&&(o=r)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),r=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),l=e.clientY>n.getBoundingClientRect().top+r/2,c=(a[o]??0)+(l?r:0);t.indicator.style.display="block",t.indicator.style.top=`${c-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 i=this.grid.getApi(),n=this.grid.getOptions(),o=t.overIndex,a=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:i,node:t.rowNode,overIndex:o,overNode:o!==null?this.grid.getDisplayedRowAtIndex(o):void 0,y:e.clientY}),n.rowDragManaged&&a>=0&&o!==null&&o!==a&&this.moveRow(a,o,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((i,n)=>{i.id===e.id&&(t=n)}),t}moveRow(e,t,i){const n=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=n.length)return;const[o]=n.splice(e,1),a=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),n.splice(Math.max(0,Math.min(n.length,a+1)),0,o),this.grid.getApi().setRowData(n),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:o}})}}function us(s){const e={setRowData:i=>s.setRowData(i),applyTransaction:i=>s.applyTransaction(i),getRowNode:i=>s.getRowNode(i),getDisplayedRowCount:()=>s.getDisplayedRowCount(),getDisplayedRowAtIndex:i=>s.getDisplayedRowAtIndex(i),getFirstDisplayedRow:()=>s.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>s.getDisplayedRowAtIndex(s.getDisplayedRowCount()-1),forEachNode:i=>{const n=s.getRowModel();for(let o=0;o<n.getRowCount();o++){const a=n.getRow(o);a&&i(a,o)}},forEachLeafNode:i=>{s.getRowModel().forEachLeafNode(i)},getModel:()=>s.getRowModel(),getValue:(i,n)=>{const o=typeof i=="string"?s.getColumn(i):i;if(!(!o||!n))return de(o,n,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:(i,n)=>s.getSelectionService().selectNode(i,n??!1),deselectNode:i=>s.getSelectionService().deselectNode(i),setQuickFilter:i=>s.setQuickFilter(i),isQuickFilterPresent:()=>s.getQuickFilter().length>0,resetQuickFilter:()=>s.setQuickFilter(""),getSortModel:()=>s.getSortService().getSortModel(),setSortModel:i=>s.getSortService().setSortModel(i),getFilterModel:()=>s.getFilterService().getFilterModel(),setFilterModel:i=>s.getFilterService().setFilterModel(i),getColumnFilterModel:i=>{const n=typeof i=="string"?i:i.colId;return s.getFilterService().getFilterInstance(n)??null},setColumnFilterModel:(i,n)=>s.getFilterService().setColumnFilterModel(i,n),getAdvancedFilterModel:()=>s.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:i=>s.getFilterService().setAdvancedFilterModel(i),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:(i,n)=>s.setRowNodePinned(i,n),getColumnDefs:()=>s.getColumnModel().getColumnDefs(),setColumnDefs:(i,n)=>{s.getColumnModel().setColumnDefs(i),s.onGridSizeChanged()},updateGridOptions:i=>s.updateGridOptions(i),setGridOption:(i,n)=>s.updateGridOptions({[i]:n}),sizeColumnsToFit:()=>{const i=s.getSideBarService().isVisible()?s.getSideBarService().getElement().offsetWidth:0;s.getColumnModel().sizeColumnsToFit(s.getGridDiv().clientWidth-i),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{s.getColumnModel().autoSizeAllColumns()},moveColumn:(i,n)=>s.getColumnModel().moveColumn(i,n),moveColumnByIndex:(i,n)=>s.getColumnModel().moveColumnByIndex(i,n),setColumnVisible:(i,n)=>s.getColumnApi().setColumnVisible(i,n),setColumnsPinned:(i,n)=>s.getColumnApi().setColumnsPinned(i,n),setColumnsVisible:(i,n)=>s.getColumnApi().setColumnsVisible(i,n),getAllColumns:()=>s.getAllColumns(),getColumns:()=>[...s.getColumns().left,...s.getColumns().center,...s.getColumns().right],getColumn:i=>s.getColumn(i)??null,getDisplayedLeftColumns:()=>s.getColumns().left,getDisplayedCenterColumns:()=>s.getColumns().center,getDisplayedRightColumns:()=>s.getColumns().right,getColumnState:()=>s.getColumnApi().getColumnState(),applyColumnState:(i,n)=>s.getColumnApi().applyColumnState(i,n),resetColumnState:()=>s.getColumnApi().resetColumnState(),openColumnMenu:i=>{const n=typeof i=="string"?s.getColumn(i):i;n!=null&&n.eHeaderCell&&s.getHeaderView().getHeaderCell(n)},setSideBarVisible:i=>{s.getSideBarService().setVisible(i),s.onGridSizeChanged()},isSideBarVisible:()=>s.getSideBarService().isVisible(),setSideBarPosition:i=>{s.getSideBarService().setPosition(i),s.onGridSizeChanged()},openToolPanel:i=>{s.getSideBarService().setVisible(!0),s.getSideBarService().openPanel(i),s.onGridSizeChanged()},closeToolPanel:()=>{s.getSideBarService().setVisible(!1),s.onGridSizeChanged()},getToolPanel:()=>s.getSideBarService().getActivePanel(),setStatusBarVisible:i=>s.getSideBarService()&&s.getOptions(),getSideBar:()=>s.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.isLastPageFound())??!0},paginationGetPageSize:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getPageSize())??0},paginationGetCurrentPage:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getCurrentPage())??0},paginationGetTotalPages:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getTotalPages())??1},paginationGetRowCount:()=>s.getDisplayedRowCount(),paginationGoToPage:i=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToPage(i)},paginationGoToNextPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToNextPage()},paginationGoToPreviousPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToPreviousPage()},paginationGoToFirstPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToFirstPage()},paginationGoToLastPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToLastPage()},paginationSetPageSize:i=>{var n;return(n=s.getPaginationService())==null?void 0:n.setPageSize(i)},startEditingCell:i=>s.getEditService().startEditingCell(i),stopEditing:i=>s.getEditService().stopEditing(i),getEditingCells:()=>s.getEditService().getEditingCells(),setFocusedCell:(i,n)=>{const o=typeof n=="string"?s.getColumn(n):n;o&&s.getEditService().setFocusedCell(i,o)},getFocusedCell:()=>{const i=s.getEditService().getFocusedCell();return i?{rowIndex:i.rowIndex,column:i.column,rowNode:i.rowNode}:null},clearFocusedCell:()=>s.getEditService().clearFocusedCell(),tabToNextCell:()=>s.getEditService().tabToNextCell(),tabToPreviousCell:()=>s.getEditService().tabToPreviousCell(),refreshCells:i=>s.getRowRenderer().refreshCells(i),redrawRows:i=>s.getRowRenderer().redrawRows(i),flashCells:i=>s.getRowRenderer().flashCells(i||{}),ensureIndexVisible:(i,n)=>s.getRowRenderer().ensureIndexVisible(i,n),ensureNodeVisible:i=>{let n=-1;s.getRowModel().forEachNode((o,a)=>{o.id===i.id&&(n=a)}),n>=0&&s.getRowRenderer().ensureIndexVisible(n)},ensureColumnVisible:i=>{const n=typeof i=="string"?s.getColumn(i):i;n&&s.getRowRenderer().ensureColumnVisible(n)},copyToClipboard:i=>s.getExportService().copyToClipboard(i),cutToClipboard:i=>s.getExportService().cutToClipboard(i),pasteFromClipboard:()=>s.getExportService().pasteFromClipboard(),exportToCsv:i=>s.getExportService().exportToCsv(i||{}),exportToExcel:i=>s.getExportService().exportToExcel(i||{}),exportToPdf:i=>s.getExportService().exportToPdf(i||{}),importExcel:(i,n)=>s.getExportService().importExcel(i,n||{}),getDataAsPdf:i=>s.getExportService().getDataAsPdf(i||{}),getDataAsCsv:i=>s.getExportService().getDataAsCsv(i||{}),getDataAsExcel:i=>s.getExportService().getDataAsExcel(i||{}),getChartData:i=>s.getChartService().getChartData(i||{}),getChartModels:()=>s.getChartService().getChartModels(),createChart:()=>s.getChartService().createChart(),getCellRanges:()=>s.getRangeSelectionService().getRanges(),clearRangeSelection:()=>s.getRangeSelectionService().clearRanges(),addCellRange:i=>{const n=s.getRangeSelectionService();n.ranges=[i],n.applyHighlight(),n.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>s.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>s.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>s.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>s.getOverlayService().hideOverlay(),setServerSideDatasource:i=>{const n=s.getServerSideRowModel();n&&n.setDatasource(i)},setDatasource:i=>{var o;const n=s.getInfiniteRowModel();n?n.setDatasource(i):(o=s.getServerSideRowModel())==null||o.setDatasource(i)},setViewportDatasource:i=>{var n;(n=s.getViewportRowModel())==null||n.setViewportDatasource(i)},setViewportRange:(i,n)=>{var o;(o=s.getViewportRowModel())==null||o.setViewportRange(i,n)},refreshServerSide:i=>{const n=s.getServerSideRowModel();n&&(i!=null&&i.purge?n.purgeCache():n.onSortOrFilterChanged())},purgeServerSideCache:()=>{var i,n;(i=s.getServerSideRowModel())==null||i.purgeCache(),(n=s.getInfiniteRowModel())==null||n.onSortOrFilterChanged()},getServerSideStoreState:()=>{const i=s.getServerSideRowModel();if(!i)return[];const n=[];for(const[o,a]of i.stores)n.push({groupPath:o,rowCount:a.rows.length,lastRow:a.lastRow,loading:a.loading});return n},setRowCount:(i,n)=>{const o=s.getServerSideRowModel();if(!o)return;const a=o.getStore("");if(a)for(a.lastRow=n?i:null;a.rows.length<i;)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:i=>s.getUndoRedoService().endBatchEdit(i),cancelBatchEdit:()=>s.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>s.getUndoRedoService().isBatchEditing(),getState:()=>{const i=s.getColumnApi(),n=s.getSelectionService(),o=s.getPaginationService();return{columns:i.getColumnState(),sort:s.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(s.getFilterService().getFilterModel())),quickFilter:s.getQuickFilter(),selectedRowIds:n.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:i=>{if(!i)return;const n=s.getColumnApi();if(i.columns&&n.applyColumnState(i.columns,!0),i.sort&&s.getSortService().setSortModel(i.sort),i.filter&&s.getFilterService().setFilterModel(i.filter),i.quickFilter!==void 0&&s.setQuickFilter(i.quickFilter),i.rowGroupColumns&&s.getColumnModel().setRowGroupColumns(i.rowGroupColumns),i.pivotMode!==void 0&&s.getColumnModel().setPivotMode(i.pivotMode),i.selectedRowIds){s.getSelectionService().deselectAll();for(const a of i.selectedRowIds){const r=s.getRowNode(a);r&&s.getSelectionService().selectNode(r,!1)}}const o=s.getPaginationService();o&&i.pagination&&(o.setPageSize(i.pagination.pageSize),o.goToPage(i.pagination.page))},setNote:(i,n,o)=>{const a=typeof n=="string"?n:n.colId;s.getNotesService().setNote(i.id,a,o)},getNote:(i,n)=>{const o=typeof n=="string"?n:n.colId,a=s.getColumn(o);return s.getNotesService().getNote(i.id,o,a==null?void 0:a.colDef.note,{data:i.data,node:i,column:a,api:s.getApi()})},getGridId:()=>"rowvia",destroy:()=>s.destroy(),refreshClientSideRowModel:()=>s.refreshModel("everything"),setPivotMode:i=>s.getColumnModel().setPivotMode(i),isPivotMode:()=>s.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>s.getAllColumns(),getColumn:i=>s.getColumn(i)??null,getColumnState:()=>s.getColumnModel().getColumnState(),applyColumnState:(i,n)=>{s.getColumnModel().applyColumnState(i,n),s.refreshModel("group")},resetColumnState:()=>{s.getColumnModel().resetColumnState(),s.refreshModel("group")},setColumnVisible:(i,n)=>s.getColumnModel().setColumnVisible(i,n),setColumnsVisible:(i,n)=>s.getColumnModel().setColumnsVisible(i,n),setColumnPinned:(i,n)=>s.getColumnModel().setColumnPinned(i,n),setColumnsPinned:(i,n)=>s.getColumnModel().setColumnsPinned(i,n),moveColumn:(i,n)=>s.getColumnModel().moveColumn(i,n),moveColumnByIndex:(i,n)=>s.getColumnModel().moveColumnByIndex(i,n),autoSizeColumn:i=>{s.getColumnModel().autoSizeColumn(i),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(i,n)=>s.getColumnModel().setRowGroupColumns(i,n),removeRowGroupColumns:i=>{for(const n of i)s.getColumnModel().removeRowGroupColumn(n)},addRowGroupColumn:i=>s.getColumnModel().addRowGroupColumn(i),setPivotColumns:i=>s.getColumnModel().setPivotColumns(i),removePivotColumns:i=>s.getColumnModel().setPivotColumns(i.map(()=>"").filter(n=>n!=="")),setValueColumns:i=>s.getColumnModel().setValueColumns(i),removeValueColumn:i=>s.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),getValueColumns:()=>s.getColumnModel().getValueColumns(),getPivotColumns:()=>s.getColumnModel().getPivotColumns(),setPivotMode:(i,n)=>s.getColumnModel().setPivotMode(i,n),isPivotMode:()=>s.getColumnModel().isPivotMode()}}}const hs={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 vt{constructor(e,t){v(this,"options");v(this,"eventService",new $e);v(this,"columnModel");v(this,"rowModel");v(this,"clientSideRowModel",null);v(this,"serverSideRowModel",null);v(this,"infiniteRowModel",null);v(this,"viewportRowModel",null);v(this,"rowRenderer");v(this,"headerView");v(this,"selectionService");v(this,"editService");v(this,"filterService");v(this,"sortService");v(this,"paginationService",null);v(this,"popupService");v(this,"filterGui");v(this,"contextMenuService");v(this,"columnMenuService");v(this,"statusBarService");v(this,"sideBarService");v(this,"findService");v(this,"rangeSelectionService");v(this,"chartService");v(this,"overlayService");v(this,"exportService");v(this,"rowGroupPanel",null);v(this,"undoRedoService");v(this,"formulaEditorService");v(this,"notesService");v(this,"rowDragService");v(this,"api");v(this,"columnApi");v(this,"localeText");v(this,"rowNodeServices");v(this,"eGridDiv");v(this,"eRoot");v(this,"eMain");v(this,"eHeader");v(this,"quickFilter","");v(this,"resizeObserver",null);v(this,"destroyed",!1);v(this,"gridReadyDispatched",!1);v(this,"context");v(this,"onWindowResize",()=>{this.onGridSizeChanged()});v(this,"onDocumentMouseDown",e=>{var i;const t=e.target;if(t&&this.eRoot.contains(t)){const n=(i=t.closest)==null?void 0:i.call(t,".ag-cell");if(!n){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!n.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var c,d,u,f;this.eGridDiv=e,this.options={...hs,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Zn(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const i=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(i),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),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:(g,p)=>this.selectionService.selectNode(g,p),deselectNode:g=>this.selectionService.deselectNode(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g)},this.columnModel=new Pi(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new Io(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),g=>this.isNodeSelectable(g)),this.filterService=new Do(this),this.sortService=new Ao(this),this.popupService=new Fo(this),this.filterGui=new Po(this,this.popupService),this.contextMenuService=new $o(this,this.popupService),this.columnMenuService=new Go(this,this.popupService),this.editService=new Lo(this,this.eventService),this.undoRedoService=new ls(this,this.eventService),this.formulaEditorService=new rs(this,this.popupService),this.notesService=new cs(this,this.popupService),this.rowDragService=new ds(this,this.eventService),this.chartService=new zo(this,this.popupService),this.findService=new Bo(this,this.popupService),this.exportService=new ss(this);const n={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 to(n),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new io(n),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new no(n),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new jn({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var g;return!!((g=this.paginationService)!=null&&g.isEnabled())},getPageSize:()=>{var g;return((g=this.paginationService)==null?void 0:g.getPageSize())??100},getCurrentPage:()=>{var g;return((g=this.paginationService)==null?void 0:g.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(d=(c=this.rowModel).setGridApi)==null||d.call(c,null)),this.headerView=new No(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(g=>g.sort)}),onSortRequested:(g,p,C)=>this.sortService.onSortRequested(g,p,C),onColumnResized:(g,p,C)=>this.onColumnResized(g,p,C),onColumnMoved:(g,p)=>this.onColumnMoved(g,p),onColumnMenuClicked:(g,p)=>this.columnMenuService.openColumnMenu(g,p),onFilterOpened:(g,p)=>this.filterGui.openFilter(g,p),isFilterActive:g=>this.filterService.isFilterActive(g),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(g,p)=>this.filterService.handleFloatingFilterChange(g,p),onHeaderCheckboxChanged:(g,p)=>this.onHeaderCheckboxChanged(g,p),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:g=>this.t(g),getApi:()=>this.api,getFilterModel:g=>this.filterService.getFilterInstance(g)??null,onFilterModelChange:(g,p)=>this.filterService.setColumnFilterModel(g,p)}),this.rowRenderer=new To(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:g=>this.t(g),getColumns:()=>this.getColumns(),getRowHeight:g=>this.getRowHeight(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g),isRowSelectable:g=>this.isNodeSelectable(g),getRowClass:g=>this.getRowClass(g),getRowStyle:g=>this.getRowStyle(g),onCellClicked:g=>this.onCellClicked(g),onCellDoubleClicked:g=>this.editService.onCellDoubleClicked(g),onCellMouseDown:g=>this.onCellMouseDown(g),onCellContextMenu:g=>this.onCellContextMenu(g),onRowClicked:g=>this.onRowClicked(g),onRowDoubleClicked:g=>this.onRowDoubleClicked(g),onRowGroupClicked:g=>this.onRowGroupClicked(g),onViewportKeyDown:g=>this.onViewportKeyDown(g),onViewportScroll:()=>{var C,h,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const g=this.rowRenderer.getFirstVisibleRowIndex(),p=this.rowRenderer.getLastVisibleRowIndex();(C=this.serverSideRowModel)==null||C.onViewportChanged(g,p),(h=this.infiniteRowModel)==null||h.onViewportChanged(g,p),(m=this.viewportRowModel)==null||m.onViewportChanged(g,p)},getCellText:(g,p)=>{const C=de(g,p,this.api);return C==null?"":String(C)},renderDetailRow:g=>this.renderDetailRow(g),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(g,p,C)=>this.rowDragService.startDrag(g,C),getNote:(g,p,C,h)=>this.notesService.getNote(g,p,C,h),onNoteClick:(g,p,C)=>this.notesService.openNoteEditor(g,p,C),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new Vo(this,this.eventService),this.statusBarService=new Ho(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Wo(this),this.sideBarService=new Oo(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 Wi(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new as(this));const{api:a,columnApi:r}=us(this);this.api=a,this.columnApi=r,this.columnModel.setGridApi(this.api),(f=(u=this.rowModel).setGridApi)==null||f.call(u,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=g=>this.filterService.doesNodePassAdvancedFilter(g),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 g,p;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(p=(g=this.options).onSelectionChanged)==null||p.call(g,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let l=this.options.columnDefs||[];(!l||l.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(l=Pi.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(l),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 i=this.localeText.t(e);return i===e?t:i}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 i,n;const e=new Map,t=this.getAllColumns().filter(o=>o.colDef.showValueAs);if(t.length>0){const o=new Map;(n=(i=this.rowModel).forEachLeafNode)==null||n.call(i,a=>{for(const r of t){const l=de(r,a,this.api);typeof l=="number"&&!isNaN(l)&&o.set(r.colId,(o.get(r.colId)??0)+l)}});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,i;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(t=this.infiniteRowModel)!=null&&t.isLoading()||(i=this.viewportRowModel)!=null&&i.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 i=t({data:e.data,node:e,api:this.api});if(i)return i}return this.options.rowHeight??42}getRowClass(e){const t=[];if(this.options.rowClass&&t.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const i=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof i=="string"?t.push(i):Array.isArray(i)&&t.push(...i)}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 i,n,o;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),t||(this.overlayService.updateAuto(),this.statusBarService.update(),(i=this.paginationService)==null||i.update(),this.chartService.refreshCharts(),(o=(n=this.options).onRowDataChanged)==null||o.call(n,{api:this.api}))}applyTransaction(e){var i;const t=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(i=this.paginationService)==null||i.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),t}setCellValue(e,t,i,n="api",o){const a=o!==void 0?o:de(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:de(e,t,this.api),newValue:i,data:t.data,node:t,column:e,api:this.api,colDef:e.colDef})===!1)return}else t.setDataValue(e.colId,i);e.rowGroup&&this.rowModel.refreshModel("group"),(n==="edit"||n==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:a,newValue:i,batchId:0}),n!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:i,value:i,data:t.data,node:t,column:e,colDef:e.colDef,api:this.api,source:n})}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,r,l,c;const{node:t,column:i,event:n}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(r=(a=this.options).onCellClicked)==null||r.call(a,{...e,api:this.api,colDef:i.colDef,value:de(i,t,this.api)});return}if(n.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,n),this.editService.onCellClicked(e),(c=(l=this.options).onCellClicked)==null||c.call(l,{...e,api:this.api,colDef:i.colDef,value:de(i,t,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var t,i;this.selectionService.handleRowClick(e.node,e.event),(i=(t=this.options).onRowClicked)==null||i.call(t,{...e,api:this.api})}onRowDoubleClicked(e){var t,i;(i=(t=this.options).onRowDoubleClicked)==null||i.call(t,{...e,api:this.api})}onCellContextMenu(e){var i,n;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(n=(i=this.options).onCellContextMenu)==null||n.call(i,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,i,n,o,a;if(e.group){const r=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);r&&r(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}),(n=(i=this.options).onRowGroupOpened)==null||n.call(i,{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 i;if(e.headerCheckboxSelectionCurrentPageOnly&&((i=this.paginationService)!=null&&i.isEnabled())){const n=this.rowModel.getRowCount();if(t)for(let o=0;o<n;o++){const a=this.rowModel.getRow(o);a&&this.isNodeSelectable(a)&&this.selectionService.selectNode(a,!1)}else for(let o=0;o<n;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 i=t.querySelector(".ag-header-select-all");if(!i)continue;const n=this.selectionService.getSelectAllState();i.checked=n.checked,i.indeterminate=n.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,i){e.width=t,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),i&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,t){const i=this.columnModel.getColumns(),n=i.findIndex(a=>a.colId===e);if(n<0)return;let o=i.length;t&&(o=i.findIndex(a=>a.colId===t)),this.columnModel.moveColumnByIndex(n,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,i,n,o,a,r;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}),(i=(t=this.options).onFirstDataRendered)==null||i.call(t,{api:this.api})),(o=(n=this.options).onModelUpdated)==null||o.call(n,{api:this.api}),(r=(a=this.options).onRowDataChanged)==null||r.call(a,{api:this.api})}onGridSizeChanged(){var o,a,r;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(l=>l.flex!==null&&l.flex>0&&l.visible),i=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,n=Math.max(0,e-i);(t||((o=this.options.autoSizeStrategy)==null?void 0:o.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(n),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}),(r=(a=this.options).onGridSizeChanged)==null||r.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var c,d;const t=e.masterNode;if(!t)return null;const i=this.options.detailRowAutoHeight===!0,n=i?this.options.detailRowHeight??200:this.options.detailRowHeight??200,o=document.createElement("div");o.className="ag-row-detail",o.style.height=`${n}px`,o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0";const a=this.options.detailCellRenderer,r=(c=this.options.detailCellRendererParams)==null?void 0:c.detailGridOptions,l=(d=this.options.detailCellRendererParams)==null?void 0:d.getDetailRowData;if(r&&l){const u=l({data:t.data,node:t,api:this.api}),f=document.createElement("div");f.style.height="100%",f.style.padding="8px 16px",o.appendChild(f),setTimeout(()=>{new vt(f,{...r,rowData:u,theme:this.options.theme})},0)}else if(typeof a=="function"){const u=a({data:t.data,node:t,api:this.api,context:this.context});u instanceof HTMLElement?o.appendChild(u):o.textContent=String(u??"")}else typeof a=="string"&&(o.textContent=a);if(i){const u=Math.max(40,o.scrollHeight||n);return e.rowHeight=u,o.style.height=`${u}px`,{eDetail:o,height:u}}return e.rowHeight=n,{eDetail:o,height:n}}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,i=e.rowData!==void 0&&e.rowData!==this.options.rowData,n=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),i&&this.setRowData(e.rowData),n&&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 Wi(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,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 Xi(s){const e=document.createElement("dialog");e.className="rowvia-detail-dialog";const t=document.createElement("h2"),i=document.createElement("dl"),n=document.createElement("button");n.type="button",n.textContent="关闭";const o=()=>e.close();return n.addEventListener("click",o),e.append(t,i,n),s.append(e),{open(a){t.textContent=a.title,e.setAttribute("aria-label",a.title),i.replaceChildren();for(const r of a.fields){const l=document.createElement("dt"),c=document.createElement("dd");l.textContent=r.label,c.textContent=r.value,i.append(l,c)}e.open||e.showModal()},close:o,destroy(){e.open&&e.close(),n.removeEventListener("click",o),e.remove()}}}const Yi=864e5;function Qe(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),i=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${i}`}function Pe(s){return new Date(`${s}T00:00:00`)}function De(s,e){return new Date(s.getTime()+e*Yi)}function je(s,e){const t=typeof s=="string"?Pe(s):s,i=typeof e=="string"?Pe(e):e;return Math.round((i.getTime()-t.getTime())/Yi)}function It(){return Qe(new Date)}function ps(s){return s.status!=="done"&&s.end&&s.end<It()&&s.progress<100?"delayed":s.status}function ri(s){const e=Pe(s);return`${e.getMonth()+1}月${e.getDate()}日`}const Qi=["day","week","biweek","month","bimonth","quarter","halfyear","year"],Ut={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},gs={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2},Ee={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)"},_t={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},fs=4,Ji=6,He=28;function ci(s){const e=(s.getDay()+6)%7;return De(s,-e)}function ms(s,e){const t=Math.max(1,je(s,e)+1);let i=0;for(let n=0;n<t;n++){const o=De(s,n).getDay();o!==0&&o!==6&&i++}return Math.max(1,i)}function vs(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function Zi(s,e,t){const i=[];if(s==="day"){let l=new Date(e);for(;l<t;){const c=De(l,1);i.push({start:new Date(l),end:c,primary:`${l.getDate()}`,secondary:""}),l=c}return i}if(s==="week"||s==="biweek"){let l=ci(e);for(;l<t;){const c=De(l,s==="biweek"?14:7);i.push({start:new Date(l),end:c,primary:`${l.getMonth()+1}/${l.getDate()}`,secondary:""}),l=c}return i}const n=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=l=>new Date(l.getFullYear(),Math.floor(l.getMonth()/n)*n,1),a=l=>s==="month"||s==="bimonth"?`${l.getMonth()+1}月`:s==="halfyear"?`${l.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(l.getMonth()/3)+1}`:`${l.getFullYear()}`;let r=o(e);for(;r<t;){const l=vs(r,n);i.push({start:new Date(r),end:l,primary:a(r),secondary:""}),r=l}return i}class en{constructor(e,t){v(this,"options");v(this,"eRoot");v(this,"eHeader");v(this,"eRuler");v(this,"rulerCtx");v(this,"eRulerTools");v(this,"eStepLabel");v(this,"eZoomValue");v(this,"eStepMenu",null);v(this,"eScroll");v(this,"eSpacer");v(this,"eCanvas");v(this,"ctx");v(this,"eTooltip");v(this,"eTodayBadge");v(this,"ePopup",null);v(this,"tasks",[]);v(this,"tasksById",new Map);v(this,"rows",[]);v(this,"selectedId",null);v(this,"hoverId",null);v(this,"unit","day");v(this,"zoom",1);v(this,"theme","content");v(this,"epochStart",new Date);v(this,"totalDays",1);v(this,"hits",[]);v(this,"hitsByRow",new Map);v(this,"drag",null);v(this,"ghost",null);v(this,"dirty",!0);v(this,"lastLeft",-1);v(this,"lastTop",-1);v(this,"timer");v(this,"observer",null);v(this,"resizeHandler",()=>this.resizeCanvases());v(this,"showChildren",!0);v(this,"milestonesOnly",!1);v(this,"locateHits",[]);v(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)});v(this,"onScroll",()=>{this.tick()});v(this,"todayLabelX",-1);v(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:i,onAvatar:n}=this.hitAt(e.clientX,e.clientY),o=this.rows[i];n?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())});v(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),i=this.locateHits.find(c=>Math.abs(c.x-(e.clientX-t.left))<12&&Math.abs(c.y-(e.clientY-t.top))<12);if(i){this.scrollToTask(i.id);return}const{hit:n,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),r=this.rows[o];if(n){const c=this.tasksById.get(n.id);if(!c)return;if(a){e.stopPropagation(),this.openAssigneePopup(n.id,n);return}if(c.kind!=="task"||c.milestone||!c.start||!c.end){this.options.onSelect(n.id);return}e.preventDefault(),this.drag={id:n.id,mode:n.mode,startX:e.clientX,startY:e.clientY,originStart:c.start,originEnd:c.end,start:c.start,end:c.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(n.id);return}if(!r)return;const l=this.tasksById.get(r.id);if(l){if(l.kind==="task"&&(!l.start||!l.end)){const c=this.pointAt(e.clientX,e.clientY),d=Math.floor(c.x/this.dayWidth),u=Qe(De(this.epochStart,d));this.options.onTaskChange({...l,start:u,end:Qe(De(Pe(u),4)),progress:0,status:"not-started"}),this.options.onSelect(r.id);return}this.options.onSelect(r.id)}});v(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const i=this.tasksById.get(t.id);if(!i||!t.moved&&Math.abs(e.clientX-t.startX)<fs)return;t.moved=!0;const n=this.dayWidth,o=Math.round((e.clientX-t.startX)/n),a=Pe(t.originStart),r=Pe(t.originEnd),l=je(a,r);let c,d;t.mode==="resize-l"?(c=De(a,Math.min(o,l)),d=r):t.mode==="resize-r"?(c=a,d=De(r,Math.max(o,-l))):(c=De(a,o),d=De(r,o)),i.milestone&&(c=d),t.start=Qe(c),t.end=Qe(d),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?ri(t.start):`${ri(t.start)} → ${ri(t.end)}`;const u=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-u.left+12}px`,this.eTooltip.style.top=`${e.clientY-u.top+16}px`});v(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})});v(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});v(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.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 i=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(i),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;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.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){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 gs[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(It()),i=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=i}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 i=It();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const n=ci(De(Pe(e),-7));this.epochStart=n,this.totalDays=Math.max(je(n,Pe(t))+730,1095)}dateX(e){return je(this.epochStart,e)*this.dayWidth}xToDate(e){return Qe(De(this.epochStart,Math.round(e/this.dayWidth)))}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[t,i]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const n=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(n*e)),t.height=Math.max(1,Math.round(o*e)),t.style.width=`${n}px`,t.style.height=`${o}px`,i.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,i=this.totalDays*e,n=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${i}px`,this.eSpacer.style.height=`${n}px`,this.drawRuler(e,i),this.drawBody(e,i,n,t)}drawRuler(e,t){const i=this.rulerCtx,n=this.eHeader.clientWidth,o=this.eHeader.clientHeight,a=this.eScroll.scrollLeft;i.clearRect(0,0,n,o),i.fillStyle="#fff",i.fillRect(0,0,n,o);const r=De(this.epochStart,this.totalDays),l=(u,f,g,p)=>{for(const C of u){const h=this.dateX(Qe(C.start))-a,m=je(C.start,C.end)*e;if(h+m<=0||h>=n)continue;const y=Math.max(0,Math.min(h+m,n)-Math.max(0,h));if(this.unit==="day"||this.unit==="week"){const S=C.start.getDay();(S===0||S===6)&&(i.fillStyle=Ee.weekend,i.fillRect(Math.max(0,h),f,y,g))}const E=i.measureText(C.primary).width;if(E+8<y){const S=Math.max(0,h)+y/2-E/2,A=f+g/2+5;i.fillStyle=Ee.text,i.font="11px "+Je,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(C.primary,S,A),C.secondary&&(i.fillStyle=Ee.textTertiary,i.font="10px "+Je,i.fillText(C.secondary,S,A+12))}}},c=40,d=De(this.epochStart,Math.floor(a/e));i.fillStyle=Ee.text,i.font="14px "+Je,i.textAlign="left",i.textBaseline="middle",i.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${d.getFullYear()}年${d.getMonth()+1}月`:`${d.getFullYear()} 年`,16,22),l(Zi(this.unit,this.epochStart,r),c+1,o-c-1),i.strokeStyle=Ee.border,i.beginPath(),i.moveTo(0,o-.5),i.lineTo(n,o-.5),i.stroke()}drawBody(e,t,i,n){const o=this.ctx,a=this.eScroll.clientWidth,r=this.eScroll.clientHeight,l=this.eScroll.scrollLeft,c=this.eScroll.scrollTop;o.clearRect(0,0,a,r),o.fillStyle="#fff",o.fillRect(0,0,a,r),o.save(),o.translate(-l,-c),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,c+r)),this.drawGridlines(e,t,Math.max(i,c+r)),this.drawRowBackgrounds(t,n);const d=this.rows.findIndex(f=>f.id===this.hoverId),u=this.hoverId?this.tasksById.get(this.hoverId):null;if(d>=0&&(u==null?void 0:u.kind)==="task"&&!u.start){const f=d*n+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,Ct(o,l+4,f,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Ee.textTertiary,o.font="14px "+Je,o.textAlign="center",o.fillText("新建排期",l+a/2,f+19)}this.drawDependencies(n),this.drawBars(n),this.drawTodayLine(t,Math.max(i,c+r)),o.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,i){if(this.unit!=="day"&&this.unit!=="week")return;const n=this.ctx;n.fillStyle=Ee.weekend;let o=ci(this.epochStart);for(;je(this.epochStart,o)<this.totalDays;){const a=this.dateX(Qe(o))+5*e;a<t&&n.fillRect(Math.max(0,a),0,e*2,i),o=De(o,7)}}drawGridlines(e,t,i){const n=this.ctx,o=De(this.epochStart,this.totalDays);for(const a of Zi(this.unit,this.epochStart,o)){const r=Math.round(this.dateX(Qe(a.start)))+.5;if(r<0||r>t)continue;const l=this.unit==="day"&&a.start.getDate()===1;n.strokeStyle=l?Ee.gridlineMonth:Ee.gridline,n.beginPath(),n.moveTo(r,0),n.lineTo(r,i),n.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=Ee.rowLine,i.lineWidth=1,i.beginPath();for(let n=1;n<this.rows.length;n++){const o=Math.round(n*t)+.5;i.moveTo(0,o),i.lineTo(e,o)}i.stroke(),this.rows.forEach((n,o)=>{const a=this.selectedId===n.id,r=this.hoverId===n.id;(a||r)&&(i.fillStyle=a?Ee.selected:r?Ee.hover:Ee.groupRow,i.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,n=Math.round(this.dateX(It())+this.dayWidth/2)+.5;n<0||n>e||(i.strokeStyle=Ee.accent,i.lineWidth=1.5,i.beginPath(),i.moveTo(n,0),i.lineTo(n,t),i.stroke(),this.todayLabelX=n-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=It().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((n,o)=>[n.id,o])),i=this.ctx;i.strokeStyle=Ee.accent,i.lineWidth=1.2;for(const n of this.rows){const o=this.tasksById.get(n.id);if(!o||o.kind!=="task"||!o.start||!o.end)continue;const a=t.get(n.id);if(a!==void 0)for(const r of o.dependsOn){const l=this.tasksById.get(r),c=t.get(r);if(!(l!=null&&l.start)||!l.end||c===void 0)continue;const d=this.dateX(l.start),u=l.milestone?this.dayWidth:Math.max(je(Pe(l.start),Pe(l.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),f=d+u,g=c*e+e/2,p=this.dateX(o.start),C=Math.max(je(Pe(o.start),Pe(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),h=a*e+e/2,m=f+10;if(p-4>m)tn(i,f,g,m,h,p-5,h);else{const y=p+C+10;tn(i,f,g,m,h,y,h)}ws(i,p-5,h)}}}drawBars(e){this.rows.forEach((t,i)=>{const n=this.tasksById.get(t.id);if(!n||!n.start||n.path.length>1&&(!this.showChildren||this.milestonesOnly&&!n.milestone))return;const o=i*e+(e-He)/2;if(t.group){this.drawSummaryBar(n,i,o);return}if(n.milestone){this.drawMilestone(n,i,o);return}n.end&&this.drawTaskBar(n,i,o)})}drawTaskBar(e,t,i){var g;const n=this.ctx,o=((g=this.ghost)==null?void 0:g.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,r=(o==null?void 0:o.end)??e.end,l=this.dateX(a),c=Math.max(28,(je(a,r)+1)*this.dayWidth),d=_t[e.status];n.save(),n.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,n.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",n.strokeStyle=this.selectedId===e.id?Ee.accent:"#dee0e3",n.lineWidth=1,Ct(n,l,i,c,He,4),n.fill(),n.stroke(),n.save(),Ct(n,l,i,c,He,4),n.clip(),n.beginPath(),n.arc(l+14,i+14,6,0,Math.PI*2),n.fillStyle=d,n.fill(),n.font="12px "+Je,n.textBaseline="middle",n.textAlign="left",n.fillStyle=Ee.text;const u=this.options.members.find(p=>p.id===e.owner),f=n.measureText(e.name).width;c>f+58?(n.fillText(e.name,l+26,i+14),u&&di(n,l+f+42,i+14,7,qt(u.id),u.name.slice(0,1))):u&&c>46&&di(n,l+38,i+14,7,qt(u.id),u.name.slice(0,1)),c>100&&(n.fillStyle=Ee.textTertiary,n.textAlign="right",n.fillText(String(ms(Pe(a),Pe(r))),l+c-8,i+14)),n.restore(),n.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:l,y:i,w:c,h:He,mode:"move",avatar:u?{x:l+(c>f+58?f+42:38),y:i+14,r:7}:void 0})}drawSummaryBar(e,t,i){if(!e.start||!e.end)return;const n=this.tasks.filter(d=>d.path.length===e.path.length+1&&d.path.slice(0,-1).join("/")===e.path.join("/")&&d.start),o=n[0],a=this.ctx,r=this.dateX(e.start),l=Math.max(92,(je(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?Ee.accent:"#dee0e3",a.lineWidth=1,Ct(a,r,i,l,He,4),a.fill(),a.stroke(),a.fillStyle=o?_t[o.status]:_t[e.status],a.beginPath(),a.arc(r+14,i+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Ee.text,a.font="11px "+Je,a.textAlign="left",a.textBaseline="middle";const c=((o==null?void 0:o.name)??e.name)+(n.length>1?` +${n.length-1}`:"");a.fillText(Cs(a,c,l-32),r+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:r,y:i,w:l,h:He,mode:"move"})}firstVisibleChildIndex(e,t){var n;const i=`${e.path.join("/")}/`;for(let o=t+1;o<this.rows.length;o++){const a=this.tasksById.get(((n=this.rows[o])==null?void 0:n.id)??"");if(a)return a.path.join("/").startsWith(i)?o:-1}return-1}drawMilestone(e,t,i){var h;const n=this.ctx,o=this.dayWidth,a=((h=this.ghost)==null?void 0:h.id)===e.id?this.ghost:null,r=a?a.start:e.start,l=ps(e),c=_t[l],d=this.dateX(r)+o/2;n.font="12px "+Je;const u=n.measureText(e.name).width,f=e.owner?24:0,g=19+u+f+14,p=d-g/2;n.fillStyle="#fff",n.strokeStyle=c,n.lineWidth=1.5,Ct(n,p,i,g,He,4),n.fill(),n.stroke(),n.fillStyle=c,n.beginPath(),n.arc(p+7+3,i+He/2,3,0,Math.PI*2),n.fill(),n.fillStyle=Ee.text,n.textAlign="left",n.textBaseline="middle",n.fillText(e.name,p+14+5,i+He/2+1);let C;if(e.owner){const m=this.options.members.find(y=>y.id===e.owner);m&&(di(n,p+g-12,i+He/2,9,qt(m.id),m.name.slice(0,1)),C={x:p+g-12,y:i+He/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:p,y:i,w:g,h:He,mode:"move",avatar:C})}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,i=this.eScroll.clientWidth;this.rows.forEach((n,o)=>{const a=this.tasksById.get(n.id);if(!(a!=null&&a.start)||!a.end||a.path.length>1&&(!this.showChildren||this.milestonesOnly&&!a.milestone))return;const r=this.dateX(a.start),l=this.dateX(a.end)+this.dayWidth;if(l>=t&&r<=t+i)return;const c=l<t?10:i-18,d=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;d<0||d>this.eScroll.clientHeight||(e.fillStyle="#8f959e",Ct(e,c-5,d-6,13,13,3),e.fill(),e.font="12px "+Je,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(l<t?"‹":"›",c+1,d),this.locateHits.push({id:a.id,x:c+1,y:d}))})}pointAt(e,t){const i=this.eScroll.getBoundingClientRect();return{x:e-i.left+this.eScroll.scrollLeft,y:t-i.top+this.eScroll.scrollTop}}hitAt(e,t){const i=this.pointAt(e,t),n=Math.floor(i.y/this.options.rowHeight),o=this.hitsByRow.get(n)??[];for(const a of o){if(a.avatar){const r=i.x-a.avatar.x,l=i.y-a.avatar.y;if(r*r+l*l<=a.avatar.r*a.avatar.r)return{hit:a,rowIndex:n,onAvatar:!0}}if(i.x>=a.x&&i.x<=a.x+a.w&&i.y>=a.y&&i.y<=a.y+a.h){const r=a.kind==="task"&&i.x<=a.x+Ji,l=a.kind==="task"&&i.x>=a.x+a.w-Ji;return{hit:{...a,mode:r?"resize-l":l?"resize-r":"move"},rowIndex:n,onAvatar:!1}}}return{hit:null,rowIndex:n,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=Ut[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 i=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 n=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(i,n),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,i){const n=document.createElement("button");return n.type="button",n.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(n.className="gt-ruler-btn gt-ruler-today"),n.textContent=e,n.title=t,n.addEventListener("click",o=>{o.stopPropagation(),i()}),n}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const t=this.totalDays*this.dayWidth-this.eScroll.clientWidth,i=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(t,i))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const n of Qi){const o=document.createElement("div");o.className="gt-step-item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(n===this.unit)),o.tabIndex=0,o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.setUnit(n),this.closeStepMenu())}),n===this.unit&&o.classList.add("gt-step-item-active"),o.textContent=Ut[n],o.addEventListener("click",a=>{a.stopPropagation(),this.setUnit(n),this.closeStepMenu()}),e.appendChild(o)}const t=this.eRulerTools.getBoundingClientRect(),i=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,i.right-t.right)}px`,e.style.top=`${t.bottom-i.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=Ut[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,t){this.closeAssigneePopup();const i=this.tasksById.get(e);if(!i)return;const n=document.createElement("div");n.className="gt-popup";const o=document.createElement("div");o.className="gt-popup-title",o.textContent="更换负责人",n.appendChild(o);for(const c of this.options.members){const d=document.createElement("div");d.className="gt-popup-item",i.owner===c.id&&d.classList.add("gt-popup-item-active");const u=document.createElement("span");u.className="gt-avatar",u.textContent=c.name.slice(0,1),u.style.backgroundColor=qt(c.id);const f=document.createElement("span");f.textContent=c.name,d.append(u,f),d.addEventListener("click",g=>{g.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,c.id)}),n.appendChild(d)}if(i.owner){const c=document.createElement("div");c.className="gt-popup-item gt-popup-clear",c.textContent="取消负责人",c.addEventListener("click",d=>{d.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),n.appendChild(c)}const a=this.eRoot.getBoundingClientRect(),r=t.x+t.w-this.eScroll.scrollLeft,l=t.y-this.eScroll.scrollTop;n.style.left=`${Math.min(a.width-150,Math.max(0,r-40))}px`,n.style.top=`${l+t.h+6}px`,this.eRoot.appendChild(n),this.ePopup=n,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const Je="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function Ct(s,e,t,i,n,o){const a=Math.max(0,i),r=Math.max(0,n);if(a===0||r===0)return;const l=Math.max(0,Math.min(o,a/2,r/2));s.beginPath(),s.moveTo(e+l,t),s.lineTo(e+a-l,t),s.arcTo(e+a,t,e+a,t+l,l),s.lineTo(e+a,t+r-l),s.arcTo(e+a,t+r,e+a-l,t+r,l),s.lineTo(e+l,t+r),s.arcTo(e,t+r,e,t+r-l,l),s.lineTo(e,t+l),s.arcTo(e,t,e+l,t,l),s.closePath()}function di(s,e,t,i,n,o){s.beginPath(),s.arc(e,t,i,0,Math.PI*2),s.fillStyle=n,s.fill(),s.lineWidth=1.5,s.strokeStyle="#fff",s.stroke(),s.fillStyle="#fff",s.font=`10px ${Je}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function Cs(s,e,t){if(t<=0)return"";if(s.measureText(e).width<=t)return e;let i=e.length;for(;i>1;){i--;const n=`${e.slice(0,i)}…`;if(s.measureText(n).width<=t)return n}return"…"}function tn(s,e,t,i,n,o,a){const l=n>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(i-5,t),s.quadraticCurveTo(i,t,i,t+5*l),s.lineTo(i,n-5*l),s.quadraticCurveTo(i,n,i+5*l,n),s.lineTo(o,a),s.stroke()}function ws(s,e,t){s.fillStyle=Ee.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 nn=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function qt(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return nn[e%nn.length]}const ys=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],bs=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Ss=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Ae(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function wt(s,e,t){const i=document.createElement("button");return i.type="button",i.className=e,i.textContent=s,i.addEventListener("click",n=>{n.stopPropagation(),t()}),i}class xs{constructor(e,t,i,n){v(this,"filterFields");v(this,"sortFields");v(this,"filterRows",[]);v(this,"sorts",[]);v(this,"filterPanel",null);v(this,"sortPanel",null);v(this,"filterAnchor",null);v(this,"sortAnchor",null);v(this,"onDocumentMouseDown",e=>{var i,n;const t=e.target;this.filterPanel&&!this.filterPanel.contains(t)&&!((i=this.filterAnchor)!=null&&i.contains(t))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(t)&&!((n=this.sortAnchor)!=null&&n.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=n,this.filterFields=i.filter,this.sortFields=i.sort,document.addEventListener("mousedown",this.onDocumentMouseDown,!0)}openFilterPanel(e){if(this.filterPanel){this.closeFilterPanel();return}this.closeSortPanel();const t=Ae("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",c=>c.stopPropagation());const i=Ae("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const n=Ae("div","gt-filter-rows");t.appendChild(n);const o=()=>{if(n.textContent="",!this.filterRows.length){const c=Ae("div","gt-panel-empty");c.textContent="点击下方字段添加筛选条件",n.appendChild(c)}for(const c of this.filterRows)n.appendChild(this.renderFilterRow(c,o))},a=Ae("div","gt-filter-add");for(const c of this.filterFields)a.appendChild(wt(c.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:c.colId,kind:c.kind,type:c.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const r=Ae("div","gt-panel-hint");r.textContent="多个条件同时满足(且)",t.appendChild(r);const l=Ae("div","gt-panel-actions");l.append(wt("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),wt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(l),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const i=Ae("div","gt-filter-row"),n=this.filterFields.find(c=>c.colId===e.colId),o=document.createElement("select");o.className="gt-panel-select";for(const c of this.filterFields){const d=document.createElement("option");d.value=c.colId,d.textContent=c.label,c.colId===e.colId&&(d.selected=!0),o.appendChild(d)}o.addEventListener("change",()=>{const c=this.filterFields.find(d=>d.colId===o.value);c&&(e.colId=c.colId,e.kind=c.kind,e.type=c.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),i.appendChild(o);const a=e.kind==="number"?bs:e.kind==="date"?Ss:ys,r=document.createElement("select");r.className="gt-panel-select gt-panel-select-cond";for(const c of a){const d=document.createElement("option");d.value=c.value,d.textContent=c.label,c.value===e.type&&(d.selected=!0),r.appendChild(d)}if(r.addEventListener("change",()=>{e.type=r.value,t()}),i.appendChild(r),e.type!=="blank")if(n!=null&&n.options){const c=document.createElement("select");c.className="gt-panel-select";const d=document.createElement("option");d.value="",d.textContent="请选择",c.appendChild(d);for(const u of n.options){const f=document.createElement("option");f.value=u.value,f.textContent=u.label,u.value===e.value&&(f.selected=!0),c.appendChild(f)}c.addEventListener("change",()=>{e.value=c.value}),i.appendChild(c)}else if(e.kind==="date"){const c=document.createElement("input");if(c.type="date",c.className="gt-panel-input",c.value=e.value,c.addEventListener("change",()=>{e.value=c.value}),i.appendChild(c),e.type==="inRange"){const d=document.createElement("input");d.type="date",d.className="gt-panel-input",d.value=e.valueTo,d.addEventListener("change",()=>{e.valueTo=d.value}),i.appendChild(d)}}else if(e.kind==="number"){const c=document.createElement("input");if(c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="数值",c.value=e.value,c.addEventListener("input",()=>{e.value=c.value}),i.appendChild(c),e.type==="inRange"){const d=document.createElement("input");d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="至",d.value=e.valueTo,d.addEventListener("input",()=>{e.valueTo=d.value}),i.appendChild(d)}}else{const c=document.createElement("input");c.type="text",c.className="gt-panel-input",c.placeholder="文本",c.value=e.value,c.addEventListener("input",()=>{e.value=c.value}),i.appendChild(c)}const l=wt("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(c=>c!==e),t()});return l.title="移除条件",i.appendChild(l),i}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 i=(t.type==="after",t.value),n=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:i||void 0,dateTo:n||void 0};continue}if(t.value)if(t.kind==="number"){const i={filterType:"number",type:t.type,filter:Number(t.value)};t.type==="inRange"&&(i.filterTo=Number(t.valueTo||t.value)),e[t.colId]=i}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=Ae("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",r=>r.stopPropagation());const i=Ae("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const n=Ae("div","gt-sort-list");t.appendChild(n);const o=()=>{var r;n.textContent="";for(const l of this.sortFields){const c=this.sorts.findIndex(g=>g.colId===l.colId),d=c>=0,u=Ae("div","gt-sort-item");d&&u.classList.add("gt-sort-item-active");const f=Ae("span","gt-sort-label");if(f.textContent=l.label,u.appendChild(f),d){const g=Ae("span","gt-sort-badge");g.textContent=String(c+1),u.appendChild(g);const p=Ae("span","gt-sort-dir");p.textContent=((r=this.sorts[c])==null?void 0:r.sort)==="asc"?"↑ 升序":"↓ 降序",u.appendChild(p)}u.addEventListener("click",()=>{var g;d?((g=this.sorts[c])==null?void 0:g.sort)==="asc"?this.sorts[c]={colId:l.colId,sort:"desc"}:this.sorts=this.sorts.filter(p=>p.colId!==l.colId):this.sorts.push({colId:l.colId,sort:"asc"}),o()}),n.appendChild(u)}},a=Ae("div","gt-panel-actions");a.append(wt("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),wt("应用","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 i=t.getBoundingClientRect();e.style.top=`${i.bottom+6}px`;const n=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(i.left,n))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const Es={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 Rs(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),i=this.getExportRows(e),n=[];e.skipHeader||n.push(t.map(o=>({value:o.headerName||o.field||o.colId,bold:!0})));for(const o of i)n.push(t.map(a=>{let r=ue(a,o,this.grid.getApi());return o.footer&&o.groupData&&o.groupData[a.colId]!==void 0&&(r=o.groupData[a.colId]),o.group&&o.groupData&&o.groupData[a.colId]!==void 0&&(r=o.groupData[a.colId]),r instanceof Date&&(r=r.toISOString().slice(0,10)),{value:r}}));return Xo([{name:e.sheetName||"Sheet1",rows:n}])}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 w;const t=this.getExportColumns(e),i=this.getExportRows(e),n=t.map(h=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(h.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(h=>({text:e.processHeaderCallback?e.processHeaderCallback({column:h,api:this.grid.getApi()}):h.headerName||h.field||h.colId,bold:!0,align:h.type==="numberColumn"||h.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const h of i)(w=e.shouldRowBeSkipped)!=null&&w.call(e,{node:h,api:this.grid.getApi()})||(o.push(t.map(p=>{let m=this.getCellValueForExport(p,h,e);if(e.processCellCallback){const y=e.processCellCallback({value:ue(p,h,this.grid.getApi()),formattedValue:m,node:h,column:p,api:this.grid.getApi()});y!=null&&(m=String(y))}return{text:m,align:p.type==="numberColumn"||p.cellDataType===!0?"right":"left"}})),a.push(void 0));const r=18,l=e.pageSize||"a4-landscape",[c,d]=l.includes("portrait")?[595,842]:[842,595],u=d-64-(e.title?24:0),f=Math.max(5,Math.floor(u/r)),g=[];o.length===0&&g.push({columnWidths:n,rows:[],rowFill:[]});for(let h=0;h<o.length;h+=f)g.push({columnWidths:n,rows:o.slice(h,h+f),rowFill:a.slice(h,h+f)});return Zo(g,{pageSize:l,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const i=e instanceof ArrayBuffer?e:await e.arrayBuffer(),o=(await ns(i))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],r=o.rows.slice(1).map(l=>{const c={};return a.forEach((d,u)=>{const f=d||`col${u+1}`,g=l[u]??"",w=String(g).trim();c[f]=w!==""&&!isNaN(Number(w))&&!/^0\d/.test(w)?Number(w):g}),c});return t.onSuccess?t.onSuccess(r):this.grid.getApi().setRowData(r),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:r}),r}fileName(e,t){const i=e.fileName||this.grid.getOptions().fileName||"export";return i.endsWith(`.${t}`)?i:`${i}.${t}`}download(e,t){const i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(i),1e3)}copyToClipboard(e={}){const t={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},i=this.getDataAsCsv(t);this.lastCopied=i,this.writeToClipboard(i),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(i=>i.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(),i=this.grid.getRangeSelectionService().getRanges();let n,o;if(i.length>0){const u=i[0];n=u.rowStartIndex;const f=this.grid.getColumns().center,g=f.findIndex(w=>w.colId===u.colStartId);o=f[g]??f[0]}else if(t)n=t.rowIndex,o=t.column;else return;const a=e.replace(/\r/g,"").split(`
27
+ `);a.length&&a[a.length-1]===""&&a.pop();const r=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],l=r.findIndex(u=>u.colId===o.colId),c=[],d=[];this.grid.getDisplayedRowCount(),a.forEach((u,f)=>{const g=u.split(" "),w=n+f;let h=this.grid.getDisplayedRowAtIndex(w);if(!h){const p={};g.forEach((m,y)=>{const E=r[l+y];E!=null&&E.field&&(p[E.field]=m)}),d.push(p);return}g.forEach((p,m)=>{const y=r[l+m];y&&this.grid.setCellValue(y,h,p,"paste")}),c.push(h)}),d.length&&this.grid.getApi().applyTransaction({add:d}),c.length&&this.grid.refreshCells({rowNodes:c,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 i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();try{document.execCommand("copy")}catch{}document.body.removeChild(i),t()}}class ss{constructor(e){v(this,"ePanel");v(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 r;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(r=o.dataTransfer)==null?void 0:r.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const i=e.getOptions();(i.rowGroupPanelShow==="always"||i.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 i=document.createElement("div");i.className="ag-row-group-chip",i.draggable=!0,i.addEventListener("dragstart",a=>{var r;(r=a.dataTransfer)==null||r.setData("text/plain",t.colId)});const n=document.createElement("span");n.textContent=t.headerName,i.appendChild(n);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)),i.appendChild(o),this.eChips.appendChild(i)}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 as{constructor(e,t){v(this,"undoStack",[]);v(this,"redoStack",[]);v(this,"limit",50);v(this,"batchDepth",0);v(this,"batchBuffer",[]);v(this,"batchCounter",0);v(this,"currentBatchId",0);this.grid=e,this.eventService=t;const i=e.getOptions();i.undoRedoCellEditing&&(this.limit=typeof i.undoRedoCellEditing=="number"?i.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 i of e)this.applyValue(i,i.oldValue),this.redoStack.push(i),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 i=this.grid.getRowNode(e.rowNodeId);if(!i)return;const n=this.grid.getColumn(e.colId);n&&(this.grid.setCellValue(n,i,t,"undoRedo"),this.grid.refreshCells({rowNodes:[i],columns:[n],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 i of this.batchBuffer)this.undoStack.push({...i,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 ls{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:i,close:n}=this.popupService.createPopup(460,"ag-formula-editor");i.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,i.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"),i.appendChild(a);const r=document.createElement("div");r.className="ag-formula-preview";const l=()=>{const h=this.grid.getDisplayedRowAtIndex(0);if(!h){r.textContent="";return}try{const p=Mt(a.value,{data:h.data});r.textContent=`${this.grid.t("formulaPreview")}: ${p==null?"":String(p)}`,r.classList.remove("ag-formula-error")}catch(p){r.textContent=`${this.grid.t("formulaError")}: ${(p==null?void 0:p.code)||(p==null?void 0:p.message)||this.grid.t("invalidFormula")}`,r.classList.add("ag-formula-error")}};a.addEventListener("input",l),i.appendChild(r);const c=document.createElement("div");c.className="ag-formula-functions";const d=document.createElement("div");d.className="ag-formula-functions-title",d.textContent=this.grid.t("functions"),c.appendChild(d);const u=document.createElement("div");u.className="ag-formula-functions-list";for(const h of Ht){const p=document.createElement("button");p.className="ag-button ag-button-small",p.textContent=h,p.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${h}()`,a.focus(),l()}),u.appendChild(p)}c.appendChild(u),i.appendChild(c);const f=document.createElement("div");f.className="ag-popup-buttons";const g=document.createElement("button");g.className="ag-button ag-button-primary",g.textContent=this.grid.t("apply"),g.addEventListener("click",()=>{const h=a.value.trim(),p=this.grid.getColumnModel(),m=p.getColumn(e.colId);m&&(m.field=h==="="||h===""?e.field:h,m.colDef={...m.colDef,field:m.field},h!=="="&&h!==""&&(m.editable=!1)),p.refreshAll(),this.grid.refreshCells({force:!0}),n()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{a.value="=",l()}),f.appendChild(w),f.appendChild(g),i.appendChild(f),this.popupService.positionAt(i,t),l()}}class rs{constructor(e,t){v(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,i,n){const o=this.runtimeNotes.get(this.keyOf(e,t));if(o!==void 0)return o;if(typeof i=="function")return i(n);if(typeof i=="string")return i}setNote(e,t,i){const n=this.keyOf(e,t);i==null||i===""?this.runtimeNotes.delete(n):this.runtimeNotes.set(n,i),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,i){const n=this.grid.getColumn(t),o=this.grid.getRowNode(e),a=this.getNote(e,t,n==null?void 0:n.colDef.note,{data:o==null?void 0:o.data,node:o,column:n,api:this.grid.getApi()})??"",{ePopup:r,close:l}=this.popupService.createPopup(280,"ag-note-editor");r.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`${this.grid.t("note")} — ${(n==null?void 0:n.headerName)||t}`,r.appendChild(c);const d=document.createElement("textarea");d.className="ag-formula-input",d.rows=4,d.value=a,d.placeholder=this.grid.t("writeNote"),r.appendChild(d);const u=document.createElement("div");u.className="ag-popup-buttons";const f=document.createElement("button");f.className="ag-button ag-button-primary",f.textContent=this.grid.t("save"),f.addEventListener("click",()=>{this.setNote(e,t,d.value.trim()||void 0),l()});const g=document.createElement("button");g.className="ag-button",g.textContent=this.grid.t("delete"),g.addEventListener("click",()=>{this.setNote(e,t,void 0),l()}),u.appendChild(g),u.appendChild(f),r.appendChild(u),this.popupService.positionAt(r,i),setTimeout(()=>d.focus(),0)}}class cs{constructor(e,t){v(this,"dragState",null);v(this,"onMouseMoveBind",e=>this.onMouseMove(e));v(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 i=document.createElement("div");i.className="ag-row-drag-ghost",i.textContent=this.rowLabel(e),document.body.appendChild(i);const n=document.createElement("div");n.className="ag-row-drop-indicator",n.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(n),this.dragState={rowNode:e,ghost:i,startY:t.clientY,overIndex:null,indicator:n},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var n;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],i=t!=null&&t.field?(n=e.data)==null?void 0:n[t.field]:"";return String(i??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 i=document.elementFromPoint(e.clientX,e.clientY),n=i==null?void 0:i.closest(".ag-row");if(!(n!=null&&n.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let o=-1;if(this.grid.getRowModel().forEachNode((a,r)=>{a.id===n.dataset.rowid&&(o=r)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),r=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),l=e.clientY>n.getBoundingClientRect().top+r/2,c=(a[o]??0)+(l?r:0);t.indicator.style.display="block",t.indicator.style.top=`${c-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 i=this.grid.getApi(),n=this.grid.getOptions(),o=t.overIndex,a=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:i,node:t.rowNode,overIndex:o,overNode:o!==null?this.grid.getDisplayedRowAtIndex(o):void 0,y:e.clientY}),n.rowDragManaged&&a>=0&&o!==null&&o!==a&&this.moveRow(a,o,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((i,n)=>{i.id===e.id&&(t=n)}),t}moveRow(e,t,i){const n=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=n.length)return;const[o]=n.splice(e,1),a=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),n.splice(Math.max(0,Math.min(n.length,a+1)),0,o),this.grid.getApi().setRowData(n),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:o}})}}function ds(s){const e={setRowData:i=>s.setRowData(i),applyTransaction:i=>s.applyTransaction(i),getRowNode:i=>s.getRowNode(i),getDisplayedRowCount:()=>s.getDisplayedRowCount(),getDisplayedRowAtIndex:i=>s.getDisplayedRowAtIndex(i),getFirstDisplayedRow:()=>s.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>s.getDisplayedRowAtIndex(s.getDisplayedRowCount()-1),forEachNode:i=>{const n=s.getRowModel();for(let o=0;o<n.getRowCount();o++){const a=n.getRow(o);a&&i(a,o)}},forEachLeafNode:i=>{s.getRowModel().forEachLeafNode(i)},getModel:()=>s.getRowModel(),getValue:(i,n)=>{const o=typeof i=="string"?s.getColumn(i):i;if(!(!o||!n))return ue(o,n,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:(i,n)=>s.getSelectionService().selectNode(i,n??!1),deselectNode:i=>s.getSelectionService().deselectNode(i),setQuickFilter:i=>s.setQuickFilter(i),isQuickFilterPresent:()=>s.getQuickFilter().length>0,resetQuickFilter:()=>s.setQuickFilter(""),getSortModel:()=>s.getSortService().getSortModel(),setSortModel:i=>s.getSortService().setSortModel(i),getFilterModel:()=>s.getFilterService().getFilterModel(),setFilterModel:i=>s.getFilterService().setFilterModel(i),getColumnFilterModel:i=>{const n=typeof i=="string"?i:i.colId;return s.getFilterService().getFilterInstance(n)??null},setColumnFilterModel:(i,n)=>s.getFilterService().setColumnFilterModel(i,n),getAdvancedFilterModel:()=>s.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:i=>s.getFilterService().setAdvancedFilterModel(i),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:(i,n)=>s.setRowNodePinned(i,n),getColumnDefs:()=>s.getColumnModel().getColumnDefs(),setColumnDefs:(i,n)=>{s.getColumnModel().setColumnDefs(i),s.onGridSizeChanged()},updateGridOptions:i=>s.updateGridOptions(i),setGridOption:(i,n)=>s.updateGridOptions({[i]:n}),sizeColumnsToFit:()=>{const i=s.getSideBarService().isVisible()?s.getSideBarService().getElement().offsetWidth:0;s.getColumnModel().sizeColumnsToFit(s.getGridDiv().clientWidth-i),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{s.getColumnModel().autoSizeAllColumns()},moveColumn:(i,n)=>s.getColumnModel().moveColumn(i,n),moveColumnByIndex:(i,n)=>s.getColumnModel().moveColumnByIndex(i,n),setColumnVisible:(i,n)=>s.getColumnApi().setColumnVisible(i,n),setColumnsPinned:(i,n)=>s.getColumnApi().setColumnsPinned(i,n),setColumnsVisible:(i,n)=>s.getColumnApi().setColumnsVisible(i,n),getAllColumns:()=>s.getAllColumns(),getColumns:()=>[...s.getColumns().left,...s.getColumns().center,...s.getColumns().right],getColumn:i=>s.getColumn(i)??null,getDisplayedLeftColumns:()=>s.getColumns().left,getDisplayedCenterColumns:()=>s.getColumns().center,getDisplayedRightColumns:()=>s.getColumns().right,getColumnState:()=>s.getColumnApi().getColumnState(),applyColumnState:(i,n)=>s.getColumnApi().applyColumnState(i,n),resetColumnState:()=>s.getColumnApi().resetColumnState(),openColumnMenu:i=>{const n=typeof i=="string"?s.getColumn(i):i;n!=null&&n.eHeaderCell&&s.getHeaderView().getHeaderCell(n)},setSideBarVisible:i=>{s.getSideBarService().setVisible(i),s.onGridSizeChanged()},isSideBarVisible:()=>s.getSideBarService().isVisible(),setSideBarPosition:i=>{s.getSideBarService().setPosition(i),s.onGridSizeChanged()},openToolPanel:i=>{s.getSideBarService().setVisible(!0),s.getSideBarService().openPanel(i),s.onGridSizeChanged()},closeToolPanel:()=>{s.getSideBarService().setVisible(!1),s.onGridSizeChanged()},getToolPanel:()=>s.getSideBarService().getActivePanel(),setStatusBarVisible:i=>s.getSideBarService()&&s.getOptions(),getSideBar:()=>s.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.isLastPageFound())??!0},paginationGetPageSize:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getPageSize())??0},paginationGetCurrentPage:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getCurrentPage())??0},paginationGetTotalPages:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getTotalPages())??1},paginationGetRowCount:()=>s.getDisplayedRowCount(),paginationGoToPage:i=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToPage(i)},paginationGoToNextPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToNextPage()},paginationGoToPreviousPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToPreviousPage()},paginationGoToFirstPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToFirstPage()},paginationGoToLastPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToLastPage()},paginationSetPageSize:i=>{var n;return(n=s.getPaginationService())==null?void 0:n.setPageSize(i)},startEditingCell:i=>s.getEditService().startEditingCell(i),stopEditing:i=>s.getEditService().stopEditing(i),getEditingCells:()=>s.getEditService().getEditingCells(),setFocusedCell:(i,n)=>{const o=typeof n=="string"?s.getColumn(n):n;o&&s.getEditService().setFocusedCell(i,o)},getFocusedCell:()=>{const i=s.getEditService().getFocusedCell();return i?{rowIndex:i.rowIndex,column:i.column,rowNode:i.rowNode}:null},clearFocusedCell:()=>s.getEditService().clearFocusedCell(),tabToNextCell:()=>s.getEditService().tabToNextCell(),tabToPreviousCell:()=>s.getEditService().tabToPreviousCell(),refreshCells:i=>s.getRowRenderer().refreshCells(i),redrawRows:i=>s.getRowRenderer().redrawRows(i),flashCells:i=>s.getRowRenderer().flashCells(i||{}),ensureIndexVisible:(i,n)=>s.getRowRenderer().ensureIndexVisible(i,n),ensureNodeVisible:i=>{let n=-1;s.getRowModel().forEachNode((o,a)=>{o.id===i.id&&(n=a)}),n>=0&&s.getRowRenderer().ensureIndexVisible(n)},ensureColumnVisible:i=>{const n=typeof i=="string"?s.getColumn(i):i;n&&s.getRowRenderer().ensureColumnVisible(n)},copyToClipboard:i=>s.getExportService().copyToClipboard(i),cutToClipboard:i=>s.getExportService().cutToClipboard(i),pasteFromClipboard:()=>s.getExportService().pasteFromClipboard(),exportToCsv:i=>s.getExportService().exportToCsv(i||{}),exportToExcel:i=>s.getExportService().exportToExcel(i||{}),exportToPdf:i=>s.getExportService().exportToPdf(i||{}),importExcel:(i,n)=>s.getExportService().importExcel(i,n||{}),getDataAsPdf:i=>s.getExportService().getDataAsPdf(i||{}),getDataAsCsv:i=>s.getExportService().getDataAsCsv(i||{}),getDataAsExcel:i=>s.getExportService().getDataAsExcel(i||{}),getChartData:i=>s.getChartService().getChartData(i||{}),getChartModels:()=>s.getChartService().getChartModels(),createChart:()=>s.getChartService().createChart(),getCellRanges:()=>s.getRangeSelectionService().getRanges(),clearRangeSelection:()=>s.getRangeSelectionService().clearRanges(),addCellRange:i=>{const n=s.getRangeSelectionService();n.ranges=[i],n.applyHighlight(),n.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>s.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>s.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>s.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>s.getOverlayService().hideOverlay(),setServerSideDatasource:i=>{const n=s.getServerSideRowModel();n&&n.setDatasource(i)},setDatasource:i=>{var o;const n=s.getInfiniteRowModel();n?n.setDatasource(i):(o=s.getServerSideRowModel())==null||o.setDatasource(i)},setViewportDatasource:i=>{var n;(n=s.getViewportRowModel())==null||n.setViewportDatasource(i)},setViewportRange:(i,n)=>{var o;(o=s.getViewportRowModel())==null||o.setViewportRange(i,n)},refreshServerSide:i=>{const n=s.getServerSideRowModel();n&&(i!=null&&i.purge?n.purgeCache():n.onSortOrFilterChanged())},purgeServerSideCache:()=>{var i,n;(i=s.getServerSideRowModel())==null||i.purgeCache(),(n=s.getInfiniteRowModel())==null||n.onSortOrFilterChanged()},getServerSideStoreState:()=>{const i=s.getServerSideRowModel();if(!i)return[];const n=[];for(const[o,a]of i.stores)n.push({groupPath:o,rowCount:a.rows.length,lastRow:a.lastRow,loading:a.loading});return n},setRowCount:(i,n)=>{const o=s.getServerSideRowModel();if(!o)return;const a=o.getStore("");if(a)for(a.lastRow=n?i:null;a.rows.length<i;)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:i=>s.getUndoRedoService().endBatchEdit(i),cancelBatchEdit:()=>s.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>s.getUndoRedoService().isBatchEditing(),getState:()=>{const i=s.getColumnApi(),n=s.getSelectionService(),o=s.getPaginationService();return{columns:i.getColumnState(),sort:s.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(s.getFilterService().getFilterModel())),quickFilter:s.getQuickFilter(),selectedRowIds:n.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:i=>{if(!i)return;const n=s.getColumnApi();if(i.columns&&n.applyColumnState(i.columns,!0),i.sort&&s.getSortService().setSortModel(i.sort),i.filter&&s.getFilterService().setFilterModel(i.filter),i.quickFilter!==void 0&&s.setQuickFilter(i.quickFilter),i.rowGroupColumns&&s.getColumnModel().setRowGroupColumns(i.rowGroupColumns),i.pivotMode!==void 0&&s.getColumnModel().setPivotMode(i.pivotMode),i.selectedRowIds){s.getSelectionService().deselectAll();for(const a of i.selectedRowIds){const r=s.getRowNode(a);r&&s.getSelectionService().selectNode(r,!1)}}const o=s.getPaginationService();o&&i.pagination&&(o.setPageSize(i.pagination.pageSize),o.goToPage(i.pagination.page))},setNote:(i,n,o)=>{const a=typeof n=="string"?n:n.colId;s.getNotesService().setNote(i.id,a,o)},getNote:(i,n)=>{const o=typeof n=="string"?n:n.colId,a=s.getColumn(o);return s.getNotesService().getNote(i.id,o,a==null?void 0:a.colDef.note,{data:i.data,node:i,column:a,api:s.getApi()})},getGridId:()=>"rowvia",destroy:()=>s.destroy(),refreshClientSideRowModel:()=>s.refreshModel("everything"),setPivotMode:i=>s.getColumnModel().setPivotMode(i),isPivotMode:()=>s.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>s.getAllColumns(),getColumn:i=>s.getColumn(i)??null,getColumnState:()=>s.getColumnModel().getColumnState(),applyColumnState:(i,n)=>{s.getColumnModel().applyColumnState(i,n),s.refreshModel("group")},resetColumnState:()=>{s.getColumnModel().resetColumnState(),s.refreshModel("group")},setColumnVisible:(i,n)=>s.getColumnModel().setColumnVisible(i,n),setColumnsVisible:(i,n)=>s.getColumnModel().setColumnsVisible(i,n),setColumnPinned:(i,n)=>s.getColumnModel().setColumnPinned(i,n),setColumnsPinned:(i,n)=>s.getColumnModel().setColumnsPinned(i,n),moveColumn:(i,n)=>s.getColumnModel().moveColumn(i,n),moveColumnByIndex:(i,n)=>s.getColumnModel().moveColumnByIndex(i,n),autoSizeColumn:i=>{s.getColumnModel().autoSizeColumn(i),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(i,n)=>s.getColumnModel().setRowGroupColumns(i,n),removeRowGroupColumns:i=>{for(const n of i)s.getColumnModel().removeRowGroupColumn(n)},addRowGroupColumn:i=>s.getColumnModel().addRowGroupColumn(i),setPivotColumns:i=>s.getColumnModel().setPivotColumns(i),removePivotColumns:i=>s.getColumnModel().setPivotColumns(i.map(()=>"").filter(n=>n!=="")),setValueColumns:i=>s.getColumnModel().setValueColumns(i),removeValueColumn:i=>s.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),getValueColumns:()=>s.getColumnModel().getValueColumns(),getPivotColumns:()=>s.getColumnModel().getPivotColumns(),setPivotMode:(i,n)=>s.getColumnModel().setPivotMode(i,n),isPivotMode:()=>s.getColumnModel().isPivotMode()}}}const us={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 Ct{constructor(e,t){v(this,"options");v(this,"eventService",new $e);v(this,"columnModel");v(this,"rowModel");v(this,"clientSideRowModel",null);v(this,"serverSideRowModel",null);v(this,"infiniteRowModel",null);v(this,"viewportRowModel",null);v(this,"rowRenderer");v(this,"headerView");v(this,"selectionService");v(this,"editService");v(this,"filterService");v(this,"sortService");v(this,"paginationService",null);v(this,"popupService");v(this,"filterGui");v(this,"contextMenuService");v(this,"columnMenuService");v(this,"statusBarService");v(this,"sideBarService");v(this,"findService");v(this,"rangeSelectionService");v(this,"chartService");v(this,"overlayService");v(this,"exportService");v(this,"rowGroupPanel",null);v(this,"undoRedoService");v(this,"formulaEditorService");v(this,"notesService");v(this,"rowDragService");v(this,"api");v(this,"columnApi");v(this,"localeText");v(this,"rowNodeServices");v(this,"eGridDiv");v(this,"eRoot");v(this,"eMain");v(this,"eHeader");v(this,"quickFilter","");v(this,"resizeObserver",null);v(this,"destroyed",!1);v(this,"gridReadyDispatched",!1);v(this,"context");v(this,"onWindowResize",()=>{this.onGridSizeChanged()});v(this,"onDocumentMouseDown",e=>{var i;const t=e.target;if(t&&this.eRoot.contains(t)){const n=(i=t.closest)==null?void 0:i.call(t,".ag-cell");if(!n){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!n.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var c,d,u,f;this.eGridDiv=e,this.options={...us,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Jn(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const i=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(i),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),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:(g,w)=>this.selectionService.selectNode(g,w),deselectNode:g=>this.selectionService.deselectNode(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g)},this.columnModel=new Pi(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new No(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),g=>this.isNodeSelectable(g)),this.filterService=new Lo(this),this.sortService=new Do(this),this.popupService=new Ao(this),this.filterGui=new Fo(this,this.popupService),this.contextMenuService=new Po(this,this.popupService),this.columnMenuService=new $o(this,this.popupService),this.editService=new Io(this,this.eventService),this.undoRedoService=new as(this,this.eventService),this.formulaEditorService=new ls(this,this.popupService),this.notesService=new rs(this,this.popupService),this.rowDragService=new cs(this,this.eventService),this.chartService=new Vo(this,this.popupService),this.findService=new Oo(this,this.popupService),this.exportService=new os(this);const n={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 eo(n),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new to(n),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new io(n),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new Kn({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var g;return!!((g=this.paginationService)!=null&&g.isEnabled())},getPageSize:()=>{var g;return((g=this.paginationService)==null?void 0:g.getPageSize())??100},getCurrentPage:()=>{var g;return((g=this.paginationService)==null?void 0:g.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(d=(c=this.rowModel).setGridApi)==null||d.call(c,null)),this.headerView=new To(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(g=>g.sort)}),onSortRequested:(g,w,h)=>this.sortService.onSortRequested(g,w,h),onColumnResized:(g,w,h)=>this.onColumnResized(g,w,h),onColumnMoved:(g,w)=>this.onColumnMoved(g,w),onColumnMenuClicked:(g,w)=>this.columnMenuService.openColumnMenu(g,w),onFilterOpened:(g,w)=>this.filterGui.openFilter(g,w),isFilterActive:g=>this.filterService.isFilterActive(g),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(g,w)=>this.filterService.handleFloatingFilterChange(g,w),onHeaderCheckboxChanged:(g,w)=>this.onHeaderCheckboxChanged(g,w),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:g=>this.t(g),getApi:()=>this.api,getFilterModel:g=>this.filterService.getFilterInstance(g)??null,onFilterModelChange:(g,w)=>this.filterService.setColumnFilterModel(g,w)}),this.rowRenderer=new ko(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:g=>this.t(g),getColumns:()=>this.getColumns(),getRowHeight:g=>this.getRowHeight(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g),isRowSelectable:g=>this.isNodeSelectable(g),getRowClass:g=>this.getRowClass(g),getRowStyle:g=>this.getRowStyle(g),onCellClicked:g=>this.onCellClicked(g),onCellDoubleClicked:g=>this.editService.onCellDoubleClicked(g),onCellMouseDown:g=>this.onCellMouseDown(g),onCellContextMenu:g=>this.onCellContextMenu(g),onRowClicked:g=>this.onRowClicked(g),onRowDoubleClicked:g=>this.onRowDoubleClicked(g),onRowGroupClicked:g=>this.onRowGroupClicked(g),onViewportKeyDown:g=>this.onViewportKeyDown(g),onViewportScroll:()=>{var h,p,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const g=this.rowRenderer.getFirstVisibleRowIndex(),w=this.rowRenderer.getLastVisibleRowIndex();(h=this.serverSideRowModel)==null||h.onViewportChanged(g,w),(p=this.infiniteRowModel)==null||p.onViewportChanged(g,w),(m=this.viewportRowModel)==null||m.onViewportChanged(g,w)},getCellText:(g,w)=>{const h=ue(g,w,this.api);return h==null?"":String(h)},renderDetailRow:g=>this.renderDetailRow(g),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(g,w,h)=>this.rowDragService.startDrag(g,h),getNote:(g,w,h,p)=>this.notesService.getNote(g,w,h,p),onNoteClick:(g,w,h)=>this.notesService.openNoteEditor(g,w,h),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new Bo(this,this.eventService),this.statusBarService=new Go(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new zo(this),this.sideBarService=new Ho(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 Wi(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new ss(this));const{api:a,columnApi:r}=ds(this);this.api=a,this.columnApi=r,this.columnModel.setGridApi(this.api),(f=(u=this.rowModel).setGridApi)==null||f.call(u,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=g=>this.filterService.doesNodePassAdvancedFilter(g),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 g,w;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(w=(g=this.options).onSelectionChanged)==null||w.call(g,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let l=this.options.columnDefs||[];(!l||l.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(l=Pi.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(l),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 i=this.localeText.t(e);return i===e?t:i}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 i,n;const e=new Map,t=this.getAllColumns().filter(o=>o.colDef.showValueAs);if(t.length>0){const o=new Map;(n=(i=this.rowModel).forEachLeafNode)==null||n.call(i,a=>{for(const r of t){const l=ue(r,a,this.api);typeof l=="number"&&!isNaN(l)&&o.set(r.colId,(o.get(r.colId)??0)+l)}});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,i;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(t=this.infiniteRowModel)!=null&&t.isLoading()||(i=this.viewportRowModel)!=null&&i.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 i=t({data:e.data,node:e,api:this.api});if(i)return i}return this.options.rowHeight??42}getRowClass(e){const t=[];if(this.options.rowClass&&t.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const i=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof i=="string"?t.push(i):Array.isArray(i)&&t.push(...i)}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 i,n,o;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),t||(this.overlayService.updateAuto(),this.statusBarService.update(),(i=this.paginationService)==null||i.update(),this.chartService.refreshCharts(),(o=(n=this.options).onRowDataChanged)==null||o.call(n,{api:this.api}))}applyTransaction(e){var i;const t=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(i=this.paginationService)==null||i.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),t}setCellValue(e,t,i,n="api",o){const a=o!==void 0?o:ue(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:ue(e,t,this.api),newValue:i,data:t.data,node:t,column:e,api:this.api,colDef:e.colDef})===!1)return}else t.setDataValue(e.colId,i);e.rowGroup&&this.rowModel.refreshModel("group"),(n==="edit"||n==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:a,newValue:i,batchId:0}),n!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:i,value:i,data:t.data,node:t,column:e,colDef:e.colDef,api:this.api,source:n})}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,r,l,c;const{node:t,column:i,event:n}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(r=(a=this.options).onCellClicked)==null||r.call(a,{...e,api:this.api,colDef:i.colDef,value:ue(i,t,this.api)});return}if(n.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,n),this.editService.onCellClicked(e),(c=(l=this.options).onCellClicked)==null||c.call(l,{...e,api:this.api,colDef:i.colDef,value:ue(i,t,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var t,i;this.selectionService.handleRowClick(e.node,e.event),(i=(t=this.options).onRowClicked)==null||i.call(t,{...e,api:this.api})}onRowDoubleClicked(e){var t,i;(i=(t=this.options).onRowDoubleClicked)==null||i.call(t,{...e,api:this.api})}onCellContextMenu(e){var i,n;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(n=(i=this.options).onCellContextMenu)==null||n.call(i,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,i,n,o,a;if(e.group){const r=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);r&&r(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}),(n=(i=this.options).onRowGroupOpened)==null||n.call(i,{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 i;if(e.headerCheckboxSelectionCurrentPageOnly&&((i=this.paginationService)!=null&&i.isEnabled())){const n=this.rowModel.getRowCount();if(t)for(let o=0;o<n;o++){const a=this.rowModel.getRow(o);a&&this.isNodeSelectable(a)&&this.selectionService.selectNode(a,!1)}else for(let o=0;o<n;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 i=t.querySelector(".ag-header-select-all");if(!i)continue;const n=this.selectionService.getSelectAllState();i.checked=n.checked,i.indeterminate=n.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,i){e.width=t,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),i&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,t){const i=this.columnModel.getColumns(),n=i.findIndex(a=>a.colId===e);if(n<0)return;let o=i.length;t&&(o=i.findIndex(a=>a.colId===t)),this.columnModel.moveColumnByIndex(n,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,i,n,o,a,r;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}),(i=(t=this.options).onFirstDataRendered)==null||i.call(t,{api:this.api})),(o=(n=this.options).onModelUpdated)==null||o.call(n,{api:this.api}),(r=(a=this.options).onRowDataChanged)==null||r.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,r;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(l=>l.flex!==null&&l.flex>0&&l.visible),i=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,n=Math.max(0,e-i);(t||((o=this.options.autoSizeStrategy)==null?void 0:o.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(n),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}),(r=(a=this.options).onGridSizeChanged)==null||r.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var c,d;const t=e.masterNode;if(!t)return null;const i=this.options.detailRowAutoHeight===!0,n=i?this.options.detailRowHeight??200:this.options.detailRowHeight??200,o=document.createElement("div");o.className="ag-row-detail",o.style.height=`${n}px`,o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0";const a=this.options.detailCellRenderer,r=(c=this.options.detailCellRendererParams)==null?void 0:c.detailGridOptions,l=(d=this.options.detailCellRendererParams)==null?void 0:d.getDetailRowData;if(r&&l){const u=l({data:t.data,node:t,api:this.api}),f=document.createElement("div");f.style.height="100%",f.style.padding="8px 16px",o.appendChild(f),setTimeout(()=>{new Ct(f,{...r,rowData:u,theme:this.options.theme})},0)}else if(typeof a=="function"){const u=a({data:t.data,node:t,api:this.api,context:this.context});u instanceof HTMLElement?o.appendChild(u):o.textContent=String(u??"")}else typeof a=="string"&&(o.textContent=a);if(i){const u=Math.max(40,o.scrollHeight||n);return e.rowHeight=u,o.style.height=`${u}px`,{eDetail:o,height:u}}return e.rowHeight=n,{eDetail:o,height:n}}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,i=e.rowData!==void 0&&e.rowData!==this.options.rowData,n=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),i&&this.setRowData(e.rowData),n&&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 Wi(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,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 Xi(s){const e=document.createElement("dialog");e.className="rowvia-detail-dialog";const t=document.createElement("h2"),i=document.createElement("dl"),n=document.createElement("button");n.type="button",n.textContent="关闭";const o=()=>e.close();return n.addEventListener("click",o),e.append(t,i,n),s.append(e),{open(a){t.textContent=a.title,e.setAttribute("aria-label",a.title),i.replaceChildren();for(const r of a.fields){const l=document.createElement("dt"),c=document.createElement("dd");l.textContent=r.label,c.textContent=r.value,i.append(l,c)}e.open||e.showModal()},close:o,destroy(){e.open&&e.close(),n.removeEventListener("click",o),e.remove()}}}const Yi=864e5;function Qe(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),i=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${i}`}function Pe(s){return new Date(`${s}T00:00:00`)}function De(s,e){return new Date(s.getTime()+e*Yi)}function je(s,e){const t=typeof s=="string"?Pe(s):s,i=typeof e=="string"?Pe(e):e;return Math.round((i.getTime()-t.getTime())/Yi)}function It(){return Qe(new Date)}function hs(s){return s.status!=="done"&&s.end&&s.end<It()&&s.progress<100?"delayed":s.status}function ri(s){const e=Pe(s);return`${e.getMonth()+1}月${e.getDate()}日`}const Qi=["day","week","biweek","month","bimonth","quarter","halfyear","year"],Ut={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},ps={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2},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)"},_t={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},gs=4,Ji=6,He=28;function ci(s){const e=(s.getDay()+6)%7;return De(s,-e)}function fs(s,e){const t=Math.max(1,je(s,e)+1);let i=0;for(let n=0;n<t;n++){const o=De(s,n).getDay();o!==0&&o!==6&&i++}return Math.max(1,i)}function ms(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function Zi(s,e,t){const i=[];if(s==="day"){let l=new Date(e);for(;l<t;){const c=De(l,1);i.push({start:new Date(l),end:c,primary:`${l.getDate()}`,secondary:""}),l=c}return i}if(s==="week"||s==="biweek"){let l=ci(e);for(;l<t;){const c=De(l,s==="biweek"?14:7);i.push({start:new Date(l),end:c,primary:`${l.getMonth()+1}/${l.getDate()}`,secondary:""}),l=c}return i}const n=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=l=>new Date(l.getFullYear(),Math.floor(l.getMonth()/n)*n,1),a=l=>s==="month"||s==="bimonth"?`${l.getMonth()+1}月`:s==="halfyear"?`${l.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(l.getMonth()/3)+1}`:`${l.getFullYear()}`;let r=o(e);for(;r<t;){const l=ms(r,n);i.push({start:new Date(r),end:l,primary:a(r),secondary:""}),r=l}return i}class en{constructor(e,t){v(this,"options");v(this,"eRoot");v(this,"eHeader");v(this,"eRuler");v(this,"rulerCtx");v(this,"eRulerTools");v(this,"eStepLabel");v(this,"eZoomValue");v(this,"eStepMenu",null);v(this,"eScroll");v(this,"eSpacer");v(this,"eCanvas");v(this,"ctx");v(this,"eTooltip");v(this,"eTodayBadge");v(this,"ePopup",null);v(this,"tasks",[]);v(this,"tasksById",new Map);v(this,"rows",[]);v(this,"selectedId",null);v(this,"hoverId",null);v(this,"unit","day");v(this,"zoom",1);v(this,"theme","content");v(this,"epochStart",new Date);v(this,"totalDays",1);v(this,"hits",[]);v(this,"hitsByRow",new Map);v(this,"drag",null);v(this,"ghost",null);v(this,"dirty",!0);v(this,"lastLeft",-1);v(this,"lastTop",-1);v(this,"timer");v(this,"observer",null);v(this,"resizeHandler",()=>this.resizeCanvases());v(this,"showChildren",!0);v(this,"milestonesOnly",!1);v(this,"locateHits",[]);v(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)});v(this,"onScroll",()=>{this.tick()});v(this,"todayLabelX",-1);v(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:i,onAvatar:n}=this.hitAt(e.clientX,e.clientY),o=this.rows[i];n?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())});v(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),i=this.locateHits.find(c=>Math.abs(c.x-(e.clientX-t.left))<12&&Math.abs(c.y-(e.clientY-t.top))<12);if(i){this.scrollToTask(i.id);return}const{hit:n,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),r=this.rows[o];if(n){const c=this.tasksById.get(n.id);if(!c)return;if(a){e.stopPropagation(),this.openAssigneePopup(n.id,n);return}if(c.kind!=="task"||c.milestone||!c.start||!c.end){this.options.onSelect(n.id);return}e.preventDefault(),this.drag={id:n.id,mode:n.mode,startX:e.clientX,startY:e.clientY,originStart:c.start,originEnd:c.end,start:c.start,end:c.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(n.id);return}if(!r)return;const l=this.tasksById.get(r.id);if(l){if(l.kind==="task"&&(!l.start||!l.end)){const c=this.pointAt(e.clientX,e.clientY),d=Math.floor(c.x/this.dayWidth),u=Qe(De(this.epochStart,d));this.options.onTaskChange({...l,start:u,end:Qe(De(Pe(u),4)),progress:0,status:"not-started"}),this.options.onSelect(r.id);return}this.options.onSelect(r.id)}});v(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const i=this.tasksById.get(t.id);if(!i||!t.moved&&Math.abs(e.clientX-t.startX)<gs)return;t.moved=!0;const n=this.dayWidth,o=Math.round((e.clientX-t.startX)/n),a=Pe(t.originStart),r=Pe(t.originEnd),l=je(a,r);let c,d;t.mode==="resize-l"?(c=De(a,Math.min(o,l)),d=r):t.mode==="resize-r"?(c=a,d=De(r,Math.max(o,-l))):(c=De(a,o),d=De(r,o)),i.milestone&&(c=d),t.start=Qe(c),t.end=Qe(d),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?ri(t.start):`${ri(t.start)} → ${ri(t.end)}`;const u=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-u.left+12}px`,this.eTooltip.style.top=`${e.clientY-u.top+16}px`});v(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})});v(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});v(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.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 i=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(i),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;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.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){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 ps[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(It()),i=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=i}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 i=It();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const n=ci(De(Pe(e),-7));this.epochStart=n,this.totalDays=Math.max(je(n,Pe(t))+730,1095)}dateX(e){return je(this.epochStart,e)*this.dayWidth}xToDate(e){return Qe(De(this.epochStart,Math.round(e/this.dayWidth)))}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[t,i]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const n=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(n*e)),t.height=Math.max(1,Math.round(o*e)),t.style.width=`${n}px`,t.style.height=`${o}px`,i.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,i=this.totalDays*e,n=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${i}px`,this.eSpacer.style.height=`${n}px`,this.drawRuler(e,i),this.drawBody(e,i,n,t)}drawRuler(e,t){const i=this.rulerCtx,n=this.eHeader.clientWidth,o=this.eHeader.clientHeight,a=this.eScroll.scrollLeft;i.clearRect(0,0,n,o),i.fillStyle="#fff",i.fillRect(0,0,n,o);const r=De(this.epochStart,this.totalDays),l=(u,f,g,w)=>{for(const h of u){const p=this.dateX(Qe(h.start))-a,m=je(h.start,h.end)*e;if(p+m<=0||p>=n)continue;const y=Math.max(0,Math.min(p+m,n)-Math.max(0,p));if(this.unit==="day"||this.unit==="week"){const S=h.start.getDay();(S===0||S===6)&&(i.fillStyle=Re.weekend,i.fillRect(Math.max(0,p),f,y,g))}const E=i.measureText(h.primary).width;if(E+8<y){const S=Math.max(0,p)+y/2-E/2,P=f+g/2+5;i.fillStyle=Re.text,i.font="11px "+Je,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(h.primary,S,P),h.secondary&&(i.fillStyle=Re.textTertiary,i.font="10px "+Je,i.fillText(h.secondary,S,P+12))}}},c=40,d=De(this.epochStart,Math.floor(a/e));i.fillStyle=Re.text,i.font="14px "+Je,i.textAlign="left",i.textBaseline="middle",i.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${d.getFullYear()}年${d.getMonth()+1}月`:`${d.getFullYear()} 年`,16,22),l(Zi(this.unit,this.epochStart,r),c+1,o-c-1),i.strokeStyle=Re.border,i.beginPath(),i.moveTo(0,o-.5),i.lineTo(n,o-.5),i.stroke()}drawBody(e,t,i,n){const o=this.ctx,a=this.eScroll.clientWidth,r=this.eScroll.clientHeight,l=this.eScroll.scrollLeft,c=this.eScroll.scrollTop;o.clearRect(0,0,a,r),o.fillStyle="#fff",o.fillRect(0,0,a,r),o.save(),o.translate(-l,-c),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,c+r)),this.drawGridlines(e,t,Math.max(i,c+r)),this.drawRowBackgrounds(t,n);const d=this.rows.findIndex(f=>f.id===this.hoverId),u=this.hoverId?this.tasksById.get(this.hoverId):null;if(d>=0&&(u==null?void 0:u.kind)==="task"&&!u.start){const f=d*n+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,wt(o,l+4,f,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Re.textTertiary,o.font="14px "+Je,o.textAlign="center",o.fillText("新建排期",l+a/2,f+19)}this.drawDependencies(n),this.drawBars(n),this.drawTodayLine(t,Math.max(i,c+r)),o.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,i){if(this.unit!=="day"&&this.unit!=="week")return;const n=this.ctx;n.fillStyle=Re.weekend;let o=ci(this.epochStart);for(;je(this.epochStart,o)<this.totalDays;){const a=this.dateX(Qe(o))+5*e;a<t&&n.fillRect(Math.max(0,a),0,e*2,i),o=De(o,7)}}drawGridlines(e,t,i){const n=this.ctx,o=De(this.epochStart,this.totalDays);for(const a of Zi(this.unit,this.epochStart,o)){const r=Math.round(this.dateX(Qe(a.start)))+.5;if(r<0||r>t)continue;const l=this.unit==="day"&&a.start.getDate()===1;n.strokeStyle=l?Re.gridlineMonth:Re.gridline,n.beginPath(),n.moveTo(r,0),n.lineTo(r,i),n.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=Re.rowLine,i.lineWidth=1,i.beginPath();for(let n=1;n<this.rows.length;n++){const o=Math.round(n*t)+.5;i.moveTo(0,o),i.lineTo(e,o)}i.stroke(),this.rows.forEach((n,o)=>{const a=this.selectedId===n.id,r=this.hoverId===n.id;(a||r)&&(i.fillStyle=a?Re.selected:r?Re.hover:Re.groupRow,i.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,n=Math.round(this.dateX(It())+this.dayWidth/2)+.5;n<0||n>e||(i.strokeStyle=Re.accent,i.lineWidth=1.5,i.beginPath(),i.moveTo(n,0),i.lineTo(n,t),i.stroke(),this.todayLabelX=n-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=It().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((n,o)=>[n.id,o])),i=this.ctx;i.strokeStyle=Re.accent,i.lineWidth=1.2;for(const n of this.rows){const o=this.tasksById.get(n.id);if(!o||o.kind!=="task"||!o.start||!o.end)continue;const a=t.get(n.id);if(a!==void 0)for(const r of o.dependsOn){const l=this.tasksById.get(r),c=t.get(r);if(!(l!=null&&l.start)||!l.end||c===void 0)continue;const d=this.dateX(l.start),u=l.milestone?this.dayWidth:Math.max(je(Pe(l.start),Pe(l.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),f=d+u,g=c*e+e/2,w=this.dateX(o.start),h=Math.max(je(Pe(o.start),Pe(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),p=a*e+e/2,m=f+10;if(w-4>m)tn(i,f,g,m,p,w-5,p);else{const y=w+h+10;tn(i,f,g,m,p,y,p)}Cs(i,w-5,p)}}}drawBars(e){this.rows.forEach((t,i)=>{const n=this.tasksById.get(t.id);if(!n||!n.start||n.path.length>1&&(!this.showChildren||this.milestonesOnly&&!n.milestone))return;const o=i*e+(e-He)/2;if(t.group){this.drawSummaryBar(n,i,o);return}if(n.milestone){this.drawMilestone(n,i,o);return}n.end&&this.drawTaskBar(n,i,o)})}drawTaskBar(e,t,i){var g;const n=this.ctx,o=((g=this.ghost)==null?void 0:g.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,r=(o==null?void 0:o.end)??e.end,l=this.dateX(a),c=Math.max(28,(je(a,r)+1)*this.dayWidth),d=_t[e.status];n.save(),n.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,n.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",n.strokeStyle=this.selectedId===e.id?Re.accent:"#dee0e3",n.lineWidth=1,wt(n,l,i,c,He,4),n.fill(),n.stroke(),n.save(),wt(n,l,i,c,He,4),n.clip(),n.beginPath(),n.arc(l+14,i+14,6,0,Math.PI*2),n.fillStyle=d,n.fill(),n.font="12px "+Je,n.textBaseline="middle",n.textAlign="left",n.fillStyle=Re.text;const u=this.options.members.find(w=>w.id===e.owner),f=n.measureText(e.name).width;c>f+58?(n.fillText(e.name,l+26,i+14),u&&di(n,l+f+42,i+14,7,qt(u.id),u.name.slice(0,1))):u&&c>46&&di(n,l+38,i+14,7,qt(u.id),u.name.slice(0,1)),c>100&&(n.fillStyle=Re.textTertiary,n.textAlign="right",n.fillText(String(fs(Pe(a),Pe(r))),l+c-8,i+14)),n.restore(),n.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:l,y:i,w:c,h:He,mode:"move",avatar:u?{x:l+(c>f+58?f+42:38),y:i+14,r:7}:void 0})}drawSummaryBar(e,t,i){if(!e.start||!e.end)return;const n=this.tasks.filter(d=>d.path.length===e.path.length+1&&d.path.slice(0,-1).join("/")===e.path.join("/")&&d.start),o=n[0],a=this.ctx,r=this.dateX(e.start),l=Math.max(92,(je(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,wt(a,r,i,l,He,4),a.fill(),a.stroke(),a.fillStyle=o?_t[o.status]:_t[e.status],a.beginPath(),a.arc(r+14,i+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Re.text,a.font="11px "+Je,a.textAlign="left",a.textBaseline="middle";const c=((o==null?void 0:o.name)??e.name)+(n.length>1?` +${n.length-1}`:"");a.fillText(vs(a,c,l-32),r+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:r,y:i,w:l,h:He,mode:"move"})}firstVisibleChildIndex(e,t){var n;const i=`${e.path.join("/")}/`;for(let o=t+1;o<this.rows.length;o++){const a=this.tasksById.get(((n=this.rows[o])==null?void 0:n.id)??"");if(a)return a.path.join("/").startsWith(i)?o:-1}return-1}drawMilestone(e,t,i){var p;const n=this.ctx,o=this.dayWidth,a=((p=this.ghost)==null?void 0:p.id)===e.id?this.ghost:null,r=a?a.start:e.start,l=hs(e),c=_t[l],d=this.dateX(r)+o/2;n.font="12px "+Je;const u=n.measureText(e.name).width,f=e.owner?24:0,g=19+u+f+14,w=d-g/2;n.fillStyle="#fff",n.strokeStyle=c,n.lineWidth=1.5,wt(n,w,i,g,He,4),n.fill(),n.stroke(),n.fillStyle=c,n.beginPath(),n.arc(w+7+3,i+He/2,3,0,Math.PI*2),n.fill(),n.fillStyle=Re.text,n.textAlign="left",n.textBaseline="middle",n.fillText(e.name,w+14+5,i+He/2+1);let h;if(e.owner){const m=this.options.members.find(y=>y.id===e.owner);m&&(di(n,w+g-12,i+He/2,9,qt(m.id),m.name.slice(0,1)),h={x:w+g-12,y:i+He/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:w,y:i,w:g,h:He,mode:"move",avatar:h})}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,i=this.eScroll.clientWidth;this.rows.forEach((n,o)=>{const a=this.tasksById.get(n.id);if(!(a!=null&&a.start)||!a.end||a.path.length>1&&(!this.showChildren||this.milestonesOnly&&!a.milestone))return;const r=this.dateX(a.start),l=this.dateX(a.end)+this.dayWidth;if(l>=t&&r<=t+i)return;const c=l<t?10:i-18,d=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;d<0||d>this.eScroll.clientHeight||(e.fillStyle="#8f959e",wt(e,c-5,d-6,13,13,3),e.fill(),e.font="12px "+Je,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(l<t?"‹":"›",c+1,d),this.locateHits.push({id:a.id,x:c+1,y:d}))})}pointAt(e,t){const i=this.eScroll.getBoundingClientRect();return{x:e-i.left+this.eScroll.scrollLeft,y:t-i.top+this.eScroll.scrollTop}}hitAt(e,t){const i=this.pointAt(e,t),n=Math.floor(i.y/this.options.rowHeight),o=this.hitsByRow.get(n)??[];for(const a of o){if(a.avatar){const r=i.x-a.avatar.x,l=i.y-a.avatar.y;if(r*r+l*l<=a.avatar.r*a.avatar.r)return{hit:a,rowIndex:n,onAvatar:!0}}if(i.x>=a.x&&i.x<=a.x+a.w&&i.y>=a.y&&i.y<=a.y+a.h){const r=a.kind==="task"&&i.x<=a.x+Ji,l=a.kind==="task"&&i.x>=a.x+a.w-Ji;return{hit:{...a,mode:r?"resize-l":l?"resize-r":"move"},rowIndex:n,onAvatar:!1}}}return{hit:null,rowIndex:n,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=Ut[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 i=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 n=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(i,n),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,i){const n=document.createElement("button");return n.type="button",n.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(n.className="gt-ruler-btn gt-ruler-today"),n.textContent=e,n.title=t,n.addEventListener("click",o=>{o.stopPropagation(),i()}),n}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const t=this.totalDays*this.dayWidth-this.eScroll.clientWidth,i=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(t,i))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const n of Qi){const o=document.createElement("div");o.className="gt-step-item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(n===this.unit)),o.tabIndex=0,o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.setUnit(n),this.closeStepMenu())}),n===this.unit&&o.classList.add("gt-step-item-active"),o.textContent=Ut[n],o.addEventListener("click",a=>{a.stopPropagation(),this.setUnit(n),this.closeStepMenu()}),e.appendChild(o)}const t=this.eRulerTools.getBoundingClientRect(),i=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,i.right-t.right)}px`,e.style.top=`${t.bottom-i.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=Ut[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,t){this.closeAssigneePopup();const i=this.tasksById.get(e);if(!i)return;const n=document.createElement("div");n.className="gt-popup";const o=document.createElement("div");o.className="gt-popup-title",o.textContent="更换负责人",n.appendChild(o);for(const c of this.options.members){const d=document.createElement("div");d.className="gt-popup-item",i.owner===c.id&&d.classList.add("gt-popup-item-active");const u=document.createElement("span");u.className="gt-avatar",u.textContent=c.name.slice(0,1),u.style.backgroundColor=qt(c.id);const f=document.createElement("span");f.textContent=c.name,d.append(u,f),d.addEventListener("click",g=>{g.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,c.id)}),n.appendChild(d)}if(i.owner){const c=document.createElement("div");c.className="gt-popup-item gt-popup-clear",c.textContent="取消负责人",c.addEventListener("click",d=>{d.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),n.appendChild(c)}const a=this.eRoot.getBoundingClientRect(),r=t.x+t.w-this.eScroll.scrollLeft,l=t.y-this.eScroll.scrollTop;n.style.left=`${Math.min(a.width-150,Math.max(0,r-40))}px`,n.style.top=`${l+t.h+6}px`,this.eRoot.appendChild(n),this.ePopup=n,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const Je="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function wt(s,e,t,i,n,o){const a=Math.max(0,i),r=Math.max(0,n);if(a===0||r===0)return;const l=Math.max(0,Math.min(o,a/2,r/2));s.beginPath(),s.moveTo(e+l,t),s.lineTo(e+a-l,t),s.arcTo(e+a,t,e+a,t+l,l),s.lineTo(e+a,t+r-l),s.arcTo(e+a,t+r,e+a-l,t+r,l),s.lineTo(e+l,t+r),s.arcTo(e,t+r,e,t+r-l,l),s.lineTo(e,t+l),s.arcTo(e,t,e+l,t,l),s.closePath()}function di(s,e,t,i,n,o){s.beginPath(),s.arc(e,t,i,0,Math.PI*2),s.fillStyle=n,s.fill(),s.lineWidth=1.5,s.strokeStyle="#fff",s.stroke(),s.fillStyle="#fff",s.font=`10px ${Je}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function vs(s,e,t){if(t<=0)return"";if(s.measureText(e).width<=t)return e;let i=e.length;for(;i>1;){i--;const n=`${e.slice(0,i)}…`;if(s.measureText(n).width<=t)return n}return"…"}function tn(s,e,t,i,n,o,a){const l=n>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(i-5,t),s.quadraticCurveTo(i,t,i,t+5*l),s.lineTo(i,n-5*l),s.quadraticCurveTo(i,n,i+5*l,n),s.lineTo(o,a),s.stroke()}function Cs(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 nn=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function qt(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return nn[e%nn.length]}const ws=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],ys=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],bs=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Ae(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function yt(s,e,t){const i=document.createElement("button");return i.type="button",i.className=e,i.textContent=s,i.addEventListener("click",n=>{n.stopPropagation(),t()}),i}class Ss{constructor(e,t,i,n){v(this,"filterFields");v(this,"sortFields");v(this,"filterRows",[]);v(this,"sorts",[]);v(this,"filterPanel",null);v(this,"sortPanel",null);v(this,"filterAnchor",null);v(this,"sortAnchor",null);v(this,"onDocumentMouseDown",e=>{var i,n;const t=e.target;this.filterPanel&&!this.filterPanel.contains(t)&&!((i=this.filterAnchor)!=null&&i.contains(t))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(t)&&!((n=this.sortAnchor)!=null&&n.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=n,this.filterFields=i.filter,this.sortFields=i.sort,document.addEventListener("mousedown",this.onDocumentMouseDown,!0)}openFilterPanel(e){if(this.filterPanel){this.closeFilterPanel();return}this.closeSortPanel();const t=Ae("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",c=>c.stopPropagation());const i=Ae("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const n=Ae("div","gt-filter-rows");t.appendChild(n);const o=()=>{if(n.textContent="",!this.filterRows.length){const c=Ae("div","gt-panel-empty");c.textContent="点击下方字段添加筛选条件",n.appendChild(c)}for(const c of this.filterRows)n.appendChild(this.renderFilterRow(c,o))},a=Ae("div","gt-filter-add");for(const c of this.filterFields)a.appendChild(yt(c.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:c.colId,kind:c.kind,type:c.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const r=Ae("div","gt-panel-hint");r.textContent="多个条件同时满足(且)",t.appendChild(r);const l=Ae("div","gt-panel-actions");l.append(yt("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),yt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(l),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const i=Ae("div","gt-filter-row"),n=this.filterFields.find(c=>c.colId===e.colId),o=document.createElement("select");o.className="gt-panel-select";for(const c of this.filterFields){const d=document.createElement("option");d.value=c.colId,d.textContent=c.label,c.colId===e.colId&&(d.selected=!0),o.appendChild(d)}o.addEventListener("change",()=>{const c=this.filterFields.find(d=>d.colId===o.value);c&&(e.colId=c.colId,e.kind=c.kind,e.type=c.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),i.appendChild(o);const a=e.kind==="number"?ys:e.kind==="date"?bs:ws,r=document.createElement("select");r.className="gt-panel-select gt-panel-select-cond";for(const c of a){const d=document.createElement("option");d.value=c.value,d.textContent=c.label,c.value===e.type&&(d.selected=!0),r.appendChild(d)}if(r.addEventListener("change",()=>{e.type=r.value,t()}),i.appendChild(r),e.type!=="blank")if(n!=null&&n.options){const c=document.createElement("select");c.className="gt-panel-select";const d=document.createElement("option");d.value="",d.textContent="请选择",c.appendChild(d);for(const u of n.options){const f=document.createElement("option");f.value=u.value,f.textContent=u.label,u.value===e.value&&(f.selected=!0),c.appendChild(f)}c.addEventListener("change",()=>{e.value=c.value}),i.appendChild(c)}else if(e.kind==="date"){const c=document.createElement("input");if(c.type="date",c.className="gt-panel-input",c.value=e.value,c.addEventListener("change",()=>{e.value=c.value}),i.appendChild(c),e.type==="inRange"){const d=document.createElement("input");d.type="date",d.className="gt-panel-input",d.value=e.valueTo,d.addEventListener("change",()=>{e.valueTo=d.value}),i.appendChild(d)}}else if(e.kind==="number"){const c=document.createElement("input");if(c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="数值",c.value=e.value,c.addEventListener("input",()=>{e.value=c.value}),i.appendChild(c),e.type==="inRange"){const d=document.createElement("input");d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="至",d.value=e.valueTo,d.addEventListener("input",()=>{e.valueTo=d.value}),i.appendChild(d)}}else{const c=document.createElement("input");c.type="text",c.className="gt-panel-input",c.placeholder="文本",c.value=e.value,c.addEventListener("input",()=>{e.value=c.value}),i.appendChild(c)}const l=yt("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(c=>c!==e),t()});return l.title="移除条件",i.appendChild(l),i}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 i=(t.type==="after",t.value),n=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:i||void 0,dateTo:n||void 0};continue}if(t.value)if(t.kind==="number"){const i={filterType:"number",type:t.type,filter:Number(t.value)};t.type==="inRange"&&(i.filterTo=Number(t.valueTo||t.value)),e[t.colId]=i}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=Ae("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",r=>r.stopPropagation());const i=Ae("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const n=Ae("div","gt-sort-list");t.appendChild(n);const o=()=>{var r;n.textContent="";for(const l of this.sortFields){const c=this.sorts.findIndex(g=>g.colId===l.colId),d=c>=0,u=Ae("div","gt-sort-item");d&&u.classList.add("gt-sort-item-active");const f=Ae("span","gt-sort-label");if(f.textContent=l.label,u.appendChild(f),d){const g=Ae("span","gt-sort-badge");g.textContent=String(c+1),u.appendChild(g);const w=Ae("span","gt-sort-dir");w.textContent=((r=this.sorts[c])==null?void 0:r.sort)==="asc"?"↑ 升序":"↓ 降序",u.appendChild(w)}u.addEventListener("click",()=>{var g;d?((g=this.sorts[c])==null?void 0:g.sort)==="asc"?this.sorts[c]={colId:l.colId,sort:"desc"}:this.sorts=this.sorts.filter(w=>w.colId!==l.colId):this.sorts.push({colId:l.colId,sort:"asc"}),o()}),n.appendChild(u)}},a=Ae("div","gt-panel-actions");a.append(yt("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),yt("应用","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 i=t.getBoundingClientRect();e.style.top=`${i.bottom+6}px`;const n=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(i.left,n))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const xs={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 Es(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 i=e.onTaskOpen?null:Xi(t),n=k=>t.querySelector(k);n(".gantt-title-name").textContent=e.title??"甘特图";let o=structuredClone(e.tasks),a=new Map(o.map(k=>[k.id,k])),r,l,c=!0,d=!1;const u=n(".gantt-left");u.style.width=`${e.tableWidth??280}px`;const f=new AbortController,g=f.signal,p=n(".gantt-status");function C(){if(!r||d)return;m.setTasks(o);const k=Array.from({length:r.getDisplayedRowCount()},(Q,ne)=>r.getDisplayedRowAtIndex(ne)).filter(Boolean);m.setRows(k.map(Q=>({id:Q.id,group:!!Q.group,expanded:!!Q.expanded})));const z=o.filter(Q=>Q.path.length===1),_=z.filter(Q=>Q.status==="done").length;p.textContent=`总工作项数 ${z.length} 完成进度 ${z.length?Math.round(_/z.length*100):0}%`}function h(k){var Q;o=o.map(ne=>ne.id===k.id?{...k}:ne),a=new Map(o.map(ne=>[ne.id,ne]));const z=[k];let _=k.path.slice(0,-1);for(;_.length;){const ne=o.find(Z=>Z.path.join("/")===_.join("/"));if(!ne)break;const U=o.filter(Z=>Z.path.length===_.length+1&&Z.path.slice(0,-1).join("/")===_.join("/")),F=U.flatMap(Z=>Z.start?[Z.start]:[]).sort(),q=U.flatMap(Z=>Z.end?[Z.end]:[]).sort();ne.start=F[0]??null,ne.end=q[q.length-1]??null,z.push(ne),_=_.slice(0,-1)}r.applyTransaction({update:z}),C(),(Q=e.onTaskChange)==null||Q.call(e,structuredClone(k))}const m=new en(n(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:k=>{var _;m.setSelected(k);const z=k?r==null?void 0:r.getRowNode(k):null;z&&((_=r.selectNode)==null||_.call(r,z,!0))},onHover:k=>{var z;t.querySelectorAll(".ag-row-hover").forEach(_=>_.classList.remove("ag-row-hover")),k&&((z=Array.from(t.querySelectorAll(".ag-row")).find(_=>_.dataset.rowid===k))==null||z.classList.add("ag-row-hover"))},onTaskChange:h,onAssign:(k,z)=>{const _=a.get(k);_&&h({..._,owner:z})}});function y(k){const z=k.data,_=document.createElement("span");if(_.className="gt-task-name",z.path.length>1?_.classList.add("gt-child-name"):k.node.group||_.classList.add("gt-root-leaf"),z.path.length>1){const ne=document.createElement("span");ne.className=`gt-node-dot gt-node-${z.status}`,_.append(ne)}const Q=document.createElement("button");return Q.className="gt-title-link",Q.textContent=z.name,Q.title=z.name,Q.addEventListener("click",()=>{m.scrollToTask(z.id),e.onTaskOpen?e.onTaskOpen(structuredClone(z)):i==null||i.open({title:z.name,fields:[{label:"排期",value:`${z.start??"未设置"} — ${z.end??"未设置"}`}]})}),_.append(Q),_}const E=document.createElement("button");E.className="gt-tree-toggle",E.textContent="▾",E.title="收起全部子层级",E.setAttribute("aria-label",E.title);function R(k){c=k,k?r.expandAll():r.collapseAll(),E.textContent=k?"▾":"▸",E.title=k?"收起全部子层级":"展开全部子层级",E.setAttribute("aria-label",E.title),C()}E.addEventListener("click",()=>R(!c));const S=["name","status","start","end","owner","progress"].map(k=>({field:k,hide:!0,filter:!0}));l=new vt(n(".grid"),{columnDefs:S,rowData:o,treeData:!0,getDataPath:k=>k.path,getRowId:k=>k.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:Es,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const k=document.createElement("div");return k.className="gt-title-header",k.append(E,document.createTextNode("标题")),k},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:y}},onGridReady:k=>{r=k.api,C()},onModelUpdated:k=>{r=k.api,C()},onRowGroupOpened:C,onRowClicked:k=>{var z;return m.setSelected(((z=k.node)==null?void 0:z.id)??null)}}),r=l.getApi();const A=n(".ag-body-viewport");let B=!1;const L=(k,z)=>{B||(B=!0,z.scrollTop=k.scrollTop,B=!1)};A.addEventListener("scroll",()=>L(A,m.scrollElement),{signal:g}),m.scrollElement.addEventListener("scroll",()=>L(m.scrollElement,A),{signal:g}),A.addEventListener("mousemove",k=>{const z=k.target.closest(".ag-row");m.setHover((z==null?void 0:z.dataset.rowid)??null)},{signal:g}),A.addEventListener("mouseleave",()=>m.setHover(null),{signal:g});const j=new xs(r,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:k=>n('[data-action="filter"]').classList.toggle("gt-btn-active",k),onSortButton:k=>n('[data-action="sort"]').classList.toggle("gt-btn-active",k)});n('[data-action="filter"]').addEventListener("click",k=>j.openFilterPanel(k.currentTarget),{signal:g}),n('[data-action="sort"]').addEventListener("click",k=>j.openSortPanel(k.currentTarget),{signal:g}),n('[type="search"]').addEventListener("input",k=>r.setQuickFilter(k.target.value),{signal:g});const W=n(".gt-settings"),M=n('[data-action="settings"]');M.addEventListener("click",()=>{W.hidden=!W.hidden,M.setAttribute("aria-expanded",String(!W.hidden))},{signal:g}),document.addEventListener("pointerdown",k=>{!W.contains(k.target)&&!M.contains(k.target)&&(W.hidden=!0,M.setAttribute("aria-expanded","false"))},{signal:g});const D=Math.random().toString(36).slice(2);return W.querySelectorAll('[type="radio"]').forEach(k=>{const z=k.name;k.name=z+D,k.addEventListener("change",()=>{z==="theme"?m.setTheme(k.value):m.setMilestonesOnly(k.value==="milestones")},{signal:g})}),n('[data-setting="children"]').addEventListener("change",k=>m.setShowChildren(k.target.checked),{signal:g}),t.addEventListener("keydown",k=>{k.key==="Escape"&&(W.hidden=!0,j.closeAll())},{signal:g}),C(),e.unit&&m.setUnit(e.unit),m.scrollToToday(.5),{grid:r,chart:m,expandAll:()=>R(!0),collapseAll:()=>R(!1),scrollToTask:k=>m.scrollToTask(k),setTasks(k){o=structuredClone(k),a=new Map(o.map(z=>[z.id,z])),r.setRowData(o),C()},destroy(){d||(d=!0,f.abort(),j.destroy(),i==null||i.destroy(),m.destroy(),l.destroy(),t.remove())}}}const Fe=s=>Date.parse(`${s}T00:00:00Z`)/864e5,Oe=s=>new Date(s*864e5).toISOString().slice(0,10),on=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Fe(s))&&Oe(Fe(s))===s,Lt=s=>!!s.start&&!!s.end;function ui(s,e){const t=new Set(s.map(i=>i.id));if(t.size!==s.length||new Set(e.map(i=>i.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const i of e){if(!t.has(i.personId))throw new Error(`Unknown person: ${i.personId}`);if(!Number.isFinite(i.estimate)||i.estimate<0)throw new Error("Invalid estimate");if(!!i.start!=!!i.end||i.start&&i.end&&(!on(i.start)||!on(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function Ms(s,e=!1){const t=[];return s.filter(Lt).slice().sort((i,n)=>i.start.localeCompare(n.start)||i.id.localeCompare(n.id)).map(i=>{let n=e?t.length:t.findIndex(o=>o<Fe(i.start));return n<0&&(n=t.length),t[n]=Fe(i.end),{item:i,lane:n}})}function Kt(s){return{scheduled:s.filter(Lt).length,unscheduled:s.filter(e=>!Lt(e)).length,estimate:s.reduce((e,t)=>e+t.estimate,0)}}const we=s=>s.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),sn=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function ks(s,e){ui(e.people,e.items);let t=structuredClone(e.people),i=structuredClone(e.items);const n=e.today??new Date().toISOString().slice(0,10);let o=new Set(t.map(K=>K.id)),a=!1,r="",l="",c="",d=!1,u=1,f=!1,g=!1,p=!1,C=!0,h=Fe(n)-new Date(`${n}T00:00:00Z`).getUTCDay(),m=90,y=`${n.slice(0,7)}-01`,E=Oe(Date.UTC(Number(n.slice(0,4)),Number(n.slice(5,7))+1,0)/864e5),R=!1,S=!1;const A=document.createElement("section");A.className="personnel-schedule",A.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${we(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
34
+ </div>`,s.append(t);const i=e.onTaskOpen?null:Xi(t),n=N=>t.querySelector(N);n(".gantt-title-name").textContent=e.title??"甘特图";let o=structuredClone(e.tasks),a=new Map(o.map(N=>[N.id,N])),r,l,c=!0,d=!1;const u=n(".gantt-left");u.style.width=`${e.tableWidth??280}px`;const f=new AbortController,g=f.signal,w=n(".gantt-status");function h(){if(!r||d)return;m.setTasks(o);const N=Array.from({length:r.getDisplayedRowCount()},(Q,ie)=>r.getDisplayedRowAtIndex(ie)).filter(Boolean);m.setRows(N.map(Q=>({id:Q.id,group:!!Q.group,expanded:!!Q.expanded})));const z=o.filter(Q=>Q.path.length===1),_=z.filter(Q=>Q.status==="done").length;w.textContent=`总工作项数 ${z.length} 完成进度 ${z.length?Math.round(_/z.length*100):0}%`}function p(N){var Q;o=o.map(ie=>ie.id===N.id?{...N}:ie),a=new Map(o.map(ie=>[ie.id,ie]));const z=[N];let _=N.path.slice(0,-1);for(;_.length;){const ie=o.find(Z=>Z.path.join("/")===_.join("/"));if(!ie)break;const U=o.filter(Z=>Z.path.length===_.length+1&&Z.path.slice(0,-1).join("/")===_.join("/")),$=U.flatMap(Z=>Z.start?[Z.start]:[]).sort(),q=U.flatMap(Z=>Z.end?[Z.end]:[]).sort();ie.start=$[0]??null,ie.end=q[q.length-1]??null,z.push(ie),_=_.slice(0,-1)}r.applyTransaction({update:z}),h(),(Q=e.onTaskChange)==null||Q.call(e,structuredClone(N))}const m=new en(n(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:N=>{var _;m.setSelected(N);const z=N?r==null?void 0:r.getRowNode(N):null;z&&((_=r.selectNode)==null||_.call(r,z,!0))},onHover:N=>{var z;t.querySelectorAll(".ag-row-hover").forEach(_=>_.classList.remove("ag-row-hover")),N&&((z=Array.from(t.querySelectorAll(".ag-row")).find(_=>_.dataset.rowid===N))==null||z.classList.add("ag-row-hover"))},onTaskChange:p,onAssign:(N,z)=>{const _=a.get(N);_&&p({..._,owner:z})}});function y(N){const z=N.data,_=document.createElement("span");if(_.className="gt-task-name",z.path.length>1?_.classList.add("gt-child-name"):N.node.group||_.classList.add("gt-root-leaf"),z.path.length>1){const ie=document.createElement("span");ie.className=`gt-node-dot gt-node-${z.status}`,_.append(ie)}const Q=document.createElement("button");return Q.className="gt-title-link",Q.textContent=z.name,Q.title=z.name,Q.addEventListener("click",()=>{m.scrollToTask(z.id),e.onTaskOpen?e.onTaskOpen(structuredClone(z)):i==null||i.open({title:z.name,fields:[{label:"排期",value:`${z.start??"未设置"} — ${z.end??"未设置"}`}]})}),_.append(Q),_}const E=document.createElement("button");E.className="gt-tree-toggle",E.textContent="▾",E.title="收起全部子层级",E.setAttribute("aria-label",E.title);function R(N){c=N,N?r.expandAll():r.collapseAll(),E.textContent=N?"▾":"▸",E.title=N?"收起全部子层级":"展开全部子层级",E.setAttribute("aria-label",E.title),h()}E.addEventListener("click",()=>R(!c));const S=["name","status","start","end","owner","progress"].map(N=>({field:N,hide:!0,filter:!0}));l=new Ct(n(".grid"),{columnDefs:S,rowData:o,treeData:!0,getDataPath:N=>N.path,getRowId:N=>N.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:xs,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const N=document.createElement("div");return N.className="gt-title-header",N.append(E,document.createTextNode("标题")),N},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:y}},onGridReady:N=>{r=N.api,h()},onModelUpdated:N=>{r=N.api,h()},onRowGroupOpened:h,onRowClicked:N=>{var z;return m.setSelected(((z=N.node)==null?void 0:z.id)??null)}}),r=l.getApi();const P=n(".ag-body-viewport");let B=!1;const A=(N,z)=>{B||(B=!0,z.scrollTop=N.scrollTop,B=!1)};P.addEventListener("scroll",()=>A(P,m.scrollElement),{signal:g}),m.scrollElement.addEventListener("scroll",()=>A(m.scrollElement,P),{signal:g}),P.addEventListener("mousemove",N=>{const z=N.target.closest(".ag-row");m.setHover((z==null?void 0:z.dataset.rowid)??null)},{signal:g}),P.addEventListener("mouseleave",()=>m.setHover(null),{signal:g});const j=new Ss(r,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:N=>n('[data-action="filter"]').classList.toggle("gt-btn-active",N),onSortButton:N=>n('[data-action="sort"]').classList.toggle("gt-btn-active",N)});n('[data-action="filter"]').addEventListener("click",N=>j.openFilterPanel(N.currentTarget),{signal:g}),n('[data-action="sort"]').addEventListener("click",N=>j.openSortPanel(N.currentTarget),{signal:g}),n('[type="search"]').addEventListener("input",N=>r.setQuickFilter(N.target.value),{signal:g});const W=n(".gt-settings"),T=n('[data-action="settings"]');T.addEventListener("click",()=>{W.hidden=!W.hidden,T.setAttribute("aria-expanded",String(!W.hidden))},{signal:g}),document.addEventListener("pointerdown",N=>{!W.contains(N.target)&&!T.contains(N.target)&&(W.hidden=!0,T.setAttribute("aria-expanded","false"))},{signal:g});const F=Math.random().toString(36).slice(2);return W.querySelectorAll('[type="radio"]').forEach(N=>{const z=N.name;N.name=z+F,N.addEventListener("change",()=>{z==="theme"?m.setTheme(N.value):m.setMilestonesOnly(N.value==="milestones")},{signal:g})}),n('[data-setting="children"]').addEventListener("change",N=>m.setShowChildren(N.target.checked),{signal:g}),t.addEventListener("keydown",N=>{N.key==="Escape"&&(W.hidden=!0,j.closeAll())},{signal:g}),h(),e.unit&&m.setUnit(e.unit),m.scrollToToday(.5),{grid:r,chart:m,expandAll:()=>R(!0),collapseAll:()=>R(!1),scrollToTask:N=>m.scrollToTask(N),setTasks(N){o=structuredClone(N),a=new Map(o.map(z=>[z.id,z])),r.setRowData(o),h()},destroy(){d||(d=!0,f.abort(),j.destroy(),i==null||i.destroy(),m.destroy(),l.destroy(),t.remove())}}}const Fe=s=>Date.parse(`${s}T00:00:00Z`)/864e5,Oe=s=>new Date(s*864e5).toISOString().slice(0,10),on=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Fe(s))&&Oe(Fe(s))===s,Lt=s=>!!s.start&&!!s.end;function ui(s,e){const t=new Set(s.map(i=>i.id));if(t.size!==s.length||new Set(e.map(i=>i.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const i of e){if(!t.has(i.personId))throw new Error(`Unknown person: ${i.personId}`);if(!Number.isFinite(i.estimate)||i.estimate<0)throw new Error("Invalid estimate");if(!!i.start!=!!i.end||i.start&&i.end&&(!on(i.start)||!on(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function Rs(s,e=!1){const t=[];return s.filter(Lt).slice().sort((i,n)=>i.start.localeCompare(n.start)||i.id.localeCompare(n.id)).map(i=>{let n=e?t.length:t.findIndex(o=>o<Fe(i.start));return n<0&&(n=t.length),t[n]=Fe(i.end),{item:i,lane:n}})}function Kt(s){return{scheduled:s.filter(Lt).length,unscheduled:s.filter(e=>!Lt(e)).length,estimate:s.reduce((e,t)=>e+t.estimate,0)}}const we=s=>s.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),sn=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function Ms(s,e){ui(e.people,e.items);let t=structuredClone(e.people),i=structuredClone(e.items);const n=e.today??new Date().toISOString().slice(0,10);let o=new Set(t.map(K=>K.id)),a=!1,r="",l="",c="",d=!1,u=1,f=!1,g=!1,w=!1,h=!0,p=Fe(n)-new Date(`${n}T00:00:00Z`).getUTCDay(),m=90,y=`${n.slice(0,7)}-01`,E=Oe(Date.UTC(Number(n.slice(0,4)),Number(n.slice(5,7))+1,0)/864e5),R=!1,S=!1;const P=document.createElement("section");P.className="personnel-schedule",P.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${we(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
35
35
  <div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${we(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>
36
36
  <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>
37
- <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(A);const B=K=>A.querySelector(K),L=B(".ps-scroll"),j=B(".ps-rows"),W=B(".ps-popover"),M=B(".ps-detail"),D=new AbortController,k=D.signal;let z;const _=()=>[22,43,64,86,120][u],Q=()=>i.filter(K=>(!r||K.name.includes(r))&&(!l||K.status===l)&&(g||!K.parentId)),ne=()=>{const K=Q();return t.filter(X=>o.has(X.id)&&(!a||K.some(J=>J.personId===X.id&&Lt(J)))).sort((X,J)=>{if(!c)return 0;const Y=Kt(K.filter(pe=>pe.personId===X.id)),oe=Kt(K.filter(pe=>pe.personId===J.id));return(c==="estimate"?Y.estimate-oe.estimate:Y.scheduled-oe.scheduled)*(d?-1:1)})};function U(K){const X=B(".ps-toast");X.textContent=K,X.hidden=!1,clearTimeout(z),z=setTimeout(()=>X.hidden=!0,2200)}function F(){if(R)return;const K=_(),X=m*K;B(".ps-table").style.width=`${X+200}px`;const J=`${y.slice(0,4)}年 第${Number(y.slice(5,7))}-${Number(E.slice(5,7))}月`;B(".ps-date-label").textContent=J,B('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,B(".ps-zoom").value=String(u);const Y=B(".ps-weeks");Y.replaceChildren();for(let ke=0;ke<m;ke+=7){const Be=document.createElement("span");Be.style.width=`${Math.min(7,m-ke)*K}px`,Be.textContent=`${Oe(h+ke).slice(5).replace("-","/")}~${Oe(h+ke+6).slice(5).replace("-","/")}`,Y.append(Be)}j.replaceChildren();const oe=Q(),pe=ne();for(const ke of pe){const Be=oe.filter(me=>me.personId===ke.id),Le=Kt(Be),bt=Ms(Be,f),ze=Math.max(0,...bt.map(me=>me.lane)),ei=Math.max(p?154:126,60+(ze+1)*(p?48:36)),ht=document.createElement("div");ht.className="ps-person-row",ht.style.height=`${ei}px`,ht.dataset.person=ke.id;const St=document.createElement("div");St.className="ps-person",St.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${we(ke.name)}</strong></div><div>已排期项 <b>${Le.scheduled}</b></div><div>总估分 <b>${Le.estimate.toFixed(2)}</b></div><div>未排期·${Le.unscheduled}<button data-action="unplanned" data-person="${we(ke.id)}">查看</button></div>`;const $t=St.querySelector(".ps-avatar");$t.textContent=ke.name.slice(-2),$t.style.background=ke.color||sn[t.indexOf(ke)%sn.length];const We=document.createElement("div");We.className="ps-timeline",We.style.width=`${X}px`,We.style.setProperty("--day",`${K}px`);for(let me=0;me<m;me++)if([0,6].includes(new Date((h+me)*864e5).getUTCDay())){const ot=document.createElement("i");ot.className="ps-weekend",ot.style.left=`${me*K}px`,ot.style.width=`${K}px`,We.append(ot)}const pt=Fe(n)-h;if(pt>=0&&pt<m){const me=document.createElement("i");me.className="ps-today",me.style.left=`${(pt+.5)*K}px`,We.append(me)}for(const{item:me,lane:ot}of bt){const st=Fe(me.start),Ue=Fe(me.end);if(Ue<h||st>=h+m)continue;const at=Math.max(0,st-h)*K,xt=Math.min(m,Ue-h+1)*K,Ve=document.createElement("button");Ve.className=`ps-bar ${C?"ps-color":"ps-content"}`,Ve.dataset.item=me.id,Ve.setAttribute("aria-label",`${me.name},${me.start} 至 ${me.end}`),Ve.style.left=`${at}px`,Ve.style.width=`${xt-at}px`,Ve.style.top=`${52+ot*(p?48:36)}px`,Ve.style.setProperty("--bar-color",me.color||"#8cafeb"),Ve.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${we(me.name)}</span><span class="ps-status">${we(me.status)}</span><span class="ps-node">● ${we(me.node)}</span><span class="ps-effort">${me.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,We.append(Ve)}if(!bt.length){const me=document.createElement("span");me.className="ps-no-schedule",me.textContent="暂无排期",We.append(me)}ht.append(St,We),j.append(ht)}pe.length||(j.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const Te=oe.filter(ke=>pe.some(Be=>Be.id===ke.personId));B(".ps-total").textContent=`ⓘ 总人数 ${pe.length} 总估分 ${Kt(Te).estimate.toFixed(2)} pd ···`}function q(K,X){if(!W.hidden&&W.dataset.kind===K){W.hidden=!0;return}W.dataset.kind=K,W.hidden=!1;const J=A.getBoundingClientRect(),Y=X==null?void 0:X.getBoundingClientRect();if(W.style.left=`${Math.max(12,Math.min(((Y==null?void 0:Y.left)??J.left)-J.left,A.clientWidth-(K==="unplanned"?760:420)-16))}px`,W.style.top=`${Y?Y.bottom-J.top+6:96}px`,W.className=`ps-popover ps-panel-${K}`,K==="people")W.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(oe=>`<label><input type="checkbox" data-person="${we(oe.id)}" ${o.has(oe.id)?"checked":""}>${we(oe.name)}</label>`).join("")}</div>`;else if(K==="sort")W.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="${d?"":"selected"}">小 → 大</button><button data-action="desc" class="${d?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,W.querySelector("select").value=c;else if(K==="filter")W.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${we(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${we(r)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(oe=>oe.status))].map(oe=>`<option>${we(oe)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,W.querySelector("select").value=l;else if(K==="settings")W.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${f?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${g?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${p?"":"selected"}">紧凑</button><button data-action="loose" class="${p?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${C?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${C?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(K==="date")be();else if(K==="save")W.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(K==="views"){const oe=ut();W.innerHTML=`<div class="ps-panel-title">视图列表</div>${oe.length?oe.map((pe,Te)=>`<button class="ps-view" data-view="${Te}">▦ ${we(pe.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let Z=new Date(`${y}T00:00:00Z`),ie=!1;function be(){let K=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${y}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${E}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let X=0;X<2;X++){const J=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+X,1));K+=`<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(oe=>`<span>${oe}</span>`).join("")}`;for(let oe=0;oe<J.getUTCDay();oe++)K+="<span></span>";const Y=new Date(Date.UTC(J.getUTCFullYear(),J.getUTCMonth()+1,0)).getUTCDate();for(let oe=1;oe<=Y;oe++){const pe=Oe(Date.UTC(J.getUTCFullYear(),J.getUTCMonth(),oe)/864e5);K+=`<button data-date="${pe}" class="${pe>=y&&pe<=E?"in-range":""} ${pe===y||pe===E?"selected":""}">${oe}</button>`}K+="</div></div>"}W.innerHTML=K+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((X,J)=>`<button data-preset="${J}">${X}</button>`).join("")}</div>`}function fe(){E<y&&([y,E]=[E,y]),h=Fe(y),h-=new Date(h*864e5).getUTCDay(),m=Math.max(35,Fe(E)-h+8),L.scrollLeft=0,F()}function ue(K,X){var oe;if(!i.some(pe=>pe.id===K))throw new Error(`Unknown schedule item: ${K}`);const J=i.map(pe=>pe.id===K?{...pe,...X}:pe);ui(t,J),i=J,F();const Y=i.find(pe=>pe.id===K);Y&&((oe=e.onItemChange)==null||oe.call(e,structuredClone(Y)))}function Ne(K){var J;const X=i.find(Y=>Y.id===K);(J=e.onItemOpen)==null||J.call(e,structuredClone(X)),M.hidden=!1,M.dataset.item=K,M.innerHTML=`<header><strong>${we(X.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${we(X.status)}</span><h3>● ${we(X.node)}</h3><form><label>名称<input name="name" required value="${we(X.name)}"></label><label>负责人<select name="personId">${t.map(Y=>`<option value="${we(Y.id)}" ${Y.id===X.personId?"selected":""}>${we(Y.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${X.estimate}" required></label><label>开始日期<input type="date" name="start" value="${X.start||""}"></label><label>结束日期<input type="date" name="end" value="${X.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 dt(K,X){q("unplanned",X),W.hidden=!1;const J=t.find(Y=>Y.id===K);W.innerHTML=`<div class="ps-panel-title">未排期工作项 ${we(J.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(Y=>Y.personId===K&&!Lt(Y)).map(Y=>`<tr><td><button data-open="${we(Y.id)}">${we(Y.name)}</button></td><td>● ${we(Y.node)}</td><td><input type="number" min="0" step="0.1" value="${Y.estimate||""}" placeholder="待填" data-estimate="${we(Y.id)}" aria-label="${we(Y.name)}估分"></td><td><button class="ps-link" data-open="${we(Y.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const Zt=e.viewStorageKey??"rowvia-personnel-views-v1";function ut(){try{const K=JSON.parse(localStorage.getItem(Zt)||"[]");return Array.isArray(K)?K:[]}catch{return[]}}A.addEventListener("click",K=>{const X=K.target,J=X.closest("button");if(!J)return;if(J.dataset.open){W.hidden=!0,Ne(J.dataset.open);return}if(J.dataset.item){S||Ne(J.dataset.item);return}if(J.dataset.date){ie?(E=J.dataset.date,ie=!1,fe()):(y=J.dataset.date,E=y,ie=!0),be();return}if(J.dataset.preset){const oe=Number(J.dataset.preset),pe=Fe(n),Te=new Date(pe*864e5);y=Oe(oe<2?pe-Te.getUTCDay():oe<4?Date.UTC(Te.getUTCFullYear(),Te.getUTCMonth(),1)/864e5:pe),E=Oe(oe===2||oe===3?Date.UTC(Te.getUTCFullYear(),Te.getUTCMonth()+(oe===2?1:2),0)/864e5:Fe(y)+[6,13,29,60,13,59,364][oe]),ie=!1,fe(),W.hidden=!0;return}if(J.dataset.view){const oe=ut()[Number(J.dataset.view)];oe&&(o=new Set(oe.selected.filter(pe=>t.some(Te=>Te.id===pe))),{query:r,status:l,sort:c,descending:d,zoom:u,from:h,days:m,rangeStart:y,rangeEnd:E,expanded:f,children:g,loose:p,colorFirst:C,onlyScheduled:a}=oe,F(),W.hidden=!0,U(`已打开 ${oe.name}`));return}const Y=J.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(Y||"")){q(Y,J);return}if(Y==="unplanned"){dt(J.dataset.person,J);return}if(Y==="close-detail"&&(M.hidden=!0),Y==="unschedule"&&(ue(M.dataset.item,{start:null,end:null}),M.hidden=!0),(Y==="plus"||Y==="minus")&&(u=Math.max(0,Math.min(4,u+(Y==="plus"?1:-1))),F()),(Y==="prev"||Y==="next"||Y==="today")&&(h=Y==="today"?Fe(n)-new Date(`${n}T00:00:00Z`).getUTCDay():h+(Y==="prev"?-14:14),y=Oe(h),E=Oe(h+59),L.scrollLeft=0,F()),(Y==="asc"||Y==="desc"||Y==="clear-sort")&&(d=Y==="desc",Y==="clear-sort"&&(c=""),F(),W.hidden=!0),Y==="clear-filter"&&(r="",l="",F(),W.hidden=!0),["compact","loose","content","color"].includes(Y||"")&&(Y==="compact"||Y==="loose"?p=Y==="loose":C=Y==="color",F(),W.hidden=!0,q("settings",B('[data-action="settings"]'))),(Y==="cal-prev"||Y==="cal-next")&&(Z=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+(Y==="cal-prev"?-1:1),1)),be()),Y==="save-view"){const oe=W.querySelector("[data-view-name]").value.trim();if(!oe)return;const pe=ut();pe.push({name:oe,selected:[...o],query:r,status:l,sort:c,descending:d,zoom:u,from:h,days:m,rangeStart:y,rangeEnd:E,expanded:f,children:g,loose:p,colorFirst:C,onlyScheduled:a});try{localStorage.setItem(Zt,JSON.stringify(pe)),W.hidden=!0,U("视图已保存")}catch{U("浏览器存储不可用,视图未保存")}}Y==="schedule"&&(W.hidden=!0,M.hidden=!0)},{signal:k}),A.addEventListener("input",K=>{const X=K.target;X.classList.contains("ps-zoom")&&(u=Number(X.value),F()),X.classList.contains("ps-person-search")&&W.querySelectorAll(".ps-person-options label").forEach(J=>{var Y;return J.hidden=!((Y=J.textContent)!=null&&Y.includes(X.value))}),X.dataset.control==="query"&&(r=X.value,F())},{signal:k}),A.addEventListener("change",K=>{const X=K.target;if(X.dataset.person&&(X.checked?o.add(X.dataset.person):o.delete(X.dataset.person),F()),X.dataset.estimate){const J=Number(X.value);Number.isFinite(J)&&J>=0&&ue(X.dataset.estimate,{estimate:J});return}switch(X.dataset.control){case"only":a=X.checked;break;case"sort":c=X.value;break;case"status":l=X.value;break;case"expanded":f=X.checked;break;case"children":g=X.checked;break;case"range-start":X.value&&(y=X.value,fe(),be());return;case"range-end":X.value&&(E=X.value,fe(),be());return}F()},{signal:k}),M.addEventListener("submit",K=>{K.preventDefault();const X=new FormData(K.target),J=String(X.get("start")||"")||null,Y=String(X.get("end")||"")||null;if(!!J!=!!Y||J&&Y&&J>Y){M.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ue(M.dataset.item,{name:String(X.get("name")),personId:String(X.get("personId")),estimate:Number(X.get("estimate")),start:J,end:Y}),M.hidden=!0,U("排期已更新")},{signal:k}),document.addEventListener("pointerdown",K=>{A.contains(K.target)?!W.contains(K.target)&&!K.target.closest("[data-action]")&&(W.hidden=!0):W.hidden=!0},{signal:k}),A.addEventListener("keydown",K=>{K.key==="Escape"&&(W.hidden=!0,M.hidden=!0)},{signal:k});let Ce=null;return j.addEventListener("pointerdown",K=>{const X=K.target,J=X.closest(".ps-bar");if(!J||K.button!==0)return;const Y=i.find(oe=>oe.id===J.dataset.item);S=!1,Ce={id:Y.id,x:K.clientX,start:Fe(Y.start),end:Fe(Y.end),edge:X.dataset.edge||"move",bar:J,left:parseFloat(J.style.left),size:parseFloat(J.style.width),delta:0,scroll:L.scrollLeft}},{signal:k}),document.addEventListener("pointermove",K=>{if(!Ce)return;const X=Math.round((K.clientX-Ce.x+L.scrollLeft-Ce.scroll)/_());Ce.delta=Ce.edge==="start"?Math.min(X,Ce.end-Ce.start):Ce.edge==="end"?Math.max(X,Ce.start-Ce.end):X,Math.abs(K.clientX-Ce.x)>4&&(S=!0),S&&(Ce.bar.style.opacity=".8",Ce.edge==="move"?Ce.bar.style.transform=`translateX(${Ce.delta*_()}px)`:(Ce.bar.style.left=`${Ce.left+(Ce.edge==="start"?Ce.delta*_():0)}px`,Ce.bar.style.width=`${Ce.size+(Ce.edge==="start"?-1:1)*Ce.delta*_()}px`))},{signal:k}),document.addEventListener("pointerup",()=>{if(!Ce)return;const K=Ce;Ce=null,S&&(ue(K.id,{start:Oe(K.start+(K.edge==="end"?0:K.delta)),end:Oe(K.end+(K.edge==="start"?0:K.delta))}),U("排期已更新"))},{signal:k}),F(),{setData(K,X){ui(K,X),t=structuredClone(K),i=structuredClone(X),o=new Set(t.map(J=>J.id)),W.hidden=!0,M.hidden=!0,F()},getItems:()=>structuredClone(i),updateItem:ue,setPeople(K){o=new Set(K.filter(X=>t.some(J=>J.id===X))),F()},destroy(){R=!0,D.abort(),clearTimeout(z),A.remove()}}}function Dt(s,e,t,i){const n=document.createElement("section");n.className=`rowvia-${e}`,n.innerHTML=t,s.append(n);let o=null,a=!1;const r=new Set,l=[];return{host:n,handle:{get api(){return(o==null?void 0:o.api)??null},get columnApi(){return(o==null?void 0:o.columnApi)??null},destroy(){a||(a=!0,r.forEach(u=>{window.clearTimeout(u),window.clearInterval(u)}),l.forEach(u=>u()),o==null||o.grid.destroy(),o=null,n.remove())}},timeout:(u,f)=>{const g=window.setTimeout(()=>{r.delete(g),a||u()},f);return r.add(g),g},cleanup(u){l.push(u)},interval(u,f){const g=window.setInterval(()=>{a||u()},f);return r.add(g),g},createGrid(u,f){return o=xi(u,{...f,...i.gridOptions}),o}}}function hi(s=42){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}const Ts=["Michael","Emma","Daniel","Olivia","James","Sophia","William","Ava","Benjamin","Isabella","Lucas","Mia","Henry","Charlotte","Alexander","Amelia","Noah","Harper","Ethan","Evelyn","Jacob","Abigail","Leo","Emily","Nathan","Elizabeth","Aaron","Sofia","Caleb","Avery","Isaac","Ella","Owen","Scarlett","Wyatt","Grace","Julian","Chloe","Miles","Victoria"],Ns=["Bridges","Stone","Collins","Reyes","Fisher","Lambert","Walsh","Harper","Keller","Novak","Silva","Weaver","Grant","Holloway","Mercer","Draper","Whitfield","Calloway","Prescott","Vance","Ellington","Monroe","Sinclair","Barlow"],Is=[{name:"France",flag:"🇫🇷"},{name:"Spain",flag:"🇪🇸"},{name:"United Kingdom",flag:"🇬🇧"},{name:"Netherlands",flag:"🇳🇱"},{name:"Portugal",flag:"🇵🇹"},{name:"Italy",flag:"🇮🇹"},{name:"United States",flag:"🇺🇸"},{name:"Ireland",flag:"🇮🇪"}],jt={executiveManagement:"Executive Management",legal:"Legal",design:"Design",engineering:"Engineering",product:"Product",customerSupport:"Customer Support"},Ls=Object.keys(jt),Xe=hi(7);function At(s){return s[Math.floor(Xe()*s.length)]}function Ds(){return`${At(Ts)} ${At(Ns)}`}function As(){const s=2015+Math.floor(Xe()*10),e=1+Math.floor(Xe()*12),t=1+Math.floor(Xe()*28);return`${s}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function yt(s,e,t){const i=s[s.length-1],n=At(Is);return{orgHierarchy:s,contact:i.replace(/\s+/g,"."),jobTitle:e,employmentType:Xe()<.7?"Permanent":"Contract",department:t,employeeId:0,location:n.name,joinDate:As(),basicMonthlySalary:2500+Math.floor(Xe()*60)*250,currency:At(["GBP","EUR","USD"]),paymentMethod:At(["Bank Transfer","Cash","Check"]),paymentStatus:Xe()<.65?"paid":"pending",image:String(1+Math.floor(Xe()*36)),flag:n.flag}}function Fs(){const s=[];let e=1001;const t="Will Bridges",i=["Michael Johnson","Sophie Turner","Ravi Patel"],n={engineering:"Nina Alvarez",design:"Tom Whitaker",product:"Grace Liu",legal:"Hannah Ford",customerSupport:"Marc Duval",executiveManagement:"Oliver Grant"},o=a=>{s.push({...a,employeeId:e++})};o(yt([t],"CEO","executiveManagement")),o(yt([t,i[0]],"COO","executiveManagement")),o(yt([t,i[1]],"CTO","executiveManagement")),o(yt([t,i[2]],"Exec. Vice President","executiveManagement"));for(const a of Ls){const r=n[a],l=a==="executiveManagement"?i[1]:i[Math.floor(Xe()*3)];o(yt([t,l,r],"Head of Department",a));const c=6+Math.floor(Xe()*4);for(let d=0;d<c;d++){const u=Ds();o(yt([t,l,r,u],"Employee",a))}}return s}const pi=hi(1337),Ps=[["US10Y","U.S. Treasury 10-Year Bond","Bond"],["MUB","iShares National Muni Bond ETF","ETF"],["BRK.B","Berkshire Hathaway Inc. Class B","Stock"],["VOO","Vanguard S&P 500 ETF","ETF"],["QQQ","Invesco QQQ Trust","ETF"],["AAPL","Apple Inc.","Stock"],["MSFT","Microsoft Corporation","Stock"],["GOOGL","Alphabet Inc. Class A","Stock"],["AMZN","Amazon.com Inc.","Stock"],["TSLA","Tesla Inc.","Stock"],["NVDA","NVIDIA Corporation","Stock"],["META","Meta Platforms Inc.","Stock"],["JPM","JPMorgan Chase & Co.","Stock"],["V","Visa Inc.","Stock"],["UNH","UnitedHealth Group Inc.","Stock"],["XOM","Exxon Mobil Corporation","Stock"],["JNJ","Johnson & Johnson","Stock"],["WMT","Walmart Inc.","Stock"],["MA","Mastercard Inc.","Stock"],["PG","Procter & Gamble Co.","Stock"],["CVX","Chevron Corporation","Stock"],["HD","Home Depot Inc.","Stock"],["ORCL","Oracle Corporation","Stock"],["MRK","Merck & Co. Inc.","Stock"],["ABBV","AbbVie Inc.","Stock"],["PEP","PepsiCo Inc.","Stock"],["KO","Coca-Cola Co.","Stock"],["COST","Costco Wholesale Corp.","Stock"],["BAC","Bank of America Corp.","Stock"],["MCD","McDonald's Corp.","Stock"],["CSCO","Cisco Systems Inc.","Stock"],["PFE","Pfizer Inc.","Stock"],["CRM","Salesforce Inc.","Stock"],["TMO","Thermo Fisher Scientific Inc.","Stock"],["AVGO","Broadcom Inc.","Stock"],["ACN","Accenture plc","Stock"],["LIN","Linde plc","Stock"],["AMD","Advanced Micro Devices Inc.","Stock"],["NFLX","Netflix Inc.","Stock"],["DIS","Walt Disney Co.","Stock"],["TXN","Texas Instruments Inc.","Stock"],["WFC","Wells Fargo & Co.","Stock"],["PM","Philip Morris International Inc.","Stock"],["VZ","Verizon Communications Inc.","Stock"],["INTC","Intel Corporation","Stock"],["CMCSA","Comcast Corp.","Stock"],["NKE","NIKE Inc.","Stock"],["DHR","Danaher Corporation","Stock"],["UNP","Union Pacific Corp.","Stock"],["MS","Morgan Stanley","Stock"],["RTX","RTX Corporation","Stock"],["LOW","Lowe's Companies Inc.","Stock"],["SPGI","S&P Global Inc.","Stock"],["INTU","Intuit Inc.","Stock"],["GS","Goldman Sachs Group Inc.","Stock"],["BDX","Becton Dickinson & Co.","Stock"],["SCHW","Charles Schwab Corp.","Stock"],["NOW","ServiceNow Inc.","Stock"],["ISRG","Intuitive Surgical Inc.","Stock"],["AMAT","Applied Materials Inc.","Stock"],["GE","GE Aerospace","Stock"],["CAT","Caterpillar Inc.","Stock"],["BLK","BlackRock Inc.","Stock"],["AXP","American Express Co.","Stock"],["TJX","TJX Companies Inc.","Stock"],["GILD","Gilead Sciences Inc.","Stock"],["SYK","Stryker Corporation","Stock"],["MDT","Medtronic plc","Stock"],["C","Citigroup Inc.","Stock"],["CB","Chubb Limited","Stock"],["ZTS","Zoetis Inc.","Stock"],["MMC","Marsh & McLennan Cos. Inc.","Stock"],["ADP","Automatic Data Processing Inc.","Stock"],["CI","Cigna Group","Stock"],["SO","Southern Co.","Stock"],["ETN","Eaton Corp. plc","Stock"],["BSX","Boston Scientific Corp.","Stock"],["PLD","Prologis Inc.","Stock"],["ITW","Illinois Tool Works Inc.","Stock"],["HON","Honeywell International Inc.","Stock"],["MU","Micron Technology Inc.","Stock"],["DE","Deere & Co.","Stock"],["AMT","American Tower Corp.","Stock"],["WM","Waste Management Inc.","Stock"],["LRCX","Lam Research Corp.","Stock"],["CSX","CSX Corporation","Stock"],["ICE","Intercontinental Exchange Inc.","Stock"],["CL","Colgate-Palmolive Co.","Stock"],["SHW","Sherwin-Williams Co.","Stock"],["FI","Fiserv Inc.","Stock"],["USB","U.S. Bancorp","Stock"],["PNC","PNC Financial Services Group Inc.","Stock"],["APH","Amphenol Corporation","Stock"],["NOC","Northrop Grumman Corp.","Stock"],["GD","General Dynamics Corp.","Stock"],["MSI","Motorola Solutions Inc.","Stock"],["TGT","Target Corporation","Stock"],["F","Ford Motor Co.","Stock"],["GM","General Motors Co.","Stock"],["BTC","Bitcoin","Crypto"],["ETH","Ethereum","Crypto"],["SOL","Solana","Crypto"],["USDC","USD Coin","Crypto"],["XRP","XRP","Crypto"],["ADA","Cardano","Crypto"],["DOT","Polkadot","Crypto"],["LINK","Chainlink","Crypto"],["AGG","iShares Core U.S. Aggregate Bond ETF","ETF"],["BND","Vanguard Total Bond Market ETF","ETF"],["LQD","iShares iBoxx $ Investment Grade Corp Bond ETF","ETF"],["HYG","iShares iBoxx $ High Yield Corp Bond ETF","ETF"],["TLT","iShares 20+ Year Treasury Bond ETF","ETF"],["IWM","iShares Russell 2000 ETF","ETF"],["EEM","iShares MSCI Emerging Markets ETF","ETF"],["VGK","Vanguard FTSE Europe ETF","ETF"],["VWO","Vanguard FTSE Emerging Markets ETF","ETF"],["XLE","Energy Select Sector SPDR Fund","ETF"],["XLF","Financial Select Sector SPDR Fund","ETF"],["XLK","Technology Select Sector SPDR Fund","ETF"],["XLV","Health Care Select Sector SPDR Fund","ETF"],["GLD","SPDR Gold Shares","ETF"],["SLV","iShares Silver Trust","ETF"],["USO","United States Oil Fund","ETF"],["VIXY","ProShares VIX Short-Term Futures ETF","ETF"],["ARKK","ARK Innovation ETF","ETF"],["SPY","SPDR S&P 500 ETF Trust","ETF"]],an=["#2196f3","#4caf50","#ff9800","#9c27b0","#f44336","#00bcd4","#795548","#607d8b","#e91e63","#3f51b5","#009688","#ffc107"];function $s(s){let e=0;for(let o=0;o<s.length;o++)e=e*31+s.charCodeAt(o)>>>0;const t=an[e%an.length],i=s.replace(/[^A-Za-z]/g,"").slice(0,2).toUpperCase()||s.slice(0,2).toUpperCase(),n=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"><rect width="40" height="40" rx="20" fill="${t}"/><text x="20" y="26" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#fff" text-anchor="middle">${i}</text></svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`}function Gs(s){const e=[];let t=s*(.9+pi()*.2);for(let i=0;i<24;i++)t=t*(1+(pi()-.5)*.04),e.push(Number(t.toFixed(2)));return e}function Hs(){return Ps.map(([s,e,t])=>{const i=Number((Math.random()*40+10).toFixed(2)),n=Number((Math.random()*40+10).toFixed(2));return{ticker:s,name:e,instrument:t,quantity:10+Math.floor(pi()*500),purchaseDate:"2023-04-11",purchasePrice:i,price:n,timeline:Gs(n)}})}function Os(s){for(const e of s)if(Math.random()<.1){const t=Math.random()*.2,i=1-t+Math.random()*t*2;e.price<10?e.price=e.price*i:e.price=Math.random()*40+10,e.price=Number(e.price.toFixed(2)),e.timeline=e.timeline.slice(1,e.timeline.length).concat(e.price)}}function Bs(s,e={}){var C,h;const t=Dt(s,"finance",`<div id="app">
37
+ <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(P);const B=K=>P.querySelector(K),A=B(".ps-scroll"),j=B(".ps-rows"),W=B(".ps-popover"),T=B(".ps-detail"),F=new AbortController,N=F.signal;let z;const _=()=>[22,43,64,86,120][u],Q=()=>i.filter(K=>(!r||K.name.includes(r))&&(!l||K.status===l)&&(g||!K.parentId)),ie=()=>{const K=Q();return t.filter(X=>o.has(X.id)&&(!a||K.some(J=>J.personId===X.id&&Lt(J)))).sort((X,J)=>{if(!c)return 0;const Y=Kt(K.filter(pe=>pe.personId===X.id)),ne=Kt(K.filter(pe=>pe.personId===J.id));return(c==="estimate"?Y.estimate-ne.estimate:Y.scheduled-ne.scheduled)*(d?-1:1)})};function U(K){const X=B(".ps-toast");X.textContent=K,X.hidden=!1,clearTimeout(z),z=setTimeout(()=>X.hidden=!0,2200)}function $(){if(R)return;const K=_(),X=m*K;B(".ps-table").style.width=`${X+200}px`;const J=`${y.slice(0,4)}年 第${Number(y.slice(5,7))}-${Number(E.slice(5,7))}月`;B(".ps-date-label").textContent=J,B('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,B(".ps-zoom").value=String(u);const Y=B(".ps-weeks");Y.replaceChildren();for(let ke=0;ke<m;ke+=7){const Be=document.createElement("span");Be.style.width=`${Math.min(7,m-ke)*K}px`,Be.textContent=`${Oe(p+ke).slice(5).replace("-","/")}~${Oe(p+ke+6).slice(5).replace("-","/")}`,Y.append(Be)}j.replaceChildren();const ne=Q(),pe=ie();for(const ke of pe){const Be=ne.filter(ve=>ve.personId===ke.id),Ie=Kt(Be),St=Rs(Be,f),ze=Math.max(0,...St.map(ve=>ve.lane)),ei=Math.max(w?154:126,60+(ze+1)*(w?48:36)),pt=document.createElement("div");pt.className="ps-person-row",pt.style.height=`${ei}px`,pt.dataset.person=ke.id;const xt=document.createElement("div");xt.className="ps-person",xt.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${we(ke.name)}</strong></div><div>已排期项 <b>${Ie.scheduled}</b></div><div>总估分 <b>${Ie.estimate.toFixed(2)}</b></div><div>未排期·${Ie.unscheduled}<button data-action="unplanned" data-person="${we(ke.id)}">查看</button></div>`;const $t=xt.querySelector(".ps-avatar");$t.textContent=ke.name.slice(-2),$t.style.background=ke.color||sn[t.indexOf(ke)%sn.length];const We=document.createElement("div");We.className="ps-timeline",We.style.width=`${X}px`,We.style.setProperty("--day",`${K}px`);for(let ve=0;ve<m;ve++)if([0,6].includes(new Date((p+ve)*864e5).getUTCDay())){const at=document.createElement("i");at.className="ps-weekend",at.style.left=`${ve*K}px`,at.style.width=`${K}px`,We.append(at)}const st=Fe(n)-p;if(st>=0&&st<m){const ve=document.createElement("i");ve.className="ps-today",ve.style.left=`${(st+.5)*K}px`,We.append(ve)}for(const{item:ve,lane:at}of St){const lt=Fe(ve.start),Ue=Fe(ve.end);if(Ue<p||lt>=p+m)continue;const rt=Math.max(0,lt-p)*K,gt=Math.min(m,Ue-p+1)*K,Ve=document.createElement("button");Ve.className=`ps-bar ${h?"ps-color":"ps-content"}`,Ve.dataset.item=ve.id,Ve.setAttribute("aria-label",`${ve.name},${ve.start} 至 ${ve.end}`),Ve.style.left=`${rt}px`,Ve.style.width=`${gt-rt}px`,Ve.style.top=`${52+at*(w?48:36)}px`,Ve.style.setProperty("--bar-color",ve.color||"#8cafeb"),Ve.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${we(ve.name)}</span><span class="ps-status">${we(ve.status)}</span><span class="ps-node">● ${we(ve.node)}</span><span class="ps-effort">${ve.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,We.append(Ve)}if(!St.length){const ve=document.createElement("span");ve.className="ps-no-schedule",ve.textContent="暂无排期",We.append(ve)}pt.append(xt,We),j.append(pt)}pe.length||(j.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const Te=ne.filter(ke=>pe.some(Be=>Be.id===ke.personId));B(".ps-total").textContent=`ⓘ 总人数 ${pe.length} 总估分 ${Kt(Te).estimate.toFixed(2)} pd ···`}function q(K,X){if(!W.hidden&&W.dataset.kind===K){W.hidden=!0;return}W.dataset.kind=K,W.hidden=!1;const J=P.getBoundingClientRect(),Y=X==null?void 0:X.getBoundingClientRect();if(W.style.left=`${Math.max(12,Math.min(((Y==null?void 0:Y.left)??J.left)-J.left,P.clientWidth-(K==="unplanned"?760:420)-16))}px`,W.style.top=`${Y?Y.bottom-J.top+6:96}px`,W.className=`ps-popover ps-panel-${K}`,K==="people")W.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(ne=>`<label><input type="checkbox" data-person="${we(ne.id)}" ${o.has(ne.id)?"checked":""}>${we(ne.name)}</label>`).join("")}</div>`;else if(K==="sort")W.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="${d?"":"selected"}">小 → 大</button><button data-action="desc" class="${d?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,W.querySelector("select").value=c;else if(K==="filter")W.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${we(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${we(r)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(ne=>ne.status))].map(ne=>`<option>${we(ne)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,W.querySelector("select").value=l;else if(K==="settings")W.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${f?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${g?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${w?"":"selected"}">紧凑</button><button data-action="loose" class="${w?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${h?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${h?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(K==="date")be();else if(K==="save")W.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(K==="views"){const ne=ot();W.innerHTML=`<div class="ps-panel-title">视图列表</div>${ne.length?ne.map((pe,Te)=>`<button class="ps-view" data-view="${Te}">▦ ${we(pe.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let Z=new Date(`${y}T00:00:00Z`),te=!1;function be(){let K=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${y}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${E}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let X=0;X<2;X++){const J=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+X,1));K+=`<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(ne=>`<span>${ne}</span>`).join("")}`;for(let ne=0;ne<J.getUTCDay();ne++)K+="<span></span>";const Y=new Date(Date.UTC(J.getUTCFullYear(),J.getUTCMonth()+1,0)).getUTCDate();for(let ne=1;ne<=Y;ne++){const pe=Oe(Date.UTC(J.getUTCFullYear(),J.getUTCMonth(),ne)/864e5);K+=`<button data-date="${pe}" class="${pe>=y&&pe<=E?"in-range":""} ${pe===y||pe===E?"selected":""}">${ne}</button>`}K+="</div></div>"}W.innerHTML=K+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((X,J)=>`<button data-preset="${J}">${X}</button>`).join("")}</div>`}function me(){E<y&&([y,E]=[E,y]),p=Fe(y),p-=new Date(p*864e5).getUTCDay(),m=Math.max(35,Fe(E)-p+8),A.scrollLeft=0,$()}function ce(K,X){var ne;if(!i.some(pe=>pe.id===K))throw new Error(`Unknown schedule item: ${K}`);const J=i.map(pe=>pe.id===K?{...pe,...X}:pe);ui(t,J),i=J,$();const Y=i.find(pe=>pe.id===K);Y&&((ne=e.onItemChange)==null||ne.call(e,structuredClone(Y)))}function Ne(K){var J;const X=i.find(Y=>Y.id===K);(J=e.onItemOpen)==null||J.call(e,structuredClone(X)),T.hidden=!1,T.dataset.item=K,T.innerHTML=`<header><strong>${we(X.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${we(X.status)}</span><h3>● ${we(X.node)}</h3><form><label>名称<input name="name" required value="${we(X.name)}"></label><label>负责人<select name="personId">${t.map(Y=>`<option value="${we(Y.id)}" ${Y.id===X.personId?"selected":""}>${we(Y.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${X.estimate}" required></label><label>开始日期<input type="date" name="start" value="${X.start||""}"></label><label>结束日期<input type="date" name="end" value="${X.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 ht(K,X){q("unplanned",X),W.hidden=!1;const J=t.find(Y=>Y.id===K);W.innerHTML=`<div class="ps-panel-title">未排期工作项 ${we(J.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(Y=>Y.personId===K&&!Lt(Y)).map(Y=>`<tr><td><button data-open="${we(Y.id)}">${we(Y.name)}</button></td><td>● ${we(Y.node)}</td><td><input type="number" min="0" step="0.1" value="${Y.estimate||""}" placeholder="待填" data-estimate="${we(Y.id)}" aria-label="${we(Y.name)}估分"></td><td><button class="ps-link" data-open="${we(Y.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const Zt=e.viewStorageKey??"rowvia-personnel-views-v1";function ot(){try{const K=JSON.parse(localStorage.getItem(Zt)||"[]");return Array.isArray(K)?K:[]}catch{return[]}}P.addEventListener("click",K=>{const X=K.target,J=X.closest("button");if(!J)return;if(J.dataset.open){W.hidden=!0,Ne(J.dataset.open);return}if(J.dataset.item){S||Ne(J.dataset.item);return}if(J.dataset.date){te?(E=J.dataset.date,te=!1,me()):(y=J.dataset.date,E=y,te=!0),be();return}if(J.dataset.preset){const ne=Number(J.dataset.preset),pe=Fe(n),Te=new Date(pe*864e5);y=Oe(ne<2?pe-Te.getUTCDay():ne<4?Date.UTC(Te.getUTCFullYear(),Te.getUTCMonth(),1)/864e5:pe),E=Oe(ne===2||ne===3?Date.UTC(Te.getUTCFullYear(),Te.getUTCMonth()+(ne===2?1:2),0)/864e5:Fe(y)+[6,13,29,60,13,59,364][ne]),te=!1,me(),W.hidden=!0;return}if(J.dataset.view){const ne=ot()[Number(J.dataset.view)];ne&&(o=new Set(ne.selected.filter(pe=>t.some(Te=>Te.id===pe))),{query:r,status:l,sort:c,descending:d,zoom:u,from:p,days:m,rangeStart:y,rangeEnd:E,expanded:f,children:g,loose:w,colorFirst:h,onlyScheduled:a}=ne,$(),W.hidden=!0,U(`已打开 ${ne.name}`));return}const Y=J.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(Y||"")){q(Y,J);return}if(Y==="unplanned"){ht(J.dataset.person,J);return}if(Y==="close-detail"&&(T.hidden=!0),Y==="unschedule"&&(ce(T.dataset.item,{start:null,end:null}),T.hidden=!0),(Y==="plus"||Y==="minus")&&(u=Math.max(0,Math.min(4,u+(Y==="plus"?1:-1))),$()),(Y==="prev"||Y==="next"||Y==="today")&&(p=Y==="today"?Fe(n)-new Date(`${n}T00:00:00Z`).getUTCDay():p+(Y==="prev"?-14:14),y=Oe(p),E=Oe(p+59),A.scrollLeft=0,$()),(Y==="asc"||Y==="desc"||Y==="clear-sort")&&(d=Y==="desc",Y==="clear-sort"&&(c=""),$(),W.hidden=!0),Y==="clear-filter"&&(r="",l="",$(),W.hidden=!0),["compact","loose","content","color"].includes(Y||"")&&(Y==="compact"||Y==="loose"?w=Y==="loose":h=Y==="color",$(),W.hidden=!0,q("settings",B('[data-action="settings"]'))),(Y==="cal-prev"||Y==="cal-next")&&(Z=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+(Y==="cal-prev"?-1:1),1)),be()),Y==="save-view"){const ne=W.querySelector("[data-view-name]").value.trim();if(!ne)return;const pe=ot();pe.push({name:ne,selected:[...o],query:r,status:l,sort:c,descending:d,zoom:u,from:p,days:m,rangeStart:y,rangeEnd:E,expanded:f,children:g,loose:w,colorFirst:h,onlyScheduled:a});try{localStorage.setItem(Zt,JSON.stringify(pe)),W.hidden=!0,U("视图已保存")}catch{U("浏览器存储不可用,视图未保存")}}Y==="schedule"&&(W.hidden=!0,T.hidden=!0)},{signal:N}),P.addEventListener("input",K=>{const X=K.target;X.classList.contains("ps-zoom")&&(u=Number(X.value),$()),X.classList.contains("ps-person-search")&&W.querySelectorAll(".ps-person-options label").forEach(J=>{var Y;return J.hidden=!((Y=J.textContent)!=null&&Y.includes(X.value))}),X.dataset.control==="query"&&(r=X.value,$())},{signal:N}),P.addEventListener("change",K=>{const X=K.target;if(X.dataset.person&&(X.checked?o.add(X.dataset.person):o.delete(X.dataset.person),$()),X.dataset.estimate){const J=Number(X.value);Number.isFinite(J)&&J>=0&&ce(X.dataset.estimate,{estimate:J});return}switch(X.dataset.control){case"only":a=X.checked;break;case"sort":c=X.value;break;case"status":l=X.value;break;case"expanded":f=X.checked;break;case"children":g=X.checked;break;case"range-start":X.value&&(y=X.value,me(),be());return;case"range-end":X.value&&(E=X.value,me(),be());return}$()},{signal:N}),T.addEventListener("submit",K=>{K.preventDefault();const X=new FormData(K.target),J=String(X.get("start")||"")||null,Y=String(X.get("end")||"")||null;if(!!J!=!!Y||J&&Y&&J>Y){T.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ce(T.dataset.item,{name:String(X.get("name")),personId:String(X.get("personId")),estimate:Number(X.get("estimate")),start:J,end:Y}),T.hidden=!0,U("排期已更新")},{signal:N}),document.addEventListener("pointerdown",K=>{P.contains(K.target)?!W.contains(K.target)&&!K.target.closest("[data-action]")&&(W.hidden=!0):W.hidden=!0},{signal:N}),P.addEventListener("keydown",K=>{K.key==="Escape"&&(W.hidden=!0,T.hidden=!0)},{signal:N});let Ce=null;return j.addEventListener("pointerdown",K=>{const X=K.target,J=X.closest(".ps-bar");if(!J||K.button!==0)return;const Y=i.find(ne=>ne.id===J.dataset.item);S=!1,Ce={id:Y.id,x:K.clientX,start:Fe(Y.start),end:Fe(Y.end),edge:X.dataset.edge||"move",bar:J,left:parseFloat(J.style.left),size:parseFloat(J.style.width),delta:0,scroll:A.scrollLeft}},{signal:N}),document.addEventListener("pointermove",K=>{if(!Ce)return;const X=Math.round((K.clientX-Ce.x+A.scrollLeft-Ce.scroll)/_());Ce.delta=Ce.edge==="start"?Math.min(X,Ce.end-Ce.start):Ce.edge==="end"?Math.max(X,Ce.start-Ce.end):X,Math.abs(K.clientX-Ce.x)>4&&(S=!0),S&&(Ce.bar.style.opacity=".8",Ce.edge==="move"?Ce.bar.style.transform=`translateX(${Ce.delta*_()}px)`:(Ce.bar.style.left=`${Ce.left+(Ce.edge==="start"?Ce.delta*_():0)}px`,Ce.bar.style.width=`${Ce.size+(Ce.edge==="start"?-1:1)*Ce.delta*_()}px`))},{signal:N}),document.addEventListener("pointerup",()=>{if(!Ce)return;const K=Ce;Ce=null,S&&(ce(K.id,{start:Oe(K.start+(K.edge==="end"?0:K.delta)),end:Oe(K.end+(K.edge==="start"?0:K.delta))}),U("排期已更新"))},{signal:N}),$(),{setData(K,X){ui(K,X),t=structuredClone(K),i=structuredClone(X),o=new Set(t.map(J=>J.id)),W.hidden=!0,T.hidden=!0,$()},getItems:()=>structuredClone(i),updateItem:ce,setPeople(K){o=new Set(K.filter(X=>t.some(J=>J.id===X))),$()},destroy(){R=!0,F.abort(),clearTimeout(z),P.remove()}}}function Dt(s,e,t,i){const n=document.createElement("section");n.className=`rowvia-${e}`,n.innerHTML=t,s.append(n);let o=null,a=!1;const r=new Set,l=[];return{host:n,handle:{get api(){return(o==null?void 0:o.api)??null},get columnApi(){return(o==null?void 0:o.columnApi)??null},destroy(){a||(a=!0,r.forEach(u=>{window.clearTimeout(u),window.clearInterval(u)}),l.forEach(u=>u()),o==null||o.grid.destroy(),o=null,n.remove())}},timeout:(u,f)=>{const g=window.setTimeout(()=>{r.delete(g),a||u()},f);return r.add(g),g},cleanup(u){l.push(u)},interval(u,f){const g=window.setInterval(()=>{a||u()},f);return r.add(g),g},createGrid(u,f){return o=xi(u,{...f,...i.gridOptions}),o}}}function hi(s=42){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}const ks=["Michael","Emma","Daniel","Olivia","James","Sophia","William","Ava","Benjamin","Isabella","Lucas","Mia","Henry","Charlotte","Alexander","Amelia","Noah","Harper","Ethan","Evelyn","Jacob","Abigail","Leo","Emily","Nathan","Elizabeth","Aaron","Sofia","Caleb","Avery","Isaac","Ella","Owen","Scarlett","Wyatt","Grace","Julian","Chloe","Miles","Victoria"],Ts=["Bridges","Stone","Collins","Reyes","Fisher","Lambert","Walsh","Harper","Keller","Novak","Silva","Weaver","Grant","Holloway","Mercer","Draper","Whitfield","Calloway","Prescott","Vance","Ellington","Monroe","Sinclair","Barlow"],Ns=[{name:"France",flag:"🇫🇷"},{name:"Spain",flag:"🇪🇸"},{name:"United Kingdom",flag:"🇬🇧"},{name:"Netherlands",flag:"🇳🇱"},{name:"Portugal",flag:"🇵🇹"},{name:"Italy",flag:"🇮🇹"},{name:"United States",flag:"🇺🇸"},{name:"Ireland",flag:"🇮🇪"}],jt={executiveManagement:"Executive Management",legal:"Legal",design:"Design",engineering:"Engineering",product:"Product",customerSupport:"Customer Support"},Is=Object.keys(jt),Xe=hi(7);function At(s){return s[Math.floor(Xe()*s.length)]}function Ls(){return`${At(ks)} ${At(Ts)}`}function Ds(){const s=2015+Math.floor(Xe()*10),e=1+Math.floor(Xe()*12),t=1+Math.floor(Xe()*28);return`${s}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function bt(s,e,t){const i=s[s.length-1],n=At(Ns);return{orgHierarchy:s,contact:i.replace(/\s+/g,"."),jobTitle:e,employmentType:Xe()<.7?"Permanent":"Contract",department:t,employeeId:0,location:n.name,joinDate:Ds(),basicMonthlySalary:2500+Math.floor(Xe()*60)*250,currency:At(["GBP","EUR","USD"]),paymentMethod:At(["Bank Transfer","Cash","Check"]),paymentStatus:Xe()<.65?"paid":"pending",image:String(1+Math.floor(Xe()*36)),flag:n.flag}}function As(){const s=[];let e=1001;const t="Will Bridges",i=["Michael Johnson","Sophie Turner","Ravi Patel"],n={engineering:"Nina Alvarez",design:"Tom Whitaker",product:"Grace Liu",legal:"Hannah Ford",customerSupport:"Marc Duval",executiveManagement:"Oliver Grant"},o=a=>{s.push({...a,employeeId:e++})};o(bt([t],"CEO","executiveManagement")),o(bt([t,i[0]],"COO","executiveManagement")),o(bt([t,i[1]],"CTO","executiveManagement")),o(bt([t,i[2]],"Exec. Vice President","executiveManagement"));for(const a of Is){const r=n[a],l=a==="executiveManagement"?i[1]:i[Math.floor(Xe()*3)];o(bt([t,l,r],"Head of Department",a));const c=6+Math.floor(Xe()*4);for(let d=0;d<c;d++){const u=Ls();o(bt([t,l,r,u],"Employee",a))}}return s}const pi=hi(1337),Fs=[["US10Y","U.S. Treasury 10-Year Bond","Bond"],["MUB","iShares National Muni Bond ETF","ETF"],["BRK.B","Berkshire Hathaway Inc. Class B","Stock"],["VOO","Vanguard S&P 500 ETF","ETF"],["QQQ","Invesco QQQ Trust","ETF"],["AAPL","Apple Inc.","Stock"],["MSFT","Microsoft Corporation","Stock"],["GOOGL","Alphabet Inc. Class A","Stock"],["AMZN","Amazon.com Inc.","Stock"],["TSLA","Tesla Inc.","Stock"],["NVDA","NVIDIA Corporation","Stock"],["META","Meta Platforms Inc.","Stock"],["JPM","JPMorgan Chase & Co.","Stock"],["V","Visa Inc.","Stock"],["UNH","UnitedHealth Group Inc.","Stock"],["XOM","Exxon Mobil Corporation","Stock"],["JNJ","Johnson & Johnson","Stock"],["WMT","Walmart Inc.","Stock"],["MA","Mastercard Inc.","Stock"],["PG","Procter & Gamble Co.","Stock"],["CVX","Chevron Corporation","Stock"],["HD","Home Depot Inc.","Stock"],["ORCL","Oracle Corporation","Stock"],["MRK","Merck & Co. Inc.","Stock"],["ABBV","AbbVie Inc.","Stock"],["PEP","PepsiCo Inc.","Stock"],["KO","Coca-Cola Co.","Stock"],["COST","Costco Wholesale Corp.","Stock"],["BAC","Bank of America Corp.","Stock"],["MCD","McDonald's Corp.","Stock"],["CSCO","Cisco Systems Inc.","Stock"],["PFE","Pfizer Inc.","Stock"],["CRM","Salesforce Inc.","Stock"],["TMO","Thermo Fisher Scientific Inc.","Stock"],["AVGO","Broadcom Inc.","Stock"],["ACN","Accenture plc","Stock"],["LIN","Linde plc","Stock"],["AMD","Advanced Micro Devices Inc.","Stock"],["NFLX","Netflix Inc.","Stock"],["DIS","Walt Disney Co.","Stock"],["TXN","Texas Instruments Inc.","Stock"],["WFC","Wells Fargo & Co.","Stock"],["PM","Philip Morris International Inc.","Stock"],["VZ","Verizon Communications Inc.","Stock"],["INTC","Intel Corporation","Stock"],["CMCSA","Comcast Corp.","Stock"],["NKE","NIKE Inc.","Stock"],["DHR","Danaher Corporation","Stock"],["UNP","Union Pacific Corp.","Stock"],["MS","Morgan Stanley","Stock"],["RTX","RTX Corporation","Stock"],["LOW","Lowe's Companies Inc.","Stock"],["SPGI","S&P Global Inc.","Stock"],["INTU","Intuit Inc.","Stock"],["GS","Goldman Sachs Group Inc.","Stock"],["BDX","Becton Dickinson & Co.","Stock"],["SCHW","Charles Schwab Corp.","Stock"],["NOW","ServiceNow Inc.","Stock"],["ISRG","Intuitive Surgical Inc.","Stock"],["AMAT","Applied Materials Inc.","Stock"],["GE","GE Aerospace","Stock"],["CAT","Caterpillar Inc.","Stock"],["BLK","BlackRock Inc.","Stock"],["AXP","American Express Co.","Stock"],["TJX","TJX Companies Inc.","Stock"],["GILD","Gilead Sciences Inc.","Stock"],["SYK","Stryker Corporation","Stock"],["MDT","Medtronic plc","Stock"],["C","Citigroup Inc.","Stock"],["CB","Chubb Limited","Stock"],["ZTS","Zoetis Inc.","Stock"],["MMC","Marsh & McLennan Cos. Inc.","Stock"],["ADP","Automatic Data Processing Inc.","Stock"],["CI","Cigna Group","Stock"],["SO","Southern Co.","Stock"],["ETN","Eaton Corp. plc","Stock"],["BSX","Boston Scientific Corp.","Stock"],["PLD","Prologis Inc.","Stock"],["ITW","Illinois Tool Works Inc.","Stock"],["HON","Honeywell International Inc.","Stock"],["MU","Micron Technology Inc.","Stock"],["DE","Deere & Co.","Stock"],["AMT","American Tower Corp.","Stock"],["WM","Waste Management Inc.","Stock"],["LRCX","Lam Research Corp.","Stock"],["CSX","CSX Corporation","Stock"],["ICE","Intercontinental Exchange Inc.","Stock"],["CL","Colgate-Palmolive Co.","Stock"],["SHW","Sherwin-Williams Co.","Stock"],["FI","Fiserv Inc.","Stock"],["USB","U.S. Bancorp","Stock"],["PNC","PNC Financial Services Group Inc.","Stock"],["APH","Amphenol Corporation","Stock"],["NOC","Northrop Grumman Corp.","Stock"],["GD","General Dynamics Corp.","Stock"],["MSI","Motorola Solutions Inc.","Stock"],["TGT","Target Corporation","Stock"],["F","Ford Motor Co.","Stock"],["GM","General Motors Co.","Stock"],["BTC","Bitcoin","Crypto"],["ETH","Ethereum","Crypto"],["SOL","Solana","Crypto"],["USDC","USD Coin","Crypto"],["XRP","XRP","Crypto"],["ADA","Cardano","Crypto"],["DOT","Polkadot","Crypto"],["LINK","Chainlink","Crypto"],["AGG","iShares Core U.S. Aggregate Bond ETF","ETF"],["BND","Vanguard Total Bond Market ETF","ETF"],["LQD","iShares iBoxx $ Investment Grade Corp Bond ETF","ETF"],["HYG","iShares iBoxx $ High Yield Corp Bond ETF","ETF"],["TLT","iShares 20+ Year Treasury Bond ETF","ETF"],["IWM","iShares Russell 2000 ETF","ETF"],["EEM","iShares MSCI Emerging Markets ETF","ETF"],["VGK","Vanguard FTSE Europe ETF","ETF"],["VWO","Vanguard FTSE Emerging Markets ETF","ETF"],["XLE","Energy Select Sector SPDR Fund","ETF"],["XLF","Financial Select Sector SPDR Fund","ETF"],["XLK","Technology Select Sector SPDR Fund","ETF"],["XLV","Health Care Select Sector SPDR Fund","ETF"],["GLD","SPDR Gold Shares","ETF"],["SLV","iShares Silver Trust","ETF"],["USO","United States Oil Fund","ETF"],["VIXY","ProShares VIX Short-Term Futures ETF","ETF"],["ARKK","ARK Innovation ETF","ETF"],["SPY","SPDR S&P 500 ETF Trust","ETF"]],an=["#2196f3","#4caf50","#ff9800","#9c27b0","#f44336","#00bcd4","#795548","#607d8b","#e91e63","#3f51b5","#009688","#ffc107"];function Ps(s){let e=0;for(let o=0;o<s.length;o++)e=e*31+s.charCodeAt(o)>>>0;const t=an[e%an.length],i=s.replace(/[^A-Za-z]/g,"").slice(0,2).toUpperCase()||s.slice(0,2).toUpperCase(),n=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"><rect width="40" height="40" rx="20" fill="${t}"/><text x="20" y="26" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#fff" text-anchor="middle">${i}</text></svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`}function $s(s){const e=[];let t=s*(.9+pi()*.2);for(let i=0;i<24;i++)t=t*(1+(pi()-.5)*.04),e.push(Number(t.toFixed(2)));return e}function Gs(){return Fs.map(([s,e,t])=>{const i=Number((Math.random()*40+10).toFixed(2)),n=Number((Math.random()*40+10).toFixed(2));return{ticker:s,name:e,instrument:t,quantity:10+Math.floor(pi()*500),purchaseDate:"2023-04-11",purchasePrice:i,price:n,timeline:$s(n)}})}function Hs(s){for(const e of s)if(Math.random()<.1){const t=Math.random()*.2,i=1-t+Math.random()*t*2;e.price<10?e.price=e.price*i:e.price=Math.random()*40+10,e.price=Number(e.price.toFixed(2)),e.timeline=e.timeline.slice(1,e.timeline.length).concat(e.price)}}function Os(s,e={}){var h,p;const t=Dt(s,"finance",`<div id="app">
38
38
  <div id="financeGrid" class="grid ag-theme-quartz gridHeight"></div>
39
- </div>`,e),{host:i,createGrid:n}=t,o=new Intl.NumberFormat("en-US",{style:"decimal",maximumFractionDigits:2});function a(m){var A,B,L;const y=document.createElement("div");y.className="ticker-cell";const E=document.createElement("img");E.src=$s(String(((A=m.data)==null?void 0:A.ticker)??"")),E.alt=`${((B=m.data)==null?void 0:B.name)??""} logo`,y.appendChild(E);const R=document.createElement("b");R.className="custom-ticker",R.textContent=String(m.value??""),y.appendChild(R);const S=document.createElement("span");return S.className="ticker-name",S.textContent=` ${((L=m.data)==null?void 0:L.name)??""}`,y.appendChild(S),y}const r=[{field:"ticker",width:340,minWidth:340,cellRenderer:a,tooltipValueGetter:m=>{var y,E;return`${((y=m.data)==null?void 0:y.name)??""} (${((E=m.data)==null?void 0:E.instrument)??""})`}},{field:"timeline",headerName:"Timeline",width:140,minWidth:140,cellRenderer:"agSparklineCellRenderer",sortable:!1,filter:!1,cellRendererParams:{sparklineOptions:{type:"bar",direction:"vertical",axis:{strokeWidth:0}}}},{field:"instrument",width:100,minWidth:100,type:"rightAligned"},{colId:"p&l",headerName:"P&L",width:140,minWidth:140,type:"rightAligned",cellRenderer:"agAnimateShowChangeCellRenderer",filter:"number",valueGetter:m=>m.data&&m.data.quantity*(m.data.price/m.data.purchasePrice),aggFunc:"sum",valueFormatter:m=>m.value==null?"":o.format(m.value)},{colId:"totalValue",headerName:"Total Value",width:160,minWidth:160,type:"rightAligned",cellRenderer:"agAnimateShowChangeCellRenderer",filter:"number",valueGetter:m=>m.data&&m.data.quantity*m.data.price,aggFunc:"sum",valueFormatter:m=>m.value==null?"":o.format(m.value)},{field:"quantity",maxWidth:75,type:"rightAligned",valueFormatter:m=>m.value==null?"":o.format(m.value)},{field:"purchasePrice",headerName:"Price",maxWidth:75,type:"rightAligned",valueFormatter:m=>m.value==null?"":o.format(m.value)}],l=Hs(),c={columnDefs:r,rowData:l,defaultColDef:{flex:1,filter:!0,enableRowGroup:!1,enableValue:!0},rowGroupPanelShow:"never",groupDefaultExpanded:-1,getRowId:m=>m.data.ticker,enableRangeSelection:!0,enableCharts:!0,statusBar:{statusPanels:[{statusPanel:"agTotalAndFilteredRowCountComponent",align:"left"},{statusPanel:"agTotalRowCountComponent",align:"left"},{statusPanel:"agFilteredRowCountComponent",align:"left"},{statusPanel:"agSelectedRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},theme:"ag-theme-quartz",context:{}},{api:d}=n(i.querySelector("#financeGrid"),c),u=60;let f;function g(){f===void 0&&(f=t.interval(()=>{Os(l);const m=[];for(const y of l){const E=d.getRowNode(y.ticker);E&&(E.data=y,m.push(E))}d.refreshCells({rowNodes:m,force:!0})},u))}function p(){f!==void 0&&(window.clearInterval(f),f=void 0)}if(e.liveUpdates!==!1&&!((C=e.gridOptions)!=null&&C.rowData)&&g(),e.liveUpdates!==!1&&!((h=e.gridOptions)!=null&&h.rowData)&&typeof IntersectionObserver<"u"){const m=new IntersectionObserver(y=>{for(const E of y)E.isIntersecting?g():p()},{threshold:0});t.cleanup(()=>m.disconnect()),m.observe(i.querySelector("#financeGrid"))}return t.cleanup(p),t.handle}function Vs(s,e={}){const t=Dt(s,"hr",`<div class="wrapper">
39
+ </div>`,e),{host:i,createGrid:n}=t,o=new Intl.NumberFormat("en-US",{style:"decimal",maximumFractionDigits:2});function a(m){var P,B,A;const y=document.createElement("div");y.className="ticker-cell";const E=document.createElement("img");E.src=Ps(String(((P=m.data)==null?void 0:P.ticker)??"")),E.alt=`${((B=m.data)==null?void 0:B.name)??""} logo`,y.appendChild(E);const R=document.createElement("b");R.className="custom-ticker",R.textContent=String(m.value??""),y.appendChild(R);const S=document.createElement("span");return S.className="ticker-name",S.textContent=` ${((A=m.data)==null?void 0:A.name)??""}`,y.appendChild(S),y}const r=[{field:"ticker",width:340,minWidth:340,cellRenderer:a,tooltipValueGetter:m=>{var y,E;return`${((y=m.data)==null?void 0:y.name)??""} (${((E=m.data)==null?void 0:E.instrument)??""})`}},{field:"timeline",headerName:"Timeline",width:140,minWidth:140,cellRenderer:"agSparklineCellRenderer",sortable:!1,filter:!1,cellRendererParams:{sparklineOptions:{type:"bar",direction:"vertical",axis:{strokeWidth:0}}}},{field:"instrument",width:100,minWidth:100,type:"rightAligned"},{colId:"p&l",headerName:"P&L",width:140,minWidth:140,type:"rightAligned",cellRenderer:"agAnimateShowChangeCellRenderer",filter:"number",valueGetter:m=>m.data&&m.data.quantity*(m.data.price/m.data.purchasePrice),aggFunc:"sum",valueFormatter:m=>m.value==null?"":o.format(m.value)},{colId:"totalValue",headerName:"Total Value",width:160,minWidth:160,type:"rightAligned",cellRenderer:"agAnimateShowChangeCellRenderer",filter:"number",valueGetter:m=>m.data&&m.data.quantity*m.data.price,aggFunc:"sum",valueFormatter:m=>m.value==null?"":o.format(m.value)},{field:"quantity",maxWidth:75,type:"rightAligned",valueFormatter:m=>m.value==null?"":o.format(m.value)},{field:"purchasePrice",headerName:"Price",maxWidth:75,type:"rightAligned",valueFormatter:m=>m.value==null?"":o.format(m.value)}],l=Gs(),c={columnDefs:r,rowData:l,defaultColDef:{flex:1,filter:!0,enableRowGroup:!1,enableValue:!0},rowGroupPanelShow:"never",groupDefaultExpanded:-1,getRowId:m=>m.data.ticker,enableRangeSelection:!0,enableCharts:!0,statusBar:{statusPanels:[{statusPanel:"agTotalAndFilteredRowCountComponent",align:"left"},{statusPanel:"agTotalRowCountComponent",align:"left"},{statusPanel:"agFilteredRowCountComponent",align:"left"},{statusPanel:"agSelectedRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},theme:"ag-theme-quartz",context:{}},{api:d}=n(i.querySelector("#financeGrid"),c),u=60;let f;function g(){f===void 0&&(f=t.interval(()=>{Hs(l);const m=[];for(const y of l){const E=d.getRowNode(y.ticker);E&&(E.data=y,m.push(E))}d.refreshCells({rowNodes:m,force:!0})},u))}function w(){f!==void 0&&(window.clearInterval(f),f=void 0)}if(e.liveUpdates!==!1&&!((h=e.gridOptions)!=null&&h.rowData)&&g(),e.liveUpdates!==!1&&!((p=e.gridOptions)!=null&&p.rowData)&&typeof IntersectionObserver<"u"){const m=new IntersectionObserver(y=>{for(const E of y)E.isIntersecting?g():w()},{threshold:0});t.cleanup(()=>m.disconnect()),m.observe(i.querySelector("#financeGrid"))}return t.cleanup(w),t.handle}function Bs(s,e={}){const t=Dt(s,"hr",`<div class="wrapper">
40
40
  <div class="container">
41
41
  <div id="hrGrid" class="grid ag-theme-quartz"></div>
42
42
  </div>
43
- </div>`,e),{host:i,createGrid:n}=t,o=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function a(h){let m=0;for(let y=0;y<h.length;y++)m=m*31+h.charCodeAt(y)>>>0;return o[m%o.length]}function r(h){return h.split(/\s+/).map(m=>m[0]).join("").slice(0,2).toUpperCase()}function l(h){var L;const m=document.createElement("div");m.className="employeeCell";const y=h.data||{},E=h.node.group?h.value:((L=y.orgHierarchy)==null?void 0:L[y.orgHierarchy.length-1])??"",R=document.createElement("div");R.className="avatar",R.style.backgroundColor=a(String(E)),R.textContent=r(String(E));const S=document.createElement("div");S.className="employeeData";const A=document.createElement("span");A.className="name",A.textContent=String(E);const B=document.createElement("span");return B.className="description",B.textContent=y.jobTitle??"",S.appendChild(A),S.appendChild(B),m.appendChild(R),m.appendChild(S),m}function c(h){const m=String(h.valueFormatted??h.value??""),y=Object.keys(jt).find(A=>jt[A]===m)??"",E=document.createElement("div");E.className=`tag ${y}Tag`;const R=document.createElement("span");R.className=`circle ${y}Circle`,E.appendChild(R);const S=document.createElement("span");return S.textContent=m,E.appendChild(S),E}function d(h){var R;const m=document.createElement("div");m.className="flagCell";const y=document.createElement("span");y.textContent=String(h.value??""),m.appendChild(y);const E=document.createElement("span");return E.className="flagImage",E.textContent=((R=h.data)==null?void 0:R.flag)??"",m.appendChild(E),m}function u(h){const m=String(h.value??""),y=document.createElement("div");if(y.className=`tag ${m}Tag`,m==="paid"){const R=document.createElement("span");R.className="tick",R.innerHTML='<svg viewBox="0 0 16 16" width="16" height="16" fill="rgb(62,184,97)"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>',y.appendChild(R)}const E=document.createElement("span");return E.textContent=m,y.appendChild(E),y}function f(h){var A;const m=document.createElement("div");m.className="contact-cell";const y=document.createElement("div");y.className="iconContainer",y.title="LinkedIn",y.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="#0a66c2"><path d="M4.98 3.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5zM3 9h4v12H3V9zm7 0h3.8v1.7h.05c.53-1 1.83-2.05 3.77-2.05C21.4 8.65 22 11 22 14.1V21h-4v-6.1c0-1.5-.54-2.5-1.87-2.5-1.02 0-1.63.69-1.9 1.35-.1.23-.13.56-.13.9V21h-4V9z"/></svg>',y.addEventListener("click",()=>window.open("https://www.linkedin.com/company/ag-grid/","_blank")),m.appendChild(y);const E=((A=h.data)==null?void 0:A.orgHierarchy)??[],R=(E[E.length-1]??"").toLowerCase().replace(/\s+/g,"."),S=document.createElement("div");return S.className="iconContainer",S.title="Email",S.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="#39485d"><path d="M2 5h20v14H2V5zm2 2v.7l8 5 8-5V7H4zm0 3.9V17h16v-6.1l-8 5-8-5z"/></svg>',S.addEventListener("click",()=>{window.location.href=`mailto:${R}@company.com`}),m.appendChild(S),m}const C={columnDefs:[{field:"employeeId",headerName:"ID",width:120},{field:"department",width:250,minWidth:250,flex:1,valueFormatter:h=>{const m=String(h.value??"");return jt[m]??m},cellRenderer:c},{field:"employmentType",editable:!0,width:180,minWidth:180,flex:1,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Permanent","Contract"]}},{field:"location",width:200,minWidth:200,flex:1,cellRenderer:d,editable:!0},{field:"joinDate",headerName:"Join Date",editable:!0,width:120},{field:"basicMonthlySalary",headerName:"Salary",valueFormatter:h=>h.value==null?"":`$${Math.round(h.value).toLocaleString()}`},{field:"paymentMethod",headerName:"Payment Method",editable:!0,width:180,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Cash","Check","Bank Transfer"]}},{field:"paymentStatus",headerName:"Status",editable:!0,width:100,cellRenderer:u,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Paid","Pending"]}},{field:"contact",headerName:"Contact",pinned:"right",cellRenderer:f,width:120}],rowData:Fs(),rowHeight:62,groupDefaultExpanded:-1,treeData:!0,getDataPath:h=>h.orgHierarchy,autoGroupColumnDef:{headerName:"Employee",width:330,pinned:"left",sort:"asc",cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:l}},theme:"ag-theme-quartz"};return n(i.querySelector("#hrGrid"),C),t.handle}const ln=[["#667eea","#764ba2"],["#f093fb","#f5576c"],["#4facfe","#00f2fe"],["#43e97b","#38f9d7"],["#fa709a","#fee140"],["#30cfd0","#330867"],["#a8edea","#fed6e3"],["#ff9a9e","#fecfef"],["#f6d365","#fda085"],["#5ee7df","#b490ca"]];function zs(s,e){const[t,i]=ln[e%ln.length],n=s.split(/\s+/).slice(0,2).map(a=>a[0]).join("").toUpperCase(),o=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="${t}"/><stop offset="1" stop-color="${i}"/></linearGradient></defs><rect width="120" height="120" rx="8" fill="url(#g)"/><text x="60" y="70" font-family="Arial, sans-serif" font-size="40" font-weight="bold" fill="rgba(255,255,255,0.85)" text-anchor="middle">${n}</text></svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(o)}`}const rn=["Vinyl, LP, Album",'Vinyl, 12", 45 RPM',"Vinyl, LP, Reissue","CD, Album"],cn=["Blue Note","Columbia","Motown","Def Jam","Sub Pop","4AD","Matador","Domino"],dn=["US","UK","Europe","Japan"];function Ws(s,e,t){return Array.from({length:s},(i,n)=>({title:e,available:Math.floor(Math.random()*40),format:rn[n%rn.length],label:cn[n%cn.length],cat:`NB ${1e3+n*7}`,country:dn[n%dn.length],year:t}))}const Us=[{product:"Dreams of You",artist:"David Nearing",category:"Pop",year:"1984",status:"active",available:32,incoming:12,price:24.99,sold:128,priceIncrease:5.2,variants:3},{product:"Blue Skies",artist:"Maya Allen",category:"Rock",year:"1991",status:"active",available:18,incoming:5,price:19.99,sold:76,priceIncrease:2.1,variants:2},{product:"Heaven",artist:"Velvet Wave",category:"Soft Rock",year:"1978",status:"paused",available:0,incoming:0,price:29.99,sold:214,priceIncrease:8.4,variants:4},{product:"Life Matters",artist:"Danielle James",category:"Synth-pop",year:"1986",status:"active",available:45,incoming:20,price:22.5,sold:189,priceIncrease:3.6,variants:3},{product:"Lonely Hearts",artist:"Emma Stone",category:"Electronic",year:"1995",status:"outOfStock",available:0,incoming:8,price:27,sold:92,priceIncrease:1.2,variants:2},{product:"Imaginary Groove",artist:"Leo Collins",category:"Jazz",year:"1972",status:"active",available:27,incoming:15,price:31.99,sold:145,priceIncrease:6.7,variants:3},{product:"Desert Bloom",artist:"Indigo Ray",category:"Trance",year:"2003",status:"active",available:12,incoming:25,price:18.75,sold:63,priceIncrease:.8,variants:2},{product:"Golden Daze",artist:"The Marlowe Sound",category:"Ambient",year:"2011",status:"paused",available:8,incoming:0,price:26.25,sold:41,priceIncrease:4.3,variants:2},{product:"Fragments",artist:"Nova Elle",category:"Alt-pop",year:"2018",status:"active",available:56,incoming:30,price:21,sold:210,priceIncrease:7.1,variants:4},{product:"Solstice City",artist:"Aurora Lines",category:"Rhythm & Blues",year:"1989",status:"active",available:22,incoming:10,price:23.99,sold:167,priceIncrease:2.9,variants:3}];function _s(){return Us.map((s,e)=>({...s,image:zs(s.product,e),variantDetails:Ws(s.variants,s.product,s.year)}))}function qs(s,e={}){const t=Dt(s,"inventory",`<div class="wrapper">
43
+ </div>`,e),{host:i,createGrid:n}=t,o=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function a(p){let m=0;for(let y=0;y<p.length;y++)m=m*31+p.charCodeAt(y)>>>0;return o[m%o.length]}function r(p){return p.split(/\s+/).map(m=>m[0]).join("").slice(0,2).toUpperCase()}function l(p){var A;const m=document.createElement("div");m.className="employeeCell";const y=p.data||{},E=p.node.group?p.value:((A=y.orgHierarchy)==null?void 0:A[y.orgHierarchy.length-1])??"",R=document.createElement("div");R.className="avatar",R.style.backgroundColor=a(String(E)),R.textContent=r(String(E));const S=document.createElement("div");S.className="employeeData";const P=document.createElement("span");P.className="name",P.textContent=String(E);const B=document.createElement("span");return B.className="description",B.textContent=y.jobTitle??"",S.appendChild(P),S.appendChild(B),m.appendChild(R),m.appendChild(S),m}function c(p){const m=String(p.valueFormatted??p.value??""),y=Object.keys(jt).find(P=>jt[P]===m)??"",E=document.createElement("div");E.className=`tag ${y}Tag`;const R=document.createElement("span");R.className=`circle ${y}Circle`,E.appendChild(R);const S=document.createElement("span");return S.textContent=m,E.appendChild(S),E}function d(p){var R;const m=document.createElement("div");m.className="flagCell";const y=document.createElement("span");y.textContent=String(p.value??""),m.appendChild(y);const E=document.createElement("span");return E.className="flagImage",E.textContent=((R=p.data)==null?void 0:R.flag)??"",m.appendChild(E),m}function u(p){const m=String(p.value??""),y=document.createElement("div");if(y.className=`tag ${m}Tag`,m==="paid"){const R=document.createElement("span");R.className="tick",R.innerHTML='<svg viewBox="0 0 16 16" width="16" height="16" fill="rgb(62,184,97)"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>',y.appendChild(R)}const E=document.createElement("span");return E.textContent=m,y.appendChild(E),y}function f(p){var P;const m=document.createElement("div");m.className="contact-cell";const y=document.createElement("div");y.className="iconContainer",y.title="LinkedIn",y.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="#0a66c2"><path d="M4.98 3.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5zM3 9h4v12H3V9zm7 0h3.8v1.7h.05c.53-1 1.83-2.05 3.77-2.05C21.4 8.65 22 11 22 14.1V21h-4v-6.1c0-1.5-.54-2.5-1.87-2.5-1.02 0-1.63.69-1.9 1.35-.1.23-.13.56-.13.9V21h-4V9z"/></svg>',y.addEventListener("click",()=>window.open("https://www.linkedin.com/company/ag-grid/","_blank")),m.appendChild(y);const E=((P=p.data)==null?void 0:P.orgHierarchy)??[],R=(E[E.length-1]??"").toLowerCase().replace(/\s+/g,"."),S=document.createElement("div");return S.className="iconContainer",S.title="Email",S.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="#39485d"><path d="M2 5h20v14H2V5zm2 2v.7l8 5 8-5V7H4zm0 3.9V17h16v-6.1l-8 5-8-5z"/></svg>',S.addEventListener("click",()=>{window.location.href=`mailto:${R}@company.com`}),m.appendChild(S),m}const h={columnDefs:[{field:"employeeId",headerName:"ID",width:120},{field:"department",width:250,minWidth:250,flex:1,valueFormatter:p=>{const m=String(p.value??"");return jt[m]??m},cellRenderer:c},{field:"employmentType",editable:!0,width:180,minWidth:180,flex:1,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Permanent","Contract"]}},{field:"location",width:200,minWidth:200,flex:1,cellRenderer:d,editable:!0},{field:"joinDate",headerName:"Join Date",editable:!0,width:120},{field:"basicMonthlySalary",headerName:"Salary",valueFormatter:p=>p.value==null?"":`$${Math.round(p.value).toLocaleString()}`},{field:"paymentMethod",headerName:"Payment Method",editable:!0,width:180,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Cash","Check","Bank Transfer"]}},{field:"paymentStatus",headerName:"Status",editable:!0,width:100,cellRenderer:u,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Paid","Pending"]}},{field:"contact",headerName:"Contact",pinned:"right",cellRenderer:f,width:120}],rowData:As(),rowHeight:62,groupDefaultExpanded:-1,treeData:!0,getDataPath:p=>p.orgHierarchy,autoGroupColumnDef:{headerName:"Employee",width:330,pinned:"left",sort:"asc",cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:l}},theme:"ag-theme-quartz"};return n(i.querySelector("#hrGrid"),h),t.handle}const ln=[["#667eea","#764ba2"],["#f093fb","#f5576c"],["#4facfe","#00f2fe"],["#43e97b","#38f9d7"],["#fa709a","#fee140"],["#30cfd0","#330867"],["#a8edea","#fed6e3"],["#ff9a9e","#fecfef"],["#f6d365","#fda085"],["#5ee7df","#b490ca"]];function Vs(s,e){const[t,i]=ln[e%ln.length],n=s.split(/\s+/).slice(0,2).map(a=>a[0]).join("").toUpperCase(),o=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="${t}"/><stop offset="1" stop-color="${i}"/></linearGradient></defs><rect width="120" height="120" rx="8" fill="url(#g)"/><text x="60" y="70" font-family="Arial, sans-serif" font-size="40" font-weight="bold" fill="rgba(255,255,255,0.85)" text-anchor="middle">${n}</text></svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(o)}`}const rn=["Vinyl, LP, Album",'Vinyl, 12", 45 RPM',"Vinyl, LP, Reissue","CD, Album"],cn=["Blue Note","Columbia","Motown","Def Jam","Sub Pop","4AD","Matador","Domino"],dn=["US","UK","Europe","Japan"];function zs(s,e,t){return Array.from({length:s},(i,n)=>({title:e,available:Math.floor(Math.random()*40),format:rn[n%rn.length],label:cn[n%cn.length],cat:`NB ${1e3+n*7}`,country:dn[n%dn.length],year:t}))}const Ws=[{product:"Dreams of You",artist:"David Nearing",category:"Pop",year:"1984",status:"active",available:32,incoming:12,price:24.99,sold:128,priceIncrease:5.2,variants:3},{product:"Blue Skies",artist:"Maya Allen",category:"Rock",year:"1991",status:"active",available:18,incoming:5,price:19.99,sold:76,priceIncrease:2.1,variants:2},{product:"Heaven",artist:"Velvet Wave",category:"Soft Rock",year:"1978",status:"paused",available:0,incoming:0,price:29.99,sold:214,priceIncrease:8.4,variants:4},{product:"Life Matters",artist:"Danielle James",category:"Synth-pop",year:"1986",status:"active",available:45,incoming:20,price:22.5,sold:189,priceIncrease:3.6,variants:3},{product:"Lonely Hearts",artist:"Emma Stone",category:"Electronic",year:"1995",status:"outOfStock",available:0,incoming:8,price:27,sold:92,priceIncrease:1.2,variants:2},{product:"Imaginary Groove",artist:"Leo Collins",category:"Jazz",year:"1972",status:"active",available:27,incoming:15,price:31.99,sold:145,priceIncrease:6.7,variants:3},{product:"Desert Bloom",artist:"Indigo Ray",category:"Trance",year:"2003",status:"active",available:12,incoming:25,price:18.75,sold:63,priceIncrease:.8,variants:2},{product:"Golden Daze",artist:"The Marlowe Sound",category:"Ambient",year:"2011",status:"paused",available:8,incoming:0,price:26.25,sold:41,priceIncrease:4.3,variants:2},{product:"Fragments",artist:"Nova Elle",category:"Alt-pop",year:"2018",status:"active",available:56,incoming:30,price:21,sold:210,priceIncrease:7.1,variants:4},{product:"Solstice City",artist:"Aurora Lines",category:"Rhythm & Blues",year:"1989",status:"active",available:22,incoming:10,price:23.99,sold:167,priceIncrease:2.9,variants:3}];function Us(){return Ws.map((s,e)=>({...s,image:Vs(s.product,e),variantDetails:zs(s.variants,s.product,s.year)}))}function _s(s,e={}){const t=Dt(s,"inventory",`<div class="wrapper">
44
44
  <div class="container">
45
45
  <div class="exampleHeader">
46
46
  <div class="tabs" id="tabs">
@@ -59,7 +59,7 @@ ${m}
59
59
  </div>
60
60
  <div id="inventoryGrid" class="grid ag-theme-quartz"></div>
61
61
  </div>
62
- </div>`,e),{host:i,createGrid:n}=t,o={all:"All",active:"Active",paused:"On Hold",outOfStock:"Out of Stock"};function a(m){return o[String(m.value??"all")]??String(m.value??"")}function r(m){var B,L,j;const y=document.createElement("div");y.className="productCell";const E=document.createElement("img");E.src=((B=m.data)==null?void 0:B.image)??"",E.alt=((L=m.data)==null?void 0:L.product)??"",y.appendChild(E);const R=document.createElement("div"),S=document.createElement("div");S.textContent=String(m.value??"");const A=document.createElement("div");return A.className="stockCell",A.textContent=((j=m.data)==null?void 0:j.category)??"",R.appendChild(S),R.appendChild(A),y.appendChild(R),y}function l(m){const y=String(m.value??""),E=document.createElement("div");E.className=`tag ${y}Tag`;const R=document.createElement("span");R.className=`circle ${y}Circle`,E.appendChild(R);const S=document.createElement("span");return S.textContent=o[y]??y,E.appendChild(S),E}function c(m){var A,B;const y=document.createElement("div");y.className="stock";const E=document.createElement("span");E.textContent=String(((A=m.data)==null?void 0:A.available)??"");const R=document.createElement("span");R.className="stockText",R.textContent="Stock /";const S=document.createElement("span");return S.className="variantsText",S.textContent=`${((B=m.data)==null?void 0:B.variants)??0} Variants`,y.appendChild(E),y.appendChild(R),y.appendChild(S),y}function d(m){var S;const y=document.createElement("div");y.className="price";const E=document.createElement("span");E.className="priceAmount",E.textContent=`£${Number(m.value??0).toFixed(2)}`;const R=document.createElement("span");return R.className="increase",R.textContent=`${((S=m.data)==null?void 0:S.priceIncrease)??0}% increase`,y.appendChild(E),y.appendChild(R),y}function u(m){const y=document.createElement("div");y.className="buttonCell";const E=document.createElement("button");E.className="removeButton",E.title="Remove",E.innerHTML='<svg viewBox="0 0 24 24" width="20" height="20" fill="#98a2b3"><path d="M7 21q-.825 0-1.412-.587Q5 19.825 5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413Q17.825 21 17 21zM17 6H7v13h10zM9 17h2V8H9zm4 0h2V8h-2z"/></svg>',E.addEventListener("click",()=>{m.api.applyTransaction({remove:[m.node.data]})}),y.appendChild(E);const R=document.createElement("button");return R.className="buttonStopSelling",R.textContent="Hold Selling",R.addEventListener("click",()=>{const S={...m.node.data};S.status!=="paused"?S.status="paused":S.available<=0?S.status="outOfStock":S.status="active",m.api.applyTransaction({update:[S]})}),y.appendChild(R),y}const f=[{field:"product",headerName:"Album Name",minWidth:300,cellRenderer:"agGroupCellRenderer",cellRendererParams:{innerRenderer:r},headerClass:"header-product"},{field:"artist",headerName:"Artist"},{field:"year",headerName:"Year",width:150,headerClass:"header-sku"},{field:"status",headerName:"Status",minWidth:140,filter:"set",filterParams:{valueFormatter:a},cellRenderer:l,headerClass:"header-status"},{field:"inventory",headerName:"Inventory",cellRenderer:c,sortable:!1,headerClass:"header-inventory"},{field:"incoming",headerName:"Incoming",editable:!0,cellEditorParams:{precision:0,step:1,showStepperButtons:!0}},{field:"price",headerName:"Price",width:120,cellRenderer:d,headerClass:"header-price"},{field:"sold",headerName:"Sold",headerClass:"header-calendar"},{colId:"profit",headerName:"Est. Profit",cellDataType:!0,valueGetter:m=>m.data.price*m.data.sold/10,valueFormatter:m=>`£${m.value}`,width:150,headerClass:"header-percentage"},{field:"actions",headerName:"Actions",minWidth:194,cellRenderer:u,sortable:!1,filter:!1}],g={columnDefs:[{field:"title",headerName:"Title",flex:1.5},{field:"available",headerName:"Available",maxWidth:120},{field:"format",headerName:"Format",flex:2},{field:"label",headerName:"Label",flex:1},{field:"country",headerName:"Country",flex:.66},{field:"cat",headerName:"Cat#",type:"rightAligned",flex:.66},{field:"year",headerName:"Year",type:"rightAligned",maxWidth:80}],headerHeight:38,defaultColDef:{flex:1,resizable:!0}},{api:p}=n(i.querySelector("#inventoryGrid"),{columnDefs:f,rowData:_s(),rowHeight:80,defaultColDef:{resizable:!1},autoSizeStrategy:{type:"fitGridWidth"},pagination:!0,paginationPageSize:10,paginationPageSizeSelector:[5,10,20],masterDetail:!0,detailRowAutoHeight:!0,detailCellRendererParams:{detailGridOptions:g,getDetailRowData:m=>m.data.variantDetails},theme:"ag-theme-quartz"}),C=i.querySelector("#tabs");C.addEventListener("click",m=>{const E=m.target.closest(".tab");if(!E)return;for(const S of C.querySelectorAll(".tab"))S.classList.remove("active");E.classList.add("active");const R=E.dataset.key;p.setColumnFilterModel("status",R==="all"?null:{filterType:"set",values:[R]}),p.onFilterChanged()});const h=i.querySelector("#filter-text-box");return h.addEventListener("input",()=>{p.setQuickFilter(h.value)}),t.handle}const gi=["Ireland","Spain","United Kingdom","France","Germany","Italy","Netherlands","Portugal","Australia","Canada","Japan","Sweden"],fi=["English","Spanish","French","German","Italian","Portuguese","Dutch","Japanese","Swedish","Mandarin"],mi=["Chess","Go","Bridge","Poker","Backgammon","Checkers","Mahjong","Sudoku","Scrabble","Risk","Catan","Dungeons & Dragons"],vi=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],un=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia","Kai","Lena","Milo","Nora","Omar","Petra","Quinn","Rosa","Sam","Tessa"],hn=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes","Ibarra","Jensen","Klein","Larsen","Moreau","Novak","Ortiz","Pavel","Quintero","Rossi","Silva","Turner"];function pn(s=12345){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}let Ze=pn();function Ks(){Ze=pn(98765)}function js(s,e){const t={name:`${un[s%un.length]} ${hn[s%hn.length]}`,language:fi[Math.floor(Ze()*fi.length)],country:gi[Math.floor(Ze()*gi.length)],game:{name:mi[Math.floor(Ze()*mi.length)],bought:Ze()<.5},bankBalance:Math.round(Ze()*1e5)-3e3,rating:Math.round(Ze()*5)};let i=0;for(const n of vi){const o=Math.round(Ze()*1e5)-20;t[n]=o,i+=o}t.totalWinnings=i;for(let n=1;n<=e;n++)t[`col${n}`]=Math.round(Ze()*1e5)-500;return t}function Xs(s,e){const t=[];for(let i=0;i<s;i++)t.push(js(i,e));return t}const Ys=[{group:"Performance",count:10},{group:"Tournaments",count:8},{group:"Social",count:6},{group:"Financial",count:8},{group:"Game Details",count:8},{group:"Training",count:8},{group:"Seasonal",count:8},{group:"Equipment",count:6},{group:"Miscellaneous",count:7}],Xt=["currency","percent","rating","text","number"];function Qs(s){const e=[];let t=0;for(const i of Ys)for(let n=0;n<i.count&&t<s;n++,t++){const o=Xt[t%Xt.length],a=o==="currency"?160:o==="percent"?130:o==="rating"?120:o==="text"?160:140;e.push({field:`col${t+1}`,group:i.group,dataType:o,width:a})}for(;t<s;){t++;const i=Xt[(t+3)%Xt.length],n=i==="currency"?160:i==="percent"?130:i==="rating"?120:i==="text"?160:140;e.push({field:`col${t}`,group:"Miscellaneous",dataType:i,width:n})}return e}function Js(s,e={}){const t=Dt(s,"performance",`<div class="exampleWrapper">
62
+ </div>`,e),{host:i,createGrid:n}=t,o={all:"All",active:"Active",paused:"On Hold",outOfStock:"Out of Stock"};function a(m){return o[String(m.value??"all")]??String(m.value??"")}function r(m){var B,A,j;const y=document.createElement("div");y.className="productCell";const E=document.createElement("img");E.src=((B=m.data)==null?void 0:B.image)??"",E.alt=((A=m.data)==null?void 0:A.product)??"",y.appendChild(E);const R=document.createElement("div"),S=document.createElement("div");S.textContent=String(m.value??"");const P=document.createElement("div");return P.className="stockCell",P.textContent=((j=m.data)==null?void 0:j.category)??"",R.appendChild(S),R.appendChild(P),y.appendChild(R),y}function l(m){const y=String(m.value??""),E=document.createElement("div");E.className=`tag ${y}Tag`;const R=document.createElement("span");R.className=`circle ${y}Circle`,E.appendChild(R);const S=document.createElement("span");return S.textContent=o[y]??y,E.appendChild(S),E}function c(m){var P,B;const y=document.createElement("div");y.className="stock";const E=document.createElement("span");E.textContent=String(((P=m.data)==null?void 0:P.available)??"");const R=document.createElement("span");R.className="stockText",R.textContent="Stock /";const S=document.createElement("span");return S.className="variantsText",S.textContent=`${((B=m.data)==null?void 0:B.variants)??0} Variants`,y.appendChild(E),y.appendChild(R),y.appendChild(S),y}function d(m){var S;const y=document.createElement("div");y.className="price";const E=document.createElement("span");E.className="priceAmount",E.textContent=`£${Number(m.value??0).toFixed(2)}`;const R=document.createElement("span");return R.className="increase",R.textContent=`${((S=m.data)==null?void 0:S.priceIncrease)??0}% increase`,y.appendChild(E),y.appendChild(R),y}function u(m){const y=document.createElement("div");y.className="buttonCell";const E=document.createElement("button");E.className="removeButton",E.title="Remove",E.innerHTML='<svg viewBox="0 0 24 24" width="20" height="20" fill="#98a2b3"><path d="M7 21q-.825 0-1.412-.587Q5 19.825 5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413Q17.825 21 17 21zM17 6H7v13h10zM9 17h2V8H9zm4 0h2V8h-2z"/></svg>',E.addEventListener("click",()=>{m.api.applyTransaction({remove:[m.node.data]})}),y.appendChild(E);const R=document.createElement("button");return R.className="buttonStopSelling",R.textContent="Hold Selling",R.addEventListener("click",()=>{const S={...m.node.data};S.status!=="paused"?S.status="paused":S.available<=0?S.status="outOfStock":S.status="active",m.api.applyTransaction({update:[S]})}),y.appendChild(R),y}const f=[{field:"product",headerName:"Album Name",minWidth:300,cellRenderer:"agGroupCellRenderer",cellRendererParams:{innerRenderer:r},headerClass:"header-product"},{field:"artist",headerName:"Artist"},{field:"year",headerName:"Year",width:150,headerClass:"header-sku"},{field:"status",headerName:"Status",minWidth:140,filter:"set",filterParams:{valueFormatter:a},cellRenderer:l,headerClass:"header-status"},{field:"inventory",headerName:"Inventory",cellRenderer:c,sortable:!1,headerClass:"header-inventory"},{field:"incoming",headerName:"Incoming",editable:!0,cellEditorParams:{precision:0,step:1,showStepperButtons:!0}},{field:"price",headerName:"Price",width:120,cellRenderer:d,headerClass:"header-price"},{field:"sold",headerName:"Sold",headerClass:"header-calendar"},{colId:"profit",headerName:"Est. Profit",cellDataType:!0,valueGetter:m=>m.data.price*m.data.sold/10,valueFormatter:m=>`£${m.value}`,width:150,headerClass:"header-percentage"},{field:"actions",headerName:"Actions",minWidth:194,cellRenderer:u,sortable:!1,filter:!1}],g={columnDefs:[{field:"title",headerName:"Title",flex:1.5},{field:"available",headerName:"Available",maxWidth:120},{field:"format",headerName:"Format",flex:2},{field:"label",headerName:"Label",flex:1},{field:"country",headerName:"Country",flex:.66},{field:"cat",headerName:"Cat#",type:"rightAligned",flex:.66},{field:"year",headerName:"Year",type:"rightAligned",maxWidth:80}],headerHeight:38,defaultColDef:{flex:1,resizable:!0}},{api:w}=n(i.querySelector("#inventoryGrid"),{columnDefs:f,rowData:Us(),rowHeight:80,defaultColDef:{resizable:!1},autoSizeStrategy:{type:"fitGridWidth"},pagination:!0,paginationPageSize:10,paginationPageSizeSelector:[5,10,20],masterDetail:!0,detailRowAutoHeight:!0,detailCellRendererParams:{detailGridOptions:g,getDetailRowData:m=>m.data.variantDetails},theme:"ag-theme-quartz"}),h=i.querySelector("#tabs");h.addEventListener("click",m=>{const E=m.target.closest(".tab");if(!E)return;for(const S of h.querySelectorAll(".tab"))S.classList.remove("active");E.classList.add("active");const R=E.dataset.key;w.setColumnFilterModel("status",R==="all"?null:{filterType:"set",values:[R]}),w.onFilterChanged()});const p=i.querySelector("#filter-text-box");return p.addEventListener("input",()=>{w.setQuickFilter(p.value)}),t.handle}const gi=["Ireland","Spain","United Kingdom","France","Germany","Italy","Netherlands","Portugal","Australia","Canada","Japan","Sweden"],fi=["English","Spanish","French","German","Italian","Portuguese","Dutch","Japanese","Swedish","Mandarin"],mi=["Chess","Go","Bridge","Poker","Backgammon","Checkers","Mahjong","Sudoku","Scrabble","Risk","Catan","Dungeons & Dragons"],vi=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],un=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia","Kai","Lena","Milo","Nora","Omar","Petra","Quinn","Rosa","Sam","Tessa"],hn=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes","Ibarra","Jensen","Klein","Larsen","Moreau","Novak","Ortiz","Pavel","Quintero","Rossi","Silva","Turner"];function pn(s=12345){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}let Ze=pn();function qs(){Ze=pn(98765)}function Ks(s,e){const t={name:`${un[s%un.length]} ${hn[s%hn.length]}`,language:fi[Math.floor(Ze()*fi.length)],country:gi[Math.floor(Ze()*gi.length)],game:{name:mi[Math.floor(Ze()*mi.length)],bought:Ze()<.5},bankBalance:Math.round(Ze()*1e5)-3e3,rating:Math.round(Ze()*5)};let i=0;for(const n of vi){const o=Math.round(Ze()*1e5)-20;t[n]=o,i+=o}t.totalWinnings=i;for(let n=1;n<=e;n++)t[`col${n}`]=Math.round(Ze()*1e5)-500;return t}function js(s,e){const t=[];for(let i=0;i<s;i++)t.push(Ks(i,e));return t}const Xs=[{group:"Performance",count:10},{group:"Tournaments",count:8},{group:"Social",count:6},{group:"Financial",count:8},{group:"Game Details",count:8},{group:"Training",count:8},{group:"Seasonal",count:8},{group:"Equipment",count:6},{group:"Miscellaneous",count:7}],Xt=["currency","percent","rating","text","number"];function Ys(s){const e=[];let t=0;for(const i of Xs)for(let n=0;n<i.count&&t<s;n++,t++){const o=Xt[t%Xt.length],a=o==="currency"?160:o==="percent"?130:o==="rating"?120:o==="text"?160:140;e.push({field:`col${t+1}`,group:i.group,dataType:o,width:a})}for(;t<s;){t++;const i=Xt[(t+3)%Xt.length],n=i==="currency"?160:i==="percent"?130:i==="rating"?120:i==="text"?160:140;e.push({field:`col${t}`,group:"Miscellaneous",dataType:i,width:n})}return e}function Qs(s,e={}){const t=Dt(s,"performance",`<div class="exampleWrapper">
63
63
  <div class="toolbar">
64
64
  <div class="controls">
65
65
  <div class="group">
@@ -89,7 +89,7 @@ ${m}
89
89
  <section class="gridWrapper">
90
90
  <div id="performanceGrid" class="gridSurface ag-theme-quartz"></div>
91
91
  </section>
92
- </div>`,e),{host:i,createGrid:n}=t,o={Ireland:"🇮🇪",Spain:"🇪🇸","United Kingdom":"🇬🇧",France:"🇫🇷",Germany:"🇩🇪",Italy:"🇮🇹",Netherlands:"🇳🇱",Portugal:"🇵🇹",Australia:"🇦🇺",Canada:"🇨🇦",Japan:"🇯🇵",Sweden:"🇸🇪"},a=S=>S.value==null?"":`$${Math.round(S.value).toLocaleString("en-US")}`;function r(S){const A=document.createElement("span");A.style.display="inline-flex",A.style.alignItems="center",A.style.gap="6px";const B=document.createElement("span");B.textContent=o[String(S.value)]??"🏳️",B.style.fontSize="15px";const L=document.createElement("span");return L.textContent=String(S.value??""),L.style.overflow="hidden",L.style.textOverflow="ellipsis",L.style.whiteSpace="nowrap",A.appendChild(B),A.appendChild(L),A}const l='<svg class="starIcon" viewBox="0 0 24 24" width="12" height="12" fill="#f59e0b"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>';function c(S){const A=document.createElement("span");A.className="v-align";const B=Number(S.value??0);if(B===0&&S.isFilterRenderer)return A.textContent="(No stars)",A;for(let L=0;L<B;L++){const j=document.createElement("span");j.innerHTML=l,A.appendChild(j)}return A}function d(S){return S.value===null||S.value===void 0?null:S.value<0?{color:"#e11d48",fontWeight:"bold"}:null}function u(S){const A=[{headerName:"Participant",groupId:"participant",openByDefault:!0,children:[{field:"name",width:200,rowDrag:!0,enableRowGroup:!0,editable:!0},{field:"language",width:150,enableRowGroup:!0,enablePivot:!0,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:fi},filter:"set",editable:!0},{field:"country",width:150,cellRenderer:r,cellEditor:"agRichSelectCellEditor",cellEditorParams:{cellRenderer:r,values:gi},filter:"set",enableRowGroup:!0,enablePivot:!0,editable:!0}]},{headerName:"Game of Choice",groupId:"gameOfChoice",openByDefault:!0,children:[{field:"game.name",headerName:"Game",width:180,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:mi,allowTyping:!0,searchType:"matchAny",filterList:!0,highlightMatch:!0},filter:"set",enableRowGroup:!0,enablePivot:!0,cellClass:"alphabet",editable:!0},{field:"game.bought",headerName:"Bought",width:110,filter:"set",cellClass:"boolean-type",enableRowGroup:!0,enablePivot:!0,editable:!0}]},{headerName:"Performance",groupId:"performance",openByDefault:!0,children:[{field:"bankBalance",headerName:"Bank Balance",width:150,aggFunc:"avg",cellDataType:!0,filter:"number",cellClassRules:{"currency-cell":B=>typeof B.value=="number"},editable:!0},{field:"rating",headerName:"Rating",width:120,cellRenderer:c,cellEditor:"agNumberCellEditor",cellEditorParams:{min:0,max:5},filterParams:{cellRenderer:c,cellRendererParams:{isFilterRenderer:!0}},aggFunc:"avg",enableRowGroup:!0,enablePivot:!0,enableValue:!0,cellClass:"v-align",editable:!0},{field:"totalWinnings",headerName:"Total Winnings",width:200,aggFunc:"sum",cellDataType:!0,filter:"number",cellStyle:d,cellClassRules:{"currency-cell":B=>typeof B.value=="number"},editable:!0}]},{headerName:"Monthly Breakdown",groupId:"monthlyBreakdown",openByDefault:!0,children:[{colId:"winningTrends",headerName:"Winning Trends",width:200,sortable:!1,filter:!1,cellRenderer:"agSparklineCellRenderer",valueGetter:B=>vi.map(L=>({month:L,value:B.data[L]})),cellRendererParams:{sparklineOptions:{type:"area"}}},...vi.map(B=>({field:B,headerName:B.charAt(0).toUpperCase()+B.slice(1),width:120,enableValue:!0,aggFunc:"sum",cellDataType:!0,filter:"number",filterParams:{buttons:["reset"],inRangeInclusive:!0},cellClassRules:{"good-score":L=>typeof L.value=="number"&&L.value>5e4,"bad-score":L=>typeof L.value=="number"&&L.value<1e4,"currency-cell":L=>typeof L.value=="number"&&L.value>=1e4&&L.value<=5e4},editable:!0}))]}];if(S>0){const B=Qs(S),L=new Map;for(const j of B)L.has(j.group)||L.set(j.group,[]),L.get(j.group).push(j);for(const[j,W]of L)A.push({headerName:j,groupId:`extra-${j}`,openByDefault:!0,children:W.map(M=>({field:M.field,headerName:M.field,width:M.width,editable:!0,cellDataType:M.dataType!=="text",filter:M.dataType==="text"?"set":"number",valueFormatter:M.dataType==="percent"?D=>D.value==null?"":`${D.value.toFixed(1)}%`:M.dataType==="currency"?a:void 0,aggFunc:M.dataType==="text"?void 0:"sum"}))})}return A}const f=i.querySelector("#performanceGrid"),g=i.querySelector("#data-size"),p=i.querySelector("#theme-select"),C=i.querySelector("#global-filter");let h=null,m,y=0;function E(){m!==void 0&&window.clearTimeout(m),m=t.timeout(()=>R(),10)}function R(){var Q;const S=++y,[A,B]=g.value.split("x").map(Number),L=Math.max(0,B-24),j=p.value;if(h&&(h.destroy(),h=null,f.innerHTML=""),h=n(f,{columnDefs:u(L),rowData:[],theme:j,rowNumbers:!0,rowHeight:42,defaultColDef:{minWidth:50,editable:!0,filter:!0,floatingFilter:!0,enableCellChangeFlash:!0},rowGroupPanelShow:"always",autoGroupColumnDef:{headerName:"Group",width:250,field:"name"},sideBar:{toolPanels:["columns","filters","charts"],position:"right",defaultToolPanel:"columns"},statusBar:{statusPanels:[{statusPanel:"agTotalAndFilteredRowCountComponent",align:"left"},{statusPanel:"agSelectedRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},rowSelection:"multiple",enableRangeSelection:!0,enableCharts:!0}).api,(Q=e.gridOptions)!=null&&Q.rowData)return;h.showLoadingOverlay();const W=A>1e4?1e4:1e3,M=Math.ceil(A/W);let D=0;const k=[],z=Date.now();Ks();const _=()=>{if(S!==y)return;const ne=Xs(Math.min(W,A-D*W),L);if(k.push(...ne),D++,D<M)t.timeout(_,0);else{const U=Date.now()-z,F=Math.max(0,500-U);t.timeout(()=>{S===y&&(h==null||h.hideOverlay(),h==null||h.setRowData(k))},F)}};t.timeout(_,0)}return g.addEventListener("change",E),p.addEventListener("change",E),C.addEventListener("input",()=>{h==null||h.setQuickFilter(C.value)}),R(),t.handle}function Zs(s,e={}){const t=Dt(s,"server-side",`<div class="exampleWrapper">
92
+ </div>`,e),{host:i,createGrid:n}=t,o={Ireland:"🇮🇪",Spain:"🇪🇸","United Kingdom":"🇬🇧",France:"🇫🇷",Germany:"🇩🇪",Italy:"🇮🇹",Netherlands:"🇳🇱",Portugal:"🇵🇹",Australia:"🇦🇺",Canada:"🇨🇦",Japan:"🇯🇵",Sweden:"🇸🇪"},a=S=>S.value==null?"":`$${Math.round(S.value).toLocaleString("en-US")}`;function r(S){const P=document.createElement("span");P.style.display="inline-flex",P.style.alignItems="center",P.style.gap="6px";const B=document.createElement("span");B.textContent=o[String(S.value)]??"🏳️",B.style.fontSize="15px";const A=document.createElement("span");return A.textContent=String(S.value??""),A.style.overflow="hidden",A.style.textOverflow="ellipsis",A.style.whiteSpace="nowrap",P.appendChild(B),P.appendChild(A),P}const l='<svg class="starIcon" viewBox="0 0 24 24" width="12" height="12" fill="#f59e0b"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>';function c(S){const P=document.createElement("span");P.className="v-align";const B=Number(S.value??0);if(B===0&&S.isFilterRenderer)return P.textContent="(No stars)",P;for(let A=0;A<B;A++){const j=document.createElement("span");j.innerHTML=l,P.appendChild(j)}return P}function d(S){return S.value===null||S.value===void 0?null:S.value<0?{color:"#e11d48",fontWeight:"bold"}:null}function u(S){const P=[{headerName:"Participant",groupId:"participant",openByDefault:!0,children:[{field:"name",width:200,rowDrag:!0,enableRowGroup:!0,editable:!0},{field:"language",width:150,enableRowGroup:!0,enablePivot:!0,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:fi},filter:"set",editable:!0},{field:"country",width:150,cellRenderer:r,cellEditor:"agRichSelectCellEditor",cellEditorParams:{cellRenderer:r,values:gi},filter:"set",enableRowGroup:!0,enablePivot:!0,editable:!0}]},{headerName:"Game of Choice",groupId:"gameOfChoice",openByDefault:!0,children:[{field:"game.name",headerName:"Game",width:180,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:mi,allowTyping:!0,searchType:"matchAny",filterList:!0,highlightMatch:!0},filter:"set",enableRowGroup:!0,enablePivot:!0,cellClass:"alphabet",editable:!0},{field:"game.bought",headerName:"Bought",width:110,filter:"set",cellClass:"boolean-type",enableRowGroup:!0,enablePivot:!0,editable:!0}]},{headerName:"Performance",groupId:"performance",openByDefault:!0,children:[{field:"bankBalance",headerName:"Bank Balance",width:150,aggFunc:"avg",cellDataType:!0,filter:"number",cellClassRules:{"currency-cell":B=>typeof B.value=="number"},editable:!0},{field:"rating",headerName:"Rating",width:120,cellRenderer:c,cellEditor:"agNumberCellEditor",cellEditorParams:{min:0,max:5},filterParams:{cellRenderer:c,cellRendererParams:{isFilterRenderer:!0}},aggFunc:"avg",enableRowGroup:!0,enablePivot:!0,enableValue:!0,cellClass:"v-align",editable:!0},{field:"totalWinnings",headerName:"Total Winnings",width:200,aggFunc:"sum",cellDataType:!0,filter:"number",cellStyle:d,cellClassRules:{"currency-cell":B=>typeof B.value=="number"},editable:!0}]},{headerName:"Monthly Breakdown",groupId:"monthlyBreakdown",openByDefault:!0,children:[{colId:"winningTrends",headerName:"Winning Trends",width:200,sortable:!1,filter:!1,cellRenderer:"agSparklineCellRenderer",valueGetter:B=>vi.map(A=>({month:A,value:B.data[A]})),cellRendererParams:{sparklineOptions:{type:"area"}}},...vi.map(B=>({field:B,headerName:B.charAt(0).toUpperCase()+B.slice(1),width:120,enableValue:!0,aggFunc:"sum",cellDataType:!0,filter:"number",filterParams:{buttons:["reset"],inRangeInclusive:!0},cellClassRules:{"good-score":A=>typeof A.value=="number"&&A.value>5e4,"bad-score":A=>typeof A.value=="number"&&A.value<1e4,"currency-cell":A=>typeof A.value=="number"&&A.value>=1e4&&A.value<=5e4},editable:!0}))]}];if(S>0){const B=Ys(S),A=new Map;for(const j of B)A.has(j.group)||A.set(j.group,[]),A.get(j.group).push(j);for(const[j,W]of A)P.push({headerName:j,groupId:`extra-${j}`,openByDefault:!0,children:W.map(T=>({field:T.field,headerName:T.field,width:T.width,editable:!0,cellDataType:T.dataType!=="text",filter:T.dataType==="text"?"set":"number",valueFormatter:T.dataType==="percent"?F=>F.value==null?"":`${F.value.toFixed(1)}%`:T.dataType==="currency"?a:void 0,aggFunc:T.dataType==="text"?void 0:"sum"}))})}return P}const f=i.querySelector("#performanceGrid"),g=i.querySelector("#data-size"),w=i.querySelector("#theme-select"),h=i.querySelector("#global-filter");let p=null,m,y=0;function E(){m!==void 0&&window.clearTimeout(m),m=t.timeout(()=>R(),10)}function R(){var Q;const S=++y,[P,B]=g.value.split("x").map(Number),A=Math.max(0,B-24),j=w.value;if(p&&(p.destroy(),p=null,f.innerHTML=""),p=n(f,{columnDefs:u(A),rowData:[],theme:j,rowNumbers:!0,rowHeight:42,defaultColDef:{minWidth:50,editable:!0,filter:!0,floatingFilter:!0,enableCellChangeFlash:!0},rowGroupPanelShow:"always",autoGroupColumnDef:{headerName:"Group",width:250,field:"name"},sideBar:{toolPanels:["columns","filters","charts"],position:"right",defaultToolPanel:"columns"},statusBar:{statusPanels:[{statusPanel:"agTotalAndFilteredRowCountComponent",align:"left"},{statusPanel:"agSelectedRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},rowSelection:"multiple",enableRangeSelection:!0,enableCharts:!0}).api,(Q=e.gridOptions)!=null&&Q.rowData)return;p.showLoadingOverlay();const W=P>1e4?1e4:1e3,T=Math.ceil(P/W);let F=0;const N=[],z=Date.now();qs();const _=()=>{if(S!==y)return;const ie=js(Math.min(W,P-F*W),A);if(N.push(...ie),F++,F<T)t.timeout(_,0);else{const U=Date.now()-z,$=Math.max(0,500-U);t.timeout(()=>{S===y&&(p==null||p.hideOverlay(),p==null||p.setRowData(N))},$)}};t.timeout(_,0)}return g.addEventListener("change",E),w.addEventListener("change",E),h.addEventListener("input",()=>{p==null||p.setQuickFilter(h.value)}),R(),t.handle}function Js(s,e={}){const t=Dt(s,"server-side",`<div class="exampleWrapper">
93
93
  <div class="toolbar">
94
94
  <div class="controls">
95
95
  <div class="group">
@@ -105,16 +105,16 @@ ${m}
105
105
  <section class="gridWrapper">
106
106
  <div id="serverSideGrid" class="gridSurface ag-theme-quartz"></div>
107
107
  </section>
108
- </div>`,e),{host:i,createGrid:n}=t,o=hi(2024),a=["Ireland","Spain","France","Germany","Italy","Portugal","Netherlands"],r=["Engineering","Design","Product","Sales","Support","Finance"],l=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia"],c=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes"],d=Array.from({length:5e4},(C,h)=>({id:h,name:`${l[h%l.length]} ${c[h*7%c.length]}`,country:a[h%a.length],department:r[h*3%r.length],salary:4e4+Math.floor(o()*8e4),rating:Math.floor(o()*6),started:`${2015+h%10}-0${1+h%9}-1${h%9}`})),u=120;function f(C){var S,A;let h=d.slice();const m=Object.entries(C.filterModel||{});if(m.length&&(h=h.filter(B=>m.every(([L,j])=>{const W=B[L],M=String(W).toLowerCase(),D=String(j.filter??"").toLowerCase();if(!D)return!0;switch(j.type){case"notEqual":return M!==D;case"startsWith":return M.startsWith(D);case"endsWith":return M.endsWith(D);default:return M.includes(D)}}))),(S=C.sortModel)!=null&&S.length){const{colId:B,sort:L}=C.sortModel[0];h=h.slice().sort((j,W)=>{const M=j[B]===W[B]?0:j[B]<W[B]?-1:1;return L==="asc"?M:-M})}const y=C.groupKeys||[],E=(A=C.rowGroupCols)==null?void 0:A[y.length];if(E){const B=h.filter(M=>y.every((D,k)=>{const z=C.rowGroupCols[k];return String(M[z.field])===D})),L=new Map,j=[];for(const M of B){const D=String(M[E.field]);L.has(D)||(L.set(D,{count:0,salary:[]}),j.push(D));const k=L.get(D);k.count++,k.salary.push(M.salary)}const W=j.map(M=>{const D=L.get(M),k={id:`group-${y.join("/")}-${E.field}-${M}`,__isGroup:!0,childCount:D.count};return k[E.field]=M,k.salary=Math.round(D.salary.reduce((z,_)=>z+_,0)/D.salary.length),k});return{rows:W,lastRow:W.length}}return{rows:h.slice(C.startRow,C.endRow),lastRow:h.length}}const g=[{field:"name",headerName:"Name",width:220,enableRowGroup:!0,filter:"text"},{field:"country",headerName:"Country",width:160,enableRowGroup:!0,filter:"text"},{field:"department",headerName:"Department",width:180,enableRowGroup:!0,filter:"text"},{field:"salary",headerName:"Avg Salary",width:160,aggFunc:"avg",type:"numberColumn",filter:"number"},{field:"rating",headerName:"Rating",width:120,type:"numberColumn",filter:"number"},{field:"started",headerName:"Started",width:140,filter:"text"}],{api:p}=n(i.querySelector("#serverSideGrid"),{columnDefs:g,rowData:[],rowModelType:"serverSide",serverSideDatasource:{getRows:C=>{t.timeout(()=>{const{rows:h,lastRow:m}=f(C);C.successCallback(h,m)},u)}},rowGroupPanelShow:"always",groupDefaultExpanded:-1,rowHeight:42,sideBar:{toolPanels:["columns","filters"],position:"right"},statusBar:{statusPanels:[{statusPanel:"agTotalRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},enableRangeSelection:!0,theme:"ag-theme-quartz"});return i.querySelector("#refresh").addEventListener("click",()=>{p.refreshServerSide({purge:!0})}),i.querySelector("#purge").addEventListener("click",()=>{p.purgeServerSideCache()}),t.handle}const ye=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},ea=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),gn=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function Ft(s){const e=document.createElement("template");e.innerHTML=String(s??"");const t=i=>{for(const n of[...i.childNodes]){if(n.nodeType!==1)continue;const o=n;if(["SCRIPT","STYLE","IFRAME","OBJECT","SVG","MATH"].includes(o.tagName)){o.remove();continue}if(t(o),!ea.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",r=o.hasAttribute("checked"),l=o.getAttribute("data-task")==="true",c=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(u=>[u,o.style.getPropertyValue(u)]),d=o.tagName==="FONT"?o.getAttribute("color"):null;for(const u of[...o.attributes])o.removeAttribute(u.name);for(const[u,f]of c)(u==="color"||u==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(f):u==="text-align"?/^(left|center|right|justify)$/.test(f):u==="margin-left"?/^\d{1,3}px$/.test(f):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(f))&&o.style.setProperty(u,f);d&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(d)&&(o.style.color=d),o.tagName==="A"&&gn(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),r&&o.setAttribute("checked","")),l&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const Ci={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 ta(s){const e=ye("div",`fc-rich${s.surface==="cell"?" fc-rich-compact":""}`),t=ye("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const i=ye("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=Ft(s.value);const n=ye("div","fc-rich-menu");n.hidden=!0;let o=null,a=!1,r=[i.innerHTML],l=0,c=!1,d=null;const u=()=>{const M=window.getSelection();M!=null&&M.rangeCount&&i.contains(M.anchorNode)&&i.contains(M.focusNode)&&(o=M.getRangeAt(0).cloneRange())},f=()=>{i.focus();const M=window.getSelection();if(!M)return;const D=o&&i.contains(o.commonAncestorContainer)?o:document.createRange();D!==o&&(D.selectNodeContents(i),D.collapse(!1)),M.removeAllRanges(),M.addRange(D),o=D},g=()=>{n.hidden=!0,n.replaceChildren()},p=new Map,C=()=>{var M;p.get("撤销").disabled=s.readonly||l===0,p.get("重做").disabled=s.readonly||l===r.length-1;for(const[D,k]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=p.get(D);if(!z)continue;const _=!!((M=document.queryCommandState)!=null&&M.call(document,k));z.classList.toggle("active",_),z.setAttribute("aria-pressed",String(_))}},h=()=>{c||(i.innerHTML!==r[l]&&(r=r.slice(0,l+1),r.push(i.innerHTML),r.length>100&&r.shift(),l=r.length-1),u(),C())},m=()=>{h(),i.dispatchEvent(new Event("change",{bubbles:!0}))},y=M=>{const D=l+M;D<0||D>=r.length||(l=D,c=!0,i.innerHTML=r[l],o=null,f(),c=!1,C(),i.dispatchEvent(new Event("change",{bubbles:!0})))},E=(M,D)=>{s.readonly||(f(),document.execCommand(M,!1,D),u(),g(),m())},R=M=>{if(s.readonly)return;f();const D=window.getSelection().getRangeAt(0);D.deleteContents(),D.insertNode(M),D.setStartAfter(M),D.collapse(!0),o=D.cloneRange(),g(),m()},S=(M,D,k,z=!0)=>{const _=ye("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return _.type="button",_.ariaLabel=M,_.title=M,_.disabled=s.readonly,Ci[D]?_.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Ci[D]}</svg>`:_.textContent=D,_.onmousedown=Q=>{Q.preventDefault(),u()},_.onclick=Q=>{Q.stopPropagation(),k()},t.append(_),p.set(M,_),_},A=(M,D)=>{if(u(),!n.hidden&&n.ariaLabel===M){g();return}n.replaceChildren(),n.className="fc-rich-menu",n.ariaLabel=M,D(),n.hidden=!1;const k=p.get(M);n.style.left=`${Math.max(4,Math.min(k.offsetLeft,e.clientWidth-280))}px`},B=(M,D)=>{const k=ye("button","fc-rich-menu-option",M);return k.type="button",k.onmousedown=z=>z.preventDefault(),k.onclick=z=>{z.stopPropagation(),D()},n.append(k),k};S("撤销","undo",()=>y(-1),!1),S("重做","redo",()=>y(1),!1),S("格式刷","paint",()=>{u();const M=o==null?void 0:o.startContainer,D=(M==null?void 0:M.nodeType)===1?M:M==null?void 0:M.parentElement;!D||!i.contains(D)||(d={tag:/^(B|STRONG|I|EM|U|S)$/.test(D.tagName)?D.tagName.toLowerCase():"span",css:D.getAttribute("style")||""},p.get("格式刷").classList.add("active"))}),S("正文样式","Aa⌄",()=>A("正文样式",()=>{for(const[M,D]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])B(M,()=>E("formatBlock",D))}));const L=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[M,D,k]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])S(M,D,()=>A(M,()=>{n.classList.add("fc-rich-colors");for(const z of L){const _=B(z,()=>E(k,z));_.textContent="",_.style.backgroundColor=z,_.ariaLabel=`${M} ${z}`}B("清除",()=>E(k,k==="foreColor"?"#1f2329":"transparent"))}));for(const[M,D,k]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])S(M,D,()=>E(k));S("对齐","☰⌄",()=>A("对齐",()=>{for(const[M,D]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])B(M,()=>E(D))})),S("有序列表","1≡",()=>E("insertOrderedList")),S("无序列表","•≡",()=>E("insertUnorderedList")),S("任务列表","task",()=>{f();const M=window.getSelection().getRangeAt(0),D=ye("ul"),k=ye("li");k.dataset.task="true";const z=ye("input");z.type="checkbox",z.contentEditable="false",k.append(z,M.extractContents()),k.textContent||k.append(document.createTextNode("待办事项")),D.append(k),R(D)}),S("引用","quote",()=>E("formatBlock","blockquote")),S("缩进","indent",()=>A("缩进",()=>{B("增加缩进",()=>E("indent")),B("减少缩进",()=>E("outdent"))})),S("分隔线","line",()=>R(ye("hr"))),S("表格","table",()=>A("表格",()=>{const M=ye("p","","选择行列"),D=ye("div","fc-rich-table-grid");n.append(M,D);for(let k=1;k<=6;k++)for(let z=1;z<=6;z++){const _=ye("button");_.type="button",_.ariaLabel=`${k}行${z}列表格`,_.dataset.row=String(k),_.dataset.col=String(z),_.onmousedown=Q=>Q.preventDefault(),_.onmouseenter=()=>{M.textContent=`${k} × ${z}`,D.querySelectorAll("button").forEach(Q=>Q.classList.toggle("active",Number(Q.dataset.row)<=k&&Number(Q.dataset.col)<=z))},_.onclick=()=>{const Q=ye("table"),ne=ye("tbody");for(let F=0;F<k;F++){const q=ye("tr");for(let Z=0;Z<z;Z++){const ie=ye("td");ie.append(ye("br")),q.append(ie)}ne.append(q)}Q.append(ne),R(Q);const U=document.createRange();U.selectNodeContents(Q.querySelector("td")),U.collapse(!0),o=U,f()},D.append(_)}}));const j=()=>A("链接",()=>{const M=ye("input","fc-input");M.ariaLabel="链接文本",M.placeholder="输入文本",M.value=(o==null?void 0:o.toString())||"";const D=ye("input","fc-input");D.ariaLabel="链接地址",D.placeholder="粘贴或输入超链接";const k=ye("div","fc-error"),z=ye("button","primary","确定");z.type="button",z.onclick=()=>{const _=D.value.trim();if(!gn(_)){k.textContent="请输入 http、https 或 mailto 链接";return}const Q=ye("a","",M.value||_);Q.href=_,Q.target="_blank",Q.rel="noopener noreferrer",R(Q)},n.append(ye("span","","文本"),M,ye("span","","链接"),D,k,z),M.focus()});S("链接","link",j),S("代码块","{ }",()=>E("formatBlock","pre")),S("表情","☺",()=>A("表情",()=>{n.classList.add("fc-rich-emojis");for(const M of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])B(M,()=>R(document.createTextNode(M)))}));const W=S("全屏编辑","expand",()=>{u(),a=!a,e.classList.toggle("is-fullscreen",a),g(),W.ariaLabel=W.title=a?"收起全屏":"全屏编辑",W.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${Ci[a?"collapse":"expand"]}</svg>`,f()},!1);return W.disabled=!1,W.classList.add("fc-rich-expand"),i.addEventListener("input",h),i.addEventListener("mouseup",()=>{if(u(),C(),d&&o&&!o.collapsed){const M=o,D=ye(d.tag);D.style.cssText=d.css,D.append(M.extractContents()),M.insertNode(D),d=null,p.get("格式刷").classList.remove("active"),m()}}),i.addEventListener("keyup",()=>{u(),C()}),i.addEventListener("click",M=>{const D=M.target;D.tagName==="A"&&M.preventDefault(),D instanceof HTMLInputElement&&D.type==="checkbox"&&(D.toggleAttribute("checked",D.checked),m()),g()}),i.addEventListener("drop",M=>M.preventDefault()),i.addEventListener("paste",M=>{var k,z;M.preventDefault(),u();const D=(k=M.clipboardData)==null?void 0:k.getData("text/html");if(D){const _=document.createElement("template");_.innerHTML=Ft(D);const Q=_.content,ne=document.createTextNode("");Q.append(ne),f();const U=window.getSelection().getRangeAt(0);U.deleteContents(),U.insertNode(Q),U.setStartAfter(ne),U.collapse(!0),o=U.cloneRange(),m()}else R(document.createTextNode(((z=M.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",M=>{M.key==="Escape"&&!n.hidden?(M.preventDefault(),M.stopPropagation(),g(),f()):M.key==="Escape"&&a?(M.preventDefault(),M.stopPropagation(),W.click()):(M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="z"?(M.preventDefault(),y(M.shiftKey?1:-1)):(M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="k"&&(M.preventDefault(),u(),j())}),e.append(t,i,n),C(),{element:e,read:()=>Ft(i.innerHTML),validate:()=>{var M;return s.field.required&&!((M=i.textContent)!=null&&M.trim())?"请填写内容":void 0},focus:()=>i.focus()}}const xe=(s,e,t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Pt=s=>String(s).padStart(2,"0"),wi=s=>`${s.getFullYear()}-${Pt(s.getMonth()+1)}-${Pt(s.getDate())}`;function Yt(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())&&wi(t)===s}const fn=s=>{var e,t;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}};function ia(s){const{time:e,range:t}=fn(s),n=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(o=>e?String(o).slice(0,16).replace("T"," "):String(o).slice(0,10)).join(" 至 ");return xe("div",`fc-value fc-${s.surface}${n?"":" fc-empty"}`,n||"待填")}function na(s){const{time:e,range:t}=fn(s),i=xe("div","fc-calendar"),n=Array.isArray(s.value)?s.value:[s.value],o=[0,1].map(U=>String(n[U]||"").slice(0,10)),a=[0,1].map(U=>String(n[U]||"").slice(11,16)||"00:00");let r=0,l=!1,c=Yt(o[0])?new Date(`${o[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const d=xe("div","fc-calendar-inputs"),u=[],f=()=>i.dispatchEvent(new Event("change",{bubbles:!0})),g=xe("div","fc-error");g.setAttribute("role","status");const p=()=>{if(o.some(U=>U&&!Yt(U)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!o[0])return"请选择日期";if(t&&!!o[0]!=!!o[1])return"请选择完整的日期范围";if(e&&a.slice(0,t?2:1).some(U=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(U)))return"请输入有效时间";if(t&&o[0]&&`${o[0]}T${e?a[0]:""}`>`${o[1]}T${e?a[1]:""}`)return"结束日期时间不能早于开始日期时间"},C=()=>{g.textContent=p()||"",g.textContent||f()};for(let U=0;U<(t?2:1);U++){const F=xe("input","fc-input fc-calendar-date");F.type="text",F.value=o[U],F.placeholder=t?U?"结束日期":"开始日期":"YYYY-MM-DD",F.ariaLabel=t?F.placeholder:s.field.label,F.disabled=s.readonly,F.onfocus=()=>{if(r=U,l=U===1,Yt(o[U])){const q=new Date(`${o[U]}T12:00:00`);c=new Date(q.getFullYear(),q.getMonth(),1)}Q()},F.addEventListener("change",q=>{if(q.stopPropagation(),o[U]=F.value.trim(),Yt(o[U])){const Z=new Date(`${o[U]}T12:00:00`);c=new Date(Z.getFullYear(),Z.getMonth(),1)}Q(),C()}),d.append(F),u.push(F)}const h=xe("div","fc-calendar-header"),m=xe("button","fc-calendar-month");m.type="button",m.ariaLabel="选择年份和月份",m.setAttribute("aria-expanded","false"),m.setAttribute("aria-live","polite");const y=(U,F,q)=>{const Z=xe("button","fc-calendar-nav");return Z.type="button",Z.ariaLabel=U,Z.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${q?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,F>0&&Z.classList.add("next"),Z.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+F,1),Q()},Z};h.append(y("上一年",-12,!0),y("上个月",-1,!1),m,y("下个月",1,!1),y("下一年",12,!0));const E=xe("div","fc-calendar-weekdays");for(const U of["日","一","二","三","四","五","六"])E.append(xe("span","",U));const R=xe("div","fc-calendar-days");R.setAttribute("role","group"),R.ariaLabel="选择日期";const S=xe("div","fc-calendar-period");S.hidden=!0;const A=xe("button","fc-calendar-back","‹ 返回选择日期");A.type="button";const B=xe("div","fc-calendar-period-columns"),L=xe("div","fc-calendar-period-list");L.setAttribute("role","group"),L.ariaLabel="年份";const j=xe("div","fc-calendar-period-list");j.setAttribute("role","group"),j.ariaLabel="月份",B.append(L,j),S.append(A,B);let W="period",M=0;const D=[],k=(U=!1)=>{const F=a[M].split(":").map(Number),q=W==="period"?[[L,c.getFullYear(),"年"],[j,c.getMonth()+1,"月"]]:[[L,F[0],"时"],[j,F[1],"分"]];for(const[Z,ie,be]of q)for(const fe of Z.querySelectorAll("button")){const ue=Number(fe.dataset.value)===ie;fe.classList.toggle("selected",ue),fe.setAttribute("aria-pressed",String(ue)),fe.textContent=`${W==="time"?Pt(Number(fe.dataset.value)):fe.dataset.value}${ue?be:""}`,ue&&U&&(Z.scrollTop=Math.max(0,fe.offsetTop-108))}},z=(U,F)=>{const q=xe("button","fc-calendar-period-option",String(U));return q.type="button",q.dataset.value=String(U),q.ariaLabel=`${W==="time"?Pt(U):U}${W==="time"?F?"时":"分":F?"年":"月"}`,q.disabled=W==="time"&&s.readonly,q.onclick=()=>{if(W==="time"){const Z=a[M].split(":");Z[F?0:1]=Pt(U),a[M]=Z.join(":"),D[M].textContent=a[M],k(),C();return}c.setFullYear(F?U:c.getFullYear(),F?c.getMonth():U-1,1),k(),Q()},q},_=(U,F=0)=>{if(W=U,M=F,L.replaceChildren(),j.replaceChildren(),L.ariaLabel=U==="period"?"年份":"小时",j.ariaLabel=U==="period"?"月份":"分钟",U==="period"){for(let q=Math.max(1,c.getFullYear()-100);q<=Math.min(9999,c.getFullYear()+100);q++)L.append(z(q,!0));for(let q=1;q<=12;q++)j.append(z(q,!1))}else{for(let q=0;q<24;q++)L.append(z(q,!0));for(let q=0;q<60;q++)j.append(z(q,!1))}i.classList.add("choosing-period"),S.hidden=!1,(U==="period"?m:D[F]).setAttribute("aria-expanded","true"),k(!0),A.focus()};m.onclick=()=>_("period"),A.onclick=()=>{i.classList.remove("choosing-period"),S.hidden=!0;const U=W==="period"?m:D[M];U.setAttribute("aria-expanded","false"),Q(),U.focus()},S.addEventListener("keydown",U=>{if(U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),A.click()),!["ArrowUp","ArrowDown","Home","End"].includes(U.key))return;const F=U.target,q=F.closest(".fc-calendar-period-list");if(!q)return;const Z=[...q.querySelectorAll("button")],ie=Z.indexOf(F),be=U.key==="Home"?0:U.key==="End"?Z.length-1:Math.max(0,Math.min(Z.length-1,ie+(U.key==="ArrowDown"?1:-1)));U.preventDefault(),Z[be].focus()});function Q(){m.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((F,q)=>F.classList.toggle("active",q===r)),R.replaceChildren();for(let F=0;F<c.getDay();F++)R.append(xe("span","fc-calendar-blank"));const U=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let F=1;F<=U;F++){const q=wi(new Date(c.getFullYear(),c.getMonth(),F)),Z=xe("button","fc-calendar-day",String(F));Z.type="button",Z.ariaLabel=q,Z.disabled=s.readonly;const ie=o[0]===q||t&&o[1]===q;Z.classList.toggle("selected",ie),Z.setAttribute("aria-pressed",String(ie)),Z.classList.toggle("in-range",t&&!!o[0]&&!!o[1]&&q>o[0]&&q<o[1]),q===wi(new Date)&&(Z.classList.add("today"),Z.setAttribute("aria-current","date")),Z.onclick=()=>{var be;t?l?(o[1]=q,o[0]&&o[1]<o[0]&&([o[0],o[1]]=[o[1],o[0]]),r=0,l=!1):(o[0]=q,o[1]="",r=1,l=!0):o[0]=q,u.forEach((fe,ue)=>fe.value=o[ue]),Q(),!t||o[1]?C():g.textContent="",(be=R.querySelector(`[aria-label="${q}"]`))==null||be.focus()},R.append(Z)}}if(i.append(d,h,E,R,S),e){const U=xe("div","fc-calendar-time");for(let F=0;F<(t?2:1);F++){const q=xe("div","fc-calendar-time-field"),Z=t?F?"结束时间":"开始时间":"时间",ie=xe("button","fc-input fc-calendar-time-trigger",a[F]);ie.type="button",ie.disabled=s.readonly,ie.ariaLabel=Z,ie.setAttribute("aria-expanded","false"),ie.onclick=()=>_("time",F),D.push(ie),q.append(xe("span","",Z),ie),U.append(q)}i.append(U)}const ne=xe("button","fc-calendar-clear","清空");return ne.type="button",ne.disabled=s.readonly,ne.onclick=()=>{o.fill(""),u.forEach(U=>U.value=""),r=0,l=!1,Q(),C()},i.append(ne,g),Q(),{element:i,read:()=>{const U=o.slice(0,t?2:1).map((F,q)=>F?F+(e?`T${a[q]}`:""):"");return t?U.some(Boolean)?U:[]:U[0]},validate:p,focus:()=>u[0].focus()}}const Me=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Qt=s=>s==null?"":String(s);function yi(s){var t;const e=Me("div",`fc-value fc-${s.surface}`);return s.field.kind==="richText"||s.field.kind==="longText"?e.innerHTML=Ft(s.value):e.textContent=Qt(s.value).replace("T",s.field.kind==="dateTime"?" ":"T"),(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function bi(s,e){const t=Me("input","fc-input");return t.type=s,t.value=Qt(e.value),t.disabled=e.readonly,t.required=!!e.field.required,t.ariaLabel=e.field.label,t.placeholder=`请输入${e.field.label}`,s==="number"&&(t.step="any"),{element:t,read:()=>s==="number"?t.value===""?null:Number(t.value):t.value,validate:()=>t.checkValidity()?void 0:t.validationMessage||"请填写有效值",focus:()=>t.focus()}}const mn=["#dcf0d5","#d9eeec","#fce2ef","#e9e7fa","#fbe8d5"];function Si(s,e){var t;return((t=s.colors)==null?void 0:t[e])||mn[Math.max(0,(s.options||[]).indexOf(e))%mn.length]}function vn(s,e){const t=Me("div","fc-choice"),i=s&&Number.isInteger(e.field.maxSelections)&&e.field.maxSelections>0?e.field.maxSelections:1/0,n=Me("div","fc-error fc-choice-feedback");n.setAttribute("role","status");const o=Me("select","fc-select");o.hidden=!0,o.multiple=s,o.disabled=e.readonly,o.required=!!e.field.required,o.ariaLabel=e.field.label;const a=s?Array.isArray(e.value)?e.value.map(String):e.value?[String(e.value)]:[]:[Qt(e.value)],r=[...new Set([...e.field.options||[],...a.filter(Boolean)])];if(!s){const h=Me("option","","");h.value="",o.append(h)}for(const h of r){const m=Me("option","",h);m.value=h,m.selected=a.includes(h),o.append(m)}const l=Me("div","fc-choice-head"),c=Me("div","fc-choice-selection"),d=Me("input","fc-choice-search");d.placeholder="搜索",d.ariaLabel=`搜索${e.field.label}选项`,d.disabled=e.readonly;const u=Me("div","fc-option-list");u.setAttribute("role","group"),u.ariaLabel=e.field.label;const f=Me("p","fc-empty fc-choice-empty","暂无匹配选项"),g=()=>{const h=d.value.trim().toLocaleLowerCase();let m=0;for(const y of u.querySelectorAll("button"))y.hidden=!y.dataset.value.toLocaleLowerCase().includes(h),y.hidden||m++;f.hidden=m>0},p=()=>{n.textContent="",c.replaceChildren();for(const h of[...o.selectedOptions].filter(m=>m.value)){const m=Me("span","fc-tag",h.text);m.style.backgroundColor=Si(e.field,h.value);const y=Me("button","fc-choice-remove","×");y.type="button",y.ariaLabel=`移除${h.text}`,y.disabled=e.readonly,y.onclick=E=>{E.stopPropagation(),h.selected=!1,p(),o.dispatchEvent(new Event("change",{bubbles:!0}))},m.append(y),c.append(m)}for(const h of u.querySelectorAll("button")){const m=[...o.selectedOptions].some(y=>y.value===h.dataset.value);h.classList.toggle("selected",m),h.setAttribute("aria-pressed",String(m)),h.querySelector(".fc-option-mark").textContent=m?"✓":""}};for(const h of[...o.options].filter(m=>m.value)){const m=Me("button","fc-option");m.type="button",m.disabled=e.readonly,m.dataset.value=h.value;const y=Me("span","fc-option-mark");y.setAttribute("aria-hidden","true");const E=Me("span","fc-option-label fc-tag",h.text);E.style.backgroundColor=Si(e.field,h.value),m.append(E,y),m.onclick=R=>{if(R.stopPropagation(),s&&!h.selected&&o.selectedOptions.length>=i){n.textContent=`最多可选择 ${i} 项,无法继续选择`;return}s?h.selected=!h.selected:o.value=h.value,p(),o.dispatchEvent(new Event("change",{bubbles:!0}))},u.append(m)}const C=h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;const m=[...u.querySelectorAll("button:not(:disabled):not([hidden])")];if(!m.length)return;h.preventDefault();const y=m.indexOf(document.activeElement),E=h.key==="Home"?0:h.key==="End"?m.length-1:(y+(h.key==="ArrowDown"?1:-1)+m.length)%m.length;m[E].focus()};return u.addEventListener("keydown",C),d.addEventListener("keydown",h=>{h.key==="ArrowDown"&&C(h)}),d.addEventListener("input",g),o.addEventListener("change",p),l.append(c,d),u.append(f),t.append(o,l,u,n),p(),g(),{element:t,read:()=>s?[...o.selectedOptions].map(h=>h.value):o.value,validate:()=>o.selectedOptions.length>i?`最多可选择 ${i} 项`:e.field.required&&![...o.selectedOptions].some(h=>h.value)?"请选择一个选项":void 0,focus:()=>d.focus()}}function Cn(s){const e=Me("div","fc-tags"),t=Array.isArray(s.value)?s.value:[s.value];for(const i of t.filter(n=>n!==""&&n!=null)){const n=Me("span","fc-tag",String(i));n.style.backgroundColor=Si(s.field,String(i)),e.append(n)}return e.children.length||e.append(Me("span","fc-empty","待填")),e}function wn(s=[]){const e=new Map,t=o=>{if(!/^[A-Za-z][\w-]*$/.test(o.id))throw new Error("Invalid control id");if(e.has(o.id))throw new Error(`Control already registered: ${o.id}`);e.set(o.id,o)};[{id:"text",label:"单行文本",glyph:"T",description:"单行输入,支持清空和必填校验",render:yi,createEditor:o=>bi("text",o)},{id:"richText",label:"富文本",glyph:"¶",description:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",render:yi,createEditor:ta},{id:"select",label:"单选",glyph:"◉",action:"select",description:"从字段配置中选择一个选项",render:Cn,createEditor:o=>vn(!1,o)},{id:"multiSelect",label:"多选",glyph:"☑",action:"select",description:"点击标签选择多项,保存为数组",render:Cn,createEditor:o=>vn(!0,o)},{id:"number",label:"数字",glyph:"#",description:"支持小数和负数,空值与零分别保存",render:yi,createEditor:o=>bi("number",o)},{id:"dateTime",label:"日期时间",glyph:"◷",description:"精简日历,可配置时间和日期范围",render:ia,createEditor:na},{id:"detail",label:"详情页查看",glyph:"↗",action:"view",description:"点击进入当前或关联工作项详情",render:o=>{const a=Me("button","fc-detail-link","查看详情 ↗");return a.type="button",a.onclick=r=>{r.stopPropagation(),o.openDetail(Qt(o.value)||o.item.id)},a},createEditor:o=>bi("text",{...o,field:{...o.field,label:"关联工作项 ID(留空查看当前项)"}})}].forEach(t),s.forEach(t);const n={title:"text",longText:"richText",status:"select",person:"select",relation:"text",vote:"text",date:"dateTime"};return{register:t,list:()=>[...e.values()],resolve:o=>{const a=o.control||n[o.kind||"text"]||o.kind||"text",r=e.get(a);if(!r)throw new Error(`Unknown control: ${a}`);return r}}}const oa=[["name","选题概要"],["description","选题描述"],["vote","选题投票"],["showVotes","是否展示投票结果"],["status","状态"],["selectedTopic","确定入选"],["format","内容形式"],["approved","选题是否通过"],["category","主题分类"],["owner","当前负责人"],["space","所属空间"],["created","创建时间"],["creator","创建者"]],sa={status:["入库","进入选题会","选题通过","废弃","已终止"],category:["产品相关","干货洞察","解决方案","客户案例"],format:["图文","视频","图文+视频"],approved:["是","待定","废弃"],showVotes:["是","否"],owner:["体验官"],creator:["体验官"],space:["内容制作全流程"]},yn=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1}),aa="rowvia:work-items:v2",la=["上班族月入过万副业案例集","城市咖啡地图探店","咖啡师教你在家做出咖啡厅品质","咖啡因含量实测排行榜","咖啡器具入门避坑指南","智能设备不联网真相:离线后还能用吗?","扫地机器人避坑指南:3000元vs5000元差在哪?","智能门锁必看!这5个功能千万别花冤枉钱","智能音箱大对比:某爱/某猫精灵/某度真实使用30天"],ra=["","特色独立咖啡馆推荐","器具和技巧分享","提神效果科学对比","新手该买什么设备","实测各类设备断网后的功能保留情况,避免被云端绑架","实测清扫能力、避障算法、噪音控制,告诉你钱该花在哪","揭秘过度营销的功能(如虹膜识别、人脸识别等),哪些真正实用",""],ca=["7105330334","7105330319","7105330315","7105330312","7105330311","7105330309","7105330300","7105330281","7105330263"],Jt=la.map((s,e)=>({id:ca[e],name:s,description:ra[e],vote:"",showVotes:"",status:e===0||e===4?"废弃":e===8?"进入选题会":"入库",selectedTopic:e===3?"10款平价咖…":e===8?"智能家居避…":"",format:e===0?"图文":e===8?"":"图文+视频",approved:e===0||e===4?"废弃":e===3?"是":"",category:e===0?"干货洞察":e===8?"":"产品相关",owner:"体验官",space:"内容制作全流程",created:"2026-09-03",creator:"体验官",source:e===0?"真实收入拆解":"",followed:!1,starred:!1,viewed:!1,comments:[],history:[]}));function bn(s,e){return e.every(t=>{const i=String(s[t.field]??"").toLocaleLowerCase(),n=t.value.toLocaleLowerCase();switch(t.operator){case"equals":return i===n;case"notEqual":return i!==n;case"blank":return!i;case"notBlank":return!!i;default:return i.includes(n)}})}function Sn(s=aa,e=Jt){try{const t=JSON.parse(localStorage.getItem(s)||"null");if(t&&Array.isArray(t.items)&&t.items.every(i=>i&&typeof i.id=="string"&&typeof i.name=="string"))return{items:t.items,views:Array.isArray(t.views)?t.views:[],drafts:t.drafts||[],customFields:Array.isArray(t.customFields)?t.customFields:[]}}catch{}return{items:structuredClone(e),views:[],drafts:[],customFields:[]}}const xn={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"/>',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">${xn[s]||xn.check}</svg>`,ae=s=>String(s??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),se=(s,e,t="",i="")=>`<button type="button" data-action="${s}" class="${i}" aria-label="${ae(e)}">${t?Re(t):""}${e?`<span>${ae(e)}</span>`:""}</button>`;function da(s){s={...s,fields:s.fields.map(w=>({...w}))},s.container.classList.add("rowvia-work-items");const e=wn(s.controls);let t=[],i=null,n=null,o=null;const a=new Set(s.fields.map(w=>w.key));if(a.size!==s.fields.length)throw new Error("Field keys must be unique");if(!a.has("name"))throw new Error("A name field is required for the work-item title");for(const w of[s.createForm,s.detailForm])for(const b of w.fields)if(!a.has(b.field))throw new Error(`Unknown form field: ${b.field}`);const r=new AbortController;let l=!1;const c=Sn(s.storageKey,s.items).customFields;for(const w of c)s.fields.some(b=>b.key===w.key)||s.fields.push(w);const d=s.fields.map(w=>[w.key,w.label]),u=w=>s.fields.find(b=>b.key===w),f=Object.fromEntries(s.fields.filter(w=>w.options).map(w=>[w.key,w.options])),g=s.storageKey,p=(w,b=s.container)=>b.querySelector(`:scope ${w}`),C=Sn(g,s.items);for(const w of C.items)w.comments??(w.comments=[]),w.history??(w.history=[]),w.roles??(w.roles=[]),w.meetings??(w.meetings=[]);let h=yn(),m="全部",y="",E=!1,R=0,S=null,A=null,B=null,L=null,j=null,W="基本信息",M=0,D=0,k="",z=[];s.container.innerHTML=`<section class="content">
109
- <div class="work-page"><section class="list-area"><div class="list-tabs" role="tablist">${["全部","最近浏览","我创建的","我参与的","我关注的","我收藏的"].map((w,b)=>`<button class="list-tab ${b===0?"active":""}" role="tab" aria-selected="${b===0}" data-tab="${w}">${w}</button>`).join("")}<div class="create-button">${se("create","新建","plus","primary")}${se("create-menu","","down","primary")}</div></div>
110
- <div class="toolbar">${se("filter","筛选","filter")}${se("sort","排序","sort")}${se("group","分组","group")}${se("color","设置颜色","color")}<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${se("previous-match","","up")}${se("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${se("close-search","","close")}</div>${se("search","查找","search")}<div class="right">${se("reset","重置","","hidden")}${se("controls","控件管理","edit")}${se("saved-views","切换视图","down")}${se("save-view","存为视图","save","outline")}</div></div><div class="selection-bar hidden"></div><div class="grid-wrap"><div id="grid"></div></div></section></div></section>`;function _(w,b){var I,O;if(!w)return'<span class="placeholder">暂无</span>';let x=b==="status"?w==="废弃"||w==="选题通过"?"green":w==="进入选题会"?"cyan":"":b==="category"?w==="干货洞察"?"teal":"green":b==="format"&&w==="图文"?"purple":"pink";const T=(O=(I=u(b))==null?void 0:I.colors)==null?void 0:O[w];return`<span class="tag ${x}" ${T?`style="background:${ae(T)}"`:""}>${ae(w)}</span>`}const Q=w=>w?`<span class="person"><span class="avatar">体验官</span>${ae(w)}</span>`:'<span class="placeholder">暂无</span>';function ne(w){if(w.node.group)return"";const b=w.data,x=w.colDef.field,T=document.createElement("div");T.className="rendered-cell";const I=u(x);if(I&&(I.control||!["title","vote","status","person","relation"].includes(I.kind||"text")))T.append(e.resolve(I).render(ze(I,b,"cell")));else if((I==null?void 0:I.kind)==="title"){const O=document.createElement("a");O.className="item-name",O.href=`#item/${b.id}`,O.textContent=b[x],O.title=b[x],O.addEventListener("click",H=>{H.preventDefault(),clearTimeout(D),H.detail===0?Le(b):H.detail===1&&(D=window.setTimeout(()=>Le(b),280))}),T.append(O);const $=document.createElement("button");$.className="inline-edit",$.innerHTML=Re("pencil"),$.ariaLabel="编辑选题概要",$.onclick=H=>{H.stopPropagation(),Ue(T,x,b,w.rowIndex)},(I==null?void 0:I.editable)!==!1&&T.append($)}else(I==null?void 0:I.kind)==="vote"?(T.innerHTML=`<button class="vote ${b.vote?"voted":""}" aria-label="${b.vote?"取消投票":"投票"}">${Re("plus")}${b.vote?"1":"投票"}</button>`,p("button",T).onclick=O=>{O.stopPropagation(),be(b,"vote",b.vote?"":"体验官")}):(I==null?void 0:I.kind)==="person"?(T.innerHTML=Q(b[x]),I.editable!==!1&&(T.onclick=()=>Ue(T,x,b,w.rowIndex))):(I==null?void 0:I.kind)==="status"?(T.innerHTML=`${_(b.status,x)}<span class="status-days">20 天</span>`,(I==null?void 0:I.editable)!==!1&&(T.onclick=O=>{O.stopPropagation(),Ue(T,x,b,w.rowIndex)})):(I==null?void 0:I.kind)==="relation"?(T.innerHTML=b[x]?`<button class="relation-tag ${b.id==="7105330263"?"pink":""}" title="${ae(b[x])}">${ae(b[x])}</button>`:'<span class="placeholder">暂无</span>',(I==null?void 0:I.editable)!==!1&&(T.onclick=()=>Ue(T,x,b,w.rowIndex))):(I==null?void 0:I.kind)==="multiSelect"?T.innerHTML=(Array.isArray(b[x])?b[x]:[]).map(O=>_(O,x)).join("")||'<span class="placeholder">暂无</span>':f[x]?(T.innerHTML=["creator","owner","space"].includes(x)?ae(b[x]):_(b[x],x),(I==null?void 0:I.editable)!==!1&&(T.onclick=O=>{O.stopPropagation(),Ue(T,x,b,w.rowIndex)})):(T.innerHTML=`<span class="cell-text">${ae(b[x]||"暂无")}</span>`,b[x]||T.classList.add("placeholder"));if(I&&I.editable!==!1&&I.kind!=="vote"&&I.kind!=="title"){const O=document.createElement("button");O.className="inline-edit field-control",O.ariaLabel=`${I.kind==="status"?"流转":"编辑"}${I.label}`,O.innerHTML=Re(I.kind==="status"?"transition":["select","multiSelect","person"].includes(I.kind||"")?"down":"pencil"),O.onclick=$=>{$.stopPropagation(),Ue(T,x,b,w.rowIndex)},T.append(O)}return T.title=String(b[x]??""),T}function U(){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:w=>{if(w.node.group)return"";const b=document.createElement("div");return b.className="row-controls",b.innerHTML=`<span class="row-number">${w.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${w.rowIndex+1} 行" ${w.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${Re("expand")}</button>`,p("input",b).onclick=x=>x.stopPropagation(),p("input",b).onchange=x=>w.node.setSelected(x.target.checked),p("button",b).onclick=x=>{x.stopPropagation(),Le(w.data)},b}},...s.fields.map(w=>({field:w.key,headerName:w.label,width:w.width??120,minWidth:w.minWidth??80,pinned:w.pinned,hide:w.hidden,enableRowGroup:!0,editable:!1,valueSetter:b=>w.required&&!String(b.newValue??"").trim()?!1:(b.data[w.key]=b.newValue,!0),comparator:w.options?(b,x)=>w.options.indexOf(b)-w.options.indexOf(x):void 0,sortable:!1,suppressMenu:!0,cellRenderer:ne,cellStyle:({data:b})=>{const x=b&&h.colors.find(T=>!!T.scope&&T.scope!=="row"&&T.field===w.key&&Ce(b,T));return x?{backgroundColor:x.color}:{}},tooltipField:w.key,cellClass:w.kind==="title"?"name-cell":void 0,...w.column})),...z,{colId:"_add",suppressMovable:!0,headerName:"+",width:60,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}const F=xi(p("#grid"),{columnDefs:U(),rowData:C.items,getRowId:({data:w})=>w.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,getRowStyle:({data:w})=>{const b=h.colors.find(x=>w&&(!x.scope||x.scope==="row")&&Ce(w,x));return b?{backgroundColor:b.color}:{}},onCellValueChanged:w=>{w.data.history.push(`更新${w.colDef.headerName}:${w.newValue}`),q(),queueMicrotask(()=>{l||ie()})},onSelectionChanged:()=>{oe(),F.api.refreshCells({force:!0})},onRowGroupOpened:()=>J(),localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"}});F.grid.getEventService().addEventListener("rowDragEnd",w=>{if(!w.overNode||w.overNode.group||w.node.id===w.overNode.id)return;const b=C.items.findIndex(I=>I.id===w.node.id),x=C.items.findIndex(I=>I.id===w.overNode.id);if(b<0||x<0)return;const[T]=C.items.splice(b,1);C.items.splice(x,0,T),h.sorts=[],q(),ie()}),F.grid.getEventService().addEventListener("columnHeaderClicked",w=>{w.column.colId==="_add"&&xt(p('.ag-header-cell[data-colid="_add"]'),"_add",!1)});function q(){var w;(w=s.onDataChange)==null||w.call(s,structuredClone(C.items));try{localStorage.setItem(g,JSON.stringify(C))}catch{fe("浏览器存储不可用,本次修改仅在当前页面保留")}}function Z(){return C.items.filter(w=>(h.showTerminated||w.status!=="已终止")&&bn(w,h.filters)&&(m!=="最近浏览"||w.viewed)&&(m!=="我关注的"||w.followed)&&(m!=="我收藏的"||w.starred)&&(m!=="我参与的"||w.owner===s.currentUser)&&(m!=="我创建的"||w.creator===s.currentUser)&&(!E||!y||w.name.toLowerCase().includes(y.toLowerCase())))}function ie(){o==null||o(),F.api.setRowData(Z()),F.api.setSortModel(h.sorts),F.columnApi.setRowGroupColumns(h.groups),F.api.redrawRows(),at();for(const[w,b]of[["filter",h.filters.length],["sort",h.sorts.length],["group",h.groups.length],["color",h.colors.length]]){const x=p(`[data-action="${w}"]`);x.classList.toggle("is-set",!!b);const T={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};p("span",x).textContent=T[w]+(b?` · ${b}`:"")}p('[data-action="reset"]').classList.toggle("hidden",!h.filters.length&&!h.sorts.length&&!h.groups.length&&!h.colors.length),oe(),Y(),J()}function be(w,b,x){var T;w[b]=x,w.history.push(`更新${((T=d.find(([I])=>I===b))==null?void 0:T[1])||b}:${String(x)}`),q(),ie()}function fe(w){var x;(x=p(".toast"))==null||x.remove(),clearTimeout(M);const b=document.createElement("div");b.className="toast",b.setAttribute("role","status"),b.innerHTML=Re("check")+ae(w),s.container.append(b),M=window.setTimeout(()=>b.remove(),2500)}function ue(w=!0){var b;w&&n&&!n()||(n=null,(b=i==null?void 0:i.destroy)==null||b.call(i),i=null,S==null||S.remove(),S=null,k="")}function Ne(w,b,x,T=460,I=""){ue(),S=document.createElement("section"),S.className=`popup ${I}`,S.setAttribute("role","dialog"),S.ariaLabel=b||"列操作",S.style.width=`${T}px`,S.innerHTML=`${b?`<div class="popup-head"><span>${ae(b)}</span>${se("close-popup","","close")}</div>`:""}${x}`,s.container.append(S);const O=w.getBoundingClientRect();return S.style.left=`${Math.max(12,Math.min(O.left,innerWidth-T-16))}px`,S.style.top=`${Math.min(O.bottom+8,Math.max(12,innerHeight-S.offsetHeight-16))}px`,S}function dt(w,b,x=""){return`<select ${x}>${w.map(([T,I])=>`<option value="${ae(T)}" ${T===b?"selected":""}>${ae(I)}</option>`).join("")}</select>`}function Zt(w,b,x){const T=Ne(w,d.find(([O])=>O===b)[1],'<input class="value-search" placeholder="搜索" aria-label="搜索选项"><div class="value-options"></div>',240),I=(O="")=>{p(".value-options",T).innerHTML=[...f[b]||[]].filter($=>$.includes(O)).map($=>`<button class="menu-option" data-value="${ae($)}">${_($,b)}<span class="spacer"></span>${(Array.isArray(x[b])?x[b].includes($):x[b]===$)?"✓":""}</button>`).join("")+'<button class="menu-option" data-value="">清空</button>'};I(),p("input",T).oninput=O=>I(O.target.value),T.onclick=O=>{var H;const $=O.target.closest("[data-value]");if($)if(O.stopPropagation(),((H=u(b))==null?void 0:H.kind)==="multiSelect"){const N=$.dataset.value,P=Array.isArray(x[b])?x[b]:[];be(x,b,N?P.includes(N)?P.filter(G=>G!==N):[...P,N]:[]),I(p("input",T).value)}else be(x,b,$.dataset.value),ue()}}function ut(w,b){const x=document.createElement("div");x.className="field-picker",x.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(O=>`<button data-kind="${O}">${O}</button>`).join("")}</div><div class="field-options"></div>`,s.container.append(x);const T=w.getBoundingClientRect();x.style.left=`${Math.min(T.left,innerWidth-410)}px`,x.style.top=`${Math.min(T.bottom+4,innerHeight-340)}px`;const I=(O="推荐",$="")=>{p(".field-options",x).innerHTML=d.filter(([H,N])=>{var P,G,V,ee,le,te;return N.includes($)&&(O==="推荐"||O==="文本"&&["title","text","longText"].includes(((P=u(H))==null?void 0:P.kind)||"text")||O==="选择"&&["status","select"].includes(((G=u(H))==null?void 0:G.kind)||"")||O==="人员"&&((V=u(H))==null?void 0:V.kind)==="person"||O==="时间"&&((ee=u(H))==null?void 0:ee.kind)==="date"||O==="关系"&&((le=u(H))==null?void 0:le.kind)==="relation"||O==="其他"&&((te=u(H))==null?void 0:te.kind)==="vote")}).map(([H,N])=>`<button data-field="${ae(H)}" class="menu-option">${Re("table")}${ae(N)}</button>`).join("")};I(),p("input",x).oninput=O=>I("推荐",O.target.value),x.onclick=O=>{const $=O.target.closest("button");$!=null&&$.dataset.kind&&I($.dataset.kind),$!=null&&$.dataset.field&&(x.remove(),b($.dataset.field))}}function Ce(w,b){return!!b.field&&(!!b.value||["blank","notBlank"].includes(b.operator))&&bn(w,[b])}function K(w){const b=h.colors.map((P,G)=>{var he;const V=(he=u(P.field))==null?void 0:he.label,ee=P.field?[["contains",f[P.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],le=!P.field||["blank","notBlank"].includes(P.operator),te=f[P.field]?dt([["","请选择目标值"],...f[P.field].map(ve=>[ve,ve])],P.value,`data-rule-value="${G}" aria-label="目标值" ${le?"disabled":""}`):`<input data-rule-value="${G}" aria-label="目标值" placeholder="请选择目标值" value="${ae(P.value)}" ${le?"disabled":""}>`;return`<div class="color-condition" data-color-row="${G}">
108
+ </div>`,e),{host:i,createGrid:n}=t,o=hi(2024),a=["Ireland","Spain","France","Germany","Italy","Portugal","Netherlands"],r=["Engineering","Design","Product","Sales","Support","Finance"],l=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia"],c=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes"],d=Array.from({length:5e4},(h,p)=>({id:p,name:`${l[p%l.length]} ${c[p*7%c.length]}`,country:a[p%a.length],department:r[p*3%r.length],salary:4e4+Math.floor(o()*8e4),rating:Math.floor(o()*6),started:`${2015+p%10}-0${1+p%9}-1${p%9}`})),u=120;function f(h){var S,P;let p=d.slice();const m=Object.entries(h.filterModel||{});if(m.length&&(p=p.filter(B=>m.every(([A,j])=>{const W=B[A],T=String(W).toLowerCase(),F=String(j.filter??"").toLowerCase();if(!F)return!0;switch(j.type){case"notEqual":return T!==F;case"startsWith":return T.startsWith(F);case"endsWith":return T.endsWith(F);default:return T.includes(F)}}))),(S=h.sortModel)!=null&&S.length){const{colId:B,sort:A}=h.sortModel[0];p=p.slice().sort((j,W)=>{const T=j[B]===W[B]?0:j[B]<W[B]?-1:1;return A==="asc"?T:-T})}const y=h.groupKeys||[],E=(P=h.rowGroupCols)==null?void 0:P[y.length];if(E){const B=p.filter(T=>y.every((F,N)=>{const z=h.rowGroupCols[N];return String(T[z.field])===F})),A=new Map,j=[];for(const T of B){const F=String(T[E.field]);A.has(F)||(A.set(F,{count:0,salary:[]}),j.push(F));const N=A.get(F);N.count++,N.salary.push(T.salary)}const W=j.map(T=>{const F=A.get(T),N={id:`group-${y.join("/")}-${E.field}-${T}`,__isGroup:!0,childCount:F.count};return N[E.field]=T,N.salary=Math.round(F.salary.reduce((z,_)=>z+_,0)/F.salary.length),N});return{rows:W,lastRow:W.length}}return{rows:p.slice(h.startRow,h.endRow),lastRow:p.length}}const g=[{field:"name",headerName:"Name",width:220,enableRowGroup:!0,filter:"text"},{field:"country",headerName:"Country",width:160,enableRowGroup:!0,filter:"text"},{field:"department",headerName:"Department",width:180,enableRowGroup:!0,filter:"text"},{field:"salary",headerName:"Avg Salary",width:160,aggFunc:"avg",type:"numberColumn",filter:"number"},{field:"rating",headerName:"Rating",width:120,type:"numberColumn",filter:"number"},{field:"started",headerName:"Started",width:140,filter:"text"}],{api:w}=n(i.querySelector("#serverSideGrid"),{columnDefs:g,rowData:[],rowModelType:"serverSide",serverSideDatasource:{getRows:h=>{t.timeout(()=>{const{rows:p,lastRow:m}=f(h);h.successCallback(p,m)},u)}},rowGroupPanelShow:"always",groupDefaultExpanded:-1,rowHeight:42,sideBar:{toolPanels:["columns","filters"],position:"right"},statusBar:{statusPanels:[{statusPanel:"agTotalRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},enableRangeSelection:!0,theme:"ag-theme-quartz"});return i.querySelector("#refresh").addEventListener("click",()=>{w.refreshServerSide({purge:!0})}),i.querySelector("#purge").addEventListener("click",()=>{w.purgeServerSideCache()}),t.handle}const ye=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Zs=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),gn=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function Ft(s){const e=document.createElement("template");e.innerHTML=String(s??"");const t=i=>{for(const n of[...i.childNodes]){if(n.nodeType!==1)continue;const o=n;if(["SCRIPT","STYLE","IFRAME","OBJECT","SVG","MATH"].includes(o.tagName)){o.remove();continue}if(t(o),!Zs.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",r=o.hasAttribute("checked"),l=o.getAttribute("data-task")==="true",c=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(u=>[u,o.style.getPropertyValue(u)]),d=o.tagName==="FONT"?o.getAttribute("color"):null;for(const u of[...o.attributes])o.removeAttribute(u.name);for(const[u,f]of c)(u==="color"||u==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(f):u==="text-align"?/^(left|center|right|justify)$/.test(f):u==="margin-left"?/^\d{1,3}px$/.test(f):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(f))&&o.style.setProperty(u,f);d&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(d)&&(o.style.color=d),o.tagName==="A"&&gn(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),r&&o.setAttribute("checked","")),l&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const Ci={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 ea(s){const e=ye("div",`fc-rich${s.surface==="cell"?" fc-rich-compact":""}`),t=ye("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const i=ye("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=Ft(s.value);const n=ye("div","fc-rich-menu");n.hidden=!0;let o=null,a=!1,r=[i.innerHTML],l=0,c=!1,d=null;const u=()=>{const T=window.getSelection();T!=null&&T.rangeCount&&i.contains(T.anchorNode)&&i.contains(T.focusNode)&&(o=T.getRangeAt(0).cloneRange())},f=()=>{i.focus();const T=window.getSelection();if(!T)return;const F=o&&i.contains(o.commonAncestorContainer)?o:document.createRange();F!==o&&(F.selectNodeContents(i),F.collapse(!1)),T.removeAllRanges(),T.addRange(F),o=F},g=()=>{n.hidden=!0,n.replaceChildren()},w=new Map,h=()=>{var T;w.get("撤销").disabled=s.readonly||l===0,w.get("重做").disabled=s.readonly||l===r.length-1;for(const[F,N]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=w.get(F);if(!z)continue;const _=!!((T=document.queryCommandState)!=null&&T.call(document,N));z.classList.toggle("active",_),z.setAttribute("aria-pressed",String(_))}},p=()=>{c||(i.innerHTML!==r[l]&&(r=r.slice(0,l+1),r.push(i.innerHTML),r.length>100&&r.shift(),l=r.length-1),u(),h())},m=()=>{p(),i.dispatchEvent(new Event("change",{bubbles:!0}))},y=T=>{const F=l+T;F<0||F>=r.length||(l=F,c=!0,i.innerHTML=r[l],o=null,f(),c=!1,h(),i.dispatchEvent(new Event("change",{bubbles:!0})))},E=(T,F)=>{s.readonly||(f(),document.execCommand(T,!1,F),u(),g(),m())},R=T=>{if(s.readonly)return;f();const F=window.getSelection().getRangeAt(0);F.deleteContents(),F.insertNode(T),F.setStartAfter(T),F.collapse(!0),o=F.cloneRange(),g(),m()},S=(T,F,N,z=!0)=>{const _=ye("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return _.type="button",_.ariaLabel=T,_.title=T,_.disabled=s.readonly,Ci[F]?_.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Ci[F]}</svg>`:_.textContent=F,_.onmousedown=Q=>{Q.preventDefault(),u()},_.onclick=Q=>{Q.stopPropagation(),N()},t.append(_),w.set(T,_),_},P=(T,F)=>{if(u(),!n.hidden&&n.ariaLabel===T){g();return}n.replaceChildren(),n.className="fc-rich-menu",n.ariaLabel=T,F(),n.hidden=!1;const N=w.get(T);n.style.left=`${Math.max(4,Math.min(N.offsetLeft,e.clientWidth-280))}px`},B=(T,F)=>{const N=ye("button","fc-rich-menu-option",T);return N.type="button",N.onmousedown=z=>z.preventDefault(),N.onclick=z=>{z.stopPropagation(),F()},n.append(N),N};S("撤销","undo",()=>y(-1),!1),S("重做","redo",()=>y(1),!1),S("格式刷","paint",()=>{u();const T=o==null?void 0:o.startContainer,F=(T==null?void 0:T.nodeType)===1?T:T==null?void 0:T.parentElement;!F||!i.contains(F)||(d={tag:/^(B|STRONG|I|EM|U|S)$/.test(F.tagName)?F.tagName.toLowerCase():"span",css:F.getAttribute("style")||""},w.get("格式刷").classList.add("active"))}),S("正文样式","Aa⌄",()=>P("正文样式",()=>{for(const[T,F]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])B(T,()=>E("formatBlock",F))}));const A=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[T,F,N]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])S(T,F,()=>P(T,()=>{n.classList.add("fc-rich-colors");for(const z of A){const _=B(z,()=>E(N,z));_.textContent="",_.style.backgroundColor=z,_.ariaLabel=`${T} ${z}`}B("清除",()=>E(N,N==="foreColor"?"#1f2329":"transparent"))}));for(const[T,F,N]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])S(T,F,()=>E(N));S("对齐","☰⌄",()=>P("对齐",()=>{for(const[T,F]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])B(T,()=>E(F))})),S("有序列表","1≡",()=>E("insertOrderedList")),S("无序列表","•≡",()=>E("insertUnorderedList")),S("任务列表","task",()=>{f();const T=window.getSelection().getRangeAt(0),F=ye("ul"),N=ye("li");N.dataset.task="true";const z=ye("input");z.type="checkbox",z.contentEditable="false",N.append(z,T.extractContents()),N.textContent||N.append(document.createTextNode("待办事项")),F.append(N),R(F)}),S("引用","quote",()=>E("formatBlock","blockquote")),S("缩进","indent",()=>P("缩进",()=>{B("增加缩进",()=>E("indent")),B("减少缩进",()=>E("outdent"))})),S("分隔线","line",()=>R(ye("hr"))),S("表格","table",()=>P("表格",()=>{const T=ye("p","","选择行列"),F=ye("div","fc-rich-table-grid");n.append(T,F);for(let N=1;N<=6;N++)for(let z=1;z<=6;z++){const _=ye("button");_.type="button",_.ariaLabel=`${N}行${z}列表格`,_.dataset.row=String(N),_.dataset.col=String(z),_.onmousedown=Q=>Q.preventDefault(),_.onmouseenter=()=>{T.textContent=`${N} × ${z}`,F.querySelectorAll("button").forEach(Q=>Q.classList.toggle("active",Number(Q.dataset.row)<=N&&Number(Q.dataset.col)<=z))},_.onclick=()=>{const Q=ye("table"),ie=ye("tbody");for(let $=0;$<N;$++){const q=ye("tr");for(let Z=0;Z<z;Z++){const te=ye("td");te.append(ye("br")),q.append(te)}ie.append(q)}Q.append(ie),R(Q);const U=document.createRange();U.selectNodeContents(Q.querySelector("td")),U.collapse(!0),o=U,f()},F.append(_)}}));const j=()=>P("链接",()=>{const T=ye("input","fc-input");T.ariaLabel="链接文本",T.placeholder="输入文本",T.value=(o==null?void 0:o.toString())||"";const F=ye("input","fc-input");F.ariaLabel="链接地址",F.placeholder="粘贴或输入超链接";const N=ye("div","fc-error"),z=ye("button","primary","确定");z.type="button",z.onclick=()=>{const _=F.value.trim();if(!gn(_)){N.textContent="请输入 http、https 或 mailto 链接";return}const Q=ye("a","",T.value||_);Q.href=_,Q.target="_blank",Q.rel="noopener noreferrer",R(Q)},n.append(ye("span","","文本"),T,ye("span","","链接"),F,N,z),T.focus()});S("链接","link",j),S("代码块","{ }",()=>E("formatBlock","pre")),S("表情","☺",()=>P("表情",()=>{n.classList.add("fc-rich-emojis");for(const T of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])B(T,()=>R(document.createTextNode(T)))}));const W=S("全屏编辑","expand",()=>{u(),a=!a,e.classList.toggle("is-fullscreen",a),g(),W.ariaLabel=W.title=a?"收起全屏":"全屏编辑",W.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${Ci[a?"collapse":"expand"]}</svg>`,f()},!1);return W.disabled=!1,W.classList.add("fc-rich-expand"),i.addEventListener("input",p),i.addEventListener("mouseup",()=>{if(u(),h(),d&&o&&!o.collapsed){const T=o,F=ye(d.tag);F.style.cssText=d.css,F.append(T.extractContents()),T.insertNode(F),d=null,w.get("格式刷").classList.remove("active"),m()}}),i.addEventListener("keyup",()=>{u(),h()}),i.addEventListener("click",T=>{const F=T.target;F.tagName==="A"&&T.preventDefault(),F instanceof HTMLInputElement&&F.type==="checkbox"&&(F.toggleAttribute("checked",F.checked),m()),g()}),i.addEventListener("drop",T=>T.preventDefault()),i.addEventListener("paste",T=>{var N,z;T.preventDefault(),u();const F=(N=T.clipboardData)==null?void 0:N.getData("text/html");if(F){const _=document.createElement("template");_.innerHTML=Ft(F);const Q=_.content,ie=document.createTextNode("");Q.append(ie),f();const U=window.getSelection().getRangeAt(0);U.deleteContents(),U.insertNode(Q),U.setStartAfter(ie),U.collapse(!0),o=U.cloneRange(),m()}else R(document.createTextNode(((z=T.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",T=>{T.key==="Escape"&&!n.hidden?(T.preventDefault(),T.stopPropagation(),g(),f()):T.key==="Escape"&&a?(T.preventDefault(),T.stopPropagation(),W.click()):(T.metaKey||T.ctrlKey)&&T.key.toLowerCase()==="z"?(T.preventDefault(),y(T.shiftKey?1:-1)):(T.metaKey||T.ctrlKey)&&T.key.toLowerCase()==="k"&&(T.preventDefault(),u(),j())}),e.append(t,i,n),h(),{element:e,read:()=>Ft(i.innerHTML),validate:()=>{var T;return s.field.required&&!((T=i.textContent)!=null&&T.trim())?"请填写内容":void 0},focus:()=>i.focus()}}const Se=(s,e,t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Pt=s=>String(s).padStart(2,"0"),wi=s=>`${s.getFullYear()}-${Pt(s.getMonth()+1)}-${Pt(s.getDate())}`;function Yt(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())&&wi(t)===s}const fn=s=>{var e,t;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}};function ta(s){const{time:e,range:t}=fn(s),n=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(o=>e?String(o).slice(0,16).replace("T"," "):String(o).slice(0,10)).join(" 至 ");return Se("div",`fc-value fc-${s.surface}${n?"":" fc-empty"}`,n||"待填")}function ia(s){const{time:e,range:t}=fn(s),i=Se("div","fc-calendar"),n=Array.isArray(s.value)?s.value:[s.value],o=[0,1].map(U=>String(n[U]||"").slice(0,10)),a=[0,1].map(U=>String(n[U]||"").slice(11,16)||"00:00");let r=0,l=!1,c=Yt(o[0])?new Date(`${o[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const d=Se("div","fc-calendar-inputs"),u=[],f=()=>i.dispatchEvent(new Event("change",{bubbles:!0})),g=Se("div","fc-error");g.setAttribute("role","status");const w=()=>{if(o.some(U=>U&&!Yt(U)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!o[0])return"请选择日期";if(t&&!!o[0]!=!!o[1])return"请选择完整的日期范围";if(e&&a.slice(0,t?2:1).some(U=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(U)))return"请输入有效时间";if(t&&o[0]&&`${o[0]}T${e?a[0]:""}`>`${o[1]}T${e?a[1]:""}`)return"结束日期时间不能早于开始日期时间"},h=()=>{g.textContent=w()||"",g.textContent||f()};for(let U=0;U<(t?2:1);U++){const $=Se("input","fc-input fc-calendar-date");$.type="text",$.value=o[U],$.placeholder=t?U?"结束日期":"开始日期":"YYYY-MM-DD",$.ariaLabel=t?$.placeholder:s.field.label,$.disabled=s.readonly,$.onfocus=()=>{if(r=U,l=U===1,Yt(o[U])){const q=new Date(`${o[U]}T12:00:00`);c=new Date(q.getFullYear(),q.getMonth(),1)}Q()},$.addEventListener("change",q=>{if(q.stopPropagation(),o[U]=$.value.trim(),Yt(o[U])){const Z=new Date(`${o[U]}T12:00:00`);c=new Date(Z.getFullYear(),Z.getMonth(),1)}Q(),h()}),d.append($),u.push($)}const p=Se("div","fc-calendar-header"),m=Se("button","fc-calendar-month");m.type="button",m.ariaLabel="选择年份和月份",m.setAttribute("aria-expanded","false"),m.setAttribute("aria-live","polite");const y=(U,$,q)=>{const Z=Se("button","fc-calendar-nav");return Z.type="button",Z.ariaLabel=U,Z.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${q?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,$>0&&Z.classList.add("next"),Z.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+$,1),Q()},Z};p.append(y("上一年",-12,!0),y("上个月",-1,!1),m,y("下个月",1,!1),y("下一年",12,!0));const E=Se("div","fc-calendar-weekdays");for(const U of["日","一","二","三","四","五","六"])E.append(Se("span","",U));const R=Se("div","fc-calendar-days");R.setAttribute("role","group"),R.ariaLabel="选择日期";const S=Se("div","fc-calendar-period");S.hidden=!0;const P=Se("button","fc-calendar-back","‹ 返回选择日期");P.type="button";const B=Se("div","fc-calendar-period-columns"),A=Se("div","fc-calendar-period-list");A.setAttribute("role","group"),A.ariaLabel="年份";const j=Se("div","fc-calendar-period-list");j.setAttribute("role","group"),j.ariaLabel="月份",B.append(A,j),S.append(P,B);let W="period",T=0;const F=[],N=(U=!1)=>{const $=a[T].split(":").map(Number),q=W==="period"?[[A,c.getFullYear(),"年"],[j,c.getMonth()+1,"月"]]:[[A,$[0],"时"],[j,$[1],"分"]];for(const[Z,te,be]of q)for(const me of Z.querySelectorAll("button")){const ce=Number(me.dataset.value)===te;me.classList.toggle("selected",ce),me.setAttribute("aria-pressed",String(ce)),me.textContent=`${W==="time"?Pt(Number(me.dataset.value)):me.dataset.value}${ce?be:""}`,ce&&U&&(Z.scrollTop=Math.max(0,me.offsetTop-108))}},z=(U,$)=>{const q=Se("button","fc-calendar-period-option",String(U));return q.type="button",q.dataset.value=String(U),q.ariaLabel=`${W==="time"?Pt(U):U}${W==="time"?$?"时":"分":$?"年":"月"}`,q.disabled=W==="time"&&s.readonly,q.onclick=()=>{if(W==="time"){const Z=a[T].split(":");Z[$?0:1]=Pt(U),a[T]=Z.join(":"),F[T].textContent=a[T],N(),h();return}c.setFullYear($?U:c.getFullYear(),$?c.getMonth():U-1,1),N(),Q()},q},_=(U,$=0)=>{if(W=U,T=$,A.replaceChildren(),j.replaceChildren(),A.ariaLabel=U==="period"?"年份":"小时",j.ariaLabel=U==="period"?"月份":"分钟",U==="period"){for(let q=Math.max(1,c.getFullYear()-100);q<=Math.min(9999,c.getFullYear()+100);q++)A.append(z(q,!0));for(let q=1;q<=12;q++)j.append(z(q,!1))}else{for(let q=0;q<24;q++)A.append(z(q,!0));for(let q=0;q<60;q++)j.append(z(q,!1))}i.classList.add("choosing-period"),S.hidden=!1,(U==="period"?m:F[$]).setAttribute("aria-expanded","true"),N(!0),P.focus()};m.onclick=()=>_("period"),P.onclick=()=>{i.classList.remove("choosing-period"),S.hidden=!0;const U=W==="period"?m:F[T];U.setAttribute("aria-expanded","false"),Q(),U.focus()},S.addEventListener("keydown",U=>{if(U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),P.click()),!["ArrowUp","ArrowDown","Home","End"].includes(U.key))return;const $=U.target,q=$.closest(".fc-calendar-period-list");if(!q)return;const Z=[...q.querySelectorAll("button")],te=Z.indexOf($),be=U.key==="Home"?0:U.key==="End"?Z.length-1:Math.max(0,Math.min(Z.length-1,te+(U.key==="ArrowDown"?1:-1)));U.preventDefault(),Z[be].focus()});function Q(){m.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach(($,q)=>$.classList.toggle("active",q===r)),R.replaceChildren();for(let $=0;$<c.getDay();$++)R.append(Se("span","fc-calendar-blank"));const U=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let $=1;$<=U;$++){const q=wi(new Date(c.getFullYear(),c.getMonth(),$)),Z=Se("button","fc-calendar-day",String($));Z.type="button",Z.ariaLabel=q,Z.disabled=s.readonly;const te=o[0]===q||t&&o[1]===q;Z.classList.toggle("selected",te),Z.setAttribute("aria-pressed",String(te)),Z.classList.toggle("in-range",t&&!!o[0]&&!!o[1]&&q>o[0]&&q<o[1]),q===wi(new Date)&&(Z.classList.add("today"),Z.setAttribute("aria-current","date")),Z.onclick=()=>{var be;t?l?(o[1]=q,o[0]&&o[1]<o[0]&&([o[0],o[1]]=[o[1],o[0]]),r=0,l=!1):(o[0]=q,o[1]="",r=1,l=!0):o[0]=q,u.forEach((me,ce)=>me.value=o[ce]),Q(),!t||o[1]?h():g.textContent="",(be=R.querySelector(`[aria-label="${q}"]`))==null||be.focus()},R.append(Z)}}if(i.append(d,p,E,R,S),e){const U=Se("div","fc-calendar-time");for(let $=0;$<(t?2:1);$++){const q=Se("div","fc-calendar-time-field"),Z=t?$?"结束时间":"开始时间":"时间",te=Se("button","fc-input fc-calendar-time-trigger",a[$]);te.type="button",te.disabled=s.readonly,te.ariaLabel=Z,te.setAttribute("aria-expanded","false"),te.onclick=()=>_("time",$),F.push(te),q.append(Se("span","",Z),te),U.append(q)}i.append(U)}const ie=Se("button","fc-calendar-clear","清空");return ie.type="button",ie.disabled=s.readonly,ie.onclick=()=>{o.fill(""),u.forEach(U=>U.value=""),r=0,l=!1,Q(),h()},i.append(ie,g),Q(),{element:i,read:()=>{const U=o.slice(0,t?2:1).map(($,q)=>$?$+(e?`T${a[q]}`:""):"");return t?U.some(Boolean)?U:[]:U[0]},validate:w,focus:()=>u[0].focus()}}const Me=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Qt=s=>s==null?"":String(s);function yi(s){var t;const e=Me("div",`fc-value fc-${s.surface}`);return s.field.kind==="richText"||s.field.kind==="longText"?e.innerHTML=Ft(s.value):e.textContent=Qt(s.value).replace("T",s.field.kind==="dateTime"?" ":"T"),(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function bi(s,e){const t=Me("input","fc-input");return t.type=s,t.value=Qt(e.value),t.disabled=e.readonly,t.required=!!e.field.required,t.ariaLabel=e.field.label,t.placeholder=`请输入${e.field.label}`,s==="number"&&(t.step="any"),{element:t,read:()=>s==="number"?t.value===""?null:Number(t.value):t.value,validate:()=>t.checkValidity()?void 0:t.validationMessage||"请填写有效值",focus:()=>t.focus()}}const mn=["#dcf0d5","#d9eeec","#fce2ef","#e9e7fa","#fbe8d5"];function Si(s,e){var t;return((t=s.colors)==null?void 0:t[e])||mn[Math.max(0,(s.options||[]).indexOf(e))%mn.length]}function vn(s,e){const t=Me("div","fc-choice"),i=s&&Number.isInteger(e.field.maxSelections)&&e.field.maxSelections>0?e.field.maxSelections:1/0,n=Me("div","fc-error fc-choice-feedback");n.setAttribute("role","status");const o=Me("select","fc-select");o.hidden=!0,o.multiple=s,o.disabled=e.readonly,o.required=!!e.field.required,o.ariaLabel=e.field.label;const a=s?Array.isArray(e.value)?e.value.map(String):e.value?[String(e.value)]:[]:[Qt(e.value)],r=[...new Set([...e.field.options||[],...a.filter(Boolean)])];if(!s){const p=Me("option","","");p.value="",o.append(p)}for(const p of r){const m=Me("option","",p);m.value=p,m.selected=a.includes(p),o.append(m)}const l=Me("div","fc-choice-head"),c=Me("div","fc-choice-selection"),d=Me("input","fc-choice-search");d.placeholder="搜索",d.ariaLabel=`搜索${e.field.label}选项`,d.disabled=e.readonly;const u=Me("div","fc-option-list");u.setAttribute("role","group"),u.ariaLabel=e.field.label;const f=Me("p","fc-empty fc-choice-empty","暂无匹配选项"),g=()=>{const p=d.value.trim().toLocaleLowerCase();let m=0;for(const y of u.querySelectorAll("button"))y.hidden=!y.dataset.value.toLocaleLowerCase().includes(p),y.hidden||m++;f.hidden=m>0},w=()=>{n.textContent="",c.replaceChildren();for(const p of[...o.selectedOptions].filter(m=>m.value)){const m=Me("span","fc-tag",p.text);m.style.backgroundColor=Si(e.field,p.value);const y=Me("button","fc-choice-remove","×");y.type="button",y.ariaLabel=`移除${p.text}`,y.disabled=e.readonly,y.onclick=E=>{E.stopPropagation(),p.selected=!1,w(),o.dispatchEvent(new Event("change",{bubbles:!0}))},m.append(y),c.append(m)}for(const p of u.querySelectorAll("button")){const m=[...o.selectedOptions].some(y=>y.value===p.dataset.value);p.classList.toggle("selected",m),p.setAttribute("aria-pressed",String(m)),p.querySelector(".fc-option-mark").textContent=m?"✓":""}};for(const p of[...o.options].filter(m=>m.value)){const m=Me("button","fc-option");m.type="button",m.disabled=e.readonly,m.dataset.value=p.value;const y=Me("span","fc-option-mark");y.setAttribute("aria-hidden","true");const E=Me("span","fc-option-label fc-tag",p.text);E.style.backgroundColor=Si(e.field,p.value),m.append(E,y),m.onclick=R=>{if(R.stopPropagation(),s&&!p.selected&&o.selectedOptions.length>=i){n.textContent=`最多可选择 ${i} 项,无法继续选择`;return}s?p.selected=!p.selected:o.value=p.value,w(),o.dispatchEvent(new Event("change",{bubbles:!0}))},u.append(m)}const h=p=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(p.key))return;const m=[...u.querySelectorAll("button:not(:disabled):not([hidden])")];if(!m.length)return;p.preventDefault();const y=m.indexOf(document.activeElement),E=p.key==="Home"?0:p.key==="End"?m.length-1:(y+(p.key==="ArrowDown"?1:-1)+m.length)%m.length;m[E].focus()};return u.addEventListener("keydown",h),d.addEventListener("keydown",p=>{p.key==="ArrowDown"&&h(p)}),d.addEventListener("input",g),o.addEventListener("change",w),l.append(c,d),u.append(f),t.append(o,l,u,n),w(),g(),{element:t,read:()=>s?[...o.selectedOptions].map(p=>p.value):o.value,validate:()=>o.selectedOptions.length>i?`最多可选择 ${i} 项`:e.field.required&&![...o.selectedOptions].some(p=>p.value)?"请选择一个选项":void 0,focus:()=>d.focus()}}function Cn(s){const e=Me("div","fc-tags"),t=Array.isArray(s.value)?s.value:[s.value];for(const i of t.filter(n=>n!==""&&n!=null)){const n=Me("span","fc-tag",String(i));n.style.backgroundColor=Si(s.field,String(i)),e.append(n)}return e.children.length||e.append(Me("span","fc-empty","待填")),e}function wn(s=[]){const e=new Map,t=o=>{if(!/^[A-Za-z][\w-]*$/.test(o.id))throw new Error("Invalid control id");if(e.has(o.id))throw new Error(`Control already registered: ${o.id}`);e.set(o.id,o)};[{id:"text",label:"单行文本",glyph:"T",description:"单行输入,支持清空和必填校验",render:yi,createEditor:o=>bi("text",o)},{id:"richText",label:"富文本",glyph:"¶",description:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",render:yi,createEditor:ea},{id:"select",label:"单选",glyph:"◉",action:"select",description:"从字段配置中选择一个选项",render:Cn,createEditor:o=>vn(!1,o)},{id:"multiSelect",label:"多选",glyph:"☑",action:"select",description:"点击标签选择多项,保存为数组",render:Cn,createEditor:o=>vn(!0,o)},{id:"number",label:"数字",glyph:"#",description:"支持小数和负数,空值与零分别保存",render:yi,createEditor:o=>bi("number",o)},{id:"dateTime",label:"日期时间",glyph:"◷",description:"精简日历,可配置时间和日期范围",render:ta,createEditor:ia},{id:"detail",label:"详情页查看",glyph:"↗",action:"view",description:"点击进入当前或关联工作项详情",render:o=>{const a=Me("button","fc-detail-link","查看详情 ↗");return a.type="button",a.onclick=r=>{r.stopPropagation(),o.openDetail(Qt(o.value)||o.item.id)},a},createEditor:o=>bi("text",{...o,field:{...o.field,label:"关联工作项 ID(留空查看当前项)"}})}].forEach(t),s.forEach(t);const n={title:"text",longText:"richText",status:"select",person:"select",relation:"text",vote:"text",date:"dateTime"};return{register:t,list:()=>[...e.values()],resolve:o=>{const a=o.control||n[o.kind||"text"]||o.kind||"text",r=e.get(a);if(!r)throw new Error(`Unknown control: ${a}`);return r}}}const na=[["name","选题概要"],["description","选题描述"],["vote","选题投票"],["showVotes","是否展示投票结果"],["status","状态"],["selectedTopic","确定入选"],["format","内容形式"],["approved","选题是否通过"],["category","主题分类"],["owner","当前负责人"],["space","所属空间"],["created","创建时间"],["creator","创建者"]],oa={status:["入库","进入选题会","选题通过","废弃","已终止"],category:["产品相关","干货洞察","解决方案","客户案例"],format:["图文","视频","图文+视频"],approved:["是","待定","废弃"],showVotes:["是","否"],owner:["体验官"],creator:["体验官"],space:["内容制作全流程"]},yn=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1}),sa="rowvia:work-items:v2",aa=["上班族月入过万副业案例集","城市咖啡地图探店","咖啡师教你在家做出咖啡厅品质","咖啡因含量实测排行榜","咖啡器具入门避坑指南","智能设备不联网真相:离线后还能用吗?","扫地机器人避坑指南:3000元vs5000元差在哪?","智能门锁必看!这5个功能千万别花冤枉钱","智能音箱大对比:某爱/某猫精灵/某度真实使用30天"],la=["","特色独立咖啡馆推荐","器具和技巧分享","提神效果科学对比","新手该买什么设备","实测各类设备断网后的功能保留情况,避免被云端绑架","实测清扫能力、避障算法、噪音控制,告诉你钱该花在哪","揭秘过度营销的功能(如虹膜识别、人脸识别等),哪些真正实用",""],ra=["7105330334","7105330319","7105330315","7105330312","7105330311","7105330309","7105330300","7105330281","7105330263"],Jt=aa.map((s,e)=>({id:ra[e],name:s,description:la[e],vote:"",showVotes:"",status:e===0||e===4?"废弃":e===8?"进入选题会":"入库",selectedTopic:e===3?"10款平价咖…":e===8?"智能家居避…":"",format:e===0?"图文":e===8?"":"图文+视频",approved:e===0||e===4?"废弃":e===3?"是":"",category:e===0?"干货洞察":e===8?"":"产品相关",owner:"体验官",space:"内容制作全流程",created:"2026-09-03",creator:"体验官",source:e===0?"真实收入拆解":"",followed:!1,starred:!1,viewed:!1,comments:[],history:[]}));function bn(s,e){return e.every(t=>{const i=String(s[t.field]??"").toLocaleLowerCase(),n=t.value.toLocaleLowerCase();switch(t.operator){case"equals":return i===n;case"notEqual":return i!==n;case"blank":return!i;case"notBlank":return!!i;default:return i.includes(n)}})}function ca(s=sa,e=Jt){try{const t=JSON.parse(localStorage.getItem(s)||"null");if(t&&Array.isArray(t.items)&&t.items.every(i=>i&&typeof i.id=="string"&&typeof i.name=="string"))return{items:t.items,views:Array.isArray(t.views)?t.views:[],drafts:t.drafts||[],customFields:Array.isArray(t.customFields)?t.customFields:[]}}catch{}return{items:structuredClone(e),views:[],drafts:[],customFields:[]}}const Sn={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"/>',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"/>'},xe=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Sn[s]||Sn.check}</svg>`,ae=s=>String(s??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),oe=(s,e,t="",i="")=>`<button type="button" data-action="${s}" class="${i}" aria-label="${ae(e)}">${t?xe(t):""}${e?`<span>${ae(e)}</span>`:""}</button>`;function da(s){s={...s,fields:s.fields.map(C=>({...C}))},s.container.classList.add("rowvia-work-items");const e=wn(s.controls);let t=[],i=null,n=null,o=null;const a=new Set(s.fields.map(C=>C.key));if(a.size!==s.fields.length)throw new Error("Field keys must be unique");if(!a.has("name"))throw new Error("A name field is required for the work-item title");for(const C of[s.createForm,s.detailForm])for(const b of C.fields)if(!a.has(b.field))throw new Error(`Unknown form field: ${b.field}`);const r=new AbortController;let l=!1;const c=s.persistence==="none"?{items:structuredClone(s.items),views:[],drafts:[],customFields:[]}:ca(s.storageKey,s.items),d=s.allowCustomFields===!1?[]:c.customFields;for(const C of d)s.fields.some(b=>b.key===C.key)||s.fields.push(C);const u=s.fields.map(C=>[C.key,C.label]),f=C=>s.fields.find(b=>b.key===C),g=Object.fromEntries(s.fields.filter(C=>C.options).map(C=>[C.key,C.options])),w=s.storageKey,h=(C,b=s.container)=>b.querySelector(`:scope ${C}`);for(const C of c.items)C.comments??(C.comments=[]),C.history??(C.history=[]),C.roles??(C.roles=[]),C.meetings??(C.meetings=[]);let p=s.initialView?structuredClone(s.initialView):yn(),m="全部",y="",E=!1,R=0,S=null,P=null,B=null,A=null,j=null,W="基本信息",T=0,F=0,N="",z=[];s.container.innerHTML=`<section class="content">
109
+ <div class="work-page"><section class="list-area"><div class="list-tabs" role="tablist">${["全部","最近浏览","我创建的","我参与的","我关注的","我收藏的"].map((C,b)=>`<button class="list-tab ${b===0?"active":""}" role="tab" aria-selected="${b===0}" data-tab="${C}">${C}</button>`).join("")}<div class="create-button">${oe("create","新建","plus","primary")}${oe("create-menu","","down","primary")}</div></div>
110
+ <div class="toolbar">${oe("filter","筛选","filter")}${oe("sort","排序","sort")}${oe("group","分组","group")}${oe("color","设置颜色","color")}<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${oe("previous-match","","up")}${oe("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${oe("close-search","","close")}</div>${oe("search","查找","search")}<div class="right">${oe("reset","重置","","hidden")}${oe("controls","控件管理","edit")}${oe("saved-views","切换视图","down")}${oe("save-view","存为视图","save","outline")}</div></div><div class="selection-bar hidden"></div><div class="grid-wrap"><div id="grid"></div></div></section></div></section>`;function _(C,b){var L,O;if(!C)return'<span class="placeholder">暂无</span>';let x=b==="status"?C==="废弃"||C==="选题通过"?"green":C==="进入选题会"?"cyan":"":b==="category"?C==="干货洞察"?"teal":"green":b==="format"&&C==="图文"?"purple":"pink";const M=(O=(L=f(b))==null?void 0:L.colors)==null?void 0:O[C];return`<span class="tag ${x}" ${M?`style="background:${ae(M)}"`:""}>${ae(C)}</span>`}const Q=C=>C?`<span class="person"><span class="avatar">体验官</span>${ae(C)}</span>`:'<span class="placeholder">暂无</span>';function ie(C){if(C.node.group)return"";const b=C.data,x=C.colDef.field,M=document.createElement("div");M.className="rendered-cell";const L=f(x);if(L&&(L.control||!["title","vote","status","person","relation"].includes(L.kind||"text")))M.append(e.resolve(L).render(ze(L,b,"cell")));else if((L==null?void 0:L.kind)==="title"){const O=document.createElement("a");O.className="item-name",O.href=`#item/${b.id}`,O.textContent=b[x],O.title=b[x],O.addEventListener("click",D=>{D.preventDefault(),clearTimeout(F),D.detail===0?Ie(b):D.detail===1&&(F=window.setTimeout(()=>Ie(b),280))}),M.append(O);const H=document.createElement("button");H.className="inline-edit",H.innerHTML=xe("pencil"),H.ariaLabel="编辑选题概要",H.onclick=D=>{D.stopPropagation(),Ue(M,x,b,C.rowIndex)},(L==null?void 0:L.editable)!==!1&&M.append(H)}else(L==null?void 0:L.kind)==="vote"?(M.innerHTML=`<button class="vote ${b.vote?"voted":""}" aria-label="${b.vote?"取消投票":"投票"}">${xe("plus")}${b.vote?"1":"投票"}</button>`,h("button",M).onclick=O=>{O.stopPropagation(),be(b,"vote",b.vote?"":"体验官")}):(L==null?void 0:L.kind)==="person"?(M.innerHTML=Q(b[x]),L.editable!==!1&&(M.onclick=()=>Ue(M,x,b,C.rowIndex))):(L==null?void 0:L.kind)==="status"?(M.innerHTML=`${_(b.status,x)}<span class="status-days">20 天</span>`,(L==null?void 0:L.editable)!==!1&&(M.onclick=O=>{O.stopPropagation(),Ue(M,x,b,C.rowIndex)})):(L==null?void 0:L.kind)==="relation"?(M.innerHTML=b[x]?`<button class="relation-tag ${b.id==="7105330263"?"pink":""}" title="${ae(b[x])}">${ae(b[x])}</button>`:'<span class="placeholder">暂无</span>',(L==null?void 0:L.editable)!==!1&&(M.onclick=()=>Ue(M,x,b,C.rowIndex))):(L==null?void 0:L.kind)==="multiSelect"?M.innerHTML=(Array.isArray(b[x])?b[x]:[]).map(O=>_(O,x)).join("")||'<span class="placeholder">暂无</span>':g[x]?(M.innerHTML=["creator","owner","space"].includes(x)?ae(b[x]):_(b[x],x),(L==null?void 0:L.editable)!==!1&&(M.onclick=O=>{O.stopPropagation(),Ue(M,x,b,C.rowIndex)})):(M.innerHTML=`<span class="cell-text">${ae(b[x]||"暂无")}</span>`,b[x]||M.classList.add("placeholder"));if(L&&L.editable!==!1&&L.kind!=="vote"&&L.kind!=="title"){const O=document.createElement("button");O.className="inline-edit field-control",O.ariaLabel=`${L.kind==="status"?"流转":"编辑"}${L.label}`,O.innerHTML=xe(L.kind==="status"?"transition":["select","multiSelect","person"].includes(L.kind||"")?"down":"pencil"),O.onclick=H=>{H.stopPropagation(),Ue(M,x,b,C.rowIndex)},M.append(O)}return M.title=String(b[x]??""),M}function U(){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:C=>{if(C.node.group)return"";const b=document.createElement("div");return b.className="row-controls",b.innerHTML=`<span class="row-number">${C.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${C.rowIndex+1} 行" ${C.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${xe("expand")}</button>`,h("input",b).onclick=x=>x.stopPropagation(),h("input",b).onchange=x=>C.node.setSelected(x.target.checked),h("button",b).onclick=x=>{x.stopPropagation(),Ie(C.data)},b}},...s.fields.map(C=>({field:C.key,headerName:C.label,width:C.width??120,minWidth:C.minWidth??80,pinned:C.pinned,hide:C.hidden,enableRowGroup:!0,editable:!1,valueSetter:b=>C.required&&!String(b.newValue??"").trim()?!1:(b.data[C.key]=b.newValue,!0),comparator:C.options?(b,x)=>C.options.indexOf(b)-C.options.indexOf(x):void 0,sortable:!1,suppressMenu:!0,cellRenderer:ie,cellStyle:({data:b})=>{const x=b&&p.colors.find(M=>!!M.scope&&M.scope!=="row"&&M.field===C.key&&Ce(b,M));return x?{backgroundColor:x.color}:{}},tooltipField:C.key,cellClass:C.kind==="title"?"name-cell":void 0,...C.column})),...z,{colId:"_add",hide:s.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}const $=xi(h("#grid"),{columnDefs:U(),rowData:c.items,getRowId:({data:C})=>C.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,getRowStyle:({data:C})=>{const b=p.colors.find(x=>C&&(!x.scope||x.scope==="row")&&Ce(C,x));return b?{backgroundColor:b.color}:{}},onCellValueChanged:C=>{C.data.history.push(`更新${C.colDef.headerName}:${C.newValue}`),q(),queueMicrotask(()=>{l||te()})},onSelectionChanged:()=>{ne(),$.api.refreshCells({force:!0})},onRowGroupOpened:()=>J(),localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"}});$.grid.getEventService().addEventListener("rowDragEnd",C=>{if(!C.overNode||C.overNode.group||C.node.id===C.overNode.id)return;const b=c.items.findIndex(L=>L.id===C.node.id),x=c.items.findIndex(L=>L.id===C.overNode.id);if(b<0||x<0)return;const[M]=c.items.splice(b,1);c.items.splice(x,0,M),p.sorts=[],q(),te()}),$.grid.getEventService().addEventListener("columnHeaderClicked",C=>{C.column.colId==="_add"&&gt(h('.ag-header-cell[data-colid="_add"]'),"_add",!1)});function q(){var C;if((C=s.onDataChange)==null||C.call(s,structuredClone(c.items)),s.persistence!=="none")try{localStorage.setItem(w,JSON.stringify(c))}catch{me("浏览器存储不可用,本次修改仅在当前页面保留")}}function Z(){return c.items.filter(C=>(p.showTerminated||C.status!=="已终止")&&bn(C,p.filters)&&(m!=="最近浏览"||C.viewed)&&(m!=="我关注的"||C.followed)&&(m!=="我收藏的"||C.starred)&&(m!=="我参与的"||C.owner===s.currentUser)&&(m!=="我创建的"||C.creator===s.currentUser)&&(!E||!y||C.name.toLowerCase().includes(y.toLowerCase())))}function te(){o==null||o(),$.api.setRowData(Z()),$.api.setSortModel(p.sorts),$.columnApi.setRowGroupColumns(p.groups),$.api.redrawRows(),rt();for(const[C,b]of[["filter",p.filters.length],["sort",p.sorts.length],["group",p.groups.length],["color",p.colors.length]]){const x=h(`[data-action="${C}"]`);x.classList.toggle("is-set",!!b);const M={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};h("span",x).textContent=M[C]+(b?` · ${b}`:"")}h('[data-action="reset"]').classList.toggle("hidden",!p.filters.length&&!p.sorts.length&&!p.groups.length&&!p.colors.length),ne(),Y(),J()}function be(C,b,x){var M;C[b]=x,C.history.push(`更新${((M=u.find(([L])=>L===b))==null?void 0:M[1])||b}:${String(x)}`),q(),te()}function me(C){var x;(x=h(".toast"))==null||x.remove(),clearTimeout(T);const b=document.createElement("div");b.className="toast",b.setAttribute("role","status"),b.innerHTML=xe("check")+ae(C),s.container.append(b),T=window.setTimeout(()=>b.remove(),2500)}function ce(C=!0){var b;C&&n&&!n()||(n=null,(b=i==null?void 0:i.destroy)==null||b.call(i),i=null,S==null||S.remove(),S=null,N="")}function Ne(C,b,x,M=460,L=""){ce(),S=document.createElement("section"),S.className=`popup ${L}`,S.setAttribute("role","dialog"),S.ariaLabel=b||"列操作",S.style.width=`${M}px`,S.innerHTML=`${b?`<div class="popup-head"><span>${ae(b)}</span>${oe("close-popup","","close")}</div>`:""}${x}`,s.container.append(S);const O=C.getBoundingClientRect();return S.style.left=`${Math.max(12,Math.min(O.left,innerWidth-M-16))}px`,S.style.top=`${Math.min(O.bottom+8,Math.max(12,innerHeight-S.offsetHeight-16))}px`,S}function ht(C,b,x=""){return`<select ${x}>${C.map(([M,L])=>`<option value="${ae(M)}" ${M===b?"selected":""}>${ae(L)}</option>`).join("")}</select>`}function Zt(C,b,x){const M=Ne(C,u.find(([O])=>O===b)[1],'<input class="value-search" placeholder="搜索" aria-label="搜索选项"><div class="value-options"></div>',240),L=(O="")=>{h(".value-options",M).innerHTML=[...g[b]||[]].filter(H=>H.includes(O)).map(H=>`<button class="menu-option" data-value="${ae(H)}">${_(H,b)}<span class="spacer"></span>${(Array.isArray(x[b])?x[b].includes(H):x[b]===H)?"✓":""}</button>`).join("")+'<button class="menu-option" data-value="">清空</button>'};L(),h("input",M).oninput=O=>L(O.target.value),M.onclick=O=>{var D;const H=O.target.closest("[data-value]");if(H)if(O.stopPropagation(),((D=f(b))==null?void 0:D.kind)==="multiSelect"){const k=H.dataset.value,I=Array.isArray(x[b])?x[b]:[];be(x,b,k?I.includes(k)?I.filter(G=>G!==k):[...I,k]:[]),L(h("input",M).value)}else be(x,b,H.dataset.value),ce()}}function ot(C,b,x={}){s.container.querySelectorAll(".field-picker").forEach(D=>D.remove());const M=document.createElement("div");M.className="field-picker",M.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(D=>`<button data-kind="${D}">${D}</button>`).join("")}</div><div class="field-options"></div>`,s.container.append(M);const L=C.getBoundingClientRect();M.style.left=`${Math.max(12,Math.min(L.left,innerWidth-410))}px`,M.style.top=`${Math.max(12,Math.min(L.bottom+4,innerHeight-340))}px`;let O="推荐";const H=(D="推荐",k="")=>{h(".field-options",M).innerHTML=u.filter(([I,G])=>{var V,ee,de,se,he,ge;return(!x.available||x.available(I))&&G.includes(k)&&(D==="推荐"||D==="文本"&&["title","text","longText","richText"].includes(((V=f(I))==null?void 0:V.kind)||"text")||D==="选择"&&["status","select","multiSelect"].includes(((ee=f(I))==null?void 0:ee.kind)||"")||D==="人员"&&((de=f(I))==null?void 0:de.kind)==="person"||D==="时间"&&["date","dateTime"].includes(((se=f(I))==null?void 0:se.kind)||"")||D==="关系"&&((he=f(I))==null?void 0:he.kind)==="relation"||D==="其他"&&((ge=f(I))==null?void 0:ge.kind)==="vote")}).map(([I,G])=>`<button data-field="${ae(I)}" ${x.onCreate?`data-insert="${ae(I)}"`:""} class="menu-option">${xe("table")}${ae(G)}</button>`).join(""),x.onCreate&&h(".field-options",M).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${xe("add")}添加字段</button>`),M.querySelectorAll("[data-kind]").forEach(I=>{I.classList.toggle("active",I.dataset.kind===D),I.setAttribute("aria-pressed",String(I.dataset.kind===D))})};H(),h("input",M).oninput=D=>H(O,D.target.value),M.onclick=D=>{var I;const k=D.target.closest("button");k&&(D.stopPropagation(),k.dataset.kind&&(O=k.dataset.kind,H(O,h("input",M).value)),k.dataset.field&&(M.remove(),b(k.dataset.field)),k.hasAttribute("data-create-field")&&(M.remove(),(I=x.onCreate)==null||I.call(x)))}}function Ce(C,b){return!!b.field&&(!!b.value||["blank","notBlank"].includes(b.operator))&&bn(C,[b])}function K(C){const b=p.colors.map((I,G)=>{var he;const V=(he=f(I.field))==null?void 0:he.label,ee=I.field?[["contains",g[I.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],de=!I.field||["blank","notBlank"].includes(I.operator),se=g[I.field]?ht([["","请选择目标值"],...g[I.field].map(ge=>[ge,ge])],I.value,`data-rule-value="${G}" aria-label="目标值" ${de?"disabled":""}`):`<input data-rule-value="${G}" aria-label="目标值" placeholder="请选择目标值" value="${ae(I.value)}" ${de?"disabled":""}>`;return`<div class="color-condition" data-color-row="${G}">
111
111
  <button class="color-drag" draggable="true" title="拖动调整条件优先级" aria-label="拖动条件">⠿</button>
112
- <button type="button" class="color-swatch" data-color="${G}" style="background-color:${ae(P.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
113
- <button type="button" class="field-select" data-color-scope="${G}" aria-label="着色范围" aria-expanded="false">${!P.scope||P.scope==="row"?"整行":"单元格"}${Re("down")}</button>
114
- <button class="field-select ${V?"":"empty"}" data-pick="${G}">${ae(V||"请选择筛选项")}${Re("down")}</button>
115
- ${dt(ee,P.field?P.operator:"",`data-operator="${G}" aria-label="运算符" ${P.field?"":"disabled"}`)}
116
- ${te}
117
- <button class="color-remove" data-remove="${G}" aria-label="删除条件" title="删除条件">${Re("close")}</button>
118
- <div class="color-more-wrap"><button class="color-more" data-color-more="${G}" aria-label="更多条件操作" aria-expanded="false">${Re("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${G}">复制条件</button><button data-color-up="${G}" ${G===0?"disabled":""}>上移</button><button data-color-down="${G}" ${G===h.colors.length-1?"disabled":""}>下移</button></div></div>
119
- </div>`}).join(""),x=Ne(w,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${b}</div><div class="color-panel-footer"><button class="add-condition">${Re("plus")}添加着色条件</button><button class="clear-rules" ${h.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");x.ariaLabel="设置颜色条件",k="color";const T=()=>K(w),I=()=>{ie(),T()},O=["#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"],$=()=>{var P;(P=x.querySelector(".color-palette"))==null||P.remove(),x.querySelectorAll("[data-color]").forEach(G=>G.setAttribute("aria-expanded","false"))},H=()=>{var P,G;(P=x.querySelector(".color-scope-picker"))==null||P.remove(),(G=i==null?void 0:i.destroy)==null||G.call(i),i=null,x.querySelectorAll("[data-color-scope]").forEach(V=>V.setAttribute("aria-expanded","false"))};let N=-1;x.querySelectorAll(".color-condition").forEach((P,G)=>{P.ondragstart=V=>{var ee;N=G,(ee=V.dataTransfer)==null||ee.setData("text/plain",String(G))},P.ondragover=V=>V.preventDefault(),P.ondrop=V=>{if(V.preventDefault(),N<0||N===G)return;const[ee]=h.colors.splice(N,1);h.colors.splice(G,0,ee),I()}}),x.onclick=P=>{var ee,le;P.stopPropagation();const G=P.target.closest("button");if(P.target.closest(".color-scope-picker"))return;const V=(G==null?void 0:G.getAttribute("aria-expanded"))==="true";if(H(),!G||G.disabled){$();return}if(G.dataset.colorScope!==void 0){if($(),V)return;const te=Number(G.dataset.colorScope),he=h.colors[te],ve={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},Ie=e.resolve(ve).createEditor({field:ve,value:!he.scope||he.scope==="row"?"整行":"单元格",item:We(),surface:"cell",readonly:!1,openDetail:()=>{}});i=Ie;const ge=document.createElement("div");ge.className="popup fc-popup fc-choice-popup color-scope-picker",ge.style.width="272px",ge.append(Ie.element),x.append(ge);const et=G.getBoundingClientRect();ge.style.left=`${Math.max(8,Math.min(et.left,innerWidth-280))}px`,ge.style.top=`${Math.max(8,Math.min(et.bottom+6,innerHeight-ge.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),Ie.element.addEventListener("change",Ye=>{var In,Ln;Ye.stopPropagation(),!((In=Ie.validate)!=null&&In.call(Ie))&&(he.scope=Ie.read()==="整行"?"row":"cell",I(),(Ln=S==null?void 0:S.querySelector(`[data-color-scope="${te}"]`))==null||Ln.focus())}),ge.onkeydown=Ye=>{Ye.key==="Escape"&&(Ye.stopPropagation(),H(),G.focus())},(ee=Ie.focus)==null||ee.call(Ie);return}if(G.dataset.paletteColor!==void 0){const te=Number(G.closest(".color-palette").dataset.ruleIndex);h.colors[te].color=G.dataset.paletteColor,I(),(le=S==null?void 0:S.querySelector(`[data-color="${te}"]`))==null||le.focus();return}if(G.dataset.color!==void 0){const te=G.getAttribute("aria-expanded")==="true";if($(),te)return;const he=Number(G.dataset.color),ve=document.createElement("div");ve.className="color-palette",ve.dataset.ruleIndex=String(he),ve.setAttribute("role","group"),ve.ariaLabel="选择着色颜色",ve.innerHTML=O.map(ge=>`<button type="button" class="color-palette-option" data-palette-color="${ge}" style="background-color:${ge}" aria-label="颜色 ${ge}" aria-pressed="${ge===h.colors[he].color.toLowerCase()}"></button>`).join(""),x.append(ve);const Ie=G.getBoundingClientRect();ve.style.left=`${Math.max(8,Math.min(Ie.left,innerWidth-ve.offsetWidth-8))}px`,ve.style.top=`${Math.max(8,Math.min(Ie.bottom+6,innerHeight-ve.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),ve.onkeydown=ge=>{ge.key==="Escape"&&(ge.stopPropagation(),$(),G.focus())};return}if($(),G.classList.contains("add-condition"))h.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),I();else if(G.dataset.pick!==void 0){const te=+G.dataset.pick;ut(G,he=>{h.colors[te].field=he,h.colors[te].value="",h.colors[te].operator="contains",I()})}else if(G.dataset.remove!==void 0)h.colors.splice(+G.dataset.remove,1),I();else if(G.classList.contains("clear-rules"))h.colors=[],I();else if(G.dataset.colorMore!==void 0){const te=G.nextElementSibling,he=te.classList.contains("hidden");x.querySelectorAll(".color-rule-menu").forEach(ve=>ve.classList.add("hidden")),x.querySelectorAll("[data-color-more]").forEach(ve=>ve.setAttribute("aria-expanded","false")),te.classList.toggle("hidden",!he),G.setAttribute("aria-expanded",String(he))}else if(G.dataset.colorCopy!==void 0){const te=+G.dataset.colorCopy;h.colors.splice(te+1,0,structuredClone(h.colors[te])),I()}else if(G.dataset.colorUp!==void 0||G.dataset.colorDown!==void 0){const te=Number(G.dataset.colorUp??G.dataset.colorDown),[he]=h.colors.splice(te,1);h.colors.splice(te+(G.dataset.colorUp!==void 0?-1:1),0,he),I()}},x.onchange=P=>{const G=P.target;if(G.dataset.operator!==void 0){h.colors[+G.dataset.operator].operator=G.value,I();return}G.dataset.ruleValue!==void 0&&(h.colors[+G.dataset.ruleValue].value=G.value),ie()},x.oninput=P=>{const G=P.target;if(G.dataset.ruleValue!==void 0)h.colors[+G.dataset.ruleValue].value=G.value;else return;ie()}}function X(w,b){if(w==="color"){K(b);return}const x={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[w],T=w==="filter"?h.filters:w==="sort"?h.sorts:w==="group"?h.groups:h.colors,I=T.map((N,P)=>{var he;const G=w==="sort"?N.colId:w==="group"?N:N.field,V=((he=d.find(([ve])=>ve===G))==null?void 0:he[1])||G,ee=`<button class="field-select" data-pick="${P}">${ae(V)}${Re("down")}</button>`;if(w==="sort")return`<div class="condition">${ee}<button class="sort-direction ${N.sort==="asc"?"selected":""}" data-dir="asc" data-index="${P}">首项 → 末项</button><button class="sort-direction ${N.sort==="desc"?"selected":""}" data-dir="desc" data-index="${P}">末项 → 首项</button><button data-remove="${P}" aria-label="删除条件">${Re("close")}</button></div>`;if(w==="group")return`<div class="condition">${ee}<span class="spacer"></span><button data-remove="${P}" aria-label="删除条件">${Re("close")}</button></div>`;const le=dt([["contains",f[G]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],N.operator,`data-operator="${P}" aria-label="运算符"`),te=["blank","notBlank"].includes(N.operator)?"":f[G]?dt([["","请选择目标值"],...f[G].map(ve=>[ve,ve])],N.value,`data-rule-value="${P}" aria-label="目标值"`):`<input data-rule-value="${P}" aria-label="目标值" value="${ae(N.value)}" placeholder="请选择目标值">`;return`<div class="condition">${ee}${le}${te}${w==="color"?`<input type="color" data-color="${P}" value="${N.color}" aria-label="行颜色">`:""}<button data-remove="${P}" aria-label="删除条件">${Re("close")}</button></div>`}).join(""),O=Ne(b,`设置${x}条件`,`${w==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${h.showTerminated?"checked":""}>显示已终止数据</label>`:""}${I}<button class="add-condition">${Re("plus")}添加${w==="color"?"着色":x}条件</button>${T.length?'<button class="clear-rules">清空全部条件</button>':""}`,w==="color"?650:560);k=w;const $=()=>X(w,b);let H=-1;O.querySelectorAll(".condition").forEach((N,P)=>{N.draggable=!0,N.ondragstart=G=>{var V;H=P,(V=G.dataTransfer)==null||V.setData("text/plain",String(P))},N.ondragover=G=>G.preventDefault(),N.ondrop=G=>{if(G.preventDefault(),H<0||H===P)return;const[V]=T.splice(H,1);T.splice(P,0,V),ie(),$()}}),O.onclick=N=>{const P=N.target.closest("button");P&&(P.classList.contains("add-condition")&&ut(P,G=>{w==="filter"&&h.filters.push({field:G,operator:"contains",value:""}),w==="sort"&&h.sorts.push({colId:G,sort:"asc"}),w==="group"&&!h.groups.includes(G)&&h.groups.push(G),w==="color"&&h.colors.push({field:G,operator:"contains",value:"",color:"#e9f2ff"}),ie(),$()}),P.dataset.pick!==void 0&&ut(P,G=>{const V=+P.dataset.pick;w==="sort"?h.sorts[V].colId=G:w==="group"?h.groups[V]=G:(T[V].field=G,T[V].value=""),ie(),$()}),P.dataset.remove!==void 0&&(T.splice(+P.dataset.remove,1),ie(),$()),P.classList.contains("clear-rules")&&(T.splice(0),ie(),$()),P.dataset.dir&&(h.sorts[+P.dataset.index].sort=P.dataset.dir,ie(),$()))},O.onchange=N=>{const P=N.target;P.id==="terminated"&&(h.showTerminated=P.checked),P.dataset.operator!==void 0&&(T[+P.dataset.operator].operator=P.value,$()),P.dataset.ruleValue!==void 0&&(T[+P.dataset.ruleValue].value=P.value),P.dataset.color!==void 0&&(h.colors[+P.dataset.color].color=P.value),ie()},O.oninput=N=>{const P=N.target;P.tagName==="INPUT"&&P.dataset.ruleValue!==void 0&&(T[+P.dataset.ruleValue].value=P.value,ie())}}function J(){const w=F.api.getDisplayedRowCount(),b=F.api.getAllColumns().filter(P=>P.visible).reduce((P,G)=>P+G.width,0),x=p(".grid-wrap"),T=p(".list-area"),I=getComputedStyle(T),O=Math.max(0,T.clientWidth-parseFloat(I.paddingLeft||"0")-parseFloat(I.paddingRight||"0")),$=Math.max(0,T.clientHeight-x.offsetTop-parseFloat(I.paddingBottom||"0")),H=p(".ag-header-wrapper",x).getBoundingClientRect().height||33,N=Math.max(1,w)*37+H+1;x.style.width=`${Math.min(O,b+2)}px`,x.style.height=`${Math.min($,N)}px`}function Y(){var b;const w=Z().filter(x=>y&&x.name.toLowerCase().includes(y.toLowerCase())).map(x=>x.id);if(R=Math.max(0,Math.min(R,w.length-1)),p("#matches").textContent=y?`${w.length?R+1:0}/${w.length}`:"",s.container.querySelectorAll(".item-name").forEach(x=>{const T=x.hash.replace("#item/","");x.classList.toggle("find-match",w.includes(T)),x.classList.toggle("find-current",w[R]===T)}),w[R]){let x=-1;for(let T=0;T<F.api.getDisplayedRowCount();T++)((b=F.api.getDisplayedRowAtIndex(T))==null?void 0:b.id)===w[R]&&(x=T);x>=0&&F.api.ensureIndexVisible(x)}p('[data-action="previous-match"]').toggleAttribute("disabled",!w.length),p('[data-action="next-match"]').toggleAttribute("disabled",!w.length)}function oe(){const w=F.api.getSelectedRows(),b=p(".selection-bar");b.classList.toggle("hidden",!w.length),b.innerHTML=`${se("deselect","","close")}<span>已选择 ${w.length} 项</span>${se("batch-status","更新状态")}${se("batch-owner","更新负责人")}${se("batch-export","导出")}${se("batch-archive","终止")}${se("deselect","取消选择")}`}function pe(w){const b=Ne(w,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${F.api.getAllColumns().filter(x=>!x.colId.startsWith("_")).map(x=>`<label class="column-option"><input type="checkbox" data-column="${x.colId}" ${x.visible?"checked":""}><span>${ae(x.headerName)}</span><button type="button" data-pin="${x.colId}">${x.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);b.onchange=x=>{const T=x.target;T.dataset.column&&F.columnApi.setColumnVisible(T.dataset.column,T.checked)},b.onclick=x=>{const T=x.target.closest("[data-pin]");if(T){x.preventDefault();const I=F.columnApi.getColumn(T.dataset.pin);F.columnApi.setColumnPinned(I,I.pinned?null:"left"),pe(w)}},p("input",b).oninput=x=>{const T=x.target.value;b.querySelectorAll(".column-option").forEach(I=>I.hidden=!I.textContent.includes(T))}}function Te(){t.forEach(w=>{var b;return(b=w.destroy)==null?void 0:b.call(w)}),t=[],A==null||A.remove(),A=null,L=null,j=null,B==null||B.focus(),s.syncLocationHash&&location.hash.startsWith("#item/")&&history.replaceState(null,"",location.pathname+location.search)}function ke(w,b="dialog-overlay"){return ue(),s.container.querySelectorAll(".field-picker").forEach(x=>x.remove()),t.forEach(x=>{var T;return(T=x.destroy)==null?void 0:T.call(x)}),t=[],A==null||A.remove(),B=document.activeElement,A=document.createElement("div"),A.className=`overlay ${b}`,A.innerHTML=w,A.setAttribute("role","dialog"),A.setAttribute("aria-modal","true"),s.container.append(A),A.addEventListener("click",x=>{x.target===A&&Te()}),A}function Be(w,b,x){const T=ke(`<form class="dialog"><h2>${ae(w)}</h2><input aria-label="${ae(w)}" value="${ae(b)}" required><div class="actions">${se("close-overlay","取消","","outline")}<button class="primary" type="submit">确定</button></div></form>`);p("form",T).onsubmit=I=>{I.preventDefault();const O=p("input",T).value.trim();O&&(Te(),x(O))},p("input",T).focus()}function Le(w,b="基本信息"){var O,$;w.viewed=!0,q(),L=w,W=b,s.syncLocationHash&&history.replaceState(null,"",`#item/${w.id}`);const x=s.detailForm.fields,T=b==="基本信息"?`<div class="detail-fields">${x.map(H=>{var N,P;return`<div class="detail-row"><label for="detail-${H.field}">${ae(H.label||((N=u(H.field))==null?void 0:N.label)||H.field)}${H.required??((P=u(H.field))==null?void 0:P.required)?" *":""}</label>${bt(H,w,"detail")}</div>`}).join("")}<div class="detail-row" data-block="roles"><label>角色与人员</label><div>提报人  ${Q(w.owner)}<p>${se("add-role","添加角色","","outline")}</p><div class="extra-roles"></div></div></div></div><section class="detail-section" data-block="meetings"><p>进入选题会</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${se("add-meeting","添加一组进入选题会","add")}</div><div class="detail-row" data-block="approval"><label>选题是否通过</label><div class="radios">${["是","待定","废弃"].map(H=>`<label><input type="radio" name="approved" value="${H}" data-detail="approved" ${w.approved===H?"checked":""}>${H}</label>`).join("")}</div></div></section><section class="detail-section" data-block="votes"><div class="detail-row"><label>选题投票</label><div>${se("detail-vote",w.vote?"1":"投票","plus","vote")}</div></div><div class="detail-row"><label>是否展示投票结果</label><div class="radios">${["是","否"].map(H=>`<label><input type="radio" name="showVotes" value="${H}" data-detail="showVotes" ${w.showVotes===H?"checked":""}>${H}</label>`).join("")}</div></div></section><div class="detail-row muted"><label>父级工作项</label><span>暂无关联WBS 父工作项</span></div>`:b==="评论/备注"?`<div class="comment-list">${w.comments.length?w.comments.map(H=>`<article>${Q("体验官")}<p>${ae(H)}</p></article>`).join(""):'<p class="muted">暂无评论/备注</p>'}</div>`:b==="操作记录"?`<div class="history-list">${w.history.length?w.history.map(H=>`<p>${ae(H)}</p>`).join(""):'<p class="muted">暂无操作记录</p>'}</div>`:`<div class="muted">${(O=w.materials)!=null&&O.length?w.materials.map(H=>`<p>${ae(H)}</p>`).join(""):"暂无关联素材"}</div>${se("link-material","关联素材","add","outline")}`,I=ke(`<article class="drawer"><div class="drawer-header"><span class="page-logo">${Re("check")}</span><strong>${ae(w.name)}</strong>${_(w.status,"approved")}<span class="muted">已进行 20 天</span><div class="spacer"></div>${se("follow",w.followed?"已关注":"关注","people",w.followed?"is-set":"")}${se("star",w.starred?"已收藏":"收藏","book",w.starred?"is-set":"")}${se("detail-more","","more")}${se("close-overlay","","close","outline")}</div><div class="detail-navigation">${se("prev-item","","up")}${se("next-item","","down")}</div><div class="detail-tabs">${["基本信息","素材管理","评论/备注","操作记录"].map(H=>`<button data-detail-tab="${H}" class="detail-tab ${H===b?"active":""}">${H}</button>`).join("")}<div class="spacer"></div>${Q(w.owner)}${se("detail-status",w.status,"down","primary")}</div><div class="drawer-body">${T}</div><form class="comment-form"><span class="avatar">体验官</span><textarea aria-label="评论" placeholder="请输入评论(Enter 换行,⌘ + Enter 发送)"></textarea><button type="submit">发送</button></form></article>`,"detail-overlay");L=w,j=w,ei(I,w,s.detailForm.fields,"detail"),me();for(const[H,N]of[["roles",s.detailForm.showRoles],["meetings",s.detailForm.showMeetings],["approval",s.detailForm.showApproval],["votes",s.detailForm.showVotes]])N||($=I.querySelector(`[data-block="${H}"]`))==null||$.remove();I.onchange=H=>{var P;const N=H.target;if(N.dataset.detail){const G=s.detailForm.fields.find(V=>V.field===N.dataset.detail);if(G&&!(G.editable??((P=u(G.field))==null?void 0:P.editable)!==!1))return;if(N.dataset.detail==="name"&&!N.value.trim()){N.value=w.name;return}be(w,N.dataset.detail,N.value)}},p("form",I).onsubmit=H=>{H.preventDefault();const N=p("textarea",p("form",I)).value.trim();N&&(w.comments.push(N),q(),Le(w,"评论/备注"),fe("评论已添加到本地 demo"))},p("form textarea",I).onkeydown=H=>{H.key==="Enter"&&(H.metaKey||H.ctrlKey)&&(H.preventDefault(),p("form",I).requestSubmit())}}function bt(w,b,x){return u(w.field)?`<div class="fc-host" data-control-field="${ae(w.field)}" data-control-mode="${x}"></div>`:""}function ze(w,b,x){return{field:w,value:b[w.key]??w.defaultValue??"",item:b,surface:x,readonly:w.editable===!1,openDetail:T=>{const I=C.items.find(O=>O.id===T);I?Le(I):fe("未找到关联工作项")}}}function ei(w,b,x,T){const I=[];for(const O of w.querySelectorAll("[data-control-field]")){const $=x.find(ge=>ge.field===O.dataset.controlField),H=u($.field),N={...H,label:$.label||H.label,required:$.required??H.required,editable:H.editable!==!1&&$.editable!==!1},P=ze(N,b,T==="new"?"create":"detail"),G=e.resolve(N),V=G.createEditor(P);t.push(V),I.push({editor:V,field:N});const ee=V.element.matches("input,select,textarea,[role=textbox]")?V.element:V.element.querySelector("input,select,textarea,[role=textbox]");ee&&(ee.id=`${T}-${N.key}`);const le=document.createElement("div");le.className="fc-error",le.setAttribute("role","status");const te=document.createElement("div");te.className="fc-detail-editor",te.append(V.element,le),O.append(te);let he;T==="detail"&&(O.classList.add("fc-detail-host"),he=document.createElement("div"),he.className="fc-detail-preview",O.prepend(he));const ve=()=>{if(he&&(he.replaceChildren(G.render(ze(N,b,"detail"))),N.editable)){const ge=document.createElement("button");ge.type="button",ge.className="fc-detail-edit",ge.textContent="编辑",ge.ariaLabel=`编辑${N.label}`,ge.onclick=et=>{var Ye;et.stopPropagation(),O.classList.add("editing"),(Ye=V.focus)==null||Ye.call(V)},he.append(ge)}};ve();const Ie=()=>{var et;if(!N.editable)return!0;const ge=(et=V.validate)==null?void 0:et.call(V);if(le.textContent=ge||"",!ge&&T==="detail"){const Ye=V.read();JSON.stringify(b[N.key])!==JSON.stringify(Ye)&&be(b,N.key,Ye),ve()}return!ge};if(T==="detail"&&N.editable){const ge=document.createElement("button");ge.type="button",ge.className="fc-detail-done",ge.textContent="完成",ge.onclick=et=>{et.stopPropagation(),Ie()&&O.classList.remove("editing")},te.append(ge)}O.addEventListener("change",Ie),O.addEventListener("focusout",()=>{queueMicrotask(()=>{O.isConnected&&!O.contains(document.activeElement)&&Ie()&&O.classList.remove("editing")})})}return()=>{var O,$;for(const{editor:H,field:N}of I){if(!N.editable)continue;const P=(O=H.validate)==null?void 0:O.call(H);if(P)return fe(`${N.label}:${P}`),($=H.focus)==null||$.call(H),!1}for(const{editor:H,field:N}of I)N.editable&&(b[N.key]=H.read());return!0}}function ht(w,b,x){var G;o==null||o(),ue();const T=w.closest(".ag-cell")||w,I=[...T.childNodes],O=e.resolve(b).createEditor(ze(b,x,"cell")),$=document.createElement("div");$.className="fc-inline-error",$.setAttribute("role","status");const H=document.createElement("div");H.className="fc-inline-editor",H.append(O.element,$),T.replaceChildren(H),T.classList.add("fc-inline-editing");let N=!1;const P=V=>{var le,te;if(N)return;if(V){const he=(le=O.validate)==null?void 0:le.call(O);if(he){$.textContent=he,O.element.setAttribute("aria-invalid","true");return}}const ee=V?O.read():void 0;N=!0,o=null,(te=O.destroy)==null||te.call(O),T.classList.remove("fc-inline-editing"),T.replaceChildren(...I),V&&x[b.key]!==ee&&be(x,b.key,ee)};o=()=>P(!1),H.addEventListener("keydown",V=>{(V.key==="Enter"||V.key==="Escape")&&(V.preventDefault(),V.stopPropagation(),P(V.key==="Enter"))}),H.addEventListener("focusout",V=>{H.contains(V.relatedTarget)||P(!0)}),H.addEventListener("click",V=>V.stopPropagation()),(G=O.focus)==null||G.call(O),O.element instanceof HTMLInputElement&&O.element.select()}function St(w,b,x){var G;const T=e.resolve(b),I=T.id==="select"||T.id==="multiSelect",O=T.id==="dateTime",$=T.id==="richText",H=Ne(w,I||O||$?"":b.label,'<div class="fc-editor-host"></div><div class="fc-error" role="status"></div>'+(I||$?"":'<div class="actions"><button type="button" class="fc-cancel">取消</button><button type="button" class="primary fc-save">保存</button></div>'),$?240:I?272:320,$?"fc-popup fc-rich-popup":I?"fc-popup fc-choice-popup":"fc-popup");if(I||$){const V=w.getBoundingClientRect();H.style.top=`${Math.max(8,Math.min(V.top,innerHeight-360))}px`}const N=T.createEditor(ze(b,x,"cell"));i=N,p(".fc-editor-host",H).append(N.element);const P=(V=!0)=>{var te;const ee=(te=N.validate)==null?void 0:te.call(N);if(p(".fc-error",H).textContent=ee||"",ee)return;const le=N.read();V&&ue(),be(x,b.key,le)};$?n=()=>{var le;const V=(le=N.validate)==null?void 0:le.call(N);if(p(".fc-error",H).textContent=V||"",V)return!1;const ee=N.read();return x[b.key]!==ee&&be(x,b.key,ee),!0}:I?N.element.addEventListener("change",()=>P(T.id==="select")):(p(".fc-cancel",H).onclick=()=>ue(!1),p(".fc-save",H).onclick=()=>P(),H.addEventListener("keydown",V=>{V.key==="Enter"&&(V.ctrlKey||V.metaKey||V.target instanceof HTMLInputElement)&&(V.preventDefault(),P())})),(G=N.focus)==null||G.call(N)}function $t(w="text"){var G;const b=e.list(),x=b.find(V=>V.id===w)||b[0],T=ke(`<section class="control-manager"><header><div><h2>控件管理</h2><p>统一管理字段的展示和编辑方式</p></div>${se("close-overlay","关闭","close")}</header><div class="control-manager-body"><nav>${b.map(V=>`<button type="button" data-control-id="${ae(V.id)}" class="${V.id===x.id?"active":""}"><span>${ae(V.glyph)}</span>${ae(V.label)}</button>`).join("")}</nav><main><h3>${ae(x.label)}</h3><p>${ae(x.description)}</p><div class="fc-preview-grid"><section><h4>表格单元格</h4><div class="fc-preview-cell"></div><p class="hint">双击或点击编辑</p></section><section><h4>详情页</h4><div class="fc-preview-detail"></div></section></div><div class="fc-preview-edit"></div><div class="fc-error" role="status"></div><div class="actions"><button type="button" class="primary fc-preview-save">应用预览</button></div><p class="hint">在字段类型中选择控件。自定义控件通过 controls 配置或 registerControl() 注册,两处共用同一套展示与编辑接口。</p></main></div></section>`),I={key:"preview",label:x.label,kind:x.id,options:["待开始","进行中","已完成"],editable:!0},O={...C.items[0],preview:x.id==="number"?128:x.id==="multiSelect"?["进行中"]:x.id==="select"?"进行中":x.id==="dateTime"?"2026-09-23T10:30":x.id==="detail"?((G=C.items[0])==null?void 0:G.id)||"":"内容示例"};let $,H=x.createEditor(ze(I,O,"detail"));t.push(H),p(".fc-preview-detail",T).append(H.element);const N=()=>{const V=p(".fc-preview-cell",T);V.replaceChildren(x.render(ze(I,O,"cell")));const ee=document.createElement("button");ee.type="button",ee.textContent="编辑",ee.onclick=P,V.append(ee),V.ondblclick=P},P=()=>{var ee,le;(ee=$==null?void 0:$.destroy)==null||ee.call($),$=x.createEditor(ze(I,O,"cell")),p(x.id==="text"?".fc-preview-cell":".fc-preview-edit",T).replaceChildren($.element),(le=$.focus)==null||le.call($)};t.push({element:T,read:()=>{},destroy:()=>{var V;return(V=$==null?void 0:$.destroy)==null?void 0:V.call($)}}),N(),p(".fc-preview-save",T).onclick=()=>{var te,he,ve;const V=$||H,ee=(te=V.validate)==null?void 0:te.call(V);if(p(".fc-error",T).textContent=ee||"",ee)return;O.preview=V.read(),N(),(he=H.destroy)==null||he.call(H);const le=x.createEditor(ze(I,O,"detail"));t.splice(t.indexOf(H),1,le),p(".fc-preview-detail",T).replaceChildren(le.element),H=le,(ve=$==null?void 0:$.destroy)==null||ve.call($),$=void 0,p(".fc-preview-edit",T).replaceChildren()},T.querySelectorAll("[data-control-id]").forEach(V=>V.onclick=()=>$t(V.dataset.controlId))}function We(){return{id:crypto.randomUUID(),name:"",description:"",source:"",status:"入库",category:"",format:"",approved:"",selectedTopic:"",created:new Date().toISOString().slice(0,10),vote:"",showVotes:"",owner:s.currentUser,creator:s.currentUser,space:s.workspace,followed:!1,starred:!1,viewed:!1,comments:[],history:[],roles:[],meetings:[],...Object.fromEntries(s.fields.filter(w=>w.defaultValue!==void 0).map(w=>[w.key,w.defaultValue]))}}function pt(w){const b=w?structuredClone(w):We(),x=ke(`<form class="create-dialog"><div class="drawer-header"><span class="page-logo">${Re("check")}</span><strong>${ae(s.title)}</strong><div class="spacer"></div>${se("drafts","草稿箱","inbox","outline")}${se("close-overlay","","close")}</div><div class="create-body"><div class="simple-mode"><label><input type="checkbox" id="simple-mode">简洁模式</label></div>${s.createForm.fields.map(I=>{var O,$,H;return`<div class="create-field ${((O=u(I.field))==null?void 0:O.kind)==="longText"?"extended-field":""}"><label for="new-${I.field}">${ae(I.label||(($=u(I.field))==null?void 0:$.label)||I.field)} ${I.required??((H=u(I.field))==null?void 0:H.required)?"<em>*</em>":""}</label>${bt(I,b,"new")}</div>`}).join("")}${s.createForm.showRoles?`<div class="create-field extended-field"><label>角色与人员</label><div><div class="role-line">${dt([["提报人","提报人"]],"提报人",'aria-label="角色"')}<div class="role-person">${Q(s.currentUser)}</div></div>${se("add-role","添加角色","","outline")}<div class="extra-roles"></div></div></div>`:""}${s.createForm.showMeetings?`<section class="detail-section extended-field"><p>进入选题会</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${se("add-meeting","添加一组进入选题会","add")}</div></section>`:""}</div><div class="drawer-footer"><label class="continuous"><input id="continuous" type="checkbox">连续创建</label>${se("close-overlay","取消","","outline")}${se("save-draft","存草稿","","outline")}<button type="submit" class="primary">确认创建</button></div></form>`);j=b,me();const T=ei(x,b,s.createForm.fields,"new");p("#simple-mode",x).onchange=I=>x.querySelectorAll(".extended-field").forEach(O=>O.classList.toggle("hidden",I.target.checked)),p('[data-action="save-draft"]',x).onclick=()=>{if(!T())return;const I=C.drafts.findIndex(O=>O.id===b.id);I>=0?C.drafts[I]=b:C.drafts.push(b),q(),Te(),fe("已存入草稿箱")},p("form",x).onsubmit=I=>{if(I.preventDefault(),!T())return;if(!b.name.trim()){p("#new-name",x).focus();return}const O=p("#continuous",x).checked;C.items.unshift(b),C.drafts=C.drafts.filter($=>$.id!==b.id),q(),ie(),Te(),fe("创建成功"),O&&(pt(),p("#continuous").checked=!0)}}function me(){if(!A||!j)return;const w=j;for(const[b,x]of[["roles",".extra-roles"],["meetings",".meeting-rows"]]){const T=A.querySelector(x);if(!T)continue;const I=w[b]||[];T.innerHTML=I.map((O,$)=>`<div class="role-line"><input data-relation-index="${$}" data-relation-field="name" aria-label="${b==="roles"?"角色名称":"选题会"}" placeholder="${b==="roles"?"角色名称":"选择选题会"}" value="${ae(O.name)}"><input data-relation-index="${$}" data-relation-field="person" aria-label="人员" value="${ae(O.person)}"><button type="button" data-relation-remove="${$}" aria-label="移除">×</button></div>`).join(""),T.onchange=O=>{const $=O.target,H=Number($.dataset.relationIndex);$.dataset.relationField&&(I[H][$.dataset.relationField]=$.value,L&&q())},T.onclick=O=>{const $=O.target.closest("[data-relation-remove]");$&&(I.splice(Number($.dataset.relationRemove),1),me(),L&&q())}}}function ot(w){const b=Ne(w,"存为视图",`<form class="save-view-form"><label>视图名称 <em>*</em></label><input name="name" value="未命名视图" placeholder="请输入视图名称" required><label>协作者</label><input name="collaborators" placeholder="搜索人员" aria-label="协作者"><label>可见范围</label><label><input type="radio" name="visibility" value="public" checked>公开 <small>空间内所有成员可见</small></label><label><input type="radio" name="visibility" value="members">指定成员 <small>协作者、管理员和指定成员可见</small></label><div class="actions"><button type="submit" class="primary">保存</button>${se("close-popup","取消","","outline")}</div></form>`,380);p("form",b).onsubmit=x=>{x.preventDefault();const T=p('input[name="name"]',b).value.trim();T&&(C.views.push({name:T,state:structuredClone(h),columns:F.columnApi.getColumnState(),gridState:F.api.getState(),tab:m,search:y,filterSearch:E,collaborators:p('[name="collaborators"]',b).value,visibility:p('[name="visibility"]:checked',b).value}),q(),st(),ue(),fe("视图已保存"))}}function st(){p('[data-action="saved-views"]').classList.toggle("hidden",!C.views.length)}document.addEventListener("contextmenu",w=>{if(!s.container.contains(w.target))return;const b=w.target.closest("[data-view]");if(!b)return;w.preventDefault();const x=Number(b.dataset.view),T=C.views[x],I=Ne(b,T.name,'<button class="menu-option" data-view-menu="rename">重命名</button><button class="menu-option" data-view-menu="duplicate">复制视图</button><button class="menu-option" data-view-menu="remove">删除视图</button>',220);I.onclick=O=>{var H;const $=(H=O.target.closest("[data-view-menu]"))==null?void 0:H.dataset.viewMenu;if($){if(ue(),$==="rename"&&Be("重命名视图",T.name,N=>{T.name=N,q(),st()}),$==="duplicate"){const N=structuredClone(T);N.name+="(副本)",C.views.push(N),q(),st()}$==="remove"&&(C.views.splice(x,1),q(),st(),fe("视图已删除"))}}},{signal:r.signal});function Ue(w,b,x,T){const I=u(b);if(I){if(I.editable===!1){fe("系统字段,不支持修改");return}if(I.kind==="vote"){be(x,b,x[b]?"":s.currentUser);return}["text","number"].includes(e.resolve(I).id)?ht(w,I,x):St(w,I,x)}}p("#grid").addEventListener("keydown",w=>{if(!["Enter","F2"].includes(w.key)||w.target.closest("button,input,textarea,select"))return;const b=w.target.closest(".ag-cell[data-colid]"),x=b==null?void 0:b.closest("[data-rowid]"),T=C.items.find(I=>I.id===(x==null?void 0:x.dataset.rowid));b&&T&&(w.preventDefault(),Ue(b,b.dataset.colid,T))},{capture:!0,signal:r.signal});function at(){p("#grid").querySelectorAll(".ag-header-cell").forEach(w=>{var O,$;const b=w.dataset.colid;if(!u(b))return;if(!w.querySelector(".work-header-sort")){const H=document.createElement("span");H.className="work-header-sort",(O=w.querySelector(".ag-header-cell-label"))==null||O.append(H);const N=document.createElement("button");N.className="work-header-menu",N.ariaLabel=`${u(b).label}操作`,N.innerHTML=Re("more"),N.onclick=G=>{G.stopPropagation(),Ve(N,b)},N.onmousedown=G=>G.stopPropagation(),w.append(N);for(const G of["right","left"]){const V=document.createElement("button");V.className="work-header-add",V.dataset.insertSide=G,V.ariaLabel=`在${u(b).label}${G==="right"?"右":"左"}侧插入列`,V.title="插入列",V.innerHTML=Re("add"),V.onclick=ee=>{ee.stopPropagation(),xt(V,b,G==="right")},V.onmousedown=ee=>ee.stopPropagation(),w.append(V)}const P=()=>{const G=w.getBoundingClientRect(),V=p(".grid-wrap").getBoundingClientRect(),le=w.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();w.querySelectorAll(".work-header-add").forEach(te=>{const he=te.dataset.insertSide==="left"?G.left:G.right;te.style.left=`${he-12}px`,te.style.top=`${G.top-20}px`,te.style.setProperty("--insert-line-height",`${Math.max(0,V.bottom-G.top+8)}px`),te.style.display=he<Math.max(V.left,le.left)-1||he>Math.min(V.right,le.right)+1?"none":""}),w.classList.add("insert-points-ready")};w.addEventListener("mouseenter",P),w.addEventListener("focusin",P),w.addEventListener("click",G=>{var ee;if(G.target.closest("button,.ag-header-cell-resize"))return;G.stopImmediatePropagation();const V=(ee=h.sorts.find(le=>le.colId===b))==null?void 0:ee.sort;h.sorts=V==="desc"?[]:[{colId:b,sort:V==="asc"?"desc":"asc"}],ie()},{capture:!0})}const x=($=h.sorts.find(H=>H.colId===b))==null?void 0:$.sort,T=w.querySelector(".work-header-sort"),I=x==="asc"?"↑":x==="desc"?"↓":"↕";T.textContent!==I&&(T.textContent=I),T.classList.toggle("sorted",!!x),w.setAttribute("aria-sort",x==="asc"?"ascending":x==="desc"?"descending":"none")})}function xt(w,b,x){const T=Ne(w,"插入列",'<input class="insert-search" placeholder="搜索字段" aria-label="搜索插入字段"><div class="insert-options"></div><button class="menu-option new-field">+ 新建字段</button>',280),I=($="")=>{p(".insert-options",T).innerHTML=s.fields.filter(H=>{var N;return H.label.includes($)&&!((N=F.columnApi.getColumn(H.key))!=null&&N.visible)}).map(H=>`<button class="menu-option" data-insert="${ae(H.key)}">${ae(H.label)}</button>`).join("")||'<p class="muted">暂无未显示字段</p>'},O=$=>{var P;const N=F.columnApi.getColumnState().findIndex(G=>G.colId===b)+(x?1:0);F.columnApi.setColumnVisible($,!0),F.columnApi.setColumnPinned($,b==="_add"?null:((P=F.columnApi.getColumn(b))==null?void 0:P.pinned)??null),F.columnApi.moveColumn($,Math.max(1,N)),ue(),J(),at()};I(),p("input",T).oninput=$=>I($.target.value),T.onclick=$=>{const H=$.target.closest("[data-insert],.new-field");if(!H)return;if(H.dataset.insert){O(H.dataset.insert);return}const N=Ne(w,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${e.list().map(P=>`<option value="${ae(P.id)}">${ae(P.label)}</option>`).join("")}<option value="person">人员</option><option value="relation">关联</option></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);p('[name="kind"]',N).onchange=P=>{p(".choice-limit",N).classList.toggle("hidden",P.target.value!=="multiSelect")},p("form",N).onsubmit=P=>{P.preventDefault();const G=new FormData(P.target),V=String(G.get("label")||"").trim();if(!V)return;const ee=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,le=String(G.get("kind")),te={key:ee,label:V,kind:le,editable:!0,width:160};["select","multiSelect","person"].includes(le)&&(te.options=[...new Set(String(G.get("options")||"").split(`
120
- `).map(Ie=>Ie.trim()).filter(Boolean))]);const he=Number(G.get("maxSelections"));le==="multiSelect"&&Number.isInteger(he)&&he>0&&(te.maxSelections=he),s.fields.push(te),d.push([ee,V]),te.options&&(f[ee]=te.options),C.customFields.push(te);const ve=F.columnApi.getColumnState();F.api.setColumnDefs(U()),F.columnApi.applyColumnState(ve,!0),O(ee),q(),ie()}}}function Ve(w,b){const x=F.columnApi.getColumn(b);if(!x||b==="_select")return;if(b==="_add"){xt(w,b,!1);return}const T=["向左插入列","向右插入列",f[b]?"以 首项 → 末项 排序":"以 A → Z 排序",f[b]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",x.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],I=Ne(w,"",[[0,1],[2,3],[4,8],[5,6,7]].map(O=>O.map($=>`<button class="menu-option${$===7?" destructive":""}" data-col-menu="${$}" ${$===7&&b==="name"?"disabled":""}>${T[$]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");I.dataset.headerMenu="true",I.onclick=O=>{const $=O.target.closest("[data-col-menu]");if(!$)return;const H=+$.dataset.colMenu;ue(),(H===0||H===1)&&xt(w,b,H===1),(H===2||H===3)&&(h.sorts=[{colId:b,sort:H===2?"asc":"desc"}],ie()),H===4&&(h.filters.push({field:b,operator:"contains",value:""}),X("filter",p('[data-action="filter"]'))),H===5&&F.columnApi.setColumnPinned(b,x.pinned?null:"left"),H===6&&Be("编辑列",x.headerName,N=>{const P=u(b);P&&(P.label=N);const G=F.api.getColumnDefs(),V=G.find(le=>le.field===b);V&&(V.headerName=N);const ee=F.columnApi.getColumnState();F.api.setColumnDefs(G),F.columnApi.applyColumnState(ee,!0),at()}),H===7&&F.columnApi.setColumnVisible(b,!1),H===8&&(h.groups.includes(b)||h.groups.push(b),ie())}}p("#grid").addEventListener("contextmenu",w=>{const b=w.target.closest(".ag-header-cell");if(b){w.preventDefault();const x=b.getAttribute("col-id")||b.dataset.colid||b.dataset.colId||"";Ve(b,x)}else{const x=w.target.closest(".ag-cell");if(x){w.preventDefault();const T=Ne(x,"单元格",se("copy-cell","复制")+se("paste-cell","粘贴")+se("export","导出表格"),200);p('[data-action="copy-cell"]',T).onclick=async()=>{try{await navigator.clipboard.writeText(x.textContent||""),fe("已复制")}catch{fe("复制失败,请使用 ⌘C")}ue()}}}}),p("#grid").addEventListener("dblclick",w=>{var $;const b=w.target.closest(".ag-cell");if(!b||w.target.closest("input,textarea,select,.ag-cell-edit-input"))return;const x=b.dataset.colid,T=C.items.find(H=>{var N;return H.id===((N=b.closest(".ag-row"))==null?void 0:N.dataset.rowid)});if(!T||!u(x))return;clearTimeout(D),w.stopImmediatePropagation(),w.preventDefault();const I=F.api.getDisplayedRowCount();let O=0;for(;O<I&&(($=F.api.getDisplayedRowAtIndex(O))==null?void 0:$.id)!==T.id;O++);Ue(b,x,T)},{capture:!0,signal:r.signal}),document.addEventListener("click",w=>{s.container.querySelectorAll(".field-picker").forEach(b=>{b.contains(w.target)||b.remove()}),p("#grid").contains(w.target)||(F.api.getCellRanges().length&&F.api.clearRangeSelection(),F.api.getFocusedCell()&&F.api.clearFocusedCell()),(S==null?void 0:S.dataset.headerMenu)==="true"&&!S.contains(w.target)&&ue()},{capture:!0,signal:r.signal}),document.addEventListener("click",async w=>{const b=w.target,x=N=>w.composedPath().some(P=>P instanceof Element&&P.matches(N));if(!w.composedPath().includes(s.container)){ue();return}x(".popup,.field-picker,.toolbar,.ag-cell,.ag-header-cell,.list-bottom,.create-button")||ue();const T=b.closest("[data-tab]");if(T){m=T.dataset.tab,s.container.querySelectorAll("[data-tab]").forEach(N=>{N.classList.toggle("active",N===T),N.setAttribute("aria-selected",String(N===T))}),ie();return}const I=b.closest("[data-view]");if(I){const N=C.views[+I.dataset.view];h=structuredClone(N.state),m=N.tab||"全部",y=N.search||"",E=!!N.filterSearch,s.container.querySelectorAll("[data-tab]").forEach(P=>{P.classList.toggle("active",P.dataset.tab===m),P.setAttribute("aria-selected",String(P.dataset.tab===m))}),p("#search").value=y,p("#filter-search").checked=E,p(".search-wrap").classList.toggle("hidden",!y),p('[data-action="search"]').classList.toggle("hidden",!!y),ue(),ie(),N.gridState?F.api.setState(N.gridState):N.columns&&F.columnApi.applyColumnState(N.columns,!0),Y();return}const O=b.closest("[data-detail-tab]");if(O&&L){Le(L,O.dataset.detailTab);return}const $=b.closest("[data-action]");if(!$)return;const H=$.dataset.action;if(["filter","sort","group","color"].includes(H)){k===H?ue():X(H,$);return}switch(H){case"controls":$t();break;case"close-popup":ue();break;case"create":pt();break;case"create-menu":Ne($,"新建",se("create","新建选题","plus","menu-option")+se("drafts","草稿箱","inbox","menu-option"),180);break;case"drafts":{const N=ke(`<section class="dialog"><h2>草稿箱</h2>${C.drafts.length?C.drafts.map((P,G)=>`<button class="menu-option" data-draft="${G}">${ae(P.name||"未命名选题")}</button>`).join(""):'<p class="muted">暂无草稿</p>'}<div class="actions">${se("close-overlay","关闭","","outline")}</div></section>`);N.onclick=P=>{const G=P.target.closest("[data-draft]");G&&pt(C.drafts[+G.dataset.draft])};break}case"close-overlay":Te();break;case"search":p(".search-wrap").classList.remove("hidden"),$.classList.add("hidden"),p("#search").focus();break;case"close-search":y="",E=!1,p("#search").value="",p("#filter-search").checked=!1,p(".search-wrap").classList.add("hidden"),p('[data-action="search"]').classList.remove("hidden"),ie();break;case"previous-match":R--,Y();break;case"next-match":R++,Y();break;case"reset":h=yn(),ie(),ue();break;case"columns":case"layout":pe($);break;case"save-view":case"pin-view":ot($);break;case"saved-views":Ne($,"切换视图",C.views.map((N,P)=>`<button class="menu-option" data-view="${P}">${Re("table")}<span>${ae(N.name)}</span></button>`).join(""),260);break;case"share":{const N=Ne($,"分享工作项列表",`<input readonly value="${ae(location.href.split("#")[0])}" aria-label="分享链接"><p class="hint">复制此 demo 的访问地址</p><button class="primary" id="copy-link">复制链接</button>`,380);p("#copy-link",N).onclick=async()=>{try{await navigator.clipboard.writeText(location.href.split("#")[0]),fe("链接已复制"),ue()}catch{p("input",N).select(),fe("请按 ⌘C 复制链接")}};break}case"deselect":F.api.deselectAll();break;case"batch-status":case"batch-owner":{const N=H==="batch-status"?"status":"owner",P=F.api.getSelectedRows(),G=Ne($,"批量更新",f[N].map(V=>`<button class="menu-option" data-batch-value="${V}">${V}</button>`).join(""),220);G.onclick=V=>{const ee=V.target.closest("[data-batch-value]");ee&&(P.forEach(le=>{le[N]=ee.dataset.batchValue,le.history.push(`批量更新${N}:${le[N]}`)}),q(),ie(),ue(),fe(`已更新 ${P.length} 项`))};break}case"batch-archive":{const N=F.api.getSelectedRows();N.forEach(P=>P.status="已终止"),q(),ie(),fe(`已终止 ${N.length} 项,可在筛选中显示`);break}case"batch-export":F.api.exportToCsv({fileName:"选题库.csv",onlySelected:!0,columnKeys:d.map(([N])=>N)});break;case"export":F.api.exportToCsv({fileName:"选题库.csv",columnKeys:d.map(([N])=>N)}),ue();break;case"paste-cell":F.api.pasteFromClipboard(),ue();break;case"follow":L&&(L.followed=!L.followed,q(),Le(L,W));break;case"star":L&&(L.starred=!L.starred,q(),Le(L,W));break;case"detail-vote":L&&(be(L,"vote",L.vote?"":"体验官"),Le(L));break;case"detail-status":L&&Zt($,"status",L);break;case"prev-item":case"next-item":if(L){const N=C.items.indexOf(L)+(H==="prev-item"?-1:1);C.items[N]&&Le(C.items[N],W)}break;case"detail-more":Ne($,"更多操作",se("duplicate","复制工作项","","menu-option")+se("terminate-item","终止工作项","","menu-option"),220);break;case"duplicate":if(L){const N=structuredClone(L);N.id=crypto.randomUUID(),N.name+="(副本)",N.comments=[],N.history=[],C.items.unshift(N),q(),ie(),Le(N)}break;case"terminate-item":L&&(be(L,"status","已终止"),Te(),fe("工作项已终止"));break;case"add-role":j&&(j.roles??(j.roles=[]),j.roles.push({name:"",person:s.currentUser}),me(),L&&q());break;case"add-meeting":j&&(j.meetings??(j.meetings=[]),j.meetings.push({name:"",person:s.currentUser}),me(),L&&q());break;case"link-material":{const N=L;N&&Be("关联素材","",P=>{N.materials??(N.materials=[]),N.materials.push(P),N.history.push(`关联素材:${P}`),q(),Le(N,"素材管理")});break}}},{signal:r.signal}),p("#search").oninput=w=>{y=w.target.value,R=0,E?ie():Y()},p("#filter-search").onchange=w=>{E=w.target.checked,ie()},document.addEventListener("keydown",w=>{if(s.container.contains(w.target)&&(w.key==="Escape"&&(s.container.querySelector(".field-picker")?s.container.querySelectorAll(".field-picker").forEach(b=>b.remove()):S?ue(!1):A&&Te()),w.key==="Tab"&&A)){const b=[...A.querySelectorAll('button:not([disabled]),input,select,textarea,[tabindex="0"]')].filter(I=>I.offsetParent!==null),x=b[0],T=b[b.length-1];w.shiftKey&&document.activeElement===x?(w.preventDefault(),T==null||T.focus()):!w.shiftKey&&document.activeElement===T&&(w.preventDefault(),x==null||x.focus())}},{signal:r.signal}),window.addEventListener("pagehide",()=>F.grid.destroy(),{once:!0,signal:r.signal});const Se=p("#grid .ag-body-viewport"),lt=p(".grid-wrap"),_e=document.createElement("div");_e.className="work-horizontal-scrollbar",_e.setAttribute("aria-label","横向滚动表格");const Rn=document.createElement("div");_e.append(Rn),lt.append(_e);const qe=document.createElement("div");qe.className="work-vertical-scrollbar",qe.setAttribute("aria-label","纵向滚动表格");const Mn=document.createElement("div");qe.append(Mn),lt.append(qe);const kn=()=>{const w=Se.getBoundingClientRect(),b=lt.getBoundingClientRect();_e.style.left=`${w.left-b.left-1}px`,_e.style.width=`${Se.clientWidth}px`,Rn.style.width=`${Se.scrollWidth}px`,_e.hidden=Se.scrollWidth<=Se.clientWidth,_e.scrollLeft=Se.scrollLeft,qe.style.top=`${w.top-b.top-1}px`,qe.style.height=`${Se.clientHeight}px`,Mn.style.height=`${Se.scrollHeight}px`,qe.hidden=Se.scrollHeight<=Se.clientHeight,qe.scrollTop=Se.scrollTop};_e.addEventListener("scroll",()=>{Se.scrollLeft=_e.scrollLeft},{passive:!0,signal:r.signal}),qe.addEventListener("scroll",()=>{Se.scrollTop=qe.scrollTop},{passive:!0,signal:r.signal});let Ei=0;Se.addEventListener("pointermove",w=>{const b=Se.getBoundingClientRect();Se.classList.toggle("scrollbar-near-right",b.right-w.clientX<=16),Se.classList.toggle("scrollbar-near-bottom",b.bottom-w.clientY<=16),lt.classList.toggle("scrollbar-near-right",b.right-w.clientX<=16),lt.classList.toggle("scrollbar-near-bottom",b.bottom-w.clientY<=16)},{signal:r.signal}),Se.addEventListener("pointerleave",()=>{Se.classList.remove("scrollbar-near-right","scrollbar-near-bottom"),lt.classList.remove("scrollbar-near-right","scrollbar-near-bottom")},{signal:r.signal}),Se.addEventListener("scroll",()=>{Se.classList.add("scrollbar-scrolling"),lt.classList.add("scrollbar-scrolling"),_e.scrollLeft=Se.scrollLeft,qe.scrollTop=Se.scrollTop,clearTimeout(Ei),Ei=window.setTimeout(()=>{Se.classList.remove("scrollbar-scrolling"),lt.classList.remove("scrollbar-scrolling")},900)},{passive:!0,signal:r.signal});const Tn=()=>{p("#grid").querySelectorAll(".insert-points-ready").forEach(w=>w.classList.remove("insert-points-ready"))};window.addEventListener("scroll",Tn,{capture:!0,signal:r.signal}),window.addEventListener("resize",Tn,{signal:r.signal});const gt=new ResizeObserver(()=>{J(),kn()});gt.observe(p(".list-area")),gt.observe(p(".toolbar")),gt.observe(p(".list-tabs")),gt.observe(p(".ag-header-wrapper")),gt.observe(Se),gt.observe(p(".ag-body-container")),kn();const Nn=new window.MutationObserver(()=>at());if(Nn.observe(p("#grid .ag-header"),{childList:!0,subtree:!0}),at(),st(),J(),s.syncLocationHash&&location.hash.startsWith("#item/")){const w=C.items.find(b=>b.id===location.hash.slice(6));w&&Le(w)}return{registerControl:w=>{e.register(w),F.api.refreshCells({force:!0})},getControls:()=>e.list(),api:F.api,columnApi:F.columnApi,getViewState:()=>({...structuredClone(h),columns:F.columnApi.getColumnState()}),getItems:()=>structuredClone(C.items),destroy:()=>{l=!0,o==null||o(),Nn.disconnect(),gt.disconnect(),r.abort(),clearTimeout(M),clearTimeout(D),clearTimeout(Ei),ue(),Te(),F.grid.destroy(),s.container.replaceChildren(),s.container.classList.remove("rowvia-work-items")}}}const ua={name:"title",description:"longText",vote:"vote",showVotes:"select",status:"status",selectedTopic:"relation",format:"multiSelect",approved:"select",category:"select",owner:"person",space:"text",created:"date",creator:"person",source:"longText"};function En(s){return{container:s,title:"选题库",workspace:"内容制作全流程",currentUser:"体验官",storageKey:"rowvia:work-items:v3",items:Jt,fields:[...oa.map(([e,t])=>({key:e,label:t,kind:ua[e],width:120,minWidth:80,pinned:e==="name"?"left":null,editable:!["created","creator","space"].includes(e),required:e==="name",options:sa[e]})),{key:"source",label:"参考来源",kind:"longText",hidden:!0,editable:!0}],createForm:{fields:["name","category","format","source","description"].map(e=>({field:e})),showRoles:!0,showMeetings:!0},detailForm:{fields:["name","description","category","format","source"].map(e=>({field:e})),showRoles:!0,showMeetings:!0,showApproval:!0,showVotes:!0}}}function ha(s){const e=En(s);e.storageKey="rowvia:work-items:date-1000:v1";const t=[{key:"singleDate",label:"单日期",kind:"date",width:150,editable:!0,dateOptions:{showTime:!1,showRange:!1}},{key:"dateTime",label:"日期时间",kind:"dateTime",width:190,editable:!0,dateOptions:{showTime:!0,showRange:!1}},{key:"dateRange",label:"日期范围",kind:"date",width:260,editable:!0,dateOptions:{showTime:!1,showRange:!0}}];e.fields.splice(1,0,...t),e.createForm.fields.push(...t.map(({key:n})=>({field:n}))),e.detailForm.fields.push(...t.map(({key:n})=>({field:n})));const i=n=>new Date(Date.UTC(2024,0,1+n)).toISOString().slice(0,10);return e.items=Array.from({length:1e3},(n,o)=>{const a=structuredClone(Jt[o%Jt.length]),r=i(o);return{...a,id:`date-demo-${String(o+1).padStart(4,"0")}`,name:`${a.name} · ${String(o+1).padStart(4,"0")}`,singleDate:r,dateTime:`${r}T${String(o%24).padStart(2,"0")}:${String(o%60).padStart(2,"0")}`,dateRange:[r,i(o+o%15)]}}),e}function xi(s,e){const t=new vt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function pa(s,e){zt[s]=e}function ga(s,e){it[s]=e}re.CELL_EDITORS=it,re.CELL_RENDERERS=zt,re.DEFAULT_LOCALE_TEXT=Hi,re.FORMULA_FUNCTIONS=Ht,re.GANTT_UNITS=Qi,re.GanttChart=en,re.Grid=vt,re.UNIT_LABEL=Ut,re.computeStickyGroupRows=Vi,re.createControlRegistry=wn,re.createDetailDialog=Xi,re.createFinancePage=Bs,re.createGantt=Rs,re.createGrid=xi,re.createHrPage=Vs,re.createInventoryPage=qs,re.createPerformancePage=Js,re.createPersonnelSchedule=ks,re.createServerSidePage=Zs,re.createSparklineSvg=si,re.createWorkItemPage=da,re.dateDemoConfig=ha,re.default=vt,re.evaluateFormula=Mt,re.formatNumberCommas=Ke,re.isFormula=ni,re.parse=Ii,re.registerEditor=ga,re.registerFormulaFunction=On,re.registerRenderer=pa,re.sanitizeRichText=Ft,re.tokenize=Ti,re.topicDemoConfig=En,Object.defineProperties(re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
112
+ <button type="button" class="color-swatch" data-color="${G}" style="background-color:${ae(I.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
113
+ <button type="button" class="field-select" data-color-scope="${G}" aria-label="着色范围" aria-expanded="false">${!I.scope||I.scope==="row"?"整行":"单元格"}${xe("down")}</button>
114
+ <button class="field-select ${V?"":"empty"}" data-pick="${G}">${ae(V||"请选择筛选项")}${xe("down")}</button>
115
+ ${ht(ee,I.field?I.operator:"",`data-operator="${G}" aria-label="运算符" ${I.field?"":"disabled"}`)}
116
+ ${se}
117
+ <button class="color-remove" data-remove="${G}" aria-label="删除条件" title="删除条件">${xe("close")}</button>
118
+ <div class="color-more-wrap"><button class="color-more" data-color-more="${G}" aria-label="更多条件操作" aria-expanded="false">${xe("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${G}">复制条件</button><button data-color-up="${G}" ${G===0?"disabled":""}>上移</button><button data-color-down="${G}" ${G===p.colors.length-1?"disabled":""}>下移</button></div></div>
119
+ </div>`}).join(""),x=Ne(C,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${b}</div><div class="color-panel-footer"><button class="add-condition">${xe("plus")}添加着色条件</button><button class="clear-rules" ${p.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");x.ariaLabel="设置颜色条件",N="color";const M=()=>K(C),L=()=>{te(),M()},O=["#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"],H=()=>{var I;(I=x.querySelector(".color-palette"))==null||I.remove(),x.querySelectorAll("[data-color]").forEach(G=>G.setAttribute("aria-expanded","false"))},D=()=>{var I,G;(I=x.querySelector(".color-scope-picker"))==null||I.remove(),(G=i==null?void 0:i.destroy)==null||G.call(i),i=null,x.querySelectorAll("[data-color-scope]").forEach(V=>V.setAttribute("aria-expanded","false"))};let k=-1;x.querySelectorAll(".color-condition").forEach((I,G)=>{I.ondragstart=V=>{var ee;k=G,(ee=V.dataTransfer)==null||ee.setData("text/plain",String(G))},I.ondragover=V=>V.preventDefault(),I.ondrop=V=>{if(V.preventDefault(),k<0||k===G)return;const[ee]=p.colors.splice(k,1);p.colors.splice(G,0,ee),L()}}),x.onclick=I=>{var ee,de;I.stopPropagation();const G=I.target.closest("button");if(I.target.closest(".color-scope-picker"))return;const V=(G==null?void 0:G.getAttribute("aria-expanded"))==="true";if(D(),!G||G.disabled){H();return}if(G.dataset.colorScope!==void 0){if(H(),V)return;const se=Number(G.dataset.colorScope),he=p.colors[se],ge={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},Le=e.resolve(ge).createEditor({field:ge,value:!he.scope||he.scope==="row"?"整行":"单元格",item:We(),surface:"cell",readonly:!1,openDetail:()=>{}});i=Le;const fe=document.createElement("div");fe.className="popup fc-popup fc-choice-popup color-scope-picker",fe.style.width="272px",fe.append(Le.element),x.append(fe);const et=G.getBoundingClientRect();fe.style.left=`${Math.max(8,Math.min(et.left,innerWidth-280))}px`,fe.style.top=`${Math.max(8,Math.min(et.bottom+6,innerHeight-fe.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),Le.element.addEventListener("change",Ye=>{var Nn,In;Ye.stopPropagation(),!((Nn=Le.validate)!=null&&Nn.call(Le))&&(he.scope=Le.read()==="整行"?"row":"cell",L(),(In=S==null?void 0:S.querySelector(`[data-color-scope="${se}"]`))==null||In.focus())}),fe.onkeydown=Ye=>{Ye.key==="Escape"&&(Ye.stopPropagation(),D(),G.focus())},(ee=Le.focus)==null||ee.call(Le);return}if(G.dataset.paletteColor!==void 0){const se=Number(G.closest(".color-palette").dataset.ruleIndex);p.colors[se].color=G.dataset.paletteColor,L(),(de=S==null?void 0:S.querySelector(`[data-color="${se}"]`))==null||de.focus();return}if(G.dataset.color!==void 0){const se=G.getAttribute("aria-expanded")==="true";if(H(),se)return;const he=Number(G.dataset.color),ge=document.createElement("div");ge.className="color-palette",ge.dataset.ruleIndex=String(he),ge.setAttribute("role","group"),ge.ariaLabel="选择着色颜色",ge.innerHTML=O.map(fe=>`<button type="button" class="color-palette-option" data-palette-color="${fe}" style="background-color:${fe}" aria-label="颜色 ${fe}" aria-pressed="${fe===p.colors[he].color.toLowerCase()}"></button>`).join(""),x.append(ge);const Le=G.getBoundingClientRect();ge.style.left=`${Math.max(8,Math.min(Le.left,innerWidth-ge.offsetWidth-8))}px`,ge.style.top=`${Math.max(8,Math.min(Le.bottom+6,innerHeight-ge.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),ge.onkeydown=fe=>{fe.key==="Escape"&&(fe.stopPropagation(),H(),G.focus())};return}if(H(),G.classList.contains("add-condition"))p.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),L();else if(G.dataset.pick!==void 0){const se=+G.dataset.pick;ot(G,he=>{p.colors[se].field=he,p.colors[se].value="",p.colors[se].operator="contains",L()})}else if(G.dataset.remove!==void 0)p.colors.splice(+G.dataset.remove,1),L();else if(G.classList.contains("clear-rules"))p.colors=[],L();else if(G.dataset.colorMore!==void 0){const se=G.nextElementSibling,he=se.classList.contains("hidden");x.querySelectorAll(".color-rule-menu").forEach(ge=>ge.classList.add("hidden")),x.querySelectorAll("[data-color-more]").forEach(ge=>ge.setAttribute("aria-expanded","false")),se.classList.toggle("hidden",!he),G.setAttribute("aria-expanded",String(he))}else if(G.dataset.colorCopy!==void 0){const se=+G.dataset.colorCopy;p.colors.splice(se+1,0,structuredClone(p.colors[se])),L()}else if(G.dataset.colorUp!==void 0||G.dataset.colorDown!==void 0){const se=Number(G.dataset.colorUp??G.dataset.colorDown),[he]=p.colors.splice(se,1);p.colors.splice(se+(G.dataset.colorUp!==void 0?-1:1),0,he),L()}},x.onchange=I=>{const G=I.target;if(G.dataset.operator!==void 0){p.colors[+G.dataset.operator].operator=G.value,L();return}G.dataset.ruleValue!==void 0&&(p.colors[+G.dataset.ruleValue].value=G.value),te()},x.oninput=I=>{const G=I.target;if(G.dataset.ruleValue!==void 0)p.colors[+G.dataset.ruleValue].value=G.value;else return;te()}}function X(C,b){if(C==="color"){K(b);return}const x={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[C],M=C==="filter"?p.filters:C==="sort"?p.sorts:C==="group"?p.groups:p.colors,L=M.map((k,I)=>{var he;const G=C==="sort"?k.colId:C==="group"?k:k.field,V=((he=u.find(([ge])=>ge===G))==null?void 0:he[1])||G,ee=`<button class="field-select" data-pick="${I}">${ae(V)}${xe("down")}</button>`;if(C==="sort")return`<div class="condition">${ee}<button class="sort-direction ${k.sort==="asc"?"selected":""}" data-dir="asc" data-index="${I}">首项 → 末项</button><button class="sort-direction ${k.sort==="desc"?"selected":""}" data-dir="desc" data-index="${I}">末项 → 首项</button><button data-remove="${I}" aria-label="删除条件">${xe("close")}</button></div>`;if(C==="group")return`<div class="condition">${ee}<span class="spacer"></span><button data-remove="${I}" aria-label="删除条件">${xe("close")}</button></div>`;const de=ht([["contains",g[G]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],k.operator,`data-operator="${I}" aria-label="运算符"`),se=["blank","notBlank"].includes(k.operator)?"":g[G]?ht([["","请选择目标值"],...g[G].map(ge=>[ge,ge])],k.value,`data-rule-value="${I}" aria-label="目标值"`):`<input data-rule-value="${I}" aria-label="目标值" value="${ae(k.value)}" placeholder="请选择目标值">`;return`<div class="condition">${ee}${de}${se}${C==="color"?`<input type="color" data-color="${I}" value="${k.color}" aria-label="行颜色">`:""}<button data-remove="${I}" aria-label="删除条件">${xe("close")}</button></div>`}).join(""),O=Ne(b,`设置${x}条件`,`${C==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${p.showTerminated?"checked":""}>显示已终止数据</label>`:""}${L}<button class="add-condition">${xe("plus")}添加${C==="color"?"着色":x}条件</button>${M.length?'<button class="clear-rules">清空全部条件</button>':""}`,C==="color"?650:560);N=C;const H=()=>X(C,b);let D=-1;O.querySelectorAll(".condition").forEach((k,I)=>{k.draggable=!0,k.ondragstart=G=>{var V;D=I,(V=G.dataTransfer)==null||V.setData("text/plain",String(I))},k.ondragover=G=>G.preventDefault(),k.ondrop=G=>{if(G.preventDefault(),D<0||D===I)return;const[V]=M.splice(D,1);M.splice(I,0,V),te(),H()}}),O.onclick=k=>{const I=k.target.closest("button");I&&(I.classList.contains("add-condition")&&ot(I,G=>{C==="filter"&&p.filters.push({field:G,operator:"contains",value:""}),C==="sort"&&p.sorts.push({colId:G,sort:"asc"}),C==="group"&&!p.groups.includes(G)&&p.groups.push(G),C==="color"&&p.colors.push({field:G,operator:"contains",value:"",color:"#e9f2ff"}),te(),H()}),I.dataset.pick!==void 0&&ot(I,G=>{const V=+I.dataset.pick;C==="sort"?p.sorts[V].colId=G:C==="group"?p.groups[V]=G:(M[V].field=G,M[V].value=""),te(),H()}),I.dataset.remove!==void 0&&(M.splice(+I.dataset.remove,1),te(),H()),I.classList.contains("clear-rules")&&(M.splice(0),te(),H()),I.dataset.dir&&(p.sorts[+I.dataset.index].sort=I.dataset.dir,te(),H()))},O.onchange=k=>{const I=k.target;I.id==="terminated"&&(p.showTerminated=I.checked),I.dataset.operator!==void 0&&(M[+I.dataset.operator].operator=I.value,H()),I.dataset.ruleValue!==void 0&&(M[+I.dataset.ruleValue].value=I.value),I.dataset.color!==void 0&&(p.colors[+I.dataset.color].color=I.value),te()},O.oninput=k=>{const I=k.target;I.tagName==="INPUT"&&I.dataset.ruleValue!==void 0&&(M[+I.dataset.ruleValue].value=I.value,te())}}function J(){const C=$.api.getDisplayedRowCount(),b=$.api.getAllColumns().filter(I=>I.visible).reduce((I,G)=>I+G.width,0),x=h(".grid-wrap"),M=h(".list-area"),L=getComputedStyle(M),O=Math.max(0,M.clientWidth-parseFloat(L.paddingLeft||"0")-parseFloat(L.paddingRight||"0")),H=Math.max(0,M.clientHeight-x.offsetTop-parseFloat(L.paddingBottom||"0")),D=h(".ag-header-wrapper",x).getBoundingClientRect().height||33,k=Math.max(1,C)*37+D+1;x.style.width=`${Math.min(O,b+1)}px`,x.style.height=`${Math.min(H,k)}px`}function Y(){var b;const C=Z().filter(x=>y&&x.name.toLowerCase().includes(y.toLowerCase())).map(x=>x.id);if(R=Math.max(0,Math.min(R,C.length-1)),h("#matches").textContent=y?`${C.length?R+1:0}/${C.length}`:"",s.container.querySelectorAll(".item-name").forEach(x=>{const M=x.hash.replace("#item/","");x.classList.toggle("find-match",C.includes(M)),x.classList.toggle("find-current",C[R]===M)}),C[R]){let x=-1;for(let M=0;M<$.api.getDisplayedRowCount();M++)((b=$.api.getDisplayedRowAtIndex(M))==null?void 0:b.id)===C[R]&&(x=M);x>=0&&$.api.ensureIndexVisible(x)}h('[data-action="previous-match"]').toggleAttribute("disabled",!C.length),h('[data-action="next-match"]').toggleAttribute("disabled",!C.length)}function ne(){const C=$.api.getSelectedRows(),b=h(".selection-bar");b.classList.toggle("hidden",!C.length),b.innerHTML=`${oe("deselect","","close")}<span>已选择 ${C.length} 项</span>${oe("batch-status","更新状态")}${oe("batch-owner","更新负责人")}${oe("batch-export","导出")}${oe("batch-archive","终止")}${oe("deselect","取消选择")}`}function pe(C){const b=Ne(C,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${$.api.getAllColumns().filter(x=>!x.colId.startsWith("_")).map(x=>`<label class="column-option"><input type="checkbox" data-column="${x.colId}" ${x.visible?"checked":""}><span>${ae(x.headerName)}</span><button type="button" data-pin="${x.colId}">${x.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);b.onchange=x=>{const M=x.target;M.dataset.column&&$.columnApi.setColumnVisible(M.dataset.column,M.checked)},b.onclick=x=>{const M=x.target.closest("[data-pin]");if(M){x.preventDefault();const L=$.columnApi.getColumn(M.dataset.pin);$.columnApi.setColumnPinned(L,L.pinned?null:"left"),pe(C)}},h("input",b).oninput=x=>{const M=x.target.value;b.querySelectorAll(".column-option").forEach(L=>L.hidden=!L.textContent.includes(M))}}function Te(){t.forEach(C=>{var b;return(b=C.destroy)==null?void 0:b.call(C)}),t=[],P==null||P.remove(),P=null,A=null,j=null,B==null||B.focus(),s.syncLocationHash&&location.hash.startsWith("#item/")&&history.replaceState(null,"",location.pathname+location.search)}function ke(C,b="dialog-overlay"){return ce(),s.container.querySelectorAll(".field-picker").forEach(x=>x.remove()),t.forEach(x=>{var M;return(M=x.destroy)==null?void 0:M.call(x)}),t=[],P==null||P.remove(),B=document.activeElement,P=document.createElement("div"),P.className=`overlay ${b}`,P.innerHTML=C,P.setAttribute("role","dialog"),P.setAttribute("aria-modal","true"),s.container.append(P),P.addEventListener("click",x=>{x.target===P&&Te()}),P}function Be(C,b,x){const M=ke(`<form class="dialog"><h2>${ae(C)}</h2><input aria-label="${ae(C)}" value="${ae(b)}" required><div class="actions">${oe("close-overlay","取消","","outline")}<button class="primary" type="submit">确定</button></div></form>`);h("form",M).onsubmit=L=>{L.preventDefault();const O=h("input",M).value.trim();O&&(Te(),x(O))},h("input",M).focus()}function Ie(C,b="基本信息"){var O,H;if(s.onOpenDetail){s.onOpenDetail(structuredClone(C));return}C.viewed=!0,q(),A=C,W=b,s.syncLocationHash&&history.replaceState(null,"",`#item/${C.id}`);const x=s.detailForm.fields,M=b==="基本信息"?`<div class="detail-fields">${x.map(D=>{var k,I;return`<div class="detail-row"><label for="detail-${D.field}">${ae(D.label||((k=f(D.field))==null?void 0:k.label)||D.field)}${D.required??((I=f(D.field))==null?void 0:I.required)?" *":""}</label>${St(D,C,"detail")}</div>`}).join("")}<div class="detail-row" data-block="roles"><label>角色与人员</label><div>提报人  ${Q(C.owner)}<p>${oe("add-role","添加角色","","outline")}</p><div class="extra-roles"></div></div></div></div><section class="detail-section" data-block="meetings"><p>进入选题会</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${oe("add-meeting","添加一组进入选题会","add")}</div><div class="detail-row" data-block="approval"><label>选题是否通过</label><div class="radios">${["是","待定","废弃"].map(D=>`<label><input type="radio" name="approved" value="${D}" data-detail="approved" ${C.approved===D?"checked":""}>${D}</label>`).join("")}</div></div></section><section class="detail-section" data-block="votes"><div class="detail-row"><label>选题投票</label><div>${oe("detail-vote",C.vote?"1":"投票","plus","vote")}</div></div><div class="detail-row"><label>是否展示投票结果</label><div class="radios">${["是","否"].map(D=>`<label><input type="radio" name="showVotes" value="${D}" data-detail="showVotes" ${C.showVotes===D?"checked":""}>${D}</label>`).join("")}</div></div></section><div class="detail-row muted"><label>父级工作项</label><span>暂无关联WBS 父工作项</span></div>`:b==="评论/备注"?`<div class="comment-list">${C.comments.length?C.comments.map(D=>`<article>${Q("体验官")}<p>${ae(D)}</p></article>`).join(""):'<p class="muted">暂无评论/备注</p>'}</div>`:b==="操作记录"?`<div class="history-list">${C.history.length?C.history.map(D=>`<p>${ae(D)}</p>`).join(""):'<p class="muted">暂无操作记录</p>'}</div>`:`<div class="muted">${(O=C.materials)!=null&&O.length?C.materials.map(D=>`<p>${ae(D)}</p>`).join(""):"暂无关联素材"}</div>${oe("link-material","关联素材","add","outline")}`,L=ke(`<article class="drawer"><div class="drawer-header"><span class="page-logo">${xe("check")}</span><strong>${ae(C.name)}</strong>${_(C.status,"approved")}<span class="muted">已进行 20 天</span><div class="spacer"></div>${oe("follow",C.followed?"已关注":"关注","people",C.followed?"is-set":"")}${oe("star",C.starred?"已收藏":"收藏","book",C.starred?"is-set":"")}${oe("detail-more","","more")}${oe("close-overlay","","close","outline")}</div><div class="detail-navigation">${oe("prev-item","","up")}${oe("next-item","","down")}</div><div class="detail-tabs">${["基本信息","素材管理","评论/备注","操作记录"].map(D=>`<button data-detail-tab="${D}" class="detail-tab ${D===b?"active":""}">${D}</button>`).join("")}<div class="spacer"></div>${Q(C.owner)}${oe("detail-status",C.status,"down","primary")}</div><div class="drawer-body">${M}</div><form class="comment-form"><span class="avatar">体验官</span><textarea aria-label="评论" placeholder="请输入评论(Enter 换行,⌘ + Enter 发送)"></textarea><button type="submit">发送</button></form></article>`,"detail-overlay");A=C,j=C,ei(L,C,s.detailForm.fields,"detail"),ve();for(const[D,k]of[["roles",s.detailForm.showRoles],["meetings",s.detailForm.showMeetings],["approval",s.detailForm.showApproval],["votes",s.detailForm.showVotes]])k||(H=L.querySelector(`[data-block="${D}"]`))==null||H.remove();L.onchange=D=>{var I;const k=D.target;if(k.dataset.detail){const G=s.detailForm.fields.find(V=>V.field===k.dataset.detail);if(G&&!(G.editable??((I=f(G.field))==null?void 0:I.editable)!==!1))return;if(k.dataset.detail==="name"&&!k.value.trim()){k.value=C.name;return}be(C,k.dataset.detail,k.value)}},h("form",L).onsubmit=D=>{D.preventDefault();const k=h("textarea",h("form",L)).value.trim();k&&(C.comments.push(k),q(),Ie(C,"评论/备注"),me("评论已添加到本地 demo"))},h("form textarea",L).onkeydown=D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)&&(D.preventDefault(),h("form",L).requestSubmit())}}function St(C,b,x){return f(C.field)?`<div class="fc-host" data-control-field="${ae(C.field)}" data-control-mode="${x}"></div>`:""}function ze(C,b,x){return{field:C,value:b[C.key]??C.defaultValue??"",item:b,surface:x,readonly:C.editable===!1,openDetail:M=>{const L=c.items.find(O=>O.id===M);L?Ie(L):me("未找到关联工作项")}}}function ei(C,b,x,M){const L=[];for(const O of C.querySelectorAll("[data-control-field]")){const H=x.find(fe=>fe.field===O.dataset.controlField),D=f(H.field),k={...D,label:H.label||D.label,required:H.required??D.required,editable:D.editable!==!1&&H.editable!==!1},I=ze(k,b,M==="new"?"create":"detail"),G=e.resolve(k),V=G.createEditor(I);t.push(V),L.push({editor:V,field:k});const ee=V.element.matches("input,select,textarea,[role=textbox]")?V.element:V.element.querySelector("input,select,textarea,[role=textbox]");ee&&(ee.id=`${M}-${k.key}`);const de=document.createElement("div");de.className="fc-error",de.setAttribute("role","status");const se=document.createElement("div");se.className="fc-detail-editor",se.append(V.element,de),O.append(se);let he;M==="detail"&&(O.classList.add("fc-detail-host"),he=document.createElement("div"),he.className="fc-detail-preview",O.prepend(he));const ge=()=>{if(he&&(he.replaceChildren(G.render(ze(k,b,"detail"))),k.editable)){const fe=document.createElement("button");fe.type="button",fe.className="fc-detail-edit",fe.textContent="编辑",fe.ariaLabel=`编辑${k.label}`,fe.onclick=et=>{var Ye;et.stopPropagation(),O.classList.add("editing"),(Ye=V.focus)==null||Ye.call(V)},he.append(fe)}};ge();const Le=()=>{var et;if(!k.editable)return!0;const fe=(et=V.validate)==null?void 0:et.call(V);if(de.textContent=fe||"",!fe&&M==="detail"){const Ye=V.read();JSON.stringify(b[k.key])!==JSON.stringify(Ye)&&be(b,k.key,Ye),ge()}return!fe};if(M==="detail"&&k.editable){const fe=document.createElement("button");fe.type="button",fe.className="fc-detail-done",fe.textContent="完成",fe.onclick=et=>{et.stopPropagation(),Le()&&O.classList.remove("editing")},se.append(fe)}O.addEventListener("change",Le),O.addEventListener("focusout",()=>{queueMicrotask(()=>{O.isConnected&&!O.contains(document.activeElement)&&Le()&&O.classList.remove("editing")})})}return()=>{var O,H;for(const{editor:D,field:k}of L){if(!k.editable)continue;const I=(O=D.validate)==null?void 0:O.call(D);if(I)return me(`${k.label}:${I}`),(H=D.focus)==null||H.call(D),!1}for(const{editor:D,field:k}of L)k.editable&&(b[k.key]=D.read());return!0}}function pt(C,b,x){var G;o==null||o(),ce();const M=C.closest(".ag-cell")||C,L=[...M.childNodes],O=e.resolve(b).createEditor(ze(b,x,"cell")),H=document.createElement("div");H.className="fc-inline-error",H.setAttribute("role","status");const D=document.createElement("div");D.className="fc-inline-editor",D.append(O.element,H),M.replaceChildren(D),M.classList.add("fc-inline-editing");let k=!1;const I=V=>{var de,se;if(k)return;if(V){const he=(de=O.validate)==null?void 0:de.call(O);if(he){H.textContent=he,O.element.setAttribute("aria-invalid","true");return}}const ee=V?O.read():void 0;k=!0,o=null,(se=O.destroy)==null||se.call(O),M.classList.remove("fc-inline-editing"),M.replaceChildren(...L),V&&x[b.key]!==ee&&be(x,b.key,ee)};o=()=>I(!1),D.addEventListener("keydown",V=>{(V.key==="Enter"||V.key==="Escape")&&(V.preventDefault(),V.stopPropagation(),I(V.key==="Enter"))}),D.addEventListener("focusout",V=>{D.contains(V.relatedTarget)||I(!0)}),D.addEventListener("click",V=>V.stopPropagation()),(G=O.focus)==null||G.call(O),O.element instanceof HTMLInputElement&&O.element.select()}function xt(C,b,x){var G;const M=e.resolve(b),L=M.id==="select"||M.id==="multiSelect",O=M.id==="dateTime",H=M.id==="richText",D=Ne(C,L||O||H?"":b.label,'<div class="fc-editor-host"></div><div class="fc-error" role="status"></div>'+(L||H?"":'<div class="actions"><button type="button" class="fc-cancel">取消</button><button type="button" class="primary fc-save">保存</button></div>'),H?240:L?272:320,H?"fc-popup fc-rich-popup":L?"fc-popup fc-choice-popup":"fc-popup");if(L||H){const V=C.getBoundingClientRect();D.style.top=`${Math.max(8,Math.min(V.top,innerHeight-360))}px`}const k=M.createEditor(ze(b,x,"cell"));i=k,h(".fc-editor-host",D).append(k.element);const I=(V=!0)=>{var se;const ee=(se=k.validate)==null?void 0:se.call(k);if(h(".fc-error",D).textContent=ee||"",ee)return;const de=k.read();V&&ce(),be(x,b.key,de)};H?n=()=>{var de;const V=(de=k.validate)==null?void 0:de.call(k);if(h(".fc-error",D).textContent=V||"",V)return!1;const ee=k.read();return x[b.key]!==ee&&be(x,b.key,ee),!0}:L?k.element.addEventListener("change",()=>I(M.id==="select")):(h(".fc-cancel",D).onclick=()=>ce(!1),h(".fc-save",D).onclick=()=>I(),D.addEventListener("keydown",V=>{V.key==="Enter"&&(V.ctrlKey||V.metaKey||V.target instanceof HTMLInputElement)&&(V.preventDefault(),I())})),(G=k.focus)==null||G.call(k)}function $t(C="text"){var G;const b=e.list(),x=b.find(V=>V.id===C)||b[0],M=ke(`<section class="control-manager"><header><div><h2>控件管理</h2><p>统一管理字段的展示和编辑方式</p></div>${oe("close-overlay","关闭","close")}</header><div class="control-manager-body"><nav>${b.map(V=>`<button type="button" data-control-id="${ae(V.id)}" class="${V.id===x.id?"active":""}"><span>${ae(V.glyph)}</span>${ae(V.label)}</button>`).join("")}</nav><main><h3>${ae(x.label)}</h3><p>${ae(x.description)}</p><div class="fc-preview-grid"><section><h4>表格单元格</h4><div class="fc-preview-cell"></div><p class="hint">双击或点击编辑</p></section><section><h4>详情页</h4><div class="fc-preview-detail"></div></section></div><div class="fc-preview-edit"></div><div class="fc-error" role="status"></div><div class="actions"><button type="button" class="primary fc-preview-save">应用预览</button></div><p class="hint">在字段类型中选择控件。自定义控件通过 controls 配置或 registerControl() 注册,两处共用同一套展示与编辑接口。</p></main></div></section>`),L={key:"preview",label:x.label,kind:x.id,options:["待开始","进行中","已完成"],editable:!0},O={...c.items[0],preview:x.id==="number"?128:x.id==="multiSelect"?["进行中"]:x.id==="select"?"进行中":x.id==="dateTime"?"2026-09-23T10:30":x.id==="detail"?((G=c.items[0])==null?void 0:G.id)||"":"内容示例"};let H,D=x.createEditor(ze(L,O,"detail"));t.push(D),h(".fc-preview-detail",M).append(D.element);const k=()=>{const V=h(".fc-preview-cell",M);V.replaceChildren(x.render(ze(L,O,"cell")));const ee=document.createElement("button");ee.type="button",ee.textContent="编辑",ee.onclick=I,V.append(ee),V.ondblclick=I},I=()=>{var ee,de;(ee=H==null?void 0:H.destroy)==null||ee.call(H),H=x.createEditor(ze(L,O,"cell")),h(x.id==="text"?".fc-preview-cell":".fc-preview-edit",M).replaceChildren(H.element),(de=H.focus)==null||de.call(H)};t.push({element:M,read:()=>{},destroy:()=>{var V;return(V=H==null?void 0:H.destroy)==null?void 0:V.call(H)}}),k(),h(".fc-preview-save",M).onclick=()=>{var se,he,ge;const V=H||D,ee=(se=V.validate)==null?void 0:se.call(V);if(h(".fc-error",M).textContent=ee||"",ee)return;O.preview=V.read(),k(),(he=D.destroy)==null||he.call(D);const de=x.createEditor(ze(L,O,"detail"));t.splice(t.indexOf(D),1,de),h(".fc-preview-detail",M).replaceChildren(de.element),D=de,(ge=H==null?void 0:H.destroy)==null||ge.call(H),H=void 0,h(".fc-preview-edit",M).replaceChildren()},M.querySelectorAll("[data-control-id]").forEach(V=>V.onclick=()=>$t(V.dataset.controlId))}function We(){return{id:crypto.randomUUID(),name:"",description:"",source:"",status:"入库",category:"",format:"",approved:"",selectedTopic:"",created:new Date().toISOString().slice(0,10),vote:"",showVotes:"",owner:s.currentUser,creator:s.currentUser,space:s.workspace,followed:!1,starred:!1,viewed:!1,comments:[],history:[],roles:[],meetings:[],...Object.fromEntries(s.fields.filter(C=>C.defaultValue!==void 0).map(C=>[C.key,C.defaultValue]))}}function st(C){if(s.canCreate===!1)return;if(s.onCreate){ce(!1),s.onCreate();return}const b=C?structuredClone(C):We(),x=ke(`<form class="create-dialog"><div class="drawer-header"><span class="page-logo">${xe("check")}</span><strong>${ae(s.title)}</strong><div class="spacer"></div>${oe("drafts","草稿箱","inbox","outline")}${oe("close-overlay","","close")}</div><div class="create-body"><div class="simple-mode"><label><input type="checkbox" id="simple-mode">简洁模式</label></div>${s.createForm.fields.map(L=>{var O,H,D;return`<div class="create-field ${((O=f(L.field))==null?void 0:O.kind)==="longText"?"extended-field":""}"><label for="new-${L.field}">${ae(L.label||((H=f(L.field))==null?void 0:H.label)||L.field)} ${L.required??((D=f(L.field))==null?void 0:D.required)?"<em>*</em>":""}</label>${St(L,b,"new")}</div>`}).join("")}${s.createForm.showRoles?`<div class="create-field extended-field"><label>角色与人员</label><div><div class="role-line">${ht([["提报人","提报人"]],"提报人",'aria-label="角色"')}<div class="role-person">${Q(s.currentUser)}</div></div>${oe("add-role","添加角色","","outline")}<div class="extra-roles"></div></div></div>`:""}${s.createForm.showMeetings?`<section class="detail-section extended-field"><p>进入选题会</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${oe("add-meeting","添加一组进入选题会","add")}</div></section>`:""}</div><div class="drawer-footer"><label class="continuous"><input id="continuous" type="checkbox">连续创建</label>${oe("close-overlay","取消","","outline")}${oe("save-draft","存草稿","","outline")}<button type="submit" class="primary">确认创建</button></div></form>`);j=b,ve();const M=ei(x,b,s.createForm.fields,"new");h("#simple-mode",x).onchange=L=>x.querySelectorAll(".extended-field").forEach(O=>O.classList.toggle("hidden",L.target.checked)),h('[data-action="save-draft"]',x).onclick=()=>{if(!M())return;const L=c.drafts.findIndex(O=>O.id===b.id);L>=0?c.drafts[L]=b:c.drafts.push(b),q(),Te(),me("已存入草稿箱")},h("form",x).onsubmit=L=>{if(L.preventDefault(),!M())return;if(!b.name.trim()){h("#new-name",x).focus();return}const O=h("#continuous",x).checked;c.items.unshift(b),c.drafts=c.drafts.filter(H=>H.id!==b.id),q(),te(),Te(),me("创建成功"),O&&(st(),h("#continuous").checked=!0)}}function ve(){if(!P||!j)return;const C=j;for(const[b,x]of[["roles",".extra-roles"],["meetings",".meeting-rows"]]){const M=P.querySelector(x);if(!M)continue;const L=C[b]||[];M.innerHTML=L.map((O,H)=>`<div class="role-line"><input data-relation-index="${H}" data-relation-field="name" aria-label="${b==="roles"?"角色名称":"选题会"}" placeholder="${b==="roles"?"角色名称":"选择选题会"}" value="${ae(O.name)}"><input data-relation-index="${H}" data-relation-field="person" aria-label="人员" value="${ae(O.person)}"><button type="button" data-relation-remove="${H}" aria-label="移除">×</button></div>`).join(""),M.onchange=O=>{const H=O.target,D=Number(H.dataset.relationIndex);H.dataset.relationField&&(L[D][H.dataset.relationField]=H.value,A&&q())},M.onclick=O=>{const H=O.target.closest("[data-relation-remove]");H&&(L.splice(Number(H.dataset.relationRemove),1),ve(),A&&q())}}}function at(C){if(s.onSaveView){s.onSaveView({...structuredClone(p),columns:$.columnApi.getColumnState()});return}const b=Ne(C,"存为视图",`<form class="save-view-form"><label>视图名称 <em>*</em></label><input name="name" value="未命名视图" placeholder="请输入视图名称" required><label>协作者</label><input name="collaborators" placeholder="搜索人员" aria-label="协作者"><label>可见范围</label><label><input type="radio" name="visibility" value="public" checked>公开 <small>空间内所有成员可见</small></label><label><input type="radio" name="visibility" value="members">指定成员 <small>协作者、管理员和指定成员可见</small></label><div class="actions"><button type="submit" class="primary">保存</button>${oe("close-popup","取消","","outline")}</div></form>`,380);h("form",b).onsubmit=x=>{x.preventDefault();const M=h('input[name="name"]',b).value.trim();M&&(c.views.push({name:M,state:structuredClone(p),columns:$.columnApi.getColumnState(),gridState:$.api.getState(),tab:m,search:y,filterSearch:E,collaborators:h('[name="collaborators"]',b).value,visibility:h('[name="visibility"]:checked',b).value}),q(),lt(),ce(),me("视图已保存"))}}function lt(){h('[data-action="saved-views"]').classList.toggle("hidden",s.showSavedViews===!1||!c.views.length)}document.addEventListener("contextmenu",C=>{if(!s.container.contains(C.target))return;const b=C.target.closest("[data-view]");if(!b)return;C.preventDefault();const x=Number(b.dataset.view),M=c.views[x],L=Ne(b,M.name,'<button class="menu-option" data-view-menu="rename">重命名</button><button class="menu-option" data-view-menu="duplicate">复制视图</button><button class="menu-option" data-view-menu="remove">删除视图</button>',220);L.onclick=O=>{var D;const H=(D=O.target.closest("[data-view-menu]"))==null?void 0:D.dataset.viewMenu;if(H){if(ce(),H==="rename"&&Be("重命名视图",M.name,k=>{M.name=k,q(),lt()}),H==="duplicate"){const k=structuredClone(M);k.name+="(副本)",c.views.push(k),q(),lt()}H==="remove"&&(c.views.splice(x,1),q(),lt(),me("视图已删除"))}}},{signal:r.signal});function Ue(C,b,x,M){const L=f(b);if(L){if(L.editable===!1){me("系统字段,不支持修改");return}if(L.kind==="vote"){be(x,b,x[b]?"":s.currentUser);return}["text","number"].includes(e.resolve(L).id)?pt(C,L,x):xt(C,L,x)}}h("#grid").addEventListener("keydown",C=>{if(!["Enter","F2"].includes(C.key)||C.target.closest("button,input,textarea,select"))return;const b=C.target.closest(".ag-cell[data-colid]"),x=b==null?void 0:b.closest("[data-rowid]"),M=c.items.find(L=>L.id===(x==null?void 0:x.dataset.rowid));b&&M&&(C.preventDefault(),Ue(b,b.dataset.colid,M))},{capture:!0,signal:r.signal});function rt(){h("#grid").querySelectorAll(".ag-header-cell").forEach(C=>{var O,H;const b=C.dataset.colid;if(b==="_add"){if(!C.querySelector(".work-add-column")){const D=C.querySelector(".ag-header-cell-label"),k=document.createElement("button");k.type="button",k.className="work-add-column",k.ariaLabel="新增字段",k.title="新增字段",k.innerHTML=xe("add"),k.onmousedown=I=>I.stopPropagation(),k.onclick=I=>{I.stopPropagation(),gt(k,"_add",!1)},D.replaceChildren(k)}return}if(!f(b))return;if(!C.querySelector(".work-header-sort")){const D=document.createElement("span");D.className="work-header-sort",(O=C.querySelector(".ag-header-cell-label"))==null||O.append(D);const k=document.createElement("button");k.className="work-header-menu",k.ariaLabel=`${f(b).label}操作`,k.innerHTML=xe("more"),k.onclick=G=>{G.stopPropagation(),Ve(k,b)},k.onmousedown=G=>G.stopPropagation(),C.append(k);for(const G of["right","left"]){const V=document.createElement("button");V.className="work-header-add",V.dataset.insertSide=G,V.ariaLabel=`在${f(b).label}${G==="right"?"右":"左"}侧插入列`,V.title="插入列",V.innerHTML=xe("add"),V.onclick=ee=>{ee.stopPropagation(),gt(V,b,G==="right")},V.onmousedown=ee=>ee.stopPropagation(),C.append(V)}const I=()=>{const G=C.getBoundingClientRect(),V=h(".grid-wrap").getBoundingClientRect(),de=C.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();C.querySelectorAll(".work-header-add").forEach(se=>{const he=se.dataset.insertSide==="left"?G.left:G.right;se.style.left=`${he-12}px`,se.style.top=`${G.top-20}px`,se.style.setProperty("--insert-line-height",`${Math.max(0,V.bottom-G.top+8)}px`),se.style.display=he<Math.max(V.left,de.left)-1||he>Math.min(V.right,de.right)+1?"none":""}),C.classList.add("insert-points-ready")};C.addEventListener("mouseenter",I),C.addEventListener("focusin",I),C.addEventListener("click",G=>{var ee;if(G.target.closest("button,.ag-header-cell-resize"))return;G.stopImmediatePropagation();const V=(ee=p.sorts.find(de=>de.colId===b))==null?void 0:ee.sort;p.sorts=V==="desc"?[]:[{colId:b,sort:V==="asc"?"desc":"asc"}],te()},{capture:!0})}const x=(H=p.sorts.find(D=>D.colId===b))==null?void 0:H.sort,M=C.querySelector(".work-header-sort"),L=x==="asc"?"↑":x==="desc"?"↓":"↕";M.textContent!==L&&(M.textContent=L),M.classList.toggle("sorted",!!x),C.setAttribute("aria-sort",x==="asc"?"ascending":x==="desc"?"descending":"none")})}function gt(C,b,x){ce();const M=O=>{var k;const D=$.columnApi.getColumnState().findIndex(I=>I.colId===b)+(x?1:0);$.columnApi.setColumnVisible(O,!0),$.columnApi.setColumnPinned(O,b==="_add"?null:((k=$.columnApi.getColumn(b))==null?void 0:k.pinned)??null),$.columnApi.moveColumn(O,Math.max(1,D)),ce(),J(),rt()};ot(C,M,{available:O=>{var H;return!((H=$.columnApi.getColumn(O))!=null&&H.visible)},onCreate:()=>{const O=Ne(C,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${e.list().map(H=>`<option value="${ae(H.id)}">${ae(H.label)}</option>`).join("")}<option value="person">人员</option><option value="relation">关联</option></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);h('[name="kind"]',O).onchange=H=>{h(".choice-limit",O).classList.toggle("hidden",H.target.value!=="multiSelect")},h("form",O).onsubmit=H=>{H.preventDefault();const D=new FormData(H.target),k=String(D.get("label")||"").trim();if(!k)return;const I=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,G=String(D.get("kind")),V={key:I,label:k,kind:G,editable:!0,width:160};["select","multiSelect","person"].includes(G)&&(V.options=[...new Set(String(D.get("options")||"").split(`
120
+ `).map(se=>se.trim()).filter(Boolean))]);const ee=Number(D.get("maxSelections"));G==="multiSelect"&&Number.isInteger(ee)&&ee>0&&(V.maxSelections=ee),s.fields.push(V),u.push([I,k]),V.options&&(g[I]=V.options),c.customFields.push(V);const de=$.columnApi.getColumnState();$.api.setColumnDefs(U()),$.columnApi.applyColumnState(de,!0),M(I),q(),te()}}})}function Ve(C,b){const x=$.columnApi.getColumn(b);if(!x||b==="_select")return;if(b==="_add"){gt(C,b,!1);return}const M=["向左插入列","向右插入列",g[b]?"以 首项 → 末项 排序":"以 A → Z 排序",g[b]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",x.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],L=Ne(C,"",[[0,1],[2,3],[4,8],[5,6,7]].map(O=>O.map(H=>`<button class="menu-option${H===7?" destructive":""}" data-col-menu="${H}" ${H===7&&b==="name"?"disabled":""}>${M[H]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");L.dataset.headerMenu="true",L.onclick=O=>{const H=O.target.closest("[data-col-menu]");if(!H)return;const D=+H.dataset.colMenu;ce(),(D===0||D===1)&&gt(C,b,D===1),(D===2||D===3)&&(p.sorts=[{colId:b,sort:D===2?"asc":"desc"}],te()),D===4&&(p.filters.push({field:b,operator:"contains",value:""}),X("filter",h('[data-action="filter"]'))),D===5&&$.columnApi.setColumnPinned(b,x.pinned?null:"left"),D===6&&Be("编辑列",x.headerName,k=>{const I=f(b);I&&(I.label=k);const G=$.api.getColumnDefs(),V=G.find(de=>de.field===b);V&&(V.headerName=k);const ee=$.columnApi.getColumnState();$.api.setColumnDefs(G),$.columnApi.applyColumnState(ee,!0),rt()}),D===7&&$.columnApi.setColumnVisible(b,!1),D===8&&(p.groups.includes(b)||p.groups.push(b),te())}}h("#grid").addEventListener("contextmenu",C=>{const b=C.target.closest(".ag-header-cell");if(b){C.preventDefault();const x=b.getAttribute("col-id")||b.dataset.colid||b.dataset.colId||"";Ve(b,x)}else{const x=C.target.closest(".ag-cell");if(x){C.preventDefault();const M=Ne(x,"单元格",oe("copy-cell","复制")+oe("paste-cell","粘贴")+oe("export","导出表格"),200);h('[data-action="copy-cell"]',M).onclick=async()=>{try{await navigator.clipboard.writeText(x.textContent||""),me("已复制")}catch{me("复制失败,请使用 ⌘C")}ce()}}}}),h("#grid").addEventListener("dblclick",C=>{var H;const b=C.target.closest(".ag-cell");if(!b||C.target.closest("input,textarea,select,.ag-cell-edit-input"))return;const x=b.dataset.colid,M=c.items.find(D=>{var k;return D.id===((k=b.closest(".ag-row"))==null?void 0:k.dataset.rowid)});if(!M||!f(x))return;clearTimeout(F),C.stopImmediatePropagation(),C.preventDefault();const L=$.api.getDisplayedRowCount();let O=0;for(;O<L&&((H=$.api.getDisplayedRowAtIndex(O))==null?void 0:H.id)!==M.id;O++);Ue(b,x,M)},{capture:!0,signal:r.signal}),document.addEventListener("click",C=>{s.container.querySelectorAll(".field-picker").forEach(b=>{b.contains(C.target)||b.remove()}),h("#grid").contains(C.target)||($.api.getCellRanges().length&&$.api.clearRangeSelection(),$.api.getFocusedCell()&&$.api.clearFocusedCell()),(S==null?void 0:S.dataset.headerMenu)==="true"&&!S.contains(C.target)&&ce()},{capture:!0,signal:r.signal}),document.addEventListener("click",async C=>{const b=C.target,x=k=>C.composedPath().some(I=>I instanceof Element&&I.matches(k));if(!C.composedPath().includes(s.container)){ce();return}x(".popup,.field-picker,.toolbar,.ag-cell,.ag-header-cell,.list-bottom,.create-button")||ce();const M=b.closest("[data-tab]");if(M){m=M.dataset.tab,s.container.querySelectorAll("[data-tab]").forEach(k=>{k.classList.toggle("active",k===M),k.setAttribute("aria-selected",String(k===M))}),te();return}const L=b.closest("[data-view]");if(L){const k=c.views[+L.dataset.view];p=structuredClone(k.state),m=k.tab||"全部",y=k.search||"",E=!!k.filterSearch,s.container.querySelectorAll("[data-tab]").forEach(I=>{I.classList.toggle("active",I.dataset.tab===m),I.setAttribute("aria-selected",String(I.dataset.tab===m))}),h("#search").value=y,h("#filter-search").checked=E,h(".search-wrap").classList.toggle("hidden",!y),h('[data-action="search"]').classList.toggle("hidden",!!y),ce(),te(),k.gridState?$.api.setState(k.gridState):k.columns&&$.columnApi.applyColumnState(k.columns,!0),Y();return}const O=b.closest("[data-detail-tab]");if(O&&A){Ie(A,O.dataset.detailTab);return}const H=b.closest("[data-action]");if(!H)return;const D=H.dataset.action;if(["filter","sort","group","color"].includes(D)){N===D?ce():X(D,H);return}switch(D){case"controls":if(s.allowCustomFields===!1)break;$t();break;case"close-popup":ce();break;case"create":st();break;case"create-menu":if(s.canCreate===!1)break;if(s.onCreate){st();break}Ne(H,"新建",oe("create","新建选题","plus","menu-option")+oe("drafts","草稿箱","inbox","menu-option"),180);break;case"drafts":{const k=ke(`<section class="dialog"><h2>草稿箱</h2>${c.drafts.length?c.drafts.map((I,G)=>`<button class="menu-option" data-draft="${G}">${ae(I.name||"未命名选题")}</button>`).join(""):'<p class="muted">暂无草稿</p>'}<div class="actions">${oe("close-overlay","关闭","","outline")}</div></section>`);k.onclick=I=>{const G=I.target.closest("[data-draft]");G&&st(c.drafts[+G.dataset.draft])};break}case"close-overlay":Te();break;case"search":h(".search-wrap").classList.remove("hidden"),H.classList.add("hidden"),h("#search").focus();break;case"close-search":y="",E=!1,h("#search").value="",h("#filter-search").checked=!1,h(".search-wrap").classList.add("hidden"),h('[data-action="search"]').classList.remove("hidden"),te();break;case"previous-match":R--,Y();break;case"next-match":R++,Y();break;case"reset":p=yn(),te(),ce();break;case"columns":case"layout":pe(H);break;case"save-view":case"pin-view":at(H);break;case"saved-views":Ne(H,"切换视图",c.views.map((k,I)=>`<button class="menu-option" data-view="${I}">${xe("table")}<span>${ae(k.name)}</span></button>`).join(""),260);break;case"share":{const k=Ne(H,"分享工作项列表",`<input readonly value="${ae(location.href.split("#")[0])}" aria-label="分享链接"><p class="hint">复制此 demo 的访问地址</p><button class="primary" id="copy-link">复制链接</button>`,380);h("#copy-link",k).onclick=async()=>{try{await navigator.clipboard.writeText(location.href.split("#")[0]),me("链接已复制"),ce()}catch{h("input",k).select(),me("请按 ⌘C 复制链接")}};break}case"deselect":$.api.deselectAll();break;case"batch-status":case"batch-owner":{const k=D==="batch-status"?"status":"owner",I=$.api.getSelectedRows(),G=Ne(H,"批量更新",g[k].map(V=>`<button class="menu-option" data-batch-value="${V}">${V}</button>`).join(""),220);G.onclick=V=>{const ee=V.target.closest("[data-batch-value]");ee&&(I.forEach(de=>{de[k]=ee.dataset.batchValue,de.history.push(`批量更新${k}:${de[k]}`)}),q(),te(),ce(),me(`已更新 ${I.length} 项`))};break}case"batch-archive":{const k=$.api.getSelectedRows();k.forEach(I=>I.status="已终止"),q(),te(),me(`已终止 ${k.length} 项,可在筛选中显示`);break}case"batch-export":$.api.exportToCsv({fileName:"选题库.csv",onlySelected:!0,columnKeys:u.map(([k])=>k)});break;case"export":$.api.exportToCsv({fileName:"选题库.csv",columnKeys:u.map(([k])=>k)}),ce();break;case"paste-cell":$.api.pasteFromClipboard(),ce();break;case"follow":A&&(A.followed=!A.followed,q(),Ie(A,W));break;case"star":A&&(A.starred=!A.starred,q(),Ie(A,W));break;case"detail-vote":A&&(be(A,"vote",A.vote?"":"体验官"),Ie(A));break;case"detail-status":A&&Zt(H,"status",A);break;case"prev-item":case"next-item":if(A){const k=c.items.indexOf(A)+(D==="prev-item"?-1:1);c.items[k]&&Ie(c.items[k],W)}break;case"detail-more":Ne(H,"更多操作",oe("duplicate","复制工作项","","menu-option")+oe("terminate-item","终止工作项","","menu-option"),220);break;case"duplicate":if(A){const k=structuredClone(A);k.id=crypto.randomUUID(),k.name+="(副本)",k.comments=[],k.history=[],c.items.unshift(k),q(),te(),Ie(k)}break;case"terminate-item":A&&(be(A,"status","已终止"),Te(),me("工作项已终止"));break;case"add-role":j&&(j.roles??(j.roles=[]),j.roles.push({name:"",person:s.currentUser}),ve(),A&&q());break;case"add-meeting":j&&(j.meetings??(j.meetings=[]),j.meetings.push({name:"",person:s.currentUser}),ve(),A&&q());break;case"link-material":{const k=A;k&&Be("关联素材","",I=>{k.materials??(k.materials=[]),k.materials.push(I),k.history.push(`关联素材:${I}`),q(),Ie(k,"素材管理")});break}}},{signal:r.signal}),h("#search").oninput=C=>{y=C.target.value,R=0,E?te():Y()},h("#filter-search").onchange=C=>{E=C.target.checked,te()},document.addEventListener("keydown",C=>{if(s.container.contains(C.target)&&(C.key==="Escape"&&(s.container.querySelector(".field-picker")?s.container.querySelectorAll(".field-picker").forEach(b=>b.remove()):S?ce(!1):P&&Te()),C.key==="Tab"&&P)){const b=[...P.querySelectorAll('button:not([disabled]),input,select,textarea,[tabindex="0"]')].filter(L=>L.offsetParent!==null),x=b[0],M=b[b.length-1];C.shiftKey&&document.activeElement===x?(C.preventDefault(),M==null||M.focus()):!C.shiftKey&&document.activeElement===M&&(C.preventDefault(),x==null||x.focus())}},{signal:r.signal}),window.addEventListener("pagehide",()=>$.grid.destroy(),{once:!0,signal:r.signal});const Ee=h("#grid .ag-body-viewport"),ct=h(".grid-wrap"),_e=document.createElement("div");_e.className="work-horizontal-scrollbar",_e.setAttribute("aria-label","横向滚动表格");const En=document.createElement("div");_e.append(En),ct.append(_e);const qe=document.createElement("div");qe.className="work-vertical-scrollbar",qe.setAttribute("aria-label","纵向滚动表格");const Rn=document.createElement("div");qe.append(Rn),ct.append(qe);const Mn=()=>{const C=Ee.getBoundingClientRect(),b=ct.getBoundingClientRect();_e.style.left=`${C.left-b.left-1}px`,_e.style.width=`${Ee.clientWidth}px`,En.style.width=`${Ee.scrollWidth}px`,_e.hidden=Ee.scrollWidth<=Ee.clientWidth,_e.scrollLeft=Ee.scrollLeft,qe.style.top=`${C.top-b.top-1}px`,qe.style.height=`${Ee.clientHeight}px`,Rn.style.height=`${Ee.scrollHeight}px`,qe.hidden=Ee.scrollHeight<=Ee.clientHeight,qe.scrollTop=Ee.scrollTop};_e.addEventListener("scroll",()=>{$.grid.setHorizontalScrollLeft(_e.scrollLeft)},{passive:!0,signal:r.signal}),qe.addEventListener("scroll",()=>{Ee.scrollTop=qe.scrollTop},{passive:!0,signal:r.signal});let Ei=0;Ee.addEventListener("pointermove",C=>{const b=Ee.getBoundingClientRect();Ee.classList.toggle("scrollbar-near-right",b.right-C.clientX<=16),Ee.classList.toggle("scrollbar-near-bottom",b.bottom-C.clientY<=16),ct.classList.toggle("scrollbar-near-right",b.right-C.clientX<=16),ct.classList.toggle("scrollbar-near-bottom",b.bottom-C.clientY<=16)},{signal:r.signal}),Ee.addEventListener("pointerleave",()=>{Ee.classList.remove("scrollbar-near-right","scrollbar-near-bottom"),ct.classList.remove("scrollbar-near-right","scrollbar-near-bottom")},{signal:r.signal}),Ee.addEventListener("scroll",()=>{Ee.classList.add("scrollbar-scrolling"),ct.classList.add("scrollbar-scrolling"),_e.scrollLeft=Ee.scrollLeft,qe.scrollTop=Ee.scrollTop,clearTimeout(Ei),Ei=window.setTimeout(()=>{Ee.classList.remove("scrollbar-scrolling"),ct.classList.remove("scrollbar-scrolling")},900)},{passive:!0,signal:r.signal});const kn=()=>{h("#grid").querySelectorAll(".insert-points-ready").forEach(C=>C.classList.remove("insert-points-ready"))};window.addEventListener("scroll",kn,{capture:!0,signal:r.signal}),window.addEventListener("resize",kn,{signal:r.signal});const ft=new ResizeObserver(()=>{J(),Mn()});ft.observe(h(".list-area")),ft.observe(h(".toolbar")),ft.observe(h(".list-tabs")),ft.observe(h(".ag-header-wrapper")),ft.observe(Ee),ft.observe(h(".ag-body-container")),Mn();const Tn=new window.MutationObserver(()=>rt());Tn.observe(h("#grid .ag-header"),{childList:!0,subtree:!0}),rt(),h('[data-action="controls"]').classList.toggle("hidden",s.allowCustomFields===!1);for(const C of["create","create-menu"])h(`[data-action="${C}"]`).disabled=s.canCreate===!1;if(lt(),s.initialView&&te(),J(),s.syncLocationHash&&location.hash.startsWith("#item/")){const C=c.items.find(b=>b.id===location.hash.slice(6));C&&Ie(C)}return{registerControl:C=>{e.register(C),$.api.refreshCells({force:!0})},getControls:()=>e.list(),api:$.api,columnApi:$.columnApi,getViewState:()=>({...structuredClone(p),columns:$.columnApi.getColumnState()}),getItems:()=>structuredClone(c.items),setItems:C=>{l||(c.items=structuredClone(C),te())},destroy:()=>{l=!0,o==null||o(),Tn.disconnect(),ft.disconnect(),r.abort(),clearTimeout(T),clearTimeout(F),clearTimeout(Ei),ce(),Te(),$.grid.destroy(),s.container.replaceChildren(),s.container.classList.remove("rowvia-work-items")}}}const ua={name:"title",description:"longText",vote:"vote",showVotes:"select",status:"status",selectedTopic:"relation",format:"multiSelect",approved:"select",category:"select",owner:"person",space:"text",created:"date",creator:"person",source:"longText"};function xn(s){return{container:s,title:"选题库",workspace:"内容制作全流程",currentUser:"体验官",storageKey:"rowvia:work-items:v3",items:Jt,fields:[...na.map(([e,t])=>({key:e,label:t,kind:ua[e],width:120,minWidth:80,pinned:e==="name"?"left":null,editable:!["created","creator","space"].includes(e),required:e==="name",options:oa[e]})),{key:"source",label:"参考来源",kind:"longText",hidden:!0,editable:!0}],createForm:{fields:["name","category","format","source","description"].map(e=>({field:e})),showRoles:!0,showMeetings:!0},detailForm:{fields:["name","description","category","format","source"].map(e=>({field:e})),showRoles:!0,showMeetings:!0,showApproval:!0,showVotes:!0}}}function ha(s){const e=xn(s);e.storageKey="rowvia:work-items:date-1000:v1";const t=[{key:"singleDate",label:"单日期",kind:"date",width:150,editable:!0,dateOptions:{showTime:!1,showRange:!1}},{key:"dateTime",label:"日期时间",kind:"dateTime",width:190,editable:!0,dateOptions:{showTime:!0,showRange:!1}},{key:"dateRange",label:"日期范围",kind:"date",width:260,editable:!0,dateOptions:{showTime:!1,showRange:!0}}];e.fields.splice(1,0,...t),e.createForm.fields.push(...t.map(({key:n})=>({field:n}))),e.detailForm.fields.push(...t.map(({key:n})=>({field:n})));const i=n=>new Date(Date.UTC(2024,0,1+n)).toISOString().slice(0,10);return e.items=Array.from({length:1e3},(n,o)=>{const a=structuredClone(Jt[o%Jt.length]),r=i(o);return{...a,id:`date-demo-${String(o+1).padStart(4,"0")}`,name:`${a.name} · ${String(o+1).padStart(4,"0")}`,singleDate:r,dateTime:`${r}T${String(o%24).padStart(2,"0")}:${String(o%60).padStart(2,"0")}`,dateRange:[r,i(o+o%15)]}}),e}function xi(s,e){const t=new Ct(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function pa(s,e){zt[s]=e}function ga(s,e){it[s]=e}le.CELL_EDITORS=it,le.CELL_RENDERERS=zt,le.DEFAULT_LOCALE_TEXT=Hi,le.FORMULA_FUNCTIONS=Ht,le.GANTT_UNITS=Qi,le.GanttChart=en,le.Grid=Ct,le.UNIT_LABEL=Ut,le.computeStickyGroupRows=Vi,le.createControlRegistry=wn,le.createDetailDialog=Xi,le.createFinancePage=Os,le.createGantt=Es,le.createGrid=xi,le.createHrPage=Bs,le.createInventoryPage=_s,le.createPerformancePage=Qs,le.createPersonnelSchedule=Ms,le.createServerSidePage=Js,le.createSparklineSvg=si,le.createWorkItemPage=da,le.dateDemoConfig=ha,le.default=Ct,le.evaluateFormula=Mt,le.formatNumberCommas=Ke,le.isFormula=ni,le.parse=Ii,le.registerEditor=ga,le.registerFormulaFunction=Hn,le.registerRenderer=pa,le.sanitizeRichText=Ft,le.tokenize=Ti,le.topicDemoConfig=xn,Object.defineProperties(le,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});