@jh-grid/jhgrid-js 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -32
- package/dist/jhgrid.esm.js +74 -26
- package/dist/jhgrid.js +74 -26
- package/dist/jhgrid.min.js +10 -10
- package/package.json +1 -1
package/dist/jhgrid.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var hs=Object.prototype.hasOwnProperty;var ds=(r,t)=>{for(var e in t)_e(r,e,{get:t[e],enumerable:!0})},us=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cs(t))!hs.call(r,i)&&i!==e&&_e(r,i,{get:()=>t[i],enumerable:!(s=as(t,i))||s.enumerable});return r};var _s=r=>us(_e({},"__esModule",{value:!0}),r);var qs={};ds(qs,{BuiltinRenderers:()=>pt,CellEditors:()=>Ht,CellRenderers:()=>pt,DEFAULT_THEME:()=>qt,DataManager:()=>Yt,GRID_CLASSES:()=>B,JA_I18N:()=>Zt,JHGrid:()=>te,KO_I18N:()=>Jt,Renderer:()=>Gt,SUPPORTED_BROWSERS:()=>Xs,VERSION:()=>Us,ZH_I18N:()=>Qt,computeHeaderCells:()=>zt,registerCellEditor:()=>xe,registerCellRenderer:()=>be});var Yt=class{#t;#e;#i;#o=new Map;#s=new Set;#n=new Set;#a=new Set;#l=0;#r=new Map;#c;#h;#d=!1;onChunkLoaded=null;onChunkError=null;constructor({fetchData:t,chunkSize:e=300,maxChunks:s=50,maxInFlight:i=2,maxQueued:o=4}){this.#t=t,this.#e=e,this.#i=s,this.#c=Math.max(1,i),this.#h=Math.max(1,o)}getRow(t){let e=Math.floor(t/this.#e);if(this.#o.has(e)){let s=this.#o.get(e);return this.#o.delete(e),this.#o.set(e,s),s[t%this.#e]??null}return this.#u(e),null}setRow(t,e){let s=Math.floor(t/this.#e),i=this.#o.get(s);i&&(i[t%this.#e]=e)}insertAt(t,e){let s=e,i=t;for(;s!==void 0;){let o=Math.floor(i/this.#e),n=this.#o.get(o);if(!n)break;let l=i%this.#e;if(l>n.length)break;let a=l<n.length?n[n.length-1]:void 0;for(let c=n.length-1;c>l;c--)n[c]=n[c-1];n[l]=s,s=a,i=(o+1)*this.#e}}prefetch(t,e){let s=Math.floor(t/this.#e),i=Math.floor(e/this.#e);for(let o=s;o<=i+1;o++)this.#u(o)}async loadAll(t,e){let s=Math.floor(t/this.#e),i=Math.floor(e/this.#e),o=[];for(let a=s;a<=i;a++)o.push(a);let n=0,l=async()=>{for(;n<o.length;)await this.#p(o[n++])};await Promise.all(Array.from({length:this.#c},l))}#u(t){if(!(this.#o.has(t)||this.#s.has(t)||this.#n.has(t))){for(this.#r.delete(t),this.#r.set(t,!0);this.#r.size>this.#h;)this.#r.delete(this.#r.keys().next().value);this.#_()}}setHold(t){let e=this.#d;this.#d=!!t,!(!e||this.#d)&&(this.#r.clear(),this.#_())}#_(){if(!this.#d)for(;this.#s.size<this.#c&&this.#r.size>0;){let t;for(let e of this.#r.keys())t=e;this.#r.delete(t),this.#p(t)}}setFetch(t){this.#t=t,this.#l++,this.clear()}async#p(t){if(this.#o.has(t)||this.#s.has(t)||this.#n.has(t))return;this.#s.add(t);let e=this.#l;try{let s;for(let i=0;i<3;i++){if(e!==this.#l)return;try{let{rows:o}=await this.#t(t,this.#e);if(e!==this.#l)return;if(!Array.isArray(o))throw new TypeError("fetchData must resolve { rows: [] }");this.#o.set(t,o),this.#g(),this.onChunkLoaded?.();return}catch(o){if(s=o,o instanceof TypeError)break;i<2&&await new Promise(n=>setTimeout(n,500*2**i))}}if(e===this.#l){console.error(`[DataManager] chunk ${t} failed after retries:`,s),this.onChunkError?.(s,t),this.#n.add(t);let i=setTimeout(()=>{this.#n.delete(t),this.#a.delete(i)},5e3);this.#a.add(i)}}finally{this.#s.delete(t),this.#_()}}#g(){for(;this.#o.size>this.#i;){let t=this.#o.keys().next().value;this.#o.delete(t)}}forEachLoaded(t){for(let[e,s]of[...this.#o]){let i=e*this.#e;for(let o=0;o<s.length;o++)if(t(s[o],i+o)===!1)return}}clear(){this.#o.clear(),this.#s.clear(),this.#r.clear(),this.#n.clear(),this.#a.forEach(clearTimeout),this.#a.clear()}};function fe(r){return r==null?[]:Array.isArray(r)?r:[r]}function ke(r,t,e,s){if(t===e)return;let i=0;for(;i<r.length;){let o=r[i],n=o._path[t];if(n===void 0){s[t].push({label:o.label??o.field,fields:[o.field],rowspan:e+1-t}),i++;continue}let l=i+1;for(;l<r.length&&r[l]._path[t]===n;)l++;let a=r.slice(i,l);s[t].push({label:n,fields:a.map(c=>c.field)}),ke(a,t+1,e,s),i=l}}function De(r){let t=(r??[]).map(i=>({field:i.field,label:i.label,_path:fe(i.group)})),e=Math.max(0,...t.map(i=>i._path.length));if(e===0)return null;let s=Array.from({length:e},()=>[]);return ke(t,0,e,s),s}function fs(r){let t="";for(let e=r+1;e>0;){let s=(e-1)%26;t=String.fromCharCode(65+s)+t,e=Math.floor((e-1)/26)}return t}function zt(r,t,e=!1){let s=t.length,i=r?.length??0,o=e?1:0,n=i+1+o,l=Array.from({length:n},()=>new Array(s).fill(!1)),a=[];if(e)for(let h=0;h<s;h++)a.push({row:0,col:h,colspan:1,rowspan:1,label:fs(h),align:"center",isLeaf:!1,isColLetter:!0});for(let h=0;h<i;h++){let d=h+o,u=0;for(let f of r[h]??[]){let{label:_="",fields:p,colspan:w,rowspan:m=1,align:x="center"}=f,S=Math.min(m,n-d),v;if(p){let b=p.map(C=>t.indexOf(C)).filter(C=>C>=0).sort((C,H)=>C-H);v=[];for(let C of b){let H=v[v.length-1];H&&H.start+H.length===C?H.length++:v.push({start:C,length:1})}}else{for(;u<s&&l[d][u];)u++;if(u>=s)continue;v=[{start:u,length:Math.min(w??1,s-u)}],u+=v[0].length}for(let{start:b,length:C}of v){let H=C;for(let D=0;D<S;D++)for(let A=0;A<H;A++)d+D<n&&(l[d+D][b+A]=!0);a.push({row:d,col:b,colspan:H,rowspan:S,label:_,align:x,isLeaf:d+S>=n})}}}let c=i+o;for(let h=0;h<s;h++)l[c][h]||a.push({row:c,col:h,colspan:1,rowspan:1,label:null,align:null,isLeaf:!0});return a}function ee(r,t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o=0,rightX:n,colPositions:l}=t;if(r<s)return l[r];let a=l.length-1;if(o>0&&r>=a-o){let c=a-o;return n+l[r]-l[c]}return i+l[r]-l[s]-e}var Pt=new Map,pe=[],ge=0,me=new Set;function ps(){for(let r of me)try{r()}catch(t){console.error("[JHGrid] image cache load listener error:",t)}}function gs(r){return r.width*r.height*4}function ms(){let r=0;for(let t of Pt.values())r+=t.bytes;if(!(r<=52428800))for(let[t,e]of Pt){if(r<=52428800)break;e.status!=="loading"&&(Pt.delete(t),r-=e.bytes)}}function ws(r){let t=Pt.get(r);return t&&(Pt.delete(r),Pt.set(r,t)),t}function ys(r,t,e){return new Promise((s,i)=>{let o=new Image;o.crossOrigin="anonymous",o.onload=()=>createImageBitmap(o,{resizeWidth:t,resizeHeight:e,resizeQuality:"medium"}).then(s,i),o.onerror=()=>i(new Error(`[JHGrid] image cache: failed to load ${r}`)),o.src=r})}async function bs(r,t,e){let s=typeof window<"u"&&window.devicePixelRatio||1,i=Math.max(24,Math.min(256,Math.round(t*s))),o=Math.max(24,Math.min(256,Math.round(e*s)));try{let n;try{let l=await fetch(r);if(!l.ok)throw new Error(`HTTP ${l.status}`);let a=await l.blob();n=await createImageBitmap(a,{resizeWidth:i,resizeHeight:o,resizeQuality:"medium"})}catch{n=await ys(r,i,o)}Pt.set(r,{status:"loaded",bitmap:n,bytes:gs(n)}),ms()}catch(n){console.error("[JHGrid] image cache decode error:",n),Pt.set(r,{status:"error",bitmap:null,bytes:0})}finally{ge--,ps(),$e()}}function $e(){for(;ge<6&&pe.length>0;){let{url:r,w:t,h:e}=pe.shift(),s=Pt.get(r);!s||s.status!=="loading"||(ge++,bs(r,t,e))}}function Le(r,t,e){if(!r)return null;let s=ws(r);if(s)return s;let i={status:"loading",bitmap:null,bytes:0};return Pt.set(r,i),pe.push({url:r,w:t,h:e}),$e(),i}function Fe(r){me.add(r)}function Pe(r){me.delete(r)}var Bt=20,ie=18,ye=16,se=20,qt={headerBg:"#E8E8E8",headerText:"#3D3D3D",headerBorder:"#C0C0C0",rowEven:"#FFFFFF",rowOdd:"#FFFFFF",cellBorder:"#D9D9D9",cellText:"#212121",loadingText:"#BFBFBF",skeletonBar:"#E4E7EB",skeletonSheen:"rgba(255,255,255,0.65)",cellPadding:10,selectionColor:"#2E75B6",selectionFill:"rgba(46,117,182,0.10)",selRowBg:"rgba(46,117,182,0.12)",hoverRowBg:"rgba(0,0,0,0.045)",scrollbarBg:"#F0F0F0",scrollbarThumb:"#C0C0C0",scrollbarRadius:4,frozenBorder:"#B0B0B0",hiddenColIndicator:"#94A3B8",groupHeaderBg:"#EEF2F7",groupHeaderText:"#1E293B",footerBg:"#F2F2F2",footerText:"#1E293B",filterIconBg:"rgba(245,158,11,0.18)",sortIconBg:"rgba(46,117,182,0.12)",filterIconColor:"#C87B00",sortIconColor:"#2E75B6",headerIconColor:"rgba(0,0,0,0.28)",dragIndicatorFill:"rgba(59,130,246,0.12)",dragIndicatorLine:"#3b82f6",dragGhostShadow:"rgba(15,23,42,0.30)",deletedRowFill:"rgba(239,68,68,0.10)",deletedRowStrike:"rgba(239,68,68,0.55)",invalidCellBorder:"#dc2626",fontSize:13,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',locale:"en-US",overlayBg:"#FFFFFF",overlayBorder:"#D0D0D0",overlayHeaderBg:"#F5F5F5",overlayDivider:"#E0E0E0",overlayText:"#212121",overlayMutedText:"#595959",overlayHintText:"#909090",overlayHoverBg:"#F5F5F5",overlayItemHoverBg:"#F0F0F0",overlayShadow:"0 4px 16px rgba(0,0,0,0.15)",overlayMenuShadow:"0 4px 12px rgba(0,0,0,0.15)",overlayAccentText:"#FFFFFF",pagerBg:"#f8fafc",pagerBorder:"#e2e8f0",pagerText:"#1e293b",pagerButtonBg:"#ffffff",pagerButtonBorder:"#cbd5e1",readonlyCellBg:"#F5F5F5",editableCellBg:void 0,imagePlaceholderBg:"#F1F5F9",imageErrorBg:"#FEE2E2",imageErrorIcon:"#DC2626"},pt={richtext(){return(r,{x:t,y:e,w:s,h:i,value:o,theme:n,padding:l})=>{if(o==null||o==="")return;let a=xs(String(o));if(!a.length)return;r.textAlign="left",r.textBaseline="middle",r.fillStyle=n.cellText,r.save(),r.beginPath(),r.rect(t,e,s,i),r.clip();let c=t+l,h=e+i/2;for(let d of a){r.font=`${d.italic?"italic ":""}${d.bold?"bold ":""}${n.fontSize}px ${n.fontFamily}`,r.fillText(d.text,c,h);let u=r.measureText(d.text).width;if(d.underline||d.strike){r.strokeStyle=n.cellText,r.lineWidth=1;let f=d.underline?h+n.fontSize/2-1:h;r.beginPath(),r.moveTo(c,f),r.lineTo(c+u,f),r.stroke()}c+=u}r.restore()}},tree({indentPx:r=ie,inner:t}={}){let e=(s,{x:i,y:o,w:n,h:l,value:a,theme:c,padding:h})=>{s.fillStyle=a!=null?c.cellText:c.loadingText,s.textAlign="left",s.textBaseline="middle",s.save(),s.beginPath(),s.rect(i,o,n,l),s.clip(),s.fillText(a!=null?String(a):"",i+h,o+l/2),s.restore()};return(s,i)=>{let{x:o,y:n,w:l,h:a,rowData:c,theme:h}=i;if(!c?.__tree__){(t??e)(s,i);return}let d=(c.__treeLevel??0)*r,u=o+d+ye;c.__treeHasChildren&&(s.fillStyle=h.cellText,s.font=`${h.fontSize}px ${h.fontFamily}`,s.textAlign="left",s.textBaseline="middle",s.fillText(c.__treeExpanded?"\u25BE":"\u25B8",o+d,n+a/2)),(t??e)(s,{...i,x:u,w:o+l-u})}},progressBar({max:r=100,showLabel:t=!0}={}){return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=Number(l);if(isNaN(h))return;let d=Math.max(0,Math.min(1,h/r)),u=t?36:0,f=s+c,_=Math.max(0,o-c*2-u),p=6,w=i+(n-p)/2,m=3;if(e.fillStyle="#e2e8f0",e.beginPath(),e.roundRect?e.roundRect(f,w,_,p,m):e.rect(f,w,_,p),e.fill(),d>0){e.fillStyle=d>=.8?"#16a34a":d>=.5?"#f59e0b":"#ef4444",e.beginPath();let x=Math.max(m*2,_*d);e.roundRect?e.roundRect(f,w,x,p,m):e.rect(f,w,x,p),e.fill()}t&&(e.fillStyle=a.cellText,e.font=`${a.fontSize}px ${a.fontFamily}`,e.textAlign="right",e.textBaseline="middle",e.fillText(`${Math.round(d*100)}%`,s+o-c,i+n/2))}},badge({colorMap:r={}}={}){return(t,{x:e,y:s,w:i,h:o,value:n,theme:l})=>{if(n==null||n==="")return;let a=String(n),{bg:c="#f1f5f9",fg:h="#475569"}=r[a]??{},d=8;t.font=`${l.fontSize-1}px ${l.fontFamily}`;let u=t.measureText(a).width,f=Math.min(u+d*2,i-8),_=o-10,p=e+(i-f)/2,w=s+5,m=_/2;t.fillStyle=c,t.beginPath(),t.roundRect?t.roundRect(p,w,f,_,m):t.rect(p,w,f,_),t.fill(),t.fillStyle=h,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,s+o/2)}},checkmark({trueColor:r="#16a34a",falseColor:t="#94a3b8",showFalse:e=!0}={}){return(s,{x:i,y:o,w:n,h:l,value:a,theme:c})=>{let h=a===!0||a===1||a==="Y"||a==="\uC608"||a==="true";!h&&!e||(s.fillStyle=h?r:t,s.font=`bold ${c.fontSize+1}px ${c.fontFamily}`,s.textAlign="center",s.textBaseline="middle",s.fillText(h?"\u2713":"\u2717",i+n/2,o+l/2))}},image({fit:r="cover",radius:t=0}={}){return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{if(!l)return;let h=s+c,d=i+c,u=o-c*2,f=n-c*2;if(u<=0||f<=0)return;let _=Le(String(l),u,f);if(e.save(),e.beginPath(),t>0&&e.roundRect?e.roundRect(h,d,u,f,t):e.rect(h,d,u,f),e.clip(),_?.status==="loaded"&&_.bitmap){let p=_.bitmap,w=r==="contain"?Math.min(u/p.width,f/p.height):Math.max(u/p.width,f/p.height),m=p.width*w,x=p.height*w;e.drawImage(p,h+(u-m)/2,d+(f-x)/2,m,x)}else _?.status==="error"?(e.fillStyle=a.imageErrorBg,e.fillRect(h,d,u,f),e.strokeStyle=a.imageErrorIcon,e.lineWidth=1.5,e.beginPath(),e.moveTo(h+u*.3,d+f*.3),e.lineTo(h+u*.7,d+f*.7),e.moveTo(h+u*.7,d+f*.3),e.lineTo(h+u*.3,d+f*.7),e.stroke()):(e.fillStyle=a.imagePlaceholderBg,e.fillRect(h,d,u,f));e.restore()}},number({locale:r,decimals:t=0}={}){let e,s;return(i,{x:o,y:n,w:l,h:a,value:c,theme:h,padding:d})=>{let u=r??h.locale;(e===void 0||s!==u)&&(e=new Intl.NumberFormat(u,{minimumFractionDigits:t,maximumFractionDigits:t}),s=u);let f=Number(c);if(c==null||c===""||isNaN(f))return;let _=e.format(f);i.fillStyle=h.cellText,i.font=`${h.fontSize}px ${h.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,l,a),i.clip(),i.fillText(_,o+l-d,n+a/2),i.restore()}},date({format:r="YYYY-MM-DD",locale:t,dateStyle:e,align:s="left"}={}){let i,o;return(n,{x:l,y:a,w:c,h,value:d,theme:u,padding:f})=>{if(d==null||d==="")return;let _=d instanceof Date?d:typeof d=="number"?new Date(d):new Date(String(d)),p=String(d);if(!isNaN(_.getTime()))if(r==="locale"){let m=t??u.locale;(i===void 0||o!==m)&&(i=new Intl.DateTimeFormat(m,e?{dateStyle:e}:void 0),o=m),p=i.format(_)}else{let m=String(_.getFullYear()).padStart(4,"0"),x=String(_.getMonth()+1).padStart(2,"0"),S=String(_.getDate()).padStart(2,"0"),v=String(_.getHours()).padStart(2,"0"),b=String(_.getMinutes()).padStart(2,"0"),C=String(_.getSeconds()).padStart(2,"0"),H=m.slice(-2);p=r.replace("YYYY",m).replace("YY",H).replace("MM",x).replace("DD",S).replace("HH",v).replace("mm",b).replace("ss",C)}let w=s==="right"?l+c-f:s==="center"?l+c/2:l+f;n.fillStyle=u.cellText,n.font=`${u.fontSize}px ${u.fontFamily}`,n.textAlign=s,n.textBaseline="middle",n.save(),n.beginPath(),n.rect(l,a,c,h),n.clip(),n.fillText(p,w,a+h/2),n.restore()}},currency({locale:r,currency:t="KRW"}={}){let e,s;return(i,{x:o,y:n,w:l,h:a,value:c,theme:h,padding:d})=>{let u=r??h.locale;(e===void 0||s!==u)&&(e=new Intl.NumberFormat(u,{style:"currency",currency:t}),s=u);let f=Number(c);if(c==null||c===""||isNaN(f))return;let _=e.format(f);i.fillStyle=h.cellText,i.font=`${h.fontSize}px ${h.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,l,a),i.clip(),i.fillText(_,o+l-d,n+a/2),i.restore()}},dropdown({placeholder:r=""}={}){let t=se;return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=l!=null&&l!==""?String(l):r;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=l!=null&&l!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(h,s+c,i+n/2),e.restore(),e.fillStyle="rgba(0,0,0,0.06)",e.fillRect(s+o-t,i+1,t-1,n-2),e.fillStyle=a.headerText??a.cellText,e.font=`11px ${a.fontFamily}`,e.textAlign="center",e.fillText("\u25BE",s+o-t/2,i+n/2)}},multiselect({placeholder:r=""}={}){let t=se;return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=l!=null&&l!==""?String(l):r;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=l!=null&&l!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(h,s+c,i+n/2),e.restore(),e.fillStyle="rgba(0,0,0,0.06)",e.fillRect(s+o-t,i+1,t-1,n-2),e.fillStyle=a.headerText??a.cellText,e.font=`11px ${a.fontFamily}`,e.textAlign="center",e.fillText("\u25BE",s+o-t/2,i+n/2)}},checkbox({checkedColor:r="#2563eb",size:t=14}={}){return(e,{x:s,y:i,w:o,h:n,value:l})=>{let a=l===!0||l===1||l==="true"||l==="1"||l==="Y"||l==="yes",c=s+(o-t)/2,h=i+(n-t)/2,d=3;e.beginPath(),e.roundRect?e.roundRect(c,h,t,t,d):e.rect(c,h,t,t),a?(e.fillStyle=r,e.fill(),e.strokeStyle="#fff",e.lineWidth=1.8,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(c+3,h+t/2),e.lineTo(c+t/2-1,h+t-4),e.lineTo(c+t-3,h+3.5),e.stroke()):(e.fillStyle="#fff",e.fill(),e.strokeStyle="#C0C0C0",e.lineWidth=1.5,e.stroke())}},button({label:r="Button",disabled:t=!1,variant:e="primary"}={}){let s={primary:"#2563eb",success:"#16a34a",danger:"#dc2626",neutral:"#64748b"};return(i,{x:o,y:n,w:l,h:a,theme:c,rowData:h,rowIndex:d})=>{let u=typeof r=="function"?r(h,d):r;if(u==null||u==="")return;let f=typeof t=="function"?!!t(h,d):!!t,_=typeof e=="function"?e(h,d):e;i.font=`${c.fontSize-1}px ${c.fontFamily}`;let p=i.measureText(u).width,w=Math.min(a-8,24),m=Math.min(l-8,p+24);if(m<=0||w<=0)return;let x=o+(l-m)/2,S=n+(a-w)/2;i.beginPath(),i.roundRect?i.roundRect(x,S,m,w,w/2):i.rect(x,S,m,w),i.fillStyle=f?"#cbd5e1":s[_]??s.primary,i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(u,x+m/2,S+w/2)}}},vs=new Set(Object.keys(pt));function be(r,t){vs.has(r)&&console.warn(`[JHGrid] registerCellRenderer: "${r}" is a built-in renderer name and will be overwritten`),pt[r]=t}var we=/<\/?(b|i|u|s)>/g;function xs(r){let t=[],e={bold:!1,italic:!1,underline:!1,strike:!1},s=l=>l.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),i=l=>{l&&t.push({text:s(l),...e})};we.lastIndex=0;let o=0,n;for(;n=we.exec(r);){i(r.slice(o,n.index)),o=we.lastIndex;let l=n[0][1]==="/",a={b:"bold",i:"italic",u:"underline",s:"strike"}[n[1]];e[a]=!l}return i(r.slice(o)),t}var Gt=class r{#t;#e;constructor(t,e){this.#t=t.getContext("2d"),this.#e=e}render({scrollTop:t,scrollLeft:e,totalRows:s,columns:i,columnLabels:o,columnAligns:n,columnHeaderAligns:l,getRow:a,geo:c,rowLayout:h,sel:d,editing:u,headerFocusCol:f,rowFocus:_,colDrag:p,rowDrag:w,sorts:m,filters:x,columnRenderers:S,invalidCells:v,selectedRows:b,fillPreview:C,deletedRows:H,skeletonPhase:D,rowNumberLabel:A,grouping:j,groupFooter:O,hiddenNeighbors:V,editableColumns:z,i18n:W,headerCheckboxCols:E,hoverRow:L=null,selAnim:M=null,colSlide:Q=null,remoteSelections:R=null}){let{headerHeight:I,theme:$}=this.#e,{headerRows:k}=this.#e,{width:T,height:F}=this.#e,g=this.#t,{vpH:U,vpW:Z,SB:lt,vSB:ot=lt,hSB:it=lt,frozenCount:K=0,frozenWidth:N=0,frozenRightCount:G=0,frozenRightWidth:ft=0,rightX:et=0,colPositions:q,headerH:X,footerH:wt=0,maxRow:Dt,rowNumW:Et=0}=c,Lt=o??i,_t=i.length,P=d,nt=M?.prev?{prev:M.prev,t:M.t}:null;g.fillStyle=$.rowEven,g.fillRect(0,0,T,F);let at=Dt??s-1,ct=Math.max(0,h.rowAt(t,at)),yt=h.rowAt(t+U,at),ht=yt<0?at:Math.min(at,yt+1),Rt=_t-1-G,At=q[K],xt=K;for(;xt<Rt&&q[xt+1]-At<=e;)xt++;let Mt=xt;for(;Mt<Rt&&q[Mt]-At<e+Z;)Mt++;if(Mt=Math.min(Rt,Mt+1),g.save(),g.beginPath(),g.rect(N,X,Z,U),g.clip(),this.#l(ct,ht,xt,Mt,t,e,i,n,a,h,X,$,K,N,G,et,q,S,v,b,H,z,L,D),g.restore(),K>0&&(g.save(),g.beginPath(),g.rect(0,X,N,U),g.clip(),this.#l(ct,ht,0,K-1,t,e,i,n,a,h,X,$,K,N,G,et,q,S,v,b,H,z,L,D),g.restore()),G>0&&(g.save(),g.beginPath(),g.rect(et,X,ft,U),g.clip(),this.#l(ct,ht,_t-G,_t-1,t,e,i,n,a,h,X,$,K,N,G,et,q,S,v,b,H,z,L,D),g.restore()),P){let Y=gt=>gt.type==="single"?gt.col:gt.c1,tt=gt=>gt.type==="single"?gt.col:gt.c2,st=nt?.prev,J=st?Math.min(Y(P),Y(st)):Y(P),rt=st?Math.max(tt(P),tt(st)):tt(P);K>0&&J<K&&(g.save(),g.beginPath(),g.rect(0,X,N,U),g.clip(),this.#c(P,u,t,e,h,X,$,K,N,G,et,q,nt),g.restore()),rt>=K&&J<_t-G&&(g.save(),g.beginPath(),g.rect(N,X,Z,U),g.clip(),this.#c(P,u,t,e,h,X,$,K,N,G,et,q,nt),g.restore()),G>0&&rt>=_t-G&&(g.save(),g.beginPath(),g.rect(et,X,ft,U),g.clip(),this.#c(P,u,t,e,h,X,$,K,N,G,et,q,nt),g.restore())}if(R&&R.length)for(let Y of R){let tt=Y.sel;if(!tt)continue;let st=tt.type==="single"?tt.col:tt.c1,J=tt.type==="single"?tt.col:tt.c2;K>0&&st<K&&(g.save(),g.beginPath(),g.rect(0,X,N,U),g.clip(),this.#h(tt,Y.color,Y.label,t,e,h,X,K,N,G,et,q),g.restore()),J>=K&&st<_t-G&&(g.save(),g.beginPath(),g.rect(N,X,Z,U),g.clip(),this.#h(tt,Y.color,Y.label,t,e,h,X,K,N,G,et,q),g.restore()),G>0&&J>=_t-G&&(g.save(),g.beginPath(),g.rect(et,X,ft,U),g.clip(),this.#h(tt,Y.color,Y.label,t,e,h,X,K,N,G,et,q),g.restore())}if(b&&b.size>0){let Y=T-ot,tt=Math.max(0,q[_t-G]-N-e),st=Math.min(Y,N+Math.min(Z,tt)+ft);g.save(),g.beginPath(),g.rect(0,X,st,U),g.clip(),g.strokeStyle=$.selectionColor,g.lineWidth=2;for(let J=ct;J<=ht;J++){if(!b.has(J)||J>ct&&b.has(J-1))continue;let rt=J;for(;rt<ht&&b.has(rt+1);)rt++;let gt=b.has(J-1)?X-4:h.yOf(J)-t+X,Tt=b.has(rt+1)?X+U+4:h.yOf(rt)-t+X+h.heightOf(rt);g.strokeRect(1,gt+1,st-2,Tt-gt-2),J=rt}g.restore()}if(g.save(),g.beginPath(),g.rect(N,0,Z,X),g.clip(),this.#a(Lt,l??n,i,m,x,xt,Mt,e,X,I,k,$,K,N,G,et,q,V,E,d),g.restore(),K>0&&(g.save(),g.beginPath(),g.rect(0,0,N,X),g.clip(),this.#a(Lt,l??n,i,m,x,0,K-1,e,X,I,k,$,K,N,G,et,q,V,E,d),g.restore()),G>0&&(g.save(),g.beginPath(),g.rect(et,0,ft,X),g.clip(),this.#a(Lt,l??n,i,m,x,_t-G,_t-1,e,X,I,k,$,K,N,G,et,q,V,E,d),g.restore()),K>0){g.strokeStyle=$.frozenBorder,g.lineWidth=2,g.beginPath();let Y=Math.round(N)+.5;g.moveTo(Y,0),g.lineTo(Y,F-it),g.stroke()}if(G>0){g.strokeStyle=$.frozenBorder,g.lineWidth=2,g.beginPath();let Y=Math.round(et)+.5;g.moveTo(Y,0),g.lineTo(Y,F-it),g.stroke()}if(f!=null&&f>=0&&f<i.length){let Y=f<K,tt=G>0&&f>=_t-G,st=this.#n(f,K,N,G,et,e,q),J=q[f+1]-q[f];g.save(),g.beginPath(),Y?g.rect(0,0,N,X):tt?g.rect(et,0,ft,X):g.rect(N,0,Z,X),g.clip(),g.strokeStyle=$.selectionColor,g.lineWidth=2,g.strokeRect(st+1,1,Math.max(0,J-2),Math.max(0,X-2)),g.restore()}if(_!=null&&Et>0){let Y=h.yOf(_)-t+X,tt=h.heightOf(_);Y+tt>X&&Y<F-it&&(g.save(),g.beginPath(),g.rect(0,X,Et,U),g.clip(),g.strokeStyle=$.selectionColor,g.lineWidth=2,g.strokeRect(1,Y+1,Math.max(0,Et-2),Math.max(0,tt-2)),g.restore())}if(d&&!u){let tt=d.type==="single"?d.row:d.r2,st=d.type==="single"?d.col:d.c2,J=this.#n(st,K,N,G,et,e,q)+(q[st+1]-q[st]),rt=h.yOf(tt+1)-t+X;J>=N-7&&J<=T-ot+7&&rt>=X&&rt<=F-it+7&&(g.fillStyle=$.selectionColor,g.fillRect(Math.round(J)-7/2,Math.round(rt)-7/2,7,7))}if(C){let{r1:Y,c1:tt,r2:st,c2:J}=C,rt=this.#n(tt,K,N,G,et,e,q),gt=h.yOf(Y)-t+X,Tt=this.#n(J,K,N,G,et,e,q)+(q[J+1]-q[J])-rt,St=h.yOf(st+1)-h.yOf(Y);g.fillStyle=$.selectionFill,g.fillRect(rt,gt,Tt,St),g.setLineDash([4,3]),g.strokeStyle=$.selectionColor,g.lineWidth=2,g.strokeRect(rt+1,gt+1,Tt-2,St-2),g.setLineDash([])}if(Q&&Q.c1>=0&&Q.c2<_t&&Q.dragCol>=0&&Q.dragCol<_t&&Q.dx!==0){let{c1:Y,c2:tt,dx:st,dragCol:J}=Q,rt=Math.min(Y,J),gt=Math.max(tt,J),Tt=Ft=>this.#n(Ft,K,N,G,et,e,q),St=Math.max(0,Tt(rt)),kt=Math.min(T-ot,Tt(gt)+(q[gt+1]-q[gt])),Ut=(Ft,jt,he)=>{g.save(),g.translate(he,0),this.#l(ct,ht,Ft,jt,t,e,i,n,a,h,X,$,K,N,G,et,q,S,v,b,H,z,L,D),this.#a(Lt,l??n,i,m,x,Ft,jt,e,X,I,k,$,K,N,G,et,q,V,E,d),g.restore()};kt>St&&(g.save(),g.beginPath(),g.rect(St,0,kt-St,F-it),g.clip(),g.fillStyle=$.headerBg,g.fillRect(St,0,kt-St,X),g.fillStyle=$.rowEven,g.fillRect(St,X,kt-St,F-it-X),Ut(Y,tt,st),Ut(J,J,0),g.restore())}if(p?.active){let{col:Y,insertBefore:tt}=p,st=this.#n(Y,K,N,G,et,e,q),J=q[Y+1]-q[Y];g.fillStyle=$.dragIndicatorFill,g.fillRect(st,0,J,F-it);let rt=i.length,gt=tt<rt?this.#n(tt,K,N,G,et,e,q):this.#n(rt-1,K,N,G,et,e,q)+(q[rt]-q[rt-1]);if(g.strokeStyle=$.dragIndicatorLine,g.lineWidth=3,g.beginPath(),g.moveTo(gt,0),g.lineTo(gt,F-it),g.stroke(),p.x!==void 0){let Tt=I,St=X-I,kt=Math.max(0,Math.min(T-ot-J,p.x-p.grabDX));g.save(),g.globalAlpha=.92,g.shadowColor=$.dragGhostShadow,g.shadowBlur=8,g.shadowOffsetY=2,g.fillStyle=$.headerBg,g.fillRect(kt,St,J,Tt),g.restore(),g.save(),g.beginPath(),g.rect(kt,St,J,Tt),g.clip(),g.globalAlpha=.92,g.strokeStyle=$.dragIndicatorLine,g.lineWidth=1,g.strokeRect(kt+.5,St+.5,J-1,Tt-1),g.font=`bold ${$.headerFontSize??$.fontSize}px ${$.fontFamily}`,g.fillStyle=$.headerText,g.textAlign="left",g.textBaseline="middle",g.fillText(this.#f(String(Lt[Y]??i[Y]??""),J-$.cellPadding*2),kt+$.cellPadding,St+Tt/2),g.restore()}}if(w?.active){let{row:Y,insertBefore:tt}=w,st=h.yOf(Y)-t+X;g.fillStyle=$.dragIndicatorFill,g.fillRect(0,st,T-ot,h.heightOf(Y));let J=h.yOf(tt)-t+X;g.strokeStyle=$.dragIndicatorLine,g.lineWidth=3,g.beginPath(),g.moveTo(0,J),g.lineTo(T-ot,J),g.stroke()}if(j){let{rowNumW:Y}=c;this.#o(ct,ht,t,h,X,$,T,ot,Y,a,i,o??i,W)}let{rowNumW:ut}=c;if(ut>0&&this.#i(ct,ht,t,h,ut,F,X,it,$,A,b,L),O&&wt>0){let Y=F-it-wt;g.save(),g.beginPath(),g.rect(N,Y,Z,wt),g.clip(),this.#s(O,i,n,xt,Mt,e,Y,wt,$,K,N,G,et,q,W),g.restore(),K>0&&(g.save(),g.beginPath(),g.rect(0,Y,N,wt),g.clip(),this.#s(O,i,n,0,K-1,e,Y,wt,$,K,N,G,et,q,W),g.restore()),G>0&&(g.save(),g.beginPath(),g.rect(et,Y,ft,wt),g.clip(),this.#s(O,i,n,_t-G,_t-1,e,Y,wt,$,K,N,G,et,q,W),g.restore())}this.#d(c,$,T,F)}#i(t,e,s,i,o,n,l,a,c,h,d,u){let f=this.#t;f.save(),f.beginPath(),f.rect(0,0,o,n-a),f.clip(),f.fillStyle=c.headerBg,f.fillRect(0,0,o,l),f.font=`bold ${c.headerFontSize??c.fontSize}px ${c.fontFamily}`,f.fillStyle=c.headerText,f.textAlign="center",f.textBaseline="middle",f.fillText(h??"No.",o/2,l/2),f.textAlign="center",f.textBaseline="middle",f.save(),f.beginPath(),f.rect(0,l,o,Math.max(0,n-a-l)),f.clip();for(let _=t;_<=e;_++){let p=i.yOf(_)-s+l,w=i.heightOf(_),m=d?.has(_);f.fillStyle=c.headerBg,f.fillRect(0,p,o,w),m&&(f.fillStyle=c.selectionColor,f.globalAlpha=.28,f.fillRect(0,p,o,w),f.globalAlpha=1),u&&u.row===_&&u.alpha>0&&c.hoverRowBg&&(f.globalAlpha=Math.min(1,u.alpha),f.fillStyle=c.hoverRowBg,f.fillRect(0,p,o,w),f.globalAlpha=1),f.font=m?`bold ${c.fontSize-1}px ${c.fontFamily}`:`${c.fontSize-1}px ${c.fontFamily}`,f.fillStyle=m?c.sortIconColor??c.selectionColor:c.headerText,f.fillText(String(_+1),o/2,p+w/2),f.strokeStyle=c.headerBorder,f.lineWidth=1,f.beginPath(),f.moveTo(0,Math.round(p+w)-.5),f.lineTo(o,Math.round(p+w)-.5),f.stroke()}f.restore(),f.strokeStyle=c.headerBorder,f.lineWidth=1,f.beginPath(),f.moveTo(0,l-.5),f.lineTo(o,l-.5),f.stroke(),f.strokeStyle=c.frozenBorder??c.headerBorder,f.lineWidth=1.5,f.beginPath(),f.moveTo(o-.5,0),f.lineTo(o-.5,n-a),f.stroke(),f.restore()}#o(t,e,s,i,o,n,l,a,c,h,d,u,f){let _=this.#t,p=c,w=l-a-c;if(w<=0)return;let m=n.cellPadding,x=f?.groupLabel??((S,v,b)=>`${S}: ${v} (${b})`);for(let S=t;S<=e;S++){let v=h(S);if(!v?.__group__)continue;let b=i.yOf(S)-s+o,C=i.heightOf(S),H=(v.level??0)*ie;_.fillStyle=n.groupHeaderBg,_.fillRect(p,b,w,C),_.strokeStyle=n.cellBorder,_.lineWidth=1,_.strokeRect(Math.round(p)+.5,Math.round(b)+.5,w-1,C-1),_.fillStyle=n.groupHeaderText,_.font=`bold ${n.fontSize}px ${n.fontFamily}`,_.textAlign="left",_.textBaseline="middle";let D=v.collapsed?"\u25B8":"\u25BE";_.fillText(`${D} ${x(v.field,v.key,v.count)}`,p+m+H,b+C/2);let A=Object.entries(v.aggregates??{});if(A.length){_.font=`${n.fontSize-1}px ${n.fontFamily}`,_.textAlign="right";let j=A.map(([O,V])=>`${u[d.indexOf(O)]??O} ${V}`).join(" ");_.fillText(j,p+w-m,b+C/2)}}}#s(t,e,s,i,o,n,l,a,c,h,d,u,f,_,p){if(i>o)return;let w=this.#t,m=c.cellPadding,x=_.length-1,S=i<h?0:u>0&&i>=x-u?f-_[x-u]:d-_[h]-n;w.fillStyle=c.footerBg,w.fillRect(_[i]+S,l,_[o+1]-_[i],a),w.font=`bold ${c.fontSize}px ${c.fontFamily}`,w.textBaseline="middle";let v=l+a/2;i===0&&(w.fillStyle=c.footerText,w.textAlign="left",w.font=`bold ${c.fontSize-1}px ${c.fontFamily}`,w.fillText(p?.groupFooterLabel??"Total",_[i]+S+m,v),w.font=`bold ${c.fontSize}px ${c.fontFamily}`);for(let C=i;C<=o;C++){let H=t[e[C]];if(H==null)continue;let D=_[C]+S,A=_[C+1]-_[C];w.fillStyle=c.footerText;let j=s?.[C]??"left";w.textAlign=j;let O=j==="right"?D+A-m:j==="center"?D+A/2:D+m;w.fillText(this.#f(String(H),A-m*2),O,v)}w.strokeStyle=c.headerBorder,w.lineWidth=1,w.beginPath();let b=Math.round(l)+.5;w.moveTo(_[i]+S,b),w.lineTo(_[o+1]+S,b),w.stroke()}#n(t,e,s,i,o,n,l){return ee(t,{frozenCount:e,frozenWidth:s,frozenRightCount:i,rightX:o,colPositions:l},n)}#a(t,e,s,i,o,n,l,a,c,h,d,u,f,_,p,w,m,x,S,v){if(n>l)return;let b=this.#t,C=u.cellPadding,H=v?v.type==="single"?v.col:v.c1:null,D=v?v.type==="single"?v.col:v.c2:null,A=m.length-1,j=R=>p>0&&R>=A-p,O=n<f?0:j(n)?w-m[A-p]:_-m[f]-a,V=m[n]+O,z=m[l+1]-m[n];b.fillStyle=u.headerBg,b.fillRect(V,0,z,c);let E=zt(d,s,this.#e.columnLetterHeader).filter(R=>R.col+R.colspan-1>=n&&R.col<=l);b.strokeStyle=u.headerBorder,b.lineWidth=1,b.beginPath();for(let R of E){let I=m[R.col]+O,$=m[R.col+R.colspan]-m[R.col],k=R.row*h,T=R.rowspan*h,F=Math.round(I+$)+.5,g=k+T+.5;b.moveTo(F,k),b.lineTo(F,k+T),b.moveTo(I,g),b.lineTo(I+$,g)}b.stroke();let L=R=>R<f?0:j(R)?2:1,M=L(n);b.textBaseline="middle",b.fillStyle=u.headerText;let Q="";for(let R of E){let I=m[R.col]+O,$=m[R.col+R.colspan]-m[R.col],k=R.row*h,T=R.rowspan*h,F=k+T/2;R.isLeaf&&H!==null&&R.col>=H&&R.col<=D&&(b.fillStyle=u.selectionColor,b.globalAlpha=.28,b.fillRect(I,k,$,T),b.globalAlpha=1,b.fillStyle=u.headerText);let g=R.isLeaf?s[R.col]:null,U=R.isLeaf&&!!o?.[g],Z=R.isLeaf&&i?.length?i.findIndex(P=>P.field===g):-1,lt=Z>=0?i[Z]:null,ot=i?.length>1,it=I+$-Bt;if(R.isLeaf&&U?(b.fillStyle=u.filterIconBg??"rgba(245,158,11,0.18)",b.fillRect(it+1,k+3,Bt-2,T-6),b.fillStyle=u.headerText):R.isLeaf&<&&(b.fillStyle=u.sortIconBg??"rgba(46,117,182,0.12)",b.fillRect(it+1,k+3,Bt-2,T-6),b.fillStyle=u.headerText),!(R.isLeaf||L(R.col)===M))continue;let N=I,G=$;if(!R.isLeaf){let P=Math.max(R.col,n),nt=Math.min(R.col+R.colspan-1,l);N=m[P]+O,G=m[nt+1]-m[P]}let ft=R.isLeaf?e?.[R.col]??"left":R.align??"center",et=R.isLeaf?Bt+4:0,q=R.isLeaf&&S?.has(g),X=q?20:0,wt=G-C*2-et-X,Dt=u.headerFontSize??u.fontSize;b.font=`bold ${Dt}px ${u.fontFamily}`;let Et=q?"left":ft;Et!==Q&&(b.textAlign=Et,Q=Et);let Lt=ft==="right"?N+G-C-et:q?N+C+X:ft==="center"?N+G/2:N+C,_t=R.isLeaf?t[R.col]??"":R.label??"";if(this.#e.wrapHeader&&_t){let P=this.#p(_t,wt),nt=Dt*1.4,at=F-(P.length-1)*nt/2;for(let ct of P)b.fillText(ct,Lt,at),at+=nt}else b.fillText(this.#f(_t,wt),Lt,F);if(R.isLeaf){b.font=`bold ${Dt-1}px ${u.fontFamily}`,b.textAlign="center",Q="center",b.fillStyle=U?u.filterIconColor??"#C87B00":lt?u.sortIconColor??"#2E75B6":u.headerIconColor??"rgba(0,0,0,0.28)";let P=lt?lt.dir==="asc"?"\u2191":"\u2193":"\u25BE",nt=lt&&ot?`${Z+1}${P}`:P;b.fillText(nt,it+Bt/2,F),b.fillStyle=u.headerText}}if(x){b.fillStyle=u.hiddenColIndicator??"#94A3B8";for(let R of E){if(!R.isLeaf)continue;let I=x[R.col];if(!I?.left&&!I?.right)continue;let $=m[R.col]+O,k=m[R.col+R.colspan]-m[R.col],T=R.row*h,F=R.rowspan*h;I.right&&b.fillRect($+k-1,T,1,F),I.left&&b.fillRect($,T,1,F)}}}#l(t,e,s,i,o,n,l,a,c,h,d,u,f,_,p,w,m,x,S,v,b,C,H,D){if(t>e||s>i)return;let A=this.#t,j=u.cellPadding,O=m.length-1,V=s<f?0:p>0&&s>=O-p?w-m[O-p]:_-m[f]-n,z=m[s]+V,W=m[i+1]-m[s];A.font=`${u.fontSize}px ${u.fontFamily}`,A.textBaseline="middle";let E=A.measureText("\u2026").width;for(let k=t;k<=e;k++)A.fillStyle=k%2===0?u.rowEven:u.rowOdd,A.fillRect(z,h.yOf(k)-o+d,W,h.heightOf(k));if(C){let k=u.editableCellBg,T=u.readonlyCellBg;if(k||T)for(let F=s;F<=i;F++){let g=C[F]?k:T;if(!g)continue;let U=m[F]+V,Z=m[F+1]-m[F];A.fillStyle=g;for(let lt=t;lt<=e;lt++)A.fillRect(U,h.yOf(lt)-o+d,Z,h.heightOf(lt))}}for(let k=t;k<=e;k++){let T=h.yOf(k)-o+d,F=h.heightOf(k);v?.has(k)&&(A.fillStyle=u.selRowBg,A.fillRect(z,T,W,F));let g=this.#e.rowHighlighter?.(c(k),k);g&&(A.fillStyle=g,A.fillRect(z,T,W,F)),b?.has(k)&&(A.fillStyle=u.deletedRowFill,A.fillRect(z,T,W,F))}let L=this.#e.cellBackground;if(L)for(let k=t;k<=e;k++){let T=h.yOf(k)-o+d,F=h.heightOf(k),g=c(k);for(let U=s;U<=i;U++){let Z;try{Z=L(g,k,l[U],U)}catch(it){console.error("[JHGrid] cellBackground error at row",k,"col",U,":",it);continue}if(!Z)continue;let lt=m[U]+V,ot=m[U+1]-m[U];A.fillStyle=Z,A.fillRect(lt,T,ot,F)}}if(H&&H.alpha>0&&H.row>=t&&H.row<=e&&u.hoverRowBg){let k=h.yOf(H.row)-o+d;A.globalAlpha=Math.min(1,H.alpha),A.fillStyle=u.hoverRowBg,A.fillRect(z,k,W,h.heightOf(H.row)),A.globalAlpha=1}let M=Math.round(h.yOf(t)-o+d),Q=Math.round(h.yOf(e+1)-o+d);A.strokeStyle=u.cellBorder,A.lineWidth=1,A.beginPath();for(let k=s;k<=i+1;k++){let T=Math.round(m[k]+V)+.5;A.moveTo(T,M),A.lineTo(T,Q)}for(let k=t;k<=e+1;k++){if(v?.has(k)&&v.has(k-1))continue;let T=Math.round(h.yOf(k)-o+d)+.5;A.moveTo(z,T),A.lineTo(z+W,T)}A.stroke();let R="",I="";for(let k=t;k<=e;k++){let T=c(k),F=h.yOf(k)-o+d;for(let g=s;g<=i;g++){let U=T?T[l[g]]:null,Z=m[g]+V,lt=m[g+1]-m[g],ot=h.heightOf(k),it=F+ot/2,K=x?.[g];if(K&&T){A.save();try{K(A,{x:Z,y:F,w:lt,h:ot,value:U,rowData:T,rowIndex:k,colIndex:g,theme:u,padding:j})}catch(wt){console.error("[JHGrid] Custom renderer error at row",k,"col",g,":",wt)}A.restore();continue}if(T==null){let Dt=(lt-j*2)*this.#_(k,g);if(Dt>2){let Et=Math.min(9,ot-12);A.fillStyle=u.skeletonBar,this.#u(Z+j,it-Et/2,Dt,Et,3),I=null}continue}let N=U!=null?u.cellText:u.loadingText,G=a?.[g]??"left";N!==I&&(A.fillStyle=N,I=N),G!==R&&(A.textAlign=G,R=G);let ft=G==="right"?Z+lt-j:G==="center"?Z+lt/2:Z+j,et=lt-j*2,q=U!=null?String(U):"";if(q.indexOf(`
|
|
2
|
-
`)!==-1){let wt=
|
|
3
|
-
`),
|
|
1
|
+
var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var hs=Object.prototype.hasOwnProperty;var ds=(r,t)=>{for(var e in t)_e(r,e,{get:t[e],enumerable:!0})},us=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cs(t))!hs.call(r,i)&&i!==e&&_e(r,i,{get:()=>t[i],enumerable:!(s=as(t,i))||s.enumerable});return r};var _s=r=>us(_e({},"__esModule",{value:!0}),r);var qs={};ds(qs,{BuiltinRenderers:()=>gt,CellEditors:()=>Ht,CellRenderers:()=>gt,DEFAULT_THEME:()=>qt,DataManager:()=>Yt,GRID_CLASSES:()=>B,JA_I18N:()=>Zt,JHGrid:()=>te,KO_I18N:()=>Jt,Renderer:()=>Gt,SUPPORTED_BROWSERS:()=>Xs,VERSION:()=>Us,ZH_I18N:()=>Qt,computeHeaderCells:()=>zt,registerCellEditor:()=>xe,registerCellRenderer:()=>be});var Yt=class{#t;#e;#i;#o=new Map;#s=-1;#n=null;#r=new Set;#l=new Set;#h=new Set;#c=0;#a=new Map;#d;#_;#f=!1;onChunkLoaded=null;onChunkError=null;constructor({fetchData:t,chunkSize:e=300,maxChunks:s=50,maxInFlight:i=2,maxQueued:o=4}){this.#t=t,this.#e=e,this.#i=s,this.#d=Math.max(1,i),this.#_=Math.max(1,o)}getRow(t){let e=Math.floor(t/this.#e);if(e===this.#s)return this.#n[t%this.#e]??null;if(this.#o.has(e)){let s=this.#o.get(e);return this.#o.delete(e),this.#o.set(e,s),this.#s=e,this.#n=s,s[t%this.#e]??null}return this.#g(e),null}setRow(t,e){let s=Math.floor(t/this.#e),i=this.#o.get(s);i&&(i[t%this.#e]=e)}insertAt(t,e){let s=e,i=t;for(;s!==void 0;){let o=Math.floor(i/this.#e),n=this.#o.get(o);if(!n)break;let l=i%this.#e;if(l>n.length)break;let a=l<n.length?n[n.length-1]:void 0;for(let c=n.length-1;c>l;c--)n[c]=n[c-1];n[l]=s,s=a,i=(o+1)*this.#e}}prefetch(t,e){let s=Math.floor(t/this.#e),i=Math.floor(e/this.#e);for(let o=s;o<=i+1;o++)this.#g(o)}async loadAll(t,e){let s=Math.floor(t/this.#e),i=Math.floor(e/this.#e),o=[];for(let a=s;a<=i;a++)o.push(a);let n=0,l=async()=>{for(;n<o.length;)await this.#m(o[n++])};await Promise.all(Array.from({length:this.#d},l))}#g(t){if(!(this.#o.has(t)||this.#r.has(t)||this.#l.has(t))){for(this.#a.delete(t),this.#a.set(t,!0);this.#a.size>this.#_;)this.#a.delete(this.#a.keys().next().value);this.#p()}}setHold(t){let e=this.#f;this.#f=!!t,!(!e||this.#f)&&(this.#a.clear(),this.#p())}#p(){if(!this.#f)for(;this.#r.size<this.#d&&this.#a.size>0;){let t;for(let e of this.#a.keys())t=e;this.#a.delete(t),this.#m(t)}}setFetch(t){this.#t=t,this.#c++,this.clear()}async#m(t){if(this.#o.has(t)||this.#r.has(t)||this.#l.has(t))return;this.#r.add(t);let e=this.#c;try{let s;for(let i=0;i<3;i++){if(e!==this.#c)return;try{let{rows:o}=await this.#t(t,this.#e);if(e!==this.#c)return;if(!Array.isArray(o))throw new TypeError("fetchData must resolve { rows: [] }");this.#o.set(t,o),this.#u(),this.onChunkLoaded?.();return}catch(o){if(s=o,o instanceof TypeError)break;i<2&&await new Promise(n=>setTimeout(n,500*2**i))}}if(e===this.#c){console.error(`[DataManager] chunk ${t} failed after retries:`,s),this.onChunkError?.(s,t),this.#l.add(t);let i=setTimeout(()=>{this.#l.delete(t),this.#h.delete(i)},5e3);this.#h.add(i)}}finally{this.#r.delete(t),this.#p()}}#u(){for(;this.#o.size>this.#i;){let t=this.#o.keys().next().value;this.#o.delete(t),t===this.#s&&(this.#s=-1,this.#n=null)}}forEachLoaded(t){for(let[e,s]of[...this.#o]){let i=e*this.#e;for(let o=0;o<s.length;o++)if(t(s[o],i+o)===!1)return}}clear(){this.#o.clear(),this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#h.forEach(clearTimeout),this.#h.clear(),this.#s=-1,this.#n=null}};function fe(r){return r==null?[]:Array.isArray(r)?r:[r]}function ke(r,t,e,s){if(t===e)return;let i=0;for(;i<r.length;){let o=r[i],n=o._path[t];if(n===void 0){s[t].push({label:o.label??o.field,fields:[o.field],rowspan:e+1-t}),i++;continue}let l=i+1;for(;l<r.length&&r[l]._path[t]===n;)l++;let a=r.slice(i,l);s[t].push({label:n,fields:a.map(c=>c.field)}),ke(a,t+1,e,s),i=l}}function De(r){let t=(r??[]).map(i=>({field:i.field,label:i.label,_path:fe(i.group)})),e=Math.max(0,...t.map(i=>i._path.length));if(e===0)return null;let s=Array.from({length:e},()=>[]);return ke(t,0,e,s),s}function fs(r){let t="";for(let e=r+1;e>0;){let s=(e-1)%26;t=String.fromCharCode(65+s)+t,e=Math.floor((e-1)/26)}return t}function zt(r,t,e=!1){let s=t.length,i=r?.length??0,o=e?1:0,n=i+1+o,l=Array.from({length:n},()=>new Array(s).fill(!1)),a=[];if(e)for(let h=0;h<s;h++)a.push({row:0,col:h,colspan:1,rowspan:1,label:fs(h),align:"center",isLeaf:!1,isColLetter:!0});for(let h=0;h<i;h++){let d=h+o,u=0;for(let f of r[h]??[]){let{label:_="",fields:g,colspan:w,rowspan:m=1,align:v="center"}=f,S=Math.min(m,n-d),b;if(g){let E=g.map(C=>t.indexOf(C)).filter(C=>C>=0).sort((C,T)=>C-T);b=[];for(let C of E){let T=b[b.length-1];T&&T.start+T.length===C?T.length++:b.push({start:C,length:1})}}else{for(;u<s&&l[d][u];)u++;if(u>=s)continue;b=[{start:u,length:Math.min(w??1,s-u)}],u+=b[0].length}for(let{start:E,length:C}of b){let T=C;for(let $=0;$<S;$++)for(let M=0;M<T;M++)d+$<n&&(l[d+$][E+M]=!0);a.push({row:d,col:E,colspan:T,rowspan:S,label:_,align:v,isLeaf:d+S>=n})}}}let c=i+o;for(let h=0;h<s;h++)l[c][h]||a.push({row:c,col:h,colspan:1,rowspan:1,label:null,align:null,isLeaf:!0});return a}function ee(r,t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o=0,rightX:n,colPositions:l}=t;if(r<s)return l[r];let a=l.length-1;if(o>0&&r>=a-o){let c=a-o;return n+l[r]-l[c]}return i+l[r]-l[s]-e}var Pt=new Map,pe=[],ge=0,me=new Set;function ps(){for(let r of me)try{r()}catch(t){console.error("[JHGrid] image cache load listener error:",t)}}function gs(r){return r.width*r.height*4}function ms(){let r=0;for(let t of Pt.values())r+=t.bytes;if(!(r<=52428800))for(let[t,e]of Pt){if(r<=52428800)break;e.status!=="loading"&&(Pt.delete(t),r-=e.bytes)}}function ws(r){let t=Pt.get(r);return t&&(Pt.delete(r),Pt.set(r,t)),t}function ys(r,t,e){return new Promise((s,i)=>{let o=new Image;o.crossOrigin="anonymous",o.onload=()=>createImageBitmap(o,{resizeWidth:t,resizeHeight:e,resizeQuality:"medium"}).then(s,i),o.onerror=()=>i(new Error(`[JHGrid] image cache: failed to load ${r}`)),o.src=r})}async function bs(r,t,e){let s=typeof window<"u"&&window.devicePixelRatio||1,i=Math.max(24,Math.min(256,Math.round(t*s))),o=Math.max(24,Math.min(256,Math.round(e*s)));try{let n;try{let l=await fetch(r);if(!l.ok)throw new Error(`HTTP ${l.status}`);let a=await l.blob();n=await createImageBitmap(a,{resizeWidth:i,resizeHeight:o,resizeQuality:"medium"})}catch{n=await ys(r,i,o)}Pt.set(r,{status:"loaded",bitmap:n,bytes:gs(n)}),ms()}catch(n){console.error("[JHGrid] image cache decode error:",n),Pt.set(r,{status:"error",bitmap:null,bytes:0})}finally{ge--,ps(),$e()}}function $e(){for(;ge<6&&pe.length>0;){let{url:r,w:t,h:e}=pe.shift(),s=Pt.get(r);!s||s.status!=="loading"||(ge++,bs(r,t,e))}}function Le(r,t,e){if(!r)return null;let s=ws(r);if(s)return s;let i={status:"loading",bitmap:null,bytes:0};return Pt.set(r,i),pe.push({url:r,w:t,h:e}),$e(),i}function Fe(r){me.add(r)}function Pe(r){me.delete(r)}var Bt=20,ie=18,ye=16,se=20,qt={headerBg:"#E8E8E8",headerText:"#3D3D3D",headerBorder:"#C0C0C0",rowEven:"#FFFFFF",rowOdd:"#FFFFFF",cellBorder:"#D9D9D9",cellText:"#212121",loadingText:"#BFBFBF",skeletonBar:"#E4E7EB",skeletonSheen:"rgba(255,255,255,0.65)",cellPadding:10,selectionColor:"#2E75B6",selectionFill:"rgba(46,117,182,0.10)",selRowBg:"rgba(46,117,182,0.12)",hoverRowBg:"rgba(0,0,0,0.045)",scrollbarBg:"#F0F0F0",scrollbarThumb:"#C0C0C0",scrollbarRadius:4,frozenBorder:"#B0B0B0",hiddenColIndicator:"#94A3B8",groupHeaderBg:"#EEF2F7",groupHeaderText:"#1E293B",footerBg:"#F2F2F2",footerText:"#1E293B",filterIconBg:"rgba(245,158,11,0.18)",sortIconBg:"rgba(46,117,182,0.12)",filterIconColor:"#C87B00",sortIconColor:"#2E75B6",headerIconColor:"rgba(0,0,0,0.28)",dragIndicatorFill:"rgba(59,130,246,0.12)",dragIndicatorLine:"#3b82f6",dragGhostShadow:"rgba(15,23,42,0.30)",deletedRowFill:"rgba(239,68,68,0.10)",deletedRowStrike:"rgba(239,68,68,0.55)",invalidCellBorder:"#dc2626",fontSize:13,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',locale:"en-US",overlayBg:"#FFFFFF",overlayBorder:"#D0D0D0",overlayHeaderBg:"#F5F5F5",overlayDivider:"#E0E0E0",overlayText:"#212121",overlayMutedText:"#595959",overlayHintText:"#909090",overlayHoverBg:"#F5F5F5",overlayItemHoverBg:"#F0F0F0",overlayShadow:"0 4px 16px rgba(0,0,0,0.15)",overlayMenuShadow:"0 4px 12px rgba(0,0,0,0.15)",overlayAccentText:"#FFFFFF",pagerBg:"#f8fafc",pagerBorder:"#e2e8f0",pagerText:"#1e293b",pagerButtonBg:"#ffffff",pagerButtonBorder:"#cbd5e1",readonlyCellBg:"#F5F5F5",editableCellBg:void 0,imagePlaceholderBg:"#F1F5F9",imageErrorBg:"#FEE2E2",imageErrorIcon:"#DC2626"},gt={richtext(){return(r,{x:t,y:e,w:s,h:i,value:o,theme:n,padding:l})=>{if(o==null||o==="")return;let a=xs(String(o));if(!a.length)return;r.textAlign="left",r.textBaseline="middle",r.fillStyle=n.cellText,r.save(),r.beginPath(),r.rect(t,e,s,i),r.clip();let c=t+l,h=e+i/2;for(let d of a){r.font=`${d.italic?"italic ":""}${d.bold?"bold ":""}${n.fontSize}px ${n.fontFamily}`,r.fillText(d.text,c,h);let u=r.measureText(d.text).width;if(d.underline||d.strike){r.strokeStyle=n.cellText,r.lineWidth=1;let f=d.underline?h+n.fontSize/2-1:h;r.beginPath(),r.moveTo(c,f),r.lineTo(c+u,f),r.stroke()}c+=u}r.restore()}},tree({indentPx:r=ie,inner:t}={}){let e=(s,{x:i,y:o,w:n,h:l,value:a,theme:c,padding:h})=>{s.fillStyle=a!=null?c.cellText:c.loadingText,s.textAlign="left",s.textBaseline="middle",s.save(),s.beginPath(),s.rect(i,o,n,l),s.clip(),s.fillText(a!=null?String(a):"",i+h,o+l/2),s.restore()};return(s,i)=>{let{x:o,y:n,w:l,h:a,rowData:c,theme:h}=i;if(!c?.__tree__){(t??e)(s,i);return}let d=(c.__treeLevel??0)*r,u=o+d+ye;c.__treeHasChildren&&(s.fillStyle=h.cellText,s.font=`${h.fontSize}px ${h.fontFamily}`,s.textAlign="left",s.textBaseline="middle",s.fillText(c.__treeExpanded?"\u25BE":"\u25B8",o+d,n+a/2)),(t??e)(s,{...i,x:u,w:o+l-u})}},progressBar({max:r=100,showLabel:t=!0}={}){return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=Number(l);if(isNaN(h))return;let d=Math.max(0,Math.min(1,h/r)),u=t?36:0,f=s+c,_=Math.max(0,o-c*2-u),g=6,w=i+(n-g)/2,m=3;if(e.fillStyle="#e2e8f0",e.beginPath(),e.roundRect?e.roundRect(f,w,_,g,m):e.rect(f,w,_,g),e.fill(),d>0){e.fillStyle=d>=.8?"#16a34a":d>=.5?"#f59e0b":"#ef4444",e.beginPath();let v=Math.max(m*2,_*d);e.roundRect?e.roundRect(f,w,v,g,m):e.rect(f,w,v,g),e.fill()}t&&(e.fillStyle=a.cellText,e.font=`${a.fontSize}px ${a.fontFamily}`,e.textAlign="right",e.textBaseline="middle",e.fillText(`${Math.round(d*100)}%`,s+o-c,i+n/2))}},badge({colorMap:r={}}={}){return(t,{x:e,y:s,w:i,h:o,value:n,theme:l})=>{if(n==null||n==="")return;let a=String(n),{bg:c="#f1f5f9",fg:h="#475569"}=r[a]??{},d=8;t.font=`${l.fontSize-1}px ${l.fontFamily}`;let u=t.measureText(a).width,f=Math.min(u+d*2,i-8),_=o-10,g=e+(i-f)/2,w=s+5,m=_/2;t.fillStyle=c,t.beginPath(),t.roundRect?t.roundRect(g,w,f,_,m):t.rect(g,w,f,_),t.fill(),t.fillStyle=h,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,s+o/2)}},checkmark({trueColor:r="#16a34a",falseColor:t="#94a3b8",showFalse:e=!0}={}){return(s,{x:i,y:o,w:n,h:l,value:a,theme:c})=>{let h=a===!0||a===1||a==="Y"||a==="\uC608"||a==="true";!h&&!e||(s.fillStyle=h?r:t,s.font=`bold ${c.fontSize+1}px ${c.fontFamily}`,s.textAlign="center",s.textBaseline="middle",s.fillText(h?"\u2713":"\u2717",i+n/2,o+l/2))}},image({fit:r="cover",radius:t=0}={}){return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{if(!l)return;let h=s+c,d=i+c,u=o-c*2,f=n-c*2;if(u<=0||f<=0)return;let _=Le(String(l),u,f);if(e.save(),e.beginPath(),t>0&&e.roundRect?e.roundRect(h,d,u,f,t):e.rect(h,d,u,f),e.clip(),_?.status==="loaded"&&_.bitmap){let g=_.bitmap,w=r==="contain"?Math.min(u/g.width,f/g.height):Math.max(u/g.width,f/g.height),m=g.width*w,v=g.height*w;e.drawImage(g,h+(u-m)/2,d+(f-v)/2,m,v)}else _?.status==="error"?(e.fillStyle=a.imageErrorBg,e.fillRect(h,d,u,f),e.strokeStyle=a.imageErrorIcon,e.lineWidth=1.5,e.beginPath(),e.moveTo(h+u*.3,d+f*.3),e.lineTo(h+u*.7,d+f*.7),e.moveTo(h+u*.7,d+f*.3),e.lineTo(h+u*.3,d+f*.7),e.stroke()):(e.fillStyle=a.imagePlaceholderBg,e.fillRect(h,d,u,f));e.restore()}},number({locale:r,decimals:t=0}={}){let e,s;return(i,{x:o,y:n,w:l,h:a,value:c,theme:h,padding:d})=>{let u=r??h.locale;(e===void 0||s!==u)&&(e=new Intl.NumberFormat(u,{minimumFractionDigits:t,maximumFractionDigits:t}),s=u);let f=Number(c);if(c==null||c===""||isNaN(f))return;let _=e.format(f);i.fillStyle=h.cellText,i.font=`${h.fontSize}px ${h.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,l,a),i.clip(),i.fillText(_,o+l-d,n+a/2),i.restore()}},date({format:r="YYYY-MM-DD",locale:t,dateStyle:e,align:s="left"}={}){let i,o;return(n,{x:l,y:a,w:c,h,value:d,theme:u,padding:f})=>{if(d==null||d==="")return;let _=d instanceof Date?d:typeof d=="number"?new Date(d):new Date(String(d)),g=String(d);if(!isNaN(_.getTime()))if(r==="locale"){let m=t??u.locale;(i===void 0||o!==m)&&(i=new Intl.DateTimeFormat(m,e?{dateStyle:e}:void 0),o=m),g=i.format(_)}else{let m=String(_.getFullYear()).padStart(4,"0"),v=String(_.getMonth()+1).padStart(2,"0"),S=String(_.getDate()).padStart(2,"0"),b=String(_.getHours()).padStart(2,"0"),E=String(_.getMinutes()).padStart(2,"0"),C=String(_.getSeconds()).padStart(2,"0"),T=m.slice(-2);g=r.replace("YYYY",m).replace("YY",T).replace("MM",v).replace("DD",S).replace("HH",b).replace("mm",E).replace("ss",C)}let w=s==="right"?l+c-f:s==="center"?l+c/2:l+f;n.fillStyle=u.cellText,n.font=`${u.fontSize}px ${u.fontFamily}`,n.textAlign=s,n.textBaseline="middle",n.save(),n.beginPath(),n.rect(l,a,c,h),n.clip(),n.fillText(g,w,a+h/2),n.restore()}},currency({locale:r,currency:t="KRW"}={}){let e,s;return(i,{x:o,y:n,w:l,h:a,value:c,theme:h,padding:d})=>{let u=r??h.locale;(e===void 0||s!==u)&&(e=new Intl.NumberFormat(u,{style:"currency",currency:t}),s=u);let f=Number(c);if(c==null||c===""||isNaN(f))return;let _=e.format(f);i.fillStyle=h.cellText,i.font=`${h.fontSize}px ${h.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,l,a),i.clip(),i.fillText(_,o+l-d,n+a/2),i.restore()}},dropdown({placeholder:r=""}={}){let t=se;return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=l!=null&&l!==""?String(l):r;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=l!=null&&l!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(h,s+c,i+n/2),e.restore(),e.fillStyle="rgba(0,0,0,0.06)",e.fillRect(s+o-t,i+1,t-1,n-2),e.fillStyle=a.headerText??a.cellText,e.font=`11px ${a.fontFamily}`,e.textAlign="center",e.fillText("\u25BE",s+o-t/2,i+n/2)}},multiselect({placeholder:r=""}={}){let t=se;return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=l!=null&&l!==""?String(l):r;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=l!=null&&l!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(h,s+c,i+n/2),e.restore(),e.fillStyle="rgba(0,0,0,0.06)",e.fillRect(s+o-t,i+1,t-1,n-2),e.fillStyle=a.headerText??a.cellText,e.font=`11px ${a.fontFamily}`,e.textAlign="center",e.fillText("\u25BE",s+o-t/2,i+n/2)}},checkbox({checkedColor:r="#2563eb",size:t=14}={}){return(e,{x:s,y:i,w:o,h:n,value:l})=>{let a=l===!0||l===1||l==="true"||l==="1"||l==="Y"||l==="yes",c=s+(o-t)/2,h=i+(n-t)/2,d=3;e.beginPath(),e.roundRect?e.roundRect(c,h,t,t,d):e.rect(c,h,t,t),a?(e.fillStyle=r,e.fill(),e.strokeStyle="#fff",e.lineWidth=1.8,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(c+3,h+t/2),e.lineTo(c+t/2-1,h+t-4),e.lineTo(c+t-3,h+3.5),e.stroke()):(e.fillStyle="#fff",e.fill(),e.strokeStyle="#C0C0C0",e.lineWidth=1.5,e.stroke())}},button({label:r="Button",disabled:t=!1,variant:e="primary"}={}){let s={primary:"#2563eb",success:"#16a34a",danger:"#dc2626",neutral:"#64748b"};return(i,{x:o,y:n,w:l,h:a,theme:c,rowData:h,rowIndex:d})=>{let u=typeof r=="function"?r(h,d):r;if(u==null||u==="")return;let f=typeof t=="function"?!!t(h,d):!!t,_=typeof e=="function"?e(h,d):e;i.font=`${c.fontSize-1}px ${c.fontFamily}`;let g=i.measureText(u).width,w=Math.min(a-8,24),m=Math.min(l-8,g+24);if(m<=0||w<=0)return;let v=o+(l-m)/2,S=n+(a-w)/2;i.beginPath(),i.roundRect?i.roundRect(v,S,m,w,w/2):i.rect(v,S,m,w),i.fillStyle=f?"#cbd5e1":s[_]??s.primary,i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(u,v+m/2,S+w/2)}}},vs=new Set(Object.keys(gt));function be(r,t){vs.has(r)&&console.warn(`[JHGrid] registerCellRenderer: "${r}" is a built-in renderer name and will be overwritten`),gt[r]=t}var we=/<\/?(b|i|u|s)>/g;function xs(r){let t=[],e={bold:!1,italic:!1,underline:!1,strike:!1},s=l=>l.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),i=l=>{l&&t.push({text:s(l),...e})};we.lastIndex=0;let o=0,n;for(;n=we.exec(r);){i(r.slice(o,n.index)),o=we.lastIndex;let l=n[0][1]==="/",a={b:"bold",i:"italic",u:"underline",s:"strike"}[n[1]];e[a]=!l}return i(r.slice(o)),t}var Gt=class r{#t;#e;constructor(t,e){this.#t=t.getContext("2d"),this.#e=e}render({scrollTop:t,scrollLeft:e,totalRows:s,columns:i,columnLabels:o,columnAligns:n,columnHeaderAligns:l,getRow:a,geo:c,rowLayout:h,sel:d,editing:u,headerFocusCol:f,rowFocus:_,colDrag:g,rowDrag:w,sorts:m,filters:v,columnRenderers:S,invalidCells:b,selectedRows:E,fillPreview:C,deletedRows:T,skeletonPhase:$,rowNumberLabel:M,grouping:j,groupFooter:O,hiddenNeighbors:V,editableColumns:P,i18n:H,headerCheckboxCols:R,hoverRow:F=null,selAnim:A=null,colSlide:it=null,remoteSelections:z=null}){let{headerHeight:G,theme:x}=this.#e,{headerRows:k}=this.#e,{width:D,height:L}=this.#e,p=this.#t,{vpH:N,vpW:Z,SB:dt,vSB:rt=dt,hSB:ot=dt,frozenCount:K=0,frozenWidth:W=0,frozenRightCount:q=0,frozenRightWidth:ut=0,rightX:Q=0,colPositions:J,headerH:U,footerH:wt=0,maxRow:Lt,rowNumW:Rt=0}=c,Dt=o??i,ft=i.length,I=d,ht=A?.prev?{prev:A.prev,t:A.t}:null;p.fillStyle=x.rowEven,p.fillRect(0,0,D,L);let st=Lt??s-1,nt=Math.max(0,h.rowAt(t,st)),pt=h.rowAt(t+N,st),at=pt<0?st:Math.min(st,pt+1),Et=ft-1-q,At=J[K],xt=K;for(;xt<Et&&J[xt+1]-At<=e;)xt++;let Mt=xt;for(;Mt<Et&&J[Mt]-At<e+Z;)Mt++;if(Mt=Math.min(Et,Mt+1),p.save(),p.beginPath(),p.rect(W,U,Z,N),p.clip(),this.#l(nt,at,xt,Mt,t,e,i,n,a,h,U,x,K,W,q,Q,J,S,b,E,T,P,F,$),p.restore(),K>0&&(p.save(),p.beginPath(),p.rect(0,U,W,N),p.clip(),this.#l(nt,at,0,K-1,t,e,i,n,a,h,U,x,K,W,q,Q,J,S,b,E,T,P,F,$),p.restore()),q>0&&(p.save(),p.beginPath(),p.rect(Q,U,ut,N),p.clip(),this.#l(nt,at,ft-q,ft-1,t,e,i,n,a,h,U,x,K,W,q,Q,J,S,b,E,T,P,F,$),p.restore()),I){let Y=mt=>mt.type==="single"?mt.col:mt.c1,tt=mt=>mt.type==="single"?mt.col:mt.c2,et=ht?.prev,X=et?Math.min(Y(I),Y(et)):Y(I),lt=et?Math.max(tt(I),tt(et)):tt(I);K>0&&X<K&&(p.save(),p.beginPath(),p.rect(0,U,W,N),p.clip(),this.#c(I,u,t,e,h,U,x,K,W,q,Q,J,ht),p.restore()),lt>=K&&X<ft-q&&(p.save(),p.beginPath(),p.rect(W,U,Z,N),p.clip(),this.#c(I,u,t,e,h,U,x,K,W,q,Q,J,ht),p.restore()),q>0&<>=ft-q&&(p.save(),p.beginPath(),p.rect(Q,U,ut,N),p.clip(),this.#c(I,u,t,e,h,U,x,K,W,q,Q,J,ht),p.restore())}if(z&&z.length)for(let Y of z){let tt=Y.sel;if(!tt)continue;let et=tt.type==="single"?tt.col:tt.c1,X=tt.type==="single"?tt.col:tt.c2;K>0&&et<K&&(p.save(),p.beginPath(),p.rect(0,U,W,N),p.clip(),this.#a(tt,Y.color,Y.label,t,e,h,U,K,W,q,Q,J),p.restore()),X>=K&&et<ft-q&&(p.save(),p.beginPath(),p.rect(W,U,Z,N),p.clip(),this.#a(tt,Y.color,Y.label,t,e,h,U,K,W,q,Q,J),p.restore()),q>0&&X>=ft-q&&(p.save(),p.beginPath(),p.rect(Q,U,ut,N),p.clip(),this.#a(tt,Y.color,Y.label,t,e,h,U,K,W,q,Q,J),p.restore())}if(E&&E.size>0){let Y=D-rt,tt=Math.max(0,J[ft-q]-W-e),et=Math.min(Y,W+Math.min(Z,tt)+ut);p.save(),p.beginPath(),p.rect(0,U,et,N),p.clip(),p.strokeStyle=x.selectionColor,p.lineWidth=2;for(let X=nt;X<=at;X++){if(!E.has(X)||X>nt&&E.has(X-1))continue;let lt=X;for(;lt<at&&E.has(lt+1);)lt++;let mt=E.has(X-1)?U-4:h.yOf(X)-t+U,Tt=E.has(lt+1)?U+N+4:h.yOf(lt)-t+U+h.heightOf(lt);p.strokeRect(1,mt+1,et-2,Tt-mt-2),X=lt}p.restore()}if(p.save(),p.beginPath(),p.rect(W,0,Z,U),p.clip(),this.#r(Dt,l??n,i,m,v,xt,Mt,e,U,G,k,x,K,W,q,Q,J,V,R,d,W,Z),p.restore(),K>0&&(p.save(),p.beginPath(),p.rect(0,0,W,U),p.clip(),this.#r(Dt,l??n,i,m,v,0,K-1,e,U,G,k,x,K,W,q,Q,J,V,R,d,0,W),p.restore()),q>0&&(p.save(),p.beginPath(),p.rect(Q,0,ut,U),p.clip(),this.#r(Dt,l??n,i,m,v,ft-q,ft-1,e,U,G,k,x,K,W,q,Q,J,V,R,d,Q,ut),p.restore()),K>0){p.strokeStyle=x.frozenBorder,p.lineWidth=2,p.beginPath();let Y=Math.round(W)+.5;p.moveTo(Y,0),p.lineTo(Y,L-ot),p.stroke()}if(q>0){p.strokeStyle=x.frozenBorder,p.lineWidth=2,p.beginPath();let Y=Math.round(Q)+.5;p.moveTo(Y,0),p.lineTo(Y,L-ot),p.stroke()}if(f!=null&&f>=0&&f<i.length){let Y=f<K,tt=q>0&&f>=ft-q,et=this.#n(f,K,W,q,Q,e,J),X=J[f+1]-J[f];p.save(),p.beginPath(),Y?p.rect(0,0,W,U):tt?p.rect(Q,0,ut,U):p.rect(W,0,Z,U),p.clip(),p.strokeStyle=x.selectionColor,p.lineWidth=2,p.strokeRect(et+1,1,Math.max(0,X-2),Math.max(0,U-2)),p.restore()}if(_!=null&&Rt>0){let Y=h.yOf(_)-t+U,tt=h.heightOf(_);Y+tt>U&&Y<L-ot&&(p.save(),p.beginPath(),p.rect(0,U,Rt,N),p.clip(),p.strokeStyle=x.selectionColor,p.lineWidth=2,p.strokeRect(1,Y+1,Math.max(0,Rt-2),Math.max(0,tt-2)),p.restore())}if(d&&!u){let tt=d.type==="single"?d.row:d.r2,et=d.type==="single"?d.col:d.c2,X=this.#n(et,K,W,q,Q,e,J)+(J[et+1]-J[et]),lt=h.yOf(tt+1)-t+U;X>=W-7&&X<=D-rt+7&<>=U&<<=L-ot+7&&(p.fillStyle=x.selectionColor,p.fillRect(Math.round(X)-7/2,Math.round(lt)-7/2,7,7))}if(C){let{r1:Y,c1:tt,r2:et,c2:X}=C,lt=this.#n(tt,K,W,q,Q,e,J),mt=h.yOf(Y)-t+U,Tt=this.#n(X,K,W,q,Q,e,J)+(J[X+1]-J[X])-lt,St=h.yOf(et+1)-h.yOf(Y);p.fillStyle=x.selectionFill,p.fillRect(lt,mt,Tt,St),p.setLineDash([4,3]),p.strokeStyle=x.selectionColor,p.lineWidth=2,p.strokeRect(lt+1,mt+1,Tt-2,St-2),p.setLineDash([])}if(it&&it.c1>=0&&it.c2<ft&&it.dragCol>=0&&it.dragCol<ft&&it.dx!==0){let{c1:Y,c2:tt,dx:et,dragCol:X}=it,lt=Math.min(Y,X),mt=Math.max(tt,X),Tt=Ft=>this.#n(Ft,K,W,q,Q,e,J),St=Math.max(0,Tt(lt)),kt=Math.min(D-rt,Tt(mt)+(J[mt+1]-J[mt])),Ut=(Ft,jt,he)=>{p.save(),p.translate(he,0),this.#l(nt,at,Ft,jt,t,e,i,n,a,h,U,x,K,W,q,Q,J,S,b,E,T,P,F,$),this.#r(Dt,l??n,i,m,v,Ft,jt,e,U,G,k,x,K,W,q,Q,J,V,R,d),p.restore()};kt>St&&(p.save(),p.beginPath(),p.rect(St,0,kt-St,L-ot),p.clip(),p.fillStyle=x.headerBg,p.fillRect(St,0,kt-St,U),p.fillStyle=x.rowEven,p.fillRect(St,U,kt-St,L-ot-U),Ut(Y,tt,et),Ut(X,X,0),p.restore())}if(g?.active){let{col:Y,insertBefore:tt}=g,et=this.#n(Y,K,W,q,Q,e,J),X=J[Y+1]-J[Y];p.fillStyle=x.dragIndicatorFill,p.fillRect(et,0,X,L-ot);let lt=i.length,mt=tt<lt?this.#n(tt,K,W,q,Q,e,J):this.#n(lt-1,K,W,q,Q,e,J)+(J[lt]-J[lt-1]);if(p.strokeStyle=x.dragIndicatorLine,p.lineWidth=3,p.beginPath(),p.moveTo(mt,0),p.lineTo(mt,L-ot),p.stroke(),g.x!==void 0){let Tt=G,St=U-G,kt=Math.max(0,Math.min(D-rt-X,g.x-g.grabDX));p.save(),p.globalAlpha=.92,p.shadowColor=x.dragGhostShadow,p.shadowBlur=8,p.shadowOffsetY=2,p.fillStyle=x.headerBg,p.fillRect(kt,St,X,Tt),p.restore(),p.save(),p.beginPath(),p.rect(kt,St,X,Tt),p.clip(),p.globalAlpha=.92,p.strokeStyle=x.dragIndicatorLine,p.lineWidth=1,p.strokeRect(kt+.5,St+.5,X-1,Tt-1),p.font=`bold ${x.headerFontSize??x.fontSize}px ${x.fontFamily}`,p.fillStyle=x.headerText,p.textAlign="left",p.textBaseline="middle",p.fillText(this.#u(String(Dt[Y]??i[Y]??""),X-x.cellPadding*2),kt+x.cellPadding,St+Tt/2),p.restore()}}if(w?.active){let{row:Y,insertBefore:tt}=w,et=h.yOf(Y)-t+U;p.fillStyle=x.dragIndicatorFill,p.fillRect(0,et,D-rt,h.heightOf(Y));let X=h.yOf(tt)-t+U;p.strokeStyle=x.dragIndicatorLine,p.lineWidth=3,p.beginPath(),p.moveTo(0,X),p.lineTo(D-rt,X),p.stroke()}if(j){let{rowNumW:Y}=c;this.#o(nt,at,t,h,U,x,D,rt,Y,a,i,o??i,H)}let{rowNumW:_t}=c;if(_t>0&&this.#i(nt,at,t,h,_t,L,U,ot,x,M,E,F),O&&wt>0){let Y=L-ot-wt;p.save(),p.beginPath(),p.rect(W,Y,Z,wt),p.clip(),this.#s(O,i,n,xt,Mt,e,Y,wt,x,K,W,q,Q,J,H),p.restore(),K>0&&(p.save(),p.beginPath(),p.rect(0,Y,W,wt),p.clip(),this.#s(O,i,n,0,K-1,e,Y,wt,x,K,W,q,Q,J,H),p.restore()),q>0&&(p.save(),p.beginPath(),p.rect(Q,Y,ut,wt),p.clip(),this.#s(O,i,n,ft-q,ft-1,e,Y,wt,x,K,W,q,Q,J,H),p.restore())}this.#d(c,x,D,L)}#i(t,e,s,i,o,n,l,a,c,h,d,u){let f=this.#t;f.save(),f.beginPath(),f.rect(0,0,o,n-a),f.clip(),f.fillStyle=c.headerBg,f.fillRect(0,0,o,l),f.font=`bold ${c.headerFontSize??c.fontSize}px ${c.fontFamily}`,f.fillStyle=c.headerText,f.textAlign="center",f.textBaseline="middle",f.fillText(h??"No.",o/2,l/2),f.textAlign="center",f.textBaseline="middle",f.save(),f.beginPath(),f.rect(0,l,o,Math.max(0,n-a-l)),f.clip();for(let _=t;_<=e;_++){let g=i.yOf(_)-s+l,w=i.heightOf(_),m=d?.has(_);f.fillStyle=c.headerBg,f.fillRect(0,g,o,w),m&&(f.fillStyle=c.selectionColor,f.globalAlpha=.28,f.fillRect(0,g,o,w),f.globalAlpha=1),u&&u.row===_&&u.alpha>0&&c.hoverRowBg&&(f.globalAlpha=Math.min(1,u.alpha),f.fillStyle=c.hoverRowBg,f.fillRect(0,g,o,w),f.globalAlpha=1),f.font=m?`bold ${c.fontSize-1}px ${c.fontFamily}`:`${c.fontSize-1}px ${c.fontFamily}`,f.fillStyle=m?c.sortIconColor??c.selectionColor:c.headerText,f.fillText(String(_+1),o/2,g+w/2),f.strokeStyle=c.headerBorder,f.lineWidth=1,f.beginPath(),f.moveTo(0,Math.round(g+w)-.5),f.lineTo(o,Math.round(g+w)-.5),f.stroke()}f.restore(),f.strokeStyle=c.headerBorder,f.lineWidth=1,f.beginPath(),f.moveTo(0,l-.5),f.lineTo(o,l-.5),f.stroke(),f.strokeStyle=c.frozenBorder??c.headerBorder,f.lineWidth=1.5,f.beginPath(),f.moveTo(o-.5,0),f.lineTo(o-.5,n-a),f.stroke(),f.restore()}#o(t,e,s,i,o,n,l,a,c,h,d,u,f){let _=this.#t,g=c,w=l-a-c;if(w<=0)return;let m=n.cellPadding,v=f?.groupLabel??((S,b,E)=>`${S}: ${b} (${E})`);for(let S=t;S<=e;S++){let b=h(S);if(!b?.__group__)continue;let E=i.yOf(S)-s+o,C=i.heightOf(S),T=(b.level??0)*ie;_.fillStyle=n.groupHeaderBg,_.fillRect(g,E,w,C),_.strokeStyle=n.cellBorder,_.lineWidth=1,_.strokeRect(Math.round(g)+.5,Math.round(E)+.5,w-1,C-1),_.fillStyle=n.groupHeaderText,_.font=`bold ${n.fontSize}px ${n.fontFamily}`,_.textAlign="left",_.textBaseline="middle";let $=b.collapsed?"\u25B8":"\u25BE";_.fillText(`${$} ${v(b.field,b.key,b.count)}`,g+m+T,E+C/2);let M=Object.entries(b.aggregates??{});if(M.length){_.font=`${n.fontSize-1}px ${n.fontFamily}`,_.textAlign="right";let j=M.map(([O,V])=>`${u[d.indexOf(O)]??O} ${V}`).join(" ");_.fillText(j,g+w-m,E+C/2)}}}#s(t,e,s,i,o,n,l,a,c,h,d,u,f,_,g){if(i>o)return;let w=this.#t,m=c.cellPadding,v=_.length-1,S=i<h?0:u>0&&i>=v-u?f-_[v-u]:d-_[h]-n;w.fillStyle=c.footerBg,w.fillRect(_[i]+S,l,_[o+1]-_[i],a),w.font=`bold ${c.fontSize}px ${c.fontFamily}`,w.textBaseline="middle";let b=l+a/2;i===0&&(w.fillStyle=c.footerText,w.textAlign="left",w.font=`bold ${c.fontSize-1}px ${c.fontFamily}`,w.fillText(g?.groupFooterLabel??"Total",_[i]+S+m,b),w.font=`bold ${c.fontSize}px ${c.fontFamily}`);for(let C=i;C<=o;C++){let T=t[e[C]];if(T==null)continue;let $=_[C]+S,M=_[C+1]-_[C];w.fillStyle=c.footerText;let j=s?.[C]??"left";w.textAlign=j;let O=j==="right"?$+M-m:j==="center"?$+M/2:$+m;w.fillText(this.#u(String(T),M-m*2),O,b)}w.strokeStyle=c.headerBorder,w.lineWidth=1,w.beginPath();let E=Math.round(l)+.5;w.moveTo(_[i]+S,E),w.lineTo(_[o+1]+S,E),w.stroke()}#n(t,e,s,i,o,n,l){return ee(t,{frozenCount:e,frozenWidth:s,frozenRightCount:i,rightX:o,colPositions:l},n)}#r(t,e,s,i,o,n,l,a,c,h,d,u,f,_,g,w,m,v,S,b,E=0,C=1/0){if(n>l)return;let T=this.#t,$=u.cellPadding,M=b?b.type==="single"?b.col:b.c1:null,j=b?b.type==="single"?b.col:b.c2:null,O=m.length-1,V=x=>g>0&&x>=O-g,P=n<f?0:V(n)?w-m[O-g]:_-m[f]-a,H=m[n]+P,R=m[l+1]-m[n];T.fillStyle=u.headerBg,T.fillRect(H,0,R,c);let A=zt(d,s,this.#e.columnLetterHeader).filter(x=>x.col+x.colspan-1>=n&&x.col<=l);T.strokeStyle=u.headerBorder,T.lineWidth=1,T.beginPath();for(let x of A){let k=m[x.col]+P,D=m[x.col+x.colspan]-m[x.col],L=x.row*h,p=x.rowspan*h,N=Math.round(k+D)+.5,Z=L+p+.5;T.moveTo(N,L),T.lineTo(N,L+p),T.moveTo(k,Z),T.lineTo(k+D,Z)}T.stroke();let it=x=>x<f?0:V(x)?2:1,z=it(n);T.textBaseline="middle",T.fillStyle=u.headerText;let G="";for(let x of A){let k=m[x.col]+P,D=m[x.col+x.colspan]-m[x.col],L=x.row*h,p=x.rowspan*h,N=L+p/2;x.isLeaf&&M!==null&&x.col>=M&&x.col<=j&&(T.fillStyle=u.selectionColor,T.globalAlpha=.28,T.fillRect(k,L,D,p),T.globalAlpha=1,T.fillStyle=u.headerText);let Z=x.isLeaf?s[x.col]:null,dt=x.isLeaf&&!!o?.[Z],rt=x.isLeaf&&i?.length?i.findIndex(st=>st.field===Z):-1,ot=rt>=0?i[rt]:null,K=i?.length>1,W=k+D-Bt;if(x.isLeaf&&dt?(T.fillStyle=u.filterIconBg??"rgba(245,158,11,0.18)",T.fillRect(W+1,L+3,Bt-2,p-6),T.fillStyle=u.headerText):x.isLeaf&&ot&&(T.fillStyle=u.sortIconBg??"rgba(46,117,182,0.12)",T.fillRect(W+1,L+3,Bt-2,p-6),T.fillStyle=u.headerText),!(x.isLeaf||it(x.col)===z))continue;let ut=k,Q=D;if(!x.isLeaf){let st=Math.max(x.col,n),nt=Math.min(x.col+x.colspan-1,l);ut=m[st]+P,Q=m[nt+1]-m[st];let pt=E+C;ut<E&&(Q-=E-ut,ut=E),ut+Q>pt&&(Q=pt-ut),Q=Math.max(0,Q)}let J=x.isLeaf?e?.[x.col]??"left":x.align??"center",U=x.isLeaf?Bt+4:0,wt=x.isLeaf&&S?.has(Z),Lt=wt?20:0,Rt=Q-$*2-U-Lt,Dt=u.headerFontSize??u.fontSize;T.font=`bold ${Dt}px ${u.fontFamily}`;let ft=wt?"left":J;ft!==G&&(T.textAlign=ft,G=ft);let I=J==="right"?ut+Q-$-U:wt?ut+$+Lt:J==="center"?ut+Q/2:ut+$,ht=x.isLeaf?t[x.col]??"":x.label??"";if(this.#e.wrapHeader&&ht){let st=this.#g(ht,Rt),nt=Dt*1.4,pt=N-(st.length-1)*nt/2;for(let at of st)T.fillText(at,I,pt),pt+=nt}else T.fillText(this.#u(ht,Rt),I,N);if(x.isLeaf){T.font=`bold ${Dt-1}px ${u.fontFamily}`,T.textAlign="center",G="center",T.fillStyle=dt?u.filterIconColor??"#C87B00":ot?u.sortIconColor??"#2E75B6":u.headerIconColor??"rgba(0,0,0,0.28)";let st=ot?ot.dir==="asc"?"\u2191":"\u2193":"\u25BE",nt=ot&&K?`${rt+1}${st}`:st;T.fillText(nt,W+Bt/2,N),T.fillStyle=u.headerText}}if(v){T.fillStyle=u.hiddenColIndicator??"#94A3B8";for(let x of A){if(!x.isLeaf)continue;let k=v[x.col];if(!k?.left&&!k?.right)continue;let D=m[x.col]+P,L=m[x.col+x.colspan]-m[x.col],p=x.row*h,N=x.rowspan*h;k.right&&T.fillRect(D+L-1,p,1,N),k.left&&T.fillRect(D,p,1,N)}}}#l(t,e,s,i,o,n,l,a,c,h,d,u,f,_,g,w,m,v,S,b,E,C,T,$){if(t>e||s>i)return;let M=this.#t,j=u.cellPadding,O=m.length-1,V=s<f?0:g>0&&s>=O-g?w-m[O-g]:_-m[f]-n,P=m[s]+V,H=m[i+1]-m[s];M.font=`${u.fontSize}px ${u.fontFamily}`,M.textBaseline="middle";let R=M.measureText("\u2026").width;for(let k=t;k<=e;k++)M.fillStyle=k%2===0?u.rowEven:u.rowOdd,M.fillRect(P,h.yOf(k)-o+d,H,h.heightOf(k));if(C){let k=u.editableCellBg,D=u.readonlyCellBg;if(k||D)for(let L=s;L<=i;L++){let p=C[L]?k:D;if(!p)continue;let N=m[L]+V,Z=m[L+1]-m[L];M.fillStyle=p;for(let dt=t;dt<=e;dt++)M.fillRect(N,h.yOf(dt)-o+d,Z,h.heightOf(dt))}}for(let k=t;k<=e;k++){let D=h.yOf(k)-o+d,L=h.heightOf(k);b?.has(k)&&(M.fillStyle=u.selRowBg,M.fillRect(P,D,H,L));let p=this.#e.rowHighlighter?.(c(k),k);p&&(M.fillStyle=p,M.fillRect(P,D,H,L)),E?.has(k)&&(M.fillStyle=u.deletedRowFill,M.fillRect(P,D,H,L))}let F=this.#e.cellBackground;if(F)for(let k=t;k<=e;k++){let D=h.yOf(k)-o+d,L=h.heightOf(k),p=c(k);for(let N=s;N<=i;N++){let Z;try{Z=F(p,k,l[N],N)}catch(ot){console.error("[JHGrid] cellBackground error at row",k,"col",N,":",ot);continue}if(!Z)continue;let dt=m[N]+V,rt=m[N+1]-m[N];M.fillStyle=Z,M.fillRect(dt,D,rt,L)}}if(T&&T.alpha>0&&T.row>=t&&T.row<=e&&u.hoverRowBg){let k=h.yOf(T.row)-o+d;M.globalAlpha=Math.min(1,T.alpha),M.fillStyle=u.hoverRowBg,M.fillRect(P,k,H,h.heightOf(T.row)),M.globalAlpha=1}let A=Math.round(h.yOf(t)-o+d),it=Math.round(h.yOf(e+1)-o+d);M.strokeStyle=u.cellBorder,M.lineWidth=1,M.beginPath();for(let k=s;k<=i+1;k++){let D=Math.round(m[k]+V)+.5;M.moveTo(D,A),M.lineTo(D,it)}for(let k=t;k<=e+1;k++){if(b?.has(k)&&b.has(k-1))continue;let D=Math.round(h.yOf(k)-o+d)+.5;M.moveTo(P,D),M.lineTo(P+H,D)}M.stroke();let z="",G="";for(let k=t;k<=e;k++){let D=c(k),L=h.yOf(k)-o+d;for(let p=s;p<=i;p++){let N=D?D[l[p]]:null,Z=m[p]+V,dt=m[p+1]-m[p],rt=h.heightOf(k),ot=L+rt/2,K=v?.[p];if(K&&D){M.save();try{K(M,{x:Z,y:L,w:dt,h:rt,value:N,rowData:D,rowIndex:k,colIndex:p,theme:u,padding:j})}catch(wt){console.error("[JHGrid] Custom renderer error at row",k,"col",p,":",wt)}M.restore();continue}if(D==null){let Lt=(dt-j*2)*this.#f(k,p);if(Lt>2){let Rt=Math.min(9,rt-12);M.fillStyle=u.skeletonBar,this.#_(Z+j,ot-Rt/2,Lt,Rt,3),G=null}continue}let W=N!=null?u.cellText:u.loadingText,q=a?.[p]??"left";W!==G&&(M.fillStyle=W,G=W),q!==z&&(M.textAlign=q,z=q);let ut=q==="right"?Z+dt-j:q==="center"?Z+dt/2:Z+j,Q=dt-j*2,J=N!=null?String(N):"";if(J.indexOf(`
|
|
2
|
+
`)!==-1){let wt=J.split(`
|
|
3
|
+
`),Lt=u.fontSize*1.4,Rt=ot-(wt.length-1)*Lt/2;M.save(),M.beginPath(),M.rect(Z,L,dt,rt),M.clip();for(let Dt of wt)M.fillText(this.#w(Dt,Q,R),ut,Rt),Rt+=Lt;M.restore();continue}let U=Math.floor(Q/(u.fontSize*.5));M.fillText(J.length<=U&&!r.#m(J)?J:this.#w(J,Q,R),ut,ot)}}if($!=null){let k=H*.28,D=P-k+(H+k*2)*$;for(let L=t;L<=e;L++){if(c(L)!=null)continue;let p=h.yOf(L)-o+d;M.save(),M.beginPath(),M.rect(P,p,H,h.heightOf(L)),M.clip(),M.fillStyle=u.skeletonSheen,M.fillRect(D,p,k,h.heightOf(L)),M.restore()}}if(E){M.strokeStyle=u.deletedRowStrike,M.lineWidth=1;for(let k=t;k<=e;k++){if(!E.has(k))continue;let D=Math.round(h.yOf(k)-o+d+h.heightOf(k)/2)+.5;M.beginPath(),M.moveTo(P,D),M.lineTo(P+H,D),M.stroke()}}if(S&&S.size){M.strokeStyle=u.invalidCellBorder,M.lineWidth=1.5;for(let k=t;k<=e;k++){let D=h.yOf(k)-o+d;for(let L=s;L<=i;L++){if(!S.has(`${k}_${l[L]}`))continue;let p=m[L]+V,N=m[L+1]-m[L],Z=h.heightOf(k);M.strokeRect(Math.round(p)+1,Math.round(D)+1,N-2,Z-2)}}}let x=this.#e.cellDecorator;if(x)for(let k=t;k<=e;k++){let D=c(k);if(D==null)continue;let L=h.yOf(k)-o+d,p=h.heightOf(k);for(let N=s;N<=i;N++){let Z=m[N]+V,dt=m[N+1]-m[N],rt=l[N];M.save();try{x(M,{x:Z,y:L,w:dt,h:p,value:D[rt],rowData:D,field:rt,rowIndex:k,colIndex:N,theme:u,padding:j})}catch(ot){console.error("[JHGrid] cellDecorator error at row",k,"col",N,":",ot)}M.restore()}}}#h(t,e,s,i,o,n,l,a,c,h){if(!t)return null;let d=v=>this.#n(v,n,l,a,c,s,h),u=v=>i.yOf(v)-e+o;if(t.type==="single")return{x:d(t.col),y:u(t.row),w:h[t.col+1]-h[t.col],h:i.heightOf(t.row)};let{r1:f,c1:_,r2:g,c2:w}=t,m=d(_);return{x:m,y:u(f),w:d(w)+(h[w+1]-h[w])-m,h:i.yOf(g+1)-i.yOf(f)}}#c(t,e,s,i,o,n,l,a,c,h,d,u,f){let _=this.#t;if(t.type==="single"&&e?.row===t.row&&e?.col===t.col)return;let g=[s,i,o,n,a,c,h,d,u],{x:w,y:m,w:v,h:S}=this.#h(t,...g);if(f?.prev&&f.t<1){let b=this.#h(f.prev,...g);if(b){let E=f.t;w=b.x+(w-b.x)*E,m=b.y+(m-b.y)*E,v=b.w+(v-b.w)*E,S=b.h+(S-b.h)*E}}t.type==="range"&&(_.fillStyle=l.selectionFill,_.fillRect(w,m,v,S)),_.strokeStyle=l.selectionColor,_.lineWidth=2,_.strokeRect(w+1,m+1,v-2,S-2)}#a(t,e,s,i,o,n,l,a,c,h,d,u){let f=this.#t,{x:_,y:g,w,h:m}=this.#h(t,i,o,n,l,a,c,h,d,u);if(f.save(),f.strokeStyle=e,f.lineWidth=2,f.strokeRect(_+1,g+1,w-2,m-2),s){f.font=`bold 11px ${this.#e.theme.fontFamily}`;let v=this.#u(s,100),S=f.measureText(v).width+8,b=14,E=g-b>=l?g-b:g+m;f.fillStyle=e,f.fillRect(_,E,S,b),f.fillStyle="#fff",f.textAlign="left",f.textBaseline="middle",f.fillText(v,_+4,E+b/2)}f.restore()}#d({v:t,h:e,SB:s,vSB:i=s,hSB:o=s,frozenWidth:n=0,frozenRightWidth:l=0,rightX:a=0,headerH:c=0},h,d,u){if(!i&&!o)return;let f=this.#t,_=h.scrollbarRadius;f.fillStyle=h.scrollbarBg,i>0&&o>0&&f.fillRect(d-i,u-o,i,o),o>0&&n>0&&f.fillRect(0,u-o,n,o),o>0&&l>0&&f.fillRect(a,u-o,l,o),i>0&&c>0&&f.fillRect(d-i,0,i,c),f.fillRect(t.x,t.y,t.w,t.h),f.fillStyle=h.scrollbarThumb,this.#_(t.x+2,t.thumbY+2,t.w-4,t.thumbH-4,_),f.fillStyle=h.scrollbarBg,f.fillRect(e.x,e.y,e.w,e.h),f.fillStyle=h.scrollbarThumb,this.#_(e.thumbX+2,e.y+2,e.thumbW-4,e.h-4,_)}#_(t,e,s,i,o){if(s<=0||i<=0)return;let n=this.#t;n.beginPath(),n.roundRect?n.roundRect(t,e,s,i,o):n.rect(t,e,s,i),n.fill()}#f(t,e){return .45+(t*73+e*151)%100/100*.4}#g(t,e){let s=this.#t,i=t.split(" "),o=[],n="";for(let l of i){let a=n?n+" "+l:l;s.measureText(a).width<=e?n=a:(n&&o.push(n),n=s.measureText(l).width>e?this.#u(l,e):l)}return n&&o.push(n),o.length?o:[t]}static#p=/[\u{1100}-\u{FFEF}\u{1F000}-\u{1FFFF}]/u;static#m(t){return r.#p.test(t)}#u(t,e){let s=this.#t;if(!t||s.measureText(t).width<=e)return t;let i=s.measureText("\u2026").width;return this.#w(t,e,i)}#w(t,e,s){let i=this.#t;if(i.measureText(t).width<=e)return t;let o=0,n=t.length;for(;o<n;){let l=o+n+1>>1;i.measureText(t.slice(0,l)).width+s<=e?o=l:n=l-1}return o>0?t.slice(0,o)+"\u2026":"\u2026"}};var B={root:"jhg-root",loading:"jhg-loading",empty:"jhg-empty",tooltip:"jhg-tooltip",overlay:"jhg-overlay",panel:"jhg-panel",dialog:"jhg-dialog",menu:"jhg-menu",menuItem:"jhg-menu-item",chip:"jhg-chip",chipContains:"jhg-chip-contains",treeGroup:"jhg-tree-group",treeToggle:"jhg-tree-toggle",btn:"jhg-btn",swatch:"jhg-swatch",pager:"jhg-pager",pagerBtn:"jhg-pager-btn",editor:"jhg-editor"},He={overlayBg:"--jhg-overlay-bg",overlayBorder:"--jhg-overlay-border",overlayHeaderBg:"--jhg-overlay-header-bg",overlayDivider:"--jhg-overlay-divider",overlayText:"--jhg-overlay-text",overlayMutedText:"--jhg-overlay-muted-text",overlayHintText:"--jhg-overlay-hint-text",overlayHoverBg:"--jhg-overlay-hover-bg",overlayItemHoverBg:"--jhg-overlay-item-hover-bg",overlayShadow:"--jhg-overlay-shadow",overlayMenuShadow:"--jhg-overlay-menu-shadow",overlayAccentText:"--jhg-overlay-accent-text",selectionColor:"--jhg-accent",pagerBg:"--jhg-pager-bg",pagerText:"--jhg-pager-text",pagerBorder:"--jhg-pager-border",pagerButtonBg:"--jhg-pager-button-bg",pagerButtonBorder:"--jhg-pager-button-border",fontFamily:"--jhg-font-family"};function y(r,t){let e=r?.[t],s=He[t];return s?`var(${s}, ${e})`:e}var ri=Object.freeze({...He}),Be="jhgrid-styles",Cs=`
|
|
4
4
|
.${B.root} {
|
|
5
5
|
--jhg-motion-fast: 140ms;
|
|
6
6
|
--jhg-motion-slow: 180ms;
|
|
@@ -116,13 +116,13 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
|
|
|
116
116
|
and may be mounted outside .${B.root}, where those variables never reach it. */
|
|
117
117
|
.${B.treeToggle}, .${B.treeGroup} { transition: none; }
|
|
118
118
|
}
|
|
119
|
-
`;function Oe(r=typeof document<"u"?document:null){if(!(!r?.head||r.getElementById(Be)))try{let t=r.createElement("style");t.id=Be,t.textContent=Cs,r.head.appendChild(t)}catch{}}var oe=(r,t,e,s,i)=>({position:"absolute",left:t+"px",top:e+"px",width:s+"px",height:i+"px",border:`2px solid ${y(r,"selectionColor")}`,outline:"none",padding:`0 ${r.cellPadding}px`,fontSize:r.fontSize+"px",fontFamily:y(r,"fontFamily"),background:y(r,"overlayBg"),color:r.cellText,zIndex:"10",boxSizing:"border-box"});function ve({el:r,wrapper:t,x:e,y:s,offsetY:i=0}){let o=()=>{let n=t.getBoundingClientRect();r.style.left=n.left+e+"px",r.style.top=n.top+s+i+"px"};return o(),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}}function ze(r,{wrapper:t,x:e,y:s,colW:i,rowH:o}){let n=t.getBoundingClientRect(),l=n.left+e,a=n.top+s;return r.clientX>=l&&r.clientX<l+i&&r.clientY>=a&&r.clientY<a+o}var Ht={text(){return r=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,kbProxy:l,i18n:a,columnLabel:c,row:h,initialValue:d,keepInputValue:u}=r,f=l;if(f._jhEditorBlur&&f.removeEventListener("blur",f._jhEditorBlur),f._jhEditorKeydown&&f.removeEventListener("keydown",f._jhEditorKeydown),u||(f.value=d),f.setAttribute("aria-label",a.editAriaLabel(c,h+1)),f.className=B.editor,f.style.cssText="",Object.assign(f.style,oe(t,e,s,i,o)),f.parentElement!==n&&n.appendChild(f),!u){f.focus();let w=f.value.length;f.setSelectionRange(w,w)}let _=()=>r.commit(),
|
|
120
|
-
`+d.value.slice(w),d.setSelectionRange(p+1,p+1);return}if(_.key==="Enter"){if(_.isComposing||_.keyCode===229)return;_.preventDefault(),_.stopPropagation(),r.commit(),r.moveSel(1,0),r.focusWrapper()}else if(_.key==="Tab")_.preventDefault(),_.stopPropagation(),r.commit(),r.moveSel(0,_.shiftKey?-1:1),r.focusWrapper();else if(_.key==="Escape")_.preventDefault(),_.stopPropagation(),r.cancel(),r.focusWrapper();else{let p=_.key.toLowerCase();(_.ctrlKey||_.metaKey)&&!["c","v","x","a"].includes(p)&&_.stopPropagation()}};return d.addEventListener("blur",u),d.addEventListener("keydown",f),d}},date({mode:r="date",min:t,max:e,format:s}={}){if(s){let o=s.match(/[^A-Za-z0-9]/)?.[0]??"/",n=s.split(/[^A-Za-z0-9]+/).map(_=>_.length),l=n.reduce((_,p)=>_+p,0),a=s.match(/YYYY|YY|MM|DD|HH|mm|ss/g)??[],c=a.includes("HH")||a.includes("mm")||a.includes("ss"),h=c?"datetime-local":"date",d=_=>{let p="",w=0;for(let m=0;m<n.length;m++){let x=_.slice(w,w+n[m]);if(!x)break;p&&(p+=o),p+=x,w+=n[m]}return p},u=_=>{let p={},w=0;for(let m of a){let x=_.slice(w,w+m.length);if(w+=m.length,x.length<m.length)return null;m==="YYYY"?p.Y=x:m==="YY"?p.Y="20"+x:m==="MM"?p.M=x:m==="DD"?p.D=x:m==="HH"?p.H=x:m==="mm"&&(p.Mi=x)}return!p.Y||!p.M||!p.D?null:c?`${p.Y}-${p.M}-${p.D}T${p.H??"00"}:${p.Mi??"00"}`:`${p.Y}-${p.M}-${p.D}`},f=_=>{let p=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/.exec(_);if(!p)return"";let[,w,m,x,S,v]=p,b="";for(let C of a)C==="YYYY"?b+=w:C==="YY"?b+=w.slice(-2):C==="MM"?b+=m:C==="DD"?b+=x:C==="HH"?b+=S??"00":C==="mm"&&(b+=v??"00");return d(b)};return _=>{let{theme:p,x:w,y:m,colW:x,rowH:S,wrapper:v,i18n:b,columnLabel:C,row:H,initialValue:D}=_,A=a.length&&x>40?22:0,j=x-A,O=document.createElement("input");O.type="text",O.value=String(D??""),O.setAttribute("aria-label",b.editAriaLabel(C,H+1)),Object.assign(O.style,oe(p,w,m,j,S)),v.appendChild(O);let V=null,z=null;if(A>0){V=document.createElement("input"),V.type=h,t!=null&&(V.min=t),e!=null&&(V.max=e),V.tabIndex=-1,V.setAttribute("aria-label",b.editAriaLabel(C,H+1)+" calendar"),Object.assign(V.style,{position:"absolute",left:w+j+"px",top:m+"px",width:A+"px",height:S+"px",opacity:"0",border:"none",padding:"0",margin:"0",zIndex:"9"}),v.appendChild(V),z=document.createElement("div"),z.textContent=String.fromCodePoint(128197),z.setAttribute("aria-hidden","true"),Object.assign(z.style,{position:"absolute",left:w+j+"px",top:m+"px",width:A+"px",height:S+"px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.min(p.fontSize,14)+"px",pointerEvents:"none",zIndex:"10"}),v.appendChild(z);let W=u(O.value.replace(/\D/g,"").slice(0,l));W!=null&&(V.value=W),V.addEventListener("click",()=>{if(typeof V.showPicker=="function")try{V.showPicker()}catch{}}),V.addEventListener("change",()=>{O.value=f(V.value),_.commit(),_.focusWrapper()}),V.addEventListener("blur",E=>{E.relatedTarget!==O&&_.commit()})}return O.focus(),O.select(),O.addEventListener("input",()=>{let W=O.selectionStart,E=O.value.slice(0,W).replace(/\D/g,"").length,L=O.value.replace(/\D/g,"").slice(0,l),M=d(L);if(O.value=M,V){let I=u(L);I!=null&&(V.value=I)}let Q=M.length,R=0;for(let I=0;I<M.length;I++)if(/\d/.test(M[I])&&(R++,R===E)){Q=I+1;break}O.setSelectionRange(Q,Q)}),O.addEventListener("blur",W=>{V&&W.relatedTarget===V||_.commit()}),O.addEventListener("keydown",W=>{W.key==="Enter"?(W.preventDefault(),W.stopPropagation(),_.commit(),_.moveSel(1,0),_.focusWrapper()):W.key==="Tab"?(W.preventDefault(),W.stopPropagation(),_.commit(),_.moveSel(0,W.shiftKey?-1:1),_.focusWrapper()):W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),_.cancel(),_.focusWrapper())}),{get value(){return O.value},remove(){O.remove(),V&&V.remove(),z&&z.remove()}}}}let i=r==="datetime-local"?16:10;return o=>{let{theme:n,x:l,y:a,colW:c,rowH:h,wrapper:d,i18n:u,columnLabel:f,row:_,initialValue:p}=o,w=document.createElement("input");return w.type=r==="datetime-local"?"datetime-local":"date",t!=null&&(w.min=t),e!=null&&(w.max=e),w.value=String(p??"").slice(0,i),w.setAttribute("aria-label",u.editAriaLabel(f,_+1)),w.className=B.editor,Object.assign(w.style,oe(n,l,a,c,h)),d.appendChild(w),w.focus(),w.addEventListener("blur",()=>o.commit()),w.addEventListener("keydown",m=>{m.key==="Enter"?(m.preventDefault(),m.stopPropagation(),o.commit(),o.moveSel(1,0),o.focusWrapper()):m.key==="Tab"?(m.preventDefault(),m.stopPropagation(),o.commit(),o.moveSel(0,m.shiftKey?-1:1),o.focusWrapper()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),o.cancel(),o.focusWrapper())}),w}},dropdown({options:r}={}){return t=>{let{theme:e,x:s,y:i,colW:o,rowH:n,wrapper:l,i18n:a,columnLabel:c,row:h,rowData:d,initialValue:u}=t,f=typeof r=="function"?r(d??{}):r??[];if(!f.length)return null;let _=u,p=document.createElement("div");Object.assign(p.style,{position:"absolute",left:s+"px",top:i+"px",width:o+"px",height:n+"px",border:`2px solid ${e.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),l.appendChild(p);let w=l.getBoundingClientRect(),m=w.left+s,x=w.top+i+n,S=document.createElement("div");S.setAttribute("role","listbox"),S.setAttribute("aria-label",a.editAriaLabel(c,h+1)),Object.assign(S.style,{position:"fixed",left:m+"px",top:x+"px",minWidth:o+"px",maxHeight:"240px",overflowY:"auto",background:e.overlayBg,border:`1px solid ${e.overlayBorder}`,borderRadius:"4px",boxShadow:e.overlayMenuShadow,zIndex:"99999",fontSize:e.fontSize+"px",fontFamily:e.fontFamily,color:e.cellText});let v=-1,b=[],C=E=>{b.forEach((L,M)=>{L.style.background=M===E?e.selectionColor:L.dataset.val===_?e.selectionFill:e.overlayBg,L.style.color=M===E?e.overlayAccentText:e.cellText}),v=E,E>=0&&b[E].scrollIntoView({block:"nearest"})};for(let E=0;E<f.length;E++){let L=f[E],M=typeof L=="string"?L:L.value,Q=typeof L=="string"?L:L.label??L.value,R=document.createElement("div");R.setAttribute("role","option"),R.dataset.val=M,R.textContent=Q,Object.assign(R.style,{padding:"6px 10px",cursor:"pointer",background:M===_?e.selectionFill:e.overlayBg,whiteSpace:"nowrap"}),R.addEventListener("mouseenter",()=>C(E)),R.addEventListener("mouseleave",()=>C(-1)),R.addEventListener("mousedown",I=>{I.preventDefault(),I.stopPropagation(),_=M,O()}),S.appendChild(R),b.push(R)}document.body.appendChild(S);let H=ve({el:S,wrapper:l,x:s,y:i,offsetY:n}),D=!0,A={get value(){return _},remove(){j(),p.remove(),S.remove()}},j=()=>{H(),document.removeEventListener("mousedown",z,!0),document.removeEventListener("keydown",W,!0)},O=()=>{D&&(D=!1,j(),t.commit(),t.focusWrapper())},V=()=>{D&&(D=!1,j(),t.cancel(),t.focusWrapper())},z=E=>{S.contains(E.target)||(ze(E,{wrapper:l,x:s,y:i,colW:o,rowH:n})&&t.suppressReopen?.(),V())},W=E=>{E.key==="Escape"?(E.preventDefault(),E.stopPropagation(),V()):E.key==="ArrowDown"?(E.preventDefault(),E.stopPropagation(),C(Math.min(v+1,b.length-1))):E.key==="ArrowUp"?(E.preventDefault(),E.stopPropagation(),C(Math.max(v-1,0))):E.key==="Enter"?(E.preventDefault(),E.stopPropagation(),v>=0&&(_=b[v].dataset.val),O()):E.key==="Tab"&&(E.preventDefault(),E.stopPropagation(),v>=0&&(_=b[v].dataset.val),O(),t.moveSel(0,E.shiftKey?-1:1))};return document.addEventListener("mousedown",z,!0),document.addEventListener("keydown",W,!0),A}},multiselect({options:r=[],delimiter:t=","}={}){return e=>{let{theme:s,x:i,y:o,colW:n,rowH:l,wrapper:a,i18n:c,columnLabel:h,row:d,rowData:u,initialValue:f}=e,_=typeof r=="function"?r(u??{}):r;if(!_.length)return null;let p=new Set(String(f??"").split(t).map(z=>z.trim()).filter(Boolean)),w=document.createElement("div");Object.assign(w.style,{position:"absolute",left:i+"px",top:o+"px",width:n+"px",height:l+"px",border:`2px solid ${s.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),a.appendChild(w);let m=a.getBoundingClientRect(),x=m.left+i,S=m.top+o+l,v=document.createElement("div");v.setAttribute("role","listbox"),v.setAttribute("aria-multiselectable","true"),v.setAttribute("aria-label",c.editAriaLabel(h,d+1)),Object.assign(v.style,{position:"fixed",left:x+"px",top:S+"px",minWidth:n+"px",maxHeight:"240px",overflowY:"auto",background:s.overlayBg,border:`1px solid ${s.overlayBorder}`,borderRadius:"4px",boxShadow:s.overlayMenuShadow,zIndex:"99999",fontSize:s.fontSize+"px",fontFamily:s.fontFamily,color:s.cellText}),_.forEach(z=>{let W=typeof z=="string"?z:z.value,E=typeof z=="string"?z:z.label??z.value,L=p.has(W),M=document.createElement("div");M.setAttribute("role","option"),M.setAttribute("aria-selected",String(L)),Object.assign(M.style,{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",cursor:"pointer",background:L?s.selectionFill:s.overlayBg,userSelect:"none",whiteSpace:"nowrap"});let Q=document.createElement("input");Q.type="checkbox",Q.checked=L,Q.tabIndex=-1,Q.style.pointerEvents="none";let R=document.createElement("span");R.textContent=E,M.appendChild(Q),M.appendChild(R),M.addEventListener("mouseenter",()=>{M.style.background=s.selectionColor,M.style.color=s.overlayAccentText}),M.addEventListener("mouseleave",()=>{M.style.background=p.has(W)?s.selectionFill:s.overlayBg,M.style.color=s.cellText}),M.addEventListener("mousedown",I=>{I.preventDefault(),I.stopPropagation(),Q.checked=!Q.checked,M.setAttribute("aria-selected",String(Q.checked)),Q.checked?p.add(W):p.delete(W),M.style.background=p.has(W)?s.selectionFill:s.overlayBg,M.style.color=s.cellText}),v.appendChild(M)}),document.body.appendChild(v);let b=ve({el:v,wrapper:a,x:i,y:o,offsetY:l}),C=!0,H={get value(){return[...p].join(t)},remove(){w.remove(),v.remove(),D()}},D=()=>{b(),document.removeEventListener("mousedown",O,!0),document.removeEventListener("keydown",V,!0)},A=()=>{C&&(C=!1,D(),e.commit(),e.focusWrapper())},j=()=>{C&&(C=!1,D(),e.cancel(),e.focusWrapper())},O=z=>{v.contains(z.target)||(ze(z,{wrapper:a,x:i,y:o,colW:n,rowH:l})&&e.suppressReopen?.(),A())},V=z=>{z.key==="Escape"?(z.preventDefault(),z.stopPropagation(),j()):z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),A()):z.key==="Tab"&&(z.preventDefault(),z.stopPropagation(),A(),e.moveSel(0,z.shiftKey?-1:1))};return document.addEventListener("mousedown",O,!0),document.addEventListener("keydown",V,!0),H}},richtext({marks:r=["bold","italic","underline","strike"]}={}){let t={bold:"bold",italic:"italic",underline:"underline",strike:"strikeThrough"},e={bold:"B",italic:"I",underline:"U",strike:"S"};return s=>{let{theme:i,x:o,y:n,colW:l,rowH:a,wrapper:c,i18n:h,columnLabel:d,row:u,initialValue:f}=s,_=document.createElement("div");Object.assign(_.style,{position:"absolute",left:o+"px",top:n+"px",width:l+"px",height:a+"px",border:`2px solid ${i.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),c.appendChild(_);let p=c.getBoundingClientRect(),w=p.left+o,m=p.top+n,x=document.createElement("div");x.setAttribute("role","toolbar"),x.setAttribute("aria-label",h.richtextToolbarLabel??"Formatting"),Object.assign(x.style,{position:"fixed",left:w+"px",top:m-30+"px",display:"flex",gap:"2px",padding:"2px",background:i.overlayBg,border:`1px solid ${i.overlayBorder}`,borderRadius:"4px",boxShadow:i.overlayMenuShadow,zIndex:"99999"});let S={},v=()=>{for(let E of r){let L=!1;try{L=document.queryCommandState(t[E])}catch{}S[E].setAttribute("aria-pressed",String(L)),S[E].style.background=L?i.selectionFill:i.overlayBg}};for(let E of r){let L=document.createElement("button");L.type="button",L.textContent=e[E]??E[0].toUpperCase(),L.setAttribute("aria-label",E),L.setAttribute("aria-pressed","false"),Object.assign(L.style,{width:"24px",height:"24px",border:"none",background:i.overlayBg,cursor:"pointer",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,fontWeight:E==="bold"?"bold":"normal",fontStyle:E==="italic"?"italic":"normal",textDecoration:E==="underline"?"underline":E==="strike"?"line-through":"none"}),L.addEventListener("mousedown",M=>{M.preventDefault();try{document.execCommand(t[E],!1,null)}catch{}v(),C.focus()}),x.appendChild(L),S[E]=L}document.body.appendChild(x);let b=ve({el:x,wrapper:c,x:o,y:n,offsetY:-30}),C=document.createElement("div");C.contentEditable="true",C.setAttribute("role","textbox"),C.setAttribute("aria-multiline","false"),C.setAttribute("aria-label",h.editAriaLabel(d,u+1)),C.innerHTML=Ie(String(f??"")),Object.assign(C.style,{position:"absolute",left:o+"px",top:n+"px",width:l+"px",height:a+"px",border:`2px solid ${i.selectionColor}`,outline:"none",boxSizing:"border-box",padding:`0 ${i.cellPadding}px`,lineHeight:a+"px",whiteSpace:"nowrap",overflow:"hidden",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,background:i.overlayBg,color:i.cellText,zIndex:"10"}),c.appendChild(C),C.focus();let H=document.createRange();H.selectNodeContents(C),H.collapse(!1);let D=window.getSelection();D.removeAllRanges(),D.addRange(H);let A=!0,j={get value(){return Ie(C.innerHTML)},remove(){O(),_.remove(),x.remove(),C.remove()}},O=()=>{document.removeEventListener("mousedown",W,!0),b(),document.removeEventListener("selectionchange",v)},V=()=>{A&&(A=!1,O(),s.commit(),s.focusWrapper())},z=()=>{A&&(A=!1,O(),s.cancel(),s.focusWrapper())},W=E=>{!C.contains(E.target)&&!x.contains(E.target)&&V()};return C.addEventListener("keydown",E=>{if(E.key==="Enter"){if(E.isComposing||E.keyCode===229)return;E.preventDefault(),E.stopPropagation(),V(),s.moveSel(1,0)}else if(E.key==="Tab")E.preventDefault(),E.stopPropagation(),V(),s.moveSel(0,E.shiftKey?-1:1);else if(E.key==="Escape")E.preventDefault(),E.stopPropagation(),z();else{let L=E.key.toLowerCase();(E.ctrlKey||E.metaKey)&&!["c","v","x","a"].includes(L)&&E.stopPropagation()}}),C.addEventListener("input",v),document.addEventListener("mousedown",W,!0),v(),j}}},Ss=new Set(Object.keys(Ht));function xe(r,t){Ss.has(r)&&console.warn(`[JHGrid] registerCellEditor: "${r}" is a built-in editor name and will be overwritten`),Ht[r]=t}var Es=new Set(["B","STRONG","I","EM","U","S","STRIKE","DEL"]),Rs={STRONG:"B",EM:"I",STRIKE:"S",DEL:"S"},As=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function Ms(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ie(r){let t=document.createElement("template");t.innerHTML=r;let e=t.content,s=[],i=1,o=3,n=l=>{for(let a of Array.from(l.childNodes))if(a.nodeType===o)s.push(Ms(a.textContent.replace(/[\r\n]+/g," ")));else if(a.nodeType===i){let c=a.tagName;if(As.has(c))continue;if(c==="BR"){s.push(" ");continue}if(c==="DIV"||c==="P"){n(a),s.push(" ");continue}let h=Rs[c]??(Es.has(c)?c:null);if(h){let d=h.toLowerCase();s.push(`<${d}>`),n(a),s.push(`</${d}>`)}else n(a)}};return n(e),s.join("").trim()}var ne=class{#t=[];#e=[];#i;constructor(t=100){this.#i=t}push(t){this.#t.push(t),this.#t.length>this.#i&&this.#t.shift(),this.#e.length=0}undo(){let t=this.#t.pop();t&&(t.undo(),this.#e.push(t))}redo(){let t=this.#e.pop();t&&(t.redo(),this.#t.push(t))}canUndo(){return this.#t.length>0}canRedo(){return this.#e.length>0}clear(){this.#t.length=0,this.#e.length=0}};var re=class{#t=new Map;#e;#i;#o;#s;#n;constructor({getColumnDef:t,getColumnLabel:e,getI18n:s,getRowData:i,onError:o}){this.#e=t,this.#i=e,this.#o=s,this.#s=i,this.#n=o}compute(t,e,s){let i=this.#e(e),o=i?.validation,n=this.#o(),l=this.#i(e)??e,a=s??"";if(o?.required&&a.trim()==="")return o.message??n.validationRequired(l);if(a==="")return null;if(!o)return this.#a(i,t,a,l,n);if(o.pattern){let c=o.pattern instanceof RegExp?o.pattern:new RegExp(o.pattern);if(c.lastIndex=0,!c.test(a))return o.message??n.validationPattern(l)}if(o.min!=null||o.max!=null){let c=i?.type==="date",h=c?Date.parse(a):Number(a);if(o.min!=null&&(isNaN(h)||h<(c?Date.parse(o.min):o.min)))return o.message??n.validationMin(l,o.min);if(o.max!=null&&(isNaN(h)||h>(c?Date.parse(o.max):o.max)))return o.message??n.validationMax(l,o.max)}if(o.minLength!=null&&a.length<o.minLength)return o.message??n.validationMinLength(l,o.minLength);if(o.maxLength!=null&&a.length>o.maxLength)return o.message??n.validationMaxLength(l,o.maxLength);if(o.validator){let c;try{c=o.validator(a,this.#s(t)??{})}catch(h){return console.error("[JHGrid] validator error at row",t,"field",e,":",h),null}if(typeof c=="string")return c;if(c===!1)return o.message??n.validationInvalid(l)}return this.#a(i,t,a,l,n)}#a(t,e,s,i,o){if(!t)return null;if(t.type==="dropdown"){let n=this.#r(t,e);if(n&&!n.includes(s))return o.validationInvalid(i)}else if(t.type==="multiselect"){let n=this.#r(t,e);if(n){let l=t.editorOptions?.delimiter??",";if(s.split(l).map(c=>c.trim()).filter(Boolean).some(c=>!n.includes(c)))return o.validationInvalid(i)}}else if(t.type==="date"&&!this.#l(s,t.format))return o.validationInvalid(i);return null}#l(t,e){let s=e?.match(/YYYY|YY|MM|DD|HH|mm|ss/g);if(!s?.length)return!isNaN(new Date(t).getTime());let i=e.match(/[^A-Za-z0-9]/)?.[0]??"/",o=t.split(i);if(o.length!==s.length)return!1;let n,l;for(let a=0;a<s.length;a++){if(!/^\d+$/.test(o[a]))return!1;s[a]==="MM"?n=Number(o[a]):s[a]==="DD"&&(l=Number(o[a]))}return!(n!=null&&(n<1||n>12)||l!=null&&(l<1||l>31))}#r(t,e){let s=typeof t.options=="function"?t.options(this.#s(e)??{}):t.options;return Array.isArray(s)?s.map(i=>typeof i=="string"?i:i.value):null}revalidate(t,e,s){let i=this.#e(e);if(!i?.validation&&!this.#c(i?.type))return null;let o=`${t}_${e}`,n=this.compute(t,e,s);return n?this.#t.set(o,n):this.#t.delete(o),this.#n?.(t,e,n??null),n}#c(t){return t==="dropdown"||t==="multiselect"||t==="date"}isValid(){return this.#t.size===0}getInvalidCells(){let t={};return this.#t.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=s.slice(i+1);(t[o]??={})[n]=e}),t}get map(){return this.#t}clear(){this.#t.clear()}};var Ts=/^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function We(r,t=","){let e=String(r??"");return/^[=+\-@\t\r]/.test(e)&&!Ts.test(e)&&(e="'"+e),e.includes(t)||e.includes('"')||e.includes(`
|
|
119
|
+
`;function Oe(r=typeof document<"u"?document:null){if(!(!r?.head||r.getElementById(Be)))try{let t=r.createElement("style");t.id=Be,t.textContent=Cs,r.head.appendChild(t)}catch{}}var oe=(r,t,e,s,i)=>({position:"absolute",left:t+"px",top:e+"px",width:s+"px",height:i+"px",border:`2px solid ${y(r,"selectionColor")}`,outline:"none",padding:`0 ${r.cellPadding}px`,fontSize:r.fontSize+"px",fontFamily:y(r,"fontFamily"),background:y(r,"overlayBg"),color:r.cellText,zIndex:"10",boxSizing:"border-box"});function ve({el:r,wrapper:t,x:e,y:s,offsetY:i=0}){let o=()=>{let n=t.getBoundingClientRect();r.style.left=n.left+e+"px",r.style.top=n.top+s+i+"px"};return o(),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}}function ze(r,{wrapper:t,x:e,y:s,colW:i,rowH:o}){let n=t.getBoundingClientRect(),l=n.left+e,a=n.top+s;return r.clientX>=l&&r.clientX<l+i&&r.clientY>=a&&r.clientY<a+o}var Ht={text(){return r=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,kbProxy:l,i18n:a,columnLabel:c,row:h,initialValue:d,keepInputValue:u}=r,f=l;if(f._jhEditorBlur&&f.removeEventListener("blur",f._jhEditorBlur),f._jhEditorKeydown&&f.removeEventListener("keydown",f._jhEditorKeydown),u||(f.value=d),f.setAttribute("aria-label",a.editAriaLabel(c,h+1)),f.className=B.editor,f.style.cssText="",Object.assign(f.style,oe(t,e,s,i,o)),f.parentElement!==n&&n.appendChild(f),!u){f.focus();let w=f.value.length;f.setSelectionRange(w,w)}let _=()=>r.commit(),g=w=>{if(w.key==="Enter"&&w.altKey)w.preventDefault(),w.stopPropagation(),r.insertLineBreak();else if(w.key==="Enter"){if(w.isComposing||w.keyCode===229)return;w.preventDefault(),w.stopPropagation(),r.commit(),r.moveSel(1,0),r.focusWrapper()}else w.key==="Tab"?(w.preventDefault(),w.stopPropagation(),r.commit(),r.moveSel(0,w.shiftKey?-1:1),r.focusWrapper()):w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),r.cancel(),r.focusWrapper())};return f._jhEditorBlur=_,f._jhEditorKeydown=g,f.addEventListener("blur",_),f.addEventListener("keydown",g),f}},textMultiline(){return r=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,i18n:l,columnLabel:a,row:c,initialValue:h}=r,d=document.createElement("textarea");d.value=h??"",d.setAttribute("aria-label",l.editAriaLabel(a,c+1)),d.className=B.editor,Object.assign(d.style,oe(t,e,s,i,o),{resize:"none",overflow:"auto",whiteSpace:"pre"}),n.appendChild(d),d.focus(),d.setSelectionRange(d.value.length,d.value.length);let u=()=>r.commit(),f=_=>{if(_.key==="Enter"&&_.altKey){_.preventDefault(),_.stopPropagation();let g=d.selectionStart??d.value.length,w=d.selectionEnd??d.value.length;d.value=d.value.slice(0,g)+`
|
|
120
|
+
`+d.value.slice(w),d.setSelectionRange(g+1,g+1);return}if(_.key==="Enter"){if(_.isComposing||_.keyCode===229)return;_.preventDefault(),_.stopPropagation(),r.commit(),r.moveSel(1,0),r.focusWrapper()}else if(_.key==="Tab")_.preventDefault(),_.stopPropagation(),r.commit(),r.moveSel(0,_.shiftKey?-1:1),r.focusWrapper();else if(_.key==="Escape")_.preventDefault(),_.stopPropagation(),r.cancel(),r.focusWrapper();else{let g=_.key.toLowerCase();(_.ctrlKey||_.metaKey)&&!["c","v","x","a"].includes(g)&&_.stopPropagation()}};return d.addEventListener("blur",u),d.addEventListener("keydown",f),d}},date({mode:r="date",min:t,max:e,format:s}={}){if(s){let o=s.match(/[^A-Za-z0-9]/)?.[0]??"/",n=s.split(/[^A-Za-z0-9]+/).map(_=>_.length),l=n.reduce((_,g)=>_+g,0),a=s.match(/YYYY|YY|MM|DD|HH|mm|ss/g)??[],c=a.includes("HH")||a.includes("mm")||a.includes("ss"),h=c?"datetime-local":"date",d=_=>{let g="",w=0;for(let m=0;m<n.length;m++){let v=_.slice(w,w+n[m]);if(!v)break;g&&(g+=o),g+=v,w+=n[m]}return g},u=_=>{let g={},w=0;for(let m of a){let v=_.slice(w,w+m.length);if(w+=m.length,v.length<m.length)return null;m==="YYYY"?g.Y=v:m==="YY"?g.Y="20"+v:m==="MM"?g.M=v:m==="DD"?g.D=v:m==="HH"?g.H=v:m==="mm"&&(g.Mi=v)}return!g.Y||!g.M||!g.D?null:c?`${g.Y}-${g.M}-${g.D}T${g.H??"00"}:${g.Mi??"00"}`:`${g.Y}-${g.M}-${g.D}`},f=_=>{let g=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/.exec(_);if(!g)return"";let[,w,m,v,S,b]=g,E="";for(let C of a)C==="YYYY"?E+=w:C==="YY"?E+=w.slice(-2):C==="MM"?E+=m:C==="DD"?E+=v:C==="HH"?E+=S??"00":C==="mm"&&(E+=b??"00");return d(E)};return _=>{let{theme:g,x:w,y:m,colW:v,rowH:S,wrapper:b,i18n:E,columnLabel:C,row:T,initialValue:$}=_,M=a.length&&v>40?22:0,j=v-M,O=document.createElement("input");O.type="text",O.value=String($??""),O.setAttribute("aria-label",E.editAriaLabel(C,T+1)),Object.assign(O.style,oe(g,w,m,j,S)),b.appendChild(O);let V=null,P=null;if(M>0){V=document.createElement("input"),V.type=h,t!=null&&(V.min=t),e!=null&&(V.max=e),V.tabIndex=-1,V.setAttribute("aria-label",E.editAriaLabel(C,T+1)+" calendar"),Object.assign(V.style,{position:"absolute",left:w+j+"px",top:m+"px",width:M+"px",height:S+"px",opacity:"0",border:"none",padding:"0",margin:"0",zIndex:"9"}),b.appendChild(V),P=document.createElement("div"),P.textContent=String.fromCodePoint(128197),P.setAttribute("aria-hidden","true"),Object.assign(P.style,{position:"absolute",left:w+j+"px",top:m+"px",width:M+"px",height:S+"px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.min(g.fontSize,14)+"px",pointerEvents:"none",zIndex:"10"}),b.appendChild(P);let H=u(O.value.replace(/\D/g,"").slice(0,l));H!=null&&(V.value=H),V.addEventListener("click",()=>{if(typeof V.showPicker=="function")try{V.showPicker()}catch{}}),V.addEventListener("change",()=>{O.value=f(V.value),_.commit(),_.focusWrapper()}),V.addEventListener("blur",R=>{R.relatedTarget!==O&&_.commit()})}return O.focus(),O.select(),O.addEventListener("input",()=>{let H=O.selectionStart,R=O.value.slice(0,H).replace(/\D/g,"").length,F=O.value.replace(/\D/g,"").slice(0,l),A=d(F);if(O.value=A,V){let G=u(F);G!=null&&(V.value=G)}let it=A.length,z=0;for(let G=0;G<A.length;G++)if(/\d/.test(A[G])&&(z++,z===R)){it=G+1;break}O.setSelectionRange(it,it)}),O.addEventListener("blur",H=>{V&&H.relatedTarget===V||_.commit()}),O.addEventListener("keydown",H=>{H.key==="Enter"?(H.preventDefault(),H.stopPropagation(),_.commit(),_.moveSel(1,0),_.focusWrapper()):H.key==="Tab"?(H.preventDefault(),H.stopPropagation(),_.commit(),_.moveSel(0,H.shiftKey?-1:1),_.focusWrapper()):H.key==="Escape"&&(H.preventDefault(),H.stopPropagation(),_.cancel(),_.focusWrapper())}),{get value(){return O.value},remove(){O.remove(),V&&V.remove(),P&&P.remove()}}}}let i=r==="datetime-local"?16:10;return o=>{let{theme:n,x:l,y:a,colW:c,rowH:h,wrapper:d,i18n:u,columnLabel:f,row:_,initialValue:g}=o,w=document.createElement("input");return w.type=r==="datetime-local"?"datetime-local":"date",t!=null&&(w.min=t),e!=null&&(w.max=e),w.value=String(g??"").slice(0,i),w.setAttribute("aria-label",u.editAriaLabel(f,_+1)),w.className=B.editor,Object.assign(w.style,oe(n,l,a,c,h)),d.appendChild(w),w.focus(),w.addEventListener("blur",()=>o.commit()),w.addEventListener("keydown",m=>{m.key==="Enter"?(m.preventDefault(),m.stopPropagation(),o.commit(),o.moveSel(1,0),o.focusWrapper()):m.key==="Tab"?(m.preventDefault(),m.stopPropagation(),o.commit(),o.moveSel(0,m.shiftKey?-1:1),o.focusWrapper()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),o.cancel(),o.focusWrapper())}),w}},dropdown({options:r}={}){return t=>{let{theme:e,x:s,y:i,colW:o,rowH:n,wrapper:l,i18n:a,columnLabel:c,row:h,rowData:d,initialValue:u}=t,f=typeof r=="function"?r(d??{}):r??[];if(!f.length)return null;let _=u,g=document.createElement("div");Object.assign(g.style,{position:"absolute",left:s+"px",top:i+"px",width:o+"px",height:n+"px",border:`2px solid ${e.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),l.appendChild(g);let w=l.getBoundingClientRect(),m=w.left+s,v=w.top+i+n,S=document.createElement("div");S.setAttribute("role","listbox"),S.setAttribute("aria-label",a.editAriaLabel(c,h+1)),Object.assign(S.style,{position:"fixed",left:m+"px",top:v+"px",minWidth:o+"px",maxHeight:"240px",overflowY:"auto",background:e.overlayBg,border:`1px solid ${e.overlayBorder}`,borderRadius:"4px",boxShadow:e.overlayMenuShadow,zIndex:"99999",fontSize:e.fontSize+"px",fontFamily:e.fontFamily,color:e.cellText});let b=-1,E=[],C=R=>{E.forEach((F,A)=>{F.style.background=A===R?e.selectionColor:F.dataset.val===_?e.selectionFill:e.overlayBg,F.style.color=A===R?e.overlayAccentText:e.cellText}),b=R,R>=0&&E[R].scrollIntoView({block:"nearest"})};for(let R=0;R<f.length;R++){let F=f[R],A=typeof F=="string"?F:F.value,it=typeof F=="string"?F:F.label??F.value,z=document.createElement("div");z.setAttribute("role","option"),z.dataset.val=A,z.textContent=it,Object.assign(z.style,{padding:"6px 10px",cursor:"pointer",background:A===_?e.selectionFill:e.overlayBg,whiteSpace:"nowrap"}),z.addEventListener("mouseenter",()=>C(R)),z.addEventListener("mouseleave",()=>C(-1)),z.addEventListener("mousedown",G=>{G.preventDefault(),G.stopPropagation(),_=A,O()}),S.appendChild(z),E.push(z)}document.body.appendChild(S);let T=ve({el:S,wrapper:l,x:s,y:i,offsetY:n}),$=!0,M={get value(){return _},remove(){j(),g.remove(),S.remove()}},j=()=>{T(),document.removeEventListener("mousedown",P,!0),document.removeEventListener("keydown",H,!0)},O=()=>{$&&($=!1,j(),t.commit(),t.focusWrapper())},V=()=>{$&&($=!1,j(),t.cancel(),t.focusWrapper())},P=R=>{S.contains(R.target)||(ze(R,{wrapper:l,x:s,y:i,colW:o,rowH:n})&&t.suppressReopen?.(),V())},H=R=>{R.key==="Escape"?(R.preventDefault(),R.stopPropagation(),V()):R.key==="ArrowDown"?(R.preventDefault(),R.stopPropagation(),C(Math.min(b+1,E.length-1))):R.key==="ArrowUp"?(R.preventDefault(),R.stopPropagation(),C(Math.max(b-1,0))):R.key==="Enter"?(R.preventDefault(),R.stopPropagation(),b>=0&&(_=E[b].dataset.val),O()):R.key==="Tab"&&(R.preventDefault(),R.stopPropagation(),b>=0&&(_=E[b].dataset.val),O(),t.moveSel(0,R.shiftKey?-1:1))};return document.addEventListener("mousedown",P,!0),document.addEventListener("keydown",H,!0),M}},multiselect({options:r=[],delimiter:t=","}={}){return e=>{let{theme:s,x:i,y:o,colW:n,rowH:l,wrapper:a,i18n:c,columnLabel:h,row:d,rowData:u,initialValue:f}=e,_=typeof r=="function"?r(u??{}):r;if(!_.length)return null;let g=new Set(String(f??"").split(t).map(P=>P.trim()).filter(Boolean)),w=document.createElement("div");Object.assign(w.style,{position:"absolute",left:i+"px",top:o+"px",width:n+"px",height:l+"px",border:`2px solid ${s.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),a.appendChild(w);let m=a.getBoundingClientRect(),v=m.left+i,S=m.top+o+l,b=document.createElement("div");b.setAttribute("role","listbox"),b.setAttribute("aria-multiselectable","true"),b.setAttribute("aria-label",c.editAriaLabel(h,d+1)),Object.assign(b.style,{position:"fixed",left:v+"px",top:S+"px",minWidth:n+"px",maxHeight:"240px",overflowY:"auto",background:s.overlayBg,border:`1px solid ${s.overlayBorder}`,borderRadius:"4px",boxShadow:s.overlayMenuShadow,zIndex:"99999",fontSize:s.fontSize+"px",fontFamily:s.fontFamily,color:s.cellText}),_.forEach(P=>{let H=typeof P=="string"?P:P.value,R=typeof P=="string"?P:P.label??P.value,F=g.has(H),A=document.createElement("div");A.setAttribute("role","option"),A.setAttribute("aria-selected",String(F)),Object.assign(A.style,{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",cursor:"pointer",background:F?s.selectionFill:s.overlayBg,userSelect:"none",whiteSpace:"nowrap"});let it=document.createElement("input");it.type="checkbox",it.checked=F,it.tabIndex=-1,it.style.pointerEvents="none";let z=document.createElement("span");z.textContent=R,A.appendChild(it),A.appendChild(z),A.addEventListener("mouseenter",()=>{A.style.background=s.selectionColor,A.style.color=s.overlayAccentText}),A.addEventListener("mouseleave",()=>{A.style.background=g.has(H)?s.selectionFill:s.overlayBg,A.style.color=s.cellText}),A.addEventListener("mousedown",G=>{G.preventDefault(),G.stopPropagation(),it.checked=!it.checked,A.setAttribute("aria-selected",String(it.checked)),it.checked?g.add(H):g.delete(H),A.style.background=g.has(H)?s.selectionFill:s.overlayBg,A.style.color=s.cellText}),b.appendChild(A)}),document.body.appendChild(b);let E=ve({el:b,wrapper:a,x:i,y:o,offsetY:l}),C=!0,T={get value(){return[...g].join(t)},remove(){w.remove(),b.remove(),$()}},$=()=>{E(),document.removeEventListener("mousedown",O,!0),document.removeEventListener("keydown",V,!0)},M=()=>{C&&(C=!1,$(),e.commit(),e.focusWrapper())},j=()=>{C&&(C=!1,$(),e.cancel(),e.focusWrapper())},O=P=>{b.contains(P.target)||(ze(P,{wrapper:a,x:i,y:o,colW:n,rowH:l})&&e.suppressReopen?.(),M())},V=P=>{P.key==="Escape"?(P.preventDefault(),P.stopPropagation(),j()):P.key==="Enter"?(P.preventDefault(),P.stopPropagation(),M()):P.key==="Tab"&&(P.preventDefault(),P.stopPropagation(),M(),e.moveSel(0,P.shiftKey?-1:1))};return document.addEventListener("mousedown",O,!0),document.addEventListener("keydown",V,!0),T}},richtext({marks:r=["bold","italic","underline","strike"]}={}){let t={bold:"bold",italic:"italic",underline:"underline",strike:"strikeThrough"},e={bold:"B",italic:"I",underline:"U",strike:"S"};return s=>{let{theme:i,x:o,y:n,colW:l,rowH:a,wrapper:c,i18n:h,columnLabel:d,row:u,initialValue:f}=s,_=document.createElement("div");Object.assign(_.style,{position:"absolute",left:o+"px",top:n+"px",width:l+"px",height:a+"px",border:`2px solid ${i.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),c.appendChild(_);let g=c.getBoundingClientRect(),w=g.left+o,m=g.top+n,v=document.createElement("div");v.setAttribute("role","toolbar"),v.setAttribute("aria-label",h.richtextToolbarLabel??"Formatting"),Object.assign(v.style,{position:"fixed",left:w+"px",top:m-30+"px",display:"flex",gap:"2px",padding:"2px",background:i.overlayBg,border:`1px solid ${i.overlayBorder}`,borderRadius:"4px",boxShadow:i.overlayMenuShadow,zIndex:"99999"});let S={},b=()=>{for(let R of r){let F=!1;try{F=document.queryCommandState(t[R])}catch{}S[R].setAttribute("aria-pressed",String(F)),S[R].style.background=F?i.selectionFill:i.overlayBg}};for(let R of r){let F=document.createElement("button");F.type="button",F.textContent=e[R]??R[0].toUpperCase(),F.setAttribute("aria-label",R),F.setAttribute("aria-pressed","false"),Object.assign(F.style,{width:"24px",height:"24px",border:"none",background:i.overlayBg,cursor:"pointer",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,fontWeight:R==="bold"?"bold":"normal",fontStyle:R==="italic"?"italic":"normal",textDecoration:R==="underline"?"underline":R==="strike"?"line-through":"none"}),F.addEventListener("mousedown",A=>{A.preventDefault();try{document.execCommand(t[R],!1,null)}catch{}b(),C.focus()}),v.appendChild(F),S[R]=F}document.body.appendChild(v);let E=ve({el:v,wrapper:c,x:o,y:n,offsetY:-30}),C=document.createElement("div");C.contentEditable="true",C.setAttribute("role","textbox"),C.setAttribute("aria-multiline","false"),C.setAttribute("aria-label",h.editAriaLabel(d,u+1)),C.innerHTML=Ie(String(f??"")),Object.assign(C.style,{position:"absolute",left:o+"px",top:n+"px",width:l+"px",height:a+"px",border:`2px solid ${i.selectionColor}`,outline:"none",boxSizing:"border-box",padding:`0 ${i.cellPadding}px`,lineHeight:a+"px",whiteSpace:"nowrap",overflow:"hidden",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,background:i.overlayBg,color:i.cellText,zIndex:"10"}),c.appendChild(C),C.focus();let T=document.createRange();T.selectNodeContents(C),T.collapse(!1);let $=window.getSelection();$.removeAllRanges(),$.addRange(T);let M=!0,j={get value(){return Ie(C.innerHTML)},remove(){O(),_.remove(),v.remove(),C.remove()}},O=()=>{document.removeEventListener("mousedown",H,!0),E(),document.removeEventListener("selectionchange",b)},V=()=>{M&&(M=!1,O(),s.commit(),s.focusWrapper())},P=()=>{M&&(M=!1,O(),s.cancel(),s.focusWrapper())},H=R=>{!C.contains(R.target)&&!v.contains(R.target)&&V()};return C.addEventListener("keydown",R=>{if(R.key==="Enter"){if(R.isComposing||R.keyCode===229)return;R.preventDefault(),R.stopPropagation(),V(),s.moveSel(1,0)}else if(R.key==="Tab")R.preventDefault(),R.stopPropagation(),V(),s.moveSel(0,R.shiftKey?-1:1);else if(R.key==="Escape")R.preventDefault(),R.stopPropagation(),P();else{let F=R.key.toLowerCase();(R.ctrlKey||R.metaKey)&&!["c","v","x","a"].includes(F)&&R.stopPropagation()}}),C.addEventListener("input",b),document.addEventListener("mousedown",H,!0),b(),j}}},Ss=new Set(Object.keys(Ht));function xe(r,t){Ss.has(r)&&console.warn(`[JHGrid] registerCellEditor: "${r}" is a built-in editor name and will be overwritten`),Ht[r]=t}var Es=new Set(["B","STRONG","I","EM","U","S","STRIKE","DEL"]),Rs={STRONG:"B",EM:"I",STRIKE:"S",DEL:"S"},As=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function Ms(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ie(r){let t=document.createElement("template");t.innerHTML=r;let e=t.content,s=[],i=1,o=3,n=l=>{for(let a of Array.from(l.childNodes))if(a.nodeType===o)s.push(Ms(a.textContent.replace(/[\r\n]+/g," ")));else if(a.nodeType===i){let c=a.tagName;if(As.has(c))continue;if(c==="BR"){s.push(" ");continue}if(c==="DIV"||c==="P"){n(a),s.push(" ");continue}let h=Rs[c]??(Es.has(c)?c:null);if(h){let d=h.toLowerCase();s.push(`<${d}>`),n(a),s.push(`</${d}>`)}else n(a)}};return n(e),s.join("").trim()}var ne=class{#t=[];#e=[];#i;constructor(t=100){this.#i=t}push(t){this.#t.push(t),this.#t.length>this.#i&&this.#t.shift(),this.#e.length=0}undo(){let t=this.#t.pop();t&&(t.undo(),this.#e.push(t))}redo(){let t=this.#e.pop();t&&(t.redo(),this.#t.push(t))}canUndo(){return this.#t.length>0}canRedo(){return this.#e.length>0}clear(){this.#t.length=0,this.#e.length=0}};var re=class{#t=new Map;#e;#i;#o;#s;#n;constructor({getColumnDef:t,getColumnLabel:e,getI18n:s,getRowData:i,onError:o}){this.#e=t,this.#i=e,this.#o=s,this.#s=i,this.#n=o}compute(t,e,s){let i=this.#e(e),o=i?.validation,n=this.#o(),l=this.#i(e)??e,a=s??"";if(o?.required&&a.trim()==="")return o.message??n.validationRequired(l);if(a==="")return null;if(!o)return this.#r(i,t,a,l,n);if(o.pattern){let c=o.pattern instanceof RegExp?o.pattern:new RegExp(o.pattern);if(c.lastIndex=0,!c.test(a))return o.message??n.validationPattern(l)}if(o.min!=null||o.max!=null){let c=i?.type==="date",h=c?Date.parse(a):Number(a);if(o.min!=null&&(isNaN(h)||h<(c?Date.parse(o.min):o.min)))return o.message??n.validationMin(l,o.min);if(o.max!=null&&(isNaN(h)||h>(c?Date.parse(o.max):o.max)))return o.message??n.validationMax(l,o.max)}if(o.minLength!=null&&a.length<o.minLength)return o.message??n.validationMinLength(l,o.minLength);if(o.maxLength!=null&&a.length>o.maxLength)return o.message??n.validationMaxLength(l,o.maxLength);if(o.validator){let c;try{c=o.validator(a,this.#s(t)??{})}catch(h){return console.error("[JHGrid] validator error at row",t,"field",e,":",h),null}if(typeof c=="string")return c;if(c===!1)return o.message??n.validationInvalid(l)}return this.#r(i,t,a,l,n)}#r(t,e,s,i,o){if(!t)return null;if(t.type==="dropdown"){let n=this.#h(t,e);if(n&&!n.includes(s))return o.validationInvalid(i)}else if(t.type==="multiselect"){let n=this.#h(t,e);if(n){let l=t.editorOptions?.delimiter??",";if(s.split(l).map(c=>c.trim()).filter(Boolean).some(c=>!n.includes(c)))return o.validationInvalid(i)}}else if(t.type==="date"&&!this.#l(s,t.format))return o.validationInvalid(i);return null}#l(t,e){let s=e?.match(/YYYY|YY|MM|DD|HH|mm|ss/g);if(!s?.length)return!isNaN(new Date(t).getTime());let i=e.match(/[^A-Za-z0-9]/)?.[0]??"/",o=t.split(i);if(o.length!==s.length)return!1;let n,l;for(let a=0;a<s.length;a++){if(!/^\d+$/.test(o[a]))return!1;s[a]==="MM"?n=Number(o[a]):s[a]==="DD"&&(l=Number(o[a]))}return!(n!=null&&(n<1||n>12)||l!=null&&(l<1||l>31))}#h(t,e){let s=typeof t.options=="function"?t.options(this.#s(e)??{}):t.options;return Array.isArray(s)?s.map(i=>typeof i=="string"?i:i.value):null}revalidate(t,e,s){let i=this.#e(e);if(!i?.validation&&!this.#c(i?.type))return null;let o=`${t}_${e}`,n=this.compute(t,e,s);return n?this.#t.set(o,n):this.#t.delete(o),this.#n?.(t,e,n??null),n}#c(t){return t==="dropdown"||t==="multiselect"||t==="date"}isValid(){return this.#t.size===0}getInvalidCells(){let t={};return this.#t.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=s.slice(i+1);(t[o]??={})[n]=e}),t}get map(){return this.#t}clear(){this.#t.clear()}};var Ts=/^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function We(r,t=","){let e=String(r??"");return/^[=+\-@\t\r]/.test(e)&&!Ts.test(e)&&(e="'"+e),e.includes(t)||e.includes('"')||e.includes(`
|
|
121
121
|
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function Ne(r,t=" "){let e=String(r??"");return e.includes(t)||e.includes('"')||e.includes(`
|
|
122
122
|
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function je(r,t=" "){let e=r.replace(/\r\n/g,`
|
|
123
123
|
`).replace(/\r/g,`
|
|
124
124
|
`),s=[],i=[],o="",n=!1;for(let l=0;l<e.length;l++){let a=e[l];if(n){a==='"'?e[l+1]==='"'?(o+='"',l++):n=!1:o+=a;continue}if(a==='"'&&o===""){n=!0;continue}if(a===t){i.push(o),o="";continue}if(a===`
|
|
125
|
-
`){i.push(o),s.push(i),i=[],o="";continue}o+=a}return i.push(o),s.push(i),s}function Kt(r,t,e){if(r==null||r==="")return r;if(t?.type==="date"){let s=r instanceof Date?r:new Date(String(r));if(isNaN(s.getTime()))return r;let i=t.format??"YYYY-MM-DD";if(i==="locale")return new Intl.DateTimeFormat(e).format(s);let o=String(s.getFullYear()).padStart(4,"0"),n=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),a=String(s.getHours()).padStart(2,"0"),c=String(s.getMinutes()).padStart(2,"0"),h=String(s.getSeconds()).padStart(2,"0"),d=o.slice(-2);return i.replace("YYYY",o).replace("YY",d).replace("MM",n).replace("DD",l).replace("HH",a).replace("mm",c).replace("ss",h)}return t?.type==="richtext"&&typeof r=="string"?r.replace(/<\/?(b|i|u|s)>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"):r}function Ce(r,t,e=1){if(r.length===0)return"";let s=r.map(Number),i=r.every(a=>a.trim()!==""&&!isNaN(Number(a))),o=e<0;if(i){if(r.length===1)return String(s[0]+(o?-t:t));let a=s.slice(1).map((h,d)=>h-s[d]),c=a[0];if(a.every(h=>Math.abs(h-c)<1e-9)){let h=o?s[0]-c*t:s[s.length-1]+c*t;return Number.isInteger(h)?String(h):String(parseFloat(h.toFixed(10)))}}let n=r.length,l=o?(n-t%n)%n:(t-1)%n;return r[l]}var le=class{#t=[];get size(){return this.#t.length}values(){return[...this.#t]}clear(){this.#t.length=0}#e(t){let e=0,s=this.#t.length;for(;e<s;){let i=e+s>>1;this.#t[i]<t?e=i+1:s=i}return e}has(t){let e=this.#e(t);return e<this.#t.length&&this.#t[e]===t}add(t){let e=this.#e(t);return e<this.#t.length&&this.#t[e]===t?!1:(this.#t.splice(e,0,t),!0)}delete(t){let e=this.#e(t);return e>=this.#t.length||this.#t[e]!==t?!1:(this.#t.splice(e,1),!0)}countBefore(t){return this.#e(t)}toServer(t){if(this.#t.length===0)return t;let e=0,s=this.#t.length;for(;e<s;){let i=e+s>>1;this.#t[i]-i<=t?e=i+1:s=i}return t+e}toVisual(t){return this.has(t)?-1:t-this.countBefore(t)}dropFrom(t){let e=this.#e(t);e<this.#t.length&&(this.#t.length=e)}shiftFrom(t){let e=this.#e(t);for(let s=e;s<this.#t.length;s++)this.#t[s]++}};var ae=class{removed=new le;serverTotal=0;anchors=[];get localCount(){return this.anchors.length}get serverVisible(){return this.serverTotal-this.removed.size}get totalRows(){return this.serverVisible+this.anchors.length}reset(t=0){this.serverTotal=t,this.removed.clear(),this.anchors.length=0}#t(t){let e=Math.min(t,this.serverTotal);return e-this.removed.countBefore(e)}visualOfLocal(t){return this.#t(this.anchors[t])+t}#e(t){let e=0,s=this.anchors.length;for(;e<s;){let i=e+s>>1;this.visualOfLocal(i)<=t?e=i+1:s=i}return e}sourceAt(t){if(t<0||t>=this.totalRows)return null;let e=this.#e(t);return e>0&&this.visualOfLocal(e-1)===t?{local:e-1,server:-1}:{local:-1,server:this.removed.toServer(t-e)}}visualOfServer(t){return this.removed.has(t)?-1:this.#t(t)+this.#i(t)}#i(t){let e=0,s=this.anchors.length;for(;e<s;){let i=e+s>>1;this.anchors[i]<=t?e=i+1:s=i}return e}planInsert(t){let e=Math.max(0,Math.min(t,this.totalRows));if(e>=this.totalRows)return{anchor:this.serverTotal,at:this.anchors.length};let s=this.sourceAt(e);return s.local>=0?{anchor:this.anchors[s.local],at:s.local}:{anchor:s.server,at:this.#i(s.server)}}insertLocal(t){let{anchor:e,at:s}=this.planInsert(t);return this.anchors.splice(s,0,e),s}removeLocal(t){this.anchors.splice(t,1)}clampAnchors(t){this.serverTotal=t;for(let e=0;e<this.anchors.length;e++)this.anchors[e]>t&&(this.anchors[e]=t)}detachAnchors(){for(let t=0;t<this.anchors.length;t++)this.anchors[t]=Number.MAX_SAFE_INTEGER}};var ks=50,Ds=2;function $s(r,t){let e=[],s=new Map;for(let i of r){let o=t(i)??[],n=e,l="";for(let a of o){l+=" "+a;let c=s.get(l);c||(c={type:"group",label:a,children:[]},s.set(l,c),n.push(c)),n=c.children}n.push({type:"field",field:i})}return e}function Se(r){return r.type==="field"?[r.field]:r.children.flatMap(Se)}function Ye({x:r,y:t,width:e,height:s,fields:i,isHidden:o,labelFor:n,groupPathFor:l=()=>[],i18n:a,theme:c,onApply:h,onCancel:d}){if(i.length===0)return null;let u=$s(i,l),f=T=>T.reduce((F,g)=>F+1+(g.type==="group"?f(g.children):0),0),_=f(u),p=(...T)=>T.join(";"),w=220,m=document.createElement("div");m.setAttribute("role","dialog"),m.setAttribute("aria-modal","true"),m.setAttribute("aria-label",a.colChooserTitle),m.className=`${B.overlay} ${B.dialog}`,m.style.cssText=p("position:absolute",`left:${Math.max(0,Math.min(r,e-w-4))}px`,`top:${Math.max(0,Math.min(t,s-40-_*32))}px`,`width:${w}px`,`background:${y(c,"overlayBg")}`,`border:1px solid ${y(c,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(c,"overlayShadow")}`,`font-family:${y(c,"fontFamily")}`,`font-size:${c.fontSize}px`,`color:${y(c,"overlayText")}`,"z-index:300","overflow:hidden","user-select:none");let x=document.createElement("div");x.style.cssText=p("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${y(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(c,"overlayDivider")}`);let S=document.createElement("span");S.textContent=a.colChooserTitle,S.style.fontWeight="600";let v=document.createElement("button");v.type="button",v.textContent="\xD7",v.setAttribute("aria-label",a.colChooserCancel),v.style.cssText=p("background:none","border:none",`color:${y(c,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),v.addEventListener("click",()=>d()),x.append(S,v);let b=document.createElement("div");b.style.cssText="padding:0 0 6px;max-height:280px;overflow-y:auto;";let C=new Map(i.map(T=>[T,!o(T)])),H=document.createElement("label");H.style.cssText=p("display:flex","align-items:center","gap:8px","padding:6px 14px","cursor:pointer",`border-bottom:1px solid ${y(c,"overlayDivider")}`,"margin-bottom:2px"),H.addEventListener("mouseover",()=>{H.style.background=y(c,"overlayHoverBg")}),H.addEventListener("mouseout",()=>{H.style.background=""});let D=document.createElement("input");D.type="checkbox",D.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;";let A=document.createElement("span");A.textContent=a.colChooserSelectAll??"\uC804\uCCB4 \uC120\uD0DD",A.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",H.append(D,A),b.appendChild(H);let j=[],O=[],V=()=>{let T=j.filter(F=>F.checked).length;D.checked=T===j.length,D.indeterminate=T>0&&T<j.length},z=new Map,W=()=>{for(let{node:T,cb:F}of O){let g=Se(T),U=g.filter(Z=>z.get(Z).checked).length;F.checked=U===g.length,F.indeterminate=U>0&&U<g.length}V()};D.addEventListener("change",()=>{D.indeterminate=!1,j.forEach(T=>{T.checked=D.checked,C.set(T.dataset.field,D.checked)}),W()});let E=18,L=32;function M(T,F,g){let U=n(T),Z=document.createElement("label");Z.style.cssText=p("display:flex","align-items:center","gap:6px","padding:6px 14px","cursor:pointer","border-radius:3px"),Z.addEventListener("mouseover",()=>{Z.style.background=y(c,"overlayHoverBg")}),Z.addEventListener("mouseout",()=>{Z.style.background=""});let lt=document.createElement("span");lt.style.cssText="width:18px;height:18px;flex-shrink:0;";let ot=document.createElement("input");ot.type="checkbox",ot.checked=C.get(T),ot.dataset.field=T,ot.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",ot.addEventListener("change",()=>{C.set(T,ot.checked),W()});let it=document.createElement("span");it.textContent=U,it.style.cssText="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",Z.append(lt,ot,it),g.appendChild(Z),j.push(ot),z.set(T,ot)}function Q(T,F,g){let U=Se(T),Z=document.createElement("div");Z.className=B.treeGroup,Z.style.cssText=p("display:flex","align-items:center","gap:6px","padding:7px 14px 7px 10px","cursor:pointer",`background:${y(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(c,"overlayDivider")}`,`border-left:3px solid ${y(c,"selectionColor")}`,"position:sticky",`top:${F*L}px`,`z-index:${10-F}`),Z.addEventListener("mouseover",()=>{Z.style.background=y(c,"overlayHoverBg")}),Z.addEventListener("mouseout",()=>{Z.style.background=y(c,"overlayHeaderBg")});let lt=document.createElement("div");lt.style.cssText=p(`margin-left:${E}px`,"padding-left:6px",`border-left:1px solid ${y(c,"overlayDivider")}`);let ot=!0,it=document.createElement("button");it.type="button",it.className=B.treeToggle,it.textContent="\u25BE",it.setAttribute("aria-expanded","true"),it.setAttribute("aria-label",T.label),it.style.cssText=p("width:18px","height:18px","flex-shrink:0","display:flex","align-items:center","justify-content:center","background:none","border:none","padding:0","cursor:pointer","font-size:13px","line-height:1",`color:${y(c,"overlayText")}`),it.addEventListener("click",ft=>{ft.preventDefault(),ft.stopPropagation(),ot=!ot,it.style.transform=ot?"":"rotate(-90deg)",it.setAttribute("aria-expanded",String(ot)),lt.style.display=ot?"":"none"});let K=document.createElement("label");K.style.cssText="display:flex;align-items:center;gap:8px;flex:1;cursor:pointer;min-width:0;";let N=document.createElement("input");N.type="checkbox",N.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",N.addEventListener("change",()=>{N.indeterminate=!1,U.forEach(ft=>{z.get(ft).checked=N.checked,C.set(ft,N.checked)}),W()});let G=document.createElement("span");G.textContent=T.label,G.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",K.append(N,G),Z.append(it,K),g.appendChild(Z),g.appendChild(lt),O.push({node:T,cb:N}),R(T.children,F+1,lt)}function R(T,F,g){for(let U of T)U.type==="group"?Q(U,F,g):M(U.field,F,g)}R(u,0,b),W();let I=document.createElement("div");I.style.cssText=p("display:flex","gap:6px","padding:10px 12px",`border-top:1px solid ${y(c,"overlayDivider")}`);let $=document.createElement("button");$.type="button",$.textContent=a.colChooserApply,$.style.cssText=p("flex:1","padding:7px 0",`background:${y(c,"selectionColor")}`,`color:${y(c,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600"),$.addEventListener("click",()=>h(C));let k=document.createElement("button");return k.type="button",k.textContent=a.colChooserCancel,k.style.cssText=p("flex:1","padding:7px 0",`background:${y(c,"overlayHeaderBg")}`,`color:${y(c,"overlayText")}`,`border:1px solid ${y(c,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"),k.addEventListener("click",()=>d()),I.append($,k),m.append(x,b,I),m.addEventListener("mousedown",T=>T.stopPropagation()),m.addEventListener("keydown",T=>{T.key==="Escape"&&d(),T.stopPropagation()}),m}function Ge({colLeft:r,headerH:t,width:e,maxPanelHeight:s,label:i,curVal:o,sortPriority:n,asc:l,desc:a,filterId:c,swatchColors:h,activeColor:d,multiSortEnabled:u,i18n:f,theme:_,wrapperHeight:p,openUpward:w,distinctValues:m,selectedValues:x,suggest:S,suggestScope:v,tagValues:b,containsValue:C,minQueryChars:H,onClose:D,onSort:A,onApply:j,onApplyValues:O,onColorFilter:V,onResetCol:z,onResetAll:W}){let L=Math.max(0,Math.min(r,e-220)),M=(...P)=>P.join(";"),Q=(P,nt,at)=>{let ct=document.createElement("button");return ct.type="button",ct.textContent=P,ct.dataset.action=nt,ct.className=B.btn,ct.style.cssText=at,ct},R=document.createElement("div");R.setAttribute("role","dialog"),R.setAttribute("aria-modal","true"),R.setAttribute("aria-label",f.filterDialog(i)),R.className=`${B.overlay} ${B.panel}`,R.style.cssText=M("position:absolute",`left:${L}px`,w?`bottom:${Math.max(0,p-t)}px`:`top:${t}px`,"width:220px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(_,"overlayShadow")}`,`font-family:${y(_,"fontFamily")}`,`font-size:${_.fontSize}px`,`color:${y(_,"overlayText")}`,"z-index:100","overflow:hidden","user-select:none","display:flex","flex-direction:column",...s?[`max-height:${Math.max(120,s)}px`]:[]);let I=document.createElement("div");I.style.cssText=M("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${y(_,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(_,"overlayDivider")}`);let $=document.createElement("span");$.textContent=i,$.style.fontWeight="600";let k=Q("\xD7","close",M("background:none","border:none",`color:${y(_,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"));k.setAttribute("aria-label",f.filterClose),I.append($,k);let T=document.createElement("div");T.style.cssText=M("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let F=document.createElement("div");F.style.cssText=M("display:flex","gap:6px");let g=M("flex:1","padding:6px 0","border-radius:4px","cursor:pointer","font-size:12px"),U=Q(f.sortAsc,"asc",M(g,`background:${l?y(_,"selectionColor"):y(_,"overlayHeaderBg")}`,`color:${l?y(_,"overlayAccentText"):y(_,"overlayText")}`,`border:1px solid ${l?y(_,"selectionColor"):y(_,"overlayBorder")}`));U.setAttribute("aria-pressed",String(l));let Z=Q(f.sortDesc,"desc",M(g,`background:${a?y(_,"selectionColor"):y(_,"overlayHeaderBg")}`,`color:${a?y(_,"overlayAccentText"):y(_,"overlayText")}`,`border:1px solid ${a?y(_,"selectionColor"):y(_,"overlayBorder")}`));if(Z.setAttribute("aria-pressed",String(a)),F.append(U,Z),n>0){let P=document.createElement("span");P.textContent=`#${n}`,P.title="Sort priority",P.style.cssText=M("align-self:center","font-size:11px","font-weight:700",`color:${y(_,"selectionColor")}`,"min-width:20px","text-align:center"),F.appendChild(P)}if(T.appendChild(F),u){let P=document.createElement("div");P.textContent=f.sortShiftHint??"Shift+click: add to multi-sort",P.style.cssText=M("font-size:10px",`color:${y(_,"overlayHintText")}`,"margin-top:5px"),T.appendChild(P)}let lt=null;if(h?.length){lt=document.createElement("div"),lt.style.cssText=M("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let P=document.createElement("div");P.textContent=f.filterColorLabel??"Filter by color",P.style.cssText=M("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:6px");let nt=document.createElement("div");nt.style.cssText=M("display:flex","flex-wrap:wrap","gap:6px"),h.forEach(at=>{let ct=d===at,yt=document.createElement("button");yt.type="button",yt.dataset.action="color-filter",yt.dataset.value=at,yt.title=at,yt.setAttribute("aria-pressed",String(ct)),yt.className=B.swatch,yt.style.cssText=M("width:22px","height:22px","border-radius:50%","cursor:pointer","padding:0","border:none",`background:${at}`,`box-shadow:${ct?`0 0 0 2px ${y(_,"overlayBg")}, 0 0 0 4px ${y(_,"selectionColor")}`:"0 0 0 1px rgba(0,0,0,0.15)"}`),nt.appendChild(yt)}),lt.append(P,nt)}let ot=document.createElement("div");ot.style.cssText=M("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let it=document.createElement("label");it.textContent=f.filterLabel,it.htmlFor=c,it.style.cssText=M("font-size:11px",`color:${y(_,"overlayMutedText")}`,"display:block","margin-bottom:6px");let K=document.createElement("input");K.type="text",K.id=c,K.value=o,K.placeholder=f.filterPlaceholder,K.className=B.editor,K.style.cssText=M("width:100%","padding:6px 8px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px",`color:${y(_,"overlayText")}`,`font-size:${_.fontSize}px`,"box-sizing:border-box"),ot.append(it,K);let N=null,G=null;if(!Array.isArray(m)&&typeof S=="function"){let Ut=function(){if(At.replaceChildren(),gt){At.appendChild(kt(f.filterTagMinChars(St),!1)),xt.replaceChildren(tt(f.filterTagContains(st),f.filterTagContains(st),()=>Y(st),!0)),Rt.style.display="flex",ht.setAttribute("aria-expanded","true"),rt=-1;return}let dt=new Set(P.tags),mt=J.filter(vt=>!dt.has(vt));if(v==="local"&&mt.length>0){let vt=kt(f.filterTagLocalScope,!0);vt.style.borderBottom=`1px solid ${y(_,"overlayDivider")}`,At.appendChild(vt)}let bt=mt.slice(0,ks);for(let vt of bt){let Ct=vt===""?f.emptyCell:vt;At.appendChild(tt(Ct,Ct,()=>ut(vt),!1))}if(mt.length>bt.length){let vt=kt(f.filterTagMore(mt.length-bt.length),!0);vt.style.borderTop=`1px solid ${y(_,"overlayDivider")}`,At.appendChild(vt)}mt.length===0&&At.appendChild(kt(J.length?f.filterTagAllSelected:f.filterTagNoMatch,!1)),xt.replaceChildren(tt(f.filterTagContains(st),f.filterTagContains(st),()=>Y(st),!0)),Rt.style.display="flex",ht.setAttribute("aria-expanded","true"),rt=-1},P={tags:Array.isArray(b)?[...b]:[],contains:typeof C=="string"&&C?C:null};N=document.createElement("div"),N.style.cssText=M("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let nt=document.createElement("div");nt.textContent=f.filterLabel,nt.style.cssText=M("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:6px");let at=document.createElement("div");at.style.cssText=M("display:none","flex-direction:column","flex:0 1 auto","min-height:0","margin-top:8px");let ct=document.createElement("div");ct.style.cssText=M("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:4px");let yt=document.createElement("div");yt.style.cssText=M("display:flex","flex-wrap:wrap","gap:4px","flex:1 1 auto","min-height:30px","max-height:64px","overflow-y:auto","padding:6px","border-radius:4px",`border:1px solid ${y(_,"overlayBorder")}`,`background:${y(_,"overlayHeaderBg")}`),at.append(ct,yt);let ht=document.createElement("input");ht.type="text",ht.id=c,ht.placeholder=f.filterTagPlaceholder,ht.className=B.editor,ht.setAttribute("role","combobox"),ht.setAttribute("aria-expanded","false"),ht.setAttribute("aria-autocomplete","list"),ht.style.cssText=M("width:100%","padding:6px 8px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px",`color:${y(_,"overlayText")}`,`font-size:${_.fontSize}px`,"box-sizing:border-box");let Rt=document.createElement("div");Rt.style.cssText=M("display:none","flex-direction:column","flex:0 0 auto","margin-top:4px",`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px","overflow:hidden");let At=document.createElement("div");At.setAttribute("role","listbox"),At.style.cssText=M("flex:0 0 auto","max-height:132px","overflow-y:auto");let xt=document.createElement("div");xt.style.cssText=M("flex:0 0 auto",`border-top:1px solid ${y(_,"overlayDivider")}`,`background:${y(_,"overlayHeaderBg")}`),Rt.append(At,xt);let Mt=()=>{yt.replaceChildren();let dt=(bt,vt,Ct,Te)=>{let Xt=document.createElement("span");Xt.className=B.chip+(Te?` ${B.chipContains}`:""),Xt.style.cssText=M("display:inline-flex","align-items:center","gap:4px","max-width:100%","padding:2px 4px 2px 7px","border-radius:10px","font-size:11px","box-sizing:border-box",Te?`background:${y(_,"overlayHeaderBg")};border:1px dashed ${y(_,"overlayBorder")};color:${y(_,"overlayMutedText")}`:`background:${y(_,"sortIconBg")};border:1px solid ${y(_,"overlayBorder")};color:${y(_,"overlayText")}`);let ue=document.createElement("span");ue.textContent=bt,Xt.title=vt,ue.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";let Wt=document.createElement("button");Wt.type="button",Wt.className=B.btn,Wt.textContent="\xD7",Wt.setAttribute("aria-label",f.filterTagRemove(vt)),Wt.style.cssText=M("border:none","background:none","cursor:pointer","padding:0 2px","line-height:1","font-size:13px",`color:${y(_,"overlayMutedText")}`),Wt.addEventListener("click",()=>{Ct(),Mt(),ht.focus()}),Xt.append(ue,Wt),yt.appendChild(Xt)};P.contains!==null?dt(f.filterTagContains(P.contains),f.filterTagContains(P.contains),()=>{P.contains=null},!0):P.tags.forEach((bt,vt)=>{let Ct=bt===""?f.emptyCell:bt;dt(Ct,Ct,()=>{P.tags.splice(vt,1)})});let mt=yt.childElementCount;at.style.display=mt?"flex":"none",ct.textContent=f.filterTagSelected(mt)},Ot=()=>{Rt.style.display="none",At.replaceChildren(),xt.replaceChildren(),ht.setAttribute("aria-expanded","false")},ut=dt=>{P.contains=null,P.tags.includes(dt)||P.tags.push(dt),ht.value="",Ot(),Mt(),ht.focus()},Y=dt=>{P.tags=[],P.contains=dt,ht.value="",Ot(),Mt(),ht.focus()},tt=(dt,mt,bt,vt)=>{let Ct=document.createElement("div");return Ct.setAttribute("role","option"),Ct.className=B.menuItem,Ct.title=mt,Ct.textContent=dt,Ct.style.cssText=M("padding:5px 8px","font-size:12px","cursor:pointer","overflow:hidden","text-overflow:ellipsis","white-space:nowrap",vt?`color:${y(_,"overlayMutedText")}`:`color:${y(_,"overlayText")}`),Ct.addEventListener("mouseenter",()=>{Ct.style.background=y(_,"overlayItemHoverBg")}),Ct.addEventListener("mouseleave",()=>{Ct.style.background="none"}),Ct.addEventListener("click",bt),Ct},st="",J=[],rt=-1,gt=!1,Tt=Math.floor(Number(H)),St=Number.isFinite(Tt)&&Tt>0?Tt:Ds,kt=(dt,mt)=>{let bt=document.createElement("div");return bt.textContent=dt,bt.style.cssText=M("padding:5px 8px",`font-size:${mt?11:12}px`,mt?"font-style:italic":"",`color:${y(_,"overlayMutedText")}`),bt},Ft=0,jt=0,he=async dt=>{let mt=++Ft,bt=[];try{bt=await S(dt)??[]}catch{bt=[]}mt!==Ft||ht.value.trim()!==dt||(st=dt,J=bt,gt=!1,Ut())};ht.addEventListener("input",()=>{clearTimeout(jt);let dt=ht.value.trim();if(!dt){Ft++,Ot();return}if(dt.length<St){Ft++,st=dt,J=[],gt=!0,Ut();return}jt=setTimeout(()=>he(dt),180)});let de=()=>[...Rt.querySelectorAll('[role="option"]')],Me=dt=>{let mt=de();mt.forEach((bt,vt)=>{bt.style.background=vt===dt?y(_,"overlayItemHoverBg"):"none"}),rt=dt,mt[dt]?.scrollIntoView({block:"nearest"})};ht.addEventListener("keydown",dt=>{let mt=Rt.style.display!=="none";dt.key==="ArrowDown"&&mt?(dt.preventDefault(),Me(Math.min(rt+1,de().length-1))):dt.key==="ArrowUp"&&mt?(dt.preventDefault(),Me(Math.max(rt-1,0))):dt.key==="Enter"?(dt.preventDefault(),mt?de()[rt>=0?rt:0]?.click():wt.click()):dt.key==="Escape"&&(mt?(Ot(),rt=-1):D()),dt.stopPropagation()}),ht.addEventListener("input",()=>{rt=-1}),N.append(nt,ht,Rt,at),Mt(),R.addEventListener("jhg-dispose",()=>{clearTimeout(jt),Ft++}),G=()=>P.contains!==null?{contains:P.contains}:{values:[...P.tags]}}let ft=null,et=[];if(Array.isArray(m)&&m.length>0){ft=document.createElement("div"),ft.style.cssText=M("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let P=document.createElement("div");P.textContent=f.filterValuesLabel,P.style.cssText=M("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:6px");let nt=Array.isArray(x)?new Set(x):null,at=(ut,Y,tt)=>{let st=document.createElement("label");st.style.cssText=M("display:flex","align-items:center","gap:6px","font-size:12px","cursor:pointer","padding:2px 0");let J=document.createElement("input");J.type="checkbox",J.checked=tt,J.dataset.value=ut;let rt=document.createElement("span");return rt.textContent=Y,rt.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",st.append(J,rt),{row:st,cb:J}},ct=document.createElement("input");ct.type="text",ct.placeholder=f.filterTagPlaceholder,ct.setAttribute("aria-label",f.filterTagPlaceholder),ct.className=B.editor,ct.style.cssText=M("width:100%","padding:6px 8px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px",`color:${y(_,"overlayText")}`,`font-size:${_.fontSize}px`,"box-sizing:border-box","margin-bottom:6px");let yt=document.createElement("div");yt.style.cssText=M("max-height:140px","overflow-y:auto","display:flex","flex-direction:column");let ht=[];m.forEach(ut=>{let Y=nt===null?!0:nt.has(ut),tt=ut===""?f.emptyCell:ut,{row:st,cb:J}=at(ut,tt,Y);et.push(J),ht.push({row:st,cb:J,text:tt}),yt.appendChild(st)});let Rt=document.createElement("div");Rt.textContent=f.filterTagNoMatch,Rt.style.cssText=M("padding:5px 8px","font-size:12px",`color:${y(_,"overlayMutedText")}`,"display:none"),yt.appendChild(Rt);let{row:At,cb:xt}=at("",f.filterSelectAll,et.every(ut=>ut.checked));delete xt.dataset.value,xt.dataset.selectAll="true",At.style.cssText+=`;font-weight:600;border-bottom:1px solid ${y(_,"overlayDivider")};padding-bottom:6px;margin-bottom:4px;`;let Mt=()=>ht.filter(ut=>ut.row.style.display!=="none").map(ut=>ut.cb),Ot=()=>{let ut=Mt();xt.checked=ut.length>0&&ut.every(Y=>Y.checked)};xt.addEventListener("change",()=>{Mt().forEach(ut=>{ut.checked=xt.checked})}),et.forEach(ut=>ut.addEventListener("change",Ot)),ct.addEventListener("input",()=>{let ut=ct.value.trim().toLowerCase(),Y=!1;for(let tt of ht){let st=!ut||tt.text.toLowerCase().includes(ut);tt.row.style.display=st?"flex":"none",Y=Y||st}Rt.style.display=Y?"none":"block",Ot()}),ct.addEventListener("keydown",ut=>{ut.key==="Enter"?(ut.preventDefault(),wt.click()):ut.key==="Escape"&&D(),ut.stopPropagation()}),ft.append(P,ct,At,yt)}let q=document.createElement("div");q.style.cssText=M("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let X=document.createElement("div");X.style.cssText=M("display:flex","gap:6px");let wt=Q(f.filterApply,"apply",M("flex:1","padding:7px 0",`background:${y(_,"selectionColor")}`,`color:${y(_,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600")),Dt=Q(f.filterReset,"reset-col",M("flex:1","padding:7px 0",`background:${y(_,"overlayHeaderBg")}`,`color:${y(_,"overlayText")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"));X.append(wt,Dt),q.appendChild(X);let Et=document.createElement("div");Et.style.cssText=M("padding:8px 12px","text-align:center");let Lt=Q(f.filterResetAll,"reset-all",M("background:none","border:none",`color:${y(_,"overlayMutedText")}`,"cursor:pointer","font-size:12px","text-decoration:underline"));Et.appendChild(Lt);let _t=ft??N??ot;R.append(I,T,...lt?[lt]:[],_t,q,Et);for(let P of R.children)P.style.flex="0 0 auto";return _t.style.flex="1 1 auto",_t.style.minHeight="0",_t===N&&(_t.style.display="flex",_t.style.flexDirection="column",_t.style.overflowY="auto"),_t===ft&&(_t.style.overflowY="auto"),R.addEventListener("mousedown",P=>P.stopPropagation()),R.addEventListener("keydown",P=>{if(P.key!=="Tab")return;let nt=[...R.querySelectorAll("button:not([disabled]), input")];if(nt.length===0)return;let at=nt[0],ct=nt[nt.length-1];P.shiftKey?document.activeElement===at&&(P.preventDefault(),ct.focus()):document.activeElement===ct&&(P.preventDefault(),at.focus())},!0),R.addEventListener("click",P=>{let nt=P.target.closest("[data-action]")?.dataset?.action;if(nt)if(nt==="close")D();else if(nt==="asc"||nt==="desc")A(nt,P.shiftKey);else if(nt==="apply")if(ft)O(et.filter(at=>at.checked).map(at=>at.dataset.value));else if(G){let at=G();at.contains!==void 0?j(at.contains):at.values.length?O(at.values):j("")}else j(K.value.trim());else if(nt==="color-filter"){let at=P.target.closest('[data-action="color-filter"]')?.dataset?.value;if(at==null)return;V(at)}else nt==="reset-col"?z():nt==="reset-all"&&W()}),K.addEventListener("keydown",P=>{P.key==="Enter"?(P.preventDefault(),wt.click()):P.key==="Escape"&&D(),P.stopPropagation()}),R.addEventListener("keydown",P=>{P.key==="Escape"&&D()}),R}function Ke({x:r,y:t,width:e,isFrozen:s,isFrozenRight:i,isDeleted:o,i18n:n,theme:l,allowedItems:a={},onFreeze:c,onFreezeRight:h,onVisibility:d,onInsertLeft:u,onInsertRight:f,onDelete:_,onUndelete:p,onEscape:w}){let{freeze:m=!0,freezeRight:x=!0,visibility:S=!0,insertLeft:v=!0,insertRight:b=!0,delete:C=!0}=a;if(!m&&!x&&!S&&!v&&!b&&!C)return null;let H=170,D=(...R)=>R.join(";"),A=D("padding:8px 14px","cursor:pointer"),j=document.createElement("div");j.setAttribute("role","menu"),j.className=`${B.overlay} ${B.menu}`,j.style.cssText=D("position:absolute",`left:${Math.min(r,e-H-2)}px`,`top:${t}px`,`width:${H}px`,`background:${y(l,"overlayBg")}`,`border:1px solid ${y(l,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(l,"overlayMenuShadow")}`,`font-family:${y(l,"fontFamily")}`,`font-size:${l.fontSize}px`,`color:${y(l,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0");let O=(R,I)=>{let $=document.createElement("div");return $.setAttribute("role","menuitem"),$.setAttribute("tabindex","0"),$.textContent=R,$.dataset.action=I,$.className=B.menuItem,$.style.cssText=A,$.addEventListener("mouseover",()=>{$.style.background=y(l,"overlayItemHoverBg")}),$.addEventListener("mouseout",()=>{$.style.background=""}),$.addEventListener("focus",()=>{$.style.background=y(l,"overlayItemHoverBg")}),$.addEventListener("blur",()=>{$.style.background=""}),$},V=()=>{let R=document.createElement("div");return R.style.cssText=`height:1px;background:${y(l,"overlayDivider")};margin:4px 0;`,R},z=[];m&&z.push(O(s?n.colUnfreeze:n.colFreeze,s?"unfreeze":"freeze")),x&&z.push(O(i?n.colUnfreezeRight:n.colFreezeRight,i?"unfreeze-right":"freeze-right"));let W=S?[O(n.colVisibility,"col-visibility")]:[],E=[];v&&E.push(O(n.colInsertLeft,"col-insert-left")),b&&E.push(O(n.colInsertRight,"col-insert-right"));let L=C?[O(o?n.colUndelete:n.colDelete,o?"col-undelete":"col-delete")]:[],Q=[z,W,E,L].filter(R=>R.length>0).flatMap((R,I)=>I===0?R:[V(),...R]);return j.addEventListener("mousedown",R=>R.stopPropagation()),j.addEventListener("click",R=>{let I=R.target.closest("[data-action]")?.dataset?.action;if(I)if(I==="freeze"||I==="unfreeze")c();else if(I==="freeze-right"||I==="unfreeze-right")h();else if(I==="col-visibility"){d();return}else if(I==="col-insert-left"){u();return}else if(I==="col-insert-right"){f();return}else I==="col-delete"?_():I==="col-undelete"&&p()}),j.addEventListener("keydown",R=>{if(R.key==="Escape")w();else if(R.key==="Enter"||R.key===" ")R.preventDefault(),document.activeElement?.click?.();else if(R.key==="ArrowDown"||R.key==="ArrowUp"){R.preventDefault();let I=[...j.querySelectorAll('[role="menuitem"]')],$=I.indexOf(document.activeElement),k=R.key==="ArrowDown"?($+1)%I.length:($-1+I.length)%I.length;I[k]?.focus()}R.stopPropagation()}),j.append(...Q),j}function Ee(r,t,e,s){let i=new Map;return r((o,n)=>{let l=e(n);l>=0&&i.set(l,o)}),t.forEach((o,n)=>i.set(s(n),o)),[...i.entries()].sort(([o],[n])=>o-n)}function Ve({cols:r,labels:t,rows:e,title:s,includeHeaders:i,i18n:o,lang:n}){let l=h=>String(h??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),a=i?`<thead><tr>${t.map(h=>`<th>${l(h)}</th>`).join("")}</tr></thead>`:"",c=e.map(h=>`<tr>${r.map(d=>`<td>${l(h[d])}</td>`).join("")}</tr>`).join("");return`<!DOCTYPE html><html lang="${l(n)}"><head>
|
|
125
|
+
`){i.push(o),s.push(i),i=[],o="";continue}o+=a}return i.push(o),s.push(i),s}function Kt(r,t,e){if(r==null||r==="")return r;if(t?.type==="date"){let s=r instanceof Date?r:new Date(String(r));if(isNaN(s.getTime()))return r;let i=t.format??"YYYY-MM-DD";if(i==="locale")return new Intl.DateTimeFormat(e).format(s);let o=String(s.getFullYear()).padStart(4,"0"),n=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),a=String(s.getHours()).padStart(2,"0"),c=String(s.getMinutes()).padStart(2,"0"),h=String(s.getSeconds()).padStart(2,"0"),d=o.slice(-2);return i.replace("YYYY",o).replace("YY",d).replace("MM",n).replace("DD",l).replace("HH",a).replace("mm",c).replace("ss",h)}return t?.type==="richtext"&&typeof r=="string"?r.replace(/<\/?(b|i|u|s)>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"):r}function Ce(r,t,e=1){if(r.length===0)return"";let s=r.map(Number),i=r.every(a=>a.trim()!==""&&!isNaN(Number(a))),o=e<0;if(i){if(r.length===1)return String(s[0]+(o?-t:t));let a=s.slice(1).map((h,d)=>h-s[d]),c=a[0];if(a.every(h=>Math.abs(h-c)<1e-9)){let h=o?s[0]-c*t:s[s.length-1]+c*t;return Number.isInteger(h)?String(h):String(parseFloat(h.toFixed(10)))}}let n=r.length,l=o?(n-t%n)%n:(t-1)%n;return r[l]}var le=class{#t=[];get size(){return this.#t.length}values(){return[...this.#t]}clear(){this.#t.length=0}#e(t){let e=0,s=this.#t.length;for(;e<s;){let i=e+s>>1;this.#t[i]<t?e=i+1:s=i}return e}has(t){let e=this.#e(t);return e<this.#t.length&&this.#t[e]===t}add(t){let e=this.#e(t);return e<this.#t.length&&this.#t[e]===t?!1:(this.#t.splice(e,0,t),!0)}delete(t){let e=this.#e(t);return e>=this.#t.length||this.#t[e]!==t?!1:(this.#t.splice(e,1),!0)}countBefore(t){return this.#e(t)}toServer(t){if(this.#t.length===0)return t;let e=0,s=this.#t.length;for(;e<s;){let i=e+s>>1;this.#t[i]-i<=t?e=i+1:s=i}return t+e}toVisual(t){return this.has(t)?-1:t-this.countBefore(t)}dropFrom(t){let e=this.#e(t);e<this.#t.length&&(this.#t.length=e)}shiftFrom(t){let e=this.#e(t);for(let s=e;s<this.#t.length;s++)this.#t[s]++}};var ae=class{removed=new le;serverTotal=0;anchors=[];get localCount(){return this.anchors.length}get serverVisible(){return this.serverTotal-this.removed.size}get totalRows(){return this.serverVisible+this.anchors.length}reset(t=0){this.serverTotal=t,this.removed.clear(),this.anchors.length=0}#t(t){let e=Math.min(t,this.serverTotal);return e-this.removed.countBefore(e)}visualOfLocal(t){return this.#t(this.anchors[t])+t}#e(t){let e=0,s=this.anchors.length;for(;e<s;){let i=e+s>>1;this.visualOfLocal(i)<=t?e=i+1:s=i}return e}sourceAt(t){if(t<0||t>=this.totalRows)return null;let e=this.#e(t);return e>0&&this.visualOfLocal(e-1)===t?{local:e-1,server:-1}:{local:-1,server:this.removed.toServer(t-e)}}visualOfServer(t){return this.removed.has(t)?-1:this.#t(t)+this.#i(t)}#i(t){let e=0,s=this.anchors.length;for(;e<s;){let i=e+s>>1;this.anchors[i]<=t?e=i+1:s=i}return e}planInsert(t){let e=Math.max(0,Math.min(t,this.totalRows));if(e>=this.totalRows)return{anchor:this.serverTotal,at:this.anchors.length};let s=this.sourceAt(e);return s.local>=0?{anchor:this.anchors[s.local],at:s.local}:{anchor:s.server,at:this.#i(s.server)}}insertLocal(t){let{anchor:e,at:s}=this.planInsert(t);return this.anchors.splice(s,0,e),s}removeLocal(t){this.anchors.splice(t,1)}clampAnchors(t){this.serverTotal=t;for(let e=0;e<this.anchors.length;e++)this.anchors[e]>t&&(this.anchors[e]=t)}detachAnchors(){for(let t=0;t<this.anchors.length;t++)this.anchors[t]=Number.MAX_SAFE_INTEGER}};var ks=50,Ds=2;function $s(r,t){let e=[],s=new Map;for(let i of r){let o=t(i)??[],n=e,l="";for(let a of o){l+=" "+a;let c=s.get(l);c||(c={type:"group",label:a,children:[]},s.set(l,c),n.push(c)),n=c.children}n.push({type:"field",field:i})}return e}function Se(r){return r.type==="field"?[r.field]:r.children.flatMap(Se)}function Ye({x:r,y:t,width:e,height:s,fields:i,isHidden:o,labelFor:n,groupPathFor:l=()=>[],i18n:a,theme:c,onApply:h,onCancel:d}){if(i.length===0)return null;let u=$s(i,l),f=D=>D.reduce((L,p)=>L+1+(p.type==="group"?f(p.children):0),0),_=f(u),g=(...D)=>D.join(";"),w=220,m=document.createElement("div");m.setAttribute("role","dialog"),m.setAttribute("aria-modal","true"),m.setAttribute("aria-label",a.colChooserTitle),m.className=`${B.overlay} ${B.dialog}`,m.style.cssText=g("position:absolute",`left:${Math.max(0,Math.min(r,e-w-4))}px`,`top:${Math.max(0,Math.min(t,s-40-_*32))}px`,`width:${w}px`,`background:${y(c,"overlayBg")}`,`border:1px solid ${y(c,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(c,"overlayShadow")}`,`font-family:${y(c,"fontFamily")}`,`font-size:${c.fontSize}px`,`color:${y(c,"overlayText")}`,"z-index:300","overflow:hidden","user-select:none");let v=document.createElement("div");v.style.cssText=g("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${y(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(c,"overlayDivider")}`);let S=document.createElement("span");S.textContent=a.colChooserTitle,S.style.fontWeight="600";let b=document.createElement("button");b.type="button",b.textContent="\xD7",b.setAttribute("aria-label",a.colChooserCancel),b.style.cssText=g("background:none","border:none",`color:${y(c,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),b.addEventListener("click",()=>d()),v.append(S,b);let E=document.createElement("div");E.style.cssText="padding:0 0 6px;max-height:280px;overflow-y:auto;";let C=new Map(i.map(D=>[D,!o(D)])),T=document.createElement("label");T.style.cssText=g("display:flex","align-items:center","gap:8px","padding:6px 14px","cursor:pointer",`border-bottom:1px solid ${y(c,"overlayDivider")}`,"margin-bottom:2px"),T.addEventListener("mouseover",()=>{T.style.background=y(c,"overlayHoverBg")}),T.addEventListener("mouseout",()=>{T.style.background=""});let $=document.createElement("input");$.type="checkbox",$.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;";let M=document.createElement("span");M.textContent=a.colChooserSelectAll??"\uC804\uCCB4 \uC120\uD0DD",M.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",T.append($,M),E.appendChild(T);let j=[],O=[],V=()=>{let D=j.filter(L=>L.checked).length;$.checked=D===j.length,$.indeterminate=D>0&&D<j.length},P=new Map,H=()=>{for(let{node:D,cb:L}of O){let p=Se(D),N=p.filter(Z=>P.get(Z).checked).length;L.checked=N===p.length,L.indeterminate=N>0&&N<p.length}V()};$.addEventListener("change",()=>{$.indeterminate=!1,j.forEach(D=>{D.checked=$.checked,C.set(D.dataset.field,$.checked)}),H()});let R=18,F=32;function A(D,L,p){let N=n(D),Z=document.createElement("label");Z.style.cssText=g("display:flex","align-items:center","gap:6px","padding:6px 14px","cursor:pointer","border-radius:3px"),Z.addEventListener("mouseover",()=>{Z.style.background=y(c,"overlayHoverBg")}),Z.addEventListener("mouseout",()=>{Z.style.background=""});let dt=document.createElement("span");dt.style.cssText="width:18px;height:18px;flex-shrink:0;";let rt=document.createElement("input");rt.type="checkbox",rt.checked=C.get(D),rt.dataset.field=D,rt.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",rt.addEventListener("change",()=>{C.set(D,rt.checked),H()});let ot=document.createElement("span");ot.textContent=N,ot.style.cssText="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",Z.append(dt,rt,ot),p.appendChild(Z),j.push(rt),P.set(D,rt)}function it(D,L,p){let N=Se(D),Z=document.createElement("div");Z.className=B.treeGroup,Z.style.cssText=g("display:flex","align-items:center","gap:6px","padding:7px 14px 7px 10px","cursor:pointer",`background:${y(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(c,"overlayDivider")}`,`border-left:3px solid ${y(c,"selectionColor")}`,"position:sticky",`top:${L*F}px`,`z-index:${10-L}`),Z.addEventListener("mouseover",()=>{Z.style.background=y(c,"overlayHoverBg")}),Z.addEventListener("mouseout",()=>{Z.style.background=y(c,"overlayHeaderBg")});let dt=document.createElement("div");dt.style.cssText=g(`margin-left:${R}px`,"padding-left:6px",`border-left:1px solid ${y(c,"overlayDivider")}`);let rt=!0,ot=document.createElement("button");ot.type="button",ot.className=B.treeToggle,ot.textContent="\u25BE",ot.setAttribute("aria-expanded","true"),ot.setAttribute("aria-label",D.label),ot.style.cssText=g("width:18px","height:18px","flex-shrink:0","display:flex","align-items:center","justify-content:center","background:none","border:none","padding:0","cursor:pointer","font-size:13px","line-height:1",`color:${y(c,"overlayText")}`),ot.addEventListener("click",ut=>{ut.preventDefault(),ut.stopPropagation(),rt=!rt,ot.style.transform=rt?"":"rotate(-90deg)",ot.setAttribute("aria-expanded",String(rt)),dt.style.display=rt?"":"none"});let K=document.createElement("label");K.style.cssText="display:flex;align-items:center;gap:8px;flex:1;cursor:pointer;min-width:0;";let W=document.createElement("input");W.type="checkbox",W.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",W.addEventListener("change",()=>{W.indeterminate=!1,N.forEach(ut=>{P.get(ut).checked=W.checked,C.set(ut,W.checked)}),H()});let q=document.createElement("span");q.textContent=D.label,q.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",K.append(W,q),Z.append(ot,K),p.appendChild(Z),p.appendChild(dt),O.push({node:D,cb:W}),z(D.children,L+1,dt)}function z(D,L,p){for(let N of D)N.type==="group"?it(N,L,p):A(N.field,L,p)}z(u,0,E),H();let G=document.createElement("div");G.style.cssText=g("display:flex","gap:6px","padding:10px 12px",`border-top:1px solid ${y(c,"overlayDivider")}`);let x=document.createElement("button");x.type="button",x.textContent=a.colChooserApply,x.style.cssText=g("flex:1","padding:7px 0",`background:${y(c,"selectionColor")}`,`color:${y(c,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600"),x.addEventListener("click",()=>h(C));let k=document.createElement("button");return k.type="button",k.textContent=a.colChooserCancel,k.style.cssText=g("flex:1","padding:7px 0",`background:${y(c,"overlayHeaderBg")}`,`color:${y(c,"overlayText")}`,`border:1px solid ${y(c,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"),k.addEventListener("click",()=>d()),G.append(x,k),m.append(v,E,G),m.addEventListener("mousedown",D=>D.stopPropagation()),m.addEventListener("keydown",D=>{D.key==="Escape"&&d(),D.stopPropagation()}),m}function Ge({colLeft:r,headerH:t,width:e,maxPanelHeight:s,label:i,curVal:o,sortPriority:n,asc:l,desc:a,filterId:c,swatchColors:h,activeColor:d,multiSortEnabled:u,i18n:f,theme:_,wrapperHeight:g,openUpward:w,distinctValues:m,selectedValues:v,suggest:S,suggestScope:b,tagValues:E,containsValue:C,minQueryChars:T,onClose:$,onSort:M,onApply:j,onApplyValues:O,onColorFilter:V,onResetCol:P,onResetAll:H}){let F=Math.max(0,Math.min(r,e-220)),A=(...I)=>I.join(";"),it=(I,ht,st)=>{let nt=document.createElement("button");return nt.type="button",nt.textContent=I,nt.dataset.action=ht,nt.className=B.btn,nt.style.cssText=st,nt},z=document.createElement("div");z.setAttribute("role","dialog"),z.setAttribute("aria-modal","true"),z.setAttribute("aria-label",f.filterDialog(i)),z.className=`${B.overlay} ${B.panel}`,z.style.cssText=A("position:absolute",`left:${F}px`,w?`bottom:${Math.max(0,g-t)}px`:`top:${t}px`,"width:220px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(_,"overlayShadow")}`,`font-family:${y(_,"fontFamily")}`,`font-size:${_.fontSize}px`,`color:${y(_,"overlayText")}`,"z-index:100","overflow:hidden","user-select:none","display:flex","flex-direction:column",...s?[`max-height:${Math.max(120,s)}px`]:[]);let G=document.createElement("div");G.style.cssText=A("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${y(_,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(_,"overlayDivider")}`);let x=document.createElement("span");x.textContent=i,x.style.fontWeight="600";let k=it("\xD7","close",A("background:none","border:none",`color:${y(_,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"));k.setAttribute("aria-label",f.filterClose),G.append(x,k);let D=document.createElement("div");D.style.cssText=A("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let L=document.createElement("div");L.style.cssText=A("display:flex","gap:6px");let p=A("flex:1","padding:6px 0","border-radius:4px","cursor:pointer","font-size:12px"),N=it(f.sortAsc,"asc",A(p,`background:${l?y(_,"selectionColor"):y(_,"overlayHeaderBg")}`,`color:${l?y(_,"overlayAccentText"):y(_,"overlayText")}`,`border:1px solid ${l?y(_,"selectionColor"):y(_,"overlayBorder")}`));N.setAttribute("aria-pressed",String(l));let Z=it(f.sortDesc,"desc",A(p,`background:${a?y(_,"selectionColor"):y(_,"overlayHeaderBg")}`,`color:${a?y(_,"overlayAccentText"):y(_,"overlayText")}`,`border:1px solid ${a?y(_,"selectionColor"):y(_,"overlayBorder")}`));if(Z.setAttribute("aria-pressed",String(a)),L.append(N,Z),n>0){let I=document.createElement("span");I.textContent=`#${n}`,I.title="Sort priority",I.style.cssText=A("align-self:center","font-size:11px","font-weight:700",`color:${y(_,"selectionColor")}`,"min-width:20px","text-align:center"),L.appendChild(I)}if(D.appendChild(L),u){let I=document.createElement("div");I.textContent=f.sortShiftHint??"Shift+click: add to multi-sort",I.style.cssText=A("font-size:10px",`color:${y(_,"overlayHintText")}`,"margin-top:5px"),D.appendChild(I)}let dt=null;if(h?.length){dt=document.createElement("div"),dt.style.cssText=A("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let I=document.createElement("div");I.textContent=f.filterColorLabel??"Filter by color",I.style.cssText=A("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:6px");let ht=document.createElement("div");ht.style.cssText=A("display:flex","flex-wrap:wrap","gap:6px"),h.forEach(st=>{let nt=d===st,pt=document.createElement("button");pt.type="button",pt.dataset.action="color-filter",pt.dataset.value=st,pt.title=st,pt.setAttribute("aria-pressed",String(nt)),pt.className=B.swatch,pt.style.cssText=A("width:22px","height:22px","border-radius:50%","cursor:pointer","padding:0","border:none",`background:${st}`,`box-shadow:${nt?`0 0 0 2px ${y(_,"overlayBg")}, 0 0 0 4px ${y(_,"selectionColor")}`:"0 0 0 1px rgba(0,0,0,0.15)"}`),ht.appendChild(pt)}),dt.append(I,ht)}let rt=document.createElement("div");rt.style.cssText=A("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let ot=document.createElement("label");ot.textContent=f.filterLabel,ot.htmlFor=c,ot.style.cssText=A("font-size:11px",`color:${y(_,"overlayMutedText")}`,"display:block","margin-bottom:6px");let K=document.createElement("input");K.type="text",K.id=c,K.value=o,K.placeholder=f.filterPlaceholder,K.className=B.editor,K.style.cssText=A("width:100%","padding:6px 8px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px",`color:${y(_,"overlayText")}`,`font-size:${_.fontSize}px`,"box-sizing:border-box"),rt.append(ot,K);let W=null,q=null;if(!Array.isArray(m)&&typeof S=="function"){let Ut=function(){if(At.replaceChildren(),mt){At.appendChild(kt(f.filterTagMinChars(St),!1)),xt.replaceChildren(tt(f.filterTagContains(et),f.filterTagContains(et),()=>Y(et),!0)),Et.style.display="flex",at.setAttribute("aria-expanded","true"),lt=-1;return}let ct=new Set(I.tags),yt=X.filter(vt=>!ct.has(vt));if(b==="local"&&yt.length>0){let vt=kt(f.filterTagLocalScope,!0);vt.style.borderBottom=`1px solid ${y(_,"overlayDivider")}`,At.appendChild(vt)}let bt=yt.slice(0,ks);for(let vt of bt){let Ct=vt===""?f.emptyCell:vt;At.appendChild(tt(Ct,Ct,()=>_t(vt),!1))}if(yt.length>bt.length){let vt=kt(f.filterTagMore(yt.length-bt.length),!0);vt.style.borderTop=`1px solid ${y(_,"overlayDivider")}`,At.appendChild(vt)}yt.length===0&&At.appendChild(kt(X.length?f.filterTagAllSelected:f.filterTagNoMatch,!1)),xt.replaceChildren(tt(f.filterTagContains(et),f.filterTagContains(et),()=>Y(et),!0)),Et.style.display="flex",at.setAttribute("aria-expanded","true"),lt=-1},I={tags:Array.isArray(E)?[...E]:[],contains:typeof C=="string"&&C?C:null};W=document.createElement("div"),W.style.cssText=A("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let ht=document.createElement("div");ht.textContent=f.filterLabel,ht.style.cssText=A("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:6px");let st=document.createElement("div");st.style.cssText=A("display:none","flex-direction:column","flex:0 1 auto","min-height:0","margin-top:8px");let nt=document.createElement("div");nt.style.cssText=A("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:4px");let pt=document.createElement("div");pt.style.cssText=A("display:flex","flex-wrap:wrap","gap:4px","flex:1 1 auto","min-height:30px","max-height:64px","overflow-y:auto","padding:6px","border-radius:4px",`border:1px solid ${y(_,"overlayBorder")}`,`background:${y(_,"overlayHeaderBg")}`),st.append(nt,pt);let at=document.createElement("input");at.type="text",at.id=c,at.placeholder=f.filterTagPlaceholder,at.className=B.editor,at.setAttribute("role","combobox"),at.setAttribute("aria-expanded","false"),at.setAttribute("aria-autocomplete","list"),at.style.cssText=A("width:100%","padding:6px 8px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px",`color:${y(_,"overlayText")}`,`font-size:${_.fontSize}px`,"box-sizing:border-box");let Et=document.createElement("div");Et.style.cssText=A("display:none","flex-direction:column","flex:0 0 auto","margin-top:4px",`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px","overflow:hidden");let At=document.createElement("div");At.setAttribute("role","listbox"),At.style.cssText=A("flex:0 0 auto","max-height:132px","overflow-y:auto");let xt=document.createElement("div");xt.style.cssText=A("flex:0 0 auto",`border-top:1px solid ${y(_,"overlayDivider")}`,`background:${y(_,"overlayHeaderBg")}`),Et.append(At,xt);let Mt=()=>{pt.replaceChildren();let ct=(bt,vt,Ct,Te)=>{let Xt=document.createElement("span");Xt.className=B.chip+(Te?` ${B.chipContains}`:""),Xt.style.cssText=A("display:inline-flex","align-items:center","gap:4px","max-width:100%","padding:2px 4px 2px 7px","border-radius:10px","font-size:11px","box-sizing:border-box",Te?`background:${y(_,"overlayHeaderBg")};border:1px dashed ${y(_,"overlayBorder")};color:${y(_,"overlayMutedText")}`:`background:${y(_,"sortIconBg")};border:1px solid ${y(_,"overlayBorder")};color:${y(_,"overlayText")}`);let ue=document.createElement("span");ue.textContent=bt,Xt.title=vt,ue.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";let Wt=document.createElement("button");Wt.type="button",Wt.className=B.btn,Wt.textContent="\xD7",Wt.setAttribute("aria-label",f.filterTagRemove(vt)),Wt.style.cssText=A("border:none","background:none","cursor:pointer","padding:0 2px","line-height:1","font-size:13px",`color:${y(_,"overlayMutedText")}`),Wt.addEventListener("click",()=>{Ct(),Mt(),at.focus()}),Xt.append(ue,Wt),pt.appendChild(Xt)};I.contains!==null?ct(f.filterTagContains(I.contains),f.filterTagContains(I.contains),()=>{I.contains=null},!0):I.tags.forEach((bt,vt)=>{let Ct=bt===""?f.emptyCell:bt;ct(Ct,Ct,()=>{I.tags.splice(vt,1)})});let yt=pt.childElementCount;st.style.display=yt?"flex":"none",nt.textContent=f.filterTagSelected(yt)},Ot=()=>{Et.style.display="none",At.replaceChildren(),xt.replaceChildren(),at.setAttribute("aria-expanded","false")},_t=ct=>{I.contains=null,I.tags.includes(ct)||I.tags.push(ct),at.value="",Ot(),Mt(),at.focus()},Y=ct=>{I.tags=[],I.contains=ct,at.value="",Ot(),Mt(),at.focus()},tt=(ct,yt,bt,vt)=>{let Ct=document.createElement("div");return Ct.setAttribute("role","option"),Ct.className=B.menuItem,Ct.title=yt,Ct.textContent=ct,Ct.style.cssText=A("padding:5px 8px","font-size:12px","cursor:pointer","overflow:hidden","text-overflow:ellipsis","white-space:nowrap",vt?`color:${y(_,"overlayMutedText")}`:`color:${y(_,"overlayText")}`),Ct.addEventListener("mouseenter",()=>{Ct.style.background=y(_,"overlayItemHoverBg")}),Ct.addEventListener("mouseleave",()=>{Ct.style.background="none"}),Ct.addEventListener("click",bt),Ct},et="",X=[],lt=-1,mt=!1,Tt=Math.floor(Number(T)),St=Number.isFinite(Tt)&&Tt>0?Tt:Ds,kt=(ct,yt)=>{let bt=document.createElement("div");return bt.textContent=ct,bt.style.cssText=A("padding:5px 8px",`font-size:${yt?11:12}px`,yt?"font-style:italic":"",`color:${y(_,"overlayMutedText")}`),bt},Ft=0,jt=0,he=async ct=>{let yt=++Ft,bt=[];try{bt=await S(ct)??[]}catch{bt=[]}yt!==Ft||at.value.trim()!==ct||(et=ct,X=bt,mt=!1,Ut())};at.addEventListener("input",()=>{clearTimeout(jt);let ct=at.value.trim();if(!ct){Ft++,Ot();return}if(ct.length<St){Ft++,et=ct,X=[],mt=!0,Ut();return}jt=setTimeout(()=>he(ct),180)});let de=()=>[...Et.querySelectorAll('[role="option"]')],Me=ct=>{let yt=de();yt.forEach((bt,vt)=>{bt.style.background=vt===ct?y(_,"overlayItemHoverBg"):"none"}),lt=ct,yt[ct]?.scrollIntoView({block:"nearest"})};at.addEventListener("keydown",ct=>{let yt=Et.style.display!=="none";ct.key==="ArrowDown"&&yt?(ct.preventDefault(),Me(Math.min(lt+1,de().length-1))):ct.key==="ArrowUp"&&yt?(ct.preventDefault(),Me(Math.max(lt-1,0))):ct.key==="Enter"?(ct.preventDefault(),yt?de()[lt>=0?lt:0]?.click():wt.click()):ct.key==="Escape"&&(yt?(Ot(),lt=-1):$()),ct.stopPropagation()}),at.addEventListener("input",()=>{lt=-1}),W.append(ht,at,Et,st),Mt(),z.addEventListener("jhg-dispose",()=>{clearTimeout(jt),Ft++}),q=()=>{let ct=at.value.trim();return ct&&I.contains===null&&I.tags.length===0&&Y(ct),I.contains!==null?{contains:I.contains}:{values:[...I.tags]}}}let ut=null,Q=[];if(Array.isArray(m)&&m.length>0){ut=document.createElement("div"),ut.style.cssText=A("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let I=document.createElement("div");I.textContent=f.filterValuesLabel,I.style.cssText=A("font-size:11px",`color:${y(_,"overlayMutedText")}`,"margin-bottom:6px");let ht=Array.isArray(v)?new Set(v):null,st=(_t,Y,tt)=>{let et=document.createElement("label");et.style.cssText=A("display:flex","align-items:center","gap:6px","font-size:12px","cursor:pointer","padding:2px 0");let X=document.createElement("input");X.type="checkbox",X.checked=tt,X.dataset.value=_t;let lt=document.createElement("span");return lt.textContent=Y,lt.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",et.append(X,lt),{row:et,cb:X}},nt=document.createElement("input");nt.type="text",nt.placeholder=f.filterTagPlaceholder,nt.setAttribute("aria-label",f.filterTagPlaceholder),nt.className=B.editor,nt.style.cssText=A("width:100%","padding:6px 8px",`background:${y(_,"overlayBg")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px",`color:${y(_,"overlayText")}`,`font-size:${_.fontSize}px`,"box-sizing:border-box","margin-bottom:6px");let pt=document.createElement("div");pt.style.cssText=A("max-height:140px","overflow-y:auto","display:flex","flex-direction:column");let at=[];m.forEach(_t=>{let Y=ht===null?!0:ht.has(_t),tt=_t===""?f.emptyCell:_t,{row:et,cb:X}=st(_t,tt,Y);Q.push(X),at.push({row:et,cb:X,text:tt}),pt.appendChild(et)});let Et=document.createElement("div");Et.textContent=f.filterTagNoMatch,Et.style.cssText=A("padding:5px 8px","font-size:12px",`color:${y(_,"overlayMutedText")}`,"display:none"),pt.appendChild(Et);let{row:At,cb:xt}=st("",f.filterSelectAll,Q.every(_t=>_t.checked));delete xt.dataset.value,xt.dataset.selectAll="true",At.style.cssText+=`;font-weight:600;border-bottom:1px solid ${y(_,"overlayDivider")};padding-bottom:6px;margin-bottom:4px;`;let Mt=()=>at.filter(_t=>_t.row.style.display!=="none").map(_t=>_t.cb),Ot=()=>{let _t=Mt();xt.checked=_t.length>0&&_t.every(Y=>Y.checked)};xt.addEventListener("change",()=>{Mt().forEach(_t=>{_t.checked=xt.checked})}),Q.forEach(_t=>_t.addEventListener("change",Ot)),nt.addEventListener("input",()=>{let _t=Q.every(et=>et.checked),Y=nt.value.trim().toLowerCase(),tt=!1;for(let et of at){let X=!Y||et.text.toLowerCase().includes(Y);et.row.style.display=X?"flex":"none",_t&&(et.cb.checked=X),tt=tt||X}Et.style.display=tt?"none":"block",Ot()}),nt.addEventListener("keydown",_t=>{_t.key==="Enter"?(_t.preventDefault(),wt.click()):_t.key==="Escape"&&$(),_t.stopPropagation()}),ut.append(I,nt,At,pt)}let J=document.createElement("div");J.style.cssText=A("padding:10px 12px",`border-bottom:1px solid ${y(_,"overlayDivider")}`);let U=document.createElement("div");U.style.cssText=A("display:flex","gap:6px");let wt=it(f.filterApply,"apply",A("flex:1","padding:7px 0",`background:${y(_,"selectionColor")}`,`color:${y(_,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600")),Lt=it(f.filterReset,"reset-col",A("flex:1","padding:7px 0",`background:${y(_,"overlayHeaderBg")}`,`color:${y(_,"overlayText")}`,`border:1px solid ${y(_,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"));U.append(wt,Lt),J.appendChild(U);let Rt=document.createElement("div");Rt.style.cssText=A("padding:8px 12px","text-align:center");let Dt=it(f.filterResetAll,"reset-all",A("background:none","border:none",`color:${y(_,"overlayMutedText")}`,"cursor:pointer","font-size:12px","text-decoration:underline"));Rt.appendChild(Dt);let ft=ut??W??rt;z.append(G,D,...dt?[dt]:[],ft,J,Rt);for(let I of z.children)I.style.flex="0 0 auto";return ft.style.flex="1 1 auto",ft.style.minHeight="0",ft===W&&(ft.style.display="flex",ft.style.flexDirection="column",ft.style.overflowY="auto"),ft===ut&&(ft.style.overflowY="auto"),z.addEventListener("mousedown",I=>I.stopPropagation()),z.addEventListener("keydown",I=>{if(I.key!=="Tab")return;let ht=[...z.querySelectorAll("button:not([disabled]), input")];if(ht.length===0)return;let st=ht[0],nt=ht[ht.length-1];I.shiftKey?document.activeElement===st&&(I.preventDefault(),nt.focus()):document.activeElement===nt&&(I.preventDefault(),st.focus())},!0),z.addEventListener("click",I=>{let ht=I.target.closest("[data-action]")?.dataset?.action;if(ht)if(ht==="close")$();else if(ht==="asc"||ht==="desc")M(ht,I.shiftKey);else if(ht==="apply")if(ut)O(Q.filter(st=>st.checked).map(st=>st.dataset.value));else if(q){let st=q();st.contains!==void 0?j(st.contains):st.values.length?O(st.values):j("")}else j(K.value.trim());else if(ht==="color-filter"){let st=I.target.closest('[data-action="color-filter"]')?.dataset?.value;if(st==null)return;V(st)}else ht==="reset-col"?P():ht==="reset-all"&&H()}),K.addEventListener("keydown",I=>{I.key==="Enter"?(I.preventDefault(),wt.click()):I.key==="Escape"&&$(),I.stopPropagation()}),z.addEventListener("keydown",I=>{I.key==="Escape"&&$()}),z}function Ke({x:r,y:t,width:e,isFrozen:s,isFrozenRight:i,isDeleted:o,i18n:n,theme:l,allowedItems:a={},onFreeze:c,onFreezeRight:h,onVisibility:d,onInsertLeft:u,onInsertRight:f,onDelete:_,onUndelete:g,onEscape:w}){let{freeze:m=!0,freezeRight:v=!0,visibility:S=!0,insertLeft:b=!0,insertRight:E=!0,delete:C=!0}=a;if(!m&&!v&&!S&&!b&&!E&&!C)return null;let T=170,$=(...z)=>z.join(";"),M=$("padding:8px 14px","cursor:pointer"),j=document.createElement("div");j.setAttribute("role","menu"),j.className=`${B.overlay} ${B.menu}`,j.style.cssText=$("position:absolute",`left:${Math.min(r,e-T-2)}px`,`top:${t}px`,`width:${T}px`,`background:${y(l,"overlayBg")}`,`border:1px solid ${y(l,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(l,"overlayMenuShadow")}`,`font-family:${y(l,"fontFamily")}`,`font-size:${l.fontSize}px`,`color:${y(l,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0");let O=(z,G)=>{let x=document.createElement("div");return x.setAttribute("role","menuitem"),x.setAttribute("tabindex","0"),x.textContent=z,x.dataset.action=G,x.className=B.menuItem,x.style.cssText=M,x.addEventListener("mouseover",()=>{x.style.background=y(l,"overlayItemHoverBg")}),x.addEventListener("mouseout",()=>{x.style.background=""}),x.addEventListener("focus",()=>{x.style.background=y(l,"overlayItemHoverBg")}),x.addEventListener("blur",()=>{x.style.background=""}),x},V=()=>{let z=document.createElement("div");return z.style.cssText=`height:1px;background:${y(l,"overlayDivider")};margin:4px 0;`,z},P=[];m&&P.push(O(s?n.colUnfreeze:n.colFreeze,s?"unfreeze":"freeze")),v&&P.push(O(i?n.colUnfreezeRight:n.colFreezeRight,i?"unfreeze-right":"freeze-right"));let H=S?[O(n.colVisibility,"col-visibility")]:[],R=[];b&&R.push(O(n.colInsertLeft,"col-insert-left")),E&&R.push(O(n.colInsertRight,"col-insert-right"));let F=C?[O(o?n.colUndelete:n.colDelete,o?"col-undelete":"col-delete")]:[],it=[P,H,R,F].filter(z=>z.length>0).flatMap((z,G)=>G===0?z:[V(),...z]);return j.addEventListener("mousedown",z=>z.stopPropagation()),j.addEventListener("click",z=>{let G=z.target.closest("[data-action]")?.dataset?.action;if(G)if(G==="freeze"||G==="unfreeze")c();else if(G==="freeze-right"||G==="unfreeze-right")h();else if(G==="col-visibility"){d();return}else if(G==="col-insert-left"){u();return}else if(G==="col-insert-right"){f();return}else G==="col-delete"?_():G==="col-undelete"&&g()}),j.addEventListener("keydown",z=>{if(z.key==="Escape")w();else if(z.key==="Enter"||z.key===" ")z.preventDefault(),document.activeElement?.click?.();else if(z.key==="ArrowDown"||z.key==="ArrowUp"){z.preventDefault();let G=[...j.querySelectorAll('[role="menuitem"]')],x=G.indexOf(document.activeElement),k=z.key==="ArrowDown"?(x+1)%G.length:(x-1+G.length)%G.length;G[k]?.focus()}z.stopPropagation()}),j.append(...it),j}function Ee(r,t,e,s){let i=new Map;return r((o,n)=>{let l=e(n);l>=0&&i.set(l,o)}),t.forEach((o,n)=>i.set(s(n),o)),[...i.entries()].sort(([o],[n])=>o-n)}function Ve({cols:r,labels:t,rows:e,title:s,includeHeaders:i,i18n:o,lang:n}){let l=h=>String(h??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),a=i?`<thead><tr>${t.map(h=>`<th>${l(h)}</th>`).join("")}</tr></thead>`:"",c=e.map(h=>`<tr>${r.map(d=>`<td>${l(h[d])}</td>`).join("")}</tr>`).join("");return`<!DOCTYPE html><html lang="${l(n)}"><head>
|
|
126
126
|
<meta charset="utf-8">
|
|
127
127
|
<title>${l(s||"Grid Print")}</title>
|
|
128
128
|
<style>
|
|
@@ -138,12 +138,12 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
|
|
|
138
138
|
${s?`<h2>${l(s)}</h2>`:""}
|
|
139
139
|
<button onclick="window.print()" style="margin-bottom:8px;padding:4px 12px;cursor:pointer">\u{1F5A8} ${l(o.printButton)}</button>
|
|
140
140
|
<table>${a}<tbody>${c}</tbody></table>
|
|
141
|
-
</body></html>`}var ce=class{#t;#e=new Map;#i=[];#o=[0];#s=!1;constructor(t){this.#t=t}get defaultHeight(){return this.#t}set defaultHeight(t){t!==this.#t&&(this.#t=t,this.#s=!0)}#n(){this.#i=[...this.#e.keys()].sort((t,e)=>t-e),this.#o=new Array(this.#i.length+1),this.#o[0]=0;for(let t=0;t<this.#i.length;t++){let e=this.#e.get(this.#i[t]);this.#o[t+1]=this.#o[t]+(e-this.#t)}this.#s=!1}#a(){this.#s&&this.#n()}#l(t){let e=0,s=this.#i.length;for(;e<s;){let i=e+s>>1;this.#i[i]<t?e=i+1:s=i}return e}heightOf(t){return this.#e.get(t)??this.#t}hasOverride(t){return this.#e.has(t)}setHeight(t,e){let s=Math.max(1,Math.round(e));if(s===this.#t){this.#e.delete(t)&&(this.#s=!0);return}this.#e.get(t)!==s&&(this.#e.set(t,s),this.#s=!0)}snapshotOverrides(){return new Map(this.#e)}restoreOverrides(t){this.#e=new Map(t),this.#s=!0}clear(){this.#e.size&&(this.#e.clear(),this.#s=!0)}yOf(t){return t<=0?0:(this.#a(),t*this.#t+this.#o[this.#l(t)])}rowAt(t,e){if(t<0||e<0||this.yOf(e)+this.heightOf(e)<=t)return-1;let s=0,i=e;for(;s<i;){let o=s+i+1>>1;this.yOf(o)<=t?s=o:i=o-1}return s}shiftRows(t){if(this.#e.size===0)return;let e=new Map;for(let[s,i]of this.#e)e.set(t(s),i);this.#e=e,this.#s=!0}deleteRow(t){if(this.#e.size===0)return;let e=new Map;for(let[s,i]of this.#e)s!==t&&e.set(s>t?s-1:s,i);this.#e=e,this.#s=!0}};var Ls=new Intl.Collator(void 0,{numeric:!0});function Ue(r){return r==null||typeof r=="string"&&r.trim()===""?NaN:Number(r)}function Fs(r){return(t,e)=>{let s=t[r],i=e[r],o=Ue(s),n=Ue(i);return!Number.isNaN(o)&&!Number.isNaN(n)?o-n:Ls.compare(String(s??""),String(i??""))}}function Xe(r,t){if(!Array.isArray(r))throw new Error("[JHGrid] opts.data must be an array");let e=t?.length?t.map(i=>i.field):Object.keys(r[0]??{});if(!e.length)throw new Error("[JHGrid] opts.data: could not resolve columns from an empty array \u2014 pass opts.columnDefs");function s(i){let{filters:o={},sorts:n=[],quickFilter:l=""}=i??{},a=r;for(let[c,h]of Object.entries(o))if(Array.isArray(h)){if(h.length===0)continue;let d=new Set(h.map(String));a=a.filter(u=>d.has(String(u[c]??"")))}else if(h){let d=String(h).toLowerCase();a=a.filter(u=>String(u[c]??"").toLowerCase().includes(d))}if(l){let c=l.toLowerCase();a=a.filter(h=>Object.values(h).some(d=>String(d??"").toLowerCase().includes(c)))}for(let{field:c,dir:h}of[...n].reverse()){let d=h==="desc"?-1:1,u=Fs(c);a=[...a].sort((f,_)=>d*u(f,_))}return a}return{fetchMeta(i){let o=s(i);return Promise.resolve({totalRows:o.length,columns:e})},fetchData(i,o,n){let l=s(n);return Promise.resolve({rows:l.slice(i*o,i*o+o)})}}}var qe=new WeakMap;function $t(r){let t=qe.get(r);return t||(t={selectedRows:new Set,lastSelRow:null},qe.set(r,t)),t}function Je(r){return r._opts.rowSelection??"none"}var Ze={resetScope:["rowIndexState","full"],clear(r){this.rowSelection.clear(r)},snapshotStructural(r,t){let e=$t(r);t.selectedRows=new Set(e.selectedRows),t.lastSelRow=e.lastSelRow},restoreStructural(r,t){let e=$t(r);e.selectedRows=new Set(t.selectedRows??[]),e.lastSelRow=t.lastSelRow??null},exportState(r,t){t.selectedRows=[...$t(r).selectedRows]},importState(r,t){if(!Array.isArray(t.selectedRows))return;let e=$t(r);e.selectedRows=new Set(t.selectedRows),e.lastSelRow=t.selectedRows.at(-1)??null,r._draw()},install(r){Object.assign(r.prototype,{getSelectedRows(){return[...$t(this).selectedRows]},clearRowSelection(){let t=$t(this);t.selectedRows.clear(),t.lastSelRow=null,this._draw()}})},rowSelection:{modeFor:Je,has(r,t){return $t(r).selectedRows.has(t)},getRenderSet(r){let t=$t(r);return t.selectedRows.size>0?t.selectedRows:null},getSorted(r){return[...$t(r).selectedRows].sort((t,e)=>t-e)},clear(r){let t=$t(r);t.selectedRows.clear(),t.lastSelRow=null},shiftRows(r,t,e=-1){let s=$t(r);if(s.selectedRows.size>0){let i=new Set;for(let o of s.selectedRows)o!==e&&i.add(t(o));s.selectedRows=i}s.lastSelRow!=null&&(s.lastSelRow=s.lastSelRow===e?null:t(s.lastSelRow))},update(r,t,e,s){let i=Je(r);if(i==="none")return;let o=$t(r);if(i==="single")o.selectedRows.has(t)?o.selectedRows.clear():(o.selectedRows.clear(),o.selectedRows.add(t)),o.lastSelRow=t;else if(s&&o.lastSelRow!==null){let n=Math.min(o.lastSelRow,t),l=Math.max(o.lastSelRow,t);e||o.selectedRows.clear();for(let a=n;a<=l;a++)o.selectedRows.add(a)}else e?(o.selectedRows.has(t)?o.selectedRows.delete(t):o.selectedRows.add(t),o.lastSelRow=t):(o.selectedRows.clear(),o.selectedRows.add(t),o.lastSelRow=t);r._opts.onRowSelect?.([...o.selectedRows].sort((n,l)=>n-l)),r._announce(r._i18n.rowsSelectedAnnounce(o.selectedRows.size))},clearOnCellClick(r,t){if(!r._opts.showRowNumbers||t.ctrlKey||t.metaKey||t.shiftKey)return;let e=$t(r);e.selectedRows.size!==0&&(e.selectedRows.clear(),e.lastSelRow=null,r._opts.onRowSelect?.([]))}}};var Qe=typeof requestAnimationFrame=="function",Ps=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),Bs=r=>r*(2-r),Nt=class{#t;#e;#i;#o=0;#s=0;#n=0;#a;#l;#r;#c;constructor({value:t=0,onFrame:e=null,requestFrame:s,cancelFrame:i,now:o}={}){this.#t=t,this.#e=t,this.#i=t,this.#a=e,this.#c=o??Ps,this.#l=s!==void 0?s:Qe?n=>requestAnimationFrame(n):null,this.#r=i!==void 0?i:Qe?n=>cancelAnimationFrame(n):null}get value(){if(this.#s===0)return this.#i;let t=(this.#c()-this.#o)/this.#s;return t>=1?(this.#s=0,this.#t=this.#i,this.#i):this.#e+(this.#i-this.#e)*Bs(Math.max(0,t))}get animating(){return this.#s!==0&&this.#c()-this.#o<this.#s}set(t){this.#d(),this.#s=0,this.#t=this.#e=this.#i=t}to(t,e){if(t!==this.#i){if(!(e>0)||!this.#l){this.set(t);return}this.#e=this.value,this.#i=t,this.#o=this.#c(),this.#s=e,this.#h()}}stop(){this.#d(),this.#s=0,this.#t=this.#e=this.#i=this.value}#h(){if(this.#n||!this.#l)return;let t=()=>{this.#n=0;let e=this.animating;this.#a?.(),e&&this.#h()};this.#n=this.#l(t)}#d(){this.#n&&this.#r&&this.#r(this.#n),this.#n=0}};function ts(r=typeof window<"u"?window:null){try{return!!r?.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches}catch{return!1}}var Jt={loading:"Loading\u2026",loadError:"\u26A0 \uB370\uC774\uD130\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",pasteTruncated:r=>`${r}\uAC1C \uAC12\uC774 \uBC94\uC704\uB97C \uBC97\uC5B4\uB098 \uBD99\uC5EC\uB123\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`,copyIncomplete:r=>`${r}\uAC1C \uD589\uC774 \uC544\uC9C1 \uBD88\uB7EC\uC624\uC9C0 \uC54A\uC544 \uBCF5\uC0AC\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`,noData:"\uD45C\uC2DC\uD560 \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.",emptyCell:"\uBE48 \uC140",ariaGrid:"\uB370\uC774\uD130 \uADF8\uB9AC\uB4DC",sortAsc:"\u2191 \uC624\uB984\uCC28\uC21C",sortDesc:"\u2193 \uB0B4\uB9BC\uCC28\uC21C",sortShiftHint:"Shift+\uD074\uB9AD: \uB2E4\uC911 \uC815\uB82C \uCD94\uAC00",rowNumberLabel:"\uBC88\uD638",filterLabel:"\uAC80\uC0C9",filterPlaceholder:"\uAC80\uC0C9\uC5B4 \uC785\uB825\u2026",filterApply:"\uC801\uC6A9",filterReset:"\uCD08\uAE30\uD654",filterResetAll:"\uBAA8\uB4E0 \uD544\uD130 \uCD08\uAE30\uD654",filterClose:"\uB2EB\uAE30",filterDialog:r=>`${r} \uD544\uD130`,filterColorLabel:"\uC0C9\uC0C1\uC73C\uB85C \uD544\uD130",filterValuesLabel:"\uAC12\uC73C\uB85C \uD544\uD130",filterSelectAll:"(\uC804\uCCB4 \uC120\uD0DD)",filterTagPlaceholder:"\uAC12 \uAC80\uC0C9\u2026",filterTagLocalScope:"\uB85C\uB4DC\uB41C \uBC94\uC704\uC5D0\uC11C",filterTagNoMatch:"\uC77C\uCE58\uD558\uB294 \uAC12 \uC5C6\uC74C",filterTagMinChars:r=>`${r}\uAE00\uC790 \uC774\uC0C1 \uC785\uB825\uD558\uC138\uC694`,filterTagAllSelected:"\uC77C\uCE58\uD558\uB294 \uAC12\uC744 \uBAA8\uB450 \uC120\uD0DD\uD568",filterTagMore:r=>`\uC678 ${r}\uAC1C \u2014 \uAC80\uC0C9\uC5B4\uB97C \uC881\uD600\uBCF4\uC138\uC694`,filterTagSelected:r=>`\uC120\uD0DD\uD55C \uAC12 (${r})`,filterTagContains:r=>`"${r}" \uD3EC\uD568`,filterTagRemove:r=>`${r} \uC81C\uAC70`,colFreeze:"\uC5F4 \uACE0\uC815",colUnfreeze:"\uC5F4 \uACE0\uC815 \uD574\uC81C",colFreezeRight:"\uC624\uB978\uCABD \uC5F4 \uACE0\uC815",colUnfreezeRight:"\uC624\uB978\uCABD \uC5F4 \uACE0\uC815 \uD574\uC81C",colVisibility:"\uC5F4 \uD45C\uC2DC/\uC228\uAE30\uAE30\u2026",colChooserTitle:"\uC5F4 \uD45C\uC2DC/\uC228\uAE30\uAE30",colChooserApply:"\uC801\uC6A9",colChooserCancel:"\uCDE8\uC18C",colChooserSelectAll:"\uC804\uCCB4 \uC120\uD0DD",colInsertLeft:"\uC67C\uCABD\uC5D0 \uC5F4 \uC0BD\uC785",colInsertRight:"\uC624\uB978\uCABD\uC5D0 \uC5F4 \uC0BD\uC785",colInsertTitle:"\uC5F4 \uCD94\uAC00",colInsertPlaceholder:"\uC5F4 \uC774\uB984 \uC785\uB825",colInsertConfirm:"\uCD94\uAC00",colInsertCancel:"\uCDE8\uC18C",colDelete:"\uC774 \uC5F4 \uC0AD\uC81C",colUndelete:"\uC0AD\uC81C \uCDE8\uC18C",rowInsertTop:"\uB9E8 \uC704\uC5D0 \uD589 \uC0BD\uC785",rowInsertBottom:"\uB9E8 \uC544\uB798\uC5D0 \uD589 \uC0BD\uC785",rowInsertAbove:"\uC704\uC5D0 \uD589 \uC0BD\uC785",rowInsertBelow:"\uC544\uB798\uC5D0 \uD589 \uC0BD\uC785",rowAddEnd:"\uD589 \uCD94\uAC00",rowDelete:"\uC774 \uD589 \uC0AD\uC81C",rowDeleteMark:"\uC774 \uD589 \uC0AD\uC81C \uD45C\uC2DC",rowDeletePermanent:"\uC774 \uD589 \uC644\uC804 \uC0AD\uC81C",rowUndelete:"\uC0AD\uC81C \uCDE8\uC18C",editAriaLabel:(r,t)=>`${r} \uD3B8\uC9D1, ${t}\uD589`,announceCell:(r,t,e)=>`${r}\uD589 ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} \uC5F4 \uBA38\uB9AC\uAE00. Enter: \uC815\uB82C/\uD544\uD130 \uBA54\uB274. \uBA54\uB274 \uD0A4: \uC5F4 \uC635\uC158.`,rowHeaderAnnounce:r=>`${r}\uD589. \uBA54\uB274 \uD0A4: \uD589 \uC635\uC158.`,rowReorderAnnounce:(r,t)=>`${r}\uD589\uC744 ${t}\uD589 \uC704\uCE58\uB85C \uC774\uB3D9\uD588\uC2B5\uB2C8\uB2E4.`,sortAppliedAnnounce:(r,t)=>`${r} ${t==="asc"?"\uC624\uB984\uCC28\uC21C":"\uB0B4\uB9BC\uCC28\uC21C"} \uC815\uB82C \uC801\uC6A9\uB428.`,filterAppliedAnnounce:r=>`${r}\uC5D0 \uD544\uD130\uAC00 \uC801\uC6A9\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,filterClearedAnnounce:r=>`${r} \uD544\uD130\uAC00 \uCD08\uAE30\uD654\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,allFiltersClearedAnnounce:"\uBAA8\uB4E0 \uD544\uD130\uC640 \uC815\uB82C\uC774 \uCD08\uAE30\uD654\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",rowsSelectedAnnounce:r=>r===0?"\uC120\uD0DD\uC774 \uD574\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.":`${r}\uAC1C \uD589\uC774 \uC120\uD0DD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,unsavedEditsWarning:"\uC800\uC7A5\uD558\uC9C0 \uC54A\uC740 \uD3B8\uC9D1\uC774 \uC788\uC2B5\uB2C8\uB2E4. \uC774 \uBCC0\uACBD\uC744 \uC801\uC6A9\uD558\uBA74 \uD3B8\uC9D1\uC774 \uC0AD\uC81C\uB429\uB2C8\uB2E4. \uACC4\uC18D\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\uC778\uC1C4",validationRequired:r=>`${r}\uC740(\uB294) \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.`,validationPattern:r=>`${r} \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,validationMin:(r,t)=>`${r}\uC740(\uB294) ${t} \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMax:(r,t)=>`${r}\uC740(\uB294) ${t} \uC774\uD558\uC5EC\uC57C \uD569\uB2C8\uB2E4.`,validationMinLength:(r,t)=>`${r}\uC740(\uB294) \uCD5C\uC18C ${t}\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMaxLength:(r,t)=>`${r}\uC740(\uB294) \uCD5C\uB300 ${t}\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`,validationInvalid:r=>`${r} \uAC12\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,pagerFirst:"\uCCAB \uD398\uC774\uC9C0",pagerPrev:"\uC774\uC804 \uD398\uC774\uC9C0",pagerNext:"\uB2E4\uC74C \uD398\uC774\uC9C0",pagerLast:"\uB9C8\uC9C0\uB9C9 \uD398\uC774\uC9C0",pagerPageLabel:(r,t)=>`${r} / ${t} \uD398\uC774\uC9C0`,aggSum:"\uD569\uACC4:",aggAvg:"\uD3C9\uADE0:",aggCount:"\uAC1C\uC218:",aggMin:"\uCD5C\uC18C:",aggMax:"\uCD5C\uB300:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"\uD569\uACC4"};var Zt={loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026",loadError:"\u26A0 \u30C7\u30FC\u30BF\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002",pasteTruncated:r=>`${r}\u4EF6\u304C\u7BC4\u56F2\u5916\u306E\u305F\u3081\u8CBC\u308A\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,copyIncomplete:r=>`${r}\u884C\u304C\u672A\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3081\u30B3\u30D4\u30FC\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,noData:"\u8868\u793A\u3059\u308B\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093\u3002",emptyCell:"\u7A7A\u30BB\u30EB",ariaGrid:"\u30C7\u30FC\u30BF\u30B0\u30EA\u30C3\u30C9",sortAsc:"\u2191 \u6607\u9806",sortDesc:"\u2193 \u964D\u9806",sortShiftHint:"Shift+\u30AF\u30EA\u30C3\u30AF: \u8907\u6570\u30BD\u30FC\u30C8\u306B\u8FFD\u52A0",rowNumberLabel:"No.",filterLabel:"\u691C\u7D22",filterPlaceholder:"\u691C\u7D22\u8A9E\u3092\u5165\u529B\u2026",filterApply:"\u9069\u7528",filterReset:"\u30EA\u30BB\u30C3\u30C8",filterResetAll:"\u3059\u3079\u3066\u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u3092\u30EA\u30BB\u30C3\u30C8",filterClose:"\u9589\u3058\u308B",filterDialog:r=>`${r} \u30D5\u30A3\u30EB\u30BF\u30FC`,filterColorLabel:"\u8272\u3067\u30D5\u30A3\u30EB\u30BF\u30FC",filterValuesLabel:"\u5024\u3067\u30D5\u30A3\u30EB\u30BF\u30FC",filterSelectAll:"(\u3059\u3079\u3066\u9078\u629E)",filterTagPlaceholder:"\u5024\u3092\u691C\u7D22\u2026",filterTagLocalScope:"\u8AAD\u307F\u8FBC\u307F\u6E08\u307F\u306E\u7BC4\u56F2\u304B\u3089",filterTagNoMatch:"\u4E00\u81F4\u3059\u308B\u5024\u304C\u3042\u308A\u307E\u305B\u3093",filterTagMinChars:r=>`${r}\u6587\u5B57\u4EE5\u4E0A\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044`,filterTagAllSelected:"\u4E00\u81F4\u3059\u308B\u5024\u3092\u3059\u3079\u3066\u9078\u629E\u6E08\u307F",filterTagMore:r=>`\u4ED6 ${r}\u4EF6 \u2014 \u691C\u7D22\u8A9E\u3092\u7D5E\u3063\u3066\u304F\u3060\u3055\u3044`,filterTagSelected:r=>`\u9078\u629E\u3057\u305F\u5024 (${r})`,filterTagContains:r=>`"${r}" \u3092\u542B\u3080`,filterTagRemove:r=>`${r} \u3092\u524A\u9664`,colFreeze:"\u5217\u3092\u56FA\u5B9A",colUnfreeze:"\u5217\u306E\u56FA\u5B9A\u3092\u89E3\u9664",colFreezeRight:"\u53F3\u5074\u306E\u5217\u3092\u56FA\u5B9A",colUnfreezeRight:"\u53F3\u5074\u306E\u5217\u306E\u56FA\u5B9A\u3092\u89E3\u9664",colVisibility:"\u5217\u306E\u8868\u793A/\u975E\u8868\u793A\u2026",colChooserTitle:"\u5217\u306E\u8868\u793A/\u975E\u8868\u793A",colChooserApply:"\u9069\u7528",colChooserCancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",colChooserSelectAll:"\u3059\u3079\u3066\u9078\u629E",colInsertLeft:"\u5DE6\u306B\u5217\u3092\u633F\u5165",colInsertRight:"\u53F3\u306B\u5217\u3092\u633F\u5165",colInsertTitle:"\u5217\u3092\u8FFD\u52A0",colInsertPlaceholder:"\u5217\u540D\u3092\u5165\u529B",colInsertConfirm:"\u8FFD\u52A0",colInsertCancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",colDelete:"\u3053\u306E\u5217\u3092\u524A\u9664",colUndelete:"\u524A\u9664\u3092\u5143\u306B\u623B\u3059",rowInsertTop:"\u5148\u982D\u306B\u884C\u3092\u633F\u5165",rowInsertBottom:"\u672B\u5C3E\u306B\u884C\u3092\u633F\u5165",rowInsertAbove:"\u4E0A\u306B\u884C\u3092\u633F\u5165",rowInsertBelow:"\u4E0B\u306B\u884C\u3092\u633F\u5165",rowAddEnd:"\u884C\u3092\u8FFD\u52A0",rowDelete:"\u3053\u306E\u884C\u3092\u524A\u9664",rowDeleteMark:"\u3053\u306E\u884C\u306B\u524A\u9664\u30DE\u30FC\u30AF",rowDeletePermanent:"\u3053\u306E\u884C\u3092\u5B8C\u5168\u306B\u524A\u9664",rowUndelete:"\u524A\u9664\u3092\u5143\u306B\u623B\u3059",editAriaLabel:(r,t)=>`${r} \u3092\u7DE8\u96C6, ${t} \u884C\u76EE`,announceCell:(r,t,e)=>`${r} \u884C\u76EE ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} \u5217\u30D8\u30C3\u30C0\u30FC\u3002Enter: \u30BD\u30FC\u30C8/\u30D5\u30A3\u30EB\u30BF\u30FC\u30E1\u30CB\u30E5\u30FC\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u5217\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowHeaderAnnounce:r=>`${r} \u884C\u76EE\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u884C\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowReorderAnnounce:(r,t)=>`${r} \u884C\u76EE\u3092 ${t} \u884C\u76EE\u306B\u79FB\u52D5\u3057\u307E\u3057\u305F\u3002`,sortAppliedAnnounce:(r,t)=>`${r} \u3092${t==="asc"?"\u6607\u9806":"\u964D\u9806"}\u306B\u4E26\u3079\u66FF\u3048\u307E\u3057\u305F\u3002`,filterAppliedAnnounce:r=>`${r} \u306B\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u9069\u7528\u3055\u308C\u307E\u3057\u305F\u3002`,filterClearedAnnounce:r=>`${r} \u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002`,allFiltersClearedAnnounce:"\u3059\u3079\u3066\u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u3068\u30BD\u30FC\u30C8\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002",rowsSelectedAnnounce:r=>r===0?"\u9078\u629E\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002":`${r} \u884C\u304C\u9078\u629E\u3055\u308C\u307E\u3057\u305F\u3002`,unsavedEditsWarning:"\u4FDD\u5B58\u3055\u308C\u3066\u3044\u306A\u3044\u7DE8\u96C6\u5185\u5BB9\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u5909\u66F4\u3092\u9069\u7528\u3059\u308B\u3068\u7834\u68C4\u3055\u308C\u307E\u3059\u3002\u7D9A\u884C\u3057\u307E\u3059\u304B?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\u5370\u5237",validationRequired:r=>`${r} \u306F\u5FC5\u9808\u9805\u76EE\u3067\u3059\u3002`,validationPattern:r=>`${r} \u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,validationMin:(r,t)=>`${r} \u306F ${t} \u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMax:(r,t)=>`${r} \u306F ${t} \u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMinLength:(r,t)=>`${r} \u306F ${t} \u6587\u5B57\u4EE5\u4E0A\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationMaxLength:(r,t)=>`${r} \u306F ${t} \u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationInvalid:r=>`${r} \u306E\u5024\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,pagerFirst:"\u6700\u521D\u306E\u30DA\u30FC\u30B8",pagerPrev:"\u524D\u306E\u30DA\u30FC\u30B8",pagerNext:"\u6B21\u306E\u30DA\u30FC\u30B8",pagerLast:"\u6700\u5F8C\u306E\u30DA\u30FC\u30B8",pagerPageLabel:(r,t)=>`${t} \u30DA\u30FC\u30B8\u4E2D ${r} \u30DA\u30FC\u30B8\u76EE`,aggSum:"\u5408\u8A08:",aggAvg:"\u5E73\u5747:",aggCount:"\u4EF6\u6570:",aggMin:"\u6700\u5C0F:",aggMax:"\u6700\u5927:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"\u5408\u8A08"};var Qt={loading:"\u52A0\u8F7D\u4E2D\u2026",loadError:"\u26A0 \u6570\u636E\u52A0\u8F7D\u5931\u8D25\u3002",pasteTruncated:r=>`${r} \u4E2A\u503C\u8D85\u51FA\u8303\u56F4\uFF0C\u672A\u88AB\u7C98\u8D34`,copyIncomplete:r=>`${r} \u884C\u5C1A\u672A\u52A0\u8F7D\uFF0C\u672A\u88AB\u590D\u5236`,noData:"\u6682\u65E0\u6570\u636E\u3002",emptyCell:"\u7A7A\u5355\u5143\u683C",ariaGrid:"\u6570\u636E\u8868\u683C",sortAsc:"\u2191 \u5347\u5E8F",sortDesc:"\u2193 \u964D\u5E8F",sortShiftHint:"Shift+\u70B9\u51FB\uFF1A\u6DFB\u52A0\u591A\u91CD\u6392\u5E8F",rowNumberLabel:"\u5E8F\u53F7",filterLabel:"\u641C\u7D22",filterPlaceholder:"\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9\u2026",filterApply:"\u5E94\u7528",filterReset:"\u91CD\u7F6E",filterResetAll:"\u91CD\u7F6E\u6240\u6709\u7B5B\u9009",filterClose:"\u5173\u95ED",filterDialog:r=>`${r} \u7B5B\u9009`,filterColorLabel:"\u6309\u989C\u8272\u7B5B\u9009",filterValuesLabel:"\u6309\u503C\u7B5B\u9009",filterSelectAll:"(\u5168\u9009)",filterTagPlaceholder:"\u641C\u7D22\u503C\u2026",filterTagLocalScope:"\u4EC5\u6765\u81EA\u5DF2\u52A0\u8F7D\u7684\u884C",filterTagNoMatch:"\u6CA1\u6709\u5339\u914D\u7684\u503C",filterTagMinChars:r=>`\u8BF7\u8F93\u5165\u81F3\u5C11 ${r} \u4E2A\u5B57\u7B26`,filterTagAllSelected:"\u5339\u914D\u7684\u503C\u5DF2\u5168\u90E8\u9009\u62E9",filterTagMore:r=>`\u53E6\u6709 ${r} \u4E2A \u2014 \u8BF7\u7F29\u5C0F\u641C\u7D22\u8303\u56F4`,filterTagSelected:r=>`\u5DF2\u9009\u503C (${r})`,filterTagContains:r=>`\u5305\u542B "${r}"`,filterTagRemove:r=>`\u79FB\u9664 ${r}`,colFreeze:"\u51BB\u7ED3\u5217",colUnfreeze:"\u53D6\u6D88\u51BB\u7ED3\u5217",colFreezeRight:"\u51BB\u7ED3\u53F3\u4FA7\u5217",colUnfreezeRight:"\u53D6\u6D88\u51BB\u7ED3\u53F3\u4FA7\u5217",colVisibility:"\u5217\u7684\u663E\u793A/\u9690\u85CF\u2026",colChooserTitle:"\u5217\u7684\u663E\u793A/\u9690\u85CF",colChooserApply:"\u5E94\u7528",colChooserCancel:"\u53D6\u6D88",colChooserSelectAll:"\u5168\u9009",colInsertLeft:"\u5728\u5DE6\u4FA7\u63D2\u5165\u5217",colInsertRight:"\u5728\u53F3\u4FA7\u63D2\u5165\u5217",colInsertTitle:"\u6DFB\u52A0\u5217",colInsertPlaceholder:"\u8BF7\u8F93\u5165\u5217\u540D",colInsertConfirm:"\u6DFB\u52A0",colInsertCancel:"\u53D6\u6D88",colDelete:"\u5220\u9664\u6B64\u5217",colUndelete:"\u64A4\u9500\u5220\u9664",rowInsertTop:"\u5728\u9876\u90E8\u63D2\u5165\u884C",rowInsertBottom:"\u5728\u5E95\u90E8\u63D2\u5165\u884C",rowInsertAbove:"\u5728\u4E0A\u65B9\u63D2\u5165\u884C",rowInsertBelow:"\u5728\u4E0B\u65B9\u63D2\u5165\u884C",rowAddEnd:"\u6DFB\u52A0\u884C",rowDelete:"\u5220\u9664\u6B64\u884C",rowDeleteMark:"\u6807\u8BB0\u6B64\u884C\u4E3A\u5220\u9664",rowDeletePermanent:"\u5F7B\u5E95\u5220\u9664\u6B64\u884C",rowUndelete:"\u64A4\u9500\u5220\u9664",editAriaLabel:(r,t)=>`\u7F16\u8F91 ${r}\uFF0C\u7B2C ${t} \u884C`,announceCell:(r,t,e)=>`\u7B2C ${r} \u884C ${t}\uFF1A${e}`,columnHeaderAnnounce:r=>`${r} \u5217\u6807\u9898\u3002Enter\uFF1A\u6392\u5E8F/\u7B5B\u9009\u83DC\u5355\u3002\u83DC\u5355\u952E\uFF1A\u5217\u9009\u9879\u3002`,rowHeaderAnnounce:r=>`\u7B2C ${r} \u884C\u3002\u83DC\u5355\u952E\uFF1A\u884C\u9009\u9879\u3002`,rowReorderAnnounce:(r,t)=>`\u5DF2\u5C06\u7B2C ${r} \u884C\u79FB\u52A8\u5230\u7B2C ${t} \u884C\u3002`,sortAppliedAnnounce:(r,t)=>`${r} \u5DF2\u6309${t==="asc"?"\u5347\u5E8F":"\u964D\u5E8F"}\u6392\u5E8F\u3002`,filterAppliedAnnounce:r=>`\u5DF2\u5BF9 ${r} \u5E94\u7528\u7B5B\u9009\u3002`,filterClearedAnnounce:r=>`\u5DF2\u6E05\u9664 ${r} \u7684\u7B5B\u9009\u3002`,allFiltersClearedAnnounce:"\u5DF2\u6E05\u9664\u6240\u6709\u7B5B\u9009\u548C\u6392\u5E8F\u3002",rowsSelectedAnnounce:r=>r===0?"\u5DF2\u53D6\u6D88\u9009\u62E9\u3002":`\u5DF2\u9009\u62E9 ${r} \u884C\u3002`,unsavedEditsWarning:"\u60A8\u6709\u5C1A\u672A\u4FDD\u5B58\u7684\u7F16\u8F91\u5185\u5BB9\uFF0C\u6B64\u66F4\u6539\u5C06\u4E22\u5F03\u8FD9\u4E9B\u5185\u5BB9\u3002\u662F\u5426\u7EE7\u7EED\uFF1F",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\u6253\u5370",validationRequired:r=>`${r} \u4E3A\u5FC5\u586B\u9879\u3002`,validationPattern:r=>`${r} \u683C\u5F0F\u4E0D\u6B63\u786E\u3002`,validationMin:(r,t)=>`${r} \u4E0D\u80FD\u5C0F\u4E8E ${t}\u3002`,validationMax:(r,t)=>`${r} \u4E0D\u80FD\u5927\u4E8E ${t}\u3002`,validationMinLength:(r,t)=>`${r} \u81F3\u5C11\u9700\u8981 ${t} \u4E2A\u5B57\u7B26\u3002`,validationMaxLength:(r,t)=>`${r} \u6700\u591A\u5141\u8BB8 ${t} \u4E2A\u5B57\u7B26\u3002`,validationInvalid:r=>`${r} \u7684\u503C\u65E0\u6548\u3002`,pagerFirst:"\u9996\u9875",pagerPrev:"\u4E0A\u4E00\u9875",pagerNext:"\u4E0B\u4E00\u9875",pagerLast:"\u672B\u9875",pagerPageLabel:(r,t)=>`\u7B2C ${r} / ${t} \u9875`,aggSum:"\u603B\u8BA1\uFF1A",aggAvg:"\u5E73\u5747\u503C\uFF1A",aggCount:"\u8BA1\u6570\uFF1A",aggMin:"\u6700\u5C0F\u503C\uFF1A",aggMax:"\u6700\u5927\u503C\uFF1A",groupLabel:(r,t,e)=>`${r}\uFF1A${t}\uFF08${e}\uFF09`,groupFooterLabel:"\u5408\u8BA1"};var Re={loading:"Loading\u2026",loadError:"\u26A0 Failed to load data.",pasteTruncated:r=>`${r} value(s) did not fit and were not pasted`,copyIncomplete:r=>`${r} row(s) hadn't loaded yet and were not copied`,noData:"No data to display.",emptyCell:"Empty cell",ariaGrid:"Data grid",sortAsc:"\u2191 Ascending",sortDesc:"\u2193 Descending",sortShiftHint:"Shift+click: add to multi-sort",rowNumberLabel:"No.",filterLabel:"Search",filterPlaceholder:"Enter search term\u2026",filterApply:"Apply",filterReset:"Reset",filterResetAll:"Reset all filters",filterClose:"Close",filterDialog:r=>`${r} Filter`,filterColorLabel:"Filter by color",filterValuesLabel:"Filter by value",filterSelectAll:"(Select all)",filterTagPlaceholder:"Search values\u2026",filterTagLocalScope:"From loaded rows only",filterTagNoMatch:"No matching values",filterTagMinChars:r=>`Type at least ${r} characters`,filterTagAllSelected:"All matches already selected",filterTagMore:r=>`+${r} more \u2014 narrow the search`,filterTagSelected:r=>`Selected (${r})`,filterTagContains:r=>`Contains "${r}"`,filterTagRemove:r=>`Remove ${r}`,colFreeze:"Freeze column",colUnfreeze:"Unfreeze column",colFreezeRight:"Freeze columns to the right",colUnfreezeRight:"Unfreeze columns to the right",colVisibility:"Column visibility\u2026",colChooserTitle:"Column Visibility",colChooserApply:"Apply",colChooserCancel:"Cancel",colChooserSelectAll:"Select all",colInsertLeft:"Insert column left",colInsertRight:"Insert column right",colInsertTitle:"Add column",colInsertPlaceholder:"Column name",colInsertConfirm:"Add",colInsertCancel:"Cancel",colDelete:"Delete column",colUndelete:"Undo delete",rowInsertTop:"Insert row at top",rowInsertBottom:"Insert row at bottom",rowInsertAbove:"Insert row above",rowInsertBelow:"Insert row below",rowAddEnd:"Add row",rowDelete:"Delete row",rowDeleteMark:"Mark row for deletion",rowDeletePermanent:"Delete row permanently",rowUndelete:"Undo delete",editAriaLabel:(r,t)=>`Edit ${r}, row ${t}`,announceCell:(r,t,e)=>`Row ${r}, ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} column header. Enter: sort/filter menu. Context menu key: column options.`,rowHeaderAnnounce:r=>`Row ${r}. Context menu key: row options.`,rowReorderAnnounce:(r,t)=>`Moved row ${r} to position ${t}.`,sortAppliedAnnounce:(r,t)=>`${r} sorted ${t==="asc"?"ascending":"descending"}.`,filterAppliedAnnounce:r=>`Filter applied to ${r}.`,filterClearedAnnounce:r=>`Filter cleared for ${r}.`,allFiltersClearedAnnounce:"All filters and sorts cleared.",rowsSelectedAnnounce:r=>r===0?"Selection cleared.":r===1?"1 row selected.":`${r} rows selected.`,unsavedEditsWarning:"You have unsaved edits. This change will discard them. Continue?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"Print",validationRequired:r=>`${r} is required.`,validationPattern:r=>`${r} format is invalid.`,validationMin:(r,t)=>`${r} must be at least ${t}.`,validationMax:(r,t)=>`${r} must be at most ${t}.`,validationMinLength:(r,t)=>`${r} must be at least ${t} characters.`,validationMaxLength:(r,t)=>`${r} must be at most ${t} characters.`,validationInvalid:r=>`${r} is invalid.`,pagerFirst:"First page",pagerPrev:"Previous page",pagerNext:"Next page",pagerLast:"Last page",pagerPageLabel:(r,t)=>`Page ${r} of ${t}`,aggSum:"Sum:",aggAvg:"Avg:",aggCount:"Count:",aggMin:"Min:",aggMax:"Max:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"Total"};var Hs={en:Re,ko:Jt,ja:Zt,zh:Qt},Os=r=>String(r??"").toLowerCase().split("-")[0];function es(r){return Hs[Os(r)]??Re}function ss(r){return r||"en-US"}var zs={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]},It=5,Vt=8,is="touch-action:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;",os=30,ns=16,Is=500,Ws=40,Ns=120,js=220,Ys=110,Gs=90,rs=1200,Ae="position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;",ls="position:absolute;opacity:0;pointer-events:none;border:0;margin:0;padding:0;background:transparent;outline:none;",Ks={width:1200,height:700,rowHeight:28,colWidth:130,headerHeight:30,columnLetterHeader:!1,scrollbarSize:12,chunkSize:300,maxCachedChunks:50,editableCols:[],deleteMode:"mark",frozenCols:0,frozenColsRight:0,rowReorder:!1,responsive:!1,rowSelection:"none",showRowNumbers:!0};function Vs(r,t,e){let s=null,i=null;return{fetchMeta:function(o){let n=Promise.resolve(r(0,t,o));return s=n,i=o,n.then(function(l){let a=l.columns??e?.map(function(c){return c.field});if(!a)throw new Error("[JHGrid] opts.fetchPage: resolve { columns } or pass opts.columnDefs");return{totalRows:l.totalRows,columns:a}})},fetchData:function(o,n,l){let c=o===0&&n===t&&s&&i===l?s:Promise.resolve(r(o,n,l));return s=null,i=null,c.then(function(h){return{rows:h.rows}})}}}var te=class r{static _plugins=[];static use(t){r._plugins.includes(t)||(r._plugins.push(t),t.install?.(r))}static _plugin(t){return r._plugins.find(e=>e[t])?.[t]??null}_clearPlugins(t){for(let e of r._plugins)e.resetScope?.includes(t)&&e.clear?.(this)}_opts;_canvas;_container;_wrapper;_loadingEl;_liveRegion;_a11yHead;_a11yBody;_a11yActiveRow;_a11yActiveCell;_dm;_renderer;_scrollTop=0;_scrollLeft=0;_ticking=!1;_drag=null;_totalRows=0;_columns=[];_columnLabels=[];_columnAligns=[];_columnHeaderAligns=[];_colDefMap=new Map;_edits=new Map;_editedRows=new Set;_validator;_undoMgr=new ne(100);_editTxn=null;_sel=null;_selAnchor=null;_selDragging=!1;_selDragStart=null;_dragScrollDir={dx:0,dy:0};_dragScrollPos=null;_dragScrollTimer=null;_lastCopyMissingRows=0;_isLocalData=!1;_pastedImageUrls=new Set;_headerFocusCol=null;_rowFocus=null;_colDrag=null;_colResize=null;_colContextMenu=null;_rowContextMenu=null;_cellContextMenu=null;_columnWidths=[];_columnRenderers=[];_headerCheckboxState=new Map;_editing=null;_editableCols=null;_filters=new Map;_trivialSetFilters=new Set;_searchModeCols=new Set;_sorts=[];_filterPanel=null;_quickFilter="";_rowDrag=null;_rowOrderData=null;_rowOrderGen=0;_rowOrderScanPending=!1;_rowResize=null;_uid=Math.random().toString(36).slice(2,9);_destroyed=!1;_booting=!1;_bootPromise=null;_readyResolve;_readyPromise=new Promise(t=>{this._readyResolve=t});_announceRaf=0;_schedRaf=0;_scrolling=!1;_scrollEndTimer=null;_skeletonRaf=0;_hcMq=null;_hcMqHandler=null;_dprMq=null;_dprMqHandler=null;_i18n={};_emptyEl=null;_resizeObserver=null;_ev={};_touch=null;_lastTap={time:0,row:-1,col:-1};_rowTap=null;_longPressTimer=null;_columnOriginalOrder=[];_hiddenColumns=new Map;_columnWidthMap=new Map;_colChooser=null;_newColDialog=null;_fillDrag=null;_fillPreview=null;_localRows=[];_pendingLocalState=null;_deletedRows=new Set;_serverTotal=0;_rowPlan=new ae;_localColumns=new Map;_deletedColumns=new Set;_newColSeq=1;_cellTooltip=null;_tooltipTimer=null;_errorBannerEl=null;_errorBannerTimer=null;_pagination=null;_page=0;_pagerBar=null;constructor(t){if(typeof window>"u")throw new Error("[JHGrid] JHGrid requires a browser environment. For SSR frameworks (Next.js, Nuxt, SvelteKit), import and instantiate only on the client side (e.g. inside useEffect / onMounted).");if(!t?.container)throw new Error("[JHGrid] opts.container is required");if(this._opts={...Ks,...t,theme:{...qt,locale:ss(t.locale),...t.theme??{}}},t.responsive){let s=["width","height"].filter(i=>t[i]!=null);s.length&&console.warn(`[JHGrid] opts.${s.join(" and opts.")} ${s.length>1?"are":"is"} ignored while opts.responsive is true \u2014 the container element's CSS size determines the grid size instead. Set width/height (or max-width) via CSS on the container element, not via opts.${s[0]}.`)}if(!this._opts.headerRows?.length){let s=De(t.columnDefs);s&&(this._opts.headerRows=s)}if(this._i18n={...es(t.locale),...t.i18n??{}},t.pagination?.enabled){let s=typeof t.pagination.pageSize=="number"&&t.pagination.pageSize>0?Math.floor(t.pagination.pageSize):50;this._pagination={enabled:!0,pageSize:s},this._opts.chunkSize=s}if(t.fetchPage&&!t.fetchMeta&&!t.fetchData){let s=Vs(t.fetchPage,this._opts.chunkSize,t.columnDefs);this._opts.fetchMeta=s.fetchMeta,this._opts.fetchData=s.fetchData}if(t.data&&!t.fetchMeta&&!t.fetchData&&!t.fetchPage){let s=Xe(t.data,t.columnDefs);this._opts.fetchMeta=s.fetchMeta,this._opts.fetchData=s.fetchData,this._isLocalData=!0}if(!this._opts.fetchMeta)throw new Error("[JHGrid] opts.fetchMeta is required (or provide opts.data / opts.fetchPage instead)");if(!this._opts.fetchData)throw new Error("[JHGrid] opts.fetchData is required (or provide opts.data / opts.fetchPage instead)");this._rowLayout=new ce(this._opts.rowHeight),this._editableCols=t.editableCols==="*"?null:new Set(t.editableCols??[]),(t.columnDefs??[]).forEach(({field:s,label:i,align:o,headerAlign:n,width:l,renderer:a,editor:c,editorOptions:h,editable:d,type:u,format:f,options:_,validation:p,button:w,aggregate:m,treeColumn:x,group:S,headerCheckbox:v})=>this._colDefMap.set(s,{label:i,align:o,headerAlign:n,width:l,renderer:a,editor:c,editorOptions:h,editable:d,type:u,format:f,options:_,validation:p,button:w,aggregate:m,treeColumn:x,group:S,headerCheckbox:v})),t.hiddenColumns?.length&&t.hiddenColumns.forEach(s=>this._hiddenColumns.set(s,null)),this._validator=new re({getColumnDef:s=>this._colDefMap.get(s),getColumnLabel:s=>this._columnLabels[this._columns.indexOf(s)]??s,getI18n:()=>this._i18n,getRowData:s=>this._getRow(s),onError:(s,i,o)=>this._opts.onValidationError?.(s,i,o)}),this._mount(),this._dm=new Yt({fetchData:(s,i)=>this._opts.fetchData(s,i,null),chunkSize:this._opts.chunkSize,maxChunks:this._opts.maxCachedChunks}),this._dm.onChunkLoaded=()=>{this._scrolling||this._schedDraw()},this._dm.onChunkError=s=>{this._opts.onChunkError?.(s),this._showErrorBanner(this._i18n.loadError)},this._imageLoadListener=()=>{this._scrolling||this._schedDraw()},Fe(this._imageLoadListener),this._renderer=new Gt(this._canvas,this._opts),this._remoteSelections=[],this._hoverRow=null,this._hoverTarget=0,this._hoverFade=new Nt({onFrame:()=>this._schedDraw()});let e=ts();this._reducedMotion=e,this._hoverFadeMs=e?0:this._opts.hoverFadeMs??Ys,this._selKey=null,this._selLast=null,this._selPrev=null,this._selMove=new Nt({value:1,onFrame:()=>this._schedDraw()}),this._selMoveMs=e?0:this._opts.selectionMoveMs??Gs,this._scrollFrom={y:0,x:0},this._scrollAim={y:0,x:0},this._scrollWrote={y:0,x:0},this._scrollEase=new Nt({value:1,onFrame:()=>this._onScrollFrame()}),this._scrollEaseMs=e?0:this._opts.scrollEaseMs??Ns,this._colSlide=null,this._colSlideTween=new Nt({value:1,onFrame:()=>this._schedDraw()}),this._colSlideMs=e?0:this._opts.columnSlideMs??js,this._bind(),this._initResizeObserver(),this._initHighContrast(),this._watchDpr(),this._boot()}_mount(){let{container:t,width:e,height:s}=this._opts,i=typeof t=="string"?document.querySelector(t):t;if(!i)throw new Error(`[JHGrid] container "${t}" not found`);this._container=i,Oe(i.ownerDocument??document),this._wrapper=document.createElement("div"),this._wrapper.className=B.root,Object.assign(this._wrapper.style,{position:"relative",overflow:"hidden",width:e+"px",height:s+"px",outline:"none"}),this._wrapper.setAttribute("role","grid"),this._wrapper.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),this._wrapper.setAttribute("aria-rowcount","0"),this._wrapper.setAttribute("aria-colcount","0"),this._wrapper.setAttribute("aria-busy","true");let o=r._plugin("rowSelection")?.modeFor(this)??"none";o!=="none"&&this._wrapper.setAttribute("aria-multiselectable",String(o==="multi")),this._wrapper.tabIndex=-1,i.appendChild(this._wrapper),this._kbProxy=document.createElement("input"),this._kbProxy.type="text",this._kbProxy.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),this._kbProxy.tabIndex=0,this._kbProxy.style.cssText=ls,this._kbProxy.remove=()=>this._resetKbProxy(),this._wrapper.appendChild(this._kbProxy);let n=window.devicePixelRatio||1;this._canvas=document.createElement("canvas"),this._canvas.width=Math.round(e*n),this._canvas.height=Math.round(s*n),this._canvas.style.cssText=`display:block;width:${e}px;height:${s}px;outline:none;${is}`,this._canvas.setAttribute("aria-hidden","true"),this._canvas.tabIndex=-1,this._canvas.getContext("2d").scale(n,n),this._wrapper.appendChild(this._canvas),this._loadingEl=Object.assign(document.createElement("div"),{textContent:this._i18n.loading}),this._loadingEl.className=B.loading,Object.assign(this._loadingEl.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.9)",fontSize:"14px",color:y(this._opts.theme,"overlayMutedText"),fontFamily:y(this._opts.theme,"fontFamily")}),this._wrapper.appendChild(this._loadingEl),this._liveRegion=document.createElement("div"),this._liveRegion.setAttribute("aria-live","polite"),this._liveRegion.setAttribute("aria-atomic","true"),this._liveRegion.style.cssText=Ae,this._wrapper.appendChild(this._liveRegion),this._a11yHead=document.createElement("div"),this._a11yHead.setAttribute("role","rowgroup"),this._a11yHead.style.cssText=Ae,this._wrapper.appendChild(this._a11yHead),this._a11yBody=document.createElement("div"),this._a11yBody.setAttribute("role","rowgroup"),this._a11yBody.style.cssText=Ae,this._a11yActiveRow=document.createElement("div"),this._a11yActiveRow.setAttribute("role","row"),this._a11yActiveRow.setAttribute("aria-rowindex","2"),this._a11yActiveCell=document.createElement("div"),this._a11yActiveCell.setAttribute("role","gridcell"),this._a11yActiveCell.setAttribute("aria-colindex","1"),this._a11yActiveCell.setAttribute("aria-selected","false"),this._a11yActiveCell.id=`jhgrid-${this._uid}-cell`,this._a11yActiveRow.appendChild(this._a11yActiveCell),this._a11yBody.appendChild(this._a11yActiveRow),this._wrapper.appendChild(this._a11yBody);for(let l of r._plugins)l.onMount?.(this);this._emptyEl=document.createElement("div"),this._emptyEl.className=B.empty,Object.assign(this._emptyEl.style,{position:"absolute",inset:"0",display:"none",alignItems:"center",justifyContent:"center",fontSize:"14px",pointerEvents:"none",color:y(this._opts.theme,"overlayHintText"),fontFamily:y(this._opts.theme,"fontFamily")}),this._emptyEl.textContent=this._i18n.noData,this._wrapper.appendChild(this._emptyEl),this._cellTooltip=document.createElement("div"),this._cellTooltip.className=B.tooltip,this._cellTooltip.style.cssText=["position:absolute","background:#212121","color:#FFFFFF","border-radius:4px","padding:5px 9px","font-size:12px","pointer-events:none","z-index:160","max-width:320px","white-space:pre-wrap","word-break:break-all","display:none","box-shadow:0 4px 12px rgba(0,0,0,0.22)",`font-family:${y(this._opts.theme,"fontFamily")}`].join(";"),this._wrapper.appendChild(this._cellTooltip),this._pagination&&this._buildPagerBar()}_buildPagerBar(){let t=this._opts.theme,e=(...h)=>h.join(";"),s=document.createElement("nav");s.setAttribute("aria-label","Pagination"),s.className=B.pager,s.style.cssText=e("display:flex","align-items:center","justify-content:center","gap:4px","padding:8px 12px",`border-top:1px solid ${y(t,"pagerBorder")}`,`background:${y(t,"pagerBg")}`,`font-size:${t.fontSize}px`,`color:${y(t,"pagerText")}`,`font-family:${y(t,"fontFamily")}`,`width:${this._opts.width}px`,"box-sizing:border-box","user-select:none");let i=(h,d,u)=>{let f=document.createElement("button");return f.type="button",f.textContent=h,f.setAttribute("aria-label",d),f.className=B.pagerBtn,f.style.cssText=e("padding:4px 10px",`border:1px solid ${y(t,"pagerButtonBorder")}`,"border-radius:4px",`background:${y(t,"pagerButtonBg")}`,"cursor:pointer",`font-size:${t.fontSize}px`,`color:${y(t,"pagerText")}`,"min-width:28px"),f.addEventListener("click",u),f},o=i("\xAB",this._i18n.pagerFirst,()=>this.goToPage(0)),n=i("\u2039",this._i18n.pagerPrev,()=>this.prevPage()),l=document.createElement("span");l.style.cssText="display:flex;align-items:center;gap:4px;margin:0 4px;";let a=i("\u203A",this._i18n.pagerNext,()=>this.nextPage()),c=i("\xBB",this._i18n.pagerLast,()=>this.goToPage(this._pageCount()-1));s.append(o,n,l,a,c),this._container.appendChild(s),this._pagerBar={el:s,firstBtn:o,prevBtn:n,numbers:l,nextBtn:a,lastBtn:c},this._updatePagerBar()}_pagerPageWindow(){let t=this._pageCount(),e=this._page,s=Math.max(0,e-2),i=Math.min(t-1,e+2),o=Math.min(4,t-1);for(;i-s<o;)if(s>0)s--;else if(i<t-1)i++;else break;return Array.from({length:i-s+1},(n,l)=>s+l)}_updatePagerBar(){if(!this._pagerBar)return;let{firstBtn:t,prevBtn:e,numbers:s,nextBtn:i,lastBtn:o}=this._pagerBar,n=this._pageCount(),l=this._page,a=this._opts.theme,c=(...h)=>h.join(";");t.disabled=e.disabled=l<=0,o.disabled=i.disabled=l>=n-1,this._pagerBar.el.setAttribute("aria-label",this._i18n.pagerPageLabel(l+1,n)),s.replaceChildren(),this._pagerPageWindow().forEach(h=>{let d=h===l,u=document.createElement("button");u.type="button",u.textContent=String(h+1),u.className=B.pagerBtn,u.style.cssText=c("padding:4px 9px","border-radius:4px","cursor:pointer",`font-size:${a.fontSize}px`,`border:1px solid ${d?y(a,"selectionColor"):y(a,"pagerButtonBorder")}`,`background:${d?y(a,"selectionColor"):y(a,"pagerButtonBg")}`,`color:${d?y(a,"overlayAccentText"):y(a,"pagerText")}`,`font-weight:${d?"600":"400"}`),d&&u.setAttribute("aria-current","page"),u.addEventListener("click",()=>this.goToPage(h)),s.appendChild(u)})}_showErrorBanner(t,e=4e3){this._errorBannerEl||(this._errorBannerEl=document.createElement("div"),this._errorBannerEl.setAttribute("role","alert"),this._errorBannerEl.setAttribute("aria-live","assertive"),this._errorBannerEl.setAttribute("aria-atomic","true"),Object.assign(this._errorBannerEl.style,{position:"absolute",top:"4px",left:"50%",transform:"translateX(-50%)",background:"#fee2e2",color:"#991b1b",border:"1px solid #fca5a5",borderRadius:"4px",padding:"6px 14px",fontSize:"12px",fontFamily:qt.fontFamily,zIndex:"10",whiteSpace:"nowrap",pointerEvents:"none"}),this._wrapper.appendChild(this._errorBannerEl)),this._errorBannerEl.textContent=t,this._errorBannerEl.style.display="block",clearTimeout(this._errorBannerTimer),this._errorBannerTimer=setTimeout(()=>{this._errorBannerEl&&(this._errorBannerEl.style.display="none")},e)}_initResizeObserver(){if(!this._opts.responsive||!window.ResizeObserver)return;let t=this._container.getBoundingClientRect();t.width>0&&t.height>0&&this._setSize(Math.floor(t.width),Math.floor(t.height)),this._resizeObserver=new ResizeObserver(e=>{let{width:s,height:i}=e[0].contentRect;s>0&&i>0&&this._setSize(Math.floor(s),Math.floor(i))}),this._resizeObserver.observe(this._container)}_setSize(t,e){if(this._destroyed)return;let s=this._pagerBar?this._pagerBar.el.offsetHeight:0,i=Math.max(0,e-s);this._opts.width=t,this._opts.height=i,this._wrapper.style.width=t+"px",this._wrapper.style.height=i+"px",this._canvas.style.cssText=`display:block;width:${t}px;height:${i}px;outline:none;${is}`;let o=window.devicePixelRatio||1;this._canvas.width=Math.round(t*o),this._canvas.height=Math.round(i*o),this._canvas.getContext("2d").setTransform(o,0,0,o,0,0),this._pagerBar&&(this._pagerBar.el.style.width=t+"px"),this._clamp(this._geo()),this._draw()}_announce(t){cancelAnimationFrame(this._announceRaf),this._liveRegion.textContent="",this._announceRaf=requestAnimationFrame(()=>{this._liveRegion.textContent=t})}_updateA11yHeader(){this._a11yHead.replaceChildren(),this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._wrapper.setAttribute("aria-colcount",String(this._columns.length));let t=document.createElement("div");t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1"),this._columnLabels.forEach((e,s)=>{let i=document.createElement("div");i.setAttribute("role","columnheader"),i.setAttribute("aria-colindex",String(s+1)),i.id=`jhgrid-${this._uid}-header-${s}`;let o=this._columns[s],n=this._sorts.find(l=>l.field===o);n&&i.setAttribute("aria-sort",n.dir==="asc"?"ascending":"descending"),i.textContent=e,t.appendChild(i)}),this._a11yHead.appendChild(t),this._headerFocusCol!==null&&(this._a11yActiveCell.setAttribute("aria-selected","false"),this._wrapper.setAttribute("aria-activedescendant",`jhgrid-${this._uid}-header-${this._headerFocusCol}`))}_updateA11yCell(){if(this._headerFocusCol!==null||this._rowFocus!==null)return;if(!this._sel){this._wrapper.removeAttribute("aria-activedescendant"),this._a11yActiveRow.setAttribute("aria-selected","false"),this._a11yActiveCell.setAttribute("aria-selected","false"),this._a11yActiveCell.removeAttribute("aria-invalid"),this._a11yActiveCell.textContent="";return}let t=this._sel.type==="single"?this._sel.row:this._sel.r1,e=this._sel.type==="single"?this._sel.col:this._sel.c1,s=this._columns[e],i=this._columnLabels[e]??s??"",o=this._cellVal(t,e),n=this._validator.map.get(`${t}_${s}`);this._a11yActiveRow.setAttribute("aria-rowindex",String(t+2)),this._a11yActiveRow.setAttribute("aria-selected",String(!!r._plugin("rowSelection")?.has(this,t))),this._a11yActiveCell.setAttribute("aria-colindex",String(e+1)),this._a11yActiveCell.setAttribute("aria-selected","true"),n?(this._a11yActiveCell.setAttribute("aria-invalid","true"),this._a11yActiveCell.setAttribute("aria-label",`${i}: ${o||this._i18n.emptyCell}. ${n}`)):(this._a11yActiveCell.removeAttribute("aria-invalid"),this._a11yActiveCell.setAttribute("aria-label",`${i}: ${o||this._i18n.emptyCell}`)),this._a11yActiveCell.textContent=o,this._wrapper.setAttribute("aria-activedescendant",`jhgrid-${this._uid}-cell`)}_enterHeaderFocus(t){this._headerFocusCol=t,this._updateA11yHeader();let e=this._sel?.type==="single"?this._sel.row:this._sel?.r1??0;this._ensureVisible(e,t),this._announce(this._i18n.columnHeaderAnnounce(this._columnLabels[t]??this._columns[t])),this._draw()}_exitHeaderFocus(){let t=this._headerFocusCol;this._headerFocusCol=null,this._updateA11yHeader();let e=this._sel?.type==="single"?this._sel.row:this._sel?.r1??0;this._setSel({type:"single",row:e,col:t}),this._selAnchor=null,this._updateA11yCell(),this._announce(this._i18n.announceCell(e+1,this._columnLabels[t]??this._columns[t],this._cellVal(e,t)||this._i18n.emptyCell)),this._draw()}_handleHeaderFocusKey(t){let e=this._headerFocusCol;if(t.key==="ArrowLeft"){t.preventDefault(),e>0&&this._enterHeaderFocus(e-1);return}if(t.key==="ArrowRight"){t.preventDefault(),e<this._columns.length-1&&this._enterHeaderFocus(e+1);return}if(t.key==="ArrowDown"||t.key==="Escape"){t.preventDefault(),this._exitHeaderFocus();return}if(t.key==="Enter"||t.key==="F2"||t.key===" "){t.preventDefault(),this._openFilterPanel(e);return}if(t.key==="ContextMenu"||t.shiftKey&&t.key==="F10"){t.preventDefault();let s=this._geo();this._openColContextMenu(e,this._colLeft(e,s),s.headerH)}}_enterRowFocus(t){this._rowFocus=t,this._ensureVisible(t,0),this._announce(this._i18n.rowHeaderAnnounce(t+1)),this._draw()}_exitRowFocus(){let t=this._rowFocus;this._rowFocus=null,this._setSel({type:"single",row:t,col:0}),this._selAnchor=null,this._updateA11yCell(),this._announce(this._i18n.announceCell(t+1,this._columnLabels[0]??this._columns[0],this._cellVal(t,0)||this._i18n.emptyCell)),this._draw()}_handleRowFocusKey(t){let e=this._rowFocus;if(t.key==="ArrowUp"){t.preventDefault(),e>0&&this._enterRowFocus(e-1);return}if(t.key==="ArrowDown"){t.preventDefault(),e<this._totalRows-1&&this._enterRowFocus(e+1);return}if(t.key==="ArrowRight"||t.key==="Escape"){t.preventDefault(),this._exitRowFocus();return}if((t.key==="Enter"||t.key===" ")&&(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"){t.preventDefault(),this._updateRowSel(e,t.ctrlKey||t.metaKey,t.shiftKey),this._draw();return}if(t.key==="ContextMenu"||t.shiftKey&&t.key==="F10"){t.preventDefault();let s=this._geo();this._closeFilterPanel(),this._closeColContextMenu(),this._closeCellContextMenu(),this._openRowContextMenu(e,0,this._rowLayout.yOf(e)-this._scrollTop+s.headerH)}}_focusDefaultCell(){this._setSel({type:"single",row:0,col:0}),this._selAnchor=null,this._ensureVisible(0,0),this._updateA11yCell(),this._announce(this._i18n.announceCell(1,this._columnLabels[0]??this._columns[0],this._cellVal(0,0)||this._i18n.emptyCell)),this._draw()}_watchDpr(){if(!window.matchMedia)return;this._dprMq?.removeEventListener("change",this._dprMqHandler);let t=window.devicePixelRatio||1;this._dprMq=window.matchMedia(`(resolution: ${t}dppx)`),this._dprMqHandler=()=>{this._resizeCanvas(),this._watchDpr()},this._dprMq.addEventListener("change",this._dprMqHandler)}_resizeCanvas(){this._setSize(this._opts.width,this._opts.height)}_initHighContrast(){if(!window.matchMedia)return;this._hcMq=window.matchMedia("(forced-colors: active)");let t={...this._opts.theme};this._hcMqHandler=e=>{e.matches?Object.assign(this._opts.theme,{headerBg:"ButtonFace",headerText:"ButtonText",headerBorder:"ButtonBorder",rowEven:"Canvas",rowOdd:"Canvas",cellBorder:"ButtonBorder",cellText:"CanvasText",loadingText:"GrayText",selectionColor:"Highlight",selectionFill:"rgba(0,0,0,0)",scrollbarBg:"Canvas",scrollbarThumb:"ButtonText",frozenBorder:"ButtonBorder",dragIndicatorFill:"ButtonFace",dragIndicatorLine:"Highlight",deletedRowFill:"ButtonFace",deletedRowStrike:"GrayText",invalidCellBorder:"Mark"}):Object.assign(this._opts.theme,t),this._draw()},this._hcMq.addEventListener("change",this._hcMqHandler),this._hcMqHandler(this._hcMq)}_pageBounds(){if(!this._pagination)return{start:0,rows:this._totalRows};let t=this._page*this._pagination.pageSize,e=Math.max(0,Math.min(this._pagination.pageSize,this._totalRows-t));return{start:t,rows:e}}_pageCount(){return this._pagination?Math.max(1,Math.ceil(this._totalRows/this._pagination.pageSize)):1}_switchToPage(t){if(!this._pagination||this._destroyed)return;let e=this._pageCount(),s=Math.max(0,Math.min(e-1,Math.trunc(t))),i=s!==this._page;this._editing&&this._commitEdit(),this._page=s,this._sel=null,this._selAnchor=null,this._scrollTop=this._rowLayout.yOf(s*this._pagination.pageSize),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._updatePagerBar(),i&&(this._opts.onPageChange?.(this._page,e),this._announce(this._i18n.pagerPageLabel(this._page+1,e))),this._draw()}get _headerH(){return this._opts.headerHeight*((this._opts.headerRows?.length??0)+1+(this._opts.columnLetterHeader?1:0))}_geo(){let{colWidth:t,scrollbarSize:e,width:s,height:i}=this._opts,o=this._headerH,n=Math.max(0,Math.min(this._opts.frozenCols??0,this._columns.length)),l=this._columns.length,a=this._opts.showRowNumbers?this._opts.rowNumberWidth??50:0,c=new Array(l+1);c[0]=a;for(let T=0;T<l;T++)c[T+1]=c[T]+(this._columnWidths[T]??t);let h=c[n],d=Math.min(t,s);for(;n>0&&h>s-d;)n--,h=c[n];let u=Math.max(0,Math.min(this._opts.frozenColsRight??0,l-n)),f=c[l]-c[l-u];for(;u>0&&h+f>s-d;)u--,f=c[l]-c[l-u];let _=c[l-u]-h,p=r._plugins.reduce((T,F)=>T+(F.footerBandHeight?.(this)??0),0),w=i-o-p,m=Math.max(0,s-h-f),{start:x,rows:S}=this._pageBounds(),v=this._rowLayout.yOf(x),b=this._rowLayout.yOf(x+S)-v,C=b>w,H=_>m;C&&!H&&(H=_>Math.max(0,m-e)),H&&!C&&(C=b>w-e);let D=C?e:0,A=H?e:0,j=w-A,O=Math.max(0,m-D),V=s-D-f,z=v,W=z+Math.max(0,b-j),E=Math.max(0,_-O),L=j,M=b>0?Math.max(24,L*(j/b)):L,Q=W-z,R=o+(Q>0?(this._scrollTop-z)/Q*(L-M):0),I=O,$=_>0?Math.max(24,I*(O/_)):I,k=h+(E>0?this._scrollLeft/E*(I-$):0);return{SB:e,vSB:D,hSB:A,vpH:j,vpW:O,frozenCount:n,frozenWidth:h,frozenRightCount:u,frozenRightWidth:f,rightX:V,minScrollY:z,maxScrollY:W,maxScrollX:E,colPositions:c,headerH:o,footerH:p,rowNumW:a,maxRow:x+S-1,v:{x:s-D,y:o,w:C?e:0,h:C?L:0,thumbY:R,thumbH:M},h:{x:h,y:i-A,w:H?I:0,h:H?e:0,thumbX:k,thumbW:$}}}_colAtX(t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o,rightX:n,colPositions:l,rowNumW:a}=e,c=this._columns.length;if(c===0||t<a)return null;if(t<i){for(let u=0;u<s;u++)if(t<l[u+1])return u;return null}if(o>0&&t>=n){let u=c-o,f=t-n+l[u];for(let _=u;_<c;_++)if(f<l[_+1])return _;return null}let h=c-o,d=t-i+this._scrollLeft+l[s];for(let u=s;u<h;u++)if(d<l[u+1])return u;return null}_hitCell(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:l,vSB:a}=s;if(e<n||e>o-l||t<0||t>i-a)return null;let c=this._rowLayout.rowAt(e-n+this._scrollTop,this._totalRows-1);if(c<0)return null;let h=this._colAtX(t,s);return h===null?null:{row:c,col:h}}_hitCellClamped(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:l,vSB:a,rowNumW:c}=s;if(this._totalRows===0||this._columns.length===0)return null;let h=Math.max(n,Math.min(o-l-1,e)),d=Math.max(c,Math.min(i-a-1,t)),u=this._rowLayout.rowAt(h-n+this._scrollTop,this._totalRows-1);if(u<0)return null;let f=this._colAtX(d,s);return f===null?null:{row:u,col:f}}_hitHeader(t,e=this._geo()){let{width:s}=this._opts;return t<0||t>s-e.vSB||t<e.rowNumW?null:this._colAtX(t,e)}_hitRowNumber(t,e,s=this._geo()){let{height:i}=this._opts;if(s.rowNumW===0||t<0||t>=s.rowNumW||e<s.headerH||e>=i-s.hSB)return null;let o=this._rowLayout.rowAt(e-s.headerH+this._scrollTop,this._totalRows-1);return o<0?null:o}_hitRowBoundary(t,e=this._geo(),s=It){let{height:i}=this._opts;if(t<e.headerH||t>=i-e.hSB)return null;let o=t-e.headerH+this._scrollTop,n=this._rowLayout.rowAt(o,this._totalRows-1);if(n<0)return null;let l=this._rowLayout.yOf(n+1)-this._scrollTop+e.headerH;if(Math.abs(t-l)<=s)return n;if(n>0){let a=this._rowLayout.yOf(n)-this._scrollTop+e.headerH;if(Math.abs(t-a)<=s)return n-1}return null}_hitScrollbar(t,e,s){let{v:i,h:o}=s;if(t>=i.x){if(e>=i.thumbY&&e<=i.thumbY+i.thumbH)this._drag={axis:"v",startMouse:e,startScroll:this._scrollTop};else if(e>=i.y&&e<=i.y+i.h){let n=Math.max(0,Math.min(1,(e-i.y-i.thumbH/2)/(i.h-i.thumbH)));this._scrollTop=s.minScrollY+n*(s.maxScrollY-s.minScrollY),this._clamp(s),this._draw()}return!0}if(e>=o.y){if(t>=o.thumbX&&t<=o.thumbX+o.thumbW)this._drag={axis:"h",startMouse:t,startScroll:this._scrollLeft};else if(t>=o.x&&t<=o.x+o.w){let n=Math.max(0,Math.min(1,(t-o.x-o.thumbW/2)/(o.w-o.thumbW)));this._scrollLeft=n*s.maxScrollX,this._clamp(s),this._draw()}return!0}return!1}_updateScrollbarDrag(t,e){let s=this._geo(),{v:i,h:o}=s;if(this._drag.axis==="v"){let n=(e-this._drag.startMouse)/(i.h-i.thumbH);this._scrollTop=this._drag.startScroll+n*(s.maxScrollY-s.minScrollY)}else{let n=(t-this._drag.startMouse)/(o.w-o.thumbW);this._scrollLeft=this._drag.startScroll+n*s.maxScrollX}this._clamp(s),this._scrolling=!0,this._dm.setHold(!0),clearTimeout(this._scrollEndTimer),this._scrollEndTimer=setTimeout(()=>{this._scrolling=!1,this._dm.setHold(!1),this._schedDraw()},150),this._schedDraw()}_hitFillHandle(t,e,s=this._geo(),i=It){if(!this._sel)return!1;let{headerH:o,colPositions:n}=s,l=this._sel.type==="single"?this._sel.row:this._sel.r2,a=this._sel.type==="single"?this._sel.col:this._sel.c2,c=this._colLeft(a,s)+(n[a+1]-n[a]),h=this._rowLayout.yOf(l+1)-this._scrollTop+o;return Math.abs(t-c)<=i&&Math.abs(e-h)<=i}_colLeft(t,e){return ee(t,e,this._scrollLeft)}_autoFitCol(t){let e=this._canvas.getContext("2d"),{theme:s}=this._opts,i=s.cellPadding,o=this._columns[t],n=this._columnLabels[t]??o;e.font=`bold ${s.fontSize}px ${s.fontFamily}`;let l=this._colDefMap.get(o)?.headerCheckbox?20:0,a=e.measureText(n).width+i*2+Bt+4+l,c=this._colDefMap.get(o),h=c?.type,d=h==="dropdown"||h==="multiselect"?se:0,u=s.locale;e.font=`${s.fontSize}px ${s.fontFamily}`,this._dm.forEachLoaded(_=>{let p=_?.[o];if(p==null)return;let w=Kt(p,c,u),m=e.measureText(String(w)).width+i*2+d;m>a&&(a=m)}),this._edits.forEach((_,p)=>{let w=p.indexOf("_");if(w===-1||p.slice(w+1)!==o)return;let m=Kt(_,c,u),x=e.measureText(String(m)).width+i*2+d;x>a&&(a=x)});let f=Math.max(os,Math.ceil(a));this._columnWidths[t]=f,this._columnWidthMap.set(o,f)}_selectedColsForAutoFit(){if(this._sel&&this._sel.type==="range"){let t=new Set;for(let e=this._sel.c1;e<=this._sel.c2;e++)t.add(e);return t}return null}_calcInsertBefore(t,e=this._geo()){let{width:s}=this._opts,{colPositions:i}=e,o=this._columns.length;if(t<=0)return 0;if(t>=s-e.vSB)return o;let n=this._colAtX(t,e)??0,l=this._colLeft(n,e),a=i[n+1]-i[n];return t>l+a/2?n+1:n}_startColSlide(t,e,s){if(this._colSlideMs===0){this._colSlide=null;return}let[i,o,n]=e>t?[t,e-1,t+1]:[e+1,t,e],l=this._geo().colPositions,a=s[n]-l[i];if(!a){this._colSlide=null;return}this._colSlide={c1:i,c2:o,dx:a,dragCol:e},this._colSlideTween.set(0),this._colSlideTween.to(1,this._colSlideMs)}_reorderCol(t,e,{silent:s=!1}={}){if(e===t||e===t+1)return t;this._commitEdit();let i=e>t?e-1:e,o=a=>{let c=[...a];return c.splice(i,0,c.splice(t,1)[0]),c},n=this._columns.length;this._columns=o(this._columns),this._columnLabels=o(this._columnLabels),this._columnAligns=o(this._columnAligns),this._columnHeaderAligns=o(this._columnHeaderAligns),this._columnWidths=o(this._columnWidths),this._columnRenderers=o(this._columnRenderers);let l=new Map;for(let a=0;a<n;a++)a===t?l.set(a,i):e>t&&a>t&&a<=i?l.set(a,a-1):e<t&&a>=i&&a<t?l.set(a,a+1):l.set(a,a);if(this._sel){let a=c=>l.get(c)??c;if(this._sel.type==="single")this._sel={...this._sel,col:a(this._sel.col)};else{let{r1:c,c1:h,r2:d,c2:u}=this._sel;this._sel={type:"range",...this._normRange(c,a(h),d,a(u))}}}return this._updateA11yHeader(),this._updateA11yCell(),s||this._opts.onColumnReorder?.([...this._columns]),i}_rowReorderReady(){return!!this._opts.rowReorder&&Array.isArray(this._rowOrderData)&&!r._plugins.some(t=>t.altRowSource?.(this))}async _materializeRowOrder(){if(this._rowOrderScanPending)return;this._rowOrderScanPending=!0;let t=this._rowOrderGen;try{let e=await this._scanAllRows();if(this._destroyed||e===null||t!==this._rowOrderGen||!this._opts.rowReorder||r._plugins.some(s=>s.altRowSource?.(this)))return;this._rowOrderData=e,this._applyDisplayFetch(e),this._draw()}finally{this._rowOrderScanPending=!1}}_calcRowInsertBefore(t,e=this._geo()){let s=t-e.headerH+this._scrollTop,i=this._rowPlan.serverVisible-1;if(i<0||s<=0)return 0;let o=this._rowLayout.rowAt(s,i);if(o<0)return this._rowPlan.serverVisible;let n=this._rowLayout.yOf(o),l=this._rowLayout.heightOf(o);return s-n<l/2?o:o+1}_reorderRow(t,e){if(!this._rowOrderData||e===t||e===t+1)return;let s=e>t?e-1:e,i;this._rebuildDisplayFetch(()=>([i]=this._rowOrderData.splice(t,1),this._rowOrderData.splice(s,0,i),this._rowOrderData))&&(this._opts.onRowReorder?.(t,s,i),this._announce(this._i18n.rowReorderAnnounce(t+1,s+1)))}_filterState(){return{sorts:[...this._sorts],filters:Object.fromEntries(this._filters),quickFilter:this._quickFilter}}_snapshotLocalRowState(){if(this._localRows.length===0)return null;let t=s=>{let i=[];return s.forEach((o,n)=>{let l=n.indexOf("_"),a=this._localIndexAt(Number(n.slice(0,l)));a>=0&&i.push([a,n.slice(l+1),o])}),i},e=[];return this._rowLayout.snapshotOverrides().forEach((s,i)=>{let o=this._localIndexAt(i);o>=0&&e.push([o,s])}),{edits:t(this._edits),invalid:t(this._validator.map),heights:e}}_restoreLocalRowState(){let t=this._pendingLocalState;if(this._pendingLocalState=null,!t)return;let e=s=>this._rowPlan.visualOfLocal(s);for(let[s,i,o]of t.edits)this._edits.set(`${e(s)}_${i}`,o),this._editedRows.add(e(s));for(let[s,i,o]of t.invalid)this._validator.map.set(`${e(s)}_${i}`,o);if(t.heights.length>0){let s=this._rowLayout.snapshotOverrides();for(let[i,o]of t.heights)s.set(e(i),o);this._rowLayout.restoreOverrides(s)}}_reloadFiltered({confirmUnsaved:t=!0,carryRows:e=!0}={}){if(t){let o=0;if(this._edits.forEach((n,l)=>{this._localIndexAt(Number(l.slice(0,l.indexOf("_"))))<0&&o++}),o>0&&!window.confirm(this._i18n.unsavedEditsWarning))return null}this._pendingLocalState=e?this._snapshotLocalRowState():null,e||(this._localRows.length=0,this._rowPlan.anchors.length=0);let s=this._filterState();this._cancelEdit(),this._closeRowContextMenu(),this._closeCellContextMenu();for(let o of r._plugins)o.hideTooltip?.(this);return this._cellTooltip.style.display="none",this._clearPlugins("rowIndexState"),this._clearPlugins("altView"),this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._rowLayout.clear(),this._sel=null,this._fillDrag=null,this._fillPreview=null,this._deletedRows.clear(),this._rowPlan.removed.clear(),this._rowPlan.detachAnchors(),this._undoMgr.clear(),this._editTxn=null,this._scrollTop=0,this._page=0,this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._opts.onSort?.(this._sorts.length>0?[...this._sorts]:null),this._opts.onFilter?.(Object.fromEntries(this._filters)),r._plugins.some(o=>o.bootOverride?.(this,s))?(this._pendingLocalState=null,Promise.resolve()):(this._dm.setFetch((o,n)=>this._opts.fetchData(o,n,s)),this._boot(s))}_skeletonPhase(){if(this._reducedMotion)return null;let t=this._geo(),e=Math.max(0,this._rowLayout.rowAt(this._scrollTop,this._totalRows-1)),s=Math.min(this._totalRows-1,this._rowLayout.rowAt(this._scrollTop+t.vpH,this._totalRows-1)),i=!1;for(let o=e;o<=s;o++)if(this._rowSource(o)==null){i=!0;break}return i?(this._skeletonRaf||(this._skeletonRaf=requestAnimationFrame(()=>{this._skeletonRaf=0,this._draw()})),performance.now()%rs/rs):(this._skeletonRaf&&(cancelAnimationFrame(this._skeletonRaf),this._skeletonRaf=0),null)}_colorScanConcurrency(){let t=this._opts.colorFilterConcurrency;if(t>0)return t;let e=typeof navigator<"u"&&navigator.hardwareConcurrency||4;return Math.max(2,Math.min(8,e))}async _forEachFilteredRow(t,e){for(let o of r._plugins)if(await o.forEachFilteredRowOverride?.(this,t,e))return;let s=this._opts.chunkSize,i=0;for(;;){let{rows:o}=await this._opts.fetchData(i,s,t);if(!o?.length||(e(o,i*s),o.length<s))break;i++}}async _scanAllRows(){let t=this._filterState();this._loadingEl.textContent=this._i18n.loading;let e=await this._opts.fetchMeta(t);if(this._destroyed)return null;let s=e.totalRows,i=Math.max(1,this._opts.colorFilterPageSize||this._opts.chunkSize),o=Math.max(1,Math.ceil(s/i)),n=new Array(o),l=0,a=0,c=async()=>{for(;;){if(this._destroyed)return;let d=l++;if(d>=o)return;let{rows:u}=await this._opts.fetchData(d,i,t);if(this._destroyed)return;n[d]=u??[],a++,this._loadingEl.textContent=`${this._i18n.loading} ${Math.round(a/o*100)}%`}};if(await Promise.all(Array.from({length:Math.min(this._colorScanConcurrency(),o)},c)),this._destroyed)return null;let h=[];for(let d of n)if(d)for(let u of d)h.push(u);return h}_applyDisplayFetch(t){this._dm.setFetch((e,s)=>Promise.resolve({rows:t.slice(e*s,(e+1)*s)})),this._serverTotal=t.length,this._rowPlan.clampAnchors(t.length),this._totalRows=t.length+this._localRows.length,this._dm.prefetch(0,Math.min(this._opts.chunkSize-1,this._totalRows-1))}_isGroupRow(t){return!!this._dm.getRow(t)?.__group__}_hitTreeChevron(t,e,s){let i=this._dm.getRow(e.row);if(!i?.__treeHasChildren)return!1;let o=this._columns[e.col];if(!this._colDefMap.get(o)?.treeColumn)return!1;let n=this._colLeft(e.col,s),l=(i.__treeLevel??0)*ie;return t>=n+l&&t<=n+l+ye}_rebuildDisplayFetch(t){if(this._edits.size>0&&!window.confirm(this._i18n.unsavedEditsWarning))return!1;this._commitEdit(),this._setSel(null),this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._clearPlugins("rowIndexState"),this._rowLayout.clear(),this._undoMgr.clear();let e=t();return this._applyDisplayFetch(e),this._clamp(this._geo()),this._updateA11yHeader(),this._draw(),!0}_suggestFilterValuesLocal(t,e,s=50){let i=String(e??"").toLowerCase(),o=new Set,n=l=>{let a=l==null?"":String(l);return a===""||o.has(a)||!a.toLowerCase().includes(i)?!0:(o.add(a),o.size<s)};if(this._dm.forEachLoaded(l=>n(l?.[t])),o.size<s){for(let l of this._localRows)if(n(l?.[t])===!1)break}return[...o].sort((l,a)=>l.localeCompare(a,void 0,{numeric:!0}))}_discoverFilterValues(t,e=200){if(this._searchModeCols.has(t))return null;let s=new Set,i=!1,o=n=>{let l=n==null?"":String(n);return!s.has(l)&&(s.add(l),s.size>e)?(i=!0,!1):!0};if(this._dm.forEachLoaded(n=>o(n?.[t])),!i){for(let n of this._localRows)if(o(n?.[t])===!1)break}return i?null:[...s].sort((n,l)=>n.localeCompare(l,void 0,{numeric:!0}))}_openFilterPanel(t){this._closeFilterPanel();let e=this._geo(),s=this._columns[t],i=this._columnLabels[t]??s,o=this._filters.get(s),n=typeof o=="string"?o:"",l=this._discoverFilterValues(s);l===null?this._searchModeCols.add(s):this._searchModeCols.has(s)&&(l=null);let a=Array.isArray(o)?o:null,c=this._sorts.find(D=>D.field===s),h=c?this._sorts.indexOf(c)+1:0,d={};for(let D of r._plugins)Object.assign(d,D.filterPanelOptions?.(this,s,t));let{swatchColors:u=[],activeColor:f}=d,_=r._plugins.some(D=>D.extraSortSlots),p=()=>{this._closeFilterPanel(),this._kbProxy.focus()};this._wrapper.style.overflow="visible";let w=this._wrapper.getBoundingClientRect().top,x=(window.innerHeight||document.documentElement.clientHeight)-w-e.headerH-8,S=w-8,b=x<260&&S>x,C=b?S:x,H=Ge({colLeft:this._colLeft(t,e),headerH:e.headerH,wrapperHeight:this._opts.height,openUpward:b,width:this._opts.width,maxPanelHeight:C,label:i,curVal:n,sortPriority:h,asc:c?.dir==="asc",desc:c?.dir==="desc",filterId:`jhgrid-${this._uid}-filter`,multiSortEnabled:_,swatchColors:u,activeColor:f,distinctValues:l,selectedValues:a,suggest:this._opts.fetchFilterValues?async D=>{let A=await this._opts.fetchFilterValues(s,D);return Array.isArray(A)?A.map(j=>j==null?"":String(j)):[]}:D=>this._suggestFilterValuesLocal(s,D),suggestScope:this._opts.fetchFilterValues?"remote":"local",tagValues:a,containsValue:n,minQueryChars:this._opts.filterValueMinChars,i18n:this._i18n,theme:this._opts.theme,onClose:p,onSort:(D,A)=>{let j=this._sorts.findIndex(O=>O.field===s);A&&_?j>=0?this._sorts[j]={field:s,dir:D}:this._sorts.push({field:s,dir:D}):this._sorts=[{field:s,dir:D}],this._reloadFiltered(),p(),this._announce(this._i18n.sortAppliedAnnounce(i,D))},onApply:D=>{this._trivialSetFilters.delete(s),D?this._filters.set(s,D):this._filters.delete(s),this._reloadFiltered(),p(),this._announce(D?this._i18n.filterAppliedAnnounce(i):this._i18n.filterClearedAnnounce(i))},onApplyValues:D=>{this._filters.set(s,D),l&&D.length===l.length?this._trivialSetFilters.add(s):this._trivialSetFilters.delete(s),this._reloadFiltered(),p(),this._announce(this._i18n.filterAppliedAnnounce(i))},onColorFilter:D=>{let A=r._plugins.find(j=>j.toggleFilterValue)?.toggleFilterValue(this,s,D);this._reloadFiltered(),p(),this._announce(A?this._i18n.filterClearedAnnounce(i):this._i18n.filterAppliedAnnounce(i))},onResetCol:()=>{this._filters.delete(s),this._trivialSetFilters.delete(s),r._plugins.find(D=>D.clearFilterField)?.clearFilterField(this,s),this._sorts=this._sorts.filter(D=>D.field!==s),this._reloadFiltered(),p(),this._announce(this._i18n.filterClearedAnnounce(i))},onResetAll:()=>{this._filters.clear(),this._trivialSetFilters.clear(),this._clearPlugins("filterState"),this._sorts=[],this._reloadFiltered(),p(),this._announce(this._i18n.allFiltersClearedAnnounce)}});this._wrapper.appendChild(H),this._filterPanel={col:t,el:H},(H.querySelector('input[type="text"]')??H.querySelector("input")).focus()}_closeFilterPanel(){this._filterPanel&&(this._filterPanel.el.dispatchEvent(new Event("jhg-dispose")),this._filterPanel.el.remove(),this._filterPanel=null,this._wrapper.style.overflow="hidden")}_colMenuItemAllowed(t){let e=this._opts.colContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openColContextMenu(t,e,s){if(this._opts.colContextMenuItems===!1)return;this._closeColContextMenu();let i=this._geo(),o=this._columns.length,n=t<i.frozenCount,l=t>=o-i.frozenRightCount,a=this._columns[t],c=this._deletedColumns.has(a),h=Ke({x:e,y:s,width:this._opts.width,isFrozen:n,isFrozenRight:l,isDeleted:c,i18n:this._i18n,theme:this._opts.theme,allowedItems:{freeze:this._colMenuItemAllowed("freeze"),freezeRight:this._colMenuItemAllowed("freeze-right"),visibility:this._colMenuItemAllowed("visibility"),insertLeft:this._colMenuItemAllowed("insert-left"),insertRight:this._colMenuItemAllowed("insert-right"),delete:this._colMenuItemAllowed("delete")},onFreeze:()=>{this._closeColContextMenu(),this._opts.frozenCols=n?0:t+1,this._scrollLeft=0,this._clamp(this._geo()),this._draw(),this._kbProxy.focus()},onFreezeRight:()=>{this._closeColContextMenu(),this._opts.frozenColsRight=l?0:o-t,this._scrollLeft=0,this._clamp(this._geo()),this._draw(),this._kbProxy.focus()},onVisibility:()=>{this._closeColContextMenu(),this._openColChooser(e,s)},onInsertLeft:()=>{this._closeColContextMenu(),this._openNewColumnDialog(t,e,s)},onInsertRight:()=>{this._closeColContextMenu(),this._openNewColumnDialog(t+1,e,s)},onDelete:()=>{this._closeColContextMenu(),this.deleteColumn(a),this._kbProxy.focus()},onUndelete:()=>{this._closeColContextMenu(),this.undeleteColumn(a),this._kbProxy.focus()},onEscape:()=>{this._closeColContextMenu(),this._kbProxy.focus()}});h&&(this._wrapper.appendChild(h),this._colContextMenu={col:t,el:h},h.querySelector('[role="menuitem"]').focus())}_closeColContextMenu(){this._colContextMenu&&(this._colContextMenu.el.remove(),this._colContextMenu=null)}_openNewColumnDialog(t,e,s){this._closeNewColumnDialog();let{width:i,height:o,theme:n}=this._opts,l=(...C)=>C.join(";"),a=220,c=122,h=Math.max(0,Math.min(e,i-a-4)),d=Math.max(0,Math.min(s,o-c-4)),u=document.createElement("div");u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-label",this._i18n.colInsertTitle),u.className=`${B.overlay} ${B.dialog}`,u.style.cssText=l("position:absolute",`left:${h}px`,`top:${d}px`,`width:${a}px`,`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(n,"overlayShadow")}`,`font-family:${y(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${y(n,"overlayText")}`,"z-index:300","overflow:hidden","user-select:none");let f=document.createElement("div");f.style.cssText=l("display:flex","align-items:center","justify-content:space-between","padding:8px 12px",`background:${y(n,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(n,"overlayDivider")}`);let _=document.createElement("span");_.textContent=this._i18n.colInsertTitle,_.style.cssText=`font-weight:600;font-size:12px;color:${y(n,"overlayMutedText")};`;let p=document.createElement("button");p.type="button",p.textContent="\xD7",p.setAttribute("aria-label",this._i18n.colInsertCancel),p.style.cssText=l("background:none","border:none",`color:${y(n,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),p.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),f.append(_,p);let w=document.createElement("div");w.style.cssText="padding:10px 12px 0;";let m=document.createElement("input");m.type="text",m.placeholder=this._i18n.colInsertPlaceholder,m.className=B.editor,m.style.cssText=l("width:100%",`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:4px",`color:${y(n,"overlayText")}`,`font-size:${n.fontSize}px`,"padding:6px 8px","box-sizing:border-box",`font-family:${y(n,"fontFamily")}`),w.appendChild(m);let x=document.createElement("div");x.style.cssText="display:flex;gap:6px;padding:10px 12px;";let S=document.createElement("button");S.type="button",S.textContent=this._i18n.colInsertConfirm,S.className=B.btn,S.style.cssText=l("flex:1","padding:6px 0",`background:${y(n,"selectionColor")}`,`color:${y(n,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600");let v=()=>{let C=m.value.trim();if(!C){m.focus();return}let H=`NEW_COL_${this._newColSeq++}`;this.addColumn(H,{label:C},{index:t}),this._closeNewColumnDialog(),this._kbProxy.focus()};S.addEventListener("click",v);let b=document.createElement("button");b.type="button",b.textContent=this._i18n.colInsertCancel,b.className=B.btn,b.style.cssText=l("flex:1","padding:6px 0",`background:${y(n,"overlayHeaderBg")}`,`color:${y(n,"overlayText")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"),b.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),x.append(S,b),u.append(f,w,x),u.addEventListener("mousedown",C=>C.stopPropagation()),m.addEventListener("keydown",C=>{C.key==="Enter"?(C.preventDefault(),v()):C.key==="Escape"&&(this._closeNewColumnDialog(),this._kbProxy.focus()),C.stopPropagation()}),this._wrapper.appendChild(u),this._newColDialog={el:u},m.focus()}_closeNewColumnDialog(){this._newColDialog&&(this._newColDialog.el.remove(),this._newColDialog=null)}_rowMenuItemAllowed(t){let e=this._opts.rowContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openRowContextMenu(t,e,s){if(this._opts.rowContextMenuItems===!1)return;this._closeRowContextMenu();let i=this._localIndexAt(t)>=0,o=this._deletedRows.has(t),n=this._opts.theme,l=170,a=(...v)=>v.join(";"),c=a("padding:8px 14px","cursor:pointer"),h=(v,b)=>{let C=document.createElement("div");return C.setAttribute("role","menuitem"),C.setAttribute("tabindex","0"),C.textContent=v,C.dataset.action=b,C.className=B.menuItem,C.style.cssText=c,C.addEventListener("mouseover",()=>{C.style.background=y(n,"overlayItemHoverBg")}),C.addEventListener("mouseout",()=>{C.style.background=""}),C.addEventListener("focus",()=>{C.style.background=y(n,"overlayItemHoverBg")}),C.addEventListener("blur",()=>{C.style.background=""}),C},d=()=>{let v=document.createElement("div");return v.style.cssText=`height:1px;background:${y(n,"overlayDivider")};margin:4px 0;`,v},u=[];this._rowMenuItemAllowed("row-insert-above")&&u.push(h(this._i18n.rowInsertAbove,"row-insert-above")),this._rowMenuItemAllowed("row-insert-below")&&u.push(h(this._i18n.rowInsertBelow,"row-insert-below")),this._rowMenuItemAllowed("row-insert-top")&&u.push(h(this._i18n.rowInsertTop,"row-insert-top")),this._rowMenuItemAllowed("row-insert-bottom")&&u.push(h(this._i18n.rowInsertBottom,"row-insert-bottom"));let f=[];if(this._rowMenuItemAllowed("row-delete")&&(o?f.push(h(this._i18n.rowUndelete,"row-undelete")):i?f.push(h(this._i18n.rowDelete,"row-delete")):(f.push(h(this._i18n.rowDeleteMark,"row-delete-mark")),f.push(h(this._i18n.rowDeletePermanent,"row-delete-permanent")))),u.length===0&&f.length===0)return;let _=u.length>0&&f.length>0?[...u,d(),...f]:[...u,...f],m=(_.length-(u.length>0&&f.length>0?1:0))*36+(u.length>0&&f.length>0?9:0)+8,x=s+m<=this._opts.height?s:Math.max(0,s-m),S=document.createElement("div");S.setAttribute("role","menu"),S.className=`${B.overlay} ${B.menu}`,S.style.cssText=a("position:absolute",`left:${e}px`,`top:${x}px`,`width:${l}px`,`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(n,"overlayMenuShadow")}`,`font-family:${y(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${y(n,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0"),S.addEventListener("mousedown",v=>v.stopPropagation()),S.addEventListener("click",v=>{let b=v.target.closest("[data-action]")?.dataset?.action;b&&(this._closeRowContextMenu(),b==="row-insert-above"?this.addRow({},{index:t}):b==="row-insert-below"?this.addRow({},{index:t+1}):b==="row-insert-top"?this.addRow({},{index:0}):b==="row-insert-bottom"?this.addRow({}):b==="row-delete-mark"?this.deleteRow(t,{permanent:!1}):b==="row-delete-permanent"?this.deleteRow(t,{permanent:!0}):b==="row-delete"?this.deleteRow(t):b==="row-undelete"&&this.undeleteRow(t),this._kbProxy.focus())}),S.addEventListener("keydown",v=>{if(v.key==="Escape")this._closeRowContextMenu(),this._kbProxy.focus();else if(v.key==="Enter"||v.key===" ")v.preventDefault(),document.activeElement?.click?.();else if(v.key==="ArrowDown"||v.key==="ArrowUp"){v.preventDefault();let b=[...S.querySelectorAll('[role="menuitem"]')],C=b.indexOf(document.activeElement),H=v.key==="ArrowDown"?(C+1)%b.length:(C-1+b.length)%b.length;b[H]?.focus()}v.stopPropagation()}),S.append(..._),this._wrapper.appendChild(S),this._rowContextMenu={row:t,el:S},_[0].focus()}_closeRowContextMenu(){this._rowContextMenu&&(this._rowContextMenu.el.remove(),this._rowContextMenu=null)}_cellMenuItemAllowed(t){let e=this._opts.cellContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openCellContextMenu(t,e,s,i){if(this._opts.cellContextMenuItems===!1)return;this._closeCellContextMenu();let o=this._columns[e],n=this._opts.theme,l=170,a=(...E)=>E.join(";"),c=a("padding:8px 14px","cursor:pointer"),h=(E,L)=>{let M=document.createElement("div");return M.setAttribute("role","menuitem"),M.setAttribute("tabindex","0"),M.textContent=E,M.dataset.action=L,M.className=B.menuItem,M.style.cssText=c,M.addEventListener("mouseover",()=>{M.style.background=y(n,"overlayItemHoverBg")}),M.addEventListener("mouseout",()=>{M.style.background=""}),M.addEventListener("focus",()=>{M.style.background=y(n,"overlayItemHoverBg")}),M.addEventListener("blur",()=>{M.style.background=""}),M},d=()=>{let E=document.createElement("div");return E.style.cssText=`height:1px;background:${y(n,"overlayDivider")};margin:4px 0;`,E},u=[];this._cellMenuItemAllowed("col-insert-left")&&u.push(h(this._i18n.colInsertLeft,"col-insert-left")),this._cellMenuItemAllowed("col-insert-right")&&u.push(h(this._i18n.colInsertRight,"col-insert-right"));let f=this._cellMenuItemAllowed("col-delete")?[h(this._i18n.colDelete,"col-delete")]:[],_=[];this._cellMenuItemAllowed("row-insert-below")&&_.push(h(this._i18n.rowInsertBelow,"row-insert-below")),this._cellMenuItemAllowed("row-delete")&&_.push(h(this._i18n.rowDelete,"row-delete"));let p=this.getRowData(t),w=this._canvas.getBoundingClientRect(),m=w.left+s,x=w.top+i,S=typeof this._opts.cellContextMenuExtraItems=="function"?this._opts.cellContextMenuExtraItems({row:t,col:e,field:o,rowData:p,clientX:m,clientY:x})||[]:[],v=S.map((E,L)=>{let M=h(E.label,`extra:${L}`);return E.disabled&&(M.setAttribute("aria-disabled","true"),M.style.opacity="0.5",M.style.pointerEvents="none"),M}),b=[u,f,_,v].filter(E=>E.length>0);if(b.length===0)return;let C=b.flatMap((E,L)=>L===0?E:[d(),...E]),H=36,D=9,A=b.reduce((E,L)=>E+L.length,0),j=b.length-1,O=A*H+j*D+8,V=i+O<=this._opts.height?i:Math.max(0,i-O),z=Math.min(s,this._opts.width-l-2),W=document.createElement("div");W.setAttribute("role","menu"),W.className=`${B.overlay} ${B.menu}`,W.style.cssText=a("position:absolute",`left:${z}px`,`top:${V}px`,`width:${l}px`,`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(n,"overlayMenuShadow")}`,`font-family:${y(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${y(n,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0"),W.addEventListener("mousedown",E=>E.stopPropagation()),W.addEventListener("click",E=>{let L=E.target.closest("[data-action]")?.dataset?.action;if(L){if(L==="col-insert-left"){this._closeCellContextMenu(),this._openNewColumnDialog(e,s,i);return}if(L==="col-insert-right"){this._closeCellContextMenu(),this._openNewColumnDialog(e+1,s,i);return}if(L.startsWith("extra:")){this._closeCellContextMenu(),S[Number(L.slice(6))]?.onClick?.({row:t,col:e,field:o,rowData:p,clientX:m,clientY:x}),this._kbProxy.focus();return}this._closeCellContextMenu(),L==="col-delete"?this.deleteColumn(o):L==="row-insert-below"?this.addRow({},{index:t+1}):L==="row-delete"&&this.deleteRow(t),this._kbProxy.focus()}}),W.addEventListener("keydown",E=>{if(E.key==="Escape")this._closeCellContextMenu(),this._kbProxy.focus();else if(E.key==="Enter"||E.key===" ")E.preventDefault(),document.activeElement?.click?.();else if(E.key==="ArrowDown"||E.key==="ArrowUp"){E.preventDefault();let L=[...W.querySelectorAll('[role="menuitem"]')],M=L.indexOf(document.activeElement),Q=E.key==="ArrowDown"?(M+1)%L.length:(M-1+L.length)%L.length;L[Q]?.focus()}E.stopPropagation()}),W.append(...C),this._wrapper.appendChild(W),this._cellContextMenu={row:t,col:e,el:W},W.querySelector('[role="menuitem"]').focus()}_closeCellContextMenu(){this._cellContextMenu&&(this._cellContextMenu.el.remove(),this._cellContextMenu=null)}_openColChooser(t,e){this._closeColChooser();let s=Ye({x:t,y:e,width:this._opts.width,height:this._opts.height,fields:this._columnOriginalOrder,isHidden:i=>this._hiddenColumns.has(i),labelFor:i=>this._colDefMap.get(i)?.label??i,groupPathFor:i=>fe(this._colDefMap.get(i)?.group),i18n:this._i18n,theme:this._opts.theme,onApply:i=>{this._withStructuralUndo(()=>{this._columnOriginalOrder.forEach(o=>{let n=i.get(o),l=!this._hiddenColumns.has(o);n&&!l?(this._deletedColumns.delete(o),this._showColumnInternal(o)):!n&&l&&this._hideColumnInternal(o)}),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()}),this._closeColChooser(),this._kbProxy.focus()},onCancel:()=>{this._closeColChooser(),this._kbProxy.focus()}});s&&(this._wrapper.appendChild(s),this._colChooser={el:s},s.querySelector("button").focus())}_closeColChooser(){this._colChooser&&(this._colChooser.el.remove(),this._colChooser=null)}_remapSelForColRemoval(t){if(!this._sel)return;let e=s=>s>t?s-1:s===t?-1:s;if(this._sel.type==="single"){let s=e(this._sel.col);this._sel=s<0?null:{...this._sel,col:s}}else{let s=e(this._sel.c1),i=e(this._sel.c2);s<0||i<0?this._sel=null:s===i?this._sel={type:"single",row:this._sel.r1,col:s}:this._sel={type:"range",...this._normRange(this._sel.r1,s,this._sel.r2,i)}}}_purgeFieldEdits(t){[...this._edits.keys()].forEach(e=>{let s=e.indexOf("_");e.slice(s+1)===t&&this._edits.delete(e)});for(let e of r._plugins)e.purgeField?.(this,t)}_hideColumnInternal(t){let e=this._columns.indexOf(t);if(e===-1)return;this._hiddenColumns.set(t,{label:this._columnLabels[e],align:this._columnAligns[e],headerAlign:this._columnHeaderAligns[e],width:this._columnWidths[e],renderer:this._columnRenderers[e]});let s=(i,o)=>o!==e;this._columns=this._columns.filter(s),this._columnLabels=this._columnLabels.filter(s),this._columnAligns=this._columnAligns.filter(s),this._columnHeaderAligns=this._columnHeaderAligns.filter(s),this._columnWidths=this._columnWidths.filter(s),this._columnRenderers=this._columnRenderers.filter(s),this._remapSelForColRemoval(e)}_showColumnInternal(t){let e=this._hiddenColumns.get(t);if(!e)return;this._hiddenColumns.delete(t);let s=this._columnOriginalOrder.indexOf(t),i=this._columns.length;for(let n=s+1;n<this._columnOriginalOrder.length;n++){let l=this._columns.indexOf(this._columnOriginalOrder[n]);if(l!==-1){i=l;break}}let o=(n,l)=>{let a=[...n];return a.splice(i,0,l),a};this._columns=o(this._columns,t),this._columnLabels=o(this._columnLabels,e.label),this._columnAligns=o(this._columnAligns,e.align),this._columnHeaderAligns=o(this._columnHeaderAligns,e.headerAlign),this._columnWidths=o(this._columnWidths,e.width),this._columnRenderers=o(this._columnRenderers,e.renderer)}_normRange(t,e,s,i){return{r1:Math.min(t,s),c1:Math.min(e,i),r2:Math.max(t,s),c2:Math.max(e,i)}}_dragEdgeDir(t,e,s=this._geo()){let{width:i,height:o}=this._opts,n=24,l=0,a=0;return t<s.frozenWidth+n?l=-1:t>s.rightX-n&&(l=1),e<s.headerH+n?a=-1:e>o-s.hSB-n&&(a=1),{dx:l,dy:a}}_extendDragSelection(t,e,s=this._geo()){let i=this._hitCellClamped(t,e,s);if(!i)return;let o=this._normRange(this._selDragStart.row,this._selDragStart.col,i.row,i.col),n=o.r1===o.r2&&o.c1===o.c2;this._sel=n?{type:"single",row:o.r1,col:o.c1}:{type:"range",...o},this._schedDraw()}_startDragAutoScroll(){this._dragScrollTimer||(this._dragScrollTimer=setInterval(()=>this._dragAutoScrollTick(),50))}_stopDragAutoScroll(){this._dragScrollTimer&&(clearInterval(this._dragScrollTimer),this._dragScrollTimer=null),this._dragScrollDir={dx:0,dy:0}}_dragAutoScrollTick(){let{dx:t,dy:e}=this._dragScrollDir;if(!t&&!e||!this._selDragging&&!this._fillDrag||!this._dragScrollPos){this._stopDragAutoScroll();return}let s=40,i=this._geo();t&&(this._scrollLeft+=t*s),e&&(this._scrollTop+=e*s),this._clamp(i),this._selDragging?this._extendDragSelection(this._dragScrollPos.x,this._dragScrollPos.y,this._geo()):this._extendFillDrag(this._dragScrollPos.x,this._dragScrollPos.y,this._geo())}_isEditable(t){if(t<0||t>=this._columns.length)return!1;let e=this._columns[t],s=this._colDefMap.get(e)?.editable;return s!==void 0?s:this._editableCols===null||this._editableCols.has(e)}_localIndexAt(t){return this._rowPlan.sourceAt(t)?.local??-1}_rowSource(t){let e=this._rowPlan.sourceAt(t);return e?e.local>=0?this._localRows[e.local]??null:this._dm.getRow(e.server):null}_cellVal(t,e){let s=this._columns[e],i=`${t}_${s}`;if(this._edits.has(i))return this._edits.get(i);let o=this._rowSource(t);if(!o)return"";let n=o[s];return n!=null?String(n):""}_getRow(t){let e=this._rowSource(t);if(!this._editedRows.has(t))return e;let s=e?{...e}:{};return this._columns.forEach(i=>{let o=`${t}_${i}`;this._edits.has(o)&&(s[i]=this._edits.get(o))}),s}_isPlainTextEditor(t){let e=this._colDefMap.get(this._columns[t]);return!e?.editor&&(e?.type??"text")==="text"}_startEdit(t,e,s=void 0,{keepInputValue:i=!1}={}){if(!this._isEditable(e))return;this._editing&&this._commitEdit();let o=this._columns[e],n=this._colDefMap.get(o),l=n?.type??"text";if(l==="checkbox"||l==="button")return;let a=this._buildEditorCtx(t,e,s);a.keepInputValue=i;let c=n?.editor,h;if(typeof c=="function")h=c(a);else{let d=c??l,f=d==="text"&&!i&&String(a.initialValue??"").includes(`
|
|
141
|
+
</body></html>`}var ce=class{#t;#e=new Map;#i=[];#o=[0];#s=!1;constructor(t){this.#t=t}get defaultHeight(){return this.#t}set defaultHeight(t){t!==this.#t&&(this.#t=t,this.#s=!0)}#n(){this.#i=[...this.#e.keys()].sort((t,e)=>t-e),this.#o=new Array(this.#i.length+1),this.#o[0]=0;for(let t=0;t<this.#i.length;t++){let e=this.#e.get(this.#i[t]);this.#o[t+1]=this.#o[t]+(e-this.#t)}this.#s=!1}#r(){this.#s&&this.#n()}#l(t){let e=0,s=this.#i.length;for(;e<s;){let i=e+s>>1;this.#i[i]<t?e=i+1:s=i}return e}heightOf(t){return this.#e.get(t)??this.#t}hasOverride(t){return this.#e.has(t)}setHeight(t,e){let s=Math.max(1,Math.round(e));if(s===this.#t){this.#e.delete(t)&&(this.#s=!0);return}this.#e.get(t)!==s&&(this.#e.set(t,s),this.#s=!0)}snapshotOverrides(){return new Map(this.#e)}restoreOverrides(t){this.#e=new Map(t),this.#s=!0}clear(){this.#e.size&&(this.#e.clear(),this.#s=!0)}yOf(t){return t<=0?0:(this.#r(),t*this.#t+this.#o[this.#l(t)])}rowAt(t,e){if(t<0||e<0||this.yOf(e)+this.heightOf(e)<=t)return-1;let s=0,i=e;for(;s<i;){let o=s+i+1>>1;this.yOf(o)<=t?s=o:i=o-1}return s}shiftRows(t){if(this.#e.size===0)return;let e=new Map;for(let[s,i]of this.#e)e.set(t(s),i);this.#e=e,this.#s=!0}deleteRow(t){if(this.#e.size===0)return;let e=new Map;for(let[s,i]of this.#e)s!==t&&e.set(s>t?s-1:s,i);this.#e=e,this.#s=!0}};var Ls=new Intl.Collator(void 0,{numeric:!0});function Ue(r){return r==null||typeof r=="string"&&r.trim()===""?NaN:Number(r)}function Fs(r){return(t,e)=>{let s=t[r],i=e[r],o=Ue(s),n=Ue(i);return!Number.isNaN(o)&&!Number.isNaN(n)?o-n:Ls.compare(String(s??""),String(i??""))}}function Xe(r,t){if(!Array.isArray(r))throw new Error("[JHGrid] opts.data must be an array");let e=t?.length?t.map(i=>i.field):Object.keys(r[0]??{});if(!e.length)throw new Error("[JHGrid] opts.data: could not resolve columns from an empty array \u2014 pass opts.columnDefs");function s(i){let{filters:o={},sorts:n=[],quickFilter:l=""}=i??{},a=r;for(let[c,h]of Object.entries(o))if(Array.isArray(h)){if(h.length===0)continue;let d=new Set(h.map(String));a=a.filter(u=>d.has(String(u[c]??"")))}else if(h){let d=String(h).toLowerCase();a=a.filter(u=>String(u[c]??"").toLowerCase().includes(d))}if(l){let c=l.toLowerCase();a=a.filter(h=>Object.values(h).some(d=>String(d??"").toLowerCase().includes(c)))}for(let{field:c,dir:h}of[...n].reverse()){let d=h==="desc"?-1:1,u=Fs(c);a=[...a].sort((f,_)=>d*u(f,_))}return a}return{fetchMeta(i){let o=s(i);return Promise.resolve({totalRows:o.length,columns:e})},fetchData(i,o,n){let l=s(n);return Promise.resolve({rows:l.slice(i*o,i*o+o)})}}}var qe=new WeakMap;function $t(r){let t=qe.get(r);return t||(t={selectedRows:new Set,lastSelRow:null},qe.set(r,t)),t}function Je(r){return r._opts.rowSelection??"none"}var Ze={resetScope:["rowIndexState","full"],clear(r){this.rowSelection.clear(r)},snapshotStructural(r,t){let e=$t(r);t.selectedRows=new Set(e.selectedRows),t.lastSelRow=e.lastSelRow},restoreStructural(r,t){let e=$t(r);e.selectedRows=new Set(t.selectedRows??[]),e.lastSelRow=t.lastSelRow??null},exportState(r,t){t.selectedRows=[...$t(r).selectedRows]},importState(r,t){if(!Array.isArray(t.selectedRows))return;let e=$t(r);e.selectedRows=new Set(t.selectedRows),e.lastSelRow=t.selectedRows.at(-1)??null,r._draw()},install(r){Object.assign(r.prototype,{getSelectedRows(){return[...$t(this).selectedRows]},clearRowSelection(){let t=$t(this);t.selectedRows.clear(),t.lastSelRow=null,this._draw()}})},rowSelection:{modeFor:Je,has(r,t){return $t(r).selectedRows.has(t)},getRenderSet(r){let t=$t(r);return t.selectedRows.size>0?t.selectedRows:null},getSorted(r){return[...$t(r).selectedRows].sort((t,e)=>t-e)},clear(r){let t=$t(r);t.selectedRows.clear(),t.lastSelRow=null},shiftRows(r,t,e=-1){let s=$t(r);if(s.selectedRows.size>0){let i=new Set;for(let o of s.selectedRows)o!==e&&i.add(t(o));s.selectedRows=i}s.lastSelRow!=null&&(s.lastSelRow=s.lastSelRow===e?null:t(s.lastSelRow))},update(r,t,e,s){let i=Je(r);if(i==="none")return;let o=$t(r);if(i==="single")o.selectedRows.has(t)?o.selectedRows.clear():(o.selectedRows.clear(),o.selectedRows.add(t)),o.lastSelRow=t;else if(s&&o.lastSelRow!==null){let n=Math.min(o.lastSelRow,t),l=Math.max(o.lastSelRow,t);e||o.selectedRows.clear();for(let a=n;a<=l;a++)o.selectedRows.add(a)}else e?(o.selectedRows.has(t)?o.selectedRows.delete(t):o.selectedRows.add(t),o.lastSelRow=t):(o.selectedRows.clear(),o.selectedRows.add(t),o.lastSelRow=t);r._opts.onRowSelect?.([...o.selectedRows].sort((n,l)=>n-l)),r._announce(r._i18n.rowsSelectedAnnounce(o.selectedRows.size))},clearOnCellClick(r,t){if(!r._opts.showRowNumbers||t.ctrlKey||t.metaKey||t.shiftKey)return;let e=$t(r);e.selectedRows.size!==0&&(e.selectedRows.clear(),e.lastSelRow=null,r._opts.onRowSelect?.([]))}}};var Qe=typeof requestAnimationFrame=="function",Ps=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),Bs=r=>r*(2-r),Nt=class{#t;#e;#i;#o=0;#s=0;#n=0;#r;#l;#h;#c;constructor({value:t=0,onFrame:e=null,requestFrame:s,cancelFrame:i,now:o}={}){this.#t=t,this.#e=t,this.#i=t,this.#r=e,this.#c=o??Ps,this.#l=s!==void 0?s:Qe?n=>requestAnimationFrame(n):null,this.#h=i!==void 0?i:Qe?n=>cancelAnimationFrame(n):null}get value(){if(this.#s===0)return this.#i;let t=(this.#c()-this.#o)/this.#s;return t>=1?(this.#s=0,this.#t=this.#i,this.#i):this.#e+(this.#i-this.#e)*Bs(Math.max(0,t))}get animating(){return this.#s!==0&&this.#c()-this.#o<this.#s}set(t){this.#d(),this.#s=0,this.#t=this.#e=this.#i=t}to(t,e){if(t!==this.#i){if(!(e>0)||!this.#l){this.set(t);return}this.#e=this.value,this.#i=t,this.#o=this.#c(),this.#s=e,this.#a()}}stop(){this.#d(),this.#s=0,this.#t=this.#e=this.#i=this.value}#a(){if(this.#n||!this.#l)return;let t=()=>{this.#n=0;let e=this.animating;this.#r?.(),e&&this.#a()};this.#n=this.#l(t)}#d(){this.#n&&this.#h&&this.#h(this.#n),this.#n=0}};function ts(r=typeof window<"u"?window:null){try{return!!r?.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches}catch{return!1}}var Jt={loading:"Loading\u2026",loadError:"\u26A0 \uB370\uC774\uD130\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",pasteTruncated:r=>`${r}\uAC1C \uAC12\uC774 \uBC94\uC704\uB97C \uBC97\uC5B4\uB098 \uBD99\uC5EC\uB123\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`,copyIncomplete:r=>`${r}\uAC1C \uD589\uC774 \uC544\uC9C1 \uBD88\uB7EC\uC624\uC9C0 \uC54A\uC544 \uBCF5\uC0AC\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`,noData:"\uD45C\uC2DC\uD560 \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.",emptyCell:"\uBE48 \uC140",ariaGrid:"\uB370\uC774\uD130 \uADF8\uB9AC\uB4DC",sortAsc:"\u2191 \uC624\uB984\uCC28\uC21C",sortDesc:"\u2193 \uB0B4\uB9BC\uCC28\uC21C",sortShiftHint:"Shift+\uD074\uB9AD: \uB2E4\uC911 \uC815\uB82C \uCD94\uAC00",rowNumberLabel:"\uBC88\uD638",filterLabel:"\uAC80\uC0C9",filterPlaceholder:"\uAC80\uC0C9\uC5B4 \uC785\uB825\u2026",filterApply:"\uC801\uC6A9",filterReset:"\uCD08\uAE30\uD654",filterResetAll:"\uBAA8\uB4E0 \uD544\uD130 \uCD08\uAE30\uD654",filterClose:"\uB2EB\uAE30",filterDialog:r=>`${r} \uD544\uD130`,filterColorLabel:"\uC0C9\uC0C1\uC73C\uB85C \uD544\uD130",filterValuesLabel:"\uAC12\uC73C\uB85C \uD544\uD130",filterSelectAll:"(\uC804\uCCB4 \uC120\uD0DD)",filterTagPlaceholder:"\uAC12 \uAC80\uC0C9\u2026",filterTagLocalScope:"\uB85C\uB4DC\uB41C \uBC94\uC704\uC5D0\uC11C",filterTagNoMatch:"\uC77C\uCE58\uD558\uB294 \uAC12 \uC5C6\uC74C",filterTagMinChars:r=>`${r}\uAE00\uC790 \uC774\uC0C1 \uC785\uB825\uD558\uC138\uC694`,filterTagAllSelected:"\uC77C\uCE58\uD558\uB294 \uAC12\uC744 \uBAA8\uB450 \uC120\uD0DD\uD568",filterTagMore:r=>`\uC678 ${r}\uAC1C \u2014 \uAC80\uC0C9\uC5B4\uB97C \uC881\uD600\uBCF4\uC138\uC694`,filterTagSelected:r=>`\uC120\uD0DD\uD55C \uAC12 (${r})`,filterTagContains:r=>`"${r}" \uD3EC\uD568`,filterTagRemove:r=>`${r} \uC81C\uAC70`,colFreeze:"\uC5F4 \uACE0\uC815",colUnfreeze:"\uC5F4 \uACE0\uC815 \uD574\uC81C",colFreezeRight:"\uC624\uB978\uCABD \uC5F4 \uACE0\uC815",colUnfreezeRight:"\uC624\uB978\uCABD \uC5F4 \uACE0\uC815 \uD574\uC81C",colVisibility:"\uC5F4 \uD45C\uC2DC/\uC228\uAE30\uAE30\u2026",colChooserTitle:"\uC5F4 \uD45C\uC2DC/\uC228\uAE30\uAE30",colChooserApply:"\uC801\uC6A9",colChooserCancel:"\uCDE8\uC18C",colChooserSelectAll:"\uC804\uCCB4 \uC120\uD0DD",colInsertLeft:"\uC67C\uCABD\uC5D0 \uC5F4 \uC0BD\uC785",colInsertRight:"\uC624\uB978\uCABD\uC5D0 \uC5F4 \uC0BD\uC785",colInsertTitle:"\uC5F4 \uCD94\uAC00",colInsertPlaceholder:"\uC5F4 \uC774\uB984 \uC785\uB825",colInsertConfirm:"\uCD94\uAC00",colInsertCancel:"\uCDE8\uC18C",colDelete:"\uC774 \uC5F4 \uC0AD\uC81C",colUndelete:"\uC0AD\uC81C \uCDE8\uC18C",rowInsertTop:"\uB9E8 \uC704\uC5D0 \uD589 \uC0BD\uC785",rowInsertBottom:"\uB9E8 \uC544\uB798\uC5D0 \uD589 \uC0BD\uC785",rowInsertAbove:"\uC704\uC5D0 \uD589 \uC0BD\uC785",rowInsertBelow:"\uC544\uB798\uC5D0 \uD589 \uC0BD\uC785",rowAddEnd:"\uD589 \uCD94\uAC00",rowDelete:"\uC774 \uD589 \uC0AD\uC81C",rowDeleteMark:"\uC774 \uD589 \uC0AD\uC81C \uD45C\uC2DC",rowDeletePermanent:"\uC774 \uD589 \uC644\uC804 \uC0AD\uC81C",rowUndelete:"\uC0AD\uC81C \uCDE8\uC18C",editAriaLabel:(r,t)=>`${r} \uD3B8\uC9D1, ${t}\uD589`,announceCell:(r,t,e)=>`${r}\uD589 ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} \uC5F4 \uBA38\uB9AC\uAE00. Enter: \uC815\uB82C/\uD544\uD130 \uBA54\uB274. \uBA54\uB274 \uD0A4: \uC5F4 \uC635\uC158.`,rowHeaderAnnounce:r=>`${r}\uD589. \uBA54\uB274 \uD0A4: \uD589 \uC635\uC158.`,rowReorderAnnounce:(r,t)=>`${r}\uD589\uC744 ${t}\uD589 \uC704\uCE58\uB85C \uC774\uB3D9\uD588\uC2B5\uB2C8\uB2E4.`,sortAppliedAnnounce:(r,t)=>`${r} ${t==="asc"?"\uC624\uB984\uCC28\uC21C":"\uB0B4\uB9BC\uCC28\uC21C"} \uC815\uB82C \uC801\uC6A9\uB428.`,filterAppliedAnnounce:r=>`${r}\uC5D0 \uD544\uD130\uAC00 \uC801\uC6A9\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,filterClearedAnnounce:r=>`${r} \uD544\uD130\uAC00 \uCD08\uAE30\uD654\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,allFiltersClearedAnnounce:"\uBAA8\uB4E0 \uD544\uD130\uC640 \uC815\uB82C\uC774 \uCD08\uAE30\uD654\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",rowsSelectedAnnounce:r=>r===0?"\uC120\uD0DD\uC774 \uD574\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.":`${r}\uAC1C \uD589\uC774 \uC120\uD0DD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,unsavedEditsWarning:"\uC800\uC7A5\uD558\uC9C0 \uC54A\uC740 \uD3B8\uC9D1\uC774 \uC788\uC2B5\uB2C8\uB2E4. \uC774 \uBCC0\uACBD\uC744 \uC801\uC6A9\uD558\uBA74 \uD3B8\uC9D1\uC774 \uC0AD\uC81C\uB429\uB2C8\uB2E4. \uACC4\uC18D\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\uC778\uC1C4",validationRequired:r=>`${r}\uC740(\uB294) \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.`,validationPattern:r=>`${r} \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,validationMin:(r,t)=>`${r}\uC740(\uB294) ${t} \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMax:(r,t)=>`${r}\uC740(\uB294) ${t} \uC774\uD558\uC5EC\uC57C \uD569\uB2C8\uB2E4.`,validationMinLength:(r,t)=>`${r}\uC740(\uB294) \uCD5C\uC18C ${t}\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMaxLength:(r,t)=>`${r}\uC740(\uB294) \uCD5C\uB300 ${t}\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`,validationInvalid:r=>`${r} \uAC12\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,pagerFirst:"\uCCAB \uD398\uC774\uC9C0",pagerPrev:"\uC774\uC804 \uD398\uC774\uC9C0",pagerNext:"\uB2E4\uC74C \uD398\uC774\uC9C0",pagerLast:"\uB9C8\uC9C0\uB9C9 \uD398\uC774\uC9C0",pagerPageLabel:(r,t)=>`${r} / ${t} \uD398\uC774\uC9C0`,aggSum:"\uD569\uACC4:",aggAvg:"\uD3C9\uADE0:",aggCount:"\uAC1C\uC218:",aggMin:"\uCD5C\uC18C:",aggMax:"\uCD5C\uB300:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"\uD569\uACC4"};var Zt={loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026",loadError:"\u26A0 \u30C7\u30FC\u30BF\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002",pasteTruncated:r=>`${r}\u4EF6\u304C\u7BC4\u56F2\u5916\u306E\u305F\u3081\u8CBC\u308A\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,copyIncomplete:r=>`${r}\u884C\u304C\u672A\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3081\u30B3\u30D4\u30FC\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,noData:"\u8868\u793A\u3059\u308B\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093\u3002",emptyCell:"\u7A7A\u30BB\u30EB",ariaGrid:"\u30C7\u30FC\u30BF\u30B0\u30EA\u30C3\u30C9",sortAsc:"\u2191 \u6607\u9806",sortDesc:"\u2193 \u964D\u9806",sortShiftHint:"Shift+\u30AF\u30EA\u30C3\u30AF: \u8907\u6570\u30BD\u30FC\u30C8\u306B\u8FFD\u52A0",rowNumberLabel:"No.",filterLabel:"\u691C\u7D22",filterPlaceholder:"\u691C\u7D22\u8A9E\u3092\u5165\u529B\u2026",filterApply:"\u9069\u7528",filterReset:"\u30EA\u30BB\u30C3\u30C8",filterResetAll:"\u3059\u3079\u3066\u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u3092\u30EA\u30BB\u30C3\u30C8",filterClose:"\u9589\u3058\u308B",filterDialog:r=>`${r} \u30D5\u30A3\u30EB\u30BF\u30FC`,filterColorLabel:"\u8272\u3067\u30D5\u30A3\u30EB\u30BF\u30FC",filterValuesLabel:"\u5024\u3067\u30D5\u30A3\u30EB\u30BF\u30FC",filterSelectAll:"(\u3059\u3079\u3066\u9078\u629E)",filterTagPlaceholder:"\u5024\u3092\u691C\u7D22\u2026",filterTagLocalScope:"\u8AAD\u307F\u8FBC\u307F\u6E08\u307F\u306E\u7BC4\u56F2\u304B\u3089",filterTagNoMatch:"\u4E00\u81F4\u3059\u308B\u5024\u304C\u3042\u308A\u307E\u305B\u3093",filterTagMinChars:r=>`${r}\u6587\u5B57\u4EE5\u4E0A\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044`,filterTagAllSelected:"\u4E00\u81F4\u3059\u308B\u5024\u3092\u3059\u3079\u3066\u9078\u629E\u6E08\u307F",filterTagMore:r=>`\u4ED6 ${r}\u4EF6 \u2014 \u691C\u7D22\u8A9E\u3092\u7D5E\u3063\u3066\u304F\u3060\u3055\u3044`,filterTagSelected:r=>`\u9078\u629E\u3057\u305F\u5024 (${r})`,filterTagContains:r=>`"${r}" \u3092\u542B\u3080`,filterTagRemove:r=>`${r} \u3092\u524A\u9664`,colFreeze:"\u5217\u3092\u56FA\u5B9A",colUnfreeze:"\u5217\u306E\u56FA\u5B9A\u3092\u89E3\u9664",colFreezeRight:"\u53F3\u5074\u306E\u5217\u3092\u56FA\u5B9A",colUnfreezeRight:"\u53F3\u5074\u306E\u5217\u306E\u56FA\u5B9A\u3092\u89E3\u9664",colVisibility:"\u5217\u306E\u8868\u793A/\u975E\u8868\u793A\u2026",colChooserTitle:"\u5217\u306E\u8868\u793A/\u975E\u8868\u793A",colChooserApply:"\u9069\u7528",colChooserCancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",colChooserSelectAll:"\u3059\u3079\u3066\u9078\u629E",colInsertLeft:"\u5DE6\u306B\u5217\u3092\u633F\u5165",colInsertRight:"\u53F3\u306B\u5217\u3092\u633F\u5165",colInsertTitle:"\u5217\u3092\u8FFD\u52A0",colInsertPlaceholder:"\u5217\u540D\u3092\u5165\u529B",colInsertConfirm:"\u8FFD\u52A0",colInsertCancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",colDelete:"\u3053\u306E\u5217\u3092\u524A\u9664",colUndelete:"\u524A\u9664\u3092\u5143\u306B\u623B\u3059",rowInsertTop:"\u5148\u982D\u306B\u884C\u3092\u633F\u5165",rowInsertBottom:"\u672B\u5C3E\u306B\u884C\u3092\u633F\u5165",rowInsertAbove:"\u4E0A\u306B\u884C\u3092\u633F\u5165",rowInsertBelow:"\u4E0B\u306B\u884C\u3092\u633F\u5165",rowAddEnd:"\u884C\u3092\u8FFD\u52A0",rowDelete:"\u3053\u306E\u884C\u3092\u524A\u9664",rowDeleteMark:"\u3053\u306E\u884C\u306B\u524A\u9664\u30DE\u30FC\u30AF",rowDeletePermanent:"\u3053\u306E\u884C\u3092\u5B8C\u5168\u306B\u524A\u9664",rowUndelete:"\u524A\u9664\u3092\u5143\u306B\u623B\u3059",editAriaLabel:(r,t)=>`${r} \u3092\u7DE8\u96C6, ${t} \u884C\u76EE`,announceCell:(r,t,e)=>`${r} \u884C\u76EE ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} \u5217\u30D8\u30C3\u30C0\u30FC\u3002Enter: \u30BD\u30FC\u30C8/\u30D5\u30A3\u30EB\u30BF\u30FC\u30E1\u30CB\u30E5\u30FC\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u5217\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowHeaderAnnounce:r=>`${r} \u884C\u76EE\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u884C\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowReorderAnnounce:(r,t)=>`${r} \u884C\u76EE\u3092 ${t} \u884C\u76EE\u306B\u79FB\u52D5\u3057\u307E\u3057\u305F\u3002`,sortAppliedAnnounce:(r,t)=>`${r} \u3092${t==="asc"?"\u6607\u9806":"\u964D\u9806"}\u306B\u4E26\u3079\u66FF\u3048\u307E\u3057\u305F\u3002`,filterAppliedAnnounce:r=>`${r} \u306B\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u9069\u7528\u3055\u308C\u307E\u3057\u305F\u3002`,filterClearedAnnounce:r=>`${r} \u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002`,allFiltersClearedAnnounce:"\u3059\u3079\u3066\u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u3068\u30BD\u30FC\u30C8\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002",rowsSelectedAnnounce:r=>r===0?"\u9078\u629E\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002":`${r} \u884C\u304C\u9078\u629E\u3055\u308C\u307E\u3057\u305F\u3002`,unsavedEditsWarning:"\u4FDD\u5B58\u3055\u308C\u3066\u3044\u306A\u3044\u7DE8\u96C6\u5185\u5BB9\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u5909\u66F4\u3092\u9069\u7528\u3059\u308B\u3068\u7834\u68C4\u3055\u308C\u307E\u3059\u3002\u7D9A\u884C\u3057\u307E\u3059\u304B?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\u5370\u5237",validationRequired:r=>`${r} \u306F\u5FC5\u9808\u9805\u76EE\u3067\u3059\u3002`,validationPattern:r=>`${r} \u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,validationMin:(r,t)=>`${r} \u306F ${t} \u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMax:(r,t)=>`${r} \u306F ${t} \u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMinLength:(r,t)=>`${r} \u306F ${t} \u6587\u5B57\u4EE5\u4E0A\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationMaxLength:(r,t)=>`${r} \u306F ${t} \u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationInvalid:r=>`${r} \u306E\u5024\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,pagerFirst:"\u6700\u521D\u306E\u30DA\u30FC\u30B8",pagerPrev:"\u524D\u306E\u30DA\u30FC\u30B8",pagerNext:"\u6B21\u306E\u30DA\u30FC\u30B8",pagerLast:"\u6700\u5F8C\u306E\u30DA\u30FC\u30B8",pagerPageLabel:(r,t)=>`${t} \u30DA\u30FC\u30B8\u4E2D ${r} \u30DA\u30FC\u30B8\u76EE`,aggSum:"\u5408\u8A08:",aggAvg:"\u5E73\u5747:",aggCount:"\u4EF6\u6570:",aggMin:"\u6700\u5C0F:",aggMax:"\u6700\u5927:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"\u5408\u8A08"};var Qt={loading:"\u52A0\u8F7D\u4E2D\u2026",loadError:"\u26A0 \u6570\u636E\u52A0\u8F7D\u5931\u8D25\u3002",pasteTruncated:r=>`${r} \u4E2A\u503C\u8D85\u51FA\u8303\u56F4\uFF0C\u672A\u88AB\u7C98\u8D34`,copyIncomplete:r=>`${r} \u884C\u5C1A\u672A\u52A0\u8F7D\uFF0C\u672A\u88AB\u590D\u5236`,noData:"\u6682\u65E0\u6570\u636E\u3002",emptyCell:"\u7A7A\u5355\u5143\u683C",ariaGrid:"\u6570\u636E\u8868\u683C",sortAsc:"\u2191 \u5347\u5E8F",sortDesc:"\u2193 \u964D\u5E8F",sortShiftHint:"Shift+\u70B9\u51FB\uFF1A\u6DFB\u52A0\u591A\u91CD\u6392\u5E8F",rowNumberLabel:"\u5E8F\u53F7",filterLabel:"\u641C\u7D22",filterPlaceholder:"\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9\u2026",filterApply:"\u5E94\u7528",filterReset:"\u91CD\u7F6E",filterResetAll:"\u91CD\u7F6E\u6240\u6709\u7B5B\u9009",filterClose:"\u5173\u95ED",filterDialog:r=>`${r} \u7B5B\u9009`,filterColorLabel:"\u6309\u989C\u8272\u7B5B\u9009",filterValuesLabel:"\u6309\u503C\u7B5B\u9009",filterSelectAll:"(\u5168\u9009)",filterTagPlaceholder:"\u641C\u7D22\u503C\u2026",filterTagLocalScope:"\u4EC5\u6765\u81EA\u5DF2\u52A0\u8F7D\u7684\u884C",filterTagNoMatch:"\u6CA1\u6709\u5339\u914D\u7684\u503C",filterTagMinChars:r=>`\u8BF7\u8F93\u5165\u81F3\u5C11 ${r} \u4E2A\u5B57\u7B26`,filterTagAllSelected:"\u5339\u914D\u7684\u503C\u5DF2\u5168\u90E8\u9009\u62E9",filterTagMore:r=>`\u53E6\u6709 ${r} \u4E2A \u2014 \u8BF7\u7F29\u5C0F\u641C\u7D22\u8303\u56F4`,filterTagSelected:r=>`\u5DF2\u9009\u503C (${r})`,filterTagContains:r=>`\u5305\u542B "${r}"`,filterTagRemove:r=>`\u79FB\u9664 ${r}`,colFreeze:"\u51BB\u7ED3\u5217",colUnfreeze:"\u53D6\u6D88\u51BB\u7ED3\u5217",colFreezeRight:"\u51BB\u7ED3\u53F3\u4FA7\u5217",colUnfreezeRight:"\u53D6\u6D88\u51BB\u7ED3\u53F3\u4FA7\u5217",colVisibility:"\u5217\u7684\u663E\u793A/\u9690\u85CF\u2026",colChooserTitle:"\u5217\u7684\u663E\u793A/\u9690\u85CF",colChooserApply:"\u5E94\u7528",colChooserCancel:"\u53D6\u6D88",colChooserSelectAll:"\u5168\u9009",colInsertLeft:"\u5728\u5DE6\u4FA7\u63D2\u5165\u5217",colInsertRight:"\u5728\u53F3\u4FA7\u63D2\u5165\u5217",colInsertTitle:"\u6DFB\u52A0\u5217",colInsertPlaceholder:"\u8BF7\u8F93\u5165\u5217\u540D",colInsertConfirm:"\u6DFB\u52A0",colInsertCancel:"\u53D6\u6D88",colDelete:"\u5220\u9664\u6B64\u5217",colUndelete:"\u64A4\u9500\u5220\u9664",rowInsertTop:"\u5728\u9876\u90E8\u63D2\u5165\u884C",rowInsertBottom:"\u5728\u5E95\u90E8\u63D2\u5165\u884C",rowInsertAbove:"\u5728\u4E0A\u65B9\u63D2\u5165\u884C",rowInsertBelow:"\u5728\u4E0B\u65B9\u63D2\u5165\u884C",rowAddEnd:"\u6DFB\u52A0\u884C",rowDelete:"\u5220\u9664\u6B64\u884C",rowDeleteMark:"\u6807\u8BB0\u6B64\u884C\u4E3A\u5220\u9664",rowDeletePermanent:"\u5F7B\u5E95\u5220\u9664\u6B64\u884C",rowUndelete:"\u64A4\u9500\u5220\u9664",editAriaLabel:(r,t)=>`\u7F16\u8F91 ${r}\uFF0C\u7B2C ${t} \u884C`,announceCell:(r,t,e)=>`\u7B2C ${r} \u884C ${t}\uFF1A${e}`,columnHeaderAnnounce:r=>`${r} \u5217\u6807\u9898\u3002Enter\uFF1A\u6392\u5E8F/\u7B5B\u9009\u83DC\u5355\u3002\u83DC\u5355\u952E\uFF1A\u5217\u9009\u9879\u3002`,rowHeaderAnnounce:r=>`\u7B2C ${r} \u884C\u3002\u83DC\u5355\u952E\uFF1A\u884C\u9009\u9879\u3002`,rowReorderAnnounce:(r,t)=>`\u5DF2\u5C06\u7B2C ${r} \u884C\u79FB\u52A8\u5230\u7B2C ${t} \u884C\u3002`,sortAppliedAnnounce:(r,t)=>`${r} \u5DF2\u6309${t==="asc"?"\u5347\u5E8F":"\u964D\u5E8F"}\u6392\u5E8F\u3002`,filterAppliedAnnounce:r=>`\u5DF2\u5BF9 ${r} \u5E94\u7528\u7B5B\u9009\u3002`,filterClearedAnnounce:r=>`\u5DF2\u6E05\u9664 ${r} \u7684\u7B5B\u9009\u3002`,allFiltersClearedAnnounce:"\u5DF2\u6E05\u9664\u6240\u6709\u7B5B\u9009\u548C\u6392\u5E8F\u3002",rowsSelectedAnnounce:r=>r===0?"\u5DF2\u53D6\u6D88\u9009\u62E9\u3002":`\u5DF2\u9009\u62E9 ${r} \u884C\u3002`,unsavedEditsWarning:"\u60A8\u6709\u5C1A\u672A\u4FDD\u5B58\u7684\u7F16\u8F91\u5185\u5BB9\uFF0C\u6B64\u66F4\u6539\u5C06\u4E22\u5F03\u8FD9\u4E9B\u5185\u5BB9\u3002\u662F\u5426\u7EE7\u7EED\uFF1F",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\u6253\u5370",validationRequired:r=>`${r} \u4E3A\u5FC5\u586B\u9879\u3002`,validationPattern:r=>`${r} \u683C\u5F0F\u4E0D\u6B63\u786E\u3002`,validationMin:(r,t)=>`${r} \u4E0D\u80FD\u5C0F\u4E8E ${t}\u3002`,validationMax:(r,t)=>`${r} \u4E0D\u80FD\u5927\u4E8E ${t}\u3002`,validationMinLength:(r,t)=>`${r} \u81F3\u5C11\u9700\u8981 ${t} \u4E2A\u5B57\u7B26\u3002`,validationMaxLength:(r,t)=>`${r} \u6700\u591A\u5141\u8BB8 ${t} \u4E2A\u5B57\u7B26\u3002`,validationInvalid:r=>`${r} \u7684\u503C\u65E0\u6548\u3002`,pagerFirst:"\u9996\u9875",pagerPrev:"\u4E0A\u4E00\u9875",pagerNext:"\u4E0B\u4E00\u9875",pagerLast:"\u672B\u9875",pagerPageLabel:(r,t)=>`\u7B2C ${r} / ${t} \u9875`,aggSum:"\u603B\u8BA1\uFF1A",aggAvg:"\u5E73\u5747\u503C\uFF1A",aggCount:"\u8BA1\u6570\uFF1A",aggMin:"\u6700\u5C0F\u503C\uFF1A",aggMax:"\u6700\u5927\u503C\uFF1A",groupLabel:(r,t,e)=>`${r}\uFF1A${t}\uFF08${e}\uFF09`,groupFooterLabel:"\u5408\u8BA1"};var Re={loading:"Loading\u2026",loadError:"\u26A0 Failed to load data.",pasteTruncated:r=>`${r} value(s) did not fit and were not pasted`,copyIncomplete:r=>`${r} row(s) hadn't loaded yet and were not copied`,noData:"No data to display.",emptyCell:"Empty cell",ariaGrid:"Data grid",sortAsc:"\u2191 Ascending",sortDesc:"\u2193 Descending",sortShiftHint:"Shift+click: add to multi-sort",rowNumberLabel:"No.",filterLabel:"Search",filterPlaceholder:"Enter search term\u2026",filterApply:"Apply",filterReset:"Reset",filterResetAll:"Reset all filters",filterClose:"Close",filterDialog:r=>`${r} Filter`,filterColorLabel:"Filter by color",filterValuesLabel:"Filter by value",filterSelectAll:"(Select all)",filterTagPlaceholder:"Search values\u2026",filterTagLocalScope:"From loaded rows only",filterTagNoMatch:"No matching values",filterTagMinChars:r=>`Type at least ${r} characters`,filterTagAllSelected:"All matches already selected",filterTagMore:r=>`+${r} more \u2014 narrow the search`,filterTagSelected:r=>`Selected (${r})`,filterTagContains:r=>`Contains "${r}"`,filterTagRemove:r=>`Remove ${r}`,colFreeze:"Freeze column",colUnfreeze:"Unfreeze column",colFreezeRight:"Freeze columns to the right",colUnfreezeRight:"Unfreeze columns to the right",colVisibility:"Column visibility\u2026",colChooserTitle:"Column Visibility",colChooserApply:"Apply",colChooserCancel:"Cancel",colChooserSelectAll:"Select all",colInsertLeft:"Insert column left",colInsertRight:"Insert column right",colInsertTitle:"Add column",colInsertPlaceholder:"Column name",colInsertConfirm:"Add",colInsertCancel:"Cancel",colDelete:"Delete column",colUndelete:"Undo delete",rowInsertTop:"Insert row at top",rowInsertBottom:"Insert row at bottom",rowInsertAbove:"Insert row above",rowInsertBelow:"Insert row below",rowAddEnd:"Add row",rowDelete:"Delete row",rowDeleteMark:"Mark row for deletion",rowDeletePermanent:"Delete row permanently",rowUndelete:"Undo delete",editAriaLabel:(r,t)=>`Edit ${r}, row ${t}`,announceCell:(r,t,e)=>`Row ${r}, ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} column header. Enter: sort/filter menu. Context menu key: column options.`,rowHeaderAnnounce:r=>`Row ${r}. Context menu key: row options.`,rowReorderAnnounce:(r,t)=>`Moved row ${r} to position ${t}.`,sortAppliedAnnounce:(r,t)=>`${r} sorted ${t==="asc"?"ascending":"descending"}.`,filterAppliedAnnounce:r=>`Filter applied to ${r}.`,filterClearedAnnounce:r=>`Filter cleared for ${r}.`,allFiltersClearedAnnounce:"All filters and sorts cleared.",rowsSelectedAnnounce:r=>r===0?"Selection cleared.":r===1?"1 row selected.":`${r} rows selected.`,unsavedEditsWarning:"You have unsaved edits. This change will discard them. Continue?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"Print",validationRequired:r=>`${r} is required.`,validationPattern:r=>`${r} format is invalid.`,validationMin:(r,t)=>`${r} must be at least ${t}.`,validationMax:(r,t)=>`${r} must be at most ${t}.`,validationMinLength:(r,t)=>`${r} must be at least ${t} characters.`,validationMaxLength:(r,t)=>`${r} must be at most ${t} characters.`,validationInvalid:r=>`${r} is invalid.`,pagerFirst:"First page",pagerPrev:"Previous page",pagerNext:"Next page",pagerLast:"Last page",pagerPageLabel:(r,t)=>`Page ${r} of ${t}`,aggSum:"Sum:",aggAvg:"Avg:",aggCount:"Count:",aggMin:"Min:",aggMax:"Max:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"Total"};var Hs={en:Re,ko:Jt,ja:Zt,zh:Qt},Os=r=>String(r??"").toLowerCase().split("-")[0];function es(r){return Hs[Os(r)]??Re}function ss(r){return r||"en-US"}var zs={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]},It=5,Vt=8,is="touch-action:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;",os=30,ns=16,Is=500,Ws=40,Ns=120,js=220,Ys=110,Gs=90,rs=1200,Ae="position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;",ls="position:absolute;opacity:0;pointer-events:none;border:0;margin:0;padding:0;background:transparent;outline:none;",Ks={width:1200,height:700,rowHeight:28,colWidth:130,headerHeight:30,columnLetterHeader:!1,scrollbarSize:12,chunkSize:300,maxCachedChunks:50,editableCols:[],deleteMode:"mark",frozenCols:0,frozenColsRight:0,rowReorder:!1,responsive:!1,rowSelection:"none",showRowNumbers:!0};function Vs(r,t,e){let s=null,i=null;return{fetchMeta:function(o){let n=Promise.resolve(r(0,t,o));return s=n,i=o,n.then(function(l){let a=l.columns??e?.map(function(c){return c.field});if(!a)throw new Error("[JHGrid] opts.fetchPage: resolve { columns } or pass opts.columnDefs");return{totalRows:l.totalRows,columns:a}})},fetchData:function(o,n,l){let c=o===0&&n===t&&s&&i===l?s:Promise.resolve(r(o,n,l));return s=null,i=null,c.then(function(h){return{rows:h.rows}})}}}var te=class r{static _plugins=[];static use(t){r._plugins.includes(t)||(r._plugins.push(t),t.install?.(r))}static _plugin(t){return r._plugins.find(e=>e[t])?.[t]??null}_clearPlugins(t){for(let e of r._plugins)e.resetScope?.includes(t)&&e.clear?.(this)}_opts;_canvas;_container;_wrapper;_loadingEl;_liveRegion;_a11yHead;_a11yBody;_a11yActiveRow;_a11yActiveCell;_dm;_renderer;_scrollTop=0;_scrollLeft=0;_ticking=!1;_drag=null;_totalRows=0;_columns=[];_columnLabels=[];_columnAligns=[];_columnHeaderAligns=[];_colDefMap=new Map;_edits=new Map;_editedRows=new Set;_validator;_undoMgr=new ne(100);_editTxn=null;_sel=null;_selAnchor=null;_selDragging=!1;_selDragStart=null;_dragScrollDir={dx:0,dy:0};_dragScrollPos=null;_dragScrollTimer=null;_lastCopyMissingRows=0;_isLocalData=!1;_pastedImageUrls=new Set;_headerFocusCol=null;_rowFocus=null;_colDrag=null;_colResize=null;_colContextMenu=null;_rowContextMenu=null;_cellContextMenu=null;_columnWidths=[];_columnRenderers=[];_headerCheckboxState=new Map;_editing=null;_editableCols=null;_filters=new Map;_trivialSetFilters=new Set;_searchModeCols=new Set;_sorts=[];_filterPanel=null;_quickFilter="";_rowDrag=null;_rowOrderData=null;_rowOrderGen=0;_rowOrderScanPending=!1;_rowResize=null;_uid=Math.random().toString(36).slice(2,9);_destroyed=!1;_booting=!1;_bootPromise=null;_readyResolve;_readyPromise=new Promise(t=>{this._readyResolve=t});_announceRaf=0;_schedRaf=0;_scrolling=!1;_scrollEndTimer=null;_skeletonRaf=0;_hcMq=null;_hcMqHandler=null;_dprMq=null;_dprMqHandler=null;_i18n={};_emptyEl=null;_resizeObserver=null;_ev={};_touch=null;_lastTap={time:0,row:-1,col:-1};_rowTap=null;_longPressTimer=null;_columnOriginalOrder=[];_hiddenColumns=new Map;_columnWidthMap=new Map;_colChooser=null;_newColDialog=null;_fillDrag=null;_fillPreview=null;_localRows=[];_pendingLocalState=null;_deletedRows=new Set;_serverTotal=0;_rowPlan=new ae;_localColumns=new Map;_deletedColumns=new Set;_newColSeq=1;_cellTooltip=null;_tooltipTimer=null;_errorBannerEl=null;_errorBannerTimer=null;_pagination=null;_page=0;_pagerBar=null;constructor(t){if(typeof window>"u")throw new Error("[JHGrid] JHGrid requires a browser environment. For SSR frameworks (Next.js, Nuxt, SvelteKit), import and instantiate only on the client side (e.g. inside useEffect / onMounted).");if(!t?.container)throw new Error("[JHGrid] opts.container is required");if(this._opts={...Ks,...t,theme:{...qt,locale:ss(t.locale),...t.theme??{}}},t.responsive){let s=["width","height"].filter(i=>t[i]!=null);s.length&&console.warn(`[JHGrid] opts.${s.join(" and opts.")} ${s.length>1?"are":"is"} ignored while opts.responsive is true \u2014 the container element's CSS size determines the grid size instead. Set width/height (or max-width) via CSS on the container element, not via opts.${s[0]}.`)}if(!this._opts.headerRows?.length){let s=De(t.columnDefs);s&&(this._opts.headerRows=s)}if(this._i18n={...es(t.locale),...t.i18n??{}},t.pagination?.enabled){let s=typeof t.pagination.pageSize=="number"&&t.pagination.pageSize>0?Math.floor(t.pagination.pageSize):50;this._pagination={enabled:!0,pageSize:s},this._opts.chunkSize=s}if(t.fetchPage&&!t.fetchMeta&&!t.fetchData){let s=Vs(t.fetchPage,this._opts.chunkSize,t.columnDefs);this._opts.fetchMeta=s.fetchMeta,this._opts.fetchData=s.fetchData}if(t.data&&!t.fetchMeta&&!t.fetchData&&!t.fetchPage){let s=Xe(t.data,t.columnDefs);this._opts.fetchMeta=s.fetchMeta,this._opts.fetchData=s.fetchData,this._isLocalData=!0}if(!this._opts.fetchMeta)throw new Error("[JHGrid] opts.fetchMeta is required (or provide opts.data / opts.fetchPage instead)");if(!this._opts.fetchData)throw new Error("[JHGrid] opts.fetchData is required (or provide opts.data / opts.fetchPage instead)");this._rowLayout=new ce(this._opts.rowHeight),this._editableCols=t.editableCols==="*"?null:new Set(t.editableCols??[]),(t.columnDefs??[]).forEach(({field:s,label:i,align:o,headerAlign:n,width:l,renderer:a,editor:c,editorOptions:h,editable:d,type:u,format:f,options:_,validation:g,button:w,aggregate:m,treeColumn:v,group:S,headerCheckbox:b})=>this._colDefMap.set(s,{label:i,align:o,headerAlign:n,width:l,renderer:a,editor:c,editorOptions:h,editable:d,type:u,format:f,options:_,validation:g,button:w,aggregate:m,treeColumn:v,group:S,headerCheckbox:b})),t.hiddenColumns?.length&&t.hiddenColumns.forEach(s=>this._hiddenColumns.set(s,null)),this._validator=new re({getColumnDef:s=>this._colDefMap.get(s),getColumnLabel:s=>this._columnLabels[this._columns.indexOf(s)]??s,getI18n:()=>this._i18n,getRowData:s=>this._getRow(s),onError:(s,i,o)=>this._opts.onValidationError?.(s,i,o)}),this._mount(),this._dm=new Yt({fetchData:(s,i)=>this._opts.fetchData(s,i,null),chunkSize:this._opts.chunkSize,maxChunks:this._opts.maxCachedChunks}),this._dm.onChunkLoaded=()=>{this._scrolling||this._schedDraw()},this._dm.onChunkError=s=>{this._opts.onChunkError?.(s),this._showErrorBanner(this._i18n.loadError)},this._imageLoadListener=()=>{this._scrolling||this._schedDraw()},Fe(this._imageLoadListener),this._renderer=new Gt(this._canvas,this._opts),this._remoteSelections=[],this._hoverRow=null,this._hoverTarget=0,this._hoverFade=new Nt({onFrame:()=>this._schedDraw()});let e=ts();this._reducedMotion=e,this._hoverFadeMs=e?0:this._opts.hoverFadeMs??Ys,this._selKey=null,this._selLast=null,this._selPrev=null,this._selMove=new Nt({value:1,onFrame:()=>this._schedDraw()}),this._selMoveMs=e?0:this._opts.selectionMoveMs??Gs,this._scrollFrom={y:0,x:0},this._scrollAim={y:0,x:0},this._scrollWrote={y:0,x:0},this._scrollEase=new Nt({value:1,onFrame:()=>this._onScrollFrame()}),this._scrollEaseMs=e?0:this._opts.scrollEaseMs??Ns,this._colSlide=null,this._colSlideTween=new Nt({value:1,onFrame:()=>this._schedDraw()}),this._colSlideMs=e?0:this._opts.columnSlideMs??js,this._bind(),this._initResizeObserver(),this._initHighContrast(),this._watchDpr(),this._boot()}_mount(){let{container:t,width:e,height:s}=this._opts,i=typeof t=="string"?document.querySelector(t):t;if(!i)throw new Error(`[JHGrid] container "${t}" not found`);this._container=i,Oe(i.ownerDocument??document),this._wrapper=document.createElement("div"),this._wrapper.className=B.root,Object.assign(this._wrapper.style,{position:"relative",overflow:"hidden",width:e+"px",height:s+"px",outline:"none"}),this._wrapper.setAttribute("role","grid"),this._wrapper.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),this._wrapper.setAttribute("aria-rowcount","0"),this._wrapper.setAttribute("aria-colcount","0"),this._wrapper.setAttribute("aria-busy","true");let o=r._plugin("rowSelection")?.modeFor(this)??"none";o!=="none"&&this._wrapper.setAttribute("aria-multiselectable",String(o==="multi")),this._wrapper.tabIndex=-1,i.appendChild(this._wrapper),this._kbProxy=document.createElement("input"),this._kbProxy.type="text",this._kbProxy.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),this._kbProxy.tabIndex=0,this._kbProxy.style.cssText=ls,this._kbProxy.remove=()=>this._resetKbProxy(),this._wrapper.appendChild(this._kbProxy);let n=window.devicePixelRatio||1;this._canvas=document.createElement("canvas"),this._canvas.width=Math.round(e*n),this._canvas.height=Math.round(s*n),this._canvas.style.cssText=`display:block;width:${e}px;height:${s}px;outline:none;${is}`,this._canvas.setAttribute("aria-hidden","true"),this._canvas.tabIndex=-1,this._canvas.getContext("2d").scale(n,n),this._wrapper.appendChild(this._canvas),this._loadingEl=Object.assign(document.createElement("div"),{textContent:this._i18n.loading}),this._loadingEl.className=B.loading,Object.assign(this._loadingEl.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.9)",fontSize:"14px",color:y(this._opts.theme,"overlayMutedText"),fontFamily:y(this._opts.theme,"fontFamily")}),this._wrapper.appendChild(this._loadingEl),this._liveRegion=document.createElement("div"),this._liveRegion.setAttribute("aria-live","polite"),this._liveRegion.setAttribute("aria-atomic","true"),this._liveRegion.style.cssText=Ae,this._wrapper.appendChild(this._liveRegion),this._a11yHead=document.createElement("div"),this._a11yHead.setAttribute("role","rowgroup"),this._a11yHead.style.cssText=Ae,this._wrapper.appendChild(this._a11yHead),this._a11yBody=document.createElement("div"),this._a11yBody.setAttribute("role","rowgroup"),this._a11yBody.style.cssText=Ae,this._a11yActiveRow=document.createElement("div"),this._a11yActiveRow.setAttribute("role","row"),this._a11yActiveRow.setAttribute("aria-rowindex","2"),this._a11yActiveCell=document.createElement("div"),this._a11yActiveCell.setAttribute("role","gridcell"),this._a11yActiveCell.setAttribute("aria-colindex","1"),this._a11yActiveCell.setAttribute("aria-selected","false"),this._a11yActiveCell.id=`jhgrid-${this._uid}-cell`,this._a11yActiveRow.appendChild(this._a11yActiveCell),this._a11yBody.appendChild(this._a11yActiveRow),this._wrapper.appendChild(this._a11yBody);for(let l of r._plugins)l.onMount?.(this);this._emptyEl=document.createElement("div"),this._emptyEl.className=B.empty,Object.assign(this._emptyEl.style,{position:"absolute",inset:"0",display:"none",alignItems:"center",justifyContent:"center",fontSize:"14px",pointerEvents:"none",color:y(this._opts.theme,"overlayHintText"),fontFamily:y(this._opts.theme,"fontFamily")}),this._emptyEl.textContent=this._i18n.noData,this._wrapper.appendChild(this._emptyEl),this._cellTooltip=document.createElement("div"),this._cellTooltip.className=B.tooltip,this._cellTooltip.style.cssText=["position:absolute","background:#212121","color:#FFFFFF","border-radius:4px","padding:5px 9px","font-size:12px","pointer-events:none","z-index:160","max-width:320px","white-space:pre-wrap","word-break:break-all","display:none","box-shadow:0 4px 12px rgba(0,0,0,0.22)",`font-family:${y(this._opts.theme,"fontFamily")}`].join(";"),this._wrapper.appendChild(this._cellTooltip),this._pagination&&this._buildPagerBar()}_buildPagerBar(){let t=this._opts.theme,e=(...h)=>h.join(";"),s=document.createElement("nav");s.setAttribute("aria-label","Pagination"),s.className=B.pager,s.style.cssText=e("display:flex","align-items:center","justify-content:center","gap:4px","padding:8px 12px",`border-top:1px solid ${y(t,"pagerBorder")}`,`background:${y(t,"pagerBg")}`,`font-size:${t.fontSize}px`,`color:${y(t,"pagerText")}`,`font-family:${y(t,"fontFamily")}`,`width:${this._opts.width}px`,"box-sizing:border-box","user-select:none");let i=(h,d,u)=>{let f=document.createElement("button");return f.type="button",f.textContent=h,f.setAttribute("aria-label",d),f.className=B.pagerBtn,f.style.cssText=e("padding:4px 10px",`border:1px solid ${y(t,"pagerButtonBorder")}`,"border-radius:4px",`background:${y(t,"pagerButtonBg")}`,"cursor:pointer",`font-size:${t.fontSize}px`,`color:${y(t,"pagerText")}`,"min-width:28px"),f.addEventListener("click",u),f},o=i("\xAB",this._i18n.pagerFirst,()=>this.goToPage(0)),n=i("\u2039",this._i18n.pagerPrev,()=>this.prevPage()),l=document.createElement("span");l.style.cssText="display:flex;align-items:center;gap:4px;margin:0 4px;";let a=i("\u203A",this._i18n.pagerNext,()=>this.nextPage()),c=i("\xBB",this._i18n.pagerLast,()=>this.goToPage(this._pageCount()-1));s.append(o,n,l,a,c),this._container.appendChild(s),this._pagerBar={el:s,firstBtn:o,prevBtn:n,numbers:l,nextBtn:a,lastBtn:c},this._updatePagerBar()}_pagerPageWindow(){let t=this._pageCount(),e=this._page,s=Math.max(0,e-2),i=Math.min(t-1,e+2),o=Math.min(4,t-1);for(;i-s<o;)if(s>0)s--;else if(i<t-1)i++;else break;return Array.from({length:i-s+1},(n,l)=>s+l)}_updatePagerBar(){if(!this._pagerBar)return;let{firstBtn:t,prevBtn:e,numbers:s,nextBtn:i,lastBtn:o}=this._pagerBar,n=this._pageCount(),l=this._page,a=this._opts.theme,c=(...h)=>h.join(";");t.disabled=e.disabled=l<=0,o.disabled=i.disabled=l>=n-1,this._pagerBar.el.setAttribute("aria-label",this._i18n.pagerPageLabel(l+1,n)),s.replaceChildren(),this._pagerPageWindow().forEach(h=>{let d=h===l,u=document.createElement("button");u.type="button",u.textContent=String(h+1),u.className=B.pagerBtn,u.style.cssText=c("padding:4px 9px","border-radius:4px","cursor:pointer",`font-size:${a.fontSize}px`,`border:1px solid ${d?y(a,"selectionColor"):y(a,"pagerButtonBorder")}`,`background:${d?y(a,"selectionColor"):y(a,"pagerButtonBg")}`,`color:${d?y(a,"overlayAccentText"):y(a,"pagerText")}`,`font-weight:${d?"600":"400"}`),d&&u.setAttribute("aria-current","page"),u.addEventListener("click",()=>this.goToPage(h)),s.appendChild(u)})}_showErrorBanner(t,e=4e3){this._errorBannerEl||(this._errorBannerEl=document.createElement("div"),this._errorBannerEl.setAttribute("role","alert"),this._errorBannerEl.setAttribute("aria-live","assertive"),this._errorBannerEl.setAttribute("aria-atomic","true"),Object.assign(this._errorBannerEl.style,{position:"absolute",top:"4px",left:"50%",transform:"translateX(-50%)",background:"#fee2e2",color:"#991b1b",border:"1px solid #fca5a5",borderRadius:"4px",padding:"6px 14px",fontSize:"12px",fontFamily:qt.fontFamily,zIndex:"10",whiteSpace:"nowrap",pointerEvents:"none"}),this._wrapper.appendChild(this._errorBannerEl)),this._errorBannerEl.textContent=t,this._errorBannerEl.style.display="block",clearTimeout(this._errorBannerTimer),this._errorBannerTimer=setTimeout(()=>{this._errorBannerEl&&(this._errorBannerEl.style.display="none")},e)}_initResizeObserver(){if(!this._opts.responsive||!window.ResizeObserver)return;let t=this._container.getBoundingClientRect();t.width>0&&t.height>0&&this._setSize(Math.floor(t.width),Math.floor(t.height)),this._resizeObserver=new ResizeObserver(e=>{let{width:s,height:i}=e[0].contentRect;s>0&&i>0&&this._setSize(Math.floor(s),Math.floor(i))}),this._resizeObserver.observe(this._container)}_setSize(t,e){if(this._destroyed)return;let s=this._pagerBar?this._pagerBar.el.offsetHeight:0,i=Math.max(0,e-s);this._opts.width=t,this._opts.height=i,this._wrapper.style.width=t+"px",this._wrapper.style.height=i+"px",this._canvas.style.cssText=`display:block;width:${t}px;height:${i}px;outline:none;${is}`;let o=window.devicePixelRatio||1;this._canvas.width=Math.round(t*o),this._canvas.height=Math.round(i*o),this._canvas.getContext("2d").setTransform(o,0,0,o,0,0),this._pagerBar&&(this._pagerBar.el.style.width=t+"px"),this._clamp(this._geo()),this._draw()}_announce(t){cancelAnimationFrame(this._announceRaf),this._liveRegion.textContent="",this._announceRaf=requestAnimationFrame(()=>{this._liveRegion.textContent=t})}_updateA11yHeader(){this._a11yHead.replaceChildren(),this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._wrapper.setAttribute("aria-colcount",String(this._columns.length));let t=document.createElement("div");t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1"),this._columnLabels.forEach((e,s)=>{let i=document.createElement("div");i.setAttribute("role","columnheader"),i.setAttribute("aria-colindex",String(s+1)),i.id=`jhgrid-${this._uid}-header-${s}`;let o=this._columns[s],n=this._sorts.find(l=>l.field===o);n&&i.setAttribute("aria-sort",n.dir==="asc"?"ascending":"descending"),i.textContent=e,t.appendChild(i)}),this._a11yHead.appendChild(t),this._headerFocusCol!==null&&(this._a11yActiveCell.setAttribute("aria-selected","false"),this._wrapper.setAttribute("aria-activedescendant",`jhgrid-${this._uid}-header-${this._headerFocusCol}`))}_updateA11yCell(){if(this._headerFocusCol!==null||this._rowFocus!==null)return;if(!this._sel){this._wrapper.removeAttribute("aria-activedescendant"),this._a11yActiveRow.setAttribute("aria-selected","false"),this._a11yActiveCell.setAttribute("aria-selected","false"),this._a11yActiveCell.removeAttribute("aria-invalid"),this._a11yActiveCell.textContent="";return}let t=this._sel.type==="single"?this._sel.row:this._sel.r1,e=this._sel.type==="single"?this._sel.col:this._sel.c1,s=this._columns[e],i=this._columnLabels[e]??s??"",o=this._cellVal(t,e),n=this._validator.map.get(`${t}_${s}`);this._a11yActiveRow.setAttribute("aria-rowindex",String(t+2)),this._a11yActiveRow.setAttribute("aria-selected",String(!!r._plugin("rowSelection")?.has(this,t))),this._a11yActiveCell.setAttribute("aria-colindex",String(e+1)),this._a11yActiveCell.setAttribute("aria-selected","true"),n?(this._a11yActiveCell.setAttribute("aria-invalid","true"),this._a11yActiveCell.setAttribute("aria-label",`${i}: ${o||this._i18n.emptyCell}. ${n}`)):(this._a11yActiveCell.removeAttribute("aria-invalid"),this._a11yActiveCell.setAttribute("aria-label",`${i}: ${o||this._i18n.emptyCell}`)),this._a11yActiveCell.textContent=o,this._wrapper.setAttribute("aria-activedescendant",`jhgrid-${this._uid}-cell`)}_enterHeaderFocus(t){this._headerFocusCol=t,this._updateA11yHeader();let e=this._sel?.type==="single"?this._sel.row:this._sel?.r1??0;this._ensureVisible(e,t),this._announce(this._i18n.columnHeaderAnnounce(this._columnLabels[t]??this._columns[t])),this._draw()}_exitHeaderFocus(){let t=this._headerFocusCol;this._headerFocusCol=null,this._updateA11yHeader();let e=this._sel?.type==="single"?this._sel.row:this._sel?.r1??0;this._setSel({type:"single",row:e,col:t}),this._selAnchor=null,this._updateA11yCell(),this._announce(this._i18n.announceCell(e+1,this._columnLabels[t]??this._columns[t],this._cellVal(e,t)||this._i18n.emptyCell)),this._draw()}_handleHeaderFocusKey(t){let e=this._headerFocusCol;if(t.key==="ArrowLeft"){t.preventDefault(),e>0&&this._enterHeaderFocus(e-1);return}if(t.key==="ArrowRight"){t.preventDefault(),e<this._columns.length-1&&this._enterHeaderFocus(e+1);return}if(t.key==="ArrowDown"||t.key==="Escape"){t.preventDefault(),this._exitHeaderFocus();return}if(t.key==="Enter"||t.key==="F2"||t.key===" "){t.preventDefault(),this._openFilterPanel(e);return}if(t.key==="ContextMenu"||t.shiftKey&&t.key==="F10"){t.preventDefault();let s=this._geo();this._openColContextMenu(e,this._colLeft(e,s),s.headerH)}}_enterRowFocus(t){this._rowFocus=t,this._ensureVisible(t,0),this._announce(this._i18n.rowHeaderAnnounce(t+1)),this._draw()}_exitRowFocus(){let t=this._rowFocus;this._rowFocus=null,this._setSel({type:"single",row:t,col:0}),this._selAnchor=null,this._updateA11yCell(),this._announce(this._i18n.announceCell(t+1,this._columnLabels[0]??this._columns[0],this._cellVal(t,0)||this._i18n.emptyCell)),this._draw()}_handleRowFocusKey(t){let e=this._rowFocus;if(t.key==="ArrowUp"){t.preventDefault(),e>0&&this._enterRowFocus(e-1);return}if(t.key==="ArrowDown"){t.preventDefault(),e<this._totalRows-1&&this._enterRowFocus(e+1);return}if(t.key==="ArrowRight"||t.key==="Escape"){t.preventDefault(),this._exitRowFocus();return}if((t.key==="Enter"||t.key===" ")&&(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"){t.preventDefault(),this._updateRowSel(e,t.ctrlKey||t.metaKey,t.shiftKey),this._draw();return}if(t.key==="ContextMenu"||t.shiftKey&&t.key==="F10"){t.preventDefault();let s=this._geo();this._closeFilterPanel(),this._closeColContextMenu(),this._closeCellContextMenu(),this._openRowContextMenu(e,0,this._rowLayout.yOf(e)-this._scrollTop+s.headerH)}}_focusDefaultCell(){this._setSel({type:"single",row:0,col:0}),this._selAnchor=null,this._ensureVisible(0,0),this._updateA11yCell(),this._announce(this._i18n.announceCell(1,this._columnLabels[0]??this._columns[0],this._cellVal(0,0)||this._i18n.emptyCell)),this._draw()}_watchDpr(){if(!window.matchMedia)return;this._dprMq?.removeEventListener("change",this._dprMqHandler);let t=window.devicePixelRatio||1;this._dprMq=window.matchMedia(`(resolution: ${t}dppx)`),this._dprMqHandler=()=>{this._resizeCanvas(),this._watchDpr()},this._dprMq.addEventListener("change",this._dprMqHandler)}_resizeCanvas(){this._setSize(this._opts.width,this._opts.height)}_initHighContrast(){if(!window.matchMedia)return;this._hcMq=window.matchMedia("(forced-colors: active)");let t={...this._opts.theme};this._hcMqHandler=e=>{e.matches?Object.assign(this._opts.theme,{headerBg:"ButtonFace",headerText:"ButtonText",headerBorder:"ButtonBorder",rowEven:"Canvas",rowOdd:"Canvas",cellBorder:"ButtonBorder",cellText:"CanvasText",loadingText:"GrayText",selectionColor:"Highlight",selectionFill:"rgba(0,0,0,0)",scrollbarBg:"Canvas",scrollbarThumb:"ButtonText",frozenBorder:"ButtonBorder",dragIndicatorFill:"ButtonFace",dragIndicatorLine:"Highlight",deletedRowFill:"ButtonFace",deletedRowStrike:"GrayText",invalidCellBorder:"Mark"}):Object.assign(this._opts.theme,t),this._draw()},this._hcMq.addEventListener("change",this._hcMqHandler),this._hcMqHandler(this._hcMq)}_pageBounds(){if(!this._pagination)return{start:0,rows:this._totalRows};let t=this._page*this._pagination.pageSize,e=Math.max(0,Math.min(this._pagination.pageSize,this._totalRows-t));return{start:t,rows:e}}_pageCount(){return this._pagination?Math.max(1,Math.ceil(this._totalRows/this._pagination.pageSize)):1}_switchToPage(t){if(!this._pagination||this._destroyed)return;let e=this._pageCount(),s=Math.max(0,Math.min(e-1,Math.trunc(t))),i=s!==this._page;this._editing&&this._commitEdit(),this._page=s,this._sel=null,this._selAnchor=null,this._scrollTop=this._rowLayout.yOf(s*this._pagination.pageSize),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._updatePagerBar(),i&&(this._opts.onPageChange?.(this._page,e),this._announce(this._i18n.pagerPageLabel(this._page+1,e))),this._draw()}get _headerH(){return this._opts.headerHeight*((this._opts.headerRows?.length??0)+1+(this._opts.columnLetterHeader?1:0))}_geo(){let{colWidth:t,scrollbarSize:e,width:s,height:i}=this._opts,o=this._headerH,n=Math.max(0,Math.min(this._opts.frozenCols??0,this._columns.length)),l=this._columns.length,a=this._opts.showRowNumbers?this._opts.rowNumberWidth??50:0,c=new Array(l+1);c[0]=a;for(let D=0;D<l;D++)c[D+1]=c[D]+(this._columnWidths[D]??t);let h=c[n],d=Math.min(t,s);for(;n>0&&h>s-d;)n--,h=c[n];let u=Math.max(0,Math.min(this._opts.frozenColsRight??0,l-n)),f=c[l]-c[l-u];for(;u>0&&h+f>s-d;)u--,f=c[l]-c[l-u];let _=c[l-u]-h,g=r._plugins.reduce((D,L)=>D+(L.footerBandHeight?.(this)??0),0),w=i-o-g,m=Math.max(0,s-h-f),{start:v,rows:S}=this._pageBounds(),b=this._rowLayout.yOf(v),E=this._rowLayout.yOf(v+S)-b,C=E>w,T=_>m;C&&!T&&(T=_>Math.max(0,m-e)),T&&!C&&(C=E>w-e);let $=C?e:0,M=T?e:0,j=w-M,O=Math.max(0,m-$),V=s-$-f,P=b,H=P+Math.max(0,E-j),R=Math.max(0,_-O),F=j,A=E>0?Math.max(24,F*(j/E)):F,it=H-P,z=o+(it>0?(this._scrollTop-P)/it*(F-A):0),G=O,x=_>0?Math.max(24,G*(O/_)):G,k=h+(R>0?this._scrollLeft/R*(G-x):0);return{SB:e,vSB:$,hSB:M,vpH:j,vpW:O,frozenCount:n,frozenWidth:h,frozenRightCount:u,frozenRightWidth:f,rightX:V,minScrollY:P,maxScrollY:H,maxScrollX:R,colPositions:c,headerH:o,footerH:g,rowNumW:a,maxRow:v+S-1,v:{x:s-$,y:o,w:C?e:0,h:C?F:0,thumbY:z,thumbH:A},h:{x:h,y:i-M,w:T?G:0,h:T?e:0,thumbX:k,thumbW:x}}}_colAtX(t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o,rightX:n,colPositions:l,rowNumW:a}=e,c=this._columns.length;if(c===0||t<a)return null;if(t<i){for(let u=0;u<s;u++)if(t<l[u+1])return u;return null}if(o>0&&t>=n){let u=c-o,f=t-n+l[u];for(let _=u;_<c;_++)if(f<l[_+1])return _;return null}let h=c-o,d=t-i+this._scrollLeft+l[s];for(let u=s;u<h;u++)if(d<l[u+1])return u;return null}_hitCell(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:l,vSB:a}=s;if(e<n||e>o-l||t<0||t>i-a)return null;let c=this._rowLayout.rowAt(e-n+this._scrollTop,this._totalRows-1);if(c<0)return null;let h=this._colAtX(t,s);return h===null?null:{row:c,col:h}}_hitCellClamped(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:l,vSB:a,rowNumW:c}=s;if(this._totalRows===0||this._columns.length===0)return null;let h=Math.max(n,Math.min(o-l-1,e)),d=Math.max(c,Math.min(i-a-1,t)),u=this._rowLayout.rowAt(h-n+this._scrollTop,this._totalRows-1);if(u<0)return null;let f=this._colAtX(d,s);return f===null?null:{row:u,col:f}}_hitHeader(t,e=this._geo()){let{width:s}=this._opts;return t<0||t>s-e.vSB||t<e.rowNumW?null:this._colAtX(t,e)}_hitRowNumber(t,e,s=this._geo()){let{height:i}=this._opts;if(s.rowNumW===0||t<0||t>=s.rowNumW||e<s.headerH||e>=i-s.hSB)return null;let o=this._rowLayout.rowAt(e-s.headerH+this._scrollTop,this._totalRows-1);return o<0?null:o}_hitRowBoundary(t,e=this._geo(),s=It){let{height:i}=this._opts;if(t<e.headerH||t>=i-e.hSB)return null;let o=t-e.headerH+this._scrollTop,n=this._rowLayout.rowAt(o,this._totalRows-1);if(n<0)return null;let l=this._rowLayout.yOf(n+1)-this._scrollTop+e.headerH;if(Math.abs(t-l)<=s)return n;if(n>0){let a=this._rowLayout.yOf(n)-this._scrollTop+e.headerH;if(Math.abs(t-a)<=s)return n-1}return null}_hitScrollbar(t,e,s){let{v:i,h:o}=s;if(t>=i.x){if(e>=i.thumbY&&e<=i.thumbY+i.thumbH)this._drag={axis:"v",startMouse:e,startScroll:this._scrollTop};else if(e>=i.y&&e<=i.y+i.h){let n=Math.max(0,Math.min(1,(e-i.y-i.thumbH/2)/(i.h-i.thumbH)));this._scrollTop=s.minScrollY+n*(s.maxScrollY-s.minScrollY),this._clamp(s),this._draw()}return!0}if(e>=o.y){if(t>=o.thumbX&&t<=o.thumbX+o.thumbW)this._drag={axis:"h",startMouse:t,startScroll:this._scrollLeft};else if(t>=o.x&&t<=o.x+o.w){let n=Math.max(0,Math.min(1,(t-o.x-o.thumbW/2)/(o.w-o.thumbW)));this._scrollLeft=n*s.maxScrollX,this._clamp(s),this._draw()}return!0}return!1}_updateScrollbarDrag(t,e){let s=this._geo(),{v:i,h:o}=s;if(this._drag.axis==="v"){let n=(e-this._drag.startMouse)/(i.h-i.thumbH);this._scrollTop=this._drag.startScroll+n*(s.maxScrollY-s.minScrollY)}else{let n=(t-this._drag.startMouse)/(o.w-o.thumbW);this._scrollLeft=this._drag.startScroll+n*s.maxScrollX}this._clamp(s),this._scrolling=!0,this._dm.setHold(!0),clearTimeout(this._scrollEndTimer),this._scrollEndTimer=setTimeout(()=>{this._scrolling=!1,this._dm.setHold(!1),this._schedDraw()},150),this._schedDraw()}_hitFillHandle(t,e,s=this._geo(),i=It){if(!this._sel)return!1;let{headerH:o,colPositions:n}=s,l=this._sel.type==="single"?this._sel.row:this._sel.r2,a=this._sel.type==="single"?this._sel.col:this._sel.c2,c=this._colLeft(a,s)+(n[a+1]-n[a]),h=this._rowLayout.yOf(l+1)-this._scrollTop+o;return Math.abs(t-c)<=i&&Math.abs(e-h)<=i}_colLeft(t,e){return ee(t,e,this._scrollLeft)}_autoFitCol(t){let e=this._canvas.getContext("2d"),{theme:s}=this._opts,i=s.cellPadding,o=this._columns[t],n=this._columnLabels[t]??o;e.font=`bold ${s.fontSize}px ${s.fontFamily}`;let l=this._colDefMap.get(o)?.headerCheckbox?20:0,a=e.measureText(n).width+i*2+Bt+4+l,c=this._colDefMap.get(o),h=c?.type,d=h==="dropdown"||h==="multiselect"?se:0,u=s.locale;e.font=`${s.fontSize}px ${s.fontFamily}`,this._dm.forEachLoaded(_=>{let g=_?.[o];if(g==null)return;let w=Kt(g,c,u),m=e.measureText(String(w)).width+i*2+d;m>a&&(a=m)}),this._edits.forEach((_,g)=>{let w=g.indexOf("_");if(w===-1||g.slice(w+1)!==o)return;let m=Kt(_,c,u),v=e.measureText(String(m)).width+i*2+d;v>a&&(a=v)});let f=Math.max(os,Math.ceil(a));this._columnWidths[t]=f,this._columnWidthMap.set(o,f)}_selectedColsForAutoFit(){if(this._sel&&this._sel.type==="range"){let t=new Set;for(let e=this._sel.c1;e<=this._sel.c2;e++)t.add(e);return t}return null}_calcInsertBefore(t,e=this._geo()){let{width:s}=this._opts,{colPositions:i}=e,o=this._columns.length;if(t<=0)return 0;if(t>=s-e.vSB)return o;let n=this._colAtX(t,e)??0,l=this._colLeft(n,e),a=i[n+1]-i[n];return t>l+a/2?n+1:n}_startColSlide(t,e,s){if(this._colSlideMs===0){this._colSlide=null;return}let[i,o,n]=e>t?[t,e-1,t+1]:[e+1,t,e],l=this._geo().colPositions,a=s[n]-l[i];if(!a){this._colSlide=null;return}this._colSlide={c1:i,c2:o,dx:a,dragCol:e},this._colSlideTween.set(0),this._colSlideTween.to(1,this._colSlideMs)}_reorderCol(t,e,{silent:s=!1}={}){if(e===t||e===t+1)return t;this._commitEdit();let i=e>t?e-1:e,o=a=>{let c=[...a];return c.splice(i,0,c.splice(t,1)[0]),c},n=this._columns.length;this._columns=o(this._columns),this._columnLabels=o(this._columnLabels),this._columnAligns=o(this._columnAligns),this._columnHeaderAligns=o(this._columnHeaderAligns),this._columnWidths=o(this._columnWidths),this._columnRenderers=o(this._columnRenderers);let l=new Map;for(let a=0;a<n;a++)a===t?l.set(a,i):e>t&&a>t&&a<=i?l.set(a,a-1):e<t&&a>=i&&a<t?l.set(a,a+1):l.set(a,a);if(this._sel){let a=c=>l.get(c)??c;if(this._sel.type==="single")this._sel={...this._sel,col:a(this._sel.col)};else{let{r1:c,c1:h,r2:d,c2:u}=this._sel;this._sel={type:"range",...this._normRange(c,a(h),d,a(u))}}}return this._updateA11yHeader(),this._updateA11yCell(),s||this._opts.onColumnReorder?.([...this._columns]),i}_rowReorderReady(){return!!this._opts.rowReorder&&Array.isArray(this._rowOrderData)&&!r._plugins.some(t=>t.altRowSource?.(this))}async _materializeRowOrder(){if(this._rowOrderScanPending)return;this._rowOrderScanPending=!0;let t=this._rowOrderGen;try{let e=await this._scanAllRows();if(this._destroyed||e===null||t!==this._rowOrderGen||!this._opts.rowReorder||r._plugins.some(s=>s.altRowSource?.(this)))return;this._rowOrderData=e,this._applyDisplayFetch(e),this._draw()}finally{this._rowOrderScanPending=!1}}_calcRowInsertBefore(t,e=this._geo()){let s=t-e.headerH+this._scrollTop,i=this._rowPlan.serverVisible-1;if(i<0||s<=0)return 0;let o=this._rowLayout.rowAt(s,i);if(o<0)return this._rowPlan.serverVisible;let n=this._rowLayout.yOf(o),l=this._rowLayout.heightOf(o);return s-n<l/2?o:o+1}_reorderRow(t,e){if(!this._rowOrderData||e===t||e===t+1)return;let s=e>t?e-1:e,i;this._rebuildDisplayFetch(()=>([i]=this._rowOrderData.splice(t,1),this._rowOrderData.splice(s,0,i),this._rowOrderData))&&(this._opts.onRowReorder?.(t,s,i),this._announce(this._i18n.rowReorderAnnounce(t+1,s+1)))}_filterState(){return{sorts:[...this._sorts],filters:Object.fromEntries(this._filters),quickFilter:this._quickFilter}}_snapshotLocalRowState(){if(this._localRows.length===0)return null;let t=s=>{let i=[];return s.forEach((o,n)=>{let l=n.indexOf("_"),a=this._localIndexAt(Number(n.slice(0,l)));a>=0&&i.push([a,n.slice(l+1),o])}),i},e=[];return this._rowLayout.snapshotOverrides().forEach((s,i)=>{let o=this._localIndexAt(i);o>=0&&e.push([o,s])}),{edits:t(this._edits),invalid:t(this._validator.map),heights:e}}_restoreLocalRowState(){let t=this._pendingLocalState;if(this._pendingLocalState=null,!t)return;let e=s=>this._rowPlan.visualOfLocal(s);for(let[s,i,o]of t.edits)this._edits.set(`${e(s)}_${i}`,o),this._editedRows.add(e(s));for(let[s,i,o]of t.invalid)this._validator.map.set(`${e(s)}_${i}`,o);if(t.heights.length>0){let s=this._rowLayout.snapshotOverrides();for(let[i,o]of t.heights)s.set(e(i),o);this._rowLayout.restoreOverrides(s)}}_reloadFiltered({confirmUnsaved:t=!0,carryRows:e=!0}={}){if(t){let n=0;if(this._edits.forEach((l,a)=>{this._localIndexAt(Number(a.slice(0,a.indexOf("_"))))<0&&n++}),n>0&&!window.confirm(this._i18n.unsavedEditsWarning))return null}this._pendingLocalState=e?this._snapshotLocalRowState():null,e||(this._localRows.length=0,this._rowPlan.anchors.length=0);let s=this._filterState();this._cancelEdit(),this._closeRowContextMenu(),this._closeCellContextMenu();for(let n of r._plugins)n.hideTooltip?.(this);if(this._cellTooltip.style.display="none",this._clearPlugins("rowIndexState"),this._clearPlugins("altView"),this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._rowLayout.clear(),this._sel=null,this._fillDrag=null,this._fillPreview=null,this._deletedRows.clear(),this._rowPlan.removed.clear(),this._rowPlan.detachAnchors(),this._undoMgr.clear(),this._editTxn=null,this._scrollTop=0,this._page=0,this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._opts.onSort?.(this._sorts.length>0?[...this._sorts]:null),this._opts.onFilter?.(Object.fromEntries(this._filters)),r._plugins.some(n=>n.bootOverride?.(this,s)))return this._pendingLocalState=null,Promise.resolve();let o=this._isLocalData?(()=>{let n=null;return(l,a)=>(n??=this._opts.fetchData(0,Number.MAX_SAFE_INTEGER,s).then(c=>c.rows),n.then(c=>({rows:c.slice(l*a,l*a+a)})))})():(n,l)=>this._opts.fetchData(n,l,s);return this._dm.setFetch(o),this._boot(s)}_skeletonPhase(){if(this._reducedMotion)return null;let t=this._geo(),e=Math.max(0,this._rowLayout.rowAt(this._scrollTop,this._totalRows-1)),s=Math.min(this._totalRows-1,this._rowLayout.rowAt(this._scrollTop+t.vpH,this._totalRows-1)),i=!1;for(let o=e;o<=s;o++)if(this._rowSource(o)==null){i=!0;break}return i?(this._skeletonRaf||(this._skeletonRaf=requestAnimationFrame(()=>{this._skeletonRaf=0,this._draw()})),performance.now()%rs/rs):(this._skeletonRaf&&(cancelAnimationFrame(this._skeletonRaf),this._skeletonRaf=0),null)}_colorScanConcurrency(){let t=this._opts.colorFilterConcurrency;if(t>0)return t;let e=typeof navigator<"u"&&navigator.hardwareConcurrency||4;return Math.max(2,Math.min(8,e))}async _forEachFilteredRow(t,e){for(let o of r._plugins)if(await o.forEachFilteredRowOverride?.(this,t,e))return;let s=this._opts.chunkSize,i=0;for(;;){let{rows:o}=await this._opts.fetchData(i,s,t);if(!o?.length||(e(o,i*s),o.length<s))break;i++}}async _scanAllRows(){let t=this._filterState();this._loadingEl.textContent=this._i18n.loading;let e=await this._opts.fetchMeta(t);if(this._destroyed)return null;let s=e.totalRows,i=Math.max(1,this._opts.colorFilterPageSize||this._opts.chunkSize),o=Math.max(1,Math.ceil(s/i)),n=new Array(o),l=0,a=0,c=async()=>{for(;;){if(this._destroyed)return;let d=l++;if(d>=o)return;let{rows:u}=await this._opts.fetchData(d,i,t);if(this._destroyed)return;n[d]=u??[],a++,this._loadingEl.textContent=`${this._i18n.loading} ${Math.round(a/o*100)}%`}};if(await Promise.all(Array.from({length:Math.min(this._colorScanConcurrency(),o)},c)),this._destroyed)return null;let h=[];for(let d of n)if(d)for(let u of d)h.push(u);return h}_applyDisplayFetch(t){this._dm.setFetch((e,s)=>Promise.resolve({rows:t.slice(e*s,(e+1)*s)})),this._serverTotal=t.length,this._rowPlan.clampAnchors(t.length),this._totalRows=t.length+this._localRows.length,this._dm.prefetch(0,Math.min(this._opts.chunkSize-1,this._totalRows-1))}_isGroupRow(t){return!!this._dm.getRow(t)?.__group__}_hitTreeChevron(t,e,s){let i=this._dm.getRow(e.row);if(!i?.__treeHasChildren)return!1;let o=this._columns[e.col];if(!this._colDefMap.get(o)?.treeColumn)return!1;let n=this._colLeft(e.col,s),l=(i.__treeLevel??0)*ie;return t>=n+l&&t<=n+l+ye}_rebuildDisplayFetch(t){if(this._edits.size>0&&!window.confirm(this._i18n.unsavedEditsWarning))return!1;this._commitEdit(),this._setSel(null),this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._clearPlugins("rowIndexState"),this._rowLayout.clear(),this._undoMgr.clear();let e=t();return this._applyDisplayFetch(e),this._clamp(this._geo()),this._updateA11yHeader(),this._draw(),!0}_suggestFilterValuesLocal(t,e,s=50){let i=String(e??"").toLowerCase(),o=new Set,n=l=>{let a=l==null?"":String(l);return a===""||o.has(a)||!a.toLowerCase().includes(i)?!0:(o.add(a),o.size<s)};if(this._dm.forEachLoaded(l=>n(l?.[t])),o.size<s){for(let l of this._localRows)if(n(l?.[t])===!1)break}return[...o].sort((l,a)=>l.localeCompare(a,void 0,{numeric:!0}))}_discoverFilterValues(t,e=200){if(this._searchModeCols.has(t))return null;let s=new Set,i=!1,o=n=>{let l=n==null?"":String(n);return!s.has(l)&&(s.add(l),s.size>e)?(i=!0,!1):!0};if(this._dm.forEachLoaded(n=>o(n?.[t])),!i){for(let n of this._localRows)if(o(n?.[t])===!1)break}return i?null:[...s].sort((n,l)=>n.localeCompare(l,void 0,{numeric:!0}))}_openFilterPanel(t){this._closeFilterPanel();let e=this._geo(),s=this._columns[t],i=this._columnLabels[t]??s,o=this._filters.get(s),n=typeof o=="string"?o:"",l=this._discoverFilterValues(s);l===null?this._searchModeCols.add(s):this._searchModeCols.has(s)&&(l=null);let a=Array.isArray(o)?o:null,c=this._sorts.find($=>$.field===s),h=c?this._sorts.indexOf(c)+1:0,d={};for(let $ of r._plugins)Object.assign(d,$.filterPanelOptions?.(this,s,t));let{swatchColors:u=[],activeColor:f}=d,_=r._plugins.some($=>$.extraSortSlots),g=()=>{this._closeFilterPanel(),this._kbProxy.focus()};this._wrapper.style.overflow="visible";let w=this._wrapper.getBoundingClientRect().top,v=(window.innerHeight||document.documentElement.clientHeight)-w-e.headerH-8,S=w-8,E=v<260&&S>v,C=E?S:v,T=Ge({colLeft:this._colLeft(t,e),headerH:e.headerH,wrapperHeight:this._opts.height,openUpward:E,width:this._opts.width,maxPanelHeight:C,label:i,curVal:n,sortPriority:h,asc:c?.dir==="asc",desc:c?.dir==="desc",filterId:`jhgrid-${this._uid}-filter`,multiSortEnabled:_,swatchColors:u,activeColor:f,distinctValues:l,selectedValues:a,suggest:this._opts.fetchFilterValues?async $=>{let M=await this._opts.fetchFilterValues(s,$);return Array.isArray(M)?M.map(j=>j==null?"":String(j)):[]}:$=>this._suggestFilterValuesLocal(s,$),suggestScope:this._opts.fetchFilterValues?"remote":"local",tagValues:a,containsValue:n,minQueryChars:this._opts.filterValueMinChars,i18n:this._i18n,theme:this._opts.theme,onClose:g,onSort:($,M)=>{let j=this._sorts.findIndex(O=>O.field===s);M&&_?j>=0?this._sorts[j]={field:s,dir:$}:this._sorts.push({field:s,dir:$}):this._sorts=[{field:s,dir:$}],this._reloadFiltered(),g(),this._announce(this._i18n.sortAppliedAnnounce(i,$))},onApply:$=>{this._trivialSetFilters.delete(s),$?this._filters.set(s,$):this._filters.delete(s),this._reloadFiltered(),g(),this._announce($?this._i18n.filterAppliedAnnounce(i):this._i18n.filterClearedAnnounce(i))},onApplyValues:$=>{this._filters.set(s,$),l&&$.length===l.length?this._trivialSetFilters.add(s):this._trivialSetFilters.delete(s),this._reloadFiltered(),g(),this._announce(this._i18n.filterAppliedAnnounce(i))},onColorFilter:$=>{let M=r._plugins.find(j=>j.toggleFilterValue)?.toggleFilterValue(this,s,$);this._reloadFiltered(),g(),this._announce(M?this._i18n.filterClearedAnnounce(i):this._i18n.filterAppliedAnnounce(i))},onResetCol:()=>{this._filters.delete(s),this._trivialSetFilters.delete(s),r._plugins.find($=>$.clearFilterField)?.clearFilterField(this,s),this._sorts=this._sorts.filter($=>$.field!==s),this._reloadFiltered(),g(),this._announce(this._i18n.filterClearedAnnounce(i))},onResetAll:()=>{this._filters.clear(),this._trivialSetFilters.clear(),this._clearPlugins("filterState"),this._sorts=[],this._reloadFiltered(),g(),this._announce(this._i18n.allFiltersClearedAnnounce)}});this._wrapper.appendChild(T),this._filterPanel={col:t,el:T},(T.querySelector('input[type="text"]')??T.querySelector("input")).focus()}_closeFilterPanel(){this._filterPanel&&(this._filterPanel.el.dispatchEvent(new Event("jhg-dispose")),this._filterPanel.el.remove(),this._filterPanel=null,this._wrapper.style.overflow="hidden")}_colMenuItemAllowed(t){let e=this._opts.colContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openColContextMenu(t,e,s){if(this._opts.colContextMenuItems===!1)return;this._closeColContextMenu();let i=this._geo(),o=this._columns.length,n=t<i.frozenCount,l=t>=o-i.frozenRightCount,a=this._columns[t],c=this._deletedColumns.has(a),h=Ke({x:e,y:s,width:this._opts.width,isFrozen:n,isFrozenRight:l,isDeleted:c,i18n:this._i18n,theme:this._opts.theme,allowedItems:{freeze:this._colMenuItemAllowed("freeze"),freezeRight:this._colMenuItemAllowed("freeze-right"),visibility:this._colMenuItemAllowed("visibility"),insertLeft:this._colMenuItemAllowed("insert-left"),insertRight:this._colMenuItemAllowed("insert-right"),delete:this._colMenuItemAllowed("delete")},onFreeze:()=>{this._closeColContextMenu(),this._opts.frozenCols=n?0:t+1,this._scrollLeft=0,this._clamp(this._geo()),this._draw(),this._kbProxy.focus()},onFreezeRight:()=>{this._closeColContextMenu(),this._opts.frozenColsRight=l?0:o-t,this._scrollLeft=0,this._clamp(this._geo()),this._draw(),this._kbProxy.focus()},onVisibility:()=>{this._closeColContextMenu(),this._openColChooser(e,s)},onInsertLeft:()=>{this._closeColContextMenu(),this._openNewColumnDialog(t,e,s)},onInsertRight:()=>{this._closeColContextMenu(),this._openNewColumnDialog(t+1,e,s)},onDelete:()=>{this._closeColContextMenu(),this.deleteColumn(a),this._kbProxy.focus()},onUndelete:()=>{this._closeColContextMenu(),this.undeleteColumn(a),this._kbProxy.focus()},onEscape:()=>{this._closeColContextMenu(),this._kbProxy.focus()}});h&&(this._wrapper.appendChild(h),this._colContextMenu={col:t,el:h},h.querySelector('[role="menuitem"]').focus())}_closeColContextMenu(){this._colContextMenu&&(this._colContextMenu.el.remove(),this._colContextMenu=null)}_openNewColumnDialog(t,e,s){this._closeNewColumnDialog();let{width:i,height:o,theme:n}=this._opts,l=(...C)=>C.join(";"),a=220,c=122,h=Math.max(0,Math.min(e,i-a-4)),d=Math.max(0,Math.min(s,o-c-4)),u=document.createElement("div");u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-label",this._i18n.colInsertTitle),u.className=`${B.overlay} ${B.dialog}`,u.style.cssText=l("position:absolute",`left:${h}px`,`top:${d}px`,`width:${a}px`,`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(n,"overlayShadow")}`,`font-family:${y(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${y(n,"overlayText")}`,"z-index:300","overflow:hidden","user-select:none");let f=document.createElement("div");f.style.cssText=l("display:flex","align-items:center","justify-content:space-between","padding:8px 12px",`background:${y(n,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(n,"overlayDivider")}`);let _=document.createElement("span");_.textContent=this._i18n.colInsertTitle,_.style.cssText=`font-weight:600;font-size:12px;color:${y(n,"overlayMutedText")};`;let g=document.createElement("button");g.type="button",g.textContent="\xD7",g.setAttribute("aria-label",this._i18n.colInsertCancel),g.style.cssText=l("background:none","border:none",`color:${y(n,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),g.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),f.append(_,g);let w=document.createElement("div");w.style.cssText="padding:10px 12px 0;";let m=document.createElement("input");m.type="text",m.placeholder=this._i18n.colInsertPlaceholder,m.className=B.editor,m.style.cssText=l("width:100%",`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:4px",`color:${y(n,"overlayText")}`,`font-size:${n.fontSize}px`,"padding:6px 8px","box-sizing:border-box",`font-family:${y(n,"fontFamily")}`),w.appendChild(m);let v=document.createElement("div");v.style.cssText="display:flex;gap:6px;padding:10px 12px;";let S=document.createElement("button");S.type="button",S.textContent=this._i18n.colInsertConfirm,S.className=B.btn,S.style.cssText=l("flex:1","padding:6px 0",`background:${y(n,"selectionColor")}`,`color:${y(n,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600");let b=()=>{let C=m.value.trim();if(!C){m.focus();return}let T=`NEW_COL_${this._newColSeq++}`;this.addColumn(T,{label:C},{index:t}),this._closeNewColumnDialog(),this._kbProxy.focus()};S.addEventListener("click",b);let E=document.createElement("button");E.type="button",E.textContent=this._i18n.colInsertCancel,E.className=B.btn,E.style.cssText=l("flex:1","padding:6px 0",`background:${y(n,"overlayHeaderBg")}`,`color:${y(n,"overlayText")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"),E.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),v.append(S,E),u.append(f,w,v),u.addEventListener("mousedown",C=>C.stopPropagation()),m.addEventListener("keydown",C=>{C.key==="Enter"?(C.preventDefault(),b()):C.key==="Escape"&&(this._closeNewColumnDialog(),this._kbProxy.focus()),C.stopPropagation()}),this._wrapper.appendChild(u),this._newColDialog={el:u},m.focus()}_closeNewColumnDialog(){this._newColDialog&&(this._newColDialog.el.remove(),this._newColDialog=null)}_rowMenuItemAllowed(t){let e=this._opts.rowContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openRowContextMenu(t,e,s){if(this._opts.rowContextMenuItems===!1)return;this._closeRowContextMenu();let i=this._localIndexAt(t)>=0,o=this._deletedRows.has(t),n=this._opts.theme,l=170,a=(...b)=>b.join(";"),c=a("padding:8px 14px","cursor:pointer"),h=(b,E)=>{let C=document.createElement("div");return C.setAttribute("role","menuitem"),C.setAttribute("tabindex","0"),C.textContent=b,C.dataset.action=E,C.className=B.menuItem,C.style.cssText=c,C.addEventListener("mouseover",()=>{C.style.background=y(n,"overlayItemHoverBg")}),C.addEventListener("mouseout",()=>{C.style.background=""}),C.addEventListener("focus",()=>{C.style.background=y(n,"overlayItemHoverBg")}),C.addEventListener("blur",()=>{C.style.background=""}),C},d=()=>{let b=document.createElement("div");return b.style.cssText=`height:1px;background:${y(n,"overlayDivider")};margin:4px 0;`,b},u=[];this._rowMenuItemAllowed("row-insert-above")&&u.push(h(this._i18n.rowInsertAbove,"row-insert-above")),this._rowMenuItemAllowed("row-insert-below")&&u.push(h(this._i18n.rowInsertBelow,"row-insert-below")),this._rowMenuItemAllowed("row-insert-top")&&u.push(h(this._i18n.rowInsertTop,"row-insert-top")),this._rowMenuItemAllowed("row-insert-bottom")&&u.push(h(this._i18n.rowInsertBottom,"row-insert-bottom"));let f=[];if(this._rowMenuItemAllowed("row-delete")&&(o?f.push(h(this._i18n.rowUndelete,"row-undelete")):i?f.push(h(this._i18n.rowDelete,"row-delete")):(f.push(h(this._i18n.rowDeleteMark,"row-delete-mark")),f.push(h(this._i18n.rowDeletePermanent,"row-delete-permanent")))),u.length===0&&f.length===0)return;let _=u.length>0&&f.length>0?[...u,d(),...f]:[...u,...f],m=(_.length-(u.length>0&&f.length>0?1:0))*36+(u.length>0&&f.length>0?9:0)+8,v=s+m<=this._opts.height?s:Math.max(0,s-m),S=document.createElement("div");S.setAttribute("role","menu"),S.className=`${B.overlay} ${B.menu}`,S.style.cssText=a("position:absolute",`left:${e}px`,`top:${v}px`,`width:${l}px`,`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(n,"overlayMenuShadow")}`,`font-family:${y(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${y(n,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0"),S.addEventListener("mousedown",b=>b.stopPropagation()),S.addEventListener("click",b=>{let E=b.target.closest("[data-action]")?.dataset?.action;E&&(this._closeRowContextMenu(),E==="row-insert-above"?this.addRow({},{index:t}):E==="row-insert-below"?this.addRow({},{index:t+1}):E==="row-insert-top"?this.addRow({},{index:0}):E==="row-insert-bottom"?this.addRow({}):E==="row-delete-mark"?this.deleteRow(t,{permanent:!1}):E==="row-delete-permanent"?this.deleteRow(t,{permanent:!0}):E==="row-delete"?this.deleteRow(t):E==="row-undelete"&&this.undeleteRow(t),this._kbProxy.focus())}),S.addEventListener("keydown",b=>{if(b.key==="Escape")this._closeRowContextMenu(),this._kbProxy.focus();else if(b.key==="Enter"||b.key===" ")b.preventDefault(),document.activeElement?.click?.();else if(b.key==="ArrowDown"||b.key==="ArrowUp"){b.preventDefault();let E=[...S.querySelectorAll('[role="menuitem"]')],C=E.indexOf(document.activeElement),T=b.key==="ArrowDown"?(C+1)%E.length:(C-1+E.length)%E.length;E[T]?.focus()}b.stopPropagation()}),S.append(..._),this._wrapper.appendChild(S),this._rowContextMenu={row:t,el:S},_[0].focus()}_closeRowContextMenu(){this._rowContextMenu&&(this._rowContextMenu.el.remove(),this._rowContextMenu=null)}_cellMenuItemAllowed(t){let e=this._opts.cellContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openCellContextMenu(t,e,s,i){if(this._opts.cellContextMenuItems===!1)return;this._closeCellContextMenu();let o=this._columns[e],n=this._opts.theme,l=170,a=(...R)=>R.join(";"),c=a("padding:8px 14px","cursor:pointer"),h=(R,F)=>{let A=document.createElement("div");return A.setAttribute("role","menuitem"),A.setAttribute("tabindex","0"),A.textContent=R,A.dataset.action=F,A.className=B.menuItem,A.style.cssText=c,A.addEventListener("mouseover",()=>{A.style.background=y(n,"overlayItemHoverBg")}),A.addEventListener("mouseout",()=>{A.style.background=""}),A.addEventListener("focus",()=>{A.style.background=y(n,"overlayItemHoverBg")}),A.addEventListener("blur",()=>{A.style.background=""}),A},d=()=>{let R=document.createElement("div");return R.style.cssText=`height:1px;background:${y(n,"overlayDivider")};margin:4px 0;`,R},u=[];this._cellMenuItemAllowed("col-insert-left")&&u.push(h(this._i18n.colInsertLeft,"col-insert-left")),this._cellMenuItemAllowed("col-insert-right")&&u.push(h(this._i18n.colInsertRight,"col-insert-right"));let f=this._cellMenuItemAllowed("col-delete")?[h(this._i18n.colDelete,"col-delete")]:[],_=[];this._cellMenuItemAllowed("row-insert-below")&&_.push(h(this._i18n.rowInsertBelow,"row-insert-below")),this._cellMenuItemAllowed("row-delete")&&_.push(h(this._i18n.rowDelete,"row-delete"));let g=this.getRowData(t),w=this._canvas.getBoundingClientRect(),m=w.left+s,v=w.top+i,S=typeof this._opts.cellContextMenuExtraItems=="function"?this._opts.cellContextMenuExtraItems({row:t,col:e,field:o,rowData:g,clientX:m,clientY:v})||[]:[],b=S.map((R,F)=>{let A=h(R.label,`extra:${F}`);return R.disabled&&(A.setAttribute("aria-disabled","true"),A.style.opacity="0.5",A.style.pointerEvents="none"),A}),E=[u,f,_,b].filter(R=>R.length>0);if(E.length===0)return;let C=E.flatMap((R,F)=>F===0?R:[d(),...R]),T=36,$=9,M=E.reduce((R,F)=>R+F.length,0),j=E.length-1,O=M*T+j*$+8,V=i+O<=this._opts.height?i:Math.max(0,i-O),P=Math.min(s,this._opts.width-l-2),H=document.createElement("div");H.setAttribute("role","menu"),H.className=`${B.overlay} ${B.menu}`,H.style.cssText=a("position:absolute",`left:${P}px`,`top:${V}px`,`width:${l}px`,`background:${y(n,"overlayBg")}`,`border:1px solid ${y(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(n,"overlayMenuShadow")}`,`font-family:${y(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${y(n,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0"),H.addEventListener("mousedown",R=>R.stopPropagation()),H.addEventListener("click",R=>{let F=R.target.closest("[data-action]")?.dataset?.action;if(F){if(F==="col-insert-left"){this._closeCellContextMenu(),this._openNewColumnDialog(e,s,i);return}if(F==="col-insert-right"){this._closeCellContextMenu(),this._openNewColumnDialog(e+1,s,i);return}if(F.startsWith("extra:")){this._closeCellContextMenu(),S[Number(F.slice(6))]?.onClick?.({row:t,col:e,field:o,rowData:g,clientX:m,clientY:v}),this._kbProxy.focus();return}this._closeCellContextMenu(),F==="col-delete"?this.deleteColumn(o):F==="row-insert-below"?this.addRow({},{index:t+1}):F==="row-delete"&&this.deleteRow(t),this._kbProxy.focus()}}),H.addEventListener("keydown",R=>{if(R.key==="Escape")this._closeCellContextMenu(),this._kbProxy.focus();else if(R.key==="Enter"||R.key===" ")R.preventDefault(),document.activeElement?.click?.();else if(R.key==="ArrowDown"||R.key==="ArrowUp"){R.preventDefault();let F=[...H.querySelectorAll('[role="menuitem"]')],A=F.indexOf(document.activeElement),it=R.key==="ArrowDown"?(A+1)%F.length:(A-1+F.length)%F.length;F[it]?.focus()}R.stopPropagation()}),H.append(...C),this._wrapper.appendChild(H),this._cellContextMenu={row:t,col:e,el:H},H.querySelector('[role="menuitem"]').focus()}_closeCellContextMenu(){this._cellContextMenu&&(this._cellContextMenu.el.remove(),this._cellContextMenu=null)}_openColChooser(t,e){this._closeColChooser();let s=Ye({x:t,y:e,width:this._opts.width,height:this._opts.height,fields:this._columnOriginalOrder,isHidden:i=>this._hiddenColumns.has(i),labelFor:i=>this._colDefMap.get(i)?.label??i,groupPathFor:i=>fe(this._colDefMap.get(i)?.group),i18n:this._i18n,theme:this._opts.theme,onApply:i=>{this._withStructuralUndo(()=>{this._columnOriginalOrder.forEach(o=>{let n=i.get(o),l=!this._hiddenColumns.has(o);n&&!l?(this._deletedColumns.delete(o),this._showColumnInternal(o)):!n&&l&&this._hideColumnInternal(o)}),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()}),this._closeColChooser(),this._kbProxy.focus()},onCancel:()=>{this._closeColChooser(),this._kbProxy.focus()}});s&&(this._wrapper.appendChild(s),this._colChooser={el:s},s.querySelector("button").focus())}_closeColChooser(){this._colChooser&&(this._colChooser.el.remove(),this._colChooser=null)}_remapSelForColRemoval(t){if(!this._sel)return;let e=s=>s>t?s-1:s===t?-1:s;if(this._sel.type==="single"){let s=e(this._sel.col);this._sel=s<0?null:{...this._sel,col:s}}else{let s=e(this._sel.c1),i=e(this._sel.c2);s<0||i<0?this._sel=null:s===i?this._sel={type:"single",row:this._sel.r1,col:s}:this._sel={type:"range",...this._normRange(this._sel.r1,s,this._sel.r2,i)}}}_purgeFieldEdits(t){[...this._edits.keys()].forEach(e=>{let s=e.indexOf("_");e.slice(s+1)===t&&this._edits.delete(e)});for(let e of r._plugins)e.purgeField?.(this,t)}_hideColumnInternal(t){let e=this._columns.indexOf(t);if(e===-1)return;this._hiddenColumns.set(t,{label:this._columnLabels[e],align:this._columnAligns[e],headerAlign:this._columnHeaderAligns[e],width:this._columnWidths[e],renderer:this._columnRenderers[e]});let s=(i,o)=>o!==e;this._columns=this._columns.filter(s),this._columnLabels=this._columnLabels.filter(s),this._columnAligns=this._columnAligns.filter(s),this._columnHeaderAligns=this._columnHeaderAligns.filter(s),this._columnWidths=this._columnWidths.filter(s),this._columnRenderers=this._columnRenderers.filter(s),this._remapSelForColRemoval(e)}_showColumnInternal(t){let e=this._hiddenColumns.get(t);if(!e)return;this._hiddenColumns.delete(t);let s=this._columnOriginalOrder.indexOf(t),i=this._columns.length;for(let n=s+1;n<this._columnOriginalOrder.length;n++){let l=this._columns.indexOf(this._columnOriginalOrder[n]);if(l!==-1){i=l;break}}let o=(n,l)=>{let a=[...n];return a.splice(i,0,l),a};this._columns=o(this._columns,t),this._columnLabels=o(this._columnLabels,e.label),this._columnAligns=o(this._columnAligns,e.align),this._columnHeaderAligns=o(this._columnHeaderAligns,e.headerAlign),this._columnWidths=o(this._columnWidths,e.width),this._columnRenderers=o(this._columnRenderers,e.renderer)}_normRange(t,e,s,i){return{r1:Math.min(t,s),c1:Math.min(e,i),r2:Math.max(t,s),c2:Math.max(e,i)}}_dragEdgeDir(t,e,s=this._geo()){let{width:i,height:o}=this._opts,n=24,l=0,a=0;return t<s.frozenWidth+n?l=-1:t>s.rightX-n&&(l=1),e<s.headerH+n?a=-1:e>o-s.hSB-n&&(a=1),{dx:l,dy:a}}_extendDragSelection(t,e,s=this._geo()){let i=this._hitCellClamped(t,e,s);if(!i)return;let o=this._normRange(this._selDragStart.row,this._selDragStart.col,i.row,i.col),n=o.r1===o.r2&&o.c1===o.c2;this._sel=n?{type:"single",row:o.r1,col:o.c1}:{type:"range",...o},this._schedDraw()}_startDragAutoScroll(){this._dragScrollTimer||(this._dragScrollTimer=setInterval(()=>this._dragAutoScrollTick(),50))}_stopDragAutoScroll(){this._dragScrollTimer&&(clearInterval(this._dragScrollTimer),this._dragScrollTimer=null),this._dragScrollDir={dx:0,dy:0}}_dragAutoScrollTick(){let{dx:t,dy:e}=this._dragScrollDir;if(!t&&!e||!this._selDragging&&!this._fillDrag||!this._dragScrollPos){this._stopDragAutoScroll();return}let s=40,i=this._geo();t&&(this._scrollLeft+=t*s),e&&(this._scrollTop+=e*s),this._clamp(i),this._selDragging?this._extendDragSelection(this._dragScrollPos.x,this._dragScrollPos.y,this._geo()):this._extendFillDrag(this._dragScrollPos.x,this._dragScrollPos.y,this._geo())}_isEditable(t){if(t<0||t>=this._columns.length)return!1;let e=this._columns[t],s=this._colDefMap.get(e)?.editable;return s!==void 0?s:this._editableCols===null||this._editableCols.has(e)}_localIndexAt(t){return this._rowPlan.sourceAt(t)?.local??-1}_rowSource(t){let e=this._rowPlan.sourceAt(t);return e?e.local>=0?this._localRows[e.local]??null:this._dm.getRow(e.server):null}_cellVal(t,e){let s=this._columns[e],i=`${t}_${s}`;if(this._edits.has(i))return this._edits.get(i);let o=this._rowSource(t);if(!o)return"";let n=o[s];return n!=null?String(n):""}_getRow(t){let e=this._rowSource(t);if(!this._editedRows.has(t))return e;let s=e?{...e}:{};return this._columns.forEach(i=>{let o=`${t}_${i}`;this._edits.has(o)&&(s[i]=this._edits.get(o))}),s}_isPlainTextEditor(t){let e=this._colDefMap.get(this._columns[t]);return!e?.editor&&(e?.type??"text")==="text"}_startEdit(t,e,s=void 0,{keepInputValue:i=!1}={}){if(!this._isEditable(e))return;this._editing&&this._commitEdit();let o=this._columns[e],n=this._colDefMap.get(o),l=n?.type??"text";if(l==="checkbox"||l==="button")return;let a=this._buildEditorCtx(t,e,s);a.keepInputValue=i;let c=n?.editor,h;if(typeof c=="function")h=c(a);else{let d=c??l,f=d==="text"&&!i&&String(a.initialValue??"").includes(`
|
|
142
142
|
`)?Ht.textMultiline:Ht[d]??Ht.text,_=d==="dropdown"||d==="multiselect"?{options:n?.options??[],...n?.editorOptions??{}}:d==="date"?{format:n?.format,...n?.editorOptions??{}}:n?.editorOptions??{};h=f(_)(a)}h&&(this._editing={row:t,col:e,el:h})}_buildEditorCtx(t,e,s){let{theme:i}=this._opts,o=this._geo(),{colPositions:n,headerH:l}=o,a=n[e+1]-n[e],c=this._rowLayout.yOf(t+1)-this._rowLayout.yOf(t),h=this._colLeft(e,o),d=this._rowLayout.yOf(t)-this._scrollTop+l;return{row:t,col:e,field:this._columns[e],rowData:this._getRow(t),x:h,y:d,colW:a,rowH:c,wrapper:this._wrapper,kbProxy:this._kbProxy,theme:i,i18n:this._i18n,columnLabel:this._columnLabels[e]??this._columns[e],initialValue:s!==void 0?s:this._cellVal(t,e),commit:()=>this._commitEdit(),cancel:()=>this._cancelEdit(),insertLineBreak:()=>this._insertLineBreakInEdit(),moveSel:(u,f)=>this._moveSel(u,f),focusWrapper:()=>this._kbProxy.focus(),suppressReopen:()=>{this._suppressReopenCell={row:t,col:e}}}}_toggleCheckbox(t,e){let s=this._columns[e],i=this._cellVal(t,e),n=i==="true"||i==="1"||i==="Y"||i==="yes"?"false":"true";this._editTxnBegin(),this._setEdit(t,s,n),this._editTxnCommit(),this._updateA11yCell(),this._draw()}_fireButtonClick(t,e){let s=this._columns[e],i=this._colDefMap.get(s)?.button;if(!i?.onClick)return;let o=this._getRow(t);if(!(typeof i.disabled=="function"?i.disabled(o,t):i.disabled))try{i.onClick(t,o,s)}catch(l){console.error("[JHGrid] button onClick error at row",t,"field",s,":",l)}}_isButtonCell(t){return!t||t.type!=="single"?!1:this._colDefMap.get(this._columns[t.col])?.type==="button"}_startDropdownEdit(t,e,s){let i=Ht[s?.type]??Ht.dropdown,o={options:s?.options??[],...s?.editorOptions??{}},n=this._buildEditorCtx(t,e),l=i(o)(n);l&&(this._editing={row:t,col:e,el:l})}_resetKbProxy(){let t=this._kbProxy;t._jhEditorBlur&&(t.removeEventListener("blur",t._jhEditorBlur),t._jhEditorBlur=null),t._jhEditorKeydown&&(t.removeEventListener("keydown",t._jhEditorKeydown),t._jhEditorKeydown=null),t.value="",t.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),t.className="",t.style.cssText=ls,this._syncKbProxyPosition()}_syncKbProxyPosition(){if(this._editing||!this._sel||this._sel.type!=="single")return;let{row:t,col:e}=this._sel,s=this._geo(),i=s.colPositions[e+1]-s.colPositions[e],o=this._rowLayout.yOf(t+1)-this._rowLayout.yOf(t),n=this._colLeft(e,s),l=this._rowLayout.yOf(t)-this._scrollTop+s.headerH;Object.assign(this._kbProxy.style,{left:n+"px",top:l+"px",width:i+"px",height:o+"px"})}_commitEdit(){if(!this._editing)return;let{row:t,col:e,el:s}=this._editing,i=s.value,o=this._columns[e];this._editTxnBegin(),this._setEdit(t,o,i),this._editTxnCommit(),this._editing=null,s.remove(),this._updateA11yCell();let n=this._validator.map.get(`${t}_${o}`);n&&this._announce(n),this._draw()}_cancelEdit(){if(!this._editing)return;let t=this._editing.el;this._editing=null,t.remove(),this._draw()}_insertLineBreakInEdit(){if(!this._editing)return;let{row:t,col:e,el:s}=this._editing,i=s.selectionStart??s.value.length,o=s.selectionEnd??s.value.length,n=s.value.slice(0,i)+`
|
|
143
|
-
`+s.value.slice(o);this._editing=null,s.remove(),this._startEdit(t,e,n),this._editing?.el.setSelectionRange(i+1,i+1)}_setSel(t){this._sel=t,this._opts.onSelectionChange?.(t)}_moveSel(t,e){let s=this._sel;if(!s)return;let i=(s.type==="single"?s.row:s.r1)+t,o=(s.type==="single"?s.col:s.c1)+e,{start:n,rows:l}=this._pageBounds(),a=Math.max(n,Math.min(n+l-1,i)),c=Math.max(0,Math.min(this._columns.length-1,o));this._setSel({type:"single",row:a,col:c}),this._ensureVisible(a,c),this._updateA11yCell(),this._announce(this._i18n.announceCell(a+1,this._columnLabels[c]??this._columns[c],this._cellVal(a,c)||this._i18n.emptyCell)),this._draw()}_updateRowSel(t,e,s){r._plugin("rowSelection")?.update(this,t,e,s)}_clearRowSelOnCellClick(t){r._plugin("rowSelection")?.clearOnCellClick(this,t)}_updateColSel(t,e){if(this._totalRows===0)return;let s=this._totalRows-1,i=e&&this._selAnchor?this._selAnchor.col:t;(!e||!this._selAnchor)&&(this._selAnchor={row:0,col:t}),r._plugin("rowSelection")?.clear(this);let o=this._normRange(0,i,s,t);this._setSel(o.r1===o.r2&&o.c1===o.c2?{type:"single",row:o.r1,col:o.c1}:{type:"range",...o}),this._ensureColVisible(t),this._updateA11yCell()}_ensureColVisible(t){let e=this._geo(),{frozenCount:s,frozenRightCount:i,colPositions:o}=e,n=this._columns.length;if(t>=s&&t<n-i){let l=o[t]-o[s],a=o[t+1]-o[t];l<this._scrollLeft&&(this._scrollLeft=l),l+a>this._scrollLeft+e.vpW&&(this._scrollLeft=l+a-e.vpW)}this._clamp(e)}_extendSel(t,e){if(!this._sel)return;this._selAnchor||(this._selAnchor=this._sel.type==="single"?{row:this._sel.row,col:this._sel.col}:{row:this._sel.r1,col:this._sel.c1});let s=this._selAnchor,i,o;this._sel.type==="single"?(i=this._sel.row,o=this._sel.col):(i=s.row===this._sel.r1?this._sel.r2:this._sel.r1,o=s.col===this._sel.c1?this._sel.c2:this._sel.c1),i=Math.max(0,Math.min(this._totalRows-1,i+t)),o=Math.max(0,Math.min(this._columns.length-1,o+e));let n=this._normRange(s.row,s.col,i,o);this._setSel(n.r1===n.r2&&n.c1===n.c2?{type:"single",row:n.r1,col:n.c1}:{type:"range",...n}),this._ensureVisible(i,o),this._updateA11yCell(),this._draw()}_clearSelection(){if(!this._sel)return;let t=this._sel.type==="single"?
|
|
143
|
+
`+s.value.slice(o);this._editing=null,s.remove(),this._startEdit(t,e,n),this._editing?.el.setSelectionRange(i+1,i+1)}_setSel(t){this._sel=t,this._opts.onSelectionChange?.(t)}_moveSel(t,e){let s=this._sel;if(!s)return;let i=(s.type==="single"?s.row:s.r1)+t,o=(s.type==="single"?s.col:s.c1)+e,{start:n,rows:l}=this._pageBounds(),a=Math.max(n,Math.min(n+l-1,i)),c=Math.max(0,Math.min(this._columns.length-1,o));this._setSel({type:"single",row:a,col:c}),this._ensureVisible(a,c),this._updateA11yCell(),this._announce(this._i18n.announceCell(a+1,this._columnLabels[c]??this._columns[c],this._cellVal(a,c)||this._i18n.emptyCell)),this._draw()}_updateRowSel(t,e,s){r._plugin("rowSelection")?.update(this,t,e,s)}_clearRowSelOnCellClick(t){r._plugin("rowSelection")?.clearOnCellClick(this,t)}_updateColSel(t,e){if(this._totalRows===0)return;let s=this._totalRows-1,i=e&&this._selAnchor?this._selAnchor.col:t;(!e||!this._selAnchor)&&(this._selAnchor={row:0,col:t}),r._plugin("rowSelection")?.clear(this);let o=this._normRange(0,i,s,t);this._setSel(o.r1===o.r2&&o.c1===o.c2?{type:"single",row:o.r1,col:o.c1}:{type:"range",...o}),this._ensureColVisible(t),this._updateA11yCell()}_ensureColVisible(t){let e=this._geo(),{frozenCount:s,frozenRightCount:i,colPositions:o}=e,n=this._columns.length;if(t>=s&&t<n-i){let l=o[t]-o[s],a=o[t+1]-o[t];l<this._scrollLeft&&(this._scrollLeft=l),l+a>this._scrollLeft+e.vpW&&(this._scrollLeft=l+a-e.vpW)}this._clamp(e)}_extendSel(t,e){if(!this._sel)return;this._selAnchor||(this._selAnchor=this._sel.type==="single"?{row:this._sel.row,col:this._sel.col}:{row:this._sel.r1,col:this._sel.c1});let s=this._selAnchor,i,o;this._sel.type==="single"?(i=this._sel.row,o=this._sel.col):(i=s.row===this._sel.r1?this._sel.r2:this._sel.r1,o=s.col===this._sel.c1?this._sel.c2:this._sel.c1),i=Math.max(0,Math.min(this._totalRows-1,i+t)),o=Math.max(0,Math.min(this._columns.length-1,o+e));let n=this._normRange(s.row,s.col,i,o);this._setSel(n.r1===n.r2&&n.c1===n.c2?{type:"single",row:n.r1,col:n.c1}:{type:"range",...n}),this._ensureVisible(i,o),this._updateA11yCell(),this._draw()}_clearSelection(){if(!this._sel)return;let t=this._sel.type==="single",e=t?this._sel.row:this._sel.r1,s=t?this._sel.row:this._sel.r2,i=t?this._sel.col:this._sel.c1,o=t?this._sel.col:this._sel.c2,n=[];for(let l=i;l<=o;l++)this._isEditable(l)&&n.push(this._columns[l]);this._editTxnBegin();for(let l=e;l<=s;l++)for(let a of n)this._setEdit(l,a,"");this._editTxnCommit(),this._draw()}_usedRange(t=0,e=0){let s=this._totalRows,i=this._columns.length;if(s===0||i===0)return{r1:0,r2:s-1,c1:0,c2:i-1};let o=w=>w==null||w==="",n=s-1;for(;n>0;){let w=this._getRow(n);if(w==null||!this._columns.every(m=>o(w[m])))break;n--}let l=new Array(i).fill(!1),a=0,c=-1,h=1/0,d=w=>{if(w==null||w<0||w>n)return;let m=this._getRow(w);if(m==null)return;a++;let v=!0;for(let S=0;S<i;S++)o(m[this._columns[S]])||(v=!1,l[S]||(l[S]=!0));v&&w!==t&&(w<t&&w>c&&(c=w),w>t&&w<h&&(h=w))};this._dm.forEachLoaded((w,m)=>d(this._rowPlan.visualOfServer(m))),this._localRows.forEach((w,m)=>d(this._rowPlan.visualOfLocal(m)));let u=0,f=n,_=0,g=i-1;if(a>0&&(h<1/0&&(f=Math.min(f,h-1)),c>-1&&(u=c+1),_=g=e,i>1)){for(;g+1<i&&l[g+1];)g++;for(;_-1>=0&&l[_-1];)_--}return{r1:u,r2:f,c1:_,c2:g}}_ensureVisible(t,e){let s=this._geo(),{frozenCount:i,frozenRightCount:o,colPositions:n}=s,l=this._columns.length,a=this._rowLayout.yOf(t),c=this._rowLayout.heightOf(t);if(a<this._scrollTop&&(this._scrollTop=a),a+c>this._scrollTop+s.vpH&&(this._scrollTop=a+c-s.vpH),e>=i&&e<l-o){let h=n[e]-n[i],d=n[e+1]-n[e];h<this._scrollLeft&&(this._scrollLeft=h),h+d>this._scrollLeft+s.vpW&&(this._scrollLeft=h+d-s.vpW)}this._clamp(s)}_pushUndoCmd(t){this._undoMgr.push(t)}_snapshotStructural(){let t={totalRows:this._totalRows,serverTotal:this._serverTotal,localRows:this._localRows.map(e=>({...e})),deletedRows:new Set(this._deletedRows),removedServer:this._rowPlan.removed.values(),localAnchors:[...this._rowPlan.anchors],edits:new Map(this._edits),editedRows:new Set(this._editedRows),sel:this._sel?{...this._sel}:null,selAnchor:this._selAnchor?{...this._selAnchor}:null,columns:[...this._columns],columnLabels:[...this._columnLabels],columnAligns:[...this._columnAligns],columnHeaderAligns:[...this._columnHeaderAligns],columnWidths:[...this._columnWidths],columnRenderers:[...this._columnRenderers],rowHeight:this._opts.rowHeight,rowHeightOverrides:this._rowLayout.snapshotOverrides(),localColumns:new Map(this._localColumns),deletedColumns:new Set(this._deletedColumns),colDefMap:new Map(this._colDefMap),columnWidthMap:new Map(this._columnWidthMap),columnOriginalOrder:[...this._columnOriginalOrder],hiddenColumns:new Map(this._hiddenColumns)};for(let e of r._plugins)e.snapshotStructural?.(this,t);return t}_restoreStructural(t){this._totalRows=t.totalRows,this._serverTotal=t.serverTotal,this._localRows=t.localRows.map(e=>({...e})),this._deletedRows=new Set(t.deletedRows),this._rowPlan.removed.clear(),this._rowPlan.detachAnchors();for(let e of t.removedServer)this._rowPlan.removed.add(e);this._rowPlan.anchors=[...t.localAnchors],this._rowPlan.serverTotal=t.serverTotal,this._edits=new Map(t.edits),this._editedRows=new Set(t.editedRows),this._sel=t.sel?{...t.sel}:null,this._selAnchor=t.selAnchor?{...t.selAnchor}:null,this._columns=[...t.columns],this._columnLabels=[...t.columnLabels],this._columnAligns=[...t.columnAligns],this._columnHeaderAligns=[...t.columnHeaderAligns],this._columnWidths=[...t.columnWidths],this._columnRenderers=[...t.columnRenderers],this._opts.rowHeight=t.rowHeight,this._rowLayout.defaultHeight=t.rowHeight,this._rowLayout.restoreOverrides(t.rowHeightOverrides),this._localColumns=new Map(t.localColumns),this._deletedColumns=new Set(t.deletedColumns),this._colDefMap=new Map(t.colDefMap),this._columnWidthMap=new Map(t.columnWidthMap),this._columnOriginalOrder=[...t.columnOriginalOrder],this._hiddenColumns=new Map(t.hiddenColumns);for(let e of r._plugins)e.restoreStructural?.(this,t);this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._wrapper.setAttribute("aria-colcount",String(this._columns.length)),this._emptyEl.style.display=this._totalRows===0?"flex":"none",this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._opts.onSelectionChange?.(this._sel),this._opts.onRowSelect?.(r._plugin("rowSelection")?.getSorted(this)??[]),this._revalidateAllFromEdits(),this._draw()}_withStructuralUndo(t){let e=this._snapshotStructural(),s=t();this._revalidateAllFromEdits(),this._draw();let i=this._snapshotStructural();return this._pushUndoCmd({undo:()=>this._restoreStructural(e),redo:()=>this._restoreStructural(i)}),s}_resolveCellStringValue(t,e){let s=`${t}_${e}`;if(this._edits.has(s))return this._edits.get(s);let i=this._rowSource(t);if(!i)return"";let o=i[e];return o!=null?String(o):""}_revalidateKey(t){let e=t.indexOf("_");this._revalidateRowField(Number(t.slice(0,e)),t.slice(e+1))}_revalidateRowField(t,e){this._validator.revalidate(t,e,this._resolveCellStringValue(t,e))}_revalidateAllFromEdits(){let t=new Set(this._validator.map.keys());this._validator.clear(),this._edits.forEach((e,s)=>this._revalidateKey(s)),t.forEach(e=>{if(this._validator.map.has(e))return;let s=e.indexOf("_");this._opts.onValidationError?.(Number(e.slice(0,s)),e.slice(s+1),null)})}isValid(){return this._validator.isValid()}getInvalidCells(){return this._validator.getInvalidCells()}validateAll(){if(this._destroyed)return this.getInvalidCells();this._validator.clear();let t=this._columns.filter(e=>this._colDefMap.get(e)?.validation);return t.length>0&&(this._dm.forEachLoaded((e,s)=>{t.forEach(i=>this._revalidateRowField(s,i))}),this._localRows.forEach((e,s)=>{let i=this._rowPlan.visualOfLocal(s);t.forEach(o=>this._revalidateRowField(i,o))})),this._draw(),this.getInvalidCells()}_editTxnBegin(){this._editTxn=new Map}_setEdit(t,e,s){let i=`${t}_${e}`,o;if(this._edits.has(i))o=this._edits.get(i);else{let n=this._rowSource(t)?.[e];o=n!=null?String(n):""}this._editTxn&&!this._editTxn.has(i)&&this._editTxn.set(i,this._edits.has(i)?{had:!0,value:this._edits.get(i)}:{had:!1,value:void 0}),this._edits.set(i,s),this._editedRows.add(t),this._opts.onCellChange?.({row:t,field:e,newValue:s,oldValue:o}),this._revalidateRowField(t,e),this._growRowForMultilineValue(t,s)}_growRowForMultilineValue(t,e){if(typeof e!="string"||e.indexOf(`
|
|
144
144
|
`)===-1)return;let{fontSize:s,cellPadding:i}=this._opts.theme,o=Math.ceil(e.split(`
|
|
145
145
|
`).length*s*1.4+i*2);o>this._rowLayout.heightOf(t)&&this._rowLayout.setHeight(t,o)}_autoFitRow(t){let{fontSize:e,cellPadding:s}=this._opts.theme,i=this._getRow(t),o=1;i&&this._columns.forEach(l=>{let a=i[l];if(a==null)return;let c=String(a).split(`
|
|
146
146
|
`).length;c>o&&(o=c)});let n=o<=1?this._rowLayout.defaultHeight:Math.max(ns,Math.ceil(o*e*1.4+s*2));this._rowLayout.setHeight(t,n)}_selectedRowsForAutoFit(){let t=r._plugin("rowSelection")?.getSorted(this);if(t&&t.length>1)return new Set(t);if(this._sel&&this._sel.type==="range"){let e=new Set;for(let s=this._sel.r1;s<=this._sel.r2;s++)e.add(s);return e}return null}_restoreEditSnap(t,e){e.had?this._edits.set(t,e.value):this._edits.delete(t);let s=t.indexOf("_");this._editedRows.add(Number(t.slice(0,s))),this._revalidateKey(t)}_editTxnCommit(){let t=this._editTxn;if(this._editTxn=null,!t||t.size===0)return;let e=new Map;t.forEach((s,i)=>{e.set(i,this._edits.has(i)?{had:!0,value:this._edits.get(i)}:{had:!1,value:void 0})}),this._pushUndoCmd({undo:()=>{t.forEach((s,i)=>this._restoreEditSnap(i,s)),this._draw()},redo:()=>{e.forEach((s,i)=>this._restoreEditSnap(i,s)),this._draw()}})}undo(){this._undoMgr.undo()}redo(){this._undoMgr.redo()}canUndo(){return this._undoMgr.canUndo()}canRedo(){return this._undoMgr.canRedo()}_selectedRowsSorted(){return r._plugin("rowSelection")?.getSorted(this)??[]}_buildCopyText(){let t=this._sel?null:this._selectedRowsSorted();if(!this._sel&&(!t||t.length===0))return"";this._lastCopyMissingRows=0;let e=(l,a)=>{let c=this._cellVal(l,a),h=this._colDefMap.get(this._columns[a]);return Ne(Kt(c,h,this._opts.theme.locale))};if(t)return t.map(l=>(this._rowSource(l)==null&&this._lastCopyMissingRows++,this._columns.map((a,c)=>e(l,c)).join(" "))).join(`
|
|
147
147
|
`);if(this._sel.type==="single")return this._rowSource(this._sel.row)==null&&(this._lastCopyMissingRows=1),e(this._sel.row,this._sel.col);let{r1:s,c1:i,r2:o,c2:n}=this._sel;return Array.from({length:o-s+1},(l,a)=>{let c=s+a;return this._rowSource(c)==null&&this._lastCopyMissingRows++,Array.from({length:n-i+1},(h,d)=>e(c,i+d)).join(" ")}).join(`
|
|
148
|
-
`)}_pasteImageBlob(t){if(!this._sel)return!1;let e=this._sel.type==="single"?this._sel.row:this._sel.r1,s=this._sel.type==="single"?this._sel.col:this._sel.c1,i=this._columns[s];if(this._colDefMap.get(i)?.type!=="image"||!this._isEditable(s))return!1;let o=this._cellVal(e,s);this._pastedImageUrls.has(o)&&(URL.revokeObjectURL(o),this._pastedImageUrls.delete(o));let n=URL.createObjectURL(t);return this._pastedImageUrls.add(n),this._editTxnBegin(),this._setEdit(e,i,n),this._editTxnCommit(),this._draw(),!0}async _pasteFromClipboardAsync(){if(navigator.clipboard?.read)try{let e=await navigator.clipboard.read();for(let s of e){let i=s.types.find(n=>n.startsWith("image/"));if(!i)continue;let o=await s.getType(i);if(this._pasteImageBlob(o))return}}catch{}if(!navigator.clipboard?.readText)return;let t=await navigator.clipboard.readText().catch(()=>"");t&&this._applyPaste(t)}_applyPaste(t){if(!this._sel||!t)return;let e=je(t.trimEnd()),s=e.length,i=Math.max(...e.map(c=>c.length)),o=this._sel.type==="single"?this._sel.row:this._sel.r1,n=this._sel.type==="single"?this._sel.col:this._sel.c1,l=0,a=(c,h,d)=>{if(c>=this._totalRows||h>=this._columns.length){l++;return}if(!this._isEditable(h)){l++;return}if(this._isGroupRow(c))return;let u=this._columns[h];this._setEdit(c,u,d)};if(this._editTxnBegin(),s===1&&i===1&&this._sel.type==="range"){let c=e[0][0];for(let h=this._sel.r1;h<=this._sel.r2;h++)for(let d=this._sel.c1;d<=this._sel.c2;d++)a(h,d,c)}else e.forEach((c,h)=>c.forEach((d,u)=>a(o+h,n+u,d)));this._editTxnCommit(),this._draw(),l>0&&(this._showErrorBanner(this._i18n.pasteTruncated(l)),this._announce(this._i18n.pasteTruncated(l)))}_applyFill(t,e){let s=t.type==="single"?t.row:t.r1,i=t.type==="single"?t.row:t.r2,o=t.type==="single"?t.col:t.c1,n=t.type==="single"?t.col:t.c2,{r1:l,c1:a,r2:c,c2:h}=e,d=l>i||c<s,u=(d?l>i:a>n)?1:-1,f=d?u>0?l:c:u>0?a:h,_=p=>Math.abs(p-f)+1;if(this._editTxnBegin(),d)for(let p=o;p<=n;p++){if(!this._isEditable(p))continue;let w=[];for(let x=s;x<=i;x++)w.push(this._cellVal(x,p));let m=this._columns[p];for(let x=f;(u>0?x<=c:x>=l)&&!(x>=this._totalRows||x<0);x+=u)this._isGroupRow(x)||this._setEdit(x,m,Ce(w,_(x),u))}else for(let p=s;p<=i;p++){if(this._isGroupRow(p))continue;let w=[];for(let m=o;m<=n;m++)w.push(this._cellVal(p,m));for(let m=f;u>0?m<=h:m>=a;m+=u){if(!this._isEditable(m))continue;let x=this._columns[m];this._setEdit(p,x,Ce(w,_(m),u))}}this._editTxnCommit(),this._draw()}_xy(t){let e=this._canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}_clamp(t){this._scrollTop=Math.max(t.minScrollY,Math.min(t.maxScrollY,this._scrollTop)),this._scrollLeft=Math.max(0,Math.min(t.maxScrollX,this._scrollLeft))}_wheelPixels(t,e){return t.deltaMode===1?{dx:t.deltaX*Ws,dy:t.deltaY*this._opts.rowHeight}:t.deltaMode===2?{dx:t.deltaX*e.vpW,dy:t.deltaY*e.vpH}:{dx:t.deltaX,dy:t.deltaY}}_easeWheel(t,e,s){if(this._scrollEaseMs===0||Math.abs(e)<this._opts.rowHeight&&Math.abs(t)<this._opts.rowHeight)return!1;let i=this._scrollEase.animating,o=(i?this._scrollAim.y:this._scrollTop)+e,n=(i?this._scrollAim.x:this._scrollLeft)+t;return this._scrollAim={y:Math.max(s.minScrollY,Math.min(s.maxScrollY,o)),x:Math.max(0,Math.min(s.maxScrollX,n))},this._scrollFrom={y:this._scrollTop,x:this._scrollLeft},this._scrollWrote={y:this._scrollTop,x:this._scrollLeft},this._scrollEase.set(0),this._scrollEase.to(1,this._scrollEaseMs),!0}_onScrollFrame(){if(this._scrollTop!==this._scrollWrote.y||this._scrollLeft!==this._scrollWrote.x){this._scrollEase.stop();return}let t=this._scrollEase.value;this._scrollTop=this._scrollFrom.y+(this._scrollAim.y-this._scrollFrom.y)*t,this._scrollLeft=this._scrollFrom.x+(this._scrollAim.x-this._scrollFrom.x)*t,this._clamp(this._geo()),this._scrollWrote={y:this._scrollTop,x:this._scrollLeft},this._schedDraw()}_cancelScrollEase(){this._scrollEase.stop()}_schedDraw(){this._ticking||(this._ticking=!0,this._schedRaf=requestAnimationFrame(()=>{this._ticking=!1,this._draw()}))}_anyOverlayOpen(){return!!(this._filterPanel||this._colContextMenu||this._rowContextMenu||this._cellContextMenu||this._colChooser||this._newColDialog)}_setHoverRow(t){if(!this._opts.theme.hoverRowBg)return;let e=t===null?0:1,s=t!==null&&t!==this._hoverRow;!s&&e===this._hoverTarget||(s&&(this._hoverRow=t),this._hoverTarget=e,this._hoverFade.to(e,this._hoverFadeMs),this._schedDraw())}_openContextMenuAt(t,e,s){let{headerH:i}=s;if(e>=0&&e<i){let n=this._hitHeader(t,s);return n===null?!1:(this._closeFilterPanel(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._openColContextMenu(n,t,e),!0)}if(s.rowNumW>0&&t<s.rowNumW){let n=this._hitRowNumber(t,e,s);return n===null?!1:(this._closeFilterPanel(),this._closeColContextMenu(),this._closeCellContextMenu(),this._openRowContextMenu(n,t,e),!0)}let o=this._hitCell(t,e,s);return o?(this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._openCellContextMenu(o.row,o.col,t,e),!0):!1}_updateStructuralGesture(t,e){if(this._colResize){let s=Math.max(os,this._colResize.startWidth+t-this._colResize.startX);return this._columnWidths[this._colResize.col]=s,this._canvas.style.cursor="col-resize",this._clamp(this._geo()),this._schedDraw(),!0}if(this._rowResize){let s=Math.max(ns,this._rowResize.startHeight+e-this._rowResize.startY);return this._rowLayout.setHeight(this._rowResize.row,s),this._canvas.style.cursor="row-resize",this._clamp(this._geo()),this._schedDraw(),!0}if(this._colDrag){if(!this._colDrag.active&&Math.abs(t-this._colDrag.startX)>5&&(this._colDrag.active=!0),this._colDrag.active){this._colDrag.x=t;let s=this._calcInsertBefore(t);this._colDrag.insertBefore=s;let i=this._colDrag.col;if(s!==i&&s!==i+1){this._colDrag.undoBefore??=this._snapshotStructural();let o=this._geo().colPositions;this._colDrag.col=this._reorderCol(i,s,{silent:!0}),this._startColSlide(i,this._colDrag.col,o)}this._canvas.style.cursor="grabbing",this._schedDraw()}return!0}return this._rowDrag?(!this._rowDrag.active&&Math.abs(e-this._rowDrag.startY)>5&&(this._rowDrag.active=!0),this._rowDrag.active&&(this._rowDrag.insertBefore=this._calcRowInsertBefore(e),this._canvas.style.cursor="grabbing",this._schedDraw()),!0):this._fillDrag?(this._dragScrollPos={x:t,y:e},this._dragScrollDir=this._dragEdgeDir(t,e),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendFillDrag(t,e),this._canvas.style.cursor="crosshair",this._schedDraw(),!0):!1}_extendFillDrag(t,e,s=this._geo()){let i=this._hitCellClamped(t,e,s);if(!i){this._fillPreview=null;return}let o=this._fillDrag.sel,n=o.type==="single"?o.row:o.r1,l=o.type==="single"?o.row:o.r2,a=o.type==="single"?o.col:o.c1,c=o.type==="single"?o.col:o.c2;i.row>l?this._fillPreview={r1:l+1,c1:a,r2:i.row,c2:c}:i.row<n?this._fillPreview={r1:i.row,c1:a,r2:n-1,c2:c}:i.col>c?this._fillPreview={r1:n,c1:c+1,r2:l,c2:i.col}:i.col<a?this._fillPreview={r1:n,c1:i.col,r2:l,c2:a-1}:this._fillPreview=null}_finalizeStructuralGesture(){if(this._colResize){let{col:t,startWidth:e,undoBefore:s}=this._colResize,i=this._columnWidths[t];if(this._colResize=null,i!==e){let o=this._columns[t];this._columnWidthMap.set(o,i),this._canvas.style.cursor="";let n=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(s),redo:()=>this._restoreStructural(n)}),this._opts.onColumnResize?.(o,i),this._draw()}return!0}if(this._rowResize){let{row:t,startHeight:e,undoBefore:s}=this._rowResize,i=this._rowLayout.heightOf(t);if(this._rowResize=null,i!==e){this._canvas.style.cursor="";let o=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(s),redo:()=>this._restoreStructural(o)}),this._opts.onRowHeightResize?.(t,i),this._draw()}return!0}if(this._colDrag){let{active:t,startCol:e,col:s,undoBefore:i,shiftKey:o}=this._colDrag;if(this._colDrag=null,t&&s!==e&&i){this._revalidateAllFromEdits();let n=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(i),redo:()=>this._restoreStructural(n)}),this._opts.onColumnReorder?.([...this._columns])}else t||(this._updateColSel(e,o),this._kbProxy.focus());return this._canvas.style.cursor="",this._draw(),!0}if(this._rowDrag){let{row:t,insertBefore:e,active:s,ctrlKey:i,shiftKey:o}=this._rowDrag;return this._rowDrag=null,this._canvas.style.cursor="",s?this._reorderRow(t,e):((r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(t,i,o),this._draw(),this._kbProxy.focus()),!0}if(this._fillDrag){if(this._stopDragAutoScroll(),this._fillPreview){let t=this._fillDrag.sel,e=t.type==="single"?t.row:t.r1,s=t.type==="single"?t.row:t.r2,i=t.type==="single"?t.col:t.c1,o=t.type==="single"?t.col:t.c2,{r1:n,c1:l,r2:a,c2:c}=this._fillPreview;this._applyFill(t,this._fillPreview),this._sel={type:"range",r1:Math.min(e,n),c1:Math.min(i,l),r2:Math.max(s,a),c2:Math.max(o,c)},this._opts.onSelectionChange?.(this._sel)}return this._fillDrag=null,this._fillPreview=null,this._canvas.style.cursor="",this._draw(),!0}return!1}_armLongPress(t,e){clearTimeout(this._longPressTimer),this._longPressTimer=setTimeout(()=>{this._longPressTimer=null,this._colDrag=null,this._rowDrag=null,this._rowTap=null,this._touch=null,navigator.vibrate?.(10),this._openContextMenuAt(t,e,this._geo())},Is)}_cancelLongPress(){clearTimeout(this._longPressTimer),this._longPressTimer=null}_bind(){let t=this._ev;t.wheel=e=>{let s=this._geo(),{dx:i,dy:o}=this._wheelPixels(e,s),n=this._scrollEase.animating,l=n?this._scrollAim.y:this._scrollTop,a=n?this._scrollAim.x:this._scrollLeft,c=l<=s.minScrollY,h=l>=s.maxScrollY,d=a<=0,u=a>=s.maxScrollX,f=o!==0&&!(o>0&&h||o<0&&c),_=i!==0&&!(i>0&&u||i<0&&d);!f&&!_||(e.preventDefault(),this._editing&&this._commitEdit(),this._easeWheel(i,o,s)||(this._cancelScrollEase(),this._scrollTop+=o,this._scrollLeft+=i,this._clamp(s)),this._scrolling=!0,this._dm.setHold(!0),clearTimeout(this._scrollEndTimer),this._scrollEndTimer=setTimeout(()=>{this._scrolling=!1,this._dm.setHold(!1),this._schedDraw()},150),this._schedDraw())},t.contextmenu=e=>{let{x:s,y:i}=this._xy(e),o=this._geo();this._openContextMenuAt(s,i,o)&&e.preventDefault()},t.mousedown=e=>{let{x:s,y:i}=this._xy(e),o=this._geo(),n=this._suppressReopenCell;this._suppressReopenCell=null,this._editing&&this._commitEdit(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu();let l=this._filterPanel?.col??-1;if(this._closeFilterPanel(),e.button===2&&this._sel){let u=this._hitCell(s,i,o);if(u&&(this._sel.type==="single"?this._sel.row===u.row&&this._sel.col===u.col:u.row>=this._sel.r1&&u.row<=this._sel.r2&&u.col>=this._sel.c1&&u.col<=this._sel.c2))return}if(this._hitScrollbar(s,i,o)){e.preventDefault();return}let{headerH:a}=o;if(i>=0&&i<a){let u=this._hitHeader(s,o);if(u!==null){let f=o.colPositions[u+1]-o.colPositions[u],_=this._colLeft(u,o)+f,p=_-Bt;if(Math.abs(s-_)<=It){this._colResize={col:u,startX:s,startWidth:f,undoBefore:this._snapshotStructural()},e.preventDefault();return}let w=this._colLeft(u,o);if(u>0&&Math.abs(s-w)<=It){let x=o.colPositions[u]-o.colPositions[u-1];this._colResize={col:u-1,startX:s,startWidth:x,undoBefore:this._snapshotStructural()},e.preventDefault();return}let m=this._columns[u];if(this._colDefMap.get(m)?.headerCheckbox){let x=this._opts.theme?.cellPadding??4,S=this._colLeft(u,o)+x+6,v=zt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(C=>C.isLeaf&&C.col===u),b=v?v.row*this._opts.headerHeight+v.rowspan*this._opts.headerHeight/2:a-this._opts.headerHeight/2;if(Math.abs(s-S)<=9&&Math.abs(i-b)<=9){let C=!(this._headerCheckboxState.get(m)??!1);this._headerCheckboxState.set(m,C),this._draw(),this._opts.onHeaderCheckboxChange?.(m,C),e.preventDefault();return}}if(s>=p&&i>=a-this._opts.headerHeight){u!==l&&this._openFilterPanel(u),e.preventDefault();return}this._colDrag={col:u,startX:s,insertBefore:u,active:!1,x:s,grabDX:s-this._colLeft(u,this._geo()),startCol:u,undoBefore:null,shiftKey:e.shiftKey},e.preventDefault();return}}let c=o.rowNumW>0&&s<o.rowNumW&&i>=o.headerH?this._hitRowBoundary(i,o):null;if(c!==null){this._rowResize={row:c,startY:i,startHeight:this._rowLayout.heightOf(c),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(o.rowNumW>0&&s<o.rowNumW&&i>=o.headerH){let u=this._hitRowNumber(s,i,o);if(u!==null){if(e.preventDefault(),this._rowReorderReady()&&this._localIndexAt(u)<0&&!this._isGroupRow(u)){this._rowDrag={row:u,startY:i,insertBefore:u,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey};return}this._opts.rowReorder&&this._rowOrderData===null&&!r._plugins.some(f=>f.altRowSource?.(this))&&this._materializeRowOrder(),(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(u,e.ctrlKey||e.metaKey,e.shiftKey),this._draw(),this._kbProxy.focus()}return}if(this._sel&&this._hitFillHandle(s,i,o)){this._fillDrag={sel:this._sel},this._fillPreview=null,e.preventDefault();return}let d=this._hitCell(s,i,o);if(d&&e.preventDefault(),d&&this._hitTreeChevron(s,d,o)){this._commitEdit(),this.toggleTreeNode(this._dm.getRow(d.row).__treePath),this._kbProxy.focus();return}if(d&&this._isGroupRow(d.row)){this._commitEdit(),this.toggleGroup(this._dm.getRow(d.row).path),this._kbProxy.focus();return}if(d){if(this._commitEdit(),!e.shiftKey&&!e.ctrlKey&&!e.metaKey){let _=this._columns[d.col];if(this._colDefMap.get(_)?.type==="button"){this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._fireButtonClick(d.row,d.col),this._draw();return}}if(!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._isEditable(d.col)){let _=this._columns[d.col];if(this._colDefMap.get(_)?.type==="checkbox"){this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(d.row+1,this._columnLabels[d.col]??this._columns[d.col],this._cellVal(d.row,d.col)||this._i18n.emptyCell)),this._toggleCheckbox(d.row,d.col);return}}let u=!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._sel?.type==="single"&&this._sel.row===d.row&&this._sel.col===d.col;if(e.shiftKey&&this._sel){this._selAnchor||(this._selAnchor=this._sel.type==="single"?{row:this._sel.row,col:this._sel.col}:{row:this._sel.r1,col:this._sel.c1});let _=this._selAnchor,p=this._normRange(_.row,_.col,d.row,d.col);this._sel=p.r1===p.r2&&p.c1===p.c2?{type:"single",row:p.r1,col:p.c1}:{type:"range",...p}}else this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null;this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,e.ctrlKey||e.metaKey,e.shiftKey),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(d.row+1,this._columnLabels[d.col]??this._columns[d.col],this._cellVal(d.row,d.col)||this._i18n.emptyCell));let f=n&&n.row===d.row&&n.col===d.col;if(u&&!f&&this._isEditable(d.col)){let _=this._columns[d.col],p=this._colDefMap.get(_);if(p?.type==="dropdown"||p?.type==="multiselect"){this._draw(),this._startDropdownEdit(d.row,d.col,p);return}}this._draw()}},t.mousemove=e=>{let{x:s,y:i}=this._xy(e);if(this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag||this._drag||this._selDragging||this._anyOverlayOpen())this._setHoverRow(null);else{let l=this._geo();this._setHoverRow(this._hitCell(s,i,l)?.row??this._hitRowNumber(s,i,l))}if(this._updateStructuralGesture(s,i))return;let n=this._headerH;if(i>=0&&i<n){let l=this._geo(),a=this._hitHeader(s,l);if(a!==null){let c=l.colPositions[a+1]-l.colPositions[a],h=this._colLeft(a,l)+c,d=this._colLeft(a,l);if(Math.abs(s-h)<=It||a>0&&Math.abs(s-d)<=It)this._canvas.style.cursor="col-resize";else{let u=i>=n-this._opts.headerHeight;this._canvas.style.cursor=s>=h-Bt&&u?"pointer":"grab"}}else!this._drag&&!this._selDragging&&(this._canvas.style.cursor="")}else if(!this._drag&&!this._selDragging){let l=this._geo();if(l.rowNumW>0&&s>=0&&s<l.rowNumW&&this._hitRowBoundary(i,l)!==null)this._canvas.style.cursor="row-resize";else if(this._sel&&this._hitFillHandle(s,i))this._canvas.style.cursor="crosshair";else{let a=this._hitCell(s,i),c=a?this._columns[a.col]:null;this._canvas.style.cursor=c&&this._colDefMap.get(c)?.type==="button"?"pointer":""}}if(this._drag){this._updateScrollbarDrag(s,i);return}if(this._selDragging&&(this._dragScrollPos={x:s,y:i},this._dragScrollDir=this._dragEdgeDir(s,i),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendDragSelection(s,i)),!this._drag&&!this._selDragging&&!this._colDrag&&!this._colResize&&!this._rowDrag){let l=this._geo(),a=this._hitCell(s,i,l),c=a&&!this._validator.isValid()?this._validator.map.get(`${a.row}_${this._columns[a.col]}`):null,h=null;if(!c&&a&&this._opts.cellTooltip)try{h=this._opts.cellTooltip(this.getRowData(a.row),a.row,this._columns[a.col],a.col)||null}catch(u){console.error("[JHGrid] cellTooltip error at row",a.row,"col",a.col,":",u)}let d=null;if(!c&&!h&&a)for(let u of r._plugins){let f=u.cellTooltip?.(this,a.row,this._columns[a.col]);if(f){d=f;break}}if(d)for(let u of r._plugins)u.showTooltip?.(this,d,s,i);else for(let u of r._plugins)u.hideTooltip?.(this);if(clearTimeout(this._tooltipTimer),c||h){let{width:u}=this._opts;this._cellTooltip.textContent=c||h,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,u-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else a&&!d&&!this._columnRenderers[a.col]?this._tooltipTimer=setTimeout(()=>{let u=this._cellVal(a.row,a.col);if(!u){this._cellTooltip.style.display="none";return}let{theme:f}=this._opts,_=this._canvas.getContext("2d");_.font=`${f.fontSize}px ${f.fontFamily}`;let w=l.colPositions[a.col+1]-l.colPositions[a.col]-f.cellPadding*2;if(_.measureText(u).width>w){let{width:x}=this._opts;this._cellTooltip.textContent=u,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,x-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else this._cellTooltip.style.display="none"},600):this._cellTooltip.style.display="none"}else{for(let l of r._plugins)l.hideTooltip?.(this);this._cellTooltip.style.display="none",clearTimeout(this._tooltipTimer)}},t.mouseup=()=>{if(this._finalizeStructuralGesture())return;this._drag=null;let e=this._selDragging;this._selDragging=!1,this._stopDragAutoScroll(),e&&this._opts.onSelectionChange?.(this._sel)},t.dblclick=e=>{let{x:s,y:i}=this._xy(e),o=this._headerH;if(i>=0&&i<o){let a=this._geo(),c=this._hitHeader(s,a);if(c!==null){let h=a.colPositions[c+1]-a.colPositions[c],d=this._colLeft(c,a)+h,u=this._colLeft(c,a),f=_=>{let p=this._selectedColsForAutoFit();p&&p.size>1&&(p.has(_)||p.has(_+1))?p.forEach(w=>this._autoFitCol(w)):this._autoFitCol(_)};if(Math.abs(s-d)<=It){f(c),this._clamp(this._geo()),this._draw();return}if(c>0&&Math.abs(s-u)<=It){f(c-1),this._clamp(this._geo()),this._draw();return}}return}let n=this._geo();if(n.rowNumW>0&&s<n.rowNumW&&i>=o){let a=this._hitRowBoundary(i,n);if(a!==null){let c=this._selectedRowsForAutoFit();c&&c.size>1&&(c.has(a)||c.has(a+1))?c.forEach(h=>this._autoFitRow(h)):this._autoFitRow(a),this._clamp(this._geo()),this._draw();return}}let l=this._hitCell(s,i);l&&this._isGroupRow(l.row)||l&&this._hitTreeChevron(s,l,this._geo())||l&&(this._sel={type:"single",row:l.row,col:l.col},this._startEdit(l.row,l.col),this._draw())},t.keydown=e=>{if(this._editing)return;if(this._headerFocusCol!==null){this._handleHeaderFocusKey(e);return}if(this._rowFocus!==null){this._handleRowFocusKey(e);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="z"){e.preventDefault(),e.shiftKey?this.redo():this.undo();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="y"){e.preventDefault(),this.redo();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="c"&&(this._sel||this._selectedRowsSorted().length>0)&&navigator.clipboard?.writeText){e.preventDefault();let i=this._buildCopyText();navigator.clipboard.writeText(i).catch(()=>{}),this._lastCopyMissingRows>0&&(this._showErrorBanner(this._i18n.copyIncomplete(this._lastCopyMissingRows)),this._announce(this._i18n.copyIncomplete(this._lastCopyMissingRows)));return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="v"&&this._sel&&(navigator.clipboard?.readText||navigator.clipboard?.read)){e.preventDefault(),this._pasteFromClipboardAsync();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"&&this._sel){e.preventDefault(),this._selAnchor=null;let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=this._sel.type==="single"?this._sel.col:this._sel.c1,{r1:n,c1:l,r2:a,c2:c}=this._usedRange(i,o);this._setSel(n===a&&l===c?{type:"single",row:n,col:l}:{type:"range",r1:n,c1:l,r2:a,c2:c}),this._ensureVisible(a,c),this._updateA11yCell(),this._draw();return}if(e.key==="Tab"){e.preventDefault(),this._sel&&(this._selAnchor=null,this._moveSel(0,e.shiftKey?-1:1));return}if(e.key==="ArrowUp"&&(e.ctrlKey||e.metaKey)&&this._sel){e.preventDefault(),this._enterHeaderFocus(this._sel.type==="single"?this._sel.col:this._sel.c1);return}if(e.key==="ArrowLeft"&&!e.shiftKey&&this._opts.showRowNumbers&&this._sel&&(this._sel.type==="single"?this._sel.col:this._sel.c1)===0){e.preventDefault(),this._enterRowFocus(this._sel.type==="single"?this._sel.row:this._sel.r1);return}let s=zs[e.key];if(s){if(e.preventDefault(),!this._sel&&this._totalRows>0){this._focusDefaultCell();return}e.shiftKey?this._extendSel(...s):(this._selAnchor=null,this._moveSel(...s));return}if(e.key==="Escape"){if(this._colDrag){let{active:i,undoBefore:o}=this._colDrag;this._colDrag=null,this._colSlide=null,this._colSlideTween.stop(),i&&o&&this._restoreStructural(o),this._canvas.style.cursor="",this._draw();return}if(this._fillDrag){this._fillDrag=null,this._fillPreview=null,this._canvas.style.cursor="",this._draw();return}this._filterPanel?this._closeFilterPanel():this._colContextMenu?this._closeColContextMenu():this._rowContextMenu?this._closeRowContextMenu():this._cellContextMenu?this._closeCellContextMenu():(this._setSel(null),this._selAnchor=null,this._updateA11yCell(),this._draw());return}if(this._sel){if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),this._clearSelection();return}if(e.key==="Home"){e.preventDefault();let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=e.ctrlKey?0:i,n=0;this._setSel({type:"single",row:o,col:n}),this._selAnchor=null,this._ensureVisible(o,n),this._updateA11yCell(),this._announce(this._i18n.announceCell(o+1,this._columnLabels[n]??this._columns[n],this._cellVal(o,n)||this._i18n.emptyCell)),this._draw()}else if(e.key==="End"){e.preventDefault();let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=e.ctrlKey?this._totalRows-1:i,n=this._columns.length-1;this._setSel({type:"single",row:o,col:n}),this._selAnchor=null,this._ensureVisible(o,n),this._updateA11yCell(),this._announce(this._i18n.announceCell(o+1,this._columnLabels[n]??this._columns[n],this._cellVal(o,n)||this._i18n.emptyCell)),this._draw()}else if(e.key==="PageDown"){e.preventDefault(),this._selAnchor=null;let i=Math.max(1,Math.floor(this._geo().vpH/this._rowLayout.defaultHeight));this._moveSel(i,0)}else if(e.key==="PageUp"){e.preventDefault(),this._selAnchor=null;let i=Math.max(1,Math.floor(this._geo().vpH/this._rowLayout.defaultHeight));this._moveSel(-i,0)}else if(e.key===" "||e.key==="F2"||e.key==="Enter"){let i=this._sel.type==="single"?this._dm.getRow(this._sel.row):null,o=!!i?.__treeHasChildren&&this._colDefMap.get(this._columns[this._sel.col])?.treeColumn;if(this._sel.type==="single"&&this._isGroupRow(this._sel.row))e.preventDefault(),this.toggleGroup(this._dm.getRow(this._sel.row).path);else if(o)e.preventDefault(),this.toggleTreeNode(i.__treePath);else if(this._sel.type==="single"){e.preventDefault();let n=this._columns[this._sel.col],l=this._colDefMap.get(n);l?.type==="button"?(this._fireButtonClick(this._sel.row,this._sel.col),this._draw()):l?.type==="checkbox"&&this._isEditable(this._sel.col)?this._toggleCheckbox(this._sel.row,this._sel.col):e.key===" "?this._startEdit(this._sel.row,this._sel.col," "):this._startEdit(this._sel.row,this._sel.col)}}else e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this._sel.type==="single"&&!this._isPlainTextEditor(this._sel.col)&&(e.preventDefault(),this._startEdit(this._sel.row,this._sel.col,e.key))}},t.copy=e=>{if(!this._sel&&this._selectedRowsSorted().length===0||e.target!==this._kbProxy)return;e.preventDefault();let s=this._buildCopyText();e.clipboardData.setData("text/plain",s),this._lastCopyMissingRows>0&&(this._showErrorBanner(this._i18n.copyIncomplete(this._lastCopyMissingRows)),this._announce(this._i18n.copyIncomplete(this._lastCopyMissingRows)))},t.paste=e=>{if(!this._sel||e.target!==this._kbProxy)return;let i=Array.from(e.clipboardData?.items??[]).find(o=>o.type?.startsWith("image/"))?.getAsFile();if(i&&this._pasteImageBlob(i)){e.preventDefault();return}e.preventDefault(),this._applyPaste(e.clipboardData.getData("text/plain"))},t.focus=()=>{this._sel||this._totalRows===0||r._plugin("rowSelection")?.getRenderSet(this)||this._focusDefaultCell()},t.kbProxyInput=()=>{if(this._editing)return;let e=this._sel;if(!(e?.type==="single"&&this._isEditable(e.col)&&this._isPlainTextEditor(e.col))){this._kbProxy.value="";return}this._startEdit(e.row,e.col,void 0,{keepInputValue:!0})},t.docMousedown=e=>{this._anyOverlayOpen()&&(this._wrapper.contains(e.target)||(this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog()))},t.touchstart=e=>{if(e.touches.length===1){let s=e.touches[0],i=this._canvas.getBoundingClientRect(),o=s.clientX-i.left,n=s.clientY-i.top;this._editing&&this._commitEdit(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu();let l=this._filterPanel?.col??-1;this._closeFilterPanel(),this._rowTap=null;let a=this._geo(),c=a.headerH;if(this._hitScrollbar(o,n,a)){e.preventDefault();return}if(n>=0&&n<c){let d=this._hitHeader(o,a);if(d!==null){let u=a.colPositions[d+1]-a.colPositions[d],f=this._colLeft(d,a)+u,_=f-Bt;if(Math.abs(o-f)<=Vt){this._colResize={col:d,startX:o,startWidth:u,undoBefore:this._snapshotStructural()},e.preventDefault();return}let p=this._colLeft(d,a);if(d>0&&Math.abs(o-p)<=Vt){let m=a.colPositions[d]-a.colPositions[d-1];this._colResize={col:d-1,startX:o,startWidth:m,undoBefore:this._snapshotStructural()},e.preventDefault();return}let w=this._columns[d];if(this._colDefMap.get(w)?.headerCheckbox){let m=this._opts.theme?.cellPadding??4,x=this._colLeft(d,a)+m+6,S=zt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(b=>b.isLeaf&&b.col===d),v=S?S.row*this._opts.headerHeight+S.rowspan*this._opts.headerHeight/2:c-this._opts.headerHeight/2;if(Math.abs(o-x)<=Vt&&Math.abs(n-v)<=Vt){let b=!(this._headerCheckboxState.get(w)??!1);this._headerCheckboxState.set(w,b),this._draw(),this._opts.onHeaderCheckboxChange?.(w,b),e.preventDefault();return}}if(o>=_&&n>=c-this._opts.headerHeight){d!==l&&this._openFilterPanel(d),e.preventDefault();return}this._colDrag={col:d,startX:o,insertBefore:d,active:!1,x:o,grabDX:o-this._colLeft(d,a),startCol:d,undoBefore:null,shiftKey:!1},this._armLongPress(o,n),e.preventDefault();return}}let h=a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH?this._hitRowBoundary(n,a,Vt):null;if(h!==null){this._rowResize={row:h,startY:n,startHeight:this._rowLayout.heightOf(h),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH){let d=this._hitRowNumber(o,n,a);d!==null&&(this._rowReorderReady()&&this._localIndexAt(d)<0&&!this._isGroupRow(d)?this._rowDrag={row:d,startY:n,insertBefore:d,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}:(this._opts.rowReorder&&this._rowOrderData===null&&!r._plugins.some(u=>u.altRowSource?.(this))&&this._materializeRowOrder(),this._rowTap={row:d,startY:n,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}),this._armLongPress(o,n),e.preventDefault());return}if(this._sel&&this._hitFillHandle(o,n,a,Vt)){this._fillDrag={sel:this._sel},this._fillPreview=null,e.preventDefault();return}this._touch={startX:o,startY:n,scrollTopStart:this._scrollTop,scrollLeftStart:this._scrollLeft,moved:!1},this._armLongPress(o,n)}else if(e.touches.length===2){this._cancelLongPress();let s=e.touches[0],i=e.touches[1],o=this._canvas.getBoundingClientRect();this._touch={twoFinger:!0,midX:(s.clientX+i.clientX)/2-o.left,midY:(s.clientY+i.clientY)/2-o.top,scrollTopStart:this._scrollTop,scrollLeftStart:this._scrollLeft},e.preventDefault()}},t.touchmove=e=>{if(this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag){if(!e.touches.length)return;let i=e.touches[0],o=this._canvas.getBoundingClientRect();this._updateStructuralGesture(i.clientX-o.left,i.clientY-o.top),(this._colDrag?.active||this._rowDrag?.active)&&this._cancelLongPress(),e.preventDefault();return}if(this._drag){if(!e.touches.length)return;let i=e.touches[0],o=this._canvas.getBoundingClientRect();this._updateScrollbarDrag(i.clientX-o.left,i.clientY-o.top),e.preventDefault();return}if(!this._touch)return;let s=this._canvas.getBoundingClientRect();if(e.touches.length>=2&&this._touch.twoFinger){e.preventDefault();let i=e.touches[0],o=e.touches[1],n=(i.clientX+o.clientX)/2-s.left,l=(i.clientY+o.clientY)/2-s.top,a=this._geo();this._scrollTop=Math.max(a.minScrollY,Math.min(a.maxScrollY,this._touch.scrollTopStart-(l-this._touch.midY))),this._scrollLeft=Math.max(0,Math.min(a.maxScrollX,this._touch.scrollLeftStart-(n-this._touch.midX))),this._schedDraw()}else if(e.touches.length===1&&!this._touch.twoFinger){let i=e.touches[0],o=i.clientX-s.left,n=i.clientY-s.top,l=o-this._touch.startX,a=n-this._touch.startY;if(!this._touch.moved&&(Math.abs(l)>5||Math.abs(a)>5)&&(this._touch.moved=!0,this._cancelLongPress()),this._touch.moved){e.preventDefault();let c=this._geo();this._scrollTop=Math.max(c.minScrollY,Math.min(c.maxScrollY,this._touch.scrollTopStart-a)),this._scrollLeft=Math.max(0,Math.min(c.maxScrollX,this._touch.scrollLeftStart-l)),this._schedDraw()}}else if(this._rowTap){let i=e.touches[0];(Math.abs(i.clientX-s.left-this._rowTap.startX)>5||Math.abs(i.clientY-s.top-this._rowTap.startY)>5)&&this._cancelLongPress()}},t.touchend=e=>{if(this._cancelLongPress(),this._finalizeStructuralGesture())return;if(this._drag){this._drag=null;return}if(this._rowTap){let{row:h,ctrlKey:d,shiftKey:u}=this._rowTap;this._rowTap=null,(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(h,d,u),this._draw(),this._kbProxy.focus();return}if(!this._touch)return;let s=this._touch;if(this._touch=null,s.twoFinger||s.moved||e.changedTouches.length!==1)return;e.preventDefault();let{startX:i,startY:o}=s,n=this._geo(),l=this._hitCell(i,o,n);if(!l)return;let a=Date.now();if(a-this._lastTap.time<350&&this._lastTap.row===l.row&&this._lastTap.col===l.col)this._lastTap={time:0,row:-1,col:-1},this._sel={type:"single",row:l.row,col:l.col},this._startEdit(l.row,l.col),this._draw();else{this._lastTap={time:a,row:l.row,col:l.col},this._editing&&this._commitEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._setSel({type:"single",row:l.row,col:l.col}),this._selAnchor=null,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(l.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(l.row+1,this._columnLabels[l.col]??this._columns[l.col],this._cellVal(l.row,l.col)||this._i18n.emptyCell));let h=this._columns[l.col],d=this._colDefMap.get(h);d?.type==="button"?(this._fireButtonClick(l.row,l.col),this._draw()):d?.type==="checkbox"&&this._isEditable(l.col)?this._toggleCheckbox(l.row,l.col):(d?.type==="dropdown"||d?.type==="multiselect")&&this._isEditable(l.col)?(this._draw(),this._startDropdownEdit(l.row,l.col,d)):this._draw()}},this._canvas.addEventListener("wheel",t.wheel,{passive:!1}),this._canvas.addEventListener("mousedown",t.mousedown),this._canvas.addEventListener("dblclick",t.dblclick),this._canvas.addEventListener("contextmenu",t.contextmenu),this._canvas.addEventListener("touchstart",t.touchstart,{passive:!1}),this._canvas.addEventListener("touchmove",t.touchmove,{passive:!1}),this._canvas.addEventListener("touchend",t.touchend),this._canvas.addEventListener("touchcancel",t.touchend),this._kbProxy.addEventListener("keydown",t.keydown),this._kbProxy.addEventListener("copy",t.copy),this._kbProxy.addEventListener("paste",t.paste),this._kbProxy.addEventListener("focus",t.focus),this._kbProxy.addEventListener("input",t.kbProxyInput),window.addEventListener("mousemove",t.mousemove),window.addEventListener("mouseup",t.mouseup),document.addEventListener("mousedown",t.docMousedown),document.addEventListener("touchstart",t.docMousedown,{passive:!0})}async _boot(t=null){if(this._booting)return this._bootPromise;this._booting=!0;let e;this._bootPromise=new Promise(s=>{e=s});try{let s=await this._opts.fetchMeta(t);if(this._destroyed)return;this._serverTotal=s.totalRows,this._rowPlan.removed.dropFrom(s.totalRows),this._rowPlan.clampAnchors(s.totalRows),this._totalRows=this._rowPlan.totalRows,this._restoreLocalRowState(),this._columns.forEach((a,c)=>{this._columnWidths[c]!=null&&this._columnWidthMap.set(a,this._columnWidths[c])});let i=new Set(s.columns),o=this._opts.columnDefs?.map(a=>a.field)??[],n=o.length>0?[...o.filter(a=>i.has(a)),...s.columns.filter(a=>!o.includes(a))]:[...s.columns];if(this._localColumns.size>0){let a=new Set([...n,...this._localColumns.keys()]);n=this._columnOriginalOrder.length>0?[...this._columnOriginalOrder.filter(c=>a.has(c)),...[...a].filter(c=>!this._columnOriginalOrder.includes(c))]:[...n,...this._localColumns.keys()]}this._columnOriginalOrder.length===0&&(this._columnOriginalOrder=[...n]);let l=n.filter(a=>!this._hiddenColumns.has(a)&&!this._deletedColumns.has(a));this._columns=l,this._columnLabels=l.map(a=>this._colDefMap.get(a)?.label??a),this._columnAligns=l.map(a=>this._colDefMap.get(a)?.align??"left"),this._columnHeaderAligns=l.map(a=>this._colDefMap.get(a)?.headerAlign??this._colDefMap.get(a)?.align??"left"),this._columnWidths=l.map(a=>this._columnWidthMap.get(a)??this._colDefMap.get(a)?.width??this._opts.colWidth),this._columnRenderers=l.map(a=>{let c=this._colDefMap.get(a),h=c?.renderer,d=h?typeof h=="function"?h:pt[h]?.()??null:c?.type==="checkbox"?pt.checkbox():c?.type==="dropdown"?pt.dropdown():c?.type==="button"?pt.button(c.button??{}):c?.type==="date"?pt.date({format:c.format,align:c.align}):c?.type==="multiselect"?pt.multiselect():c?.type==="richtext"?pt.richtext():c?.type==="image"?pt.image():null;return c?.treeColumn?pt.tree({inner:d}):d}),this._hiddenColumns.forEach((a,c)=>{if(a!==null)return;if(n.indexOf(c)===-1){this._hiddenColumns.delete(c);return}this._hiddenColumns.set(c,{label:this._colDefMap.get(c)?.label??c,align:this._colDefMap.get(c)?.align??"left",headerAlign:this._colDefMap.get(c)?.headerAlign??this._colDefMap.get(c)?.align??"left",width:this._columnWidthMap.get(c)??this._colDefMap.get(c)?.width??this._opts.colWidth,renderer:(()=>{let d=this._colDefMap.get(c)?.renderer;return d?typeof d=="function"?d:pt[d]?.()??null:null})()})}),this._loadingEl.style.display="none",this._emptyEl.style.display=this._totalRows===0?"flex":"none",this._wrapper.removeAttribute("aria-busy"),this._updateA11yHeader(),this._pagination&&(this._page=Math.min(this._page,this._pageCount()-1),this._updatePagerBar()),this._isLocalData?this._dm.loadAll(0,this._totalRows-1):this._dm.prefetch(0,Math.min(this._opts.chunkSize-1,this._totalRows-1)),this._draw(),this._opts.rowReorder&&(this._rowOrderData=null,this._rowOrderGen++)}catch(s){console.error("[JHGrid] fetchMeta failed:",s),this._loadingEl.textContent=this._i18n.loadError,this._wrapper.removeAttribute("aria-busy")}finally{this._booting=!1,this._bootPromise=null,e(),this._readyResolve&&(this._readyResolve(),this._readyResolve=null)}}static _selKeyOf(t){return t?t.type==="single"?`s${t.row},${t.col}`:`r${t.r1},${t.c1},${t.r2},${t.c2}`:null}_syncSelAnim(t){let e=r._selKeyOf(t);if(e===this._selKey)return;this._selMoveMs===0||this._selDragging||this._fillDrag||!t||!this._selLast||this._selMove.animating?(this._selPrev=null,this._selMove.set(1)):(this._selPrev=this._selLast,this._selMove.set(0),this._selMove.to(1,this._selMoveMs)),this._selKey=e,this._selLast=t}_draw(){if(this._destroyed)return;let t={filters:null,grouping:null,groupFooter:null};for(let s of r._plugins)s.renderParams?.(this,t);if(this._filters.size>0){let s={};for(let[i,o]of this._filters)this._trivialSetFilters.has(i)||(s[i]=o);t.filters={...s,...t.filters}}let e=this._isButtonCell(this._sel)?null:this._sel;this._syncSelAnim(e),this._renderer.render({scrollTop:this._scrollTop,scrollLeft:this._scrollLeft,totalRows:this._totalRows,columns:this._columns,columnLabels:this._columnLabels,columnAligns:this._columnAligns,columnHeaderAligns:this._columnHeaderAligns,getRow:s=>this._getRow(s),geo:this._geo(),rowLayout:this._rowLayout,sel:e,editing:this._editing?{row:this._editing.row,col:this._editing.col}:null,headerFocusCol:this._headerFocusCol,rowFocus:this._rowFocus,colDrag:this._colDrag,rowDrag:this._rowDrag,sorts:this._sorts,filters:t.filters,columnRenderers:this._columnRenderers,invalidCells:this._validator.isValid()?null:this._validator.map,selectedRows:r._plugin("rowSelection")?.getRenderSet(this)??null,fillPreview:this._fillPreview,deletedRows:this._deletedRows.size>0?this._deletedRows:null,skeletonPhase:this._skeletonPhase(),rowNumberLabel:this._i18n.rowNumberLabel??"No.",grouping:t.grouping,groupFooter:t.groupFooter,hiddenNeighbors:this._computeHiddenNeighbors(),editableColumns:(()=>{let s=this._columns.map((i,o)=>this._isEditable(o));return s.every(Boolean)?null:s})(),i18n:this._i18n,hoverRow:this._hoverRow===null?null:{row:this._hoverRow,alpha:this._hoverFade.value},selAnim:this._selPrev&&this._selMove.value<1?{prev:this._selPrev,t:this._selMove.value}:null,colSlide:this._colSlide&&this._colSlideTween.value<1?{...this._colSlide,dx:this._colSlide.dx*(1-this._colSlideTween.value)}:null,remoteSelections:this._remoteSelections??null,headerCheckboxCols:this._columns.some(s=>this._colDefMap.get(s)?.headerCheckbox)?new Set(this._columns.filter(s=>this._colDefMap.get(s)?.headerCheckbox)):null}),this._drawHeaderCheckboxes(),this._syncKbProxyPosition(),this._opts.onRender?.()}_drawHeaderCheckboxes(){let t=this._geo(),{headerH:e,colPositions:s}=t,i=this._opts.headerHeight,o=12,n=window.devicePixelRatio||1,l=this._canvas.getContext("2d"),a=this._canvas.width/n,c=new Map;for(let h of zt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader))h.isLeaf&&c.set(h.col,h.row*i+h.rowspan*i/2);l.save(),l.setTransform(n,0,0,n,0,0);for(let h=0;h<this._columns.length;h++){let d=this._columns[h];if(!this._colDefMap.get(d)?.headerCheckbox)continue;let u=this._colLeft(h,t),f=(s[h+1]??s[h])-s[h];if(u+f<0||u>a)continue;let _=s.length-1,p=h<t.frozenCount,w=t.frozenRightCount>0&&h>=_-t.frozenRightCount;if(!p&&!w&&u<t.frozenWidth||!p&&!w&&t.frozenRightCount>0&&u>=t.rightX)continue;let m=this._opts.theme?.cellPadding??4,x=u+m+o/2,S=c.get(h)??e-i/2,v=this._headerCheckboxState.get(d)??!1;l.fillStyle=v?"#2563eb":"#ffffff",l.strokeStyle=v?"#2563eb":"#9ca3af",l.lineWidth=1,l.beginPath(),l.rect(x-o/2,S-o/2,o,o),l.fill(),l.stroke(),v&&(l.strokeStyle="#ffffff",l.lineWidth=1.5,l.lineCap="round",l.lineJoin="round",l.beginPath(),l.moveTo(x-3,S),l.lineTo(x-.5,S+2.5),l.lineTo(x+3.5,S-2.5),l.stroke())}l.restore()}_computeHiddenNeighbors(){if(this._hiddenColumns.size===0||this._columnOriginalOrder.length===0)return null;let t=this._columnOriginalOrder,e=this._hiddenColumns,s=new Set(this._columns);return this._columns.map(i=>{let o=t.indexOf(i);if(o<0)return{left:!1,right:!1};let n=!1,l=!1;for(let a=o-1;a>=0;a--){if(e.has(t[a])){n=!0;break}if(s.has(t[a]))break}for(let a=o+1;a<t.length;a++){if(e.has(t[a])){l=!0;break}if(s.has(t[a]))break}return{left:n,right:l}})}ready(){return this._readyPromise}setHeaderCheckbox(t,e){this._headerCheckboxState.set(t,e),this._draw()}getHeaderCheckbox(t){return this._headerCheckboxState.get(t)??!1}repaint(){this._schedDraw()}refresh(){this._closeFilterPanel(),this._cancelEdit();for(let t of r._plugins)t.hideTooltip?.(this);this._setSel(null),this._scrollTop=0,this._scrollLeft=0,this._page=0,this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._undoMgr.clear(),this._editTxn=null,this._filters.clear(),this._trivialSetFilters.clear(),this._sorts=[],this._clearPlugins("full"),this._rowLayout.clear(),this._fillDrag=null,this._fillPreview=null,this._localRows.length=0,this._deletedRows.clear(),this._serverTotal=0,this._rowPlan.reset(0),this._localColumns.clear(),this._deletedColumns.clear(),this._dm.setFetch((t,e)=>this._opts.fetchData(t,e,null)),this._columnWidths=[],this._columnWidthMap.clear(),this._columnOriginalOrder=[],this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._boot()}scrollTo(t){if(typeof t!="number"||!isFinite(t))throw new TypeError("[JHGrid] scrollTo: rowIndex must be a finite number");if(this._pagination){let i=Math.floor(Math.max(0,t)/this._pagination.pageSize);i!==this._page&&this._switchToPage(i)}let{minScrollY:e,maxScrollY:s}=this._geo();this._scrollTop=Math.min(s,Math.max(e,this._rowLayout.yOf(t))),this._draw()}goToPage(t){typeof t!="number"||!isFinite(t)||this._switchToPage(t)}nextPage(){this._pagination&&this._switchToPage(this._page+1)}prevPage(){this._pagination&&this._switchToPage(this._page-1)}getCurrentPage(){return this._pagination?this._page:0}getPageCount(){return this._pageCount()}getEdits(){let t={};return this._edits.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=s.slice(i+1);(t[o]??={})[n]=e}),t}clearEdits(){this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._fillDrag=null,this._fillPreview=null,this._undoMgr.clear(),this._editTxn=null,this._draw()}setRemoteSelections(t){if(!Array.isArray(t))throw new TypeError("[JHGrid] setRemoteSelections: list must be an array");this._remoteSelections=t,this._schedDraw()}setCellValue(t,e,s){if(!Number.isInteger(t)||t<0)throw new TypeError("[JHGrid] setCellValue: row must be a non-negative integer");if(typeof e!="string")throw new TypeError("[JHGrid] setCellValue: field must be a string");if(typeof s!="string")throw new TypeError("[JHGrid] setCellValue: value must be a string");if(this._columns.length>0&&!this._columns.includes(e))throw new RangeError(`[JHGrid] setCellValue: unknown field "${e}"`);this._isGroupRow(t)||(this._editTxnBegin(),this._setEdit(t,e,s),this._editTxnCommit(),this._updateA11yCell(),this._draw())}setCellValues(t){if(!Array.isArray(t))throw new TypeError("[JHGrid] setCellValues: entries must be an array");for(let e of t){let{row:s,field:i,value:o}=e??{};if(!Number.isInteger(s)||s<0)throw new TypeError("[JHGrid] setCellValues: row must be a non-negative integer");if(typeof i!="string")throw new TypeError("[JHGrid] setCellValues: field must be a string");if(typeof o!="string")throw new TypeError("[JHGrid] setCellValues: value must be a string");if(this._columns.length>0&&!this._columns.includes(i))throw new RangeError(`[JHGrid] setCellValues: unknown field "${i}"`)}this._editTxnBegin();for(let{row:e,field:s,value:i}of t)this._isGroupRow(e)||this._setEdit(e,s,i);this._editTxnCommit(),this._updateA11yCell(),this._draw()}addRow(t={},{index:e}={}){return this._withStructuralUndo(()=>{let s=e==null?this._totalRows:Math.max(0,Math.min(e,this._totalRows)),i=this._rowPlan.insertLocal(s);return this._localRows.splice(i,0,{...t}),this._totalRows=this._rowPlan.totalRows,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display="none",s<this._totalRows-1&&this._shiftRowKeyedState(o=>o>=s?o+1:o,{grow:!0}),this._draw(),s})}deleteRow(t,{permanent:e=this._opts.deleteMode==="permanent"}={}){t<0||t>=this._totalRows||this._withStructuralUndo(()=>{let s=this._localIndexAt(t);s>=0?(this._localRows.splice(s,1),this._rowPlan.removeLocal(s),this._totalRows=this._rowPlan.totalRows,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._totalRows===0&&(this._emptyEl.style.display="flex"),this._shiftAfterRemoval(t)):e?this._rowPlan.removed.add(this._rowPlan.sourceAt(t).server)&&(this._totalRows--,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._totalRows===0&&(this._emptyEl.style.display="flex"),this._shiftAfterRemoval(t)):this._deletedRows.add(t),this._sel&&(this._sel.type==="single"?this._sel.row===t:this._sel.r1===t||this._sel.r2===t)&&this._setSel(null),this._draw()})}_shiftRowKeyedState(t,{drop:e=-1,grow:s=!1}={}){let i=(o,n)=>{let l=new Map(o);o.clear(),l.forEach((a,c)=>{let h=c.indexOf("_"),d=Number(c.slice(0,h));if(d===e)return;let u=t(d);o.set(`${u}_${c.slice(h+1)}`,a),n?.(u)})};if(this._editedRows.clear(),i(this._edits,o=>this._editedRows.add(o)),i(this._validator.map),this._deletedRows.size>0){let o=[...this._deletedRows];this._deletedRows.clear();for(let n of o)n!==e&&this._deletedRows.add(t(n))}this._sel&&(this._sel=this._sel.type==="single"?{...this._sel,row:t(this._sel.row)}:{...this._sel,r1:t(this._sel.r1),r2:t(this._sel.r2)}),r._plugin("rowSelection")?.shiftRows(this,t,e),s?this._rowLayout.shiftRows(t):e>=0?this._rowLayout.deleteRow(e):this._rowLayout.shiftRows(t)}_shiftAfterRemoval(t){this._shiftRowKeyedState(e=>e>t?e-1:e,{drop:t})}undeleteRow(t){if(this._deletedRows.has(t)){this._withStructuralUndo(()=>{this._deletedRows.delete(t),this._draw()});return}this._rowPlan.removed.has(t)&&this._withStructuralUndo(()=>{this._rowPlan.removed.delete(t);let e=this._rowPlan.visualOfServer(t);this._totalRows++,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display="none",this._shiftAfterRestore(e),this._draw()})}_shiftAfterRestore(t){this._shiftRowKeyedState(e=>e>=t?e+1:e,{grow:!0})}getNewRows(){return this._localRows.map(t=>({...t}))}getDeletedRows(){return[...this._deletedRows].map(t=>this._rowPlan.sourceAt(t)?.server??-1).filter(t=>t>=0).sort((t,e)=>t-e)}getRemovedRows(){return this._rowPlan.removed.values()}clearFilters(){this._filters.clear(),this._trivialSetFilters.clear(),this._quickFilter="",this._clearPlugins("filterState"),this._sorts=[],this._cancelEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog(),this._cellTooltip&&(this._cellTooltip.style.display="none");for(let t of r._plugins)t.hideTooltip?.(this);this._dm.setFetch((t,e)=>this._opts.fetchData(t,e,null)),this._scrollTop=0,this._scrollLeft=0,this._setSel(null),this._undoMgr.clear(),this._editTxn=null,this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._boot()}getState(){let t={selectedRows:[],grouping:null,treeData:null,colorFilters:null};for(let e of r._plugins)e.exportState?.(this,t);return{columns:[...this._columns],columnWidths:Object.fromEntries(this._columns.map((e,s)=>[e,this._columnWidths[s]])),hiddenColumns:[...this._hiddenColumns.keys()],frozenCols:this._opts.frozenCols??0,frozenColsRight:this._opts.frozenColsRight??0,sorts:this._sorts.map(e=>({...e})),filters:Object.fromEntries(this._filters),quickFilter:this._quickFilter,headerCheckboxState:Object.fromEntries(this._headerCheckboxState),localColumns:this.getNewColumns(),deletedColumns:this.getDeletedColumns(),rowChanges:this._exportRowChanges(),...t}}_exportRowChanges(){let t=i=>{let o={},n=`${i}_`;return this._edits.forEach((l,a)=>{a.startsWith(n)&&(o[a.slice(n.length)]=l)}),o},e=this._localRows.map((i,o)=>({anchor:this._rowPlan.anchors[o],data:{...i},edits:t(this._rowPlan.visualOfLocal(o))})),s={};return this._edits.forEach((i,o)=>{let n=o.indexOf("_"),l=Number(o.slice(0,n)),a=this._rowPlan.sourceAt(l);!a||a.local>=0||((s[a.server]??={})[o.slice(n+1)]=i)}),{added:e,removed:this.getRemovedRows(),marked:this.getDeletedRows(),edits:s}}_importRowChanges(t){if(!t||typeof t!="object")return;this._localRows.length=0,this._rowPlan.anchors.length=0,this._rowPlan.removed.clear(),this._deletedRows.clear(),this._edits.clear(),this._editedRows.clear();for(let i of t.removed??[])this._rowPlan.removed.add(i);let e=[...t.added??[]].sort((i,o)=>(i.anchor??0)-(o.anchor??0));for(let i of e)this._localRows.push({...i.data??{}}),this._rowPlan.anchors.push(i.anchor??this._rowPlan.serverTotal);this._rowPlan.clampAnchors(this._serverTotal),this._totalRows=this._rowPlan.totalRows;let s=(i,o)=>{if(!(i<0||!o))for(let[n,l]of Object.entries(o))this._edits.set(`${i}_${n}`,l),this._editedRows.add(i)};e.forEach((i,o)=>s(this._rowPlan.visualOfLocal(o),i.edits));for(let[i,o]of Object.entries(t.edits??{}))s(this._rowPlan.visualOfServer(Number(i)),o);for(let i of t.marked??[]){let o=this._rowPlan.visualOfServer(i);o>=0&&this._deletedRows.add(o)}this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display=this._totalRows===0?"flex":"none"}setState(t){if(!t)return;this._withStructuralUndo(()=>{if(Array.isArray(t.localColumns))for(let{field:o,...n}of t.localColumns)this._columns.includes(o)||this._hiddenColumns.has(o)||this._deletedColumns.has(o)||this._addColumnImpl(o,n);if(Array.isArray(t.deletedColumns))for(let o of t.deletedColumns)!this._columns.includes(o)||this._localColumns.has(o)||this._deletedColumns.has(o)||(this._hideColumnInternal(o),this._deletedColumns.add(o),this._purgeFieldEdits(o));if(Array.isArray(t.columns)){let o=new Set(t.hiddenColumns??[]);[...this._hiddenColumns.keys()].forEach(h=>this._showColumnInternal(h)),o.forEach(h=>this._hideColumnInternal(h));let n=t.columns.filter(h=>this._columns.includes(h)),l=this._columns.filter(h=>!n.includes(h)),a=[...n,...l],c=h=>a.map(d=>h[this._columns.indexOf(d)]);this._columnLabels=c(this._columnLabels),this._columnAligns=c(this._columnAligns),this._columnHeaderAligns=c(this._columnHeaderAligns),this._columnWidths=c(this._columnWidths),this._columnRenderers=c(this._columnRenderers),this._columns=a}if(t.columnWidths&&Object.entries(t.columnWidths).forEach(([o,n])=>{let l=this._columns.indexOf(o);l!==-1&&(this._columnWidths[l]=n),this._columnWidthMap.set(o,n)}),t.frozenCols!=null&&(this._opts.frozenCols=t.frozenCols),t.frozenColsRight!=null&&(this._opts.frozenColsRight=t.frozenColsRight),Array.isArray(t.sorts)){let o=r._plugins.some(n=>n.extraSortSlots);this._sorts=(o?t.sorts:t.sorts.slice(0,1)).map(n=>({...n}))}else t.sort&&(this._sorts=[{...t.sort}]);t.filters&&(this._filters.clear(),this._trivialSetFilters.clear(),Object.entries(t.filters).forEach(([o,n])=>this._filters.set(o,n))),typeof t.quickFilter=="string"&&(this._quickFilter=t.quickFilter),t.headerCheckboxState&&(this._headerCheckboxState.clear(),Object.entries(t.headerCheckboxState).forEach(([o,n])=>this._headerCheckboxState.set(o,n))),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()});for(let o of r._plugins)o.importState?.(this,t);let e=t.sorts!==void 0||t.filters!==void 0||t.quickFilter!==void 0,s=()=>{t.rowChanges&&this._importRowChanges(t.rowChanges),this._draw()};if(!e)return s(),Promise.resolve();let i=this._reloadFiltered({confirmUnsaved:!1,carryRows:!1});return Promise.resolve(i).then(s)}setFilter(t,e){if(typeof t!="string")throw new TypeError("[JHGrid] setFilter: field must be a string");if(e!=null&&e!==""&&typeof e!="string")throw new TypeError("[JHGrid] setFilter: value must be a string, null, or undefined");if(typeof e=="string"&&e.length>1e3)throw new RangeError("[JHGrid] setFilter: value exceeds maximum length of 1000 characters");if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setFilter: unknown field "${t}"`);this._trivialSetFilters.delete(t),e==null||e===""?this._filters.delete(t):this._filters.set(t,e),this._reloadFiltered()}removeFilter(t){if(typeof t!="string")throw new TypeError("[JHGrid] removeFilter: field must be a string");this._filters.has(t)&&(this._filters.delete(t),this._trivialSetFilters.delete(t),this._reloadFiltered())}setFilterValues(t,e){if(typeof t!="string")throw new TypeError("[JHGrid] setFilterValues: field must be a string");if(e!=null&&!Array.isArray(e))throw new TypeError("[JHGrid] setFilterValues: values must be an array, null, or undefined");if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setFilterValues: unknown field "${t}"`);this._trivialSetFilters.delete(t),e==null?this._filters.delete(t):this._filters.set(t,e.map(String)),this._reloadFiltered()}setQuickFilter(t){if(t!=null&&typeof t!="string")throw new TypeError("[JHGrid] setQuickFilter: value must be a string, null, or undefined");if(typeof t=="string"&&t.length>1e3)throw new RangeError("[JHGrid] setQuickFilter: value exceeds maximum length of 1000 characters");let e=t??"";e!==this._quickFilter&&(this._quickFilter=e,this._reloadFiltered())}getQuickFilter(){return this._quickFilter}clearQuickFilter(){this.setQuickFilter("")}setSort(t,e="asc"){if(typeof t!="string")throw new TypeError("[JHGrid] setSort: field must be a string");if(e!=="asc"&&e!=="desc")throw new RangeError('[JHGrid] setSort: dir must be "asc" or "desc"');if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setSort: unknown field "${t}"`);this._sorts=[{field:t,dir:e}],this._reloadFiltered()}removeSort(t){if(typeof t!="string")throw new TypeError("[JHGrid] removeSort: field must be a string");let e=this._sorts.length;this._sorts=this._sorts.filter(s=>s.field!==t),this._sorts.length!==e&&this._reloadFiltered()}clearSort(){this._sorts.length!==0&&(this._sorts=[],this._reloadFiltered())}getRowData(t){return this._getRow(t)}getOriginalRowData(t){let e=this._rowSource(t);return e?{...e}:null}isNewRow(t){return this._localIndexAt(t)>=0}acknowledgeSave(t,e){let s=this._rowPlan.sourceAt(t);!s||s.local>=0||(this._dm.setRow(s.server,{...e}),this._columns.forEach(i=>this._edits.delete(`${t}_${i}`)),this._editedRows.delete(t),this._updateA11yCell(),this._draw())}acknowledgeInsert(t,e){let s=this._rowPlan.sourceAt(t);if(!s||s.local<0)return!1;let i=this._rowPlan,o=i.anchors[s.local];i.serverTotal++,i.anchors.splice(s.local,1);for(let n=0;n<i.anchors.length;n++)i.anchors[n]>=o&&i.anchors[n]++;return i.removed.shiftFrom(o),this._localRows.splice(s.local,1),this._dm.insertAt(o,{...e}),this._columns.forEach(n=>this._edits.delete(`${t}_${n}`)),this._editedRows.delete(t),this._updateA11yCell(),this._draw(),!0}autoFitColumns(...t){this._destroyed||this._withStructuralUndo(()=>{let e=t.length?t.map(s=>this._columns.indexOf(s)).filter(s=>s!==-1):this._columns.map((s,i)=>i);e.forEach(s=>this._autoFitCol(s)),this._clamp(this._geo()),this._draw(),this._opts.onColumnResize&&e.forEach(s=>this._opts.onColumnResize(this._columns[s],this._columnWidths[s]))})}setRowHeight(t,e){if(this._destroyed)return;if(e===void 0){if(typeof t!="number"||!isFinite(t)||t<=0)throw new TypeError("[JHGrid] setRowHeight: height must be a positive finite number");this._commitEdit(),this._opts.rowHeight=t,this._rowLayout.defaultHeight=t,this._clamp(this._geo()),this._draw();return}let s=t;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>=this._totalRows)throw new RangeError("[JHGrid] setRowHeight: rowIndex out of range");if(typeof e!="number"||!isFinite(e)||e<=0)throw new TypeError("[JHGrid] setRowHeight: height must be a positive finite number");this._commitEdit(),this._rowLayout.setHeight(s,e),this._clamp(this._geo()),this._draw()}getRowHeight(t){return this._rowLayout.heightOf(t)}resetRowHeight(t){this._destroyed||!this._rowLayout.hasOverride(t)||(this._commitEdit(),this._rowLayout.setHeight(t,this._rowLayout.defaultHeight),this._clamp(this._geo()),this._draw())}hideColumn(t){this._hiddenColumns.has(t)||this._withStructuralUndo(()=>{this._hideColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._draw()})}showColumn(t){this._hiddenColumns.has(t)&&this._withStructuralUndo(()=>{this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()})}isColumnVisible(t){return!this._hiddenColumns.has(t)}getHiddenColumns(){return[...this._hiddenColumns.keys()]}_foldColumnIntoAdjacentGroups(t,e){let s=this._opts.headerRows;if(!s?.length)return;let i=e>0?this._columns[e-1]:null,o=e<this._columns.length-1?this._columns[e+1]:null;if(!(!i||!o))for(let n of s)for(let l of n??[])l.fields?.includes(i)&&l.fields?.includes(o)&&!l.fields.includes(t)&&l.fields.push(t)}addColumn(t,e={},{index:s}={}){return typeof t!="string"||!t||this._columns.includes(t)||this._hiddenColumns.has(t)||this._deletedColumns.has(t)?!1:this._withStructuralUndo(()=>this._addColumnImpl(t,e,s))}_addColumnImpl(t,e,s){this._colDefMap.set(t,{label:e.label,align:e.align,headerAlign:e.headerAlign,width:e.width,renderer:e.renderer,editable:e.editable,type:e.type,options:e.options,validation:e.validation,button:e.button,editor:e.editor,editorOptions:e.editorOptions,treeColumn:e.treeColumn,group:e.group}),this._localColumns.set(t,{...e});let i=s==null?this._columns.length:Math.max(0,Math.min(s,this._columns.length)),o=e.label??t,n=e.align??"left",l=e.headerAlign??n,a=e.width??this._opts.colWidth,c=e.renderer?typeof e.renderer=="function"?e.renderer:pt[e.renderer]?.()??null:e.type==="checkbox"?pt.checkbox():e.type==="dropdown"?pt.dropdown():e.type==="button"?pt.button(e.button??{}):e.type==="date"?pt.date({format:e.format,align:e.align}):e.type==="multiselect"?pt.multiselect():e.type==="richtext"?pt.richtext():e.type==="image"?pt.image():null,h=e.treeColumn?pt.tree({inner:c}):c,d=(_,p)=>{let w=[..._];return w.splice(i,0,p),w};this._columns=d(this._columns,t),this._columnLabels=d(this._columnLabels,o),this._columnAligns=d(this._columnAligns,n),this._columnHeaderAligns=d(this._columnHeaderAligns,l),this._columnWidths=d(this._columnWidths,a),this._columnRenderers=d(this._columnRenderers,h),this._columnWidthMap.set(t,a),this._foldColumnIntoAdjacentGroups(t,i);let u=this._columns[i+1]??null,f=u?this._columnOriginalOrder.indexOf(u):-1;if(f===-1?this._columnOriginalOrder.push(t):this._columnOriginalOrder.splice(f,0,t),this._sel){let _=p=>p>=i?p+1:p;this._sel=this._sel.type==="single"?{...this._sel,col:_(this._sel.col)}:{...this._sel,c1:_(this._sel.c1),c2:_(this._sel.c2)}}return this._clamp(this._geo()),this._updateA11yHeader(),this._draw(),!0}deleteColumn(t){return this._columns.includes(t)?(this._withStructuralUndo(()=>{if(this._localColumns.has(t)){let e=this._columns.indexOf(t),s=(o,n)=>n!==e;this._columns=this._columns.filter(s),this._columnLabels=this._columnLabels.filter(s),this._columnAligns=this._columnAligns.filter(s),this._columnHeaderAligns=this._columnHeaderAligns.filter(s),this._columnWidths=this._columnWidths.filter(s),this._columnRenderers=this._columnRenderers.filter(s),this._remapSelForColRemoval(e),this._localColumns.delete(t),this._colDefMap.delete(t),this._columnWidthMap.delete(t);let i=this._columnOriginalOrder.indexOf(t);i!==-1&&this._columnOriginalOrder.splice(i,1)}else this._hideColumnInternal(t),this._deletedColumns.add(t);this._purgeFieldEdits(t),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._draw()}),!0):!1}undeleteColumn(t){this._deletedColumns.has(t)&&this._withStructuralUndo(()=>{this._deletedColumns.delete(t),this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()})}getNewColumns(){return[...this._localColumns].map(([t,e])=>({field:t,...e}))}getDeletedColumns(){return[...this._deletedColumns]}commitColumns(t){let e=t==null?[...this._localColumns.keys(),...this._deletedColumns]:Array.isArray(t)?t:[t];for(let s of e)this._localColumns.delete(s),this._deletedColumns.delete(s)}printGrid({title:t="",includeHeaders:e=!0}={}){let s=this._columns.filter(c=>!this._hiddenColumns.has(c)),i=s.map(c=>this._colDefMap.get(c)?.label??c),o=Ee(c=>this._dm.forEachLoaded(c),this._localRows,c=>this._rowPlan.visualOfServer(c),c=>this._rowPlan.visualOfLocal(c)).map(([c,h])=>{let d={};for(let u of s){let f=`${c}_${u}`,_=this._edits.has(f)?this._edits.get(f):h?.[u];d[u]=Kt(_,this._colDefMap.get(u),this._opts.theme.locale)}return d}),n=document.documentElement.lang||navigator.language||"en",l=Ve({cols:s,labels:i,rows:o,title:t,includeHeaders:e,i18n:this._i18n,lang:n}),a=window.open("","_blank","width=1000,height=720");if(!a){console.error("[JHGrid] printGrid: popup blocked");return}a.document.write(l),a.document.close(),a.focus()}async exportCsv({filename:t,delimiter:e=",",includeHeaders:s=!0,bom:i=!0,full:o=!1}={}){let n=f=>We(f,e),l=[];s&&l.push(this._columnLabels.map(n).join(e));let a=(f,_)=>Kt(_,this._colDefMap.get(f),this._opts.theme.locale);if(o){let f=this._filterState();await this._forEachFilteredRow(f,(_,p)=>{_.forEach((w,m)=>{let x=this._columns.map(S=>{let v=p!=null&&this._edits.has(`${p+m}_${S}`)?this._edits.get(`${p+m}_${S}`):w?.[S];return n(a(S,v))});l.push(x.join(e))})})}else{let f=Ee(p=>this._dm.forEachLoaded(p),this._localRows,p=>this._rowPlan.visualOfServer(p),p=>this._rowPlan.visualOfLocal(p));for(let[p,w]of f){let m=this._columns.map(x=>{let S=`${p}_${x}`,v=this._edits.has(S)?this._edits.get(S):w?.[x];return n(a(x,v))});l.push(m.join(e))}let _=f.length-this._localRows.length;this._serverTotal>_&&console.warn(`[JHGrid] exportCsv: ${_} of ${this._serverTotal} server rows exported (only loaded chunks). Pass { full: true } to export all server rows.`)}let c=(i?"\uFEFF":"")+l.join(`\r
|
|
149
|
-
`),h=new Blob([c],{type:"text/csv;charset=utf-8;"}),d=URL.createObjectURL(h),u=document.createElement("a");u.href=d,u.download=t??this._i18n.exportCsvFilename,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(d)}destroy(){this._destroyed=!0,this._clearPlugins("filterState"),cancelAnimationFrame(this._announceRaf),cancelAnimationFrame(this._schedRaf),this._hoverFade.stop(),this._selMove.stop(),this._scrollEase.stop(),this._colSlideTween.stop(),this._dm.onChunkLoaded=null,Pe(this._imageLoadListener);for(let e of this._pastedImageUrls)URL.revokeObjectURL(e);this._pastedImageUrls.clear(),this._hcMq?.removeEventListener("change",this._hcMqHandler),this._dprMq?.removeEventListener("change",this._dprMqHandler),this._resizeObserver?.disconnect(),this._pagerBar=null;let t=this._ev;clearTimeout(this._tooltipTimer),clearTimeout(this._errorBannerTimer),this._stopDragAutoScroll(),this._cancelEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog(),this._canvas.removeEventListener("wheel",t.wheel),this._canvas.removeEventListener("mousedown",t.mousedown),this._canvas.removeEventListener("dblclick",t.dblclick),this._canvas.removeEventListener("contextmenu",t.contextmenu),this._canvas.removeEventListener("touchstart",t.touchstart),this._canvas.removeEventListener("touchmove",t.touchmove),this._canvas.removeEventListener("touchend",t.touchend),this._canvas.removeEventListener("touchcancel",t.touchend),this._kbProxy.removeEventListener("keydown",t.keydown),this._kbProxy.removeEventListener("copy",t.copy),this._kbProxy.removeEventListener("paste",t.paste),this._kbProxy.removeEventListener("focus",t.focus),this._kbProxy.removeEventListener("input",t.kbProxyInput),window.removeEventListener("mousemove",t.mousemove),window.removeEventListener("mouseup",t.mouseup),document.removeEventListener("mousedown",t.docMousedown),document.removeEventListener("touchstart",t.docMousedown),this._cancelLongPress(),this._container.replaceChildren()}};te.use(Ze);var Us="0.1.
|
|
148
|
+
`)}_pasteImageBlob(t){if(!this._sel)return!1;let e=this._sel.type==="single"?this._sel.row:this._sel.r1,s=this._sel.type==="single"?this._sel.col:this._sel.c1,i=this._columns[s];if(this._colDefMap.get(i)?.type!=="image"||!this._isEditable(s))return!1;let o=this._cellVal(e,s);this._pastedImageUrls.has(o)&&(URL.revokeObjectURL(o),this._pastedImageUrls.delete(o));let n=URL.createObjectURL(t);return this._pastedImageUrls.add(n),this._editTxnBegin(),this._setEdit(e,i,n),this._editTxnCommit(),this._draw(),!0}async _pasteFromClipboardAsync(){if(navigator.clipboard?.read)try{let e=await navigator.clipboard.read();for(let s of e){let i=s.types.find(n=>n.startsWith("image/"));if(!i)continue;let o=await s.getType(i);if(this._pasteImageBlob(o))return}}catch{}if(!navigator.clipboard?.readText)return;let t=await navigator.clipboard.readText().catch(()=>"");t&&this._applyPaste(t)}_applyPaste(t){if(!this._sel||!t)return;let e=je(t.trimEnd()),s=e.length,i=Math.max(...e.map(c=>c.length)),o=this._sel.type==="single"?this._sel.row:this._sel.r1,n=this._sel.type==="single"?this._sel.col:this._sel.c1,l=0,a=(c,h,d)=>{if(c>=this._totalRows||h>=this._columns.length){l++;return}if(!this._isEditable(h)){l++;return}if(this._isGroupRow(c))return;let u=this._columns[h];this._setEdit(c,u,d)};if(this._editTxnBegin(),s===1&&i===1&&this._sel.type==="range"){let c=e[0][0];for(let h=this._sel.r1;h<=this._sel.r2;h++)for(let d=this._sel.c1;d<=this._sel.c2;d++)a(h,d,c)}else e.forEach((c,h)=>c.forEach((d,u)=>a(o+h,n+u,d)));this._editTxnCommit(),this._draw(),l>0&&(this._showErrorBanner(this._i18n.pasteTruncated(l)),this._announce(this._i18n.pasteTruncated(l)))}_applyFill(t,e){let s=t.type==="single"?t.row:t.r1,i=t.type==="single"?t.row:t.r2,o=t.type==="single"?t.col:t.c1,n=t.type==="single"?t.col:t.c2,{r1:l,c1:a,r2:c,c2:h}=e,d=l>i||c<s,u=(d?l>i:a>n)?1:-1,f=d?u>0?l:c:u>0?a:h,_=g=>Math.abs(g-f)+1;if(this._editTxnBegin(),d)for(let g=o;g<=n;g++){if(!this._isEditable(g))continue;let w=[];for(let v=s;v<=i;v++)w.push(this._cellVal(v,g));let m=this._columns[g];for(let v=f;(u>0?v<=c:v>=l)&&!(v>=this._totalRows||v<0);v+=u)this._isGroupRow(v)||this._setEdit(v,m,Ce(w,_(v),u))}else for(let g=s;g<=i;g++){if(this._isGroupRow(g))continue;let w=[];for(let m=o;m<=n;m++)w.push(this._cellVal(g,m));for(let m=f;u>0?m<=h:m>=a;m+=u){if(!this._isEditable(m))continue;let v=this._columns[m];this._setEdit(g,v,Ce(w,_(m),u))}}this._editTxnCommit(),this._draw()}_xy(t){let e=this._canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}_clamp(t){this._scrollTop=Math.max(t.minScrollY,Math.min(t.maxScrollY,this._scrollTop)),this._scrollLeft=Math.max(0,Math.min(t.maxScrollX,this._scrollLeft))}_wheelPixels(t,e){return t.deltaMode===1?{dx:t.deltaX*Ws,dy:t.deltaY*this._opts.rowHeight}:t.deltaMode===2?{dx:t.deltaX*e.vpW,dy:t.deltaY*e.vpH}:{dx:t.deltaX,dy:t.deltaY}}_easeWheel(t,e,s){if(this._scrollEaseMs===0||Math.abs(e)<this._opts.rowHeight&&Math.abs(t)<this._opts.rowHeight)return!1;let i=this._scrollEase.animating,o=(i?this._scrollAim.y:this._scrollTop)+e,n=(i?this._scrollAim.x:this._scrollLeft)+t;return this._scrollAim={y:Math.max(s.minScrollY,Math.min(s.maxScrollY,o)),x:Math.max(0,Math.min(s.maxScrollX,n))},this._scrollFrom={y:this._scrollTop,x:this._scrollLeft},this._scrollWrote={y:this._scrollTop,x:this._scrollLeft},this._scrollEase.set(0),this._scrollEase.to(1,this._scrollEaseMs),!0}_onScrollFrame(){if(this._scrollTop!==this._scrollWrote.y||this._scrollLeft!==this._scrollWrote.x){this._scrollEase.stop();return}let t=this._scrollEase.value;this._scrollTop=this._scrollFrom.y+(this._scrollAim.y-this._scrollFrom.y)*t,this._scrollLeft=this._scrollFrom.x+(this._scrollAim.x-this._scrollFrom.x)*t,this._clamp(this._geo()),this._scrollWrote={y:this._scrollTop,x:this._scrollLeft},this._schedDraw()}_cancelScrollEase(){this._scrollEase.stop()}_schedDraw(){this._ticking||(this._ticking=!0,this._schedRaf=requestAnimationFrame(()=>{this._ticking=!1,this._draw()}))}_anyOverlayOpen(){return!!(this._filterPanel||this._colContextMenu||this._rowContextMenu||this._cellContextMenu||this._colChooser||this._newColDialog)}_setHoverRow(t){if(!this._opts.theme.hoverRowBg)return;let e=t===null?0:1,s=t!==null&&t!==this._hoverRow;!s&&e===this._hoverTarget||(s&&(this._hoverRow=t),this._hoverTarget=e,this._hoverFade.to(e,this._hoverFadeMs),this._schedDraw())}_openContextMenuAt(t,e,s){let{headerH:i}=s;if(e>=0&&e<i){let n=this._hitHeader(t,s);return n===null?!1:(this._closeFilterPanel(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._openColContextMenu(n,t,e),!0)}if(s.rowNumW>0&&t<s.rowNumW){let n=this._hitRowNumber(t,e,s);return n===null?!1:(this._closeFilterPanel(),this._closeColContextMenu(),this._closeCellContextMenu(),this._openRowContextMenu(n,t,e),!0)}let o=this._hitCell(t,e,s);return o?(this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._openCellContextMenu(o.row,o.col,t,e),!0):!1}_updateStructuralGesture(t,e){if(this._colResize){let s=Math.max(os,this._colResize.startWidth+t-this._colResize.startX);return this._columnWidths[this._colResize.col]=s,this._canvas.style.cursor="col-resize",this._clamp(this._geo()),this._schedDraw(),!0}if(this._rowResize){let s=Math.max(ns,this._rowResize.startHeight+e-this._rowResize.startY);return this._rowLayout.setHeight(this._rowResize.row,s),this._canvas.style.cursor="row-resize",this._clamp(this._geo()),this._schedDraw(),!0}if(this._colDrag){if(!this._colDrag.active&&Math.abs(t-this._colDrag.startX)>5&&(this._colDrag.active=!0),this._colDrag.active){this._colDrag.x=t;let s=this._calcInsertBefore(t);this._colDrag.insertBefore=s;let i=this._colDrag.col;if(s!==i&&s!==i+1){this._colDrag.undoBefore??=this._snapshotStructural();let o=this._geo().colPositions;this._colDrag.col=this._reorderCol(i,s,{silent:!0}),this._startColSlide(i,this._colDrag.col,o)}this._canvas.style.cursor="grabbing",this._schedDraw()}return!0}return this._rowDrag?(!this._rowDrag.active&&Math.abs(e-this._rowDrag.startY)>5&&(this._rowDrag.active=!0),this._rowDrag.active&&(this._rowDrag.insertBefore=this._calcRowInsertBefore(e),this._canvas.style.cursor="grabbing",this._schedDraw()),!0):this._fillDrag?(this._dragScrollPos={x:t,y:e},this._dragScrollDir=this._dragEdgeDir(t,e),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendFillDrag(t,e),this._canvas.style.cursor="crosshair",this._schedDraw(),!0):!1}_extendFillDrag(t,e,s=this._geo()){let i=this._hitCellClamped(t,e,s);if(!i){this._fillPreview=null;return}let o=this._fillDrag.sel,n=o.type==="single"?o.row:o.r1,l=o.type==="single"?o.row:o.r2,a=o.type==="single"?o.col:o.c1,c=o.type==="single"?o.col:o.c2;i.row>l?this._fillPreview={r1:l+1,c1:a,r2:i.row,c2:c}:i.row<n?this._fillPreview={r1:i.row,c1:a,r2:n-1,c2:c}:i.col>c?this._fillPreview={r1:n,c1:c+1,r2:l,c2:i.col}:i.col<a?this._fillPreview={r1:n,c1:i.col,r2:l,c2:a-1}:this._fillPreview=null}_finalizeStructuralGesture(){if(this._colResize){let{col:t,startWidth:e,undoBefore:s}=this._colResize,i=this._columnWidths[t];if(this._colResize=null,i!==e){let o=this._columns[t];this._columnWidthMap.set(o,i),this._canvas.style.cursor="";let n=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(s),redo:()=>this._restoreStructural(n)}),this._opts.onColumnResize?.(o,i),this._draw()}return!0}if(this._rowResize){let{row:t,startHeight:e,undoBefore:s}=this._rowResize,i=this._rowLayout.heightOf(t);if(this._rowResize=null,i!==e){this._canvas.style.cursor="";let o=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(s),redo:()=>this._restoreStructural(o)}),this._opts.onRowHeightResize?.(t,i),this._draw()}return!0}if(this._colDrag){let{active:t,startCol:e,col:s,undoBefore:i,shiftKey:o}=this._colDrag;if(this._colDrag=null,t&&s!==e&&i){this._revalidateAllFromEdits();let n=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(i),redo:()=>this._restoreStructural(n)}),this._opts.onColumnReorder?.([...this._columns])}else t||(this._updateColSel(e,o),this._kbProxy.focus());return this._canvas.style.cursor="",this._draw(),!0}if(this._rowDrag){let{row:t,insertBefore:e,active:s,ctrlKey:i,shiftKey:o}=this._rowDrag;return this._rowDrag=null,this._canvas.style.cursor="",s?this._reorderRow(t,e):((r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(t,i,o),this._draw(),this._kbProxy.focus()),!0}if(this._fillDrag){if(this._stopDragAutoScroll(),this._fillPreview){let t=this._fillDrag.sel,e=t.type==="single"?t.row:t.r1,s=t.type==="single"?t.row:t.r2,i=t.type==="single"?t.col:t.c1,o=t.type==="single"?t.col:t.c2,{r1:n,c1:l,r2:a,c2:c}=this._fillPreview;this._applyFill(t,this._fillPreview),this._sel={type:"range",r1:Math.min(e,n),c1:Math.min(i,l),r2:Math.max(s,a),c2:Math.max(o,c)},this._opts.onSelectionChange?.(this._sel)}return this._fillDrag=null,this._fillPreview=null,this._canvas.style.cursor="",this._draw(),!0}return!1}_armLongPress(t,e){clearTimeout(this._longPressTimer),this._longPressTimer=setTimeout(()=>{this._longPressTimer=null,this._colDrag=null,this._rowDrag=null,this._rowTap=null,this._touch=null,navigator.vibrate?.(10),this._openContextMenuAt(t,e,this._geo())},Is)}_cancelLongPress(){clearTimeout(this._longPressTimer),this._longPressTimer=null}_bind(){let t=this._ev;t.wheel=e=>{let s=this._geo(),{dx:i,dy:o}=this._wheelPixels(e,s),n=this._scrollEase.animating,l=n?this._scrollAim.y:this._scrollTop,a=n?this._scrollAim.x:this._scrollLeft,c=l<=s.minScrollY,h=l>=s.maxScrollY,d=a<=0,u=a>=s.maxScrollX,f=o!==0&&!(o>0&&h||o<0&&c),_=i!==0&&!(i>0&&u||i<0&&d);!f&&!_||(e.preventDefault(),this._editing&&this._commitEdit(),this._easeWheel(i,o,s)||(this._cancelScrollEase(),this._scrollTop+=o,this._scrollLeft+=i,this._clamp(s)),this._scrolling=!0,this._dm.setHold(!0),clearTimeout(this._scrollEndTimer),this._scrollEndTimer=setTimeout(()=>{this._scrolling=!1,this._dm.setHold(!1),this._schedDraw()},150),this._schedDraw())},t.contextmenu=e=>{let{x:s,y:i}=this._xy(e),o=this._geo();this._openContextMenuAt(s,i,o)&&e.preventDefault()},t.mousedown=e=>{let{x:s,y:i}=this._xy(e),o=this._geo(),n=this._suppressReopenCell;this._suppressReopenCell=null,this._editing&&this._commitEdit(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu();let l=this._filterPanel?.col??-1;if(this._closeFilterPanel(),e.button===2&&this._sel){let u=this._hitCell(s,i,o);if(u&&(this._sel.type==="single"?this._sel.row===u.row&&this._sel.col===u.col:u.row>=this._sel.r1&&u.row<=this._sel.r2&&u.col>=this._sel.c1&&u.col<=this._sel.c2))return}if(this._hitScrollbar(s,i,o)){e.preventDefault();return}let{headerH:a}=o;if(i>=0&&i<a){let u=this._hitHeader(s,o);if(u!==null){let f=o.colPositions[u+1]-o.colPositions[u],_=this._colLeft(u,o)+f,g=_-Bt;if(Math.abs(s-_)<=It){this._colResize={col:u,startX:s,startWidth:f,undoBefore:this._snapshotStructural()},e.preventDefault();return}let w=this._colLeft(u,o);if(u>0&&Math.abs(s-w)<=It){let v=o.colPositions[u]-o.colPositions[u-1];this._colResize={col:u-1,startX:s,startWidth:v,undoBefore:this._snapshotStructural()},e.preventDefault();return}let m=this._columns[u];if(this._colDefMap.get(m)?.headerCheckbox){let v=this._opts.theme?.cellPadding??4,S=this._colLeft(u,o)+v+6,b=zt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(C=>C.isLeaf&&C.col===u),E=b?b.row*this._opts.headerHeight+b.rowspan*this._opts.headerHeight/2:a-this._opts.headerHeight/2;if(Math.abs(s-S)<=9&&Math.abs(i-E)<=9){let C=!(this._headerCheckboxState.get(m)??!1);this._headerCheckboxState.set(m,C),this._draw(),this._opts.onHeaderCheckboxChange?.(m,C),e.preventDefault();return}}if(s>=g&&i>=a-this._opts.headerHeight){u!==l&&this._openFilterPanel(u),e.preventDefault();return}this._colDrag={col:u,startX:s,insertBefore:u,active:!1,x:s,grabDX:s-this._colLeft(u,this._geo()),startCol:u,undoBefore:null,shiftKey:e.shiftKey},e.preventDefault();return}}let c=o.rowNumW>0&&s<o.rowNumW&&i>=o.headerH?this._hitRowBoundary(i,o):null;if(c!==null){this._rowResize={row:c,startY:i,startHeight:this._rowLayout.heightOf(c),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(o.rowNumW>0&&s<o.rowNumW&&i>=o.headerH){let u=this._hitRowNumber(s,i,o);if(u!==null){if(e.preventDefault(),this._rowReorderReady()&&this._localIndexAt(u)<0&&!this._isGroupRow(u)){this._rowDrag={row:u,startY:i,insertBefore:u,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey};return}this._opts.rowReorder&&this._rowOrderData===null&&!r._plugins.some(f=>f.altRowSource?.(this))&&this._materializeRowOrder(),(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(u,e.ctrlKey||e.metaKey,e.shiftKey),this._draw(),this._kbProxy.focus()}return}if(this._sel&&this._hitFillHandle(s,i,o)){this._fillDrag={sel:this._sel},this._fillPreview=null,e.preventDefault();return}let d=this._hitCell(s,i,o);if(d&&e.preventDefault(),d&&this._hitTreeChevron(s,d,o)){this._commitEdit(),this.toggleTreeNode(this._dm.getRow(d.row).__treePath),this._kbProxy.focus();return}if(d&&this._isGroupRow(d.row)){this._commitEdit(),this.toggleGroup(this._dm.getRow(d.row).path),this._kbProxy.focus();return}if(d){if(this._commitEdit(),!e.shiftKey&&!e.ctrlKey&&!e.metaKey){let _=this._columns[d.col];if(this._colDefMap.get(_)?.type==="button"){this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._fireButtonClick(d.row,d.col),this._draw();return}}if(!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._isEditable(d.col)){let _=this._columns[d.col];if(this._colDefMap.get(_)?.type==="checkbox"){this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(d.row+1,this._columnLabels[d.col]??this._columns[d.col],this._cellVal(d.row,d.col)||this._i18n.emptyCell)),this._toggleCheckbox(d.row,d.col);return}}let u=!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._sel?.type==="single"&&this._sel.row===d.row&&this._sel.col===d.col;if(e.shiftKey&&this._sel){this._selAnchor||(this._selAnchor=this._sel.type==="single"?{row:this._sel.row,col:this._sel.col}:{row:this._sel.r1,col:this._sel.c1});let _=this._selAnchor,g=this._normRange(_.row,_.col,d.row,d.col);this._sel=g.r1===g.r2&&g.c1===g.c2?{type:"single",row:g.r1,col:g.c1}:{type:"range",...g}}else this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null;this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,e.ctrlKey||e.metaKey,e.shiftKey),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(d.row+1,this._columnLabels[d.col]??this._columns[d.col],this._cellVal(d.row,d.col)||this._i18n.emptyCell));let f=n&&n.row===d.row&&n.col===d.col;if(u&&!f&&this._isEditable(d.col)){let _=this._columns[d.col],g=this._colDefMap.get(_);if(g?.type==="dropdown"||g?.type==="multiselect"){this._draw(),this._startDropdownEdit(d.row,d.col,g);return}}this._draw()}},t.mousemove=e=>{let{x:s,y:i}=this._xy(e);if(this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag||this._drag||this._selDragging||this._anyOverlayOpen())this._setHoverRow(null);else{let l=this._geo();this._setHoverRow(this._hitCell(s,i,l)?.row??this._hitRowNumber(s,i,l))}if(this._updateStructuralGesture(s,i))return;let n=this._headerH;if(i>=0&&i<n){let l=this._geo(),a=this._hitHeader(s,l);if(a!==null){let c=l.colPositions[a+1]-l.colPositions[a],h=this._colLeft(a,l)+c,d=this._colLeft(a,l);if(Math.abs(s-h)<=It||a>0&&Math.abs(s-d)<=It)this._canvas.style.cursor="col-resize";else{let u=i>=n-this._opts.headerHeight;this._canvas.style.cursor=s>=h-Bt&&u?"pointer":"grab"}}else!this._drag&&!this._selDragging&&(this._canvas.style.cursor="")}else if(!this._drag&&!this._selDragging){let l=this._geo();if(l.rowNumW>0&&s>=0&&s<l.rowNumW&&this._hitRowBoundary(i,l)!==null)this._canvas.style.cursor="row-resize";else if(this._sel&&this._hitFillHandle(s,i))this._canvas.style.cursor="crosshair";else{let a=this._hitCell(s,i),c=a?this._columns[a.col]:null;this._canvas.style.cursor=c&&this._colDefMap.get(c)?.type==="button"?"pointer":""}}if(this._drag){this._updateScrollbarDrag(s,i);return}if(this._selDragging&&(this._dragScrollPos={x:s,y:i},this._dragScrollDir=this._dragEdgeDir(s,i),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendDragSelection(s,i)),!this._drag&&!this._selDragging&&!this._colDrag&&!this._colResize&&!this._rowDrag){let l=this._geo(),a=this._hitCell(s,i,l),c=a&&!this._validator.isValid()?this._validator.map.get(`${a.row}_${this._columns[a.col]}`):null,h=null;if(!c&&a&&this._opts.cellTooltip)try{h=this._opts.cellTooltip(this.getRowData(a.row),a.row,this._columns[a.col],a.col)||null}catch(u){console.error("[JHGrid] cellTooltip error at row",a.row,"col",a.col,":",u)}let d=null;if(!c&&!h&&a)for(let u of r._plugins){let f=u.cellTooltip?.(this,a.row,this._columns[a.col]);if(f){d=f;break}}if(d)for(let u of r._plugins)u.showTooltip?.(this,d,s,i);else for(let u of r._plugins)u.hideTooltip?.(this);if(clearTimeout(this._tooltipTimer),c||h){let{width:u}=this._opts;this._cellTooltip.textContent=c||h,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,u-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else a&&!d&&!this._columnRenderers[a.col]?this._tooltipTimer=setTimeout(()=>{let u=this._cellVal(a.row,a.col);if(!u){this._cellTooltip.style.display="none";return}let{theme:f}=this._opts,_=this._canvas.getContext("2d");_.font=`${f.fontSize}px ${f.fontFamily}`;let w=l.colPositions[a.col+1]-l.colPositions[a.col]-f.cellPadding*2;if(_.measureText(u).width>w){let{width:v}=this._opts;this._cellTooltip.textContent=u,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,v-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else this._cellTooltip.style.display="none"},600):this._cellTooltip.style.display="none"}else{for(let l of r._plugins)l.hideTooltip?.(this);this._cellTooltip.style.display="none",clearTimeout(this._tooltipTimer)}},t.mouseup=()=>{if(this._finalizeStructuralGesture())return;this._drag=null;let e=this._selDragging;this._selDragging=!1,this._stopDragAutoScroll(),e&&this._opts.onSelectionChange?.(this._sel)},t.dblclick=e=>{let{x:s,y:i}=this._xy(e),o=this._headerH;if(i>=0&&i<o){let a=this._geo(),c=this._hitHeader(s,a);if(c!==null){let h=a.colPositions[c+1]-a.colPositions[c],d=this._colLeft(c,a)+h,u=this._colLeft(c,a),f=_=>{let g=this._selectedColsForAutoFit();g&&g.size>1&&(g.has(_)||g.has(_+1))?g.forEach(w=>this._autoFitCol(w)):this._autoFitCol(_)};if(Math.abs(s-d)<=It){f(c),this._clamp(this._geo()),this._draw();return}if(c>0&&Math.abs(s-u)<=It){f(c-1),this._clamp(this._geo()),this._draw();return}}return}let n=this._geo();if(n.rowNumW>0&&s<n.rowNumW&&i>=o){let a=this._hitRowBoundary(i,n);if(a!==null){let c=this._selectedRowsForAutoFit();c&&c.size>1&&(c.has(a)||c.has(a+1))?c.forEach(h=>this._autoFitRow(h)):this._autoFitRow(a),this._clamp(this._geo()),this._draw();return}}let l=this._hitCell(s,i);l&&this._isGroupRow(l.row)||l&&this._hitTreeChevron(s,l,this._geo())||l&&(this._sel={type:"single",row:l.row,col:l.col},this._startEdit(l.row,l.col),this._draw())},t.keydown=e=>{if(this._editing)return;if(this._headerFocusCol!==null){this._handleHeaderFocusKey(e);return}if(this._rowFocus!==null){this._handleRowFocusKey(e);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="z"){e.preventDefault(),e.shiftKey?this.redo():this.undo();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="y"){e.preventDefault(),this.redo();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="c"&&(this._sel||this._selectedRowsSorted().length>0)&&navigator.clipboard?.writeText){e.preventDefault();let i=this._buildCopyText();navigator.clipboard.writeText(i).catch(()=>{}),this._lastCopyMissingRows>0&&(this._showErrorBanner(this._i18n.copyIncomplete(this._lastCopyMissingRows)),this._announce(this._i18n.copyIncomplete(this._lastCopyMissingRows)));return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="v"&&this._sel&&(navigator.clipboard?.readText||navigator.clipboard?.read)){e.preventDefault(),this._pasteFromClipboardAsync();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"&&this._sel){e.preventDefault(),this._selAnchor=null;let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=this._sel.type==="single"?this._sel.col:this._sel.c1,{r1:n,c1:l,r2:a,c2:c}=this._usedRange(i,o);this._setSel(n===a&&l===c?{type:"single",row:n,col:l}:{type:"range",r1:n,c1:l,r2:a,c2:c}),this._ensureVisible(a,c),this._updateA11yCell(),this._draw();return}if(e.key==="Tab"){e.preventDefault(),this._sel&&(this._selAnchor=null,this._moveSel(0,e.shiftKey?-1:1));return}if(e.key==="ArrowUp"&&(e.ctrlKey||e.metaKey)&&this._sel){e.preventDefault(),this._enterHeaderFocus(this._sel.type==="single"?this._sel.col:this._sel.c1);return}if(e.key==="ArrowLeft"&&!e.shiftKey&&this._opts.showRowNumbers&&this._sel&&(this._sel.type==="single"?this._sel.col:this._sel.c1)===0){e.preventDefault(),this._enterRowFocus(this._sel.type==="single"?this._sel.row:this._sel.r1);return}let s=zs[e.key];if(s){if(e.preventDefault(),!this._sel&&this._totalRows>0){this._focusDefaultCell();return}e.shiftKey?this._extendSel(...s):(this._selAnchor=null,this._moveSel(...s));return}if(e.key==="Escape"){if(this._colDrag){let{active:i,undoBefore:o}=this._colDrag;this._colDrag=null,this._colSlide=null,this._colSlideTween.stop(),i&&o&&this._restoreStructural(o),this._canvas.style.cursor="",this._draw();return}if(this._fillDrag){this._fillDrag=null,this._fillPreview=null,this._canvas.style.cursor="",this._draw();return}this._filterPanel?this._closeFilterPanel():this._colContextMenu?this._closeColContextMenu():this._rowContextMenu?this._closeRowContextMenu():this._cellContextMenu?this._closeCellContextMenu():(this._setSel(null),this._selAnchor=null,this._updateA11yCell(),this._draw());return}if(this._sel){if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),this._clearSelection();return}if(e.key==="Home"){e.preventDefault();let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=e.ctrlKey?0:i,n=0;this._setSel({type:"single",row:o,col:n}),this._selAnchor=null,this._ensureVisible(o,n),this._updateA11yCell(),this._announce(this._i18n.announceCell(o+1,this._columnLabels[n]??this._columns[n],this._cellVal(o,n)||this._i18n.emptyCell)),this._draw()}else if(e.key==="End"){e.preventDefault();let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=e.ctrlKey?this._totalRows-1:i,n=this._columns.length-1;this._setSel({type:"single",row:o,col:n}),this._selAnchor=null,this._ensureVisible(o,n),this._updateA11yCell(),this._announce(this._i18n.announceCell(o+1,this._columnLabels[n]??this._columns[n],this._cellVal(o,n)||this._i18n.emptyCell)),this._draw()}else if(e.key==="PageDown"){e.preventDefault(),this._selAnchor=null;let i=Math.max(1,Math.floor(this._geo().vpH/this._rowLayout.defaultHeight));this._moveSel(i,0)}else if(e.key==="PageUp"){e.preventDefault(),this._selAnchor=null;let i=Math.max(1,Math.floor(this._geo().vpH/this._rowLayout.defaultHeight));this._moveSel(-i,0)}else if(e.key===" "||e.key==="F2"||e.key==="Enter"){let i=this._sel.type==="single"?this._dm.getRow(this._sel.row):null,o=!!i?.__treeHasChildren&&this._colDefMap.get(this._columns[this._sel.col])?.treeColumn;if(this._sel.type==="single"&&this._isGroupRow(this._sel.row))e.preventDefault(),this.toggleGroup(this._dm.getRow(this._sel.row).path);else if(o)e.preventDefault(),this.toggleTreeNode(i.__treePath);else if(this._sel.type==="single"){e.preventDefault();let n=this._columns[this._sel.col],l=this._colDefMap.get(n);l?.type==="button"?(this._fireButtonClick(this._sel.row,this._sel.col),this._draw()):l?.type==="checkbox"&&this._isEditable(this._sel.col)?this._toggleCheckbox(this._sel.row,this._sel.col):e.key===" "?this._startEdit(this._sel.row,this._sel.col," "):this._startEdit(this._sel.row,this._sel.col)}}else e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this._sel.type==="single"&&!this._isPlainTextEditor(this._sel.col)&&(e.preventDefault(),this._startEdit(this._sel.row,this._sel.col,e.key))}},t.copy=e=>{if(!this._sel&&this._selectedRowsSorted().length===0||e.target!==this._kbProxy)return;e.preventDefault();let s=this._buildCopyText();e.clipboardData.setData("text/plain",s),this._lastCopyMissingRows>0&&(this._showErrorBanner(this._i18n.copyIncomplete(this._lastCopyMissingRows)),this._announce(this._i18n.copyIncomplete(this._lastCopyMissingRows)))},t.paste=e=>{if(!this._sel||e.target!==this._kbProxy)return;let i=Array.from(e.clipboardData?.items??[]).find(o=>o.type?.startsWith("image/"))?.getAsFile();if(i&&this._pasteImageBlob(i)){e.preventDefault();return}e.preventDefault(),this._applyPaste(e.clipboardData.getData("text/plain"))},t.focus=()=>{this._sel||this._totalRows===0||r._plugin("rowSelection")?.getRenderSet(this)||this._focusDefaultCell()},t.kbProxyInput=()=>{if(this._editing)return;let e=this._sel;if(!(e?.type==="single"&&this._isEditable(e.col)&&this._isPlainTextEditor(e.col))){this._kbProxy.value="";return}this._startEdit(e.row,e.col,void 0,{keepInputValue:!0})},t.docMousedown=e=>{this._anyOverlayOpen()&&(this._wrapper.contains(e.target)||(this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog()))},t.touchstart=e=>{if(e.touches.length===1){let s=e.touches[0],i=this._canvas.getBoundingClientRect(),o=s.clientX-i.left,n=s.clientY-i.top;this._editing&&this._commitEdit(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu();let l=this._filterPanel?.col??-1;this._closeFilterPanel(),this._rowTap=null;let a=this._geo(),c=a.headerH;if(this._hitScrollbar(o,n,a)){e.preventDefault();return}if(n>=0&&n<c){let d=this._hitHeader(o,a);if(d!==null){let u=a.colPositions[d+1]-a.colPositions[d],f=this._colLeft(d,a)+u,_=f-Bt;if(Math.abs(o-f)<=Vt){this._colResize={col:d,startX:o,startWidth:u,undoBefore:this._snapshotStructural()},e.preventDefault();return}let g=this._colLeft(d,a);if(d>0&&Math.abs(o-g)<=Vt){let m=a.colPositions[d]-a.colPositions[d-1];this._colResize={col:d-1,startX:o,startWidth:m,undoBefore:this._snapshotStructural()},e.preventDefault();return}let w=this._columns[d];if(this._colDefMap.get(w)?.headerCheckbox){let m=this._opts.theme?.cellPadding??4,v=this._colLeft(d,a)+m+6,S=zt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(E=>E.isLeaf&&E.col===d),b=S?S.row*this._opts.headerHeight+S.rowspan*this._opts.headerHeight/2:c-this._opts.headerHeight/2;if(Math.abs(o-v)<=Vt&&Math.abs(n-b)<=Vt){let E=!(this._headerCheckboxState.get(w)??!1);this._headerCheckboxState.set(w,E),this._draw(),this._opts.onHeaderCheckboxChange?.(w,E),e.preventDefault();return}}if(o>=_&&n>=c-this._opts.headerHeight){d!==l&&this._openFilterPanel(d),e.preventDefault();return}this._colDrag={col:d,startX:o,insertBefore:d,active:!1,x:o,grabDX:o-this._colLeft(d,a),startCol:d,undoBefore:null,shiftKey:!1},this._armLongPress(o,n),e.preventDefault();return}}let h=a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH?this._hitRowBoundary(n,a,Vt):null;if(h!==null){this._rowResize={row:h,startY:n,startHeight:this._rowLayout.heightOf(h),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH){let d=this._hitRowNumber(o,n,a);d!==null&&(this._rowReorderReady()&&this._localIndexAt(d)<0&&!this._isGroupRow(d)?this._rowDrag={row:d,startY:n,insertBefore:d,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}:(this._opts.rowReorder&&this._rowOrderData===null&&!r._plugins.some(u=>u.altRowSource?.(this))&&this._materializeRowOrder(),this._rowTap={row:d,startY:n,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}),this._armLongPress(o,n),e.preventDefault());return}if(this._sel&&this._hitFillHandle(o,n,a,Vt)){this._fillDrag={sel:this._sel},this._fillPreview=null,e.preventDefault();return}this._touch={startX:o,startY:n,scrollTopStart:this._scrollTop,scrollLeftStart:this._scrollLeft,moved:!1},this._armLongPress(o,n)}else if(e.touches.length===2){this._cancelLongPress();let s=e.touches[0],i=e.touches[1],o=this._canvas.getBoundingClientRect();this._touch={twoFinger:!0,midX:(s.clientX+i.clientX)/2-o.left,midY:(s.clientY+i.clientY)/2-o.top,scrollTopStart:this._scrollTop,scrollLeftStart:this._scrollLeft},e.preventDefault()}},t.touchmove=e=>{if(this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag){if(!e.touches.length)return;let i=e.touches[0],o=this._canvas.getBoundingClientRect();this._updateStructuralGesture(i.clientX-o.left,i.clientY-o.top),(this._colDrag?.active||this._rowDrag?.active)&&this._cancelLongPress(),e.preventDefault();return}if(this._drag){if(!e.touches.length)return;let i=e.touches[0],o=this._canvas.getBoundingClientRect();this._updateScrollbarDrag(i.clientX-o.left,i.clientY-o.top),e.preventDefault();return}if(!this._touch)return;let s=this._canvas.getBoundingClientRect();if(e.touches.length>=2&&this._touch.twoFinger){e.preventDefault();let i=e.touches[0],o=e.touches[1],n=(i.clientX+o.clientX)/2-s.left,l=(i.clientY+o.clientY)/2-s.top,a=this._geo();this._scrollTop=Math.max(a.minScrollY,Math.min(a.maxScrollY,this._touch.scrollTopStart-(l-this._touch.midY))),this._scrollLeft=Math.max(0,Math.min(a.maxScrollX,this._touch.scrollLeftStart-(n-this._touch.midX))),this._schedDraw()}else if(e.touches.length===1&&!this._touch.twoFinger){let i=e.touches[0],o=i.clientX-s.left,n=i.clientY-s.top,l=o-this._touch.startX,a=n-this._touch.startY;if(!this._touch.moved&&(Math.abs(l)>5||Math.abs(a)>5)&&(this._touch.moved=!0,this._cancelLongPress()),this._touch.moved){e.preventDefault();let c=this._geo();this._scrollTop=Math.max(c.minScrollY,Math.min(c.maxScrollY,this._touch.scrollTopStart-a)),this._scrollLeft=Math.max(0,Math.min(c.maxScrollX,this._touch.scrollLeftStart-l)),this._schedDraw()}}else if(this._rowTap){let i=e.touches[0];(Math.abs(i.clientX-s.left-this._rowTap.startX)>5||Math.abs(i.clientY-s.top-this._rowTap.startY)>5)&&this._cancelLongPress()}},t.touchend=e=>{if(this._cancelLongPress(),this._finalizeStructuralGesture())return;if(this._drag){this._drag=null;return}if(this._rowTap){let{row:h,ctrlKey:d,shiftKey:u}=this._rowTap;this._rowTap=null,(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(h,d,u),this._draw(),this._kbProxy.focus();return}if(!this._touch)return;let s=this._touch;if(this._touch=null,s.twoFinger||s.moved||e.changedTouches.length!==1)return;e.preventDefault();let{startX:i,startY:o}=s,n=this._geo(),l=this._hitCell(i,o,n);if(!l)return;let a=Date.now();if(a-this._lastTap.time<350&&this._lastTap.row===l.row&&this._lastTap.col===l.col)this._lastTap={time:0,row:-1,col:-1},this._sel={type:"single",row:l.row,col:l.col},this._startEdit(l.row,l.col),this._draw();else{this._lastTap={time:a,row:l.row,col:l.col},this._editing&&this._commitEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._setSel({type:"single",row:l.row,col:l.col}),this._selAnchor=null,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(l.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(l.row+1,this._columnLabels[l.col]??this._columns[l.col],this._cellVal(l.row,l.col)||this._i18n.emptyCell));let h=this._columns[l.col],d=this._colDefMap.get(h);d?.type==="button"?(this._fireButtonClick(l.row,l.col),this._draw()):d?.type==="checkbox"&&this._isEditable(l.col)?this._toggleCheckbox(l.row,l.col):(d?.type==="dropdown"||d?.type==="multiselect")&&this._isEditable(l.col)?(this._draw(),this._startDropdownEdit(l.row,l.col,d)):this._draw()}},this._canvas.addEventListener("wheel",t.wheel,{passive:!1}),this._canvas.addEventListener("mousedown",t.mousedown),this._canvas.addEventListener("dblclick",t.dblclick),this._canvas.addEventListener("contextmenu",t.contextmenu),this._canvas.addEventListener("touchstart",t.touchstart,{passive:!1}),this._canvas.addEventListener("touchmove",t.touchmove,{passive:!1}),this._canvas.addEventListener("touchend",t.touchend),this._canvas.addEventListener("touchcancel",t.touchend),this._kbProxy.addEventListener("keydown",t.keydown),this._kbProxy.addEventListener("copy",t.copy),this._kbProxy.addEventListener("paste",t.paste),this._kbProxy.addEventListener("focus",t.focus),this._kbProxy.addEventListener("input",t.kbProxyInput),window.addEventListener("mousemove",t.mousemove),window.addEventListener("mouseup",t.mouseup),document.addEventListener("mousedown",t.docMousedown),document.addEventListener("touchstart",t.docMousedown,{passive:!0})}async _boot(t=null){if(this._booting)return this._bootPromise;this._booting=!0;let e;this._bootPromise=new Promise(s=>{e=s});try{let s=await this._opts.fetchMeta(t);if(this._destroyed)return;this._serverTotal=s.totalRows,this._rowPlan.removed.dropFrom(s.totalRows),this._rowPlan.clampAnchors(s.totalRows),this._totalRows=this._rowPlan.totalRows,this._restoreLocalRowState(),this._columns.forEach((a,c)=>{this._columnWidths[c]!=null&&this._columnWidthMap.set(a,this._columnWidths[c])});let i=new Set(s.columns),o=this._opts.columnDefs?.map(a=>a.field)??[],n=o.length>0?[...o.filter(a=>i.has(a)),...s.columns.filter(a=>!o.includes(a))]:[...s.columns];if(this._localColumns.size>0){let a=new Set([...n,...this._localColumns.keys()]);n=this._columnOriginalOrder.length>0?[...this._columnOriginalOrder.filter(c=>a.has(c)),...[...a].filter(c=>!this._columnOriginalOrder.includes(c))]:[...n,...this._localColumns.keys()]}this._columnOriginalOrder.length===0&&(this._columnOriginalOrder=[...n]);let l=n.filter(a=>!this._hiddenColumns.has(a)&&!this._deletedColumns.has(a));this._columns=l,this._columnLabels=l.map(a=>this._colDefMap.get(a)?.label??a),this._columnAligns=l.map(a=>this._colDefMap.get(a)?.align??"left"),this._columnHeaderAligns=l.map(a=>this._colDefMap.get(a)?.headerAlign??this._colDefMap.get(a)?.align??"left"),this._columnWidths=l.map(a=>this._columnWidthMap.get(a)??this._colDefMap.get(a)?.width??this._opts.colWidth),this._columnRenderers=l.map(a=>{let c=this._colDefMap.get(a),h=c?.renderer,d=h?typeof h=="function"?h:gt[h]?.()??null:c?.type==="checkbox"?gt.checkbox():c?.type==="dropdown"?gt.dropdown():c?.type==="button"?gt.button(c.button??{}):c?.type==="date"?gt.date({format:c.format,align:c.align}):c?.type==="multiselect"?gt.multiselect():c?.type==="richtext"?gt.richtext():c?.type==="image"?gt.image():null;return c?.treeColumn?gt.tree({inner:d}):d}),this._hiddenColumns.forEach((a,c)=>{if(a!==null)return;if(n.indexOf(c)===-1){this._hiddenColumns.delete(c);return}this._hiddenColumns.set(c,{label:this._colDefMap.get(c)?.label??c,align:this._colDefMap.get(c)?.align??"left",headerAlign:this._colDefMap.get(c)?.headerAlign??this._colDefMap.get(c)?.align??"left",width:this._columnWidthMap.get(c)??this._colDefMap.get(c)?.width??this._opts.colWidth,renderer:(()=>{let d=this._colDefMap.get(c)?.renderer;return d?typeof d=="function"?d:gt[d]?.()??null:null})()})}),this._loadingEl.style.display="none",this._emptyEl.style.display=this._totalRows===0?"flex":"none",this._wrapper.removeAttribute("aria-busy"),this._updateA11yHeader(),this._pagination&&(this._page=Math.min(this._page,this._pageCount()-1),this._updatePagerBar()),this._isLocalData?this._dm.loadAll(0,this._totalRows-1):this._dm.prefetch(0,Math.min(this._opts.chunkSize-1,this._totalRows-1)),this._draw(),this._opts.rowReorder&&(this._rowOrderData=null,this._rowOrderGen++)}catch(s){console.error("[JHGrid] fetchMeta failed:",s),this._loadingEl.textContent=this._i18n.loadError,this._wrapper.removeAttribute("aria-busy")}finally{this._booting=!1,this._bootPromise=null,e(),this._readyResolve&&(this._readyResolve(),this._readyResolve=null)}}static _selKeyOf(t){return t?t.type==="single"?`s${t.row},${t.col}`:`r${t.r1},${t.c1},${t.r2},${t.c2}`:null}_syncSelAnim(t){let e=r._selKeyOf(t);if(e===this._selKey)return;this._selMoveMs===0||this._selDragging||this._fillDrag||!t||!this._selLast||this._selMove.animating?(this._selPrev=null,this._selMove.set(1)):(this._selPrev=this._selLast,this._selMove.set(0),this._selMove.to(1,this._selMoveMs)),this._selKey=e,this._selLast=t}_draw(){if(this._destroyed)return;let t={filters:null,grouping:null,groupFooter:null};for(let s of r._plugins)s.renderParams?.(this,t);if(this._filters.size>0){let s={};for(let[i,o]of this._filters)this._trivialSetFilters.has(i)||(s[i]=o);t.filters={...s,...t.filters}}let e=this._isButtonCell(this._sel)?null:this._sel;this._syncSelAnim(e),this._renderer.render({scrollTop:this._scrollTop,scrollLeft:this._scrollLeft,totalRows:this._totalRows,columns:this._columns,columnLabels:this._columnLabels,columnAligns:this._columnAligns,columnHeaderAligns:this._columnHeaderAligns,getRow:s=>this._getRow(s),geo:this._geo(),rowLayout:this._rowLayout,sel:e,editing:this._editing?{row:this._editing.row,col:this._editing.col}:null,headerFocusCol:this._headerFocusCol,rowFocus:this._rowFocus,colDrag:this._colDrag,rowDrag:this._rowDrag,sorts:this._sorts,filters:t.filters,columnRenderers:this._columnRenderers,invalidCells:this._validator.isValid()?null:this._validator.map,selectedRows:r._plugin("rowSelection")?.getRenderSet(this)??null,fillPreview:this._fillPreview,deletedRows:this._deletedRows.size>0?this._deletedRows:null,skeletonPhase:this._skeletonPhase(),rowNumberLabel:this._i18n.rowNumberLabel??"No.",grouping:t.grouping,groupFooter:t.groupFooter,hiddenNeighbors:this._computeHiddenNeighbors(),editableColumns:(()=>{let s=this._columns.map((i,o)=>this._isEditable(o));return s.every(Boolean)?null:s})(),i18n:this._i18n,hoverRow:this._hoverRow===null?null:{row:this._hoverRow,alpha:this._hoverFade.value},selAnim:this._selPrev&&this._selMove.value<1?{prev:this._selPrev,t:this._selMove.value}:null,colSlide:this._colSlide&&this._colSlideTween.value<1?{...this._colSlide,dx:this._colSlide.dx*(1-this._colSlideTween.value)}:null,remoteSelections:this._remoteSelections??null,headerCheckboxCols:this._columns.some(s=>this._colDefMap.get(s)?.headerCheckbox)?new Set(this._columns.filter(s=>this._colDefMap.get(s)?.headerCheckbox)):null}),this._drawHeaderCheckboxes(),this._syncKbProxyPosition(),this._opts.onRender?.()}_drawHeaderCheckboxes(){let t=this._geo(),{headerH:e,colPositions:s}=t,i=this._opts.headerHeight,o=12,n=window.devicePixelRatio||1,l=this._canvas.getContext("2d"),a=this._canvas.width/n,c=new Map;for(let h of zt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader))h.isLeaf&&c.set(h.col,h.row*i+h.rowspan*i/2);l.save(),l.setTransform(n,0,0,n,0,0);for(let h=0;h<this._columns.length;h++){let d=this._columns[h];if(!this._colDefMap.get(d)?.headerCheckbox)continue;let u=this._colLeft(h,t),f=(s[h+1]??s[h])-s[h];if(u+f<0||u>a)continue;let _=s.length-1,g=h<t.frozenCount,w=t.frozenRightCount>0&&h>=_-t.frozenRightCount;if(!g&&!w&&u<t.frozenWidth||!g&&!w&&t.frozenRightCount>0&&u>=t.rightX)continue;let m=this._opts.theme?.cellPadding??4,v=u+m+o/2,S=c.get(h)??e-i/2,b=this._headerCheckboxState.get(d)??!1;l.fillStyle=b?"#2563eb":"#ffffff",l.strokeStyle=b?"#2563eb":"#9ca3af",l.lineWidth=1,l.beginPath(),l.rect(v-o/2,S-o/2,o,o),l.fill(),l.stroke(),b&&(l.strokeStyle="#ffffff",l.lineWidth=1.5,l.lineCap="round",l.lineJoin="round",l.beginPath(),l.moveTo(v-3,S),l.lineTo(v-.5,S+2.5),l.lineTo(v+3.5,S-2.5),l.stroke())}l.restore()}_computeHiddenNeighbors(){if(this._hiddenColumns.size===0||this._columnOriginalOrder.length===0)return null;let t=this._columnOriginalOrder,e=this._hiddenColumns,s=new Set(this._columns);return this._columns.map(i=>{let o=t.indexOf(i);if(o<0)return{left:!1,right:!1};let n=!1,l=!1;for(let a=o-1;a>=0;a--){if(e.has(t[a])){n=!0;break}if(s.has(t[a]))break}for(let a=o+1;a<t.length;a++){if(e.has(t[a])){l=!0;break}if(s.has(t[a]))break}return{left:n,right:l}})}ready(){return this._readyPromise}setHeaderCheckbox(t,e){this._headerCheckboxState.set(t,e),this._draw()}getHeaderCheckbox(t){return this._headerCheckboxState.get(t)??!1}repaint(){this._schedDraw()}refresh(){this._closeFilterPanel(),this._cancelEdit();for(let t of r._plugins)t.hideTooltip?.(this);this._setSel(null),this._scrollTop=0,this._scrollLeft=0,this._page=0,this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._undoMgr.clear(),this._editTxn=null,this._filters.clear(),this._trivialSetFilters.clear(),this._sorts=[],this._clearPlugins("full"),this._rowLayout.clear(),this._fillDrag=null,this._fillPreview=null,this._localRows.length=0,this._deletedRows.clear(),this._serverTotal=0,this._rowPlan.reset(0),this._localColumns.clear(),this._deletedColumns.clear(),this._dm.setFetch((t,e)=>this._opts.fetchData(t,e,null)),this._columnWidths=[],this._columnWidthMap.clear(),this._columnOriginalOrder=[],this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._boot()}scrollTo(t){if(typeof t!="number"||!isFinite(t))throw new TypeError("[JHGrid] scrollTo: rowIndex must be a finite number");if(this._pagination){let i=Math.floor(Math.max(0,t)/this._pagination.pageSize);i!==this._page&&this._switchToPage(i)}let{minScrollY:e,maxScrollY:s}=this._geo();this._scrollTop=Math.min(s,Math.max(e,this._rowLayout.yOf(t))),this._draw()}goToPage(t){typeof t!="number"||!isFinite(t)||this._switchToPage(t)}nextPage(){this._pagination&&this._switchToPage(this._page+1)}prevPage(){this._pagination&&this._switchToPage(this._page-1)}getCurrentPage(){return this._pagination?this._page:0}getPageCount(){return this._pageCount()}getEdits(){let t={};return this._edits.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=s.slice(i+1);(t[o]??={})[n]=e}),t}clearEdits(){this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._fillDrag=null,this._fillPreview=null,this._undoMgr.clear(),this._editTxn=null,this._draw()}setRemoteSelections(t){if(!Array.isArray(t))throw new TypeError("[JHGrid] setRemoteSelections: list must be an array");this._remoteSelections=t,this._schedDraw()}setCellValue(t,e,s){if(!Number.isInteger(t)||t<0)throw new TypeError("[JHGrid] setCellValue: row must be a non-negative integer");if(typeof e!="string")throw new TypeError("[JHGrid] setCellValue: field must be a string");if(typeof s!="string")throw new TypeError("[JHGrid] setCellValue: value must be a string");if(this._columns.length>0&&!this._columns.includes(e))throw new RangeError(`[JHGrid] setCellValue: unknown field "${e}"`);this._isGroupRow(t)||(this._editTxnBegin(),this._setEdit(t,e,s),this._editTxnCommit(),this._updateA11yCell(),this._draw())}setCellValues(t){if(!Array.isArray(t))throw new TypeError("[JHGrid] setCellValues: entries must be an array");for(let e of t){let{row:s,field:i,value:o}=e??{};if(!Number.isInteger(s)||s<0)throw new TypeError("[JHGrid] setCellValues: row must be a non-negative integer");if(typeof i!="string")throw new TypeError("[JHGrid] setCellValues: field must be a string");if(typeof o!="string")throw new TypeError("[JHGrid] setCellValues: value must be a string");if(this._columns.length>0&&!this._columns.includes(i))throw new RangeError(`[JHGrid] setCellValues: unknown field "${i}"`)}this._editTxnBegin();for(let{row:e,field:s,value:i}of t)this._isGroupRow(e)||this._setEdit(e,s,i);this._editTxnCommit(),this._updateA11yCell(),this._draw()}addRow(t={},{index:e}={}){return this._withStructuralUndo(()=>{let s=e==null?this._totalRows:Math.max(0,Math.min(e,this._totalRows)),i=this._rowPlan.insertLocal(s);return this._localRows.splice(i,0,{...t}),this._totalRows=this._rowPlan.totalRows,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display="none",s<this._totalRows-1&&this._shiftRowKeyedState(o=>o>=s?o+1:o,{grow:!0}),this._draw(),s})}deleteRow(t,{permanent:e=this._opts.deleteMode==="permanent"}={}){t<0||t>=this._totalRows||this._withStructuralUndo(()=>{let s=this._localIndexAt(t);s>=0?(this._localRows.splice(s,1),this._rowPlan.removeLocal(s),this._totalRows=this._rowPlan.totalRows,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._totalRows===0&&(this._emptyEl.style.display="flex"),this._shiftAfterRemoval(t)):e?this._rowPlan.removed.add(this._rowPlan.sourceAt(t).server)&&(this._totalRows--,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._totalRows===0&&(this._emptyEl.style.display="flex"),this._shiftAfterRemoval(t)):this._deletedRows.add(t),this._sel&&(this._sel.type==="single"?this._sel.row===t:this._sel.r1===t||this._sel.r2===t)&&this._setSel(null),this._draw()})}_shiftRowKeyedState(t,{drop:e=-1,grow:s=!1}={}){let i=(o,n)=>{let l=new Map(o);o.clear(),l.forEach((a,c)=>{let h=c.indexOf("_"),d=Number(c.slice(0,h));if(d===e)return;let u=t(d);o.set(`${u}_${c.slice(h+1)}`,a),n?.(u)})};if(this._editedRows.clear(),i(this._edits,o=>this._editedRows.add(o)),i(this._validator.map),this._deletedRows.size>0){let o=[...this._deletedRows];this._deletedRows.clear();for(let n of o)n!==e&&this._deletedRows.add(t(n))}this._sel&&(this._sel=this._sel.type==="single"?{...this._sel,row:t(this._sel.row)}:{...this._sel,r1:t(this._sel.r1),r2:t(this._sel.r2)}),r._plugin("rowSelection")?.shiftRows(this,t,e),s?this._rowLayout.shiftRows(t):e>=0?this._rowLayout.deleteRow(e):this._rowLayout.shiftRows(t)}_shiftAfterRemoval(t){this._shiftRowKeyedState(e=>e>t?e-1:e,{drop:t})}undeleteRow(t){if(this._deletedRows.has(t)){this._withStructuralUndo(()=>{this._deletedRows.delete(t),this._draw()});return}this._rowPlan.removed.has(t)&&this._withStructuralUndo(()=>{this._rowPlan.removed.delete(t);let e=this._rowPlan.visualOfServer(t);this._totalRows++,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display="none",this._shiftAfterRestore(e),this._draw()})}_shiftAfterRestore(t){this._shiftRowKeyedState(e=>e>=t?e+1:e,{grow:!0})}getNewRows(){return this._localRows.map(t=>({...t}))}getDeletedRows(){return[...this._deletedRows].map(t=>this._rowPlan.sourceAt(t)?.server??-1).filter(t=>t>=0).sort((t,e)=>t-e)}getRemovedRows(){return this._rowPlan.removed.values()}clearFilters(){this._filters.clear(),this._trivialSetFilters.clear(),this._quickFilter="",this._clearPlugins("filterState"),this._sorts=[],this._cancelEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog(),this._cellTooltip&&(this._cellTooltip.style.display="none");for(let t of r._plugins)t.hideTooltip?.(this);this._dm.setFetch((t,e)=>this._opts.fetchData(t,e,null)),this._scrollTop=0,this._scrollLeft=0,this._setSel(null),this._undoMgr.clear(),this._editTxn=null,this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._boot()}getState(){let t={selectedRows:[],grouping:null,treeData:null,colorFilters:null};for(let e of r._plugins)e.exportState?.(this,t);return{columns:[...this._columns],columnWidths:Object.fromEntries(this._columns.map((e,s)=>[e,this._columnWidths[s]])),hiddenColumns:[...this._hiddenColumns.keys()],frozenCols:this._opts.frozenCols??0,frozenColsRight:this._opts.frozenColsRight??0,sorts:this._sorts.map(e=>({...e})),filters:Object.fromEntries(this._filters),quickFilter:this._quickFilter,headerCheckboxState:Object.fromEntries(this._headerCheckboxState),localColumns:this.getNewColumns(),deletedColumns:this.getDeletedColumns(),rowChanges:this._exportRowChanges(),...t}}_exportRowChanges(){let t=i=>{let o={},n=`${i}_`;return this._edits.forEach((l,a)=>{a.startsWith(n)&&(o[a.slice(n.length)]=l)}),o},e=this._localRows.map((i,o)=>({anchor:this._rowPlan.anchors[o],data:{...i},edits:t(this._rowPlan.visualOfLocal(o))})),s={};return this._edits.forEach((i,o)=>{let n=o.indexOf("_"),l=Number(o.slice(0,n)),a=this._rowPlan.sourceAt(l);!a||a.local>=0||((s[a.server]??={})[o.slice(n+1)]=i)}),{added:e,removed:this.getRemovedRows(),marked:this.getDeletedRows(),edits:s}}_importRowChanges(t){if(!t||typeof t!="object")return;this._localRows.length=0,this._rowPlan.anchors.length=0,this._rowPlan.removed.clear(),this._deletedRows.clear(),this._edits.clear(),this._editedRows.clear();for(let i of t.removed??[])this._rowPlan.removed.add(i);let e=[...t.added??[]].sort((i,o)=>(i.anchor??0)-(o.anchor??0));for(let i of e)this._localRows.push({...i.data??{}}),this._rowPlan.anchors.push(i.anchor??this._rowPlan.serverTotal);this._rowPlan.clampAnchors(this._serverTotal),this._totalRows=this._rowPlan.totalRows;let s=(i,o)=>{if(!(i<0||!o))for(let[n,l]of Object.entries(o))this._edits.set(`${i}_${n}`,l),this._editedRows.add(i)};e.forEach((i,o)=>s(this._rowPlan.visualOfLocal(o),i.edits));for(let[i,o]of Object.entries(t.edits??{}))s(this._rowPlan.visualOfServer(Number(i)),o);for(let i of t.marked??[]){let o=this._rowPlan.visualOfServer(i);o>=0&&this._deletedRows.add(o)}this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display=this._totalRows===0?"flex":"none"}setState(t){if(!t)return;this._withStructuralUndo(()=>{if(Array.isArray(t.localColumns))for(let{field:o,...n}of t.localColumns)this._columns.includes(o)||this._hiddenColumns.has(o)||this._deletedColumns.has(o)||this._addColumnImpl(o,n);if(Array.isArray(t.deletedColumns))for(let o of t.deletedColumns)!this._columns.includes(o)||this._localColumns.has(o)||this._deletedColumns.has(o)||(this._hideColumnInternal(o),this._deletedColumns.add(o),this._purgeFieldEdits(o));if(Array.isArray(t.columns)){let o=new Set(t.hiddenColumns??[]);[...this._hiddenColumns.keys()].forEach(h=>this._showColumnInternal(h)),o.forEach(h=>this._hideColumnInternal(h));let n=t.columns.filter(h=>this._columns.includes(h)),l=this._columns.filter(h=>!n.includes(h)),a=[...n,...l],c=h=>a.map(d=>h[this._columns.indexOf(d)]);this._columnLabels=c(this._columnLabels),this._columnAligns=c(this._columnAligns),this._columnHeaderAligns=c(this._columnHeaderAligns),this._columnWidths=c(this._columnWidths),this._columnRenderers=c(this._columnRenderers),this._columns=a}if(t.columnWidths&&Object.entries(t.columnWidths).forEach(([o,n])=>{let l=this._columns.indexOf(o);l!==-1&&(this._columnWidths[l]=n),this._columnWidthMap.set(o,n)}),t.frozenCols!=null&&(this._opts.frozenCols=t.frozenCols),t.frozenColsRight!=null&&(this._opts.frozenColsRight=t.frozenColsRight),Array.isArray(t.sorts)){let o=r._plugins.some(n=>n.extraSortSlots);this._sorts=(o?t.sorts:t.sorts.slice(0,1)).map(n=>({...n}))}else t.sort&&(this._sorts=[{...t.sort}]);t.filters&&(this._filters.clear(),this._trivialSetFilters.clear(),Object.entries(t.filters).forEach(([o,n])=>this._filters.set(o,n))),typeof t.quickFilter=="string"&&(this._quickFilter=t.quickFilter),t.headerCheckboxState&&(this._headerCheckboxState.clear(),Object.entries(t.headerCheckboxState).forEach(([o,n])=>this._headerCheckboxState.set(o,n))),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()});for(let o of r._plugins)o.importState?.(this,t);let e=t.sorts!==void 0||t.filters!==void 0||t.quickFilter!==void 0,s=()=>{t.rowChanges&&this._importRowChanges(t.rowChanges),this._draw()};if(!e)return s(),Promise.resolve();let i=this._reloadFiltered({confirmUnsaved:!1,carryRows:!1});return Promise.resolve(i).then(s)}setFilter(t,e){if(typeof t!="string")throw new TypeError("[JHGrid] setFilter: field must be a string");if(e!=null&&e!==""&&typeof e!="string")throw new TypeError("[JHGrid] setFilter: value must be a string, null, or undefined");if(typeof e=="string"&&e.length>1e3)throw new RangeError("[JHGrid] setFilter: value exceeds maximum length of 1000 characters");if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setFilter: unknown field "${t}"`);this._trivialSetFilters.delete(t),e==null||e===""?this._filters.delete(t):this._filters.set(t,e),this._reloadFiltered()}removeFilter(t){if(typeof t!="string")throw new TypeError("[JHGrid] removeFilter: field must be a string");this._filters.has(t)&&(this._filters.delete(t),this._trivialSetFilters.delete(t),this._reloadFiltered())}setFilterValues(t,e){if(typeof t!="string")throw new TypeError("[JHGrid] setFilterValues: field must be a string");if(e!=null&&!Array.isArray(e))throw new TypeError("[JHGrid] setFilterValues: values must be an array, null, or undefined");if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setFilterValues: unknown field "${t}"`);this._trivialSetFilters.delete(t),e==null?this._filters.delete(t):this._filters.set(t,e.map(String)),this._reloadFiltered()}setQuickFilter(t){if(t!=null&&typeof t!="string")throw new TypeError("[JHGrid] setQuickFilter: value must be a string, null, or undefined");if(typeof t=="string"&&t.length>1e3)throw new RangeError("[JHGrid] setQuickFilter: value exceeds maximum length of 1000 characters");let e=t??"";e!==this._quickFilter&&(this._quickFilter=e,this._reloadFiltered())}getQuickFilter(){return this._quickFilter}clearQuickFilter(){this.setQuickFilter("")}setSort(t,e="asc"){if(typeof t!="string")throw new TypeError("[JHGrid] setSort: field must be a string");if(e!=="asc"&&e!=="desc")throw new RangeError('[JHGrid] setSort: dir must be "asc" or "desc"');if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setSort: unknown field "${t}"`);this._sorts=[{field:t,dir:e}],this._reloadFiltered()}removeSort(t){if(typeof t!="string")throw new TypeError("[JHGrid] removeSort: field must be a string");let e=this._sorts.length;this._sorts=this._sorts.filter(s=>s.field!==t),this._sorts.length!==e&&this._reloadFiltered()}clearSort(){this._sorts.length!==0&&(this._sorts=[],this._reloadFiltered())}getRowData(t){return this._getRow(t)}getOriginalRowData(t){let e=this._rowSource(t);return e?{...e}:null}isNewRow(t){return this._localIndexAt(t)>=0}acknowledgeSave(t,e){let s=this._rowPlan.sourceAt(t);!s||s.local>=0||(this._dm.setRow(s.server,{...e}),this._columns.forEach(i=>this._edits.delete(`${t}_${i}`)),this._editedRows.delete(t),this._updateA11yCell(),this._draw())}acknowledgeInsert(t,e){let s=this._rowPlan.sourceAt(t);if(!s||s.local<0)return!1;let i=this._rowPlan,o=i.anchors[s.local];i.serverTotal++,i.anchors.splice(s.local,1);for(let n=0;n<i.anchors.length;n++)i.anchors[n]>=o&&i.anchors[n]++;return i.removed.shiftFrom(o),this._localRows.splice(s.local,1),this._dm.insertAt(o,{...e}),this._columns.forEach(n=>this._edits.delete(`${t}_${n}`)),this._editedRows.delete(t),this._updateA11yCell(),this._draw(),!0}autoFitColumns(...t){this._destroyed||this._withStructuralUndo(()=>{let e=t.length?t.map(s=>this._columns.indexOf(s)).filter(s=>s!==-1):this._columns.map((s,i)=>i);e.forEach(s=>this._autoFitCol(s)),this._clamp(this._geo()),this._draw(),this._opts.onColumnResize&&e.forEach(s=>this._opts.onColumnResize(this._columns[s],this._columnWidths[s]))})}setRowHeight(t,e){if(this._destroyed)return;if(e===void 0){if(typeof t!="number"||!isFinite(t)||t<=0)throw new TypeError("[JHGrid] setRowHeight: height must be a positive finite number");this._commitEdit(),this._opts.rowHeight=t,this._rowLayout.defaultHeight=t,this._clamp(this._geo()),this._draw();return}let s=t;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>=this._totalRows)throw new RangeError("[JHGrid] setRowHeight: rowIndex out of range");if(typeof e!="number"||!isFinite(e)||e<=0)throw new TypeError("[JHGrid] setRowHeight: height must be a positive finite number");this._commitEdit(),this._rowLayout.setHeight(s,e),this._clamp(this._geo()),this._draw()}getRowHeight(t){return this._rowLayout.heightOf(t)}resetRowHeight(t){this._destroyed||!this._rowLayout.hasOverride(t)||(this._commitEdit(),this._rowLayout.setHeight(t,this._rowLayout.defaultHeight),this._clamp(this._geo()),this._draw())}hideColumn(t){this._hiddenColumns.has(t)||this._withStructuralUndo(()=>{this._hideColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._draw()})}showColumn(t){this._hiddenColumns.has(t)&&this._withStructuralUndo(()=>{this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()})}isColumnVisible(t){return!this._hiddenColumns.has(t)}getHiddenColumns(){return[...this._hiddenColumns.keys()]}_foldColumnIntoAdjacentGroups(t,e){let s=this._opts.headerRows;if(!s?.length)return;let i=e>0?this._columns[e-1]:null,o=e<this._columns.length-1?this._columns[e+1]:null;if(!(!i||!o))for(let n of s)for(let l of n??[])l.fields?.includes(i)&&l.fields?.includes(o)&&!l.fields.includes(t)&&l.fields.push(t)}addColumn(t,e={},{index:s}={}){return typeof t!="string"||!t||this._columns.includes(t)||this._hiddenColumns.has(t)||this._deletedColumns.has(t)?!1:this._withStructuralUndo(()=>this._addColumnImpl(t,e,s))}_addColumnImpl(t,e,s){this._colDefMap.set(t,{label:e.label,align:e.align,headerAlign:e.headerAlign,width:e.width,renderer:e.renderer,editable:e.editable,type:e.type,options:e.options,validation:e.validation,button:e.button,editor:e.editor,editorOptions:e.editorOptions,treeColumn:e.treeColumn,group:e.group}),this._localColumns.set(t,{...e});let i=s==null?this._columns.length:Math.max(0,Math.min(s,this._columns.length)),o=e.label??t,n=e.align??"left",l=e.headerAlign??n,a=e.width??this._opts.colWidth,c=e.renderer?typeof e.renderer=="function"?e.renderer:gt[e.renderer]?.()??null:e.type==="checkbox"?gt.checkbox():e.type==="dropdown"?gt.dropdown():e.type==="button"?gt.button(e.button??{}):e.type==="date"?gt.date({format:e.format,align:e.align}):e.type==="multiselect"?gt.multiselect():e.type==="richtext"?gt.richtext():e.type==="image"?gt.image():null,h=e.treeColumn?gt.tree({inner:c}):c,d=(_,g)=>{let w=[..._];return w.splice(i,0,g),w};this._columns=d(this._columns,t),this._columnLabels=d(this._columnLabels,o),this._columnAligns=d(this._columnAligns,n),this._columnHeaderAligns=d(this._columnHeaderAligns,l),this._columnWidths=d(this._columnWidths,a),this._columnRenderers=d(this._columnRenderers,h),this._columnWidthMap.set(t,a),this._foldColumnIntoAdjacentGroups(t,i);let u=this._columns[i+1]??null,f=u?this._columnOriginalOrder.indexOf(u):-1;if(f===-1?this._columnOriginalOrder.push(t):this._columnOriginalOrder.splice(f,0,t),this._sel){let _=g=>g>=i?g+1:g;this._sel=this._sel.type==="single"?{...this._sel,col:_(this._sel.col)}:{...this._sel,c1:_(this._sel.c1),c2:_(this._sel.c2)}}return this._clamp(this._geo()),this._updateA11yHeader(),this._draw(),!0}deleteColumn(t){return this._columns.includes(t)?(this._withStructuralUndo(()=>{if(this._localColumns.has(t)){let e=this._columns.indexOf(t),s=(o,n)=>n!==e;this._columns=this._columns.filter(s),this._columnLabels=this._columnLabels.filter(s),this._columnAligns=this._columnAligns.filter(s),this._columnHeaderAligns=this._columnHeaderAligns.filter(s),this._columnWidths=this._columnWidths.filter(s),this._columnRenderers=this._columnRenderers.filter(s),this._remapSelForColRemoval(e),this._localColumns.delete(t),this._colDefMap.delete(t),this._columnWidthMap.delete(t);let i=this._columnOriginalOrder.indexOf(t);i!==-1&&this._columnOriginalOrder.splice(i,1)}else this._hideColumnInternal(t),this._deletedColumns.add(t);this._purgeFieldEdits(t),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._draw()}),!0):!1}undeleteColumn(t){this._deletedColumns.has(t)&&this._withStructuralUndo(()=>{this._deletedColumns.delete(t),this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()})}getNewColumns(){return[...this._localColumns].map(([t,e])=>({field:t,...e}))}getDeletedColumns(){return[...this._deletedColumns]}commitColumns(t){let e=t==null?[...this._localColumns.keys(),...this._deletedColumns]:Array.isArray(t)?t:[t];for(let s of e)this._localColumns.delete(s),this._deletedColumns.delete(s)}printGrid({title:t="",includeHeaders:e=!0}={}){let s=this._columns.filter(c=>!this._hiddenColumns.has(c)),i=s.map(c=>this._colDefMap.get(c)?.label??c),o=Ee(c=>this._dm.forEachLoaded(c),this._localRows,c=>this._rowPlan.visualOfServer(c),c=>this._rowPlan.visualOfLocal(c)).map(([c,h])=>{let d={};for(let u of s){let f=`${c}_${u}`,_=this._edits.has(f)?this._edits.get(f):h?.[u];d[u]=Kt(_,this._colDefMap.get(u),this._opts.theme.locale)}return d}),n=document.documentElement.lang||navigator.language||"en",l=Ve({cols:s,labels:i,rows:o,title:t,includeHeaders:e,i18n:this._i18n,lang:n}),a=window.open("","_blank","width=1000,height=720");if(!a){console.error("[JHGrid] printGrid: popup blocked");return}a.document.write(l),a.document.close(),a.focus()}async exportCsv({filename:t,delimiter:e=",",includeHeaders:s=!0,bom:i=!0,full:o=!1}={}){let n=f=>We(f,e),l=[];s&&l.push(this._columnLabels.map(n).join(e));let a=(f,_)=>Kt(_,this._colDefMap.get(f),this._opts.theme.locale);if(o){let f=this._filterState();await this._forEachFilteredRow(f,(_,g)=>{_.forEach((w,m)=>{let v=this._columns.map(S=>{let b=g!=null&&this._edits.has(`${g+m}_${S}`)?this._edits.get(`${g+m}_${S}`):w?.[S];return n(a(S,b))});l.push(v.join(e))})})}else{let f=Ee(g=>this._dm.forEachLoaded(g),this._localRows,g=>this._rowPlan.visualOfServer(g),g=>this._rowPlan.visualOfLocal(g));for(let[g,w]of f){let m=this._columns.map(v=>{let S=`${g}_${v}`,b=this._edits.has(S)?this._edits.get(S):w?.[v];return n(a(v,b))});l.push(m.join(e))}let _=f.length-this._localRows.length;this._serverTotal>_&&console.warn(`[JHGrid] exportCsv: ${_} of ${this._serverTotal} server rows exported (only loaded chunks). Pass { full: true } to export all server rows.`)}let c=(i?"\uFEFF":"")+l.join(`\r
|
|
149
|
+
`),h=new Blob([c],{type:"text/csv;charset=utf-8;"}),d=URL.createObjectURL(h),u=document.createElement("a");u.href=d,u.download=t??this._i18n.exportCsvFilename,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(d)}destroy(){this._destroyed=!0,this._clearPlugins("filterState"),cancelAnimationFrame(this._announceRaf),cancelAnimationFrame(this._schedRaf),this._hoverFade.stop(),this._selMove.stop(),this._scrollEase.stop(),this._colSlideTween.stop(),this._dm.onChunkLoaded=null,Pe(this._imageLoadListener);for(let e of this._pastedImageUrls)URL.revokeObjectURL(e);this._pastedImageUrls.clear(),this._hcMq?.removeEventListener("change",this._hcMqHandler),this._dprMq?.removeEventListener("change",this._dprMqHandler),this._resizeObserver?.disconnect(),this._pagerBar=null;let t=this._ev;clearTimeout(this._tooltipTimer),clearTimeout(this._errorBannerTimer),this._stopDragAutoScroll(),this._cancelEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog(),this._canvas.removeEventListener("wheel",t.wheel),this._canvas.removeEventListener("mousedown",t.mousedown),this._canvas.removeEventListener("dblclick",t.dblclick),this._canvas.removeEventListener("contextmenu",t.contextmenu),this._canvas.removeEventListener("touchstart",t.touchstart),this._canvas.removeEventListener("touchmove",t.touchmove),this._canvas.removeEventListener("touchend",t.touchend),this._canvas.removeEventListener("touchcancel",t.touchend),this._kbProxy.removeEventListener("keydown",t.keydown),this._kbProxy.removeEventListener("copy",t.copy),this._kbProxy.removeEventListener("paste",t.paste),this._kbProxy.removeEventListener("focus",t.focus),this._kbProxy.removeEventListener("input",t.kbProxyInput),window.removeEventListener("mousemove",t.mousemove),window.removeEventListener("mouseup",t.mouseup),document.removeEventListener("mousedown",t.docMousedown),document.removeEventListener("touchstart",t.docMousedown),this._cancelLongPress(),this._container.replaceChildren()}};te.use(Ze);var Us="0.1.3",Xs={chrome:99,edge:99,firefox:112,safari:15.4};return _s(qs);})();
|