rowvia 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +24 -8
  2. package/dist/fields.css +1 -0
  3. package/dist/fields.es.js +1913 -0
  4. package/dist/fields.umd.cjs +1 -0
  5. package/dist/rowvia.css +1 -1
  6. package/dist/rowvia.es.js +10670 -10741
  7. package/dist/rowvia.umd.cjs +84 -105
  8. package/dist/types/api.d.ts +1 -1
  9. package/dist/types/components/cells.d.ts +25 -0
  10. package/dist/types/components/detailDialog.d.ts +7 -1
  11. package/dist/types/components/scrollbars.d.ts +10 -0
  12. package/dist/types/contracts/work-item.d.ts +335 -0
  13. package/dist/types/core/clientSideRowModel.d.ts +1 -2
  14. package/dist/types/core/columnModel.d.ts +2 -2
  15. package/dist/types/core/gridHost.d.ts +365 -0
  16. package/dist/types/core/remoteRowModels.d.ts +2 -10
  17. package/dist/types/core/rowNode.d.ts +1 -2
  18. package/dist/types/core/valueService.d.ts +1 -1
  19. package/dist/types/createGrid.d.ts +10 -0
  20. package/dist/types/features/chartService.d.ts +2 -11
  21. package/dist/types/features/columnMenu.d.ts +1 -1
  22. package/dist/types/features/contextMenu.d.ts +2 -13
  23. package/dist/types/features/editService.d.ts +3 -8
  24. package/dist/types/features/exportService.d.ts +3 -2
  25. package/dist/types/features/filterGui.d.ts +1 -1
  26. package/dist/types/features/filterService.d.ts +2 -14
  27. package/dist/types/features/findService.d.ts +1 -1
  28. package/dist/types/features/formulaEditor.d.ts +1 -1
  29. package/dist/types/features/notesService.d.ts +1 -5
  30. package/dist/types/features/overlays.d.ts +1 -1
  31. package/dist/types/features/paginationService.d.ts +1 -2
  32. package/dist/types/features/popupService.d.ts +1 -1
  33. package/dist/types/features/rangeSelection.d.ts +1 -8
  34. package/dist/types/features/rowDragService.d.ts +1 -1
  35. package/dist/types/features/rowGroupPanel.d.ts +1 -1
  36. package/dist/types/features/selectionService.d.ts +1 -1
  37. package/dist/types/features/sideBar.d.ts +2 -5
  38. package/dist/types/features/sortService.d.ts +1 -1
  39. package/dist/types/features/statusBar.d.ts +2 -3
  40. package/dist/types/features/undoRedoService.d.ts +2 -9
  41. package/dist/types/fields/attachment-control.d.ts +2 -0
  42. package/dist/types/fields/base-field.d.ts +62 -0
  43. package/dist/types/{pages/work-items → fields}/cascade-control.d.ts +1 -1
  44. package/dist/types/{pages/work-items → fields}/choice-control.d.ts +2 -3
  45. package/dist/types/fields/composite-control.d.ts +3 -0
  46. package/dist/types/fields/controls.d.ts +19 -0
  47. package/dist/types/{pages/work-items → fields}/date-control.d.ts +1 -1
  48. package/dist/types/fields/field-types.d.ts +114 -0
  49. package/dist/types/fields/index.d.ts +8 -0
  50. package/dist/types/fields/internal/dom.d.ts +1 -0
  51. package/dist/types/fields/internal/focus-boundary.d.ts +7 -0
  52. package/dist/types/fields/internal/interaction.d.ts +23 -0
  53. package/dist/types/fields/internal/lifecycle.d.ts +12 -0
  54. package/dist/types/fields/internal/textarea.d.ts +1 -0
  55. package/dist/types/fields/location-control.d.ts +3 -0
  56. package/dist/types/fields/popup.d.ts +38 -0
  57. package/dist/types/{pages/work-items → fields}/rich-control.d.ts +1 -1
  58. package/dist/types/fields/text-control.d.ts +3 -0
  59. package/dist/types/fields/types.d.ts +185 -0
  60. package/dist/types/fields/value-control.d.ts +12 -0
  61. package/dist/types/fields/vote-control.d.ts +2 -0
  62. package/dist/types/forms/form-conditions.d.ts +29 -0
  63. package/dist/types/forms/form-surface.d.ts +13 -0
  64. package/dist/types/gantt/component.d.ts +5 -4
  65. package/dist/types/gantt/ganttChart.d.ts +7 -7
  66. package/dist/types/gantt/index.d.ts +3 -3
  67. package/dist/types/gantt/scale.d.ts +18 -0
  68. package/dist/types/grid.d.ts +21 -17
  69. package/dist/types/index.d.ts +19 -20
  70. package/dist/types/node-flow/canvas.d.ts +26 -0
  71. package/dist/types/node-flow/card.d.ts +23 -0
  72. package/dist/types/node-flow/cardSections.d.ts +14 -0
  73. package/dist/types/node-flow/component.d.ts +9 -0
  74. package/dist/types/node-flow/contextBar.d.ts +20 -0
  75. package/dist/types/node-flow/demo.d.ts +6 -0
  76. package/dist/types/node-flow/index.d.ts +13 -0
  77. package/dist/types/node-flow/model.d.ts +48 -0
  78. package/dist/types/node-flow/timeline.d.ts +16 -0
  79. package/dist/types/node-flow/types.d.ts +220 -0
  80. package/dist/types/personnel/component.d.ts +3 -2
  81. package/dist/types/personnel/index.d.ts +1 -1
  82. package/dist/types/personnel/render.d.ts +22 -0
  83. package/dist/types/render/headerView.d.ts +1 -1
  84. package/dist/types/render/rowComponent.d.ts +29 -0
  85. package/dist/types/render/rowContext.d.ts +39 -0
  86. package/dist/types/render/rowRenderer.d.ts +6 -73
  87. package/dist/types/shared/dom.d.ts +1 -0
  88. package/dist/types/shared/interaction.d.ts +1 -0
  89. package/dist/types/shared/lifecycle.d.ts +1 -0
  90. package/dist/types/shared/markup.d.ts +5 -0
  91. package/dist/types/shared/state.d.ts +5 -0
  92. package/dist/types/types.d.ts +3 -2
  93. package/dist/types/work-items/action-surface.d.ts +17 -0
  94. package/dist/types/work-items/detail/detail-header.d.ts +23 -0
  95. package/dist/types/work-items/fields/control-base.d.ts +17 -0
  96. package/dist/types/{pages/work-items → work-items/fields}/focus-editor.d.ts +1 -1
  97. package/dist/types/work-items/fields/registry.d.ts +5 -0
  98. package/dist/types/work-items/index.d.ts +19 -0
  99. package/dist/types/work-items/layers.d.ts +19 -0
  100. package/dist/types/work-items/model.d.ts +10 -0
  101. package/dist/types/work-items/selection-bar.d.ts +7 -0
  102. package/dist/types/work-items/style-scope.d.ts +1 -0
  103. package/dist/types/work-items/table/column-panels.d.ts +39 -0
  104. package/dist/types/work-items/table/columns.d.ts +28 -0
  105. package/dist/types/work-items/table/headers.d.ts +10 -0
  106. package/dist/types/work-items/table/table.d.ts +10 -0
  107. package/dist/types/work-items/tabs.d.ts +14 -0
  108. package/dist/types/work-items/toolbar.d.ts +11 -0
  109. package/dist/types/work-items/views/rule-panels.d.ts +28 -0
  110. package/package.json +24 -6
  111. package/dist/types/pages/finance/component.d.ts +0 -2
  112. package/dist/types/pages/finance/data.d.ts +0 -14
  113. package/dist/types/pages/hr/component.d.ts +0 -2
  114. package/dist/types/pages/hr/data.d.ts +0 -21
  115. package/dist/types/pages/index.d.ts +0 -13
  116. package/dist/types/pages/inventory/component.d.ts +0 -2
  117. package/dist/types/pages/inventory/data.d.ts +0 -26
  118. package/dist/types/pages/lifecycle.d.ts +0 -24
  119. package/dist/types/pages/performance/component.d.ts +0 -2
  120. package/dist/types/pages/performance/data.d.ts +0 -33
  121. package/dist/types/pages/server-side/component.d.ts +0 -2
  122. package/dist/types/pages/work-items/config.d.ts +0 -118
  123. package/dist/types/pages/work-items/controls.d.ts +0 -50
  124. package/dist/types/pages/work-items/field-controls.d.ts +0 -4
  125. package/dist/types/pages/work-items/model.d.ts +0 -72
  126. package/dist/types/pages/work-items/page.d.ts +0 -24
@@ -1,122 +1,101 @@
1
- (function(pe,ze){typeof exports=="object"&&typeof module<"u"?ze(exports):typeof define=="function"&&define.amd?define(["exports"],ze):(pe=typeof globalThis<"u"?globalThis:pe||self,ze(pe.Rowvia={}))})(this,function(pe){"use strict";var Ja=Object.defineProperty;var Za=(pe,ze,wt)=>ze in pe?Ja(pe,ze,{enumerable:!0,configurable:!0,writable:!0,value:wt}):pe[ze]=wt;var v=(pe,ze,wt)=>Za(pe,typeof ze!="symbol"?ze+"":ze,wt);class ze{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 wt=13,so=27,Wi=9,Ui=8,_i=46,ao=36,lo=35;function Ht(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let ro=0;function mi(s="id"){return`${s}-${++ro}`}function Qe(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 vi(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function co(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 uo(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class We extends Error{constructor(e){super(e),this.code=e}}const ho=/^\$?[A-Za-z]{1,3}\$?\d+$/;function qi(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++];ho.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 We("#NAME?")}return e}const Ki={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function ji(s){let e=0;const t=()=>s[e],i=()=>s[e++];function n(r=0){let c=o();for(;t()&&t().type==="op"&&Ki[t().value]>=r;){const d=i().value,u=n(Ki[d]+1);c={type:"binary",operator:d,left:c,right:u}}return c}function o(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){i();const c=o();return r.value==="-"?{type:"unary",operator:"-",operand:c}:c}return a()}function a(){const r=i();if(!r)throw new We("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const c=r.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 We("#ERROR!");return i(),{type:"call",name:c,args:u}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const c=n();if(!t()||t().type!=="rparen")throw new We("#ERROR!");return i(),c}throw new We("#ERROR!")}const l=n();if(e<s.length)throw new We("#ERROR!");return l}function ge(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 Jt={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=>Jt.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(ge(s[0])),ROUND:s=>{const e=s.length>1?ge(s[1]):0,t=Math.pow(10,e);return Math.round(ge(s[0])*t)/t},FLOOR:s=>Math.floor(ge(s[0])),CEIL:s=>Math.ceil(ge(s[0])),CEILING:s=>Math.ceil(ge(s[0])),SQRT:s=>{const e=ge(s[0]);return e<0?(()=>{throw new We("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(ge(s[0]),ge(s[1])),POW:s=>Math.pow(ge(s[0]),ge(s[1])),MOD:s=>{const e=ge(s[1]);if(e===0)throw new We("#DIV/0!");return ge(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?ge(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?ge(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,ge(s[1])-1),i=s.length>2?ge(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=>ge(s[0]),NUMBER:s=>ge(s[0]),BETWEEN:s=>ge(s[0])>=ge(s[1])&&ge(s[0])<=ge(s[2])},Zt=Object.keys(Jt);function po(s,e){Jt[s.toUpperCase()]=e,Zt.includes(s.toUpperCase())||Zt.push(s.toUpperCase())}function go(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 fo(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 Ot(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return fo(s.value,e);case"cell":return go(s.value,e);case"unary":return-ge(Ot(s.operand,e));case"call":{const t=Jt[s.name];if(!t)throw new We("#NAME?");const i=s.args.map(n=>Ot(n,e));return t(i,e)}case"binary":{const t=Ot(s.left,e),i=Ot(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:ge(t)+ge(i);case"-":return ge(t)-ge(i);case"*":return ge(t)*ge(i);case"/":{const n=ge(i);if(n===0)throw new We("#DIV/0!");return ge(t)/n}case"^":return Math.pow(ge(t),ge(i));case"%":{const n=ge(i);if(n===0)throw new We("#DIV/0!");return ge(t)%n}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return ge(t)<ge(i);case"<=":return ge(t)<=ge(i);case">":return ge(t)>ge(i);case">=":return ge(t)>=ge(i);default:throw new We("#ERROR!")}}default:throw new We("#ERROR!")}}function Bt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,i=ji(qi(t));return Ot(i,e)}function Ci(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function wi(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 me(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"?r=>Ci(a)?Bt(a,{data:r.data}):wi(r.data,a):a)({data:n?e.groupData:e.data,node:e,column:s,api:t,colDef:i,getValue:r=>wi(n?e.groupData:e.data,r)});if(s.field&&Ci(s.field))return Bt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return Bt(`=${s.field}`,{data:e.data});if(s.field)return wi(o,s.field)}function ei(s,e,t){var o;let i=me(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"?l=>mo(l.colDef.valueFormatter,l.value,l):n.valueFormatter)({value:i,data:e.data,node:e,column:s,api:t,colDef:n}):vo(s,i)}function mo(s,e,t={}){var i,n,o;if(e==null)return"";switch(s){case"number":return Qe(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${Qe(e,((n=t.column)==null?void 0:n.decimals)??2)}`;case"percent":return`${Qe(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Xi(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Xi(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 vo(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?Qe(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Xi(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Yi(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?i=>Qi(i.colDef.valueParser,i.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Qi(s.type,e)}function Qi(s,e){if(s==="numberColumn")return vi(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 Ji(s){const t=s.colDef.comparator,i=s.type;return(n,o)=>{const a=me(s,n,null),l=me(s,o,null);if(t)return t(a,l,n,o);if(i==="numberColumn"){const r=typeof a=="number"?a:vi(a),c=typeof l=="number"?l:vi(l);return r!==null&&c!==null?r-c:r===null&&c===null?0:r===null?-1:1}if(i==="dateColumn"){const r=a instanceof Date?a.getTime():new Date(a).getTime(),c=l instanceof Date?l.getTime():new Date(l).getTime();if(!isNaN(r)&&!isNaN(c))return r-c}return co(a,l)}}function Vt(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 Co={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 wo(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 bo(s){return!!s.treeData}function yo(){return{applyAggregate:Vt}}class Zi{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=en){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 l=i[a],r={field:a,headerName:t(a)};typeof l=="number"?(r.type="numberColumn",r.filter="number"):typeof l=="boolean"?r.type="booleanColumn":l instanceof Date&&(r.type="dateColumn"),o.push(r)}return o}getColumnGroups(){return this.columnGroups}getGroupDepth(){return this.columnGroups.reduce((e,t)=>Math.max(e,t.depth),0)}isGroupOpen(e){return this.openGroups.has(e)}setGroupOpen(e,t){t?this.openGroups.add(e):this.openGroups.delete(e),this.updateVisible(),this.refreshAll()}getColumnDefs(){return this.gridColumnDefs}buildColumns(){const e=this.columns,t=new Map;for(const d of e)t.set(d.colId,d);const i=this.options.defaultColDef||{},n={...Co,...this.options.columnTypes||{}},o=[],a=[];let l=0;const r=(d,u)=>{const p=d.colId||d.field||mi("col"),g={...i,...d};if(g.type&&n[g.type]){const C=n[g.type],h=new Set(Object.keys(d));for(const[f,m]of Object.entries(C))!h.has(f)&&!(f in i)&&(g[f]=m)}this.pushColumnInto(o,g,p,l++,t,u)},c=(d,u,p)=>{for(const g of d)if(g.children&&g.children.length){const C=g.groupId||mi("group"),h={id:C,headerName:g.headerName??"",openByDefault:g.openByDefault===!0||g.columnGroupShow==="open",parentId:u,depth:p,childColumnIds:[]};a.push(h),this.groupsInitialised||(h.openByDefault?this.openGroups.add(C):this.openGroups.delete(C)),c(g.children,C,p+1)}else r(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(p=>p.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),l=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?en(e.field):""),headerTooltip:e.headerTooltip,colDef:e,width:e.width??e.minWidth??(e.flex?200:100),minWidth:e.minWidth??20,maxWidth:e.maxWidth??Number.MAX_SAFE_INTEGER,flex:e.flex??null,pinned:e.pinned??null,hide:l,visible:!l,lockPosition:e.lockPosition??!1,type:e.type,sortable:e.sortable??!!e.field,sort:e.sort??null,sortIndex:e.sortIndex??null,resizable:e.resizable??!0,filter:wo(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&&(r.pinned=a.pinned,r.visible=a.visible,r.width=a.width,r.flex=a.flex,r.sort=a.sort,r.sortIndex=a.sortIndex,r.rowGroup=a.rowGroup,r.rowGroupIndex=a.rowGroupIndex,r.pivot=a.pivot,r.pivotIndex=a.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const i=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),n=[];for(const r of t){const c=[],d=new Set;for(const u of e){const p=u==null?void 0:u[r.field],g=String(p);d.has(g)||(d.add(g),c.push(p))}c.sort((u,p)=>u===p?0:String(u)<String(p)?-1:1);for(const u of i){for(const C of c){const h=`__pivot_${r.colId}_${u.colId}_${C}`,f=this.createColumn({colId:h,headerName:`${String(C)}`,width:130,type:u.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:u.cellClass,cellDataType:u.cellDataType},h,-1,new Map,null);f.aggFunc=u.aggFunc,f.groupId=r.colId,f.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:C,valueColumnId:u.colId,valueField:u.field},f.valueGetter=m=>this.evaluatePivotValue(f,m.node),n.push(f)}const p=`__pivot_${r.colId}_${u.colId}_total`,g=this.createColumn({colId:p,headerName:"Total",width:130,type:u.type,sortable:!1,filter:!1,cellDataType:u.cellDataType},p,-1,new Map,null);g.aggFunc=u.aggFunc,g.groupId=r.colId,g.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:u.colId,valueField:u.field},g.valueGetter=C=>this.evaluatePivotValue(g,C.node),n.push(g)}}const o=new Set(t.map(r=>r.colId)),a=this.columns.reduce((r,c,d)=>o.has(c.groupId??"")?r:d,0);this.columns.splice(a+1,0,...n);for(const r of n)this.displayOrder.push(r.colId);const l=new Set(this.columnGroups.map(r=>r.id));for(const r of t)l.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const 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 l=(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(l.length===0)return null;const r=this.columns.find(d=>d.colId===i.valueColumnId),{applyAggregate:c}=yo();return c(r,e.aggFunc,l)}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 l={...this.autoGroupColumnDef};if(l.colId=e,a)a.headerName=l.headerName??"",a.colDef=l,a.cellRenderer=l.cellRenderer,a.cellRendererParams=l.cellRendererParams,a.width=l.width??a.width,a.minWidth=l.minWidth??a.minWidth,a.pinned=l.pinned??"left";else{const d=this.createColumn(l,e,-2,new Map,null);this.columns.unshift(d),this.displayOrder.unshift(e)}const r=this.columns.find(d=>d.colId===e),c=()=>this.getRowGroupColumns()[0];r.valueGetter=d=>{const u=d.node;if(!u)return"";if(u.key!==null&&u.key!==void 0)return u.key;if(bo(this.options))return"";const p=c();return p!=null&&p.field&&u.data?u.data[p.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,l=0;for(const c of n)t.includes(c.colId)?l+=c.width:c.flex!==null&&c.flex>0?a+=c.flex:l+=c.width;const r=Math.max(0,e-l-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(r*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 l,r,c,d,u,p;const i=this.getColumn(e);if(!i)return;let n=this.measureTextWidth(i.headerName)+32;t||(n+=16);const o=((r=(l=this.gridApi)==null?void 0:l.getDisplayedRowCount)==null?void 0:r.call(l))??0,a=Math.min(o,300);for(let g=0;g<a;g++){const C=(d=(c=this.gridApi)==null?void 0:c.getDisplayedRowAtIndex)==null?void 0:d.call(c,g);if(!C)continue;const h=(p=(u=this.gridApi)==null?void 0:u.getCellText)==null?void 0:p.call(u,i,C);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 en(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class lt{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=mi("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 So{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],l=t?t({data:a,level:0}):void 0,r=this.createRowNode(a,l);r.rowIndex=o,n.push(r)}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 lt(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=[],l=(c,d,u)=>{const p=i(c),g=p.join("/"),C=t?t({data:c,level:u}):g,h=this.createRowNode(c,C,d,u);h.key=p[p.length-1],o.set(g,h);const f=c[n];if(Array.isArray(f)&&f.length){h.children=[],h.group=!0,h.expanded=!0;for(const m of f){const b=l(m,h,u+1);h.children.push(b)}h.allChildrenCount=f.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},r=c=>{if(!c.children||c.children.length===0)return 1;let d=0;for(const u of c.children)d+=r(u);return c.allChildrenCount=d,d};for(const c of a)r(c);for(const c of e){if(!c)continue;const u=i(c).slice(0,-1).join("/"),p=u&&o.get(u)||null;l(c,p??null,p?p.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(l=>{const r=t?t({data:l,level:0}):l.id;return String(r)===String(o)?n:l}),a.data=n,i.update.push(a);else{const l=this.createRowNode(n,o!==void 0?String(o):void 0);this.rowData.push(n),i.add.push(l)}}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,l=this.createRowNode(o,a);i.add.push(l),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,l=C=>{for(const[h,f]of Object.entries(e)){const m=o.find(b=>b.colId===h);if(m&&!this.doesNodePassFilter(C,m,f))return!1}return!0},r=C=>{const h=this.options.__advancedFilterPass;return h?h(C):!0},c=Object.entries(e).some(([C,h])=>{const f=o.find(m=>m.colId===C);return!f||!f.aggFunc?!1:h.filterType==="multi"?(h.filterModels||[]).length>0:!0}),d=C=>{if(C.__passesFilter=!0,C.children)for(const h of C.children)d(h)},u=C=>{const h=this.options;return typeof h.isExternalFilterPresent!="function"||!h.isExternalFilterPresent()||typeof h.doesExternalFilterPass!="function"?!0:h.doesExternalFilterPass(C)},p=C=>{if(!n)return!0;const h=t.toLowerCase(),f=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of f){const b=me(m,C,null);if(uo(h,b))return!0}return!1},g=C=>{let h=!0;if(!C.group||C.footer||a?h=(!i||l(C))&&p(C)&&u(C)&&r(C):c&&(h=(!i||l(C))&&r(C)),C.__passesFilter=h,C.children){let f=!1;for(const m of C.children)g(m)&&(f=!0);return C.group&&!C.footer&&(c?(C.__passesFilter=h,h&&d(C)):(C.__passesFilter=a?f||h:f,a&&h&&d(C))),C.__passesFilter}return h};for(const C of this.rootRowNodes)g(C)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const d=[];ii(e,d);const u=d.map(p=>me(t,p,null));r=Vt(t,t.aggFunc,u)}const c={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(c,t,i)}if(i.filterType==="multi"){const r=i.filterModels||[];if(r.length===0)return!0;const c=i.operator||"AND",d=r.map(u=>this.doesNodePassFilter(e,t,u));return c==="OR"?d.some(Boolean):d.every(Boolean)}if(i.condition1||i.condition2){const{condition1:r,condition2:c,...d}=i,u=[this.doesNodePassFilter(e,t,{...d,...r||{}})];return c&&u.push(this.doesNodePassFilter(e,t,{...d,...c})),(i.operator||"AND")==="OR"?u.some(Boolean):u.every(Boolean)}const n=me(t,e,null),o=Eo(t,n),a=n,l=i.filterType||"text";if(l==="text"){const r=String(i.filter??"").toLowerCase();if(!r)return!0;const c=(a==null?"":String(a)).toLowerCase();switch(i.type){case"equals":return c===r;case"notEqual":return c!==r;case"startsWith":return c.startsWith(r);case"endsWith":return c.endsWith(r);case"contains":default:return c.includes(r)}}if(l==="number"){const r=typeof a=="number"?a:Number(a);if(isNaN(r))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 r===c;case"notEqual":return r!==c;case"lessThan":return r<c;case"lessThanOrEqual":return r<=c;case"greaterThan":return r>c;case"greaterThanOrEqual":return r>=c;case"inRange":return d!==null?r>=Math.min(c,d)&&r<=Math.max(c,d):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(l==="date"){const r=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(r))return!1;const c=i.dateFrom?new Date(i.dateFrom).getTime():null,d=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(c!==null&&r<c||d!==null&&r>d)}return l==="boolean"?!!a==!!i.filter:l==="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,l)=>(a.column.sortIndex??0)-(l.column.sortIndex??0));const n=(a,l)=>{for(const{column:d,direction:u}of t){const p=Ji(d)(a,l)*(u==="asc"?1:-1);if(p!==0)return p}const r=a.rowIndex??0,c=l.rowIndex??0;return r-c},o=a=>{a.sort(n);for(const l of a)l.children&&o(l.children)};if(e.length===0)o(this.rootRowNodes);else for(const a of this.rootRowNodes)a.children&&o(a.children)}doGroup(e){if(e.length===0)return;const t=this.columns().filter(c=>c.aggFunc&&!c.rowGroup),i=(c,d,u,p)=>{if(d>=e.length)return c;const g=e[d],C=new Map,h=[];for(const m of c){if(!m.__passesFilter)continue;const b=me(g,m,null),R=xo(b);C.has(R)||(C.set(R,[]),h.push(R)),C.get(R).push(m)}const f=[];for(const m of h){const b=C.get(m),R=`${p}|${g.colId}:${m}`,k=this.rowNodeMap.get(R),y=k||new lt({[g.colId]:m},this.rowNodeServices,R);y.group=!0,y.key=m,y.level=u,y.uiLevel=u,y.parent=null,y.children=i(b,d+1,u+1,R);for(const D of y.children)D.parent=y;y.allChildrenCount=tn(y),y.data={...y.data};const M=[];ii(y,M);const P={};for(const D of t){const j=M.map(W=>me(D,W,null));P[D.colId]=Vt(D,D.aggFunc,j)}P[g.colId]=m,y.groupData=P,k||this.rowNodeMap.set(R,y),f.push(y)}return f},n=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=i(o,0,0,""),l=c=>{for(const d of c){if(!d.group)continue;const u=ti(d),p=this.expandedGroups.has(u);n===-1||p?d.expanded=!0:this.groupDefaultExpandedApplied?d.expanded=!1:d.expanded=d.level<n,d.expanded&&this.expandedGroups.add(u),d.children&&l(d.children)}};l(a),this.groupDefaultExpandedApplied=!0;const r=(c,d)=>{const u=e[d],p=u.sort==="desc"?-1:1,g=Ji(u);c.sort((C,h)=>{const f=me(u,C,null),m=me(u,h,null);return g({...C,data:{[u.colId]:f}},{...h,data:{[u.colId]:m}})*p})};e[0].sort&&r(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],i=!!this.options.treeData,n=(a,l)=>{if(a.uiLevel=l,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||i)){const r=a.group?a.children.filter(c=>c.__passesFilter||c.group):a.children;if(a.expanded){for(const c of r)n(c,l+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const c=this.createFooterNode(a,l+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(),l=this.getCurrentPage();let r=0,c=-1;for(let u=0;u<o.length;u++)if(!o[u].masterNode){if(r===l*a){c=u;break}r++}c<0&&(c=o.length);let d=c;for(r=0;d<o.length&&r<a;)o[d].masterNode||r++,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,l)=>a.__displayIndex=l)}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 lt(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 lt(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(l=>l.aggFunc&&!l.rowGroup),o=[];for(const l of this.rootRowNodes)l.group?ii(l,o):l.__passesFilter&&o.push(l);const a={};for(const l of n){const r=o.map(c=>me(l,c,null));a[l.colId]=Vt(l,l.aggFunc,r)}return a.__grandTotal=!0,i.groupData=a,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(ti(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(ti(e)):this.expandedGroups.delete(ti(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 xo(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function ti(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function tn(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+tn(t),0)}function ii(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)ii(t,e)}function Eo(s,e){return e}const nn={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:"散点图"},Ro={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 ko{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:nn[e]??e}}function Mo(s){return new ko(s??{})}function To(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class No{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,l)=>{n.loading=!1,this.onBlockLoaded(e,a,l??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],l=(n.rows.length>0,o),r=this.createNode(a,e,o,l);n.rows[l]=r}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=To(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${n}`,l=this.rowNodeMap.get(a),r=l instanceof lt?l:new lt(e,this.rowNodeServices,a);return r.data=e,r.rowIndex=i,o&&(r.group=!0,r.key=String(me(this.columns().find(c=>c.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(a,r),r}buildDisplayRows(){const e=[],t=(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 l=`${i?i+"|":""}${a.key}`;t(l,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 l=this.stores.get(a);if(l){for(const r of l.rows)if(r){if(i>=e&&i<=t){const c=Math.floor(i/this.blockSize)*this.blockSize,d=c+this.blockSize,u=l.lastRow,p=u!==null?Math.min(u,d):d;i<(l.rows.length||0)&&c<(l.rows.length||0)||(l.lastRow===null||d<=l.lastRow)&&this.loadBlock(a,c,p)}i++,r.group&&r.expanded&&n(`${a?a+"|":""}${r.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 l=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let r=this.rowNodeMap.get(l);r||(r=new lt(o,this.rowNodeServices,l),this.rowNodeMap.set(l,r)),r.data=o,r.rowIndex=e+a,this.nodes[e+a]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const 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 Lo{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 l=this.rowNodeMap.get(a);l||(l=new lt(n,this.rowNodeServices,a),this.rowNodeMap.set(a,l)),l.data=n,l.rowIndex=e+o,this.nodes[e+o-e]=l}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}setViewportDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}onViewportChanged(e,t){this.setViewportRange(e,t)}isLoading(){return this.loading}getRowCount(){return this.nodes.filter(Boolean).length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,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 Ao{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,l=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${l}px`,o){const p=document.createElement("span");p.className="ag-group-value-expanded-icon",p.classList.add(a?"ag-expanded":"ag-contracted"),p.innerHTML=a?Yo:Xo,r.appendChild(p);const g=document.createElement("span");g.className="ag-group-value";const C=(c=e.colDef.cellRendererParams)==null?void 0:c.innerRenderer;if(typeof C=="function"){const h=C({...e,value:e.value,valueFormatted:e.valueFormatted});h instanceof HTMLElement?g.appendChild(h):typeof h=="string"&&(g.innerHTML=h)}else g.textContent=Bo(e.value);if(r.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})`,r.appendChild(h)}}else{const p=document.createElement("span");p.className="ag-group-value";const g=(u=e.colDef.cellRendererParams)==null?void 0:u.innerRenderer;if(typeof g=="function"){const C=g({...e,value:e.value,valueFormatted:e.valueFormatted});C instanceof HTMLElement?p.appendChild(C):typeof C=="string"&&(p.innerHTML=C)}else p.textContent=e.valueFormatted??String(e.value??"");r.appendChild(p)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Do{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 Fo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',Po='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class $o{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?Fo:Po,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 Go{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 Ho{constructor(e){v(this,"eGui");var r,c;this.params=e;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],n=e.sparklineOptions||((c=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:c.sparklineOptions)||{},o=e.column.width||100,a=n.height||24,l=bi(i,Math.max(20,o-16),a,n);t.appendChild(l),this.eGui=t}getGui(){return this.eGui}refresh(e){var l,r;const t=e.value||[],i=e.sparklineOptions||((r=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:r.sparklineOptions)||{},n=e.column.width||100,o=i.height||24;this.eGui.innerHTML="";const a=bi(t,Math.max(20,n-16),o,{type:i.type,direction:i.direction});return this.eGui.appendChild(a),!0}}function bi(s,e,t,i={}){var m,b,R;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(k=>typeof k=="number"?k:Number((k==null?void 0:k.value)??0));if(!o||o.length<1)return n;const a=i.type||"line",l=Math.min(...o,0),c=Math.max(...o,0)-l||1,d=((m=i.tooltip)==null?void 0:m.enabled)===!0,u=((b=i.axis)==null?void 0:b.type)||"number",p=((R=i.pointsOfInterest)==null?void 0:R.show)===!0,g=(k,y)=>u==="category"?`${k+1}: ${y}`:String(y);if(p&&o.length>1){const k=o.indexOf(Math.min(...o)),y=o.indexOf(Math.max(...o)),M=e/Math.max(1,o.length-1),P=j=>t-2-(j-l)/c*(t-4),D=(j,W)=>{const B=document.createElementNS("http://www.w3.org/2000/svg","circle");B.setAttribute("cx",String(j*M)),B.setAttribute("cy",String(P(o[j]))),B.setAttribute("r","2.5"),B.setAttribute("fill",W),n.appendChild(B)};D(0,"#4caf50"),D(o.length-1,"#f44336"),D(k,"#2196f3"),D(y,"#ff9800")}if(d){const k=document.createElementNS("http://www.w3.org/2000/svg","title");k.textContent=o.map((y,M)=>g(M,y)).join(`
3
- `),n.appendChild(k),n.style.cursor="default"}if(a==="bar"){const k=i.direction==="vertical",y=o.length;if(k){const M=Math.max(1,e/y-1),P=t-2-(0-l)/c*(t-4);o.forEach((D,j)=>{const W=j*(e/y),B=t-2-(D-l)/c*(t-4),E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("x",String(W)),E.setAttribute("width",String(M)),E.setAttribute("y",String(Math.min(B,P))),E.setAttribute("height",String(Math.max(1,Math.abs(P-B)))),E.setAttribute("fill","currentColor"),n.appendChild(E)})}else{const M=Math.max(1,t/y-1),P=2+(0-l)/c*(e-4);o.forEach((D,j)=>{const W=j*(t/y),B=2+(D-l)/c*(e-4),E=document.createElementNS("http://www.w3.org/2000/svg","rect");E.setAttribute("y",String(W)),E.setAttribute("height",String(M)),E.setAttribute("x",String(Math.min(B,P))),E.setAttribute("width",String(Math.max(1,Math.abs(P-B)))),E.setAttribute("fill","currentColor"),n.appendChild(E)})}return n}const C=e/Math.max(1,o.length-1),h=o.map((k,y)=>{const M=y*C,P=t-2-(k-l)/c*(t-4);return`${M.toFixed(1)},${P.toFixed(1)}`});if(a==="area"){const k=document.createElementNS("http://www.w3.org/2000/svg","polygon");k.setAttribute("points",`0,${t} ${h.join(" ")} ${e},${t}`),k.setAttribute("fill","currentColor"),k.setAttribute("opacity","0.2"),n.appendChild(k)}const f=document.createElementNS("http://www.w3.org/2000/svg","polyline");return f.setAttribute("points",h.join(" ")),f.setAttribute("fill","none"),f.setAttribute("stroke","currentColor"),f.setAttribute("stroke-width","1.5"),n.appendChild(f),n}class Oo{constructor(e){v(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=on,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const ni={agGroupCellRenderer:s=>new Ao(s),agCheckboxCellRenderer:s=>new Do(s),agSparklineCellRenderer:s=>new Ho(s),agAnimateShowChangeCellRenderer:s=>new $o(s),agRowNumberCellRenderer:s=>new Go(s),agRowDragComp:s=>new Oo(s)};function Bo(s){return s==null?"":String(s)}class Vo{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 zo{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",r=>{var c,d;r.preventDefault(),r.preventDefault(),i.value=String(Number(i.value||0)+(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))});const l=document.createElement("span");l.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",l.innerHTML="▼",l.addEventListener("mousedown",r=>{var c,d;r.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(l)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",a=>{var l;return(l=e.onKeyDown)==null?void 0:l.call(e,a)})}getGui(){return this.eGui}getValue(){if(this.cancelled)return;const e=Number(this.eInput.value);return isNaN(e)?null:e}focusIn(){this.eInput.focus(),this.eInput.select()}}class Wo{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 Uo{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 _o{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 qo(s,e){if(!e)return Ht(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?Ht(s):Ht(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+Ht(s.slice(t,t+e.length))+"</span>"+Ht(s.slice(t+e.length))}class Ko{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,l;if(this.ePopup)return;const e=document.createElement("div");e.className="ag-rich-select-popup";const t=this.eGui.getBoundingClientRect();if(e.style.position="fixed",e.style.left=`${t.left}px`,e.style.top=`${t.bottom}px`,e.style.minWidth=`${Math.max(t.width,180)}px`,e.style.zIndex="1000",(this.eGui.closest(".ag-root")||document.body).appendChild(e),this.ePopup=e,jo(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((l=(a=this.params).t)==null?void 0:l.call(a,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const n=document.createElement("div");n.className="ag-rich-select-list",e.appendChild(n),this.eList=n,this.renderList();const o=r=>{!e.contains(r.target)&&!this.eGui.contains(r.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var 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(),l=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?l.every(r=>a.includes(r)):l.some(r=>a.includes(r))}),this.filtered.forEach((o,a)=>{const l=document.createElement("div");l.className="ag-rich-select-item",a===this.activeIndex&&l.classList.add("ag-active"),String(o)===String(this.selectedValue)&&l.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const c=r({value:o,valueFormatted:String(o)});c instanceof HTMLElement?l.appendChild(c):l.textContent=String(c)}else l.innerHTML=qo(String(o),e);l.addEventListener("click",c=>{c.stopPropagation(),this.commit(o)}),l.addEventListener("mousedown",c=>c.preventDefault()),this.eList.appendChild(l)}),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 jo(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 rt={agTextCellEditor:s=>new Vo(s),agNumberCellEditor:s=>new zo(s),agSelectCellEditor:s=>new Wo(s),agDateCellEditor:s=>new Uo(s),agLargeTextCellEditor:s=>new _o(s),agRichSelectCellEditor:s=>new Ko(s)},Xo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',Yo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',on='<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>',Qo='<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>',Jo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Zo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',es='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',sn='<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 an(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,l=e[a];if(!l||l.level===0)return[];const r=[];let c=l.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&&r.push(d),u.level===0))break}return r.reverse()}class ts{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 l=0;l<e;l++)t[l]=l*a,i[l]=this.rowInfoAt(l);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,l,r,c)=>{o.innerHTML="",a.innerHTML="",l.innerHTML="";const{left:d,center:u,right:p}=this.ctx.getColumns();let g=0;for(let C=0;C<r;C++){const h=c(C);if(!h)continue;const f=this.ctx.getRowHeight(h),m=new oi(this.ctx,h,d,u,p,f,this.heightVersion);m.appendTo(a,o,l),m.setTop(g),g+=f,this.rowComps.set(`${h.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${g}px`,o.style.display=r>0?"":"none",a.style.height=`${g}px`,l.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:l}=this.ctx.getColumns(),r=new oi(this.ctx,i,o,a,l,this.getRowHeightForIndex(n),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[n]??0),this.rowComps.set(this.rowCompKey(i),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){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?[]:an(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 l=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 p=this.rowComps.get(d.id);p&&(p.destroy(),this.rowComps.delete(d.id)),u=new oi(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(l),l+=this.getRowHeightForIndex(c)}for(const[c,d]of this.stickyComps)a.has(c)||(d.destroy(),this.stickyComps.delete(c));const r=`${l}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),i=this.eViewport.scrollTop,n=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a=0,l=t-1;if(this.hasVariableHeights())a=this.findIndexAtPixel(i)-o,l=this.findIndexAtPixel(i+n)+o;else{const f=this.getFixedRowHeight();a=Math.floor(i/f)-o,l=Math.ceil((i+n)/f)+o}if(a=Math.max(0,a),l=Math.min(t-1,l),!e&&this.lastRange[0]===a&&this.lastRange[1]===l&&this.lastScrollTop===i)return;const r=this.lastRange[0]!==a||this.lastRange[1]!==l;this.lastRange=[a,l],this.lastScrollTop=i;const c=new Set(this.stickyComps.keys()),d=this.syncStickyGroupRows(),u=c.size!==d.size||[...c].some(f=>!d.has(f));if(!e&&!r&&!u)return;const p=new Set(d),{left:g,center:C,right:h}=this.ctx.getColumns();for(let f=a;f<=l;f++){const m=this.ctx.rowModel.getRow(f);if(!m||(p.add(m.id),d.has(m.id)))continue;let b=this.rowComps.get(m.id);b||(b=new oi(this.ctx,m,g,C,h,this.getRowHeightForIndex(f),this.heightVersion),b.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,b)),b.setTop(this.rowOffsets[f]??f*this.getFixedRowHeight())}for(const[f,m]of this.rowComps)!p.has(f)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(f))}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,l)=>a+l.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 l=this.ctx.rowModel.getRowNode(a);if(!l)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:l,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:me(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:me(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:me(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:me(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 oi{constructor(e,t,i,n,o,a,l){v(this,"eLeft",null);v(this,"eCenter",null);v(this,"eRight",null);v(this,"cellComps",[]);v(this,"pinned",!1);var r,c,d,u,p,g,C,h,f;if(this.ctx=e,this.node=t,this.rowHeight=a,this.heightVersion=l,t.masterNode){const m=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(m){const b=document.createElement("div");b.className="ag-row ag-row-detail-row",b.dataset.rowid=t.id,b.style.height=`${m.height}px`,b.style.width="100%",b.appendChild(m.eDetail),this.eCenter=b,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&&((r=this.eCenter)==null||r.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"),(p=this.eLeft)==null||p.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)&&((C=this.eCenter)==null||C.classList.add("ag-row-selected"),(h=this.eLeft)==null||h.classList.add("ag-row-selected"),(f=this.eRight)==null||f.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 r;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&&((r=e.groupData)!=null&&r.__grandTotal)&&(n.classList.add("ag-row-full-width"),n.style.width="100%",n.style.right="0",n.style.left="0");let l=0;for(let c=0;c<t.length;c++){const d=t[c],u=this.createCell(d,e);let p=1;typeof d.colDef.colSpan=="function"&&(p=Math.max(1,Math.round(d.colDef.colSpan({value:me(d,e,null),data:e.data,node:e,column:d,rowIndex:e.__displayIndex??0,api:null}))));let g=d.width;for(let C=1;C<p&&c+C<t.length;C++)g+=t[c+C].width;u.eCell.style.left=`${l}px`,u.eCell.style.width=`${g}px`,u.eCell.style.position="absolute",u.eCell.style.top="0",u.eCell.style.height=`${this.rowHeight}px`,p>1&&u.eCell.classList.add("ag-cell-col-span"),l+=g,c+=p-1,n.appendChild(u.eCell),this.cellComps.push(u)}return n.style.width=`${l}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:me(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const p=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof p=="string"?i.classList.add(...p.split(" ").filter(Boolean)):Array.isArray(p)&&i.classList.add(...p)}if(e.cellClassRules)for(const[p,g]of Object.entries(e.cellClassRules))g(o)&&i.classList.add(p);if(e.cellStyle){const p=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(i.style,p)}(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 l=(u=(d=this.ctx).getNote)==null?void 0:u.call(d,t.id,e.colId,e.colDef.note,{value:me(e,t,null),data:t.data,node:t,column:e,api:null});if(l){const p=document.createElement("span");p.className="ag-cell-note-marker",p.title=l,p.addEventListener("click",g=>{var C,h;g.stopPropagation(),(h=(C=this.ctx).onNoteClick)==null||h.call(C,t.id,e.colId,p)}),i.appendChild(p)}if(e.rowDrag){const p=document.createElement("span");p.className="ag-row-drag-handle",p.innerHTML=on,p.title=this.ctx.t("dragRow"),p.addEventListener("mousedown",g=>{var C,h;g.button===0&&(g.stopPropagation(),(h=(C=this.ctx).onRowDragStart)==null||h.call(C,t,p,g))}),i.appendChild(p)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?i.title=String(t.data[r]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:me(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=me(t,i,null),o=ei(t,i,null);e.lastValue=n,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,l=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||l){e.custom=!0;const 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 p=null;if(a&&ni[a]){const g=ni[a](u);g instanceof HTMLElement?p=g:(e.rendererInstance=g,p=g.getGui())}else if(l){const g=l(u);g instanceof HTMLElement?p=g:g&&typeof g.getGui=="function"?(e.rendererInstance=g,p=g.getGui()):typeof g=="string"&&(e.eValue.innerHTML=g)}p&&e.eValue.appendChild(p)}return}e.rendererKey="",e.custom=!1,(c=e.rendererInstance)!=null&&c.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=o??"";if((i.group||i.footer)&&i.groupData){const d=i.groupData[t.colId];r=d==null?"":String(d)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,i){var a,l,r,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=me(d.column,this.node,null),p=t||u!==d.lastValue;if(!p&&!i)continue;const g=d.eValue.textContent;if(d.rendererInstance&&typeof d.rendererInstance.refresh=="function"){d.rendererInstance.refresh({value:u,valueFormatted:ei(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){(p||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||p&&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),(l=this.eLeft)==null||l.classList.toggle("ag-row-selected",o),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",o),this.node.group&&((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 is{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 l;const e=this.ctx.getColumnModel(),t=((l=e==null?void 0:e.getColumnGroups)==null?void 0:l.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((r,c)=>Math.max(r,c.depth),0),n=this.ctx.options.groupHeaderHeight??30;let o=0;for(let r=1;r<=i;r++){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,p,g=0,C=0;const h=(m,b)=>{let R=m.groupId;for(;R;){const k=t.find(y=>y.id===R);if(!k)return null;if(k.depth===b)return k.id;R=k.parentId}return null},f=()=>{if(p==null)return;const m=t.find(y=>y.id===p);if(!m)return;const b=document.createElement("div");b.className="ag-header-group-cell",b.style.left=`${g}px`,b.style.width=`${C}px`,b.style.height=`${n}px`;const R=e.isGroupOpen(m.id),k=document.createElement("div");if(k.className="ag-header-group-cell-label",k.textContent=m.headerName,b.appendChild(k),!R){const y=document.createElement("span");y.className="ag-header-group-expand",y.textContent="▸",y.title=this.ctx.t("expandGroup"),b.appendChild(y)}b.addEventListener("click",()=>{e.setGroupOpen(m.id,!R)}),c.appendChild(b)};d.forEach(m=>{const b=h(m,r);b!==p&&(f(),p=b,g=u,C=0),C+=m.width,u+=m.width}),f(),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 l=this.createFloatingFilter(o);l.style.left=`${n-o.width}px`,l.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(l)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${n}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${n}px`)}createHeaderCell(e){var a,l;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const r=i({column:e,colDef:e.colDef,api:((l=(a=this.ctx).getApi)==null?void 0:l.call(a))??null,displayName:e.headerName}),c=r&&typeof r.getGui=="function"?r.getGui():r;if(c instanceof HTMLElement)return c.classList.add("ag-header-component"),t.appendChild(c),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const n=document.createElement("div");if(n.className="ag-header-cell-label",e.headerTooltip&&(n.title=e.headerTooltip),e.headerCheckboxSelection){const r=document.createElement("input");r.type="checkbox",r.className="ag-native-checkbox ag-header-select-all",r.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,r.checked)),r.addEventListener("click",c=>c.stopPropagation()),n.appendChild(r)}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 r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const c=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",c),r.innerHTML=Jo,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=Qo,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const c=t.getBoundingClientRect();r.clientX>c.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",c=>{c.stopPropagation(),c.preventDefault(),this.resizeState={column:e,startX:c.clientX,startWidth:e.width};const d=p=>{if(!this.resizeState)return;const g=p.clientX-this.resizeState.startX;let C=this.resizeState.startWidth+g;C=Math.max(e.minWidth,Math.min(e.maxWidth,C)),this.ctx.onColumnResized(e,Math.round(C),!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(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const 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),r.dataTransfer.setDragImage(c,20,20),this.dragState={colId:e.colId,ghost:c,startX:r.clientX,startY:r.clientY},setTimeout(()=>c.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var d;r.preventDefault();const c=(d=r.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=Zo):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=es),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 l=o.querySelector(".ag-filter-icon");l&&l.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 ns{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 l=Math.min(n,o),r=Math.max(n,o);a=0,i.forEachNode(c=>{a>=l&&a<=r&&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 os{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=me(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 l=null;if(typeof t.cellEditor=="string")l=(rt[t.cellEditor]||rt.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const d=t.cellEditor(a);l=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";l=rt[d](a)}if(!l)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:n,editor:l,startedValue:o},n.classList.add("ag-cell-inline-editing");const r=l.getGui();r.classList.add("ag-cell-editor"),n.appendChild(r),n.classList.add("ag-cell-editing"),l.focusIn&&l.focusIn(),l.afterGuiAttached&&l.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 l=me(o,t,this.grid.getApi()),r=this.createEditor(o,t,e,l,i);if(!r)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const c=r.getGui();c.classList.add("ag-cell-editor"),a.appendChild(c),this.fullRowEditors.push({column:o,editor:r,eCell:a,startedValue:l})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,n,o){var r;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:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(rt[e.cellEditor]||rt.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 l=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return rt[l](a)}stopEditing(e=!1){var c,d,u,p;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:i,rowNode:n,eCell:o,editor:a,startedValue:l}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?l:a.getValue();if(r===void 0&&!e)return(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){r=Yi(i,r);const g=this.applyValueSetter(i,n,r);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;r=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&&!ln(r,l)&&(this.grid.setCellValue(i,n,r,"edit",l),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l,newValue:r,value:r,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(p=(u=this.grid.getOptions()).onCellValueChanged)==null||p.call(u,{oldValue:l,newValue:r,value:r,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:me(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,l;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=r.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const n=[];for(const r of t){if(!i)break;let c=r.editor.getValue();c!==void 0&&(c=Yi(r.column,c),ln(c,r.startedValue)||n.push({column:r.column,rowNode:i,newValue:c,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const r of n)this.grid.setCellValue(r.column,r.rowNode,r.newValue,"edit",r.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi(),source:"edit"}),(l=(a=this.grid.getOptions()).onCellValueChanged)==null||l.call(a,{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[r.rowNode],columns:[r.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===wt){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===so)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===Wi){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 wt:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case Wi:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case Ui:case _i: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 ao:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case lo: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 l=o.findIndex(r=>r.colId===i.column.colId)+t;for(;l>=0&&l<o.length&&!o[l].visible;)l+=t;l<0&&(l=0),l>=o.length&&(l=o.length-1),this.setFocusedCell(n,o[l])}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 ln(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}class ss{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 l=this.grid.getColumn(a.colId);return!l||!n?!0:n(e,l,{...a,filterType:l.filter===!0?"text":l.filter})});return t.operator==="OR"?o.some(Boolean):o.every(Boolean)}getFilterModel(){return this.filterModel}getFilterInstance(e){return this.filterModel[e]}setFilterModel(e){this.filterModel=e||{},this.onFilterChanged("api")}setColumnFilterModel(e,t){const 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 as{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(),l=e.sort;let r=a.indexOf(l)+1;r>=a.length&&(r=0);const c=a[r];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 rn{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,l=document.createElement("span");l.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(l);const r=document.createElement("select");r.className="ag-pagination-page-size-select";const 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),r.appendChild(u)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),a.appendChild(r),this.ePageSizeSelect=r}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),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 l,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),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}),(r=(l=this.grid.getOptions()).onPaginationChanged)==null||r.call(l,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class ls{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",l,!0),document.removeEventListener("keydown",r,!0),(c=n.onClose)==null||c.call(n))},a=c=>{n.onClose=c},l=c=>{if(!i.contains(c.target)&&!this.grid.getRootElement().contains(c.target)){o();return}i.contains(c.target)||o()},r=c=>{c.key==="Escape"&&(c.stopPropagation(),o())};return this.getParent().appendChild(i),this.openPopups.add(n),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",r,!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 l=o.left-n.left+i;const r=n.width-a-4;l>r&&(l=r),l<4&&(l=4);const c=o.bottom-n.top+2;e.style.left=`${l}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 zt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Wt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class rs{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var f,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:l}=this.popupService.createPopup(o,"ag-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=`Search ${e.headerName||e.field||""}`,a.appendChild(r);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),l()},p=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),l()};if(i==="set")a.appendChild(this.buildSetFilter(e,c,b=>{d=b}));else if(i==="boolean"){const b=this.buildConditionSelect(["true","false"],String(c.filter??""),R=>{d={filterType:"boolean",filter:R==="true"}});a.appendChild(b)}else{const b=i==="number"?Wt:zt,R=this.buildConditionSelect(b,c.type||b[0],k=>{c.type=k,d={...c}});if(a.appendChild(R),c.type!=="blank"&&c.type!=="notBlank")if(i==="number"&&c.type==="inRange"){const k=document.createElement("div");k.className="ag-filter-inputs";const y=document.createElement("input");y.type="number",y.className="ag-filter-input",y.value=c.filter??"",y.placeholder=this.grid.t("from"),y.addEventListener("input",()=>{d={...c,filter:y.value,filterTo:M.value}});const M=document.createElement("input");M.type="number",M.className="ag-filter-input",M.value=c.filterTo??"",M.placeholder=this.grid.t("to"),M.addEventListener("input",()=>{d={...c,filter:y.value,filterTo:M.value}}),k.appendChild(y),k.appendChild(M),a.appendChild(k)}else if(i==="date"){const k=document.createElement("div");k.className="ag-filter-inputs";const y=document.createElement("input");y.type="date",y.className="ag-filter-input",y.value=c.dateFrom??"",y.addEventListener("input",()=>{d={...c,dateFrom:y.value,dateTo:M.value}});const M=document.createElement("input");M.type="date",M.className="ag-filter-input",M.value=c.dateTo??"",M.addEventListener("input",()=>{d={...c,dateFrom:y.value,dateTo:M.value}}),k.appendChild(y),k.appendChild(M),a.appendChild(k)}else{const k=document.createElement("input");k.type=i==="number"?"number":"text",k.className="ag-filter-input",k.value=c.filter??"",k.placeholder=this.grid.t("filterOoo"),k.addEventListener("input",()=>{d={...c,filter:k.value}}),k.addEventListener("keydown",y=>{y.key==="Enter"&&u()}),a.appendChild(k),setTimeout(()=>k.focus(),0)}else d={...c}}if(i==="text"||i==="number"){const b=document.createElement("div");b.className="ag-filter-second-condition";const R=document.createElement("select");R.className="ag-filter-condition",R.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,R.value=c.operator||"AND",b.appendChild(R);const k=this.buildConditionSelect(i==="number"?Wt:zt,((f=c.condition2)==null?void 0:f.type)||(i==="number"?Wt:zt)[0],M=>{d||(d={...c}),d.condition2={...d.condition2,type:M}});b.appendChild(k);const y=document.createElement("input");y.type=i==="number"?"number":"text",y.className="ag-filter-input",y.placeholder=this.grid.t("secondValue"),y.value=((m=c.condition2)==null?void 0:m.filter)??"",y.addEventListener("input",()=>{d||(d={...c}),d.condition2={...d.condition2,filter:y.value}}),b.appendChild(y),a.appendChild(b),R.addEventListener("change",()=>{d||(d={...c}),d.operator=R.value})}const g=document.createElement("div");g.className="ag-popup-buttons";const C=document.createElement("button");C.className="ag-button ag-button-primary",C.textContent=this.grid.t("apply"),C.addEventListener("click",u);const h=document.createElement("button");h.className="ag-button",h.textContent=this.grid.t("clear"),h.addEventListener("click",p),g.appendChild(h),g.appendChild(C),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(me(e,h,this.grid.getApi()))});let r=[...a].sort((h,f)=>h===f?0:h<f?-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 f=0;for(const m of r){const b=m==null?"(Blanks)":String(m);if(h&&!b.toLowerCase().includes(h))continue;f++;const R=document.createElement("label");R.className="ag-set-filter-item";const k=document.createElement("input");k.type="checkbox",k.checked=d.has(String(m)),k.addEventListener("change",()=>{k.checked?d.add(String(m)):d.delete(String(m)),i({filterType:"set",values:[...d]})});const y=document.createElement("span");y.textContent=b,R.appendChild(k),R.appendChild(y),c.appendChild(R)}if(f===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 p=document.createElement("div");p.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 r)d.add(String(h));u(),i({filterType:"set",values:[...d]})});const C=document.createElement("button");return C.className="ag-button ag-button-small",C.textContent=this.grid.t("clearAll"),C.addEventListener("click",()=>{d.clear(),u(),i({filterType:"set",values:[]})}),p.appendChild(g),p.appendChild(C),n.appendChild(c),n.appendChild(p),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 l=Ro[o];a.textContent=l?this.grid.t(l):o,o===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n}openMultiFilter(e,t){var R;const i=this.grid.getFilterService().getFilterInstance(e.colId),n=i&&i.filterType==="multi"?i:null,o=(R=n==null?void 0:n.filterModels)!=null&&R.length?n.filterModels.map(k=>({...k})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(n==null?void 0:n.operator)||"AND";const{ePopup:l,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");l.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`Filters for ${e.headerName||e.field||""}`,l.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 p=document.createElement("select");p.className="ag-filter-condition",p.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',p.value=a,p.addEventListener("change",()=>{a=p.value}),d.appendChild(u),d.appendChild(p),l.appendChild(d);const g=document.createElement("div");g.className="ag-multi-filter-list",l.appendChild(g);const C=()=>{g.innerHTML="",o.forEach((k,y)=>{const M=document.createElement("div");M.className="ag-multi-filter-row";const P=document.createElement("select");P.className="ag-filter-condition";const D=["text","number","date","set","boolean"];for(const E of D){const S=document.createElement("option");S.value=E,S.textContent=E.charAt(0).toUpperCase()+E.slice(1),E===k.filterType&&(S.selected=!0),P.appendChild(S)}P.addEventListener("change",()=>{o[y]={...this.getDefaultModel(P.value)},C()}),M.appendChild(P);const j=k.filterType==="number"?Wt:zt,W=this.buildConditionSelect(j,k.type||j[0],E=>{o[y].type=E});if(M.appendChild(W),k.filterType!=="blank"&&k.type!=="blank"&&k.type!=="notBlank"){const E=document.createElement("input");E.type=k.filterType==="number"?"number":"text",E.className="ag-filter-input",E.value=k.filter??"",E.placeholder=this.grid.t("value"),E.addEventListener("input",()=>{o[y].filter=E.value}),M.appendChild(E)}const B=document.createElement("button");B.className="ag-button ag-button-small",B.textContent="×",B.title=this.grid.t("removeFilter"),B.addEventListener("click",()=>{o.splice(y,1),C()}),M.appendChild(B),g.appendChild(M)})};C();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")),C()}),l.appendChild(h);const f=document.createElement("div");f.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(y=>y.filter!==void 0&&y.filter!==""||y.type==="blank"||y.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const b=document.createElement("button");b.className="ag-button",b.textContent=this.grid.t("clear"),b.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),f.appendChild(b),f.appendChild(m),l.appendChild(f),this.popupService.positionAt(l,t)}openAdvancedFilter(e){var R,k;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),n=(R=i==null?void 0:i.conditions)!=null&&R.length?i.conditions.map(y=>({...y})):[{colId:((k=this.grid.getColumns().center[0])==null?void 0:k.colId)??"",type:"contains",filter:""}];let o=(i==null?void 0:i.operator)||"AND";const{ePopup:a,close:l}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),a.appendChild(r);const 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(y=>y.filter),u=()=>{c.innerHTML="",n.forEach((y,M)=>{const P=document.createElement("div");P.className="ag-advanced-filter-row";const D=document.createElement("select");D.className="ag-filter-condition";for(const z of d()){const q=document.createElement("option");q.value=z.colId,q.textContent=z.headerName||z.field||z.colId,z.colId===y.colId&&(q.selected=!0),D.appendChild(q)}D.addEventListener("change",()=>{n[M].colId=D.value}),P.appendChild(D);const j=this.grid.getColumn(y.colId),W=j&&j.filter!==!1?String(j.filter):"text",B=W==="number"?Wt:zt,E=this.buildConditionSelect(B,y.type||"contains",z=>{n[M].type=z});P.appendChild(E);const S=document.createElement("input");S.type=W==="number"?"number":"text",S.className="ag-filter-input",S.value=y.filter??"",S.placeholder=this.grid.t("value"),S.addEventListener("input",()=>{n[M].filter=S.value}),P.appendChild(S);const $=document.createElement("button");$.className="ag-button ag-button-small",$.textContent="×",$.addEventListener("click",()=>{n.splice(M,1),u()}),P.appendChild($),c.appendChild(P)})};u();const p=document.createElement("button");p.className="ag-button ag-button-small",p.textContent="+ "+this.grid.t("addCondition"),p.addEventListener("click",()=>{var y;n.push({colId:((y=d()[0])==null?void 0:y.colId)??"",type:"contains",filter:""}),u()}),a.appendChild(p);const g=document.createElement("div");g.className="ag-multi-filter-operator";const C=document.createElement("span");C.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(C),g.appendChild(h),a.appendChild(g);const f=document.createElement("div");f.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 y=n.filter(M=>M.filter!==void 0&&M.filter!=="");y.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:y}):t.setAdvancedFilterModel(null),l()});const b=document.createElement("button");b.className="ag-button",b.textContent=this.grid.t("clear"),b.addEventListener("click",()=>{t.setAdvancedFilterModel(null),l()}),f.appendChild(b),f.appendChild(m),a.appendChild(f),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:l}=this.popupService.createPopup(260,"ag-filter-popup");a.innerHTML="";const r=typeof(o==null?void 0:o.getGui)=="function"?o.getGui():o;r instanceof HTMLElement&&a.appendChild(r),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 cn={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 cs{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 r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);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&&cn[n.icon]&&(a.innerHTML=cn[n.icon]),o.appendChild(a);const l=document.createElement("span");if(l.className="ag-menu-item-label",l.textContent=n.label??n.name,o.appendChild(l),n.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=n.shortcut,o.appendChild(r)}if(n.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",o.appendChild(r),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(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 ds{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=(r,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=sn),d.appendChild(u);const p=document.createElement("span");if(p.className="ag-menu-item-label",p.textContent=r,d.appendChild(p),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},l=r=>{const c=document.createElement("div");c.className="ag-menu-section",c.textContent=r,i.appendChild(c)};e.sortable&&(l(this.grid.t("sort")),a(this.grid.t("sortAscending"),{checked:e.sort==="asc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"asc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}}),a(this.grid.t("sortDescending"),{checked:e.sort==="desc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"desc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}})),e.resizable&&(l(this.grid.t("columnSize")),a(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),a(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(l(this.grid.t("pinColumn")),a(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),a(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),a(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(l(this.grid.t("filter")),a(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,t)}),e.filter!=="multi"&&a(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,t)}),this.grid.getOptions().enableAdvancedFilter&&a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)}),a(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(l(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),l(this.grid.t("formula")),a(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,t)}),l(this.grid.t("visibility")),a(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),a(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(i,t)}}class us{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 l=document.createElement("div");l.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(l);const r={def:a,ePanel:l,render:()=>this.renderPanel(a.key,l)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const 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,l=i.getSelectedNodes().length,r=[],c=this.grid.getColumnModel().getValueColumns().filter(d=>d.aggFunc);switch(this.grid.getRowModel().forEachNode(d=>{!d.footer&&d.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${Qe(a)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${Qe(n)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${Qe(n)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${Qe(l)}`);break;case"agAggregationComponent":{if(c.length===0)break;const d=i.getSelectedNodes().filter(p=>!p.group&&!p.footer),u=[];for(const p of c){const C=d.map(b=>me(p,b,i)).filter(b=>typeof b=="number"&&!isNaN(b)),h=C.reduce((b,R)=>b+R,0),f=b=>b===null?"":Qe(b,p.decimals),m=[[this.grid.translate("average","Average"),C.length?h/C.length:null],[this.grid.translate("count","Count"),C.length],[this.grid.translate("min","Min"),C.length?Math.min(...C):null],[this.grid.translate("max","Max"),C.length?Math.max(...C):null],[this.grid.translate("sum","Sum"),C.length?h:null]];for(const[b,R]of m)u.push(`${b}${p.headerName?` (${p.headerName})`:""} : ${f(R)}`)}u.length&&r.push(u.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class hs{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(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const l=(o==null?void 0:o.defaultToolPanel)||((n=this.panels[0])==null?void 0:n.id)||"columns";this.buildButtons(),this.openPanel(l)}else this.eBar.style.display="none"}defaultLabel(e){switch(e){case"columns":return this.grid.t("columns");case"filters":return this.grid.t("filters");case"charts":return this.grid.t("charts");default:return e}}buildButtons(){this.eButtons.innerHTML="";for(const e of this.panels){const t=document.createElement("button");t.className="ag-side-button",t.textContent=e.label,t.title=e.label,t.dataset.panelId=e.id,e.id===this.activePanelId&&t.classList.add("ag-selected"),t.addEventListener("click",()=>{this.activePanelId===e.id&&this.visible?this.setVisible(!1):(this.visible=!0,this.eBar.style.display="",this.openPanel(e.id)),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"sideBarButtonClicked",api:this.grid.getApi()})}),this.eButtons.appendChild(t)}}getElement(){return this.eBar}setPosition(e){this.position=e,this.eBar.classList.remove("ag-side-bar-left","ag-side-bar-right"),this.eBar.classList.add(`ag-side-bar-${e}`)}setVisible(e){this.visible=e,this.eBar.style.display=e?"":"none",this.grid.onGridSizeChanged(),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"api",api:this.grid.getApi()})}isVisible(){return this.visible}openPanel(e){this.activePanelId=e;for(const t of this.eButtons.querySelectorAll(".ag-side-button"))t.classList.toggle("ag-selected",t.dataset.panelId===e);switch(this.ePanel.innerHTML="",e){case"columns":this.ePanel.appendChild(this.buildColumnsPanel());break;case"filters":this.ePanel.appendChild(this.buildFiltersPanel());break;case"charts":this.ePanel.appendChild(this.grid.getChartService().buildChartPanel());break;default:{const t=document.createElement("div");t.className="ag-side-bar-empty",t.textContent=e,this.ePanel.appendChild(t)}}}getActivePanel(){return this.activePanelId}refresh(){this.activePanelId&&this.openPanel(this.activePanelId)}buildColumnsPanel(){const e=document.createElement("div");e.className="ag-column-panel";const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const 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(p=>p.pinned!=="left"&&p.pinned!=="right").concat(d.filter(p=>p.pinned==="left"||p.pinned==="right"));for(const p of u)c&&!p.headerName.toLowerCase().includes(c)&&!p.colId.toLowerCase().includes(c)||i.appendChild(this.buildColumnItem(p));if(!i.children.length){const p=document.createElement("div");p.className="ag-side-bar-empty",p.textContent=this.grid.t("noMatchingColumns"),i.appendChild(p)}};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 l=document.createElement("div");l.className="ag-column-group-list",o.appendChild(l);const r=()=>{l.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"),l.appendChild(d)}for(const d of c){const u=document.createElement("div");u.className="ag-column-group-item",u.draggable=!0,u.addEventListener("dragstart",C=>{var h;(h=C.dataTransfer)==null||h.setData("text/plain",d.colId)}),u.addEventListener("dragover",C=>C.preventDefault()),u.addEventListener("drop",C=>{var f;C.preventDefault();const h=(f=C.dataTransfer)==null?void 0:f.getData("text/plain");h&&this.grid.getColumnModel().setRowGroupColumns([...c.map(m=>m.colId),h])});const p=document.createElement("span");p.textContent=d.headerName,u.appendChild(p);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),l.appendChild(u)}};return r(),l.addEventListener("dragover",c=>c.preventDefault()),l.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"&&r()}),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 l=document.createElement("button");l.className="ag-column-select-action",l.title=this.grid.t("groupByThisColumn"),l.textContent="≡",l.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(l)}const a=document.createElement("button");return a.className="ag-column-select-action",a.title=this.grid.t("pinColumnTitle"),a.textContent="📌",a.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),o.appendChild(a),t.appendChild(o),t}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent=`${this.grid.t("advancedFilter")}…`,o.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(o)),e.appendChild(o);const a=this.grid.getFilterService().getAdvancedFilterModel();if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(l)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const 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(l=>l.filter);for(const l of a)o&&!l.headerName.toLowerCase().includes(o)||i.appendChild(this.buildFilterItem(l));if(!i.children.length){const l=document.createElement("div");l.className="ag-side-bar-empty",l.textContent=this.grid.t("noMatchingColumns"),i.appendChild(l)}};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 l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.innerHTML=sn,n.appendChild(l)}if(i.appendChild(n),e.filter==="set"){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=a?"Edit filter":"Add filter",l.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,l)),i.appendChild(l)}else if(e.filter==="date"){const l=document.createElement("input");l.type="date",l.className="ag-filter-input";const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.dateFrom)??"",l.addEventListener("change",()=>{t.setColumnFilterModel(e,l.value?{filterType:"date",dateFrom:l.value,dateTo:l.value}:null)}),i.appendChild(l)}else{const l=document.createElement("input");l.type=e.filter==="number"?"number":"text",l.className="ag-filter-input",l.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.filter)??"",l.addEventListener("input",()=>{t.handleFloatingFilterChange(e,l.value)}),i.appendChild(l)}if(a){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=this.grid.t("clear"),l.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(l)}return i}}class ps{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 r,c;if(this.ePopup){(r=this.eInput)==null||r.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 l=(d,u,p)=>{const g=document.createElement("button");return g.className="ag-button ag-button-small",g.textContent=d,g.title=u,g.addEventListener("click",p),e.appendChild(g),g};l("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),l("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),l("×",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){me(o,i,this.grid.getApi());const a=ei(o,i,this.grid.getApi())??"",l=this.matchCase?a:a.toLowerCase(),r=this.matchCase?e:e.toLowerCase();l.includes(r)&&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 l=t.getPageSize(),r=Math.floor(e.rowIndex/l);r!==t.getCurrentPage()&&t.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const 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,l=this.matches.findIndex(r=>r.rowIndex===n&&r.colId===a);o.classList.toggle("ag-find-match",l>=0),o.classList.toggle("ag-find-active-match",l>=0&&l===this.activeMatch)}}}}class gs{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((r,c)=>{r.id===o.id&&(a=c)}),a<0)return;const l=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(l.rowStartIndex,a),rowEndIndex:Math.max(l.rowStartIndex,a),colStartId:l.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(l.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 l=0,r=0;for(let h=0;h<=a;h++)h<o?l+=t[h].width:r+=t[h].width;const d=this.grid.getRowRenderer().getRowOffsets(),u=Math.min(e.rowStartIndex,e.rowEndIndex),p=Math.max(e.rowStartIndex,e.rowEndIndex),g=d[u]??u*(this.grid.getOptions().rowHeight??42);let C=0;for(let h=u;h<=p;h++){const f=this.grid.getDisplayedRowAtIndex(h);C+=f?this.grid.getRowHeight(f):this.grid.getOptions().rowHeight??42}return{top:g,left:l,width:r,height:C}}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((l,r)=>{l.id===n&&(a=r)}),!(a<0))for(const l of o.getCellElements()){const r=l.dataset.colid,c=i.findIndex(p=>p.colId===r);let d=!1,u=!1;for(const p of e){const g=i.findIndex(R=>R.colId===p.colStartId),C=i.findIndex(R=>R.colId===p.colEndId),h=Math.min(p.rowStartIndex,p.rowEndIndex),f=Math.max(p.rowStartIndex,p.rowEndIndex),m=Math.min(g,C),b=Math.max(g,C);a>=h&&a<=f&&c>=m&&c<=b&&(d=!0,a===p.rowStartIndex&&c===g&&(u=!0))}l.classList.toggle("ag-cell-range-selected",d),l.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),l=Math.min(i,n),r=Math.max(i,n),c=[];for(let d=o;d<=a;d++){const u=this.grid.getDisplayedRowAtIndex(d);if(u)for(let p=l;p<=r;p++)t[p]&&c.push({node:u,column:t[p]})}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===_i||e.keyCode===Ui)&&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 dn(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const ct=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class fs{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(r=>r.aggFunc),a=[],l=o.map(()=>[]);if(i.length>0)((c,d)=>{for(const u of c)if(u.group){const p=i[0]?String(me(i[0],u,this.grid.getApi())??""):u.key??"";a.push(p);for(let g=0;g<o.length;g++){const C=[];un(u,o[g],C),l[g].push(Number(Vt(o[g],o[g].aggFunc,C))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(n||(n=this.grid.getColumns().center.find(r=>r.field&&r.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(r=>{if(r.group||r.footer)return;const c=n?me(n,r,this.grid.getApi()):"";a.push(String(c??""));for(let d=0;d<o.length;d++){const u=me(o[d],r,this.grid.getApi());l[d].push(typeof u=="number"?u:Number(u)||0)}}),a.length>200){const r=Math.ceil(a.length/200),c=[],d=l.map(()=>[]);for(let u=0;u<a.length;u+=r){c.push(a[u]);for(let p=0;p<l.length;p++)d[p].push(l[p][u])}return{categories:c,series:o.map((u,p)=>({title:u.headerName,data:d[p]}))}}return{categories:a,series:o.map((r,c)=>({title:r.headerName,data:l[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 f of o){const m=document.createElement("option");m.value=f.value,m.textContent=f.label,f.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 l=document.createElement("select");l.className="ag-chart-panel-select";const r=this.grid.getColumnModel().getRowGroupColumns(),c=r.length>0?r:this.grid.getColumns().center.filter(f=>f.field);for(const f of c){const m=document.createElement("option");m.value=f.colId,m.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${f.headerName}`:f.headerName,l.appendChild(m)}e.appendChild(l);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(f=>f.aggFunc),p=document.createElement("div");p.className="ag-chart-panel-series";const g=new Set(u.slice(0,3).map(f=>f.colId));for(const f of this.grid.getColumns().center.filter(m=>m.field)){const m=document.createElement("label");m.className="ag-chart-panel-series-item";const b=document.createElement("input");b.type="checkbox",b.checked=g.has(f.colId),b.addEventListener("change",()=>{b.checked?g.add(f.colId):g.delete(f.colId)}),m.appendChild(b);const R=document.createElement("span");R.textContent=f.headerName,m.appendChild(R),p.appendChild(m)}e.appendChild(p);const C=document.createElement("button");C.className="ag-button ag-button-primary ag-chart-panel-create",C.textContent=this.grid.t("createChart"),C.addEventListener("click",()=>{const f=this.grid.getColumn(l.value)||void 0,m=[...g].map(b=>this.grid.getColumn(b)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:f,valueColumns:m})}),e.appendChild(C);const h=document.createElement("div");if(h.className="ag-chart-panel-list",this.charts.size===0){const f=document.createElement("div");f.className="ag-side-bar-empty",f.textContent=this.grid.t("noChartsCreated"),h.appendChild(f)}for(const[f,m]of this.charts){const b=document.createElement("div");b.className="ag-chart-panel-list-item";const R=document.createElement("span");R.textContent=m.title,b.appendChild(R);const k=document.createElement("button");k.className="ag-column-group-remove",k.textContent="×",k.addEventListener("click",()=>this.destroyChart(f)),b.appendChild(k),h.appendChild(b)}return e.appendChild(h),e}createChart(e={}){var f,m,b,R;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 l=document.createElement("div");l.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=o,l.appendChild(r);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent=this.grid.t("downloadPng"),l.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)),l.appendChild(d),a.appendChild(l);const u=document.createElement("div");u.className="ag-chart-window-body";const p=document.createElement("canvas");p.className="ag-chart-canvas",p.width=600,p.height=360,u.appendChild(p);const g=document.createElement("div");g.className="ag-chart-tooltip",g.style.display="none",u.appendChild(g),p.addEventListener("mousemove",k=>this.onChartHover({id:n,ePopup:a,canvas:p,type:t,data:i,title:o},k,g)),p.addEventListener("mouseleave",()=>{g.style.display="none"});const C=document.createElement("div");C.className="ag-chart-legend",u.appendChild(C),a.appendChild(u),this.timeSeries=i.categories.length>0&&i.categories.every(k=>!isNaN(Date.parse(String(k)))&&isNaN(Number(k)));const h={id:n,ePopup:a,canvas:p,type:t,data:i,title:o};return this.charts.set(n,h),c.addEventListener("click",()=>{const k=p.toDataURL("image/png"),y=document.createElement("a");y.href=k,y.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,y.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=(f=this.grid.getOptions()).onChartCreated)==null||m.call(f,{chartId:n,chartTitle:o,api:this.grid.getApi()}),((b=this.grid.getSideBarService())==null?void 0:b.getActivePanel())==="charts"&&((R=this.grid.getSideBarService())==null||R.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),l=360/(o.height||1),r=(t.clientX-o.left)*a,c=(t.clientY-o.top)*l,d={top:20,right:20,bottom:34,left:56},u=600-d.left-d.right,p=360-d.top-d.bottom;if(r<d.left||r>d.left+u||c<d.top||c>d.top+p){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const g=e.type==="bar",C=Math.max(1,e.data.categories.length),h=(g?p:u)/C,f=Math.floor((g?c-d.top:r-d.left)/h);if(f<0||f>=e.data.categories.length){i.style.display="none";return}const m=e.data.series.map(b=>`${b.title}: ${this.formatTick(b.data[f]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${dn(e.data.categories[f])}</div>`+m.map(b=>`<div>${dn(b)}</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 l=document.createElement("div");l.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,l.appendChild(r);const c=document.createElement("div");c.className="ag-chart-legend",l.appendChild(c),i.appendChild(l);const d={id:t,ePopup:i,canvas:r,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 l=getComputedStyle(this.grid.getRootElement()),r=l.getPropertyValue("--ag-chart-text-color")||"#666",c=l.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,p=a-d.top-d.bottom;i.font="11px sans-serif",i.fillStyle=r,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,B)=>{const E=document.createElement("span");E.className="ag-chart-legend-item";const S=document.createElement("span");S.className="ag-chart-legend-swatch",S.style.backgroundColor=ct[B%ct.length],E.appendChild(S),E.appendChild(document.createTextNode(W.title)),g.appendChild(E)})),e.type==="pie"){this.renderPie(i,e.data,o,a,r);return}const C=e.data.series.flatMap(W=>W.data);let h=Math.max(0,...C),f=Math.min(0,...C);e.type==="scatter"&&(f=Math.min(...C),h=Math.max(...C));const m=h-f||1;h+=m*.08,f-=f<0?m*.08:0;const b=h-f||1,R=W=>d.top+p-(W-f)/b*p,k=5;i.textAlign="right",i.textBaseline="middle";for(let W=0;W<=k;W++){const B=f+b*W/k,E=R(B);i.beginPath(),i.moveTo(d.left,E),i.lineTo(o-d.right,E),i.stroke(),i.fillText(this.formatTick(B),d.left-6,E)}const y=e.data.categories,M=e.type==="bar",P=Math.max(1,y.length),D=(M?p:u)/P;if(M){i.textAlign="left",y.forEach((B,E)=>{const S=d.top+E*D,$=Math.max(2,D*.7/e.data.series.length);e.data.series.forEach((z,q)=>{const ee=z.data[E]||0,se=Math.abs(ee)/b*u,V=d.left+(0-f)/b*u;i.fillStyle=ct[q%ct.length],i.fillRect(V,S+q*$,Math.max(1,se),$-1)}),i.fillStyle=r,i.fillText(this.truncate(B,18),d.left+4,S+D/2)});const W=d.left+(0-f)/b*u;i.beginPath(),i.moveTo(W,d.top),i.lineTo(W,d.top+p),i.strokeStyle=r,i.stroke()}else{const W=Math.max(1,Math.ceil(P/12));i.textAlign="center",i.textBaseline="top",y.forEach((S,$)=>{if($%W!==0)return;const z=d.left+D*($+.5);i.fillStyle=r,i.fillText(this.truncate(S,10),z,d.top+p+6)});const B=e.data.series.length,E=Math.max(1,D*.7/Math.max(1,B));e.data.series.forEach((S,$)=>{const z=ct[$%ct.length];if(e.type==="column")i.fillStyle=z,S.data.forEach((q,ee)=>{const se=d.left+D*ee+(D-E*B)/2+$*E,V=R(q);i.fillRect(se,V,E-1,d.top+p-V)});else if(e.type==="area"){i.beginPath(),S.data.forEach((ee,se)=>{const V=d.left+D*(se+.5),U=R(ee);se===0?i.moveTo(V,U):i.lineTo(V,U)});const q=d.left+D*(S.data.length-.5);i.lineTo(q,d.top+p),i.lineTo(d.left+D*.5,d.top+p),i.closePath(),i.globalAlpha=.25,i.fillStyle=z,i.fill(),i.globalAlpha=1,i.beginPath(),S.data.forEach((ee,se)=>{const V=d.left+D*(se+.5),U=R(ee);se===0?i.moveTo(V,U):i.lineTo(V,U)}),i.strokeStyle=z,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=z,S.data.forEach((q,ee)=>{const se=d.left+D*(ee+.5),V=R(q);i.beginPath(),i.arc(se,V,3,0,Math.PI*2),i.fill()})):(i.beginPath(),S.data.forEach((q,ee)=>{const se=d.left+D*(ee+.5),V=R(q);ee===0?i.moveTo(se,V):i.lineTo(se,V)}),i.strokeStyle=z,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,n,o){const a=t.series[0];if(!a)return;const l=a.data.reduce((p,g)=>p+Math.abs(g),0)||1,r=i/2,c=n/2,d=Math.min(i,n)/2-30;let u=-Math.PI/2;a.data.forEach((p,g)=>{const C=Math.abs(p)/l*Math.PI*2;e.beginPath(),e.moveTo(r,c),e.arc(r,c,d,u,u+C),e.closePath(),e.fillStyle=ct[g%ct.length],e.fill();const h=u+C/2,f=r+Math.cos(h)*(d*.7),m=c+Math.sin(h)*(d*.7),b=Math.round(Math.abs(p)/l*100);b>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${b}%`,f,m)),u+=C}),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 un(s,e,t){const i=s.children;if(!i||i.length===0){const n=me(e,s,null);typeof n=="number"&&!isNaN(n)&&t.push(n);return}for(const n of i)un(n,e,t)}class ms{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 vs=(()=>{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 Cs(s){let e=4294967295;for(let t=0;t<s.length;t++)e=vs[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function hn(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 ws(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 bs(s){const e=new TextEncoder,t=[],i=[];let n=0;for(const u of s){const p=e.encode(u.name),g=Cs(u.data),C=new Uint8Array(30+p.length),h=new DataView(C.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,p.length,!0),h.setUint16(28,0,!0),C.set(p,30),t.push(C,u.data);const f=new Uint8Array(46+p.length),m=new DataView(f.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,p.length,!0),m.setUint32(42,n,!0),f.set(p,46),i.push(f),n+=C.length+u.data.length}const o=i.reduce((u,p)=>u+p.length,0),a=new Uint8Array(22),l=new DataView(a.buffer);l.setUint32(0,101010256,!0),l.setUint16(8,s.length,!0),l.setUint16(10,s.length,!0),l.setUint32(12,o,!0),l.setUint32(16,n,!0);const r=t.reduce((u,p)=>u+p.length,0)+o+a.length,c=new Uint8Array(r);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 ys(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(l=>l.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${n}"${a}>`,t.forEach((l,r)=>{const c=`${ws(r)}${n}`,d=l.bold?' s="1"':"";if(l.value===null||l.value===void 0||l.value===""){e+=`<c r="${c}"${d}/>`;return}typeof l.value=="number"&&isFinite(l.value)?e+=`<c r="${c}"${d}><v>${l.value}</v></c>`:typeof l.value=="boolean"?e+=`<c r="${c}"${d} t="b"><v>${l.value?1:0}</v></c>`:e+=`<c r="${c}"${d} t="inlineStr"><is><t xml:space="preserve">${hn(String(l.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const Ss='<?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 xs(s){const e=new TextEncoder,t=(u,p)=>u.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${p+1}`;let i="",n="",o="";s.forEach((u,p)=>{const g=t(u.name,p),C=p+1;i+=`<sheet name="${hn(g)}" sheetId="${C}" r:id="rId${C}"/>`,n+=`<Relationship Id="rId${C}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${C}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${C}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const a='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+o+"</Types>",l='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${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(l)},{name:"xl/workbook.xml",data:e.encode(r)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(c)},{name:"xl/styles.xml",data:e.encode(Ss)}];return s.forEach((u,p)=>{d.push({name:`xl/worksheets/sheet${p+1}.xml`,data:e.encode(ys(u.rows))})}),new Blob([bs(d)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const Es={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function pn(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function Rs(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 ks(){return new TextEncoder}function Ms(s,e={}){const[t,i]=Es[e.pageSize||"a4-landscape"],n=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,l=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],c=ks(),d=[],u=b=>(d.push(b),d.length);u(""),u("");const p=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),g=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),C=[];for(const b of s){let R="";const k=b.columnWidths.reduce((S,$)=>S+$,0),y=Math.min(1,(t-n*2)/(k||1)),M=b.columnWidths.map(S=>S*y),P=n;let D=i-n-(e.title?24:0);e.title&&(R+=`BT /F2 ${o+4} Tf ${P} ${D} Td (${pn(e.title)}) Tj ET
4
- `,D-=18),b.rows.forEach((S,$)=>{var se;const z=$===0,q=((se=b.rowFill)==null?void 0:se[$])??(z?l:void 0);q&&(R+=`${q[0]} ${q[1]} ${q[2]} rg ${P} ${(D-a+4).toFixed(2)} ${k*y} ${a} re f
5
- `);let ee=P;S.forEach((V,U)=>{const Z=M[U]??0,K=pn(Rs(V.text??"",Z-6,o)),oe=V.bold||z?g:p,ve=(V.text??"").length*o*.5;let he=ee+3;V.align==="right"||!V.align&&U>0&&/^-?[\d,.%$£€\s]+$/.test(V.text??"")?he=ee+Z-3-Math.min(ve,Z-6):V.align==="center"&&(he=ee+(Z-Math.min(ve,Z-6))/2),R+=`BT /F${oe===g?2:1} ${o} Tf ${he.toFixed(2)} ${(D-o+2).toFixed(2)} Td (${K}) Tj ET
6
- `,ee+=Z}),R+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${P} ${(D-a+4).toFixed(2)} m ${(P+k*y).toFixed(2)} ${(D-a+4).toFixed(2)} l S
7
- `,D-=a});const j=b.rows.length*a;R+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${P} ${(D+a-4).toFixed(2)} m ${P} ${(D+j+a-4).toFixed(2)} l ${(P+k*y).toFixed(2)} ${(D+j+a-4).toFixed(2)} l ${(P+k*y).toFixed(2)} ${(D+a-4).toFixed(2)} l S
8
- `;const W=c.encode(R),B=u(`<< /Length ${W.length} >>
1
+ (function(j,Ae){typeof exports=="object"&&typeof module<"u"?Ae(exports):typeof define=="function"&&define.amd?define(["exports"],Ae):(j=typeof globalThis<"u"?globalThis:j||self,Ae(j.Rowvia={}))})(this,function(j){"use strict";var Xa=Object.defineProperty;var Za=(j,Ae,pt)=>Ae in j?Xa(j,Ae,{enumerable:!0,configurable:!0,writable:!0,value:pt}):j[Ae]=pt;var w=(j,Ae,pt)=>Za(j,typeof Ae!="symbol"?Ae+"":Ae,pt);function H(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let Jn=0;function Gt(s="id"){return`${s}-${++Jn}`}function He(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 zt(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function es(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 ts(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ie extends Error{constructor(e){super(e),this.code=e}}const is=/^\$?[A-Za-z]{1,3}\$?\d+$/;function Ci(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++];is.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 Ie("#NAME?")}return e}const yi={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function bi(s){let e=0;const t=()=>s[e],i=()=>s[e++];function n(r=0){let d=o();for(;t()&&t().type==="op"&&yi[t().value]>=r;){const c=i().value,p=n(yi[c]+1);d={type:"binary",operator:c,left:d,right:p}}return d}function o(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){i();const d=o();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return a()}function a(){const r=i();if(!r)throw new Ie("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=t();if(c&&c.type==="lparen"){i();const p=[];if(t()&&t().type!=="rparen")for(p.push(n());t()&&t().type==="comma";)i(),p.push(n());if(!t()||t().type!=="rparen")throw new Ie("#ERROR!");return i(),{type:"call",name:d,args:p}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=n();if(!t()||t().type!=="rparen")throw new Ie("#ERROR!");return i(),d}throw new Ie("#ERROR!")}const l=n();if(e<s.length)throw new Ie("#ERROR!");return l}function te(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 tt(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...tt(t));else if(t!=null&&t!==""){const i=typeof t=="number"?t:Number(t);isNaN(i)||e.push(i)}return e}const Rt={SUM:s=>tt(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=tt(s);return e.length?e.reduce((t,i)=>t+i,0)/e.length:0},AVG:s=>Rt.AVERAGE(s,{}),MIN:s=>{const e=tt(s);return e.length?Math.min(...e):0},MAX:s=>{const e=tt(s);return e.length?Math.max(...e):0},COUNT:s=>tt(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(te(s[0])),ROUND:s=>{const e=s.length>1?te(s[1]):0,t=Math.pow(10,e);return Math.round(te(s[0])*t)/t},FLOOR:s=>Math.floor(te(s[0])),CEIL:s=>Math.ceil(te(s[0])),CEILING:s=>Math.ceil(te(s[0])),SQRT:s=>{const e=te(s[0]);return e<0?(()=>{throw new Ie("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(te(s[0]),te(s[1])),POW:s=>Math.pow(te(s[0]),te(s[1])),MOD:s=>{const e=te(s[1]);if(e===0)throw new Ie("#DIV/0!");return te(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?te(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?te(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,te(s[1])-1),i=s.length>2?te(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=>te(s[0]),NUMBER:s=>te(s[0]),BETWEEN:s=>te(s[0])>=te(s[1])&&te(s[0])<=te(s[2])},Mt=Object.keys(Rt);function ns(s,e){Rt[s.toUpperCase()]=e,Mt.includes(s.toUpperCase())||Mt.push(s.toUpperCase())}function ss(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 os(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 ft(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return os(s.value,e);case"cell":return ss(s.value,e);case"unary":return-te(ft(s.operand,e));case"call":{const t=Rt[s.name];if(!t)throw new Ie("#NAME?");const i=s.args.map(n=>ft(n,e));return t(i,e)}case"binary":{const t=ft(s.left,e),i=ft(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:te(t)+te(i);case"-":return te(t)-te(i);case"*":return te(t)*te(i);case"/":{const n=te(i);if(n===0)throw new Ie("#DIV/0!");return te(t)/n}case"^":return Math.pow(te(t),te(i));case"%":{const n=te(i);if(n===0)throw new Ie("#DIV/0!");return te(t)%n}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return te(t)<te(i);case"<=":return te(t)<=te(i);case">":return te(t)>te(i);case">=":return te(t)>=te(i);default:throw new Ie("#ERROR!")}}default:throw new Ie("#ERROR!")}}function gt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,i=bi(Ci(t));return ft(i,e)}function _t(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function Wt(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 oe(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"?r=>_t(a)?gt(a,{data:r.data}):Wt(r.data,a):a)({data:n?e.groupData:e.data,node:e,column:s,api:t,colDef:i,getValue:r=>Wt(n?e.groupData:e.data,r)});if(s.field&&_t(s.field))return gt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return gt(`=${s.field}`,{data:e.data});if(s.field)return Wt(o,s.field)}function kt(s,e,t){var o;const i=oe(s,e,t),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"?l=>as(l.colDef.valueFormatter,l.value,l):n.valueFormatter)({value:i,data:e.data,node:e,column:s,api:t,colDef:n}):rs(s,i)}function as(s,e,t={}){var i,n,o;if(e==null)return"";switch(s){case"number":return He(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${He(e,((n=t.column)==null?void 0:n.decimals)??2)}`;case"percent":return`${He(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Si(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Si(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 rs(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?He(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Si(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Ei(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?i=>xi(i.colDef.valueParser,i.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):xi(s.type,e)}function xi(s,e){if(s==="numberColumn")return zt(e);if(s==="dateColumn"){if(e instanceof Date)return e;const t=new Date(e);return isNaN(t.getTime())?e:t}return s==="booleanColumn"?e===!0||e==="true":e}function Ri(s){const t=s.colDef.comparator,i=s.type;return(n,o)=>{const a=oe(s,n,null),l=oe(s,o,null);if(t)return t(a,l,n,o);if(i==="numberColumn"){const r=typeof a=="number"?a:zt(a),d=typeof l=="number"?l:zt(l);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(i==="dateColumn"){const r=a instanceof Date?a.getTime():new Date(a).getTime(),d=l instanceof Date?l.getTime():new Date(l).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return es(a,l)}}function mt(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}}function ls(s){const e={onInteraction:s.onInteraction,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 oe(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 l=s.getRowNode(a);l&&s.getSelectionService().selectNode(l,!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()}}}class We{constructor(e,t,i){w(this,"id");w(this,"__id");w(this,"data");w(this,"parent",null);w(this,"children",null);w(this,"group",!1);w(this,"key",null);w(this,"level",0);w(this,"uiLevel",0);w(this,"rowGroupIndex");w(this,"expanded",!1);w(this,"selectable",!0);w(this,"selected",!1);w(this,"rowPinned",null);w(this,"detailNode",null);w(this,"masterNode",null);w(this,"footer",!1);w(this,"groupData",null);w(this,"rowHeight",null);w(this,"allChildrenCount",null);w(this,"stub",!1);w(this,"rowIndex",null);w(this,"__displayIndex");w(this,"services");w(this,"__passesFilter",!0);w(this,"__childCount",0);w(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=Gt("row"),this.id=i??this.__id}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 ds{constructor(e){w(this,"options");w(this,"eventService");w(this,"columns");w(this,"getFilterModel");w(this,"getQuickFilter");w(this,"isPaginationEnabled");w(this,"getPageSize");w(this,"getCurrentPage");w(this,"rowHeightProvider");w(this,"rowNodeServices");w(this,"rowData",[]);w(this,"rootRowNodes",[]);w(this,"dataRows",[]);w(this,"rowsToDisplay",[]);w(this,"rowNodeMap",new Map);w(this,"expandedGroups",new Set);w(this,"groupDefaultExpandedApplied",!1);w(this,"pinnedTopRows",[]);w(this,"pinnedBottomRows",[]);w(this,"totalRowCount",0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getFilterModel=e.getFilterModel,this.getQuickFilter=e.getQuickFilter,this.isPaginationEnabled=e.isPaginationEnabled,this.getPageSize=e.getPageSize,this.getCurrentPage=e.getCurrentPage,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices}getType(){return"clientSide"}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.rootRowNodes}getRowCount(){return this.rowsToDisplay.length}getTotalRowCount(){return this.totalRowCount}getRow(e){return this.rowsToDisplay[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.rowsToDisplay.forEach((t,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],l=t?t({data:a,level:0}):void 0,r=this.createRowNode(a,l);r.rowIndex=o,n.push(r)}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 We(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||(d=>String(d.id??d.key).split("/")),n=this.options.treeDataChildrenField||"children",o=new Map,a=[],l=(d,c,p)=>{const f=i(d),u=f.join("/"),h=t?t({data:d,level:p}):u,g=this.createRowNode(d,h,c,p);g.key=f[f.length-1],o.set(u,g);const v=d[n];if(Array.isArray(v)&&v.length){g.children=[],g.group=!0,g.expanded=!0;for(const m of v){const C=l(m,g,p+1);g.children.push(C)}g.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(g),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||a.push(g),g},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const p of d.children)c+=r(p);return d.allChildrenCount=c,c};for(const d of a)r(d);for(const d of e){if(!d)continue;const p=i(d).slice(0,-1).join("/"),f=p&&o.get(p)||null;l(d,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(l=>{const r=t?t({data:l,level:0}):l.id;return String(r)===String(o)?n:l}),a.data=n,i.update.push(a);else{const l=this.createRowNode(n,o!==void 0?String(o):void 0);this.rowData.push(n),i.add.push(l)}}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,l=this.createRowNode(o,a);i.add.push(l),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,l=h=>{for(const[g,v]of Object.entries(e)){const m=o.find(C=>C.colId===g);if(m&&!this.doesNodePassFilter(h,m,v))return!1}return!0},r=h=>{const g=this.options.__advancedFilterPass;return g?g(h):!0},d=Object.entries(e).some(([h,g])=>{const v=o.find(m=>m.colId===h);return!v||!v.aggFunc?!1:g.filterType==="multi"?(g.filterModels||[]).length>0:!0}),c=h=>{if(h.__passesFilter=!0,h.children)for(const g of h.children)c(g)},p=h=>{const g=this.options;return typeof g.isExternalFilterPresent!="function"||!g.isExternalFilterPresent()||typeof g.doesExternalFilterPass!="function"?!0:g.doesExternalFilterPass(h)},f=h=>{if(!n)return!0;const g=t.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of v){const C=oe(m,h,null);if(ts(g,C))return!0}return!1},u=h=>{let g=!0;if(!h.group||h.footer||a?g=(!i||l(h))&&f(h)&&p(h)&&r(h):d&&(g=(!i||l(h))&&r(h)),h.__passesFilter=g,h.children){let v=!1;for(const m of h.children)u(m)&&(v=!0);return h.group&&!h.footer&&(d?(h.__passesFilter=g,g&&c(h)):(h.__passesFilter=a?v||g:v,a&&g&&c(h))),h.__passesFilter}return g};for(const h of this.rootRowNodes)u(h)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const c=[];Lt(e,c);const p=c.map(f=>oe(t,f,null));r=mt(t,t.aggFunc,p)}const d={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,t,i)}if(i.filterType==="multi"){const r=i.filterModels||[];if(r.length===0)return!0;const d=i.operator||"AND",c=r.map(p=>this.doesNodePassFilter(e,t,p));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(i.condition1||i.condition2){const{condition1:r,condition2:d,...c}=i,p=[this.doesNodePassFilter(e,t,{...c,...r||{}})];return d&&p.push(this.doesNodePassFilter(e,t,{...c,...d})),(i.operator||"AND")==="OR"?p.some(Boolean):p.every(Boolean)}const n=oe(t,e,null),o=us(t,n),a=n,l=i.filterType||"text";if(l==="text"){const r=String(i.filter??"").toLowerCase();if(!r)return!0;const d=(a==null?"":String(a)).toLowerCase();switch(i.type){case"equals":return d===r;case"notEqual":return d!==r;case"startsWith":return d.startsWith(r);case"endsWith":return d.endsWith(r);case"contains":default:return d.includes(r)}}if(l==="number"){const r=typeof a=="number"?a:Number(a);if(isNaN(r))return!1;const d=Number(i.filter),c=i.filterTo!==void 0&&i.filterTo!==null&&i.filterTo!==""?Number(i.filterTo):null;switch(i.type){case"equals":return r===d;case"notEqual":return r!==d;case"lessThan":return r<d;case"lessThanOrEqual":return r<=d;case"greaterThan":return r>d;case"greaterThanOrEqual":return r>=d;case"inRange":return c!==null?r>=Math.min(d,c)&&r<=Math.max(d,c):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(l==="date"){const r=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(r))return!1;const d=i.dateFrom?new Date(i.dateFrom).getTime():null,c=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return l==="boolean"?!!a==!!i.filter:l==="set"?(i.values||[]).map(d=>String(d)).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,l)=>(a.column.sortIndex??0)-(l.column.sortIndex??0));const n=(a,l)=>{for(const{column:c,direction:p}of t){const f=Ri(c)(a,l)*(p==="asc"?1:-1);if(f!==0)return f}const r=a.rowIndex??0,d=l.rowIndex??0;return r-d},o=a=>{a.sort(n);for(const l of a)l.children&&o(l.children)};if(e.length===0)o(this.rootRowNodes);else for(const a of this.rootRowNodes)a.children&&o(a.children)}doGroup(e){if(e.length===0)return;const t=this.columns().filter(d=>d.aggFunc&&!d.rowGroup),i=(d,c,p,f)=>{if(c>=e.length)return d;const u=e[c],h=new Map,g=[];for(const m of d){if(!m.__passesFilter)continue;const C=oe(u,m,null),S=cs(C);h.has(S)||(h.set(S,[]),g.push(S)),h.get(S).push(m)}const v=[];for(const m of g){const C=h.get(m),S=`${f}|${u.colId}:${m}`,b=this.rowNodeMap.get(S),y=b||new We({[u.colId]:m},this.rowNodeServices,S);y.group=!0,y.key=m,y.level=p,y.uiLevel=p,y.parent=null,y.children=i(C,c+1,p+1,S);for(const T of y.children)T.parent=y;y.allChildrenCount=Mi(y),y.data={...y.data};const R=[];Lt(y,R);const M={};for(const T of t){const W=R.map(E=>oe(T,E,null));M[T.colId]=mt(T,T.aggFunc,W)}M[u.colId]=m,y.groupData=M,b||this.rowNodeMap.set(S,y),v.push(y)}return v},n=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=i(o,0,0,""),l=d=>{for(const c of d){if(!c.group)continue;const p=Tt(c),f=this.expandedGroups.has(p);n===-1||f?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<n,c.expanded&&this.expandedGroups.add(p),c.children&&l(c.children)}};l(a),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const p=e[c],f=p.sort==="desc"?-1:1,u=Ri(p);d.sort((h,g)=>{const v=oe(p,h,null),m=oe(p,g,null);return u({...h,data:{[p.colId]:v}},{...g,data:{[p.colId]:m}})*f})};e[0].sort&&r(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],i=!!this.options.treeData,n=(a,l)=>{if(a.uiLevel=l,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||i)){const r=a.group?a.children.filter(d=>d.__passesFilter||d.group):a.children;if(a.expanded){for(const d of r)n(d,l+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const d=this.createFooterNode(a,l+1);t.push(d)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&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(),l=this.getCurrentPage();let r=0,d=-1;for(let p=0;p<o.length;p++)if(!o[p].masterNode){if(r===l*a){d=p;break}r++}d<0&&(d=o.length);let c=d;for(r=0;c<o.length&&r<a;)o[c].masterNode||r++,c++;for(;c<o.length&&o[c].masterNode;)c++;this.rowsToDisplay=o.slice(d,c)}else this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,l)=>a.__displayIndex=l)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const i=`${e.id}|footer`;let n=this.rowNodeMap.get(i);return n||(n=new We(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 We(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(l=>l.aggFunc&&!l.rowGroup),o=[];for(const l of this.rootRowNodes)l.group?Lt(l,o):l.__passesFilter&&o.push(l);const a={};for(const l of n){const r=o.map(d=>oe(l,d,null));a[l.colId]=mt(l,l.aggFunc,r)}return a.__grandTotal=!0,i.groupData=a,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Tt(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(Tt(e)):this.expandedGroups.delete(Tt(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 cs(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Tt(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Mi(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Mi(t),0)}function Lt(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Lt(t,e)}function us(s,e){return e}const hs={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 ps(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 fs(s){return!!s.treeData}function gs(){return{applyAggregate:mt}}class ki{constructor(e,t,i){w(this,"options");w(this,"eventService");w(this,"gridApi");w(this,"measureCtx",null);w(this,"gridColumnDefs",[]);w(this,"columns",[]);w(this,"displayOrder",[]);w(this,"autoGroupColumnDef");w(this,"pivotMode",!1);w(this,"columnGroups",[]);w(this,"openGroups",new Set);w(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=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=Ti){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 l=i[a],r={field:a,headerName:t(a)};typeof l=="number"?(r.type="numberColumn",r.filter="number"):typeof l=="boolean"?r.type="booleanColumn":l instanceof Date&&(r.type="dateColumn"),o.push(r)}return o}getColumnGroups(){return this.columnGroups}getGroupDepth(){return this.columnGroups.reduce((e,t)=>Math.max(e,t.depth),0)}isGroupOpen(e){return this.openGroups.has(e)}setGroupOpen(e,t){t?this.openGroups.add(e):this.openGroups.delete(e),this.updateVisible(),this.refreshAll()}getColumnDefs(){return this.gridColumnDefs}buildColumns(){const e=this.columns,t=new Map;for(const c of e)t.set(c.colId,c);const i=this.options.defaultColDef||{},n={...hs,...this.options.columnTypes||{}},o=[],a=[];let l=0;const r=(c,p)=>{const f=c.colId||c.field||Gt("col"),u={...i,...c};if(u.type&&n[u.type]){const h=n[u.type],g=new Set(Object.keys(c));for(const[v,m]of Object.entries(h))!g.has(v)&&!(v in i)&&(u[v]=m)}this.pushColumnInto(o,u,f,l++,t,p)},d=(c,p,f)=>{for(const u of c)if(u.children&&u.children.length){const h=u.groupId||Gt("group"),g={id:h,headerName:u.headerName??"",openByDefault:u.openByDefault===!0||u.columnGroupShow==="open",parentId:p,depth:f,childColumnIds:[]};a.push(g),this.groupsInitialised||(g.openByDefault?this.openGroups.add(h):this.openGroups.delete(h)),d(u.children,h,f+1)}else r(u,p)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,this.options.rowNumbers){const c={colId:"__rowNumber",headerName:"",width:60,pinned:"left",sortable:!1,filter:!1,resizable:!1,suppressMovable:!0,cellRenderer:"agRowNumberCellRenderer",cellClass:"ag-row-number-cell"};this.pushColumnInto(o,{...i,...c},"__rowNumber",-1,t,null)}for(const c of o){if(!c.groupId)continue;const p=a.find(f=>f.id===c.groupId);p&&p.childColumnIds.push(c.colId)}this.columns=o,this.displayOrder=o.map(c=>c.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,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),l=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?Ti(e.field):""),headerTooltip:e.headerTooltip,colDef:e,width:e.width??e.minWidth??(e.flex?200:100),minWidth:e.minWidth??20,maxWidth:e.maxWidth??Number.MAX_SAFE_INTEGER,flex:e.flex??null,pinned:e.pinned??null,hide:l,visible:!l,lockPosition:e.lockPosition??!1,type:e.type,sortable:e.sortable??!!e.field,sort:e.sort??null,sortIndex:e.sortIndex??null,resizable:e.resizable??!0,filter:ps(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&&(r.pinned=a.pinned,r.visible=a.visible,r.width=a.width,r.flex=a.flex,r.sort=a.sort,r.sortIndex=a.sortIndex,r.rowGroup=a.rowGroup,r.rowGroupIndex=a.rowGroupIndex,r.pivot=a.pivot,r.pivotIndex=a.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const i=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),n=[];for(const r of t){const d=[],c=new Set;for(const p of e){const f=p==null?void 0:p[r.field],u=String(f);c.has(u)||(c.add(u),d.push(f))}d.sort((p,f)=>p===f?0:String(p)<String(f)?-1:1);for(const p of i){for(const h of d){const g=`__pivot_${r.colId}_${p.colId}_${h}`,v=this.createColumn({colId:g,headerName:`${String(h)}`,width:130,type:p.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:p.cellClass,cellDataType:p.cellDataType},g,-1,new Map,null);v.aggFunc=p.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:h,valueColumnId:p.colId,valueField:p.field},v.valueGetter=m=>this.evaluatePivotValue(v,m.node),n.push(v)}const f=`__pivot_${r.colId}_${p.colId}_total`,u=this.createColumn({colId:f,headerName:"Total",width:130,type:p.type,sortable:!1,filter:!1,cellDataType:p.cellDataType},f,-1,new Map,null);u.aggFunc=p.aggFunc,u.groupId=r.colId,u.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:p.colId,valueField:p.field},u.valueGetter=h=>this.evaluatePivotValue(u,h.node),n.push(u)}}const o=new Set(t.map(r=>r.colId)),a=this.columns.reduce((r,d,c)=>o.has(d.groupId??"")?r:c,0);this.columns.splice(a+1,0,...n);for(const r of n)this.displayOrder.push(r.colId);const l=new Set(this.columnGroups.map(r=>r.id));for(const r of t)l.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const i=e.__pivot;if(!i||!t)return;const n=[],o=c=>{if(!c.children||c.children.length===0){n.push(c);return}for(const p of c.children)o(p)};o(t);const l=(i.pivotValue===void 0?n:n.filter(c=>{var p;return String((p=c.data)==null?void 0:p[i.pivotField])===String(i.pivotValue)})).map(c=>{var p;return(p=c.data)==null?void 0:p[i.valueField]}).filter(c=>typeof c=="number");if(l.length===0)return null;const r=this.columns.find(c=>c.colId===i.valueColumnId),{applyAggregate:d}=gs();return d(r,e.aggFunc,l)}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 c of i)n==="multipleColumns"?(c.cellRenderer="agGroupCellRenderer",c.cellRendererParams={...c.cellRendererParams||{},suppressCount:!0}):c.cellRenderer==="agGroupCellRenderer"&&!c.colDef.cellRenderer&&(c.cellRenderer=void 0,c.cellRendererParams=void 0);const a=this.columns.find(c=>c.colId===e);if(!o){a&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const l={...this.autoGroupColumnDef};if(l.colId=e,a)a.headerName=l.headerName??"",a.colDef=l,a.cellRenderer=l.cellRenderer,a.cellRendererParams=l.cellRendererParams,a.width=l.width??a.width,a.minWidth=l.minWidth??a.minWidth,a.pinned=l.pinned??"left";else{const c=this.createColumn(l,e,-2,new Map,null);this.columns.unshift(c),this.displayOrder.unshift(e)}const r=this.columns.find(c=>c.colId===e),d=()=>this.getRowGroupColumns()[0];r.valueGetter=c=>{const p=c.node;if(!p)return"";if(p.key!==null&&p.key!==void 0)return p.key;if(fs(this.options))return"";const f=d();return f!=null&&f.field&&p.data?p.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,l=0;for(const d of n)t.includes(d.colId)?l+=d.width:d.flex!==null&&d.flex>0?a+=d.flex:l+=d.width;const r=Math.max(0,e-l-32);if(a>0){for(const d of n)if(d.flex!==null&&d.flex>0&&!t.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/a));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var l,r,d,c,p,f;const i=this.getColumn(e);if(!i)return;let n=this.measureTextWidth(i.headerName)+32;t||(n+=16);const o=((r=(l=this.gridApi)==null?void 0:l.getDisplayedRowCount)==null?void 0:r.call(l))??0,a=Math.min(o,300);for(let u=0;u<a;u++){const h=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,u);if(!h)continue;const g=(f=(p=this.gridApi)==null?void 0:p.getCellText)==null?void 0:f.call(p,i,h);g&&(n=Math.max(n,this.measureTextWidth(g)+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 Ti(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class ms{constructor(){w(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 Li={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:"散点图"},vs={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 ws{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Li[e]??e}}function Cs(s){return new ws(s??{})}function ys(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class bs{constructor(e){w(this,"eventService");w(this,"columns");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"stores",new Map);w(this,"rowNodeMap",new Map);w(this,"displayRows",[]);w(this,"blockSize");this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"serverSide"}setDatasource(e){this.datasource=e,this.purgeCache()}getStore(e){return this.stores.get(e)}getOrCreateStore(e){let t=this.stores.get(e);return t||(t={rows:[],lastRow:null,loading:!1,failed:!1},this.stores.set(e,t)),t}isLoading(){for(const e of this.stores.values())if(e.loading)return!0;return!1}loadBlock(e,t,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,l)=>{n.loading=!1,this.onBlockLoaded(e,a,l??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],l=(n.rows.length>0,o),r=this.createNode(a,e,o,l);n.rows[l]=r}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=ys(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${n}`,l=this.rowNodeMap.get(a),r=l instanceof We?l:new We(e,this.rowNodeServices,a);return r.data=e,r.rowIndex=i,o&&(r.group=!0,r.key=String(oe(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(a,r),r}buildDisplayRows(){const e=[],t=(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 l=`${i?i+"|":""}${a.key}`;t(l,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 l=this.stores.get(a);if(l){for(const r of l.rows)if(r){if(i>=e&&i<=t){const d=Math.floor(i/this.blockSize)*this.blockSize,c=d+this.blockSize,p=l.lastRow,f=p!==null?Math.min(p,c):c;i<(l.rows.length||0)&&d<(l.rows.length||0)||(l.lastRow===null||c<=l.lastRow)&&this.loadBlock(a,d,f)}i++,r.group&&r.expanded&&n(`${a?a+"|":""}${r.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 Ss{constructor(e){w(this,"eventService");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"blockSize");w(this,"loading",!1);this.eventService=e.eventService,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"infinite"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let 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,i.forEach((o,a)=>{const l=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let r=this.rowNodeMap.get(l);r||(r=new We(o,this.rowNodeServices,l),this.rowNodeMap.set(l,r)),r.data=o,r.rowIndex=e+a,this.nodes[e+a]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const 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.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 Es{constructor(e){w(this,"eventService");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"loading",!1);this.eventService=e.eventService,this.rowNodeServices=e.rowNodeServices}getType(){return"viewport"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}setViewportRange(e,t){if(!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((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 l=this.rowNodeMap.get(a);l||(l=new We(n,this.rowNodeServices,a),this.rowNodeMap.set(a,l)),l.data=n,l.rowIndex=e+o,this.nodes[e+o-e]=l}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}setViewportDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}onViewportChanged(e,t){this.setViewportRange(e,t)}isLoading(){return this.loading}getRowCount(){return this.nodes.filter(Boolean).length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,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}}function Ni(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const qe=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class xs{constructor(e,t){w(this,"charts",new Map);w(this,"chartCounter",0);w(this,"currentType","line");w(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),i=t.getRowGroupColumns();let n=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(r=>r.aggFunc),a=[],l=o.map(()=>[]);if(i.length>0)((d,c)=>{for(const p of d)if(p.group){const f=i[0]?String(oe(i[0],p,this.grid.getApi())??""):p.key??"";a.push(f);for(let u=0;u<o.length;u++){const h=[];Ii(p,o[u],h),l[u].push(Number(mt(o[u],o[u].aggFunc,h))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(n||(n=this.grid.getColumns().center.find(r=>r.field&&r.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(r=>{if(r.group||r.footer)return;const d=n?oe(n,r,this.grid.getApi()):"";a.push(String(d??""));for(let c=0;c<o.length;c++){const p=oe(o[c],r,this.grid.getApi());l[c].push(typeof p=="number"?p:Number(p)||0)}}),a.length>200){const r=Math.ceil(a.length/200),d=[],c=l.map(()=>[]);for(let p=0;p<a.length;p+=r){d.push(a[p]);for(let f=0;f<l.length;f++)c[f].push(l[f][p])}return{categories:d,series:o.map((p,f)=>({title:p.headerName,data:c[f]}))}}return{categories:a,series:o.map((r,d)=>({title:r.headerName,data:l[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const t=document.createElement("div");t.className="ag-side-bar-section-title",t.textContent=this.grid.t("integratedCharts"),e.appendChild(t);const 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 v of o){const m=document.createElement("option");m.value=v.value,m.textContent=v.label,v.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 l=document.createElement("select");l.className="ag-chart-panel-select";const r=this.grid.getColumnModel().getRowGroupColumns(),d=r.length>0?r:this.grid.getColumns().center.filter(v=>v.field);for(const v of d){const m=document.createElement("option");m.value=v.colId,m.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${v.headerName}`:v.headerName,l.appendChild(m)}e.appendChild(l);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent=this.grid.t("chartSeries"),e.appendChild(c);const p=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),f=document.createElement("div");f.className="ag-chart-panel-series";const u=new Set(p.slice(0,3).map(v=>v.colId));for(const v of this.grid.getColumns().center.filter(m=>m.field)){const m=document.createElement("label");m.className="ag-chart-panel-series-item";const C=document.createElement("input");C.type="checkbox",C.checked=u.has(v.colId),C.addEventListener("change",()=>{C.checked?u.add(v.colId):u.delete(v.colId)}),m.appendChild(C);const S=document.createElement("span");S.textContent=v.headerName,m.appendChild(S),f.appendChild(m)}e.appendChild(f);const h=document.createElement("button");h.className="ag-button ag-button-primary ag-chart-panel-create",h.textContent=this.grid.t("createChart"),h.addEventListener("click",()=>{const v=this.grid.getColumn(l.value)||void 0,m=[...u].map(C=>this.grid.getColumn(C)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:m})}),e.appendChild(h);const g=document.createElement("div");if(g.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent=this.grid.t("noChartsCreated"),g.appendChild(v)}for(const[v,m]of this.charts){const C=document.createElement("div");C.className="ag-chart-panel-list-item";const S=document.createElement("span");S.textContent=m.title,C.appendChild(S);const b=document.createElement("button");b.className="ag-column-group-remove",b.textContent="×",b.addEventListener("click",()=>this.destroyChart(v)),C.appendChild(b),g.appendChild(C)}return e.appendChild(g),e}createChart(e={}){var v,m,C,S;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 l=document.createElement("div");l.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=o,l.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent=this.grid.t("downloadPng"),l.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title=this.grid.t("close"),c.addEventListener("click",()=>this.destroyChart(n)),l.appendChild(c),a.appendChild(l);const p=document.createElement("div");p.className="ag-chart-window-body";const f=document.createElement("canvas");f.className="ag-chart-canvas",f.width=600,f.height=360,p.appendChild(f);const u=document.createElement("div");u.className="ag-chart-tooltip",u.style.display="none",p.appendChild(u),f.addEventListener("mousemove",b=>this.onChartHover({id:n,ePopup:a,canvas:f,type:t,data:i,title:o},b,u)),f.addEventListener("mouseleave",()=>{u.style.display="none"});const h=document.createElement("div");h.className="ag-chart-legend",p.appendChild(h),a.appendChild(p),this.timeSeries=i.categories.length>0&&i.categories.every(b=>!isNaN(Date.parse(String(b)))&&isNaN(Number(b)));const g={id:n,ePopup:a,canvas:f,type:t,data:i,title:o};return this.charts.set(n,g),d.addEventListener("click",()=>{const b=f.toDataURL("image/png"),y=document.createElement("a");y.href=b,y.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,y.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(g),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:n,chartTitle:o,api:this.grid.getApi()}),(m=(v=this.grid.getOptions()).onChartCreated)==null||m.call(v,{chartId:n,chartTitle:o,api:this.grid.getApi()}),((C=this.grid.getSideBarService())==null?void 0:C.getActivePanel())==="charts"&&((S=this.grid.getSideBarService())==null||S.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),l=360/(o.height||1),r=(t.clientX-o.left)*a,d=(t.clientY-o.top)*l,c={top:20,right:20,bottom:34,left:56},p=600-c.left-c.right,f=360-c.top-c.bottom;if(r<c.left||r>c.left+p||d<c.top||d>c.top+f){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const u=e.type==="bar",h=Math.max(1,e.data.categories.length),g=(u?f:p)/h,v=Math.floor((u?d-c.top:r-c.left)/g);if(v<0||v>=e.data.categories.length){i.style.display="none";return}const m=e.data.series.map(C=>`${C.title}: ${this.formatTick(C.data[v]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${Ni(e.data.categories[v])}</div>`+m.map(C=>`<div>${Ni(C)}</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 l=document.createElement("div");l.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,l.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",l.appendChild(d),i.appendChild(l);const c={id:t,ePopup:i,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,c),this.popupService.positionAt(i,this.grid.getRootElement()),i.style.top="60px",this.renderChart(c)}renderChart(e){var W;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 l=getComputedStyle(this.grid.getRootElement()),r=l.getPropertyValue("--ag-chart-text-color")||"#666",d=l.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},p=o-c.left-c.right,f=a-c.top-c.bottom;i.font="11px sans-serif",i.fillStyle=r,i.strokeStyle=d,i.lineWidth=1;const u=(W=e.canvas.parentElement)==null?void 0:W.querySelector(".ag-chart-legend");if(u&&(u.innerHTML="",e.data.series.forEach((E,x)=>{const k=document.createElement("span");k.className="ag-chart-legend-item";const $=document.createElement("span");$.className="ag-chart-legend-swatch",$.style.backgroundColor=qe[x%qe.length],k.appendChild($),k.appendChild(document.createTextNode(E.title)),u.appendChild(k)})),e.type==="pie"){this.renderPie(i,e.data,o,a,r);return}const h=e.data.series.flatMap(E=>E.data);let g=Math.max(0,...h),v=Math.min(0,...h);e.type==="scatter"&&(v=Math.min(...h),g=Math.max(...h));const m=g-v||1;g+=m*.08,v-=v<0?m*.08:0;const C=g-v||1,S=E=>c.top+f-(E-v)/C*f,b=5;i.textAlign="right",i.textBaseline="middle";for(let E=0;E<=b;E++){const x=v+C*E/b,k=S(x);i.beginPath(),i.moveTo(c.left,k),i.lineTo(o-c.right,k),i.stroke(),i.fillText(this.formatTick(x),c.left-6,k)}const y=e.data.categories,R=e.type==="bar",M=Math.max(1,y.length),T=(R?f:p)/M;if(R){i.textAlign="left",y.forEach((x,k)=>{const $=c.top+k*T,q=Math.max(2,T*.7/e.data.series.length);e.data.series.forEach((F,G)=>{const I=F.data[k]||0,L=Math.abs(I)/C*p,D=c.left+(0-v)/C*p;i.fillStyle=qe[G%qe.length],i.fillRect(D,$+G*q,Math.max(1,L),q-1)}),i.fillStyle=r,i.fillText(this.truncate(x,18),c.left+4,$+T/2)});const E=c.left+(0-v)/C*p;i.beginPath(),i.moveTo(E,c.top),i.lineTo(E,c.top+f),i.strokeStyle=r,i.stroke()}else{const E=Math.max(1,Math.ceil(M/12));i.textAlign="center",i.textBaseline="top",y.forEach(($,q)=>{if(q%E!==0)return;const F=c.left+T*(q+.5);i.fillStyle=r,i.fillText(this.truncate($,10),F,c.top+f+6)});const x=e.data.series.length,k=Math.max(1,T*.7/Math.max(1,x));e.data.series.forEach(($,q)=>{const F=qe[q%qe.length];if(e.type==="column")i.fillStyle=F,$.data.forEach((G,I)=>{const L=c.left+T*I+(T-k*x)/2+q*k,D=S(G);i.fillRect(L,D,k-1,c.top+f-D)});else if(e.type==="area"){i.beginPath(),$.data.forEach((I,L)=>{const D=c.left+T*(L+.5),z=S(I);L===0?i.moveTo(D,z):i.lineTo(D,z)});const G=c.left+T*($.data.length-.5);i.lineTo(G,c.top+f),i.lineTo(c.left+T*.5,c.top+f),i.closePath(),i.globalAlpha=.25,i.fillStyle=F,i.fill(),i.globalAlpha=1,i.beginPath(),$.data.forEach((I,L)=>{const D=c.left+T*(L+.5),z=S(I);L===0?i.moveTo(D,z):i.lineTo(D,z)}),i.strokeStyle=F,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=F,$.data.forEach((G,I)=>{const L=c.left+T*(I+.5),D=S(G);i.beginPath(),i.arc(L,D,3,0,Math.PI*2),i.fill()})):(i.beginPath(),$.data.forEach((G,I)=>{const L=c.left+T*(I+.5),D=S(G);I===0?i.moveTo(L,D):i.lineTo(L,D)}),i.strokeStyle=F,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,n,o){const a=t.series[0];if(!a)return;const l=a.data.reduce((f,u)=>f+Math.abs(u),0)||1,r=i/2,d=n/2,c=Math.min(i,n)/2-30;let p=-Math.PI/2;a.data.forEach((f,u)=>{const h=Math.abs(f)/l*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,p,p+h),e.closePath(),e.fillStyle=qe[u%qe.length],e.fill();const g=p+h/2,v=r+Math.cos(g)*(c*.7),m=d+Math.sin(g)*(c*.7),C=Math.round(Math.abs(f)/l*100);C>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${C}%`,v,m)),p+=h}),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 Ii(s,e,t){const i=s.children;if(!i||i.length===0){const n=oe(e,s,null);typeof n=="number"&&!isNaN(n)&&t.push(n);return}for(const n of i)Ii(n,e,t)}class Rs{constructor(e){w(this,"eGui");var d,c,p;const t=e.node,i=!!t.group,n=!!t.detailNode,o=i||n,a=t.expanded,l=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${l}px`,o){const f=document.createElement("span");f.className="ag-group-value-expanded-icon",f.classList.add(a?"ag-expanded":"ag-contracted"),f.innerHTML=a?_s:zs,r.appendChild(f);const u=document.createElement("span");u.className="ag-group-value";const h=(d=e.colDef.cellRendererParams)==null?void 0:d.innerRenderer;if(typeof h=="function"){const g=h({...e,value:e.value,valueFormatted:e.valueFormatted});g instanceof HTMLElement?u.appendChild(g):typeof g=="string"&&(u.innerHTML=g)}else u.textContent=Ds(e.value);if(r.appendChild(u),i&&t.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const g=document.createElement("span");g.className="ag-group-child-count",g.textContent=` (${t.allChildrenCount})`,r.appendChild(g)}}else{const f=document.createElement("span");f.className="ag-group-value";const u=(p=e.colDef.cellRendererParams)==null?void 0:p.innerRenderer;if(typeof u=="function"){const h=u({...e,value:e.value,valueFormatted:e.valueFormatted});h instanceof HTMLElement?f.appendChild(h):typeof h=="string"&&(f.innerHTML=h)}else f.textContent=e.valueFormatted??String(e.value??"");r.appendChild(f)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Ms{constructor(e){w(this,"eGui");w(this,"eCheckbox");this.eGui=document.createElement("span"),this.eGui.className="ag-cell-checkbox";const t=document.createElement("input");t.type="checkbox",t.className="ag-native-checkbox",t.checked=!!e.node.selected,t.addEventListener("click",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.eCheckbox.checked=!!e.node.selected,!0}}const ks='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',Ts='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class Ls{constructor(e){w(this,"eGui");w(this,"eArrow");w(this,"eOld");w(this,"eNew");w(this,"lastValue");w(this,"flashTimer",null);this.eGui=document.createElement("span"),this.eGui.className="ag-animate-show-change-cell-renderer",this.eArrow=document.createElement("span"),this.eArrow.className="ag-value-change-arrow",this.eArrow.style.display="none",this.eOld=document.createElement("span"),this.eOld.className="ag-value-change-old",this.eOld.style.display="none",this.eNew=document.createElement("span"),this.eNew.className="ag-value-change-new",this.eGui.appendChild(this.eArrow),this.eGui.appendChild(this.eOld),this.eGui.appendChild(this.eNew),this.eNew.textContent=this.formatValue(e),this.lastValue=e.value}formatValue(e){const t=e.valueFormatted??e.value;return t==null?"":String(t)}getGui(){return this.eGui}refresh(e){const t=e.value;if(t!==this.lastValue){const i=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),n=this.eNew.textContent??"";this.eArrow.innerHTML=i?ks:Ts,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 Ns{constructor(e){w(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-number-cell",this.eGui.textContent=String(e.rowIndex+1)}getGui(){return this.eGui}refresh(e){return this.eGui.textContent=String(e.rowIndex+1),!0}}class Is{constructor(e){w(this,"eGui");var r,d;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],n=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},o=e.column.width||100,a=n.height||24,l=qt(i,Math.max(20,o-16),a,n);t.appendChild(l),this.eGui=t}getGui(){return this.eGui}refresh(e){var l,r;const t=e.value||[],i=e.sparklineOptions||((r=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:r.sparklineOptions)||{},n=e.column.width||100,o=i.height||24;this.eGui.innerHTML="";const a=qt(t,Math.max(20,n-16),o,{type:i.type,direction:i.direction});return this.eGui.appendChild(a),!0}}function qt(s,e,t,i={}){var m,C,S;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(b=>typeof b=="number"?b:Number((b==null?void 0:b.value)??0));if(!o||o.length<1)return n;const a=i.type||"line",l=Math.min(...o,0),d=Math.max(...o,0)-l||1,c=((m=i.tooltip)==null?void 0:m.enabled)===!0,p=((C=i.axis)==null?void 0:C.type)||"number",f=((S=i.pointsOfInterest)==null?void 0:S.show)===!0,u=(b,y)=>p==="category"?`${b+1}: ${y}`:String(y);if(f&&o.length>1){const b=o.indexOf(Math.min(...o)),y=o.indexOf(Math.max(...o)),R=e/Math.max(1,o.length-1),M=W=>t-2-(W-l)/d*(t-4),T=(W,E)=>{const x=document.createElementNS("http://www.w3.org/2000/svg","circle");x.setAttribute("cx",String(W*R)),x.setAttribute("cy",String(M(o[W]))),x.setAttribute("r","2.5"),x.setAttribute("fill",E),n.appendChild(x)};T(0,"#4caf50"),T(o.length-1,"#f44336"),T(b,"#2196f3"),T(y,"#ff9800")}if(c){const b=document.createElementNS("http://www.w3.org/2000/svg","title");b.textContent=o.map((y,R)=>u(R,y)).join(`
3
+ `),n.appendChild(b),n.style.cursor="default"}if(a==="bar"){const b=i.direction==="vertical",y=o.length;if(b){const R=Math.max(1,e/y-1),M=t-2-(0-l)/d*(t-4);o.forEach((T,W)=>{const E=W*(e/y),x=t-2-(T-l)/d*(t-4),k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("x",String(E)),k.setAttribute("width",String(R)),k.setAttribute("y",String(Math.min(x,M))),k.setAttribute("height",String(Math.max(1,Math.abs(M-x)))),k.setAttribute("fill","currentColor"),n.appendChild(k)})}else{const R=Math.max(1,t/y-1),M=2+(0-l)/d*(e-4);o.forEach((T,W)=>{const E=W*(t/y),x=2+(T-l)/d*(e-4),k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("y",String(E)),k.setAttribute("height",String(R)),k.setAttribute("x",String(Math.min(x,M))),k.setAttribute("width",String(Math.max(1,Math.abs(M-x)))),k.setAttribute("fill","currentColor"),n.appendChild(k)})}return n}const h=e/Math.max(1,o.length-1),g=o.map((b,y)=>{const R=y*h,M=t-2-(b-l)/d*(t-4);return`${R.toFixed(1)},${M.toFixed(1)}`});if(a==="area"){const b=document.createElementNS("http://www.w3.org/2000/svg","polygon");b.setAttribute("points",`0,${t} ${g.join(" ")} ${e},${t}`),b.setAttribute("fill","currentColor"),b.setAttribute("opacity","0.2"),n.appendChild(b)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",g.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),n.appendChild(v),n}class As{constructor(e){w(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Ai,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const Nt={agGroupCellRenderer:s=>new Rs(s),agCheckboxCellRenderer:s=>new Ms(s),agSparklineCellRenderer:s=>new Is(s),agAnimateShowChangeCellRenderer:s=>new Ls(s),agRowNumberCellRenderer:s=>new Ns(s),agRowDragComp:s=>new As(s)};function Ds(s){return s==null?"":String(s)}class Fs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);this.eGui=document.createElement("input"),this.eGui.type="text",this.eGui.className="ag-cell-editor-input",this.eGui.value=e.value??"",this.eGui.addEventListener("keydown",t=>{var 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 Ps{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"cancelled",!1);var n,o;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",r=>{var d,c;r.preventDefault(),r.preventDefault(),i.value=String(Number(i.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const l=document.createElement("span");l.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",l.innerHTML="▼",l.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),i.value=String(Number(i.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),t.appendChild(a),t.appendChild(i),t.appendChild(l)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",a=>{var l;return(l=e.onKeyDown)==null?void 0:l.call(e,a)})}getGui(){return this.eGui}getValue(){if(this.cancelled)return;const e=Number(this.eInput.value);return isNaN(e)?null:e}focusIn(){this.eInput.focus(),this.eInput.select()}}class $s{constructor(e){w(this,"eGui");w(this,"cancelled",!1);var i,n;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 Hs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);this.eGui=document.createElement("input"),this.eGui.type="date",this.eGui.className="ag-cell-editor-input";const t=e.value instanceof Date?e.value:e.value?new Date(e.value):null;t&&!isNaN(t.getTime())&&(this.eGui.value=t.toISOString().slice(0,10))}getGui(){return this.eGui}getValue(){if(!this.cancelled)return this.eGui.value?new Date(this.eGui.value):null}focusIn(){this.eGui.focus()}}class Os{constructor(e){w(this,"eGui");w(this,"cancelled",!1);this.eGui=document.createElement("textarea"),this.eGui.className="ag-cell-editor-textarea",this.eGui.value=e.value??""}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}function Bs(s,e){if(!e)return H(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?H(s):H(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+H(s.slice(t,t+e.length))+"</span>"+H(s.slice(t+e.length))}class Vs{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"ePopup",null);w(this,"eList",null);w(this,"values",[]);w(this,"filtered",[]);w(this,"activeIndex",0);w(this,"selectedValue");w(this,"cancelled",!1);var t,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,l;if(this.ePopup)return;const e=document.createElement("div");e.className="ag-rich-select-popup";const t=this.eGui.getBoundingClientRect();if(e.style.position="fixed",e.style.left=`${t.left}px`,e.style.top=`${t.bottom}px`,e.style.minWidth=`${Math.max(t.width,180)}px`,e.style.zIndex="1000",(this.eGui.closest(".ag-root")||document.body).appendChild(e),this.ePopup=e,Gs(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((l=(a=this.params).t)==null?void 0:l.call(a,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const n=document.createElement("div");n.className="ag-rich-select-list",e.appendChild(n),this.eList=n,this.renderList();const o=r=>{!e.contains(r.target)&&!this.eGui.contains(r.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var 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(),l=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?l.every(r=>a.includes(r)):l.some(r=>a.includes(r))}),this.filtered.forEach((o,a)=>{const l=document.createElement("div");l.className="ag-rich-select-item",a===this.activeIndex&&l.classList.add("ag-active"),String(o)===String(this.selectedValue)&&l.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const d=r({value:o,valueFormatted:String(o)});d instanceof HTMLElement?l.appendChild(d):l.textContent=String(d)}else l.innerHTML=Bs(String(o),e);l.addEventListener("click",d=>{d.stopPropagation(),this.commit(o)}),l.addEventListener("mousedown",d=>d.preventDefault()),this.eList.appendChild(l)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((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 Gs(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 Ue={agTextCellEditor:s=>new Fs(s),agNumberCellEditor:s=>new Ps(s),agSelectCellEditor:s=>new $s(s),agDateCellEditor:s=>new Hs(s),agLargeTextCellEditor:s=>new Os(s),agRichSelectCellEditor:s=>new Vs(s)},zs='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',_s='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Ai='<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>',Ws='<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>',qs='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Us='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',js='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Di='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>';class Ks{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=(r,d)=>{const c=document.createElement("div");c.className="ag-menu-item",d.disabled&&c.classList.add("ag-menu-item-disabled"),d.checked&&c.classList.add("ag-menu-item-active");const p=document.createElement("span");p.className="ag-menu-item-check",d.checked&&(p.innerHTML=Di),c.appendChild(p);const f=document.createElement("span");if(f.className="ag-menu-item-label",f.textContent=r,c.appendChild(f),d.shortcut){const u=document.createElement("span");u.className="ag-menu-item-shortcut",u.textContent=d.shortcut,c.appendChild(u)}return!d.disabled&&d.onClick&&c.addEventListener("click",()=>{d.onClick(),n()}),i.appendChild(c),c},l=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,i.appendChild(d)};e.sortable&&(l(this.grid.t("sort")),a(this.grid.t("sortAscending"),{checked:e.sort==="asc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"asc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}}),a(this.grid.t("sortDescending"),{checked:e.sort==="desc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"desc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}})),e.resizable&&(l(this.grid.t("columnSize")),a(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),a(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(l(this.grid.t("pinColumn")),a(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),a(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),a(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(l(this.grid.t("filter")),a(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,t)}),e.filter!=="multi"&&a(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,t)}),this.grid.getOptions().enableAdvancedFilter&&a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)}),a(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(l(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),l(this.grid.t("formula")),a(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,t)}),l(this.grid.t("visibility")),a(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),a(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(i,t)}}const Fi={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 Ys{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 r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);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&&Fi[n.icon]&&(a.innerHTML=Fi[n.icon]),o.appendChild(a);const l=document.createElement("span");if(l.className="ag-menu-item-label",l.textContent=n.label??n.name,o.appendChild(l),n.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=n.shortcut,o.appendChild(r)}if(n.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",o.appendChild(r),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,n.subMenu,i),e.appendChild(c)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;o.matches(":hover")||((c=o.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove())},200)})}else!n.disabled&&n.action&&o.addEventListener("click",()=>{n.action(),i()});e.appendChild(o)}}}class Xs{constructor(e,t){w(this,"editing",null);w(this,"fullRowEditors",null);w(this,"fullRowNode",null);w(this,"focusedCell",null);this.grid=e,this.eventService=t}getFocusedCell(){return this.focusedCell}setFocusedCell(e,t){this.focusedCell={rowIndex:e,column:t,rowNode:this.grid.getDisplayedRowAtIndex(e)},this.clearFocusClass();const 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 d;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=oe(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:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=t.cellEditorParams)==null?void 0:d.values,...t.cellEditorParams};let l;if(typeof t.cellEditor=="string")l=(Ue[t.cellEditor]||Ue.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const c=t.cellEditor(a);l=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";l=Ue[c](a)}if(!l)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:n,editor:l,startedValue:o},n.classList.add("ag-cell-inline-editing");const r=l.getGui();r.classList.add("ag-cell-editor"),n.appendChild(r),n.classList.add("ag-cell-editing"),l.focusIn&&l.focusIn(),l.afterGuiAttached&&l.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 l=oe(o,t,this.grid.getApi()),r=this.createEditor(o,t,e,l,i);if(!r)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),a.appendChild(d),this.fullRowEditors.push({column:o,editor:r,eCell:a,startedValue:l})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,n,o){var r;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:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(Ue[e.cellEditor]||Ue.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const d=e.cellEditor(a);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const l=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return Ue[l](a)}stopEditing(e=!1){var d,c,p,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:l}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?l:a.getValue();if(r===void 0&&!e)return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!1;if(!e){r=Ei(i,r);const u=this.applyValueSetter(i,n,r);if(u===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:i}),!1;r=u}return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!e&&!Pi(r,l)&&(this.grid.setCellValue(i,n,r,"edit",l),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l,newValue:r,value:r,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(f=(p=this.grid.getOptions()).onCellValueChanged)==null||f.call(p,{oldValue:l,newValue:r,value:r,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:oe(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,l;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=r.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const n=[];for(const r of t){if(!i)break;let d=r.editor.getValue();d!==void 0&&(d=Ei(r.column,d),Pi(d,r.startedValue)||n.push({column:r.column,rowNode:i,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const r of n)this.grid.setCellValue(r.column,r.rowNode,r.newValue,"edit",r.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi(),source:"edit"}),(l=(a=this.grid.getOptions()).onCellValueChanged)==null||l.call(a,{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[r.rowNode],columns:[r.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===13){e.preventDefault();const t=this.editing;this.stopEditing(),t&&this.grid.getOptions().enterNavigatesVerticallyAfterEdit!==!1&&this.moveFocus(1,0)}else if(e.key==="Escape"||e.keyCode===27)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===9){e.preventDefault(),this.stopEditing(),this.moveFocus(0,e.shiftKey?-1:1);const t=this.focusedCell;t&&this.grid.isCellEditable(t.column,t.rowNode)&&this.startEditingCell({rowIndex:t.rowIndex,colKey:t.column})}}onGridKeyDown(e){const t=e.key;if(this.editing){t==="Escape"&&this.stopEditing(!0);return}const i=this.focusedCell;switch(e.keyCode){case 13:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case 9:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case 8:case 46: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 36:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case 35:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1/0,0));break;case 33:e.preventDefault(),this.moveFocus(-this.getPageJump(),0);break;case 34:e.preventDefault(),this.moveFocus(this.getPageJump(),0);break;case 70:(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.grid.openFind());break;default:if((t==="f"||t==="F")&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.grid.openFind();return}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 l=o.findIndex(r=>r.colId===i.column.colId)+t;for(;l>=0&&l<o.length&&!o[l].visible;)l+=t;l<0&&(l=0),l>=o.length&&(l=o.length-1),this.setFocusedCell(n,o[l])}else this.setFocusedCell(n,i.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:i}=e;if(this.setFocusedCell(e.rowIndex,i),i.checkboxSelection)return;const n=this.grid.isCellEditable(i,t),o=i.singleClickEdit||this.grid.getOptions().singleClickEdit;n&&o&&!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 Pi(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}const Zs={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function $i(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function Qs(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 Js(){return new TextEncoder}function eo(s,e={}){const[t,i]=Zs[e.pageSize||"a4-landscape"],n=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,l=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=Js(),c=[],p=C=>(c.push(C),c.length);p(""),p("");const f=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),u=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),h=[];for(const C of s){let S="";const b=C.columnWidths.reduce(($,q)=>$+q,0),y=Math.min(1,(t-n*2)/(b||1)),R=C.columnWidths.map($=>$*y),M=n;let T=i-n-(e.title?24:0);e.title&&(S+=`BT /F2 ${o+4} Tf ${M} ${T} Td (${$i(e.title)}) Tj ET
4
+ `,T-=18),C.rows.forEach(($,q)=>{var L;const F=q===0,G=((L=C.rowFill)==null?void 0:L[q])??(F?l:void 0);G&&(S+=`${G[0]} ${G[1]} ${G[2]} rg ${M} ${(T-a+4).toFixed(2)} ${b*y} ${a} re f
5
+ `);let I=M;$.forEach((D,z)=>{const U=R[z]??0,K=$i(Qs(D.text??"",U-6,o)),Z=D.bold||F?u:f,ie=(D.text??"").length*o*.5;let pe=I+3;D.align==="right"||!D.align&&z>0&&/^-?[\d,.%$£€\s]+$/.test(D.text??"")?pe=I+U-3-Math.min(ie,U-6):D.align==="center"&&(pe=I+(U-Math.min(ie,U-6))/2),S+=`BT /F${Z===u?2:1} ${o} Tf ${pe.toFixed(2)} ${(T-o+2).toFixed(2)} Td (${K}) Tj ET
6
+ `,I+=U}),S+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${M} ${(T-a+4).toFixed(2)} m ${(M+b*y).toFixed(2)} ${(T-a+4).toFixed(2)} l S
7
+ `,T-=a});const W=C.rows.length*a;S+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${M} ${(T+a-4).toFixed(2)} m ${M} ${(T+W+a-4).toFixed(2)} l ${(M+b*y).toFixed(2)} ${(T+W+a-4).toFixed(2)} l ${(M+b*y).toFixed(2)} ${(T+a-4).toFixed(2)} l S
8
+ `;const E=d.encode(S),x=p(`<< /Length ${E.length} >>
9
9
  stream
10
- ${R}
11
- endstream`),E=u(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${i}] /Resources << /Font << /F1 ${p} 0 R /F2 ${g} 0 R >> >> /Contents ${B} 0 R >>`);C.push(E)}d[0]="<< /Type /Catalog /Pages 2 0 R >>",d[1]=`<< /Type /Pages /Kids [${C.map(b=>`${b} 0 R`).join(" ")}] /Count ${C.length} >>`;let h=`%PDF-1.4
12
- `;const f=[];d.forEach((b,R)=>{const k=R+1;f.push(c.encode(h).length),h+=`${k} 0 obj
13
- ${b}
10
+ ${S}
11
+ endstream`),k=p(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${i}] /Resources << /Font << /F1 ${f} 0 R /F2 ${u} 0 R >> >> /Contents ${x} 0 R >>`);h.push(k)}c[0]="<< /Type /Catalog /Pages 2 0 R >>",c[1]=`<< /Type /Pages /Kids [${h.map(C=>`${C} 0 R`).join(" ")}] /Count ${h.length} >>`;let g=`%PDF-1.4
12
+ `;const v=[];c.forEach((C,S)=>{const b=S+1;v.push(d.encode(g).length),g+=`${b} 0 obj
13
+ ${C}
14
14
  endobj
15
- `});const m=c.encode(h).length;h+=`xref
16
- 0 ${d.length+1}
15
+ `});const m=d.encode(g).length;g+=`xref
16
+ 0 ${c.length+1}
17
17
  0000000000 65535 f
18
- `;for(const b of f)h+=`${String(b).padStart(10,"0")} 00000 n
19
- `;return h+=`trailer
20
- << /Size ${d.length+1} /Root 1 0 R >>
18
+ `;for(const C of v)g+=`${String(C).padStart(10,"0")} 00000 n
19
+ `;return g+=`trailer
20
+ << /Size ${c.length+1} /Root 1 0 R >>
21
21
  startxref
22
22
  ${m}
23
23
  %%EOF
24
- `,new Blob([c.encode(h)],{type:"application/pdf"})}function Tt(s,e){return s.getUint32(e,!0)}function bt(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 Ns(s){const e=new DataView(s),t=new Uint8Array(s);let i=-1;for(let l=t.length-22;l>=0;l--)if(Tt(e,l)===101010256){i=l;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const n=bt(e,i+10);let o=Tt(e,i+16);const a=[];for(let l=0;l<n&&Tt(e,o)===33639248;l++){const r=bt(e,o+10),c=Tt(e,o+20),d=Tt(e,o+24),u=bt(e,o+28),p=bt(e,o+30),g=bt(e,o+32),C=Tt(e,o+42),h=new TextDecoder().decode(t.subarray(o+46,o+46+u));a.push({name:h,compressionMethod:r,compressedSize:c,uncompressedSize:d,localHeaderOffset:C}),o+=46+u+p+g}return a}async function yi(s,e){const t=new DataView(s),i=new Uint8Array(s),n=bt(t,e.localHeaderOffset+26),o=bt(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+n+o,l=i.subarray(a,a+e.compressedSize);return e.compressionMethod===0?l:Ts(l)}function Si(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 Ls(s){const e=Ns(s),t=e.find(c=>c.name==="xl/workbook.xml"),i=[];if(t){const d=Si(new TextDecoder().decode(await yi(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=Si(new TextDecoder().decode(await yi(s,o))).getElementsByTagName("si");for(let u=0;u<d.length;u++){const p=d[u].getElementsByTagName("t");let g="";for(let C=0;C<p.length;C++)g+=p[C].textContent||"";n.push(g)}}const l=e.filter(c=>/^xl\/worksheets\/sheet\d+\.xml$/.test(c.name)).sort((c,d)=>c.name.localeCompare(d.name,void 0,{numeric:!0})),r=[];for(let c=0;c<l.length;c++){const u=Si(new TextDecoder().decode(await yi(s,l[c]))).getElementsByTagName("row"),p=[];for(let g=0;g<u.length;g++){const C=u[g],h=[],f=C.getElementsByTagName("c");for(let m=0;m<f.length;m++){const b=f[m],R=b.getAttribute("r")||"",k=b.getAttribute("t")||"";let y="";if(k==="s"){const P=b.getElementsByTagName("v")[0],D=Number((P==null?void 0:P.textContent)||"0");y=n[D]??""}else if(k==="inlineStr"){const P=b.getElementsByTagName("t");for(let D=0;D<P.length;D++)y+=P[D].textContent||""}else{const P=b.getElementsByTagName("v")[0];y=(P==null?void 0:P.textContent)??""}const M=R?Is(R):m;h[M]=y}p.push(h.map(m=>m??""))}r.push({name:i[c]||`Sheet${c+1}`,rows:p})}return r}class As{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(l=>{l.rowPinned==="top"&&e.skipPinnedTop!==!1||l.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&l.group&&!l.footer||a&&l.footer||n&&!l.selected||i.push(l)}),n&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let n=me(e,t,this.grid.getApi()),o=ei(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 l=t.map(r=>{const c=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):c});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),n,e.suppressQuotes)),o.push(this.csvRow(l,n,e.suppressQuotes))}for(const l of i){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:l,api:this.grid.getApi()}))continue;const r=t.map(c=>this.getCellValueForExport(c,l,e));o.push(this.csvRow(r,n,e.suppressQuotes))}return o.join(`\r
24
+ `,new Blob([d.encode(g)],{type:"application/pdf"})}function it(s,e){return s.getUint32(e,!0)}function Qe(s,e){return s.getUint16(e,!0)}async function to(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 io(s){const e=new DataView(s),t=new Uint8Array(s);let i=-1;for(let l=t.length-22;l>=0;l--)if(it(e,l)===101010256){i=l;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const n=Qe(e,i+10);let o=it(e,i+16);const a=[];for(let l=0;l<n&&it(e,o)===33639248;l++){const r=Qe(e,o+10),d=it(e,o+20),c=it(e,o+24),p=Qe(e,o+28),f=Qe(e,o+30),u=Qe(e,o+32),h=it(e,o+42),g=new TextDecoder().decode(t.subarray(o+46,o+46+p));a.push({name:g,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:h}),o+=46+p+f+u}return a}async function Ut(s,e){const t=new DataView(s),i=new Uint8Array(s),n=Qe(t,e.localHeaderOffset+26),o=Qe(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+n+o,l=i.subarray(a,a+e.compressedSize);return e.compressionMethod===0?l:to(l)}function jt(s){return new DOMParser().parseFromString(s,"application/xml")}function no(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 so(s){const e=io(s),t=e.find(d=>d.name==="xl/workbook.xml"),i=[];if(t){const c=jt(new TextDecoder().decode(await Ut(s,t))).getElementsByTagName("sheet");for(let p=0;p<c.length;p++)i.push(c[p].getAttribute("name")||`Sheet${p+1}`),c[p].getAttribute("r:id")||c[p].getAttribute("id")}const n=[],o=e.find(d=>d.name==="xl/sharedStrings.xml");if(o){const c=jt(new TextDecoder().decode(await Ut(s,o))).getElementsByTagName("si");for(let p=0;p<c.length;p++){const f=c[p].getElementsByTagName("t");let u="";for(let h=0;h<f.length;h++)u+=f[h].textContent||"";n.push(u)}}const l=e.filter(d=>/^xl\/worksheets\/sheet\d+\.xml$/.test(d.name)).sort((d,c)=>d.name.localeCompare(c.name,void 0,{numeric:!0})),r=[];for(let d=0;d<l.length;d++){const p=jt(new TextDecoder().decode(await Ut(s,l[d]))).getElementsByTagName("row"),f=[];for(let u=0;u<p.length;u++){const h=p[u],g=[],v=h.getElementsByTagName("c");for(let m=0;m<v.length;m++){const C=v[m],S=C.getAttribute("r")||"",b=C.getAttribute("t")||"";let y="";if(b==="s"){const M=C.getElementsByTagName("v")[0],T=Number((M==null?void 0:M.textContent)||"0");y=n[T]??""}else if(b==="inlineStr"){const M=C.getElementsByTagName("t");for(let T=0;T<M.length;T++)y+=M[T].textContent||""}else{const M=C.getElementsByTagName("v")[0];y=(M==null?void 0:M.textContent)??""}const R=S?no(S):m;g[R]=y}f.push(g.map(m=>m??""))}r.push({name:i[d]||`Sheet${d+1}`,rows:f})}return r}const oo=(()=>{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 ao(s){let e=4294967295;for(let t=0;t<s.length;t++)e=oo[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Hi(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function ro(s){let e="",t=s+1;for(;t>0;){const i=(t-1)%26;e=String.fromCharCode(65+i)+e,t=Math.floor((t-1)/26)}return e}function lo(s){const e=new TextEncoder,t=[],i=[];let n=0;for(const p of s){const f=e.encode(p.name),u=ao(p.data),h=new Uint8Array(30+f.length),g=new DataView(h.buffer);g.setUint32(0,67324752,!0),g.setUint16(4,20,!0),g.setUint16(6,2048,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,8585,!0),g.setUint32(14,u,!0),g.setUint32(18,p.data.length,!0),g.setUint32(22,p.data.length,!0),g.setUint16(26,f.length,!0),g.setUint16(28,0,!0),h.set(f,30),t.push(h,p.data);const v=new Uint8Array(46+f.length),m=new DataView(v.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,2048,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,u,!0),m.setUint32(20,p.data.length,!0),m.setUint32(24,p.data.length,!0),m.setUint16(28,f.length,!0),m.setUint32(42,n,!0),v.set(f,46),i.push(v),n+=h.length+p.data.length}const o=i.reduce((p,f)=>p+f.length,0),a=new Uint8Array(22),l=new DataView(a.buffer);l.setUint32(0,101010256,!0),l.setUint16(8,s.length,!0),l.setUint16(10,s.length,!0),l.setUint32(12,o,!0),l.setUint32(16,n,!0);const r=t.reduce((p,f)=>p+f.length,0)+o+a.length,d=new Uint8Array(r);let c=0;for(const p of t)d.set(p,c),c+=p.length;for(const p of i)d.set(p,c),c+=p.length;return d.set(a,c),d}function co(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(l=>l.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${n}"${a}>`,t.forEach((l,r)=>{const d=`${ro(r)}${n}`,c=l.bold?' s="1"':"";if(l.value===null||l.value===void 0||l.value===""){e+=`<c r="${d}"${c}/>`;return}typeof l.value=="number"&&isFinite(l.value)?e+=`<c r="${d}"${c}><v>${l.value}</v></c>`:typeof l.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${l.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${Hi(String(l.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const uo='<?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 ho(s){const e=new TextEncoder,t=(p,f)=>p.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${f+1}`;let i="",n="",o="";s.forEach((p,f)=>{const u=t(p.name,f),h=f+1;i+=`<sheet name="${Hi(u)}" sheetId="${h}" r:id="rId${h}"/>`,n+=`<Relationship Id="rId${h}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${h}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${h}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const a='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+o+"</Types>",l='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${i}</sheets></workbook>`,d='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+n+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(l)},{name:"xl/workbook.xml",data:e.encode(r)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(d)},{name:"xl/styles.xml",data:e.encode(uo)}];return s.forEach((p,f)=>{c.push({name:`xl/worksheets/sheet${f+1}.xml`,data:e.encode(co(p.rows))})}),new Blob([lo(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}class po{constructor(e){w(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(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(l=>{l.rowPinned==="top"&&e.skipPinnedTop!==!1||l.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&l.group&&!l.footer||a&&l.footer||n&&!l.selected||i.push(l)}),n&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let n=oe(e,t,this.grid.getApi()),o=kt(e,t,this.grid.getApi());if(i.processCellCallback){const l=i.processCellCallback({value:n,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(l!=null)return String(l)}const a=this.groupValue(e,t);return a!==void 0&&(n=a,o=n===null?"":String(n)),n instanceof Date?n.toISOString().slice(0,10):o??(n==null?"":String(n))}groupValue(e,t){var i;return t.group||t.footer?(i=t.groupData)==null?void 0:i[e.colId]:void 0}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),i=this.getExportRows(e),n=e.columnSeparator??",",o=[];if(!e.skipHeader){const l=t.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),n,e.suppressQuotes)),o.push(this.csvRow(l,n,e.suppressQuotes))}for(const l of i){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:l,api:this.grid.getApi()}))continue;const r=t.map(d=>this.getCellValueForExport(d,l,e));o.push(this.csvRow(r,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 l=me(a,o,this.grid.getApi());return o.footer&&o.groupData&&o.groupData[a.colId]!==void 0&&(l=o.groupData[a.colId]),o.group&&o.groupData&&o.groupData[a.colId]!==void 0&&(l=o.groupData[a.colId]),l instanceof Date&&(l=l.toISOString().slice(0,10)),{value:l}}));return xs([{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 C;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)(C=e.shouldRowBeSkipped)!=null&&C.call(e,{node:h,api:this.grid.getApi()})||(o.push(t.map(f=>{let m=this.getCellValueForExport(f,h,e);if(e.processCellCallback){const b=e.processCellCallback({value:me(f,h,this.grid.getApi()),formattedValue:m,node:h,column:f,api:this.grid.getApi()});b!=null&&(m=String(b))}return{text:m,align:f.type==="numberColumn"||f.cellDataType===!0?"right":"left"}})),a.push(void 0));const l=18,r=e.pageSize||"a4-landscape",[c,d]=r.includes("portrait")?[595,842]:[842,595],u=d-64-(e.title?24:0),p=Math.max(5,Math.floor(u/l)),g=[];o.length===0&&g.push({columnWidths:n,rows:[],rowFill:[]});for(let h=0;h<o.length;h+=p)g.push({columnWidths:n,rows:o.slice(h,h+p),rowFill:a.slice(h,h+p)});return Ms(g,{pageSize:r,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 Ls(i))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],l=o.rows.slice(1).map(r=>{const c={};return a.forEach((d,u)=>{const p=d||`col${u+1}`,g=r[u]??"",C=String(g).trim();c[p]=C!==""&&!isNaN(Number(C))&&!/^0\d/.test(C)?Number(C):g}),c});return t.onSuccess?t.onSuccess(l):this.grid.getApi().setRowData(l),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:l}),l}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 p=this.grid.getColumns().center,g=p.findIndex(C=>C.colId===u.colStartId);o=p[g]??p[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 l=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=l.findIndex(u=>u.colId===o.colId),c=[],d=[];this.grid.getDisplayedRowCount(),a.forEach((u,p)=>{const g=u.split(" "),C=n+p;let h=this.grid.getDisplayedRowAtIndex(C);if(!h){const f={};g.forEach((m,b)=>{const R=l[r+b];R!=null&&R.field&&(f[R.field]=m)}),d.push(f);return}g.forEach((f,m)=>{const b=l[r+m];b&&this.grid.setCellValue(b,h,f,"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 Ds{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 l;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(l=o.dataTransfer)==null?void 0:l.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const 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 l;(l=a.dataTransfer)==null||l.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 Fs{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 Ps{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 l=document.createElement("div");l.className="ag-formula-preview";const r=()=>{const h=this.grid.getDisplayedRowAtIndex(0);if(!h){l.textContent="";return}try{const f=Bt(a.value,{data:h.data});l.textContent=`${this.grid.t("formulaPreview")}: ${f==null?"":String(f)}`,l.classList.remove("ag-formula-error")}catch(f){l.textContent=`${this.grid.t("formulaError")}: ${(f==null?void 0:f.code)||(f==null?void 0:f.message)||this.grid.t("invalidFormula")}`,l.classList.add("ag-formula-error")}};a.addEventListener("input",r),i.appendChild(l);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 Zt){const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent=h,f.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${h}()`,a.focus(),r()}),u.appendChild(f)}c.appendChild(u),i.appendChild(c);const p=document.createElement("div");p.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(),f=this.grid.getColumnModel(),m=f.getColumn(e.colId);m&&(m.field=h==="="||h===""?e.field:h,m.colDef={...m.colDef,field:m.field},h!=="="&&h!==""&&(m.editable=!1)),f.refreshAll(),this.grid.refreshCells({force:!0}),n()});const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",()=>{a.value="=",r()}),p.appendChild(C),p.appendChild(g),i.appendChild(p),this.popupService.positionAt(i,t),r()}}class $s{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:l,close:r}=this.popupService.createPopup(280,"ag-note-editor");l.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`${this.grid.t("note")} — ${(n==null?void 0:n.headerName)||t}`,l.appendChild(c);const d=document.createElement("textarea");d.className="ag-formula-input",d.rows=4,d.value=a,d.placeholder=this.grid.t("writeNote"),l.appendChild(d);const u=document.createElement("div");u.className="ag-popup-buttons";const p=document.createElement("button");p.className="ag-button ag-button-primary",p.textContent=this.grid.t("save"),p.addEventListener("click",()=>{this.setNote(e,t,d.value.trim()||void 0),r()});const g=document.createElement("button");g.className="ag-button",g.textContent=this.grid.t("delete"),g.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),u.appendChild(g),u.appendChild(p),l.appendChild(u),this.popupService.positionAt(l,i),setTimeout(()=>d.focus(),0)}}class Gs{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,l)=>{a.id===n.dataset.rowid&&(o=l)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),l=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),r=e.clientY>n.getBoundingClientRect().top+l/2,c=(a[o]??0)+(r?l: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 Hs(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 me(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 l=s.getRowNode(a);l&&s.getSelectionService().selectNode(l,!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 Os={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 Nt{constructor(e,t){v(this,"options");v(this,"eventService",new ze);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,p;this.eGridDiv=e,this.options={...Os,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Mo(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,C)=>this.selectionService.selectNode(g,C),deselectNode:g=>this.selectionService.deselectNode(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g)},this.columnModel=new Zi(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new ns(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),g=>this.isNodeSelectable(g)),this.filterService=new ss(this),this.sortService=new as(this),this.popupService=new ls(this),this.filterGui=new rs(this,this.popupService),this.contextMenuService=new cs(this,this.popupService),this.columnMenuService=new ds(this,this.popupService),this.editService=new os(this,this.eventService),this.undoRedoService=new Fs(this,this.eventService),this.formulaEditorService=new Ps(this,this.popupService),this.notesService=new $s(this,this.popupService),this.rowDragService=new Gs(this,this.eventService),this.chartService=new fs(this,this.popupService),this.findService=new ps(this,this.popupService),this.exportService=new As(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 No(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 Lo(n),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new So({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 is(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(g=>g.sort)}),onSortRequested:(g,C,h)=>this.sortService.onSortRequested(g,C,h),onColumnResized:(g,C,h)=>this.onColumnResized(g,C,h),onColumnMoved:(g,C)=>this.onColumnMoved(g,C),onColumnMenuClicked:(g,C)=>this.columnMenuService.openColumnMenu(g,C),onFilterOpened:(g,C)=>this.filterGui.openFilter(g,C),isFilterActive:g=>this.filterService.isFilterActive(g),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(g,C)=>this.filterService.handleFloatingFilterChange(g,C),onHeaderCheckboxChanged:(g,C)=>this.onHeaderCheckboxChanged(g,C),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,C)=>this.filterService.setColumnFilterModel(g,C)}),this.rowRenderer=new ts(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,f,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const g=this.rowRenderer.getFirstVisibleRowIndex(),C=this.rowRenderer.getLastVisibleRowIndex();(h=this.serverSideRowModel)==null||h.onViewportChanged(g,C),(f=this.infiniteRowModel)==null||f.onViewportChanged(g,C),(m=this.viewportRowModel)==null||m.onViewportChanged(g,C)},getCellText:(g,C)=>{const h=me(g,C,this.api);return h==null?"":String(h)},renderDetailRow:g=>this.renderDetailRow(g),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(g,C,h)=>this.rowDragService.startDrag(g,h),getNote:(g,C,h,f)=>this.notesService.getNote(g,C,h,f),onNoteClick:(g,C,h)=>this.notesService.openNoteEditor(g,C,h),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new gs(this,this.eventService),this.statusBarService=new us(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new ms(this),this.sideBarService=new hs(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 rn(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Ds(this));const{api:a,columnApi:l}=Hs(this);this.api=a,this.columnApi=l,this.columnModel.setGridApi(this.api),(p=(u=this.rowModel).setGridApi)==null||p.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,C;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(C=(g=this.options).onSelectionChanged)==null||C.call(g,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let r=this.options.columnDefs||[];(!r||r.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(r=Zi.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const 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 l of t){const r=me(l,a,this.api);typeof r=="number"&&!isNaN(r)&&o.set(l.colId,(o.get(l.colId)??0)+r)}});for(const a of t)e.set(a.colId,o.get(a.colId)??0)}this.api.__columnTotalCache=e}refreshPivotColumns(){this.columnModel.updatePivotColumns(this.options.rowData||[])}onRemoteModelChanged(){this.serverSideRowModel?this.serverSideRowModel.onSortOrFilterChanged():this.infiniteRowModel?this.infiniteRowModel.onSortOrFilterChanged():this.viewportRowModel&&this.viewportRowModel.setViewportDatasource(this.viewportRowModel.datasource)}isRemoteLoading(){var e,t,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:me(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:me(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,l,r,c;const{node:t,column:i,event:n}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(l=(a=this.options).onCellClicked)==null||l.call(a,{...e,api:this.api,colDef:i.colDef,value:me(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=(r=this.options).onCellClicked)==null||c.call(r,{...e,api:this.api,colDef:i.colDef,value:me(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 l=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);l&&l(e,!e.expanded),globalThis.__dbgLogs.push(["after-toggle",e.id,"expanded=",e.expanded]),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(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,l;this.updateColumnTotalCache(),this.rowRenderer.refreshRows(),this.options.__loadingRows=this.isRemoteLoading(),this.overlayService.updateAuto(),this.statusBarService.update(),(e=this.paginationService)==null||e.update(),this.rangeSelectionService.applyHighlight(),this.findService.applyHighlight(),this.chartService.refreshCharts(),this.gridReadyDispatched||(this.gridReadyDispatched=!0,this.eventService.dispatchEvent("firstDataRendered",{api:this.api}),(i=(t=this.options).onFirstDataRendered)==null||i.call(t,{api:this.api})),(o=(n=this.options).onModelUpdated)==null||o.call(n,{api:this.api}),(l=(a=this.options).onRowDataChanged)==null||l.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,l;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),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}),(l=(a=this.options).onGridSizeChanged)==null||l.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,l=(c=this.options.detailCellRendererParams)==null?void 0:c.detailGridOptions,r=(d=this.options.detailCellRendererParams)==null?void 0:d.getDetailRowData;if(l&&r){const u=r({data:t.data,node:t,api:this.api}),p=document.createElement("div");p.style.height="100%",p.style.padding="8px 16px",o.appendChild(p),setTimeout(()=>{new Nt(p,{...l,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 rn(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 gn(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 l of a.fields){const r=document.createElement("dt"),c=document.createElement("dd");r.textContent=l.label,c.textContent=l.value,i.append(r,c)}e.open||e.showModal()},close:o,destroy(){e.open&&e.close(),n.removeEventListener("click",o),e.remove()}}}const fn=864e5;function tt(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 Be(s){return new Date(`${s}T00:00:00`)}function Ge(s,e){return new Date(s.getTime()+e*fn)}function Je(s,e){const t=typeof s=="string"?Be(s):s,i=typeof e=="string"?Be(e):e;return Math.round((i.getTime()-t.getTime())/fn)}function Ut(){return tt(new Date)}function Bs(s){return s.status!=="done"&&s.end&&s.end<Ut()&&s.progress<100?"delayed":s.status}function xi(s){const e=Be(s);return`${e.getMonth()+1}月${e.getDate()}日`}const mn=["day","week","biweek","month","bimonth","quarter","halfyear","year"],si={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Vs={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2},Ae={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)"},ai={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},zs=4,vn=6,Ue=28;function Ei(s){const e=(s.getDay()+6)%7;return Ge(s,-e)}function Ws(s,e){const t=Math.max(1,Je(s,e)+1);let i=0;for(let n=0;n<t;n++){const o=Ge(s,n).getDay();o!==0&&o!==6&&i++}return Math.max(1,i)}function Us(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function Cn(s,e,t){const i=[];if(s==="day"){let r=new Date(e);for(;r<t;){const c=Ge(r,1);i.push({start:new Date(r),end:c,primary:`${r.getDate()}`,secondary:""}),r=c}return i}if(s==="week"||s==="biweek"){let r=Ei(e);for(;r<t;){const c=Ge(r,s==="biweek"?14:7);i.push({start:new Date(r),end:c,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=c}return i}const n=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/n)*n,1),a=r=>s==="month"||s==="bimonth"?`${r.getMonth()+1}月`:s==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let l=o(e);for(;l<t;){const r=Us(l,n);i.push({start:new Date(l),end:r,primary:a(l),secondary:""}),l=r}return i}class wn{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),l=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(!l)return;const r=this.tasksById.get(l.id);if(r){if(r.kind==="task"&&(!r.start||!r.end)){const c=this.pointAt(e.clientX,e.clientY),d=Math.floor(c.x/this.dayWidth),u=tt(Ge(this.epochStart,d));this.options.onTaskChange({...r,start:u,end:tt(Ge(Be(u),4)),progress:0,status:"not-started"}),this.options.onSelect(l.id);return}this.options.onSelect(l.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)<zs)return;t.moved=!0;const n=this.dayWidth,o=Math.round((e.clientX-t.startX)/n),a=Be(t.originStart),l=Be(t.originEnd),r=Je(a,l);let c,d;t.mode==="resize-l"?(c=Ge(a,Math.min(o,r)),d=l):t.mode==="resize-r"?(c=a,d=Ge(l,Math.max(o,-r))):(c=Ge(a,o),d=Ge(l,o)),i.milestone&&(c=d),t.start=tt(c),t.end=tt(d),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?xi(t.start):`${xi(t.start)} → ${xi(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 Vs[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(Ut()),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=Ut();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const n=Ei(Ge(Be(e),-7));this.epochStart=n,this.totalDays=Math.max(Je(n,Be(t))+730,1095)}dateX(e){return Je(this.epochStart,e)*this.dayWidth}xToDate(e){return tt(Ge(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 l=Ge(this.epochStart,this.totalDays),r=(u,p,g,C)=>{for(const h of u){const f=this.dateX(tt(h.start))-a,m=Je(h.start,h.end)*e;if(f+m<=0||f>=n)continue;const b=Math.max(0,Math.min(f+m,n)-Math.max(0,f));if(this.unit==="day"||this.unit==="week"){const y=h.start.getDay();(y===0||y===6)&&(i.fillStyle=Ae.weekend,i.fillRect(Math.max(0,f),p,b,g))}const R=i.measureText(h.primary).width;if(R+8<b){const y=Math.max(0,f)+b/2-R/2,M=p+g/2+5;i.fillStyle=Ae.text,i.font="11px "+it,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(h.primary,y,M),h.secondary&&(i.fillStyle=Ae.textTertiary,i.font="10px "+it,i.fillText(h.secondary,y,M+12))}}},c=40,d=Ge(this.epochStart,Math.floor(a/e));i.fillStyle=Ae.text,i.font="14px "+it,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),r(Cn(this.unit,this.epochStart,l),c+1,o-c-1),i.strokeStyle=Ae.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,l=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,c=this.eScroll.scrollTop;o.clearRect(0,0,a,l),o.fillStyle="#fff",o.fillRect(0,0,a,l),o.save(),o.translate(-r,-c),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,c+l)),this.drawGridlines(e,t,Math.max(i,c+l)),this.drawRowBackgrounds(t,n);const d=this.rows.findIndex(p=>p.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 p=d*n+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,It(o,r+4,p,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Ae.textTertiary,o.font="14px "+it,o.textAlign="center",o.fillText("新建排期",r+a/2,p+19)}this.drawDependencies(n),this.drawBars(n),this.drawTodayLine(t,Math.max(i,c+l)),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=Ae.weekend;let o=Ei(this.epochStart);for(;Je(this.epochStart,o)<this.totalDays;){const a=this.dateX(tt(o))+5*e;a<t&&n.fillRect(Math.max(0,a),0,e*2,i),o=Ge(o,7)}}drawGridlines(e,t,i){const n=this.ctx,o=Ge(this.epochStart,this.totalDays);for(const a of Cn(this.unit,this.epochStart,o)){const l=Math.round(this.dateX(tt(a.start)))+.5;if(l<0||l>t)continue;const r=this.unit==="day"&&a.start.getDate()===1;n.strokeStyle=r?Ae.gridlineMonth:Ae.gridline,n.beginPath(),n.moveTo(l,0),n.lineTo(l,i),n.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=Ae.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,l=this.hoverId===n.id;(a||l)&&(i.fillStyle=a?Ae.selected:l?Ae.hover:Ae.groupRow,i.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,n=Math.round(this.dateX(Ut())+this.dayWidth/2)+.5;n<0||n>e||(i.strokeStyle=Ae.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=Ut().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=Ae.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 l of o.dependsOn){const r=this.tasksById.get(l),c=t.get(l);if(!(r!=null&&r.start)||!r.end||c===void 0)continue;const d=this.dateX(r.start),u=r.milestone?this.dayWidth:Math.max(Je(Be(r.start),Be(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),p=d+u,g=c*e+e/2,C=this.dateX(o.start),h=Math.max(Je(Be(o.start),Be(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),f=a*e+e/2,m=p+10;if(C-4>m)bn(i,p,g,m,f,C-5,f);else{const b=C+h+10;bn(i,p,g,m,f,b,f)}qs(i,C-5,f)}}}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-Ue)/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,l=(o==null?void 0:o.end)??e.end,r=this.dateX(a),c=Math.max(28,(Je(a,l)+1)*this.dayWidth),d=ai[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?Ae.accent:"#dee0e3",n.lineWidth=1,It(n,r,i,c,Ue,4),n.fill(),n.stroke(),n.save(),It(n,r,i,c,Ue,4),n.clip(),n.beginPath(),n.arc(r+14,i+14,6,0,Math.PI*2),n.fillStyle=d,n.fill(),n.font="12px "+it,n.textBaseline="middle",n.textAlign="left",n.fillStyle=Ae.text;const u=this.options.members.find(C=>C.id===e.owner),p=n.measureText(e.name).width;c>p+58?(n.fillText(e.name,r+26,i+14),u&&Ri(n,r+p+42,i+14,7,li(u.id),u.name.slice(0,1))):u&&c>46&&Ri(n,r+38,i+14,7,li(u.id),u.name.slice(0,1)),c>100&&(n.fillStyle=Ae.textTertiary,n.textAlign="right",n.fillText(String(Ws(Be(a),Be(l))),r+c-8,i+14)),n.restore(),n.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:i,w:c,h:Ue,mode:"move",avatar:u?{x:r+(c>p+58?p+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,l=this.dateX(e.start),r=Math.max(92,(Je(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?Ae.accent:"#dee0e3",a.lineWidth=1,It(a,l,i,r,Ue,4),a.fill(),a.stroke(),a.fillStyle=o?ai[o.status]:ai[e.status],a.beginPath(),a.arc(l+14,i+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Ae.text,a.font="11px "+it,a.textAlign="left",a.textBaseline="middle";const c=((o==null?void 0:o.name)??e.name)+(n.length>1?` +${n.length-1}`:"");a.fillText(_s(a,c,r-32),l+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:l,y:i,w:r,h:Ue,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 f;const n=this.ctx,o=this.dayWidth,a=((f=this.ghost)==null?void 0:f.id)===e.id?this.ghost:null,l=a?a.start:e.start,r=Bs(e),c=ai[r],d=this.dateX(l)+o/2;n.font="12px "+it;const u=n.measureText(e.name).width,p=e.owner?24:0,g=19+u+p+14,C=d-g/2;n.fillStyle="#fff",n.strokeStyle=c,n.lineWidth=1.5,It(n,C,i,g,Ue,4),n.fill(),n.stroke(),n.fillStyle=c,n.beginPath(),n.arc(C+7+3,i+Ue/2,3,0,Math.PI*2),n.fill(),n.fillStyle=Ae.text,n.textAlign="left",n.textBaseline="middle",n.fillText(e.name,C+14+5,i+Ue/2+1);let h;if(e.owner){const m=this.options.members.find(b=>b.id===e.owner);m&&(Ri(n,C+g-12,i+Ue/2,9,li(m.id),m.name.slice(0,1)),h={x:C+g-12,y:i+Ue/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:C,y:i,w:g,h:Ue,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 l=this.dateX(a.start),r=this.dateX(a.end)+this.dayWidth;if(r>=t&&l<=t+i)return;const c=r<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",It(e,c-5,d-6,13,13,3),e.fill(),e.font="12px "+it,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<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 l=i.x-a.avatar.x,r=i.y-a.avatar.y;if(l*l+r*r<=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 l=a.kind==="task"&&i.x<=a.x+vn,r=a.kind==="task"&&i.x>=a.x+a.w-vn;return{hit:{...a,mode:l?"resize-l":r?"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=si[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 mn){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=si[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=si[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=li(c.id);const p=document.createElement("span");p.textContent=c.name,d.append(u,p),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(),l=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;n.style.left=`${Math.min(a.width-150,Math.max(0,l-40))}px`,n.style.top=`${r+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 it="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function It(s,e,t,i,n,o){const a=Math.max(0,i),l=Math.max(0,n);if(a===0||l===0)return;const r=Math.max(0,Math.min(o,a/2,l/2));s.beginPath(),s.moveTo(e+r,t),s.lineTo(e+a-r,t),s.arcTo(e+a,t,e+a,t+r,r),s.lineTo(e+a,t+l-r),s.arcTo(e+a,t+l,e+a-r,t+l,r),s.lineTo(e+r,t+l),s.arcTo(e,t+l,e,t+l-r,r),s.lineTo(e,t+r),s.arcTo(e,t,e+r,t,r),s.closePath()}function Ri(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 ${it}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function _s(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 bn(s,e,t,i,n,o,a){const r=n>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(i-5,t),s.quadraticCurveTo(i,t,i,t+5*r),s.lineTo(i,n-5*r),s.quadraticCurveTo(i,n,i+5*r,n),s.lineTo(o,a),s.stroke()}function qs(s,e,t){s.fillStyle=Ae.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 yn=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function li(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return yn[e%yn.length]}const Ks=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],js=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Xs=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function He(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function Lt(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 Ys{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=He("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",c=>c.stopPropagation());const i=He("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const n=He("div","gt-filter-rows");t.appendChild(n);const o=()=>{if(n.textContent="",!this.filterRows.length){const c=He("div","gt-panel-empty");c.textContent="点击下方字段添加筛选条件",n.appendChild(c)}for(const c of this.filterRows)n.appendChild(this.renderFilterRow(c,o))},a=He("div","gt-filter-add");for(const c of this.filterFields)a.appendChild(Lt(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 l=He("div","gt-panel-hint");l.textContent="多个条件同时满足(且)",t.appendChild(l);const r=He("div","gt-panel-actions");r.append(Lt("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),Lt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const i=He("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"?js:e.kind==="date"?Xs:Ks,l=document.createElement("select");l.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),l.appendChild(d)}if(l.addEventListener("change",()=>{e.type=l.value,t()}),i.appendChild(l),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 p=document.createElement("option");p.value=u.value,p.textContent=u.label,u.value===e.value&&(p.selected=!0),c.appendChild(p)}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 r=Lt("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(c=>c!==e),t()});return r.title="移除条件",i.appendChild(r),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=He("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",l=>l.stopPropagation());const i=He("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const n=He("div","gt-sort-list");t.appendChild(n);const o=()=>{var l;n.textContent="";for(const r of this.sortFields){const c=this.sorts.findIndex(g=>g.colId===r.colId),d=c>=0,u=He("div","gt-sort-item");d&&u.classList.add("gt-sort-item-active");const p=He("span","gt-sort-label");if(p.textContent=r.label,u.appendChild(p),d){const g=He("span","gt-sort-badge");g.textContent=String(c+1),u.appendChild(g);const C=He("span","gt-sort-dir");C.textContent=((l=this.sorts[c])==null?void 0:l.sort)==="asc"?"↑ 升序":"↓ 降序",u.appendChild(C)}u.addEventListener("click",()=>{var g;d?((g=this.sorts[c])==null?void 0:g.sort)==="asc"?this.sorts[c]={colId:r.colId,sort:"desc"}:this.sorts=this.sorts.filter(C=>C.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),o()}),n.appendChild(u)}},a=He("div","gt-panel-actions");a.append(Lt("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),Lt("应用","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 Qs={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 Js(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 l=oe(a,o,this.grid.getApi());const r=this.groupValue(a,o);return r!==void 0&&(l=r),l instanceof Date&&(l=l.toISOString().slice(0,10)),{value:l}}));return ho([{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 h;const t=this.getExportColumns(e),i=this.getExportRows(e),n=t.map(g=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(g.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(g=>({text:e.processHeaderCallback?e.processHeaderCallback({column:g,api:this.grid.getApi()}):g.headerName||g.field||g.colId,bold:!0,align:g.type==="numberColumn"||g.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const g of i)(h=e.shouldRowBeSkipped)!=null&&h.call(e,{node:g,api:this.grid.getApi()})||(o.push(t.map(v=>{let m=this.getCellValueForExport(v,g,e);if(e.processCellCallback){const C=e.processCellCallback({value:oe(v,g,this.grid.getApi()),formattedValue:m,node:g,column:v,api:this.grid.getApi()});C!=null&&(m=String(C))}return{text:m,align:v.type==="numberColumn"||v.cellDataType===!0?"right":"left"}})),a.push(void 0));const l=18,r=e.pageSize||"a4-landscape",[d,c]=r.includes("portrait")?[595,842]:[842,595],p=c-64-(e.title?24:0),f=Math.max(5,Math.floor(p/l)),u=[];o.length===0&&u.push({columnWidths:n,rows:[],rowFill:[]});for(let g=0;g<o.length;g+=f)u.push({columnWidths:n,rows:o.slice(g,g+f),rowFill:a.slice(g,g+f)});return eo(u,{pageSize:r,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const i=e instanceof ArrayBuffer?e:await e.arrayBuffer(),o=(await so(i))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],l=o.rows.slice(1).map(r=>{const d={};return a.forEach((c,p)=>{const f=c||`col${p+1}`,u=r[p]??"",h=String(u).trim();d[f]=h!==""&&!isNaN(Number(h))&&!/^0\d/.test(h)?Number(h):u}),d});return t.onSuccess?t.onSuccess(l):this.grid.getApi().setRowData(l),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:l}),l}fileName(e,t){const 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 p=i[0];n=p.rowStartIndex;const f=this.grid.getColumns().center,u=f.findIndex(h=>h.colId===p.colStartId);o=f[u]??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 l=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=l.findIndex(p=>p.colId===o.colId),d=[],c=[];a.forEach((p,f)=>{const u=p.split(" "),h=n+f,g=this.grid.getDisplayedRowAtIndex(h);if(!g){const v={};u.forEach((m,C)=>{const S=l[r+C];S!=null&&S.field&&(v[S.field]=m)}),c.push(v);return}u.forEach((v,m)=>{const C=l[r+m];C&&this.grid.setCellValue(C,g,v,"paste")}),d.push(g)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const t=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t,()=>this.fallbackCopy(e,t)):this.fallbackCopy(e,t)}fallbackCopy(e,t){const 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()}}const vt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],wt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class fo{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var g,v;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const i=e.filter===!0?"text":e.filter,n=this.grid.getFilterService().getFilterInstance(e.colId),o=i==="set"?260:240,{ePopup:a}=this.popupService.createPopup(o,"ag-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=`Search ${e.headerName||e.field||""}`,a.appendChild(l);const r=n?{...n}:this.getDefaultModel(i);let d=n?{...n}:null;const c=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),close()},p=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),close()};if(i==="set")a.appendChild(this.buildSetFilter(e,r,m=>{d=m}));else if(i==="boolean"){const m=this.buildConditionSelect(["true","false"],String(r.filter??""),C=>{d={filterType:"boolean",filter:C==="true"}});a.appendChild(m)}else{const m=i==="number"?wt:vt,C=this.buildConditionSelect(m,r.type||m[0],S=>{r.type=S,d={...r}});if(a.appendChild(C),r.type!=="blank"&&r.type!=="notBlank")if(i==="number"&&r.type==="inRange"){const S=document.createElement("div");S.className="ag-filter-inputs";const b=document.createElement("input");b.type="number",b.className="ag-filter-input",b.value=r.filter??"",b.placeholder=this.grid.t("from"),b.addEventListener("input",()=>{d={...r,filter:b.value,filterTo:y.value}});const y=document.createElement("input");y.type="number",y.className="ag-filter-input",y.value=r.filterTo??"",y.placeholder=this.grid.t("to"),y.addEventListener("input",()=>{d={...r,filter:b.value,filterTo:y.value}}),S.appendChild(b),S.appendChild(y),a.appendChild(S)}else if(i==="date"){const S=document.createElement("div");S.className="ag-filter-inputs";const b=document.createElement("input");b.type="date",b.className="ag-filter-input",b.value=r.dateFrom??"",b.addEventListener("input",()=>{d={...r,dateFrom:b.value,dateTo:y.value}});const y=document.createElement("input");y.type="date",y.className="ag-filter-input",y.value=r.dateTo??"",y.addEventListener("input",()=>{d={...r,dateFrom:b.value,dateTo:y.value}}),S.appendChild(b),S.appendChild(y),a.appendChild(S)}else{const S=document.createElement("input");S.type=i==="number"?"number":"text",S.className="ag-filter-input",S.value=r.filter??"",S.placeholder=this.grid.t("filterOoo"),S.addEventListener("input",()=>{d={...r,filter:S.value}}),S.addEventListener("keydown",b=>{b.key==="Enter"&&c()}),a.appendChild(S),setTimeout(()=>S.focus(),0)}else d={...r}}if(i==="text"||i==="number"){const m=document.createElement("div");m.className="ag-filter-second-condition";const C=document.createElement("select");C.className="ag-filter-condition",C.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,C.value=r.operator||"AND",m.appendChild(C);const S=this.buildConditionSelect(i==="number"?wt:vt,((g=r.condition2)==null?void 0:g.type)||(i==="number"?wt:vt)[0],y=>{d||(d={...r}),d.condition2={...d.condition2,type:y}});m.appendChild(S);const b=document.createElement("input");b.type=i==="number"?"number":"text",b.className="ag-filter-input",b.placeholder=this.grid.t("secondValue"),b.value=((v=r.condition2)==null?void 0:v.filter)??"",b.addEventListener("input",()=>{d||(d={...r}),d.condition2={...d.condition2,filter:b.value}}),m.appendChild(b),a.appendChild(m),C.addEventListener("change",()=>{d||(d={...r}),d.operator=C.value})}const f=document.createElement("div");f.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",c);const h=document.createElement("button");h.className="ag-button",h.textContent=this.grid.t("clear"),h.addEventListener("click",p),f.appendChild(h),f.appendChild(u),a.appendChild(f),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(g=>{!g.group&&!g.footer&&a.add(oe(e,g,this.grid.getApi()))});const r=[...a].sort((g,v)=>g===v?0:g<v?-1:1),d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((t.values||[]).map(g=>String(g))),p=()=>{d.innerHTML="";const g=o.value.toLowerCase();let v=0;for(const m of r){const C=m==null?"(Blanks)":String(m);if(g&&!C.toLowerCase().includes(g))continue;v++;const S=document.createElement("label");S.className="ag-set-filter-item";const b=document.createElement("input");b.type="checkbox",b.checked=c.has(String(m)),b.addEventListener("change",()=>{b.checked?c.add(String(m)):c.delete(String(m)),i({filterType:"set",values:[...c]})});const y=document.createElement("span");y.textContent=C,S.appendChild(b),S.appendChild(y),d.appendChild(S)}if(v===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),d.appendChild(m)}};o.addEventListener("input",p),p();const f=document.createElement("div");f.className="ag-set-filter-actions";const u=document.createElement("button");u.className="ag-button ag-button-small",u.textContent=this.grid.t("selectAll"),u.addEventListener("click",()=>{c.clear();for(const g of r)c.add(String(g));p(),i({filterType:"set",values:[...c]})});const h=document.createElement("button");return h.className="ag-button ag-button-small",h.textContent=this.grid.t("clearAll"),h.addEventListener("click",()=>{c.clear(),p(),i({filterType:"set",values:[]})}),f.appendChild(u),f.appendChild(h),n.appendChild(d),n.appendChild(f),i({filterType:"set",values:[...c]}),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 l=vs[o];a.textContent=l?this.grid.t(l):o,o===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n}openMultiFilter(e,t){var S;const i=this.grid.getFilterService().getFilterInstance(e.colId),n=i&&i.filterType==="multi"?i:null,o=(S=n==null?void 0:n.filterModels)!=null&&S.length?n.filterModels.map(b=>({...b})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(n==null?void 0:n.operator)||"AND";const{ePopup:l,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,l.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const p=document.createElement("span");p.textContent=this.grid.t("join");const 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}),c.appendChild(p),c.appendChild(f),l.appendChild(c);const u=document.createElement("div");u.className="ag-multi-filter-list",l.appendChild(u);const h=()=>{u.innerHTML="",o.forEach((b,y)=>{const R=document.createElement("div");R.className="ag-multi-filter-row";const M=document.createElement("select");M.className="ag-filter-condition";const T=["text","number","date","set","boolean"];for(const k of T){const $=document.createElement("option");$.value=k,$.textContent=k.charAt(0).toUpperCase()+k.slice(1),k===b.filterType&&($.selected=!0),M.appendChild($)}M.addEventListener("change",()=>{o[y]={...this.getDefaultModel(M.value)},h()}),R.appendChild(M);const W=b.filterType==="number"?wt:vt,E=this.buildConditionSelect(W,b.type||W[0],k=>{o[y].type=k});if(R.appendChild(E),b.filterType!=="blank"&&b.type!=="blank"&&b.type!=="notBlank"){const k=document.createElement("input");k.type=b.filterType==="number"?"number":"text",k.className="ag-filter-input",k.value=b.filter??"",k.placeholder=this.grid.t("value"),k.addEventListener("input",()=>{o[y].filter=k.value}),R.appendChild(k)}const x=document.createElement("button");x.className="ag-button ag-button-small",x.textContent="×",x.title=this.grid.t("removeFilter"),x.addEventListener("click",()=>{o.splice(y,1),h()}),R.appendChild(x),u.appendChild(R)})};h();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addFilter"),g.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),h()}),l.appendChild(g);const v=document.createElement("div");v.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",()=>{o.filter(y=>y.filter!==void 0&&y.filter!==""||y.type==="blank"||y.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(C),v.appendChild(m),l.appendChild(v),this.popupService.positionAt(l,t)}openAdvancedFilter(e){var S,b;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),n=(S=i==null?void 0:i.conditions)!=null&&S.length?i.conditions.map(y=>({...y})):[{colId:((b=this.grid.getColumns().center[0])==null?void 0:b.colId)??"",type:"contains",filter:""}];let o=(i==null?void 0:i.operator)||"AND";const{ePopup:a,close:l}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),a.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",a.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(y=>y.filter),p=()=>{d.innerHTML="",n.forEach((y,R)=>{const M=document.createElement("div");M.className="ag-advanced-filter-row";const T=document.createElement("select");T.className="ag-filter-condition";for(const F of c()){const G=document.createElement("option");G.value=F.colId,G.textContent=F.headerName||F.field||F.colId,F.colId===y.colId&&(G.selected=!0),T.appendChild(G)}T.addEventListener("change",()=>{n[R].colId=T.value}),M.appendChild(T);const W=this.grid.getColumn(y.colId),E=W&&W.filter!==!1?String(W.filter):"text",x=E==="number"?wt:vt,k=this.buildConditionSelect(x,y.type||"contains",F=>{n[R].type=F});M.appendChild(k);const $=document.createElement("input");$.type=E==="number"?"number":"text",$.className="ag-filter-input",$.value=y.filter??"",$.placeholder=this.grid.t("value"),$.addEventListener("input",()=>{n[R].filter=$.value}),M.appendChild($);const q=document.createElement("button");q.className="ag-button ag-button-small",q.textContent="×",q.addEventListener("click",()=>{n.splice(R,1),p()}),M.appendChild(q),d.appendChild(M)})};p();const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent="+ "+this.grid.t("addCondition"),f.addEventListener("click",()=>{var y;n.push({colId:((y=c()[0])==null?void 0:y.colId)??"",type:"contains",filter:""}),p()}),a.appendChild(f);const u=document.createElement("div");u.className="ag-multi-filter-operator";const h=document.createElement("span");h.textContent=this.grid.t("join");const g=document.createElement("select");g.className="ag-filter-condition",g.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',g.value=o,g.addEventListener("change",()=>{o=g.value}),u.appendChild(h),u.appendChild(g),a.appendChild(u);const v=document.createElement("div");v.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",()=>{const y=n.filter(R=>R.filter!==void 0&&R.filter!=="");y.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:y}):t.setAdvancedFilterModel(null),l()});const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",()=>{t.setAdvancedFilterModel(null),l()}),v.appendChild(C),v.appendChild(m),a.appendChild(v),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:r=>n.setColumnFilterModel(e,r),onGuiAttached:()=>{}}),{ePopup:a}=this.popupService.createPopup(260,"ag-filter-popup");a.innerHTML="";const l=typeof(o==null?void 0:o.getGui)=="function"?o.getGui():o;l instanceof HTMLElement&&a.appendChild(l),typeof(o==null?void 0:o.afterGuiAttached)=="function"&&o.afterGuiAttached(),this.popupService.positionAt(a,t)}getDefaultModel(e){return e==="number"?{filterType:"number",type:"equals",filter:""}:e==="date"?{filterType:"date",dateFrom:"",dateTo:""}:e==="set"?{filterType:"set",values:[]}:e==="boolean"?{filterType:"boolean",filter:!0}:{filterType:"text",type:"contains",filter:""}}isMeaningful(e){return e.filterType==="text"?!!e.filter||e.type==="blank"||e.type==="notBlank":e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0:!1}}class go{constructor(e){w(this,"filterModel",{});w(this,"advancedFilterModel",null);this.grid=e}getAdvancedFilterModel(){return this.advancedFilterModel}setAdvancedFilterModel(e){this.advancedFilterModel=e,this.onFilterChanged("api")}isAdvancedFilterEnabled(){return!!this.grid.getOptions().enableAdvancedFilter}doesNodePassAdvancedFilter(e){const t=this.advancedFilterModel;if(!t||!t.conditions||t.conditions.length===0)return!0;const i=this.grid.getRowModel(),n=typeof i.doesNodePassFilterModel=="function"?i.doesNodePassFilterModel.bind(i):null,o=t.conditions.map(a=>{const l=this.grid.getColumn(a.colId);return!l||!n?!0:n(e,l,{...a,filterType:l.filter===!0?"text":l.filter})});return t.operator==="OR"?o.some(Boolean):o.every(Boolean)}getFilterModel(){return this.filterModel}getFilterInstance(e){return this.filterModel[e]}setFilterModel(e){this.filterModel=e||{},this.onFilterChanged("api")}setColumnFilterModel(e,t){const 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 mo{constructor(e,t){w(this,"matches",[]);w(this,"activeMatch",0);w(this,"searchText","");w(this,"matchCase",!1);w(this,"ePopup",null);w(this,"eCount",null);w(this,"eInput",null);w(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const 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 l=(c,p,f)=>{const u=document.createElement("button");return u.className="ag-button ag-button-small",u.textContent=c,u.title=p,u.addEventListener("click",f),e.appendChild(u),u};l("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),l("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),l("×",this.grid.translate("close","关闭"),()=>this.close()),i.addEventListener("input",()=>this.find(i.value)),i.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),c.shiftKey?this.findPrevious():this.findNext()):c.key==="Escape"&&this.close()}),this.grid.getRootElement(),e.style.position="absolute",e.style.left="50%",e.style.top="8px",e.style.transform="translateX(-50%)",e.style.display="flex",setTimeout(()=>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){const a=kt(o,i,this.grid.getApi())??"",l=this.matchCase?a:a.toLowerCase(),r=this.matchCase?e:e.toLowerCase();l.includes(r)&&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 l=t.getPageSize(),r=Math.floor(e.rowIndex/l);r!==t.getCurrentPage()&&t.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const 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,l=this.matches.findIndex(r=>r.rowIndex===n&&r.colId===a);o.classList.toggle("ag-find-match",l>=0),o.classList.toggle("ag-find-active-match",l>=0&&l===this.activeMatch)}}}}class vo{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 l=document.createElement("div");l.className="ag-formula-preview";const r=()=>{const g=this.grid.getDisplayedRowAtIndex(0);if(!g){l.textContent="";return}try{const v=gt(a.value,{data:g.data});l.textContent=`${this.grid.t("formulaPreview")}: ${v==null?"":String(v)}`,l.classList.remove("ag-formula-error")}catch(v){l.textContent=`${this.grid.t("formulaError")}: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||this.grid.t("invalidFormula")}`,l.classList.add("ag-formula-error")}};a.addEventListener("input",r),i.appendChild(l);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent=this.grid.t("functions"),d.appendChild(c);const p=document.createElement("div");p.className="ag-formula-functions-list";for(const g of Mt){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=g,v.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${g}()`,a.focus(),r()}),p.appendChild(v)}d.appendChild(p),i.appendChild(d);const f=document.createElement("div");f.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",()=>{const g=a.value.trim(),v=this.grid.getColumnModel(),m=v.getColumn(e.colId);m&&(m.field=g==="="||g===""?e.field:g,m.colDef={...m.colDef,field:m.field},g!=="="&&g!==""&&(m.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),n()});const h=document.createElement("button");h.className="ag-button",h.textContent=this.grid.t("clear"),h.addEventListener("click",()=>{a.value="=",r()}),f.appendChild(h),f.appendChild(u),i.appendChild(f),this.popupService.positionAt(i,t),r()}}class wo{constructor(e,t){w(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:l,close:r}=this.popupService.createPopup(280,"ag-note-editor");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`${this.grid.t("note")} — ${(n==null?void 0:n.headerName)||t}`,l.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=a,c.placeholder=this.grid.t("writeNote"),l.appendChild(c);const p=document.createElement("div");p.className="ag-popup-buttons";const f=document.createElement("button");f.className="ag-button ag-button-primary",f.textContent=this.grid.t("save"),f.addEventListener("click",()=>{this.setNote(e,t,c.value.trim()||void 0),r()});const u=document.createElement("button");u.className="ag-button",u.textContent=this.grid.t("delete"),u.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),p.appendChild(u),p.appendChild(f),l.appendChild(p),this.popupService.positionAt(l,i),setTimeout(()=>c.focus(),0)}}class Co{constructor(e){w(this,"eOverlayWrapper");w(this,"current",null);this.grid=e,this.eOverlayWrapper=document.createElement("div"),this.eOverlayWrapper.className="ag-overlay",this.eOverlayWrapper.style.display="none";const t=e.getRowRenderer().getViewport();t.style.position="relative",this.eOverlayWrapper.style.position="absolute",this.eOverlayWrapper.style.inset="0",this.eOverlayWrapper.style.zIndex="10",t.appendChild(this.eOverlayWrapper)}show(e,t){this.current=e,this.eOverlayWrapper.innerHTML="";const 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}e.getRowCount()===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}class Oi{constructor(e,t){w(this,"enabled");w(this,"pageSize");w(this,"currentPage",0);w(this,"pageSizeSelector");w(this,"ePanel");w(this,"ePageInfo");w(this,"ePageInput");w(this,"ePageSizeContainer");w(this,"eFromToContainer");this.grid=e,this.eventService=t;const 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,l=document.createElement("span");l.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(l);const r=document.createElement("select");r.className="ag-pagination-page-size-select";const d=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const c of d){const p=document.createElement("option");p.value=String(c),p.textContent=String(c),c===this.pageSize&&(p.selected=!0),r.appendChild(p)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),a.appendChild(r)}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),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 l,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),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}),(r=(l=this.grid.getOptions()).onPaginationChanged)==null||r.call(l,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class yo{constructor(e){w(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 d;this.openPopups.has(n)&&(this.openPopups.delete(n),i.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",r,!0),(d=n.onClose)==null||d.call(n))},a=d=>{n.onClose=d},l=d=>{if(!i.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){o();return}i.contains(d.target)||o()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),o())};return this.getParent().appendChild(i),this.openPopups.add(n),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",r,!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 l=o.left-n.left+i;const r=n.width-a-4;l>r&&(l=r),l<4&&(l=4);const d=o.bottom-n.top+2;e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}class bo{constructor(e,t){w(this,"ranges",[]);w(this,"currentRange",null);w(this,"eOverlay");w(this,"eHandle");w(this,"dragState",null);this.grid=e,this.eventService=t;const 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((r,d)=>{r.id===o.id&&(a=d)}),a<0)return;const l=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(l.rowStartIndex,a),rowEndIndex:Math.max(l.rowStartIndex,a),colStartId:l.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(l.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(g=>g.colId===e.colStartId),n=t.findIndex(g=>g.colId===e.colEndId);if(i<0||n<0)return null;const o=Math.min(i,n),a=Math.max(i,n);let l=0,r=0;for(let g=0;g<=a;g++)g<o?l+=t[g].width:r+=t[g].width;const c=this.grid.getRowRenderer().getRowOffsets(),p=Math.min(e.rowStartIndex,e.rowEndIndex),f=Math.max(e.rowStartIndex,e.rowEndIndex),u=c[p]??p*(this.grid.getOptions().rowHeight??42);let h=0;for(let g=p;g<=f;g++){const v=this.grid.getDisplayedRowAtIndex(g);h+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:u,left:l,width:r,height:h}}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((l,r)=>{l.id===n&&(a=r)}),!(a<0))for(const l of o.getCellElements()){const r=l.dataset.colid,d=i.findIndex(f=>f.colId===r);let c=!1,p=!1;for(const f of e){const u=i.findIndex(S=>S.colId===f.colStartId),h=i.findIndex(S=>S.colId===f.colEndId),g=Math.min(f.rowStartIndex,f.rowEndIndex),v=Math.max(f.rowStartIndex,f.rowEndIndex),m=Math.min(u,h),C=Math.max(u,h);a>=g&&a<=v&&d>=m&&d<=C&&(c=!0,a===f.rowStartIndex&&d===u&&(p=!0))}l.classList.toggle("ag-cell-range-selected",c),l.classList.toggle("ag-cell-range-anchor",p)}}}getRangeCells(e){const t=this.getCenterColumns(),i=t.findIndex(c=>c.colId===e.colStartId),n=t.findIndex(c=>c.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),l=Math.min(i,n),r=Math.max(i,n),d=[];for(let c=o;c<=a;c++){const p=this.grid.getDisplayedRowAtIndex(c);if(p)for(let f=l;f<=r;f++)t[f]&&d.push({node:p,column:t[f]})}return d}getCurrentRange(){return this.currentRange}onGridKeyDown(e){if(this.isEnabled()){if((e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().copyToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="x"||e.key==="X")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().cutToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().pasteFromClipboard());return}if((e.keyCode===46||e.keyCode===8)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const i of this.getRangeCells(t))this.grid.setCellValue(i.column,i.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}class So{constructor(e,t){w(this,"dragState",null);w(this,"onMouseMoveBind",e=>this.onMouseMove(e));w(this,"onMouseUpBind",e=>this.onMouseUp(e));this.grid=e,this.eventService=t}isEnabled(){const e=this.grid.getOptions();return!!e.rowDragManaged||!!e.rowDragEnt||this.hasDragHandle()}hasDragHandle(){return this.grid.getAllColumns().some(e=>e.rowDrag)}startDrag(e,t){if(!this.isEnabled()||this.dragState)return;t.preventDefault();const 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,l)=>{a.id===n.dataset.rowid&&(o=l)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),l=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),r=e.clientY>n.getBoundingClientRect().top+l/2,d=(a[o]??0)+(r?l:0);t.indicator.style.display="block",t.indicator.style.top=`${d-1}px`}else t.indicator.style.display="none"}onMouseUp(e){const t=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!t)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),t.ghost.remove(),t.indicator.remove();const 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}})}}class Eo{constructor(e){w(this,"ePanel");w(this,"eChips");this.grid=e,this.ePanel=document.createElement("div"),this.ePanel.className="ag-row-group-panel";const t=document.createElement("span");t.className="ag-row-group-panel-label",t.textContent=this.grid.t("rowGroups"),this.ePanel.appendChild(t),this.eChips=document.createElement("div"),this.eChips.className="ag-row-group-panel-chips",this.ePanel.appendChild(this.eChips),this.eChips.addEventListener("dragover",o=>{o.preventDefault(),this.eChips.classList.add("ag-drag-over")}),this.eChips.addEventListener("dragleave",()=>this.eChips.classList.remove("ag-drag-over")),this.eChips.addEventListener("drop",o=>{var l;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(l=o.dataTransfer)==null?void 0:l.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const 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 l;(l=a.dataTransfer)==null||l.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 xo{constructor(e,t,i){w(this,"selectedNodes",new Set);w(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(d=>{d===e&&(n=a),d===t&&(o=a),a++}),n<0||o<0)return;const l=Math.min(n,o),r=Math.max(n,o);a=0,i.forEachNode(d=>{a>=l&&a<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(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 Ro{constructor(e){w(this,"eBar");w(this,"eButtons");w(this,"ePanel");w(this,"panels",[]);w(this,"activePanelId",null);w(this,"visible",!1);w(this,"position");var 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(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const l=(o==null?void 0:o.defaultToolPanel)||((n=this.panels[0])==null?void 0:n.id)||"columns";this.buildButtons(),this.openPanel(l)}else this.eBar.style.display="none"}defaultLabel(e){switch(e){case"columns":return this.grid.t("columns");case"filters":return this.grid.t("filters");case"charts":return this.grid.t("charts");default:return e}}buildButtons(){this.eButtons.innerHTML="";for(const e of this.panels){const t=document.createElement("button");t.className="ag-side-button",t.textContent=e.label,t.title=e.label,t.dataset.panelId=e.id,e.id===this.activePanelId&&t.classList.add("ag-selected"),t.addEventListener("click",()=>{this.activePanelId===e.id&&this.visible?this.setVisible(!1):(this.visible=!0,this.eBar.style.display="",this.openPanel(e.id)),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"sideBarButtonClicked",api:this.grid.getApi()})}),this.eButtons.appendChild(t)}}getElement(){return this.eBar}setPosition(e){this.position=e,this.eBar.classList.remove("ag-side-bar-left","ag-side-bar-right"),this.eBar.classList.add(`ag-side-bar-${e}`)}setVisible(e){this.visible=e,this.eBar.style.display=e?"":"none",this.grid.onGridSizeChanged(),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"api",api:this.grid.getApi()})}isVisible(){return this.visible}openPanel(e){this.activePanelId=e;for(const t of this.eButtons.querySelectorAll(".ag-side-button"))t.classList.toggle("ag-selected",t.dataset.panelId===e);switch(this.ePanel.innerHTML="",e){case"columns":this.ePanel.appendChild(this.buildColumnsPanel());break;case"filters":this.ePanel.appendChild(this.buildFiltersPanel());break;case"charts":this.ePanel.appendChild(this.grid.getChartService().buildChartPanel());break;default:{const t=document.createElement("div");t.className="ag-side-bar-empty",t.textContent=e,this.ePanel.appendChild(t)}}}getActivePanel(){return this.activePanelId}refresh(){this.activePanelId&&this.openPanel(this.activePanelId)}buildColumnsPanel(){const e=document.createElement("div");e.className="ag-column-panel";const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const i=document.createElement("div");i.className="ag-column-panel-columns",e.appendChild(i);const n=()=>{const d=t.value.toLowerCase();i.innerHTML="";const c=this.grid.getColumnModel().getColumns(),p=c.filter(f=>f.pinned!=="left"&&f.pinned!=="right").concat(c.filter(f=>f.pinned==="left"||f.pinned==="right"));for(const f of p)d&&!f.headerName.toLowerCase().includes(d)&&!f.colId.toLowerCase().includes(d)||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 l=document.createElement("div");l.className="ag-column-group-list",o.appendChild(l);const r=()=>{l.innerHTML="";const d=this.grid.getColumnModel().getRowGroupColumns();if(d.length===0){const c=document.createElement("div");c.className="ag-column-group-hint",c.textContent=this.grid.t("dragColumnsHere"),l.appendChild(c)}for(const c of d){const p=document.createElement("div");p.className="ag-column-group-item",p.draggable=!0,p.addEventListener("dragstart",h=>{var g;(g=h.dataTransfer)==null||g.setData("text/plain",c.colId)}),p.addEventListener("dragover",h=>h.preventDefault()),p.addEventListener("drop",h=>{var v;h.preventDefault();const g=(v=h.dataTransfer)==null?void 0:v.getData("text/plain");g&&this.grid.getColumnModel().setRowGroupColumns([...d.map(m=>m.colId),g])});const f=document.createElement("span");f.textContent=c.headerName,p.appendChild(f);const u=document.createElement("button");u.className="ag-column-group-remove",u.textContent="×",u.title=this.grid.t("remove"),u.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(c)),p.appendChild(u),l.appendChild(p)}};return r(),l.addEventListener("dragover",d=>d.preventDefault()),l.addEventListener("drop",d=>{var p;d.preventDefault();const c=(p=d.dataTransfer)==null?void 0:p.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&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 l=document.createElement("button");l.className="ag-column-select-action",l.title=this.grid.t("groupByThisColumn"),l.textContent="≡",l.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(l)}const a=document.createElement("button");return a.className="ag-column-select-action",a.title=this.grid.t("pinColumnTitle"),a.textContent="📌",a.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),o.appendChild(a),t.appendChild(o),t}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent=`${this.grid.t("advancedFilter")}…`,o.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(o)),e.appendChild(o);const a=this.grid.getFilterService().getAdvancedFilterModel();if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(l)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const 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(l=>l.filter);for(const l of a)o&&!l.headerName.toLowerCase().includes(o)||i.appendChild(this.buildFilterItem(l));if(!i.children.length){const l=document.createElement("div");l.className="ag-side-bar-empty",l.textContent=this.grid.t("noMatchingColumns"),i.appendChild(l)}};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 l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.innerHTML=Di,n.appendChild(l)}if(i.appendChild(n),e.filter==="set"){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=a?"Edit filter":"Add filter",l.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,l)),i.appendChild(l)}else if(e.filter==="date"){const l=document.createElement("input");l.type="date",l.className="ag-filter-input";const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.dateFrom)??"",l.addEventListener("change",()=>{t.setColumnFilterModel(e,l.value?{filterType:"date",dateFrom:l.value,dateTo:l.value}:null)}),i.appendChild(l)}else{const l=document.createElement("input");l.type=e.filter==="number"?"number":"text",l.className="ag-filter-input",l.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.filter)??"",l.addEventListener("input",()=>{t.handleFloatingFilterChange(e,l.value)}),i.appendChild(l)}if(a){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=this.grid.t("clear"),l.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(l)}return i}}class Mo{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(),l=e.sort;let r=a.indexOf(l)+1;r>=a.length&&(r=0);const d=a[r];if(!o)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,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 ko{constructor(e,t){w(this,"eBar");w(this,"panels",[]);this.grid=e,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 l=document.createElement("div");l.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(l);const r={def:a,ePanel:l,render:()=>this.renderPanel(a.key,l)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const 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,l=i.getSelectedNodes().length,r=[],d=this.grid.getColumnModel().getValueColumns().filter(c=>c.aggFunc);switch(this.grid.getRowModel().forEachNode(c=>{!c.footer&&c.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${He(a)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${He(n)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${He(n)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${He(l)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=i.getSelectedNodes().filter(f=>!f.group&&!f.footer),p=[];for(const f of d){const h=c.map(C=>oe(f,C,i)).filter(C=>typeof C=="number"&&!isNaN(C)),g=h.reduce((C,S)=>C+S,0),v=C=>C===null?"":He(C,f.decimals),m=[[this.grid.translate("average","Average"),h.length?g/h.length:null],[this.grid.translate("count","Count"),h.length],[this.grid.translate("min","Min"),h.length?Math.min(...h):null],[this.grid.translate("max","Max"),h.length?Math.max(...h):null],[this.grid.translate("sum","Sum"),h.length?g:null]];for(const[C,S]of m)p.push(`${C}${f.headerName?` (${f.headerName})`:""} : ${v(S)}`)}p.length&&r.push(p.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class To{constructor(e,t){w(this,"undoStack",[]);w(this,"redoStack",[]);w(this,"limit",50);w(this,"batchDepth",0);w(this,"batchBuffer",[]);w(this,"batchCounter",0);w(this,"currentBatchId",0);this.grid=e,this.eventService=t;const 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 Lo{constructor(e,t){w(this,"ctx");w(this,"eHeader");w(this,"ePinnedLeftHeader");w(this,"ePinnedRightHeader");w(this,"eHeaderViewport");w(this,"eHeaderContainer");w(this,"eHeaderRow");w(this,"eFloatingFiltersRow",null);w(this,"eGroupRows");w(this,"headerCells",new Map);w(this,"customHeaderComponents",new Map);w(this,"resizeState",null);w(this,"dragState",null);w(this,"lastWidths",new Map);this.ctx=t,this.eHeader=e,e.classList.add("ag-header"),e.style.height=`${t.headerHeight}px`,this.ePinnedLeftHeader=document.createElement("div"),this.ePinnedLeftHeader.className="ag-pinned-left-header",e.appendChild(this.ePinnedLeftHeader),this.eHeaderViewport=document.createElement("div"),this.eHeaderViewport.className="ag-header-viewport",e.appendChild(this.eHeaderViewport),this.eHeaderContainer=document.createElement("div"),this.eHeaderContainer.className="ag-header-container",this.eHeaderViewport.appendChild(this.eHeaderContainer),this.eGroupRows=document.createElement("div"),this.eGroupRows.className="ag-group-header-rows",this.eHeaderContainer.appendChild(this.eGroupRows),this.eHeaderRow=document.createElement("div"),this.eHeaderRow.className="ag-header-row",this.eHeaderContainer.appendChild(this.eHeaderRow),this.ePinnedRightHeader=document.createElement("div"),this.ePinnedRightHeader.className="ag-pinned-right-header",e.appendChild(this.ePinnedRightHeader),this.refresh()}refresh(){this.headerCells.clear(),this.renderGroupRows();const{left:e,center:t,right: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 l;const e=this.ctx.getColumnModel(),t=((l=e==null?void 0:e.getColumnGroups)==null?void 0:l.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((r,d)=>Math.max(r,d.depth),0),n=this.ctx.options.groupHeaderHeight??30;let o=0;for(let r=1;r<=i;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${n}px`;const c=this.ctx.getColumns().center;let p=0,f,u=0,h=0;const g=(m,C)=>{let S=m.groupId;for(;S;){const b=t.find(y=>y.id===S);if(!b)return null;if(b.depth===C)return b.id;S=b.parentId}return null},v=()=>{if(f==null)return;const m=t.find(y=>y.id===f);if(!m)return;const C=document.createElement("div");C.className="ag-header-group-cell",C.style.left=`${u}px`,C.style.width=`${h}px`,C.style.height=`${n}px`;const S=e.isGroupOpen(m.id),b=document.createElement("div");if(b.className="ag-header-group-cell-label",b.textContent=m.headerName,C.appendChild(b),!S){const y=document.createElement("span");y.className="ag-header-group-expand",y.textContent="▸",y.title=this.ctx.t("expandGroup"),C.appendChild(y)}C.addEventListener("click",()=>{e.setGroupOpen(m.id,!S)}),d.appendChild(C)};c.forEach(m=>{const C=g(m,r);C!==f&&(v(),f=C,u=p,h=0),h+=m.width,p+=m.width}),v(),d.style.width=`${p}px`,this.eGroupRows.appendChild(d),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 l=this.createFloatingFilter(o);l.style.left=`${n-o.width}px`,l.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(l)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${n}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${n}px`)}createHeaderCell(e){var a,l;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const r=i({column:e,colDef:e.colDef,api:((l=(a=this.ctx).getApi)==null?void 0:l.call(a))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),t.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const n=document.createElement("div");if(n.className="ag-header-cell-label",e.headerTooltip&&(n.title=e.headerTooltip),e.headerCheckboxSelection){const r=document.createElement("input");r.type="checkbox",r.className="ag-native-checkbox ag-header-select-all",r.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,r.checked)),r.addEventListener("click",d=>d.stopPropagation()),n.appendChild(r)}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 r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=qs,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=Ws,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const d=t.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=f=>{if(!this.resizeState)return;const u=f.clientX-this.resizeState.startX;let h=this.resizeState.startWidth+u;h=Math.max(e.minWidth,Math.min(e.maxWidth,h)),this.ctx.onColumnResized(e,Math.round(h),!1)},p=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",p),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",p)}),t.appendChild(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=t.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),t}createFloatingFilter(e){const t=document.createElement("div");if(t.className="ag-header-cell ag-floating-filter-cell",t.dataset.colid=e.colId,t.style.position="absolute",t.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const 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=Us):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=js),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 l=o.querySelector(".ag-filter-icon");l&&l.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 It{constructor(e,t,i,n,o,a,l){w(this,"eLeft",null);w(this,"eCenter",null);w(this,"eRight",null);w(this,"cellComps",[]);w(this,"pinned",!1);var r,d,c,p,f,u,h,g,v;if(this.ctx=e,this.node=t,this.rowHeight=a,t.masterNode){const m=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(m){const C=document.createElement("div");C.className="ag-row ag-row-detail-row",C.dataset.rowid=t.id,C.style.height=`${m.height}px`,C.style.width="100%",C.appendChild(m.eDetail),this.eCenter=C,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&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),t.group&&((p=this.eCenter)==null||p.classList.add("ag-row-group"),(f=this.eLeft)==null||f.classList.add("ag-row-group"),(u=this.eRight)==null||u.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((h=this.eCenter)==null||h.classList.add("ag-row-selected"),(g=this.eLeft)==null||g.classList.add("ag-row-selected"),(v=this.eRight)==null||v.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,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 r;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&&((r=e.groupData)!=null&&r.__grandTotal)&&(n.classList.add("ag-row-full-width"),n.style.width="100%",n.style.right="0",n.style.left="0");let l=0;for(let d=0;d<t.length;d++){const c=t[d],p=this.createCell(c,e);let f=1;typeof c.colDef.colSpan=="function"&&(f=Math.max(1,Math.round(c.colDef.colSpan({value:oe(c,e,null),data:e.data,node:e,column:c,rowIndex:e.__displayIndex??0,api:null}))));let u=c.width;for(let h=1;h<f&&d+h<t.length;h++)u+=t[d+h].width;p.eCell.style.left=`${l}px`,p.eCell.style.width=`${u}px`,p.eCell.style.position="absolute",p.eCell.style.top="0",p.eCell.style.height=`${this.rowHeight}px`,f>1&&p.eCell.classList.add("ag-cell-col-span"),l+=u,d+=f-1,n.appendChild(p.eCell),this.cellComps.push(p)}return n.style.width=`${l}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 c,p;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:oe(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,u]of Object.entries(e.cellClassRules))u(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 l=(p=(c=this.ctx).getNote)==null?void 0:p.call(c,t.id,e.colId,e.colDef.note,{value:oe(e,t,null),data:t.data,node:t,column:e,api:null});if(l){const f=document.createElement("span");f.className="ag-cell-note-marker",f.title=l,f.addEventListener("click",u=>{var h,g;u.stopPropagation(),(g=(h=this.ctx).onNoteClick)==null||g.call(h,t.id,e.colId,f)}),i.appendChild(f)}if(e.rowDrag){const f=document.createElement("span");f.className="ag-row-drag-handle",f.innerHTML=Ai,f.title=this.ctx.t("dragRow"),f.addEventListener("mousedown",u=>{var h,g;u.button===0&&(u.stopPropagation(),(g=(h=this.ctx).onRowDragStart)==null||g.call(h,t,f,u))}),i.appendChild(f)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?i.title=String(t.data[r]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:oe(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:i,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:t,node:i}={column:e.column,node:this.node},n=oe(t,i,null),o=kt(t,i,null);e.lastValue=n,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,l=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||l){e.custom=!0;const c=a||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const p={value: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&&Nt[a]){const u=Nt[a](p);u instanceof HTMLElement?f=u:(e.rendererInstance=u,f=u.getGui())}else if(l){const u=l(p);u instanceof HTMLElement?f=u:u&&typeof u.getGui=="function"?(e.rendererInstance=u,f=u.getGui()):typeof u=="string"&&(e.eValue.innerHTML=u)}f&&e.eValue.appendChild(f)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=o??"";if((i.group||i.footer)&&i.groupData){const c=i.groupData[t.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,i){var a,l,r,d;const n=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(n&&!n.has(c.column.colId))continue;const p=oe(c.column,this.node,null),f=t||p!==c.lastValue;if(!f&&!i)continue;const u=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:p,valueFormatted:kt(c.column,this.node,null),data:this.node.data,node:this.node,column:c.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:c.column.colDef,eGridCell:c.eCell,...c.column.cellRendererParams||{}})===!1&&this.updateCellContent(c),c.lastValue=p,i&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(f||i)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=p,i&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(i||f&&u!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"))}const o=this.ctx.isNodeSelected(this.node);(a=this.eCenter)==null||a.classList.toggle("ag-row-selected",o),(l=this.eLeft)==null||l.classList.toggle("ag-row-selected",o),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",o),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,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=[]}}function Bi(s,e,t){const i=s.length;if(i===0||t<=0)return[];let n=0,o=i-1;for(;n<o;){const c=n+o>>1;s[c]>=t?o=c:n=c+1}const a=s[n]>=t?n:i-1,l=e[a];if(!l||l.level===0)return[];const r=[];let d=l.level;for(let c=a-1;c>=0;c--){const p=e[c];if(!(!p||p.level>=d)&&(d=p.level,p.group&&s[c]<t&&r.push(c),p.level===0))break}return r.reverse()}class No{constructor(e,t,i){w(this,"ctx");w(this,"eRoot");w(this,"eHeader");w(this,"eBody");w(this,"ePinnedLeft");w(this,"ePinnedRight");w(this,"ePinnedLeftInner");w(this,"ePinnedRightInner");w(this,"eViewport");w(this,"eContainer");w(this,"eFloatingTop");w(this,"eFloatingBottom");w(this,"eFloatingTopLeft");w(this,"eFloatingTopRight");w(this,"eFloatingBottomLeft");w(this,"eFloatingBottomRight");w(this,"eStickyTop");w(this,"eStickyLeft");w(this,"eStickyCenter");w(this,"eStickyRight");w(this,"rowComps",new Map);w(this,"stickyComps",new Map);w(this,"hoveredRowId",null);w(this,"rowOffsets",[]);w(this,"rowIndices",new Map);w(this,"rowInfos",[]);w(this,"totalHeight",0);w(this,"lastScrollTop",-1);w(this,"lastRange",[-1,-1]);w(this,"heightVersion",0);w(this,"scrollFrame",null);w(this,"onSectionWheel",e=>{if(e.ctrlKey||!e.cancelable)return;const t=e.target;if(t!=null&&t.closest('input, textarea, select, [contenteditable="true"]'))return;const 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()});w(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)});w(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}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount();this.rowIndices.clear();const 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 l=0;l<e;l++)t[l]=l*a,i[l]=this.rowInfoAt(l);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=i}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?(this.rowIndices.set(t.id,e),{level:t.uiLevel??t.level??0,group:!!t.group}):{level:0,group:!1}}hasVariableHeights(){return!!(this.ctx.options.detailRowAutoHeight||this.ctx.options.getRowHeight)}getFixedRowHeight(){return this.ctx.options.rowHeight??42}getRowHeightForIndex(e){const t=this.ctx.rowModel.getRow(e);return t?this.ctx.getRowHeight(t):this.getFixedRowHeight()}refreshRows(){this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`;const e=this.ctx.getColumns().center.reduce((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,l,r,d)=>{o.innerHTML="",a.innerHTML="",l.innerHTML="";const{left:c,center:p,right:f}=this.ctx.getColumns();let u=0;for(let h=0;h<r;h++){const g=d(h);if(!g)continue;const v=this.ctx.getRowHeight(g),m=new It(this.ctx,g,c,p,f,v,this.heightVersion);m.appendTo(a,o,l),m.setTop(u),u+=v,this.rowComps.set(`${g.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${u}px`,o.style.display=r>0?"":"none",a.style.height=`${u}px`,l.style.height=`${u}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((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:l}=this.ctx.getColumns(),r=new It(this.ctx,i,o,a,l,this.getRowHeightForIndex(n),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[n]??0),this.rowComps.set(this.rowCompKey(i),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){return this.rowIndices.get(e.id)??-1}scheduleScrollRender(){this.scrollFrame===null&&(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=null,this.renderVisibleRows()}))}onScroll(){this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),this.ctx.eventService.dispatchEvent("bodyScroll",{direction:"vertical",top:this.eViewport.scrollTop,left:this.eViewport.scrollLeft})}syncPinnedScroll(){const e=`translateY(${-this.eViewport.scrollTop}px)`;this.ePinnedLeftInner.style.transform=e,this.ePinnedRightInner.style.transform=e,this.ePinnedLeft.scrollTop=this.eViewport.scrollTop,this.ePinnedRight.scrollTop=this.eViewport.scrollTop,this.syncStickyHorizontal()}syncStickyHorizontal(){const 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?[]:Bi(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 l=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;a.add(c.id);let p=this.stickyComps.get(c.id);if(!p){const f=this.rowComps.get(c.id);f&&(f.destroy(),this.rowComps.delete(c.id)),p=new It(this.ctx,c,t,i,n,this.getRowHeightForIndex(d),this.heightVersion),p.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),p.setSticky(!0),this.stickyComps.set(c.id,p)}p.setTop(l),l+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)a.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${l}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),i=this.eViewport.scrollTop,n=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a,l;if(this.hasVariableHeights())a=this.findIndexAtPixel(i)-o,l=this.findIndexAtPixel(i+n)+o;else{const v=this.getFixedRowHeight();a=Math.floor(i/v)-o,l=Math.ceil((i+n)/v)+o}if(a=Math.max(0,a),l=Math.min(t-1,l),!e&&this.lastRange[0]===a&&this.lastRange[1]===l&&this.lastScrollTop===i)return;const r=this.lastRange[0]!==a||this.lastRange[1]!==l;this.lastRange=[a,l],this.lastScrollTop=i;const d=new Set(this.stickyComps.keys()),c=this.syncStickyGroupRows(),p=d.size!==c.size||[...d].some(v=>!c.has(v));if(!e&&!r&&!p)return;const f=new Set(c),{left:u,center:h,right:g}=this.ctx.getColumns();for(let v=a;v<=l;v++){const m=this.ctx.rowModel.getRow(v);if(!m||(f.add(m.id),c.has(m.id)))continue;let C=this.rowComps.get(m.id);C||(C=new It(this.ctx,m,u,h,g,this.getRowHeightForIndex(v),this.heightVersion),C.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,C)),C.setTop(this.rowOffsets[v]??v*this.getFixedRowHeight())}for(const[v,m]of this.rowComps)!f.has(v)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(v))}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;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,l)=>a+l.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 l=this.ctx.rowModel.getRowNode(a);if(!l)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===n);return d?{node:l,column:d,eCell:i,rowIndex:this.findRowIndex(l)}:null}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:oe(t.column,t.node,null),rowIndex:this.findRowIndex(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.findRowIndex(n)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:oe(t.column,t.node,null),rowIndex:this.findRowIndex(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:oe(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:oe(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}destroy(){this.scrollFrame!==null&&cancelAnimationFrame(this.scrollFrame),this.scrollFrame=null;for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear()}}class Ge{constructor(){w(this,"cleanups",new Set);w(this,"stopped",!1)}get destroyed(){return this.stopped}add(e){return this.stopped?e():this.cleanups.add(e),()=>{this.cleanups.delete(e)&&e()}}listen(e,t,i,n){return e.addEventListener(t,i,n),this.add(()=>e.removeEventListener(t,i,n))}timeout(e,t){if(this.stopped)return 0;const i=window.setTimeout(()=>{n(),this.stopped||e()},t),n=this.add(()=>window.clearTimeout(i));return i}interval(e,t){if(this.stopped)return 0;const i=window.setInterval(()=>{this.stopped||e()},t);return this.add(()=>window.clearInterval(i)),i}destroy(){if(this.stopped)return;this.stopped=!0;const e=[...this.cleanups].reverse();this.cleanups.clear();let t;for(const i of e)try{i()}catch(n){t??(t=n)}if(t!==void 0)throw t}}function xe(s,e,t={},i=[]){const n=new Ge,o=new Set,a=f=>[...o].some(u=>u.contains(f)),l=new Set,r=new WeakMap,d=f=>{const u=f.target;if(!(u!=null&&u.closest))return;const h=u.closest('button,input,select,textarea,a,[data-action],[contenteditable],[role="button"],[role="tab"],[data-node-id],[data-rowid],[data-viewport],canvas');if(!h||!a(h))return;const g={};for(let m=h;m&&a(m);m=m.parentElement)for(const[C,S]of Object.entries(m.dataset))S!==void 0&&!(C in g)&&(g[C]=S);const v=h;r.has(f)||(r.set(f,{component:e,type:f.type,action:g.action??g.control,value:"value"in h?v.value:void 0,checked:v.type==="checkbox"||v.type==="radio"?v.checked:void 0,data:g,originalEvent:f}),queueMicrotask(()=>c(f)))},c=f=>{var g;const u=r.get(f);if(!u||n.destroyed)return;r.delete(f),(g=t.onInteraction)==null||g.call(t,u);for(const v of[...l])v(u);const h=s.ownerDocument.defaultView.CustomEvent;s.dispatchEvent(new h("rowvia:interaction",{detail:u,bubbles:!0}))},p=f=>{if(n.destroyed||o.has(f))return()=>{};o.add(f);const u=[];for(const h of["click","dblclick","contextmenu","input","change","submit","keydown","pointerdown","pointerup","wheel"])u.push(n.listen(f,h,d,{capture:!0,passive:!0}));return()=>{o.delete(f),u.forEach(h=>h())}};for(const f of[s,...i])p(f);return{addRoot:p,onInteraction(f){return n.destroyed?()=>{}:(l.add(f),()=>{l.delete(f)})},destroy(){n.destroy(),l.clear(),o.clear()}}}const Io={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 nt{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eventService",new ms);w(this,"columnModel");w(this,"rowModel");w(this,"clientSideRowModel",null);w(this,"serverSideRowModel",null);w(this,"infiniteRowModel",null);w(this,"viewportRowModel",null);w(this,"rowRenderer");w(this,"headerView");w(this,"selectionService");w(this,"editService");w(this,"filterService");w(this,"sortService");w(this,"paginationService",null);w(this,"popupService");w(this,"filterGui");w(this,"contextMenuService");w(this,"columnMenuService");w(this,"statusBarService");w(this,"sideBarService");w(this,"findService");w(this,"rangeSelectionService");w(this,"chartService");w(this,"overlayService");w(this,"exportService");w(this,"rowGroupPanel",null);w(this,"undoRedoService");w(this,"formulaEditorService");w(this,"notesService");w(this,"rowDragService");w(this,"api");w(this,"columnApi");w(this,"localeText");w(this,"rowNodeServices");w(this,"eGridDiv");w(this,"eRoot");w(this,"eMain");w(this,"eHeader");w(this,"quickFilter","");w(this,"resizeObserver",null);w(this,"destroyed",!1);w(this,"gridReadyDispatched",!1);w(this,"context");w(this,"onWindowResize",()=>{this.onGridSizeChanged()});w(this,"onDocumentMouseDown",e=>{var 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 d,c,p,f;this.eGridDiv=e,this.options={...Io,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Cs(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.interactions=xe(this.eRoot,"grid",this.options),this.onInteraction=this.interactions.onInteraction,this.eMain=document.createElement("div"),this.eMain.className="ag-main",this.eRoot.appendChild(this.eMain),this.eHeader=document.createElement("div"),this.eHeader.className="ag-header-wrapper",this.eMain.appendChild(this.eHeader),this.rowNodeServices={selectNode:(u,h)=>this.selectionService.selectNode(u,h),deselectNode:u=>this.selectionService.deselectNode(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u)},this.columnModel=new ki(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new xo(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),u=>this.isNodeSelectable(u)),this.filterService=new go(this),this.sortService=new Mo(this),this.popupService=new yo(this),this.filterGui=new fo(this,this.popupService),this.contextMenuService=new Ys(this,this.popupService),this.columnMenuService=new Ks(this,this.popupService),this.editService=new Xs(this,this.eventService),this.undoRedoService=new To(this,this.eventService),this.formulaEditorService=new vo(this,this.popupService),this.notesService=new wo(this,this.popupService),this.rowDragService=new So(this,this.eventService),this.chartService=new xs(this,this.popupService),this.findService=new mo(this,this.popupService),this.exportService=new po(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 bs(n),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new Ss(n),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new Es(n),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new ds({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var u;return!!((u=this.paginationService)!=null&&u.isEnabled())},getPageSize:()=>{var u;return((u=this.paginationService)==null?void 0:u.getPageSize())??100},getCurrentPage:()=>{var u;return((u=this.paginationService)==null?void 0:u.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(c=(d=this.rowModel).setGridApi)==null||c.call(d,null)),this.headerView=new Lo(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(u=>u.sort)}),onSortRequested:(u,h,g)=>this.sortService.onSortRequested(u,h,g),onColumnResized:(u,h,g)=>this.onColumnResized(u,h,g),onColumnMoved:(u,h)=>this.onColumnMoved(u,h),onColumnMenuClicked:(u,h)=>this.columnMenuService.openColumnMenu(u,h),onFilterOpened:(u,h)=>this.filterGui.openFilter(u,h),isFilterActive:u=>this.filterService.isFilterActive(u),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(u,h)=>this.filterService.handleFloatingFilterChange(u,h),onHeaderCheckboxChanged:(u,h)=>this.onHeaderCheckboxChanged(u,h),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:u=>this.t(u),getApi:()=>this.api,getFilterModel:u=>this.filterService.getFilterInstance(u)??null,onFilterModelChange:(u,h)=>this.filterService.setColumnFilterModel(u,h)}),this.rowRenderer=new No(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:u=>this.t(u),getColumns:()=>this.getColumns(),getRowHeight:u=>this.getRowHeight(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u),isRowSelectable:u=>this.isNodeSelectable(u),getRowClass:u=>this.getRowClass(u),getRowStyle:u=>this.getRowStyle(u),onCellClicked:u=>this.onCellClicked(u),onCellDoubleClicked:u=>this.editService.onCellDoubleClicked(u),onCellMouseDown:u=>this.onCellMouseDown(u),onCellContextMenu:u=>this.onCellContextMenu(u),onRowClicked:u=>this.onRowClicked(u),onRowDoubleClicked:u=>this.onRowDoubleClicked(u),onRowGroupClicked:u=>this.onRowGroupClicked(u),onViewportKeyDown:u=>this.onViewportKeyDown(u),onViewportScroll:()=>{var g,v,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const u=this.rowRenderer.getFirstVisibleRowIndex(),h=this.rowRenderer.getLastVisibleRowIndex();(g=this.serverSideRowModel)==null||g.onViewportChanged(u,h),(v=this.infiniteRowModel)==null||v.onViewportChanged(u,h),(m=this.viewportRowModel)==null||m.onViewportChanged(u,h)},getCellText:(u,h)=>{const g=oe(u,h,this.api);return g==null?"":String(g)},renderDetailRow:u=>this.renderDetailRow(u),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(u,h,g)=>this.rowDragService.startDrag(u,g),getNote:(u,h,g,v)=>this.notesService.getNote(u,h,g,v),onNoteClick:(u,h,g)=>this.notesService.openNoteEditor(u,h,g),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new bo(this,this.eventService),this.statusBarService=new ko(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Co(this),this.sideBarService=new Ro(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 Oi(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Eo(this));const{api:a,columnApi:l}=ls(this);this.api=a,this.columnApi=l,this.columnModel.setGridApi(this.api),(f=(p=this.rowModel).setGridApi)==null||f.call(p,this.api),this.selectionService.gridApiRef=this.api,this.eventService.addEventListener("columnEverythingChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("displayedColumnsChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("columnRowGroupChanged",()=>{this.serverSideRowModel||this.infiniteRowModel?this.onRemoteModelChanged():this.rowModel.refreshModel("group")}),this.options.__advancedFilterPass=u=>this.filterService.doesNodePassAdvancedFilter(u),this.eventService.addEventListener("columnPivotModeChanged",()=>this.refreshPivotColumns()),this.eventService.addEventListener("modelUpdated",()=>{this.columnModel.isPivotMode()&&this.refreshPivotColumns()}),this.eventService.addEventListener("sortChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("filterChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("columnValueChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("columnPivotModeChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("modelUpdated",()=>this.onModelUpdated()),this.eventService.addEventListener("selectionChanged",()=>{var u,h;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(h=(u=this.options).onSelectionChanged)==null||h.call(u,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let r=this.options.columnDefs||[];(!r||r.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(r=ki.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const 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 l of t){const r=oe(l,a,this.api);typeof r=="number"&&!isNaN(r)&&o.set(l.colId,(o.get(l.colId)??0)+r)}});for(const a of t)e.set(a.colId,o.get(a.colId)??0)}this.api.__columnTotalCache=e}refreshPivotColumns(){this.columnModel.updatePivotColumns(this.options.rowData||[])}onRemoteModelChanged(){this.serverSideRowModel?this.serverSideRowModel.onSortOrFilterChanged():this.infiniteRowModel?this.infiniteRowModel.onSortOrFilterChanged():this.viewportRowModel&&this.viewportRowModel.setViewportDatasource(this.viewportRowModel.datasource)}isRemoteLoading(){var e,t,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:oe(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:oe(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,l,r,d;const{node:t,column:i,event:n}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(l=(a=this.options).onCellClicked)==null||l.call(a,{...e,api:this.api,colDef:i.colDef,value:oe(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),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:i.colDef,value:oe(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 l=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);l&&l(e,!e.expanded),globalThis.__dbgLogs.push(["after-toggle",e.id,"expanded=",e.expanded]),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(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,l;this.updateColumnTotalCache(),this.rowRenderer.refreshRows(),this.options.__loadingRows=this.isRemoteLoading(),this.overlayService.updateAuto(),this.statusBarService.update(),(e=this.paginationService)==null||e.update(),this.rangeSelectionService.applyHighlight(),this.findService.applyHighlight(),this.chartService.refreshCharts(),this.gridReadyDispatched||(this.gridReadyDispatched=!0,this.eventService.dispatchEvent("firstDataRendered",{api:this.api}),(i=(t=this.options).onFirstDataRendered)==null||i.call(t,{api:this.api})),(o=(n=this.options).onModelUpdated)==null||o.call(n,{api:this.api}),(l=(a=this.options).onRowDataChanged)==null||l.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,l;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),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}),(l=(a=this.options).onGridSizeChanged)==null||l.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const t=e.masterNode;if(!t)return null;const 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,l=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(l&&r){const p=r({data:t.data,node:t,api:this.api}),f=document.createElement("div");f.style.height="100%",f.style.padding="8px 16px",o.appendChild(f),setTimeout(()=>{new nt(f,{...l,rowData:p,theme:this.options.theme})},0)}else if(typeof a=="function"){const p=a({data:t.data,node:t,api:this.api,context:this.context});p instanceof HTMLElement?o.appendChild(p):o.textContent=String(p??"")}else typeof a=="string"&&(o.textContent=a);if(i){const p=Math.max(40,o.scrollHeight||n);return e.rowHeight=p,o.style.height=`${p}px`,{eDetail:o,height:p}}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 Oi(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,this.interactions.destroy(),window.removeEventListener("resize",this.onWindowResize),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0),(e=this.resizeObserver)==null||e.disconnect(),this.rowRenderer.destroy(),this.editService.destroy(),this.popupService.closeAll(),this.eRoot.remove(),this.eGridDiv.classList.remove("ag-grid-root","ag-theme-alpine","ag-theme-quartz","ag-theme-balham"),this.eventService.dispatchEvent("gridReady",{}))}}function Vi(s,e){const t=new nt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function Gi(s,e={}){const t=document.createElement("dialog");t.className="rowvia-detail-dialog";const i=xe(t,"detail-dialog",e),n=()=>{var d;return(d=e.onClose)==null?void 0:d.call(e)};t.addEventListener("close",n);const o=document.createElement("h2"),a=document.createElement("dl"),l=document.createElement("button");l.type="button",l.textContent="关闭";const r=()=>t.close();return l.addEventListener("click",r),t.append(o,a,l),s.append(t),{onInteraction:i.onInteraction,open(d){var c;o.textContent=d.title,t.setAttribute("aria-label",d.title),a.replaceChildren();for(const p of d.fields){const f=document.createElement("dt"),u=document.createElement("dd");f.textContent=p.label,u.textContent=p.value,a.append(f,u)}t.open||t.showModal(),(c=e.onOpen)==null||c.call(e,d)},close:r,destroy(){t.open&&t.close(),l.removeEventListener("click",r),t.removeEventListener("close",n),i.destroy(),t.remove()}}}const Ao=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Do=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Fo=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Ee(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function st(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 Po{constructor(e,t,i,n){w(this,"filterFields");w(this,"sortFields");w(this,"filterRows",[]);w(this,"sorts",[]);w(this,"filterPanel",null);w(this,"sortPanel",null);w(this,"filterAnchor",null);w(this,"sortAnchor",null);w(this,"onDocumentMouseDown",e=>{var 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=Ee("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",d=>d.stopPropagation());const i=Ee("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const n=Ee("div","gt-filter-rows");t.appendChild(n);const o=()=>{if(n.textContent="",!this.filterRows.length){const d=Ee("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",n.appendChild(d)}for(const d of this.filterRows)n.appendChild(this.renderFilterRow(d,o))},a=Ee("div","gt-filter-add");for(const d of this.filterFields)a.appendChild(st(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const l=Ee("div","gt-panel-hint");l.textContent="多个条件同时满足(且)",t.appendChild(l);const r=Ee("div","gt-panel-actions");r.append(st("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),st("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const i=Ee("div","gt-filter-row"),n=this.filterFields.find(d=>d.colId===e.colId),o=document.createElement("select");o.className="gt-panel-select";for(const d of this.filterFields){const c=document.createElement("option");c.value=d.colId,c.textContent=d.label,d.colId===e.colId&&(c.selected=!0),o.appendChild(c)}o.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===o.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),i.appendChild(o);const a=e.kind==="number"?Do:e.kind==="date"?Fo:Ao,l=document.createElement("select");l.className="gt-panel-select gt-panel-select-cond";for(const d of a){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),l.appendChild(c)}if(l.addEventListener("change",()=>{e.type=l.value,t()}),i.appendChild(l),e.type!=="blank")if(n!=null&&n.options){const d=document.createElement("select");d.className="gt-panel-select";const c=document.createElement("option");c.value="",c.textContent="请选择",d.appendChild(c);for(const p of n.options){const f=document.createElement("option");f.value=p.value,f.textContent=p.label,p.value===e.value&&(f.selected=!0),d.appendChild(f)}d.addEventListener("change",()=>{e.value=d.value}),i.appendChild(d)}else if(e.kind==="date"){const d=document.createElement("input");if(d.type="date",d.className="gt-panel-input",d.value=e.value,d.addEventListener("change",()=>{e.value=d.value}),i.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="date",c.className="gt-panel-input",c.value=e.valueTo,c.addEventListener("change",()=>{e.valueTo=c.value}),i.appendChild(c)}}else if(e.kind==="number"){const d=document.createElement("input");if(d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="数值",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),i.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="至",c.value=e.valueTo,c.addEventListener("input",()=>{e.valueTo=c.value}),i.appendChild(c)}}else{const d=document.createElement("input");d.type="text",d.className="gt-panel-input",d.placeholder="文本",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),i.appendChild(d)}const r=st("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),t()});return r.title="移除条件",i.appendChild(r),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=Ee("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",l=>l.stopPropagation());const i=Ee("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const n=Ee("div","gt-sort-list");t.appendChild(n);const o=()=>{var l;n.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(u=>u.colId===r.colId),c=d>=0,p=Ee("div","gt-sort-item");c&&p.classList.add("gt-sort-item-active");const f=Ee("span","gt-sort-label");if(f.textContent=r.label,p.appendChild(f),c){const u=Ee("span","gt-sort-badge");u.textContent=String(d+1),p.appendChild(u);const h=Ee("span","gt-sort-dir");h.textContent=((l=this.sorts[d])==null?void 0:l.sort)==="asc"?"↑ 升序":"↓ 降序",p.appendChild(h)}p.addEventListener("click",()=>{var u;c?((u=this.sorts[d])==null?void 0:u.sort)==="asc"?this.sorts[d]={colId:r.colId,sort:"desc"}:this.sorts=this.sorts.filter(h=>h.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),o()}),n.appendChild(p)}},a=Ee("div","gt-panel-actions");a.append(st("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),st("应用","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 zi=864e5;function je(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 ke(s){return new Date(`${s}T00:00:00`)}function Re(s,e){return new Date(s.getTime()+e*zi)}function Oe(s,e){const t=typeof s=="string"?ke(s):s,i=typeof e=="string"?ke(e):e;return Math.round((i.getTime()-t.getTime())/zi)}function Ct(){return je(new Date)}function $o(s){return s.status!=="done"&&s.end&&s.end<Ct()&&s.progress<100?"delayed":s.status}function Kt(s){const e=ke(s);return`${e.getMonth()+1}月${e.getDate()}日`}const _i=["day","week","biweek","month","bimonth","quarter","halfyear","year"],At={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Ho={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2};function Yt(s){const e=(s.getDay()+6)%7;return Re(s,-e)}function Oo(s,e){const t=Math.max(1,Oe(s,e)+1);let i=0;for(let n=0;n<t;n++){const o=Re(s,n).getDay();o!==0&&o!==6&&i++}return Math.max(1,i)}function Bo(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function Wi(s,e,t){const i=[];if(s==="day"){let r=new Date(e);for(;r<t;){const d=Re(r,1);i.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return i}if(s==="week"||s==="biweek"){let r=Yt(e);for(;r<t;){const d=Re(r,s==="biweek"?14:7);i.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return i}const n=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/n)*n,1),a=r=>s==="month"||s==="bimonth"?`${r.getMonth()+1}月`:s==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let l=o(e);for(;l<t;){const r=Bo(l,n);i.push({start:new Date(l),end:r,primary:a(l),secondary:""}),l=r}return i}const ve={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)"},Dt={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},Vo=4,qi=6,De=28;class Ui{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eRoot");w(this,"eHeader");w(this,"eRuler");w(this,"rulerCtx");w(this,"eRulerTools");w(this,"eStepLabel");w(this,"eZoomValue");w(this,"eStepMenu",null);w(this,"eScroll");w(this,"eSpacer");w(this,"eCanvas");w(this,"ctx");w(this,"eTooltip");w(this,"eTodayBadge");w(this,"ePopup",null);w(this,"tasks",[]);w(this,"tasksById",new Map);w(this,"rows",[]);w(this,"selectedId",null);w(this,"hoverId",null);w(this,"unit","day");w(this,"zoom",1);w(this,"theme","content");w(this,"epochStart",new Date);w(this,"totalDays",1);w(this,"hits",[]);w(this,"hitsByRow",new Map);w(this,"drag",null);w(this,"ghost",null);w(this,"dirty",!0);w(this,"lastLeft",-1);w(this,"lastTop",-1);w(this,"timer");w(this,"observer",null);w(this,"resizeHandler",()=>this.resizeCanvases());w(this,"showChildren",!0);w(this,"milestonesOnly",!1);w(this,"locateHits",[]);w(this,"tick",()=>{const e=this.eScroll.scrollLeft,t=this.eScroll.scrollTop;(e!==this.lastLeft||t!==this.lastTop||this.dirty)&&(this.lastLeft=e,this.lastTop=t,this.eCanvas.style.transform=`translate(${e}px, ${t}px)`,this.draw(),this.dirty=!1)});w(this,"onScroll",()=>{this.tick()});w(this,"todayLabelX",-1);w(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex: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())});w(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),i=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-t.left))<12&&Math.abs(d.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),l=this.rows[o];if(n){const d=this.tasksById.get(n.id);if(!d)return;if(a){e.stopPropagation(),this.openAssigneePopup(n.id,n);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(n.id);return}e.preventDefault(),this.drag={id:n.id,mode:n.mode,startX:e.clientX,startY:e.clientY,originStart:d.start,originEnd:d.end,start:d.start,end:d.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(n.id);return}if(!l)return;const r=this.tasksById.get(l.id);if(r){if(r.kind==="task"&&(!r.start||!r.end)){const d=this.pointAt(e.clientX,e.clientY),c=Math.floor(d.x/this.dayWidth),p=je(Re(this.epochStart,c));this.options.onTaskChange({...r,start:p,end:je(Re(ke(p),4)),progress:0,status:"not-started"}),this.options.onSelect(l.id);return}this.options.onSelect(l.id)}});w(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const i=this.tasksById.get(t.id);if(!i||!t.moved&&Math.abs(e.clientX-t.startX)<Vo)return;t.moved=!0;const n=this.dayWidth,o=Math.round((e.clientX-t.startX)/n),a=ke(t.originStart),l=ke(t.originEnd),r=Oe(a,l);let d,c;t.mode==="resize-l"?(d=Re(a,Math.min(o,r)),c=l):t.mode==="resize-r"?(d=a,c=Re(l,Math.max(o,-r))):(d=Re(a,o),c=Re(l,o)),i.milestone&&(d=c),t.start=je(d),t.end=je(c),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?Kt(t.start):`${Kt(t.start)} → ${Kt(t.end)}`;const p=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-p.left+12}px`,this.eTooltip.style.top=`${e.clientY-p.top+16}px`});w(this,"endDrag",()=>{window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.eTooltip.style.display="none";const e=this.drag;if(this.drag=null,this.ghost=null,this.markDirty(),!(e!=null&&e.moved)||e.start===e.originStart&&e.end===e.originEnd)return;const t=this.tasksById.get(e.id);t&&this.options.onTaskChange({...t,start:e.start,end:e.end})});w(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});w(this,"onDocumentMouseDown",e=>{const t=e.target;this.ePopup&&!this.ePopup.contains(t)&&this.closeAssigneePopup(),this.eStepMenu&&!this.eStepMenu.contains(t)&&!this.eRulerTools.contains(t)&&this.closeStepMenu()});this.options=t,this.eRoot=document.createElement("div"),this.interactions=xe(this.eRoot,"gantt-chart",t),this.onInteraction=this.interactions.onInteraction,this.eRoot.className="gt-root",e.appendChild(this.eRoot),this.eHeader=document.createElement("div"),this.eHeader.className="gt-header",this.eRuler=document.createElement("canvas"),this.eRuler.className="gt-ruler",this.eHeader.appendChild(this.eRuler),this.eRoot.appendChild(this.eHeader),this.rulerCtx=this.eRuler.getContext("2d"),this.buildRulerTools(),this.eScroll=document.createElement("div"),this.eScroll.className="gt-scroll",this.eSpacer=document.createElement("div"),this.eSpacer.className="gt-spacer",this.eCanvas=document.createElement("canvas"),this.eCanvas.className="gt-canvas",this.eScroll.append(this.eSpacer,this.eCanvas),this.eRoot.appendChild(this.eScroll),this.ctx=this.eCanvas.getContext("2d"),this.eTooltip=document.createElement("div"),this.eTooltip.className="gt-tooltip",this.eTooltip.style.display="none",this.eRoot.appendChild(this.eTooltip),this.eTodayBadge=document.createElement("div"),this.eTodayBadge.className="gt-today-badge",this.eRoot.appendChild(this.eTodayBadge),this.eScroll.addEventListener("scroll",this.onScroll),this.eCanvas.addEventListener("mousedown",this.onCanvasMouseDown),this.eCanvas.addEventListener("mousemove",this.onCanvasMouseMove),this.eRoot.addEventListener("mouseleave",this.onRootMouseLeave);const 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;this.interactions.destroy(),clearInterval(this.timer),(e=this.observer)==null||e.disconnect(),window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.closeAssigneePopup(),this.closeStepMenu(),this.eRoot.remove()}setHover(e){this.hoverId!==e&&(this.hoverId=e,this.markDirty())}setShowChildren(e){this.showChildren=e,this.markDirty()}setMilestonesOnly(e){this.milestonesOnly=e,this.markDirty()}scrollToTask(e){const t=this.tasksById.get(e);t!=null&&t.start&&(this.eScroll.scrollLeft=Math.max(0,this.dateX(t.start)-this.eScroll.clientWidth*.12),this.markDirty())}setTasks(e){this.tasks=e,this.tasksById=new Map(e.map(t=>[t.id,t])),this.computeDomain(),this.markDirty()}setRows(e){e.length===this.rows.length&&e.every((t,i)=>{const n=this.rows[i];return t.id===n.id&&t.group===n.group&&t.expanded===n.expanded})||(this.rows=e,this.markDirty())}setSelected(e){this.selectedId=e,this.markDirty()}setUnit(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.unit=e,this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setZoom(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.zoom=Math.max(.5,Math.min(3,e)),this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setTheme(e){this.theme=e,this.markDirty()}get dayWidth(){return Ho[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(Ct()),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=Ct();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const n=Yt(Re(ke(e),-7));this.epochStart=n,this.totalDays=Math.max(Oe(n,ke(t))+730,1095)}dateX(e){return Oe(this.epochStart,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 l=Re(this.epochStart,this.totalDays),r=(p,f,u,h)=>{for(const g of p){const v=this.dateX(je(g.start))-a,m=Oe(g.start,g.end)*e;if(v+m<=0||v>=n)continue;const C=Math.max(0,Math.min(v+m,n)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const y=g.start.getDay();(y===0||y===6)&&(i.fillStyle=ve.weekend,i.fillRect(Math.max(0,v),f,C,u))}const S=i.measureText(g.primary).width;if(S+8<C){const y=Math.max(0,v)+C/2-S/2,R=f+u/2+5;i.fillStyle=ve.text,i.font="11px "+ze,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(g.primary,y,R),g.secondary&&(i.fillStyle=ve.textTertiary,i.font="10px "+ze,i.fillText(g.secondary,y,R+12))}}},d=40,c=Re(this.epochStart,Math.floor(a/e));i.fillStyle=ve.text,i.font="14px "+ze,i.textAlign="left",i.textBaseline="middle",i.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(Wi(this.unit,this.epochStart,l),d+1,o-d-1),i.strokeStyle=ve.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,l=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;o.clearRect(0,0,a,l),o.fillStyle="#fff",o.fillRect(0,0,a,l),o.save(),o.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,d+l)),this.drawGridlines(e,t,Math.max(i,d+l)),this.drawRowBackgrounds(t,n);const c=this.rows.findIndex(f=>f.id===this.hoverId),p=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(p==null?void 0:p.kind)==="task"&&!p.start){const f=c*n+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,ot(o,r+4,f,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=ve.textTertiary,o.font="14px "+ze,o.textAlign="center",o.fillText("新建排期",r+a/2,f+19)}this.drawDependencies(n),this.drawBars(n),this.drawTodayLine(t,Math.max(i,d+l)),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=ve.weekend;let o=Yt(this.epochStart);for(;Oe(this.epochStart,o)<this.totalDays;){const a=this.dateX(je(o))+5*e;a<t&&n.fillRect(Math.max(0,a),0,e*2,i),o=Re(o,7)}}drawGridlines(e,t,i){const n=this.ctx,o=Re(this.epochStart,this.totalDays);for(const a of Wi(this.unit,this.epochStart,o)){const l=Math.round(this.dateX(je(a.start)))+.5;if(l<0||l>t)continue;const r=this.unit==="day"&&a.start.getDate()===1;n.strokeStyle=r?ve.gridlineMonth:ve.gridline,n.beginPath(),n.moveTo(l,0),n.lineTo(l,i),n.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=ve.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,l=this.hoverId===n.id;(a||l)&&(i.fillStyle=a?ve.selected:l?ve.hover:ve.groupRow,i.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,n=Math.round(this.dateX(Ct())+this.dayWidth/2)+.5;n<0||n>e||(i.strokeStyle=ve.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=Ct().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=ve.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 l of o.dependsOn){const r=this.tasksById.get(l),d=t.get(l);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),p=r.milestone?this.dayWidth:Math.max(Oe(ke(r.start),ke(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),f=c+p,u=d*e+e/2,h=this.dateX(o.start),g=Math.max(Oe(ke(o.start),ke(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=a*e+e/2,m=f+10;if(h-4>m)ji(i,f,u,m,v,h-5,v);else{const C=h+g+10;ji(i,f,u,m,v,C,v)}zo(i,h-5,v)}}}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-De)/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 u;const n=this.ctx,o=((u=this.ghost)==null?void 0:u.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,l=(o==null?void 0:o.end)??e.end,r=this.dateX(a),d=Math.max(28,(Oe(a,l)+1)*this.dayWidth),c=Dt[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?ve.accent:"#dee0e3",n.lineWidth=1,ot(n,r,i,d,De,4),n.fill(),n.stroke(),n.save(),ot(n,r,i,d,De,4),n.clip(),n.beginPath(),n.arc(r+14,i+14,6,0,Math.PI*2),n.fillStyle=c,n.fill(),n.font="12px "+ze,n.textBaseline="middle",n.textAlign="left",n.fillStyle=ve.text;const p=this.options.members.find(h=>h.id===e.owner),f=n.measureText(e.name).width;d>f+58?(n.fillText(e.name,r+26,i+14),p&&Xt(n,r+f+42,i+14,7,Ft(p.id),p.name.slice(0,1))):p&&d>46&&Xt(n,r+38,i+14,7,Ft(p.id),p.name.slice(0,1)),d>100&&(n.fillStyle=ve.textTertiary,n.textAlign="right",n.fillText(String(Oo(ke(a),ke(l))),r+d-8,i+14)),n.restore(),n.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:i,w:d,h:De,mode:"move",avatar:p?{x:r+(d>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(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),o=n[0],a=this.ctx,l=this.dateX(e.start),r=Math.max(92,(Oe(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?ve.accent:"#dee0e3",a.lineWidth=1,ot(a,l,i,r,De,4),a.fill(),a.stroke(),a.fillStyle=o?Dt[o.status]:Dt[e.status],a.beginPath(),a.arc(l+14,i+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":ve.text,a.font="11px "+ze,a.textAlign="left",a.textBaseline="middle";const d=((o==null?void 0:o.name)??e.name)+(n.length>1?` +${n.length-1}`:"");a.fillText(Go(a,d,r-32),l+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:l,y:i,w:r,h:De,mode:"move"})}drawMilestone(e,t,i){var v;const n=this.ctx,o=this.dayWidth,a=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,l=a?a.start:e.start,r=$o(e),d=Dt[r],c=this.dateX(l)+o/2;n.font="12px "+ze;const p=n.measureText(e.name).width,f=e.owner?24:0,u=19+p+f+14,h=c-u/2;n.fillStyle="#fff",n.strokeStyle=d,n.lineWidth=1.5,ot(n,h,i,u,De,4),n.fill(),n.stroke(),n.fillStyle=d,n.beginPath(),n.arc(h+7+3,i+De/2,3,0,Math.PI*2),n.fill(),n.fillStyle=ve.text,n.textAlign="left",n.textBaseline="middle",n.fillText(e.name,h+14+5,i+De/2+1);let g;if(e.owner){const m=this.options.members.find(C=>C.id===e.owner);m&&(Xt(n,h+u-12,i+De/2,9,Ft(m.id),m.name.slice(0,1)),g={x:h+u-12,y:i+De/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:h,y:i,w:u,h:De,mode:"move",avatar:g})}pushHit(e){this.hits.push(e);const t=this.hitsByRow.get(e.rowIndex);t?t.push(e):this.hitsByRow.set(e.rowIndex,[e])}drawLocateButtons(){this.locateHits=[];const e=this.ctx,t=this.eScroll.scrollLeft,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 l=this.dateX(a.start),r=this.dateX(a.end)+this.dayWidth;if(r>=t&&l<=t+i)return;const d=r<t?10:i-18,c=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",ot(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+ze,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<t?"‹":"›",d+1,c),this.locateHits.push({id:a.id,x:d+1,y:c}))})}pointAt(e,t){const 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 l=i.x-a.avatar.x,r=i.y-a.avatar.y;if(l*l+r*r<=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 l=a.kind==="task"&&i.x<=a.x+qi,r=a.kind==="task"&&i.x>=a.x+a.w-qi;return{hit:{...a,mode:l?"resize-l":r?"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=At[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 _i){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=At[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=At[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 d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",i.owner===d.id&&c.classList.add("gt-popup-item-active");const p=document.createElement("span");p.className="gt-avatar",p.textContent=d.name.slice(0,1),p.style.backgroundColor=Ft(d.id);const f=document.createElement("span");f.textContent=d.name,c.append(p,f),c.addEventListener("click",u=>{u.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),n.appendChild(c)}if(i.owner){const d=document.createElement("div");d.className="gt-popup-item gt-popup-clear",d.textContent="取消负责人",d.addEventListener("click",c=>{c.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),n.appendChild(d)}const a=this.eRoot.getBoundingClientRect(),l=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;n.style.left=`${Math.min(a.width-150,Math.max(0,l-40))}px`,n.style.top=`${r+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 ze="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function ot(s,e,t,i,n,o){const a=Math.max(0,i),l=Math.max(0,n);if(a===0||l===0)return;const r=Math.max(0,Math.min(o,a/2,l/2));s.beginPath(),s.moveTo(e+r,t),s.lineTo(e+a-r,t),s.arcTo(e+a,t,e+a,t+r,r),s.lineTo(e+a,t+l-r),s.arcTo(e+a,t+l,e+a-r,t+l,r),s.lineTo(e+r,t+l),s.arcTo(e,t+l,e,t+l-r,r),s.lineTo(e,t+r),s.arcTo(e,t,e+r,t,r),s.closePath()}function Xt(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 ${ze}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function Go(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 ji(s,e,t,i,n,o,a){const r=n>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(i-5,t),s.quadraticCurveTo(i,t,i,t+5*r),s.lineTo(i,n-5*r),s.quadraticCurveTo(i,n,i+5*r,n),s.lineTo(o,a),s.stroke()}function zo(s,e,t){s.fillStyle=ve.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 Ki=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function Ft(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return Ki[e%Ki.length]}const _o={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 Wo(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:gn(t),n=S=>t.querySelector(S);n(".gantt-title-name").textContent=e.title??"甘特图";let o=structuredClone(e.tasks),a=new Map(o.map(S=>[S.id,S])),l,r,c=!0,d=!1;const u=n(".gantt-left");u.style.width=`${e.tableWidth??280}px`;const p=new AbortController,g=p.signal,C=n(".gantt-status");function h(){if(!l||d)return;m.setTasks(o);const S=Array.from({length:l.getDisplayedRowCount()},(q,ee)=>l.getDisplayedRowAtIndex(ee)).filter(Boolean);m.setRows(S.map(q=>({id:q.id,group:!!q.group,expanded:!!q.expanded})));const $=o.filter(q=>q.path.length===1),z=$.filter(q=>q.status==="done").length;C.textContent=`总工作项数 ${$.length} 完成进度 ${$.length?Math.round(z/$.length*100):0}%`}function f(S){var q;o=o.map(ee=>ee.id===S.id?{...S}:ee),a=new Map(o.map(ee=>[ee.id,ee]));const $=[S];let z=S.path.slice(0,-1);for(;z.length;){const ee=o.find(Z=>Z.path.join("/")===z.join("/"));if(!ee)break;const se=o.filter(Z=>Z.path.length===z.length+1&&Z.path.slice(0,-1).join("/")===z.join("/")),V=se.flatMap(Z=>Z.start?[Z.start]:[]).sort(),U=se.flatMap(Z=>Z.end?[Z.end]:[]).sort();ee.start=V[0]??null,ee.end=U[U.length-1]??null,$.push(ee),z=z.slice(0,-1)}l.applyTransaction({update:$}),h(),(q=e.onTaskChange)==null||q.call(e,structuredClone(S))}const m=new wn(n(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:S=>{var z;m.setSelected(S);const $=S?l==null?void 0:l.getRowNode(S):null;$&&((z=l.selectNode)==null||z.call(l,$,!0))},onHover:S=>{var $;t.querySelectorAll(".ag-row-hover").forEach(z=>z.classList.remove("ag-row-hover")),S&&(($=Array.from(t.querySelectorAll(".ag-row")).find(z=>z.dataset.rowid===S))==null||$.classList.add("ag-row-hover"))},onTaskChange:f,onAssign:(S,$)=>{const z=a.get(S);z&&f({...z,owner:$})}});function b(S){const $=S.data,z=document.createElement("span");if(z.className="gt-task-name",$.path.length>1?z.classList.add("gt-child-name"):S.node.group||z.classList.add("gt-root-leaf"),$.path.length>1){const ee=document.createElement("span");ee.className=`gt-node-dot gt-node-${$.status}`,z.append(ee)}const q=document.createElement("button");return q.className="gt-title-link",q.textContent=$.name,q.title=$.name,q.addEventListener("click",()=>{m.scrollToTask($.id),e.onTaskOpen?e.onTaskOpen(structuredClone($)):i==null||i.open({title:$.name,fields:[{label:"排期",value:`${$.start??"未设置"} — ${$.end??"未设置"}`}]})}),z.append(q),z}const R=document.createElement("button");R.className="gt-tree-toggle",R.textContent="▾",R.title="收起全部子层级",R.setAttribute("aria-label",R.title);function k(S){c=S,S?l.expandAll():l.collapseAll(),R.textContent=S?"▾":"▸",R.title=S?"收起全部子层级":"展开全部子层级",R.setAttribute("aria-label",R.title),h()}R.addEventListener("click",()=>k(!c));const y=["name","status","start","end","owner","progress"].map(S=>({field:S,hide:!0,filter:!0}));r=new Nt(n(".grid"),{columnDefs:y,rowData:o,treeData:!0,getDataPath:S=>S.path,getRowId:S=>S.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:Qs,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const S=document.createElement("div");return S.className="gt-title-header",S.append(R,document.createTextNode("标题")),S},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:b}},onGridReady:S=>{l=S.api,h()},onModelUpdated:S=>{l=S.api,h()},onRowGroupOpened:h,onRowClicked:S=>{var $;return m.setSelected((($=S.node)==null?void 0:$.id)??null)}}),l=r.getApi();const M=n(".ag-body-viewport");let P=!1;const D=(S,$)=>{P||(P=!0,$.scrollTop=S.scrollTop,P=!1)};M.addEventListener("scroll",()=>D(M,m.scrollElement),{signal:g}),m.scrollElement.addEventListener("scroll",()=>D(m.scrollElement,M),{signal:g}),M.addEventListener("mousemove",S=>{const $=S.target.closest(".ag-row");m.setHover(($==null?void 0:$.dataset.rowid)??null)},{signal:g}),M.addEventListener("mouseleave",()=>m.setHover(null),{signal:g});const j=new Ys(l,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:S=>n('[data-action="filter"]').classList.toggle("gt-btn-active",S),onSortButton:S=>n('[data-action="sort"]').classList.toggle("gt-btn-active",S)});n('[data-action="filter"]').addEventListener("click",S=>j.openFilterPanel(S.currentTarget),{signal:g}),n('[data-action="sort"]').addEventListener("click",S=>j.openSortPanel(S.currentTarget),{signal:g}),n('[type="search"]').addEventListener("input",S=>l.setQuickFilter(S.target.value),{signal:g});const W=n(".gt-settings"),B=n('[data-action="settings"]');B.addEventListener("click",()=>{W.hidden=!W.hidden,B.setAttribute("aria-expanded",String(!W.hidden))},{signal:g}),document.addEventListener("pointerdown",S=>{!W.contains(S.target)&&!B.contains(S.target)&&(W.hidden=!0,B.setAttribute("aria-expanded","false"))},{signal:g});const E=Math.random().toString(36).slice(2);return W.querySelectorAll('[type="radio"]').forEach(S=>{const $=S.name;S.name=$+E,S.addEventListener("change",()=>{$==="theme"?m.setTheme(S.value):m.setMilestonesOnly(S.value==="milestones")},{signal:g})}),n('[data-setting="children"]').addEventListener("change",S=>m.setShowChildren(S.target.checked),{signal:g}),t.addEventListener("keydown",S=>{S.key==="Escape"&&(W.hidden=!0,j.closeAll())},{signal:g}),h(),e.unit&&m.setUnit(e.unit),m.scrollToToday(.5),{grid:l,chart:m,expandAll:()=>k(!0),collapseAll:()=>k(!1),scrollToTask:S=>m.scrollToTask(S),setTasks(S){o=structuredClone(S),a=new Map(o.map($=>[$.id,$])),l.setRowData(o),h()},destroy(){d||(d=!0,p.abort(),j.destroy(),i==null||i.destroy(),m.destroy(),r.destroy(),t.remove())}}}const Oe=s=>Date.parse(`${s}T00:00:00Z`)/864e5,_e=s=>new Date(s*864e5).toISOString().slice(0,10),Sn=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Oe(s))&&_e(Oe(s))===s,_t=s=>!!s.start&&!!s.end;function ki(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&&(!Sn(i.start)||!Sn(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function Zs(s,e=!1){const t=[];return s.filter(_t).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<Oe(i.start));return n<0&&(n=t.length),t[n]=Oe(i.end),{item:i,lane:n}})}function ri(s){return{scheduled:s.filter(_t).length,unscheduled:s.filter(e=>!_t(e)).length,estimate:s.reduce((e,t)=>e+t.estimate,0)}}const Re=s=>s.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),xn=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function ea(s,e){ki(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(Y=>Y.id)),a=!1,l="",r="",c="",d=!1,u=1,p=!1,g=!1,C=!1,h=!0,f=Oe(n)-new Date(`${n}T00:00:00Z`).getUTCDay(),m=90,b=`${n.slice(0,7)}-01`,R=_e(Date.UTC(Number(n.slice(0,4)),Number(n.slice(5,7))+1,0)/864e5),k=!1,y=!1;const M=document.createElement("section");M.className="personnel-schedule",M.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${Re(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
35
- <div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${Re(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
- <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(M);const P=Y=>M.querySelector(Y),D=P(".ps-scroll"),j=P(".ps-rows"),W=P(".ps-popover"),B=P(".ps-detail"),E=new AbortController,S=E.signal;let $;const z=()=>[22,43,64,86,120][u],q=()=>i.filter(Y=>(!l||Y.name.includes(l))&&(!r||Y.status===r)&&(g||!Y.parentId)),ee=()=>{const Y=q();return t.filter(Q=>o.has(Q.id)&&(!a||Y.some(te=>te.personId===Q.id&&_t(te)))).sort((Q,te)=>{if(!c)return 0;const J=ri(Y.filter(Ce=>Ce.personId===Q.id)),ae=ri(Y.filter(Ce=>Ce.personId===te.id));return(c==="estimate"?J.estimate-ae.estimate:J.scheduled-ae.scheduled)*(d?-1:1)})};function se(Y){const Q=P(".ps-toast");Q.textContent=Y,Q.hidden=!1,clearTimeout($),$=setTimeout(()=>Q.hidden=!0,2200)}function V(){if(k)return;const Y=z(),Q=m*Y;P(".ps-table").style.width=`${Q+200}px`;const te=`${b.slice(0,4)}年 第${Number(b.slice(5,7))}-${Number(R.slice(5,7))}月`;P(".ps-date-label").textContent=te,P('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,P(".ps-zoom").value=String(u);const J=P(".ps-weeks");J.replaceChildren();for(let De=0;De<m;De+=7){const qe=document.createElement("span");qe.style.width=`${Math.min(7,m-De)*Y}px`,qe.textContent=`${_e(f+De).slice(5).replace("-","/")}~${_e(f+De+6).slice(5).replace("-","/")}`,J.append(qe)}j.replaceChildren();const ae=q(),Ce=ee();for(const De of Ce){const qe=ae.filter(we=>we.personId===De.id),$e=ri(qe),Pt=Zs(qe,p),ht=Math.max(0,...Pt.map(we=>we.lane)),gi=Math.max(C?154:126,60+(ht+1)*(C?48:36)),xt=document.createElement("div");xt.className="ps-person-row",xt.style.height=`${gi}px`,xt.dataset.person=De.id;const $t=document.createElement("div");$t.className="ps-person",$t.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${Re(De.name)}</strong></div><div>已排期项 <b>${$e.scheduled}</b></div><div>总估分 <b>${$e.estimate.toFixed(2)}</b></div><div>未排期·${$e.unscheduled}<button data-action="unplanned" data-person="${Re(De.id)}">查看</button></div>`;const Gt=$t.querySelector(".ps-avatar");Gt.textContent=De.name.slice(-2),Gt.style.background=De.color||xn[t.indexOf(De)%xn.length];const je=document.createElement("div");je.className="ps-timeline",je.style.width=`${Q}px`,je.style.setProperty("--day",`${Y}px`);for(let we=0;we<m;we++)if([0,6].includes(new Date((f+we)*864e5).getUTCDay())){const gt=document.createElement("i");gt.className="ps-weekend",gt.style.left=`${we*Y}px`,gt.style.width=`${Y}px`,je.append(gt)}const pt=Oe(n)-f;if(pt>=0&&pt<m){const we=document.createElement("i");we.className="ps-today",we.style.left=`${(pt+.5)*Y}px`,je.append(we)}for(const{item:we,lane:gt}of Pt){const ft=Oe(we.start),ot=Oe(we.end);if(ot<f||ft>=f+m)continue;const mt=Math.max(0,ft-f)*Y,Et=Math.min(m,ot-f+1)*Y,Ke=document.createElement("button");Ke.className=`ps-bar ${h?"ps-color":"ps-content"}`,Ke.dataset.item=we.id,Ke.setAttribute("aria-label",`${we.name},${we.start} 至 ${we.end}`),Ke.style.left=`${mt}px`,Ke.style.width=`${Et-mt}px`,Ke.style.top=`${52+gt*(C?48:36)}px`,Ke.style.setProperty("--bar-color",we.color||"#8cafeb"),Ke.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${Re(we.name)}</span><span class="ps-status">${Re(we.status)}</span><span class="ps-node">● ${Re(we.node)}</span><span class="ps-effort">${we.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,je.append(Ke)}if(!Pt.length){const we=document.createElement("span");we.className="ps-no-schedule",we.textContent="暂无排期",je.append(we)}xt.append($t,je),j.append(xt)}Ce.length||(j.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const Pe=ae.filter(De=>Ce.some(qe=>qe.id===De.personId));P(".ps-total").textContent=`ⓘ 总人数 ${Ce.length} 总估分 ${ri(Pe).estimate.toFixed(2)} pd ···`}function U(Y,Q){if(!W.hidden&&W.dataset.kind===Y){W.hidden=!0;return}W.dataset.kind=Y,W.hidden=!1;const te=M.getBoundingClientRect(),J=Q==null?void 0:Q.getBoundingClientRect();if(W.style.left=`${Math.max(12,Math.min(((J==null?void 0:J.left)??te.left)-te.left,M.clientWidth-(Y==="unplanned"?760:420)-16))}px`,W.style.top=`${J?J.bottom-te.top+6:96}px`,W.className=`ps-popover ps-panel-${Y}`,Y==="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(ae=>`<label><input type="checkbox" data-person="${Re(ae.id)}" ${o.has(ae.id)?"checked":""}>${Re(ae.name)}</label>`).join("")}</div>`;else if(Y==="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(Y==="filter")W.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${Re(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${Re(l)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(ae=>ae.status))].map(ae=>`<option>${Re(ae)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,W.querySelector("select").value=r;else if(Y==="settings")W.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${p?"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="${C?"":"selected"}">紧凑</button><button data-action="loose" class="${C?"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(Y==="date")oe();else if(Y==="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(Y==="views"){const ae=ut();W.innerHTML=`<div class="ps-panel-title">视图列表</div>${ae.length?ae.map((Ce,Pe)=>`<button class="ps-view" data-view="${Pe}">▦ ${Re(Ce.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let Z=new Date(`${b}T00:00:00Z`),K=!1;function oe(){let Y=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${b}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${R}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let Q=0;Q<2;Q++){const te=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+Q,1));Y+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${te.getUTCFullYear()}年 ${te.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(ae=>`<span>${ae}</span>`).join("")}`;for(let ae=0;ae<te.getUTCDay();ae++)Y+="<span></span>";const J=new Date(Date.UTC(te.getUTCFullYear(),te.getUTCMonth()+1,0)).getUTCDate();for(let ae=1;ae<=J;ae++){const Ce=_e(Date.UTC(te.getUTCFullYear(),te.getUTCMonth(),ae)/864e5);Y+=`<button data-date="${Ce}" class="${Ce>=b&&Ce<=R?"in-range":""} ${Ce===b||Ce===R?"selected":""}">${ae}</button>`}Y+="</div></div>"}W.innerHTML=Y+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((Q,te)=>`<button data-preset="${te}">${Q}</button>`).join("")}</div>`}function ve(){R<b&&([b,R]=[R,b]),f=Oe(b),f-=new Date(f*864e5).getUTCDay(),m=Math.max(35,Oe(R)-f+8),D.scrollLeft=0,V()}function he(Y,Q){var ae;if(!i.some(Ce=>Ce.id===Y))throw new Error(`Unknown schedule item: ${Y}`);const te=i.map(Ce=>Ce.id===Y?{...Ce,...Q}:Ce);ki(t,te),i=te,V();const J=i.find(Ce=>Ce.id===Y);J&&((ae=e.onItemChange)==null||ae.call(e,structuredClone(J)))}function Ee(Y){var te;const Q=i.find(J=>J.id===Y);(te=e.onItemOpen)==null||te.call(e,structuredClone(Q)),B.hidden=!1,B.dataset.item=Y,B.innerHTML=`<header><strong>${Re(Q.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${Re(Q.status)}</span><h3>● ${Re(Q.node)}</h3><form><label>名称<input name="name" required value="${Re(Q.name)}"></label><label>负责人<select name="personId">${t.map(J=>`<option value="${Re(J.id)}" ${J.id===Q.personId?"selected":""}>${Re(J.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${Q.estimate}" required></label><label>开始日期<input type="date" name="start" value="${Q.start||""}"></label><label>结束日期<input type="date" name="end" value="${Q.end||""}"></label><p class="ps-error" role="alert"></p><button class="ps-primary" type="submit">保存排期</button><button type="button" data-action="unschedule">移至未排期</button></form></div>`}function Ve(Y,Q){U("unplanned",Q),W.hidden=!1;const te=t.find(J=>J.id===Y);W.innerHTML=`<div class="ps-panel-title">未排期工作项 ${Re(te.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(J=>J.personId===Y&&!_t(J)).map(J=>`<tr><td><button data-open="${Re(J.id)}">${Re(J.name)}</button></td><td>● ${Re(J.node)}</td><td><input type="number" min="0" step="0.1" value="${J.estimate||""}" placeholder="待填" data-estimate="${Re(J.id)}" aria-label="${Re(J.name)}估分"></td><td><button class="ps-link" data-open="${Re(J.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const pi=e.viewStorageKey??"rowvia-personnel-views-v1";function ut(){try{const Y=JSON.parse(localStorage.getItem(pi)||"[]");return Array.isArray(Y)?Y:[]}catch{return[]}}M.addEventListener("click",Y=>{const Q=Y.target,te=Q.closest("button");if(!te)return;if(te.dataset.open){W.hidden=!0,Ee(te.dataset.open);return}if(te.dataset.item){y||Ee(te.dataset.item);return}if(te.dataset.date){K?(R=te.dataset.date,K=!1,ve()):(b=te.dataset.date,R=b,K=!0),oe();return}if(te.dataset.preset){const ae=Number(te.dataset.preset),Ce=Oe(n),Pe=new Date(Ce*864e5);b=_e(ae<2?Ce-Pe.getUTCDay():ae<4?Date.UTC(Pe.getUTCFullYear(),Pe.getUTCMonth(),1)/864e5:Ce),R=_e(ae===2||ae===3?Date.UTC(Pe.getUTCFullYear(),Pe.getUTCMonth()+(ae===2?1:2),0)/864e5:Oe(b)+[6,13,29,60,13,59,364][ae]),K=!1,ve(),W.hidden=!0;return}if(te.dataset.view){const ae=ut()[Number(te.dataset.view)];ae&&(o=new Set(ae.selected.filter(Ce=>t.some(Pe=>Pe.id===Ce))),{query:l,status:r,sort:c,descending:d,zoom:u,from:f,days:m,rangeStart:b,rangeEnd:R,expanded:p,children:g,loose:C,colorFirst:h,onlyScheduled:a}=ae,V(),W.hidden=!0,se(`已打开 ${ae.name}`));return}const J=te.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(J||"")){U(J,te);return}if(J==="unplanned"){Ve(te.dataset.person,te);return}if(J==="close-detail"&&(B.hidden=!0),J==="unschedule"&&(he(B.dataset.item,{start:null,end:null}),B.hidden=!0),(J==="plus"||J==="minus")&&(u=Math.max(0,Math.min(4,u+(J==="plus"?1:-1))),V()),(J==="prev"||J==="next"||J==="today")&&(f=J==="today"?Oe(n)-new Date(`${n}T00:00:00Z`).getUTCDay():f+(J==="prev"?-14:14),b=_e(f),R=_e(f+59),D.scrollLeft=0,V()),(J==="asc"||J==="desc"||J==="clear-sort")&&(d=J==="desc",J==="clear-sort"&&(c=""),V(),W.hidden=!0),J==="clear-filter"&&(l="",r="",V(),W.hidden=!0),["compact","loose","content","color"].includes(J||"")&&(J==="compact"||J==="loose"?C=J==="loose":h=J==="color",V(),W.hidden=!0,U("settings",P('[data-action="settings"]'))),(J==="cal-prev"||J==="cal-next")&&(Z=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+(J==="cal-prev"?-1:1),1)),oe()),J==="save-view"){const ae=W.querySelector("[data-view-name]").value.trim();if(!ae)return;const Ce=ut();Ce.push({name:ae,selected:[...o],query:l,status:r,sort:c,descending:d,zoom:u,from:f,days:m,rangeStart:b,rangeEnd:R,expanded:p,children:g,loose:C,colorFirst:h,onlyScheduled:a});try{localStorage.setItem(pi,JSON.stringify(Ce)),W.hidden=!0,se("视图已保存")}catch{se("浏览器存储不可用,视图未保存")}}J==="schedule"&&(W.hidden=!0,B.hidden=!0)},{signal:S}),M.addEventListener("input",Y=>{const Q=Y.target;Q.classList.contains("ps-zoom")&&(u=Number(Q.value),V()),Q.classList.contains("ps-person-search")&&W.querySelectorAll(".ps-person-options label").forEach(te=>{var J;return te.hidden=!((J=te.textContent)!=null&&J.includes(Q.value))}),Q.dataset.control==="query"&&(l=Q.value,V())},{signal:S}),M.addEventListener("change",Y=>{const Q=Y.target;if(Q.dataset.person&&(Q.checked?o.add(Q.dataset.person):o.delete(Q.dataset.person),V()),Q.dataset.estimate){const te=Number(Q.value);Number.isFinite(te)&&te>=0&&he(Q.dataset.estimate,{estimate:te});return}switch(Q.dataset.control){case"only":a=Q.checked;break;case"sort":c=Q.value;break;case"status":r=Q.value;break;case"expanded":p=Q.checked;break;case"children":g=Q.checked;break;case"range-start":Q.value&&(b=Q.value,ve(),oe());return;case"range-end":Q.value&&(R=Q.value,ve(),oe());return}V()},{signal:S}),B.addEventListener("submit",Y=>{Y.preventDefault();const Q=new FormData(Y.target),te=String(Q.get("start")||"")||null,J=String(Q.get("end")||"")||null;if(!!te!=!!J||te&&J&&te>J){B.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}he(B.dataset.item,{name:String(Q.get("name")),personId:String(Q.get("personId")),estimate:Number(Q.get("estimate")),start:te,end:J}),B.hidden=!0,se("排期已更新")},{signal:S}),document.addEventListener("pointerdown",Y=>{M.contains(Y.target)?!W.contains(Y.target)&&!Y.target.closest("[data-action]")&&(W.hidden=!0):W.hidden=!0},{signal:S}),M.addEventListener("keydown",Y=>{Y.key==="Escape"&&(W.hidden=!0,B.hidden=!0)},{signal:S});let xe=null;return j.addEventListener("pointerdown",Y=>{const Q=Y.target,te=Q.closest(".ps-bar");if(!te||Y.button!==0)return;const J=i.find(ae=>ae.id===te.dataset.item);y=!1,xe={id:J.id,x:Y.clientX,start:Oe(J.start),end:Oe(J.end),edge:Q.dataset.edge||"move",bar:te,left:parseFloat(te.style.left),size:parseFloat(te.style.width),delta:0,scroll:D.scrollLeft}},{signal:S}),document.addEventListener("pointermove",Y=>{if(!xe)return;const Q=Math.round((Y.clientX-xe.x+D.scrollLeft-xe.scroll)/z());xe.delta=xe.edge==="start"?Math.min(Q,xe.end-xe.start):xe.edge==="end"?Math.max(Q,xe.start-xe.end):Q,Math.abs(Y.clientX-xe.x)>4&&(y=!0),y&&(xe.bar.style.opacity=".8",xe.edge==="move"?xe.bar.style.transform=`translateX(${xe.delta*z()}px)`:(xe.bar.style.left=`${xe.left+(xe.edge==="start"?xe.delta*z():0)}px`,xe.bar.style.width=`${xe.size+(xe.edge==="start"?-1:1)*xe.delta*z()}px`))},{signal:S}),document.addEventListener("pointerup",()=>{if(!xe)return;const Y=xe;xe=null,y&&(he(Y.id,{start:_e(Y.start+(Y.edge==="end"?0:Y.delta)),end:_e(Y.end+(Y.edge==="start"?0:Y.delta))}),se("排期已更新"))},{signal:S}),V(),{setData(Y,Q){ki(Y,Q),t=structuredClone(Y),i=structuredClone(Q),o=new Set(t.map(te=>te.id)),W.hidden=!0,B.hidden=!0,V()},getItems:()=>structuredClone(i),updateItem:he,setPeople(Y){o=new Set(Y.filter(Q=>t.some(te=>te.id===Q))),V()},destroy(){k=!0,E.abort(),clearTimeout($),M.remove()}}}function qt(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 l=new Set,r=[];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,l.forEach(u=>{window.clearTimeout(u),window.clearInterval(u)}),r.forEach(u=>u()),o==null||o.grid.destroy(),o=null,n.remove())}},timeout:(u,p)=>{const g=window.setTimeout(()=>{l.delete(g),a||u()},p);return l.add(g),g},cleanup(u){r.push(u)},interval(u,p){const g=window.setInterval(()=>{a||u()},p);return l.add(g),g},createGrid(u,p){return o=Vi(u,{...p,...i.gridOptions}),o}}}function Mi(s=42){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}const ta=["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"],ia=["Bridges","Stone","Collins","Reyes","Fisher","Lambert","Walsh","Harper","Keller","Novak","Silva","Weaver","Grant","Holloway","Mercer","Draper","Whitfield","Calloway","Prescott","Vance","Ellington","Monroe","Sinclair","Barlow"],na=[{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:"🇮🇪"}],ci={executiveManagement:"Executive Management",legal:"Legal",design:"Design",engineering:"Engineering",product:"Product",customerSupport:"Customer Support"},oa=Object.keys(ci),Ze=Mi(7);function Kt(s){return s[Math.floor(Ze()*s.length)]}function sa(){return`${Kt(ta)} ${Kt(ia)}`}function aa(){const s=2015+Math.floor(Ze()*10),e=1+Math.floor(Ze()*12),t=1+Math.floor(Ze()*28);return`${s}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function At(s,e,t){const i=s[s.length-1],n=Kt(na);return{orgHierarchy:s,contact:i.replace(/\s+/g,"."),jobTitle:e,employmentType:Ze()<.7?"Permanent":"Contract",department:t,employeeId:0,location:n.name,joinDate:aa(),basicMonthlySalary:2500+Math.floor(Ze()*60)*250,currency:Kt(["GBP","EUR","USD"]),paymentMethod:Kt(["Bank Transfer","Cash","Check"]),paymentStatus:Ze()<.65?"paid":"pending",image:String(1+Math.floor(Ze()*36)),flag:n.flag}}function la(){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(At([t],"CEO","executiveManagement")),o(At([t,i[0]],"COO","executiveManagement")),o(At([t,i[1]],"CTO","executiveManagement")),o(At([t,i[2]],"Exec. Vice President","executiveManagement"));for(const a of oa){const l=n[a],r=a==="executiveManagement"?i[1]:i[Math.floor(Ze()*3)];o(At([t,r,l],"Head of Department",a));const c=6+Math.floor(Ze()*4);for(let d=0;d<c;d++){const u=sa();o(At([t,r,l,u],"Employee",a))}}return s}const Ti=Mi(1337),ra=[["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"]],En=["#2196f3","#4caf50","#ff9800","#9c27b0","#f44336","#00bcd4","#795548","#607d8b","#e91e63","#3f51b5","#009688","#ffc107"];function ca(s){let e=0;for(let o=0;o<s.length;o++)e=e*31+s.charCodeAt(o)>>>0;const t=En[e%En.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 da(s){const e=[];let t=s*(.9+Ti()*.2);for(let i=0;i<24;i++)t=t*(1+(Ti()-.5)*.04),e.push(Number(t.toFixed(2)));return e}function ua(){return ra.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(Ti()*500),purchaseDate:"2023-04-11",purchasePrice:i,price:n,timeline:da(n)}})}function ha(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 pa(s,e={}){var h,f;const t=qt(s,"finance",`<div id="app">
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 M,P,D;const b=document.createElement("div");b.className="ticker-cell";const R=document.createElement("img");R.src=ca(String(((M=m.data)==null?void 0:M.ticker)??"")),R.alt=`${((P=m.data)==null?void 0:P.name)??""} logo`,b.appendChild(R);const k=document.createElement("b");k.className="custom-ticker",k.textContent=String(m.value??""),b.appendChild(k);const y=document.createElement("span");return y.className="ticker-name",y.textContent=` ${((D=m.data)==null?void 0:D.name)??""}`,b.appendChild(y),b}const l=[{field:"ticker",width:340,minWidth:340,cellRenderer:a,tooltipValueGetter:m=>{var b,R;return`${((b=m.data)==null?void 0:b.name)??""} (${((R=m.data)==null?void 0:R.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)}],r=ua(),c={columnDefs:l,rowData:r,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 p;function g(){p===void 0&&(p=t.interval(()=>{ha(r);const m=[];for(const b of r){const R=d.getRowNode(b.ticker);R&&(R.data=b,m.push(R))}d.refreshCells({rowNodes:m,force:!0})},u))}function C(){p!==void 0&&(window.clearInterval(p),p=void 0)}if(e.liveUpdates!==!1&&!((h=e.gridOptions)!=null&&h.rowData)&&g(),e.liveUpdates!==!1&&!((f=e.gridOptions)!=null&&f.rowData)&&typeof IntersectionObserver<"u"){const m=new IntersectionObserver(b=>{for(const R of b)R.isIntersecting?g():C()},{threshold:0});t.cleanup(()=>m.disconnect()),m.observe(i.querySelector("#financeGrid"))}return t.cleanup(C),t.handle}function ga(s,e={}){const t=qt(s,"hr",`<div class="wrapper">
40
- <div class="container">
41
- <div id="hrGrid" class="grid ag-theme-quartz"></div>
42
- </div>
43
- </div>`,e),{host:i,createGrid:n}=t,o=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function a(f){let m=0;for(let b=0;b<f.length;b++)m=m*31+f.charCodeAt(b)>>>0;return o[m%o.length]}function l(f){return f.split(/\s+/).map(m=>m[0]).join("").slice(0,2).toUpperCase()}function r(f){var D;const m=document.createElement("div");m.className="employeeCell";const b=f.data||{},R=f.node.group?f.value:((D=b.orgHierarchy)==null?void 0:D[b.orgHierarchy.length-1])??"",k=document.createElement("div");k.className="avatar",k.style.backgroundColor=a(String(R)),k.textContent=l(String(R));const y=document.createElement("div");y.className="employeeData";const M=document.createElement("span");M.className="name",M.textContent=String(R);const P=document.createElement("span");return P.className="description",P.textContent=b.jobTitle??"",y.appendChild(M),y.appendChild(P),m.appendChild(k),m.appendChild(y),m}function c(f){const m=String(f.valueFormatted??f.value??""),b=Object.keys(ci).find(M=>ci[M]===m)??"",R=document.createElement("div");R.className=`tag ${b}Tag`;const k=document.createElement("span");k.className=`circle ${b}Circle`,R.appendChild(k);const y=document.createElement("span");return y.textContent=m,R.appendChild(y),R}function d(f){var k;const m=document.createElement("div");m.className="flagCell";const b=document.createElement("span");b.textContent=String(f.value??""),m.appendChild(b);const R=document.createElement("span");return R.className="flagImage",R.textContent=((k=f.data)==null?void 0:k.flag)??"",m.appendChild(R),m}function u(f){const m=String(f.value??""),b=document.createElement("div");if(b.className=`tag ${m}Tag`,m==="paid"){const k=document.createElement("span");k.className="tick",k.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>',b.appendChild(k)}const R=document.createElement("span");return R.textContent=m,b.appendChild(R),b}function p(f){var M;const m=document.createElement("div");m.className="contact-cell";const b=document.createElement("div");b.className="iconContainer",b.title="LinkedIn",b.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>',b.addEventListener("click",()=>window.open("https://www.linkedin.com/company/ag-grid/","_blank")),m.appendChild(b);const R=((M=f.data)==null?void 0:M.orgHierarchy)??[],k=(R[R.length-1]??"").toLowerCase().replace(/\s+/g,"."),y=document.createElement("div");return y.className="iconContainer",y.title="Email",y.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>',y.addEventListener("click",()=>{window.location.href=`mailto:${k}@company.com`}),m.appendChild(y),m}const h={columnDefs:[{field:"employeeId",headerName:"ID",width:120},{field:"department",width:250,minWidth:250,flex:1,valueFormatter:f=>{const m=String(f.value??"");return ci[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:f=>f.value==null?"":`$${Math.round(f.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:p,width:120}],rowData:la(),rowHeight:62,groupDefaultExpanded:-1,treeData:!0,getDataPath:f=>f.orgHierarchy,autoGroupColumnDef:{headerName:"Employee",width:330,pinned:"left",sort:"asc",cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:r}},theme:"ag-theme-quartz"};return n(i.querySelector("#hrGrid"),h),t.handle}const Rn=[["#667eea","#764ba2"],["#f093fb","#f5576c"],["#4facfe","#00f2fe"],["#43e97b","#38f9d7"],["#fa709a","#fee140"],["#30cfd0","#330867"],["#a8edea","#fed6e3"],["#ff9a9e","#fecfef"],["#f6d365","#fda085"],["#5ee7df","#b490ca"]];function fa(s,e){const[t,i]=Rn[e%Rn.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 kn=["Vinyl, LP, Album",'Vinyl, 12", 45 RPM',"Vinyl, LP, Reissue","CD, Album"],Mn=["Blue Note","Columbia","Motown","Def Jam","Sub Pop","4AD","Matador","Domino"],Tn=["US","UK","Europe","Japan"];function ma(s,e,t){return Array.from({length:s},(i,n)=>({title:e,available:Math.floor(Math.random()*40),format:kn[n%kn.length],label:Mn[n%Mn.length],cat:`NB ${1e3+n*7}`,country:Tn[n%Tn.length],year:t}))}const va=[{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 Ca(){return va.map((s,e)=>({...s,image:fa(s.product,e),variantDetails:ma(s.variants,s.product,s.year)}))}function wa(s,e={}){const t=qt(s,"inventory",`<div class="wrapper">
44
- <div class="container">
45
- <div class="exampleHeader">
46
- <div class="tabs" id="tabs">
47
- <button class="tab active" data-key="all">All</button>
48
- <button class="tab" data-key="active">Active</button>
49
- <button class="tab" data-key="paused">On Hold</button>
50
- <button class="tab" data-key="outOfStock">Out of Stock</button>
51
- </div>
52
- <div class="inputWrapper">
53
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="#98a2b3" stroke-width="2">
54
- <circle cx="11" cy="11" r="7" />
55
- <path d="M20 20l-3.5-3.5" />
56
- </svg>
57
- <input id="filter-text-box" class="input" placeholder="Search product..." />
58
- </div>
59
- </div>
60
- <div id="inventoryGrid" class="grid ag-theme-quartz"></div>
34
+ </div>`,s.append(t);const i=xe(t,"gantt",e),n=e.onTaskOpen?null:Gi(t),o=F=>t.querySelector(F);o(".gantt-title-name").textContent=e.title??"甘特图";let a=structuredClone(e.tasks),l=new Map(a.map(F=>[F.id,F])),r=null,d,c=!0,p=!1;const f=o(".gantt-left");f.style.width=`${e.tableWidth??280}px`;const u=new AbortController,h=u.signal,g=o(".gantt-status");function v(){if(!d||p)return;r!==a&&(C.setTasks(a),r=a);const F=Array.from({length:d.getDisplayedRowCount()},(L,D)=>d.getDisplayedRowAtIndex(D)).filter(Boolean);C.setRows(F.map(L=>({id:L.id,group:!!L.group,expanded:!!L.expanded})));const G=a.filter(L=>L.path.length===1),I=G.filter(L=>L.status==="done").length;g.textContent=`总工作项数 ${G.length} 完成进度 ${G.length?Math.round(I/G.length*100):0}%`}function m(F){var L;a=a.map(D=>D.id===F.id?{...F}:D),l=new Map(a.map(D=>[D.id,D]));const G=[F];let I=F.path.slice(0,-1);for(;I.length;){const D=a.find(Z=>Z.path.join("/")===I.join("/"));if(!D)break;const z=a.filter(Z=>Z.path.length===I.length+1&&Z.path.slice(0,-1).join("/")===I.join("/")),U=z.flatMap(Z=>Z.start?[Z.start]:[]).sort(),K=z.flatMap(Z=>Z.end?[Z.end]:[]).sort();D.start=U[0]??null,D.end=K[K.length-1]??null,G.push(D),I=I.slice(0,-1)}d.applyTransaction({update:G}),v(),(L=e.onTaskChange)==null||L.call(e,structuredClone(F))}const C=new Ui(o(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:F=>{var I;C.setSelected(F);const G=F?d==null?void 0:d.getRowNode(F):null;G&&((I=d.selectNode)==null||I.call(d,G,!0))},onHover:F=>{var G;t.querySelectorAll(".ag-row-hover").forEach(I=>I.classList.remove("ag-row-hover")),F&&((G=Array.from(t.querySelectorAll(".ag-row")).find(I=>I.dataset.rowid===F))==null||G.classList.add("ag-row-hover"))},onTaskChange:m,onAssign:(F,G)=>{const I=l.get(F);I&&m({...I,owner:G})}});function S(F){const G=F.data,I=document.createElement("span");if(I.className="gt-task-name",G.path.length>1?I.classList.add("gt-child-name"):F.node.group||I.classList.add("gt-root-leaf"),G.path.length>1){const D=document.createElement("span");D.className=`gt-node-dot gt-node-${G.status}`,I.append(D)}const L=document.createElement("button");return L.className="gt-title-link",L.textContent=G.name,L.title=G.name,L.addEventListener("click",()=>{C.scrollToTask(G.id),e.onTaskOpen?e.onTaskOpen(structuredClone(G)):n==null||n.open({title:G.name,fields:[{label:"排期",value:`${G.start??"未设置"} — ${G.end??"未设置"}`}]})}),I.append(L),I}const b=document.createElement("button");b.className="gt-tree-toggle",b.textContent="▾",b.title="收起全部子层级",b.setAttribute("aria-label",b.title);function y(F){c=F,F?d.expandAll():d.collapseAll(),b.textContent=F?"▾":"▸",b.title=F?"收起全部子层级":"展开全部子层级",b.setAttribute("aria-label",b.title),v()}b.addEventListener("click",()=>y(!c));const R=["name","status","start","end","owner","progress"].map(F=>({field:F,hide:!0,filter:!0})),M=new nt(o(".grid"),{columnDefs:R,rowData:a,treeData:!0,getDataPath:F=>F.path,getRowId:F=>F.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:_o,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const F=document.createElement("div");return F.className="gt-title-header",F.append(b,document.createTextNode("标题")),F},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:S}},onGridReady:F=>{d=F.api,v()},onModelUpdated:F=>{d=F.api,v()},onRowGroupOpened:v,onRowClicked:F=>{var G;return C.setSelected(((G=F.node)==null?void 0:G.id)??null)}});d=M.getApi();const T=o(".ag-body-viewport");let W=!1;const E=(F,G)=>{W||(W=!0,G.scrollTop=F.scrollTop,W=!1)};T.addEventListener("scroll",()=>E(T,C.scrollElement),{signal:h}),C.scrollElement.addEventListener("scroll",()=>E(C.scrollElement,T),{signal:h}),T.addEventListener("mousemove",F=>{const G=F.target.closest(".ag-row");C.setHover((G==null?void 0:G.dataset.rowid)??null)},{signal:h}),T.addEventListener("mouseleave",()=>C.setHover(null),{signal:h});const x=new Po(d,t,{filter:[{colId:"name",label:"标题",kind:"text"},{colId:"status",label:"状态",kind:"text",options:[{value:"not-started",label:"未开始"},{value:"in-progress",label:"进行中"},{value:"done",label:"已完成"}]},{colId:"start",label:"开始日期",kind:"date"}],sort:[{colId:"name",label:"标题"},{colId:"start",label:"开始日期"},{colId:"end",label:"结束日期"}]},{onFilterButton:F=>o('[data-action="filter"]').classList.toggle("gt-btn-active",F),onSortButton:F=>o('[data-action="sort"]').classList.toggle("gt-btn-active",F)});o('[data-action="filter"]').addEventListener("click",F=>x.openFilterPanel(F.currentTarget),{signal:h}),o('[data-action="sort"]').addEventListener("click",F=>x.openSortPanel(F.currentTarget),{signal:h}),o('[type="search"]').addEventListener("input",F=>d.setQuickFilter(F.target.value),{signal:h});const k=o(".gt-settings"),$=o('[data-action="settings"]');$.addEventListener("click",()=>{k.hidden=!k.hidden,$.setAttribute("aria-expanded",String(!k.hidden))},{signal:h}),document.addEventListener("pointerdown",F=>{!k.contains(F.target)&&!$.contains(F.target)&&(k.hidden=!0,$.setAttribute("aria-expanded","false"))},{signal:h});const q=Math.random().toString(36).slice(2);return k.querySelectorAll('[type="radio"]').forEach(F=>{const G=F.name;F.name=G+q,F.addEventListener("change",()=>{G==="theme"?C.setTheme(F.value):C.setMilestonesOnly(F.value==="milestones")},{signal:h})}),o('[data-setting="children"]').addEventListener("change",F=>C.setShowChildren(F.target.checked),{signal:h}),t.addEventListener("keydown",F=>{F.key==="Escape"&&(k.hidden=!0,x.closeAll())},{signal:h}),v(),e.unit&&C.setUnit(e.unit),C.scrollToToday(.5),{onInteraction:i.onInteraction,grid:d,chart:C,expandAll:()=>y(!0),collapseAll:()=>y(!1),scrollToTask:F=>C.scrollToTask(F),setTasks(F){a=structuredClone(F),l=new Map(a.map(G=>[G.id,G])),d.setRowData(a),v()},destroy(){p||(p=!0,u.abort(),x.destroy(),n==null||n.destroy(),C.destroy(),M.destroy(),i.destroy(),t.remove())}}}const at={pending:{key:"pending",label:"未开始",className:"pending"},inProgress:{key:"inProgress",label:"进行中",className:"in-progress"},done:{key:"done",label:"已完成",className:"done"},failed:{key:"failed",label:"未通过",className:"failed"}},Yi={auto:"自动完成",and:"单人确认(并签)",or:"多人确认(会签)"};function Zt(s){const e=[{id:"owner",label:"已填写节点负责人",met:!!s.owner,fixLabel:"去填写",detail:"对应配置:节点字段必填 › 完成负责人"},{id:"schedule",label:"已填写排期与估分",met:!!(s.schedule&&s.estimate),fixLabel:"去填写",detail:s.milestone?"里程碑节点只需截止时间":"对应配置:节点字段必填 › 完成节点排期与估分"}];for(const t of s.form??[])t.required&&e.push({id:`form:${t.id}`,label:`节点表单「${t.label}」已填写`,met:!!(t.value&&String(t.value).trim()),fixLabel:"去填写",detail:"对应配置:完成表单"});for(const t of s.gates??[])e.push(t);return e}const Xi=s=>s.every(e=>e.met);function Zi(s){const e=s.nodes.length,t=s.nodes.filter(a=>a.status==="done").length,i=s.nodes.filter(a=>a.status==="failed").length,n=s.nodes.filter(a=>a.status==="inProgress").length,o=Math.max(1,s.nodes.findIndex(a=>a.status==="inProgress")+1);return{total:e,done:t,current:n,failed:i,index:o}}function qo(s,e){const t=s.filter(n=>n.groupId===e.id);return{done:t.filter(n=>n.status==="done").length,total:t.length}}function Qi(s){var t;const e=new Map;for(const i of s.groups)e.set(i.id,[]);for(const i of s.nodes){const n=i.groupId??((t=s.groups[0])==null?void 0:t.id);e.has(n)||e.set(n,[]),e.get(n).push(i)}return s.groups.map(i=>({group:i,nodes:e.get(i.id)??[]})).filter(i=>i.nodes.length>0)}function Qt(s,e){const t=e.trim().toLowerCase();return t?new Set(s.nodes.filter(i=>i.name.toLowerCase().includes(t)).map(i=>i.id)):new Set(s.nodes.map(i=>i.id))}const Uo=.4,jo=1.8,Ji=.2;function en(s,e){const t=document.createElement("div"),i=new Ge;t.className="rowvia-nf-canvas",t.innerHTML=`
35
+ <div class="rowvia-nf-canvas-toolbar">
36
+ <span class="rowvia-nf-legend" data-legend></span>
37
+ <span class="rowvia-nf-space"></span>
38
+ <button type="button" class="rowvia-nf-ghost" data-action="fit">适应画布</button>
39
+ <button type="button" class="rowvia-nf-round" data-action="zoom-out" aria-label="缩小">−</button>
40
+ <span class="rowvia-nf-zoom" data-zoom>100%</span>
41
+ <button type="button" class="rowvia-nf-round" data-action="zoom-in" aria-label="放大">+</button>
42
+ </div>
43
+ <div class="rowvia-nf-canvas-viewport" data-viewport>
44
+ <div class="rowvia-nf-canvas-sizer" data-sizer>
45
+ <div class="rowvia-nf-canvas-surface" data-surface></div>
61
46
  </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 l(m){var P,D,j;const b=document.createElement("div");b.className="productCell";const R=document.createElement("img");R.src=((P=m.data)==null?void 0:P.image)??"",R.alt=((D=m.data)==null?void 0:D.product)??"",b.appendChild(R);const k=document.createElement("div"),y=document.createElement("div");y.textContent=String(m.value??"");const M=document.createElement("div");return M.className="stockCell",M.textContent=((j=m.data)==null?void 0:j.category)??"",k.appendChild(y),k.appendChild(M),b.appendChild(k),b}function r(m){const b=String(m.value??""),R=document.createElement("div");R.className=`tag ${b}Tag`;const k=document.createElement("span");k.className=`circle ${b}Circle`,R.appendChild(k);const y=document.createElement("span");return y.textContent=o[b]??b,R.appendChild(y),R}function c(m){var M,P;const b=document.createElement("div");b.className="stock";const R=document.createElement("span");R.textContent=String(((M=m.data)==null?void 0:M.available)??"");const k=document.createElement("span");k.className="stockText",k.textContent="Stock /";const y=document.createElement("span");return y.className="variantsText",y.textContent=`${((P=m.data)==null?void 0:P.variants)??0} Variants`,b.appendChild(R),b.appendChild(k),b.appendChild(y),b}function d(m){var y;const b=document.createElement("div");b.className="price";const R=document.createElement("span");R.className="priceAmount",R.textContent=`£${Number(m.value??0).toFixed(2)}`;const k=document.createElement("span");return k.className="increase",k.textContent=`${((y=m.data)==null?void 0:y.priceIncrease)??0}% increase`,b.appendChild(R),b.appendChild(k),b}function u(m){const b=document.createElement("div");b.className="buttonCell";const R=document.createElement("button");R.className="removeButton",R.title="Remove",R.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>',R.addEventListener("click",()=>{m.api.applyTransaction({remove:[m.node.data]})}),b.appendChild(R);const k=document.createElement("button");return k.className="buttonStopSelling",k.textContent="Hold Selling",k.addEventListener("click",()=>{const y={...m.node.data};y.status!=="paused"?y.status="paused":y.available<=0?y.status="outOfStock":y.status="active",m.api.applyTransaction({update:[y]})}),b.appendChild(k),b}const p=[{field:"product",headerName:"Album Name",minWidth:300,cellRenderer:"agGroupCellRenderer",cellRendererParams:{innerRenderer:l},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:r,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:C}=n(i.querySelector("#inventoryGrid"),{columnDefs:p,rowData:Ca(),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 R=m.target.closest(".tab");if(!R)return;for(const y of h.querySelectorAll(".tab"))y.classList.remove("active");R.classList.add("active");const k=R.dataset.key;C.setColumnFilterModel("status",k==="all"?null:{filterType:"set",values:[k]}),C.onFilterChanged()});const f=i.querySelector("#filter-text-box");return f.addEventListener("input",()=>{C.setQuickFilter(f.value)}),t.handle}const Ni=["Ireland","Spain","United Kingdom","France","Germany","Italy","Netherlands","Portugal","Australia","Canada","Japan","Sweden"],Ii=["English","Spanish","French","German","Italian","Portuguese","Dutch","Japanese","Swedish","Mandarin"],Li=["Chess","Go","Bridge","Poker","Backgammon","Checkers","Mahjong","Sudoku","Scrabble","Risk","Catan","Dungeons & Dragons"],Ai=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],Nn=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia","Kai","Lena","Milo","Nora","Omar","Petra","Quinn","Rosa","Sam","Tessa"],In=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes","Ibarra","Jensen","Klein","Larsen","Moreau","Novak","Ortiz","Pavel","Quintero","Rossi","Silva","Turner"];function Ln(s=12345){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}let nt=Ln();function ba(){nt=Ln(98765)}function ya(s,e){const t={name:`${Nn[s%Nn.length]} ${In[s%In.length]}`,language:Ii[Math.floor(nt()*Ii.length)],country:Ni[Math.floor(nt()*Ni.length)],game:{name:Li[Math.floor(nt()*Li.length)],bought:nt()<.5},bankBalance:Math.round(nt()*1e5)-3e3,rating:Math.round(nt()*5)};let i=0;for(const n of Ai){const o=Math.round(nt()*1e5)-20;t[n]=o,i+=o}t.totalWinnings=i;for(let n=1;n<=e;n++)t[`col${n}`]=Math.round(nt()*1e5)-500;return t}function Sa(s,e){const t=[];for(let i=0;i<s;i++)t.push(ya(i,e));return t}const xa=[{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}],di=["currency","percent","rating","text","number"];function Ea(s){const e=[];let t=0;for(const i of xa)for(let n=0;n<i.count&&t<s;n++,t++){const o=di[t%di.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=di[(t+3)%di.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 Ra(s,e={}){const t=qt(s,"performance",`<div class="exampleWrapper">
63
- <div class="toolbar">
64
- <div class="controls">
65
- <div class="group">
66
- <label class="label" for="data-size">Data Size</label>
67
- <select class="select" id="data-size">
68
- <option value="100x24" selected>100 Rows, 24 Cols</option>
69
- <option value="1000x24">1,000 Rows, 24 Cols</option>
70
- <option value="10000x100">10,000 Rows, 100 Cols</option>
71
- <option value="50000x100">50,000 Rows, 100 Cols</option>
72
- <option value="100000x100">100,000 Rows, 100 Cols</option>
73
- </select>
74
- </div>
75
- <div class="group">
76
- <label class="label" for="theme-select">Theme</label>
77
- <select class="select" id="theme-select">
78
- <option value="ag-theme-quartz" selected>Quartz</option>
79
- <option value="ag-theme-balham">Balham</option>
80
- <option value="ag-theme-alpine">Alpine</option>
81
- </select>
82
- </div>
83
- <div class="group">
84
- <label class="label" for="global-filter">Filter</label>
85
- <input class="input" id="global-filter" placeholder="Filter any column..." />
86
- </div>
47
+ </div>`,s.append(t);const n=xe(t,"flow-canvas",e),o=t.querySelector("[data-viewport]"),a=t.querySelector("[data-sizer]"),l=t.querySelector("[data-surface]"),r=t.querySelector("[data-zoom]"),d=t.querySelector("[data-legend]");let c=e.flow,p=e.selectedNodeId,f=e.query??"",u=1;const h=(E,x,k)=>{if(E.hiddenReason)return`<span class="rowvia-nf-node is-hidden" title="${H(E.hiddenReason)}">
48
+ <span class="rowvia-nf-node-name">${H(E.name)}</span>
49
+ <span class="rowvia-nf-node-note">未显示 · ${H(E.hiddenReason)}</span>
50
+ </span>`;const $=at[E.status],q=k==="right"&&E.info?`<span class="rowvia-nf-node-info">${H(E.info)}</span>`:"",F=k!=="none"&&(E.progress!==void 0||E.delayed)?[`
51
+ <span class="rowvia-nf-node-sub">
52
+ ${E.progress!==void 0?`<span class="rowvia-nf-progress"><i style="width:${E.progress}%"></i></span>${E.progress}%`:""}
53
+ ${E.delayed?'<em class="rowvia-nf-delay">延期</em>':""}
54
+ </span>`].join(""):"";return`<button type="button"
55
+ class="rowvia-nf-node status-${$.className} ${p===E.id?"is-selected":""} ${x?"is-dimmed":""} ${E.milestone?"is-milestone":""}"
56
+ data-node-id="${H(E.id)}"
57
+ aria-pressed="${p===E.id}"
58
+ title="${H(E.name)} · ${H($.label)}${E.milestone?" · 里程碑":""}">
59
+ <span class="rowvia-nf-node-dot" aria-hidden="true"></span>
60
+ <span class="rowvia-nf-node-name">${H(E.name)}</span>
61
+ ${E.milestone?'<span class="rowvia-nf-node-flag" title="里程碑:仅可填写截止时间">◆</span>':""}
62
+ ${q}
63
+ ${F}
64
+ </button>`},g=()=>{var k;const E=Qt(c,f),x=((k=c.infoField)==null?void 0:k.position)??"none";d.textContent=c.infoField?`显示:${c.infoField.label} · 位置:${x==="right"?"右侧":x==="below"?"下方":"不显示"}`:"未配置流程图展示信息",l.innerHTML=Qi(c).map(({group:$,nodes:q})=>{const F=qo(c.nodes,$),G=$.layout==="parallel",I=q.map((z,U)=>{const K=h(z,!E.has(z.id),x);return G?K:`${U?'<i class="rowvia-nf-edge" aria-hidden="true"></i>':""}${K}`}).join(""),L=c.groups[c.groups.indexOf($)+1],D=G?`<div class="rowvia-nf-fan"><span>并行 ${q.length} 路</span><span>全部完成 → ${H((L==null?void 0:L.name)??"结束")}</span></div>`:"";return`<section class="rowvia-nf-group" data-group="${H($.id)}">
65
+ <header class="rowvia-nf-group-head">
66
+ <strong>${H($.name)}</strong>
67
+ <em>${F.done}/${F.total}</em>
68
+ </header>
69
+ <div class="rowvia-nf-lane ${G?"is-parallel":"is-sequence"}">${I}</div>
70
+ ${D}
71
+ </section>`}).join(""),v()},v=()=>{l.style.transform=`scale(${u})`,r.textContent=`${Math.round(u*100)}%`,a.style.width=`${l.scrollWidth*u}px`,a.style.height=`${l.scrollHeight*u}px`},m=E=>{var x;u=Math.min(jo,Math.max(Uo,Math.round(E*100)/100)),v(),(x=e.onZoomChange)==null||x.call(e,u)},C=()=>{const E=l.scrollWidth||1,x=o.clientWidth-8;m(x/E),o.scrollTo({left:0,top:0})},S=E=>{var k;const x=E.target.closest("[data-node-id],[data-action]");if(!(!x||!t.contains(x))){if(x.dataset.nodeId){(k=e.onSelectNode)==null||k.call(e,x.dataset.nodeId);return}x.dataset.action==="fit"&&C(),x.dataset.action==="zoom-in"&&m(u+Ji),x.dataset.action==="zoom-out"&&m(u-Ji)}};t.addEventListener("click",S);const b=E=>{!E.ctrlKey&&!E.metaKey||(E.preventDefault(),m(u+(E.deltaY<0?.1:-.1)))};o.addEventListener("wheel",b,{passive:!1});let y=null;const R=E=>{E.target.closest("button")||(y={x:E.clientX,y:E.clientY,left:o.scrollLeft,top:o.scrollTop},o.setPointerCapture(E.pointerId),o.classList.add("is-panning"))},M=E=>{y&&(o.scrollLeft=y.left-(E.clientX-y.x),o.scrollTop=y.top-(E.clientY-y.y))},T=()=>{y=null,o.classList.remove("is-panning")};o.addEventListener("pointerdown",R),o.addEventListener("pointermove",M),o.addEventListener("pointerup",T),o.addEventListener("pointercancel",T);const W=typeof ResizeObserver<"u"?new ResizeObserver(v):null;return W==null||W.observe(o),g(),{onInteraction:n.onInteraction,update(E){const x=E.flow!==void 0||E.hiddenHints!==void 0;if(E.flow&&(c=E.flow),E.selectedNodeId!==void 0&&(p=E.selectedNodeId),E.query!==void 0&&(f=E.query),E.hiddenHints&&(e.hiddenHints=E.hiddenHints),E.onZoomChange!==void 0&&(e.onZoomChange=E.onZoomChange),E.onSelectNode!==void 0&&(e.onSelectNode=E.onSelectNode),x)g();else{const k=Qt(c,f);for(const $ of l.querySelectorAll("[data-node-id]")){const q=$.dataset.nodeId===p;$.classList.toggle("is-selected",q),$.classList.toggle("is-dimmed",!k.has($.dataset.nodeId)),$.setAttribute("aria-pressed",String(q))}}},focusNode(E){const x=Array.from(l.querySelectorAll("[data-node-id]")).find(k=>k.dataset.nodeId===E);x==null||x.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}),x==null||x.classList.add("is-pulsing"),i.timeout(()=>x==null?void 0:x.classList.remove("is-pulsing"),900)},fit:C,getZoom:()=>u,destroy(){W==null||W.disconnect(),t.removeEventListener("click",S),o.removeEventListener("wheel",b),n.destroy(),i.destroy(),t.remove()}}}function Ko(s){const e=[{id:"schedule",label:"总排期",value:s.schedule,source:"系统字段 · 排期",permission:"节点负责人、管理员"},{id:"estimate",label:"估分",value:s.estimate,source:"系统字段 · 估分",permission:"节点负责人、管理员"},{id:"worklog",label:"实际工时",value:s.worklog??"—",source:"系统字段 · 实际工时"}],t=s.progress!==void 0?[{id:"progress",label:"进度",value:s.progress+"%",percent:s.progress,writeMode:s.progressMode,group:"progress",source:"节点进度"}]:[],i=[{id:"conclusion",label:"整体完成结论",value:s.conclusion,source:"节点完成结论与意见",permission:"独立填写或按负责人结论汇总"},{id:"opinion",label:"整体完成意见",value:s.opinion,source:"节点完成结论与意见"}],n=(s.fields??[]).filter(a=>a.group!=="schedule");return[{key:"schedule",title:"排期与工作量",fields:e},{key:"progress",title:"进度",fields:t},{key:"conclusion",title:"结论与意见",fields:i},{key:"custom",title:"自定义字段",fields:n}].filter(a=>a.fields.length>0)}function Yo(s,e,t){var a;const i=!t&&!e.readonly,n=[];e.group==="progress"?(n.push('<span class="rowvia-nf-progress is-large"><i style="width:'+(e.percent??0)+'%"></i></span>',"<b>"+H(e.value)+"</b>"),e.writeMode&&n.push('<em class="rowvia-nf-mode">'+H(e.writeMode)+"</em>")):i&&e.id==="conclusion"&&((a=s.conclusionOptions)!=null&&a.length)?n.push('<select data-field="'+H(e.id)+'" aria-label="'+H(e.label)+'"><option value="">请选择</option>'+s.conclusionOptions.map(l=>"<option"+(l===e.value?" selected":"")+">"+H(l)+"</option>").join("")+"</select>"):i?n.push('<input data-field="'+H(e.id)+'" value="'+H(e.value??"")+'" placeholder="待填" aria-label="'+H(e.label)+'">'):n.push('<span class="rowvia-nf-value'+(e.value?"":" is-empty")+'">'+H(e.value||"待填")+"</span>");const o=[e.source,e.permission?"可编辑:"+e.permission:""].filter(Boolean).join(" · ");return'<div class="rowvia-nf-field"><label>'+H(e.label)+'</label><div class="rowvia-nf-field-control">'+n.join("")+'</div><button type="button" class="rowvia-nf-info" data-info="'+H(o)+'" aria-label="字段来源">ⓘ</button></div>'}function Xo(s){const e=s.filter(i=>i.met).length,t=s.map(i=>{const n=i.met?"":'<button type="button" class="rowvia-nf-fix" data-'+(i.viewLink?'gate-view="'+H(i.id)+'"':'gate-fix="'+H(i.id)+'"')+">"+H(i.fixLabel??"去填写")+"</button>";return'<li class="'+(i.met?"is-met":"is-unmet")+'"><i aria-hidden="true">'+(i.met?"✓":"✕")+"</i><span>"+H(i.label)+(i.detail?"<small>"+H(i.detail)+"</small>":"")+"</span>"+n+"</li>"}).join("");return'<section class="rowvia-nf-gates" data-gates><h4>完成前需满足 <em>'+e+"/"+s.length+"</em></h4><ul>"+t+"</ul></section>"}function Zo(s,e){const t=s.tasks??[],i=e?"":'<button type="button" class="rowvia-nf-link" data-action="add-task">+ 新增任务</button>';if(!t.length)return'<section class="rowvia-nf-tasks is-empty"><h4>全部任务 (0/0)</h4><p>暂无子任务'+(e?"":'<button type="button" data-action="add-task">+ 新增任务</button>')+"</p></section>";const n=t.filter(a=>a.done).length,o=t.map(a=>{const l=a.deliverable?'<span class="rowvia-nf-deliverable">📎 '+H(a.deliverable)+"</span>":'<span class="rowvia-nf-value is-empty">暂无</span>';return'<tr class="'+(a.done?"is-done":"")+'"><td><label class="rowvia-nf-check"><input type="checkbox" data-task="'+H(a.id)+'"'+(a.done?" checked":"")+(e?" disabled":"")+"><span>"+H(a.name)+"</span></label>"+(a.blocking?'<em class="rowvia-nf-blocker" title="未完成前主节点无法流转">阻塞项</em>':"")+"</td><td>"+l+"</td><td>"+H(a.owner||"暂无")+"</td><td>"+H(a.estimate||"暂无")+"</td><td>"+H(a.schedule||"暂无")+"</td></tr>"}).join("");return'<section class="rowvia-nf-tasks"><h4>全部任务 ('+n+"/"+t.length+")"+i+"</h4><table><thead><tr><th>名称</th><th>交付物</th><th>当前负责人</th><th>估分</th><th>排期</th></tr></thead><tbody>"+o+"</tbody></table></section>"}function Qo(s,e){const t=s.form??[];if(!t.length)return"";const i=t.filter(r=>r.required).length,n=t.filter(r=>r.required&&!r.value).length,o=t.map(r=>{var c;let d;return!e&&r.type==="select"&&((c=r.options)!=null&&c.length)?d='<select data-form="'+H(r.id)+'" aria-label="'+H(r.label)+'"><option value="">请选择</option>'+r.options.map(p=>"<option"+(p===r.value?" selected":"")+">"+H(p)+"</option>").join("")+"</select>":!e&&r.type==="date"?d='<input type="date" data-form="'+H(r.id)+'" value="'+H(r.value??"")+'" aria-label="'+H(r.label)+'">':e?d='<span class="rowvia-nf-value'+(r.value?"":" is-empty")+'">'+H(r.value||"待填")+"</span>":d='<input data-form="'+H(r.id)+'" value="'+H(r.value??"")+'" placeholder="'+H(r.placeholder??"待填")+'" aria-label="'+H(r.label)+'">','<div class="rowvia-nf-form-row"><label>'+H(r.label)+(r.required?"<b>*</b>":"")+'</label><div class="rowvia-nf-field-control">'+d+"</div></div>"}).join(""),a=n?'<em class="rowvia-nf-warn">'+n+" 项必填未完成</em>":"",l="节点表单 · "+t.length+" 项"+(i?"("+i+" 必填)":"")+a;return'<section class="rowvia-nf-form'+(n?" has-pending":"")+'"><h4>'+l+"</h4>"+o+"</section>"}function Jo(s){const e=s.events??[];if(!e.length)return"";const t=(o,a)=>a.length?"<span><b>"+o+"</b>"+a.map(l=>H(l.text)).join(";")+"</span>":"",i=e.filter(o=>o.trigger==="arrive"),n=e.filter(o=>o.trigger==="complete");return'<section class="rowvia-nf-events"><details><summary>ℹ 节点事件('+e.length+' 条规则已生效)</summary><div class="rowvia-nf-events-body">'+t("到达本节点时:",i)+t("完成本节点时:",n)+"<p>事件规则由流程模板配置,回滚节点至到达/完成之前的状态可解除限制。</p></div></details></section>"}function tn(s,e){const t=document.createElement("div"),i=new Ge;t.className="rowvia-nf-card",s.append(t);const n=xe(t,"node-card",e);let o=e.node??null,a={...e},l=!1;const r=()=>{var E;if(!o){t.innerHTML='<div class="rowvia-nf-empty">在上方流程画布中选择一个节点,查看它的字段、表单与通行条件。</div>';return}const f=!!a.readonly,u=at[o.status],h=Zt(o),g=o.completionMode?Yi[o.completionMode]:"",v=Ko(o),m=(o.buttons??[]).filter(x=>(x.placement??"inline")==="inline"),C=(o.buttons??[]).filter(x=>x.placement==="more"),S=(x,k,$="")=>'<span class="rowvia-nf-chip '+k+'"'+($?' title="'+H($)+'"':"")+">"+H(x)+"</span>",b=(x,k,$,q="",F=!1)=>'<button type="button" class="rowvia-nf-btn '+$+'" data-action="'+H(x)+'"'+(q?' title="'+H(q)+'"':"")+(F?" disabled":"")+">"+H(k)+"</button>",y=[];if(!f){o.status==="inProgress"&&y.push(b("complete","完成","is-primary")),o.status==="failed"&&y.push(b("resubmit","重新提交","is-primary")),(o.status==="done"||o.status==="failed")&&y.push(b("rollback","回滚","is-ghost","将节点状态回退至进行中")),y.push(b("transfer","转办","is-ghost","将负责人转交他人"));for(const x of m){const k=[x.hint,(E=x.roles)!=null&&E.length?"授权:"+x.roles.join("、"):""].filter(Boolean).join(" · "),$=x.variant==="primary"?"is-primary":x.variant==="warning"?"is-warning":"is-ghost";y.push(b("custom:"+x.id,x.label,$,k))}y.push('<button type="button" class="rowvia-nf-btn is-icon" data-action="more" aria-haspopup="menu" aria-expanded="'+String(l)+'">···</button>')}const R='<span class="rowvia-nf-owner">负责人 '+H(o.owner||"待填")+(o.ownerSource?"<em>"+H(o.ownerSource)+"</em>":"")+"</span>",M='<div class="rowvia-nf-menu" data-menu'+(l?"":" hidden")+' role="menu"><button type="button" role="menuitem" data-action="estimate">填写估分</button><button type="button" role="menuitem" data-action="group-chat">节点建群</button>'+C.map(x=>'<button type="button" role="menuitem" data-action="custom:'+H(x.id)+'">'+H(x.label)+"</button>").join("")+'<button type="button" role="menuitem" class="is-danger" data-action="delete-node"'+(o.deleteRoles?' title="允许删除:'+H(o.deleteRoles.join("、"))+'"':"")+">删除节点</button></div>",T='<header class="rowvia-nf-card-head"><span class="rowvia-nf-dot status-'+u.className+'" aria-hidden="true"></span><h3>'+H(o.name)+"</h3>"+S(u.label,"status-"+u.className)+(g?S(g,"is-mode","对应配置:完成方式"):"")+(o.milestone?S("◆ 里程碑"+(o.deadline?" · "+o.deadline:""),"is-milestone","里程碑:仅可填写截止时间"):"")+R+'<span class="rowvia-nf-space"></span><div class="rowvia-nf-actions">'+y.join("")+"</div>"+M+"</header>",W=v.map(x=>'<div class="rowvia-nf-field-group" data-section="'+x.key+'"><h5>'+H(x.title)+"</h5>"+x.fields.map(k=>Yo(o,k,f)).join("")+"</div>").join("");t.innerHTML=T+Xo(h)+'<details class="rowvia-nf-section" open><summary>节点字段 <em>'+v.length+" 组</em></summary>"+W+"</details>"+Qo(o,f)+Zo(o,f)+Jo(o)},d=f=>{var g,v,m,C,S;const u=f.target.closest("[data-action],[data-gate-fix],[data-gate-view],[data-info]");if(!u||!t.contains(u))return;if(u.dataset.info){i.add(nn(u,u.dataset.info));return}if(u.dataset.gateFix||u.dataset.gateView){p(),(g=a.onAction)==null||g.call(a,u.dataset.gateView?"open-gate-view":"fix-gate",(o==null?void 0:o.id)??"");return}const h=u.dataset.action;if(h){if(h==="more"){const b=t.querySelector("[data-menu]");if(!b)return;l=b.hidden,b.hidden=!l,u.setAttribute("aria-expanded",String(l));return}if(h==="complete"){const b=o?Zt(o):[];if(!Xi(b)){p(),(v=a.onAction)==null||v.call(a,"complete-blocked",(o==null?void 0:o.id)??"");return}if(((m=a.onComplete)==null?void 0:m.call(a,(o==null?void 0:o.id)??"",b))===!1)return;(C=a.onAction)==null||C.call(a,"complete",(o==null?void 0:o.id)??"");return}(S=a.onAction)==null||S.call(a,h,(o==null?void 0:o.id)??"")}},c=f=>{var h,g,v,m,C;const u=f.target;if(u instanceof HTMLInputElement){u.dataset.task?(h=a.onTaskToggle)==null||h.call(a,(o==null?void 0:o.id)??"",u.dataset.task,u.checked):u.dataset.field?(g=a.onFieldChange)==null||g.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((v=a.onFormChange)==null||v.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value));return}u instanceof HTMLSelectElement&&(u.dataset.field?(m=a.onFieldChange)==null||m.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((C=a.onFormChange)==null||C.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value)))};function p(){const f=t.querySelector(".rowvia-nf-gates");f&&(f.classList.add("is-shaking"),i.timeout(()=>f.classList.remove("is-shaking"),700))}return t.addEventListener("click",d),t.addEventListener("change",c),r(),{onInteraction:n.onInteraction,update(f,u){o=f,u&&(a={...a,...u}),r()},destroy(){t.removeEventListener("click",d),t.removeEventListener("change",c),n.destroy(),i.destroy(),t.remove()}}}function nn(s,e){const t=document.createElement("div");t.className="rowvia-nf-tip",t.textContent=e,document.body.append(t);const i=s.getBoundingClientRect();t.style.left=Math.max(8,Math.min(window.innerWidth-260,i.left))+"px",t.style.top=i.bottom+6+"px";const n=window.setTimeout(()=>t.remove(),2600);return()=>{window.clearTimeout(n),t.remove()}}function sn(s,e){const t=document.createElement("div"),i=new Ge;t.className="rowvia-nf-contextbar",s.append(t);const n=xe(t,"flow-context",e);let o=e.flow,a=e.query??"",l=!1;const r=()=>{const c=Zi(o),p=!!(o.templateVersion&&o.latestTemplateVersion&&o.templateVersion!==o.latestTemplateVersion);t.innerHTML=`
72
+ <div class="rowvia-nf-context-main">
73
+ <label class="rowvia-nf-flowtype">
74
+ <span class="rowvia-nf-label">流程类型</span>
75
+ <select data-action="flow-type" aria-label="流程类型"><option>${H(o.name)}</option></select>
76
+ </label>
77
+ <span class="rowvia-nf-divider"></span>
78
+ <span class="rowvia-nf-stats">${c.total} 节点 · 已完成 ${c.done} · 当前第 ${c.index}/${c.total}</span>
79
+ <span class="rowvia-nf-chip ${c.failed?"has-failed":""}">未通过 ${c.failed}</span>
80
+ <span class="rowvia-nf-space"></span>
81
+ <div class="rowvia-nf-search">
82
+ <input data-action="search" placeholder="查找节点" value="${H(a)}" aria-label="查找节点">
83
+ <div class="rowvia-nf-suggestions" hidden data-suggestions></div>
87
84
  </div>
85
+ <button type="button" class="rowvia-nf-ghost" data-action="rules" title="只读展示该流程的完成方式、节点事件与状态计算规则">⚙ 规则</button>
88
86
  </div>
89
- <section class="gridWrapper">
90
- <div id="performanceGrid" class="gridSurface ag-theme-quartz"></div>
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=y=>y.value==null?"":`$${Math.round(y.value).toLocaleString("en-US")}`;function l(y){const M=document.createElement("span");M.style.display="inline-flex",M.style.alignItems="center",M.style.gap="6px";const P=document.createElement("span");P.textContent=o[String(y.value)]??"🏳️",P.style.fontSize="15px";const D=document.createElement("span");return D.textContent=String(y.value??""),D.style.overflow="hidden",D.style.textOverflow="ellipsis",D.style.whiteSpace="nowrap",M.appendChild(P),M.appendChild(D),M}const r='<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(y){const M=document.createElement("span");M.className="v-align";const P=Number(y.value??0);if(P===0&&y.isFilterRenderer)return M.textContent="(No stars)",M;for(let D=0;D<P;D++){const j=document.createElement("span");j.innerHTML=r,M.appendChild(j)}return M}function d(y){return y.value===null||y.value===void 0?null:y.value<0?{color:"#e11d48",fontWeight:"bold"}:null}function u(y){const M=[{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:Ii},filter:"set",editable:!0},{field:"country",width:150,cellRenderer:l,cellEditor:"agRichSelectCellEditor",cellEditorParams:{cellRenderer:l,values:Ni},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:Li,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":P=>typeof P.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":P=>typeof P.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:P=>Ai.map(D=>({month:D,value:P.data[D]})),cellRendererParams:{sparklineOptions:{type:"area"}}},...Ai.map(P=>({field:P,headerName:P.charAt(0).toUpperCase()+P.slice(1),width:120,enableValue:!0,aggFunc:"sum",cellDataType:!0,filter:"number",filterParams:{buttons:["reset"],inRangeInclusive:!0},cellClassRules:{"good-score":D=>typeof D.value=="number"&&D.value>5e4,"bad-score":D=>typeof D.value=="number"&&D.value<1e4,"currency-cell":D=>typeof D.value=="number"&&D.value>=1e4&&D.value<=5e4},editable:!0}))]}];if(y>0){const P=Ea(y),D=new Map;for(const j of P)D.has(j.group)||D.set(j.group,[]),D.get(j.group).push(j);for(const[j,W]of D)M.push({headerName:j,groupId:`extra-${j}`,openByDefault:!0,children:W.map(B=>({field:B.field,headerName:B.field,width:B.width,editable:!0,cellDataType:B.dataType!=="text",filter:B.dataType==="text"?"set":"number",valueFormatter:B.dataType==="percent"?E=>E.value==null?"":`${E.value.toFixed(1)}%`:B.dataType==="currency"?a:void 0,aggFunc:B.dataType==="text"?void 0:"sum"}))})}return M}const p=i.querySelector("#performanceGrid"),g=i.querySelector("#data-size"),C=i.querySelector("#theme-select"),h=i.querySelector("#global-filter");let f=null,m,b=0;function R(){m!==void 0&&window.clearTimeout(m),m=t.timeout(()=>k(),10)}function k(){var q;const y=++b,[M,P]=g.value.split("x").map(Number),D=Math.max(0,P-24),j=C.value;if(f&&(f.destroy(),f=null,p.innerHTML=""),f=n(p,{columnDefs:u(D),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;f.showLoadingOverlay();const W=M>1e4?1e4:1e3,B=Math.ceil(M/W);let E=0;const S=[],$=Date.now();ba();const z=()=>{if(y!==b)return;const ee=Sa(Math.min(W,M-E*W),D);if(S.push(...ee),E++,E<B)t.timeout(z,0);else{const se=Date.now()-$,V=Math.max(0,500-se);t.timeout(()=>{y===b&&(f==null||f.hideOverlay(),f==null||f.setRowData(S))},V)}};t.timeout(z,0)}return g.addEventListener("change",R),C.addEventListener("change",R),h.addEventListener("input",()=>{f==null||f.setQuickFilter(h.value)}),k(),t.handle}function ka(s,e={}){const t=qt(s,"server-side",`<div class="exampleWrapper">
93
- <div class="toolbar">
94
- <div class="controls">
95
- <div class="group">
96
- <label class="label">Server-Side Row Model</label>
97
- <span class="hint">50,000 rows · sorting, filtering and grouping run on the server · 120 ms latency</span>
98
- </div>
99
- <div class="group">
100
- <button class="button" id="refresh">Refresh Server Data</button>
101
- <button class="button" id="purge">Purge Cache</button>
102
- </div>
103
- </div>
104
- </div>
105
- <section class="gridWrapper">
106
- <div id="serverSideGrid" class="gridSurface ag-theme-quartz"></div>
107
- </section>
108
- </div>`,e),{host:i,createGrid:n}=t,o=Mi(2024),a=["Ireland","Spain","France","Germany","Italy","Portugal","Netherlands"],l=["Engineering","Design","Product","Sales","Support","Finance"],r=["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,f)=>({id:f,name:`${r[f%r.length]} ${c[f*7%c.length]}`,country:a[f%a.length],department:l[f*3%l.length],salary:4e4+Math.floor(o()*8e4),rating:Math.floor(o()*6),started:`${2015+f%10}-0${1+f%9}-1${f%9}`})),u=120;function p(h){var y,M;let f=d.slice();const m=Object.entries(h.filterModel||{});if(m.length&&(f=f.filter(P=>m.every(([D,j])=>{const W=P[D],B=String(W).toLowerCase(),E=String(j.filter??"").toLowerCase();if(!E)return!0;switch(j.type){case"notEqual":return B!==E;case"startsWith":return B.startsWith(E);case"endsWith":return B.endsWith(E);default:return B.includes(E)}}))),(y=h.sortModel)!=null&&y.length){const{colId:P,sort:D}=h.sortModel[0];f=f.slice().sort((j,W)=>{const B=j[P]===W[P]?0:j[P]<W[P]?-1:1;return D==="asc"?B:-B})}const b=h.groupKeys||[],R=(M=h.rowGroupCols)==null?void 0:M[b.length];if(R){const P=f.filter(B=>b.every((E,S)=>{const $=h.rowGroupCols[S];return String(B[$.field])===E})),D=new Map,j=[];for(const B of P){const E=String(B[R.field]);D.has(E)||(D.set(E,{count:0,salary:[]}),j.push(E));const S=D.get(E);S.count++,S.salary.push(B.salary)}const W=j.map(B=>{const E=D.get(B),S={id:`group-${b.join("/")}-${R.field}-${B}`,__isGroup:!0,childCount:E.count};return S[R.field]=B,S.salary=Math.round(E.salary.reduce(($,z)=>$+z,0)/E.salary.length),S});return{rows:W,lastRow:W.length}}return{rows:f.slice(h.startRow,h.endRow),lastRow:f.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:C}=n(i.querySelector("#serverSideGrid"),{columnDefs:g,rowData:[],rowModelType:"serverSide",serverSideDatasource:{getRows:h=>{t.timeout(()=>{const{rows:f,lastRow:m}=p(h);h.successCallback(f,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",()=>{C.refreshServerSide({purge:!0})}),i.querySelector("#purge").addEventListener("click",()=>{C.purgeServerSideCache()}),t.handle}const X=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},et=s=>s.choices??(s.options||[]).map(e=>({id:e,label:e})),An=["#dcf0d5","#d9eeec","#fce2ef","#e9e7fa","#fbe8d5"],Di=(s,e)=>{var t,i;return((t=et(s).find(n=>n.id===e))==null?void 0:t.color)||((i=s.colors)==null?void 0:i[e])||An[Math.max(0,et(s).findIndex(n=>n.id===e))%An.length]},Dn=s=>(Array.isArray(s)?s:s==null||s===""?[]:[s]).map(String);function Ma(s,e){var t;return((t=et(s).find(i=>i.id===e))==null?void 0:t.label)||e}function jt(s,e="choice"){const t=X("div","fc-tags");for(const i of Dn(s.value)){const n=Ma(s.field,i),o=X(e==="relation"?"button":"span","fc-tag fc-tag--"+e);e==="choice"&&(o.style.backgroundColor=Di(s.field,i)),e==="person"&&o.append(X("span","fc-avatar",n.slice(0,1))),o.append(X("span","",n)),o.tagName==="BUTTON"&&(o.type="button",o.onclick=a=>{a.stopPropagation(),s.openDetail(i)}),t.append(o)}return t.children.length||t.append(X("span","fc-empty","待填")),t}function Dt(s,e,t="choice"){var W;const i=X("div","fc-choice fc-choice--"+t);let n=Dn(e.value).slice(0,s?void 0:1);const o=new Map(et(e.field).map(B=>[B.id,B]));let a=et(e.field);const l=s&&(e.field.maxSelections??0)>0?e.field.maxSelections:1/0,r=X("select","fc-select");r.hidden=!0,r.multiple=s,r.disabled=e.readonly,r.required=!!e.field.required,r.ariaLabel=e.field.label;const c=X("div","fc-choice-head"),d=X("div","fc-choice-selection"),u=X("input","fc-choice-search");u.placeholder=t==="person"?"搜索姓名":t==="relation"?"搜索工作项名称或编号":"搜索",u.ariaLabel="搜索"+e.field.label,u.disabled=e.readonly;const p=X("div","fc-option-list");p.setAttribute("role",t==="radio"?"radiogroup":"group"),p.ariaLabel=e.field.label;const g=X("div","fc-error fc-choice-feedback");g.setAttribute("role","status");const C=X("div","fc-picker-status");C.setAttribute("role","status");const h=X("button","fc-retry","重试");h.type="button",h.hidden=!0;let f,m=0,b=!1,R=!1;const k=t!=="radio"&&!!((W=e.services)!=null&&W.searchOptions),y=()=>{var B;(B=e.onSelectedOptions)==null||B.call(e,n.map(E=>o.get(E)).filter(E=>!!E)),i.dispatchEvent(new Event("change",{bubbles:!0}))},M=()=>{var B;if(r.replaceChildren(),!s){const E=X("option");E.value="",r.append(E)}for(const E of new Set([...a.map(S=>S.id),...n])){const S=X("option","",((B=o.get(E))==null?void 0:B.label)||E);S.value=E,S.selected=n.includes(E),r.append(S)}s||(r.value=n[0]||"")},P=()=>{d.replaceChildren(),p.replaceChildren(),M();for(const S of n){const $=o.get(S),z=X("span","fc-tag fc-tag--"+t);(t==="choice"||t==="radio")&&(z.style.backgroundColor=Di(e.field,S)),t==="person"&&z.append(X("span","fc-avatar",(($==null?void 0:$.label)||S).slice(0,1))),z.append(X("span","",(($==null?void 0:$.label)||S)+($!=null&&$.disabled?"(已停用)":"")));const q=X("button","fc-choice-remove","×");q.type="button",q.disabled=e.readonly,q.ariaLabel="移除"+(($==null?void 0:$.label)||S),q.onclick=ee=>{ee.stopPropagation(),n=n.filter(se=>se!==S),g.textContent="",P(),u.focus(),y()},z.append(q),d.append(z)}const B=u.value.trim().toLocaleLowerCase(),E=a.filter(S=>!S.disabled&&(k||(S.label+" "+S.id+" "+(S.description||"")).toLocaleLowerCase().includes(B)));for(const S of E){const $=X("button","fc-option");$.type="button",$.dataset.value=S.id,$.disabled=e.readonly||R;const z=n.includes(S.id);$.classList.toggle("selected",z),$.setAttribute(t==="radio"?"aria-checked":"aria-pressed",String(z)),t==="radio"&&$.setAttribute("role","radio");const q=X("span","fc-option-label"+(t==="choice"?" fc-tag":""),S.label);t==="choice"&&(q.style.backgroundColor=Di(e.field,S.id)),t==="person"&&$.append(X("span","fc-avatar",S.label.slice(0,1))),t==="relation"&&$.append(X("span","fc-relation-icon","↗"));const ee=X("span","fc-option-copy");ee.append(q),S.description&&ee.append(X("small","fc-option-description",S.description)),$.append(ee,X("span","fc-option-mark",z?"✓":"")),$.onclick=se=>{if(se.stopPropagation(),!e.readonly){if(!s)n=[S.id];else if(z)n=n.filter(V=>V!==S.id);else{const V=S.exclusive?[]:n.filter(U=>{var Z;return!((Z=o.get(U))!=null&&Z.exclusive)});if(V.length>=l){g.textContent="最多可选择 "+l+" 项";return}n=[...V,S.id]}g.textContent="",P(),p.querySelectorAll("button").forEach(V=>{V.dataset.value===S.id&&V.focus()}),y()}},p.append($)}!E.length&&!R&&p.append(X("p","fc-empty fc-choice-empty","暂无匹配选项"))},D=async()=>{f==null||f.abort();const B=++m;f=new AbortController,R=!0,h.hidden=!0,C.textContent="加载中…",i.setAttribute("aria-busy","true"),P();try{const E=await e.services.searchOptions(e.field,u.value.trim(),f.signal);if(b||B!==m)return;a=E,E.forEach(S=>o.set(S.id,S)),C.textContent=""}catch{if(b||B!==m)return;a=[],C.textContent="加载失败,请重试",h.hidden=!1}finally{!b&&B===m&&(R=!1,i.setAttribute("aria-busy","false"),P())}};u.oninput=()=>{k?D():P()},h.onclick=()=>void D();const j=B=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(B.key))return;const E=[...p.querySelectorAll("button:not(:disabled)")];if(!E.length)return;B.preventDefault();const S=E.indexOf(document.activeElement),$=B.key==="Home"?0:B.key==="End"?E.length-1:(S+(B.key==="ArrowUp"||B.key==="ArrowLeft"?-1:1)+E.length)%E.length;E[$].focus()};return p.onkeydown=j,u.onkeydown=B=>{B.key==="ArrowDown"&&j(B)},r.onchange=()=>{n=[...r.selectedOptions].map(B=>B.value).filter(Boolean),P()},c.append(d),t!=="radio"&&c.append(u),i.append(r,c,C,p,h,g),P(),k&&!e.readonly&&D(),{element:i,read:()=>s?[...n]:n[0]||"",validate:()=>e.field.required&&!n.length?"请选择一个选项":n.length>l?"最多可选择 "+l+" 项":void 0,focus:()=>{var B;return t==="radio"?(B=p.querySelector("button"))==null?void 0:B.focus():u.focus()},destroy:()=>{b=!0,++m,f==null||f.abort()}}}const ye=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Ta=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),Fn=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function Xt(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),!Ta.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",l=o.getAttribute("src")||"",r=o.getAttribute("alt")||"",c=o.getAttribute("data-person-id"),d=o.hasAttribute("checked"),u=o.getAttribute("data-task")==="true",p=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(C=>[C,o.style.getPropertyValue(C)]),g=o.tagName==="FONT"?o.getAttribute("color"):null;for(const C of[...o.attributes])o.removeAttribute(C.name);for(const[C,h]of p)(C==="color"||C==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(h):C==="text-align"?/^(left|center|right|justify)$/.test(h):C==="margin-left"?/^\d{1,3}px$/.test(h):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(h))&&o.style.setProperty(C,h);if(g&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(g)&&(o.style.color=g),o.tagName==="A"&&Fn(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="IMG"){if(!/^https?:\/\//i.test(l.trim())){o.remove();continue}o.setAttribute("src",l.trim()),o.setAttribute("alt",r),o.setAttribute("loading","lazy"),o.setAttribute("referrerpolicy","no-referrer")}o.tagName==="SPAN"&&c&&(o.setAttribute("data-person-id",c),o.setAttribute("contenteditable","false")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),d&&o.setAttribute("checked","")),u&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const Fi={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 Na(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=Xt(s.value);const n=ye("div","fc-rich-menu");n.hidden=!0;let o=null,a=!1,l=[i.innerHTML],r=0,c=!1,d=null,u;const p=()=>{const E=window.getSelection();E!=null&&E.rangeCount&&i.contains(E.anchorNode)&&i.contains(E.focusNode)&&(o=E.getRangeAt(0).cloneRange())},g=()=>{i.focus();const E=window.getSelection();if(!E)return;const S=o&&i.contains(o.commonAncestorContainer)?o:document.createRange();S!==o&&(S.selectNodeContents(i),S.collapse(!1)),E.removeAllRanges(),E.addRange(S),o=S},C=()=>{var E;(E=u==null?void 0:u.destroy)==null||E.call(u),u=void 0,n.hidden=!0,n.replaceChildren()},h=new Map,f=()=>{var E;h.get("撤销").disabled=s.readonly||r===0,h.get("重做").disabled=s.readonly||r===l.length-1;for(const[S,$]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=h.get(S);if(!z)continue;const q=!!((E=document.queryCommandState)!=null&&E.call(document,$));z.classList.toggle("active",q),z.setAttribute("aria-pressed",String(q))}},m=()=>{c||(i.innerHTML!==l[r]&&(l=l.slice(0,r+1),l.push(i.innerHTML),l.length>100&&l.shift(),r=l.length-1),p(),f())},b=()=>{m(),i.dispatchEvent(new Event("change",{bubbles:!0}))},R=E=>{const S=r+E;S<0||S>=l.length||(r=S,c=!0,i.innerHTML=l[r],o=null,g(),c=!1,f(),i.dispatchEvent(new Event("change",{bubbles:!0})))},k=(E,S)=>{s.readonly||(g(),document.execCommand(E,!1,S),p(),C(),b())},y=E=>{if(s.readonly)return;g();const S=window.getSelection().getRangeAt(0);S.deleteContents(),S.insertNode(E),S.setStartAfter(E),S.collapse(!0),o=S.cloneRange(),C(),b()},M=(E,S,$,z=!0)=>{const q=ye("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return q.type="button",q.ariaLabel=E,q.title=E,q.disabled=s.readonly,Fi[S]?q.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Fi[S]}</svg>`:q.textContent=S,q.onmousedown=ee=>{ee.preventDefault(),p()},q.onclick=ee=>{ee.stopPropagation(),$()},t.append(q),h.set(E,q),q},P=(E,S)=>{var z;if(s.readonly)return;if(p(),!n.hidden&&n.ariaLabel===E){C();return}(z=u==null?void 0:u.destroy)==null||z.call(u),u=void 0,n.replaceChildren(),n.className="fc-rich-menu",n.ariaLabel=E,S(),n.hidden=!1;const $=h.get(E);n.style.left=`${Math.max(4,Math.min($.offsetLeft,e.clientWidth-280))}px`},D=(E,S)=>{const $=ye("button","fc-rich-menu-option",E);return $.type="button",$.onmousedown=z=>z.preventDefault(),$.onclick=z=>{z.stopPropagation(),S()},n.append($),$};M("撤销","undo",()=>R(-1),!1),M("重做","redo",()=>R(1),!1),M("格式刷","paint",()=>{p();const E=o==null?void 0:o.startContainer,S=(E==null?void 0:E.nodeType)===1?E:E==null?void 0:E.parentElement;!S||!i.contains(S)||(d={tag:/^(B|STRONG|I|EM|U|S)$/.test(S.tagName)?S.tagName.toLowerCase():"span",css:S.getAttribute("style")||""},h.get("格式刷").classList.add("active"))}),M("正文样式","Aa⌄",()=>P("正文样式",()=>{for(const[E,S]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])D(E,()=>k("formatBlock",S))}));const j=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[E,S,$]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])M(E,S,()=>P(E,()=>{n.classList.add("fc-rich-colors");for(const z of j){const q=D(z,()=>k($,z));q.textContent="",q.style.backgroundColor=z,q.ariaLabel=`${E} ${z}`}D("清除",()=>k($,$==="foreColor"?"#1f2329":"transparent"))}));for(const[E,S,$]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])M(E,S,()=>k($));M("对齐","☰⌄",()=>P("对齐",()=>{for(const[E,S]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])D(E,()=>k(S))})),M("有序列表","1≡",()=>k("insertOrderedList")),M("无序列表","•≡",()=>k("insertUnorderedList")),M("任务列表","task",()=>{g();const E=window.getSelection().getRangeAt(0),S=ye("ul"),$=ye("li");$.dataset.task="true";const z=ye("input");z.type="checkbox",z.contentEditable="false",$.append(z,E.extractContents()),$.textContent||$.append(document.createTextNode("待办事项")),S.append($),y(S)}),M("引用","quote",()=>k("formatBlock","blockquote")),M("缩进","indent",()=>P("缩进",()=>{D("增加缩进",()=>k("indent")),D("减少缩进",()=>k("outdent"))})),M("分隔线","line",()=>y(ye("hr"))),M("表格","table",()=>P("表格",()=>{const E=ye("p","","选择行列"),S=ye("div","fc-rich-table-grid");n.append(E,S);for(let $=1;$<=6;$++)for(let z=1;z<=6;z++){const q=ye("button");q.type="button",q.ariaLabel=`${$}行${z}列表格`,q.dataset.row=String($),q.dataset.col=String(z),q.onmousedown=ee=>ee.preventDefault(),q.onmouseenter=()=>{E.textContent=`${$} × ${z}`,S.querySelectorAll("button").forEach(ee=>ee.classList.toggle("active",Number(ee.dataset.row)<=$&&Number(ee.dataset.col)<=z))},q.onclick=()=>{const ee=ye("table"),se=ye("tbody");for(let U=0;U<$;U++){const Z=ye("tr");for(let K=0;K<z;K++){const oe=ye("td");oe.append(ye("br")),Z.append(oe)}se.append(Z)}ee.append(se),y(ee);const V=document.createRange();V.selectNodeContents(ee.querySelector("td")),V.collapse(!0),o=V,g()},S.append(q)}}));const W=()=>P("链接",()=>{const E=ye("input","fc-input");E.ariaLabel="链接文本",E.placeholder="输入文本",E.value=(o==null?void 0:o.toString())||"";const S=ye("input","fc-input");S.ariaLabel="链接地址",S.placeholder="粘贴或输入超链接";const $=ye("div","fc-error"),z=ye("button","primary","确定");z.type="button",z.onclick=()=>{const q=S.value.trim();if(!Fn(q)){$.textContent="请输入 http、https 或 mailto 链接";return}const ee=ye("a","",E.value||q);ee.href=q,ee.target="_blank",ee.rel="noopener noreferrer",y(ee)},n.append(ye("span","","文本"),E,ye("span","","链接"),S,$,z),E.focus()});M("链接","link",W),M("插入图片","▧",()=>P("插入图片",()=>{const E=ye("input","fc-input");E.type="url",E.ariaLabel="图片地址",E.placeholder="https:// 图片地址";const S=ye("input","fc-input");S.ariaLabel="图片说明",S.placeholder="图片说明";const $=ye("div","fc-error"),z=ye("button","primary","插入");z.type="button",z.onclick=()=>{if(!/^https?:\/\//i.test(E.value.trim())||!E.checkValidity()){$.textContent="请输入有效的 http 或 https 图片地址";return}const q=ye("img");q.src=E.value.trim(),q.alt=S.value,q.referrerPolicy="no-referrer",y(q)},n.append(E,S,$,z),E.focus()})),M("提及人员","@",()=>P("提及人员",()=>{var S;const E=Dt(!1,{...s,value:"",field:{...s.field,label:"人员"}},"person");u=E,n.append(E.element),E.element.addEventListener("change",$=>{var ee,se;$.stopPropagation();const z=String(E.read());if(!z)return;const q=ye("span","","@"+(((ee=et(s.field).find(V=>V.id===z))==null?void 0:ee.label)||((se=E.element.querySelector("option:checked"))==null?void 0:se.textContent)||z));q.dataset.personId=z,q.contentEditable="false",y(q)}),(S=E.focus)==null||S.call(E)})),M("代码块","{ }",()=>k("formatBlock","pre")),M("表情","☺",()=>P("表情",()=>{n.classList.add("fc-rich-emojis");for(const E of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])D(E,()=>y(document.createTextNode(E)))}));const B=M("全屏编辑","expand",()=>{p(),a=!a,e.classList.toggle("is-fullscreen",a),C(),B.ariaLabel=B.title=a?"收起全屏":"全屏编辑",B.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${Fi[a?"collapse":"expand"]}</svg>`,g()},!1);return B.disabled=!1,B.classList.add("fc-rich-expand"),i.addEventListener("input",m),i.addEventListener("mouseup",()=>{if(p(),f(),d&&o&&!o.collapsed){const E=o,S=ye(d.tag);S.style.cssText=d.css,S.append(E.extractContents()),E.insertNode(S),d=null,h.get("格式刷").classList.remove("active"),b()}}),i.addEventListener("keyup",()=>{p(),f()}),i.addEventListener("click",E=>{const S=E.target;if(S.tagName==="A"&&E.preventDefault(),S instanceof HTMLInputElement&&S.type==="checkbox"){if(s.readonly){E.preventDefault();return}S.toggleAttribute("checked",S.checked),b()}C()}),i.addEventListener("drop",E=>E.preventDefault()),i.addEventListener("paste",E=>{var $,z;if(s.readonly){E.preventDefault();return}E.preventDefault(),p();const S=($=E.clipboardData)==null?void 0:$.getData("text/html");if(S){const q=document.createElement("template");q.innerHTML=Xt(S);const ee=q.content,se=document.createTextNode("");ee.append(se),g();const V=window.getSelection().getRangeAt(0);V.deleteContents(),V.insertNode(ee),V.setStartAfter(se),V.collapse(!0),o=V.cloneRange(),b()}else y(document.createTextNode(((z=E.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",E=>{E.key==="Escape"&&!n.hidden?(E.preventDefault(),E.stopPropagation(),C(),g()):E.key==="Escape"&&a?(E.preventDefault(),E.stopPropagation(),B.click()):!s.readonly&&(E.metaKey||E.ctrlKey)&&E.key.toLowerCase()==="z"?(E.preventDefault(),R(E.shiftKey?1:-1)):(E.metaKey||E.ctrlKey)&&E.key.toLowerCase()==="k"&&(E.preventDefault(),p(),W())}),e.append(t,i,n),f(),{element:e,read:()=>Xt(i.innerHTML),validate:()=>{var E;return s.field.required&&!((E=i.textContent)!=null&&E.trim())&&!i.querySelector("img")?"请填写内容":void 0},focus:()=>i.focus(),deactivate:()=>{C(),a=!1,e.classList.remove("is-fullscreen"),B.ariaLabel=B.title="全屏编辑"},destroy:()=>{var E;return(E=u==null?void 0:u.destroy)==null?void 0:E.call(u)}}}const ke=(s,e,t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},dt=s=>String(s).padStart(2,"0"),Pi=s=>`${s.getFullYear()}-${dt(s.getMonth()+1)}-${dt(s.getDate())}`;function ui(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())&&Pi(t)===s}const Pn=s=>{var e,t,i;return{time:((e=s.field.dateOptions)==null?void 0:e.showTime)??s.field.kind!=="date",range:((t=s.field.dateOptions)==null?void 0:t.showRange)??!1,seconds:((i=s.field.dateOptions)==null?void 0:i.showSeconds)??s.field.kind==="datetime"}};function $n(s){const{time:e,range:t,seconds:i}=Pn(s),o=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(a=>e?String(a).slice(0,i?19:16).replace("T"," "):String(a).slice(0,10)).join(" 至 ");return ke("div",`fc-value fc-${s.surface}${o?"":" fc-empty"}`,o||"待填")}function Gn(s){const{time:e,range:t,seconds:i}=Pn(s),n=ke("div","fc-calendar"),o=Array.isArray(s.value)?s.value:[s.value],a=[0,1].map(U=>String(o[U]||"").slice(0,10)),l=[0,1].map(U=>(String(o[U]||"").slice(11,16)||"00:00")+(i?":"+(String(o[U]||"").slice(17,19)||"00"):""));let r=0,c=!1,d=ui(a[0])?new Date(`${a[0]}T12:00:00`):new Date;d=new Date(d.getFullYear(),d.getMonth(),1);const u=ke("div","fc-calendar-inputs"),p=[],g=()=>n.dispatchEvent(new Event("change",{bubbles:!0})),C=ke("div","fc-error");C.setAttribute("role","status");const h=()=>{if(a.some(U=>U&&!ui(U)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!a[0])return"请选择日期";if(t&&!!a[0]!=!!a[1])return"请选择完整的日期范围";if(e&&l.slice(0,t?2:1).some(U=>!(i?/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/:/^([01]\d|2[0-3]):[0-5]\d$/).test(U)))return"请输入有效时间";if(t&&a[0]&&`${a[0]}T${e?l[0]:""}`>`${a[1]}T${e?l[1]:""}`)return"结束日期时间不能早于开始日期时间"},f=()=>{C.textContent=h()||"",C.textContent||g()};for(let U=0;U<(t?2:1);U++){const Z=ke("input","fc-input fc-calendar-date");Z.type="text",Z.value=a[U],Z.placeholder=t?U?"结束日期":"开始日期":"YYYY-MM-DD",Z.ariaLabel=t?Z.placeholder:s.field.label,Z.disabled=s.readonly,Z.onfocus=()=>{if(r=U,c=U===1,ui(a[U])){const K=new Date(`${a[U]}T12:00:00`);d=new Date(K.getFullYear(),K.getMonth(),1)}se()},Z.addEventListener("change",K=>{if(K.stopPropagation(),a[U]=Z.value.trim(),ui(a[U])){const oe=new Date(`${a[U]}T12:00:00`);d=new Date(oe.getFullYear(),oe.getMonth(),1)}se(),f()}),u.append(Z),p.push(Z)}const m=ke("div","fc-calendar-header"),b=ke("button","fc-calendar-month");b.type="button",b.ariaLabel="选择年份和月份",b.setAttribute("aria-expanded","false"),b.setAttribute("aria-live","polite");const R=(U,Z,K)=>{const oe=ke("button","fc-calendar-nav");return oe.type="button",oe.ariaLabel=U,oe.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${K?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,Z>0&&oe.classList.add("next"),oe.onclick=()=>{d=new Date(d.getFullYear(),d.getMonth()+Z,1),se()},oe};m.append(R("上一年",-12,!0),R("上个月",-1,!1),b,R("下个月",1,!1),R("下一年",12,!0));const k=ke("div","fc-calendar-weekdays");for(const U of["日","一","二","三","四","五","六"])k.append(ke("span","",U));const y=ke("div","fc-calendar-days");y.setAttribute("role","group"),y.ariaLabel="选择日期";const M=ke("div","fc-calendar-period");M.hidden=!0;const P=ke("button","fc-calendar-back","‹ 返回选择日期");P.type="button";const D=ke("div","fc-calendar-period-columns"),j=ke("div","fc-calendar-period-list");j.setAttribute("role","group"),j.ariaLabel="年份";const W=ke("div","fc-calendar-period-list");W.setAttribute("role","group"),W.ariaLabel="月份";const B=ke("div","fc-calendar-period-list");B.ariaLabel="秒",B.hidden=!0,D.append(j,W,B),M.append(P,D);let E="period",S=0;const $=[],z=(U=!1)=>{const Z=l[S].split(":").map(Number),K=E==="period"?[[j,d.getFullYear(),"年"],[W,d.getMonth()+1,"月"]]:[[j,Z[0],"时"],[W,Z[1],"分"],[B,Z[2],"秒"]];for(const[oe,ve,he]of K)for(const Ee of oe.querySelectorAll("button")){const Ve=Number(Ee.dataset.value)===ve;Ee.classList.toggle("selected",Ve),Ee.setAttribute("aria-pressed",String(Ve)),Ee.textContent=`${E==="time"?dt(Number(Ee.dataset.value)):Ee.dataset.value}${Ve?he:""}`,Ve&&U&&(oe.scrollTop=Math.max(0,Ee.offsetTop-108))}},q=(U,Z)=>{const K=ke("button","fc-calendar-period-option",String(U));return K.type="button",K.dataset.value=String(U),K.ariaLabel=`${E==="time"?dt(U):U}${E==="time"?Z?"时":"分":Z?"年":"月"}`,K.disabled=E==="time"&&s.readonly,K.onclick=()=>{if(E==="time"){const oe=l[S].split(":");oe[Z?0:1]=dt(U),l[S]=oe.join(":"),$[S].textContent=l[S],z(),f();return}d.setFullYear(Z?U:d.getFullYear(),Z?d.getMonth():U-1,1),z(),se()},K},ee=(U,Z=0)=>{if(E=U,S=Z,j.replaceChildren(),W.replaceChildren(),B.replaceChildren(),B.hidden=U!=="time"||!i,j.ariaLabel=U==="period"?"年份":"小时",W.ariaLabel=U==="period"?"月份":"分钟",U==="period"){for(let K=Math.max(1,d.getFullYear()-100);K<=Math.min(9999,d.getFullYear()+100);K++)j.append(q(K,!0));for(let K=1;K<=12;K++)W.append(q(K,!1))}else{for(let K=0;K<24;K++)j.append(q(K,!0));for(let K=0;K<60;K++)W.append(q(K,!1));if(i)for(let K=0;K<60;K++){const oe=ke("button","fc-calendar-period-option",dt(K));oe.type="button",oe.dataset.value=String(K),oe.ariaLabel=dt(K)+"秒",oe.disabled=s.readonly,oe.onclick=()=>{const ve=l[S].split(":");ve[2]=dt(K),l[S]=ve.join(":"),$[S].textContent=l[S],z(),f()},B.append(oe)}}n.classList.add("choosing-period"),M.hidden=!1,(U==="period"?b:$[Z]).setAttribute("aria-expanded","true"),z(!0),P.focus()};b.onclick=()=>ee("period"),P.onclick=()=>{n.classList.remove("choosing-period"),M.hidden=!0;const U=E==="period"?b:$[S];U.setAttribute("aria-expanded","false"),se(),U.focus()},M.addEventListener("keydown",U=>{if(U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),P.click()),!["ArrowUp","ArrowDown","Home","End"].includes(U.key))return;const Z=U.target,K=Z.closest(".fc-calendar-period-list");if(!K)return;const oe=[...K.querySelectorAll("button")],ve=oe.indexOf(Z),he=U.key==="Home"?0:U.key==="End"?oe.length-1:Math.max(0,Math.min(oe.length-1,ve+(U.key==="ArrowDown"?1:-1)));U.preventDefault(),oe[he].focus()});function se(){b.textContent=`${d.getFullYear()}年 ${d.getMonth()+1}月`,p.forEach((Z,K)=>Z.classList.toggle("active",K===r)),y.replaceChildren();for(let Z=0;Z<d.getDay();Z++)y.append(ke("span","fc-calendar-blank"));const U=new Date(d.getFullYear(),d.getMonth()+1,0).getDate();for(let Z=1;Z<=U;Z++){const K=Pi(new Date(d.getFullYear(),d.getMonth(),Z)),oe=ke("button","fc-calendar-day",String(Z));oe.type="button",oe.ariaLabel=K,oe.disabled=s.readonly;const ve=a[0]===K||t&&a[1]===K;oe.classList.toggle("selected",ve),oe.setAttribute("aria-pressed",String(ve)),oe.classList.toggle("in-range",t&&!!a[0]&&!!a[1]&&K>a[0]&&K<a[1]),K===Pi(new Date)&&(oe.classList.add("today"),oe.setAttribute("aria-current","date")),oe.onclick=()=>{var he;t?c?(a[1]=K,a[0]&&a[1]<a[0]&&([a[0],a[1]]=[a[1],a[0]]),r=0,c=!1):(a[0]=K,a[1]="",r=1,c=!0):a[0]=K,p.forEach((Ee,Ve)=>Ee.value=a[Ve]),se(),!t||a[1]?f():C.textContent="",(he=y.querySelector(`[aria-label="${K}"]`))==null||he.focus()},y.append(oe)}}if(n.append(u,m,k,y,M),e){const U=ke("div","fc-calendar-time");for(let Z=0;Z<(t?2:1);Z++){const K=ke("div","fc-calendar-time-field"),oe=t?Z?"结束时间":"开始时间":"时间",ve=ke("button","fc-input fc-calendar-time-trigger",l[Z]);ve.type="button",ve.disabled=s.readonly,ve.ariaLabel=oe,ve.setAttribute("aria-expanded","false"),ve.onclick=()=>ee("time",Z),$.push(ve),K.append(ke("span","",oe),ve),U.append(K)}n.append(U)}const V=ke("button","fc-calendar-clear","清空");return V.type="button",V.disabled=s.readonly,V.onclick=()=>{a.fill(""),p.forEach(U=>U.value=""),r=0,c=!1,se(),f()},n.append(V,C),se(),{element:n,read:()=>{const U=a.slice(0,t?2:1).map((Z,K)=>Z?Z+(e?`T${l[K]}`:""):"");return t?U.some(Boolean)?U:[]:U[0]},validate:h,focus:()=>p[0].focus()}}const Hn=s=>!Array.isArray(s)||!s.length?[]:Array.isArray(s[0])?s.map(e=>e.map(String)):[s.map(String)];function Yt(s,e){const t=[];for(const i of e){const n=s.find(o=>o.id===i);t.push((n==null?void 0:n.label)||i),s=(n==null?void 0:n.children)||[]}return t.join(" / ")}function On(s){const e=X("div","fc-tags");for(const t of Hn(s.value))e.append(X("span","fc-tag",Yt(et(s.field),t)));return e.children.length||e.append(X("span","fc-empty","待填")),e}function Bn(s,e){const t=X("div","fc-cascade"),i=X("div","fc-choice-selection"),n=X("input","fc-choice-search");n.placeholder="搜索完整路径",n.ariaLabel="搜索"+e.field.label,n.disabled=e.readonly;const o=X("div","fc-cascade-columns"),a=X("div","fc-error");a.setAttribute("role","status");const l=et(e.field);let r=Hn(e.value),c=[];const d=[],u=(h,f,m=!1)=>h.forEach(b=>{var R;(R=b.children)!=null&&R.length?u(b.children,[...f,b.id],m||!!b.disabled):d.push({path:[...f,b.id],disabled:m||!!b.disabled})});u(l,[]);const p=(h,f)=>JSON.stringify(h)===JSON.stringify(f),g=h=>{if(e.readonly)return;const f=r.findIndex(m=>p(m,h));if(s&&f>=0)r.splice(f,1);else{if(s&&e.field.maxSelections&&r.length>=e.field.maxSelections){a.textContent="最多可选择 "+e.field.maxSelections+" 项";return}r=s?[...r,h]:[h]}a.textContent="",C(),t.dispatchEvent(new Event("change",{bubbles:!0}))},C=()=>{var b,R;if(i.replaceChildren(),o.replaceChildren(),r.forEach(k=>{const y=X("span","fc-tag",Yt(l,k)),M=X("button","fc-choice-remove","×");M.type="button",M.disabled=e.readonly,M.ariaLabel="移除"+Yt(l,k),M.onclick=()=>{r=r.filter(P=>!p(k,P)),C(),t.dispatchEvent(new Event("change",{bubbles:!0}))},y.append(M),i.append(y)}),n.value.trim()){const k=d.filter(y=>!y.disabled&&Yt(l,y.path).toLocaleLowerCase().includes(n.value.trim().toLocaleLowerCase()));for(const{path:y}of k){const M=X("button","fc-option",Yt(l,y));M.type="button",M.disabled=e.readonly,M.setAttribute("aria-pressed",String(r.some(P=>p(P,y)))),M.onclick=()=>g(y),o.append(M)}o.classList.add("is-search"),k.length||o.append(X("p","fc-empty","暂无匹配路径"));return}o.classList.remove("is-search");let h=l,f=[],m=0;for(;h.length;){const k=X("div","fc-cascade-column");k.setAttribute("role","group"),k.ariaLabel="第"+(m+1)+"级";for(const M of h.filter(P=>!P.disabled)){const P=[...f,M.id],D=!!((b=M.children)!=null&&b.length),j=X("button","fc-option",M.label+(D?" ›":""));j.type="button",j.disabled=e.readonly,j.classList.toggle("selected",D?c[m]===M.id:r.some(W=>p(W,P))),j.setAttribute(D?"aria-expanded":"aria-pressed",String(D?c[m]===M.id:r.some(W=>p(W,P)))),j.onclick=()=>{var W,B;D?(c=P,C(),(B=(W=o.lastElementChild)==null?void 0:W.querySelector("button"))==null||B.focus()):g(P)},k.append(j)}o.append(k);const y=h.find(M=>M.id===c[m]&&!M.disabled);if(!((R=y==null?void 0:y.children)!=null&&R.length))break;f=[...f,y.id],h=y.children,m++}l.length||o.append(X("p","fc-empty","暂无可选分类"))};return n.oninput=C,o.onkeydown=h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;const f=h.target,b=[...(f.closest(".fc-cascade-column")||o).querySelectorAll("button:not(:disabled)")];if(!b.length)return;h.preventDefault();const R=b.indexOf(f);b[h.key==="Home"?0:h.key==="End"?b.length-1:(R+(h.key==="ArrowDown"?1:-1)+b.length)%b.length].focus()},t.append(i,n,o,a),C(),{element:t,read:()=>s?r.map(h=>[...h]):[...r[0]||[]],focus:()=>n.focus(),validate:()=>e.field.required&&!r.length?"请选择分类":void 0}}const yt=s=>s==null?"":String(s),Ft=s=>s.dispatchEvent(new Event("change",{bubbles:!0}));function $i(s){try{const e=new URL(yt(s));return["http:","https:"].includes(e.protocol)?e.href:void 0}catch{return}}function St(s){return X("div","fc-value fc-"+s.surface+(s.value==null||s.value===""?" fc-empty":""),yt(s.value)||"待填")}function Qt(s,e){const t=e==="textarea"?X("textarea","fc-input fc-textarea"):X("input","fc-input");return t instanceof HTMLInputElement&&(t.type=e),t.value=yt(s.value),t.disabled=s.readonly,t.required=!!s.field.required,t.ariaLabel=s.field.label,t.placeholder=s.field.placeholder||"请输入"+s.field.label,s.field.maxLength!==void 0&&(t.maxLength=s.field.maxLength),{element:t,read:()=>t.value,focus:()=>t.focus(),validate:()=>e==="url"&&t.value&&!$i(t.value)?"请输入 http 或 https 链接":t.checkValidity()?void 0:"请填写有效的"+s.field.label}}function Vn(s){const e=X("div","fc-link-value"),t=$i(s.value);if(!t)return St(s);const i=X("a","fc-link",yt(s.value));return i.href=t,i.target="_blank",i.rel="noopener noreferrer",i.onclick=n=>n.stopPropagation(),e.append(X("span","fc-link-icon","↗"),i),e}function zn(s){let e=s.value===!0;const t=X("div","fc-switch-field"),i=X("button","fc-switch");i.type="button",i.setAttribute("role","switch"),i.ariaLabel=s.field.label,i.disabled=s.readonly;const n=X("span"),o=()=>{i.setAttribute("aria-checked",String(e)),n.textContent=e?"是":"否"};return i.onclick=()=>{s.readonly||(e=!e,o(),Ft(t))},t.append(i,n),o(),{element:t,read:()=>e,focus:()=>i.focus()}}function Ia(s){return zn({...s,readonly:!0}).element}function Wn(s){var C,h,f;let e=Array.isArray(s.value)?structuredClone(s.value):[];const t=X("div","fc-attachments"),i=X("div","fc-file-list"),n=X("label","fc-upload-zone","+ 上传附件"),o=X("input");o.type="file",o.multiple=!0,o.ariaLabel="上传"+s.field.label,o.accept=((C=s.field.attachmentOptions)==null?void 0:C.accept)||"",o.disabled=s.readonly||!((h=s.services)!=null&&h.upload);const a=X("p","fc-error");a.setAttribute("role","status");const l=X("button","fc-retry","重试上传");l.type="button",l.hidden=!0;let r=[],c=!1,d=!1,u;const p=()=>{i.replaceChildren(),e.forEach((m,b)=>{const R=X("div","fc-file-row"),k=$i(m.url),y=k?X("a","fc-link",m.name):X("span","",m.name);if(y.tagName==="A"){const M=y;M.href=k,M.target="_blank",M.rel="noopener noreferrer"}if(R.append(X("span","fc-file-icon","▤"),y),m.size!=null&&R.append(X("small","fc-file-size",Math.ceil(m.size/1024)+" KB")),!s.readonly){const M=X("button","fc-file-remove","×");M.type="button",M.disabled=c,M.ariaLabel="移除"+m.name,M.onclick=()=>{e.splice(b,1),p(),Ft(t)},R.append(M)}i.append(R)}),e.length||i.append(X("span","fc-empty","暂无附件"))},g=async()=>{var R;if(!((R=s.services)!=null&&R.upload)||s.readonly||c||!r.length)return;const m=s.field.attachmentOptions;if(m!=null&&m.maxFiles&&e.length+r.length>m.maxFiles){a.textContent="最多上传 "+m.maxFiles+" 个文件";return}if(m!=null&&m.maxBytes&&r.some(k=>k.size>m.maxBytes)){a.textContent="文件大小超过限制";return}const b=((m==null?void 0:m.accept)||"").split(",").map(k=>k.trim().toLowerCase()).filter(Boolean);if(b.length&&r.some(k=>!b.some(y=>y.startsWith(".")?k.name.toLowerCase().endsWith(y):y.endsWith("/*")?k.type.toLowerCase().startsWith(y.slice(0,-1)):k.type.toLowerCase()===y))){a.textContent="文件类型不符合要求";return}u=new AbortController,c=!0,o.disabled=!0,l.hidden=!0,a.textContent="上传中…",t.setAttribute("aria-busy","true"),p();try{const k=await s.services.upload(s.field,r,u.signal);if(d)return;if(k.length!==r.length||k.some(y=>!y.id||!y.name))throw new Error("Invalid file references");e=[...e,...k],r=[],a.textContent="",o.value=""}catch{d||(a.textContent="上传失败,已保留原有附件",l.hidden=!1)}finally{d||(c=!1,o.disabled=!1,t.setAttribute("aria-busy","false"),p(),r.length||Ft(t))}};return o.onchange=m=>{m.stopPropagation(),r=Array.from(o.files||[]),g()},l.onclick=()=>void g(),n.append(o),t.append(i),s.readonly||(t.append(n),(f=s.services)!=null&&f.upload||t.append(X("p","fc-service-note","上传服务未接入"))),t.append(a,l),p(),{element:t,read:()=>structuredClone(e),focus:()=>o.focus(),validate:()=>c?"请等待上传完成":r.length?"请完成或重新选择上传文件":s.field.required&&!e.length?"请上传附件":void 0,destroy:()=>{d=!0,u==null||u.abort()}}}function Un(s){if(s&&typeof s=="object"&&!Array.isArray(s)){const e=s;return{selected:Array.isArray(e.selected)?[...e.selected]:[],counts:{...e.counts},total:e.total}}return{selected:[],counts:{}}}function _n(s,e){var g;let t=Un(s.value),i=[...t.selected];const n=e==="attitude"?[{id:"like",label:"赞同"}]:et(s.field),o=X("div","fc-vote"),a=X("div","fc-vote-list"),l=X("p","fc-error");l.setAttribute("role","status");const r=X("button","fc-vote-submit","提交投票");r.type="button";let c=!1,d=!1,u;const p=()=>{var h,f;a.replaceChildren();const C=Math.max(1,...Object.values(t.counts));for(const m of n){const b=X("button","fc-vote-option");b.type="button",b.disabled=s.readonly||c||!((h=s.services)!=null&&h.vote)||!!m.disabled,b.classList.toggle("selected",i.includes(m.id)),b.setAttribute("aria-pressed",String(i.includes(m.id)));const R=X("span","fc-vote-bar");R.style.width=(t.counts[m.id]||0)/C*100+"%",b.append(R,X("span","",(e==="attitude"?"♡ ":"")+m.label),X("strong","",String(t.counts[m.id]||0))),b.onclick=()=>{i=i.includes(m.id)?i.filter(k=>k!==m.id):e==="multi"?[...i,m.id]:[m.id],p()},a.append(b)}n.length||a.append(X("p","fc-empty","暂无投票选项")),r.disabled=c||!((f=s.services)!=null&&f.vote)||!n.length,r.textContent=c?"提交中…":"提交投票"};return r.onclick=async()=>{var C;if(!(c||s.readonly||!((C=s.services)!=null&&C.vote))){c=!0,l.textContent="",u=new AbortController,o.setAttribute("aria-busy","true"),p();try{const h=await s.services.vote(s.field,s.item,i,u.signal);if(d)return;t=Un(h),i=[...t.selected]}catch{d||(l.textContent="投票失败,请重试")}finally{d||(c=!1,o.setAttribute("aria-busy","false"),p(),l.textContent||Ft(o))}}},o.append(a),s.readonly||(o.append(r),(g=s.services)!=null&&g.vote||o.append(X("p","fc-service-note","投票服务未接入"))),o.append(l),p(),{element:o,read:()=>structuredClone(t),validate:()=>c?"请等待投票完成":void 0,destroy:()=>{d=!0,u==null||u.abort()}}}function La(s){const e=X("div","fc-signals"),t=Array.isArray(s.value)?s.value:[s.value];for(const i of t.filter(n=>n!=null&&n!=="")){const n=typeof i=="object"?i:{status:i},o=n.status??n.value,a=o===!0||o==="passed"||o==="success",l=X("span","fc-signal "+(a?"is-success":"is-pending"),(a?"● ":"○ ")+yt(n.label||n.name||(a?"已满足":o===!1?"未满足":o||"等待信号")));e.append(l)}return e.children.length||e.append(X("span","fc-empty","等待外部信号")),e}function Aa(s){const e=s.value&&typeof s.value=="object"?s.value.display??s.value.value:s.value;return St({...s,value:e!=null&&typeof e!="object"?e:""})}function Da(s,e){const t=X("div","fc-readonly");return t.append(e(s),X("small","fc-service-note","由系统更新 · 只读")),{element:t,read:()=>s.value}}function Fa(s){const e=s.value&&typeof s.value=="object"?s.value:{},t=X("div","fc-location"),n=[["address","地址","text"],["longitude","经度","number"],["latitude","纬度","number"]].map(([a,l,r])=>{const c=X("label","fc-location-part",l),d=X("input","fc-input");return d.type=r,d.value=yt(e[a]),d.disabled=s.readonly,d.ariaLabel=l,d.placeholder=l,r==="number"&&(d.step="any",d.min=a==="longitude"?"-180":"-90",d.max=a==="longitude"?"180":"90"),c.append(d),t.append(c),d}),o=()=>n.every(a=>!a.value)?null:{address:n[0].value,longitude:n[1].value?Number(n[1].value):null,latitude:n[2].value?Number(n[2].value):null};return{element:t,read:o,focus:()=>n[0].focus(),validate:()=>{if(!o())return s.field.required?"请填写位置":void 0;if(n.slice(1).some(a=>a.value===""||!a.checkValidity()))return"请填写有效的经纬度"}}}function Pa(s){const e=s.value;return St({...s,value:e&&typeof e=="object"?yt(e.address)||[e.longitude,e.latitude].filter(t=>t!=null).join(", "):""})}function qn(s,e){const t=X("div","fc-composite"),i=X("div","fc-composite-rows"),n=X("button","fc-composite-add","+ 添加一组");n.type="button";const o=s.field.compositeFields||[];let a=(Array.isArray(s.value)?s.value:[]).map(d=>({value:structuredClone(d),editors:[]}));const l=d=>({...d.value,...Object.fromEntries(d.editors.map(({field:u,editor:p})=>[u.key,p.read()]))}),r=()=>a.forEach(d=>d.editors.forEach(({editor:u})=>{var p;return(p=u.destroy)==null?void 0:p.call(u)})),c=()=>{a.forEach(d=>{d.value=l(d)}),r(),i.replaceChildren(),a.forEach((d,u)=>{const p=X("fieldset","fc-composite-row");if(p.append(X("legend","","第 "+(u+1)+" 组")),d.editors=o.map(g=>{const C=e(g),h=C.createEditor({...s,field:g,value:d.value[g.key],readonly:s.readonly||g.editable===!1||!!C.readonly,onDeactivate:void 0,focusBoundary:void 0,onSelectedOptions:m=>{var b;(b=s.services)!=null&&b.searchOptions&&(g.choices=[...new Map([...et(g),...m].map(R=>[R.id,R])).values()])}}),f=X("div","fc-composite-field");return f.append(X("label","",g.label+(g.required?" *":"")),h.element),p.append(f),{field:g,editor:h}}),!s.readonly){const g=X("button","fc-composite-remove","删除此组");g.type="button",g.onclick=()=>{d.editors.forEach(({editor:C})=>{var h;return(h=C.destroy)==null?void 0:h.call(C)}),a.splice(u,1),c(),Ft(t)},p.append(g)}i.append(p)}),n.disabled=s.readonly||!o.length||a.length>=(s.field.maxRows||100),a.length||i.append(X("p","fc-empty","暂无记录"))};return n.onclick=()=>{a.push({value:{},editors:[]}),c(),Ft(t)},t.append(i),s.readonly||t.append(n),o.length||t.append(X("p","fc-service-note","请配置复合子字段")),c(),{element:t,read:()=>a.map(l),validate:()=>{var d;if(s.field.required&&!a.length)return"请至少添加一组";for(const[u,p]of a.entries())for(const{field:g,editor:C}of p.editors){const h=(d=C.validate)==null?void 0:d.call(C);if(h)return"第 "+(u+1)+" 组 · "+g.label+":"+h}},destroy:r}}const Kn=[{id:"todo",label:"待开始",color:"#e9e7fa"},{id:"doing",label:"进行中",color:"#d9eeec"},{id:"done",label:"已完成",color:"#dcf0d5"}],jn=[{id:"u1",label:"林晓",description:"产品设计"},{id:"u2",label:"陈舟",description:"研发团队"}],$a=[{id:"REQ-001",label:"优化新建流程",description:"REQ-001 · 进行中"},{id:"REQ-002",label:"完善字段体验",description:"REQ-002 · 待开始"}];function Ga(s){const e=(n,o,a,l,r,c,d,u)=>({id:n,label:o,group:a,glyph:l,description:r,render:c,createEditor:d,example:u}),t=[e("textarea","多行文本","文本","≡","保留换行的纯文本,支持长度限制",St,n=>Qt(n,"textarea"),{value:`记录背景与目标
109
- 补充说明和验收条件`}),e("radio","单选按钮","选择","◉","平铺选项,一次选择一项",jt,n=>Dt(!1,n,"radio"),{value:"doing",field:{choices:Kn}}),e("cascadeSingle","级联单选","选择","⑂","逐级浏览分类,选择完整路径",On,n=>Bn(!1,n)),e("cascadeMulti","级联多选","选择","⑂","逐级浏览并选择多条路径",On,n=>Bn(!0,n)),...[["person","单选人员",!1],["multiPerson","多选人员",!0]].map(([n,o,a])=>e(n,o,"人员","♙","按姓名搜索,以稳定人员 ID 保存",l=>jt(l,"person"),l=>Dt(a,l,"person"),{value:a?["u1","u2"]:"u1",field:{choices:jn}})),...[["date","日期",!1],["dateRange","日期区间",!0]].map(([n,o,a])=>{const l=r=>({...r,field:{...r.field,dateOptions:{showTime:!1,showRange:a,...r.field.dateOptions}}});return e(n,o,"日期","▦",a?"连续选择起止日期,校验完整范围":"日历选择和直接输入,支持清空",r=>$n(l(r)),r=>Gn(l(r)),{value:a?["2026-09-24","2026-09-30"]:"2026-09-24"})}),e("url","URL 链接","其他","↗","填写网址并在新窗口安全打开",Vn,n=>Qt(n,"url"),{value:"https://example.com/project"}),e("cloudDocument","关联云文档","其他","▤","添加云文档链接,点击打开原文档",Vn,n=>Qt(n,"url"),{value:"https://example.com/docs/design"}),e("email","邮箱","其他","@","邮箱输入与格式校验",St,n=>Qt(n,"email"),{value:"design@example.com"}),e("phone","电话","其他","☎","支持国家区号的电话输入",St,n=>Qt(n,"tel"),{value:"+86 138 0000 0000"}),e("switch","开关","其他","◐","以是或否记录布尔状态",Ia,zn,{value:!0}),e("attachment","附件","其他","⌑","文件列表、上传与删除,支持上传失败重试",n=>Wn({...n,readonly:!0}).element,Wn,{value:[{id:"sample-file",name:"设计说明.pdf",size:24576}]}),e("location","地理位置","其他","⌖","填写地址和经纬度,校验坐标边界",Pa,Fa,{value:{address:"上海",longitude:121.47,latitude:31.23}}),...[["relation","单选关联工作项",!1],["multiRelation","多选关联工作项",!0]].map(([n,o,a])=>e(n,o,"关联工作项","↗","按名称或编号搜索工作项,点击名称打开详情",l=>jt(l,"relation"),l=>Dt(a,l,"relation"),{value:a?["REQ-001","REQ-002"]:"REQ-001",field:{choices:$a}})),...[["attitudeVote","表态投票","attitude"],["singleVote","单选投票","single"],["multiVote","多选投票","multi"]].map(([n,o,a])=>e(n,o,"投票","♡","选择并提交投票,结果以宿主服务回读为准",l=>_n({...l,readonly:!0},a).element,l=>_n(l,a),{value:{selected:[],counts:{like:12,todo:2,doing:8,done:3}},field:{choices:Kn}}))];for(const[n,o]of[["externalSignal","系统外信号"],["externalMultiSignal","多值系统外信号"],["formula","公式计算"],["aggregate","聚合计算"],["ai","AI 字段"],["system","系统字段"]]){const a=n.startsWith("external"),l=a?La:Aa;t.push({...e(n,o,"系统",a?"◌":"ƒ",a?"由外部系统更新,系统内只读":"展示服务端计算结果,不可手工覆盖",l,r=>Da(r,l),{value:a?n==="externalSignal"?!0:[{name:"CI 检查",status:!0},{name:"评审",status:!1}]:n==="ai"?"已生成的内容摘要":128}),readonly:!0})}for(const[n,o]of[["composite","复合字段"],["multiPersonComposite","多人复合字段"]]){const a=[...n==="multiPersonComposite"?[{key:"owner",label:"填写人",kind:"person",required:!0,choices:jn}]:[],{key:"name",label:"事项",kind:"text",required:!0},{key:"effort",label:"工作量",kind:"number"}];t.push(e(n,o,"其他","▦","可重复字段组,复用已注册子控件并逐组校验",l=>l.surface==="cell"?St({...l,value:Array.isArray(l.value)&&l.value.length?l.value.length+" 组记录":""}):qn({...l,readonly:!0},s).element,l=>qn(l,s),{value:[{name:"交互走查",effort:2,owner:"u1"}],field:{compositeFields:a}}))}const i=[{id:"product",label:"产品",children:[{id:"design",label:"设计",children:[{id:"interaction",label:"交互设计"},{id:"visual",label:"视觉设计"}]},{id:"research",label:"用户研究"}]},{id:"engineering",label:"研发",children:[{id:"web",label:"前端"},{id:"server",label:"后端"}]}];return t.filter(n=>n.id.startsWith("cascade")).forEach(n=>n.example={value:n.id==="cascadeMulti"?[["product","design","interaction"]]:["product","design","interaction"],field:{choices:i}}),t}function Ha(s,e,t){if(e.readonly||s.readonly)return t;const i=document.createElement("div");i.className="fc-focus-editor",i.dataset.expanded="true",i.tabIndex=-1;const n=document.createElement("div");n.className="fc-focus-body",n.append(t.element);const o=document.createElement("div");o.className="fc-focus-trigger",o.tabIndex=0,o.setAttribute("role","button"),o.ariaLabel="编辑"+e.field.label,o.setAttribute("aria-expanded","true"),o.hidden=!0;const a=document.createElement("span");a.className="fc-error fc-focus-error",a.setAttribute("role","status"),i.append(n,o,a);const l=i.ownerDocument,r=e.focusBoundary||i;let c=!1;const d=()=>{c||(n.hidden=!1,o.hidden=!0,i.dataset.expanded="true",o.setAttribute("aria-expanded","true"),a.textContent="",t.focus&&t.focus(),n.contains(l.activeElement)||(Array.from(n.querySelectorAll('input:not([type=hidden]):not(:disabled),textarea:not(:disabled),[contenteditable=true],button:not(:disabled),[tabindex="0"]')).find(m=>!m.closest("[hidden]"))||i).focus())},u=()=>{var b,R,k;if(c||!i.isConnected||i.dataset.expanded==="false")return;const f=(b=t.validate)==null?void 0:b.call(t),m=s.render({...e,readonly:!0,surface:"cell",value:f?e.value:t.read()});m.inert=!0,o.replaceChildren(m),a.textContent=f?"尚未保存:"+f:"",(R=t.deactivate)==null||R.call(t),i.dataset.expanded="false",n.hidden=!0,o.hidden=!1,o.setAttribute("aria-expanded","false"),(k=e.onDeactivate)==null||k.call(e)},p=f=>{if(f.relatedTarget instanceof Node&&r.contains(f.relatedTarget))return;const m=f.target;queueMicrotask(()=>{c||!i.isConnected||r.contains(l.activeElement)||(m&&!m.isConnected&&l.activeElement===l.body?i.focus():u())})},g=f=>{f.composedPath().includes(r)||u()},C=f=>{f.composedPath().includes(r)||u()},h=()=>{queueMicrotask(()=>{!c&&i.isConnected&&i.dataset.expanded==="true"&&(!l.activeElement||l.activeElement===l.body)&&i.focus()})};return o.onclick=f=>{f.stopPropagation(),d()},o.onkeydown=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.stopPropagation(),d())},r.addEventListener("focusout",p),i.addEventListener("click",h,!0),l.addEventListener("pointerdown",g,!0),l.addEventListener("focusin",C,!0),{...t,element:i,focus:d,destroy:()=>{var f;c||(c=!0,l.removeEventListener("pointerdown",g,!0),l.removeEventListener("focusin",C,!0),r.removeEventListener("focusout",p),i.removeEventListener("click",h,!0),(f=t.destroy)==null||f.call(t))}}}const Gi=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Hi=s=>s==null?"":String(s);function Oi(s){var t;const e=Gi("div",`fc-value fc-${s.surface}`);if(s.field.kind==="richText"||s.field.kind==="richtext"||s.field.kind==="longText"||s.field.control==="richText")e.innerHTML=Xt(s.value);else if(s.field.kind==="number"&&typeof s.value=="number"){const i=s.field.numberOptions;e.textContent=s.value.toLocaleString("zh-CN",{useGrouping:(i==null?void 0:i.thousandsSeparator)??!1,maximumFractionDigits:(i==null?void 0:i.decimals)??10})+((i==null?void 0:i.suffix)||"")}else e.textContent=Hi(s.value);return(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function Bi(s,e){const t=Gi("input","fc-input");if(t.type=s,t.value=Hi(e.value),t.disabled=e.readonly,t.required=!!e.field.required,t.ariaLabel=e.field.label,t.placeholder=`请输入${e.field.label}`,e.field.maxLength!==void 0&&(t.maxLength=e.field.maxLength),s==="number"){const i=e.field.numberOptions;t.step=String((i==null?void 0:i.step)??"any"),(i==null?void 0:i.min)!==void 0&&(t.min=String(i.min)),(i==null?void 0:i.max)!==void 0&&(t.max=String(i.max))}return{element:t,read:()=>s==="number"?t.value===""?null:Number(t.value):t.value,validate:()=>t.checkValidity()?void 0:t.validationMessage||"请填写有效值",focus:()=>t.focus()}}function Xn(s=[]){const e=new Map,t=a=>{if(!/^[A-Za-z][\w-]*$/.test(a.id))throw new Error("Invalid control id");if(e.has(a.id))throw new Error(`Control already registered: ${a.id}`);e.set(a.id,{...a,createEditor:l=>Ha(a,l,a.createEditor(l))})};[{id:"text",label:"单行文本",glyph:"T",description:"单行输入,支持清空和必填校验",render:Oi,createEditor:a=>Bi("text",a)},{id:"richText",label:"富文本",glyph:"¶",description:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",render:Oi,createEditor:Na},{id:"select",label:"单选",glyph:"◉",action:"select",description:"从字段配置中选择一个选项",render:jt,createEditor:a=>Dt(!1,a)},{id:"multiSelect",label:"多选",glyph:"☑",action:"select",description:"点击标签选择多项,保存为数组",render:jt,createEditor:a=>Dt(!0,a)},{id:"number",label:"数字",glyph:"#",description:"支持小数和负数,空值与零分别保存",render:Oi,createEditor:a=>Bi("number",a)},{id:"dateTime",label:"日期时间",glyph:"◷",description:"精简日历,可配置时间和日期范围",render:$n,createEditor:Gn},{id:"detail",label:"详情页查看",glyph:"↗",action:"view",description:"点击进入当前或关联工作项详情",render:a=>{const l=Gi("button","fc-detail-link","查看详情 ↗");return l.type="button",l.onclick=r=>{r.stopPropagation(),a.openDetail(Hi(a.value)||a.item.id)},l},createEditor:a=>Bi("text",{...a,field:{...a.field,label:"关联工作项 ID(留空查看当前项)"}})}].forEach(a=>t({group:a.id==="richText"||a.id==="text"?"文本":a.id.includes("Select")||a.id==="select"?"选择":a.id==="dateTime"?"日期":"其他",...a})),Ga(a=>o(a)).forEach(t),s.forEach(t);const n={title:"text",longText:"richText",status:"select",richtext:"richText",single_select:"select",multi_select:"multiSelect",user:"person",multi_user:"multiPerson",multi_person:"multiPerson",cascade_select:"cascadeSingle",cascade_single:"cascadeSingle",cascade_multi:"cascadeMulti",daterange:"dateRange",date_range:"dateRange",datetime:"dateTime",multi_relation:"multiRelation",attitude_vote:"attitudeVote",single_vote:"singleVote",multi_vote:"multiVote",vote:"attitudeVote",external_signal:"externalSignal",external_multi_signal:"externalMultiSignal",multi_person_composite:"multiPersonComposite",cloud_document:"cloudDocument"},o=a=>{const l=a.control||n[a.kind||"text"]||a.kind||"text",r=e.get(l);if(!r)throw new Error(`Unknown control: ${l}`);return r};return{register:t,list:()=>[...e.values()],resolve:o}}const Oa=[["name","选题概要"],["description","选题描述"],["vote","选题投票"],["showVotes","是否展示投票结果"],["status","状态"],["selectedTopic","确定入选"],["format","内容形式"],["approved","选题是否通过"],["category","主题分类"],["owner","当前负责人"],["space","所属空间"],["created","创建时间"],["creator","创建者"]],Ba={status:["入库","进入选题会","选题通过","废弃","已终止"],category:["产品相关","干货洞察","解决方案","客户案例"],format:["图文","视频","图文+视频"],approved:["是","待定","废弃"],showVotes:["是","否"],owner:["体验官"],creator:["体验官"],space:["内容制作全流程"]},Yn=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1}),Va="rowvia:work-items:v2",za=["上班族月入过万副业案例集","城市咖啡地图探店","咖啡师教你在家做出咖啡厅品质","咖啡因含量实测排行榜","咖啡器具入门避坑指南","智能设备不联网真相:离线后还能用吗?","扫地机器人避坑指南:3000元vs5000元差在哪?","智能门锁必看!这5个功能千万别花冤枉钱","智能音箱大对比:某爱/某猫精灵/某度真实使用30天"],Wa=["","特色独立咖啡馆推荐","器具和技巧分享","提神效果科学对比","新手该买什么设备","实测各类设备断网后的功能保留情况,避免被云端绑架","实测清扫能力、避障算法、噪音控制,告诉你钱该花在哪","揭秘过度营销的功能(如虹膜识别、人脸识别等),哪些真正实用",""],Ua=["7105330334","7105330319","7105330315","7105330312","7105330311","7105330309","7105330300","7105330281","7105330263"],hi=za.map((s,e)=>({id:Ua[e],name:s,description:Wa[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 Qn(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 _a(s=Va,e=hi){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 Jn={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"/>'},Ie=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Jn[s]||Jn.check}</svg>`,de=s=>String(s??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),ce=(s,e,t="",i="")=>`<button type="button" data-action="${s}" class="${i}" aria-label="${de(e)}">${t?Ie(t):""}${e?`<span>${de(e)}</span>`:""}</button>`;function qa(s){s={...s,fields:s.fields.map(w=>({...w}))},s.container.classList.add("rowvia-work-items");const e=Xn(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 x of w.fields)if(!a.has(x.field))throw new Error(`Unknown form field: ${x.field}`);const l=new AbortController;let r=!1;const c=s.persistence==="none"?{items:structuredClone(s.items),views:[],drafts:[],customFields:[]}:_a(s.storageKey,s.items),d=s.allowCustomFields===!1?[]:c.customFields;for(const w of d)s.fields.some(x=>x.key===w.key)||s.fields.push(w);const u=s.fields.map(w=>[w.key,w.label]),p=w=>s.fields.find(x=>x.key===w),g=Object.fromEntries(s.fields.filter(w=>w.options).map(w=>[w.key,w.options])),C=s.storageKey,h=(w,x=s.container)=>x.querySelector(`:scope ${w}`);for(const w of c.items)w.comments??(w.comments=[]),w.history??(w.history=[]),w.roles??(w.roles=[]),w.meetings??(w.meetings=[]);let f=s.initialView?structuredClone(s.initialView):Yn(),m="全部",b="",R=!1,k=0,y=null,M=null,P=null,D=null,j=null,W="基本信息",B=0,E=0,S="",$=[];s.container.innerHTML=`<section class="content">
110
- <div class="work-page"><section class="list-area"><div class="list-tabs" role="tablist">${["全部","最近浏览","我创建的","我参与的","我关注的","我收藏的"].map((w,x)=>`<button class="list-tab ${x===0?"active":""}" role="tab" aria-selected="${x===0}" data-tab="${w}">${w}</button>`).join("")}<div class="create-button">${ce("create","新建","plus","primary")}${ce("create-menu","","down","primary")}</div></div>
111
- <div class="toolbar">${ce("filter","筛选","filter")}${ce("sort","排序","sort")}${ce("group","分组","group")}${ce("color","设置颜色","color")}<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${ce("previous-match","","up")}${ce("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${ce("close-search","","close")}</div>${ce("search","查找","search")}<div class="right">${ce("reset","重置","","hidden")}${ce("controls","控件管理","edit")}${ce("saved-views","切换视图","down")}${ce("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 z(w,x){var L,H;if(!w)return'<span class="placeholder">暂无</span>';let T=x==="status"?w==="废弃"||w==="选题通过"?"green":w==="进入选题会"?"cyan":"":x==="category"?w==="干货洞察"?"teal":"green":x==="format"&&w==="图文"?"purple":"pink";const I=(H=(L=p(x))==null?void 0:L.colors)==null?void 0:H[w];return`<span class="tag ${T}" ${I?`style="background:${de(I)}"`:""}>${de(w)}</span>`}const q=w=>w?`<span class="person"><span class="avatar">体验官</span>${de(w)}</span>`:'<span class="placeholder">暂无</span>';function ee(w){if(w.node.group)return"";const x=w.data,T=w.colDef.field,I=document.createElement("div");I.className="rendered-cell";const L=p(T);if(L&&(L.control||!["title","status"].includes(L.kind||"text")))I.append(e.resolve(L).render(ht(L,x,"cell")));else if((L==null?void 0:L.kind)==="title"){const H=document.createElement("a");H.className="item-name",H.href=`#item/${x.id}`,H.textContent=x[T],H.title=x[T],H.addEventListener("click",F=>{F.preventDefault(),clearTimeout(E),F.detail===0?$e(x):F.detail===1&&(E=window.setTimeout(()=>$e(x),280))}),I.append(H);const O=document.createElement("button");O.className="inline-edit",O.innerHTML=Ie("pencil"),O.ariaLabel="编辑选题概要",O.onclick=F=>{F.stopPropagation(),ot(I,T,x,w.rowIndex)},(L==null?void 0:L.editable)!==!1&&I.append(O)}else(L==null?void 0:L.kind)==="status"?(I.innerHTML=`${z(x.status,T)}<span class="status-days">20 天</span>`,(L==null?void 0:L.editable)!==!1&&(I.onclick=H=>{H.stopPropagation(),ot(I,T,x,w.rowIndex)})):g[T]?(I.innerHTML=["creator","owner","space"].includes(T)?de(x[T]):z(x[T],T),(L==null?void 0:L.editable)!==!1&&(I.onclick=H=>{H.stopPropagation(),ot(I,T,x,w.rowIndex)})):(I.innerHTML=`<span class="cell-text">${de(x[T]||"暂无")}</span>`,x[T]||I.classList.add("placeholder"));if(L&&L.editable!==!1&&!e.resolve(L).readonly&&L.kind!=="title"){const H=document.createElement("button");H.className="inline-edit field-control",H.ariaLabel=`${L.kind==="status"?"流转":"编辑"}${L.label}`,H.innerHTML=Ie(L.kind==="status"?"transition":["select","multiSelect","person"].includes(L.kind||"")?"down":"pencil"),H.onclick=O=>{O.stopPropagation(),ot(I,T,x,w.rowIndex)},I.append(H)}return I.title=String(x[T]??""),I}function se(){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 x=document.createElement("div");return x.className="row-controls",x.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="展开详情">${Ie("expand")}</button>`,h("input",x).onclick=T=>T.stopPropagation(),h("input",x).onchange=T=>w.node.setSelected(T.target.checked),h("button",x).onclick=T=>{T.stopPropagation(),$e(w.data)},x}},...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:x=>w.required&&!String(x.newValue??"").trim()?!1:(x.data[w.key]=x.newValue,!0),comparator:w.options?(x,T)=>w.options.indexOf(x)-w.options.indexOf(T):void 0,sortable:!1,suppressMenu:!0,cellRenderer:ee,cellStyle:({data:x})=>{const T=x&&f.colors.find(I=>!!I.scope&&I.scope!=="row"&&I.field===w.key&&xe(x,I));return T?{backgroundColor:T.color}:{}},tooltipField:w.key,cellClass:w.kind==="title"?"name-cell":void 0,...w.column})),...$,{colId:"_add",hide:s.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}const V=Vi(h("#grid"),{columnDefs:se(),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 x=f.colors.find(T=>w&&(!T.scope||T.scope==="row")&&xe(w,T));return x?{backgroundColor:x.color}:{}},onCellValueChanged:w=>{w.data.history.push(`更新${w.colDef.headerName}:${w.newValue}`),U(),queueMicrotask(()=>{r||K()})},onSelectionChanged:()=>{ae(),V.api.refreshCells({force:!0})},onRowGroupOpened:()=>te(),localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"}});V.grid.getEventService().addEventListener("rowDragEnd",w=>{if(!w.overNode||w.overNode.group||w.node.id===w.overNode.id)return;const x=c.items.findIndex(L=>L.id===w.node.id),T=c.items.findIndex(L=>L.id===w.overNode.id);if(x<0||T<0)return;const[I]=c.items.splice(x,1);c.items.splice(T,0,I),f.sorts=[],U(),K()}),V.grid.getEventService().addEventListener("columnHeaderClicked",w=>{w.column.colId==="_add"&&Et(h('.ag-header-cell[data-colid="_add"]'),"_add",!1)});function U(){var w;if((w=s.onDataChange)==null||w.call(s,structuredClone(c.items)),s.persistence!=="none")try{localStorage.setItem(C,JSON.stringify(c))}catch{ve("浏览器存储不可用,本次修改仅在当前页面保留")}}function Z(){return c.items.filter(w=>(f.showTerminated||w.status!=="已终止")&&Qn(w,f.filters)&&(m!=="最近浏览"||w.viewed)&&(m!=="我关注的"||w.followed)&&(m!=="我收藏的"||w.starred)&&(m!=="我参与的"||w.owner===s.currentUser)&&(m!=="我创建的"||w.creator===s.currentUser)&&(!R||!b||w.name.toLowerCase().includes(b.toLowerCase())))}function K(){o==null||o(),V.api.setRowData(Z()),V.api.setSortModel(f.sorts),V.columnApi.setRowGroupColumns(f.groups),V.api.redrawRows(),mt();for(const[w,x]of[["filter",f.filters.length],["sort",f.sorts.length],["group",f.groups.length],["color",f.colors.length]]){const T=h(`[data-action="${w}"]`);T.classList.toggle("is-set",!!x);const I={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};h("span",T).textContent=I[w]+(x?` · ${x}`:"")}h('[data-action="reset"]').classList.toggle("hidden",!f.filters.length&&!f.sorts.length&&!f.groups.length&&!f.colors.length),ae(),J(),te()}function oe(w,x,T){var I;w[x]=T,w.history.push(`更新${((I=u.find(([L])=>L===x))==null?void 0:I[1])||x}:${String(T)}`),U(),K()}function ve(w){var T;(T=h(".toast"))==null||T.remove(),clearTimeout(B);const x=document.createElement("div");x.className="toast",x.setAttribute("role","status"),x.innerHTML=Ie("check")+de(w),s.container.append(x),B=window.setTimeout(()=>x.remove(),2500)}function he(w=!0){var x;w&&n&&!n()||(n=null,(x=i==null?void 0:i.destroy)==null||x.call(i),i=null,y==null||y.remove(),y=null,S="")}function Ee(w,x,T,I=460,L=""){he(),y=document.createElement("section"),y.className=`popup ${L}`,y.setAttribute("role","dialog"),y.ariaLabel=x||"列操作",y.style.width=`${I}px`,y.innerHTML=`${x?`<div class="popup-head"><span>${de(x)}</span>${ce("close-popup","","close")}</div>`:""}${T}`,s.container.append(y);const H=w.getBoundingClientRect();return y.style.left=`${Math.max(12,Math.min(H.left,innerWidth-I-16))}px`,y.style.top=`${Math.min(H.bottom+8,Math.max(12,innerHeight-y.offsetHeight-16))}px`,y}function Ve(w,x,T=""){return`<select ${T}>${w.map(([I,L])=>`<option value="${de(I)}" ${I===x?"selected":""}>${de(L)}</option>`).join("")}</select>`}function pi(w,x,T){const I=Ee(w,u.find(([H])=>H===x)[1],'<input class="value-search" placeholder="搜索" aria-label="搜索选项"><div class="value-options"></div>',240),L=(H="")=>{h(".value-options",I).innerHTML=[...g[x]||[]].filter(O=>O.includes(H)).map(O=>`<button class="menu-option" data-value="${de(O)}">${z(O,x)}<span class="spacer"></span>${(Array.isArray(T[x])?T[x].includes(O):T[x]===O)?"✓":""}</button>`).join("")+'<button class="menu-option" data-value="">清空</button>'};L(),h("input",I).oninput=H=>L(H.target.value),I.onclick=H=>{var F;const O=H.target.closest("[data-value]");if(O)if(H.stopPropagation(),((F=p(x))==null?void 0:F.kind)==="multiSelect"){const N=O.dataset.value,A=Array.isArray(T[x])?T[x]:[];oe(T,x,N?A.includes(N)?A.filter(G=>G!==N):[...A,N]:[]),L(h("input",I).value)}else oe(T,x,O.dataset.value),he()}}function ut(w,x,T={}){s.container.querySelectorAll(".field-picker").forEach(F=>F.remove());const I=document.createElement("div");I.className="field-picker",I.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(F=>`<button data-kind="${F}">${F}</button>`).join("")}</div><div class="field-options"></div>`,s.container.append(I);const L=w.getBoundingClientRect();I.style.left=`${Math.max(12,Math.min(L.left,innerWidth-410))}px`,I.style.top=`${Math.max(12,Math.min(L.bottom+4,innerHeight-340))}px`;let H="推荐";const O=(F="推荐",N="")=>{h(".field-options",I).innerHTML=u.filter(([A,G])=>{var _,ie,fe,le,ne,re;return(!T.available||T.available(A))&&G.includes(N)&&(F==="推荐"||F==="文本"&&["title","text","longText","richText"].includes(((_=p(A))==null?void 0:_.kind)||"text")||F==="选择"&&["status","select","multiSelect"].includes(((ie=p(A))==null?void 0:ie.kind)||"")||F==="人员"&&((fe=p(A))==null?void 0:fe.kind)==="person"||F==="时间"&&["date","dateTime"].includes(((le=p(A))==null?void 0:le.kind)||"")||F==="关系"&&((ne=p(A))==null?void 0:ne.kind)==="relation"||F==="其他"&&((re=p(A))==null?void 0:re.kind)==="vote")}).map(([A,G])=>`<button data-field="${de(A)}" ${T.onCreate?`data-insert="${de(A)}"`:""} class="menu-option">${Ie("table")}${de(G)}</button>`).join(""),T.onCreate&&h(".field-options",I).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${Ie("add")}添加字段</button>`),I.querySelectorAll("[data-kind]").forEach(A=>{A.classList.toggle("active",A.dataset.kind===F),A.setAttribute("aria-pressed",String(A.dataset.kind===F))})};O(),h("input",I).oninput=F=>O(H,F.target.value),I.onclick=F=>{var A;const N=F.target.closest("button");N&&(F.stopPropagation(),N.dataset.kind&&(H=N.dataset.kind,O(H,h("input",I).value)),N.dataset.field&&(I.remove(),x(N.dataset.field)),N.hasAttribute("data-create-field")&&(I.remove(),(A=T.onCreate)==null||A.call(T)))}}function xe(w,x){return!!x.field&&(!!x.value||["blank","notBlank"].includes(x.operator))&&Qn(w,[x])}function Y(w){const x=f.colors.map((A,G)=>{var ne;const _=(ne=p(A.field))==null?void 0:ne.label,ie=A.field?[["contains",g[A.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],fe=!A.field||["blank","notBlank"].includes(A.operator),le=g[A.field]?Ve([["","请选择目标值"],...g[A.field].map(re=>[re,re])],A.value,`data-rule-value="${G}" aria-label="目标值" ${fe?"disabled":""}`):`<input data-rule-value="${G}" aria-label="目标值" placeholder="请选择目标值" value="${de(A.value)}" ${fe?"disabled":""}>`;return`<div class="color-condition" data-color-row="${G}">
87
+ ${p?`<div class="rowvia-nf-banner">当前使用的不是最新流程模板(${H(o.templateVersion)} → ${H(o.latestTemplateVersion)})<button type="button" data-action="diff">查看差异</button></div>`:""}`;const f=t.querySelector('[data-action="search"]'),u=t.querySelector("[data-suggestions]"),h=()=>{if(!u)return;const g=f.value.trim().toLowerCase(),v=g?o.nodes.filter(m=>m.name.toLowerCase().includes(g)).slice(0,8):[];u.hidden=!l||v.length===0,u.innerHTML=v.map(m=>`<button type="button" data-node="${H(m.id)}">${H(m.name)}<em>${H(at[m.status].label)}</em></button>`).join("")};f.addEventListener("focus",()=>{l=!0,h()}),f.addEventListener("blur",()=>{l=!1,i.timeout(h,120)}),f.addEventListener("input",()=>{var g;a=f.value,h(),(g=e.onQuery)==null||g.call(e,a)}),u==null||u.addEventListener("click",g=>{var m;const v=g.target.closest("[data-node]");v&&(l=!1,u.hidden=!0,(m=e.onFocusNode)==null||m.call(e,v.dataset.node))}),a&&h()},d=c=>{var f,u;const p=c.target.closest("[data-action]");!p||!t.contains(p)||(p.dataset.action==="rules"&&((f=e.onOpenRules)==null||f.call(e)),p.dataset.action==="diff"&&((u=e.onOpenDiff)==null||u.call(e)))};return t.addEventListener("click",d),r(),{onInteraction:n.onInteraction,update(c,p){o=c,p!==void 0&&(a=p),r()},getQuery:()=>a,destroy(){t.removeEventListener("click",d),n.destroy(),i.destroy(),t.remove()}}}function on(s,e){const t=document.createElement("div");t.className="rowvia-nf-timeline",s.append(t);const i=xe(t,"node-timeline",e);let n=e.flow,o=e.selectedNodeId,a="timeline",l="all",r=null;const d=[{key:"all",label:"全部状态"},{key:"done",label:"已完成"},{key:"inProgress",label:"进行中"},{key:"pending",label:"未开始"},{key:"failed",label:"未通过"}],c=h=>[h.owner?"负责人 "+h.owner:"负责人待填",h.schedule?"排期 "+h.schedule:"排期待填",h.estimate?"估分 "+h.estimate:"估分待填",h.progress!==void 0?"进度 "+h.progress+"%":"",(h.tasks??[]).length?"任务 "+(h.tasks??[]).filter(v=>v.done).length+"/"+(h.tasks??[]).length:"",(h.form??[]).length?"表单 "+(h.form??[]).filter(v=>v.value).length+"/"+(h.form??[]).length:""].filter(Boolean).join(" · "),p=h=>{const g=at[h.status],v=r===h.id,m=v?'<div class="rowvia-nf-tl-detail"><p>'+H(c(h))+"</p>"+((h.events??[]).length?'<p class="rowvia-nf-tl-events">'+h.events.map(C=>(C.trigger==="arrive"?"到达:":"完成:")+H(C.text)).join(" · ")+"</p>":"")+'<button type="button" class="rowvia-nf-ghost" data-action="edit" data-node="'+H(h.id)+'">回到操作卡编辑</button></div>':"";return'<div class="rowvia-nf-tl-row'+(o===h.id?" is-selected":"")+(h.milestone?" is-milestone":"")+'" data-row="'+H(h.id)+'"><button type="button" class="rowvia-nf-tl-toggle" data-action="toggle" data-node="'+H(h.id)+'" aria-expanded="'+String(v)+'" aria-label="展开">'+(v?"▾":"▸")+'</button><span class="rowvia-nf-dot status-'+g.className+'" aria-hidden="true"></span><button type="button" class="rowvia-nf-tl-name" data-action="edit" data-node="'+H(h.id)+'">'+H(h.name)+(h.milestone?'<em title="里程碑">◆</em>':"")+'</button><span class="rowvia-nf-chip status-'+g.className+'">'+H(g.label)+'</span><span class="rowvia-nf-tl-cell">'+H(h.owner||"待填")+'</span><span class="rowvia-nf-tl-cell">'+H(h.schedule||(h.deadline?"截止 "+h.deadline:"待填"))+'</span><span class="rowvia-nf-tl-cell">'+H(h.estimate||"待填")+'</span><span class="rowvia-nf-tl-cell is-progress">'+(h.progress!==void 0?'<span class="rowvia-nf-progress"><i style="width:'+h.progress+'%"></i></span>'+h.progress+"%":"—")+"</span></div>"+m},f=()=>{const h=n.nodes.filter(v=>l==="all"||v.status===l).map(p).join(""),g="<span>节点</span><span>状态</span><span>负责人</span><span>排期</span><span>估分</span><span>进度</span>";t.innerHTML='<div class="rowvia-nf-tl-toolbar"><div class="rowvia-nf-tl-filters">'+d.map(v=>'<button type="button" class="'+(l===v.key?"is-active":"")+'" data-action="filter" data-filter="'+v.key+'">'+v.label+"</button>").join("")+'</div><span class="rowvia-nf-space"></span><div class="rowvia-nf-seg" role="tablist"><button type="button" role="tab" class="'+(a==="timeline"?"is-active":"")+'" data-action="view" data-view="timeline">节点时间线</button><button type="button" role="tab" class="'+(a==="schedule"?"is-active":"")+'" data-action="view" data-view="schedule">排期信息</button></div></div><div class="rowvia-nf-tl-head">'+g+"</div>"+(h||'<div class="rowvia-nf-empty">没有符合筛选条件的节点</div>')},u=h=>{var m;const g=h.target.closest("[data-action]");if(!g||!t.contains(g))return;const v=g.dataset.action;if(v==="filter")l=g.dataset.filter??"all",f();else if(v==="view")a=g.dataset.view??"timeline",f();else if(v==="toggle"){const C=g.dataset.node;r=r===C?null:C,f()}else if(v==="edit"){const C=g.dataset.node;(m=e.onSelectNode)==null||m.call(e,C)}};return t.addEventListener("click",u),f(),{onInteraction:i.onInteraction,update(h){const g=h.flow!==void 0;if(h.flow&&(n=h.flow),h.selectedNodeId!==void 0&&(o=h.selectedNodeId),h.onSelectNode&&(e.onSelectNode=h.onSelectNode),g)f();else for(const v of t.querySelectorAll("[data-row]"))v.classList.toggle("is-selected",v.dataset.row===o)},destroy(){t.removeEventListener("click",u),i.destroy(),t.remove()}}}const ea=["schedule","estimate","worklog","conclusion","opinion"];function ta(s){const e={};for(const t of s){const i=at[t.status].label;e[i]=(e[i]??0)+1}return Object.entries(e).map(([t,i])=>t+" "+i).join(" · ")}function ia(s,e){let t=e.flow,i=e.selectedNodeId??"",n="",o=!1;const a=E=>{var x,k;return((x=E.nodes.find($=>$.status==="inProgress"))==null?void 0:x.id)??((k=E.nodes[0])==null?void 0:k.id)??""};i||(i=a(t));const l=document.createElement("section");if(l.className="rowvia-nf",e.title){const E=document.createElement("header");E.className="rowvia-nf-title",E.innerHTML="<strong>"+H(e.title)+"</strong>",l.append(E)}const r=document.createElement("div");r.className="rowvia-nf-body",r.innerHTML='<div data-region="context"></div><div data-region="canvas"></div><div data-region="card"></div><div data-region="timeline"></div><aside class="rowvia-nf-rules" data-region="rules" hidden></aside>',l.append(r),s.append(l);const d=xe(l,"node-flow",e),c=E=>r.querySelector('[data-region="'+E+'"]'),p=E=>t.nodes.find(x=>x.id===E)??null,f=sn(c("context"),{flow:t,query:n,onQuery:E=>{n=E,u.update({query:n})},onFocusNode:E=>C(E,!0),onOpenRules:()=>T(),onOpenDiff:()=>{var E;return(E=e.onAction)==null?void 0:E.call(e,"open-template-diff",i)}}),u=en(c("canvas"),{flow:t,selectedNodeId:i,query:n,onSelectNode:E=>C(E)}),h=on(c("timeline"),{flow:t,selectedNodeId:i,onSelectNode:E=>C(E,!0)}),g=c("rules"),v=tn(c("card"),{node:p(i),readonly:e.readonly,onComplete:(E,x)=>{var k;return(k=e.onComplete)==null?void 0:k.call(e,E,x)},onAction:(E,x)=>S(E,x),onFieldChange:(E,x,k)=>y(E,x,k),onFormChange:(E,x,k)=>R(E,x,k),onTaskToggle:(E,x,k)=>M(E,x,k)});function m(){v.update(p(i),{readonly:e.readonly})}function C(E,x=!1){var k;p(E)&&(i=E,u.update({selectedNodeId:E}),h.update({selectedNodeId:E}),m(),x&&u.focusNode(E),(k=e.onSelectNode)==null||k.call(e,E))}function S(E,x){var k;(E==="complete"||E==="rollback"||E==="resubmit")&&b(x,{status:E==="complete"?"done":"inProgress"}),(k=e.onAction)==null||k.call(e,E,x)}function b(E,x){t={...t,nodes:t.nodes.map(k=>k.id===E?{...k,...x}:k)},u.update({flow:t}),h.update({flow:t}),f.update(t,n),m()}function y(E,x,k){var q;const $=p(E);$&&(x==="conclusion"?b(E,{conclusion:k}):x==="opinion"?b(E,{opinion:k}):ea.includes(x)?b(E,{[x]:k}):b(E,{fields:($.fields??[]).map(F=>F.id===x?{...F,value:k}:F)}),(q=e.onFieldChange)==null||q.call(e,E,x,k))}function R(E,x,k){var q;const $=p(E);$&&b(E,{form:($.form??[]).map(F=>F.id===x?{...F,value:k}:F)}),(q=e.onFormChange)==null||q.call(e,E,x,k)}function M(E,x,k){var q;const $=p(E);$&&b(E,{tasks:($.tasks??[]).map(F=>F.id===x?{...F,done:k}:F)}),(q=e.onTaskToggle)==null||q.call(e,E,x,k)}function T(){var k;if(!g.hidden){g.hidden=!0;return}const E=Array.from(new Set(t.nodes.map($=>$.completionMode).filter(Boolean))),x=t.nodes.flatMap($=>$.events??[]);g.innerHTML='<div class="rowvia-nf-rules-head"><strong>流程规则(只读)</strong><button type="button" class="rowvia-nf-ghost" data-action="close-rules">关闭</button></div><dl><dt>流程类型</dt><dd>'+H(t.name)+"</dd><dt>完成方式</dt><dd>"+(E.length?E.map($=>H(String($))).join("、"):"未配置")+"</dd><dt>状态计算规则</dt><dd>"+((k=t.statusRules)!=null&&k.length?t.statusRules.map($=>H($)).join("<br>"):"未命中规则时按节点流转事件配置显示")+"</dd><dt>节点事件</dt><dd>"+(x.length?x.slice(0,6).map($=>($.trigger==="arrive"?"到达:":"完成:")+H($.text)).join("<br>"):"无")+"</dd><dt>节点状态分布</dt><dd>"+H(ta(t.nodes))+"</dd></dl>",g.hidden=!1}const W=E=>{E.target.closest('[data-action="close-rules"]')&&(g.hidden=!0)};return g.addEventListener("click",W),{onInteraction:d.onInteraction,selectNode(E){C(E,!0)},getSelectedNode:()=>p(i),setFlow(E){t=E,p(i)||(i=a(t)),f.update(t,n),u.update({flow:t,selectedNodeId:i,query:n}),h.update({flow:t,selectedNodeId:i}),m(),g.hidden=!0},updateNode(E,x){b(E,x)},focusNode(E){C(E,!0)},destroy(){o||(o=!0,g.removeEventListener("click",W),f.destroy(),u.destroy(),v.destroy(),h.destroy(),d.destroy(),l.remove())}}}const na=(s,e,t={})=>({id:s,name:e,...t});function Te(s){return{groupId:"g1",completionMode:"and",...s}}function sa(){const s=(t,i,n)=>Te({id:t,name:i,status:"pending",groupId:"g4",owner:n,ownerSource:"来源:角色联动",schedule:"09-02 ~ 09-06",estimate:"2d"}),e=[Te({id:"n-start",name:"开始",status:"done",owner:"系统",ownerSource:"来源:自动创建",schedule:"08-11",estimate:"0d",conclusion:"通过",events:[{trigger:"arrive",text:"需求状态 → 选题"}]}),Te({id:"n-meeting",name:"选题会",status:"inProgress",owner:"林小满",ownerSource:"来源:自行添加",schedule:"08-12 ~ 08-14",estimate:"3d",worklog:"1.5d",progress:40,progressMode:"按排期自动计算",conclusionOptions:["通过","不通过","有条件通过"],form:[{id:"f-entry",label:"选题入围",required:!0,placeholder:"请填写选题入围(至少五个主题)"}],tasks:[na("t-1","请填写选题入围",{blocking:!0,deliverable:"选题清单",owner:"林小满",estimate:"1d",schedule:"08-12"})],fields:[{id:"cf-risk",label:"节点风险",value:"中风险",group:"custom",source:"节点字段 · 单选"}],events:[{trigger:"arrive",text:"需求状态 → 选题"},{trigger:"complete",text:"「选题状态」字段 → 已定稿"}],buttons:[{id:"pass",label:"通过评审",variant:"primary",roles:["节点负责人","管理员"],hint:"数据赋值:整体完成结论 → 已通过"},{id:"reject",label:"不通过",variant:"warning",placement:"more"}],actionRoles:["节点负责人","管理员"],deleteRoles:["管理员"]}),Te({id:"n-topic",name:"确定选题",status:"pending",groupId:"g1",owner:"周野",schedule:"08-15 ~ 08-16",estimate:"2d",progress:0,progressMode:"手动填写",predecessors:["选题会"]}),Te({id:"n-ads",name:"广告植入",status:"pending",owner:"商务组",schedule:"08-17",estimate:"1d",predecessors:["确定选题"]}),Te({id:"n-script",name:"脚本制作",status:"pending",groupId:"g2",owner:"周野",schedule:"08-18 ~ 08-20",estimate:"3d"}),Te({id:"n-review",name:"脚本评审",status:"pending",groupId:"g2",completionMode:"or",owner:"内容总监",schedule:"08-21",estimate:"1d",conclusionOptions:["通过","不通过"],events:[{trigger:"complete",text:"「脚本状态」字段 → 已评审"}]}),Te({id:"n-plan",name:"制定计划表",status:"pending",groupId:"g3",owner:"制片人",schedule:"08-22 ~ 08-23",estimate:"2d"}),s("n-shoot","拍摄","导演组"),s("n-edit","剪辑","剪辑师"),s("n-art","美术","美术组"),s("n-audio","收音","录音师"),s("n-dit","DIT","DIT"),s("n-motion","动效","动效师"),s("n-color","调色","调色师"),s("n-mix","混音","混音师"),s("n-cover","封面","设计师"),Te({id:"n-final",name:"成片",status:"pending",groupId:"g5",milestone:!0,deadline:"09-08",owner:"制片人",schedule:"09-08",estimate:"0d",predecessors:["全部并行节点"]}),Te({id:"n-final-review",name:"成片评审会",status:"pending",groupId:"g5",completionMode:"or",owner:"内容总监",schedule:"09-09",estimate:"1d",conclusionOptions:["通过","不通过"],form:[{id:"f-pass",label:"成片评审是否通过",required:!0,type:"select",options:["是","否"]},{id:"f-publish",label:"预计发布时间",required:!0,type:"date"}],gates:[{id:"g-conclusion",label:"自定义条件:整体结论 = 通过",met:!1,fixLabel:"查看规则",detail:"完成流转条件 · 校验当前工作项",viewLink:"gates"},{id:"g-linked",label:"关联缺陷全部关闭",met:!1,fixLabel:"查看 3 条",detail:"完成流转条件 · 校验关联工作项",viewLink:"gates"}],events:[{trigger:"complete",text:"需求状态 → 待发布"}]}),Te({id:"n-publish",name:"发布",status:"pending",groupId:"g5",owner:"运营",schedule:"09-10",estimate:"1d"}),Te({id:"n-monitor",name:"数据监控",status:"pending",groupId:"g6",completionMode:"auto",owner:"数据组",schedule:"09-11 ~ 09-17",estimate:"5d",progress:0,progressMode:"同步自计算字段",delayed:!1}),Te({id:"n-retro",name:"项目复盘",status:"pending",groupId:"g6",owner:"制片人",schedule:"09-18",estimate:"1d",delayed:!0,info:"09-18"}),Te({id:"n-end",name:"结束",status:"pending",groupId:"g6",owner:"系统",estimate:"0d"})];for(const t of e)t.info||(t.info=t.schedule?t.schedule.split(" ~ ")[0]:"");return{id:"video",name:"视频流程",templateVersion:"v3",latestTemplateVersion:"v4",infoField:{label:"排期",position:"right"},statusRules:["整体结论 = 未通过 → 节点状态显示「未通过」","里程碑截止时间早于今天 → 节点状态显示「延期」"],groups:[{id:"g1",name:"前期策划"},{id:"g2",name:"脚本"},{id:"g3",name:"排期"},{id:"g4",name:"制作",layout:"parallel"},{id:"g5",name:"交付"},{id:"g6",name:"复盘"}],nodes:e}}const Me=s=>Date.parse(`${s}T00:00:00Z`)/864e5,Fe=s=>new Date(s*864e5).toISOString().slice(0,10),an=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Me(s))&&Fe(Me(s))===s,Jt=s=>!!s.start&&!!s.end;function ei(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&&(!an(i.start)||!an(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function oa(s,e=!1){const t=[];return s.filter(Jt).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<Me(i.start));return n<0&&(n=t.length),t[n]=Me(i.end),{item:i,lane:n}})}function rn(s){let e=0,t=0;for(const i of s)Jt(i)&&e++,t+=i.estimate;return{scheduled:e,unscheduled:s.length-e,estimate:t}}const ln=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function aa(s,e){const{people:t,items:i,today:n,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:f,children:u,loose:h,colorFirst:g,from:v,days:m,rangeStart:C,rangeEnd:S}=e,b=D=>s.querySelector(D),y=b(".ps-rows"),R=()=>[22,43,64,86,120][p],M=()=>i.filter(D=>(!l||D.name.includes(l))&&(!r||D.status===r)&&(u||!D.parentId)),T=R(),W=m*T;b(".ps-table").style.width=`${W+200}px`;const E=`${C.slice(0,4)}年 第${Number(C.slice(5,7))}-${Number(S.slice(5,7))}月`;b(".ps-date-label").textContent=E,b('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,b(".ps-zoom").value=String(p);const x=b(".ps-weeks");x.replaceChildren();for(let D=0;D<m;D+=7){const z=document.createElement("span");z.style.width=`${Math.min(7,m-D)*T}px`,z.textContent=`${Fe(v+D).slice(5).replace("-","/")}~${Fe(v+D+6).slice(5).replace("-","/")}`,x.append(z)}y.replaceChildren();const k=M(),$=new Map;for(const D of k){const z=$.get(D.personId);z?z.push(D):$.set(D.personId,[D])}const q=new Map(t.map(D=>[D.id,rn($.get(D.id)??[])])),F=t.filter(D=>o.has(D.id)&&(!a||q.get(D.id).scheduled>0));d&&F.sort((D,z)=>{const U=q.get(D.id),K=q.get(z.id);return(d==="estimate"?U.estimate-K.estimate:U.scheduled-K.scheduled)*(c?-1:1)});const G=document.createElement("div");for(let D=0;D<m;D++){const z=new Date((v+D)*864e5).getUTCDay();if(z!==0&&z!==6)continue;const U=document.createElement("i");U.className="ps-weekend",U.style.left=`${D*T}px`,U.style.width=`${T}px`,G.append(U)}for(const D of F){const z=$.get(D.id)??[],U=q.get(D.id),K=oa(z,f),Z=Math.max(0,...K.map(A=>A.lane)),ie=Math.max(h?154:126,60+(Z+1)*(h?48:36)),pe=document.createElement("div");pe.className="ps-person-row",pe.style.height=`${ie}px`,pe.dataset.person=D.id;const J=document.createElement("div");J.className="ps-person",J.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${H(D.name)}</strong></div><div>已排期项 <b>${U.scheduled}</b></div><div>总估分 <b>${U.estimate.toFixed(2)}</b></div><div>未排期·${U.unscheduled}<button data-action="unplanned" data-person="${H(D.id)}">查看</button></div>`;const ce=J.querySelector(".ps-avatar");ce.textContent=D.name.slice(-2),ce.style.background=D.color||ln[t.indexOf(D)%ln.length];const fe=document.createElement("div");fe.className="ps-timeline",fe.style.width=`${W}px`,fe.style.setProperty("--day",`${T}px`);for(const A of G.children)fe.append(A.cloneNode(!0));const ne=Me(n)-v;if(ne>=0&&ne<m){const A=document.createElement("i");A.className="ps-today",A.style.left=`${(ne+.5)*T}px`,fe.append(A)}for(const{item:A,lane:O}of K){const V=Me(A.start),_=Me(A.end);if(_<v||V>=v+m)continue;const X=Math.max(0,V-v)*T,N=Math.min(m,_-v+1)*T,B=document.createElement("button");B.className=`ps-bar ${g?"ps-color":"ps-content"}`,B.dataset.item=A.id,B.setAttribute("aria-label",`${A.name},${A.start} 至 ${A.end}`),B.style.left=`${X}px`,B.style.width=`${N-X}px`,B.style.top=`${52+O*(h?48:36)}px`,B.style.setProperty("--bar-color",A.color||"#8cafeb"),B.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${H(A.name)}</span><span class="ps-status">${H(A.status)}</span><span class="ps-node">● ${H(A.node)}</span><span class="ps-effort">${A.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,fe.append(B)}if(!K.length){const A=document.createElement("span");A.className="ps-no-schedule",A.textContent="暂无排期",fe.append(A)}pe.append(J,fe),y.append(pe)}F.length||(y.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const I=new Set(F.map(D=>D.id)),L=k.filter(D=>I.has(D.personId));b(".ps-total").textContent=`ⓘ 总人数 ${F.length} 总估分 ${rn(L).estimate.toFixed(2)} pd ···`}function ra(s,e){ei(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(A=>A.id)),a=!1,l="",r="",d="",c=!1,p=1,f=!1,u=!1,h=!1,g=!0,v=Me(n)-new Date(`${n}T00:00:00Z`).getUTCDay(),m=90,C=`${n.slice(0,7)}-01`,S=Fe(Date.UTC(Number(n.slice(0,4)),Number(n.slice(5,7))+1,0)/864e5),b=!1,y=!1;const R=document.createElement("section");R.className="personnel-schedule",R.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${H(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
88
+ <div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${H(e.workItemLabel??"工作项")}</button><button data-action="sort">☷ 人员排序</button><span class="ps-space"></span><button class="ps-round" data-action="minus" aria-label="缩小">−</button><input class="ps-zoom" type="range" min="0" max="4" step="1" value="1" aria-label="时间缩放"><button class="ps-round" data-action="plus" aria-label="放大">+</button><button class="ps-save" data-action="save">▣ 存为视图</button><button data-action="settings" aria-label="显示设置">⚙</button></div>
89
+ <div class="ps-scroll"><div class="ps-table"><div class="ps-time-header"><div class="ps-date-nav"><button data-action="date" class="ps-date-label"></button><button data-action="prev" aria-label="上一时间段">‹</button><button data-action="today" aria-label="回到今天">•</button><button data-action="next" aria-label="下一时间段">›</button></div><div class="ps-weeks"></div></div><div class="ps-rows"></div></div></div>
90
+ <footer class="ps-total"></footer><div class="ps-popover" hidden></div><aside class="ps-detail" hidden></aside><div class="ps-toast" role="status" hidden></div>`,s.append(R);const M=xe(R,"personnel",e),T=A=>R.querySelector(A),W=T(".ps-scroll"),E=T(".ps-rows"),x=T(".ps-popover"),k=T(".ps-detail"),$=new AbortController,q=$.signal;let F;const G=()=>[22,43,64,86,120][p];function I(A){const O=T(".ps-toast");O.textContent=A,O.hidden=!1,clearTimeout(F),F=setTimeout(()=>O.hidden=!0,2200)}function L(){b||aa(R,{people:t,items:i,today:n,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:f,children:u,loose:h,colorFirst:g,from:v,days:m,rangeStart:C,rangeEnd:S})}function D(A,O){if(!x.hidden&&x.dataset.kind===A){x.hidden=!0;return}x.dataset.kind=A,x.hidden=!1;const V=R.getBoundingClientRect(),_=O==null?void 0:O.getBoundingClientRect();if(x.style.left=`${Math.max(12,Math.min(((_==null?void 0:_.left)??V.left)-V.left,R.clientWidth-(A==="unplanned"?760:420)-16))}px`,x.style.top=`${_?_.bottom-V.top+6:96}px`,x.className=`ps-popover ps-panel-${A}`,A==="people")x.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(X=>`<label><input type="checkbox" data-person="${H(X.id)}" ${o.has(X.id)?"checked":""}>${H(X.name)}</label>`).join("")}</div>`;else if(A==="sort")x.innerHTML=`<div class="ps-panel-title">设置排序条件 ⓘ</div><div class="ps-sort-fields"><select aria-label="排序字段" data-control="sort"><option value="">请选择排序项</option><option value="estimate">总估分</option><option value="scheduled">已排期项</option></select><button data-action="asc" class="${c?"":"selected"}">小 → 大</button><button data-action="desc" class="${c?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,x.querySelector("select").value=d;else if(A==="filter")x.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${H(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${H(l)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(X=>X.status))].map(X=>`<option>${H(X)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,x.querySelector("select").value=r;else if(A==="settings")x.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${f?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${u?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${h?"":"selected"}">紧凑</button><button data-action="loose" class="${h?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${g?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${g?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(A==="date")K();else if(A==="save")x.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(A==="views"){const X=fe();x.innerHTML=`<div class="ps-panel-title">视图列表</div>${X.length?X.map((N,B)=>`<button class="ps-view" data-view="${B}">▦ ${H(N.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let z=new Date(`${C}T00:00:00Z`),U=!1;function K(){let A=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${C}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${S}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let O=0;O<2;O++){const V=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+O,1));A+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${V.getUTCFullYear()}年 ${V.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(X=>`<span>${X}</span>`).join("")}`;for(let X=0;X<V.getUTCDay();X++)A+="<span></span>";const _=new Date(Date.UTC(V.getUTCFullYear(),V.getUTCMonth()+1,0)).getUTCDate();for(let X=1;X<=_;X++){const N=Fe(Date.UTC(V.getUTCFullYear(),V.getUTCMonth(),X)/864e5);A+=`<button data-date="${N}" class="${N>=C&&N<=S?"in-range":""} ${N===C||N===S?"selected":""}">${X}</button>`}A+="</div></div>"}x.innerHTML=A+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((O,V)=>`<button data-preset="${V}">${O}</button>`).join("")}</div>`}function Z(){S<C&&([C,S]=[S,C]),v=Me(C),v-=new Date(v*864e5).getUTCDay(),m=Math.max(35,Me(S)-v+8),W.scrollLeft=0,L()}function ie(A,O){var X;if(!i.some(N=>N.id===A))throw new Error(`Unknown schedule item: ${A}`);const V=i.map(N=>N.id===A?{...N,...O}:N);ei(t,V),i=V,L();const _=i.find(N=>N.id===A);_&&((X=e.onItemChange)==null||X.call(e,structuredClone(_)))}function pe(A){var V;const O=i.find(_=>_.id===A);(V=e.onItemOpen)==null||V.call(e,structuredClone(O)),k.hidden=!1,k.dataset.item=A,k.innerHTML=`<header><strong>${H(O.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${H(O.status)}</span><h3>● ${H(O.node)}</h3><form><label>名称<input name="name" required value="${H(O.name)}"></label><label>负责人<select name="personId">${t.map(_=>`<option value="${H(_.id)}" ${_.id===O.personId?"selected":""}>${H(_.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${O.estimate}" required></label><label>开始日期<input type="date" name="start" value="${O.start||""}"></label><label>结束日期<input type="date" name="end" value="${O.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 J(A,O){D("unplanned",O),x.hidden=!1;const V=t.find(_=>_.id===A);x.innerHTML=`<div class="ps-panel-title">未排期工作项 ${H(V.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(_=>_.personId===A&&!Jt(_)).map(_=>`<tr><td><button data-open="${H(_.id)}">${H(_.name)}</button></td><td>● ${H(_.node)}</td><td><input type="number" min="0" step="0.1" value="${_.estimate||""}" placeholder="待填" data-estimate="${H(_.id)}" aria-label="${H(_.name)}估分"></td><td><button class="ps-link" data-open="${H(_.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const ce=e.viewStorageKey??"rowvia-personnel-views-v1";function fe(){try{const A=JSON.parse(localStorage.getItem(ce)||"[]");return Array.isArray(A)?A:[]}catch{return[]}}R.addEventListener("click",A=>{const O=A.target,V=O.closest("button");if(!V)return;if(V.dataset.open){x.hidden=!0,pe(V.dataset.open);return}if(V.dataset.item){y||pe(V.dataset.item);return}if(V.dataset.date){U?(S=V.dataset.date,U=!1,Z()):(C=V.dataset.date,S=C,U=!0),K();return}if(V.dataset.preset){const X=Number(V.dataset.preset),N=Me(n),B=new Date(N*864e5);C=Fe(X<2?N-B.getUTCDay():X<4?Date.UTC(B.getUTCFullYear(),B.getUTCMonth(),1)/864e5:N),S=Fe(X===2||X===3?Date.UTC(B.getUTCFullYear(),B.getUTCMonth()+(X===2?1:2),0)/864e5:Me(C)+[6,13,29,60,13,59,364][X]),U=!1,Z(),x.hidden=!0;return}if(V.dataset.view){const X=fe()[Number(V.dataset.view)];X&&(o=new Set(X.selected.filter(N=>t.some(B=>B.id===N))),{query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:C,rangeEnd:S,expanded:f,children:u,loose:h,colorFirst:g,onlyScheduled:a}=X,L(),x.hidden=!0,I(`已打开 ${X.name}`));return}const _=V.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(_||"")){D(_,V);return}if(_==="unplanned"){J(V.dataset.person,V);return}if(_==="close-detail"&&(k.hidden=!0),_==="unschedule"&&(ie(k.dataset.item,{start:null,end:null}),k.hidden=!0),(_==="plus"||_==="minus")&&(p=Math.max(0,Math.min(4,p+(_==="plus"?1:-1))),L()),(_==="prev"||_==="next"||_==="today")&&(v=_==="today"?Me(n)-new Date(`${n}T00:00:00Z`).getUTCDay():v+(_==="prev"?-14:14),C=Fe(v),S=Fe(v+59),W.scrollLeft=0,L()),(_==="asc"||_==="desc"||_==="clear-sort")&&(c=_==="desc",_==="clear-sort"&&(d=""),L(),x.hidden=!0),_==="clear-filter"&&(l="",r="",L(),x.hidden=!0),["compact","loose","content","color"].includes(_||"")&&(_==="compact"||_==="loose"?h=_==="loose":g=_==="color",L(),x.hidden=!0,D("settings",T('[data-action="settings"]'))),(_==="cal-prev"||_==="cal-next")&&(z=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+(_==="cal-prev"?-1:1),1)),K()),_==="save-view"){const X=x.querySelector("[data-view-name]").value.trim();if(!X)return;const N=fe();N.push({name:X,selected:[...o],query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:C,rangeEnd:S,expanded:f,children:u,loose:h,colorFirst:g,onlyScheduled:a});try{localStorage.setItem(ce,JSON.stringify(N)),x.hidden=!0,I("视图已保存")}catch{I("浏览器存储不可用,视图未保存")}}_==="schedule"&&(x.hidden=!0,k.hidden=!0)},{signal:q}),R.addEventListener("input",A=>{const O=A.target;O.classList.contains("ps-zoom")&&(p=Number(O.value),L()),O.classList.contains("ps-person-search")&&x.querySelectorAll(".ps-person-options label").forEach(V=>{var _;return V.hidden=!((_=V.textContent)!=null&&_.includes(O.value))}),O.dataset.control==="query"&&(l=O.value,L())},{signal:q}),R.addEventListener("change",A=>{const O=A.target;if(O.dataset.person&&(O.checked?o.add(O.dataset.person):o.delete(O.dataset.person),L()),O.dataset.estimate){const V=Number(O.value);Number.isFinite(V)&&V>=0&&ie(O.dataset.estimate,{estimate:V});return}switch(O.dataset.control){case"only":a=O.checked;break;case"sort":d=O.value;break;case"status":r=O.value;break;case"expanded":f=O.checked;break;case"children":u=O.checked;break;case"range-start":O.value&&(C=O.value,Z(),K());return;case"range-end":O.value&&(S=O.value,Z(),K());return}L()},{signal:q}),k.addEventListener("submit",A=>{A.preventDefault();const O=new FormData(A.target),V=String(O.get("start")||"")||null,_=String(O.get("end")||"")||null;if(!!V!=!!_||V&&_&&V>_){k.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ie(k.dataset.item,{name:String(O.get("name")),personId:String(O.get("personId")),estimate:Number(O.get("estimate")),start:V,end:_}),k.hidden=!0,I("排期已更新")},{signal:q}),document.addEventListener("pointerdown",A=>{R.contains(A.target)?!x.contains(A.target)&&!A.target.closest("[data-action]")&&(x.hidden=!0):x.hidden=!0},{signal:q}),R.addEventListener("keydown",A=>{A.key==="Escape"&&(x.hidden=!0,k.hidden=!0)},{signal:q});let ne=null;return E.addEventListener("pointerdown",A=>{const O=A.target,V=O.closest(".ps-bar");if(!V||A.button!==0)return;const _=i.find(X=>X.id===V.dataset.item);y=!1,ne={id:_.id,x:A.clientX,start:Me(_.start),end:Me(_.end),edge:O.dataset.edge||"move",bar:V,left:parseFloat(V.style.left),size:parseFloat(V.style.width),delta:0,scroll:W.scrollLeft}},{signal:q}),document.addEventListener("pointermove",A=>{if(!ne)return;const O=Math.round((A.clientX-ne.x+W.scrollLeft-ne.scroll)/G());ne.delta=ne.edge==="start"?Math.min(O,ne.end-ne.start):ne.edge==="end"?Math.max(O,ne.start-ne.end):O,Math.abs(A.clientX-ne.x)>4&&(y=!0),y&&(ne.bar.style.opacity=".8",ne.edge==="move"?ne.bar.style.transform=`translateX(${ne.delta*G()}px)`:(ne.bar.style.left=`${ne.left+(ne.edge==="start"?ne.delta*G():0)}px`,ne.bar.style.width=`${ne.size+(ne.edge==="start"?-1:1)*ne.delta*G()}px`))},{signal:q}),document.addEventListener("pointerup",()=>{if(!ne)return;const A=ne;ne=null,y&&(ie(A.id,{start:Fe(A.start+(A.edge==="end"?0:A.delta)),end:Fe(A.end+(A.edge==="start"?0:A.delta))}),I("排期已更新"))},{signal:q}),L(),{onInteraction:M.onInteraction,setData(A,O){ei(A,O),t=structuredClone(A),i=structuredClone(O),o=new Set(t.map(V=>V.id)),x.hidden=!0,k.hidden=!0,L()},getItems:()=>structuredClone(i),updateItem:ie,setPeople(A){o=new Set(A.filter(O=>t.some(V=>V.id===O))),L()},destroy(){b=!0,$.abort(),clearTimeout(F),M.destroy(),R.remove()}}}const la=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1});function dn(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)}})}const cn={pencil:'<path d="m15 3 6 6-12 12H3v-6ZM13 5l6 6"/>',transition:'<path d="M4 8h14l-4-4m4 4-4 4M20 16H6l4-4m-4 4 4 4"/>',expand:'<path d="M15 3h6v6m0-6-7 7M9 21H3v-6m0 6 7-7"/>',check:'<circle cx="12" cy="12" r="8"/><path d="m8 12 3 3 5-6"/>',plus:'<circle cx="12" cy="12" r="9"/><path d="M12 7v10M7 12h10"/>',add:'<path d="M12 4v16M4 12h16"/>',close:'<path d="m6 6 12 12M6 18 18 6"/>',back:'<path d="m15 18-6-6 6-6"/>',filter:'<path d="M3 4h18l-7 8v7l-4 2v-9Z"/>',sort:'<path d="M4 5h16M4 11h11M4 17h6"/>',group:'<path d="m3 13 10-10h8v8L11 21Z"/><circle cx="17" cy="7" r="1"/>',color:'<path d="m10 3 10 10-8 8L2 11Z M4 13h14M10 3 7 0"/><path d="M21 17q4 5 0 5q-4 0 0-5"/>',search:'<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6M2 3h5M2 9h2M2 16h5"/>',save:'<path d="M4 3h13l4 4v14H3V3h1ZM8 3v7h8V3M7 21v-7h10v7"/>',down:'<path d="m6 9 6 6 6-6"/>',up:'<path d="m6 15 6-6 6 6"/>',link:'<path d="m10 14 4-4M8 16l-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0M16 8l1-1a4 4 0 0 1 6 6l-5 5a4 4 0 0 1-6 0"/>',edit:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><path d="M14 17h8m-4-4v8"/>',book:'<path d="M6 3h12v18l-6-4-6 4Z"/>',people:'<circle cx="9" cy="8" r="3"/><path d="M3 21v-3a6 6 0 0 1 12 0v3ZM17 4a3 3 0 0 1 0 6M18 14q4 1 4 7"/>',table:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M3 14h18M9 9v11M15 9v11"/>',chart:'<circle cx="12" cy="12" r="9"/><path d="M12 3v9h9"/>',menu:'<path d="M4 6h16M4 12h12M4 18h16"/>',more:'<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',inbox:'<path d="m5 4-3 10v6h20v-6L19 4ZM2 14h6l2 3h4l2-3h6"/>'},me=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${cn[s]||cn.check}</svg>`,Ce=(s,e,t="",i="")=>`<button type="button" data-action="${s}" class="${i}" aria-label="${H(e)}">${t?me(t):""}${e?`<span>${H(e)}</span>`:""}</button>`,Pt=(s,e,t="")=>`<select ${t}>${s.map(([i,n])=>`<option value="${H(i)}" ${i===e?"selected":""}>${H(n)}</option>`).join("")}</select>`,ti=new WeakMap;function un(s){let e=ti.get(s);e||(e={owners:0,added:!s.classList.contains("rowvia-work-items"),fieldAdded:!s.classList.contains("rowvia-field-scope")},ti.set(s,e),s.classList.add("rowvia-work-items","rowvia-field-scope")),e.owners++;let t=!1;return()=>{t||(t=!0,!--e.owners&&(e.added&&s.classList.remove("rowvia-work-items"),e.fieldAdded&&s.classList.remove("rowvia-field-scope"),ti.delete(s)))}}function ii(s,e,t,i){const n=document.createElement("div");n.className=e,n.innerHTML=t;const o=un(s);s.append(n);const a=new Ge,l=xe(n,e,i);return a.listen(n,"click",r=>{var p;const d=r.target.closest("[data-action]");if(!d||!n.contains(d)||d.matches(":disabled"))return;const c={action:d.dataset.action,anchor:d,originalEvent:r};(p=i.onAction)==null||p.call(i,c),n.dispatchEvent(new CustomEvent("rowvia:action",{detail:c,bubbles:!0}))}),{element:n,lifecycle:a,onInteraction:l.onInteraction,destroy(){a.destroy(),l.destroy(),n.remove(),o()}}}function da(s,e){const t=ii(s,"list-tabs",e.tabs.map(o=>`<button class="list-tab" role="tab" data-tab="${H(o)}">${H(o)}</button>`).join("")+`<div class="create-button">${Ce("create","新建","plus","primary")}${Ce("create-menu","","down","primary")}</div>`,e);t.element.setAttribute("role","tablist");let i=e.value??e.tabs[0]??"";const n=o=>{i=o,t.element.querySelectorAll("[data-tab]").forEach(a=>{const l=a.dataset.tab===i;a.classList.toggle("active",l),a.setAttribute("aria-selected",String(l))})};return t.lifecycle.listen(t.element,"click",o=>{var l;const a=o.target.closest("[data-tab]");!a||a.dataset.tab===i||(n(a.dataset.tab),(l=e.onChange)==null||l.call(e,i),t.element.dispatchEvent(new CustomEvent("rowvia:tab-change",{detail:i,bubbles:!0})))}),t.element.querySelectorAll("[data-action]").forEach(o=>{o.disabled=e.canCreate===!1}),n(i),{element:t.element,onInteraction:t.onInteraction,setValue:n,getValue:()=>i,destroy:t.destroy}}const ni={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};function ca(s,e={}){const t=ii(s,"toolbar",Object.entries(ni).map(([a,l])=>Ce(a,l,a)).join("")+`<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${Ce("previous-match","","up")}${Ce("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${Ce("close-search","","close")}</div>${Ce("search","查找","search")}<div class="right">${Ce("reset","重置","","hidden")}${Ce("saved-views","切换视图","down")}${Ce("save-view","存为视图","save","outline")}</div>`,e),i=t.element.querySelector("#search"),n=t.element.querySelector("#filter-search"),o=()=>{var a;(a=e.onSearch)==null||a.call(e,i.value,n.checked),t.element.dispatchEvent(new CustomEvent("rowvia:search",{detail:{query:i.value,filter:n.checked},bubbles:!0}))};return t.lifecycle.listen(i,"input",o),t.lifecycle.listen(n,"change",o),{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setRuleCounts(a){for(const l of Object.keys(ni)){const r=t.element.querySelector(`[data-action="${l}"]`);r.classList.toggle("is-set",!!a[l]),r.querySelector("span").textContent=ni[l]+(a[l]?` · ${a[l]}`:"")}t.element.querySelector('[data-action="reset"]').classList.toggle("hidden",!Object.values(a).some(Boolean))}}}function ua(s,e={}){const t=ii(s,"selection-bar hidden",`${Ce("deselect","","close")}<span data-selection-count></span>${Ce("batch-status","更新状态")}${Ce("batch-owner","更新负责人")}${Ce("batch-export","导出")}${Ce("batch-archive","终止")}${Ce("deselect","取消选择")}`,e),i=t.element.querySelector("[data-selection-count]");return{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setCount(n){t.element.classList.toggle("hidden",n===0),i.textContent=`已选择 ${n} 项`}}}function ha(s,e){const t=un(s),i=Vi(s,{getRowId:({data:n})=>n.id,rowHeight:37,headerHeight:32,theme:"ag-theme-quartz",rowSelection:"multiple",defaultColDef:{resizable:!0,sortable:!1,filter:!1},suppressRowClickSelection:!0,groupDefaultExpanded:-1,autoGroupColumnDef:{headerName:"分组",width:180,pinned:"left"},suppressContextMenu:!0,enableRangeSelection:!1,undoRedoCellEditing:!0,stopEditingWhenCellsLoseFocus:!0,localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"},...e});return{...i,onInteraction:i.grid.onInteraction,destroy(){i.grid.destroy(),t()}}}function pa(s){const{config:e,controls:t,fieldConfig:i,options:n,$:o,tag:a,activateCell:l,controlContext:r,openDetail:d,colorRuleMatches:c}=s;function p(u){if(u.node.group)return"";const h=u.data,g=u.colDef.field,v=document.createElement("div");v.className="rendered-cell";const m=i(g);if(m&&(m.control||!["title","status"].includes(m.kind||"text")))v.append(t.resolve(m).render(r(m,h,"cell")));else if((m==null?void 0:m.kind)==="title"){const C=document.createElement("a");C.className="item-name",C.href=`#item/${h.id}`,C.textContent=h[g],C.title=h[g],C.addEventListener("click",b=>{b.preventDefault(),clearTimeout(s.detailClickTimer.get()),b.detail===0?d(h):b.detail===1&&s.detailClickTimer.set(window.setTimeout(()=>d(h),280))}),v.append(C);const S=document.createElement("button");S.className="inline-edit",S.innerHTML=me("pencil"),S.ariaLabel="编辑选题概要",S.onclick=b=>{b.stopPropagation(),l(v,g,h,u.rowIndex)},(m==null?void 0:m.editable)!==!1&&v.append(S)}else(m==null?void 0:m.kind)==="status"?(v.innerHTML=`${a(h.status,g)}<span class="status-days">20 天</span>`,(m==null?void 0:m.editable)!==!1&&(v.onclick=C=>{C.stopPropagation(),l(v,g,h,u.rowIndex)})):n[g]?(v.innerHTML=["creator","owner","space"].includes(g)?H(h[g]):a(h[g],g),(m==null?void 0:m.editable)!==!1&&(v.onclick=C=>{C.stopPropagation(),l(v,g,h,u.rowIndex)})):(v.innerHTML=`<span class="cell-text">${H(h[g]||"暂无")}</span>`,h[g]||v.classList.add("placeholder"));if(m&&m.editable!==!1&&!t.resolve(m).readonly&&m.kind!=="title"){const C=document.createElement("button");C.className="inline-edit field-control",C.ariaLabel=`${m.kind==="status"?"流转":"编辑"}${m.label}`,C.innerHTML=me(m.kind==="status"?"transition":["select","multiSelect","person"].includes(m.kind||"")?"down":"pencil"),C.onclick=S=>{S.stopPropagation(),l(v,g,h,u.rowIndex)},v.append(C)}return v.title=String(h[g]??""),v}function f(){return[{colId:"_select",headerName:"",width:64,minWidth:64,maxWidth:64,pinned:"left",sortable:!1,resizable:!1,suppressMovable:!0,suppressMenu:!0,checkboxSelection:!0,headerCheckboxSelection:!0,rowDrag:!0,cellRenderer:u=>{if(u.node.group)return"";const h=document.createElement("div");return h.className="row-controls",h.innerHTML=`<span class="row-number">${u.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${u.rowIndex+1} 行" ${u.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${me("expand")}</button>`,o("input",h).onclick=g=>g.stopPropagation(),o("input",h).onchange=g=>u.node.setSelected(g.target.checked),o("button",h).onclick=g=>{g.stopPropagation(),d(u.data)},h}},...e.fields.map(u=>({field:u.key,headerName:u.label,width:u.width??120,minWidth:u.minWidth??80,pinned:u.pinned,hide:u.hidden,enableRowGroup:!0,editable:!1,valueSetter:h=>u.required&&!String(h.newValue??"").trim()?!1:(h.data[u.key]=h.newValue,!0),comparator:u.options?(h,g)=>u.options.indexOf(h)-u.options.indexOf(g):void 0,sortable:!1,suppressMenu:!0,cellRenderer:p,cellStyle:({data:h})=>{const g=h&&s.view().colors.find(v=>!!v.scope&&v.scope!=="row"&&v.field===u.key&&c(h,v));return g?{backgroundColor:g.color}:{}},tooltipField:u.key,cellClass:u.kind==="title"?"name-cell":void 0,...u.column})),...s.customColumns(),{colId:"_add",hide:e.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}return{cell:p,columnDefs:f}}function fa(s){const{config:e,data:t,fields:i,fieldConfig:n,options:o,controls:a,$:l,showPopup:r,closePopup:d,applyView:c,save:p,resizeGrid:f,decorateHeaders:u}=s;function h(C,S,b={}){e.container.querySelectorAll(".field-picker").forEach(W=>W.remove());const y=document.createElement("div");y.className="field-picker",y.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(W=>`<button data-kind="${W}">${W}</button>`).join("")}</div><div class="field-options"></div>`,e.container.append(y);const R=C.getBoundingClientRect();y.style.left=`${Math.max(12,Math.min(R.left,innerWidth-410))}px`,y.style.top=`${Math.max(12,Math.min(R.bottom+4,innerHeight-340))}px`;let M="推荐";const T=(W="推荐",E="")=>{l(".field-options",y).innerHTML=i.filter(([x,k])=>{var $,q,F,G,I,L;return(!b.available||b.available(x))&&k.includes(E)&&(W==="推荐"||W==="文本"&&["title","text","longText","richText"].includes((($=n(x))==null?void 0:$.kind)||"text")||W==="选择"&&["status","select","multiSelect"].includes(((q=n(x))==null?void 0:q.kind)||"")||W==="人员"&&((F=n(x))==null?void 0:F.kind)==="person"||W==="时间"&&["date","dateTime"].includes(((G=n(x))==null?void 0:G.kind)||"")||W==="关系"&&((I=n(x))==null?void 0:I.kind)==="relation"||W==="其他"&&((L=n(x))==null?void 0:L.kind)==="vote")}).map(([x,k])=>`<button data-field="${H(x)}" ${b.onCreate?`data-insert="${H(x)}"`:""} class="menu-option">${me("table")}${H(k)}</button>`).join(""),b.onCreate&&l(".field-options",y).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${me("add")}添加字段</button>`),y.querySelectorAll("[data-kind]").forEach(x=>{x.classList.toggle("active",x.dataset.kind===W),x.setAttribute("aria-pressed",String(x.dataset.kind===W))})};T(),l("input",y).oninput=W=>T(M,W.target.value),y.onclick=W=>{var x;const E=W.target.closest("button");E&&(W.stopPropagation(),E.dataset.kind&&(M=E.dataset.kind,T(M,l("input",y).value)),E.dataset.field&&(y.remove(),S(E.dataset.field)),E.hasAttribute("data-create-field")&&(y.remove(),(x=b.onCreate)==null||x.call(b)))}}function g(C){const S=s.instance(),b=r(C,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${S.api.getAllColumns().filter(y=>!y.colId.startsWith("_")).map(y=>`<label class="column-option"><input type="checkbox" data-column="${y.colId}" ${y.visible?"checked":""}><span>${H(y.headerName)}</span><button type="button" data-pin="${y.colId}">${y.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);b.onchange=y=>{const R=y.target;R.dataset.column&&S.columnApi.setColumnVisible(R.dataset.column,R.checked)},b.onclick=y=>{const R=y.target.closest("[data-pin]");if(R){y.preventDefault();const M=S.columnApi.getColumn(R.dataset.pin);S.columnApi.setColumnPinned(M,M.pinned?null:"left"),g(C)}},l("input",b).oninput=y=>{const R=y.target.value;b.querySelectorAll(".column-option").forEach(M=>M.hidden=!M.textContent.includes(R))}}function v(C,S,b){const y=s.instance();d();const R=T=>{var x;const E=y.columnApi.getColumnState().findIndex(k=>k.colId===S)+(b?1:0);y.columnApi.setColumnVisible(T,!0),y.columnApi.setColumnPinned(T,S==="_add"?null:((x=y.columnApi.getColumn(S))==null?void 0:x.pinned)??null),y.columnApi.moveColumn(T,Math.max(1,E)),d(),f(),u()};h(C,R,{available:T=>{var W;return!((W=y.columnApi.getColumn(T))!=null&&W.visible)},onCreate:()=>{const T=r(C,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${a.list().map(L=>`<option value="${H(L.id)}">${H(L.label)}</option>`).join("")}</select></label><label>选项(每行一个)<textarea name="options" aria-label="字段选项"></textarea></label><label class="choice-limit hidden">最多可选数量<input name="maxSelections" type="number" min="1" step="1" placeholder="不限" aria-label="最多可选数量"></label><button class="primary" type="submit">确认创建</button></form>`,320),W=l('[name="kind"]',T),E=l('[name="options"]',T),x=E.closest("label"),k=document.createElement("div");k.className="fc-field-schema",k.hidden=!0,k.innerHTML='<p class="hint">每组记录包含以下子字段</p><div class="fc-field-schema-rows"></div><button type="button" class="fc-composite-add">+ 添加子字段</button>';const $=a.list().filter(L=>!L.readonly&&!["composite","multiPersonComposite","attitudeVote","singleVote","multiVote","detail"].includes(L.id)),q=()=>{const L=document.createElement("div");L.className="fc-field-schema-row",L.innerHTML='<input class="fc-input" aria-label="子字段名称" placeholder="子字段名称"><select class="fc-input" aria-label="子字段类型">'+$.map(D=>'<option value="'+H(D.id)+'">'+H(D.label)+"</option>").join("")+'</select><button type="button" aria-label="移除子字段">×</button>',L.querySelector("button").onclick=()=>L.remove(),k.querySelector(".fc-field-schema-rows").append(L)};k.querySelector("button").onclick=q,q();const F=document.createElement("p");F.className="fc-service-note";const G=document.createElement("p");G.className="fc-error",G.setAttribute("role","status"),l("form",T).insertBefore(k,l('button[type="submit"]',T)),l("form",T).insertBefore(F,l('button[type="submit"]',T)),l("form",T).insertBefore(G,l('button[type="submit"]',T));const I=()=>{const L=W.value,D=L==="cascadeSingle"||L==="cascadeMulti";x.hidden=!D&&!["select","multiSelect","radio","singleVote","multiVote","person","multiPerson","relation","multiRelation"].includes(L),E.placeholder=D?"每行一条路径,例如:产品 / 设计 / 交互":"每行一个选项",l(".choice-limit",T).classList.toggle("hidden",!["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(L)),k.hidden=!["composite","multiPersonComposite"].includes(L),F.textContent=D?"用 / 分隔层级;同名上级会合并。":L==="attachment"?"上传操作由宿主上传服务提供。":L.endsWith("Vote")?"投票操作由宿主投票服务提供。":"",G.textContent=""};W.onchange=I,I(),l("form",T).onsubmit=L=>{L.preventDefault();const D=new FormData(L.target),z=String(D.get("label")||"").trim();if(!z)return;const U=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,K=String(D.get("kind")),Z={key:U,label:z,kind:K,editable:!a.resolve({key:U,label:z,kind:K}).readonly,width:160};["select","multiSelect","person","multiPerson","radio","singleVote","multiVote","relation","multiRelation"].includes(K)&&(Z.options=[...new Set(String(D.get("options")||"").split(`
91
+ `).map(J=>J.trim()).filter(Boolean))]);const ie=Number(D.get("maxSelections"));if(["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(K)&&Number.isInteger(ie)&&ie>0&&(Z.maxSelections=ie),K==="dateTime"&&(Z.dateOptions={showTime:!0,showSeconds:!0}),K==="cascadeSingle"||K==="cascadeMulti"){Z.choices=[];for(const J of E.value.split(`
92
+ `).filter(ce=>ce.trim())){let ce=Z.choices;const fe=J.split("/").map(ne=>ne.trim()).filter(Boolean);fe.forEach((ne,A)=>{let O=ce.find(V=>V.id===ne);O||(O={id:ne,label:ne},ce.push(O)),A<fe.length-1&&(O.children??(O.children=[]),ce=O.children)})}if(!Z.choices.length){G.textContent="请至少填写一条分类路径";return}}if(K==="composite"||K==="multiPersonComposite"){const J=[...k.querySelectorAll(".fc-field-schema-row")];if(!J.length||J.some(ce=>!ce.querySelector("input").value.trim())){G.textContent="请填写子字段名称";return}Z.compositeFields=J.map((ce,fe)=>({key:"sub_"+fe,label:ce.querySelector("input").value.trim(),kind:ce.querySelector("select").value})),K==="multiPersonComposite"&&Z.compositeFields.unshift({key:"owner",label:"填写人",kind:"person",required:!0})}e.fields.push(Z),i.push([U,z]),Z.options&&(o[U]=Z.options),t.customFields.push(Z);const pe=y.columnApi.getColumnState();y.api.setColumnDefs(s.columnDefs()),y.columnApi.applyColumnState(pe,!0),R(U),p(),c()}}})}function m(C,S){const b=s.instance(),y=s.view(),R=b.columnApi.getColumn(S);if(!R||S==="_select")return;if(S==="_add"){v(C,S,!1);return}const M=["向左插入列","向右插入列",o[S]?"以 首项 → 末项 排序":"以 A → Z 排序",o[S]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",R.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],T=r(C,"",[[0,1],[2,3],[4,8],[5,6,7]].map(W=>W.map(E=>`<button class="menu-option${E===7?" destructive":""}" data-col-menu="${E}" ${E===7&&S==="name"?"disabled":""}>${M[E]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");T.dataset.headerMenu="true",T.onclick=W=>{const E=W.target.closest("[data-col-menu]");if(!E)return;const x=+E.dataset.colMenu;d(),(x===0||x===1)&&v(C,S,x===1),(x===2||x===3)&&(y.sorts=[{colId:S,sort:x===2?"asc":"desc"}],c()),x===4&&(y.filters.push({field:S,operator:"contains",value:""}),s.rulePanel("filter",l('[data-action="filter"]'))),x===5&&b.columnApi.setColumnPinned(S,R.pinned?null:"left"),x===6&&s.textDialog("编辑列",R.headerName,k=>{const $=n(S);$&&($.label=k);const q=b.api.getColumnDefs(),F=q.find(I=>I.field===S);F&&(F.headerName=k);const G=b.columnApi.getColumnState();b.api.setColumnDefs(q),b.columnApi.applyColumnState(G,!0),u()}),x===7&&b.columnApi.setColumnVisible(S,!1),x===8&&(y.groups.includes(S)||y.groups.push(S),c())}}return{fieldPicker:h,showColumns:g,showInsertField:v,showColumnMenu:m}}function ga(s){const{root:e,view:t,fieldConfig:i,showInsertField:n,showColumnMenu:o,applyView:a}=s,l=r=>e.querySelector(r);return function(){l("#grid").querySelectorAll(".ag-header-cell").forEach(d=>{var h,g;const c=d.dataset.colid;if(c==="_add"){if(!d.querySelector(".work-add-column")){const v=d.querySelector(".ag-header-cell-label"),m=document.createElement("button");m.type="button",m.className="work-add-column",m.ariaLabel="新增字段",m.title="新增字段",m.innerHTML=me("add"),m.onmousedown=C=>C.stopPropagation(),m.onclick=C=>{C.stopPropagation(),n(m,"_add",!1)},v.replaceChildren(m)}return}if(!i(c))return;if(!d.querySelector(".work-header-sort")){const v=document.createElement("span");v.className="work-header-sort",(h=d.querySelector(".ag-header-cell-label"))==null||h.append(v);const m=document.createElement("button");m.className="work-header-menu",m.ariaLabel=`${i(c).label}操作`,m.innerHTML=me("more"),m.onclick=S=>{S.stopPropagation(),o(m,c)},m.onmousedown=S=>S.stopPropagation(),d.append(m);for(const S of["right","left"]){const b=document.createElement("button");b.className="work-header-add",b.dataset.insertSide=S,b.ariaLabel=`在${i(c).label}${S==="right"?"右":"左"}侧插入列`,b.title="插入列",b.innerHTML=me("add"),b.onclick=y=>{y.stopPropagation(),n(b,c,S==="right")},b.onmousedown=y=>y.stopPropagation(),d.append(b)}const C=()=>{const S=d.getBoundingClientRect(),b=l(".grid-wrap").getBoundingClientRect(),R=d.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();d.querySelectorAll(".work-header-add").forEach(M=>{const T=M.dataset.insertSide==="left"?S.left:S.right;M.style.left=`${T-12}px`,M.style.top=`${S.top-20}px`,M.style.setProperty("--insert-line-height",`${Math.max(0,b.bottom-S.top+8)}px`),M.style.display=T<Math.max(b.left,R.left)-1||T>Math.min(b.right,R.right)+1?"none":""}),d.classList.add("insert-points-ready")};d.addEventListener("mouseenter",C),d.addEventListener("focusin",C),d.addEventListener("click",S=>{var y;if(S.target.closest("button,.ag-header-cell-resize"))return;S.stopImmediatePropagation();const b=(y=t().sorts.find(R=>R.colId===c))==null?void 0:y.sort;t().sorts=b==="desc"?[]:[{colId:c,sort:b==="asc"?"desc":"asc"}],a()},{capture:!0})}const p=(g=t().sorts.find(v=>v.colId===c))==null?void 0:g.sort,f=d.querySelector(".work-header-sort"),u=p==="asc"?"↑":p==="desc"?"↓":"↕";f.textContent!==u&&(f.textContent=u),f.classList.toggle("sorted",!!p),d.setAttribute("aria-sort",p==="asc"?"ascending":p==="desc"?"descending":"none")})}}function ma(s){const{fields:e,fieldConfig:t,options:i,controls:n,newItem:o,fieldPicker:a,showPopup:l,applyView:r}=s;function d(f,u){return!!u.field&&(!!u.value||["blank","notBlank"].includes(u.operator))&&dn(f,[u])}function c(f){const u=s.view(),h=u.colors.map((R,M)=>{var k;const T=(k=t(R.field))==null?void 0:k.label,W=R.field?[["contains",i[R.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],E=!R.field||["blank","notBlank"].includes(R.operator),x=i[R.field]?Pt([["","请选择目标值"],...i[R.field].map($=>[$,$])],R.value,`data-rule-value="${M}" aria-label="目标值" ${E?"disabled":""}`):`<input data-rule-value="${M}" aria-label="目标值" placeholder="请选择目标值" value="${H(R.value)}" ${E?"disabled":""}>`;return`<div class="color-condition" data-color-row="${M}">
112
93
  <button class="color-drag" draggable="true" title="拖动调整条件优先级" aria-label="拖动条件">⠿</button>
113
- <button type="button" class="color-swatch" data-color="${G}" style="background-color:${de(A.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
114
- <button type="button" class="field-select" data-color-scope="${G}" aria-label="着色范围" aria-expanded="false">${!A.scope||A.scope==="row"?"整行":"单元格"}${Ie("down")}</button>
115
- <button class="field-select ${_?"":"empty"}" data-pick="${G}">${de(_||"请选择筛选项")}${Ie("down")}</button>
116
- ${Ve(ie,A.field?A.operator:"",`data-operator="${G}" aria-label="运算符" ${A.field?"":"disabled"}`)}
117
- ${le}
118
- <button class="color-remove" data-remove="${G}" aria-label="删除条件" title="删除条件">${Ie("close")}</button>
119
- <div class="color-more-wrap"><button class="color-more" data-color-more="${G}" aria-label="更多条件操作" aria-expanded="false">${Ie("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===f.colors.length-1?"disabled":""}>下移</button></div></div>
120
- </div>`}).join(""),T=Ee(w,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${x}</div><div class="color-panel-footer"><button class="add-condition">${Ie("plus")}添加着色条件</button><button class="clear-rules" ${f.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");T.ariaLabel="设置颜色条件",S="color";const I=()=>Y(w),L=()=>{K(),I()},H=["#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"],O=()=>{var A;(A=T.querySelector(".color-palette"))==null||A.remove(),T.querySelectorAll("[data-color]").forEach(G=>G.setAttribute("aria-expanded","false"))},F=()=>{var A,G;(A=T.querySelector(".color-scope-picker"))==null||A.remove(),(G=i==null?void 0:i.destroy)==null||G.call(i),i=null,T.querySelectorAll("[data-color-scope]").forEach(_=>_.setAttribute("aria-expanded","false"))};let N=-1;T.querySelectorAll(".color-condition").forEach((A,G)=>{A.ondragstart=_=>{var ie;N=G,(ie=_.dataTransfer)==null||ie.setData("text/plain",String(G))},A.ondragover=_=>_.preventDefault(),A.ondrop=_=>{if(_.preventDefault(),N<0||N===G)return;const[ie]=f.colors.splice(N,1);f.colors.splice(G,0,ie),L()}}),T.onclick=A=>{var ie,fe;A.stopPropagation();const G=A.target.closest("button");if(A.target.closest(".color-scope-picker"))return;const _=(G==null?void 0:G.getAttribute("aria-expanded"))==="true";if(F(),!G||G.disabled){O();return}if(G.dataset.colorScope!==void 0){if(O(),_)return;const le=Number(G.dataset.colorScope),ne=f.colors[le],re={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},Te=e.resolve(re).createEditor({field:re,value:!ne.scope||ne.scope==="row"?"整行":"单元格",item:je(),surface:"cell",readonly:!1,openDetail:()=>{}});i=Te;const ue=document.createElement("div");ue.className="popup fc-popup fc-choice-popup color-scope-picker",ue.style.width="272px",ue.append(Te.element),T.append(ue);const Le=G.getBoundingClientRect();ue.style.left=`${Math.max(8,Math.min(Le.left,innerWidth-280))}px`,ue.style.top=`${Math.max(8,Math.min(Le.bottom+6,innerHeight-ue.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),Te.element.addEventListener("change",Me=>{var st,Se;Me.stopPropagation(),!((st=Te.validate)!=null&&st.call(Te))&&(ne.scope=Te.read()==="整行"?"row":"cell",L(),(Se=y==null?void 0:y.querySelector(`[data-color-scope="${le}"]`))==null||Se.focus())}),ue.onkeydown=Me=>{Me.key==="Escape"&&(Me.stopPropagation(),F(),G.focus())},(ie=Te.focus)==null||ie.call(Te);return}if(G.dataset.paletteColor!==void 0){const le=Number(G.closest(".color-palette").dataset.ruleIndex);f.colors[le].color=G.dataset.paletteColor,L(),(fe=y==null?void 0:y.querySelector(`[data-color="${le}"]`))==null||fe.focus();return}if(G.dataset.color!==void 0){const le=G.getAttribute("aria-expanded")==="true";if(O(),le)return;const ne=Number(G.dataset.color),re=document.createElement("div");re.className="color-palette",re.dataset.ruleIndex=String(ne),re.setAttribute("role","group"),re.ariaLabel="选择着色颜色",re.innerHTML=H.map(ue=>`<button type="button" class="color-palette-option" data-palette-color="${ue}" style="background-color:${ue}" aria-label="颜色 ${ue}" aria-pressed="${ue===f.colors[ne].color.toLowerCase()}"></button>`).join(""),T.append(re);const Te=G.getBoundingClientRect();re.style.left=`${Math.max(8,Math.min(Te.left,innerWidth-re.offsetWidth-8))}px`,re.style.top=`${Math.max(8,Math.min(Te.bottom+6,innerHeight-re.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),re.onkeydown=ue=>{ue.key==="Escape"&&(ue.stopPropagation(),O(),G.focus())};return}if(O(),G.classList.contains("add-condition"))f.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),L();else if(G.dataset.pick!==void 0){const le=+G.dataset.pick;ut(G,ne=>{f.colors[le].field=ne,f.colors[le].value="",f.colors[le].operator="contains",L()})}else if(G.dataset.remove!==void 0)f.colors.splice(+G.dataset.remove,1),L();else if(G.classList.contains("clear-rules"))f.colors=[],L();else if(G.dataset.colorMore!==void 0){const le=G.nextElementSibling,ne=le.classList.contains("hidden");T.querySelectorAll(".color-rule-menu").forEach(re=>re.classList.add("hidden")),T.querySelectorAll("[data-color-more]").forEach(re=>re.setAttribute("aria-expanded","false")),le.classList.toggle("hidden",!ne),G.setAttribute("aria-expanded",String(ne))}else if(G.dataset.colorCopy!==void 0){const le=+G.dataset.colorCopy;f.colors.splice(le+1,0,structuredClone(f.colors[le])),L()}else if(G.dataset.colorUp!==void 0||G.dataset.colorDown!==void 0){const le=Number(G.dataset.colorUp??G.dataset.colorDown),[ne]=f.colors.splice(le,1);f.colors.splice(le+(G.dataset.colorUp!==void 0?-1:1),0,ne),L()}},T.onchange=A=>{const G=A.target;if(G.dataset.operator!==void 0){f.colors[+G.dataset.operator].operator=G.value,L();return}G.dataset.ruleValue!==void 0&&(f.colors[+G.dataset.ruleValue].value=G.value),K()},T.oninput=A=>{const G=A.target;if(G.dataset.ruleValue!==void 0)f.colors[+G.dataset.ruleValue].value=G.value;else return;K()}}function Q(w,x){if(w==="color"){Y(x);return}const T={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[w],I=w==="filter"?f.filters:w==="sort"?f.sorts:w==="group"?f.groups:f.colors,L=I.map((N,A)=>{var ne;const G=w==="sort"?N.colId:w==="group"?N:N.field,_=((ne=u.find(([re])=>re===G))==null?void 0:ne[1])||G,ie=`<button class="field-select" data-pick="${A}">${de(_)}${Ie("down")}</button>`;if(w==="sort")return`<div class="condition">${ie}<button class="sort-direction ${N.sort==="asc"?"selected":""}" data-dir="asc" data-index="${A}">首项 → 末项</button><button class="sort-direction ${N.sort==="desc"?"selected":""}" data-dir="desc" data-index="${A}">末项 → 首项</button><button data-remove="${A}" aria-label="删除条件">${Ie("close")}</button></div>`;if(w==="group")return`<div class="condition">${ie}<span class="spacer"></span><button data-remove="${A}" aria-label="删除条件">${Ie("close")}</button></div>`;const fe=Ve([["contains",g[G]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],N.operator,`data-operator="${A}" aria-label="运算符"`),le=["blank","notBlank"].includes(N.operator)?"":g[G]?Ve([["","请选择目标值"],...g[G].map(re=>[re,re])],N.value,`data-rule-value="${A}" aria-label="目标值"`):`<input data-rule-value="${A}" aria-label="目标值" value="${de(N.value)}" placeholder="请选择目标值">`;return`<div class="condition">${ie}${fe}${le}${w==="color"?`<input type="color" data-color="${A}" value="${N.color}" aria-label="行颜色">`:""}<button data-remove="${A}" aria-label="删除条件">${Ie("close")}</button></div>`}).join(""),H=Ee(x,`设置${T}条件`,`${w==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${f.showTerminated?"checked":""}>显示已终止数据</label>`:""}${L}<button class="add-condition">${Ie("plus")}添加${w==="color"?"着色":T}条件</button>${I.length?'<button class="clear-rules">清空全部条件</button>':""}`,w==="color"?650:560);S=w;const O=()=>Q(w,x);let F=-1;H.querySelectorAll(".condition").forEach((N,A)=>{N.draggable=!0,N.ondragstart=G=>{var _;F=A,(_=G.dataTransfer)==null||_.setData("text/plain",String(A))},N.ondragover=G=>G.preventDefault(),N.ondrop=G=>{if(G.preventDefault(),F<0||F===A)return;const[_]=I.splice(F,1);I.splice(A,0,_),K(),O()}}),H.onclick=N=>{const A=N.target.closest("button");A&&(A.classList.contains("add-condition")&&ut(A,G=>{w==="filter"&&f.filters.push({field:G,operator:"contains",value:""}),w==="sort"&&f.sorts.push({colId:G,sort:"asc"}),w==="group"&&!f.groups.includes(G)&&f.groups.push(G),w==="color"&&f.colors.push({field:G,operator:"contains",value:"",color:"#e9f2ff"}),K(),O()}),A.dataset.pick!==void 0&&ut(A,G=>{const _=+A.dataset.pick;w==="sort"?f.sorts[_].colId=G:w==="group"?f.groups[_]=G:(I[_].field=G,I[_].value=""),K(),O()}),A.dataset.remove!==void 0&&(I.splice(+A.dataset.remove,1),K(),O()),A.classList.contains("clear-rules")&&(I.splice(0),K(),O()),A.dataset.dir&&(f.sorts[+A.dataset.index].sort=A.dataset.dir,K(),O()))},H.onchange=N=>{const A=N.target;A.id==="terminated"&&(f.showTerminated=A.checked),A.dataset.operator!==void 0&&(I[+A.dataset.operator].operator=A.value,O()),A.dataset.ruleValue!==void 0&&(I[+A.dataset.ruleValue].value=A.value),A.dataset.color!==void 0&&(f.colors[+A.dataset.color].color=A.value),K()},H.oninput=N=>{const A=N.target;A.tagName==="INPUT"&&A.dataset.ruleValue!==void 0&&(I[+A.dataset.ruleValue].value=A.value,K())}}function te(){const w=V.api.getDisplayedRowCount(),x=V.api.getAllColumns().filter(A=>A.visible).reduce((A,G)=>A+G.width,0),T=h(".grid-wrap"),I=h(".list-area"),L=getComputedStyle(I),H=Math.max(0,I.clientWidth-parseFloat(L.paddingLeft||"0")-parseFloat(L.paddingRight||"0")),O=Math.max(0,I.clientHeight-T.offsetTop-parseFloat(L.paddingBottom||"0")),F=h(".ag-header-wrapper",T).getBoundingClientRect().height||33,N=Math.max(1,w)*37+F+1;T.style.width=`${Math.min(H,x+1)}px`,T.style.height=`${Math.min(O,N)}px`}function J(){var x;const w=Z().filter(T=>b&&T.name.toLowerCase().includes(b.toLowerCase())).map(T=>T.id);if(k=Math.max(0,Math.min(k,w.length-1)),h("#matches").textContent=b?`${w.length?k+1:0}/${w.length}`:"",s.container.querySelectorAll(".item-name").forEach(T=>{const I=T.hash.replace("#item/","");T.classList.toggle("find-match",w.includes(I)),T.classList.toggle("find-current",w[k]===I)}),w[k]){let T=-1;for(let I=0;I<V.api.getDisplayedRowCount();I++)((x=V.api.getDisplayedRowAtIndex(I))==null?void 0:x.id)===w[k]&&(T=I);T>=0&&V.api.ensureIndexVisible(T)}h('[data-action="previous-match"]').toggleAttribute("disabled",!w.length),h('[data-action="next-match"]').toggleAttribute("disabled",!w.length)}function ae(){const w=V.api.getSelectedRows(),x=h(".selection-bar");x.classList.toggle("hidden",!w.length),x.innerHTML=`${ce("deselect","","close")}<span>已选择 ${w.length} 项</span>${ce("batch-status","更新状态")}${ce("batch-owner","更新负责人")}${ce("batch-export","导出")}${ce("batch-archive","终止")}${ce("deselect","取消选择")}`}function Ce(w){const x=Ee(w,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${V.api.getAllColumns().filter(T=>!T.colId.startsWith("_")).map(T=>`<label class="column-option"><input type="checkbox" data-column="${T.colId}" ${T.visible?"checked":""}><span>${de(T.headerName)}</span><button type="button" data-pin="${T.colId}">${T.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);x.onchange=T=>{const I=T.target;I.dataset.column&&V.columnApi.setColumnVisible(I.dataset.column,I.checked)},x.onclick=T=>{const I=T.target.closest("[data-pin]");if(I){T.preventDefault();const L=V.columnApi.getColumn(I.dataset.pin);V.columnApi.setColumnPinned(L,L.pinned?null:"left"),Ce(w)}},h("input",x).oninput=T=>{const I=T.target.value;x.querySelectorAll(".column-option").forEach(L=>L.hidden=!L.textContent.includes(I))}}function Pe(){t.forEach(w=>{var x;return(x=w.destroy)==null?void 0:x.call(w)}),t=[],M==null||M.remove(),M=null,D=null,j=null,P==null||P.focus(),s.syncLocationHash&&location.hash.startsWith("#item/")&&history.replaceState(null,"",location.pathname+location.search)}function De(w,x="dialog-overlay"){return he(),s.container.querySelectorAll(".field-picker").forEach(T=>T.remove()),t.forEach(T=>{var I;return(I=T.destroy)==null?void 0:I.call(T)}),t=[],M==null||M.remove(),P=document.activeElement,M=document.createElement("div"),M.className=`overlay ${x}`,M.innerHTML=w,M.setAttribute("role","dialog"),M.setAttribute("aria-modal","true"),s.container.append(M),M.addEventListener("click",T=>{T.target===M&&Pe()}),M}function qe(w,x,T){const I=De(`<form class="dialog"><h2>${de(w)}</h2><input aria-label="${de(w)}" value="${de(x)}" required><div class="actions">${ce("close-overlay","取消","","outline")}<button class="primary" type="submit">确定</button></div></form>`);h("form",I).onsubmit=L=>{L.preventDefault();const H=h("input",I).value.trim();H&&(Pe(),T(H))},h("input",I).focus()}function $e(w,x="基本信息"){var H,O;if(s.onOpenDetail){s.onOpenDetail(structuredClone(w));return}w.viewed=!0,U(),D=w,W=x,s.syncLocationHash&&history.replaceState(null,"",`#item/${w.id}`);const T=s.detailForm.fields,I=x==="基本信息"?`<div class="detail-fields">${T.map(F=>{var N,A;return`<div class="detail-row"><label for="detail-${F.field}">${de(F.label||((N=p(F.field))==null?void 0:N.label)||F.field)}${F.required??((A=p(F.field))==null?void 0:A.required)?" *":""}</label>${Pt(F,w,"detail")}</div>`}).join("")}<div class="detail-row" data-block="roles"><label>角色与人员</label><div>提报人  ${q(w.owner)}<p>${ce("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>${ce("add-meeting","添加一组进入选题会","add")}</div><div class="detail-row" data-block="approval"><label>选题是否通过</label><div class="radios">${["是","待定","废弃"].map(F=>`<label><input type="radio" name="approved" value="${F}" data-detail="approved" ${w.approved===F?"checked":""}>${F}</label>`).join("")}</div></div></section><section class="detail-section" data-block="votes"><div class="detail-row"><label>选题投票</label><div>${ce("detail-vote",w.vote?"1":"投票","plus","vote")}</div></div><div class="detail-row"><label>是否展示投票结果</label><div class="radios">${["是","否"].map(F=>`<label><input type="radio" name="showVotes" value="${F}" data-detail="showVotes" ${w.showVotes===F?"checked":""}>${F}</label>`).join("")}</div></div></section><div class="detail-row muted"><label>父级工作项</label><span>暂无关联WBS 父工作项</span></div>`:x==="评论/备注"?`<div class="comment-list">${w.comments.length?w.comments.map(F=>`<article>${q("体验官")}<p>${de(F)}</p></article>`).join(""):'<p class="muted">暂无评论/备注</p>'}</div>`:x==="操作记录"?`<div class="history-list">${w.history.length?w.history.map(F=>`<p>${de(F)}</p>`).join(""):'<p class="muted">暂无操作记录</p>'}</div>`:`<div class="muted">${(H=w.materials)!=null&&H.length?w.materials.map(F=>`<p>${de(F)}</p>`).join(""):"暂无关联素材"}</div>${ce("link-material","关联素材","add","outline")}`,L=De(`<article class="drawer"><div class="drawer-header"><span class="page-logo">${Ie("check")}</span><strong>${de(w.name)}</strong>${z(w.status,"approved")}<span class="muted">已进行 20 天</span><div class="spacer"></div>${ce("follow",w.followed?"已关注":"关注","people",w.followed?"is-set":"")}${ce("star",w.starred?"已收藏":"收藏","book",w.starred?"is-set":"")}${ce("detail-more","","more")}${ce("close-overlay","","close","outline")}</div><div class="detail-navigation">${ce("prev-item","","up")}${ce("next-item","","down")}</div><div class="detail-tabs">${["基本信息","素材管理","评论/备注","操作记录"].map(F=>`<button data-detail-tab="${F}" class="detail-tab ${F===x?"active":""}">${F}</button>`).join("")}<div class="spacer"></div>${q(w.owner)}${ce("detail-status",w.status,"down","primary")}</div><div class="drawer-body">${I}</div><form class="comment-form"><span class="avatar">体验官</span><textarea aria-label="评论" placeholder="请输入评论(Enter 换行,⌘ + Enter 发送)"></textarea><button type="submit">发送</button></form></article>`,"detail-overlay");D=w,j=w,gi(L,w,s.detailForm.fields,"detail"),we();for(const[F,N]of[["roles",s.detailForm.showRoles],["meetings",s.detailForm.showMeetings],["approval",s.detailForm.showApproval],["votes",s.detailForm.showVotes]])N||(O=L.querySelector(`[data-block="${F}"]`))==null||O.remove();L.onchange=F=>{var A;const N=F.target;if(N.dataset.detail){const G=s.detailForm.fields.find(_=>_.field===N.dataset.detail);if(G&&!(G.editable??((A=p(G.field))==null?void 0:A.editable)!==!1))return;if(N.dataset.detail==="name"&&!N.value.trim()){N.value=w.name;return}oe(w,N.dataset.detail,N.value)}},h("form",L).onsubmit=F=>{F.preventDefault();const N=h("textarea",h("form",L)).value.trim();N&&(w.comments.push(N),U(),$e(w,"评论/备注"),ve("评论已添加到本地 demo"))},h("form textarea",L).onkeydown=F=>{F.key==="Enter"&&(F.metaKey||F.ctrlKey)&&(F.preventDefault(),h("form",L).requestSubmit())}}function Pt(w,x,T){return p(w.field)?`<div class="fc-host" data-control-field="${de(w.field)}" data-control-mode="${T}"></div>`:""}function ht(w,x,T){return{field:w,value:x[w.key]??w.defaultValue??"",item:x,surface:T,readonly:w.editable===!1||!!e.resolve(w).readonly,services:s.fieldServices,onSelectedOptions:I=>{var O;if(!((O=s.fieldServices)!=null&&O.searchOptions))return;const L=F=>{F.choices=[...new Map([...F.choices||(F.options||[]).map(N=>({id:N,label:N})),...I].map(N=>[N.id,N])).values()]};L(w);const H=p(w.key);H&&H!==w&&L(H)},openDetail:I=>{const L=c.items.find(H=>H.id===I);L?$e(L):ve("未找到关联工作项")}}}function gi(w,x,T,I){const L=[];for(const H of w.querySelectorAll("[data-control-field]")){const O=T.find(ue=>ue.field===H.dataset.controlField),F=p(O.field),N={...F,label:O.label||F.label,required:O.required??F.required,editable:F.editable!==!1&&O.editable!==!1&&!e.resolve(F).readonly},A=ht(N,x,I==="new"?"create":"detail"),G=e.resolve(N),_=G.createEditor(A);t.push(_),L.push({editor:_,field:N});const ie=_.element.matches("input,select,textarea,[role=textbox]")?_.element:_.element.querySelector("input,select,textarea,[role=textbox]");ie&&(ie.id=`${I}-${N.key}`);const fe=document.createElement("div");fe.className="fc-error",fe.setAttribute("role","status");const le=document.createElement("div");le.className="fc-detail-editor",le.append(_.element,fe),H.append(le);let ne;I==="detail"&&(H.classList.add("fc-detail-host"),ne=document.createElement("div"),ne.className="fc-detail-preview",H.prepend(ne));const re=()=>{if(ne&&(ne.replaceChildren(G.render(ht(N,x,"detail"))),N.editable)){const ue=document.createElement("button");ue.type="button",ue.className="fc-detail-edit",ue.textContent="编辑",ue.ariaLabel=`编辑${N.label}`,ue.onclick=Le=>{var Me;Le.stopPropagation(),H.classList.add("editing"),(Me=_.focus)==null||Me.call(_)},ne.append(ue)}};re();const Te=()=>{var Le;if(!N.editable)return!0;const ue=(Le=_.validate)==null?void 0:Le.call(_);if(fe.textContent=ue||"",!ue&&I==="detail"){const Me=_.read();JSON.stringify(x[N.key])!==JSON.stringify(Me)&&oe(x,N.key,Me),re()}return!ue};if(I==="detail"&&N.editable){const ue=document.createElement("button");ue.type="button",ue.className="fc-detail-done",ue.textContent="完成",ue.onclick=Le=>{Le.stopPropagation(),Te()&&H.classList.remove("editing")},le.append(ue)}H.addEventListener("change",Te),H.addEventListener("focusout",()=>{queueMicrotask(()=>{H.isConnected&&!H.contains(document.activeElement)&&Te()&&H.classList.remove("editing")})})}return()=>{var H,O;for(const{editor:F,field:N}of L){if(!N.editable)continue;const A=(H=F.validate)==null?void 0:H.call(F);if(A)return ve(`${N.label}:${A}`),(O=F.focus)==null||O.call(F),!1}for(const{editor:F,field:N}of L)N.editable&&(x[N.key]=F.read());return!0}}function xt(w,x,T){var G,_;o==null||o(),he();const I=w.closest(".ag-cell")||w,L=[...I.childNodes],H=e.resolve(x).createEditor(ht(x,T,"cell")),O=document.createElement("div");O.className="fc-inline-error",O.setAttribute("role","status");const F=document.createElement("div");F.className="fc-inline-editor",F.append(H.element,O),I.replaceChildren(F),I.classList.add("fc-inline-editing");let N=!1;const A=ie=>{var le,ne;if(N)return;if(ie){const re=(le=H.validate)==null?void 0:le.call(H);if(re){O.textContent=re,H.element.setAttribute("aria-invalid","true");return}}const fe=ie?H.read():void 0;N=!0,o=null,(ne=H.destroy)==null||ne.call(H),I.classList.remove("fc-inline-editing"),I.replaceChildren(...L),ie&&T[x.key]!==fe&&oe(T,x.key,fe)};o=()=>A(!1),F.addEventListener("keydown",ie=>{(ie.key==="Enter"||ie.key==="Escape")&&(ie.preventDefault(),ie.stopPropagation(),A(ie.key==="Enter"))}),F.addEventListener("focusout",ie=>{F.contains(ie.relatedTarget)||A(!0)}),F.addEventListener("click",ie=>ie.stopPropagation()),(G=H.focus)==null||G.call(H),(_=H.element.querySelector("input"))==null||_.select()}function $t(w,x,T){var G;const I=e.resolve(x),L=I.id==="select"||I.id==="multiSelect",H=["dateTime","date","dateRange"].includes(I.id),O=I.id==="richText",F=Ee(w,L||H||O?"":x.label,'<div class="fc-editor-host"></div><div class="fc-error" role="status"></div>'+(L||O?"":'<div class="actions"><button type="button" class="fc-cancel">取消</button><button type="button" class="primary fc-save">保存</button></div>'),O?240:L?272:320,O?"fc-popup fc-rich-popup":L?"fc-popup fc-choice-popup":"fc-popup");if(L||O){const _=w.getBoundingClientRect();F.style.top=`${Math.max(8,Math.min(_.top,innerHeight-360))}px`}const N=I.createEditor({...ht(x,T,"cell"),focusBoundary:F,onDeactivate:()=>{i===N&&(he(),i===N&&he(!1))}});i=N,h(".fc-editor-host",F).append(N.element);const A=(_=!0)=>{var le;const ie=(le=N.validate)==null?void 0:le.call(N);if(h(".fc-error",F).textContent=ie||"",ie)return;const fe=N.read();_&&he(),oe(T,x.key,fe)};O?n=()=>{var fe;const _=(fe=N.validate)==null?void 0:fe.call(N);if(h(".fc-error",F).textContent=_||"",_)return!1;const ie=N.read();return T[x.key]!==ie&&oe(T,x.key,ie),!0}:L?N.element.addEventListener("change",()=>A(I.id==="select")):(h(".fc-cancel",F).onclick=()=>he(!1),h(".fc-save",F).onclick=()=>A(),F.addEventListener("keydown",_=>{_.key==="Enter"&&(_.ctrlKey||_.metaKey||_.target instanceof HTMLInputElement)&&(_.preventDefault(),A())})),(G=N.focus)==null||G.call(N)}function Gt(w="text",x="",T=!1){var Me,st;const I=e.list(),L=I.find(Se=>Se.id===w)||I[0],H=["文本","选择","人员","日期","投票","其他","关联工作项","系统"],O=De(`<section class="control-manager"><header><div><h2>字段控件</h2><p>一套控件,覆盖表格、新建与详情 · ${I.length} 种</p></div>${ce("close-overlay","关闭","close")}</header><div class="control-manager-body"><nav aria-label="字段控件目录"><div class="fc-catalog-search-wrap"><input class="fc-input fc-catalog-search" aria-label="搜索控件" placeholder="搜索字段类型" value="${de(x)}"></div>${H.map(Se=>`<section class="fc-catalog-group" data-group="${Se}"><h4>${Se}</h4>${I.filter(be=>(be.group||"其他")===Se).map(be=>`<button type="button" data-control-id="${de(be.id)}" class="${be.id===L.id?"active":""}" aria-current="${be.id===L.id?"true":"false"}"><span>${de(be.glyph)}</span>${de(be.label)}</button>`).join("")}</section>`).join("")}<p class="fc-catalog-empty fc-empty" hidden>没有匹配的控件</p></nav><main><div class="fc-catalog-heading"><div><h3>${de(L.label)}</h3><p>${de(L.description)}</p></div><span class="fc-catalog-badge">${L.readonly?"系统只读":"可复用"}</span></div><label class="fc-readonly-toggle"><input type="checkbox" ${T?"checked":""}>只读预览</label><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 fc-preview-error" role="status"></div><div class="actions"><button type="button" class="primary fc-preview-save">应用预览</button></div><p class="hint">示例数据仅用于体验。附件上传、投票与远程查询需由宿主接入服务。</p></main></div></section>`),F={key:"preview",label:L.label,kind:L.id,options:["待开始","进行中","已完成"],editable:!L.readonly&&!T,...(Me=L.example)==null?void 0:Me.field},N=L.id==="number"?128:L.id==="multiSelect"?["进行中"]:L.id==="select"?"进行中":L.id==="dateTime"?"2026-09-24T10:30:00":L.id==="richText"?"<p><strong>需求背景</strong></p><p>记录目标、范围与验收条件。</p>":L.id==="detail"?((st=c.items[0])==null?void 0:st.id)||"":"内容示例";L.id==="dateTime"&&(F.dateOptions={showSeconds:!0});const A={...c.items[0],preview:L.example?structuredClone(L.example.value):N},G=Se=>({...ht(F,A,Se),services:void 0,onSelectedOptions:void 0});let _,ie=L.createEditor(G("detail"));t.push(ie),h(".fc-preview-detail",O).append(ie.element);const fe=()=>{const Se=h(".fc-preview-cell",O);Se.replaceChildren(L.render(G("cell")));const be=document.createElement("button");be.type="button",be.textContent="编辑",be.onclick=le,F.editable&&(Se.append(be),Se.ondblclick=le)},le=()=>{var be,Fe;if(!F.editable)return;(be=_==null?void 0:_.destroy)==null||be.call(_),_=L.createEditor(G("cell")),h(L.id==="text"?".fc-preview-cell":".fc-preview-edit",O).replaceChildren(_.element),(Fe=_.focus)==null||Fe.call(_)};t.push({element:O,read:()=>{},destroy:()=>{var Se;return(Se=_==null?void 0:_.destroy)==null?void 0:Se.call(_)}}),fe(),h(".fc-preview-save",O).disabled=!F.editable,h(".fc-preview-save",O).onclick=()=>{var at,Ct,fi;const Se=_||ie,be=(at=Se.validate)==null?void 0:at.call(Se);if(h(".fc-preview-error",O).textContent=be||"",be)return;A.preview=Se.read(),fe(),(Ct=ie.destroy)==null||Ct.call(ie);const Fe=L.createEditor(G("detail"));t.splice(t.indexOf(ie),1,Fe),h(".fc-preview-detail",O).replaceChildren(Fe.element),ie=Fe,(fi=_==null?void 0:_.destroy)==null||fi.call(_),_=void 0,h(".fc-preview-edit",O).replaceChildren()};const ne=h(".fc-catalog-search",O),re=()=>{let Se=0;O.querySelectorAll("[data-control-id]").forEach(be=>{const Fe=I.find(at=>at.id===be.dataset.controlId);be.hidden=!(Fe.label+Fe.id+Fe.description).toLowerCase().includes(ne.value.trim().toLowerCase()),be.hidden||Se++}),O.querySelectorAll(".fc-catalog-group").forEach(be=>be.hidden=!be.querySelector("[data-control-id]:not([hidden])")),h(".fc-catalog-empty",O).hidden=Se>0};ne.oninput=re,re();const Te=O.querySelector("[data-control-id].active"),ue=O.querySelector("nav");Te&&ue&&(ue.scrollTop=Math.max(0,Te.offsetTop-ue.offsetTop-ue.clientHeight/2)),O.querySelectorAll("[data-control-id]").forEach(Se=>Se.onclick=()=>Gt(Se.dataset.controlId,ne.value,T));const Le=h(".fc-readonly-toggle input",O);Le.onchange=()=>Gt(L.id,ne.value,Le.checked)}function je(){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){if(s.canCreate===!1)return;if(s.onCreate){he(!1),s.onCreate();return}const x=w?structuredClone(w):je(),T=De(`<form class="create-dialog"><div class="drawer-header"><span class="page-logo">${Ie("check")}</span><strong>${de(s.title)}</strong><div class="spacer"></div>${ce("drafts","草稿箱","inbox","outline")}${ce("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 H,O,F;return`<div class="create-field ${((H=p(L.field))==null?void 0:H.kind)==="longText"?"extended-field":""}"><label for="new-${L.field}">${de(L.label||((O=p(L.field))==null?void 0:O.label)||L.field)} ${L.required??((F=p(L.field))==null?void 0:F.required)?"<em>*</em>":""}</label>${Pt(L,x,"new")}</div>`}).join("")}${s.createForm.showRoles?`<div class="create-field extended-field"><label>角色与人员</label><div><div class="role-line">${Ve([["提报人","提报人"]],"提报人",'aria-label="角色"')}<div class="role-person">${q(s.currentUser)}</div></div>${ce("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>${ce("add-meeting","添加一组进入选题会","add")}</div></section>`:""}</div><div class="drawer-footer"><label class="continuous"><input id="continuous" type="checkbox">连续创建</label>${ce("close-overlay","取消","","outline")}${ce("save-draft","存草稿","","outline")}<button type="submit" class="primary">确认创建</button></div></form>`);j=x,we();const I=gi(T,x,s.createForm.fields,"new");h("#simple-mode",T).onchange=L=>T.querySelectorAll(".extended-field").forEach(H=>H.classList.toggle("hidden",L.target.checked)),h('[data-action="save-draft"]',T).onclick=()=>{if(!I())return;const L=c.drafts.findIndex(H=>H.id===x.id);L>=0?c.drafts[L]=x:c.drafts.push(x),U(),Pe(),ve("已存入草稿箱")},h("form",T).onsubmit=L=>{if(L.preventDefault(),!I())return;if(!x.name.trim()){h("#new-name",T).focus();return}const H=h("#continuous",T).checked;c.items.unshift(x),c.drafts=c.drafts.filter(O=>O.id!==x.id),U(),K(),Pe(),ve("创建成功"),H&&(pt(),h("#continuous").checked=!0)}}function we(){if(!M||!j)return;const w=j;for(const[x,T]of[["roles",".extra-roles"],["meetings",".meeting-rows"]]){const I=M.querySelector(T);if(!I)continue;const L=w[x]||[];I.innerHTML=L.map((H,O)=>`<div class="role-line"><input data-relation-index="${O}" data-relation-field="name" aria-label="${x==="roles"?"角色名称":"选题会"}" placeholder="${x==="roles"?"角色名称":"选择选题会"}" value="${de(H.name)}"><input data-relation-index="${O}" data-relation-field="person" aria-label="人员" value="${de(H.person)}"><button type="button" data-relation-remove="${O}" aria-label="移除">×</button></div>`).join(""),I.onchange=H=>{const O=H.target,F=Number(O.dataset.relationIndex);O.dataset.relationField&&(L[F][O.dataset.relationField]=O.value,D&&U())},I.onclick=H=>{const O=H.target.closest("[data-relation-remove]");O&&(L.splice(Number(O.dataset.relationRemove),1),we(),D&&U())}}}function gt(w){if(s.onSaveView){s.onSaveView({...structuredClone(f),columns:V.columnApi.getColumnState()});return}const x=Ee(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>${ce("close-popup","取消","","outline")}</div></form>`,380);h("form",x).onsubmit=T=>{T.preventDefault();const I=h('input[name="name"]',x).value.trim();I&&(c.views.push({name:I,state:structuredClone(f),columns:V.columnApi.getColumnState(),gridState:V.api.getState(),tab:m,search:b,filterSearch:R,collaborators:h('[name="collaborators"]',x).value,visibility:h('[name="visibility"]:checked',x).value}),U(),ft(),he(),ve("视图已保存"))}}function ft(){h('[data-action="saved-views"]').classList.toggle("hidden",s.showSavedViews===!1||!c.views.length)}document.addEventListener("contextmenu",w=>{if(!s.container.contains(w.target))return;const x=w.target.closest("[data-view]");if(!x)return;w.preventDefault();const T=Number(x.dataset.view),I=c.views[T],L=Ee(x,I.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=H=>{var F;const O=(F=H.target.closest("[data-view-menu]"))==null?void 0:F.dataset.viewMenu;if(O){if(he(),O==="rename"&&qe("重命名视图",I.name,N=>{I.name=N,U(),ft()}),O==="duplicate"){const N=structuredClone(I);N.name+="(副本)",c.views.push(N),U(),ft()}O==="remove"&&(c.views.splice(T,1),U(),ft(),ve("视图已删除"))}}},{signal:l.signal});function ot(w,x,T,I){const L=p(x);if(L){if(L.editable===!1||e.resolve(L).readonly){ve("系统字段,不支持修改");return}if(L.kind==="vote"){oe(T,x,T[x]?"":s.currentUser);return}["text","number"].includes(e.resolve(L).id)?xt(w,L,T):$t(w,L,T)}}h("#grid").addEventListener("keydown",w=>{if(!["Enter","F2"].includes(w.key)||w.target.closest("button,input,textarea,select"))return;const x=w.target.closest(".ag-cell[data-colid]"),T=x==null?void 0:x.closest("[data-rowid]"),I=c.items.find(L=>L.id===(T==null?void 0:T.dataset.rowid));x&&I&&(w.preventDefault(),ot(x,x.dataset.colid,I))},{capture:!0,signal:l.signal});function mt(){h("#grid").querySelectorAll(".ag-header-cell").forEach(w=>{var H,O;const x=w.dataset.colid;if(x==="_add"){if(!w.querySelector(".work-add-column")){const F=w.querySelector(".ag-header-cell-label"),N=document.createElement("button");N.type="button",N.className="work-add-column",N.ariaLabel="新增字段",N.title="新增字段",N.innerHTML=Ie("add"),N.onmousedown=A=>A.stopPropagation(),N.onclick=A=>{A.stopPropagation(),Et(N,"_add",!1)},F.replaceChildren(N)}return}if(!p(x))return;if(!w.querySelector(".work-header-sort")){const F=document.createElement("span");F.className="work-header-sort",(H=w.querySelector(".ag-header-cell-label"))==null||H.append(F);const N=document.createElement("button");N.className="work-header-menu",N.ariaLabel=`${p(x).label}操作`,N.innerHTML=Ie("more"),N.onclick=G=>{G.stopPropagation(),Ke(N,x)},N.onmousedown=G=>G.stopPropagation(),w.append(N);for(const G of["right","left"]){const _=document.createElement("button");_.className="work-header-add",_.dataset.insertSide=G,_.ariaLabel=`在${p(x).label}${G==="right"?"右":"左"}侧插入列`,_.title="插入列",_.innerHTML=Ie("add"),_.onclick=ie=>{ie.stopPropagation(),Et(_,x,G==="right")},_.onmousedown=ie=>ie.stopPropagation(),w.append(_)}const A=()=>{const G=w.getBoundingClientRect(),_=h(".grid-wrap").getBoundingClientRect(),fe=w.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();w.querySelectorAll(".work-header-add").forEach(le=>{const ne=le.dataset.insertSide==="left"?G.left:G.right;le.style.left=`${ne-12}px`,le.style.top=`${G.top-20}px`,le.style.setProperty("--insert-line-height",`${Math.max(0,_.bottom-G.top+8)}px`),le.style.display=ne<Math.max(_.left,fe.left)-1||ne>Math.min(_.right,fe.right)+1?"none":""}),w.classList.add("insert-points-ready")};w.addEventListener("mouseenter",A),w.addEventListener("focusin",A),w.addEventListener("click",G=>{var ie;if(G.target.closest("button,.ag-header-cell-resize"))return;G.stopImmediatePropagation();const _=(ie=f.sorts.find(fe=>fe.colId===x))==null?void 0:ie.sort;f.sorts=_==="desc"?[]:[{colId:x,sort:_==="asc"?"desc":"asc"}],K()},{capture:!0})}const T=(O=f.sorts.find(F=>F.colId===x))==null?void 0:O.sort,I=w.querySelector(".work-header-sort"),L=T==="asc"?"↑":T==="desc"?"↓":"↕";I.textContent!==L&&(I.textContent=L),I.classList.toggle("sorted",!!T),w.setAttribute("aria-sort",T==="asc"?"ascending":T==="desc"?"descending":"none")})}function Et(w,x,T){he();const I=H=>{var N;const F=V.columnApi.getColumnState().findIndex(A=>A.colId===x)+(T?1:0);V.columnApi.setColumnVisible(H,!0),V.columnApi.setColumnPinned(H,x==="_add"?null:((N=V.columnApi.getColumn(x))==null?void 0:N.pinned)??null),V.columnApi.moveColumn(H,Math.max(1,F)),he(),te(),mt()};ut(w,I,{available:H=>{var O;return!((O=V.columnApi.getColumn(H))!=null&&O.visible)},onCreate:()=>{const H=Ee(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(ne=>`<option value="${de(ne.id)}">${de(ne.label)}</option>`).join("")}</select></label><label>选项(每行一个)<textarea name="options" aria-label="字段选项"></textarea></label><label class="choice-limit hidden">最多可选数量<input name="maxSelections" type="number" min="1" step="1" placeholder="不限" aria-label="最多可选数量"></label><button class="primary" type="submit">确认创建</button></form>`,320),O=h('[name="kind"]',H),F=h('[name="options"]',H),N=F.closest("label"),A=document.createElement("div");A.className="fc-field-schema",A.hidden=!0,A.innerHTML='<p class="hint">每组记录包含以下子字段</p><div class="fc-field-schema-rows"></div><button type="button" class="fc-composite-add">+ 添加子字段</button>';const G=e.list().filter(ne=>!ne.readonly&&!["composite","multiPersonComposite","attitudeVote","singleVote","multiVote","detail"].includes(ne.id)),_=()=>{const ne=document.createElement("div");ne.className="fc-field-schema-row",ne.innerHTML='<input class="fc-input" aria-label="子字段名称" placeholder="子字段名称"><select class="fc-input" aria-label="子字段类型">'+G.map(re=>'<option value="'+de(re.id)+'">'+de(re.label)+"</option>").join("")+'</select><button type="button" aria-label="移除子字段">×</button>',ne.querySelector("button").onclick=()=>ne.remove(),A.querySelector(".fc-field-schema-rows").append(ne)};A.querySelector("button").onclick=_,_();const ie=document.createElement("p");ie.className="fc-service-note";const fe=document.createElement("p");fe.className="fc-error",fe.setAttribute("role","status"),h("form",H).insertBefore(A,h('button[type="submit"]',H)),h("form",H).insertBefore(ie,h('button[type="submit"]',H)),h("form",H).insertBefore(fe,h('button[type="submit"]',H));const le=()=>{const ne=O.value,re=ne==="cascadeSingle"||ne==="cascadeMulti";N.hidden=!re&&!["select","multiSelect","radio","singleVote","multiVote","person","multiPerson","relation","multiRelation"].includes(ne),F.placeholder=re?"每行一条路径,例如:产品 / 设计 / 交互":"每行一个选项",h(".choice-limit",H).classList.toggle("hidden",!["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(ne)),A.hidden=!["composite","multiPersonComposite"].includes(ne),ie.textContent=re?"用 / 分隔层级;同名上级会合并。":ne==="attachment"?"上传操作由宿主上传服务提供。":ne.endsWith("Vote")?"投票操作由宿主投票服务提供。":"",fe.textContent=""};O.onchange=le,le(),h("form",H).onsubmit=ne=>{ne.preventDefault();const re=new FormData(ne.target),Te=String(re.get("label")||"").trim();if(!Te)return;const ue=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,Le=String(re.get("kind")),Me={key:ue,label:Te,kind:Le,editable:!e.resolve({key:ue,label:Te,kind:Le}).readonly,width:160};["select","multiSelect","person","multiPerson","radio","singleVote","multiVote","relation","multiRelation"].includes(Le)&&(Me.options=[...new Set(String(re.get("options")||"").split(`
121
- `).map(be=>be.trim()).filter(Boolean))]);const st=Number(re.get("maxSelections"));if(["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(Le)&&Number.isInteger(st)&&st>0&&(Me.maxSelections=st),Le==="dateTime"&&(Me.dateOptions={showTime:!0,showSeconds:!0}),Le==="cascadeSingle"||Le==="cascadeMulti"){Me.choices=[];for(const be of F.value.split(`
122
- `).filter(Fe=>Fe.trim())){let Fe=Me.choices;const at=be.split("/").map(Ct=>Ct.trim()).filter(Boolean);at.forEach((Ct,fi)=>{let kt=Fe.find(Qa=>Qa.id===Ct);kt||(kt={id:Ct,label:Ct},Fe.push(kt)),fi<at.length-1&&(kt.children??(kt.children=[]),Fe=kt.children)})}if(!Me.choices.length){fe.textContent="请至少填写一条分类路径";return}}if(Le==="composite"||Le==="multiPersonComposite"){const be=[...A.querySelectorAll(".fc-field-schema-row")];if(!be.length||be.some(Fe=>!Fe.querySelector("input").value.trim())){fe.textContent="请填写子字段名称";return}Me.compositeFields=be.map((Fe,at)=>({key:"sub_"+at,label:Fe.querySelector("input").value.trim(),kind:Fe.querySelector("select").value})),Le==="multiPersonComposite"&&Me.compositeFields.unshift({key:"owner",label:"填写人",kind:"person",required:!0})}s.fields.push(Me),u.push([ue,Te]),Me.options&&(g[ue]=Me.options),c.customFields.push(Me);const Se=V.columnApi.getColumnState();V.api.setColumnDefs(se()),V.columnApi.applyColumnState(Se,!0),I(ue),U(),K()}}})}function Ke(w,x){const T=V.columnApi.getColumn(x);if(!T||x==="_select")return;if(x==="_add"){Et(w,x,!1);return}const I=["向左插入列","向右插入列",g[x]?"以 首项 → 末项 排序":"以 A → Z 排序",g[x]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",T.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],L=Ee(w,"",[[0,1],[2,3],[4,8],[5,6,7]].map(H=>H.map(O=>`<button class="menu-option${O===7?" destructive":""}" data-col-menu="${O}" ${O===7&&x==="name"?"disabled":""}>${I[O]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");L.dataset.headerMenu="true",L.onclick=H=>{const O=H.target.closest("[data-col-menu]");if(!O)return;const F=+O.dataset.colMenu;he(),(F===0||F===1)&&Et(w,x,F===1),(F===2||F===3)&&(f.sorts=[{colId:x,sort:F===2?"asc":"desc"}],K()),F===4&&(f.filters.push({field:x,operator:"contains",value:""}),Q("filter",h('[data-action="filter"]'))),F===5&&V.columnApi.setColumnPinned(x,T.pinned?null:"left"),F===6&&qe("编辑列",T.headerName,N=>{const A=p(x);A&&(A.label=N);const G=V.api.getColumnDefs(),_=G.find(fe=>fe.field===x);_&&(_.headerName=N);const ie=V.columnApi.getColumnState();V.api.setColumnDefs(G),V.columnApi.applyColumnState(ie,!0),mt()}),F===7&&V.columnApi.setColumnVisible(x,!1),F===8&&(f.groups.includes(x)||f.groups.push(x),K())}}h("#grid").addEventListener("contextmenu",w=>{const x=w.target.closest(".ag-header-cell");if(x){w.preventDefault();const T=x.getAttribute("col-id")||x.dataset.colid||x.dataset.colId||"";Ke(x,T)}else{const T=w.target.closest(".ag-cell");if(T){w.preventDefault();const I=Ee(T,"单元格",ce("copy-cell","复制")+ce("paste-cell","粘贴")+ce("export","导出表格"),200);h('[data-action="copy-cell"]',I).onclick=async()=>{try{await navigator.clipboard.writeText(T.textContent||""),ve("已复制")}catch{ve("复制失败,请使用 ⌘C")}he()}}}}),h("#grid").addEventListener("dblclick",w=>{var O;const x=w.target.closest(".ag-cell");if(!x||w.target.closest("input,textarea,select,.ag-cell-edit-input"))return;const T=x.dataset.colid,I=c.items.find(F=>{var N;return F.id===((N=x.closest(".ag-row"))==null?void 0:N.dataset.rowid)});if(!I||!p(T))return;clearTimeout(E),w.stopImmediatePropagation(),w.preventDefault();const L=V.api.getDisplayedRowCount();let H=0;for(;H<L&&((O=V.api.getDisplayedRowAtIndex(H))==null?void 0:O.id)!==I.id;H++);ot(x,T,I)},{capture:!0,signal:l.signal}),document.addEventListener("click",w=>{s.container.querySelectorAll(".field-picker").forEach(x=>{x.contains(w.target)||x.remove()}),h("#grid").contains(w.target)||(V.api.getCellRanges().length&&V.api.clearRangeSelection(),V.api.getFocusedCell()&&V.api.clearFocusedCell()),(y==null?void 0:y.dataset.headerMenu)==="true"&&!y.contains(w.target)&&he()},{capture:!0,signal:l.signal}),document.addEventListener("click",async w=>{const x=w.target,T=N=>w.composedPath().some(A=>A instanceof Element&&A.matches(N));if(!w.composedPath().includes(s.container)){he();return}T(".popup,.field-picker,.toolbar,.ag-cell,.ag-header-cell,.list-bottom,.create-button")||he();const I=x.closest("[data-tab]");if(I){m=I.dataset.tab,s.container.querySelectorAll("[data-tab]").forEach(N=>{N.classList.toggle("active",N===I),N.setAttribute("aria-selected",String(N===I))}),K();return}const L=x.closest("[data-view]");if(L){const N=c.views[+L.dataset.view];f=structuredClone(N.state),m=N.tab||"全部",b=N.search||"",R=!!N.filterSearch,s.container.querySelectorAll("[data-tab]").forEach(A=>{A.classList.toggle("active",A.dataset.tab===m),A.setAttribute("aria-selected",String(A.dataset.tab===m))}),h("#search").value=b,h("#filter-search").checked=R,h(".search-wrap").classList.toggle("hidden",!b),h('[data-action="search"]').classList.toggle("hidden",!!b),he(),K(),N.gridState?V.api.setState(N.gridState):N.columns&&V.columnApi.applyColumnState(N.columns,!0),J();return}const H=x.closest("[data-detail-tab]");if(H&&D){$e(D,H.dataset.detailTab);return}const O=x.closest("[data-action]");if(!O)return;const F=O.dataset.action;if(["filter","sort","group","color"].includes(F)){S===F?he():Q(F,O);return}switch(F){case"controls":if(s.allowCustomFields===!1)break;Gt();break;case"close-popup":he();break;case"create":pt();break;case"create-menu":if(s.canCreate===!1)break;if(s.onCreate){pt();break}Ee(O,"新建",ce("create","新建选题","plus","menu-option")+ce("drafts","草稿箱","inbox","menu-option"),180);break;case"drafts":{const N=De(`<section class="dialog"><h2>草稿箱</h2>${c.drafts.length?c.drafts.map((A,G)=>`<button class="menu-option" data-draft="${G}">${de(A.name||"未命名选题")}</button>`).join(""):'<p class="muted">暂无草稿</p>'}<div class="actions">${ce("close-overlay","关闭","","outline")}</div></section>`);N.onclick=A=>{const G=A.target.closest("[data-draft]");G&&pt(c.drafts[+G.dataset.draft])};break}case"close-overlay":Pe();break;case"search":h(".search-wrap").classList.remove("hidden"),O.classList.add("hidden"),h("#search").focus();break;case"close-search":b="",R=!1,h("#search").value="",h("#filter-search").checked=!1,h(".search-wrap").classList.add("hidden"),h('[data-action="search"]').classList.remove("hidden"),K();break;case"previous-match":k--,J();break;case"next-match":k++,J();break;case"reset":f=Yn(),K(),he();break;case"columns":case"layout":Ce(O);break;case"save-view":case"pin-view":gt(O);break;case"saved-views":Ee(O,"切换视图",c.views.map((N,A)=>`<button class="menu-option" data-view="${A}">${Ie("table")}<span>${de(N.name)}</span></button>`).join(""),260);break;case"share":{const N=Ee(O,"分享工作项列表",`<input readonly value="${de(location.href.split("#")[0])}" aria-label="分享链接"><p class="hint">复制此 demo 的访问地址</p><button class="primary" id="copy-link">复制链接</button>`,380);h("#copy-link",N).onclick=async()=>{try{await navigator.clipboard.writeText(location.href.split("#")[0]),ve("链接已复制"),he()}catch{h("input",N).select(),ve("请按 ⌘C 复制链接")}};break}case"deselect":V.api.deselectAll();break;case"batch-status":case"batch-owner":{const N=F==="batch-status"?"status":"owner",A=V.api.getSelectedRows(),G=Ee(O,"批量更新",g[N].map(_=>`<button class="menu-option" data-batch-value="${_}">${_}</button>`).join(""),220);G.onclick=_=>{const ie=_.target.closest("[data-batch-value]");ie&&(A.forEach(fe=>{fe[N]=ie.dataset.batchValue,fe.history.push(`批量更新${N}:${fe[N]}`)}),U(),K(),he(),ve(`已更新 ${A.length} 项`))};break}case"batch-archive":{const N=V.api.getSelectedRows();N.forEach(A=>A.status="已终止"),U(),K(),ve(`已终止 ${N.length} 项,可在筛选中显示`);break}case"batch-export":V.api.exportToCsv({fileName:"选题库.csv",onlySelected:!0,columnKeys:u.map(([N])=>N)});break;case"export":V.api.exportToCsv({fileName:"选题库.csv",columnKeys:u.map(([N])=>N)}),he();break;case"paste-cell":V.api.pasteFromClipboard(),he();break;case"follow":D&&(D.followed=!D.followed,U(),$e(D,W));break;case"star":D&&(D.starred=!D.starred,U(),$e(D,W));break;case"detail-vote":D&&(oe(D,"vote",D.vote?"":"体验官"),$e(D));break;case"detail-status":D&&pi(O,"status",D);break;case"prev-item":case"next-item":if(D){const N=c.items.indexOf(D)+(F==="prev-item"?-1:1);c.items[N]&&$e(c.items[N],W)}break;case"detail-more":Ee(O,"更多操作",ce("duplicate","复制工作项","","menu-option")+ce("terminate-item","终止工作项","","menu-option"),220);break;case"duplicate":if(D){const N=structuredClone(D);N.id=crypto.randomUUID(),N.name+="(副本)",N.comments=[],N.history=[],c.items.unshift(N),U(),K(),$e(N)}break;case"terminate-item":D&&(oe(D,"status","已终止"),Pe(),ve("工作项已终止"));break;case"add-role":j&&(j.roles??(j.roles=[]),j.roles.push({name:"",person:s.currentUser}),we(),D&&U());break;case"add-meeting":j&&(j.meetings??(j.meetings=[]),j.meetings.push({name:"",person:s.currentUser}),we(),D&&U());break;case"link-material":{const N=D;N&&qe("关联素材","",A=>{N.materials??(N.materials=[]),N.materials.push(A),N.history.push(`关联素材:${A}`),U(),$e(N,"素材管理")});break}}},{signal:l.signal}),h("#search").oninput=w=>{b=w.target.value,k=0,R?K():J()},h("#filter-search").onchange=w=>{R=w.target.checked,K()},document.addEventListener("keydown",w=>{if(s.container.contains(w.target)&&(w.key==="Escape"&&(s.container.querySelector(".field-picker")?s.container.querySelectorAll(".field-picker").forEach(x=>x.remove()):y?he(!1):M&&Pe()),w.key==="Tab"&&M)){const x=[...M.querySelectorAll('button:not([disabled]),input,select,textarea,[tabindex="0"]')].filter(L=>L.offsetParent!==null),T=x[0],I=x[x.length-1];w.shiftKey&&document.activeElement===T?(w.preventDefault(),I==null||I.focus()):!w.shiftKey&&document.activeElement===I&&(w.preventDefault(),T==null||T.focus())}},{signal:l.signal}),window.addEventListener("pagehide",()=>V.grid.destroy(),{once:!0,signal:l.signal});const Ne=h("#grid .ag-body-viewport"),vt=h(".grid-wrap"),Xe=document.createElement("div");Xe.className="work-horizontal-scrollbar",Xe.setAttribute("aria-label","横向滚动表格");const eo=document.createElement("div");Xe.append(eo),vt.append(Xe);const Ye=document.createElement("div");Ye.className="work-vertical-scrollbar",Ye.setAttribute("aria-label","纵向滚动表格");const to=document.createElement("div");Ye.append(to),vt.append(Ye);const io=()=>{const w=Ne.getBoundingClientRect(),x=vt.getBoundingClientRect();Xe.style.left=`${w.left-x.left-1}px`,Xe.style.width=`${Ne.clientWidth}px`,eo.style.width=`${Ne.scrollWidth}px`,Xe.hidden=Ne.scrollWidth<=Ne.clientWidth,Xe.scrollLeft=Ne.scrollLeft,Ye.style.top=`${w.top-x.top-1}px`,Ye.style.height=`${Ne.clientHeight}px`,to.style.height=`${Ne.scrollHeight}px`,Ye.hidden=Ne.scrollHeight<=Ne.clientHeight,Ye.scrollTop=Ne.scrollTop};Xe.addEventListener("scroll",()=>{V.grid.setHorizontalScrollLeft(Xe.scrollLeft)},{passive:!0,signal:l.signal}),Ye.addEventListener("scroll",()=>{Ne.scrollTop=Ye.scrollTop},{passive:!0,signal:l.signal});let zi=0;Ne.addEventListener("pointermove",w=>{const x=Ne.getBoundingClientRect();Ne.classList.toggle("scrollbar-near-right",x.right-w.clientX<=16),Ne.classList.toggle("scrollbar-near-bottom",x.bottom-w.clientY<=16),vt.classList.toggle("scrollbar-near-right",x.right-w.clientX<=16),vt.classList.toggle("scrollbar-near-bottom",x.bottom-w.clientY<=16)},{signal:l.signal}),Ne.addEventListener("pointerleave",()=>{Ne.classList.remove("scrollbar-near-right","scrollbar-near-bottom"),vt.classList.remove("scrollbar-near-right","scrollbar-near-bottom")},{signal:l.signal}),Ne.addEventListener("scroll",()=>{Ne.classList.add("scrollbar-scrolling"),vt.classList.add("scrollbar-scrolling"),Xe.scrollLeft=Ne.scrollLeft,Ye.scrollTop=Ne.scrollTop,clearTimeout(zi),zi=window.setTimeout(()=>{Ne.classList.remove("scrollbar-scrolling"),vt.classList.remove("scrollbar-scrolling")},900)},{passive:!0,signal:l.signal});const no=()=>{h("#grid").querySelectorAll(".insert-points-ready").forEach(w=>w.classList.remove("insert-points-ready"))};window.addEventListener("scroll",no,{capture:!0,signal:l.signal}),window.addEventListener("resize",no,{signal:l.signal});const Rt=new ResizeObserver(()=>{te(),io()});Rt.observe(h(".list-area")),Rt.observe(h(".toolbar")),Rt.observe(h(".list-tabs")),Rt.observe(h(".ag-header-wrapper")),Rt.observe(Ne),Rt.observe(h(".ag-body-container")),io();const oo=new window.MutationObserver(()=>mt());oo.observe(h("#grid .ag-header"),{childList:!0,subtree:!0}),mt(),h('[data-action="controls"]').classList.toggle("hidden",s.allowCustomFields===!1);for(const w of["create","create-menu"])h(`[data-action="${w}"]`).disabled=s.canCreate===!1;if(ft(),s.initialView&&K(),te(),s.syncLocationHash&&location.hash.startsWith("#item/")){const w=c.items.find(x=>x.id===location.hash.slice(6));w&&$e(w)}return{registerControl:w=>{e.register(w),V.api.refreshCells({force:!0})},getControls:()=>e.list(),api:V.api,columnApi:V.columnApi,getViewState:()=>({...structuredClone(f),columns:V.columnApi.getColumnState()}),getItems:()=>structuredClone(c.items),setItems:w=>{r||(c.items=structuredClone(w),K())},destroy:()=>{r=!0,o==null||o(),oo.disconnect(),Rt.disconnect(),l.abort(),clearTimeout(B),clearTimeout(E),clearTimeout(zi),he(),Pe(),V.grid.destroy(),s.container.replaceChildren(),s.container.classList.remove("rowvia-work-items")}}}const Ka={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 Zn(s){return{container:s,title:"选题库",workspace:"内容制作全流程",currentUser:"体验官",storageKey:"rowvia:work-items:v3",items:hi,fields:[...Oa.map(([e,t])=>({key:e,label:t,kind:Ka[e],width:120,minWidth:80,pinned:e==="name"?"left":null,editable:!["created","creator","space"].includes(e),required:e==="name",options:Ba[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 ja(s){const e=Zn(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(hi[o%hi.length]),l=i(o);return{...a,id:`date-demo-${String(o+1).padStart(4,"0")}`,name:`${a.name} · ${String(o+1).padStart(4,"0")}`,singleDate:l,dateTime:`${l}T${String(o%24).padStart(2,"0")}:${String(o%60).padStart(2,"0")}`,dateRange:[l,i(o+o%15)]}}),e}function Vi(s,e){const t=new Nt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function Xa(s,e){ni[s]=e}function Ya(s,e){rt[s]=e}pe.CELL_EDITORS=rt,pe.CELL_RENDERERS=ni,pe.DEFAULT_LOCALE_TEXT=nn,pe.FORMULA_FUNCTIONS=Zt,pe.GANTT_UNITS=mn,pe.GanttChart=wn,pe.Grid=Nt,pe.UNIT_LABEL=si,pe.computeStickyGroupRows=an,pe.createControlRegistry=Xn,pe.createDetailDialog=gn,pe.createFinancePage=pa,pe.createGantt=Js,pe.createGrid=Vi,pe.createHrPage=ga,pe.createInventoryPage=wa,pe.createPerformancePage=Ra,pe.createPersonnelSchedule=ea,pe.createServerSidePage=ka,pe.createSparklineSvg=bi,pe.createWorkItemPage=qa,pe.dateDemoConfig=ja,pe.default=Nt,pe.evaluateFormula=Bt,pe.formatNumberCommas=Qe,pe.isFormula=Ci,pe.parse=ji,pe.registerEditor=Ya,pe.registerFormulaFunction=po,pe.registerRenderer=Xa,pe.sanitizeRichText=Xt,pe.tokenize=qi,pe.topicDemoConfig=Zn,Object.defineProperties(pe,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
94
+ <button type="button" class="color-swatch" data-color="${M}" style="background-color:${H(R.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
95
+ <button type="button" class="field-select" data-color-scope="${M}" aria-label="着色范围" aria-expanded="false">${!R.scope||R.scope==="row"?"整行":"单元格"}${me("down")}</button>
96
+ <button class="field-select ${T?"":"empty"}" data-pick="${M}">${H(T||"请选择筛选项")}${me("down")}</button>
97
+ ${Pt(W,R.field?R.operator:"",`data-operator="${M}" aria-label="运算符" ${R.field?"":"disabled"}`)}
98
+ ${x}
99
+ <button class="color-remove" data-remove="${M}" aria-label="删除条件" title="删除条件">${me("close")}</button>
100
+ <div class="color-more-wrap"><button class="color-more" data-color-more="${M}" aria-label="更多条件操作" aria-expanded="false">${me("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${M}">复制条件</button><button data-color-up="${M}" ${M===0?"disabled":""}>上移</button><button data-color-down="${M}" ${M===u.colors.length-1?"disabled":""}>下移</button></div></div>
101
+ </div>`}).join(""),g=l(f,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${h}</div><div class="color-panel-footer"><button class="add-condition">${me("plus")}添加着色条件</button><button class="clear-rules" ${u.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");g.ariaLabel="设置颜色条件",s.setActiveRulePanel("color");const v=()=>c(f),m=()=>{r(),v()},C=["#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"],S=()=>{var R;(R=g.querySelector(".color-palette"))==null||R.remove(),g.querySelectorAll("[data-color]").forEach(M=>M.setAttribute("aria-expanded","false"))},b=()=>{var R,M,T;(R=g.querySelector(".color-scope-picker"))==null||R.remove(),(T=(M=s.getPopupEditor())==null?void 0:M.destroy)==null||T.call(M),s.setPopupEditor(null),g.querySelectorAll("[data-color-scope]").forEach(W=>W.setAttribute("aria-expanded","false"))};let y=-1;g.querySelectorAll(".color-condition").forEach((R,M)=>{R.ondragstart=T=>{var W;y=M,(W=T.dataTransfer)==null||W.setData("text/plain",String(M))},R.ondragover=T=>T.preventDefault(),R.ondrop=T=>{if(T.preventDefault(),y<0||y===M)return;const[W]=u.colors.splice(y,1);u.colors.splice(M,0,W),m()}}),g.onclick=R=>{var W,E,x;R.stopPropagation();const M=R.target.closest("button");if(R.target.closest(".color-scope-picker"))return;const T=(M==null?void 0:M.getAttribute("aria-expanded"))==="true";if(b(),!M||M.disabled){S();return}if(M.dataset.colorScope!==void 0){if(S(),T)return;const k=Number(M.dataset.colorScope),$=u.colors[k],q={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},F=n.resolve(q).createEditor({field:q,value:!$.scope||$.scope==="row"?"整行":"单元格",item:o(),surface:"cell",readonly:!1,openDetail:()=>{}});s.setPopupEditor(F);const G=document.createElement("div");G.className="popup fc-popup fc-choice-popup color-scope-picker",G.style.width="272px",G.append(F.element),g.append(G);const I=M.getBoundingClientRect();G.style.left=`${Math.max(8,Math.min(I.left,innerWidth-280))}px`,G.style.top=`${Math.max(8,Math.min(I.bottom+6,innerHeight-G.offsetHeight-8))}px`,M.setAttribute("aria-expanded","true"),F.element.addEventListener("change",L=>{var D,z,U;L.stopPropagation(),!((D=F.validate)!=null&&D.call(F))&&($.scope=F.read()==="整行"?"row":"cell",m(),(U=(z=s.popup())==null?void 0:z.querySelector(`[data-color-scope="${k}"]`))==null||U.focus())}),G.onkeydown=L=>{L.key==="Escape"&&(L.stopPropagation(),b(),M.focus())},(W=F.focus)==null||W.call(F);return}if(M.dataset.paletteColor!==void 0){const k=Number(M.closest(".color-palette").dataset.ruleIndex);u.colors[k].color=M.dataset.paletteColor,m(),(x=(E=s.popup())==null?void 0:E.querySelector(`[data-color="${k}"]`))==null||x.focus();return}if(M.dataset.color!==void 0){const k=M.getAttribute("aria-expanded")==="true";if(S(),k)return;const $=Number(M.dataset.color),q=document.createElement("div");q.className="color-palette",q.dataset.ruleIndex=String($),q.setAttribute("role","group"),q.ariaLabel="选择着色颜色",q.innerHTML=C.map(G=>`<button type="button" class="color-palette-option" data-palette-color="${G}" style="background-color:${G}" aria-label="颜色 ${G}" aria-pressed="${G===u.colors[$].color.toLowerCase()}"></button>`).join(""),g.append(q);const F=M.getBoundingClientRect();q.style.left=`${Math.max(8,Math.min(F.left,innerWidth-q.offsetWidth-8))}px`,q.style.top=`${Math.max(8,Math.min(F.bottom+6,innerHeight-q.offsetHeight-8))}px`,M.setAttribute("aria-expanded","true"),q.onkeydown=G=>{G.key==="Escape"&&(G.stopPropagation(),S(),M.focus())};return}if(S(),M.classList.contains("add-condition"))u.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),m();else if(M.dataset.pick!==void 0){const k=+M.dataset.pick;a(M,$=>{u.colors[k].field=$,u.colors[k].value="",u.colors[k].operator="contains",m()})}else if(M.dataset.remove!==void 0)u.colors.splice(+M.dataset.remove,1),m();else if(M.classList.contains("clear-rules"))u.colors=[],m();else if(M.dataset.colorMore!==void 0){const k=M.nextElementSibling,$=k.classList.contains("hidden");g.querySelectorAll(".color-rule-menu").forEach(q=>q.classList.add("hidden")),g.querySelectorAll("[data-color-more]").forEach(q=>q.setAttribute("aria-expanded","false")),k.classList.toggle("hidden",!$),M.setAttribute("aria-expanded",String($))}else if(M.dataset.colorCopy!==void 0){const k=+M.dataset.colorCopy;u.colors.splice(k+1,0,structuredClone(u.colors[k])),m()}else if(M.dataset.colorUp!==void 0||M.dataset.colorDown!==void 0){const k=Number(M.dataset.colorUp??M.dataset.colorDown),[$]=u.colors.splice(k,1);u.colors.splice(k+(M.dataset.colorUp!==void 0?-1:1),0,$),m()}},g.onchange=R=>{const M=R.target;if(M.dataset.operator!==void 0){u.colors[+M.dataset.operator].operator=M.value,m();return}M.dataset.ruleValue!==void 0&&(u.colors[+M.dataset.ruleValue].value=M.value),r()},g.oninput=R=>{const M=R.target;if(M.dataset.ruleValue!==void 0)u.colors[+M.dataset.ruleValue].value=M.value;else return;r()}}function p(f,u){if(f==="color"){c(u);return}const h=s.view(),g={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[f],v=f==="filter"?h.filters:f==="sort"?h.sorts:f==="group"?h.groups:h.colors,m=v.map((y,R)=>{var k;const M=f==="sort"?y.colId:f==="group"?y:y.field,T=((k=e.find(([$])=>$===M))==null?void 0:k[1])||M,W=`<button class="field-select" data-pick="${R}">${H(T)}${me("down")}</button>`;if(f==="sort")return`<div class="condition">${W}<button class="sort-direction ${y.sort==="asc"?"selected":""}" data-dir="asc" data-index="${R}">首项 → 末项</button><button class="sort-direction ${y.sort==="desc"?"selected":""}" data-dir="desc" data-index="${R}">末项 → 首项</button><button data-remove="${R}" aria-label="删除条件">${me("close")}</button></div>`;if(f==="group")return`<div class="condition">${W}<span class="spacer"></span><button data-remove="${R}" aria-label="删除条件">${me("close")}</button></div>`;const E=Pt([["contains",i[M]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],y.operator,`data-operator="${R}" aria-label="运算符"`),x=["blank","notBlank"].includes(y.operator)?"":i[M]?Pt([["","请选择目标值"],...i[M].map($=>[$,$])],y.value,`data-rule-value="${R}" aria-label="目标值"`):`<input data-rule-value="${R}" aria-label="目标值" value="${H(y.value)}" placeholder="请选择目标值">`;return`<div class="condition">${W}${E}${x}${f==="color"?`<input type="color" data-color="${R}" value="${y.color}" aria-label="行颜色">`:""}<button data-remove="${R}" aria-label="删除条件">${me("close")}</button></div>`}).join(""),C=l(u,`设置${g}条件`,`${f==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${h.showTerminated?"checked":""}>显示已终止数据</label>`:""}${m}<button class="add-condition">${me("plus")}添加${f==="color"?"着色":g}条件</button>${v.length?'<button class="clear-rules">清空全部条件</button>':""}`,f==="color"?650:560);s.setActiveRulePanel(f);const S=()=>p(f,u);let b=-1;C.querySelectorAll(".condition").forEach((y,R)=>{y.draggable=!0,y.ondragstart=M=>{var T;b=R,(T=M.dataTransfer)==null||T.setData("text/plain",String(R))},y.ondragover=M=>M.preventDefault(),y.ondrop=M=>{if(M.preventDefault(),b<0||b===R)return;const[T]=v.splice(b,1);v.splice(R,0,T),r(),S()}}),C.onclick=y=>{const R=y.target.closest("button");R&&(R.classList.contains("add-condition")&&a(R,M=>{f==="filter"&&h.filters.push({field:M,operator:"contains",value:""}),f==="sort"&&h.sorts.push({colId:M,sort:"asc"}),f==="group"&&!h.groups.includes(M)&&h.groups.push(M),f==="color"&&h.colors.push({field:M,operator:"contains",value:"",color:"#e9f2ff"}),r(),S()}),R.dataset.pick!==void 0&&a(R,M=>{const T=+R.dataset.pick;f==="sort"?h.sorts[T].colId=M:f==="group"?h.groups[T]=M:(v[T].field=M,v[T].value=""),r(),S()}),R.dataset.remove!==void 0&&(v.splice(+R.dataset.remove,1),r(),S()),R.classList.contains("clear-rules")&&(v.splice(0),r(),S()),R.dataset.dir&&(h.sorts[+R.dataset.index].sort=R.dataset.dir,r(),S()))},C.onchange=y=>{const R=y.target;R.id==="terminated"&&(h.showTerminated=R.checked),R.dataset.operator!==void 0&&(v[+R.dataset.operator].operator=R.value,S()),R.dataset.ruleValue!==void 0&&(v[+R.dataset.ruleValue].value=R.value),R.dataset.color!==void 0&&(h.colors[+R.dataset.color].color=R.value),r()},C.oninput=y=>{const R=y.target;R.tagName==="INPUT"&&R.dataset.ruleValue!==void 0&&(v[+R.dataset.ruleValue].value=R.value,r())}}return{colorRuleMatches:d,colorPanel:c,rulePanel:p}}function va(s={}){var d;const e=document.createElement("section");e.className="rowvia-work-items detail-header-surface";const t=document.createElement("div");t.className="detail-meta-row";const i=s.tags??[];t.innerHTML=`${i.map(c=>`<span class="detail-meta-tag">${H(c)}</span>`).join("")}<button type="button" class="detail-meta-add" data-detail-action="add-tag" aria-label="添加标签">${me("add")}</button><span class="detail-meta-divider"></span>${(s.signals||[]).map(c=>`<button type="button" class="detail-signal${c.checked?" checked":""}" data-detail-action="toggle-signal"><span class="detail-signal-dot">${c.checked?"✓":""}</span>${H(c.label)}</button>`).join("")}`,e.append(t);const n=s.stages??[],o=s.activeStage||((d=n.find(c=>c.state==="active"))==null?void 0:d.id),a=document.createElement("div");a.className="detail-process-strip",a.setAttribute("aria-label","工作项流程"),a.innerHTML=n.map((c,p)=>`<div class="detail-stage-wrap"><button type="button" class="detail-stage ${c.id===o?"active":""} ${c.state||""}" data-detail-action="stage" data-stage="${H(c.id)}"><span class="detail-stage-dot"></span>${H(c.label)}</button>${p<n.length-1?'<span class="detail-stage-line"></span>':""}</div>`).join(""),e.append(a);const l=document.createElement("div");l.className="detail-stage-card";const r=n.find(c=>c.id===o)||n[0];return r&&(l.innerHTML=`<div class="detail-stage-card-head"><div><span class="detail-stage-chevron">⌄</span><span class="detail-stage-card-dot ${r.state||""}"></span><strong>${H(r.label)}</strong><span class="detail-stage-status">进行中</span></div><div class="detail-stage-card-actions"><button type="button" class="primary" data-detail-action="complete-stage">完成</button><button type="button" class="icon-button" data-detail-action="stage-more" aria-label="节点更多">${me("more")}</button></div></div><div class="detail-stage-card-body"><span>负责人</span><strong>${H(s.owner||"待填")}</strong></div><div class="detail-dependency"><span>⌄</span> 依赖项</div>`),r&&e.append(l),e.onclick=c=>{var u;const p=c.target.closest("[data-detail-action]");if(!p)return;const f=p.dataset.detailAction||"";(u=s.onAction)==null||u.call(s,f),e.dispatchEvent(new CustomEvent("rowvia:detail-action",{detail:{action:f,stage:p.dataset.stage},bubbles:!0}))},e}function wa(s={}){const e=va(s),t=xe(e,"work-item-detail-header",s);return{element:e,onInteraction:t.onInteraction,destroy(){t.destroy(),e.onclick=null,e.remove()}}}function Ca(s,e={}){const t=document.createElement("div");t.className="rowvia-work-items rowvia-field-scope",t.style.display="contents",s.append(t);const i=new Ge,n=xe(t,"work-item-layers",e);let o=null,a=null,l=null,r,d=null;const c=(u,h,g)=>{var v,m;u==="open"?(v=e.onOpen)==null||v.call(e,h,g):(m=e.onClose)==null||m.call(e,h),t.dispatchEvent(new CustomEvent(`rowvia:layer-${u}`,{detail:{kind:h,element:g},bubbles:!0}))};function p(){o&&(o.remove(),o=null,c("close","popup"))}function f(){a&&(a.remove(),a=null,l==null||l.focus(),l=null,c("close","overlay"))}return i.listen(t,"click",u=>{var m;const h=u.target,g=(m=h.closest("[data-action]"))==null?void 0:m.dataset.action,v=g==="close-popup"?"popup":g==="close-overlay"||h===a?"overlay":void 0;v&&(u.stopPropagation(),e.onCloseRequest?e.onCloseRequest(v):v==="popup"?p():f())}),{element:t,onInteraction:n.onInteraction,closePopup:p,closeOverlay:f,showPopup(u,h,g,v=460,m=""){if(i.destroyed)throw new Error("Cannot open a destroyed layer host");p(),o=document.createElement("section"),o.className=`popup ${m}`,o.setAttribute("role","dialog"),o.ariaLabel=h||"列操作",o.style.width=`${v}px`,o.innerHTML=`${h?`<div class="popup-head"><span>${H(h)}</span>${Ce("close-popup","","close")}</div>`:""}${g}`,t.append(o);const C=u.getBoundingClientRect();return o.style.left=`${Math.max(12,Math.min(C.left,innerWidth-v-16))}px`,o.style.top=`${Math.min(C.bottom+8,Math.max(12,innerHeight-o.offsetHeight-16))}px`,c("open","popup",o),o},showOverlay(u,h="dialog-overlay"){if(i.destroyed)throw new Error("Cannot open a destroyed layer host");return a?(a.remove(),c("close","overlay")):l=document.activeElement,a=document.createElement("div"),a.className=`overlay ${h}`,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),typeof u=="string"?a.innerHTML=u:a.append(u),t.append(a),c("open","overlay",a),a},toast(u){if(i.destroyed)return;r==null||r(),d==null||d.remove();const h=document.createElement("div");h.className="toast",h.setAttribute("role","status"),h.innerHTML=me("check")+H(u),t.append(h),d=h;const g=window.setTimeout(()=>{h.remove(),r==null||r()},2500);r=i.add(()=>window.clearTimeout(g))},destroy(){i.destroyed||(i.destroy(),n.destroy(),p(),f(),t.remove())}}}const rt=new Map;function Ke(s,e){if(!s)return!1;const t=e?[e]:[],i=new Set;for(let n=0;n<Math.max(1,t.length);n++)for(const[o,a]of rt)if(!(i.has(o)||e&&!t[n].contains(a))){if(o.element.contains(s))return!0;i.add(o),t.push(o.element)}return!1}function ya(s){for(const[e,t]of[...rt])(!s||s.contains(t))&&e.close()}function $t(s){const{anchor:e,content:t,width:i="anchor",gap:n=4,onDismiss:o}=s,a=e.ownerDocument,l=a.defaultView||window,r=s.anchorMode==="element"?e:e.closest(".fc-focus-body")||e,d=a.createElement("div");d.className="rowvia-field-scope rowvia-field-popup-layer";const c=a.createElement("div");c.className="rowvia-field-popup",c.append(t),d.append(c),(a.body||a.documentElement).append(d);let p=!1;const f=()=>{if(p||!d.isConnected)return;const m=r.getBoundingClientRect(),C=a.documentElement.clientWidth||l.innerWidth,S=a.documentElement.clientHeight||l.innerHeight,b=i==="anchor"?m.width+2:i==="auto"?c.getBoundingClientRect().width:i;c.style.width=i==="auto"?"max-content":b+"px";const y=c.getBoundingClientRect().height;let R=m.bottom+n;const M=m.top-n-y;R+y>S-8&&M>=8&&(R=M),R=Math.max(8,Math.min(R,Math.max(8,S-y-8)));const T=Math.max(8,Math.min(s.align==="end"?m.right-b:m.left,Math.max(8,C-b-8)));d.style.top=Math.round(R)+"px",d.style.left=Math.round(T)+"px"},u=()=>{p||(p=!0,ya(d),rt.delete(v),a.removeEventListener("pointerdown",h,!0),a.removeEventListener("keydown",g,!0),l.removeEventListener("resize",f),l.removeEventListener("scroll",f,!0),d.remove(),o==null||o())},h=m=>{const C=m.target;C&&(d.contains(C)||r.contains(C)||e.contains(C)||Ke(C,d))||u()},g=m=>{if(m.key!=="Escape"||[...rt.keys()][rt.size-1]!==v)return;if(m.preventDefault(),m.stopPropagation(),u(),s.onEscape){s.onEscape();return}const C=a.defaultView.CustomEvent;e.dispatchEvent(new C("fc-collapse",{bubbles:!0,detail:{reason:"escape"}}))},v={element:d,reposition:f,close:u};return rt.set(v,e),a.addEventListener("pointerdown",h,!0),a.addEventListener("keydown",g,!0),l.addEventListener("resize",f),l.addEventListener("scroll",f,!0),f(),v}const si=new WeakMap;function hn(s,e){let t=si.get(s);if(!t){const n=new Set,o=a=>{for(const l of[...n])n.has(l)&&!l.contains(a.target,a)&&l.leave(a)};s.addEventListener("pointerdown",o,!0),s.addEventListener("focusin",o,!0),t={boundaries:n,stop:()=>{s.removeEventListener("pointerdown",o,!0),s.removeEventListener("focusin",o,!0)}},si.set(s,t)}t.boundaries.add(e);const i=t;return()=>{!i.boundaries.delete(e)||i.boundaries.size||(i.stop(),si.delete(s))}}class Le{constructor(e){w(this,"root");w(this,"destroying",!1);w(this,"feedback");w(this,"options");w(this,"value");w(this,"committedValue");w(this,"state");w(this,"view");w(this,"viewLife",new Ge);w(this,"life",new Ge);w(this,"listeners",new Set);w(this,"interactions");w(this,"interactionListeners",new Set);w(this,"mounted",!1);w(this,"handled",new WeakSet);this.options={...e},this.value=e.value,this.committedValue=e.value,this.state=e.readonly||e.canEdit===!1?"display":e.state??"display"}get element(){if(this.root)return this.root;const e=document.createElement("div");return e.className="rowvia-field",e.tabIndex=0,e.setAttribute("aria-label",this.options.field.label),this.root=e,e}bindRoot(){this.life.listen(this.element,"pointerenter",()=>{this.state==="display"&&this.setState("hover","user")}),this.life.listen(this.element,"pointerleave",()=>{this.state==="hover"&&this.setState("display","user")}),this.life.listen(this.element,"click",e=>{e.target.closest("button,a,input,textarea,select,[contenteditable]")||this.edit("user")}),this.life.listen(this.element,"keydown",e=>{const t=e.key;t==="Escape"&&this.state==="editing"?(e.preventDefault(),this.cancel("user")):(t==="Enter"||t===" ")&&this.state!=="editing"&&e.target===this.element&&(e.preventDefault(),this.edit("user"))}),this.life.listen(this.element,"fc-collapse",e=>{var t;((t=e.detail)==null?void 0:t.reason)==="escape"?this.cancel("user"):this.commit("user")}),this.life.listen(this.element,"focusout",()=>{queueMicrotask(()=>{var t,i;if(this.life.destroyed||!this.element.isConnected||this.state!=="editing")return;const e=this.element.ownerDocument.activeElement;this.element.contains(e)||(i=(t=this.view)==null?void 0:t.content)!=null&&i.contains(e)||Ke(e,this.element)||this.commit("user")})})}renderHover(e){return this.renderDisplay(e)}beforeInput(e){return e}beforeCommit(e){return!0}beforeCancel(e){return!0}beforeStateChange(e){return!0}validateValue(e){}isReadonly(){return!!this.options.readonly||this.options.canEdit===!1||this.options.field.editable===!1}onOutput(e){}get snapshot(){return{key:this.options.field.key,value:this.read(),committedValue:this.committedValue,state:this.state,readonly:this.isReadonly()}}mount(e){if(this.life.destroyed)throw new Error("Cannot mount a destroyed field");return this.mounted||(this.mounted=!0,this.bindRoot(),this.draw()),e==null||e.append(this.element),this}read(){var e;return this.state==="editing"&&((e=this.view)!=null&&e.read)?this.view.read():this.value}on(e){return this.life.destroyed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)})}onInteraction(e){return this.life.destroyed?()=>{}:(this.interactionListeners.add(e),()=>{this.interactionListeners.delete(e)})}input(e,t="api",i){var l;if(this.life.destroyed||this.snapshot.readonly)return;const n=this.value,o=this.snapshot,a=this.beforeInput(e);this.value=(l=this.options.hooks)!=null&&l.beforeInput?this.options.hooks.beforeInput(a,o):a,(t==="api"||!Object.is(e,this.value))&&this.draw(),this.emit("input",t,{previousValue:n,originalEvent:i})}setValue(e){if(this.life.destroyed)return;const t=this.read();this.value=e,this.committedValue=e,this.draw(),this.emit("change","api",{previousValue:t})}update(e){this.life.destroyed||(this.value=this.read(),this.options={...this.options,...e},"value"in e&&(this.value=this.committedValue=e.value),e.state&&(this.state=e.state),this.isReadonly()&&(this.state="display"),this.draw())}validate(){var i,n,o,a;const e=this.read(),t=e==null||e===""||Array.isArray(e)&&e.length===0;return(this.options.field.required&&t?"此项必填":void 0)||this.validateValue(e)||((n=(i=this.view)==null?void 0:i.validate)==null?void 0:n.call(i))||((a=(o=this.options.hooks)==null?void 0:o.validate)==null?void 0:a.call(o,e))}commit(e="api"){var n,o;if(this.life.destroyed||this.snapshot.readonly)return!1;const t=this.validate();if(this.showValidation(t),t)return this.emit("invalid",e,{message:t}),!1;const i=this.event("commit",e,{previousValue:this.committedValue});return!this.beforeCommit(i)||((o=(n=this.options.hooks)==null?void 0:n.beforeCommit)==null?void 0:o.call(n,i))===!1?!1:(this.value=this.read(),this.committedValue=this.value,this.element.removeAttribute("aria-invalid"),this.emit("commit",e,{previousValue:i.previousValue}),this.setState("display",e),!0)}cancel(e="api"){var n,o,a,l;if(this.life.destroyed)return;const t=this.event("cancel",e);if(!this.beforeCancel(t)||((o=(n=this.options.hooks)==null?void 0:n.beforeCancel)==null?void 0:o.call(n,t))===!1)return;const i=this.event("state",e,{previousState:this.state,state:"display",value:this.committedValue});this.state!=="display"&&(!this.beforeStateChange(i)||((l=(a=this.options.hooks)==null?void 0:a.beforeStateChange)==null?void 0:l.call(a,i))===!1)||(this.value=this.committedValue,this.disposeView(),this.state="display",this.draw(),this.emit("cancel",e),i.previousState!=="display"&&this.publish(i))}edit(e="api"){var t,i;this.life.destroyed||(this.setState("editing",e),this.state==="editing"&&((i=(t=this.view)==null?void 0:t.focus)==null||i.call(t)))}setState(e,t="api"){var o,a,l,r;if(this.life.destroyed||e===this.state||e==="editing"&&this.snapshot.readonly)return;const i=this.event("state",t,{previousState:this.state});if(i.state=e,!this.beforeStateChange(i)||((a=(o=this.options.hooks)==null?void 0:o.beforeStateChange)==null?void 0:a.call(o,i))===!1)return;const n=this.state!=="editing"&&e!=="editing"&&!((l=this.options.renderers)!=null&&l.display)&&!((r=this.options.renderers)!=null&&r.hover)&&this.renderHover===Le.prototype.renderHover;this.value=this.read(),this.state=e,n&&this.view?this.element.dataset.state=e:this.draw(),this.publish(i)}action(e,t){var n,o;if(this.life.destroyed)return;const i={type:e,value:t};(o=(n=this.options).onAction)==null||o.call(n,i),this.emit("action","api",{action:i})}destroy(){var e,t;if(!(this.life.destroyed||this.destroying)){this.destroying=!0,this.value=this.read();try{this.emit("destroy","api")}finally{try{this.disposeView()}finally{(e=this.interactions)==null||e.destroy(),this.life.destroy(),this.listeners.clear(),this.interactionListeners.clear(),(t=this.root)==null||t.remove()}}}}createEditor(){if(this.life.destroyed)throw new Error("Cannot edit a destroyed field");this.disposeView(),this.state="editing";const e=this.renderEditing(this.context());return this.view=e,this.watch(e),{...e,read:()=>this.read(),validate:()=>this.validate(),onInteraction:t=>this.onInteraction(t),destroy:()=>this.destroy()}}render(){if(this.life.destroyed)throw new Error("Cannot render a destroyed field");return this.disposeView(),this.view=this.renderDisplay(this.context()),{...this.view,destroy:()=>this.destroy()}}context(){return{...this.options,readonly:this.isReadonly(),value:this.value,onAction:e=>this.action(e.type,e.value)}}showValidation(e){var t;if(this.mounted){if(!e){this.element.removeAttribute("aria-invalid"),(t=this.feedback)==null||t.remove();return}this.feedback??(this.feedback=this.element.ownerDocument.createElement("div")),this.feedback.className="fc-error",this.feedback.setAttribute("role","status"),this.feedback.textContent=e,this.element.setAttribute("aria-invalid","true"),this.element.append(this.feedback)}}draw(){var c,p,f,u,h,g,v;if(!this.mounted||this.life.destroyed)return;const e=this.element.ownerDocument.activeElement,t=this.state==="editing"&&!!e&&(!!((c=this.view)!=null&&c.element.contains(e))||!!((f=(p=this.view)==null?void 0:p.content)!=null&&f.contains(e))),i=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:void 0;this.disposeView(),this.isReadonly()&&(this.state="display");const n=this.snapshot,o=this.options.content,a=typeof o=="function"?o(n):o??{kind:"text",text:this.value==null?"":String(this.value)},l=this.context(),r=()=>this.state==="editing"?this.renderEditing(l):o?oi(a):this.state==="hover"?this.renderHover(l):this.renderDisplay(l),d={...n,element:this.element,field:this.options.field,content:a,renderDefault:r,input:m=>this.input(m),commit:()=>this.commit(),cancel:()=>this.cancel(),edit:()=>this.edit(),action:(m,C)=>this.action(m,C)};if(this.view=((h=(u=this.options.renderers)==null?void 0:u[this.state])==null?void 0:h.call(u,d))??r(),this.element.setAttribute("aria-label",this.options.field.label),this.element.dataset.state=this.state,this.element.dataset.readonly=String(n.readonly),this.element.replaceChildren(this.view.element),this.element.removeAttribute("aria-invalid"),this.watch(this.view),t){(v=(g=this.view).focus)==null||v.call(g);const m=this.element.ownerDocument.activeElement;if((i==null?void 0:i.start)!=null&&i.end!=null&&(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement))try{m.setSelectionRange(i.start,i.end)}catch{}}}watch(e){if(this.mounted&&this.state==="editing"){const i=()=>[this.element,e.content,this.options.focusBoundary].filter(n=>!!n);this.viewLife.add(hn(this.element.ownerDocument,{contains:(n,o)=>i().some(a=>o.composedPath().includes(a)||!!n&&a.contains(n)||Ke(n,a)),leave:()=>{this.element.isConnected&&this.commit("user")}}))}this.interactions??(this.interactions=xe(this.mounted?this.element:e.element,`field:${this.options.field.key}`,{onInteraction:i=>{var n,o;(o=(n=this.options).onInteraction)==null||o.call(n,i);for(const a of this.interactionListeners)a(i)}}));const t=[...new Set([e.element,e.content].filter(i=>!!i))];for(const i of t)this.viewLife.add(this.interactions.addRoot(i));for(const i of e.inputRoot?[e.inputRoot]:t)for(const n of["input","change"])this.viewLife.listen(i,n,o=>{var a;this.handled.has(o)||(this.handled.add(o),this.input(((a=e.read)==null?void 0:a.call(e))??this.value,"user",o),n==="change"&&this.emit("change","user",{originalEvent:o}))})}disposeView(){var t;this.viewLife.destroy(),this.viewLife=new Ge;const e=this.view;this.view=void 0,(t=e==null?void 0:e.destroy)==null||t.call(e)}event(e,t,i={}){return{...this.snapshot,type:e,source:t,...i}}emit(e,t,i={}){this.publish(this.event(e,t,i))}publish(e){var n,o,a;this.onOutput(e),(o=(n=this.options).onEvent)==null||o.call(n,e);for(const l of[...this.listeners])l(e);const t=this.mounted?this.element:(a=this.view)==null?void 0:a.element;if(!t)return;const i=t.ownerDocument.defaultView.CustomEvent;t.dispatchEvent(new i(`field:${e.type}`,{detail:e,bubbles:!0}))}}function oi(s){if(s.kind==="node")return{element:s.node,destroy:s.destroy};const e=document.createElement("div");if(e.className=s.className??"",s.kind==="text")return e.textContent=s.text,{element:e};const t=s.children.map(oi);return e.append(...t.map(i=>i.element)),{element:e,destroy:()=>t.forEach(i=>{var n;return(n=i.destroy)==null?void 0:n.call(i)})}}function P(s,e="",t){const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i}function pn(s,e=312){s.rows=1,s.style.resize="none";const t=()=>{s.style.height="auto";const i=s.scrollHeight;i>0&&(s.style.height=Math.min(i,e)+"px"),s.style.overflowY=i>e?"auto":"hidden"};return s.addEventListener("input",t),s.addEventListener("focus",t),queueMicrotask(t),t}const Be=s=>s.choices??(s.options||[]).map(e=>({id:e,label:e})),fn=["rgba(61, 188, 47, 0.2)","rgba(0, 184, 159, 0.2)","rgba(244, 118, 189, 0.2)","rgba(149, 155, 238, 0.2)","rgba(184, 143, 255, 0.2)"],ai=(s,e)=>{var t,i;return((t=Be(s).find(n=>n.id===e))==null?void 0:t.color)||((i=s.colors)==null?void 0:i[e])||fn[Math.max(0,Be(s).findIndex(n=>n.id===e))%fn.length]},gn=s=>(Array.isArray(s)?s:s==null||s===""?[]:[s]).map(String);function ba(s,e){var t;return((t=Be(s).find(i=>i.id===e))==null?void 0:t.label)||e}function Sa(s,e="choice"){const t=P("div","fc-tags");for(const i of gn(s.value)){const n=ba(s.field,i),o=P(e==="relation"?"button":"span","fc-tag fc-tag--"+e);e==="choice"&&(o.style.backgroundColor=ai(s.field,i)),e==="person"&&o.append(P("span","fc-avatar",n.slice(0,1))),o.append(P("span","fc-tag-label",n)),o.tagName==="BUTTON"&&(o.type="button",o.onclick=a=>{var l;a.stopPropagation(),(l=s.onAction)==null||l.call(s,{type:"open",value:i})}),t.append(o)}return t.children.length||t.append(P("span","fc-empty","待填")),t}function mn(s,e,t="choice"){var I;const i=P("div","fc-choice fc-choice--"+t);let n=gn(e.value).slice(0,s?void 0:1);const o=new Map(Be(e.field).map(L=>[L.id,L]));let a=Be(e.field);const l=s&&(e.field.maxSelections??0)>0?e.field.maxSelections:1/0,r=P("select","fc-select");r.hidden=!0,r.multiple=s,r.disabled=e.readonly,r.required=!!e.field.required,r.ariaLabel=e.field.label;const d=P("div","fc-choice-head"),c=P("div","fc-choice-selection"),p=P("span","fc-empty fc-choice-placeholder","待填"),f=P("input","fc-choice-search");f.placeholder="",f.autocomplete="off",f.ariaLabel="输入以搜索"+e.field.label,f.disabled=e.readonly;const u=()=>{f.size=Math.max(1,[...f.value].length+1)};u();const h=P("div","fc-option-list");h.setAttribute("role",t==="radio"?"radiogroup":"group"),h.ariaLabel=e.field.label;const g=P("div","fc-error fc-choice-feedback");g.setAttribute("role","status");const v=P("div","fc-picker-status");v.setAttribute("role","status");const m=P("button","fc-retry","重试");m.type="button",m.hidden=!0;let C,S=0,b=!1,y=!1;const R=t!=="radio"&&!!((I=e.services)!=null&&I.searchOptions),M=t!=="radio"&&e.layout!=="compact"&&!e.readonly;let T;const W=()=>{const L=T;T=void 0,L==null||L.close()},E=()=>{!M||b||T||e.readonly||(T=$t({anchor:d,content:h,width:"anchor",onDismiss:()=>{T=void 0}}))},x=()=>{!M||!T||(W(),i.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},k=()=>{var L;(L=e.onSelectedOptions)==null||L.call(e,n.map(D=>o.get(D)).filter(D=>!!D)),i.dispatchEvent(new Event("change",{bubbles:!0}))},$=()=>{var L;if(r.replaceChildren(),!s){const D=P("option");D.value="",r.append(D)}for(const D of new Set([...a.map(z=>z.id),...n])){const z=P("option","",((L=o.get(D))==null?void 0:L.label)||D);z.value=D,z.selected=n.includes(D),r.append(z)}s||(r.value=n[0]||"")},q=()=>{c.replaceChildren(),h.replaceChildren(),$(),!n.length&&!f.value&&c.append(p);for(const z of n){const U=o.get(z),K=P("span","fc-tag fc-tag--"+t);(t==="choice"||t==="radio")&&(K.style.backgroundColor=ai(e.field,z)),t==="person"&&K.append(P("span","fc-avatar",((U==null?void 0:U.label)||z).slice(0,1))),K.append(P("span","fc-tag-label",((U==null?void 0:U.label)||z)+(U!=null&&U.disabled?"(已停用)":"")));const Z=P("span","fc-tag-slot"),ie=P("button","fc-choice-remove","×");ie.type="button",ie.disabled=e.readonly,ie.ariaLabel="移除"+((U==null?void 0:U.label)||z),ie.onclick=pe=>{pe.stopPropagation(),n=n.filter(J=>J!==z),g.textContent="",q(),f.focus(),k()},Z.append(ie),K.append(Z),c.append(K)}const L=f.value.trim().toLocaleLowerCase(),D=a.filter(z=>!z.disabled&&(R||(z.label+" "+z.id+" "+(z.description||"")).toLocaleLowerCase().includes(L)));for(const z of D){const U=P("button","fc-option");U.type="button",U.dataset.value=z.id,U.disabled=e.readonly||y;const K=n.includes(z.id);U.classList.toggle("selected",K),U.setAttribute(t==="radio"?"aria-checked":"aria-pressed",String(K)),t==="radio"&&U.setAttribute("role","radio");const Z=P("span","fc-option-label"+(t==="choice"?" fc-tag":""),z.label);t==="choice"&&(Z.style.backgroundColor=ai(e.field,z.id)),t==="person"&&U.append(P("span","fc-avatar",z.label.slice(0,1))),t==="relation"&&U.append(P("span","fc-relation-icon","↗"));const ie=P("span","fc-option-copy");ie.append(Z),z.description&&ie.append(P("small","fc-option-description",z.description)),U.append(ie,P("span","fc-option-mark",K?"✓":"")),U.onclick=pe=>{if(pe.stopPropagation(),!e.readonly){if(!s)n=[z.id];else if(K)n=n.filter(J=>J!==z.id);else{const J=z.exclusive?[]:n.filter(ce=>{var fe;return!((fe=o.get(ce))!=null&&fe.exclusive)});if(J.length>=l){g.textContent="最多可选择 "+l+" 项";return}n=[...J,z.id]}g.textContent="",s||(f.value="",u()),q(),h.querySelectorAll("button").forEach(J=>{J.dataset.value===z.id&&J.focus()}),k(),!s&&M&&x()}},h.append(U)}!D.length&&!y&&h.append(P("p","fc-empty fc-choice-empty","暂无匹配选项"))},F=async()=>{C==null||C.abort();const L=++S;C=new AbortController,y=!0,m.hidden=!0,v.textContent="加载中…",i.setAttribute("aria-busy","true"),q();try{const D=await e.services.searchOptions(e.field,f.value.trim(),C.signal);if(b||L!==S)return;a=D,D.forEach(z=>o.set(z.id,z)),v.textContent=""}catch{if(b||L!==S)return;a=[],v.textContent="加载失败,请重试",m.hidden=!1}finally{!b&&L===S&&(y=!1,i.setAttribute("aria-busy","false"),q())}};f.oninput=()=>{u(),R?F():q()},f.onfocus=()=>E(),d.onclick=L=>{L.target.closest("button")||f.focus()},m.onclick=()=>void F();const G=L=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(L.key))return;const D=[...h.querySelectorAll("button:not(:disabled)")];if(!D.length)return;L.preventDefault();const z=D.indexOf(document.activeElement),U=L.key==="Home"?0:L.key==="End"?D.length-1:(z+(L.key==="ArrowUp"||L.key==="ArrowLeft"?-1:1)+D.length)%D.length;D[U].focus()};if(h.onkeydown=G,f.onkeydown=L=>{L.key==="ArrowDown"&&(E(),G(L))},r.onchange=()=>{n=[...r.selectedOptions].map(L=>L.value).filter(Boolean),q()},d.append(c),t!=="radio"&&d.append(f),M){const L=P("span","fc-field-chevron");L.setAttribute("aria-hidden","true"),d.append(L),i.append(r,d,v,m,g)}else i.append(r,d,v,h,m,g);return q(),R&&!e.readonly&&F(),{element:i,content:M?h:void 0,read:()=>s?[...n]:n[0]||"",validate:()=>e.field.required&&!n.length?"请选择一个选项":n.length>l?"最多可选择 "+l+" 项":void 0,focus:()=>{var L;if(t==="radio"){(L=h.querySelector("button"))==null||L.focus();return}f.focus(),E()},deactivate:()=>{f.value="",u(),W()},destroy:()=>{b=!0,++S,C==null||C.abort(),W()}}}const 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 IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),vn=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function yt(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")||"",l=o.getAttribute("src")||"",r=o.getAttribute("alt")||"",d=o.getAttribute("data-person-id"),c=o.hasAttribute("checked"),p=o.getAttribute("data-task")==="true",f=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(h=>[h,o.style.getPropertyValue(h)]),u=o.tagName==="FONT"?o.getAttribute("color"):null;for(const h of[...o.attributes])o.removeAttribute(h.name);for(const[h,g]of f)(h==="color"||h==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(g):h==="text-align"?/^(left|center|right|justify)$/.test(g):h==="margin-left"?/^\d{1,3}px$/.test(g):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(g))&&o.style.setProperty(h,g);if(u&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(u)&&(o.style.color=u),o.tagName==="A"&&vn(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="IMG"){if(!/^https?:\/\//i.test(l.trim())){o.remove();continue}o.setAttribute("src",l.trim()),o.setAttribute("alt",r),o.setAttribute("loading","lazy"),o.setAttribute("referrerpolicy","no-referrer")}o.tagName==="SPAN"&&d&&(o.setAttribute("data-person-id",d),o.setAttribute("contenteditable","false")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),c&&o.setAttribute("checked","")),p&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const ri={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 xa(s){const e=P("div",`fc-rich${s.layout==="compact"?" fc-rich-compact":""}`),t=P("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const i=P("div","fc-rich-tools");t.append(i);const n=P("div","fc-rich-content");n.contentEditable=String(!s.readonly),n.setAttribute("role","textbox"),n.setAttribute("aria-multiline","true"),n.ariaLabel=s.field.label,n.tabIndex=s.readonly?-1:0,n.innerHTML=yt(s.value);const o=P("div","fc-rich-menu");o.hidden=!0;let a=null,l=!1,r=[n.innerHTML],d=0,c=!1,p=null,f,u;const h=()=>{const I=window.getSelection();I!=null&&I.rangeCount&&n.contains(I.anchorNode)&&n.contains(I.focusNode)&&(a=I.getRangeAt(0).cloneRange())},g=()=>{n.focus();const I=window.getSelection();if(!I)return;const L=a&&n.contains(a.commonAncestorContainer)?a:document.createRange();L!==a&&(L.selectNodeContents(n),L.collapse(!1)),I.removeAllRanges(),I.addRange(L),a=L},v=()=>{var L;const I=u;u=void 0,I==null||I.close(),(L=f==null?void 0:f.destroy)==null||L.call(f),f=void 0,o.hidden=!0,o.replaceChildren()},m=new Map,C=()=>{var I;m.get("撤销").disabled=s.readonly||d===0,m.get("重做").disabled=s.readonly||d===r.length-1;for(const[L,D]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=m.get(L);if(!z)continue;const U=!!((I=document.queryCommandState)!=null&&I.call(document,D));z.classList.toggle("active",U),z.setAttribute("aria-pressed",String(U))}},S=()=>{c||(n.innerHTML!==r[d]&&(r=r.slice(0,d+1),r.push(n.innerHTML),r.length>100&&r.shift(),d=r.length-1),h(),C())},b=()=>{S(),n.dispatchEvent(new Event("change",{bubbles:!0}))},y=I=>{const L=d+I;L<0||L>=r.length||(d=L,c=!0,n.innerHTML=r[d],a=null,g(),c=!1,C(),n.dispatchEvent(new Event("change",{bubbles:!0})))},R=(I,L)=>{s.readonly||(g(),document.execCommand(I,!1,L),h(),v(),b())},M=I=>{if(s.readonly)return;g();const L=window.getSelection().getRangeAt(0);L.deleteContents(),L.insertNode(I),L.setStartAfter(I),L.collapse(!0),a=L.cloneRange(),v(),b()},T=(I,L,D,z=!0)=>{const U=P("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return U.type="button",U.ariaLabel=I,U.title=I,U.disabled=s.readonly,ri[L]?U.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ri[L]}</svg>`:U.textContent=L,U.onmousedown=K=>{K.preventDefault(),h()},U.onclick=K=>{K.stopPropagation(),D()},i.append(U),m.set(I,U),U},W=(I,L)=>{if(!s.readonly){if(h(),!o.hidden&&o.ariaLabel===I){v();return}v(),o.className="fc-rich-menu",o.ariaLabel=I,o.hidden=!1,u=$t({anchor:m.get(I),anchorMode:"element",content:o,width:"auto",onDismiss:v,onEscape:g}),L(),u==null||u.reposition()}},E=(I,L)=>{const D=P("button","fc-rich-menu-option",I);return D.type="button",D.onmousedown=z=>z.preventDefault(),D.onclick=z=>{z.stopPropagation(),L()},o.append(D),D};T("撤销","undo",()=>y(-1),!1),T("重做","redo",()=>y(1),!1),T("格式刷","paint",()=>{h();const I=a==null?void 0:a.startContainer,L=(I==null?void 0:I.nodeType)===1?I:I==null?void 0:I.parentElement;!L||!n.contains(L)||(p={tag:/^(B|STRONG|I|EM|U|S)$/.test(L.tagName)?L.tagName.toLowerCase():"span",css:L.getAttribute("style")||""},m.get("格式刷").classList.add("active"))}),T("正文样式","Aa⌄",()=>W("正文样式",()=>{for(const[I,L]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])E(I,()=>R("formatBlock",L))}));const x=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[I,L,D]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])T(I,L,()=>W(I,()=>{o.classList.add("fc-rich-colors");for(const z of x){const U=E(z,()=>R(D,z));U.textContent="",U.style.backgroundColor=z,U.ariaLabel=`${I} ${z}`}E("清除",()=>R(D,D==="foreColor"?"#1f2329":"transparent"))}));for(const[I,L,D]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])T(I,L,()=>R(D));T("对齐","☰⌄",()=>W("对齐",()=>{for(const[I,L]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])E(I,()=>R(L))})),T("有序列表","1≡",()=>R("insertOrderedList")),T("无序列表","•≡",()=>R("insertUnorderedList")),T("任务列表","task",()=>{g();const I=window.getSelection().getRangeAt(0),L=P("ul"),D=P("li");D.dataset.task="true";const z=P("input");z.type="checkbox",z.contentEditable="false",D.append(z,I.extractContents()),D.textContent||D.append(document.createTextNode("待办事项")),L.append(D),M(L)}),T("引用","quote",()=>R("formatBlock","blockquote")),T("缩进","indent",()=>W("缩进",()=>{E("增加缩进",()=>R("indent")),E("减少缩进",()=>R("outdent"))})),T("分隔线","line",()=>M(P("hr"))),T("表格","table",()=>W("表格",()=>{const I=P("p","","选择行列"),L=P("div","fc-rich-table-grid");o.append(I,L);for(let D=1;D<=6;D++)for(let z=1;z<=6;z++){const U=P("button");U.type="button",U.ariaLabel=`${D}行${z}列表格`,U.dataset.row=String(D),U.dataset.col=String(z),U.onmousedown=K=>K.preventDefault(),U.onmouseenter=()=>{I.textContent=`${D} × ${z}`,L.querySelectorAll("button").forEach(K=>K.classList.toggle("active",Number(K.dataset.row)<=D&&Number(K.dataset.col)<=z))},U.onclick=()=>{const K=P("table"),Z=P("tbody");for(let pe=0;pe<D;pe++){const J=P("tr");for(let ce=0;ce<z;ce++){const fe=P("td");fe.append(P("br")),J.append(fe)}Z.append(J)}K.append(Z),M(K);const ie=document.createRange();ie.selectNodeContents(K.querySelector("td")),ie.collapse(!0),a=ie,g()},L.append(U)}}));const k=()=>W("链接",()=>{const I=P("input","fc-input");I.ariaLabel="链接文本",I.placeholder="输入文本",I.value=(a==null?void 0:a.toString())||"";const L=P("input","fc-input");L.ariaLabel="链接地址",L.placeholder="粘贴或输入超链接";const D=P("div","fc-error"),z=P("button","primary","确定");z.type="button",z.onclick=()=>{const U=L.value.trim();if(!vn(U)){D.textContent="请输入 http、https 或 mailto 链接";return}const K=P("a","",I.value||U);K.href=U,K.target="_blank",K.rel="noopener noreferrer",M(K)},o.append(P("span","","文本"),I,P("span","","链接"),L,D,z),I.focus()});T("链接","link",k),T("插入图片","▧",()=>W("插入图片",()=>{const I=P("input","fc-input");I.type="url",I.ariaLabel="图片地址",I.placeholder="https:// 图片地址";const L=P("input","fc-input");L.ariaLabel="图片说明",L.placeholder="图片说明";const D=P("div","fc-error"),z=P("button","primary","插入");z.type="button",z.onclick=()=>{if(!/^https?:\/\//i.test(I.value.trim())||!I.checkValidity()){D.textContent="请输入有效的 http 或 https 图片地址";return}const U=P("img");U.src=I.value.trim(),U.alt=L.value,U.referrerPolicy="no-referrer",M(U)},o.append(I,L,D,z),I.focus()})),T("提及人员","@",()=>W("提及人员",()=>{var L;const I=mn(!1,{...s,value:"",field:{...s.field,label:"人员"}},"person");f=I,o.append(I.element),I.element.addEventListener("change",D=>{var K,Z;D.stopPropagation();const z=String(I.read());if(!z)return;const U=P("span","","@"+(((K=Be(s.field).find(ie=>ie.id===z))==null?void 0:K.label)||((Z=I.element.querySelector("option:checked"))==null?void 0:Z.textContent)||z));U.dataset.personId=z,U.contentEditable="false",M(U)}),(L=I.focus)==null||L.call(I)})),T("代码块","{ }",()=>R("formatBlock","pre")),T("表情","☺",()=>W("表情",()=>{o.classList.add("fc-rich-emojis");for(const I of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])E(I,()=>M(document.createTextNode(I)))}));const $=T("全屏编辑","expand",()=>{h(),l=!l,e.classList.toggle("is-fullscreen",l),v(),$.ariaLabel=$.title=l?"收起全屏":"全屏编辑",$.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${ri[l?"collapse":"expand"]}</svg>`,g()},!1);$.disabled=!1,$.classList.add("fc-rich-expand"),t.append($);const q=()=>{for(const I of i.children)I.inert=I.offsetTop>=i.clientHeight},F=typeof ResizeObserver>"u"?void 0:new ResizeObserver(q);F==null||F.observe(i);const G=I=>{const L=I.target;n.contains(L)||L.closest("input,textarea,select,[contenteditable=true]")||(I.preventDefault(),!e.contains(document.activeElement)&&!o.contains(document.activeElement)&&g())};return e.addEventListener("mousedown",G),o.addEventListener("mousedown",G),n.addEventListener("input",S),n.addEventListener("mouseup",()=>{if(h(),C(),p&&a&&!a.collapsed){const I=a,L=P(p.tag);L.style.cssText=p.css,L.append(I.extractContents()),I.insertNode(L),p=null,m.get("格式刷").classList.remove("active"),b()}}),n.addEventListener("keyup",()=>{h(),C()}),n.addEventListener("click",I=>{const L=I.target;if(L.tagName==="A"&&I.preventDefault(),L instanceof HTMLInputElement&&L.type==="checkbox"){if(s.readonly){I.preventDefault();return}L.toggleAttribute("checked",L.checked),b()}v()}),n.addEventListener("drop",I=>I.preventDefault()),n.addEventListener("paste",I=>{var D,z;if(s.readonly){I.preventDefault();return}I.preventDefault(),h();const L=(D=I.clipboardData)==null?void 0:D.getData("text/html");if(L){const U=document.createElement("template");U.innerHTML=yt(L);const K=U.content,Z=document.createTextNode("");K.append(Z),g();const ie=window.getSelection().getRangeAt(0);ie.deleteContents(),ie.insertNode(K),ie.setStartAfter(Z),ie.collapse(!0),a=ie.cloneRange(),b()}else M(document.createTextNode(((z=I.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",I=>{I.key==="Escape"&&!o.hidden?(I.preventDefault(),I.stopPropagation(),v(),g()):I.key==="Escape"&&l?(I.preventDefault(),I.stopPropagation(),$.click()):!s.readonly&&(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="z"?(I.preventDefault(),y(I.shiftKey?1:-1)):(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="k"&&(I.preventDefault(),h(),k())}),e.append(t,n),C(),{element:e,content:o,inputRoot:e,read:()=>yt(n.innerHTML),validate:()=>{var I;return s.field.required&&!((I=n.textContent)!=null&&I.trim())&&!n.querySelector("img")?"请填写内容":void 0},focus:()=>n.focus(),deactivate:()=>{v(),l=!1,e.classList.remove("is-fullscreen"),$.ariaLabel=$.title="全屏编辑"},destroy:()=>{F==null||F.disconnect(),v()}}}const wn=s=>s==null?"":String(s);function Ra(s){var t;const e=P("div",`fc-value fc-${s.className||""}`);if(s.field.kind==="richText"||s.field.kind==="richtext"||s.field.kind==="longText"||s.field.control==="richText")e.innerHTML=yt(s.value);else if(s.field.kind==="number"&&typeof s.value=="number"){const i=s.field.numberOptions;e.textContent=s.value.toLocaleString("zh-CN",{useGrouping:(i==null?void 0:i.thousandsSeparator)??!1,maximumFractionDigits:(i==null?void 0:i.decimals)??10})+((i==null?void 0:i.suffix)||""),e.classList.add("fc-plain")}else e.textContent=wn(s.value),e.classList.add("fc-plain");return(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function Cn(s,e){const i=s==="text"&&e.layout!=="compact"?P("textarea","fc-input fc-textarea"):P("input","fc-input");if(i instanceof HTMLInputElement&&(i.type=s),i.value=wn(e.value),i.disabled=e.readonly,i.required=!!e.field.required,i.ariaLabel=e.field.label,i.placeholder=e.field.placeholder||(e.layout!=="compact"?"待填":`请输入${e.field.label}`),e.field.maxLength!==void 0&&(i.maxLength=e.field.maxLength),s==="number"&&i instanceof HTMLInputElement){const n=e.field.numberOptions;i.step=String((n==null?void 0:n.step)??"any"),(n==null?void 0:n.min)!==void 0&&(i.min=String(n.min)),(n==null?void 0:n.max)!==void 0&&(i.max=String(n.max))}return i instanceof HTMLTextAreaElement&&pn(i),s==="text"&&e.layout!=="compact"&&i.addEventListener("keydown",n=>{n.key==="Enter"&&(n.preventDefault(),i.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))}),{element:i,read:()=>s==="number"?i.value===""?null:Number(i.value):i.value,validate:()=>e.field.required&&!i.value.trim()?"此项必填":i.checkValidity()?void 0:i.validationMessage||"请填写有效值",focus:()=>i.focus()}}const yn=s=>!Array.isArray(s)||!s.length?[]:Array.isArray(s[0])?s.map(e=>e.map(String)):[s.map(String)];function bt(s,e){const t=[];for(const i of e){const n=s.find(o=>o.id===i);t.push((n==null?void 0:n.label)||i),s=(n==null?void 0:n.children)||[]}return t.join(" / ")}function Ma(s){const e=P("div","fc-tags");for(const t of yn(s.value)){const i=P("span","fc-tag");i.append(P("span","fc-tag-label",bt(Be(s.field),t))),e.append(i)}return e.children.length||e.append(P("span","fc-empty","待填")),e}function ka(s,e){const t=P("div","fc-cascade"),i=P("div","fc-choice-selection"),n=P("input","fc-choice-search");n.placeholder="",n.autocomplete="off",n.ariaLabel="输入以搜索"+e.field.label,n.disabled=e.readonly;const o=()=>{n.size=Math.max(1,[...n.value].length+1)};o();const a=P("div","fc-cascade-columns"),l=P("div","fc-error");l.setAttribute("role","status");const r=Be(e.field);let d=yn(e.value),c=[];const p=[],f=(y,R,M=!1)=>y.forEach(T=>{var W;(W=T.children)!=null&&W.length?f(T.children,[...R,T.id],M||!!T.disabled):p.push({path:[...R,T.id],disabled:M||!!T.disabled})});f(r,[]);const u=(y,R)=>JSON.stringify(y)===JSON.stringify(R),h=e.layout!=="compact"&&!e.readonly;let g;const v=()=>{const y=g;g=void 0,y==null||y.close()},m=()=>{!h||g||e.readonly||(g=$t({anchor:n.parentElement||t,content:a,width:"anchor",gap:4,onDismiss:()=>{g=void 0}}))},C=()=>{!h||!g||(v(),t.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},S=y=>{if(e.readonly)return;const R=d.findIndex(M=>u(M,y));if(s&&R>=0)d.splice(R,1);else{if(s&&e.field.maxSelections&&d.length>=e.field.maxSelections){l.textContent="最多可选择 "+e.field.maxSelections+" 项";return}d=s?[...d,y]:[y]}l.textContent="",b(),t.dispatchEvent(new Event("change",{bubbles:!0})),s||C()},b=()=>{var T,W;if(i.replaceChildren(),a.replaceChildren(),d.forEach(E=>{const x=P("span","fc-tag");x.append(P("span","fc-tag-label",bt(r,E)));const k=P("span","fc-tag-slot"),$=P("button","fc-choice-remove","×");$.type="button",$.disabled=e.readonly,$.ariaLabel="移除"+bt(r,E),$.onclick=()=>{d=d.filter(q=>!u(E,q)),b(),t.dispatchEvent(new Event("change",{bubbles:!0}))},k.append($),x.append(k),i.append(x)}),n.value.trim()){const E=p.filter(x=>!x.disabled&&bt(r,x.path).toLocaleLowerCase().includes(n.value.trim().toLocaleLowerCase()));for(const{path:x}of E){const k=P("button","fc-option",bt(r,x));k.type="button",k.disabled=e.readonly,k.setAttribute("aria-pressed",String(d.some($=>u($,x)))),k.onclick=()=>S(x),a.append(k)}a.classList.add("is-search"),E.length||a.append(P("p","fc-empty","暂无匹配路径"));return}a.classList.remove("is-search");let y=r,R=[],M=0;for(;y.length;){const E=P("div","fc-cascade-column");E.setAttribute("role","group"),E.ariaLabel="第"+(M+1)+"级";for(const k of y.filter($=>!$.disabled)){const $=[...R,k.id],q=!!((T=k.children)!=null&&T.length),F=P("button","fc-option",k.label+(q?" ›":""));F.type="button",F.disabled=e.readonly,F.classList.toggle("selected",q?c[M]===k.id:d.some(G=>u(G,$))),F.setAttribute(q?"aria-expanded":"aria-pressed",String(q?c[M]===k.id:d.some(G=>u(G,$)))),F.onclick=()=>{var G,I;q?(c=$,b(),(I=(G=a.lastElementChild)==null?void 0:G.querySelector("button"))==null||I.focus()):S($)},E.append(F)}a.append(E);const x=y.find(k=>k.id===c[M]&&!k.disabled);if(!((W=x==null?void 0:x.children)!=null&&W.length))break;R=[...R,x.id],y=x.children,M++}r.length||a.append(P("p","fc-empty","暂无可选分类"))};if(n.oninput=()=>{o(),b()},n.onfocus=m,a.onkeydown=y=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(y.key))return;const R=y.target,T=[...(R.closest(".fc-cascade-column")||a).querySelectorAll("button:not(:disabled)")];if(!T.length)return;y.preventDefault();const W=T.indexOf(R);T[y.key==="Home"?0:y.key==="End"?T.length-1:(W+(y.key==="ArrowDown"?1:-1)+T.length)%T.length].focus()},t.append(i,n,l),h){const y=P("span","fc-field-chevron");y.setAttribute("aria-hidden","true"),t.append(y),t.addEventListener("click",()=>m())}else t.append(a);return b(),{element:t,content:h?a:void 0,read:()=>s?d.map(y=>[...y]):[...d[0]||[]],focus:()=>{n.focus(),m()},deactivate:()=>{n.value="",o(),v()},destroy:()=>v(),validate:()=>e.field.required&&!d.length?"请选择分类":void 0}}const Ye=s=>String(s).padStart(2,"0"),li=s=>`${s.getFullYear()}-${Ye(s.getMonth()+1)}-${Ye(s.getDate())}`;function Ht(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())&&li(t)===s}const bn=s=>{var e,t,i;return{time:((e=s.field.dateOptions)==null?void 0:e.showTime)??s.field.kind!=="date",range:((t=s.field.dateOptions)==null?void 0:t.showRange)??!1,seconds:((i=s.field.dateOptions)==null?void 0:i.showSeconds)??s.field.kind==="datetime"}};function Sn(s){const{time:e,range:t,seconds:i}=bn(s),o=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(a=>e?String(a).slice(0,i?19:16).replace("T"," "):String(a).slice(0,10)).join(" 至 ");return P("div",`fc-value fc-${s.className||""}${o?"":" fc-empty"}`,o||"待填")}function Ta(s){const{time:e,range:t,seconds:i}=bn(s),n=P("div","fc-calendar"),o=Array.isArray(s.value)?s.value:[s.value],a=[0,1].map(A=>String(o[A]||"").slice(0,10)),l=[0,1].map(A=>(String(o[A]||"").slice(11,16)||"00:00")+(i?":"+(String(o[A]||"").slice(17,19)||"00"):""));let r=0,d=!1,c=Ht(a[0])?new Date(`${a[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const p=P("div","fc-calendar-panel"),f=P("div","fc-calendar-inputs"),u=[],h=()=>n.dispatchEvent(new Event("change",{bubbles:!0})),g=P("div","fc-error");g.setAttribute("role","status");const v=()=>{if(a.some(A=>A&&!Ht(A)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!a[0])return"请选择日期";if(t&&!!a[0]!=!!a[1])return"请选择完整的日期范围";if(e&&l.slice(0,t?2:1).some(A=>!(i?/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/:/^([01]\d|2[0-3]):[0-5]\d$/).test(A)))return"请输入有效时间";if(t&&a[0]&&`${a[0]}T${e?l[0]:""}`>`${a[1]}T${e?l[1]:""}`)return"结束日期时间不能早于开始日期时间"},m=()=>{g.textContent=v()||"",g.textContent||h()};for(let A=0;A<(t?2:1);A++){const O=P("input","fc-input fc-calendar-date");O.type="text",O.value=a[A],O.placeholder=t?A?"结束日期":"开始日期":"YYYY-MM-DD",O.ariaLabel=t?O.placeholder:s.field.label,O.disabled=s.readonly,O.onfocus=()=>{if(r=A,d=A===1,Ht(a[A])){const V=new Date(`${a[A]}T12:00:00`);c=new Date(V.getFullYear(),V.getMonth(),1)}D()},O.addEventListener("change",V=>{if(V.stopPropagation(),a[A]=O.value.trim(),Ht(a[A])){const _=new Date(`${a[A]}T12:00:00`);c=new Date(_.getFullYear(),_.getMonth(),1)}D(),m()}),f.append(O),u.push(O)}const C=P("div","fc-calendar-header"),S=P("button","fc-calendar-month");S.type="button",S.ariaLabel="选择年份和月份",S.setAttribute("aria-expanded","false"),S.setAttribute("aria-live","polite");const b=(A,O,V)=>{const _=P("button","fc-calendar-nav");return _.type="button",_.ariaLabel=A,_.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${V?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,O>0&&_.classList.add("next"),_.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+O,1),D()},_};C.append(b("上一年",-12,!0),b("上个月",-1,!1),S,b("下个月",1,!1),b("下一年",12,!0));const y=P("div","fc-calendar-weekdays");for(const A of["日","一","二","三","四","五","六"])y.append(P("span","",A));const R=P("div","fc-calendar-days");R.setAttribute("role","group"),R.ariaLabel="选择日期";const M=P("div","fc-calendar-period");M.hidden=!0;const T=P("button","fc-calendar-back","‹ 返回选择日期");T.type="button";const W=P("div","fc-calendar-period-columns"),E=P("div","fc-calendar-period-list");E.setAttribute("role","group"),E.ariaLabel="年份";const x=P("div","fc-calendar-period-list");x.setAttribute("role","group"),x.ariaLabel="月份";const k=P("div","fc-calendar-period-list");k.ariaLabel="秒",k.hidden=!0,W.append(E,x,k),M.append(T,W);let $="period",q=0;const F=[],G=(A=!1)=>{const O=l[q].split(":").map(Number),V=$==="period"?[[E,c.getFullYear(),"年"],[x,c.getMonth()+1,"月"]]:[[E,O[0],"时"],[x,O[1],"分"],[k,O[2],"秒"]];for(const[_,X,N]of V)for(const B of _.querySelectorAll("button")){const Y=Number(B.dataset.value)===X;B.classList.toggle("selected",Y),B.setAttribute("aria-pressed",String(Y)),B.textContent=`${$==="time"?Ye(Number(B.dataset.value)):B.dataset.value}${Y?N:""}`,Y&&A&&(_.scrollTop=Math.max(0,B.offsetTop-108))}},I=(A,O)=>{const V=P("button","fc-calendar-period-option",String(A));return V.type="button",V.dataset.value=String(A),V.ariaLabel=`${$==="time"?Ye(A):A}${$==="time"?O?"时":"分":O?"年":"月"}`,V.disabled=$==="time"&&s.readonly,V.onclick=()=>{if($==="time"){const _=l[q].split(":");_[O?0:1]=Ye(A),l[q]=_.join(":"),F[q].textContent=l[q],G(),m();return}c.setFullYear(O?A:c.getFullYear(),O?c.getMonth():A-1,1),G(),D()},V},L=(A,O=0)=>{if($=A,q=O,E.replaceChildren(),x.replaceChildren(),k.replaceChildren(),k.hidden=A!=="time"||!i,E.ariaLabel=A==="period"?"年份":"小时",x.ariaLabel=A==="period"?"月份":"分钟",A==="period"){for(let V=Math.max(1,c.getFullYear()-100);V<=Math.min(9999,c.getFullYear()+100);V++)E.append(I(V,!0));for(let V=1;V<=12;V++)x.append(I(V,!1))}else{for(let V=0;V<24;V++)E.append(I(V,!0));for(let V=0;V<60;V++)x.append(I(V,!1));if(i)for(let V=0;V<60;V++){const _=P("button","fc-calendar-period-option",Ye(V));_.type="button",_.dataset.value=String(V),_.ariaLabel=Ye(V)+"秒",_.disabled=s.readonly,_.onclick=()=>{const X=l[q].split(":");X[2]=Ye(V),l[q]=X.join(":"),F[q].textContent=l[q],G(),m()},k.append(_)}}n.classList.add("choosing-period"),M.hidden=!1,(A==="period"?S:F[O]).setAttribute("aria-expanded","true"),G(!0),T.focus()};S.onclick=()=>L("period"),T.onclick=()=>{n.classList.remove("choosing-period"),M.hidden=!0;const A=$==="period"?S:F[q];A.setAttribute("aria-expanded","false"),D(),A.focus()},M.addEventListener("keydown",A=>{if(A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),T.click()),!["ArrowUp","ArrowDown","Home","End"].includes(A.key))return;const O=A.target,V=O.closest(".fc-calendar-period-list");if(!V)return;const _=[...V.querySelectorAll("button")],X=_.indexOf(O),N=A.key==="Home"?0:A.key==="End"?_.length-1:Math.max(0,Math.min(_.length-1,X+(A.key==="ArrowDown"?1:-1)));A.preventDefault(),_[N].focus()});function D(){S.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((O,V)=>O.classList.toggle("active",V===r)),R.replaceChildren();for(let O=0;O<c.getDay();O++)R.append(P("span","fc-calendar-blank"));const A=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let O=1;O<=A;O++){const V=li(new Date(c.getFullYear(),c.getMonth(),O)),_=P("button","fc-calendar-day",String(O));_.type="button",_.ariaLabel=V,_.disabled=s.readonly;const X=a[0]===V||t&&a[1]===V;_.classList.toggle("selected",X),_.setAttribute("aria-pressed",String(X)),_.classList.toggle("in-range",t&&!!a[0]&&!!a[1]&&V>a[0]&&V<a[1]),V===li(new Date)&&(_.classList.add("today"),_.setAttribute("aria-current","date")),_.onclick=()=>{var N;t?d?(a[1]=V,a[0]&&a[1]<a[0]&&([a[0],a[1]]=[a[1],a[0]]),r=0,d=!1):(a[0]=V,a[1]="",r=1,d=!0):a[0]=V,u.forEach((B,Y)=>B.value=a[Y]),D(),!t||a[1]?m():g.textContent="",(N=R.querySelector(`[aria-label="${V}"]`))==null||N.focus(),(!t||a[1])&&n.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))},R.append(_)}}p.append(C,y,R,M);const z=P("div","fc-calendar-time");if(e){for(let A=0;A<(t?2:1);A++){const O=P("div","fc-calendar-time-field"),V=t?A?"结束时间":"开始时间":"时间",_=P("button","fc-input fc-calendar-time-trigger",l[A]);_.type="button",_.disabled=s.readonly,_.ariaLabel=V,_.setAttribute("aria-expanded","false"),_.onclick=()=>L("time",A),F.push(_),O.append(P("span","",V),_),z.append(O)}p.append(z)}const U=P("button","fc-calendar-clear","清空");U.type="button",U.disabled=s.readonly,U.onclick=()=>{a.fill(""),u.forEach(A=>A.value=""),r=0,d=!1,D(),m()},n.append(f,p,U,g);const K=()=>{const A=a.slice(0,t?2:1).map((O,V)=>O?O+(e?`T${l[V]}`:""):"");return t?A.some(Boolean)?A:[]:A[0]};if(s.layout==="compact"||s.readonly)return D(),{element:n,read:K,validate:v,focus:()=>{u[0].focus()},deactivate:()=>{n.classList.remove("choosing-period"),M.hidden=!0}};const Z=P("div","fc-date-mirror"),ie=()=>Z.replaceChildren(Sn({...s,value:K()})),pe=P("span","fc-field-chevron");pe.setAttribute("aria-hidden","true");const J=P("div","fc-date-trigger");J.tabIndex=0,J.setAttribute("role","button"),J.ariaLabel=`编辑${s.field.label}`,J.append(Z,pe);let ce;const fe=()=>{const A=ce;ce=void 0;const O=!!A&&A.element.contains(document.activeElement);A==null||A.close(),pe.classList.remove("is-open"),O&&queueMicrotask(()=>{ce||!J.isConnected||J.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))})},ne=()=>{ce||s.readonly||(ie(),ce=$t({anchor:J,content:n,width:320,gap:4,onDismiss:()=>{ce=void 0,pe.classList.remove("is-open")}}),pe.classList.add("is-open"))};return J.onclick=()=>ne(),J.onkeydown=A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),ne())},n.addEventListener("focusout",A=>{const O=A.relatedTarget;if(O&&(n.contains(O)||J.contains(O)||Ke(O)))return;const V=new Event("focusout",{bubbles:!0});O&&Object.defineProperty(V,"relatedTarget",{value:O}),J.dispatchEvent(V)}),n.addEventListener("change",()=>J.dispatchEvent(new Event("change",{bubbles:!0}))),D(),ie(),{element:J,content:n,inputRoot:J,read:K,validate:v,focus:()=>{ne(),u[0].focus()},deactivate:fe,destroy:fe}}const Je=s=>s==null?"":String(s),lt=s=>s.dispatchEvent(new Event("change",{bubbles:!0}));function di(s){try{const e=new URL(Je(s));return["http:","https:"].includes(e.protocol)?e.href:void 0}catch{return}}function St(s){return P("div","fc-value fc-plain fc-"+(s.className||"")+(s.value==null||s.value===""?" fc-empty":""),Je(s.value)||"待填")}function Ot(s,e){const t=e==="textarea"?P("textarea","fc-input fc-textarea"):P("input","fc-input");return t instanceof HTMLInputElement&&(t.type=e),t instanceof HTMLTextAreaElement&&pn(t),t.value=Je(s.value),t.disabled=s.readonly,t.required=!!s.field.required,t.ariaLabel=s.field.label,t.placeholder=s.field.placeholder||"请输入"+s.field.label,s.field.maxLength!==void 0&&(t.maxLength=s.field.maxLength),{element:t,read:()=>t.value,focus:()=>t.focus(),validate:()=>e==="url"&&t.value&&!di(t.value)?"请输入 http 或 https 链接":t.checkValidity()?void 0:"请填写有效的"+s.field.label}}function La(s){const e=P("div","fc-link-value"),t=di(s.value);if(!t)return St(s);const i=P("a","fc-link",Je(s.value));return i.href=t,i.target="_blank",i.rel="noopener noreferrer",i.onclick=n=>n.stopPropagation(),e.append(P("span","fc-link-icon","↗"),i),e}function En(s){let e=s.value===!0;const t=P("div","fc-switch-field"),i=P("button","fc-switch");i.type="button",i.setAttribute("role","switch"),i.ariaLabel=s.field.label,i.disabled=s.readonly;const n=P("span"),o=()=>{i.setAttribute("aria-checked",String(e)),n.textContent=e?"是":"否"};return i.onclick=()=>{s.readonly||(e=!e,o(),lt(t))},t.append(i,n),o(),{element:t,read:()=>e,focus:()=>i.focus()}}function Na(s){return En({...s,readonly:!0}).element}function Ia(s){const e=P("div","fc-signals"),t=Array.isArray(s.value)?s.value:[s.value];for(const i of t.filter(n=>n!=null&&n!=="")){const n=typeof i=="object"?i:{status:i},o=n.status??n.value,a=o===!0||o==="passed"||o==="success",l=P("span","fc-signal "+(a?"is-success":"is-pending"),(a?"● ":"○ ")+Je(n.label||n.name||(a?"已满足":o===!1?"未满足":o||"等待信号")));e.append(l)}return e.children.length||e.append(P("span","fc-empty","等待外部信号")),e}function Aa(s){const e=s.value&&typeof s.value=="object"?s.value.display??s.value.value:s.value;return St({...s,value:e!=null&&typeof e!="object"?e:""})}function Da(s,e){const t=P("div","fc-readonly");return t.append(e(s),P("small","fc-service-note","由系统更新 · 只读")),{element:t,read:()=>s.value}}function xn(s){var h,g,v;let e=Array.isArray(s.value)?structuredClone(s.value):[];const t=P("div","fc-attachments"),i=P("div","fc-file-list"),n=P("label","fc-upload-zone","+ 上传附件"),o=P("input");o.type="file",o.multiple=!0,o.ariaLabel="上传"+s.field.label,o.accept=((h=s.field.attachmentOptions)==null?void 0:h.accept)||"",o.disabled=s.readonly||!((g=s.services)!=null&&g.upload);const a=P("p","fc-error");a.setAttribute("role","status");const l=P("button","fc-retry","重试上传");l.type="button",l.hidden=!0;let r=[],d=!1,c=!1,p;const f=()=>{i.replaceChildren(),e.forEach((m,C)=>{const S=P("div","fc-file-row"),b=di(m.url),y=b?P("a","fc-link",m.name):P("span","",m.name);if(y.tagName==="A"){const R=y;R.href=b,R.target="_blank",R.rel="noopener noreferrer"}if(S.append(P("span","fc-file-icon","▤"),y),m.size!=null&&S.append(P("small","fc-file-size",Math.ceil(m.size/1024)+" KB")),!s.readonly){const R=P("button","fc-file-remove","×");R.type="button",R.disabled=d,R.ariaLabel="移除"+m.name,R.onclick=()=>{e.splice(C,1),f(),lt(t)},S.append(R)}i.append(S)}),e.length||i.append(P("span","fc-empty","暂无附件"))},u=async()=>{var S;if(!((S=s.services)!=null&&S.upload)||s.readonly||d||!r.length)return;const m=s.field.attachmentOptions;if(m!=null&&m.maxFiles&&e.length+r.length>m.maxFiles){a.textContent="最多上传 "+m.maxFiles+" 个文件";return}if(m!=null&&m.maxBytes&&r.some(b=>b.size>m.maxBytes)){a.textContent="文件大小超过限制";return}const C=((m==null?void 0:m.accept)||"").split(",").map(b=>b.trim().toLowerCase()).filter(Boolean);if(C.length&&r.some(b=>!C.some(y=>y.startsWith(".")?b.name.toLowerCase().endsWith(y):y.endsWith("/*")?b.type.toLowerCase().startsWith(y.slice(0,-1)):b.type.toLowerCase()===y))){a.textContent="文件类型不符合要求";return}p=new AbortController,d=!0,o.disabled=!0,l.hidden=!0,a.textContent="上传中…",t.setAttribute("aria-busy","true"),f();try{const b=await s.services.upload(s.field,r,p.signal);if(c)return;if(b.length!==r.length||b.some(y=>!y.id||!y.name))throw new Error("Invalid file references");e=[...e,...b],r=[],a.textContent="",o.value=""}catch{c||(a.textContent="上传失败,已保留原有附件",l.hidden=!1)}finally{c||(d=!1,o.disabled=!1,t.setAttribute("aria-busy","false"),f(),r.length||lt(t))}};return o.onchange=m=>{m.stopPropagation(),r=Array.from(o.files||[]),u()},l.onclick=()=>void u(),n.append(o),t.append(i),s.readonly||(t.append(n),(v=s.services)!=null&&v.upload||t.append(P("p","fc-service-note","上传服务未接入"))),t.append(a,l),f(),{element:t,read:()=>structuredClone(e),focus:()=>o.focus(),validate:()=>d?"请等待上传完成":r.length?"请完成或重新选择上传文件":s.field.required&&!e.length?"请上传附件":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function Rn(s){if(s&&typeof s=="object"&&!Array.isArray(s)){const e=s;return{selected:Array.isArray(e.selected)?[...e.selected]:[],counts:{...e.counts},total:e.total}}return{selected:[],counts:{}}}function Mn(s,e){var u;let t=Rn(s.value),i=[...t.selected];const n=e==="attitude"?[{id:"like",label:"赞同"}]:Be(s.field),o=P("div","fc-vote"),a=P("div","fc-vote-list"),l=P("p","fc-error");l.setAttribute("role","status");const r=P("button","fc-vote-submit","提交投票");r.type="button";let d=!1,c=!1,p;const f=()=>{var g,v;a.replaceChildren();const h=Math.max(1,...Object.values(t.counts));for(const m of n){const C=P("button","fc-vote-option");C.type="button",C.disabled=s.readonly||d||!((g=s.services)!=null&&g.vote)||!!m.disabled,C.classList.toggle("selected",i.includes(m.id)),C.setAttribute("aria-pressed",String(i.includes(m.id)));const S=P("span","fc-vote-bar");S.style.width=(t.counts[m.id]||0)/h*100+"%",C.append(S,P("span","",(e==="attitude"?"♡ ":"")+m.label),P("strong","",String(t.counts[m.id]||0))),C.onclick=()=>{i=i.includes(m.id)?i.filter(b=>b!==m.id):e==="multi"?[...i,m.id]:[m.id],f()},a.append(C)}n.length||a.append(P("p","fc-empty","暂无投票选项")),r.disabled=d||!((v=s.services)!=null&&v.vote)||!n.length,r.textContent=d?"提交中…":"提交投票"};return r.onclick=async()=>{var h;if(!(d||s.readonly||!((h=s.services)!=null&&h.vote))){d=!0,l.textContent="",p=new AbortController,o.setAttribute("aria-busy","true"),f();try{const g=await s.services.vote(s.field,i,p.signal);if(c)return;t=Rn(g),i=[...t.selected]}catch{c||(l.textContent="投票失败,请重试")}finally{c||(d=!1,o.setAttribute("aria-busy","false"),f(),l.textContent||lt(o))}}},o.append(a),s.readonly||(o.append(r),(u=s.services)!=null&&u.vote||o.append(P("p","fc-service-note","投票服务未接入"))),o.append(l),f(),{element:o,read:()=>structuredClone(t),validate:()=>d?"请等待投票完成":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function Fa(s){const e=s.value&&typeof s.value=="object"?s.value:{},t=P("div","fc-location"),n=[["address","地址","text"],["longitude","经度","number"],["latitude","纬度","number"]].map(([a,l,r])=>{const d=P("label","fc-location-part",l),c=P("input","fc-input");return c.type=r,c.value=Je(e[a]),c.disabled=s.readonly,c.ariaLabel=l,c.placeholder=l,r==="number"&&(c.step="any",c.min=a==="longitude"?"-180":"-90",c.max=a==="longitude"?"180":"90"),d.append(c),t.append(d),c}),o=()=>n.every(a=>!a.value)?null:{address:n[0].value,longitude:n[1].value?Number(n[1].value):null,latitude:n[2].value?Number(n[2].value):null};return{element:t,read:o,focus:()=>n[0].focus(),validate:()=>{if(!o())return s.field.required?"请填写位置":void 0;if(n.slice(1).some(a=>a.value===""||!a.checkValidity()))return"请填写有效的经纬度"}}}function Pa(s){const e=s.value;return St({...s,value:e&&typeof e=="object"?Je(e.address)||[e.longitude,e.latitude].filter(t=>t!=null).join(", "):""})}function $a(s,e){const t=P("div","fc-composite"),i=P("div","fc-composite-rows"),n=P("button","fc-composite-add","+ 添加一组");n.type="button";const o=s.field.compositeFields||[],a=[];let l=!1;const r=u=>({...u.value,...Object.fromEntries(u.editors.map(({field:h,editor:g})=>[h.key,g.read()]))}),d=u=>{u.editors.forEach(({editor:h})=>{var g;return(g=h.destroy)==null?void 0:g.call(h)}),u.remove&&(u.remove.onclick=null),u.element.remove()},c=P("p","fc-empty","暂无记录"),p=()=>{a.forEach((u,h)=>{u.legend.textContent="第 "+(h+1)+" 组"}),n.disabled=s.readonly||!o.length||a.length>=(s.field.maxRows||100),a.length?c.remove():i.append(c)},f=u=>{const h=P("fieldset","fc-composite-row"),g=P("legend");h.append(g);const v=o.map(C=>{const S=e(C),b=S.createEditor({...s,field:C,value:u[C.key],readonly:s.readonly||C.editable===!1||!!S.readonly,focusBoundary:void 0,onSelectedOptions:R=>{var M;(M=s.services)!=null&&M.searchOptions&&(C.choices=[...new Map([...Be(C),...R].map(T=>[T.id,T])).values()])}}),y=P("div","fc-composite-field");return y.append(P("label","",C.label+(C.required?" *":"")),b.element),h.append(y),{field:C,editor:b}}),m={value:u,element:h,legend:g,editors:v};if(!s.readonly){const C=P("button","fc-composite-remove","删除此组");C.type="button",C.onclick=()=>{if(l)return;const S=a.indexOf(m);S<0||(d(m),a.splice(S,1),p(),lt(t))},m.remove=C,h.append(C)}a.push(m),i.append(h),p()};for(const u of Array.isArray(s.value)?s.value:[])f(structuredClone(u));return n.onclick=()=>{l||n.disabled||(f({}),lt(t))},t.append(i),s.readonly||t.append(n),o.length||t.append(P("p","fc-service-note","请配置复合子字段")),p(),{element:t,read:()=>a.map(r),validate:()=>{var u;if(s.field.required&&!a.length)return"请至少添加一组";for(const[h,g]of a.entries())for(const{field:v,editor:m}of g.editors){const C=(u=m.validate)==null?void 0:u.call(m);if(C)return"第 "+(h+1)+" 组 · "+v.label+":"+C}},destroy:()=>{l||(l=!0,n.onclick=null,a.forEach(d))}}}class _e extends Le{renderDisplay(e){return{element:Ra(e)}}renderEditing(e){return Cn("text",e)}}class kn extends _e{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,kind:"number"}})}renderEditing(e){return Cn("number",e)}}class Tn extends _e{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,control:"richText"}})}renderEditing(e){return xa(e)}}class Ln extends _e{renderDisplay(e){return{element:St(e)}}renderEditing(e){return Ot(e,"textarea")}}class ci extends _e{renderDisplay(e){return{element:La(e)}}renderEditing(e){return Ot(e,"url")}}class Nn extends _e{renderEditing(e){return Ot(e,"email")}}class In extends _e{renderEditing(e){return Ot(e,"tel")}}class dt extends Le{constructor(){super(...arguments);w(this,"multiple",!1);w(this,"variant","choice")}renderDisplay(t){return{element:Sa(t,this.variant==="radio"?"choice":this.variant)}}renderEditing(t){return mn(this.multiple,t,this.variant)}}class An extends dt{constructor(){super(...arguments);w(this,"multiple",!0)}}class Dn extends dt{constructor(){super(...arguments);w(this,"variant","radio")}}class ui extends dt{constructor(){super(...arguments);w(this,"variant","person")}}class Fn extends ui{constructor(){super(...arguments);w(this,"multiple",!0)}}class hi extends dt{constructor(){super(...arguments);w(this,"variant","relation")}}class Pn extends hi{constructor(){super(...arguments);w(this,"multiple",!0)}}class pi extends Le{constructor(){super(...arguments);w(this,"multiple",!1)}renderDisplay(t){return{element:Ma(t)}}renderEditing(t){return ka(this.multiple,t)}}class $n extends pi{constructor(){super(...arguments);w(this,"multiple",!0)}}class fi extends Le{normalize(e){return e}renderDisplay(e){return{element:Sn(this.normalize(e))}}renderEditing(e){return Ta(this.normalize(e))}}class gi extends fi{constructor(){super(...arguments);w(this,"range",!1)}normalize(t){return{...t,field:{...t.field,dateOptions:{showTime:!1,showRange:this.range,...t.field.dateOptions}}}}}class Hn extends gi{constructor(){super(...arguments);w(this,"range",!0)}}class On extends Le{renderDisplay(e){return{element:Na(e)}}renderEditing(e){return En(e)}}class Bn extends Le{renderDisplay(e){return xn({...e,readonly:!0})}renderEditing(e){return xn(e)}}class Vn extends Le{renderDisplay(e){return{element:Pa(e)}}renderEditing(e){return Fa(e)}}class Bt extends Le{constructor(){super(...arguments);w(this,"mode","attitude")}renderDisplay(t){return Mn({...t,readonly:!0},this.mode)}renderEditing(t){return Mn(t,this.mode)}}class Gn extends Bt{constructor(){super(...arguments);w(this,"mode","single")}}class zn extends Bt{constructor(){super(...arguments);w(this,"mode","multi")}}class ct extends Le{isReadonly(){return!0}constructor(e){super({...e,readonly:!0})}renderDisplay(e){return{element:Aa(e)}}renderEditing(e){return Da(e,t=>this.renderDisplay(t).element)}}class mi extends ct{renderDisplay(e){return{element:Ia(e)}}}class _n extends _e{renderDisplay(e){const t=document.createElement("button");return t.type="button",t.className="fc-detail-link",t.textContent=e.field.label,t.onclick=i=>{var n;i.stopPropagation(),(n=e.onAction)==null||n.call(e,{type:"open",value:e.value})},{element:t,destroy:()=>{t.onclick=null}}}}class Wn extends Le{constructor(e,t){super(e),this.resolve=t}renderDisplay(e){var n;if(e.layout==="compact")return{element:St({...e,value:Array.isArray(e.value)&&e.value.length?e.value.length+" 组记录":""})};const t=document.createElement("div");t.className="fc-composite";const i=[];for(const o of Array.isArray(e.value)?e.value:[]){const a=document.createElement("fieldset");a.className="fc-composite-row";for(const l of e.field.compositeFields??[]){const r=document.createElement("label");r.textContent=l.label;const d={...e,field:l,value:o[l.key],readonly:!0},c=this.resolve(l),p=((n=c.renderView)==null?void 0:n.call(c,d))??{element:c.render(d)};i.push(p),a.append(r,p.element)}t.append(a)}return{element:t,destroy:()=>i.forEach(o=>{var a;return(a=o.destroy)==null?void 0:a.call(o)})}}renderEditing(e){return $a(e,this.resolve)}}const Ha={textarea:"保留换行的纯文本,支持长度限制",radio:"平铺选项,一次选择一项",cascadeSingle:"逐级浏览分类,选择完整路径",cascadeMulti:"逐级浏览并选择多条路径",person:"按姓名搜索,以稳定人员 ID 保存",multiPerson:"按姓名搜索,以稳定人员 ID 保存",date:"日历选择和直接输入,支持清空",dateRange:"连续选择起止日期,校验完整范围",url:"填写网址并在新窗口安全打开",cloudDocument:"添加云文档链接,点击打开原文档",email:"邮箱输入与格式校验",phone:"支持国家区号的电话输入",switch:"以是或否记录布尔状态",attachment:"文件列表、上传与删除,支持上传失败重试",location:"填写地址和经纬度,校验坐标边界",relation:"按名称或编号搜索工作项,点击名称打开详情",multiRelation:"按名称或编号搜索工作项,点击名称打开详情",attitudeVote:"选择并提交投票,结果以宿主服务回读为准",singleVote:"选择并提交投票,结果以宿主服务回读为准",multiVote:"选择并提交投票,结果以宿主服务回读为准",externalSignal:"由外部系统更新,系统内只读",externalMultiSignal:"由外部系统更新,系统内只读",formula:"展示服务端计算结果,不可手工覆盖",aggregate:"展示服务端计算结果,不可手工覆盖",ai:"展示服务端计算结果,不可手工覆盖",system:"展示服务端计算结果,不可手工覆盖",composite:"可重复字段组,复用已注册子控件并逐组校验",multiPersonComposite:"可重复字段组,复用已注册子控件并逐组校验",text:"单行输入,支持清空和必填校验",richText:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",select:"从字段配置中选择一个选项",multiSelect:"点击标签选择多项,保存为数组",number:"支持小数和负数,空值与零分别保存",dateTime:"日历、时间与日期范围",detail:"由调用方处理关联内容导航"},Oa={title:"text",longText:"richText",status:"select",richtext:"richText",single_select:"select",multi_select:"multiSelect",user:"person",multi_user:"multiPerson",multi_person:"multiPerson",cascade_select:"cascadeSingle",cascade_single:"cascadeSingle",cascade_multi:"cascadeMulti",daterange:"dateRange",date_range:"dateRange",datetime:"dateTime",multi_relation:"multiRelation",attitude_vote:"attitudeVote",single_vote:"singleVote",multi_vote:"multiVote",vote:"attitudeVote",external_signal:"externalSignal",external_multi_signal:"externalMultiSignal",multi_person_composite:"multiPersonComposite",cloud_document:"cloudDocument"},Ba=[["text","单行文本",_e,"文本","T"],["richText","富文本",Tn,"文本","¶"],["select","单选",dt,"选择","◉"],["multiSelect","多选",An,"选择","☑"],["number","数字",kn,"其他","#"],["dateTime","日期时间",fi,"日期","◷"],["detail","详情页查看",_n,"关联工作项","↗"],["textarea","多行文本",Ln,"文本","≡"],["radio","单选按钮",Dn,"选择","◉"],["cascadeSingle","级联单选",pi,"选择","⑂"],["cascadeMulti","级联多选",$n,"选择","⑂"],["person","单选人员",ui,"人员","♙"],["multiPerson","多选人员",Fn,"人员","♙"],["date","日期",gi,"日期","▦"],["dateRange","日期区间",Hn,"日期","▦"],["url","URL 链接",ci,"其他","↗"],["cloudDocument","关联云文档",ci,"其他","▤"],["email","邮箱",Nn,"其他","@"],["phone","电话",In,"其他","☎"],["switch","开关",On,"其他","◐"],["attachment","附件",Bn,"其他","⌑"],["location","地理位置",Vn,"其他","⌖"],["relation","单选关联工作项",hi,"关联工作项","↗"],["multiRelation","多选关联工作项",Pn,"关联工作项","↗"],["attitudeVote","表态投票",Bt,"投票","♡"],["singleVote","单选投票",Gn,"投票","♡"],["multiVote","多选投票",zn,"投票","♡"],["externalSignal","系统外信号",mi,"系统","◌",!0],["externalMultiSignal","多值系统外信号",mi,"系统","◌",!0],["formula","公式计算",ct,"系统","ƒ",!0],["aggregate","聚合计算",ct,"系统","ƒ",!0],["ai","AI 字段",ct,"系统","ƒ",!0],["system","系统字段",ct,"系统","ƒ",!0]];function qn(s=[]){const e=new Map,t=a=>{if(!/^[A-Za-z][\w-]*$/.test(a.id))throw new Error("Invalid control id");if(e.has(a.id))throw new Error(`Control already registered: ${a.id}`);e.set(a.id,a)},i=a=>{const l=a.control||Oa[a.kind||"text"]||a.kind||"text",r=e.get(l);if(!r)throw new Error(`Unknown control: ${l}`);return r},n=a=>i(a.field).create(a),o=a=>{const l=i(a);return{...l,render:r=>l.create(r).render().element,renderView:r=>l.create(r).render(),createEditor:r=>l.create(r).createEditor()}};for(const[a,l,r,d,c,p]of Ba)t({id:a,label:l,description:Ha[a]||l,glyph:c,group:d,readonly:p,action:a==="detail"?"view":a==="select"||a==="multiSelect"?"select":void 0,create:f=>new r({...f,readonly:p||f.readonly})});for(const[a,l]of[["composite","复合字段"],["multiPersonComposite","多人复合字段"]])t({id:a,label:l,description:"组合多个已注册字段",glyph:"▦",group:"其他",create:r=>new Wn(r,o)});return s.forEach(t),{register:t,resolve:i,create:n,list:()=>[...e.values()]}}class vi extends Le{constructor(e,t){super(e),this.control=t}renderDisplay(e){return{element:this.control.render(e)}}renderEditing(e){return this.control.createEditor(e)}}const Xe={page(s){return s.page||(s.surface==="cell"?"table":"basic")},render(s,e){const t=P("div","fc-base-control"),i=Xe.page(s);return t.dataset.page=i,t.dataset.mode=s.mode||"default",t.dataset.editable=String(s.canEdit??!s.readonly),t.dataset.readonly=String(s.readonly),t.setAttribute("data-field-control",s.field.control||s.field.kind||"text"),t.append(e),t}},Va=new Set(["select","multiSelect","person","multiPerson","relation","multiRelation","cascadeSingle","cascadeMulti","date","dateRange","dateTime","detail","composite","multiPersonComposite"]);function Et(s){return s.id==="richText"?"rich":Va.has(s.id)?"select":"text"}function Un(s,e,t){if(Xe.page(e)==="table"||e.readonly||s.readonly||e.canEdit===!1)return t;const i=document.createElement("div");i.className="fc-base-control fc-focus-editor",i.dataset.expanded="true",i.tabIndex=-1;const n=Xe.page(e);i.dataset.page=n,i.dataset.mode=n==="table"?"editing":"expanded",i.dataset.controlKey=s.id,i.dataset.box=Et(s);const o=document.createElement("div");o.className="fc-focus-body",o.dataset.box=Et(s),o.append(t.element);const a=document.createElement("div");a.className="fc-focus-trigger",a.tabIndex=0,a.setAttribute("role","button"),a.ariaLabel="编辑"+e.field.label,a.setAttribute("aria-expanded","true"),a.hidden=!0;const l=document.createElement("span");l.className="fc-error fc-focus-error",l.setAttribute("role","status"),i.append(o,a,l);const r=i.ownerDocument,d=e.focusBoundary||i,c=m=>!!m&&(d.contains(m)||Ke(m,i));let p=!1;const f=()=>{p||(o.hidden=!1,a.hidden=!0,i.dataset.expanded="true",i.dataset.mode="editing",a.setAttribute("aria-expanded","true"),l.textContent="",t.focus&&t.focus(),!o.contains(r.activeElement)&&!Ke(r.activeElement,i)&&(Array.from(o.querySelectorAll('input:not([type=hidden]):not(:disabled),textarea:not(:disabled),[contenteditable=true],button:not(:disabled),[tabindex="0"]')).find(C=>!C.closest("[hidden]"))||i).focus())},u=()=>{var b,y,R;if(p||!i.isConnected||i.dataset.expanded==="false")return;const m=(b=t.validate)==null?void 0:b.call(t),C={...e,readonly:!0,canEdit:!1,mode:"default",value:m?e.value:t.read()},S=Xe.render(C,s.render(C));S.inert=!0,a.replaceChildren(S),l.textContent=m?"尚未保存:"+m:"",(y=t.deactivate)==null||y.call(t),i.dataset.expanded="false",i.dataset.mode="default",o.hidden=!0,a.hidden=!1,a.setAttribute("aria-expanded","false"),(R=e.onDeactivate)==null||R.call(e)},h=m=>{if(m.relatedTarget instanceof Node&&c(m.relatedTarget))return;const C=m.target;queueMicrotask(()=>{p||!i.isConnected||c(r.activeElement)||(C&&!C.isConnected&&r.activeElement===r.body?i.focus():u())})},g=()=>{queueMicrotask(()=>{!p&&i.isConnected&&i.dataset.expanded==="true"&&(!r.activeElement||r.activeElement===r.body)&&i.focus()})};a.onclick=m=>{m.stopPropagation(),f()},a.onkeydown=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),f())},d.addEventListener("focusout",h),i.addEventListener("click",g,!0),i.addEventListener("fc-collapse",u);const v=hn(r,{contains:(m,C)=>C.composedPath().includes(d)||c(m),leave:u});return{...t,element:i,focus:f,destroy:()=>{var m;p||(p=!0,v(),d.removeEventListener("focusout",h),i.removeEventListener("click",g,!0),i.removeEventListener("fc-collapse",u),(m=t.destroy)==null||m.call(t))}}}function wi(s){return{...s,context:s,layout:Xe.page(s)==="table"?"compact":"form",className:s.surface,services:s.services?{searchOptions:s.services.searchOptions,upload:s.services.upload,vote:s.services.vote?(e,t,i)=>s.services.vote(e,s.item,t,i):void 0}:void 0,onAction:e=>{e.type==="open"&&s.openDetail(String(e.value||s.item.id))}}}function jn(s=[]){const e=qn(),t=new Map;for(const n of e.list()){const o={...n,render(a){const l=e.create(wi(a));return Xe.render(a,l.render().element)},createEditor(a){const l=e.create(wi(a));return Un(o,a,l.createEditor())}};t.set(n.id,o)}const i=n=>{e.register({...n,create:a=>new vi(a,{render:l=>n.render({...l.context,field:l.field,value:l.value,readonly:l.readonly}),createEditor:l=>n.createEditor({...l.context,field:l.field,value:l.value,readonly:l.readonly})})});const o={...n,render:a=>Xe.render(a,n.render(a)),createEditor(a){const l=new vi(wi(a),{render:r=>n.render({...a,value:r.value}),createEditor:r=>n.createEditor({...a,value:r.value})});return Un(n,a,l.createEditor())}};t.set(n.id,o)};return s.forEach(i),{register:i,list:()=>[...t.values()],resolve:n=>t.get(e.resolve(n).id)}}function Ga(s,e){const t=e[s.field],i=s.value,n=Array.isArray(t)?t.map(String):t==null||t===""?[]:[String(t)];switch(s.op){case"equals":return Array.isArray(t)?n.includes(String(i)):String(t??"")===String(i??"");case"notEqual":return Array.isArray(t)?!n.includes(String(i)):String(t??"")!==String(i??"");case"contains":return n.some(o=>o.includes(String(i??"")));case"notContains":return!n.some(o=>o.includes(String(i??"")));case"in":return(Array.isArray(i)?i.map(String):[String(i??"")]).some(o=>n.includes(o));case"notIn":return!(Array.isArray(i)?i.map(String):[String(i??"")]).some(o=>n.includes(o));case"blank":return n.length===0;case"notBlank":return n.length>0;default:return!0}}function Ne(s,e,t={}){return s?"all"in s?s.all.every(i=>Ne(i,e,t)):"any"in s?s.any.some(i=>Ne(i,e,t)):"not"in s?!Ne(s.not,e,t):Ga(s,e):!0}function et(s,e={}){var t,i,n,o,a,l;return!s||s.all||(t=s.members)!=null&&t.length&&s.members.includes(e.currentUser||"")||(i=s.teams)!=null&&i.length&&(e.teams||[]).some(r=>s.teams.includes(r))||(n=s.roles)!=null&&n.length&&(e.roles||[]).some(r=>s.roles.includes(r))?!0:!((o=s.members)!=null&&o.length||(a=s.teams)!=null&&a.length||(l=s.roles)!=null&&l.length)}const za={empty:"待填",required:"此项必填",simpleMode:"简洁模式",continuous:"连续创建",cancel:"取消",draft:"存草稿",submit:"确认创建",addRole:"添加角色",addMeeting:"添加一组进入选题会"};function _a(s){return s.items!==void 0}function Wa(s,e={}){var X;const t=s.variant,i=s.presentation||(t==="create"?"modal":"drawer"),n={...za,...s.labels},o=e.controls||jn(),a=s.events||{},l={...s.data||{}};let r={...s.context||{}},d=s.fields.map(N=>({...N})),c=(s.tabs||[]).map(N=>({...N})),p=s.items?[...s.items]:d.map(N=>({field:N.key})),f=s.blocks?[...s.blocks]:[],u=s.actions?[...s.actions]:b();const h=t==="create"?"new":"detail";let g=s.fieldState||"display",v=s.simpleMode??!1;const m=s.simpleKeep&&s.simpleKeep.length?new Set(s.simpleKeep):new Set(d.slice(0,1).map(N=>N.key));let C=s.open??!0,S=!1;function b(){return t==="create"?[{id:"continuous",kind:"checkbox",label:n.continuous},{id:"close-overlay",label:n.cancel,variant:"outline"},{id:"save-draft",label:n.draft,variant:"outline"},{id:"submit",kind:"submit",label:n.submit,variant:"primary"}]:[]}const y=N=>d.find(B=>B.key===N);function R(N,B,Y){var we,ge,ae;const Q=Ne(N.visibleWhen,l,r)&&et((we=N.permission)==null?void 0:we.view,r)&&(!B||Ne(B.visibleWhen,l,r))&&(!Y||Ne(Y.visibleWhen,l,r)&&et(Y.visibleScope,r))&&(t!=="create"||N.createVisible!==!1),ue=!!N.required||(N.requiredWhen?Ne(N.requiredWhen,l,r):!1)||(B!=null&&B.requiredWhen?Ne(B.requiredWhen,l,r):!1)||((ge=N.permission)!=null&&ge.required?et(N.permission.required,r):!1),he=N.editable!==!1&&et((ae=N.permission)==null?void 0:ae.edit,r);return{visible:Q,required:!!ue,editable:he}}function M(N){if(l[N.key]===void 0&&(N.defaultMode==="always"&&N.defaultValue!==void 0&&(l[N.key]=N.defaultValue),N.defaultMode==="conditional")){for(const B of N.defaultWhen||[])if(Ne(B.when,l,r)){l[N.key]=B.value;return}}}const T=document.createElement(t==="create"?"form":"article"),W=xe(T,"form-surface",s);T.className=t==="create"?"rowvia-work-items rowvia-field-scope create-dialog form-surface":`rowvia-work-items rowvia-field-scope drawer form-surface${i==="fullscreen"?" is-fullscreen":""}`,T.dataset.variant=t,T.dataset.presentation=i,T.dataset.fieldState=g;let E=[];function x(){var ue,he,we,ge,ae,Se;for(const re of E)re.destroy();E=[],T.innerHTML="";const N=document.createElement("div");if(N.className="drawer-header",(ue=s.slots)!=null&&ue.leading){const re=document.createElement("div");re.className="drawer-leading",k(re,s.slots.leading),N.append(re)}if(N.insertAdjacentHTML("beforeend",`<span class="page-logo">${me("check")}</span><strong>${H(s.title||"")}</strong>`),(he=s.slots)!=null&&he.header&&k(N,s.slots.header),T.append(N),(we=s.slots)!=null&&we.subHeader){const re=document.createElement("div");re.className="detail-sub-header",k(re,s.slots.subHeader),T.append(re)}if((ge=s.slots)!=null&&ge.navigation){const re=document.createElement("div");re.className="detail-navigation",k(re,s.slots.navigation),T.append(re)}const B=F();if(t==="detail"&&B.length){const re=document.createElement("div");re.className="detail-tabs",re.setAttribute("role","tablist");for(const le of B){const se=document.createElement("button");se.type="button",se.className=`detail-tab${le.id===G?" active":""}`,se.dataset.tabId=le.id,se.dataset.detailTab=le.label,se.setAttribute("role","tab"),se.setAttribute("aria-selected",String(le.id===G)),se.textContent=le.label,se.onclick=()=>A(le.id),re.append(se)}const ye=document.createElement("div");ye.className="spacer",re.append(ye),(ae=s.slots)!=null&&ae.tabSuffix&&k(re,s.slots.tabSuffix),T.append(re)}const Y=document.createElement("div");Y.className=t==="create"?"create-body":"drawer-body",t==="create"&&s.simpleMode!==void 0&&Y.append($());const Q=B.find(re=>re.id===G);if(Y.append(I(Q)),T.append(Y),(Se=s.slots)!=null&&Se.footer){const re=document.createElement("div");re.className="form-surface-slot-footer",k(re,s.slots.footer),T.append(re)}u.length&&T.append(q()),t==="create"&&(T.onsubmit=re=>{var le,se;re.preventDefault();const ye=ce();if(ye){(le=a.onInvalid)==null||le.call(a,ye);return}(se=a.onSubmit)==null||se.call(a,J())})}function k(N,B){typeof B=="string"?N.insertAdjacentHTML("beforeend",B):N.append(B)}function $(){const N=document.createElement("div");return N.className="simple-mode",N.innerHTML=`<label><input type="checkbox" id="simple-mode"${v?" checked":""}>${H(n.simpleMode)}</label>`,N.querySelector("input").onchange=B=>O(B.target.checked),N}function q(){const N=document.createElement("div");N.className=t==="create"?"drawer-footer":"drawer-footer form-surface-actions";for(const B of u)if(Ne(B.visibleWhen,l,r)){if(B.kind==="checkbox"){const Y=document.createElement("label");Y.className="continuous",Y.innerHTML=`<input id="${H(B.id)}" type="checkbox"${B.checked?" checked":""}>${H(B.label||"")}`,N.append(Y);continue}if(B.kind==="submit"){const Y=document.createElement("button");Y.type="submit",Y.className=B.variant||"primary",Y.dataset.action=B.id,Y.textContent=B.label||n.submit,N.append(Y);continue}N.insertAdjacentHTML("beforeend",Ce(B.id,B.label||"",B.glyph||"",B.variant||""))}return N}function F(){return c.filter(B=>Ne(B.visibleWhen,l,r)&&et(B.visibleScope,r)).map((B,Y)=>({...B,order:B.order??Y})).sort((B,Y)=>B.order-Y.order)}let G=s.defaultTab||((X=c[0])==null?void 0:X.id);function I(N){var he;const B={data:l,context:r,variant:t,tab:N},Y=document.createElement("div");if(Y.className=t==="create"?"form-surface-body":"detail-fields form-surface-body",!N||N.kind==="form"){const we=(N==null?void 0:N.items)??p;for(const ae of we)if(_a(ae)){const Se=L(ae);Se&&Y.append(Se)}else{const Se=D(ae);Se&&Y.append(Se)}const ge=(N==null?void 0:N.blocks)??f;for(const ae of ge){const Se=z(ae,B);Se&&Y.append(Se)}return Y}const Q=N.kind==="custom"?N.render:((he=e.renderers)==null?void 0:he[N.kind])||N.render,ue=Q?Q(B):"";return typeof ue=="string"?Y.innerHTML=ue:ue&&Y.append(ue),Y}function L(N){const B=Ne(N.visibleWhen,l,r),Y=[];for(const ue of N.items){const he=D(ue);he&&Y.push(he)}if(!B||!Y.length)return null;const Q=document.createElement("section");return Q.className="form-group",Q.dataset.group=N.id,Q.innerHTML=`<p class="form-group-title">${H(N.label)}</p>`,Q.append(...Y),Q}function D(N){var ae;const B=y(N.field);if(!B)return null;const Y=R(B,N,K());if(!Y.visible||v&&!m.has(B.key))return null;M(B);const Q=document.createElement("div");Q.className=t==="create"?"create-field":"detail-row",Q.dataset.field=B.key,N.span===2&&Q.classList.add("span-2"),(N.labelPosition||((ae=s.layout)==null?void 0:ae.labelPosition)||"side")==="top"&&Q.classList.add("label-top");const he=Y.required,we=t==="create"?"<em>*</em>":" *";Q.innerHTML=`<label for="${h}-${H(B.key)}">${H(B.label)}${he?we:""}</label><div class="field-value"><div class="fc-host" data-control-field="${H(B.key)}" data-control-mode="${t}"></div>`+(B.description?`<small class="field-description">${H(B.description)}</small>`:"")+"</div>";const ge=Q.querySelector(".fc-host");return ie(ge,{...B,required:he},he),Q}function z(N,B){var ue;if(!Ne(N.visibleWhen,l,r)||v&&!m.has(N.id))return null;const Y=(ue=e.renderers)!=null&&ue.block?e.renderers.block({...B,block:N}):N.render?N.render(B):U(N,B),Q=document.createElement("div");return Q.className=`form-surface-block block-${N.kind}`,Q.dataset.block=N.id,typeof Y=="string"?Q.innerHTML=Y:Y&&Q.append(Y),Q}function U(N,B){var Y,Q;if(N.kind==="roles"){const ue=document.createElement("div");ue.className=t==="create"?"create-field":"detail-row",ue.innerHTML=`<label>${H(N.label||"角色与人员")}${(Y=N.requiredRoles)!=null&&Y.length?"<em>*</em>":""}</label><div class="role-body"><div class="role-rows"></div><div class="role-actions">${Ce("add-role",n.addRole,"","outline")}</div></div>`;const he=ue.querySelector(".role-rows"),we=(Q=N.roleOptions)!=null&&Q.length?N.roleOptions:["提报人"],ge=N.people??[],ae=()=>{const ye=Array.isArray(l.roles)?l.roles:[];return ye.length||ye.push({name:we[0],person:String(l.owner??B.context.currentUser??"")}),l.roles=ye,ye};let Se=[];const re=()=>{for(const le of Se)le.destroy(),E=E.filter(se=>se!==le);Se=[],he.replaceChildren();const ye=ae();ye.forEach((le,se)=>{const Pe=document.createElement("div");Pe.className="role-line";const Ze=document.createElement("div");Ze.className="fc-host role-select";const $e=document.createElement("div");if($e.className="fc-host role-person",Pe.append(Ze,$e),ye.length>1){const de=document.createElement("button");de.type="button",de.className="role-remove",de.dataset.roleRemove=String(se),de.setAttribute("aria-label","移除角色"),de.textContent="×",Pe.append(de)}he.append(Pe),Se.push(ie(Ze,{key:`role-${se}`,label:"角色",kind:"select",options:we,editable:!0},!1,{get:()=>le.name,set:de=>{le.name=String(de??"")},notify:()=>{var de;return(de=a.onCommit)==null?void 0:de.call(a,"roles",ae(),l)}}),ie($e,{key:`role-person-${se}`,label:"人员",kind:"person",options:ge.map(de=>de.id),choices:ge,editable:!0},()=>{var de;return!!((de=N.requiredRoles)!=null&&de.includes(le.name))},{get:()=>le.person,set:de=>{le.person=String(de??"")},notify:()=>{var de,Ve;se===0&&(l.owner=le.person,(de=a.onCommit)==null||de.call(a,"owner",le.person,l)),(Ve=a.onCommit)==null||Ve.call(a,"roles",ae(),l)}}))})};return re(),ue.addEventListener("click",ye=>{var Pe,Ze,$e;const le=ye.target,se=le.closest("[data-role-remove]");if(se){const de=ae();de.splice(Number(se.dataset.roleRemove),1),de.length||de.push({name:we[0],person:""}),l.owner=((Pe=de[0])==null?void 0:Pe.person)??"",re(),(Ze=a.onChange)==null||Ze.call(a,"roles",de,l);return}if(le.closest('[data-action="add-role"]')){const de=ae();de.push({name:we.find(Ve=>!de.some(ut=>ut.name===Ve))??we[0],person:""}),re(),($e=a.onChange)==null||$e.call(a,"roles",de,l)}}),ue}if(N.kind==="meetings"){const ue=document.createElement("section");return ue.className="detail-section",ue.innerHTML=`<p>${H(N.label||"进入选题会")}</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${Ce("add-meeting",n.addMeeting,"add")}</div>`,ue}return""}function K(){return F().find(N=>N.id===G)}function Z(N,B,Y){return{field:N,value:Y?Y.get():l[N.key]??N.defaultValue??"",item:l,surface:t==="create"?"create":"detail",page:"basic",mode:"default",canEdit:B,readonly:!B,services:e.services,onSelectedOptions:ue=>{(we=>{we.choices=[...new Map([...we.choices||(we.options||[]).map(ge=>({id:ge,label:ge})),...ue].map(ge=>[ge.id,ge])).values()]})(N)},openDetail:ue=>{var he;return(he=a.onOpenDetail)==null?void 0:he.call(a,ue)}}}function ie(N,B,Y,Q){var Zn;const ue=()=>typeof Y=="function"?Y():Y,he=B.editable!==!1&&et((Zn=B.permission)==null?void 0:Zn.edit,r),we=Z(B,he,Q),ge=o.resolve(B),ae=ge.createEditor(we),Se="input,select,textarea,[role=textbox]",re=[ae.content,ae.element].filter(ee=>!!ee).map(ee=>ee.matches(Se)?ee:ee.querySelector(Se)).find(Boolean);re&&(re.id=`${h}-${B.key}`);const ye=document.createElement("div");ye.className="fc-error",ye.setAttribute("role","status");const le=document.createElement("div");le.className="fc-detail-editor",le.dataset.mode="editing",le.dataset.box=Et(ge),le.append(ae.element),N.classList.add("fc-detail-host"),N.dataset.page="basic",N.dataset.mode="default",N.dataset.surface=t==="create"?"create":"detail",N.append(le,ye);const se=document.createElement("div");se.className="fc-detail-preview",se.dataset.box=Et(ge),se.dataset.editable=String(he),se.dataset.surface=t==="create"?"create":"detail",N.prepend(se);const Pe=()=>{if(!N.classList.contains("editing")){N.style.minHeight="";return}N.style.minHeight=`${le.offsetHeight}px`},Ze=ee=>{le.style.minHeight=`${ee}px`,le.style.maxHeight=`${ee}px`},$e=()=>{le.style.maxHeight="",Pe()},de=Et(ge)==="rich",Ve=()=>{var be,xt;if(!he||N.classList.contains("editing"))return;const ee=se.offsetHeight;N.classList.add("editing"),N.dataset.mode="editing",de||Ze(ee),Pe(),(be=ae.focus)==null||be.call(ae),(xt=a.onFieldStateChange)==null||xt.call(a,B.key,"edit")},ut=()=>{if(se.replaceChildren(ge.render({...Z(B,he,Q),readonly:!0,canEdit:!1,mode:"default",value:Q?Q.get():l[B.key]??""})),se.dataset.box==="select"){const ee=document.createElement("span");ee.className="fc-field-chevron",ee.setAttribute("aria-hidden","true"),se.append(ee)}if(he){se.tabIndex=0,se.setAttribute("role","button"),se.setAttribute("aria-label",`编辑${B.label}`),se.onclick=be=>{be.target.closest("a,button,input,textarea,select")||Ve()},se.onkeydown=be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),Ve())};const ee=document.createElement("button");ee.type="button",ee.className="fc-detail-edit",ee.tabIndex=-1,ee.textContent="编辑",ee.ariaLabel=`编辑${B.label}`,ee.onclick=be=>{be.stopPropagation(),Ve()},se.append(ee)}else se.removeAttribute("role"),se.removeAttribute("tabindex"),se.onclick=null,se.onkeydown=null};ut();const Kn=()=>{var be;const ee=ue()&&!pe(ae.read())?n.required:(be=ae.validate)==null?void 0:be.call(ae);return ye.textContent=ee||"",N.classList.toggle("is-error",!!ee),ee},Vt=()=>{var be,xt,Qn;if(!he)return!0;const ee=Kn();if(ee&&$e(),!ee){const ht=ae.read(),Ya=Q?Q.get():l[B.key];JSON.stringify(Ya)!==JSON.stringify(ht)&&(Q?(Q.set(ht),(be=Q.notify)==null||be.call(Q,ht)):(l[B.key]=ht,(xt=a.onCommit)==null||xt.call(a,B.key,ht,l))),(Qn=a.onChange)==null||Qn.call(a,B.key,ht,l),ut()}return!ee},Yn=()=>{var ee;N.classList.remove("editing"),N.dataset.mode="default",N.style.minHeight="",le.style.minHeight="",le.style.maxHeight="",(ee=a.onFieldStateChange)==null||ee.call(a,B.key,"display")};N.addEventListener("input",()=>{var ee;$e(),(ee=a.onChange)==null||ee.call(a,B.key,ae.read(),l)}),N.addEventListener("pointerdown",()=>{N.classList.contains("editing")&&$e()},!0),N.addEventListener("mousedown",ee=>{var be;ge.id!=="richText"||!N.classList.contains("editing")||ee.target.closest("button,a,input,textarea,select,[contenteditable=true]")||(ee.preventDefault(),!N.contains(document.activeElement)&&!Ke(document.activeElement,N)&&((be=ae.focus)==null||be.call(ae)))}),N.addEventListener("change",()=>{$e(),Vt()}),N.addEventListener("fc-collapse",()=>{Vt(),Yn(),ut()}),N.addEventListener("focusout",()=>{queueMicrotask(()=>{if(!(S||!N.isConnected)){if(N.contains(document.activeElement)||Ke(document.activeElement,N)){Pe();return}Vt(),Yn(),ut()}})}),(B.defaultState||g)==="edit"&&he&&queueMicrotask(()=>{S||Ve()});const Xn={key:B.key,host:N,editor:ae,editable:he,check:Kn,commit:Vt,beginEdit:Ve,write:ee=>{Q?Q.set(ee):l[B.key]=ee},destroy:()=>{var ee;return(ee=ae.destroy)==null?void 0:ee.call(ae)}};return E.push(Xn),Xn}const pe=N=>Array.isArray(N)?N.length>0:N!=null&&String(N).trim()!=="";function J(){for(const N of E)N.editable&&N.write(N.editor.read());return{...l}}function ce(){let N;for(const B of E){if(!B.editable)continue;const Y=B.check();Y&&N===void 0&&(N=Y,B.beginEdit())}return N}function fe(N){C=N,T.hidden=!N,T.dataset.open=String(N)}function ne(N){g=N,T.dataset.fieldState=N;for(const B of E)N==="edit"?B.beginEdit():B.host.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))}function A(N){var Y;if(N===G||!F().some(Q=>Q.id===N))return;G=N;const B=K();x(),B&&((Y=a.onTabChange)==null||Y.call(a,N,B))}function O(N){v=N,x()}function V(N){N.data&&Object.assign(l,N.data),N.fields&&(d=N.fields.map(B=>({...B}))),N.tabs&&(c=N.tabs.map(B=>({...B}))),N.items&&(p=[...N.items]),N.blocks&&(f=[...N.blocks]),N.actions&&(u=[...N.actions]),N.context&&(r={...N.context}),x()}function _(){var N;if(!S){S=!0,(N=a.onDestroy)==null||N.call(a),W.destroy();for(const B of E)B.destroy();E=[],T.remove()}}return x(),fe(C),{element:T,onInteraction:W.onInteraction,read:J,validate:ce,setOpen:fe,setFieldState:ne,setTab:A,setSimpleMode:O,activeTab:()=>G,update:V,destroy:_}}function qa(s){const e=P("div",s.className??"tag");return s.marker?e.append(s.marker):s.markerClassName&&e.append(P("span",s.markerClassName)),e.append(P("span","",s.label)),e}function Ua(s){const e=P("div",s.className);if(s.leading)e.append(s.leading);else if(s.image){const i=P("img");i.src=s.image.src,i.alt=s.image.alt,e.append(i)}const t=s.inline?e:P("div",s.contentClassName);return t.append(P(s.titleTag??"span",s.titleClassName,s.title)),s.description!==void 0&&t.append(P(s.descriptionTag??"span",s.descriptionClassName,s.description)),s.inline||e.append(t),e}function ja(s,e){Nt[s]=e}function Ka(s,e){Ue[s]=e}j.ActionField=_n,j.AttachmentField=Bn,j.BaseField=Le,j.BaseFieldControl=Xe,j.CELL_EDITORS=Ue,j.CELL_RENDERERS=Nt,j.COMPLETION_LABEL=Yi,j.CascadeField=pi,j.ChoiceField=dt,j.CompositeField=Wn,j.ComputedField=ct,j.CustomField=vi,j.DEFAULT_LOCALE_TEXT=Li,j.DateField=gi,j.DateRangeField=Hn,j.DateTimeField=fi,j.EmailField=Nn,j.FORMULA_FUNCTIONS=Mt,j.GANTT_UNITS=_i,j.GanttChart=Ui,j.Grid=nt,j.LinkField=ci,j.LocationField=Vn,j.MultiCascadeField=$n,j.MultiChoiceField=An,j.MultiPersonField=Fn,j.MultiRelationField=Pn,j.MultiVoteField=zn,j.NumberField=kn,j.PersonField=ui,j.PhoneField=In,j.RadioField=Dn,j.RelationField=hi,j.RichTextField=Tn,j.STATUS_META=at,j.SignalField=mi,j.SingleVoteField=Gn,j.SwitchField=On,j.TextField=_e,j.TextareaField=Ln,j.UNIT_LABEL=At,j.VoteField=Bt,j.allGatesMet=Xi,j.computeStickyGroupRows=Bi,j.createControlRegistry=jn,j.createDetailDialog=Gi,j.createFieldRegistry=qn,j.createFlowCanvas=en,j.createFlowContextBar=sn,j.createGantt=Wo,j.createGrid=Vi,j.createMediaCell=Ua,j.createNodeCard=tn,j.createNodeFlow=ia,j.createNodeTimeline=on,j.createPersonnelSchedule=ra,j.createSparklineSvg=qt,j.createTagCell=qa,j.createWorkItemColumnPanels=fa,j.createWorkItemColumns=pa,j.createWorkItemDetailHeader=wa,j.createWorkItemFormSurface=Wa,j.createWorkItemHeaderDecorator=ga,j.createWorkItemLayers=Ca,j.createWorkItemRulePanels=ma,j.createWorkItemSelectionBar=ua,j.createWorkItemTable=ha,j.createWorkItemTabs=da,j.createWorkItemToolbar=ca,j.default=nt,j.emptyView=la,j.escapeHtml=H,j.evalFormCondition=Ne,j.evalFormScope=et,j.evaluateFormula=gt,j.evaluateGates=Zt,j.formatNumberCommas=He,j.groupNodes=Qi,j.isFormula=_t,j.matchNodes=Qt,j.matches=dn,j.parse=bi,j.registerEditor=Ka,j.registerFormulaFunction=ns,j.registerRenderer=ja,j.renderContent=oi,j.sanitizeRichText=yt,j.showTip=nn,j.summarize=Zi,j.tokenize=Ci,j.videoFlow=sa,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});