@jh-grid/jhgrid-js 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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:()=>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(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/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&&lt>=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&&lt>=U&&lt<=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=`
1
+ var JHGrid=(()=>{var _e=Object.defineProperty;var cs=Object.getOwnPropertyDescriptor;var hs=Object.getOwnPropertyNames;var ds=Object.prototype.hasOwnProperty;var us=(l,t)=>{for(var e in t)_e(l,e,{get:t[e],enumerable:!0})},_s=(l,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of hs(t))!ds.call(l,i)&&i!==e&&_e(l,i,{get:()=>t[i],enumerable:!(s=cs(t,i))||s.enumerable});return l};var fs=l=>_s(_e({},"__esModule",{value:!0}),l);var ei={};us(ei,{BuiltinRenderers:()=>pt,CellEditors:()=>Ft,CellRenderers:()=>pt,DEFAULT_THEME:()=>Xt,DataManager:()=>Wt,GRID_CLASSES:()=>B,JA_I18N:()=>Jt,JHGrid:()=>Qt,KO_I18N:()=>qt,Renderer:()=>jt,SUPPORTED_BROWSERS:()=>ti,VERSION:()=>Qs,ZH_I18N:()=>Zt,computeHeaderCells:()=>Bt,registerCellEditor:()=>ve,registerCellRenderer:()=>be});var Wt=class{#e;#t;#o;#s=new Map;#i=-1;#n=null;#r=new Set;#l=new Set;#h=new Set;#a=0;#c=new Map;#d;#p;#u=!1;onChunkLoaded=null;onChunkError=null;constructor({fetchData:t,chunkSize:e=300,maxChunks:s=50,maxInFlight:i=2,maxQueued:o=4}){this.#e=t,this.#t=e,this.#o=s,this.#d=Math.max(1,i),this.#p=Math.max(1,o)}getRow(t){let e=Math.floor(t/this.#t);if(e===this.#i)return this.#n[t%this.#t]??null;if(this.#s.has(e)){let s=this.#s.get(e);return this.#s.delete(e),this.#s.set(e,s),this.#i=e,this.#n=s,s[t%this.#t]??null}return this.#_(e),null}setRow(t,e){let s=Math.floor(t/this.#t),i=this.#s.get(s);i&&(i[t%this.#t]=e)}insertAt(t,e){let s=e,i=t;for(;s!==void 0;){let o=Math.floor(i/this.#t),n=this.#s.get(o);if(!n)break;let r=i%this.#t;if(r>n.length)break;let a=r<n.length?n[n.length-1]:void 0;for(let c=n.length-1;c>r;c--)n[c]=n[c-1];n[r]=s,s=a,i=(o+1)*this.#t}}prefetch(t,e){let s=Math.floor(t/this.#t),i=Math.floor(e/this.#t);for(let o=s;o<=i+1;o++)this.#_(o)}async loadAll(t,e){let s=Math.floor(t/this.#t),i=Math.floor(e/this.#t),o=[];for(let a=s;a<=i;a++)o.push(a);let n=0,r=async()=>{for(;n<o.length;)await this.#g(o[n++])};await Promise.all(Array.from({length:this.#d},r))}#_(t){if(!(this.#s.has(t)||this.#r.has(t)||this.#l.has(t))){for(this.#c.delete(t),this.#c.set(t,!0);this.#c.size>this.#p;)this.#c.delete(this.#c.keys().next().value);this.#f()}}setHold(t){let e=this.#u;this.#u=!!t,!(!e||this.#u)&&(this.#c.clear(),this.#f())}#f(){if(!this.#u)for(;this.#r.size<this.#d&&this.#c.size>0;){let t;for(let e of this.#c.keys())t=e;this.#c.delete(t),this.#g(t)}}setFetch(t){this.#e=t,this.#a++,this.clear()}async#g(t){if(this.#s.has(t)||this.#r.has(t)||this.#l.has(t))return;this.#r.add(t);let e=this.#a;try{let s;for(let i=0;i<3;i++){if(e!==this.#a)return;try{let{rows:o}=await this.#e(t,this.#t);if(e!==this.#a)return;if(!Array.isArray(o))throw new TypeError("fetchData must resolve { rows: [] }");this.#s.set(t,o),this.#m(),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.#a){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.#f()}}#m(){for(;this.#s.size>this.#o;){let t=this.#s.keys().next().value;this.#s.delete(t),t===this.#i&&(this.#i=-1,this.#n=null)}}forEachLoaded(t){for(let[e,s]of[...this.#s]){let i=e*this.#t;for(let o=0;o<s.length;o++)if(t(s[o],i+o)===!1)return}}clear(){this.#s.clear(),this.#r.clear(),this.#c.clear(),this.#l.clear(),this.#h.forEach(clearTimeout),this.#h.clear(),this.#i=-1,this.#n=null}};function fe(l){return l==null?[]:Array.isArray(l)?l:[l]}function De(l,t,e,s){if(t===e)return;let i=0;for(;i<l.length;){let o=l[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 r=i+1;for(;r<l.length&&l[r]._path[t]===n;)r++;let a=l.slice(i,r);s[t].push({label:n,fields:a.map(c=>c.field)}),De(a,t+1,e,s),i=r}}function Le(l){let t=(l??[]).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 De(t,0,e,s),s}function ps(l){let t="";for(let e=l+1;e>0;){let s=(e-1)%26;t=String.fromCharCode(65+s)+t,e=Math.floor((e-1)/26)}return t}var te=[],ke=4;function Bt(l,t,e=!1){for(let u of te)if(u.headerRows===l&&u.columns===t&&u.columnLetterHeader===e)return u.cells;let s=t.length,i=l?.length??0,o=e?1:0,n=i+1+o,r=Array.from({length:n},()=>new Array(s).fill(!1)),a=[];if(e)for(let u=0;u<s;u++)a.push({row:0,col:u,colspan:1,rowspan:1,label:ps(u),align:"center",isLeaf:!1,isColLetter:!0});for(let u=0;u<i;u++){let _=u+o,h=0;for(let d of l[u]??[]){let{label:m="",fields:f,colspan:g,rowspan:p=1,align:b="center"}=d,v=Math.min(p,n-_),x;if(f){let S=f.map(C=>t.indexOf(C)).filter(C=>C>=0).sort((C,E)=>C-E);x=[];for(let C of S){let E=x[x.length-1];E&&E.start+E.length===C?E.length++:x.push({start:C,length:1})}}else{for(;h<s&&r[_][h];)h++;if(h>=s)continue;x=[{start:h,length:Math.min(g??1,s-h)}],h+=x[0].length}for(let{start:S,length:C}of x){let E=C;for(let U=0;U<v;U++)for(let ot=0;ot<E;ot++)_+U<n&&(r[_+U][S+ot]=!0);a.push({row:_,col:S,colspan:E,rowspan:v,label:m,align:b,isLeaf:_+v>=n})}}}let c=i+o;for(let u=0;u<s;u++)r[c][u]||a.push({row:c,col:u,colspan:1,rowspan:1,label:null,align:null,isLeaf:!0});return te.unshift({headerRows:l,columns:t,columnLetterHeader:e,cells:a}),te.length>ke&&(te.length=ke),a}function ee(l,t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o=0,rightX:n,colPositions:r}=t;if(l<s)return r[l];let a=r.length-1;if(o>0&&l>=a-o){let c=a-o;return n+r[l]-r[c]}return i+r[l]-r[s]-e}var Lt=new Map,pe=[],ge=0,me=new Set;function gs(){for(let l of me)try{l()}catch(t){console.error("[JHGrid] image cache load listener error:",t)}}function ms(l){return l.width*l.height*4}function ws(){let l=0;for(let t of Lt.values())l+=t.bytes;if(!(l<=52428800))for(let[t,e]of Lt){if(l<=52428800)break;e.status!=="loading"&&(Lt.delete(t),l-=e.bytes)}}function ys(l){let t=Lt.get(l);return t&&(Lt.delete(l),Lt.set(l,t)),t}function bs(l,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 ${l}`)),o.src=l})}async function vs(l,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 r=await fetch(l);if(!r.ok)throw new Error(`HTTP ${r.status}`);let a=await r.blob();n=await createImageBitmap(a,{resizeWidth:i,resizeHeight:o,resizeQuality:"medium"})}catch{n=await bs(l,i,o)}Lt.set(l,{status:"loaded",bitmap:n,bytes:ms(n)}),ws()}catch(n){console.error("[JHGrid] image cache decode error:",n),Lt.set(l,{status:"error",bitmap:null,bytes:0})}finally{ge--,gs(),$e()}}function $e(){for(;ge<6&&pe.length>0;){let{url:l,w:t,h:e}=pe.shift(),s=Lt.get(l);!s||s.status!=="loading"||(ge++,vs(l,t,e))}}function Fe(l,t,e){if(!l)return null;let s=ys(l);if(s)return s;let i={status:"loading",bitmap:null,bytes:0};return Lt.set(l,i),pe.push({url:l,w:t,h:e}),$e(),i}function Pe(l){me.add(l)}function Be(l){me.delete(l)}var $t=20,Nt=20,Xt={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",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"};function ye(l,t,e,s){if(!t||l.measureText(t).width<=e)return t;let i=s??l.measureText("\u2026").width,o=0,n=t.length;for(;o<n;){let r=o+n+1>>1;l.measureText(t.slice(0,r)).width+i<=e?o=r:n=r-1}return o>0?t.slice(0,o)+"\u2026":"\u2026"}function xs(l,{x:t,y:e,w:s,h:i,theme:o,button:n}){let r=n.width??Nt;n.style!=="plain"&&(l.fillStyle="rgba(0,0,0,0.06)",l.fillRect(t+s-r,e+1,r-1,i-2)),l.fillStyle=n.iconColor??o.headerText??o.cellText,l.font=`${n.iconSize??13}px ${o.fontFamily}`,l.textAlign="center",l.textBaseline="middle",l.fillText(n.icon,t+s-r/2,e+i/2)}var pt={richtext(){return(l,{x:t,y:e,w:s,h:i,value:o,theme:n,padding:r})=>{if(o==null||o==="")return;let a=Ss(String(o));if(!a.length)return;l.textAlign="left",l.textBaseline="middle",l.fillStyle=n.cellText,l.save(),l.beginPath(),l.rect(t,e,s,i),l.clip();let c=t+r,u=e+i/2;for(let _ of a){l.font=`${_.italic?"italic ":""}${_.bold?"bold ":""}${n.fontSize}px ${n.fontFamily}`,l.fillText(_.text,c,u);let h=l.measureText(_.text).width;if(_.underline||_.strike){l.strokeStyle=n.cellText,l.lineWidth=1;let d=_.underline?u+n.fontSize/2-1:u;l.beginPath(),l.moveTo(c,d),l.lineTo(c+h,d),l.stroke()}c+=h}l.restore()}},progressBar({max:l=100,showLabel:t=!0}={}){return(e,{x:s,y:i,w:o,h:n,value:r,theme:a,padding:c})=>{let u=Number(r);if(isNaN(u))return;let _=Math.max(0,Math.min(1,u/l)),h=t?36:0,d=s+c,m=Math.max(0,o-c*2-h),f=6,g=i+(n-f)/2,p=3;if(e.fillStyle="#e2e8f0",e.beginPath(),e.roundRect?e.roundRect(d,g,m,f,p):e.rect(d,g,m,f),e.fill(),_>0){e.fillStyle=_>=.8?"#16a34a":_>=.5?"#f59e0b":"#ef4444",e.beginPath();let b=Math.max(p*2,m*_);e.roundRect?e.roundRect(d,g,b,f,p):e.rect(d,g,b,f),e.fill()}t&&(e.fillStyle=a.cellText,e.font=`${a.fontSize}px ${a.fontFamily}`,e.textAlign="right",e.textBaseline="middle",e.fillText(`${Math.round(_*100)}%`,s+o-c,i+n/2))}},badge({colorMap:l={}}={}){return(t,{x:e,y:s,w:i,h:o,value:n,theme:r})=>{if(n==null||n==="")return;let a=String(n),{bg:c="#f1f5f9",fg:u="#475569"}=l[a]??{},_=8;t.font=`${r.fontSize-1}px ${r.fontFamily}`;let h=t.measureText(a).width,d=Math.min(h+_*2,i-8),m=o-10,f=e+(i-d)/2,g=s+5,p=m/2;t.fillStyle=c,t.beginPath(),t.roundRect?t.roundRect(f,g,d,m,p):t.rect(f,g,d,m),t.fill(),t.fillStyle=u,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,s+o/2)}},checkmark({trueColor:l="#16a34a",falseColor:t="#94a3b8",showFalse:e=!0}={}){return(s,{x:i,y:o,w:n,h:r,value:a,theme:c})=>{let u=a===!0||a===1||a==="Y"||a==="\uC608"||a==="true";!u&&!e||(s.fillStyle=u?l:t,s.font=`bold ${c.fontSize+1}px ${c.fontFamily}`,s.textAlign="center",s.textBaseline="middle",s.fillText(u?"\u2713":"\u2717",i+n/2,o+r/2))}},image({fit:l="cover",radius:t=0}={}){return(e,{x:s,y:i,w:o,h:n,value:r,theme:a,padding:c})=>{if(!r)return;let u=s+c,_=i+c,h=o-c*2,d=n-c*2;if(h<=0||d<=0)return;let m=Fe(String(r),h,d);if(e.save(),e.beginPath(),t>0&&e.roundRect?e.roundRect(u,_,h,d,t):e.rect(u,_,h,d),e.clip(),m?.status==="loaded"&&m.bitmap){let f=m.bitmap,g=l==="contain"?Math.min(h/f.width,d/f.height):Math.max(h/f.width,d/f.height),p=f.width*g,b=f.height*g;e.drawImage(f,u+(h-p)/2,_+(d-b)/2,p,b)}else m?.status==="error"?(e.fillStyle=a.imageErrorBg,e.fillRect(u,_,h,d),e.strokeStyle=a.imageErrorIcon,e.lineWidth=1.5,e.beginPath(),e.moveTo(u+h*.3,_+d*.3),e.lineTo(u+h*.7,_+d*.7),e.moveTo(u+h*.7,_+d*.3),e.lineTo(u+h*.3,_+d*.7),e.stroke()):(e.fillStyle=a.imagePlaceholderBg,e.fillRect(u,_,h,d));e.restore()}},number({locale:l,decimals:t=0}={}){let e,s;return(i,{x:o,y:n,w:r,h:a,value:c,theme:u,padding:_})=>{let h=l??u.locale;(e===void 0||s!==h)&&(e=new Intl.NumberFormat(h,{minimumFractionDigits:t,maximumFractionDigits:t}),s=h);let d=Number(c);if(c==null||c===""||isNaN(d))return;let m=e.format(d);i.fillStyle=u.cellText,i.font=`${u.fontSize}px ${u.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,r,a),i.clip(),i.fillText(m,o+r-_,n+a/2),i.restore()}},date({format:l="YYYY-MM-DD",locale:t,dateStyle:e,align:s="left"}={}){let i,o;return(n,{x:r,y:a,w:c,h:u,value:_,theme:h,padding:d})=>{if(_==null||_==="")return;let m=_ instanceof Date?_:typeof _=="number"?new Date(_):new Date(String(_)),f=String(_);if(!isNaN(m.getTime()))if(l==="locale"){let p=t??h.locale;(i===void 0||o!==p)&&(i=new Intl.DateTimeFormat(p,e?{dateStyle:e}:void 0),o=p),f=i.format(m)}else{let p=String(m.getFullYear()).padStart(4,"0"),b=String(m.getMonth()+1).padStart(2,"0"),v=String(m.getDate()).padStart(2,"0"),x=String(m.getHours()).padStart(2,"0"),S=String(m.getMinutes()).padStart(2,"0"),C=String(m.getSeconds()).padStart(2,"0"),E=p.slice(-2);f=l.replace("YYYY",p).replace("YY",E).replace("MM",b).replace("DD",v).replace("HH",x).replace("mm",S).replace("ss",C)}let g=s==="right"?r+c-d:s==="center"?r+c/2:r+d;n.fillStyle=h.cellText,n.font=`${h.fontSize}px ${h.fontFamily}`,n.textAlign=s,n.textBaseline="middle",n.save(),n.beginPath(),n.rect(r,a,c,u),n.clip(),n.fillText(f,g,a+u/2),n.restore()}},currency({locale:l,currency:t="KRW"}={}){let e,s;return(i,{x:o,y:n,w:r,h:a,value:c,theme:u,padding:_})=>{let h=l??u.locale;(e===void 0||s!==h)&&(e=new Intl.NumberFormat(h,{style:"currency",currency:t}),s=h);let d=Number(c);if(c==null||c===""||isNaN(d))return;let m=e.format(d);i.fillStyle=u.cellText,i.font=`${u.fontSize}px ${u.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,r,a),i.clip(),i.fillText(m,o+r-_,n+a/2),i.restore()}},link({color:l="#2563eb",mutedColor:t,underline:e=!0,align:s="left",linked:i=!0}={}){return(o,{x:n,y:r,w:a,h:c,value:u,rowData:_,theme:h,padding:d})=>{if(u==null||u==="")return;let m=typeof i=="function"?!!i(_):!!i;o.save(),o.beginPath(),o.rect(n,r,a,c),o.clip(),o.font=`${h.fontSize}px ${h.fontFamily}`,o.textAlign=s,o.textBaseline="middle";let f=ye(o,String(u),a-d*2),g=s==="center"?n+a/2:s==="right"?n+a-d:n+d,p=r+c/2;if(o.fillStyle=m?l:t??h.cellText,o.fillText(f,g,p),m&&e){let b=o.measureText(f).width,v=s==="center"?g-b/2:s==="right"?g-b:g,x=Math.round(p+h.fontSize/2+1)+.5;o.strokeStyle=l,o.lineWidth=1,o.beginPath(),o.moveTo(v,x),o.lineTo(v+b,x),o.stroke()}o.restore()}},dropdown({placeholder:l=""}={}){let t=Nt;return(e,{x:s,y:i,w:o,h:n,value:r,theme:a,padding:c})=>{let u=r!=null&&r!==""?String(r):l;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=r!=null&&r!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(u,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:l=""}={}){let t=Nt;return(e,{x:s,y:i,w:o,h:n,value:r,theme:a,padding:c})=>{let u=r!=null&&r!==""?String(r):l;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=r!=null&&r!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(u,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:l="#2563eb",size:t=14}={}){return(e,{x:s,y:i,w:o,h:n,value:r})=>{let a=r===!0||r===1||r==="true"||r==="1"||r==="Y"||r==="yes",c=s+(o-t)/2,u=i+(n-t)/2,_=3;e.beginPath(),e.roundRect?e.roundRect(c,u,t,t,_):e.rect(c,u,t,t),a?(e.fillStyle=l,e.fill(),e.strokeStyle="#fff",e.lineWidth=1.8,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(c+3,u+t/2),e.lineTo(c+t/2-1,u+t-4),e.lineTo(c+t-3,u+3.5),e.stroke()):(e.fillStyle="#fff",e.fill(),e.strokeStyle="#C0C0C0",e.lineWidth=1.5,e.stroke())}},button({label:l="Button",disabled:t=!1,variant:e="primary"}={}){let s={primary:"#2563eb",success:"#16a34a",danger:"#dc2626",neutral:"#64748b"};return(i,{x:o,y:n,w:r,h:a,theme:c,rowData:u,rowIndex:_})=>{let h=typeof l=="function"?l(u,_):l;if(h==null||h==="")return;let d=typeof t=="function"?!!t(u,_):!!t,m=typeof e=="function"?e(u,_):e;i.font=`${c.fontSize-1}px ${c.fontFamily}`;let f=i.measureText(h).width,g=Math.min(a-8,24),p=Math.min(r-8,f+24);if(p<=0||g<=0)return;let b=o+(r-p)/2,v=n+(a-g)/2;i.beginPath(),i.roundRect?i.roundRect(b,v,p,g,g/2):i.rect(b,v,p,g),i.fillStyle=d?"#cbd5e1":s[m]??s.primary,i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(h,b+p/2,v+g/2)}}},Cs=new Set(Object.keys(pt));function be(l,t){Cs.has(l)&&console.warn(`[JHGrid] registerCellRenderer: "${l}" is a built-in renderer name and will be overwritten`),pt[l]=t}var we=/<\/?(b|i|u|s)>/g;function Ss(l){let t=[],e={bold:!1,italic:!1,underline:!1,strike:!1},s=r=>r.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),i=r=>{r&&t.push({text:s(r),...e})};we.lastIndex=0;let o=0,n;for(;n=we.exec(l);){i(l.slice(o,n.index)),o=we.lastIndex;let r=n[0][1]==="/",a={b:"bold",i:"italic",u:"underline",s:"strike"}[n[1]];e[a]=!r}return i(l.slice(o)),t}var jt=class l{#e;#t;constructor(t,e){this.#e=t.getContext("2d"),this.#t=e}render({scrollTop:t,scrollLeft:e,totalRows:s,columns:i,columnLabels:o,columnAligns:n,columnHeaderAligns:r,getRow:a,geo:c,rowLayout:u,sel:_,editing:h,headerFocusCol:d,rowFocus:m,colDrag:f,rowDrag:g,sorts:p,filters:b,columnRenderers:v,invalidCells:x,selectedRows:S,fillPreview:C,deletedRows:E,skeletonPhase:U,rowNumberLabel:ot,hiddenNeighbors:M,editableColumns:k,i18n:Y,headerCheckboxCols:et,hoverRow:W=null,selAnim:T=null,colSlide:X=null}){let{headerHeight:I,theme:j}=this.#t,{headerRows:q}=this.#t,{width:V,height:A}=this.#t,w=this.#e,{vpH:N,vpW:R,SB:O,vSB:z=O,hSB:F=O,frozenCount:D=0,frozenWidth:L=0,frozenRightCount:$=0,frozenRightWidth:ct=0,rightX:G=0,colPositions:J,headerH:H,maxRow:gt,rowNumW:kt=0}=c,Et=o??i,dt=i.length,vt=x?.size?new Map(i.map((Z,lt)=>[Z,lt])):null,P=_,nt=T?.prev?{prev:T.prev,t:T.t}:null;w.fillStyle=j.rowEven,w.fillRect(0,0,V,A);let rt=gt??s-1,at=Math.max(0,u.rowAt(t,rt)),St=u.rowAt(t+N,rt),Q=St<0?rt:Math.min(rt,St+1),ut=dt-1-$,mt=J[D],wt=D;for(;wt<ut&&J[wt+1]-mt<=e;)wt++;let At=wt;for(;At<ut&&J[At]-mt<e+R;)At++;if(At=Math.min(ut,At+1),w.save(),w.beginPath(),w.rect(L,H,R,N),w.clip(),this.#n(at,Q,wt,At,t,e,i,n,a,u,H,j,D,L,$,G,J,v,x,S,E,k,W,U,vt),w.restore(),D>0&&(w.save(),w.beginPath(),w.rect(0,H,L,N),w.clip(),this.#n(at,Q,0,D-1,t,e,i,n,a,u,H,j,D,L,$,G,J,v,x,S,E,k,W,U,vt),w.restore()),$>0&&(w.save(),w.beginPath(),w.rect(G,H,ct,N),w.clip(),this.#n(at,Q,dt-$,dt-1,t,e,i,n,a,u,H,j,D,L,$,G,J,v,x,S,E,k,W,U,vt),w.restore()),P){let Z=_t=>_t.type==="single"?_t.col:_t.c1,lt=_t=>_t.type==="single"?_t.col:_t.c2,tt=nt?.prev,K=tt?Math.min(Z(P),Z(tt)):Z(P),st=tt?Math.max(lt(P),lt(tt)):lt(P);D>0&&K<D&&(w.save(),w.beginPath(),w.rect(0,H,L,N),w.clip(),this.#l(P,h,t,e,u,H,j,D,L,$,G,J,nt),w.restore()),st>=D&&K<dt-$&&(w.save(),w.beginPath(),w.rect(L,H,R,N),w.clip(),this.#l(P,h,t,e,u,H,j,D,L,$,G,J,nt),w.restore()),$>0&&st>=dt-$&&(w.save(),w.beginPath(),w.rect(G,H,ct,N),w.clip(),this.#l(P,h,t,e,u,H,j,D,L,$,G,J,nt),w.restore())}if(S&&S.size>0){let Z=V-z,lt=Math.max(0,J[dt-$]-L-e),tt=Math.min(Z,L+Math.min(R,lt)+ct);w.save(),w.beginPath(),w.rect(0,H,tt,N),w.clip(),w.strokeStyle=j.selectionColor,w.lineWidth=2;for(let K=at;K<=Q;K++){if(!S.has(K)||K>at&&S.has(K-1))continue;let st=K;for(;st<Q&&S.has(st+1);)st++;let _t=S.has(K-1)?H-4:u.yOf(K)-t+H,Rt=S.has(st+1)?H+N+4:u.yOf(st)-t+H+u.heightOf(st);w.strokeRect(1,_t+1,tt-2,Rt-_t-2),K=st}w.restore()}if(w.save(),w.beginPath(),w.rect(L,0,R,H),w.clip(),this.#i(Et,r??n,i,p,b,wt,At,e,H,I,q,j,D,L,$,G,J,M,et,_,L,R),w.restore(),D>0&&(w.save(),w.beginPath(),w.rect(0,0,L,H),w.clip(),this.#i(Et,r??n,i,p,b,0,D-1,e,H,I,q,j,D,L,$,G,J,M,et,_,0,L),w.restore()),$>0&&(w.save(),w.beginPath(),w.rect(G,0,ct,H),w.clip(),this.#i(Et,r??n,i,p,b,dt-$,dt-1,e,H,I,q,j,D,L,$,G,J,M,et,_,G,ct),w.restore()),D>0){w.strokeStyle=j.frozenBorder,w.lineWidth=2,w.beginPath();let Z=Math.round(L)+.5;w.moveTo(Z,0),w.lineTo(Z,A-F),w.stroke()}if($>0){w.strokeStyle=j.frozenBorder,w.lineWidth=2,w.beginPath();let Z=Math.round(G)+.5;w.moveTo(Z,0),w.lineTo(Z,A-F),w.stroke()}if(d!=null&&d>=0&&d<i.length){let Z=d<D,lt=$>0&&d>=dt-$,tt=this.#s(d,D,L,$,G,e,J),K=J[d+1]-J[d];w.save(),w.beginPath(),Z?w.rect(0,0,L,H):lt?w.rect(G,0,ct,H):w.rect(L,0,R,H),w.clip(),w.strokeStyle=j.selectionColor,w.lineWidth=2,w.strokeRect(tt+1,1,Math.max(0,K-2),Math.max(0,H-2)),w.restore()}if(m!=null&&kt>0){let Z=u.yOf(m)-t+H,lt=u.heightOf(m);Z+lt>H&&Z<A-F&&(w.save(),w.beginPath(),w.rect(0,H,kt,N),w.clip(),w.strokeStyle=j.selectionColor,w.lineWidth=2,w.strokeRect(1,Z+1,Math.max(0,kt-2),Math.max(0,lt-2)),w.restore())}if(_&&!h){let lt=_.type==="single"?_.row:_.r2,tt=_.type==="single"?_.col:_.c2,K=this.#s(tt,D,L,$,G,e,J)+(J[tt+1]-J[tt]),st=u.yOf(lt+1)-t+H;K>=L-7&&K<=V-z+7&&st>=H&&st<=A-F+7&&(w.fillStyle=j.selectionColor,w.fillRect(Math.round(K)-7/2,Math.round(st)-7/2,7,7))}if(C){let{r1:Z,c1:lt,r2:tt,c2:K}=C,st=this.#s(lt,D,L,$,G,e,J),_t=u.yOf(Z)-t+H,Rt=this.#s(K,D,L,$,G,e,J)+(J[K+1]-J[K])-st,Ct=u.yOf(tt+1)-u.yOf(Z);w.fillStyle=j.selectionFill,w.fillRect(st,_t,Rt,Ct),w.setLineDash([4,3]),w.strokeStyle=j.selectionColor,w.lineWidth=2,w.strokeRect(st+1,_t+1,Rt-2,Ct-2),w.setLineDash([])}if(X&&X.c1>=0&&X.c2<dt&&X.dragCol>=0&&X.dragCol<dt&&X.dx!==0){let{c1:Z,c2:lt,dx:tt,dragCol:K}=X,st=Math.min(Z,K),_t=Math.max(lt,K),Rt=Dt=>this.#s(Dt,D,L,$,G,e,J),Ct=Math.max(0,Rt(st)),Mt=Math.min(V-z,Rt(_t)+(J[_t+1]-J[_t])),Gt=(Dt,It,he)=>{w.save(),w.translate(he,0),this.#n(at,Q,Dt,It,t,e,i,n,a,u,H,j,D,L,$,G,J,v,x,S,E,k,W,U,vt),this.#i(Et,r??n,i,p,b,Dt,It,e,H,I,q,j,D,L,$,G,J,M,et,_),w.restore()};Mt>Ct&&(w.save(),w.beginPath(),w.rect(Ct,0,Mt-Ct,A-F),w.clip(),w.fillStyle=j.headerBg,w.fillRect(Ct,0,Mt-Ct,H),w.fillStyle=j.rowEven,w.fillRect(Ct,H,Mt-Ct,A-F-H),Gt(Z,lt,tt),Gt(K,K,0),w.restore())}if(f?.active){let{col:Z,insertBefore:lt}=f,tt=this.#s(Z,D,L,$,G,e,J),K=J[Z+1]-J[Z];w.fillStyle=j.dragIndicatorFill,w.fillRect(tt,0,K,A-F);let st=i.length,_t=lt<st?this.#s(lt,D,L,$,G,e,J):this.#s(st-1,D,L,$,G,e,J)+(J[st]-J[st-1]);if(w.strokeStyle=j.dragIndicatorLine,w.lineWidth=3,w.beginPath(),w.moveTo(_t,0),w.lineTo(_t,A-F),w.stroke(),f.x!==void 0){let Rt=I,Ct=H-I,Mt=Math.max(0,Math.min(V-z-K,f.x-f.grabDX));w.save(),w.globalAlpha=.92,w.shadowColor=j.dragGhostShadow,w.shadowBlur=8,w.shadowOffsetY=2,w.fillStyle=j.headerBg,w.fillRect(Mt,Ct,K,Rt),w.restore(),w.save(),w.beginPath(),w.rect(Mt,Ct,K,Rt),w.clip(),w.globalAlpha=.92,w.strokeStyle=j.dragIndicatorLine,w.lineWidth=1,w.strokeRect(Mt+.5,Ct+.5,K-1,Rt-1),w.font=`bold ${j.headerFontSize??j.fontSize}px ${j.fontFamily}`,w.fillStyle=j.headerText,w.textAlign="left",w.textBaseline="middle",w.fillText(this.#_(String(Et[Z]??i[Z]??""),K-j.cellPadding*2),Mt+j.cellPadding,Ct+Rt/2),w.restore()}}if(g?.active){let{row:Z,insertBefore:lt}=g,tt=u.yOf(Z)-t+H;w.fillStyle=j.dragIndicatorFill,w.fillRect(0,tt,V-z,u.heightOf(Z));let K=u.yOf(lt)-t+H;w.strokeStyle=j.dragIndicatorLine,w.lineWidth=3,w.beginPath(),w.moveTo(0,K),w.lineTo(V-z,K),w.stroke()}let{rowNumW:ht}=c;ht>0&&this.#o(at,Q,t,u,ht,A,H,F,j,ot,S,W),this.#h(c,j,V,A)}#o(t,e,s,i,o,n,r,a,c,u,_,h){let d=this.#e;d.save(),d.beginPath(),d.rect(0,0,o,n-a),d.clip(),d.fillStyle=c.headerBg,d.fillRect(0,0,o,r),d.font=`bold ${c.headerFontSize??c.fontSize}px ${c.fontFamily}`,d.fillStyle=c.headerText,d.textAlign="center",d.textBaseline="middle",d.fillText(u??"No.",o/2,r/2),d.textAlign="center",d.textBaseline="middle",d.save(),d.beginPath(),d.rect(0,r,o,Math.max(0,n-a-r)),d.clip();for(let m=t;m<=e;m++){let f=i.yOf(m)-s+r,g=i.heightOf(m),p=_?.has(m);d.fillStyle=c.headerBg,d.fillRect(0,f,o,g),p&&(d.fillStyle=c.selectionColor,d.globalAlpha=.28,d.fillRect(0,f,o,g),d.globalAlpha=1),h&&h.row===m&&h.alpha>0&&c.hoverRowBg&&(d.globalAlpha=Math.min(1,h.alpha),d.fillStyle=c.hoverRowBg,d.fillRect(0,f,o,g),d.globalAlpha=1),d.font=p?`bold ${c.fontSize-1}px ${c.fontFamily}`:`${c.fontSize-1}px ${c.fontFamily}`,d.fillStyle=p?c.sortIconColor??c.selectionColor:c.headerText,d.fillText(String(m+1),o/2,f+g/2),d.strokeStyle=c.headerBorder,d.lineWidth=1,d.beginPath(),d.moveTo(0,Math.round(f+g)-.5),d.lineTo(o,Math.round(f+g)-.5),d.stroke()}d.restore(),d.strokeStyle=c.headerBorder,d.lineWidth=1,d.beginPath(),d.moveTo(0,r-.5),d.lineTo(o,r-.5),d.stroke(),d.strokeStyle=c.frozenBorder??c.headerBorder,d.lineWidth=1.5,d.beginPath(),d.moveTo(o-.5,0),d.lineTo(o-.5,n-a),d.stroke(),d.restore()}#s(t,e,s,i,o,n,r){return ee(t,{frozenCount:e,frozenWidth:s,frozenRightCount:i,rightX:o,colPositions:r},n)}#i(t,e,s,i,o,n,r,a,c,u,_,h,d,m,f,g,p,b,v,x,S=0,C=1/0){if(n>r)return;let E=this.#e,U=h.cellPadding,ot=x?x.type==="single"?x.col:x.c1:null,M=x?x.type==="single"?x.col:x.c2:null,k=p.length-1,Y=A=>f>0&&A>=k-f,et=n<d?0:Y(n)?g-p[k-f]:m-p[d]-a,W=p[n]+et,T=p[r+1]-p[n];E.fillStyle=h.headerBg,E.fillRect(W,0,T,c);let I=Bt(_,s,this.#t.columnLetterHeader).filter(A=>A.col+A.colspan-1>=n&&A.col<=r);E.strokeStyle=h.headerBorder,E.lineWidth=1,E.beginPath();for(let A of I){let w=p[A.col]+et,N=p[A.col+A.colspan]-p[A.col],R=A.row*u,O=A.rowspan*u,z=Math.round(w+N)+.5,F=R+O+.5;E.moveTo(z,R),E.lineTo(z,R+O),E.moveTo(w,F),E.lineTo(w+N,F)}E.stroke();let j=A=>A<d?0:Y(A)?2:1,q=j(n);E.textBaseline="middle",E.fillStyle=h.headerText;let V="";for(let A of I){let w=p[A.col]+et,N=p[A.col+A.colspan]-p[A.col],R=A.row*u,O=A.rowspan*u,z=R+O/2;A.isLeaf&&ot!==null&&A.col>=ot&&A.col<=M&&(E.fillStyle=h.selectionColor,E.globalAlpha=.28,E.fillRect(w,R,N,O),E.globalAlpha=1,E.fillStyle=h.headerText);let F=A.isLeaf?s[A.col]:null,D=A.isLeaf&&!!o?.[F],L=A.isLeaf&&i?.length?i.findIndex(Q=>Q.field===F):-1,$=L>=0?i[L]:null,ct=i?.length>1,G=w+N-$t;if(A.isLeaf&&D?(E.fillStyle=h.filterIconBg??"rgba(245,158,11,0.18)",E.fillRect(G+1,R+3,$t-2,O-6),E.fillStyle=h.headerText):A.isLeaf&&$&&(E.fillStyle=h.sortIconBg??"rgba(46,117,182,0.12)",E.fillRect(G+1,R+3,$t-2,O-6),E.fillStyle=h.headerText),!(A.isLeaf||j(A.col)===q))continue;let H=w,gt=N;if(!A.isLeaf){let Q=Math.max(A.col,n),ut=Math.min(A.col+A.colspan-1,r);H=p[Q]+et,gt=p[ut+1]-p[Q];let mt=S+C;H<S&&(gt-=S-H,H=S),H+gt>mt&&(gt=mt-H),gt=Math.max(0,gt)}let kt=A.isLeaf?e?.[A.col]??"left":A.align??"center",Et=A.isLeaf?$t+4:0,dt=A.isLeaf&&v?.has(F),vt=dt?20:0,P=gt-U*2-Et-vt,nt=h.headerFontSize??h.fontSize;E.font=`bold ${nt}px ${h.fontFamily}`;let rt=dt?"left":kt;rt!==V&&(E.textAlign=rt,V=rt);let at=kt==="right"?H+gt-U-Et:dt?H+U+vt:kt==="center"?H+gt/2:H+U,St=A.isLeaf?t[A.col]??"":A.label??"";if(this.#t.wrapHeader&&St){let Q=this.#d(St,P),ut=nt*1.4,mt=z-(Q.length-1)*ut/2;for(let wt of Q)E.fillText(wt,at,mt),mt+=ut}else E.fillText(this.#_(St,P),at,z);if(A.isLeaf){E.font=`bold ${nt-1}px ${h.fontFamily}`,E.textAlign="center",V="center",E.fillStyle=D?h.filterIconColor??"#C87B00":$?h.sortIconColor??"#2E75B6":h.headerIconColor??"rgba(0,0,0,0.28)";let Q=$?$.dir==="asc"?"\u2191":"\u2193":"\u25BE",ut=$&&ct?`${L+1}${Q}`:Q;E.fillText(ut,G+$t/2,z),E.fillStyle=h.headerText}}if(b){E.fillStyle=h.hiddenColIndicator??"#94A3B8";for(let A of I){if(!A.isLeaf)continue;let w=b[A.col];if(!w?.left&&!w?.right)continue;let N=p[A.col]+et,R=p[A.col+A.colspan]-p[A.col],O=A.row*u,z=A.rowspan*u;w.right&&E.fillRect(N+R-1,O,1,z),w.left&&E.fillRect(N,O,1,z)}}}#n(t,e,s,i,o,n,r,a,c,u,_,h,d,m,f,g,p,b,v,x,S,C,E,U,ot){if(t>e||s>i)return;let M=this.#e,k=h.cellPadding,Y=p.length-1,et=s<d?0:f>0&&s>=Y-f?g-p[Y-f]:m-p[d]-n,W=p[s]+et,T=p[i+1]-p[s];M.font=`${h.fontSize}px ${h.fontFamily}`,M.textBaseline="middle";let X=M.measureText("\u2026").width;for(let R=t;R<=e;R++)M.fillStyle=R%2===0?h.rowEven:h.rowOdd,M.fillRect(W,u.yOf(R)-o+_,T,u.heightOf(R));if(C){let R=h.editableCellBg,O=h.readonlyCellBg;if(R||O)for(let z=s;z<=i;z++){let F=C[z]?R:O;if(!F)continue;let D=p[z]+et,L=p[z+1]-p[z];M.fillStyle=F;for(let $=t;$<=e;$++)M.fillRect(D,u.yOf($)-o+_,L,u.heightOf($))}}for(let R=t;R<=e;R++){let O=u.yOf(R)-o+_,z=u.heightOf(R);x?.has(R)&&(M.fillStyle=h.selRowBg,M.fillRect(W,O,T,z));let F=this.#t.rowHighlighter?.(c(R),R);F&&(M.fillStyle=F,M.fillRect(W,O,T,z)),S?.has(R)&&(M.fillStyle=h.deletedRowFill,M.fillRect(W,O,T,z))}let I=this.#t.cellBackground;if(I)for(let R=t;R<=e;R++){let O=u.yOf(R)-o+_,z=u.heightOf(R),F=c(R);for(let D=s;D<=i;D++){let L;try{L=I(F,R,r[D],D)}catch(G){console.error("[JHGrid] cellBackground error at row",R,"col",D,":",G);continue}if(!L)continue;let $=p[D]+et,ct=p[D+1]-p[D];M.fillStyle=L,M.fillRect($,O,ct,z)}}if(E&&E.alpha>0&&E.row>=t&&E.row<=e&&h.hoverRowBg){let R=u.yOf(E.row)-o+_;M.globalAlpha=Math.min(1,E.alpha),M.fillStyle=h.hoverRowBg,M.fillRect(W,R,T,u.heightOf(E.row)),M.globalAlpha=1}let j=Math.round(u.yOf(t)-o+_),q=Math.round(u.yOf(e+1)-o+_);M.strokeStyle=h.cellBorder,M.lineWidth=1,M.beginPath();for(let R=s;R<=i+1;R++){let O=Math.round(p[R]+et)+.5;M.moveTo(O,j),M.lineTo(O,q)}for(let R=t;R<=e+1;R++){if(x?.has(R)&&x.has(R-1))continue;let O=Math.round(u.yOf(R)-o+_)+.5;M.moveTo(W,O),M.lineTo(W+T,O)}M.stroke();let V="",A="";for(let R=t;R<=e;R++){let O=c(R),z=u.yOf(R)-o+_;for(let F=s;F<=i;F++){let D=O?O[r[F]]:null,L=p[F]+et,$=p[F+1]-p[F],ct=u.heightOf(R),G=z+ct/2,J=b?.[F];if(J&&O){M.save();try{J(M,{x:L,y:z,w:$,h:ct,value:D,rowData:O,rowIndex:R,colIndex:F,theme:h,padding:k})}catch(P){console.error("[JHGrid] Custom renderer error at row",R,"col",F,":",P)}M.restore();continue}if(O==null){let nt=($-k*2)*this.#c(R,F);if(nt>2){let rt=Math.min(9,ct-12);M.fillStyle=h.skeletonBar,this.#a(L+k,G-rt/2,nt,rt,3),A=null}continue}let H=D!=null?h.cellText:h.loadingText,gt=a?.[F]??"left";H!==A&&(M.fillStyle=H,A=H),gt!==V&&(M.textAlign=gt,V=gt);let kt=gt==="right"?L+$-k:gt==="center"?L+$/2:L+k,Et=$-k*2,dt=D!=null?String(D):"";if(dt.indexOf(`
2
+ `)!==-1){let P=dt.split(`
3
+ `),nt=h.fontSize*1.4,rt=G-(P.length-1)*nt/2;M.save(),M.beginPath(),M.rect(L,z,$,ct),M.clip();for(let at of P)M.fillText(this.#f(at,Et,X),kt,rt),rt+=nt;M.restore();continue}let vt=Math.floor(Et/(h.fontSize*.5));M.fillText(dt.length<=vt&&!l.#u(dt)?dt:this.#f(dt,Et,X),kt,G)}}if(U!=null){let R=T*.28,O=W-R+(T+R*2)*U;for(let z=t;z<=e;z++){if(c(z)!=null)continue;let F=u.yOf(z)-o+_;M.save(),M.beginPath(),M.rect(W,F,T,u.heightOf(z)),M.clip(),M.fillStyle=h.skeletonSheen,M.fillRect(O,F,R,u.heightOf(z)),M.restore()}}if(S){M.strokeStyle=h.deletedRowStrike,M.lineWidth=1;for(let R=t;R<=e;R++){if(!S.has(R))continue;let O=Math.round(u.yOf(R)-o+_+u.heightOf(R)/2)+.5;M.beginPath(),M.moveTo(W,O),M.lineTo(W+T,O),M.stroke()}}if(ot){M.strokeStyle=h.invalidCellBorder,M.lineWidth=1.5;for(let R of v.keys()){let O=R.indexOf("_"),z=Number(R.slice(0,O));if(z<t||z>e)continue;let F=ot.get(R.slice(O+1));if(F===void 0||F<s||F>i)continue;let D=u.yOf(z)-o+_,L=p[F]+et,$=p[F+1]-p[F],ct=u.heightOf(z);M.strokeRect(Math.round(L)+1,Math.round(D)+1,$-2,ct-2)}}let w=this.#t.cellDecorator,N=this.#t.cellButtonFor;if(w||N)for(let R=t;R<=e;R++){let O=c(R);if(O==null)continue;let z=u.yOf(R)-o+_,F=u.heightOf(R);for(let D=s;D<=i;D++){let L=p[D]+et,$=p[D+1]-p[D],ct=r[D],G=N?.(ct);if(G?.icon&&(M.save(),xs(M,{x:L,y:z,w:$,h:F,theme:h,button:G}),M.restore()),!!w){M.save();try{w(M,{x:L,y:z,w:$,h:F,value:O[ct],rowData:O,field:ct,rowIndex:R,colIndex:D,theme:h,padding:k})}catch(J){console.error("[JHGrid] cellDecorator error at row",R,"col",D,":",J)}M.restore()}}}}#r(t,e,s,i,o,n,r,a,c,u){if(!t)return null;let _=b=>this.#s(b,n,r,a,c,s,u),h=b=>i.yOf(b)-e+o;if(t.type==="single")return{x:_(t.col),y:h(t.row),w:u[t.col+1]-u[t.col],h:i.heightOf(t.row)};let{r1:d,c1:m,r2:f,c2:g}=t,p=_(m);return{x:p,y:h(d),w:_(g)+(u[g+1]-u[g])-p,h:i.yOf(f+1)-i.yOf(d)}}#l(t,e,s,i,o,n,r,a,c,u,_,h,d){let m=this.#e;if(t.type==="single"&&e?.row===t.row&&e?.col===t.col)return;let f=[s,i,o,n,a,c,u,_,h],{x:g,y:p,w:b,h:v}=this.#r(t,...f);if(d?.prev&&d.t<1){let x=this.#r(d.prev,...f);if(x){let S=d.t;g=x.x+(g-x.x)*S,p=x.y+(p-x.y)*S,b=x.w+(b-x.w)*S,v=x.h+(v-x.h)*S}}t.type==="range"&&(m.fillStyle=r.selectionFill,m.fillRect(g,p,b,v)),m.strokeStyle=r.selectionColor,m.lineWidth=2,m.strokeRect(g+1,p+1,b-2,v-2)}#h({v:t,h:e,SB:s,vSB:i=s,hSB:o=s,frozenWidth:n=0,frozenRightWidth:r=0,rightX:a=0,headerH:c=0},u,_,h){if(!i&&!o)return;let d=this.#e,m=u.scrollbarRadius;d.fillStyle=u.scrollbarBg,i>0&&o>0&&d.fillRect(_-i,h-o,i,o),o>0&&n>0&&d.fillRect(0,h-o,n,o),o>0&&r>0&&d.fillRect(a,h-o,r,o),i>0&&c>0&&d.fillRect(_-i,0,i,c),d.fillRect(t.x,t.y,t.w,t.h),d.fillStyle=u.scrollbarThumb,this.#a(t.x+2,t.thumbY+2,t.w-4,t.thumbH-4,m),d.fillStyle=u.scrollbarBg,d.fillRect(e.x,e.y,e.w,e.h),d.fillStyle=u.scrollbarThumb,this.#a(e.thumbX+2,e.y+2,e.thumbW-4,e.h-4,m)}#a(t,e,s,i,o){if(s<=0||i<=0)return;let n=this.#e;n.beginPath(),n.roundRect?n.roundRect(t,e,s,i,o):n.rect(t,e,s,i),n.fill()}#c(t,e){return .45+(t*73+e*151)%100/100*.4}#d(t,e){let s=this.#e,i=t.split(" "),o=[],n="";for(let r of i){let a=n?n+" "+r:r;s.measureText(a).width<=e?n=a:(n&&o.push(n),n=s.measureText(r).width>e?this.#_(r,e):r)}return n&&o.push(n),o.length?o:[t]}static#p=/[\u{1100}-\u{FFEF}\u{1F000}-\u{1FFFF}]/u;static#u(t){return l.#p.test(t)}#_(t,e){return ye(this.#e,t,e)}#f(t,e,s){return ye(this.#e,t,e,s)}};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",pager:"jhg-pager",pagerBtn:"jhg-pager-btn",editor:"jhg-editor"},Oe={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(l,t){let e=l?.[t],s=Oe[t];return s?`var(${s}, ${e})`:e}var di=Object.freeze({...Oe}),He="jhgrid-styles",Es=`
4
4
  .${B.root} {
5
5
  --jhg-motion-fast: 140ms;
6
6
  --jhg-motion-slow: 180ms;
@@ -17,9 +17,6 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
17
17
  to { opacity: 1; }
18
18
  }
19
19
 
20
- /* Entrance only. Every close path removes its element synchronously (and callers/tests observe
21
- that immediately), so an exit animation would mean deferring removal \u2014 a behavioral change,
22
- not a cosmetic one. Hover/focus transitions below still animate in both directions. */
23
20
  .${B.overlay} {
24
21
  animation: jhg-overlay-in var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out) both;
25
22
  transform-origin: top center;
@@ -29,8 +26,6 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
29
26
  transition: background-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
30
27
  }
