@guiexpert/table 1.1.115 → 1.1.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -44,7 +44,7 @@ export class ${t} implements CellRendererIf {
44
44
  `||o==="\r"){s++;continue}const i=s;if(Ee(o)||o==="."&&s+1<t&&Ee(n[s+1])){for(;s<t&&Ee(n[s]);)s++;if(n[s]===".")for(s++;s<t&&Ee(n[s]);)s++;if(n[s]==="e"||n[s]==="E"){let a=s+1;if((n[a]==="+"||n[a]==="-")&&a++,a<t&&Ee(n[a]))for(s=a;s<t&&Ee(n[s]);)s++}if(s<t&&(Ps(n[s])||n[s]==="."||n[s]==="$"))throw new X(`Invalid number "${n.slice(i,s+1)}"`,i);const l=n.slice(i,s);e.push({kind:"number",text:l,value:Number(l),pos:i});continue}if(o==='"'){s++;let l="",a=!1;for(;s<t;){if(n[s]==='"'){if(n[s+1]==='"'){l+='"',s+=2;continue}a=!0,s++;break}l+=n[s++]}if(!a)throw new X("Unterminated text",i);e.push({kind:"string",text:l,pos:i});continue}if(o==="["){const l=n.indexOf("]",s+1),a=l<0?"":n.slice(s+1,l);if(l<0||a.includes("["))throw new X("Unterminated field reference, missing ]",i);const c=a.trim();if(!c)throw new X("Empty field reference []",i);e.push({kind:"field",text:c,pos:i}),s=l+1;continue}if(o==="#"){const l=Dh.exec(n.slice(s));if(!l)throw new X('Unexpected character "#"',i);e.push({kind:"error",text:l[0].toUpperCase(),pos:i}),s+=l[0].length;continue}if(Ps(o)||o==="$"){for(;s<t&&(Al(n[s])||n[s]==="$");)s++;e.push({kind:"ident",text:n.slice(i,s),pos:i});continue}if(o==="("||o===")"||o===","){e.push({kind:o,text:o,pos:i}),s++;continue}if(o===";"){e.push({kind:",",text:";",pos:i}),s++;continue}const r=Ih.find(l=>n.startsWith(l,s));if(r){e.push({kind:"op",text:r,pos:i}),s+=r.length;continue}throw new X(`Unexpected character "${o}"`,i)}return e.push({kind:"eof",text:"",pos:t}),e}const hi=1e4,nn=64,ln=1e3,Oh={"=":{bp:10,op:"="},"==":{bp:10,op:"="},"<>":{bp:10,op:"<>"},"!=":{bp:10,op:"<>"},"<":{bp:10,op:"<"},"<=":{bp:10,op:"<="},">":{bp:10,op:">"},">=":{bp:10,op:">="},"&":{bp:20,op:"&"},"+":{bp:30,op:"+"},"-":{bp:30,op:"-"},"*":{bp:40,op:"*"},"/":{bp:40,op:"/"},"^":{bp:60,right:!0,op:"^"}},Nh=50,Vh=75,Ph=70,Bh=80;class _h{constructor(e,t=!1){this.tokens=e,this.references=t,this.index=0,this.depth=0,this.operators=0}parse(){if(this.peek().kind==="eof")throw new X("Empty formula",0);const e=this.expression(0),t=this.peek();if(t.kind!=="eof")throw new X(`Unexpected "${t.text}"`,t.pos);return e}peek(){return this.tokens[this.index]}next(){return this.tokens[this.index++]}enter(e){if(++this.depth>nn)throw new X(`Nested too deeply (more than ${nn} levels)`,e)}expression(e){let t=this.prefix();for(;;){const s=this.peek();if(s.kind!=="op")break;if(this.references&&s.text==="%"){if(Ph<=e)break;this.next(),t={kind:"unary",op:"%",operand:t};continue}if(this.references&&s.text===":"){if(Bh<=e)break;this.next(),t=this.range(t,s.pos);continue}const o=Oh[s.text];if(!o||o.bp<=e)break;if(this.next(),++this.operators>ln)throw new X(`Too many operators (more than ${ln})`,s.pos);this.enter(s.pos);const i=this.expression(o.right&&!this.references?o.bp-1:o.bp);this.depth--,t={kind:"binary",op:o.op,left:t,right:i}}return t}prefix(){const e=this.next();switch(e.kind){case"number":return this.references&&this.peekRangeOp()&&/^\d+$/.test(e.text)?this.rowRef(e.text,e.pos):{kind:"literal",value:e.value};case"string":return{kind:"literal",value:e.text};case"field":return{kind:"field",name:e.text};case"error":return{kind:"error",code:e.text};case"op":if(e.text==="-"||e.text==="+"){this.enter(e.pos);const t=this.expression(this.references?Vh:Nh);return this.depth--,{kind:"unary",op:e.text,operand:t}}throw new X(`Unexpected "${e.text}"`,e.pos);case"(":{this.enter(e.pos);const t=this.expression(0);return this.depth--,this.expect(")","Missing )"),t}case"ident":return this.identifier(e);case"eof":throw new X("Unexpected end of formula",e.pos);default:throw new X(`Unexpected "${e.text}"`,e.pos)}}identifier(e){const t=e.text.toUpperCase();if(this.references&&this.peek().kind!=="("){if(t==="TRUE")return{kind:"literal",value:!0};if(t==="FALSE")return{kind:"literal",value:!1};const o=ut(e.text);if(o)return{kind:"ref",row:o.row,col:o.col,absRow:o.absRow,absCol:o.absCol};if(this.peekRangeOp()){const i=/^(\$?)([A-Za-z]{1,3})$/.exec(e.text);if(i&&Qe(i[2])>=0)return{kind:"ref",row:-1,col:Qe(i[2]),absRow:!1,absCol:i[1]==="$"};const r=/^\$(\d+)$/.exec(e.text);if(r)return this.rowRef(r[1],e.pos,!0)}return{kind:"error",code:"#NAME?",message:`Unknown name "${e.text}"`,text:e.text}}if(this.references&&t.includes("$"))throw new X(`Unexpected "${e.text}"`,e.pos);if(this.peek().kind!=="("){if(t==="TRUE")return{kind:"literal",value:!0};if(t==="FALSE")return{kind:"literal",value:!1};throw new X(`Unknown name "${e.text}" – fields are written in brackets: [${e.text}]`,e.pos)}this.next(),this.enter(e.pos);const s=[];if(this.peek().kind!==")")for(;;){const o=this.peek().kind;if(s.push(this.references&&(o===","||o===")")?{kind:"literal",value:null}:this.expression(0)),this.peek().kind===","){this.next();continue}break}return this.expect(")",`Missing ) after the arguments of ${t}`),this.depth--,{kind:"call",name:t,args:s}}peekRangeOp(){const e=this.peek();return e.kind==="op"&&e.text===":"}rowRef(e,t,s=!1){const o=Number(e)-1;if(!(o>=0&&o<ye))throw new X(`Invalid row "${e}"`,t);return{kind:"ref",row:o,col:-1,absRow:s,absCol:!1}}rangeOperand(){const e=this.next();if(e.kind==="number"&&/^\d+$/.test(e.text))return this.rowRef(e.text,e.pos);if(e.kind==="ident"){const t=ut(e.text);if(t)return{kind:"ref",row:t.row,col:t.col,absRow:t.absRow,absCol:t.absCol};const s=/^(\$?)([A-Za-z]{1,3})$/.exec(e.text);if(s&&Qe(s[2])>=0)return{kind:"ref",row:-1,col:Qe(s[2]),absRow:!1,absCol:s[1]==="$"};const o=/^\$(\d+)$/.exec(e.text);if(o)return this.rowRef(o[1],e.pos,!0)}throw new X("A range needs two cells, columns or rows (A1:B5, A:A, 3:3)",e.pos)}range(e,t){const s=this.rangeOperand();if(e.kind!=="ref"||s.kind!=="ref")throw new X("A range needs two cells, columns or rows (A1:B5, A:A, 3:3)",t);const o=c=>c.row<0?"col":c.col<0?"row":"cell";if(o(e)!==o(s))throw new X("A range needs two cells, columns or rows (A1:B5, A:A, 3:3)",t);const[i,r]=e.row<=s.row?[e,s]:[s,e],[l,a]=e.col<=s.col?[e,s]:[s,e];return{kind:"range",from:{kind:"ref",row:i.row,col:l.col,absRow:i.absRow,absCol:l.absCol},to:{kind:"ref",row:r.row,col:a.col,absRow:r.absRow,absCol:a.absCol}}}expect(e,t){const s=this.peek();if(s.kind!==e)throw new X(t,s.pos);this.next()}}function qs(n,e=!1){if(n.length>hi)throw new X(`Formula too long (more than ${hi} characters)`,hi);return new _h(kh(n,e),e).parse()}const $h=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i;function Wt(n){return n===null||n===""}function wo(n,e,t=!1){if(n==null)return null;switch(typeof n){case"number":return Number.isNaN(n)?null:n;case"string":case"boolean":return n;case"bigint":return Number(n)}if(t&&v(n))return n;if(n instanceof Date){const s=n.getTime();return Number.isNaN(s)?null:s}return new L("#VALUE!",`[${e}] is not a number, text or boolean`)}function we(n){if(typeof n=="number")return n;if(n===null||n==="")return 0;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const e=n.trim();if($h.test(e)){const t=Number(e);if(Number.isFinite(t))return t}return new L("#VALUE!",`"${n.length>40?n.slice(0,40)+"…":n}" is not a number`)}return n}function Ze(n){return typeof n=="string"?n:n===null?"":typeof n=="number"?String(n):typeof n=="boolean"?n?"TRUE":"FALSE":n}function Di(n){if(typeof n=="boolean")return n;if(n===null||n==="")return!1;if(typeof n=="number")return n!==0;if(typeof n=="string"){const e=n.trim().toUpperCase();return e==="TRUE"?!0:e==="FALSE"?!1:new L("#VALUE!",`"${n.length>40?n.slice(0,40)+"…":n}" is not TRUE or FALSE`)}return n}function Me(n){return Number.isFinite(n)?n===0?0:n:new L("#NUM!","The result is not a finite number")}function Hh(n,e){if(v(n))return n;if(v(e))return e;if(Wt(n)&&Wt(e))return 0;const t=typeof n=="string"&&!Wt(n),s=typeof e=="string"&&!Wt(e);if(t||s){if(t&&s){const u=n.toLowerCase(),f=e.toLowerCase();return u<f?-1:u>f?1:0}const r=we(n),l=we(e);if(!v(r)&&!v(l))return r-l;const a=Ze(n),c=Ze(e),h=a.toLowerCase(),d=c.toLowerCase();return h<d?-1:h>d?1:0}const o=we(n),i=we(e);return o-i}const El={IF:{min:2,max:3},IFERROR:{min:2,max:2},AND:{min:1,max:255},OR:{min:1,max:255}},Wh={SUM:"sum",AVG:"avg",AVERAGE:"avg",MIN:"min",MAX:"max",COUNT:"count"};function oo(n){const e=[];for(const t of n){if(Wt(t))continue;const s=we(t);if(v(s))return s;e.push(s)}return e}function di(n){return{min:1,max:1,fn:e=>{const t=we(e[0]);return v(t)?t:Me(n(t))}}}function Sr(n,e){const t=Math.trunc(e),s=Math.pow(10,t);if(s===0)return 0;const o=Math.abs(n)*s;if(!Number.isFinite(o))return n;const i=Math.round(o>=1e15?o:Number(o.toPrecision(15)))/s;return n<0?-i:i}const Bs={ABS:di(Math.abs),FLOOR:di(Math.floor),CEILING:di(Math.ceil),SQRT:{min:1,max:1,fn:n=>{const e=we(n[0]);return v(e)?e:e<0?new L("#NUM!","SQRT of a negative number"):Math.sqrt(e)}},ROUND:{min:1,max:2,fn:n=>{const e=we(n[0]);if(v(e))return e;const t=n.length>1?we(n[1]):0;return v(t)?t:Me(Sr(e,t))}},MOD:{min:2,max:2,fn:n=>{const e=we(n[0]);if(v(e))return e;const t=we(n[1]);return v(t)?t:t===0?new L("#DIV/0!","MOD by zero"):Me(e-t*Math.floor(e/t))}},POWER:{min:2,max:2,fn:n=>{const e=we(n[0]);if(v(e))return e;const t=we(n[1]);return v(t)?t:Me(Math.pow(e,t))}},SUM:{min:1,max:255,fn:n=>{const e=oo(n);return v(e)?e:Me(e.reduce((t,s)=>t+s,0))}},AVG:{min:1,max:255,fn:n=>{const e=oo(n);return v(e)?e:e.length?Me(e.reduce((t,s)=>t+s,0)/e.length):new L("#DIV/0!","AVG of no numbers")}},MIN:{min:1,max:255,fn:n=>{const e=oo(n);return v(e)?e:e.length?Math.min(...e):0}},MAX:{min:1,max:255,fn:n=>{const e=oo(n);return v(e)?e:e.length?Math.max(...e):0}},COUNT:{min:1,max:255,fn:n=>n.filter(e=>typeof e=="number").length},NOT:{min:1,max:1,fn:n=>{const e=Di(n[0]);return v(e)?e:!e}},CONCAT:{min:1,max:255,fn:n=>{let e="";for(const t of n){const s=Ze(t);if(v(s))return s;e+=s}return e}},LEN:{min:1,max:1,fn:n=>{const e=Ze(n[0]);return v(e)?e:e.length}},UPPER:{min:1,max:1,fn:n=>{const e=Ze(n[0]);return v(e)?e:e.toUpperCase()}},LOWER:{min:1,max:1,fn:n=>{const e=Ze(n[0]);return v(e)?e:e.toLowerCase()}},TRIM:{min:1,max:1,fn:n=>{const e=Ze(n[0]);return v(e)?e:e.trim().replace(/\s+/g," ")}},ISBLANK:{min:1,max:1,fn:n=>Wt(n[0])}};Bs.AVERAGE=Bs.AVG;const Gh=new Set(["__proto__","constructor","prototype"]),Uh=(n,e)=>Object.prototype.hasOwnProperty.call(n,e);function Kh(n,e,t,s=e.split(".")){if(t!=null&&t.isCalculated(e))return wo(t.getValue(n,e),e,!0);if(s.some(i=>Gh.has(i)))return new L("#NAME?",`Unknown field [${e}]`);let o=n;for(let i=0;i<s.length;i++){if(o==null||typeof o!="object")return null;if(!Uh(o,s[i]))return i===0&&!(t!=null&&t.hasColumn(e))?new L("#NAME?",`Unknown field [${e}]`):null;o=o[s[i]]}return wo(o,e)}function an(n,e,t){if(v(e))return e;if(v(t))return t;if(n==="&"){const i=Ze(e);if(v(i))return i;const r=Ze(t);return v(r)?r:i+r}if(n==="="||n==="<>"||n==="<"||n==="<="||n===">"||n===">="){const i=Hh(e,t);if(v(i))return i;switch(n){case"=":return i===0;case"<>":return i!==0;case"<":return i<0;case"<=":return i<=0;case">":return i>0;default:return i>=0}}const s=typeof e=="number"?e:we(e);if(v(s))return s;const o=typeof t=="number"?t:we(t);if(v(o))return o;switch(n){case"+":return Me(s+o);case"-":return Me(s-o);case"*":return Me(s*o);case"/":return o===0?new L("#DIV/0!","Division by zero"):Me(s/o);default:return Me(Math.pow(s,o))}}function zh(n,e){return n==null?null:typeof n=="number"?Number.isNaN(n)?new L("#NUM!",`${e} returned NaN`):n:typeof n=="string"||typeof n=="boolean"||v(n)?n:n instanceof Date?wo(n,e):new L("#VALUE!",`${e} returned no number, text or boolean`)}function cn(n,e,t){const s=new Array(n.length);for(let o=0;o<n.length;o++){const i=n[o](e,t);if(v(i))return i;s[o]=i}return s}class jh{constructor(e){this.functions=e}compile(e){const t=this.node(e);return(s,o)=>{try{const i=t(s,o);return typeof i=="number"?Me(i):i}catch(i){return new L("#VALUE!",i instanceof Error?i.message.slice(0,200):"Evaluation failed")}}}evaluate(e,t,s){return this.compile(e)(t,s)}node(e){switch(e.kind){case"literal":{const t=e.value;return()=>t}case"field":{const t=e.name,s=t.split(".");return(o,i)=>Kh(o,t,i,s)}case"unary":{const t=this.node(e.operand),s=e.op==="-";return(o,i)=>{const r=t(o,i),l=typeof r=="number"?r:we(r);return v(l)?l:s?-l:l}}case"binary":{const t=this.node(e.left),s=this.node(e.right),o=e.op;return o==="*"||o==="+"||o==="-"?(i,r)=>{const l=t(i,r),a=s(i,r);return typeof l=="number"&&typeof a=="number"?Me(o==="*"?l*a:o==="+"?l+a:l-a):an(o,l,a)}:(i,r)=>an(o,t(i,r),s(i,r))}case"call":return this.call(e.name,e.args);default:{const t=new L("#ERROR!","Cell references are not allowed in column formulas");return()=>t}}}call(e,t){const s=this.functions.get(e);if(s){const a=t.map(c=>this.node(c));return(c,h)=>{const d=cn(a,c,h);if(v(d))return d;try{return zh(s(...d),e)}catch(u){return new L("#VALUE!",`${e}: ${u instanceof Error?u.message.slice(0,200):"failed"}`)}}}switch(e){case"IF":{const[a,c,h]=t.map(d=>this.node(d));return(d,u)=>{const f=Di(a(d,u));return v(f)?f:f?c(d,u):h?h(d,u):!1}}case"IFERROR":{const[a,c]=t.map(h=>this.node(h));return(h,d)=>{const u=a(h,d);return v(u)?c(h,d):u}}case"AND":case"OR":{const a=e==="AND",c=t.map(h=>this.node(h));return(h,d)=>{for(const u of c){const f=Di(u(h,d));if(v(f))return f;if(a&&!f)return!1;if(!a&&f)return!0}return a}}}const o=Wh[e],i=t[0];if(o&&t.length===1&&i.kind==="field"){const a=i.name;return(c,h)=>{if(!h)return new L("#VALUE!",`${e}([${a}]) needs the rows of a table`);if(!h.hasColumn(a))return new L("#NAME?",`Unknown column [${a}] in ${e}`);const d=h.aggregate(a,o);return d===void 0?o==="avg"?new L("#DIV/0!","AVG of no numbers"):0:wo(d,a,!0)}}const r=Bs[e];if(!r){const a=new L("#NAME?",`Unknown function ${e}`);return()=>a}const l=t.map(a=>this.node(a));return(a,c)=>{const h=cn(l,a,c);return v(h)?h:r.fn(h)}}}const Xh=Object.freeze([...Object.keys(Bs),...Object.keys(El)].sort());function Ss(n,e,t,s){switch(n.kind){case"literal":return;case"field":t.includes(n.name)||t.push(n.name);return;case"unary":return Ss(n.operand,e,t,s);case"binary":return Ss(n.left,e,t,s)??Ss(n.right,e,t,s);case"call":{if(!e.has(n.name)){const o=Bs[n.name]??El[n.name];if(!o)return new L("#NAME?",`Unknown function ${n.name}`);if(n.args.length<o.min||n.args.length>o.max){const i=o.min===o.max?`${o.min}`:o.max>=255?`at least ${o.min}`:`${o.min} to ${o.max}`;return new L("#ERROR!",`${n.name} needs ${i} argument${o.max===1?"":"s"}, got ${n.args.length}`)}["SUM","AVG","AVERAGE","MIN","MAX","COUNT"].includes(n.name)&&n.args.length===1&&n.args[0].kind==="field"&&(s.aggregates=!0)}for(const o of n.args){const i=Ss(o,e,t,s);if(i)return i}return}default:return new L("#ERROR!","Cell references are not allowed in column formulas")}}function xr(n,e){let t="";const s=new Map;for(const c of Object.keys((e==null?void 0:e.functions)??{})){const h=e.functions[c];typeof h=="function"&&s.set(c.toUpperCase(),h)}let o,i;const r=[],l={aggregates:!1};let a;try{t=typeof n=="string"?n:String(n??"");const c=t.replace(/^\s+/,"");o=qs(c.startsWith("=")&&!c.startsWith("==")?c.slice(1):t),i=Ss(o,s,r,l),i||(a=new jh(s).compile(o))}catch(c){i=c instanceof X?c.toFormulaError():new L("#ERROR!","Invalid formula")}return i&&(o=void 0,r.length=0),i&&(a=void 0),Object.freeze({source:t,ast:o,error:i,fields:Object.freeze([...r]),usesAggregates:l.aggregates,evaluate:(c,h)=>a?a(c,h):i})}function Rr(n,e){const t=typeof n=="string"?xr(n,e):n;return(s,o)=>t.evaluate(s,o)}const Yh={"=":10,"<>":10,"<":10,"<=":10,">":10,">=":10,"&":20,"+":30,"-":30,"*":40,"/":40,"^":60};function ui(n){return n.row<0?`${n.absCol?"$":""}${st(n.col)}`:n.col<0?`${n.absRow?"$":""}${n.row+1}`:n.row>=ye||n.col>=de?"#REF!":`${n.absCol?"$":""}${st(n.col)}${n.absRow?"$":""}${n.row+1}`}function qh(n){return String(n)}function _t(n,e){switch(n.kind){case"literal":return n.value===null?"":typeof n.value=="string"?`"${n.value.replace(/"/g,'""')}"`:typeof n.value=="boolean"?n.value?"TRUE":"FALSE":qh(n.value);case"field":return`[${n.name}]`;case"ref":return ui(n);case"range":return`${ui(n.from)}:${ui(n.to)}`;case"error":return n.text??n.code;case"call":return`${n.name}(${n.args.map(t=>_t(t,0)).join(",")})`;case"unary":{if(n.op==="%")return`${_t(n.operand,70)}%`;const t=_t(n.operand,75);return`${n.op}${t}`}case"binary":{const t=Yh[n.op],s=`${_t(n.left,t)}${n.op}${_t(n.right,t+1)}`;return t<e?`(${s})`:s}}}function Ms(n){return _t(n,0)}const Jh=new Set(["XLOOKUP","IFS","SWITCH","TEXTJOIN","CONCAT","IFNA","XOR"]);function Zh(n,e){let t;try{t=qs(n.slice(1),!0)}catch{return}let s=!0;const o=(l,a)=>({...l,row:l.row<0?e.dRow+(a?e.rows-1:0):l.row+e.dRow,col:l.col<0?e.dCol+(a?e.cols-1:0):l.col+e.dCol,absRow:l.row<0?!0:l.absRow,absCol:l.col<0?!0:l.absCol}),i=l=>{switch(l.kind){case"field":return s=!1,l;case"ref":return o(l,!1);case"range":return{kind:"range",from:o(l.from,!1),to:o(l.to,!0)};case"unary":return{...l,operand:i(l.operand)};case"binary":return{...l,left:i(l.left),right:i(l.right)};case"call":return{...l,name:Jh.has(l.name)?`_xlfn.${l.name}`:l.name,args:l.args.map(i)};default:return l}},r=i(t);return s?Ms(r):void 0}class ue extends Ys{constructor(e,t,s,o=[]){super(e,o,s),this.areaIdent=e,this.arr=t,this.defaultRowHeight=s,this.columnDefs=o,this.filteredArr=[...t]}externalFilterChanged(e){this.filteredArr=this.arr?this.arr.filter(e):[]}getRowCount(){return this.filteredArr?this.filteredArr.length:0}getUnfilteredRowCount(){var e;return((e=this.arr)==null?void 0:e.length)??0}canMoveRows(e,t){return Go(this.filteredArr.length,this.arr.length,e,t)}moveRows(e,t){return vr(this.filteredArr,this.arr,e,t)}getValueAt(e,t){const s=this.filteredArr[e],o=s[t];return this.sheetCells&&typeof o=="string"?this.sheetCells.valueAt(s,t,o):o}getInputValueAt(e,t){var s;return(s=this.filteredArr[e])==null?void 0:s[t]}setValue(e,t,s){var r;const o=(r=this.columnDefs[t])==null?void 0:r.editInputPipe;o&&(s=o(s,e,t));const i=this.filteredArr[e];return i?(i[t]=s,!0):!1}getRowByIndex(e){return this.filteredArr[e]}getRowHeight(e){return this.defaultRowHeight}getConstantRowHeight(){return this.getRowHeight===ue.prototype.getRowHeight&&this.defaultRowHeight>0?this.defaultRowHeight:void 0}changeColumnOrder(e,t){const s=new Set,o=i=>{i&&!s.has(i)&&(s.add(i),this.arrayMove(i,e,t))};(this.arr??[]).forEach(o),this.filteredArr.forEach(o),super.changeColumnOrder(e,t)}}class os{constructor(e){this.serial=e,this.type="SheetDate"}toDate(){return Ar(this.serial)}}function q(n){return!!n&&typeof n=="object"&&n.type==="SheetDate"&&typeof n.serial=="number"}const Ml=864e5,Tl=Date.UTC(1899,11,30);function fs(n){const e=n.getTime();if(Number.isNaN(e))return NaN;let s=(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds())-Tl)/Ml;return s<61&&(s-=1),s}function Ar(n){const e=n<60?n+1:n>=60&&n<61?61+(n-60):n,t=new Date(Tl+Math.round(e*Ml));return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}function Ts(n,e,t){return fs(new Date(n,e-1,t))}function Mt(n){if(Math.floor(n)===60)return{y:1900,m:2,d:29};const e=Ar(Math.floor(n));return{y:e.getFullYear(),m:e.getMonth()+1,d:e.getDate()}}class Tt{constructor(e,t,s,o,i){this.row=e,this.col=t,this.rows=s,this.cols=o,this.read=i,this.type="FormulaRange"}get(e,t){return e<0||t<0||e>=this.rows||t>=this.cols?null:this.read(this.row+e,this.col+t)}values(){const e=[];for(let t=0;t<this.rows;t++)for(let s=0;s<this.cols;s++)e.push(this.get(t,s));return e}}function bt(n){return!!n&&typeof n=="object"&&n.type==="FormulaRange"}function We(n){if(n===0||!Number.isFinite(n))return n===0?0:n;const e=Number(n.toPrecision(15));return e===0?0:e}function Z(n){return Number.isFinite(n)?We(n):new L("#NUM!","The result is not a finite number")}const hn=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i,Qh=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function is(n){const e=Qh.exec(n);if(!e)return;const t=new Date(+e[1],+e[2]-1,+e[3],+(e[4]??0),+(e[5]??0),+(e[6]??0));if(t.getMonth()===+e[2]-1)return fs(t)}function Il(n){if(n==null)return null;switch(typeof n){case"number":return Number.isNaN(n)?null:n;case"string":return n;case"boolean":return n;case"bigint":return Number(n)}if(v(n)||q(n))return n;if(n instanceof Date){const e=fs(n);return Number.isNaN(e)?null:new os(e)}return new L("#VALUE!","The cell holds no number, text or boolean")}function j(n){return bt(n)?n.rows===1&&n.cols===1?j(n.get(0,0)):new L("#VALUE!","A range where one value is expected"):n}function ie(n,e){const t=j(n);if(typeof t=="number")return t;if(t===null||t==="")return 0;if(typeof t=="boolean")return t?1:0;if(q(t))return t.serial;if(typeof t=="string"){const s=t.trim();if(hn.test(s)){const o=Number(s);if(Number.isFinite(o))return o}if(s.endsWith("%")&&hn.test(s.slice(0,-1).trim()))return Number(s.slice(0,-1).trim())/100;if(e.isoDatesAsDates){const o=is(s);if(o!==void 0)return o}return new L("#VALUE!",`"${t.length>40?t.slice(0,40)+"…":t}" is not a number`)}return t}function dn(n){const e=We(n),t=Math.abs(e);return t!==0&&(t>=1e15||t<1e-9)?e.toExponential().replace("e","E"):String(e)}function ve(n){const e=j(n);return typeof e=="string"?e:e===null?"":typeof e=="number"?dn(e):typeof e=="boolean"?e?"TRUE":"FALSE":q(e)?dn(e.serial):e}function Gt(n){const e=j(n);if(typeof e=="boolean")return e;if(e===null||e==="")return!1;if(typeof e=="number")return e!==0;if(q(e))return e.serial!==0;if(typeof e=="string"){const t=e.trim().toUpperCase();return t==="TRUE"?!0:t==="FALSE"?!1:new L("#VALUE!",`"${e.length>40?e.slice(0,40)+"…":e}" is not TRUE or FALSE`)}return e}function un(n){return typeof n=="string"?1:typeof n=="boolean"?2:0}function Js(n,e){let t=j(n),s=j(e);if(v(t))return t;if(v(s))return s;if(q(t)&&(t=t.serial),q(s)&&(s=s.serial),t===null&&s===null)return 0;t===null&&(t=typeof s=="string"?"":typeof s=="boolean"?!1:0),s===null&&(s=typeof t=="string"?"":typeof t=="boolean"?!1:0);const o=un(t),i=un(s);if(o!==i)return o-i;if(typeof t=="number"&&typeof s=="number"){const r=We(t)-We(s);return r===0?0:r<0?-1:1}if(typeof t=="string"&&typeof s=="string"){const r=t.toLowerCase(),l=s.toLowerCase();return r<l?-1:r>l?1:0}return(t?1:0)-(s?1:0)}function Fi(n){return n===null||n===""}function fn(n){return q(n)?n.toDate():bt(n)?j(n):n}class ot extends Ys{constructor(e,t,s,o,i,r=[],l=0){super(e,r,i),this.rowCount=s,this.columnCount=o,this.columnOffset=l,this.version=0,this.rows=new Map,this.physicalOfArray=new Map,this.setSheetData(t,s,o)}setSheetData(e,t=this.rowCount,s=this.columnCount){this.rows.clear(),this.physicalOfArray.clear(),e.forEach((o,i)=>{if(o&&o.some(r=>r!=null&&r!=="")){const r=[...o];this.rows.set(i,r),this.physicalOfArray.set(r,i)}}),this.rowCount=Math.max(t,e.length),this.columnCount=Math.max(s,e.reduce((o,i)=>Math.max(o,(i==null?void 0:i.length)??0),0)),this.perm=void 0,this.inverse=void 0,this.version++}getSheetData(){let e=-1,t=-1;this.rows.forEach((o,i)=>{for(let r=o.length-1;r>=0;r--)if(!bs(o[r])){e=Math.max(e,i),t=Math.max(t,r);break}});const s=[];for(let o=0;o<=e;o++){const i=this.rows.get(o);s.push(Array.from({length:t+1},(r,l)=>i&&!bs(i[l])?i[l]:""))}return s}getCell(e,t){var s;return(s=this.rows.get(e))==null?void 0:s[t]}setCell(e,t,s){let o=this.rows.get(e);if(!o){if(bs(s))return;o=[],this.rows.set(e,o),this.physicalOfArray.set(o,e)}o[t]=s}getRowArray(e){return this.rows.get(e)}forEachCell(e){this.rows.forEach((t,s)=>t.forEach((o,i)=>e(s,i,o)))}getPhysicalRowOfArray(e){return this.physicalOfArray.get(e)}getSheetColumnCount(){return this.columnCount}setColumnDefs(e){this.columnDefs=e,this.cellRenderers=e.map(t=>{var s;return(s=t.rendererMap)==null?void 0:s[this.areaIdent]})}getRowCount(){return this.perm?this.perm.length:this.rowCount}getUnfilteredRowCount(){return this.rowCount}getPhysicalRowIndex(e){return this.perm?this.perm[e]:e}getDisplayRowIndex(e){return this.perm?(this.inverse||(this.inverse=new Map,this.perm.forEach((t,s)=>this.inverse.set(t,s))),this.inverse.get(e)??-1):e<this.rowCount?e:-1}getValueAt(e,t){const s=this.rows.get(this.getPhysicalRowIndex(e)),o=s==null?void 0:s[t-this.columnOffset];return o==null?"":this.sheetCells&&typeof o=="string"?this.sheetCells.valueAt(s,t,o):o}getInputValueAt(e,t){var s;return((s=this.rows.get(this.getPhysicalRowIndex(e)))==null?void 0:s[t-this.columnOffset])??""}getTextValueAt(e,t){const s=this.getValueAt(e,t);return v(s)?s.code:String(s)}setValue(e,t,s){var i;const o=(i=this.columnDefs[t])==null?void 0:i.editInputPipe;return o&&(s=o(s,e,t)),t<this.columnOffset||e<0||e>=this.getRowCount()?!1:(this.setCell(this.getPhysicalRowIndex(e),t-this.columnOffset,s),!0)}getRowByIndex(e){return this.rows.get(this.getPhysicalRowIndex(e))}getRowHeight(e){return this.defaultRowHeight}getConstantRowHeight(){return this.defaultRowHeight>0?this.defaultRowHeight:void 0}getMaxColspan(){return 1}getMaxRowspan(){return 1}externalFilterChanged(e){const t=[];for(let s=0;s<this.rowCount;s++)e(this.rows.get(s)??[],s,[])&&t.push(s);this.perm=t.length===this.rowCount?void 0:Int32Array.from(t),this.inverse=void 0}doSort(e){const t=e.filter(o=>o.sortState==="asc"||o.sortState==="desc"),s=this.perm?Array.from(this.perm):Array.from({length:this.rowCount},(o,i)=>i);return s.sort((o,i)=>{for(const{columnIndex:r,sortState:l}of t){const a=this.valueOfPhysical(o,r),c=this.valueOfPhysical(i,r),h=a===""||v(a),d=c===""||v(c);if(h||d){if(h!==d)return h?1:-1;continue}const u=Js(a,c),f=typeof u=="number"?u:0;if(f)return l==="asc"?f:-f}return o-i}),!t.length&&s.length===this.rowCount?(this.perm=void 0,this.inverse=void 0,!0):(this.perm=Int32Array.from(s),this.inverse=void 0,!0)}insertRows(e,t){this.shiftRows(e,t),this.rowCount+=t}deleteRows(e,t){const s=[];for(let o=e;o<e+t;o++){const i=this.rows.get(o);i&&(s.push([o-e,i]),this.physicalOfArray.delete(i),this.rows.delete(o))}return this.shiftRows(e+t,-t),this.rowCount=Math.max(0,this.rowCount-t),s}restoreRows(e,t,s){this.insertRows(e,t);for(const[o,i]of s)this.rows.set(e+o,i),this.physicalOfArray.set(i,e+o)}insertColumns(e,t){this.rows.forEach(s=>{s.length>e&&s.splice(e,0,...new Array(t))}),this.columnCount+=t,this.changed()}deleteColumns(e,t){const s=[];return this.rows.forEach(o=>{const i=o.splice(e,t);i.some(r=>!bs(r))&&s.push([o,i])}),this.columnCount=Math.max(0,this.columnCount-t),this.changed(),s}restoreColumns(e,t,s){this.insertColumns(e,t);for(const[o,i]of s)i.forEach((r,l)=>{o[e+l]=r})}getContentExtent(){let e=-1,t=-1;return this.rows.forEach((s,o)=>{let i=-1;for(let l=s.length-1;l>=0;l--)if(!bs(s[l])){i=l;break}if(i<0)return;const r=this.getDisplayRowIndex(o);r<0||(e=Math.max(e,r),t=Math.max(t,i+this.columnOffset))}),[e,t]}valueOfPhysical(e,t){const s=this.rows.get(e),o=s==null?void 0:s[t-this.columnOffset];return o==null?"":this.sheetCells&&typeof o=="string"?this.sheetCells.valueAt(s,t,o):o}shiftRows(e,t){const s=Array.from(this.rows).filter(([o])=>o>=e).sort((o,i)=>t>0?i[0]-o[0]:o[0]-i[0]);for(const[o]of s)this.rows.delete(o);for(const[o,i]of s)this.rows.set(o+t,i),this.physicalOfArray.set(i,o+t);this.changed()}changed(){this.perm=void 0,this.inverse=void 0,this.version++}}function bs(n){return n==null||n===""}class yo{constructor(e=0,t=0,s=0,o=0){this.top=e,this.right=t,this.bottom=s,this.left=o}}class et{constructor(e=34,t=34,s=34){this.header=e,this.body=t,this.footer=s}}class Dl{constructor(){this.checkedRows=[]}getCheckedRows(){return this.checkedRows}setCheckedRows(e){this.checkedRows=e}addCheckedRows(e){this.checkedRows||(this.checkedRows=[]);for(const t of e)this.checkedRows.includes(t)||this.checkedRows.push(t)}checkRow(e,t){this.checkedRows||(this.checkedRows=[]),t?this.checkedRows.includes(e)||this.checkedRows.push(e):this.removeSelectedRow(e)}isRowChecked(e){return this.checkedRows&&this.checkedRows.includes(e)?"full":"none"}checkAll(e){this.checkedRows=[]}removeSelectedRow(e){if(this.checkedRows){const t=this.checkedRows.indexOf(e);t>-1&&this.checkedRows.splice(t,1)}}}class rs{constructor(e=[]){this.allRootNodes=e}checkRow(e,t){this.setCheckedRecursive(e,t),this.autoCheckParent(e.parent)}checkAll(e=this.allRootNodes){for(const s of e)this.uncheckRecursive(s);const t=new Set;for(const s of e)s.parent&&t.add(s.parent);t.forEach(s=>this.autoCheckParent(s))}getCheckedRows(){const e=[];return this.addSelectedRecursive(this.allRootNodes,e),e}isRowChecked(e){return e.checked?"full":this.hasMixedDescendants(e)?"semi":"none"}hasMixedDescendants(e){let t=!1,s=!1;const o=i=>{for(const r of i??[])if(r.checked?t=!0:s=!0,t&&s||o(r.children))return!0;return!1};return o(e.children)}setCheckedRecursive(e,t){if(e.checked=t,e.children)for(const s of e.children)this.setCheckedRecursive(s,t)}setCheckedRows(e){this.addCheckedRows(e)}addCheckedRows(e){for(const t of e)t.checked=!0}autoCheckParent(e){if(e){const t=this.areAllChildrenChecked(e),s=this.areAllChildrenUnchecked(e);t?e.checked=!0:e.checked=!1,this.autoCheckParent(e.parent)}}areAllChildrenChecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(!o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenChecked(o))return!1}return!0}areAllChildrenUnchecked(e){var t,s;if((t=e.children)!=null&&t.length){for(const o of e.children)if(o.checked||(s=o.children)!=null&&s.length&&!this.areAllChildrenUnchecked(o))return!1}return!0}uncheckRecursive(e){if(e.checked=!1,e.children)for(const t of e.children)this.uncheckRecursive(t)}addSelectedRecursive(e,t){for(const s of e)s.checked&&t.push(s),s.children&&this.addSelectedRecursive(s.children,t)}}class ed{constructor(e){this.bodyAreaModel=e}getCheckedRows(){var e;return((e=this.bodyAreaModel.rowSelectionModel)==null?void 0:e.getCheckedRows())??[]}setCheckedRows(e){var t;(t=this.bodyAreaModel.rowSelectionModel)==null||t.setCheckedRows(e)}addCheckedRows(e){var t;(t=this.bodyAreaModel.rowSelectionModel)==null||t.addCheckedRows(e)}checkRow(e,t){const s=this.bodyAreaModel.rowSelectionModel;if(s instanceof rs){this.getTopTreeRows().forEach(o=>s.checkRow(o,t));return}this.checkAll(t?this.getBodyRows():[])}isRowChecked(e){const t=this.bodyAreaModel.rowSelectionModel;if(t instanceof rs){const a=this.getTopTreeRows().map(c=>t.isRowChecked(c));return!a.length||a.every(c=>c==="none")?"none":a.every(c=>c==="full")?"full":"semi"}const s=this.getCheckedRows(),o=this.bodyAreaModel.getRowCount();if(!s.length||!o)return"none";if(s.length<o)return"semi";const i=this.cache;if(i&&i.checkedRows===s&&i.checkedCount===s.length&&i.rowCount===o)return i.state;const r=new Set(s);let l="full";for(let a=0;a<o;a++)if(!r.has(this.bodyAreaModel.getRowByIndex(a))){l="semi";break}return this.cache={checkedRows:s,checkedCount:s.length,rowCount:o,state:l},l}checkAll(e){const t=this.bodyAreaModel.rowSelectionModel;if(!t)return;if(!e.length){t.setCheckedRows([]);return}const s=new Set(t.getCheckedRows());e.forEach(o=>s.add(o)),t.setCheckedRows(Array.from(s))}getTopTreeRows(){const e=this.bodyAreaModel;return typeof e.getDisplayedRootRows=="function"?e.getDisplayedRootRows():this.getBodyRows().filter(t=>!t.parent)}getBodyRows(){const e=this.bodyAreaModel.getRowCount(),t=new Array(e);for(let s=0;s<e;s++)t[s]=this.bodyAreaModel.getRowByIndex(s);return t}}function _s(n){return n!=null&&n.length&&G(n[0])?1:0}class D{constructor(e=100,t="px"){this.value=e,this.unit=t}}const ps=()=>!0,Fl=()=>!1,ns=new WeakSet,Co=new WeakMap;function kl(n,e){e?ns.delete(n):ns.add(n),Ll(n)}function fi(n,e){e?Co.set(n,e):Co.delete(n),Ll(n)}function at(n){var e;return Co.has(n)?!ns.has(n):!ns.has(n)&&((e=n.isVisible)==null?void 0:e.call(n))!==!1}function Ll(n){const e=Co.get(n),t=!ns.has(n);e?n.isVisible=()=>!ns.has(n)&&e():n.isVisible=t?ps:Fl}const Fo=class Fo{constructor(e,t,s,o=0,i=0,r=!1,l=new et,a=[],c=[],h=-1,d=0,u=400,f=()=>{}){var g,m,b,w;this.headerAreaModel=e,this.bodyAreaModel=t,this.footerAreaModel=s,this.fixedLeftColumnCount=o,this.fixedRightColumnCount=i,this.rowCheckboxVisible=r,this.defaultRowHeights=l,this.columnDefs=a,this.columnSizes=c,this.overridingColumnWidth=h,this.columnCount=d,this.parentSize=u,this.getSelectionModel=f,this.rowCount=0,this.contentHeightInPx=0,this.contentWidthInPx=0,this.padding=new yo(0,0,0,0),this.xPositions=[],this.headerVisible=!0,this.footerVisible=!0,e.areaIdent="header",t.areaIdent="body",s.areaIdent="footer",this.columnCount||((g=this.columnDefs)!=null&&g.length?this.columnCount=this.columnDefs.length:(m=this.columnSizes)!=null&&m.length&&(this.columnCount=(b=this.columnSizes)==null?void 0:b.length));const p=(w=this.columnDefs)==null?void 0:w[_s(this.columnDefs)];Ae(p)&&!t.rowSelectionModel&&(t.rowSelectionModel=new Dl),Ae(p)&&!e.rowSelectionModel&&(e.rowSelectionModel=new ed(t))}init(){this.recalcSize(this.parentSize),this.overridingColumnWidth===-1&&this.calcXPositions(),this.headerAreaModel&&this.headerAreaModel.init(),this.bodyAreaModel&&this.bodyAreaModel.init(),this.footerAreaModel&&this.footerAreaModel.init()}setParentWidth(e){this.parentSize=e}getColumnCount(){return this.columnCount}setColumnWidth(e,t){var s,o;if(t=Math.max(0,t),this.overridingColumnWidth!==-1&&(this.overridingColumnWidth=t),e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)){this.columnSizes[e]=t;const i=(o=this.columnDefs)==null?void 0:o[e];i&&(i.width=new D(t,"px"))}this.overridingColumnWidth===-1&&this.calcXPositions(),this.recalcContentWidthInPx()}getColumnWidth(e){var s;const t=this.getColumnDef(e);return t&&t.isVisible&&!t.isVisible()?0:this.overridingColumnWidth!==-1?this.overridingColumnWidth:e>-1&&e<((s=this.columnSizes)==null?void 0:s.length)?this.columnSizes[e]:0}getXPosByColumnIndex(e){return e===0?0:this.overridingColumnWidth>-1?this.overridingColumnWidth*e:this.xPositions[e]}recalcSize(e){e>0&&(this.parentSize=e),this.recalcColumnWidths(e),this.recalcHeightAndPadding()}recalcHeightAndPadding(){const e=this.getAreaModel("body");this.rowCount=e.getRowCount(),this.contentHeightInPx=this.getAreaHeight("body"),this.recalcContentWidthInPx(),this.recalcPadding()}recalcPadding(){var r,l;const e=this.getSideAreaWidth("west"),t=this.getSideAreaWidth("east"),s=this.headerVisible?((l=(r=this.tableScope)==null?void 0:r.getHeaderExtraHeight)==null?void 0:l.call(r))??0:0,o=this.headerVisible?this.getAreaHeight("header")+s:0,i=this.footerVisible?this.getAreaHeight("footer"):0;this.padding=new yo(o,t,i,e)}getPadding(){return this.padding}getContentHeightInPixel(){return this.contentHeightInPx}getContentWidthInPixel(){return this.contentWidthInPx}getRowHeight(e,t){return this.getAreaModel(e).getRowHeight(t)}getModel(e){return this.getAreaModel(e)}getAreaHeight(e){var r;const t=this.getModel(e),s=t.getRowCount();if(!(s>0))return 0;const o=(r=t.getConstantRowHeight)==null?void 0:r.call(t);if(o!==void 0&&o>0)return s*o;let i=0;for(let l=0;l<s;l++)i=i+t.getRowHeight(l);return i>0?i:s*(this.defaultRowHeights[e]||0)}getSideAreaWidth(e){const[t,s]=this.getSideStartAndEndColumnIndex(e);let o=0;for(let i=t;i<=s;i++)o=o+this.getColumnWidth(i);return o}getSideStartAndEndColumnIndex(e){const t=this.getFixedLeftColumnCount(),s=this.getFixedRightColumnCount();let o=0,i=this.columnCount-1;return e==="west"?i=t-1:e==="east"?o=this.columnCount-s:(o=t,i=this.columnCount-s-1),[o,i]}getColumnDef(e){if(e<this.columnDefs.length)return this.columnDefs[e]}getFixedLeftColumnCount(){return this.fixedLeftColumnCount}getFixedRightColumnCount(){return this.fixedRightColumnCount}getAreaModel(e){if(e==="header")return this.headerAreaModel;if(e==="body")return this.bodyAreaModel;if(e==="footer")return this.footerAreaModel;throw new Error("Wrong ident.")}getBodyModel(){return this.bodyAreaModel}isFooterVisibe(){var e;return this.footerVisible&&(((e=this.footerAreaModel)==null?void 0:e.getRowCount())??0)>0}isHeaderVisibe(){var e;return this.headerVisible&&(((e=this.headerAreaModel)==null?void 0:e.getRowCount())??0)>0}setHeaderVisible(e){this.headerVisible=e,this.recalcPadding()}setFooterVisible(e){this.footerVisible=e,this.recalcPadding()}setColumnVisible(e,t){var i;const s=this.findColumnDef(e);if(!s)return!1;kl(s,t);const o=s;return typeof o.visible=="boolean"&&(o.visible=t),(i=this.columnDefs)!=null&&i.some(r=>{var l;return((l=r.width)==null?void 0:l.unit)==="weight"})&&this.recalcColumnWidths(this.parentSize),this.recalcContentWidthInPx(),this.recalcPadding(),this.calcXPositions(),!0}isColumnVisible(e){var s;const t=this.findColumnDef(e);return t?((s=t.isVisible)==null?void 0:s.call(t))!==!1:typeof e=="number"&&e>=0&&e<this.getColumnCount()}isRowCheckboxVisible(){return this.rowCheckboxVisible}externalFilterChanged(e){this.getAreaModel("body").externalFilterChanged(e)}doSort(e){return this.getAreaModel("body").doSort(e)}sort(e){return this.getAreaModel("body").sort(e)}getColumnDefs(){return this.columnDefs}getColumnProperty(e){var t,s;return((s=(t=this.columnDefs)==null?void 0:t[e])==null?void 0:s.property)??""}getBodyRowByIndex(e){return this.getBodyModel().getRowByIndex(e)}isSortable(e){var t;if(this.columnDefs&&e<this.columnDefs.length){const s=(t=this.columnDefs[e])==null?void 0:t.sortable;if(typeof s=="function")return s()}return!1}changeColumnOrder(e,t){var s,o,i;this.arrayMove(this.columnDefs,e,t),this.arrayMove(this.columnSizes,e,t),(s=this.headerAreaModel)==null||s.changeColumnOrder(e,t),(o=this.bodyAreaModel)==null||o.changeColumnOrder(e,t),(i=this.footerAreaModel)==null||i.changeColumnOrder(e,t),this.calcXPositions()}recalcColumnWidths(e){var t,s,o;if(!((t=this.columnDefs)!=null&&t.length)&&!((s=this.columnSizes)!=null&&s.length)&&(this.columnSizes=new Array(this.getColumnCount()).fill(this.overridingColumnWidth>-1?this.overridingColumnWidth:Fo.DEFAULT_COLUMN_WIDTH)),(o=this.columnDefs)!=null&&o.length){const i=this.columnDefs.filter(h=>{var d;return((d=h.width)==null?void 0:d.unit)==="weight"});this.columnSizes=this.columnDefs.map(h=>{if(h.width.unit==="%"&&e){let d=Math.floor(h.width.value*e/100);if(h.minWidth){const u=this.sizeToPixel(h.minWidth,e);d=Math.max(u,d)}if(h.maxWidth){const u=this.sizeToPixel(h.maxWidth,e);d=Math.min(u,d)}return d}else if(h.width.unit==="px"&&e)return h.width.value;return 0});const r=h=>{var d;return((d=h.isVisible)==null?void 0:d.call(h))!==!1},l=this.columnSizes.reduce((h,d,u)=>r(this.columnDefs[u])?h+d:h,0),a=e-l,c=i.filter(r);if(a>0&&c.length){const h=c.map(d=>d.width.value).reduce((d,u)=>d+u);for(let d=0;d<this.columnDefs.length;d++){const u=this.columnDefs[d];u.width.unit==="weight"&&r(u)&&(this.columnSizes[d]=u.width.value*a/h)}}}}sizeToPixel(e,t){return e.unit==="px"?e.value:e.unit==="%"?Math.floor(e.value*t/100):-1}findColumnDef(e){const t=this.columnDefs??[];if(typeof e=="number")return e>=0?t[e]:void 0;if(typeof e=="string"){for(const s of t)if(s.property===e)return s;return}return t.indexOf(e)>-1?e:void 0}arrayMove(e,t,s){if(t<0||t>=e.length)return e;const o=e.splice(t,1)[0];return e.splice(s,0,o),e}recalcContentWidthInPx(){this.contentWidthInPx=this.getSideAreaWidth("center")}calcXPositions(){const e=this.getColumnCount();this.xPositions=new Array(e+1),this.xPositions[0]=0;for(let t=0;t<e;t++)this.xPositions[t+1]=this.getColumnWidth(t)+this.xPositions[t]}setTableScope(e){this.tableScope=e}getTableScope(){return this.tableScope}};Fo.DEFAULT_COLUMN_WIDTH=100;let ft=Fo;class fe{constructor(e,t,s){this.header=e,this.body=t,this.footer=s}}class Oe{constructor(e,t,s=new D(100,"px"),o=new fe,i=new fe,r,l,a,c,h,d,u,f,p,g,m=()=>this.visible){this.property=e,this.headerLabel=t,this.width=s,this.classes=o,this.rendererMap=i,this.sortable=a,this.sortComparator=c,this.sortState=h,this.sortStatesOrder=d,this.sortIconVisible=u,this.editable=f,this.getEditRenderer=p,this.editInputPipe=g,this.isVisible=m,this.visible=!0,this.minWidth=r??new D(0,"px"),this.maxWidth=l??new D(1e5,"px")}static bodyRenderer(e){return new fe(void 0,e,void 0)}static create(e){const t=new fe(e.headerRenderer,e.bodyRenderer,e.footerRenderer),s=new fe(e.headerClasses,e.bodyClasses,e.footerClasses),o=e.sortIconVisible??e.sortable,i=e.editable??ml,r=e.isVisible??e.isVisible??ps,l=new Oe(e.property??"",e.headerLabel??"",e.width??new D(100,"px"),s,t,e.minWidth,e.maxWidth,e.sortable,e.sortComparator,e.sortState,e.sortStatesOrder,o,i,e.getEditRenderer,e.editInputPipe,r);return e.formula!==void 0&&e.formula!==null?(l.formula=e.formula,l.valueGetter=Rr(e.formula,e.formulaOptions)):e.valueGetter&&(l.valueGetter=e.valueGetter),e.valueSetter&&(l.valueSetter=e.valueSetter),e.showValuesAs&&(l.showValuesAs=e.showValuesAs),e.rowDrag!==void 0&&(l.rowDrag=e.rowDrag),e.validate&&(l.validate=e.validate),e.editor&&(l.editor=e.editor),e.emptyValue!==void 0&&(l.emptyValue=e.emptyValue),e.cellFormulas!==void 0&&(l.cellFormulas=e.cellFormulas),e.resizable!==void 0&&(l.resizable=e.resizable),e.movable!==void 0&&(l.movable=e.movable),e.filter!==void 0&&(l.filter=e.filter),e.hideable!==void 0&&(l.hideable=e.hideable),l}}class xe{constructor(e="body"){this.areaIdent=e,this.rowSelectionModel=void 0}sort(e){}getRowCount(){return 0}getValueAt(e,t){return""}getTextValueAt(e,t){return""}getCellRenderer(e,t){}getRowHeight(e){return 0}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!1}isRowChecked(e){}setRowChecked(e,t){}getTooltipAt(e,t){return""}getMaxColspan(){return 0}getMaxRowspan(){return 0}getYPosByRowIndex(e){return 0}init(){}externalFilterChanged(e){}isFilterable(){return!1}doSort(e){return!1}isEditable(e,t){return!1}setValue(e,t,s){return!1}isSelectable(e,t){return!1}changeColumnOrder(e,t){}}class Ol{constructor(e){this.columnDef=e,this.type="RowNumberCellRenderer"}render(e,t,s,o,i,r,l){const a=this.columnDef.getRowNumberText(t,i),c=l.createElement("div");l.addClass(c,"ge-table-label-div");const h=l.createElement("div");l.addClass(h,"ge-table-label"),l.setAttribute(h,"data-row-index",`${t}`),l.setAttribute(h,"data-col-index",`${s}`),l.setAttribute(h,"data-area",o),l.appendChild(h,l.createText(a)),l.appendChild(c,h),l.appendChild(e,c)}}class ki{constructor(){this.mode="display",this.format=td,this.headerLabel="#",this.exported=!1,this.minWidthInPx=36}}function td(n){return String(n)}class Zs{constructor(e={}){this.type="RowNumberColumnDef",this.property="RowNumberColumn",this.maxWidth=new D(400,"px"),this.classes=new fe(["ge-table-row-number-header","ge-table-text-align-right"],["ge-table-row-number","ge-table-text-align-right"],["ge-table-row-number-footer"]),this.isVisible=ps,this.resizable=!1,this.movable=!1,this.filter=!1,this.options={...new ki,...e},this.headerLabel=this.options.headerLabel,this.width=new D(this.options.minWidthInPx,"px"),this.minWidth=new D(this.options.minWidthInPx,"px"),this.rendererMap=new fe(void 0,new Ol(this),void 0)}getRowNumber(e,t){var s;if(this.options.mode==="original"){const o=(s=t.getPhysicalRowIndex)==null?void 0:s.call(t,e);if(o!==void 0)return o+1;const i=this.getOriginalPosition(t.getRowByIndex(e),t);if(i!==void 0)return i+1}return e+1}getRowNumberText(e,t){return this.options.format(this.getRowNumber(e,t))}getWidestText(e){var s,o;let t=e.getRowCount();return this.options.mode==="original"&&this.hasAllRows(e)?t=((s=e.getUnfilteredRowCount)==null?void 0:s.call(e))??e.getAllRows().length:this.options.mode==="original"&&"getPhysicalRowIndex"in e&&(t=((o=e.getUnfilteredRowCount)==null?void 0:o.call(e))??t),this.options.format(Math.max(1,t))}hasDefaultFormat(){return this.options.format===new ki().format}hasAllRows(e){return typeof e.getAllRows=="function"}getOriginalPosition(e,t){if(!this.hasAllRows(t))return;const s=t.getAllRows();if(!Array.isArray(s))return;let o=this.originalIndex;(!o||o.rows!==s||o.length!==s.length)&&(o=this.buildOriginalIndex(s));const i=o.index.get(e);if(i!==void 0&&s[i]===e)return i;if(i!==void 0||!o.missRebuilt){o=this.buildOriginalIndex(s),o.missRebuilt=!0;const r=o.index.get(e);return r!==void 0&&s[r]===e?r:void 0}}buildOriginalIndex(e){const t=new Map;for(let s=0;s<e.length;s++)t.has(e[s])||t.set(e[s],s);return this.originalIndex={rows:e,length:e.length,index:t,missRebuilt:!1},this.originalIndex}}class Nl{render(e,t,s,o,i,r,l){if(i.isEditable(t,s)){l.addClass(e,"ge-table-row-input-div");const a=r!==void 0?r:i.getValueAt(t,s),c=l.createElement("input");l.setAttribute(c,"type","text"),l.setAttribute(c,"autofocus",""),l.setAttribute(c,"data-listen","change"),l.setAttribute(c,"data-area",o),l.setAttribute(c,"data-row-index",String(t)),l.setAttribute(c,"data-col-index",String(s)),l.setAttribute(c,"data-input-type","text"),l.addClass(c,"ge-table-cell-editor-input"),c.value=a==null?"":String(a),c.defaultValue=c.value,c.addEventListener("focus",()=>c.setSelectionRange(0,c.value.length),{once:!0}),e.textContent="",l.appendChild(e,c)}}}class Uo{constructor(e=new ze("❯","",["gt-table-icon-expanded"]),t=new ze("❯","transform: rotate(180deg) translate(-100%, -100%); transform-origin: 0 0;",["ge-table-icon-collapsed"])){this.iconExpanded=e,this.iconCollapsed=t}}const Er=(n,e)=>new Nl;class gt{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new dr,this.headerGroupOptions=new Uo,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new ur,this.sortOrder=["asc","desc"],this.shortcutActionsDisabled=!1,this.resizeEventDebounceDelay=500,this.getEditRenderer=Er,this.getSelectionModel=void 0,this.getFocusModel=void 0,this.ariaLabel=void 0,this.ariaLabelledBy=void 0,this.ariaDescribedBy=void 0,this.ariaTexts=void 0,this.overlayOptions=void 0,this.rowDragOptions=void 0,this.columnAutoWidth=void 0,this.fillHandle=void 0,this.masterDetail=void 0,this.batchEdit=void 0,this.editing=void 0,this.clipboard=void 0,this.undo=void 0,this.cellFormulas=void 0,this.spreadsheet=void 0,this.direction=void 0,this.focusFrame=void 0,this.filterRow=void 0,this.columnFilterMenu=void 0,this.columnFilter=void 0,this.columnFilterTexts=void 0}}class ke{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.silent=!1,this.listenerArr=[]}getEventSelectionChangedListeners(){return this.listenerArr}addEventSelectionChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventSelectionChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.silent||this.listenerArr.forEach(e=>e.onSelectionChanged(this))}firstClick(e,t){this.selectionType==="row"?this.addRange(M.singleRow(e)):this.selectionType==="column"?this.addRange(M.singleColumn(t)):(this.selectionType==="cell"||this.selectionType==="range")&&this.addRange(M.singleCell(e,t))}createSnapshot(){return{ranges:[...this.ranges],negativeRanges:[...this.negativeRanges],allSelected:this.allSelected}}restoreSnapshot(e){this.ranges=[...e.ranges],this.negativeRanges=[...e.negativeRanges],this.allSelected=e.allSelected,this.fireChangeEvent()}adjustForRowChanges(e){if(e.isEmpty())return!1;const t=ke.shiftRanges(this.ranges,e);return ke.shiftRanges(this.negativeRanges,e),t}static shiftRanges(e,t){let s=!1;const o=[];for(const i of e){const r=Math.min(i.r1,i.r2),l=Math.max(i.r1,i.r2);if(r===0&&l>=Number.MAX_SAFE_INTEGER){o.push(i);continue}const a=l>=Number.MAX_SAFE_INTEGER?[[t.mapIndexOrNext(r),Number.MAX_SAFE_INTEGER]]:t.mapRange(r,l),c=a.reduce((f,[p,g])=>f+(g>=Number.MAX_SAFE_INTEGER?0:g-p+1),0);if(l<Number.MAX_SAFE_INTEGER&&c<l-r+1&&(s=!0),!a.length)continue;const h=i.r1>i.r2,[d,...u]=a;i.r1=h?d[1]:d[0],i.r2=h?d[0]:d[1],o.push(i);for(const[f,p]of u)o.push(new M(f,i.c1,p,i.c2,i.gammaRange))}e.length=0;for(const i of o)e.push(i);return s}getSelectionCount(e,t){let s=0;for(const o of this.ranges)o.isInRange(e,t)&&s++;return this.allSelected&&s++,this.isInNegativeRange(e,t)&&(s=0),s}isInNegativeRange(e,t){for(const s of this.negativeRanges)if(s.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.fireChangeEvent()}hasSelection(){return this.allSelected||!!this.ranges.length}hasNoSelection(){return!this.hasSelection()}getMergedRowIndices(e){const t=e===void 0?void 0:e-1,s=[...this.ranges];this.allSelected&&t!==void 0&&s.push(new M(0,0,t,Number.MAX_SAFE_INTEGER));const o=new Set;for(const i of s){const r=Math.max(i.r1,0),l=t===void 0?i.r2:Math.min(i.r2,t);if(t===void 0&&!(l<Number.MAX_SAFE_INTEGER))continue;const a=this.negativeRanges.filter(c=>ke.intersects(c,i));for(let c=r;c<=l;c++)!o.has(c)&&(!a.length||!ke.coversColumns(a,c,i.c1,i.c2))&&o.add(c)}return Array.from(o).sort((i,r)=>i-r)}selectAll(){this.selectionType!=="none"&&(this.allSelected=!0,this.negativeRanges=[],this.fireChangeEvent())}isAllSelected(){return this.allSelected}addSelection(e){this.addRange(e)}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=new M(e.r1,0,e.r2,Number.MAX_SAFE_INTEGER):this.selectionType==="column"&&(t=new M(0,e.c1,Number.MAX_SAFE_INTEGER,e.c2)),this.negativeRanges.push(t),this.ranges=this.ranges.filter(s=>!this.isCoveredByNegativeRanges(s)),this.fireChangeEvent()}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(M.singleCell(e,t)):this.reselectPoint(e,t)?this.fireChangeEvent():this.addSelection(M.singleCell(e,t))}isSelected(e,t){return this.getSelectionCount(e,t)>0}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[],this.negativeRanges=[]),this.adjustRangeToSelectionType(e),this.liftNegativeRanges(e),this.ranges.push(e),this.fireChangeEvent())}adjustRangeToSelectionType(e){return this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,e}reselectPoint(e,t){return this.selectionType==="none"||!this.isInNegativeRange(e,t)||!this.allSelected&&!this.ranges.some(s=>s.isInRange(e,t))?!1:(this.liftNegativeRanges(this.adjustRangeToSelectionType(M.singleCell(e,t))),!0)}liftNegativeRanges(e){if(!this.negativeRanges.length)return;const t=[];for(const s of this.negativeRanges){const o=Math.max(s.r1,e.r1),i=Math.min(s.r2,e.r2),r=Math.max(s.c1,e.c1),l=Math.min(s.c2,e.c2);if(o>i||r>l){t.push(s);continue}s.r1<o&&t.push(new M(s.r1,s.c1,o-1,s.c2,s.gammaRange)),i<s.r2&&t.push(new M(i+1,s.c1,s.r2,s.c2,s.gammaRange)),s.c1<r&&t.push(new M(o,s.c1,i,r-1,s.gammaRange)),l<s.c2&&t.push(new M(o,l+1,i,s.c2,s.gammaRange))}this.negativeRanges=t}isCoveredByNegativeRanges(e){let t=[e];for(const s of this.negativeRanges)if(t=t.flatMap(o=>ke.difference(o,s)),!t.length)return!0;return!1}static difference(e,t){const s=Math.max(e.r1,t.r1),o=Math.min(e.r2,t.r2),i=Math.max(e.c1,t.c1),r=Math.min(e.c2,t.c2);if(s>o||i>r)return[e];const l=[];return e.r1<s&&l.push(new M(e.r1,e.c1,s-1,e.c2)),o<e.r2&&l.push(new M(o+1,e.c1,e.r2,e.c2)),e.c1<i&&l.push(new M(s,e.c1,o,i-1)),r<e.c2&&l.push(new M(s,r+1,o,e.c2)),l}static intersects(e,t){return Math.max(e.r1,t.r1)<=Math.min(e.r2,t.r2)&&Math.max(e.c1,t.c1)<=Math.min(e.c2,t.c2)}static coversColumns(e,t,s,o){const i=e.filter(l=>l.r1<=t&&t<=l.r2&&l.c1<=l.c2).sort((l,a)=>l.c1-a.c1);let r=s;for(const l of i){if(l.c1>r)return!1;if(l.c2>=r&&(r=l.c2+1),r>o)return!0}return r>o}}class Mr{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1,this.listenerArr=[]}getEventFocusChangedListeners(){return this.listenerArr}addEventFocusChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventFocusChangedListener(e){const t=this.listenerArr.indexOf(e,0);t>-1&&this.listenerArr.splice(t,1)}fireChangeEvent(){this.listenerArr.forEach(e=>e.onFocusChanged(this))}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1,this.fireChangeEvent()}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0,this.fireChangeEvent())}adjustForRowChanges(e){if(this.rowIndex<0||e.isEmpty())return;const t=e.mapIndex(this.rowIndex);if(t>=0){this.rowIndex=t;return}this.rowIndex=e.mapIndexOrNext(this.rowIndex),this.changed=!0,this.fireChangeEvent()}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}function sd(n){var e,t;try{const o=new Intl.NumberFormat(n).formatToParts(12345.6);return{decimal:((e=o.find(i=>i.type==="decimal"))==null?void 0:e.value)??".",group:((t=o.find(i=>i.type==="group"))==null?void 0:t.value)??","}}catch{return{decimal:".",group:","}}}const od=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let pi;function Vl(n){var e;if(!pi){let t=[];try{t=((e=Intl.supportedValuesOf)==null?void 0:e.call(Intl,"currency"))??[]}catch{t=[]}pi=new Set(t.length?t:["EUR","USD","GBP","CHF","JPY","CNY","CAD","AUD","SEK","NOK","DKK","PLN","CZK"])}return pi.has(n)}function pn(n){return n.replace(new RegExp("^\\p{Sc}\\s*","u"),"").replace(/^([A-Z]{3})\s+/u,(e,t)=>Vl(t)?"":e)}function Xt(n,e){let t=n.trim().replace(/[   ]/g," ").replace(/−/g,"-");if(!t)return;let s=!1;if(/^\(.*\)$/.test(t)&&(s=!0,t=t.slice(1,-1).trim(),/^[-+]/.test(t)))return;let o=!1;t=pn(t),t=t.replace(/\s*%$/u,()=>(o=!0,"")),t=t.replace(new RegExp("\\s*\\p{Sc}$","u"),"").replace(/\s+([A-Z]{3})$/u,(c,h)=>Vl(h)?"":c),(t.startsWith("-")||t.startsWith("+"))&&(s=s!==t.startsWith("-"),t=pn(t.slice(1).trim()));const{decimal:i,group:r}=sd(e),l=r.trim()===""?" ":r;if(t=t.replace(new RegExp(`[${od(l)}](?=\\d{3}(\\D|$))`,"g"),""),i!=="."){if(t.includes(".")&&!/[eE]/.test(t))return;t=t.replace(i,".")}if(!/^(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(t))return;let a=Number(t);return o&&(a/=100),s?-a:a}function id(n){return e=>typeof e!="string"?e:e.trim()===""?"":Xt(e,n)??e}function rd(n){try{return new Intl.DateTimeFormat(n).formatToParts(new Date(2026,10,23)).filter(e=>e.type==="day"||e.type==="month"||e.type==="year").map(e=>e.type)}catch{return["month","day","year"]}}function Qs(n,e){const t=n.trim(),s=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/.exec(t);if(s)return gn(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));const o=/^(\d{1,4})([./-])(\d{1,2})\2(\d{1,4})(?:,? (\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(t);if(!o)return;const i=rd(e),r=[o[1],o[3],o[4]],l={};for(let c=0;c<3;c++){const h=i[c],d=r[c];if(h==="year"?d.length!==2&&d.length!==4:d.length>2)return;l[h]=+d}let a=l.year;return a<100&&(a+=2e3),gn(a,l.month,l.day,+(o[5]??0),+(o[6]??0),+(o[7]??0))}function gn(n,e,t,s,o,i){const r=new Date(n,e-1,t,s,o,i);return r.getFullYear()===n&&r.getMonth()===e-1&&r.getDate()===t?r:void 0}function nd(n){return e=>typeof e!="string"?e:e.trim()===""?"":Qs(e,n)??e}const ld=["true","yes","1","x","wahr","ja"],ad=["false","no","0","falsch","nein"],cd=n=>{if(typeof n!="string")return n;const e=n.trim().toLowerCase();return e===""?"":ld.includes(e)?!0:ad.includes(e)?!1:n};function Tr(n){return e=>{if(typeof e!="string"||e.startsWith("=")||e.startsWith("'="))return e;if(e.startsWith("'"))return e.slice(1);const t=e.trim();if(t==="")return"";const s=t.toUpperCase();if(s==="TRUE")return!0;if(s==="FALSE")return!1;const o=Xt(t,n);return o!==void 0?o:Qs(t,n)??e}}class Ir extends ue{constructor(){super(...arguments),this.columnLetterRows=1}isColumnLetterRow(e){return e<this.columnLetterRows}setColumns(e){this.arr.length=0,this.arr.push(e.map(t=>t.headerLabel)),this.filteredArr=[...this.arr],this.columnDefs=e,this.cellRenderers=e.map(t=>{var s;return(s=t.rendererMap)==null?void 0:s[this.areaIdent]})}}class Dr extends ft{constructor(e,t,s,o,i,r,l=Tr()){super(e,t,new xe("footer"),s?1:0,0,!1,new et(i,i,i),o),this.sheetBody=t,this.rowNumberColumn=s,this.columnWidth=r,this.inputPipe=l}setDataColumns(e,t=[]){const s=Pl(e,this.columnWidth,this.rowNumberColumn,t,this.inputPipe);this.columnDefs=s,this.columnCount=s.length,this.columnSizes=[],this.headerAreaModel.setColumns(s),this.sheetBody.setColumnDefs(s),this.init()}getDataColumnWidths(){const e=this.rowNumberColumn?1:0;return Array.from({length:this.getColumnCount()-e},(t,s)=>this.getColumnWidth(s+e))}}function Pl(n,e,t,s=[],o){const i=Array.from({length:n},(r,l)=>Oe.create({editInputPipe:o,property:st(l),headerLabel:st(l),width:new D(s[l]??e,"px"),minWidth:new D(20,"px"),maxWidth:new D(2e3,"px")}));return t?[t,...i]:i}class hd{static create(e={}){const t=e.data??[],s=Math.max(e.rowCount??100,t.length),o=Math.max(e.columnCount??26,t.reduce((m,b)=>Math.max(m,(b==null?void 0:b.length)??0),0)),i=e.rowHeight??30,r=e.columnWidth??100,l=e.rowNumbers===!1?void 0:new Zs({mode:"original"}),a=Tr(e.locale),c=Pl(o,r,l,[],a),h=new Ir("header",[c.map(m=>m.headerLabel)],i,c),d=new ot("body",t,s,o,i,c,l?1:0),u=new Dr(h,d,l,c,i,r,a),f=new ke("range","multi"),p=new Mr("cell");p.setFocus(0,l?1:0);const g={...new gt,getSelectionModel:()=>f,getFocusModel:()=>p,spreadsheet:!0,...e.functions?{cellFormulas:{functions:e.functions}}:{},hoverRowVisible:!1,hoverColumnVisible:!1,...e.tableOptions};return{tableModel:u,tableOptions:g}}}function Ko(n){return n instanceof Dr}class Li{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class mt{constructor(e,t,s){this.cells=e,this.changes=t,this.source=s}static createForChanges(e,t){const s=e.filter(o=>o.rowIndex>-1).map(o=>new Li(o.rowIndex,o.columnIndex));return new mt(s,e,t)}static createSingle(e,t){return new mt([new Li(e,t)])}}class Le{static create(e){const t=new Le;if(e)for(const s of Object.keys(e)){const o=e[s];typeof o=="function"&&(t[s]=o)}return t}sorted(e,t){return t==="asc"?`Sorted by ${e}, ascending`:t==="desc"?`Sorted by ${e}, descending`:`Sorting of ${e} removed`}filtered(e){return e===0?"No rows":e===1?"1 row":`${e} rows`}copied(e){return e===1?"1 cell copied":`${e} cells copied`}allSelected(){return"All cells selected"}selectionCleared(){return"Selection cleared"}selectRow(e){return`Select row ${e}`}selectAllRows(){return"Select all rows"}expandGroup(e){return e?`Expand group ${e}`:"Expand group"}collapseGroup(e){return e?`Collapse group ${e}`:"Collapse group"}rowDragStarted(e){return e===1?"Dragging 1 row. Press Escape to cancel.":`Dragging ${e} rows. Press Escape to cancel.`}rowMoved(e,t){return`Row moved to position ${e} of ${t}`}rowMoveNotPossible(){return"Rows cannot be moved while the table is sorted or filtered"}rowDragCancelled(){return"Drag cancelled"}cellsFilled(e){return e===1?"1 cell filled":`${e} cells filled`}detailExpanded(){return"Details expanded"}detailCollapsed(){return"Details collapsed"}fillTooLarge(e){return`Too many cells to fill (at most ${e})`}pendingChanges(e){return e===0?"No unsaved changes":e===1?"1 change not saved":`${e} changes not saved`}changesCommitted(e){return e===1?"1 change saved":`${e} changes saved`}changesDiscarded(){return"Changes discarded"}commitBlocked(e){return e===1?"1 invalid value – nothing saved":`${e} invalid values – nothing saved`}invalidValue(e){return e?`Invalid value: ${e}`:"Invalid value"}editingStarted(e){return e?`Editing ${e}`:"Editing"}readOnlyCell(){return"Read only"}cellsCleared(e){return e===1?"1 cell cleared":`${e} cells cleared`}clearTooLarge(e){return`Too many cells to clear (at most ${e})`}rangeSelected(e,t){const s=e===1?"1 row":`${e} rows`,o=t===1?"1 column":`${t} columns`;return`${s}, ${o} selected`}rowSelected(e){return e===1?"Row selected":`${e} rows selected`}columnSelected(e){return e===1?"Column selected":`${e} columns selected`}gridEditingHint(){return"Type to edit a cell, Enter to edit or commit, Escape to cancel. Tab in the last column leaves the table."}cellsPasted(e,t){const s=e===1?"1 cell pasted":`${e} cells pasted`;return t>0?`${s}, ${t} skipped`:s}pasteTooLarge(e){return`Too many cells to paste (at most ${e})`}copyTooLarge(e){return`Too many cells to copy (at most ${e})`}cutMarked(e){return`${e===1?"1 cell":`${e} cells`} cut, paste to move them`}copiedLastRangeOnly(){return"Only the last selected range was copied"}undone(e,t){return`Undo ${e}, ${t===1?"1 cell":`${t} cells`}`}redone(e,t){return`Redo ${e}, ${t===1?"1 cell":`${t} cells`}`}nothingToUndo(){return"Nothing to undo"}nothingToRedo(){return"Nothing to redo"}undoSkipped(e){return`${e===1?"1 cell":`${e} cells`} skipped`}undoHistoryCleared(e){return`This change cannot be undone (more than ${e} cells)`}formulaError(e){return`Formula error: ${e}`}functionSuggestions(){return"Functions"}referenceInserted(e){return e}rowsInserted(e){return e===1?"1 row inserted":`${e} rows inserted`}rowsDeleted(e){return e===1?"1 row deleted":`${e} rows deleted`}columnsInserted(e){return e===1?"1 column inserted":`${e} columns inserted`}columnsDeleted(e){return e===1?"1 column deleted":`${e} columns deleted`}filterInput(e){return e?`Filter ${e}`:"Filter column"}clearColumnFilter(e){return e?`Clear filter for ${e}`:"Clear filter"}filterColumn(e){return e?`Filter menu for ${e}`:"Filter menu"}filterColumnActive(e){return e?`Filter menu for ${e} (active)`:"Filter menu (active)"}filterMenuDialog(e){return e?`Filter ${e}`:"Filter"}columnChooserDialog(){return"Choose columns"}}const dd={insertRows:"Insert rows",deleteRows:"Delete rows",insertColumns:"Insert columns",deleteColumns:"Delete columns"};function Ut(n,e,t={}){var m,b,w,y,C;const s=n.tableModel,o=s.getBodyModel(),i=e.kind==="insertColumns"||e.kind==="deleteColumns",r=o instanceof ot?o:void 0,l=o instanceof oe||o instanceof ue;if(!(e.count>=1)||!(e.at>=0)||(i?!r||!Ko(s):!r&&!l)||n.isBatchEditActive())return!1;const a=i?r.getSheetColumnCount():r?r.getUnfilteredRowCount():Fr(o).length,h=e.kind==="deleteRows"||e.kind==="deleteColumns"?Math.min(e.count,a-e.at):e.count;if(e.at>a||h<1||(m=n.cellEditorService)!=null&&m.isOpen()&&!n.cellEditorService.commit("none"))return!1;const d={...e,count:h},u=n.tableSheet;u==null||u.rowCount();const f=u?u.engine.adjustForStructureChange(d):[],p=ud(n,d,t.rows),g=[];if(u){const S=u.rowsArray();for(const{row:x,col:R,input:I}of f){const A=S?S[x]:r==null?void 0:r.getRowArray(x),T=u.inputAt(x,R);if(A&&typeof A=="object"){const P=d.kind==="insertColumns"?R>=d.at+h?R-h:R:d.kind==="deleteColumns"&&R>=d.at?R+h:R;p.inputs.push({row:A,col:P,old:T})}u.writeInput(x,R,I);const F=u.modelColumn(R);g.push({row:A,rowIndex:u.displayRow(x),columnIndex:F,property:((b=s.getColumnDef(F))==null?void 0:b.property)??"",oldValue:T,newValue:I})}u.recalculate()}return n.refreshAfterStructureChange(i),t.record!==!1&&((w=n.undoService)==null||w.addStep(new gd(d,p))),n.announce(pd(n,d)),(C=(y=n.getEventListener()).onModelChanged)==null||C.call(y,mt.createForChanges(g,t.source??"structure")),!0}function ud(n,e,t){const s=n.tableModel,o=s.getBodyModel(),{at:i,count:r}=e,l={inputs:[]};if(o instanceof ot){if(e.kind==="insertRows")o.insertRows(i,r);else if(e.kind==="deleteRows")l.sheetRows=o.deleteRows(i,r);else if(Ko(s)){const c=s.getDataColumnWidths();l.widths=[...c],e.kind==="insertColumns"?(o.insertColumns(i,r),c.splice(i,0,...new Array(r).fill(NaN))):(l.sheetColumns=o.deleteColumns(i,r),c.splice(i,r)),s.setDataColumns(o.getSheetColumnCount(),c.map(h=>Number.isNaN(h)?void 0:h))}return l}const a=Fr(o);if(e.kind==="insertRows"){const c=t??Array.from({length:r},(h,d)=>fd(n,i+d));for(let h=0;h<c.length;h++)a.splice(i+h,0,c[h]);l.rows=c}else l.rows=a.splice(i,r);return Bl(o,a),l}function Fr(n){return n instanceof oe?n.getAllRows():n.arr}function Bl(n,e){n instanceof oe?n.setRows(e):n instanceof ue&&(n.filteredArr=[...e])}function fd(n,e){if(n.tableModel.getBodyModel()instanceof ue)return new Array(n.tableModel.getColumnCount()).fill("");const s=n.getClipboardService().options.createRow;return s?s(e):{}}function pd(n,e){const t=n.ariaTexts,s=new Le;switch(e.kind){case"insertRows":return(t.rowsInserted??s.rowsInserted).call(t,e.count);case"deleteRows":return(t.rowsDeleted??s.rowsDeleted).call(t,e.count);case"insertColumns":return(t.columnsInserted??s.columnsInserted).call(t,e.count);default:return(t.columnsDeleted??s.columnsDeleted).call(t,e.count)}}class gd{constructor(e,t){var s,o;this.edit=e,this.delta=t,this.source="structure",this.label=dd[e.kind],this.cellCount=e.count+t.inputs.length+(((s=t.sheetRows)==null?void 0:s.reduce((i,[,r])=>i+r.length,0))??0)+(((o=t.sheetColumns)==null?void 0:o.reduce((i,[,r])=>i+r.length,0))??0)}undo(e){var a,c,h,d,u;const t=e.tableModel,s=t.getBodyModel(),{at:o,count:i,kind:r}=this.edit,l=this.delta;if(s instanceof ot)r==="insertRows"?s.deleteRows(o,i):r==="deleteRows"?s.restoreRows(o,i,l.sheetRows):Ko(t)&&(r==="insertColumns"?s.deleteColumns(o,i):s.restoreColumns(o,i,l.sheetColumns),t.setDataColumns(s.getSheetColumnCount(),l.widths));else{const f=Fr(s);if(r==="insertRows")f.splice(o,i);else for(let p=0;p<(((a=l.rows)==null?void 0:a.length)??0);p++)f.splice(o+p,0,l.rows[p]);Bl(s,f)}for(const{row:f,col:p,old:g}of l.inputs)(c=e.tableSheet)==null||c.writeInput(f,p,g);return(h=e.tableSheet)==null||h.recalculate(),e.refreshAfterStructureChange(r==="insertColumns"||r==="deleteColumns"),(u=(d=e.getEventListener()).onModelChanged)==null||u.call(d,mt.createForChanges([],"undo")),{applied:i,skipped:0}}redo(e){return Ut(e,this.edit,{record:!1,rows:this.edit.kind==="insertRows"?this.delta.rows:void 0,source:"redo"}),{applied:this.edit.count,skipped:0}}}class _l{constructor(e){this.tableScope=e}updateCells(e,t=!1){this.tableScope.updateCells(e,t)}externalFilterChanged(){this.tableScope.externalFilterChanged()}setColumnFilter(e,t){this.tableScope.setColumnFilter(e,t)}getColumnFilter(e){return this.tableScope.getColumnFilter(e)}getColumnFilters(){return this.tableScope.getColumnFilters()}setColumnFilters(e){this.tableScope.setColumnFilters(e)}clearColumnFilters(){this.tableScope.clearColumnFilters()}isColumnFiltered(e){return this.tableScope.isColumnFiltered(e)}setFilterRowVisible(e){this.tableScope.setFilterRowVisible(e)}isFilterRowVisible(){return this.tableScope.isFilterRowVisible()}showColumnFilterMenu(e){return this.tableScope.showColumnFilterMenu(e)}hideColumnFilterMenu(){this.tableScope.hideColumnFilterMenu()}showColumnChooser(e){this.tableScope.showColumnChooser(e)}hideColumnChooser(){this.tableScope.hideColumnChooser()}scrollToPixel(e=0,t=0){this.tableScope.scrollToPixel(e,t)}getDirection(){return this.tableScope.direction}scrollToIndex(e=0,t=0){this.tableScope.scrollToIndex(e,t)}setHeaderVisible(e=!0){this.tableScope.setHeaderVisible(e)}setColumnVisible(e,t=!0){return this.tableScope.setColumnVisible(e,t)}isColumnVisible(e){var i;const t=this.tableScope.tableModel;if(t.isColumnVisible)return t.isColumnVisible(e);const s=t.getColumnDefs()??[],o=typeof e=="number"?s[e]:typeof e=="string"?s.filter(r=>r.property===e)[0]:e;return o?((i=o.isVisible)==null?void 0:i.call(o))!==!1:typeof e=="number"&&e>=0&&e<t.getColumnCount()}isHeaderVisible(){return this.tableScope.tableModel.isHeaderVisibe()}setFooterVisible(e=!0){this.tableScope.setFooterVisible(e)}isFooterVisible(){return this.tableScope.tableModel.isFooterVisibe()}repaint(){this.tableScope.invalidateAggregates(),this.tableScope.repaint()}destroy(){this.tableScope.destroy()}repaintHard(e){this.tableScope.invalidateAggregates(),this.tableScope.repaintHard(e)}recalcColumnWidths(e){this.tableScope.recalcColumnWidths(e)}clearSelection(){this.tableScope.clearSelection(!0)}setSelectionModel(e,t=!0){this.tableScope.setSelectionModel(e,t)}triggerAction(e){return this.tableScope.onActionTriggered(e)}getShortcutActionMapping(){return this.tableScope.shortcutService.getShortcutActionMapping()}copyToClipboard(){return this.tableScope.copyService.copyToClipboard(this.tableScope.tableModel,this.tableScope.selectionModel(),this.tableScope.focusModel()).then(e=>(this.tableScope.announceCopied(e),e))}announce(e){this.tableScope.announce(e)}showLoadingOverlay(e){this.tableScope.showLoadingOverlay(e)}showNoRowsOverlay(e){this.tableScope.showNoRowsOverlay(e)}hideOverlay(){this.tableScope.hideOverlay()}getOverlayState(){return this.tableScope.getOverlayState()}getState(e){return this.tableScope.stateService.getState(e)}applyState(e,t){this.tableScope.stateService.applyState(e,t)}resetState(){this.tableScope.stateService.resetState()}setCustomState(e){this.tableScope.stateService.setCustomState(e)}setHeaderGroupCollapsed(e,t=!0){return this.tableScope.setHeaderGroupCollapsed(e,t)}getHeaderFocus(){return this.tableScope.getHeaderFocus()}downloadExcel(e="table.xlsx",t="",s={}){var f;const o=[],i=this.tableScope.tableModel,r=[];for(let p=0;p<i.getColumnCount();p++){const g=i.getColumnDef(p);((f=g==null?void 0:g.isVisible)==null?void 0:f.call(g))!==!1&&(G(g)&&!g.options.exported||r.push(p))}const l=i.getBodyModel(),a=l instanceof ot?l.getContentExtent():void 0;if(a){const p=this.tableScope.getFirstDataColumnIndex();for(let g=r.length-1;g>=0;g--)r[g]>=p&&r[g]>a[1]&&r.splice(g,1)}const c=s.cellFormulas?this.getExcelFormulaOffset(r,a==null?void 0:a[1]):void 0,h=["header","body","footer"];for(const p of h){const g=i.getAreaModel(p),m=p==="body"&&a?a[0]+1:(g==null?void 0:g.getRowCount())??0;for(let b=0;b<m;b++)p==="header"&&mn(g,b)||o.push(r.map(w=>c&&p==="body"?this.getExcelFormulaCell(g,b,w,c)??this.getExportValue(i,p,g,b,w):this.getExportValue(i,p,g,b,w)))}const d=this.tableScope.isRtl()?{rightToLeft:!0}:void 0,u=Object.keys(s).length?{...s,...d}:d;return Promise.resolve(u?this.tableScope.excelService.downloadExcel(o,e,t,u):this.tableScope.excelService.downloadExcel(o,e,t))}getExcelFormulaOffset(e,t=Number.MAX_SAFE_INTEGER){var f;const s=this.tableScope,o=s.tableSheet;if(!o)return;const i=p=>{console.warn(`GuiExpert Table – downloadExcel: values instead of formulas (${p}).`)};if(!s.excelService.supportsFormulas)return i("the Excel service writes no formulas");const r=s.tableModel.getBodyModel(),l=r.getRowCount();if(l!==(((f=r.getUnfilteredRowCount)==null?void 0:f.call(r))??l))return i("a filter hides rows");for(let p=0;p<l;p++)if(o.physicalRow(p)!==p)return i("the rows are sorted");const a=e.map(p=>o.engineColumn(p)),c=a.findIndex(p=>p!==void 0);let h=0;for(let p=0;p<e.length;p++){const g=a[p];if(g!==void 0){if(g!==h||p!==c+h)return i("a data column is hidden or moved");h++}}for(let p=0;p<s.tableModel.getColumnCount();p++)if(o.engineColumn(p)!==void 0&&!e.includes(p)&&p<=t)return i("a data column is hidden");const d=s.tableModel.getAreaModel("header");let u=0;for(let p=0;p<((d==null?void 0:d.getRowCount())??0);p++)mn(d,p)||u++;return u+l>ye||Math.max(0,c)+h>de?i("the sheet is larger than an Excel sheet"):{dRow:u,dCol:Math.max(0,c),rows:l,cols:h,sheet:o}}getExcelFormulaCell(e,t,s,o){var l;const i=(l=e.getInputValueAt)==null?void 0:l.call(e,t,s);if(!o.sheet.isFormulaInput(s,i))return;const r=Zh(i,o);return r===void 0?void 0:{formula:r,value:e.getValueAt(t,s)}}getExportValue(e,t,s,o,i){const r=e.getColumnDef(i);if(G(r)&&t!=="header")return t!=="body"?"":r.hasDefaultFormat()?r.getRowNumber(o,s):r.getRowNumberText(o,s);const l=s.getValueAt(o,i);if(t!=="header"&&typeof l=="number"&&this.tableScope.excelService.supportsNumberFormats){const a=js(r)?r.pivot.value.showValuesAs:t==="body"?r==null?void 0:r.showValuesAs:void 0,c=Mh(a);if(c)return{value:l,numberFormat:c}}return l}getColumnIndex(e){var s,o,i;const t=((o=(s=this.tableScope.tableModel).getColumnDefs)==null?void 0:o.call(s))??[];for(let r=0;r<t.length;r++)if(((i=t[r])==null?void 0:i.property)===e)return r;return-1}getTableScope(){return this.tableScope}getSelectionModel(){return this.tableScope.selectionModel()}getSelectionAggregates(){return new bo().aggregate(this.tableScope.tableModel,this.getSelectionModel())}autoResizeColumns(e=!0){this.tableScope.autoResizeColumns(e)}autoResizeColumn(e){return this.tableScope.autoResizeColumn(e)}isColumnDragging(){return this.tableScope.isColumnDragging()}cancelColumnDrag(){this.tableScope.cancelColumnDrag()}recalcWrappers(){this.tableScope.recalcWrappers()}setColumnWidth(e,t){this.tableScope.setColumnWidth(e,t)}getTableModel(){return this.tableScope.tableModel}getBodyModel(){return this.tableScope.tableModel.getBodyModel()}setRows(e){var s;const t=this.getBodyModel();t instanceof oe?(t.setRows(e),this.tableScope.columnFilterService.onRowsReplaced(),(s=this.tableScope.batchEditService)==null||s.pruneOrphans(),this.tableScope.invalidateRowLayout()):console.warn("setRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof t,t)}appendRows(e,t){return this.tableScope.appendRows(e,t)}rowsAppended(e,t){return this.tableScope.notifyRowsAppended(e,t)}addRows(e){const t=this.getBodyModel();if(t instanceof oe){const s=t;let o=s.getAllRows();s.setRows([...o,...e])}else console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof t,t)}addRowsAt(e,t){const s=this.getBodyModel();if(s instanceof oe){const o=s;let i=o.getAllRows();o.setRows([...i.slice(0,t),...e,...i.slice(t)])}else console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}removeRows(e,t=(s,o)=>s===o){const s=this.getBodyModel();if(s instanceof oe){const o=s,i=o.getAllRows().filter(r=>!e.some(l=>t(r,l)));o.setRows(i)}else console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}findRows(e,t=(s,o)=>s===o){const s=this.getBodyModel();return s instanceof oe?s.getAllRows().filter(i=>e.some(r=>t(i,r))):(console.warn("findRows<T>(rows: T[], predicate: (a: T, b: T) => boolean) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s),[])}findRowFromFilteredRowsByAllCriteria(e,t){const s=this.getBodyModel();if(s instanceof oe)return s.getFilteredRows().find(i=>t(e,i));console.warn("findRowFromFilteredRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}findRowFromAllRowsByAllCriteria(e,t){const s=this.getBodyModel();if(s instanceof oe)return s.getAllRows().find(i=>t(e,i));console.warn("findRowFromAllRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}updateRows(e,t=(s,o)=>s===o){const s=this.getBodyModel();if(s instanceof oe){let i=s.getAllRows();for(const r of i)for(const l of e)if(t(r,l))for(const a of Object.keys(l))r[a]=l[a]}else console.warn("updateRows<T>(rows: T[], predicate: (a: T, b: T) => boolean) only works with AreaModelObjectArray<T>, but this body area model is ",typeof s,s)}sortByColumn(e,t){return this.tableScope.sortByColumn(e,t)}reSort(){this.tableScope.reSort()}expandAll(){this.tableScope.toggleExpandCollapseAll(!0)}collapseAll(){this.tableScope.toggleExpandCollapseAll(!1)}setRowExpanded(e,t){const s=this.tableScope.tableModel.getBodyModel().getRowByIndex(e);return J(s)?this.tableScope.setTreeRowExpanded(s,t):!1}setRowGroupBy(e){return this.tableScope.setRowGroupBy(e)}getRowGroupBy(){const e=this.tableScope.tableModel.getBodyModel();return ge(e)?e.getGroupBy():void 0}setPivotConfig(e,t){return this.tableScope.setPivotConfig(e,t)}getPivotConfig(){const e=this.tableScope.tableModel;return po(e)?e.getPivotConfig():void 0}getRowValue(e,t){const s=this.tableScope.tableModel.getBodyModel();if(typeof s.getRowValue=="function")return s.getRowValue(e,t);const o=J(e)?e.data:e;if(o==null)return;let i=o;for(const r of t.split(".")){if(i==null)return;i=i[r]}return i}setShowValuesAs(e,t){const s=(this.tableScope.tableModel.getColumnDefs()??[]).filter(o=>o.property===e);return!s.length||t!==void 0&&!ds(t)?!1:(s.forEach(o=>o.showValuesAs=t),this.repaint(),!0)}getShowValuesAs(e){var t,s;return(s=(t=this.tableScope.tableModel.getColumnDefs())==null?void 0:t.find(o=>o.property===e))==null?void 0:s.showValuesAs}setColumnFormula(e,t,s){const o=(this.tableScope.tableModel.getColumnDefs()??[]).filter(l=>l.property===e);if(!o.length)return new L("#NAME?",`No column "${e}"`);const i=xr(t,s),r=Rr(i);return o.forEach(l=>{l.formula=i.source,l.valueGetter=r}),this.repaint(),i.error}sort(e){this.tableScope.sort(e)}moveRows(e,t){const s=this.tableScope.rowDragService;if(!s)return!1;const o=Array.isArray(e)?e:[e];let i;if(typeof t=="number"){const r=this.tableScope.tableModel.getBodyModel().getRowCount();i=t>=r?{rowIndex:r-1,position:"after"}:{rowIndex:Math.max(0,t),position:"before"}}else i=t;return s.moveRows(o,i,!0)>-1}isRowDragging(){var e;return!!((e=this.tableScope.rowDragService)!=null&&e.isDragging())}cancelRowDrag(){var e;(e=this.tableScope.rowDragService)==null||e.cancel()}applyCellChanges(e,t="api",s={}){return this.tableScope.applyCellChanges(e,t,s)}fillRange(e,t,s,o="auto"){return this.tableScope.fillRange(e,t,s,o)}isFilling(){var e;return!!((e=this.tableScope.fillHandleService)!=null&&e.isFilling())}cancelFill(){var e;(e=this.tableScope.fillHandleService)==null||e.cancel()}subscribe(e){return this.tableScope.subscribe(e)}startEditing(e,t,s){var i;const o=typeof t=="number"?t:this.getColumnIndex(t);return o<0?!1:s!==void 0&&((i=this.tableScope.cellEditorService)!=null&&i.handlesColumn(o))?this.tableScope.cellEditorService.start(e,o,{mode:"enter",typedText:s}):this.tableScope.startEditing(e,o,"edit","end")}stopEditing(e=!1){const t=this.tableScope.cellEditorService;if(t!=null&&t.isOpen())return e?(t.cancel(),!0):t.commit("none");const s=this.tableScope.getInCellEditorCell();if(s){const o=this.tableScope.hostElement.querySelector(".ge-table-cell-editor-input, .ge-table-cell-editor-select");e||!o?this.tableScope.cancelEditing(o??void 0):this.tableScope.updateModelValueAfterEdit("body",s[0],s[1],o.value)}return!this.tableScope.isEditing()}isEditing(){return this.tableScope.isEditing()}getEditingCell(){var e;return((e=this.tableScope.cellEditorService)==null?void 0:e.getCell())??this.tableScope.getInCellEditorCell()}clearCells(e){return this.tableScope.clearCells(e)}copySelection(){return this.tableScope.getClipboardService().writeSelection(!1)}cutSelection(){return this.tableScope.getClipboardService().writeSelection(!0)}pasteText(e,t){return this.tableScope.getClipboardService().paste(e,void 0,t)}getSelectionAsText(){return this.tableScope.getClipboardService().getSelectionAsText()}cancelCut(){var e;(e=this.tableScope.clipboardService)==null||e.cancelCut()}undo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.undo())}redo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.redo())}canUndo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.canUndo())}canRedo(){var e;return!!((e=this.tableScope.undoService)!=null&&e.canRedo())}clearUndoHistory(){var e;(e=this.tableScope.undoService)==null||e.clear()}getUndoState(){var e;return(e=this.tableScope.undoService)==null?void 0:e.getState()}batchUndoable(e,t){const s=this.tableScope.undoService;return s?s.batch(e,t):t()}hasCellFormulas(){return!!this.tableScope.tableSheet}getCellAddress(e,t){var s;return(s=this.tableScope.tableSheet)==null?void 0:s.address(e,this.toColumnIndex(t))}getCellByAddress(e){var t;return(t=this.tableScope.tableSheet)==null?void 0:t.cellOfAddress(e)}getCellInput(e,t){const s=this.toColumnIndex(t),o=this.tableScope.tableModel.getBodyModel();if(!(e<0||e>=o.getRowCount()||s<0))return this.tableScope.getCellInput(e,s)}getCellValue(e,t){const s=this.toColumnIndex(t),o=this.tableScope.tableModel.getBodyModel();if(!(e<0||e>=o.getRowCount()||s<0))return o.getValueAt(e,s)}setCellInput(e,t,s){return this.tableScope.applyCellChanges([{rowIndex:e,column:t,value:s}],"api").length>0}evaluateFormula(e){var t;return(t=this.tableScope.tableSheet)==null?void 0:t.evaluate(e)}getSheetValue(e){const t=this.tableScope.tableSheet;if(!t)return;const s=ut(e);return s?t.cellValue(s.row,s.col):void 0}recalculate(){const e=this.tableScope.tableSheet;e&&(e.recalculate(),this.tableScope.invalidateAggregates(),this.tableScope.repaint())}getPrecedents(e,t){var s;return((s=this.tableScope.tableSheet)==null?void 0:s.precedents(e,this.toColumnIndex(t)))??[]}getDependents(e,t){var s;return((s=this.tableScope.tableSheet)==null?void 0:s.dependents(e,this.toColumnIndex(t)))??[]}getSheetEngine(){var e;return(e=this.tableScope.tableSheet)==null?void 0:e.engine}getActiveCell(){return this.tableScope.getActiveBodyCell()}goToAddress(e){const t=this.tableScope.tableSheet,s=e.trim().split(":");if(!t||s.length>2)return!1;const o=s.map(a=>t.cellOfAddress(a));if(o.some(a=>!a||a[0]<0))return!1;const[i,r]=[o[0],o[o.length-1]],l=new M(Math.min(i[0],r[0]),Math.min(i[1],r[1]),Math.max(i[0],r[0]),Math.max(i[1],r[1]));return this.tableScope.selectBodyRange(l),this.tableScope.ensureRowIsVisible(l.r1),this.tableScope.ensureColumnIsVisible(l.c1),!0}insertRows(e,t=1){return Ut(this.tableScope,{kind:"insertRows",at:e,count:t})}deleteRows(e,t=1){return Ut(this.tableScope,{kind:"deleteRows",at:e,count:t})}insertColumns(e,t=1){return Ut(this.tableScope,{kind:"insertColumns",at:e,count:t})}deleteColumns(e,t=1){return Ut(this.tableScope,{kind:"deleteColumns",at:e,count:t})}getSheetData(){const e=this.tableScope.tableModel.getBodyModel();return e instanceof ot?e.getSheetData():void 0}toColumnIndex(e){return typeof e=="number"?e:this.getColumnIndex(e)}setDetailExpanded(e,t){return this.tableScope.setDetailExpanded(e,t,"api")}toggleDetail(e){return this.tableScope.toggleDetail(e,"api")}isDetailExpanded(e){var t;return!!((t=this.tableScope.masterDetailService)!=null&&t.isExpanded(e))}getExpandedDetailRows(){var e;return((e=this.tableScope.masterDetailService)==null?void 0:e.getExpandedRows())??[]}expandAllDetails(){var e;return((e=this.tableScope.masterDetailService)==null?void 0:e.expandAll())??0}collapseAllDetails(){var e;return((e=this.tableScope.masterDetailService)==null?void 0:e.collapseAll())??0}refreshDetail(e){var t;return!!((t=this.tableScope.masterDetailService)!=null&&t.refresh(e))}getDetailElement(e){var t;return(t=this.tableScope.masterDetailService)==null?void 0:t.getDetailElement(e)}startBatchEdit(){var t;const e=!!((t=this.tableScope.batchEditService)!=null&&t.start());return e&&this.tableScope.repaint(),e}isBatchEditing(){var e;return!!((e=this.tableScope.batchEditService)!=null&&e.isActive())}hasPendingChanges(){var e,t;return(e=this.tableScope.batchEditService)==null||e.pruneOrphans(),!!((t=this.tableScope.batchEditService)!=null&&t.hasPending())}getPendingChanges(){var e;return((e=this.tableScope.batchEditService)==null?void 0:e.getPendingChanges())??[]}commitBatchEdit(){var e;return!!((e=this.tableScope.batchEditService)!=null&&e.commit())}cancelBatchEdit(){var e;(e=this.tableScope.batchEditService)==null||e.cancel()}ensureRowIsVisible(e){return this.tableScope.ensureRowIsVisible(e)}ensureColumnIsVisible(e){return this.tableScope.ensureColumnIsVisible(e)}getDisplayedRowCount(){return this.tableScope.getDisplayedRowCount()}getFirstVisibleRowIndex(){return this.tableScope.getFirstVisibleRowIndex()}getFirstFullVisibleRowIndex(){return this.tableScope.getFirstFullVisibleRowIndex()}getLastVisibleRowIndex(){return this.tableScope.getLastVisibleRowIndex()}getLastFullVisibleRowIndex(){return this.tableScope.getLastFullVisibleRowIndex()}setLoggingActive(e){this.tableScope.loggingActive=e}isLoggingActive(){return this.tableScope.loggingActive}}function mn(n,e){var t;return!!((t=n==null?void 0:n.isColumnLetterRow)!=null&&t.call(n,e))}class Ke{constructor(e=0,t=0,s=0,o=0,i){this.left=e,this.width=t,this.height=s,this.top=o,this.index=i}}const Os=class Os{constructor(e){this.prefix=e}static createPrefix(e){const t=(e??"").trim();return t?`ge-${t.replace(/\s+/g,"_")}`:(Os.counter++,`ge-t${Os.counter}`)}cell(e,t,s){return`${this.prefix}-${e}-r${t}-c${s}`}rowGroup(e,t){return`${this.prefix}-rg-${e}-${t}`}filterRowGroup(e){return`${this.prefix}-rg-filter-${e}`}detailRowGroup(){return`${this.prefix}-rg-detail`}liveRegion(){return`${this.prefix}-live`}};Os.counter=0;let $s=Os;class zo{constructor(){this.loadingText="Loading…",this.noRowsText="No rows to show",this.noMatchesText="No matching rows",this.autoNoRows=!0,this.blockInteractionWhileLoading=!0,this.loadingDelayInMs=0,this.getOverlayElement=void 0}static create(e){const t=new zo;if(e)for(const s of Object.keys(e))e[s]!==void 0&&(t[s]=e[s]);return t}}function Oi(n){return n.manual?n.manual:!n.autoNoRows||n.rowCount!==0?"none":(n.unfilteredRowCount??0)>0?"noMatches":"noRows"}const bn={none:"",loading:"ge-table-overlay-loading",noRows:"ge-table-overlay-no-rows",noMatches:"ge-table-overlay-no-matches"};class $l{constructor(e,t,s,o=()=>{}){this.dom=t,this.requestUpdate=o,this.shownKind="none",this.shownText="",this.shownBlocking=!1,this.bounds="",this.destroyed=!1,this.options=zo.create(s),this.element=t.applyStylePosistionAbsolute(t.createDivWithClass("ge-table-overlay",e)),t.setAriaHidden(this.element),t.applyDisplayNoneStyle(this.element),this.contentElement=t.createDivWithClass("ge-table-overlay-content",this.element)}showLoading(e){var o;if(this.destroyed)return;const t=((o=this.manual)==null?void 0:o.kind)==="loading";this.manual={kind:"loading",text:e};const s=this.options.loadingDelayInMs;!t&&s>0&&!this.delayTimeout&&(this.delayTimeout=setTimeout(()=>{this.delayTimeout=void 0,this.requestUpdate()},s)),this.requestUpdate()}showNoRows(e){this.destroyed||(this.clearDelay(),this.manual={kind:"noRows",text:e},this.requestUpdate())}hide(){this.destroyed||!this.manual||(this.clearDelay(),this.manual=void 0,this.requestUpdate())}getState(){return this.shownKind}isBlocking(){return this.shownBlocking}isEventBlocked(e){const t=e.target;return this.shownBlocking&&t instanceof Node&&this.element.contains(t)}update(e,t){var a;if(this.destroyed)return;const s=this.options.autoNoRows,o=this.delayTimeout?Oi({rowCount:e,unfilteredRowCount:t,autoNoRows:s}):Oi({manual:(a=this.manual)==null?void 0:a.kind,rowCount:e,unfilteredRowCount:t,autoNoRows:s}),i=this.getText(o),r=o==="loading"&&this.options.blockInteractionWhileLoading;if(o===this.shownKind&&i===this.shownText&&r===this.shownBlocking)return;const l=this.shownKind;return this.render(o,i,r),{previous:l,kind:o,text:i}}setBounds(e,t,s,o){const i=`${e},${t},${s},${o}`;this.destroyed||i===this.bounds||(this.bounds=i,this.dom.applyStyle(this.element,{left:`${e}px`,top:`${t}px`,width:`${Math.max(0,s)}px`,height:`${Math.max(0,o)}px`}))}destroy(){this.destroyed||(this.destroyed=!0,this.clearDelay(),this.contentElement.replaceChildren(),this.element.remove(),this.manual=void 0,this.shownKind="none",this.shownBlocking=!1)}getText(e){var s,o;const t=this.options;switch(e){case"loading":return((s=this.manual)==null?void 0:s.text)??t.loadingText;case"noRows":return(((o=this.manual)==null?void 0:o.kind)==="noRows"?this.manual.text:void 0)??t.noRowsText;case"noMatches":return t.noMatchesText;default:return""}}render(e,t,s){const o=this.dom,i=this.element;if(this.shownKind!=="none"&&o.removeClass(bn[this.shownKind],i),this.contentElement.replaceChildren(),e==="none")o.removeClass("ge-table-overlay-visible",i),o.applyDisplayNoneStyle(i);else{o.addClass(`ge-table-overlay-visible ${bn[e]}`,i),o.setStyle(i,"display","flex");const r=this.getOwnElement(e,t);if(r)o.domService.appendChild(this.contentElement,r);else{e==="loading"&&o.createDivWithClass("ge-table-spinner",this.contentElement);const l=o.createDivWithClass("ge-table-overlay-text",this.contentElement);l.textContent=t}}s?o.addClass("ge-table-overlay-blocking",i):o.removeClass("ge-table-overlay-blocking",i),this.shownKind=e,this.shownText=t,this.shownBlocking=s}getOwnElement(e,t){var s,o;try{return(o=(s=this.options).getOverlayElement)==null?void 0:o.call(s,e,t)}catch(i){console.error("TableOverlay: getOverlayElement failed, the built-in content is shown",i);return}}clearDelay(){this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=void 0)}}function Hl(n,e){var s,o,i;if(n==="rtl")return"rtl";if(n!=="auto"||!e)return"ltr";if(e.isConnected&&typeof getComputedStyle=="function"){const r=getComputedStyle(e).direction;if(r==="rtl"||r==="ltr")return r}return((i=(o=(s=e.closest)==null?void 0:s.call(e,"[dir]"))==null?void 0:o.getAttribute("dir"))==null?void 0:i.toLowerCase())==="rtl"?"rtl":"ltr"}function Wl(n,e){const t=n.scrollLeft;return e?Math.max(0,-t):t}function Gl(n,e,t){n.scrollLeft=t?-e:e}function kr(n,e){return e&&n!==0?-n:n}function Ul(n,e,t){if(!e)return!1;const s=n.scrollWidth-n.clientWidth;return s<=0?!1:t?e>0?n.scrollLeft<0:n.scrollLeft>-s+1:e>0?n.scrollLeft+n.clientWidth<n.scrollWidth-1:n.scrollLeft>0}function Kl(n,e,t,s){return s?e+t-n:n-e}function zl(n){return n.split(" ").map(e=>e==="left"?"right":e==="right"?"left":e).join(" ")}const ko=class ko{constructor(e,t,s,o){this.hostElement=e,this.tableModel=t,this.dom=s,this.tableOptions=o,this.scrollTop=0,this.horizontalScrollBarHeight=0,this.verticalScrollBarWidth=0,this.areaBodyWestGeo=new Ke,this.areaBodyCenterGeo=new Ke,this.areaBodyEastGeo=new Ke,this.hostAttributesBefore=new Map;const i=this.hostElement;i.innerText="",this.direction=Hl(o==null?void 0:o.direction,i),this.dom.setDirection(this.direction),this.dom.setAttribute(i,"tabindex","0"),this.ariaIds=new $s($s.createPrefix(i.id)),this.initHostAria(),this.setHostAriaAttribute("dir",this.direction),this.dom.setStyle(this.dom.addClass("ge-table",i),"position","relative"),this.hoverRow=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-row",i)),this.hoverColumn=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-column",i)),this.draggingColumn=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-dragging-column",i)),this.areaHeaderWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-west",i,"header","west"))),this.areaHeaderCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-center",i,"header","center"))),this.areaHeaderEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-east",i,"header","east"))),this.areaBodyWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-west",i,"body","west"))),this.areaBodyEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-east",i,"body","east"))),this.areaFooterWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-west",i,"footer","west"))),this.areaFooterCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-center",i,"footer","center"))),this.areaFooterEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-east",i,"footer","east"))),this.scrollViewport=s.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",s.applyStyleNoPadding(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-scroll-viewport",i,"body","center")))),this.contentWrapperDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),s.applyStyle(this.contentDiv,{position:"sticky",top:"0",left:"0"}),this.areaBodyCenter=s.appendRelativeChildDiv(s.createDivWithClass("ge-table-body-center",this.contentDiv));const r=(a,c)=>a?s.applyStylePosistionAbsolute(s.createDivWithClass(c,i)):void 0;this.borderHeaderBottom=r(o==null?void 0:o.headerSeparatorBorderVisible,"ge-table-header-border"),this.borderFixedWest=r(o==null?void 0:o.fixedWestSeparatorBorderVisible,"ge-table-west-fixed-column-border"),this.borderFixedEast=r(o==null?void 0:o.fixedEastSeparatorBorderVisible,"ge-table-east-fixed-column-border"),this.borderFooterTop=r(o==null?void 0:o.footerSeparatorBorderVisible,"ge-table-footer-border"),[this.hoverRow,this.hoverColumn,this.draggingColumn,this.borderHeaderBottom,this.borderFixedWest,this.borderFixedEast,this.borderFooterTop].forEach(a=>{a&&s.setAriaHidden(a)}),o!=null&&o.shortcutActionsDisabled||s.setAttribute(this.scrollViewport,"tabindex","-1"),[this.areaHeaderWest,this.areaHeaderCenter,this.areaHeaderEast,this.areaBodyWest,this.areaBodyEast,this.areaFooterWest,this.areaFooterCenter,this.areaFooterEast,this.areaBodyCenter].forEach(a=>s.setAttribute(a.parent,"role","presentation")),s.setAttribute(this.contentWrapperDiv,"role","presentation"),s.setAttribute(this.contentDiv,"role","presentation");const l=[];for(const a of["header","body","footer"])for(const c of["west","center","east"]){const h=this.ariaIds.rowGroup(a,c),d=this.getAreaChild(a,c);s.setAttribute(d,"id",h),s.setAttribute(d,"role","presentation"),l.push(h)}this.setHostAriaAttribute("aria-owns",l.join(" ")),this.tableOverlay=new $l(i,s,o==null?void 0:o.overlayOptions,()=>this.updateOverlay())}isRtl(){return this.direction==="rtl"}getViewportScrollLeft(){return Wl(this.scrollViewport,this.isRtl())}setViewportScrollLeft(e){Gl(this.scrollViewport,e,this.isRtl())}clientXToHostX(e){const t=this.hostElement,s=t.getBoundingClientRect();return Kl(e,s.left+t.clientLeft,t.clientWidth,this.isRtl())}updateOverlay(){}setHostAriaAttribute(e,t){const s=this.hostElement;this.hostAttributesBefore.has(e)||this.hostAttributesBefore.set(e,s.getAttribute(e)),t===void 0?s.hasAttribute(e)&&this.dom.removeAttribute(s,e):s.getAttribute(e)!==t&&this.dom.setAttribute(s,e,t)}restoreHostAriaAttribute(e){const t=this.hostAttributesBefore.get(e)??null;t===null?this.hostElement.hasAttribute(e)&&this.dom.removeAttribute(this.hostElement,e):this.hostElement.getAttribute(e)!==t&&this.dom.setAttribute(this.hostElement,e,t)}removeHostAria(){this.hostAttributesBefore.forEach((e,t)=>{e===null?this.dom.removeAttribute(this.hostElement,t):this.dom.setAttribute(this.hostElement,t,e)}),this.hostAttributesBefore.clear()}initHostAria(){const e=this.tableOptions,t=ee(this.tableModel.getAreaModel("body"));this.setHostAriaAttribute("role",t?"treegrid":"grid"),e!=null&&e.ariaLabelledBy?this.setHostAriaAttribute("aria-labelledby",e.ariaLabelledBy):e!=null&&e.ariaLabel&&this.setHostAriaAttribute("aria-label",e.ariaLabel),e!=null&&e.ariaDescribedBy&&this.setHostAriaAttribute("aria-describedby",e.ariaDescribedBy)}getAreaChild(e,t){return{"header-west":this.areaHeaderWest,"header-center":this.areaHeaderCenter,"header-east":this.areaHeaderEast,"body-west":this.areaBodyWest,"body-center":this.areaBodyCenter,"body-east":this.areaBodyEast,"footer-west":this.areaFooterWest,"footer-center":this.areaFooterCenter,"footer-east":this.areaFooterEast}[`${e}-${t}`].child}adjustContainersAndRows(){this.layoutContainers(),this.adjustAfterScrolling()}layoutContainers(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,s=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${s-e.top}px`,top:`${e.top}px`,left:`${e.left}px`}),this.horizontalScrollBarHeight=this.measureHorizontalScrollBarHeight(),this.verticalScrollBarWidth=this.measureVerticalScrollBarWidth();const o=this.getLayoutWidth(),i=this.getLayoutHeight();this.scrollTop=this.scrollViewport.scrollTop,this.dom.applyStyle(this.contentDiv,{width:`${this.scrollViewport.clientWidth}px`,height:`${this.scrollViewport.clientHeight}px`}),this.areaBodyWestGeo.width=e.left,this.areaBodyWestGeo.height=i-e.top-e.bottom,this.areaBodyWestGeo.top=e.top,this.areaBodyWestGeo.left=0,this.dom.applyStyleInPx(this.areaBodyWest.parent,this.areaBodyWestGeo),this.borderFixedWest&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest,{width:"1px",height:`${this.areaBodyWestGeo.height}px`,top:`${this.areaBodyWestGeo.top}px`,left:`${this.areaBodyWestGeo.width}px`})):this.borderFixedWest&&this.dom.applyDisplayNoneStyle(this.borderFixedWest),this.areaBodyEastGeo.width=e.right,this.areaBodyEastGeo.height=i-e.top-e.bottom,this.areaBodyEastGeo.top=e.top,this.areaBodyEastGeo.left=o-e.right,this.dom.applyStyleInPx(this.areaBodyEast.parent,this.areaBodyEastGeo),this.borderFixedEast&&this.tableModel.getFixedRightColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast,{width:"1px",height:`${this.areaBodyEastGeo.height}px`,top:`${this.areaBodyEastGeo.top}px`,left:`${this.areaBodyEastGeo.left}px`})):this.borderFixedEast&&this.dom.applyDisplayNoneStyle(this.borderFixedEast),this.areaBodyCenterGeo.width=o-e.left-e.right,this.areaBodyCenterGeo.height=i-e.top-e.bottom,this.areaBodyCenterGeo.top=0,this.areaBodyCenterGeo.left=0,this.dom.applyStyleInPx(this.areaBodyCenter.parent,this.areaBodyCenterGeo),this.dom.applyStyle(this.areaHeaderCenter.parent,{width:`${o-e.left-e.right}px`,height:`${e.top}px`,top:"0",left:`${e.left}px`}),this.dom.applyStyle(this.areaHeaderWest.parent,{width:`${e.left}px`,height:`${e.top}px`,top:"0",left:"0"}),this.dom.applyStyle(this.areaHeaderEast.parent,{width:`${e.right}px`,height:`${e.top}px`,top:"0",left:`${o-e.right}px`}),this.borderHeaderBottom&&this.tableModel.isHeaderVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom,{width:`${o}px`,height:"1px",top:`${e.top}px`,left:"0px"})):this.borderHeaderBottom&&this.dom.applyDisplayNoneStyle(this.borderHeaderBottom),this.dom.applyStyle(this.areaFooterWest.parent,{width:`${e.left}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${o-e.left-e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${o-e.right}px`}),this.borderFooterTop&&this.tableModel.isFooterVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop,{width:`${o}px`,height:"1px",top:`${i-e.bottom}px`,left:"0px"})):this.borderFooterTop&&this.dom.applyDisplayNoneStyle(this.borderFooterTop),this.tableOverlay.setBounds(0,e.top,Math.min(o,e.left+this.scrollViewport.clientWidth),i-e.top-e.bottom),this.adjustDetailLayerBounds(0,e.top,Math.min(o,e.left+this.scrollViewport.clientWidth),Math.max(0,Math.min(i-e.top-e.bottom,this.scrollViewport.clientHeight)))}getLayoutHeight(){return Math.max(0,this.hostElement.clientHeight-this.horizontalScrollBarHeight)}getLayoutWidth(){return Math.max(0,this.hostElement.clientWidth-this.verticalScrollBarWidth)}measureHorizontalScrollBarHeight(){const e=this.scrollViewport;return Math.max(0,e.offsetHeight-e.clientHeight)}measureVerticalScrollBarWidth(){const e=this.scrollViewport;return Math.max(0,e.offsetWidth-e.clientWidth)}adjustDetailLayerBounds(e,t,s,o){}adjustAfterScrolling(){}getBodyContentHeight(){return this.tableModel.getContentHeightInPixel()}resetSizeOfWrapperDiv(){const e=`${this.tableModel.getContentWidthInPixel()}px`,t=this.getBodyContentHeight()+1,s=`${Math.min(t,ko.maxScrollHeightInPx)}px`;this.dom.setStyle(this.contentWrapperDiv,"width",e),this.dom.setStyle(this.contentWrapperDiv,"height",s)}};ko.maxScrollHeightInPx=8e6;let Hs=ko;class jl{constructor(e,t){this.tableModel=e,this.areaModel=t,this.colAndRowspanRanges=void 0,this.rowCountAtInit=-1}init(){if(this.rowCountAtInit=this.areaModel.getRowCount(),this.areaModel.getMaxColspan()<2&&this.areaModel.getMaxRowspan()<2){this.colAndRowspanRanges=void 0;return}this.colAndRowspanRanges=[];const e=this.areaModel.getRowCount();for(let t=0;t<e;t++)this.scanRow(t,this.colAndRowspanRanges)}scanRow(e,t){const s=this.tableModel.getColumnCount();for(let o=0;o<s;o++){let i=this.areaModel.getColspanAt(e,o),r=this.areaModel.getRowspanAt(e,o);if(i>1||r>1){i===0&&(i=1),r===0&&(r=1);const l="gammaCells"in this.areaModel;t.push(new M(e,o,e+r-1,o+i-1,l))}}}updateForInsertedRows(e){var s;if(this.rowCountAtInit<0||(s=this.colAndRowspanRanges)!=null&&s.length)return!1;const t=[];if(this.areaModel.getMaxColspan()>=2||this.areaModel.getMaxRowspan()>=2)for(let o=0;o<e.length;o++)this.scanRow(e[o],t);return this.colAndRowspanRanges=t.length?t:this.colAndRowspanRanges,this.rowCountAtInit=this.areaModel.getRowCount(),!0}initIfRowCountChanged(){return this.areaModel.getRowCount()===this.rowCountAtInit?!1:(this.init(),!0)}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const s of this.colAndRowspanRanges)if(s.isInRange(e,t))return!0}return!1}}class Yt{constructor(e,t,s,o,i=0){this.headerRowCount=e,this.bodyRowCount=t,this.footerRowCount=s,this.colIndexMap=o,this.filterRowCount=i}static create(e,t=0){var h,d,u;const s=e.isHeaderVisibe()?Math.max(0,((h=e.getAreaModel("header"))==null?void 0:h.getRowCount())??0):0,o=s>0?Math.max(0,t):0,i=e.isFooterVisibe()?Math.max(0,((d=e.getAreaModel("footer"))==null?void 0:d.getRowCount())??0):0,r=((u=e.getAreaModel("body"))==null?void 0:u.getRowCount())??0,l=e.getColumnCount(),a=new Array(Math.max(0,l));let c=0;for(let f=0;f<l;f++)a[f]=e.getColumnWidth(f)>0?++c:0;return new Yt(s,r,i,a,o)}get rowCount(){return this.bodyRowCount<0?-1:this.headerRowCount+this.filterRowCount+this.bodyRowCount+this.footerRowCount}get colCount(){let e=0;for(const t of this.colIndexMap)t>0&&e++;return e}filterRowIndex(){return this.filterRowCount>0?this.headerRowCount+1:0}rowIndex(e,t){return e==="header"?t+1:e==="body"?this.headerRowCount+this.filterRowCount+t+1:this.headerRowCount+this.filterRowCount+Math.max(0,this.bodyRowCount)+t+1}colIndex(e){return this.colIndexMap[e]??0}colSpan(e,t){let s=0;for(let o=e;o<e+t;o++)(this.colIndexMap[o]??0)>0&&s++;return Math.max(1,s)}}class Xl{constructor(){this.positions=new WeakMap,this.sizes=new WeakMap}get(e,t){const s=e.getRowByIndex(t);if(!s)return;const o=e.getFilteredFlattenRows();o!==this.displayedRows&&(this.displayedRows=o,this.positions=new WeakMap,this.sizes=new WeakMap);const i=s.parent??e;let r=this.positions.get(i);if(!r){const a=s.parent?e.getDisplayedChildren(s.parent):e.getDisplayedRootRows();r=new Map,a.forEach((c,h)=>r.set(c,h+1)),this.positions.set(i,r),this.sizes.set(i,a.length)}const l=e.hasDisplayedChildren(s);return{level:(s.deep??0)+1,setSize:Math.max(1,this.sizes.get(i)??1),posInSet:r.get(s)??1,expanded:l?!!s.expanded:void 0}}}class Yl{constructor(){this.rowCount=0,this.heightOf=()=>0,this.extraIndices=new Int32Array(0),this.extraHeights=new Float64Array(0),this.extraPrefix=new Float64Array(1)}setRows(e,t,s){if(this.rowCount=Math.max(0,Math.floor(e)||0),this.heightOf=t,this.constantHeight=s!==void 0&&s>0?s:void 0,this.prefix=void 0,this.extraIndices.length&&this.extraIndices[this.extraIndices.length-1]>=this.rowCount){const o=[],i=[];this.extraIndices.forEach((r,l)=>{r<this.rowCount&&(o.push(r),i.push(this.extraHeights[l]))}),this.setExtras(o,i)}}setExtras(e,t){const s=new Map;for(let i=0;i<e.length;i++){const r=e[i],l=t[i];r>=0&&r<this.rowCount&&l>0&&s.set(r,(s.get(r)??0)+l)}const o=Int32Array.from(s.keys()).sort();this.extraIndices=o,this.extraHeights=Float64Array.from(o,i=>s.get(i)),this.rebuildExtraPrefix()}setExtraHeight(e,t){const s=this.findExtra(e);return s<0||!(t>0)||this.extraHeights[s]===t?!1:(this.extraHeights[s]=t,this.rebuildExtraPrefix(),!0)}setExtra(e,t){if(!(e>=0&&e<this.rowCount))return!1;const s=this.findExtra(e);if(s>=0){if(t>0)return this.setExtraHeight(e,t);const l=Array.from(this.extraIndices),a=Array.from(this.extraHeights);return l.splice(s,1),a.splice(s,1),this.extraIndices=Int32Array.from(l),this.extraHeights=Float64Array.from(a),this.rebuildExtraPrefix(),!0}if(!(t>0))return!1;const o=this.countExtrasBelow(e),i=Array.from(this.extraIndices),r=Array.from(this.extraHeights);return i.splice(o,0,e),r.splice(o,0,t),this.extraIndices=Int32Array.from(i),this.extraHeights=Float64Array.from(r),this.rebuildExtraPrefix(),!0}getRowCount(){return this.rowCount}getExtraCount(){return this.extraIndices.length}hasPrefixSums(){return!!this.prefix}getRowHeight(e){if(this.constantHeight!==void 0)return this.constantHeight;const t=this.ensurePrefix();return e>=0&&e<this.rowCount?t[e+1]-t[e]:0}getExtraHeight(e){const t=this.findExtra(e);return t<0?0:this.extraHeights[t]}getExtraBefore(e){return this.extraPrefix[this.countExtrasBelow(e)]}getExtraTotal(){return this.extraPrefix[this.extraIndices.length]}getTop(e){const t=Math.min(Math.max(0,Math.floor(e)||0),this.rowCount);return this.getBaseTop(t)+this.extraPrefix[this.countExtrasBelow(t)]}getTotalHeight(){return this.getTop(this.rowCount)}findIndexAt(e){const t=this.rowCount;if(t<1)return-1;if(!(e>0))return 0;const s=this.constantHeight;if(s!==void 0&&!this.extraIndices.length){let r=Math.min(t-1,Math.floor(e/s));for(;r>0&&r*s>e;)r--;for(;r<t-1&&(r+1)*s<=e;)r++;return r}let o=0,i=t-1;for(;o<i;){const r=o+i>>>1;this.getTop(r+1)>e?i=r:o=r+1}return o}getBaseTop(e){return this.constantHeight!==void 0?e*this.constantHeight:this.ensurePrefix()[e]}ensurePrefix(){if(!this.prefix){const e=this.rowCount,t=new Float64Array(e+1);let s=0;for(let o=0;o<e;o++)s+=this.heightOf(o)||0,t[o+1]=s;this.prefix=t}return this.prefix}rebuildExtraPrefix(){const e=this.extraIndices.length,t=new Float64Array(e+1);for(let s=0;s<e;s++)t[s+1]=t[s]+this.extraHeights[s];this.extraPrefix=t}countExtrasBelow(e){const t=this.extraIndices;let s=0,o=t.length;for(;s<o;){const i=s+o>>>1;t[i]<e?s=i+1:o=i}return s}findExtra(e){const t=this.countExtrasBelow(e);return t<this.extraIndices.length&&this.extraIndices[t]===e?t:-1}}class ql extends Hs{constructor(e,t,s,o){var r,l,a,c,h;if(super(e,t,s,o),this.firstVisibleRowIndex=-1,this.lastVisibleRowIndex=-1,this.firstFullVisibleRowIndex=-1,this.lastFullVisibleRowIndex=-1,this.displayedRowCount=0,this.pixelLimitForFullVisible=5,this.loggingActive=!1,this.dragging=!1,this.editing=!1,this.storedColumnWidths=[],this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new fe,this.draggingTargetColumnIndex=-1,this.contentScrollTop=0,this.renderedScrollTop=Number.NaN,this.renderedBodyRows={count:0,first:0,offset:0,last:-1,atEnd:!0},this.renderedScrollLeft=Number.NaN,this.removables=[],this.treeAriaInfo=new Xl,this.ariaSelectionKind="none",this.renderedSpanCells=new Set,this.bodyRowLayout=new Yl,this.bodyRowLayoutDirty=!0,this.adjustingRowNumberWidth=!1,this.keyboardModality=!1,this.adjustingRelativeWidths=!1,this.relativeWidthsBase=-1,this.rowNumberRemeasureScheduled=!1,this.ariaTexts=Le.create(o==null?void 0:o.ariaTexts),(l=(r=this.tableModel).getSelectionModel)!=null&&l.call(r))this.getSelectionModel=()=>this.tableModel.getSelectionModel();else if((a=this.tableOptions)!=null&&a.getSelectionModel)this.getSelectionModel=this.tableOptions.getSelectionModel;else{const d=(c=this.tableOptions)!=null&&c.spreadsheet?new ke("range","multi"):new ke;this.getSelectionModel=()=>d}if((h=this.tableOptions)!=null&&h.getFocusModel)this.getFocusModel=this.tableOptions.getFocusModel;else{const d=new Mr("cell");this.getFocusModel=()=>d}ee(t.getAreaModel("body"))&&(this.tree=!0),["header","body","footer"].forEach(d=>{var u;this.colAndRowspanModels[d]=new jl(t,t.getAreaModel(d)),(u=this.colAndRowspanModels[d])==null||u.init()})}getDomService(){return this.dom}getBodyViewport(){const e=this.hostElement,t=e.getBoundingClientRect();return{top:t.top+e.clientTop+this.tableModel.getPadding().top,height:this.areaBodyCenterGeo.height,left:t.left+e.clientLeft,width:this.scrollViewport.clientWidth,contentScrollTop:this.contentScrollTop}}getBodyCellRectInHost(e,t){const s=this.tableModel,o=s.getBodyModel(),i=s.getPadding(),r=this.getLayoutWidth(),l=this.getLayoutHeight(),a=i.top+this.getBodyRowTop(e)-this.contentScrollTop,c=this.getColumnLeftInHost(t,s.getXPosByColumnIndex(t)),h=s.getColumnCount(),d=s.getFixedLeftColumnCount(),u=s.getFixedRightColumnCount();let f=i.left,p=r-i.right;return t<d?(f=0,p=i.left):u>0&&t>=h-u&&(f=r-i.right,p=r),{left:c,top:a,width:s.getColumnWidth(t),height:o.getRowHeight(e),clipLeft:f,clipRight:p,clipTop:i.top,clipBottom:l-i.bottom}}getBodyCellAtHostPoint(e,t){const s=this.tableModel,i=s.getBodyModel().getRowCount(),r=s.getColumnCount();if(i<1||r<1)return[-1,-1];const l=s.getPadding(),a=this.getLayoutWidth(),c=this.getLayoutHeight()-l.top-l.bottom,h=Math.min(Math.max(t-l.top,0),Math.max(0,c-1))+this.contentScrollTop,d=this.getBodyRowIndexAtY(h),u=s.getFixedLeftColumnCount(),f=s.getFixedRightColumnCount();let p,g,m;if(u>0&&e<l.left)[p,g,m]=[0,u-1,e];else if(f>0&&e>=a-l.right){const w=r-f;[p,g,m]=[w,r-1,e-(a-l.right)+s.getXPosByColumnIndex(w)]}else{const w=a-l.right,y=Math.min(Math.max(e,l.left),Math.max(l.left,w-1));[p,g,m]=[u,r-f-1,y+this.getContentScrollLeft()]}let b=g;for(let w=p;w<=g;w++)if(m<s.getXPosByColumnIndex(w)+s.getColumnWidth(w)){b=w;break}return[d,Math.min(r-1,Math.max(p,b))]}getBodyRowLayout(){var o,i;const e=this.tableModel.getBodyModel(),t=e.getRowCount(),s=this.bodyRowLayout;if(this.bodyRowLayoutDirty||this.bodyRowLayoutModel!==e||s.getRowCount()!==t){this.bodyRowLayoutDirty=!1,this.bodyRowLayoutModel=e;const r=this.tableModel;s.setRows(t,a=>r.getRowHeight("body",a),(o=e.getConstantRowHeight)==null?void 0:o.call(e));const l=(i=this.masterDetailService)==null?void 0:i.computeExtras();s.setExtras((l==null?void 0:l.rowIndices)??[],(l==null?void 0:l.heights)??[])}return s}invalidateRowLayout(){this.bodyRowLayoutDirty=!0}setBodyRowExtra(e,t){const s=this.tableModel.getBodyModel();return this.bodyRowLayoutDirty||this.bodyRowLayoutModel!==s||this.bodyRowLayout.getRowCount()!==s.getRowCount()?!1:(this.bodyRowLayout.setExtra(e,t),!0)}hasBodyRowExtras(){var e;return!!((e=this.masterDetailService)!=null&&e.hasExpanded())&&this.getBodyRowLayout().getExtraCount()>0}getBodyRowTop(e){return this.getBodyRowLayout().getTop(e)}getBodyRowIndexAtY(e){return this.getBodyRowLayout().findIndexAt(e)}getScrollerToContentRatioY(){if(!this.isScrollHeightCapped())return 1;const e=this.getContentScrollRangeY(),t=this.getScrollerRangeY();return e>0&&t>0?t/e:1}isEditing(){var e;return this.editing||!!((e=this.cellEditorService)!=null&&e.isOpen())}getInCellEditorCell(){return this.editing&&this.editorRenderer&&(this.editorRendererRow??-1)>=0?[this.editorRendererRow,this.editorRendererColumn]:void 0}setEditorDraft(e,t,s){if(this.editing&&this.editorRendererRow===e&&this.editorRendererColumn===t){let o=null,i=null;try{o=s.selectionStart,i=s.selectionEnd}catch{}this.editorDraft={rowIndex:e,columnIndex:t,value:s.value,start:o,end:i}}}shiftEditorRow(e){if(this.editing&&this.editorRenderer&&(this.editorRendererRow??-1)>=0){const t=e.mapIndex(this.editorRendererRow);if(t<0){this.resetEditorRenderer();return}this.editorRendererRow=t}if(this.editorDraft){const t=e.mapIndex(this.editorDraft.rowIndex);this.editorDraft=t<0?void 0:{...this.editorDraft,rowIndex:t}}}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1,this.editorDraft=void 0}clearSelection(e=!1){if(this.getSelectionModel){const t=this.getSelectionModel();t==null||t.clear(),e&&this.repaint()}}initRenderEditor(e,t){var o;let s=(o=this.tableModel.getColumnDef(t))==null?void 0:o.getEditRenderer;if(s||(s=this.tableOptions.getEditRenderer),s)if(this.editorRenderer=s(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const i=this.hostElement.querySelector("input.ge-table-cell-editor-input");i&&i.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}invalidateAggregates(e){var t,s;e||this.invalidateRowLayout();for(const o of["header","body","footer"])(s=(t=this.tableModel.getAreaModel(o))==null?void 0:t.invalidateDerivedValues)==null||s.call(t,e)}repaintHard(e){var t;for(const s of["header","body","footer"])(t=this.colAndRowspanModels[s])==null||t.initIfRowCountChanged();this.tableModel.recalcHeightAndPadding(),this.invalidateRowLayout(),this.resetSizeOfWrapperDiv(),this.layoutContainers(),e&&this.setContentScrollPosition(e.px,e.py),this.adjustAfterScrolling()}rememberRenderedBodyRows(){const e=this.tableModel.getBodyModel().getRowCount();if(e<=0){this.renderedBodyRows={count:Math.max(0,e),first:0,offset:0,last:-1,atEnd:!0};return}const t=this.contentScrollTop,s=this.getBodyRowIndexAtY(t),o=this.getBodyRowIndexAtY(t+Math.max(0,this.areaBodyCenterGeo.height-1)),i=this.getContentScrollRangeY(),r=Math.max(1,this.tableModel.getRowHeight("body",e-1)/2);this.renderedBodyRows={count:e,first:s,offset:t-this.getBodyRowTop(s),last:o,atEnd:i<=0||t>=i-r}}updateRowCountWithoutRender(e){for(const s of["header","body","footer"]){const o=this.colAndRowspanModels[s];if(o==null||o.initIfRowCountChanged(),o!=null&&o.getRanges().length)return!1}const t=this.scrollViewport.clientWidth;return this.tableModel.recalcHeightAndPadding(),this.invalidateRowLayout(),this.resetSizeOfWrapperDiv(),this.layoutContainers(),this.scrollViewport.clientWidth!==t?!1:(this.setContentScrollPosition(void 0,e),this.renderedScrollTop=this.scrollViewport.scrollTop,this.scrollTop=this.scrollViewport.scrollTop,this.renderedBodyRows={...this.renderedBodyRows,count:this.tableModel.getBodyModel().getRowCount(),atEnd:!1},this.setHostAttribute("aria-rowcount",`${Yt.create(this.tableModel,this.getFilterRowCount()).rowCount}`),!0)}setContentScrollPosition(e,t){const s=this.scrollViewport,o={};if(e!==void 0&&(o.left=kr(e,this.isRtl())),t===void 0)return e!==void 0&&s.scrollTo(o),!1;const i=this.getContentScrollRangeY(),r=this.getScrollerRangeY();if(i>0&&r>0){const l=Math.min(i,Math.max(0,t));return o.top=l/i*r,s.scrollTo(o),this.pendingContentScroll={scrollTop:s.scrollTop,contentTop:l},!0}return o.top=t,s.scrollTo(o),!1}onViewportScroll(){this.scrollViewport.scrollTop===this.renderedScrollTop&&this.getViewportScrollLeft()===this.renderedScrollLeft||this.adjustAfterScrolling()}recalcColumnWidths(e){const t=this.getAvailableColumnWidth(e);t>0&&this.setParentWidth(t),this.tableModel.init(),this.repaintHard()}setParentWidth(e){this.relativeWidthsBase=e,this.tableModel.setParentWidth(e)}hasRelativeColumnWidths(){var e,t,s;return!!((s=(t=(e=this.tableModel).getColumnDefs)==null?void 0:t.call(e))!=null&&s.some(o=>{var i,r;return((i=o.width)==null?void 0:i.unit)==="weight"||((r=o.width)==null?void 0:r.unit)==="%"}))}layoutContainers(){super.layoutContainers(),this.adjustRelativeColumnWidthsToScrollBar()}adjustRelativeColumnWidthsToScrollBar(){if(this.adjustingRelativeWidths||!this.hasRelativeColumnWidths())return;const e=this.getAvailableColumnWidth();if(!(e<=0||e===this.relativeWidthsBase)){this.adjustingRelativeWidths=!0;try{this.setParentWidth(e),this.tableModel.init(),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.layoutContainers()}finally{this.adjustingRelativeWidths=!1}}}getAvailableColumnWidth(e=this.hostElement.clientWidth){const t=Math.max(0,this.scrollViewport.offsetWidth-this.scrollViewport.clientWidth);return Math.max(0,e-this.tableModel.getPadding().left-t)}adjustAfterScrolling(){var i,r,l,a;if(this.beforeRenderPass(),!this.adjustingRowNumberWidth&&this.adjustRowNumberColumnWidth()){this.adjustingRowNumberWidth=!0;try{if((l=(r=(i=this.tableModel).getColumnDefs)==null?void 0:r.call(i))!=null&&l.some(c=>{var h,d;return((h=c.width)==null?void 0:h.unit)==="weight"||((d=c.width)==null?void 0:d.unit)==="%"})){this.tableModel.recalcPadding();const c=this.getAvailableColumnWidth();c>0&&(this.setParentWidth(c),this.tableModel.init())}this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}finally{this.adjustingRowNumberWidth=!1}return}for(const c of this.removables)c.remove();if(this.hideHoverRow(),this.hideHoverColumn(),this.scrollTop=this.scrollViewport.scrollTop,this.scrollLeft=this.getViewportScrollLeft(),this.scrollViewportLeft=this.scrollLeft,this.scrollFactorY=this.scrollTop/(this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight),this.scrollFactorX=this.scrollLeft/(this.scrollViewport.scrollWidth-this.scrollViewport.clientWidth),isNaN(this.scrollFactorY)&&(this.scrollFactorY=0),this.pendingContentScroll){const c=this.getContentScrollRangeY();Math.abs(this.scrollTop-this.pendingContentScroll.scrollTop)<=1&&c>0?this.scrollFactorY=Math.min(1,Math.max(0,this.pendingContentScroll.contentTop/c)):this.pendingContentScroll=void 0}isNaN(this.scrollFactorX)&&(this.scrollFactorX=0);const e=this.hostElement.clientWidth,t=this.hostElement.clientHeight,s=this.areaBodyWest.child.clientWidth,o=this.areaHeaderCenter.child.clientHeight;this.areaHeightsOfRenderPass={body:this.areaBodyCenter.child.clientHeight,footer:this.areaFooterCenter.child.clientHeight,header:o},this.ariaGridInfo=Yt.create(this.tableModel,this.getFilterRowCount()),this.ariaSelectionKind=this.getAriaSelectionKind(),this.ariaFocusedCell=void 0,this.renderedSpanCells.clear();try{this.adjustBody(),this.adjustArea("footer"),this.adjustArea("header")}finally{this.areaHeightsOfRenderPass=void 0}this.updateHostAria(),this.tableOptions.tableTopBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new Ke(0,e,1,0),this.hostElement,"ge-table-border")),this.tableOptions.tableBottomBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new Ke(0,e,1,t-1),this.hostElement,"ge-table-border")),this.tableModel.getFixedLeftColumnCount()>0&&this.tableOptions.fixedWestSeparatorBorderVisible!==!1&&this.removables.push(this.dom.addVerticalBorder(new Ke(s,1,t,0),this.hostElement,"ge-table-body-west-vertical-border")),this.tableModel.isHeaderVisibe()&&this.tableOptions.headerSeparatorBorderVisible!==!1&&this.removables.push(this.dom.addHorizontalBorder(new Ke(0,e,1,o),this.hostElement,"ge-table-body-west-vertical-border")),this.updateOverlay(),(a=this.rowNumberWidth)!=null&&a.approximate&&!this.rowNumberRemeasureScheduled&&this.findRowNumberLabel()&&(this.rowNumberRemeasureScheduled=!0,requestAnimationFrame(()=>{this.hostElement.isConnected&&this.repaint()})),this.rememberRenderedBodyRows(),this.afterRenderPass(),this.renderedScrollTop=this.scrollTop,this.renderedScrollLeft=this.scrollLeft}afterRenderPass(){}updateOverlay(){var r;const e=this.tableOverlay;if(!e)return;const t=this.tableModel.getBodyModel(),s=t.getRowCount(),o=s===0?(r=t.getUnfilteredRowCount)==null?void 0:r.call(t):void 0,i=e.update(s,o);i&&this.onOverlayChanged(i)}onOverlayChanged(e){}checkForScrollPosSaving(){this.afterRenderPass()}updateCells(e,t=!1){const s=this.tableModel.getBodyModel(),o=s.getRowCount(),i=this.tableSheet,r=()=>e.forEach(c=>{i&&c.area==="body"&&i.isFormulaInput(c.columnIndex,c.value)?this.setRawValue(c.rowIndex,c.columnIndex,c.value):this.tableModel.getAreaModel(c.area).setValue(c.rowIndex,c.columnIndex,c.value),!t&&!(i&&c.area==="body")&&this.rerenderCellContent(c)}),l=ge(s)?s.batch(r):(r(),!1),a=this.tableSheet?e.filter(c=>c.area==="body"):[];if(a.length&&(this.tableSheet.cellsWritten(a.map(c=>({row:void 0,rowIndex:c.rowIndex,columnIndex:c.columnIndex,property:"",oldValue:void 0,newValue:c.value}))),t=!0),l){this.invalidateAggregates(),this.repaintHard();return}if(e.length){const c=e[0].area;this.invalidateAggregates(e.every(h=>h.area===c)?{area:c,rowIndices:e.map(h=>h.rowIndex)}:void 0)}e.length&&s.getRowCount()!==o?this.repaintHard():t?this.repaint():e.length&&(this.rerenderDerivedFooterCells(e),this.rerenderGroupRowCells(),this.rerenderCalculatedCells())}setRawValue(e,t,s){const o=this.tableModel.getBodyModel(),i=this.tableModel.getColumnDef(t),r=i==null?void 0:i.editInputPipe;if(!i||!r||Object.isFrozen(i))return o.setValue(e,t,s);i.editInputPipe=void 0;try{return o.setValue(e,t,s)}finally{i.editInputPipe=r}}rerenderCalculatedCells(){var o;const e=this.tableModel.getBodyModel();if(!((o=e.hasDerivedColumns)!=null&&o.call(e)))return;const t=new Map;this.hostElement.querySelectorAll('div.ge-table-col-div[data-area="body"][data-row-index][data-col-index]').forEach(i=>{var a,c;const r=Number(i.getAttribute("data-row-index")),l=Number(i.getAttribute("data-col-index"));if(!t.has(l)){const h=(a=this.tableModel.getColumnDef(l))==null?void 0:a.property;t.set(l,h!==void 0&&!!((c=e.isDerivedProperty)!=null&&c.call(e,h)))}t.get(l)&&this.rerenderCellContent({area:"body",rowIndex:r,columnIndex:l,value:e.getValueAt(r,l)??""})})}rerenderGroupRowCells(){const e=this.tableModel.getBodyModel();if(!ge(e))return;this.hostElement.querySelectorAll('div.ge-table-col-div[data-area="body"][data-row-index][data-col-index]').forEach(s=>{const o=Number(s.getAttribute("data-row-index")),i=Number(s.getAttribute("data-col-index"));!e.isGroupRowIndex(o)||!e.getCellRenderer(o,i)||this.rerenderCellContent({area:"body",rowIndex:o,columnIndex:i,value:e.getValueAt(o,i)})})}rerenderDerivedFooterCells(e){const t=this.tableModel.getAreaModel("footer");if(!(t!=null&&t.invalidateDerivedValues)||e.every(o=>o.area==="footer"))return;this.hostElement.querySelectorAll('div.ge-table-col-div[data-area="footer"][data-row-index][data-col-index]').forEach(o=>{const i=Number(o.getAttribute("data-row-index")),r=Number(o.getAttribute("data-col-index"));this.rerenderCellContent({area:"footer",rowIndex:i,columnIndex:r,value:t.getValueAt(i,r)})})}rerenderCellContent({area:e,rowIndex:t,columnIndex:s,value:o,cssClasses:i}){const r=this.tableModel.getAreaModel(e),l='div[data-col-index="'+s+'"][data-row-index="'+t+'"][data-area="'+e+'"]',a=this.hostElement.querySelector(l);if(a){let c;const h=e==="body"&&this.editorRenderer&&this.editorRendererRow===t&&this.editorRendererColumn===s;let d;if(h?d=this.editorRenderer:d=r.getCellRenderer(t,s),a.innerText="",this.applyCssClasses(a,i),d)c=d.render(a,t,s,e,r,o,this.dom.domService),c&&this.cleanupFunctions[e].push(c);else{const p=`${o}`;this.dom.addLabelDiv(a,p,!1,t,s,e)}const u=r.getCustomClassesAt(t,s);u.length&&this.dom.addClasses(u,a);const f=r.getCustomStyleAt(t,s);if(f)for(const p in f)this.dom.domService.setStyle(a,p,f[p])}}getFirstVisibleRowIndex(){return this.firstVisibleRowIndex}getLastVisibleRowIndex(){return this.lastVisibleRowIndex}getFirstFullVisibleRowIndex(){return this.firstFullVisibleRowIndex}getLastFullVisibleRowIndex(){return this.lastFullVisibleRowIndex}getDisplayedRowCount(){return this.displayedRowCount}storeColumnWidths(){const e=this.tableModel.getColumnDefs();e!=null&&e.length&&(this.storedColumnWidths=e.map((t,s)=>this.tableModel.getColumnWidth(s)))}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),s=this.getStringByAttr(e,"data-side");if(s&&t)return[t,s]}return[void 0,void 0]}getArea(e,t){if(e==="header"){if(t==="west")return this.areaHeaderWest;if(t==="center")return this.areaHeaderCenter;if(t==="east")return this.areaHeaderEast}else if(e==="body"){if(t==="west")return this.areaBodyWest;if(t==="center")return this.areaBodyCenter;if(t==="east")return this.areaBodyEast}else if(e==="footer"){if(t==="west")return this.areaFooterWest;if(t==="center")return this.areaFooterCenter;if(t==="east")return this.areaFooterEast}throw Error(`Wrong area identifier: row:${e}, col:${t}`)}snapToDevicePixel(e){const t=typeof window<"u"&&window.devicePixelRatio||1;return Math.round(e*t)/t}isScrollHeightCapped(){return this.getBodyContentHeight()+1>Hs.maxScrollHeightInPx}adjustDetailLayerBounds(e,t,s,o){var i;(i=this.masterDetailService)==null||i.setBounds(e,t,s,o)}getBodyContentHeight(){var t;const e=this.tableModel.getContentHeightInPixel();return(t=this.masterDetailService)!=null&&t.hasExpanded()?e+this.getBodyRowLayout().getExtraTotal():e}getContentScrollRangeY(){return this.getBodyContentHeight()-this.areaBodyCenterGeo.height}getScrollerRangeY(){return this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight}onWheel(e){if(e.ctrlKey||!this.isScrollHeightCapped())return;const t=this.getContentScrollRangeY(),s=this.getScrollerRangeY();if(t<=0||s<=0)return;const o=s/t,i=e.deltaMode===1?16:e.deltaMode===2?this.scrollViewport.clientHeight:1;e.preventDefault(),e.deltaY&&(this.scrollViewport.scrollTop+=e.deltaY*i*o),e.deltaX&&(this.scrollViewport.scrollLeft+=e.deltaX*i)}adjustBody(){const e=this.areaBodyCenterGeo.height-this.getBodyContentHeight(),t=this.snapToDevicePixel(this.scrollFactorY*e);this.contentScrollTop=-t,this.adjustArea("body",t)}getNumberByAttr(e,t){var s;if(e){const o=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(o)return Number(o)}return-1}getStringByAttr(e,t){var s;if(e){const o=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(o)return o}return""}adjustArea(e,t=0){var C,S,x,R,I;const s=this.getArea(e,"west"),o=this.getArea(e,"center"),i=this.getArea(e,"east"),r=((C=this.areaHeightsOfRenderPass)==null?void 0:C[e])??o.child.clientHeight;s.child.innerText="",o.child.innerText="",i.child.innerText="";const l=0,a=this.areaBodyCenterGeo.width,c=this.tableModel.getPadding(),h=this.tableModel.getAreaModel(e),d=h.getRowCount();for(;this.cleanupFunctions[e].length;){const A=this.cleanupFunctions[e].shift();A&&A()}if(e==="header"&&!this.tableModel.isHeaderVisibe()||e==="footer"&&!this.tableModel.isFooterVisibe()){this.updateRowGroupRoles(s,o,i);return}let u=t;const f=this.tableModel.getColumnCount(),p=this.tableModel.getFixedRightColumnCount(),g=this.tableModel.getFixedLeftColumnCount();e==="body"&&(this.firstVisibleRowIndex=-1,this.firstFullVisibleRowIndex=-1,this.lastVisibleRowIndex=-1,this.lastFullVisibleRowIndex=-1,this.displayedRowCount=0);let m=0;const b=e==="body"?this.getBodyRowLayout():void 0,w=!!b&&b.getExtraCount()>0,y=[];if(b)(S=this.masterDetailService)==null||S.startRenderPass(),u<0&&d>0&&(m=b.findIndexAt(-u),u=u+b.getTop(m));else{const A=(x=h.getConstantRowHeight)==null?void 0:x.call(h);if(A!==void 0&&A>0&&u<0){for(m=Math.min(d,Math.floor(-u/A));m>0&&u+m*A>0;)m--;u=u+m*A}}for(let A=m;A<d;A++){const T=u,F=A===d-1,P=this.tableModel.getRowHeight(e,A),O=w?b.getExtraHeight(A):0;if(O>0&&T+P+O>0&&y.push(A,T+P,O),T+P>0){e==="body"&&this.firstVisibleRowIndex===-1&&(this.firstVisibleRowIndex=A,this.firstFullVisibleRowIndex=T<-this.pixelLimitForFullVisible?this.firstVisibleRowIndex+1:this.firstVisibleRowIndex);let N={left:l,width:a,height:P,top:T,index:A},K=this.dom.addRowDiv(o,N,A,e,"center");this.applyRowAria(K,e,h,A);const Y=[K],U=g;this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:h,geo:N,parent:K,rowIndex:A,columnIndexStart:U,columnIndexEnd:f-p-1,verticalFixed:!1,lastRowOfModel:F}),c.left>0&&(N={left:l,width:this.areaBodyWestGeo.width,height:P,top:T,index:A},K=this.dom.addRowDiv(s,N,A,e,"west"),this.applyRowAria(K,e,h,A),Y.push(K),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:h,geo:N,parent:K,rowIndex:A,columnIndexStart:0,columnIndexEnd:U-1,verticalFixed:!0,lastRowOfModel:F})),c.right>0&&(N={left:l,width:this.areaBodyEastGeo.width,height:P,top:T,index:A},K=this.dom.addRowDiv(i,N,A,e,"east"),this.applyRowAria(K,e,h,A),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:h,geo:N,parent:K,rowIndex:A,columnIndexStart:f-p,columnIndexEnd:f-1,verticalFixed:!0,lastRowOfModel:F}));const $=e==="header"&&this.tree&&A===d-1?this.findCellDiv(Y,this.getTreeArrowColumnIndex()):void 0;if($!=null&&$.parentElement){const me=this.dom.getInlineStart($)+16,te=this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv($.parentElement,new Ke(me,20,20,8)),"data-ge-action","toggleExpandCollapseAll"),{cursor:"pointer"}),le=this.tableOptions.treeOptions.arrowExpandCollapseAll;if(le){const Te=this.dom.domService.createText(le.content);this.dom.domService.appendChild(te,Te),le.style&&this.dom.applyStyleString(te,le.style)}}}if(u=u+P+O,u>r){if(e==="body"){const N=u-O;N<=0&&this.firstVisibleRowIndex===-1?this.displayedRowCount=0:(this.lastVisibleRowIndex=A,this.lastFullVisibleRowIndex=r-N<-this.pixelLimitForFullVisible?A-1:A,this.displayedRowCount=this.lastFullVisibleRowIndex-this.firstFullVisibleRowIndex+1)}break}}if(b&&((R=this.masterDetailService)==null||R.layoutVisible(y)),e==="body"&&this.firstVisibleRowIndex>-1&&this.lastVisibleRowIndex===-1&&(this.lastVisibleRowIndex=d-1,this.lastFullVisibleRowIndex=d-1,this.displayedRowCount=this.lastFullVisibleRowIndex-this.firstFullVisibleRowIndex+1),this.loggingActive&&e==="body"&&console.log("render scope: this.firstVisibleRowIndex <- "+this.firstVisibleRowIndex+`
45
45
  render scope: this.firstFullVisibleRowIndex <- `+this.firstFullVisibleRowIndex+`
46
46
  render scope: this.lastVisibleRowIndex <- `+this.lastVisibleRowIndex+`
47
- render scope: this.lastFullVisibleRowIndex <- `+this.lastFullVisibleRowIndex),this.pruneRowDivCache(s),this.pruneRowDivCache(o),this.pruneRowDivCache(i),this.colAndRowspanModels&&this.colAndRowspanModels[e]){const A=((I=this.colAndRowspanModels[e])==null?void 0:I.getRanges())??[];if(A.length)for(const T of A){if(T.r1>=d||T.c1>=f)continue;let F=0,P=o.child,O="center";if(T.c1<g)P=s.child,O="west";else if(p>0&&T.c1>=f-p)P=i.child,O="east";else{const N=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();F=this.snapToDevicePixel(this.scrollFactorX*N)-this.areaBodyWestGeo.width,O="center"}this.drawBigCell(T,F,t,h,P,O)}}this.updateRowGroupRoles(s,o,i)}getFilterRowCount(){return 0}getAriaGridInfo(){return this.ariaGridInfo||(this.ariaGridInfo=Yt.create(this.tableModel,this.getFilterRowCount())),this.ariaGridInfo}applyRowAria(e,t,s,o,i=!0){var l,a;const r=this.dom.domService;if(r.setAttribute(e,"role","row"),r.setAttribute(e,"aria-rowindex",`${this.getAriaGridInfo().rowIndex(t,o)}`),!(t!=="body"||!i)){if(this.tree&&ee(s)){const c=this.treeAriaInfo.get(s,o);c&&(r.setAttribute(e,"aria-level",`${c.level}`),r.setAttribute(e,"aria-setsize",`${c.setSize}`),r.setAttribute(e,"aria-posinset",`${c.posInSet}`),c.expanded===void 0?this.dom.removeAttribute(e,"aria-expanded"):r.setAttribute(e,"aria-expanded",`${c.expanded}`))}if((l=this.masterDetailService)!=null&&l.isActive()&&(this.masterDetailService.isMasterAt(o)?r.setAttribute(e,"aria-expanded",`${this.masterDetailService.isExpandedAt(o)}`):e.hasAttribute("aria-expanded")&&this.dom.removeAttribute(e,"aria-expanded")),this.ariaSelectionKind==="row"){const c=(a=this.getSelectionModel)==null?void 0:a.call(this);r.setAttribute(e,"aria-selected",c&&c.getSelectionCount(o,0)>0?"true":"false")}else e.hasAttribute("aria-selected")&&this.dom.removeAttribute(e,"aria-selected")}}applyCellAria(e,t,s,o,i){var f,p;const r=this.dom.domService,l=this.getAriaGridInfo(),a=t==="header",c=t==="body"&&G(this.tableModel.getColumnDef(i))||t==="footer"&&pl(s)&&s.isLabelCell(o,i)||t==="body"&&ge(s)&&s.isGroupLabelCell(o,i)||!a&&!!((f=s.isRowHeaderCell)!=null&&f.call(s,o,i));r.setAttribute(e,"role",a?"columnheader":c?"rowheader":"gridcell");const h=l.colIndex(i);h>0&&r.setAttribute(e,"aria-colindex",`${h}`);const d=Math.max(1,s.getRowspanAt(o,i)||1),u=Math.max(1,s.getColspanAt(o,i)||1);if(u>1&&r.setAttribute(e,"aria-colspan",`${l.colSpan(i,u)}`),d>1&&r.setAttribute(e,"aria-rowspan",`${d}`),(d>1||u>1)&&this.renderedSpanCells.add(`${t}:${o}:${i}`),a&&o+d>=l.headerRowCount&&u===1){const g=this.tableModel.getColumnDef(i);if((p=g==null?void 0:g.sortable)!=null&&p.call(g)){const m=g.sortState;r.setAttribute(e,"aria-sort",m==="asc"?"ascending":m==="desc"?"descending":"none")}}return[d,u]}updateRowGroupRoles(...e){for(const t of e){let s=0;for(const i of Array.from(t.child.children)){if(!i.classList.contains("ge-table-row-div")||i.classList.contains("ge-table-span-row")){i.getAttribute("role")==="row"&&s++;continue}i.querySelector(':scope > [role="gridcell"], :scope > [role="columnheader"], :scope > [role="rowheader"]')?s++:i.getAttribute("role")==="row"&&(this.dom.domService.setAttribute(i,"role","presentation"),this.dom.removeAttribute(i,"aria-rowindex"))}const o=t.child.firstElementChild&&s?"rowgroup":"presentation";t.child.getAttribute("role")!==o&&this.dom.domService.setAttribute(t.child,"role",o)}}setHostAttribute(e,t){this.setHostAriaAttribute(e,t)}updateHostAria(){var i;const e=this.getAriaGridInfo();this.setHostAttribute("aria-rowcount",`${e.rowCount}`),this.setHostAttribute("aria-colcount",`${e.colCount}`);const t=(i=this.getSelectionModel)==null?void 0:i.call(this),s=this.ariaSelectionKind!=="none"&&(t==null?void 0:t.selectionMode)==="multi";this.setHostAttribute("aria-multiselectable",s?"true":void 0);const o=this.ariaFocusedCell;if(o){const r=this.ariaIds.cell(o.area,o.rowIndex,o.columnIndex);this.dom.domService.setAttribute(o.element,"id",r),this.setHostAttribute("aria-activedescendant",r)}else this.setHostAttribute("aria-activedescendant",void 0)}setAriaFocusedCell(e,t,s,o){const i=this.ariaFocusedCell;i&&i.area===t&&i.rowIndex===s&&i.columnIndex===o||(this.ariaFocusedCell={element:e,area:t,rowIndex:s,columnIndex:o})}getAriaSelectionKind(){var s;const e=(s=this.getSelectionModel)==null?void 0:s.call(this);if(!e)return"none";const t=e.selectionType;return t==="none"?"none":t==="row"?"row":"cell"}getColumnAriaLabel(e){const t=this.tableModel.getColumnDef(e);if(t!=null&&t.headerLabel)return`${t.headerLabel}`;const s=this.tableModel.getAreaModel("header"),o=(s==null?void 0:s.getRowCount())??0;if(o>0){const i=s.getValueAt(o-1,e),r=i&&typeof i=="object"&&"data"in i?i.data:i;if(typeof r=="string"&&r.trim()||typeof r=="number")return`${r}`}return(t==null?void 0:t.property)||`Column ${e+1}`}getCheckboxAriaLabel(e,t){return e==="header"?this.ariaTexts.selectAllRows():this.ariaTexts.selectRow(t+1)}labelControl(e,t){t&&!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&this.dom.domService.setAttribute(e,"aria-label",t)}labelRendererControls(e,t,s,o,i){if(hr(t)||e.classList.contains("ge-table-row-checkbox-div")){const l=e.querySelector("input.ge-table-row-checkbox");if(l){this.labelControl(l,this.getCheckboxAriaLabel(s,o));return}const a=e.querySelector("input.ge-input-checkbox");a&&this.labelControl(a,this.getColumnAriaLabel(i));return}const r=this.tableOptions.ariaTexts;if(s==="header"&&(r!=null&&r.expandGroup||r!=null&&r.collapseGroup)){const l=e.querySelector('.ge-table-toggle-icon-div[role="button"]');if(l){const a=l.getAttribute("data-ge-group-label")??"",c=l.getAttribute("aria-expanded")==="true";this.dom.domService.setAttribute(l,"aria-label",c?this.ariaTexts.collapseGroup(a):this.ariaTexts.expandGroup(a))}}}findCellDiv(e,t){for(const s of e){const o=s.querySelector(`:scope > .ge-table-col-div[data-col-index="${t}"]`);if(o)return o}}pruneRowDivCache(e){const t=e.cache;for(const s in t)t[s].parentNode!==e.child&&delete t[s]}drawBigCell(e,t,s,o,i,r){const l=s+(o.areaIdent==="body"?this.getBodyRowLayout().getTop(e.r1):this.getRowHeights(0,e.r1-1,o).reduce((w,y)=>w+y,0)),a=this.tableModel.getColumnCount(),c=this.tableModel.getFixedRightColumnCount();let h=0;c>0&&e.c1>=a-c&&(h=a-c);const d=t+this.getColumnWidths(h,e.c1-1).reduce((w,y)=>w+y,0),u=this.getRowHeights(e.r1,e.r2,o).reduce((w,y)=>w+y,0),f=this.getColumnWidths(e.c1,e.c2).reduce((w,y)=>w+y,0);let p=!1;const g=this.getSelectionModel?this.getSelectionModel():void 0;g&&(p=g.getSelectionCount(e.r1,e.c1)>0);const m=o.areaIdent,b=this.dom.applyStyle(this.dom.createDivWithClass("ge-table-span-row",i),{position:"absolute",left:"0",top:"0",width:"0",height:"0",overflow:"visible"});this.renderedSpanCells.has(`${m}:${e.r1}:${e.c1}`)?this.dom.setAriaHidden(b):this.applyRowAria(b,m,o,e.r1,!1),i=b,e.gammaRange?this.renderCell({areaModel:o,areaIdent:o.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:d,top:l,width:f,height:u,parent:i,cellSelected:p,lastRowOfModel:!0,gammaRange:e.gammaRange}):this.renderCell({areaModel:o,areaIdent:o.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:d,top:l,width:f,height:u,parent:i,cellSelected:p,lastRowOfModel:!0,gammaRange:e.gammaRange}),o.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.isColumnResizable(e.c1)&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:d,cellTop:l,cellWidth:f,cellHeight:u,parent:i})}findRowOfImportantRowspanCell(e,t,s){const o=e.getMaxRowspan();for(let i=t-1;i>-1;i--){const r=e.getRowspanAt(i,s);if(r>1&&i+r+1>=t)return i;if(t-i>o)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:s,geo:o,parent:i,rowIndex:r,columnIndexStart:l,columnIndexEnd:a,verticalFixed:c=!1,lastRowOfModel:h=!1}){var g;let d=0;if(!c){const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();d=this.snapToDevicePixel(this.scrollFactorX*m)}const u=0,f=!!(e==="body"&&t);let p=d;for(let m=l;m<=a;m++){const b=p,w=this.tableModel.getColumnWidth(m);if(w>0&&b+w>0){let y=o.height;const C=s.getRowspanAt(r,m),S=s.getColspanAt(r,m);C>1&&(y=this.getRowHeights(r,r+C-1,s).reduce((I,A)=>I+A,0));let x=w;S>1&&(x=this.getColumnWidths(m,m+S-1).reduce((I,A)=>I+A,0));let R=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(g=this.colAndRowspanModels[e])!=null&&g.isInRange(r,m)&&(R=!0),this.draggingTargetColumnIndex===m&&e!=="header"){this.renderDragTargetDiv(i,b,u,x,y);const I={left:b,top:u,width:x,height:y};this.dom.addColumnBorderDivs(this.tableOptions,i,I,e,t)}else{const I=this.renderSelectedBackgroundDiv(R,f,t,s,r,m,i,b,u,x,y);"gammaCells"in s&&s.getValueAt(r,m)&&(R=!1),R||this.renderCell({areaModel:s,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:m,left:b,top:u,width:x,height:y,parent:i,cellSelected:I,lastRowOfModel:h,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.isColumnResizable(m)&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:m,cellLeft:b,cellTop:u,cellWidth:x,cellHeight:y,parent:i})}}if(p=p+w,p>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new Ke(p-1,1,o.height,0),i)}getTreeArrowColumnIndex(){const e=this.getFirstDataColumnIndex();return this.tableOptions.showCheckboxWihoutExtraColumn?e:this.tableModel.isRowCheckboxVisible()?e+1:e}getFirstDataColumnIndex(){var e,t;return _s((t=(e=this.tableModel).getColumnDefs)==null?void 0:t.call(e))}isColumnResizable(e){var t;return((t=this.tableModel.getColumnDef(e))==null?void 0:t.resizable)!==!1}isColumnMovable(e){var t;return((t=this.tableModel.getColumnDef(e))==null?void 0:t.movable)!==!1}isFocusFrameVisible(){var t;const e=((t=this.tableOptions)==null?void 0:t.focusFrame)??"always";return e==="always"||e==="keyboard"&&this.keyboardModality}beforeRenderPass(){}adjustRowNumberColumnWidth(){var i,r;if(!this.getFirstDataColumnIndex()||this.tableModel.overridingColumnWidth>-1)return!1;const e=this.tableModel.getColumnDef(0),t=e.getWidestText(this.tableModel.getBodyModel()),s=this.rowNumberWidth;let o=(s==null?void 0:s.text)===t?s.width:-1;if(o<0||s!=null&&s.approximate&&this.findRowNumberLabel()){const[l,a]=this.measureRowNumberText(t);o=Math.max(e.options.minWidthInPx,l),this.rowNumberWidth={text:t,width:o,approximate:a}}return this.tableModel.getColumnWidth(0)===o||((r=(i=this.tableModel).isColumnVisible)==null?void 0:r.call(i,0))===!1?!1:(this.tableModel.setColumnWidth(0,o),this.tableModel.getColumnWidth(0)===o)}findRowNumberLabel(){return this.hostElement.querySelector(".ge-table-row-number .ge-table-label")}measureRowNumberText(e){const t=this.findRowNumberLabel(),s=getComputedStyle(t??this.hostElement),i=(t?(parseFloat(s.paddingLeft)||0)+(parseFloat(s.paddingRight)||0):12)+4,r=e.replace(/[0-9]/g,"0");let l=null;try{l=document.createElement("canvas").getContext("2d")}catch{l=null}return l?(l.font=s.font||`${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,[Math.ceil(l.measureText(r).width+i),!t]):[Math.ceil(e.length*8+i),!t]}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:o,index:i,left:r,width:l,height:a,top:c,parent:h,lastRowOfModel:d}){var $,me,te,le,Te;const u=t==="body"&&this.editorRenderer&&this.editorRendererRow===o&&this.editorRendererColumn===i,f=this.tableModel.getColumnDef(i),p=G(f),g=u?this.editorRenderer:(p&&t==="body"?f.rendererMap.body:void 0)??e.getCellRenderer(o,i),m={left:r,width:l,height:a,top:c,index:i},b=e.getRowByIndex(o);let w="none";if(i===this.getTreeArrowColumnIndex()&&J(b)){const H=b;("hasDisplayedChildren"in e&&typeof e.hasDisplayedChildren=="function"?e.hasDisplayedChildren(H):!!(($=H.children)!=null&&$.length))?H.expanded?w="expanded":w="collapsed":w="hidden"}let C;t==="header"&&(!(f!=null&&f.sortIconVisible)||f!=null&&f.sortIconVisible())&&(C=f==null?void 0:f.sortState);const S=t==="body"&&((me=this.batchEditService)!=null&&me.hasPending())?this.batchEditService.getPendingAt(o,i):void 0,x=S?S.newValue:e.getValueAt(o,i),R=g||p&&t==="footer"?"":`${x??""}`,I=e.isRowChecked(o),A=this.getFirstDataColumnIndex(),T=this.tableOptions.showCheckboxWihoutExtraColumn&&i===A&&I?this.getCheckboxAriaLabel(t,o):void 0,F=this.dom.addColumnDiv({parent:h,geo:m,rowIndex:o,columnIndex:i,areaIdent:t,sideIdent:s,text:R,treeArrow:w,tableOptions:this.tableOptions,checkedType:I,sortState:C,checkboxAriaLabel:T,firstDataColumnIndex:A}),[P,O]=this.applyCellAria(F,t,e,o,i),N=(S==null?void 0:S.error)||e.getTooltipAt(o,i);N&&this.dom.setAttribute(F,"title",N),S&&(this.dom.addClass("ge-table-cell-pending",F),S.error&&(this.dom.addClass("ge-table-cell-invalid",F),this.dom.setAttribute(F,"aria-invalid","true"))),f&&f.classes[t]&&this.dom.addClasses(f.classes[t],F);let K;if(g)if(K=g.render(F,o,i,t,e,x,this.dom.domService),u){const H=F.querySelector("input, select");if(H){this.labelControl(H,this.getColumnAriaLabel(i));const ae=this.editorDraft;if(ae&&ae.rowIndex===o&&ae.columnIndex===i&&H instanceof HTMLInputElement&&(H.value=ae.value,this.dom.setAttribute(H,"data-ge-restored","true")),H.contains(document.activeElement)||H.focus(),ae&&ae.rowIndex===o&&ae.columnIndex===i&&H instanceof HTMLInputElement&&ae.start!==null&&ae.end!==null)try{H.setSelectionRange(ae.start,ae.end)}catch{}}}else this.labelRendererControls(F,g,t,o,i);const Y=e.getCustomClassesAt(o,i);if(Y.length&&this.dom.addClasses(Y,F),t==="body"&&this.cellEditorService&&!p){e.isEditable(o,i)||this.dom.setAttribute(F,"aria-readonly","true");const H=this.cellEditorService.getOwnedEditorId(o,i);H&&this.dom.setAttribute(F,"aria-owns",H)}if(this.dom.addColumnBorderDivs(this.tableOptions,h,m,t,s),d&&this.dom.addHorizontalBorder({left:r,width:l,height:a,top:c+a},h),this.getFocusModel&&t==="body"&&!this.headerFocus){const H=this.getFocusModel();if(H!=null&&H.hasFocus(o,i))this.isFocusFrameVisible()&&this.dom.addFocusBorderDivs(h,m,{},!!((te=e.getTileLayout)!=null&&te.call(e))),this.setAriaFocusedCell(F,t,o,i);else if(H&&(P>1||O>1)){const[ae,je]=H.getFocus();ae>=o&&ae<o+P&&je>=i&&je<i+O&&this.setAriaFocusedCell(F,t,o,i)}}else t==="header"&&this.headerFocus&&this.headerFocus[0]===o&&this.headerFocus[1]===i&&(this.isFocusFrameVisible()&&this.dom.addFocusBorderDivs(h,m,{}),this.setAriaFocusedCell(F,t,o,i));t==="header"&&this.isColumnMovable(i)&&this.dom.setAttribute(F,"data-ge-action","drag-column"),t==="header"&&((le=this.columnFilterMenuService)!=null&&le.hasHeaderButtons())&&O===1&&o+P>=this.getAriaGridInfo().headerRowCount&&h.getAttribute("aria-hidden")!=="true"&&this.columnFilterMenuService.decorateHeaderCell(F,o,i),t==="body"&&((Te=this.masterDetailService)!=null&&Te.isActive())&&this.masterDetailService.decorateCell(F,o,i),t==="body"&&this.rowDragService&&!u&&(f!=null&&f.rowDrag&&this.rowDragService.decorateCell(F,this.rowDragService.getHandleState(o,f,e)),this.rowDragService.isDragSourceRow(o)&&this.dom.addClass("ge-table-row-dragging",F));const U=e.getCustomStyleAt(o,i);if(U)for(const H in U)this.dom.domService.setStyle(F,H,U[H]);return[F,K]}applyCssClasses(e,t={}){e&&Object.entries(t).forEach(([s,o])=>{o?this.dom.addClass(s,e):this.dom.removeClass(s,e)})}getColumnWidths(e,t){const s=[];for(let o=e;o<=t;o++)s.push(this.tableModel.getColumnWidth(o));return s}getRowHeights(e,t,s){const o=[];for(let i=e;i<=t;i++)o.push(s.getRowHeight(i));return o}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1&&e.areaIdent==="body"){const t=this.hostElement.clientWidth,s=this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex),o=this.contentScrollTop,i=e.rowTop+this.areaHeaderCenter.parent.clientHeight-o;this.dom.applyStyle(this.hoverRow,{left:"0",top:i+"px",width:t+"px",height:s+"px",display:"block"})}else this.hideHoverRow()}hideHover(){this.hideHoverRow(),this.hideHoverColumn()}hideHoverRow(){this.dom.applyStyle(this.hoverRow,{display:"none"})}adjustHoverColumns(e){if(this.tableOptions.hoverColumnVisible&&e.rowIndex>-1){const t=this.hostElement.clientHeight,s=this.tableModel.getColumnWidth(e.columnIndex),o=this.getColumnLeftInHost(e.columnIndex,e.columnLeft);this.dom.applyStyle(this.hoverColumn,{left:o+"px",top:"0px",width:s+"px",height:t+"px",display:"block"})}else this.hideHoverColumn()}getColumnLeftInHost(e,t){const s=this.tableModel.getColumnCount(),o=this.tableModel.getFixedLeftColumnCount(),i=this.tableModel.getFixedRightColumnCount();if(e<o)return t;if(i>0&&e>=s-i){const r=this.tableModel.getXPosByColumnIndex(s-i);return this.areaBodyEastGeo.left+t-r}return t-this.getContentScrollLeft()}getContentScrollLeft(){const e=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();return-this.snapToDevicePixel(this.scrollFactorX*e)}hideHoverColumn(){this.dom.applyStyle(this.hoverColumn,{display:"none"})}disposeRendering(){this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null);for(const e of["header","body","footer"])for(;this.cleanupFunctions[e].length;){const t=this.cleanupFunctions[e].shift();t&&t()}}debounce(e,t=1e3){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(()=>{this.debounceTimeout=null,e.call(this)},t)}adjustDraggingColumn(e,t,s){var o;if(this.dragging){const i=this.hostElement.clientHeight,r=this.tableModel.getColumnWidth(t);if((o=e.originalEvent)!=null&&o.clientX){const c={left:(this.isRtl()?this.clientXToHostX(e.originalEvent.clientX):e.originalEvent.clientX)-r/2,width:r,height:i,top:0,index:t};this.dom.applyStyle(this.draggingColumn,{background:"rgba(128,128,128,0.2)",display:"block",overflow:"hidden"}),this.dom.applyStyleInPx(this.draggingColumn,c),s&&this.renderContentOfDraggingColumn(c)}}else this.hideDraggingColumn()}renderContentOfDraggingColumn(e){const t=this.renderContentOfDraggingColumnForArea(e,"header",0),s=Math.max(0,this.firstVisibleRowIndex),o=t+this.getBodyRowTop(s)-this.contentScrollTop;this.renderContentOfDraggingColumnForArea(e,"body",o,s,this.hostElement.clientHeight)}renderContentOfDraggingColumnForArea(e,t,s=0,o=0,i=Number.POSITIVE_INFINITY){const r="center",l=this.tableModel.getAreaModel(t),a=l==null?void 0:l.getRowCount();if(a){const c=e.index??0,h=this.draggingColumn;for(let d=o;d<a&&s<i;d++){const u=s,f=l.getRowHeight(d),p={left:0,width:e.width,height:f,top:u,index:d},g=l.getValueAt(d,c),m=l.getCellRenderer(d,c),b=m?"":`${g??""}`,w={parent:h,geo:p,rowIndex:d,columnIndex:c,areaIdent:t,sideIdent:r,text:b},y=this.dom.addColumnDiv(w);let C;m&&(C=m.render(y,d,c,t,l,g,this.dom.domService),C&&this.cleanupFunctions[t].push(C));const S=l.getCustomClassesAt(d,c);S.length&&this.dom.addClasses(S,y);const x=this.tableModel.getColumnDef(c);x&&x.classes[t]&&this.dom.addClasses(x.classes[t],y),this.dom.addColumnBorderDivs(this.tableOptions,h,p,t,r);const R=l.getCustomStyleAt(d,c);if(R)for(const I in R)this.dom.domService.setStyle(y,I,R[I]);s=s+f}}return s}hideDraggingColumn(){this.dom.applyStyle(this.draggingColumn,{display:"none"})}renderDragTargetDiv(e,t,s,o,i){const r=this.dom.applyStylePosistionAbsolute(this.dom.setAriaHidden(this.dom.createDivWithClass("ge-table-drop-zone",e)));return this.dom.setStyle(r,"left",`${t}px`),this.dom.setStyle(r,"top",`${s}px`),this.dom.setStyle(r,"width",`${o}px`),this.dom.setStyle(r,"height",`${i}px`),r}renderSelectedBackgroundDiv(e,t,s,o,i,r,l,a,c,h,d){let u=!1;if(!e&&t&&o.isSelectable(i,r)&&this.getSelectionModel){const f=this.getSelectionModel();if(f){const p=f.getSelectionCount(i,r);u=p>0;for(let g=0;g<p;g++){const m=this.dom.applyStylePosistionAbsolute(this.dom.setAriaHidden(this.dom.createDivWithClass(`ge-table-${o.areaIdent}-${s}-selected-range`,l)));this.dom.setStyle(m,"left",`${a}px`),this.dom.setStyle(m,"top",`${c}px`),this.dom.setStyle(m,"width",`${h}px`),this.dom.setStyle(m,"height",`${d}px`)}}}return u}renderCell({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:o,columnIndex:i,left:r,top:l,width:a,height:c,parent:h,cellSelected:d,lastRowOfModel:u}){const[f,p]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:o,index:i,left:r,width:a,height:c,top:l,parent:h,lastRowOfModel:u});d&&this.dom.addClass(`ge-table-${t}-${s}-selected-range`,f),t==="body"&&this.ariaSelectionKind==="cell"&&this.dom.domService.setAttribute(f,"aria-selected",d?"true":"false"),p&&this.cleanupFunctions[t].push(p)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:s,cellTop:o,cellWidth:i,cellHeight:r,parent:l}){const a=this.dom.domService,c=this.tableOptions.columnResizeHandleWidthInPx??2,h=a.createElement("div");a.setAttribute(h,"data-col-index",`${t}`),a.setAttribute(h,"data-row-index",`${e}`),a.setAttribute(h,"data-area","header"),a.setAttribute(h,"data-ge-action","resize-column"),a.addClass(h,"ge-table-column-resize-handle"),a.setAttribute(h,"aria-hidden","true"),a.setStyle(h,"display","clip"),a.setStyle(h,"position","absolute"),a.setStyle(h,"cursor","col-resize"),this.dom.setStyle(h,"left",`${s+i-c}px`),a.setStyle(h,"top",`${o}px`),a.setStyle(h,"width",`${c}px`),a.setStyle(h,"height",`${r}px`),a.appendChild(l,h)}}class Is{constructor(e,t){this.columnIndex=e,this.sortState=t}}function md(n,e,t){const s=n.length;if(e<0||t<0||e>=s||t>=s||!n[e]||!n[t])return;if(e===t)return[];const o=[],i=[];for(let d=0;d<s;d++)n[d]&&(o.push(d),i.push(d));i.splice(o.indexOf(e),1),i.splice(o.indexOf(t),0,e);const r=Array.from({length:s},(d,u)=>u);o.forEach((d,u)=>{r[d]=i[u]});const l=[[e,t]],a=r.map((d,u)=>u);wn(a,e,t);const c=Math.min(e,t),h=Math.max(e,t);for(let d=c;d<=h;d++){const u=a.indexOf(r[d]);u!==d&&(l.push([u,d]),wn(a,u,d))}return l}function bd(n,e,t,s,o){const i=Math.max(s,t-o);let r=0,l=t-1;return n<s?l=s-1:n>=i?r=i:(r=s,l=i-1),Math.min(Math.max(e,r),l)}function wd(n,e,t){if(!t.size)return n;const s=n.filter(o=>!t.has(o));return e.forEach((o,i)=>{t.has(o)&&s.splice(Math.min(i,s.length),0,o)}),s}function wn(n,e,t){const[s]=n.splice(e,1);n.splice(t,0,s)}const Jl=new WeakSet;function yd(n){return Jl.add(n),n}function Zl(n){return typeof n=="function"&&Jl.has(n)}class Ql{constructor(e,t){this.state=e,this.changedParts=t}}const rt=Object.freeze(["headerGroups","columns","filters","tree","sort","checked","selection","details","scroll","custom"]),Cd=["sortingState","scrollState","collapsedExpandedState"];function gi(n,e){try{const t=n.getItem(e);return t?JSON.parse(t):void 0}catch{return}}function ea(n,e,t){const s={version:1};let o=!1;const i=gi(n,e+"sortingState");Array.isArray(i)&&(o=!0,s.sort=i.filter(a=>a&&typeof a.columnIndex=="number"&&(a.sortState==="asc"||a.sortState==="desc")).map(a=>{const c=t[a.columnIndex],h=a.sortState;return c?{property:c,sortState:h}:{columnIndex:a.columnIndex,sortState:h}}));const r=gi(n,e+"scrollState");Array.isArray(r)&&typeof r[0]=="number"&&typeof r[1]=="number"&&(o=!0,s.scroll={left:r[0],top:r[1]});const l=gi(n,e+"collapsedExpandedState");if(l&&typeof l=="object"){o=!0;let a;l.allExpanded?a={collapsedRowIds:[]}:l.allCollapsed?a={expandedRowIds:[]}:l.mode==="expanded"?a={expandedRowIds:l.rowIds??[]}:a={collapsedRowIds:l.rowIds??[]},s.tree=a}return o?s:void 0}function Ni(n,e){for(const t of Cd)try{n.removeItem(e+t)}catch{}}const vd={headerGroups:"autoRestoreHeaderGroupState",columns:"autoRestoreColumnLayout",tree:"autoRestoreCollapsedExpandedState",sort:"autoRestoreSortingState",checked:"autoRestoreCheckedState",selection:"autoRestoreSelectedState",scroll:"autoRestoreScrollPosition",custom:"autoRestoreCustomState",details:"autoRestoreDetailState",filters:"autoRestoreFilterState"},St=n=>n==="checked"?"checkedRowIds":n==="details"?"detailRowIds":n,Ye=Number.MAX_SAFE_INTEGER,qe=class qe{constructor(e){this.scope=e,this.restoring=!1,this.started=!1,this.destroyed=!1,this.dirty=new Set,this.lastReported=new Map,this.reported={version:1},this.legacyRemoved=!1,this.sortPriority=[],this.initialWidths=new Map,this.startState={},this.custom=void 0,this.warnedNoRowObject=!1,this.warnedNoId=!1,this.warnWithoutStorageKey()}initBeforeModel(){this.started||(this.started=!0,this.restoring=!0,this.startState=this.readStartState(),this.defaultState={version:1},this.computePart("headerGroups",this.defaultState),this.startState.headerGroups&&this.applyHeaderGroups(this.startState.headerGroups))}initAfterModel(){if(!this.restoring)return;for(const s of this.columnDefs())this.initialWidths.set(s,s.width);this.sortPriority=this.columnDefs().filter(s=>s.sortState&&s.property).map(s=>s.property);const e=s=>this.persistedParts().includes(s)||this.startState[St(s)]!==void 0,t=this.getState(rt.filter(s=>s!=="headerGroups"&&s!=="scroll"&&s!=="custom"&&(!qe.EXPENSIVE.includes(s)||e(s))));this.defaultState={...this.defaultState,...t,scroll:{left:0,top:0}},this.startState.columns&&this.applyColumns(this.startState.columns,!1),this.startState.filters&&this.scope.columnFilterService.applyStateFilters(this.startState.filters,!1),typeof this.startState.filterRowVisible=="boolean"&&this.scope.restoreFilterRowVisible(this.startState.filterRowVisible)}initAfterFilter(){if(!this.restoring)return;const e=this.startState;e.tree&&this.applyTree(e.tree),e.sort&&this.applySort(e.sort),e.checkedRowIds&&this.applyChecked(e.checkedRowIds),e.selection&&this.applySelection(e.selection),e.detailRowIds&&this.applyDetails(e.detailRowIds),"custom"in e&&(this.custom=e.custom)}initAfterLayout(){this.restoring&&(this.startState.scroll&&this.applyScroll(this.startState.scroll),this.restoring=!1,this.rememberAsReported(this.getState(rt.filter(e=>!qe.EXPENSIVE.includes(e)))))}getState(e=rt){const t={version:1};for(const s of e)this.computePart(s,t);return t}applyState(e,t=rt){if(!e||typeof e!="object")return;const s=r=>t.includes(r)&&e[St(r)]!==void 0,o=[];let i=!1;if(s("headerGroups")&&this.applyHeaderGroups(e.headerGroups)&&o.push("headerGroups"),s("columns")&&(i=this.applyColumns(e.columns,!0),o.push("columns")),t.includes("filters")&&(e.filters!==void 0||typeof e.filterRowVisible=="boolean")){let r=!1;e.filters!==void 0&&this.scope.columnFilterService.applyStateFilters(e.filters,!0)&&(r=!0),typeof e.filterRowVisible=="boolean"&&this.scope.restoreFilterRowVisible(e.filterRowVisible)&&(r=!0),r&&o.push("filters")}s("tree")&&(this.applyTree(e.tree),o.push("tree")),s("sort")&&(this.applySort(e.sort),o.push("sort")),s("checked")&&(this.applyChecked(e.checkedRowIds),o.push("checked")),s("selection")&&(this.applySelection(e.selection),o.push("selection")),s("details")&&(this.applyDetails(e.detailRowIds),o.push("details")),t.includes("custom")&&"custom"in e&&(this.custom=e.custom,o.push("custom")),o.includes("headerGroups")?this.scope.headerGroupsChanged():i?this.scope.recalcColumnWidths():o.length&&(this.scope.tableModel.recalcHeightAndPadding(),this.scope.recalcWrappers(),this.scope.repaintHard()),s("scroll")&&(this.applyScroll(e.scroll),o.push("scroll")),o.forEach(r=>this.markDirty(r))}resetState(){if(!this.defaultState)return;const e=this.scope.columnFilterService.hasActiveFilters()?{...this.defaultState,filters:this.defaultState.filters??{}}:this.defaultState;this.applyState(e),this.custom=void 0,this.markDirty("custom"),this.flush();const t=this.storageKey(),s=this.storage();if(t&&s)try{s.removeItem(t+qe.STORAGE_SUFFIX),Ni(s,t)}catch{}this.lastPersisted=void 0}setCustomState(e){this.custom=e,this.markDirty("custom")}sortedByColumn(e){this.sortPriority=e?[e]:[],this.markDirty("sort")}markDirty(e){!this.started||this.restoring||this.destroyed||(this.dirty.add(e),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.flush(),this.scope.tableOptions.stateChangedDebounceDelay??300))}rendered(){if(this.restoring||!this.started)return;const e=this.scope.scrollViewport,t=this.reportedScroll;(!t||t.left!==this.scope.getViewportScrollLeft()||t.top!==e.scrollTop)&&this.markDirty("scroll")}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),!this.dirty.size||!this.started||this.restoring)return;this.persistedParts().includes("checked")&&this.dirty.add("checked");const e=rt.filter(t=>this.dirty.has(t));this.dirty.clear();try{const t=this.getState(e),s=e.filter(i=>this.partJson(t,i)!==this.lastReported.get(i));if(!s.length)return;const o={...this.reported};for(const i of e){const r=St(i);t[r]===void 0?delete o[r]:o[r]=t[r],i==="filters"&&(t.filterRowVisible===void 0?delete o.filterRowVisible:o.filterRowVisible=t.filterRowVisible),this.lastReported.set(i,this.partJson(t,i))}this.reported=o,t.scroll&&(this.reportedScroll={left:t.scroll.left,top:t.scroll.top}),this.persist(o),this.scope.stateChanged(new Ql(JSON.parse(JSON.stringify(o)),s))}catch(t){console.error("GuiExpert Table: the table state could not be stored or reported",t)}}destroy(){if(!this.destroyed){this.started&&!this.restoring&&this.persistedParts().includes("checked")&&this.dirty.add("checked");try{this.flush()}finally{this.destroyed=!0}}}storageKey(){var s;const e=(s=this.scope.tableOptions.autoRestoreOptions)==null?void 0:s.getStorageKeyFn;return(e?e():void 0)||void 0}storage(){var t;const e=(t=this.scope.tableOptions.autoRestoreOptions)==null?void 0:t.storage;if(e)return e;try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}persistedParts(){const e=this.scope.tableOptions.autoRestoreOptions;return e?rt.filter(t=>!!e[vd[t]]):[]}warnWithoutStorageKey(){this.scope.tableOptions.autoRestoreOptions&&this.persistedParts().length&&!this.storageKey()&&console.warn("GuiExpert Table: autoRestoreOptions are ignored without getStorageKeyFn (nothing is stored).")}readStartState(){const e=this.scope.tableOptions.initialState??{},t=this.persistedParts(),s=this.storageKey(),o=this.storage();if(!t.length||!s||!o)return{...e};let i;try{const l=o.getItem(s+qe.STORAGE_SUFFIX);if(l){const a=JSON.parse(l);a&&typeof a=="object"&&a.version===1&&(i=a,this.lastPersisted=l)}}catch{}i||(i=ea(o,s,this.columnDefs().map(l=>l.property)));const r={...e};if(i)for(const l of t){const a=St(l);a in i&&(r[a]=i[a]),l==="filters"&&"filterRowVisible"in i&&(r.filterRowVisible=i.filterRowVisible)}return r}persist(e){const t=this.persistedParts(),s=this.storageKey(),o=this.storage();if(!t.length||!s||!o)return;const i={version:1};for(const l of t){const a=St(l);e[a]!==void 0&&(i[a]=e[a]),l==="filters"&&e.filterRowVisible!==void 0&&(i.filterRowVisible=e.filterRowVisible)}const r=JSON.stringify(i);if(r!==this.lastPersisted)try{o.setItem(s+qe.STORAGE_SUFFIX,r),this.lastPersisted=r,this.legacyRemoved||(Ni(o,s),this.legacyRemoved=!0)}catch{}}rememberAsReported(e){this.reported=e,e.scroll&&(this.reportedScroll={left:e.scroll.left,top:e.scroll.top});for(const t of rt)(St(t)in e||t==="filters"&&"filterRowVisible"in e)&&this.lastReported.set(t,this.partJson(e,t))}partJson(e,t){if(t==="filters")return e.filters===void 0&&e.filterRowVisible===void 0?"":JSON.stringify({filters:e.filters,filterRowVisible:e.filterRowVisible});const s=e[St(t)];return s===void 0?"":JSON.stringify(s)}computePart(e,t){var s,o;switch(e){case"headerGroups":{const i=(s=this.headerGroupModel())==null?void 0:s.getToggleGroupStates();i!=null&&i.length&&(t.headerGroups=i);break}case"columns":{const i=this.computeColumns();i&&(t.columns=i);break}case"sort":{const i=this.computeSort();i&&(t.sort=i);break}case"scroll":t.scroll=this.computeScroll();break;case"tree":{const i=this.computeTree();i&&(t.tree=i);break}case"checked":{const i=this.computeChecked();i&&(t.checkedRowIds=i);break}case"selection":{const i=this.computeSelection();i&&(t.selection=i);break}case"custom":this.custom!==void 0&&(t.custom=this.custom);break;case"details":{const i=this.computeDetails();i&&(t.detailRowIds=i);break}case"filters":{(o=this.scope.columnFilterService)!=null&&o.hasActiveFilters()&&(t.filters=this.scope.columnFilterService.getColumnFilters()),this.scope.hasFilterRow()&&(t.filterRowVisible=this.scope.isFilterRowVisible());break}}}computeColumns(){const e=this.columnDefs();if(!e.length)return;const t=new Set,s=[];for(const o of e){if(!o.property||t.has(o.property))continue;t.add(o.property);const i={property:o.property},r=this.initialWidths.get(o);r&&o.width&&(r.value!==o.width.value||r.unit!==o.width.unit)&&o.width.unit==="px"&&(i.width=o.width.value),i.visible=at(o),s.push(i)}return s}computeSort(){const e=this.columnDefs();if(!e.length)return;const t=s=>{const o=this.sortPriority.indexOf(s.property);return o<0?Ye:o};return e.filter(s=>s.sortState&&s.property).map((s,o)=>({cd:s,index:o})).sort((s,o)=>t(s.cd)-t(o.cd)||s.index-o.index).map(({cd:s})=>({property:s.property,sortState:s.sortState}))}computeScroll(){const e=this.scope.scrollViewport,t={left:this.scope.getViewportScrollLeft(),top:e.scrollTop},s=this.scope.getFirstVisibleRowIndex();if(s>-1&&this.body().getRowCount()>0){const o=this.idAt(s,this.warns("scroll"));o!==void 0&&(t.firstRowId=o)}return t}computeTree(){const e=this.body();if(!ee(e))return;const t=[],s=[],o=this.warns("tree");return this.walkTree(e,i=>{var r;if((r=i.children)!=null&&r.length){const l=this.idOfRow(i,-1,o);l!==void 0&&(i.expanded?t:s).push(l)}}),t.length<=s.length?{expandedRowIds:t}:{collapsedRowIds:s}}computeChecked(){const e=this.body().rowSelectionModel;if(!e)return;const t=this.warns("checked"),s=[];for(const o of e.getCheckedRows()??[]){const i=this.idOfRow(o,-1,t);i!==void 0&&s.push(i)}return s}computeDetails(){const e=this.scope.masterDetailService;if(!(e!=null&&e.isActive()))return;const t=this.warns("details"),s=[];for(const o of e.getExpandedRows()){const i=this.idOfRow(o,-1,t);i!==void 0&&s.push(i)}return s}applyDetails(e){const t=this.scope.masterDetailService;if(!(t!=null&&t.isActive())||!Array.isArray(e))return;const s=new Set(e),o=this.body(),i=o,r=i.getAllRows?i.getAllRows():Array.from({length:o.getRowCount()},(l,a)=>o.getRowByIndex(a));t.setExpandedRows(r.filter((l,a)=>{const c=this.idOfRow(l,i.getAllRows?-1:a,!1);return c!==void 0&&s.has(c)}),"state")}computeSelection(){const e=this.scope.selectionModel();if(!e||!e.selectionType||e.selectionType==="none")return;const t=e.createSnapshot?e.createSnapshot():{ranges:e.getRanges(),negativeRanges:[],allSelected:e.isAllSelected()},s=this.warns("selection"),o=r=>r.map(l=>this.toStateRange(l,s)).filter(l=>!!l),i={ranges:o(t.ranges)};return t.negativeRanges.length&&(i.negativeRanges=o(t.negativeRanges)),t.allSelected&&(i.allSelected=!0),i}toStateRange(e,t){var a,c;const s={},o=Math.min(e.r1,e.r2),i=Math.max(e.r1,e.r2);if(!(o<=0&&i>=Ye)){const h=this.idAt(o,t);if(h===void 0)return;if(s.fromRowId=h,i<Ye){const d=this.idAt(i,t);if(d===void 0)return;s.toRowId=d}}const r=Math.min(e.c1,e.c2),l=Math.max(e.c1,e.c2);if(!(r<=0&&l>=Ye)){const h=this.columnDefs(),d=(a=h[r])==null?void 0:a.property;if(!d)return;if(s.fromProperty=d,l<Ye){const u=(c=h[l])==null?void 0:c.property;if(!u)return;s.toProperty=u}}return s}applyHeaderGroups(e){const t=this.scope.tableModel.getAreaModel("header");if(!t.setGroupClosed||!t.getToggleGroupStates||!Array.isArray(e))return!1;const s=new Map(t.getToggleGroupStates().map(i=>[i.id,i.closed]));let o=!1;for(const i of e)if(i&&s.has(i.id)&&s.get(i.id)!==!!i.closed){const r=t.setGroupClosed(i.id,!!i.closed);r&&"columnDefs"in this.scope.tableModel&&(this.scope.tableModel.columnDefs=r),o=!0}return o}applyColumns(e,t){const s=this.scope.tableModel,o=this.columnDefs();if(!o.length||!Array.isArray(e))return!1;const i=new Map;for(const u of e)u&&typeof u.property=="string"&&!i.has(u.property)&&o.some(f=>f.property===u.property)&&i.set(u.property,u);const r=o.map(u=>u.property),l=Array.from(i.keys()),a=new Set;r.forEach((u,f)=>{if(i.has(u)&&!a.has(u)){a.add(u);return}const p=f>0?l.lastIndexOf(r[f-1]):-1;l.splice(p+1,0,u)});const c=wd(l,r,new Set(o.filter(u=>u.movable===!1).map(u=>u.property)));for(let u=0;u<c.length;u++){const p=s.getColumnDefs().map(g=>g.property).indexOf(c[u],u);p>u&&s.changeColumnOrder(p,u)}let h=!1;return this.columnDefs().forEach((u,f)=>{var g;const p=i.get(u.property);if(p){if(typeof p.visible=="boolean"&&at(u)!==p.visible&&((g=s.setColumnVisible)==null||g.call(s,f,p.visible)),typeof p.width=="number"&&p.width>=0)s.setColumnWidth(f,p.width);else if(t){const m=this.initialWidths.get(u);m&&(m.value!==u.width.value||m.unit!==u.width.unit)&&(m.unit==="px"?s.setColumnWidth(f,m.value):h=!0,u.width=m)}}}),h}applyTree(e){const t=this.body();if(!ee(t)||!e)return;const s=Array.isArray(e.expandedRowIds);if(!s&&!Array.isArray(e.collapsedRowIds))return;const o=new Set((s?e.expandedRowIds:e.collapsedRowIds)??[]),i=t;this.walkTree(i,r=>{var l;if((l=r.children)!=null&&l.length){const a=this.idOfRow(r,-1,!1);a!==void 0&&(r.expanded=s?o.has(a):!o.has(a))}}),i.recalcVisibleTreeRows(!1)}applySort(e){var i;if(!Array.isArray(e))return;const t=this.columnDefs(),s=[],o=[];for(const r of e){if(!r||r.sortState!=="asc"&&r.sortState!=="desc")continue;const l=typeof r.property=="string"?t.findIndex(a=>a.property===r.property):typeof r.columnIndex=="number"?r.columnIndex:-1;l<0||l>=this.scope.tableModel.getColumnCount()||s.some(a=>a.columnIndex===l)||(s.push(new Is(l,r.sortState)),(i=t[l])!=null&&i.property&&o.push(t[l].property))}this.scope.applySortItems(s),this.sortPriority=o}applyChecked(e){const t=this.body(),s=t.rowSelectionModel;if(!s||!Array.isArray(e))return;const o=new Set(e);if(ee(t)){const l=t;this.walkTree(l,a=>{a.checked=!1}),this.walkTree(l,a=>{const c=this.idOfRow(a,-1,!1);c!==void 0&&o.has(c)&&!a.checked&&s.checkRow(a,!0)});return}const i=t,r=i.getAllRows?i.getAllRows():Array.from({length:t.getRowCount()},(l,a)=>t.getRowByIndex(a));s.setCheckedRows(r.filter((l,a)=>{const c=this.idOfRow(l,i.getAllRows?-1:a,!1);return c!==void 0&&o.has(c)}))}applySelection(e){const t=this.scope.selectionModel();if(!t||!e||!Array.isArray(e.ranges))return;const o=[...e.ranges,...e.negativeRanges??[]].some(c=>c&&(c.fromRowId!==void 0||c.toRowId!==void 0))?this.rowIndexMap():new Map,i=this.columnDefs(),r=c=>{if(!c)return;let h=0,d=Ye,u=0,f=Ye;if(c.fromRowId!==void 0||c.toRowId!==void 0){const p=o.get(c.fromRowId??c.toRowId),g=c.toRowId===void 0?Ye:o.get(c.toRowId);if(p===void 0||g===void 0)return;h=Math.min(p,g),d=Math.max(p,g)}if(c.fromProperty!==void 0||c.toProperty!==void 0){const p=i.findIndex(m=>m.property===(c.fromProperty??c.toProperty)),g=c.toProperty===void 0?Ye:i.findIndex(m=>m.property===c.toProperty);if(p<0||g<0)return;u=Math.min(p,g),f=Math.max(p,g)}return new M(h,u,d,f)},l=c=>(c??[]).map(r).filter(h=>!!h),a={ranges:l(e.ranges),negativeRanges:l(e.negativeRanges),allSelected:!!e.allSelected};t.restoreSnapshot?t.restoreSnapshot(a):(t.clear(),a.ranges.forEach(c=>t.addSelection(c)))}applyScroll(e){if(!e||typeof e.top!="number"||typeof e.left!="number"||(this.scope.scrollViewport.scrollTo(kr(e.left,this.scope.isRtl()),e.top),this.scope.adjustAfterScrolling(),e.firstRowId===void 0))return;const t=this.scope.getFirstVisibleRowIndex();if(t>-1&&this.idAt(t,!1)===e.firstRowId)return;const s=this.rowIndexMap().get(e.firstRowId);s!==void 0&&(this.scope.scrollToIndex(-1,s),this.scope.adjustAfterScrolling())}columnDefs(){return this.scope.tableModel.getColumnDefs()??[]}body(){return this.scope.tableModel.getBodyModel()}headerGroupModel(){const e=this.scope.tableModel.getAreaModel("header");return e&&typeof e.getToggleGroupStates=="function"?e:void 0}warns(e){return this.persistedParts().includes(e)}ownGetRowId(){var t;const e=(t=this.scope.tableOptions.autoRestoreOptions)==null?void 0:t.getRowId;return e&&!Zl(e)?e:void 0}idAt(e,t){return this.idOfRow(this.body().getRowByIndex(e),e,t)}idOfRow(e,t,s){const o=this.ownGetRowId();if(e==null){if(o&&o.length>=2&&t>-1)return o(void 0,t);s&&!this.warnedNoRowObject&&(this.warnedNoRowObject=!0,console.warn("GuiExpert Table: the body model has no row objects – these rows are not stored. Set autoRestoreOptions.getRowId = (_row, rowIndex) => rowIndex to store them by index."));return}const i=J(e)?e.data:e;if(Se(i))return i.id;if(o)return o(i,t);if(i&&typeof i=="object")for(const r of["id","uuid"]){const l=i[r];if(typeof l=="string"||typeof l=="number")return l}s&&!this.warnedNoId&&(this.warnedNoId=!0,console.warn("GuiExpert Table: rows without 'id' or 'uuid' are not stored – set autoRestoreOptions.getRowId."))}rowIndexMap(){const e=this.body(),t=new Map,s=e.getRowCount();for(let o=0;o<s;o++){const i=this.idAt(o,!1);i!==void 0&&!t.has(i)&&t.set(i,o)}return t}walkTree(e,t){const s=o=>o==null?void 0:o.forEach(i=>{t(i),s(i.children)});s(e.rows)}};qe.STORAGE_SUFFIX="tableState",qe.EXPENSIVE=["tree","checked","selection"];let vo=qe;class ta{constructor(e){this.tableScope=e,this.tableScope.hostElement.addEventListener("change",this.onHostElementChanged.bind(this),{signal:this.tableScope.listenerAbortController.signal}),this.tableScope.hostElement.addEventListener("keydown",this.onHostElementKeyDown.bind(this),{signal:this.tableScope.listenerAbortController.signal}),this.tableScope.hostElement.addEventListener("input",this.onHostElementInput.bind(this),{signal:this.tableScope.listenerAbortController.signal}),this.tableScope.hostElement.addEventListener("focusout",this.onHostElementFocusOut.bind(this),{signal:this.tableScope.listenerAbortController.signal})}onHostElementFocusOut(e){var s,o;const t=e.target;t instanceof HTMLInputElement&&t.isConnected&&t.getAttribute("data-ge-restored")==="true"&&((o=(s=this.tableScope).getInCellEditorCell)!=null&&o.call(s))&&this.commitInCellEditor(t)}commitInCellEditor(e){const t=Number(e.getAttribute("data-row-index")),s=Number(e.getAttribute("data-col-index"));this.tableScope.updateModelValueAfterEdit("body",t,s,e.value)}onHostElementInput(e){const t=e.target;if(!this.tableScope.isEditing()||!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)||t.getAttribute("data-area")!=="body")return;const s=Number(t.getAttribute("data-row-index")),o=Number(t.getAttribute("data-col-index"));this.tableScope.setEditorDraft(s,o,t)}onHostElementKeyDown(e){var o,i,r,l;if((i=(o=this.tableScope).isEventInDetail)!=null&&i.call(o,e)||(l=(r=this.tableScope).isEventInFilterUI)!=null&&l.call(r,e)||!this.tableScope.isEditing())return;const t=e.target;if(e.key==="Enter"&&!e.isComposing&&e.keyCode!==229&&t instanceof HTMLInputElement&&t.getAttribute("data-area")==="body"&&t.getAttribute("data-ge-restored")==="true"){e.preventDefault(),this.commitInCellEditor(t);return}if(e.key!=="Escape")return;const s=e.target;(s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement)&&s.getAttribute("data-area")==="body"&&(e.preventDefault(),e.stopPropagation(),this.tableScope.cancelEditing(s))}onHostElementChanged(e){var t,s,o,i,r,l;if(!((s=(t=this.tableScope).isEventInDetail)!=null&&s.call(t,e)||(i=(o=this.tableScope).isEventInFilterUI)!=null&&i.call(o,e))&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLTextAreaElement)){const a=e.target,c=a.getAttribute("data-area"),h=a.getAttribute("data-row-index"),d=a.getAttribute("data-col-index");if((a.classList.contains("ge-table-cell-editor-input")||a.classList.contains("ge-table-cell-editor-select"))&&!((l=(r=this.tableScope).getInCellEditorCell)!=null&&l.call(r)))return;if(c&&h&&d){const f=ss(c),p=Number(h),g=Number(d);this.tableScope.updateModelValueAfterEdit(f,p,g,a.value)}}}}class sa{constructor(e,t,s,o,i,r,l,a){this.scrollTop=e,this.scrollLeft=t,this.scrollHeight=s,this.scrollWidth=o,this.clientHeight=i,this.clientWidth=r,this.scrollFactorY=l,this.scrollFactorX=a}}class De{constructor(e){this.tableScope=e,this.ignoreNextClick=!1,this.anchorRanges=[],this.getSelectionModel=()=>this.tableScope.selectionModel(),this.getFocusModel=()=>this.tableScope.focusModel()}onMouseDown(){this.ignoreNextClick=!1,this.dragSnapshot=void 0}onMouseDragging(e,t){var o;if(!t||t.action||t.areaIdent!=="body"||e.areaIdent!=="body"||t.rowIndex<0||t.columnIndex<0||e.rowIndex<0||e.columnIndex<0)return!1;const s=(o=this.getSelectionModel)==null?void 0:o.call(this);return!s||!("selectionType"in s)||s.selectionType!=="range"?!1:(this.batch(()=>{var l,a,c;!!((l=t.originalEvent)!=null&&l.ctrlKey||(a=t.originalEvent)!=null&&a.metaKey)&&De.hasSnapshots(s)?(this.dragSnapshot=this.dragSnapshot??s.createSnapshot(),s.restoreSnapshot(this.dragSnapshot)):s.clear(),s.addSelection(this.createRangeByEvents(e,t));const r=(c=this.getFocusModel)==null?void 0:c.call(this);r&&!r.hasFocus(t.rowIndex,t.columnIndex)&&r.setFocus(t.rowIndex,t.columnIndex),this.previousEvt=t.clone(),this.anchor=[t.rowIndex,t.columnIndex],this.extent=[e.rowIndex,e.columnIndex],this.anchorRanges=[],this.ignoreNextClick=e.rowIndex!==t.rowIndex||e.columnIndex!==t.columnIndex,this.tableScope.onSelectionChanged(s)}),!0)}onMouseClicked(e,t){var o,i;if(this.ignoreNextClick)return this.ignoreNextClick=!1,!1;if(e.areaIdent==="header"&&e.clickCount===1&&this.isRowNumberColumn(e.columnIndex)&&e.rowIndex===this.tableScope.tableModel.getAreaModel("header").getRowCount()-1)return this.selectAllByRowNumberHeader();if(e.areaIdent==="header"&&e.clickCount===1&&e.columnIndex>-1&&this.isColumnLetterCell(e))return this.clickColumnLetter(e);if(e.areaIdent!=="body"||e.rowIndex<0||e.columnIndex<0||e.clickCount>1||((i=(o=this.tableScope).canFocusBodyCell)==null?void 0:i.call(o,e.rowIndex,e.columnIndex))===!1)return!1;let s=!1;if(this.getSelectionModel&&this.getFocusModel){const r=this.getSelectionModel(),l=this.getFocusModel();r&&l&&(this.batch(()=>{var f,p,g,m;l.hasFocus(e.rowIndex,e.columnIndex)||l.setFocus(e.rowIndex,e.columnIndex);const a=!!((f=e.originalEvent)!=null&&f.shiftKey),c=!!((p=e.originalEvent)!=null&&p.ctrlKey||(g=e.originalEvent)!=null&&g.metaKey),h=!!((m=e.originalEvent)!=null&&m.altKey),d=this.isRowNumberColumn(e.columnIndex)&&De.isRangeSelection(r);if(a&&(this.anchor||this.previousEvt)){if(this.anchorRanges.length&&De.hasSnapshots(r)){const C=r.createSnapshot();r.restoreSnapshot({...C,ranges:C.ranges.filter(S=>!this.anchorRanges.includes(S))})}const[b,w]=this.anchor??[this.previousEvt.rowIndex,this.previousEvt.columnIndex],y=De.rangeBetween(e.rowIndex,e.columnIndex,b,w);this.extent=[e.rowIndex,e.columnIndex],d&&(y.c1=0,y.c2=Number.MAX_SAFE_INTEGER),r.addSelection(y),this.anchorRanges=[y],this.tableScope.onSelectionChanged(r);return}const u=r.getRanges().slice();d?this.clickRowNumber(r,e.rowIndex,e.columnIndex,a,c,h):c&&h?r.removeSelection(M.singleCell(e.rowIndex,e.columnIndex)):c?r.togglePoint(e.rowIndex,e.columnIndex):(!a&&r.hasSelection()&&r.clear(),r.firstClick(e.rowIndex,e.columnIndex)),this.anchorRanges=r.getRanges().filter(b=>!u.includes(b)),this.previousEvt=e.clone(),this.anchor=[e.rowIndex,e.columnIndex],this.letterAnchor=void 0,this.extent=void 0,this.tableScope.onSelectionChanged(r)}),s=!0)}return s}onActionTriggered(e){var t,s;if(this.getSelectionModel&&this.getFocusModel){const o=this.getSelectionModel(),i=this.getFocusModel();if(o&&i){if(e==="SELECT_ALL")return o.selectAll(),this.tableScope.repaint(),this.announce(r=>r.allSelected()),!0;if(e==="DESELECT_ALL")return o.clear(),this.tableScope.repaint(),this.announce(r=>r.selectionCleared()),!0;if(e==="TOGGLE_SELECTION"&&((s=(t=this.tableScope).getHeaderFocus)!=null&&s.call(t)))return!1;if(e==="TOGGLE_SELECTION"){const[r,l]=i.getFocus();return this.isRowNumberColumn(l)&&De.isRangeSelection(o)?(this.clickRowNumber(o,r,l,!1,!0,!1),this.tableScope.onSelectionChanged(o),this.tableScope.repaint(),!0):(o.togglePoint(r,l),this.tableScope.repaint(),!0)}}}return!1}adjustForRowChanges(e){var o,i;const t=r=>{if(!r)return;const l=e.mapIndex(r[0]);return l>=0?[l,r[1]]:void 0};if(this.anchor=t(this.anchor),this.extent=t(this.extent),this.previousEvt&&this.previousEvt.areaIdent==="body"){const r=e.mapIndex(this.previousEvt.rowIndex);r>=0?this.previousEvt.rowIndex=r:this.previousEvt=void 0}const s=((i=(o=this.getSelectionModel)==null?void 0:o.call(this))==null?void 0:i.getRanges())??[];this.anchorRanges=this.anchorRanges.filter(r=>s.includes(r))}getAnchor(){return this.anchor?[this.anchor[0],this.anchor[1]]:void 0}getExtent(){var r;const e=(r=this.getFocusModel)==null?void 0:r.call(this),[t,s]=e?e.getFocus():[-1,-1],o=this.extent??this.anchor,i=this.anchor;return t>=0&&s>=0&&!(i&&i[0]===t&&i[1]===s)&&!(o&&o[0]===t&&o[1]===s)?[t,s]:o?[o[0],o[1]]:void 0}collapseTo(e,t){var i;const s=(i=this.getSelectionModel)==null?void 0:i.call(this);this.anchor=[e,t],this.extent=void 0,this.anchorRanges=[];const o=s==null?void 0:s.selectionType;!s||o!=="range"&&o!=="cell"||this.batch(()=>{const r=s.getRanges();r.length===1&&r[0].r1===e&&r[0].r2===e&&r[0].c1===t&&r[0].c2===t&&!s.isAllSelected()||(s.clear(),s.addSelection(M.singleCell(e,t)),this.tableScope.onSelectionChanged(s)),this.anchorRanges=s.getRanges().slice()})}extendTo(e,t){var h,d;const s=(h=this.getSelectionModel)==null?void 0:h.call(this);if(!s||!De.isRangeSelection(s))return;const o=(d=this.getFocusModel)==null?void 0:d.call(this),[i,r]=o?o.getFocus():[-1,-1],l=this.extent??this.anchor,a=this.anchor&&this.anchor[0]===i&&this.anchor[1]===r||l&&l[0]===i&&l[1]===r;if((!this.anchor||!a)&&i>=0&&r>=0&&(this.anchor=[i,r],this.extent=void 0,this.anchorRanges=[]),!this.anchor)return;const c=De.rangeBetween(e,t,this.anchor[0],this.anchor[1]);return this.batch(()=>{if(De.hasSnapshots(s)){const u=s.createSnapshot();s.restoreSnapshot({...u,ranges:u.ranges.filter(f=>!this.anchorRanges.includes(f))})}else s.clear();s.addSelection(c),this.anchorRanges=[c],this.extent=[e,t],this.tableScope.onSelectionChanged(s)}),c}static rangeBetween(e,t,s,o){return new M(Math.min(e,s),Math.min(t,o),Math.max(e,s),Math.max(t,o))}isRowNumberColumn(e){var t;return e>-1&&G((t=this.tableScope.tableModel)==null?void 0:t.getColumnDef(e))}isColumnLetterCell(e){var s;const t=this.tableScope.tableModel.getAreaModel("header");return!!((s=t.isColumnLetterRow)!=null&&s.call(t,e.rowIndex))&&!this.isRowNumberColumn(e.columnIndex)&&!Ae(this.tableScope.tableModel.getColumnDef(e.columnIndex))}clickColumnLetter(e){var l,a,c,h,d;const t=(l=this.getSelectionModel)==null?void 0:l.call(this),s=(a=this.getFocusModel)==null?void 0:a.call(this);if(!t||!De.isRangeSelection(t))return!1;const o=e.columnIndex,i=!!((c=e.originalEvent)!=null&&c.shiftKey),r=!!((h=e.originalEvent)!=null&&h.ctrlKey||(d=e.originalEvent)!=null&&d.metaKey);return this.batch(()=>{const u=i?this.letterAnchor??(s==null?void 0:s.getFocus()[1])??o:o,f=new M(0,Math.min(u,o),Number.MAX_SAFE_INTEGER,Math.max(u,o));if(!r&&t.hasSelection()&&t.clear(),t.addSelection(f),i||(this.letterAnchor=o),s){const p=Math.max(0,s.getFocus()[0]);s.setFocus(p,o)}this.anchor=[0,o],this.extent=void 0,this.tableScope.onSelectionChanged(t)}),!0}selectAllByRowNumberHeader(){var s;const e=(s=this.getSelectionModel)==null?void 0:s.call(this),t=e==null?void 0:e.selectionType;return!e||t!=="row"&&t!=="range"?!1:(this.batch(()=>{e.selectAll(),this.tableScope.onSelectionChanged(e)}),this.announce(o=>o.allSelected()),!0)}clickRowNumber(e,t,s,o,i,r){const l=new M(t,0,t,Number.MAX_SAFE_INTEGER);i&&r?e.removeSelection(l):i?e.isSelected(t,s)?e.removeSelection(l):e.addSelection(l):(!o&&e.hasSelection()&&e.clear(),e.addSelection(l))}static isRangeSelection(e){return e.selectionType==="range"}announce(e){var s;const t=(s=this.getSelectionModel)==null?void 0:s.call(this);(t==null?void 0:t.selectionType)!=="none"&&this.tableScope.ariaTexts&&typeof this.tableScope.announce=="function"&&this.tableScope.announce(e(this.tableScope.ariaTexts))}batch(e){typeof this.tableScope.holdSelectionEvents=="function"?this.tableScope.holdSelectionEvents(e):e()}static hasSnapshots(e){return typeof e.createSnapshot=="function"&&typeof e.restoreSnapshot=="function"}createRangeByEvents(e,t){t||(t=e);const s=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),o=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),i=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return M.create({rowIndex1:s,columnIndex1:i,rowIndex2:o,columnIndex2:r})}}class oa{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","ctrl+a":"SELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+x":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","meta -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT",home:"NAVIGATE_ROW_START",end:"NAVIGATE_ROW_END","ctrl+home":"NAVIGATE_FIRST_CELL","ctrl+end":"NAVIGATE_LAST_CELL",pageup:"NAVIGATE_PAGE_UP",pagedown:"NAVIGATE_PAGE_DOWN",enter:"ACTIVATE_CELL","ctrl+alt+up":"MOVE_ROW_UP","ctrl+alt+down":"MOVE_ROW_DOWN","ctrl+d":"FILL_DOWN","ctrl+r":"FILL_RIGHT","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}class ia{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","meta+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","meta+x":"DESELECT_ALL","meta+shift+a":"DESELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","ctrl -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT",home:"NAVIGATE_ROW_START",end:"NAVIGATE_ROW_END","meta+left":"NAVIGATE_ROW_START","meta+right":"NAVIGATE_ROW_END","ctrl+home":"NAVIGATE_FIRST_CELL","ctrl+end":"NAVIGATE_LAST_CELL","meta+up":"NAVIGATE_FIRST_CELL","meta+down":"NAVIGATE_LAST_CELL",pageup:"NAVIGATE_PAGE_UP",pagedown:"NAVIGATE_PAGE_DOWN",enter:"ACTIVATE_CELL","ctrl+alt+up":"MOVE_ROW_UP","ctrl+alt+down":"MOVE_ROW_DOWN","meta+d":"FILL_DOWN","meta+r":"FILL_RIGHT","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}const Sd={arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right"};function Ds(n){return n.trim().replace(/\+/g," ").replace(/ +/g," ").replace(/⌫/g,"backspace").replace(/↩/g,"enter").replace(/⇧/g,"shift").replace(/⌥/g,"alt").replace(/option/g,"alt").replace(/opt/g,"alt").replace(/⌃/g,"ctrl").replace(/control/g,"ctrl").replace(/command/g,"cmd").replace(/meta/g,"cmd").replace(/escape/g,"esc").replace(/⌘/g,"cmd").replace(/\*/g,"multiply").split(" ").filter(e=>e).map(e=>Sd[e]??e).filter((e,t,s)=>s.indexOf(e)===t).sort((e,t)=>{const s={cmd:1,ctrl:2,alt:3,shift:4},o=s[e]||5,i=s[t]||5;return o!==i?o-i:e.localeCompare(t)}).join(" ")}function ra(n){let e=n.key.toLowerCase();if(e===" "&&(e="space"),e==="arrowleft"&&(e="left"),e==="arrowright"&&(e="right"),e==="arrowup"&&(e="up"),e==="arrowdown"&&(e="down"),e==="delete"&&n.code==="Delete"&&(e="delete"),e==="backspace"&&(e="backspace"),e==="escape"&&(e="esc"),e==="return"&&(e="enter"),n.code.startsWith("Numpad")){const s=n.code.replace("Numpad","").toLowerCase();s==="add"?e="num_add":s==="subtract"?e="num_subtract":s==="multiply"?e="num_multiply":s==="divide"?e="num_divide":s==="decimal"?e="num_decimal":s==="enter"?e="num_enter":e="num_"+s}n.code.match(/^F\d+$/)&&(e=n.code.toLowerCase()),n.code.match(/^Digit\d+$/)&&(e=n.code.replace(/Digit/g,""));let t="";return n.ctrlKey&&(t+=" ctrl"),n.altKey&&(t+=t+" alt"),n.shiftKey&&(t+=t+" shift"),n.metaKey&&(t+=t+" cmd"),Ds(t+" "+e)}function Lr(){return typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.indexOf("Mac")>-1}class na{constructor(e){this.tableScope=e,this.shortcutActionIdMapping={},this.listener=[],this.listener.push(e),this.init()}addListener(e){this.listener.includes(e)||this.listener.push(e)}init(){var e,t,s,o;if((t=(e=this.tableScope)==null?void 0:e.tableOptions)!=null&&t.shortcutActionsDisabled)this.isDebug()&&console.debug("ShortcutService skipped.");else{this.assignPredefinedSystemShortcutMappings();for(const i of((o=(s=this.tableScope).getShortcutLayers)==null?void 0:o.call(s,this.isMacintosh()))??[])this.assignMapping(i);this.assignMapping(this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this),{signal:this.tableScope.listenerAbortController.signal})}}assignPredefinedSystemShortcutMappings(){this.isMacintosh()?this.assignMapping(new ia().get()):this.assignMapping(new oa().get())}assignMapping(e){if(e)for(const t of Object.keys(e)){const s=Ds(t);for(const o of Object.keys(this.shortcutActionIdMapping))o!==t&&Ds(o)===s&&delete this.shortcutActionIdMapping[o];this.shortcutActionIdMapping[t]=e[t]}}isMacintosh(){return Lr()}isDebug(){return this.isLocalhost()}isLocalhost(){return location.hostname==="localhost"||location.hostname==="127.0.0.1"}onKeyDown(e){var o,i,r,l;if((i=(o=this.tableScope).isEventInDetail)!=null&&i.call(o,e)||(l=(r=this.tableScope).isEventInFilterUI)!=null&&l.call(r,e))return;const t=e.target;if(t&&(t.isContentEditable||["INPUT","SELECT","TEXTAREA","BUTTON","A"].includes(t.tagName)))return;const s=this.findEntity(e);if(s){this.tableScope.shortcutKeyEvent=e;let a;try{a=this.emit(s)}finally{this.tableScope.shortcutKeyEvent=void 0}a&&(e.preventDefault(),e.stopPropagation())}}emit(e){this.isDebug()&&console.debug("ShortcutService emit :",e);let t=!1;for(const s of this.listener)s.onActionTriggered(e)&&(t=!0);return t}findEntity(e){var s,o;let t=ra(e);(o=(s=this.tableScope).isRtl)!=null&&o.call(s)&&(t=zl(t)),this.isDebug()&&console.debug("ShortcutService shortcut :",t);for(const i in this.shortcutActionIdMapping)if(Ds(i)===t)return this.isDebug()&&console.debug("ShortcutService action :",this.shortcutActionIdMapping[i]),this.shortcutActionIdMapping[i]}getShortcutActionMapping(){return this.shortcutActionIdMapping}}class Fs{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}onScroll(e){}onSelectionChanged(e){}onFocusChanged(e){}onStateChanged(e){}onRowDragStart(e){}onRowDragMove(e){}onRowDragEnd(e){}onBatchEditChanged(e){}onDetailExpandedChanged(e){}onEditingChanged(e){}onUndoStackChanged(e){}onColumnResizeStart(e){}onColumnResizeEnd(e){}onColumnMoveStart(e){}onColumnMoveEnd(e){}onFilterChanged(e){}onCellActivated(e){}}class Vi{setStyle(e,t,s){return e.style[t]=s,e}appendText(e,t){const s=this.createText(t);return this.appendChild(e,s),s}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.add(s)):e.classList.add(t),e}removeClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.remove(s)):e.classList.remove(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,s){e.setAttribute(t,s)}removeAttribute(e,t){e.removeAttribute(t)}}const xd=null;function ls(n){return n==null||n===""}const yn=new Intl.Collator("en",{numeric:!0});function Cn(n){return typeof n=="number"||typeof n=="bigint"?0:n instanceof Date?1:typeof n=="boolean"?2:typeof n=="string"?3:4}function vn(n,e){const t=Cn(n),s=Cn(e);if(t!==s)return t-s;switch(t){case 0:{const o=n,i=e,r=typeof o=="number"&&Number.isNaN(o),l=typeof i=="number"&&Number.isNaN(i);return r||l?r===l?0:r?1:-1:o<i?-1:o>i?1:0}case 1:{const o=n.getTime(),i=e.getTime();return(Number.isNaN(o)?1/0:o)-(Number.isNaN(i)?1/0:i)||0}case 2:return(n?1:0)-(e?1:0);case 3:return yn.compare(n,e);default:return yn.compare(String(n),String(e))}}function io(n){return(e,t)=>{const s=ls(e),o=ls(t);return s||o?s===o?0:s?1:-1:n(e,t)}}function Rd(n,e){const t=typeof n=="string"||typeof n=="function"?{value:n}:n;if(!t||typeof t.value!="string"&&typeof t.value!="function")throw new Error(`Row grouping: level ${e} has no value (a property path or a function).`);const s=typeof t.value=="string"?t.value:void 0,o=t.order??"asc";let i;return o==="asc"?i=io(vn):o==="desc"?i=io((r,l)=>vn(l,r)):typeof o=="function"?i=io(o):i=io(()=>0),{name:t.name??s??`level${e}`,label:t.label,path:s,getKey:dt(t.value),format:t.format,compare:i}}function it(n){return(n??[]).map((e,t)=>Rd(e,t))}const Sn=new WeakMap;let Ad=1;function It(n){if(ls(n))return"empty";switch(typeof n){case"string":return"s:"+n;case"number":return"n:"+String(n);case"boolean":return"b:"+n;case"bigint":return"i:"+String(n);case"symbol":return"y:"+(n.description??"");case"function":case"object":{if(n instanceof Date)return"d:"+n.getTime();let e=Sn.get(n);return e===void 0&&(e=Ad++,Sn.set(n,e)),"o:"+e}default:return"u:"+String(n)}}function Ed(n,e){return ls(n)?e:n instanceof Date?Number.isNaN(n.getTime())?"Invalid Date":n.toLocaleDateString("en-US"):String(n)}function la(n,e){return n.map(t=>t.label??(t.path!==void 0?e(t.path):void 0)??t.name)}function aa(n,e){const t=la(it(n),s=>{var o;return(o=e.find(i=>i.property===s&&!ht(i)))==null?void 0:o.headerLabel});return t.length?t.join(" › "):"Group"}function Pi(n){var a,c;const e=n.getBodyModel();if(!ge(e))return!1;const t=n.getColumnDefs()??[],s=e.getGroupBy(),o=e.options.hideGroupedColumns===!1?[]:it(s).map(h=>h.path).filter(h=>h!==void 0&&t.some(d=>d.property===h&&!ht(d))),i=e.hiddenColumnProperties.filter(h=>o.includes(h));for(const h of e.hiddenColumnProperties)o.includes(h)||(a=n.setColumnVisible)==null||a.call(n,h,!0);for(const h of o)i.includes(h)||!Md(t,h)||((c=n.setColumnVisible)==null||c.call(n,h,!1),i.push(h));e.hiddenColumnProperties=i;const r=t.findIndex(ht),l=t[r];if(l&&ht(l)&&l.autoHeaderLabel){const h=aa(s,t);l.headerLabel=h;const d=n.getAreaModel("header"),u=d.getRowCount()-1;u>=0&&d.getValueAt(u,r)!==h&&d.setValue(u,r,h)}return!0}function Md(n,e){var t,s;return((s=(t=n.find(o=>o.property===e))==null?void 0:t.isVisible)==null?void 0:s.call(t))!==!1}const Je=class Je{createContent(e,t,s){return new Promise((o,i)=>{var r;if(t!=null&&t.hasSelection()){const l=t.isAllSelected()?new M(0,0,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER):this.mergeRanges(t.getRanges());if(l){l.c2=Math.min(l.c2,e.getColumnCount()-1),l.r2=Math.min(l.r2,e.getBodyModel().getRowCount()-1);const a=Math.max(0,l.r2-l.r1+1)*Math.max(0,l.c2-l.c1+1);if(a>Je.maxCopyCells)return i(`Cannot copy ${a} cells – more than CopyService.maxCopyCells (${Je.maxCopyCells}).`);const c=[];for(let h=l.r1;h<=l.r2;h++){const d=[];for(let u=l.c1;u<=l.c2;u++){const f=e.getColumnDef(u);if(((r=f==null?void 0:f.isVisible)==null?void 0:r.call(f))===!1)continue;const p=G(f)?f:void 0;if(p&&!p.options.exported)continue;const g=t.isSelected(h,u),m=e.getBodyModel(),b=g?p?p.getRowNumberText(h,m):m.getTextValueAt(h,u):"";d.push(b)}c.push(d.join(Je.columnSeparatorChar))}return o(c.join(Je.rowSeparatorChar))}}if(s){const[l,a]=s.getFocus(),c=e.getColumnDef(a),h=G(c)?c.getRowNumberText(l,e.getBodyModel()):e.getBodyModel().getTextValueAt(l,a);return o(h)}i("Cannot copy, neither selection nor focus defined.")})}copyContent(e){return navigator.clipboard.writeText(e)}copyToClipboard(e,t,s){return new Promise((o,i)=>{this.createContent(e,t,s).then(r=>{r?this.copyContent(r).then(l=>{o(r)}).catch(l=>{i()}):o("")}).catch(r=>{i()})})}mergeRanges(e){let t;for(const s of e)t?(t.r1=Math.min(t.r1,s.r1),t.c1=Math.min(t.c1,s.c1),t.r2=Math.max(t.r2,s.r2),t.c2=Math.max(t.c2,s.c2)):t=new M(s.r1,s.c1,s.r2,s.c2);return t}};Je.maxCopyCells=1e6,Je.columnSeparatorChar=" ",Je.rowSeparatorChar=`
47
+ render scope: this.lastFullVisibleRowIndex <- `+this.lastFullVisibleRowIndex),this.pruneRowDivCache(s),this.pruneRowDivCache(o),this.pruneRowDivCache(i),this.colAndRowspanModels&&this.colAndRowspanModels[e]){const A=((I=this.colAndRowspanModels[e])==null?void 0:I.getRanges())??[];if(A.length)for(const T of A){if(T.r1>=d||T.c1>=f)continue;let F=0,P=o.child,O="center";if(T.c1<g)P=s.child,O="west";else if(p>0&&T.c1>=f-p)P=i.child,O="east";else{const N=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();F=this.snapToDevicePixel(this.scrollFactorX*N)-this.areaBodyWestGeo.width,O="center"}this.drawBigCell(T,F,t,h,P,O)}}this.updateRowGroupRoles(s,o,i)}getFilterRowCount(){return 0}getAriaGridInfo(){return this.ariaGridInfo||(this.ariaGridInfo=Yt.create(this.tableModel,this.getFilterRowCount())),this.ariaGridInfo}applyRowAria(e,t,s,o,i=!0){var l,a;const r=this.dom.domService;if(r.setAttribute(e,"role","row"),r.setAttribute(e,"aria-rowindex",`${this.getAriaGridInfo().rowIndex(t,o)}`),!(t!=="body"||!i)){if(this.tree&&ee(s)){const c=this.treeAriaInfo.get(s,o);c&&(r.setAttribute(e,"aria-level",`${c.level}`),r.setAttribute(e,"aria-setsize",`${c.setSize}`),r.setAttribute(e,"aria-posinset",`${c.posInSet}`),c.expanded===void 0?this.dom.removeAttribute(e,"aria-expanded"):r.setAttribute(e,"aria-expanded",`${c.expanded}`))}if((l=this.masterDetailService)!=null&&l.isActive()&&(this.masterDetailService.isMasterAt(o)?r.setAttribute(e,"aria-expanded",`${this.masterDetailService.isExpandedAt(o)}`):e.hasAttribute("aria-expanded")&&this.dom.removeAttribute(e,"aria-expanded")),this.ariaSelectionKind==="row"){const c=(a=this.getSelectionModel)==null?void 0:a.call(this);r.setAttribute(e,"aria-selected",c&&c.getSelectionCount(o,0)>0?"true":"false")}else e.hasAttribute("aria-selected")&&this.dom.removeAttribute(e,"aria-selected")}}applyCellAria(e,t,s,o,i){var f,p;const r=this.dom.domService,l=this.getAriaGridInfo(),a=t==="header",c=t==="body"&&G(this.tableModel.getColumnDef(i))||t==="footer"&&pl(s)&&s.isLabelCell(o,i)||t==="body"&&ge(s)&&s.isGroupLabelCell(o,i)||!a&&!!((f=s.isRowHeaderCell)!=null&&f.call(s,o,i));r.setAttribute(e,"role",a?"columnheader":c?"rowheader":"gridcell");const h=l.colIndex(i);h>0&&r.setAttribute(e,"aria-colindex",`${h}`);const d=Math.max(1,s.getRowspanAt(o,i)||1),u=Math.max(1,s.getColspanAt(o,i)||1);if(u>1&&r.setAttribute(e,"aria-colspan",`${l.colSpan(i,u)}`),d>1&&r.setAttribute(e,"aria-rowspan",`${d}`),(d>1||u>1)&&this.renderedSpanCells.add(`${t}:${o}:${i}`),a&&o+d>=l.headerRowCount&&u===1){const g=this.tableModel.getColumnDef(i);if((p=g==null?void 0:g.sortable)!=null&&p.call(g)){const m=g.sortState;r.setAttribute(e,"aria-sort",m==="asc"?"ascending":m==="desc"?"descending":"none")}}return[d,u]}updateRowGroupRoles(...e){for(const t of e){let s=0;for(const i of Array.from(t.child.children)){if(!i.classList.contains("ge-table-row-div")||i.classList.contains("ge-table-span-row")){i.getAttribute("role")==="row"&&s++;continue}i.querySelector(':scope > [role="gridcell"], :scope > [role="columnheader"], :scope > [role="rowheader"]')?s++:i.getAttribute("role")==="row"&&(this.dom.domService.setAttribute(i,"role","presentation"),this.dom.removeAttribute(i,"aria-rowindex"))}const o=t.child.firstElementChild&&s?"rowgroup":"presentation";t.child.getAttribute("role")!==o&&this.dom.domService.setAttribute(t.child,"role",o)}}setHostAttribute(e,t){this.setHostAriaAttribute(e,t)}updateHostAria(){var i;const e=this.getAriaGridInfo();this.setHostAttribute("aria-rowcount",`${e.rowCount}`),this.setHostAttribute("aria-colcount",`${e.colCount}`);const t=(i=this.getSelectionModel)==null?void 0:i.call(this),s=this.ariaSelectionKind!=="none"&&(t==null?void 0:t.selectionMode)==="multi";this.setHostAttribute("aria-multiselectable",s?"true":void 0);const o=this.ariaFocusedCell;if(o){const r=this.ariaIds.cell(o.area,o.rowIndex,o.columnIndex);this.dom.domService.setAttribute(o.element,"id",r),this.setHostAttribute("aria-activedescendant",r)}else this.setHostAttribute("aria-activedescendant",void 0)}setAriaFocusedCell(e,t,s,o){const i=this.ariaFocusedCell;i&&i.area===t&&i.rowIndex===s&&i.columnIndex===o||(this.ariaFocusedCell={element:e,area:t,rowIndex:s,columnIndex:o})}getAriaSelectionKind(){var s;const e=(s=this.getSelectionModel)==null?void 0:s.call(this);if(!e)return"none";const t=e.selectionType;return t==="none"?"none":t==="row"?"row":"cell"}getColumnAriaLabel(e){const t=this.tableModel.getColumnDef(e);if(t!=null&&t.headerLabel)return`${t.headerLabel}`;const s=this.tableModel.getAreaModel("header"),o=(s==null?void 0:s.getRowCount())??0;if(o>0){const i=s.getValueAt(o-1,e),r=i&&typeof i=="object"&&"data"in i?i.data:i;if(typeof r=="string"&&r.trim()||typeof r=="number")return`${r}`}return(t==null?void 0:t.property)||`Column ${e+1}`}getCheckboxAriaLabel(e,t){return e==="header"?this.ariaTexts.selectAllRows():this.ariaTexts.selectRow(t+1)}labelControl(e,t){t&&!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&this.dom.domService.setAttribute(e,"aria-label",t)}labelRendererControls(e,t,s,o,i){if(hr(t)||e.classList.contains("ge-table-row-checkbox-div")){const l=e.querySelector("input.ge-table-row-checkbox");if(l){this.labelControl(l,this.getCheckboxAriaLabel(s,o));return}const a=e.querySelector("input.ge-input-checkbox");a&&this.labelControl(a,this.getColumnAriaLabel(i));return}const r=this.tableOptions.ariaTexts;if(s==="header"&&(r!=null&&r.expandGroup||r!=null&&r.collapseGroup)){const l=e.querySelector('.ge-table-toggle-icon-div[role="button"]');if(l){const a=l.getAttribute("data-ge-group-label")??"",c=l.getAttribute("aria-expanded")==="true";this.dom.domService.setAttribute(l,"aria-label",c?this.ariaTexts.collapseGroup(a):this.ariaTexts.expandGroup(a))}}}findCellDiv(e,t){for(const s of e){const o=s.querySelector(`:scope > .ge-table-col-div[data-col-index="${t}"]`);if(o)return o}}pruneRowDivCache(e){const t=e.cache;for(const s in t)t[s].parentNode!==e.child&&delete t[s]}drawBigCell(e,t,s,o,i,r){const l=s+(o.areaIdent==="body"?this.getBodyRowLayout().getTop(e.r1):this.getRowHeights(0,e.r1-1,o).reduce((w,y)=>w+y,0)),a=this.tableModel.getColumnCount(),c=this.tableModel.getFixedRightColumnCount();let h=0;c>0&&e.c1>=a-c&&(h=a-c);const d=t+this.getColumnWidths(h,e.c1-1).reduce((w,y)=>w+y,0),u=this.getRowHeights(e.r1,e.r2,o).reduce((w,y)=>w+y,0),f=this.getColumnWidths(e.c1,e.c2).reduce((w,y)=>w+y,0);let p=!1;const g=this.getSelectionModel?this.getSelectionModel():void 0;g&&(p=g.getSelectionCount(e.r1,e.c1)>0);const m=o.areaIdent,b=this.dom.applyStyle(this.dom.createDivWithClass("ge-table-span-row",i),{position:"absolute",left:"0",top:"0",width:"0",height:"0",overflow:"visible"});this.renderedSpanCells.has(`${m}:${e.r1}:${e.c1}`)?this.dom.setAriaHidden(b):this.applyRowAria(b,m,o,e.r1,!1),i=b,e.gammaRange?this.renderCell({areaModel:o,areaIdent:o.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:d,top:l,width:f,height:u,parent:i,cellSelected:p,lastRowOfModel:!0,gammaRange:e.gammaRange}):this.renderCell({areaModel:o,areaIdent:o.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:d,top:l,width:f,height:u,parent:i,cellSelected:p,lastRowOfModel:!0,gammaRange:e.gammaRange}),o.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.isColumnResizable(e.c1)&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:d,cellTop:l,cellWidth:f,cellHeight:u,parent:i})}findRowOfImportantRowspanCell(e,t,s){const o=e.getMaxRowspan();for(let i=t-1;i>-1;i--){const r=e.getRowspanAt(i,s);if(r>1&&i+r+1>=t)return i;if(t-i>o)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:s,geo:o,parent:i,rowIndex:r,columnIndexStart:l,columnIndexEnd:a,verticalFixed:c=!1,lastRowOfModel:h=!1}){var g;let d=0;if(!c){const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();d=this.snapToDevicePixel(this.scrollFactorX*m)}const u=0,f=!!(e==="body"&&t);let p=d;for(let m=l;m<=a;m++){const b=p,w=this.tableModel.getColumnWidth(m);if(w>0&&b+w>0){let y=o.height;const C=s.getRowspanAt(r,m),S=s.getColspanAt(r,m);C>1&&(y=this.getRowHeights(r,r+C-1,s).reduce((I,A)=>I+A,0));let x=w;S>1&&(x=this.getColumnWidths(m,m+S-1).reduce((I,A)=>I+A,0));let R=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(g=this.colAndRowspanModels[e])!=null&&g.isInRange(r,m)&&(R=!0),this.draggingTargetColumnIndex===m&&e!=="header"){this.renderDragTargetDiv(i,b,u,x,y);const I={left:b,top:u,width:x,height:y};this.dom.addColumnBorderDivs(this.tableOptions,i,I,e,t)}else{const I=this.renderSelectedBackgroundDiv(R,f,t,s,r,m,i,b,u,x,y);"gammaCells"in s&&s.getValueAt(r,m)&&(R=!1),R||this.renderCell({areaModel:s,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:m,left:b,top:u,width:x,height:y,parent:i,cellSelected:I,lastRowOfModel:h,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.isColumnResizable(m)&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:m,cellLeft:b,cellTop:u,cellWidth:x,cellHeight:y,parent:i})}}if(p=p+w,p>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new Ke(p-1,1,o.height,0),i)}getTreeArrowColumnIndex(){const e=this.getFirstDataColumnIndex();return this.tableOptions.showCheckboxWihoutExtraColumn?e:this.tableModel.isRowCheckboxVisible()?e+1:e}getFirstDataColumnIndex(){var e,t;return _s((t=(e=this.tableModel).getColumnDefs)==null?void 0:t.call(e))}isColumnResizable(e){var t;return((t=this.tableModel.getColumnDef(e))==null?void 0:t.resizable)!==!1}isColumnMovable(e){var t;return((t=this.tableModel.getColumnDef(e))==null?void 0:t.movable)!==!1}isFocusFrameVisible(){var t;const e=((t=this.tableOptions)==null?void 0:t.focusFrame)??"always";return e==="always"||e==="keyboard"&&this.keyboardModality}beforeRenderPass(){}adjustRowNumberColumnWidth(){var i,r;if(!this.getFirstDataColumnIndex()||this.tableModel.overridingColumnWidth>-1)return!1;const e=this.tableModel.getColumnDef(0),t=e.getWidestText(this.tableModel.getBodyModel()),s=this.rowNumberWidth;let o=(s==null?void 0:s.text)===t?s.width:-1;if(o<0||s!=null&&s.approximate&&this.findRowNumberLabel()){const[l,a]=this.measureRowNumberText(t);o=Math.max(e.options.minWidthInPx,l),this.rowNumberWidth={text:t,width:o,approximate:a}}return this.tableModel.getColumnWidth(0)===o||((r=(i=this.tableModel).isColumnVisible)==null?void 0:r.call(i,0))===!1?!1:(this.tableModel.setColumnWidth(0,o),this.tableModel.getColumnWidth(0)===o)}findRowNumberLabel(){return this.hostElement.querySelector(".ge-table-row-number .ge-table-label")}measureRowNumberText(e){const t=this.findRowNumberLabel(),s=getComputedStyle(t??this.hostElement),i=(t?(parseFloat(s.paddingLeft)||0)+(parseFloat(s.paddingRight)||0):12)+4,r=e.replace(/[0-9]/g,"0");let l=null;try{l=document.createElement("canvas").getContext("2d")}catch{l=null}return l?(l.font=s.font||`${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,[Math.ceil(l.measureText(r).width+i),!t]):[Math.ceil(e.length*8+i),!t]}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:o,index:i,left:r,width:l,height:a,top:c,parent:h,lastRowOfModel:d}){var $,me,te,le,Te;const u=t==="body"&&this.editorRenderer&&this.editorRendererRow===o&&this.editorRendererColumn===i,f=this.tableModel.getColumnDef(i),p=G(f),g=u?this.editorRenderer:(p&&t==="body"?f.rendererMap.body:void 0)??e.getCellRenderer(o,i),m={left:r,width:l,height:a,top:c,index:i},b=e.getRowByIndex(o);let w="none";if(i===this.getTreeArrowColumnIndex()&&J(b)){const H=b;("hasDisplayedChildren"in e&&typeof e.hasDisplayedChildren=="function"?e.hasDisplayedChildren(H):!!(($=H.children)!=null&&$.length))?H.expanded?w="expanded":w="collapsed":w="hidden"}let C;t==="header"&&(!(f!=null&&f.sortIconVisible)||f!=null&&f.sortIconVisible())&&(C=f==null?void 0:f.sortState);const S=t==="body"&&((me=this.batchEditService)!=null&&me.hasPending())?this.batchEditService.getPendingAt(o,i):void 0,x=S?S.newValue:e.getValueAt(o,i),R=g||p&&t==="footer"?"":`${x??""}`,I=e.isRowChecked(o),A=this.getFirstDataColumnIndex(),T=this.tableOptions.showCheckboxWihoutExtraColumn&&i===A&&I?this.getCheckboxAriaLabel(t,o):void 0,F=this.dom.addColumnDiv({parent:h,geo:m,rowIndex:o,columnIndex:i,areaIdent:t,sideIdent:s,text:R,treeArrow:w,tableOptions:this.tableOptions,checkedType:I,sortState:C,checkboxAriaLabel:T,firstDataColumnIndex:A}),[P,O]=this.applyCellAria(F,t,e,o,i),N=(S==null?void 0:S.error)||e.getTooltipAt(o,i);N&&this.dom.setAttribute(F,"title",N),S&&(this.dom.addClass("ge-table-cell-pending",F),S.error&&(this.dom.addClass("ge-table-cell-invalid",F),this.dom.setAttribute(F,"aria-invalid","true"))),f&&f.classes[t]&&this.dom.addClasses(f.classes[t],F);let K;if(g)if(K=g.render(F,o,i,t,e,x,this.dom.domService),u){const H=F.querySelector("input, select");if(H){this.labelControl(H,this.getColumnAriaLabel(i));const ae=this.editorDraft;if(ae&&ae.rowIndex===o&&ae.columnIndex===i&&H instanceof HTMLInputElement&&(H.value=ae.value,this.dom.setAttribute(H,"data-ge-restored","true")),H.contains(document.activeElement)||H.focus(),ae&&ae.rowIndex===o&&ae.columnIndex===i&&H instanceof HTMLInputElement&&ae.start!==null&&ae.end!==null)try{H.setSelectionRange(ae.start,ae.end)}catch{}}}else this.labelRendererControls(F,g,t,o,i);const Y=e.getCustomClassesAt(o,i);if(Y.length&&this.dom.addClasses(Y,F),t==="body"&&this.cellEditorService&&!p){e.isEditable(o,i)||this.dom.setAttribute(F,"aria-readonly","true");const H=this.cellEditorService.getOwnedEditorId(o,i);H&&this.dom.setAttribute(F,"aria-owns",H)}if(this.dom.addColumnBorderDivs(this.tableOptions,h,m,t,s),d&&this.dom.addHorizontalBorder({left:r,width:l,height:a,top:c+a},h),this.getFocusModel&&t==="body"&&!this.headerFocus){const H=this.getFocusModel();if(H!=null&&H.hasFocus(o,i))this.isFocusFrameVisible()&&this.dom.addFocusBorderDivs(h,m,{},!!((te=e.getTileLayout)!=null&&te.call(e))),this.setAriaFocusedCell(F,t,o,i);else if(H&&(P>1||O>1)){const[ae,je]=H.getFocus();ae>=o&&ae<o+P&&je>=i&&je<i+O&&this.setAriaFocusedCell(F,t,o,i)}}else t==="header"&&this.headerFocus&&this.headerFocus[0]===o&&this.headerFocus[1]===i&&(this.isFocusFrameVisible()&&this.dom.addFocusBorderDivs(h,m,{}),this.setAriaFocusedCell(F,t,o,i));t==="header"&&this.isColumnMovable(i)&&this.dom.setAttribute(F,"data-ge-action","drag-column"),t==="header"&&((le=this.columnFilterMenuService)!=null&&le.hasHeaderButtons())&&O===1&&o+P>=this.getAriaGridInfo().headerRowCount&&h.getAttribute("aria-hidden")!=="true"&&this.columnFilterMenuService.decorateHeaderCell(F,o,i),t==="body"&&((Te=this.masterDetailService)!=null&&Te.isActive())&&this.masterDetailService.decorateCell(F,o,i),t==="body"&&this.rowDragService&&!u&&(f!=null&&f.rowDrag&&this.rowDragService.decorateCell(F,this.rowDragService.getHandleState(o,f,e)),this.rowDragService.isDragSourceRow(o)&&this.dom.addClass("ge-table-row-dragging",F));const U=e.getCustomStyleAt(o,i);if(U)for(const H in U)this.dom.domService.setStyle(F,H,U[H]);return[F,K]}applyCssClasses(e,t={}){e&&Object.entries(t).forEach(([s,o])=>{o?this.dom.addClass(s,e):this.dom.removeClass(s,e)})}getColumnWidths(e,t){const s=[];for(let o=e;o<=t;o++)s.push(this.tableModel.getColumnWidth(o));return s}getRowHeights(e,t,s){const o=[];for(let i=e;i<=t;i++)o.push(s.getRowHeight(i));return o}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1&&e.areaIdent==="body"){const t=this.hostElement.clientWidth,s=this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex),o=this.contentScrollTop,i=e.rowTop+this.areaHeaderCenter.parent.clientHeight-o;this.dom.applyStyle(this.hoverRow,{left:"0",top:i+"px",width:t+"px",height:s+"px",display:"block"})}else this.hideHoverRow()}hideHover(){this.hideHoverRow(),this.hideHoverColumn()}hideHoverRow(){this.dom.applyStyle(this.hoverRow,{display:"none"})}adjustHoverColumns(e){if(this.tableOptions.hoverColumnVisible&&e.rowIndex>-1){const t=this.hostElement.clientHeight,s=this.tableModel.getColumnWidth(e.columnIndex),o=this.getColumnLeftInHost(e.columnIndex,e.columnLeft);this.dom.applyStyle(this.hoverColumn,{left:o+"px",top:"0px",width:s+"px",height:t+"px",display:"block"})}else this.hideHoverColumn()}getColumnLeftInHost(e,t){const s=this.tableModel.getColumnCount(),o=this.tableModel.getFixedLeftColumnCount(),i=this.tableModel.getFixedRightColumnCount();if(e<o)return t;if(i>0&&e>=s-i){const r=this.tableModel.getXPosByColumnIndex(s-i);return this.areaBodyEastGeo.left+t-r}return t-this.getContentScrollLeft()}getContentScrollLeft(){const e=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();return-this.snapToDevicePixel(this.scrollFactorX*e)}hideHoverColumn(){this.dom.applyStyle(this.hoverColumn,{display:"none"})}disposeRendering(){this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null);for(const e of["header","body","footer"])for(;this.cleanupFunctions[e].length;){const t=this.cleanupFunctions[e].shift();t&&t()}}debounce(e,t=1e3){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(()=>{this.debounceTimeout=null,e.call(this)},t)}adjustDraggingColumn(e,t,s){var o;if(this.dragging){const i=this.hostElement.clientHeight,r=this.tableModel.getColumnWidth(t);if((o=e.originalEvent)!=null&&o.clientX){const c={left:(this.isRtl()?this.clientXToHostX(e.originalEvent.clientX):e.originalEvent.clientX)-r/2,width:r,height:i,top:0,index:t};this.dom.applyStyle(this.draggingColumn,{background:"rgba(128,128,128,0.2)",display:"block",overflow:"hidden"}),this.dom.applyStyleInPx(this.draggingColumn,c),s&&this.renderContentOfDraggingColumn(c)}}else this.hideDraggingColumn()}renderContentOfDraggingColumn(e){const t=this.renderContentOfDraggingColumnForArea(e,"header",0),s=Math.max(0,this.firstVisibleRowIndex),o=t+this.getBodyRowTop(s)-this.contentScrollTop;this.renderContentOfDraggingColumnForArea(e,"body",o,s,this.hostElement.clientHeight)}renderContentOfDraggingColumnForArea(e,t,s=0,o=0,i=Number.POSITIVE_INFINITY){const r="center",l=this.tableModel.getAreaModel(t),a=l==null?void 0:l.getRowCount();if(a){const c=e.index??0,h=this.draggingColumn;for(let d=o;d<a&&s<i;d++){const u=s,f=l.getRowHeight(d),p={left:0,width:e.width,height:f,top:u,index:d},g=l.getValueAt(d,c),m=l.getCellRenderer(d,c),b=m?"":`${g??""}`,w={parent:h,geo:p,rowIndex:d,columnIndex:c,areaIdent:t,sideIdent:r,text:b},y=this.dom.addColumnDiv(w);let C;m&&(C=m.render(y,d,c,t,l,g,this.dom.domService),C&&this.cleanupFunctions[t].push(C));const S=l.getCustomClassesAt(d,c);S.length&&this.dom.addClasses(S,y);const x=this.tableModel.getColumnDef(c);x&&x.classes[t]&&this.dom.addClasses(x.classes[t],y),this.dom.addColumnBorderDivs(this.tableOptions,h,p,t,r);const R=l.getCustomStyleAt(d,c);if(R)for(const I in R)this.dom.domService.setStyle(y,I,R[I]);s=s+f}}return s}hideDraggingColumn(){this.dom.applyStyle(this.draggingColumn,{display:"none"})}renderDragTargetDiv(e,t,s,o,i){const r=this.dom.applyStylePosistionAbsolute(this.dom.setAriaHidden(this.dom.createDivWithClass("ge-table-drop-zone",e)));return this.dom.setStyle(r,"left",`${t}px`),this.dom.setStyle(r,"top",`${s}px`),this.dom.setStyle(r,"width",`${o}px`),this.dom.setStyle(r,"height",`${i}px`),r}renderSelectedBackgroundDiv(e,t,s,o,i,r,l,a,c,h,d){let u=!1;if(!e&&t&&o.isSelectable(i,r)&&this.getSelectionModel){const f=this.getSelectionModel();if(f){const p=f.getSelectionCount(i,r);u=p>0;for(let g=0;g<p;g++){const m=this.dom.applyStylePosistionAbsolute(this.dom.setAriaHidden(this.dom.createDivWithClass(`ge-table-${o.areaIdent}-${s}-selected-range`,l)));this.dom.setStyle(m,"left",`${a}px`),this.dom.setStyle(m,"top",`${c}px`),this.dom.setStyle(m,"width",`${h}px`),this.dom.setStyle(m,"height",`${d}px`)}}}return u}renderCell({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:o,columnIndex:i,left:r,top:l,width:a,height:c,parent:h,cellSelected:d,lastRowOfModel:u}){const[f,p]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:o,index:i,left:r,width:a,height:c,top:l,parent:h,lastRowOfModel:u});d&&this.dom.addClass(`ge-table-${t}-${s}-selected-range`,f),t==="body"&&this.ariaSelectionKind==="cell"&&this.dom.domService.setAttribute(f,"aria-selected",d?"true":"false"),p&&this.cleanupFunctions[t].push(p)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:s,cellTop:o,cellWidth:i,cellHeight:r,parent:l}){const a=this.dom.domService,c=this.tableOptions.columnResizeHandleWidthInPx??2,h=a.createElement("div");a.setAttribute(h,"data-col-index",`${t}`),a.setAttribute(h,"data-row-index",`${e}`),a.setAttribute(h,"data-area","header"),a.setAttribute(h,"data-ge-action","resize-column"),a.addClass(h,"ge-table-column-resize-handle"),a.setAttribute(h,"aria-hidden","true"),a.setStyle(h,"display","clip"),a.setStyle(h,"position","absolute"),a.setStyle(h,"cursor","col-resize"),this.dom.setStyle(h,"left",`${s+i-c}px`),a.setStyle(h,"top",`${o}px`),a.setStyle(h,"width",`${c}px`),a.setStyle(h,"height",`${r}px`),a.appendChild(l,h)}}class Is{constructor(e,t){this.columnIndex=e,this.sortState=t}}function md(n,e,t){const s=n.length;if(e<0||t<0||e>=s||t>=s||!n[e]||!n[t])return;if(e===t)return[];const o=[],i=[];for(let d=0;d<s;d++)n[d]&&(o.push(d),i.push(d));i.splice(o.indexOf(e),1),i.splice(o.indexOf(t),0,e);const r=Array.from({length:s},(d,u)=>u);o.forEach((d,u)=>{r[d]=i[u]});const l=[[e,t]],a=r.map((d,u)=>u);wn(a,e,t);const c=Math.min(e,t),h=Math.max(e,t);for(let d=c;d<=h;d++){const u=a.indexOf(r[d]);u!==d&&(l.push([u,d]),wn(a,u,d))}return l}function bd(n,e,t,s,o){const i=Math.max(s,t-o);let r=0,l=t-1;return n<s?l=s-1:n>=i?r=i:(r=s,l=i-1),Math.min(Math.max(e,r),l)}function wd(n,e,t){if(!t.size)return n;const s=n.filter(o=>!t.has(o));return e.forEach((o,i)=>{t.has(o)&&s.splice(Math.min(i,s.length),0,o)}),s}function wn(n,e,t){const[s]=n.splice(e,1);n.splice(t,0,s)}const Jl=new WeakSet;function yd(n){return Jl.add(n),n}function Zl(n){return typeof n=="function"&&Jl.has(n)}class Ql{constructor(e,t){this.state=e,this.changedParts=t}}const rt=Object.freeze(["headerGroups","columns","filters","tree","sort","checked","selection","details","scroll","custom"]),Cd=["sortingState","scrollState","collapsedExpandedState"];function gi(n,e){try{const t=n.getItem(e);return t?JSON.parse(t):void 0}catch{return}}function ea(n,e,t){const s={version:1};let o=!1;const i=gi(n,e+"sortingState");Array.isArray(i)&&(o=!0,s.sort=i.filter(a=>a&&typeof a.columnIndex=="number"&&(a.sortState==="asc"||a.sortState==="desc")).map(a=>{const c=t[a.columnIndex],h=a.sortState;return c?{property:c,sortState:h}:{columnIndex:a.columnIndex,sortState:h}}));const r=gi(n,e+"scrollState");Array.isArray(r)&&typeof r[0]=="number"&&typeof r[1]=="number"&&(o=!0,s.scroll={left:r[0],top:r[1]});const l=gi(n,e+"collapsedExpandedState");if(l&&typeof l=="object"){o=!0;let a;l.allExpanded?a={collapsedRowIds:[]}:l.allCollapsed?a={expandedRowIds:[]}:l.mode==="expanded"?a={expandedRowIds:l.rowIds??[]}:a={collapsedRowIds:l.rowIds??[]},s.tree=a}return o?s:void 0}function Ni(n,e){for(const t of Cd)try{n.removeItem(e+t)}catch{}}const vd={headerGroups:"autoRestoreHeaderGroupState",columns:"autoRestoreColumnLayout",tree:"autoRestoreCollapsedExpandedState",sort:"autoRestoreSortingState",checked:"autoRestoreCheckedState",selection:"autoRestoreSelectedState",scroll:"autoRestoreScrollPosition",custom:"autoRestoreCustomState",details:"autoRestoreDetailState",filters:"autoRestoreFilterState"},St=n=>n==="checked"?"checkedRowIds":n==="details"?"detailRowIds":n,Ye=Number.MAX_SAFE_INTEGER,qe=class qe{constructor(e){this.scope=e,this.restoring=!1,this.started=!1,this.destroyed=!1,this.dirty=new Set,this.lastReported=new Map,this.reported={version:1},this.legacyRemoved=!1,this.sortPriority=[],this.initialWidths=new Map,this.startState={},this.custom=void 0,this.warnedNoRowObject=!1,this.warnedNoId=!1,this.warnWithoutStorageKey()}initBeforeModel(){this.started||(this.started=!0,this.restoring=!0,this.startState=this.readStartState(),this.defaultState={version:1},this.computePart("headerGroups",this.defaultState),this.startState.headerGroups&&this.applyHeaderGroups(this.startState.headerGroups))}initAfterModel(){if(!this.restoring)return;for(const s of this.columnDefs())this.initialWidths.set(s,s.width);this.sortPriority=this.columnDefs().filter(s=>s.sortState&&s.property).map(s=>s.property);const e=s=>this.persistedParts().includes(s)||this.startState[St(s)]!==void 0,t=this.getState(rt.filter(s=>s!=="headerGroups"&&s!=="scroll"&&s!=="custom"&&(!qe.EXPENSIVE.includes(s)||e(s))));this.defaultState={...this.defaultState,...t,scroll:{left:0,top:0}},this.startState.columns&&this.applyColumns(this.startState.columns,!1),this.startState.filters&&this.scope.columnFilterService.applyStateFilters(this.startState.filters,!1),typeof this.startState.filterRowVisible=="boolean"&&this.scope.restoreFilterRowVisible(this.startState.filterRowVisible)}initAfterFilter(){if(!this.restoring)return;const e=this.startState;e.tree&&this.applyTree(e.tree),e.sort&&this.applySort(e.sort),e.checkedRowIds&&this.applyChecked(e.checkedRowIds),e.selection&&this.applySelection(e.selection),e.detailRowIds&&this.applyDetails(e.detailRowIds),"custom"in e&&(this.custom=e.custom)}initAfterLayout(){this.restoring&&(this.startState.scroll&&this.applyScroll(this.startState.scroll),this.restoring=!1,this.rememberAsReported(this.getState(rt.filter(e=>!qe.EXPENSIVE.includes(e)))))}getState(e=rt){const t={version:1};for(const s of e)this.computePart(s,t);return t}applyState(e,t=rt){if(!e||typeof e!="object")return;const s=r=>t.includes(r)&&e[St(r)]!==void 0,o=[];let i=!1;if(s("headerGroups")&&this.applyHeaderGroups(e.headerGroups)&&o.push("headerGroups"),s("columns")&&(i=this.applyColumns(e.columns,!0),o.push("columns")),t.includes("filters")&&(e.filters!==void 0||typeof e.filterRowVisible=="boolean")){let r=!1;e.filters!==void 0&&this.scope.columnFilterService.applyStateFilters(e.filters,!0)&&(r=!0),typeof e.filterRowVisible=="boolean"&&this.scope.restoreFilterRowVisible(e.filterRowVisible)&&(r=!0),r&&o.push("filters")}s("tree")&&(this.applyTree(e.tree),o.push("tree")),s("sort")&&(this.applySort(e.sort),o.push("sort")),s("checked")&&(this.applyChecked(e.checkedRowIds),o.push("checked")),s("selection")&&(this.applySelection(e.selection),o.push("selection")),s("details")&&(this.applyDetails(e.detailRowIds),o.push("details")),t.includes("custom")&&"custom"in e&&(this.custom=e.custom,o.push("custom")),o.includes("headerGroups")?this.scope.headerGroupsChanged():i?this.scope.recalcColumnWidths():o.length&&(this.scope.tableModel.recalcHeightAndPadding(),this.scope.recalcWrappers(),this.scope.repaintHard()),s("scroll")&&(this.applyScroll(e.scroll),o.push("scroll")),o.forEach(r=>this.markDirty(r))}resetState(){if(!this.defaultState)return;const e=this.scope.columnFilterService.hasActiveFilters()?{...this.defaultState,filters:this.defaultState.filters??{}}:this.defaultState;this.applyState(e),this.custom=void 0,this.markDirty("custom"),this.flush();const t=this.storageKey(),s=this.storage();if(t&&s)try{s.removeItem(t+qe.STORAGE_SUFFIX),Ni(s,t)}catch{}this.lastPersisted=void 0}setCustomState(e){this.custom=e,this.markDirty("custom")}sortedByColumn(e){this.sortPriority=e?[e]:[],this.markDirty("sort")}markDirty(e){!this.started||this.restoring||this.destroyed||(this.dirty.add(e),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.flush(),this.scope.tableOptions.stateChangedDebounceDelay??300))}rendered(){if(this.restoring||!this.started)return;const e=this.scope.scrollViewport,t=this.reportedScroll;(!t||t.left!==this.scope.getViewportScrollLeft()||t.top!==e.scrollTop)&&this.markDirty("scroll")}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),!this.dirty.size||!this.started||this.restoring)return;this.persistedParts().includes("checked")&&this.dirty.add("checked");const e=rt.filter(t=>this.dirty.has(t));this.dirty.clear();try{const t=this.getState(e),s=e.filter(i=>this.partJson(t,i)!==this.lastReported.get(i));if(!s.length)return;const o={...this.reported};for(const i of e){const r=St(i);t[r]===void 0?delete o[r]:o[r]=t[r],i==="filters"&&(t.filterRowVisible===void 0?delete o.filterRowVisible:o.filterRowVisible=t.filterRowVisible),this.lastReported.set(i,this.partJson(t,i))}this.reported=o,t.scroll&&(this.reportedScroll={left:t.scroll.left,top:t.scroll.top}),this.persist(o),this.scope.stateChanged(new Ql(JSON.parse(JSON.stringify(o)),s))}catch(t){console.error("GuiExpert Table: the table state could not be stored or reported",t)}}destroy(){if(!this.destroyed){this.started&&!this.restoring&&this.persistedParts().includes("checked")&&this.dirty.add("checked");try{this.flush()}finally{this.destroyed=!0}}}storageKey(){var s;const e=(s=this.scope.tableOptions.autoRestoreOptions)==null?void 0:s.getStorageKeyFn;return(e?e():void 0)||void 0}storage(){var t;const e=(t=this.scope.tableOptions.autoRestoreOptions)==null?void 0:t.storage;if(e)return e;try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}persistedParts(){const e=this.scope.tableOptions.autoRestoreOptions;return e?rt.filter(t=>!!e[vd[t]]):[]}warnWithoutStorageKey(){this.scope.tableOptions.autoRestoreOptions&&this.persistedParts().length&&!this.storageKey()&&console.warn("GuiExpert Table: autoRestoreOptions are ignored without getStorageKeyFn (nothing is stored).")}readStartState(){const e=this.scope.tableOptions.initialState??{},t=this.persistedParts(),s=this.storageKey(),o=this.storage();if(!t.length||!s||!o)return{...e};let i;try{const l=o.getItem(s+qe.STORAGE_SUFFIX);if(l){const a=JSON.parse(l);a&&typeof a=="object"&&a.version===1&&(i=a,this.lastPersisted=l)}}catch{}i||(i=ea(o,s,this.columnDefs().map(l=>l.property)));const r={...e};if(i)for(const l of t){const a=St(l);a in i&&(r[a]=i[a]),l==="filters"&&"filterRowVisible"in i&&(r.filterRowVisible=i.filterRowVisible)}return r}persist(e){const t=this.persistedParts(),s=this.storageKey(),o=this.storage();if(!t.length||!s||!o)return;const i={version:1};for(const l of t){const a=St(l);e[a]!==void 0&&(i[a]=e[a]),l==="filters"&&e.filterRowVisible!==void 0&&(i.filterRowVisible=e.filterRowVisible)}const r=JSON.stringify(i);if(r!==this.lastPersisted)try{o.setItem(s+qe.STORAGE_SUFFIX,r),this.lastPersisted=r,this.legacyRemoved||(Ni(o,s),this.legacyRemoved=!0)}catch{}}rememberAsReported(e){this.reported=e,e.scroll&&(this.reportedScroll={left:e.scroll.left,top:e.scroll.top});for(const t of rt)(St(t)in e||t==="filters"&&"filterRowVisible"in e)&&this.lastReported.set(t,this.partJson(e,t))}partJson(e,t){if(t==="filters")return e.filters===void 0&&e.filterRowVisible===void 0?"":JSON.stringify({filters:e.filters,filterRowVisible:e.filterRowVisible});const s=e[St(t)];return s===void 0?"":JSON.stringify(s)}computePart(e,t){var s,o;switch(e){case"headerGroups":{const i=(s=this.headerGroupModel())==null?void 0:s.getToggleGroupStates();i!=null&&i.length&&(t.headerGroups=i);break}case"columns":{const i=this.computeColumns();i&&(t.columns=i);break}case"sort":{const i=this.computeSort();i&&(t.sort=i);break}case"scroll":t.scroll=this.computeScroll();break;case"tree":{const i=this.computeTree();i&&(t.tree=i);break}case"checked":{const i=this.computeChecked();i&&(t.checkedRowIds=i);break}case"selection":{const i=this.computeSelection();i&&(t.selection=i);break}case"custom":this.custom!==void 0&&(t.custom=this.custom);break;case"details":{const i=this.computeDetails();i&&(t.detailRowIds=i);break}case"filters":{(o=this.scope.columnFilterService)!=null&&o.hasActiveFilters()&&(t.filters=this.scope.columnFilterService.getColumnFilters()),this.scope.hasFilterRow()&&(t.filterRowVisible=this.scope.isFilterRowVisible());break}}}computeColumns(){const e=this.columnDefs();if(!e.length)return;const t=new Set,s=[];for(const o of e){if(!o.property||t.has(o.property))continue;t.add(o.property);const i={property:o.property},r=this.initialWidths.get(o);r&&o.width&&(r.value!==o.width.value||r.unit!==o.width.unit)&&o.width.unit==="px"&&(i.width=o.width.value),i.visible=at(o),s.push(i)}return s}computeSort(){const e=this.columnDefs();if(!e.length)return;const t=s=>{const o=this.sortPriority.indexOf(s.property);return o<0?Ye:o};return e.filter(s=>s.sortState&&s.property).map((s,o)=>({cd:s,index:o})).sort((s,o)=>t(s.cd)-t(o.cd)||s.index-o.index).map(({cd:s})=>({property:s.property,sortState:s.sortState}))}computeScroll(){const e=this.scope.scrollViewport,t={left:this.scope.getViewportScrollLeft(),top:e.scrollTop},s=this.scope.getFirstVisibleRowIndex(),o=this.scope.getTileLayout();if(o){const i=s>-1?this.tileIdAt(o,s*o.getTilesPerRow()):void 0;i!==void 0&&(t.firstRowId=i)}else if(s>-1&&this.body().getRowCount()>0){const i=this.idAt(s,this.warns("scroll"));i!==void 0&&(t.firstRowId=i)}return t}computeTree(){const e=this.body();if(!ee(e))return;const t=[],s=[],o=this.warns("tree");return this.walkTree(e,i=>{var r;if((r=i.children)!=null&&r.length){const l=this.idOfRow(i,-1,o);l!==void 0&&(i.expanded?t:s).push(l)}}),t.length<=s.length?{expandedRowIds:t}:{collapsedRowIds:s}}computeChecked(){const e=this.body().rowSelectionModel;if(!e)return;const t=this.warns("checked"),s=[];for(const o of e.getCheckedRows()??[]){const i=this.idOfRow(o,-1,t);i!==void 0&&s.push(i)}return s}computeDetails(){const e=this.scope.masterDetailService;if(!(e!=null&&e.isActive()))return;const t=this.warns("details"),s=[];for(const o of e.getExpandedRows()){const i=this.idOfRow(o,-1,t);i!==void 0&&s.push(i)}return s}applyDetails(e){const t=this.scope.masterDetailService;if(!(t!=null&&t.isActive())||!Array.isArray(e))return;const s=new Set(e),o=this.body(),i=o,r=i.getAllRows?i.getAllRows():Array.from({length:o.getRowCount()},(l,a)=>o.getRowByIndex(a));t.setExpandedRows(r.filter((l,a)=>{const c=this.idOfRow(l,i.getAllRows?-1:a,!1);return c!==void 0&&s.has(c)}),"state")}computeSelection(){const e=this.scope.selectionModel();if(!e||!e.selectionType||e.selectionType==="none")return;const t=e.createSnapshot?e.createSnapshot():{ranges:e.getRanges(),negativeRanges:[],allSelected:e.isAllSelected()},s=this.warns("selection"),o=r=>r.map(l=>this.toStateRange(l,s)).filter(l=>!!l),i={ranges:o(t.ranges)};return t.negativeRanges.length&&(i.negativeRanges=o(t.negativeRanges)),t.allSelected&&(i.allSelected=!0),i}toStateRange(e,t){var a,c;const s={},o=Math.min(e.r1,e.r2),i=Math.max(e.r1,e.r2);if(!(o<=0&&i>=Ye)){const h=this.idAt(o,t);if(h===void 0)return;if(s.fromRowId=h,i<Ye){const d=this.idAt(i,t);if(d===void 0)return;s.toRowId=d}}const r=Math.min(e.c1,e.c2),l=Math.max(e.c1,e.c2);if(!(r<=0&&l>=Ye)){const h=this.columnDefs(),d=(a=h[r])==null?void 0:a.property;if(!d)return;if(s.fromProperty=d,l<Ye){const u=(c=h[l])==null?void 0:c.property;if(!u)return;s.toProperty=u}}return s}applyHeaderGroups(e){const t=this.scope.tableModel.getAreaModel("header");if(!t.setGroupClosed||!t.getToggleGroupStates||!Array.isArray(e))return!1;const s=new Map(t.getToggleGroupStates().map(i=>[i.id,i.closed]));let o=!1;for(const i of e)if(i&&s.has(i.id)&&s.get(i.id)!==!!i.closed){const r=t.setGroupClosed(i.id,!!i.closed);r&&"columnDefs"in this.scope.tableModel&&(this.scope.tableModel.columnDefs=r),o=!0}return o}applyColumns(e,t){const s=this.scope.tableModel,o=this.columnDefs();if(!o.length||!Array.isArray(e))return!1;const i=new Map;for(const u of e)u&&typeof u.property=="string"&&!i.has(u.property)&&o.some(f=>f.property===u.property)&&i.set(u.property,u);const r=o.map(u=>u.property),l=Array.from(i.keys()),a=new Set;r.forEach((u,f)=>{if(i.has(u)&&!a.has(u)){a.add(u);return}const p=f>0?l.lastIndexOf(r[f-1]):-1;l.splice(p+1,0,u)});const c=wd(l,r,new Set(o.filter(u=>u.movable===!1).map(u=>u.property)));for(let u=0;u<c.length;u++){const p=s.getColumnDefs().map(g=>g.property).indexOf(c[u],u);p>u&&s.changeColumnOrder(p,u)}let h=!1;return this.columnDefs().forEach((u,f)=>{var g;const p=i.get(u.property);if(p){if(typeof p.visible=="boolean"&&at(u)!==p.visible&&((g=s.setColumnVisible)==null||g.call(s,f,p.visible)),typeof p.width=="number"&&p.width>=0)s.setColumnWidth(f,p.width);else if(t){const m=this.initialWidths.get(u);m&&(m.value!==u.width.value||m.unit!==u.width.unit)&&(m.unit==="px"?s.setColumnWidth(f,m.value):h=!0,u.width=m)}}}),h}applyTree(e){const t=this.body();if(!ee(t)||!e)return;const s=Array.isArray(e.expandedRowIds);if(!s&&!Array.isArray(e.collapsedRowIds))return;const o=new Set((s?e.expandedRowIds:e.collapsedRowIds)??[]),i=t;this.walkTree(i,r=>{var l;if((l=r.children)!=null&&l.length){const a=this.idOfRow(r,-1,!1);a!==void 0&&(r.expanded=s?o.has(a):!o.has(a))}}),i.recalcVisibleTreeRows(!1)}applySort(e){var i;if(!Array.isArray(e))return;const t=this.columnDefs(),s=[],o=[];for(const r of e){if(!r||r.sortState!=="asc"&&r.sortState!=="desc")continue;const l=typeof r.property=="string"?t.findIndex(a=>a.property===r.property):typeof r.columnIndex=="number"?r.columnIndex:-1;l<0||l>=this.scope.tableModel.getColumnCount()||s.some(a=>a.columnIndex===l)||(s.push(new Is(l,r.sortState)),(i=t[l])!=null&&i.property&&o.push(t[l].property))}this.scope.applySortItems(s),this.sortPriority=o}applyChecked(e){const t=this.body(),s=t.rowSelectionModel;if(!s||!Array.isArray(e))return;const o=new Set(e);if(ee(t)){const l=t;this.walkTree(l,a=>{a.checked=!1}),this.walkTree(l,a=>{const c=this.idOfRow(a,-1,!1);c!==void 0&&o.has(c)&&!a.checked&&s.checkRow(a,!0)});return}const i=t,r=i.getAllRows?i.getAllRows():Array.from({length:t.getRowCount()},(l,a)=>t.getRowByIndex(a));s.setCheckedRows(r.filter((l,a)=>{const c=this.idOfRow(l,i.getAllRows?-1:a,!1);return c!==void 0&&o.has(c)}))}applySelection(e){const t=this.scope.selectionModel();if(!t||!e||!Array.isArray(e.ranges))return;const o=[...e.ranges,...e.negativeRanges??[]].some(c=>c&&(c.fromRowId!==void 0||c.toRowId!==void 0))?this.rowIndexMap():new Map,i=this.columnDefs(),r=c=>{if(!c)return;let h=0,d=Ye,u=0,f=Ye;if(c.fromRowId!==void 0||c.toRowId!==void 0){const p=o.get(c.fromRowId??c.toRowId),g=c.toRowId===void 0?Ye:o.get(c.toRowId);if(p===void 0||g===void 0)return;h=Math.min(p,g),d=Math.max(p,g)}if(c.fromProperty!==void 0||c.toProperty!==void 0){const p=i.findIndex(m=>m.property===(c.fromProperty??c.toProperty)),g=c.toProperty===void 0?Ye:i.findIndex(m=>m.property===c.toProperty);if(p<0||g<0)return;u=Math.min(p,g),f=Math.max(p,g)}return new M(h,u,d,f)},l=c=>(c??[]).map(r).filter(h=>!!h),a={ranges:l(e.ranges),negativeRanges:l(e.negativeRanges),allSelected:!!e.allSelected};t.restoreSnapshot?t.restoreSnapshot(a):(t.clear(),a.ranges.forEach(c=>t.addSelection(c)))}applyScroll(e){if(!e||typeof e.top!="number"||typeof e.left!="number"||(this.scope.scrollViewport.scrollTo(kr(e.left,this.scope.isRtl()),e.top),this.scope.adjustAfterScrolling(),e.firstRowId===void 0))return;const t=this.scope.getTileLayout();if(t){this.applyTileScroll(t,e.firstRowId);return}const s=this.scope.getFirstVisibleRowIndex();if(s>-1&&this.idAt(s,!1)===e.firstRowId)return;const o=this.rowIndexMap().get(e.firstRowId);o!==void 0&&(this.scope.scrollToIndex(-1,o),this.scope.adjustAfterScrolling())}applyTileScroll(e,t){const s=e.getTilesPerRow(),o=e.getTileCount(),i=this.scope.getFirstVisibleRowIndex();if(i>-1){for(let r=i*s,l=Math.min(o,(i+1)*s);r<l;r++)if(this.tileIdAt(e,r)===t){this.scope.anchorTileScroll(r);return}}for(let r=0;r<o;r++)if(this.tileIdAt(e,r)===t){this.scope.scrollToIndex(-1,Math.floor(r/s)),this.scope.adjustAfterScrolling(),this.scope.anchorTileScroll(r);return}}columnDefs(){return this.scope.tableModel.getColumnDefs()??[]}body(){return this.scope.tableModel.getBodyModel()}headerGroupModel(){const e=this.scope.tableModel.getAreaModel("header");return e&&typeof e.getToggleGroupStates=="function"?e:void 0}warns(e){return this.persistedParts().includes(e)}ownGetRowId(){var t;const e=(t=this.scope.tableOptions.autoRestoreOptions)==null?void 0:t.getRowId;return e&&!Zl(e)?e:void 0}tileIdAt(e,t){if(!(t<0||t>=e.getTileCount()))return this.idOfRow(e.getTileAt(t),t,!1)}idAt(e,t){return this.idOfRow(this.body().getRowByIndex(e),e,t)}idOfRow(e,t,s){const o=this.ownGetRowId();if(e==null){if(o&&o.length>=2&&t>-1)return o(void 0,t);s&&!this.warnedNoRowObject&&(this.warnedNoRowObject=!0,console.warn("GuiExpert Table: the body model has no row objects – these rows are not stored. Set autoRestoreOptions.getRowId = (_row, rowIndex) => rowIndex to store them by index."));return}const i=J(e)?e.data:e;if(Se(i))return i.id;if(o)return o(i,t);if(i&&typeof i=="object")for(const r of["id","uuid"]){const l=i[r];if(typeof l=="string"||typeof l=="number")return l}s&&!this.warnedNoId&&(this.warnedNoId=!0,console.warn("GuiExpert Table: rows without 'id' or 'uuid' are not stored – set autoRestoreOptions.getRowId."))}rowIndexMap(){const e=this.body(),t=new Map,s=e.getRowCount();for(let o=0;o<s;o++){const i=this.idAt(o,!1);i!==void 0&&!t.has(i)&&t.set(i,o)}return t}walkTree(e,t){const s=o=>o==null?void 0:o.forEach(i=>{t(i),s(i.children)});s(e.rows)}};qe.STORAGE_SUFFIX="tableState",qe.EXPENSIVE=["tree","checked","selection"];let vo=qe;class ta{constructor(e){this.tableScope=e,this.tableScope.hostElement.addEventListener("change",this.onHostElementChanged.bind(this),{signal:this.tableScope.listenerAbortController.signal}),this.tableScope.hostElement.addEventListener("keydown",this.onHostElementKeyDown.bind(this),{signal:this.tableScope.listenerAbortController.signal}),this.tableScope.hostElement.addEventListener("input",this.onHostElementInput.bind(this),{signal:this.tableScope.listenerAbortController.signal}),this.tableScope.hostElement.addEventListener("focusout",this.onHostElementFocusOut.bind(this),{signal:this.tableScope.listenerAbortController.signal})}onHostElementFocusOut(e){var s,o;const t=e.target;t instanceof HTMLInputElement&&t.isConnected&&t.getAttribute("data-ge-restored")==="true"&&((o=(s=this.tableScope).getInCellEditorCell)!=null&&o.call(s))&&this.commitInCellEditor(t)}commitInCellEditor(e){const t=Number(e.getAttribute("data-row-index")),s=Number(e.getAttribute("data-col-index"));this.tableScope.updateModelValueAfterEdit("body",t,s,e.value)}onHostElementInput(e){const t=e.target;if(!this.tableScope.isEditing()||!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)||t.getAttribute("data-area")!=="body")return;const s=Number(t.getAttribute("data-row-index")),o=Number(t.getAttribute("data-col-index"));this.tableScope.setEditorDraft(s,o,t)}onHostElementKeyDown(e){var o,i,r,l;if((i=(o=this.tableScope).isEventInDetail)!=null&&i.call(o,e)||(l=(r=this.tableScope).isEventInFilterUI)!=null&&l.call(r,e)||!this.tableScope.isEditing())return;const t=e.target;if(e.key==="Enter"&&!e.isComposing&&e.keyCode!==229&&t instanceof HTMLInputElement&&t.getAttribute("data-area")==="body"&&t.getAttribute("data-ge-restored")==="true"){e.preventDefault(),this.commitInCellEditor(t);return}if(e.key!=="Escape")return;const s=e.target;(s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement)&&s.getAttribute("data-area")==="body"&&(e.preventDefault(),e.stopPropagation(),this.tableScope.cancelEditing(s))}onHostElementChanged(e){var t,s,o,i,r,l;if(!((s=(t=this.tableScope).isEventInDetail)!=null&&s.call(t,e)||(i=(o=this.tableScope).isEventInFilterUI)!=null&&i.call(o,e))&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLTextAreaElement)){const a=e.target,c=a.getAttribute("data-area"),h=a.getAttribute("data-row-index"),d=a.getAttribute("data-col-index");if((a.classList.contains("ge-table-cell-editor-input")||a.classList.contains("ge-table-cell-editor-select"))&&!((l=(r=this.tableScope).getInCellEditorCell)!=null&&l.call(r)))return;if(c&&h&&d){const f=ss(c),p=Number(h),g=Number(d);this.tableScope.updateModelValueAfterEdit(f,p,g,a.value)}}}}class sa{constructor(e,t,s,o,i,r,l,a){this.scrollTop=e,this.scrollLeft=t,this.scrollHeight=s,this.scrollWidth=o,this.clientHeight=i,this.clientWidth=r,this.scrollFactorY=l,this.scrollFactorX=a}}class De{constructor(e){this.tableScope=e,this.ignoreNextClick=!1,this.anchorRanges=[],this.getSelectionModel=()=>this.tableScope.selectionModel(),this.getFocusModel=()=>this.tableScope.focusModel()}onMouseDown(){this.ignoreNextClick=!1,this.dragSnapshot=void 0}onMouseDragging(e,t){var o;if(!t||t.action||t.areaIdent!=="body"||e.areaIdent!=="body"||t.rowIndex<0||t.columnIndex<0||e.rowIndex<0||e.columnIndex<0)return!1;const s=(o=this.getSelectionModel)==null?void 0:o.call(this);return!s||!("selectionType"in s)||s.selectionType!=="range"?!1:(this.batch(()=>{var l,a,c;!!((l=t.originalEvent)!=null&&l.ctrlKey||(a=t.originalEvent)!=null&&a.metaKey)&&De.hasSnapshots(s)?(this.dragSnapshot=this.dragSnapshot??s.createSnapshot(),s.restoreSnapshot(this.dragSnapshot)):s.clear(),s.addSelection(this.createRangeByEvents(e,t));const r=(c=this.getFocusModel)==null?void 0:c.call(this);r&&!r.hasFocus(t.rowIndex,t.columnIndex)&&r.setFocus(t.rowIndex,t.columnIndex),this.previousEvt=t.clone(),this.anchor=[t.rowIndex,t.columnIndex],this.extent=[e.rowIndex,e.columnIndex],this.anchorRanges=[],this.ignoreNextClick=e.rowIndex!==t.rowIndex||e.columnIndex!==t.columnIndex,this.tableScope.onSelectionChanged(s)}),!0)}onMouseClicked(e,t){var o,i;if(this.ignoreNextClick)return this.ignoreNextClick=!1,!1;if(e.areaIdent==="header"&&e.clickCount===1&&this.isRowNumberColumn(e.columnIndex)&&e.rowIndex===this.tableScope.tableModel.getAreaModel("header").getRowCount()-1)return this.selectAllByRowNumberHeader();if(e.areaIdent==="header"&&e.clickCount===1&&e.columnIndex>-1&&this.isColumnLetterCell(e))return this.clickColumnLetter(e);if(e.areaIdent!=="body"||e.rowIndex<0||e.columnIndex<0||e.clickCount>1||((i=(o=this.tableScope).canFocusBodyCell)==null?void 0:i.call(o,e.rowIndex,e.columnIndex))===!1)return!1;let s=!1;if(this.getSelectionModel&&this.getFocusModel){const r=this.getSelectionModel(),l=this.getFocusModel();r&&l&&(this.batch(()=>{var f,p,g,m;l.hasFocus(e.rowIndex,e.columnIndex)||l.setFocus(e.rowIndex,e.columnIndex);const a=!!((f=e.originalEvent)!=null&&f.shiftKey),c=!!((p=e.originalEvent)!=null&&p.ctrlKey||(g=e.originalEvent)!=null&&g.metaKey),h=!!((m=e.originalEvent)!=null&&m.altKey),d=this.isRowNumberColumn(e.columnIndex)&&De.isRangeSelection(r);if(a&&(this.anchor||this.previousEvt)){if(this.anchorRanges.length&&De.hasSnapshots(r)){const C=r.createSnapshot();r.restoreSnapshot({...C,ranges:C.ranges.filter(S=>!this.anchorRanges.includes(S))})}const[b,w]=this.anchor??[this.previousEvt.rowIndex,this.previousEvt.columnIndex],y=De.rangeBetween(e.rowIndex,e.columnIndex,b,w);this.extent=[e.rowIndex,e.columnIndex],d&&(y.c1=0,y.c2=Number.MAX_SAFE_INTEGER),r.addSelection(y),this.anchorRanges=[y],this.tableScope.onSelectionChanged(r);return}const u=r.getRanges().slice();d?this.clickRowNumber(r,e.rowIndex,e.columnIndex,a,c,h):c&&h?r.removeSelection(M.singleCell(e.rowIndex,e.columnIndex)):c?r.togglePoint(e.rowIndex,e.columnIndex):(!a&&r.hasSelection()&&r.clear(),r.firstClick(e.rowIndex,e.columnIndex)),this.anchorRanges=r.getRanges().filter(b=>!u.includes(b)),this.previousEvt=e.clone(),this.anchor=[e.rowIndex,e.columnIndex],this.letterAnchor=void 0,this.extent=void 0,this.tableScope.onSelectionChanged(r)}),s=!0)}return s}onActionTriggered(e){var t,s;if(this.getSelectionModel&&this.getFocusModel){const o=this.getSelectionModel(),i=this.getFocusModel();if(o&&i){if(e==="SELECT_ALL")return o.selectAll(),this.tableScope.repaint(),this.announce(r=>r.allSelected()),!0;if(e==="DESELECT_ALL")return o.clear(),this.tableScope.repaint(),this.announce(r=>r.selectionCleared()),!0;if(e==="TOGGLE_SELECTION"&&((s=(t=this.tableScope).getHeaderFocus)!=null&&s.call(t)))return!1;if(e==="TOGGLE_SELECTION"){const[r,l]=i.getFocus();return this.isRowNumberColumn(l)&&De.isRangeSelection(o)?(this.clickRowNumber(o,r,l,!1,!0,!1),this.tableScope.onSelectionChanged(o),this.tableScope.repaint(),!0):(o.togglePoint(r,l),this.tableScope.repaint(),!0)}}}return!1}adjustForRowChanges(e){var o,i;const t=r=>{if(!r)return;const l=e.mapIndex(r[0]);return l>=0?[l,r[1]]:void 0};if(this.anchor=t(this.anchor),this.extent=t(this.extent),this.previousEvt&&this.previousEvt.areaIdent==="body"){const r=e.mapIndex(this.previousEvt.rowIndex);r>=0?this.previousEvt.rowIndex=r:this.previousEvt=void 0}const s=((i=(o=this.getSelectionModel)==null?void 0:o.call(this))==null?void 0:i.getRanges())??[];this.anchorRanges=this.anchorRanges.filter(r=>s.includes(r))}getAnchor(){return this.anchor?[this.anchor[0],this.anchor[1]]:void 0}getExtent(){var r;const e=(r=this.getFocusModel)==null?void 0:r.call(this),[t,s]=e?e.getFocus():[-1,-1],o=this.extent??this.anchor,i=this.anchor;return t>=0&&s>=0&&!(i&&i[0]===t&&i[1]===s)&&!(o&&o[0]===t&&o[1]===s)?[t,s]:o?[o[0],o[1]]:void 0}collapseTo(e,t){var i;const s=(i=this.getSelectionModel)==null?void 0:i.call(this);this.anchor=[e,t],this.extent=void 0,this.anchorRanges=[];const o=s==null?void 0:s.selectionType;!s||o!=="range"&&o!=="cell"||this.batch(()=>{const r=s.getRanges();r.length===1&&r[0].r1===e&&r[0].r2===e&&r[0].c1===t&&r[0].c2===t&&!s.isAllSelected()||(s.clear(),s.addSelection(M.singleCell(e,t)),this.tableScope.onSelectionChanged(s)),this.anchorRanges=s.getRanges().slice()})}extendTo(e,t){var h,d;const s=(h=this.getSelectionModel)==null?void 0:h.call(this);if(!s||!De.isRangeSelection(s))return;const o=(d=this.getFocusModel)==null?void 0:d.call(this),[i,r]=o?o.getFocus():[-1,-1],l=this.extent??this.anchor,a=this.anchor&&this.anchor[0]===i&&this.anchor[1]===r||l&&l[0]===i&&l[1]===r;if((!this.anchor||!a)&&i>=0&&r>=0&&(this.anchor=[i,r],this.extent=void 0,this.anchorRanges=[]),!this.anchor)return;const c=De.rangeBetween(e,t,this.anchor[0],this.anchor[1]);return this.batch(()=>{if(De.hasSnapshots(s)){const u=s.createSnapshot();s.restoreSnapshot({...u,ranges:u.ranges.filter(f=>!this.anchorRanges.includes(f))})}else s.clear();s.addSelection(c),this.anchorRanges=[c],this.extent=[e,t],this.tableScope.onSelectionChanged(s)}),c}static rangeBetween(e,t,s,o){return new M(Math.min(e,s),Math.min(t,o),Math.max(e,s),Math.max(t,o))}isRowNumberColumn(e){var t;return e>-1&&G((t=this.tableScope.tableModel)==null?void 0:t.getColumnDef(e))}isColumnLetterCell(e){var s;const t=this.tableScope.tableModel.getAreaModel("header");return!!((s=t.isColumnLetterRow)!=null&&s.call(t,e.rowIndex))&&!this.isRowNumberColumn(e.columnIndex)&&!Ae(this.tableScope.tableModel.getColumnDef(e.columnIndex))}clickColumnLetter(e){var l,a,c,h,d;const t=(l=this.getSelectionModel)==null?void 0:l.call(this),s=(a=this.getFocusModel)==null?void 0:a.call(this);if(!t||!De.isRangeSelection(t))return!1;const o=e.columnIndex,i=!!((c=e.originalEvent)!=null&&c.shiftKey),r=!!((h=e.originalEvent)!=null&&h.ctrlKey||(d=e.originalEvent)!=null&&d.metaKey);return this.batch(()=>{const u=i?this.letterAnchor??(s==null?void 0:s.getFocus()[1])??o:o,f=new M(0,Math.min(u,o),Number.MAX_SAFE_INTEGER,Math.max(u,o));if(!r&&t.hasSelection()&&t.clear(),t.addSelection(f),i||(this.letterAnchor=o),s){const p=Math.max(0,s.getFocus()[0]);s.setFocus(p,o)}this.anchor=[0,o],this.extent=void 0,this.tableScope.onSelectionChanged(t)}),!0}selectAllByRowNumberHeader(){var s;const e=(s=this.getSelectionModel)==null?void 0:s.call(this),t=e==null?void 0:e.selectionType;return!e||t!=="row"&&t!=="range"?!1:(this.batch(()=>{e.selectAll(),this.tableScope.onSelectionChanged(e)}),this.announce(o=>o.allSelected()),!0)}clickRowNumber(e,t,s,o,i,r){const l=new M(t,0,t,Number.MAX_SAFE_INTEGER);i&&r?e.removeSelection(l):i?e.isSelected(t,s)?e.removeSelection(l):e.addSelection(l):(!o&&e.hasSelection()&&e.clear(),e.addSelection(l))}static isRangeSelection(e){return e.selectionType==="range"}announce(e){var s;const t=(s=this.getSelectionModel)==null?void 0:s.call(this);(t==null?void 0:t.selectionType)!=="none"&&this.tableScope.ariaTexts&&typeof this.tableScope.announce=="function"&&this.tableScope.announce(e(this.tableScope.ariaTexts))}batch(e){typeof this.tableScope.holdSelectionEvents=="function"?this.tableScope.holdSelectionEvents(e):e()}static hasSnapshots(e){return typeof e.createSnapshot=="function"&&typeof e.restoreSnapshot=="function"}createRangeByEvents(e,t){t||(t=e);const s=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),o=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),i=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return M.create({rowIndex1:s,columnIndex1:i,rowIndex2:o,columnIndex2:r})}}class oa{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","ctrl+a":"SELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+x":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","meta -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT",home:"NAVIGATE_ROW_START",end:"NAVIGATE_ROW_END","ctrl+home":"NAVIGATE_FIRST_CELL","ctrl+end":"NAVIGATE_LAST_CELL",pageup:"NAVIGATE_PAGE_UP",pagedown:"NAVIGATE_PAGE_DOWN",enter:"ACTIVATE_CELL","ctrl+alt+up":"MOVE_ROW_UP","ctrl+alt+down":"MOVE_ROW_DOWN","ctrl+d":"FILL_DOWN","ctrl+r":"FILL_RIGHT","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}class ia{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","meta+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","meta+x":"DESELECT_ALL","meta+shift+a":"DESELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","ctrl -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT",home:"NAVIGATE_ROW_START",end:"NAVIGATE_ROW_END","meta+left":"NAVIGATE_ROW_START","meta+right":"NAVIGATE_ROW_END","ctrl+home":"NAVIGATE_FIRST_CELL","ctrl+end":"NAVIGATE_LAST_CELL","meta+up":"NAVIGATE_FIRST_CELL","meta+down":"NAVIGATE_LAST_CELL",pageup:"NAVIGATE_PAGE_UP",pagedown:"NAVIGATE_PAGE_DOWN",enter:"ACTIVATE_CELL","ctrl+alt+up":"MOVE_ROW_UP","ctrl+alt+down":"MOVE_ROW_DOWN","meta+d":"FILL_DOWN","meta+r":"FILL_RIGHT","meta+c":"COPY_2_CLIPBOARD","ctrl+c":"COPY_2_CLIPBOARD"}}}const Sd={arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right"};function Ds(n){return n.trim().replace(/\+/g," ").replace(/ +/g," ").replace(/⌫/g,"backspace").replace(/↩/g,"enter").replace(/⇧/g,"shift").replace(/⌥/g,"alt").replace(/option/g,"alt").replace(/opt/g,"alt").replace(/⌃/g,"ctrl").replace(/control/g,"ctrl").replace(/command/g,"cmd").replace(/meta/g,"cmd").replace(/escape/g,"esc").replace(/⌘/g,"cmd").replace(/\*/g,"multiply").split(" ").filter(e=>e).map(e=>Sd[e]??e).filter((e,t,s)=>s.indexOf(e)===t).sort((e,t)=>{const s={cmd:1,ctrl:2,alt:3,shift:4},o=s[e]||5,i=s[t]||5;return o!==i?o-i:e.localeCompare(t)}).join(" ")}function ra(n){let e=n.key.toLowerCase();if(e===" "&&(e="space"),e==="arrowleft"&&(e="left"),e==="arrowright"&&(e="right"),e==="arrowup"&&(e="up"),e==="arrowdown"&&(e="down"),e==="delete"&&n.code==="Delete"&&(e="delete"),e==="backspace"&&(e="backspace"),e==="escape"&&(e="esc"),e==="return"&&(e="enter"),n.code.startsWith("Numpad")){const s=n.code.replace("Numpad","").toLowerCase();s==="add"?e="num_add":s==="subtract"?e="num_subtract":s==="multiply"?e="num_multiply":s==="divide"?e="num_divide":s==="decimal"?e="num_decimal":s==="enter"?e="num_enter":e="num_"+s}n.code.match(/^F\d+$/)&&(e=n.code.toLowerCase()),n.code.match(/^Digit\d+$/)&&(e=n.code.replace(/Digit/g,""));let t="";return n.ctrlKey&&(t+=" ctrl"),n.altKey&&(t+=t+" alt"),n.shiftKey&&(t+=t+" shift"),n.metaKey&&(t+=t+" cmd"),Ds(t+" "+e)}function Lr(){return typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.indexOf("Mac")>-1}class na{constructor(e){this.tableScope=e,this.shortcutActionIdMapping={},this.listener=[],this.listener.push(e),this.init()}addListener(e){this.listener.includes(e)||this.listener.push(e)}init(){var e,t,s,o;if((t=(e=this.tableScope)==null?void 0:e.tableOptions)!=null&&t.shortcutActionsDisabled)this.isDebug()&&console.debug("ShortcutService skipped.");else{this.assignPredefinedSystemShortcutMappings();for(const i of((o=(s=this.tableScope).getShortcutLayers)==null?void 0:o.call(s,this.isMacintosh()))??[])this.assignMapping(i);this.assignMapping(this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this),{signal:this.tableScope.listenerAbortController.signal})}}assignPredefinedSystemShortcutMappings(){this.isMacintosh()?this.assignMapping(new ia().get()):this.assignMapping(new oa().get())}assignMapping(e){if(e)for(const t of Object.keys(e)){const s=Ds(t);for(const o of Object.keys(this.shortcutActionIdMapping))o!==t&&Ds(o)===s&&delete this.shortcutActionIdMapping[o];this.shortcutActionIdMapping[t]=e[t]}}isMacintosh(){return Lr()}isDebug(){return this.isLocalhost()}isLocalhost(){return location.hostname==="localhost"||location.hostname==="127.0.0.1"}onKeyDown(e){var o,i,r,l;if((i=(o=this.tableScope).isEventInDetail)!=null&&i.call(o,e)||(l=(r=this.tableScope).isEventInFilterUI)!=null&&l.call(r,e))return;const t=e.target;if(t&&(t.isContentEditable||["INPUT","SELECT","TEXTAREA","BUTTON","A"].includes(t.tagName)))return;const s=this.findEntity(e);if(s){this.tableScope.shortcutKeyEvent=e;let a;try{a=this.emit(s)}finally{this.tableScope.shortcutKeyEvent=void 0}a&&(e.preventDefault(),e.stopPropagation())}}emit(e){this.isDebug()&&console.debug("ShortcutService emit :",e);let t=!1;for(const s of this.listener)s.onActionTriggered(e)&&(t=!0);return t}findEntity(e){var s,o;let t=ra(e);(o=(s=this.tableScope).isRtl)!=null&&o.call(s)&&(t=zl(t)),this.isDebug()&&console.debug("ShortcutService shortcut :",t);for(const i in this.shortcutActionIdMapping)if(Ds(i)===t)return this.isDebug()&&console.debug("ShortcutService action :",this.shortcutActionIdMapping[i]),this.shortcutActionIdMapping[i]}getShortcutActionMapping(){return this.shortcutActionIdMapping}}class Fs{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}onScroll(e){}onSelectionChanged(e){}onFocusChanged(e){}onStateChanged(e){}onRowDragStart(e){}onRowDragMove(e){}onRowDragEnd(e){}onBatchEditChanged(e){}onDetailExpandedChanged(e){}onEditingChanged(e){}onUndoStackChanged(e){}onColumnResizeStart(e){}onColumnResizeEnd(e){}onColumnMoveStart(e){}onColumnMoveEnd(e){}onFilterChanged(e){}onCellActivated(e){}}class Vi{setStyle(e,t,s){return e.style[t]=s,e}appendText(e,t){const s=this.createText(t);return this.appendChild(e,s),s}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.add(s)):e.classList.add(t),e}removeClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.remove(s)):e.classList.remove(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,s){e.setAttribute(t,s)}removeAttribute(e,t){e.removeAttribute(t)}}const xd=null;function ls(n){return n==null||n===""}const yn=new Intl.Collator("en",{numeric:!0});function Cn(n){return typeof n=="number"||typeof n=="bigint"?0:n instanceof Date?1:typeof n=="boolean"?2:typeof n=="string"?3:4}function vn(n,e){const t=Cn(n),s=Cn(e);if(t!==s)return t-s;switch(t){case 0:{const o=n,i=e,r=typeof o=="number"&&Number.isNaN(o),l=typeof i=="number"&&Number.isNaN(i);return r||l?r===l?0:r?1:-1:o<i?-1:o>i?1:0}case 1:{const o=n.getTime(),i=e.getTime();return(Number.isNaN(o)?1/0:o)-(Number.isNaN(i)?1/0:i)||0}case 2:return(n?1:0)-(e?1:0);case 3:return yn.compare(n,e);default:return yn.compare(String(n),String(e))}}function io(n){return(e,t)=>{const s=ls(e),o=ls(t);return s||o?s===o?0:s?1:-1:n(e,t)}}function Rd(n,e){const t=typeof n=="string"||typeof n=="function"?{value:n}:n;if(!t||typeof t.value!="string"&&typeof t.value!="function")throw new Error(`Row grouping: level ${e} has no value (a property path or a function).`);const s=typeof t.value=="string"?t.value:void 0,o=t.order??"asc";let i;return o==="asc"?i=io(vn):o==="desc"?i=io((r,l)=>vn(l,r)):typeof o=="function"?i=io(o):i=io(()=>0),{name:t.name??s??`level${e}`,label:t.label,path:s,getKey:dt(t.value),format:t.format,compare:i}}function it(n){return(n??[]).map((e,t)=>Rd(e,t))}const Sn=new WeakMap;let Ad=1;function It(n){if(ls(n))return"empty";switch(typeof n){case"string":return"s:"+n;case"number":return"n:"+String(n);case"boolean":return"b:"+n;case"bigint":return"i:"+String(n);case"symbol":return"y:"+(n.description??"");case"function":case"object":{if(n instanceof Date)return"d:"+n.getTime();let e=Sn.get(n);return e===void 0&&(e=Ad++,Sn.set(n,e)),"o:"+e}default:return"u:"+String(n)}}function Ed(n,e){return ls(n)?e:n instanceof Date?Number.isNaN(n.getTime())?"Invalid Date":n.toLocaleDateString("en-US"):String(n)}function la(n,e){return n.map(t=>t.label??(t.path!==void 0?e(t.path):void 0)??t.name)}function aa(n,e){const t=la(it(n),s=>{var o;return(o=e.find(i=>i.property===s&&!ht(i)))==null?void 0:o.headerLabel});return t.length?t.join(" › "):"Group"}function Pi(n){var a,c;const e=n.getBodyModel();if(!ge(e))return!1;const t=n.getColumnDefs()??[],s=e.getGroupBy(),o=e.options.hideGroupedColumns===!1?[]:it(s).map(h=>h.path).filter(h=>h!==void 0&&t.some(d=>d.property===h&&!ht(d))),i=e.hiddenColumnProperties.filter(h=>o.includes(h));for(const h of e.hiddenColumnProperties)o.includes(h)||(a=n.setColumnVisible)==null||a.call(n,h,!0);for(const h of o)i.includes(h)||!Md(t,h)||((c=n.setColumnVisible)==null||c.call(n,h,!1),i.push(h));e.hiddenColumnProperties=i;const r=t.findIndex(ht),l=t[r];if(l&&ht(l)&&l.autoHeaderLabel){const h=aa(s,t);l.headerLabel=h;const d=n.getAreaModel("header"),u=d.getRowCount()-1;u>=0&&d.getValueAt(u,r)!==h&&d.setValue(u,r,h)}return!0}function Md(n,e){var t,s;return((s=(t=n.find(o=>o.property===e))==null?void 0:t.isVisible)==null?void 0:s.call(t))!==!1}const Je=class Je{createContent(e,t,s){return new Promise((o,i)=>{var r;if(t!=null&&t.hasSelection()){const l=t.isAllSelected()?new M(0,0,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER):this.mergeRanges(t.getRanges());if(l){l.c2=Math.min(l.c2,e.getColumnCount()-1),l.r2=Math.min(l.r2,e.getBodyModel().getRowCount()-1);const a=Math.max(0,l.r2-l.r1+1)*Math.max(0,l.c2-l.c1+1);if(a>Je.maxCopyCells)return i(`Cannot copy ${a} cells – more than CopyService.maxCopyCells (${Je.maxCopyCells}).`);const c=[];for(let h=l.r1;h<=l.r2;h++){const d=[];for(let u=l.c1;u<=l.c2;u++){const f=e.getColumnDef(u);if(((r=f==null?void 0:f.isVisible)==null?void 0:r.call(f))===!1)continue;const p=G(f)?f:void 0;if(p&&!p.options.exported)continue;const g=t.isSelected(h,u),m=e.getBodyModel(),b=g?p?p.getRowNumberText(h,m):m.getTextValueAt(h,u):"";d.push(b)}c.push(d.join(Je.columnSeparatorChar))}return o(c.join(Je.rowSeparatorChar))}}if(s){const[l,a]=s.getFocus(),c=e.getColumnDef(a),h=G(c)?c.getRowNumberText(l,e.getBodyModel()):e.getBodyModel().getTextValueAt(l,a);return o(h)}i("Cannot copy, neither selection nor focus defined.")})}copyContent(e){return navigator.clipboard.writeText(e)}copyToClipboard(e,t,s){return new Promise((o,i)=>{this.createContent(e,t,s).then(r=>{r?this.copyContent(r).then(l=>{o(r)}).catch(l=>{i()}):o("")}).catch(r=>{i()})})}mergeRanges(e){let t;for(const s of e)t?(t.r1=Math.min(t.r1,s.r1),t.c1=Math.min(t.c1,s.c1),t.r2=Math.max(t.r2,s.r2),t.c2=Math.max(t.c2,s.c2)):t=new M(s.r1,s.c1,s.r2,s.c2);return t}};Je.maxCopyCells=1e6,Je.columnSeparatorChar=" ",Je.rowSeparatorChar=`
48
48
  `;let He=Je;class ca{constructor(e,t=500){this.tableScope=e,this.debounceDelay=t,this.disconnected=!1,this.resizeObserver=new ResizeObserver(rl(this.handleResize.bind(this),t)),this.resizeObserver.observe(this.tableScope.hostElement)}disconnect(){this.disconnected=!0,this.resizeObserver.disconnect()}handleResize(e){if(this.disconnected)return;const t=e[0],{width:s}=t.contentRect;this.tableScope.recalcColumnWidths(s)}}function ho(n){return!!n&&typeof n=="object"&&typeof n.formula=="string"&&"value"in n}function uo(n){return!!n&&typeof n=="object"&&typeof n.value=="number"&&typeof n.numberFormat=="string"}const mi="yyyy-mm-dd";let ro;function xn(n){if(!ro){ro=new Uint32Array(256);for(let t=0;t<256;t++){let s=t;for(let o=0;o<8;o++)s=s&1?3988292384^s>>>1:s>>>1;ro[t]=s>>>0}}let e=4294967295;for(let t=0;t<n.length;t++)e=ro[(e^n[t])&255]^e>>>8;return(e^4294967295)>>>0}async function Td(n){const e=globalThis.CompressionStream;if(!(!e||typeof Response>"u"||typeof Blob>"u"))try{const t=new Blob([n]).stream().pipeThrough(new e("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}catch{return}}class ha{constructor(){this.supportsNumberFormats=!0,this.supportsFormulas=!0,this.numberFormatStyles=new Map}downloadExcel(e,t="file.xlsx",s="",o={}){if(!Array.isArray(e)||e.some(i=>!Array.isArray(i)))throw new Error("Invalid matrix format. Expected a 2D array.");if((t==null?void 0:t.trim())==="")throw new Error("Invalid filename. Filename must be a non-empty string.");return this.createExcelBlob(e,s,o).then(i=>{const r=URL.createObjectURL(i),l=document.createElement("a");l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(r),1e3)}).catch(i=>{throw console.error("Error generating Excel file:",i),new Error("Failed to download Excel file.")})}async createExcelBlob(e,t="",s={}){const o=await this.createZipCompressed(this.generateMap(e,t,s));return new Blob([o],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}generateMap(e,t="",s={}){const o=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
49
49
  <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`,i=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
50
50
  <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Macintosh Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size="2" baseType="variant"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>1</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector size="1" baseType="lpstr"><vt:lpstr>Sheet1</vt:lpstr></vt:vector></TitlesOfParts><Company></Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>16.0300</AppVersion></Properties>`,r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
@@ -68,7 +68,7 @@ render scope: this.lastFullVisibleRowIndex <- `+this.lastFullVisibleRowIndex),th
68
68
  `&&n[s]!=="\r";)s++;l=n.slice(c,s)}if(t.push(l),i=!1,s>=o){e.push(t);break}const a=n[s];if(a===" "){if(s++,s===o){t.push(""),e.push(t);break}continue}if(s+=a==="\r"&&n[s+1]===`
69
69
  `?2:1,e.push(t),t=[],i=!0,s>=o)break}i&&e.length===0&&e.push([""]);const r=e.reduce((l,a)=>Math.max(l,a.length),0);for(const l of e)for(;l.length<r;)l.push("");return e}function qa(n){return`<meta charset="utf-8"><table><tbody>${n.map(t=>"<tr>"+t.map(s=>`<td${s.num!==void 0&&Number.isFinite(s.num)?` x:num="${s.num}"`:""}>${ne(s.text).replace(/\r\n|\n|\r/g,"<br>")}</td>`).join("")+"</tr>").join("")}</tbody></table>`}function Ja(n){if(typeof DOMParser>"u")return[];const e=new DOMParser().parseFromString(n,"text/html"),t=e.querySelector("table");if(!t)return[];for(const i of Array.from(t.querySelectorAll("script, style, template, noscript")))i.remove();for(const i of Array.from(t.querySelectorAll("br")))i.replaceWith(e.createTextNode(`
70
70
  `));const s=[];for(const i of Array.from(t.querySelectorAll("tr"))){if(i.closest("table")!==t)continue;const r=[];for(const l of Array.from(i.children)){if(l.tagName!=="TD"&&l.tagName!=="TH")continue;r.push(String(l.textContent).replace(/ /g," ").trim());const a=Math.min(1e3,Math.max(1,Number(l.getAttribute("colspan"))||1));for(let c=1;c<a;c++)r.push("")}s.push(r)}const o=s.reduce((i,r)=>Math.max(i,r.length),0);for(const i of s)for(;i.length<o;)i.push("");return s}function Za(n){const{matrix:e,anchorRow:t,shownColumns:s,rowCount:o}=n,i=e.length,r=e.reduce((y,C)=>Math.max(y,C.length),0),l=s.indexOf(n.anchorColumn),a={cells:[],range:new M(t,n.anchorColumn,t,n.anchorColumn),skipped:0,clipped:0,addRows:0};if(!i||!r||l<0||t<0)return a;const{rows:c,columns:h}=Vr(i,r,n.selection),d=s.length-l,u=Math.min(h,d);let f=(h-u)*c;const p=o-t;let g=c,m=0;c>p&&(n.canAddRows?m=c-Math.max(0,p):(g=Math.max(0,p),f+=(c-g)*u));const b=[];let w=0;for(let y=0;y<g;y++){const C=t+y,S=e[y%i];for(let x=0;x<u;x++){const R=s[l+x];if(C<o&&n.isWritable&&!n.isWritable(C,R)){w++;continue}const I=S[x%r]??"";b.push({rowIndex:C,columnIndex:R,value:I})}}return!g||!u?{...a,clipped:f}:{cells:b,range:new M(t,n.anchorColumn,t+g-1,s[l+u-1]),skipped:w,clipped:f,addRows:m}}function Vr(n,e,t){return t&&(t.rows>1||t.columns>1)&&n>0&&e>0&&(n===1&&e===1||t.rows%n===0&&t.columns%e===0)?{rows:t.rows,columns:t.columns}:{rows:n,columns:e}}const Wn=n=>n.replace(/\r\n?/g,`
71
- `).replace(/\n$/,"");class Wi{constructor(e,t,s){this.tableScope=e,this.options=t;const o=e.listenerAbortController.signal;if(s){const i=e.hostElement.ownerDocument;i.addEventListener("copy",r=>this.onClipboardEvent(r,"copy"),{signal:o}),i.addEventListener("cut",r=>this.onClipboardEvent(r,"cut"),{signal:o}),i.addEventListener("paste",r=>this.onClipboardEvent(r,"paste"),{signal:o})}e.hostElement.addEventListener("keydown",i=>{var r;i.key==="Escape"&&((r=this.memory)!=null&&r.cut)&&i.target===e.hostElement&&!e.isEditing()&&this.cancelCut()},{signal:o}),e.subscribe({onModelChanged:i=>{var r;i.source!=="cut"&&((r=this.memory)!=null&&r.cut)&&this.cancelCut()}})}isCutMarked(){var e;return!!((e=this.memory)!=null&&e.cut)}arm(e){const t=this.tableScope;if(t.isEditing()||t.getHeaderFocus()||!t.getActiveBodyCell()||e!=="paste"&&!this.hasBuiltInCopyService()||e!=="copy"&&t.isOverlayBlocking())return!1;const s=this.ensureProxy();return s.value=" ",s.select(),s.focus({preventScroll:!0}),this.armedKind=e,clearTimeout(this.restoreTimer),this.restoreTimer=setTimeout(()=>this.restoreFocus(),0),!0}getSelectionAsText(){var e;return((e=this.buildCopy(!1))==null?void 0:e.text)??""}async writeSelection(e){const t=this.buildCopy(e);if(!t)return;const s=typeof navigator<"u"?navigator.clipboard:void 0,o=globalThis.ClipboardItem;if(s!=null&&s.write&&o&&t.html)await s.write([new o({"text/plain":new Blob([t.text],{type:"text/plain"}),"text/html":new Blob([t.html],{type:"text/html"})})]);else if(s!=null&&s.writeText)await s.writeText(t.text);else return;this.remember(t,e)}async runWithoutKey(e){var t,s;try{if(e==="paste"){const o=await((s=(t=navigator.clipboard)==null?void 0:t.readText)==null?void 0:s.call(t));o&&this.paste(o)}else await this.writeSelection(e==="cut")}catch(o){console.warn("GuiExpert Table – clipboard:",o)}}paste(e,t,s){var K,Y;const o=this.tableScope,i=e?Ya(e):t?Ja(t):[];if(!i.length||!i[0].length)return[];const r=this.memory&&e&&Wn(e)===this.memory.text?this.memory:void 0,l=r==null?void 0:r.cut,a=o.tableModel.getBodyModel(),c=a.getRowCount(),h=this.getPasteColumns(),d=this.getPasteAnchor(h,s);if(!d||!h.length)return[];const[u,f]=d,p=l?void 0:d[2],g=i[0].length,m=h.indexOf(f),b=h[Math.min(h.length-1,m+g-1)],w=o.isBatchEditActive();let y=r&&!w?r.values:r?i.map((U,$)=>U.map((me,te)=>{var le;return((le=r.values[$])==null?void 0:le[te])instanceof ks?r.values[$][te]:me})):i,C=!!r&&!w;const S=this.options.processPaste;if(S){const U={text:e,html:t,matrix:i,target:new M(u,f,u+i.length-1,b),internal:!!r},$=S(U);if($===!1)return[];Array.isArray($)&&(y=$,C=!1)}const x=this.options.maxPasteCells,R=Vr(y.length,y.reduce((U,$)=>Math.max(U,$.length),0),p);if(R.rows*R.columns>x)return o.announce(o.getSheetTexts().pasteTooLarge(x)),[];const I=this.options.pasteAddsRows&&!!this.options.createRow&&!w&&this.canAppendRows(),A=((Y=(K=o.tableModel).getColumnDefs)==null?void 0:Y.call(K))??[],T=Za({matrix:y,anchorRow:u,anchorColumn:f,shownColumns:h,rowCount:c,selection:p,canAddRows:I,isWritable:(U,$)=>a.isEditable(U,$)&&!G(A[$])});if(T.addRows&&this.appendRows(T.addRows),r)for(const U of T.cells)U.value=o.resolvePastedValue(U.value,U.rowIndex,U.columnIndex,!!l);const F=[];let P="paste";if(l){P="cut";const U=new Map(h.map((te,le)=>[te,le])),$=[],me=new Set;for(const{rowIndex:te,columnIndex:le,value:Te}of T.cells){const H=C?Te:this.convertPastedText(Te,te,le);o.checkPastedValue(te,le,H,C)||(F.push({rowIndex:te,column:le,value:H}),$.push([te-u,U.get(le)-m]),me.add(`${te}:${le}`))}for(const te of this.cutSourceChanges(l,$,me))F.push(te)}else for(const{rowIndex:U,columnIndex:$,value:me}of T.cells)F.push({rowIndex:U,column:$,value:C?me:this.convertPastedText(me,U,$)});const O=F.length?o.writePastedCells(F,P,C):[];l&&(this.memory=void 0,this.removeCutFrame()),T.addRows&&o.repaintHard();let N=O.length;if(l){const U=new Set(T.cells.map($=>`${$.rowIndex}:${$.columnIndex}`));N=O.filter($=>U.has(`${$.rowIndex}:${$.columnIndex}`)).length}return o.selectBodyRange(T.range),o.announce(o.getSheetTexts().cellsPasted(N,T.skipped+T.clipped+Math.max(0,T.cells.length-N))),O}cancelCut(){var e;(e=this.memory)!=null&&e.cut&&(this.memory={...this.memory,cut:void 0}),this.removeCutFrame()}update(){var u;const e=(u=this.memory)==null?void 0:u.cut,t=this.cutFrame;if(!e||!t)return;const s=this.tableScope,o=s.tableModel.getBodyModel(),{range:i}=e;if(i.r2>=o.getRowCount()||this.rowObjectAt(i.r1)!==e.rows[0]||this.rowObjectAt(i.r2)!==e.rows[e.rows.length-1]){this.removeCutFrame();return}const r=s.getBodyCellRectInHost(i.r1,i.c1),l=s.getBodyCellRectInHost(i.r2,i.c2),a=Math.max(r.top,r.clipTop),c=Math.min(l.top+l.height,l.clipBottom),h=Math.max(r.left,r.clipLeft),d=Math.min(l.left+l.width,l.clipRight);s.getDomService().applyStyle(t,{display:c>a&&d>h?"block":"none",left:`${h}px`,top:`${a}px`,width:`${Math.max(0,d-h)}px`,height:`${Math.max(0,c-a)}px`})}destroy(){var e;clearTimeout(this.restoreTimer),(e=this.proxy)==null||e.remove(),this.proxy=void 0,this.removeCutFrame(),this.memory=void 0}onClipboardEvent(e,t){var a,c;const s=this.tableScope,o=s.hostElement,i=typeof e.composedPath=="function"?e.composedPath()[0]:e.target,r=!!this.proxy&&i===this.proxy;if(!r&&(Gn(o)!==o||s.isEditing()||(a=s.isEventInDetail)!=null&&a.call(s,e)||(c=s.isEventInFilterUI)!=null&&c.call(s,e))||!r&&(s.getHeaderFocus()||!s.getActiveBodyCell())||t!=="paste"&&!this.hasBuiltInCopyService())return;const l=e.clipboardData;try{if(!l||(e.preventDefault(),t!=="copy"&&s.isOverlayBlocking()))return;if(t==="paste")this.paste(l.getData("text/plain"),l.getData("text/html")||void 0);else{const h=this.buildCopy(t==="cut");h&&(l.setData("text/plain",h.text),h.html&&l.setData("text/html",h.html),this.remember(h,t==="cut"))}}finally{(r||this.armedKind)&&this.restoreFocus()}}restoreFocus(){clearTimeout(this.restoreTimer),this.armedKind=void 0;const e=this.proxy;e&&(e.value="",Gn(e)===e&&this.tableScope.hostElement.focus({preventScroll:!0}))}ensureProxy(){if(!this.proxy||!this.proxy.isConnected){const e=this.tableScope.getDomService().domService,t=e.createElement("textarea");e.addClass(t,"ge-table-clipboard-proxy"),e.setAttribute(t,"aria-hidden","true"),e.setAttribute(t,"tabindex","-1"),e.setAttribute(t,"autocomplete","off"),e.appendChild(this.tableScope.hostElement,t),this.proxy=t}return this.proxy}remember(e,t){var r;const s=this.tableScope;this.cancelCut(),this.memory=e.processed?void 0:{text:Wn(e.text),values:e.values,cut:t?{range:e.range,columns:e.columns,rows:this.rowObjectsOf(e.range)}:void 0},(r=this.memory)!=null&&r.cut&&this.showCutFrame();const o=s.getSheetTexts(),i=t?o.cutMarked(e.cellCount):s.ariaTexts.copied(e.cellCount);s.announce(e.lastRangeOnly?`${i}. ${o.copiedLastRangeOnly()}`:i)}buildCopy(e){var S;const t=this.tableScope,s=t.tableModel,o=s.getBodyModel(),i=o.getRowCount(),r=s.getColumnCount();if(!i||!r)return;const l=t.selectionModel();let a,c=!1;if(l!=null&&l.isAllSelected())a=new M(0,0,i-1,r-1);else if(l!=null&&l.hasSelection()&&l.getRanges().length){const x=l.getRanges(),R=x[x.length-1];c=x.length>1,a=new M(Math.max(0,R.r1),Math.max(0,R.c1),Math.min(i-1,R.r2),Math.min(r-1,R.c2))}else{const x=t.getActiveBodyCell();a=x?M.singleCell(x[0],x[1]):void 0}if(!a||a.r2<a.r1||a.c2<a.c1)return;const h=[];for(let x=a.c1;x<=a.c2;x++){const R=s.getColumnDef(x);((S=R==null?void 0:R.isVisible)==null?void 0:S.call(R))===!1||s.getColumnWidth(x)<=0||G(R)&&!R.options.exported||h.push(x)}const d=(a.r2-a.r1+1)*h.length;if(!h.length)return;if(d>He.maxCopyCells){t.announce(t.getSheetTexts().copyTooLarge(He.maxCopyCells));return}const u=this.options.copyValue==="raw",f=!!(l!=null&&l.hasSelection())&&!l.isAllSelected(),p=[],g=[],m=[];if(this.options.copyHeaders&&!e){const x=h.map(R=>t.getColumnAriaLabel(R));p.push(x),g.push(x),m.push(x.map(R=>({text:R})))}for(let x=a.r1;x<=a.r2;x++){const R=[],I=[],A=[];for(const T of h){const F=s.getColumnDef(T);let P,O;if(f&&!l.isSelected(x,T))P="",O="";else if(G(F))P=F.getRowNumberText(x,o),O=P;else{O=t.getCopyValue(x,T);const K=O instanceof ks?O.value:O;P=u||K===null||K===void 0||K instanceof Date?pu(K):o.getTextValueAt(x,T)}R.push(P),I.push(O);const N=O instanceof ks?O.value:O;A.push(typeof N=="number"?{text:P,num:N}:{text:P})}p.push(R),g.push(I),m.push(A)}let b=p,w=!1;if(this.options.processCopy){const x=this.options.processCopy({ranges:[a],matrix:p,cut:e});Array.isArray(x)&&(b=x,w=!0)}const y=Xa(b),C=this.options.html?qa(w?b.map(x=>x.map(R=>({text:R}))):m):void 0;return{text:y,html:C,values:g,range:a,columns:h,cellCount:d,lastRangeOnly:c,processed:w}}getPasteColumns(){var o;const e=this.tableScope.tableModel,t=[],s=e.getColumnCount();for(let i=0;i<s;i++){const r=e.getColumnDef(i);e.getColumnWidth(i)>0&&((o=r==null?void 0:r.isVisible)==null?void 0:o.call(r))!==!1&&!G(r)&&t.push(i)}return t}getPasteAnchor(e,t){const s=this.tableScope,o=s.tableModel.getBodyModel().getRowCount(),i=h=>e.find(d=>d>=h);if(t){const h=i(t[1]);return h===void 0||t[0]<0||t[0]>=o?void 0:[t[0],h,void 0]}const r=s.selectionModel();let l;if(r!=null&&r.isAllSelected())l=new M(0,0,o-1,Number.MAX_SAFE_INTEGER);else if(r!=null&&r.hasSelection()&&r.getRanges().length){const h=r.getRanges();l=h[h.length-1]}if(l){const h=Math.max(0,l.r1),d=Math.min(o-1,l.r2),u=i(Math.max(0,l.c1));if(u!==void 0&&d>=h){const f=e.filter(p=>p>=l.c1&&p<=l.c2).length;return[h,u,{rows:d-h+1,columns:f}]}}const a=s.getActiveBodyCell();if(!a)return;const c=i(a[1]);return c===void 0?void 0:[a[0],c,void 0]}convertPastedText(e,t,s){if(typeof e!="string")return e;const o=this.tableScope,i=o.tableModel.getColumnDef(s);if(i!=null&&i.editInputPipe)return e;const r=t<o.tableModel.getBodyModel().getRowCount()?o.getTypedCellValue(t,s):void 0,l=e.trim();if(typeof r=="number"||(i==null?void 0:i.editor)==="number")return l!==""&&/^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(l)?Number(l):e;if(typeof r=="boolean"){const a=l.toUpperCase();return a==="TRUE"?!0:a==="FALSE"?!1:e}if(r instanceof Date){const a=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/.exec(l);return a?a[4]===void 0?new Date(+a[1],+a[2]-1,+a[3],r.getHours(),r.getMinutes(),r.getSeconds()):new Date(+a[1],+a[2]-1,+a[3],+a[4],+a[5],+(a[6]??0)):e}return e}cutSourceChanges(e,t,s){var a;const o=this.tableScope,i=o.tableModel.getBodyModel(),r=this.rowIndexLookup(e),l=[];for(const[c,h]of t){if(c<0||h<0||c>=e.rows.length||h>=e.columns.length)continue;const d=r(c);if(d<0)continue;const u=e.columns[h],f=o.tableModel.getColumnDef(u);if(s.has(`${d}:${u}`)||G(f)||!i.isEditable(d,u))continue;const p=(f==null?void 0:f.emptyValue)!==void 0?f.emptyValue:((a=o.getEditingOptions())==null?void 0:a.emptyValue)??"";l.push({rowIndex:d,column:u,value:p})}return l}rowIndexLookup(e){const t=this.tableScope.tableModel.getBodyModel().getRowCount(),s=e.rows.every(r=>r!==null&&typeof r=="object"),o=e.rows.every((r,l)=>this.rowObjectAt(e.range.r1+l)===r);if(!s||o)return r=>e.range.r1+r<t?e.range.r1+r:-1;const i=new Map;for(let r=0;r<t;r++)i.set(this.rowObjectAt(r),r);return r=>i.get(e.rows[r])??-1}hasBuiltInCopyService(){const e=this.tableScope.copyService;return!!e&&Object.getPrototypeOf(e)===He.prototype}rowObjectAt(e){const t=this.tableScope.tableModel.getBodyModel().getRowByIndex(e);return J(t)?t.data:t}rowObjectsOf(e){const t=[];for(let s=e.r1;s<=e.r2;s++)t.push(this.rowObjectAt(s));return t}canAppendRows(){const e=this.tableScope.tableModel.getBodyModel();return typeof e.getAllRows=="function"&&typeof e.getFilteredRows=="function"&&!this.tableScope.isRowGroupingOrTree()}appendRows(e){const t=this.tableScope.tableModel.getBodyModel(),s=t.getAllRows(),o=t.getFilteredRows(),i=o.length;for(let r=0;r<e;r++){const l=this.options.createRow(i+r);s.push(l),o!==s&&o.push(l)}this.tableScope.rowsAppended()}showCutFrame(){if(!this.cutFrame){const e=this.tableScope.getDomService();this.cutFrame=e.setAriaHidden(e.createDivWithClass("ge-table-cut-range",this.tableScope.hostElement))}this.update()}removeCutFrame(){var e;(e=this.cutFrame)==null||e.remove(),this.cutFrame=void 0}}function Gn(n){return n.getRootNode().activeElement??null}function pu(n){if(n==null)return"";if(n instanceof Date){if(Number.isNaN(n.getTime()))return"";const e=o=>String(o).padStart(2,"0"),t=`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())}`,s=n.getHours()||n.getMinutes()||n.getSeconds()?`T${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}`:"";return t+s}return typeof n=="boolean"?n?"TRUE":"FALSE":typeof n=="object"?"":String(n)}function Qa(n){return n?{"meta+z":"UNDO","meta+shift+z":"REDO"}:{"ctrl+z":"UNDO","ctrl+y":"REDO","ctrl+shift+z":"REDO"}}class ti{constructor(){this.maxSteps=100,this.maxCells=1e6,this.onConflict="skip",this.recordApiChanges=!1}static create(e){if(!e)return;const t=new ti;if(typeof e=="object")for(const[s,o]of Object.entries(e))o!==void 0&&(t[s]=o);return t}}class ec{constructor(e,t){this.maxSteps=e,this.maxCells=t,this.undoSteps=[],this.redoSteps=[],this.cells=0}push(e){if(this.clearRedo(),e.cellCount>this.maxCells||this.maxSteps<1)return this.clear(),!1;for(this.undoSteps.push(e),this.cells+=e.cellCount;this.undoSteps.length>this.maxSteps||this.cells>this.maxCells;)this.cells-=this.undoSteps.shift().cellCount;return!0}undo(){const e=this.undoSteps.pop();return e&&this.redoSteps.push(e),e}redo(){const e=this.redoSteps.pop();return e&&this.undoSteps.push(e),e}peekUndo(){return this.undoSteps[this.undoSteps.length-1]}peekRedo(){return this.redoSteps[this.redoSteps.length-1]}canUndo(){return this.undoSteps.length>0}canRedo(){return this.redoSteps.length>0}size(){return this.undoSteps.length}cellCount(){return this.cells}clear(){this.undoSteps.length=0,this.redoSteps.length=0,this.cells=0}clearRedo(){for(const e of this.redoSteps)this.cells-=e.cellCount;this.redoSteps.length=0}}function tc(n){var t,s;const e=n;return ee(n)?e.rows:((t=e.getAllRows)==null?void 0:t.call(e))??((s=e.getSourceRows)==null?void 0:s.call(e))??e.arr}function gu(n){if(ee(n)){const t=new Set,s=o=>o==null?void 0:o.forEach(i=>{const r=i;t.add(r.data??r),s(r.children)});return s(n.rows),t}const e=tc(n);return e?new Set(e):null}class Gi{constructor(e,t,s){this.label=e,this.source=t,this.entries=s.map(o=>({row:o.row,rowIndex:o.rowIndex,columnIndex:o.columnIndex,property:o.property,oldValue:o.oldValue,newValue:o.newValue}))}get cellCount(){return this.entries.length}append(e){for(const t of e)this.entries.push({row:t.row,rowIndex:t.rowIndex,columnIndex:t.columnIndex,property:t.property,oldValue:t.oldValue,newValue:t.newValue})}undo(e){return this.apply(e,"undo")}redo(e){return this.apply(e,"redo")}apply(e,t){var y;const s=e.tableModel,o=s.getBodyModel(),i=o.getRowCount(),r=((y=e.getUndoOptions())==null?void 0:y.onConflict)==="overwrite",l=C=>{const S=o.getRowByIndex(C);return J(S)?S.data:S};let a,c;const h=C=>{if(C.row===void 0||C.row===null||typeof C.row!="object")return C.rowIndex>=0&&C.rowIndex<i?C.rowIndex:-1;if(C.rowIndex>=0&&C.rowIndex<i&&l(C.rowIndex)===C.row)return C.rowIndex;if(!a){a=new Map;for(let S=0;S<i;S++)a.set(l(S),S)}return a.get(C.row)??-1},d=C=>(c===void 0&&(c=gu(o)),!!c&&c.has(C)),u=C=>{var S;return!!C&&(bl(C)?!!o.defaultEditable:!!((S=C.editable)!=null&&S.call(C)))},f=[],p=[];let g=0;const m=t==="undo"?[...this.entries].reverse():this.entries;for(const C of m){const S=t==="undo"?C.newValue:C.oldValue,x=t==="undo"?C.oldValue:C.newValue,R=mu(e,C);if(R<0){g++;continue}const I=h(C);if(I>=0){if(!o.isEditable(I,R)||!r&&!as(e.getCellInput(I,R),S)){g++;continue}f.push({rowIndex:I,columnIndex:R,value:x});continue}const A=s.getColumnDef(R),T=d(C.row)?bu(C.row,A,R,S):void 0;if(!d(C.row)||!u(A)||!r&&!as(T,S)||!ga(C.row,A,R,x)){g++;continue}p.push({row:C.row,rowIndex:-1,columnIndex:R,property:C.property,oldValue:T,newValue:x})}const b=e.writeUndoCells(f,p,t);let w;for(const C of b)C.rowIndex<0||(w?(w.r1=Math.min(w.r1,C.rowIndex),w.r2=Math.max(w.r2,C.rowIndex),w.c1=Math.min(w.c1,C.columnIndex),w.c2=Math.max(w.c2,C.columnIndex)):w=new M(C.rowIndex,C.columnIndex,C.rowIndex,C.columnIndex));return{applied:b.length,skipped:g+f.length+p.length-b.length,range:w}}}function mu(n,e){const t=n.tableModel,s=i=>{var r;return((r=t.getColumnDef(i))==null?void 0:r.property)||`#${i}`};if(e.columnIndex>=0&&e.columnIndex<t.getColumnCount()&&s(e.columnIndex)===e.property)return e.columnIndex;const o=t.getColumnCount();for(let i=0;i<o;i++)if(s(i)===e.property)return i;return-1}function bu(n,e,t,s){if(Array.isArray(n))return n[t];if(!(e!=null&&e.property)||n===null||typeof n!="object")return;if(e.valueGetter)return s;let o=n;for(const i of e.property.split("."))o=o==null?void 0:o[i];return o}class sc{constructor(e,t,s){this.label=e,this.source=t,this.cells=s}get cellCount(){return this.cells.length}undo(e){return this.apply(e,"undo")}redo(e){return this.apply(e,"redo")}apply(e,t){var c;const s=e.batchEditService;if(!s)return{applied:0,skipped:this.cells.length};const o=((c=e.getUndoOptions())==null?void 0:c.onConflict)==="overwrite",i=[];let r=0;for(const h of this.cells){const d=t==="undo"?h.after:h.before,u=t==="undo"?h.before:h.after,f=s.getPendingEntry(h.rowKey,h.property);if(!(!f&&!d?!0:!!f&&!!d&&as(f.newValue,d.newValue))&&!o){r++;continue}i.push({rowKey:h.rowKey,property:h.property,entry:u})}const l=s.restorePending(i,!1);let a;for(const h of l)h.rowIndex<0||h.columnIndex<0||(a=a?new M(Math.min(a.r1,h.rowIndex),Math.min(a.c1,h.columnIndex),Math.max(a.r2,h.rowIndex),Math.max(a.c2,h.columnIndex)):new M(h.rowIndex,h.columnIndex,h.rowIndex,h.columnIndex));return e.repaint(),{applied:l.length,skipped:r,range:a}}}class oc{constructor(e,t,s,o,i){this.canUndo=e,this.canRedo=t,this.undoLabel=s,this.redoLabel=o,this.size=i}}const Un={edit:"Edit",fill:"Fill",paste:"Paste",cut:"Cut",clear:"Clear",api:"Change"};class wu{constructor(e,t){this.label=e,this.steps=t,this.source=t[0].source}get cellCount(){return this.steps.reduce((e,t)=>e+t.cellCount,0)}undo(e){return Kn([...this.steps].reverse().map(t=>t.undo(e)))}redo(e){return Kn(this.steps.map(t=>t.redo(e)))}}function Kn(n){let e;for(const t of n)t.range&&(e=e?new M(Math.min(e.r1,t.range.r1),Math.min(e.c1,t.range.c1),Math.max(e.r2,t.range.r2),Math.max(e.c2,t.range.c2)):t.range);return{applied:n.reduce((t,s)=>t+s.applied,0),skipped:n.reduce((t,s)=>t+s.skipped,0),range:e}}class ic{constructor(e,t){this.tableScope=e,this.options=t,this.running=!1,this.foldDepth=0,this.stack=new ec(t.maxSteps,t.maxCells)}addStep(e){this.running||this.add(e)}record(e,t,s){if(this.running||t==="undo"||t==="redo"||!e.length||s===!1)return;if(this.folding instanceof Gi&&t!=="commit"){this.folding.append(e),this.lastRecorded=this.folding;return}if(t==="commit"){this.clear();return}if(t==="api"&&!(s??this.options.recordApiChanges))return;const o=new Gi(Un[t]??"Change",t,e);this.lastRecorded=o,this.add(o)}beginFold(){this.foldDepth++===0&&(this.folding=this.lastRecorded)}endFold(){--this.foldDepth<=0&&(this.foldDepth=0,this.folding=void 0,this.lastRecorded=void 0)}recordPending(e,t,s){this.running||!e.length||s===!1||t==="api"&&!(s??this.options.recordApiChanges)||this.add(new sc(Un[t]??"Change",t,e))}batch(e,t){this.group?this.group.depth++:this.group={label:e,steps:[],depth:1};let s=!0;try{const o=t();return s=!1,o}finally{const o=this.group;--o.depth===0&&(this.group=void 0,o.steps.length&&!s&&this.add(o.steps.length===1&&o.steps[0].label===o.label?o.steps[0]:new wu(o.label,o.steps)))}}undo(){return this.run("undo")}redo(){return this.run("redo")}canUndo(){return this.checkRows(!1),this.stack.canUndo()}canRedo(){return this.checkRows(!1),this.stack.canRedo()}getState(){var e,t;return this.checkRows(!1),new oc(this.stack.canUndo(),this.stack.canRedo(),(e=this.stack.peekUndo())==null?void 0:e.label,(t=this.stack.peekRedo())==null?void 0:t.label,this.stack.size())}clear(e=!1){const t=this.stack.canUndo()||this.stack.canRedo();this.stack.clear(),this.rowsRef=void 0,this.lastRecorded=void 0,this.group&&(this.group.steps.length=0),t&&!e&&this.fire()}add(e){if(this.group){this.group.steps.push(e);return}if(this.checkRows(),this.rowsRef??(this.rowsRef=this.currentRows()),!this.stack.push(e)){const t=this.tableScope;t.announce(t.getUndoTexts().undoHistoryCleared(this.options.maxCells))}this.fire()}run(e){const t=this.tableScope;if(t.isEditing()||this.group)return!1;this.checkRows();const s=e==="undo"?this.stack.undo():this.stack.redo(),o=t.getUndoTexts();if(!s)return t.announce(e==="undo"?o.nothingToUndo():o.nothingToRedo()),!1;let i;this.running=!0;try{i=e==="undo"?s.undo(t):s.redo(t)}finally{this.running=!1}i.range&&(t.selectBodyRange(i.range),t.ensureColumnIsVisible(i.range.c1),t.ensureRowIsVisible(i.range.r1));const r=e==="undo"?o.undone(s.label,i.applied):o.redone(s.label,i.applied);return t.announce(i.skipped?`${r}. ${o.undoSkipped(i.skipped)}`:r),this.fire(),!0}checkRows(e=!0){this.rowsRef&&this.currentRows()!==this.rowsRef&&this.clear(!e)}currentRows(){return tc(this.tableScope.tableModel.getBodyModel())}fire(){var e,t;(t=(e=this.tableScope.getEventListener()).onUndoStackChanged)==null||t.call(e,this.getState())}}function rc(n,e,t,s,o,i,r,l=()=>!0){const a=(d,u)=>{const f=d+i;let p=u+r;for(;r!==0&&p>=0&&p<t&&!l(p);)p+=r;return f>=0&&f<e&&p>=0&&p<t?[f,p]:void 0};let c=a(s,o);if(!c)return[s,o];if(!n(s,o)&&!n(c[0],c[1])){let d=c;for(let u=a(d[0],d[1]);u&&!n(u[0],u[1]);u=a(u[0],u[1]))d=u;return d}let h=c;for(;n(c[0],c[1]);){const d=a(c[0],c[1]);if(!d)return h;h=c=d}return c}function yu(n,e){return new Proxy(n,{get(t,s,o){const i=Reflect.get(t,s,o);return typeof s!="string"||!s.startsWith("on")||!e.size?i:(...r)=>{const l=typeof i=="function"?i.apply(t,r):void 0;for(const a of Array.from(e)){const c=a[s];if(typeof c=="function")try{c.apply(a,r)}catch(h){console.error(h)}}return l}}})}function At(n,e){const t=n==null?void 0:n[e],s=n==null?void 0:n.spreadsheet;if(t!==void 0||!s)return t;const o=typeof s=="object"?s[e]:void 0;if(o!==!1)return e==="editing"?{defaultEditable:!0,...typeof o=="object"?o:{}}:o??!0}function Cu(n){if(!(n!=null&&n.spreadsheet))return n;const e={...n};for(const t of["editing","clipboard","undo","cellFormulas","fillHandle"])e[t]=At(n,t);return e}class nc{constructor(e=[],t=[]){this.removed=e,this.inserted=t,this.insertBefore=new Int32Array(t.length);for(let s=0;s<t.length;s++)this.insertBefore[s]=t[s]-s}isEmpty(){return this.removed.length===0&&this.inserted.length===0}getRemovedCount(){return this.removed.length}getInsertedCount(){return this.inserted.length}touchesUpTo(e){return this.removed.length&&this.removed[0]<=e?!0:this.insertBefore.length>0&&this.insertBefore[0]<=e}mapIndex(e){if(e<0)return-1;const t=lo(this.removed,e);if(t<this.removed.length&&this.removed[t]===e)return-1;const s=e-t;return s+xi(this.insertBefore,s)}mapIndexOrNext(e){const t=Math.max(0,e-lo(this.removed,e));return t+xi(this.insertBefore,t)}mapRange(e,t){e>t&&([e,t]=[t,e]);const s=t>=Number.MAX_SAFE_INTEGER,o=e-lo(this.removed,e),i=s?Number.MAX_SAFE_INTEGER:t-lo(this.removed,t+1);if(i<o)return[];const r=[];let l=o,a=xi(this.insertBefore,o);for(let c=a;c<this.insertBefore.length&&this.insertBefore[c]<=i;c++){const h=this.insertBefore[c];h>l&&(r.push([l+a,h-1+a]),l=h),a++}return r.push([l+a,s?Number.MAX_SAFE_INTEGER:i+a]),r}}function lo(n,e){let t=0,s=n.length;for(;t<s;){const o=t+s>>>1;n[o]<e?t=o+1:s=o}return t}function xi(n,e){let t=0,s=n.length;for(;t<s;){const o=t+s>>>1;n[o]<=e?t=o+1:s=o}return t}class si{constructor(){this.doubleClick=!0,this.maxRows=1e4}static create(e){return{...new si,...e??{}}}}const Xr=class Xr{constructor(e){this.ctx=null;const t=e.querySelector(".ge-table-label"),s=getComputedStyle(t??e);this.padding=t?(parseFloat(s.paddingLeft)||0)+(parseFloat(s.paddingRight)||0):20;try{this.ctx=document.createElement("canvas").getContext("2d")}catch{this.ctx=null}this.ctx&&(this.ctx.font=s.font||`${s.fontSize} ${s.fontFamily}`)}measureText(e){const t=this.ctx?this.ctx.measureText(e).width:e.length*8;return Math.ceil(t+this.padding+2)}measureWidest(e){let t=this.measureText("");return e.forEach(s=>{t=Math.max(t,this.measureText(s))}),Math.max(t,50)}};Xr.maxCandidates=30;let Dt=Xr;function vu(n,e,t,s,o,i){var l,a;if(!n)return;const r=Dt.maxCandidates;for(let c=e;c<=t;c++)for(let h=0;h<s.length;h++){const d=s[h],u=((l=n.getTextValueAt)==null?void 0:l.call(n,c,d))||(((a=n.getValueAt(c,d))==null?void 0:a.toString())??""),f=u.length;f>i[h]&&(i[h]=f,o[h].forEach(p=>{p.length<f-2&&o[h].delete(p)})),f>=i[h]-2&&o[h].size<r&&o[h].add(u)}}class lc{constructor(e,t,s,o,i,r,l,a){this.type=e,this.source=t,this.columnIndex=s,this.columnDef=o,this.property=i,this.oldWidth=r,this.newWidth=l,this.originalEvent=a}}class ac{constructor(e,t,s,o,i,r,l){this.type=e,this.fromIndex=t,this.toIndex=s,this.columnDef=o,this.property=i,this.columnOrder=r,this.originalEvent=l}get moved(){return this.toIndex!==this.fromIndex}}class cc{constructor(e,t,s,o,i,r,l){this.areaIdent=e,this.rowIndex=t,this.columnIndex=s,this.value=o,this.row=i,this.source=r,this.originalEvent=l}}function hc(n,e,t){const s=Math.floor(t.count);if(!(s>0))return-1;const o=s-1;if(e==="first")return 0;if(e==="last")return o;if(!(n>=0&&n<=o))return Math.min(o,Math.max(0,Math.floor(t.firstVisible??0)));const i=Math.max(1,Math.floor(t.perRow)||1),r=Math.max(1,Math.floor(t.pageRows)||1),l=n%i,a=o-o%i,c=()=>Math.min(o,a+l);switch(e){case"previous":return Math.max(0,n-1);case"next":return Math.min(o,n+1);case"up":return n-i>=0?n-i:n;case"down":return n+i<=o?n+i:n<a?o:n;case"pageUp":{const h=n-r*i;return h>=0?h:l}default:{const h=n+r*i;return h<=o?h:n<a?c():n}}}function Ui(n,e){if(!(n>=0))return[-1,-1];const t=Math.max(1,Math.floor(e)||1);return[Math.floor(n/t),n%t]}function Es(n,e,t){const s=Math.max(1,Math.floor(t)||1);return!(n>=0)||!(e>=0)||e>=s?-1:n*s+e}class dc{constructor(e,t,s,o,i){this.filters=e,this.property=t,this.source=s,this.rowCount=o,this.unfilteredRowCount=i}}class Us{constructor(){this.showCondition=!0,this.showValues=!0,this.applyOnChange=!1,this.maxValues=1e4}static create(e,t){if(!e)return;const s=new Us,o=t!==void 0&&t>0?t:s.maxValues;return e===!0?{...s,maxValues:o}:{showCondition:e.showCondition??s.showCondition,showValues:e.showValues??s.showValues,applyOnChange:e.applyOnChange??s.applyOnChange,maxValues:Math.max(1,e.maxValues??o)}}}class oi{constructor(){this.visible=!0,this.debounce=200,this.placeholder=void 0,this.height=34,this.clearButtonVisible=!0,this.minInputWidthInPx=44}static create(e){if(!e)return;const t=new oi;return e===!0?t:{visible:e.visible??t.visible,debounce:Math.max(0,e.debounce??t.debounce),placeholder:e.placeholder??t.placeholder,height:Math.max(20,e.height??t.height),clearButtonVisible:e.clearButtonVisible??t.clearButtonVisible,minInputWidthInPx:Math.max(20,e.minInputWidthInPx??t.minInputWidthInPx)}}}class ii{constructor(){this.managed=!0,this.caseSensitive=!1,this.locale=void 0,this.maxValues=1e4}static create(e){const t=new ii;return e?{managed:e.managed??t.managed,caseSensitive:e.caseSensitive??t.caseSensitive,locale:e.locale??t.locale,maxValues:e.maxValues??t.maxValues}:t}}class eo{constructor(){this.searchPlaceholder="Search",this.searchValuesPlaceholder="Search values…",this.selectAll="(Select all)",this.blanks="(Blanks)",this.ok="OK",this.cancel="Cancel",this.clear="Clear",this.andLabel="and",this.noValues="No values",this.columnsTitle="Columns",this.searchColumnsPlaceholder="Search columns…",this.operators={contains:"Contains",startsWith:"Starts with",endsWith:"Ends with",equals:"Equals",notEquals:"Does not equal",lessThan:"Less than",lessOrEqual:"Less than or equal",greaterThan:"Greater than",greaterOrEqual:"Greater than or equal",between:"Between",blank:"Blank",notBlank:"Not blank"}}selectedValuesCount(e){return e===1?"(1 value)":`(${e} values)`}valuesTruncated(e){return`Showing first ${e.toLocaleString("en-US")} values – refine your search`}static create(e){const t=new eo;return e?{searchPlaceholder:e.searchPlaceholder??t.searchPlaceholder,searchValuesPlaceholder:e.searchValuesPlaceholder??t.searchValuesPlaceholder,selectAll:e.selectAll??t.selectAll,blanks:e.blanks??t.blanks,ok:e.ok??t.ok,cancel:e.cancel??t.cancel,clear:e.clear??t.clear,andLabel:e.andLabel??t.andLabel,selectedValuesCount:e.selectedValuesCount??t.selectedValuesCount.bind(t),valuesTruncated:e.valuesTruncated??t.valuesTruncated.bind(t),noValues:e.noValues??t.noValues,columnsTitle:e.columnsTitle??t.columnsTitle,searchColumnsPlaceholder:e.searchColumnsPlaceholder??t.searchColumnsPlaceholder,operators:{...t.operators,...e.operators??{}}}:t}}function Q(n){return!!(n==null||n===""||typeof n=="number"&&Number.isNaN(n)||n instanceof Date&&Number.isNaN(n.getTime()))}function Ki(n){return Q(n)?"blank":typeof n=="number"?`n:${Object.is(n,-0)?0:n}`:typeof n=="string"?`s:${n}`:typeof n=="boolean"?n?"b:true":"b:false":n instanceof Date?`d:${n.getTime()}`:`o:${String(n)}`}const Su=/^(\d{4})-(\d{2})-(\d{2})(?:$|[T ])/;function Pe(n){if(n instanceof Date){const e=n.getTime();return Number.isNaN(e)?void 0:Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())}if(typeof n=="string"){const e=Su.exec(n.trim());if(!e)return;const t=+e[1],s=+e[2],o=+e[3],i=new Date(Date.UTC(t,s-1,o));return i.getUTCFullYear()!==t||i.getUTCMonth()!==s-1||i.getUTCDate()!==o?void 0:i.getTime()}}function ys(n){if(typeof n=="number")return Number.isNaN(n)?void 0:n}function zi(n,e,t){const s=n.operator;if(s==="blank")return Q;if(s==="notBlank")return c=>!Q(c);const o=Q(n.value);if(s==="between"){const c=Q(n.valueTo);if(o&&c)return()=>!0;if(c)return zi({operator:"greaterOrEqual",value:n.value},e,t);if(o)return zi({operator:"lessOrEqual",value:n.valueTo},e,t)}else if(o&&(s==="equals"||s==="notEquals"))return s==="equals"?Q:c=>!Q(c);const i=s==="lessThan"||s==="lessOrEqual"||s==="greaterThan"||s==="greaterOrEqual"||s==="between";if(e==="number"||i&&typeof n.value=="number"){const c=typeof n.value=="number"?n.value:Number(n.value);if(Number.isNaN(c))return()=>!0;switch(s){case"equals":return h=>typeof h=="number"&&h===c;case"notEquals":return h=>typeof h!="number"||Number.isNaN(h)||h!==c;case"lessThan":return h=>{const d=ys(h);return d!==void 0&&d<c};case"lessOrEqual":return h=>{const d=ys(h);return d!==void 0&&d<=c};case"greaterThan":return h=>{const d=ys(h);return d!==void 0&&d>c};case"greaterOrEqual":return h=>{const d=ys(h);return d!==void 0&&d>=c};case"between":{const h=typeof n.valueTo=="number"?n.valueTo:Number(n.valueTo);if(Number.isNaN(h))return()=>!0;const d=Math.min(c,h),u=Math.max(c,h);return f=>{const p=ys(f);return p!==void 0&&p>=d&&p<=u}}}}if(e==="date"||n.value instanceof Date&&(i||s==="equals"||s==="notEquals")){const c=Pe(n.value);if(c===void 0)return()=>!0;switch(s){case"equals":return h=>Pe(h)===c;case"notEquals":return h=>Pe(h)!==c;case"lessThan":return h=>{const d=Pe(h);return d!==void 0&&d<c};case"lessOrEqual":return h=>{const d=Pe(h);return d!==void 0&&d<=c};case"greaterThan":return h=>{const d=Pe(h);return d!==void 0&&d>c};case"greaterOrEqual":return h=>{const d=Pe(h);return d!==void 0&&d>=c};case"between":{const h=Pe(n.valueTo);if(h===void 0)return()=>!0;const d=Math.min(c,h),u=Math.max(c,h);return f=>{const p=Pe(f);return p!==void 0&&p>=d&&p<=u}}}}if(e==="boolean"){const c=!!n.value;if(s==="equals")return h=>typeof h=="boolean"&&h===c;if(s==="notEquals")return h=>typeof h!="boolean"||h!==c}const r=n.value===null||n.value===void 0?"":String(n.value),l=t?r:r.toLowerCase(),a=t?c=>c==null?"":String(c):c=>c==null?"":String(c).toLowerCase();switch(s){case"contains":return c=>!Q(c)&&a(c).includes(l);case"startsWith":return c=>!Q(c)&&a(c).startsWith(l);case"endsWith":return c=>!Q(c)&&a(c).endsWith(l);case"equals":return c=>!Q(c)&&a(c)===l;case"notEquals":return c=>Q(c)||a(c)!==l;case"lessThan":return c=>!Q(c)&&a(c)<l;case"lessOrEqual":return c=>!Q(c)&&a(c)<=l;case"greaterThan":return c=>!Q(c)&&a(c)>l;case"greaterOrEqual":return c=>!Q(c)&&a(c)>=l;case"between":{const c=n.valueTo===null||n.valueTo===void 0?"":String(n.valueTo),h=t?c:c.toLowerCase(),d=l<=h?l:h,u=l<=h?h:l;return f=>{if(Q(f))return!1;const p=a(f);return p>=d&&p<=u}}default:return()=>!0}}const xu="\0d:";function ji(n){if(n==null||n==="")return null;if(typeof n=="number")return Number.isNaN(n)?null:n===0?0:n;if(typeof n=="string"||typeof n=="boolean")return n;if(n instanceof Date){const e=n.getTime();return Number.isNaN(e)?null:`${xu}${e}`}return n}function Ro(n){if(Q(n))return null;if(n instanceof Date)return n.getTime();if(typeof n=="string"){const e=Date.parse(n);return Number.isNaN(e)?n:e}return n}function uc(n,e="text",t){const s=(t==null?void 0:t.caseSensitive)??!1,o=n.condition?zi(n.condition,e,s):void 0;let i;if(n.values!==void 0){if(n.values.length===0)return()=>!1;const r=new Set;let l=!1;for(let c=0;c<n.values.length;c++){const h=n.values[c];h instanceof Date&&(l=!0),r.add(ji(h))}const a=r.has(null);if(e==="date"){const c=new Set;for(let h=0;h<n.values.length;h++)c.add(Ro(n.values[h]));i=h=>c.has(Ro(h))}else l?i=c=>r.has(ji(c)):i=c=>c==null||c===""||typeof c=="number"&&Number.isNaN(c)?a:r.has(c)}return o&&i?r=>i(r)&&o(r):o??i??(()=>!0)}function fc(n,e,t){const s=[],o=[];for(let r=0;r<e.length;r++){const l=e[r],a=n[l.property];!a||a.condition===void 0&&a.values===void 0||(s.push(l.getValue),o.push(uc(a,l.type,{caseSensitive:l.caseSensitive??(t==null?void 0:t.caseSensitive)??!1})))}const i=o.length;if(i!==0){if(i===1){const r=s[0],l=o[0];return a=>l(r(a))}return r=>{for(let l=0;l<i;l++)if(!o[l](s[l](r)))return!1;return!0}}}function Ru(n){if(n instanceof Date){if(Number.isNaN(n.getTime()))return"";const e=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0");return`${e}-${t}-${s}`}return String(n)}function zn(n){return Q(n)?99:typeof n=="number"?0:n instanceof Date?1:typeof n=="boolean"?2:3}function Au(n,e){const t=zn(n.value),s=zn(e.value);if(t!==s)return t-s;if(t===99)return 0;if(t===0)return n.value-e.value;if(t===1)return n.value.getTime()-e.value.getTime();if(t===2)return Number(n.value)-Number(e.value);const o=n.label??String(n.value),i=e.label??String(e.value);return o<i?-1:o>i?1:0}function pc(n,e,t={}){var h;const s=t.maxValues??1e4,o=t.blanksLabel??"(Blanks)",i=t.formatValue??Ru,r=((h=t.search)==null?void 0:h.trim().toLowerCase())??"",l=new Map;let a=!1;for(let d=0;d<n.length;d++){const u=e(n[d]),f=ji(u),p=l.get(f);if(p){p.count=(p.count??0)+1;continue}if(!r&&l.size>=s){a=!0;continue}const g=f===null,m=g?o:i(u);if(!(r&&!m.toLowerCase().includes(r))){if(l.size>=s){a=!0;continue}l.set(f,{value:g?null:u,label:m,count:1})}}const c=Array.from(l.values());return c.sort(Au),{items:c,truncated:a}}function jn(n){return n<10?`0${n}`:`${n}`}function Xn(n){return n instanceof Date?Number.isNaN(n.getTime())?void 0:`${n.getFullYear()}-${jn(n.getMonth()+1)}-${jn(n.getDate())}`:n}function Eu(n){return n instanceof Date?Number.isNaN(n.getTime())?null:n.toISOString():n}function Zt(n){var o;if(!n||typeof n!="object")return;const e=n.condition!==void 0&&typeof((o=n.condition)==null?void 0:o.operator)=="string",t=Array.isArray(n.values);if(!e&&!t)return;const s={};if(e){const i={operator:n.condition.operator};n.condition.value!==void 0&&(i.value=n.condition.value),n.condition.valueTo!==void 0&&(i.valueTo=n.condition.valueTo),s.condition=i}return t&&(s.values=n.values.slice()),s}function Ks(n){const e={},t=Object.keys(n);for(let s=0;s<t.length;s++){const o=t[s],i=Zt(n[o]);if(!i)continue;const r={};if(i.condition){const l={operator:i.condition.operator};i.condition.value!==void 0&&(l.value=Xn(i.condition.value)),i.condition.valueTo!==void 0&&(l.valueTo=Xn(i.condition.valueTo)),r.condition=l}i.values!==void 0&&(r.values=i.values.map(Eu)),e[o]=r}return e}function gc(n,e){const t={};if(!n||typeof n!="object")return t;const s=n,o=Object.keys(s);for(let i=0;i<o.length;i++){const r=o[i];if(e&&!e.has(r))continue;const l=Zt(s[r]);l&&(t[r]=l)}return t}function Xi(n,e){const t=Ks(n),s=Ks(e),o=Object.keys(t).sort(),i=Object.keys(s).sort();if(o.length!==i.length)return!1;for(let r=0;r<o.length;r++){const l=o[r];if(l!==i[r]||JSON.stringify(t[l])!==JSON.stringify(s[l]))return!1}return!0}function mc(n,e,t=100){let s,o=0;for(let i=0;i<n.length&&o<t;i++){const r=e(n[i]);if(Q(r))continue;o++;let l;if(typeof r=="number")l="number";else if(typeof r=="boolean")l="boolean";else if(r instanceof Date)l="date";else if(typeof r=="string"&&Pe(r)!==void 0)l="date";else return"text";if(s===void 0)s=l;else if(s!==l)return"text"}return s??"text"}const Mu=/^#(\d+)$/;function Yn(n){if(n&&typeof n=="object")return n}function Tu(n){if(typeof n=="string")return n;if(n&&typeof n=="object")return n.type}class bc{constructor(e){this.scope=e,this.filters={},this.typeCache=new Map,this.warnedNonFilterable=!1}getOptions(){return ii.create(this.scope.tableOptions.columnFilter)}getTexts(){return eo.create(this.scope.tableOptions.columnFilterTexts)}isColumnFilterable(e){const t=this.scope.tableModel;if(e<0||e>=t.getColumnCount())return!1;const s=t.getColumnDef(e);return!((s==null?void 0:s.filter)===!1||(s==null?void 0:s.filter)===void 0&&(G(s)||Ae(s)||ht(s)||js(s)))}hasActiveFilters(){return Object.keys(this.filters).length>0}isBodyFilterable(){return this.scope.tableModel.getBodyModel().isFilterable()}resolveColumn(e){var i;const t=this.scope.tableModel,s=t.getColumnDefs(),o=t.getColumnCount();if(typeof e=="number"){if(e<0||e>=o)return;const r=t.getColumnDef(e);return{property:(r==null?void 0:r.property)||`#${e}`,columnIndex:e,columnDef:r}}if(typeof e=="string"){if(!e)return;if(s){for(let l=0;l<s.length;l++)if(((i=s[l])==null?void 0:i.property)===e)return{property:e,columnIndex:l,columnDef:s[l]}}const r=Mu.exec(e);if(r){const l=Number(r[1]);if(l>=0&&l<o){const a=t.getColumnDef(l);return{property:(a==null?void 0:a.property)||`#${l}`,columnIndex:l,columnDef:a}}}return zt(t.getBodyModel())||ge(t.getBodyModel())?{property:e,columnIndex:-1,columnDef:void 0}:void 0}if(e&&typeof e=="object"){if(s){const r=s.indexOf(e);if(r>=0)return{property:e.property||`#${r}`,columnIndex:r,columnDef:e};if(e.property){const l=s.findIndex(a=>a.property===e.property);if(l>=0)return{property:e.property,columnIndex:l,columnDef:s[l]}}}if(e.property)return{property:e.property,columnIndex:-1,columnDef:e}}}getColumnFilter(e){const t=this.resolveColumn(e);if(!t)return;const s=this.filters[t.property];return s?Zt(s):void 0}getColumnFilters(){return Ks(this.filters)}isColumnFiltered(e){const t=this.resolveColumn(e);return!!t&&this.filters[t.property]!==void 0}setColumnFilter(e,t,s="api"){const o=this.resolveColumn(e);if(!o)return;const i=Zt(t),r={...this.filters};i?r[o.property]=i:delete r[o.property],this.commitFilters(r,o.property,s)}setColumnFilters(e,t="api"){const s={},o=Object.keys(e??{});for(let i=0;i<o.length;i++){const r=o[i],l=this.resolveColumn(r);if(!l)continue;const a=Zt(e[r]);a&&(s[l.property]=a)}this.commitFilters(s,void 0,t)}clearColumnFilters(e="api"){this.hasActiveFilters()&&this.commitFilters({},void 0,e)}applyStateFilters(e,t){const s=this.validPropertySet(),o=gc(e,s),i=!Xi(this.filters,o);return this.filters=o,this.cachedCompiled=void 0,t&&i?(this.runManagedFilter(!1,!1),this.scope.onColumnFiltersChanged("state"),this.emitFilterEvent(void 0,"state")):i&&this.scope.onColumnFiltersChanged("state"),i}getEffectiveFilterFunction(){const e=this.scope.tableOptions.externalFilterFunction;if(!this.hasActiveFilters()||!this.getOptions().managed)return e;const t=this.getCompiledColumnPredicate();return t?e?(s,o,i)=>!!e(s,o,i)&&t(s):s=>t(s):e}invalidateTypeCache(){this.typeCache.clear(),this.cachedCompiled=void 0}onRowsReplaced(){if(this.invalidateTypeCache(),this.hasActiveFilters()&&this.getOptions().managed&&this.isBodyFilterable()){const e=this.getEffectiveFilterFunction();e&&this.scope.reapplyFilterAfterSetRows(e)}}getColumnFilterType(e,t,s){const o=Tu(s==null?void 0:s.filter);if(o)return o;const i=this.typeCache.get(t);if(i)return i;const r=this.collectSampleRows(1e4),l=this.buildValueGetter(t,e,s),a=mc(r,l,100);let c=!1;for(let h=0;h<r.length&&!c;h++)c=!Q(l(r[h]));return c&&this.typeCache.set(t,a),a}collectColumnDistinctValues(e,t={}){const s=this.resolveColumn(e);if(!s)return{items:[],truncated:!1};const o=this.getOptions(),i=this.getTexts(),r=this.buildValueGetter(s.property,s.columnIndex,s.columnDef),l=this.buildOtherFiltersPredicate(s.property),a=this.getAllRowsForDistinct(),c=l?a.filter((h,d,u)=>l(h,d,u)):a;return pc(c,r,{maxValues:t.maxValues??o.maxValues,search:t.search,blanksLabel:t.blanksLabel??i.blanks,formatValue:t.formatValue})}getOtherFilters(e){const t={},s=Object.keys(this.filters);for(let o=0;o<s.length;o++){const i=s[o];i!==e&&(t[i]=this.filters[i])}return t}commitFilters(e,t,s){const o=this.getOptions();if(o.managed&&!this.isBodyFilterable()){this.warnedNonFilterable||(this.warnedNonFilterable=!0,console.warn("GuiExpert Table – columnFilter: body area model is not filterable (isFilterable() returned false). Set tableOptions.columnFilter = { managed: false } for server-side filtering."));return}const i=this.hasActiveFilters();Xi(this.filters,e)&&(!i||Object.keys(e).length>0)||(this.filters=e,this.cachedCompiled=void 0,o.managed&&this.runManagedFilter(!0,!0),this.scope.onColumnFiltersChanged(s),this.scope.stateService.markDirty("filters"),this.emitFilterEvent(t,s))}runManagedFilter(e,t){const o=this.getEffectiveFilterFunction()??(()=>!0);this.scope.applyFilterFunction(o,e,t,!0)}emitFilterEvent(e,t){var l,a,c;const s=this.scope.tableModel.getBodyModel(),o=s.getRowCount(),i=((l=s.getUnfilteredRowCount)==null?void 0:l.call(s))??o,r=new dc(Ks(this.filters),e,t,o,i);(c=(a=this.scope.getEventListener()).onFilterChanged)==null||c.call(a,r)}validPropertySet(){var i;const e=this.scope.tableModel.getBodyModel();if(zt(e)||ge(e))return;const t=this.scope.tableModel.getColumnDefs(),s=this.scope.tableModel.getColumnCount(),o=new Set;if(t&&t.length>0){for(let r=0;r<t.length;r++)(i=t[r])!=null&&i.property?o.add(t[r].property):o.add(`#${r}`);return o}for(let r=0;r<s;r++)o.add(`#${r}`);return o}getCompiledColumnPredicate(){if(this.cachedCompiled&&this.cachedCompiled.filters===this.filters)return this.cachedCompiled.fn;const e=this.compileForFilters(this.filters);return this.cachedCompiled={filters:this.filters,fn:e},e}buildOtherFiltersPredicate(e){const t=this.scope.tableOptions.externalFilterFunction,s=this.getOtherFilters(e),o=Object.keys(s).length>0?this.compileForFilters(s):void 0;return o?t?(i,r,l)=>!!t(i,r,l)&&o(i):i=>o(i):t}compileForFilters(e){var i;const t=Object.keys(e);if(t.length===0)return;const s=this.getOptions(),o=[];for(let r=0;r<t.length;r++){const l=t[r],a=this.resolveColumn(l);if(!a)continue;const c=Yn((i=a.columnDef)==null?void 0:i.filter),h=this.getColumnFilterType(a.columnIndex,a.property,a.columnDef),d=this.buildValueGetter(a.property,a.columnIndex,a.columnDef);o.push({property:l,type:h,getValue:d,caseSensitive:(c==null?void 0:c.caseSensitive)??s.caseSensitive})}return fc(e,o,{caseSensitive:s.caseSensitive})}buildValueGetter(e,t,s){var c;const o=Yn(s==null?void 0:s.filter);if(o!=null&&o.valueGetter)return o.valueGetter;const i=this.scope.tableModel.getBodyModel(),r=i;if(typeof r.getSheetColumnCount=="function"){const h=t-(r.columnOffset??0),d=r.sheetCells;return d?u=>{const f=Array.isArray(u)?u[h]:void 0;return f==null?"":typeof f=="string"?d.valueAt(u,t,f):f}:u=>Array.isArray(u)?u[h]:void 0}if(Array.isArray(i.arr)&&t>=0){const h=r.sheetCells;return h?d=>{const u=Array.isArray(d)?d[t]:void 0;return typeof u=="string"?h.valueAt(d,t,u):u}:d=>Array.isArray(d)?d[t]:void 0}if(zt(i))return dt(e);if(((s==null?void 0:s.valueGetter)!==void 0||(((c=i.isCalculatedProperty)==null?void 0:c.call(i,e))??!1)||!!r.sheetCells)&&i.getRowValue){const h=i.getRowValue.bind(i);return d=>h(d,e)}if(ee(i)&&!ge(i)){const h=dt(e);return d=>h(J(d)?d.data:d)}return e.includes(".")?dt(e):h=>h==null?void 0:h[e]}collectSampleRows(e){const t=this.scope.tableModel.getBodyModel(),s=t;if(typeof s.getSourceRows=="function")return s.getSourceRows().slice(0,e);const o=t;if(typeof o.getAllRows=="function")return o.getAllRows().slice(0,e);const i=t;if(Array.isArray(i.arr))return i.arr.slice(0,e);if(typeof t.getSheetColumnCount=="function"){const h=[],d=t.getRowCount();for(let u=0;u<d&&h.length<e;u++){const f=t.getRowByIndex(u);f!==void 0&&h.push(f)}return h}const l=t;if(ee(t)&&Array.isArray(l.rows)){const h=[],d=u=>{var f;for(let p=0;p<u.length&&h.length<e;p++)h.push(u[p]),(f=u[p].children)!=null&&f.length&&d(u[p].children)};return d(l.rows),h}const a=[],c=Math.min(t.getRowCount(),e);for(let h=0;h<c;h++)a.push(t.getRowByIndex(h));return a}getAllRowsForDistinct(){var a;const e=this.scope.tableModel.getBodyModel(),t=e;if(typeof t.getSourceRows=="function")return t.getSourceRows();const s=e;if(typeof s.getAllRows=="function")return s.getAllRows();const o=e;if(Array.isArray(o.arr))return o.arr;const i=e;if(ee(e)&&Array.isArray(i.rows)){const c=[],h=d=>{var u;for(let f=0;f<d.length;f++)c.push(d[f]),(u=d[f].children)!=null&&u.length&&h(d[f].children)};return h(i.rows),c}const r=((a=e.getUnfilteredRowCount)==null?void 0:a.call(e))??e.getRowCount(),l=[];for(let c=0;c<r;c++)l.push(e.getRowByIndex(c));return l}}const Iu=["true","yes","1","wahr","ja"],Du=["false","no","0","falsch","nein"];function qn(n){return n<10?`0${n}`:`${n}`}function Rt(n){return`${n.getFullYear()}-${qn(n.getMonth()+1)}-${qn(n.getDate())}`}function Jn(n){const e=n.trim();return e.startsWith(">=")?{operator:"greaterOrEqual",rest:e.slice(2).trim()}:e.startsWith("<=")?{operator:"lessOrEqual",rest:e.slice(2).trim()}:e.startsWith("!=")||e.startsWith("<>")?{operator:"notEquals",rest:e.slice(2).trim()}:e.startsWith(">")?{operator:"greaterThan",rest:e.slice(1).trim()}:e.startsWith("<")?{operator:"lessThan",rest:e.slice(1).trim()}:e.startsWith("=")?{operator:"equals",rest:e.slice(1).trim()}:{rest:e}}const wc=/^(\d{4})-(\d{1,2})$/;function ao(n,e,t){const s=wc.exec(n);if(s){const o=Number(s[1]),i=Number(s[2]);return i<1||i>12?void 0:e?new Date(o,i,0):new Date(o,i-1,1)}return Qs(n,t)??void 0}function Fu(n){let e="contains",t=n;return n.startsWith("!=")||n.startsWith("<>")?(e="notEquals",t=n.slice(2).trim()):n.startsWith("=")?(e="equals",t=n.slice(1).trim()):n.startsWith("^")?(e="startsWith",t=n.slice(1).trim()):n.endsWith("$")&&(e="endsWith",t=n.slice(0,-1).trim()),t?{operator:e,value:t}:null}function yc(n,e="text",t){const s=n.trim();if(s){if(s==='""')return{operator:"blank"};if(/^(!=|<>)\s*""$/.test(s))return{operator:"notBlank"};if(e==="text"||e==="set")return Fu(s);if(e==="boolean"){const o=s.toLowerCase();return Iu.includes(o)?{operator:"equals",value:!0}:Du.includes(o)?{operator:"equals",value:!1}:null}if(e==="number"){const o=s.indexOf("..");if(o!==-1){const a=s.slice(0,o).trim(),c=s.slice(o+2).trim();if(!a||!c)return null;const h=Xt(a,t),d=Xt(c,t);return h===void 0||d===void 0?null:{operator:"between",value:h,valueTo:d}}const{operator:i,rest:r}=Jn(s);if(!r)return null;const l=Xt(r,t);return l===void 0?null:{operator:i??"equals",value:l}}if(e==="date"){const o=s.indexOf("..");if(o!==-1){const a=s.slice(0,o).trim(),c=s.slice(o+2).trim();if(!a||!c)return null;const h=ao(a,!1,t),d=ao(c,!0,t);return!h||!d?null:{operator:"between",value:Rt(h),valueTo:Rt(d)}}const{operator:i,rest:r}=Jn(s);if(!r)return null;if(wc.test(r)){const a=ao(r,!1,t),c=ao(r,!0,t);return!a||!c?null:i===void 0||i==="equals"?{operator:"between",value:Rt(a),valueTo:Rt(c)}:i==="notEquals"?null:{operator:i,value:Rt(i==="greaterThan"||i==="lessOrEqual"?c:a)}}const l=Qs(r,t);return l?{operator:i??"equals",value:Rt(l)}:null}return{operator:"contains",value:s}}}function Zn(n,e){return n==null?"":n instanceof Date?Number.isNaN(n.getTime())?"":Rt(n):typeof n=="number"?Pr(n,e):String(n)}function Pr(n,e){const t=String(n);if(!t.includes(".")||/e/i.test(t))return t;let s=".";try{const o=new Intl.NumberFormat(e).formatToParts(1.5).find(i=>i.type==="decimal");s=(o==null?void 0:o.value)??"."}catch{}return s==="."?t:t.replace(".",s)}function Yi(n,e,t){if(!n)return"";const s=eo.create(e);if(n.values!==void 0&&!n.condition)return s.selectedValuesCount(n.values.length);const o=n.condition;if(!o)return"";const i=Zn(o.value,t);let r;switch(o.operator){case"contains":r=i;break;case"startsWith":r=`^${i}`;break;case"endsWith":r=`${i}$`;break;case"equals":r=`= ${i}`;break;case"notEquals":r=`!= ${i}`;break;case"lessThan":r=`< ${i}`;break;case"lessOrEqual":r=`<= ${i}`;break;case"greaterThan":r=`> ${i}`;break;case"greaterOrEqual":r=`>= ${i}`;break;case"between":r=`${i}..${Zn(o.valueTo,t)}`;break;case"blank":r='""';break;case"notBlank":r='!=""';break;default:r=i}return n.values!==void 0?`${r} ${s.selectedValuesCount(n.values.length)}`:r}const Qn="http://www.w3.org/2000/svg";function ku(n,e){if(n!=null&&n.filter&&typeof n.filter=="object"){const t=n.filter.placeholder;if(t!==void 0)return t}return e}function Lu(n){const e=n.createElementNS(Qn,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=n.createElementNS(Qn,"path");return t.setAttribute("fill","currentColor"),t.setAttribute("d","M2 3.25A.75.75 0 0 1 2.75 2.5h10.5a.75.75 0 0 1 .58 1.22L9.75 8.6v4.15a.75.75 0 0 1-1.17.62l-2-1.33a.75.75 0 0 1-.33-.62V8.6L2.17 3.72A.75.75 0 0 1 2 3.25Z"),e.appendChild(t),e}class Cc{constructor(e,t){this.scope=e,this.options=t,this.cells=new Map,this.timers=new Map,this.drafts=new Map,this.abortController=new AbortController,this.lastLayerTop=-1,this.lastLayerWidth=-1,this.lastLayerHeight=-1,this.lastLayerVisible=!1,this.destroyed=!1,this.dom=e.getDomService(),this.visible=t.visible;const s=e.columnFilterService.isBodyFilterable(),o=e.columnFilterService.getOptions().managed;this.supported=s||!o,this.supported||console.warn("GuiExpert Table – filterRow is ignored: the body area model is not filterable (set columnFilter: { managed: false } for server-side filtering).");const i=e.hostElement;this.layer=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-filter-row-layer",i)),this.dom.setAttribute(this.layer,"role","presentation"),this.dom.applyDisplayNoneStyle(this.layer),this.sides={west:this.createSideSlot("west"),center:this.createSideSlot("center"),east:this.createSideSlot("east")}}isVisible(){return!this.destroyed&&this.supported&&this.visible&&this.scope.tableModel.isHeaderVisibe()}getVisibleOption(){return this.visible}getReservedHeight(){return this.isVisible()?this.options.height:0}setVisible(e){const t=!!e;return this.visible===t?!1:(this.visible=t,t||this.hideLayer(),!0)}isInLayer(e){var s;if(this.destroyed)return!1;const t=(s=e.composedPath)==null?void 0:s.call(e);return t!=null&&t.length?t.includes(this.layer):e.target instanceof Node&&this.layer.contains(e.target)}update(){if(this.destroyed)return;if(!this.isVisible()){this.hideLayer();return}const e=this.scope.tableModel,t=this.getHeaderRowsHeight(),s=this.scope.getLayoutWidth(),o=e.getPadding(),i=o.left,r=o.right,l=Math.max(0,s-i-r),a=this.options.height;this.lastLayerVisible||(this.dom.applyDisplayBlockStyle(this.layer),this.lastLayerVisible=!0),(this.lastLayerTop!==t||this.lastLayerWidth!==s||this.lastLayerHeight!==a)&&(this.dom.applyStyle(this.layer,{top:`${t}px`,left:"0px",width:`${s}px`,height:`${a}px`}),this.lastLayerTop=t,this.lastLayerWidth=s,this.lastLayerHeight=a),this.layoutSide(this.sides.west,0,i,i>0),this.layoutSide(this.sides.center,i,l,l>0),this.layoutSide(this.sides.east,s-r,r,r>0);const c=e.getColumnCount(),h=e.getFixedLeftColumnCount(),d=e.getFixedRightColumnCount(),u=Math.max(h,c-d),f=this.scope.getAriaGridInfo(),p=f.filterRowIndex(),g=new Set;let m=0;for(let w=0;w<h&&w<c;w++){const y=e.getColumnWidth(w);y>0&&(this.mountOrUpdateCell("west",w,m,y,f.colIndex(w),g),m+=y)}m=-this.scope.getContentScrollLeft();for(let w=h;w<u;w++){const y=e.getColumnWidth(w);if(y>0&&(m+y>0&&m<l&&this.mountOrUpdateCell("center",w,m,y,f.colIndex(w),g),m+=y,m>=l))break}m=0;for(let w=u;w<c;w++){const y=e.getColumnWidth(w);y>0&&(this.mountOrUpdateCell("east",w,m,y,f.colIndex(w),g),m+=y)}const b=[];this.cells.forEach((w,y)=>{g.has(y)||(this.isCellFocused(w)?this.parkCell(w):(w.el.remove(),b.push(y)))});for(let w=0;w<b.length;w++)this.cells.delete(b[w]);this.updateSideRoles(p)}syncFromFilters(e){if(this.destroyed)return;e!=="row"&&(this.clearAllTimers(),this.drafts.clear());const t=this.scope.columnFilterService.getTexts();this.cells.forEach(s=>{if(!s.filterable||!s.input)return;const o=this.scope.columnFilterService.getColumnFilter(s.key),i=!!(o!=null&&o.values&&o.values.length>0)||(o==null?void 0:o.values)!==void 0&&o.values.length===0;if(e!=="row"||!this.isCellFocused(s)){const r=o?Yi(o,t,this.scope.columnFilterService.getOptions().locale):"";s.input.value!==r&&(s.input.value=r)}this.applyCellFilterState(s,o!==void 0,i)})}focusColumn(e){if(!this.isVisible())return!1;const t=this.scope.tableModel;if(e<0||e>=t.getColumnCount()||t.getColumnWidth(e)<=0||!this.scope.columnFilterService.isColumnFilterable(e))return!1;this.scope.ensureColumnIsVisible(e),this.update();const s=this.columnKey(e),o=this.cells.get(s);return o!=null&&o.input?(o.input.focus(),!0):!1}focusActiveOrFirstColumn(e){if(!this.isVisible())return!1;if(e!==void 0&&this.focusColumn(e))return!0;const t=this.scope.tableModel.getColumnCount();for(let s=0;s<t;s++)if(this.scope.tableModel.getColumnWidth(s)>0&&this.scope.columnFilterService.isColumnFilterable(s))return this.focusColumn(s);return!1}destroy(){this.destroyed||(this.destroyed=!0,this.clearAllTimers(),this.drafts.clear(),this.abortController.abort(),this.cells.clear(),this.layer.remove())}createSideSlot(e){const t=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-filter-side ge-table-filter-side-${e}`,this.layer));this.dom.setAttribute(t,"id",this.scope.ariaIds.filterRowGroup(e)),this.dom.setAttribute(t,"role","presentation"),this.dom.applyStyle(t,{top:"0px",height:"100%",overflow:"hidden"});const s=this.dom.createDivWithClass("ge-table-filter-row",t);return this.dom.setAttribute(s,"role","presentation"),this.dom.applyStyle(s,{position:"relative",width:"100%",height:"100%"}),{side:e,container:t,row:s,lastLeft:-1,lastWidth:-1,lastVisible:!1}}layoutSide(e,t,s,o){e.lastVisible!==o&&(o?this.dom.applyDisplayBlockStyle(e.container):this.dom.applyDisplayNoneStyle(e.container),e.lastVisible=o),o&&(e.lastLeft!==t||e.lastWidth!==s)&&(this.dom.applyStyle(e.container,{left:`${t}px`,width:`${s}px`}),e.lastLeft=t,e.lastWidth=s)}hideLayer(){this.lastLayerVisible&&(this.dom.applyDisplayNoneStyle(this.layer),this.lastLayerVisible=!1);for(const e of["west","center","east"]){const t=this.sides[e];t.container.getAttribute("role")!=="presentation"&&this.dom.setAttribute(t.container,"role","presentation"),t.row.getAttribute("role")!=="presentation"&&(this.dom.setAttribute(t.row,"role","presentation"),this.dom.removeAttribute(t.row,"aria-rowindex"))}}updateSideRoles(e){const t=`${e}`;for(const s of["west","center","east"]){const o=this.sides[s];o.lastVisible&&o.row.childElementCount>0?(o.container.getAttribute("role")!=="rowgroup"&&this.dom.setAttribute(o.container,"role","rowgroup"),o.row.getAttribute("role")!=="row"&&this.dom.setAttribute(o.row,"role","row"),o.row.getAttribute("aria-rowindex")!==t&&this.dom.setAttribute(o.row,"aria-rowindex",t)):(o.container.getAttribute("role")!=="presentation"&&this.dom.setAttribute(o.container,"role","presentation"),o.row.getAttribute("role")!=="presentation"&&(this.dom.setAttribute(o.row,"role","presentation"),this.dom.removeAttribute(o.row,"aria-rowindex")))}}columnKey(e){const t=this.scope.tableModel.getColumnDef(e);return(t==null?void 0:t.property)||`#${e}`}mountOrUpdateCell(e,t,s,o,i,r){const l=this.columnKey(t),a=this.scope.columnFilterService.isColumnFilterable(t),c=this.scope.getColumnAriaLabel(t),h=this.sides[e];r.add(l);let d=this.cells.get(l);if(d&&d.filterable!==a&&(d.el.remove(),this.cells.delete(l),d=void 0),d?(d.side!==e||d.el.parentElement!==h.row)&&(d.side=e,this.dom.domService.appendChild(h.row,d.el)):(d=this.createCell(l,t,e,a,c,h.row),this.cells.set(l,d)),d.columnIndex=t,d.parked&&(d.parked=!1,this.dom.applyStyle(d.el,{clipPath:"",pointerEvents:""})),(d.lastLeft!==s||d.lastWidth!==o)&&(this.dom.applyStyle(d.el,{left:`${s}px`,width:`${o}px`}),d.lastLeft=s,d.lastWidth=o),d.lastColIndex!==i&&(this.dom.setAttribute(d.el,"aria-colindex",`${i}`),this.dom.setAttribute(d.el,"data-col-index",`${t}`),d.lastColIndex=i),d.filterable){const u=o<this.options.minInputWidthInPx;d.lastNarrow!==u&&(u?this.dom.addClass("ge-table-filter-cell-narrow",d.el):this.dom.removeClass("ge-table-filter-cell-narrow",d.el),d.lastNarrow=u),d.lastLabel!==c&&(this.updateCellLabels(d,c),d.lastLabel=c)}}createCell(e,t,s,o,i,r){const l=this.scope.hostElement.ownerDocument,a=this.dom.domService,c=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(o?"ge-table-filter-cell":"ge-table-filter-cell ge-table-filter-cell-disabled",r));this.dom.setAttribute(c,"role","gridcell"),this.dom.setAttribute(c,"data-col-property",e),this.dom.setAttribute(c,"data-col-index",`${t}`),this.dom.applyStyle(c,{top:"0px",height:"100%"});const h={key:e,columnIndex:t,filterable:o,side:s,el:c,parked:!1,lastLeft:Number.NaN,lastWidth:Number.NaN,lastColIndex:-1,lastLabel:i,lastNarrow:!1};if(!o)return h;const d=this.scope.columnFilterService.getTexts(),u=this.scope.tableModel.getColumnDef(t),f=ku(u,this.options.placeholder??d.searchPlaceholder),p=this.abortController.signal,g=a.createElement("input");a.setAttribute(g,"type","text"),a.setAttribute(g,"tabindex","-1"),a.setAttribute(g,"autocomplete","off"),a.setAttribute(g,"autocorrect","off"),a.setAttribute(g,"autocapitalize","none"),a.setAttribute(g,"spellcheck","false"),f&&a.setAttribute(g,"placeholder",f),a.addClass(g,"ge-table-filter-input"),a.appendChild(c,g),h.input=g;const m=a.createElement("button");a.setAttribute(m,"type","button"),a.setAttribute(m,"tabindex","-1"),a.addClass(m,"ge-table-filter-clear");const b=a.createElement("span");a.setAttribute(b,"aria-hidden","true"),b.textContent="×",a.appendChild(m,b),m.hidden=!0,a.appendChild(c,m),h.clearBtn=m;const w=a.createElement("button");a.setAttribute(w,"type","button"),a.setAttribute(w,"tabindex","-1"),a.addClass(w,"ge-table-filter-narrow-btn"),a.appendChild(w,Lu(l)),a.appendChild(c,w),h.narrowBtn=w,this.updateCellLabels(h,i);const y=this.scope.columnFilterService.getColumnFilter(e),C=(y==null?void 0:y.values)!==void 0;return this.drafts.has(e)&&!C?g.value=this.drafts.get(e)??"":y&&(g.value=Yi(y,d,this.scope.columnFilterService.getOptions().locale)),this.applyCellFilterState(h,y!==void 0,C),g.addEventListener("focus",()=>{this.scope.clearHeaderFocusForFilterRow()},{signal:p}),g.addEventListener("focusout",()=>{h.parked&&!this.isCellFocused(h)&&(h.el.remove(),this.cells.delete(h.key))},{signal:p}),g.addEventListener("input",()=>{g.readOnly||this.onInputChanged(h)},{signal:p}),g.addEventListener("keydown",S=>{this.onInputKeyDown(h,S)},{signal:p}),m.addEventListener("click",()=>{this.clearCellFilter(h,!0)},{signal:p}),w.addEventListener("click",()=>{var S;(S=this.scope.columnFilterMenuService)!=null&&S.hasHeaderButtons()?this.scope.toggleColumnFilterMenu(h.columnIndex):g.focus()},{signal:p}),h}updateCellLabels(e,t){const s=this.dom.domService,o=this.scope.ariaTexts,i=o.filterInput?o.filterInput(t):`Filter ${t}`,r=o.clearColumnFilter?o.clearColumnFilter(t):`Clear filter for ${t}`;e.input&&s.setAttribute(e.input,"aria-label",i),e.clearBtn&&s.setAttribute(e.clearBtn,"aria-label",r),e.narrowBtn&&s.setAttribute(e.narrowBtn,"aria-label",i)}getHeaderRowsHeight(){const e=this.scope.tableModel,t=e.getAreaModel("header"),s=(t==null?void 0:t.getRowCount())??0;let o=0;for(let i=0;i<s;i++)o+=e.getRowHeight("header",i);return o>0?o:Math.max(0,e.getPadding().top-this.options.height)}applyCellFilterState(e,t,s){if(e.input&&(e.input.readOnly=s,s?this.dom.addClass("ge-table-filter-input-readonly",e.input):this.dom.removeClass("ge-table-filter-input-readonly",e.input),t?this.dom.addClass("ge-table-filter-cell-active",e.el):this.dom.removeClass("ge-table-filter-cell-active",e.el),e.clearBtn)){const o=this.options.clearButtonVisible&&(t||e.input.value.length>0);e.clearBtn.hidden=!o}}onInputChanged(e){const t=e.input;if(!t)return;const s=t.value;if(this.drafts.set(e.key,s),this.applyCellFilterState(e,this.scope.columnFilterService.isColumnFiltered(e.key),!1),this.cancelTimer(e.key),this.options.debounce<=0)this.commitCellInput(e);else{const o=setTimeout(()=>{this.timers.delete(e.key),this.commitCellInput(e)},this.options.debounce);this.timers.set(e.key,o)}}onInputKeyDown(e,t){const s=e.input;if(s&&!(t.isComposing||t.keyCode===229)){if(t.key==="Enter"){t.preventDefault(),this.cancelTimer(e.key),s.readOnly||this.commitCellInput(e);return}if(t.key==="Escape"){t.preventDefault(),s.value.length>0||this.scope.columnFilterService.isColumnFiltered(e.key)?this.clearCellFilter(e,!0):this.scope.focusHeaderFromFilterRow(e.columnIndex);return}if((t.key==="Backspace"||t.key==="Delete")&&s.readOnly){t.preventDefault(),this.clearCellFilter(e,!0);return}if(t.key==="ArrowUp"){t.preventDefault(),this.scope.focusHeaderFromFilterRow(e.columnIndex);return}if(t.key==="ArrowDown"){t.preventDefault(),this.scope.focusBodyFromFilterRow(e.columnIndex);return}if(t.key==="Tab"){const o=this.findAdjacentFilterableColumn(e.columnIndex,t.shiftKey?-1:1);o>=0&&(t.preventDefault(),this.focusColumn(o))}}}commitCellInput(e){var c;if(this.destroyed)return;const t=this.drafts.has(e.key)?this.drafts.get(e.key)??"":((c=e.input)==null?void 0:c.value)??"";this.drafts.delete(e.key);const s=this.scope.columnFilterService,o=s.resolveColumn(e.key),i=(o==null?void 0:o.columnIndex)??e.columnIndex,r=s.getColumnFilterType(i,e.key,o==null?void 0:o.columnDef),l=s.getOptions().locale,a=yc(t,r,l);if(a===null){e.input&&this.drafts.set(e.key,t);return}a?s.setColumnFilter(e.key,{condition:a},"row"):s.setColumnFilter(e.key,void 0,"row")}clearCellFilter(e,t){this.cancelTimer(e.key),this.drafts.delete(e.key),e.input&&(e.input.value="",e.input.readOnly=!1),this.applyCellFilterState(e,!1,!1),this.scope.columnFilterService.setColumnFilter(e.key,void 0,"row"),t&&e.input&&e.input.isConnected&&e.input.focus()}findAdjacentFilterableColumn(e,t){const s=this.scope.tableModel,o=s.getColumnCount();for(let i=e+t;i>=0&&i<o;i+=t)if(s.getColumnWidth(i)>0&&this.scope.columnFilterService.isColumnFilterable(i))return i;return-1}isCellFocused(e){var o,i,r;const t=(i=(o=this.layer).getRootNode)==null?void 0:i.call(o),s=t&&"activeElement"in t?t.activeElement:(r=this.scope.hostElement.ownerDocument)==null?void 0:r.activeElement;return!!s&&e.el.contains(s)}parkCell(e){e.parked||(e.parked=!0,this.dom.applyStyle(e.el,{clipPath:"inset(100%)",pointerEvents:"none"}))}cancelTimer(e){const t=this.timers.get(e);t!==void 0&&(clearTimeout(t),this.timers.delete(e))}clearAllTimers(){this.timers.forEach(e=>clearTimeout(e)),this.timers.clear()}}const Ou='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Nu(n){return typeof HTMLElement<"u"&&Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover")&&typeof n.showPopover=="function"}function el(n){const e=n.querySelectorAll(Ou),t=[];for(let s=0;s<e.length;s++){const o=e[s];!o.hidden&&o.offsetParent!==null&&t.push(o)}return t}class Br{constructor(e){this.scope=e,this.usingPopover=!1}isOpen(){return this.el!==void 0}getElement(){return this.el}isInPopup(e){var o;const t=this.el;if(!t)return!1;const s=(o=e.composedPath)==null?void 0:o.call(e);return s!=null&&s.length?s.includes(t):e.target instanceof Node&&t.contains(e.target)}open(e){var b,w;this.el&&this.close("api");const t=this.scope.hostElement,s=t.ownerDocument,o=s.defaultView??window,i=this.scope.getDomService().domService,r=i.createElement("div");if(i.addClass(r,"ge-table-filter-popup"),e.className)for(const y of e.className.split(/\s+/).filter(Boolean))i.addClass(r,y);i.setAttribute(r,"role","dialog"),i.setAttribute(r,"aria-modal","false"),i.setAttribute(r,"aria-label",e.ariaLabel),i.setAttribute(r,"tabindex","-1"),i.setAttribute(r,"dir",this.scope.direction);const l=(b=t.getRootNode)==null?void 0:b.call(t),a=s.fullscreenElement,c=a&&(a===t||a.contains(t))?a:typeof ShadowRoot<"u"&&l instanceof ShadowRoot?l:s.body,h=Nu(r);if(this.usingPopover=h,h?(i.setAttribute(r,"popover","manual"),c.appendChild(r)):(i.addClass(r,"ge-table-filter-popup-fallback"),c.appendChild(r)),this.el=r,this.onCloseCb=e.onClose,this.lastAnchorRect=e.anchorRect,h)try{r.showPopover()}catch{this.usingPopover=!1,(w=i.removeAttribute)==null||w.call(i,r,"popover"),i.addClass(r,"ge-table-filter-popup-fallback"),r.parentNode!==c&&c.appendChild(r)}const d=new AbortController;this.abortController=d;const u=d.signal;r.addEventListener("keydown",y=>{var C;if(y.key==="Escape"){y.preventDefault(),this.close("escape");return}if(y.key==="Tab"){const S=el(r);if(S.length===0){y.preventDefault(),r.focus();return}const x=(C=r.getRootNode)==null?void 0:C.call(r),R=x&&"activeElement"in x?x.activeElement:s.activeElement,I=S[0],A=S[S.length-1];y.shiftKey?(R===I||R===r||!r.contains(R))&&(y.preventDefault(),A.focus()):(R===A||!r.contains(R))&&(y.preventDefault(),I.focus())}},{signal:u});let f=!1;const p=y=>{var x;const C=(x=y.composedPath)==null?void 0:x.call(y);if(C!=null&&C.length){if(C.includes(r)||e.triggerEl&&C.includes(e.triggerEl))return!1;if(e.isTrigger)for(let R=0;R<C.length;R++){const I=C[R];if(I instanceof HTMLElement&&e.isTrigger(I))return!1}return!0}const S=y.target;return S?!(r.contains(S)||e.triggerEl&&e.triggerEl.contains(S)):!0};s.addEventListener("pointerdown",y=>{f=p(y)},{capture:!0,signal:u}),s.addEventListener("pointerup",y=>{f&&p(y)?(f=!1,this.close("outside")):f=!1},{capture:!0,signal:u});const g=this.scope.scrollViewport,m=g.scrollLeft;return g.addEventListener("scroll",()=>{Math.abs(g.scrollLeft-m)>=1&&this.close("scroll")},{passive:!0,signal:u}),o.addEventListener("resize",()=>{this.close("resize")},{passive:!0,signal:u}),r}reposition(e=this.lastAnchorRect){const t=this.el;if(!t||!e)return;this.lastAnchorRect=e;const s=t.ownerDocument.defaultView??window,o=s.innerWidth||t.ownerDocument.documentElement.clientWidth||1024,i=s.innerHeight||t.ownerDocument.documentElement.clientHeight||768,r=8,l=4;t.style.position="fixed",t.style.inset="auto",t.style.margin="0";const a=t.getBoundingClientRect(),c=a.width||260,h=a.height||300;let d=e.bottom+l;d+h>i-r&&e.top-l-h>=r&&(d=e.top-l-h),d=Math.max(r,Math.min(d,Math.max(r,i-h-r)));let u;this.scope.isRtl()?(u=e.right-c,u<r&&e.left+c<=o-r&&(u=e.left)):(u=e.left,u+c>o-r&&e.right-c>=r&&(u=e.right-c)),u=Math.max(r,Math.min(u,Math.max(r,o-c-r))),t.style.left=`${Math.round(u)}px`,t.style.top=`${Math.round(d)}px`}focusInitial(e){const t=this.el;if(!t)return;if(e&&!e.hidden&&e.isConnected){e.focus({preventScroll:!0});return}const s=el(t);s.length>0?s[0].focus({preventScroll:!0}):t.focus({preventScroll:!0})}close(e="api"){var l,a,c;const t=this.el;if(!t)return;const s=this.onCloseCb,o=(l=t.getRootNode)==null?void 0:l.call(t),i=o&&"activeElement"in o?o.activeElement:t.ownerDocument.activeElement,r=!!i&&t.contains(i);if(this.el=void 0,this.onCloseCb=void 0,this.lastAnchorRect=void 0,(a=this.abortController)==null||a.abort(),this.abortController=void 0,this.usingPopover)try{(c=t.hidePopover)==null||c.call(t)}catch{}if(this.usingPopover=!1,t.remove(),s==null||s(e),r&&e!=="destroy"){const h=t.ownerDocument;(!h.activeElement||h.activeElement===h.body)&&this.scope.hostElement.focus({preventScroll:!0})}}destroy(){this.close("destroy")}}const tl="http://www.w3.org/2000/svg",Cs=28,sl=4,ol={text:["contains","startsWith","endsWith","equals","notEquals","blank","notBlank"],number:["equals","notEquals","greaterThan","greaterOrEqual","lessThan","lessOrEqual","between","blank","notBlank"],date:["equals","notEquals","greaterThan","greaterOrEqual","lessThan","lessOrEqual","between","blank","notBlank"],boolean:["equals","notEquals","blank","notBlank"],set:[]};function Vu(n){const e=n.createElementNS(tl,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=n.createElementNS(tl,"path");return t.setAttribute("fill","currentColor"),t.setAttribute("d","M2 3.25A.75.75 0 0 1 2.75 2.5h10.5a.75.75 0 0 1 .58 1.22L9.75 8.6v4.15a.75.75 0 0 1-1.17.62l-2-1.33a.75.75 0 0 1-.33-.62V8.6L2.17 3.72A.75.75 0 0 1 2 3.25Z"),e.appendChild(t),e}function Ri(n,e,t){if(n==null)return"";if(typeof n=="number")return Pr(n,t);if(e==="date"&&n instanceof Date&&!Number.isNaN(n.getTime())){const s=n.getFullYear(),o=`${n.getMonth()+1}`.padStart(2,"0"),i=`${n.getDate()}`.padStart(2,"0");return`${s}-${o}-${i}`}return String(n)}function Ai(n,e,t){const s=n.trim();if(s){if(e==="number"){const o=Xt(s,t);return Number.isNaN(o)?void 0:o}if(e==="date")return Qs(s,t)??void 0;if(e==="boolean"){const o=s.toLowerCase();return o==="true"||o==="1"||o==="yes"?!0:o==="false"||o==="0"||o==="no"?!1:void 0}return n}}function Pu(n){return n!=null&&n.filter&&typeof n.filter=="object"?n.filter:void 0}class qi{constructor(e,t,s=!0){this.scope=e,this.options=t,this.showHeaderButtons=s,this.openColumnIndex=-1,this.loadGeneration=0,this.destroyed=!1;const o=e.columnFilterService.isBodyFilterable(),i=e.columnFilterService.getOptions().managed;this.supported=o||!i,this.supported||console.warn("GuiExpert Table – columnFilterMenu is ignored: the body area model is not filterable (set columnFilter: { managed: false } for server-side filtering)."),this.popup=new Br(e)}isActive(){return!this.destroyed&&this.supported}hasHeaderButtons(){return this.isActive()&&this.showHeaderButtons}isOpen(){return this.popup.isOpen()}getOpenColumnIndex(){return this.popup.isOpen()?this.openColumnIndex:-1}isInPopup(e){return this.popup.isInPopup(e)}decorateHeaderCell(e,t,s){if(!this.hasHeaderButtons()||!this.scope.columnFilterService.isColumnFilterable(s))return;const o=this.scope.getDomService().domService,i=e.ownerDocument,r=this.scope.columnFilterService.isColumnFiltered(s),l=this.popup.isOpen()&&this.openColumnIndex===s,a=this.scope.getColumnAriaLabel(s),c=this.scope.ariaTexts,h=r?c.filterColumnActive?c.filterColumnActive(a):`Filter menu for ${a} (active)`:c.filterColumn?c.filterColumn(a):`Filter menu for ${a}`,d=o.createElement("button");o.setAttribute(d,"type","button"),o.setAttribute(d,"tabindex","-1"),o.setAttribute(d,"data-ge-action","filter-column"),o.setAttribute(d,"data-area","header"),o.setAttribute(d,"data-row-index",`${t}`),o.setAttribute(d,"data-col-index",`${s}`),o.setAttribute(d,"aria-haspopup","dialog"),o.setAttribute(d,"aria-expanded",l?"true":"false"),o.setAttribute(d,"aria-label",h),o.addClass(d,"ge-table-column-filter-btn"),r&&o.addClass(d,"ge-table-column-filter-active"),o.appendChild(d,Vu(i)),o.appendChild(e,d)}toggle(e){const t=this.scope.columnFilterService.resolveColumn(e);return t?this.popup.isOpen()&&this.openProperty===t.property?(this.close("api"),!0):this.open(e):!1}open(e){if(!this.isActive())return!1;const t=this.scope.columnFilterService,s=t.resolveColumn(e);if(!s||s.columnIndex<0)return!1;const o=s.columnIndex;if(this.scope.tableModel.getColumnWidth(o)<=0||!t.isColumnFilterable(o))return!1;this.scope.ensureColumnIsVisible(o);const i=this.findHeaderAnchor(o),r=(i==null?void 0:i.getBoundingClientRect())??this.fallbackAnchorRect(o),l=this.scope.getColumnAriaLabel(o),a=this.scope.ariaTexts,c=a.filterMenuDialog?a.filterMenuDialog(l):`Filter ${l}`,h=this.openColumnIndex;this.popup.isOpen()&&this.popup.close("api"),h>=0&&this.setHeaderButtonExpanded(h,!1),this.openProperty=s.property,this.openColumnIndex=o,this.setHeaderButtonExpanded(o,!0);const d=this.popup.open({ariaLabel:c,className:"ge-table-column-filter-menu",anchorRect:r,triggerEl:i,isTrigger:f=>f.classList.contains("ge-table-column-filter-btn")&&f.getAttribute("data-col-index")===`${o}`&&this.scope.hostElement.contains(f),onClose:f=>this.handleClosed(o,f)}),u=this.renderMenuContent(d,o,s.property,s.columnDef,l);return this.popup.reposition(r),this.popup.focusInitial(u),!0}close(e="api"){this.clearSearchTimer(),this.loadGeneration++,this.popup.close(e)}destroy(){this.destroyed||(this.destroyed=!0,this.clearSearchTimer(),this.loadGeneration++,this.popup.destroy(),this.openProperty=void 0,this.openColumnIndex=-1)}handleClosed(e,t){this.clearSearchTimer(),this.loadGeneration++,this.openProperty=void 0,this.openColumnIndex=-1,this.setHeaderButtonExpanded(e,!1),!this.destroyed&&(t==="escape"||t==="action"||t==="cancel")&&this.scope.focusHeaderFromFilterRow(e)}findHeaderAnchor(e){var r;const t=this.scope.hostElement,s=t.querySelector(`.ge-table-header button.ge-table-column-filter-btn[data-col-index="${e}"]`);if(s)return s;const o=((r=this.scope.tableModel.getAreaModel("header"))==null?void 0:r.getRowCount())??1,i=Math.max(0,o-1);return t.querySelector(`.ge-table-header .ge-table-col-div[data-row-index="${i}"][data-col-index="${e}"]`)??t.querySelector(`.ge-table-header .ge-table-col-div[data-col-index="${e}"]`)}fallbackAnchorRect(e){const t=this.scope.hostElement.getBoundingClientRect(),s=Math.max(40,this.scope.tableModel.getColumnWidth(e)),o=this.scope.isRtl()?t.right-s:t.left,i=t.top,r=this.scope.tableModel.getRowHeight("header",0)||34;return{left:o,right:o+s,top:i,bottom:i+r,width:s,height:r}}setHeaderButtonExpanded(e,t){const s=this.scope.hostElement.querySelector(`.ge-table-header button.ge-table-column-filter-btn[data-col-index="${e}"]`);s&&this.scope.getDomService().domService.setAttribute(s,"aria-expanded",t?"true":"false")}renderMenuContent(e,t,s,o,i){var Yr,qr,Jr,Zr;const r=this.scope.getDomService().domService,l=this.scope.columnFilterService,a=l.getTexts(),c=l.getOptions(),h=Pu(o),d=l.getColumnFilterType(t,s,o),u=l.getColumnFilter(s),f=this.options.maxValues??c.maxValues,p=`${this.scope.ariaIds.prefix}-fm-${t}`;let g=null;const m=r.createElement("div");r.addClass(m,"ge-table-filter-menu-header");const b=r.createElement("span");r.addClass(b,"ge-table-filter-menu-title"),b.textContent=i,r.appendChild(m,b),r.appendChild(e,m);const w=ol[d]??ol.text,y=this.options.showCondition&&w.length>0;let C,S,x,R;const I=()=>{if(!y||!C)return u==null?void 0:u.condition;const _=C.value;if(_==="blank"||_==="notBlank")return{operator:_};const V=(S==null?void 0:S.value)??"";if(_==="between"){const k=(x==null?void 0:x.value)??"",W=Ai(V,d,c.locale),B=Ai(k,d,c.locale);return W===void 0&&B===void 0?void 0:B===void 0?{operator:"greaterOrEqual",value:W}:W===void 0?{operator:"lessOrEqual",value:B}:{operator:"between",value:W,valueTo:B}}const z=Ai(V,d,c.locale);if(z!==void 0)return{operator:_,value:z}},A=()=>{if(!C)return;const _=C.value,V=_==="blank"||_==="notBlank",z=_==="between";S&&(S.hidden=V),R&&(R.hidden=!z),x&&(x.hidden=!z)};let T=()=>{};if(y){const _=r.createElement("div");r.addClass(_,"ge-table-filter-menu-condition");const V=r.createElement("select");r.addClass(V,"ge-table-filter-menu-select"),r.setAttribute(V,"aria-label",i);for(let k=0;k<w.length;k++){const W=w[k],B=r.createElement("option");B.value=W,B.textContent=a.operators[W]??W,r.appendChild(V,B)}V.value=(Yr=u==null?void 0:u.condition)!=null&&Yr.operator&&w.includes(u.condition.operator)?u.condition.operator:w[0],r.appendChild(_,V),C=V;const z=r.createElement("div");if(r.addClass(z,"ge-table-filter-menu-inputs"),d==="boolean"){const k=r.createElement("select");r.addClass(k,"ge-table-filter-menu-input"),r.setAttribute(k,"aria-label",i);for(const[W,B]of[["",""],["true","true"],["false","false"]]){const be=r.createElement("option");be.value=W,be.textContent=B,r.appendChild(k,be)}k.value=Ri((qr=u==null?void 0:u.condition)==null?void 0:qr.value,d),r.appendChild(z,k),S=k,k.addEventListener("change",()=>{this.options.applyOnChange&&T()})}else{const k=r.createElement("input");r.setAttribute(k,"type","text"),r.setAttribute(k,"autocomplete","off"),r.setAttribute(k,"autocorrect","off"),r.setAttribute(k,"autocapitalize","none"),r.setAttribute(k,"spellcheck","false"),r.setAttribute(k,"aria-label",i),r.setAttribute(k,"placeholder",d==="date"?"YYYY-MM-DD":a.searchPlaceholder),r.addClass(k,"ge-table-filter-menu-input"),k.value=Ri((Jr=u==null?void 0:u.condition)==null?void 0:Jr.value,d,c.locale),r.appendChild(z,k),S=k;const W=r.createElement("span");r.addClass(W,"ge-table-filter-menu-and"),W.textContent=a.andLabel,W.hidden=!0,r.appendChild(z,W),R=W;const B=r.createElement("input");r.setAttribute(B,"type","text"),r.setAttribute(B,"autocomplete","off"),r.setAttribute(B,"autocorrect","off"),r.setAttribute(B,"autocapitalize","none"),r.setAttribute(B,"spellcheck","false"),r.setAttribute(B,"aria-label",`${i} (${a.andLabel})`),r.setAttribute(B,"placeholder",d==="date"?"YYYY-MM-DD":a.searchPlaceholder),r.addClass(B,"ge-table-filter-menu-input"),B.value=Ri((Zr=u==null?void 0:u.condition)==null?void 0:Zr.valueTo,d,c.locale),B.hidden=!0,r.appendChild(z,B),x=B;const be=se=>{se.key==="Enter"&&!se.isComposing&&se.keyCode!==229&&(se.preventDefault(),T(),this.close("action"))};k.addEventListener("keydown",be),B.addEventListener("keydown",be),this.options.applyOnChange&&(k.addEventListener("input",()=>T()),B.addEventListener("input",()=>T()))}V.addEventListener("change",()=>{A(),this.popup.reposition(),this.options.applyOnChange&&T()}),A(),r.appendChild(_,z),r.appendChild(e,_),g||(g=S&&!S.hidden?S:V)}const F=this.options.showValues;let P=[],O=[],N=!1,K=(u==null?void 0:u.values)===void 0;const Y=new Set,U=new Map;let $=()=>"";const me=d==="date"?_=>{const V=Ro(_);return typeof V=="number"?`d:${V}`:Ki(_)}:Ki;if((u==null?void 0:u.values)!==void 0)for(let _=0;_<u.values.length;_++){const V=u.values[_],z=me(V);Y.add(z),U.set(z,V)}const te=_=>{const V=new Array(_.length);for(let z=0;z<_.length;z++){const k=_[z],W=me(k.value),B=k.label??(Q(k.value)?a.blanks:String(k.value));U.set(W,k.value),K&&Y.add(W),V[z]={key:W,value:k.value,label:B,count:k.count}}return V};if(F){const _=r.createElement("div");r.addClass(_,"ge-table-filter-menu-values");const V=r.createElement("input");r.setAttribute(V,"type","search"),r.setAttribute(V,"autocomplete","off"),r.setAttribute(V,"autocorrect","off"),r.setAttribute(V,"autocapitalize","none"),r.setAttribute(V,"spellcheck","false"),r.setAttribute(V,"placeholder",a.searchValuesPlaceholder),r.setAttribute(V,"aria-label",a.searchValuesPlaceholder),r.addClass(V,"ge-table-filter-menu-search"),r.appendChild(_,V);const z=r.createElement("div");r.addClass(z,"ge-table-filter-select-all");const k=r.createElement("input"),W=`${p}-all`;r.setAttribute(k,"type","checkbox"),r.setAttribute(k,"id",W);const B=r.createElement("label");r.setAttribute(B,"for",W),B.textContent=a.selectAll,r.appendChild(z,k),r.appendChild(z,B),r.appendChild(_,z);const be=r.createElement("div");r.addClass(be,"ge-table-filter-values-notice"),be.hidden=!0,r.appendChild(_,be);const se=r.createElement("div");r.addClass(se,"ge-table-filter-values-viewport"),r.setAttribute(se,"role","group"),r.setAttribute(se,"aria-label",i),r.setAttribute(se,"tabindex","-1"),$=()=>V.value.trim();const Ce=r.createElement("div");r.addClass(Ce,"ge-table-filter-values-spacer"),r.appendChild(se,Ce);const Xe=r.createElement("div");r.addClass(Xe,"ge-table-filter-values-empty"),Xe.textContent=a.noValues,Xe.hidden=!0,r.appendChild(se,Xe),r.appendChild(_,se),r.appendChild(e,_);const ri=()=>{if(O.length===0){k.checked=!1,k.indeterminate=!1;return}let re=0;for(let ce=0;ce<O.length;ce++)Y.has(O[ce].key)&&re++;re===0?(k.checked=!1,k.indeterminate=!1):re===O.length?(k.checked=!0,k.indeterminate=!1):(k.checked=!1,k.indeterminate=!0)},ni=()=>{var tn;const re=O.length;if(Ce.style.height=`${re*Cs}px`,Xe.hidden=re>0,Ce.hidden=re===0,re===0){Ce.textContent="";return}const ce=se.clientHeight||210,yt=se.scrollTop,to=Math.max(0,Math.floor(yt/Cs)-sl),Lt=Math.min(re-1,Math.ceil((yt+ce)/Cs)+sl),Ne=(tn=Ce.getRootNode)==null?void 0:tn.call(Ce),Ve=Ne&&"activeElement"in Ne?Ne.activeElement:null,Ot=Ve&&Ce.contains(Ve)?Ve.id:void 0;let Qr;Ce.textContent="";const en=e.ownerDocument.createDocumentFragment();for(let ms=to;ms<=Lt;ms++){const Nt=O[ms],Ct=r.createElement("div");r.addClass(Ct,"ge-table-filter-value-row"),Ct.style.top=`${ms*Cs}px`,Ct.style.height=`${Cs}px`;const vt=r.createElement("input"),ai=`${p}-v-${ms}`;r.setAttribute(vt,"type","checkbox"),r.setAttribute(vt,"id",ai),vt.checked=Y.has(Nt.key),Ot!==void 0&&ai===Ot&&(Qr=vt),vt.addEventListener("change",()=>{K=!1,vt.checked?Y.add(Nt.key):Y.delete(Nt.key),ri(),this.options.applyOnChange&&T()});const so=r.createElement("label");if(r.setAttribute(so,"for",ai),r.addClass(so,"ge-table-filter-value-label"),so.textContent=Nt.label,r.appendChild(Ct,vt),r.appendChild(Ct,so),Nt.count!==void 0){const ci=r.createElement("span");r.addClass(ci,"ge-table-filter-value-count"),ci.textContent=`${Nt.count}`,r.appendChild(Ct,ci)}en.appendChild(Ct)}Ce.appendChild(en),Ot!==void 0&&(Qr??se).focus({preventScroll:!0})};se.addEventListener("scroll",()=>ni(),{passive:!0}),k.addEventListener("change",()=>{K=!1;const re=k.checked;for(let ce=0;ce<O.length;ce++)re?Y.add(O[ce].key):Y.delete(O[ce].key);ri(),ni(),this.options.applyOnChange&&T()});const gs=(re,ce,yt)=>{yt&&(P=re,N=ce),O=re,be.hidden=!ce,ce&&(be.textContent=a.valuesTruncated(f)),se.scrollTop=0,ri(),ni()},li=(re,ce)=>{const yt=++this.loadGeneration;if(h!=null&&h.getValues){const Lt={columnIndex:t,columnDef:o,property:s,search:re,maxValues:f,otherFilters:l.getOtherFilters(s)},Ne=h.getValues(Lt);if(Ne&&typeof Ne.then=="function")Xe.textContent="…",Xe.hidden=!1,Ce.hidden=!0,Ne.then(Ve=>{if(this.destroyed||!this.popup.isOpen()||yt!==this.loadGeneration)return;Xe.textContent=a.noValues;const Ot=Array.isArray(Ve)?Ve:[];gs(te(Ot),Ot.length>=f,ce)}).catch(()=>{this.destroyed||!this.popup.isOpen()||yt!==this.loadGeneration||(Xe.textContent=a.noValues,gs([],!1,ce))});else{const Ve=Array.isArray(Ne)?Ne:[];gs(te(Ve),Ve.length>=f,ce)}return}if(!ce&&!N){const Lt=re.trim().toLowerCase(),Ne=Lt?P.filter(Ve=>Ve.label.toLowerCase().includes(Lt)):P;gs(Ne,!1,!1);return}const to=l.collectColumnDistinctValues(t,{maxValues:f,search:re||void 0});gs(te(to.items),to.truncated,ce)};V.addEventListener("input",()=>{this.clearSearchTimer();const re=V.value;!(h!=null&&h.getValues)&&!N?li(re,!1):this.searchTimer=setTimeout(()=>{this.searchTimer=void 0,li(re,!1)},120)}),li("",!0),g||(g=V)}const le=()=>{const _=I();let V=u==null?void 0:u.values;if(F){const k=$()&&!K?O.filter(W=>Y.has(W.key)):[];if(K)V=void 0;else if(k.length>0)V=k.map(W=>W.value);else if(N&&!(h!=null&&h.getValues)){const W=(u==null?void 0:u.values)===void 0,B=l.collectColumnDistinctValues(t,{maxValues:Number.POSITIVE_INFINITY}).items,be=[];for(let se=0;se<B.length;se++){const Ce=me(B[se].value);(Y.has(Ce)||W&&!U.has(Ce))&&be.push(B[se].value)}V=be.length===B.length?void 0:be}else if(!N&&P.length>0&&Y.size===P.length&&P.every(W=>Y.has(W.key)))V=void 0;else{const W=[];Y.forEach(B=>{W.push(U.get(B))}),V=W}}if(!_&&V===void 0)return;const z={};return _&&(z.condition=_),V!==void 0&&(z.values=V),z};T=()=>{l.setColumnFilter(s,le(),"menu")};const Te=r.createElement("div");r.addClass(Te,"ge-table-filter-menu-footer");const H=r.createElement("button");r.setAttribute(H,"type","button"),r.addClass(H,"ge-table-filter-btn"),r.addClass(H,"ge-table-filter-btn-clear"),H.textContent=a.clear,H.addEventListener("click",()=>{l.setColumnFilter(s,void 0,"menu"),this.close("action")});const ae=r.createElement("div");r.addClass(ae,"ge-table-filter-menu-footer-actions");const je=r.createElement("button");r.setAttribute(je,"type","button"),r.addClass(je,"ge-table-filter-btn"),r.addClass(je,"ge-table-filter-btn-cancel"),je.textContent=a.cancel,je.addEventListener("click",()=>{this.close("cancel")});const wt=r.createElement("button");return r.setAttribute(wt,"type","button"),r.addClass(wt,"ge-table-filter-btn"),r.addClass(wt,"ge-table-filter-btn-primary"),r.addClass(wt,"ge-table-filter-btn-ok"),wt.textContent=a.ok,wt.addEventListener("click",()=>{this.options.applyOnChange||T(),this.close("action")}),r.appendChild(Te,H),r.appendChild(ae,je),r.appendChild(ae,wt),r.appendChild(Te,ae),r.appendChild(e,Te),g}clearSearchTimer(){this.searchTimer!==void 0&&(clearTimeout(this.searchTimer),this.searchTimer=void 0)}}const Bu=8;class vc{constructor(e){this.scope=e,this.destroyed=!1,this.popup=new Br(e)}isOpen(){return this.popup.isOpen()}isInPopup(e){return this.popup.isInPopup(e)}open(e){if(this.destroyed)return;if(this.popup.isOpen()&&e&&this.lastAnchor===e){this.close("api");return}this.lastAnchor=e;const t=e?e.getBoundingClientRect():this.defaultAnchorRect(),s=this.scope.ariaTexts,o=s.columnChooserDialog?s.columnChooserDialog():"Choose columns",i=this.popup.open({ariaLabel:o,className:"ge-table-column-chooser",anchorRect:t,triggerEl:e,onClose:l=>this.handleClosed(e,l)}),r=this.renderContent(i);this.popup.reposition(t),this.popup.focusInitial(r)}close(e="api"){this.popup.close(e)}destroy(){this.destroyed||(this.destroyed=!0,this.lastAnchor=void 0,this.popup.destroy())}handleClosed(e,t){this.lastAnchor=void 0,!this.destroyed&&(t==="escape"||t==="action"||t==="cancel")&&(e&&e.isConnected?e.focus({preventScroll:!0}):this.scope.hostElement.focus({preventScroll:!0}))}defaultAnchorRect(){const e=this.scope.hostElement.getBoundingClientRect(),t=this.scope.tableModel.getPadding().top||34;return this.scope.isRtl()?{left:e.left,right:e.left+1,top:e.top,bottom:e.top+t,width:1,height:t}:{left:e.right-1,right:e.right,top:e.top,bottom:e.top+t,width:1,height:t}}collectColumns(){const e=this.scope.tableModel,t=e.getColumnCount(),s=[];for(let o=0;o<t;o++){const i=e.getColumnDef(o);!i||G(i)||Ae(i)||s.push({columnIndex:o,columnDef:i,label:this.scope.getColumnAriaLabel(o),property:i.property||`#${o}`,hideable:i.hideable!==!1})}return s}renderContent(e){const t=this.scope.getDomService().domService,s=this.scope.columnFilterService.getTexts(),o=this.collectColumns(),i=`${this.scope.ariaIds.prefix}-cc`;let r=null;const l=t.createElement("div");t.addClass(l,"ge-table-filter-menu-header");const a=t.createElement("span");t.addClass(a,"ge-table-filter-menu-title"),a.textContent=s.columnsTitle,t.appendChild(l,a),t.appendChild(e,l);const c=t.createElement("div");t.addClass(c,"ge-table-filter-menu-values");let h="",d;o.length>=Bu&&(d=t.createElement("input"),t.setAttribute(d,"type","search"),t.setAttribute(d,"autocomplete","off"),t.setAttribute(d,"autocorrect","off"),t.setAttribute(d,"autocapitalize","none"),t.setAttribute(d,"spellcheck","false"),t.setAttribute(d,"placeholder",s.searchColumnsPlaceholder),t.setAttribute(d,"aria-label",s.searchColumnsPlaceholder),t.addClass(d,"ge-table-filter-menu-search"),t.appendChild(c,d),r=d);const u=t.createElement("div");t.addClass(u,"ge-table-filter-select-all");const f=t.createElement("input"),p=`${i}-all`;t.setAttribute(f,"type","checkbox"),t.setAttribute(f,"id",p);const g=t.createElement("label");t.setAttribute(g,"for",p),g.textContent=s.selectAll,t.appendChild(u,f),t.appendChild(u,g),t.appendChild(c,u);const m=t.createElement("div");t.addClass(m,"ge-table-column-chooser-list"),t.setAttribute(m,"role","group"),t.setAttribute(m,"aria-label",s.columnsTitle),t.appendChild(c,m),t.appendChild(e,c);const b=()=>{const C=h.trim().toLowerCase();return C?o.filter(S=>S.label.toLowerCase().includes(C)||S.property.toLowerCase().includes(C)):o},w=()=>{let C=0;for(let S=0;S<o.length;S++)at(o[S].columnDef)&&C++;return C},y=()=>{const C=b(),S=w();let x=0;for(let I=0;I<C.length;I++)at(C[I].columnDef)&&x++;if(C.length===0||x===0?(f.checked=!1,f.indeterminate=!1):x===C.length?(f.checked=!0,f.indeterminate=!1):(f.checked=!1,f.indeterminate=!0),m.textContent="",C.length===0){const I=t.createElement("div");t.addClass(I,"ge-table-filter-values-empty"),I.textContent=s.noValues,t.appendChild(m,I);return}const R=e.ownerDocument.createDocumentFragment();for(let I=0;I<C.length;I++){const A=C[I],T=at(A.columnDef),F=T&&S<=1,P=!A.hideable||F,O=t.createElement("div");t.addClass(O,"ge-table-column-chooser-row");const N=t.createElement("input"),K=`${i}-c-${I}`;t.setAttribute(N,"type","checkbox"),t.setAttribute(N,"id",K),t.setAttribute(N,"data-col-property",A.property),N.checked=T,N.disabled=P,N.addEventListener("change",()=>{if(!N.checked&&w()<=1){N.checked=!0;return}this.scope.setColumnVisible(A.columnDef,N.checked),y()});const Y=t.createElement("label");t.setAttribute(Y,"for",K),t.addClass(Y,"ge-table-filter-value-label"),Y.textContent=A.label,t.appendChild(O,N),t.appendChild(O,Y),R.appendChild(O),!r&&!N.disabled&&(r=N)}m.appendChild(R)};return f.addEventListener("change",()=>{const C=b();if(f.checked)for(let x=0;x<C.length;x++)at(C[x].columnDef)||this.scope.setColumnVisible(C[x].columnDef,!0);else for(let x=C.length-1;x>=0;x--){const R=C[x];if(!(!R.hideable||!at(R.columnDef))){if(w()<=1)break;this.scope.setColumnVisible(R.columnDef,!1)}}y()}),d&&d.addEventListener("input",()=>{h=d.value,y()}),y(),r??f}}function Sc(n){return n?{"meta+shift+f":"FOCUS_COLUMN_FILTER","alt+arrowdown":"OPEN_COLUMN_FILTER_MENU"}:{"ctrl+shift+f":"FOCUS_COLUMN_FILTER","alt+arrowdown":"OPEN_COLUMN_FILTER_MENU"}}const Ie=class Ie extends ql{constructor(e,t,s,o,i,r=new He,l=new ha){var u;if(super(e,t,new go(s),o),this.eventListener=i,this.copyService=r,this.excelService=l,this.licenseManager=Et.getInstance(),this.listenerAbortController=new AbortController,this.destroyed=!1,this.selectionService=new De(this),this.api=new _l(this),this.initialized=!1,this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.lastDragFrom=-1,this.lastDragTo=-1,this.firstDraggingRendering=!0,this.editingOptions=Jo.create(At(this.tableOptions,"editing")),this.subscribers=new Set,this.clipboardOptions=Gs.create(At(this.tableOptions,"clipboard")),this.undoOptions=ti.create(At(this.tableOptions,"undo")),this.lastTabKeyTime=0,this.syncingTileFocus=!1,this.tileFocusKnown=!1,this.focusFrameDirty=!1,this.lastContextmenu=Date.now(),this.allExpanded=!0,this.selectionEventsHeld=0,t.setTableScope(this),this.liveAnnouncer=new So(e.ownerDocument,this.ariaIds.liveRegion(),s),this.eventListener=yu(i??new Fs,this.subscribers),this.stateService=new vo(this),this.columnFilterService=new bc(this),o!=null&&o.filterRow&&this.initFilterRowService(o.filterRow),o!=null&&o.columnFilterMenu){const f=Us.create(o.columnFilterMenu,this.columnFilterService.getOptions().maxValues);f&&(this.columnFilterMenuService=new qi(this,f,!0))}if(this.mouseHandler=new gl(this),this.inputHandler=new ta(this),this.resizeHandler=new ca(this,o.resizeEventDebounceDelay),this.shortcutService=new na(this),this.rowDragService=new ua(this),this.batchEditService=new ma(this),this.fillHandleService=new Ma(this),this.editingOptions){this.cellEditorService=new Pa(this,this.editingOptions);const f=t.getBodyModel();this.editingOptions.defaultEditable&&"defaultEditable"in f&&(f.defaultEditable=!0),this.setHostAriaAttribute("aria-description",this.getSheetTexts().gridEditingHint())}this.clipboardOptions&&(this.clipboardService=new Wi(this,this.clipboardOptions,!0)),this.undoOptions&&(this.undoService=new ic(this,this.undoOptions));const a=cs.create(At(o,"cellFormulas"));if(a&&(o.masterDetail?console.warn("GuiExpert Table – cellFormulas: no cell formulas with master/detail."):this.tableSheet=ei.create(t,a)),o!=null&&o.masterDetail&&(this.masterDetailService=new Ta(this,(f,p,g,m)=>new Ie(f,p,new Vi,this.nestedTableOptions(g),m??new Fs)),this.masterDetailService.isActive())){const f=(e.getAttribute("aria-owns")??"").split(" ").filter(Boolean),p=f.findIndex(g=>g.startsWith(this.ariaIds.rowGroup("footer","west")));f.splice(p<0?f.length:p,0,this.ariaIds.detailRowGroup()),this.setHostAriaAttribute("aria-owns",f.join(" ")),this.setHostAriaAttribute("role","treegrid")}this.shortcutService.addListener(this.selectionService);const c=this.getSelectionModel?this.getSelectionModel():void 0;c&&c.addEventSelectionChangedListener(this);const h=this.getFocusModel?this.getFocusModel():void 0;h&&h.addEventFocusChangedListener(this);const d=this.listenerAbortController.signal;(u=e.ownerDocument)==null||u.addEventListener("keydown",f=>{f.key==="Tab"&&(this.lastTabKeyTime=Date.now())},{capture:!0,signal:d}),e.addEventListener("focus",()=>this.onHostKeyboardFocus(),{signal:d}),e.addEventListener("keydown",f=>{!["Shift","Control","Alt","Meta"].includes(f.key)&&!Ie.isControlEvent(f)&&this.setKeyboardModality(!0)},{capture:!0,signal:d}),e.addEventListener("mousedown",f=>{Ie.isControlEvent(f)||this.setKeyboardModality(!1)},{capture:!0,signal:d}),this.scrollViewport.addEventListener("focus",()=>this.hostElement.focus({preventScroll:!0}),{signal:d})}nestedTableOptions(e){return e?e.direction!==void 0||!this.isRtl()?e:Object.assign(Object.create(e),{direction:this.direction}):{...new gt,direction:this.direction}}onHostKeyboardFocus(){const e=Date.now()-this.lastTabKeyTime<1e3;e&&this.setKeyboardModality(!0);const t=this.focusModel();if(!e||!t||this.headerFocus||this.isEditing())return;const[s,o]=t.getFocus(),i=this.tableModel.getBodyModel().getRowCount();if((s<0||o<0)&&i>0&&this.tableModel.getColumnCount()>0){const r=this.firstFullVisibleRowIndex>=0?this.firstFullVisibleRowIndex:Math.max(0,this.getBodyRowIndexAtY(this.contentScrollTop));this.setFocusCell(r,this.getFirstShownColumnIndex())}else i<1&&this.getAriaGridInfo().headerRowCount>0&&this.tableModel.getColumnCount()>0&&this.setHeaderFocus(this.getAriaGridInfo().headerRowCount-1,this.getFirstShownColumnIndex())}static create(e,t,s=new gt,o=new Fs,i=new Vi,r=new He){return new Ie(e,t,i,s,o,r)}onActionTriggered(e){var i,r,l,a,c;if(!this.headerFocus&&this.tableOverlay.isBlocking()&&Ie.actionsBlockedWhileLoading.includes(e))return!0;if(e==="FOCUS_COLUMN_FILTER"){const h=this.headerFocus?this.headerFocus[1]:(r=(i=this.focusModel())==null?void 0:i.getFocus())==null?void 0:r[1];return!!((l=this.filterRowService)!=null&&l.focusActiveOrFirstColumn(h!==void 0&&h>=0?h:void 0))}if(e==="OPEN_COLUMN_FILTER_MENU")return this.headerFocus&&((a=this.columnFilterMenuService)!=null&&a.isActive())?this.columnFilterMenuService.open(this.headerFocus[1]):!1;if(this.headerFocus){const h=this.onHeaderAction(e);if(h!==void 0)return h}if(e==="FILL_DOWN"||e==="FILL_RIGHT")return!this.headerFocus&&this.fillByKeyboard(e==="FILL_DOWN"?"down":"right");const t=this.onSheetAction(e);if(t!==void 0)return t;if(e==="MOVE_ROW_UP"||e==="MOVE_ROW_DOWN")return!this.headerFocus&&!!((c=this.rowDragService)!=null&&c.moveByKeyboard(e==="MOVE_ROW_UP"?-1:1));if(e==="NAVIGATE_UP"&&this.moveFocusIntoHeader())return!0;const s=this.onTileNavigation(e);if(s!==void 0)return s;const o=this.onBodyNavigation(e);if(o!==void 0)return o;if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const h=this.getFocusModel();if(h){const[d,u]=h.getFocus();this.tableModel.getBodyModel().isEditable(d,u)&&this.startEditing(d,u,"edit","end")}return!0}if(this.undoService&&(e==="UNDO"||e==="REDO"))return e==="UNDO"?this.undoService.undo():this.undoService.redo(),!0;if(this.clipboardService&&this.clipboardOptions&&(e==="COPY_2_CLIPBOARD"||e==="CUT_2_CLIPBOARD"||e==="PASTE_FROM_CLIPBOARD")){const h=e==="COPY_2_CLIPBOARD"?"copy":e==="CUT_2_CLIPBOARD"?"cut":"paste";if(this.shortcutKeyEvent){if(this.clipboardService.arm(h)||h!=="copy")return!1}else if(h!=="copy"||Object.getPrototypeOf(this.copyService)===He.prototype)return this.clipboardService.runWithoutKey(h),!0}if(e==="COPY_2_CLIPBOARD"){const h=this.getSelectionModel?this.getSelectionModel():void 0,d=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,h,d).then(u=>u||!this.getTileLayout()?this.copyService.copyContent(u).then(()=>this.announceCopied(u)):void 0).catch(u=>console.warn("GuiExpert Table – copy to clipboard failed:",u))}return!1}getEditingOptions(){return this.editingOptions}getShortcutLayers(e){const t=[];(this.tableOptions.filterRow||this.filterRowService||this.tableOptions.columnFilterMenu||this.columnFilterMenuService)&&t.push(Sc(e));const s=this.editingOptions;if(this.clipboardOptions&&t.push(_a(e)),this.undoOptions&&t.push(Qa(e)),!s)return t;const o=Ba(e);return s.tabMoves||(delete o.tab,delete o["shift+tab"]),s.clearKeys||(delete o.delete,delete o.backspace),[o,...t]}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}startEditing(e,t,s="edit",o){var r,l,a;if((r=this.cellEditorService)!=null&&r.handlesColumn(t))return this.cellEditorService.start(e,t,{mode:s,textSelection:o});if(!this.tableModel.getBodyModel().isEditable(e,t))return!1;this.clearSelection(),this.initRenderEditor(e,t);const i=this.getInCellEditorCell();return i&&((a=(l=this.eventListener).onEditingChanged)==null||a.call(l,new qt("start",e,t,s))),!!i}canStartEditing(){var e,t;return!this.isDestroyed()&&!this.headerFocus&&!this.tableOverlay.isBlocking()&&!((e=this.rowDragService)!=null&&e.isDragging())&&!((t=this.fillHandleService)!=null&&t.isFilling())&&!this.editing}getShownCellValue(e,t){return this.batchEditService?this.batchEditService.getShownValue(e,t):this.getCellInput(e,t)}getActiveBodyCell(){const e=this.focusModel();if(!e||this.headerFocus)return;const[t,s]=e.getFocus(),o=this.tableModel.getBodyModel().getRowCount();return t>=0&&s>=0&&t<o&&s<this.tableModel.getColumnCount()?[t,s]:void 0}refreshAfterStructureChange(e){var r,l;const t=this.getEffectiveFilterFunction();if(t&&this.tableModel.externalFilterChanged(t),this.reapplySorting(),(r=this.batchEditService)==null||r.pruneOrphans(),e){for(const a of["header","body","footer"])(l=this.colAndRowspanModels[a])==null||l.init();this.firstInit(),this.stateService.markDirty("columns")}this.invalidateAggregates();const s=this.focusModel(),o=this.tableModel.getBodyModel().getRowCount(),i=this.tableModel.getColumnCount();if(s&&o>0&&i>0){const[a,c]=s.getFocus();if(a>=o||c>=i){const h=Math.min(Math.max(0,a),o-1),d=Math.min(Math.max(this.getFirstDataColumnIndex(),c),i-1);s.setFocus(h,d),this.selectionService.collapseTo(h,d)}}this.repaintHard()}nextShownColumn(e,t){return this.getNextShownColumnIndex(e,t,this.tableModel.getColumnCount())}hasShownColumnBeside(e,t){const s=this.getNextShownColumnIndex(e,t,this.tableModel.getColumnCount());return s!==e&&!G(this.tableModel.getColumnDef(s))}moveActiveCell(e,t,s,o){const i=this.focusModel();return i?(i.hasFocus(e,t)||i.setFocus(e,t),this.changeFocusCell(o,s)):!1}getSelectedBodyCells(e){return this.collectSelectedBodyCells(e)}collectSelectedBodyCells(e,t){const s=this.selectionModel();if(!t&&!(s!=null&&s.hasSelection())&&!(s!=null&&s.isAllSelected()))return[];const o=this.tableModel.getBodyModel().getRowCount(),i=this.tableModel.getColumnCount(),r=t??(s.isAllSelected()?[new M(0,0,o-1,i-1)]:s.getRanges()),l=h=>this.tableModel.getColumnWidth(h)>0&&!G(this.tableModel.getColumnDef(h)),a=[],c=r.length>1?new Set:void 0;for(const h of r){const d=Math.max(0,h.r1),u=Math.min(o-1,h.r2),f=Math.max(0,h.c1),p=Math.min(i-1,h.c2);if(u>=d&&p>=f&&(u-d+1)*(p-f+1)>e)return;for(let g=d;g<=u;g++)for(let m=f;m<=p;m++)if(!(!l(m)||!t&&!s.isSelected(g,m))){if(c){const b=g*i+m;if(c.has(b))continue;c.add(b)}if(a.push([g,m]),a.length>e)return}}return a}clearCells(e){var a,c;const t=((a=this.editingOptions)==null?void 0:a.maxClearCells)??He.maxCopyCells,s=this.collectSelectedBodyCells(t,e);if(!s)return this.announce(this.getSheetTexts().clearTooLarge(t)),-1;if(!s.length&&!e){const h=this.getActiveBodyCell();h&&s.push(h)}const o=this.tableModel.getBodyModel(),i=h=>h==null||h==="",r=[];for(const[h,d]of s){if(h<0||d<0||h>=o.getRowCount()||d>=this.tableModel.getColumnCount()||!o.isEditable(h,d)||i(this.getShownCellValue(h,d)))continue;const u=this.tableModel.getColumnDef(d),f=(u==null?void 0:u.emptyValue)!==void 0?u.emptyValue:((c=this.editingOptions)==null?void 0:c.emptyValue)??"";r.push({rowIndex:h,column:d,value:f})}const l=r.length?this.applyCellChanges(r,"clear"):[];return this.announce(this.getSheetTexts().cellsCleared(l.length)),l.length}commitCellEditor(e,t,s){var l;const o=e.map(([a,c])=>({rowIndex:a,column:c,value:t})),i=this.resolveCellChanges(o,e.length>1);if(!i.length)return{written:0,invalid:0};if((l=this.batchEditService)!=null&&l.isActive())return this.markPending(i.map(a=>({rowIndex:a.rowIndex,column:a.columnIndex,value:a.value})),!0),s?this.debounceRepaint():this.repaint(),{written:i.length,invalid:0};const r=this.writeCellsInternal(i,"edit",{deferRepaint:s});return{written:r.changes.length,invalid:r.invalid,message:r.message}}toggleBooleanCell(e,t){this.applyCellChanges([{rowIndex:e,column:t,value:!this.getShownCellValue(e,t)}],"edit")}getSheetTexts(){const e=this.ariaTexts??{},t=new Le;return{editingStarted:s=>(e.editingStarted??t.editingStarted).call(e,s),readOnlyCell:()=>(e.readOnlyCell??t.readOnlyCell).call(e),cellsCleared:s=>(e.cellsCleared??t.cellsCleared).call(e,s),clearTooLarge:s=>(e.clearTooLarge??t.clearTooLarge).call(e,s),rangeSelected:(s,o)=>(e.rangeSelected??t.rangeSelected).call(e,s,o),rowSelected:s=>(e.rowSelected??t.rowSelected).call(e,s),columnSelected:s=>(e.columnSelected??t.columnSelected).call(e,s),gridEditingHint:()=>(e.gridEditingHint??t.gridEditingHint).call(e),cellsPasted:(s,o)=>(e.cellsPasted??t.cellsPasted).call(e,s,o),pasteTooLarge:s=>(e.pasteTooLarge??t.pasteTooLarge).call(e,s),copyTooLarge:s=>(e.copyTooLarge??t.copyTooLarge).call(e,s),cutMarked:s=>(e.cutMarked??t.cutMarked).call(e,s),copiedLastRangeOnly:()=>(e.copiedLastRangeOnly??t.copiedLastRangeOnly).call(e)}}onSheetAction(e){var s,o;const t=this.editingOptions;if(t)switch(e){case"NAVIGATE_NEXT_CELL":case"NAVIGATE_PREVIOUS_CELL":{const i=this.getActiveBodyCell(),r=e==="NAVIGATE_NEXT_CELL"?1:-1;return!i||this.isEditing()||!this.hasShownColumnBeside(i[1],r)||r>0&&((s=this.masterDetailService)!=null&&s.hasTabTarget(i[0]))?!1:this.moveActiveCell(i[0],i[1],0,r)}case"EXTEND_SELECTION_UP":case"EXTEND_SELECTION_DOWN":case"EXTEND_SELECTION_LEFT":case"EXTEND_SELECTION_RIGHT":case"EXTEND_SELECTION_ROW_START":case"EXTEND_SELECTION_ROW_END":case"EXTEND_SELECTION_PAGE_UP":case"EXTEND_SELECTION_PAGE_DOWN":{const i=this.getSelectionExtent();if(!i||this.isEditing())return!1;const[r,l]=i,a=this.tableModel.getBodyModel().getRowCount(),c=this.tableModel.getColumnCount(),h=Math.max(1,this.displayedRowCount-1),d={EXTEND_SELECTION_UP:[Math.max(0,r-1),l],EXTEND_SELECTION_DOWN:[Math.min(a-1,r+1),l],EXTEND_SELECTION_LEFT:[r,this.getNextShownColumnIndex(l,-1,c)],EXTEND_SELECTION_RIGHT:[r,this.getNextShownColumnIndex(l,1,c)],EXTEND_SELECTION_ROW_START:[r,this.getFirstShownDataColumnIndex()],EXTEND_SELECTION_ROW_END:[r,this.getLastShownColumnIndex()],EXTEND_SELECTION_PAGE_UP:[Math.max(0,r-h),l],EXTEND_SELECTION_PAGE_DOWN:[Math.min(a-1,r+h),l]},[u,f]=d[e];return this.extendSelectionTo(u,G(this.tableModel.getColumnDef(f))?l:f)}case"NAVIGATE_DATA_EDGE_UP":case"NAVIGATE_DATA_EDGE_DOWN":case"NAVIGATE_DATA_EDGE_LEFT":case"NAVIGATE_DATA_EDGE_RIGHT":{const i=this.getActiveBodyCell();if(!i||this.isEditing())return!1;const[r,l]=this.dataEdge(i,e);return this.setFocusCell(r,l)}case"EXTEND_TO_DATA_EDGE_UP":case"EXTEND_TO_DATA_EDGE_DOWN":case"EXTEND_TO_DATA_EDGE_LEFT":case"EXTEND_TO_DATA_EDGE_RIGHT":{const i=this.getSelectionExtent();if(!i||this.isEditing())return!1;const[r,l]=this.dataEdge(i,e);return this.extendSelectionTo(r,l)}case"SELECT_ROW":case"SELECT_COLUMN":return this.selectWholeRowsOrColumns(e==="SELECT_ROW");case"CLEAR_CELLS":return!t.clearKeys||this.isEditing()||this.headerFocus?!1:(this.clearCells(),!0);case"CLEAR_AND_EDIT":{if(!t.clearKeys||this.isEditing()||this.headerFocus)return!1;const i=this.getActiveBodyCell(),r=this.collectSelectedBodyCells(1);return i&&r&&((o=this.cellEditorService)!=null&&o.handlesColumn(i[1]))&&this.tableModel.getBodyModel().isEditable(i[0],i[1])?(this.cellEditorService.start(i[0],i[1],{mode:"enter",typedText:""}),!0):(this.clearCells(),!0)}default:return}}getSelectionExtent(){if(!this.headerFocus)return this.selectionService.getExtent()??this.getActiveBodyCell()}getFirstShownDataColumnIndex(){const e=this.getFirstShownColumnIndex();return G(this.tableModel.getColumnDef(e))?this.getNextShownColumnIndex(e,1,this.tableModel.getColumnCount()):e}dataEdge(e,t){const s=t.endsWith("_UP")?-1:t.endsWith("_DOWN")?1:0,o=t.endsWith("_LEFT")?-1:t.endsWith("_RIGHT")?1:0;return rc((r,l)=>{const a=this.getShownCellValue(r,l);return a==null||a===""},this.tableModel.getBodyModel().getRowCount(),this.tableModel.getColumnCount(),e[0],e[1],s,o,r=>this.tableModel.getColumnWidth(r)>0&&!G(this.tableModel.getColumnDef(r)))}extendSelectionTo(e,t){const s=this.selectionService.extendTo(e,t);if(!s)return!1;this.ensureColumnIsVisible(t),this.ensureRowIsVisible(e),this.repaint();let o=0;for(let i=s.c1;i<=s.c2;i++)this.tableModel.getColumnWidth(i)>0&&o++;return this.announce(this.getSheetTexts().rangeSelected(s.r2-s.r1+1,o)),!0}selectWholeRowsOrColumns(e){const t=this.selectionModel(),s=this.getActiveBodyCell();if(!t||!s||this.isEditing()||t.selectionType!=="range")return!1;const o=t.getRanges(),i=o.length?o[o.length-1]:M.singleCell(s[0],s[1]),r=e?new M(i.r1,0,i.r2,Number.MAX_SAFE_INTEGER):new M(0,i.c1,Number.MAX_SAFE_INTEGER,i.c2);this.holdSelectionEvents(()=>{t.clear(),t.addSelection(r),this.onSelectionChanged(t)}),this.repaint();const l=this.getSheetTexts();return this.announce(e?l.rowSelected(i.r2-i.r1+1):l.columnSelected(i.c2-i.c1+1)),!0}getEventListener(){return this.eventListener}afterRowsMoved(){this.lastSortCompareFn=void 0,this.invalidateAggregates()}announce(e,t){e&&!this.isDestroyed()&&this.liveAnnouncer.announce(e,t)}showLoadingOverlay(e){this.tableOverlay.showLoading(e)}showNoRowsOverlay(e){this.tableOverlay.showNoRows(e)}hideOverlay(){this.tableOverlay.hide()}getOverlayState(){return this.tableOverlay.getState()}onOverlayChanged(e){this.isDestroyed()||(e.kind==="loading"?(this.setHostAriaAttribute("aria-busy","true"),this.tableOverlay.isBlocking()&&(this.hideHoverRow(),this.hideHoverColumn())):e.previous==="loading"&&(this.restoreHostAriaAttribute("aria-busy"),this.liveAnnouncer.cancel(this.lastLoadingAnnouncement)),e.kind==="loading"&&(this.lastLoadingAnnouncement=e.text),(e.kind==="loading"||e.kind==="noRows"&&this.initialized)&&this.announce(e.text))}announceCopied(e){this.announce(this.ariaTexts.copied(this.countCopiedCells()))}countCopiedCells(){const e=this.selectionModel();if(!(e!=null&&e.hasSelection()))return 1;const t=this.tableModel.getBodyModel().getRowCount(),s=this.tableModel.getColumnCount(),o=u=>{var f,p;return((p=(f=this.tableModel.getColumnDef(u))==null?void 0:f.isVisible)==null?void 0:p.call(f))!==!1};let i=0;for(let u=0;u<s;u++)o(u)&&i++;if(e.isAllSelected())return t*i;const r=e.getRanges();if(!r.length)return 1;const l=Math.max(0,Math.min(...r.map(u=>u.r1))),a=Math.min(t-1,Math.max(...r.map(u=>u.r2))),c=Math.max(0,Math.min(...r.map(u=>u.c1))),h=Math.min(s-1,Math.max(...r.map(u=>u.c2)));if((a-l+1)*(h-c+1)>He.maxCopyCells)return 0;let d=0;for(let u=l;u<=a;u++)for(let f=c;f<=h;f++)o(f)&&e.isSelected(u,f)&&d++;return d}getHeaderFocus(){return this.headerFocus?[this.headerFocus[0],this.headerFocus[1]]:void 0}setFocusCell(e,t){const s=this.focusModel();return s?(this.headerFocus=void 0,s.setFocus(e,t),this.ensureColumnIsVisible(t),this.ensureRowIsVisible(e),this.afterActiveCellMoved(e,t),this.repaint(),!0):!1}afterActiveCellMoved(e,t){var s;(s=this.editingOptions)!=null&&s.collapseSelectionOnNavigate&&this.selectionService.collapseTo(e,t)}getFirstShownColumnIndex(){return this.getNextShownColumnIndex(-1,1,this.tableModel.getColumnCount())}getLastShownColumnIndex(){const e=this.tableModel.getColumnCount();return this.getNextShownColumnIndex(e,-1,e)}onBodyNavigation(e){const t=this.focusModel();if(!["NAVIGATE_ROW_START","NAVIGATE_ROW_END","NAVIGATE_FIRST_CELL","NAVIGATE_LAST_CELL","NAVIGATE_PAGE_UP","NAVIGATE_PAGE_DOWN","ACTIVATE_CELL"].includes(e))return;if(!t||this.isEditing())return!1;const o=this.tableModel.getBodyModel().getRowCount();if(o<1||this.tableModel.getColumnCount()<1)return!1;const[i,r]=t.getFocus(),l=Math.min(Math.max(i,0),o-1),a=r<0?this.getFirstShownColumnIndex():r,c=Math.max(1,this.displayedRowCount-1);switch(e){case"NAVIGATE_ROW_START":return this.setFocusCell(l,this.getFirstShownColumnIndex());case"NAVIGATE_ROW_END":return this.setFocusCell(l,this.getLastShownColumnIndex());case"NAVIGATE_FIRST_CELL":return this.setFocusCell(0,this.getFirstShownColumnIndex());case"NAVIGATE_LAST_CELL":return this.setFocusCell(o-1,this.getLastShownColumnIndex());case"NAVIGATE_PAGE_UP":return this.setFocusCell(Math.max(0,l-c),a);case"NAVIGATE_PAGE_DOWN":return this.setFocusCell(Math.min(o-1,l+c),a);default:{if(i<0||r<0)return!1;if(this.activateBodyCell(i,r))return!0;const h=this.editingOptions;if(h){if(h.enterKey==="moveDown")return this.moveActiveCell(i,r,1,0);if(this.tableModel.getBodyModel().isEditable(i,r))return this.startEditing(i,r,"edit")}const d=this.shortcutKeyEvent;return d!=null&&d.repeat||this.activateCell(i,r,d?"keyboard":"api",d),!1}}}activateCell(e,t,s,o){var r,l;const i=this.tableModel.getBodyModel();return!(e>=0&&t>=0)||e>=i.getRowCount()||t>=this.tableModel.getColumnCount()||!this.canFocusBodyCell(e,t)||this.tableOverlay.isBlocking()?!1:((l=(r=this.eventListener).onCellActivated)==null||l.call(r,new cc("body",e,t,i.getValueAt(e,t),i.getRowByIndex(e),s,o)),!0)}getTileLayout(){var e,t;return(t=(e=this.tableModel.getBodyModel()).getTileLayout)==null?void 0:t.call(e)}canFocusBodyCell(e,t){const s=this.getTileLayout();if(!s)return!0;const o=Es(e,t,s.getTilesPerRow());return o>=0&&o<s.getTileCount()}onTileNavigation(e){const t=Ie.tileActions[e],s=t?this.getTileLayout():void 0;if(!t||!s)return;const o=this.focusModel(),i=s.getTileCount();if(!o||this.isEditing()||i<1)return!1;const r=Math.max(1,s.getTilesPerRow()),[l,a]=o.getFocus(),c=this.firstFullVisibleRowIndex>=0?this.firstFullVisibleRowIndex:Math.max(0,this.getBodyRowIndexAtY(this.contentScrollTop)),h=hc(Es(l,a,r),t,{count:i,perRow:r,pageRows:this.displayedRowCount-1,firstVisible:c*r}),[d,u]=Ui(h,r);return(d!==l||u!==a)&&(this.headerFocus=void 0,o.setFocus(d,u),this.showBodyRow(d)||this.repaint()),!0}showBodyRow(e){const t=this.getBodyRowTop(e),s=t+this.tableModel.getRowHeight("body",e),o=this.contentScrollTop,i=this.areaBodyCenterGeo.height,r=t<o?t:s>o+i?Math.min(t,s-i):void 0;return r===void 0||!this.setContentScrollPosition(void 0,r)?!1:(this.adjustAfterScrolling(),!0)}rememberFocusedTile(){const e=this.getTileLayout(),t=e?this.focusModel():void 0;if(!e||!t){this.focusedTile=void 0;return}const[s,o]=t.getFocus(),i=Es(s,o,e.getTilesPerRow()),r=i>=0&&i<e.getTileCount()?e.getTileAt(i):void 0;this.focusedTile=r===void 0?void 0:{item:r,index:i}}beforeRenderPass(){if(this.focusFrameDirty&&(this.focusFrameDirty=!1,this.cancelPendingRepaint()),!this.tileFocusKnown){this.tileFocusKnown=!0,this.rememberFocusedTile();return}const e=this.focusedTile;if(!e||this.syncingTileFocus)return;const t=this.getTileLayout(),s=t?this.focusModel():void 0;if(!t||!s)return;const o=Math.max(1,t.getTilesPerRow()),i=t.getTileCount(),[r,l]=s.getFocus(),a=Es(r,l,o);if(a>=0&&a<i&&t.getTileAt(a)===e.item){e.index=a;return}let c=i>0?t.indexOfTile(e.item):-1;(c<0||c>=i)&&(c=Math.min(i-1,e.index)),this.syncingTileFocus=!0;try{if(c<0)s.clear();else{const[h,d]=Ui(c,o);s.setFocus(h,d)}}finally{this.syncingTileFocus=!1}this.rememberFocusedTile()}static isControlEvent(e){const t=e.target instanceof Element?e.target:null;return!!(t!=null&&t.closest('input, select, textarea, button, a[href], [contenteditable]:not([contenteditable="false"])'))}setKeyboardModality(e){var s,o;if(this.keyboardModality===e||(this.keyboardModality=e,((s=this.tableOptions)==null?void 0:s.focusFrame)!=="keyboard"))return;const t=(o=this.focusModel())==null?void 0:o.getFocus();(this.headerFocus||t&&t[0]>=0&&t[1]>=0)&&(this.focusFrameDirty=!0,this.debounceRepaint())}activateBodyCell(e,t){var r;const s=this.tableModel.getBodyModel();if(s.isRowCheckable(e)&&(this.tableOptions.showCheckboxWihoutExtraColumn&&t===this.getFirstDataColumnIndex()||hr(s.getCellRenderer(e,t))))return this.toggleRowCheckbox(e,t,"body"),!0;if((r=this.masterDetailService)!=null&&r.isMasterAt(e))return this.toggleDetail(e,"keyboard");const i=s.getRowByIndex(e);if(J(i)&&ee(s)&&s.hasDisplayedChildren(i)){const l=i;return this.setTreeRowExpanded(l,!l.expanded)}return!1}moveFocusIntoHeader(){const e=this.focusModel();if(!e||this.isEditing()||this.headerFocus)return!1;const[t,s]=e.getFocus(),o=this.getAriaGridInfo().headerRowCount,i=this.tableModel.getBodyModel().getRowCount()<1;return t!==0&&!i||o<1||this.tableModel.getColumnCount()<1?!1:(this.setHeaderFocus(o-1,s<0?this.getFirstShownColumnIndex():s),!0)}setHeaderFocus(e,t){var o;const s=(o=this.colAndRowspanModels.header)==null?void 0:o.getRanges().find(i=>i.isInRange(e,t));this.headerFocus=s?[s.r1,s.c1]:[e,t],this.ensureColumnIsVisible(this.headerFocus[1]),this.repaint()}onHeaderAction(e){var c;const[t,s]=this.headerFocus,o=this.tableModel.getAreaModel("header"),i=this.getAriaGridInfo().headerRowCount,r=this.tableModel.getColumnCount(),l=Math.max(1,o.getColspanAt(t,s)||1),a=Math.max(1,o.getRowspanAt(t,s)||1);switch(e){case"NAVIGATE_LEFT":{const h=this.getNextShownColumnIndex(s,-1,r);return h!==s&&this.setHeaderFocus(t,h),!0}case"NAVIGATE_RIGHT":{const h=this.getNextShownColumnIndex(s+l-1,1,r);return h>s+l-1&&this.setHeaderFocus(t,h),!0}case"NAVIGATE_ROW_START":return this.setHeaderFocus(t,this.getFirstShownColumnIndex()),!0;case"NAVIGATE_ROW_END":return this.setHeaderFocus(t,this.getLastShownColumnIndex()),!0;case"NAVIGATE_UP":return t>0&&this.setHeaderFocus(t-1,s),!0;case"NAVIGATE_DOWN":return t+a<i?(this.setHeaderFocus(t+a,s),!0):(c=this.filterRowService)!=null&&c.isVisible()&&this.filterRowService.focusColumn(s)?(this.headerFocus=void 0,this.repaint(),!0):this.tableModel.getBodyModel().getRowCount()<1?!0:this.setFocusCell(Math.max(0,this.firstFullVisibleRowIndex),s);case"NAVIGATE_FIRST_CELL":case"NAVIGATE_LAST_CELL":case"NAVIGATE_PAGE_UP":case"NAVIGATE_PAGE_DOWN":this.headerFocus=void 0;return;case"ACTIVATE_CELL":return this.activateHeaderCell(t,s,a,i);case"START_EDITING":case"TOGGLE_SELECTION":return!0;default:return}}activateHeaderCell(e,t,s,o){var a;const i=this.tableModel.getAreaModel("header"),r=i.getValueAt(e,t);if(r&&typeof r=="object"&&r.toggle&&r.visibility!=="always"&&"toggleHeaderGroup"in i){const c=new mo(null,this);return c.rowIdx=e,c.colIdx=t,c.areaIdent="header",c.areaModel=i,this.toggleHeaderGroup(c),this.setHeaderFocus(e,t),!0}const l=this.tableModel.getColumnDef(t);return e+s>=o&&((a=l==null?void 0:l.sortable)!=null&&a.call(l))?(this.sortByColumn(t),!0):!1}cancelEditing(e){var s,o;const t=this.getInCellEditorCell();if(t&&((o=(s=this.eventListener).onEditingChanged)==null||o.call(s,new qt("cancel",t[0],t[1],"edit"))),e instanceof HTMLSelectElement){const i=Array.from(e.options).find(r=>r.defaultSelected);e.selectedIndex=i?i.index:-1}else e&&(e.value=e.defaultValue);this.resetEditorRenderer(),this.hostElement.focus(),this.repaint()}updateModelValueAfterEdit(e,t,s,o){var l,a,c;if(e!=="body")return;this.getInCellEditorCell()&&((a=(l=this.eventListener).onEditingChanged)==null||a.call(l,new qt("commit",t,s,"edit",o)));const i=()=>{this.resetEditorRenderer()};if((c=this.batchEditService)!=null&&c.isActive()){i(),this.markPending([{rowIndex:t,column:s,value:o}],!1),this.repaint(),this.hostElement.focus();return}const r=this.writeCellsInternal([{rowIndex:t,columnIndex:s,value:o}],"edit",{beforeRepaint:i});(r.changes.length||r.invalid)&&(r.changes.length||(i(),this.repaint()),this.hostElement.focus())}applyCellChanges(e,t="api",s={}){var i;const o=this.resolveCellChanges(e);if(!o.length)return[];if((i=this.batchEditService)!=null&&i.isActive()){const r=this.markPending(o.map(l=>({rowIndex:l.rowIndex,column:l.columnIndex,value:l.value})),!0,!1,t,s.undoable);return this.repaint(),r}return this.writeCellsInternal(o,t,{undoable:s.undoable}).changes}writeCells(e,t,s={}){return this.writeCellsInternal(e,t,s).changes}writeCellsInternal(e,t,s){var g,m,b,w,y,C,S,x,R,I;const o=this.tableModel.getBodyModel(),i=o.getRowCount(),r=ge(o)?o.getBuildCount():0,l=[];let a=0,c="";const h=this.tableSheet,d=()=>{for(const{rowIndex:A,columnIndex:T,value:F}of e){const P=!!(h!=null&&h.isFormulaInput(T,F));if(!s.skipValidation){const N=P?this.checkFormulaSyntax(F):this.validateCellValue(A,T,s.raw?F:this.pipeCellValue(A,T,F));if(N){a++,c=c||N;continue}}const O=this.getCellInput(A,T);(s.raw||P?this.setRawValue(A,T,F):o.setValue(A,T,F))&&l.push({row:this.rowObjectOf(A),rowIndex:A,columnIndex:T,property:this.batchEditService.propertyOf(T),oldValue:O,newValue:this.getCellInput(A,T)})}};ge(o)?o.batch(d):d(),a&&this.announce(this.getEditTexts().invalidValue(c));const u=(g=s.extraChanges)!=null&&g.length?[...l,...s.extraChanges]:l;if(!u.length)return{changes:u,invalid:a,message:c||void 0};h==null||h.cellsWritten(u),(m=this.undoService)==null||m.record(u,t,s.undoable),(b=s.beforeRepaint)==null||b.call(s);const f=(w=s.extraChanges)!=null&&w.length?void 0:{area:"body",rowIndices:l.map(A=>A.rowIndex)};this.invalidateAggregates(f),ge(o)&&o.getBuildCount()!==r||o.getRowCount()!==i||t==="commit"?this.repaintHard():s.deferRepaint?this.debounceRepaint():this.repaint(),this.invalidateAggregates(f),(y=this.undoService)==null||y.beginFold();try{if(t==="edit"&&u.length===1){const A=mt.createSingle(u[0].rowIndex,u[0].columnIndex);A.changes=u,A.source=t,(S=(C=this.eventListener).onModelChanged)==null||S.call(C,A)}else(R=(x=this.eventListener).onModelChanged)==null||R.call(x,mt.createForChanges(u,t))}finally{(I=this.undoService)==null||I.endFold()}return{changes:u,invalid:a,message:c||void 0}}writePastedCells(e,t,s){var i;const o=this.resolveCellChanges(e);if(!o.length)return[];if((i=this.batchEditService)!=null&&i.isActive()){const r=this.markPending(o.map(l=>({rowIndex:l.rowIndex,column:l.columnIndex,value:l.value})),!0,s,t);return this.repaint(),r}return this.writeCellsInternal(o,t,{raw:s}).changes}selectBodyRange(e){const t=this.focusModel();t&&(this.headerFocus=void 0,t.setFocus(e.r1,e.c1)),this.selectionService.collapseTo(e.r1,e.c1),(e.r2!==e.r1||e.c2!==e.c1)&&this.selectionService.extendTo(e.r2,e.c2),this.repaint()}checkPastedValue(e,t,s,o){var i;return(i=this.tableSheet)!=null&&i.isFormulaInput(t,s)?this.checkFormulaSyntax(s):this.validateCellValue(e,t,o?s:this.pipeCellValue(e,t,s))}getCellInput(e,t){const s=this.tableModel.getBodyModel();return this.tableSheet&&s.getInputValueAt?s.getInputValueAt(e,t):s.getValueAt(e,t)}getTypedCellValue(e,t){var o;const s=this.getShownCellValue(e,t);return(o=this.tableSheet)!=null&&o.isFormulaInput(t,s)?this.tableModel.getBodyModel().getValueAt(e,t):s}getFormulaErrorText(e){const t=this.ariaTexts??{};return(t.formulaError??new Le().formulaError).call(t,e)}checkFormulaSyntax(e){const t=this.tableSheet;return t.options.rejectInvalidFormulas?t.syntaxError(e):void 0}resolvePastedValue(e,t,s,o){if(!(e instanceof ks))return e;const i=this.tableSheet;return!i||!i.isFormulaColumnIndex(s)?e.value:o?e.input:i.moveFormula(e.input,e.row,e.col,t,s)??e.value}getCopyValue(e,t){var i;const s=this.tableSheet,o=this.getShownCellValue(e,t);return!s||(i=this.batchEditService)!=null&&i.getPendingAt(e,t)?o:s.copyOf(e,t,o,this.tableModel.getBodyModel().getValueAt(e,t))}isBatchEditActive(){var e;return!!((e=this.batchEditService)!=null&&e.isActive())}getUndoOptions(){return this.undoOptions}writeUndoCells(e,t,s){var r;if(!e.length&&!t.length)return[];const o=this.tableModel.getBodyModel();if((r=this.batchEditService)!=null&&r.isActive()){const l=e.length?this.markPending(e.map(a=>({rowIndex:a.rowIndex,column:a.columnIndex,value:a.value})),!0,!0,s):[];return this.repaint(),l}const i=this.writeCellsInternal(e,s,{raw:!0,skipValidation:!0,extraChanges:t}).changes;return t.length&&ge(o)&&(o.regroup(),this.invalidateAggregates(),this.repaintHard()),i}getUndoTexts(){const e=this.ariaTexts??{},t=new Le;return{undone:(s,o)=>(e.undone??t.undone).call(e,s,o),redone:(s,o)=>(e.redone??t.redone).call(e,s,o),nothingToUndo:()=>(e.nothingToUndo??t.nothingToUndo).call(e),nothingToRedo:()=>(e.nothingToRedo??t.nothingToRedo).call(e),undoSkipped:s=>(e.undoSkipped??t.undoSkipped).call(e,s),undoHistoryCleared:s=>(e.undoHistoryCleared??t.undoHistoryCleared).call(e,s)}}isOverlayBlocking(){return this.tableOverlay.isBlocking()}rowsAppended(){this.invalidateAggregates()}isRowGroupingOrTree(){const e=this.tableModel.getBodyModel();return ee(e)||ge(e)||po(this.tableModel)}getClipboardService(){return this.clipboardService||(this.clipboardService=new Wi(this,Gs.create(!0),!1)),this.clipboardService}markPending(e,t,s=!1,o="edit",i){const r=t?e.map(d=>({rowIndex:d.rowIndex,columnIndex:d.column,value:d.value})):this.resolveCellChanges(e,!1),l=this.batchEditService,a=this.undoService?r.map(({rowIndex:d,columnIndex:u})=>{const f=l.rowKeyOf(d),p=l.propertyOf(u),g=l.getPendingEntry(f,p);return{rowKey:f,property:p,before:g?{...g}:void 0}}):void 0,c=r.map(({rowIndex:d,columnIndex:u,value:f})=>{var m;if((m=this.tableSheet)!=null&&m.isFormulaInput(u,f)){const b=this.checkFormulaSyntax(f);return{rowIndex:d,columnIndex:u,value:f,rawValue:f,...b?{error:b}:{}}}const p=s?f:this.pipeCellValue(d,u,f),g=this.validateCellValue(d,u,p);return{rowIndex:d,columnIndex:u,value:p,rawValue:f,...g?{error:g}:{}}}),h=l.addPending(c);if(a&&h.length){for(const d of a){const u=l.getPendingEntry(d.rowKey,d.property);d.after=u?{...u}:void 0}this.undoService.recordPending(a.filter(d=>!d.before!=!d.after||!!d.before&&!!d.after&&!as(d.before.newValue,d.after.newValue)),o,i)}return h}resolveCellChanges(e,t=!0){var a,c;const s=this.tableModel.getBodyModel(),o=s.getRowCount(),i=this.tableModel.getColumnCount(),r=((c=(a=this.tableModel).getColumnDefs)==null?void 0:c.call(a))??[],l=[];for(const h of e){const d=typeof h.column=="number"?h.column:r.findIndex(f=>f.property===h.column),u=h.rowIndex;u>=0&&u<o&&d>=0&&d<i&&(t&&!s.isEditable(u,d)||l.push({rowIndex:u,columnIndex:d,value:h.value}))}return l}pipeCellValue(e,t,s){var i;const o=(i=this.tableModel.getColumnDef(t))==null?void 0:i.editInputPipe;return o?o(s,e,t):s}validateCellValue(e,t,s){var r;const o=(r=this.tableModel.getColumnDef(t))==null?void 0:r.validate;if(!o)return;const i=o(s,this.rowObjectOf(e));return i?String(i):void 0}rowObjectOf(e){const t=this.tableModel.getBodyModel().getRowByIndex(e);return J(t)?t.data:t}getFillHandleOptions(){return Ws.create(At(this.tableOptions,"fillHandle"))}fillRange(e,t,s,o="auto",i){const r=this.getFillHandleOptions()??Ws.create(!0),l=this.tableModel.getBodyModel(),a=l.getRowCount(),c=this.tableModel.getColumnCount(),h=this.normalizeRange(e,a,c);if(!h||s<1)return 0;const d=t==="down"?a-1-h.r2:t==="up"?h.r1:t==="right"?c-1-h.c2:h.c1,u=Math.min(s,d);if(u<1)return 0;const f=t==="down"||t==="up"?h.c2-h.c1+1:h.r2-h.r1+1;if(u*f>r.maxCells)return this.announce(this.getEditTexts().fillTooLarge(r.maxCells)),-1;const p=this.batchEditService,g=Ea({source:h,direction:t,count:u,mode:o,getValue:(w,y)=>p.getShownValue(w,y),isFillable:(w,y)=>this.tableModel.getColumnWidth(y)>0&&l.isEditable(w,y),fillValue:r.fillValue,getCellInfo:(w,y)=>{var C;return{row:this.rowObjectOf(w),property:((C=this.tableModel.getColumnDef(y))==null?void 0:C.property)??""}}});this.tableSheet&&this.moveFilledFormulas(g,h,t);const m=this.applyCellChanges(g,"fill"),b=this.selectionModel();return b&&this.holdSelectionEvents(()=>{b.clear(),b.addSelection(i??Or(h,t,u)),this.onSelectionChanged(b)}),this.repaint(),this.announce(this.getEditTexts().cellsFilled(m.length)),m.length}moveFilledFormulas(e,t,s){const o=this.tableSheet,i=t.r2-t.r1+1,r=t.c2-t.c1+1,l=(a,c)=>(a%c+c)%c;for(const a of e){const c=a.rowIndex,h=a.column,d=s==="down"?t.r1+l(c-t.r2-1,i):s==="up"?t.r2-l(t.r1-1-c,i):c,u=s==="right"?t.c1+l(h-t.c2-1,r):s==="left"?t.c2-l(t.c1-1-h,r):h,f=this.getShownCellValue(d,u);if(!o.isFormulaInput(u,f))continue;const p=o.physicalRow(d),g=o.engineColumn(u);if(p===void 0||g===void 0)continue;const m=o.moveFormula(f,p,g,c,h);m!==void 0&&(a.value=m)}}getFillSourceRange(){const e=this.selectionModel();if(!e||e.selectionType!=="range"||e.isAllSelected())return;const t=e.getRanges();if(t.length)return this.normalizeRange(t[t.length-1],this.tableModel.getBodyModel().getRowCount(),this.tableModel.getColumnCount())}normalizeRange(e,t,s){const o=Math.max(0,Math.min(e.r1,e.r2)),i=Math.min(t-1,Math.max(e.r1,e.r2)),r=Math.max(0,Math.min(e.c1,e.c2)),l=Math.min(s-1,Math.max(e.c1,e.c2));return o<=i&&r<=l?new M(o,r,i,l):void 0}fillByKeyboard(e){var r;const t=this.getFillHandleOptions(),s=e==="down";if(!t||this.isEditing()||(r=this.fillHandleService)!=null&&r.isFilling()||t.direction===(s?"horizontal":"vertical"))return!1;const o=this.getFillSourceRange();if(!o)return!1;const i=s?o.r2-o.r1:o.c2-o.c1;if(i>0){const l=s?new M(o.r1,o.c1,o.r1,o.c2):new M(o.r1,o.c1,o.r2,o.c1);this.fillRange(l,e,i,"copy")}else if(s?o.r1>0:o.c1>0){const l=s?new M(o.r1-1,o.c1,o.r1-1,o.c2):new M(o.r1,o.c1-1,o.r2,o.c1-1);this.fillRange(l,e,1,"copy",o)}return!0}setHostKeyShortcuts(e){e===void 0?this.restoreHostAriaAttribute("aria-keyshortcuts"):this.setHostAriaAttribute("aria-keyshortcuts",e)}getEditTexts(){const e=this.ariaTexts,t=new Le;return{cellsFilled:s=>(e.cellsFilled??t.cellsFilled).call(e,s),fillTooLarge:s=>(e.fillTooLarge??t.fillTooLarge).call(e,s),pendingChanges:s=>(e.pendingChanges??t.pendingChanges).call(e,s),changesCommitted:s=>(e.changesCommitted??t.changesCommitted).call(e,s),changesDiscarded:()=>(e.changesDiscarded??t.changesDiscarded).call(e),commitBlocked:s=>(e.commitBlocked??t.commitBlocked).call(e,s),invalidValue:s=>(e.invalidValue??t.invalidValue).call(e,s)}}getApi(){return this.api}firstInit(){const e=this.getAvailableColumnWidth();e>0&&this.setParentWidth(e),this.stateService.initBeforeModel(),this.tableModel.init(),this.stateService.initAfterModel();const t=this.getEffectiveFilterFunction();return t&&this.applyFilterFunction(t,!1,!1),this.stateService.initAfterFilter(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.stateService.initAfterLayout(),this.liveAnnouncer.getElement(),this.initialized=!0,this}destroy(){var s,o,i,r,l,a,c,h,d,u,f;if(this.destroyed)return;try{this.stateService.destroy()}catch(p){console.error(p)}(o=(s=this.columnDrag)==null?void 0:s.keyAbort)==null||o.abort(),this.columnDrag=void 0;try{(i=this.rowDragService)==null||i.destroy()}catch(p){console.error(p)}(r=this.fillHandleService)==null||r.destroy(),(l=this.cellEditorService)==null||l.destroy(),(a=this.clipboardService)==null||a.destroy(),(c=this.filterRowService)==null||c.destroy(),(h=this.columnFilterMenuService)==null||h.destroy(),(d=this.columnChooserService)==null||d.destroy(),(u=this.tableSheet)==null||u.destroy(),this.subscribers.clear();try{(f=this.masterDetailService)==null||f.destroy()}catch(p){console.error(p)}this.destroyed=!0,this.listenerAbortController.abort(),this.resizeHandler.disconnect();const e=this.getSelectionModel?this.getSelectionModel():void 0;e==null||e.removeEventSelectionChangedListener(this);const t=this.getFocusModel?this.getFocusModel():void 0;t==null||t.removeEventFocusChangedListener(this),this.disposeRendering(),this.tableOverlay.destroy(),this.liveAnnouncer.destroy(),this.removeHostAria(),this.hostElement.innerText=""}isEventInDetail(e){var t;return!!((t=this.masterDetailService)!=null&&t.isInLayer(e))}setDetailExpanded(e,t,s="api"){var o;return!!((o=this.masterDetailService)!=null&&o.setExpanded(e,t,s))}toggleDetail(e,t="api"){const s=this.masterDetailService;return!!s&&s.setExpanded(e,!s.isExpanded(e),t)}onDetailToggled(e,t,s,o,i=!0,r=!1){var l,a,c,h,d,u;if(r||this.invalidateRowLayout(),this.resetSizeOfWrapperDiv(),this.repaint(),i&&((a=(l=this.eventListener).onDetailExpandedChanged)==null||a.call(l,new Ia(e,t,s,o))),o==="mouse"||o==="keyboard"){const f=s?(h=(c=this.ariaTexts).detailExpanded)==null?void 0:h.call(c):(u=(d=this.ariaTexts).detailCollapsed)==null?void 0:u.call(d);f&&this.announce(f)}this.stateService.markDirty("details")}onDetailHeightChanged(){this.destroyed||(this.resetSizeOfWrapperDiv(),this.adjustAfterScrolling())}takeFocusFromDetail(e){const t=this.focusModel();if(t&&e>=0){const s=t.getFocus()[1];this.headerFocus=void 0,t.setFocus(e,s>=0?s:this.getFirstShownColumnIndex())}this.hostElement.focus({preventScroll:!0})}focusDetailMaster(e){const t=this.focusModel();if(!t||e<0)return;const s=t.getFocus()[1];this.setFocusCell(e,s>=0?s:this.getFirstShownColumnIndex())}isDestroyed(){return this.destroyed}createGeMouseEvent(e){if(!e)return new Vs;const t=this.getMouseEventTarget(e),[s,o]=this.getAreaAndSideIdentByAttr(t);return this.createGeMouseEventForCell(e,{areaIdent:s,sideIdent:o,rowIndex:this.getNumberByAttr(t,"data-row-index"),columnIndex:this.getNumberByAttr(t,"data-col-index"),action:this.getStringByAttr(t,"data-ge-action")})}createGeMouseEventForCell(e,t){const s=new Vs;if(s.originalEvent=e,s.areaIdent=t.areaIdent,s.sideIdent=t.sideIdent,s.rowIndex=t.rowIndex,s.columnIndex=t.columnIndex,s.action=t.action,s.areaIdent){const o=this.tableModel.getAreaModel(s.areaIdent);s.rowTop=s.areaIdent==="body"?this.getBodyRowTop(s.rowIndex):o.getYPosByRowIndex(s.rowIndex)}return s.columnLeft=this.tableModel.getXPosByColumnIndex(s.columnIndex),s}getMouseEventTarget(e){let t=e.target;if(t instanceof Element&&!t.isConnected&&Number.isFinite(e.clientX)&&Number.isFinite(e.clientY)&&(t=this.getCellElementAtPoint(e.clientX,e.clientY)??t),(t===this.scrollViewport||t===this.contentWrapperDiv||t===this.contentDiv)&&this.tableModel.getPadding().bottom>0){const s=this.scrollViewport.getBoundingClientRect(),o=e.clientX-s.left,i=e.clientY-s.top>=this.scrollViewport.clientHeight||o<this.scrollViewport.clientLeft||o>=this.scrollViewport.clientLeft+this.scrollViewport.clientWidth,r=this.hostElement.getRootNode();if(!i&&r.elementsFromPoint){const l=r.elementsFromPoint(e.clientX,e.clientY).find(a=>this.hostElement.contains(a)&&a.closest(".ge-table-footer"));if(l)return l}}return t}getCellElementAtPoint(e,t){var o;const s=this.hostElement.getRootNode();return(o=s.elementsFromPoint)==null?void 0:o.call(s,e,t).find(i=>this.hostElement.contains(i)&&!!i.closest("[data-col-index]"))}onMouseDown(e){var o;this.selectionService.onMouseDown(),this.resetColumnDrag();const t=e.columnIndex,s=e.action==="resize-column";if(t>-1&&(s||e.action==="drag-column")&&(s?this.isColumnResizable(t):this.isColumnMovable(t))&&(this.mouseStartWidth=this.tableModel.getColumnWidth(t),this.mouseStartAction=e.action,this.mouseStartColumnIndex=t,this.mouseStartAction==="drag-column"&&(this.firstDraggingRendering=!0,this.dragFrom=this.mouseStartColumnIndex),s?this.tableOptions.columnsResizable:this.tableOptions.columnsDraggable&&((o=this.tableSheet)==null?void 0:o.allowsColumnDrag())!==!1)){const r=this.tableModel.getColumnDef(t);this.columnDrag={kind:s?"resize":"move",source:"mouse",columnIndex:t,currentIndex:t,columnDef:r,startWidth:this.mouseStartWidth,moves:[],started:!1,cancelled:!1}}}resetColumnDrag(){var e,t;(t=(e=this.columnDrag)==null?void 0:e.keyAbort)==null||t.abort(),this.columnDrag=void 0,this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.firstDraggingRendering=!0}beginColumnDrag(e){var l;const t=this.columnDrag;if(!t||t.cancelled)return!1;if(t.started)return!0;const s=e.draggingX||0,o=e.draggingY||0,i=((l=this.mouseHandler)==null?void 0:l.clickMoveTolerance)??4;if(s*s+o*o<=i*i)return!1;t.started=!0;const r=new AbortController;return t.keyAbort=r,(this.hostElement.ownerDocument??document).addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),this.cancelColumnDrag(a))},{capture:!0,signal:r.signal}),this.emitColumnDragEvent(t,"start",e.originalEvent),!t.cancelled&&this.columnDrag===t&&!this.isDestroyed()}isColumnDragging(){var e;return!!((e=this.columnDrag)!=null&&e.started)&&!this.columnDrag.cancelled}cancelColumnDrag(e){var s;const t=this.columnDrag;if(!(!t||!t.started||t.cancelled)){if(t.cancelled=!0,(s=t.keyAbort)==null||s.abort(),t.kind==="resize")this.tableModel.setColumnWidth(t.columnIndex,t.startWidth),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows();else{this.hideDraggingColumn(),this.draggingTargetColumnIndex=-1;for(let o=t.moves.length-1;o>=0;o--){const[i,r]=t.moves[o];this.tableModel.changeColumnOrder(r,i)}t.moves=[],t.currentIndex=t.columnIndex,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.stateService.markDirty("selection")}this.stateService.markDirty("columns"),this.emitColumnDragEvent(t,"cancel",e)}}emitColumnDragEvent(e,t,s){var i,r,l,a,c,h,d,u,f,p,g;const o=(i=e.columnDef)==null?void 0:i.property;if(e.kind==="resize"){const m=t==="start"?e.startWidth:this.tableModel.getColumnWidth(e.columnIndex),b=new lc(t,e.source,e.columnIndex,e.columnDef,o,e.startWidth,m,s);t==="start"?(l=(r=this.eventListener).onColumnResizeStart)==null||l.call(r,b):(c=(a=this.eventListener).onColumnResizeEnd)==null||c.call(a,b)}else{const m=(((d=(h=this.tableModel).getColumnDefs)==null?void 0:d.call(h))??[]).map(w=>w==null?void 0:w.property),b=new ac(t,e.columnIndex,t==="start"?e.columnIndex:e.currentIndex,e.columnDef,o,m,s);t==="start"?(f=(u=this.eventListener).onColumnMoveStart)==null||f.call(u,b):(g=(p=this.eventListener).onColumnMoveEnd)==null||g.call(p,b)}}mouseDraggingOnFrame(e,t){var s,o;(o=(s=this.eventListener).onMouseDragging)==null||o.call(s,e),this.mouseEvent=e,!((this.mouseStartAction==="resize-column"||this.mouseStartAction==="drag-column")&&!this.beginColumnDrag(e))&&(this.mouseStartAction==="resize-column"?this.resizeColumn(e):!this.mouseStartAction&&this.selectionService.onMouseDragging(e,t)?this.repaint():this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&(this.moveDraggedColumn(e.columnIndex),t&&(this.adjustDraggingColumn(e,this.dragFrom,this.firstDraggingRendering),this.firstDraggingRendering=!1),this.repaint()))}moveDraggedColumn(e){var i;const t=this.tableModel,s=t.getColumnCount();let o=bd(this.dragFrom,e,s,t.getFixedLeftColumnCount(),t.getFixedRightColumnCount());for(;this.dragFrom>-1&&o!==this.dragFrom&&!this.isColumnMovable(o);)o+=o>this.dragFrom?-1:1;if(this.dragFrom>-1&&o!==this.dragFrom&&!(this.lastDragFrom===o&&this.lastDragTo===this.dragFrom)){const r=Array.from({length:s},(a,c)=>this.isColumnMovable(c)),l=md(r,this.dragFrom,o);l!=null&&l.length&&(l.forEach(([a,c])=>t.changeColumnOrder(a,c)),(i=this.columnDrag)==null||i.moves.push(...l),this.lastDragFrom=this.dragFrom,this.lastDragTo=o,this.dragFrom=o,this.columnDrag&&(this.columnDrag.currentIndex=o),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows())}this.draggingTargetColumnIndex=this.dragFrom}mouseDraggingEndOnFrame(e){var o,i;(i=(o=this.eventListener).onMouseDraggingEnd)==null||i.call(o,e),this.draggingTargetColumnIndex=-1;const t=this.columnDrag;t&&this.beginColumnDrag(e);const s=!!t&&t.started&&!t.cancelled;this.mouseStartAction==="resize-column"?s&&(this.resizeColumn(e),this.stateService.markDirty("columns")):this.mouseStartAction==="drag-column"&&(s&&e.columnIndex>-1&&(this.moveDraggedColumn(e.columnIndex),this.draggingTargetColumnIndex=-1),this.hideDraggingColumn(),s&&(this.repaint(),this.stateService.markDirty("columns"),this.stateService.markDirty("selection"))),this.resetColumnDrag(),s&&this.emitColumnDragEvent(t,"end",e.originalEvent)}mouseMove(e){var t,s;(s=(t=this.eventListener).onMouseMoved)==null||s.call(t,e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){var s,o,i,r;const t=Date.now();if(t-this.lastContextmenu<50){this.lastContextmenu=t,(s=e.originalEvent)==null||s.preventDefault(),(o=e.originalEvent)==null||o.stopImmediatePropagation();return}this.lastContextmenu=t,(r=(i=this.eventListener).onContextmenu)==null||r.call(i,e)}toggleExpandCollapseAll(e=!0){const t=this.tableModel.getBodyModel();ee(t)&&(t.toggleExpandCollapseAll(e),this.allExpanded=e,this.repaintHard(),this.stateService.markDirty("tree"))}setTreeRowExpanded(e,t){const s=this.tableModel.getBodyModel();return!ee(s)||e.expanded===t?!1:(e.expanded=t,s.recalcVisibleTreeRows(!1),this.repaintHard(),this.stateService.markDirty("tree"),!0)}setRowGroupBy(e){const t=this.tableModel.getBodyModel();return ge(t)?(t.setGroupBy(e),Pi(this.tableModel),this.invalidateAggregates(),this.tableModel.recalcPadding(),this.repaintHard(),this.stateService.markDirty("tree"),this.stateService.markDirty("columns"),!0):!1}setPivotConfig(e,t){var o,i;const s=this.tableModel;if(!po(s))return!1;s.setPivotConfig(e,t),(s.getColumnDefs()??[]).forEach(r=>r.sortState=void 0),this.lastSortCompareFn=void 0,this.clearSelection(),(o=this.getFocusModel?this.getFocusModel():void 0)==null||o.clear();for(const r of["header","body","footer"])(i=this.colAndRowspanModels[r])==null||i.init();return this.invalidateAggregates(),this.firstInit(),this.repaintHard(),this.stateService.markDirty("columns"),this.stateService.markDirty("sort"),this.stateService.markDirty("tree"),this.stateService.markDirty("headerGroups"),!0}toggleRowCheckbox(e,t,s){var a,c,h;const o=this.tableModel.getAreaModel(s),i=o.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";o.setRowChecked(e,r),this.repaint();const l=(a=o.rowSelectionModel)==null?void 0:a.getCheckedRows();(h=(c=this.eventListener).onCheckboxChanged)==null||h.call(c,l?l.slice():[]),this.stateService.markDirty("checked")}onMouseClicked(e,t){if(this.headerFocus=void 0,e.clickCount>1)return!1;let s=this.selectionService.onMouseClicked(e,t);if(!s&&this.getFocusModel){this.resetEditorRenderer();const o=this.getFocusModel();o&&(s=o.hasChanged(),o.clearChanged())}return s}debounceRepaint(){this.debounce(this.repaint.bind(this),1)}cancelPendingRepaint(){return this.debounceTimeout?(clearTimeout(this.debounceTimeout),this.debounceTimeout=null,!0):!1}publishGeMouseEvent(e){var t,s;(s=(t=this.eventListener).onMouseClicked)==null||s.call(t,e)}onFocusChanged(e){var t,s;this.rememberFocusedTile(),(s=(t=this.eventListener).onFocusChanged)==null||s.call(t,e)}stateChanged(e){var t,s;(s=(t=this.eventListener).onStateChanged)==null||s.call(t,e)}afterRenderPass(){var e,t,s,o,i;(e=this.stateService)==null||e.rendered(),(t=this.filterRowService)==null||t.update(),(s=this.fillHandleService)==null||s.update(),(o=this.cellEditorService)==null||o.update(),(i=this.clipboardService)==null||i.update()}onSelectionChanged(e){var t,s,o;if((t=this.stateService)==null||t.markDirty("selection"),this.selectionEventsHeld>0){this.heldSelectionModel=e;return}(o=(s=this.eventListener).onSelectionChanged)==null||o.call(s,e)}holdSelectionEvents(e){var t,s;this.selectionEventsHeld++;try{e()}finally{if(this.selectionEventsHeld--,this.selectionEventsHeld===0&&this.heldSelectionModel){const o=this.heldSelectionModel;this.heldSelectionModel=void 0,(s=(t=this.eventListener).onSelectionChanged)==null||s.call(t,o)}}}getEffectiveFilterFunction(){return this.columnFilterService.getEffectiveFilterFunction()}applyFilterFunction(e,t=!0,s=!0,o=!1){if(t&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(e),this.reapplySorting(),this.invalidateAggregates(),o?this.scrollViewport.scrollTop=0:this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),s&&this.repaint(),this.initialized){const i=this.tableModel.getBodyModel().getRowCount();this.announce(this.ariaTexts.filtered(i),Ie.filterAnnouncementDelayInMs)}}reapplyFilterAfterSetRows(e){this.tableModel.externalFilterChanged(e),this.reapplySorting(),this.invalidateAggregates()}externalFilterChanged(e=!0){const t=this.getEffectiveFilterFunction();t&&this.applyFilterFunction(t,e,!0)}setColumnFilter(e,t){this.columnFilterService.setColumnFilter(e,t,"api")}getColumnFilter(e){return this.columnFilterService.getColumnFilter(e)}getColumnFilters(){return this.columnFilterService.getColumnFilters()}setColumnFilters(e){this.columnFilterService.setColumnFilters(e,"api")}clearColumnFilters(){this.columnFilterService.clearColumnFilters("api")}isColumnFiltered(e){return this.columnFilterService.isColumnFiltered(e)}getHeaderExtraHeight(){var e;return((e=this.filterRowService)==null?void 0:e.getReservedHeight())??0}getFilterRowCount(){var e;return(e=this.filterRowService)!=null&&e.isVisible()?1:0}isEventInFilterUI(e){var t,s,o;return!!((t=this.filterRowService)!=null&&t.isInLayer(e))||!!((s=this.columnFilterMenuService)!=null&&s.isInPopup(e))||!!((o=this.columnChooserService)!=null&&o.isInPopup(e))}showColumnFilterMenu(e){if(!this.columnFilterMenuService){const t=Us.create(!0,this.columnFilterService.getOptions().maxValues);this.columnFilterMenuService=new qi(this,t,!1)}return this.columnFilterMenuService.open(e)}toggleColumnFilterMenu(e){return this.columnFilterMenuService?this.columnFilterMenuService.toggle(e):!1}hideColumnFilterMenu(){var e;(e=this.columnFilterMenuService)==null||e.close("api")}showColumnChooser(e){this.columnChooserService||(this.columnChooserService=new vc(this)),this.columnChooserService.open(e)}hideColumnChooser(){var e;(e=this.columnChooserService)==null||e.close("api")}hasFilterRow(){return!!this.filterRowService}isFilterRowVisible(){var e;return!!((e=this.filterRowService)!=null&&e.isVisible())}setFilterRowVisible(e){if(e&&!this.filterRowService)this.initFilterRowService(!0);else if(this.filterRowService){if(!this.filterRowService.setVisible(e))return}else return;this.recalcWrappers(),this.stateService.markDirty("filters")}restoreFilterRowVisible(e){if(!this.filterRowService)return!1;const t=this.filterRowService.setVisible(e);return t&&this.tableModel.recalcPadding(),t}onColumnFiltersChanged(e){var t;(t=this.filterRowService)==null||t.syncFromFilters(e)}clearHeaderFocusForFilterRow(){this.headerFocus&&(this.headerFocus=void 0,this.repaint())}focusHeaderFromFilterRow(e){const t=this.getAriaGridInfo().headerRowCount;t>0&&this.setHeaderFocus(t-1,e),this.hostElement.focus({preventScroll:!0})}focusBodyFromFilterRow(e){const t=this.tableModel.getBodyModel().getRowCount();this.headerFocus=void 0,t>0&&this.setFocusCell(Math.max(0,this.firstFullVisibleRowIndex),e),this.hostElement.focus({preventScroll:!0})}initFilterRowService(e){const t=oi.create(e);if(!t)return;this.filterRowService=new Cc(this,t);const s=(this.hostElement.getAttribute("aria-owns")??"").split(" ").filter(Boolean),o=this.ariaIds.rowGroup("body","west"),i=s.indexOf(o),r=[this.ariaIds.filterRowGroup("west"),this.ariaIds.filterRowGroup("center"),this.ariaIds.filterRowGroup("east")];s.splice(i<0?s.length:i,0,...r),this.setHostAriaAttribute("aria-owns",s.join(" "))}onHeaderDblClicked(e,t,s){const o=this.tableModel.getColumnDef(s);o!=null&&o.sortable&&o.sortable()&&(e.preventDefault(),e.stopPropagation(),this.sortByColumn(s))}sortByColumn(e,t){var h;const s=typeof e=="number"?e:(this.tableModel.getColumnDefs()??[]).findIndex(d=>d.property===e),o=this.tableModel.getColumnDef(s);if(!o)return!1;const i=o.sortStatesOrder?o.sortStatesOrder:this.tableOptions.sortOrder,r=o.sortState??"",l=t??i[(i.indexOf(r)+1)%i.length],a=new Is(s,l),c=this.tableModel.doSort([a]);return c&&(this.invalidateAggregates(),this.lastSortCompareFn=void 0,(h=this.tableModel.getColumnDefs())==null||h.forEach(d=>d.sortState=""),o.sortState=l),this.repaint(),c&&this.stateService.sortedByColumn(l?o.property:void 0),c&&this.announce(this.ariaTexts.sorted(this.getColumnAriaLabel(s),l)),!0}scrollToPixel(e,t){this.setContentScrollPosition(e,t)&&this.adjustAfterScrolling()}scrollToIndex(e,t){const s=this.getBodyRowTop(t);this.scrollToPixel(this.getScrollLeftForColumnIndex(e),s)}getScrollLeftForColumnIndex(e){const t=this.scrollViewport,s=this.tableModel.getFixedLeftColumnCount(),o=this.tableModel.getColumnCount()-this.tableModel.getFixedRightColumnCount()-1;if(e>=0&&e<s)return 0;if(!(e>=s&&e<=o))return this.getViewportScrollLeft();let i=0;for(let a=s;a<e;a++)i+=this.tableModel.getColumnWidth(a);const r=this.tableModel.getContentWidthInPixel()-this.areaBodyCenterGeo.width,l=t.scrollWidth-t.clientWidth;return r<=0||l<=0?0:Math.min(1,i/r)*l}adjustAfterScrolling(){var t,s;if(super.adjustAfterScrolling(),this.adjustingRowNumberWidth)return;const e=this.scrollViewport;(s=(t=this.eventListener).onScroll)==null||s.call(t,new sa(this.scrollTop,this.scrollLeft,e.scrollHeight,e.scrollWidth,e.clientHeight,e.clientWidth,this.scrollFactorY,this.scrollFactorX))}setSelectionModel(e,t=!1){var o;(o=this.selectionModel())==null||o.removeEventSelectionChangedListener(this),e.addEventSelectionChangedListener(this);const s=()=>e;this.tableOptions.getSelectionModel=s,this.getSelectionModel=s,this.selectionService.getSelectionModel=s,t&&this.repaint()}toggleHeaderGroup(e){const t=this.tableModel.getAreaModel("header");"columnDefs"in this.tableModel&&(this.tableModel.columnDefs=t.toggleHeaderGroup(e)),this.headerGroupsChanged()}setHeaderGroupCollapsed(e,t){var i;const s=this.tableModel.getAreaModel("header"),o=(i=s.setGroupClosed)==null?void 0:i.call(s,e,t);return o?("columnDefs"in this.tableModel&&(this.tableModel.columnDefs=o),this.headerGroupsChanged(),!0):!1}headerGroupsChanged(){this.firstInit(),this.stateService.markDirty("headerGroups"),this.stateService.markDirty("columns")}selectionModel(){if(this!=null&&this.getSelectionModel)return this.getSelectionModel()}focusModel(){if(this!=null&&this.getFocusModel)return this.getFocusModel()}setDragging(e){this.dragging=e,this.dragging?(this.storeColumnWidths(),this.lastDragFrom=-1,this.lastDragTo=-1):this.storedColumnWidths=[]}changeFocusCell(e,t){var s;if(!this.isEditing()&&this.getFocusModel){const o=this.getFocusModel();if(o){const i=this.tableModel.getBodyModel().getRowCount(),r=this.tableModel.getColumnCount();if(i<1||r<1)return!1;const[l,a]=o.getFocus(),c=Math.min(Math.max(l+t,0),i-1),h=this.getNextShownColumnIndex(a,e,r);return c!==l||h!==a?(o.setFocus(c,h),this.ensureColumnIsVisible(h),this.ensureRowIsVisible(c),this.afterActiveCellMoved(c,h),this.repaint()):(s=this.editingOptions)!=null&&s.collapseSelectionOnNavigate&&(this.afterActiveCellMoved(c,h),this.repaint()),!0}}return!1}getNextShownColumnIndex(e,t,s){if(!t){const l=Math.min(Math.max(e,0),s-1);return e<0&&this.tableModel.getColumnWidth(l)<=0?this.getNextShownColumnIndex(-1,1,s):l}const o=t>0?1:-1;let i=e,r=e;for(let l=Math.abs(t);l>0;l--){for(r+=o;r>=0&&r<s&&this.tableModel.getColumnWidth(r)<=0;)r+=o;if(r<0||r>=s)break;i=r}return Math.min(Math.max(i,0),s-1)}resizeColumn(e){const t=this.isRtl()?-e.draggingX:e.draggingX,s=this.clampToColumnWidthLimits(this.mouseStartColumnIndex,this.mouseStartWidth+t,this.mouseStartWidth);this.tableModel.setColumnWidth(this.mouseStartColumnIndex,s),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clampToColumnWidthLimits(e,t,s){var c,h,d;const o=(d=(h=(c=this.tableModel).getColumnDefs)==null?void 0:h.call(c))==null?void 0:d[e];if(!o)return t;const i=this.getAvailableColumnWidth(),r=u=>{if(!(!u||!Number.isFinite(u.value))){if(u.unit==="px")return u.value;if(u.unit==="%"&&i>0)return Math.floor(u.value*i/100)}};let l=r(o.minWidth),a=r(o.maxWidth);return l!==void 0&&a!==void 0&&l>a||(s!==void 0&&s>=0&&(l!==void 0&&(l=Math.min(l,s)),a!==void 0&&(a=Math.max(a,s))),l!==void 0&&(t=Math.max(l,t)),a!==void 0&&(t=Math.min(a,t))),t}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}calcAutoColumnWidths(){if(!this.tableModel.getBodyModel())return console.warn("Body model is not available."),[];const e=Array.from({length:this.tableModel.getColumnCount()},(t,s)=>s);return this.measureDefaultColumnWidths(e,new Dt(this.hostElement))}measureDefaultColumnWidths(e,t){const s=e.map(()=>new Set),o=e.map(()=>0);return["header","body","footer"].forEach(i=>{const r=this.tableModel.getAreaModel(i),[l,a]=i==="body"?this.getMeasuredBodyRows():[0,((r==null?void 0:r.getRowCount())??0)-1];vu(r,l,a,e,s,o)}),s.map(i=>t.measureWidest(i))}getMeasuredBodyRows(){var i;const e=((i=this.tableModel.getBodyModel())==null?void 0:i.getRowCount())??0;if(e<=this.getColumnAutoWidthOptions().maxRows)return[0,e-1];const t=this.renderedBodyRows,s=Math.min(Math.max(0,t.first),e-1),o=t.last>=s?Math.min(t.last,e-1):Math.min(s+50,e-1);return[s,o]}getColumnAutoWidthOptions(){return si.create(this.tableOptions.columnAutoWidth)}calcAutoColumnWidth(e,t,s,o){let i=o;const r=()=>(i===void 0&&(i=this.measureDefaultColumnWidths([e],s)[0]),i),l=this.getColumnAutoWidthOptions().getWidth;let a;if(l){const c=this.tableModel.getColumnDef(e),h={columnIndex:e,columnDef:c,property:c==null?void 0:c.property,source:t,firstRenderedRow:this.renderedBodyRows.first,lastRenderedRow:this.renderedBodyRows.last,measureText:u=>s.measureText(u),getDefaultWidth:r},d=l(h);a=typeof d=="number"&&Number.isFinite(d)&&d>=0?Math.round(d):void 0}return this.clampToColumnWidthLimits(e,a??r())}autoResizeColumn(e){const t=this.resolveColumnIndex(e);if(t<0||!this.isColumnAutoResizable(t))return;const s=this.calcAutoColumnWidth(t,"api",new Dt(this.hostElement));return this.tableModel.setColumnWidth(t,s),this.recalcWrappers(),this.stateService.markDirty("columns"),s}autoResizeColumnByUser(e,t){if(!this.tableOptions.columnsResizable||!this.getColumnAutoWidthOptions().doubleClick||e<0||e>=this.tableModel.getColumnCount()||!this.isColumnAutoResizable(e))return!1;const s=this.tableModel.getColumnWidth(e),o=this.tableModel.getColumnDef(e),i={kind:"resize",source:"dblclick",columnIndex:e,currentIndex:e,columnDef:o,startWidth:s,moves:[],started:!0,cancelled:!1},r=this.calcAutoColumnWidth(e,"dblclick",new Dt(this.hostElement)),l=this.columnDrag;this.columnDrag=i;try{if(this.emitColumnDragEvent(i,"start",t),i.cancelled||this.isDestroyed())return!0;this.tableModel.setColumnWidth(e,r),this.recalcWrappers(),this.stateService.markDirty("columns"),this.emitColumnDragEvent(i,"end",t)}finally{this.columnDrag===i&&(this.columnDrag=l)}return!0}isColumnAutoResizable(e){var s;const t=this.tableModel.getColumnDef(e);return this.isColumnResizable(e)&&!G(t)&&((s=t==null?void 0:t.isVisible)==null?void 0:s.call(t))!==!1}resolveColumnIndex(e){var o,i;const t=this.tableModel.getColumnCount();if(typeof e=="number")return Number.isInteger(e)&&e>=0&&e<t?e:-1;const s=((i=(o=this.tableModel).getColumnDefs)==null?void 0:i.call(o))??[];return typeof e=="string"?s.findIndex(r=>r.property===e):s.indexOf(e)}setColumnWidth(e,t){this.tableModel.setColumnWidth(e,t),this.stateService.markDirty("columns")}setColumnVisible(e,t){var s,o;return(o=(s=this.tableModel).setColumnVisible)!=null&&o.call(s,e,t)?(this.recalcWrappers(),this.stateService.markDirty("columns"),!0):!1}setHeaderVisible(e){this.setAreaVisible("header",e)}setFooterVisible(e){this.setAreaVisible("footer",e)}setAreaVisible(e,t){const s=this.tableModel,o=e==="header"?s.setHeaderVisible:s.setFooterVisible;if(!o){console.warn(`set${e==="header"?"Header":"Footer"}Visible() needs a table model with this method (e.g. TableModel), this one has none:`,s);return}o.call(s,t),e==="header"&&!t&&(this.headerFocus=void 0),this.recalcWrappers()}autoResizeColumns(e=!0){const t=this.tableModel.getColumnCount();if(!this.tableModel.getBodyModel()){console.warn("Body model is not available.");return}const s=new Dt(this.hostElement),o=Array.from({length:t},(r,l)=>l),i=this.measureDefaultColumnWidths(o,s);for(let r=0;r<t;r++)this.isColumnAutoResizable(r)&&this.tableModel.setColumnWidth(r,this.calcAutoColumnWidth(r,"api",s,i[r]));e&&this.recalcWrappers(),this.stateService.markDirty("columns")}recalcWrappers(){this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}appendRows(e,t={}){const s=this.tableModel.getBodyModel();if(!s.appendRows||this.tableSheet||this.isRowGroupingOrTree())return console.warn("appendRows() works with an AreaModelObjectArray body (TableFactory.createTableModel({ rows })) without cell formulas – use rowsAppended() for an own area model. Nothing changed."),!1;const o=s.appendRows(e,{filter:this.getEffectiveFilterFunction(),compare:this.getActiveSortComparator(),maxRows:t.maxRows});return o?this.afterRowsAppended(o,t.follow??"auto"):(console.warn("appendRows(): the body model did not append the rows."),!1)}notifyRowsAppended(e,t={}){const s=Math.max(0,this.tableModel.getBodyModel().getRowCount()),o=Math.max(0,Math.min(Math.floor(e)||0,s)),i=this.renderedBodyRows.count,r=Math.max(0,Math.min(Math.floor(t.removedAtStart??0)||0,i)),l=new Int32Array(r);for(let c=0;c<r;c++)l[c]=c;const a=new Int32Array(o);for(let c=0;c<o;c++)a[c]=s-o+c;return this.afterRowsAppended({added:o,shown:o,removed:r,removedPositions:l,insertedPositions:a},t.follow??"auto")}getActiveSortComparator(){var s,o;if(this.lastSortCompareFn)return this.lastSortCompareFn;const e=[];(s=this.tableModel.getColumnDefs())==null||s.forEach((i,r)=>{(i.sortState==="asc"||i.sortState==="desc")&&e.push(new Is(r,i.sortState))});const t=this.tableModel.getBodyModel();return e.length?(o=t.createSortComparator)==null?void 0:o.call(t,e):void 0}afterRowsAppended(e,t){var m,b,w,y,C,S;const s=new nc(e.removedPositions,e.insertedPositions),o=this.renderedBodyRows,i=this.selectionModel(),r=((m=i==null?void 0:i.adjustForRowChanges)==null?void 0:m.call(i,s))??!1;(w=(b=this.focusModel())==null?void 0:b.adjustForRowChanges)==null||w.call(b,s),this.selectionService.adjustForRowChanges(s),this.mouseHandler.adjustForRowChanges(s),this.shiftEditorRow(s);const l=this.tableModel.getBodyModel().getRowCount(),a=this.focusModel();a&&l>0&&a.getFocus()[0]>=l&&a.setFocus(l-1,a.getFocus()[1]),e.removed&&((y=this.batchEditService)==null||y.pruneOrphans());const c=this.colAndRowspanModels.body;c&&!c.updateForInsertedRows(e.insertedPositions)&&!s.isEmpty()&&c.init(),this.invalidateAggregates();const h=this.mouseHandler.isButtonDown()||!!((C=this.rowDragService)!=null&&C.isDragging())||!!((S=this.fillHandleService)!=null&&S.isFilling()),d=this.followHeldAt,u=o.atEnd||d!==void 0&&Math.abs(this.contentScrollTop-d)<1,f=t===!0||t==="auto"&&u&&!h;let p;if(f)p=Number.MAX_SAFE_INTEGER;else if(o.count>0){const x=s.mapIndex(o.first)>=0,R=Math.min(s.mapIndexOrNext(o.first),Math.max(0,l-1));p=l>0?this.getBodyRowTop(R)+(x?o.offset:0):0}else p=0;return!f&&s.getRemovedCount()===0&&o.count>0&&o.last<o.count-1&&!s.touchesUpTo(o.last)&&this.canKeepDrawnRows()&&this.updateRowCountWithoutRender(p)||this.repaintHard({py:p}),this.followHeldAt=t==="auto"&&h&&u?this.contentScrollTop:void 0,r&&i&&this.onSelectionChanged(i),{added:e.added,shown:e.shown,removed:e.removed,following:f}}canKeepDrawnRows(){var s;if(this.getFirstDataColumnIndex()>0||this.masterDetailService||this.tableModel.isRowCheckboxVisible()||this.tableOptions.showCheckboxWihoutExtraColumn)return!1;const e=this.tableModel.getAreaModel("footer");if(e.getRowCount()>0&&e.invalidateDerivedValues)return!1;const t=this.tableModel.getBodyModel();return!((s=t.hasDerivedColumns)!=null&&s.call(t))}reSort(){this.reapplySorting(),this.invalidateAggregates(),this.repaint()}sort(e){var t;this.tableModel.sort(e),this.invalidateAggregates(),this.lastSortCompareFn=e,(t=this.tableModel.getColumnDefs())==null||t.forEach(s=>s.sortState=""),this.repaint(),this.stateService.sortedByColumn(void 0)}applySortItems(e){const t=this.tableModel.getColumnDefs();t==null||t.forEach(s=>s.sortState=""),e.forEach(s=>{const o=t==null?void 0:t[s.columnIndex];o&&(o.sortState=s.sortState)}),e.length&&(this.lastSortCompareFn=void 0,this.tableModel.doSort(e),this.invalidateAggregates())}reapplySorting(){var t;if(this.lastSortCompareFn){this.tableModel.sort(this.lastSortCompareFn);return}const e=[];(t=this.tableModel.getColumnDefs())==null||t.forEach((s,o)=>{s.sortState&&e.push(new Is(o,s.sortState))}),e.length&&this.tableModel.doSort(e)}ensureRowIsVisible(e){if(this.hasBodyRowExtras()){const i=this.getBodyRowTop(e),r=i+this.tableModel.getRowHeight("body",e),l=this.contentScrollTop,a=this.areaBodyCenterGeo.height;return i<l?(this.scrollToPixel(this.getViewportScrollLeft(),i),!0):r>l+a?(this.scrollToPixel(this.getViewportScrollLeft(),r-a),!0):!1}const t=this.getFirstFullVisibleRowIndex(),s=this.getLastFullVisibleRowIndex(),o=this.getDisplayedRowCount();return e<t?(this.scrollToIndex(-1,e),!0):e>s?(this.scrollToIndex(-1,e-o+1),!0):!1}ensureColumnIsVisible(e){const t=this.tableModel.getFixedLeftColumnCount(),s=this.tableModel.getColumnCount()-this.tableModel.getFixedRightColumnCount()-1;if(!(e>=t&&e<=s))return!1;const o=this.tableModel.getColumnWidth(e),i=this.scrollViewport,r=this.areaBodyCenterGeo.width,l=this.tableModel.getContentWidthInPixel()-r,a=i.scrollWidth-i.clientWidth;if(o<=0||l<=0||a<=0)return!1;let c=0;for(let f=t;f<e;f++)c+=this.tableModel.getColumnWidth(f);const h=Math.min(1,Math.max(0,this.getViewportScrollLeft()/a))*l;let d;if(c<h-.5)d=c;else if(c+o>h+r+.5)d=o>r?c:c+o-r;else return!1;const u=Math.min(1,Math.max(0,d/l))*a;return this.setViewportScrollLeft(d===c?Math.floor(u):Math.ceil(u)),this.adjustAfterScrolling(),!0}};Ie.actionsBlockedWhileLoading=["START_EDITING","TOGGLE_SELECTION","ACTIVATE_CELL","MOVE_ROW_UP","MOVE_ROW_DOWN","FILL_DOWN","FILL_RIGHT","CLEAR_CELLS","CLEAR_AND_EDIT","CUT_2_CLIPBOARD","PASTE_FROM_CLIPBOARD","UNDO","REDO"],Ie.filterAnnouncementDelayInMs=400,Ie.tileActions={NAVIGATE_LEFT:"previous",NAVIGATE_RIGHT:"next",NAVIGATE_UP:"up",NAVIGATE_DOWN:"down",NAVIGATE_ROW_START:"first",NAVIGATE_FIRST_CELL:"first",NAVIGATE_ROW_END:"last",NAVIGATE_LAST_CELL:"last",NAVIGATE_PAGE_UP:"pageUp",NAVIGATE_PAGE_DOWN:"pageDown"};let Ji=Ie;class _u extends Fs{constructor(e){super(),this.onCheckboxChangedCallback=e,super.onCheckboxChanged=t=>{this.onCheckboxChangedCallback(t)}}}const Oo=class Oo{};Oo.themes=["light","combat","paper","blackboard"],Oo.vars={light:`html[data-theme="light"] {
71
+ `).replace(/\n$/,"");class Wi{constructor(e,t,s){this.tableScope=e,this.options=t;const o=e.listenerAbortController.signal;if(s){const i=e.hostElement.ownerDocument;i.addEventListener("copy",r=>this.onClipboardEvent(r,"copy"),{signal:o}),i.addEventListener("cut",r=>this.onClipboardEvent(r,"cut"),{signal:o}),i.addEventListener("paste",r=>this.onClipboardEvent(r,"paste"),{signal:o})}e.hostElement.addEventListener("keydown",i=>{var r;i.key==="Escape"&&((r=this.memory)!=null&&r.cut)&&i.target===e.hostElement&&!e.isEditing()&&this.cancelCut()},{signal:o}),e.subscribe({onModelChanged:i=>{var r;i.source!=="cut"&&((r=this.memory)!=null&&r.cut)&&this.cancelCut()}})}isCutMarked(){var e;return!!((e=this.memory)!=null&&e.cut)}arm(e){const t=this.tableScope;if(t.isEditing()||t.getHeaderFocus()||!t.getActiveBodyCell()||e!=="paste"&&!this.hasBuiltInCopyService()||e!=="copy"&&t.isOverlayBlocking())return!1;const s=this.ensureProxy();return s.value=" ",s.select(),s.focus({preventScroll:!0}),this.armedKind=e,clearTimeout(this.restoreTimer),this.restoreTimer=setTimeout(()=>this.restoreFocus(),0),!0}getSelectionAsText(){var e;return((e=this.buildCopy(!1))==null?void 0:e.text)??""}async writeSelection(e){const t=this.buildCopy(e);if(!t)return;const s=typeof navigator<"u"?navigator.clipboard:void 0,o=globalThis.ClipboardItem;if(s!=null&&s.write&&o&&t.html)await s.write([new o({"text/plain":new Blob([t.text],{type:"text/plain"}),"text/html":new Blob([t.html],{type:"text/html"})})]);else if(s!=null&&s.writeText)await s.writeText(t.text);else return;this.remember(t,e)}async runWithoutKey(e){var t,s;try{if(e==="paste"){const o=await((s=(t=navigator.clipboard)==null?void 0:t.readText)==null?void 0:s.call(t));o&&this.paste(o)}else await this.writeSelection(e==="cut")}catch(o){console.warn("GuiExpert Table – clipboard:",o)}}paste(e,t,s){var K,Y;const o=this.tableScope,i=e?Ya(e):t?Ja(t):[];if(!i.length||!i[0].length)return[];const r=this.memory&&e&&Wn(e)===this.memory.text?this.memory:void 0,l=r==null?void 0:r.cut,a=o.tableModel.getBodyModel(),c=a.getRowCount(),h=this.getPasteColumns(),d=this.getPasteAnchor(h,s);if(!d||!h.length)return[];const[u,f]=d,p=l?void 0:d[2],g=i[0].length,m=h.indexOf(f),b=h[Math.min(h.length-1,m+g-1)],w=o.isBatchEditActive();let y=r&&!w?r.values:r?i.map((U,$)=>U.map((me,te)=>{var le;return((le=r.values[$])==null?void 0:le[te])instanceof ks?r.values[$][te]:me})):i,C=!!r&&!w;const S=this.options.processPaste;if(S){const U={text:e,html:t,matrix:i,target:new M(u,f,u+i.length-1,b),internal:!!r},$=S(U);if($===!1)return[];Array.isArray($)&&(y=$,C=!1)}const x=this.options.maxPasteCells,R=Vr(y.length,y.reduce((U,$)=>Math.max(U,$.length),0),p);if(R.rows*R.columns>x)return o.announce(o.getSheetTexts().pasteTooLarge(x)),[];const I=this.options.pasteAddsRows&&!!this.options.createRow&&!w&&this.canAppendRows(),A=((Y=(K=o.tableModel).getColumnDefs)==null?void 0:Y.call(K))??[],T=Za({matrix:y,anchorRow:u,anchorColumn:f,shownColumns:h,rowCount:c,selection:p,canAddRows:I,isWritable:(U,$)=>a.isEditable(U,$)&&!G(A[$])});if(T.addRows&&this.appendRows(T.addRows),r)for(const U of T.cells)U.value=o.resolvePastedValue(U.value,U.rowIndex,U.columnIndex,!!l);const F=[];let P="paste";if(l){P="cut";const U=new Map(h.map((te,le)=>[te,le])),$=[],me=new Set;for(const{rowIndex:te,columnIndex:le,value:Te}of T.cells){const H=C?Te:this.convertPastedText(Te,te,le);o.checkPastedValue(te,le,H,C)||(F.push({rowIndex:te,column:le,value:H}),$.push([te-u,U.get(le)-m]),me.add(`${te}:${le}`))}for(const te of this.cutSourceChanges(l,$,me))F.push(te)}else for(const{rowIndex:U,columnIndex:$,value:me}of T.cells)F.push({rowIndex:U,column:$,value:C?me:this.convertPastedText(me,U,$)});const O=F.length?o.writePastedCells(F,P,C):[];l&&(this.memory=void 0,this.removeCutFrame()),T.addRows&&o.repaintHard();let N=O.length;if(l){const U=new Set(T.cells.map($=>`${$.rowIndex}:${$.columnIndex}`));N=O.filter($=>U.has(`${$.rowIndex}:${$.columnIndex}`)).length}return o.selectBodyRange(T.range),o.announce(o.getSheetTexts().cellsPasted(N,T.skipped+T.clipped+Math.max(0,T.cells.length-N))),O}cancelCut(){var e;(e=this.memory)!=null&&e.cut&&(this.memory={...this.memory,cut:void 0}),this.removeCutFrame()}update(){var u;const e=(u=this.memory)==null?void 0:u.cut,t=this.cutFrame;if(!e||!t)return;const s=this.tableScope,o=s.tableModel.getBodyModel(),{range:i}=e;if(i.r2>=o.getRowCount()||this.rowObjectAt(i.r1)!==e.rows[0]||this.rowObjectAt(i.r2)!==e.rows[e.rows.length-1]){this.removeCutFrame();return}const r=s.getBodyCellRectInHost(i.r1,i.c1),l=s.getBodyCellRectInHost(i.r2,i.c2),a=Math.max(r.top,r.clipTop),c=Math.min(l.top+l.height,l.clipBottom),h=Math.max(r.left,r.clipLeft),d=Math.min(l.left+l.width,l.clipRight);s.getDomService().applyStyle(t,{display:c>a&&d>h?"block":"none",left:`${h}px`,top:`${a}px`,width:`${Math.max(0,d-h)}px`,height:`${Math.max(0,c-a)}px`})}destroy(){var e;clearTimeout(this.restoreTimer),(e=this.proxy)==null||e.remove(),this.proxy=void 0,this.removeCutFrame(),this.memory=void 0}onClipboardEvent(e,t){var a,c;const s=this.tableScope,o=s.hostElement,i=typeof e.composedPath=="function"?e.composedPath()[0]:e.target,r=!!this.proxy&&i===this.proxy;if(!r&&(Gn(o)!==o||s.isEditing()||(a=s.isEventInDetail)!=null&&a.call(s,e)||(c=s.isEventInFilterUI)!=null&&c.call(s,e))||!r&&(s.getHeaderFocus()||!s.getActiveBodyCell())||t!=="paste"&&!this.hasBuiltInCopyService())return;const l=e.clipboardData;try{if(!l||(e.preventDefault(),t!=="copy"&&s.isOverlayBlocking()))return;if(t==="paste")this.paste(l.getData("text/plain"),l.getData("text/html")||void 0);else{const h=this.buildCopy(t==="cut");h&&(l.setData("text/plain",h.text),h.html&&l.setData("text/html",h.html),this.remember(h,t==="cut"))}}finally{(r||this.armedKind)&&this.restoreFocus()}}restoreFocus(){clearTimeout(this.restoreTimer),this.armedKind=void 0;const e=this.proxy;e&&(e.value="",Gn(e)===e&&this.tableScope.hostElement.focus({preventScroll:!0}))}ensureProxy(){if(!this.proxy||!this.proxy.isConnected){const e=this.tableScope.getDomService().domService,t=e.createElement("textarea");e.addClass(t,"ge-table-clipboard-proxy"),e.setAttribute(t,"aria-hidden","true"),e.setAttribute(t,"tabindex","-1"),e.setAttribute(t,"autocomplete","off"),e.appendChild(this.tableScope.hostElement,t),this.proxy=t}return this.proxy}remember(e,t){var r;const s=this.tableScope;this.cancelCut(),this.memory=e.processed?void 0:{text:Wn(e.text),values:e.values,cut:t?{range:e.range,columns:e.columns,rows:this.rowObjectsOf(e.range)}:void 0},(r=this.memory)!=null&&r.cut&&this.showCutFrame();const o=s.getSheetTexts(),i=t?o.cutMarked(e.cellCount):s.ariaTexts.copied(e.cellCount);s.announce(e.lastRangeOnly?`${i}. ${o.copiedLastRangeOnly()}`:i)}buildCopy(e){var S;const t=this.tableScope,s=t.tableModel,o=s.getBodyModel(),i=o.getRowCount(),r=s.getColumnCount();if(!i||!r)return;const l=t.selectionModel();let a,c=!1;if(l!=null&&l.isAllSelected())a=new M(0,0,i-1,r-1);else if(l!=null&&l.hasSelection()&&l.getRanges().length){const x=l.getRanges(),R=x[x.length-1];c=x.length>1,a=new M(Math.max(0,R.r1),Math.max(0,R.c1),Math.min(i-1,R.r2),Math.min(r-1,R.c2))}else{const x=t.getActiveBodyCell();a=x?M.singleCell(x[0],x[1]):void 0}if(!a||a.r2<a.r1||a.c2<a.c1)return;const h=[];for(let x=a.c1;x<=a.c2;x++){const R=s.getColumnDef(x);((S=R==null?void 0:R.isVisible)==null?void 0:S.call(R))===!1||s.getColumnWidth(x)<=0||G(R)&&!R.options.exported||h.push(x)}const d=(a.r2-a.r1+1)*h.length;if(!h.length)return;if(d>He.maxCopyCells){t.announce(t.getSheetTexts().copyTooLarge(He.maxCopyCells));return}const u=this.options.copyValue==="raw",f=!!(l!=null&&l.hasSelection())&&!l.isAllSelected(),p=[],g=[],m=[];if(this.options.copyHeaders&&!e){const x=h.map(R=>t.getColumnAriaLabel(R));p.push(x),g.push(x),m.push(x.map(R=>({text:R})))}for(let x=a.r1;x<=a.r2;x++){const R=[],I=[],A=[];for(const T of h){const F=s.getColumnDef(T);let P,O;if(f&&!l.isSelected(x,T))P="",O="";else if(G(F))P=F.getRowNumberText(x,o),O=P;else{O=t.getCopyValue(x,T);const K=O instanceof ks?O.value:O;P=u||K===null||K===void 0||K instanceof Date?pu(K):o.getTextValueAt(x,T)}R.push(P),I.push(O);const N=O instanceof ks?O.value:O;A.push(typeof N=="number"?{text:P,num:N}:{text:P})}p.push(R),g.push(I),m.push(A)}let b=p,w=!1;if(this.options.processCopy){const x=this.options.processCopy({ranges:[a],matrix:p,cut:e});Array.isArray(x)&&(b=x,w=!0)}const y=Xa(b),C=this.options.html?qa(w?b.map(x=>x.map(R=>({text:R}))):m):void 0;return{text:y,html:C,values:g,range:a,columns:h,cellCount:d,lastRangeOnly:c,processed:w}}getPasteColumns(){var o;const e=this.tableScope.tableModel,t=[],s=e.getColumnCount();for(let i=0;i<s;i++){const r=e.getColumnDef(i);e.getColumnWidth(i)>0&&((o=r==null?void 0:r.isVisible)==null?void 0:o.call(r))!==!1&&!G(r)&&t.push(i)}return t}getPasteAnchor(e,t){const s=this.tableScope,o=s.tableModel.getBodyModel().getRowCount(),i=h=>e.find(d=>d>=h);if(t){const h=i(t[1]);return h===void 0||t[0]<0||t[0]>=o?void 0:[t[0],h,void 0]}const r=s.selectionModel();let l;if(r!=null&&r.isAllSelected())l=new M(0,0,o-1,Number.MAX_SAFE_INTEGER);else if(r!=null&&r.hasSelection()&&r.getRanges().length){const h=r.getRanges();l=h[h.length-1]}if(l){const h=Math.max(0,l.r1),d=Math.min(o-1,l.r2),u=i(Math.max(0,l.c1));if(u!==void 0&&d>=h){const f=e.filter(p=>p>=l.c1&&p<=l.c2).length;return[h,u,{rows:d-h+1,columns:f}]}}const a=s.getActiveBodyCell();if(!a)return;const c=i(a[1]);return c===void 0?void 0:[a[0],c,void 0]}convertPastedText(e,t,s){if(typeof e!="string")return e;const o=this.tableScope,i=o.tableModel.getColumnDef(s);if(i!=null&&i.editInputPipe)return e;const r=t<o.tableModel.getBodyModel().getRowCount()?o.getTypedCellValue(t,s):void 0,l=e.trim();if(typeof r=="number"||(i==null?void 0:i.editor)==="number")return l!==""&&/^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(l)?Number(l):e;if(typeof r=="boolean"){const a=l.toUpperCase();return a==="TRUE"?!0:a==="FALSE"?!1:e}if(r instanceof Date){const a=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/.exec(l);return a?a[4]===void 0?new Date(+a[1],+a[2]-1,+a[3],r.getHours(),r.getMinutes(),r.getSeconds()):new Date(+a[1],+a[2]-1,+a[3],+a[4],+a[5],+(a[6]??0)):e}return e}cutSourceChanges(e,t,s){var a;const o=this.tableScope,i=o.tableModel.getBodyModel(),r=this.rowIndexLookup(e),l=[];for(const[c,h]of t){if(c<0||h<0||c>=e.rows.length||h>=e.columns.length)continue;const d=r(c);if(d<0)continue;const u=e.columns[h],f=o.tableModel.getColumnDef(u);if(s.has(`${d}:${u}`)||G(f)||!i.isEditable(d,u))continue;const p=(f==null?void 0:f.emptyValue)!==void 0?f.emptyValue:((a=o.getEditingOptions())==null?void 0:a.emptyValue)??"";l.push({rowIndex:d,column:u,value:p})}return l}rowIndexLookup(e){const t=this.tableScope.tableModel.getBodyModel().getRowCount(),s=e.rows.every(r=>r!==null&&typeof r=="object"),o=e.rows.every((r,l)=>this.rowObjectAt(e.range.r1+l)===r);if(!s||o)return r=>e.range.r1+r<t?e.range.r1+r:-1;const i=new Map;for(let r=0;r<t;r++)i.set(this.rowObjectAt(r),r);return r=>i.get(e.rows[r])??-1}hasBuiltInCopyService(){const e=this.tableScope.copyService;return!!e&&Object.getPrototypeOf(e)===He.prototype}rowObjectAt(e){const t=this.tableScope.tableModel.getBodyModel().getRowByIndex(e);return J(t)?t.data:t}rowObjectsOf(e){const t=[];for(let s=e.r1;s<=e.r2;s++)t.push(this.rowObjectAt(s));return t}canAppendRows(){const e=this.tableScope.tableModel.getBodyModel();return typeof e.getAllRows=="function"&&typeof e.getFilteredRows=="function"&&!this.tableScope.isRowGroupingOrTree()}appendRows(e){const t=this.tableScope.tableModel.getBodyModel(),s=t.getAllRows(),o=t.getFilteredRows(),i=o.length;for(let r=0;r<e;r++){const l=this.options.createRow(i+r);s.push(l),o!==s&&o.push(l)}this.tableScope.rowsAppended()}showCutFrame(){if(!this.cutFrame){const e=this.tableScope.getDomService();this.cutFrame=e.setAriaHidden(e.createDivWithClass("ge-table-cut-range",this.tableScope.hostElement))}this.update()}removeCutFrame(){var e;(e=this.cutFrame)==null||e.remove(),this.cutFrame=void 0}}function Gn(n){return n.getRootNode().activeElement??null}function pu(n){if(n==null)return"";if(n instanceof Date){if(Number.isNaN(n.getTime()))return"";const e=o=>String(o).padStart(2,"0"),t=`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())}`,s=n.getHours()||n.getMinutes()||n.getSeconds()?`T${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}`:"";return t+s}return typeof n=="boolean"?n?"TRUE":"FALSE":typeof n=="object"?"":String(n)}function Qa(n){return n?{"meta+z":"UNDO","meta+shift+z":"REDO"}:{"ctrl+z":"UNDO","ctrl+y":"REDO","ctrl+shift+z":"REDO"}}class ti{constructor(){this.maxSteps=100,this.maxCells=1e6,this.onConflict="skip",this.recordApiChanges=!1}static create(e){if(!e)return;const t=new ti;if(typeof e=="object")for(const[s,o]of Object.entries(e))o!==void 0&&(t[s]=o);return t}}class ec{constructor(e,t){this.maxSteps=e,this.maxCells=t,this.undoSteps=[],this.redoSteps=[],this.cells=0}push(e){if(this.clearRedo(),e.cellCount>this.maxCells||this.maxSteps<1)return this.clear(),!1;for(this.undoSteps.push(e),this.cells+=e.cellCount;this.undoSteps.length>this.maxSteps||this.cells>this.maxCells;)this.cells-=this.undoSteps.shift().cellCount;return!0}undo(){const e=this.undoSteps.pop();return e&&this.redoSteps.push(e),e}redo(){const e=this.redoSteps.pop();return e&&this.undoSteps.push(e),e}peekUndo(){return this.undoSteps[this.undoSteps.length-1]}peekRedo(){return this.redoSteps[this.redoSteps.length-1]}canUndo(){return this.undoSteps.length>0}canRedo(){return this.redoSteps.length>0}size(){return this.undoSteps.length}cellCount(){return this.cells}clear(){this.undoSteps.length=0,this.redoSteps.length=0,this.cells=0}clearRedo(){for(const e of this.redoSteps)this.cells-=e.cellCount;this.redoSteps.length=0}}function tc(n){var t,s;const e=n;return ee(n)?e.rows:((t=e.getAllRows)==null?void 0:t.call(e))??((s=e.getSourceRows)==null?void 0:s.call(e))??e.arr}function gu(n){if(ee(n)){const t=new Set,s=o=>o==null?void 0:o.forEach(i=>{const r=i;t.add(r.data??r),s(r.children)});return s(n.rows),t}const e=tc(n);return e?new Set(e):null}class Gi{constructor(e,t,s){this.label=e,this.source=t,this.entries=s.map(o=>({row:o.row,rowIndex:o.rowIndex,columnIndex:o.columnIndex,property:o.property,oldValue:o.oldValue,newValue:o.newValue}))}get cellCount(){return this.entries.length}append(e){for(const t of e)this.entries.push({row:t.row,rowIndex:t.rowIndex,columnIndex:t.columnIndex,property:t.property,oldValue:t.oldValue,newValue:t.newValue})}undo(e){return this.apply(e,"undo")}redo(e){return this.apply(e,"redo")}apply(e,t){var y;const s=e.tableModel,o=s.getBodyModel(),i=o.getRowCount(),r=((y=e.getUndoOptions())==null?void 0:y.onConflict)==="overwrite",l=C=>{const S=o.getRowByIndex(C);return J(S)?S.data:S};let a,c;const h=C=>{if(C.row===void 0||C.row===null||typeof C.row!="object")return C.rowIndex>=0&&C.rowIndex<i?C.rowIndex:-1;if(C.rowIndex>=0&&C.rowIndex<i&&l(C.rowIndex)===C.row)return C.rowIndex;if(!a){a=new Map;for(let S=0;S<i;S++)a.set(l(S),S)}return a.get(C.row)??-1},d=C=>(c===void 0&&(c=gu(o)),!!c&&c.has(C)),u=C=>{var S;return!!C&&(bl(C)?!!o.defaultEditable:!!((S=C.editable)!=null&&S.call(C)))},f=[],p=[];let g=0;const m=t==="undo"?[...this.entries].reverse():this.entries;for(const C of m){const S=t==="undo"?C.newValue:C.oldValue,x=t==="undo"?C.oldValue:C.newValue,R=mu(e,C);if(R<0){g++;continue}const I=h(C);if(I>=0){if(!o.isEditable(I,R)||!r&&!as(e.getCellInput(I,R),S)){g++;continue}f.push({rowIndex:I,columnIndex:R,value:x});continue}const A=s.getColumnDef(R),T=d(C.row)?bu(C.row,A,R,S):void 0;if(!d(C.row)||!u(A)||!r&&!as(T,S)||!ga(C.row,A,R,x)){g++;continue}p.push({row:C.row,rowIndex:-1,columnIndex:R,property:C.property,oldValue:T,newValue:x})}const b=e.writeUndoCells(f,p,t);let w;for(const C of b)C.rowIndex<0||(w?(w.r1=Math.min(w.r1,C.rowIndex),w.r2=Math.max(w.r2,C.rowIndex),w.c1=Math.min(w.c1,C.columnIndex),w.c2=Math.max(w.c2,C.columnIndex)):w=new M(C.rowIndex,C.columnIndex,C.rowIndex,C.columnIndex));return{applied:b.length,skipped:g+f.length+p.length-b.length,range:w}}}function mu(n,e){const t=n.tableModel,s=i=>{var r;return((r=t.getColumnDef(i))==null?void 0:r.property)||`#${i}`};if(e.columnIndex>=0&&e.columnIndex<t.getColumnCount()&&s(e.columnIndex)===e.property)return e.columnIndex;const o=t.getColumnCount();for(let i=0;i<o;i++)if(s(i)===e.property)return i;return-1}function bu(n,e,t,s){if(Array.isArray(n))return n[t];if(!(e!=null&&e.property)||n===null||typeof n!="object")return;if(e.valueGetter)return s;let o=n;for(const i of e.property.split("."))o=o==null?void 0:o[i];return o}class sc{constructor(e,t,s){this.label=e,this.source=t,this.cells=s}get cellCount(){return this.cells.length}undo(e){return this.apply(e,"undo")}redo(e){return this.apply(e,"redo")}apply(e,t){var c;const s=e.batchEditService;if(!s)return{applied:0,skipped:this.cells.length};const o=((c=e.getUndoOptions())==null?void 0:c.onConflict)==="overwrite",i=[];let r=0;for(const h of this.cells){const d=t==="undo"?h.after:h.before,u=t==="undo"?h.before:h.after,f=s.getPendingEntry(h.rowKey,h.property);if(!(!f&&!d?!0:!!f&&!!d&&as(f.newValue,d.newValue))&&!o){r++;continue}i.push({rowKey:h.rowKey,property:h.property,entry:u})}const l=s.restorePending(i,!1);let a;for(const h of l)h.rowIndex<0||h.columnIndex<0||(a=a?new M(Math.min(a.r1,h.rowIndex),Math.min(a.c1,h.columnIndex),Math.max(a.r2,h.rowIndex),Math.max(a.c2,h.columnIndex)):new M(h.rowIndex,h.columnIndex,h.rowIndex,h.columnIndex));return e.repaint(),{applied:l.length,skipped:r,range:a}}}class oc{constructor(e,t,s,o,i){this.canUndo=e,this.canRedo=t,this.undoLabel=s,this.redoLabel=o,this.size=i}}const Un={edit:"Edit",fill:"Fill",paste:"Paste",cut:"Cut",clear:"Clear",api:"Change"};class wu{constructor(e,t){this.label=e,this.steps=t,this.source=t[0].source}get cellCount(){return this.steps.reduce((e,t)=>e+t.cellCount,0)}undo(e){return Kn([...this.steps].reverse().map(t=>t.undo(e)))}redo(e){return Kn(this.steps.map(t=>t.redo(e)))}}function Kn(n){let e;for(const t of n)t.range&&(e=e?new M(Math.min(e.r1,t.range.r1),Math.min(e.c1,t.range.c1),Math.max(e.r2,t.range.r2),Math.max(e.c2,t.range.c2)):t.range);return{applied:n.reduce((t,s)=>t+s.applied,0),skipped:n.reduce((t,s)=>t+s.skipped,0),range:e}}class ic{constructor(e,t){this.tableScope=e,this.options=t,this.running=!1,this.foldDepth=0,this.stack=new ec(t.maxSteps,t.maxCells)}addStep(e){this.running||this.add(e)}record(e,t,s){if(this.running||t==="undo"||t==="redo"||!e.length||s===!1)return;if(this.folding instanceof Gi&&t!=="commit"){this.folding.append(e),this.lastRecorded=this.folding;return}if(t==="commit"){this.clear();return}if(t==="api"&&!(s??this.options.recordApiChanges))return;const o=new Gi(Un[t]??"Change",t,e);this.lastRecorded=o,this.add(o)}beginFold(){this.foldDepth++===0&&(this.folding=this.lastRecorded)}endFold(){--this.foldDepth<=0&&(this.foldDepth=0,this.folding=void 0,this.lastRecorded=void 0)}recordPending(e,t,s){this.running||!e.length||s===!1||t==="api"&&!(s??this.options.recordApiChanges)||this.add(new sc(Un[t]??"Change",t,e))}batch(e,t){this.group?this.group.depth++:this.group={label:e,steps:[],depth:1};let s=!0;try{const o=t();return s=!1,o}finally{const o=this.group;--o.depth===0&&(this.group=void 0,o.steps.length&&!s&&this.add(o.steps.length===1&&o.steps[0].label===o.label?o.steps[0]:new wu(o.label,o.steps)))}}undo(){return this.run("undo")}redo(){return this.run("redo")}canUndo(){return this.checkRows(!1),this.stack.canUndo()}canRedo(){return this.checkRows(!1),this.stack.canRedo()}getState(){var e,t;return this.checkRows(!1),new oc(this.stack.canUndo(),this.stack.canRedo(),(e=this.stack.peekUndo())==null?void 0:e.label,(t=this.stack.peekRedo())==null?void 0:t.label,this.stack.size())}clear(e=!1){const t=this.stack.canUndo()||this.stack.canRedo();this.stack.clear(),this.rowsRef=void 0,this.lastRecorded=void 0,this.group&&(this.group.steps.length=0),t&&!e&&this.fire()}add(e){if(this.group){this.group.steps.push(e);return}if(this.checkRows(),this.rowsRef??(this.rowsRef=this.currentRows()),!this.stack.push(e)){const t=this.tableScope;t.announce(t.getUndoTexts().undoHistoryCleared(this.options.maxCells))}this.fire()}run(e){const t=this.tableScope;if(t.isEditing()||this.group)return!1;this.checkRows();const s=e==="undo"?this.stack.undo():this.stack.redo(),o=t.getUndoTexts();if(!s)return t.announce(e==="undo"?o.nothingToUndo():o.nothingToRedo()),!1;let i;this.running=!0;try{i=e==="undo"?s.undo(t):s.redo(t)}finally{this.running=!1}i.range&&(t.selectBodyRange(i.range),t.ensureColumnIsVisible(i.range.c1),t.ensureRowIsVisible(i.range.r1));const r=e==="undo"?o.undone(s.label,i.applied):o.redone(s.label,i.applied);return t.announce(i.skipped?`${r}. ${o.undoSkipped(i.skipped)}`:r),this.fire(),!0}checkRows(e=!0){this.rowsRef&&this.currentRows()!==this.rowsRef&&this.clear(!e)}currentRows(){return tc(this.tableScope.tableModel.getBodyModel())}fire(){var e,t;(t=(e=this.tableScope.getEventListener()).onUndoStackChanged)==null||t.call(e,this.getState())}}function rc(n,e,t,s,o,i,r,l=()=>!0){const a=(d,u)=>{const f=d+i;let p=u+r;for(;r!==0&&p>=0&&p<t&&!l(p);)p+=r;return f>=0&&f<e&&p>=0&&p<t?[f,p]:void 0};let c=a(s,o);if(!c)return[s,o];if(!n(s,o)&&!n(c[0],c[1])){let d=c;for(let u=a(d[0],d[1]);u&&!n(u[0],u[1]);u=a(u[0],u[1]))d=u;return d}let h=c;for(;n(c[0],c[1]);){const d=a(c[0],c[1]);if(!d)return h;h=c=d}return c}function yu(n,e){return new Proxy(n,{get(t,s,o){const i=Reflect.get(t,s,o);return typeof s!="string"||!s.startsWith("on")||!e.size?i:(...r)=>{const l=typeof i=="function"?i.apply(t,r):void 0;for(const a of Array.from(e)){const c=a[s];if(typeof c=="function")try{c.apply(a,r)}catch(h){console.error(h)}}return l}}})}function At(n,e){const t=n==null?void 0:n[e],s=n==null?void 0:n.spreadsheet;if(t!==void 0||!s)return t;const o=typeof s=="object"?s[e]:void 0;if(o!==!1)return e==="editing"?{defaultEditable:!0,...typeof o=="object"?o:{}}:o??!0}function Cu(n){if(!(n!=null&&n.spreadsheet))return n;const e={...n};for(const t of["editing","clipboard","undo","cellFormulas","fillHandle"])e[t]=At(n,t);return e}class nc{constructor(e=[],t=[]){this.removed=e,this.inserted=t,this.insertBefore=new Int32Array(t.length);for(let s=0;s<t.length;s++)this.insertBefore[s]=t[s]-s}isEmpty(){return this.removed.length===0&&this.inserted.length===0}getRemovedCount(){return this.removed.length}getInsertedCount(){return this.inserted.length}touchesUpTo(e){return this.removed.length&&this.removed[0]<=e?!0:this.insertBefore.length>0&&this.insertBefore[0]<=e}mapIndex(e){if(e<0)return-1;const t=lo(this.removed,e);if(t<this.removed.length&&this.removed[t]===e)return-1;const s=e-t;return s+xi(this.insertBefore,s)}mapIndexOrNext(e){const t=Math.max(0,e-lo(this.removed,e));return t+xi(this.insertBefore,t)}mapRange(e,t){e>t&&([e,t]=[t,e]);const s=t>=Number.MAX_SAFE_INTEGER,o=e-lo(this.removed,e),i=s?Number.MAX_SAFE_INTEGER:t-lo(this.removed,t+1);if(i<o)return[];const r=[];let l=o,a=xi(this.insertBefore,o);for(let c=a;c<this.insertBefore.length&&this.insertBefore[c]<=i;c++){const h=this.insertBefore[c];h>l&&(r.push([l+a,h-1+a]),l=h),a++}return r.push([l+a,s?Number.MAX_SAFE_INTEGER:i+a]),r}}function lo(n,e){let t=0,s=n.length;for(;t<s;){const o=t+s>>>1;n[o]<e?t=o+1:s=o}return t}function xi(n,e){let t=0,s=n.length;for(;t<s;){const o=t+s>>>1;n[o]<=e?t=o+1:s=o}return t}class si{constructor(){this.doubleClick=!0,this.maxRows=1e4}static create(e){return{...new si,...e??{}}}}const Xr=class Xr{constructor(e){this.ctx=null;const t=e.querySelector(".ge-table-label"),s=getComputedStyle(t??e);this.padding=t?(parseFloat(s.paddingLeft)||0)+(parseFloat(s.paddingRight)||0):20;try{this.ctx=document.createElement("canvas").getContext("2d")}catch{this.ctx=null}this.ctx&&(this.ctx.font=s.font||`${s.fontSize} ${s.fontFamily}`)}measureText(e){const t=this.ctx?this.ctx.measureText(e).width:e.length*8;return Math.ceil(t+this.padding+2)}measureWidest(e){let t=this.measureText("");return e.forEach(s=>{t=Math.max(t,this.measureText(s))}),Math.max(t,50)}};Xr.maxCandidates=30;let Dt=Xr;function vu(n,e,t,s,o,i){var l,a;if(!n)return;const r=Dt.maxCandidates;for(let c=e;c<=t;c++)for(let h=0;h<s.length;h++){const d=s[h],u=((l=n.getTextValueAt)==null?void 0:l.call(n,c,d))||(((a=n.getValueAt(c,d))==null?void 0:a.toString())??""),f=u.length;f>i[h]&&(i[h]=f,o[h].forEach(p=>{p.length<f-2&&o[h].delete(p)})),f>=i[h]-2&&o[h].size<r&&o[h].add(u)}}class lc{constructor(e,t,s,o,i,r,l,a){this.type=e,this.source=t,this.columnIndex=s,this.columnDef=o,this.property=i,this.oldWidth=r,this.newWidth=l,this.originalEvent=a}}class ac{constructor(e,t,s,o,i,r,l){this.type=e,this.fromIndex=t,this.toIndex=s,this.columnDef=o,this.property=i,this.columnOrder=r,this.originalEvent=l}get moved(){return this.toIndex!==this.fromIndex}}class cc{constructor(e,t,s,o,i,r,l){this.areaIdent=e,this.rowIndex=t,this.columnIndex=s,this.value=o,this.row=i,this.source=r,this.originalEvent=l}}function hc(n,e,t){const s=Math.floor(t.count);if(!(s>0))return-1;const o=s-1;if(e==="first")return 0;if(e==="last")return o;if(!(n>=0&&n<=o))return Math.min(o,Math.max(0,Math.floor(t.firstVisible??0)));const i=Math.max(1,Math.floor(t.perRow)||1),r=Math.max(1,Math.floor(t.pageRows)||1),l=n%i,a=o-o%i,c=()=>Math.min(o,a+l);switch(e){case"previous":return Math.max(0,n-1);case"next":return Math.min(o,n+1);case"up":return n-i>=0?n-i:n;case"down":return n+i<=o?n+i:n<a?o:n;case"pageUp":{const h=n-r*i;return h>=0?h:l}default:{const h=n+r*i;return h<=o?h:n<a?c():n}}}function Ui(n,e){if(!(n>=0))return[-1,-1];const t=Math.max(1,Math.floor(e)||1);return[Math.floor(n/t),n%t]}function Es(n,e,t){const s=Math.max(1,Math.floor(t)||1);return!(n>=0)||!(e>=0)||e>=s?-1:n*s+e}class dc{constructor(e,t,s,o,i){this.filters=e,this.property=t,this.source=s,this.rowCount=o,this.unfilteredRowCount=i}}class Us{constructor(){this.showCondition=!0,this.showValues=!0,this.applyOnChange=!1,this.maxValues=1e4}static create(e,t){if(!e)return;const s=new Us,o=t!==void 0&&t>0?t:s.maxValues;return e===!0?{...s,maxValues:o}:{showCondition:e.showCondition??s.showCondition,showValues:e.showValues??s.showValues,applyOnChange:e.applyOnChange??s.applyOnChange,maxValues:Math.max(1,e.maxValues??o)}}}class oi{constructor(){this.visible=!0,this.debounce=200,this.placeholder=void 0,this.height=34,this.clearButtonVisible=!0,this.minInputWidthInPx=44}static create(e){if(!e)return;const t=new oi;return e===!0?t:{visible:e.visible??t.visible,debounce:Math.max(0,e.debounce??t.debounce),placeholder:e.placeholder??t.placeholder,height:Math.max(20,e.height??t.height),clearButtonVisible:e.clearButtonVisible??t.clearButtonVisible,minInputWidthInPx:Math.max(20,e.minInputWidthInPx??t.minInputWidthInPx)}}}class ii{constructor(){this.managed=!0,this.caseSensitive=!1,this.locale=void 0,this.maxValues=1e4}static create(e){const t=new ii;return e?{managed:e.managed??t.managed,caseSensitive:e.caseSensitive??t.caseSensitive,locale:e.locale??t.locale,maxValues:e.maxValues??t.maxValues}:t}}class eo{constructor(){this.searchPlaceholder="Search",this.searchValuesPlaceholder="Search values…",this.selectAll="(Select all)",this.blanks="(Blanks)",this.ok="OK",this.cancel="Cancel",this.clear="Clear",this.andLabel="and",this.noValues="No values",this.columnsTitle="Columns",this.searchColumnsPlaceholder="Search columns…",this.operators={contains:"Contains",startsWith:"Starts with",endsWith:"Ends with",equals:"Equals",notEquals:"Does not equal",lessThan:"Less than",lessOrEqual:"Less than or equal",greaterThan:"Greater than",greaterOrEqual:"Greater than or equal",between:"Between",blank:"Blank",notBlank:"Not blank"}}selectedValuesCount(e){return e===1?"(1 value)":`(${e} values)`}valuesTruncated(e){return`Showing first ${e.toLocaleString("en-US")} values – refine your search`}static create(e){const t=new eo;return e?{searchPlaceholder:e.searchPlaceholder??t.searchPlaceholder,searchValuesPlaceholder:e.searchValuesPlaceholder??t.searchValuesPlaceholder,selectAll:e.selectAll??t.selectAll,blanks:e.blanks??t.blanks,ok:e.ok??t.ok,cancel:e.cancel??t.cancel,clear:e.clear??t.clear,andLabel:e.andLabel??t.andLabel,selectedValuesCount:e.selectedValuesCount??t.selectedValuesCount.bind(t),valuesTruncated:e.valuesTruncated??t.valuesTruncated.bind(t),noValues:e.noValues??t.noValues,columnsTitle:e.columnsTitle??t.columnsTitle,searchColumnsPlaceholder:e.searchColumnsPlaceholder??t.searchColumnsPlaceholder,operators:{...t.operators,...e.operators??{}}}:t}}function Q(n){return!!(n==null||n===""||typeof n=="number"&&Number.isNaN(n)||n instanceof Date&&Number.isNaN(n.getTime()))}function Ki(n){return Q(n)?"blank":typeof n=="number"?`n:${Object.is(n,-0)?0:n}`:typeof n=="string"?`s:${n}`:typeof n=="boolean"?n?"b:true":"b:false":n instanceof Date?`d:${n.getTime()}`:`o:${String(n)}`}const Su=/^(\d{4})-(\d{2})-(\d{2})(?:$|[T ])/;function Pe(n){if(n instanceof Date){const e=n.getTime();return Number.isNaN(e)?void 0:Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())}if(typeof n=="string"){const e=Su.exec(n.trim());if(!e)return;const t=+e[1],s=+e[2],o=+e[3],i=new Date(Date.UTC(t,s-1,o));return i.getUTCFullYear()!==t||i.getUTCMonth()!==s-1||i.getUTCDate()!==o?void 0:i.getTime()}}function ys(n){if(typeof n=="number")return Number.isNaN(n)?void 0:n}function zi(n,e,t){const s=n.operator;if(s==="blank")return Q;if(s==="notBlank")return c=>!Q(c);const o=Q(n.value);if(s==="between"){const c=Q(n.valueTo);if(o&&c)return()=>!0;if(c)return zi({operator:"greaterOrEqual",value:n.value},e,t);if(o)return zi({operator:"lessOrEqual",value:n.valueTo},e,t)}else if(o&&(s==="equals"||s==="notEquals"))return s==="equals"?Q:c=>!Q(c);const i=s==="lessThan"||s==="lessOrEqual"||s==="greaterThan"||s==="greaterOrEqual"||s==="between";if(e==="number"||i&&typeof n.value=="number"){const c=typeof n.value=="number"?n.value:Number(n.value);if(Number.isNaN(c))return()=>!0;switch(s){case"equals":return h=>typeof h=="number"&&h===c;case"notEquals":return h=>typeof h!="number"||Number.isNaN(h)||h!==c;case"lessThan":return h=>{const d=ys(h);return d!==void 0&&d<c};case"lessOrEqual":return h=>{const d=ys(h);return d!==void 0&&d<=c};case"greaterThan":return h=>{const d=ys(h);return d!==void 0&&d>c};case"greaterOrEqual":return h=>{const d=ys(h);return d!==void 0&&d>=c};case"between":{const h=typeof n.valueTo=="number"?n.valueTo:Number(n.valueTo);if(Number.isNaN(h))return()=>!0;const d=Math.min(c,h),u=Math.max(c,h);return f=>{const p=ys(f);return p!==void 0&&p>=d&&p<=u}}}}if(e==="date"||n.value instanceof Date&&(i||s==="equals"||s==="notEquals")){const c=Pe(n.value);if(c===void 0)return()=>!0;switch(s){case"equals":return h=>Pe(h)===c;case"notEquals":return h=>Pe(h)!==c;case"lessThan":return h=>{const d=Pe(h);return d!==void 0&&d<c};case"lessOrEqual":return h=>{const d=Pe(h);return d!==void 0&&d<=c};case"greaterThan":return h=>{const d=Pe(h);return d!==void 0&&d>c};case"greaterOrEqual":return h=>{const d=Pe(h);return d!==void 0&&d>=c};case"between":{const h=Pe(n.valueTo);if(h===void 0)return()=>!0;const d=Math.min(c,h),u=Math.max(c,h);return f=>{const p=Pe(f);return p!==void 0&&p>=d&&p<=u}}}}if(e==="boolean"){const c=!!n.value;if(s==="equals")return h=>typeof h=="boolean"&&h===c;if(s==="notEquals")return h=>typeof h!="boolean"||h!==c}const r=n.value===null||n.value===void 0?"":String(n.value),l=t?r:r.toLowerCase(),a=t?c=>c==null?"":String(c):c=>c==null?"":String(c).toLowerCase();switch(s){case"contains":return c=>!Q(c)&&a(c).includes(l);case"startsWith":return c=>!Q(c)&&a(c).startsWith(l);case"endsWith":return c=>!Q(c)&&a(c).endsWith(l);case"equals":return c=>!Q(c)&&a(c)===l;case"notEquals":return c=>Q(c)||a(c)!==l;case"lessThan":return c=>!Q(c)&&a(c)<l;case"lessOrEqual":return c=>!Q(c)&&a(c)<=l;case"greaterThan":return c=>!Q(c)&&a(c)>l;case"greaterOrEqual":return c=>!Q(c)&&a(c)>=l;case"between":{const c=n.valueTo===null||n.valueTo===void 0?"":String(n.valueTo),h=t?c:c.toLowerCase(),d=l<=h?l:h,u=l<=h?h:l;return f=>{if(Q(f))return!1;const p=a(f);return p>=d&&p<=u}}default:return()=>!0}}const xu="\0d:";function ji(n){if(n==null||n==="")return null;if(typeof n=="number")return Number.isNaN(n)?null:n===0?0:n;if(typeof n=="string"||typeof n=="boolean")return n;if(n instanceof Date){const e=n.getTime();return Number.isNaN(e)?null:`${xu}${e}`}return n}function Ro(n){if(Q(n))return null;if(n instanceof Date)return n.getTime();if(typeof n=="string"){const e=Date.parse(n);return Number.isNaN(e)?n:e}return n}function uc(n,e="text",t){const s=(t==null?void 0:t.caseSensitive)??!1,o=n.condition?zi(n.condition,e,s):void 0;let i;if(n.values!==void 0){if(n.values.length===0)return()=>!1;const r=new Set;let l=!1;for(let c=0;c<n.values.length;c++){const h=n.values[c];h instanceof Date&&(l=!0),r.add(ji(h))}const a=r.has(null);if(e==="date"){const c=new Set;for(let h=0;h<n.values.length;h++)c.add(Ro(n.values[h]));i=h=>c.has(Ro(h))}else l?i=c=>r.has(ji(c)):i=c=>c==null||c===""||typeof c=="number"&&Number.isNaN(c)?a:r.has(c)}return o&&i?r=>i(r)&&o(r):o??i??(()=>!0)}function fc(n,e,t){const s=[],o=[];for(let r=0;r<e.length;r++){const l=e[r],a=n[l.property];!a||a.condition===void 0&&a.values===void 0||(s.push(l.getValue),o.push(uc(a,l.type,{caseSensitive:l.caseSensitive??(t==null?void 0:t.caseSensitive)??!1})))}const i=o.length;if(i!==0){if(i===1){const r=s[0],l=o[0];return a=>l(r(a))}return r=>{for(let l=0;l<i;l++)if(!o[l](s[l](r)))return!1;return!0}}}function Ru(n){if(n instanceof Date){if(Number.isNaN(n.getTime()))return"";const e=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0");return`${e}-${t}-${s}`}return String(n)}function zn(n){return Q(n)?99:typeof n=="number"?0:n instanceof Date?1:typeof n=="boolean"?2:3}function Au(n,e){const t=zn(n.value),s=zn(e.value);if(t!==s)return t-s;if(t===99)return 0;if(t===0)return n.value-e.value;if(t===1)return n.value.getTime()-e.value.getTime();if(t===2)return Number(n.value)-Number(e.value);const o=n.label??String(n.value),i=e.label??String(e.value);return o<i?-1:o>i?1:0}function pc(n,e,t={}){var h;const s=t.maxValues??1e4,o=t.blanksLabel??"(Blanks)",i=t.formatValue??Ru,r=((h=t.search)==null?void 0:h.trim().toLowerCase())??"",l=new Map;let a=!1;for(let d=0;d<n.length;d++){const u=e(n[d]),f=ji(u),p=l.get(f);if(p){p.count=(p.count??0)+1;continue}if(!r&&l.size>=s){a=!0;continue}const g=f===null,m=g?o:i(u);if(!(r&&!m.toLowerCase().includes(r))){if(l.size>=s){a=!0;continue}l.set(f,{value:g?null:u,label:m,count:1})}}const c=Array.from(l.values());return c.sort(Au),{items:c,truncated:a}}function jn(n){return n<10?`0${n}`:`${n}`}function Xn(n){return n instanceof Date?Number.isNaN(n.getTime())?void 0:`${n.getFullYear()}-${jn(n.getMonth()+1)}-${jn(n.getDate())}`:n}function Eu(n){return n instanceof Date?Number.isNaN(n.getTime())?null:n.toISOString():n}function Zt(n){var o;if(!n||typeof n!="object")return;const e=n.condition!==void 0&&typeof((o=n.condition)==null?void 0:o.operator)=="string",t=Array.isArray(n.values);if(!e&&!t)return;const s={};if(e){const i={operator:n.condition.operator};n.condition.value!==void 0&&(i.value=n.condition.value),n.condition.valueTo!==void 0&&(i.valueTo=n.condition.valueTo),s.condition=i}return t&&(s.values=n.values.slice()),s}function Ks(n){const e={},t=Object.keys(n);for(let s=0;s<t.length;s++){const o=t[s],i=Zt(n[o]);if(!i)continue;const r={};if(i.condition){const l={operator:i.condition.operator};i.condition.value!==void 0&&(l.value=Xn(i.condition.value)),i.condition.valueTo!==void 0&&(l.valueTo=Xn(i.condition.valueTo)),r.condition=l}i.values!==void 0&&(r.values=i.values.map(Eu)),e[o]=r}return e}function gc(n,e){const t={};if(!n||typeof n!="object")return t;const s=n,o=Object.keys(s);for(let i=0;i<o.length;i++){const r=o[i];if(e&&!e.has(r))continue;const l=Zt(s[r]);l&&(t[r]=l)}return t}function Xi(n,e){const t=Ks(n),s=Ks(e),o=Object.keys(t).sort(),i=Object.keys(s).sort();if(o.length!==i.length)return!1;for(let r=0;r<o.length;r++){const l=o[r];if(l!==i[r]||JSON.stringify(t[l])!==JSON.stringify(s[l]))return!1}return!0}function mc(n,e,t=100){let s,o=0;for(let i=0;i<n.length&&o<t;i++){const r=e(n[i]);if(Q(r))continue;o++;let l;if(typeof r=="number")l="number";else if(typeof r=="boolean")l="boolean";else if(r instanceof Date)l="date";else if(typeof r=="string"&&Pe(r)!==void 0)l="date";else return"text";if(s===void 0)s=l;else if(s!==l)return"text"}return s??"text"}const Mu=/^#(\d+)$/;function Yn(n){if(n&&typeof n=="object")return n}function Tu(n){if(typeof n=="string")return n;if(n&&typeof n=="object")return n.type}class bc{constructor(e){this.scope=e,this.filters={},this.typeCache=new Map,this.warnedNonFilterable=!1}getOptions(){return ii.create(this.scope.tableOptions.columnFilter)}getTexts(){return eo.create(this.scope.tableOptions.columnFilterTexts)}isColumnFilterable(e){const t=this.scope.tableModel;if(e<0||e>=t.getColumnCount())return!1;const s=t.getColumnDef(e);return!((s==null?void 0:s.filter)===!1||(s==null?void 0:s.filter)===void 0&&(G(s)||Ae(s)||ht(s)||js(s)))}hasActiveFilters(){return Object.keys(this.filters).length>0}isBodyFilterable(){return this.scope.tableModel.getBodyModel().isFilterable()}resolveColumn(e){var i;const t=this.scope.tableModel,s=t.getColumnDefs(),o=t.getColumnCount();if(typeof e=="number"){if(e<0||e>=o)return;const r=t.getColumnDef(e);return{property:(r==null?void 0:r.property)||`#${e}`,columnIndex:e,columnDef:r}}if(typeof e=="string"){if(!e)return;if(s){for(let l=0;l<s.length;l++)if(((i=s[l])==null?void 0:i.property)===e)return{property:e,columnIndex:l,columnDef:s[l]}}const r=Mu.exec(e);if(r){const l=Number(r[1]);if(l>=0&&l<o){const a=t.getColumnDef(l);return{property:(a==null?void 0:a.property)||`#${l}`,columnIndex:l,columnDef:a}}}return zt(t.getBodyModel())||ge(t.getBodyModel())?{property:e,columnIndex:-1,columnDef:void 0}:void 0}if(e&&typeof e=="object"){if(s){const r=s.indexOf(e);if(r>=0)return{property:e.property||`#${r}`,columnIndex:r,columnDef:e};if(e.property){const l=s.findIndex(a=>a.property===e.property);if(l>=0)return{property:e.property,columnIndex:l,columnDef:s[l]}}}if(e.property)return{property:e.property,columnIndex:-1,columnDef:e}}}getColumnFilter(e){const t=this.resolveColumn(e);if(!t)return;const s=this.filters[t.property];return s?Zt(s):void 0}getColumnFilters(){return Ks(this.filters)}isColumnFiltered(e){const t=this.resolveColumn(e);return!!t&&this.filters[t.property]!==void 0}setColumnFilter(e,t,s="api"){const o=this.resolveColumn(e);if(!o)return;const i=Zt(t),r={...this.filters};i?r[o.property]=i:delete r[o.property],this.commitFilters(r,o.property,s)}setColumnFilters(e,t="api"){const s={},o=Object.keys(e??{});for(let i=0;i<o.length;i++){const r=o[i],l=this.resolveColumn(r);if(!l)continue;const a=Zt(e[r]);a&&(s[l.property]=a)}this.commitFilters(s,void 0,t)}clearColumnFilters(e="api"){this.hasActiveFilters()&&this.commitFilters({},void 0,e)}applyStateFilters(e,t){const s=this.validPropertySet(),o=gc(e,s),i=!Xi(this.filters,o);return this.filters=o,this.cachedCompiled=void 0,t&&i?(this.runManagedFilter(!1,!1),this.scope.onColumnFiltersChanged("state"),this.emitFilterEvent(void 0,"state")):i&&this.scope.onColumnFiltersChanged("state"),i}getEffectiveFilterFunction(){const e=this.scope.tableOptions.externalFilterFunction;if(!this.hasActiveFilters()||!this.getOptions().managed)return e;const t=this.getCompiledColumnPredicate();return t?e?(s,o,i)=>!!e(s,o,i)&&t(s):s=>t(s):e}invalidateTypeCache(){this.typeCache.clear(),this.cachedCompiled=void 0}onRowsReplaced(){if(this.invalidateTypeCache(),this.hasActiveFilters()&&this.getOptions().managed&&this.isBodyFilterable()){const e=this.getEffectiveFilterFunction();e&&this.scope.reapplyFilterAfterSetRows(e)}}getColumnFilterType(e,t,s){const o=Tu(s==null?void 0:s.filter);if(o)return o;const i=this.typeCache.get(t);if(i)return i;const r=this.collectSampleRows(1e4),l=this.buildValueGetter(t,e,s),a=mc(r,l,100);let c=!1;for(let h=0;h<r.length&&!c;h++)c=!Q(l(r[h]));return c&&this.typeCache.set(t,a),a}collectColumnDistinctValues(e,t={}){const s=this.resolveColumn(e);if(!s)return{items:[],truncated:!1};const o=this.getOptions(),i=this.getTexts(),r=this.buildValueGetter(s.property,s.columnIndex,s.columnDef),l=this.buildOtherFiltersPredicate(s.property),a=this.getAllRowsForDistinct(),c=l?a.filter((h,d,u)=>l(h,d,u)):a;return pc(c,r,{maxValues:t.maxValues??o.maxValues,search:t.search,blanksLabel:t.blanksLabel??i.blanks,formatValue:t.formatValue})}getOtherFilters(e){const t={},s=Object.keys(this.filters);for(let o=0;o<s.length;o++){const i=s[o];i!==e&&(t[i]=this.filters[i])}return t}commitFilters(e,t,s){const o=this.getOptions();if(o.managed&&!this.isBodyFilterable()){this.warnedNonFilterable||(this.warnedNonFilterable=!0,console.warn("GuiExpert Table – columnFilter: body area model is not filterable (isFilterable() returned false). Set tableOptions.columnFilter = { managed: false } for server-side filtering."));return}const i=this.hasActiveFilters();Xi(this.filters,e)&&(!i||Object.keys(e).length>0)||(this.filters=e,this.cachedCompiled=void 0,o.managed&&this.runManagedFilter(!0,!0),this.scope.onColumnFiltersChanged(s),this.scope.stateService.markDirty("filters"),this.emitFilterEvent(t,s))}runManagedFilter(e,t){const o=this.getEffectiveFilterFunction()??(()=>!0);this.scope.applyFilterFunction(o,e,t,!0)}emitFilterEvent(e,t){var l,a,c;const s=this.scope.tableModel.getBodyModel(),o=s.getRowCount(),i=((l=s.getUnfilteredRowCount)==null?void 0:l.call(s))??o,r=new dc(Ks(this.filters),e,t,o,i);(c=(a=this.scope.getEventListener()).onFilterChanged)==null||c.call(a,r)}validPropertySet(){var i;const e=this.scope.tableModel.getBodyModel();if(zt(e)||ge(e))return;const t=this.scope.tableModel.getColumnDefs(),s=this.scope.tableModel.getColumnCount(),o=new Set;if(t&&t.length>0){for(let r=0;r<t.length;r++)(i=t[r])!=null&&i.property?o.add(t[r].property):o.add(`#${r}`);return o}for(let r=0;r<s;r++)o.add(`#${r}`);return o}getCompiledColumnPredicate(){if(this.cachedCompiled&&this.cachedCompiled.filters===this.filters)return this.cachedCompiled.fn;const e=this.compileForFilters(this.filters);return this.cachedCompiled={filters:this.filters,fn:e},e}buildOtherFiltersPredicate(e){const t=this.scope.tableOptions.externalFilterFunction,s=this.getOtherFilters(e),o=Object.keys(s).length>0?this.compileForFilters(s):void 0;return o?t?(i,r,l)=>!!t(i,r,l)&&o(i):i=>o(i):t}compileForFilters(e){var i;const t=Object.keys(e);if(t.length===0)return;const s=this.getOptions(),o=[];for(let r=0;r<t.length;r++){const l=t[r],a=this.resolveColumn(l);if(!a)continue;const c=Yn((i=a.columnDef)==null?void 0:i.filter),h=this.getColumnFilterType(a.columnIndex,a.property,a.columnDef),d=this.buildValueGetter(a.property,a.columnIndex,a.columnDef);o.push({property:l,type:h,getValue:d,caseSensitive:(c==null?void 0:c.caseSensitive)??s.caseSensitive})}return fc(e,o,{caseSensitive:s.caseSensitive})}buildValueGetter(e,t,s){var c;const o=Yn(s==null?void 0:s.filter);if(o!=null&&o.valueGetter)return o.valueGetter;const i=this.scope.tableModel.getBodyModel(),r=i;if(typeof r.getSheetColumnCount=="function"){const h=t-(r.columnOffset??0),d=r.sheetCells;return d?u=>{const f=Array.isArray(u)?u[h]:void 0;return f==null?"":typeof f=="string"?d.valueAt(u,t,f):f}:u=>Array.isArray(u)?u[h]:void 0}if(Array.isArray(i.arr)&&t>=0){const h=r.sheetCells;return h?d=>{const u=Array.isArray(d)?d[t]:void 0;return typeof u=="string"?h.valueAt(d,t,u):u}:d=>Array.isArray(d)?d[t]:void 0}if(zt(i))return dt(e);if(((s==null?void 0:s.valueGetter)!==void 0||(((c=i.isCalculatedProperty)==null?void 0:c.call(i,e))??!1)||!!r.sheetCells)&&i.getRowValue){const h=i.getRowValue.bind(i);return d=>h(d,e)}if(ee(i)&&!ge(i)){const h=dt(e);return d=>h(J(d)?d.data:d)}return e.includes(".")?dt(e):h=>h==null?void 0:h[e]}collectSampleRows(e){const t=this.scope.tableModel.getBodyModel(),s=t;if(typeof s.getSourceRows=="function")return s.getSourceRows().slice(0,e);const o=t;if(typeof o.getAllRows=="function")return o.getAllRows().slice(0,e);const i=t;if(Array.isArray(i.arr))return i.arr.slice(0,e);if(typeof t.getSheetColumnCount=="function"){const h=[],d=t.getRowCount();for(let u=0;u<d&&h.length<e;u++){const f=t.getRowByIndex(u);f!==void 0&&h.push(f)}return h}const l=t;if(ee(t)&&Array.isArray(l.rows)){const h=[],d=u=>{var f;for(let p=0;p<u.length&&h.length<e;p++)h.push(u[p]),(f=u[p].children)!=null&&f.length&&d(u[p].children)};return d(l.rows),h}const a=[],c=Math.min(t.getRowCount(),e);for(let h=0;h<c;h++)a.push(t.getRowByIndex(h));return a}getAllRowsForDistinct(){var a;const e=this.scope.tableModel.getBodyModel(),t=e;if(typeof t.getSourceRows=="function")return t.getSourceRows();const s=e;if(typeof s.getAllRows=="function")return s.getAllRows();const o=e;if(Array.isArray(o.arr))return o.arr;const i=e;if(ee(e)&&Array.isArray(i.rows)){const c=[],h=d=>{var u;for(let f=0;f<d.length;f++)c.push(d[f]),(u=d[f].children)!=null&&u.length&&h(d[f].children)};return h(i.rows),c}const r=((a=e.getUnfilteredRowCount)==null?void 0:a.call(e))??e.getRowCount(),l=[];for(let c=0;c<r;c++)l.push(e.getRowByIndex(c));return l}}const Iu=["true","yes","1","wahr","ja"],Du=["false","no","0","falsch","nein"];function qn(n){return n<10?`0${n}`:`${n}`}function Rt(n){return`${n.getFullYear()}-${qn(n.getMonth()+1)}-${qn(n.getDate())}`}function Jn(n){const e=n.trim();return e.startsWith(">=")?{operator:"greaterOrEqual",rest:e.slice(2).trim()}:e.startsWith("<=")?{operator:"lessOrEqual",rest:e.slice(2).trim()}:e.startsWith("!=")||e.startsWith("<>")?{operator:"notEquals",rest:e.slice(2).trim()}:e.startsWith(">")?{operator:"greaterThan",rest:e.slice(1).trim()}:e.startsWith("<")?{operator:"lessThan",rest:e.slice(1).trim()}:e.startsWith("=")?{operator:"equals",rest:e.slice(1).trim()}:{rest:e}}const wc=/^(\d{4})-(\d{1,2})$/;function ao(n,e,t){const s=wc.exec(n);if(s){const o=Number(s[1]),i=Number(s[2]);return i<1||i>12?void 0:e?new Date(o,i,0):new Date(o,i-1,1)}return Qs(n,t)??void 0}function Fu(n){let e="contains",t=n;return n.startsWith("!=")||n.startsWith("<>")?(e="notEquals",t=n.slice(2).trim()):n.startsWith("=")?(e="equals",t=n.slice(1).trim()):n.startsWith("^")?(e="startsWith",t=n.slice(1).trim()):n.endsWith("$")&&(e="endsWith",t=n.slice(0,-1).trim()),t?{operator:e,value:t}:null}function yc(n,e="text",t){const s=n.trim();if(s){if(s==='""')return{operator:"blank"};if(/^(!=|<>)\s*""$/.test(s))return{operator:"notBlank"};if(e==="text"||e==="set")return Fu(s);if(e==="boolean"){const o=s.toLowerCase();return Iu.includes(o)?{operator:"equals",value:!0}:Du.includes(o)?{operator:"equals",value:!1}:null}if(e==="number"){const o=s.indexOf("..");if(o!==-1){const a=s.slice(0,o).trim(),c=s.slice(o+2).trim();if(!a||!c)return null;const h=Xt(a,t),d=Xt(c,t);return h===void 0||d===void 0?null:{operator:"between",value:h,valueTo:d}}const{operator:i,rest:r}=Jn(s);if(!r)return null;const l=Xt(r,t);return l===void 0?null:{operator:i??"equals",value:l}}if(e==="date"){const o=s.indexOf("..");if(o!==-1){const a=s.slice(0,o).trim(),c=s.slice(o+2).trim();if(!a||!c)return null;const h=ao(a,!1,t),d=ao(c,!0,t);return!h||!d?null:{operator:"between",value:Rt(h),valueTo:Rt(d)}}const{operator:i,rest:r}=Jn(s);if(!r)return null;if(wc.test(r)){const a=ao(r,!1,t),c=ao(r,!0,t);return!a||!c?null:i===void 0||i==="equals"?{operator:"between",value:Rt(a),valueTo:Rt(c)}:i==="notEquals"?null:{operator:i,value:Rt(i==="greaterThan"||i==="lessOrEqual"?c:a)}}const l=Qs(r,t);return l?{operator:i??"equals",value:Rt(l)}:null}return{operator:"contains",value:s}}}function Zn(n,e){return n==null?"":n instanceof Date?Number.isNaN(n.getTime())?"":Rt(n):typeof n=="number"?Pr(n,e):String(n)}function Pr(n,e){const t=String(n);if(!t.includes(".")||/e/i.test(t))return t;let s=".";try{const o=new Intl.NumberFormat(e).formatToParts(1.5).find(i=>i.type==="decimal");s=(o==null?void 0:o.value)??"."}catch{}return s==="."?t:t.replace(".",s)}function Yi(n,e,t){if(!n)return"";const s=eo.create(e);if(n.values!==void 0&&!n.condition)return s.selectedValuesCount(n.values.length);const o=n.condition;if(!o)return"";const i=Zn(o.value,t);let r;switch(o.operator){case"contains":r=i;break;case"startsWith":r=`^${i}`;break;case"endsWith":r=`${i}$`;break;case"equals":r=`= ${i}`;break;case"notEquals":r=`!= ${i}`;break;case"lessThan":r=`< ${i}`;break;case"lessOrEqual":r=`<= ${i}`;break;case"greaterThan":r=`> ${i}`;break;case"greaterOrEqual":r=`>= ${i}`;break;case"between":r=`${i}..${Zn(o.valueTo,t)}`;break;case"blank":r='""';break;case"notBlank":r='!=""';break;default:r=i}return n.values!==void 0?`${r} ${s.selectedValuesCount(n.values.length)}`:r}const Qn="http://www.w3.org/2000/svg";function ku(n,e){if(n!=null&&n.filter&&typeof n.filter=="object"){const t=n.filter.placeholder;if(t!==void 0)return t}return e}function Lu(n){const e=n.createElementNS(Qn,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=n.createElementNS(Qn,"path");return t.setAttribute("fill","currentColor"),t.setAttribute("d","M2 3.25A.75.75 0 0 1 2.75 2.5h10.5a.75.75 0 0 1 .58 1.22L9.75 8.6v4.15a.75.75 0 0 1-1.17.62l-2-1.33a.75.75 0 0 1-.33-.62V8.6L2.17 3.72A.75.75 0 0 1 2 3.25Z"),e.appendChild(t),e}class Cc{constructor(e,t){this.scope=e,this.options=t,this.cells=new Map,this.timers=new Map,this.drafts=new Map,this.abortController=new AbortController,this.lastLayerTop=-1,this.lastLayerWidth=-1,this.lastLayerHeight=-1,this.lastLayerVisible=!1,this.destroyed=!1,this.dom=e.getDomService(),this.visible=t.visible;const s=e.columnFilterService.isBodyFilterable(),o=e.columnFilterService.getOptions().managed;this.supported=s||!o,this.supported||console.warn("GuiExpert Table – filterRow is ignored: the body area model is not filterable (set columnFilter: { managed: false } for server-side filtering).");const i=e.hostElement;this.layer=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-filter-row-layer",i)),this.dom.setAttribute(this.layer,"role","presentation"),this.dom.applyDisplayNoneStyle(this.layer),this.sides={west:this.createSideSlot("west"),center:this.createSideSlot("center"),east:this.createSideSlot("east")}}isVisible(){return!this.destroyed&&this.supported&&this.visible&&this.scope.tableModel.isHeaderVisibe()}getVisibleOption(){return this.visible}getReservedHeight(){return this.isVisible()?this.options.height:0}setVisible(e){const t=!!e;return this.visible===t?!1:(this.visible=t,t||this.hideLayer(),!0)}isInLayer(e){var s;if(this.destroyed)return!1;const t=(s=e.composedPath)==null?void 0:s.call(e);return t!=null&&t.length?t.includes(this.layer):e.target instanceof Node&&this.layer.contains(e.target)}update(){if(this.destroyed)return;if(!this.isVisible()){this.hideLayer();return}const e=this.scope.tableModel,t=this.getHeaderRowsHeight(),s=this.scope.getLayoutWidth(),o=e.getPadding(),i=o.left,r=o.right,l=Math.max(0,s-i-r),a=this.options.height;this.lastLayerVisible||(this.dom.applyDisplayBlockStyle(this.layer),this.lastLayerVisible=!0),(this.lastLayerTop!==t||this.lastLayerWidth!==s||this.lastLayerHeight!==a)&&(this.dom.applyStyle(this.layer,{top:`${t}px`,left:"0px",width:`${s}px`,height:`${a}px`}),this.lastLayerTop=t,this.lastLayerWidth=s,this.lastLayerHeight=a),this.layoutSide(this.sides.west,0,i,i>0),this.layoutSide(this.sides.center,i,l,l>0),this.layoutSide(this.sides.east,s-r,r,r>0);const c=e.getColumnCount(),h=e.getFixedLeftColumnCount(),d=e.getFixedRightColumnCount(),u=Math.max(h,c-d),f=this.scope.getAriaGridInfo(),p=f.filterRowIndex(),g=new Set;let m=0;for(let w=0;w<h&&w<c;w++){const y=e.getColumnWidth(w);y>0&&(this.mountOrUpdateCell("west",w,m,y,f.colIndex(w),g),m+=y)}m=-this.scope.getContentScrollLeft();for(let w=h;w<u;w++){const y=e.getColumnWidth(w);if(y>0&&(m+y>0&&m<l&&this.mountOrUpdateCell("center",w,m,y,f.colIndex(w),g),m+=y,m>=l))break}m=0;for(let w=u;w<c;w++){const y=e.getColumnWidth(w);y>0&&(this.mountOrUpdateCell("east",w,m,y,f.colIndex(w),g),m+=y)}const b=[];this.cells.forEach((w,y)=>{g.has(y)||(this.isCellFocused(w)?this.parkCell(w):(w.el.remove(),b.push(y)))});for(let w=0;w<b.length;w++)this.cells.delete(b[w]);this.updateSideRoles(p)}syncFromFilters(e){if(this.destroyed)return;e!=="row"&&(this.clearAllTimers(),this.drafts.clear());const t=this.scope.columnFilterService.getTexts();this.cells.forEach(s=>{if(!s.filterable||!s.input)return;const o=this.scope.columnFilterService.getColumnFilter(s.key),i=!!(o!=null&&o.values&&o.values.length>0)||(o==null?void 0:o.values)!==void 0&&o.values.length===0;if(e!=="row"||!this.isCellFocused(s)){const r=o?Yi(o,t,this.scope.columnFilterService.getOptions().locale):"";s.input.value!==r&&(s.input.value=r)}this.applyCellFilterState(s,o!==void 0,i)})}focusColumn(e){if(!this.isVisible())return!1;const t=this.scope.tableModel;if(e<0||e>=t.getColumnCount()||t.getColumnWidth(e)<=0||!this.scope.columnFilterService.isColumnFilterable(e))return!1;this.scope.ensureColumnIsVisible(e),this.update();const s=this.columnKey(e),o=this.cells.get(s);return o!=null&&o.input?(o.input.focus(),!0):!1}focusActiveOrFirstColumn(e){if(!this.isVisible())return!1;if(e!==void 0&&this.focusColumn(e))return!0;const t=this.scope.tableModel.getColumnCount();for(let s=0;s<t;s++)if(this.scope.tableModel.getColumnWidth(s)>0&&this.scope.columnFilterService.isColumnFilterable(s))return this.focusColumn(s);return!1}destroy(){this.destroyed||(this.destroyed=!0,this.clearAllTimers(),this.drafts.clear(),this.abortController.abort(),this.cells.clear(),this.layer.remove())}createSideSlot(e){const t=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-filter-side ge-table-filter-side-${e}`,this.layer));this.dom.setAttribute(t,"id",this.scope.ariaIds.filterRowGroup(e)),this.dom.setAttribute(t,"role","presentation"),this.dom.applyStyle(t,{top:"0px",height:"100%",overflow:"hidden"});const s=this.dom.createDivWithClass("ge-table-filter-row",t);return this.dom.setAttribute(s,"role","presentation"),this.dom.applyStyle(s,{position:"relative",width:"100%",height:"100%"}),{side:e,container:t,row:s,lastLeft:-1,lastWidth:-1,lastVisible:!1}}layoutSide(e,t,s,o){e.lastVisible!==o&&(o?this.dom.applyDisplayBlockStyle(e.container):this.dom.applyDisplayNoneStyle(e.container),e.lastVisible=o),o&&(e.lastLeft!==t||e.lastWidth!==s)&&(this.dom.applyStyle(e.container,{left:`${t}px`,width:`${s}px`}),e.lastLeft=t,e.lastWidth=s)}hideLayer(){this.lastLayerVisible&&(this.dom.applyDisplayNoneStyle(this.layer),this.lastLayerVisible=!1);for(const e of["west","center","east"]){const t=this.sides[e];t.container.getAttribute("role")!=="presentation"&&this.dom.setAttribute(t.container,"role","presentation"),t.row.getAttribute("role")!=="presentation"&&(this.dom.setAttribute(t.row,"role","presentation"),this.dom.removeAttribute(t.row,"aria-rowindex"))}}updateSideRoles(e){const t=`${e}`;for(const s of["west","center","east"]){const o=this.sides[s];o.lastVisible&&o.row.childElementCount>0?(o.container.getAttribute("role")!=="rowgroup"&&this.dom.setAttribute(o.container,"role","rowgroup"),o.row.getAttribute("role")!=="row"&&this.dom.setAttribute(o.row,"role","row"),o.row.getAttribute("aria-rowindex")!==t&&this.dom.setAttribute(o.row,"aria-rowindex",t)):(o.container.getAttribute("role")!=="presentation"&&this.dom.setAttribute(o.container,"role","presentation"),o.row.getAttribute("role")!=="presentation"&&(this.dom.setAttribute(o.row,"role","presentation"),this.dom.removeAttribute(o.row,"aria-rowindex")))}}columnKey(e){const t=this.scope.tableModel.getColumnDef(e);return(t==null?void 0:t.property)||`#${e}`}mountOrUpdateCell(e,t,s,o,i,r){const l=this.columnKey(t),a=this.scope.columnFilterService.isColumnFilterable(t),c=this.scope.getColumnAriaLabel(t),h=this.sides[e];r.add(l);let d=this.cells.get(l);if(d&&d.filterable!==a&&(d.el.remove(),this.cells.delete(l),d=void 0),d?(d.side!==e||d.el.parentElement!==h.row)&&(d.side=e,this.dom.domService.appendChild(h.row,d.el)):(d=this.createCell(l,t,e,a,c,h.row),this.cells.set(l,d)),d.columnIndex=t,d.parked&&(d.parked=!1,this.dom.applyStyle(d.el,{clipPath:"",pointerEvents:""})),(d.lastLeft!==s||d.lastWidth!==o)&&(this.dom.applyStyle(d.el,{left:`${s}px`,width:`${o}px`}),d.lastLeft=s,d.lastWidth=o),d.lastColIndex!==i&&(this.dom.setAttribute(d.el,"aria-colindex",`${i}`),this.dom.setAttribute(d.el,"data-col-index",`${t}`),d.lastColIndex=i),d.filterable){const u=o<this.options.minInputWidthInPx;d.lastNarrow!==u&&(u?this.dom.addClass("ge-table-filter-cell-narrow",d.el):this.dom.removeClass("ge-table-filter-cell-narrow",d.el),d.lastNarrow=u),d.lastLabel!==c&&(this.updateCellLabels(d,c),d.lastLabel=c)}}createCell(e,t,s,o,i,r){const l=this.scope.hostElement.ownerDocument,a=this.dom.domService,c=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(o?"ge-table-filter-cell":"ge-table-filter-cell ge-table-filter-cell-disabled",r));this.dom.setAttribute(c,"role","gridcell"),this.dom.setAttribute(c,"data-col-property",e),this.dom.setAttribute(c,"data-col-index",`${t}`),this.dom.applyStyle(c,{top:"0px",height:"100%"});const h={key:e,columnIndex:t,filterable:o,side:s,el:c,parked:!1,lastLeft:Number.NaN,lastWidth:Number.NaN,lastColIndex:-1,lastLabel:i,lastNarrow:!1};if(!o)return h;const d=this.scope.columnFilterService.getTexts(),u=this.scope.tableModel.getColumnDef(t),f=ku(u,this.options.placeholder??d.searchPlaceholder),p=this.abortController.signal,g=a.createElement("input");a.setAttribute(g,"type","text"),a.setAttribute(g,"tabindex","-1"),a.setAttribute(g,"autocomplete","off"),a.setAttribute(g,"autocorrect","off"),a.setAttribute(g,"autocapitalize","none"),a.setAttribute(g,"spellcheck","false"),f&&a.setAttribute(g,"placeholder",f),a.addClass(g,"ge-table-filter-input"),a.appendChild(c,g),h.input=g;const m=a.createElement("button");a.setAttribute(m,"type","button"),a.setAttribute(m,"tabindex","-1"),a.addClass(m,"ge-table-filter-clear");const b=a.createElement("span");a.setAttribute(b,"aria-hidden","true"),b.textContent="×",a.appendChild(m,b),m.hidden=!0,a.appendChild(c,m),h.clearBtn=m;const w=a.createElement("button");a.setAttribute(w,"type","button"),a.setAttribute(w,"tabindex","-1"),a.addClass(w,"ge-table-filter-narrow-btn"),a.appendChild(w,Lu(l)),a.appendChild(c,w),h.narrowBtn=w,this.updateCellLabels(h,i);const y=this.scope.columnFilterService.getColumnFilter(e),C=(y==null?void 0:y.values)!==void 0;return this.drafts.has(e)&&!C?g.value=this.drafts.get(e)??"":y&&(g.value=Yi(y,d,this.scope.columnFilterService.getOptions().locale)),this.applyCellFilterState(h,y!==void 0,C),g.addEventListener("focus",()=>{this.scope.clearHeaderFocusForFilterRow()},{signal:p}),g.addEventListener("focusout",()=>{h.parked&&!this.isCellFocused(h)&&(h.el.remove(),this.cells.delete(h.key))},{signal:p}),g.addEventListener("input",()=>{g.readOnly||this.onInputChanged(h)},{signal:p}),g.addEventListener("keydown",S=>{this.onInputKeyDown(h,S)},{signal:p}),m.addEventListener("click",()=>{this.clearCellFilter(h,!0)},{signal:p}),w.addEventListener("click",()=>{var S;(S=this.scope.columnFilterMenuService)!=null&&S.hasHeaderButtons()?this.scope.toggleColumnFilterMenu(h.columnIndex):g.focus()},{signal:p}),h}updateCellLabels(e,t){const s=this.dom.domService,o=this.scope.ariaTexts,i=o.filterInput?o.filterInput(t):`Filter ${t}`,r=o.clearColumnFilter?o.clearColumnFilter(t):`Clear filter for ${t}`;e.input&&s.setAttribute(e.input,"aria-label",i),e.clearBtn&&s.setAttribute(e.clearBtn,"aria-label",r),e.narrowBtn&&s.setAttribute(e.narrowBtn,"aria-label",i)}getHeaderRowsHeight(){const e=this.scope.tableModel,t=e.getAreaModel("header"),s=(t==null?void 0:t.getRowCount())??0;let o=0;for(let i=0;i<s;i++)o+=e.getRowHeight("header",i);return o>0?o:Math.max(0,e.getPadding().top-this.options.height)}applyCellFilterState(e,t,s){if(e.input&&(e.input.readOnly=s,s?this.dom.addClass("ge-table-filter-input-readonly",e.input):this.dom.removeClass("ge-table-filter-input-readonly",e.input),t?this.dom.addClass("ge-table-filter-cell-active",e.el):this.dom.removeClass("ge-table-filter-cell-active",e.el),e.clearBtn)){const o=this.options.clearButtonVisible&&(t||e.input.value.length>0);e.clearBtn.hidden=!o}}onInputChanged(e){const t=e.input;if(!t)return;const s=t.value;if(this.drafts.set(e.key,s),this.applyCellFilterState(e,this.scope.columnFilterService.isColumnFiltered(e.key),!1),this.cancelTimer(e.key),this.options.debounce<=0)this.commitCellInput(e);else{const o=setTimeout(()=>{this.timers.delete(e.key),this.commitCellInput(e)},this.options.debounce);this.timers.set(e.key,o)}}onInputKeyDown(e,t){const s=e.input;if(s&&!(t.isComposing||t.keyCode===229)){if(t.key==="Enter"){t.preventDefault(),this.cancelTimer(e.key),s.readOnly||this.commitCellInput(e);return}if(t.key==="Escape"){t.preventDefault(),s.value.length>0||this.scope.columnFilterService.isColumnFiltered(e.key)?this.clearCellFilter(e,!0):this.scope.focusHeaderFromFilterRow(e.columnIndex);return}if((t.key==="Backspace"||t.key==="Delete")&&s.readOnly){t.preventDefault(),this.clearCellFilter(e,!0);return}if(t.key==="ArrowUp"){t.preventDefault(),this.scope.focusHeaderFromFilterRow(e.columnIndex);return}if(t.key==="ArrowDown"){t.preventDefault(),this.scope.focusBodyFromFilterRow(e.columnIndex);return}if(t.key==="Tab"){const o=this.findAdjacentFilterableColumn(e.columnIndex,t.shiftKey?-1:1);o>=0&&(t.preventDefault(),this.focusColumn(o))}}}commitCellInput(e){var c;if(this.destroyed)return;const t=this.drafts.has(e.key)?this.drafts.get(e.key)??"":((c=e.input)==null?void 0:c.value)??"";this.drafts.delete(e.key);const s=this.scope.columnFilterService,o=s.resolveColumn(e.key),i=(o==null?void 0:o.columnIndex)??e.columnIndex,r=s.getColumnFilterType(i,e.key,o==null?void 0:o.columnDef),l=s.getOptions().locale,a=yc(t,r,l);if(a===null){e.input&&this.drafts.set(e.key,t);return}a?s.setColumnFilter(e.key,{condition:a},"row"):s.setColumnFilter(e.key,void 0,"row")}clearCellFilter(e,t){this.cancelTimer(e.key),this.drafts.delete(e.key),e.input&&(e.input.value="",e.input.readOnly=!1),this.applyCellFilterState(e,!1,!1),this.scope.columnFilterService.setColumnFilter(e.key,void 0,"row"),t&&e.input&&e.input.isConnected&&e.input.focus()}findAdjacentFilterableColumn(e,t){const s=this.scope.tableModel,o=s.getColumnCount();for(let i=e+t;i>=0&&i<o;i+=t)if(s.getColumnWidth(i)>0&&this.scope.columnFilterService.isColumnFilterable(i))return i;return-1}isCellFocused(e){var o,i,r;const t=(i=(o=this.layer).getRootNode)==null?void 0:i.call(o),s=t&&"activeElement"in t?t.activeElement:(r=this.scope.hostElement.ownerDocument)==null?void 0:r.activeElement;return!!s&&e.el.contains(s)}parkCell(e){e.parked||(e.parked=!0,this.dom.applyStyle(e.el,{clipPath:"inset(100%)",pointerEvents:"none"}))}cancelTimer(e){const t=this.timers.get(e);t!==void 0&&(clearTimeout(t),this.timers.delete(e))}clearAllTimers(){this.timers.forEach(e=>clearTimeout(e)),this.timers.clear()}}const Ou='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Nu(n){return typeof HTMLElement<"u"&&Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover")&&typeof n.showPopover=="function"}function el(n){const e=n.querySelectorAll(Ou),t=[];for(let s=0;s<e.length;s++){const o=e[s];!o.hidden&&o.offsetParent!==null&&t.push(o)}return t}class Br{constructor(e){this.scope=e,this.usingPopover=!1}isOpen(){return this.el!==void 0}getElement(){return this.el}isInPopup(e){var o;const t=this.el;if(!t)return!1;const s=(o=e.composedPath)==null?void 0:o.call(e);return s!=null&&s.length?s.includes(t):e.target instanceof Node&&t.contains(e.target)}open(e){var b,w;this.el&&this.close("api");const t=this.scope.hostElement,s=t.ownerDocument,o=s.defaultView??window,i=this.scope.getDomService().domService,r=i.createElement("div");if(i.addClass(r,"ge-table-filter-popup"),e.className)for(const y of e.className.split(/\s+/).filter(Boolean))i.addClass(r,y);i.setAttribute(r,"role","dialog"),i.setAttribute(r,"aria-modal","false"),i.setAttribute(r,"aria-label",e.ariaLabel),i.setAttribute(r,"tabindex","-1"),i.setAttribute(r,"dir",this.scope.direction);const l=(b=t.getRootNode)==null?void 0:b.call(t),a=s.fullscreenElement,c=a&&(a===t||a.contains(t))?a:typeof ShadowRoot<"u"&&l instanceof ShadowRoot?l:s.body,h=Nu(r);if(this.usingPopover=h,h?(i.setAttribute(r,"popover","manual"),c.appendChild(r)):(i.addClass(r,"ge-table-filter-popup-fallback"),c.appendChild(r)),this.el=r,this.onCloseCb=e.onClose,this.lastAnchorRect=e.anchorRect,h)try{r.showPopover()}catch{this.usingPopover=!1,(w=i.removeAttribute)==null||w.call(i,r,"popover"),i.addClass(r,"ge-table-filter-popup-fallback"),r.parentNode!==c&&c.appendChild(r)}const d=new AbortController;this.abortController=d;const u=d.signal;r.addEventListener("keydown",y=>{var C;if(y.key==="Escape"){y.preventDefault(),this.close("escape");return}if(y.key==="Tab"){const S=el(r);if(S.length===0){y.preventDefault(),r.focus();return}const x=(C=r.getRootNode)==null?void 0:C.call(r),R=x&&"activeElement"in x?x.activeElement:s.activeElement,I=S[0],A=S[S.length-1];y.shiftKey?(R===I||R===r||!r.contains(R))&&(y.preventDefault(),A.focus()):(R===A||!r.contains(R))&&(y.preventDefault(),I.focus())}},{signal:u});let f=!1;const p=y=>{var x;const C=(x=y.composedPath)==null?void 0:x.call(y);if(C!=null&&C.length){if(C.includes(r)||e.triggerEl&&C.includes(e.triggerEl))return!1;if(e.isTrigger)for(let R=0;R<C.length;R++){const I=C[R];if(I instanceof HTMLElement&&e.isTrigger(I))return!1}return!0}const S=y.target;return S?!(r.contains(S)||e.triggerEl&&e.triggerEl.contains(S)):!0};s.addEventListener("pointerdown",y=>{f=p(y)},{capture:!0,signal:u}),s.addEventListener("pointerup",y=>{f&&p(y)?(f=!1,this.close("outside")):f=!1},{capture:!0,signal:u});const g=this.scope.scrollViewport,m=g.scrollLeft;return g.addEventListener("scroll",()=>{Math.abs(g.scrollLeft-m)>=1&&this.close("scroll")},{passive:!0,signal:u}),o.addEventListener("resize",()=>{this.close("resize")},{passive:!0,signal:u}),r}reposition(e=this.lastAnchorRect){const t=this.el;if(!t||!e)return;this.lastAnchorRect=e;const s=t.ownerDocument.defaultView??window,o=s.innerWidth||t.ownerDocument.documentElement.clientWidth||1024,i=s.innerHeight||t.ownerDocument.documentElement.clientHeight||768,r=8,l=4;t.style.position="fixed",t.style.inset="auto",t.style.margin="0";const a=t.getBoundingClientRect(),c=a.width||260,h=a.height||300;let d=e.bottom+l;d+h>i-r&&e.top-l-h>=r&&(d=e.top-l-h),d=Math.max(r,Math.min(d,Math.max(r,i-h-r)));let u;this.scope.isRtl()?(u=e.right-c,u<r&&e.left+c<=o-r&&(u=e.left)):(u=e.left,u+c>o-r&&e.right-c>=r&&(u=e.right-c)),u=Math.max(r,Math.min(u,Math.max(r,o-c-r))),t.style.left=`${Math.round(u)}px`,t.style.top=`${Math.round(d)}px`}focusInitial(e){const t=this.el;if(!t)return;if(e&&!e.hidden&&e.isConnected){e.focus({preventScroll:!0});return}const s=el(t);s.length>0?s[0].focus({preventScroll:!0}):t.focus({preventScroll:!0})}close(e="api"){var l,a,c;const t=this.el;if(!t)return;const s=this.onCloseCb,o=(l=t.getRootNode)==null?void 0:l.call(t),i=o&&"activeElement"in o?o.activeElement:t.ownerDocument.activeElement,r=!!i&&t.contains(i);if(this.el=void 0,this.onCloseCb=void 0,this.lastAnchorRect=void 0,(a=this.abortController)==null||a.abort(),this.abortController=void 0,this.usingPopover)try{(c=t.hidePopover)==null||c.call(t)}catch{}if(this.usingPopover=!1,t.remove(),s==null||s(e),r&&e!=="destroy"){const h=t.ownerDocument;(!h.activeElement||h.activeElement===h.body)&&this.scope.hostElement.focus({preventScroll:!0})}}destroy(){this.close("destroy")}}const tl="http://www.w3.org/2000/svg",Cs=28,sl=4,ol={text:["contains","startsWith","endsWith","equals","notEquals","blank","notBlank"],number:["equals","notEquals","greaterThan","greaterOrEqual","lessThan","lessOrEqual","between","blank","notBlank"],date:["equals","notEquals","greaterThan","greaterOrEqual","lessThan","lessOrEqual","between","blank","notBlank"],boolean:["equals","notEquals","blank","notBlank"],set:[]};function Vu(n){const e=n.createElementNS(tl,"svg");e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const t=n.createElementNS(tl,"path");return t.setAttribute("fill","currentColor"),t.setAttribute("d","M2 3.25A.75.75 0 0 1 2.75 2.5h10.5a.75.75 0 0 1 .58 1.22L9.75 8.6v4.15a.75.75 0 0 1-1.17.62l-2-1.33a.75.75 0 0 1-.33-.62V8.6L2.17 3.72A.75.75 0 0 1 2 3.25Z"),e.appendChild(t),e}function Ri(n,e,t){if(n==null)return"";if(typeof n=="number")return Pr(n,t);if(e==="date"&&n instanceof Date&&!Number.isNaN(n.getTime())){const s=n.getFullYear(),o=`${n.getMonth()+1}`.padStart(2,"0"),i=`${n.getDate()}`.padStart(2,"0");return`${s}-${o}-${i}`}return String(n)}function Ai(n,e,t){const s=n.trim();if(s){if(e==="number"){const o=Xt(s,t);return Number.isNaN(o)?void 0:o}if(e==="date")return Qs(s,t)??void 0;if(e==="boolean"){const o=s.toLowerCase();return o==="true"||o==="1"||o==="yes"?!0:o==="false"||o==="0"||o==="no"?!1:void 0}return n}}function Pu(n){return n!=null&&n.filter&&typeof n.filter=="object"?n.filter:void 0}class qi{constructor(e,t,s=!0){this.scope=e,this.options=t,this.showHeaderButtons=s,this.openColumnIndex=-1,this.loadGeneration=0,this.destroyed=!1;const o=e.columnFilterService.isBodyFilterable(),i=e.columnFilterService.getOptions().managed;this.supported=o||!i,this.supported||console.warn("GuiExpert Table – columnFilterMenu is ignored: the body area model is not filterable (set columnFilter: { managed: false } for server-side filtering)."),this.popup=new Br(e)}isActive(){return!this.destroyed&&this.supported}hasHeaderButtons(){return this.isActive()&&this.showHeaderButtons}isOpen(){return this.popup.isOpen()}getOpenColumnIndex(){return this.popup.isOpen()?this.openColumnIndex:-1}isInPopup(e){return this.popup.isInPopup(e)}decorateHeaderCell(e,t,s){if(!this.hasHeaderButtons()||!this.scope.columnFilterService.isColumnFilterable(s))return;const o=this.scope.getDomService().domService,i=e.ownerDocument,r=this.scope.columnFilterService.isColumnFiltered(s),l=this.popup.isOpen()&&this.openColumnIndex===s,a=this.scope.getColumnAriaLabel(s),c=this.scope.ariaTexts,h=r?c.filterColumnActive?c.filterColumnActive(a):`Filter menu for ${a} (active)`:c.filterColumn?c.filterColumn(a):`Filter menu for ${a}`,d=o.createElement("button");o.setAttribute(d,"type","button"),o.setAttribute(d,"tabindex","-1"),o.setAttribute(d,"data-ge-action","filter-column"),o.setAttribute(d,"data-area","header"),o.setAttribute(d,"data-row-index",`${t}`),o.setAttribute(d,"data-col-index",`${s}`),o.setAttribute(d,"aria-haspopup","dialog"),o.setAttribute(d,"aria-expanded",l?"true":"false"),o.setAttribute(d,"aria-label",h),o.addClass(d,"ge-table-column-filter-btn"),r&&o.addClass(d,"ge-table-column-filter-active"),o.appendChild(d,Vu(i)),o.appendChild(e,d)}toggle(e){const t=this.scope.columnFilterService.resolveColumn(e);return t?this.popup.isOpen()&&this.openProperty===t.property?(this.close("api"),!0):this.open(e):!1}open(e){if(!this.isActive())return!1;const t=this.scope.columnFilterService,s=t.resolveColumn(e);if(!s||s.columnIndex<0)return!1;const o=s.columnIndex;if(this.scope.tableModel.getColumnWidth(o)<=0||!t.isColumnFilterable(o))return!1;this.scope.ensureColumnIsVisible(o);const i=this.findHeaderAnchor(o),r=(i==null?void 0:i.getBoundingClientRect())??this.fallbackAnchorRect(o),l=this.scope.getColumnAriaLabel(o),a=this.scope.ariaTexts,c=a.filterMenuDialog?a.filterMenuDialog(l):`Filter ${l}`,h=this.openColumnIndex;this.popup.isOpen()&&this.popup.close("api"),h>=0&&this.setHeaderButtonExpanded(h,!1),this.openProperty=s.property,this.openColumnIndex=o,this.setHeaderButtonExpanded(o,!0);const d=this.popup.open({ariaLabel:c,className:"ge-table-column-filter-menu",anchorRect:r,triggerEl:i,isTrigger:f=>f.classList.contains("ge-table-column-filter-btn")&&f.getAttribute("data-col-index")===`${o}`&&this.scope.hostElement.contains(f),onClose:f=>this.handleClosed(o,f)}),u=this.renderMenuContent(d,o,s.property,s.columnDef,l);return this.popup.reposition(r),this.popup.focusInitial(u),!0}close(e="api"){this.clearSearchTimer(),this.loadGeneration++,this.popup.close(e)}destroy(){this.destroyed||(this.destroyed=!0,this.clearSearchTimer(),this.loadGeneration++,this.popup.destroy(),this.openProperty=void 0,this.openColumnIndex=-1)}handleClosed(e,t){this.clearSearchTimer(),this.loadGeneration++,this.openProperty=void 0,this.openColumnIndex=-1,this.setHeaderButtonExpanded(e,!1),!this.destroyed&&(t==="escape"||t==="action"||t==="cancel")&&this.scope.focusHeaderFromFilterRow(e)}findHeaderAnchor(e){var r;const t=this.scope.hostElement,s=t.querySelector(`.ge-table-header button.ge-table-column-filter-btn[data-col-index="${e}"]`);if(s)return s;const o=((r=this.scope.tableModel.getAreaModel("header"))==null?void 0:r.getRowCount())??1,i=Math.max(0,o-1);return t.querySelector(`.ge-table-header .ge-table-col-div[data-row-index="${i}"][data-col-index="${e}"]`)??t.querySelector(`.ge-table-header .ge-table-col-div[data-col-index="${e}"]`)}fallbackAnchorRect(e){const t=this.scope.hostElement.getBoundingClientRect(),s=Math.max(40,this.scope.tableModel.getColumnWidth(e)),o=this.scope.isRtl()?t.right-s:t.left,i=t.top,r=this.scope.tableModel.getRowHeight("header",0)||34;return{left:o,right:o+s,top:i,bottom:i+r,width:s,height:r}}setHeaderButtonExpanded(e,t){const s=this.scope.hostElement.querySelector(`.ge-table-header button.ge-table-column-filter-btn[data-col-index="${e}"]`);s&&this.scope.getDomService().domService.setAttribute(s,"aria-expanded",t?"true":"false")}renderMenuContent(e,t,s,o,i){var Yr,qr,Jr,Zr;const r=this.scope.getDomService().domService,l=this.scope.columnFilterService,a=l.getTexts(),c=l.getOptions(),h=Pu(o),d=l.getColumnFilterType(t,s,o),u=l.getColumnFilter(s),f=this.options.maxValues??c.maxValues,p=`${this.scope.ariaIds.prefix}-fm-${t}`;let g=null;const m=r.createElement("div");r.addClass(m,"ge-table-filter-menu-header");const b=r.createElement("span");r.addClass(b,"ge-table-filter-menu-title"),b.textContent=i,r.appendChild(m,b),r.appendChild(e,m);const w=ol[d]??ol.text,y=this.options.showCondition&&w.length>0;let C,S,x,R;const I=()=>{if(!y||!C)return u==null?void 0:u.condition;const _=C.value;if(_==="blank"||_==="notBlank")return{operator:_};const V=(S==null?void 0:S.value)??"";if(_==="between"){const k=(x==null?void 0:x.value)??"",W=Ai(V,d,c.locale),B=Ai(k,d,c.locale);return W===void 0&&B===void 0?void 0:B===void 0?{operator:"greaterOrEqual",value:W}:W===void 0?{operator:"lessOrEqual",value:B}:{operator:"between",value:W,valueTo:B}}const z=Ai(V,d,c.locale);if(z!==void 0)return{operator:_,value:z}},A=()=>{if(!C)return;const _=C.value,V=_==="blank"||_==="notBlank",z=_==="between";S&&(S.hidden=V),R&&(R.hidden=!z),x&&(x.hidden=!z)};let T=()=>{};if(y){const _=r.createElement("div");r.addClass(_,"ge-table-filter-menu-condition");const V=r.createElement("select");r.addClass(V,"ge-table-filter-menu-select"),r.setAttribute(V,"aria-label",i);for(let k=0;k<w.length;k++){const W=w[k],B=r.createElement("option");B.value=W,B.textContent=a.operators[W]??W,r.appendChild(V,B)}V.value=(Yr=u==null?void 0:u.condition)!=null&&Yr.operator&&w.includes(u.condition.operator)?u.condition.operator:w[0],r.appendChild(_,V),C=V;const z=r.createElement("div");if(r.addClass(z,"ge-table-filter-menu-inputs"),d==="boolean"){const k=r.createElement("select");r.addClass(k,"ge-table-filter-menu-input"),r.setAttribute(k,"aria-label",i);for(const[W,B]of[["",""],["true","true"],["false","false"]]){const be=r.createElement("option");be.value=W,be.textContent=B,r.appendChild(k,be)}k.value=Ri((qr=u==null?void 0:u.condition)==null?void 0:qr.value,d),r.appendChild(z,k),S=k,k.addEventListener("change",()=>{this.options.applyOnChange&&T()})}else{const k=r.createElement("input");r.setAttribute(k,"type","text"),r.setAttribute(k,"autocomplete","off"),r.setAttribute(k,"autocorrect","off"),r.setAttribute(k,"autocapitalize","none"),r.setAttribute(k,"spellcheck","false"),r.setAttribute(k,"aria-label",i),r.setAttribute(k,"placeholder",d==="date"?"YYYY-MM-DD":a.searchPlaceholder),r.addClass(k,"ge-table-filter-menu-input"),k.value=Ri((Jr=u==null?void 0:u.condition)==null?void 0:Jr.value,d,c.locale),r.appendChild(z,k),S=k;const W=r.createElement("span");r.addClass(W,"ge-table-filter-menu-and"),W.textContent=a.andLabel,W.hidden=!0,r.appendChild(z,W),R=W;const B=r.createElement("input");r.setAttribute(B,"type","text"),r.setAttribute(B,"autocomplete","off"),r.setAttribute(B,"autocorrect","off"),r.setAttribute(B,"autocapitalize","none"),r.setAttribute(B,"spellcheck","false"),r.setAttribute(B,"aria-label",`${i} (${a.andLabel})`),r.setAttribute(B,"placeholder",d==="date"?"YYYY-MM-DD":a.searchPlaceholder),r.addClass(B,"ge-table-filter-menu-input"),B.value=Ri((Zr=u==null?void 0:u.condition)==null?void 0:Zr.valueTo,d,c.locale),B.hidden=!0,r.appendChild(z,B),x=B;const be=se=>{se.key==="Enter"&&!se.isComposing&&se.keyCode!==229&&(se.preventDefault(),T(),this.close("action"))};k.addEventListener("keydown",be),B.addEventListener("keydown",be),this.options.applyOnChange&&(k.addEventListener("input",()=>T()),B.addEventListener("input",()=>T()))}V.addEventListener("change",()=>{A(),this.popup.reposition(),this.options.applyOnChange&&T()}),A(),r.appendChild(_,z),r.appendChild(e,_),g||(g=S&&!S.hidden?S:V)}const F=this.options.showValues;let P=[],O=[],N=!1,K=(u==null?void 0:u.values)===void 0;const Y=new Set,U=new Map;let $=()=>"";const me=d==="date"?_=>{const V=Ro(_);return typeof V=="number"?`d:${V}`:Ki(_)}:Ki;if((u==null?void 0:u.values)!==void 0)for(let _=0;_<u.values.length;_++){const V=u.values[_],z=me(V);Y.add(z),U.set(z,V)}const te=_=>{const V=new Array(_.length);for(let z=0;z<_.length;z++){const k=_[z],W=me(k.value),B=k.label??(Q(k.value)?a.blanks:String(k.value));U.set(W,k.value),K&&Y.add(W),V[z]={key:W,value:k.value,label:B,count:k.count}}return V};if(F){const _=r.createElement("div");r.addClass(_,"ge-table-filter-menu-values");const V=r.createElement("input");r.setAttribute(V,"type","search"),r.setAttribute(V,"autocomplete","off"),r.setAttribute(V,"autocorrect","off"),r.setAttribute(V,"autocapitalize","none"),r.setAttribute(V,"spellcheck","false"),r.setAttribute(V,"placeholder",a.searchValuesPlaceholder),r.setAttribute(V,"aria-label",a.searchValuesPlaceholder),r.addClass(V,"ge-table-filter-menu-search"),r.appendChild(_,V);const z=r.createElement("div");r.addClass(z,"ge-table-filter-select-all");const k=r.createElement("input"),W=`${p}-all`;r.setAttribute(k,"type","checkbox"),r.setAttribute(k,"id",W);const B=r.createElement("label");r.setAttribute(B,"for",W),B.textContent=a.selectAll,r.appendChild(z,k),r.appendChild(z,B),r.appendChild(_,z);const be=r.createElement("div");r.addClass(be,"ge-table-filter-values-notice"),be.hidden=!0,r.appendChild(_,be);const se=r.createElement("div");r.addClass(se,"ge-table-filter-values-viewport"),r.setAttribute(se,"role","group"),r.setAttribute(se,"aria-label",i),r.setAttribute(se,"tabindex","-1"),$=()=>V.value.trim();const Ce=r.createElement("div");r.addClass(Ce,"ge-table-filter-values-spacer"),r.appendChild(se,Ce);const Xe=r.createElement("div");r.addClass(Xe,"ge-table-filter-values-empty"),Xe.textContent=a.noValues,Xe.hidden=!0,r.appendChild(se,Xe),r.appendChild(_,se),r.appendChild(e,_);const ri=()=>{if(O.length===0){k.checked=!1,k.indeterminate=!1;return}let re=0;for(let ce=0;ce<O.length;ce++)Y.has(O[ce].key)&&re++;re===0?(k.checked=!1,k.indeterminate=!1):re===O.length?(k.checked=!0,k.indeterminate=!1):(k.checked=!1,k.indeterminate=!0)},ni=()=>{var tn;const re=O.length;if(Ce.style.height=`${re*Cs}px`,Xe.hidden=re>0,Ce.hidden=re===0,re===0){Ce.textContent="";return}const ce=se.clientHeight||210,yt=se.scrollTop,to=Math.max(0,Math.floor(yt/Cs)-sl),Lt=Math.min(re-1,Math.ceil((yt+ce)/Cs)+sl),Ne=(tn=Ce.getRootNode)==null?void 0:tn.call(Ce),Ve=Ne&&"activeElement"in Ne?Ne.activeElement:null,Ot=Ve&&Ce.contains(Ve)?Ve.id:void 0;let Qr;Ce.textContent="";const en=e.ownerDocument.createDocumentFragment();for(let ms=to;ms<=Lt;ms++){const Nt=O[ms],Ct=r.createElement("div");r.addClass(Ct,"ge-table-filter-value-row"),Ct.style.top=`${ms*Cs}px`,Ct.style.height=`${Cs}px`;const vt=r.createElement("input"),ai=`${p}-v-${ms}`;r.setAttribute(vt,"type","checkbox"),r.setAttribute(vt,"id",ai),vt.checked=Y.has(Nt.key),Ot!==void 0&&ai===Ot&&(Qr=vt),vt.addEventListener("change",()=>{K=!1,vt.checked?Y.add(Nt.key):Y.delete(Nt.key),ri(),this.options.applyOnChange&&T()});const so=r.createElement("label");if(r.setAttribute(so,"for",ai),r.addClass(so,"ge-table-filter-value-label"),so.textContent=Nt.label,r.appendChild(Ct,vt),r.appendChild(Ct,so),Nt.count!==void 0){const ci=r.createElement("span");r.addClass(ci,"ge-table-filter-value-count"),ci.textContent=`${Nt.count}`,r.appendChild(Ct,ci)}en.appendChild(Ct)}Ce.appendChild(en),Ot!==void 0&&(Qr??se).focus({preventScroll:!0})};se.addEventListener("scroll",()=>ni(),{passive:!0}),k.addEventListener("change",()=>{K=!1;const re=k.checked;for(let ce=0;ce<O.length;ce++)re?Y.add(O[ce].key):Y.delete(O[ce].key);ri(),ni(),this.options.applyOnChange&&T()});const gs=(re,ce,yt)=>{yt&&(P=re,N=ce),O=re,be.hidden=!ce,ce&&(be.textContent=a.valuesTruncated(f)),se.scrollTop=0,ri(),ni()},li=(re,ce)=>{const yt=++this.loadGeneration;if(h!=null&&h.getValues){const Lt={columnIndex:t,columnDef:o,property:s,search:re,maxValues:f,otherFilters:l.getOtherFilters(s)},Ne=h.getValues(Lt);if(Ne&&typeof Ne.then=="function")Xe.textContent="…",Xe.hidden=!1,Ce.hidden=!0,Ne.then(Ve=>{if(this.destroyed||!this.popup.isOpen()||yt!==this.loadGeneration)return;Xe.textContent=a.noValues;const Ot=Array.isArray(Ve)?Ve:[];gs(te(Ot),Ot.length>=f,ce)}).catch(()=>{this.destroyed||!this.popup.isOpen()||yt!==this.loadGeneration||(Xe.textContent=a.noValues,gs([],!1,ce))});else{const Ve=Array.isArray(Ne)?Ne:[];gs(te(Ve),Ve.length>=f,ce)}return}if(!ce&&!N){const Lt=re.trim().toLowerCase(),Ne=Lt?P.filter(Ve=>Ve.label.toLowerCase().includes(Lt)):P;gs(Ne,!1,!1);return}const to=l.collectColumnDistinctValues(t,{maxValues:f,search:re||void 0});gs(te(to.items),to.truncated,ce)};V.addEventListener("input",()=>{this.clearSearchTimer();const re=V.value;!(h!=null&&h.getValues)&&!N?li(re,!1):this.searchTimer=setTimeout(()=>{this.searchTimer=void 0,li(re,!1)},120)}),li("",!0),g||(g=V)}const le=()=>{const _=I();let V=u==null?void 0:u.values;if(F){const k=$()&&!K?O.filter(W=>Y.has(W.key)):[];if(K)V=void 0;else if(k.length>0)V=k.map(W=>W.value);else if(N&&!(h!=null&&h.getValues)){const W=(u==null?void 0:u.values)===void 0,B=l.collectColumnDistinctValues(t,{maxValues:Number.POSITIVE_INFINITY}).items,be=[];for(let se=0;se<B.length;se++){const Ce=me(B[se].value);(Y.has(Ce)||W&&!U.has(Ce))&&be.push(B[se].value)}V=be.length===B.length?void 0:be}else if(!N&&P.length>0&&Y.size===P.length&&P.every(W=>Y.has(W.key)))V=void 0;else{const W=[];Y.forEach(B=>{W.push(U.get(B))}),V=W}}if(!_&&V===void 0)return;const z={};return _&&(z.condition=_),V!==void 0&&(z.values=V),z};T=()=>{l.setColumnFilter(s,le(),"menu")};const Te=r.createElement("div");r.addClass(Te,"ge-table-filter-menu-footer");const H=r.createElement("button");r.setAttribute(H,"type","button"),r.addClass(H,"ge-table-filter-btn"),r.addClass(H,"ge-table-filter-btn-clear"),H.textContent=a.clear,H.addEventListener("click",()=>{l.setColumnFilter(s,void 0,"menu"),this.close("action")});const ae=r.createElement("div");r.addClass(ae,"ge-table-filter-menu-footer-actions");const je=r.createElement("button");r.setAttribute(je,"type","button"),r.addClass(je,"ge-table-filter-btn"),r.addClass(je,"ge-table-filter-btn-cancel"),je.textContent=a.cancel,je.addEventListener("click",()=>{this.close("cancel")});const wt=r.createElement("button");return r.setAttribute(wt,"type","button"),r.addClass(wt,"ge-table-filter-btn"),r.addClass(wt,"ge-table-filter-btn-primary"),r.addClass(wt,"ge-table-filter-btn-ok"),wt.textContent=a.ok,wt.addEventListener("click",()=>{this.options.applyOnChange||T(),this.close("action")}),r.appendChild(Te,H),r.appendChild(ae,je),r.appendChild(ae,wt),r.appendChild(Te,ae),r.appendChild(e,Te),g}clearSearchTimer(){this.searchTimer!==void 0&&(clearTimeout(this.searchTimer),this.searchTimer=void 0)}}const Bu=8;class vc{constructor(e){this.scope=e,this.destroyed=!1,this.popup=new Br(e)}isOpen(){return this.popup.isOpen()}isInPopup(e){return this.popup.isInPopup(e)}open(e){if(this.destroyed)return;if(this.popup.isOpen()&&e&&this.lastAnchor===e){this.close("api");return}this.lastAnchor=e;const t=e?e.getBoundingClientRect():this.defaultAnchorRect(),s=this.scope.ariaTexts,o=s.columnChooserDialog?s.columnChooserDialog():"Choose columns",i=this.popup.open({ariaLabel:o,className:"ge-table-column-chooser",anchorRect:t,triggerEl:e,onClose:l=>this.handleClosed(e,l)}),r=this.renderContent(i);this.popup.reposition(t),this.popup.focusInitial(r)}close(e="api"){this.popup.close(e)}destroy(){this.destroyed||(this.destroyed=!0,this.lastAnchor=void 0,this.popup.destroy())}handleClosed(e,t){this.lastAnchor=void 0,!this.destroyed&&(t==="escape"||t==="action"||t==="cancel")&&(e&&e.isConnected?e.focus({preventScroll:!0}):this.scope.hostElement.focus({preventScroll:!0}))}defaultAnchorRect(){const e=this.scope.hostElement.getBoundingClientRect(),t=this.scope.tableModel.getPadding().top||34;return this.scope.isRtl()?{left:e.left,right:e.left+1,top:e.top,bottom:e.top+t,width:1,height:t}:{left:e.right-1,right:e.right,top:e.top,bottom:e.top+t,width:1,height:t}}collectColumns(){const e=this.scope.tableModel,t=e.getColumnCount(),s=[];for(let o=0;o<t;o++){const i=e.getColumnDef(o);!i||G(i)||Ae(i)||s.push({columnIndex:o,columnDef:i,label:this.scope.getColumnAriaLabel(o),property:i.property||`#${o}`,hideable:i.hideable!==!1})}return s}renderContent(e){const t=this.scope.getDomService().domService,s=this.scope.columnFilterService.getTexts(),o=this.collectColumns(),i=`${this.scope.ariaIds.prefix}-cc`;let r=null;const l=t.createElement("div");t.addClass(l,"ge-table-filter-menu-header");const a=t.createElement("span");t.addClass(a,"ge-table-filter-menu-title"),a.textContent=s.columnsTitle,t.appendChild(l,a),t.appendChild(e,l);const c=t.createElement("div");t.addClass(c,"ge-table-filter-menu-values");let h="",d;o.length>=Bu&&(d=t.createElement("input"),t.setAttribute(d,"type","search"),t.setAttribute(d,"autocomplete","off"),t.setAttribute(d,"autocorrect","off"),t.setAttribute(d,"autocapitalize","none"),t.setAttribute(d,"spellcheck","false"),t.setAttribute(d,"placeholder",s.searchColumnsPlaceholder),t.setAttribute(d,"aria-label",s.searchColumnsPlaceholder),t.addClass(d,"ge-table-filter-menu-search"),t.appendChild(c,d),r=d);const u=t.createElement("div");t.addClass(u,"ge-table-filter-select-all");const f=t.createElement("input"),p=`${i}-all`;t.setAttribute(f,"type","checkbox"),t.setAttribute(f,"id",p);const g=t.createElement("label");t.setAttribute(g,"for",p),g.textContent=s.selectAll,t.appendChild(u,f),t.appendChild(u,g),t.appendChild(c,u);const m=t.createElement("div");t.addClass(m,"ge-table-column-chooser-list"),t.setAttribute(m,"role","group"),t.setAttribute(m,"aria-label",s.columnsTitle),t.appendChild(c,m),t.appendChild(e,c);const b=()=>{const C=h.trim().toLowerCase();return C?o.filter(S=>S.label.toLowerCase().includes(C)||S.property.toLowerCase().includes(C)):o},w=()=>{let C=0;for(let S=0;S<o.length;S++)at(o[S].columnDef)&&C++;return C},y=()=>{const C=b(),S=w();let x=0;for(let I=0;I<C.length;I++)at(C[I].columnDef)&&x++;if(C.length===0||x===0?(f.checked=!1,f.indeterminate=!1):x===C.length?(f.checked=!0,f.indeterminate=!1):(f.checked=!1,f.indeterminate=!0),m.textContent="",C.length===0){const I=t.createElement("div");t.addClass(I,"ge-table-filter-values-empty"),I.textContent=s.noValues,t.appendChild(m,I);return}const R=e.ownerDocument.createDocumentFragment();for(let I=0;I<C.length;I++){const A=C[I],T=at(A.columnDef),F=T&&S<=1,P=!A.hideable||F,O=t.createElement("div");t.addClass(O,"ge-table-column-chooser-row");const N=t.createElement("input"),K=`${i}-c-${I}`;t.setAttribute(N,"type","checkbox"),t.setAttribute(N,"id",K),t.setAttribute(N,"data-col-property",A.property),N.checked=T,N.disabled=P,N.addEventListener("change",()=>{if(!N.checked&&w()<=1){N.checked=!0;return}this.scope.setColumnVisible(A.columnDef,N.checked),y()});const Y=t.createElement("label");t.setAttribute(Y,"for",K),t.addClass(Y,"ge-table-filter-value-label"),Y.textContent=A.label,t.appendChild(O,N),t.appendChild(O,Y),R.appendChild(O),!r&&!N.disabled&&(r=N)}m.appendChild(R)};return f.addEventListener("change",()=>{const C=b();if(f.checked)for(let x=0;x<C.length;x++)at(C[x].columnDef)||this.scope.setColumnVisible(C[x].columnDef,!0);else for(let x=C.length-1;x>=0;x--){const R=C[x];if(!(!R.hideable||!at(R.columnDef))){if(w()<=1)break;this.scope.setColumnVisible(R.columnDef,!1)}}y()}),d&&d.addEventListener("input",()=>{h=d.value,y()}),y(),r??f}}function Sc(n){return n?{"meta+shift+f":"FOCUS_COLUMN_FILTER","alt+arrowdown":"OPEN_COLUMN_FILTER_MENU"}:{"ctrl+shift+f":"FOCUS_COLUMN_FILTER","alt+arrowdown":"OPEN_COLUMN_FILTER_MENU"}}const Ie=class Ie extends ql{constructor(e,t,s,o,i,r=new He,l=new ha){var u;if(super(e,t,new go(s),o),this.eventListener=i,this.copyService=r,this.excelService=l,this.licenseManager=Et.getInstance(),this.listenerAbortController=new AbortController,this.destroyed=!1,this.selectionService=new De(this),this.api=new _l(this),this.initialized=!1,this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.lastDragFrom=-1,this.lastDragTo=-1,this.firstDraggingRendering=!0,this.editingOptions=Jo.create(At(this.tableOptions,"editing")),this.subscribers=new Set,this.clipboardOptions=Gs.create(At(this.tableOptions,"clipboard")),this.undoOptions=ti.create(At(this.tableOptions,"undo")),this.lastTabKeyTime=0,this.syncingTileFocus=!1,this.tileFocusKnown=!1,this.focusFrameDirty=!1,this.lastContextmenu=Date.now(),this.allExpanded=!0,this.selectionEventsHeld=0,t.setTableScope(this),this.liveAnnouncer=new So(e.ownerDocument,this.ariaIds.liveRegion(),s),this.eventListener=yu(i??new Fs,this.subscribers),this.stateService=new vo(this),this.columnFilterService=new bc(this),o!=null&&o.filterRow&&this.initFilterRowService(o.filterRow),o!=null&&o.columnFilterMenu){const f=Us.create(o.columnFilterMenu,this.columnFilterService.getOptions().maxValues);f&&(this.columnFilterMenuService=new qi(this,f,!0))}if(this.mouseHandler=new gl(this),this.inputHandler=new ta(this),this.resizeHandler=new ca(this,o.resizeEventDebounceDelay),this.shortcutService=new na(this),this.rowDragService=new ua(this),this.batchEditService=new ma(this),this.fillHandleService=new Ma(this),this.editingOptions){this.cellEditorService=new Pa(this,this.editingOptions);const f=t.getBodyModel();this.editingOptions.defaultEditable&&"defaultEditable"in f&&(f.defaultEditable=!0),this.setHostAriaAttribute("aria-description",this.getSheetTexts().gridEditingHint())}this.clipboardOptions&&(this.clipboardService=new Wi(this,this.clipboardOptions,!0)),this.undoOptions&&(this.undoService=new ic(this,this.undoOptions));const a=cs.create(At(o,"cellFormulas"));if(a&&(o.masterDetail?console.warn("GuiExpert Table – cellFormulas: no cell formulas with master/detail."):this.tableSheet=ei.create(t,a)),o!=null&&o.masterDetail&&(this.masterDetailService=new Ta(this,(f,p,g,m)=>new Ie(f,p,new Vi,this.nestedTableOptions(g),m??new Fs)),this.masterDetailService.isActive())){const f=(e.getAttribute("aria-owns")??"").split(" ").filter(Boolean),p=f.findIndex(g=>g.startsWith(this.ariaIds.rowGroup("footer","west")));f.splice(p<0?f.length:p,0,this.ariaIds.detailRowGroup()),this.setHostAriaAttribute("aria-owns",f.join(" ")),this.setHostAriaAttribute("role","treegrid")}this.shortcutService.addListener(this.selectionService);const c=this.getSelectionModel?this.getSelectionModel():void 0;c&&c.addEventSelectionChangedListener(this);const h=this.getFocusModel?this.getFocusModel():void 0;h&&h.addEventFocusChangedListener(this);const d=this.listenerAbortController.signal;(u=e.ownerDocument)==null||u.addEventListener("keydown",f=>{f.key==="Tab"&&(this.lastTabKeyTime=Date.now())},{capture:!0,signal:d}),e.addEventListener("focus",()=>this.onHostKeyboardFocus(),{signal:d}),e.addEventListener("keydown",f=>{!["Shift","Control","Alt","Meta"].includes(f.key)&&!Ie.isControlEvent(f)&&this.setKeyboardModality(!0)},{capture:!0,signal:d}),e.addEventListener("mousedown",f=>{Ie.isControlEvent(f)||this.setKeyboardModality(!1)},{capture:!0,signal:d}),this.scrollViewport.addEventListener("focus",()=>this.hostElement.focus({preventScroll:!0}),{signal:d})}nestedTableOptions(e){return e?e.direction!==void 0||!this.isRtl()?e:Object.assign(Object.create(e),{direction:this.direction}):{...new gt,direction:this.direction}}onHostKeyboardFocus(){const e=Date.now()-this.lastTabKeyTime<1e3;e&&this.setKeyboardModality(!0);const t=this.focusModel();if(!e||!t||this.headerFocus||this.isEditing())return;const[s,o]=t.getFocus(),i=this.tableModel.getBodyModel().getRowCount();if((s<0||o<0)&&i>0&&this.tableModel.getColumnCount()>0){const r=this.firstFullVisibleRowIndex>=0?this.firstFullVisibleRowIndex:Math.max(0,this.getBodyRowIndexAtY(this.contentScrollTop));this.setFocusCell(r,this.getFirstShownColumnIndex())}else i<1&&this.getAriaGridInfo().headerRowCount>0&&this.tableModel.getColumnCount()>0&&this.setHeaderFocus(this.getAriaGridInfo().headerRowCount-1,this.getFirstShownColumnIndex())}static create(e,t,s=new gt,o=new Fs,i=new Vi,r=new He){return new Ie(e,t,i,s,o,r)}onActionTriggered(e){var i,r,l,a,c;if(!this.headerFocus&&this.tableOverlay.isBlocking()&&Ie.actionsBlockedWhileLoading.includes(e))return!0;if(e==="FOCUS_COLUMN_FILTER"){const h=this.headerFocus?this.headerFocus[1]:(r=(i=this.focusModel())==null?void 0:i.getFocus())==null?void 0:r[1];return!!((l=this.filterRowService)!=null&&l.focusActiveOrFirstColumn(h!==void 0&&h>=0?h:void 0))}if(e==="OPEN_COLUMN_FILTER_MENU")return this.headerFocus&&((a=this.columnFilterMenuService)!=null&&a.isActive())?this.columnFilterMenuService.open(this.headerFocus[1]):!1;if(this.headerFocus){const h=this.onHeaderAction(e);if(h!==void 0)return h}if(e==="FILL_DOWN"||e==="FILL_RIGHT")return!this.headerFocus&&this.fillByKeyboard(e==="FILL_DOWN"?"down":"right");const t=this.onSheetAction(e);if(t!==void 0)return t;if(e==="MOVE_ROW_UP"||e==="MOVE_ROW_DOWN")return!this.headerFocus&&!!((c=this.rowDragService)!=null&&c.moveByKeyboard(e==="MOVE_ROW_UP"?-1:1));if(e==="NAVIGATE_UP"&&this.moveFocusIntoHeader())return!0;const s=this.onTileNavigation(e);if(s!==void 0)return s;const o=this.onBodyNavigation(e);if(o!==void 0)return o;if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const h=this.getFocusModel();if(h){const[d,u]=h.getFocus();this.tableModel.getBodyModel().isEditable(d,u)&&this.startEditing(d,u,"edit","end")}return!0}if(this.undoService&&(e==="UNDO"||e==="REDO"))return e==="UNDO"?this.undoService.undo():this.undoService.redo(),!0;if(this.clipboardService&&this.clipboardOptions&&(e==="COPY_2_CLIPBOARD"||e==="CUT_2_CLIPBOARD"||e==="PASTE_FROM_CLIPBOARD")){const h=e==="COPY_2_CLIPBOARD"?"copy":e==="CUT_2_CLIPBOARD"?"cut":"paste";if(this.shortcutKeyEvent){if(this.clipboardService.arm(h)||h!=="copy")return!1}else if(h!=="copy"||Object.getPrototypeOf(this.copyService)===He.prototype)return this.clipboardService.runWithoutKey(h),!0}if(e==="COPY_2_CLIPBOARD"){const h=this.getSelectionModel?this.getSelectionModel():void 0,d=this.getFocusModel?this.getFocusModel():void 0;this.copyService.createContent(this.tableModel,h,d).then(u=>u||!this.getTileLayout()?this.copyService.copyContent(u).then(()=>this.announceCopied(u)):void 0).catch(u=>console.warn("GuiExpert Table – copy to clipboard failed:",u))}return!1}getEditingOptions(){return this.editingOptions}getShortcutLayers(e){const t=[];(this.tableOptions.filterRow||this.filterRowService||this.tableOptions.columnFilterMenu||this.columnFilterMenuService)&&t.push(Sc(e));const s=this.editingOptions;if(this.clipboardOptions&&t.push(_a(e)),this.undoOptions&&t.push(Qa(e)),!s)return t;const o=Ba(e);return s.tabMoves||(delete o.tab,delete o["shift+tab"]),s.clearKeys||(delete o.delete,delete o.backspace),[o,...t]}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}startEditing(e,t,s="edit",o){var r,l,a;if((r=this.cellEditorService)!=null&&r.handlesColumn(t))return this.cellEditorService.start(e,t,{mode:s,textSelection:o});if(!this.tableModel.getBodyModel().isEditable(e,t))return!1;this.clearSelection(),this.initRenderEditor(e,t);const i=this.getInCellEditorCell();return i&&((a=(l=this.eventListener).onEditingChanged)==null||a.call(l,new qt("start",e,t,s))),!!i}canStartEditing(){var e,t;return!this.isDestroyed()&&!this.headerFocus&&!this.tableOverlay.isBlocking()&&!((e=this.rowDragService)!=null&&e.isDragging())&&!((t=this.fillHandleService)!=null&&t.isFilling())&&!this.editing}getShownCellValue(e,t){return this.batchEditService?this.batchEditService.getShownValue(e,t):this.getCellInput(e,t)}getActiveBodyCell(){const e=this.focusModel();if(!e||this.headerFocus)return;const[t,s]=e.getFocus(),o=this.tableModel.getBodyModel().getRowCount();return t>=0&&s>=0&&t<o&&s<this.tableModel.getColumnCount()?[t,s]:void 0}refreshAfterStructureChange(e){var r,l;const t=this.getEffectiveFilterFunction();if(t&&this.tableModel.externalFilterChanged(t),this.reapplySorting(),(r=this.batchEditService)==null||r.pruneOrphans(),e){for(const a of["header","body","footer"])(l=this.colAndRowspanModels[a])==null||l.init();this.firstInit(),this.stateService.markDirty("columns")}this.invalidateAggregates();const s=this.focusModel(),o=this.tableModel.getBodyModel().getRowCount(),i=this.tableModel.getColumnCount();if(s&&o>0&&i>0){const[a,c]=s.getFocus();if(a>=o||c>=i){const h=Math.min(Math.max(0,a),o-1),d=Math.min(Math.max(this.getFirstDataColumnIndex(),c),i-1);s.setFocus(h,d),this.selectionService.collapseTo(h,d)}}this.repaintHard()}nextShownColumn(e,t){return this.getNextShownColumnIndex(e,t,this.tableModel.getColumnCount())}hasShownColumnBeside(e,t){const s=this.getNextShownColumnIndex(e,t,this.tableModel.getColumnCount());return s!==e&&!G(this.tableModel.getColumnDef(s))}moveActiveCell(e,t,s,o){const i=this.focusModel();return i?(i.hasFocus(e,t)||i.setFocus(e,t),this.changeFocusCell(o,s)):!1}getSelectedBodyCells(e){return this.collectSelectedBodyCells(e)}collectSelectedBodyCells(e,t){const s=this.selectionModel();if(!t&&!(s!=null&&s.hasSelection())&&!(s!=null&&s.isAllSelected()))return[];const o=this.tableModel.getBodyModel().getRowCount(),i=this.tableModel.getColumnCount(),r=t??(s.isAllSelected()?[new M(0,0,o-1,i-1)]:s.getRanges()),l=h=>this.tableModel.getColumnWidth(h)>0&&!G(this.tableModel.getColumnDef(h)),a=[],c=r.length>1?new Set:void 0;for(const h of r){const d=Math.max(0,h.r1),u=Math.min(o-1,h.r2),f=Math.max(0,h.c1),p=Math.min(i-1,h.c2);if(u>=d&&p>=f&&(u-d+1)*(p-f+1)>e)return;for(let g=d;g<=u;g++)for(let m=f;m<=p;m++)if(!(!l(m)||!t&&!s.isSelected(g,m))){if(c){const b=g*i+m;if(c.has(b))continue;c.add(b)}if(a.push([g,m]),a.length>e)return}}return a}clearCells(e){var a,c;const t=((a=this.editingOptions)==null?void 0:a.maxClearCells)??He.maxCopyCells,s=this.collectSelectedBodyCells(t,e);if(!s)return this.announce(this.getSheetTexts().clearTooLarge(t)),-1;if(!s.length&&!e){const h=this.getActiveBodyCell();h&&s.push(h)}const o=this.tableModel.getBodyModel(),i=h=>h==null||h==="",r=[];for(const[h,d]of s){if(h<0||d<0||h>=o.getRowCount()||d>=this.tableModel.getColumnCount()||!o.isEditable(h,d)||i(this.getShownCellValue(h,d)))continue;const u=this.tableModel.getColumnDef(d),f=(u==null?void 0:u.emptyValue)!==void 0?u.emptyValue:((c=this.editingOptions)==null?void 0:c.emptyValue)??"";r.push({rowIndex:h,column:d,value:f})}const l=r.length?this.applyCellChanges(r,"clear"):[];return this.announce(this.getSheetTexts().cellsCleared(l.length)),l.length}commitCellEditor(e,t,s){var l;const o=e.map(([a,c])=>({rowIndex:a,column:c,value:t})),i=this.resolveCellChanges(o,e.length>1);if(!i.length)return{written:0,invalid:0};if((l=this.batchEditService)!=null&&l.isActive())return this.markPending(i.map(a=>({rowIndex:a.rowIndex,column:a.columnIndex,value:a.value})),!0),s?this.debounceRepaint():this.repaint(),{written:i.length,invalid:0};const r=this.writeCellsInternal(i,"edit",{deferRepaint:s});return{written:r.changes.length,invalid:r.invalid,message:r.message}}toggleBooleanCell(e,t){this.applyCellChanges([{rowIndex:e,column:t,value:!this.getShownCellValue(e,t)}],"edit")}getSheetTexts(){const e=this.ariaTexts??{},t=new Le;return{editingStarted:s=>(e.editingStarted??t.editingStarted).call(e,s),readOnlyCell:()=>(e.readOnlyCell??t.readOnlyCell).call(e),cellsCleared:s=>(e.cellsCleared??t.cellsCleared).call(e,s),clearTooLarge:s=>(e.clearTooLarge??t.clearTooLarge).call(e,s),rangeSelected:(s,o)=>(e.rangeSelected??t.rangeSelected).call(e,s,o),rowSelected:s=>(e.rowSelected??t.rowSelected).call(e,s),columnSelected:s=>(e.columnSelected??t.columnSelected).call(e,s),gridEditingHint:()=>(e.gridEditingHint??t.gridEditingHint).call(e),cellsPasted:(s,o)=>(e.cellsPasted??t.cellsPasted).call(e,s,o),pasteTooLarge:s=>(e.pasteTooLarge??t.pasteTooLarge).call(e,s),copyTooLarge:s=>(e.copyTooLarge??t.copyTooLarge).call(e,s),cutMarked:s=>(e.cutMarked??t.cutMarked).call(e,s),copiedLastRangeOnly:()=>(e.copiedLastRangeOnly??t.copiedLastRangeOnly).call(e)}}onSheetAction(e){var s,o;const t=this.editingOptions;if(t)switch(e){case"NAVIGATE_NEXT_CELL":case"NAVIGATE_PREVIOUS_CELL":{const i=this.getActiveBodyCell(),r=e==="NAVIGATE_NEXT_CELL"?1:-1;return!i||this.isEditing()||!this.hasShownColumnBeside(i[1],r)||r>0&&((s=this.masterDetailService)!=null&&s.hasTabTarget(i[0]))?!1:this.moveActiveCell(i[0],i[1],0,r)}case"EXTEND_SELECTION_UP":case"EXTEND_SELECTION_DOWN":case"EXTEND_SELECTION_LEFT":case"EXTEND_SELECTION_RIGHT":case"EXTEND_SELECTION_ROW_START":case"EXTEND_SELECTION_ROW_END":case"EXTEND_SELECTION_PAGE_UP":case"EXTEND_SELECTION_PAGE_DOWN":{const i=this.getSelectionExtent();if(!i||this.isEditing())return!1;const[r,l]=i,a=this.tableModel.getBodyModel().getRowCount(),c=this.tableModel.getColumnCount(),h=Math.max(1,this.displayedRowCount-1),d={EXTEND_SELECTION_UP:[Math.max(0,r-1),l],EXTEND_SELECTION_DOWN:[Math.min(a-1,r+1),l],EXTEND_SELECTION_LEFT:[r,this.getNextShownColumnIndex(l,-1,c)],EXTEND_SELECTION_RIGHT:[r,this.getNextShownColumnIndex(l,1,c)],EXTEND_SELECTION_ROW_START:[r,this.getFirstShownDataColumnIndex()],EXTEND_SELECTION_ROW_END:[r,this.getLastShownColumnIndex()],EXTEND_SELECTION_PAGE_UP:[Math.max(0,r-h),l],EXTEND_SELECTION_PAGE_DOWN:[Math.min(a-1,r+h),l]},[u,f]=d[e];return this.extendSelectionTo(u,G(this.tableModel.getColumnDef(f))?l:f)}case"NAVIGATE_DATA_EDGE_UP":case"NAVIGATE_DATA_EDGE_DOWN":case"NAVIGATE_DATA_EDGE_LEFT":case"NAVIGATE_DATA_EDGE_RIGHT":{const i=this.getActiveBodyCell();if(!i||this.isEditing())return!1;const[r,l]=this.dataEdge(i,e);return this.setFocusCell(r,l)}case"EXTEND_TO_DATA_EDGE_UP":case"EXTEND_TO_DATA_EDGE_DOWN":case"EXTEND_TO_DATA_EDGE_LEFT":case"EXTEND_TO_DATA_EDGE_RIGHT":{const i=this.getSelectionExtent();if(!i||this.isEditing())return!1;const[r,l]=this.dataEdge(i,e);return this.extendSelectionTo(r,l)}case"SELECT_ROW":case"SELECT_COLUMN":return this.selectWholeRowsOrColumns(e==="SELECT_ROW");case"CLEAR_CELLS":return!t.clearKeys||this.isEditing()||this.headerFocus?!1:(this.clearCells(),!0);case"CLEAR_AND_EDIT":{if(!t.clearKeys||this.isEditing()||this.headerFocus)return!1;const i=this.getActiveBodyCell(),r=this.collectSelectedBodyCells(1);return i&&r&&((o=this.cellEditorService)!=null&&o.handlesColumn(i[1]))&&this.tableModel.getBodyModel().isEditable(i[0],i[1])?(this.cellEditorService.start(i[0],i[1],{mode:"enter",typedText:""}),!0):(this.clearCells(),!0)}default:return}}getSelectionExtent(){if(!this.headerFocus)return this.selectionService.getExtent()??this.getActiveBodyCell()}getFirstShownDataColumnIndex(){const e=this.getFirstShownColumnIndex();return G(this.tableModel.getColumnDef(e))?this.getNextShownColumnIndex(e,1,this.tableModel.getColumnCount()):e}dataEdge(e,t){const s=t.endsWith("_UP")?-1:t.endsWith("_DOWN")?1:0,o=t.endsWith("_LEFT")?-1:t.endsWith("_RIGHT")?1:0;return rc((r,l)=>{const a=this.getShownCellValue(r,l);return a==null||a===""},this.tableModel.getBodyModel().getRowCount(),this.tableModel.getColumnCount(),e[0],e[1],s,o,r=>this.tableModel.getColumnWidth(r)>0&&!G(this.tableModel.getColumnDef(r)))}extendSelectionTo(e,t){const s=this.selectionService.extendTo(e,t);if(!s)return!1;this.ensureColumnIsVisible(t),this.ensureRowIsVisible(e),this.repaint();let o=0;for(let i=s.c1;i<=s.c2;i++)this.tableModel.getColumnWidth(i)>0&&o++;return this.announce(this.getSheetTexts().rangeSelected(s.r2-s.r1+1,o)),!0}selectWholeRowsOrColumns(e){const t=this.selectionModel(),s=this.getActiveBodyCell();if(!t||!s||this.isEditing()||t.selectionType!=="range")return!1;const o=t.getRanges(),i=o.length?o[o.length-1]:M.singleCell(s[0],s[1]),r=e?new M(i.r1,0,i.r2,Number.MAX_SAFE_INTEGER):new M(0,i.c1,Number.MAX_SAFE_INTEGER,i.c2);this.holdSelectionEvents(()=>{t.clear(),t.addSelection(r),this.onSelectionChanged(t)}),this.repaint();const l=this.getSheetTexts();return this.announce(e?l.rowSelected(i.r2-i.r1+1):l.columnSelected(i.c2-i.c1+1)),!0}getEventListener(){return this.eventListener}afterRowsMoved(){this.lastSortCompareFn=void 0,this.invalidateAggregates()}announce(e,t){e&&!this.isDestroyed()&&this.liveAnnouncer.announce(e,t)}showLoadingOverlay(e){this.tableOverlay.showLoading(e)}showNoRowsOverlay(e){this.tableOverlay.showNoRows(e)}hideOverlay(){this.tableOverlay.hide()}getOverlayState(){return this.tableOverlay.getState()}onOverlayChanged(e){this.isDestroyed()||(e.kind==="loading"?(this.setHostAriaAttribute("aria-busy","true"),this.tableOverlay.isBlocking()&&(this.hideHoverRow(),this.hideHoverColumn())):e.previous==="loading"&&(this.restoreHostAriaAttribute("aria-busy"),this.liveAnnouncer.cancel(this.lastLoadingAnnouncement)),e.kind==="loading"&&(this.lastLoadingAnnouncement=e.text),(e.kind==="loading"||e.kind==="noRows"&&this.initialized)&&this.announce(e.text))}announceCopied(e){this.announce(this.ariaTexts.copied(this.countCopiedCells()))}countCopiedCells(){const e=this.selectionModel();if(!(e!=null&&e.hasSelection()))return 1;const t=this.tableModel.getBodyModel().getRowCount(),s=this.tableModel.getColumnCount(),o=u=>{var f,p;return((p=(f=this.tableModel.getColumnDef(u))==null?void 0:f.isVisible)==null?void 0:p.call(f))!==!1};let i=0;for(let u=0;u<s;u++)o(u)&&i++;if(e.isAllSelected())return t*i;const r=e.getRanges();if(!r.length)return 1;const l=Math.max(0,Math.min(...r.map(u=>u.r1))),a=Math.min(t-1,Math.max(...r.map(u=>u.r2))),c=Math.max(0,Math.min(...r.map(u=>u.c1))),h=Math.min(s-1,Math.max(...r.map(u=>u.c2)));if((a-l+1)*(h-c+1)>He.maxCopyCells)return 0;let d=0;for(let u=l;u<=a;u++)for(let f=c;f<=h;f++)o(f)&&e.isSelected(u,f)&&d++;return d}getHeaderFocus(){return this.headerFocus?[this.headerFocus[0],this.headerFocus[1]]:void 0}setFocusCell(e,t){const s=this.focusModel();return s?(this.headerFocus=void 0,s.setFocus(e,t),this.ensureColumnIsVisible(t),this.ensureRowIsVisible(e),this.afterActiveCellMoved(e,t),this.repaint(),!0):!1}afterActiveCellMoved(e,t){var s;(s=this.editingOptions)!=null&&s.collapseSelectionOnNavigate&&this.selectionService.collapseTo(e,t)}getFirstShownColumnIndex(){return this.getNextShownColumnIndex(-1,1,this.tableModel.getColumnCount())}getLastShownColumnIndex(){const e=this.tableModel.getColumnCount();return this.getNextShownColumnIndex(e,-1,e)}onBodyNavigation(e){const t=this.focusModel();if(!["NAVIGATE_ROW_START","NAVIGATE_ROW_END","NAVIGATE_FIRST_CELL","NAVIGATE_LAST_CELL","NAVIGATE_PAGE_UP","NAVIGATE_PAGE_DOWN","ACTIVATE_CELL"].includes(e))return;if(!t||this.isEditing())return!1;const o=this.tableModel.getBodyModel().getRowCount();if(o<1||this.tableModel.getColumnCount()<1)return!1;const[i,r]=t.getFocus(),l=Math.min(Math.max(i,0),o-1),a=r<0?this.getFirstShownColumnIndex():r,c=Math.max(1,this.displayedRowCount-1);switch(e){case"NAVIGATE_ROW_START":return this.setFocusCell(l,this.getFirstShownColumnIndex());case"NAVIGATE_ROW_END":return this.setFocusCell(l,this.getLastShownColumnIndex());case"NAVIGATE_FIRST_CELL":return this.setFocusCell(0,this.getFirstShownColumnIndex());case"NAVIGATE_LAST_CELL":return this.setFocusCell(o-1,this.getLastShownColumnIndex());case"NAVIGATE_PAGE_UP":return this.setFocusCell(Math.max(0,l-c),a);case"NAVIGATE_PAGE_DOWN":return this.setFocusCell(Math.min(o-1,l+c),a);default:{if(i<0||r<0)return!1;if(this.activateBodyCell(i,r))return!0;const h=this.editingOptions;if(h){if(h.enterKey==="moveDown")return this.moveActiveCell(i,r,1,0);if(this.tableModel.getBodyModel().isEditable(i,r))return this.startEditing(i,r,"edit")}const d=this.shortcutKeyEvent;return d!=null&&d.repeat||this.activateCell(i,r,d?"keyboard":"api",d),!1}}}activateCell(e,t,s,o){var r,l;const i=this.tableModel.getBodyModel();return!(e>=0&&t>=0)||e>=i.getRowCount()||t>=this.tableModel.getColumnCount()||!this.canFocusBodyCell(e,t)||this.tableOverlay.isBlocking()?!1:((l=(r=this.eventListener).onCellActivated)==null||l.call(r,new cc("body",e,t,i.getValueAt(e,t),i.getRowByIndex(e),s,o)),!0)}getTileLayout(){var e,t;return(t=(e=this.tableModel.getBodyModel()).getTileLayout)==null?void 0:t.call(e)}canFocusBodyCell(e,t){const s=this.getTileLayout();if(!s)return!0;const o=Es(e,t,s.getTilesPerRow());return o>=0&&o<s.getTileCount()}onTileNavigation(e){const t=Ie.tileActions[e],s=t?this.getTileLayout():void 0;if(!t||!s)return;const o=this.focusModel(),i=s.getTileCount();if(!o||this.isEditing()||i<1)return!1;const r=Math.max(1,s.getTilesPerRow()),[l,a]=o.getFocus(),c=this.firstFullVisibleRowIndex>=0?this.firstFullVisibleRowIndex:Math.max(0,this.getBodyRowIndexAtY(this.contentScrollTop)),h=hc(Es(l,a,r),t,{count:i,perRow:r,pageRows:this.displayedRowCount-1,firstVisible:c*r}),[d,u]=Ui(h,r);return(d!==l||u!==a)&&(this.headerFocus=void 0,o.setFocus(d,u),this.showBodyRow(d)||this.repaint()),!0}showBodyRow(e){const t=this.getBodyRowTop(e),s=t+this.tableModel.getRowHeight("body",e),o=this.contentScrollTop,i=this.areaBodyCenterGeo.height,r=t<o?t:s>o+i?Math.min(t,s-i):void 0;return r===void 0||!this.setContentScrollPosition(void 0,r)?!1:(this.adjustAfterScrolling(),!0)}rememberFocusedTile(){const e=this.getTileLayout(),t=e?this.focusModel():void 0;if(!e||!t){this.focusedTile=void 0;return}const[s,o]=t.getFocus(),i=Es(s,o,e.getTilesPerRow()),r=i>=0&&i<e.getTileCount()?e.getTileAt(i):void 0;this.focusedTile=r===void 0?void 0:{item:r,index:i}}beforeRenderPass(){if(this.keepTileScrollAnchor(),this.focusFrameDirty&&(this.focusFrameDirty=!1,this.cancelPendingRepaint()),!this.tileFocusKnown){this.tileFocusKnown=!0,this.rememberFocusedTile();return}const e=this.focusedTile;if(!e||this.syncingTileFocus)return;const t=this.getTileLayout(),s=t?this.focusModel():void 0;if(!t||!s)return;const o=Math.max(1,t.getTilesPerRow()),i=t.getTileCount(),[r,l]=s.getFocus(),a=Es(r,l,o);if(a>=0&&a<i&&t.getTileAt(a)===e.item){e.index=a;return}let c=i>0?t.indexOfTile(e.item):-1;(c<0||c>=i)&&(c=Math.min(i-1,e.index)),this.syncingTileFocus=!0;try{if(c<0)s.clear();else{const[h,d]=Ui(c,o);s.setFocus(h,d)}}finally{this.syncingTileFocus=!1}this.rememberFocusedTile()}rememberTileScrollAnchor(){const e=this.getTileLayout(),t=this.renderedBodyRows;if(!e||!t||t.count<=0){this.tileScrollAnchor=void 0;return}const s=Math.max(1,e.getTilesPerRow()),o=e.getTileCount(),i=this.tileScrollAnchor;let r=t.first*s,l;i&&Math.floor(i.index/s)===t.first&&i.index<o&&e.getTileAt(i.index)===i.item?(r=i.index,l=i.item):l=r<o?e.getTileAt(r):void 0;const a=this.tableModel.getRowHeight("body",t.first);return this.tileScrollAnchor=l===void 0?void 0:{item:l,index:r,perRow:s,rowHeight:a,ratio:a>0?t.offset/a:0},this.tileScrollAnchor}anchorTileScroll(e){this.tileScrollAnchor=void 0;const t=this.rememberTileScrollAnchor(),s=this.getTileLayout();s&&t&&Math.floor(e/t.perRow)===Math.floor(t.index/t.perRow)&&e<s.getTileCount()&&(this.tileScrollAnchor={...t,item:s.getTileAt(e),index:e})}keepTileScrollAnchor(){const e=this.tileScrollAnchor,t=e?this.getTileLayout():void 0;if(!e||!t)return;const s=Math.max(1,t.getTilesPerRow()),o=Math.floor(e.index/e.perRow);if(s===e.perRow&&this.tableModel.getRowHeight("body",o)===e.rowHeight)return;const i=t.getTileCount(),r=e.index<i&&t.getTileAt(e.index)===e.item?e.index:t.indexOfTile(e.item);if(r<0||r>=i){this.tileScrollAnchor=void 0;return}e.index=r;const l=Math.floor(r/s);this.setContentScrollPosition(void 0,this.getBodyRowTop(l)+Math.round(e.ratio*this.tableModel.getRowHeight("body",l)))}static isControlEvent(e){const t=e.target instanceof Element?e.target:null;return!!(t!=null&&t.closest('input, select, textarea, button, a[href], [contenteditable]:not([contenteditable="false"])'))}setKeyboardModality(e){var s,o;if(this.keyboardModality===e||(this.keyboardModality=e,((s=this.tableOptions)==null?void 0:s.focusFrame)!=="keyboard"))return;const t=(o=this.focusModel())==null?void 0:o.getFocus();(this.headerFocus||t&&t[0]>=0&&t[1]>=0)&&(this.focusFrameDirty=!0,this.debounceRepaint())}activateBodyCell(e,t){var r;const s=this.tableModel.getBodyModel();if(s.isRowCheckable(e)&&(this.tableOptions.showCheckboxWihoutExtraColumn&&t===this.getFirstDataColumnIndex()||hr(s.getCellRenderer(e,t))))return this.toggleRowCheckbox(e,t,"body"),!0;if((r=this.masterDetailService)!=null&&r.isMasterAt(e))return this.toggleDetail(e,"keyboard");const i=s.getRowByIndex(e);if(J(i)&&ee(s)&&s.hasDisplayedChildren(i)){const l=i;return this.setTreeRowExpanded(l,!l.expanded)}return!1}moveFocusIntoHeader(){const e=this.focusModel();if(!e||this.isEditing()||this.headerFocus)return!1;const[t,s]=e.getFocus(),o=this.getAriaGridInfo().headerRowCount,i=this.tableModel.getBodyModel().getRowCount()<1;return t!==0&&!i||o<1||this.tableModel.getColumnCount()<1?!1:(this.setHeaderFocus(o-1,s<0?this.getFirstShownColumnIndex():s),!0)}setHeaderFocus(e,t){var o;const s=(o=this.colAndRowspanModels.header)==null?void 0:o.getRanges().find(i=>i.isInRange(e,t));this.headerFocus=s?[s.r1,s.c1]:[e,t],this.ensureColumnIsVisible(this.headerFocus[1]),this.repaint()}onHeaderAction(e){var c;const[t,s]=this.headerFocus,o=this.tableModel.getAreaModel("header"),i=this.getAriaGridInfo().headerRowCount,r=this.tableModel.getColumnCount(),l=Math.max(1,o.getColspanAt(t,s)||1),a=Math.max(1,o.getRowspanAt(t,s)||1);switch(e){case"NAVIGATE_LEFT":{const h=this.getNextShownColumnIndex(s,-1,r);return h!==s&&this.setHeaderFocus(t,h),!0}case"NAVIGATE_RIGHT":{const h=this.getNextShownColumnIndex(s+l-1,1,r);return h>s+l-1&&this.setHeaderFocus(t,h),!0}case"NAVIGATE_ROW_START":return this.setHeaderFocus(t,this.getFirstShownColumnIndex()),!0;case"NAVIGATE_ROW_END":return this.setHeaderFocus(t,this.getLastShownColumnIndex()),!0;case"NAVIGATE_UP":return t>0&&this.setHeaderFocus(t-1,s),!0;case"NAVIGATE_DOWN":return t+a<i?(this.setHeaderFocus(t+a,s),!0):(c=this.filterRowService)!=null&&c.isVisible()&&this.filterRowService.focusColumn(s)?(this.headerFocus=void 0,this.repaint(),!0):this.tableModel.getBodyModel().getRowCount()<1?!0:this.setFocusCell(Math.max(0,this.firstFullVisibleRowIndex),s);case"NAVIGATE_FIRST_CELL":case"NAVIGATE_LAST_CELL":case"NAVIGATE_PAGE_UP":case"NAVIGATE_PAGE_DOWN":this.headerFocus=void 0;return;case"ACTIVATE_CELL":return this.activateHeaderCell(t,s,a,i);case"START_EDITING":case"TOGGLE_SELECTION":return!0;default:return}}activateHeaderCell(e,t,s,o){var a;const i=this.tableModel.getAreaModel("header"),r=i.getValueAt(e,t);if(r&&typeof r=="object"&&r.toggle&&r.visibility!=="always"&&"toggleHeaderGroup"in i){const c=new mo(null,this);return c.rowIdx=e,c.colIdx=t,c.areaIdent="header",c.areaModel=i,this.toggleHeaderGroup(c),this.setHeaderFocus(e,t),!0}const l=this.tableModel.getColumnDef(t);return e+s>=o&&((a=l==null?void 0:l.sortable)!=null&&a.call(l))?(this.sortByColumn(t),!0):!1}cancelEditing(e){var s,o;const t=this.getInCellEditorCell();if(t&&((o=(s=this.eventListener).onEditingChanged)==null||o.call(s,new qt("cancel",t[0],t[1],"edit"))),e instanceof HTMLSelectElement){const i=Array.from(e.options).find(r=>r.defaultSelected);e.selectedIndex=i?i.index:-1}else e&&(e.value=e.defaultValue);this.resetEditorRenderer(),this.hostElement.focus(),this.repaint()}updateModelValueAfterEdit(e,t,s,o){var l,a,c;if(e!=="body")return;this.getInCellEditorCell()&&((a=(l=this.eventListener).onEditingChanged)==null||a.call(l,new qt("commit",t,s,"edit",o)));const i=()=>{this.resetEditorRenderer()};if((c=this.batchEditService)!=null&&c.isActive()){i(),this.markPending([{rowIndex:t,column:s,value:o}],!1),this.repaint(),this.hostElement.focus();return}const r=this.writeCellsInternal([{rowIndex:t,columnIndex:s,value:o}],"edit",{beforeRepaint:i});(r.changes.length||r.invalid)&&(r.changes.length||(i(),this.repaint()),this.hostElement.focus())}applyCellChanges(e,t="api",s={}){var i;const o=this.resolveCellChanges(e);if(!o.length)return[];if((i=this.batchEditService)!=null&&i.isActive()){const r=this.markPending(o.map(l=>({rowIndex:l.rowIndex,column:l.columnIndex,value:l.value})),!0,!1,t,s.undoable);return this.repaint(),r}return this.writeCellsInternal(o,t,{undoable:s.undoable}).changes}writeCells(e,t,s={}){return this.writeCellsInternal(e,t,s).changes}writeCellsInternal(e,t,s){var g,m,b,w,y,C,S,x,R,I;const o=this.tableModel.getBodyModel(),i=o.getRowCount(),r=ge(o)?o.getBuildCount():0,l=[];let a=0,c="";const h=this.tableSheet,d=()=>{for(const{rowIndex:A,columnIndex:T,value:F}of e){const P=!!(h!=null&&h.isFormulaInput(T,F));if(!s.skipValidation){const N=P?this.checkFormulaSyntax(F):this.validateCellValue(A,T,s.raw?F:this.pipeCellValue(A,T,F));if(N){a++,c=c||N;continue}}const O=this.getCellInput(A,T);(s.raw||P?this.setRawValue(A,T,F):o.setValue(A,T,F))&&l.push({row:this.rowObjectOf(A),rowIndex:A,columnIndex:T,property:this.batchEditService.propertyOf(T),oldValue:O,newValue:this.getCellInput(A,T)})}};ge(o)?o.batch(d):d(),a&&this.announce(this.getEditTexts().invalidValue(c));const u=(g=s.extraChanges)!=null&&g.length?[...l,...s.extraChanges]:l;if(!u.length)return{changes:u,invalid:a,message:c||void 0};h==null||h.cellsWritten(u),(m=this.undoService)==null||m.record(u,t,s.undoable),(b=s.beforeRepaint)==null||b.call(s);const f=(w=s.extraChanges)!=null&&w.length?void 0:{area:"body",rowIndices:l.map(A=>A.rowIndex)};this.invalidateAggregates(f),ge(o)&&o.getBuildCount()!==r||o.getRowCount()!==i||t==="commit"?this.repaintHard():s.deferRepaint?this.debounceRepaint():this.repaint(),this.invalidateAggregates(f),(y=this.undoService)==null||y.beginFold();try{if(t==="edit"&&u.length===1){const A=mt.createSingle(u[0].rowIndex,u[0].columnIndex);A.changes=u,A.source=t,(S=(C=this.eventListener).onModelChanged)==null||S.call(C,A)}else(R=(x=this.eventListener).onModelChanged)==null||R.call(x,mt.createForChanges(u,t))}finally{(I=this.undoService)==null||I.endFold()}return{changes:u,invalid:a,message:c||void 0}}writePastedCells(e,t,s){var i;const o=this.resolveCellChanges(e);if(!o.length)return[];if((i=this.batchEditService)!=null&&i.isActive()){const r=this.markPending(o.map(l=>({rowIndex:l.rowIndex,column:l.columnIndex,value:l.value})),!0,s,t);return this.repaint(),r}return this.writeCellsInternal(o,t,{raw:s}).changes}selectBodyRange(e){const t=this.focusModel();t&&(this.headerFocus=void 0,t.setFocus(e.r1,e.c1)),this.selectionService.collapseTo(e.r1,e.c1),(e.r2!==e.r1||e.c2!==e.c1)&&this.selectionService.extendTo(e.r2,e.c2),this.repaint()}checkPastedValue(e,t,s,o){var i;return(i=this.tableSheet)!=null&&i.isFormulaInput(t,s)?this.checkFormulaSyntax(s):this.validateCellValue(e,t,o?s:this.pipeCellValue(e,t,s))}getCellInput(e,t){const s=this.tableModel.getBodyModel();return this.tableSheet&&s.getInputValueAt?s.getInputValueAt(e,t):s.getValueAt(e,t)}getTypedCellValue(e,t){var o;const s=this.getShownCellValue(e,t);return(o=this.tableSheet)!=null&&o.isFormulaInput(t,s)?this.tableModel.getBodyModel().getValueAt(e,t):s}getFormulaErrorText(e){const t=this.ariaTexts??{};return(t.formulaError??new Le().formulaError).call(t,e)}checkFormulaSyntax(e){const t=this.tableSheet;return t.options.rejectInvalidFormulas?t.syntaxError(e):void 0}resolvePastedValue(e,t,s,o){if(!(e instanceof ks))return e;const i=this.tableSheet;return!i||!i.isFormulaColumnIndex(s)?e.value:o?e.input:i.moveFormula(e.input,e.row,e.col,t,s)??e.value}getCopyValue(e,t){var i;const s=this.tableSheet,o=this.getShownCellValue(e,t);return!s||(i=this.batchEditService)!=null&&i.getPendingAt(e,t)?o:s.copyOf(e,t,o,this.tableModel.getBodyModel().getValueAt(e,t))}isBatchEditActive(){var e;return!!((e=this.batchEditService)!=null&&e.isActive())}getUndoOptions(){return this.undoOptions}writeUndoCells(e,t,s){var r;if(!e.length&&!t.length)return[];const o=this.tableModel.getBodyModel();if((r=this.batchEditService)!=null&&r.isActive()){const l=e.length?this.markPending(e.map(a=>({rowIndex:a.rowIndex,column:a.columnIndex,value:a.value})),!0,!0,s):[];return this.repaint(),l}const i=this.writeCellsInternal(e,s,{raw:!0,skipValidation:!0,extraChanges:t}).changes;return t.length&&ge(o)&&(o.regroup(),this.invalidateAggregates(),this.repaintHard()),i}getUndoTexts(){const e=this.ariaTexts??{},t=new Le;return{undone:(s,o)=>(e.undone??t.undone).call(e,s,o),redone:(s,o)=>(e.redone??t.redone).call(e,s,o),nothingToUndo:()=>(e.nothingToUndo??t.nothingToUndo).call(e),nothingToRedo:()=>(e.nothingToRedo??t.nothingToRedo).call(e),undoSkipped:s=>(e.undoSkipped??t.undoSkipped).call(e,s),undoHistoryCleared:s=>(e.undoHistoryCleared??t.undoHistoryCleared).call(e,s)}}isOverlayBlocking(){return this.tableOverlay.isBlocking()}rowsAppended(){this.invalidateAggregates()}isRowGroupingOrTree(){const e=this.tableModel.getBodyModel();return ee(e)||ge(e)||po(this.tableModel)}getClipboardService(){return this.clipboardService||(this.clipboardService=new Wi(this,Gs.create(!0),!1)),this.clipboardService}markPending(e,t,s=!1,o="edit",i){const r=t?e.map(d=>({rowIndex:d.rowIndex,columnIndex:d.column,value:d.value})):this.resolveCellChanges(e,!1),l=this.batchEditService,a=this.undoService?r.map(({rowIndex:d,columnIndex:u})=>{const f=l.rowKeyOf(d),p=l.propertyOf(u),g=l.getPendingEntry(f,p);return{rowKey:f,property:p,before:g?{...g}:void 0}}):void 0,c=r.map(({rowIndex:d,columnIndex:u,value:f})=>{var m;if((m=this.tableSheet)!=null&&m.isFormulaInput(u,f)){const b=this.checkFormulaSyntax(f);return{rowIndex:d,columnIndex:u,value:f,rawValue:f,...b?{error:b}:{}}}const p=s?f:this.pipeCellValue(d,u,f),g=this.validateCellValue(d,u,p);return{rowIndex:d,columnIndex:u,value:p,rawValue:f,...g?{error:g}:{}}}),h=l.addPending(c);if(a&&h.length){for(const d of a){const u=l.getPendingEntry(d.rowKey,d.property);d.after=u?{...u}:void 0}this.undoService.recordPending(a.filter(d=>!d.before!=!d.after||!!d.before&&!!d.after&&!as(d.before.newValue,d.after.newValue)),o,i)}return h}resolveCellChanges(e,t=!0){var a,c;const s=this.tableModel.getBodyModel(),o=s.getRowCount(),i=this.tableModel.getColumnCount(),r=((c=(a=this.tableModel).getColumnDefs)==null?void 0:c.call(a))??[],l=[];for(const h of e){const d=typeof h.column=="number"?h.column:r.findIndex(f=>f.property===h.column),u=h.rowIndex;u>=0&&u<o&&d>=0&&d<i&&(t&&!s.isEditable(u,d)||l.push({rowIndex:u,columnIndex:d,value:h.value}))}return l}pipeCellValue(e,t,s){var i;const o=(i=this.tableModel.getColumnDef(t))==null?void 0:i.editInputPipe;return o?o(s,e,t):s}validateCellValue(e,t,s){var r;const o=(r=this.tableModel.getColumnDef(t))==null?void 0:r.validate;if(!o)return;const i=o(s,this.rowObjectOf(e));return i?String(i):void 0}rowObjectOf(e){const t=this.tableModel.getBodyModel().getRowByIndex(e);return J(t)?t.data:t}getFillHandleOptions(){return Ws.create(At(this.tableOptions,"fillHandle"))}fillRange(e,t,s,o="auto",i){const r=this.getFillHandleOptions()??Ws.create(!0),l=this.tableModel.getBodyModel(),a=l.getRowCount(),c=this.tableModel.getColumnCount(),h=this.normalizeRange(e,a,c);if(!h||s<1)return 0;const d=t==="down"?a-1-h.r2:t==="up"?h.r1:t==="right"?c-1-h.c2:h.c1,u=Math.min(s,d);if(u<1)return 0;const f=t==="down"||t==="up"?h.c2-h.c1+1:h.r2-h.r1+1;if(u*f>r.maxCells)return this.announce(this.getEditTexts().fillTooLarge(r.maxCells)),-1;const p=this.batchEditService,g=Ea({source:h,direction:t,count:u,mode:o,getValue:(w,y)=>p.getShownValue(w,y),isFillable:(w,y)=>this.tableModel.getColumnWidth(y)>0&&l.isEditable(w,y),fillValue:r.fillValue,getCellInfo:(w,y)=>{var C;return{row:this.rowObjectOf(w),property:((C=this.tableModel.getColumnDef(y))==null?void 0:C.property)??""}}});this.tableSheet&&this.moveFilledFormulas(g,h,t);const m=this.applyCellChanges(g,"fill"),b=this.selectionModel();return b&&this.holdSelectionEvents(()=>{b.clear(),b.addSelection(i??Or(h,t,u)),this.onSelectionChanged(b)}),this.repaint(),this.announce(this.getEditTexts().cellsFilled(m.length)),m.length}moveFilledFormulas(e,t,s){const o=this.tableSheet,i=t.r2-t.r1+1,r=t.c2-t.c1+1,l=(a,c)=>(a%c+c)%c;for(const a of e){const c=a.rowIndex,h=a.column,d=s==="down"?t.r1+l(c-t.r2-1,i):s==="up"?t.r2-l(t.r1-1-c,i):c,u=s==="right"?t.c1+l(h-t.c2-1,r):s==="left"?t.c2-l(t.c1-1-h,r):h,f=this.getShownCellValue(d,u);if(!o.isFormulaInput(u,f))continue;const p=o.physicalRow(d),g=o.engineColumn(u);if(p===void 0||g===void 0)continue;const m=o.moveFormula(f,p,g,c,h);m!==void 0&&(a.value=m)}}getFillSourceRange(){const e=this.selectionModel();if(!e||e.selectionType!=="range"||e.isAllSelected())return;const t=e.getRanges();if(t.length)return this.normalizeRange(t[t.length-1],this.tableModel.getBodyModel().getRowCount(),this.tableModel.getColumnCount())}normalizeRange(e,t,s){const o=Math.max(0,Math.min(e.r1,e.r2)),i=Math.min(t-1,Math.max(e.r1,e.r2)),r=Math.max(0,Math.min(e.c1,e.c2)),l=Math.min(s-1,Math.max(e.c1,e.c2));return o<=i&&r<=l?new M(o,r,i,l):void 0}fillByKeyboard(e){var r;const t=this.getFillHandleOptions(),s=e==="down";if(!t||this.isEditing()||(r=this.fillHandleService)!=null&&r.isFilling()||t.direction===(s?"horizontal":"vertical"))return!1;const o=this.getFillSourceRange();if(!o)return!1;const i=s?o.r2-o.r1:o.c2-o.c1;if(i>0){const l=s?new M(o.r1,o.c1,o.r1,o.c2):new M(o.r1,o.c1,o.r2,o.c1);this.fillRange(l,e,i,"copy")}else if(s?o.r1>0:o.c1>0){const l=s?new M(o.r1-1,o.c1,o.r1-1,o.c2):new M(o.r1,o.c1-1,o.r2,o.c1-1);this.fillRange(l,e,1,"copy",o)}return!0}setHostKeyShortcuts(e){e===void 0?this.restoreHostAriaAttribute("aria-keyshortcuts"):this.setHostAriaAttribute("aria-keyshortcuts",e)}getEditTexts(){const e=this.ariaTexts,t=new Le;return{cellsFilled:s=>(e.cellsFilled??t.cellsFilled).call(e,s),fillTooLarge:s=>(e.fillTooLarge??t.fillTooLarge).call(e,s),pendingChanges:s=>(e.pendingChanges??t.pendingChanges).call(e,s),changesCommitted:s=>(e.changesCommitted??t.changesCommitted).call(e,s),changesDiscarded:()=>(e.changesDiscarded??t.changesDiscarded).call(e),commitBlocked:s=>(e.commitBlocked??t.commitBlocked).call(e,s),invalidValue:s=>(e.invalidValue??t.invalidValue).call(e,s)}}getApi(){return this.api}firstInit(){const e=this.getAvailableColumnWidth();e>0&&this.setParentWidth(e),this.stateService.initBeforeModel(),this.tableModel.init(),this.stateService.initAfterModel();const t=this.getEffectiveFilterFunction();return t&&this.applyFilterFunction(t,!1,!1),this.stateService.initAfterFilter(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.stateService.initAfterLayout(),this.liveAnnouncer.getElement(),this.initialized=!0,this}destroy(){var s,o,i,r,l,a,c,h,d,u,f;if(this.destroyed)return;try{this.stateService.destroy()}catch(p){console.error(p)}(o=(s=this.columnDrag)==null?void 0:s.keyAbort)==null||o.abort(),this.columnDrag=void 0;try{(i=this.rowDragService)==null||i.destroy()}catch(p){console.error(p)}(r=this.fillHandleService)==null||r.destroy(),(l=this.cellEditorService)==null||l.destroy(),(a=this.clipboardService)==null||a.destroy(),(c=this.filterRowService)==null||c.destroy(),(h=this.columnFilterMenuService)==null||h.destroy(),(d=this.columnChooserService)==null||d.destroy(),(u=this.tableSheet)==null||u.destroy(),this.subscribers.clear();try{(f=this.masterDetailService)==null||f.destroy()}catch(p){console.error(p)}this.destroyed=!0,this.listenerAbortController.abort(),this.resizeHandler.disconnect();const e=this.getSelectionModel?this.getSelectionModel():void 0;e==null||e.removeEventSelectionChangedListener(this);const t=this.getFocusModel?this.getFocusModel():void 0;t==null||t.removeEventFocusChangedListener(this),this.disposeRendering(),this.tableOverlay.destroy(),this.liveAnnouncer.destroy(),this.removeHostAria(),this.hostElement.innerText=""}isEventInDetail(e){var t;return!!((t=this.masterDetailService)!=null&&t.isInLayer(e))}setDetailExpanded(e,t,s="api"){var o;return!!((o=this.masterDetailService)!=null&&o.setExpanded(e,t,s))}toggleDetail(e,t="api"){const s=this.masterDetailService;return!!s&&s.setExpanded(e,!s.isExpanded(e),t)}onDetailToggled(e,t,s,o,i=!0,r=!1){var l,a,c,h,d,u;if(r||this.invalidateRowLayout(),this.resetSizeOfWrapperDiv(),this.repaint(),i&&((a=(l=this.eventListener).onDetailExpandedChanged)==null||a.call(l,new Ia(e,t,s,o))),o==="mouse"||o==="keyboard"){const f=s?(h=(c=this.ariaTexts).detailExpanded)==null?void 0:h.call(c):(u=(d=this.ariaTexts).detailCollapsed)==null?void 0:u.call(d);f&&this.announce(f)}this.stateService.markDirty("details")}onDetailHeightChanged(){this.destroyed||(this.resetSizeOfWrapperDiv(),this.adjustAfterScrolling())}takeFocusFromDetail(e){const t=this.focusModel();if(t&&e>=0){const s=t.getFocus()[1];this.headerFocus=void 0,t.setFocus(e,s>=0?s:this.getFirstShownColumnIndex())}this.hostElement.focus({preventScroll:!0})}focusDetailMaster(e){const t=this.focusModel();if(!t||e<0)return;const s=t.getFocus()[1];this.setFocusCell(e,s>=0?s:this.getFirstShownColumnIndex())}isDestroyed(){return this.destroyed}createGeMouseEvent(e){if(!e)return new Vs;const t=this.getMouseEventTarget(e),[s,o]=this.getAreaAndSideIdentByAttr(t);return this.createGeMouseEventForCell(e,{areaIdent:s,sideIdent:o,rowIndex:this.getNumberByAttr(t,"data-row-index"),columnIndex:this.getNumberByAttr(t,"data-col-index"),action:this.getStringByAttr(t,"data-ge-action")})}createGeMouseEventForCell(e,t){const s=new Vs;if(s.originalEvent=e,s.areaIdent=t.areaIdent,s.sideIdent=t.sideIdent,s.rowIndex=t.rowIndex,s.columnIndex=t.columnIndex,s.action=t.action,s.areaIdent){const o=this.tableModel.getAreaModel(s.areaIdent);s.rowTop=s.areaIdent==="body"?this.getBodyRowTop(s.rowIndex):o.getYPosByRowIndex(s.rowIndex)}return s.columnLeft=this.tableModel.getXPosByColumnIndex(s.columnIndex),s}getMouseEventTarget(e){let t=e.target;if(t instanceof Element&&!t.isConnected&&Number.isFinite(e.clientX)&&Number.isFinite(e.clientY)&&(t=this.getCellElementAtPoint(e.clientX,e.clientY)??t),(t===this.scrollViewport||t===this.contentWrapperDiv||t===this.contentDiv)&&this.tableModel.getPadding().bottom>0){const s=this.scrollViewport.getBoundingClientRect(),o=e.clientX-s.left,i=e.clientY-s.top>=this.scrollViewport.clientHeight||o<this.scrollViewport.clientLeft||o>=this.scrollViewport.clientLeft+this.scrollViewport.clientWidth,r=this.hostElement.getRootNode();if(!i&&r.elementsFromPoint){const l=r.elementsFromPoint(e.clientX,e.clientY).find(a=>this.hostElement.contains(a)&&a.closest(".ge-table-footer"));if(l)return l}}return t}getCellElementAtPoint(e,t){var o;const s=this.hostElement.getRootNode();return(o=s.elementsFromPoint)==null?void 0:o.call(s,e,t).find(i=>this.hostElement.contains(i)&&!!i.closest("[data-col-index]"))}onMouseDown(e){var o;this.selectionService.onMouseDown(),this.resetColumnDrag();const t=e.columnIndex,s=e.action==="resize-column";if(t>-1&&(s||e.action==="drag-column")&&(s?this.isColumnResizable(t):this.isColumnMovable(t))&&(this.mouseStartWidth=this.tableModel.getColumnWidth(t),this.mouseStartAction=e.action,this.mouseStartColumnIndex=t,this.mouseStartAction==="drag-column"&&(this.firstDraggingRendering=!0,this.dragFrom=this.mouseStartColumnIndex),s?this.tableOptions.columnsResizable:this.tableOptions.columnsDraggable&&((o=this.tableSheet)==null?void 0:o.allowsColumnDrag())!==!1)){const r=this.tableModel.getColumnDef(t);this.columnDrag={kind:s?"resize":"move",source:"mouse",columnIndex:t,currentIndex:t,columnDef:r,startWidth:this.mouseStartWidth,moves:[],started:!1,cancelled:!1}}}resetColumnDrag(){var e,t;(t=(e=this.columnDrag)==null?void 0:e.keyAbort)==null||t.abort(),this.columnDrag=void 0,this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.firstDraggingRendering=!0}beginColumnDrag(e){var l;const t=this.columnDrag;if(!t||t.cancelled)return!1;if(t.started)return!0;const s=e.draggingX||0,o=e.draggingY||0,i=((l=this.mouseHandler)==null?void 0:l.clickMoveTolerance)??4;if(s*s+o*o<=i*i)return!1;t.started=!0;const r=new AbortController;return t.keyAbort=r,(this.hostElement.ownerDocument??document).addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),this.cancelColumnDrag(a))},{capture:!0,signal:r.signal}),this.emitColumnDragEvent(t,"start",e.originalEvent),!t.cancelled&&this.columnDrag===t&&!this.isDestroyed()}isColumnDragging(){var e;return!!((e=this.columnDrag)!=null&&e.started)&&!this.columnDrag.cancelled}cancelColumnDrag(e){var s;const t=this.columnDrag;if(!(!t||!t.started||t.cancelled)){if(t.cancelled=!0,(s=t.keyAbort)==null||s.abort(),t.kind==="resize")this.tableModel.setColumnWidth(t.columnIndex,t.startWidth),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows();else{this.hideDraggingColumn(),this.draggingTargetColumnIndex=-1;for(let o=t.moves.length-1;o>=0;o--){const[i,r]=t.moves[o];this.tableModel.changeColumnOrder(r,i)}t.moves=[],t.currentIndex=t.columnIndex,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.stateService.markDirty("selection")}this.stateService.markDirty("columns"),this.emitColumnDragEvent(t,"cancel",e)}}emitColumnDragEvent(e,t,s){var i,r,l,a,c,h,d,u,f,p,g;const o=(i=e.columnDef)==null?void 0:i.property;if(e.kind==="resize"){const m=t==="start"?e.startWidth:this.tableModel.getColumnWidth(e.columnIndex),b=new lc(t,e.source,e.columnIndex,e.columnDef,o,e.startWidth,m,s);t==="start"?(l=(r=this.eventListener).onColumnResizeStart)==null||l.call(r,b):(c=(a=this.eventListener).onColumnResizeEnd)==null||c.call(a,b)}else{const m=(((d=(h=this.tableModel).getColumnDefs)==null?void 0:d.call(h))??[]).map(w=>w==null?void 0:w.property),b=new ac(t,e.columnIndex,t==="start"?e.columnIndex:e.currentIndex,e.columnDef,o,m,s);t==="start"?(f=(u=this.eventListener).onColumnMoveStart)==null||f.call(u,b):(g=(p=this.eventListener).onColumnMoveEnd)==null||g.call(p,b)}}mouseDraggingOnFrame(e,t){var s,o;(o=(s=this.eventListener).onMouseDragging)==null||o.call(s,e),this.mouseEvent=e,!((this.mouseStartAction==="resize-column"||this.mouseStartAction==="drag-column")&&!this.beginColumnDrag(e))&&(this.mouseStartAction==="resize-column"?this.resizeColumn(e):!this.mouseStartAction&&this.selectionService.onMouseDragging(e,t)?this.repaint():this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&(this.moveDraggedColumn(e.columnIndex),t&&(this.adjustDraggingColumn(e,this.dragFrom,this.firstDraggingRendering),this.firstDraggingRendering=!1),this.repaint()))}moveDraggedColumn(e){var i;const t=this.tableModel,s=t.getColumnCount();let o=bd(this.dragFrom,e,s,t.getFixedLeftColumnCount(),t.getFixedRightColumnCount());for(;this.dragFrom>-1&&o!==this.dragFrom&&!this.isColumnMovable(o);)o+=o>this.dragFrom?-1:1;if(this.dragFrom>-1&&o!==this.dragFrom&&!(this.lastDragFrom===o&&this.lastDragTo===this.dragFrom)){const r=Array.from({length:s},(a,c)=>this.isColumnMovable(c)),l=md(r,this.dragFrom,o);l!=null&&l.length&&(l.forEach(([a,c])=>t.changeColumnOrder(a,c)),(i=this.columnDrag)==null||i.moves.push(...l),this.lastDragFrom=this.dragFrom,this.lastDragTo=o,this.dragFrom=o,this.columnDrag&&(this.columnDrag.currentIndex=o),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows())}this.draggingTargetColumnIndex=this.dragFrom}mouseDraggingEndOnFrame(e){var o,i;(i=(o=this.eventListener).onMouseDraggingEnd)==null||i.call(o,e),this.draggingTargetColumnIndex=-1;const t=this.columnDrag;t&&this.beginColumnDrag(e);const s=!!t&&t.started&&!t.cancelled;this.mouseStartAction==="resize-column"?s&&(this.resizeColumn(e),this.stateService.markDirty("columns")):this.mouseStartAction==="drag-column"&&(s&&e.columnIndex>-1&&(this.moveDraggedColumn(e.columnIndex),this.draggingTargetColumnIndex=-1),this.hideDraggingColumn(),s&&(this.repaint(),this.stateService.markDirty("columns"),this.stateService.markDirty("selection"))),this.resetColumnDrag(),s&&this.emitColumnDragEvent(t,"end",e.originalEvent)}mouseMove(e){var t,s;(s=(t=this.eventListener).onMouseMoved)==null||s.call(t,e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){var s,o,i,r;const t=Date.now();if(t-this.lastContextmenu<50){this.lastContextmenu=t,(s=e.originalEvent)==null||s.preventDefault(),(o=e.originalEvent)==null||o.stopImmediatePropagation();return}this.lastContextmenu=t,(r=(i=this.eventListener).onContextmenu)==null||r.call(i,e)}toggleExpandCollapseAll(e=!0){const t=this.tableModel.getBodyModel();ee(t)&&(t.toggleExpandCollapseAll(e),this.allExpanded=e,this.repaintHard(),this.stateService.markDirty("tree"))}setTreeRowExpanded(e,t){const s=this.tableModel.getBodyModel();return!ee(s)||e.expanded===t?!1:(e.expanded=t,s.recalcVisibleTreeRows(!1),this.repaintHard(),this.stateService.markDirty("tree"),!0)}setRowGroupBy(e){const t=this.tableModel.getBodyModel();return ge(t)?(t.setGroupBy(e),Pi(this.tableModel),this.invalidateAggregates(),this.tableModel.recalcPadding(),this.repaintHard(),this.stateService.markDirty("tree"),this.stateService.markDirty("columns"),!0):!1}setPivotConfig(e,t){var o,i;const s=this.tableModel;if(!po(s))return!1;s.setPivotConfig(e,t),(s.getColumnDefs()??[]).forEach(r=>r.sortState=void 0),this.lastSortCompareFn=void 0,this.clearSelection(),(o=this.getFocusModel?this.getFocusModel():void 0)==null||o.clear();for(const r of["header","body","footer"])(i=this.colAndRowspanModels[r])==null||i.init();return this.invalidateAggregates(),this.firstInit(),this.repaintHard(),this.stateService.markDirty("columns"),this.stateService.markDirty("sort"),this.stateService.markDirty("tree"),this.stateService.markDirty("headerGroups"),!0}toggleRowCheckbox(e,t,s){var a,c,h;const o=this.tableModel.getAreaModel(s),i=o.isRowChecked(e),r=i===void 0||i==="semi"||i==="none";o.setRowChecked(e,r),this.repaint();const l=(a=o.rowSelectionModel)==null?void 0:a.getCheckedRows();(h=(c=this.eventListener).onCheckboxChanged)==null||h.call(c,l?l.slice():[]),this.stateService.markDirty("checked")}onMouseClicked(e,t){if(this.headerFocus=void 0,e.clickCount>1)return!1;let s=this.selectionService.onMouseClicked(e,t);if(!s&&this.getFocusModel){this.resetEditorRenderer();const o=this.getFocusModel();o&&(s=o.hasChanged(),o.clearChanged())}return s}debounceRepaint(){this.debounce(this.repaint.bind(this),1)}cancelPendingRepaint(){return this.debounceTimeout?(clearTimeout(this.debounceTimeout),this.debounceTimeout=null,!0):!1}publishGeMouseEvent(e){var t,s;(s=(t=this.eventListener).onMouseClicked)==null||s.call(t,e)}onFocusChanged(e){var t,s;this.rememberFocusedTile(),(s=(t=this.eventListener).onFocusChanged)==null||s.call(t,e)}stateChanged(e){var t,s;(s=(t=this.eventListener).onStateChanged)==null||s.call(t,e)}afterRenderPass(){var e,t,s,o,i;this.rememberTileScrollAnchor(),(e=this.stateService)==null||e.rendered(),(t=this.filterRowService)==null||t.update(),(s=this.fillHandleService)==null||s.update(),(o=this.cellEditorService)==null||o.update(),(i=this.clipboardService)==null||i.update()}onSelectionChanged(e){var t,s,o;if((t=this.stateService)==null||t.markDirty("selection"),this.selectionEventsHeld>0){this.heldSelectionModel=e;return}(o=(s=this.eventListener).onSelectionChanged)==null||o.call(s,e)}holdSelectionEvents(e){var t,s;this.selectionEventsHeld++;try{e()}finally{if(this.selectionEventsHeld--,this.selectionEventsHeld===0&&this.heldSelectionModel){const o=this.heldSelectionModel;this.heldSelectionModel=void 0,(s=(t=this.eventListener).onSelectionChanged)==null||s.call(t,o)}}}getEffectiveFilterFunction(){return this.columnFilterService.getEffectiveFilterFunction()}applyFilterFunction(e,t=!0,s=!0,o=!1){if(t&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(e),this.reapplySorting(),this.invalidateAggregates(),o?this.scrollViewport.scrollTop=0:this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),s&&this.repaint(),this.initialized){const i=this.tableModel.getBodyModel().getRowCount();this.announce(this.ariaTexts.filtered(i),Ie.filterAnnouncementDelayInMs)}}reapplyFilterAfterSetRows(e){this.tableModel.externalFilterChanged(e),this.reapplySorting(),this.invalidateAggregates()}externalFilterChanged(e=!0){const t=this.getEffectiveFilterFunction();t&&this.applyFilterFunction(t,e,!0)}setColumnFilter(e,t){this.columnFilterService.setColumnFilter(e,t,"api")}getColumnFilter(e){return this.columnFilterService.getColumnFilter(e)}getColumnFilters(){return this.columnFilterService.getColumnFilters()}setColumnFilters(e){this.columnFilterService.setColumnFilters(e,"api")}clearColumnFilters(){this.columnFilterService.clearColumnFilters("api")}isColumnFiltered(e){return this.columnFilterService.isColumnFiltered(e)}getHeaderExtraHeight(){var e;return((e=this.filterRowService)==null?void 0:e.getReservedHeight())??0}getFilterRowCount(){var e;return(e=this.filterRowService)!=null&&e.isVisible()?1:0}isEventInFilterUI(e){var t,s,o;return!!((t=this.filterRowService)!=null&&t.isInLayer(e))||!!((s=this.columnFilterMenuService)!=null&&s.isInPopup(e))||!!((o=this.columnChooserService)!=null&&o.isInPopup(e))}showColumnFilterMenu(e){if(!this.columnFilterMenuService){const t=Us.create(!0,this.columnFilterService.getOptions().maxValues);this.columnFilterMenuService=new qi(this,t,!1)}return this.columnFilterMenuService.open(e)}toggleColumnFilterMenu(e){return this.columnFilterMenuService?this.columnFilterMenuService.toggle(e):!1}hideColumnFilterMenu(){var e;(e=this.columnFilterMenuService)==null||e.close("api")}showColumnChooser(e){this.columnChooserService||(this.columnChooserService=new vc(this)),this.columnChooserService.open(e)}hideColumnChooser(){var e;(e=this.columnChooserService)==null||e.close("api")}hasFilterRow(){return!!this.filterRowService}isFilterRowVisible(){var e;return!!((e=this.filterRowService)!=null&&e.isVisible())}setFilterRowVisible(e){if(e&&!this.filterRowService)this.initFilterRowService(!0);else if(this.filterRowService){if(!this.filterRowService.setVisible(e))return}else return;this.recalcWrappers(),this.stateService.markDirty("filters")}restoreFilterRowVisible(e){if(!this.filterRowService)return!1;const t=this.filterRowService.setVisible(e);return t&&this.tableModel.recalcPadding(),t}onColumnFiltersChanged(e){var t;(t=this.filterRowService)==null||t.syncFromFilters(e)}clearHeaderFocusForFilterRow(){this.headerFocus&&(this.headerFocus=void 0,this.repaint())}focusHeaderFromFilterRow(e){const t=this.getAriaGridInfo().headerRowCount;t>0&&this.setHeaderFocus(t-1,e),this.hostElement.focus({preventScroll:!0})}focusBodyFromFilterRow(e){const t=this.tableModel.getBodyModel().getRowCount();this.headerFocus=void 0,t>0&&this.setFocusCell(Math.max(0,this.firstFullVisibleRowIndex),e),this.hostElement.focus({preventScroll:!0})}initFilterRowService(e){const t=oi.create(e);if(!t)return;this.filterRowService=new Cc(this,t);const s=(this.hostElement.getAttribute("aria-owns")??"").split(" ").filter(Boolean),o=this.ariaIds.rowGroup("body","west"),i=s.indexOf(o),r=[this.ariaIds.filterRowGroup("west"),this.ariaIds.filterRowGroup("center"),this.ariaIds.filterRowGroup("east")];s.splice(i<0?s.length:i,0,...r),this.setHostAriaAttribute("aria-owns",s.join(" "))}onHeaderDblClicked(e,t,s){const o=this.tableModel.getColumnDef(s);o!=null&&o.sortable&&o.sortable()&&(e.preventDefault(),e.stopPropagation(),this.sortByColumn(s))}sortByColumn(e,t){var h;const s=typeof e=="number"?e:(this.tableModel.getColumnDefs()??[]).findIndex(d=>d.property===e),o=this.tableModel.getColumnDef(s);if(!o)return!1;const i=o.sortStatesOrder?o.sortStatesOrder:this.tableOptions.sortOrder,r=o.sortState??"",l=t??i[(i.indexOf(r)+1)%i.length],a=new Is(s,l),c=this.tableModel.doSort([a]);return c&&(this.invalidateAggregates(),this.lastSortCompareFn=void 0,(h=this.tableModel.getColumnDefs())==null||h.forEach(d=>d.sortState=""),o.sortState=l),this.repaint(),c&&this.stateService.sortedByColumn(l?o.property:void 0),c&&this.announce(this.ariaTexts.sorted(this.getColumnAriaLabel(s),l)),!0}scrollToPixel(e,t){this.setContentScrollPosition(e,t)&&this.adjustAfterScrolling()}scrollToIndex(e,t){const s=this.getBodyRowTop(t);this.scrollToPixel(this.getScrollLeftForColumnIndex(e),s)}getScrollLeftForColumnIndex(e){const t=this.scrollViewport,s=this.tableModel.getFixedLeftColumnCount(),o=this.tableModel.getColumnCount()-this.tableModel.getFixedRightColumnCount()-1;if(e>=0&&e<s)return 0;if(!(e>=s&&e<=o))return this.getViewportScrollLeft();let i=0;for(let a=s;a<e;a++)i+=this.tableModel.getColumnWidth(a);const r=this.tableModel.getContentWidthInPixel()-this.areaBodyCenterGeo.width,l=t.scrollWidth-t.clientWidth;return r<=0||l<=0?0:Math.min(1,i/r)*l}adjustAfterScrolling(){var t,s;if(super.adjustAfterScrolling(),this.adjustingRowNumberWidth)return;const e=this.scrollViewport;(s=(t=this.eventListener).onScroll)==null||s.call(t,new sa(this.scrollTop,this.scrollLeft,e.scrollHeight,e.scrollWidth,e.clientHeight,e.clientWidth,this.scrollFactorY,this.scrollFactorX))}setSelectionModel(e,t=!1){var o;(o=this.selectionModel())==null||o.removeEventSelectionChangedListener(this),e.addEventSelectionChangedListener(this);const s=()=>e;this.tableOptions.getSelectionModel=s,this.getSelectionModel=s,this.selectionService.getSelectionModel=s,t&&this.repaint()}toggleHeaderGroup(e){const t=this.tableModel.getAreaModel("header");"columnDefs"in this.tableModel&&(this.tableModel.columnDefs=t.toggleHeaderGroup(e)),this.headerGroupsChanged()}setHeaderGroupCollapsed(e,t){var i;const s=this.tableModel.getAreaModel("header"),o=(i=s.setGroupClosed)==null?void 0:i.call(s,e,t);return o?("columnDefs"in this.tableModel&&(this.tableModel.columnDefs=o),this.headerGroupsChanged(),!0):!1}headerGroupsChanged(){this.firstInit(),this.stateService.markDirty("headerGroups"),this.stateService.markDirty("columns")}selectionModel(){if(this!=null&&this.getSelectionModel)return this.getSelectionModel()}focusModel(){if(this!=null&&this.getFocusModel)return this.getFocusModel()}setDragging(e){this.dragging=e,this.dragging?(this.storeColumnWidths(),this.lastDragFrom=-1,this.lastDragTo=-1):this.storedColumnWidths=[]}changeFocusCell(e,t){var s;if(!this.isEditing()&&this.getFocusModel){const o=this.getFocusModel();if(o){const i=this.tableModel.getBodyModel().getRowCount(),r=this.tableModel.getColumnCount();if(i<1||r<1)return!1;const[l,a]=o.getFocus(),c=Math.min(Math.max(l+t,0),i-1),h=this.getNextShownColumnIndex(a,e,r);return c!==l||h!==a?(o.setFocus(c,h),this.ensureColumnIsVisible(h),this.ensureRowIsVisible(c),this.afterActiveCellMoved(c,h),this.repaint()):(s=this.editingOptions)!=null&&s.collapseSelectionOnNavigate&&(this.afterActiveCellMoved(c,h),this.repaint()),!0}}return!1}getNextShownColumnIndex(e,t,s){if(!t){const l=Math.min(Math.max(e,0),s-1);return e<0&&this.tableModel.getColumnWidth(l)<=0?this.getNextShownColumnIndex(-1,1,s):l}const o=t>0?1:-1;let i=e,r=e;for(let l=Math.abs(t);l>0;l--){for(r+=o;r>=0&&r<s&&this.tableModel.getColumnWidth(r)<=0;)r+=o;if(r<0||r>=s)break;i=r}return Math.min(Math.max(i,0),s-1)}resizeColumn(e){const t=this.isRtl()?-e.draggingX:e.draggingX,s=this.clampToColumnWidthLimits(this.mouseStartColumnIndex,this.mouseStartWidth+t,this.mouseStartWidth);this.tableModel.setColumnWidth(this.mouseStartColumnIndex,s),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clampToColumnWidthLimits(e,t,s){var c,h,d;const o=(d=(h=(c=this.tableModel).getColumnDefs)==null?void 0:h.call(c))==null?void 0:d[e];if(!o)return t;const i=this.getAvailableColumnWidth(),r=u=>{if(!(!u||!Number.isFinite(u.value))){if(u.unit==="px")return u.value;if(u.unit==="%"&&i>0)return Math.floor(u.value*i/100)}};let l=r(o.minWidth),a=r(o.maxWidth);return l!==void 0&&a!==void 0&&l>a||(s!==void 0&&s>=0&&(l!==void 0&&(l=Math.min(l,s)),a!==void 0&&(a=Math.max(a,s))),l!==void 0&&(t=Math.max(l,t)),a!==void 0&&(t=Math.min(a,t))),t}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}calcAutoColumnWidths(){if(!this.tableModel.getBodyModel())return console.warn("Body model is not available."),[];const e=Array.from({length:this.tableModel.getColumnCount()},(t,s)=>s);return this.measureDefaultColumnWidths(e,new Dt(this.hostElement))}measureDefaultColumnWidths(e,t){const s=e.map(()=>new Set),o=e.map(()=>0);return["header","body","footer"].forEach(i=>{const r=this.tableModel.getAreaModel(i),[l,a]=i==="body"?this.getMeasuredBodyRows():[0,((r==null?void 0:r.getRowCount())??0)-1];vu(r,l,a,e,s,o)}),s.map(i=>t.measureWidest(i))}getMeasuredBodyRows(){var i;const e=((i=this.tableModel.getBodyModel())==null?void 0:i.getRowCount())??0;if(e<=this.getColumnAutoWidthOptions().maxRows)return[0,e-1];const t=this.renderedBodyRows,s=Math.min(Math.max(0,t.first),e-1),o=t.last>=s?Math.min(t.last,e-1):Math.min(s+50,e-1);return[s,o]}getColumnAutoWidthOptions(){return si.create(this.tableOptions.columnAutoWidth)}calcAutoColumnWidth(e,t,s,o){let i=o;const r=()=>(i===void 0&&(i=this.measureDefaultColumnWidths([e],s)[0]),i),l=this.getColumnAutoWidthOptions().getWidth;let a;if(l){const c=this.tableModel.getColumnDef(e),h={columnIndex:e,columnDef:c,property:c==null?void 0:c.property,source:t,firstRenderedRow:this.renderedBodyRows.first,lastRenderedRow:this.renderedBodyRows.last,measureText:u=>s.measureText(u),getDefaultWidth:r},d=l(h);a=typeof d=="number"&&Number.isFinite(d)&&d>=0?Math.round(d):void 0}return this.clampToColumnWidthLimits(e,a??r())}autoResizeColumn(e){const t=this.resolveColumnIndex(e);if(t<0||!this.isColumnAutoResizable(t))return;const s=this.calcAutoColumnWidth(t,"api",new Dt(this.hostElement));return this.tableModel.setColumnWidth(t,s),this.recalcWrappers(),this.stateService.markDirty("columns"),s}autoResizeColumnByUser(e,t){if(!this.tableOptions.columnsResizable||!this.getColumnAutoWidthOptions().doubleClick||e<0||e>=this.tableModel.getColumnCount()||!this.isColumnAutoResizable(e))return!1;const s=this.tableModel.getColumnWidth(e),o=this.tableModel.getColumnDef(e),i={kind:"resize",source:"dblclick",columnIndex:e,currentIndex:e,columnDef:o,startWidth:s,moves:[],started:!0,cancelled:!1},r=this.calcAutoColumnWidth(e,"dblclick",new Dt(this.hostElement)),l=this.columnDrag;this.columnDrag=i;try{if(this.emitColumnDragEvent(i,"start",t),i.cancelled||this.isDestroyed())return!0;this.tableModel.setColumnWidth(e,r),this.recalcWrappers(),this.stateService.markDirty("columns"),this.emitColumnDragEvent(i,"end",t)}finally{this.columnDrag===i&&(this.columnDrag=l)}return!0}isColumnAutoResizable(e){var s;const t=this.tableModel.getColumnDef(e);return this.isColumnResizable(e)&&!G(t)&&((s=t==null?void 0:t.isVisible)==null?void 0:s.call(t))!==!1}resolveColumnIndex(e){var o,i;const t=this.tableModel.getColumnCount();if(typeof e=="number")return Number.isInteger(e)&&e>=0&&e<t?e:-1;const s=((i=(o=this.tableModel).getColumnDefs)==null?void 0:i.call(o))??[];return typeof e=="string"?s.findIndex(r=>r.property===e):s.indexOf(e)}setColumnWidth(e,t){this.tableModel.setColumnWidth(e,t),this.stateService.markDirty("columns")}setColumnVisible(e,t){var s,o;return(o=(s=this.tableModel).setColumnVisible)!=null&&o.call(s,e,t)?(this.recalcWrappers(),this.stateService.markDirty("columns"),!0):!1}setHeaderVisible(e){this.setAreaVisible("header",e)}setFooterVisible(e){this.setAreaVisible("footer",e)}setAreaVisible(e,t){const s=this.tableModel,o=e==="header"?s.setHeaderVisible:s.setFooterVisible;if(!o){console.warn(`set${e==="header"?"Header":"Footer"}Visible() needs a table model with this method (e.g. TableModel), this one has none:`,s);return}o.call(s,t),e==="header"&&!t&&(this.headerFocus=void 0),this.recalcWrappers()}autoResizeColumns(e=!0){const t=this.tableModel.getColumnCount();if(!this.tableModel.getBodyModel()){console.warn("Body model is not available.");return}const s=new Dt(this.hostElement),o=Array.from({length:t},(r,l)=>l),i=this.measureDefaultColumnWidths(o,s);for(let r=0;r<t;r++)this.isColumnAutoResizable(r)&&this.tableModel.setColumnWidth(r,this.calcAutoColumnWidth(r,"api",s,i[r]));e&&this.recalcWrappers(),this.stateService.markDirty("columns")}recalcWrappers(){this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}appendRows(e,t={}){const s=this.tableModel.getBodyModel();if(!s.appendRows||this.tableSheet||this.isRowGroupingOrTree())return console.warn("appendRows() works with an AreaModelObjectArray body (TableFactory.createTableModel({ rows })) without cell formulas – use rowsAppended() for an own area model. Nothing changed."),!1;const o=s.appendRows(e,{filter:this.getEffectiveFilterFunction(),compare:this.getActiveSortComparator(),maxRows:t.maxRows});return o?this.afterRowsAppended(o,t.follow??"auto"):(console.warn("appendRows(): the body model did not append the rows."),!1)}notifyRowsAppended(e,t={}){const s=Math.max(0,this.tableModel.getBodyModel().getRowCount()),o=Math.max(0,Math.min(Math.floor(e)||0,s)),i=this.renderedBodyRows.count,r=Math.max(0,Math.min(Math.floor(t.removedAtStart??0)||0,i)),l=new Int32Array(r);for(let c=0;c<r;c++)l[c]=c;const a=new Int32Array(o);for(let c=0;c<o;c++)a[c]=s-o+c;return this.afterRowsAppended({added:o,shown:o,removed:r,removedPositions:l,insertedPositions:a},t.follow??"auto")}getActiveSortComparator(){var s,o;if(this.lastSortCompareFn)return this.lastSortCompareFn;const e=[];(s=this.tableModel.getColumnDefs())==null||s.forEach((i,r)=>{(i.sortState==="asc"||i.sortState==="desc")&&e.push(new Is(r,i.sortState))});const t=this.tableModel.getBodyModel();return e.length?(o=t.createSortComparator)==null?void 0:o.call(t,e):void 0}afterRowsAppended(e,t){var m,b,w,y,C,S;const s=new nc(e.removedPositions,e.insertedPositions),o=this.renderedBodyRows,i=this.selectionModel(),r=((m=i==null?void 0:i.adjustForRowChanges)==null?void 0:m.call(i,s))??!1;(w=(b=this.focusModel())==null?void 0:b.adjustForRowChanges)==null||w.call(b,s),this.selectionService.adjustForRowChanges(s),this.mouseHandler.adjustForRowChanges(s),this.shiftEditorRow(s);const l=this.tableModel.getBodyModel().getRowCount(),a=this.focusModel();a&&l>0&&a.getFocus()[0]>=l&&a.setFocus(l-1,a.getFocus()[1]),e.removed&&((y=this.batchEditService)==null||y.pruneOrphans());const c=this.colAndRowspanModels.body;c&&!c.updateForInsertedRows(e.insertedPositions)&&!s.isEmpty()&&c.init(),this.invalidateAggregates();const h=this.mouseHandler.isButtonDown()||!!((C=this.rowDragService)!=null&&C.isDragging())||!!((S=this.fillHandleService)!=null&&S.isFilling()),d=this.followHeldAt,u=o.atEnd||d!==void 0&&Math.abs(this.contentScrollTop-d)<1,f=t===!0||t==="auto"&&u&&!h;let p;if(f)p=Number.MAX_SAFE_INTEGER;else if(o.count>0){const x=s.mapIndex(o.first)>=0,R=Math.min(s.mapIndexOrNext(o.first),Math.max(0,l-1));p=l>0?this.getBodyRowTop(R)+(x?o.offset:0):0}else p=0;return!f&&s.getRemovedCount()===0&&o.count>0&&o.last<o.count-1&&!s.touchesUpTo(o.last)&&this.canKeepDrawnRows()&&this.updateRowCountWithoutRender(p)||this.repaintHard({py:p}),this.followHeldAt=t==="auto"&&h&&u?this.contentScrollTop:void 0,r&&i&&this.onSelectionChanged(i),{added:e.added,shown:e.shown,removed:e.removed,following:f}}canKeepDrawnRows(){var s;if(this.getFirstDataColumnIndex()>0||this.masterDetailService||this.tableModel.isRowCheckboxVisible()||this.tableOptions.showCheckboxWihoutExtraColumn)return!1;const e=this.tableModel.getAreaModel("footer");if(e.getRowCount()>0&&e.invalidateDerivedValues)return!1;const t=this.tableModel.getBodyModel();return!((s=t.hasDerivedColumns)!=null&&s.call(t))}reSort(){this.reapplySorting(),this.invalidateAggregates(),this.repaint()}sort(e){var t;this.tableModel.sort(e),this.invalidateAggregates(),this.lastSortCompareFn=e,(t=this.tableModel.getColumnDefs())==null||t.forEach(s=>s.sortState=""),this.repaint(),this.stateService.sortedByColumn(void 0)}applySortItems(e){const t=this.tableModel.getColumnDefs();t==null||t.forEach(s=>s.sortState=""),e.forEach(s=>{const o=t==null?void 0:t[s.columnIndex];o&&(o.sortState=s.sortState)}),e.length&&(this.lastSortCompareFn=void 0,this.tableModel.doSort(e),this.invalidateAggregates())}reapplySorting(){var t;if(this.lastSortCompareFn){this.tableModel.sort(this.lastSortCompareFn);return}const e=[];(t=this.tableModel.getColumnDefs())==null||t.forEach((s,o)=>{s.sortState&&e.push(new Is(o,s.sortState))}),e.length&&this.tableModel.doSort(e)}ensureRowIsVisible(e){if(this.hasBodyRowExtras()){const i=this.getBodyRowTop(e),r=i+this.tableModel.getRowHeight("body",e),l=this.contentScrollTop,a=this.areaBodyCenterGeo.height;return i<l?(this.scrollToPixel(this.getViewportScrollLeft(),i),!0):r>l+a?(this.scrollToPixel(this.getViewportScrollLeft(),r-a),!0):!1}const t=this.getFirstFullVisibleRowIndex(),s=this.getLastFullVisibleRowIndex(),o=this.getDisplayedRowCount();return e<t?(this.scrollToIndex(-1,e),!0):e>s?(this.scrollToIndex(-1,e-o+1),!0):!1}ensureColumnIsVisible(e){const t=this.tableModel.getFixedLeftColumnCount(),s=this.tableModel.getColumnCount()-this.tableModel.getFixedRightColumnCount()-1;if(!(e>=t&&e<=s))return!1;const o=this.tableModel.getColumnWidth(e),i=this.scrollViewport,r=this.areaBodyCenterGeo.width,l=this.tableModel.getContentWidthInPixel()-r,a=i.scrollWidth-i.clientWidth;if(o<=0||l<=0||a<=0)return!1;let c=0;for(let f=t;f<e;f++)c+=this.tableModel.getColumnWidth(f);const h=Math.min(1,Math.max(0,this.getViewportScrollLeft()/a))*l;let d;if(c<h-.5)d=c;else if(c+o>h+r+.5)d=o>r?c:c+o-r;else return!1;const u=Math.min(1,Math.max(0,d/l))*a;return this.setViewportScrollLeft(d===c?Math.floor(u):Math.ceil(u)),this.adjustAfterScrolling(),!0}};Ie.actionsBlockedWhileLoading=["START_EDITING","TOGGLE_SELECTION","ACTIVATE_CELL","MOVE_ROW_UP","MOVE_ROW_DOWN","FILL_DOWN","FILL_RIGHT","CLEAR_CELLS","CLEAR_AND_EDIT","CUT_2_CLIPBOARD","PASTE_FROM_CLIPBOARD","UNDO","REDO"],Ie.filterAnnouncementDelayInMs=400,Ie.tileActions={NAVIGATE_LEFT:"previous",NAVIGATE_RIGHT:"next",NAVIGATE_UP:"up",NAVIGATE_DOWN:"down",NAVIGATE_ROW_START:"first",NAVIGATE_FIRST_CELL:"first",NAVIGATE_ROW_END:"last",NAVIGATE_LAST_CELL:"last",NAVIGATE_PAGE_UP:"pageUp",NAVIGATE_PAGE_DOWN:"pageDown"};let Ji=Ie;class _u extends Fs{constructor(e){super(),this.onCheckboxChangedCallback=e,super.onCheckboxChanged=t=>{this.onCheckboxChangedCallback(t)}}}const Oo=class Oo{};Oo.themes=["light","combat","paper","blackboard"],Oo.vars={light:`html[data-theme="light"] {
72
72
  --ge-table-bg: rgba(255,255,255, 0.5);
73
73
  --ge-table-header-west-bg: rgba(233, 233, 233, 0.5);
74
74
  --ge-table-header-center-bg: rgba(233, 233, 233, 0.5);