31
28
 
32
- /* The builders assign background/border/color inline; declaring the transition here is what makes
33
- those assignments animate instead of snapping. */
34
29
  .${B.btn}, .${B.pagerBtn} {
35
30
  transition: background-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
36
31
  border-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
@@ -45,14 +40,6 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
45
40
  cursor: default;
46
41
  }
47
42
 
48
- .${B.swatch} {
49
- transition: transform var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
50
- box-shadow var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
51
- }
52
- .${B.swatch}:hover { transform: scale(1.12); }
53
-
54
- /* The chooser sets \`transform\` inline to turn the arrow; this is what makes it turn rather than
55
- flip. Same split as everywhere else here \u2014 the value is the builder's, the timing is ours. */
56
43
  .${B.treeToggle} {
57
44
  transition: transform var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
58
45
  color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
@@ -61,9 +48,6 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
61
48
  transition: background-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
62
49
  }
63
50
 
64
- /* These three are shown and hidden by flipping display, which no transition can observe \u2014 a
65
- transition on opacity here would be dead code, since opacity itself never changes. An animation
66
- works instead: a display:none element runs none, and starting to display it replays it. */
67
51
  .${B.tooltip}, .${B.empty} {
68
52
  animation: jhg-fade-in var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out) both;
69
53
  }
@@ -71,9 +55,6 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
71
55
  animation: jhg-fade-in var(--jhg-motion-slow, 180ms) var(--jhg-ease, ease-out) both;
72
56
  }
73
57
 
74
- /* Editors mount over the cell and take focus immediately, so this stays short enough not to read
75
- as lag while typing. Kept to opacity only \u2014 moving a text caret around would be worse, not
76
- better. */
77
58
  @keyframes jhg-editor-in {
78
59
  from { opacity: 0; }
79
60
  to { opacity: 1; }
@@ -82,24 +63,11 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
82
63
  animation: jhg-editor-in 90ms var(--jhg-ease, ease-out) both;
83
64
  }
84
65
 
85
- /* A visible focus target for keyboard users. :focus-visible keeps it off mouse interactions, and
86
- the grid wrapper is excluded because it is focused programmatically on nearly every
87
- interaction \u2014 a ring there would flash constantly rather than indicate anything.
88
- Menu items are also excluded: a context menu focuses its first item with a plain
89
- \`.focus()\` call as soon as it opens \u2014 including on a mouse right-click, since focus-visible
90
- can't tell that script-driven focus apart from a keyboard interaction \u2014 so this outline would
91
- flash on every open. A full-width single-row item makes the outline's top/bottom edges read as
92
- two stray horizontal lines rather than a ring, which is the actual bug this excludes. Menu
93
- items get their own focus indicator instead (same highlight as mouse hover \u2014 see each menu
94
- builder's \`mkItem\`). */
95
66
  .${B.root} :focus-visible:not([role="menuitem"]),
96
67
  .${B.pager} :focus-visible {
97
68
  outline: 2px solid var(--jhg-focus-ring, #2E75B6);
98
69
  outline-offset: 1px;
99
70
  }
100
- /* ...and the browser's own default focus outline (not our rule above) needs suppressing too,
101
- since excluding [role="menuitem"] from the rule above only stops *our* outline \u2014 without this
102
- it's replaced by the UA's native one instead of by mkItem's background highlight. */
103
71
  .${B.menuItem}:focus {
104
72
  outline: none;
105
73
  }
@@ -110,21 +78,18 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
110
78
  --jhg-motion-slow: 1ms;
111
79
  }
112
80
  .${B.overlay}, .${B.loading}, .${B.tooltip}, .${B.empty}, .${B.editor} { animation: none; }
113
- .${B.swatch}:hover { transform: none; }
114
81
  .${B.btn}:active:not(:disabled), .${B.pagerBtn}:active:not(:disabled) { transform: none; }
115
- /* Stated outright rather than left to the retimed variables: the chooser is a floating surface
116
- and may be mounted outside .${B.root}, where those variables never reach it. */
117
82
  .${B.treeToggle}, .${B.treeGroup} { transition: none; }
118
83
  }
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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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
- `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function Ne(r,t=" "){let e=String(r??"");return e.includes(t)||e.includes('"')||e.includes(`
122
- `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function je(r,t=" "){let e=r.replace(/\r\n/g,`
84
+ `;function ze(l=typeof document<"u"?document:null){if(!(!l?.head||l.getElementById(He)))try{let t=l.createElement("style");t.id=He,t.textContent=Es,l.head.appendChild(t)}catch{}}var se=(l,t,e,s,i)=>({position:"absolute",left:t+"px",top:e+"px",width:s+"px",height:i+"px",border:`2px solid ${y(l,"selectionColor")}`,outline:"none",padding:`0 ${l.cellPadding}px`,fontSize:l.fontSize+"px",fontFamily:y(l,"fontFamily"),background:y(l,"overlayBg"),color:l.cellText,zIndex:"10",boxSizing:"border-box"}),Ft={text(){return l=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,kbProxy:r,i18n:a,columnLabel:c,row:u,initialValue:_,keepInputValue:h}=l,d=r;if(d._jhEditorBlur&&d.removeEventListener("blur",d._jhEditorBlur),d._jhEditorKeydown&&d.removeEventListener("keydown",d._jhEditorKeydown),h||(d.value=_),d.setAttribute("aria-label",a.editAriaLabel(c,u+1)),d.className=B.editor,d.style.cssText="",Object.assign(d.style,se(t,e,s,i,o)),d.parentElement!==n&&n.appendChild(d),!h){d.focus();let g=d.value.length;d.setSelectionRange(g,g)}let m=()=>l.commit(),f=g=>{if(g.key==="Enter"&&g.altKey)g.preventDefault(),g.stopPropagation(),l.insertLineBreak();else if(g.key==="Enter"){if(g.isComposing||g.keyCode===229)return;g.preventDefault(),g.stopPropagation(),l.commit(),l.moveSel(1,0),l.focusWrapper()}else g.key==="Tab"?(g.preventDefault(),g.stopPropagation(),l.commit(),l.moveSel(0,g.shiftKey?-1:1),l.focusWrapper()):g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),l.cancel(),l.focusWrapper())};return d._jhEditorBlur=m,d._jhEditorKeydown=f,d.addEventListener("blur",m),d.addEventListener("keydown",f),d}},textMultiline(){return l=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,i18n:r,columnLabel:a,row:c,initialValue:u}=l,_=document.createElement("textarea");_.value=u??"",_.setAttribute("aria-label",r.editAriaLabel(a,c+1)),_.className=B.editor,Object.assign(_.style,se(t,e,s,i,o),{resize:"none",overflow:"auto",whiteSpace:"pre"}),n.appendChild(_),_.focus(),_.setSelectionRange(_.value.length,_.value.length);let h=()=>l.commit(),d=m=>{if(m.key==="Enter"&&m.altKey){m.preventDefault(),m.stopPropagation();let f=_.selectionStart??_.value.length,g=_.selectionEnd??_.value.length;_.value=_.value.slice(0,f)+`
85
+ `+_.value.slice(g),_.setSelectionRange(f+1,f+1);return}if(m.key==="Enter"){if(m.isComposing||m.keyCode===229)return;m.preventDefault(),m.stopPropagation(),l.commit(),l.moveSel(1,0),l.focusWrapper()}else if(m.key==="Tab")m.preventDefault(),m.stopPropagation(),l.commit(),l.moveSel(0,m.shiftKey?-1:1),l.focusWrapper();else if(m.key==="Escape")m.preventDefault(),m.stopPropagation(),l.cancel(),l.focusWrapper();else{let f=m.key.toLowerCase();(m.ctrlKey||m.metaKey)&&!["c","v","x","a"].includes(f)&&m.stopPropagation()}};return _.addEventListener("blur",h),_.addEventListener("keydown",d),_}},date({mode:l="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(m=>m.length),r=n.reduce((m,f)=>m+f,0),a=s.match(/YYYY|YY|MM|DD|HH|mm|ss/g)??[],c=a.includes("HH")||a.includes("mm")||a.includes("ss"),u=c?"datetime-local":"date",_=m=>{let f="",g=0;for(let p=0;p<n.length;p++){let b=m.slice(g,g+n[p]);if(!b)break;f&&(f+=o),f+=b,g+=n[p]}return f},h=m=>{let f={},g=0;for(let p of a){let b=m.slice(g,g+p.length);if(g+=p.length,b.length<p.length)return null;p==="YYYY"?f.Y=b:p==="YY"?f.Y="20"+b:p==="MM"?f.M=b:p==="DD"?f.D=b:p==="HH"?f.H=b:p==="mm"&&(f.Mi=b)}return!f.Y||!f.M||!f.D?null:c?`${f.Y}-${f.M}-${f.D}T${f.H??"00"}:${f.Mi??"00"}`:`${f.Y}-${f.M}-${f.D}`},d=m=>{let f=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/.exec(m);if(!f)return"";let[,g,p,b,v,x]=f,S="";for(let C of a)C==="YYYY"?S+=g:C==="YY"?S+=g.slice(-2):C==="MM"?S+=p:C==="DD"?S+=b:C==="HH"?S+=v??"00":C==="mm"&&(S+=x??"00");return _(S)};return m=>{let{theme:f,x:g,y:p,colW:b,rowH:v,wrapper:x,i18n:S,columnLabel:C,row:E,initialValue:U}=m,ot=a.length&&b>40?22:0,M=b-ot,k=document.createElement("input");k.type="text",k.value=String(U??""),k.setAttribute("aria-label",S.editAriaLabel(C,E+1)),Object.assign(k.style,se(f,g,p,M,v)),x.appendChild(k);let Y=null,et=null;if(ot>0){Y=document.createElement("input"),Y.type=u,t!=null&&(Y.min=t),e!=null&&(Y.max=e),Y.tabIndex=-1,Y.setAttribute("aria-label",S.editAriaLabel(C,E+1)+" calendar"),Object.assign(Y.style,{position:"absolute",left:g+M+"px",top:p+"px",width:ot+"px",height:v+"px",opacity:"0",border:"none",padding:"0",margin:"0",zIndex:"9"}),x.appendChild(Y),et=document.createElement("div"),et.textContent=String.fromCodePoint(128197),et.setAttribute("aria-hidden","true"),Object.assign(et.style,{position:"absolute",left:g+M+"px",top:p+"px",width:ot+"px",height:v+"px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.min(f.fontSize,14)+"px",pointerEvents:"none",zIndex:"10"}),x.appendChild(et);let W=h(k.value.replace(/\D/g,"").slice(0,r));W!=null&&(Y.value=W),Y.addEventListener("click",()=>{if(typeof Y.showPicker=="function")try{Y.showPicker()}catch{}}),Y.addEventListener("change",()=>{k.value=d(Y.value),m.commit(),m.focusWrapper()}),Y.addEventListener("blur",T=>{T.relatedTarget!==k&&m.commit()})}return k.focus(),k.select(),k.addEventListener("input",()=>{let W=k.selectionStart,T=k.value.slice(0,W).replace(/\D/g,"").length,X=k.value.replace(/\D/g,"").slice(0,r),I=_(X);if(k.value=I,Y){let V=h(X);V!=null&&(Y.value=V)}let j=I.length,q=0;for(let V=0;V<I.length;V++)if(/\d/.test(I[V])&&(q++,q===T)){j=V+1;break}k.setSelectionRange(j,j)}),k.addEventListener("blur",W=>{Y&&W.relatedTarget===Y||m.commit()}),k.addEventListener("keydown",W=>{W.key==="Enter"?(W.preventDefault(),W.stopPropagation(),m.commit(),m.moveSel(1,0),m.focusWrapper()):W.key==="Tab"?(W.preventDefault(),W.stopPropagation(),m.commit(),m.moveSel(0,W.shiftKey?-1:1),m.focusWrapper()):W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),m.cancel(),m.focusWrapper())}),{get value(){return k.value},remove(){k.remove(),Y&&Y.remove(),et&&et.remove()}}}}let i=l==="datetime-local"?16:10;return o=>{let{theme:n,x:r,y:a,colW:c,rowH:u,wrapper:_,i18n:h,columnLabel:d,row:m,initialValue:f}=o,g=document.createElement("input");return g.type=l==="datetime-local"?"datetime-local":"date",t!=null&&(g.min=t),e!=null&&(g.max=e),g.value=String(f??"").slice(0,i),g.setAttribute("aria-label",h.editAriaLabel(d,m+1)),g.className=B.editor,Object.assign(g.style,se(n,r,a,c,u)),_.appendChild(g),g.focus(),g.addEventListener("blur",()=>o.commit()),g.addEventListener("keydown",p=>{p.key==="Enter"?(p.preventDefault(),p.stopPropagation(),o.commit(),o.moveSel(1,0),o.focusWrapper()):p.key==="Tab"?(p.preventDefault(),p.stopPropagation(),o.commit(),o.moveSel(0,p.shiftKey?-1:1),o.focusWrapper()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),o.cancel(),o.focusWrapper())}),g}},dropdown({options:l}={}){return t=>{let{theme:e,i18n:s,columnLabel:i,row:o,rowData:n,initialValue:r}=t,a=typeof l=="function"?l(n??{}):l??[];if(!a.length)return null;let c=r;t.cellBox();let u=t.popup({role:"listbox",ariaLabel:s.editAriaLabel(i,o+1)}),_=-1,h=[],d=f=>{h.forEach((g,p)=>{g.style.background=p===f?e.selectionColor:g.dataset.val===c?e.selectionFill:e.overlayBg,g.style.color=p===f?e.overlayAccentText:e.cellText}),_=f,f>=0&&h[f].scrollIntoView({block:"nearest"})};for(let f=0;f<a.length;f++){let g=a[f],p=typeof g=="string"?g:g.value,b=typeof g=="string"?g:g.label??g.value,v=document.createElement("div");v.setAttribute("role","option"),v.dataset.val=p,v.textContent=b,Object.assign(v.style,{padding:"6px 10px",cursor:"pointer",background:p===c?e.selectionFill:e.overlayBg,whiteSpace:"nowrap"}),v.addEventListener("mouseenter",()=>d(f)),v.addEventListener("mouseleave",()=>d(-1)),v.addEventListener("mousedown",x=>{x.preventDefault(),x.stopPropagation(),c=p,m.commit()}),u.appendChild(v),h.push(v)}let m=t.done({value:()=>c,outside:"cancel",onKey:f=>f.key!=="ArrowDown"&&f.key!=="ArrowUp"?!1:(f.preventDefault(),f.stopPropagation(),d(f.key==="ArrowDown"?Math.min(_+1,h.length-1):Math.max(_-1,0)),!0),onCommit:()=>{_>=0&&(c=h[_].dataset.val)}});return m}},multiselect({options:l=[],delimiter:t=","}={}){return e=>{let{theme:s,i18n:i,columnLabel:o,row:n,rowData:r,initialValue:a}=e,c=typeof l=="function"?l(r??{}):l;if(!c.length)return null;let u=new Set(String(a??"").split(t).map(h=>h.trim()).filter(Boolean));e.cellBox();let _=e.popup({role:"listbox",ariaLabel:i.editAriaLabel(o,n+1)});return _.setAttribute("aria-multiselectable","true"),c.forEach(h=>{let d=typeof h=="string"?h:h.value,m=typeof h=="string"?h:h.label??h.value,f=u.has(d),g=document.createElement("div");g.setAttribute("role","option"),g.setAttribute("aria-selected",String(f)),Object.assign(g.style,{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",cursor:"pointer",background:f?s.selectionFill:s.overlayBg,userSelect:"none",whiteSpace:"nowrap"});let p=document.createElement("input");p.type="checkbox",p.checked=f,p.tabIndex=-1,p.style.pointerEvents="none";let b=document.createElement("span");b.textContent=m,g.appendChild(p),g.appendChild(b),g.addEventListener("mouseenter",()=>{g.style.background=s.selectionColor,g.style.color=s.overlayAccentText}),g.addEventListener("mouseleave",()=>{g.style.background=u.has(d)?s.selectionFill:s.overlayBg,g.style.color=s.cellText}),g.addEventListener("mousedown",v=>{v.preventDefault(),v.stopPropagation(),p.checked=!p.checked,g.setAttribute("aria-selected",String(p.checked)),p.checked?u.add(d):u.delete(d),g.style.background=u.has(d)?s.selectionFill:s.overlayBg,g.style.color=s.cellText}),_.appendChild(g)}),e.done({value:()=>[...u].join(t)})}},richtext({marks:l=["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:r,rowH:a,wrapper:c,i18n:u,columnLabel:_,row:h,initialValue:d}=s,m=s.cellBox(),f=s.popup({placement:"above",minWidth:null,maxHeight:null,flip:!1,role:"toolbar",ariaLabel:u.richtextToolbarLabel??"Formatting"});Object.assign(f.style,{display:"flex",gap:"2px",padding:"2px",overflowY:"visible"});let g={},p=()=>{for(let k of l){let Y=!1;try{Y=document.queryCommandState(t[k])}catch{}g[k].setAttribute("aria-pressed",String(Y)),g[k].style.background=Y?i.selectionFill:i.overlayBg}};for(let k of l){let Y=document.createElement("button");Y.type="button",Y.textContent=e[k]??k[0].toUpperCase(),Y.setAttribute("aria-label",k),Y.setAttribute("aria-pressed","false"),Object.assign(Y.style,{width:"24px",height:"24px",border:"none",background:i.overlayBg,cursor:"pointer",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,fontWeight:k==="bold"?"bold":"normal",fontStyle:k==="italic"?"italic":"normal",textDecoration:k==="underline"?"underline":k==="strike"?"line-through":"none"}),Y.addEventListener("mousedown",et=>{et.preventDefault();try{document.execCommand(t[k],!1,null)}catch{}p(),b.focus()}),f.appendChild(Y),g[k]=Y}let b=document.createElement("div");b.contentEditable="true",b.setAttribute("role","textbox"),b.setAttribute("aria-multiline","false"),b.setAttribute("aria-label",u.editAriaLabel(_,h+1)),b.innerHTML=Ie(String(d??"")),Object.assign(b.style,{position:"absolute",left:o+"px",top:n+"px",width:r+"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(b),b.focus();let v=document.createRange();v.selectNodeContents(b),v.collapse(!1);let x=window.getSelection();x.removeAllRanges(),x.addRange(v);let S=!0,C={get value(){return Ie(b.innerHTML)},remove(){E(),m.remove(),f.remove(),b.remove()}},E=()=>{document.removeEventListener("mousedown",M,!0),document.removeEventListener("selectionchange",p),s._disposeSurfaces?.()},U=()=>{S&&(S=!1,E(),s.commit(),s.focusWrapper())},ot=()=>{S&&(S=!1,E(),s.cancel(),s.focusWrapper())},M=k=>{!b.contains(k.target)&&!f.contains(k.target)&&U()};return b.addEventListener("keydown",k=>{if(k.key==="Enter"){if(k.isComposing||k.keyCode===229)return;k.preventDefault(),k.stopPropagation(),U(),s.moveSel(1,0)}else if(k.key==="Tab")k.preventDefault(),k.stopPropagation(),U(),s.moveSel(0,k.shiftKey?-1:1);else if(k.key==="Escape")k.preventDefault(),k.stopPropagation(),ot();else{let Y=k.key.toLowerCase();(k.ctrlKey||k.metaKey)&&!["c","v","x","a"].includes(Y)&&k.stopPropagation()}}),b.addEventListener("input",p),document.addEventListener("mousedown",M,!0),p(),C}}},Rs=new Set(Object.keys(Ft));function ve(l,t){Rs.has(l)&&console.warn(`[JHGrid] registerCellEditor: "${l}" is a built-in editor name and will be overwritten`),Ft[l]=t}var As=new Set(["B","STRONG","I","EM","U","S","STRIKE","DEL"]),Ms={STRONG:"B",EM:"I",STRIKE:"S",DEL:"S"},Ts=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function ks(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ie(l){let t=document.createElement("template");t.innerHTML=l;let e=t.content,s=[],i=1,o=3,n=r=>{for(let a of Array.from(r.childNodes))if(a.nodeType===o)s.push(ks(a.textContent.replace(/[\r\n]+/g," ")));else if(a.nodeType===i){let c=a.tagName;if(Ts.has(c))continue;if(c==="BR"){s.push(" ");continue}if(c==="DIV"||c==="P"){n(a),s.push(" ");continue}let u=Ms[c]??(As.has(c)?c:null);if(u){let _=u.toLowerCase();s.push(`<${_}>`),n(a),s.push(`</${_}>`)}else n(a)}};return n(e),s.join("").trim()}var oe=new Set,Yt=0,xe=!1;function Ds(){Yt=0;let l=[];for(let t of oe)l.push([t,t.measure()]);for(let[t,e]of l)t.apply(e)}function ie(){Yt||(Yt=requestAnimationFrame(Ds))}function Ls(l){return xe||(window.addEventListener("scroll",ie,!0),window.addEventListener("resize",ie),xe=!0),oe.add(l),l.apply(l.measure()),()=>{oe.delete(l)&&oe.size===0&&(window.removeEventListener("scroll",ie,!0),window.removeEventListener("resize",ie),xe=!1,Yt&&(cancelAnimationFrame(Yt),Yt=0))}}function $s(l){return{position:"fixed",background:y(l,"overlayBg"),border:`1px solid ${y(l,"overlayBorder")}`,borderRadius:"4px",boxShadow:y(l,"overlayMenuShadow"),zIndex:"99999",overflowY:"auto",fontSize:l.fontSize+"px",fontFamily:y(l,"fontFamily"),color:l.cellText}}function We(l){let t=[],e=!1,s=()=>{if(!e){e=!0;for(let o of t)o.unanchor?.(),o.el.remove();t.length=0}},i=o=>{let n=l.wrapper.getBoundingClientRect(),r=n.left+l.x,a=n.top+l.y;return o.clientX>=r&&o.clientX<r+l.colW&&o.clientY>=a&&o.clientY<a+l.rowH};return l.cellBox=({el:o=null,border:n=!0,interactive:r=o!=null}={})=>{let a=o??document.createElement("div");return Object.assign(a.style,{position:"absolute",left:l.x+"px",top:l.y+"px",width:l.colW+"px",height:l.rowH+"px",boxSizing:"border-box",zIndex:"10",pointerEvents:r?"auto":"none",...n?{border:`2px solid ${y(l.theme,"selectionColor")}`}:null}),l.wrapper.appendChild(a),t.push({el:a}),a},l.popup=({placement:o="below",align:n="left",minWidth:r="cell",maxHeight:a=240,flip:c=!0,chrome:u=!0,role:_,ariaLabel:h=!0}={})=>{let d=document.createElement("div");_&&d.setAttribute("role",_),h&&d.setAttribute("aria-label",typeof h=="string"?h:l.i18n.editAriaLabel(l.columnLabel,l.row+1)),Object.assign(d.style,u?$s(l.theme):{position:"fixed",zIndex:"99999"}),a!=null&&(d.style.maxHeight=a+"px"),r==="cell"?d.style.minWidth=l.colW+"px":r!=null&&(d.style.minWidth=r+"px"),n==="stretch"&&(d.style.width=l.colW+"px"),document.body.appendChild(d);let m=()=>{let g=l.wrapper.getBoundingClientRect();return{cellLeft:g.left+l.x,cellTop:g.top+l.y,popW:d.offsetWidth,popH:d.offsetHeight}},f=({cellLeft:g,cellTop:p,popW:b,popH:v})=>{let x=p+l.rowH,S=p-v,C;o==="over"?C=p:o==="above"?C=c&&S<0&&x+v<=window.innerHeight?x:S:C=c&&x+v>window.innerHeight&&S>=0?S:x;let E=n==="right"?g+l.colW-b:g;c&&(E=Math.max(0,Math.min(E,window.innerWidth-b))),d.style.left=E+"px",d.style.top=C+"px"};return t.push({el:d,unanchor:Ls({measure:m,apply:f})}),d},l.done=({value:o,outside:n="commit",keys:r={},onKey:a,onCommit:c,onCancel:u}={})=>{let{enter:_="commit",escape:h="cancel",tab:d="commit-and-move"}=r,m=!0,f=()=>{document.removeEventListener("mousedown",p,!0),document.removeEventListener("keydown",b,!0)},g=v=>{m&&(m=!1,f(),v==="cancel"?(u?.(),l.cancel()):(c?.(),l.commit()),l.focusWrapper())};function p(v){t.some(x=>x.el.contains(v.target))||(i(v)&&l.suppressReopen?.(),n!=="ignore"&&g(n))}function b(v){if(!m||a?.(v))return;let x=v.key==="Escape"?h:v.key==="Enter"?_:v.key==="Tab"?d:null;x&&(v.preventDefault(),v.stopPropagation(),g(x==="commit-and-move"?"commit":x),x==="commit-and-move"&&l.moveSel(0,v.shiftKey?-1:1))}return document.addEventListener("mousedown",p,!0),document.addEventListener("keydown",b,!0),{get value(){let v=typeof o=="function"?o():o;return v==null?"":String(v)},remove(){f(),s()},commit(){g("commit")},cancel(){g("cancel")}}},l._disposeSurfaces=s,l}var ne=class{#e=[];#t=[];#o;constructor(t=100){this.#o=t}push(t){this.#e.push(t),this.#e.length>this.#o&&this.#e.shift(),this.#t.length=0}undo(){let t=this.#e.pop();t&&(t.undo(),this.#t.push(t))}redo(){let t=this.#t.pop();t&&(t.redo(),this.#e.push(t))}canUndo(){return this.#e.length>0}canRedo(){return this.#t.length>0}clear(){this.#e.length=0,this.#t.length=0}};var le=class{#e=new Map;#t;#o;#s;#i;#n;constructor({getColumnDef:t,getColumnLabel:e,getI18n:s,getRowData:i,onError:o}){this.#t=t,this.#o=e,this.#s=s,this.#i=i,this.#n=o}compute(t,e,s){let i=this.#t(e),o=i?.validation,n=this.#s(),r=this.#o(e)??e,a=s??"";if(o?.required&&a.trim()==="")return o.message??n.validationRequired(r);if(a==="")return null;if(!o)return this.#r(i,t,a,r,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(r)}if(o.min!=null||o.max!=null){let c=i?.type==="date",u=c?Date.parse(a):Number(a);if(o.min!=null&&(isNaN(u)||u<(c?Date.parse(o.min):o.min)))return o.message??n.validationMin(r,o.min);if(o.max!=null&&(isNaN(u)||u>(c?Date.parse(o.max):o.max)))return o.message??n.validationMax(r,o.max)}if(o.minLength!=null&&a.length<o.minLength)return o.message??n.validationMinLength(r,o.minLength);if(o.maxLength!=null&&a.length>o.maxLength)return o.message??n.validationMaxLength(r,o.maxLength);if(o.validator){let c;try{c=o.validator(a,this.#i(t)??{})}catch(u){return console.error("[JHGrid] validator error at row",t,"field",e,":",u),null}if(typeof c=="string")return c;if(c===!1)return o.message??n.validationInvalid(r)}return this.#r(i,t,a,r,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 r=t.editorOptions?.delimiter??",";if(s.split(r).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,r;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"&&(r=Number(o[a]))}return!(n!=null&&(n<1||n>12)||r!=null&&(r<1||r>31))}#h(t,e){let s=typeof t.options=="function"?t.options(this.#i(e)??{}):t.options;return Array.isArray(s)?s.map(i=>typeof i=="string"?i:i.value):null}revalidate(t,e,s){let i=this.#t(e);if(!i?.validation&&!this.#a(i?.type))return null;let o=`${t}_${e}`,n=this.compute(t,e,s);return n?this.#e.set(o,n):this.#e.delete(o),this.#n?.(t,e,n??null),n}#a(t){return t==="dropdown"||t==="multiselect"||t==="date"}isValid(){return this.#e.size===0}getInvalidCells(){let t={};return this.#e.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.#e}clear(){this.#e.clear()}};var Fs=/^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function Ne(l,t=","){let e=String(l??"");return/^[=+\-@\t\r]/.test(e)&&!Fs.test(e)&&(e="'"+e),e.includes(t)||e.includes('"')||e.includes(`
86
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function je(l,t=" "){let e=String(l??"");return e.includes(t)||e.includes('"')||e.includes(`
87
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function Ye(l,t=" "){let e=l.replace(/\r\n/g,`
123
88
  `).replace(/\r/g,`
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(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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>
89
+ `),s=[],i=[],o="",n=!1;for(let r=0;r<e.length;r++){let a=e[r];if(n){a==='"'?e[r+1]==='"'?(o+='"',r++):n=!1:o+=a;continue}if(a==='"'&&o===""){n=!0;continue}if(a===t){i.push(o),o="";continue}if(a===`
90
+ `){i.push(o),s.push(i),i=[],o="";continue}o+=a}return i.push(o),s.push(i),s}function Kt(l,t,e){if(l==null||l==="")return l;if(t?.type==="date"){let s=l instanceof Date?l:new Date(String(l));if(isNaN(s.getTime()))return l;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"),r=String(s.getDate()).padStart(2,"0"),a=String(s.getHours()).padStart(2,"0"),c=String(s.getMinutes()).padStart(2,"0"),u=String(s.getSeconds()).padStart(2,"0"),_=o.slice(-2);return i.replace("YYYY",o).replace("YY",_).replace("MM",n).replace("DD",r).replace("HH",a).replace("mm",c).replace("ss",u)}return t?.type==="richtext"&&typeof l=="string"?l.replace(/<\/?(b|i|u|s)>/g,"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"):l}function Ce(l,t,e=1){if(l.length===0)return"";let s=l.map(Number),i=l.every(a=>a.trim()!==""&&!isNaN(Number(a))),o=e<0;if(i){if(l.length===1)return String(s[0]+(o?-t:t));let a=s.slice(1).map((u,_)=>u-s[_]),c=a[0];if(a.every(u=>Math.abs(u-c)<1e-9)){let u=o?s[0]-c*t:s[s.length-1]+c*t;return Number.isInteger(u)?String(u):String(parseFloat(u.toFixed(10)))}}let n=l.length,r=o?(n-t%n)%n:(t-1)%n;return l[r]}var re=class{#e=[];get size(){return this.#e.length}values(){return[...this.#e]}clear(){this.#e.length=0}#t(t){let e=0,s=this.#e.length;for(;e<s;){let i=e+s>>1;this.#e[i]<t?e=i+1:s=i}return e}has(t){let e=this.#t(t);return e<this.#e.length&&this.#e[e]===t}add(t){let e=this.#t(t);return e<this.#e.length&&this.#e[e]===t?!1:(this.#e.splice(e,0,t),!0)}delete(t){let e=this.#t(t);return e>=this.#e.length||this.#e[e]!==t?!1:(this.#e.splice(e,1),!0)}countBefore(t){return this.#t(t)}toServer(t){if(this.#e.length===0)return t;let e=0,s=this.#e.length;for(;e<s;){let i=e+s>>1;this.#e[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.#t(t);e<this.#e.length&&(this.#e.length=e)}shiftFrom(t){let e=this.#t(t);for(let s=e;s<this.#e.length;s++)this.#e[s]++}};var ae=class{removed=new re;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}#e(t){let e=Math.min(t,this.serverTotal);return e-this.removed.countBefore(e)}visualOfLocal(t){return this.#e(this.anchors[t])+t}#t(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.#t(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.#e(t)+this.#o(t)}#o(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.#o(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 Ps=50,Bs=2;function Hs(l,t){let e=[],s=new Map;for(let i of l){let o=t(i)??[],n=e,r="";for(let a of o){r+=" "+a;let c=s.get(r);c||(c={type:"group",label:a,children:[]},s.set(r,c),n.push(c)),n=c.children}n.push({type:"field",field:i})}return e}function Se(l){return l.type==="field"?[l.field]:l.children.flatMap(Se)}function Ke({x:l,y:t,width:e,height:s,fields:i,isHidden:o,labelFor:n,groupPathFor:r=()=>[],i18n:a,theme:c,onApply:u,onCancel:_}){if(i.length===0)return null;let h=Hs(i,r),d=N=>N.reduce((R,O)=>R+1+(O.type==="group"?d(O.children):0),0),m=d(h),f=(...N)=>N.join(";"),g=220,p=document.createElement("div");p.setAttribute("role","dialog"),p.setAttribute("aria-modal","true"),p.setAttribute("aria-label",a.colChooserTitle),p.className=`${B.overlay} ${B.dialog}`,p.style.cssText=f("position:absolute",`left:${Math.max(0,Math.min(l,e-g-4))}px`,`top:${Math.max(0,Math.min(t,s-40-m*32))}px`,`width:${g}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 b=document.createElement("div");b.style.cssText=f("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${y(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(c,"overlayDivider")}`);let v=document.createElement("span");v.textContent=a.colChooserTitle,v.style.fontWeight="600";let x=document.createElement("button");x.type="button",x.textContent="\xD7",x.setAttribute("aria-label",a.colChooserCancel),x.style.cssText=f("background:none","border:none",`color:${y(c,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),x.addEventListener("click",()=>_()),b.append(v,x);let S=document.createElement("div");S.style.cssText="padding:0 0 6px;max-height:280px;overflow-y:auto;";let C=new Map(i.map(N=>[N,!o(N)])),E=document.createElement("label");E.style.cssText=f("display:flex","align-items:center","gap:8px","padding:6px 14px","cursor:pointer",`border-bottom:1px solid ${y(c,"overlayDivider")}`,"margin-bottom:2px"),E.addEventListener("mouseover",()=>{E.style.background=y(c,"overlayHoverBg")}),E.addEventListener("mouseout",()=>{E.style.background=""});let U=document.createElement("input");U.type="checkbox",U.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;";let ot=document.createElement("span");ot.textContent=a.colChooserSelectAll??"\uC804\uCCB4 \uC120\uD0DD",ot.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",E.append(U,ot),S.appendChild(E);let M=[],k=[],Y=()=>{let N=M.filter(R=>R.checked).length;U.checked=N===M.length,U.indeterminate=N>0&&N<M.length},et=new Map,W=()=>{for(let{node:N,cb:R}of k){let O=Se(N),z=O.filter(F=>et.get(F).checked).length;R.checked=z===O.length,R.indeterminate=z>0&&z<O.length}Y()};U.addEventListener("change",()=>{U.indeterminate=!1,M.forEach(N=>{N.checked=U.checked,C.set(N.dataset.field,U.checked)}),W()});let T=18,X=32;function I(N,R,O){let z=n(N),F=document.createElement("label");F.style.cssText=f("display:flex","align-items:center","gap:6px","padding:6px 14px","cursor:pointer","border-radius:3px"),F.addEventListener("mouseover",()=>{F.style.background=y(c,"overlayHoverBg")}),F.addEventListener("mouseout",()=>{F.style.background=""});let D=document.createElement("span");D.style.cssText="width:18px;height:18px;flex-shrink:0;";let L=document.createElement("input");L.type="checkbox",L.checked=C.get(N),L.dataset.field=N,L.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",L.addEventListener("change",()=>{C.set(N,L.checked),W()});let $=document.createElement("span");$.textContent=z,$.style.cssText="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",F.append(D,L,$),O.appendChild(F),M.push(L),et.set(N,L)}function j(N,R,O){let z=Se(N),F=document.createElement("div");F.className=B.treeGroup,F.style.cssText=f("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:${R*X}px`,`z-index:${10-R}`),F.addEventListener("mouseover",()=>{F.style.background=y(c,"overlayHoverBg")}),F.addEventListener("mouseout",()=>{F.style.background=y(c,"overlayHeaderBg")});let D=document.createElement("div");D.style.cssText=f(`margin-left:${T}px`,"padding-left:6px",`border-left:1px solid ${y(c,"overlayDivider")}`);let L=!0,$=document.createElement("button");$.type="button",$.className=B.treeToggle,$.textContent="\u25BE",$.setAttribute("aria-expanded","true"),$.setAttribute("aria-label",N.label),$.style.cssText=f("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")}`),$.addEventListener("click",H=>{H.preventDefault(),H.stopPropagation(),L=!L,$.style.transform=L?"":"rotate(-90deg)",$.setAttribute("aria-expanded",String(L)),D.style.display=L?"":"none"});let ct=document.createElement("label");ct.style.cssText="display:flex;align-items:center;gap:8px;flex:1;cursor:pointer;min-width:0;";let G=document.createElement("input");G.type="checkbox",G.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",G.addEventListener("change",()=>{G.indeterminate=!1,z.forEach(H=>{et.get(H).checked=G.checked,C.set(H,G.checked)}),W()});let J=document.createElement("span");J.textContent=N.label,J.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",ct.append(G,J),F.append($,ct),O.appendChild(F),O.appendChild(D),k.push({node:N,cb:G}),q(N.children,R+1,D)}function q(N,R,O){for(let z of N)z.type==="group"?j(z,R,O):I(z.field,R,O)}q(h,0,S),W();let V=document.createElement("div");V.style.cssText=f("display:flex","gap:6px","padding:10px 12px",`border-top:1px solid ${y(c,"overlayDivider")}`);let A=document.createElement("button");A.type="button",A.textContent=a.colChooserApply,A.style.cssText=f("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"),A.addEventListener("click",()=>u(C));let w=document.createElement("button");return w.type="button",w.textContent=a.colChooserCancel,w.style.cssText=f("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"),w.addEventListener("click",()=>_()),V.append(A,w),p.append(b,S,V),p.addEventListener("mousedown",N=>N.stopPropagation()),p.addEventListener("keydown",N=>{N.key==="Escape"&&_(),N.stopPropagation()}),p}function Ve({colLeft:l,headerH:t,width:e,maxPanelHeight:s,label:i,curVal:o,sortPriority:n,asc:r,desc:a,filterId:c,extraSection:u,multiSortEnabled:_,i18n:h,theme:d,wrapperHeight:m,openUpward:f,distinctValues:g,selectedValues:p,suggest:b,suggestScope:v,tagValues:x,containsValue:S,minQueryChars:C,onClose:E,onSort:U,onApply:ot,onApplyValues:M,onResetCol:k,onResetAll:Y}){let W=Math.max(0,Math.min(l,e-220)),T=(...P)=>P.join(";"),X=(P,nt,rt)=>{let at=document.createElement("button");return at.type="button",at.textContent=P,at.dataset.action=nt,at.className=B.btn,at.style.cssText=rt,at},I=document.createElement("div");I.setAttribute("role","dialog"),I.setAttribute("aria-modal","true"),I.setAttribute("aria-label",h.filterDialog(i)),I.className=`${B.overlay} ${B.panel}`,I.style.cssText=T("position:absolute",`left:${W}px`,f?`bottom:${Math.max(0,m-t)}px`:`top:${t}px`,"width:220px",`background:${y(d,"overlayBg")}`,`border:1px solid ${y(d,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(d,"overlayShadow")}`,`font-family:${y(d,"fontFamily")}`,`font-size:${d.fontSize}px`,`color:${y(d,"overlayText")}`,"z-index:100","overflow:hidden","user-select:none","display:flex","flex-direction:column",...s?[`max-height:${Math.max(120,s)}px`]:[]);let j=document.createElement("div");j.style.cssText=T("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${y(d,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(d,"overlayDivider")}`);let q=document.createElement("span");q.textContent=i,q.style.fontWeight="600";let V=X("\xD7","close",T("background:none","border:none",`color:${y(d,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"));V.setAttribute("aria-label",h.filterClose),j.append(q,V);let A=document.createElement("div");A.style.cssText=T("padding:10px 12px",`border-bottom:1px solid ${y(d,"overlayDivider")}`);let w=document.createElement("div");w.style.cssText=T("display:flex","gap:6px");let N=T("flex:1","padding:6px 0","border-radius:4px","cursor:pointer","font-size:12px"),R=X(h.sortAsc,"asc",T(N,`background:${r?y(d,"selectionColor"):y(d,"overlayHeaderBg")}`,`color:${r?y(d,"overlayAccentText"):y(d,"overlayText")}`,`border:1px solid ${r?y(d,"selectionColor"):y(d,"overlayBorder")}`));R.setAttribute("aria-pressed",String(r));let O=X(h.sortDesc,"desc",T(N,`background:${a?y(d,"selectionColor"):y(d,"overlayHeaderBg")}`,`color:${a?y(d,"overlayAccentText"):y(d,"overlayText")}`,`border:1px solid ${a?y(d,"selectionColor"):y(d,"overlayBorder")}`));if(O.setAttribute("aria-pressed",String(a)),w.append(R,O),n>0){let P=document.createElement("span");P.textContent=`#${n}`,P.title="Sort priority",P.style.cssText=T("align-self:center","font-size:11px","font-weight:700",`color:${y(d,"selectionColor")}`,"min-width:20px","text-align:center"),w.appendChild(P)}if(A.appendChild(w),_){let P=document.createElement("div");P.textContent=h.sortShiftHint??"Shift+click: add to multi-sort",P.style.cssText=T("font-size:10px",`color:${y(d,"overlayHintText")}`,"margin-top:5px"),A.appendChild(P)}let z=document.createElement("div");z.style.cssText=T("padding:10px 12px",`border-bottom:1px solid ${y(d,"overlayDivider")}`);let F=document.createElement("label");F.textContent=h.filterLabel,F.htmlFor=c,F.style.cssText=T("font-size:11px",`color:${y(d,"overlayMutedText")}`,"display:block","margin-bottom:6px");let D=document.createElement("input");D.type="text",D.id=c,D.value=o,D.placeholder=h.filterPlaceholder,D.className=B.editor,D.style.cssText=T("width:100%","padding:6px 8px",`background:${y(d,"overlayBg")}`,`border:1px solid ${y(d,"overlayBorder")}`,"border-radius:4px",`color:${y(d,"overlayText")}`,`font-size:${d.fontSize}px`,"box-sizing:border-box"),z.append(F,D);let L=null,$=null;if(!Array.isArray(g)&&typeof b=="function"){let Gt=function(){if(mt.replaceChildren(),_t){mt.appendChild(Mt(h.filterTagMinChars(Ct),!1)),wt.replaceChildren(lt(h.filterTagContains(tt),h.filterTagContains(tt),()=>Z(tt),!0)),ut.style.display="flex",Q.setAttribute("aria-expanded","true"),st=-1;return}let it=new Set(P.tags),ft=K.filter(bt=>!it.has(bt));if(v==="local"&&ft.length>0){let bt=Mt(h.filterTagLocalScope,!0);bt.style.borderBottom=`1px solid ${y(d,"overlayDivider")}`,mt.appendChild(bt)}let yt=ft.slice(0,Ps);for(let bt of yt){let xt=bt===""?h.emptyCell:bt;mt.appendChild(lt(xt,xt,()=>ht(bt),!1))}if(ft.length>yt.length){let bt=Mt(h.filterTagMore(ft.length-yt.length),!0);bt.style.borderTop=`1px solid ${y(d,"overlayDivider")}`,mt.appendChild(bt)}ft.length===0&&mt.appendChild(Mt(K.length?h.filterTagAllSelected:h.filterTagNoMatch,!1)),wt.replaceChildren(lt(h.filterTagContains(tt),h.filterTagContains(tt),()=>Z(tt),!0)),ut.style.display="flex",Q.setAttribute("aria-expanded","true"),st=-1},P={tags:Array.isArray(x)?[...x]:[],contains:typeof S=="string"&&S?S:null};L=document.createElement("div"),L.style.cssText=T("padding:10px 12px",`border-bottom:1px solid ${y(d,"overlayDivider")}`);let nt=document.createElement("div");nt.textContent=h.filterLabel,nt.style.cssText=T("font-size:11px",`color:${y(d,"overlayMutedText")}`,"margin-bottom:6px");let rt=document.createElement("div");rt.style.cssText=T("display:none","flex-direction:column","flex:0 1 auto","min-height:0","margin-top:8px");let at=document.createElement("div");at.style.cssText=T("font-size:11px",`color:${y(d,"overlayMutedText")}`,"margin-bottom:4px");let St=document.createElement("div");St.style.cssText=T("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(d,"overlayBorder")}`,`background:${y(d,"overlayHeaderBg")}`),rt.append(at,St);let Q=document.createElement("input");Q.type="text",Q.id=c,Q.placeholder=h.filterTagPlaceholder,Q.className=B.editor,Q.setAttribute("role","combobox"),Q.setAttribute("aria-expanded","false"),Q.setAttribute("aria-autocomplete","list"),Q.style.cssText=T("width:100%","padding:6px 8px",`background:${y(d,"overlayBg")}`,`border:1px solid ${y(d,"overlayBorder")}`,"border-radius:4px",`color:${y(d,"overlayText")}`,`font-size:${d.fontSize}px`,"box-sizing:border-box");let ut=document.createElement("div");ut.style.cssText=T("display:none","flex-direction:column","flex:0 0 auto","margin-top:4px",`border:1px solid ${y(d,"overlayBorder")}`,"border-radius:4px","overflow:hidden");let mt=document.createElement("div");mt.setAttribute("role","listbox"),mt.style.cssText=T("flex:0 0 auto","max-height:132px","overflow-y:auto");let wt=document.createElement("div");wt.style.cssText=T("flex:0 0 auto",`border-top:1px solid ${y(d,"overlayDivider")}`,`background:${y(d,"overlayHeaderBg")}`),ut.append(mt,wt);let At=()=>{St.replaceChildren();let it=(yt,bt,xt,Te)=>{let Ut=document.createElement("span");Ut.className=B.chip+(Te?` ${B.chipContains}`:""),Ut.style.cssText=T("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(d,"overlayHeaderBg")};border:1px dashed ${y(d,"overlayBorder")};color:${y(d,"overlayMutedText")}`:`background:${y(d,"sortIconBg")};border:1px solid ${y(d,"overlayBorder")};color:${y(d,"overlayText")}`);let ue=document.createElement("span");ue.textContent=yt,Ut.title=bt,ue.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";let Ot=document.createElement("button");Ot.type="button",Ot.className=B.btn,Ot.textContent="\xD7",Ot.setAttribute("aria-label",h.filterTagRemove(bt)),Ot.style.cssText=T("border:none","background:none","cursor:pointer","padding:0 2px","line-height:1","font-size:13px",`color:${y(d,"overlayMutedText")}`),Ot.addEventListener("click",()=>{xt(),At(),Q.focus()}),Ut.append(ue,Ot),St.appendChild(Ut)};P.contains!==null?it(h.filterTagContains(P.contains),h.filterTagContains(P.contains),()=>{P.contains=null},!0):P.tags.forEach((yt,bt)=>{let xt=yt===""?h.emptyCell:yt;it(xt,xt,()=>{P.tags.splice(bt,1)})});let ft=St.childElementCount;rt.style.display=ft?"flex":"none",at.textContent=h.filterTagSelected(ft)},Pt=()=>{ut.style.display="none",mt.replaceChildren(),wt.replaceChildren(),Q.setAttribute("aria-expanded","false")},ht=it=>{P.contains=null,P.tags.includes(it)||P.tags.push(it),Q.value="",Pt(),At(),Q.focus()},Z=it=>{P.tags=[],P.contains=it,Q.value="",Pt(),At(),Q.focus()},lt=(it,ft,yt,bt)=>{let xt=document.createElement("div");return xt.setAttribute("role","option"),xt.className=B.menuItem,xt.title=ft,xt.textContent=it,xt.style.cssText=T("padding:5px 8px","font-size:12px","cursor:pointer","overflow:hidden","text-overflow:ellipsis","white-space:nowrap",bt?`color:${y(d,"overlayMutedText")}`:`color:${y(d,"overlayText")}`),xt.addEventListener("mouseenter",()=>{xt.style.background=y(d,"overlayItemHoverBg")}),xt.addEventListener("mouseleave",()=>{xt.style.background="none"}),xt.addEventListener("click",yt),xt},tt="",K=[],st=-1,_t=!1,Rt=Math.floor(Number(C)),Ct=Number.isFinite(Rt)&&Rt>0?Rt:Bs,Mt=(it,ft)=>{let yt=document.createElement("div");return yt.textContent=it,yt.style.cssText=T("padding:5px 8px",`font-size:${ft?11:12}px`,ft?"font-style:italic":"",`color:${y(d,"overlayMutedText")}`),yt},Dt=0,It=0,he=async it=>{let ft=++Dt,yt=[];try{yt=await b(it)??[]}catch{yt=[]}ft!==Dt||Q.value.trim()!==it||(tt=it,K=yt,_t=!1,Gt())};Q.addEventListener("input",()=>{clearTimeout(It);let it=Q.value.trim();if(!it){Dt++,Pt();return}if(it.length<Ct){Dt++,tt=it,K=[],_t=!0,Gt();return}It=setTimeout(()=>he(it),180)});let de=()=>[...ut.querySelectorAll('[role="option"]')],Me=it=>{let ft=de();ft.forEach((yt,bt)=>{yt.style.background=bt===it?y(d,"overlayItemHoverBg"):"none"}),st=it,ft[it]?.scrollIntoView({block:"nearest"})};Q.addEventListener("keydown",it=>{let ft=ut.style.display!=="none";it.key==="ArrowDown"&&ft?(it.preventDefault(),Me(Math.min(st+1,de().length-1))):it.key==="ArrowUp"&&ft?(it.preventDefault(),Me(Math.max(st-1,0))):it.key==="Enter"?(it.preventDefault(),ft?de()[st>=0?st:0]?.click():gt.click()):it.key==="Escape"&&(ft?(Pt(),st=-1):E()),it.stopPropagation()}),Q.addEventListener("input",()=>{st=-1}),L.append(nt,Q,ut,rt),At(),I.addEventListener("jhg-dispose",()=>{clearTimeout(It),Dt++}),$=()=>{let it=Q.value.trim();return it&&P.contains===null&&P.tags.length===0&&Z(it),P.contains!==null?{contains:P.contains}:{values:[...P.tags]}}}let ct=null,G=[];if(Array.isArray(g)&&g.length>0){ct=document.createElement("div"),ct.style.cssText=T("padding:10px 12px",`border-bottom:1px solid ${y(d,"overlayDivider")}`);let P=document.createElement("div");P.textContent=h.filterValuesLabel,P.style.cssText=T("font-size:11px",`color:${y(d,"overlayMutedText")}`,"margin-bottom:6px");let nt=Array.isArray(p)?new Set(p):null,rt=(ht,Z,lt)=>{let tt=document.createElement("label");tt.style.cssText=T("display:flex","align-items:center","gap:6px","font-size:12px","cursor:pointer","padding:2px 0");let K=document.createElement("input");K.type="checkbox",K.checked=lt,K.dataset.value=ht;let st=document.createElement("span");return st.textContent=Z,st.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",tt.append(K,st),{row:tt,cb:K}},at=document.createElement("input");at.type="text",at.placeholder=h.filterTagPlaceholder,at.setAttribute("aria-label",h.filterTagPlaceholder),at.className=B.editor,at.style.cssText=T("width:100%","padding:6px 8px",`background:${y(d,"overlayBg")}`,`border:1px solid ${y(d,"overlayBorder")}`,"border-radius:4px",`color:${y(d,"overlayText")}`,`font-size:${d.fontSize}px`,"box-sizing:border-box","margin-bottom:6px");let St=document.createElement("div");St.style.cssText=T("max-height:140px","overflow-y:auto","display:flex","flex-direction:column");let Q=[];g.forEach(ht=>{let Z=nt===null?!0:nt.has(ht),lt=ht===""?h.emptyCell:ht,{row:tt,cb:K}=rt(ht,lt,Z);G.push(K),Q.push({row:tt,cb:K,text:lt}),St.appendChild(tt)});let ut=document.createElement("div");ut.textContent=h.filterTagNoMatch,ut.style.cssText=T("padding:5px 8px","font-size:12px",`color:${y(d,"overlayMutedText")}`,"display:none"),St.appendChild(ut);let{row:mt,cb:wt}=rt("",h.filterSelectAll,G.every(ht=>ht.checked));delete wt.dataset.value,wt.dataset.selectAll="true",mt.style.cssText+=`;font-weight:600;border-bottom:1px solid ${y(d,"overlayDivider")};padding-bottom:6px;margin-bottom:4px;`;let At=()=>Q.filter(ht=>ht.row.style.display!=="none").map(ht=>ht.cb),Pt=()=>{let ht=At();wt.checked=ht.length>0&&ht.every(Z=>Z.checked)};wt.addEventListener("change",()=>{At().forEach(ht=>{ht.checked=wt.checked})}),G.forEach(ht=>ht.addEventListener("change",Pt)),at.addEventListener("input",()=>{let ht=G.every(tt=>tt.checked),Z=at.value.trim().toLowerCase(),lt=!1;for(let tt of Q){let K=!Z||tt.text.toLowerCase().includes(Z);tt.row.style.display=K?"flex":"none",ht&&(tt.cb.checked=K),lt=lt||K}ut.style.display=lt?"none":"block",Pt()}),at.addEventListener("keydown",ht=>{ht.key==="Enter"?(ht.preventDefault(),gt.click()):ht.key==="Escape"&&E(),ht.stopPropagation()}),ct.append(P,at,mt,St)}let J=document.createElement("div");J.style.cssText=T("padding:10px 12px",`border-bottom:1px solid ${y(d,"overlayDivider")}`);let H=document.createElement("div");H.style.cssText=T("display:flex","gap:6px");let gt=X(h.filterApply,"apply",T("flex:1","padding:7px 0",`background:${y(d,"selectionColor")}`,`color:${y(d,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600")),kt=X(h.filterReset,"reset-col",T("flex:1","padding:7px 0",`background:${y(d,"overlayHeaderBg")}`,`color:${y(d,"overlayText")}`,`border:1px solid ${y(d,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"));H.append(gt,kt),J.appendChild(H);let Et=document.createElement("div");Et.style.cssText=T("padding:8px 12px","text-align:center");let dt=X(h.filterResetAll,"reset-all",T("background:none","border:none",`color:${y(d,"overlayMutedText")}`,"cursor:pointer","font-size:12px","text-decoration:underline"));Et.appendChild(dt);let vt=ct??L??z;I.append(j,A,...u?[u]:[],vt,J,Et);for(let P of I.children)P.style.flex="0 0 auto";return vt.style.flex="1 1 auto",vt.style.minHeight="0",vt===L&&(vt.style.display="flex",vt.style.flexDirection="column",vt.style.overflowY="auto"),vt===ct&&(vt.style.overflowY="auto"),I.addEventListener("mousedown",P=>P.stopPropagation()),I.addEventListener("keydown",P=>{if(P.key!=="Tab")return;let nt=[...I.querySelectorAll("button:not([disabled]), input")];if(nt.length===0)return;let rt=nt[0],at=nt[nt.length-1];P.shiftKey?document.activeElement===rt&&(P.preventDefault(),at.focus()):document.activeElement===at&&(P.preventDefault(),rt.focus())},!0),I.addEventListener("click",P=>{let nt=P.target.closest("[data-action]")?.dataset?.action;if(nt)if(nt==="close")E();else if(nt==="asc"||nt==="desc")U(nt,P.shiftKey);else if(nt==="apply")if(ct)M(G.filter(rt=>rt.checked).map(rt=>rt.dataset.value));else if($){let rt=$();rt.contains!==void 0?ot(rt.contains):rt.values.length?M(rt.values):ot("")}else ot(D.value.trim());else nt==="reset-col"?k():nt==="reset-all"&&Y()}),D.addEventListener("keydown",P=>{P.key==="Enter"?(P.preventDefault(),gt.click()):P.key==="Escape"&&E(),P.stopPropagation()}),I.addEventListener("keydown",P=>{P.key==="Escape"&&E()}),I}function Ge({x:l,y:t,width:e,isFrozen:s,isFrozenRight:i,isDeleted:o,i18n:n,theme:r,allowedItems:a={},onFreeze:c,onFreezeRight:u,onVisibility:_,onInsertLeft:h,onInsertRight:d,onDelete:m,onUndelete:f,onEscape:g}){let{freeze:p=!0,freezeRight:b=!0,visibility:v=!0,insertLeft:x=!0,insertRight:S=!0,delete:C=!0}=a;if(!p&&!b&&!v&&!x&&!S&&!C)return null;let E=170,U=(...q)=>q.join(";"),ot=U("padding:8px 14px","cursor:pointer"),M=document.createElement("div");M.setAttribute("role","menu"),M.className=`${B.overlay} ${B.menu}`,M.style.cssText=U("position:absolute",`left:${Math.min(l,e-E-2)}px`,`top:${t}px`,`width:${E}px`,`background:${y(r,"overlayBg")}`,`border:1px solid ${y(r,"overlayBorder")}`,"border-radius:6px",`box-shadow:${y(r,"overlayMenuShadow")}`,`font-family:${y(r,"fontFamily")}`,`font-size:${r.fontSize}px`,`color:${y(r,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0");let k=(q,V)=>{let A=document.createElement("div");return A.setAttribute("role","menuitem"),A.setAttribute("tabindex","0"),A.textContent=q,A.dataset.action=V,A.className=B.menuItem,A.style.cssText=ot,A.addEventListener("mouseover",()=>{A.style.background=y(r,"overlayItemHoverBg")}),A.addEventListener("mouseout",()=>{A.style.background=""}),A.addEventListener("focus",()=>{A.style.background=y(r,"overlayItemHoverBg")}),A.addEventListener("blur",()=>{A.style.background=""}),A},Y=()=>{let q=document.createElement("div");return q.style.cssText=`height:1px;background:${y(r,"overlayDivider")};margin:4px 0;`,q},et=[];p&&et.push(k(s?n.colUnfreeze:n.colFreeze,s?"unfreeze":"freeze")),b&&et.push(k(i?n.colUnfreezeRight:n.colFreezeRight,i?"unfreeze-right":"freeze-right"));let W=v?[k(n.colVisibility,"col-visibility")]:[],T=[];x&&T.push(k(n.colInsertLeft,"col-insert-left")),S&&T.push(k(n.colInsertRight,"col-insert-right"));let X=C?[k(o?n.colUndelete:n.colDelete,o?"col-undelete":"col-delete")]:[],j=[et,W,T,X].filter(q=>q.length>0).flatMap((q,V)=>V===0?q:[Y(),...q]);return M.addEventListener("mousedown",q=>q.stopPropagation()),M.addEventListener("click",q=>{let V=q.target.closest("[data-action]")?.dataset?.action;if(V)if(V==="freeze"||V==="unfreeze")c();else if(V==="freeze-right"||V==="unfreeze-right")u();else if(V==="col-visibility"){_();return}else if(V==="col-insert-left"){h();return}else if(V==="col-insert-right"){d();return}else V==="col-delete"?m():V==="col-undelete"&&f()}),M.addEventListener("keydown",q=>{if(q.key==="Escape")g();else if(q.key==="Enter"||q.key===" ")q.preventDefault(),document.activeElement?.click?.();else if(q.key==="ArrowDown"||q.key==="ArrowUp"){q.preventDefault();let V=[...M.querySelectorAll('[role="menuitem"]')],A=V.indexOf(document.activeElement),w=q.key==="ArrowDown"?(A+1)%V.length:(A-1+V.length)%V.length;V[w]?.focus()}q.stopPropagation()}),M.append(...j),M}function Ee(l,t,e,s){let i=new Map;return l((o,n)=>{let r=e(n);r>=0&&i.set(r,o)}),t.forEach((o,n)=>i.set(s(n),o)),[...i.entries()].sort(([o],[n])=>o-n)}function Ue({cols:l,labels:t,rows:e,title:s,includeHeaders:i,i18n:o,lang:n}){let r=u=>String(u??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),a=i?`<thead><tr>${t.map(u=>`<th>${r(u)}</th>`).join("")}</tr></thead>`:"",c=e.map(u=>`<tr>${l.map(_=>`<td>${r(u[_])}</td>`).join("")}</tr>`).join("");return`<!DOCTYPE html><html lang="${r(n)}"><head>
126
91
  <meta charset="utf-8">
127
- <title>${l(s||"Grid Print")}</title>
92
+ <title>${r(s||"Grid Print")}</title>
128
93
  <style>
129
94
  body{font-family:sans-serif;font-size:11px;margin:12px}
130
95
  h2{font-size:14px;margin:0 0 8px}
@@ -135,15 +100,15 @@ var JHGrid=(()=>{var _e=Object.defineProperty;var as=Object.getOwnPropertyDescri
135
100
  @media print{body{margin:0}button{display:none}}
136
101
  </style>
137
102
  </head><body>
138
- ${s?`<h2>${l(s)}</h2>`:""}
139
- <button onclick="window.print()" style="margin-bottom:8px;padding:4px 12px;cursor:pointer">\u{1F5A8} ${l(o.printButton)}</button>
103
+ ${s?`<h2>${r(s)}</h2>`:""}
104
+ <button onclick="window.print()" style="margin-bottom:8px;padding:4px 12px;cursor:pointer">\u{1F5A8} ${r(o.printButton)}</button>
140
105
  <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}#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
- `)?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",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(`
106
+ </body></html>`}var ce=class{#e;#t=new Map;#o=[];#s=[0];#i=!1;constructor(t){this.#e=t}get defaultHeight(){return this.#e}set defaultHeight(t){t!==this.#e&&(this.#e=t,this.#i=!0)}#n(){this.#o=[...this.#t.keys()].sort((t,e)=>t-e),this.#s=new Array(this.#o.length+1),this.#s[0]=0;for(let t=0;t<this.#o.length;t++){let e=this.#t.get(this.#o[t]);this.#s[t+1]=this.#s[t]+(e-this.#e)}this.#i=!1}#r(){this.#i&&this.#n()}#l(t){let e=0,s=this.#o.length;for(;e<s;){let i=e+s>>1;this.#o[i]<t?e=i+1:s=i}return e}heightOf(t){return this.#t.get(t)??this.#e}hasOverride(t){return this.#t.has(t)}setHeight(t,e){let s=Math.max(1,Math.round(e));if(s===this.#e){this.#t.delete(t)&&(this.#i=!0);return}this.#t.get(t)!==s&&(this.#t.set(t,s),this.#i=!0)}snapshotOverrides(){return new Map(this.#t)}restoreOverrides(t){this.#t=new Map(t),this.#i=!0}clear(){this.#t.size&&(this.#t.clear(),this.#i=!0)}yOf(t){return t<=0?0:(this.#r(),t*this.#e+this.#s[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.#t.size===0)return;let e=new Map;for(let[s,i]of this.#t)e.set(t(s),i);this.#t=e,this.#i=!0}deleteRow(t){if(this.#t.size===0)return;let e=new Map;for(let[s,i]of this.#t)s!==t&&e.set(s>t?s-1:s,i);this.#t=e,this.#i=!0}};var Os=new Intl.Collator(void 0,{numeric:!0});function Xe(l){return l==null||typeof l=="string"&&l.trim()===""?NaN:Number(l)}function zs(l){return(t,e)=>{let s=t[l],i=e[l],o=Xe(s),n=Xe(i);return!Number.isNaN(o)&&!Number.isNaN(n)?o-n:Os.compare(String(s??""),String(i??""))}}function qe(l,t){if(!Array.isArray(l))throw new Error("[JHGrid] opts.data must be an array");let e=t?.length?t.map(i=>i.field):Object.keys(l[0]??{});if(!e.length)throw new Error("[JHGrid] opts.data: could not resolve columns from an empty array - pass opts.columnDefs");function s(i){let{filters:o={},sorts:n=[],quickFilter:r=""}=i??{},a=l;for(let[c,u]of Object.entries(o))if(Array.isArray(u)){if(u.length===0)continue;let _=new Set(u.map(String));a=a.filter(h=>_.has(String(h[c]??"")))}else if(u){let _=String(u).toLowerCase();a=a.filter(h=>String(h[c]??"").toLowerCase().includes(_))}if(r){let c=r.toLowerCase();a=a.filter(u=>Object.values(u).some(_=>String(_??"").toLowerCase().includes(c)))}for(let{field:c,dir:u}of[...n].reverse()){let _=u==="desc"?-1:1,h=zs(c);a=[...a].sort((d,m)=>_*h(d,m))}return a}return{fetchMeta(i){let o=s(i);return Promise.resolve({totalRows:o.length,columns:e})},fetchData(i,o,n){let r=s(n);return Promise.resolve({rows:r.slice(i*o,i*o+o)})}}}var Je=new WeakMap;function Tt(l){let t=Je.get(l);return t||(t={selectedRows:new Set,lastSelRow:null},Je.set(l,t)),t}function Ze(l){return l._opts.rowSelection??"none"}var Qe={resetScope:["rowIndexState","full"],clear(l){this.rowSelection.clear(l)},snapshotStructural(l,t){let e=Tt(l);t.selectedRows=new Set(e.selectedRows),t.lastSelRow=e.lastSelRow},restoreStructural(l,t){let e=Tt(l);e.selectedRows=new Set(t.selectedRows??[]),e.lastSelRow=t.lastSelRow??null},exportState(l,t){t.selectedRows=[...Tt(l).selectedRows]},importState(l,t){if(!Array.isArray(t.selectedRows))return;let e=Tt(l);e.selectedRows=new Set(t.selectedRows),e.lastSelRow=t.selectedRows.at(-1)??null,l._draw()},install(l){Object.assign(l.prototype,{getSelectedRows(){return[...Tt(this).selectedRows]},clearRowSelection(){let t=Tt(this);t.selectedRows.clear(),t.lastSelRow=null,this._draw()}})},rowSelection:{modeFor:Ze,has(l,t){return Tt(l).selectedRows.has(t)},getRenderSet(l){let t=Tt(l);return t.selectedRows.size>0?t.selectedRows:null},getSorted(l){return[...Tt(l).selectedRows].sort((t,e)=>t-e)},clear(l){let t=Tt(l);t.selectedRows.clear(),t.lastSelRow=null},shiftRows(l,t,e=-1){let s=Tt(l);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(l,t,e,s){let i=Ze(l);if(i==="none")return;let o=Tt(l);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),r=Math.max(o.lastSelRow,t);e||o.selectedRows.clear();for(let a=n;a<=r;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);l._opts.onRowSelect?.([...o.selectedRows].sort((n,r)=>n-r)),l._announce(l._i18n.rowsSelectedAnnounce(o.selectedRows.size))},clearOnCellClick(l,t){if(!l._opts.showRowNumbers||t.ctrlKey||t.metaKey||t.shiftKey)return;let e=Tt(l);e.selectedRows.size!==0&&(e.selectedRows.clear(),e.lastSelRow=null,l._opts.onRowSelect?.([]))}}};var ts=typeof requestAnimationFrame=="function",Is=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),Ws=l=>l*(2-l),zt=class{#e;#t;#o;#s=0;#i=0;#n=0;#r;#l;#h;#a;constructor({value:t=0,onFrame:e=null,requestFrame:s,cancelFrame:i,now:o}={}){this.#e=t,this.#t=t,this.#o=t,this.#r=e,this.#a=o??Is,this.#l=s!==void 0?s:ts?n=>requestAnimationFrame(n):null,this.#h=i!==void 0?i:ts?n=>cancelAnimationFrame(n):null}get value(){if(this.#i===0)return this.#o;let t=(this.#a()-this.#s)/this.#i;return t>=1?(this.#i=0,this.#e=this.#o,this.#o):this.#t+(this.#o-this.#t)*Ws(Math.max(0,t))}get animating(){return this.#i!==0&&this.#a()-this.#s<this.#i}set(t){this.#d(),this.#i=0,this.#e=this.#t=this.#o=t}to(t,e){if(t!==this.#o){if(!(e>0)||!this.#l){this.set(t);return}this.#t=this.value,this.#o=t,this.#s=this.#a(),this.#i=e,this.#c()}}stop(){this.#d(),this.#i=0,this.#e=this.#t=this.#o=this.value}#c(){if(this.#n||!this.#l)return;let t=()=>{this.#n=0;let e=this.animating;this.#r?.(),e&&this.#c()};this.#n=this.#l(t)}#d(){this.#n&&this.#h&&this.#h(this.#n),this.#n=0}};function es(l=typeof window<"u"?window:null){try{return!!l?.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches}catch{return!1}}var qt={loading:"Loading\u2026",loadError:"\u26A0 \uB370\uC774\uD130\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",pasteTruncated:l=>`${l}\uAC1C \uAC12\uC774 \uBC94\uC704\uB97C \uBC97\uC5B4\uB098 \uBD99\uC5EC\uB123\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`,copyIncomplete:l=>`${l}\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:l=>`${l} \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:l=>`${l}\uAE00\uC790 \uC774\uC0C1 \uC785\uB825\uD558\uC138\uC694`,filterTagAllSelected:"\uC77C\uCE58\uD558\uB294 \uAC12\uC744 \uBAA8\uB450 \uC120\uD0DD\uD568",filterTagMore:l=>`\uC678 ${l}\uAC1C - \uAC80\uC0C9\uC5B4\uB97C \uC881\uD600\uBCF4\uC138\uC694`,filterTagSelected:l=>`\uC120\uD0DD\uD55C \uAC12 (${l})`,filterTagContains:l=>`"${l}" \uD3EC\uD568`,filterTagRemove:l=>`${l} \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:(l,t)=>`${l} \uD3B8\uC9D1, ${t}\uD589`,announceCell:(l,t,e)=>`${l}\uD589 ${t}: ${e}`,columnHeaderAnnounce:l=>`${l} \uC5F4 \uBA38\uB9AC\uAE00. Enter: \uC815\uB82C/\uD544\uD130 \uBA54\uB274. \uBA54\uB274 \uD0A4: \uC5F4 \uC635\uC158.`,rowHeaderAnnounce:l=>`${l}\uD589. \uBA54\uB274 \uD0A4: \uD589 \uC635\uC158.`,rowReorderAnnounce:(l,t)=>`${l}\uD589\uC744 ${t}\uD589 \uC704\uCE58\uB85C \uC774\uB3D9\uD588\uC2B5\uB2C8\uB2E4.`,sortAppliedAnnounce:(l,t)=>`${l} ${t==="asc"?"\uC624\uB984\uCC28\uC21C":"\uB0B4\uB9BC\uCC28\uC21C"} \uC815\uB82C \uC801\uC6A9\uB428.`,filterAppliedAnnounce:l=>`${l}\uC5D0 \uD544\uD130\uAC00 \uC801\uC6A9\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,filterClearedAnnounce:l=>`${l} \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:l=>l===0?"\uC120\uD0DD\uC774 \uD574\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.":`${l}\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",printButton:"\uC778\uC1C4",validationRequired:l=>`${l}\uC740(\uB294) \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.`,validationPattern:l=>`${l} \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,validationMin:(l,t)=>`${l}\uC740(\uB294) ${t} \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMax:(l,t)=>`${l}\uC740(\uB294) ${t} \uC774\uD558\uC5EC\uC57C \uD569\uB2C8\uB2E4.`,validationMinLength:(l,t)=>`${l}\uC740(\uB294) \uCD5C\uC18C ${t}\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMaxLength:(l,t)=>`${l}\uC740(\uB294) \uCD5C\uB300 ${t}\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`,validationInvalid:l=>`${l} \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:(l,t)=>`${l} / ${t} \uD398\uC774\uC9C0`};var Jt={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:l=>`${l}\u4EF6\u304C\u7BC4\u56F2\u5916\u306E\u305F\u3081\u8CBC\u308A\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,copyIncomplete:l=>`${l}\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:l=>`${l} \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:l=>`${l}\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:l=>`\u4ED6 ${l}\u4EF6 - \u691C\u7D22\u8A9E\u3092\u7D5E\u3063\u3066\u304F\u3060\u3055\u3044`,filterTagSelected:l=>`\u9078\u629E\u3057\u305F\u5024 (${l})`,filterTagContains:l=>`"${l}" \u3092\u542B\u3080`,filterTagRemove:l=>`${l} \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:(l,t)=>`${l} \u3092\u7DE8\u96C6, ${t} \u884C\u76EE`,announceCell:(l,t,e)=>`${l} \u884C\u76EE ${t}: ${e}`,columnHeaderAnnounce:l=>`${l} \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:l=>`${l} \u884C\u76EE\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u884C\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowReorderAnnounce:(l,t)=>`${l} \u884C\u76EE\u3092 ${t} \u884C\u76EE\u306B\u79FB\u52D5\u3057\u307E\u3057\u305F\u3002`,sortAppliedAnnounce:(l,t)=>`${l} \u3092${t==="asc"?"\u6607\u9806":"\u964D\u9806"}\u306B\u4E26\u3079\u66FF\u3048\u307E\u3057\u305F\u3002`,filterAppliedAnnounce:l=>`${l} \u306B\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u9069\u7528\u3055\u308C\u307E\u3057\u305F\u3002`,filterClearedAnnounce:l=>`${l} \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:l=>l===0?"\u9078\u629E\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002":`${l} \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",printButton:"\u5370\u5237",validationRequired:l=>`${l} \u306F\u5FC5\u9808\u9805\u76EE\u3067\u3059\u3002`,validationPattern:l=>`${l} \u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,validationMin:(l,t)=>`${l} \u306F ${t} \u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMax:(l,t)=>`${l} \u306F ${t} \u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMinLength:(l,t)=>`${l} \u306F ${t} \u6587\u5B57\u4EE5\u4E0A\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationMaxLength:(l,t)=>`${l} \u306F ${t} \u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationInvalid:l=>`${l} \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:(l,t)=>`${t} \u30DA\u30FC\u30B8\u4E2D ${l} \u30DA\u30FC\u30B8\u76EE`};var Zt={loading:"\u52A0\u8F7D\u4E2D\u2026",loadError:"\u26A0 \u6570\u636E\u52A0\u8F7D\u5931\u8D25\u3002",pasteTruncated:l=>`${l} \u4E2A\u503C\u8D85\u51FA\u8303\u56F4\uFF0C\u672A\u88AB\u7C98\u8D34`,copyIncomplete:l=>`${l} \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:l=>`${l} \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:l=>`\u8BF7\u8F93\u5165\u81F3\u5C11 ${l} \u4E2A\u5B57\u7B26`,filterTagAllSelected:"\u5339\u914D\u7684\u503C\u5DF2\u5168\u90E8\u9009\u62E9",filterTagMore:l=>`\u53E6\u6709 ${l} \u4E2A - \u8BF7\u7F29\u5C0F\u641C\u7D22\u8303\u56F4`,filterTagSelected:l=>`\u5DF2\u9009\u503C (${l})`,filterTagContains:l=>`\u5305\u542B "${l}"`,filterTagRemove:l=>`\u79FB\u9664 ${l}`,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:(l,t)=>`\u7F16\u8F91 ${l}\uFF0C\u7B2C ${t} \u884C`,announceCell:(l,t,e)=>`\u7B2C ${l} \u884C ${t}\uFF1A${e}`,columnHeaderAnnounce:l=>`${l} \u5217\u6807\u9898\u3002Enter\uFF1A\u6392\u5E8F/\u7B5B\u9009\u83DC\u5355\u3002\u83DC\u5355\u952E\uFF1A\u5217\u9009\u9879\u3002`,rowHeaderAnnounce:l=>`\u7B2C ${l} \u884C\u3002\u83DC\u5355\u952E\uFF1A\u884C\u9009\u9879\u3002`,rowReorderAnnounce:(l,t)=>`\u5DF2\u5C06\u7B2C ${l} \u884C\u79FB\u52A8\u5230\u7B2C ${t} \u884C\u3002`,sortAppliedAnnounce:(l,t)=>`${l} \u5DF2\u6309${t==="asc"?"\u5347\u5E8F":"\u964D\u5E8F"}\u6392\u5E8F\u3002`,filterAppliedAnnounce:l=>`\u5DF2\u5BF9 ${l} \u5E94\u7528\u7B5B\u9009\u3002`,filterClearedAnnounce:l=>`\u5DF2\u6E05\u9664 ${l} \u7684\u7B5B\u9009\u3002`,allFiltersClearedAnnounce:"\u5DF2\u6E05\u9664\u6240\u6709\u7B5B\u9009\u548C\u6392\u5E8F\u3002",rowsSelectedAnnounce:l=>l===0?"\u5DF2\u53D6\u6D88\u9009\u62E9\u3002":`\u5DF2\u9009\u62E9 ${l} \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",printButton:"\u6253\u5370",validationRequired:l=>`${l} \u4E3A\u5FC5\u586B\u9879\u3002`,validationPattern:l=>`${l} \u683C\u5F0F\u4E0D\u6B63\u786E\u3002`,validationMin:(l,t)=>`${l} \u4E0D\u80FD\u5C0F\u4E8E ${t}\u3002`,validationMax:(l,t)=>`${l} \u4E0D\u80FD\u5927\u4E8E ${t}\u3002`,validationMinLength:(l,t)=>`${l} \u81F3\u5C11\u9700\u8981 ${t} \u4E2A\u5B57\u7B26\u3002`,validationMaxLength:(l,t)=>`${l} \u6700\u591A\u5141\u8BB8 ${t} \u4E2A\u5B57\u7B26\u3002`,validationInvalid:l=>`${l} \u7684\u503C\u65E0\u6548\u3002`,pagerFirst:"\u9996\u9875",pagerPrev:"\u4E0A\u4E00\u9875",pagerNext:"\u4E0B\u4E00\u9875",pagerLast:"\u672B\u9875",pagerPageLabel:(l,t)=>`\u7B2C ${l} / ${t} \u9875`};var Re={loading:"Loading\u2026",loadError:"\u26A0 Failed to load data.",pasteTruncated:l=>`${l} value(s) did not fit and were not pasted`,copyIncomplete:l=>`${l} 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:l=>`${l} Filter`,filterValuesLabel:"Filter by value",filterSelectAll:"(Select all)",filterTagPlaceholder:"Search values\u2026",filterTagLocalScope:"From loaded rows only",filterTagNoMatch:"No matching values",filterTagMinChars:l=>`Type at least ${l} characters`,filterTagAllSelected:"All matches already selected",filterTagMore:l=>`+${l} more - narrow the search`,filterTagSelected:l=>`Selected (${l})`,filterTagContains:l=>`Contains "${l}"`,filterTagRemove:l=>`Remove ${l}`,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:(l,t)=>`Edit ${l}, row ${t}`,announceCell:(l,t,e)=>`Row ${l}, ${t}: ${e}`,columnHeaderAnnounce:l=>`${l} column header. Enter: sort/filter menu. Context menu key: column options.`,rowHeaderAnnounce:l=>`Row ${l}. Context menu key: row options.`,rowReorderAnnounce:(l,t)=>`Moved row ${l} to position ${t}.`,sortAppliedAnnounce:(l,t)=>`${l} sorted ${t==="asc"?"ascending":"descending"}.`,filterAppliedAnnounce:l=>`Filter applied to ${l}.`,filterClearedAnnounce:l=>`Filter cleared for ${l}.`,allFiltersClearedAnnounce:"All filters and sorts cleared.",rowsSelectedAnnounce:l=>l===0?"Selection cleared.":l===1?"1 row selected.":`${l} rows selected.`,unsavedEditsWarning:"You have unsaved edits. This change will discard them. Continue?",exportCsvFilename:"export.csv",printButton:"Print",validationRequired:l=>`${l} is required.`,validationPattern:l=>`${l} format is invalid.`,validationMin:(l,t)=>`${l} must be at least ${t}.`,validationMax:(l,t)=>`${l} must be at most ${t}.`,validationMinLength:(l,t)=>`${l} must be at least ${t} characters.`,validationMaxLength:(l,t)=>`${l} must be at most ${t} characters.`,validationInvalid:l=>`${l} is invalid.`,pagerFirst:"First page",pagerPrev:"Previous page",pagerNext:"Next page",pagerLast:"Last page",pagerPageLabel:(l,t)=>`Page ${l} of ${t}`};var Ns={en:Re,ko:qt,ja:Jt,zh:Zt},js=l=>String(l??"").toLowerCase().split("-")[0];function ss(l){return Ns[js(l)]??Re}function is(l){return l||"en-US"}var Ys={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]},Ht=5,Vt=8,os="touch-action:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;",ns=30,ls=16,Ks=500,Vs=40,Gs=120,Us=220,Xs=110,qs=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;",as="position:absolute;opacity:0;pointer-events:none;border:0;margin:0;padding:0;background:transparent;outline:none;",Js={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 Zs(l,t,e){let s=null,i=null;return{fetchMeta:function(o){let n=Promise.resolve(l(0,t,o));return s=n,i=o,n.then(function(r){let a=r.columns??e?.map(function(c){return c.field});if(!a)throw new Error("[JHGrid] opts.fetchPage: resolve { columns } or pass opts.columnDefs");return{totalRows:r.totalRows,columns:a}})},fetchData:function(o,n,r){let c=o===0&&n===t&&s&&i===r?s:Promise.resolve(l(o,n,r));return s=null,i=null,c.then(function(u){return{rows:u.rows}})}}}var Qt=class l{static _plugins=[];static use(t){l._plugins.includes(t)||(l._plugins.push(t),t.install?.(l))}static _plugin(t){return l._plugins.find(e=>e[t])?.[t]??null}_clearPlugins(t){for(let e of l._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;_editsByRow=null;_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;_suppressDefaultFocus=!1;_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={...Js,...t,theme:{...Xt,locale:is(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 - 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=Le(t.columnDefs);s&&(this._opts.headerRows=s)}if(this._i18n={...ss(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=Zs(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=qe(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:r,renderer:a,editor:c,editorOptions:u,editable:_,type:h,format:d,options:m,validation:f,button:g,cellButton:p,group:b,headerCheckbox:v})=>this._colDefMap.set(s,{label:i,align:o,headerAlign:n,width:r,renderer:a,editor:c,editorOptions:u,editable:_,type:h,format:d,options:m,validation:f,button:g,cellButton:p,group:b,headerCheckbox:v})),t.hiddenColumns?.length&&t.hiddenColumns.forEach(s=>this._hiddenColumns.set(s,null)),this._validator=new le({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 Wt({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()},Pe(this._imageLoadListener),this._opts.cellButtonFor=s=>this._colDefMap.get(s)?.cellButton,this._renderer=new jt(this._canvas,this._opts),this._hoverRow=null,this._hoverTarget=0,this._hoverFade=new zt({onFrame:()=>this._schedDraw()});let e=es();this._reducedMotion=e,this._hoverFadeMs=e?0:this._opts.hoverFadeMs??Xs,this._selKey=null,this._selLast=null,this._selPrev=null,this._selMove=new zt({value:1,onFrame:()=>this._schedDraw()}),this._selMoveMs=e?0:this._opts.selectionMoveMs??qs,this._scrollFrom={y:0,x:0},this._scrollAim={y:0,x:0},this._scrollWrote={y:0,x:0},this._scrollEase=new zt({value:1,onFrame:()=>this._onScrollFrame()}),this._scrollEaseMs=e?0:this._opts.scrollEaseMs??Gs,this._colSlide=null,this._colSlideTween=new zt({value:1,onFrame:()=>this._schedDraw()}),this._colSlideMs=e?0:this._opts.columnSlideMs??Us,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,ze(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=l._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=as,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;${os}`,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 r of l._plugins)r.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=(...u)=>u.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=(u,_,h)=>{let d=document.createElement("button");return d.type="button",d.textContent=u,d.setAttribute("aria-label",_),d.className=B.pagerBtn,d.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"),d.addEventListener("click",h),d},o=i("\xAB",this._i18n.pagerFirst,()=>this.goToPage(0)),n=i("\u2039",this._i18n.pagerPrev,()=>this.prevPage()),r=document.createElement("span");r.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,r,a,c),this._container.appendChild(s),this._pagerBar={el:s,firstBtn:o,prevBtn:n,numbers:r,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,r)=>s+r)}_updatePagerBar(){if(!this._pagerBar)return;let{firstBtn:t,prevBtn:e,numbers:s,nextBtn:i,lastBtn:o}=this._pagerBar,n=this._pageCount(),r=this._page,a=this._opts.theme,c=(...u)=>u.join(";");t.disabled=e.disabled=r<=0,o.disabled=i.disabled=r>=n-1,this._pagerBar.el.setAttribute("aria-label",this._i18n.pagerPageLabel(r+1,n)),s.replaceChildren(),this._pagerPageWindow().forEach(u=>{let _=u===r,h=document.createElement("button");h.type="button",h.textContent=String(u+1),h.className=B.pagerBtn,h.style.cssText=c("padding:4px 9px","border-radius:4px","cursor:pointer",`font-size:${a.fontSize}px`,`border:1px solid ${_?y(a,"selectionColor"):y(a,"pagerButtonBorder")}`,`background:${_?y(a,"selectionColor"):y(a,"pagerButtonBg")}`,`color:${_?y(a,"overlayAccentText"):y(a,"pagerText")}`,`font-weight:${_?"600":"400"}`),_&&h.setAttribute("aria-current","page"),h.addEventListener("click",()=>this.goToPage(u)),s.appendChild(h)})}_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:Xt.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;${os}`;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(r=>r.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(!!l._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===" ")&&(l._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)),r=this._columns.length,a=this._opts.showRowNumbers?this._opts.rowNumberWidth??50:0,c=new Array(r+1);c[0]=a;for(let w=0;w<r;w++)c[w+1]=c[w]+(this._columnWidths[w]??t);let u=c[n],_=Math.min(t,s);for(;n>0&&u>s-_;)n--,u=c[n];let h=Math.max(0,Math.min(this._opts.frozenColsRight??0,r-n)),d=c[r]-c[r-h];for(;h>0&&u+d>s-_;)h--,d=c[r]-c[r-h];let m=c[r-h]-u,f=i-o,g=Math.max(0,s-u-d),{start:p,rows:b}=this._pageBounds(),v=this._rowLayout.yOf(p),x=this._rowLayout.yOf(p+b)-v,S=x>f,C=m>g;S&&!C&&(C=m>Math.max(0,g-e)),C&&!S&&(S=x>f-e);let E=S?e:0,U=C?e:0,ot=f-U,M=Math.max(0,g-E),k=s-E-d,Y=v,et=Y+Math.max(0,x-ot),W=Math.max(0,m-M),T=ot,X=x>0?Math.max(24,T*(ot/x)):T,I=et-Y,j=o+(I>0?(this._scrollTop-Y)/I*(T-X):0),q=M,V=m>0?Math.max(24,q*(M/m)):q,A=u+(W>0?this._scrollLeft/W*(q-V):0);return{SB:e,vSB:E,hSB:U,vpH:ot,vpW:M,frozenCount:n,frozenWidth:u,frozenRightCount:h,frozenRightWidth:d,rightX:k,minScrollY:Y,maxScrollY:et,maxScrollX:W,colPositions:c,headerH:o,rowNumW:a,maxRow:p+b-1,v:{x:s-E,y:o,w:S?e:0,h:S?T:0,thumbY:j,thumbH:X},h:{x:u,y:i-U,w:C?q:0,h:C?e:0,thumbX:A,thumbW:V}}}_colAtX(t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o,rightX:n,colPositions:r,rowNumW:a}=e,c=this._columns.length;if(c===0||t<a)return null;if(t<i){for(let h=0;h<s;h++)if(t<r[h+1])return h;return null}if(o>0&&t>=n){let h=c-o,d=t-n+r[h];for(let m=h;m<c;m++)if(d<r[m+1])return m;return null}let u=c-o,_=t-i+this._scrollLeft+r[s];for(let h=s;h<u;h++)if(_<r[h+1])return h;return null}_hitCell(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:r,vSB:a}=s;if(e<n||e>o-r||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 u=this._colAtX(t,s);return u===null?null:{row:c,col:u}}_hitCellClamped(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:r,vSB:a,rowNumW:c}=s;if(this._totalRows===0||this._columns.length===0)return null;let u=Math.max(n,Math.min(o-r-1,e)),_=Math.max(c,Math.min(i-a-1,t)),h=this._rowLayout.rowAt(u-n+this._scrollTop,this._totalRows-1);if(h<0)return null;let d=this._colAtX(_,s);return d===null?null:{row:h,col:d}}_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=Ht){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 r=this._rowLayout.yOf(n+1)-this._scrollTop+e.headerH;if(Math.abs(t-r)<=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=Ht){if(!this._sel)return!1;let{headerH:o,colPositions:n}=s,r=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]),u=this._rowLayout.yOf(r+1)-this._scrollTop+o;return Math.abs(t-c)<=i&&Math.abs(e-u)<=i}_colLeft(t,e){return ee(t,e,this._scrollLeft)}_hitCellButton(t,e,s){let i=this._colDefMap.get(this._columns[t])?.cellButton;if(!i)return null;let o=this._colLeft(t,s)+this._columnWidths[t],n=i.width??Nt;return e>=o-n&&e<=o?i:null}_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 r=this._colDefMap.get(o)?.headerCheckbox?20:0,a=e.measureText(n).width+i*2+$t+4+r,c=this._colDefMap.get(o),u=c?.type,_=u==="dropdown"||u==="multiselect"?Nt:0,h=s.locale;e.font=`${s.fontSize}px ${s.fontFamily}`,this._dm.forEachLoaded(m=>{let f=m?.[o];if(f==null)return;let g=Kt(f,c,h),p=e.measureText(String(g)).width+i*2+_;p>a&&(a=p)}),this._edits.forEach((m,f)=>{let g=f.indexOf("_");if(g===-1||f.slice(g+1)!==o)return;let p=Kt(m,c,h),b=e.measureText(String(p)).width+i*2+_;b>a&&(a=b)});let d=Math.max(ns,Math.ceil(a));this._columnWidths[t]=d,this._columnWidthMap.set(o,d)}_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,r=this._colLeft(n,e),a=i[n+1]-i[n];return t>r+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],r=this._geo().colPositions,a=s[n]-r[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 r=new Map;for(let a=0;a<n;a++)a===t?r.set(a,i):e>t&&a>t&&a<=i?r.set(a,a-1):e<t&&a>=i&&a<t?r.set(a,a+1):r.set(a,a);if(this._sel){let a=c=>r.get(c)??c;if(this._sel.type==="single")this._sel={...this._sel,col:a(this._sel.col)};else{let{r1:c,c1:u,r2:_,c2:h}=this._sel;this._sel={type:"range",...this._normRange(c,a(u),_,a(h))}}}return this._updateA11yHeader(),this._updateA11yCell(),s||this._opts.onColumnReorder?.([...this._columns]),i}_rowReorderReady(){return!!this._opts.rowReorder&&Array.isArray(this._rowOrderData)&&!l._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||l._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),r=this._rowLayout.heightOf(o);return s-n<r/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 r=n.indexOf("_"),a=this._localIndexAt(Number(n.slice(0,r)));a>=0&&i.push([a,n.slice(r+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));t.edits.length>0&&(this._editsByRow=null);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((r,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 l._plugins)n.hideTooltip?.(this);if(this._cellTooltip.style.display="none",this._clearPlugins("rowIndexState"),this._clearPlugins("altView"),this._edits.clear(),this._editedRows.clear(),this._editsByRow=null,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._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)),l._plugins.some(n=>n.bootOverride?.(this,s)))return this._pendingLocalState=null,Promise.resolve();let o=this._isLocalData?(()=>{let n=null;return(r,a)=>(n??=this._opts.fetchData(0,Number.MAX_SAFE_INTEGER,s).then(c=>c.rows),n.then(c=>({rows:c.slice(r*a,r*a+a)})))})():(n,r)=>this._opts.fetchData(n,r,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)}_fullScanConcurrency(){let t=this._opts.fullScanConcurrency;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 l._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.fullScanPageSize||this._opts.chunkSize),o=Math.max(1,Math.ceil(s/i)),n=new Array(o),r=0,a=0,c=async()=>{for(;;){if(this._destroyed)return;let _=r++;if(_>=o)return;let{rows:h}=await this._opts.fetchData(_,i,t);if(this._destroyed)return;n[_]=h??[],a++,this._loadingEl.textContent=`${this._i18n.loading} ${Math.round(a/o*100)}%`}};if(await Promise.all(Array.from({length:Math.min(this._fullScanConcurrency(),o)},c)),this._destroyed)return null;let u=[];for(let _ of n)if(_)for(let h of _)u.push(h);return u}_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))}_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._editsByRow=null,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=r=>{let a=r==null?"":String(r);return a===""||o.has(a)||!a.toLowerCase().includes(i)?!0:(o.add(a),o.size<s)};if(this._dm.forEachLoaded(r=>n(r?.[t])),o.size<s){for(let r of this._localRows)if(n(r?.[t])===!1)break}return[...o].sort((r,a)=>r.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 r=n==null?"":String(n);return!s.has(r)&&(s.add(r),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,r)=>n.localeCompare(r,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:"",r=this._discoverFilterValues(s);r===null?this._searchModeCols.add(s):this._searchModeCols.has(s)&&(r=null);let a=Array.isArray(o)?o:null,c=this._sorts.find(C=>C.field===s),u=c?this._sorts.indexOf(c)+1:0,_=l._plugins.some(C=>C.extraSortSlots),h=()=>{this._closeFilterPanel(),this._suppressDefaultFocus=!0,this._kbProxy.focus(),this._suppressDefaultFocus=!1},d=null;for(let C of l._plugins){let E=C.renderFilterPanelExtra?.(this,s,t,U=>{this._reloadFiltered(),h(),this._announce(U?this._i18n.filterClearedAnnounce(i):this._i18n.filterAppliedAnnounce(i))});if(E){d=E;break}}this._wrapper.style.overflow="visible";let m=this._wrapper.getBoundingClientRect().top,g=(window.innerHeight||document.documentElement.clientHeight)-m-e.headerH-8,p=m-8,v=g<260&&p>g,x=v?p:g,S=Ve({colLeft:this._colLeft(t,e),headerH:e.headerH,wrapperHeight:this._opts.height,openUpward:v,width:this._opts.width,maxPanelHeight:x,label:i,curVal:n,sortPriority:u,asc:c?.dir==="asc",desc:c?.dir==="desc",filterId:`jhgrid-${this._uid}-filter`,multiSortEnabled:_,extraSection:d,distinctValues:r,selectedValues:a,suggest:this._opts.fetchFilterValues?async C=>{let E=await this._opts.fetchFilterValues(s,C);return Array.isArray(E)?E.map(U=>U==null?"":String(U)):[]}:C=>this._suggestFilterValuesLocal(s,C),suggestScope:this._opts.fetchFilterValues?"remote":"local",tagValues:a,containsValue:n,minQueryChars:this._opts.filterValueMinChars,i18n:this._i18n,theme:this._opts.theme,onClose:h,onSort:(C,E)=>{let U=this._sorts.findIndex(ot=>ot.field===s);E&&_?U>=0?this._sorts[U]={field:s,dir:C}:this._sorts.push({field:s,dir:C}):this._sorts=[{field:s,dir:C}],this._reloadFiltered(),h(),this._announce(this._i18n.sortAppliedAnnounce(i,C))},onApply:C=>{this._trivialSetFilters.delete(s),C?this._filters.set(s,C):this._filters.delete(s),this._reloadFiltered(),h(),this._announce(C?this._i18n.filterAppliedAnnounce(i):this._i18n.filterClearedAnnounce(i))},onApplyValues:C=>{this._filters.set(s,C),r&&C.length===r.length?this._trivialSetFilters.add(s):this._trivialSetFilters.delete(s),this._reloadFiltered(),h(),this._announce(this._i18n.filterAppliedAnnounce(i))},onResetCol:()=>{this._filters.delete(s),this._trivialSetFilters.delete(s),l._plugins.find(C=>C.clearFilterField)?.clearFilterField(this,s),this._sorts=this._sorts.filter(C=>C.field!==s),this._reloadFiltered(),h(),this._announce(this._i18n.filterClearedAnnounce(i))},onResetAll:()=>{this._filters.clear(),this._trivialSetFilters.clear(),this._clearPlugins("filterState"),this._sorts=[],this._reloadFiltered(),h(),this._announce(this._i18n.allFiltersClearedAnnounce)}});this._wrapper.appendChild(S),this._filterPanel={col:t,el:S},(S.querySelector('input[type="text"]')??S.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,r=t>=o-i.frozenRightCount,a=this._columns[t],c=this._deletedColumns.has(a),u=Ge({x:e,y:s,width:this._opts.width,isFrozen:n,isFrozenRight:r,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=r?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()}});u&&(this._wrapper.appendChild(u),this._colContextMenu={col:t,el:u},u.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,r=(...C)=>C.join(";"),a=220,c=122,u=Math.max(0,Math.min(e,i-a-4)),_=Math.max(0,Math.min(s,o-c-4)),h=document.createElement("div");h.setAttribute("role","dialog"),h.setAttribute("aria-modal","true"),h.setAttribute("aria-label",this._i18n.colInsertTitle),h.className=`${B.overlay} ${B.dialog}`,h.style.cssText=r("position:absolute",`left:${u}px`,`top:${_}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 d=document.createElement("div");d.style.cssText=r("display:flex","align-items:center","justify-content:space-between","padding:8px 12px",`background:${y(n,"overlayHeaderBg")}`,`border-bottom:1px solid ${y(n,"overlayDivider")}`);let m=document.createElement("span");m.textContent=this._i18n.colInsertTitle,m.style.cssText=`font-weight:600;font-size:12px;color:${y(n,"overlayMutedText")};`;let f=document.createElement("button");f.type="button",f.textContent="\xD7",f.setAttribute("aria-label",this._i18n.colInsertCancel),f.style.cssText=r("background:none","border:none",`color:${y(n,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),f.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),d.append(m,f);let g=document.createElement("div");g.style.cssText="padding:10px 12px 0;";let p=document.createElement("input");p.type="text",p.placeholder=this._i18n.colInsertPlaceholder,p.className=B.editor,p.style.cssText=r("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")}`),g.appendChild(p);let b=document.createElement("div");b.style.cssText="display:flex;gap:6px;padding:10px 12px;";let v=document.createElement("button");v.type="button",v.textContent=this._i18n.colInsertConfirm,v.className=B.btn,v.style.cssText=r("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 x=()=>{let C=p.value.trim();if(!C){p.focus();return}let E=`NEW_COL_${this._newColSeq++}`;this.addColumn(E,{label:C},{index:t}),this._closeNewColumnDialog(),this._kbProxy.focus()};v.addEventListener("click",x);let S=document.createElement("button");S.type="button",S.textContent=this._i18n.colInsertCancel,S.className=B.btn,S.style.cssText=r("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"),S.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),b.append(v,S),h.append(d,g,b),h.addEventListener("mousedown",C=>C.stopPropagation()),p.addEventListener("keydown",C=>{C.key==="Enter"?(C.preventDefault(),x()):C.key==="Escape"&&(this._closeNewColumnDialog(),this._kbProxy.focus()),C.stopPropagation()}),this._wrapper.appendChild(h),this._newColDialog={el:h},p.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,r=170,a=(...x)=>x.join(";"),c=a("padding:8px 14px","cursor:pointer"),u=(x,S)=>{let C=document.createElement("div");return C.setAttribute("role","menuitem"),C.setAttribute("tabindex","0"),C.textContent=x,C.dataset.action=S,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},_=()=>{let x=document.createElement("div");return x.style.cssText=`height:1px;background:${y(n,"overlayDivider")};margin:4px 0;`,x},h=[];this._rowMenuItemAllowed("row-insert-above")&&h.push(u(this._i18n.rowInsertAbove,"row-insert-above")),this._rowMenuItemAllowed("row-insert-below")&&h.push(u(this._i18n.rowInsertBelow,"row-insert-below")),this._rowMenuItemAllowed("row-insert-top")&&h.push(u(this._i18n.rowInsertTop,"row-insert-top")),this._rowMenuItemAllowed("row-insert-bottom")&&h.push(u(this._i18n.rowInsertBottom,"row-insert-bottom"));let d=[];if(this._rowMenuItemAllowed("row-delete")&&(o?d.push(u(this._i18n.rowUndelete,"row-undelete")):i?d.push(u(this._i18n.rowDelete,"row-delete")):(d.push(u(this._i18n.rowDeleteMark,"row-delete-mark")),d.push(u(this._i18n.rowDeletePermanent,"row-delete-permanent")))),h.length===0&&d.length===0)return;let m=h.length>0&&d.length>0?[...h,_(),...d]:[...h,...d],p=(m.length-(h.length>0&&d.length>0?1:0))*36+(h.length>0&&d.length>0?9:0)+8,b=s+p<=this._opts.height?s:Math.max(0,s-p),v=document.createElement("div");v.setAttribute("role","menu"),v.className=`${B.overlay} ${B.menu}`,v.style.cssText=a("position:absolute",`left:${e}px`,`top:${b}px`,`width:${r}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"),v.addEventListener("mousedown",x=>x.stopPropagation()),v.addEventListener("click",x=>{let S=x.target.closest("[data-action]")?.dataset?.action;S&&(this._closeRowContextMenu(),S==="row-insert-above"?this.addRow({},{index:t}):S==="row-insert-below"?this.addRow({},{index:t+1}):S==="row-insert-top"?this.addRow({},{index:0}):S==="row-insert-bottom"?this.addRow({}):S==="row-delete-mark"?this.deleteRow(t,{permanent:!1}):S==="row-delete-permanent"?this.deleteRow(t,{permanent:!0}):S==="row-delete"?this.deleteRow(t):S==="row-undelete"&&this.undeleteRow(t),this._kbProxy.focus())}),v.addEventListener("keydown",x=>{if(x.key==="Escape")this._closeRowContextMenu(),this._kbProxy.focus();else if(x.key==="Enter"||x.key===" ")x.preventDefault(),document.activeElement?.click?.();else if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();let S=[...v.querySelectorAll('[role="menuitem"]')],C=S.indexOf(document.activeElement),E=x.key==="ArrowDown"?(C+1)%S.length:(C-1+S.length)%S.length;S[E]?.focus()}x.stopPropagation()}),v.append(...m),this._wrapper.appendChild(v),this._rowContextMenu={row:t,el:v},m[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,r=170,a=(...T)=>T.join(";"),c=a("padding:8px 14px","cursor:pointer"),u=(T,X)=>{let I=document.createElement("div");return I.setAttribute("role","menuitem"),I.setAttribute("tabindex","0"),I.textContent=T,I.dataset.action=X,I.className=B.menuItem,I.style.cssText=c,I.addEventListener("mouseover",()=>{I.style.background=y(n,"overlayItemHoverBg")}),I.addEventListener("mouseout",()=>{I.style.background=""}),I.addEventListener("focus",()=>{I.style.background=y(n,"overlayItemHoverBg")}),I.addEventListener("blur",()=>{I.style.background=""}),I},_=()=>{let T=document.createElement("div");return T.style.cssText=`height:1px;background:${y(n,"overlayDivider")};margin:4px 0;`,T},h=[];this._cellMenuItemAllowed("col-insert-left")&&h.push(u(this._i18n.colInsertLeft,"col-insert-left")),this._cellMenuItemAllowed("col-insert-right")&&h.push(u(this._i18n.colInsertRight,"col-insert-right"));let d=this._cellMenuItemAllowed("col-delete")?[u(this._i18n.colDelete,"col-delete")]:[],m=[];this._cellMenuItemAllowed("row-insert-below")&&m.push(u(this._i18n.rowInsertBelow,"row-insert-below")),this._cellMenuItemAllowed("row-delete")&&m.push(u(this._i18n.rowDelete,"row-delete"));let f=this.getRowData(t),g=this._canvas.getBoundingClientRect(),p=g.left+s,b=g.top+i,v=typeof this._opts.cellContextMenuExtraItems=="function"?this._opts.cellContextMenuExtraItems({row:t,col:e,field:o,rowData:f,clientX:p,clientY:b})||[]:[],x=v.map((T,X)=>{let I=u(T.label,`extra:${X}`);return T.disabled&&(I.setAttribute("aria-disabled","true"),I.style.opacity="0.5",I.style.pointerEvents="none"),I}),S=[h,d,m,x].filter(T=>T.length>0);if(S.length===0)return;let C=S.flatMap((T,X)=>X===0?T:[_(),...T]),E=36,U=9,ot=S.reduce((T,X)=>T+X.length,0),M=S.length-1,k=ot*E+M*U+8,Y=i+k<=this._opts.height?i:Math.max(0,i-k),et=Math.min(s,this._opts.width-r-2),W=document.createElement("div");W.setAttribute("role","menu"),W.className=`${B.overlay} ${B.menu}`,W.style.cssText=a("position:absolute",`left:${et}px`,`top:${Y}px`,`width:${r}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",T=>T.stopPropagation()),W.addEventListener("click",T=>{let X=T.target.closest("[data-action]")?.dataset?.action;if(X){if(X==="col-insert-left"){this._closeCellContextMenu(),this._openNewColumnDialog(e,s,i);return}if(X==="col-insert-right"){this._closeCellContextMenu(),this._openNewColumnDialog(e+1,s,i);return}if(X.startsWith("extra:")){this._closeCellContextMenu(),v[Number(X.slice(6))]?.onClick?.({row:t,col:e,field:o,rowData:f,clientX:p,clientY:b}),this._kbProxy.focus();return}this._closeCellContextMenu(),X==="col-delete"?this.deleteColumn(o):X==="row-insert-below"?this.addRow({},{index:t+1}):X==="row-delete"&&this.deleteRow(t),this._kbProxy.focus()}}),W.addEventListener("keydown",T=>{if(T.key==="Escape")this._closeCellContextMenu(),this._kbProxy.focus();else if(T.key==="Enter"||T.key===" ")T.preventDefault(),document.activeElement?.click?.();else if(T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault();let X=[...W.querySelectorAll('[role="menuitem"]')],I=X.indexOf(document.activeElement),j=T.key==="ArrowDown"?(I+1)%X.length:(I-1+X.length)%X.length;X[j]?.focus()}T.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=Ke({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=>{let o=!1;this._withStructuralUndo(()=>{this._columnOriginalOrder.forEach(n=>{let r=i.get(n),a=!this._hiddenColumns.has(n);r&&!a?(this._deletedColumns.delete(n),this._showColumnInternal(n),o=!0):!r&&a&&(this._hideColumnInternal(n),o=!0)}),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()}),o&&this._opts.onColumnVisibilityChange?.(this.getHiddenColumns()),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){let e=!1;[...this._edits.keys()].forEach(s=>{let i=s.indexOf("_");s.slice(i+1)===t&&(this._edits.delete(s),e=!0)}),e&&(this._editsByRow=null);for(let s of l._plugins)s.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 r=this._columns.indexOf(this._columnOriginalOrder[n]);if(r!==-1){i=r;break}}let o=(n,r)=>{let a=[...n];return a.splice(i,0,r),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,r=0,a=0;return t<s.frozenWidth+n?r=-1:t>s.rightX-n&&(r=1),e<s.headerH+n?a=-1:e>o-s.hSB-n&&(a=1),{dx:r,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):""}_ensureEditsIndex(){if(this._editsByRow)return this._editsByRow;let t=new Map;return this._edits.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=t.get(o);n||t.set(o,n=new Set),n.add(s.slice(i+1))}),this._editsByRow=t,t}_getRow(t){let e=this._rowSource(t);if(!this._editedRows.has(t))return e;let s=e?{...e}:{},i=this._ensureEditsIndex().get(t);if(i)for(let o of i)s[o]=this._edits.get(`${t}_${o}`);return 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),r=n?.type??"text";if(r==="checkbox"||r==="button")return;let a=this._buildEditorCtx(t,e,s);a.keepInputValue=i;let c=n?.editor,u;if(typeof c=="function")u=c(a);else{let _=c??r,d=_==="text"&&!i&&String(a.initialValue??"").includes(`
107
+ `)?Ft.textMultiline:Ft[_]??Ft.text,m=_==="dropdown"||_==="multiselect"?{options:n?.options??[],...n?.editorOptions??{}}:_==="date"?{format:n?.format,...n?.editorOptions??{}}:n?.editorOptions??{};u=d(m)(a)}u&&(this._editing={row:t,col:e,el:u,ctx:a})}_buildEditorCtx(t,e,s){let{theme:i}=this._opts,o=this._geo(),{colPositions:n,headerH:r}=o,a=n[e+1]-n[e],c=this._rowLayout.yOf(t+1)-this._rowLayout.yOf(t),u=this._colLeft(e,o),_=this._rowLayout.yOf(t)-this._scrollTop+r;return We({row:t,col:e,field:this._columns[e],rowData:this._getRow(t),x:u,y:_,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:(h,d)=>this._moveSel(h,d),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(r){console.error("[JHGrid] button onClick error at row",t,"field",s,":",r)}}_isButtonCell(t){return!t||t.type!=="single"?!1:this._colDefMap.get(this._columns[t.col])?.type==="button"}_startDropdownEdit(t,e,s){let i=Ft[s?.type]??Ft.dropdown,o={options:s?.options??[],...s?.editorOptions??{}},n=this._buildEditorCtx(t,e),r=i(o)(n);r&&(this._editing={row:t,col:e,el:r,ctx:n})}_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=as,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),r=this._rowLayout.yOf(t)-this._scrollTop+s.headerH;Object.assign(this._kbProxy.style,{left:n+"px",top:r+"px",width:i+"px",height:o+"px"})}_commitEdit(){if(!this._editing)return;let{row:t,col:e,el:s,ctx:i}=this._editing,o=s.value,n=this._columns[e];this._editTxnBegin(),this._setEdit(t,n,o),this._editTxnCommit(),this._editing=null,s.remove(),i?._disposeSurfaces?.(),this._updateA11yCell();let r=this._validator.map.get(`${t}_${n}`);r&&this._announce(r),this._draw()}_cancelEdit(){if(!this._editing)return;let{el:t,ctx:e}=this._editing;this._editing=null,t.remove(),e?._disposeSurfaces?.(),this._draw()}_insertLineBreakInEdit(){if(!this._editing)return;let{row:t,col:e,el:s,ctx:i}=this._editing,o=s.selectionStart??s.value.length,n=s.selectionEnd??s.value.length,r=s.value.slice(0,o)+`
108
+ `+s.value.slice(n);this._editing=null,s.remove(),i?._disposeSurfaces?.(),this._startEdit(t,e,r),this._editing?.el.setSelectionRange(o+1,o+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:r}=this._pageBounds(),a=Math.max(n,Math.min(n+r-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){l._plugin("rowSelection")?.update(this,t,e,s)}_clearRowSelOnCellClick(t){l._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}),l._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 r=o[t]-o[s],a=o[t+1]-o[t];r<this._scrollLeft&&(this._scrollLeft=r),r+a>this._scrollLeft+e.vpW&&(this._scrollLeft=r+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 r=i;r<=o;r++)this._isEditable(r)&&n.push(this._columns[r]);this._editTxnBegin();for(let r=e;r<=s;r++)for(let a of n)this._setEdit(r,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=g=>g==null||g==="",n=s-1;for(;n>0;){let g=this._getRow(n);if(g==null||!this._columns.every(p=>o(g[p])))break;n--}let r=new Array(i).fill(!1),a=0,c=-1,u=1/0,_=g=>{if(g==null||g<0||g>n)return;let p=this._getRow(g);if(p==null)return;a++;let b=!0;for(let v=0;v<i;v++)o(p[this._columns[v]])||(b=!1,r[v]||(r[v]=!0));b&&g!==t&&(g<t&&g>c&&(c=g),g>t&&g<u&&(u=g))};this._dm.forEachLoaded((g,p)=>_(this._rowPlan.visualOfServer(p))),this._localRows.forEach((g,p)=>_(this._rowPlan.visualOfLocal(p)));let h=0,d=n,m=0,f=i-1;if(a>0&&(u<1/0&&(d=Math.min(d,u-1)),c>-1&&(h=c+1),m=f=e,i>1)){for(;f+1<i&&r[f+1];)f++;for(;m-1>=0&&r[m-1];)m--}return{r1:h,r2:d,c1:m,c2:f}}_ensureVisible(t,e){let s=this._geo(),{frozenCount:i,frozenRightCount:o,colPositions:n}=s,r=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<r-o){let u=n[e]-n[i],_=n[e+1]-n[e];u<this._scrollLeft&&(this._scrollLeft=u),u+_>this._scrollLeft+s.vpW&&(this._scrollLeft=u+_-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 l._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._editsByRow=null,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 l._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?.(l._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._editsByRow=null,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
109
  `)===-1)return;let{fontSize:s,cellPadding:i}=this._opts.theme,o=Math.ceil(e.split(`
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
- `).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
- `);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,_=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);})();
110
+ `).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(r=>{let a=i[r];if(a==null)return;let c=String(a).split(`
111
+ `).length;c>o&&(o=c)});let n=o<=1?this._rowLayout.defaultHeight:Math.max(ls,Math.ceil(o*e*1.4+s*2));this._rowLayout.setHeight(t,n)}_selectedRowsForAutoFit(){let t=l._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),this._editsByRow=null;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 l._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=(r,a)=>{let c=this._cellVal(r,a),u=this._colDefMap.get(this._columns[a]);return je(Kt(c,u,this._opts.theme.locale))};if(t)return t.map(r=>(this._rowSource(r)==null&&this._lastCopyMissingRows++,this._columns.map((a,c)=>e(r,c)).join(" "))).join(`
112
+ `);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},(r,a)=>{let c=s+a;return this._rowSource(c)==null&&this._lastCopyMissingRows++,Array.from({length:n-i+1},(u,_)=>e(c,i+_)).join(" ")}).join(`
113
+ `)}_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=Ye(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,r=0,a=(c,u,_)=>{if(c>=this._totalRows||u>=this._columns.length){r++;return}if(!this._isEditable(u)){r++;return}let h=this._columns[u];this._setEdit(c,h,_)};if(this._editTxnBegin(),s===1&&i===1&&this._sel.type==="range"){let c=e[0][0];for(let u=this._sel.r1;u<=this._sel.r2;u++)for(let _=this._sel.c1;_<=this._sel.c2;_++)a(u,_,c)}else e.forEach((c,u)=>c.forEach((_,h)=>a(o+u,n+h,_)));this._editTxnCommit(),this._draw(),r>0&&(this._showErrorBanner(this._i18n.pasteTruncated(r)),this._announce(this._i18n.pasteTruncated(r)))}_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:r,c1:a,r2:c,c2:u}=e,_=r>i||c<s,h=(_?r>i:a>n)?1:-1,d=_?h>0?r:c:h>0?a:u,m=f=>Math.abs(f-d)+1;if(this._editTxnBegin(),_)for(let f=o;f<=n;f++){if(!this._isEditable(f))continue;let g=[];for(let b=s;b<=i;b++)g.push(this._cellVal(b,f));let p=this._columns[f];for(let b=d;(h>0?b<=c:b>=r)&&!(b>=this._totalRows||b<0);b+=h)this._setEdit(b,p,Ce(g,m(b),h))}else for(let f=s;f<=i;f++){let g=[];for(let p=o;p<=n;p++)g.push(this._cellVal(f,p));for(let p=d;h>0?p<=u:p>=a;p+=h){if(!this._isEditable(p))continue;let b=this._columns[p];this._setEdit(f,b,Ce(g,m(p),h))}}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*Vs,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(ns,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(ls,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,r=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>r?this._fillPreview={r1:r+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:r,c2:i.col}:i.col<a?this._fillPreview={r1:n,c1:i.col,r2:r,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):((l._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:r,r2:a,c2:c}=this._fillPreview;this._applyFill(t,this._fillPreview),this._sel={type:"range",r1:Math.min(e,n),c1:Math.min(i,r),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())},Ks)}_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,r=n?this._scrollAim.y:this._scrollTop,a=n?this._scrollAim.x:this._scrollLeft,c=r<=s.minScrollY,u=r>=s.maxScrollY,_=a<=0,h=a>=s.maxScrollX,d=o!==0&&!(o>0&&u||o<0&&c),m=i!==0&&!(i>0&&h||i<0&&_);!d&&!m||(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 r=this._filterPanel?.col??-1;if(this._closeFilterPanel(),e.button===2&&this._sel){let h=this._hitCell(s,i,o);if(h&&(this._sel.type==="single"?this._sel.row===h.row&&this._sel.col===h.col:h.row>=this._sel.r1&&h.row<=this._sel.r2&&h.col>=this._sel.c1&&h.col<=this._sel.c2))return}if(this._hitScrollbar(s,i,o)){e.preventDefault();return}let{headerH:a}=o;if(i>=0&&i<a){let h=this._hitHeader(s,o);if(h!==null){let d=o.colPositions[h+1]-o.colPositions[h],m=this._colLeft(h,o)+d,f=m-$t;if(Math.abs(s-m)<=Ht){this._colResize={col:h,startX:s,startWidth:d,undoBefore:this._snapshotStructural()},e.preventDefault();return}let g=this._colLeft(h,o);if(h>0&&Math.abs(s-g)<=Ht){let b=o.colPositions[h]-o.colPositions[h-1];this._colResize={col:h-1,startX:s,startWidth:b,undoBefore:this._snapshotStructural()},e.preventDefault();return}let p=this._columns[h];if(this._colDefMap.get(p)?.headerCheckbox){let b=this._opts.theme?.cellPadding??4,v=this._colLeft(h,o)+b+6,x=Bt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(C=>C.isLeaf&&C.col===h),S=x?x.row*this._opts.headerHeight+x.rowspan*this._opts.headerHeight/2:a-this._opts.headerHeight/2;if(Math.abs(s-v)<=9&&Math.abs(i-S)<=9){let C=!(this._headerCheckboxState.get(p)??!1);this._headerCheckboxState.set(p,C),this._draw(),this._opts.onHeaderCheckboxChange?.(p,C),e.preventDefault();return}}if(s>=f&&i>=a-this._opts.headerHeight){h!==r&&this._openFilterPanel(h),e.preventDefault();return}this._colDrag={col:h,startX:s,insertBefore:h,active:!1,x:s,grabDX:s-this._colLeft(h,this._geo()),startCol:h,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 h=this._hitRowNumber(s,i,o);if(h!==null){if(e.preventDefault(),this._rowReorderReady()&&this._localIndexAt(h)<0){this._rowDrag={row:h,startY:i,insertBefore:h,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey};return}this._opts.rowReorder&&this._rowOrderData===null&&!l._plugins.some(d=>d.altRowSource?.(this))&&this._materializeRowOrder(),(l._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(h,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 _=this._hitCell(s,i,o);if(_&&e.preventDefault(),_){if(this._commitEdit(),!e.shiftKey&&!e.ctrlKey&&!e.metaKey){let m=this._hitCellButton(_.col,s,o);if(m){this._sel={type:"single",row:_.row,col:_.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=_,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(_.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell();try{m.onClick(_.row,this._getRow(_.row),this._columns[_.col])}catch(f){console.error("[JHGrid] cellButton onClick error at row",_.row,"field",this._columns[_.col],":",f)}this._draw();return}}if(!e.shiftKey&&!e.ctrlKey&&!e.metaKey){let m=this._columns[_.col];if(this._colDefMap.get(m)?.type==="button"){this._sel={type:"single",row:_.row,col:_.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=_,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(_.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._fireButtonClick(_.row,_.col),this._draw();return}}if(!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._isEditable(_.col)){let m=this._columns[_.col];if(this._colDefMap.get(m)?.type==="checkbox"){this._sel={type:"single",row:_.row,col:_.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=_,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(_.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(_.row+1,this._columnLabels[_.col]??this._columns[_.col],this._cellVal(_.row,_.col)||this._i18n.emptyCell)),this._toggleCheckbox(_.row,_.col);return}}let h=!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._sel?.type==="single"&&this._sel.row===_.row&&this._sel.col===_.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 m=this._selAnchor,f=this._normRange(m.row,m.col,_.row,_.col);this._sel=f.r1===f.r2&&f.c1===f.c2?{type:"single",row:f.r1,col:f.c1}:{type:"range",...f}}else this._sel={type:"single",row:_.row,col:_.col},this._selAnchor=null;this._selDragging=!0,this._selDragStart=_,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(_.row,e.ctrlKey||e.metaKey,e.shiftKey),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(_.row+1,this._columnLabels[_.col]??this._columns[_.col],this._cellVal(_.row,_.col)||this._i18n.emptyCell));let d=n&&n.row===_.row&&n.col===_.col;if(h&&!d&&this._isEditable(_.col)){let m=this._columns[_.col],f=this._colDefMap.get(m);if(f?.type==="dropdown"||f?.type==="multiselect"){this._draw(),this._startDropdownEdit(_.row,_.col,f);return}}this._draw()}},t.mousemove=e=>{let{x:s,y:i}=this._xy(e),o=this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag||this._drag||this._selDragging,n=null;if(o||this._anyOverlayOpen()?this._setHoverRow(null):(n=this._geo(),this._setHoverRow(this._hitCell(s,i,n)?.row??this._hitRowNumber(s,i,n))),this._updateStructuralGesture(s,i))return;n??=this._geo();let r=this._headerH;if(i>=0&&i<r){let a=this._hitHeader(s,n);if(a!==null){let c=n.colPositions[a+1]-n.colPositions[a],u=this._colLeft(a,n)+c,_=this._colLeft(a,n);if(Math.abs(s-u)<=Ht||a>0&&Math.abs(s-_)<=Ht)this._canvas.style.cursor="col-resize";else{let h=i>=r-this._opts.headerHeight;this._canvas.style.cursor=s>=u-$t&&h?"pointer":"grab"}}else!this._drag&&!this._selDragging&&(this._canvas.style.cursor="")}else if(!this._drag&&!this._selDragging)if(n.rowNumW>0&&s>=0&&s<n.rowNumW&&this._hitRowBoundary(i,n)!==null)this._canvas.style.cursor="row-resize";else if(this._sel&&this._hitFillHandle(s,i,n))this._canvas.style.cursor="crosshair";else{let a=this._hitCell(s,i,n),c=a?this._columns[a.col]:null,u=c&&this._colDefMap.get(c)?.type==="button",_=a&&this._hitCellButton(a.col,s,n);this._canvas.style.cursor=u||_?"pointer":""}if(this._drag){this._updateScrollbarDrag(s,i);return}if(this._selDragging&&(this._dragScrollPos={x:s,y:i},this._dragScrollDir=this._dragEdgeDir(s,i,n),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendDragSelection(s,i,n)),!this._drag&&!this._selDragging&&!this._colDrag&&!this._colResize&&!this._rowDrag){let a=this._hitCell(s,i,n),c=a&&!this._validator.isValid()?this._validator.map.get(`${a.row}_${this._columns[a.col]}`):null,u=null;if(!c&&a&&this._opts.cellTooltip)try{u=this._opts.cellTooltip(this.getRowData(a.row),a.row,this._columns[a.col],a.col)||null}catch(h){console.error("[JHGrid] cellTooltip error at row",a.row,"col",a.col,":",h)}let _=null;if(!c&&!u&&a)for(let h of l._plugins){let d=h.cellTooltip?.(this,a.row,this._columns[a.col]);if(d){_=d;break}}if(_)for(let h of l._plugins)h.showTooltip?.(this,_,s,i);else for(let h of l._plugins)h.hideTooltip?.(this);if(clearTimeout(this._tooltipTimer),c||u){let{width:h}=this._opts;this._cellTooltip.textContent=c||u,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,h-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else a&&!_&&!this._columnRenderers[a.col]?this._tooltipTimer=setTimeout(()=>{let h=this._cellVal(a.row,a.col);if(!h){this._cellTooltip.style.display="none";return}let{theme:d}=this._opts,m=this._canvas.getContext("2d");m.font=`${d.fontSize}px ${d.fontFamily}`;let g=n.colPositions[a.col+1]-n.colPositions[a.col]-d.cellPadding*2;if(m.measureText(h).width>g){let{width:b}=this._opts;this._cellTooltip.textContent=h,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,b-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 a of l._plugins)a.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 u=a.colPositions[c+1]-a.colPositions[c],_=this._colLeft(c,a)+u,h=this._colLeft(c,a),d=m=>{let f=this._selectedColsForAutoFit();f&&f.size>1&&(f.has(m)||f.has(m+1))?f.forEach(g=>this._autoFitCol(g)):this._autoFitCol(m)};if(Math.abs(s-_)<=Ht){d(c),this._clamp(this._geo()),this._draw();return}if(c>0&&Math.abs(s-h)<=Ht){d(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(u=>this._autoFitRow(u)):this._autoFitRow(a),this._clamp(this._geo()),this._draw();return}}let r=this._hitCell(s,i);r&&(this._sel={type:"single",row:r.row,col:r.col},this._opts.onCellDoubleClick?.(r.row,this._getRow(r.row),this._columns[r.col]),this._startEdit(r.row,r.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:r,r2:a,c2:c}=this._usedRange(i,o);this._setSel(n===a&&r===c?{type:"single",row:n,col:r}:{type:"range",r1:n,c1:r,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=Ys[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"){if(this._sel.type==="single"){e.preventDefault();let i=this._columns[this._sel.col],o=this._colDefMap.get(i);o?.type==="button"?(this._fireButtonClick(this._sel.row,this._sel.col),this._draw()):o?.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._suppressDefaultFocus||this._sel||this._totalRows===0||l._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 r=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 _=this._hitHeader(o,a);if(_!==null){let h=a.colPositions[_+1]-a.colPositions[_],d=this._colLeft(_,a)+h,m=d-$t;if(Math.abs(o-d)<=Vt){this._colResize={col:_,startX:o,startWidth:h,undoBefore:this._snapshotStructural()},e.preventDefault();return}let f=this._colLeft(_,a);if(_>0&&Math.abs(o-f)<=Vt){let p=a.colPositions[_]-a.colPositions[_-1];this._colResize={col:_-1,startX:o,startWidth:p,undoBefore:this._snapshotStructural()},e.preventDefault();return}let g=this._columns[_];if(this._colDefMap.get(g)?.headerCheckbox){let p=this._opts.theme?.cellPadding??4,b=this._colLeft(_,a)+p+6,v=Bt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(S=>S.isLeaf&&S.col===_),x=v?v.row*this._opts.headerHeight+v.rowspan*this._opts.headerHeight/2:c-this._opts.headerHeight/2;if(Math.abs(o-b)<=Vt&&Math.abs(n-x)<=Vt){let S=!(this._headerCheckboxState.get(g)??!1);this._headerCheckboxState.set(g,S),this._draw(),this._opts.onHeaderCheckboxChange?.(g,S),e.preventDefault();return}}if(o>=m&&n>=c-this._opts.headerHeight){_!==r&&this._openFilterPanel(_),e.preventDefault();return}this._colDrag={col:_,startX:o,insertBefore:_,active:!1,x:o,grabDX:o-this._colLeft(_,a),startCol:_,undoBefore:null,shiftKey:!1},this._armLongPress(o,n),e.preventDefault();return}}let u=a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH?this._hitRowBoundary(n,a,Vt):null;if(u!==null){this._rowResize={row:u,startY:n,startHeight:this._rowLayout.heightOf(u),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH){let _=this._hitRowNumber(o,n,a);_!==null&&(this._rowReorderReady()&&this._localIndexAt(_)<0?this._rowDrag={row:_,startY:n,insertBefore:_,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}:(this._opts.rowReorder&&this._rowOrderData===null&&!l._plugins.some(h=>h.altRowSource?.(this))&&this._materializeRowOrder(),this._rowTap={row:_,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,r=(i.clientY+o.clientY)/2-s.top,a=this._geo();this._scrollTop=Math.max(a.minScrollY,Math.min(a.maxScrollY,this._touch.scrollTopStart-(r-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,r=o-this._touch.startX,a=n-this._touch.startY;if(!this._touch.moved&&(Math.abs(r)>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-r)),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:u,ctrlKey:_,shiftKey:h}=this._rowTap;this._rowTap=null,(l._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(u,_,h),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(),r=this._hitCell(i,o,n);if(!r)return;let a=Date.now();if(a-this._lastTap.time<350&&this._lastTap.row===r.row&&this._lastTap.col===r.col)this._lastTap={time:0,row:-1,col:-1},this._sel={type:"single",row:r.row,col:r.col},this._startEdit(r.row,r.col),this._draw();else{this._lastTap={time:a,row:r.row,col:r.col},this._editing&&this._commitEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._setSel({type:"single",row:r.row,col:r.col}),this._selAnchor=null,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(r.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(r.row+1,this._columnLabels[r.col]??this._columns[r.col],this._cellVal(r.row,r.col)||this._i18n.emptyCell));let u=this._columns[r.col],_=this._colDefMap.get(u),h=this._hitCellButton(r.col,i,n);if(h){try{h.onClick(r.row,this._getRow(r.row),u)}catch(d){console.error("[JHGrid] cellButton onClick error at row",r.row,"field",u,":",d)}this._draw()}else _?.type==="button"?(this._fireButtonClick(r.row,r.col),this._draw()):_?.type==="checkbox"&&this._isEditable(r.col)?this._toggleCheckbox(r.row,r.col):(_?.type==="dropdown"||_?.type==="multiselect")&&this._isEditable(r.col)?(this._draw(),this._startDropdownEdit(r.row,r.col,_)):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 r=n.filter(a=>!this._hiddenColumns.has(a)&&!this._deletedColumns.has(a));this._columns=r,this._columnLabels=r.map(a=>this._colDefMap.get(a)?.label??a),this._columnAligns=r.map(a=>this._colDefMap.get(a)?.align??"left"),this._columnHeaderAligns=r.map(a=>this._colDefMap.get(a)?.headerAlign??this._colDefMap.get(a)?.align??"left"),this._columnWidths=r.map(a=>this._columnWidthMap.get(a)??this._colDefMap.get(a)?.width??this._opts.colWidth),this._columnRenderers=r.map(a=>{let c=this._colDefMap.get(a),u=c?.renderer;return u?typeof u=="function"?u:pt[u]?.()??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}),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 _=this._colDefMap.get(c)?.renderer;return _?typeof _=="function"?_:pt[_]?.()??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._clamp(this._geo()),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=l._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};for(let s of l._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:l._plugin("rowSelection")?.getRenderSet(this)??null,fillPreview:this._fillPreview,deletedRows:this._deletedRows.size>0?this._deletedRows:null,skeletonPhase:this._skeletonPhase(),rowNumberLabel:this._i18n.rowNumberLabel??"No.",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,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,r=this._canvas.getContext("2d"),a=this._canvas.width/n,c=new Map;for(let u of Bt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader))u.isLeaf&&c.set(u.col,u.row*i+u.rowspan*i/2);r.save(),r.setTransform(n,0,0,n,0,0);for(let u=0;u<this._columns.length;u++){let _=this._columns[u];if(!this._colDefMap.get(_)?.headerCheckbox)continue;let h=this._colLeft(u,t),d=(s[u+1]??s[u])-s[u];if(h+d<0||h>a)continue;let m=s.length-1,f=u<t.frozenCount,g=t.frozenRightCount>0&&u>=m-t.frozenRightCount;if(!f&&!g&&h<t.frozenWidth||!f&&!g&&t.frozenRightCount>0&&h>=t.rightX)continue;let p=this._opts.theme?.cellPadding??4,b=h+p+o/2,v=c.get(u)??e-i/2,x=this._headerCheckboxState.get(_)??!1;r.fillStyle=x?"#2563eb":"#ffffff",r.strokeStyle=x?"#2563eb":"#9ca3af",r.lineWidth=1,r.beginPath(),r.rect(b-o/2,v-o/2,o,o),r.fill(),r.stroke(),x&&(r.strokeStyle="#ffffff",r.lineWidth=1.5,r.lineCap="round",r.lineJoin="round",r.beginPath(),r.moveTo(b-3,v),r.lineTo(b-.5,v+2.5),r.lineTo(b+3.5,v-2.5),r.stroke())}r.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,r=!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])){r=!0;break}if(s.has(t[a]))break}return{left:n,right:r}})}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 l._plugins)t.hideTooltip?.(this);this._setSel(null),this._scrollTop=0,this._scrollLeft=0,this._page=0,this._edits.clear(),this._editedRows.clear(),this._editsByRow=null,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._editsByRow=null,this._validator.clear(),this._fillDrag=null,this._fillPreview=null,this._undoMgr.clear(),this._editTxn=null,this._draw()}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._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._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 r=new Map(o);o.clear(),r.forEach((a,c)=>{let u=c.indexOf("_"),_=Number(c.slice(0,u));if(_===e)return;let h=t(_);o.set(`${h}_${c.slice(u+1)}`,a),n?.(h)})};if(this._editedRows.clear(),i(this._edits,o=>this._editedRows.add(o)),this._editsByRow=null,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)}),l._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 l._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:[]};for(let e of l._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((r,a)=>{a.startsWith(n)&&(o[a.slice(n.length)]=r)}),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("_"),r=Number(o.slice(0,n)),a=this._rowPlan.sourceAt(r);!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(),this._editsByRow=null;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,r]of Object.entries(o))this._edits.set(`${i}_${n}`,r),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(d=>this._showColumnInternal(d)),o.forEach(d=>this._hideColumnInternal(d));let n=new Set(this._columns),r=t.columns.filter(d=>n.has(d)),a=new Set(r),c=this._columns.filter(d=>!a.has(d)),u=[...r,...c],_=new Map(this._columns.map((d,m)=>[d,m])),h=d=>u.map(m=>d[_.get(m)]);this._columnLabels=h(this._columnLabels),this._columnAligns=h(this._columnAligns),this._columnHeaderAligns=h(this._columnHeaderAligns),this._columnWidths=h(this._columnWidths),this._columnRenderers=h(this._columnRenderers),this._columns=u}if(t.columnWidths&&Object.entries(t.columnWidths).forEach(([o,n])=>{let r=this._columns.indexOf(o);r!==-1&&(this._columnWidths[r]=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=l._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 l._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._editsByRow=null,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._editsByRow=null,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()}),this._opts.onColumnVisibilityChange?.(this.getHiddenColumns()))}showColumn(t){this._hiddenColumns.has(t)&&(this._withStructuralUndo(()=>{this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()}),this._opts.onColumnVisibilityChange?.(this.getHiddenColumns()))}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 r of n??[])r.fields?.includes(i)&&r.fields?.includes(o)&&!r.fields.includes(t)&&r.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,cellButton:e.cellButton,editor:e.editor,editorOptions:e.editorOptions,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",r=e.headerAlign??n,a=e.width??this._opts.colWidth,u=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,_=(m,f)=>{let g=[...m];return g.splice(i,0,f),g};this._columns=_(this._columns,t),this._columnLabels=_(this._columnLabels,o),this._columnAligns=_(this._columnAligns,n),this._columnHeaderAligns=_(this._columnHeaderAligns,r),this._columnWidths=_(this._columnWidths,a),this._columnRenderers=_(this._columnRenderers,u),this._columnWidthMap.set(t,a),this._foldColumnIntoAdjacentGroups(t,i);let h=this._columns[i+1]??null,d=h?this._columnOriginalOrder.indexOf(h):-1;if(d===-1?this._columnOriginalOrder.push(t):this._columnOriginalOrder.splice(d,0,t),this._sel){let m=f=>f>=i?f+1:f;this._sel=this._sel.type==="single"?{...this._sel,col:m(this._sel.col)}:{...this._sel,c1:m(this._sel.c1),c2:m(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,u])=>{let _={};for(let h of s){let d=`${c}_${h}`,m=this._edits.has(d)?this._edits.get(d):u?.[h];_[h]=Kt(m,this._colDefMap.get(h),this._opts.theme.locale)}return _}),n=document.documentElement.lang||navigator.language||"en",r=Ue({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(r),a.document.close(),a.focus()}async exportCsv({filename:t,delimiter:e=",",includeHeaders:s=!0,bom:i=!0,full:o=!1}={}){let n=d=>Ne(d,e),r=[];s&&r.push(this._columnLabels.map(n).join(e));let a=(d,m)=>Kt(m,this._colDefMap.get(d),this._opts.theme.locale);if(o){let d=this._filterState();await this._forEachFilteredRow(d,(m,f)=>{m.forEach((g,p)=>{let b=this._columns.map(v=>{let x=f!=null&&this._edits.has(`${f+p}_${v}`)?this._edits.get(`${f+p}_${v}`):g?.[v];return n(a(v,x))});r.push(b.join(e))})})}else{let d=Ee(f=>this._dm.forEachLoaded(f),this._localRows,f=>this._rowPlan.visualOfServer(f),f=>this._rowPlan.visualOfLocal(f));for(let[f,g]of d){let p=this._columns.map(b=>{let v=`${f}_${b}`,x=this._edits.has(v)?this._edits.get(v):g?.[b];return n(a(b,x))});r.push(p.join(e))}let m=d.length-this._localRows.length;this._serverTotal>m&&console.warn(`[JHGrid] exportCsv: ${m} of ${this._serverTotal} server rows exported (only loaded chunks). Pass { full: true } to export all server rows.`)}let c=(i?"\uFEFF":"")+r.join(`\r
114
+ `),u=new Blob([c],{type:"text/csv;charset=utf-8;"}),_=URL.createObjectURL(u),h=document.createElement("a");h.href=_,h.download=t??this._i18n.exportCsvFilename,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(_)}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,Be(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()}};Qt.use(Qe);var Qs="0.2.0",ti={chrome:99,edge:99,firefox:112,safari:15.4};return fs(ei);})();