@keenmate/web-grid 1.0.5 → 1.2.0-rc01

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,27 +1,27 @@
1
- (function(oe,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(oe=typeof globalThis<"u"?globalThis:oe||self,U(oe.WebGrid={}))})(this,function(oe){"use strict";var Ca=Object.defineProperty;var Sa=(oe,U,Q)=>U in oe?Ca(oe,U,{enumerable:!0,configurable:!0,writable:!0,value:Q}):oe[U]=Q;var b=(oe,U,Q)=>Sa(oe,typeof U!="symbol"?U+"":U,Q);const U=Math.min,Q=Math.max,bt=Math.round,_t=Math.floor,ve=e=>({x:e,y:e}),lr={left:"right",right:"left",bottom:"top",top:"bottom"},ar={start:"end",end:"start"};function Bt(e,t,o){return Q(e,U(t,o))}function Ue(e,t){return typeof e=="function"?e(t):e}function Me(e){return e.split("-")[0]}function Ke(e){return e.split("-")[1]}function ko(e){return e==="x"?"y":"x"}function Wt(e){return e==="y"?"height":"width"}const dr=new Set(["top","bottom"]);function xe(e){return dr.has(Me(e))?"y":"x"}function Yt(e){return ko(xe(e))}function cr(e,t,o){o===void 0&&(o=!1);const i=Ke(e),r=Yt(e),s=Wt(r);let n=r==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(n=vt(n)),[n,vt(n)]}function gr(e){const t=vt(e);return[Ut(e),t,Ut(t)]}function Ut(e){return e.replace(/start|end/g,t=>ar[t])}const Ro=["left","right"],Eo=["right","left"],ur=["top","bottom"],hr=["bottom","top"];function fr(e,t,o){switch(e){case"top":case"bottom":return o?t?Eo:Ro:t?Ro:Eo;case"left":case"right":return t?ur:hr;default:return[]}}function wr(e,t,o,i){const r=Ke(e);let s=fr(Me(e),o==="start",i);return r&&(s=s.map(n=>n+"-"+r),t&&(s=s.concat(s.map(Ut)))),s}function vt(e){return e.replace(/left|right|bottom|top/g,t=>lr[t])}function pr(e){return{top:0,right:0,bottom:0,left:0,...e}}function Io(e){return typeof e!="number"?pr(e):{top:e,right:e,bottom:e,left:e}}function yt(e){const{x:t,y:o,width:i,height:r}=e;return{width:i,height:r,top:o,left:t,right:t+i,bottom:o+r,x:t,y:o}}function Do(e,t,o){let{reference:i,floating:r}=e;const s=xe(t),n=Yt(t),l=Wt(n),a=Me(t),d=s==="y",c=i.x+i.width/2-r.width/2,u=i.y+i.height/2-r.height/2,g=i[l]/2-r[l]/2;let h;switch(a){case"top":h={x:c,y:i.y-r.height};break;case"bottom":h={x:c,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:u};break;case"left":h={x:i.x-r.width,y:u};break;default:h={x:i.x,y:i.y}}switch(Ke(t)){case"start":h[n]-=g*(o&&d?-1:1);break;case"end":h[n]+=g*(o&&d?-1:1);break}return h}const mr=async(e,t,o)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:n}=o,l=s.filter(Boolean),a=await(n.isRTL==null?void 0:n.isRTL(t));let d=await n.getElementRects({reference:e,floating:t,strategy:r}),{x:c,y:u}=Do(d,i,a),g=i,h={},f=0;for(let w=0;w<l.length;w++){const{name:p,fn:m}=l[w],{x:v,y,data:x,reset:C}=await m({x:c,y:u,initialPlacement:i,placement:g,strategy:r,middlewareData:h,rects:d,platform:n,elements:{reference:e,floating:t}});c=v??c,u=y??u,h={...h,[p]:{...h[p],...x}},C&&f<=50&&(f++,typeof C=="object"&&(C.placement&&(g=C.placement),C.rects&&(d=C.rects===!0?await n.getElementRects({reference:e,floating:t,strategy:r}):C.rects),{x:c,y:u}=Do(d,g,a)),w=-1)}return{x:c,y:u,placement:g,strategy:r,middlewareData:h}};async function Kt(e,t){var o;t===void 0&&(t={});const{x:i,y:r,platform:s,rects:n,elements:l,strategy:a}=e,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:u="floating",altBoundary:g=!1,padding:h=0}=Ue(t,e),f=Io(h),p=l[g?u==="floating"?"reference":"floating":u],m=yt(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(p)))==null||o?p:p.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:c,strategy:a})),v=u==="floating"?{x:i,y:r,width:n.floating.width,height:n.floating.height}:n.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),x=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},C=yt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:y,strategy:a}):v);return{top:(m.top-C.top+f.top)/x.y,bottom:(C.bottom-m.bottom+f.bottom)/x.y,left:(m.left-C.left+f.left)/x.x,right:(C.right-m.right+f.right)/x.x}}const br=e=>({name:"arrow",options:e,async fn(t){const{x:o,y:i,placement:r,rects:s,platform:n,elements:l,middlewareData:a}=t,{element:d,padding:c=0}=Ue(e,t)||{};if(d==null)return{};const u=Io(c),g={x:o,y:i},h=Yt(r),f=Wt(h),w=await n.getDimensions(d),p=h==="y",m=p?"top":"left",v=p?"bottom":"right",y=p?"clientHeight":"clientWidth",x=s.reference[f]+s.reference[h]-g[h]-s.floating[f],C=g[h]-s.reference[h],_=await(n.getOffsetParent==null?void 0:n.getOffsetParent(d));let S=_?_[y]:0;(!S||!await(n.isElement==null?void 0:n.isElement(_)))&&(S=l.floating[y]||s.floating[f]);const k=x/2-C/2,E=S/2-w[f]/2-1,R=U(u[m],E),I=U(u[v],E),M=R,z=S-w[f]-I,D=S/2-w[f]/2+k,P=Bt(M,D,z),j=!a.arrow&&Ke(r)!=null&&D!==P&&s.reference[f]/2-(D<M?R:I)-w[f]/2<0,T=j?D<M?D-M:D-z:0;return{[h]:g[h]+T,data:{[h]:P,centerOffset:D-P-T,...j&&{alignmentOffset:T}},reset:j}}}),_r=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var o,i;const{placement:r,middlewareData:s,rects:n,initialPlacement:l,platform:a,elements:d}=t,{mainAxis:c=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:w=!0,...p}=Ue(e,t);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const m=Me(r),v=xe(l),y=Me(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(d.floating)),C=g||(y||!w?[vt(l)]:gr(l)),_=f!=="none";!g&&_&&C.push(...wr(l,w,f,x));const S=[l,...C],k=await Kt(t,p),E=[];let R=((i=s.flip)==null?void 0:i.overflows)||[];if(c&&E.push(k[m]),u){const D=cr(r,n,x);E.push(k[D[0]],k[D[1]])}if(R=[...R,{placement:r,overflows:E}],!E.every(D=>D<=0)){var I,M;const D=(((I=s.flip)==null?void 0:I.index)||0)+1,P=S[D];if(P&&(!(u==="alignment"?v!==xe(P):!1)||R.every(A=>xe(A.placement)===v?A.overflows[0]>0:!0)))return{data:{index:D,overflows:R},reset:{placement:P}};let j=(M=R.filter(T=>T.overflows[0]<=0).sort((T,A)=>T.overflows[1]-A.overflows[1])[0])==null?void 0:M.placement;if(!j)switch(h){case"bestFit":{var z;const T=(z=R.filter(A=>{if(_){const W=xe(A.placement);return W===v||W==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(W=>W>0).reduce((W,B)=>W+B,0)]).sort((A,W)=>A[1]-W[1])[0])==null?void 0:z[0];T&&(j=T);break}case"initialPlacement":j=l;break}if(r!==j)return{reset:{placement:j}}}return{}}}},vr=new Set(["left","top"]);async function yr(e,t){const{placement:o,platform:i,elements:r}=e,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),n=Me(o),l=Ke(o),a=xe(o)==="y",d=vr.has(n)?-1:1,c=s&&a?-1:1,u=Ue(t,e);let{mainAxis:g,crossAxis:h,alignmentAxis:f}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof f=="number"&&(h=l==="end"?f*-1:f),a?{x:h*c,y:g*d}:{x:g*d,y:h*c}}const Cr=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var o,i;const{x:r,y:s,placement:n,middlewareData:l}=t,a=await yr(t,e);return n===((o=l.offset)==null?void 0:o.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+a.x,y:s+a.y,data:{...a,placement:n}}}}},Sr=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:i,placement:r}=t,{mainAxis:s=!0,crossAxis:n=!1,limiter:l={fn:p=>{let{x:m,y:v}=p;return{x:m,y:v}}},...a}=Ue(e,t),d={x:o,y:i},c=await Kt(t,a),u=xe(Me(r)),g=ko(u);let h=d[g],f=d[u];if(s){const p=g==="y"?"top":"left",m=g==="y"?"bottom":"right",v=h+c[p],y=h-c[m];h=Bt(v,h,y)}if(n){const p=u==="y"?"top":"left",m=u==="y"?"bottom":"right",v=f+c[p],y=f-c[m];f=Bt(v,f,y)}const w=l.fn({...t,[g]:h,[u]:f});return{...w,data:{x:w.x-o,y:w.y-i,enabled:{[g]:s,[u]:n}}}}}},xr=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var o,i;const{placement:r,rects:s,platform:n,elements:l}=t,{apply:a=()=>{},...d}=Ue(e,t),c=await Kt(t,d),u=Me(r),g=Ke(r),h=xe(r)==="y",{width:f,height:w}=s.floating;let p,m;u==="top"||u==="bottom"?(p=u,m=g===(await(n.isRTL==null?void 0:n.isRTL(l.floating))?"start":"end")?"left":"right"):(m=u,p=g==="end"?"top":"bottom");const v=w-c.top-c.bottom,y=f-c.left-c.right,x=U(w-c[p],v),C=U(f-c[m],y),_=!t.middlewareData.shift;let S=x,k=C;if((o=t.middlewareData.shift)!=null&&o.enabled.x&&(k=y),(i=t.middlewareData.shift)!=null&&i.enabled.y&&(S=v),_&&!g){const R=Q(c.left,0),I=Q(c.right,0),M=Q(c.top,0),z=Q(c.bottom,0);h?k=f-2*(R!==0||I!==0?R+I:Q(c.left,c.right)):S=w-2*(M!==0||z!==0?M+z:Q(c.top,c.bottom))}await a({...t,availableWidth:k,availableHeight:S});const E=await n.getDimensions(l.floating);return f!==E.width||w!==E.height?{reset:{rects:!0}}:{}}}};function Ct(){return typeof window<"u"}function je(e){return To(e)?(e.nodeName||"").toLowerCase():"#document"}function re(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ye(e){var t;return(t=(To(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function To(e){return Ct()?e instanceof Node||e instanceof re(e).Node:!1}function ge(e){return Ct()?e instanceof Element||e instanceof re(e).Element:!1}function Ce(e){return Ct()?e instanceof HTMLElement||e instanceof re(e).HTMLElement:!1}function Mo(e){return!Ct()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof re(e).ShadowRoot}const kr=new Set(["inline","contents"]);function ot(e){const{overflow:t,overflowX:o,overflowY:i,display:r}=ue(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+o)&&!kr.has(r)}const Rr=new Set(["table","td","th"]);function Er(e){return Rr.has(je(e))}const Ir=[":popover-open",":modal"];function St(e){return Ir.some(t=>{try{return e.matches(t)}catch{return!1}})}const Dr=["transform","translate","scale","rotate","perspective"],Tr=["transform","translate","scale","rotate","perspective","filter"],Mr=["paint","layout","strict","content"];function jt(e){const t=Xt(),o=ge(e)?ue(e):e;return Dr.some(i=>o[i]?o[i]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!t&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!t&&(o.filter?o.filter!=="none":!1)||Tr.some(i=>(o.willChange||"").includes(i))||Mr.some(i=>(o.contain||"").includes(i))}function $r(e){let t=$e(e);for(;Ce(t)&&!Xe(t);){if(jt(t))return t;if(St(t))return null;t=$e(t)}return null}function Xt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ar=new Set(["html","body","#document"]);function Xe(e){return Ar.has(je(e))}function ue(e){return re(e).getComputedStyle(e)}function xt(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $e(e){if(je(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Mo(e)&&e.host||ye(e);return Mo(t)?t.host:t}function $o(e){const t=$e(e);return Xe(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ce(t)&&ot(t)?t:$o(t)}function it(e,t,o){var i;t===void 0&&(t=[]),o===void 0&&(o=!0);const r=$o(e),s=r===((i=e.ownerDocument)==null?void 0:i.body),n=re(r);if(s){const l=Gt(n);return t.concat(n,n.visualViewport||[],ot(r)?r:[],l&&o?it(l):[])}return t.concat(r,it(r,[],o))}function Gt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ao(e){const t=ue(e);let o=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const r=Ce(e),s=r?e.offsetWidth:o,n=r?e.offsetHeight:i,l=bt(o)!==s||bt(i)!==n;return l&&(o=s,i=n),{width:o,height:i,$:l}}function Qt(e){return ge(e)?e:e.contextElement}function Ge(e){const t=Qt(e);if(!Ce(t))return ve(1);const o=t.getBoundingClientRect(),{width:i,height:r,$:s}=Ao(t);let n=(s?bt(o.width):o.width)/i,l=(s?bt(o.height):o.height)/r;return(!n||!Number.isFinite(n))&&(n=1),(!l||!Number.isFinite(l))&&(l=1),{x:n,y:l}}const Lr=ve(0);function Lo(e){const t=re(e);return!Xt()||!t.visualViewport?Lr:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function zr(e,t,o){return t===void 0&&(t=!1),!o||t&&o!==re(e)?!1:t}function Fe(e,t,o,i){t===void 0&&(t=!1),o===void 0&&(o=!1);const r=e.getBoundingClientRect(),s=Qt(e);let n=ve(1);t&&(i?ge(i)&&(n=Ge(i)):n=Ge(e));const l=zr(s,o,i)?Lo(s):ve(0);let a=(r.left+l.x)/n.x,d=(r.top+l.y)/n.y,c=r.width/n.x,u=r.height/n.y;if(s){const g=re(s),h=i&&ge(i)?re(i):i;let f=g,w=Gt(f);for(;w&&i&&h!==f;){const p=Ge(w),m=w.getBoundingClientRect(),v=ue(w),y=m.left+(w.clientLeft+parseFloat(v.paddingLeft))*p.x,x=m.top+(w.clientTop+parseFloat(v.paddingTop))*p.y;a*=p.x,d*=p.y,c*=p.x,u*=p.y,a+=y,d+=x,f=re(w),w=Gt(f)}}return yt({width:c,height:u,x:a,y:d})}function kt(e,t){const o=xt(e).scrollLeft;return t?t.left+o:Fe(ye(e)).left+o}function zo(e,t){const o=e.getBoundingClientRect(),i=o.left+t.scrollLeft-kt(e,o),r=o.top+t.scrollTop;return{x:i,y:r}}function Pr(e){let{elements:t,rect:o,offsetParent:i,strategy:r}=e;const s=r==="fixed",n=ye(i),l=t?St(t.floating):!1;if(i===n||l&&s)return o;let a={scrollLeft:0,scrollTop:0},d=ve(1);const c=ve(0),u=Ce(i);if((u||!u&&!s)&&((je(i)!=="body"||ot(n))&&(a=xt(i)),Ce(i))){const h=Fe(i);d=Ge(i),c.x=h.x+i.clientLeft,c.y=h.y+i.clientTop}const g=n&&!u&&!s?zo(n,a):ve(0);return{width:o.width*d.x,height:o.height*d.y,x:o.x*d.x-a.scrollLeft*d.x+c.x+g.x,y:o.y*d.y-a.scrollTop*d.y+c.y+g.y}}function Or(e){return Array.from(e.getClientRects())}function Hr(e){const t=ye(e),o=xt(e),i=e.ownerDocument.body,r=Q(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),s=Q(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let n=-o.scrollLeft+kt(e);const l=-o.scrollTop;return ue(i).direction==="rtl"&&(n+=Q(t.clientWidth,i.clientWidth)-r),{width:r,height:s,x:n,y:l}}const Po=25;function Fr(e,t){const o=re(e),i=ye(e),r=o.visualViewport;let s=i.clientWidth,n=i.clientHeight,l=0,a=0;if(r){s=r.width,n=r.height;const c=Xt();(!c||c&&t==="fixed")&&(l=r.offsetLeft,a=r.offsetTop)}const d=kt(i);if(d<=0){const c=i.ownerDocument,u=c.body,g=getComputedStyle(u),h=c.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,f=Math.abs(i.clientWidth-u.clientWidth-h);f<=Po&&(s-=f)}else d<=Po&&(s+=d);return{width:s,height:n,x:l,y:a}}const Vr=new Set(["absolute","fixed"]);function qr(e,t){const o=Fe(e,!0,t==="fixed"),i=o.top+e.clientTop,r=o.left+e.clientLeft,s=Ce(e)?Ge(e):ve(1),n=e.clientWidth*s.x,l=e.clientHeight*s.y,a=r*s.x,d=i*s.y;return{width:n,height:l,x:a,y:d}}function Oo(e,t,o){let i;if(t==="viewport")i=Fr(e,o);else if(t==="document")i=Hr(ye(e));else if(ge(t))i=qr(t,o);else{const r=Lo(e);i={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return yt(i)}function Ho(e,t){const o=$e(e);return o===t||!ge(o)||Xe(o)?!1:ue(o).position==="fixed"||Ho(o,t)}function Nr(e,t){const o=t.get(e);if(o)return o;let i=it(e,[],!1).filter(l=>ge(l)&&je(l)!=="body"),r=null;const s=ue(e).position==="fixed";let n=s?$e(e):e;for(;ge(n)&&!Xe(n);){const l=ue(n),a=jt(n);!a&&l.position==="fixed"&&(r=null),(s?!a&&!r:!a&&l.position==="static"&&!!r&&Vr.has(r.position)||ot(n)&&!a&&Ho(e,n))?i=i.filter(c=>c!==n):r=l,n=$e(n)}return t.set(e,i),i}function Br(e){let{element:t,boundary:o,rootBoundary:i,strategy:r}=e;const n=[...o==="clippingAncestors"?St(t)?[]:Nr(t,this._c):[].concat(o),i],l=n[0],a=n.reduce((d,c)=>{const u=Oo(t,c,r);return d.top=Q(u.top,d.top),d.right=U(u.right,d.right),d.bottom=U(u.bottom,d.bottom),d.left=Q(u.left,d.left),d},Oo(t,l,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Wr(e){const{width:t,height:o}=Ao(e);return{width:t,height:o}}function Yr(e,t,o){const i=Ce(t),r=ye(t),s=o==="fixed",n=Fe(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const a=ve(0);function d(){a.x=kt(r)}if(i||!i&&!s)if((je(t)!=="body"||ot(r))&&(l=xt(t)),i){const h=Fe(t,!0,s,t);a.x=h.x+t.clientLeft,a.y=h.y+t.clientTop}else r&&d();s&&!i&&r&&d();const c=r&&!i&&!s?zo(r,l):ve(0),u=n.left+l.scrollLeft-a.x-c.x,g=n.top+l.scrollTop-a.y-c.y;return{x:u,y:g,width:n.width,height:n.height}}function Jt(e){return ue(e).position==="static"}function Fo(e,t){if(!Ce(e)||ue(e).position==="fixed")return null;if(t)return t(e);let o=e.offsetParent;return ye(e)===o&&(o=o.ownerDocument.body),o}function Vo(e,t){const o=re(e);if(St(e))return o;if(!Ce(e)){let r=$e(e);for(;r&&!Xe(r);){if(ge(r)&&!Jt(r))return r;r=$e(r)}return o}let i=Fo(e,t);for(;i&&Er(i)&&Jt(i);)i=Fo(i,t);return i&&Xe(i)&&Jt(i)&&!jt(i)?o:i||$r(e)||o}const Ur=async function(e){const t=this.getOffsetParent||Vo,o=this.getDimensions,i=await o(e.floating);return{reference:Yr(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Kr(e){return ue(e).direction==="rtl"}const jr={convertOffsetParentRelativeRectToViewportRelativeRect:Pr,getDocumentElement:ye,getClippingRect:Br,getOffsetParent:Vo,getElementRects:Ur,getClientRects:Or,getDimensions:Wr,getScale:Ge,isElement:ge,isRTL:Kr};function qo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Xr(e,t){let o=null,i;const r=ye(e);function s(){var l;clearTimeout(i),(l=o)==null||l.disconnect(),o=null}function n(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),s();const d=e.getBoundingClientRect(),{left:c,top:u,width:g,height:h}=d;if(l||t(),!g||!h)return;const f=_t(u),w=_t(r.clientWidth-(c+g)),p=_t(r.clientHeight-(u+h)),m=_t(c),y={rootMargin:-f+"px "+-w+"px "+-p+"px "+-m+"px",threshold:Q(0,U(1,a))||1};let x=!0;function C(_){const S=_[0].intersectionRatio;if(S!==a){if(!x)return n();S?n(!1,S):i=setTimeout(()=>{n(!1,1e-7)},1e3)}S===1&&!qo(d,e.getBoundingClientRect())&&n(),x=!1}try{o=new IntersectionObserver(C,{...y,root:r.ownerDocument})}catch{o=new IntersectionObserver(C,y)}o.observe(e)}return n(!0),s}function Gr(e,t,o,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,d=Qt(e),c=r||s?[...d?it(d):[],...it(t)]:[];c.forEach(m=>{r&&m.addEventListener("scroll",o,{passive:!0}),s&&m.addEventListener("resize",o)});const u=d&&l?Xr(d,o):null;let g=-1,h=null;n&&(h=new ResizeObserver(m=>{let[v]=m;v&&v.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(t)})),o()}),d&&!a&&h.observe(d),h.observe(t));let f,w=a?Fe(e):null;a&&p();function p(){const m=Fe(e);w&&!qo(w,m)&&o(),w=m,f=requestAnimationFrame(p)}return o(),()=>{var m;c.forEach(v=>{r&&v.removeEventListener("scroll",o),s&&v.removeEventListener("resize",o)}),u==null||u(),(m=h)==null||m.disconnect(),h=null,a&&cancelAnimationFrame(f)}}const Rt=Cr,rt=Sr,Ve=_r,Qr=xr,Jr=br,qe=(e,t,o)=>{const i=new Map,r={platform:jr,...o},s={...r.platform,_c:i};return mr(e,t,{...r,platform:s})},No={today:"Today",clear:"Clear",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdayNamesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]};function Et(e){const t={};let o="";return e.includes("-")?o="-":e.includes("/")?o="/":e.includes(".")&&(o="."),e.split(o).forEach((r,s)=>{r==="YYYY"||r==="YY"?t.year={index:s,length:r.length}:r==="MM"||r==="M"?t.month={index:s,length:2}:(r==="DD"||r==="D")&&(t.day={index:s,length:2})}),{format:e,separator:o,parts:t,maxLength:e.length}}function Zt(e,t){if(!e||isNaN(e.getTime()))return"";const o=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),{separator:s,parts:n}=t,l=[];for(let a=0;a<3;a++)n.year&&n.year.index===a?l.push(n.year.length===2?String(o).slice(-2):o):n.month&&n.month.index===a?l.push(i):n.day&&n.day.index===a&&l.push(r);return l.join(s)}function Zr(e,t){if(!e)return null;const{separator:o,parts:i}=t,r=e.split(o);let s=null,n=null,l=null;if(r.forEach((d,c)=>{if(d){if(i.year&&i.year.index===c){const u=parseInt(d,10);i.year.length===4&&d.length===4?s=u:i.year.length===2&&d.length===2&&(s=u<100?u+2e3:u)}else if(i.month&&i.month.index===c){const u=parseInt(d,10);d.length===2&&u>=1&&u<=12&&(n=u)}else if(i.day&&i.day.index===c){const u=parseInt(d,10);d.length===2&&u>=1&&u<=31&&(l=u)}}}),s===null||n===null||l===null)return null;const a=new Date(s,n-1,l);return a.getMonth()!==n-1||a.getDate()!==l?null:a}function ne(e){if(!e)return null;let t;if(typeof e=="string"){const[o,i,r]=e.split("-").map(Number);!o||!i||!r?t=new Date(e):t=new Date(o,i-1,r)}else t=new Date(e);return t.setHours(0,0,0,0),isNaN(t.getTime())?null:t}function It(e){const t=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${o}-${i}`}function nt(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function en(e){return nt(e,new Date)}function Qe(e,t){return new Date(e,t+1,0).getDate()}function tn(e,t){return new Date(e,t,1).getDay()}function on(e,t){if(!e)return{min:t-10,max:t+10};if(e.includes("-")){const[i,r]=e.split("-");return{min:parseInt(i,10),max:parseInt(r,10)}}const o=parseInt(e,10);return{min:o,max:o}}function rn(e,t,o=No){const i=nn(e,o),r=sn(e,t,o),s=ln(e,t,o),n=t.showTodayButton!==!1?cn(o):"";return`
1
+ (function(ne,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(ne=typeof globalThis<"u"?globalThis:ne||self,X(ne.WebGrid={}))})(this,function(ne){"use strict";var Da=Object.defineProperty;var Ta=(ne,X,Z)=>X in ne?Da(ne,X,{enumerable:!0,configurable:!0,writable:!0,value:Z}):ne[X]=Z;var b=(ne,X,Z)=>Ta(ne,typeof X!="symbol"?X+"":X,Z);const X=Math.min,Z=Math.max,vt=Math.round,yt=Math.floor,Ce=t=>({x:t,y:t}),hr={left:"right",right:"left",bottom:"top",top:"bottom"},fr={start:"end",end:"start"};function Kt(t,e,o){return Z(t,X(e,o))}function je(t,e){return typeof t=="function"?t(e):t}function Pe(t){return t.split("-")[0]}function Xe(t){return t.split("-")[1]}function $o(t){return t==="x"?"y":"x"}function jt(t){return t==="y"?"height":"width"}const wr=new Set(["top","bottom"]);function Ie(t){return wr.has(Pe(t))?"y":"x"}function Xt(t){return $o(Ie(t))}function pr(t,e,o){o===void 0&&(o=!1);const i=Xe(t),r=Xt(t),s=jt(r);let n=r==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(n=Ct(n)),[n,Ct(n)]}function mr(t){const e=Ct(t);return[Gt(t),e,Gt(e)]}function Gt(t){return t.replace(/start|end/g,e=>fr[e])}const Po=["left","right"],Ao=["right","left"],br=["top","bottom"],_r=["bottom","top"];function vr(t,e,o){switch(t){case"top":case"bottom":return o?e?Ao:Po:e?Po:Ao;case"left":case"right":return e?br:_r;default:return[]}}function yr(t,e,o,i){const r=Xe(t);let s=vr(Pe(t),o==="start",i);return r&&(s=s.map(n=>n+"-"+r),e&&(s=s.concat(s.map(Gt)))),s}function Ct(t){return t.replace(/left|right|bottom|top/g,e=>hr[e])}function Cr(t){return{top:0,right:0,bottom:0,left:0,...t}}function Lo(t){return typeof t!="number"?Cr(t):{top:t,right:t,bottom:t,left:t}}function St(t){const{x:e,y:o,width:i,height:r}=t;return{width:i,height:r,top:o,left:e,right:e+i,bottom:o+r,x:e,y:o}}function zo(t,e,o){let{reference:i,floating:r}=t;const s=Ie(e),n=Xt(e),l=jt(n),a=Pe(e),d=s==="y",c=i.x+i.width/2-r.width/2,u=i.y+i.height/2-r.height/2,h=i[l]/2-r[l]/2;let g;switch(a){case"top":g={x:c,y:i.y-r.height};break;case"bottom":g={x:c,y:i.y+i.height};break;case"right":g={x:i.x+i.width,y:u};break;case"left":g={x:i.x-r.width,y:u};break;default:g={x:i.x,y:i.y}}switch(Xe(e)){case"start":g[n]-=h*(o&&d?-1:1);break;case"end":g[n]+=h*(o&&d?-1:1);break}return g}const Sr=async(t,e,o)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:n}=o,l=s.filter(Boolean),a=await(n.isRTL==null?void 0:n.isRTL(e));let d=await n.getElementRects({reference:t,floating:e,strategy:r}),{x:c,y:u}=zo(d,i,a),h=i,g={},f=0;for(let w=0;w<l.length;w++){const{name:p,fn:m}=l[w],{x:_,y,data:C,reset:S}=await m({x:c,y:u,initialPlacement:i,placement:h,strategy:r,middlewareData:g,rects:d,platform:n,elements:{reference:t,floating:e}});c=_??c,u=y??u,g={...g,[p]:{...g[p],...C}},S&&f<=50&&(f++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(d=S.rects===!0?await n.getElementRects({reference:t,floating:e,strategy:r}):S.rects),{x:c,y:u}=zo(d,h,a)),w=-1)}return{x:c,y:u,placement:h,strategy:r,middlewareData:g}};async function Qt(t,e){var o;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:n,elements:l,strategy:a}=t,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:u="floating",altBoundary:h=!1,padding:g=0}=je(e,t),f=Lo(g),p=l[h?u==="floating"?"reference":"floating":u],m=St(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(p)))==null||o?p:p.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:c,strategy:a})),_=u==="floating"?{x:i,y:r,width:n.floating.width,height:n.floating.height}:n.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),C=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=St(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:_,offsetParent:y,strategy:a}):_);return{top:(m.top-S.top+f.top)/C.y,bottom:(S.bottom-m.bottom+f.bottom)/C.y,left:(m.left-S.left+f.left)/C.x,right:(S.right-m.right+f.right)/C.x}}const xr=t=>({name:"arrow",options:t,async fn(e){const{x:o,y:i,placement:r,rects:s,platform:n,elements:l,middlewareData:a}=e,{element:d,padding:c=0}=je(t,e)||{};if(d==null)return{};const u=Lo(c),h={x:o,y:i},g=Xt(r),f=jt(g),w=await n.getDimensions(d),p=g==="y",m=p?"top":"left",_=p?"bottom":"right",y=p?"clientHeight":"clientWidth",C=s.reference[f]+s.reference[g]-h[g]-s.floating[f],S=h[g]-s.reference[g],v=await(n.getOffsetParent==null?void 0:n.getOffsetParent(d));let x=v?v[y]:0;(!x||!await(n.isElement==null?void 0:n.isElement(v)))&&(x=l.floating[y]||s.floating[f]);const k=C/2-S/2,E=x/2-w[f]/2-1,I=X(u[m],E),R=X(u[_],E),P=I,D=x-w[f]-R,M=x/2-w[f]/2+k,A=Kt(P,M,D),F=!a.arrow&&Xe(r)!=null&&M!==A&&s.reference[f]/2-(M<P?I:R)-w[f]/2<0,T=F?M<P?M-P:M-D:0;return{[g]:h[g]+T,data:{[g]:A,centerOffset:M-A-T,...F&&{alignmentOffset:T}},reset:F}}}),kr=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,i;const{placement:r,middlewareData:s,rects:n,initialPlacement:l,platform:a,elements:d}=e,{mainAxis:c=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:w=!0,...p}=je(t,e);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const m=Pe(r),_=Ie(l),y=Pe(l)===l,C=await(a.isRTL==null?void 0:a.isRTL(d.floating)),S=h||(y||!w?[Ct(l)]:mr(l)),v=f!=="none";!h&&v&&S.push(...yr(l,w,f,C));const x=[l,...S],k=await Qt(e,p),E=[];let I=((i=s.flip)==null?void 0:i.overflows)||[];if(c&&E.push(k[m]),u){const M=pr(r,n,C);E.push(k[M[0]],k[M[1]])}if(I=[...I,{placement:r,overflows:E}],!E.every(M=>M<=0)){var R,P;const M=(((R=s.flip)==null?void 0:R.index)||0)+1,A=x[M];if(A&&(!(u==="alignment"?_!==Ie(A):!1)||I.every($=>Ie($.placement)===_?$.overflows[0]>0:!0)))return{data:{index:M,overflows:I},reset:{placement:A}};let F=(P=I.filter(T=>T.overflows[0]<=0).sort((T,$)=>T.overflows[1]-$.overflows[1])[0])==null?void 0:P.placement;if(!F)switch(g){case"bestFit":{var D;const T=(D=I.filter($=>{if(v){const Y=Ie($.placement);return Y===_||Y==="y"}return!0}).map($=>[$.placement,$.overflows.filter(Y=>Y>0).reduce((Y,U)=>Y+U,0)]).sort(($,Y)=>$[1]-Y[1])[0])==null?void 0:D[0];T&&(F=T);break}case"initialPlacement":F=l;break}if(r!==F)return{reset:{placement:F}}}return{}}}},Ir=new Set(["left","top"]);async function Er(t,e){const{placement:o,platform:i,elements:r}=t,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),n=Pe(o),l=Xe(o),a=Ie(o)==="y",d=Ir.has(n)?-1:1,c=s&&a?-1:1,u=je(e,t);let{mainAxis:h,crossAxis:g,alignmentAxis:f}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof f=="number"&&(g=l==="end"?f*-1:f),a?{x:g*c,y:h*d}:{x:h*d,y:g*c}}const Rr=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,i;const{x:r,y:s,placement:n,middlewareData:l}=e,a=await Er(e,t);return n===((o=l.offset)==null?void 0:o.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+a.x,y:s+a.y,data:{...a,placement:n}}}}},Dr=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:i,placement:r}=e,{mainAxis:s=!0,crossAxis:n=!1,limiter:l={fn:p=>{let{x:m,y:_}=p;return{x:m,y:_}}},...a}=je(t,e),d={x:o,y:i},c=await Qt(e,a),u=Ie(Pe(r)),h=$o(u);let g=d[h],f=d[u];if(s){const p=h==="y"?"top":"left",m=h==="y"?"bottom":"right",_=g+c[p],y=g-c[m];g=Kt(_,g,y)}if(n){const p=u==="y"?"top":"left",m=u==="y"?"bottom":"right",_=f+c[p],y=f-c[m];f=Kt(_,f,y)}const w=l.fn({...e,[h]:g,[u]:f});return{...w,data:{x:w.x-o,y:w.y-i,enabled:{[h]:s,[u]:n}}}}}},Tr=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var o,i;const{placement:r,rects:s,platform:n,elements:l}=e,{apply:a=()=>{},...d}=je(t,e),c=await Qt(e,d),u=Pe(r),h=Xe(r),g=Ie(r)==="y",{width:f,height:w}=s.floating;let p,m;u==="top"||u==="bottom"?(p=u,m=h===(await(n.isRTL==null?void 0:n.isRTL(l.floating))?"start":"end")?"left":"right"):(m=u,p=h==="end"?"top":"bottom");const _=w-c.top-c.bottom,y=f-c.left-c.right,C=X(w-c[p],_),S=X(f-c[m],y),v=!e.middlewareData.shift;let x=C,k=S;if((o=e.middlewareData.shift)!=null&&o.enabled.x&&(k=y),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(x=_),v&&!h){const I=Z(c.left,0),R=Z(c.right,0),P=Z(c.top,0),D=Z(c.bottom,0);g?k=f-2*(I!==0||R!==0?I+R:Z(c.left,c.right)):x=w-2*(P!==0||D!==0?P+D:Z(c.top,c.bottom))}await a({...e,availableWidth:k,availableHeight:x});const E=await n.getDimensions(l.floating);return f!==E.width||w!==E.height?{reset:{rects:!0}}:{}}}};function xt(){return typeof window<"u"}function Ge(t){return Oo(t)?(t.nodeName||"").toLowerCase():"#document"}function se(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Se(t){var e;return(e=(Oo(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Oo(t){return xt()?t instanceof Node||t instanceof se(t).Node:!1}function ue(t){return xt()?t instanceof Element||t instanceof se(t).Element:!1}function xe(t){return xt()?t instanceof HTMLElement||t instanceof se(t).HTMLElement:!1}function Ho(t){return!xt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof se(t).ShadowRoot}const Mr=new Set(["inline","contents"]);function nt(t){const{overflow:e,overflowX:o,overflowY:i,display:r}=he(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+o)&&!Mr.has(r)}const $r=new Set(["table","td","th"]);function Pr(t){return $r.has(Ge(t))}const Ar=[":popover-open",":modal"];function kt(t){return Ar.some(e=>{try{return t.matches(e)}catch{return!1}})}const Lr=["transform","translate","scale","rotate","perspective"],zr=["transform","translate","scale","rotate","perspective","filter"],Or=["paint","layout","strict","content"];function Jt(t){const e=Zt(),o=ue(t)?he(t):t;return Lr.some(i=>o[i]?o[i]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||zr.some(i=>(o.willChange||"").includes(i))||Or.some(i=>(o.contain||"").includes(i))}function Hr(t){let e=Ae(t);for(;xe(e)&&!Qe(e);){if(Jt(e))return e;if(kt(e))return null;e=Ae(e)}return null}function Zt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Fr=new Set(["html","body","#document"]);function Qe(t){return Fr.has(Ge(t))}function he(t){return se(t).getComputedStyle(t)}function It(t){return ue(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ae(t){if(Ge(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ho(t)&&t.host||Se(t);return Ho(e)?e.host:e}function Fo(t){const e=Ae(t);return Qe(e)?t.ownerDocument?t.ownerDocument.body:t.body:xe(e)&&nt(e)?e:Fo(e)}function st(t,e,o){var i;e===void 0&&(e=[]),o===void 0&&(o=!0);const r=Fo(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),n=se(r);if(s){const l=eo(n);return e.concat(n,n.visualViewport||[],nt(r)?r:[],l&&o?st(l):[])}return e.concat(r,st(r,[],o))}function eo(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function qo(t){const e=he(t);let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=xe(t),s=r?t.offsetWidth:o,n=r?t.offsetHeight:i,l=vt(o)!==s||vt(i)!==n;return l&&(o=s,i=n),{width:o,height:i,$:l}}function to(t){return ue(t)?t:t.contextElement}function Je(t){const e=to(t);if(!xe(e))return Ce(1);const o=e.getBoundingClientRect(),{width:i,height:r,$:s}=qo(e);let n=(s?vt(o.width):o.width)/i,l=(s?vt(o.height):o.height)/r;return(!n||!Number.isFinite(n))&&(n=1),(!l||!Number.isFinite(l))&&(l=1),{x:n,y:l}}const qr=Ce(0);function Vo(t){const e=se(t);return!Zt()||!e.visualViewport?qr:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Vr(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==se(t)?!1:e}function Ve(t,e,o,i){e===void 0&&(e=!1),o===void 0&&(o=!1);const r=t.getBoundingClientRect(),s=to(t);let n=Ce(1);e&&(i?ue(i)&&(n=Je(i)):n=Je(t));const l=Vr(s,o,i)?Vo(s):Ce(0);let a=(r.left+l.x)/n.x,d=(r.top+l.y)/n.y,c=r.width/n.x,u=r.height/n.y;if(s){const h=se(s),g=i&&ue(i)?se(i):i;let f=h,w=eo(f);for(;w&&i&&g!==f;){const p=Je(w),m=w.getBoundingClientRect(),_=he(w),y=m.left+(w.clientLeft+parseFloat(_.paddingLeft))*p.x,C=m.top+(w.clientTop+parseFloat(_.paddingTop))*p.y;a*=p.x,d*=p.y,c*=p.x,u*=p.y,a+=y,d+=C,f=se(w),w=eo(f)}}return St({width:c,height:u,x:a,y:d})}function Et(t,e){const o=It(t).scrollLeft;return e?e.left+o:Ve(Se(t)).left+o}function No(t,e){const o=t.getBoundingClientRect(),i=o.left+e.scrollLeft-Et(t,o),r=o.top+e.scrollTop;return{x:i,y:r}}function Nr(t){let{elements:e,rect:o,offsetParent:i,strategy:r}=t;const s=r==="fixed",n=Se(i),l=e?kt(e.floating):!1;if(i===n||l&&s)return o;let a={scrollLeft:0,scrollTop:0},d=Ce(1);const c=Ce(0),u=xe(i);if((u||!u&&!s)&&((Ge(i)!=="body"||nt(n))&&(a=It(i)),xe(i))){const g=Ve(i);d=Je(i),c.x=g.x+i.clientLeft,c.y=g.y+i.clientTop}const h=n&&!u&&!s?No(n,a):Ce(0);return{width:o.width*d.x,height:o.height*d.y,x:o.x*d.x-a.scrollLeft*d.x+c.x+h.x,y:o.y*d.y-a.scrollTop*d.y+c.y+h.y}}function Br(t){return Array.from(t.getClientRects())}function Wr(t){const e=Se(t),o=It(t),i=t.ownerDocument.body,r=Z(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=Z(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let n=-o.scrollLeft+Et(t);const l=-o.scrollTop;return he(i).direction==="rtl"&&(n+=Z(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:n,y:l}}const Bo=25;function Ur(t,e){const o=se(t),i=Se(t),r=o.visualViewport;let s=i.clientWidth,n=i.clientHeight,l=0,a=0;if(r){s=r.width,n=r.height;const c=Zt();(!c||c&&e==="fixed")&&(l=r.offsetLeft,a=r.offsetTop)}const d=Et(i);if(d<=0){const c=i.ownerDocument,u=c.body,h=getComputedStyle(u),g=c.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(i.clientWidth-u.clientWidth-g);f<=Bo&&(s-=f)}else d<=Bo&&(s+=d);return{width:s,height:n,x:l,y:a}}const Yr=new Set(["absolute","fixed"]);function Kr(t,e){const o=Ve(t,!0,e==="fixed"),i=o.top+t.clientTop,r=o.left+t.clientLeft,s=xe(t)?Je(t):Ce(1),n=t.clientWidth*s.x,l=t.clientHeight*s.y,a=r*s.x,d=i*s.y;return{width:n,height:l,x:a,y:d}}function Wo(t,e,o){let i;if(e==="viewport")i=Ur(t,o);else if(e==="document")i=Wr(Se(t));else if(ue(e))i=Kr(e,o);else{const r=Vo(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return St(i)}function Uo(t,e){const o=Ae(t);return o===e||!ue(o)||Qe(o)?!1:he(o).position==="fixed"||Uo(o,e)}function jr(t,e){const o=e.get(t);if(o)return o;let i=st(t,[],!1).filter(l=>ue(l)&&Ge(l)!=="body"),r=null;const s=he(t).position==="fixed";let n=s?Ae(t):t;for(;ue(n)&&!Qe(n);){const l=he(n),a=Jt(n);!a&&l.position==="fixed"&&(r=null),(s?!a&&!r:!a&&l.position==="static"&&!!r&&Yr.has(r.position)||nt(n)&&!a&&Uo(t,n))?i=i.filter(c=>c!==n):r=l,n=Ae(n)}return e.set(t,i),i}function Xr(t){let{element:e,boundary:o,rootBoundary:i,strategy:r}=t;const n=[...o==="clippingAncestors"?kt(e)?[]:jr(e,this._c):[].concat(o),i],l=n[0],a=n.reduce((d,c)=>{const u=Wo(e,c,r);return d.top=Z(u.top,d.top),d.right=X(u.right,d.right),d.bottom=X(u.bottom,d.bottom),d.left=Z(u.left,d.left),d},Wo(e,l,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Gr(t){const{width:e,height:o}=qo(t);return{width:e,height:o}}function Qr(t,e,o){const i=xe(e),r=Se(e),s=o==="fixed",n=Ve(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=Ce(0);function d(){a.x=Et(r)}if(i||!i&&!s)if((Ge(e)!=="body"||nt(r))&&(l=It(e)),i){const g=Ve(e,!0,s,e);a.x=g.x+e.clientLeft,a.y=g.y+e.clientTop}else r&&d();s&&!i&&r&&d();const c=r&&!i&&!s?No(r,l):Ce(0),u=n.left+l.scrollLeft-a.x-c.x,h=n.top+l.scrollTop-a.y-c.y;return{x:u,y:h,width:n.width,height:n.height}}function oo(t){return he(t).position==="static"}function Yo(t,e){if(!xe(t)||he(t).position==="fixed")return null;if(e)return e(t);let o=t.offsetParent;return Se(t)===o&&(o=o.ownerDocument.body),o}function Ko(t,e){const o=se(t);if(kt(t))return o;if(!xe(t)){let r=Ae(t);for(;r&&!Qe(r);){if(ue(r)&&!oo(r))return r;r=Ae(r)}return o}let i=Yo(t,e);for(;i&&Pr(i)&&oo(i);)i=Yo(i,e);return i&&Qe(i)&&oo(i)&&!Jt(i)?o:i||Hr(t)||o}const Jr=async function(t){const e=this.getOffsetParent||Ko,o=this.getDimensions,i=await o(t.floating);return{reference:Qr(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Zr(t){return he(t).direction==="rtl"}const en={convertOffsetParentRelativeRectToViewportRelativeRect:Nr,getDocumentElement:Se,getClippingRect:Xr,getOffsetParent:Ko,getElementRects:Jr,getClientRects:Br,getDimensions:Gr,getScale:Je,isElement:ue,isRTL:Zr};function jo(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function tn(t,e){let o=null,i;const r=Se(t);function s(){var l;clearTimeout(i),(l=o)==null||l.disconnect(),o=null}function n(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),s();const d=t.getBoundingClientRect(),{left:c,top:u,width:h,height:g}=d;if(l||e(),!h||!g)return;const f=yt(u),w=yt(r.clientWidth-(c+h)),p=yt(r.clientHeight-(u+g)),m=yt(c),y={rootMargin:-f+"px "+-w+"px "+-p+"px "+-m+"px",threshold:Z(0,X(1,a))||1};let C=!0;function S(v){const x=v[0].intersectionRatio;if(x!==a){if(!C)return n();x?n(!1,x):i=setTimeout(()=>{n(!1,1e-7)},1e3)}x===1&&!jo(d,t.getBoundingClientRect())&&n(),C=!1}try{o=new IntersectionObserver(S,{...y,root:r.ownerDocument})}catch{o=new IntersectionObserver(S,y)}o.observe(t)}return n(!0),s}function on(t,e,o,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,d=to(t),c=r||s?[...d?st(d):[],...st(e)]:[];c.forEach(m=>{r&&m.addEventListener("scroll",o,{passive:!0}),s&&m.addEventListener("resize",o)});const u=d&&l?tn(d,o):null;let h=-1,g=null;n&&(g=new ResizeObserver(m=>{let[_]=m;_&&_.target===d&&g&&(g.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(e)})),o()}),d&&!a&&g.observe(d),g.observe(e));let f,w=a?Ve(t):null;a&&p();function p(){const m=Ve(t);w&&!jo(w,m)&&o(),w=m,f=requestAnimationFrame(p)}return o(),()=>{var m;c.forEach(_=>{r&&_.removeEventListener("scroll",o),s&&_.removeEventListener("resize",o)}),u==null||u(),(m=g)==null||m.disconnect(),g=null,a&&cancelAnimationFrame(f)}}const Rt=Rr,lt=Dr,Ne=kr,rn=Tr,nn=xr,Be=(t,e,o)=>{const i=new Map,r={platform:en,...o},s={...r.platform,_c:i};return Sr(t,e,{...r,platform:s})},Xo={today:"Today",clear:"Clear",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdayNamesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]};function Dt(t){const e={};let o="";return t.includes("-")?o="-":t.includes("/")?o="/":t.includes(".")&&(o="."),t.split(o).forEach((r,s)=>{r==="YYYY"||r==="YY"?e.year={index:s,length:r.length}:r==="MM"||r==="M"?e.month={index:s,length:2}:(r==="DD"||r==="D")&&(e.day={index:s,length:2})}),{format:t,separator:o,parts:e,maxLength:t.length}}function io(t,e){if(!t||isNaN(t.getTime()))return"";const o=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),{separator:s,parts:n}=e,l=[];for(let a=0;a<3;a++)n.year&&n.year.index===a?l.push(n.year.length===2?String(o).slice(-2):o):n.month&&n.month.index===a?l.push(i):n.day&&n.day.index===a&&l.push(r);return l.join(s)}function sn(t,e){if(!t)return null;const{separator:o,parts:i}=e,r=t.split(o);let s=null,n=null,l=null;if(r.forEach((d,c)=>{if(d){if(i.year&&i.year.index===c){const u=parseInt(d,10);i.year.length===4&&d.length===4?s=u:i.year.length===2&&d.length===2&&(s=u<100?u+2e3:u)}else if(i.month&&i.month.index===c){const u=parseInt(d,10);d.length===2&&u>=1&&u<=12&&(n=u)}else if(i.day&&i.day.index===c){const u=parseInt(d,10);d.length===2&&u>=1&&u<=31&&(l=u)}}}),s===null||n===null||l===null)return null;const a=new Date(s,n-1,l);return a.getMonth()!==n-1||a.getDate()!==l?null:a}function le(t){if(!t)return null;let e;if(typeof t=="string"){const[o,i,r]=t.split("-").map(Number);!o||!i||!r?e=new Date(t):e=new Date(o,i-1,r)}else e=new Date(t);return e.setHours(0,0,0,0),isNaN(e.getTime())?null:e}function Tt(t){const e=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${o}-${i}`}function at(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function ln(t){return at(t,new Date)}function Ze(t,e){return new Date(t,e+1,0).getDate()}function an(t,e){return new Date(t,e,1).getDay()}function dn(t,e){if(!t)return{min:e-10,max:e+10};if(t.includes("-")){const[i,r]=t.split("-");return{min:parseInt(i,10),max:parseInt(r,10)}}const o=parseInt(t,10);return{min:o,max:o}}function cn(t,e,o=Xo){const i=gn(t,o),r=un(t,e,o),s=hn(t,e,o),n=e.showTodayButton!==!1?pn(o):"";return`
2
2
  <div class="wg-datepicker">
3
3
  <div class="wg-datepicker__header">
4
4
  ${i}
5
5
  </div>
6
- <div class="wg-datepicker__rolling-selector${e.rollingSelectorOpen?" wg-datepicker__rolling-selector--visible":""}">
6
+ <div class="wg-datepicker__rolling-selector${t.rollingSelectorOpen?" wg-datepicker__rolling-selector--visible":""}">
7
7
  ${r}
8
8
  </div>
9
- <div class="wg-datepicker__calendar${e.rollingSelectorOpen?" wg-datepicker__calendar--hidden":""}">
9
+ <div class="wg-datepicker__calendar${t.rollingSelectorOpen?" wg-datepicker__calendar--hidden":""}">
10
10
  ${s}
11
11
  </div>
12
12
  ${n}
13
13
  </div>
14
- `}function nn(e,t){return`
14
+ `}function gn(t,e){return`
15
15
  <button type="button" class="wg-datepicker__nav wg-datepicker__nav--prev" data-action="prev-month">
16
16
  <svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>
17
17
  </button>
18
18
  <button type="button" class="wg-datepicker__month-year" data-action="toggle-rolling">
19
- ${t.monthNames[e.viewMonth]} ${e.viewYear}
19
+ ${e.monthNames[t.viewMonth]} ${t.viewYear}
20
20
  </button>
21
21
  <button type="button" class="wg-datepicker__nav wg-datepicker__nav--next" data-action="next-month">
22
22
  <svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"/></svg>
23
23
  </button>
24
- `}function sn(e,t,o){const i=on(t.rollingYearRange,new Date().getFullYear());let r="";for(let n=i.min;n<=i.max;n++){const l=n===e.viewYear?" wg-datepicker__rolling-item--selected":"";r+=`<div class="wg-datepicker__rolling-item${l}" data-year="${n}">${n}</div>`}let s="";for(let n=0;n<12;n++){const l=n===e.viewMonth?" wg-datepicker__rolling-item--selected":"";s+=`<div class="wg-datepicker__rolling-item${l}" data-month="${n}">${o.monthNamesShort[n]}</div>`}return`
24
+ `}function un(t,e,o){const i=dn(e.rollingYearRange,new Date().getFullYear());let r="";for(let n=i.min;n<=i.max;n++){const l=n===t.viewYear?" wg-datepicker__rolling-item--selected":"";r+=`<div class="wg-datepicker__rolling-item${l}" data-year="${n}">${n}</div>`}let s="";for(let n=0;n<12;n++){const l=n===t.viewMonth?" wg-datepicker__rolling-item--selected":"";s+=`<div class="wg-datepicker__rolling-item${l}" data-month="${n}">${o.monthNamesShort[n]}</div>`}return`
25
25
  <div class="wg-datepicker__rolling-lists">
26
26
  <div class="wg-datepicker__rolling-list" data-list="months">
27
27
  ${s}
@@ -30,20 +30,20 @@
30
30
  ${r}
31
31
  </div>
32
32
  </div>
33
- `}function ln(e,t,o){const i=an(o),r=Bo(e,t);return`
33
+ `}function hn(t,e,o){const i=fn(o),r=Go(t,e);return`
34
34
  <div class="wg-datepicker__weekdays">
35
35
  ${i}
36
36
  </div>
37
37
  <div class="wg-datepicker__days">
38
38
  ${r}
39
39
  </div>
40
- `}function an(e){return e.weekdayNamesShort.map(t=>`<div class="wg-datepicker__weekday">${t}</div>`).join("")}function Bo(e,t){const{viewYear:o,viewMonth:i,selectedDate:r,focusedDate:s}=e,n=t.minDate?ne(t.minDate):null,l=t.maxDate?ne(t.maxDate):null,a=tn(o,i),d=Qe(o,i),c=Qe(o,i-1),u=new Date(o,i-1,1),g=u.getFullYear(),h=u.getMonth(),f=new Date(o,i+1,1),w=f.getFullYear(),p=f.getMonth(),m=[];for(let C=a-1;C>=0;C--){const _=c-C;m.push({date:new Date(g,h,_),day:_,isOtherMonth:!0})}for(let C=1;C<=d;C++)m.push({date:new Date(o,i,C),day:C,isOtherMonth:!1});const y=Math.ceil((a+d)/7)*7-m.length;for(let C=1;C<=y;C++)m.push({date:new Date(w,p,C),day:C,isOtherMonth:!0});let x="";for(const C of m){const _=["wg-datepicker__day"];C.isOtherMonth&&_.push("wg-datepicker__day--other-month"),dn(C.date,n,l)&&_.push("wg-datepicker__day--disabled"),en(C.date)&&_.push("wg-datepicker__day--today"),nt(C.date,r)&&_.push("wg-datepicker__day--selected"),nt(C.date,s)&&_.push("wg-datepicker__day--focused");const k=It(C.date);x+=`<div class="${_.join(" ")}" data-date="${k}">${C.day}</div>`}return x}function dn(e,t,o){return!!(t&&e<t||o&&e>o)}function cn(e){return`
40
+ `}function fn(t){return t.weekdayNamesShort.map(e=>`<div class="wg-datepicker__weekday">${e}</div>`).join("")}function Go(t,e){const{viewYear:o,viewMonth:i,selectedDate:r,focusedDate:s}=t,n=e.minDate?le(e.minDate):null,l=e.maxDate?le(e.maxDate):null,a=an(o,i),d=Ze(o,i),c=Ze(o,i-1),u=new Date(o,i-1,1),h=u.getFullYear(),g=u.getMonth(),f=new Date(o,i+1,1),w=f.getFullYear(),p=f.getMonth(),m=[];for(let S=a-1;S>=0;S--){const v=c-S;m.push({date:new Date(h,g,v),day:v,isOtherMonth:!0})}for(let S=1;S<=d;S++)m.push({date:new Date(o,i,S),day:S,isOtherMonth:!1});const y=Math.ceil((a+d)/7)*7-m.length;for(let S=1;S<=y;S++)m.push({date:new Date(w,p,S),day:S,isOtherMonth:!0});let C="";for(const S of m){const v=["wg-datepicker__day"];S.isOtherMonth&&v.push("wg-datepicker__day--other-month"),wn(S.date,n,l)&&v.push("wg-datepicker__day--disabled"),ln(S.date)&&v.push("wg-datepicker__day--today"),at(S.date,r)&&v.push("wg-datepicker__day--selected"),at(S.date,s)&&v.push("wg-datepicker__day--focused");const k=Tt(S.date);C+=`<div class="${v.join(" ")}" data-date="${k}">${S.day}</div>`}return C}function wn(t,e,o){return!!(e&&t<e||o&&t>o)}function pn(t){return`
41
41
  <div class="wg-datepicker__footer">
42
42
  <button type="button" class="wg-datepicker__today-btn" data-action="today">
43
- ${e.today}
43
+ ${t.today}
44
44
  </button>
45
45
  </div>
46
- `}function gn(e,t,o){const i=e.querySelector(".wg-datepicker__days");i&&(i.innerHTML=Bo(t,o))}function un(e,t,o){const i=e.querySelector(".wg-datepicker__month-year");if(i){const r=o.monthNames[t.viewMonth];i.textContent=`${r} ${t.viewYear}`}}function hn(e,t){const o=e.querySelector(".wg-datepicker__rolling-selector"),i=e.querySelector(".wg-datepicker__calendar");o&&o.classList.toggle("wg-datepicker__rolling-selector--visible",t),i&&i.classList.toggle("wg-datepicker__calendar--hidden",t)}function fn(e,t){e.querySelectorAll("[data-year]").forEach(r=>{const s=parseInt(r.dataset.year||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===t.viewYear)}),e.querySelectorAll("[data-month]").forEach(r=>{const s=parseInt(r.dataset.month||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===t.viewMonth)})}function Wo(e){const t=e.querySelector("[data-year].wg-datepicker__rolling-item--selected"),o=e.querySelector("[data-month].wg-datepicker__rolling-item--selected");if(t){const i=t.parentElement;if(i){const r=t.offsetTop-i.clientHeight/2+t.clientHeight/2;i.scrollTop=r}}if(o){const i=o.parentElement;if(i){const r=o.offsetTop-i.clientHeight/2+o.clientHeight/2;i.scrollTop=r}}}function eo(e){e.viewMonth===0?(e.viewMonth=11,e.viewYear--):e.viewMonth--}function to(e){e.viewMonth===11?(e.viewMonth=0,e.viewYear++):e.viewMonth++}function wn(e,t,o,i){var s,n,l,a;const{key:r}=e;if(r==="Escape")return(s=i.onClose)==null||s.call(i),!0;if(t.rollingSelectorOpen)return mn(e,t);if((r==="ArrowLeft"||r==="ArrowRight")&&(e.ctrlKey||e.metaKey)){if(e.preventDefault(),r==="ArrowLeft"?eo(t):to(t),t.focusedDate){const d=Math.min(t.focusedDate.getDate(),Qe(t.viewYear,t.viewMonth));t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(r))return e.preventDefault(),pn(t,r,o),!0;if(r==="Enter")return e.preventDefault(),e.stopPropagation(),t.focusedDate&&((n=i.onSelect)==null||n.call(i,t.focusedDate,"down")),!0;if(r==="Tab")return e.preventDefault(),t.focusedDate?(l=i.onSelect)==null||l.call(i,t.focusedDate,"next"):(a=i.onClose)==null||a.call(i),!0;if(r==="Home"){if(e.preventDefault(),e.ctrlKey||e.metaKey){let d=t.viewYear;const c=new Date(d,0,1);if(t.focusedDate&&nt(t.focusedDate,c)&&d--,o.minDate){const u=ne(o.minDate);u&&d<u.getFullYear()&&(d=u.getFullYear())}t.viewMonth=0,t.viewYear=d,t.focusedDate=new Date(d,0,1)}else t.focusedDate=new Date(t.viewYear,t.viewMonth,1);return!0}if(r==="End"){if(e.preventDefault(),e.ctrlKey||e.metaKey){let d=t.viewYear;const c=new Date(d,11,31);if(t.focusedDate&&nt(t.focusedDate,c)&&d++,o.maxDate){const u=ne(o.maxDate);u&&d>u.getFullYear()&&(d=u.getFullYear())}t.viewMonth=11,t.viewYear=d,t.focusedDate=new Date(d,11,31)}else{const d=Qe(t.viewYear,t.viewMonth);t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}if(r==="PageUp"){if(e.preventDefault(),eo(t),t.focusedDate){const d=Math.min(t.focusedDate.getDate(),Qe(t.viewYear,t.viewMonth));t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}if(r==="PageDown"){if(e.preventDefault(),to(t),t.focusedDate){const d=Math.min(t.focusedDate.getDate(),Qe(t.viewYear,t.viewMonth));t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}return!1}function pn(e,t,o){if(!e.focusedDate){e.focusedDate=e.selectedDate?new Date(e.selectedDate):new Date(e.viewYear,e.viewMonth,1);return}const i=new Date(e.focusedDate),r=o.minDate?ne(o.minDate):null,s=o.maxDate?ne(o.maxDate):null;switch(t){case"ArrowLeft":i.setDate(i.getDate()-1);break;case"ArrowRight":i.setDate(i.getDate()+1);break;case"ArrowUp":i.setDate(i.getDate()-7);break;case"ArrowDown":i.setDate(i.getDate()+7);break}r&&i<r||s&&i>s||(e.focusedDate=i,(i.getMonth()!==e.viewMonth||i.getFullYear()!==e.viewYear)&&(e.viewMonth=i.getMonth(),e.viewYear=i.getFullYear()))}function mn(e,t){const{key:o}=e;if(o==="ArrowUp"||o==="ArrowDown"){e.preventDefault();const i=o==="ArrowUp"?-1:1;if(t.rollingSelectorMode==="month"){const r=t.viewMonth+i;r>=0&&r<=11&&(t.viewMonth=r)}else t.viewYear+=i;return!0}return o==="ArrowLeft"||o==="ArrowRight"?(e.preventDefault(),t.rollingSelectorMode=t.rollingSelectorMode==="month"?"year":"month",!0):o==="Enter"||o==="Escape"?(e.preventDefault(),t.rollingSelectorOpen=!1,!0):!1}function bn(e){if(e.selectedDate)e.focusedDate=new Date(e.selectedDate),e.viewYear=e.selectedDate.getFullYear(),e.viewMonth=e.selectedDate.getMonth();else{const t=new Date;e.focusedDate=new Date(e.viewYear,e.viewMonth,t.getDate())}}function _n(e,t,o){const i=e.dataset.date;if(!i||e.classList.contains("wg-datepicker__day--disabled"))return null;const[r,s,n]=i.split("-").map(Number),l=new Date(r,s-1,n),a=o.minDate?ne(o.minDate):null,d=o.maxDate?ne(o.maxDate):null;return a&&l<a||d&&l>d?null:(t.selectedDate=l,t.focusedDate=l,l)}function vn(e,t){const o=new Date;o.setHours(0,0,0,0);const i=t.minDate?ne(t.minDate):null,r=t.maxDate?ne(t.maxDate):null;return i&&o<i||r&&o>r?null:(e.selectedDate=o,e.focusedDate=o,e.viewYear=o.getFullYear(),e.viewMonth=o.getMonth(),o)}function yn(e,t){const o=e.dataset.month;o!==void 0&&(t.viewMonth=parseInt(o,10))}function Cn(e,t){const o=e.dataset.year;o!==void 0&&(t.viewYear=parseInt(o,10))}function oo(e,t){var u,g,h,f;const{separator:o,parts:i,maxLength:r}=t,s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=e.replace(new RegExp(s,"g"),""),l=((u=i.year)==null?void 0:u.length)??4,a=[{type:"year",pos:((g=i.year)==null?void 0:g.index)??0,length:l},{type:"month",pos:((h=i.month)==null?void 0:h.index)??1,length:2},{type:"day",pos:((f=i.day)==null?void 0:f.index)??2,length:2}].sort((w,p)=>w.pos-p.pos);let d="",c=0;for(let w=0;w<a.length;w++){const p=a[w],m=n.substring(c,c+p.length);if(!m)break;d+=m,c+=m.length,w<a.length-1&&m.length===p.length&&(d+=o)}return d.substring(0,r)}function Sn(e,t,o){const i=e.value,r=e.selectionStart||0,s=i.length<o.length,{separator:n}=t,l=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=i.replace(new RegExp(`[^0-9${l}]`,"g"),""),d=oo(a,t);if(d!==i){e.value=d;let c=r;if(s)c=r;else if(d.length>i.length&&d[r]===n)c=r+1;else if(d.length>i.length){const u=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=(i.substring(0,r).match(new RegExp(u,"g"))||[]).length,f=(d.substring(0,r).match(new RegExp(u,"g"))||[]).length-g;c=r+f}e.setSelectionRange(c,c)}return d}function xn(e,t){const{key:o,ctrlKey:i,metaKey:r}=e,{separator:s}=t;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(o)||i||r)return!1;if(o===s){const l=e.target,a=l.selectionStart||0,d=l.value;let c=0;for(let g=a-1;g>=0;g--)if(d[g]===s){c=g+1;break}const u=d.substring(c,a);if(/^\d$/.test(u)){e.preventDefault();const g=d.substring(0,c)+"0"+u+s+d.substring(a);l.value=g;const h=c+2+s.length;return l.setSelectionRange(h,h),!0}}return!/^\d$/.test(o)&&o!==s?(e.preventDefault(),!0):!1}function kn(e,t,o){var h;e.preventDefault();const i=((h=e.clipboardData)==null?void 0:h.getData("text"))||"",{separator:r}=o,s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=i.replace(new RegExp(`[^0-9${s}]`,"g"),""),l=oo(n,o),a=t.selectionStart||0,d=t.selectionEnd||0,c=t.value,u=c.substring(0,a)+l+c.substring(d);t.value=oo(u,o);const g=a+l.length;t.setSelectionRange(g,g)}function Rn(e,t,o,i){if(!e||e.length<t.maxLength)return!1;const r=Zr(e,t);if(!r)return!1;const s=i.minDate?ne(i.minDate):null,n=i.maxDate?ne(i.maxDate):null;return s&&r<s||n&&r>n?!1:(o.selectedDate=r,o.focusedDate=r,o.viewYear=r.getFullYear(),o.viewMonth=r.getMonth(),!0)}const En=`
46
+ `}function mn(t,e,o){const i=t.querySelector(".wg-datepicker__days");i&&(i.innerHTML=Go(e,o))}function bn(t,e,o){const i=t.querySelector(".wg-datepicker__month-year");if(i){const r=o.monthNames[e.viewMonth];i.textContent=`${r} ${e.viewYear}`}}function _n(t,e){const o=t.querySelector(".wg-datepicker__rolling-selector"),i=t.querySelector(".wg-datepicker__calendar");o&&o.classList.toggle("wg-datepicker__rolling-selector--visible",e),i&&i.classList.toggle("wg-datepicker__calendar--hidden",e)}function vn(t,e){t.querySelectorAll("[data-year]").forEach(r=>{const s=parseInt(r.dataset.year||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===e.viewYear)}),t.querySelectorAll("[data-month]").forEach(r=>{const s=parseInt(r.dataset.month||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===e.viewMonth)})}function Qo(t){const e=t.querySelector("[data-year].wg-datepicker__rolling-item--selected"),o=t.querySelector("[data-month].wg-datepicker__rolling-item--selected");if(e){const i=e.parentElement;if(i){const r=e.offsetTop-i.clientHeight/2+e.clientHeight/2;i.scrollTop=r}}if(o){const i=o.parentElement;if(i){const r=o.offsetTop-i.clientHeight/2+o.clientHeight/2;i.scrollTop=r}}}function ro(t){t.viewMonth===0?(t.viewMonth=11,t.viewYear--):t.viewMonth--}function no(t){t.viewMonth===11?(t.viewMonth=0,t.viewYear++):t.viewMonth++}function yn(t,e,o,i){var s,n,l,a;const{key:r}=t;if(r==="Escape")return(s=i.onClose)==null||s.call(i),!0;if(e.rollingSelectorOpen)return Sn(t,e);if((r==="ArrowLeft"||r==="ArrowRight")&&(t.ctrlKey||t.metaKey)){if(t.preventDefault(),r==="ArrowLeft"?ro(e):no(e),e.focusedDate){const d=Math.min(e.focusedDate.getDate(),Ze(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(r))return t.preventDefault(),Cn(e,r,o),!0;if(r==="Enter")return t.preventDefault(),t.stopPropagation(),e.focusedDate&&((n=i.onSelect)==null||n.call(i,e.focusedDate,"down")),!0;if(r==="Tab")return t.preventDefault(),e.focusedDate?(l=i.onSelect)==null||l.call(i,e.focusedDate,"next"):(a=i.onClose)==null||a.call(i),!0;if(r==="Home"){if(t.preventDefault(),t.ctrlKey||t.metaKey){let d=e.viewYear;const c=new Date(d,0,1);if(e.focusedDate&&at(e.focusedDate,c)&&d--,o.minDate){const u=le(o.minDate);u&&d<u.getFullYear()&&(d=u.getFullYear())}e.viewMonth=0,e.viewYear=d,e.focusedDate=new Date(d,0,1)}else e.focusedDate=new Date(e.viewYear,e.viewMonth,1);return!0}if(r==="End"){if(t.preventDefault(),t.ctrlKey||t.metaKey){let d=e.viewYear;const c=new Date(d,11,31);if(e.focusedDate&&at(e.focusedDate,c)&&d++,o.maxDate){const u=le(o.maxDate);u&&d>u.getFullYear()&&(d=u.getFullYear())}e.viewMonth=11,e.viewYear=d,e.focusedDate=new Date(d,11,31)}else{const d=Ze(e.viewYear,e.viewMonth);e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}if(r==="PageUp"){if(t.preventDefault(),ro(e),e.focusedDate){const d=Math.min(e.focusedDate.getDate(),Ze(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}if(r==="PageDown"){if(t.preventDefault(),no(e),e.focusedDate){const d=Math.min(e.focusedDate.getDate(),Ze(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}return!1}function Cn(t,e,o){if(!t.focusedDate){t.focusedDate=t.selectedDate?new Date(t.selectedDate):new Date(t.viewYear,t.viewMonth,1);return}const i=new Date(t.focusedDate),r=o.minDate?le(o.minDate):null,s=o.maxDate?le(o.maxDate):null;switch(e){case"ArrowLeft":i.setDate(i.getDate()-1);break;case"ArrowRight":i.setDate(i.getDate()+1);break;case"ArrowUp":i.setDate(i.getDate()-7);break;case"ArrowDown":i.setDate(i.getDate()+7);break}r&&i<r||s&&i>s||(t.focusedDate=i,(i.getMonth()!==t.viewMonth||i.getFullYear()!==t.viewYear)&&(t.viewMonth=i.getMonth(),t.viewYear=i.getFullYear()))}function Sn(t,e){const{key:o}=t;if(o==="ArrowUp"||o==="ArrowDown"){t.preventDefault();const i=o==="ArrowUp"?-1:1;if(e.rollingSelectorMode==="month"){const r=e.viewMonth+i;r>=0&&r<=11&&(e.viewMonth=r)}else e.viewYear+=i;return!0}return o==="ArrowLeft"||o==="ArrowRight"?(t.preventDefault(),e.rollingSelectorMode=e.rollingSelectorMode==="month"?"year":"month",!0):o==="Enter"||o==="Escape"?(t.preventDefault(),e.rollingSelectorOpen=!1,!0):!1}function xn(t){if(t.selectedDate)t.focusedDate=new Date(t.selectedDate),t.viewYear=t.selectedDate.getFullYear(),t.viewMonth=t.selectedDate.getMonth();else{const e=new Date;t.focusedDate=new Date(t.viewYear,t.viewMonth,e.getDate())}}function kn(t,e,o){const i=t.dataset.date;if(!i||t.classList.contains("wg-datepicker__day--disabled"))return null;const[r,s,n]=i.split("-").map(Number),l=new Date(r,s-1,n),a=o.minDate?le(o.minDate):null,d=o.maxDate?le(o.maxDate):null;return a&&l<a||d&&l>d?null:(e.selectedDate=l,e.focusedDate=l,l)}function In(t,e){const o=new Date;o.setHours(0,0,0,0);const i=e.minDate?le(e.minDate):null,r=e.maxDate?le(e.maxDate):null;return i&&o<i||r&&o>r?null:(t.selectedDate=o,t.focusedDate=o,t.viewYear=o.getFullYear(),t.viewMonth=o.getMonth(),o)}function En(t,e){const o=t.dataset.month;o!==void 0&&(e.viewMonth=parseInt(o,10))}function Rn(t,e){const o=t.dataset.year;o!==void 0&&(e.viewYear=parseInt(o,10))}function so(t,e){var u,h,g,f;const{separator:o,parts:i,maxLength:r}=e,s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=t.replace(new RegExp(s,"g"),""),l=((u=i.year)==null?void 0:u.length)??4,a=[{type:"year",pos:((h=i.year)==null?void 0:h.index)??0,length:l},{type:"month",pos:((g=i.month)==null?void 0:g.index)??1,length:2},{type:"day",pos:((f=i.day)==null?void 0:f.index)??2,length:2}].sort((w,p)=>w.pos-p.pos);let d="",c=0;for(let w=0;w<a.length;w++){const p=a[w],m=n.substring(c,c+p.length);if(!m)break;d+=m,c+=m.length,w<a.length-1&&m.length===p.length&&(d+=o)}return d.substring(0,r)}function Dn(t,e,o){const i=t.value,r=t.selectionStart||0,s=i.length<o.length,{separator:n}=e,l=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=i.replace(new RegExp(`[^0-9${l}]`,"g"),""),d=so(a,e);if(d!==i){t.value=d;let c=r;if(s)c=r;else if(d.length>i.length&&d[r]===n)c=r+1;else if(d.length>i.length){const u=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=(i.substring(0,r).match(new RegExp(u,"g"))||[]).length,f=(d.substring(0,r).match(new RegExp(u,"g"))||[]).length-h;c=r+f}t.setSelectionRange(c,c)}return d}function Tn(t,e){const{key:o,ctrlKey:i,metaKey:r}=t,{separator:s}=e;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(o)||i||r)return!1;if(o===s){const l=t.target,a=l.selectionStart||0,d=l.value;let c=0;for(let h=a-1;h>=0;h--)if(d[h]===s){c=h+1;break}const u=d.substring(c,a);if(/^\d$/.test(u)){t.preventDefault();const h=d.substring(0,c)+"0"+u+s+d.substring(a);l.value=h;const g=c+2+s.length;return l.setSelectionRange(g,g),!0}}return!/^\d$/.test(o)&&o!==s?(t.preventDefault(),!0):!1}function Mn(t,e,o){var g;t.preventDefault();const i=((g=t.clipboardData)==null?void 0:g.getData("text"))||"",{separator:r}=o,s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=i.replace(new RegExp(`[^0-9${s}]`,"g"),""),l=so(n,o),a=e.selectionStart||0,d=e.selectionEnd||0,c=e.value,u=c.substring(0,a)+l+c.substring(d);e.value=so(u,o);const h=a+l.length;e.setSelectionRange(h,h)}function $n(t,e,o,i){if(!t||t.length<e.maxLength)return!1;const r=sn(t,e);if(!r)return!1;const s=i.minDate?le(i.minDate):null,n=i.maxDate?le(i.maxDate):null;return s&&r<s||n&&r>n?!1:(o.selectedDate=r,o.focusedDate=r,o.viewYear=r.getFullYear(),o.viewMonth=r.getMonth(),!0)}const Pn=`
47
47
  .wg-datepicker-container {
48
48
  position: fixed;
49
49
  z-index: var(--wg-dp-z-index, 9999);
@@ -293,245 +293,245 @@
293
293
  .wg-datepicker__today-btn:hover {
294
294
  background-color: color-mix(in srgb, var(--wg-dp-accent-color) 10%, transparent);
295
295
  }
296
- `;let Yo=!1;class Dt{constructor(t={}){b(this,"options");b(this,"state");b(this,"localeStrings");b(this,"formatInfo");b(this,"element",null);b(this,"anchor",null);b(this,"input",null);b(this,"cleanupAutoUpdate",null);b(this,"previousInputValue","");b(this,"boundHandleClickOutside");b(this,"boundHandleKeyDown");this.options={dateFormat:"YYYY-MM-DD",showTodayButton:!0,...t};const o=new Date;this.state={viewMonth:o.getMonth(),viewYear:o.getFullYear(),selectedDate:null,isOpen:!1,rollingSelectorOpen:!1,rollingSelectorMode:"month",focusedDate:null},this.localeStrings=this.initLocaleStrings(t.locale),this.formatInfo=Et(this.options.dateFormat||"YYYY-MM-DD"),this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}initLocaleStrings(t){const o=t||navigator.language||"en";try{const i=new Intl.DateTimeFormat(o,{month:"long"}),r=new Intl.DateTimeFormat(o,{month:"short"}),s=new Intl.DateTimeFormat(o,{weekday:"long"}),n=new Intl.DateTimeFormat(o,{weekday:"short"}),l=[],a=[];for(let u=0;u<12;u++){const g=new Date(2024,u,1);l.push(i.format(g)),a.push(r.format(g))}const d=[],c=[];for(let u=0;u<7;u++){const g=new Date(2024,0,7+u);d.push(s.format(g));const h=n.format(g);c.push(h.substring(0,2))}return{today:"Today",clear:"Clear",monthNames:l,monthNamesShort:a,weekdayNames:d,weekdayNamesShort:c}}catch{return No}}static injectStyles(){if(Yo)return;const t=document.createElement("style");t.id="wg-datepicker-styles",t.textContent=En,document.head.appendChild(t),Yo=!0}open(t,o=null){Dt.injectStyles(),this.state.isOpen&&this.close(),this.anchor=t;const i=ne(o);if(i)this.state.selectedDate=i,this.state.viewYear=i.getFullYear(),this.state.viewMonth=i.getMonth();else{const r=new Date;this.state.viewYear=r.getFullYear(),this.state.viewMonth=r.getMonth()}bn(this.state),this.element=document.createElement("div"),this.element.className="wg-datepicker-container",this.element.innerHTML=rn(this.state,this.options,this.localeStrings),document.body.appendChild(this.element),this.position(),this.attachListeners(),this.state.isOpen=!0,this.state.rollingSelectorOpen&&Wo(this.element)}close(t=!1){var o,i;this.state.isOpen&&(this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),document.removeEventListener("mousedown",this.boundHandleClickOutside),document.removeEventListener("keydown",this.boundHandleKeyDown),this.element&&(this.element.remove(),this.element=null),this.state.isOpen=!1,this.state.rollingSelectorOpen=!1,t||(i=(o=this.options).onClose)==null||i.call(o))}destroy(){this.close(),this.anchor=null,this.input=null}getSelectedDate(){return this.state.selectedDate}getFormattedValue(){return Zt(this.state.selectedDate,this.formatInfo)}position(){if(!this.element||!this.anchor)return;const t=this.element.querySelector(".wg-datepicker");t&&(this.cleanupAutoUpdate=Gr(this.anchor,t,()=>{if(!this.anchor.isConnected){this.close(!0);return}qe(this.anchor,t,{placement:"bottom-start",middleware:[Rt(4),Ve({fallbackPlacements:["top-start","bottom-end","top-end"]}),rt({padding:8})]}).then(({x:o,y:i})=>{Object.assign(t.style,{left:`${o}px`,top:`${i}px`})})}))}attachListeners(){this.element&&(this.element.addEventListener("click",t=>this.handleClick(t)),setTimeout(()=>{document.addEventListener("mousedown",this.boundHandleClickOutside)},0),document.addEventListener("keydown",this.boundHandleKeyDown))}handleClick(t){var l;const o=t.target,i=(l=o.closest("[data-action]"))==null?void 0:l.getAttribute("data-action");if(i==="prev-month"){t.preventDefault(),eo(this.state),this.render();return}if(i==="next-month"){t.preventDefault(),to(this.state),this.render();return}if(i==="toggle-rolling"){t.preventDefault(),this.state.rollingSelectorOpen=!this.state.rollingSelectorOpen,this.render(),this.state.rollingSelectorOpen&&this.element&&Wo(this.element);return}if(i==="today"){t.preventDefault();const a=vn(this.state,this.options);a&&this.selectDate(a);return}const r=o.closest(".wg-datepicker__day");if(r){t.preventDefault();const a=_n(r,this.state,this.options);a&&this.selectDate(a);return}const s=o.closest("[data-month]");if(s&&this.state.rollingSelectorOpen){t.preventDefault(),yn(s,this.state),this.render();return}const n=o.closest("[data-year]");if(n&&this.state.rollingSelectorOpen){t.preventDefault(),Cn(n,this.state),this.render();return}}handleClickOutside(t){if(!this.element||!this.anchor)return;const o=t.composedPath();!o.includes(this.element)&&!o.includes(this.anchor)&&this.close()}handleKeyDown(t){wn(t,this.state,this.options,{onSelect:(i,r)=>this.selectDate(i,r),onClose:()=>this.close()})&&this.render()}selectDate(t,o){var i,r;this.state.selectedDate=t,(r=(i=this.options).onSelect)==null||r.call(i,t,o),this.close(!0)}render(){if(!this.element)return;const t=this.element.querySelector(".wg-datepicker");t&&(un(t,this.state,this.localeStrings),hn(t,this.state.rollingSelectorOpen),this.state.rollingSelectorOpen?fn(t,this.state):gn(t,this.state,this.options))}connectInput(t){this.input=t,this.previousInputValue=t.value,t.addEventListener("input",()=>{this.previousInputValue=Sn(t,this.formatInfo,this.previousInputValue),Rn(t.value,this.formatInfo,this.state,this.options)}),t.addEventListener("keydown",o=>{xn(o,this.formatInfo)}),t.addEventListener("paste",o=>{kn(o,t,this.formatInfo)}),t.addEventListener("focus",()=>{!this.state.isOpen&&this.anchor&&this.open(this.anchor,t.value)})}}var Uo=function(){},he="undefined",In=typeof window!==he&&typeof window.navigator!==he&&/Trident\/|MSIE /.test(window.navigator.userAgent),io=["trace","debug","info","warn","error"],st={},N=null;function Ko(e,t){var o=e[t];if(typeof o.bind=="function")return o.bind(e);try{return Function.prototype.bind.call(o,e)}catch{return function(){return Function.prototype.apply.apply(o,[e,arguments])}}}function Dn(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function Tn(e){return e==="debug"&&(e="log"),typeof console===he?!1:e==="trace"&&In?Dn:console[e]!==void 0?Ko(console,e):console.log!==void 0?Ko(console,"log"):Uo}function lt(){for(var e=this.getLevel(),t=0;t<io.length;t++){var o=io[t];this[o]=t<e?Uo:this.methodFactory(o,e,this.name)}if(this.log=this.debug,typeof console===he&&e<this.levels.SILENT)return"No console available for logging"}function Mn(e){return function(){typeof console!==he&&(lt.call(this),this[e].apply(this,arguments))}}function $n(e,t,o){return Tn(e)||Mn.apply(this,arguments)}function jo(e,t){var o=this,i,r,s,n="loglevel";typeof e=="string"?n+=":"+e:typeof e=="symbol"&&(n=void 0);function l(g){var h=(io[g]||"silent").toUpperCase();if(!(typeof window===he||!n)){try{window.localStorage[n]=h;return}catch{}try{window.document.cookie=encodeURIComponent(n)+"="+h+";"}catch{}}}function a(){var g;if(!(typeof window===he||!n)){try{g=window.localStorage[n]}catch{}if(typeof g===he)try{var h=window.document.cookie,f=encodeURIComponent(n),w=h.indexOf(f+"=");w!==-1&&(g=/^([^;]+)/.exec(h.slice(w+f.length+1))[1])}catch{}return o.levels[g]===void 0&&(g=void 0),g}}function d(){if(!(typeof window===he||!n)){try{window.localStorage.removeItem(n)}catch{}try{window.document.cookie=encodeURIComponent(n)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function c(g){var h=g;if(typeof h=="string"&&o.levels[h.toUpperCase()]!==void 0&&(h=o.levels[h.toUpperCase()]),typeof h=="number"&&h>=0&&h<=o.levels.SILENT)return h;throw new TypeError("log.setLevel() called with invalid level: "+g)}o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=t||$n,o.getLevel=function(){return s??r??i},o.setLevel=function(g,h){return s=c(g),h!==!1&&l(s),lt.call(o)},o.setDefaultLevel=function(g){r=c(g),a()||o.setLevel(g,!1)},o.resetLevel=function(){s=null,d(),lt.call(o)},o.enableAll=function(g){o.setLevel(o.levels.TRACE,g)},o.disableAll=function(g){o.setLevel(o.levels.SILENT,g)},o.rebuild=function(){if(N!==o&&(i=c(N.getLevel())),lt.call(o),N===o)for(var g in st)st[g].rebuild()},i=c(N?N.getLevel():"WARN");var u=a();u!=null&&(s=c(u)),lt.call(o)}N=new jo,N.getLogger=function(t){if(typeof t!="symbol"&&typeof t!="string"||t==="")throw new TypeError("You must supply a name when creating a logger.");var o=st[t];return o||(o=st[t]=new jo(t,N.methodFactory)),o};var An=typeof window!==he?window.log:void 0;N.noConflict=function(){return typeof window!==he&&window.log===N&&(window.log=An),N},N.getLoggers=function(){return st},N.default=N;var Ln=function(e){for(var t=1,o=arguments.length,i;t<o;t++)for(i in arguments[t])Object.prototype.hasOwnProperty.call(arguments[t],i)&&(e[i]=arguments[t][i]);return e},zn={template:"[%t] %l:",levelFormatter:function(e){return e.toUpperCase()},nameFormatter:function(e){return e||"root"},timestampFormatter:function(e){return e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},Xo,Ne={},Pn=function(e){if(!e||!e.getLogger)throw new TypeError("Argument is not a root logger");Xo=e},On=function(e,t){if(!e||!e.setLevel)throw new TypeError("Argument is not a logger");var o=e.methodFactory,i=e.name||"",r=Ne[i]||Ne[""]||zn;function s(n,l,a){var d=o(n,l,a),c=Ne[a]||Ne[""],u=c.template.indexOf("%t")!==-1,g=c.template.indexOf("%l")!==-1,h=c.template.indexOf("%n")!==-1;return function(){for(var f="",w=arguments.length,p=Array(w),m=0;m<w;m++)p[m]=arguments[m];if(i||!Ne[a]){var v=c.timestampFormatter(new Date),y=c.levelFormatter(n),x=c.nameFormatter(a);c.format?f+=c.format(y,x,v):(f+=c.template,u&&(f=f.replace(/%t/,v)),g&&(f=f.replace(/%l/,y)),h&&(f=f.replace(/%n/,x))),p.length&&typeof p[0]=="string"?p[0]=f+" "+p[0]:p.unshift(f)}d.apply(void 0,p)}}return Ne[i]||(e.methodFactory=s),t=t||{},t.template&&(t.format=void 0),Ne[i]=Ln({},r,t),e.setLevel(e.getLevel()),Xo||e.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),e},Go={reg:Pn,apply:On};const Qo={debug:"#0ea5e9",info:"#10b981",warn:"#f59e0b",error:"#ef4444"};Go.reg(N),Go.apply(N,{format(e,t,o){return Qo[e.toLowerCase()],`%c[${o}]%c %c[${e}]%c ${t?`%c[${t}]%c `:""}`},timestampFormatter(e){return e.toTimeString().split(" ")[0]+"."+e.getMilliseconds().toString().padStart(3,"0")}});const Hn=N.methodFactory;N.methodFactory=function(e,t,o){const i=Hn(e,t,o);return function(...r){if(r.length>0&&typeof r[0]=="string"&&r[0].includes("%c")){const s=Qo[e]||"#666",n=[r[0],`color: ${s}; font-weight: bold;`,"color: inherit;",`color: ${s}; font-weight: bold;`,"color: inherit;",...o?[`color: ${s}; font-weight: bold;`,"color: inherit;"]:[],...r.slice(1)];i(...n)}else i(...r)}},N.setLevel("silent");const ro=N.getLogger("GRID:INIT"),at=N.getLogger("GRID:DATA"),Jo=N.getLogger("GRID:UI"),dt=N.getLogger("GRID:INTERACTION"),Fn=["GRID:INIT","GRID:DATA","GRID:UI","GRID:INTERACTION"];function Vn(){N.setLevel("debug")}function qn(){N.setLevel("silent")}function Nn(e){N.setLevel(e)}function Bn(e,t){N.getLogger(e).setLevel(t)}const Zo={rowActions:"Row actions",inlineActionsHeader:"Actions",keyboardShortcuts:"Keyboard shortcuts",paginationFirst:"⏮",paginationPrevious:"◀",paginationNext:"▶",paginationLast:"⏭",paginationPageInfo:"Page {current} of {total}",paginationItemCount:"{count} items",paginationPerPage:"per page",dropdownNoOptions:"No options",dropdownSearching:"Searching...",contextMenu:{sortAsc:"Sort Ascending",sortDesc:"Sort Descending",clearSort:"Clear Sort",hideColumn:"Hide Column",freezeColumn:"Freeze Column",unfreezeColumn:"Unfreeze Column",columnVisibility:"Column Visibility",showAll:"Show all"}};class ei{constructor(){b(this,"_items",[]);b(this,"_columns",[]);b(this,"_sortMode","none");b(this,"_isFilterable",!1);b(this,"_isPageable",!1);b(this,"_pageSize",10);b(this,"_pageSizes",[10,25,50,100]);b(this,"_paginationMode","client");b(this,"_isStriped",!0);b(this,"_isHoverable",!0);b(this,"_isEditable",!1);b(this,"_editTrigger","dblclick");b(this,"_editStartSelection","mousePosition");b(this,"_mode","excel");b(this,"_dropdownToggleVisibility","always");b(this,"_shouldShowDropdownOnFocus",!0);b(this,"_shouldOpenDropdownOnEnter",!1);b(this,"_isCheckboxAlwaysEditable",!1);b(this,"_isRowNumbersVisible",!1);b(this,"_isStickyRowNumbers",!1);b(this,"_freezeColumns",0);b(this,"_invalidCells",[]);b(this,"_isDirtyIndicatorVisible",!0);b(this,"_isRowToolbarVisible",!1);b(this,"_rowToolbar",["add","delete","duplicate"]);b(this,"_toolbarVerticalAlign","bottom");b(this,"_toolbarHorizontalAlign","center");b(this,"_toolbarTrigger","hover");b(this,"_toolbarPosition","auto");b(this,"_toolbarColumn");b(this,"_toolbarFollowsCursor",!1);b(this,"_cellToolbar");b(this,"_cellToolbarOffset",.2);b(this,"_toolbarBtnMinWidth");b(this,"_inlineActionsTitle","");b(this,"_contextMenu");b(this,"_contextMenuXOffset",8);b(this,"_contextMenuYOffset",0);b(this,"_headerContextMenu");b(this,"_rowShortcuts");b(this,"_isShortcutsHelpVisible",!1);b(this,"_shortcutsHelpPosition","top-right");b(this,"_shortcutsHelpContentCallback");b(this,"_idValueMember");b(this,"_idValueCallback");b(this,"_rowLocking");b(this,"_externalLocks",new Map);b(this,"_onrowlockchange");b(this,"_gridName",null);b(this,"_shouldPersistColumnWidths",!1);b(this,"_columnWidths",new Map);b(this,"_oncolumnresize");b(this,"_isColumnReorderAllowed",!1);b(this,"_shouldPersistColumnOrder",!1);b(this,"_columnOrder",new Map);b(this,"_oncolumnreorder");b(this,"_fillDirection","vertical");b(this,"_fillDragCallback");b(this,"_onrowchange");b(this,"_onroweditstart");b(this,"_onroweditcancel");b(this,"_onvalidationerror");b(this,"_validationTooltipCallback");b(this,"_ontoolbarclick");b(this,"_onrowaction");b(this,"_oncontextmenuopen");b(this,"_onheadercontextmenuopen");b(this,"_ondatarequest");b(this,"_onrowdelete");b(this,"_sort",[]);b(this,"_filters",{});b(this,"_currentPage",1);b(this,"_totalItems",null);b(this,"_showPagination",!0);b(this,"_paginationPosition","bottom-center");b(this,"_paginationLabelsCallback");b(this,"_paginationLayout","pageSize|previous|pageInfo|next");b(this,"_summaryPosition");b(this,"_summaryContentCallback");b(this,"_summaryMetadata");b(this,"_isSummaryInline",!0);b(this,"_customStylesCallback");b(this,"_rowClassCallback");b(this,"_labels",{...Zo});b(this,"_isScrollable",!1);b(this,"_scrollMaxHeight","100vh");b(this,"_tableBorderOnly",!1);b(this,"_isVirtualScrollEnabled",!1);b(this,"_virtualScrollThreshold",100);b(this,"_virtualScrollRowHeight",38);b(this,"_virtualScrollBuffer",10);b(this,"_isInfiniteScrollEnabled",!1);b(this,"_infiniteScrollThreshold",100);b(this,"_hasMoreItems",!0);b(this,"_isLoadingMore",!1);b(this,"_editingCell",null);b(this,"_currentCellError",null);b(this,"_isValidating",!1);b(this,"_draftRows",new Map);b(this,"_focusedCell",null);b(this,"_isCommittingFromKeyboard",!1);b(this,"_skipNextDropdownAutoEdit",!1);b(this,"_tabTraversalStartColIndex",null);b(this,"_hoveredRowIndex",null);b(this,"_focusedRowIndex",null);b(this,"_onrowfocus");b(this,"_onInteractionChange",null);b(this,"_selectedRows",new Set);b(this,"_lastSelectedRowIndex",null);b(this,"_rangeShortcuts",[]);b(this,"_cellSelectionMode","click");b(this,"_selectedCellRange",null);b(this,"_lastClickedCell",null);b(this,"_shouldCopyWithHeaders",!1);b(this,"_oncellselectionchange",null);b(this,"_selectedColumns",new Set);b(this,"_lastSelectedColumnIndex",-1);b(this,"_pasteMode","skip-non-editable");b(this,"_shouldValidateOnPaste",!0);b(this,"_createRowCallback");b(this,"_onbeforepaste");b(this,"_onpaste");b(this,"_isNewRowEnabled",!1);b(this,"_newRowPosition","bottom");b(this,"_newRowIndicator","+");b(this,"_createEmptyRowCallback");b(this,"_emptyRowDraft",null)}get items(){return this._items}set items(t){at.debug("items set:",t.length,"rows"),this._items=t,this.requestUpdate()}get columns(){return this._columns}set columns(t){ro.debug("columns set:",t.length,"columns",t.map(o=>String(o.field))),this._columns=t,this.requestUpdate()}get sortMode(){return this._sortMode}set sortMode(t){this._sortMode=t,this.requestUpdate()}get isFilterable(){return this._isFilterable}set isFilterable(t){this._isFilterable=t,this.requestUpdate()}get isPageable(){return this._isPageable}set isPageable(t){this._isPageable=t,this.requestUpdate()}get pageSize(){return this._pageSize}set pageSize(t){this._pageSize=t,this.requestUpdate()}get pageSizes(){return this._pageSizes}set pageSizes(t){this._pageSizes=t,this.requestUpdate()}get paginationMode(){return this._paginationMode}set paginationMode(t){this._paginationMode=t,this.requestUpdate()}get isStriped(){return this._isStriped}set isStriped(t){this._isStriped=t,this.requestUpdate()}get isHoverable(){return this._isHoverable}set isHoverable(t){this._isHoverable=t,this.requestUpdate()}get isEditable(){return this._isEditable}set isEditable(t){this._isEditable=t,this.checkEditTriggerConflicts(),this.requestUpdate()}get editTrigger(){return this._editTrigger}set editTrigger(t){this._editTrigger=t,this.checkSelectionConflicts(),this.checkEditTriggerConflicts(),this.requestUpdate()}get editStartSelection(){return this._editStartSelection}set editStartSelection(t){this._editStartSelection=t}get mode(){return this._mode}set mode(t){this._mode=t,this.applyModeDefaults(),this.checkEditTriggerConflicts(),this.requestUpdate()}get dropdownToggleVisibility(){return this._dropdownToggleVisibility}set dropdownToggleVisibility(t){this._dropdownToggleVisibility=t,this.requestUpdate()}getEffectiveToggleVisibility(t){return t.dropdownToggleVisibility??this._dropdownToggleVisibility}get shouldShowDropdownOnFocus(){return this._shouldShowDropdownOnFocus}set shouldShowDropdownOnFocus(t){this._shouldShowDropdownOnFocus=t}get shouldOpenDropdownOnEnter(){return this._shouldOpenDropdownOnEnter}set shouldOpenDropdownOnEnter(t){this._shouldOpenDropdownOnEnter=t}getEffectiveShouldOpenDropdownOnEnter(t){return t.shouldOpenDropdownOnEnter??this._shouldOpenDropdownOnEnter}get isCheckboxAlwaysEditable(){return this._isCheckboxAlwaysEditable}set isCheckboxAlwaysEditable(t){this._isCheckboxAlwaysEditable=t,this.requestUpdate()}get isRowNumbersVisible(){return this._isRowNumbersVisible}set isRowNumbersVisible(t){this._isRowNumbersVisible=t,this.requestUpdate()}get isDirtyIndicatorVisible(){return this._isDirtyIndicatorVisible}set isDirtyIndicatorVisible(t){this._isDirtyIndicatorVisible=t,this.requestUpdate()}get isStickyRowNumbers(){return this._isStickyRowNumbers}set isStickyRowNumbers(t){this._isStickyRowNumbers=t,this.requestUpdate()}get freezeColumns(){return this._freezeColumns}set freezeColumns(t){this._freezeColumns=Math.max(0,Math.floor(t)),this.requestUpdate()}get visualColumns(){const t=[],o=[];this._columns.filter(s=>s.isFrozen&&!s.isHidden).length,this._columns.forEach((s,n)=>{if(s.isHidden)return;const l={column:s,originalIndex:n};s.isFrozen?t.push(l):o.push(l)});const i=[],r=[];return o.forEach((s,n)=>{n<this._freezeColumns?i.push(s):r.push(s)}),this._columnOrder.size>0&&r.sort((s,n)=>{const l=String(s.column.field),a=String(n.column.field),d=this._columnOrder.get(l)??s.originalIndex,c=this._columnOrder.get(a)??n.originalIndex;return d-c}),[...t,...i,...r]}get totalFrozenColumns(){return this._columns.filter(o=>o.isFrozen).length+this._freezeColumns}isColumnFrozen(t){return t<this.totalFrozenColumns}get invalidCells(){return this._invalidCells}set invalidCells(t){this._invalidCells=t,this.requestUpdate()}get editingCell(){return this._editingCell}get isValidating(){return this._isValidating}get currentCellError(){return this._currentCellError}get hoveredRowIndex(){return this._hoveredRowIndex}get isRowToolbarVisible(){return this._isRowToolbarVisible}set isRowToolbarVisible(t){this._isRowToolbarVisible=t,this.requestUpdate()}get rowToolbar(){return this._rowToolbar}set rowToolbar(t){this._rowToolbar=t,this.requestUpdate()}get toolbarVerticalAlign(){return this._toolbarVerticalAlign}set toolbarVerticalAlign(t){this._toolbarVerticalAlign=t,this.checkToolbarConflicts(),this.requestUpdate()}get toolbarHorizontalAlign(){return this._toolbarHorizontalAlign}set toolbarHorizontalAlign(t){this._toolbarHorizontalAlign=t,this.checkToolbarConflicts(),this.requestUpdate()}get toolbarAlign(){return this._toolbarVerticalAlign}set toolbarAlign(t){this.toolbarVerticalAlign=t}get toolbarTopPosition(){return this._toolbarHorizontalAlign}set toolbarTopPosition(t){this.toolbarHorizontalAlign=t}get toolbarTrigger(){return this._toolbarTrigger}set toolbarTrigger(t){this._toolbarTrigger=t,this.requestUpdate()}get toolbarPosition(){return this._toolbarPosition}set toolbarPosition(t){this._toolbarPosition=t,this.checkToolbarConflicts(),this.requestUpdate()}get toolbarColumn(){return this._toolbarColumn}set toolbarColumn(t){this._toolbarColumn=t,this.checkToolbarConflicts()}get toolbarFollowsCursor(){return this._toolbarFollowsCursor}set toolbarFollowsCursor(t){this._toolbarFollowsCursor=t,this.checkToolbarConflicts()}get cellToolbar(){return this._cellToolbar}set cellToolbar(t){this._cellToolbar=t,this.checkToolbarConflicts()}get cellToolbarOffset(){return this._cellToolbarOffset}set cellToolbarOffset(t){typeof t=="number"?this._cellToolbarOffset=Math.max(0,Math.min(1,t)):this._cellToolbarOffset=t}get toolbarBtnMinWidth(){return this._toolbarBtnMinWidth}set toolbarBtnMinWidth(t){this._toolbarBtnMinWidth=t}get inlineActionsTitle(){return this._inlineActionsTitle}set inlineActionsTitle(t){this._inlineActionsTitle=t,this.requestUpdate()}get contextMenu(){return this._contextMenu}set contextMenu(t){this._contextMenu=t,this.requestUpdate()}get contextMenuXOffset(){return this._contextMenuXOffset}set contextMenuXOffset(t){this._contextMenuXOffset=t}get contextMenuYOffset(){return this._contextMenuYOffset}set contextMenuYOffset(t){this._contextMenuYOffset=t}get headerContextMenu(){return this._headerContextMenu}set headerContextMenu(t){this._headerContextMenu=t}get rowShortcuts(){return this._rowShortcuts}set rowShortcuts(t){this._rowShortcuts=t,this.requestUpdate()}get isShortcutsHelpVisible(){return this._isShortcutsHelpVisible}set isShortcutsHelpVisible(t){this._isShortcutsHelpVisible=t,this.requestUpdate()}get shortcutsHelpPosition(){return this._shortcutsHelpPosition}set shortcutsHelpPosition(t){this._shortcutsHelpPosition=t,this.requestUpdate()}get shortcutsHelpContentCallback(){return this._shortcutsHelpContentCallback}set shortcutsHelpContentCallback(t){this._shortcutsHelpContentCallback=t,this.requestUpdate()}get sort(){return this._sort}set sort(t){at.debug("sort changed:",t.map(o=>`${o.column} ${o.direction}`).join(", ")||"none"),this._sort=t,this.requestUpdate()}get currentPage(){return this._currentPage}set currentPage(t){at.debug("page changed:",t),this._currentPage=t,this.requestUpdate()}get totalItems(){return this._totalItems}set totalItems(t){this._totalItems=t,this.requestUpdate()}get showPagination(){return this._showPagination}set showPagination(t){this._showPagination=t,this.requestUpdate()}get paginationPosition(){return this._paginationPosition}set paginationPosition(t){this._paginationPosition=t,this.requestUpdate()}get paginationLabelsCallback(){return this._paginationLabelsCallback}set paginationLabelsCallback(t){this._paginationLabelsCallback=t,this.requestUpdate()}get paginationLayout(){return this._paginationLayout}set paginationLayout(t){this._paginationLayout=t,this.requestUpdate()}get summaryPosition(){return this._summaryPosition}set summaryPosition(t){this._summaryPosition=t,this.requestUpdate()}get summaryContentCallback(){return this._summaryContentCallback}set summaryContentCallback(t){this._summaryContentCallback=t,this.requestUpdate()}get summaryMetadata(){return this._summaryMetadata}set summaryMetadata(t){this._summaryMetadata=t,this.requestUpdate()}get isSummaryInline(){return this._isSummaryInline}set isSummaryInline(t){this._isSummaryInline=t,this.requestUpdate()}get customStylesCallback(){return this._customStylesCallback}set customStylesCallback(t){this._customStylesCallback=t}get rowClassCallback(){return this._rowClassCallback}set rowClassCallback(t){this._rowClassCallback=t,this.requestUpdate()}get labels(){return this._labels}set labels(t){this._labels={...Zo,...t},this.requestUpdate()}get isScrollable(){return this._isScrollable}set isScrollable(t){this._isScrollable=t,this.requestUpdate()}get scrollMaxHeight(){return this._scrollMaxHeight}set scrollMaxHeight(t){this._scrollMaxHeight=t,this.requestUpdate()}get tableBorderOnly(){return this._tableBorderOnly}set tableBorderOnly(t){this._tableBorderOnly=t,this.requestUpdate()}get isVirtualScrollEnabled(){return this._isVirtualScrollEnabled}set isVirtualScrollEnabled(t){this._isVirtualScrollEnabled=t,this.requestUpdate()}get virtualScrollThreshold(){return this._virtualScrollThreshold}set virtualScrollThreshold(t){this._virtualScrollThreshold=t,this.requestUpdate()}get virtualScrollRowHeight(){return this._virtualScrollRowHeight}set virtualScrollRowHeight(t){this._virtualScrollRowHeight=t,this.requestUpdate()}get virtualScrollBuffer(){return this._virtualScrollBuffer}set virtualScrollBuffer(t){this._virtualScrollBuffer=t,this.requestUpdate()}get isInfiniteScrollEnabled(){return this._isInfiniteScrollEnabled}set isInfiniteScrollEnabled(t){this._isInfiniteScrollEnabled=t,this.requestUpdate()}get infiniteScrollThreshold(){return this._infiniteScrollThreshold}set infiniteScrollThreshold(t){this._infiniteScrollThreshold=t}get hasMoreItems(){return this._hasMoreItems}set hasMoreItems(t){this._hasMoreItems=t}get isLoadingMore(){return this._isLoadingMore}set isLoadingMore(t){this._isLoadingMore=t}shouldUseVirtualScroll(){return this._isVirtualScrollEnabled===!1?!1:this._isVirtualScrollEnabled===!0?!0:this.displayItems.length>=this._virtualScrollThreshold}set onrowchange(t){this._onrowchange=t}set onroweditstart(t){this._onroweditstart=t}set onroweditcancel(t){this._onroweditcancel=t}set onvalidationerror(t){this._onvalidationerror=t}get validationTooltipCallback(){return this._validationTooltipCallback}set validationTooltipCallback(t){this._validationTooltipCallback=t}get ontoolbarclick(){return this._ontoolbarclick}set ontoolbarclick(t){this._ontoolbarclick=t}set onrowaction(t){this._onrowaction=t}set oncontextmenuopen(t){this._oncontextmenuopen=t}get onheadercontextmenuopen(){return this._onheadercontextmenuopen}set onheadercontextmenuopen(t){this._onheadercontextmenuopen=t}get ondatarequest(){return this._ondatarequest}set ondatarequest(t){this._ondatarequest=t}get onrowdelete(){return this._onrowdelete}set onrowdelete(t){this._onrowdelete=t}get idValueMember(){return this._idValueMember}set idValueMember(t){this._idValueMember=t}get idValueCallback(){return this._idValueCallback}set idValueCallback(t){this._idValueCallback=t}get rowLocking(){return this._rowLocking}set rowLocking(t){this._rowLocking=t,this.requestUpdate()}get onrowlockchange(){return this._onrowlockchange}set onrowlockchange(t){this._onrowlockchange=t}get gridName(){return this._gridName}set gridName(t){this._gridName=t}get shouldPersistColumnWidths(){return this._shouldPersistColumnWidths}set shouldPersistColumnWidths(t){this._shouldPersistColumnWidths=t}get oncolumnresize(){return this._oncolumnresize}set oncolumnresize(t){this._oncolumnresize=t}get isColumnReorderAllowed(){return this._isColumnReorderAllowed}set isColumnReorderAllowed(t){this._isColumnReorderAllowed=t}get shouldPersistColumnOrder(){return this._shouldPersistColumnOrder}set shouldPersistColumnOrder(t){this._shouldPersistColumnOrder=t}get oncolumnreorder(){return this._oncolumnreorder}set oncolumnreorder(t){this._oncolumnreorder=t}get fillDirection(){return this._fillDirection}set fillDirection(t){this._fillDirection=t}get fillDragCallback(){return this._fillDragCallback}set fillDragCallback(t){this._fillDragCallback=t}get selectedRows(){return Array.from(this._selectedRows).sort((t,o)=>t-o)}get rangeShortcuts(){return this._rangeShortcuts}set rangeShortcuts(t){this._rangeShortcuts=t}isRowSelected(t){return this._selectedRows.has(t)}selectRow(t,o="replace"){switch(dt.debug("selectRow:",{rowIndex:t,mode:o}),this._selectedCellRange&&(this._selectedCellRange=null),this._selectedColumns.clear(),o){case"replace":this._selectedRows.clear(),this._selectedRows.add(t),this._lastSelectedRowIndex=t;break;case"toggle":this._selectedRows.has(t)?this._selectedRows.delete(t):this._selectedRows.add(t),this._lastSelectedRowIndex=t;break;case"range":if(this._lastSelectedRowIndex!==null){const i=Math.min(this._lastSelectedRowIndex,t),r=Math.max(this._lastSelectedRowIndex,t);for(let s=i;s<=r;s++)this._selectedRows.add(s)}else this._selectedRows.add(t),this._lastSelectedRowIndex=t;break}this.requestUpdate()}selectRowRange(t,o){this._selectedColumns.clear(),this._selectedCellRange=null,this._selectedRows.clear();const i=Math.min(t,o),r=Math.max(t,o);for(let s=i;s<=r;s++)this._selectedRows.add(s);this._lastSelectedRowIndex=o,this.requestUpdate()}clearSelection(){this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null,this.requestUpdate())}clearSelection_noRender(){this._selectedRows.clear(),this._lastSelectedRowIndex=null}getSelectedRowsData(){return this.selectedRows.map(t=>this.displayItems[t]).filter(Boolean)}async copySelectedRowsToClipboard(){const t=this.selectedRows;if(t.length===0)return!1;const o=[];if(this._shouldCopyWithHeaders){const r=[];for(const s of this.visualColumns){const n=s.column.title??s.column.field??"";r.push(String(n))}o.push(r.join(" "))}for(const r of t){const s=this.displayItems[r];if(!s)continue;const n=[];for(const l of this.visualColumns){const a=String(l.column.field),d=s[a],c=d==null?"":String(d);n.push(c)}o.push(n.join(" "))}const i=o.join(`
297
- `);try{return await navigator.clipboard.writeText(i),!0}catch{return!1}}async copySelectedColumnsToClipboard(){const t=this.selectedColumns;if(t.length===0)return!1;const o=[];if(this._shouldCopyWithHeaders){const r=[];for(const s of t){const n=this.visualColumns[s];if(!n)continue;const l=n.column.title??n.column.field??"";r.push(String(l))}o.push(r.join(" "))}for(let r=0;r<this.displayItems.length;r++){const s=this.displayItems[r];if(!s)continue;const n=[];for(const l of t){const a=this.visualColumns[l];if(!a)continue;const d=String(a.column.field),c=s[d],u=c==null?"":String(c);n.push(u)}o.push(n.join(" "))}const i=o.join(`
298
- `);try{return await navigator.clipboard.writeText(i),!0}catch{return!1}}get cellSelectionMode(){return this._cellSelectionMode}set cellSelectionMode(t){this._cellSelectionMode=t,this.checkSelectionConflicts(),this.requestUpdate()}get shouldCopyWithHeaders(){return this._shouldCopyWithHeaders}set shouldCopyWithHeaders(t){this._shouldCopyWithHeaders=t}get selectedCellRange(){return this._selectedCellRange}get lastClickedCell(){return this._lastClickedCell}set lastClickedCell(t){this._lastClickedCell=t}get oncellselectionchange(){return this._oncellselectionchange}set oncellselectionchange(t){this._oncellselectionchange=t}get pasteMode(){return this._pasteMode}set pasteMode(t){this._pasteMode=t}get shouldValidateOnPaste(){return this._shouldValidateOnPaste}set shouldValidateOnPaste(t){this._shouldValidateOnPaste=t}get createRowCallback(){return this._createRowCallback}set createRowCallback(t){this._createRowCallback=t}get onbeforepaste(){return this._onbeforepaste}set onbeforepaste(t){this._onbeforepaste=t}get onpaste(){return this._onpaste}set onpaste(t){this._onpaste=t}get isNewRowEnabled(){return this._isNewRowEnabled}set isNewRowEnabled(t){t&&!this.isNavigateMode&&console.warn('[WebGrid] Empty row requires navigate mode (editTrigger: "navigate"). Tab navigation will not work correctly without it.'),this._isNewRowEnabled=t,this._emptyRowDraft=null,this.requestUpdate()}get newRowPosition(){return this._newRowPosition}set newRowPosition(t){this._newRowPosition=t,this.requestUpdate()}get newRowIndicator(){return this._newRowIndicator}set newRowIndicator(t){this._newRowIndicator=t,this.requestUpdate()}get createEmptyRowCallback(){return this._createEmptyRowCallback}set createEmptyRowCallback(t){this._createEmptyRowCallback=t}selectCellRange(t){if(dt.debug("selectCellRange:",{startRow:t.startRowIndex,startCol:t.startColIndex,endRow:t.endRowIndex,endCol:t.endColIndex}),this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null),this._selectedColumns.clear(),this._selectedCellRange=t,this.requestUpdate(),this._oncellselectionchange){const o=this.getSelectedCells();this._oncellselectionchange({range:t,cellCount:o.length})}}clearCellSelection(){this._selectedCellRange&&(this._selectedCellRange=null,this.requestUpdate(),this._oncellselectionchange&&this._oncellselectionchange({range:null,cellCount:0}))}clearCellSelection_noRender(){this._selectedCellRange&&(this._selectedCellRange=null,this._oncellselectionchange&&this._oncellselectionchange({range:null,cellCount:0}))}selectAll(){const t=this.displayItems.length,o=this.visualColumns.length;if(t===0||o===0)return;const i=this.visualColumns[0],r=this.visualColumns[o-1],s={startRowIndex:0,startColIndex:0,endRowIndex:t-1,endColIndex:o-1,startField:String(i.column.field),endField:String(r.column.field)};this.selectCellRange(s)}selectColumn(t,o="replace"){const i=this.visualColumns.length;if(!(t<0||t>=i)){if(this._selectedRows.clear(),this._selectedCellRange=null,o==="replace")this._selectedColumns.clear(),this._selectedColumns.add(t),this._lastSelectedColumnIndex=t;else if(o==="toggle")this._selectedColumns.has(t)?this._selectedColumns.delete(t):this._selectedColumns.add(t),this._lastSelectedColumnIndex=t;else if(o==="range"){const r=this._lastSelectedColumnIndex>=0?this._lastSelectedColumnIndex:t,s=Math.min(r,t),n=Math.max(r,t);for(let l=s;l<=n;l++)this._selectedColumns.add(l)}this.requestUpdate()}}clearColumnSelection(){this._selectedColumns.clear(),this._lastSelectedColumnIndex=-1,this.requestUpdate()}clearColumnSelection_noRender(){this._selectedColumns.clear(),this._lastSelectedColumnIndex=-1}selectColumnRange(t,o){this._selectedRows.clear(),this._selectedCellRange=null,this._selectedColumns.clear();const i=Math.min(t,o),r=Math.max(t,o);for(let s=i;s<=r;s++)this._selectedColumns.add(s);this._lastSelectedColumnIndex=o,this.requestUpdate()}get selectedColumns(){return Array.from(this._selectedColumns).sort((t,o)=>t-o)}isColumnSelected(t){return this._selectedColumns.has(t)}getSelectedCells(){var c;if(!this._selectedCellRange)return[];const{startRowIndex:t,endRowIndex:o,startColIndex:i,endColIndex:r}=this._selectedCellRange,s=Math.min(t,o),n=Math.max(t,o),l=Math.min(i,r),a=Math.max(i,r),d=[];for(let u=s;u<=n;u++)for(let g=l;g<=a;g++){const h=(c=this.visualColumns[g])==null?void 0:c.column;if(!h)continue;const f=this.displayItems[u];if(!f)continue;const w=String(h.field),p=f[w];d.push({row:f,rowIndex:u,colIndex:g,field:w,value:p})}return d}isCellInSelectedRange(t,o){if(!this._selectedCellRange)return!1;const{startRowIndex:i,endRowIndex:r,startColIndex:s,endColIndex:n}=this._selectedCellRange,l=Math.min(i,r),a=Math.max(i,r),d=Math.min(s,n),c=Math.max(s,n);return t>=l&&t<=a&&o>=d&&o<=c}async copyCellSelectionToClipboard(){var u,g;if(!this._selectedCellRange)return!1;const{startRowIndex:t,endRowIndex:o,startColIndex:i,endColIndex:r}=this._selectedCellRange,s=Math.min(t,o),n=Math.max(t,o),l=Math.min(i,r),a=Math.max(i,r),d=[];if(this._shouldCopyWithHeaders){const h=[];for(let f=l;f<=a;f++){const w=(u=this.visualColumns[f])==null?void 0:u.column,p=(w==null?void 0:w.title)??(w==null?void 0:w.field)??"";h.push(String(p))}d.push(h.join(" "))}for(let h=s;h<=n;h++){const f=this.displayItems[h];if(!f)continue;const w=[];for(let p=l;p<=a;p++){const m=(g=this.visualColumns[p])==null?void 0:g.column;if(!m){w.push("");continue}const v=String(m.field),y=f[v],x=y==null?"":String(y);w.push(x)}d.push(w.join(" "))}const c=d.join(`
299
- `);try{return await navigator.clipboard.writeText(c),!0}catch{return!1}}get isNavigateMode(){return this._editTrigger==="navigate"||this._columns.some(t=>t.editTrigger==="navigate")}get filteredItems(){return!this._isFilterable||Object.keys(this._filters).length===0?this._items:this._items.filter(t=>Object.entries(this._filters).every(([o,i])=>i?String(t[o]??"").toLowerCase().includes(i.toLowerCase()):!0))}get sortedItems(){return this._sort.length===0?this.filteredItems:[...this.filteredItems].sort((t,o)=>{for(const i of this._sort){const r=t[i.column],s=o[i.column];if(r===s)continue;let n=0;return typeof r=="string"&&typeof s=="string"?n=r.localeCompare(s):typeof r=="number"&&typeof s=="number"?n=r-s:n=String(r??"").localeCompare(String(s??"")),i.direction==="asc"?n:-n}return 0})}get paginatedItems(){if(!this._isPageable)return this.sortedItems;if(this._paginationMode==="server")return this.sortedItems;const t=(this._currentPage-1)*this._pageSize,o=t+this._pageSize;return this.sortedItems.slice(t,o)}get totalPages(){const t=this._totalItems!==null?this._totalItems:this.sortedItems.length;return Math.max(1,Math.ceil(t/this._pageSize))}get displayItems(){const t=this.paginatedItems;if(!this._isNewRowEnabled)return t;const o=this.getEmptyRow();return this._newRowPosition==="top"?[o,...t]:[...t,o]}getEmptyRow(){if(this._emptyRowDraft)return this._emptyRowDraft;const t=this.createNewEmptyRow();return this._emptyRowDraft=t,t}createNewEmptyRow(){if(this._createEmptyRowCallback){const o=this._createEmptyRowCallback();return o instanceof Promise?(o.then(i=>{this._emptyRowDraft=i,this.requestUpdate()}).catch(i=>{console.warn("WebGrid: createEmptyRowCallback failed",i)}),{}):o}const t={};for(const o of this._columns)t[String(o.field)]=null;return t}isEmptyRowIndex(t){return this._isNewRowEnabled?this._newRowPosition==="top"?t===0:t===this.paginatedItems.length:!1}getDataIndexFromDisplayIndex(t){return this._isNewRowEnabled&&this._newRowPosition==="top"?t-1:t}emptyRowHasData(t){for(const o of this._columns){const i=t[String(o.field)];if(i!=null&&i!=="")return!0}return!1}fireDataRequest(t){if(this._ondatarequest){const o=t==="loadMore"?this._items.length:(this._currentPage-1)*this._pageSize,i={sort:[...this._sort],page:this._currentPage,pageSize:this._pageSize,trigger:t,mode:t==="loadMore"?"append":"replace",skip:o};at.debug("fireDataRequest:",t,i),this._ondatarequest(i)}}getColumnSortState(t){return this._sort.find(o=>o.column===t)}getColumnSortPriority(t){const o=this._sort.findIndex(i=>i.column===t);return o>=0?o+1:0}applyModeDefaults(){switch(this._mode){case"read-only":this._isEditable=!1,this._dropdownToggleVisibility="on-focus",this._cellSelectionMode="click";break;case"excel":this._isEditable=!0,this._editTrigger="navigate",this._dropdownToggleVisibility="always",this._shouldShowDropdownOnFocus=!1,this._cellSelectionMode="click";break;case"input-matrix":this._isEditable=!0,this._editTrigger="always",this._dropdownToggleVisibility="always",this._shouldShowDropdownOnFocus=!0,this._cellSelectionMode="shift";break}}checkSelectionConflicts(){this._cellSelectionMode==="click"&&this._editTrigger==="click"&&console.warn('WebGrid: cellSelectionMode="click" conflicts with editTrigger="click". Cell range selection takes priority. Use Shift+click to enter edit mode, or change to cellSelectionMode="shift" to avoid confusion.')}checkEditTriggerConflicts(){!this._isEditable&&this._editTrigger==="always"&&console.warn(`%cWebGrid: editTrigger="always" is not supported in read-only mode (isEditable=false).
296
+ `;let Jo=!1;class Mt{constructor(e={}){b(this,"options");b(this,"state");b(this,"localeStrings");b(this,"formatInfo");b(this,"element",null);b(this,"anchor",null);b(this,"input",null);b(this,"cleanupAutoUpdate",null);b(this,"previousInputValue","");b(this,"boundHandleClickOutside");b(this,"boundHandleKeyDown");this.options={dateFormat:"YYYY-MM-DD",showTodayButton:!0,...e};const o=new Date;this.state={viewMonth:o.getMonth(),viewYear:o.getFullYear(),selectedDate:null,isOpen:!1,rollingSelectorOpen:!1,rollingSelectorMode:"month",focusedDate:null},this.localeStrings=this.initLocaleStrings(e.locale),this.formatInfo=Dt(this.options.dateFormat||"YYYY-MM-DD"),this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}getElement(){return this.element}initLocaleStrings(e){const o=e||navigator.language||"en";try{const i=new Intl.DateTimeFormat(o,{month:"long"}),r=new Intl.DateTimeFormat(o,{month:"short"}),s=new Intl.DateTimeFormat(o,{weekday:"long"}),n=new Intl.DateTimeFormat(o,{weekday:"short"}),l=[],a=[];for(let u=0;u<12;u++){const h=new Date(2024,u,1);l.push(i.format(h)),a.push(r.format(h))}const d=[],c=[];for(let u=0;u<7;u++){const h=new Date(2024,0,7+u);d.push(s.format(h));const g=n.format(h);c.push(g.substring(0,2))}return{today:"Today",clear:"Clear",monthNames:l,monthNamesShort:a,weekdayNames:d,weekdayNamesShort:c}}catch{return Xo}}static injectStyles(){if(Jo)return;const e=document.createElement("style");e.id="wg-datepicker-styles",e.textContent=Pn,document.head.appendChild(e),Jo=!0}open(e,o=null){Mt.injectStyles(),this.state.isOpen&&this.close(),this.anchor=e;const i=le(o);if(i)this.state.selectedDate=i,this.state.viewYear=i.getFullYear(),this.state.viewMonth=i.getMonth();else{const r=new Date;this.state.viewYear=r.getFullYear(),this.state.viewMonth=r.getMonth()}xn(this.state),this.element=document.createElement("div"),this.element.className="wg-datepicker-container",this.element.innerHTML=cn(this.state,this.options,this.localeStrings),document.body.appendChild(this.element),this.position(),this.attachListeners(),this.state.isOpen=!0,this.state.rollingSelectorOpen&&Qo(this.element)}close(e=!1){var o,i;this.state.isOpen&&(this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),document.removeEventListener("mousedown",this.boundHandleClickOutside),document.removeEventListener("keydown",this.boundHandleKeyDown),this.element&&(this.element.remove(),this.element=null),this.state.isOpen=!1,this.state.rollingSelectorOpen=!1,e||(i=(o=this.options).onClose)==null||i.call(o))}destroy(){this.close(),this.anchor=null,this.input=null}getSelectedDate(){return this.state.selectedDate}getFormattedValue(){return io(this.state.selectedDate,this.formatInfo)}position(){if(!this.element||!this.anchor)return;const e=this.element.querySelector(".wg-datepicker");e&&(this.cleanupAutoUpdate=on(this.anchor,e,()=>{if(!this.anchor.isConnected){this.close(!0);return}Be(this.anchor,e,{placement:"bottom-start",middleware:[Rt(4),Ne({fallbackPlacements:["top-start","bottom-end","top-end"]}),lt({padding:8})]}).then(({x:o,y:i})=>{Object.assign(e.style,{left:`${o}px`,top:`${i}px`})})}))}attachListeners(){this.element&&(this.element.addEventListener("click",e=>this.handleClick(e)),setTimeout(()=>{document.addEventListener("mousedown",this.boundHandleClickOutside)},0),document.addEventListener("keydown",this.boundHandleKeyDown))}handleClick(e){var l;const o=e.target,i=(l=o.closest("[data-action]"))==null?void 0:l.getAttribute("data-action");if(i==="prev-month"){e.preventDefault(),ro(this.state),this.render();return}if(i==="next-month"){e.preventDefault(),no(this.state),this.render();return}if(i==="toggle-rolling"){e.preventDefault(),this.state.rollingSelectorOpen=!this.state.rollingSelectorOpen,this.render(),this.state.rollingSelectorOpen&&this.element&&Qo(this.element);return}if(i==="today"){e.preventDefault();const a=In(this.state,this.options);a&&this.selectDate(a);return}const r=o.closest(".wg-datepicker__day");if(r){e.preventDefault();const a=kn(r,this.state,this.options);a&&this.selectDate(a);return}const s=o.closest("[data-month]");if(s&&this.state.rollingSelectorOpen){e.preventDefault(),En(s,this.state),this.render();return}const n=o.closest("[data-year]");if(n&&this.state.rollingSelectorOpen){e.preventDefault(),Rn(n,this.state),this.render();return}}handleClickOutside(e){if(!this.element||!this.anchor)return;const o=e.composedPath();!o.includes(this.element)&&!o.includes(this.anchor)&&this.close()}handleKeyDown(e){yn(e,this.state,this.options,{onSelect:(i,r)=>this.selectDate(i,r),onClose:()=>this.close()})&&this.render()}selectDate(e,o){var i,r;this.state.selectedDate=e,(r=(i=this.options).onSelect)==null||r.call(i,e,o),this.close(!0)}render(){if(!this.element)return;const e=this.element.querySelector(".wg-datepicker");e&&(bn(e,this.state,this.localeStrings),_n(e,this.state.rollingSelectorOpen),this.state.rollingSelectorOpen?vn(e,this.state):mn(e,this.state,this.options))}connectInput(e){this.input=e,this.previousInputValue=e.value,e.addEventListener("input",()=>{this.previousInputValue=Dn(e,this.formatInfo,this.previousInputValue),$n(e.value,this.formatInfo,this.state,this.options)}),e.addEventListener("keydown",o=>{Tn(o,this.formatInfo)}),e.addEventListener("paste",o=>{Mn(o,e,this.formatInfo)}),e.addEventListener("focus",()=>{!this.state.isOpen&&this.anchor&&this.open(this.anchor,e.value)})}}var Zo=function(){},fe="undefined",An=typeof window!==fe&&typeof window.navigator!==fe&&/Trident\/|MSIE /.test(window.navigator.userAgent),lo=["trace","debug","info","warn","error"],dt={},W=null;function ei(t,e){var o=t[e];if(typeof o.bind=="function")return o.bind(t);try{return Function.prototype.bind.call(o,t)}catch{return function(){return Function.prototype.apply.apply(o,[t,arguments])}}}function Ln(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function zn(t){return t==="debug"&&(t="log"),typeof console===fe?!1:t==="trace"&&An?Ln:console[t]!==void 0?ei(console,t):console.log!==void 0?ei(console,"log"):Zo}function ct(){for(var t=this.getLevel(),e=0;e<lo.length;e++){var o=lo[e];this[o]=e<t?Zo:this.methodFactory(o,t,this.name)}if(this.log=this.debug,typeof console===fe&&t<this.levels.SILENT)return"No console available for logging"}function On(t){return function(){typeof console!==fe&&(ct.call(this),this[t].apply(this,arguments))}}function Hn(t,e,o){return zn(t)||On.apply(this,arguments)}function ti(t,e){var o=this,i,r,s,n="loglevel";typeof t=="string"?n+=":"+t:typeof t=="symbol"&&(n=void 0);function l(h){var g=(lo[h]||"silent").toUpperCase();if(!(typeof window===fe||!n)){try{window.localStorage[n]=g;return}catch{}try{window.document.cookie=encodeURIComponent(n)+"="+g+";"}catch{}}}function a(){var h;if(!(typeof window===fe||!n)){try{h=window.localStorage[n]}catch{}if(typeof h===fe)try{var g=window.document.cookie,f=encodeURIComponent(n),w=g.indexOf(f+"=");w!==-1&&(h=/^([^;]+)/.exec(g.slice(w+f.length+1))[1])}catch{}return o.levels[h]===void 0&&(h=void 0),h}}function d(){if(!(typeof window===fe||!n)){try{window.localStorage.removeItem(n)}catch{}try{window.document.cookie=encodeURIComponent(n)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function c(h){var g=h;if(typeof g=="string"&&o.levels[g.toUpperCase()]!==void 0&&(g=o.levels[g.toUpperCase()]),typeof g=="number"&&g>=0&&g<=o.levels.SILENT)return g;throw new TypeError("log.setLevel() called with invalid level: "+h)}o.name=t,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=e||Hn,o.getLevel=function(){return s??r??i},o.setLevel=function(h,g){return s=c(h),g!==!1&&l(s),ct.call(o)},o.setDefaultLevel=function(h){r=c(h),a()||o.setLevel(h,!1)},o.resetLevel=function(){s=null,d(),ct.call(o)},o.enableAll=function(h){o.setLevel(o.levels.TRACE,h)},o.disableAll=function(h){o.setLevel(o.levels.SILENT,h)},o.rebuild=function(){if(W!==o&&(i=c(W.getLevel())),ct.call(o),W===o)for(var h in dt)dt[h].rebuild()},i=c(W?W.getLevel():"WARN");var u=a();u!=null&&(s=c(u)),ct.call(o)}W=new ti,W.getLogger=function(e){if(typeof e!="symbol"&&typeof e!="string"||e==="")throw new TypeError("You must supply a name when creating a logger.");var o=dt[e];return o||(o=dt[e]=new ti(e,W.methodFactory)),o};var Fn=typeof window!==fe?window.log:void 0;W.noConflict=function(){return typeof window!==fe&&window.log===W&&(window.log=Fn),W},W.getLoggers=function(){return dt},W.default=W;var qn=function(t){for(var e=1,o=arguments.length,i;e<o;e++)for(i in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],i)&&(t[i]=arguments[e][i]);return t},Vn={template:"[%t] %l:",levelFormatter:function(t){return t.toUpperCase()},nameFormatter:function(t){return t||"root"},timestampFormatter:function(t){return t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},oi,We={},Nn=function(t){if(!t||!t.getLogger)throw new TypeError("Argument is not a root logger");oi=t},Bn=function(t,e){if(!t||!t.setLevel)throw new TypeError("Argument is not a logger");var o=t.methodFactory,i=t.name||"",r=We[i]||We[""]||Vn;function s(n,l,a){var d=o(n,l,a),c=We[a]||We[""],u=c.template.indexOf("%t")!==-1,h=c.template.indexOf("%l")!==-1,g=c.template.indexOf("%n")!==-1;return function(){for(var f="",w=arguments.length,p=Array(w),m=0;m<w;m++)p[m]=arguments[m];if(i||!We[a]){var _=c.timestampFormatter(new Date),y=c.levelFormatter(n),C=c.nameFormatter(a);c.format?f+=c.format(y,C,_):(f+=c.template,u&&(f=f.replace(/%t/,_)),h&&(f=f.replace(/%l/,y)),g&&(f=f.replace(/%n/,C))),p.length&&typeof p[0]=="string"?p[0]=f+" "+p[0]:p.unshift(f)}d.apply(void 0,p)}}return We[i]||(t.methodFactory=s),e=e||{},e.template&&(e.format=void 0),We[i]=qn({},r,e),t.setLevel(t.getLevel()),oi||t.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),t},ii={reg:Nn,apply:Bn};ii.reg(W),ii.apply(W,{format(t,e,o){return`[${o}] [${t}]${e?` [${e}]`:""}`},timestampFormatter(t){return t.toTimeString().split(" ")[0]+"."+t.getMilliseconds().toString().padStart(3,"0")}}),W.setLevel("silent");const ao=W.getLogger("GRID:INIT"),gt=W.getLogger("GRID:DATA"),Ee=W.getLogger("GRID:UI"),Le=W.getLogger("GRID:INTERACTION"),$t=W.getLogger("GRID:PERF"),Wn=["GRID:INIT","GRID:DATA","GRID:UI","GRID:INTERACTION","GRID:PERF"];function Un(){W.setLevel("debug")}function Yn(){W.setLevel("silent")}function Kn(t){W.setLevel(t)}function jn(t,e){W.getLogger(t).setLevel(e)}const ie={counters:{displayItems:0,displayItemsMs:0,paginatedItems:0,paginatedItemsMs:0,treeSorted:0,treeSortedMs:0,treeVisible:0,treeVisibleMs:0,cellDisplayItemsLookup:0},reset(){const t=this.counters;t.displayItems=0,t.displayItemsMs=0,t.paginatedItems=0,t.paginatedItemsMs=0,t.treeSorted=0,t.treeSortedMs=0,t.treeVisible=0,t.treeVisibleMs=0,t.cellDisplayItemsLookup=0},summary(){const t=this.counters;return[`displayItems=${t.displayItems} (${t.displayItemsMs.toFixed(1)}ms)`,`paginatedItems=${t.paginatedItems} (${t.paginatedItemsMs.toFixed(1)}ms)`,`treeSorted=${t.treeSorted} (${t.treeSortedMs.toFixed(1)}ms)`,`treeVisible=${t.treeVisible} (${t.treeVisibleMs.toFixed(1)}ms)`,`cellDisplayItemsLookup=${t.cellDisplayItemsLookup}`].join(" | ")}},ri={rowActions:"Row actions",inlineActionsHeader:"Actions",keyboardShortcuts:"Keyboard shortcuts",paginationFirst:"⏮",paginationPrevious:"◀",paginationNext:"▶",paginationLast:"⏭",paginationPageInfo:"Page {current} of {total}",paginationItemCount:"{count} items",paginationPerPage:"per page",dropdownNoOptions:"No options",dropdownSearching:"Searching...",contextMenu:{sortAsc:"Sort Ascending",sortDesc:"Sort Descending",clearSort:"Clear Sort",hideColumn:"Hide Column",freezeColumn:"Freeze Column",unfreezeColumn:"Unfreeze Column",columnVisibility:"Column Visibility",showAll:"Show all"}};class ni{constructor(){b(this,"_items",[]);b(this,"_columns",[]);b(this,"_sortMode","none");b(this,"_isFilterable",!1);b(this,"_isPageable",!1);b(this,"_pageSize",10);b(this,"_pageSizes",[10,25,50,100]);b(this,"_paginationMode","client");b(this,"_isStriped",!0);b(this,"_isHoverable",!0);b(this,"_isEditable",!1);b(this,"_isRowEditable");b(this,"_editTrigger","dblclick");b(this,"_editStartSelection","mousePosition");b(this,"_mode","excel");b(this,"_dropdownToggleVisibility","always");b(this,"_shouldShowDropdownOnFocus",!0);b(this,"_shouldOpenDropdownOnEnter",!1);b(this,"_isCheckboxAlwaysEditable",!1);b(this,"_isRowNumbersVisible",!1);b(this,"_isStickyRowNumbers",!1);b(this,"_freezeColumns",0);b(this,"_invalidCells",[]);b(this,"_isDirtyIndicatorVisible",!0);b(this,"_isRowToolbarVisible",!1);b(this,"_rowToolbar",["add","delete","duplicate"]);b(this,"_toolbarVerticalAlign","bottom");b(this,"_toolbarHorizontalAlign","center");b(this,"_toolbarTrigger","hover");b(this,"_toolbarPosition","auto");b(this,"_toolbarColumn");b(this,"_toolbarFollowsCursor",!1);b(this,"_cellToolbar");b(this,"_cellToolbarOffset",.2);b(this,"_toolbarBtnMinWidth");b(this,"_inlineActionsTitle","");b(this,"_contextMenu");b(this,"_contextMenuXOffset",8);b(this,"_contextMenuYOffset",0);b(this,"_headerContextMenu");b(this,"_rowShortcuts");b(this,"_isShortcutsHelpVisible",!1);b(this,"_shortcutsHelpPosition","top-right");b(this,"_shortcutsHelpContentCallback");b(this,"_idValueMember");b(this,"_idValueCallback");b(this,"_rowLocking");b(this,"_externalLocks",new Map);b(this,"_onrowlockchange");b(this,"_gridName",null);b(this,"_shouldPersistColumnWidths",!1);b(this,"_columnWidths",new Map);b(this,"_oncolumnresize");b(this,"_isColumnReorderAllowed",!1);b(this,"_shouldPersistColumnOrder",!1);b(this,"_columnOrder",new Map);b(this,"_oncolumnreorder");b(this,"_fillDirection","vertical");b(this,"_fillDragCallback");b(this,"_onrowchange");b(this,"_onroweditstart");b(this,"_onroweditcancel");b(this,"_onvalidationerror");b(this,"_validationTooltipCallback");b(this,"_ontoolbarclick");b(this,"_onrowaction");b(this,"_oncontextmenuopen");b(this,"_onheadercontextmenuopen");b(this,"_ondatarequest");b(this,"_onrowdelete");b(this,"_sort",[]);b(this,"_filters",{});b(this,"_onfilterchange");b(this,"_columnMinWidth");b(this,"_currentPage",1);b(this,"_totalItems",null);b(this,"_showPagination",!0);b(this,"_paginationPosition","bottom-center");b(this,"_paginationLabelsCallback");b(this,"_paginationLayout","pageSize|previous|pageInfo|next");b(this,"_summaryPosition");b(this,"_summaryContentCallback");b(this,"_summaryMetadata");b(this,"_isSummaryInline",!0);b(this,"_customStylesCallback");b(this,"_rowClassCallback");b(this,"_labels",{...ri});b(this,"_isScrollable",!1);b(this,"_scrollMaxHeight","100vh");b(this,"_tableBorderOnly",!1);b(this,"_isVirtualScrollEnabled",!1);b(this,"_virtualScrollThreshold",100);b(this,"_virtualScrollRowHeight",38);b(this,"_virtualScrollBuffer",10);b(this,"_isInfiniteScrollEnabled",!1);b(this,"_infiniteScrollThreshold",100);b(this,"_hasMoreItems",!0);b(this,"_isLoadingMore",!1);b(this,"_editingCell",null);b(this,"_currentCellError",null);b(this,"_isValidating",!1);b(this,"_draftRows",new Map);b(this,"_focusedCell",null);b(this,"_isCommittingFromKeyboard",!1);b(this,"_skipNextDropdownAutoEdit",!1);b(this,"_tabTraversalStartColIndex",null);b(this,"_hoveredRowIndex",null);b(this,"_focusedRowIndex",null);b(this,"_onrowfocus");b(this,"_onInteractionChange",null);b(this,"_selectedRows",new Set);b(this,"_lastSelectedRowIndex",null);b(this,"_rangeShortcuts",[]);b(this,"_cellSelectionMode","click");b(this,"_selectedCellRange",null);b(this,"_lastClickedCell",null);b(this,"_shouldCopyWithHeaders",!1);b(this,"_oncellselectionchange",null);b(this,"_selectedColumns",new Set);b(this,"_lastSelectedColumnIndex",-1);b(this,"_pasteMode","skip-non-editable");b(this,"_shouldValidateOnPaste",!0);b(this,"_createRowCallback");b(this,"_onbeforepaste");b(this,"_onpaste");b(this,"_isNewRowEnabled",!1);b(this,"_newRowPosition","bottom");b(this,"_newRowIndicator","+");b(this,"_createEmptyRowCallback");b(this,"_emptyRowDraft",null);b(this,"_treePathMember",null);b(this,"_treeLevelMember",null);b(this,"_treeParentMember",null);b(this,"_idMember",null);b(this,"_hasWarnedAboutMissingRowId",!1);b(this,"_treeSeparator",null);b(this,"_treeDataSorted",!1);b(this,"_expandedPaths",new Set);b(this,"_expandedPathsExternal",null);b(this,"_defaultExpandDepth",null);b(this,"_treeIndex",null);b(this,"_onexpandedpathschange");b(this,"_treeDoubleClickBehavior","none");b(this,"_treeExpandedGlyph","▶");b(this,"_treeCollapsedGlyph","▶");b(this,"_treeChevronCallback");b(this,"_treeChevronCache",new WeakMap);b(this,"_paginatedItemsCache",null);b(this,"_displayItemsCache",null)}get items(){return this._items}set items(e){gt.debug("items set:",e.length,"rows"),this._items=e,this._treeChevronCache=new WeakMap,this.rebuildTreeState(),this.requestUpdate()}get columns(){return this._columns}set columns(e){ao.debug("columns set:",e.length,"columns",e.map(o=>String(o.field))),this._columns=e,this.requestUpdate()}get sortMode(){return this._sortMode}set sortMode(e){this._sortMode=e,this.requestUpdate()}get isFilterable(){return this._isFilterable}set isFilterable(e){this._isFilterable=e,this.requestUpdate()}get onfilterchange(){return this._onfilterchange}set onfilterchange(e){this._onfilterchange=e}get columnMinWidth(){return this._columnMinWidth}set columnMinWidth(e){this._columnMinWidth=e||void 0,this.requestUpdate()}get isPageable(){return this._isPageable}set isPageable(e){this._isPageable=e,this.requestUpdate()}get pageSize(){return this._pageSize}set pageSize(e){this._pageSize=e,this.requestUpdate()}get pageSizes(){return this._pageSizes}set pageSizes(e){this._pageSizes=e,this.requestUpdate()}get paginationMode(){return this._paginationMode}set paginationMode(e){this._paginationMode=e,this.requestUpdate()}get isStriped(){return this._isStriped}set isStriped(e){this._isStriped=e,this.requestUpdate()}get isHoverable(){return this._isHoverable}set isHoverable(e){this._isHoverable=e,this.requestUpdate()}get isEditable(){return this._isEditable}set isEditable(e){this._isEditable=e,this.checkEditTriggerConflicts(),this.maybeWarnAboutRowIdentity(),this.requestUpdate()}get isRowEditable(){return this._isRowEditable}set isRowEditable(e){this._isRowEditable=e,this.requestUpdate()}get editTrigger(){return this._editTrigger}set editTrigger(e){this._editTrigger=e,this.checkSelectionConflicts(),this.checkEditTriggerConflicts(),this.requestUpdate()}get editStartSelection(){return this._editStartSelection}set editStartSelection(e){this._editStartSelection=e}get mode(){return this._mode}set mode(e){this._mode=e,this.applyModeDefaults(),this.checkEditTriggerConflicts(),this.requestUpdate()}get dropdownToggleVisibility(){return this._dropdownToggleVisibility}set dropdownToggleVisibility(e){this._dropdownToggleVisibility=e,this.requestUpdate()}getEffectiveToggleVisibility(e){return e.dropdownToggleVisibility??this._dropdownToggleVisibility}get shouldShowDropdownOnFocus(){return this._shouldShowDropdownOnFocus}set shouldShowDropdownOnFocus(e){this._shouldShowDropdownOnFocus=e}get shouldOpenDropdownOnEnter(){return this._shouldOpenDropdownOnEnter}set shouldOpenDropdownOnEnter(e){this._shouldOpenDropdownOnEnter=e}getEffectiveShouldOpenDropdownOnEnter(e){return e.shouldOpenDropdownOnEnter??this._shouldOpenDropdownOnEnter}get isCheckboxAlwaysEditable(){return this._isCheckboxAlwaysEditable}set isCheckboxAlwaysEditable(e){this._isCheckboxAlwaysEditable=e,this.requestUpdate()}get isRowNumbersVisible(){return this._isRowNumbersVisible}set isRowNumbersVisible(e){this._isRowNumbersVisible=e,this.requestUpdate()}get isDirtyIndicatorVisible(){return this._isDirtyIndicatorVisible}set isDirtyIndicatorVisible(e){this._isDirtyIndicatorVisible=e,this.requestUpdate()}get isStickyRowNumbers(){return this._isStickyRowNumbers}set isStickyRowNumbers(e){this._isStickyRowNumbers=e,this.requestUpdate()}get freezeColumns(){return this._freezeColumns}set freezeColumns(e){this._freezeColumns=Math.max(0,Math.floor(e)),this.requestUpdate()}get visualColumns(){const e=[],o=[];this._columns.filter(s=>s.isFrozen&&!s.isHidden).length,this._columns.forEach((s,n)=>{if(s.isHidden)return;const l={column:s,originalIndex:n};s.isFrozen?e.push(l):o.push(l)});const i=[],r=[];return o.forEach((s,n)=>{n<this._freezeColumns?i.push(s):r.push(s)}),this._columnOrder.size>0&&r.sort((s,n)=>{const l=String(s.column.field),a=String(n.column.field),d=this._columnOrder.get(l)??s.originalIndex,c=this._columnOrder.get(a)??n.originalIndex;return d-c}),[...e,...i,...r]}get totalFrozenColumns(){return this._columns.filter(o=>o.isFrozen).length+this._freezeColumns}isColumnFrozen(e){return e<this.totalFrozenColumns}get invalidCells(){return this._invalidCells}set invalidCells(e){this._invalidCells=e,this.requestUpdate()}get editingCell(){return this._editingCell}get isValidating(){return this._isValidating}get currentCellError(){return this._currentCellError}get hoveredRowIndex(){return this._hoveredRowIndex}get isRowToolbarVisible(){return this._isRowToolbarVisible}set isRowToolbarVisible(e){this._isRowToolbarVisible=e,this.requestUpdate()}get rowToolbar(){return this._rowToolbar}set rowToolbar(e){this._rowToolbar=e,this.requestUpdate()}get toolbarVerticalAlign(){return this._toolbarVerticalAlign}set toolbarVerticalAlign(e){this._toolbarVerticalAlign=e,this.checkToolbarConflicts(),this.requestUpdate()}get toolbarHorizontalAlign(){return this._toolbarHorizontalAlign}set toolbarHorizontalAlign(e){this._toolbarHorizontalAlign=e,this.checkToolbarConflicts(),this.requestUpdate()}get toolbarAlign(){return this._toolbarVerticalAlign}set toolbarAlign(e){this.toolbarVerticalAlign=e}get toolbarTopPosition(){return this._toolbarHorizontalAlign}set toolbarTopPosition(e){this.toolbarHorizontalAlign=e}get toolbarTrigger(){return this._toolbarTrigger}set toolbarTrigger(e){this._toolbarTrigger=e,this.requestUpdate()}get toolbarPosition(){return this._toolbarPosition}set toolbarPosition(e){this._toolbarPosition=e,this.checkToolbarConflicts(),this.requestUpdate()}get toolbarColumn(){return this._toolbarColumn}set toolbarColumn(e){this._toolbarColumn=e,this.checkToolbarConflicts()}get toolbarFollowsCursor(){return this._toolbarFollowsCursor}set toolbarFollowsCursor(e){this._toolbarFollowsCursor=e,this.checkToolbarConflicts()}get cellToolbar(){return this._cellToolbar}set cellToolbar(e){this._cellToolbar=e,this.checkToolbarConflicts()}get cellToolbarOffset(){return this._cellToolbarOffset}set cellToolbarOffset(e){typeof e=="number"?this._cellToolbarOffset=Math.max(0,Math.min(1,e)):this._cellToolbarOffset=e}get toolbarBtnMinWidth(){return this._toolbarBtnMinWidth}set toolbarBtnMinWidth(e){this._toolbarBtnMinWidth=e}get inlineActionsTitle(){return this._inlineActionsTitle}set inlineActionsTitle(e){this._inlineActionsTitle=e,this.requestUpdate()}get contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,this.requestUpdate()}get contextMenuXOffset(){return this._contextMenuXOffset}set contextMenuXOffset(e){this._contextMenuXOffset=e}get contextMenuYOffset(){return this._contextMenuYOffset}set contextMenuYOffset(e){this._contextMenuYOffset=e}get headerContextMenu(){return this._headerContextMenu}set headerContextMenu(e){this._headerContextMenu=e}get rowShortcuts(){return this._rowShortcuts}set rowShortcuts(e){this._rowShortcuts=e,this.requestUpdate()}get isShortcutsHelpVisible(){return this._isShortcutsHelpVisible}set isShortcutsHelpVisible(e){this._isShortcutsHelpVisible=e,this.requestUpdate()}get shortcutsHelpPosition(){return this._shortcutsHelpPosition}set shortcutsHelpPosition(e){this._shortcutsHelpPosition=e,this.requestUpdate()}get shortcutsHelpContentCallback(){return this._shortcutsHelpContentCallback}set shortcutsHelpContentCallback(e){this._shortcutsHelpContentCallback=e,this.requestUpdate()}get sort(){return this._sort}set sort(e){gt.debug("sort changed:",e.map(o=>`${o.column} ${o.direction}`).join(", ")||"none"),this._sort=e,this.requestUpdate()}get currentPage(){return this._currentPage}set currentPage(e){gt.debug("page changed:",e),this._currentPage=e,this.requestUpdate()}get totalItems(){return this._totalItems}set totalItems(e){this._totalItems=e,this.requestUpdate()}get showPagination(){return this._showPagination}set showPagination(e){this._showPagination=e,this.requestUpdate()}get paginationPosition(){return this._paginationPosition}set paginationPosition(e){this._paginationPosition=e,this.requestUpdate()}get paginationLabelsCallback(){return this._paginationLabelsCallback}set paginationLabelsCallback(e){this._paginationLabelsCallback=e,this.requestUpdate()}get paginationLayout(){return this._paginationLayout}set paginationLayout(e){this._paginationLayout=e,this.requestUpdate()}get summaryPosition(){return this._summaryPosition}set summaryPosition(e){this._summaryPosition=e,this.requestUpdate()}get summaryContentCallback(){return this._summaryContentCallback}set summaryContentCallback(e){this._summaryContentCallback=e,this.requestUpdate()}get summaryMetadata(){return this._summaryMetadata}set summaryMetadata(e){this._summaryMetadata=e,this.requestUpdate()}get isSummaryInline(){return this._isSummaryInline}set isSummaryInline(e){this._isSummaryInline=e,this.requestUpdate()}get customStylesCallback(){return this._customStylesCallback}set customStylesCallback(e){this._customStylesCallback=e}get rowClassCallback(){return this._rowClassCallback}set rowClassCallback(e){this._rowClassCallback=e,this.requestUpdate()}get labels(){return this._labels}set labels(e){this._labels={...ri,...e},this.requestUpdate()}get isScrollable(){return this._isScrollable}set isScrollable(e){this._isScrollable=e,this.requestUpdate()}get scrollMaxHeight(){return this._scrollMaxHeight}set scrollMaxHeight(e){this._scrollMaxHeight=e,this.requestUpdate()}get tableBorderOnly(){return this._tableBorderOnly}set tableBorderOnly(e){this._tableBorderOnly=e,this.requestUpdate()}get isVirtualScrollEnabled(){return this._isVirtualScrollEnabled}set isVirtualScrollEnabled(e){this._isVirtualScrollEnabled=e,this.requestUpdate()}get virtualScrollThreshold(){return this._virtualScrollThreshold}set virtualScrollThreshold(e){this._virtualScrollThreshold=e,this.requestUpdate()}get virtualScrollRowHeight(){return this._virtualScrollRowHeight}set virtualScrollRowHeight(e){this._virtualScrollRowHeight=e,this.requestUpdate()}get virtualScrollBuffer(){return this._virtualScrollBuffer}set virtualScrollBuffer(e){this._virtualScrollBuffer=e,this.requestUpdate()}get isInfiniteScrollEnabled(){return this._isInfiniteScrollEnabled}set isInfiniteScrollEnabled(e){this._isInfiniteScrollEnabled=e,this.requestUpdate()}get infiniteScrollThreshold(){return this._infiniteScrollThreshold}set infiniteScrollThreshold(e){this._infiniteScrollThreshold=e}get hasMoreItems(){return this._hasMoreItems}set hasMoreItems(e){this._hasMoreItems=e}get isLoadingMore(){return this._isLoadingMore}set isLoadingMore(e){this._isLoadingMore=e}shouldUseVirtualScroll(){return this._isVirtualScrollEnabled===!1?!1:this._isVirtualScrollEnabled===!0?!0:this.displayItems.length>=this._virtualScrollThreshold}set onrowchange(e){this._onrowchange=e}set onroweditstart(e){this._onroweditstart=e}set onroweditcancel(e){this._onroweditcancel=e}set onvalidationerror(e){this._onvalidationerror=e}get validationTooltipCallback(){return this._validationTooltipCallback}set validationTooltipCallback(e){this._validationTooltipCallback=e}get ontoolbarclick(){return this._ontoolbarclick}set ontoolbarclick(e){this._ontoolbarclick=e}set onrowaction(e){this._onrowaction=e}get oncontextmenuopen(){return this._oncontextmenuopen}set oncontextmenuopen(e){this._oncontextmenuopen=e}get onheadercontextmenuopen(){return this._onheadercontextmenuopen}set onheadercontextmenuopen(e){this._onheadercontextmenuopen=e}get ondatarequest(){return this._ondatarequest}set ondatarequest(e){this._ondatarequest=e}get onrowdelete(){return this._onrowdelete}set onrowdelete(e){this._onrowdelete=e}get idValueMember(){return this._idValueMember}set idValueMember(e){this._idValueMember=e}get idValueCallback(){return this._idValueCallback}set idValueCallback(e){this._idValueCallback=e}get rowLocking(){return this._rowLocking}set rowLocking(e){this._rowLocking=e,this.requestUpdate()}get onrowlockchange(){return this._onrowlockchange}set onrowlockchange(e){this._onrowlockchange=e}get gridName(){return this._gridName}set gridName(e){this._gridName=e}get shouldPersistColumnWidths(){return this._shouldPersistColumnWidths}set shouldPersistColumnWidths(e){this._shouldPersistColumnWidths=e}get oncolumnresize(){return this._oncolumnresize}set oncolumnresize(e){this._oncolumnresize=e}get isColumnReorderAllowed(){return this._isColumnReorderAllowed}set isColumnReorderAllowed(e){this._isColumnReorderAllowed=e}get shouldPersistColumnOrder(){return this._shouldPersistColumnOrder}set shouldPersistColumnOrder(e){this._shouldPersistColumnOrder=e}get oncolumnreorder(){return this._oncolumnreorder}set oncolumnreorder(e){this._oncolumnreorder=e}get fillDirection(){return this._fillDirection}set fillDirection(e){this._fillDirection=e}get fillDragCallback(){return this._fillDragCallback}set fillDragCallback(e){this._fillDragCallback=e}get selectedRows(){return Array.from(this._selectedRows).sort((e,o)=>e-o)}get rangeShortcuts(){return this._rangeShortcuts}set rangeShortcuts(e){this._rangeShortcuts=e}isRowSelected(e){return this._selectedRows.has(e)}selectRow(e,o="replace"){switch(Le.debug("selectRow:",{rowIndex:e,mode:o}),this._selectedCellRange&&(this._selectedCellRange=null),this._selectedColumns.clear(),o){case"replace":this._selectedRows.clear(),this._selectedRows.add(e),this._lastSelectedRowIndex=e;break;case"toggle":this._selectedRows.has(e)?this._selectedRows.delete(e):this._selectedRows.add(e),this._lastSelectedRowIndex=e;break;case"range":if(this._lastSelectedRowIndex!==null){const i=Math.min(this._lastSelectedRowIndex,e),r=Math.max(this._lastSelectedRowIndex,e);for(let s=i;s<=r;s++)this._selectedRows.add(s)}else this._selectedRows.add(e),this._lastSelectedRowIndex=e;break}this.requestUpdate()}selectRowRange(e,o){this._selectedColumns.clear(),this._selectedCellRange=null,this._selectedRows.clear();const i=Math.min(e,o),r=Math.max(e,o);for(let s=i;s<=r;s++)this._selectedRows.add(s);this._lastSelectedRowIndex=o,this.requestUpdate()}clearSelection(){this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null,this.requestUpdate())}clearSelection_noRender(){this._selectedRows.clear(),this._lastSelectedRowIndex=null}getSelectedRowsData(){return this.selectedRows.map(e=>this.displayItems[e]).filter(Boolean)}async copySelectedRowsToClipboard(){const e=this.selectedRows;if(e.length===0)return!1;const o=[];if(this._shouldCopyWithHeaders){const r=[];for(const s of this.visualColumns){const n=s.column.title??s.column.field??"";r.push(String(n))}o.push(r.join(" "))}for(const r of e){const s=this.displayItems[r];if(!s)continue;const n=[];for(const l of this.visualColumns){const a=String(l.column.field),d=s[a],c=d==null?"":String(d);n.push(c)}o.push(n.join(" "))}const i=o.join(`
297
+ `);try{return await navigator.clipboard.writeText(i),!0}catch{return!1}}async copySelectedColumnsToClipboard(){const e=this.selectedColumns;if(e.length===0)return!1;const o=[];if(this._shouldCopyWithHeaders){const r=[];for(const s of e){const n=this.visualColumns[s];if(!n)continue;const l=n.column.title??n.column.field??"";r.push(String(l))}o.push(r.join(" "))}for(let r=0;r<this.displayItems.length;r++){const s=this.displayItems[r];if(!s)continue;const n=[];for(const l of e){const a=this.visualColumns[l];if(!a)continue;const d=String(a.column.field),c=s[d],u=c==null?"":String(c);n.push(u)}o.push(n.join(" "))}const i=o.join(`
298
+ `);try{return await navigator.clipboard.writeText(i),!0}catch{return!1}}get cellSelectionMode(){return this._cellSelectionMode}set cellSelectionMode(e){this._cellSelectionMode=e,this.checkSelectionConflicts(),this.requestUpdate()}get shouldCopyWithHeaders(){return this._shouldCopyWithHeaders}set shouldCopyWithHeaders(e){this._shouldCopyWithHeaders=e}get selectedCellRange(){return this._selectedCellRange}get lastClickedCell(){return this._lastClickedCell}set lastClickedCell(e){this._lastClickedCell=e}get oncellselectionchange(){return this._oncellselectionchange}set oncellselectionchange(e){this._oncellselectionchange=e}get pasteMode(){return this._pasteMode}set pasteMode(e){this._pasteMode=e}get shouldValidateOnPaste(){return this._shouldValidateOnPaste}set shouldValidateOnPaste(e){this._shouldValidateOnPaste=e}get createRowCallback(){return this._createRowCallback}set createRowCallback(e){this._createRowCallback=e}get onbeforepaste(){return this._onbeforepaste}set onbeforepaste(e){this._onbeforepaste=e}get onpaste(){return this._onpaste}set onpaste(e){this._onpaste=e}get isNewRowEnabled(){return this._isNewRowEnabled}set isNewRowEnabled(e){e&&!this.isNavigateMode&&console.warn('[WebGrid] Empty row requires navigate mode (editTrigger: "navigate"). Tab navigation will not work correctly without it.'),this._isNewRowEnabled=e,this._emptyRowDraft=null,this.requestUpdate()}get newRowPosition(){return this._newRowPosition}set newRowPosition(e){this._newRowPosition=e,this.requestUpdate()}get newRowIndicator(){return this._newRowIndicator}set newRowIndicator(e){this._newRowIndicator=e,this.requestUpdate()}get createEmptyRowCallback(){return this._createEmptyRowCallback}set createEmptyRowCallback(e){this._createEmptyRowCallback=e}get idMember(){return this._idMember}set idMember(e){this._idMember=e||null,this.maybeWarnAboutRowIdentity()}getStableRowKey(e,o){if(this._idMember){const i=e[this._idMember];if(i!=null)return String(i)}if(this._treePathMember){const i=e[this._treePathMember];if(i!=null)return String(i)}return String(o)}maybeWarnAboutRowIdentity(){this._hasWarnedAboutMissingRowId||this._isEditable&&(this._idMember||this._treePathMember||(this._hasWarnedAboutMissingRowId=!0,console.warn("[WebGrid] editable grid has no `idMember` (and no `treePathMember`). Internal state (drafts, invalid-cell markers) will be keyed by displayed index, so re-ordering (sort, filter, pagination) can move state to the wrong row. Set `idMember` to the field that uniquely identifies each row.")))}get treePathMember(){return this._treePathMember}set treePathMember(e){this._treePathMember=e||null,this.rebuildTreeState(),this.requestUpdate()}get treeLevelMember(){return this._treeLevelMember}set treeLevelMember(e){this._treeLevelMember=e||null,this.rebuildTreeState(),this.requestUpdate()}get treeParentMember(){return this._treeParentMember}set treeParentMember(e){this._treeParentMember=e||null,this.rebuildTreeState(),this.requestUpdate()}get treeSeparator(){return this._treeSeparator}set treeSeparator(e){this._treeSeparator=e||null,this.rebuildTreeState(),this.requestUpdate()}get treeDataSorted(){return this._treeDataSorted}set treeDataSorted(e){this._treeDataSorted=e,this.requestUpdate()}get expandedPaths(){return this._expandedPaths}set expandedPaths(e){this._expandedPathsExternal=e instanceof Set?e:null,this.rebuildExpandedPaths(),this.requestUpdate()}get defaultExpandDepth(){return this._defaultExpandDepth}set defaultExpandDepth(e){this._defaultExpandDepth=typeof e=="number"&&e>=0?e:null,this._expandedPathsExternal||(this.rebuildExpandedPaths(),this.requestUpdate())}get onexpandedpathschange(){return this._onexpandedpathschange}set onexpandedpathschange(e){this._onexpandedpathschange=e}get isTreeMode(){return!!this._treePathMember&&!!this._treeIndex}isPathExpanded(e){return this._expandedPaths.has(e)}toggleExpandedPath(e){var i,r;const o=this._expandedPaths.has(e);$t.debug("toggleExpandedPath start:",e,"| willExpand:",!o,"| _items.length:",this._items.length,"| treeNodes:",((i=this._treeIndex)==null?void 0:i.nodes.size)??0),o?this._expandedPaths.delete(e):this._expandedPaths.add(e),Le.debug("tree toggle:",e,o?"expanded → collapsed":"collapsed → expanded","| set size now:",this._expandedPaths.size),(r=this._onexpandedpathschange)==null||r.call(this,{path:e,expanded:!o,expandedPaths:this._expandedPaths}),this.requestUpdate()}expandAll(){if(this._treeIndex){this._expandedPaths.clear();for(const e of this._treeIndex.nodes.keys())this._expandedPaths.add(e);Le.debug("tree expandAll: size =",this._expandedPaths.size),this.requestUpdate()}}collapseAll(){this._expandedPaths.clear(),Le.debug("tree collapseAll"),this.requestUpdate()}expandSubtree(e){if(!this._treeIndex||!this._treeIndex.nodes.get(e))return;const i=[e];for(;i.length;){const r=i.shift();this._expandedPaths.add(r);const s=this._treeIndex.nodes.get(r);s&&i.push(...s.childPaths)}this.requestUpdate()}collapseSubtree(e){if(!this._treeIndex||!this._treeIndex.nodes.get(e))return;const i=[e];for(;i.length;){const r=i.shift();this._expandedPaths.delete(r);const s=this._treeIndex.nodes.get(r);s&&i.push(...s.childPaths)}this.requestUpdate()}findNearestExpandedAncestor(e){var i,r;if(!this._treeIndex)return null;let o=((i=this._treeIndex.nodes.get(e))==null?void 0:i.parent)??null;for(;o!==null;){if(this._expandedPaths.has(o))return o;o=((r=this._treeIndex.nodes.get(o))==null?void 0:r.parent)??null}return null}getRowTreeInfo(e){if(!this.isTreeMode)return null;const o=this.getRowTreePath(e);if(!o)return null;const i=this._treeIndex.nodes.get(o);return i?{path:o,level:i.level,hasChildren:i.childPaths.length>0}:null}get treeDoubleClickBehavior(){return this._treeDoubleClickBehavior}set treeDoubleClickBehavior(e){this._treeDoubleClickBehavior=e||"none"}get treeExpandedGlyph(){return this._treeExpandedGlyph}set treeExpandedGlyph(e){this._treeExpandedGlyph=e??"▶",this.requestUpdate()}get treeCollapsedGlyph(){return this._treeCollapsedGlyph}set treeCollapsedGlyph(e){this._treeCollapsedGlyph=e??"▶",this.requestUpdate()}get treeChevronCallback(){return this._treeChevronCallback}set treeChevronCallback(e){this._treeChevronCallback=e,this._treeChevronCache=new WeakMap,this.requestUpdate()}getTreeChevronHtml(e,o,i,r,s){const n=this._treeChevronCallback;if(!n)return i?o?this._treeExpandedGlyph:this._treeCollapsedGlyph:"";const l=e;let a=this._treeChevronCache.get(l);a||(a=new Map,this._treeChevronCache.set(l,a));const d=`${o?"e":"c"}|${i?"1":"0"}`;let c=a.get(d);return c===void 0&&(c=n({expanded:o,hasChildren:i,row:e,level:r,path:s}),a.set(d,c)),c}getRowTreePath(e){if(!this._treePathMember)return null;const o=e[this._treePathMember];if(o==null)return null;const i=String(o);return i===""?null:i}detectTreeSeparator(e){return e.includes("/")?"/":e.includes("\\")?"\\":(e.includes("."),".")}rebuildTreeState(){if(!this._treePathMember||this._items.length===0){this._treeIndex=null,this.rebuildExpandedPaths();return}let e=this._treeSeparator;if(!e){for(const r of this._items){const s=this.getRowTreePath(r);if(s){e=this.detectTreeSeparator(s);break}}e=e||"."}const o=new Map;for(let r=0;r<this._items.length;r++){const s=this._items[r],n=this.getRowTreePath(s);if(!n)continue;let l=0;if(this._treeLevelMember){const d=s[this._treeLevelMember];typeof d=="number"&&(l=d)}else l=Math.max(0,n.split(e).filter(Boolean).length-1);let a=null;if(this._treeParentMember){const d=s[this._treeParentMember];a=d==null||d===""?null:String(d)}else{const d=n.endsWith(e)?n.slice(0,-e.length):n,c=d.lastIndexOf(e);a=c<0?null:d.slice(0,c)||null}o.set(n,{path:n,parent:a,level:l,rowIndex:r,childPaths:[]})}const i=[];for(const r of o.values())r.parent&&o.has(r.parent)?o.get(r.parent).childPaths.push(r.path):i.push(r.path);this._treeIndex={separator:e,nodes:o,rootPaths:i},this.rebuildExpandedPaths()}rebuildExpandedPaths(){if(this._expandedPathsExternal){this._expandedPaths=this._expandedPathsExternal;return}const e=new Set;if(this._treeIndex)if(this._defaultExpandDepth!==null)for(const o of this._treeIndex.nodes.values())o.level<this._defaultExpandDepth&&e.add(o.path);else for(const o of this._treeIndex.nodes.keys())e.add(o);this._expandedPaths=e}compareTreeNodes(e,o){const i=this._items[e.rowIndex],r=this._items[o.rowIndex];for(const s of this._sort){const n=i[s.column],l=r[s.column];if(n===l)continue;let a=0;return typeof n=="string"&&typeof l=="string"?a=n.localeCompare(l):typeof n=="number"&&typeof l=="number"?a=n-l:a=String(n??"").localeCompare(String(l??"")),s.direction==="asc"?a:-a}return e.path.localeCompare(o.path)}getTreeFilterAllowedPaths(){var r,s;if(!this._treeIndex||!this._isFilterable)return null;const e=Object.entries(this._filters).filter(([,n])=>!!n);if(e.length===0)return null;const o=new Set;for(const n of this._treeIndex.nodes.values()){const l=this._items[n.rowIndex];let a=!0;for(const[d,c]of e)if(!String(l[d]??"").toLowerCase().includes(c.toLowerCase())){a=!1;break}a&&o.add(n.path)}const i=new Set(o);for(const n of o){let l=((r=this._treeIndex.nodes.get(n))==null?void 0:r.parent)??null;for(;l&&!i.has(l);)i.add(l),l=((s=this._treeIndex.nodes.get(l))==null?void 0:s.parent)??null}return i}getTreeSortedItems(){const e=performance.now();if(ie.counters.treeSorted++,!this._treeIndex)return ie.counters.treeSortedMs+=performance.now()-e,this._items;const o=this.getTreeFilterAllowedPaths();if(this._treeDataSorted){const n=[];for(let l=0;l<this._items.length;l++){const a=this._items[l],d=this.getRowTreePath(a);d&&(o&&!o.has(d)||n.push(a))}return ie.counters.treeSortedMs+=performance.now()-e,n}const i=this._treeIndex,r=[],s=n=>{const l=o?n.filter(a=>o.has(a)):[...n];l.sort((a,d)=>this.compareTreeNodes(i.nodes.get(a),i.nodes.get(d)));for(const a of l){const d=i.nodes.get(a);r.push(this._items[d.rowIndex]),d.childPaths.length>0&&s(d.childPaths)}};return s(i.rootPaths),ie.counters.treeSortedMs+=performance.now()-e,r}getTreeVisibleItems(){const e=performance.now();if(ie.counters.treeVisible++,!this._treeIndex)return ie.counters.treeVisibleMs+=performance.now()-e,this._items;const o=this.getTreeSortedItems(),i=this._treeIndex,r=this.getTreeFilterAllowedPaths()!==null,s=[];for(const n of o){const l=this.getRowTreePath(n);if(!l){s.push(n);continue}const a=i.nodes.get(l);if(!a){s.push(n);continue}let d=!0,c=a.parent;for(;c;){if(!this.isPathExpanded(c)&&!r){d=!1;break}const u=i.nodes.get(c);c=u?u.parent:null}d&&s.push(n)}return ie.counters.treeVisibleMs+=performance.now()-e,s}selectCellRange(e){if(Le.debug("selectCellRange:",{startRow:e.startRowIndex,startCol:e.startColIndex,endRow:e.endRowIndex,endCol:e.endColIndex}),this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null),this._selectedColumns.clear(),this._selectedCellRange=e,this.requestUpdate(),this._oncellselectionchange){const o=this.getSelectedCells();this._oncellselectionchange({range:e,cellCount:o.length})}}clearCellSelection(){this._selectedCellRange&&(this._selectedCellRange=null,this.requestUpdate(),this._oncellselectionchange&&this._oncellselectionchange({range:null,cellCount:0}))}clearCellSelection_noRender(){this._selectedCellRange&&(this._selectedCellRange=null,this._oncellselectionchange&&this._oncellselectionchange({range:null,cellCount:0}))}selectAll(){const e=this.displayItems.length,o=this.visualColumns.length;if(e===0||o===0)return;const i=this.visualColumns[0],r=this.visualColumns[o-1],s={startRowIndex:0,startColIndex:0,endRowIndex:e-1,endColIndex:o-1,startField:String(i.column.field),endField:String(r.column.field)};this.selectCellRange(s)}selectColumn(e,o="replace"){const i=this.visualColumns.length;if(!(e<0||e>=i)){if(this._selectedRows.clear(),this._selectedCellRange=null,o==="replace")this._selectedColumns.clear(),this._selectedColumns.add(e),this._lastSelectedColumnIndex=e;else if(o==="toggle")this._selectedColumns.has(e)?this._selectedColumns.delete(e):this._selectedColumns.add(e),this._lastSelectedColumnIndex=e;else if(o==="range"){const r=this._lastSelectedColumnIndex>=0?this._lastSelectedColumnIndex:e,s=Math.min(r,e),n=Math.max(r,e);for(let l=s;l<=n;l++)this._selectedColumns.add(l)}this.requestUpdate()}}clearColumnSelection(){this._selectedColumns.clear(),this._lastSelectedColumnIndex=-1,this.requestUpdate()}clearColumnSelection_noRender(){this._selectedColumns.clear(),this._lastSelectedColumnIndex=-1}selectColumnRange(e,o){this._selectedRows.clear(),this._selectedCellRange=null,this._selectedColumns.clear();const i=Math.min(e,o),r=Math.max(e,o);for(let s=i;s<=r;s++)this._selectedColumns.add(s);this._lastSelectedColumnIndex=o,this.requestUpdate()}get selectedColumns(){return Array.from(this._selectedColumns).sort((e,o)=>e-o)}isColumnSelected(e){return this._selectedColumns.has(e)}getSelectedCells(){var c;if(!this._selectedCellRange)return[];const{startRowIndex:e,endRowIndex:o,startColIndex:i,endColIndex:r}=this._selectedCellRange,s=Math.min(e,o),n=Math.max(e,o),l=Math.min(i,r),a=Math.max(i,r),d=[];for(let u=s;u<=n;u++)for(let h=l;h<=a;h++){const g=(c=this.visualColumns[h])==null?void 0:c.column;if(!g)continue;const f=this.displayItems[u];if(!f)continue;const w=String(g.field),p=f[w];d.push({row:f,rowIndex:u,colIndex:h,field:w,value:p})}return d}isCellInSelectedRange(e,o){if(!this._selectedCellRange)return!1;const{startRowIndex:i,endRowIndex:r,startColIndex:s,endColIndex:n}=this._selectedCellRange,l=Math.min(i,r),a=Math.max(i,r),d=Math.min(s,n),c=Math.max(s,n);return e>=l&&e<=a&&o>=d&&o<=c}async copyCellSelectionToClipboard(){var u,h;if(!this._selectedCellRange)return!1;const{startRowIndex:e,endRowIndex:o,startColIndex:i,endColIndex:r}=this._selectedCellRange,s=Math.min(e,o),n=Math.max(e,o),l=Math.min(i,r),a=Math.max(i,r),d=[];if(this._shouldCopyWithHeaders){const g=[];for(let f=l;f<=a;f++){const w=(u=this.visualColumns[f])==null?void 0:u.column,p=(w==null?void 0:w.title)??(w==null?void 0:w.field)??"";g.push(String(p))}d.push(g.join(" "))}for(let g=s;g<=n;g++){const f=this.displayItems[g];if(!f)continue;const w=[];for(let p=l;p<=a;p++){const m=(h=this.visualColumns[p])==null?void 0:h.column;if(!m){w.push("");continue}const _=String(m.field),y=f[_],C=y==null?"":String(y);w.push(C)}d.push(w.join(" "))}const c=d.join(`
299
+ `);try{return await navigator.clipboard.writeText(c),!0}catch{return!1}}get isNavigateMode(){return this._editTrigger==="navigate"||this._columns.some(e=>e.editTrigger==="navigate")}get filteredItems(){return this._onfilterchange?this._items:!this._isFilterable||Object.keys(this._filters).length===0?this._items:this._items.filter(e=>Object.entries(this._filters).every(([o,i])=>{if(!i)return!0;const r=this._columns.find(n=>String(n.field)===o);if(r!=null&&r.filter){const n=r.filter(i,e);return n===null?!0:n}return String(e[o]??"").toLowerCase().includes(i.toLowerCase())}))}getInvalidFilterFields(){const e=new Set,o=this._items[0];if(!o)return e;for(const[i,r]of Object.entries(this._filters)){if(!r)continue;const s=this._columns.find(n=>String(n.field)===i);s!=null&&s.filter&&s.filter(r,o)===null&&e.add(i)}return e}get filters(){return{...this._filters}}set filters(e){var o;this._filters={...e},(o=this._onfilterchange)==null||o.call(this,{...this._filters}),this.requestUpdate()}setFilter(e,o){var i;if(o)this._filters={...this._filters,[e]:o};else{const r={...this._filters};delete r[e],this._filters=r}(i=this._onfilterchange)==null||i.call(this,{...this._filters}),this.requestUpdate()}get sortedItems(){return this.isTreeMode?this.getTreeSortedItems():this._sort.length===0?this.filteredItems:[...this.filteredItems].sort((e,o)=>{for(const i of this._sort){const r=e[i.column],s=o[i.column];if(r===s)continue;let n=0;return typeof r=="string"&&typeof s=="string"?n=r.localeCompare(s):typeof r=="number"&&typeof s=="number"?n=r-s:n=String(r??"").localeCompare(String(s??"")),i.direction==="asc"?n:-n}return 0})}get paginatedItems(){if(this._paginatedItemsCache!==null)return this._paginatedItemsCache;const e=performance.now();ie.counters.paginatedItems++;const o=this.isTreeMode?this.getTreeVisibleItems():this.sortedItems;let i;if(!this._isPageable)i=o;else if(this._paginationMode==="server")i=o;else{const r=(this._currentPage-1)*this._pageSize,s=r+this._pageSize;i=o.slice(r,s)}return this._paginatedItemsCache=i,ie.counters.paginatedItemsMs+=performance.now()-e,i}get totalPages(){let e;return this._totalItems!==null?e=this._totalItems:this.isTreeMode?e=this.getTreeVisibleItems().length:e=this.sortedItems.length,Math.max(1,Math.ceil(e/this._pageSize))}get displayItems(){if(this._displayItemsCache!==null)return this._displayItemsCache;const e=performance.now();ie.counters.displayItems++;const o=this.paginatedItems;let i;if(!this._isNewRowEnabled)i=o;else{const r=this.getEmptyRow();i=this._newRowPosition==="top"?[r,...o]:[...o,r]}return this._displayItemsCache=i,ie.counters.displayItemsMs+=performance.now()-e,i}getEmptyRow(){if(this._emptyRowDraft)return this._emptyRowDraft;const e=this.createNewEmptyRow();return this._emptyRowDraft=e,e}createNewEmptyRow(){if(this._createEmptyRowCallback){const o=this._createEmptyRowCallback();return o instanceof Promise?(o.then(i=>{this._emptyRowDraft=i,this.requestUpdate()}).catch(i=>{console.warn("WebGrid: createEmptyRowCallback failed",i)}),{}):o}const e={};for(const o of this._columns)e[String(o.field)]=null;return e}isEmptyRowIndex(e){return this._isNewRowEnabled?this._newRowPosition==="top"?e===0:e===this.paginatedItems.length:!1}getDataIndexFromDisplayIndex(e){return this._isNewRowEnabled&&this._newRowPosition==="top"?e-1:e}emptyRowHasData(e){for(const o of this._columns){const i=e[String(o.field)];if(i!=null&&i!=="")return!0}return!1}fireDataRequest(e){if(this._ondatarequest){const o=e==="loadMore"?this._items.length:(this._currentPage-1)*this._pageSize,i={sort:[...this._sort],page:this._currentPage,pageSize:this._pageSize,trigger:e,mode:e==="loadMore"?"append":"replace",skip:o};gt.debug("fireDataRequest:",e,i),this._ondatarequest(i)}}getColumnSortState(e){return this._sort.find(o=>o.column===e)}getColumnSortPriority(e){const o=this._sort.findIndex(i=>i.column===e);return o>=0?o+1:0}applyModeDefaults(){switch(this._mode){case"read-only":this._isEditable=!1,this._dropdownToggleVisibility="on-focus",this._cellSelectionMode="click";break;case"excel":this._isEditable=!0,this._editTrigger="navigate",this._dropdownToggleVisibility="always",this._shouldShowDropdownOnFocus=!1,this._cellSelectionMode="click";break;case"input-matrix":this._isEditable=!0,this._editTrigger="always",this._dropdownToggleVisibility="always",this._shouldShowDropdownOnFocus=!0,this._cellSelectionMode="shift";break}}checkSelectionConflicts(){this._cellSelectionMode==="click"&&this._editTrigger==="click"&&console.warn('WebGrid: cellSelectionMode="click" conflicts with editTrigger="click". Cell range selection takes priority. Use Shift+click to enter edit mode, or change to cellSelectionMode="shift" to avoid confusion.')}checkEditTriggerConflicts(){!this._isEditable&&this._editTrigger==="always"&&console.warn(`%cWebGrid: editTrigger="always" is not supported in read-only mode (isEditable=false).
300
300
  Supported editTrigger values in read-only mode: "navigate", "click", "dblclick".
301
- The grid may behave unexpectedly.`,"font-size: 14px; font-weight: bold;")}checkToolbarConflicts(){const t=this._toolbarPosition,o=t==="top"||t==="inline",i=t==="top",r="font-size: 14px; font-weight: bold;";this._toolbarVerticalAlign!=="bottom"&&o&&console.warn(`%cWebGrid: toolbarVerticalAlign="${this._toolbarVerticalAlign}" has no effect with toolbarPosition="${t}".
302
- verticalAlign only applies to side positions: "left", "right", or "auto".`,r),this._toolbarHorizontalAlign!=="center"&&!i&&console.warn(`%cWebGrid: toolbarHorizontalAlign="${this._toolbarHorizontalAlign}" has no effect with toolbarPosition="${t}".
303
- horizontalAlign only applies to toolbarPosition="top".`,r),this._toolbarColumn!==void 0&&!i&&console.warn(`%cWebGrid: toolbarColumn has no effect with toolbarPosition="${t}".
304
- toolbarColumn only applies to toolbarPosition="top".`,r),this._toolbarFollowsCursor&&!i&&console.warn(`%cWebGrid: toolbarFollowsCursor has no effect with toolbarPosition="${t}".
305
- toolbarFollowsCursor only applies to toolbarPosition="top".`,r),this._cellToolbar!==void 0&&!i&&console.warn(`%cWebGrid: cellToolbar has no effect with toolbarPosition="${t}".
301
+ The grid may behave unexpectedly.`,"font-size: 14px; font-weight: bold;")}checkToolbarConflicts(){const e=this._toolbarPosition,o=e==="top"||e==="inline",i=e==="top",r="font-size: 14px; font-weight: bold;";this._toolbarVerticalAlign!=="bottom"&&o&&console.warn(`%cWebGrid: toolbarVerticalAlign="${this._toolbarVerticalAlign}" has no effect with toolbarPosition="${e}".
302
+ verticalAlign only applies to side positions: "left", "right", or "auto".`,r),this._toolbarHorizontalAlign!=="center"&&!i&&console.warn(`%cWebGrid: toolbarHorizontalAlign="${this._toolbarHorizontalAlign}" has no effect with toolbarPosition="${e}".
303
+ horizontalAlign only applies to toolbarPosition="top".`,r),this._toolbarColumn!==void 0&&!i&&console.warn(`%cWebGrid: toolbarColumn has no effect with toolbarPosition="${e}".
304
+ toolbarColumn only applies to toolbarPosition="top".`,r),this._toolbarFollowsCursor&&!i&&console.warn(`%cWebGrid: toolbarFollowsCursor has no effect with toolbarPosition="${e}".
305
+ toolbarFollowsCursor only applies to toolbarPosition="top".`,r),this._cellToolbar!==void 0&&!i&&console.warn(`%cWebGrid: cellToolbar has no effect with toolbarPosition="${e}".
306
306
  cellToolbar requires toolbarPosition="top".`,r),this._toolbarFollowsCursor&&this._toolbarColumn!==void 0&&console.warn(`%cWebGrid: toolbarColumn and toolbarFollowsCursor are both set.
307
- toolbarColumn takes priority — cursor following is disabled.`,r)}requestUpdate(){}getRowDraft(t){return this._draftRows.get(t)}hasRowDraft(t){return this._draftRows.has(t)}isCellDirty(t,o){const i=this._draftRows.get(t);if(!i)return!1;const r=this.displayItems[t];if(!r)return!1;const s=i[o],n=r[o];return s!==n}isRowDirty(t){return this._draftRows.has(t)}discardRowDraft(t){this._draftRows.delete(t),this._invalidCells=this._invalidCells.filter(o=>o.rowIndex!==t),this.requestUpdate()}discardCellDraft(t,o){const i=this._draftRows.get(t);if(!i)return;const r=this.displayItems[t];if(!r)return;const s=r[o];i[o]=s;const n=Object.keys(i);let l=!1;for(const a of n){const d=i[a],c=r[a];if(d!==c){l=!0;break}}l||this._draftRows.delete(t),this._invalidCells=this._invalidCells.filter(a=>!(a.rowIndex===t&&a.field===o))}getDraftRowIndices(){return Array.from(this._draftRows.keys())}discardAllDrafts(){this._draftRows.clear(),this._invalidCells=[],this.requestUpdate()}getCellRawValue(t,o,i){if(!this.isEmptyRowIndex(o)){const r=this._draftRows.get(o);if(r)return r[i]}return t[i]}getCellValue(t,o,i){var s;if(o.templateCallback)return o.templateCallback(t);const r=i!==void 0?this.getCellRawValue(t,i,String(o.field)):t[String(o.field)];if(o.formatCallback)return o.formatCallback(r,t);if(o.editor==="date"&&((s=o.editorOptions)!=null&&s.dateFormat)&&r)try{const n=r instanceof Date?r:new Date(r);if(!isNaN(n.getTime())){const l=Et(o.editorOptions.dateFormat);return Zt(n,l)}}catch{}return String(r??"")}isCellInvalid(t,o){return this._invalidCells.some(i=>i.rowIndex===t&&i.field===o)}getCellValidationError(t,o){const i=this._invalidCells.find(r=>r.rowIndex===t&&r.field===o);return(i==null?void 0:i.error)||null}addInvalidCell(t,o,i){const r=this._invalidCells.findIndex(s=>s.rowIndex===t&&s.field===o);r>=0?this._invalidCells[r]={rowIndex:t,field:o,error:i}:this._invalidCells=[...this._invalidCells,{rowIndex:t,field:o,error:i}]}removeInvalidCell(t,o){this._invalidCells=this._invalidCells.filter(i=>!(i.rowIndex===t&&i.field===o))}isEditing(t,o){var i,r;return((i=this._editingCell)==null?void 0:i.rowIndex)===t&&((r=this._editingCell)==null?void 0:r.field)===o}shouldShowEditor(t,o){const i=this._columns[o];if(!i)return!1;const r=String(i.field);return!!(this.isEditing(t,r)||(i.editTrigger??this._editTrigger)==="always"&&this.isCellEditable(i))}startEdit(t,o,i){var n,l;if(!this.canEditCell(t,o)){dt.debug("startEdit blocked (locked):",{rowIndex:t,field:o});return}dt.debug("startEdit:",{rowIndex:t,field:o,options:i});const r=this.displayItems[t];if(!r)return;this._draftRows.has(t)||this._draftRows.set(t,{...r});const s=this._editingCell;this._editingCell={rowIndex:t,field:o,initialSearchQuery:i==null?void 0:i.initialSearchQuery,cursorPosition:i==null?void 0:i.cursorPosition},(n=this._onInteractionChange)==null||n.call(this,"editingCell",{prev:s,current:this._editingCell}),this._currentCellError=null,(l=this._onroweditstart)==null||l.call(this,{row:r,rowIndex:t,field:o})}cancelEdit(){var t,o;if(this._editingCell){const i=this._editingCell,{rowIndex:r,field:s}=i,n=this.displayItems[r];n&&((t=this._onroweditcancel)==null||t.call(this,{row:n,rowIndex:r,field:s})),this._editingCell=null,(o=this._onInteractionChange)==null||o.call(this,"editingCell",{prev:i,current:null}),this._currentCellError=null}}normalizeValidationResult(t,o){return t==null||t===!0?{valid:!0,finalValue:o}:t===!1?{valid:!1,message:"Validation failed",finalValue:o}:typeof t=="string"?{valid:!1,message:t,finalValue:o}:{valid:t.valid,message:t.message,finalValue:t.transformedValue!==void 0?t.transformedValue:o}}async commitEdit(t,o,i,r=!1){var f,w,p,m,v,y,x;at.debug("commitEdit:",{rowIndex:t,field:o,newValue:i});const s=this._columns.find(C=>String(C.field)===o);if(!s)return;const n=this.displayItems[t];if(!n)return;const l=this.isEmptyRowIndex(t),a=n[o];let d=i,c=null,u=!0;this._isValidating=!0;try{if(s.beforeCommitCallback){const C={value:i,oldValue:a,row:n,rowIndex:t,field:o},_=await Promise.resolve(s.beforeCommitCallback(C)),S=this.normalizeValidationResult(_,i);u=S.valid,c=S.message||null,d=S.finalValue}else if(s.validateCallback){const C=await Promise.resolve(s.validateCallback(i,n));C&&(u=!1,c=C)}}catch(C){u=!1,c=C instanceof Error?C.message:"Validation failed"}if(this._isValidating=!1,l){if(this._emptyRowDraft||(this._emptyRowDraft={...n}),this._emptyRowDraft[o]=d,u?(this.removeInvalidCell(t,o),this._currentCellError=null):(this.addInvalidCell(t,o,c||"Invalid value"),this._currentCellError=c,(f=this._onvalidationerror)==null||f.call(this,{row:n,rowIndex:t,field:o,error:c||"Invalid value"})),r&&this.emptyRowHasData(this._emptyRowDraft)){const S={...this._emptyRowDraft},k=this._newRowPosition==="top"?0:this._items.length;this._invalidCells=this._invalidCells.map(I=>I.rowIndex===t?{...I,rowIndex:k}:this._newRowPosition==="top"?{...I,rowIndex:I.rowIndex+1}:I),this._newRowPosition==="top"?this._items=[S,...this._items]:this._items=[...this._items,S];const E=this._invalidCells.some(I=>I.rowIndex===k);(w=this._onrowchange)==null||w.call(this,{row:S,draftRow:S,rowIndex:k,field:o,oldValue:null,newValue:d,isValid:!E,validationError:E?"Row has invalid cells":null}),this._emptyRowDraft=null;const R=this._editingCell;this._editingCell=null,(p=this._onInteractionChange)==null||p.call(this,"editingCell",{prev:R,current:null}),this.requestUpdate();return}const C=this._editingCell;this._editingCell=null,(m=this._onInteractionChange)==null||m.call(this,"editingCell",{prev:C,current:null});return}let g=this._draftRows.get(t);g||(g={...n},this._draftRows.set(t,g)),g[o]=d,u?(this.removeInvalidCell(t,o),this._currentCellError=null):(this.addInvalidCell(t,o,c||"Invalid value"),this._currentCellError=c,(v=this._onvalidationerror)==null||v.call(this,{row:n,rowIndex:t,field:o,error:c||"Invalid value"})),(y=this._onrowchange)==null||y.call(this,{row:n,draftRow:g,rowIndex:t,field:o,oldValue:a,newValue:d,isValid:u,validationError:c});const h=this._editingCell;this._editingCell=null,(x=this._onInteractionChange)==null||x.call(this,"editingCell",{prev:h,current:null})}updateDraftValue(t,o,i){var a;if(!this._columns.find(d=>String(d.field)===o))return;const s=this.displayItems[t];if(!s)return;const n=this.getCellRawValue(s,t,o);if(this.isEmptyRowIndex(t))this._emptyRowDraft||(this._emptyRowDraft={...s}),this._emptyRowDraft[o]=i;else{let d=this._draftRows.get(t);d||(d={...s},this._draftRows.set(t,d)),d[o]=i}const l=this._draftRows.get(t)||this._emptyRowDraft||s;(a=this._onrowchange)==null||a.call(this,{row:s,draftRow:l,rowIndex:t,field:o,oldValue:n,newValue:i,isValid:!0,validationError:null})}isCellEditable(t){return t.isEditable===!1?!1:t.isEditable===!0?!0:this._isEditable}getEditableColumns(){return this._columns.map((t,o)=>({index:o,column:t})).filter(({column:t})=>this.isCellEditable(t))}isCellFocused(t,o){var i,r;return((i=this._focusedCell)==null?void 0:i.rowIndex)===t&&((r=this._focusedCell)==null?void 0:r.colIndex)===o}get focusedCell(){return this._focusedCell}setFocusedCell(t,o){var s;const i=this._focusedCell,r={rowIndex:t,colIndex:o};(i==null?void 0:i.rowIndex)===r.rowIndex&&(i==null?void 0:i.colIndex)===r.colIndex||(this._focusedCell=r,(s=this._onInteractionChange)==null||s.call(this,"focusedCell",{prev:i,current:r}))}clearFocusedCell(){var o;const t=this._focusedCell;t!==null&&(this._focusedCell=null,(o=this._onInteractionChange)==null||o.call(this,"focusedCell",{prev:t,current:null}))}get tabTraversalStartColIndex(){return this._tabTraversalStartColIndex}set tabTraversalStartColIndex(t){this._tabTraversalStartColIndex=t}setHoveredRow(t){var i;if(this._hoveredRowIndex===t)return;const o=this._hoveredRowIndex;this._hoveredRowIndex=t,(i=this._onInteractionChange)==null||i.call(this,"hoveredRow",{prev:o,current:t})}get focusedRowIndex(){return this._focusedRowIndex}set focusedRowIndex(t){t===null?this.clearRowFocus():this.setFocusedRow(t),this.requestUpdate()}get onrowfocus(){return this._onrowfocus}set onrowfocus(t){this._onrowfocus=t}isRowFocused(t){return this._focusedRowIndex===t}clearRowFocus(){var o;if(this._focusedRowIndex===null)return;const t=this._focusedRowIndex;this._focusedRowIndex=null,(o=this._onInteractionChange)==null||o.call(this,"focusedRow",{prev:t,current:null})}setFocusedRow(t){var r;if(this._focusedRowIndex===t)return;dt.debug("setFocusedRow:",t,"(prev:",this._focusedRowIndex,")");const o=this._focusedRowIndex;this._focusedRowIndex=t,(r=this._onInteractionChange)==null||r.call(this,"focusedRow",{prev:o,current:t});const i=this.displayItems[t];i&&this._onrowfocus&&this._onrowfocus({rowIndex:t,row:i,previousRowIndex:o})}getRowId(t){if(this._idValueCallback)return this._idValueCallback(t);if(this._idValueMember)return t[String(this._idValueMember)]}findRowById(t){const o=this._items.findIndex(i=>this.getRowId(i)===t);return o===-1?null:{row:this._items[o],index:o}}getRowLockInfo(t){let o,i,r=-1;if(typeof t=="object"&&t!==null)o=t,i=this.getRowId(o),r=this._items.indexOf(o),r===-1&&(r=this.displayItems.indexOf(o));else{i=t;const n=this.findRowById(i);n&&(o=n.row,r=n.index)}if(i!==void 0&&this._externalLocks.has(i))return this._externalLocks.get(i);if(!o)return null;const s=this._rowLocking;if(!s)return null;if(s.getLockInfoCallback){const n=s.getLockInfoCallback(o,r);if(n!=null&&n.isLocked)return n}if(s.isLockedCallback&&s.isLockedCallback(o,r))return{isLocked:!0};if(s.lockInfoMember){const n=o[String(s.lockInfoMember)];if(n!=null&&n.isLocked)return n}return s.lockedMember&&o[String(s.lockedMember)]?{isLocked:!0}:null}isRowLocked(t){const o=this.getRowLockInfo(t);return(o==null?void 0:o.isLocked)===!0}lockRowById(t,o){var s;const i={isLocked:!0,lockedBy:o==null?void 0:o.lockedBy,lockedAt:(o==null?void 0:o.lockedAt)??new Date,reason:o==null?void 0:o.reason,...o};this._externalLocks.set(t,i);const r=this.findRowById(t);return r&&this._editingCell&&this._editingCell.rowIndex===r.index&&this.cancelEdit(),this.requestUpdate(),(s=this._onrowlockchange)==null||s.call(this,{rowId:t,row:(r==null?void 0:r.row)??null,rowIndex:(r==null?void 0:r.index)??-1,lockInfo:i,source:"external"}),!0}unlockRowById(t){var i;const o=this._externalLocks.has(t);if(this._externalLocks.delete(t),o){this.requestUpdate();const r=this.findRowById(t);(i=this._onrowlockchange)==null||i.call(this,{rowId:t,row:(r==null?void 0:r.row)??null,rowIndex:(r==null?void 0:r.index)??-1,lockInfo:null,source:"external"})}return o}getExternalLocks(){return new Map(this._externalLocks)}clearExternalLocks(){this._externalLocks.clear(),this.requestUpdate()}updateRowById(t,o){const i=this.findRowById(t);if(!i)return!1;Object.assign(this._items[i.index],o);const r=this._draftRows.get(i.index);return r&&Object.assign(r,o),this.requestUpdate(),!0}replaceRowById(t,o){const i=this.findRowById(t);return i?(this._items[i.index]=o,this._draftRows.delete(i.index),this.requestUpdate(),!0):!1}canEditCell(t,o){var a;const i=this._columns.find(d=>String(d.field)===o);if(!i||!this.isCellEditable(i))return!1;const r=this.displayItems[t];if(!r)return!1;const s=this.getRowLockInfo(r);if(!(s!=null&&s.isLocked))return!0;const n=this._rowLocking;switch((n==null?void 0:n.lockedEditBehavior)??"block"){case"allow":return!0;case"callback":return((a=n==null?void 0:n.canEditLockedCallback)==null?void 0:a.call(n,r,s))??!1;case"block":default:return!1}}getColumnWidth(t){return this._columnWidths.get(t)}setColumnWidth(t,o,i=!1){this._columnWidths.set(t,o),i||this.requestUpdate()}setColumnWidths(t){for(const{field:o,width:i}of t)o&&i&&this._columnWidths.set(o,i);this.requestUpdate()}getColumnWidthsState(){return this._columns.map(t=>{const o=String(t.field),i=this._columnWidths.get(o)||t.width||"";return{field:o,width:i}}).filter(t=>t.width)}loadPersistedWidths(){this.loadPersistedState()}savePersistedWidths(){this.savePersistedState()}loadPersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const t=`wg-${this._gridName}-state`,o=localStorage.getItem(t);if(!o)return;const i=JSON.parse(o),r=new Set(this._columns.map(n=>String(n.field)));let s=!1;if(i.columnWidths){this._columnWidths.clear();for(const n of i.columnWidths)r.has(n.field)?this._columnWidths.set(n.field,n.width):s=!0}if(i.columnOrder){this._columnOrder.clear();for(const n of i.columnOrder)r.has(n.field)?this._columnOrder.set(n.field,n.order):s=!0}s&&this.savePersistedState()}catch(t){console.warn("WebGrid: Failed to load persisted state",t)}}savePersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const t=`wg-${this._gridName}-state`,o={};this._shouldPersistColumnWidths&&(o.columnWidths=this.getColumnWidthsState()),this._shouldPersistColumnOrder&&(o.columnOrder=this.getColumnOrderState()),localStorage.setItem(t,JSON.stringify(o))}catch(t){console.warn("WebGrid: Failed to save persisted state",t)}}getColumnOrder(t){return this._columnOrder.get(t)}setColumnOrder(t){this._columnOrder.clear();for(const{field:o,order:i}of t)o!==void 0&&i!==void 0&&this._columnOrder.set(o,i);this.requestUpdate()}getColumnOrderState(){const t=this.visualColumns,o=this.totalFrozenColumns;return t.slice(o).map((i,r)=>({field:String(i.column.field),order:r}))}moveColumn(t,o){const i=this.visualColumns,r=this.totalFrozenColumns,s=i.slice(r),n=s.findIndex(d=>String(d.column.field)===t);if(n===-1||n===o)return;this._columnOrder.clear();const l=[...s],[a]=l.splice(n,1);l.splice(o,0,a),l.forEach((d,c)=>{this._columnOrder.set(String(d.column.field),c)}),this.requestUpdate()}}const Wn=':host{--wg-rem: 10px;font-family:var(--wg-font-family);display:block;position:relative;--wg-accent-color: var(--base-accent-color, #0078d4);--wg-accent-color-hover: var(--base-accent-color-hover, #106ebe);--wg-accent-color-active: var(--base-accent-color-active, #005a9e);--wg-accent-color-light: var(--base-accent-color-light, color-mix(in srgb, var(--wg-accent-color) 15%, transparent));--wg-text-color-1: var(--base-text-color-1, #242424);--wg-text-color-2: var(--base-text-color-2, #424242);--wg-text-color-3: var(--base-text-color-3, #707070);--wg-text-on-accent: var(--base-text-color-on-accent, #ffffff);--wg-surface-1: var(--base-main-bg, #ffffff);--wg-surface-2: var(--base-elevated-bg, #f5f5f5);--wg-surface-3: var(--base-hover-bg, #ebebeb);--wg-surface-floating: var(--base-dropdown-bg, var(--base-main-bg, #ffffff));--wg-border-color: var(--base-border-color, #e0e0e0);--wg-border-color-hover: var(--base-border-color, #d1d1d1);--wg-input-bg: var(--base-input-bg, #ffffff);--wg-input-color: var(--base-input-color, var(--wg-text-color-1));--wg-input-border: var(--base-input-border, 1px solid #d1d1d1);--wg-input-border-hover: var(--base-input-border-hover, 1px solid #0078d4);--wg-input-border-focus: var(--base-input-border-focus, 1px solid #0078d4);--wg-input-placeholder-color: var(--base-input-placeholder-color, #707070);--wg-danger-color: var(--base-danger-color, #d13438);--wg-danger-bg-light: var(--base-danger-bg-light, #fde7e9);--wg-hover-bg: var(--base-hover-bg, #f0f0f0);--wg-active-bg: var(--base-hover-bg, #e0e0e0);--wg-font-size-base: calc(var(--base-font-size-sm, 1.4) * var(--wg-rem));--wg-font-size-sm: calc(var(--base-font-size-xs, 1.2) * var(--wg-rem));--wg-font-size-xs: calc(var(--base-font-size-2xs, 1.1) * var(--wg-rem));--wg-font-size-lg: calc(var(--base-font-size-base, 1.6) * var(--wg-rem));--wg-font-family: var(--base-font-family, inherit);--wg-line-height-base: var(--base-line-height-normal, 1.5);--wg-font-weight-normal: var(--base-font-weight-normal, 400);--wg-font-weight-semibold: var(--base-font-weight-semibold, 600);--wg-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--wg-border-radius-sm: calc(var(--base-border-radius-sm, .4) * var(--wg-rem));--wg-border-radius-md: calc(var(--base-border-radius-md, .6) * var(--wg-rem));--wg-border-radius-lg: calc(var(--base-border-radius-lg, .8) * var(--wg-rem));--wg-spacing-xs: calc(.4 * var(--wg-rem));--wg-spacing-sm: calc(.8 * var(--wg-rem));--wg-spacing-md: calc(1.2 * var(--wg-rem));--wg-spacing-lg: calc(1.6 * var(--wg-rem));--wg-spacing-xl: calc(2.4 * var(--wg-rem));--wg-table-bg: var(--wg-surface-1);--wg-table-border: 1px solid var(--wg-border-color);--wg-row-number-width: calc(4 * var(--wg-rem));--wg-actions-column-width: calc(3.2 * var(--wg-rem));--wg-header-bg: var(--wg-surface-2);--wg-header-bg-hover: var(--wg-surface-3);--wg-header-bg-sorted: var(--wg-surface-3);--wg-header-color: var(--wg-text-color-1);--wg-header-border: 2px solid var(--wg-border-color);--wg-header-separator: 1px solid var(--wg-border-color);--wg-header-padding: var(--wg-spacing-sm);--wg-header-font-weight: var(--wg-font-weight-semibold);--wg-header-min-height: auto;--wg-cell-padding: var(--wg-spacing-sm);--wg-cell-padding-block: var(--wg-spacing-sm);--wg-cell-padding-inline: var(--wg-spacing-sm);--wg-row-min-height: auto;--wg-cell-color: var(--wg-text-color-1);--wg-cell-border: 1px solid var(--wg-border-color);--wg-cell-splitter-color: var(--wg-border-color);--wg-cell-splitter-width: 1px;--wg-cell-bg-hover: var(--wg-hover-bg);--wg-cell-bg-editing: var(--wg-surface-1);--wg-cell-readonly-bg: var(--base-disabled-bg, var(--wg-surface-2));--wg-row-border: 1px solid var(--wg-border-color);--wg-row-bg-even: var(--wg-surface-2);--wg-row-bg-hover: var(--wg-surface-3);--wg-filter-bg: var(--wg-surface-1);--wg-filter-border: 1px solid var(--wg-border-color);--wg-filter-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-filter-input-padding: calc(.4 * var(--wg-rem)) calc(.8 * var(--wg-rem));--wg-filter-input-bg: var(--wg-input-bg);--wg-filter-input-border: var(--wg-input-border);--wg-filter-input-border-focus: var(--wg-input-border-focus);--wg-filter-input-border-radius: var(--wg-border-radius-sm);--wg-filter-input-font-size: var(--wg-font-size-sm);--wg-sort-indicator-size: calc(1.4 * var(--wg-rem));--wg-sort-indicator-opacity: .9;--wg-sort-placeholder-opacity: .3;--wg-sort-priority-size: calc(1.1 * var(--wg-rem));--wg-pagination-padding: var(--wg-spacing-md);--wg-pagination-gap: calc(1.6 * var(--wg-rem));--wg-pagination-bg: var(--wg-surface-1);--wg-pagination-border: 1px solid var(--wg-border-color);--wg-pagination-btn-padding: calc(.6 * var(--wg-rem)) calc(1.6 * var(--wg-rem));--wg-pagination-btn-bg: var(--wg-surface-1);--wg-pagination-btn-bg-hover: var(--wg-surface-2);--wg-pagination-btn-bg-active: var(--wg-surface-3);--wg-pagination-btn-border: 1px solid var(--wg-border-color);--wg-pagination-btn-border-hover: 1px solid var(--wg-border-color-hover);--wg-pagination-btn-border-radius: var(--wg-border-radius-sm);--wg-pagination-btn-disabled-opacity: .4;--wg-empty-padding: var(--wg-spacing-xl);--wg-empty-color: var(--wg-text-color-3);--wg-error-cell-bg: var(--wg-danger-bg-light);--wg-error-cell-border: 1px solid var(--wg-danger-color);--wg-error-message-color: var(--wg-danger-color);--wg-error-message-font-size: var(--wg-font-size-xs);--wg-error-indicator-color: var(--wg-danger-color);--wg-dirty-indicator-color: #ed8b00;--wg-dirty-indicator-size: 6px;--wg-dirty-cell-bg: rgba(237, 139, 0, .08);--wg-dirty-row-number-border-color: #ed8b00;--wg-editor-bg: var(--wg-surface-1);--wg-editor-outline: 2px solid var(--wg-accent-color);--wg-editor-outline-offset: -2px;--wg-editor-validating-opacity: .7;--wg-dropdown-toggle-right: var(--wg-spacing-sm);--wg-dropdown-toggle-size: calc(1.2 * var(--wg-rem));--wg-dropdown-toggle-hitbox: calc(2.4 * var(--wg-rem));--wg-date-trigger-size: calc(2.8 * var(--wg-rem));--wg-editor-hitbox-height: calc(4.8 * var(--wg-rem));--wg-checkbox-scale: 1.2;--wg-toolbar-bg: var(--wg-surface-floating);--wg-toolbar-border: 1px solid var(--wg-border-color);--wg-toolbar-border-radius: var(--wg-border-radius-sm);--wg-toolbar-shadow: var(--base-dropdown-box-shadow, 0 2px 8px rgba(0, 0, 0, .15));--wg-toolbar-divider-color: var(--wg-border-color);--wg-toolbar-divider-height: calc(1.6 * var(--wg-rem));--wg-toolbar-row-height: calc(3.7 * var(--wg-rem));--wg-toolbar-icon-size: calc(1.6 * var(--wg-rem));--wg-toolbar-btn-min-width: calc(2.4 * var(--wg-rem));--wg-toolbar-btn-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-btn-border-radius: var(--wg-border-radius-sm);--wg-toolbar-btn-bg-hover: var(--wg-hover-bg);--wg-toolbar-btn-bg-active: var(--wg-active-bg);--wg-toolbar-btn-color: var(--wg-text-color-1);--wg-toolbar-trigger-color: var(--wg-text-color-3);--wg-toolbar-trigger-color-hover: var(--wg-text-color-1);--wg-toolbar-trigger-bg-hover: var(--wg-hover-bg);--wg-overlay-bg: rgba(0, 0, 0, .4);--wg-dialog-shadow: 0 4px 20px rgba(0, 0, 0, .15);--wg-tooltip-bg: var(--base-tooltip-bg, #333);--wg-tooltip-color: var(--base-tooltip-color, #fff);--wg-tooltip-max-width: 300px;--wg-tooltip-arrow-size: 8px;--wg-context-menu-z-index: var(--wg-z-context-menu);--wg-context-menu-min-width: calc(16 * var(--wg-rem));--wg-focus-outline: 2px solid var(--wg-accent-color);--wg-focus-outline-offset: -2px;--wg-focus-border-width: 2px;--wg-focus-border-color: var(--wg-accent-color);--wg-focus-bg: var(--wg-hover-bg);--wg-transition-fast: .1s ease;--wg-transition-normal: .15s ease;--wg-z-cell-highlight: 1;--wg-z-selection-border: 1;--wg-z-frozen: 2;--wg-z-header: 3;--wg-z-frozen-header: 4;--wg-z-fill-handle: 5;--wg-z-fill-handle-area: 4;--wg-z-resize-handle: 6;--wg-z-shortcuts-help: 10;--wg-z-reorder-indicator: 100;--wg-z-toolbar: 1000;--wg-z-context-menu: 1001;--wg-z-dropdown: 9999;--wg-z-reorder-ghost: 10000;--wg-z-tooltip: 10000;--wg-row-locked-bg: var(--base-disabled-bg, var(--wg-surface-2));--wg-row-locked-opacity: .7;--wg-frozen-column-bg: var(--wg-surface-1);--wg-frozen-header-bg: color-mix(in srgb, var(--wg-accent-color) 8%, var(--wg-header-bg));--wg-frozen-column-shadow: 2px 0 4px rgba(0, 0, 0, .1);--wg-frozen-column-shadow-active: 6px 0 12px rgba(0, 0, 0, .25);--wg-frozen-column-border: 2px solid var(--wg-border-color);--wg-frozen-column-shadow-gradient: linear-gradient(to right, rgba(0, 0, 0, .15), transparent);--wg-frozen-column-shadow-width: 8px;--wg-resize-handle-width: 12px;--wg-resize-handle-offset: -6px;--wg-resize-handle-line-width: 2px;--wg-resize-handle-color: var(--wg-border-color);--wg-resize-handle-active-color: var(--wg-accent-color);--wg-fill-handle-size: 8px;--wg-fill-handle-bg: var(--wg-surface-1);--wg-fill-handle-border-color: var(--wg-accent-color);--wg-fill-handle-border-width: 2px;--wg-fill-range-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-fill-range-border-color: var(--wg-accent-color);--wg-selection-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-selection-row-number-bg: var(--wg-accent-color);--wg-selection-row-number-color: var(--base-text-inverted, #fff);--wg-selection-border-width: 2px;--wg-selection-border-color: var(--wg-accent-color);--wg-row-focus-bg: color-mix(in srgb, var(--wg-accent-color) 10%, transparent);--wg-row-focus-row-number-bg: color-mix(in srgb, var(--wg-accent-color) 30%, transparent);--wg-cell-selection-bg: color-mix(in srgb, var(--wg-accent-color) 10%, transparent);--wg-cell-selection-border: var(--wg-accent-color);--wg-cell-selection-border-width: 2px;--wg-dropdown-max-height: 200px;--wg-dropdown-option-gap: var(--wg-spacing-sm);--wg-dropdown-option-padding: calc(.6 * var(--wg-rem)) var(--wg-spacing-sm) calc(.6 * var(--wg-rem)) calc(var(--wg-spacing-sm) - 1px);--wg-dropdown-empty-padding: calc(.8 * var(--wg-rem)) var(--wg-spacing-sm) calc(.8 * var(--wg-rem)) calc(var(--wg-spacing-sm) - 1px);--wg-inline-actions-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-inline-actions-gap: calc(.2 * var(--wg-rem));--wg-toolbar-row-gap: calc(.2 * var(--wg-rem));--wg-toolbar-row-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-label-font-size: var(--wg-font-size-sm);--wg-toolbar-btn-gap: calc(.4 * var(--wg-rem));--wg-tooltip-padding: calc(.6 * var(--wg-rem)) calc(1 * var(--wg-rem));--wg-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .2)}web-grid:not(:defined){display:block;min-height:calc(10 * var(--wg-rem));color:transparent!important;background:transparent}.wg{position:relative;width:100%;max-height:inherit;overflow:auto;overscroll-behavior:contain;border:var(--wg-table-border)}.wg--scrollable{max-height:var(--wg-scroll-max-height, 100vh)}.wg--table-border-only{border:none;overflow:visible;display:flex;flex-direction:column}.wg--table-border-only .wg__table-container{border:var(--wg-table-border);overflow:auto;max-height:inherit;flex:1;min-height:0}.wg--table-border-only .wg__table-container .wg__header{position:sticky;top:0;z-index:var(--wg-z-header)}.wg__table{width:100%;min-width:max-content;border-collapse:collapse;table-layout:fixed;background:var(--wg-table-bg);font-size:var(--wg-font-size-base);line-height:var(--wg-line-height-base)}.wg__filler{width:auto;min-width:0;padding:0!important;border:none!important;box-shadow:none!important}th.wg__filler{position:sticky;top:0;z-index:var(--wg-z-header);background:var(--wg-header-bg);box-shadow:inset 0 -2px 0 var(--wg-border-color)!important}td.wg__filler{background:transparent}.wg__table tbody tr{border-bottom:var(--wg-row-border)}.wg__row-number-header,.wg__row-number{width:var(--wg-row-number-width);min-width:var(--wg-row-number-width);max-width:var(--wg-row-number-width);box-sizing:border-box;text-align:center;color:var(--wg-text-color-2);background:var(--wg-header-bg);-webkit-user-select:none;user-select:none;font-size:var(--wg-font-size-sm)}.wg__row-number-header{cursor:pointer}.wg__row-number-header:hover{background:var(--wg-hover-bg)}.wg__row-number{box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__actions-column{width:var(--wg-actions-column-width);min-width:var(--wg-actions-column-width);max-width:var(--wg-actions-column-width);padding:0!important;text-align:center}thead .wg__actions-column{background:var(--wg-header-bg);box-shadow:inset 0 -2px 0 var(--wg-border-color)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__header{position:sticky;top:0;z-index:var(--wg-z-header);background:var(--wg-header-bg);color:var(--wg-header-color);font-weight:var(--wg-header-font-weight);padding:var(--wg-header-padding);height:var(--wg-header-min-height);box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color),inset 0 -2px 0 var(--wg-border-color);box-sizing:border-box;-webkit-user-select:none;user-select:none;overflow:hidden}.wg__header:last-child{box-shadow:inset 0 -2px 0 var(--wg-border-color)}.wg__header--sortable{cursor:pointer}.wg__header--sortable:hover{background:var(--wg-header-bg-hover)}.wg__header--sorted{background:var(--wg-header-bg-sorted)}.wg__header--selected,.wg__header--selected:hover{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__header-container{display:flex;align-items:stretch;gap:var(--wg-spacing-xs);height:100%}.wg__header-content{flex:1;min-width:0;display:flex;align-items:center;justify-content:flex-start}.wg__header-content--align-left{justify-content:flex-start}.wg__header-content--align-center{justify-content:center}.wg__header-content--align-right{justify-content:flex-end}.wg__header-content--align-justify{justify-content:flex-start}.wg__header-content--valign-top{align-items:flex-start}.wg__header-content--valign-middle{align-items:center}.wg__header-content--valign-bottom{align-items:flex-end}.wg__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__header-controls{flex-shrink:0;display:flex;align-items:center}.wg__sort-indicator{font-size:var(--wg-sort-indicator-size);opacity:var(--wg-sort-indicator-opacity);min-width:16px;text-align:center}.wg__sort-placeholder{opacity:var(--wg-sort-placeholder-opacity)}.wg__sort-priority{font-size:var(--wg-sort-priority-size);font-weight:var(--wg-font-weight-semibold);margin-left:2px;vertical-align:super;line-height:1}.wg__header-info{display:inline-flex;align-items:center;color:var(--wg-accent-color);cursor:help;opacity:.7;margin-left:var(--wg-spacing-xs);vertical-align:middle}.wg__header-info:hover{opacity:1}.wg__filter-row th{padding:var(--wg-filter-padding);background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__filter-input{width:100%;padding:var(--wg-filter-input-padding);border:var(--wg-filter-input-border);border-radius:var(--wg-filter-input-border-radius);background:var(--wg-surface-1);color:var(--wg-text-color-1);font-family:inherit;font-size:var(--wg-filter-input-font-size);box-sizing:border-box}.wg__filter-input:focus{outline:none;border:var(--wg-filter-input-border-focus);box-shadow:0 0 0 1px var(--wg-accent-color)}.wg__resize-handle{position:absolute;top:0;right:var(--wg-resize-handle-offset);bottom:0;width:var(--wg-resize-handle-width);cursor:col-resize;z-index:var(--wg-z-resize-handle);opacity:0;transition:opacity .1s ease}.wg__header:hover .wg__resize-handle{opacity:1}.wg__resize-handle:after{content:"";position:absolute;top:25%;bottom:25%;left:50%;width:var(--wg-resize-handle-line-width);background:var(--wg-resize-handle-color);transform:translate(-50%);border-radius:1px}.wg__resize-handle:hover:after{background:var(--wg-resize-handle-active-color);top:15%;bottom:15%}.wg__resize-handle--active:after{background:var(--wg-resize-handle-active-color);top:0;bottom:0}.wg__resize-handle--disabled{cursor:not-allowed}.wg__resize-handle--disabled:after{display:none}.wg--resizing .wg__resize-handle{opacity:1}.wg--resizing{-webkit-user-select:none;user-select:none;cursor:col-resize}.wg--resizing .wg__cell,.wg--resizing .wg__header{cursor:col-resize}.wg--resizing .wg__table{min-width:0!important}.wg__header--dragging{opacity:1;background:var(--wg-header-bg)!important;outline:2px dashed var(--wg-accent-color);outline-offset:-2px}.wg__reorder-ghost{position:fixed;z-index:var(--wg-z-reorder-ghost);background:var(--wg-header-bg);border:2px solid var(--wg-accent-color);border-radius:var(--wg-border-radius-sm);padding:.4em .8em;font-size:var(--wg-font-size-sm);font-weight:var(--wg-header-font-weight);color:var(--wg-header-color);box-shadow:var(--wg-dialog-shadow);opacity:.95;pointer-events:none;white-space:nowrap}.wg__drop-indicator{position:absolute;width:3px;background:var(--wg-accent-color);z-index:var(--wg-z-reorder-indicator);pointer-events:none;display:none}.wg__drop-indicator:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);border-left:6px solid transparent;border-right:6px solid transparent;border-top:8px solid var(--wg-accent-color)}.wg--reordering{cursor:grabbing;-webkit-user-select:none;user-select:none}.wg--reordering .wg__cell,.wg--reordering .wg__header{cursor:grabbing}.wg--reorderable .wg__header:not(.wg__header--frozen):hover{cursor:grab}.wg__header--frozen{cursor:default}.wg__fill-handle{position:absolute;width:var(--wg-fill-handle-size);height:var(--wg-fill-handle-size);background:var(--wg-fill-handle-bg);border:var(--wg-fill-handle-border-width) solid var(--wg-fill-handle-border-color);cursor:crosshair;z-index:var(--wg-z-fill-handle);pointer-events:auto;box-sizing:border-box}.wg__fill-handle:hover{transform:scale(1.2)}.wg__fill-range{position:absolute;background:var(--wg-fill-range-bg);border:1px dashed var(--wg-fill-range-border-color);pointer-events:none;z-index:var(--wg-z-fill-handle-area);box-sizing:border-box}.wg--filling{cursor:crosshair;-webkit-user-select:none;user-select:none}.wg--filling .wg__cell,.wg--filling .wg__header{cursor:crosshair}.wg__cell--editing .wg__fill-handle{display:none}.wg__row--selected>.wg__cell{background:var(--wg-selection-bg)}.wg__row--selected>.wg__cell.wg__row-number,.wg--editable.wg--navigate-mode .wg__row--selected>.wg__cell.wg__row-number{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__row-number[data-row-number]{cursor:pointer;-webkit-user-select:none;user-select:none}.wg__row-number[data-row-number]:hover{background:var(--wg-hover-bg)}.wg__row--selected>.wg__cell.wg__row-number:hover,.wg--editable.wg--navigate-mode .wg__row--selected>.wg__cell.wg__row-number:hover{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__cell--column-selected{background:var(--wg-selection-bg)}.wg--selecting{cursor:default;-webkit-user-select:none;user-select:none}.wg--selecting *{-webkit-user-select:none;user-select:none}.wg:focus{outline:none}.wg__cell--in-range{background:var(--wg-cell-selection-bg)!important;position:relative;z-index:var(--wg-z-cell-highlight)}.wg__cell--editing.wg__cell--in-range{background:var(--wg-input-bg)!important}.wg__cell--editable.wg__cell--in-range:hover{background:var(--wg-cell-selection-bg)!important}.wg__cell--editable.wg__cell--in-range:hover:after{display:none}.wg__cell-range-border{position:absolute;border:var(--wg-cell-selection-border-width) solid var(--wg-cell-selection-border);pointer-events:none;z-index:var(--wg-z-selection-border);box-sizing:border-box;border-radius:1px}.wg--selecting-cells,.wg--selecting-cells *{cursor:crosshair!important;-webkit-user-select:none;user-select:none}.wg--selecting-cells .wg__cell{cursor:crosshair!important}.wg:has(.wg__cell-range-border) .wg__fill-handle{display:none}.wg__row-selection-border,.wg__column-selection-border{position:absolute;border:var(--wg-selection-border-width) solid var(--wg-selection-border-color);pointer-events:none;z-index:var(--wg-z-selection-border);box-sizing:border-box;border-radius:1px}.wg--selecting-columns,.wg--selecting-columns *{cursor:col-resize!important;-webkit-user-select:none;user-select:none}.wg--selecting-columns .wg__header{cursor:col-resize!important}.wg__header--frozen{background:var(--wg-frozen-header-bg, var(--wg-header-bg));z-index:var(--wg-z-frozen-header)!important}.wg__header--frozen.wg__header--selected,.wg__header--frozen.wg__header--selected:hover{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__row-number-header.wg__header--frozen{z-index:var(--wg-z-frozen-header)!important}.wg__cell--frozen{background:var(--wg-frozen-column-bg, var(--wg-surface-1))}.wg__cell--frozen-last{box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__row-number.wg__cell--frozen{background:var(--wg-header-bg);z-index:var(--wg-z-frozen)!important}.wg--striped tbody tr:nth-child(2n) .wg__cell--frozen{background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover .wg__cell--frozen{background:var(--wg-row-bg-hover)}.wg__row--focused>.wg__cell--frozen{background:color-mix(in srgb,var(--wg-accent-color) 10%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__row--selected>.wg__cell--frozen{background:color-mix(in srgb,var(--wg-accent-color) 15%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__row--selected>.wg__row-number.wg__cell--frozen{background:var(--wg-selection-row-number-bg)!important;color:var(--wg-selection-row-number-color)}.wg__cell--frozen.wg__cell--column-selected{background:color-mix(in srgb,var(--wg-accent-color) 15%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__cell--frozen.wg__cell--in-range{background:color-mix(in srgb,var(--wg-accent-color) 10%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__header.wg__header--frozen-last,.wg__cell.wg__cell--frozen-last{overflow:visible}.wg--scrolled-horizontal .wg__header--frozen-last:after,.wg--scrolled-horizontal .wg__cell--frozen-last:after{content:"";position:absolute;top:0;right:calc(-1 * var(--wg-frozen-column-shadow-width));bottom:0;width:var(--wg-frozen-column-shadow-width);background:var(--wg-frozen-column-shadow-gradient);pointer-events:none}.wg__cell{padding:var(--wg-cell-padding);color:var(--wg-cell-color);height:var(--wg-row-min-height);box-sizing:border-box;position:relative;scroll-margin-top:calc(3 * var(--wg-rem));scroll-margin-bottom:calc(.5 * var(--wg-rem));-webkit-user-select:none;user-select:none;overflow:hidden;box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__cell-text{-webkit-user-select:none;user-select:none;pointer-events:none}.wg__cell--ellipsis .wg__cell-text{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__cell--line-clamp .wg__cell-text{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}.wg__cell--editable{cursor:pointer}.wg__cell--editable:hover{background:var(--wg-cell-bg-hover)}.wg__cell--editable:hover:after{content:"";position:absolute;top:2px;right:2px;bottom:2px;left:2px;border:1px dashed var(--wg-border-color);border-radius:2px;pointer-events:none}.wg__cell--editing{position:relative;background:var(--wg-surface-1);outline:2px solid var(--wg-accent-color);outline-offset:-2px;z-index:var(--wg-z-cell-highlight)}.wg__cell--editing:after{display:none}.wg__cell--invalid{background:var(--wg-danger-bg-light);box-shadow:inset 0 0 0 2px var(--wg-danger-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg--editable.wg--navigate-mode .wg__cell:not(.wg__cell--editable){background:var(--wg-cell-readonly-bg)}.wg__row--locked{background:var(--wg-row-locked-bg)!important}.wg__row--locked .wg__cell{opacity:var(--wg-row-locked-opacity)}.wg__row--locked .wg__cell--editable{cursor:not-allowed}.wg__row--locked .wg__cell--editable:hover{background:inherit}.wg__row--locked .wg__cell--editable:hover:after{display:none}.wg__row-number--locked{opacity:1!important;cursor:help}.wg__cell--dirty{background:var(--wg-dirty-cell-bg)!important}.wg__cell--dirty:before{content:"";position:absolute;top:0;left:0;width:0;height:0;border-style:solid;border-width:var(--wg-dirty-indicator-size) var(--wg-dirty-indicator-size) 0 0;border-color:var(--wg-dirty-indicator-color) transparent transparent transparent;pointer-events:none}.wg__cell--dirty.wg__cell--editing:before{display:none}.wg__row-number--dirty{box-shadow:inset 3px 0 0 var(--wg-dirty-row-number-border-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__editor{position:absolute;top:0;left:0;right:0;width:100%;padding:var(--wg-cell-padding);border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:inherit;box-sizing:border-box}.wg__editor:focus,.wg__editor:focus-visible{outline:none;box-shadow:none}.wg__editor--text{text-align:inherit}.wg__editor--number{text-align:right}.wg__editor--valign-top{top:0;bottom:auto}.wg__editor--valign-middle{top:0;bottom:0}.wg__editor--valign-bottom{top:auto;bottom:0}.wg__editor--date{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:transparent;padding:var(--wg-cell-padding)}.wg__date-input{flex:1;min-width:0;height:100%;border:none;background:transparent;font:inherit;padding:0;outline:none;color:inherit}.wg__date-trigger{width:var(--wg-date-trigger-size);height:100%;display:flex;align-items:center;justify-content:center;border:none;background:transparent;color:var(--wg-text-color-3);cursor:pointer;padding:0;flex-shrink:0}.wg__date-trigger:hover{color:var(--wg-accent-color);background:var(--wg-hover-bg)}.wg__editor--checkbox{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(var(--wg-checkbox-scale));width:auto;height:auto;margin:0;padding:0;cursor:pointer}.wg__checkbox-display{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(var(--wg-checkbox-scale));width:auto;height:auto;margin:0;padding:0;cursor:pointer;pointer-events:none}.wg__checkbox-display--readonly{cursor:default;opacity:.5}.wg__editor--custom{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:var(--wg-editor-bg);padding:var(--wg-cell-padding-block) var(--wg-cell-padding-inline);cursor:pointer}.wg__editor--custom:focus{outline:none}.wg__custom-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;cursor:pointer}.wg__editor--combobox,.wg__editor--autocomplete{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:var(--wg-cell-padding);padding-right:0;background:transparent;box-sizing:border-box}.wg__combobox-input,.wg__autocomplete-input{flex:1;width:100%;height:100%;padding:0;padding-right:var(--wg-dropdown-toggle-hitbox);border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base);outline:none;box-sizing:border-box;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.wg__combobox-input:focus,.wg__autocomplete-input:focus{outline:none}.wg__combobox-toggle{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:var(--wg-dropdown-toggle-size);color:var(--wg-text-color-2);pointer-events:auto;cursor:pointer}.wg__combobox-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__loading-indicator{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:var(--wg-font-size-sm);animation:wg-pulse 1s infinite}@keyframes wg-pulse{0%,to{opacity:1}50%{opacity:.4}}.wg__select-trigger{display:flex;align-items:center;justify-content:space-between;cursor:pointer;background:transparent}.wg__select-trigger:focus,.wg__select-trigger:focus-visible{outline:none;box-shadow:none}.wg__select-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__select-toggle{position:relative;font-size:var(--wg-dropdown-toggle-size);opacity:.6;margin-left:var(--wg-spacing-xs);flex-shrink:0;pointer-events:auto;cursor:pointer}.wg__select-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__cell-dropdown-display{display:flex;align-items:center;justify-content:space-between;width:100%;pointer-events:none}.wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:0}.wg__cell:hover .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle,.wg__cell--focused .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:.6}.wg__cell-date-display{display:flex;align-items:center;justify-content:space-between;width:100%;pointer-events:none}.wg__cell-date-display .wg__date-trigger{position:relative;background:none;border:none;padding:0;margin:0;cursor:pointer;opacity:.6;display:flex;align-items:center;justify-content:center;color:inherit;pointer-events:auto}.wg__cell-date-display .wg__date-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:0}.wg__cell:hover .wg__cell-date-display--toggle-on-focus .wg__date-trigger,.wg__cell--focused .wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:.6}.wg__dropdown{background:var(--wg-surface-floating);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);box-shadow:var(--wg-toolbar-shadow);max-height:var(--wg-dropdown-max-height);overflow-y:auto;font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base)}.wg__dropdown-option{display:flex;align-items:center;gap:var(--wg-dropdown-option-gap);padding:var(--wg-dropdown-option-padding);cursor:pointer;color:var(--wg-text-color-1)}.wg__dropdown-option:hover,.wg__dropdown-option--highlighted{background:var(--wg-hover-bg);box-shadow:inset 0 0 0 2px var(--wg-accent-color)}.wg__dropdown-option--selected{background:var(--wg-accent-color-light)}.wg__dropdown-option--disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.wg__dropdown-option-icon{flex-shrink:0;width:1.5em;text-align:center}.wg__dropdown-option-content{flex:1;min-width:0;overflow:hidden}.wg__dropdown-option-label{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-option-subtitle{display:block;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-empty{padding:var(--wg-dropdown-empty-padding);color:var(--wg-text-color-2);font-style:italic;text-align:center}.wg__dropdown-option--align-left{justify-content:flex-start}.wg__dropdown-option--align-left .wg__dropdown-option-content{text-align:left}.wg__dropdown-option--align-center{justify-content:center}.wg__dropdown-option--align-center .wg__dropdown-option-content{text-align:center}.wg__dropdown-option--align-right{justify-content:flex-end}.wg__dropdown-option--align-right .wg__dropdown-option-content{text-align:right}.wg__dropdown-option--align-justify{justify-content:flex-start}.wg__dropdown-option--align-justify .wg__dropdown-option-content{text-align:justify}.wg--navigate-mode .wg__cell{cursor:cell}.wg__cell:focus{outline:none;box-shadow:inset 0 0 0 var(--wg-focus-border-width) var(--wg-focus-border-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg--editable .wg__cell.wg__cell--focused,.wg__cell.wg__cell--always-edit-focused{box-shadow:inset 0 0 0 var(--wg-focus-border-width) var(--wg-focus-border-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__cell--focused:after,.wg__cell--always-edit-focused:after{display:none}.wg__row--focused>.wg__cell{background:var(--wg-row-focus-bg)}.wg__row--focused>.wg__cell.wg__row-number{background:var(--wg-row-focus-row-number-bg)}.wg--editable.wg--navigate-mode .wg__row--focused>.wg__cell{background:var(--wg-row-focus-bg)}.wg--editable.wg--navigate-mode .wg__row--focused>.wg__cell.wg__row-number{background:var(--wg-row-focus-row-number-bg)}.wg__pagination{display:flex;align-items:center;justify-content:center;gap:var(--wg-pagination-gap);padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__pagination-btn{padding:var(--wg-pagination-btn-padding);background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer;transition:all var(--wg-transition-fast)}.wg__pagination-btn:hover:not(:disabled){background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-btn:active:not(:disabled){background:var(--wg-pagination-btn-bg-active)}.wg__pagination-btn:disabled{opacity:var(--wg-pagination-btn-disabled-opacity);cursor:not-allowed}.wg__pagination-info{font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__pagination-count{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3);margin-left:var(--wg-spacing-xs)}.wg__pagination-pagesize{display:flex;align-items:center;gap:calc(.6 * var(--wg-rem))}.wg__pagination-select{padding:var(--wg-spacing-xs) var(--wg-spacing-sm);background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer}.wg__pagination-select:hover{background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-select:focus{outline:2px solid var(--wg-accent-color);outline-offset:-2px}.wg__pagination-label{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3)}.wg__pagination--left{justify-content:flex-start}.wg__pagination--right{justify-content:flex-end}.wg__pagination--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__summary{display:flex;align-items:center;padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg);font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__summary--left{justify-content:flex-start}.wg__summary--right{justify-content:flex-end}.wg__summary--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer{display:flex;align-items:center;justify-content:space-between;border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__footer--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer .wg__summary,.wg__footer .wg__pagination{border:none}.wg__footer .wg__summary{flex:0 0 auto}.wg__footer .wg__pagination{flex:0 0 auto;margin-left:auto}.wg__toolbar-container{position:fixed;z-index:var(--wg-z-toolbar)}.wg__toolbar{display:flex;flex-direction:column-reverse;gap:0;padding:0;background:var(--wg-toolbar-bg);border:var(--wg-toolbar-border);border-radius:var(--wg-toolbar-border-radius);box-shadow:var(--wg-toolbar-shadow)}.wg__toolbar-row{display:flex;gap:var(--wg-toolbar-row-gap);align-items:center;height:var(--wg-toolbar-row-height);padding:var(--wg-toolbar-row-padding)}.wg__toolbar-row+.wg__toolbar-row{border-top:1px solid var(--wg-toolbar-divider-color)}.wg__toolbar-divider{width:1px;height:var(--wg-toolbar-divider-height);background:var(--wg-toolbar-divider-color);margin:0 var(--wg-spacing-xs);flex-shrink:0}.wg__toolbar-btn{min-width:var(--wg-toolbar-btn-min-width);height:100%;border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--wg-toolbar-btn-gap);font-family:inherit;font-size:var(--wg-font-size-base);font-weight:var(--wg-font-weight-normal);padding:var(--wg-toolbar-btn-padding);transition:background .1s ease}.wg__toolbar-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__toolbar-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__toolbar-btn:disabled{opacity:.5;cursor:not-allowed}.wg__toolbar-btn:disabled:hover{background:transparent}.wg__toolbar-btn svg{width:var(--wg-toolbar-icon-size);height:var(--wg-toolbar-icon-size);flex-shrink:0}.wg__toolbar-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__toolbar-label{font-size:var(--wg-toolbar-label-font-size);white-space:nowrap}.wg__actions-column{width:var(--wg-toolbar-btn-min-width);min-width:var(--wg-toolbar-btn-min-width);max-width:var(--wg-toolbar-btn-min-width);padding:0!important;text-align:center}.wg__header .wg__actions-column{background:var(--wg-header-bg)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg)}.wg__toolbar-trigger{position:relative;padding:0;background:transparent;border:none;border-radius:var(--wg-border-radius-sm);cursor:pointer;font-size:var(--wg-font-size-base);line-height:1;color:var(--wg-toolbar-trigger-color)}.wg__toolbar-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__toolbar-trigger:hover,.wg__toolbar-trigger--active{color:var(--wg-toolbar-trigger-color-hover);background:var(--wg-toolbar-trigger-bg-hover)}.wg__inline-actions-header,.wg__inline-actions-cell{white-space:nowrap;text-align:start;padding:var(--wg-inline-actions-padding);overflow:visible}.wg__inline-actions-header{background:var(--wg-header-bg)}.wg__inline-actions-wrap{display:flex;flex-direction:column;gap:var(--wg-inline-actions-gap);align-items:flex-start}.wg__inline-actions-row{display:flex;gap:var(--wg-inline-actions-gap);align-items:center;justify-content:flex-start}.wg__inline-action-btn{width:var(--wg-toolbar-btn-min-width);max-width:var(--wg-toolbar-btn-min-width);height:calc(2.4 * var(--wg-rem));border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;box-sizing:border-box;font-family:inherit;font-size:var(--wg-font-size-base);transition:background var(--wg-transition-fast)}.wg__inline-action-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__inline-action-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__inline-action-btn:disabled,.wg__inline-action-btn--disabled{opacity:.5;cursor:not-allowed}.wg__inline-action-btn:disabled:hover,.wg__inline-action-btn--disabled:hover{background:transparent}.wg__inline-action-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__inline-action-btn svg{width:var(--wg-toolbar-icon-size);height:var(--wg-toolbar-icon-size);flex-shrink:0}.wg__shortcuts-help{position:absolute;top:var(--wg-spacing-xs);right:var(--wg-spacing-sm);z-index:var(--wg-z-shortcuts-help)}.wg__shortcuts-help--left{right:auto;left:var(--wg-spacing-sm)}.wg__shortcuts-help-icon{display:flex;align-items:center;justify-content:center;width:var(--wg-spacing-xl);height:var(--wg-spacing-xl);padding:0;border:none;border-radius:50%;background:var(--wg-surface-1);color:var(--wg-text-color-2);cursor:pointer;opacity:.7}.wg__shortcuts-help-icon:hover{opacity:1;background:var(--wg-surface-2)}.wg__shortcuts-help-icon svg{width:var(--wg-toolbar-icon-size);height:var(--wg-toolbar-icon-size)}.wg__shortcuts-help-overlay{display:none;position:absolute;top:100%;right:0;margin-top:var(--wg-spacing-xs);padding:var(--wg-spacing-md);background:var(--wg-surface-1);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-md);box-shadow:var(--wg-dialog-shadow);min-width:200px;max-width:var(--wg-tooltip-max-width);z-index:100}.wg__shortcuts-help--left .wg__shortcuts-help-overlay{right:auto;left:0}.wg__shortcuts-help:hover .wg__shortcuts-help-overlay,.wg__shortcuts-help:focus-within .wg__shortcuts-help-overlay{display:block}.wg__shortcuts-help-title{font-weight:var(--wg-font-weight-semibold);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1);margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-xs);border-bottom:1px solid var(--wg-border-color)}.wg__shortcuts-help-custom{margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-sm);border-bottom:1px solid var(--wg-border-color);font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg__shortcuts-help-list{display:flex;flex-direction:column;gap:var(--wg-spacing-xs)}.wg__shortcuts-help-item{display:flex;align-items:center;gap:var(--wg-spacing-md)}.wg__shortcuts-help-key{display:inline-flex;align-items:center;justify-content:center;min-width:28px;padding:2px calc(.6 * var(--wg-rem));font-family:var(--wg-font-family-mono);font-size:var(--wg-font-size-xs);font-weight:var(--wg-font-weight-semibold);color:var(--wg-text-color-1);background:var(--wg-surface-2);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm)}.wg__shortcuts-help-label{flex:1;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg--striped tbody tr:nth-child(2n){background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover{background:var(--wg-row-bg-hover)}.wg__empty{text-align:center;padding:var(--wg-empty-padding);color:var(--wg-empty-color);font-style:italic}.wg__loading-more{text-align:center;padding:var(--wg-cell-padding);color:var(--wg-text-color-2);font-size:var(--wg-font-size-sm)}.wg__tooltip{position:absolute;z-index:var(--wg-z-tooltip);max-width:var(--wg-tooltip-max-width);padding:var(--wg-tooltip-padding);background:var(--wg-tooltip-bg);color:var(--wg-tooltip-color);font-size:var(--wg-font-size-sm);line-height:1.4;border-radius:var(--wg-border-radius-sm);box-shadow:var(--wg-tooltip-shadow);pointer-events:none;opacity:0;transition:opacity var(--wg-transition-fast)}.wg__tooltip--visible{opacity:1}.wg__tooltip-arrow{position:absolute;width:var(--wg-tooltip-arrow-size);height:var(--wg-tooltip-arrow-size);background:var(--wg-tooltip-bg);transform:rotate(45deg)}.wg__tooltip[data-placement^=top] .wg__tooltip-arrow{bottom:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip[data-placement^=bottom] .wg__tooltip-arrow{top:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip[data-placement^=left] .wg__tooltip-arrow{right:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip[data-placement^=right] .wg__tooltip-arrow{left:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip-title{font-weight:600}.wg__tooltip-desc{opacity:.85;margin-top:2px}.wg__tooltip-shortcut{margin-top:4px;opacity:.7;font-size:.9em}.wg__goto-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:var(--wg-overlay-bg);display:flex;align-items:center;justify-content:center;z-index:1000}.wg__goto-dialog{background:var(--wg-surface-1);border-radius:var(--wg-border-radius-md);padding:var(--wg-spacing-lg);box-shadow:var(--wg-dialog-shadow);min-width:250px}.wg__goto-label{display:block;margin-bottom:var(--wg-spacing-sm);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1)}.wg__goto-input{width:100%;padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-base);margin-bottom:var(--wg-spacing-md);box-sizing:border-box}.wg__goto-input:focus{outline:none;border-color:var(--wg-accent-color);box-shadow:0 0 0 2px color-mix(in srgb,var(--wg-accent-color) 20%,transparent)}.wg__goto-buttons{display:flex;gap:var(--wg-spacing-sm);justify-content:flex-end}.wg__goto-btn{padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-sm);cursor:pointer;background:var(--wg-surface-1);color:var(--wg-text-color-1)}.wg__goto-btn:hover{background:var(--wg-surface-2)}.wg__goto-btn--go{background:var(--wg-accent-color);border-color:var(--wg-accent-color);color:var(--wg-text-on-accent)}.wg__goto-btn--go:hover{background:var(--wg-accent-color-hover)}.wg__spacer-top td,.wg__spacer-bottom td{padding:0;border:none;background:transparent;height:inherit;line-height:0}@media (prefers-color-scheme: dark){:host{--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86;--wg-dirty-indicator-color: #ffa940;--wg-dirty-cell-bg: rgba(255, 169, 64, .12);--wg-dirty-row-number-border-color: #ffa940}}:host([data-theme="dark"]),:host-context([data-theme="dark"]),:host([data-bs-theme="dark"]),:host-context([data-bs-theme="dark"]),:host-context(.dark){--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86;--wg-dirty-indicator-color: #ffa940;--wg-dirty-row-number-border-color: #ffa940}:host([data-theme="light"]),:host-context([data-theme="light"]),:host([data-bs-theme="light"]),:host-context([data-bs-theme="light"]),:host-context(.light){--wg-surface-1: var(--base-main-bg, #ffffff);--wg-surface-2: var(--base-elevated-bg, #f5f5f5);--wg-surface-3: var(--base-hover-bg, #ebebeb);--wg-surface-floating: var(--base-dropdown-bg, var(--base-main-bg, #ffffff));--wg-text-color-1: var(--base-text-color-1, #242424);--wg-text-color-2: var(--base-text-color-2, #424242);--wg-text-color-3: var(--base-text-color-3, #707070);--wg-border-color: var(--base-border-color, #e0e0e0);--wg-border-color-hover: var(--base-border-color, #d1d1d1);--wg-input-bg: var(--base-input-bg, #ffffff);--wg-input-border: var(--base-input-border, 1px solid #d1d1d1);--wg-hover-bg: var(--base-hover-bg, #f0f0f0);--wg-active-bg: var(--base-hover-bg, #e0e0e0);--wg-danger-bg-light: var(--base-danger-bg-light, #fde7e9);--wg-danger-color: var(--base-danger-color, #d13438)}';function ct(e,t,o){const i=o.valueMember||"value",r=t.find(s=>s[i]===e);return r?Be(r,o):e!=null?String(e):""}function Be(e,t){if(t.getDisplayCallback)return t.getDisplayCallback(e);const o=t.displayMember||"label";return String(e[o]??e.label??"")}function Ae(e,t){if(t.getValueCallback)return t.getValueCallback(e);const o=t.valueMember||"value";return e[o]??e.value}function Yn(e,t){return t.getIconCallback?t.getIconCallback(e):t.iconMember&&e[t.iconMember]||null}function Un(e,t){return t.getSubtitleCallback?t.getSubtitleCallback(e):t.subtitleMember&&e[t.subtitleMember]||null}function de(e,t){return t.getDisabledCallback?t.getDisabledCallback(e):t.disabledMember?!!e[t.disabledMember]:!1}function no(e,t,o,i,r,s,n=!0){const l=i.editor==="select"||i.editor==="combobox"||i.editor==="autocomplete",a=i.editor==="date",d=i.editor==="checkbox",c=String(i.field);if(d){if(i.formatCallback)return`<span class="wg__cell-text">${e.escapeHtml(r)}</span>`;const g=e.grid.displayItems[t],h=g?e.grid.getCellRawValue(g,t,c):!1,f=i.editorOptions||{},w=f.trueValue!==void 0?f.trueValue:!0;return`
307
+ toolbarColumn takes priority — cursor following is disabled.`,r)}requestUpdate(){}invalidateDisplayCache(){this._paginatedItemsCache=null,this._displayItemsCache=null}getRowDraft(e){return this._draftRows.get(e)}hasRowDraft(e){return this._draftRows.has(e)}isCellDirty(e,o){const i=this._draftRows.get(e);if(!i)return!1;const r=this.displayItems[e];if(!r)return!1;const s=i[o],n=r[o];return s!==n}isRowDirty(e){return this._draftRows.has(e)}discardRowDraft(e){this._draftRows.delete(e);const o=this.rowKeyForIndex(e);o!==null&&(this._invalidCells=this._invalidCells.filter(i=>i.rowKey!==o)),this.requestUpdate()}discardCellDraft(e,o){const i=this._draftRows.get(e);if(!i)return;const r=this.displayItems[e];if(!r)return;const s=r[o];i[o]=s;const n=Object.keys(i);let l=!1;for(const d of n){const c=i[d],u=r[d];if(c!==u){l=!0;break}}l||this._draftRows.delete(e);const a=this.rowKeyForIndex(e);a!==null&&(this._invalidCells=this._invalidCells.filter(d=>!(d.rowKey===a&&d.field===o)))}getDraftRowIndices(){return Array.from(this._draftRows.keys())}discardAllDrafts(){this._draftRows.clear(),this._invalidCells=[],this.requestUpdate()}getCellRawValue(e,o,i){if(!this.isEmptyRowIndex(o)){const r=this._draftRows.get(o);if(r)return r[i]}return e[i]}getCellValue(e,o,i){var s;if(o.templateCallback)return o.templateCallback(e);const r=i!==void 0?this.getCellRawValue(e,i,String(o.field)):e[String(o.field)];if(o.formatCallback)return o.formatCallback(r,e);if(o.editor==="date"&&((s=o.editorOptions)!=null&&s.dateFormat)&&r)try{const n=r instanceof Date?r:new Date(r);if(!isNaN(n.getTime())){const l=Dt(o.editorOptions.dateFormat);return io(n,l)}}catch{}return String(r??"")}rowKeyForIndex(e){const o=this.displayItems[e];return o===void 0?null:this.getStableRowKey(o,e)}isCellInvalid(e,o){const i=this.rowKeyForIndex(e);return i===null?!1:this._invalidCells.some(r=>r.rowKey===i&&r.field===o)}getCellValidationError(e,o){const i=this.rowKeyForIndex(e);if(i===null)return null;const r=this._invalidCells.find(s=>s.rowKey===i&&s.field===o);return(r==null?void 0:r.error)||null}addInvalidCell(e,o,i){const r=this.rowKeyForIndex(e);if(r===null)return;const s=this._invalidCells.findIndex(n=>n.rowKey===r&&n.field===o);s>=0?this._invalidCells[s]={rowKey:r,field:o,error:i}:this._invalidCells=[...this._invalidCells,{rowKey:r,field:o,error:i}]}removeInvalidCell(e,o){const i=this.rowKeyForIndex(e);i!==null&&(this._invalidCells=this._invalidCells.filter(r=>!(r.rowKey===i&&r.field===o)))}isEditing(e,o){var i,r;return((i=this._editingCell)==null?void 0:i.rowIndex)===e&&((r=this._editingCell)==null?void 0:r.field)===o}shouldShowEditor(e,o){const i=this._columns[o];if(!i)return!1;const r=String(i.field);return!!(this.isEditing(e,r)||(i.editTrigger??this._editTrigger)==="always"&&this.isCellEditable(i))}startEdit(e,o,i){var n,l;if(!this.canEditCell(e,o)){Le.debug("startEdit blocked (locked):",{rowIndex:e,field:o});return}Le.debug("startEdit:",{rowIndex:e,field:o,options:i});const r=this.displayItems[e];if(!r)return;this._draftRows.has(e)||this._draftRows.set(e,{...r});const s=this._editingCell;this._editingCell={rowIndex:e,field:o,initialSearchQuery:i==null?void 0:i.initialSearchQuery,cursorPosition:i==null?void 0:i.cursorPosition},(n=this._onInteractionChange)==null||n.call(this,"editingCell",{prev:s,current:this._editingCell}),this._currentCellError=null,(l=this._onroweditstart)==null||l.call(this,{row:r,rowIndex:e,field:o})}cancelEdit(){var e,o;if(this._editingCell){const i=this._editingCell,{rowIndex:r,field:s}=i,n=this.displayItems[r];n&&((e=this._onroweditcancel)==null||e.call(this,{row:n,rowIndex:r,field:s})),this._editingCell=null,(o=this._onInteractionChange)==null||o.call(this,"editingCell",{prev:i,current:null}),this._currentCellError=null}}normalizeValidationResult(e,o){return e==null||e===!0?{valid:!0,finalValue:o}:e===!1?{valid:!1,message:"Validation failed",finalValue:o}:typeof e=="string"?{valid:!1,message:e,finalValue:o}:{valid:e.valid,message:e.message,finalValue:e.transformedValue!==void 0?e.transformedValue:o}}async commitEdit(e,o,i,r=!1){var w,p,m,_,y,C,S;gt.debug("commitEdit:",{rowIndex:e,field:o,newValue:i});const s=this._columns.find(v=>String(v.field)===o);if(!s)return;const n=this.displayItems[e];if(!n)return;const l=this.isEmptyRowIndex(e),a=n[o];let d=i,c=null,u=!0;this._isValidating=!0;try{if(s.beforeCommitCallback){const v={value:i,oldValue:a,row:n,rowIndex:e,field:o},x=await Promise.resolve(s.beforeCommitCallback(v)),k=this.normalizeValidationResult(x,i);u=k.valid,c=k.message||null,d=k.finalValue}else if(s.validateCallback){const v=await Promise.resolve(s.validateCallback(i,n));v&&(u=!1,c=v)}}catch(v){u=!1,c=v instanceof Error?v.message:"Validation failed"}if(this._isValidating=!1,l){if(this._emptyRowDraft||(this._emptyRowDraft={...n}),this._emptyRowDraft[o]=d,u?(this.removeInvalidCell(e,o),this._currentCellError=null):(this.addInvalidCell(e,o,c||"Invalid value"),this._currentCellError=c,(w=this._onvalidationerror)==null||w.call(this,{row:n,rowIndex:e,field:o,error:c||"Invalid value"})),r&&this.emptyRowHasData(this._emptyRowDraft)){const k={...this._emptyRowDraft},E=this._newRowPosition==="top"?0:this._items.length,I=this.getStableRowKey(this._emptyRowDraft,e);this._newRowPosition==="top"?this._items=[k,...this._items]:this._items=[...this._items,k];const R=this.getStableRowKey(k,E),P=!this._idMember&&!this._treePathMember;this._invalidCells=this._invalidCells.map(A=>{if(A.rowKey===I)return{...A,rowKey:R};if(P&&this._newRowPosition==="top"){const F=Number(A.rowKey);if(!Number.isNaN(F))return{...A,rowKey:String(F+1)}}return A});const D=this._invalidCells.some(A=>A.rowKey===R);(p=this._onrowchange)==null||p.call(this,{row:k,draftRow:k,rowIndex:E,field:o,oldValue:null,newValue:d,isValid:!D,validationError:D?"Row has invalid cells":null}),this._emptyRowDraft=null;const M=this._editingCell;this._editingCell=null,(m=this._onInteractionChange)==null||m.call(this,"editingCell",{prev:M,current:null}),this.requestUpdate();return}const v=this._editingCell;this._editingCell=null,(_=this._onInteractionChange)==null||_.call(this,"editingCell",{prev:v,current:null});return}let h=this._draftRows.get(e);h||(h={...n},this._draftRows.set(e,h)),h[o]=d,u?(this.removeInvalidCell(e,o),this._currentCellError=null):(this.addInvalidCell(e,o,c||"Invalid value"),this._currentCellError=c,(y=this._onvalidationerror)==null||y.call(this,{row:n,rowIndex:e,field:o,error:c||"Invalid value"})),(d!==a||!u)&&((C=this._onrowchange)==null||C.call(this,{row:n,draftRow:h,rowIndex:e,field:o,oldValue:a,newValue:d,isValid:u,validationError:c}));const f=this._editingCell;this._editingCell=null,(S=this._onInteractionChange)==null||S.call(this,"editingCell",{prev:f,current:null})}updateDraftValue(e,o,i){var l;if(!this._columns.find(a=>String(a.field)===o))return;const s=this.displayItems[e];if(!s)return;const n=this.getCellRawValue(s,e,o);if(this.isEmptyRowIndex(e))this._emptyRowDraft||(this._emptyRowDraft={...s}),this._emptyRowDraft[o]=i;else{let a=this._draftRows.get(e);a||(a={...s},this._draftRows.set(e,a)),a[o]=i}if(i!==n){const a=this._draftRows.get(e)||this._emptyRowDraft||s;(l=this._onrowchange)==null||l.call(this,{row:s,draftRow:a,rowIndex:e,field:o,oldValue:n,newValue:i,isValid:!0,validationError:null})}}isCellEditable(e,o){return this.isTreeMode&&e.isTree||e.isEditable===!1||typeof e.isEditable=="function"&&o!==void 0&&!e.isEditable(o)||this._isRowEditable!==void 0&&o!==void 0&&!(typeof this._isRowEditable=="function"?this._isRowEditable(o):this._isRowEditable)?!1:e.isEditable===!0||typeof e.isEditable=="function"&&o!==void 0?!0:this._isEditable}getEditableColumns(e){return this._columns.map((o,i)=>({index:i,column:o})).filter(({column:o})=>this.isCellEditable(o,e))}findNextEditableCell(e,o,i){const r=this.displayItems,s=i==="forward"?1:-1,n=r[e];if(n!==void 0){const a=this.getEditableColumns(n),d=o+s;if(d>=0&&d<a.length)return{rowIndex:e,colIndex:a[d].index}}let l=e+s;for(;l>=0&&l<r.length;){const a=r[l],d=this.getEditableColumns(a);if(d.length>0){const c=i==="forward"?d[0]:d[d.length-1];return{rowIndex:l,colIndex:c.index}}l+=s}return null}isCellFocused(e,o){var i,r;return((i=this._focusedCell)==null?void 0:i.rowIndex)===e&&((r=this._focusedCell)==null?void 0:r.colIndex)===o}get focusedCell(){return this._focusedCell}setFocusedCell(e,o){var s;const i=this._focusedCell,r={rowIndex:e,colIndex:o};(i==null?void 0:i.rowIndex)===r.rowIndex&&(i==null?void 0:i.colIndex)===r.colIndex||(this._focusedCell=r,(s=this._onInteractionChange)==null||s.call(this,"focusedCell",{prev:i,current:r}))}clearFocusedCell(){var o;const e=this._focusedCell;e!==null&&(this._focusedCell=null,(o=this._onInteractionChange)==null||o.call(this,"focusedCell",{prev:e,current:null}))}get tabTraversalStartColIndex(){return this._tabTraversalStartColIndex}set tabTraversalStartColIndex(e){this._tabTraversalStartColIndex=e}setHoveredRow(e){var i;if(this._hoveredRowIndex===e)return;const o=this._hoveredRowIndex;this._hoveredRowIndex=e,(i=this._onInteractionChange)==null||i.call(this,"hoveredRow",{prev:o,current:e})}get focusedRowIndex(){return this._focusedRowIndex}set focusedRowIndex(e){e===null?this.clearRowFocus():this.setFocusedRow(e),this.requestUpdate()}get onrowfocus(){return this._onrowfocus}set onrowfocus(e){this._onrowfocus=e}isRowFocused(e){return this._focusedRowIndex===e}clearRowFocus(){var o;if(this._focusedRowIndex===null)return;const e=this._focusedRowIndex;this._focusedRowIndex=null,(o=this._onInteractionChange)==null||o.call(this,"focusedRow",{prev:e,current:null})}setFocusedRow(e){var r;if(this._focusedRowIndex===e)return;Le.debug("setFocusedRow:",e,"(prev:",this._focusedRowIndex,")");const o=this._focusedRowIndex;this._focusedRowIndex=e,(r=this._onInteractionChange)==null||r.call(this,"focusedRow",{prev:o,current:e});const i=this.displayItems[e];i&&this._onrowfocus&&this._onrowfocus({rowIndex:e,row:i,previousRowIndex:o})}getRowId(e){if(this._idValueCallback)return this._idValueCallback(e);if(this._idValueMember)return e[String(this._idValueMember)]}findRowById(e){const o=this._items.findIndex(i=>this.getRowId(i)===e);return o===-1?null:{row:this._items[o],index:o}}getRowLockInfo(e){let o,i,r=-1;if(typeof e=="object"&&e!==null)o=e,i=this.getRowId(o),r=this._items.indexOf(o),r===-1&&(r=this.displayItems.indexOf(o));else{i=e;const n=this.findRowById(i);n&&(o=n.row,r=n.index)}if(i!==void 0&&this._externalLocks.has(i))return this._externalLocks.get(i);if(!o)return null;const s=this._rowLocking;if(!s)return null;if(s.getLockInfoCallback){const n=s.getLockInfoCallback(o,r);if(n!=null&&n.isLocked)return n}if(s.isLockedCallback&&s.isLockedCallback(o,r))return{isLocked:!0};if(s.lockInfoMember){const n=o[String(s.lockInfoMember)];if(n!=null&&n.isLocked)return n}return s.lockedMember&&o[String(s.lockedMember)]?{isLocked:!0}:null}isRowLocked(e){const o=this.getRowLockInfo(e);return(o==null?void 0:o.isLocked)===!0}lockRowById(e,o){var s;const i={isLocked:!0,lockedBy:o==null?void 0:o.lockedBy,lockedAt:(o==null?void 0:o.lockedAt)??new Date,reason:o==null?void 0:o.reason,...o};this._externalLocks.set(e,i);const r=this.findRowById(e);return r&&this._editingCell&&this._editingCell.rowIndex===r.index&&this.cancelEdit(),this.requestUpdate(),(s=this._onrowlockchange)==null||s.call(this,{rowId:e,row:(r==null?void 0:r.row)??null,rowIndex:(r==null?void 0:r.index)??-1,lockInfo:i,source:"external"}),!0}unlockRowById(e){var i;const o=this._externalLocks.has(e);if(this._externalLocks.delete(e),o){this.requestUpdate();const r=this.findRowById(e);(i=this._onrowlockchange)==null||i.call(this,{rowId:e,row:(r==null?void 0:r.row)??null,rowIndex:(r==null?void 0:r.index)??-1,lockInfo:null,source:"external"})}return o}getExternalLocks(){return new Map(this._externalLocks)}clearExternalLocks(){this._externalLocks.clear(),this.requestUpdate()}updateRowById(e,o){const i=this.findRowById(e);if(!i)return!1;Object.assign(this._items[i.index],o);const r=this._draftRows.get(i.index);return r&&Object.assign(r,o),this.requestUpdate(),!0}replaceRowById(e,o){const i=this.findRowById(e);return i?(this._items[i.index]=o,this._draftRows.delete(i.index),this.requestUpdate(),!0):!1}canEditCell(e,o){var a;const i=this._columns.find(d=>String(d.field)===o);if(!i)return!1;const r=this.displayItems[e];if(!r||!this.isCellEditable(i,r))return!1;const s=this.getRowLockInfo(r);if(!(s!=null&&s.isLocked))return!0;const n=this._rowLocking;switch((n==null?void 0:n.lockedEditBehavior)??"block"){case"allow":return!0;case"callback":return((a=n==null?void 0:n.canEditLockedCallback)==null?void 0:a.call(n,r,s))??!1;case"block":default:return!1}}getColumnWidth(e){return this._columnWidths.get(e)}setColumnWidth(e,o,i=!1){this._columnWidths.set(e,o),i||this.requestUpdate()}setColumnWidths(e){for(const{field:o,width:i}of e)o&&i&&this._columnWidths.set(o,i);this.requestUpdate()}getColumnWidthsState(){return this._columns.map(e=>{const o=String(e.field),i=this._columnWidths.get(o)||e.width||"";return{field:o,width:i}}).filter(e=>e.width)}loadPersistedWidths(){this.loadPersistedState()}savePersistedWidths(){this.savePersistedState()}loadPersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const e=`wg-${this._gridName}-state`,o=localStorage.getItem(e);if(!o)return;const i=JSON.parse(o),r=new Set(this._columns.map(n=>String(n.field)));let s=!1;if(i.columnWidths){this._columnWidths.clear();for(const n of i.columnWidths)r.has(n.field)?this._columnWidths.set(n.field,n.width):s=!0}if(i.columnOrder){this._columnOrder.clear();for(const n of i.columnOrder)r.has(n.field)?this._columnOrder.set(n.field,n.order):s=!0}s&&this.savePersistedState()}catch(e){console.warn("WebGrid: Failed to load persisted state",e)}}savePersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const e=`wg-${this._gridName}-state`,o={};this._shouldPersistColumnWidths&&(o.columnWidths=this.getColumnWidthsState()),this._shouldPersistColumnOrder&&(o.columnOrder=this.getColumnOrderState()),localStorage.setItem(e,JSON.stringify(o))}catch(e){console.warn("WebGrid: Failed to save persisted state",e)}}getColumnOrder(e){return this._columnOrder.get(e)}setColumnOrder(e){this._columnOrder.clear();for(const{field:o,order:i}of e)o!==void 0&&i!==void 0&&this._columnOrder.set(o,i);this.requestUpdate()}getColumnOrderState(){const e=this.visualColumns,o=this.totalFrozenColumns;return e.slice(o).map((i,r)=>({field:String(i.column.field),order:r}))}moveColumn(e,o){const i=this.visualColumns,r=this.totalFrozenColumns,s=i.slice(r),n=s.findIndex(d=>String(d.column.field)===e);if(n===-1||n===o)return;this._columnOrder.clear();const l=[...s],[a]=l.splice(n,1);l.splice(o,0,a),l.forEach((d,c)=>{this._columnOrder.set(String(d.column.field),c)}),this.requestUpdate()}}const Xn=':host{--wg-rem: 10px;font-family:var(--wg-font-family);display:block;position:relative;--wg-accent-color: var(--base-accent-color, #0078d4);--wg-accent-color-hover: var(--base-accent-color-hover, #106ebe);--wg-accent-color-active: var(--base-accent-color-active, #005a9e);--wg-accent-color-light: var(--base-accent-color-light, color-mix(in srgb, var(--wg-accent-color) 15%, transparent));--wg-text-color-1: var(--base-text-color-1, #242424);--wg-text-color-2: var(--base-text-color-2, #424242);--wg-text-color-3: var(--base-text-color-3, #707070);--wg-text-on-accent: var(--base-text-color-on-accent, #ffffff);--wg-surface-1: var(--base-main-bg, #ffffff);--wg-surface-2: var(--base-elevated-bg, #f5f5f5);--wg-surface-3: var(--base-hover-bg, #ebebeb);--wg-surface-floating: var(--base-dropdown-bg, var(--base-main-bg, #ffffff));--wg-border-color: var(--base-border-color, #e0e0e0);--wg-border-color-hover: var(--base-border-color, #d1d1d1);--wg-input-bg: var(--base-input-bg, #ffffff);--wg-input-color: var(--base-input-color, var(--wg-text-color-1));--wg-input-border: var(--base-input-border, 1px solid #d1d1d1);--wg-input-border-hover: var(--base-input-border-hover, 1px solid #0078d4);--wg-input-border-focus: var(--base-input-border-focus, 1px solid #0078d4);--wg-input-placeholder-color: var(--base-input-placeholder-color, #707070);--wg-danger-color: var(--base-danger-color, #d13438);--wg-danger-bg-light: var(--base-danger-bg-light, #fde7e9);--wg-hover-bg: var(--base-hover-bg, #f0f0f0);--wg-active-bg: var(--base-hover-bg, #e0e0e0);--wg-font-size-base: calc(var(--base-font-size-sm, 1.4) * var(--wg-rem));--wg-font-size-sm: calc(var(--base-font-size-xs, 1.2) * var(--wg-rem));--wg-font-size-xs: calc(var(--base-font-size-2xs, 1.1) * var(--wg-rem));--wg-font-size-lg: calc(var(--base-font-size-base, 1.6) * var(--wg-rem));--wg-font-family: var(--base-font-family, inherit);--wg-line-height-base: var(--base-line-height-normal, 1.5);--wg-font-weight-normal: var(--base-font-weight-normal, 400);--wg-font-weight-semibold: var(--base-font-weight-semibold, 600);--wg-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--wg-border-radius-sm: calc(var(--base-border-radius-sm, .4) * var(--wg-rem));--wg-border-radius-md: calc(var(--base-border-radius-md, .6) * var(--wg-rem));--wg-border-radius-lg: calc(var(--base-border-radius-lg, .8) * var(--wg-rem));--wg-spacing-xs: calc(.4 * var(--wg-rem));--wg-spacing-sm: calc(.8 * var(--wg-rem));--wg-spacing-md: calc(1.2 * var(--wg-rem));--wg-spacing-lg: calc(1.6 * var(--wg-rem));--wg-spacing-xl: calc(2.4 * var(--wg-rem));--wg-table-bg: var(--wg-surface-1);--wg-table-border: 1px solid var(--wg-border-color);--wg-row-number-width: calc(4 * var(--wg-rem));--wg-actions-column-width: calc(3.2 * var(--wg-rem));--wg-header-bg: var(--wg-surface-2);--wg-header-bg-hover: var(--wg-surface-3);--wg-header-bg-sorted: var(--wg-surface-3);--wg-header-color: var(--wg-text-color-1);--wg-header-border: 2px solid var(--wg-border-color);--wg-header-separator: 1px solid var(--wg-border-color);--wg-header-padding: var(--wg-spacing-sm);--wg-header-font-weight: var(--wg-font-weight-semibold);--wg-header-min-height: auto;--wg-cell-padding: var(--wg-spacing-sm);--wg-cell-padding-block: var(--wg-spacing-sm);--wg-cell-padding-inline: var(--wg-spacing-sm);--wg-row-min-height: auto;--wg-cell-color: var(--wg-text-color-1);--wg-cell-border: 1px solid var(--wg-border-color);--wg-cell-splitter-color: var(--wg-border-color);--wg-cell-splitter-width: 1px;--wg-cell-bg-hover: var(--wg-hover-bg);--wg-cell-bg-editing: var(--wg-surface-1);--wg-cell-readonly-bg: var(--base-disabled-bg, var(--wg-surface-2));--wg-row-border: 1px solid var(--wg-border-color);--wg-row-bg-even: var(--wg-surface-2);--wg-row-bg-hover: var(--wg-surface-3);--wg-filter-bg: var(--wg-surface-1);--wg-filter-border: 1px solid var(--wg-border-color);--wg-filter-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-filter-input-padding: calc(.4 * var(--wg-rem)) calc(.8 * var(--wg-rem));--wg-filter-input-bg: var(--wg-input-bg);--wg-filter-input-border: var(--wg-input-border);--wg-filter-input-border-focus: var(--wg-input-border-focus);--wg-filter-input-border-radius: var(--wg-border-radius-sm);--wg-filter-input-font-size: var(--wg-font-size-sm);--wg-sort-indicator-size: calc(1.4 * var(--wg-rem));--wg-sort-indicator-opacity: .9;--wg-sort-placeholder-opacity: .3;--wg-sort-priority-size: calc(1.1 * var(--wg-rem));--wg-pagination-padding: var(--wg-spacing-md);--wg-pagination-gap: calc(1.6 * var(--wg-rem));--wg-pagination-bg: var(--wg-surface-1);--wg-pagination-border: 1px solid var(--wg-border-color);--wg-pagination-btn-padding: calc(.6 * var(--wg-rem)) calc(1.6 * var(--wg-rem));--wg-pagination-btn-bg: var(--wg-surface-1);--wg-pagination-btn-bg-hover: var(--wg-surface-2);--wg-pagination-btn-bg-active: var(--wg-surface-3);--wg-pagination-btn-border: 1px solid var(--wg-border-color);--wg-pagination-btn-border-hover: 1px solid var(--wg-border-color-hover);--wg-pagination-btn-border-radius: var(--wg-border-radius-sm);--wg-pagination-btn-disabled-opacity: .4;--wg-empty-padding: var(--wg-spacing-xl);--wg-empty-color: var(--wg-text-color-3);--wg-error-cell-bg: var(--wg-danger-bg-light);--wg-error-cell-border: 1px solid var(--wg-danger-color);--wg-error-message-color: var(--wg-danger-color);--wg-error-message-font-size: var(--wg-font-size-xs);--wg-error-indicator-color: var(--wg-danger-color);--wg-dirty-indicator-color: #ed8b00;--wg-dirty-indicator-size: 6px;--wg-dirty-cell-bg: rgba(237, 139, 0, .08);--wg-dirty-row-number-border-color: #ed8b00;--wg-editor-bg: var(--wg-surface-1);--wg-editor-outline: 2px solid var(--wg-accent-color);--wg-editor-outline-offset: -2px;--wg-editor-validating-opacity: .7;--wg-dropdown-toggle-right: var(--wg-spacing-sm);--wg-dropdown-toggle-size: calc(1.2 * var(--wg-rem));--wg-dropdown-toggle-hitbox: calc(2.4 * var(--wg-rem));--wg-date-trigger-size: calc(2.8 * var(--wg-rem));--wg-editor-hitbox-height: calc(4.8 * var(--wg-rem));--wg-checkbox-scale: 1.2;--wg-toolbar-bg: var(--wg-surface-floating);--wg-toolbar-border: 1px solid var(--wg-border-color);--wg-toolbar-border-radius: var(--wg-border-radius-sm);--wg-toolbar-shadow: var(--base-dropdown-box-shadow, 0 2px 8px rgba(0, 0, 0, .15));--wg-toolbar-divider-color: var(--wg-border-color);--wg-toolbar-divider-height: calc(1.6 * var(--wg-rem));--wg-toolbar-row-height: calc(3.7 * var(--wg-rem));--wg-toolbar-icon-size: calc(1.6 * var(--wg-rem));--wg-toolbar-btn-min-width: calc(2.4 * var(--wg-rem));--wg-toolbar-btn-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-btn-border-radius: var(--wg-border-radius-sm);--wg-toolbar-btn-bg-hover: var(--wg-hover-bg);--wg-toolbar-btn-bg-active: var(--wg-active-bg);--wg-toolbar-btn-color: var(--wg-text-color-1);--wg-toolbar-trigger-color: var(--wg-text-color-3);--wg-toolbar-trigger-color-hover: var(--wg-text-color-1);--wg-toolbar-trigger-bg-hover: var(--wg-hover-bg);--wg-overlay-bg: rgba(0, 0, 0, .4);--wg-dialog-shadow: 0 4px 20px rgba(0, 0, 0, .15);--wg-tooltip-bg: var(--base-tooltip-bg, #333);--wg-tooltip-color: var(--base-tooltip-color, #fff);--wg-tooltip-max-width: 300px;--wg-tooltip-arrow-size: 8px;--wg-context-menu-z-index: var(--wg-z-context-menu);--wg-context-menu-min-width: calc(16 * var(--wg-rem));--wg-focus-outline: 2px solid var(--wg-accent-color);--wg-focus-outline-offset: -2px;--wg-focus-border-width: 2px;--wg-focus-border-color: var(--wg-accent-color);--wg-focus-bg: var(--wg-hover-bg);--wg-transition-fast: .1s ease;--wg-transition-normal: .15s ease;--wg-z-cell-highlight: 1;--wg-z-selection-border: 1;--wg-z-frozen: 2;--wg-z-header: 3;--wg-z-frozen-header: 4;--wg-z-fill-handle: 5;--wg-z-fill-handle-area: 4;--wg-z-resize-handle: 6;--wg-z-shortcuts-help: 10;--wg-z-reorder-indicator: 100;--wg-z-toolbar: 1000;--wg-z-context-menu: 1001;--wg-z-dropdown: 9999;--wg-z-reorder-ghost: 10000;--wg-z-tooltip: 10000;--wg-row-locked-bg: var(--base-disabled-bg, var(--wg-surface-2));--wg-row-locked-opacity: .7;--wg-frozen-column-bg: var(--wg-surface-1);--wg-frozen-header-bg: color-mix(in srgb, var(--wg-accent-color) 8%, var(--wg-header-bg));--wg-frozen-column-shadow: 2px 0 4px rgba(0, 0, 0, .1);--wg-frozen-column-shadow-active: 6px 0 12px rgba(0, 0, 0, .25);--wg-frozen-column-border: 2px solid var(--wg-border-color);--wg-frozen-column-shadow-gradient: linear-gradient(to right, rgba(0, 0, 0, .15), transparent);--wg-frozen-column-shadow-width: 8px;--wg-resize-handle-width: 12px;--wg-resize-handle-offset: -6px;--wg-resize-handle-line-width: 2px;--wg-resize-handle-color: var(--wg-border-color);--wg-resize-handle-active-color: var(--wg-accent-color);--wg-fill-handle-size: 8px;--wg-fill-handle-bg: var(--wg-surface-1);--wg-fill-handle-border-color: var(--wg-accent-color);--wg-fill-handle-border-width: 2px;--wg-fill-range-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-fill-range-border-color: var(--wg-accent-color);--wg-selection-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-selection-row-number-bg: var(--wg-accent-color);--wg-selection-row-number-color: var(--base-text-inverted, #fff);--wg-selection-border-width: 2px;--wg-selection-border-color: var(--wg-accent-color);--wg-row-focus-bg: color-mix(in srgb, var(--wg-accent-color) 10%, transparent);--wg-row-focus-row-number-bg: color-mix(in srgb, var(--wg-accent-color) 30%, transparent);--wg-cell-selection-bg: color-mix(in srgb, var(--wg-accent-color) 10%, transparent);--wg-cell-selection-border: var(--wg-accent-color);--wg-cell-selection-border-width: 2px;--wg-dropdown-max-height: 200px;--wg-dropdown-option-gap: var(--wg-spacing-sm);--wg-dropdown-option-padding: calc(.6 * var(--wg-rem)) var(--wg-spacing-sm) calc(.6 * var(--wg-rem)) calc(var(--wg-spacing-sm) - 1px);--wg-dropdown-empty-padding: calc(.8 * var(--wg-rem)) var(--wg-spacing-sm) calc(.8 * var(--wg-rem)) calc(var(--wg-spacing-sm) - 1px);--wg-inline-actions-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-inline-actions-gap: calc(.2 * var(--wg-rem));--wg-toolbar-row-gap: calc(.2 * var(--wg-rem));--wg-toolbar-row-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-label-font-size: var(--wg-font-size-sm);--wg-toolbar-btn-gap: calc(.4 * var(--wg-rem));--wg-tooltip-padding: calc(.6 * var(--wg-rem)) calc(1 * var(--wg-rem));--wg-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .2)}web-grid:not(:defined){display:block;min-height:calc(10 * var(--wg-rem));color:transparent!important;background:transparent}.wg{position:relative;width:100%;max-height:inherit;overflow:auto;overscroll-behavior:contain;border:var(--wg-table-border)}.wg--scrollable{max-height:var(--wg-scroll-max-height, 100vh)}.wg--table-border-only{border:none;overflow:visible;display:flex;flex-direction:column}.wg--table-border-only .wg__table-container{border:var(--wg-table-border);overflow:auto;max-height:inherit;flex:1;min-height:0}.wg--table-border-only .wg__table-container .wg__header{position:sticky;top:0;z-index:var(--wg-z-header)}.wg__table{width:100%;border-collapse:collapse;table-layout:fixed;background:var(--wg-table-bg);font-size:var(--wg-font-size-base);line-height:var(--wg-line-height-base)}.wg__filler{width:auto;min-width:0;padding:0!important;border:none!important;box-shadow:none!important}th.wg__filler{position:sticky;top:0;z-index:var(--wg-z-header);background:var(--wg-header-bg);box-shadow:inset 0 -2px 0 var(--wg-border-color)!important}td.wg__filler{background:transparent}.wg__table tbody tr{border-bottom:var(--wg-row-border)}.wg__row-number-header,.wg__row-number{width:var(--wg-row-number-width);min-width:var(--wg-row-number-width);max-width:var(--wg-row-number-width);box-sizing:border-box;text-align:center;color:var(--wg-text-color-2);background:var(--wg-header-bg);-webkit-user-select:none;user-select:none;font-size:var(--wg-font-size-sm)}.wg__row-number-header{cursor:pointer}.wg__row-number-header:hover{background:var(--wg-hover-bg)}.wg__row-number{box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__actions-column{width:var(--wg-actions-column-width);min-width:var(--wg-actions-column-width);max-width:var(--wg-actions-column-width);padding:0!important;text-align:center}thead .wg__actions-column{background:var(--wg-header-bg);box-shadow:inset 0 -2px 0 var(--wg-border-color)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__header{position:sticky;top:0;z-index:var(--wg-z-header);background:var(--wg-header-bg);color:var(--wg-header-color);font-weight:var(--wg-header-font-weight);padding:var(--wg-header-padding);height:var(--wg-header-min-height);box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color),inset 0 -2px 0 var(--wg-border-color);box-sizing:border-box;-webkit-user-select:none;user-select:none;overflow:hidden}.wg__header:last-child{box-shadow:inset 0 -2px 0 var(--wg-border-color)}.wg__header--sortable{cursor:pointer}.wg__header--sortable:hover{background:var(--wg-header-bg-hover)}.wg__header--sorted{background:var(--wg-header-bg-sorted)}.wg__header--selected,.wg__header--selected:hover{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__header-container{display:flex;align-items:stretch;gap:var(--wg-spacing-xs);height:100%}.wg__header-content{flex:1;min-width:0;display:flex;align-items:center;justify-content:flex-start}.wg__header-content--align-left{justify-content:flex-start}.wg__header-content--align-center{justify-content:center}.wg__header-content--align-right{justify-content:flex-end}.wg__header-content--align-justify{justify-content:flex-start}.wg__header-content--valign-top{align-items:flex-start}.wg__header-content--valign-middle{align-items:center}.wg__header-content--valign-bottom{align-items:flex-end}.wg__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__header-controls{flex-shrink:0;display:flex;align-items:center}.wg__sort-indicator{font-size:var(--wg-sort-indicator-size);opacity:var(--wg-sort-indicator-opacity);min-width:16px;text-align:center}.wg__sort-placeholder{opacity:var(--wg-sort-placeholder-opacity)}.wg__sort-priority{font-size:var(--wg-sort-priority-size);font-weight:var(--wg-font-weight-semibold);margin-left:2px;vertical-align:super;line-height:1}.wg__header-info{display:inline-flex;align-items:center;color:var(--wg-accent-color);cursor:help;opacity:.7;margin-left:var(--wg-spacing-xs);vertical-align:middle}.wg__header-info:hover{opacity:1}.wg__filter-row th{padding:var(--wg-filter-padding);background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__filter-input{width:100%;padding:var(--wg-filter-input-padding);border:var(--wg-filter-input-border);border-radius:var(--wg-filter-input-border-radius);background:var(--wg-surface-1);color:var(--wg-text-color-1);font-family:inherit;font-size:var(--wg-filter-input-font-size);box-sizing:border-box}.wg__filter-input:focus{outline:none;border:var(--wg-filter-input-border-focus);box-shadow:0 0 0 1px var(--wg-accent-color)}.wg__resize-handle{position:absolute;top:0;right:var(--wg-resize-handle-offset);bottom:0;width:var(--wg-resize-handle-width);cursor:col-resize;z-index:var(--wg-z-resize-handle);opacity:0;transition:opacity .1s ease}.wg__header:hover .wg__resize-handle{opacity:1}.wg__resize-handle:after{content:"";position:absolute;top:25%;bottom:25%;left:50%;width:var(--wg-resize-handle-line-width);background:var(--wg-resize-handle-color);transform:translate(-50%);border-radius:1px}.wg__resize-handle:hover:after{background:var(--wg-resize-handle-active-color);top:15%;bottom:15%}.wg__resize-handle--active:after{background:var(--wg-resize-handle-active-color);top:0;bottom:0}.wg__resize-handle--disabled{cursor:not-allowed}.wg__resize-handle--disabled:after{display:none}.wg--resizing .wg__resize-handle{opacity:1}.wg--resizing{-webkit-user-select:none;user-select:none;cursor:col-resize}.wg--resizing .wg__cell,.wg--resizing .wg__header{cursor:col-resize}.wg--resizing .wg__table{min-width:0!important}.wg__header--dragging{opacity:1;background:var(--wg-header-bg)!important;outline:2px dashed var(--wg-accent-color);outline-offset:-2px}.wg__reorder-ghost{position:fixed;z-index:var(--wg-z-reorder-ghost);background:var(--wg-header-bg);border:2px solid var(--wg-accent-color);border-radius:var(--wg-border-radius-sm);padding:.4em .8em;font-size:var(--wg-font-size-sm);font-weight:var(--wg-header-font-weight);color:var(--wg-header-color);box-shadow:var(--wg-dialog-shadow);opacity:.95;pointer-events:none;white-space:nowrap}.wg__drop-indicator{position:absolute;width:3px;background:var(--wg-accent-color);z-index:var(--wg-z-reorder-indicator);pointer-events:none;display:none}.wg__drop-indicator:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);border-left:6px solid transparent;border-right:6px solid transparent;border-top:8px solid var(--wg-accent-color)}.wg--reordering{cursor:grabbing;-webkit-user-select:none;user-select:none}.wg--reordering .wg__cell,.wg--reordering .wg__header{cursor:grabbing}.wg--reorderable .wg__header:not(.wg__header--frozen):hover{cursor:grab}.wg__header--frozen{cursor:default}.wg__fill-handle{position:absolute;width:var(--wg-fill-handle-size);height:var(--wg-fill-handle-size);background:var(--wg-fill-handle-bg);border:var(--wg-fill-handle-border-width) solid var(--wg-fill-handle-border-color);cursor:crosshair;z-index:var(--wg-z-fill-handle);pointer-events:auto;box-sizing:border-box}.wg__fill-handle:hover{transform:scale(1.2)}.wg__fill-range{position:absolute;background:var(--wg-fill-range-bg);border:1px dashed var(--wg-fill-range-border-color);pointer-events:none;z-index:var(--wg-z-fill-handle-area);box-sizing:border-box}.wg--filling{cursor:crosshair;-webkit-user-select:none;user-select:none}.wg--filling .wg__cell,.wg--filling .wg__header{cursor:crosshair}.wg__cell--editing .wg__fill-handle{display:none}.wg__row--selected>.wg__cell{background:var(--wg-selection-bg)}.wg__row--selected>.wg__cell.wg__row-number,.wg--editable.wg--navigate-mode .wg__row--selected>.wg__cell.wg__row-number{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__row-number[data-row-number]{cursor:pointer;-webkit-user-select:none;user-select:none}.wg__row-number[data-row-number]:hover{background:var(--wg-hover-bg)}.wg__row--selected>.wg__cell.wg__row-number:hover,.wg--editable.wg--navigate-mode .wg__row--selected>.wg__cell.wg__row-number:hover{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__cell--column-selected{background:var(--wg-selection-bg)}.wg--selecting{cursor:default;-webkit-user-select:none;user-select:none}.wg--selecting *{-webkit-user-select:none;user-select:none}.wg:focus{outline:none}.wg__cell--in-range{background:var(--wg-cell-selection-bg)!important;position:relative;z-index:var(--wg-z-cell-highlight)}.wg__cell--editing.wg__cell--in-range{background:var(--wg-input-bg)!important}.wg__cell--editable.wg__cell--in-range:hover{background:var(--wg-cell-selection-bg)!important}.wg__cell--editable.wg__cell--in-range:hover:after{display:none}.wg__cell-range-border{position:absolute;border:var(--wg-cell-selection-border-width) solid var(--wg-cell-selection-border);pointer-events:none;z-index:var(--wg-z-selection-border);box-sizing:border-box;border-radius:1px}.wg--selecting-cells,.wg--selecting-cells *{cursor:crosshair!important;-webkit-user-select:none;user-select:none}.wg--selecting-cells .wg__cell{cursor:crosshair!important}.wg:has(.wg__cell-range-border) .wg__fill-handle{display:none}.wg__row-selection-border,.wg__column-selection-border{position:absolute;border:var(--wg-selection-border-width) solid var(--wg-selection-border-color);pointer-events:none;z-index:var(--wg-z-selection-border);box-sizing:border-box;border-radius:1px}.wg--selecting-columns,.wg--selecting-columns *{cursor:col-resize!important;-webkit-user-select:none;user-select:none}.wg--selecting-columns .wg__header{cursor:col-resize!important}.wg__header--frozen{background:var(--wg-frozen-header-bg, var(--wg-header-bg));z-index:var(--wg-z-frozen-header)!important}.wg__header--frozen.wg__header--selected,.wg__header--frozen.wg__header--selected:hover{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__row-number-header.wg__header--frozen{z-index:var(--wg-z-frozen-header)!important}.wg__cell--frozen{background:var(--wg-frozen-column-bg, var(--wg-surface-1))}.wg__cell--frozen-last{box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__row-number.wg__cell--frozen{background:var(--wg-header-bg);z-index:var(--wg-z-frozen)!important}.wg--striped tbody tr:nth-child(2n) .wg__cell--frozen{background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover .wg__cell--frozen{background:var(--wg-row-bg-hover)}.wg__row--focused>.wg__cell--frozen{background:color-mix(in srgb,var(--wg-accent-color) 10%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__row--selected>.wg__cell--frozen{background:color-mix(in srgb,var(--wg-accent-color) 15%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__row--selected>.wg__row-number.wg__cell--frozen{background:var(--wg-selection-row-number-bg)!important;color:var(--wg-selection-row-number-color)}.wg__cell--frozen.wg__cell--column-selected{background:color-mix(in srgb,var(--wg-accent-color) 15%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__cell--frozen.wg__cell--in-range{background:color-mix(in srgb,var(--wg-accent-color) 10%,var(--wg-frozen-column-bg, var(--wg-surface-1)))!important}.wg__header.wg__header--frozen-last,.wg__cell.wg__cell--frozen-last{overflow:visible}.wg--scrolled-horizontal .wg__header--frozen-last:after,.wg--scrolled-horizontal .wg__cell--frozen-last:after{content:"";position:absolute;top:0;right:calc(-1 * var(--wg-frozen-column-shadow-width));bottom:0;width:var(--wg-frozen-column-shadow-width);background:var(--wg-frozen-column-shadow-gradient);pointer-events:none}.wg__cell{padding:var(--wg-cell-padding);color:var(--wg-cell-color);height:var(--wg-row-min-height);box-sizing:border-box;position:relative;scroll-margin-top:calc(3 * var(--wg-rem));scroll-margin-bottom:calc(.5 * var(--wg-rem));-webkit-user-select:none;user-select:none;overflow:hidden;box-shadow:inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__cell-text{-webkit-user-select:none;user-select:none;pointer-events:none}.wg__cell--ellipsis .wg__cell-text{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__cell--line-clamp .wg__cell-text{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}.wg__cell--editable{cursor:pointer}.wg__cell--editable:hover{background:var(--wg-cell-bg-hover)}.wg__cell--editable:hover:after{content:"";position:absolute;top:2px;right:2px;bottom:2px;left:2px;border:1px dashed var(--wg-border-color);border-radius:2px;pointer-events:none}.wg__cell--editing{position:relative;background:var(--wg-surface-1);outline:2px solid var(--wg-accent-color);outline-offset:-2px;z-index:var(--wg-z-cell-highlight)}.wg__cell--editing:after{display:none}.wg__cell--invalid{background:var(--wg-danger-bg-light);box-shadow:inset 0 0 0 2px var(--wg-danger-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg--editable.wg--navigate-mode .wg__cell:not(.wg__cell--editable){background:var(--wg-cell-readonly-bg)}.wg__row--locked{background:var(--wg-row-locked-bg)!important}.wg__row--locked .wg__cell{opacity:var(--wg-row-locked-opacity)}.wg__row--locked .wg__cell--editable{cursor:not-allowed}.wg__row--locked .wg__cell--editable:hover{background:inherit}.wg__row--locked .wg__cell--editable:hover:after{display:none}.wg__row-number--locked{opacity:1!important;cursor:help}.wg__cell--dirty{background:var(--wg-dirty-cell-bg)!important}.wg__cell--dirty:before{content:"";position:absolute;top:0;left:0;width:0;height:0;border-style:solid;border-width:var(--wg-dirty-indicator-size) var(--wg-dirty-indicator-size) 0 0;border-color:var(--wg-dirty-indicator-color) transparent transparent transparent;pointer-events:none}.wg__cell--dirty.wg__cell--editing:before{display:none}.wg__row-number--dirty{box-shadow:inset 3px 0 0 var(--wg-dirty-row-number-border-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__editor{position:absolute;top:0;left:0;right:0;width:100%;padding:var(--wg-cell-padding);border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:inherit;box-sizing:border-box}.wg__editor:focus,.wg__editor:focus-visible{outline:none;box-shadow:none}.wg__editor--text{text-align:inherit}.wg__editor--number{text-align:right}.wg__editor--valign-top{top:0;bottom:auto}.wg__editor--valign-middle{top:0;bottom:0}.wg__editor--valign-bottom{top:auto;bottom:0}.wg__editor--date{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:transparent;padding:var(--wg-cell-padding)}.wg__date-input{flex:1;min-width:0;height:100%;border:none;background:transparent;font:inherit;padding:0;outline:none;color:inherit}.wg__date-trigger{width:var(--wg-date-trigger-size);height:100%;display:flex;align-items:center;justify-content:center;border:none;background:transparent;color:var(--wg-text-color-3);cursor:pointer;padding:0;flex-shrink:0}.wg__date-trigger:hover{color:var(--wg-accent-color);background:var(--wg-hover-bg)}.wg__editor--checkbox{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(var(--wg-checkbox-scale));width:auto;height:auto;margin:0;padding:0;cursor:pointer}.wg__checkbox-display{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(var(--wg-checkbox-scale));width:auto;height:auto;margin:0;padding:0;cursor:pointer;pointer-events:none}.wg__checkbox-display--readonly{cursor:default;opacity:.5}.wg__editor--custom{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:var(--wg-editor-bg);padding:var(--wg-cell-padding-block) var(--wg-cell-padding-inline);cursor:pointer}.wg__editor--custom:focus{outline:none}.wg__custom-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;cursor:pointer}.wg__editor--combobox,.wg__editor--autocomplete{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:var(--wg-cell-padding);padding-right:0;background:transparent;box-sizing:border-box}.wg__combobox-input,.wg__autocomplete-input{flex:1;width:100%;height:100%;padding:0;padding-right:var(--wg-dropdown-toggle-hitbox);border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base);outline:none;box-sizing:border-box;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.wg__combobox-input:focus,.wg__autocomplete-input:focus{outline:none}.wg__combobox-toggle{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:var(--wg-dropdown-toggle-size);color:var(--wg-text-color-2);pointer-events:auto;cursor:pointer}.wg__combobox-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__loading-indicator{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:var(--wg-font-size-sm);animation:wg-pulse 1s infinite}@keyframes wg-pulse{0%,to{opacity:1}50%{opacity:.4}}.wg__select-trigger{display:flex;align-items:center;justify-content:space-between;cursor:pointer;background:transparent}.wg__select-trigger:focus,.wg__select-trigger:focus-visible{outline:none;box-shadow:none}.wg__select-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__select-toggle{position:relative;font-size:var(--wg-dropdown-toggle-size);opacity:.6;margin-left:var(--wg-spacing-xs);flex-shrink:0;pointer-events:auto;cursor:pointer}.wg__select-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__cell-dropdown-display{display:flex;align-items:center;justify-content:space-between;width:100%;pointer-events:none}.wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:0}.wg__cell:hover .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle,.wg__cell--focused .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:.6}.wg__cell-date-display{display:flex;align-items:center;justify-content:space-between;width:100%;pointer-events:none}.wg__cell-date-display .wg__date-trigger{position:relative;background:none;border:none;padding:0;margin:0;cursor:pointer;opacity:.6;display:flex;align-items:center;justify-content:center;color:inherit;pointer-events:auto}.wg__cell-date-display .wg__date-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:0}.wg__cell:hover .wg__cell-date-display--toggle-on-focus .wg__date-trigger,.wg__cell--focused .wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:.6}.wg__dropdown{background:var(--wg-surface-floating);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);box-shadow:var(--wg-toolbar-shadow);max-height:var(--wg-dropdown-max-height);overflow-y:auto;font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base)}.wg__dropdown-option{display:flex;align-items:center;gap:var(--wg-dropdown-option-gap);padding:var(--wg-dropdown-option-padding);cursor:pointer;color:var(--wg-text-color-1)}.wg__dropdown-option:hover,.wg__dropdown-option--highlighted{background:var(--wg-hover-bg);box-shadow:inset 0 0 0 2px var(--wg-accent-color)}.wg__dropdown-option--selected{background:var(--wg-accent-color-light)}.wg__dropdown-option--disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.wg__dropdown-option-icon{flex-shrink:0;width:1.5em;text-align:center}.wg__dropdown-option-content{flex:1;min-width:0;overflow:hidden}.wg__dropdown-option-label{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-option-subtitle{display:block;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-empty{padding:var(--wg-dropdown-empty-padding);color:var(--wg-text-color-2);font-style:italic;text-align:center}.wg__dropdown-option--align-left{justify-content:flex-start}.wg__dropdown-option--align-left .wg__dropdown-option-content{text-align:left}.wg__dropdown-option--align-center{justify-content:center}.wg__dropdown-option--align-center .wg__dropdown-option-content{text-align:center}.wg__dropdown-option--align-right{justify-content:flex-end}.wg__dropdown-option--align-right .wg__dropdown-option-content{text-align:right}.wg__dropdown-option--align-justify{justify-content:flex-start}.wg__dropdown-option--align-justify .wg__dropdown-option-content{text-align:justify}.wg--navigate-mode .wg__cell{cursor:cell}.wg__cell:focus{outline:none;box-shadow:inset 0 0 0 var(--wg-focus-border-width) var(--wg-focus-border-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__cell.wg__cell--focused,.wg__cell.wg__cell--always-edit-focused{box-shadow:inset 0 0 0 var(--wg-focus-border-width) var(--wg-focus-border-color),inset calc(-1 * var(--wg-cell-splitter-width)) 0 0 var(--wg-cell-splitter-color)}.wg__cell--focused:after,.wg__cell--always-edit-focused:after{display:none}.wg__row--focused>.wg__cell{background:var(--wg-row-focus-bg)}.wg__row--focused>.wg__cell.wg__row-number{background:var(--wg-row-focus-row-number-bg)}.wg--editable.wg--navigate-mode .wg__row--focused>.wg__cell{background:var(--wg-row-focus-bg)}.wg--editable.wg--navigate-mode .wg__row--focused>.wg__cell.wg__row-number{background:var(--wg-row-focus-row-number-bg)}.wg__pagination{display:flex;align-items:center;justify-content:center;gap:var(--wg-pagination-gap);padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__pagination-btn{padding:var(--wg-pagination-btn-padding);background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer;transition:all var(--wg-transition-fast)}.wg__pagination-btn:hover:not(:disabled){background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-btn:active:not(:disabled){background:var(--wg-pagination-btn-bg-active)}.wg__pagination-btn:disabled{opacity:var(--wg-pagination-btn-disabled-opacity);cursor:not-allowed}.wg__pagination-info{font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__pagination-count{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3);margin-left:var(--wg-spacing-xs)}.wg__pagination-pagesize{display:flex;align-items:center;gap:calc(.6 * var(--wg-rem))}.wg__pagination-select{padding:var(--wg-spacing-xs) var(--wg-spacing-sm);background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer}.wg__pagination-select:hover{background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-select:focus{outline:2px solid var(--wg-accent-color);outline-offset:-2px}.wg__pagination-label{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3)}.wg__pagination--left{justify-content:flex-start}.wg__pagination--right{justify-content:flex-end}.wg__pagination--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__summary{display:flex;align-items:center;padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg);font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__summary--left{justify-content:flex-start}.wg__summary--right{justify-content:flex-end}.wg__summary--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer{display:flex;align-items:center;justify-content:space-between;border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__footer--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer .wg__summary,.wg__footer .wg__pagination{border:none}.wg__footer .wg__summary{flex:0 0 auto}.wg__footer .wg__pagination{flex:0 0 auto;margin-left:auto}.wg__toolbar-container{position:fixed;z-index:var(--wg-z-toolbar)}.wg__toolbar{display:flex;flex-direction:column-reverse;gap:0;padding:0;background:var(--wg-toolbar-bg);border:var(--wg-toolbar-border);border-radius:var(--wg-toolbar-border-radius);box-shadow:var(--wg-toolbar-shadow)}.wg__toolbar-row{display:flex;gap:var(--wg-toolbar-row-gap);align-items:center;height:var(--wg-toolbar-row-height);padding:var(--wg-toolbar-row-padding)}.wg__toolbar-row+.wg__toolbar-row{border-top:1px solid var(--wg-toolbar-divider-color)}.wg__toolbar-divider{width:1px;height:var(--wg-toolbar-divider-height);background:var(--wg-toolbar-divider-color);margin:0 var(--wg-spacing-xs);flex-shrink:0}.wg__toolbar-btn{min-width:var(--wg-toolbar-btn-min-width);height:100%;border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--wg-toolbar-btn-gap);font-family:inherit;font-size:var(--wg-font-size-base);font-weight:var(--wg-font-weight-normal);padding:var(--wg-toolbar-btn-padding);transition:background .1s ease}.wg__toolbar-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__toolbar-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__toolbar-btn:disabled{opacity:.5;cursor:not-allowed}.wg__toolbar-btn:disabled:hover{background:transparent}.wg__toolbar-btn svg{width:var(--wg-toolbar-icon-size);height:var(--wg-toolbar-icon-size);flex-shrink:0}.wg__toolbar-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__toolbar-label{font-size:var(--wg-toolbar-label-font-size);white-space:nowrap}.wg__actions-column{width:var(--wg-toolbar-btn-min-width);min-width:var(--wg-toolbar-btn-min-width);max-width:var(--wg-toolbar-btn-min-width);padding:0!important;text-align:center}.wg__header .wg__actions-column{background:var(--wg-header-bg)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg)}.wg__toolbar-trigger{position:relative;padding:0;background:transparent;border:none;border-radius:var(--wg-border-radius-sm);cursor:pointer;font-size:var(--wg-font-size-base);line-height:1;color:var(--wg-toolbar-trigger-color)}.wg__toolbar-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:var(--wg-editor-hitbox-height)}.wg__toolbar-trigger:hover,.wg__toolbar-trigger--active{color:var(--wg-toolbar-trigger-color-hover);background:var(--wg-toolbar-trigger-bg-hover)}.wg__inline-actions-header,.wg__inline-actions-cell{white-space:nowrap;text-align:start;padding:var(--wg-inline-actions-padding);overflow:visible}.wg__inline-actions-header{background:var(--wg-header-bg)}.wg__inline-actions-wrap{display:flex;flex-direction:column;gap:var(--wg-inline-actions-gap);align-items:flex-start}.wg__inline-actions-row{display:flex;gap:var(--wg-inline-actions-gap);align-items:center;justify-content:flex-start}.wg__inline-action-btn{width:var(--wg-toolbar-btn-min-width);max-width:var(--wg-toolbar-btn-min-width);height:calc(2.4 * var(--wg-rem));border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;box-sizing:border-box;font-family:inherit;font-size:var(--wg-font-size-base);transition:background var(--wg-transition-fast)}.wg__inline-action-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__inline-action-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__inline-action-btn:disabled,.wg__inline-action-btn--disabled{opacity:.5;cursor:not-allowed}.wg__inline-action-btn:disabled:hover,.wg__inline-action-btn--disabled:hover{background:transparent}.wg__inline-action-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__inline-action-btn svg{width:var(--wg-toolbar-icon-size);height:var(--wg-toolbar-icon-size);flex-shrink:0}.wg__shortcuts-help{position:absolute;top:var(--wg-spacing-xs);right:var(--wg-spacing-sm);z-index:var(--wg-z-shortcuts-help)}.wg__shortcuts-help--left{right:auto;left:var(--wg-spacing-sm)}.wg__shortcuts-help-icon{display:flex;align-items:center;justify-content:center;width:var(--wg-spacing-xl);height:var(--wg-spacing-xl);padding:0;border:none;border-radius:50%;background:var(--wg-surface-1);color:var(--wg-text-color-2);cursor:pointer;opacity:.7}.wg__shortcuts-help-icon:hover{opacity:1;background:var(--wg-surface-2)}.wg__shortcuts-help-icon svg{width:var(--wg-toolbar-icon-size);height:var(--wg-toolbar-icon-size)}.wg__shortcuts-help-overlay{display:none;position:absolute;top:100%;right:0;margin-top:var(--wg-spacing-xs);padding:var(--wg-spacing-md);background:var(--wg-surface-1);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-md);box-shadow:var(--wg-dialog-shadow);min-width:200px;max-width:var(--wg-tooltip-max-width);z-index:100}.wg__shortcuts-help--left .wg__shortcuts-help-overlay{right:auto;left:0}.wg__shortcuts-help:hover .wg__shortcuts-help-overlay,.wg__shortcuts-help:focus-within .wg__shortcuts-help-overlay{display:block}.wg__shortcuts-help-title{font-weight:var(--wg-font-weight-semibold);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1);margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-xs);border-bottom:1px solid var(--wg-border-color)}.wg__shortcuts-help-custom{margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-sm);border-bottom:1px solid var(--wg-border-color);font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg__shortcuts-help-list{display:flex;flex-direction:column;gap:var(--wg-spacing-xs)}.wg__shortcuts-help-item{display:flex;align-items:center;gap:var(--wg-spacing-md)}.wg__shortcuts-help-key{display:inline-flex;align-items:center;justify-content:center;min-width:28px;padding:2px calc(.6 * var(--wg-rem));font-family:var(--wg-font-family-mono);font-size:var(--wg-font-size-xs);font-weight:var(--wg-font-weight-semibold);color:var(--wg-text-color-1);background:var(--wg-surface-2);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm)}.wg__shortcuts-help-label{flex:1;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg--striped tbody tr:nth-child(2n){background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover{background:var(--wg-row-bg-hover)}.wg__empty{text-align:center;padding:var(--wg-empty-padding);color:var(--wg-empty-color);font-style:italic}.wg__loading-more{text-align:center;padding:var(--wg-cell-padding);color:var(--wg-text-color-2);font-size:var(--wg-font-size-sm)}.wg__tooltip{position:absolute;z-index:var(--wg-z-tooltip);max-width:var(--wg-tooltip-max-width);padding:var(--wg-tooltip-padding);background:var(--wg-tooltip-bg);color:var(--wg-tooltip-color);font-size:var(--wg-font-size-sm);line-height:1.4;border-radius:var(--wg-border-radius-sm);box-shadow:var(--wg-tooltip-shadow);pointer-events:none;opacity:0;transition:opacity var(--wg-transition-fast)}.wg__tooltip--visible{opacity:1}.wg__tooltip-arrow{position:absolute;width:var(--wg-tooltip-arrow-size);height:var(--wg-tooltip-arrow-size);background:var(--wg-tooltip-bg);transform:rotate(45deg)}.wg__tooltip[data-placement^=top] .wg__tooltip-arrow{bottom:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip[data-placement^=bottom] .wg__tooltip-arrow{top:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip[data-placement^=left] .wg__tooltip-arrow{right:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip[data-placement^=right] .wg__tooltip-arrow{left:calc(-.5 * var(--wg-tooltip-arrow-size))}.wg__tooltip-title{font-weight:600}.wg__tooltip-desc{opacity:.85;margin-top:2px}.wg__tooltip-shortcut{margin-top:4px;opacity:.7;font-size:.9em}.wg__goto-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:var(--wg-overlay-bg);display:flex;align-items:center;justify-content:center;z-index:1000}.wg__goto-dialog{background:var(--wg-surface-1);border-radius:var(--wg-border-radius-md);padding:var(--wg-spacing-lg);box-shadow:var(--wg-dialog-shadow);min-width:250px}.wg__goto-label{display:block;margin-bottom:var(--wg-spacing-sm);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1)}.wg__goto-input{width:100%;padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-base);margin-bottom:var(--wg-spacing-md);box-sizing:border-box}.wg__goto-input:focus{outline:none;border-color:var(--wg-accent-color);box-shadow:0 0 0 2px color-mix(in srgb,var(--wg-accent-color) 20%,transparent)}.wg__goto-buttons{display:flex;gap:var(--wg-spacing-sm);justify-content:flex-end}.wg__goto-btn{padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-sm);cursor:pointer;background:var(--wg-surface-1);color:var(--wg-text-color-1)}.wg__goto-btn:hover{background:var(--wg-surface-2)}.wg__goto-btn--go{background:var(--wg-accent-color);border-color:var(--wg-accent-color);color:var(--wg-text-on-accent)}.wg__goto-btn--go:hover{background:var(--wg-accent-color-hover)}.wg__spacer-top td,.wg__spacer-bottom td{padding:0;border:none;background:transparent;height:inherit;line-height:0}:host{--wg-tree-indent: 1.25rem;--wg-tree-chevron-size: 1rem;--wg-tree-chevron-color: var(--wg-text-color-2);--wg-tree-chevron-gap: 4px}.wg__tree-cell{display:inline-flex;align-items:center;gap:var(--wg-tree-chevron-gap)}.wg__tree-cell-body{min-width:0;overflow:hidden;text-overflow:inherit;white-space:inherit}.wg__tree-chevron{all:unset;display:inline-flex;align-items:center;justify-content:center;width:var(--wg-tree-chevron-size);height:var(--wg-tree-chevron-size);border-radius:2px;font-size:.85em;line-height:1;color:var(--wg-tree-chevron-color);cursor:pointer;flex-shrink:0;transition:transform .12s ease,background .1s ease}.wg__tree-chevron:hover:not(.wg__tree-chevron--leaf){background:var(--wg-hover-bg)}.wg__tree-chevron--expanded{transform:rotate(90deg)}.wg__tree-leaf-spacer{display:inline-block;width:var(--wg-tree-chevron-size);height:var(--wg-tree-chevron-size);flex-shrink:0}.wg__cell--editing .wg__tree-chevron,.wg__cell--editing .wg__tree-leaf-spacer{display:none}.wg__cell--editing .wg__tree-cell{display:contents}@media (prefers-color-scheme: dark){:host{--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86;--wg-dirty-indicator-color: #ffa940;--wg-dirty-cell-bg: rgba(255, 169, 64, .12);--wg-dirty-row-number-border-color: #ffa940}}:host([data-theme="dark"]),:host-context([data-theme="dark"]),:host([data-bs-theme="dark"]),:host-context([data-bs-theme="dark"]),:host-context(.dark){--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86;--wg-dirty-indicator-color: #ffa940;--wg-dirty-row-number-border-color: #ffa940}:host([data-theme="light"]),:host-context([data-theme="light"]),:host([data-bs-theme="light"]),:host-context([data-bs-theme="light"]),:host-context(.light){--wg-surface-1: var(--base-main-bg, #ffffff);--wg-surface-2: var(--base-elevated-bg, #f5f5f5);--wg-surface-3: var(--base-hover-bg, #ebebeb);--wg-surface-floating: var(--base-dropdown-bg, var(--base-main-bg, #ffffff));--wg-text-color-1: var(--base-text-color-1, #242424);--wg-text-color-2: var(--base-text-color-2, #424242);--wg-text-color-3: var(--base-text-color-3, #707070);--wg-border-color: var(--base-border-color, #e0e0e0);--wg-border-color-hover: var(--base-border-color, #d1d1d1);--wg-input-bg: var(--base-input-bg, #ffffff);--wg-input-border: var(--base-input-border, 1px solid #d1d1d1);--wg-hover-bg: var(--base-hover-bg, #f0f0f0);--wg-active-bg: var(--base-hover-bg, #e0e0e0);--wg-danger-bg-light: var(--base-danger-bg-light, #fde7e9);--wg-danger-color: var(--base-danger-color, #d13438)}';function ut(t,e,o){const i=o.valueMember||"value",r=e.find(s=>s[i]===t);return r?Ue(r,o):t!=null?String(t):""}function Ue(t,e){if(e.getDisplayCallback)return e.getDisplayCallback(t);const o=e.displayMember||"label";return String(t[o]??t.label??"")}function ze(t,e){if(e.getValueCallback)return e.getValueCallback(t);const o=e.valueMember||"value";return t[o]??t.value}function Gn(t,e){return e.getIconCallback?e.getIconCallback(t):e.iconMember&&t[e.iconMember]||null}function Qn(t,e){return e.getSubtitleCallback?e.getSubtitleCallback(t):e.subtitleMember&&t[e.subtitleMember]||null}function de(t,e){return e.getDisabledCallback?e.getDisabledCallback(t):e.disabledMember?!!t[e.disabledMember]:!1}function co(t,e,o,i,r,s,n=!0){const l=i.editor==="select"||i.editor==="combobox"||i.editor==="autocomplete",a=i.editor==="date",d=i.editor==="checkbox",c=String(i.field);if(d){if(i.formatCallback)return`<span class="wg__cell-text">${t.escapeHtml(r)}</span>`;ie.counters.cellDisplayItemsLookup++;const h=t.grid.displayItems[e],g=h?t.grid.getCellRawValue(h,e,c):!1,f=i.editorOptions||{},w=f.trueValue!==void 0?f.trueValue:!0;return`
308
308
  <input
309
309
  type="checkbox"
310
310
  class="wg__checkbox-display${n?"":" wg__checkbox-display--readonly"}"
311
- ${h===w?"checked":""}
311
+ ${g===w?"checked":""}
312
312
  disabled
313
313
  tabindex="-1"
314
- data-row="${t}"
314
+ data-row="${e}"
315
315
  data-field="${c}"
316
316
  />
317
- `}if(l){const g=e.grid.displayItems[t],h=g?e.grid.getCellRawValue(g,t,c):void 0,f=i.editorOptions||{},w=f.initialOptions||f.options||[],p=ct(h,w,f),v=e.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-dropdown-display--toggle-on-focus":"",y=n?'<span class="wg__select-toggle">▼</span>':"";return`
318
- <div class="wg__cell-dropdown-display ${v}" data-row="${t}" data-field="${c}">
319
- <span class="wg__select-value">${e.escapeHtml(p)}</span>
317
+ `}if(l){ie.counters.cellDisplayItemsLookup++;const h=t.grid.displayItems[e],g=h?t.grid.getCellRawValue(h,e,c):void 0,f=i.editorOptions||{},w=f.initialOptions||f.options||[],p=ut(g,w,f),_=t.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-dropdown-display--toggle-on-focus":"",y=n?'<span class="wg__select-toggle">▼</span>':"";return`
318
+ <div class="wg__cell-dropdown-display ${_}" data-row="${e}" data-field="${c}">
319
+ <span class="wg__select-value">${t.escapeHtml(p)}</span>
320
320
  ${y}
321
321
  </div>
322
- `}if(a){const h=e.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-date-display--toggle-on-focus":"",f=n?`<button type="button" class="wg__date-trigger" tabindex="-1">
322
+ `}if(a){const g=t.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-date-display--toggle-on-focus":"",f=n?`<button type="button" class="wg__date-trigger" tabindex="-1">
323
323
  <svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm-8 4H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z"/></svg>
324
324
  </button>`:"";return`
325
- <div class="wg__cell-date-display ${h}" data-row="${t}" data-field="${c}">
326
- <span class="wg__date-value">${e.escapeHtml(r)}</span>
325
+ <div class="wg__cell-date-display ${g}" data-row="${e}" data-field="${c}">
326
+ <span class="wg__date-value">${t.escapeHtml(r)}</span>
327
327
  ${f}
328
328
  </div>
329
- `}const u=i.maxLines?`style="-webkit-line-clamp: ${i.maxLines}"`:"";return i.templateCallback?`<span class="wg__cell-text" ${u}>${r}</span>`:`<span class="wg__cell-text" ${u}>${e.escapeHtml(r)}</span>`}function so(e,t){if(typeof t=="number")return e.left+e.width*t;const o=document.createElement("div");o.style.cssText=`position:fixed;left:0;top:0;width:${t};height:0;visibility:hidden;pointer-events:none`,document.body.appendChild(o);const i=o.getBoundingClientRect().width;return o.remove(),e.left+i}let ee={path:null,arrowPos:null,arrowDir:"right"};const gt={add:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M8 3v10M3 8h10"/></svg>',delete:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M3 3l10 10M13 3L3 13"/></svg>',duplicate:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V4a1 1 0 011-1h7"/></svg>',moveUp:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 13V3M4 7l4-4 4 4"/></svg>',moveDown:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v10M4 9l4 4 4-4"/></svg>'},Kn={add:{icon:gt.add,title:"Add row"},delete:{icon:gt.delete,title:"Delete row",danger:!0},duplicate:{icon:gt.duplicate,title:"Duplicate row"},moveUp:{icon:gt.moveUp,title:"Move up"},moveDown:{icon:gt.moveDown,title:"Move down"}};function Je(e){return e.map((t,o)=>{if(typeof t=="string"){const i=Kn[t];return i?{id:t,icon:i.icon,title:i.title,row:1,group:1,type:t,danger:i.danger}:(console.warn(`Unknown predefined toolbar action: ${t}`),null)}return{id:t.id||`toolbar-item-${o}`,icon:t.icon,title:t.title,label:t.label,row:t.row??1,group:t.group??1,type:t.type,danger:t.danger,disabled:t.disabled,hidden:t.hidden,onclick:t.onclick,tooltip:t.tooltip,tooltipCallback:t.tooltipCallback}}).filter(t=>t!==null)}function jn(e){const t=new Map;for(const r of e){const s=r.row;t.has(s)||t.set(s,[]),t.get(s).push(r)}const o=[],i=[...t.keys()].sort((r,s)=>r-s);for(const r of i){const s=t.get(r),n=new Map;for(const a of s){const d=a.group;n.has(d)||n.set(d,[]),n.get(d).push(a)}const l=[...n.keys()].sort((a,d)=>a-d);o.push({rowNum:r,groups:l.map(a=>({groupNum:a,items:n.get(a)}))})}return o}function Xn(e){return e.replace(/\+/g," + ")}function Gn(e,t){var r,s;const o=[];o.push(`<span class="wg__tooltip-title">${e.title}</span>`),(r=e.tooltip)!=null&&r.description&&o.push(`<div class="wg__tooltip-desc">${e.tooltip.description}</div>`);const i=((s=e.tooltip)==null?void 0:s.shortcut)||t;return i&&o.push(`<div class="wg__tooltip-shortcut">${Xn(i)}</div>`),o.join("")}function ti(e,t,o,i=!1){let r=jn(e);return i&&(r=r.reverse()),`<div class="wg__toolbar">${r.map(({groups:n})=>`<div class="wg__toolbar-row">${n.map(({items:a},d)=>{const c=d>0?'<div class="wg__toolbar-divider"></div>':"",u=a.map(g=>{const h=typeof g.disabled=="function"?g.disabled(t,o):g.disabled,f=["wg__toolbar-btn",g.danger?"wg__toolbar-btn--danger":""].filter(Boolean).join(" "),w=g.label?`<span class="wg__toolbar-label">${g.label}</span>`:"",p=g.minWidth?` style="min-width: ${g.minWidth}"`:"";return`<button
329
+ `}const u=i.maxLines?`style="-webkit-line-clamp: ${i.maxLines}"`:"";return i.templateCallback?`<span class="wg__cell-text" ${u}>${r}</span>`:`<span class="wg__cell-text" ${u}>${t.escapeHtml(r)}</span>`}function Pt(t,e,o,i){if(!e.isTree||!t.grid.isTreeMode)return i;const r=t.grid.getRowTreeInfo(o);if(!r)return i;const s=t.grid.isPathExpanded(r.path),n=`padding-inline-start: calc(${r.level} * var(--wg-tree-indent))`,l=t.grid.getTreeChevronHtml(o,s,r.hasChildren,r.level,r.path),a=!t.grid.treeChevronCallback&&t.grid.treeExpandedGlyph===t.grid.treeCollapsedGlyph;let d;return r.hasChildren?d=`<button type="button" class="wg__tree-chevron${a&&s?" wg__tree-chevron--expanded":""}" data-tree-toggle="${t.escapeHtml(r.path)}" tabindex="-1" aria-label="${s?"Collapse":"Expand"}">${l}</button>`:d=`<span class="wg__tree-leaf-spacer" aria-hidden="true">${l}</span>`,`<div class="wg__tree-cell" style="${n}">${d}<div class="wg__tree-cell-body">${i}</div></div>`}function go(t,e){if(typeof e=="number")return t.left+t.width*e;const o=document.createElement("div");o.style.cssText=`position:fixed;left:0;top:0;width:${e};height:0;visibility:hidden;pointer-events:none`,document.body.appendChild(o);const i=o.getBoundingClientRect().width;return o.remove(),t.left+i}let oe={path:null,arrowPos:null,arrowDir:"right"};const ht={add:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M8 3v10M3 8h10"/></svg>',delete:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M3 3l10 10M13 3L3 13"/></svg>',duplicate:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V4a1 1 0 011-1h7"/></svg>',moveUp:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 13V3M4 7l4-4 4 4"/></svg>',moveDown:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v10M4 9l4 4 4-4"/></svg>'},Jn={add:{icon:ht.add,title:"Add row"},delete:{icon:ht.delete,title:"Delete row",danger:!0},duplicate:{icon:ht.duplicate,title:"Duplicate row"},moveUp:{icon:ht.moveUp,title:"Move up"},moveDown:{icon:ht.moveDown,title:"Move down"}};function et(t){return t.map((e,o)=>{if(typeof e=="string"){const i=Jn[e];return i?{id:e,icon:i.icon,title:i.title,row:1,group:1,type:e,danger:i.danger}:(console.warn(`Unknown predefined toolbar action: ${e}`),null)}return{id:e.id||`toolbar-item-${o}`,icon:e.icon,title:e.title,label:e.label,row:e.row??1,group:e.group??1,type:e.type,danger:e.danger,disabled:e.disabled,hidden:e.hidden,onclick:e.onclick,tooltip:e.tooltip,tooltipCallback:e.tooltipCallback}}).filter(e=>e!==null)}function Zn(t){const e=new Map;for(const r of t){const s=r.row;e.has(s)||e.set(s,[]),e.get(s).push(r)}const o=[],i=[...e.keys()].sort((r,s)=>r-s);for(const r of i){const s=e.get(r),n=new Map;for(const a of s){const d=a.group;n.has(d)||n.set(d,[]),n.get(d).push(a)}const l=[...n.keys()].sort((a,d)=>a-d);o.push({rowNum:r,groups:l.map(a=>({groupNum:a,items:n.get(a)}))})}return o}function es(t){return t.replace(/\+/g," + ")}function ts(t,e){var r,s;const o=[];o.push(`<span class="wg__tooltip-title">${t.title}</span>`),(r=t.tooltip)!=null&&r.description&&o.push(`<div class="wg__tooltip-desc">${t.tooltip.description}</div>`);const i=((s=t.tooltip)==null?void 0:s.shortcut)||e;return i&&o.push(`<div class="wg__tooltip-shortcut">${es(i)}</div>`),o.join("")}function si(t,e,o,i=!1){let r=Zn(t);return i&&(r=r.reverse()),`<div class="wg__toolbar">${r.map(({groups:n})=>`<div class="wg__toolbar-row">${n.map(({items:a},d)=>{const c=d>0?'<div class="wg__toolbar-divider"></div>':"",u=a.map(h=>{const g=typeof h.disabled=="function"?h.disabled(e,o):h.disabled,f=["wg__toolbar-btn",h.danger?"wg__toolbar-btn--danger":""].filter(Boolean).join(" "),w=h.label?`<span class="wg__toolbar-label">${h.label}</span>`:"",p=h.minWidth?` style="min-width: ${h.minWidth}"`:"";return`<button
330
330
  class="${f}"
331
- data-toolbar-item="${g.id}"
332
- title="${g.title}"
333
- ${h?"disabled":""}${p}
334
- >${g.icon}${w}</button>`}).join("");return c+u}).join("")}</div>`).join("")}</div>`}let F=null;function Qn(e,t,o,i,r,s,n){Tt();const l=e.grid.toolbarVerticalAlign!=="top",a=ti(i,r,o,l),d=document.createElement("div");d.className="wg__toolbar-container",e.grid.toolbarBtnMinWidth&&d.style.setProperty("--wg-toolbar-btn-min-width",e.grid.toolbarBtnMinWidth),d.innerHTML=a,e.shadow.appendChild(d);const c=d.querySelector(".wg__toolbar"),u=e.grid.toolbarPosition;let g=u==="top"?"top":u==="right"?"right":"left";c.style.position="fixed",c.style.visibility="hidden",requestAnimationFrame(()=>{const f=e.shadow.querySelector(`tr[data-row-index="${o}"]`);if(!f){Tt();return}const w=e.grid.toolbarPosition,p=e.grid.toolbarVerticalAlign,m=e.grid.toolbarHorizontalAlign;let v,y,x="";p==="top"?x="-end":p==="bottom"&&(x="-start");const C=()=>m==="start"?"top-start":m==="end"?"top-end":"top";w==="left"?(v=`left${x}`,y=[`right${x}`,C()]):w==="right"?(v=`right${x}`,y=[`left${x}`,C()]):w==="top"?(v=C(),y=[`left${x}`,`right${x}`]):(v=`left${x}`,y=[`right${x}`,C()]);let _=f;const S=e.grid.toolbarColumn;if(w==="top"){if(S!==void 0){const k=f.querySelectorAll(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");let E=null;if(typeof S=="number")E=k[S]||null;else for(let R=0;R<k.length;R++){const I=k[R];if(I.dataset.field===S){E=I;break}}if(E){const R=E.getBoundingClientRect();_={getBoundingClientRect:()=>({x:R.left+R.width/2,y:R.top,top:R.top,left:R.left+R.width/2,bottom:R.bottom,right:R.left+R.width/2,width:0,height:R.height,toJSON:()=>({})})}}}else if(m==="cursor"&&n!==void 0){const k=f.getBoundingClientRect();_={getBoundingClientRect:()=>({x:n,y:k.top,top:k.top,left:n,bottom:k.bottom,right:n,width:0,height:k.height,toJSON:()=>({})})}}}qe(_,c,{strategy:"fixed",placement:v,middleware:[Ve({fallbackPlacements:y}),rt({padding:8})]}).then(({x:k,y:E,placement:R})=>{let I=k;if((e.grid.toolbarFollowsCursor||e.grid.cellToolbar)&&R.startsWith("top")&&n!==void 0&&e.grid.toolbarColumn===void 0){const M=f.querySelectorAll(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");for(const z of M){const D=z.getBoundingClientRect();if(n>=D.left&&n<=D.right){I=so(D,e.grid.cellToolbarOffset);break}}}Object.assign(c.style,{left:`${I}px`,top:`${E}px`,visibility:"visible"}),g=R.split("-")[0],F&&(F.position=g)}).catch(()=>{c.style.visibility="visible"})});const h=f=>{const w=f.target.closest(".wg__toolbar-btn");if(w&&!w.disabled){const p=w.dataset.toolbarItem||"",m=i.find(v=>v.id===p);m&&s(m,f,w)}};d.addEventListener("click",h),F={container:d,toolbar:c,rowIndex:o,rowItem:r,position:g,hasRowMoved:!1,cursorX:n,cleanup:()=>{d.removeEventListener("click",h),d.remove()}},ee={path:null,arrowPos:null,arrowDir:"right"}}function Tt(){F&&(F.cleanup(),F=null),ee={path:null,arrowPos:null,arrowDir:"right"}}function We(){return(F==null?void 0:F.rowIndex)??null}function oi(e){return(F==null?void 0:F.container.getRootNode())===e}function lo(e){return(F==null?void 0:F.rowIndex)===e}function Jn(){return ee}function Zn(){return F?{toolbar:F.toolbar,container:F.container}:null}function ao(e,t,o="center"){if(!F||F.position!=="top")return;const i=F.toolbar,r=i.getBoundingClientRect();let s;o==="start"?s=e:s=e-r.width/2;const n=8,l=window.innerWidth-r.width-8;s=Math.max(n,Math.min(l,s)),i.style.left=`${s}px`,F.cursorX=e}function ii(e,t){if(!F){ee={path:null,arrowPos:null,arrowDir:"right"};return}const{toolbar:o,rowItem:i,position:r}=F,s=t.findIndex(C=>C===i);if(s===-1){ee={path:null,arrowPos:null,arrowDir:"right"};return}const n=e.shadow.querySelector(`tr[data-row-index="${s}"]`);if(!n){ee={path:null,arrowPos:null,arrowDir:"right"};return}if(s===F.rowIndex||(F.hasRowMoved=!0),!F.hasRowMoved){ee={path:null,arrowPos:null,arrowDir:"right"};return}const a=o.getBoundingClientRect(),d=n.getBoundingClientRect(),c=e.shadow.querySelector(".wg__table"),u=c==null?void 0:c.getBoundingClientRect(),g=e.shadow.querySelector(".wg"),h=g==null?void 0:g.getBoundingClientRect();if(!u||!h){ee={path:null,arrowPos:null,arrowDir:"right"};return}const f=document.dir==="rtl"||document.documentElement.dir==="rtl",w=d.top+d.height/2,p=d.bottom<=h.top,m=d.top>=h.bottom,v=!p&&!m;let y,x="right";if(p?(y=h.top+8,x="up"):m?(y=h.bottom-8,x="down"):y=w,r==="left"){const C=a.right,_=a.top+a.height/2,S=f?h.right+15:h.left-15;if(!v){ee={path:`M ${C} ${_} H ${S} V ${y}`,arrowPos:{x:S,y},arrowDir:x};return}const k=f?h.right-8:h.left+8;x=f?"left":"right",ee={path:`M ${C} ${_} H ${S} V ${y} H ${k}`,arrowPos:{x:k,y},arrowDir:x};return}else if(r==="right"){const C=a.left,_=a.top+a.height/2,S=f?h.left-15:h.right+15;if(!v){ee={path:`M ${C} ${_} H ${S} V ${y}`,arrowPos:{x:S,y},arrowDir:x};return}const k=f?h.left+8:h.right-8;x=f?"right":"left",ee={path:`M ${C} ${_} H ${S} V ${y} H ${k}`,arrowPos:{x:k,y},arrowDir:x};return}else{const _=a.right,S=a.top+a.height/2,k=_+48,E=s-F.rowIndex,R=8;if(E===0){let I=d.top-R;m&&(I=h.bottom-R),ee={path:`M ${_} ${S} H ${k} V ${I}`,arrowPos:{x:k,y:I},arrowDir:"down"};return}else if(E===-1){const M=a.top+a.height*.25,z=a.top+a.height*.75,D=a.right+24,P=a.right+R;ee={path:`M ${a.right} ${M} H ${D} V ${z} H ${P}`,arrowPos:{x:P,y:z},arrowDir:"left"};return}else if(E<0){let I=d.bottom+R;p&&(I=h.top+R),ee={path:`M ${_} ${S} H ${k} V ${I}`,arrowPos:{x:k,y:I},arrowDir:"up"};return}else{let I=d.top-R;m&&(I=h.bottom-R),ee={path:`M ${_} ${S} H ${k} V ${I}`,arrowPos:{x:k,y:I},arrowDir:"down"};return}}}function ri(e,t,o="Row actions"){return`<button
335
- class="wg__toolbar-trigger ${t?"wg__toolbar-trigger--active":""}"
336
- data-toolbar-trigger="${e}"
331
+ data-toolbar-item="${h.id}"
332
+ title="${h.title}"
333
+ ${g?"disabled":""}${p}
334
+ >${h.icon}${w}</button>`}).join("");return c+u}).join("")}</div>`).join("")}</div>`}let q=null;function os(t,e,o,i,r,s,n){At();const l=t.grid.toolbarVerticalAlign!=="top",a=si(i,r,o,l),d=document.createElement("div");d.className="wg__toolbar-container",t.grid.toolbarBtnMinWidth&&d.style.setProperty("--wg-toolbar-btn-min-width",t.grid.toolbarBtnMinWidth),d.innerHTML=a,t.shadow.appendChild(d);const c=d.querySelector(".wg__toolbar"),u=t.grid.toolbarPosition;let h=u==="top"?"top":u==="right"?"right":"left";c.style.position="fixed",c.style.visibility="hidden",requestAnimationFrame(()=>{const f=t.shadow.querySelector(`tr[data-row-index="${o}"]`);if(!f){At();return}const w=t.grid.toolbarPosition,p=t.grid.toolbarVerticalAlign,m=t.grid.toolbarHorizontalAlign;let _,y,C="";p==="top"?C="-end":p==="bottom"&&(C="-start");const S=()=>m==="start"?"top-start":m==="end"?"top-end":"top";w==="left"?(_=`left${C}`,y=[`right${C}`,S()]):w==="right"?(_=`right${C}`,y=[`left${C}`,S()]):w==="top"?(_=S(),y=[`left${C}`,`right${C}`]):(_=`left${C}`,y=[`right${C}`,S()]);let v=f;const x=t.grid.toolbarColumn;if(w==="top"){if(x!==void 0){const k=f.querySelectorAll(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");let E=null;if(typeof x=="number")E=k[x]||null;else for(let I=0;I<k.length;I++){const R=k[I];if(R.dataset.field===x){E=R;break}}if(E){const I=E.getBoundingClientRect();v={getBoundingClientRect:()=>({x:I.left+I.width/2,y:I.top,top:I.top,left:I.left+I.width/2,bottom:I.bottom,right:I.left+I.width/2,width:0,height:I.height,toJSON:()=>({})})}}}else if(m==="cursor"&&n!==void 0){const k=f.getBoundingClientRect();v={getBoundingClientRect:()=>({x:n,y:k.top,top:k.top,left:n,bottom:k.bottom,right:n,width:0,height:k.height,toJSON:()=>({})})}}}Be(v,c,{strategy:"fixed",placement:_,middleware:[Ne({fallbackPlacements:y}),lt({padding:8})]}).then(({x:k,y:E,placement:I})=>{let R=k;if((t.grid.toolbarFollowsCursor||t.grid.cellToolbar)&&I.startsWith("top")&&n!==void 0&&t.grid.toolbarColumn===void 0){const P=f.querySelectorAll(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");for(const D of P){const M=D.getBoundingClientRect();if(n>=M.left&&n<=M.right){R=go(M,t.grid.cellToolbarOffset);break}}}Object.assign(c.style,{left:`${R}px`,top:`${E}px`,visibility:"visible"}),h=I.split("-")[0],q&&(q.position=h)}).catch(()=>{c.style.visibility="visible"})});const g=f=>{const w=f.target.closest(".wg__toolbar-btn");if(w&&!w.disabled){const p=w.dataset.toolbarItem||"",m=i.find(_=>_.id===p);m&&s(m,f,w)}};d.addEventListener("click",g),q={container:d,toolbar:c,rowIndex:o,rowItem:r,position:h,hasRowMoved:!1,cursorX:n,cleanup:()=>{d.removeEventListener("click",g),d.remove()}},oe={path:null,arrowPos:null,arrowDir:"right"}}function At(){q&&(q.cleanup(),q=null),oe={path:null,arrowPos:null,arrowDir:"right"}}function Ye(){return(q==null?void 0:q.rowIndex)??null}function li(t){return(q==null?void 0:q.container.getRootNode())===t}function uo(t){return(q==null?void 0:q.rowIndex)===t}function is(){return oe}function rs(){return q?{toolbar:q.toolbar,container:q.container}:null}function ho(t,e,o="center"){if(!q||q.position!=="top")return;const i=q.toolbar,r=i.getBoundingClientRect();let s;o==="start"?s=t:s=t-r.width/2;const n=8,l=window.innerWidth-r.width-8;s=Math.max(n,Math.min(l,s)),i.style.left=`${s}px`,q.cursorX=t}function ai(t,e){if(!q){oe={path:null,arrowPos:null,arrowDir:"right"};return}const{toolbar:o,rowItem:i,position:r}=q,s=e.findIndex(S=>S===i);if(s===-1){oe={path:null,arrowPos:null,arrowDir:"right"};return}const n=t.shadow.querySelector(`tr[data-row-index="${s}"]`);if(!n){oe={path:null,arrowPos:null,arrowDir:"right"};return}if(s===q.rowIndex||(q.hasRowMoved=!0),!q.hasRowMoved){oe={path:null,arrowPos:null,arrowDir:"right"};return}const a=o.getBoundingClientRect(),d=n.getBoundingClientRect(),c=t.shadow.querySelector(".wg__table"),u=c==null?void 0:c.getBoundingClientRect(),h=t.shadow.querySelector(".wg"),g=h==null?void 0:h.getBoundingClientRect();if(!u||!g){oe={path:null,arrowPos:null,arrowDir:"right"};return}const f=document.dir==="rtl"||document.documentElement.dir==="rtl",w=d.top+d.height/2,p=d.bottom<=g.top,m=d.top>=g.bottom,_=!p&&!m;let y,C="right";if(p?(y=g.top+8,C="up"):m?(y=g.bottom-8,C="down"):y=w,r==="left"){const S=a.right,v=a.top+a.height/2,x=f?g.right+15:g.left-15;if(!_){oe={path:`M ${S} ${v} H ${x} V ${y}`,arrowPos:{x,y},arrowDir:C};return}const k=f?g.right-8:g.left+8;C=f?"left":"right",oe={path:`M ${S} ${v} H ${x} V ${y} H ${k}`,arrowPos:{x:k,y},arrowDir:C};return}else if(r==="right"){const S=a.left,v=a.top+a.height/2,x=f?g.left-15:g.right+15;if(!_){oe={path:`M ${S} ${v} H ${x} V ${y}`,arrowPos:{x,y},arrowDir:C};return}const k=f?g.left+8:g.right-8;C=f?"right":"left",oe={path:`M ${S} ${v} H ${x} V ${y} H ${k}`,arrowPos:{x:k,y},arrowDir:C};return}else{const v=a.right,x=a.top+a.height/2,k=v+48,E=s-q.rowIndex,I=8;if(E===0){let R=d.top-I;m&&(R=g.bottom-I),oe={path:`M ${v} ${x} H ${k} V ${R}`,arrowPos:{x:k,y:R},arrowDir:"down"};return}else if(E===-1){const P=a.top+a.height*.25,D=a.top+a.height*.75,M=a.right+24,A=a.right+I;oe={path:`M ${a.right} ${P} H ${M} V ${D} H ${A}`,arrowPos:{x:A,y:D},arrowDir:"left"};return}else if(E<0){let R=d.bottom+I;p&&(R=g.top+I),oe={path:`M ${v} ${x} H ${k} V ${R}`,arrowPos:{x:k,y:R},arrowDir:"up"};return}else{let R=d.top-I;m&&(R=g.bottom-I),oe={path:`M ${v} ${x} H ${k} V ${R}`,arrowPos:{x:k,y:R},arrowDir:"down"};return}}}function di(t,e,o="Row actions"){return`<button
335
+ class="wg__toolbar-trigger ${e?"wg__toolbar-trigger--active":""}"
336
+ data-toolbar-trigger="${t}"
337
337
  title="${o}"
338
- >⋮</button>`}const co=40;function go(e){if(!e||e==="auto")return 150;const t=e.match(/^([\d.]+)(px|em|rem|%)?$/);if(!t)return 150;const o=parseFloat(t[1]);switch(t[2]||"px"){case"px":return o;case"em":return o*16;case"rem":return o*10;case"%":return 150;default:return o}}function es(e){const t=["wg"];return e.grid.isStriped&&t.push("wg--striped"),e.grid.isHoverable&&t.push("wg--hoverable"),e.grid.isEditable&&t.push("wg--editable"),e.grid.isNavigateMode&&t.push("wg--navigate-mode"),e.grid.isColumnReorderAllowed&&t.push("wg--reorderable"),e.grid.isScrollable&&t.push("wg--scrollable"),e.grid.tableBorderOnly&&t.push("wg--table-border-only"),t.join(" ")}function ts(e){const t=e.grid.visualColumns;if(t.length===0)return"";let o=0,i="";if(e.grid.isRowNumbersVisible){const d=e.grid.isStickyRowNumbers;i=`<th class="wg__header wg__row-number-header${d?" wg__header--frozen":""}" style="${d?"position: sticky; left: 0; z-index: 4;":""}">#</th>`,o+=co}const r=e.grid.isRowToolbarVisible&&e.grid.toolbarPosition==="inline";let s="";if(r){const d=Je(e.grid.rowToolbar),c=new Map;for(const h of d){const f=h.row??1;c.set(f,(c.get(f)||0)+1)}const u=Math.max(1,...c.values());s=`<th class="wg__header wg__inline-actions-header" style="width: ${`calc(${u} * var(--wg-toolbar-btn-min-width) + ${Math.max(0,u-1)} * var(--wg-inline-actions-gap) + 2 * var(--wg-spacing-sm))`}">${e.escapeHtml(e.grid.inlineActionsTitle??e.grid.labels.inlineActionsHeader)}</th>`}const l=e.grid.isRowToolbarVisible&&e.grid.toolbarTrigger==="button"&&e.grid.toolbarPosition!=="inline"?'<th class="wg__header wg__actions-column"></th>':"",a=t.map(({column:d,originalIndex:c},u)=>{const g=String(d.field),h=d.isSortable!==!1&&e.grid.sortMode!=="none",f=e.grid.getColumnSortState(g),w=e.grid.getColumnSortPriority(g),p=f!==void 0,m=e.grid.isColumnFrozen(u),v=m&&u===e.grid.totalFrozenColumns-1,y=e.grid.isColumnSelected(u),x=["wg__header"];h&&x.push("wg__header--sortable"),p&&x.push("wg__header--sorted"),m&&x.push("wg__header--frozen"),v&&x.push("wg__header--frozen-last"),y&&x.push("wg__header--selected");const _=e.grid.getColumnWidth(g)||d.width||d.maxWidth,S=go(_),k=d.minWidth,E=d.headerHorizontalAlign||d.horizontalAlign||"left",R=d.headerVerticalAlign||d.verticalAlign||"middle",M=`style="${[m?"position: sticky":"",m?`left: ${o}px`:"",m?"z-index: 2":"",_?`width: ${_}`:"",_?`max-width: ${_}`:"",k?`min-width: ${k}`:"",`text-align: ${E}`,`vertical-align: ${R}`].filter(Boolean).join("; ")}"`;m&&(o+=S);let z="";if(h)if(p){const T=f.direction==="asc"?"▲":"▼",A=e.grid.sort.length>1?`<sup class="wg__sort-priority">${w}</sup>`:"";z=`<span class="wg__sort-indicator">${T}${A}</span>`}else z='<span class="wg__sort-indicator wg__sort-placeholder">⬍</span>';let D="";d.headerInfo&&(D=`<span class="wg__header-info" data-tooltip="${e.escapeHtml(d.headerInfo)}"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></span>`);const j=`<div class="wg__resize-handle${d.isResizable!==!1?"":" wg__resize-handle--disabled"}" data-field="${g}"></div>`;return`
339
- <th class="${x.join(" ")}" ${M} data-field="${g}">
338
+ >⋮</button>`}const fo=40;function wo(t){if(!t||t==="auto")return 150;const e=t.match(/^([\d.]+)(px|em|rem|%)?$/);if(!e)return 150;const o=parseFloat(e[1]);switch(e[2]||"px"){case"px":return o;case"em":return o*16;case"rem":return o*10;case"%":return 150;default:return o}}function ci(t){const e=["wg"];return t.grid.isStriped&&e.push("wg--striped"),t.grid.isHoverable&&e.push("wg--hoverable"),t.grid.isEditable&&e.push("wg--editable"),t.grid.isNavigateMode&&e.push("wg--navigate-mode"),t.grid.isColumnReorderAllowed&&e.push("wg--reorderable"),t.grid.isScrollable&&e.push("wg--scrollable"),t.grid.tableBorderOnly&&e.push("wg--table-border-only"),e.join(" ")}function ns(t){const e=t.grid.visualColumns;if(e.length===0)return"";let o=0,i="";if(t.grid.isRowNumbersVisible){const d=t.grid.isStickyRowNumbers;i=`<th class="wg__header wg__row-number-header${d?" wg__header--frozen":""}" style="${d?"position: sticky; left: 0; z-index: 4;":""}">#</th>`,o+=fo}const r=t.grid.isRowToolbarVisible&&t.grid.toolbarPosition==="inline";let s="";if(r){const d=et(t.grid.rowToolbar),c=new Map;for(const g of d){const f=g.row??1;c.set(f,(c.get(f)||0)+1)}const u=Math.max(1,...c.values());s=`<th class="wg__header wg__inline-actions-header" style="width: ${`calc(${u} * var(--wg-toolbar-btn-min-width) + ${Math.max(0,u-1)} * var(--wg-inline-actions-gap) + 2 * var(--wg-spacing-sm))`}">${t.escapeHtml(t.grid.inlineActionsTitle??t.grid.labels.inlineActionsHeader)}</th>`}const l=t.grid.isRowToolbarVisible&&t.grid.toolbarTrigger==="button"&&t.grid.toolbarPosition!=="inline"?'<th class="wg__header wg__actions-column"></th>':"",a=e.map(({column:d,originalIndex:c},u)=>{const h=String(d.field),g=d.isSortable!==!1&&t.grid.sortMode!=="none",f=t.grid.getColumnSortState(h),w=t.grid.getColumnSortPriority(h),p=f!==void 0,m=t.grid.isColumnFrozen(u),_=m&&u===t.grid.totalFrozenColumns-1,y=t.grid.isColumnSelected(u),C=["wg__header"];g&&C.push("wg__header--sortable"),p&&C.push("wg__header--sorted"),m&&C.push("wg__header--frozen"),_&&C.push("wg__header--frozen-last"),y&&C.push("wg__header--selected");const v=t.grid.getColumnWidth(h)||d.width||d.maxWidth,x=wo(v),k=d.minWidth??t.grid.columnMinWidth,E=d.headerHorizontalAlign||d.horizontalAlign||"left",I=d.headerVerticalAlign||d.verticalAlign||"middle",P=`style="${[m?"position: sticky":"",m?`left: ${o}px`:"",m?"z-index: 2":"",v?`width: ${v}`:"",v?`max-width: ${v}`:"",k?`min-width: ${k}`:"",d.nowrap?"white-space: nowrap":"",`text-align: ${E}`,`vertical-align: ${I}`].filter(Boolean).join("; ")}"`;m&&(o+=x);let D="";if(g)if(p){const T=f.direction==="asc"?"▲":"▼",$=t.grid.sort.length>1?`<sup class="wg__sort-priority">${w}</sup>`:"";D=`<span class="wg__sort-indicator">${T}${$}</span>`}else D='<span class="wg__sort-indicator wg__sort-placeholder">⬍</span>';let M="";d.headerInfo&&(M=`<span class="wg__header-info" data-tooltip="${t.escapeHtml(d.headerInfo)}"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></span>`);const F=`<div class="wg__resize-handle${d.isResizable!==!1?"":" wg__resize-handle--disabled"}" data-field="${h}"></div>`;return`
339
+ <th class="${C.join(" ")}" ${P} data-field="${h}">
340
340
  <div class="wg__header-container">
341
- <div class="wg__header-content wg__header-content--align-${E} wg__header-content--valign-${R}">
342
- <span class="wg__header-title">${e.escapeHtml(d.title)}</span>
343
- ${D}
341
+ <div class="wg__header-content wg__header-content--align-${E} wg__header-content--valign-${I}">
342
+ <span class="wg__header-title">${t.escapeHtml(d.title)}</span>
343
+ ${M}
344
344
  </div>
345
345
  <div class="wg__header-controls">
346
- ${z}
346
+ ${D}
347
347
  </div>
348
348
  </div>
349
- ${j}
349
+ ${F}
350
350
  </th>
351
- `}).join("");return`<tr>${i}${s}${l}${a}<th class="wg__filler">&nbsp;</th></tr>`}function os(e){const t=e.grid.displayItems,o=e.grid.visualColumns,i=e.grid.isRowNumbersVisible,r=e.grid.isStickyRowNumbers,s=e.grid.isRowToolbarVisible&&e.grid.toolbarPosition==="inline",n=e.grid.isRowToolbarVisible&&e.grid.toolbarTrigger==="button"&&e.grid.toolbarPosition!=="inline",l=o.length+(n?1:0)+(i?1:0)+(s?1:0);if(t.length===0)return`
351
+ `}).join("");return`<tr>${i}${s}${l}${a}<th class="wg__filler">&nbsp;</th></tr>`}function ss(t){const e=t.grid.displayItems,o=t.grid.visualColumns,i=t.grid.isRowNumbersVisible,r=t.grid.isStickyRowNumbers,s=t.grid.isRowToolbarVisible&&t.grid.toolbarPosition==="inline",n=t.grid.isRowToolbarVisible&&t.grid.toolbarTrigger==="button"&&t.grid.toolbarPosition!=="inline",l=o.length+(n?1:0)+(i?1:0)+(s?1:0);if(e.length===0)return`
352
352
  <tr>
353
353
  <td class="wg__empty" colspan="${l}">
354
354
  No items to display
355
355
  </td>
356
356
  </tr>
357
- `;const a=We(),d=o.map(({column:c})=>go(c.width||c.maxWidth));return t.map((c,u)=>{const g=e.grid.getRowLockInfo(c),h=(g==null?void 0:g.isLocked)===!0,f=e.grid.isEmptyRowIndex(u);let w=0,p="";if(i){const _=r?"position: sticky; left: 0; z-index: 2;":"",S=r?" wg__cell--frozen":"";if(h){const k=g!=null&&g.lockedBy?`Locked by ${g.lockedBy}`:"This row is locked";p=`<td class="wg__cell wg__row-number wg__row-number--locked${S}" style="${_}" data-tooltip="${e.escapeHtml(k)}" data-row-number="${u}">🔒</td>`}else f?p=`<td class="wg__cell wg__row-number wg__empty-row-indicator${S}" style="${_}" data-row-number="${u}">${e.grid.newRowIndicator}</td>`:p=`<td class="wg__cell wg__row-number${e.grid.isDirtyIndicatorVisible&&e.grid.isRowDirty(u)?" wg__row-number--dirty":""}${S}" style="${_}" data-row-number="${u}">${u+1}</td>`;w+=co}const m=s?ni(e,c,u):"";let v="";n&&(v=`
357
+ `;const a=Ye(),d=o.map(({column:c})=>wo(c.width||c.maxWidth));return e.map((c,u)=>{const h=t.grid.getRowLockInfo(c),g=(h==null?void 0:h.isLocked)===!0,f=t.grid.isEmptyRowIndex(u);let w=0,p="";if(i){const v=r?"position: sticky; left: 0; z-index: 2;":"",x=r?" wg__cell--frozen":"";if(g){const k=h!=null&&h.lockedBy?`Locked by ${h.lockedBy}`:"This row is locked";p=`<td class="wg__cell wg__row-number wg__row-number--locked${x}" style="${v}" data-tooltip="${t.escapeHtml(k)}" data-row-number="${u}">🔒</td>`}else f?p=`<td class="wg__cell wg__row-number wg__empty-row-indicator${x}" style="${v}" data-row-number="${u}">${t.grid.newRowIndicator}</td>`:p=`<td class="wg__cell wg__row-number${t.grid.isDirtyIndicatorVisible&&t.grid.isRowDirty(u)?" wg__row-number--dirty":""}${x}" style="${v}" data-row-number="${u}">${u+1}</td>`;w+=fo}const m=s?gi(t,c,u):"";let _="";n&&(_=`
358
358
  <td class="wg__cell wg__actions-column">
359
- ${ri(u,a===u,e.grid.labels.rowActions)}
359
+ ${di(u,a===u,t.grid.labels.rowActions)}
360
360
  </td>
361
- `);const y=o.map(({column:_,originalIndex:S},k)=>{const E=String(_.field),R=e.grid.getCellValue(c,_,u),I=_.horizontalAlign||"left",M=_.verticalAlign||"middle",z=e.grid.canEditCell(u,E),D=e.grid.isCellFocused(u,S),P=e.grid.isColumnFrozen(k),j=P&&k===e.grid.totalFrozenColumns-1,T=_.editTrigger??e.grid.editTrigger,A=["wg__cell"],W=e.grid.shouldShowEditor(u,S),B=e.grid.isEditing(u,E);if(z&&A.push("wg__cell--editable"),D&&!B&&A.push("wg__cell--focused"),D&&T==="always"&&A.push("wg__cell--always-edit-focused"),_.textOverflow!=="wrap"&&A.push("wg__cell--ellipsis"),_.maxLines&&A.push("wg__cell--line-clamp"),B&&A.push("wg__cell--editing"),e.grid.isCellInvalid(u,E)&&A.push("wg__cell--invalid"),e.grid.isDirtyIndicatorVisible&&e.grid.isCellDirty(u,E)&&A.push("wg__cell--dirty"),e.grid.isCellInSelectedRange(u,k)&&A.push("wg__cell--in-range"),e.grid.isColumnSelected(k)&&A.push("wg__cell--column-selected"),P&&A.push("wg__cell--frozen"),j&&A.push("wg__cell--frozen-last"),_.cellClass&&A.push(_.cellClass),_.cellClassCallback){const ae=e.grid.getCellRawValue(c,u,E),be=_.cellClassCallback(ae,c);be&&A.push(be)}const Ie=e.grid.getColumnWidth(E)||_.width,te=_.minWidth,He=[P?"position: sticky":"",P?`left: ${w}px`:"",P?"z-index: 1":"",`text-align: ${I}`,`vertical-align: ${M}`,Ie?`width: ${Ie}`:"",te?`min-width: ${te}`:"",_.maxWidth?`max-width: ${_.maxWidth}`:""].filter(Boolean).join("; ");P&&(w+=d[k]);const De=e.grid.isNavigateMode?'tabindex="0"':"";let ie="";if(_.tooltipCallback){const ae=e.grid.getCellRawValue(c,u,E),be=_.tooltipCallback(ae,c);be&&(ie=`${_.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${e.escapeHtml(be)}"`)}else if(_.tooltipMember){const ae=c[_.tooltipMember];ae&&typeof ae=="string"&&(ie=`${_.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${e.escapeHtml(ae)}"`)}if(!ie&&e.grid.isCellInvalid(u,E)){const ae=e.grid.getCellValidationError(u,E);if(ae){const be=_.validationTooltipCallback||e.grid.validationTooltipCallback;if(be){const Z=e.grid.getCellRawValue(c,u,E),Nt=be({field:E,error:ae,value:Z,row:c,rowIndex:u});Nt&&(ie=`data-tooltip-html="${e.escapeHtml(Nt)}"`)}ie||(ie=`data-tooltip="${e.escapeHtml(ae)}"`)}}return`
361
+ `);const y=o.map(({column:v,originalIndex:x},k)=>{const E=String(v.field),I=t.grid.getCellValue(c,v,u),R=v.horizontalAlign||"left",P=v.verticalAlign||"middle",D=t.grid.canEditCell(u,E),M=t.grid.isCellFocused(u,x),A=t.grid.isColumnFrozen(k),F=A&&k===t.grid.totalFrozenColumns-1,T=v.editTrigger??t.grid.editTrigger,$=["wg__cell"],Y=t.grid.shouldShowEditor(u,x),U=t.grid.isEditing(u,E);if(D&&$.push("wg__cell--editable"),M&&!U&&$.push("wg__cell--focused"),M&&T==="always"&&$.push("wg__cell--always-edit-focused"),v.textOverflow!=="wrap"&&$.push("wg__cell--ellipsis"),v.maxLines&&$.push("wg__cell--line-clamp"),U&&$.push("wg__cell--editing"),t.grid.isCellInvalid(u,E)&&$.push("wg__cell--invalid"),t.grid.isDirtyIndicatorVisible&&t.grid.isCellDirty(u,E)&&$.push("wg__cell--dirty"),t.grid.isCellInSelectedRange(u,k)&&$.push("wg__cell--in-range"),t.grid.isColumnSelected(k)&&$.push("wg__cell--column-selected"),A&&$.push("wg__cell--frozen"),F&&$.push("wg__cell--frozen-last"),v.cellClass&&$.push(v.cellClass),v.cellClassCallback){const B=t.grid.getCellRawValue(c,u,E),ve=v.cellClassCallback(B,c);ve&&$.push(ve)}const K=t.grid.getColumnWidth(E)||v.width,_e=v.minWidth??t.grid.columnMinWidth,J=[A?"position: sticky":"",A?`left: ${w}px`:"",A?"z-index: 1":"",`text-align: ${R}`,`vertical-align: ${P}`,K?`width: ${K}`:"",K?`max-width: ${K}`:"",_e?`min-width: ${_e}`:"",v.maxWidth?`max-width: ${v.maxWidth}`:"",v.nowrap?"white-space: nowrap":""].filter(Boolean).join("; ");A&&(w+=d[k]);const Me=t.grid.isNavigateMode?'tabindex="0"':"";let te="";if(v.tooltipCallback){const B=t.grid.getCellRawValue(c,u,E),ve=v.tooltipCallback(B,c);ve&&(te=`${v.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${t.escapeHtml(ve)}"`)}else if(v.tooltipMember){const B=c[v.tooltipMember];B&&typeof B=="string"&&(te=`${v.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${t.escapeHtml(B)}"`)}if(!te&&t.grid.isCellInvalid(u,E)){const B=t.grid.getCellValidationError(u,E);if(B){const ve=v.validationTooltipCallback||t.grid.validationTooltipCallback;if(ve){const _t=t.grid.getCellRawValue(c,u,E),Mo=ve({field:E,error:B,value:_t,row:c,rowIndex:u});Mo&&(te=`data-tooltip-html="${t.escapeHtml(Mo)}"`)}te||(te=`data-tooltip="${t.escapeHtml(B)}"`)}}const Do=Y?Ot(t,u,x,v):co(t,u,x,v,I,M,D),To=Pt(t,v,c,Do);return`
362
362
  <td
363
- class="${A.join(" ")}"
364
- style="${He}"
363
+ class="${$.join(" ")}"
364
+ style="${J}"
365
365
  data-row="${u}"
366
- data-col="${S}"
366
+ data-col="${x}"
367
367
  data-field="${E}"
368
- ${De}
369
- ${ie}
368
+ ${Me}
369
+ ${te}
370
370
  >
371
- ${W?At(e,u,S,_):no(e,u,S,_,R,D,z)}
371
+ ${To}
372
372
  </td>
373
- `}).join(""),x=["wg__row"];if(h&&x.push("wg__row--locked"),f&&x.push("wg__row--empty-row"),e.grid.isRowSelected(u)&&x.push("wg__row--selected"),e.grid.isRowFocused(u)&&x.push("wg__row--focused"),e.grid.rowClassCallback){const _=e.grid.rowClassCallback(c,u);_&&x.push(_)}const C=h&&!i?`data-tooltip="${e.escapeHtml(g!=null&&g.lockedBy?`Locked by ${g.lockedBy}`:"This row is locked")}"`:"";return`<tr class="${x.join(" ")}" data-row-index="${u}" ${C}>${p}${m}${v}${y}<td class="wg__cell wg__filler" data-row="${u}"></td></tr>`}).join("")}function ni(e,t,o){const r=Je(e.grid.rowToolbar).filter(a=>typeof a.hidden=="function"?!a.hidden(t,o):!a.hidden),s=new Map;for(const a of r){const d=a.row??1;s.has(d)||s.set(d,[]),s.get(d).push(a)}return`<td class="wg__cell wg__inline-actions-cell"><div class="wg__inline-actions-wrap">${[...s.keys()].sort((a,d)=>a-d).map(a=>`<div class="wg__inline-actions-row">${s.get(a).map(u=>{const g=typeof u.disabled=="function"?u.disabled(t,o):u.disabled,h=["wg__inline-action-btn",u.danger?"wg__inline-action-btn--danger":"",g?"wg__inline-action-btn--disabled":""].filter(Boolean).join(" "),f=g?"disabled":"";return`<button class="${h}" data-action-id="${u.id}" data-row="${o}" title="${e.escapeHtml(u.title)}" ${f}>${u.icon}</button>`}).join("")}</div>`).join("")}</div></td>`}function si(e,t){const o=e.grid.displayItems,i=e.grid.visualColumns,{startIndex:r,endIndex:s,rowHeight:n,totalItems:l}=t,a=e.grid.isRowNumbersVisible,d=e.grid.isStickyRowNumbers,c=e.grid.isRowToolbarVisible&&e.grid.toolbarPosition==="inline",u=e.grid.isRowToolbarVisible&&e.grid.toolbarTrigger==="button"&&e.grid.toolbarPosition!=="inline",g=i.length+(u?1:0)+(a?1:0)+(c?1:0);if(o.length===0)return`
373
+ `}).join(""),C=["wg__row"];if(g&&C.push("wg__row--locked"),f&&C.push("wg__row--empty-row"),t.grid.isRowSelected(u)&&C.push("wg__row--selected"),t.grid.isRowFocused(u)&&C.push("wg__row--focused"),t.grid.rowClassCallback){const v=t.grid.rowClassCallback(c,u);v&&C.push(v)}const S=g&&!i?`data-tooltip="${t.escapeHtml(h!=null&&h.lockedBy?`Locked by ${h.lockedBy}`:"This row is locked")}"`:"";return`<tr class="${C.join(" ")}" data-row-index="${u}" ${S}>${p}${m}${_}${y}<td class="wg__cell wg__filler" data-row="${u}"></td></tr>`}).join("")}function gi(t,e,o){const r=et(t.grid.rowToolbar).filter(a=>typeof a.hidden=="function"?!a.hidden(e,o):!a.hidden),s=new Map;for(const a of r){const d=a.row??1;s.has(d)||s.set(d,[]),s.get(d).push(a)}return`<td class="wg__cell wg__inline-actions-cell"><div class="wg__inline-actions-wrap">${[...s.keys()].sort((a,d)=>a-d).map(a=>`<div class="wg__inline-actions-row">${s.get(a).map(u=>{const h=typeof u.disabled=="function"?u.disabled(e,o):u.disabled,g=["wg__inline-action-btn",u.danger?"wg__inline-action-btn--danger":"",h?"wg__inline-action-btn--disabled":""].filter(Boolean).join(" "),f=h?"disabled":"";return`<button class="${g}" data-action-id="${u.id}" data-row="${o}" title="${t.escapeHtml(u.title)}" ${f}>${u.icon}</button>`}).join("")}</div>`).join("")}</div></td>`}function ui(t,e){const o=t.grid.displayItems,i=t.grid.visualColumns,{startIndex:r,endIndex:s,rowHeight:n,totalItems:l}=e,a=t.grid.isRowNumbersVisible,d=t.grid.isStickyRowNumbers,c=t.grid.isRowToolbarVisible&&t.grid.toolbarPosition==="inline",u=t.grid.isRowToolbarVisible&&t.grid.toolbarTrigger==="button"&&t.grid.toolbarPosition!=="inline",h=i.length+(u?1:0)+(a?1:0)+(c?1:0);if(o.length===0)return`
374
374
  <tr>
375
- <td class="wg__empty" colspan="${g}">
375
+ <td class="wg__empty" colspan="${h}">
376
376
  No items to display
377
377
  </td>
378
378
  </tr>
379
- `;const h=We(),f=i.map(({column:x})=>go(x.width||x.maxWidth)),w=r*n,p=(l-s)*n,m=w>0?`<tr class="wg__spacer-top"><td colspan="${g}" style="height: ${w}px"></td></tr>`:"",v=[];for(let x=r;x<s&&x<o.length;x++){const C=o[x],_=x,S=e.grid.getRowLockInfo(C),k=(S==null?void 0:S.isLocked)===!0,E=e.grid.isEmptyRowIndex(_);let R=0,I="";if(a){const T=d?"position: sticky; left: 0; z-index: 2;":"",A=d?" wg__cell--frozen":"";if(k){const W=S!=null&&S.lockedBy?`Locked by ${S.lockedBy}`:"This row is locked";I=`<td class="wg__cell wg__row-number wg__row-number--locked${A}" style="${T}" data-tooltip="${e.escapeHtml(W)}" data-row-number="${_}">🔒</td>`}else E?I=`<td class="wg__cell wg__row-number wg__empty-row-indicator${A}" style="${T}" data-row-number="${_}">${e.grid.newRowIndicator}</td>`:I=`<td class="wg__cell wg__row-number${e.grid.isDirtyIndicatorVisible&&e.grid.isRowDirty(_)?" wg__row-number--dirty":""}${A}" style="${T}" data-row-number="${_}">${_+1}</td>`;R+=co}const M=c?ni(e,C,_):"";let z="";u&&(z=`
379
+ `;const g=Ye(),f=i.map(({column:C})=>wo(C.width||C.maxWidth)),w=r*n,p=(l-s)*n,m=w>0?`<tr class="wg__spacer-top"><td colspan="${h}" style="height: ${w}px"></td></tr>`:"",_=[];for(let C=r;C<s&&C<o.length;C++){const S=o[C],v=C,x=t.grid.getRowLockInfo(S),k=(x==null?void 0:x.isLocked)===!0,E=t.grid.isEmptyRowIndex(v);let I=0,R="";if(a){const T=d?"position: sticky; left: 0; z-index: 2;":"",$=d?" wg__cell--frozen":"";if(k){const Y=x!=null&&x.lockedBy?`Locked by ${x.lockedBy}`:"This row is locked";R=`<td class="wg__cell wg__row-number wg__row-number--locked${$}" style="${T}" data-tooltip="${t.escapeHtml(Y)}" data-row-number="${v}">🔒</td>`}else E?R=`<td class="wg__cell wg__row-number wg__empty-row-indicator${$}" style="${T}" data-row-number="${v}">${t.grid.newRowIndicator}</td>`:R=`<td class="wg__cell wg__row-number${t.grid.isDirtyIndicatorVisible&&t.grid.isRowDirty(v)?" wg__row-number--dirty":""}${$}" style="${T}" data-row-number="${v}">${v+1}</td>`;I+=fo}const P=c?gi(t,S,v):"";let D="";u&&(D=`
380
380
  <td class="wg__cell wg__actions-column">
381
- ${ri(_,h===_,e.grid.labels.rowActions)}
381
+ ${di(v,g===v,t.grid.labels.rowActions)}
382
382
  </td>
383
- `);const D=i.map(({column:T,originalIndex:A},W)=>{const B=String(T.field),X=e.grid.getCellValue(C,T,_),Ie=T.horizontalAlign||"left",te=T.verticalAlign||"middle",He=e.grid.canEditCell(_,B),De=e.grid.isCellFocused(_,A),ie=e.grid.isColumnFrozen(W),ae=ie&&W===e.grid.totalFrozenColumns-1,be=T.editTrigger??e.grid.editTrigger,Z=["wg__cell"],Nt=e.grid.shouldShowEditor(_,A),or=e.grid.isEditing(_,B);if(He&&Z.push("wg__cell--editable"),De&&!or&&Z.push("wg__cell--focused"),De&&be==="always"&&Z.push("wg__cell--always-edit-focused"),T.textOverflow!=="wrap"&&Z.push("wg__cell--ellipsis"),T.maxLines&&Z.push("wg__cell--line-clamp"),or&&Z.push("wg__cell--editing"),e.grid.isCellInvalid(_,B)&&Z.push("wg__cell--invalid"),e.grid.isDirtyIndicatorVisible&&e.grid.isCellDirty(_,B)&&Z.push("wg__cell--dirty"),e.grid.isCellInSelectedRange(_,W)&&Z.push("wg__cell--in-range"),e.grid.isColumnSelected(W)&&Z.push("wg__cell--column-selected"),ie&&Z.push("wg__cell--frozen"),ae&&Z.push("wg__cell--frozen-last"),T.cellClass&&Z.push(T.cellClass),T.cellClassCallback){const _e=e.grid.getCellRawValue(C,_,B),Te=T.cellClassCallback(_e,C);Te&&Z.push(Te)}const ir=e.grid.getColumnWidth(B)||T.width,rr=T.minWidth,va=[ie?"position: sticky":"",ie?`left: ${R}px`:"",ie?"z-index: 1":"",`text-align: ${Ie}`,`vertical-align: ${te}`,ir?`width: ${ir}`:"",rr?`min-width: ${rr}`:"",T.maxWidth?`max-width: ${T.maxWidth}`:""].filter(Boolean).join("; ");ie&&(R+=f[W]);const ya=e.grid.isNavigateMode?'tabindex="0"':"";let Ye="";if(T.tooltipCallback){const _e=e.grid.getCellRawValue(C,_,B),Te=T.tooltipCallback(_e,C);Te&&(Ye=`${T.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${e.escapeHtml(Te)}"`)}else if(T.tooltipMember){const _e=C[T.tooltipMember];_e&&typeof _e=="string"&&(Ye=`${T.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${e.escapeHtml(_e)}"`)}if(!Ye&&e.grid.isCellInvalid(_,B)){const _e=e.grid.getCellValidationError(_,B);if(_e){const Te=T.validationTooltipCallback||e.grid.validationTooltipCallback;if(Te){const nr=e.grid.getCellRawValue(C,_,B),sr=Te({field:B,error:_e,value:nr,row:C,rowIndex:_});sr&&(Ye=`data-tooltip-html="${e.escapeHtml(sr)}"`)}Ye||(Ye=`data-tooltip="${e.escapeHtml(_e)}"`)}}return`
383
+ `);const M=i.map(({column:T,originalIndex:$},Y)=>{const U=String(T.field),ge=t.grid.getCellValue(S,T,v),K=T.horizontalAlign||"left",_e=T.verticalAlign||"middle",J=t.grid.canEditCell(v,U),Me=t.grid.isCellFocused(v,$),te=t.grid.isColumnFrozen(Y),Do=te&&Y===t.grid.totalFrozenColumns-1,To=T.editTrigger??t.grid.editTrigger,B=["wg__cell"],ve=t.grid.shouldShowEditor(v,$),_t=t.grid.isEditing(v,U);if(J&&B.push("wg__cell--editable"),Me&&!_t&&B.push("wg__cell--focused"),Me&&To==="always"&&B.push("wg__cell--always-edit-focused"),T.textOverflow!=="wrap"&&B.push("wg__cell--ellipsis"),T.maxLines&&B.push("wg__cell--line-clamp"),_t&&B.push("wg__cell--editing"),t.grid.isCellInvalid(v,U)&&B.push("wg__cell--invalid"),t.grid.isDirtyIndicatorVisible&&t.grid.isCellDirty(v,U)&&B.push("wg__cell--dirty"),t.grid.isCellInSelectedRange(v,Y)&&B.push("wg__cell--in-range"),t.grid.isColumnSelected(Y)&&B.push("wg__cell--column-selected"),te&&B.push("wg__cell--frozen"),Do&&B.push("wg__cell--frozen-last"),T.cellClass&&B.push(T.cellClass),T.cellClassCallback){const ye=t.grid.getCellRawValue(S,v,U),$e=T.cellClassCallback(ye,S);$e&&B.push($e)}const Yt=t.grid.getColumnWidth(U)||T.width,cr=T.minWidth??t.grid.columnMinWidth,ka=[te?"position: sticky":"",te?`left: ${I}px`:"",te?"z-index: 1":"",`text-align: ${K}`,`vertical-align: ${_e}`,Yt?`width: ${Yt}`:"",Yt?`max-width: ${Yt}`:"",cr?`min-width: ${cr}`:"",T.maxWidth?`max-width: ${T.maxWidth}`:"",T.nowrap?"white-space: nowrap":""].filter(Boolean).join("; ");te&&(I+=f[Y]);const Ia=t.grid.isNavigateMode?'tabindex="0"':"";let Ke="";if(T.tooltipCallback){const ye=t.grid.getCellRawValue(S,v,U),$e=T.tooltipCallback(ye,S);$e&&(Ke=`${T.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${t.escapeHtml($e)}"`)}else if(T.tooltipMember){const ye=S[T.tooltipMember];ye&&typeof ye=="string"&&(Ke=`${T.isTooltipHtml?"data-tooltip-html":"data-tooltip"}="${t.escapeHtml(ye)}"`)}if(!Ke&&t.grid.isCellInvalid(v,U)){const ye=t.grid.getCellValidationError(v,U);if(ye){const $e=T.validationTooltipCallback||t.grid.validationTooltipCallback;if($e){const gr=t.grid.getCellRawValue(S,v,U),ur=$e({field:U,error:ye,value:gr,row:S,rowIndex:v});ur&&(Ke=`data-tooltip-html="${t.escapeHtml(ur)}"`)}Ke||(Ke=`data-tooltip="${t.escapeHtml(ye)}"`)}}const Ea=ve?Ot(t,v,$,T):co(t,v,$,T,ge,Me,J),Ra=Pt(t,T,S,Ea);return`
384
384
  <td
385
- class="${Z.join(" ")}"
386
- style="${va}"
387
- data-row="${_}"
388
- data-col="${A}"
389
- data-field="${B}"
390
- ${ya}
391
- ${Ye}
385
+ class="${B.join(" ")}"
386
+ style="${ka}"
387
+ data-row="${v}"
388
+ data-col="${$}"
389
+ data-field="${U}"
390
+ ${Ia}
391
+ ${Ke}
392
392
  >
393
- ${Nt?At(e,_,A,T):no(e,_,A,T,X,De,He)}
393
+ ${Ra}
394
394
  </td>
395
- `}).join(""),P=["wg__row"];if(k&&P.push("wg__row--locked"),E&&P.push("wg__row--empty-row"),e.grid.isRowSelected(_)&&P.push("wg__row--selected"),e.grid.isRowFocused(_)&&P.push("wg__row--focused"),e.grid.rowClassCallback){const T=e.grid.rowClassCallback(C,_);T&&P.push(T)}const j=k&&!a?`data-tooltip="${e.escapeHtml(S!=null&&S.lockedBy?`Locked by ${S.lockedBy}`:"This row is locked")}"`:"";v.push(`<tr class="${P.join(" ")}" data-row-index="${_}" ${j}>${I}${M}${z}${D}<td class="wg__cell wg__filler" data-row="${_}"></td></tr>`)}const y=p>0?`<tr class="wg__spacer-bottom"><td colspan="${g}" style="height: ${p}px"></td></tr>`:"";return m+v.join("")+y}function uo(e,t="bottom-center"){const o=e.grid.showPagination;if(!e.grid.isPageable||o===!1||o==="auto"&&e.grid.totalPages<=1)return"";const i=e.grid.currentPage,r=e.grid.totalPages,s=e.grid.pageSize,n=e.grid.pageSizes,l=e.grid.totalItems!==null?e.grid.totalItems:e.grid.sortedItems.length,a=e.grid.labels,d={first:a.paginationFirst,previous:a.paginationPrevious,next:a.paginationNext,last:a.paginationLast,pageInfo:a.paginationPageInfo.replace("{current}",String(i)).replace("{total}",String(r)),itemCount:a.paginationItemCount.replace("{count}",String(l)),perPage:a.paginationPerPage},c=e.grid.paginationLabelsCallback,u=c?c({currentPage:i,totalPages:r,totalItems:l,pageSize:s}):{},g={...d,...u},h=t.startsWith("top-"),f=t.replace("top-","").replace("bottom-",""),w=["wg__pagination"];f==="left"?w.push("wg__pagination--left"):f==="right"&&w.push("wg__pagination--right"),h&&w.push("wg__pagination--top");const p={first:`
395
+ `}).join(""),A=["wg__row"];if(k&&A.push("wg__row--locked"),E&&A.push("wg__row--empty-row"),t.grid.isRowSelected(v)&&A.push("wg__row--selected"),t.grid.isRowFocused(v)&&A.push("wg__row--focused"),t.grid.rowClassCallback){const T=t.grid.rowClassCallback(S,v);T&&A.push(T)}const F=k&&!a?`data-tooltip="${t.escapeHtml(x!=null&&x.lockedBy?`Locked by ${x.lockedBy}`:"This row is locked")}"`:"";_.push(`<tr class="${A.join(" ")}" data-row-index="${v}" ${F}>${R}${P}${D}${M}<td class="wg__cell wg__filler" data-row="${v}"></td></tr>`)}const y=p>0?`<tr class="wg__spacer-bottom"><td colspan="${h}" style="height: ${p}px"></td></tr>`:"";return m+_.join("")+y}function po(t,e="bottom-center"){const o=t.grid.showPagination;if(!t.grid.isPageable||o===!1||o==="auto"&&t.grid.totalPages<=1)return"";const i=t.grid.currentPage,r=t.grid.totalPages,s=t.grid.pageSize,n=t.grid.pageSizes,l=t.grid.totalItems!==null?t.grid.totalItems:t.grid.sortedItems.length,a=t.grid.labels,d={first:a.paginationFirst,previous:a.paginationPrevious,next:a.paginationNext,last:a.paginationLast,pageInfo:a.paginationPageInfo.replace("{current}",String(i)).replace("{total}",String(r)),itemCount:a.paginationItemCount.replace("{count}",String(l)),perPage:a.paginationPerPage},c=t.grid.paginationLabelsCallback,u=c?c({currentPage:i,totalPages:r,totalItems:l,pageSize:s}):{},h={...d,...u},g=e.startsWith("top-"),f=e.replace("top-","").replace("bottom-",""),w=["wg__pagination"];f==="left"?w.push("wg__pagination--left"):f==="right"&&w.push("wg__pagination--right"),g&&w.push("wg__pagination--top");const p={first:`
396
396
  <button class="wg__pagination-btn" data-action="first" ${i===1?"disabled":""}>
397
- ${g.first}
397
+ ${h.first}
398
398
  </button>
399
399
  `,previous:`
400
400
  <button class="wg__pagination-btn" data-action="prev" ${i===1?"disabled":""}>
401
- ${g.previous}
401
+ ${h.previous}
402
402
  </button>
403
403
  `,next:`
404
404
  <button class="wg__pagination-btn" data-action="next" ${i===r?"disabled":""}>
405
- ${g.next}
405
+ ${h.next}
406
406
  </button>
407
407
  `,last:`
408
408
  <button class="wg__pagination-btn" data-action="last" ${i===r?"disabled":""}>
409
- ${g.last}
409
+ ${h.last}
410
410
  </button>
411
411
  `,pageInfo:`
412
412
  <div class="wg__pagination-info">
413
- ${g.pageInfo}
414
- <span class="wg__pagination-count">${g.itemCount}</span>
413
+ ${h.pageInfo}
414
+ <span class="wg__pagination-count">${h.itemCount}</span>
415
415
  </div>
416
416
  `,pageSize:n.length>0?`
417
417
  <div class="wg__pagination-pagesize">
418
418
  <select class="wg__pagination-select" data-action="pagesize">
419
419
  ${n.map(y=>`<option value="${y}" ${y===s?"selected":""}>${y}</option>`).join("")}
420
420
  </select>
421
- <span class="wg__pagination-label">${g.perPage}</span>
421
+ <span class="wg__pagination-label">${h.perPage}</span>
422
422
  </div>
423
- `:""},v=e.grid.paginationLayout.split("|").map(y=>y.trim()).map(y=>p[y]||"").join("");return`<div class="${w.join(" ")}">${v}</div>`}function ho(e,t){const o=e.grid.summaryContentCallback;if(!o)return"";const i=e.grid.currentPage,r=e.grid.pageSize,s=e.grid.sortedItems,n=e.grid.displayItems,l=e.grid.totalItems!==null?e.grid.totalItems:s.length,a=o({items:n,allItems:s,totalItems:l,currentPage:i,pageSize:r,metadata:e.grid.summaryMetadata}),d=t.startsWith("top-"),c=t.replace("top-","").replace("bottom-",""),u=["wg__summary"];return c==="left"?u.push("wg__summary--left"):c==="right"&&u.push("wg__summary--right"),d&&u.push("wg__summary--top"),`<div class="${u.join(" ")}">${a}</div>`}function li(e,t){if(t){let o=e.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger");if(o||(o=e.querySelector(".wg__editor")),o){o.focus({preventScroll:!0}),o instanceof HTMLInputElement&&o.type==="text"&&o.select();return}}e.focus({preventScroll:!0})}function ut(e,t,o){const i=e.grid.columns[o],s=((i==null?void 0:i.editTrigger)??e.grid.editTrigger)==="always";if(e.grid.shouldUseVirtualScroll()){is(e,t);const d=e.shadow.querySelector(`[data-row="${t}"][data-col="${o}"]`);d&&(li(d,s),fo(e,d,t));return}const n=e.shadow.querySelector(`[data-row="${t}"][data-col="${o}"]`);if(!n)return;li(n,s),n.scrollIntoView({block:"nearest",inline:"nearest"});const l=e.shadow.querySelector(".wg__header"),a=e.shadow.querySelector(".wg");if(l&&a){const d=n.getBoundingClientRect(),c=l.getBoundingClientRect();if(d.top<c.bottom){const u=d.top-c.bottom-4;a.scrollBy({top:u,behavior:"instant"})}fo(e,n,t)}}function fo(e,t,o){const i=e.shadow.querySelector(".wg");if(!i)return;const r=e.shadow.querySelector(`tr[data-row-index="${o}"] .wg__cell--frozen-last`);if(!r)return;const s=r.getBoundingClientRect().right,n=t.getBoundingClientRect();n.left<s&&i.scrollBy({left:n.left-s,behavior:"instant"})}function is(e,t){const o=e.shadow.querySelector(".wg");if(!o)return;const i=e.grid.virtualScrollRowHeight,r=o.scrollTop,s=o.clientHeight,n=e.shadow.querySelector(".wg__header"),l=(n==null?void 0:n.offsetHeight)||0,a=t*i,d=a+i,c=r+l,u=r+s;a<c?o.scrollTop=a-l:d>u&&(o.scrollTop=d-s)}let ai=0;const rs=100;function J(e,t,o){const i=t&&o&&t.rowIndex===o.rowIndex&&t.colIndex===o.colIndex,r=Date.now();if(i&&r-ai<rs)return;ai=r;const s=e.grid.editingCell;if(t){const n=s&&s.rowIndex===t.rowIndex&&e.grid.columns.findIndex(c=>String(c.field)===s.field)===t.colIndex,l=e.grid.columns[t.colIndex],d=((l==null?void 0:l.editTrigger)??e.grid.editTrigger)==="always";if(!n&&!d)H(e,t.rowIndex,t.colIndex);else{const c=e.shadow.querySelector(`td[data-row="${t.rowIndex}"][data-col="${t.colIndex}"]`);c&&c.classList.remove("wg__cell--focused","wg__cell--always-edit-focused")}}if(o){const n=e.grid.columns[o.colIndex],l=(n==null?void 0:n.editTrigger)??e.grid.editTrigger,a=l==="always",d=l==="click"||l==="dblclick";if(!(s&&s.rowIndex===o.rowIndex&&e.grid.columns.findIndex(u=>String(u.field)===s.field)===o.colIndex)&&!a&&!d)H(e,o.rowIndex,o.colIndex);else if(a||d){const u=e.shadow.querySelector(`td[data-row="${o.rowIndex}"][data-col="${o.colIndex}"]`);u&&(u.classList.add("wg__cell--focused"),a&&u.classList.add("wg__cell--always-edit-focused"))}}}function K(e){const t=e.grid.editingCell;if(t){const o=e.grid.columns.findIndex(r=>String(r.field)===t.field),i=e.shadow.querySelector(`[data-row="${t.rowIndex}"][data-col="${o}"]`);i&&i.classList.remove("wg__cell--editing")}}function ns(e,t,o){H(e,t,o)}function ss(e,t,o){if(!e.grid.isNavigateMode)return;const i=e.grid.focusedCell,r={rowIndex:t,colIndex:o};(i==null?void 0:i.rowIndex)===t&&(i==null?void 0:i.colIndex)===o||(e.grid.setFocusedCell(t,o),J(e,i,r))}function V(e,t,o){const i=e.grid.focusedCell,r={rowIndex:t,colIndex:o};e.grid.setFocusedCell(t,o),J(e,i,r),ut(e,t,o)}function se(e,t,o,i){const r=e.grid.columns[o];if(!r)return;const s=String(r.field);if(!e.grid.canEditCell(t,s))return;e.dropdownOpen&&q(e);const n=e.grid.editingCell;if(n){const l=e.grid.columns.findIndex(a=>String(a.field)===n.field);(n.rowIndex!==t||l!==o)&&(e.isTransitioningCells=!0,e.grid.cancelEdit(),H(e,n.rowIndex,l))}e.grid.startEdit(t,s,i),H(e,t,o,{focusEditor:!0,cursorPosition:i==null?void 0:i.cursorPosition,initialSearchQuery:i==null?void 0:i.initialSearchQuery}),e.isTransitioningCells&&requestAnimationFrame(()=>{e.isTransitioningCells=!1})}function ht(e,t){const o=t.querySelector(".wg__cell-text, .wg__select-value, .wg__date-value");if(!o)return null;const i=o.textContent||"";if(!i.length)return 0;const r=e.clientX,s=o.getBoundingClientRect();if(r<=s.left)return 0;if(r>=s.right)return i.length;const n=o.firstChild;if(!n||n.nodeType!==Node.TEXT_NODE)return null;const l=document.createRange();let a=0,d=i.length;try{for(;a<d;){const c=Math.floor((a+d)/2);l.setStart(n,0),l.setEnd(n,c),l.getBoundingClientRect().right<r?a=c+1:d=c}if(a>0&&a<i.length){l.setStart(n,a-1),l.setEnd(n,a);const c=l.getBoundingClientRect(),u=c.left+c.width/2;r<u&&a--}}catch{return i.length}return a}function di(e){if(e.dropdownOpen&&q(e),e.grid.editingCell){const t=e.grid.editingCell,o=e.grid.columns.findIndex(i=>String(i.field)===t.field);K(e),e.grid.cancelEdit(),o>=0&&H(e,t.rowIndex,o)}if(e.grid.focusedCell){const t=e.grid.focusedCell;e.grid.clearFocusedCell(),J(e,t,null),ke(e.shadow.host)}}function ls(e,t){if(e.isTransitioningCells)return;const o=t.relatedTarget,i=e.shadow.querySelector(".wg__table");o&&(i!=null&&i.contains(o))||requestAnimationFrame(()=>{if(e.isTransitioningCells)return;const r=e.shadow.activeElement;if(r&&(i==null?void 0:i.contains(r)))return;const n=e.shadow.host;if(document.activeElement===n||n.contains(document.activeElement))return;const a=e.grid.focusedCell;e.grid.clearFocusedCell(),J(e,a,null),ke(n)})}function as(e,t){if(!e)return null;const[o,i,r]=e.split("-").map(Number),s=new Date(o,i-1,r);if(isNaN(s.getTime()))return null;switch(t){case"date":return s;case"timestamp":return s.getTime();case"iso":default:return e}}function Mt(e,t,o){H(e,t,o)}async function $t(e,t,o=!1){const i=parseInt(t.dataset.row||"0",10),r=t.dataset.field||"";let s;if(t instanceof HTMLInputElement)if(t.type==="checkbox"){const n=JSON.parse(t.dataset.trueValue||"true"),l=JSON.parse(t.dataset.falseValue||"false");s=t.checked?n:l}else t.classList.contains("wg__editor--number")?s=t.value===""?null:parseFloat(t.value):t.type==="date"?s=as(t.value,t.dataset.outputFormat||"iso"):s=t.value;else t instanceof HTMLSelectElement&&(s=t.value);await e.grid.commitEdit(i,r,s,o)}function ds(e,t){$t(e,t)}function cs(e,t,o){console.trace("[LEGACY] toggleCheckboxAndMove");const i=e.grid.columns[o];if(!i)return;const r=String(i.field),s=e.grid.displayItems[t];if(!s)return;const n=i.editorOptions||{},l=n.trueValue??!0,a=n.falseValue??!1,c=s[r]===l?a:l;e.grid.commitEdit(t,r,c),H(e,t,o);const u=e.grid.displayItems;t<u.length-1&&requestAnimationFrame(()=>{V(e,t+1,o)})}async function gs(e,t){if(!e.isCommittingFromKeyboard&&e.grid.editingCell){const o=parseInt(t.dataset.row||"0",10),i=t.dataset.field||"",r=e.grid.columns.findIndex(s=>String(s.field)===i);await $t(e,t),r>=0&&Mt(e,o,r)}}function wo(e,t,o,i){const s=e.grid.columns.findIndex(d=>String(d.field)===o),n=e.grid.displayItems;let l=t,a=s;if(i==="down"){const d=e.grid.tabTraversalStartColIndex;d!==null&&(a=d,e.grid.tabTraversalStartColIndex=null),l=Math.min(t+1,n.length-1)}else if(i==="up")l=Math.max(t-1,0);else{e.grid.tabTraversalStartColIndex===null&&(e.grid.tabTraversalStartColIndex=s);const d=e.grid.getEditableColumns(),c=d.findIndex(u=>u.index===s);i==="next"?c>=0&&c<d.length-1?a=d[c+1].index:t<n.length-1&&(l=t+1,a=d[0].index):c>0?a=d[c-1].index:t>0&&(l=t-1,a=d[d.length-1].index)}Mt(e,t,s),V(e,l,a),e.isCommittingFromKeyboard=!1}function us(e,t,o){const r=e.grid.columns.findIndex(s=>String(s.field)===o);r>=0&&(Mt(e,t,r),V(e,t,r),e.isCommittingFromKeyboard=!1)}function At(e,t,o,i){const r=String(i.field),s=e.grid.displayItems[t],n=e.grid.getCellRawValue(s,t,r);switch(i.editor||"text"){case"checkbox":return ms(e,t,r,n,i);case"number":return fs(e,t,r,n,i);case"date":return ws(e,t,r,n,i);case"select":return bs(e,t,r,n,i);case"combobox":return _s(e,t,r,n,i);case"autocomplete":return vs(e,t,r,n,i);case"custom":return ys(e,t,r,n,i);case"text":default:return hs(e,t,r,n,i)}}function ci(e){return`wg__editor--valign-${e.verticalAlign||"middle"}`}function hs(e,t,o,i,r){var d;const s=r.editorOptions||{},n=(d=e.grid.editingCell)==null?void 0:d.initialSearchQuery,l=n!==void 0?n:i!=null?String(i):"";return`
423
+ `:""},_=t.grid.paginationLayout.split("|").map(y=>y.trim()).map(y=>p[y]||"").join("");return`<div class="${w.join(" ")}">${_}</div>`}function mo(t,e){const o=t.grid.summaryContentCallback;if(!o)return"";const i=t.grid.currentPage,r=t.grid.pageSize,s=t.grid.sortedItems,n=t.grid.displayItems,l=t.grid.totalItems!==null?t.grid.totalItems:s.length,a=o({items:n,allItems:s,totalItems:l,currentPage:i,pageSize:r,metadata:t.grid.summaryMetadata}),d=e.startsWith("top-"),c=e.replace("top-","").replace("bottom-",""),u=["wg__summary"];return c==="left"?u.push("wg__summary--left"):c==="right"&&u.push("wg__summary--right"),d&&u.push("wg__summary--top"),`<div class="${u.join(" ")}">${a}</div>`}function hi(t,e){if(e){let o=t.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger");if(o||(o=t.querySelector(".wg__editor")),o){o.focus({preventScroll:!0}),o instanceof HTMLInputElement&&o.type==="text"&&o.select();return}}t.focus({preventScroll:!0})}function ft(t,e,o){const i=t.grid.columns[o],s=((i==null?void 0:i.editTrigger)??t.grid.editTrigger)==="always";if(t.grid.shouldUseVirtualScroll()){ls(t,e);const d=t.shadow.querySelector(`[data-row="${e}"][data-col="${o}"]`);d&&(hi(d,s),bo(t,d,e));return}const n=t.shadow.querySelector(`[data-row="${e}"][data-col="${o}"]`);if(!n)return;hi(n,s),n.scrollIntoView({block:"nearest",inline:"nearest"});const l=t.shadow.querySelector(".wg__header"),a=t.shadow.querySelector(".wg");if(l&&a){const d=n.getBoundingClientRect(),c=l.getBoundingClientRect();if(d.top<c.bottom){const u=d.top-c.bottom-4;a.scrollBy({top:u,behavior:"instant"})}bo(t,n,e)}}function bo(t,e,o){const i=t.shadow.querySelector(".wg");if(!i)return;const r=t.shadow.querySelector(`tr[data-row-index="${o}"] .wg__cell--frozen-last`);if(!r)return;const s=r.getBoundingClientRect().right,n=e.getBoundingClientRect();n.left<s&&i.scrollBy({left:n.left-s,behavior:"instant"})}function ls(t,e){const o=t.shadow.querySelector(".wg");if(!o)return;const i=t.grid.virtualScrollRowHeight,r=o.scrollTop,s=o.clientHeight,n=t.shadow.querySelector(".wg__header"),l=(n==null?void 0:n.offsetHeight)||0,a=e*i,d=a+i,c=r+l,u=r+s;a<c?o.scrollTop=a-l:d>u&&(o.scrollTop=d-s)}let fi=0;const as=100;function ee(t,e,o){const i=e&&o&&e.rowIndex===o.rowIndex&&e.colIndex===o.colIndex,r=Date.now();if(i&&r-fi<as)return;fi=r;const s=t.grid.editingCell;if(e){const n=s&&s.rowIndex===e.rowIndex&&t.grid.columns.findIndex(c=>String(c.field)===s.field)===e.colIndex,l=t.grid.columns[e.colIndex],d=((l==null?void 0:l.editTrigger)??t.grid.editTrigger)==="always";if(!n&&!d)O(t,e.rowIndex,e.colIndex);else{const c=t.shadow.querySelector(`td[data-row="${e.rowIndex}"][data-col="${e.colIndex}"]`);c&&c.classList.remove("wg__cell--focused","wg__cell--always-edit-focused")}}if(o){const n=t.grid.columns[o.colIndex],l=(n==null?void 0:n.editTrigger)??t.grid.editTrigger,a=l==="always",d=l==="click"||l==="dblclick";if(!(s&&s.rowIndex===o.rowIndex&&t.grid.columns.findIndex(u=>String(u.field)===s.field)===o.colIndex)&&!a&&!d)O(t,o.rowIndex,o.colIndex);else if(a||d){const u=t.shadow.querySelector(`td[data-row="${o.rowIndex}"][data-col="${o.colIndex}"]`);u&&(u.classList.add("wg__cell--focused"),a&&u.classList.add("wg__cell--always-edit-focused"))}}}function G(t){const e=t.grid.editingCell;if(e){const o=t.grid.columns.findIndex(r=>String(r.field)===e.field),i=t.shadow.querySelector(`[data-row="${e.rowIndex}"][data-col="${o}"]`);i&&i.classList.remove("wg__cell--editing")}}function ds(t,e,o){O(t,e,o)}function cs(t,e,o){if(!t.grid.isNavigateMode)return;const i=t.grid.focusedCell,r={rowIndex:e,colIndex:o};(i==null?void 0:i.rowIndex)===e&&(i==null?void 0:i.colIndex)===o||(t.grid.setFocusedCell(e,o),ee(t,i,r))}function N(t,e,o){const i=t.grid.focusedCell,r={rowIndex:e,colIndex:o};t.grid.setFocusedCell(e,o),ee(t,i,r),ft(t,e,o)}function re(t,e,o,i){const r=t.grid.columns[o];if(!r)return;const s=String(r.field);if(!t.grid.canEditCell(e,s))return;t.dropdownOpen&&V(t);const n=t.grid.editingCell;if(n){const l=t.grid.columns.findIndex(a=>String(a.field)===n.field);(n.rowIndex!==e||l!==o)&&(t.isTransitioningCells=!0,t.grid.cancelEdit(),O(t,n.rowIndex,l))}t.grid.startEdit(e,s,i),O(t,e,o,{focusEditor:!0,cursorPosition:i==null?void 0:i.cursorPosition,initialSearchQuery:i==null?void 0:i.initialSearchQuery}),t.isTransitioningCells&&requestAnimationFrame(()=>{t.isTransitioningCells=!1})}function tt(t,e){const o=e.querySelector(".wg__cell-text, .wg__select-value, .wg__date-value");if(!o)return null;const i=o.textContent||"";if(!i.length)return 0;const r=t.clientX,s=o.getBoundingClientRect();if(r<=s.left)return 0;if(r>=s.right)return i.length;const n=o.firstChild;if(!n||n.nodeType!==Node.TEXT_NODE)return null;const l=document.createRange();let a=0,d=i.length;try{for(;a<d;){const c=Math.floor((a+d)/2);l.setStart(n,0),l.setEnd(n,c),l.getBoundingClientRect().right<r?a=c+1:d=c}if(a>0&&a<i.length){l.setStart(n,a-1),l.setEnd(n,a);const c=l.getBoundingClientRect(),u=c.left+c.width/2;r<u&&a--}}catch{return i.length}return a}function wi(t){if(t.dropdownOpen&&V(t),t.grid.editingCell){const e=t.grid.editingCell,o=t.grid.columns.findIndex(i=>String(i.field)===e.field);G(t),t.grid.cancelEdit(),o>=0&&O(t,e.rowIndex,o)}if(t.grid.focusedCell){const e=t.grid.focusedCell;t.grid.clearFocusedCell(),ee(t,e,null),Re(t.shadow.host)}}function gs(t,e){if(t.isTransitioningCells)return;const o=e.relatedTarget,i=t.shadow.querySelector(".wg__table");o&&(i!=null&&i.contains(o))||o&&pi(t,o)||requestAnimationFrame(()=>{if(t.isTransitioningCells)return;const r=t.shadow.activeElement;if(r&&(i==null?void 0:i.contains(r)))return;const n=t.shadow.host;if(document.activeElement===n||n.contains(document.activeElement)||pi(t,document.activeElement))return;const a=t.grid.focusedCell;t.grid.clearFocusedCell(),ee(t,a,null),Re(n)})}function pi(t,e){var i;if(!e)return!1;const o=((i=t.datepicker)==null?void 0:i.getElement())??null;return!!(o&&o.contains(e)||t.contextMenuElement&&t.contextMenuElement.contains(e)||t.headerContextMenuElement&&t.headerContextMenuElement.contains(e))}function us(t,e){if(!t)return null;const[o,i,r]=t.split("-").map(Number),s=new Date(o,i-1,r);if(isNaN(s.getTime()))return null;switch(e){case"date":return s;case"timestamp":return s.getTime();case"iso":default:return t}}function Lt(t,e,o){O(t,e,o)}async function zt(t,e,o=!1){const i=parseInt(e.dataset.row||"0",10),r=e.dataset.field||"";let s;if(e instanceof HTMLInputElement)if(e.type==="checkbox"){const n=JSON.parse(e.dataset.trueValue||"true"),l=JSON.parse(e.dataset.falseValue||"false");s=e.checked?n:l}else e.classList.contains("wg__editor--number")?s=e.value===""?null:parseFloat(e.value):e.type==="date"?s=us(e.value,e.dataset.outputFormat||"iso"):s=e.value;else e instanceof HTMLSelectElement&&(s=e.value);await t.grid.commitEdit(i,r,s,o)}function hs(t,e){zt(t,e)}function fs(t,e,o){const i=t.grid.columns[o];if(!i)return;const r=String(i.field),s=t.grid.displayItems[e];if(!s)return;const n=i.editorOptions||{},l=n.trueValue??!0,a=n.falseValue??!1,c=s[r]===l?a:l;t.grid.commitEdit(e,r,c),O(t,e,o);const u=t.grid.displayItems;e<u.length-1&&requestAnimationFrame(()=>{N(t,e+1,o)})}async function ws(t,e){if(!t.isCommittingFromKeyboard&&t.grid.editingCell){const o=parseInt(e.dataset.row||"0",10),i=e.dataset.field||"",r=t.grid.columns.findIndex(s=>String(s.field)===i);await zt(t,e),r>=0&&Lt(t,o,r)}}function _o(t,e,o,i){const s=t.grid.columns.findIndex(u=>String(u.field)===o),n=t.grid.displayItems;let l=e,a=s;if(i==="down"){const u=t.grid.tabTraversalStartColIndex;u!==null&&(a=u,t.grid.tabTraversalStartColIndex=null),l=Math.min(e+1,n.length-1)}else if(i==="up")l=Math.max(e-1,0);else{t.grid.tabTraversalStartColIndex===null&&(t.grid.tabTraversalStartColIndex=s);const u=n[e],h=t.grid.getEditableColumns(u),g=h.findIndex(m=>m.index===s),f=i==="next"?"forward":"backward",w=g===-1?f==="forward"?-1:h.length:g,p=t.grid.findNextEditableCell(e,w,f);p&&(l=p.rowIndex,a=p.colIndex)}if(Lt(t,e,s),N(t,l,a),(i==="next"||i==="prev")&&(l!==e||a!==s)){const u=t.grid.columns[a],h=(u==null?void 0:u.editTrigger)??t.grid.editTrigger;if(h==="dblclick"||h==="click"||h==="button"){requestAnimationFrame(()=>{t.grid.canEditCell(l,String(u.field))&&re(t,l,a),t.isCommittingFromKeyboard=!1});return}}t.isCommittingFromKeyboard=!1}function ps(t,e,o){const r=t.grid.columns.findIndex(s=>String(s.field)===o);r>=0&&(Lt(t,e,r),N(t,e,r),t.isCommittingFromKeyboard=!1)}function Ot(t,e,o,i){const r=String(i.field),s=t.grid.displayItems[e],n=t.grid.getCellRawValue(s,e,r);switch(i.editor||"text"){case"checkbox":return ys(t,e,r,n,i);case"number":return bs(t,e,r,n,i);case"date":return _s(t,e,r,n,i);case"select":return Cs(t,e,r,n,i);case"combobox":return Ss(t,e,r,n,i);case"autocomplete":return xs(t,e,r,n,i);case"custom":return ks(t,e,r,n,i);case"text":default:return ms(t,e,r,n,i)}}function mi(t){return`wg__editor--valign-${t.verticalAlign||"middle"}`}function ms(t,e,o,i,r){var d;const s=r.editorOptions||{},n=(d=t.grid.editingCell)==null?void 0:d.initialSearchQuery,l=n!==void 0?n:i!=null?String(i):"";return`
424
424
  <input
425
425
  type="text"
426
- class="wg__editor wg__editor--text ${ci(r)}"
427
- value="${e.escapeHtml(l)}"
428
- data-row="${t}"
426
+ class="wg__editor wg__editor--text ${mi(r)}"
427
+ value="${t.escapeHtml(l)}"
428
+ data-row="${e}"
429
429
  data-field="${o}"
430
430
  ${s.maxLength?`maxlength="${s.maxLength}"`:""}
431
- ${s.placeholder?`placeholder="${e.escapeHtml(s.placeholder)}"`:""}
432
- ${s.pattern?`pattern="${e.escapeHtml(s.pattern)}"`:""}
431
+ ${s.placeholder?`placeholder="${t.escapeHtml(s.placeholder)}"`:""}
432
+ ${s.pattern?`pattern="${t.escapeHtml(s.pattern)}"`:""}
433
433
  />
434
- `}function fs(e,t,o,i,r){var a;r.editorOptions;const s=(a=e.grid.editingCell)==null?void 0:a.initialSearchQuery,n=s!==void 0?s:i!=null?String(i):"";return`
434
+ `}function bs(t,e,o,i,r){var a;r.editorOptions;const s=(a=t.grid.editingCell)==null?void 0:a.initialSearchQuery,n=s!==void 0?s:i!=null?String(i):"";return`
435
435
  <input
436
436
  type="text"
437
437
  inputmode="numeric"
438
- class="wg__editor wg__editor--number ${ci(r)}"
438
+ class="wg__editor wg__editor--number ${mi(r)}"
439
439
  value="${n}"
440
- data-row="${t}"
440
+ data-row="${e}"
441
441
  data-field="${o}"
442
442
  />
443
- `}function ws(e,t,o,i,r){var d;const s=r.editorOptions||{},n=(d=e.grid.editingCell)==null?void 0:d.initialSearchQuery,l=po(i),a=n!==void 0?n:ps(i,s.dateFormat);return`
444
- <div class="wg__editor wg__editor--date" data-row="${t}" data-field="${o}">
443
+ `}function _s(t,e,o,i,r){var d;const s=r.editorOptions||{},n=(d=t.grid.editingCell)==null?void 0:d.initialSearchQuery,l=vo(i),a=n!==void 0?n:vs(i,s.dateFormat);return`
444
+ <div class="wg__editor wg__editor--date" data-row="${e}" data-field="${o}">
445
445
  <input
446
446
  type="text"
447
447
  class="wg__date-input"
448
- value="${e.escapeHtml(a)}"
449
- data-row="${t}"
448
+ value="${t.escapeHtml(a)}"
449
+ data-row="${e}"
450
450
  data-field="${o}"
451
451
  data-date-value="${l}"
452
452
  data-output-format="${s.outputFormat||"iso"}"
453
453
  data-date-format="${s.dateFormat||"YYYY-MM-DD"}"
454
- ${s.minDate?`data-min-date="${po(s.minDate)}"`:""}
455
- ${s.maxDate?`data-max-date="${po(s.maxDate)}"`:""}
456
- placeholder="${e.escapeHtml(s.dateFormat||"YYYY-MM-DD")}"
454
+ ${s.minDate?`data-min-date="${vo(s.minDate)}"`:""}
455
+ ${s.maxDate?`data-max-date="${vo(s.maxDate)}"`:""}
456
+ placeholder="${t.escapeHtml(s.dateFormat||"YYYY-MM-DD")}"
457
457
  />
458
458
  <button type="button" class="wg__date-trigger" tabindex="-1">
459
459
  <svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm-8 4H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z"/></svg>
460
460
  </button>
461
461
  </div>
462
- `}function ps(e,t){if(!e)return"";let o=null;if(e instanceof Date?o=e:typeof e=="number"?o=new Date(e):typeof e=="string"&&(o=new Date(e)),!o||isNaN(o.getTime()))return"";const i=t||"YYYY-MM-DD",r=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),n=String(o.getDate()).padStart(2,"0");return i.replace("YYYY",String(r)).replace("YY",String(r).slice(-2)).replace("MM",s).replace("DD",n)}function po(e){if(!e)return"";let t=null;if(e instanceof Date?t=e:typeof e=="number"?t=new Date(e):typeof e=="string"&&(t=new Date(e)),!t||isNaN(t.getTime()))return"";const o=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${o}-${i}-${r}`}function ms(e,t,o,i,r){const s=r.editorOptions||{};return`
462
+ `}function vs(t,e){if(!t)return"";let o=null;if(t instanceof Date?o=t:typeof t=="number"?o=new Date(t):typeof t=="string"&&(o=new Date(t)),!o||isNaN(o.getTime()))return"";const i=e||"YYYY-MM-DD",r=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),n=String(o.getDate()).padStart(2,"0");return i.replace("YYYY",String(r)).replace("YY",String(r).slice(-2)).replace("MM",s).replace("DD",n)}function vo(t){if(!t)return"";let e=null;if(t instanceof Date?e=t:typeof t=="number"?e=new Date(t):typeof t=="string"&&(e=new Date(t)),!e||isNaN(e.getTime()))return"";const o=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${o}-${i}-${r}`}function ys(t,e,o,i,r){const s=r.editorOptions||{};return`
463
463
  <input
464
464
  type="checkbox"
465
465
  class="wg__editor wg__editor--checkbox"
466
466
  ${(s.trueValue!==void 0?i===s.trueValue:!!i)?"checked":""}
467
- data-row="${t}"
467
+ data-row="${e}"
468
468
  data-field="${o}"
469
- data-true-value="${e.escapeHtml(JSON.stringify(s.trueValue??!0))}"
470
- data-false-value="${e.escapeHtml(JSON.stringify(s.falseValue??!1))}"
469
+ data-true-value="${t.escapeHtml(JSON.stringify(s.trueValue??!0))}"
470
+ data-false-value="${t.escapeHtml(JSON.stringify(s.falseValue??!1))}"
471
471
  />
472
- `}function bs(e,t,o,i,r){var d;const s=r.editorOptions||{},n=s.options||[],l=ct(i,n,s),a=(d=e.grid.editingCell)==null?void 0:d.initialSearchQuery;return e.dropdownOptions=n,e.filterText=a||"",e.highlightedIndex=n.findIndex(c=>Ae(c,s)===i),e.highlightedIndex<0&&n.length>0&&(e.highlightedIndex=0),`
472
+ `}function Cs(t,e,o,i,r){var d;const s=r.editorOptions||{},n=s.options||[],l=ut(i,n,s),a=(d=t.grid.editingCell)==null?void 0:d.initialSearchQuery;return t.dropdownOptions=n,t.filterText=a||"",t.highlightedIndex=n.findIndex(c=>ze(c,s)===i),t.highlightedIndex<0&&n.length>0&&(t.highlightedIndex=0),`
473
473
  <div
474
474
  class="wg__editor wg__editor--select wg__select-trigger"
475
475
  tabindex="0"
476
476
  role="combobox"
477
477
  aria-haspopup="listbox"
478
- data-row="${t}"
478
+ data-row="${e}"
479
479
  data-field="${o}"
480
- data-value="${e.escapeHtml(String(i??""))}"
480
+ data-value="${t.escapeHtml(String(i??""))}"
481
481
  >
482
- <span class="wg__select-value">${e.escapeHtml(l)}</span>
482
+ <span class="wg__select-value">${t.escapeHtml(l)}</span>
483
483
  <span class="wg__select-toggle">▼</span>
484
484
  </div>
485
- `}function _s(e,t,o,i,r){var c;const s=r.editorOptions||{},n=s.options||[],l=ct(i,n,s),a=(c=e.grid.editingCell)==null?void 0:c.initialSearchQuery,d=a!==void 0?a:l;return e.dropdownOptions=n,e.filterText=d,e.highlightedIndex=n.length>0?0:-1,`
486
- <div class="wg__editor wg__editor--combobox" data-row="${t}" data-field="${o}">
485
+ `}function Ss(t,e,o,i,r){var c;const s=r.editorOptions||{},n=s.options||[],l=ut(i,n,s),a=(c=t.grid.editingCell)==null?void 0:c.initialSearchQuery,d=a!==void 0?a:l;return t.dropdownOptions=n,t.filterText=d,t.highlightedIndex=n.length>0?0:-1,`
486
+ <div class="wg__editor wg__editor--combobox" data-row="${e}" data-field="${o}">
487
487
  <input
488
488
  type="text"
489
489
  class="wg__combobox-input"
490
- value="${e.escapeHtml(d)}"
491
- data-row="${t}"
490
+ value="${t.escapeHtml(d)}"
491
+ data-row="${e}"
492
492
  data-field="${o}"
493
493
  />
494
494
  <span class="wg__combobox-toggle">▼</span>
495
495
  </div>
496
- `}function vs(e,t,o,i,r){var c;const s=r.editorOptions||{},n=s.initialOptions||s.options||[],l=ct(i,n,s),a=(c=e.grid.editingCell)==null?void 0:c.initialSearchQuery,d=a!==void 0?a:l;return e.dropdownOptions=n,e.filterText=d,e.highlightedIndex=n.length>0?0:-1,`
497
- <div class="wg__editor wg__editor--autocomplete" data-row="${t}" data-field="${o}">
496
+ `}function xs(t,e,o,i,r){var c;const s=r.editorOptions||{},n=s.initialOptions||s.options||[],l=ut(i,n,s),a=(c=t.grid.editingCell)==null?void 0:c.initialSearchQuery,d=a!==void 0?a:l;return t.dropdownOptions=n,t.filterText=d,t.highlightedIndex=n.length>0?0:-1,`
497
+ <div class="wg__editor wg__editor--autocomplete" data-row="${e}" data-field="${o}">
498
498
  <input
499
499
  type="text"
500
500
  class="wg__autocomplete-input"
501
- value="${e.escapeHtml(d)}"
502
- placeholder="${e.escapeHtml(s.placeholder||"")}"
503
- data-row="${t}"
501
+ value="${t.escapeHtml(d)}"
502
+ placeholder="${t.escapeHtml(s.placeholder||"")}"
503
+ data-row="${e}"
504
504
  data-field="${o}"
505
505
  />
506
506
  <span class="wg__combobox-toggle">▼</span>
507
507
  <span class="wg__loading-indicator" style="display: none;">⏳</span>
508
508
  </div>
509
- `}function ys(e,t,o,i,r){const s=r.formatCallback?r.formatCallback(i,e.grid.displayItems[t]):i!=null?String(i):"";return`
509
+ `}function ks(t,e,o,i,r){const s=r.formatCallback?r.formatCallback(i,t.grid.displayItems[e]):i!=null?String(i):"";return`
510
510
  <div
511
511
  class="wg__editor wg__editor--custom"
512
512
  tabindex="0"
513
- data-row="${t}"
513
+ data-row="${e}"
514
514
  data-field="${o}"
515
515
  >
516
- <span class="wg__custom-value">${e.escapeHtml(s)}</span>
516
+ <span class="wg__custom-value">${t.escapeHtml(s)}</span>
517
517
  </div>
518
- `}function H(e,t,o,i={}){const r=e.grid.columns[o];if(!r)return;const s=e.shadow.querySelector(`td[data-row="${t}"][data-col="${o}"]`);if(!s)return;const n=String(r.field),l=e.grid.displayItems[t];if(!l)return;const a=e.grid.shouldShowEditor(t,o),d=e.grid.isEditing(t,n),c=e.grid.isCellFocused(t,o),u=e.grid.canEditCell(t,n),g=e.grid.isCellInvalid(t,n),h=e.grid.visualColumns.findIndex(v=>v.originalIndex===o),f=h>=0&&e.grid.isColumnFrozen(h),w=f&&h===e.grid.totalFrozenColumns-1,p=r.editTrigger??e.grid.editTrigger,m=["wg__cell"];if(u&&m.push("wg__cell--editable"),c&&!d&&m.push("wg__cell--focused"),c&&p==="always"&&m.push("wg__cell--always-edit-focused"),r.textOverflow!=="wrap"&&m.push("wg__cell--ellipsis"),r.maxLines&&m.push("wg__cell--line-clamp"),d&&m.push("wg__cell--editing"),g&&m.push("wg__cell--invalid"),e.grid.isDirtyIndicatorVisible&&e.grid.isCellDirty(t,n)&&m.push("wg__cell--dirty"),h>=0&&e.grid.isCellInSelectedRange(t,h)&&m.push("wg__cell--in-range"),h>=0&&e.grid.isColumnSelected(h)&&m.push("wg__cell--column-selected"),f&&m.push("wg__cell--frozen"),w&&m.push("wg__cell--frozen-last"),r.cellClass&&m.push(r.cellClass),r.cellClassCallback){const v=e.grid.getCellRawValue(l,t,n),y=r.cellClassCallback(v,l);y&&m.push(y)}if(s.className=m.join(" "),a)s.innerHTML=At(e,t,o,r),i.focusEditor&&Cs(e,s,r,i);else{const v=e.grid.getCellValue(l,r,t);s.innerHTML=no(e,t,o,r,v,c,u)}}function Cs(e,t,o,i){var s;let r=t.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__select-trigger, .wg__date-input");if(r||(r=t.querySelector(".wg__editor")),!!r&&(r.focus(),r instanceof HTMLInputElement&&r.type==="text")){const n=i.cursorPosition,a=r.classList.contains("wg__combobox-input")||r.classList.contains("wg__autocomplete-input")?"selectAll":void 0,d=((s=o.editorOptions)==null?void 0:s.editStartSelection)||a||e.grid.editStartSelection;if(i.initialSearchQuery!==void 0){const c=r.value.length;r.setSelectionRange(c,c)}else switch(d){case"mousePosition":if(n!==void 0){const c=Math.min(n,r.value.length);r.setSelectionRange(c,c)}else r.setSelectionRange(r.value.length,r.value.length);break;case"cursorAtStart":r.setSelectionRange(0,0);break;case"cursorAtEnd":r.setSelectionRange(r.value.length,r.value.length);break;case"selectAll":default:r.select();break}}}const Ss=5;function xs(e,t){var i,r;switch(t.editor||"text"){case"number":return typeof e=="number"&&!isNaN(e);case"select":case"combobox":{const s=(i=t.editorOptions)==null?void 0:i.options;if(!s||s.length===0)return!0;const n=((r=t.editorOptions)==null?void 0:r.valueMember)||"value";return s.some(l=>l[n]===e)}case"date":{if(e==null||e==="")return!0;if(e instanceof Date)return!isNaN(e.getTime());if(typeof e=="string"){if(!/\d{4}[-/]\d{1,2}[-/]\d{1,2}/.test(e)&&!/\d{1,2}[-/.]\d{1,2}[-/.]\d{2,4}/.test(e))return!1;const s=new Date(e);return!isNaN(s.getTime())}if(typeof e=="number"){const s=new Date("2000-01-01").getTime(),n=new Date("2100-01-01").getTime();if(e<s||e>n)return!1;const l=new Date(e);return!isNaN(l.getTime())}return!1}case"text":case"autocomplete":case"checkbox":case"custom":default:return!0}}let L={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:null,rangeElement:null},Se=null,ft=null;function Lt(e){var p;const t=e.grid.focusedCell,o=e.shadow.host;if(!t||e.grid.editingCell||e.dropdownOpen){ke(o);return}const{rowIndex:i,colIndex:r}=t,s=(p=e.grid.visualColumns[r])==null?void 0:p.column;if(!s||!e.grid.isCellEditable(s)){ke(o);return}const n=e.shadow.querySelector(`[data-row="${i}"][data-col="${r}"]`);if(!n){ke(o);return}const l=e.shadow.querySelector(".wg");if(!l)return;const a=l.getBoundingClientRect(),d=n.getBoundingClientRect(),c=l.scrollLeft,u=l.scrollTop,g=8,h=i===e.grid.displayItems.length-1,f=d.right-a.left+c-g/2,w=h?d.top-a.top+u-g/2:d.bottom-a.top+u-g/2;if(L.handleElement&&L.handleElement.parentElement!==l&&(L.handleElement.remove(),L.handleElement=null,ft=null),!L.handleElement){const m=document.createElement("div");m.className="wg__fill-handle",l.appendChild(m),L.handleElement=m,ft=o,m.addEventListener("mousedown",v=>ks(e,v))}L.handleElement.style.left=`${f}px`,L.handleElement.style.top=`${w}px`}function ke(e){if(L.handleElement){if(e&&ft&&e!==ft)return;L.handleElement.remove(),L.handleElement=null,ft=null}}function ks(e,t){var l;t.preventDefault(),t.stopPropagation();const o=e.grid.focusedCell;if(!o)return;const{rowIndex:i,colIndex:r}=o,n=(l=e.grid.visualColumns[r])==null?void 0:l.column;n&&(L={...L,isPending:!0,isDragging:!1,startRowIndex:i,startColIndex:r,startField:String(n.field),startX:t.clientX,startY:t.clientY,currentRowIndex:i,currentColIndex:r},Se=e,document.addEventListener("mousemove",gi),document.addEventListener("mouseup",hi),document.addEventListener("keydown",fi))}function gi(e){if(!Se)return;if(L.isPending){const o=e.clientX-L.startX,i=e.clientY-L.startY;Math.sqrt(o*o+i*i)>=Ss&&Rs(Se);return}if(!L.isDragging)return;const t=Is(Se,e.clientX,e.clientY);t&&(t.rowIndex!==L.currentRowIndex||t.colIndex!==L.currentColIndex)&&(L.currentRowIndex=t.rowIndex,L.currentColIndex=t.colIndex,ui(Se))}function Rs(e){L.isPending=!1,L.isDragging=!0;const t=e.shadow.querySelector(".wg");t==null||t.classList.add("wg--filling"),Es(e)}function Es(e){const t=e.shadow.querySelector(".wg");if(!t)return;const o=document.createElement("div");o.className="wg__fill-range",t.appendChild(o),L.rangeElement=o,ui(e)}function ui(e){if(!L.rangeElement)return;const t=e.shadow.querySelector(".wg");if(!t)return;const{startRowIndex:o,startColIndex:i,currentRowIndex:r,currentColIndex:s}=L,n=Math.min(o,r),l=Math.max(o,r),a=Math.min(i,s),d=Math.max(i,s),c=e.shadow.querySelector(`[data-row="${n}"][data-col="${a}"]`),u=e.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`);if(!c||!u)return;const g=t.getBoundingClientRect(),h=c.getBoundingClientRect(),f=u.getBoundingClientRect(),w=t.scrollLeft,p=t.scrollTop,m=h.left-g.left+w,v=h.top-g.top+p,y=f.right-h.left,x=f.bottom-h.top;L.rangeElement.style.left=`${m}px`,L.rangeElement.style.top=`${v}px`,L.rangeElement.style.width=`${y}px`,L.rangeElement.style.height=`${x}px`}function hi(e){if(!Se)return;const t=Se;if(L.isPending){mo(t);return}L.isDragging&&(Ts(t),mo(t))}function fi(e){e.key==="Escape"&&Se&&(e.preventDefault(),mo(Se))}function Is(e,t,o){if(!e.shadow.querySelector(".wg"))return null;const r=e.shadow.querySelectorAll(".wg__cell[data-row][data-col]");for(const s of r){const n=s.getBoundingClientRect();if(t>=n.left&&t<=n.right&&o>=n.top&&o<=n.bottom){const l=parseInt(s.dataset.row||"-1",10),a=parseInt(s.dataset.col||"-1",10);if(l>=0&&a>=0)return{rowIndex:l,colIndex:a}}}return null}function Ds(e,t,o,i){const r=o-e,s=i-t;return r===0&&s===0?"down":Math.abs(r)>=Math.abs(s)?r>0?"down":"up":s>0?"right":"left"}async function Ts(e){var v,y;const{startRowIndex:t,startColIndex:o,currentRowIndex:i,currentColIndex:r,startField:s}=L,n=e.grid.visualColumns,l=(v=n[o])==null?void 0:v.column;if(!l)return;const a=e.grid.getRowDraft(t)??e.grid.displayItems[t];if(!a)return;const d=a[s],c=Ds(t,o,i,r),u=l.fillDirection??e.grid.fillDirection,g=[],h=Math.min(t,i),f=Math.max(t,i),w=u==="vertical"?o:Math.min(o,r),p=u==="vertical"?o:Math.max(o,r);for(let x=h;x<=f;x++)for(let C=w;C<=p;C++){if(x===t&&C===o)continue;const _=(y=n[C])==null?void 0:y.column;if(!_)continue;const S=String(_.field);e.grid.canEditCell(x,S)&&xs(d,_)&&g.push({rowIndex:x,colIndex:C,field:S})}if(g.length===0)return;const m={sourceCell:{rowIndex:t,colIndex:o,field:s,value:d},targetCells:g,direction:c};if(!(e.grid.fillDragCallback&&e.grid.fillDragCallback(m)===!1))for(const x of g)await e.grid.commitEdit(x.rowIndex,x.field,d),H(e,x.rowIndex,x.colIndex)}function mo(e){L.rangeElement&&(L.rangeElement.remove(),L.rangeElement=null);const t=e.shadow.querySelector(".wg");t==null||t.classList.remove("wg--filling"),document.removeEventListener("mousemove",gi),document.removeEventListener("mouseup",hi),document.removeEventListener("keydown",fi),L={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:L.handleElement,rangeElement:null},Se=null}function Le(e,t,o,i){var s;q(e);const r=document.createElement("div");if(r.className="wg__dropdown",r.style.cssText=`
518
+ `}function O(t,e,o,i={}){const r=t.grid.columns[o];if(!r)return;const s=t.shadow.querySelector(`td[data-row="${e}"][data-col="${o}"]`);if(!s)return;const n=String(r.field),l=t.grid.displayItems[e];if(!l)return;const a=t.grid.shouldShowEditor(e,o),d=t.grid.isEditing(e,n),c=t.grid.isCellFocused(e,o),u=t.grid.canEditCell(e,n),h=t.grid.isCellInvalid(e,n),g=t.grid.visualColumns.findIndex(_=>_.originalIndex===o),f=g>=0&&t.grid.isColumnFrozen(g),w=f&&g===t.grid.totalFrozenColumns-1,p=r.editTrigger??t.grid.editTrigger,m=["wg__cell"];if(u&&m.push("wg__cell--editable"),c&&!d&&m.push("wg__cell--focused"),c&&p==="always"&&m.push("wg__cell--always-edit-focused"),r.textOverflow!=="wrap"&&m.push("wg__cell--ellipsis"),r.maxLines&&m.push("wg__cell--line-clamp"),d&&m.push("wg__cell--editing"),h&&m.push("wg__cell--invalid"),t.grid.isDirtyIndicatorVisible&&t.grid.isCellDirty(e,n)&&m.push("wg__cell--dirty"),g>=0&&t.grid.isCellInSelectedRange(e,g)&&m.push("wg__cell--in-range"),g>=0&&t.grid.isColumnSelected(g)&&m.push("wg__cell--column-selected"),f&&m.push("wg__cell--frozen"),w&&m.push("wg__cell--frozen-last"),r.cellClass&&m.push(r.cellClass),r.cellClassCallback){const _=t.grid.getCellRawValue(l,e,n),y=r.cellClassCallback(_,l);y&&m.push(y)}if(s.className=m.join(" "),a)s.innerHTML=Pt(t,r,l,Ot(t,e,o,r)),i.focusEditor&&Is(t,s,r,i);else{const _=t.grid.getCellValue(l,r,e);s.innerHTML=Pt(t,r,l,co(t,e,o,r,_,c,u))}}function Is(t,e,o,i){var s;let r=e.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__select-trigger, .wg__date-input");if(r||(r=e.querySelector(".wg__editor")),!!r&&(r.focus(),r instanceof HTMLInputElement&&r.type==="text")){const n=i.cursorPosition,a=r.classList.contains("wg__combobox-input")||r.classList.contains("wg__autocomplete-input")?"selectAll":void 0,d=((s=o.editorOptions)==null?void 0:s.editStartSelection)||a||t.grid.editStartSelection;if(i.initialSearchQuery!==void 0){const c=r.value.length;r.setSelectionRange(c,c)}else switch(d){case"mousePosition":if(n!==void 0){const c=Math.min(n,r.value.length);r.setSelectionRange(c,c)}else r.setSelectionRange(r.value.length,r.value.length);break;case"cursorAtStart":r.setSelectionRange(0,0);break;case"cursorAtEnd":r.setSelectionRange(r.value.length,r.value.length);break;case"selectAll":default:r.select();break}}}const Es=5;function Rs(t,e){var i,r;switch(e.editor||"text"){case"number":return typeof t=="number"&&!isNaN(t);case"select":case"combobox":{const s=(i=e.editorOptions)==null?void 0:i.options;if(!s||s.length===0)return!0;const n=((r=e.editorOptions)==null?void 0:r.valueMember)||"value";return s.some(l=>l[n]===t)}case"date":{if(t==null||t==="")return!0;if(t instanceof Date)return!isNaN(t.getTime());if(typeof t=="string"){if(!/\d{4}[-/]\d{1,2}[-/]\d{1,2}/.test(t)&&!/\d{1,2}[-/.]\d{1,2}[-/.]\d{2,4}/.test(t))return!1;const s=new Date(t);return!isNaN(s.getTime())}if(typeof t=="number"){const s=new Date("2000-01-01").getTime(),n=new Date("2100-01-01").getTime();if(t<s||t>n)return!1;const l=new Date(t);return!isNaN(l.getTime())}return!1}case"text":case"autocomplete":case"checkbox":case"custom":default:return!0}}let z={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:null,rangeElement:null},ke=null,wt=null;function Ht(t){var m;const e=t.grid.focusedCell,o=t.shadow.host;if(!e||t.grid.editingCell||t.dropdownOpen){Re(o);return}const{rowIndex:i,colIndex:r}=e,s=(m=t.grid.visualColumns[r])==null?void 0:m.column,n=t.grid.displayItems[i];if(!s||!t.grid.isCellEditable(s,n)){Re(o);return}const l=t.shadow.querySelector(`[data-row="${i}"][data-col="${r}"]`);if(!l){Re(o);return}const a=t.shadow.querySelector(".wg");if(!a)return;const d=a.getBoundingClientRect(),c=l.getBoundingClientRect(),u=a.scrollLeft,h=a.scrollTop,g=8,f=i===t.grid.displayItems.length-1,w=c.right-d.left+u-g/2,p=f?c.top-d.top+h-g/2:c.bottom-d.top+h-g/2;if(z.handleElement&&z.handleElement.parentElement!==a&&(z.handleElement.remove(),z.handleElement=null,wt=null),!z.handleElement){const _=document.createElement("div");_.className="wg__fill-handle",a.appendChild(_),z.handleElement=_,wt=o,_.addEventListener("mousedown",y=>Ds(t,y))}z.handleElement.style.left=`${w}px`,z.handleElement.style.top=`${p}px`}function Re(t){if(z.handleElement){if(t&&wt&&t!==wt)return;z.handleElement.remove(),z.handleElement=null,wt=null}}function Ds(t,e){var l;e.preventDefault(),e.stopPropagation();const o=t.grid.focusedCell;if(!o)return;const{rowIndex:i,colIndex:r}=o,n=(l=t.grid.visualColumns[r])==null?void 0:l.column;n&&(z={...z,isPending:!0,isDragging:!1,startRowIndex:i,startColIndex:r,startField:String(n.field),startX:e.clientX,startY:e.clientY,currentRowIndex:i,currentColIndex:r},ke=t,document.addEventListener("mousemove",bi),document.addEventListener("mouseup",vi),document.addEventListener("keydown",yi))}function bi(t){if(!ke)return;if(z.isPending){const o=t.clientX-z.startX,i=t.clientY-z.startY;Math.sqrt(o*o+i*i)>=Es&&Ts(ke);return}if(!z.isDragging)return;const e=$s(ke,t.clientX,t.clientY);e&&(e.rowIndex!==z.currentRowIndex||e.colIndex!==z.currentColIndex)&&(z.currentRowIndex=e.rowIndex,z.currentColIndex=e.colIndex,_i(ke))}function Ts(t){z.isPending=!1,z.isDragging=!0;const e=t.shadow.querySelector(".wg");e==null||e.classList.add("wg--filling"),Ms(t)}function Ms(t){const e=t.shadow.querySelector(".wg");if(!e)return;const o=document.createElement("div");o.className="wg__fill-range",e.appendChild(o),z.rangeElement=o,_i(t)}function _i(t){if(!z.rangeElement)return;const e=t.shadow.querySelector(".wg");if(!e)return;const{startRowIndex:o,startColIndex:i,currentRowIndex:r,currentColIndex:s}=z,n=Math.min(o,r),l=Math.max(o,r),a=Math.min(i,s),d=Math.max(i,s),c=t.shadow.querySelector(`[data-row="${n}"][data-col="${a}"]`),u=t.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`);if(!c||!u)return;const h=e.getBoundingClientRect(),g=c.getBoundingClientRect(),f=u.getBoundingClientRect(),w=e.scrollLeft,p=e.scrollTop,m=g.left-h.left+w,_=g.top-h.top+p,y=f.right-g.left,C=f.bottom-g.top;z.rangeElement.style.left=`${m}px`,z.rangeElement.style.top=`${_}px`,z.rangeElement.style.width=`${y}px`,z.rangeElement.style.height=`${C}px`}function vi(t){if(!ke)return;const e=ke;if(z.isPending){yo(e);return}z.isDragging&&(As(e),yo(e))}function yi(t){t.key==="Escape"&&ke&&(t.preventDefault(),yo(ke))}function $s(t,e,o){if(!t.shadow.querySelector(".wg"))return null;const r=t.shadow.querySelectorAll(".wg__cell[data-row][data-col]");for(const s of r){const n=s.getBoundingClientRect();if(e>=n.left&&e<=n.right&&o>=n.top&&o<=n.bottom){const l=parseInt(s.dataset.row||"-1",10),a=parseInt(s.dataset.col||"-1",10);if(l>=0&&a>=0)return{rowIndex:l,colIndex:a}}}return null}function Ps(t,e,o,i){const r=o-t,s=i-e;return r===0&&s===0?"down":Math.abs(r)>=Math.abs(s)?r>0?"down":"up":s>0?"right":"left"}async function As(t){var _,y;const{startRowIndex:e,startColIndex:o,currentRowIndex:i,currentColIndex:r,startField:s}=z,n=t.grid.visualColumns,l=(_=n[o])==null?void 0:_.column;if(!l)return;const a=t.grid.getRowDraft(e)??t.grid.displayItems[e];if(!a)return;const d=a[s],c=Ps(e,o,i,r),u=l.fillDirection??t.grid.fillDirection,h=[],g=Math.min(e,i),f=Math.max(e,i),w=u==="vertical"?o:Math.min(o,r),p=u==="vertical"?o:Math.max(o,r);for(let C=g;C<=f;C++)for(let S=w;S<=p;S++){if(C===e&&S===o)continue;const v=(y=n[S])==null?void 0:y.column;if(!v)continue;const x=String(v.field);t.grid.canEditCell(C,x)&&Rs(d,v)&&h.push({rowIndex:C,colIndex:S,field:x})}if(h.length===0)return;const m={sourceCell:{rowIndex:e,colIndex:o,field:s,value:d},targetCells:h,direction:c};if(!(t.grid.fillDragCallback&&t.grid.fillDragCallback(m)===!1))for(const C of h)await t.grid.commitEdit(C.rowIndex,C.field,d),O(t,C.rowIndex,C.colIndex)}function yo(t){z.rangeElement&&(z.rangeElement.remove(),z.rangeElement=null);const e=t.shadow.querySelector(".wg");e==null||e.classList.remove("wg--filling"),document.removeEventListener("mousemove",bi),document.removeEventListener("mouseup",vi),document.removeEventListener("keydown",yi),z={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:z.handleElement,rangeElement:null},ke=null}function Oe(t,e,o,i){var s;V(t);const r=document.createElement("div");if(r.className="wg__dropdown",r.style.cssText=`
519
519
  position: absolute;
520
520
  top: 0;
521
521
  left: 0;
522
522
  max-height: 200px;
523
523
  overflow-y: auto;
524
524
  z-index: var(--wg-z-dropdown);
525
- `,o.length===0){const n=e.isSearching?i.searchingText||e.grid.labels.dropdownSearching:i.noOptionsText||e.grid.labels.dropdownNoOptions;r.innerHTML=`<div class="wg__dropdown-empty">${e.escapeHtml(n)}</div>`}else{const n=e.grid.editingCell,l=n?(s=e.grid.displayItems[n.rowIndex])==null?void 0:s[n.field]:void 0,a=e.getCurrentEditingColumn(),d=(a==null?void 0:a.horizontalAlign)||"left";r.innerHTML=o.map((c,u)=>{const g=u===e.highlightedIndex,h=Ae(c,i)===l,f=de(c,i);if(i.renderOptionCallback){const C={index:u,isHighlighted:g,isSelected:h,isDisabled:f};return i.renderOptionCallback(c,C)}const w=Be(c,i),p=Yn(c,i),m=Un(c,i),v=["wg__dropdown-option",`wg__dropdown-option--align-${d}`];g&&v.push("wg__dropdown-option--highlighted"),h&&v.push("wg__dropdown-option--selected"),f&&v.push("wg__dropdown-option--disabled");const y=p?`<span class="wg__dropdown-option-icon">${e.escapeHtml(p)}</span>`:"",x=m?`<span class="wg__dropdown-option-subtitle">${e.escapeHtml(m)}</span>`:"";return`<div class="${v.join(" ")}" data-index="${u}" ${f?'data-disabled="true"':""}>
525
+ `,o.length===0){const n=t.isSearching?i.searchingText||t.grid.labels.dropdownSearching:i.noOptionsText||t.grid.labels.dropdownNoOptions;r.innerHTML=`<div class="wg__dropdown-empty">${t.escapeHtml(n)}</div>`}else{const n=t.grid.editingCell,l=n?(s=t.grid.displayItems[n.rowIndex])==null?void 0:s[n.field]:void 0,a=t.getCurrentEditingColumn(),d=(a==null?void 0:a.horizontalAlign)||"left";r.innerHTML=o.map((c,u)=>{const h=u===t.highlightedIndex,g=ze(c,i)===l,f=de(c,i);if(i.renderOptionCallback){const S={index:u,isHighlighted:h,isSelected:g,isDisabled:f};return i.renderOptionCallback(c,S)}const w=Ue(c,i),p=Gn(c,i),m=Qn(c,i),_=["wg__dropdown-option",`wg__dropdown-option--align-${d}`];h&&_.push("wg__dropdown-option--highlighted"),g&&_.push("wg__dropdown-option--selected"),f&&_.push("wg__dropdown-option--disabled");const y=p?`<span class="wg__dropdown-option-icon">${t.escapeHtml(p)}</span>`:"",C=m?`<span class="wg__dropdown-option-subtitle">${t.escapeHtml(m)}</span>`:"";return`<div class="${_.join(" ")}" data-index="${u}" ${f?'data-disabled="true"':""}>
526
526
  ${y}
527
527
  <div class="wg__dropdown-option-content">
528
- <span class="wg__dropdown-option-label">${e.escapeHtml(w)}</span>
529
- ${x}
528
+ <span class="wg__dropdown-option-label">${t.escapeHtml(w)}</span>
529
+ ${C}
530
530
  </div>
531
- </div>`}).join("")}return e.shadow.appendChild(r),e.dropdownOpen=!0,ke(),qe(t,r,{strategy:"absolute",placement:"bottom-start",middleware:[Rt(1),Ve({fallbackPlacements:["top-start"]}),Qr({apply({rects:n}){Object.assign(r.style,{minWidth:i.dropdownMinWidth||`${n.reference.width}px`})}})]}).then(({x:n,y:l})=>{Object.assign(r.style,{left:`${n}px`,top:`${l}px`})}),r}function q(e){const t=e.shadow.querySelector(".wg__dropdown");t==null||t.remove(),e.dropdownOpen=!1,e.highlightedIndex=-1,e.filterText="",e.dropdownUserInteracted=!1}function wi(e,t,o=!0,i=!1){var w;const r=e.dropdownOptions[t];if(!r)return;const s=e.grid.editingCell,n=e.grid.focusedCell,l=s?{rowIndex:s.rowIndex,field:s.field,colIndex:e.grid.columns.findIndex(p=>String(p.field)===s.field)}:n?{rowIndex:n.rowIndex,field:String((w=e.grid.columns[n.colIndex])==null?void 0:w.field),colIndex:n.colIndex}:null;if(!l)return;const{rowIndex:a,field:d,colIndex:c}=l,u=e.grid.columns[c],g=(u==null?void 0:u.editorOptions)||{};if(de(r,g))return;const h=Ae(r,g),f=e.grid.displayItems[a];g.onselect&&f&&g.onselect(r,f),e.justSelected=!0,e.isCommittingFromKeyboard=!0,q(e),e.grid.commitEdit(a,d,h,i),o?e.moveFocusAfterCommit(a,d,"down"):H(e,a,c),requestAnimationFrame(()=>{e.justSelected=!1})}function fe(e){const t=e.shadow.querySelector(".wg__dropdown");if(!t)return;t.querySelectorAll(".wg__dropdown-option").forEach((i,r)=>{i.classList.toggle("wg__dropdown-option--highlighted",r===e.highlightedIndex)})}function bo(e){const t=e.shadow.querySelector(".wg__dropdown-option--highlighted");t==null||t.scrollIntoView({block:"nearest"})}function _o(e,t){const o=e.shadow.querySelector(".wg__loading-indicator");o&&(o.style.display=t?"inline":"none");const i=e.shadow.querySelector(".wg__editor--autocomplete .wg__combobox-toggle");i&&(i.style.display=t?"none":"inline")}function we(e){var u;if(e.justSelected)return;e.dropdownUserInteracted=!1;const t=e.grid.editingCell,o=e.grid.focusedCell,i=t?{rowIndex:t.rowIndex,field:t.field}:o?{rowIndex:o.rowIndex,field:String((u=e.grid.columns[o.colIndex])==null?void 0:u.field)}:null;if(!i)return;const{rowIndex:r,field:s}=i;let n=e.getCurrentEditingColumn();if(n||(n=e.grid.columns.find(g=>String(g.field)===s)||null),!n)return;const l=n.editorOptions||{},a=n.editor;let d=0;if(a==="select"){const g=l.options||[];if(e.filterText){const h=e.filterText.toLowerCase();e.dropdownOptions=g.filter(f=>Be(f,l).toLowerCase().includes(h)),d=e.dropdownOptions.length>0?0:-1}else{e.dropdownOptions=g;const h=e.grid.displayItems[r],f=h?h[s]:void 0,w=e.dropdownOptions.findIndex(p=>Ae(p,l)===f);d=w>=0?w:0}}else if(a==="combobox"||a==="autocomplete"){const g=a==="autocomplete"?l.initialOptions||l.options||[]:l.options||[],h=e.grid.displayItems[r],f=h?h[s]:void 0,w=g.findIndex(p=>Ae(p,l)===f);if(w>=0)e.dropdownOptions=g,d=w;else if(f!=null&&f!==""){const p=l.valueMember||"value",m=l.displayMember||"label",v=String(f),y={value:f,label:v,[p]:f,[m]:v};e.dropdownOptions=[y,...g],d=0}else e.dropdownOptions=g,d=g.length>0?0:-1}const c=e.shadow.querySelector(`.wg__editor--select[data-row="${r}"][data-field="${s}"],
531
+ </div>`}).join("")}return t.shadow.appendChild(r),t.dropdownOpen=!0,Re(),Be(e,r,{strategy:"absolute",placement:"bottom-start",middleware:[Rt(1),Ne({fallbackPlacements:["top-start"]}),rn({apply({rects:n}){Object.assign(r.style,{minWidth:i.dropdownMinWidth||`${n.reference.width}px`})}})]}).then(({x:n,y:l})=>{Object.assign(r.style,{left:`${n}px`,top:`${l}px`})}),r}function V(t){const e=t.shadow.querySelector(".wg__dropdown");e==null||e.remove(),t.dropdownOpen=!1,t.highlightedIndex=-1,t.filterText="",t.dropdownUserInteracted=!1}function Ci(t,e,o=!0,i=!1){var w;const r=t.dropdownOptions[e];if(!r)return;const s=t.grid.editingCell,n=t.grid.focusedCell,l=s?{rowIndex:s.rowIndex,field:s.field,colIndex:t.grid.columns.findIndex(p=>String(p.field)===s.field)}:n?{rowIndex:n.rowIndex,field:String((w=t.grid.columns[n.colIndex])==null?void 0:w.field),colIndex:n.colIndex}:null;if(!l)return;const{rowIndex:a,field:d,colIndex:c}=l,u=t.grid.columns[c],h=(u==null?void 0:u.editorOptions)||{};if(de(r,h))return;const g=ze(r,h),f=t.grid.displayItems[a];h.onselect&&f&&h.onselect(r,f),t.justSelected=!0,t.isCommittingFromKeyboard=!0,V(t),t.grid.commitEdit(a,d,g,i),o?t.moveFocusAfterCommit(a,d,"down"):O(t,a,c),requestAnimationFrame(()=>{t.justSelected=!1})}function we(t){const e=t.shadow.querySelector(".wg__dropdown");if(!e)return;e.querySelectorAll(".wg__dropdown-option").forEach((i,r)=>{i.classList.toggle("wg__dropdown-option--highlighted",r===t.highlightedIndex)})}function Co(t){const e=t.shadow.querySelector(".wg__dropdown-option--highlighted");e==null||e.scrollIntoView({block:"nearest"})}function So(t,e){const o=t.shadow.querySelector(".wg__loading-indicator");o&&(o.style.display=e?"inline":"none");const i=t.shadow.querySelector(".wg__editor--autocomplete .wg__combobox-toggle");i&&(i.style.display=e?"none":"inline")}function pe(t){var u;if(t.justSelected)return;t.dropdownUserInteracted=!1;const e=t.grid.editingCell,o=t.grid.focusedCell,i=e?{rowIndex:e.rowIndex,field:e.field}:o?{rowIndex:o.rowIndex,field:String((u=t.grid.columns[o.colIndex])==null?void 0:u.field)}:null;if(!i)return;const{rowIndex:r,field:s}=i;let n=t.getCurrentEditingColumn();if(n||(n=t.grid.columns.find(h=>String(h.field)===s)||null),!n)return;const l=n.editorOptions||{},a=n.editor;let d=0;if(a==="select"){const h=l.options||[];if(t.filterText){const g=t.filterText.toLowerCase();t.dropdownOptions=h.filter(f=>Ue(f,l).toLowerCase().includes(g)),d=t.dropdownOptions.length>0?0:-1}else{t.dropdownOptions=h;const g=t.grid.displayItems[r],f=g?g[s]:void 0,w=t.dropdownOptions.findIndex(p=>ze(p,l)===f);d=w>=0?w:0}}else if(a==="combobox"||a==="autocomplete"){const h=a==="autocomplete"?l.initialOptions||l.options||[]:l.options||[],g=t.grid.displayItems[r],f=g?g[s]:void 0,w=h.findIndex(p=>ze(p,l)===f);if(w>=0)t.dropdownOptions=h,d=w;else if(f!=null&&f!==""){const p=l.valueMember||"value",m=l.displayMember||"label",_=String(f),y={value:f,label:_,[p]:f,[m]:_};t.dropdownOptions=[y,...h],d=0}else t.dropdownOptions=h,d=h.length>0?0:-1}const c=t.shadow.querySelector(`.wg__editor--select[data-row="${r}"][data-field="${s}"],
532
532
  .wg__editor--combobox[data-row="${r}"][data-field="${s}"],
533
- .wg__editor--autocomplete[data-row="${r}"][data-field="${s}"]`);if(c&&e.dropdownOptions.length>0){const g=e.filterText;e.isOpeningDropdown=!0;const h=Le(e,c,e.dropdownOptions,l);ze(e,h),e.filterText=g,e.highlightedIndex=d,fe(e);const f=e.shadow.querySelector(`.wg__select-trigger[data-row="${r}"][data-field="${s}"]`),w=e.shadow.querySelector(`.wg__combobox-input[data-row="${r}"][data-field="${s}"],
534
- .wg__autocomplete-input[data-row="${r}"][data-field="${s}"]`),p=f||w;p&&p!==e.shadow.activeElement&&p.focus(),requestAnimationFrame(()=>{e.isOpeningDropdown=!1})}}function Ms(e){e.dropdownOpen?q(e):we(e)}function ze(e,t){t.addEventListener("mousedown",o=>{o.preventDefault();const i=o.target.closest(".wg__dropdown-option");if(i&&!i.hasAttribute("data-disabled")){const r=parseInt(i.getAttribute("data-index")||"0",10);wi(e,r,!1)}}),t.addEventListener("mouseover",o=>{const i=o.target.closest(".wg__dropdown-option");i&&!i.hasAttribute("data-disabled")&&(e.highlightedIndex=parseInt(i.getAttribute("data-index")||"0",10),e.dropdownUserInteracted=!0,fe(e))})}function pi(e,t){const o=t.options||[],i=e.filterText.toLowerCase(),r=e.filterText;e.dropdownOptions=o.filter(n=>Be(n,t).toLowerCase().includes(i)),e.highlightedIndex=e.dropdownOptions.length>0?0:-1;const s=e.shadow.querySelector(".wg__editor--select");if(s){const n=Le(e,s,e.dropdownOptions,t);ze(e,n),e.filterText=r,e.dropdownOptions.length>0&&(e.highlightedIndex=0,fe(e))}}function $s(e,t){const o=t.target;e.filterText=o.value,e.isUserFiltering=!0;let i=e.getCurrentEditingColumn();if(!i){const l=o.dataset.field;l&&(i=e.grid.columns.find(a=>String(a.field)===l)||null)}if(!i)return;const r=i.editorOptions||{},s=r.options||[];if(e.filterText.trim()){const l=e.filterText.toLowerCase();e.dropdownOptions=s.filter(a=>Be(a,r).toLowerCase().includes(l))}else e.dropdownOptions=s;e.highlightedIndex=e.dropdownOptions.length>0?0:-1;const n=o.closest(".wg__editor--combobox");if(n){const l=Le(e,n,e.dropdownOptions,r);ze(e,l),e.highlightedIndex=e.dropdownOptions.length>0?0:-1,fe(e)}}function As(e,t){const o=t.target;e.filterText=o.value;let i=e.getCurrentEditingColumn();if(!i){const a=o.dataset.field;a&&(i=e.grid.columns.find(d=>String(d.field)===a)||null)}if(!i)return;const r=i.editorOptions||{},s=r.debounceMs??300,n=r.minSearchLength??1;e.searchDebounceTimer&&clearTimeout(e.searchDebounceTimer);const l=o.closest(".wg__editor--autocomplete");if(!e.dropdownOpen&&l){e.dropdownOptions=r.initialOptions||[];const a=Le(e,l,e.dropdownOptions,r);ze(e,a),e.highlightedIndex=e.dropdownOptions.length>0?0:-1,fe(e)}if(e.filterText.length<n){if(e.dropdownOptions=r.initialOptions||[],l){const a=Le(e,l,e.dropdownOptions,r);ze(e,a),e.highlightedIndex=e.dropdownOptions.length>0?0:-1,fe(e)}return}e.searchDebounceTimer=setTimeout(()=>{Ls(e,e.filterText,i)},s)}async function Ls(e,t,o){const i=o.editorOptions||{};if(!i.searchCallback){const s=i.initialOptions||i.options||[],n=t.toLowerCase();e.dropdownOptions=s.filter(a=>Be(a,i).toLowerCase().includes(n)),e.highlightedIndex=e.dropdownOptions.length>0?0:-1;const l=e.grid.editingCell;if(l){const{rowIndex:a,field:d}=l,c=e.shadow.querySelector(`.wg__editor--autocomplete[data-row="${a}"][data-field="${d}"]`);if(c){const u=Le(e,c,e.dropdownOptions,i);ze(e,u),fe(e)}}return}e.searchAbortController&&e.searchAbortController.abort(),e.searchAbortController=new AbortController;const r=e.searchAbortController.signal;e.isSearching=!0,_o(e,!0);try{const s=e.grid.editingCell;if(!s)return;const n=e.grid.displayItems[s.rowIndex],l=await i.searchCallback(t,n,r);if(!r.aborted){e.isSearching=!1,_o(e,!1),e.dropdownOptions=l;const{rowIndex:a,field:d}=s,c=e.shadow.querySelector(`.wg__editor--autocomplete[data-row="${a}"][data-field="${d}"]`);if(c){const u=Le(e,c,e.dropdownOptions,i);ze(e,u),e.highlightedIndex=l.length>0?0:-1,fe(e)}}}catch(s){if(s instanceof Error&&s.name==="AbortError")return;console.error("Autocomplete search failed:",s),e.isSearching=!1,_o(e,!1),e.dropdownOptions=[];const n=e.grid.editingCell;if(n){const{rowIndex:l,field:a}=n,d=e.shadow.querySelector(`.wg__editor--autocomplete[data-row="${l}"][data-field="${a}"]`);if(d){const c=Le(e,d,e.dropdownOptions,i);ze(e,c)}}}}function vo(e,t,o,i,r){const s=i??e.tooltipShowDelay;e.tooltipHideTimer&&(clearTimeout(e.tooltipHideTimer),e.tooltipHideTimer=null),!(e.tooltipElement&&e.tooltipAnchor===t)&&(e.tooltipShowTimer&&clearTimeout(e.tooltipShowTimer),e.tooltipShowTimer=setTimeout(()=>{zs(e,t,o,r)},s))}function zt(e,t){const o=t??e.tooltipHideDelay;e.tooltipShowTimer&&(clearTimeout(e.tooltipShowTimer),e.tooltipShowTimer=null),e.tooltipElement&&(e.tooltipHideTimer=setTimeout(()=>{e.tooltipElement&&(e.tooltipElement.classList.remove("wg__tooltip--visible"),setTimeout(()=>{var i;(i=e.tooltipElement)==null||i.remove(),e.tooltipElement=null,e.tooltipArrowElement=null,e.tooltipAnchor=null},100))},o))}function zs(e,t,o,i){var l;(l=e.tooltipElement)==null||l.remove();const r=document.createElement("div");r.className="wg__tooltip";const s=document.createElement("div");s.className="wg__tooltip-content",i?s.innerHTML=o:s.textContent=o,r.appendChild(s);const n=document.createElement("div");n.className="wg__tooltip-arrow",r.appendChild(n),e.shadow.appendChild(r),e.tooltipElement=r,e.tooltipArrowElement=n,e.tooltipAnchor=t,qe(t,r,{strategy:"absolute",placement:"top",middleware:[Rt(8),Ve({fallbackPlacements:["bottom","left","right"]}),Jr({element:n})]}).then(({x:a,y:d,placement:c,middlewareData:u})=>{if(r.style.left=`${a}px`,r.style.top=`${d}px`,r.setAttribute("data-placement",c),u.arrow){const{x:g,y:h}=u.arrow;g!=null&&(n.style.left=`${g}px`),h!=null&&(n.style.top=`${h}px`)}requestAnimationFrame(()=>{r.classList.add("wg__tooltip--visible")})})}const Ps=`
533
+ .wg__editor--autocomplete[data-row="${r}"][data-field="${s}"]`);if(c&&t.dropdownOptions.length>0){const h=t.filterText;t.isOpeningDropdown=!0;const g=Oe(t,c,t.dropdownOptions,l);He(t,g),t.filterText=h,t.highlightedIndex=d,we(t);const f=t.shadow.querySelector(`.wg__select-trigger[data-row="${r}"][data-field="${s}"]`),w=t.shadow.querySelector(`.wg__combobox-input[data-row="${r}"][data-field="${s}"],
534
+ .wg__autocomplete-input[data-row="${r}"][data-field="${s}"]`),p=f||w;p&&p!==t.shadow.activeElement&&p.focus(),requestAnimationFrame(()=>{t.isOpeningDropdown=!1})}}function Ls(t){t.dropdownOpen?V(t):pe(t)}function He(t,e){e.addEventListener("mousedown",o=>{o.preventDefault();const i=o.target.closest(".wg__dropdown-option");if(i&&!i.hasAttribute("data-disabled")){const r=parseInt(i.getAttribute("data-index")||"0",10);Ci(t,r,!1)}}),e.addEventListener("mouseover",o=>{const i=o.target.closest(".wg__dropdown-option");i&&!i.hasAttribute("data-disabled")&&(t.highlightedIndex=parseInt(i.getAttribute("data-index")||"0",10),t.dropdownUserInteracted=!0,we(t))})}function Si(t,e){const o=e.options||[],i=t.filterText.toLowerCase(),r=t.filterText;t.dropdownOptions=o.filter(n=>Ue(n,e).toLowerCase().includes(i)),t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const s=t.shadow.querySelector(".wg__editor--select");if(s){const n=Oe(t,s,t.dropdownOptions,e);He(t,n),t.filterText=r,t.dropdownOptions.length>0&&(t.highlightedIndex=0,we(t))}}function zs(t,e){const o=e.target;t.filterText=o.value,t.isUserFiltering=!0;let i=t.getCurrentEditingColumn();if(!i){const l=o.dataset.field;l&&(i=t.grid.columns.find(a=>String(a.field)===l)||null)}if(!i)return;const r=i.editorOptions||{},s=r.options||[];if(t.filterText.trim()){const l=t.filterText.toLowerCase();t.dropdownOptions=s.filter(a=>Ue(a,r).toLowerCase().includes(l))}else t.dropdownOptions=s;t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const n=o.closest(".wg__editor--combobox");if(n){const l=Oe(t,n,t.dropdownOptions,r);He(t,l),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,we(t)}}function Os(t,e){const o=e.target,i=o.value;t.filterText=i;let r=t.getCurrentEditingColumn();if(!r){const d=o.dataset.field;d&&(r=t.grid.columns.find(c=>String(c.field)===d)||null)}if(!r)return;const s=r.editorOptions||{},n=s.debounceMs??300,l=s.minSearchLength??1;t.searchDebounceTimer&&clearTimeout(t.searchDebounceTimer);const a=o.closest(".wg__editor--autocomplete");if(!t.dropdownOpen&&a){t.dropdownOptions=s.initialOptions||[];const d=Oe(t,a,t.dropdownOptions,s);He(t,d),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,we(t),t.filterText=i}if(i.length<l){if(t.dropdownOptions=s.initialOptions||[],a){const d=Oe(t,a,t.dropdownOptions,s);He(t,d),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,we(t)}return}t.searchDebounceTimer=setTimeout(()=>{Hs(t,i,r)},n)}async function Hs(t,e,o){const i=o.editorOptions||{};if(!i.searchCallback){const s=i.initialOptions||i.options||[],n=e.toLowerCase();t.dropdownOptions=s.filter(a=>Ue(a,i).toLowerCase().includes(n)),t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const l=t.grid.editingCell;if(l){const{rowIndex:a,field:d}=l,c=t.shadow.querySelector(`.wg__editor--autocomplete[data-row="${a}"][data-field="${d}"]`);if(c){const u=Oe(t,c,t.dropdownOptions,i);He(t,u),we(t)}}return}t.searchAbortController&&t.searchAbortController.abort(),t.searchAbortController=new AbortController;const r=t.searchAbortController.signal;t.isSearching=!0,So(t,!0);try{const s=t.grid.editingCell;if(!s)return;const n=t.grid.displayItems[s.rowIndex],l=await i.searchCallback(e,n,r);if(!r.aborted){t.isSearching=!1,So(t,!1),t.dropdownOptions=l;const{rowIndex:a,field:d}=s,c=t.shadow.querySelector(`.wg__editor--autocomplete[data-row="${a}"][data-field="${d}"]`);if(c){const u=Oe(t,c,t.dropdownOptions,i);He(t,u),t.highlightedIndex=l.length>0?0:-1,we(t)}}}catch(s){if(s instanceof Error&&s.name==="AbortError")return;console.error("Autocomplete search failed:",s),t.isSearching=!1,So(t,!1),t.dropdownOptions=[];const n=t.grid.editingCell;if(n){const{rowIndex:l,field:a}=n,d=t.shadow.querySelector(`.wg__editor--autocomplete[data-row="${l}"][data-field="${a}"]`);if(d){const c=Oe(t,d,t.dropdownOptions,i);He(t,c)}}}}function xo(t,e,o,i,r){const s=i??t.tooltipShowDelay;t.tooltipHideTimer&&(clearTimeout(t.tooltipHideTimer),t.tooltipHideTimer=null),!(t.tooltipElement&&t.tooltipAnchor===e)&&(t.tooltipShowTimer&&clearTimeout(t.tooltipShowTimer),t.tooltipShowTimer=setTimeout(()=>{Fs(t,e,o,r)},s))}function Ft(t,e){const o=e??t.tooltipHideDelay;t.tooltipShowTimer&&(clearTimeout(t.tooltipShowTimer),t.tooltipShowTimer=null),t.tooltipElement&&(t.tooltipHideTimer=setTimeout(()=>{t.tooltipElement&&(t.tooltipElement.classList.remove("wg__tooltip--visible"),setTimeout(()=>{var i;(i=t.tooltipElement)==null||i.remove(),t.tooltipElement=null,t.tooltipArrowElement=null,t.tooltipAnchor=null},100))},o))}function Fs(t,e,o,i){var l;(l=t.tooltipElement)==null||l.remove();const r=document.createElement("div");r.className="wg__tooltip";const s=document.createElement("div");s.className="wg__tooltip-content",i?s.innerHTML=o:s.textContent=o,r.appendChild(s);const n=document.createElement("div");n.className="wg__tooltip-arrow",r.appendChild(n),t.shadow.appendChild(r),t.tooltipElement=r,t.tooltipArrowElement=n,t.tooltipAnchor=e,Be(e,r,{strategy:"absolute",placement:"top",middleware:[Rt(8),Ne({fallbackPlacements:["bottom","left","right"]}),nn({element:n})]}).then(({x:a,y:d,placement:c,middlewareData:u})=>{if(r.style.left=`${a}px`,r.style.top=`${d}px`,r.setAttribute("data-placement",c),u.arrow){const{x:h,y:g}=u.arrow;h!=null&&(n.style.left=`${h}px`),g!=null&&(n.style.top=`${g}px`)}requestAnimationFrame(()=>{r.classList.add("wg__tooltip--visible")})})}function qs(t,e){return t.map(o=>{if(typeof o=="string")return xi(o,e);if(o.type){const i=xi(o.type,e);return{...i,...o,onclick:o.onclick??i.onclick,label:o.label??i.label,icon:o.icon??i.icon,visible:o.visible??i.visible}}return o})}function xi(t,e){switch(t){case"expand-all":return{id:"expand-all",type:t,label:"Expand all",icon:"▾",visible:o=>{const i=e.getRowTreeInfo(o.row);return!!(i!=null&&i.hasChildren)},onclick:o=>{const i=e.getRowTreeInfo(o.row);i&&e.expandSubtree(i.path)}};case"collapse-all":return{id:"collapse-all",type:t,label:"Collapse all",icon:"▸",visible:o=>{const i=e.getRowTreeInfo(o.row);return!!(i!=null&&i.hasChildren)},onclick:o=>{const i=e.getRowTreeInfo(o.row);i&&e.collapseSubtree(i.path)}};case"expand-tree":return{id:"expand-tree",type:t,label:"Expand entire tree",icon:"⤓",visible:()=>e.isTreeMode,onclick:()=>e.expandAll()};case"collapse-tree":return{id:"collapse-tree",type:t,label:"Collapse entire tree",icon:"⤒",visible:()=>e.isTreeMode&&e.expandedPaths.size>0,onclick:()=>e.collapseAll()}}}const Vs=`
535
535
  .wg-context-menu-container {
536
536
  position: fixed;
537
537
  z-index: var(--wg-cm-z-index, 10000);
@@ -653,14 +653,14 @@ toolbarColumn takes priority — cursor following is disabled.`,r)}requestUpdate
653
653
  .wg-context-menu__item--toggle.wg-context-menu__item--checked .wg-context-menu__icon {
654
654
  opacity: 1;
655
655
  }
656
- `;let mi=!1;function bi(){if(mi)return;const e=document.createElement("style");e.id="wg-context-menu-styles",e.textContent=Ps,document.head.appendChild(e),mi=!0}function Os(e,t){const o=e.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(t):r.visible);return o.length===0?"":`<div class="wg-context-menu">${o.map((r,s)=>{const n=typeof r.label=="function"?r.label(t):r.label,l=typeof r.icon=="function"?r.icon(t):r.icon,a=r.shortcut,d=typeof r.disabled=="function"?r.disabled(t):r.disabled,c=r.danger===!0,u=["wg-context-menu__item",d?"wg-context-menu__item--disabled":"",c?"wg-context-menu__item--danger":""].filter(Boolean).join(" "),g=r.dividerBefore&&s>0?'<div class="wg-context-menu__divider"></div>':"",h=l?`<span class="wg-context-menu__icon">${l}</span>`:"",f=a?`<span class="wg-context-menu__shortcut">${a}</span>`:"";return`${g}<div class="${u}" data-item-id="${r.id}" data-disabled="${d?"true":"false"}" data-shortcut="${a||""}">${h}<span class="wg-context-menu__label">${n}</span>${f}</div>`}).join("")}</div>`}function Hs(e,t,o,i,r,s,n,l,a){bi();const d=Os(s,n);if(!d)return null;const c=document.createElement("div");c.className="wg-context-menu-container",c.innerHTML=d,document.body.appendChild(c);const u=c.querySelector(".wg-context-menu");qe({getBoundingClientRect:()=>({width:0,height:0,x:t,y:o,top:o,left:t,right:t,bottom:o})},u,{placement:"bottom-start",strategy:"fixed",middleware:[Rt({mainAxis:r,alignmentAxis:i}),Ve({fallbackPlacements:["top-start","bottom-end","top-end"]}),rt({padding:8})]}).then(({x:v,y})=>{Object.assign(u.style,{left:`${v}px`,top:`${y}px`})}),c.addEventListener("click",v=>{const y=v.target.closest(".wg-context-menu__item");if(y&&y.dataset.disabled!=="true"){const x=y.dataset.itemId||"";l(x)}});const h=e.scrollEvents.subscribe("window",()=>{w(),a()}),f=e.scrollEvents.subscribe("container",()=>{w(),a()}),w=()=>{h.unsubscribe(),f.unsubscribe(),document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m),c.remove()},p=v=>{c.contains(v.target)||(w(),a())},m=v=>{if(v.key==="Escape"){v.preventDefault(),w(),a();return}const y=v.key.toLowerCase(),x=c.querySelectorAll(".wg-context-menu__item");for(const C of x){const _=C.dataset.shortcut;if(C.dataset.disabled==="true"||!_)continue;if(_.toLowerCase()===y||_===v.key){v.preventDefault();const E=C.dataset.itemId||"";l(E),w(),a();return}}};return setTimeout(()=>{document.addEventListener("mousedown",p),document.addEventListener("keydown",m)},0),c._cleanup=w,c}function ce(e,t,o){const i=e._cleanup;if(typeof i=="function"){i();return}e.remove()}const Fs={sortAsc:{icon:"↑",labelKey:"sortAsc"},sortDesc:{icon:"↓",labelKey:"sortDesc"},clearSort:{icon:"✕",labelKey:"clearSort"},hideColumn:{icon:"👁",labelKey:"hideColumn"},freezeColumn:{icon:"❄",labelKey:"freezeColumn"},unfreezeColumn:{icon:"☀",labelKey:"unfreezeColumn"},columnVisibility:{icon:"👁",labelKey:"columnVisibility",hasSubmenu:!0}};function _i(e,t){const o=[];let i=!1;for(let r=0;r<e.length;r++){const s=e[r];if(typeof s=="string"){const n=Fs[s];if(!n){console.warn(`Unknown predefined header menu action: ${s}`);continue}let l=!0;s==="sortAsc"||s==="sortDesc"?l=d=>d.column.isSortable!==!1:s==="clearSort"?l=d=>d.sortDirection!==null:s==="freezeColumn"?l=d=>!d.isFrozen:s==="unfreezeColumn"&&(l=d=>d.isFrozen);let a;s==="columnVisibility"&&(a=d=>{const u=[{id:"show-all-columns",icon:d.allColumns.every(g=>!g.isHidden)?"☑":"☐",label:d.labels.contextMenu.showAll,onclick:()=>{d.allColumns.forEach(g=>{g.isHidden=!1})}}];return d.allColumns.forEach(g=>{u.push({id:`toggle-col-${String(g.field)}`,icon:g.isHidden?"☐":"☑",label:g.title||String(g.field),onclick:()=>{g.isHidden=!g.isHidden}})}),u}),o.push({id:s,icon:n.icon,label:t.labels.contextMenu[n.labelKey],danger:n.danger,visible:l,dividerBefore:i,submenu:a}),i=!1}else s.dividerBefore&&!s.id&&!s.label?i=!0:(o.push({id:s.id||`header-menu-item-${r}`,...s,dividerBefore:i||s.dividerBefore}),i=!1)}return o}function vi(e,t,o,i=!1){var v,y;const r=typeof e.label=="function"?e.label(t):e.label,s=typeof e.icon=="function"?e.icon(t):e.icon,n=e.shortcut,l=typeof e.disabled=="function"?e.disabled(t):e.disabled,a=e.danger===!0,d=((v=e.children)==null?void 0:v.length)||e.submenu,c=e.children||(e.submenu?e.submenu(t):[]);let u="";d&&c.length>0&&(u=`<div class="wg-context-menu wg-context-menu--submenu">${c.map((C,_)=>vi(C,t,_,!0)).join("")}</div>`);const g=i&&((y=e.id)==null?void 0:y.startsWith("toggle-col-")),f=["wg-context-menu__item",l?"wg-context-menu__item--disabled":"",a?"wg-context-menu__item--danger":"",d?"wg-context-menu__item--has-submenu":"",g?"wg-context-menu__item--toggle":"",g&&s==="☑"?"wg-context-menu__item--checked":""].filter(Boolean).join(" "),w=e.dividerBefore&&o>0?'<div class="wg-context-menu__divider"></div>':"",p=s?`<span class="wg-context-menu__icon">${s}</span>`:"",m=n?`<span class="wg-context-menu__shortcut">${n}</span>`:"";return`${w}<div class="${f}" data-item-id="${e.id}" data-disabled="${l?"true":"false"}" data-shortcut="${n||""}">${p}<span class="wg-context-menu__label">${r}</span>${m}${u}</div>`}function yi(e,t){const o=e.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(t):r.visible);return o.length===0?"":`<div class="wg-context-menu">${o.map((r,s)=>vi(r,t,s)).join("")}</div>`}function Vs(e,t,o,i=!1){const{field:r,columnIndex:s}=o;switch(t){case"sortAsc":case"sortDesc":{const n=t==="sortAsc"?"asc":"desc",l=[...e.grid.sort];if(i&&e.grid.sortMode==="multi"){const a=l.findIndex(d=>d.column===r);a>=0?l[a]={column:r,direction:n}:l.push({column:r,direction:n}),e.grid.sort=l}else e.grid.sort=[{column:r,direction:n}];break}case"clearSort":e.grid.sort=e.grid.sort.filter(n=>n.column!==r);break;case"hideColumn":{const n=e.grid.columns.find(l=>String(l.field)===r);n&&(n.isHidden=!0,e.grid.columns=[...e.grid.columns]);break}case"freezeColumn":e.grid.freezeColumns=s+1;break;case"unfreezeColumn":e.grid.freezeColumns=Math.max(0,s);break}}function Ci(e,t){t.style.display="block",qe(e,t,{placement:"right-start",strategy:"fixed",middleware:[Ve({fallbackPlacements:["left-start","right-end","left-end"]}),rt({padding:8})]}).then(({x:o,y:i})=>{t.style.left=`${o}px`,t.style.top=`${i}px`})}function Si(e){e.querySelectorAll(".wg-context-menu__item--has-submenu").forEach(o=>{const i=o,r=i.querySelector(":scope > .wg-context-menu--submenu");if(!r)return;let s=null;const n=()=>{s!==null&&(clearTimeout(s),s=null)},l=()=>{s=window.setTimeout(()=>{r.style.display="none",s=null},150)};i.addEventListener("mouseenter",()=>{n(),Ci(i,r)}),i.addEventListener("mouseleave",l),r.addEventListener("mouseenter",n),r.addEventListener("mouseleave",l)})}function xi(e,t,o,i,r,s,n){bi();const l=yi(i,r);if(!l)return null;const a=document.createElement("div");a.className="wg-context-menu-container",a.innerHTML=l,document.body.appendChild(a);let d=a.querySelector(".wg-context-menu");Si(d),qe({getBoundingClientRect:()=>({width:0,height:0,x:t,y:o,top:o,left:t,right:t,bottom:o})},d,{placement:"bottom-start",strategy:"fixed",middleware:[Ve({fallbackPlacements:["top-start","bottom-end","top-end"]}),rt({padding:8})]}).then(({x:p,y:m})=>{Object.assign(d.style,{left:`${p}px`,top:`${m}px`})}),a.addEventListener("click",p=>{const m=p.target.closest(".wg-context-menu__item");if(!m||m.dataset.disabled==="true")return;const v=m.dataset.itemId||"",y=p.ctrlKey;if(!m.classList.contains("wg-context-menu__item--has-submenu")){if(v.startsWith("toggle-col-")||v==="show-all-columns"){s(v,!0,y);const x=yi(i,r),C=document.createElement("div");C.innerHTML=x;const _=C.querySelector(".wg-context-menu");if(_&&d.parentNode){_.style.left=d.style.left,_.style.top=d.style.top,d.parentNode.replaceChild(_,d),d=_,Si(_);const S=_.querySelector(".wg-context-menu__item--has-submenu"),k=S==null?void 0:S.querySelector(":scope > .wg-context-menu--submenu");S&&k&&Ci(S,k)}return}s(v,!1,y)}});const u=e.scrollEvents.subscribe("window",()=>{h(),n()}),g=e.scrollEvents.subscribe("container",()=>{h(),n()}),h=()=>{u.unsubscribe(),g.unsubscribe(),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",w),a.remove()},f=p=>{a.contains(p.target)||(h(),n())},w=p=>{if(p.key==="Escape"){p.preventDefault(),h(),n();return}const m=p.key.toLowerCase(),v=a.querySelectorAll(".wg-context-menu__item");for(const y of v){const x=y.dataset.shortcut;if(y.dataset.disabled==="true"||!x)continue;if(x.toLowerCase()===m||x===p.key){p.preventDefault();const S=y.dataset.itemId||"";s(S),h(),n();return}}};return setTimeout(()=>{document.addEventListener("mousedown",f),document.addEventListener("keydown",w)},0),a._cleanup=h,a}function wt(e){const t=e.split("+").map(i=>i.trim()),o={key:"",ctrl:!1,shift:!1,alt:!1,meta:!1};for(const i of t){const r=i.toLowerCase();r==="ctrl"||r==="control"?o.ctrl=!0:r==="shift"?o.shift=!0:r==="alt"?o.alt=!0:r==="meta"||r==="cmd"||r==="command"?o.meta=!0:o.key=i}return o}function pt(e,t){if(t.ctrl!==e.ctrlKey||t.shift!==e.shiftKey||t.alt!==e.altKey||t.meta!==e.metaKey)return!1;const o=e.key.toLowerCase(),i=t.key.toLowerCase();return o===i}function qs(e){return e.split("+").map(t=>{const o=t.trim();return["ctrl","control","shift","alt","meta","cmd","command"].includes(o.toLowerCase())?o.charAt(0).toUpperCase()+o.slice(1).toLowerCase():o}).join("+")}function Ns(e){const{scrollTop:t,viewportHeight:o,rowHeight:i,buffer:r,totalItems:s,editingRowIndex:n}=e;let l=Math.max(0,Math.floor(t/i)-r);const a=Math.ceil(o/i)+r*2;let d=Math.min(s,l+a);return n!==void 0&&(n<l&&(l=n),n>=d&&(d=n+1)),{startIndex:l,endIndex:d}}function Bs(e){const{targetRow:t,rowHeight:o,buffer:i,totalItems:r,viewportHeight:s,scrollHeight:n,clientHeight:l}=e,a=Math.max(0,(t-1)*o),d=Math.max(0,n-l),c=Math.min(a,d);let u=Math.max(0,Math.floor(c/o)-i);const g=Math.ceil(s/o)+i*2;let h=Math.min(r,u+g);return t<u&&(u=t),t>=h&&(h=t+1),{scrollTop:c,startIndex:u,endIndex:h}}function Ws(e,t,o,i){return t-(e+o)<=i}function Ys(e,t,o){if(!o){const l=t.target.closest(".wg__header--sortable");if(!l||(o=l.dataset.field,!o))return}const i=[...e.grid.sort],r=i.findIndex(n=>n.column===o);(t.ctrlKey||t.metaKey)&&e.grid.sortMode==="multi"?r>=0?i[r].direction==="asc"?i[r]={column:o,direction:"desc"}:i.splice(r,1):i.push({column:o,direction:"asc"}):r>=0&&i.length===1?i[0].direction==="asc"?i[0]={column:o,direction:"desc"}:i.length=0:(i.length=0,i.push({column:o,direction:"asc"})),e.grid.sort=i,e.grid.isPageable&&(e.grid.currentPage=1),e.grid.fireDataRequest("sort")}function Us(e,t){const i=t.target.closest(".wg__pagination-btn");if(!i||i.hasAttribute("disabled"))return!1;const r=i.dataset.action;let s=!1;return r==="first"&&e.grid.currentPage!==1?(e.grid.currentPage=1,s=!0):r==="prev"&&e.grid.currentPage>1?(e.grid.currentPage--,s=!0):r==="next"&&e.grid.currentPage<e.grid.totalPages?(e.grid.currentPage++,s=!0):r==="last"&&e.grid.currentPage!==e.grid.totalPages&&(e.grid.currentPage=e.grid.totalPages,s=!0),s&&e.grid.fireDataRequest("page"),s}function Ks(e,t){const o=parseInt(t.value,10);return o!==e.grid.pageSize?(e.grid.pageSize=o,e.grid.currentPage=1,e.grid.fireDataRequest("pageSize"),!0):!1}let Y={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},Re=null;function ki(e,t){if(!e)return t;const o=parseFloat(e);return isNaN(o)?t:o}function js(e,t,o){const i=t.target,r=i.closest(".wg__header");if(!r)return;const s=e.grid.columns.find(a=>String(a.field)===o);if(!s||s.isResizable===!1)return;const n=r.getBoundingClientRect().width;Y={isResizing:!0,startX:t.clientX,startWidth:n,field:o,headerCell:r,minWidth:ki(s.minWidth,30),maxWidth:s.maxWidth?ki(s.maxWidth,1/0):null},Re=e,s.minWidth?r.style.minWidth=s.minWidth:r.style.minWidth=`${Y.minWidth}px`;const l=e.shadow.querySelector(".wg");l==null||l.classList.add("wg--resizing"),i.classList.add("wg__resize-handle--active"),document.addEventListener("mousemove",Ri),document.addEventListener("mouseup",Ei),t.preventDefault()}function Ri(e){if(!Y.isResizing||!Re)return;const t=e.clientX-Y.startX;let o=Y.startWidth+t;o=Math.max(o,Y.minWidth),Y.maxWidth!==null&&(o=Math.min(o,Y.maxWidth)),Y.headerCell&&(Y.headerCell.style.width=`${o}px`,Y.headerCell.style.maxWidth=`${o}px`),Xs(Re,Y.field,`${o}px`),(Re.grid.freezeColumns>0||Re.grid.isStickyRowNumbers)&&Qs(Re)}function Ei(e){if(!Y.isResizing||!Re)return;const t=Re,o=Y.field,i=`${Y.startWidth}px`,r=e.clientX-Y.startX;let s=Y.startWidth+r;s=Math.max(s,Y.minWidth),Y.maxWidth!==null&&(s=Math.min(s,Y.maxWidth));const n=`${s}px`;t.grid.setColumnWidth(o,n,!0);const l=t.shadow.querySelector(`col[data-field="${o}"]`);l&&(l.style.width=n);const a=t.shadow.querySelector(".wg");a==null||a.classList.remove("wg--resizing");const d=t.shadow.querySelector(".wg__resize-handle--active");d==null||d.classList.remove("wg__resize-handle--active"),t.grid.oncolumnresize&&t.grid.oncolumnresize({field:o,oldWidth:i,newWidth:n,allWidths:t.grid.getColumnWidthsState()}),t.grid.shouldPersistColumnWidths&&t.grid.gridName&&t.grid.savePersistedWidths(),document.removeEventListener("mousemove",Ri),document.removeEventListener("mouseup",Ei),Y={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},Re=null}function Xs(e,t,o){e.shadow.querySelectorAll(`td[data-field="${t}"]`).forEach(r=>{r.style.width=o,r.style.maxWidth=o})}const Gs=40;function Qs(e){const t=e.grid.freezeColumns;let i=e.grid.isRowNumbersVisible&&e.grid.isStickyRowNumbers?Gs:0;const r=e.grid.visualColumns;for(let s=0;s<t&&s<r.length;s++){const{column:n}=r[s],l=String(n.field),a=e.shadow.querySelector(`th[data-field="${l}"]`);a&&(a.style.left=`${i}px`,e.shadow.querySelectorAll(`td[data-field="${l}"]`).forEach(c=>{c.style.left=`${i}px`}),i+=a.getBoundingClientRect().width)}}const Js=5;let O={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},Ee=null,Pt=!1;function Ii(){return Pt?(Pt=!1,!0):O.isReordering}function Zs(e,t,o){var c;const i=t.target,r=i.closest(".wg__header");if(!r||i.classList.contains("wg__resize-handle"))return;const s=e.grid.visualColumns,n=e.grid.totalFrozenColumns,l=s.findIndex(u=>String(u.column.field)===o);if(l<n)return;const a=(c=s[l])==null?void 0:c.column;if((a==null?void 0:a.isMovable)===!1)return;const d=l-n;O={isPending:!0,isReordering:!1,field:o,startX:t.clientX,startY:t.clientY,headerCell:r,ghost:null,dropIndicator:null,fromIndex:d,currentDropIndex:d},Ee=e,document.addEventListener("mousemove",Di),document.addEventListener("mouseup",Ti),t.preventDefault()}function el(e,t,o){var r;const i=document.createElement("div");i.className="wg__reorder-ghost",i.textContent=((r=t.querySelector(".wg__header-title"))==null?void 0:r.textContent)||"",i.style.left=`${o.clientX+10}px`,i.style.top=`${o.clientY-10}px`,e.shadow.appendChild(i),O.ghost=i}function tl(e){var o;const t=document.createElement("div");t.className="wg__drop-indicator",(o=e.shadow.querySelector(".wg"))==null||o.appendChild(t),O.dropIndicator=t}function ol(e,t){O.isPending=!1,O.isReordering=!0;const o=e.shadow.querySelector(".wg");o==null||o.classList.add("wg--reordering"),O.headerCell&&O.headerCell.classList.add("wg__header--dragging"),O.headerCell&&el(e,O.headerCell,t),tl(e)}function Di(e){if(!Ee)return;if(O.isPending){const i=e.clientX-O.startX,r=e.clientY-O.startY;Math.sqrt(i*i+r*r)>=Js&&ol(Ee,e);return}if(!O.isReordering||!Ee.shadow.querySelector(".wg"))return;O.ghost&&(O.ghost.style.left=`${e.clientX+10}px`,O.ghost.style.top=`${e.clientY-10}px`);const o=rl(Ee,e.clientX);o!==O.currentDropIndex&&(O.currentDropIndex=o,nl(Ee,o))}function il(e){const t=e.grid.visualColumns,o=e.grid.totalFrozenColumns,i=t.slice(o);let r=0;for(let s=0;s<i.length;s++)i[s].column.isMovable===!1&&(r=s+1);return r}function rl(e,t){const o=e.grid.visualColumns,i=e.grid.totalFrozenColumns,r=o.slice(i);if(r.length===0)return 0;const s=il(e),n=String(r[0].column.field),l=e.shadow.querySelector(`th[data-field="${n}"]`);if(l){const a=l.getBoundingClientRect();if(t<a.left)return s}for(let a=0;a<r.length;a++){const d=String(r[a].column.field),c=e.shadow.querySelector(`th[data-field="${d}"]`);if(c){const u=c.getBoundingClientRect(),g=u.left+u.width/2;if(t<g)return Math.max(a,s)}}return r.length}function nl(e,t){const o=O.dropIndicator;if(!o)return;const i=e.grid.visualColumns,r=e.grid.totalFrozenColumns,s=i.slice(r),n=e.shadow.querySelector(".wg"),l=n==null?void 0:n.getBoundingClientRect();if(!l||!n)return;let a;if(t>=s.length){const u=String(s[s.length-1].column.field),g=e.shadow.querySelector(`th[data-field="${u}"]`);if(g)a=g.getBoundingClientRect().right-l.left+n.scrollLeft;else return}else{const u=String(s[t].column.field),g=e.shadow.querySelector(`th[data-field="${u}"]`);if(g)a=g.getBoundingClientRect().left-l.left+n.scrollLeft;else return}const d=n.scrollTop,c=n.clientHeight;o.style.left=`${a}px`,o.style.top=`${d}px`,o.style.height=`${c}px`,o.style.display="block"}function Ti(e){if(!Ee)return;const t=Ee;if(O.isPending){Mi(t);return}if(!O.isReordering)return;const o=O.field,i=O.fromIndex,r=O.currentDropIndex;if(i!==r&&r!==i+1){const s=r>i?r-1:r;t.grid.moveColumn(o,s),t.grid.oncolumnreorder&&t.grid.oncolumnreorder({field:o,fromIndex:i,toIndex:s,allOrder:t.grid.getColumnOrderState()}),t.grid.shouldPersistColumnOrder&&t.grid.gridName&&t.grid.savePersistedState()}Pt=!0,requestAnimationFrame(()=>{Pt=!1}),Mi(t)}function Mi(e){O.ghost&&O.ghost.remove(),O.dropIndicator&&O.dropIndicator.remove();const t=e.shadow.querySelector(".wg");t==null||t.classList.remove("wg--reordering"),O.headerCell&&O.headerCell.classList.remove("wg__header--dragging"),document.removeEventListener("mousemove",Di),document.removeEventListener("mouseup",Ti),O={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},Ee=null}function sl(){const e=new Set,t=new Set;let o=null,i=!1;const r=()=>{e.forEach(n=>n())},s=()=>{t.forEach(n=>n())};return{subscribe(n,l){const a=n==="container"?e:t;return a.add(l),{unsubscribe:()=>{a.delete(l)}}},init(n){o=n,n.addEventListener("scroll",r),i||(window.addEventListener("scroll",s,{capture:!0,passive:!0}),i=!0)},destroy(){o&&(o.removeEventListener("scroll",r),o=null),i&&(window.removeEventListener("scroll",s,!0),i=!1),e.clear(),t.clear()}}}function ll(e,t){const o=new Set,i=new Set;let r=null;const s=l=>{const a=l.target,d=l.relatedTarget;o.forEach(c=>c(a,d))},n=l=>{const a=l.target,d=l.relatedTarget;i.forEach(c=>c(a,d))};return{subscribe(l,a){const d=l==="blur"?o:i;return d.add(a),{unsubscribe:()=>{d.delete(a)}}},shouldSkipBlur(){const l=e();return l.isClosingViaToggle?(t(),!0):l.isCommittingFromKeyboard||l.isTransitioningCells||l.isOpeningDropdown},init(l){r=l,l.addEventListener("blur",s,!0),l.addEventListener("focusout",n)},destroy(){r&&(r.removeEventListener("blur",s,!0),r.removeEventListener("focusout",n),r=null),o.clear(),i.clear()}}}function al(){const e={outsideClick:new Set,cellClick:new Set,rowNumberClick:new Set,headerClick:new Set,sortClick:new Set,emptyAreaClick:new Set};let t=null,o=!1,i=!1;const r=(a,d)=>{for(const c of e[a])if(c(d)===!0)return!0;return!1},s=()=>{setTimeout(()=>{i&&(i=!1)},10)},n=a=>{i=!0;const d=a,u=d.composedPath()[0]||d.target,g={target:u,event:d},h=u.closest(".wg__cell"),f=u.closest(".wg__row-number[data-row-number]"),w=u.closest(".wg__header:not(.wg__row-number-header)"),p=u.closest(".wg__sort-indicator");if(p){const m=p.closest(".wg__header--sortable");if(m){g.field=m.dataset.field,g.colIndex=parseInt(m.dataset.colIndex||"-1",10),r("sortClick",g);return}}f?(g.rowIndex=parseInt(f.dataset.rowNumber||"-1",10),r("rowNumberClick",g)):w&&!u.closest(".wg__resize-handle")?(g.field=w.dataset.field,g.colIndex=parseInt(w.dataset.colIndex||"-1",10),r("headerClick",g)):h&&!h.classList.contains("wg__row-number")?(g.rowIndex=parseInt(h.dataset.row||"-1",10),g.colIndex=parseInt(h.dataset.col||"-1",10),r("cellClick",g)):u.closest(".wg__toolbar, button, input, select, textarea")||r("emptyAreaClick",g)},l=a=>{if(!t)return;if(i){i=!1;return}const d=a,c=d.target;(d.composedPath?d.composedPath():[]).includes(t)||r("outsideClick",{target:c,event:d})};return{subscribe(a,d){return e[a].add(d),{unsubscribe:()=>{e[a].delete(d)}}},init(a,d){t=d,d.addEventListener("mousedown",n),d.addEventListener("mouseup",s),o||(document.addEventListener("click",l,!0),o=!0)},destroy(){t&&(t.removeEventListener("mousedown",n),t.removeEventListener("mouseup",s)),o&&(document.removeEventListener("click",l,!0),o=!1),t=null,i=!1,Object.values(e).forEach(a=>a.clear())}}}const dl=5;let $={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,rangeBorder:null},le=null,mt=null,Ze=null;function $i(){return $.isDragging}function yo(){return $.isPending}function Ai(e,t,o,i){var l;const r=i.shiftKey&&e.grid.cellSelectionMode==="shift";e.grid.selectedCellRange&&!r&&(e.grid.clearCellSelection(),G()),(l=e.grid.visualColumns[o])!=null&&l.column&&($={...$,isPending:!0,isDragging:!1,startRowIndex:t,startColIndex:o,startX:i.clientX,startY:i.clientY,currentRowIndex:t,currentColIndex:o},le=e,document.addEventListener("mousemove",Li),document.addEventListener("mouseup",Pi),document.addEventListener("keydown",Oi))}function cl(e,t,o){var i,r;if(G(),e.grid.lastClickedCell){const{rowIndex:s,colIndex:n}=e.grid.lastClickedCell,l=e.grid.visualColumns,a=(i=l[n])==null?void 0:i.column,d=(r=l[o])==null?void 0:r.column;if(a&&d){const c={startRowIndex:s,startColIndex:n,endRowIndex:t,endColIndex:o,startField:String(a.field),endField:String(d.field)};e.grid.clearFocusedCell(),e.grid.selectCellRange(c),Ot(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const u=e.shadow.querySelector(".wg");u==null||u.focus({preventScroll:!0})})})}}else e.grid.lastClickedCell={rowIndex:t,colIndex:o}}function Li(e){if(le){if($.isPending){const t=e.clientX-$.startX,o=e.clientY-$.startY;Math.sqrt(t*t+o*o)>=dl&&ul(le);return}$.isDragging&&(mt=e,Ze||(Ze=requestAnimationFrame(gl)))}}function gl(){if(Ze=null,!mt||!le)return;const e=mt;mt=null;const t=hl(le,e.clientX,e.clientY);if(t&&(t.rowIndex!==$.currentRowIndex||t.colIndex!==$.currentColIndex)){$.currentRowIndex=t.rowIndex,$.currentColIndex=t.colIndex;const o=Hi(le);zi(le),Fi(le,o)}}function ul(e){$.isPending=!1,$.isDragging=!0;const t=e.shadow.querySelector(".wg");t==null||t.classList.add("wg--selecting-cells");const o=e.grid.focusedCell;e.grid.clearFocusedCell(),J(e,o,null);const i=e.shadow.querySelector(".wg__cell:focus");i==null||i.blur();const r=e.grid.focusedRowIndex;if(r!==null){const s=e.shadow.querySelector(`tr[data-row-index="${r}"]`);s==null||s.classList.remove("wg__row--focused"),e.grid.clearRowFocus()}zi(e),Vi(e)}function zi(e){const{startRowIndex:t,startColIndex:o,currentRowIndex:i,currentColIndex:r}=$,s=Math.min(t,i),n=Math.max(t,i),l=Math.min(o,r),a=Math.max(o,r);e.shadow.querySelectorAll(".wg__cell--in-range").forEach(c=>c.classList.remove("wg__cell--in-range"));for(let c=s;c<=n;c++)for(let u=l;u<=a;u++){const g=e.shadow.querySelector(`[data-row="${c}"][data-col="${u}"]`);g&&g.classList.add("wg__cell--in-range")}}function Pi(e){if(!le)return;const t=le;if($.isPending){e.shiftKey&&t.grid.cellSelectionMode==="shift"&&t.grid.lastClickedCell?cl(t,$.startRowIndex,$.startColIndex):t.grid.lastClickedCell={rowIndex:$.startRowIndex,colIndex:$.startColIndex},Ht(t);return}if(!$.isDragging)return;if($.startRowIndex===$.currentRowIndex&&$.startColIndex===$.currentColIndex){t.shadow.querySelectorAll(".wg__cell--in-range").forEach(n=>n.classList.remove("wg__cell--in-range")),G();const{startRowIndex:r,startColIndex:s}=$;t.grid.setFocusedCell(r,s),J(t,null,{rowIndex:r,colIndex:s}),ut(t,r,s),Ht(t)}else fl(t),Ht(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=t.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})})}function Oi(e){if(e.key==="Escape"&&le){e.preventDefault();const t=le;if($.isDragging){t.shadow.querySelectorAll(".wg__cell--in-range").forEach(s=>s.classList.remove("wg__cell--in-range")),G();const{startRowIndex:i,startColIndex:r}=$;t.grid.setFocusedCell(i,r),J(t,null,{rowIndex:i,colIndex:r}),ut(t,i,r)}Ht(t)}}function hl(e,t,o){const i=e.shadow.elementFromPoint(t,o);if(!i)return null;const r=i.closest(".wg__cell[data-row][data-col]");if(!r)return null;const s=parseInt(r.dataset.row||"-1",10),n=parseInt(r.dataset.col||"-1",10);return s>=0&&n>=0?{rowIndex:s,colIndex:n}:null}function fl(e){var d,c;const{startRowIndex:t,startColIndex:o,currentRowIndex:i,currentColIndex:r}=$,s=e.grid.visualColumns,n=(d=s[o])==null?void 0:d.column,l=(c=s[r])==null?void 0:c.column;if(!n||!l)return;const a={startRowIndex:t,startColIndex:o,endRowIndex:i,endColIndex:r,startField:String(n.field),endField:String(l.field)};e.grid.clearFocusedCell(),e.grid.selectCellRange(a),Ot(e)}function Hi(e){const{startRowIndex:t,startColIndex:o,currentRowIndex:i,currentColIndex:r}=$,s=e.shadow.querySelector(".wg");if(!s)return null;const n=Math.min(t,i),l=Math.max(t,i),a=Math.min(o,r),d=Math.max(o,r),c=e.shadow.querySelector(`[data-row="${n}"][data-col="${a}"]`),u=e.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`);if(!c||!u)return null;const g=s.getBoundingClientRect(),h=c.getBoundingClientRect(),f=u.getBoundingClientRect(),w=s.scrollLeft,p=s.scrollTop;return{container:s,left:h.left-g.left+w-s.clientLeft,top:h.top-g.top+p-s.clientTop,width:f.right-h.left,height:f.bottom-h.top}}function Fi(e,t){if(!t){G();return}let o=$.rangeBorder;o||(o=document.createElement("div"),o.className="wg__cell-range-border",t.container.appendChild(o),$.rangeBorder=o),o.style.left=`${t.left}px`,o.style.top=`${t.top}px`,o.style.width=`${t.width}px`,o.style.height=`${t.height}px`}function Vi(e){const t=Hi(e);Fi(e,t)}function Ot(e){G();const t=e.grid.selectedCellRange;if(!t)return;const o=e.shadow.querySelector(".wg");if(!o)return;const{startRowIndex:i,endRowIndex:r,startColIndex:s,endColIndex:n}=t,l=Math.min(i,r),a=Math.max(i,r),d=Math.min(s,n),c=Math.max(s,n),u=e.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`),g=e.shadow.querySelector(`[data-row="${a}"][data-col="${c}"]`);if(!u||!g)return;const h=o.getBoundingClientRect(),f=u.getBoundingClientRect(),w=g.getBoundingClientRect(),p=o.scrollLeft,m=o.scrollTop,v=f.left-h.left+p-o.clientLeft,y=f.top-h.top+m-o.clientTop,x=w.right-f.left,C=w.bottom-f.top,_=document.createElement("div");_.className="wg__cell-range-border",_.style.left=`${v}px`,_.style.top=`${y}px`,_.style.width=`${x}px`,_.style.height=`${C}px`,o.appendChild(_),$.rangeBorder=_}function qi(e){$.rangeBorder&&(G(),$.isDragging?Vi(e):Ot(e))}function G(){$.rangeBorder&&($.rangeBorder.remove(),$.rangeBorder=null)}function Ht(e){const t=e.shadow.querySelector(".wg");t==null||t.classList.remove("wg--selecting-cells"),Ze&&(cancelAnimationFrame(Ze),Ze=null),mt=null,document.removeEventListener("mousemove",Li),document.removeEventListener("mouseup",Pi),document.removeEventListener("keydown",Oi),$={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,rangeBorder:$.rangeBorder},le=null}const wl=5;let pe={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},Pe=null;function pl(e,t,o){if(o.preventDefault(),o.stopPropagation(),di(e),e.grid.selectedCellRange&&(e.grid.clearCellSelection(),G()),e.grid.focusedCell){const{rowIndex:i,colIndex:r}=e.grid.focusedCell,s=e.shadow.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`);s==null||s.classList.remove("wg__cell--focused"),e.grid.clearFocusedCell()}if(o.ctrlKey||o.metaKey){e.grid.selectRow(t,"toggle"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=e.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}if(o.shiftKey){e.grid.selectRow(t,"range"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=e.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}pe={isPending:!0,isDragging:!1,startRowIndex:t,startX:o.clientX,startY:o.clientY,currentRowIndex:t},Pe=e,e.grid.selectRow(t,"replace"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=e.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})}),document.addEventListener("mousemove",Ni),document.addEventListener("mouseup",Bi)}function Ni(e){if(!Pe)return;if(pe.isPending){const o=e.clientX-pe.startX,i=e.clientY-pe.startY;Math.sqrt(o*o+i*i)>=wl&&ml(Pe);return}if(!pe.isDragging)return;const t=bl(Pe,e.clientY);t!==null&&t!==pe.currentRowIndex&&(pe.currentRowIndex=t,Pe.grid.selectRowRange(pe.startRowIndex,t))}function ml(e){pe.isPending=!1,pe.isDragging=!0;const t=e.shadow.querySelector(".wg");t==null||t.classList.add("wg--selecting")}function Bi(){if(!Pe)return;const e=Pe,t=e.shadow.querySelector(".wg");t==null||t.classList.remove("wg--selecting"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const o=e.shadow.querySelector(".wg");o==null||o.focus({preventScroll:!0})})}),document.removeEventListener("mousemove",Ni),document.removeEventListener("mouseup",Bi),pe={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},Pe=null}function bl(e,t){const o=e.shadow.querySelectorAll(".wg__row[data-row-index]");for(const i of o){const r=i.getBoundingClientRect();if(t>=r.top&&t<=r.bottom){const s=parseInt(i.dataset.rowIndex||"-1",10);if(s>=0)return s}}if(o.length>0){const i=o[0],r=o[o.length-1],s=i.getBoundingClientRect(),n=r.getBoundingClientRect();if(t<s.top)return parseInt(i.dataset.rowIndex||"0",10);if(t>n.bottom)return parseInt(r.dataset.rowIndex||"0",10)}return null}let Ft=[],Vt=[];function Wi(e){if(e.length===0)return[];const t=[...e].sort((s,n)=>s-n),o=[];let i=t[0],r=t[0];for(let s=1;s<t.length;s++)t[s]===r+1||(o.push({start:i,end:r}),i=t[s]),r=t[s];return o.push({start:i,end:r}),o}function Yi(e,t,o,i,r,s){const n=document.createElement("div");return n.className=s,n.style.left=`${t}px`,n.style.top=`${o}px`,n.style.width=`${i}px`,n.style.height=`${r}px`,e.appendChild(n),n}function Ui(e){et();const t=e.grid.selectedRows;if(t.length===0)return;const o=e.shadow.querySelector(".wg");if(!o)return;const i=Wi(t),r=e.grid.visualColumns;if(r.length===0)return;const s=o.getBoundingClientRect(),n=o.scrollLeft,l=o.scrollTop;for(const a of i){const d=e.shadow.querySelector(`.wg__cell[data-row="${a.start}"][data-col="0"]`),c=r.length-1,u=e.shadow.querySelector(`.wg__cell[data-row="${a.end}"][data-col="${c}"]`);if(!d||!u)continue;const g=d.getBoundingClientRect(),h=u.getBoundingClientRect(),f=g.left-s.left+n-o.clientLeft,w=g.top-s.top+l-o.clientTop,p=h.right-g.left,m=h.bottom-g.top,v=Yi(o,f,w,p,m,"wg__row-selection-border");Ft.push(v)}}function Ki(e){tt();const t=e.grid.selectedColumns;if(t.length===0)return;const o=e.shadow.querySelector(".wg");if(!o)return;const i=Wi(t),r=e.grid.displayItems,s=e.grid.visualColumns;if(r.length===0||s.length===0)return;const n=o.getBoundingClientRect(),l=o.scrollLeft,a=o.scrollTop;for(const d of i){const c=s[d.start],u=s[d.end];if(!c||!u)continue;const g=String(c.column.field),h=String(u.column.field),f=e.shadow.querySelector(`.wg__header[data-field="${g}"]`),w=r.length-1,p=e.shadow.querySelector(`.wg__cell[data-row="${w}"][data-col="${u.originalIndex}"]`);if(!f||!p)continue;const m=e.shadow.querySelector(`.wg__header[data-field="${h}"]`);if(!m)continue;const v=f.getBoundingClientRect(),y=m.getBoundingClientRect(),x=p.getBoundingClientRect(),C=v.left-n.left+l-o.clientLeft,_=v.top-n.top+a-o.clientTop,S=y.right-v.left,k=x.bottom-v.top,E=Yi(o,C,_,S,k,"wg__column-selection-border");Vt.push(E)}}function _l(e){Ft.length>0&&Ui(e),Vt.length>0&&Ki(e)}function et(){for(const e of Ft)e.remove();Ft=[]}function tt(){for(const e of Vt)e.remove();Vt=[]}function vl(){et(),tt()}const yl=5;let me={isPending:!1,isDragging:!1,startColIndex:-1,startX:0,startY:0,currentColIndex:-1},Oe=null;function Cl(e,t,o){if(o.preventDefault(),o.stopPropagation(),di(e),e.grid.selectedCellRange&&(e.grid.clearCellSelection(),G()),o.ctrlKey||o.metaKey){e.grid.selectColumn(t,"toggle"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=e.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}me={isPending:!0,isDragging:!1,startColIndex:t,startX:o.clientX,startY:o.clientY,currentColIndex:t},Oe=e,o.shiftKey?e.grid.selectColumn(t,"range"):e.grid.selectColumn(t,"replace"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=e.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})}),document.addEventListener("mousemove",ji),document.addEventListener("mouseup",Xi)}function ji(e){if(!Oe)return;if(me.isPending){const o=e.clientX-me.startX,i=e.clientY-me.startY;Math.sqrt(o*o+i*i)>=yl&&Sl(Oe);return}if(!me.isDragging)return;const t=xl(Oe,e.clientX);t!==null&&t!==me.currentColIndex&&(me.currentColIndex=t,Oe.grid.selectColumnRange(me.startColIndex,t))}function Sl(e){me.isPending=!1,me.isDragging=!0;const t=e.shadow.querySelector(".wg");t==null||t.classList.add("wg--selecting-columns")}function Xi(){if(!Oe)return;const e=Oe,t=e.shadow.querySelector(".wg");t==null||t.classList.remove("wg--selecting-columns"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const o=e.shadow.querySelector(".wg");o==null||o.focus({preventScroll:!0})})}),document.removeEventListener("mousemove",ji),document.removeEventListener("mouseup",Xi),me={isPending:!1,isDragging:!1,startColIndex:-1,startX:0,startY:0,currentColIndex:-1},Oe=null}function xl(e,t){const o=e.shadow.querySelectorAll(".wg__header:not(.wg__row-number-header):not(.wg__inline-actions-header):not(.wg__actions-column):not(.wg__filler)"),i=e.grid.visualColumns;for(const r of o){const s=r.getBoundingClientRect();if(t>=s.left&&t<=s.right){const n=r.dataset.field;if(n){const l=i.findIndex(a=>String(a.column.field)===n);if(l>=0)return l}}}if(o.length>0){const r=o[0],s=o[o.length-1],n=r.getBoundingClientRect(),l=s.getBoundingClientRect();if(t<n.left){const a=r.dataset.field;if(a){const d=i.findIndex(c=>String(c.column.field)===a);if(d>=0)return d}return 0}if(t>l.right){const a=s.dataset.field;if(a){const d=i.findIndex(c=>String(c.column.field)===a);if(d>=0)return d}return i.length-1}}return null}function kl(e){const t=[];let o=[],i="",r=!1;for(let s=0;s<e.length;s++){const n=e[s],l=e[s+1];r?n==='"'?l==='"'?(i+='"',s++):r=!1:i+=n:n==='"'?r=!0:n===" "?(o.push(i),i=""):n===`
656
+ `;let ki=!1;function Ii(){if(ki)return;const t=document.createElement("style");t.id="wg-context-menu-styles",t.textContent=Vs,document.head.appendChild(t),ki=!0}function Ns(t,e){const o=t.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(e):r.visible);return o.length===0?"":`<div class="wg-context-menu">${o.map((r,s)=>{const n=typeof r.label=="function"?r.label(e):r.label,l=typeof r.icon=="function"?r.icon(e):r.icon,a=r.shortcut,d=typeof r.disabled=="function"?r.disabled(e):r.disabled,c=r.danger===!0,u=["wg-context-menu__item",d?"wg-context-menu__item--disabled":"",c?"wg-context-menu__item--danger":""].filter(Boolean).join(" "),h=r.dividerBefore&&s>0?'<div class="wg-context-menu__divider"></div>':"",g=l?`<span class="wg-context-menu__icon">${l}</span>`:"",f=a?`<span class="wg-context-menu__shortcut">${a}</span>`:"";return`${h}<div class="${u}" data-item-id="${r.id}" data-disabled="${d?"true":"false"}" data-shortcut="${a||""}">${g}<span class="wg-context-menu__label">${n}</span>${f}</div>`}).join("")}</div>`}function Bs(t,e,o,i,r,s,n,l,a){Ii();const d=Ns(s,n);if(!d)return null;const c=document.createElement("div");c.className="wg-context-menu-container",c.innerHTML=d,document.body.appendChild(c);const u=c.querySelector(".wg-context-menu");Be({getBoundingClientRect:()=>({width:0,height:0,x:e,y:o,top:o,left:e,right:e,bottom:o})},u,{placement:"bottom-start",strategy:"fixed",middleware:[Rt({mainAxis:r,alignmentAxis:i}),Ne({fallbackPlacements:["top-start","bottom-end","top-end"]}),lt({padding:8})]}).then(({x:_,y})=>{Object.assign(u.style,{left:`${_}px`,top:`${y}px`})}),c.addEventListener("click",_=>{const y=_.target.closest(".wg-context-menu__item");if(y&&y.dataset.disabled!=="true"){const C=y.dataset.itemId||"";l(C)}});const g=t.scrollEvents.subscribe("window",()=>{w(),a()}),f=t.scrollEvents.subscribe("container",()=>{w(),a()}),w=()=>{g.unsubscribe(),f.unsubscribe(),document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m),c.remove()},p=_=>{c.contains(_.target)||(w(),a())},m=_=>{if(_.key==="Escape"){_.preventDefault(),w(),a();return}const y=_.key.toLowerCase(),C=c.querySelectorAll(".wg-context-menu__item");for(const S of C){const v=S.dataset.shortcut;if(S.dataset.disabled==="true"||!v)continue;if(v.toLowerCase()===y||v===_.key){_.preventDefault();const E=S.dataset.itemId||"";l(E),w(),a();return}}};return setTimeout(()=>{document.addEventListener("mousedown",p),document.addEventListener("keydown",m)},0),c._cleanup=w,c}function ce(t,e,o){const i=t._cleanup;if(typeof i=="function"){i();return}t.remove()}const Ws={sortAsc:{icon:"↑",labelKey:"sortAsc"},sortDesc:{icon:"↓",labelKey:"sortDesc"},clearSort:{icon:"✕",labelKey:"clearSort"},hideColumn:{icon:"👁",labelKey:"hideColumn"},freezeColumn:{icon:"❄",labelKey:"freezeColumn"},unfreezeColumn:{icon:"☀",labelKey:"unfreezeColumn"},columnVisibility:{icon:"👁",labelKey:"columnVisibility",hasSubmenu:!0}};function Ei(t,e){const o=[];let i=!1;for(let r=0;r<t.length;r++){const s=t[r];if(typeof s=="string"){const n=Ws[s];if(!n){console.warn(`Unknown predefined header menu action: ${s}`);continue}let l=!0;s==="sortAsc"||s==="sortDesc"?l=d=>d.column.isSortable!==!1:s==="clearSort"?l=d=>d.sortDirection!==null:s==="hideColumn"?l=d=>{var c;return!(d.isTreeMode&&((c=d.column)!=null&&c.isTree))}:s==="freezeColumn"?l=d=>!d.isFrozen:s==="unfreezeColumn"&&(l=d=>d.isFrozen);let a;s==="columnVisibility"&&(a=d=>{const c=d.allColumns.filter(g=>!(d.isTreeMode&&g.isTree)),h=[{id:"show-all-columns",icon:c.every(g=>!g.isHidden)?"☑":"☐",label:d.labels.contextMenu.showAll,onclick:()=>{c.forEach(g=>{g.isHidden=!1})}}];return c.forEach(g=>{h.push({id:`toggle-col-${String(g.field)}`,icon:g.isHidden?"☐":"☑",label:g.title||String(g.field),onclick:()=>{g.isHidden=!g.isHidden}})}),h}),o.push({id:s,icon:n.icon,label:e.labels.contextMenu[n.labelKey],danger:n.danger,visible:l,dividerBefore:i,submenu:a}),i=!1}else s.dividerBefore&&!s.id&&!s.label?i=!0:(o.push({id:s.id||`header-menu-item-${r}`,...s,dividerBefore:i||s.dividerBefore}),i=!1)}return o}function Ri(t,e,o,i=!1){var _,y;const r=typeof t.label=="function"?t.label(e):t.label,s=typeof t.icon=="function"?t.icon(e):t.icon,n=t.shortcut,l=typeof t.disabled=="function"?t.disabled(e):t.disabled,a=t.danger===!0,d=((_=t.children)==null?void 0:_.length)||t.submenu,c=t.children||(t.submenu?t.submenu(e):[]);let u="";d&&c.length>0&&(u=`<div class="wg-context-menu wg-context-menu--submenu">${c.map((S,v)=>Ri(S,e,v,!0)).join("")}</div>`);const h=i&&((y=t.id)==null?void 0:y.startsWith("toggle-col-")),f=["wg-context-menu__item",l?"wg-context-menu__item--disabled":"",a?"wg-context-menu__item--danger":"",d?"wg-context-menu__item--has-submenu":"",h?"wg-context-menu__item--toggle":"",h&&s==="☑"?"wg-context-menu__item--checked":""].filter(Boolean).join(" "),w=t.dividerBefore&&o>0?'<div class="wg-context-menu__divider"></div>':"",p=s?`<span class="wg-context-menu__icon">${s}</span>`:"",m=n?`<span class="wg-context-menu__shortcut">${n}</span>`:"";return`${w}<div class="${f}" data-item-id="${t.id}" data-disabled="${l?"true":"false"}" data-shortcut="${n||""}">${p}<span class="wg-context-menu__label">${r}</span>${m}${u}</div>`}function Di(t,e){const o=t.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(e):r.visible);return o.length===0?"":`<div class="wg-context-menu">${o.map((r,s)=>Ri(r,e,s)).join("")}</div>`}function Us(t,e,o,i=!1){const{field:r,columnIndex:s}=o;switch(e){case"sortAsc":case"sortDesc":{const n=e==="sortAsc"?"asc":"desc",l=[...t.grid.sort];if(i&&t.grid.sortMode==="multi"){const a=l.findIndex(d=>d.column===r);a>=0?l[a]={column:r,direction:n}:l.push({column:r,direction:n}),t.grid.sort=l}else t.grid.sort=[{column:r,direction:n}];break}case"clearSort":t.grid.sort=t.grid.sort.filter(n=>n.column!==r);break;case"hideColumn":{const n=t.grid.columns.find(l=>String(l.field)===r);n&&!(t.grid.isTreeMode&&n.isTree)&&(n.isHidden=!0,t.grid.columns=[...t.grid.columns]);break}case"freezeColumn":t.grid.freezeColumns=s+1;break;case"unfreezeColumn":t.grid.freezeColumns=Math.max(0,s);break}}function Ti(t,e){e.style.display="block",Be(t,e,{placement:"right-start",strategy:"fixed",middleware:[Ne({fallbackPlacements:["left-start","right-end","left-end"]}),lt({padding:8})]}).then(({x:o,y:i})=>{e.style.left=`${o}px`,e.style.top=`${i}px`})}function Mi(t){t.querySelectorAll(".wg-context-menu__item--has-submenu").forEach(o=>{const i=o,r=i.querySelector(":scope > .wg-context-menu--submenu");if(!r)return;let s=null;const n=()=>{s!==null&&(clearTimeout(s),s=null)},l=()=>{s=window.setTimeout(()=>{r.style.display="none",s=null},150)};i.addEventListener("mouseenter",()=>{n(),Ti(i,r)}),i.addEventListener("mouseleave",l),r.addEventListener("mouseenter",n),r.addEventListener("mouseleave",l)})}function $i(t,e,o,i,r,s,n){Ii();const l=Di(i,r);if(!l)return null;const a=document.createElement("div");a.className="wg-context-menu-container",a.innerHTML=l,document.body.appendChild(a);let d=a.querySelector(".wg-context-menu");Mi(d),Be({getBoundingClientRect:()=>({width:0,height:0,x:e,y:o,top:o,left:e,right:e,bottom:o})},d,{placement:"bottom-start",strategy:"fixed",middleware:[Ne({fallbackPlacements:["top-start","bottom-end","top-end"]}),lt({padding:8})]}).then(({x:p,y:m})=>{Object.assign(d.style,{left:`${p}px`,top:`${m}px`})}),a.addEventListener("click",p=>{const m=p.target.closest(".wg-context-menu__item");if(!m||m.dataset.disabled==="true")return;const _=m.dataset.itemId||"",y=p.ctrlKey;if(!m.classList.contains("wg-context-menu__item--has-submenu")){if(_.startsWith("toggle-col-")||_==="show-all-columns"){s(_,!0,y);const C=Di(i,r),S=document.createElement("div");S.innerHTML=C;const v=S.querySelector(".wg-context-menu");if(v&&d.parentNode){v.style.left=d.style.left,v.style.top=d.style.top,d.parentNode.replaceChild(v,d),d=v,Mi(v);const x=v.querySelector(".wg-context-menu__item--has-submenu"),k=x==null?void 0:x.querySelector(":scope > .wg-context-menu--submenu");x&&k&&Ti(x,k)}return}s(_,!1,y)}});const u=t.scrollEvents.subscribe("window",()=>{g(),n()}),h=t.scrollEvents.subscribe("container",()=>{g(),n()}),g=()=>{u.unsubscribe(),h.unsubscribe(),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",w),a.remove()},f=p=>{a.contains(p.target)||(g(),n())},w=p=>{if(p.key==="Escape"){p.preventDefault(),g(),n();return}const m=p.key.toLowerCase(),_=a.querySelectorAll(".wg-context-menu__item");for(const y of _){const C=y.dataset.shortcut;if(y.dataset.disabled==="true"||!C)continue;if(C.toLowerCase()===m||C===p.key){p.preventDefault();const x=y.dataset.itemId||"";s(x),g(),n();return}}};return setTimeout(()=>{document.addEventListener("mousedown",f),document.addEventListener("keydown",w)},0),a._cleanup=g,a}function pt(t){const e=t.split("+").map(i=>i.trim()),o={key:"",ctrl:!1,shift:!1,alt:!1,meta:!1};for(const i of e){const r=i.toLowerCase();r==="ctrl"||r==="control"?o.ctrl=!0:r==="shift"?o.shift=!0:r==="alt"?o.alt=!0:r==="meta"||r==="cmd"||r==="command"?o.meta=!0:o.key=i}return o}function mt(t,e){if(e.ctrl!==t.ctrlKey||e.shift!==t.shiftKey||e.alt!==t.altKey||e.meta!==t.metaKey)return!1;const o=t.key.toLowerCase(),i=e.key.toLowerCase();return o===i}function Ys(t){return t.split("+").map(e=>{const o=e.trim();return["ctrl","control","shift","alt","meta","cmd","command"].includes(o.toLowerCase())?o.charAt(0).toUpperCase()+o.slice(1).toLowerCase():o}).join("+")}function Ks(t){const{scrollTop:e,viewportHeight:o,rowHeight:i,buffer:r,totalItems:s,editingRowIndex:n}=t;let l=Math.max(0,Math.floor(e/i)-r);const a=Math.ceil(o/i)+r*2;let d=Math.min(s,l+a);return n!==void 0&&(n<l&&(l=n),n>=d&&(d=n+1)),{startIndex:l,endIndex:d}}function js(t){const{targetRow:e,rowHeight:o,buffer:i,totalItems:r,viewportHeight:s,scrollHeight:n,clientHeight:l}=t,a=Math.max(0,(e-1)*o),d=Math.max(0,n-l),c=Math.min(a,d);let u=Math.max(0,Math.floor(c/o)-i);const h=Math.ceil(s/o)+i*2;let g=Math.min(r,u+h);return e<u&&(u=e),e>=g&&(g=e+1),{scrollTop:c,startIndex:u,endIndex:g}}function Xs(t,e,o,i){return e-(t+o)<=i}function Gs(t,e,o){if(!o){const l=e.target.closest(".wg__header--sortable");if(!l||(o=l.dataset.field,!o))return}const i=[...t.grid.sort],r=i.findIndex(n=>n.column===o);(e.ctrlKey||e.metaKey)&&t.grid.sortMode==="multi"?r>=0?i[r].direction==="asc"?i[r]={column:o,direction:"desc"}:i.splice(r,1):i.push({column:o,direction:"asc"}):r>=0&&i.length===1?i[0].direction==="asc"?i[0]={column:o,direction:"desc"}:i.length=0:(i.length=0,i.push({column:o,direction:"asc"})),t.grid.sort=i,t.grid.isPageable&&(t.grid.currentPage=1),t.grid.fireDataRequest("sort")}function Qs(t,e){const i=e.target.closest(".wg__pagination-btn");if(!i||i.hasAttribute("disabled"))return!1;const r=i.dataset.action;let s=!1;return r==="first"&&t.grid.currentPage!==1?(t.grid.currentPage=1,s=!0):r==="prev"&&t.grid.currentPage>1?(t.grid.currentPage--,s=!0):r==="next"&&t.grid.currentPage<t.grid.totalPages?(t.grid.currentPage++,s=!0):r==="last"&&t.grid.currentPage!==t.grid.totalPages&&(t.grid.currentPage=t.grid.totalPages,s=!0),s&&t.grid.fireDataRequest("page"),s}function Js(t,e){const o=parseInt(e.value,10);return o!==t.grid.pageSize?(t.grid.pageSize=o,t.grid.currentPage=1,t.grid.fireDataRequest("pageSize"),!0):!1}let j={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},De=null;function Pi(t,e){if(!t)return e;const o=parseFloat(t);return isNaN(o)?e:o}function Zs(t,e,o){const i=e.target,r=i.closest(".wg__header");if(!r)return;const s=t.grid.columns.find(a=>String(a.field)===o);if(!s||s.isResizable===!1)return;const n=r.getBoundingClientRect().width;j={isResizing:!0,startX:e.clientX,startWidth:n,field:o,headerCell:r,minWidth:Pi(s.minWidth,30),maxWidth:s.maxWidth?Pi(s.maxWidth,1/0):null},De=t,s.minWidth?r.style.minWidth=s.minWidth:r.style.minWidth=`${j.minWidth}px`;const l=t.shadow.querySelector(".wg");l==null||l.classList.add("wg--resizing"),i.classList.add("wg__resize-handle--active"),document.addEventListener("mousemove",Ai),document.addEventListener("mouseup",Li),e.preventDefault()}function Ai(t){if(!j.isResizing||!De)return;const e=t.clientX-j.startX;let o=j.startWidth+e;o=Math.max(o,j.minWidth),j.maxWidth!==null&&(o=Math.min(o,j.maxWidth)),j.headerCell&&(j.headerCell.style.width=`${o}px`,j.headerCell.style.maxWidth=`${o}px`),el(De,j.field,`${o}px`),(De.grid.freezeColumns>0||De.grid.isStickyRowNumbers)&&ol(De)}function Li(t){if(!j.isResizing||!De)return;const e=De,o=j.field,i=`${j.startWidth}px`,r=t.clientX-j.startX;let s=j.startWidth+r;s=Math.max(s,j.minWidth),j.maxWidth!==null&&(s=Math.min(s,j.maxWidth));const n=`${s}px`;e.grid.setColumnWidth(o,n,!0);const l=e.shadow.querySelector(`col[data-field="${o}"]`);l&&(l.style.width=n);const a=e.shadow.querySelector(".wg");a==null||a.classList.remove("wg--resizing");const d=e.shadow.querySelector(".wg__resize-handle--active");d==null||d.classList.remove("wg__resize-handle--active"),e.grid.oncolumnresize&&e.grid.oncolumnresize({field:o,oldWidth:i,newWidth:n,allWidths:e.grid.getColumnWidthsState()}),e.grid.shouldPersistColumnWidths&&e.grid.gridName&&e.grid.savePersistedWidths(),document.removeEventListener("mousemove",Ai),document.removeEventListener("mouseup",Li),j={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},De=null}function el(t,e,o){t.shadow.querySelectorAll(`td[data-field="${e}"]`).forEach(r=>{r.style.width=o,r.style.maxWidth=o})}const tl=40;function ol(t){const e=t.grid.freezeColumns;let i=t.grid.isRowNumbersVisible&&t.grid.isStickyRowNumbers?tl:0;const r=t.grid.visualColumns;for(let s=0;s<e&&s<r.length;s++){const{column:n}=r[s],l=String(n.field),a=t.shadow.querySelector(`th[data-field="${l}"]`);a&&(a.style.left=`${i}px`,t.shadow.querySelectorAll(`td[data-field="${l}"]`).forEach(c=>{c.style.left=`${i}px`}),i+=a.getBoundingClientRect().width)}}const il=5;let H={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},Te=null,qt=!1;function zi(){return qt?(qt=!1,!0):H.isReordering}function rl(t,e,o){var c;const i=e.target,r=i.closest(".wg__header");if(!r||i.classList.contains("wg__resize-handle"))return;const s=t.grid.visualColumns,n=t.grid.totalFrozenColumns,l=s.findIndex(u=>String(u.column.field)===o);if(l<n)return;const a=(c=s[l])==null?void 0:c.column;if((a==null?void 0:a.isMovable)===!1)return;const d=l-n;H={isPending:!0,isReordering:!1,field:o,startX:e.clientX,startY:e.clientY,headerCell:r,ghost:null,dropIndicator:null,fromIndex:d,currentDropIndex:d},Te=t,document.addEventListener("mousemove",Oi),document.addEventListener("mouseup",Hi),e.preventDefault()}function nl(t,e,o){var r;const i=document.createElement("div");i.className="wg__reorder-ghost",i.textContent=((r=e.querySelector(".wg__header-title"))==null?void 0:r.textContent)||"",i.style.left=`${o.clientX+10}px`,i.style.top=`${o.clientY-10}px`,t.shadow.appendChild(i),H.ghost=i}function sl(t){var o;const e=document.createElement("div");e.className="wg__drop-indicator",(o=t.shadow.querySelector(".wg"))==null||o.appendChild(e),H.dropIndicator=e}function ll(t,e){H.isPending=!1,H.isReordering=!0;const o=t.shadow.querySelector(".wg");o==null||o.classList.add("wg--reordering"),H.headerCell&&H.headerCell.classList.add("wg__header--dragging"),H.headerCell&&nl(t,H.headerCell,e),sl(t)}function Oi(t){if(!Te)return;if(H.isPending){const i=t.clientX-H.startX,r=t.clientY-H.startY;Math.sqrt(i*i+r*r)>=il&&ll(Te,t);return}if(!H.isReordering||!Te.shadow.querySelector(".wg"))return;H.ghost&&(H.ghost.style.left=`${t.clientX+10}px`,H.ghost.style.top=`${t.clientY-10}px`);const o=dl(Te,t.clientX);o!==H.currentDropIndex&&(H.currentDropIndex=o,cl(Te,o))}function al(t){const e=t.grid.visualColumns,o=t.grid.totalFrozenColumns,i=e.slice(o);let r=0;for(let s=0;s<i.length;s++)i[s].column.isMovable===!1&&(r=s+1);return r}function dl(t,e){const o=t.grid.visualColumns,i=t.grid.totalFrozenColumns,r=o.slice(i);if(r.length===0)return 0;const s=al(t),n=String(r[0].column.field),l=t.shadow.querySelector(`th[data-field="${n}"]`);if(l){const a=l.getBoundingClientRect();if(e<a.left)return s}for(let a=0;a<r.length;a++){const d=String(r[a].column.field),c=t.shadow.querySelector(`th[data-field="${d}"]`);if(c){const u=c.getBoundingClientRect(),h=u.left+u.width/2;if(e<h)return Math.max(a,s)}}return r.length}function cl(t,e){const o=H.dropIndicator;if(!o)return;const i=t.grid.visualColumns,r=t.grid.totalFrozenColumns,s=i.slice(r),n=t.shadow.querySelector(".wg"),l=n==null?void 0:n.getBoundingClientRect();if(!l||!n)return;let a;if(e>=s.length){const u=String(s[s.length-1].column.field),h=t.shadow.querySelector(`th[data-field="${u}"]`);if(h)a=h.getBoundingClientRect().right-l.left+n.scrollLeft;else return}else{const u=String(s[e].column.field),h=t.shadow.querySelector(`th[data-field="${u}"]`);if(h)a=h.getBoundingClientRect().left-l.left+n.scrollLeft;else return}const d=n.scrollTop,c=n.clientHeight;o.style.left=`${a}px`,o.style.top=`${d}px`,o.style.height=`${c}px`,o.style.display="block"}function Hi(t){if(!Te)return;const e=Te;if(H.isPending){Fi(e);return}if(!H.isReordering)return;const o=H.field,i=H.fromIndex,r=H.currentDropIndex;if(i!==r&&r!==i+1){const s=r>i?r-1:r;e.grid.moveColumn(o,s),e.grid.oncolumnreorder&&e.grid.oncolumnreorder({field:o,fromIndex:i,toIndex:s,allOrder:e.grid.getColumnOrderState()}),e.grid.shouldPersistColumnOrder&&e.grid.gridName&&e.grid.savePersistedState()}qt=!0,requestAnimationFrame(()=>{qt=!1}),Fi(e)}function Fi(t){H.ghost&&H.ghost.remove(),H.dropIndicator&&H.dropIndicator.remove();const e=t.shadow.querySelector(".wg");e==null||e.classList.remove("wg--reordering"),H.headerCell&&H.headerCell.classList.remove("wg__header--dragging"),document.removeEventListener("mousemove",Oi),document.removeEventListener("mouseup",Hi),H={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},Te=null}function gl(){const t=new Set,e=new Set;let o=null,i=!1;const r=()=>{t.forEach(n=>n())},s=()=>{e.forEach(n=>n())};return{subscribe(n,l){const a=n==="container"?t:e;return a.add(l),{unsubscribe:()=>{a.delete(l)}}},init(n){o=n,n.addEventListener("scroll",r),i||(window.addEventListener("scroll",s,{capture:!0,passive:!0}),i=!0)},destroy(){o&&(o.removeEventListener("scroll",r),o=null),i&&(window.removeEventListener("scroll",s,!0),i=!1),t.clear(),e.clear()}}}function ul(t,e){const o=new Set,i=new Set;let r=null;const s=l=>{const a=l.target,d=l.relatedTarget;o.forEach(c=>c(a,d))},n=l=>{const a=l.target,d=l.relatedTarget;i.forEach(c=>c(a,d))};return{subscribe(l,a){const d=l==="blur"?o:i;return d.add(a),{unsubscribe:()=>{d.delete(a)}}},shouldSkipBlur(){const l=t();return l.isClosingViaToggle?(e(),!0):l.isCommittingFromKeyboard||l.isTransitioningCells||l.isOpeningDropdown},init(l){r=l,l.addEventListener("blur",s,!0),l.addEventListener("focusout",n)},destroy(){r&&(r.removeEventListener("blur",s,!0),r.removeEventListener("focusout",n),r=null),o.clear(),i.clear()}}}function hl(){const t={outsideClick:new Set,cellClick:new Set,rowNumberClick:new Set,headerClick:new Set,sortClick:new Set,emptyAreaClick:new Set};let e=null,o=!1,i=null,r=!1;const s=(d,c)=>{for(const u of t[d])if(u(c)===!0)return!0;return!1},n=()=>{setTimeout(()=>{r&&(r=!1)},10)},l=d=>{r=!0;const c=d,h=c.composedPath()[0]||c.target,g={target:h,event:c},f=h.closest(".wg__cell"),w=h.closest(".wg__row-number[data-row-number]"),p=h.closest(".wg__header:not(.wg__row-number-header)"),m=h.closest(".wg__sort-indicator");if(m){const _=m.closest(".wg__header--sortable");if(_){g.field=_.dataset.field,g.colIndex=parseInt(_.dataset.colIndex||"-1",10),s("sortClick",g);return}}w?(g.rowIndex=parseInt(w.dataset.rowNumber||"-1",10),s("rowNumberClick",g)):p&&!h.closest(".wg__resize-handle")?(g.field=p.dataset.field,g.colIndex=parseInt(p.dataset.colIndex||"-1",10),s("headerClick",g)):f&&!f.classList.contains("wg__row-number")?(g.rowIndex=parseInt(f.dataset.row||"-1",10),g.colIndex=parseInt(f.dataset.col||"-1",10),s("cellClick",g)):h.closest(".wg__toolbar, button, input, select, textarea")||s("emptyAreaClick",g)},a=d=>{if(!e)return;if(r){r=!1;return}const c=d,u=c.target,h=c.composedPath?c.composedPath():[],g=h.includes(e),f=!g&&(i==null?void 0:i(h))===!0;!g&&!f&&s("outsideClick",{target:u,event:c})};return{subscribe(d,c){return t[d].add(c),{unsubscribe:()=>{t[d].delete(c)}}},init(d,c,u){e=c,i=u??null,c.addEventListener("mousedown",l),c.addEventListener("mouseup",n),o||(document.addEventListener("click",a,!0),o=!0)},destroy(){e&&(e.removeEventListener("mousedown",l),e.removeEventListener("mouseup",n)),o&&(document.removeEventListener("click",a,!0),o=!1),e=null,i=null,r=!1,Object.values(t).forEach(d=>d.clear())}}}const fl=5;let L={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,rangeBorder:null},ae=null,bt=null,ot=null;function qi(){return L.isDragging}function ko(){return L.isPending}function Vi(t,e,o,i){var l;const r=i.shiftKey&&t.grid.cellSelectionMode==="shift";t.grid.selectedCellRange&&!r&&(t.grid.clearCellSelection(),Q()),(l=t.grid.visualColumns[o])!=null&&l.column&&(L={...L,isPending:!0,isDragging:!1,startRowIndex:e,startColIndex:o,startX:i.clientX,startY:i.clientY,currentRowIndex:e,currentColIndex:o},ae=t,document.addEventListener("mousemove",Ni),document.addEventListener("mouseup",Wi),document.addEventListener("keydown",Ui))}function wl(t,e,o){var i,r;if(Q(),t.grid.lastClickedCell){const{rowIndex:s,colIndex:n}=t.grid.lastClickedCell,l=t.grid.visualColumns,a=(i=l[n])==null?void 0:i.column,d=(r=l[o])==null?void 0:r.column;if(a&&d){const c={startRowIndex:s,startColIndex:n,endRowIndex:e,endColIndex:o,startField:String(a.field),endField:String(d.field)};t.grid.clearFocusedCell(),t.grid.selectCellRange(c),Vt(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const u=t.shadow.querySelector(".wg");u==null||u.focus({preventScroll:!0})})})}}else t.grid.lastClickedCell={rowIndex:e,colIndex:o}}function Ni(t){if(ae){if(L.isPending){const e=t.clientX-L.startX,o=t.clientY-L.startY;Math.sqrt(e*e+o*o)>=fl&&ml(ae);return}L.isDragging&&(bt=t,ot||(ot=requestAnimationFrame(pl)))}}function pl(){if(ot=null,!bt||!ae)return;const t=bt;bt=null;const e=bl(ae,t.clientX,t.clientY);if(e&&(e.rowIndex!==L.currentRowIndex||e.colIndex!==L.currentColIndex)){L.currentRowIndex=e.rowIndex,L.currentColIndex=e.colIndex;const o=Yi(ae);Bi(ae),Ki(ae,o)}}function ml(t){L.isPending=!1,L.isDragging=!0;const e=t.shadow.querySelector(".wg");e==null||e.classList.add("wg--selecting-cells");const o=t.grid.focusedCell;t.grid.clearFocusedCell(),ee(t,o,null);const i=t.shadow.querySelector(".wg__cell:focus");i==null||i.blur();const r=t.grid.focusedRowIndex;if(r!==null){const s=t.shadow.querySelector(`tr[data-row-index="${r}"]`);s==null||s.classList.remove("wg__row--focused"),t.grid.clearRowFocus()}Bi(t),ji(t)}function Bi(t){const{startRowIndex:e,startColIndex:o,currentRowIndex:i,currentColIndex:r}=L,s=Math.min(e,i),n=Math.max(e,i),l=Math.min(o,r),a=Math.max(o,r);t.shadow.querySelectorAll(".wg__cell--in-range").forEach(c=>c.classList.remove("wg__cell--in-range"));for(let c=s;c<=n;c++)for(let u=l;u<=a;u++){const h=t.shadow.querySelector(`[data-row="${c}"][data-col="${u}"]`);h&&h.classList.add("wg__cell--in-range")}}function Wi(t){if(!ae)return;const e=ae;if(L.isPending){t.shiftKey&&e.grid.cellSelectionMode==="shift"&&e.grid.lastClickedCell?wl(e,L.startRowIndex,L.startColIndex):e.grid.lastClickedCell={rowIndex:L.startRowIndex,colIndex:L.startColIndex},Nt(e);return}if(!L.isDragging)return;if(L.startRowIndex===L.currentRowIndex&&L.startColIndex===L.currentColIndex){e.shadow.querySelectorAll(".wg__cell--in-range").forEach(n=>n.classList.remove("wg__cell--in-range")),Q();const{startRowIndex:r,startColIndex:s}=L;e.grid.setFocusedCell(r,s),ee(e,null,{rowIndex:r,colIndex:s}),ft(e,r,s),Nt(e)}else _l(e),Nt(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=e.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})})}function Ui(t){if(t.key==="Escape"&&ae){t.preventDefault();const e=ae;if(L.isDragging){e.shadow.querySelectorAll(".wg__cell--in-range").forEach(s=>s.classList.remove("wg__cell--in-range")),Q();const{startRowIndex:i,startColIndex:r}=L;e.grid.setFocusedCell(i,r),ee(e,null,{rowIndex:i,colIndex:r}),ft(e,i,r)}Nt(e)}}function bl(t,e,o){const i=t.shadow.elementFromPoint(e,o);if(!i)return null;const r=i.closest(".wg__cell[data-row][data-col]");if(!r)return null;const s=parseInt(r.dataset.row||"-1",10),n=parseInt(r.dataset.col||"-1",10);return s>=0&&n>=0?{rowIndex:s,colIndex:n}:null}function _l(t){var d,c;const{startRowIndex:e,startColIndex:o,currentRowIndex:i,currentColIndex:r}=L,s=t.grid.visualColumns,n=(d=s[o])==null?void 0:d.column,l=(c=s[r])==null?void 0:c.column;if(!n||!l)return;const a={startRowIndex:e,startColIndex:o,endRowIndex:i,endColIndex:r,startField:String(n.field),endField:String(l.field)};t.grid.clearFocusedCell(),t.grid.selectCellRange(a),Vt(t)}function Yi(t){const{startRowIndex:e,startColIndex:o,currentRowIndex:i,currentColIndex:r}=L,s=t.shadow.querySelector(".wg");if(!s)return null;const n=Math.min(e,i),l=Math.max(e,i),a=Math.min(o,r),d=Math.max(o,r),c=t.shadow.querySelector(`[data-row="${n}"][data-col="${a}"]`),u=t.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`);if(!c||!u)return null;const h=s.getBoundingClientRect(),g=c.getBoundingClientRect(),f=u.getBoundingClientRect(),w=s.scrollLeft,p=s.scrollTop;return{container:s,left:g.left-h.left+w-s.clientLeft,top:g.top-h.top+p-s.clientTop,width:f.right-g.left,height:f.bottom-g.top}}function Ki(t,e){if(!e){Q();return}let o=L.rangeBorder;o||(o=document.createElement("div"),o.className="wg__cell-range-border",e.container.appendChild(o),L.rangeBorder=o),o.style.left=`${e.left}px`,o.style.top=`${e.top}px`,o.style.width=`${e.width}px`,o.style.height=`${e.height}px`}function ji(t){const e=Yi(t);Ki(t,e)}function Vt(t){Q();const e=t.grid.selectedCellRange;if(!e)return;const o=t.shadow.querySelector(".wg");if(!o)return;const{startRowIndex:i,endRowIndex:r,startColIndex:s,endColIndex:n}=e,l=Math.min(i,r),a=Math.max(i,r),d=Math.min(s,n),c=Math.max(s,n),u=t.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`),h=t.shadow.querySelector(`[data-row="${a}"][data-col="${c}"]`);if(!u||!h)return;const g=o.getBoundingClientRect(),f=u.getBoundingClientRect(),w=h.getBoundingClientRect(),p=o.scrollLeft,m=o.scrollTop,_=f.left-g.left+p-o.clientLeft,y=f.top-g.top+m-o.clientTop,C=w.right-f.left,S=w.bottom-f.top,v=document.createElement("div");v.className="wg__cell-range-border",v.style.left=`${_}px`,v.style.top=`${y}px`,v.style.width=`${C}px`,v.style.height=`${S}px`,o.appendChild(v),L.rangeBorder=v}function Xi(t){L.rangeBorder&&(Q(),L.isDragging?ji(t):Vt(t))}function Q(){L.rangeBorder&&(L.rangeBorder.remove(),L.rangeBorder=null)}function Nt(t){const e=t.shadow.querySelector(".wg");e==null||e.classList.remove("wg--selecting-cells"),ot&&(cancelAnimationFrame(ot),ot=null),bt=null,document.removeEventListener("mousemove",Ni),document.removeEventListener("mouseup",Wi),document.removeEventListener("keydown",Ui),L={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,rangeBorder:L.rangeBorder},ae=null}const vl=5;let me={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},Fe=null;function yl(t,e,o){if(o.preventDefault(),o.stopPropagation(),wi(t),t.grid.selectedCellRange&&(t.grid.clearCellSelection(),Q()),t.grid.focusedCell){const{rowIndex:i,colIndex:r}=t.grid.focusedCell,s=t.shadow.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`);s==null||s.classList.remove("wg__cell--focused"),t.grid.clearFocusedCell()}if(o.ctrlKey||o.metaKey){t.grid.selectRow(e,"toggle"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=t.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}if(o.shiftKey){t.grid.selectRow(e,"range"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=t.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}me={isPending:!0,isDragging:!1,startRowIndex:e,startX:o.clientX,startY:o.clientY,currentRowIndex:e},Fe=t,t.grid.selectRow(e,"replace"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=t.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})}),document.addEventListener("mousemove",Gi),document.addEventListener("mouseup",Qi)}function Gi(t){if(!Fe)return;if(me.isPending){const o=t.clientX-me.startX,i=t.clientY-me.startY;Math.sqrt(o*o+i*i)>=vl&&Cl(Fe);return}if(!me.isDragging)return;const e=Sl(Fe,t.clientY);e!==null&&e!==me.currentRowIndex&&(me.currentRowIndex=e,Fe.grid.selectRowRange(me.startRowIndex,e))}function Cl(t){me.isPending=!1,me.isDragging=!0;const e=t.shadow.querySelector(".wg");e==null||e.classList.add("wg--selecting")}function Qi(){if(!Fe)return;const t=Fe,e=t.shadow.querySelector(".wg");e==null||e.classList.remove("wg--selecting"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const o=t.shadow.querySelector(".wg");o==null||o.focus({preventScroll:!0})})}),document.removeEventListener("mousemove",Gi),document.removeEventListener("mouseup",Qi),me={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},Fe=null}function Sl(t,e){const o=t.shadow.querySelectorAll(".wg__row[data-row-index]");for(const i of o){const r=i.getBoundingClientRect();if(e>=r.top&&e<=r.bottom){const s=parseInt(i.dataset.rowIndex||"-1",10);if(s>=0)return s}}if(o.length>0){const i=o[0],r=o[o.length-1],s=i.getBoundingClientRect(),n=r.getBoundingClientRect();if(e<s.top)return parseInt(i.dataset.rowIndex||"0",10);if(e>n.bottom)return parseInt(r.dataset.rowIndex||"0",10)}return null}let Bt=[],Wt=[];function Ji(t){if(t.length===0)return[];const e=[...t].sort((s,n)=>s-n),o=[];let i=e[0],r=e[0];for(let s=1;s<e.length;s++)e[s]===r+1||(o.push({start:i,end:r}),i=e[s]),r=e[s];return o.push({start:i,end:r}),o}function Zi(t,e,o,i,r,s){const n=document.createElement("div");return n.className=s,n.style.left=`${e}px`,n.style.top=`${o}px`,n.style.width=`${i}px`,n.style.height=`${r}px`,t.appendChild(n),n}function er(t){it();const e=t.grid.selectedRows;if(e.length===0)return;const o=t.shadow.querySelector(".wg");if(!o)return;const i=Ji(e),r=t.grid.visualColumns;if(r.length===0)return;const s=o.getBoundingClientRect(),n=o.scrollLeft,l=o.scrollTop;for(const a of i){const d=t.shadow.querySelector(`.wg__cell[data-row="${a.start}"][data-col="0"]`),c=r.length-1,u=t.shadow.querySelector(`.wg__cell[data-row="${a.end}"][data-col="${c}"]`);if(!d||!u)continue;const h=d.getBoundingClientRect(),g=u.getBoundingClientRect(),f=h.left-s.left+n-o.clientLeft,w=h.top-s.top+l-o.clientTop,p=g.right-h.left,m=g.bottom-h.top,_=Zi(o,f,w,p,m,"wg__row-selection-border");Bt.push(_)}}function tr(t){rt();const e=t.grid.selectedColumns;if(e.length===0)return;const o=t.shadow.querySelector(".wg");if(!o)return;const i=Ji(e),r=t.grid.displayItems,s=t.grid.visualColumns;if(r.length===0||s.length===0)return;const n=o.getBoundingClientRect(),l=o.scrollLeft,a=o.scrollTop;for(const d of i){const c=s[d.start],u=s[d.end];if(!c||!u)continue;const h=String(c.column.field),g=String(u.column.field),f=t.shadow.querySelector(`.wg__header[data-field="${h}"]`),w=r.length-1,p=t.shadow.querySelector(`.wg__cell[data-row="${w}"][data-col="${u.originalIndex}"]`);if(!f||!p)continue;const m=t.shadow.querySelector(`.wg__header[data-field="${g}"]`);if(!m)continue;const _=f.getBoundingClientRect(),y=m.getBoundingClientRect(),C=p.getBoundingClientRect(),S=_.left-n.left+l-o.clientLeft,v=_.top-n.top+a-o.clientTop,x=y.right-_.left,k=C.bottom-_.top,E=Zi(o,S,v,x,k,"wg__column-selection-border");Wt.push(E)}}function xl(t){Bt.length>0&&er(t),Wt.length>0&&tr(t)}function it(){for(const t of Bt)t.remove();Bt=[]}function rt(){for(const t of Wt)t.remove();Wt=[]}function kl(){it(),rt()}const Il=5;let be={isPending:!1,isDragging:!1,startColIndex:-1,startX:0,startY:0,currentColIndex:-1},qe=null;function El(t,e,o){if(o.preventDefault(),o.stopPropagation(),wi(t),t.grid.selectedCellRange&&(t.grid.clearCellSelection(),Q()),o.ctrlKey||o.metaKey){t.grid.selectColumn(e,"toggle"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=t.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}be={isPending:!0,isDragging:!1,startColIndex:e,startX:o.clientX,startY:o.clientY,currentColIndex:e},qe=t,o.shiftKey?t.grid.selectColumn(e,"range"):t.grid.selectColumn(e,"replace"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=t.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})}),document.addEventListener("mousemove",or),document.addEventListener("mouseup",ir)}function or(t){if(!qe)return;if(be.isPending){const o=t.clientX-be.startX,i=t.clientY-be.startY;Math.sqrt(o*o+i*i)>=Il&&Rl(qe);return}if(!be.isDragging)return;const e=Dl(qe,t.clientX);e!==null&&e!==be.currentColIndex&&(be.currentColIndex=e,qe.grid.selectColumnRange(be.startColIndex,e))}function Rl(t){be.isPending=!1,be.isDragging=!0;const e=t.shadow.querySelector(".wg");e==null||e.classList.add("wg--selecting-columns")}function ir(){if(!qe)return;const t=qe,e=t.shadow.querySelector(".wg");e==null||e.classList.remove("wg--selecting-columns"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const o=t.shadow.querySelector(".wg");o==null||o.focus({preventScroll:!0})})}),document.removeEventListener("mousemove",or),document.removeEventListener("mouseup",ir),be={isPending:!1,isDragging:!1,startColIndex:-1,startX:0,startY:0,currentColIndex:-1},qe=null}function Dl(t,e){const o=t.shadow.querySelectorAll(".wg__header:not(.wg__row-number-header):not(.wg__inline-actions-header):not(.wg__actions-column):not(.wg__filler)"),i=t.grid.visualColumns;for(const r of o){const s=r.getBoundingClientRect();if(e>=s.left&&e<=s.right){const n=r.dataset.field;if(n){const l=i.findIndex(a=>String(a.column.field)===n);if(l>=0)return l}}}if(o.length>0){const r=o[0],s=o[o.length-1],n=r.getBoundingClientRect(),l=s.getBoundingClientRect();if(e<n.left){const a=r.dataset.field;if(a){const d=i.findIndex(c=>String(c.column.field)===a);if(d>=0)return d}return 0}if(e>l.right){const a=s.dataset.field;if(a){const d=i.findIndex(c=>String(c.column.field)===a);if(d>=0)return d}return i.length-1}}return null}function Tl(t){const e=[];let o=[],i="",r=!1;for(let s=0;s<t.length;s++){const n=t[s],l=t[s+1];r?n==='"'?l==='"'?(i+='"',s++):r=!1:i+=n:n==='"'?r=!0:n===" "?(o.push(i),i=""):n===`
657
657
  `||n==="\r"&&l===`
658
- `?(o.push(i),o.some(a=>a!=="")&&t.push(o),o=[],i="",n==="\r"&&s++):n!=="\r"&&(i+=n)}return(i!==""||o.length>0)&&(o.push(i),o.some(s=>s!=="")&&t.push(o)),t}function Rl(e,t){const o=new Map,i=new Map;t.forEach((a,d)=>{var g;if(a.isHidden)return;const c=String(a.field),u=((g=a.title)==null?void 0:g.toLowerCase().trim())||"";u&&o.set(u,{field:c,colIndex:d}),i.set(c.toLowerCase(),{field:c,colIndex:d})});const r=[];let s=0;for(const a of e){const d=a.trim().toLowerCase();if(!d)continue;const c=o.get(d)||i.get(d);c&&(s++,r.push({pastedHeader:a,gridField:c.field,colIndex:c.colIndex}))}const n=e.filter(a=>a.trim()!=="").length,l=Math.max(2,Math.floor(n*.5));return s>=l?r:null}async function El(e,t,o,i){var _;const r=e.grid,s=kl(t);if(s.length===0)return{totalCells:0,successfulCells:0,failedCells:0,skippedCells:0,newRowsCreated:0,cellResults:[],hadHeaders:!1};const n=Rl(s[0],r.columns),l=n!==null,a=l?s.slice(1):s;if(a.length===0)return{totalCells:0,successfulCells:0,failedCells:0,skippedCells:0,newRowsCreated:0,cellResults:[],hadHeaders:l};const d=r.visualColumns,c=r.isEmptyRowIndex(o),u=r.items.length;let g;if(c)g=a.length;else{const S=o+a.length-1;g=Math.max(0,S-u+1)}const h={rawText:t,parsedRows:s,hasHeaders:l,headerMapping:n,targetRowIndex:o,targetColIndex:i,newRowsCount:g,cancel:!1,skipCells:new Set};if(r.onbeforepaste&&(r.onbeforepaste(h),h.cancel))return{totalCells:a.reduce((S,k)=>S+k.length,0),successfulCells:0,failedCells:0,skippedCells:a.reduce((S,k)=>S+k.length,0),newRowsCreated:0,cellResults:[],hadHeaders:l};let f=0,w=u;if(g>0){const S=[];for(let k=0;k<g;k++){const E=c?k:u+k-o,R=a[E],I={};l&&n?R==null||R.forEach((z,D)=>{const P=n[D];P&&(I[P.gridField]=z)}):R==null||R.forEach((z,D)=>{const P=i+D;if(P<d.length){const j=String(d[P].column.field);I[j]=z}});let M;r.createRowCallback?M=r.createRowCallback(I,u+k):M=I,S.push(M),f++}c&&r.newRowPosition==="top"?(r.items=[...S,...r.items],w=0):(r.items=[...r.items,...S],w=u)}const p=[],m=r.pasteMode;for(let S=0;S<a.length;S++){const k=a[S],E=c?w+S:o+S,R=c?r.newRowPosition==="top"?1+S:r.items.length-a.length+S:o+S,I=E;for(let M=0;M<k.length;M++){const z=k[M];let D,P;if(l&&n){const X=n[M];if(!X)continue;D=X.gridField,P=X.colIndex}else{if(P=i+M,P>=d.length){p.push({rowIndex:R,field:"",value:z,isValid:!1,wasSkipped:!0,skipReason:"out-of-bounds"});continue}D=String(d[P].column.field)}const j=`${S}-${M}`;if(h.skipCells.has(j)){p.push({rowIndex:R,field:D,value:z,isValid:!0,wasSkipped:!0,skipReason:"user-canceled"});continue}const T=r.columns.find(X=>String(X.field)===D);if(!T)continue;if(!r.isCellEditable(T)){if(m==="editable-only"){p.push({rowIndex:R,field:D,value:z,isValid:!1,wasSkipped:!0,skipReason:"non-editable"});continue}else if(m==="skip-non-editable"){p.push({rowIndex:R,field:D,value:z,isValid:!0,wasSkipped:!0,skipReason:"non-editable"});continue}}const W=c?r.items[I]:r.displayItems[I];if(W&&r.isRowLocked(W)){p.push({rowIndex:R,field:D,value:z,isValid:!0,wasSkipped:!0,skipReason:"locked"});continue}let B=z;if(T.beforePasteCallback&&W&&(B=T.beforePasteCallback(z,W)),c){const X=r.items[I];if(X&&r.shouldValidateOnPaste&&T.beforeCommitCallback){const Ie={value:B,oldValue:void 0,row:X,rowIndex:I,field:D},te=await Promise.resolve(T.beforeCommitCallback(Ie)),He=te===!0||te===void 0||typeof te=="object"&&te!==null&&te.valid!==!1,De=typeof te=="object"&&te!==null?te.error||te.message:typeof te=="string"?te:void 0;He||(r.addInvalidCell(R,D,De||"Invalid value"),(_=r.onvalidationerror)==null||_.call(r,{row:X,rowIndex:R,field:D,error:De||"Invalid value"})),p.push({rowIndex:R,field:D,value:B,isValid:He,validationError:He?void 0:De,wasSkipped:!1})}else p.push({rowIndex:R,field:D,value:B,isValid:!0,wasSkipped:!1})}else if(r.shouldValidateOnPaste){await r.commitEdit(R,D,B);const X=r.invalidCells.find(Ie=>Ie.rowIndex===R&&Ie.field===D);p.push({rowIndex:R,field:D,value:B,isValid:!X,validationError:X==null?void 0:X.error,wasSkipped:!1})}else{const X=r.items[I];X&&(X[D]=B),p.push({rowIndex:R,field:D,value:B,isValid:!0,wasSkipped:!1})}}}const v=p.filter(S=>!S.wasSkipped&&S.isValid).length,y=p.filter(S=>!S.wasSkipped&&!S.isValid).length,x=p.filter(S=>S.wasSkipped).length,C={totalCells:p.length,successfulCells:v,failedCells:y,skippedCells:x,newRowsCreated:f,cellResults:p,hadHeaders:l};return r.onpaste&&r.onpaste(C),C}class Il{constructor(t){b(this,"executors",new Map);b(this,"ctx");this.ctx=t}registerExecutor(t){for(const o of t.handles)this.executors.set(o,t)}dispatch(t){const o=[t];for(;o.length>0;){const i=o.shift(),r=this.executors.get(i.type);if(!r){console.warn(`[ActionPipeline] No executor for action type: ${i.type}`);continue}const s=new Proxy(this.ctx,{get:(l,a)=>a==="dispatch"?d=>this.dispatch(d):l[a],set:(l,a,d)=>(l[a]=d,!0)}),n=r.execute(s,i);n&&n.length>0&&o.unshift(...n)}}}function Dl(e){return new Il(e)}const Tl={handles:["focusCell","blurCell"],execute(e,t){switch(t.type){case"focusCell":return Ml(e,t);case"blurCell":return $l(e)}}};function Ml(e,t){const{rowIndex:o,colIndex:i}=t.target,r=e.grid.columns[i];if(!r)return;const s=r.editTrigger??e.grid.editTrigger,n=s==="always",l=e.grid.focusedCell;(!l||l.rowIndex!==o||l.colIndex!==i)&&(e.filterText="",e.searchDebounceTimer&&(clearTimeout(e.searchDebounceTimer),e.searchDebounceTimer=null),e.searchAbortController&&(e.searchAbortController.abort(),e.searchAbortController=null)),e.grid.setFocusedCell(o,i),J(e,l,{rowIndex:o,colIndex:i});const d=e.shadow.querySelector(`td[data-row="${o}"][data-col="${i}"]`);if(!d)return;if(n){let h=d.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger");h||(h=d.querySelector(".wg__editor")),h&&(h.focus({preventScroll:!0}),t.selectText!==!1&&h instanceof HTMLInputElement&&h.type==="text"&&h.select())}else d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0});d.scrollIntoView({block:"nearest",inline:"nearest"}),Lt(e);const c=r.editor,u=c==="select"||c==="combobox"||c==="autocomplete",g=s==="navigate";if(n&&e.grid.shouldShowDropdownOnFocus&&!e.justSelected&&u)return[{type:"openDropdown"}];if(g&&e.grid.shouldShowDropdownOnFocus&&u)return[{type:"startEdit",target:{rowIndex:o,colIndex:i}},{type:"openDropdown"}]}function $l(e,t){const o=e.grid.focusedCell;e.grid.clearFocusedCell(),J(e,o,null)}const Al={handles:["navigate"],execute(e,t){if(t.type==="navigate")return Ll(e,t)}};function Ll(e,t){const o=t.from??e.grid.focusedCell;if(!o)return;const i=zl(e,o,t),r=e.grid.columns[o.colIndex],s=r?String(r.field):"",n=e.grid.editingCell&&e.grid.editingCell.rowIndex===o.rowIndex&&e.grid.editingCell.field===s;return i?i.rowIndex===o.rowIndex&&i.colIndex===o.colIndex?void 0:[{type:"transitionCell",from:o,to:i,selectText:!0}]:n?[{type:"commitEdit"},{type:"renderCell",target:o},{type:"focusCell",target:o,selectText:!1}]:void 0}function zl(e,t,o){const{direction:i,ctrlKey:r}=o,{rowIndex:s,colIndex:n}=t,l=e.grid.columns,d=e.grid.displayItems.length-1,c=l.length-1,u=e.grid.getEditableColumns();switch(i!=="tab"&&i!=="tab-back"&&i!=="enter"&&(e.grid.tabTraversalStartColIndex=null),i){case"up":if(s>0)return{rowIndex:s-1,colIndex:n};break;case"down":if(s<d)return{rowIndex:s+1,colIndex:n};break;case"left":if(n>0)return{rowIndex:s,colIndex:n-1};break;case"right":if(n<c)return{rowIndex:s,colIndex:n+1};break;case"tab":{if(u.length===0){if(n<c)return{rowIndex:s,colIndex:n+1};if(s<d)return{rowIndex:s+1,colIndex:0};break}e.grid.tabTraversalStartColIndex===null&&(e.grid.tabTraversalStartColIndex=n);const g=u.findIndex(h=>h.index===n);if(g>=0&&g<u.length-1)return{rowIndex:s,colIndex:u[g+1].index};if(g===-1&&u.length>0)return{rowIndex:s,colIndex:u[0].index};if(s<d)return{rowIndex:s+1,colIndex:u[0].index};if(e.grid.isEmptyRowIndex(s))return{rowIndex:s,colIndex:u[0].index};break}case"tab-back":{if(u.length===0){if(n>0)return{rowIndex:s,colIndex:n-1};if(s>0)return{rowIndex:s-1,colIndex:c};break}e.grid.tabTraversalStartColIndex===null&&(e.grid.tabTraversalStartColIndex=n);const g=u.findIndex(h=>h.index===n);if(g>0)return{rowIndex:s,colIndex:u[g-1].index};if(s>0)return{rowIndex:s-1,colIndex:u[u.length-1].index};break}case"enter":{const g=e.grid.tabTraversalStartColIndex??n;if(e.grid.tabTraversalStartColIndex=null,s<d)return{rowIndex:s+1,colIndex:g};break}case"home":return r?{rowIndex:0,colIndex:0}:{rowIndex:s,colIndex:0};case"end":return r?{rowIndex:d,colIndex:c}:{rowIndex:s,colIndex:c};case"page-up":return r?{rowIndex:0,colIndex:n}:{rowIndex:Math.max(0,s-10),colIndex:n};case"page-down":return r?{rowIndex:d,colIndex:n}:{rowIndex:Math.min(d,s+10),colIndex:n}}return null}const Pl={handles:["transitionCell"],execute(e,t){if(t.type==="transitionCell")return Ol(e,t)}};function Ol(e,t){const{from:o,to:i,selectText:r}=t,s=[],n=e.grid.editingCell,l=n&&n.rowIndex===o.rowIndex&&e.grid.columns.findIndex(g=>String(g.field)===n.field)===o.colIndex,a=e.grid.columns[o.colIndex],c=((a==null?void 0:a.editTrigger)??e.grid.editTrigger)==="always";if(o.rowIndex!==i.rowIndex||o.colIndex!==i.colIndex)if(l)s.push({type:"commitEdit"});else if(c)s.push({type:"commitEdit",target:o});else{const g={type:"renderCell",target:o};s.push(g)}const u={type:"focusCell",target:i,selectText:r};return s.push(u),s}const Hl={handles:["renderCell"],execute(e,t){t.type==="renderCell"&&Fl(e,t)}};function Fl(e,t){const{target:o,focusEditor:i,cursorPosition:r,initialSearchQuery:s}=t;H(e,o.rowIndex,o.colIndex,{focusEditor:i,cursorPosition:r,initialSearchQuery:s})}const Vl={handles:["openDropdown","closeDropdown","toggleDropdown","dropdownNavigate","dropdownSelect"],execute(e,t){switch(t.type){case"openDropdown":we(e);break;case"closeDropdown":q(e);break;case"toggleDropdown":e.dropdownOpen?q(e):we(e);break;case"dropdownNavigate":return ql(e,t);case"dropdownSelect":return Nl(e,t)}}},Gi=10;function ql(e,t){if(!e.dropdownOpen)return;const o=e.getCurrentEditorOptions();let i=e.highlightedIndex;const r=e.dropdownOptions.length;switch(t.direction){case"up":for(i=e.highlightedIndex-1;i>=0&&de(e.dropdownOptions[i],o);)i--;if(i<0)return;break;case"down":for(i=e.highlightedIndex+1;i<r&&de(e.dropdownOptions[i],o);)i++;if(i>=r)return;break;case"page-up":for(i=Math.max(0,e.highlightedIndex-Gi);i<e.highlightedIndex&&de(e.dropdownOptions[i],o);)i++;if(i>=e.highlightedIndex)return;break;case"page-down":for(i=Math.min(r-1,e.highlightedIndex+Gi);i>e.highlightedIndex&&de(e.dropdownOptions[i],o);)i--;if(i<=e.highlightedIndex)return;break;case"home":for(i=0;i<r&&de(e.dropdownOptions[i],o);)i++;if(i>=r)return;break;case"end":for(i=r-1;i>=0&&de(e.dropdownOptions[i],o);)i--;if(i<0)return;break}e.highlightedIndex=i,e.dropdownUserInteracted=!0,fe(e),bo(e)}function Nl(e,t){var h;if(!e.dropdownOpen||e.highlightedIndex<0)return q(e),t.thenNavigate?[{type:"navigate",direction:t.thenNavigate}]:void 0;const o=e.dropdownOptions[e.highlightedIndex];if(!o)return;const i=e.grid.editingCell,r=e.grid.focusedCell,s=i?{rowIndex:i.rowIndex,field:i.field,colIndex:e.grid.columns.findIndex(f=>String(f.field)===i.field)}:r?{rowIndex:r.rowIndex,field:String((h=e.grid.columns[r.colIndex])==null?void 0:h.field),colIndex:r.colIndex}:null;if(!s)return;const{rowIndex:n,field:l,colIndex:a}=s,d=e.grid.columns[a],c=(d==null?void 0:d.editorOptions)||{};if(de(o,c))return;const u=Ae(o,c),g=e.grid.displayItems[n];if(c.onselect&&g&&c.onselect(o,g),e.justSelected=!0,e.isCommittingFromKeyboard=!0,q(e),e.grid.commitEdit(n,l,u,t.commitEmptyRow??!1),t.thenNavigate)return H(e,n,a),e.justSelected=!1,[{type:"navigate",direction:t.thenNavigate,from:{rowIndex:n,colIndex:a}}];t.moveAfterSelect?e.moveFocusAfterCommit(n,l,"down"):H(e,n,a),requestAnimationFrame(()=>{e.justSelected=!1})}const Bl={handles:["noop"],execute(){}},Wl={handles:["toggleCheckbox"],execute(e,t){t.type==="toggleCheckbox"&&Yl(e,t)}};function Yl(e,t){const{rowIndex:o,colIndex:i}=t.target,r=e.grid.columns[i];if(!r||!e.grid.isCellEditable(r))return;const s=String(r.field),n=e.grid.displayItems[o];if(!n)return;const l=r.editorOptions||{},a=l.trueValue??!0,d=l.falseValue??!1,u=e.grid.getCellRawValue(n,o,s)===a?d:a;e.grid.startEdit(o,s),e.grid.updateDraftValue(o,s,u),H(e,o,i,{focusEditor:!0})}const Ul={handles:["openDatePicker","closeDatePicker","toggleDatePicker"],execute(e,t){switch(t.type){case"openDatePicker":Qi(e);break;case"closeDatePicker":Xl(e);break;case"toggleDatePicker":Gl(e);break}}};function Qi(e){const t=e.grid.focusedCell;if(!t)return;const{rowIndex:o,colIndex:i}=t,r=e.grid.columns[i];if(!r||r.editor!=="date")return;const s=String(r.field),n=e.shadow.querySelector(`.wg__cell[data-row="${o}"][data-col="${i}"]`);if(!n)return;const l=n.querySelector(".wg__editor--date"),a=n.querySelector(".wg__date-input");if(!l||!a)return;e.datepicker&&(e.datepicker.close(!0),e.datepicker=null);const d=a.dataset.dateFormat||"YYYY-MM-DD",c=a.dataset.minDate,u=a.dataset.maxDate,g=a.dataset.dateValue||"",h=o,f=i,w=s;e.datepicker=new Dt({dateFormat:d,minDate:c||void 0,maxDate:u||void 0,onSelect:(p,m)=>{Kl(e,h,f,w,p,m)},onClose:()=>{jl(e,h,f)}}),e.datepicker.open(l,g||null)}function Kl(e,t,o,i,r,s){e.datepicker=null,e.grid.commitEdit(t,i,It(r)),H(e,t,o);const n=e.shadow.querySelector(`.wg__cell[data-row="${t}"][data-col="${o}"]`);n&&n.focus(),s==="down"?e.dispatch({type:"navigate",direction:"down"}):s==="next"&&e.dispatch({type:"navigate",direction:"tab"})}function jl(e,t,o){e.datepicker=null;const i=e.grid.columns[o];if(!i)return;if((i.editTrigger??e.grid.editTrigger)==="always")H(e,t,o);else{K(e),e.grid.cancelEdit(),H(e,t,o);const s=e.shadow.querySelector(`.wg__cell[data-row="${t}"][data-col="${o}"]`);s&&s.focus()}}function Xl(e){e.datepicker&&(e.datepicker.close(!0),e.datepicker=null)}function Gl(e){e.datepicker?e.datepicker.close(!1):Qi(e)}const Ql={handles:["startEdit","commitEdit","cancelEdit","escapeEdit","deleteCell"],execute(e,t){switch(t.type){case"startEdit":Jl(e,t);break;case"commitEdit":Zl(e,t.commitEmptyRow,t.target);break;case"cancelEdit":ea(e);break;case"escapeEdit":return ta(e,t);case"deleteCell":oa(e,t);break}}};function Jl(e,t){const{rowIndex:o,colIndex:i}=t.target;se(e,o,i,{initialSearchQuery:t.initialSearchQuery,cursorPosition:t.cursorPosition})}async function Zl(e,t,o){const i=e.grid.editingCell;let r,s,n;if(o){r=o.rowIndex,s=o.colIndex;const c=e.grid.columns[s];if(!c)return;n=String(c.field)}else if(i){if(r=i.rowIndex,n=i.field,s=e.grid.columns.findIndex(c=>String(c.field)===n),s<0)return}else return;const l=e.shadow.querySelector(`.wg__cell[data-row="${r}"][data-col="${s}"]`);if(!l)return;let a=l.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger");if(a||(a=l.querySelector(".wg__editor")),!a)return;let d;if(e.grid.columns[s],a instanceof HTMLInputElement)if(a.type==="checkbox"){const c=e.grid.displayItems[r];d=e.grid.getCellRawValue(c,r,n)}else if(a.classList.contains("wg__date-input"))d=a.dataset.dateValue||a.value;else if(a.classList.contains("wg__editor--number")){const c=a.value.trim();if(c==="")d=null;else{const u=parseFloat(c);d=isNaN(u)?c:u}}else d=a.value;else a instanceof HTMLSelectElement?d=a.value:d=a.dataset.value||"";e.dropdownOpen&&q(e),K(e),await e.grid.commitEdit(r,n,d,t),H(e,r,s)}function ea(e){const t=e.grid.editingCell;if(!t)return;const{rowIndex:o,field:i}=t,r=e.grid.columns.findIndex(n=>String(n.field)===i),s=e.grid.columns[r];e.dropdownOpen&&q(e),K(e),(s==null?void 0:s.editor)==="checkbox"&&e.grid.discardCellDraft(o,i),e.grid.cancelEdit(),r>=0&&H(e,o,r)}function ta(e,t){const o=e.grid.editingCell,i=e.grid.focusedCell;if(t.phase==="dropdown"){const r=o||i;if(!r)return;const s=o?e.grid.columns.findIndex(a=>String(a.field)===o.field):(i==null?void 0:i.colIndex)??-1,n=e.grid.columns[s],l=n==null?void 0:n.editor;if(l==="select"&&e.filterText){e.filterText="",q(e),e.dispatch({type:"openDropdown"});return}if(l==="autocomplete"||l==="combobox"){const a=e.shadow.querySelector(`.wg__cell[data-row="${r.rowIndex}"][data-col="${s}"]`),d=a==null?void 0:a.querySelector(".wg__combobox-input, .wg__autocomplete-input"),c=e.grid.displayItems[r.rowIndex],u=n==null?void 0:n.field,g=c&&u?c[u]:void 0,h=(n==null?void 0:n.editorOptions)||{},f=h.initialOptions||h.options||[],w=ct(g,f,h),p=(d==null?void 0:d.value)??"";if(d&&p!==w){e.filterText="",d.value=w,d.focus(),d.select(),q(e),e.dispatch({type:"openDropdown"});return}}q(e),o&&(K(e),l==="checkbox"&&e.grid.discardCellDraft(r.rowIndex,o.field),e.grid.cancelEdit(),H(e,r.rowIndex,s),ut(e,r.rowIndex,s));return}if(o){const{rowIndex:r,field:s}=o,n=e.grid.columns.findIndex(a=>String(a.field)===s),l=e.grid.columns[n];e.dropdownOpen&&q(e),e.datepicker&&(e.datepicker.close(!0),e.datepicker=null),K(e),(l==null?void 0:l.editor)==="checkbox"&&e.grid.discardCellDraft(r,s),e.grid.cancelEdit(),n>=0&&(H(e,r,n),ut(e,r,n))}else if(i){const{rowIndex:r,colIndex:s}=i;e.grid.clearFocusedCell(),H(e,r,s)}}function oa(e,t){const o=t.target||e.grid.focusedCell;if(!o)return;const{rowIndex:i,colIndex:r}=o,s=e.grid.columns[r];if(!s||!e.grid.isCellEditable(s))return;const n=String(s.field);e.grid.commitEdit(i,n,null),H(e,i,r)}const ia={handles:["selectRow","selectColumn","clearSelection"],execute(e,t){switch(t.type){case"selectRow":ra(e,t);break;case"selectColumn":na(e,t);break;case"clearSelection":sa(e);break}}};function ra(e,t){const{rowIndex:o,addToSelection:i,extendSelection:r}=t;e.grid.selectedColumns.length>0&&e.grid.clearColumnSelection(),e.grid.selectedCellRange&&(e.grid.clearCellSelection(),G(),ke(),Co(e)),r&&e.grid.selectedRows.length>0?e.grid.selectRow(o,"range"):i?e.grid.selectRow(o,"toggle"):e.grid.selectRow(o,"replace"),Ji(e)}function na(e,t){const{colIndex:o,addToSelection:i,extendSelection:r}=t;e.grid.selectedRows.length>0&&e.grid.clearSelection(),e.grid.selectedCellRange&&(e.grid.clearCellSelection(),G(),ke(),Co(e)),r&&e.grid.selectedColumns.length>0?e.grid.selectColumn(o,"range"):i?e.grid.selectColumn(o,"toggle"):e.grid.selectColumn(o,"replace"),Zi(e)}function sa(e){if(console.log("[clearSelection] rows:",e.grid.selectedRows.length,"cols:",e.grid.selectedColumns.length,"cellRange:",!!e.grid.selectedCellRange),e.grid.selectedRows.length>0&&(console.log("[clearSelection] clearing rows"),e.grid.clearSelection_noRender(),et(),Ji(e)),e.grid.selectedColumns.length>0){console.log("[clearSelection] clearing columns, removing visual classes"),e.grid.clearColumnSelection_noRender(),tt(),Zi(e),console.log("[clearSelection] after clear, selectedColumns:",e.grid.selectedColumns.length);const t=e.shadow.querySelectorAll(".wg__header--selected");console.log("[clearSelection] remaining header--selected elements:",t.length)}e.grid.selectedCellRange&&(e.grid.clearCellSelection_noRender(),G(),ke(),Co(e))}function Ji(e){e.shadow.querySelectorAll(".wg__row--selected").forEach(o=>o.classList.remove("wg__row--selected"));for(const o of e.grid.selectedRows){const i=e.shadow.querySelector(`tr[data-row="${o}"]`);i&&i.classList.add("wg__row--selected")}}function Zi(e){e.shadow.querySelectorAll(".wg__cell--column-selected").forEach(i=>i.classList.remove("wg__cell--column-selected")),e.shadow.querySelectorAll(".wg__header--selected").forEach(i=>i.classList.remove("wg__header--selected"));for(const i of e.grid.selectedColumns){e.shadow.querySelectorAll(`.wg__cell[data-col="${i}"]`).forEach(n=>n.classList.add("wg__cell--column-selected"));const s=e.shadow.querySelector(`.wg__header[data-col="${i}"]`);s&&s.classList.add("wg__header--selected")}}function Co(e){e.shadow.querySelectorAll(".wg__cell--in-range").forEach(u=>u.classList.remove("wg__cell--in-range"));const o=e.grid.selectedCellRange;if(!o)return;const{startRowIndex:i,endRowIndex:r,startColIndex:s,endColIndex:n}=o,l=Math.min(i,r),a=Math.max(i,r),d=Math.min(s,n),c=Math.max(s,n);for(let u=l;u<=a;u++)for(let g=d;g<=c;g++){const h=e.shadow.querySelector(`.wg__cell[data-row="${u}"][data-col="${g}"]`);h&&h.classList.add("wg__cell--in-range")}}const la={handles:["copy","paste"],execute(e,t){switch(t.type){case"copy":aa(e);break}}};async function aa(e){var o,i;let t="";if(e.grid.selectedCellRange){const r=e.grid.selectedCellRange,{startRowIndex:s,endRowIndex:n,startColIndex:l,endColIndex:a}=r,d=Math.min(s,n),c=Math.max(s,n),u=Math.min(l,a),g=Math.max(l,a),h=[];for(let f=d;f<=c;f++){const w=[];for(let p=u;p<=g;p++){const m=e.grid.displayItems[f],v=(o=e.grid.visualColumns[p])==null?void 0:o.column;if(m&&v){const y=m[String(v.field)];w.push(qt(y))}else w.push("")}h.push(w.join(" "))}t=h.join(`
659
- `)}else if(e.grid.selectedColumns.length>0){const r=[],s=e.grid.displayItems;for(let n=0;n<s.length;n++){const l=[];for(const a of e.grid.selectedColumns){const d=s[n],c=(i=e.grid.visualColumns[a])==null?void 0:i.column;if(d&&c){const u=d[String(c.field)];l.push(qt(u))}else l.push("")}r.push(l.join(" "))}t=r.join(`
660
- `)}else if(e.grid.selectedRows.length>0){const r=[],s=e.grid.visualColumns;for(const n of e.grid.selectedRows){const l=e.grid.displayItems[n];if(l){const a=[];for(const d of s){const c=l[String(d.column.field)];a.push(qt(c))}r.push(a.join(" "))}}t=r.join(`
661
- `)}else if(e.grid.focusedCell){const{rowIndex:r,colIndex:s}=e.grid.focusedCell,n=e.grid.displayItems[r],l=e.grid.columns[s];if(n&&l){const a=n[String(l.field)];t=qt(a)}}if(t)try{await navigator.clipboard.writeText(t)}catch{console.warn("Failed to copy to clipboard")}}function qt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}const da={handles:["openContextMenu","closeContextMenu"],execute(e,t){switch(t.type){case"openContextMenu":ca(e,t);break;case"closeContextMenu":ga(e);break}}};function ca(e,t){t.target&&e.dispatch({type:"focusCell",target:t.target,selectText:!1})}function ga(e){e.contextMenuElement&&(ce(e.contextMenuElement),e.contextMenuElement=null),e.headerContextMenuElement&&(ce(e.headerContextMenuElement),e.headerContextMenuElement=null)}const ua={handles:["startFillDrag","updateFillDrag","completeFillDrag"],execute(e,t){switch(t.type){}}},ha={handles:["startCellSelection"],execute(e,t){if(t.type==="startCellSelection")return fa(e,t)}};function fa(e,t){Ai(e,t.rowIndex,t.colIndex,{clientX:t.clientX,clientY:t.clientY,shiftKey:t.shiftKey})}const wa={handles:["resetState"],execute(e,t){if(t.type==="resetState")return pa(e,t)}};function pa(e,t){const o=t.edit!==!1,i=t.selections!==!1,r=t.overlays!==!1,s=t.focus===!0,n=[];return r&&((e.contextMenuElement||e.headerContextMenuElement)&&n.push({type:"closeContextMenu"}),e.datepicker&&n.push({type:"closeDatePicker"})),o&&e.grid.editingCell&&n.push({type:"cancelEdit"}),i&&(e.grid.selectedRows.length>0||e.grid.selectedColumns.length>0||e.grid.selectedCellRange)&&n.push({type:"clearSelection"}),s&&e.grid.focusedCell&&n.push({type:"blurCell"}),n}const ma={handles:["openCustomEditor"],execute(e,t){if(t.type!=="openCustomEditor")return;const{rowIndex:o,colIndex:i}=t.target;e.openCustomEditor(o,i)}};function So(e,t){const{currentCell:o,dropdownOpen:i,isDropdownEditor:r}=t;if(!o)return null;const s=e.ctrlKey||e.metaKey;if(i)switch(e.key){case"ArrowUp":return{type:"dropdownNavigate",direction:"up"};case"ArrowDown":return{type:"dropdownNavigate",direction:"down"};case"ArrowLeft":case"ArrowRight":return t.editorType==="autocomplete"?null:{type:"noop"};case"Home":return t.editorType==="autocomplete"?null:{type:"dropdownNavigate",direction:"home"};case"End":return t.editorType==="autocomplete"?null:{type:"dropdownNavigate",direction:"end"};case"PageUp":return{type:"dropdownNavigate",direction:"page-up"};case"PageDown":return{type:"dropdownNavigate",direction:"page-down"};case"Enter":return{type:"dropdownSelect",moveAfterSelect:!0,commitEmptyRow:!0};case"Tab":return{type:"dropdownSelect",moveAfterSelect:!1,commitEmptyRow:!1,thenNavigate:e.shiftKey?"tab-back":"tab"};case"Escape":return{type:"escapeEdit",phase:"dropdown"}}if(e.key==="Escape")return{type:"escapeEdit",phase:"edit"};if(t.isCheckboxEditor){if(e.key===" ")return{type:"toggleCheckbox",target:o};if(e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight")return{type:"noop"}}if(r&&!i)switch(e.key){case" ":case"F2":return{type:"openDropdown"};case"Enter":return{type:"openDropdown"}}let n=null;switch(e.key){case"Tab":n=e.shiftKey?"tab-back":"tab";break;case"Enter":n="enter";break;case"ArrowUp":n="up";break;case"ArrowDown":n="down";break;case"ArrowLeft":n="left";break;case"ArrowRight":n="right";break;case"Home":n="home";break;case"End":n="end";break;case"PageUp":n="page-up";break;case"PageDown":n="page-down";break;default:return null}return n?{type:"navigate",direction:n,from:o,ctrlKey:s}:null}function er(e,t,o,i=!1){return!!(["Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"].includes(e)||e==="Escape"||o&&!t&&(e===" "||e==="F2")||i&&e===" ")}function tr(e,t){const{cell:o,dropdownOpen:i,isToggleClick:r,isDateTriggerClick:s,isCheckboxClick:n,isCellClick:l}=t,a=[];if(n)return a.push({type:"toggleCheckbox",target:o}),a;if(s)return a.push({type:"focusCell",target:o,selectText:!1}),a.push({type:"startEdit",target:o}),a.push({type:"toggleDatePicker"}),a;i&&!r&&a.push({type:"closeDropdown"});const{isDropdownEditor:d}=t,c=!r&&(!l||d);return a.push({type:"focusCell",target:o,selectText:c}),r&&(i?a.push({type:"closeDropdown"}):(a.push({type:"startEdit",target:o}),a.push({type:"openDropdown"}))),a}class ba{constructor(t){b(this,"pipeline");b(this,"ctx");this.ctx=t,this.pipeline=Dl(t),this.pipeline.registerExecutor(Tl),this.pipeline.registerExecutor(Al),this.pipeline.registerExecutor(Pl),this.pipeline.registerExecutor(Hl),this.pipeline.registerExecutor(Vl),this.pipeline.registerExecutor(Wl),this.pipeline.registerExecutor(Ul),this.pipeline.registerExecutor(Ql),this.pipeline.registerExecutor(ia),this.pipeline.registerExecutor(la),this.pipeline.registerExecutor(da),this.pipeline.registerExecutor(ua),this.pipeline.registerExecutor(ha),this.pipeline.registerExecutor(wa),this.pipeline.registerExecutor(ma),this.pipeline.registerExecutor(Bl)}getEditTrigger(t){const o=this.ctx.grid.columns[t];return o?o.editTrigger??this.ctx.grid.editTrigger:"navigate"}isAlwaysMode(t){return this.ctx.grid.isEditable?this.getEditTrigger(t)==="always":!1}isEditingCell(t,o){const i=this.ctx.grid.editingCell;if(!i)return!1;const r=this.ctx.grid.columns[o];return r?i.rowIndex===t&&i.field===String(r.field):!1}isDropdownEditor(t){const o=this.ctx.grid.columns[t];if(!o)return!1;const i=o.editor;return i==="select"||i==="combobox"||i==="autocomplete"}isCheckboxEditor(t){const o=this.ctx.grid.columns[t];return o?o.editor==="checkbox":!1}isDateEditor(t){const o=this.ctx.grid.columns[t];return o?o.editor==="date":!1}isCustomEditor(t){const o=this.ctx.grid.columns[t];return o?o.editor==="custom":!1}getDropdownEditorType(t){const o=this.ctx.grid.columns[t];if(!o)return;const i=o.editor;if(i==="select"||i==="combobox"||i==="autocomplete")return i}getCellFromTarget(t){const o=t.closest(".wg__cell");if(!o)return null;const i=parseInt(o.dataset.row||"",10),r=parseInt(o.dataset.col||"",10);return isNaN(i)||isNaN(r)?null:{rowIndex:i,colIndex:r}}tryHandleKeyDown(t){const o=t.target,i=this.getCellFromTarget(o);if(!i||this.ctx.datepicker&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(t.key))return!1;const r=this.getEditTrigger(i.colIndex),s=this.isAlwaysMode(i.colIndex),n=this.isEditingCell(i.rowIndex,i.colIndex),l=this.ctx.dropdownOpen,a=this.isDropdownEditor(i.colIndex),d=this.isCheckboxEditor(i.colIndex),c=this.isDateEditor(i.colIndex);if(s){if(!er(t.key,l,a,d))return!1;const g=So(t,{currentCell:i,dropdownOpen:l,isDropdownEditor:a,isCheckboxEditor:d,editorType:this.getDropdownEditorType(i.colIndex)});return g?(t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch(g),!0):!1}if(n){const g=t.key==="ArrowLeft"||t.key==="ArrowRight";if(g&&r==="navigate"&&a)return t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"navigate",direction:t.key==="ArrowLeft"?"left":"right",from:i}),!0;if(t.key==="Tab"&&r==="navigate"&&l)return t.preventDefault(),t.stopPropagation(),this.ctx.dropdownUserInteracted?this.pipeline.dispatch({type:"dropdownSelect",moveAfterSelect:!1,thenNavigate:t.shiftKey?"tab-back":"tab"}):(this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"navigate",direction:t.shiftKey?"tab-back":"tab",from:i})),!0;if(!er(t.key,l,a,d)||!a&&!d&&!c&&g&&!l)return!1;const w=So(t,{currentCell:i,dropdownOpen:l,isDropdownEditor:a,isCheckboxEditor:d,editorType:this.getDropdownEditorType(i.colIndex)});return w?(t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch(w),!0):!1}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","PageUp","PageDown"].includes(t.key)){const g=So(t,{currentCell:i,dropdownOpen:!1,isDropdownEditor:!1,isCheckboxEditor:!1});return g?(t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch(g),!0):!1}if(t.key==="F2"){const g=this.isCustomEditor(i.colIndex);return t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch({type:"startEdit",target:i}),a?this.pipeline.dispatch({type:"openDropdown"}):c?this.pipeline.dispatch({type:"openDatePicker"}):g&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}if(t.key==="Enter"){if(c)return t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch({type:"startEdit",target:i}),this.pipeline.dispatch({type:"openDatePicker"}),!0;if(a){const g=this.ctx.grid.columns[i.colIndex];return g&&this.ctx.grid.getEffectiveShouldOpenDropdownOnEnter(g)?(t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch({type:"startEdit",target:i}),this.pipeline.dispatch({type:"openDropdown"}),!0):!1}return!1}if(t.key===" "){const g=this.isCustomEditor(i.colIndex);if(a||c||d||g)return t.preventDefault(),t.stopPropagation(),d?this.pipeline.dispatch({type:"toggleCheckbox",target:i}):(this.pipeline.dispatch({type:"startEdit",target:i}),a?this.pipeline.dispatch({type:"openDropdown"}):c?this.pipeline.dispatch({type:"openDatePicker"}):g&&this.pipeline.dispatch({type:"openCustomEditor",target:i})),!0}if(t.key==="Delete")return t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch({type:"deleteCell",target:i}),!0;if((t.ctrlKey||t.metaKey)&&t.key==="c")return t.preventDefault(),t.stopPropagation(),this.pipeline.dispatch({type:"copy"}),!0;if(t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey){if(this.isEditingCell(i.rowIndex,i.colIndex))return!1;t.preventDefault(),t.stopPropagation();const g=this.isCustomEditor(i.colIndex);return this.pipeline.dispatch({type:"startEdit",target:i,initialSearchQuery:t.key}),a?this.pipeline.dispatch({type:"openDropdown"}):g&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}return!1}tryHandleFocus(t){const o=t.target,i=this.getCellFromTarget(o);if(!i||!this.isAlwaysMode(i.colIndex)||!o.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger"))return!1;const s=this.ctx.grid.focusedCell;return(!s||s.rowIndex!==i.rowIndex||s.colIndex!==i.colIndex)&&this.pipeline.dispatch({type:"focusCell",target:i,selectText:!1}),!0}tryHandleMouseDown(t){const o=t.target,i=o.matches(".wg__combobox-toggle, .wg__select-toggle"),r=!!o.closest(".wg__date-trigger"),s=o.matches('.wg__checkbox-input, input[type="checkbox"]'),n=!i&&!r&&!s&&(o.matches(".wg__cell")||o.closest(".wg__cell")!==null);let l=null;if(i){const w=o.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete")||o.closest(".wg__cell-dropdown-display");if(w){const p=parseInt(w.dataset.row||"",10),m=w.dataset.field||"",v=this.ctx.grid.columns.findIndex(y=>String(y.field)===m);!isNaN(p)&&v>=0&&(l={rowIndex:p,colIndex:v})}}else if(r){const w=o.closest(".wg__editor--date")||o.closest(".wg__cell-date-display");if(w){const p=parseInt(w.dataset.row||"",10),m=w.dataset.field||"",v=this.ctx.grid.columns.findIndex(y=>String(y.field)===m);!isNaN(p)&&v>=0&&(l={rowIndex:p,colIndex:v})}}else l=this.getCellFromTarget(o);if(!l)return!1;this.ctx.grid.tabTraversalStartColIndex=null;const a=this.isAlwaysMode(l.colIndex),d=this.isEditingCell(l.rowIndex,l.colIndex);if(!i&&!r&&!s&&!n)return!1;const c=this.ctx.grid.cellSelectionMode,u=t.shiftKey;if(c==="shift"&&u&&n)return this.pipeline.dispatch({type:"startCellSelection",rowIndex:l.rowIndex,colIndex:l.colIndex,clientX:t.clientX,clientY:t.clientY,shiftKey:!0}),t.preventDefault(),!0;if(a||d){const w=o.matches(".wg__editor--text, .wg__editor--number, .wg__date-input"),p=o.matches(".wg__combobox-input, .wg__autocomplete-input"),m=this.ctx.grid.focusedCell,v=m&&m.rowIndex===l.rowIndex&&m.colIndex===l.colIndex;if((w||p)&&v&&n)return!0;const y=n&&this.ctx.grid.selectedCellRange;n&&(y||this.ctx.grid.selectedRows.length>0||this.ctx.grid.selectedColumns.length>0)&&(y&&(this.ctx.isTransitioningCells=!0),this.pipeline.dispatch({type:"clearSelection"}));const C=this.ctx.dropdownOpen,_=this.isDropdownEditor(l.colIndex),S=tr(t,{cell:l,dropdownOpen:C,isDropdownEditor:_,isDateEditor:this.isDateEditor(l.colIndex),isCheckboxEditor:this.isCheckboxEditor(l.colIndex),isToggleClick:i,isDateTriggerClick:r,isCheckboxClick:s,isCellClick:n});if(S.length===0)return y&&(this.ctx.isTransitioningCells=!1),!1;w||(t.preventDefault(),t.stopPropagation());for(const k of S)this.pipeline.dispatch(k);return y&&requestAnimationFrame(()=>{this.ctx.isTransitioningCells=!1}),!0}if(i)return t.preventDefault(),t.stopPropagation(),this.ctx.grid.editingCell&&this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"focusCell",target:l,selectText:!1}),this.pipeline.dispatch({type:"startEdit",target:l}),this.pipeline.dispatch({type:"openDropdown"}),!0;if(r)return t.preventDefault(),t.stopPropagation(),this.ctx.grid.editingCell&&this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"focusCell",target:l,selectText:!1}),this.pipeline.dispatch({type:"startEdit",target:l}),this.pipeline.dispatch({type:"openDatePicker"}),!0;if(n&&!i&&!s){t.preventDefault(),this.ctx.grid.editingCell&&(this.ctx.isTransitioningCells=!0,this.pipeline.dispatch({type:"cancelEdit"})),(this.ctx.grid.selectedRows.length>0||this.ctx.grid.selectedColumns.length>0||this.ctx.grid.selectedCellRange)&&this.pipeline.dispatch({type:"clearSelection"}),this.pipeline.dispatch({type:"focusCell",target:l,selectText:!1});const w=this.ctx.grid.cellSelectionMode,p=t.shiftKey;return w!=="disabled"&&(w==="click"&&!p||w==="shift"&&p)&&this.pipeline.dispatch({type:"startCellSelection",rowIndex:l.rowIndex,colIndex:l.colIndex,clientX:t.clientX,clientY:t.clientY,shiftKey:t.shiftKey}),this.ctx.isTransitioningCells&&requestAnimationFrame(()=>{this.ctx.isTransitioningCells=!1}),!0}const g=this.ctx.dropdownOpen,h=this.isDropdownEditor(l.colIndex),f=tr(t,{cell:l,dropdownOpen:g,isDropdownEditor:h,isDateEditor:this.isDateEditor(l.colIndex),isCheckboxEditor:this.isCheckboxEditor(l.colIndex),isToggleClick:i,isDateTriggerClick:r,isCheckboxClick:s,isCellClick:n});if(f.length===0)return!1;t.preventDefault(),t.stopPropagation();for(const w of f)this.pipeline.dispatch(w);return!0}tryHandleClick(t){const o=t.target,i=this.getCellFromTarget(o);if(!i||this.getEditTrigger(i.colIndex)!=="click"||this.isEditingCell(i.rowIndex,i.colIndex))return!1;t.preventDefault();const s=this.isDropdownEditor(i.colIndex),n=this.isDateEditor(i.colIndex),l=this.isCustomEditor(i.colIndex);(s||n||l)&&t.stopImmediatePropagation();const a=o.closest(".wg__cell"),d=a?ht(t,a):null;return this.pipeline.dispatch({type:"startEdit",target:i,cursorPosition:d??void 0}),s?this.pipeline.dispatch({type:"openDropdown"}):n?this.pipeline.dispatch({type:"openDatePicker"}):l&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}tryHandleDblClick(t){const o=t.target,i=this.getCellFromTarget(o);if(!i)return!1;const r=this.getEditTrigger(i.colIndex);if(r!=="dblclick"&&r!=="navigate"||this.isEditingCell(i.rowIndex,i.colIndex))return!1;t.preventDefault();const s=this.isDropdownEditor(i.colIndex),n=this.isDateEditor(i.colIndex),l=this.isCustomEditor(i.colIndex),a=o.closest(".wg__cell"),d=a?ht(t,a):null;return this.pipeline.dispatch({type:"startEdit",target:i,cursorPosition:d??void 0}),s?this.pipeline.dispatch({type:"openDropdown"}):n?this.pipeline.dispatch({type:"openDatePicker"}):l&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}isDatepickerOpen(){return!!this.ctx.datepicker}clearSelection(){this.pipeline.dispatch({type:"clearSelection"})}}function _a(e){return new ba(e)}class xo extends HTMLElement{constructor(){super();b(this,"grid");b(this,"shadow");b(this,"styleElement");b(this,"customStyleElement",null);b(this,"updatePending",!1);b(this,"isCommittingFromKeyboard",!1);b(this,"isTransitioningCells",!1);b(this,"toolbarOutsideClickAdded",!1);b(this,"clickEventsSubscribed",!1);b(this,"focusEventsSubscribed",!1);b(this,"toolbarMoveInProgress",!1);b(this,"toolbarHideTimeout",null);b(this,"toolbarHovered",!1);b(this,"toolbarShortcutHandler",null);b(this,"hoveredCell",null);b(this,"currentCellToolbarItems",null);b(this,"toolbarMousemoveHandler",null);b(this,"inlineShortcutHandler",null);b(this,"dropdownOpen",!1);b(this,"dropdownOptions",[]);b(this,"highlightedIndex",-1);b(this,"filterText","");b(this,"isUserFiltering",!1);b(this,"justSelected",!1);b(this,"isOpeningDropdown",!1);b(this,"dropdownUserInteracted",!1);b(this,"isClosingViaToggle",!1);b(this,"isProgrammaticScroll",!1);b(this,"searchDebounceTimer",null);b(this,"searchAbortController",null);b(this,"isSearching",!1);b(this,"tooltipElement",null);b(this,"tooltipArrowElement",null);b(this,"tooltipAnchor",null);b(this,"tooltipShowTimer",null);b(this,"tooltipHideTimer",null);b(this,"_tooltipShowDelay",200);b(this,"_tooltipHideDelay",100);b(this,"datepicker",null);b(this,"contextMenuElement",null);b(this,"headerContextMenuElement",null);b(this,"virtualScrollStart",0);b(this,"virtualScrollEnd",0);b(this,"isLoadingMoreItems",!1);b(this,"scrollEvents");b(this,"focusEvents");b(this,"clickEvents");b(this,"pipelineAdapter",null);b(this,"_isMouseDown",!1);b(this,"handlePaste",async o=>{var l;if(!this.grid.isNavigateMode||this.grid.editingCell||!this.grid.focusedCell)return;const{rowIndex:i,colIndex:r}=this.grid.focusedCell,s=((l=o.clipboardData)==null?void 0:l.getData("text"))||"";if(!s)return;if(s.includes(" ")||s.includes(`
662
- `))o.preventDefault(),await El(this,s,i,r),this.render();else{const a=this.grid.columns[r],d=this.grid.displayItems[i];if(!a||!d||!this.grid.isCellEditable(a))return;o.preventDefault();let c=s;a.beforePasteCallback&&(c=a.beforePasteCallback(s,d));const u=String(a.field);await this.grid.commitEdit(i,u,c),this.render()}});this.shadow=this.attachShadow({mode:"open"}),this.grid=new ei,this.scrollEvents=sl(),this.clickEvents=al(),this.focusEvents=ll(()=>({isCommittingFromKeyboard:this.isCommittingFromKeyboard,isTransitioningCells:this.isTransitioningCells,isClosingViaToggle:this.isClosingViaToggle,isOpeningDropdown:this.isOpeningDropdown}),()=>{this.isClosingViaToggle=!1}),this.styleElement=document.createElement("style"),this.styleElement.textContent=Wn,this.shadow.appendChild(this.styleElement),this.grid.requestUpdate=()=>this.requestUpdate(),this.grid._onInteractionChange=(o,i)=>{o==="editingCell"&&i.current===null&&q(this)}}get tooltipShowDelay(){return this._tooltipShowDelay}set tooltipShowDelay(o){this._tooltipShowDelay=o}get tooltipHideDelay(){return this._tooltipHideDelay}set tooltipHideDelay(o){this._tooltipHideDelay=o}connectedCallback(){ro.debug("connectedCallback — grid attached to DOM"),this.grid.gridName&&this.grid.shouldPersistColumnWidths&&this.grid.loadPersistedWidths(),this.pipelineAdapter=_a(this),this.render(),this.addEventListener("paste",this.handlePaste)}disconnectedCallback(){ro.debug("disconnectedCallback — grid removed from DOM"),this.scrollEvents.destroy(),this.focusEvents.destroy(),this.clickEvents.destroy(),this.clickEventsSubscribed=!1,this.focusEventsSubscribed=!1,this.removeEventListener("paste",this.handlePaste),this.datepicker&&(this.datepicker.destroy(),this.datepicker=null),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null),Tt(),this.removeInlineShortcuts(),vl()}get items(){return this.grid.items}set items(o){this.grid.items=o,this.isLoadingMoreItems=!1}get columns(){return this.grid.columns}set columns(o){this.grid.columns=o}get isFilterable(){return this.grid.isFilterable}set isFilterable(o){this.grid.isFilterable=o}get isPageable(){return this.grid.isPageable}set isPageable(o){this.grid.isPageable=o}get pageSize(){return this.grid.pageSize}set pageSize(o){this.grid.pageSize=o}get pageSizes(){return this.grid.pageSizes}set pageSizes(o){this.grid.pageSizes=o}get paginationMode(){return this.grid.paginationMode}set paginationMode(o){this.grid.paginationMode=o}get isStriped(){return this.grid.isStriped}set isStriped(o){this.grid.isStriped=o}get isHoverable(){return this.grid.isHoverable}set isHoverable(o){this.grid.isHoverable=o}get isEditable(){return this.grid.isEditable}set isEditable(o){this.grid.isEditable=o}get editTrigger(){return this.grid.editTrigger}set editTrigger(o){this.grid.editTrigger=o}get editStartSelection(){return this.grid.editStartSelection}set editStartSelection(o){this.grid.editStartSelection=o}get mode(){return this.grid.mode}set mode(o){this.grid.mode=o}get dropdownToggleVisibility(){return this.grid.dropdownToggleVisibility}set dropdownToggleVisibility(o){this.grid.dropdownToggleVisibility=o}get shouldShowDropdownOnFocus(){return this.grid.shouldShowDropdownOnFocus}set shouldShowDropdownOnFocus(o){this.grid.shouldShowDropdownOnFocus=o}get shouldOpenDropdownOnEnter(){return this.grid.shouldOpenDropdownOnEnter}set shouldOpenDropdownOnEnter(o){this.grid.shouldOpenDropdownOnEnter=o}get isCheckboxAlwaysEditable(){return this.grid.isCheckboxAlwaysEditable}set isCheckboxAlwaysEditable(o){this.grid.isCheckboxAlwaysEditable=o}get isRowNumbersVisible(){return this.grid.isRowNumbersVisible}set isRowNumbersVisible(o){this.grid.isRowNumbersVisible=o}get isDirtyIndicatorVisible(){return this.grid.isDirtyIndicatorVisible}set isDirtyIndicatorVisible(o){this.grid.isDirtyIndicatorVisible=o}isCellDirty(o,i){return this.grid.isCellDirty(o,i)}isRowDirty(o){return this.grid.isRowDirty(o)}get isStickyRowNumbers(){return this.grid.isStickyRowNumbers}set isStickyRowNumbers(o){this.grid.isStickyRowNumbers=o}get freezeColumns(){return this.grid.freezeColumns}set freezeColumns(o){this.grid.freezeColumns=o}get invalidCells(){return this.grid.invalidCells}set invalidCells(o){this.grid.invalidCells=o}get isRowToolbarVisible(){return this.grid.isRowToolbarVisible}set isRowToolbarVisible(o){this.grid.isRowToolbarVisible=o}get rowToolbar(){return this.grid.rowToolbar}set rowToolbar(o){this.grid.rowToolbar=o}get toolbarVerticalAlign(){return this.grid.toolbarVerticalAlign}set toolbarVerticalAlign(o){this.grid.toolbarVerticalAlign=o}get toolbarHorizontalAlign(){return this.grid.toolbarHorizontalAlign}set toolbarHorizontalAlign(o){this.grid.toolbarHorizontalAlign=o}get toolbarAlign(){return this.grid.toolbarVerticalAlign}set toolbarAlign(o){this.grid.toolbarVerticalAlign=o}get toolbarTopPosition(){return this.grid.toolbarHorizontalAlign}set toolbarTopPosition(o){this.grid.toolbarHorizontalAlign=o}get toolbarTrigger(){return this.grid.toolbarTrigger}set toolbarTrigger(o){this.grid.toolbarTrigger=o}get toolbarPosition(){return this.grid.toolbarPosition}set toolbarPosition(o){this.grid.toolbarPosition=o}get toolbarColumn(){return this.grid.toolbarColumn}set toolbarColumn(o){this.grid.toolbarColumn=o}get toolbarFollowsCursor(){return this.grid.toolbarFollowsCursor}set toolbarFollowsCursor(o){this.grid.toolbarFollowsCursor=o}get cellToolbar(){return this.grid.cellToolbar}set cellToolbar(o){this.grid.cellToolbar=o}get cellToolbarOffset(){return this.grid.cellToolbarOffset}set cellToolbarOffset(o){this.grid.cellToolbarOffset=o}get toolbarBtnMinWidth(){return this.grid.toolbarBtnMinWidth}set toolbarBtnMinWidth(o){this.grid.toolbarBtnMinWidth=o}get inlineActionsTitle(){return this.grid.inlineActionsTitle}set inlineActionsTitle(o){this.grid.inlineActionsTitle=o}get contextMenu(){return this.grid.contextMenu}set contextMenu(o){this.grid.contextMenu=o}get contextMenuXOffset(){return this.grid.contextMenuXOffset}set contextMenuXOffset(o){this.grid.contextMenuXOffset=o}get contextMenuYOffset(){return this.grid.contextMenuYOffset}set contextMenuYOffset(o){this.grid.contextMenuYOffset=o}get headerContextMenu(){return this.grid.headerContextMenu}set headerContextMenu(o){this.grid.headerContextMenu=o}set onheadercontextmenuopen(o){this.grid.onheadercontextmenuopen=o}get rowShortcuts(){return this.grid.rowShortcuts}set rowShortcuts(o){this.grid.rowShortcuts=o}get rangeShortcuts(){return this.grid.rangeShortcuts}set rangeShortcuts(o){this.grid.rangeShortcuts=o}get selectedRows(){return this.grid.selectedRows}selectRow(o,i="replace"){this.grid.selectRow(o,i)}selectRowRange(o,i){this.grid.selectRowRange(o,i)}clearSelection(){this.grid.clearSelection()}isRowSelected(o){return this.grid.isRowSelected(o)}getSelectedRowsData(){return this.grid.getSelectedRowsData()}copySelectedRowsToClipboard(){return this.grid.copySelectedRowsToClipboard()}get cellSelectionMode(){return this.grid.cellSelectionMode}set cellSelectionMode(o){this.grid.cellSelectionMode=o}get selectedCellRange(){return this.grid.selectedCellRange}selectCellRange(o){this.grid.selectCellRange(o)}clearCellSelection(){this.grid.clearCellSelection()}getSelectedCells(){return this.grid.getSelectedCells()}copyCellSelectionToClipboard(){return this.grid.copyCellSelectionToClipboard()}get shouldCopyWithHeaders(){return this.grid.shouldCopyWithHeaders}set shouldCopyWithHeaders(o){this.grid.shouldCopyWithHeaders=o}get oncellselectionchange(){return this.grid.oncellselectionchange}set oncellselectionchange(o){this.grid.oncellselectionchange=o}get isNewRowEnabled(){return this.grid.isNewRowEnabled}set isNewRowEnabled(o){this.grid.isNewRowEnabled=o}get newRowPosition(){return this.grid.newRowPosition}set newRowPosition(o){this.grid.newRowPosition=o}get newRowIndicator(){return this.grid.newRowIndicator}set newRowIndicator(o){this.grid.newRowIndicator=o}get createEmptyRowCallback(){return this.grid.createEmptyRowCallback}set createEmptyRowCallback(o){this.grid.createEmptyRowCallback=o}get isShortcutsHelpVisible(){return this.grid.isShortcutsHelpVisible}set isShortcutsHelpVisible(o){this.grid.isShortcutsHelpVisible=o}get shortcutsHelpPosition(){return this.grid.shortcutsHelpPosition}set shortcutsHelpPosition(o){this.grid.shortcutsHelpPosition=o}get shortcutsHelpContentCallback(){return this.grid.shortcutsHelpContentCallback}set shortcutsHelpContentCallback(o){this.grid.shortcutsHelpContentCallback=o}set onrowchange(o){this.grid.onrowchange=o}set onroweditstart(o){this.grid.onroweditstart=o}set onroweditcancel(o){this.grid.onroweditcancel=o}set onvalidationerror(o){this.grid.onvalidationerror=o}get validationTooltipCallback(){return this.grid.validationTooltipCallback}set validationTooltipCallback(o){this.grid.validationTooltipCallback=o}set ontoolbarclick(o){this.grid.ontoolbarclick=o}set onrowaction(o){this.grid.onrowaction=o}set oncontextmenuopen(o){this.grid.oncontextmenuopen=o}get ondatarequest(){return this.grid.ondatarequest}set ondatarequest(o){this.grid.ondatarequest=o}get onrowdelete(){return this.grid.onrowdelete}set onrowdelete(o){this.grid.onrowdelete=o}get onrowfocus(){return this.grid.onrowfocus}set onrowfocus(o){this.grid.onrowfocus=o}get focusedRowIndex(){return this.grid.focusedRowIndex}set focusedRowIndex(o){this.grid.focusedRowIndex=o}get sort(){return this.grid.sort}set sort(o){this.grid.sort=o}get sortMode(){return this.grid.sortMode}set sortMode(o){this.grid.sortMode=o}get currentPage(){return this.grid.currentPage}set currentPage(o){this.grid.currentPage=o}get totalItems(){return this.grid.totalItems}set totalItems(o){this.grid.totalItems=o}get showPagination(){return this.grid.showPagination}set showPagination(o){this.grid.showPagination=o}get paginationPosition(){return this.grid.paginationPosition}set paginationPosition(o){this.grid.paginationPosition=o}get paginationLabelsCallback(){return this.grid.paginationLabelsCallback}set paginationLabelsCallback(o){this.grid.paginationLabelsCallback=o}get paginationLayout(){return this.grid.paginationLayout}set paginationLayout(o){this.grid.paginationLayout=o}get summaryPosition(){return this.grid.summaryPosition}set summaryPosition(o){this.grid.summaryPosition=o}get summaryContentCallback(){return this.grid.summaryContentCallback}set summaryContentCallback(o){this.grid.summaryContentCallback=o}get customStylesCallback(){return this.grid.customStylesCallback}set customStylesCallback(o){this.grid.customStylesCallback=o,this.updateCustomStyles()}get rowClassCallback(){return this.grid.rowClassCallback}set rowClassCallback(o){this.grid.rowClassCallback=o}get labels(){return this.grid.labels}set labels(o){this.grid.labels=o}get summaryMetadata(){return this.grid.summaryMetadata}set summaryMetadata(o){this.grid.summaryMetadata=o}get isSummaryInline(){return this.grid.isSummaryInline}set isSummaryInline(o){this.grid.isSummaryInline=o}get idValueMember(){return this.grid.idValueMember}set idValueMember(o){this.grid.idValueMember=o}get idValueCallback(){return this.grid.idValueCallback}set idValueCallback(o){this.grid.idValueCallback=o}get rowLocking(){return this.grid.rowLocking}set rowLocking(o){this.grid.rowLocking=o}get onrowlockchange(){return this.grid.onrowlockchange}set onrowlockchange(o){this.grid.onrowlockchange=o}get gridName(){return this.grid.gridName}set gridName(o){this.grid.gridName=o,this.tryLoadPersistedWidths()}get shouldPersistColumnWidths(){return this.grid.shouldPersistColumnWidths}set shouldPersistColumnWidths(o){this.grid.shouldPersistColumnWidths=o,this.tryLoadPersistedState()}get isColumnReorderAllowed(){return this.grid.isColumnReorderAllowed}set isColumnReorderAllowed(o){this.grid.isColumnReorderAllowed=o}get shouldPersistColumnOrder(){return this.grid.shouldPersistColumnOrder}set shouldPersistColumnOrder(o){this.grid.shouldPersistColumnOrder=o,this.tryLoadPersistedState()}tryLoadPersistedState(){this.grid.gridName&&(this.grid.shouldPersistColumnWidths||this.grid.shouldPersistColumnOrder)&&(this.grid.loadPersistedState(),this.isConnected&&this.render())}tryLoadPersistedWidths(){this.tryLoadPersistedState()}get oncolumnresize(){return this.grid.oncolumnresize}set oncolumnresize(o){this.grid.oncolumnresize=o}get oncolumnreorder(){return this.grid.oncolumnreorder}set oncolumnreorder(o){this.grid.oncolumnreorder=o}get fillDragCallback(){return this.grid.fillDragCallback}set fillDragCallback(o){this.grid.fillDragCallback=o}get isScrollable(){return this.grid.isScrollable}set isScrollable(o){this.grid.isScrollable=o}get scrollMaxHeight(){return this.grid.scrollMaxHeight}set scrollMaxHeight(o){this.grid.scrollMaxHeight=o}get tableBorderOnly(){return this.grid.tableBorderOnly}set tableBorderOnly(o){this.grid.tableBorderOnly=o}get isVirtualScrollEnabled(){return this.grid.isVirtualScrollEnabled}set isVirtualScrollEnabled(o){this.grid.isVirtualScrollEnabled=o}get virtualScrollThreshold(){return this.grid.virtualScrollThreshold}set virtualScrollThreshold(o){this.grid.virtualScrollThreshold=o}get virtualScrollRowHeight(){return this.grid.virtualScrollRowHeight}set virtualScrollRowHeight(o){this.grid.virtualScrollRowHeight=o}get virtualScrollBuffer(){return this.grid.virtualScrollBuffer}set virtualScrollBuffer(o){this.grid.virtualScrollBuffer=o}get isInfiniteScrollEnabled(){return this.grid.isInfiniteScrollEnabled}set isInfiniteScrollEnabled(o){this.grid.isInfiniteScrollEnabled=o}get infiniteScrollThreshold(){return this.grid.infiniteScrollThreshold}set infiniteScrollThreshold(o){this.grid.infiniteScrollThreshold=o}get hasMoreItems(){return this.grid.hasMoreItems}set hasMoreItems(o){this.grid.hasMoreItems=o}get displayItems(){return this.grid.displayItems}get totalPages(){return this.grid.totalPages}get isNavigateMode(){return this.grid.isNavigateMode}getRowDraft(o){return this.grid.getRowDraft(o)}hasRowDraft(o){return this.grid.hasRowDraft(o)}discardRowDraft(o){this.grid.discardRowDraft(o)}getDraftRowIndices(){return this.grid.getDraftRowIndices()}discardAllDrafts(){this.grid.discardAllDrafts()}isCellInvalid(o,i){return this.grid.isCellInvalid(o,i)}getCellValidationError(o,i){return this.grid.getCellValidationError(o,i)}getRowId(o){return this.grid.getRowId(o)}findRowById(o){return this.grid.findRowById(o)}isRowLocked(o){return this.grid.isRowLocked(o)}getRowLockInfo(o){return this.grid.getRowLockInfo(o)}lockRowById(o,i){return this.grid.lockRowById(o,i)}unlockRowById(o){return this.grid.unlockRowById(o)}getExternalLocks(){return this.grid.getExternalLocks()}clearExternalLocks(){this.grid.clearExternalLocks()}updateRowById(o,i){return this.grid.updateRowById(o,i)}replaceRowById(o,i){return this.grid.replaceRowById(o,i)}canEditCell(o,i){return this.grid.canEditCell(o,i)}setColumnWidth(o,i){this.grid.setColumnWidth(o,i)}setColumnWidths(o){this.grid.setColumnWidths(o)}getColumnWidthsState(){return this.grid.getColumnWidthsState()}setColumnOrder(o){this.grid.setColumnOrder(o)}getColumnOrderState(){return this.grid.getColumnOrderState()}focusCell(o,i){const r=this.grid.columns,s=this.grid.displayItems;o<0||o>=s.length||i<0||i>=r.length||(this.grid.setFocusedCell(o,i),requestAnimationFrame(()=>{V(this,o,i)}))}startEditing(o,i){const r=this.grid.columns;if(i<0||i>=r.length)return;const s=r[i],n=String(s.field);this.grid.startEdit(o,n);const l=this.shadow.querySelector(`td[data-row="${o}"][data-col="${i}"]`);l&&(l.classList.remove("wg__cell--focused"),l.classList.add("wg__cell--editing"),l.innerHTML=At(this,o,i,s))}escapeHtml(o){const i=document.createElement("div");return i.textContent=o,i.innerHTML}getCurrentEditingColumn(){const o=this.grid.editingCell;return o&&this.grid.columns.find(i=>String(i.field)===o.field)||null}getCurrentEditorOptions(){const o=this.getCurrentEditingColumn();return(o==null?void 0:o.editorOptions)||{}}moveFocusAfterCommit(o,i,r){wo(this,o,i,r)}requestUpdate(){this.updatePending||(Jo.debug("requestUpdate: scheduling render"),this.updatePending=!0,queueMicrotask(()=>{this.updatePending=!1,this.render()}))}updateCustomStyles(){const o=this.grid.customStylesCallback;if(o){const i=o();this.customStyleElement||(this.customStyleElement=document.createElement("style"),this.shadow.appendChild(this.customStyleElement)),this.customStyleElement.textContent=i}else this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}handleCellKeyDown(o,i,r){var u;if(!this.grid.isNavigateMode)return;const s=this.grid.columns,n=this.grid.displayItems,l=this.grid.getEditableColumns(),a=l.findIndex(g=>g.index===r);if((o.ctrlKey||o.metaKey)&&o.key==="c"){if(this.grid.selectedCellRange){o.preventDefault(),this.grid.copyCellSelectionToClipboard();return}const g=s[r],h=n[i];if(g&&h){let f=this.grid.getCellRawValue(h,i,String(g.field));g.beforeCopyCallback&&(f=g.beforeCopyCallback(f,h));const w=f!=null?String(f):"";navigator.clipboard.writeText(w)}return}const d=this.grid.selectedRows;if(d.length>0){const g=this.grid.rangeShortcuts;if(g&&g.length>0)for(const h of g){const f=wt(h.key);if(pt(o,f)){const w={rows:this.grid.getSelectedRowsData(),rowIndices:d};if(!(typeof h.disabled=="function"?h.disabled(w):h.disabled===!0)){o.preventDefault(),h.action(w);return}}}}const c=this.grid.rowShortcuts;if(c&&c.length>0){const g=s[r],h=n[i];if(g&&h)for(const f of c){const w=wt(f.key);if(pt(o,w)){const p={row:h,rowIndex:i,colIndex:r,column:g,cellValue:this.grid.getCellRawValue(h,i,String(g.field))};if(!(typeof f.disabled=="function"?f.disabled(p):f.disabled===!0)){o.preventDefault(),f.action(p);return}}}}switch(o.key){case"ArrowUp":o.preventDefault(),i>0&&V(this,i-1,r);break;case"ArrowDown":o.preventDefault(),i<n.length-1&&V(this,i+1,r);break;case"ArrowLeft":o.preventDefault(),r>0&&V(this,i,r-1);break;case"ArrowRight":o.preventDefault(),r<s.length-1&&V(this,i,r+1);break;case"Tab":if(o.preventDefault(),o.shiftKey){if(a>0){const g=l[a-1].index;V(this,i,g)}else if(i>0){const g=l[l.length-1].index;V(this,i-1,g)}}else if(a>=0&&a<l.length-1){const g=l[a+1].index;V(this,i,g)}else if(a===-1&&l.length>0)V(this,i,l[0].index);else if(i<n.length-1){const g=l[0].index;V(this,i+1,g)}else this.grid.isEmptyRowIndex(i)&&V(this,i,l[0].index);break;case"Home":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(0,0),this.scrollToRowProgrammatically(0);const h=this.shadow.querySelector('td[data-row="0"][data-col="0"]');h&&(h.focus({preventScroll:!0}),J(this,g,{rowIndex:0,colIndex:0}))}else V(this,0,0);else V(this,i,0);break;case"End":if(o.preventDefault(),o.ctrlKey){const g=n.length-1,h=s.length-1;if(this.grid.shouldUseVirtualScroll()){const f=this.grid.focusedCell;this.grid.setFocusedCell(g,h),this.scrollToRowProgrammatically(g);const w=this.shadow.querySelector(`td[data-row="${g}"][data-col="${h}"]`);w&&(w.focus({preventScroll:!0}),J(this,f,{rowIndex:g,colIndex:h}))}else V(this,g,h)}else V(this,i,s.length-1);break;case"PageUp":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(0,r),this.scrollToRowProgrammatically(0);const h=this.shadow.querySelector(`td[data-row="0"][data-col="${r}"]`);h&&(h.focus({preventScroll:!0}),J(this,g,{rowIndex:0,colIndex:r}))}else V(this,0,r);else{const g=Math.max(0,i-10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(g,r),this.scrollToRowProgrammatically(g);const f=this.shadow.querySelector(`td[data-row="${g}"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),J(this,h,{rowIndex:g,colIndex:r}))}else V(this,g,r)}break;case"PageDown":if(o.preventDefault(),o.ctrlKey){const g=n.length-1;if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(g,r),this.scrollToRowProgrammatically(g);const f=this.shadow.querySelector(`td[data-row="${g}"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),J(this,h,{rowIndex:g,colIndex:r}))}else V(this,g,r)}else{const g=Math.min(n.length-1,i+10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(g,r),this.scrollToRowProgrammatically(g);const f=this.shadow.querySelector(`td[data-row="${g}"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),J(this,h,{rowIndex:g,colIndex:r}))}else V(this,g,r)}break;case"g":case"G":o.ctrlKey&&(o.preventDefault(),this.showGoToRowDialog(r));break;case"Enter":{o.preventDefault();const g=s[r],h=(g==null?void 0:g.editor)==="select"||(g==null?void 0:g.editor)==="combobox"||(g==null?void 0:g.editor)==="autocomplete",f=this.grid.isEmptyRowIndex(i);if(h&&this.grid.getEffectiveShouldOpenDropdownOnEnter(g))se(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||we(this)});else if(f&&g&&this.grid.isCellEditable(g))se(this,i,r);else if(i<n.length-1){const w=this.grid.tabTraversalStartColIndex??r;this.grid.tabTraversalStartColIndex=null,V(this,i+1,w)}break}case"F2":{o.preventDefault();const g=s[r],h=(g==null?void 0:g.editor)==="select"||(g==null?void 0:g.editor)==="combobox"||(g==null?void 0:g.editor)==="autocomplete",f=(g==null?void 0:g.editor)==="custom";se(this,i,r),h?requestAnimationFrame(()=>{this.dropdownOpen||we(this)}):f&&requestAnimationFrame(()=>{this.openCustomEditor(i,r)});break}case" ":{o.preventDefault();const g=s[r],h=(g==null?void 0:g.editor)==="checkbox",f=(g==null?void 0:g.editor)==="select"||(g==null?void 0:g.editor)==="combobox"||(g==null?void 0:g.editor)==="autocomplete",w=(g==null?void 0:g.editor)==="date",p=(g==null?void 0:g.editor)==="custom";h&&g&&this.grid.isCellEditable(g)?cs(this,i,r):f?(se(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||we(this)})):w?(se(this,i,r),requestAnimationFrame(()=>{var x;const m=(x=this.shadowRoot)==null?void 0:x.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`),v=m==null?void 0:m.querySelector(".wg__date-input"),y=m==null?void 0:m.querySelector(".wg__editor--date");v&&y&&this.openDatePicker(v,y)})):p&&(se(this,i,r),requestAnimationFrame(()=>{this.openCustomEditor(i,r)}));break}case"Escape":if(o.preventDefault(),this.grid.editingCell)K(this),this.grid.cancelEdit();else if(this.grid.selectedRows.length>0)this.grid.clearSelection();else{const g=this.grid.focusedCell;this.grid.clearFocusedCell(),J(this,g,null),(u=o.target)==null||u.blur()}break;case"Delete":{o.preventDefault();const g=s[r],h=n[i];if(o.ctrlKey){if(h){const f={rowIndex:i,row:h};this.grid.onrowdelete&&this.grid.onrowdelete(f),this.dispatchEvent(new CustomEvent("rowdelete",{detail:f}))}}else g&&this.grid.isCellEditable(g)&&(this.grid.commitEdit(i,String(g.field),null),this.render(),requestAnimationFrame(()=>{const f=this.shadow.querySelector(`td[data-row="${i}"][data-col="${r}"]`);f==null||f.focus()}));break}default:if(o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey){const g=s[r];if((g==null?void 0:g.editor)==="number"&&!/[\d.\-]/.test(o.key))return;se(this,i,r,{initialSearchQuery:o.key}),o.preventDefault()}break}}async handleEditorKeyDown(o,i){const r=parseInt(i.dataset.row||"0",10),s=i.dataset.field||"",n=this.grid.columns.find(c=>c.field===s),l=(n==null?void 0:n.editor)||"text",a=l==="select"||l==="combobox"||l==="autocomplete",d=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"];if(a&&!this.dropdownOpen&&d.includes(o.key)){o.preventDefault(),o.stopPropagation();const c=this.grid.columns.findIndex(m=>m.field===s),u=this.grid.columns.map((m,v)=>({index:v,column:m})).filter(m=>m.column.isEditable!==!1),g=u.findIndex(m=>m.index===c),h=this.grid.displayItems;let f=r,w=c,p=!1;switch(o.key){case"ArrowUp":r>0&&(f=r-1,p=!0);break;case"ArrowDown":r<h.length-1&&(f=r+1,p=!0);break;case"ArrowLeft":g>0&&(w=u[g-1].index,p=!0);break;case"ArrowRight":g<u.length-1&&(w=u[g+1].index,p=!0);break;case"PageUp":f=Math.max(0,r-10),p=!0;break;case"PageDown":f=Math.min(h.length-1,r+10),p=!0;break;case"Home":o.ctrlKey&&(f=0),w=0,p=!0;break;case"End":o.ctrlKey?(f=h.length-1,w=this.grid.columns.length-1):w=this.grid.columns.length-1,p=!0;break}p&&(K(this),this.grid.cancelEdit(),queueMicrotask(()=>{V(this,f,w)}));return}switch(o.key){case"ArrowDown":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const p=this.getCurrentEditorOptions();let m=this.highlightedIndex+1;for(;m<this.dropdownOptions.length&&de(this.dropdownOptions[m],p);)m++;m<this.dropdownOptions.length&&(this.highlightedIndex=m,fe(this),bo(this))}break;case"ArrowUp":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const p=this.getCurrentEditorOptions();let m=this.highlightedIndex-1;for(;m>=0&&de(this.dropdownOptions[m],p);)m--;m>=0&&(this.highlightedIndex=m,fe(this),bo(this))}break;case"Enter":if(this.datepicker)return;o.preventDefault(),o.stopPropagation(),this.dropdownOpen&&this.highlightedIndex>=0?wi(this,this.highlightedIndex,!0,!0):a&&!this.dropdownOpen?we(this):(this.isCommittingFromKeyboard=!0,q(this),l==="date"&&i instanceof HTMLInputElement?await this.commitDateEditor(i,!0):await $t(this,i,!0),wo(this,r,s,"down"));break;case"Tab":if(this.datepicker)return;o.preventDefault(),o.stopPropagation(),this.isCommittingFromKeyboard=!0;const c=this.grid.getEditableColumns(),u=this.grid.columns.findIndex(p=>String(p.field)===s),g=c.findIndex(p=>p.index===u),h=this.grid.isEmptyRowIndex(r),f=g===c.length-1,w=h&&f&&!o.shiftKey;if(this.dropdownOpen&&this.highlightedIndex>=0&&a){const p=this.dropdownOptions[this.highlightedIndex],m=this.getCurrentEditorOptions();if(p&&!de(p,m)){const v=Ae(p,m);await this.grid.commitEdit(r,s,v,w)}q(this)}else q(this),l==="date"&&i instanceof HTMLInputElement?await this.commitDateEditor(i,w):a||await $t(this,i,w);if(w){Mt(this,r,u);const p=c.length>0?c[0].index:0;queueMicrotask(()=>{const m=this.grid.newRowPosition==="top"?0:this.grid.displayItems.length-1;V(this,m,p),this.isCommittingFromKeyboard=!1})}else wo(this,r,s,o.shiftKey?"prev":"next");break;case"Escape":if(o.preventDefault(),o.stopPropagation(),this.dropdownOpen){q(this),(l==="autocomplete"||l==="combobox")&&(this.filterText="",i instanceof HTMLInputElement&&(i.value="",i.focus()));return}if(this.datepicker){this.datepicker.close(!0),this.datepicker=null;return}this.isCommittingFromKeyboard=!0,K(this),this.grid.cancelEdit(),us(this,r,s);break;case"F2":o.preventDefault(),o.stopPropagation(),a&&!this.dropdownOpen&&we(this);break;case"Backspace":l==="select"&&(o.preventDefault(),o.stopPropagation(),this.filterText.length>0&&(this.filterText=this.filterText.slice(0,-1),pi(this,n.editorOptions||{})));break;default:l==="select"&&o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),o.stopPropagation(),this.filterText+=o.key,pi(this,n.editorOptions||{}));break}}attachEventListeners(){const o=this.shadow.querySelector(".wg__table");if(!o)return;o.addEventListener("mousedown",()=>{this._isMouseDown=!0},!0),document.addEventListener("mouseup",()=>{this._isMouseDown=!1},!0),o.addEventListener("focus",n=>{const l=n.target;if(l.matches(".wg__cell")){const a=parseInt(l.dataset.row||"0",10),d=parseInt(l.dataset.col||"0",10);if(ss(this,a,d),Lt(this),!this._isMouseDown&&!yo()&&!$i()){const c=this.grid.focusedRowIndex;this.grid.setFocusedRow(a),this.updateRowFocusVisual(c,a)}fo(this,l,a)}if(l.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger")){const a=l.closest(".wg__cell");if(a){const d=parseInt(a.dataset.row||"0",10),c=parseInt(a.dataset.col||"0",10),u=this.grid.columns[c];if(((u==null?void 0:u.editTrigger)??this.grid.editTrigger)==="always"){const h=this.grid.focusedCell;if(!h||h.rowIndex!==d||h.colIndex!==c){if(this.grid.setFocusedCell(d,c),h){const f=this.shadow.querySelector(`td[data-row="${h.rowIndex}"][data-col="${h.colIndex}"]`);f&&f.classList.remove("wg__cell--always-edit-focused")}if(a.classList.add("wg__cell--always-edit-focused"),!this._isMouseDown){const f=this.grid.focusedRowIndex;this.grid.setFocusedRow(d),this.updateRowFocusVisual(f,d)}}}}}},!0),o.addEventListener("keydown",n=>{var a;const l=n.target;if(!((a=this.pipelineAdapter)!=null&&a.tryHandleKeyDown(n))){if(this.datepicker){const d=n.key;if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(d))return}if(l.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input")){this.handleEditorKeyDown(n,l);return}if(l.matches(".wg__cell")){const d=parseInt(l.dataset.row||"0",10),c=parseInt(l.dataset.col||"0",10);this.handleCellKeyDown(n,d,c)}}}),this.focusEvents.init(o),this.focusEvents.subscribe("focusout",(n,l)=>{(!l||!o.contains(l))&&ls(this,{relatedTarget:l})}),o.addEventListener("dblclick",n=>{var d;if((d=this.pipelineAdapter)!=null&&d.tryHandleDblClick(n))return;n.preventDefault();const a=n.target.closest(".wg__cell");if(a){const c=parseInt(a.dataset.row||"0",10),u=parseInt(a.dataset.col||"0",10),g=this.grid.columns[u];if(g){const h=g.editTrigger||this.grid.editTrigger;if(h==="dblclick"||h==="navigate"){const f=ht(n,a);se(this,c,u,{cursorPosition:f??void 0});const w=g.editor;w==="select"||w==="combobox"||w==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||we(this)}):w==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(c,u)})}}}}),o.addEventListener("click",n=>{var d;if((d=this.pipelineAdapter)!=null&&d.tryHandleClick(n))return;const a=n.target.closest(".wg__cell");if(a&&!a.classList.contains("wg__cell--editing")){const c=parseInt(a.dataset.row||"0",10),u=parseInt(a.dataset.col||"0",10),g=this.grid.columns[u];if(g&&(g.editTrigger||this.grid.editTrigger)==="click"){n.preventDefault();const f=ht(n,a);se(this,c,u,{cursorPosition:f??void 0});const w=g.editor;w==="select"||w==="combobox"||w==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||we(this)}):w==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(c,u)})}}}),o.addEventListener("mousedown",n=>{var g,h;const l=n.target,a=n;if((g=this.pipelineAdapter)!=null&&g.tryHandleMouseDown(a))return;const d=l.closest(".wg__cell"),c=l.closest(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(d&&!d.classList.contains("wg__cell--editing")&&!l.closest(".wg__row-number")&&!c){const f=parseInt(d.dataset.row||"0",10),w=parseInt(d.dataset.col||"0",10),p=(h=this.grid.visualColumns[w])==null?void 0:h.column;if(p){const m=this.grid.cellSelectionMode,v=a.shiftKey;if(p.editTrigger||this.grid.editTrigger,m!=="disabled"&&(m==="click"&&!v||m==="shift"&&v)){if(this.grid.editingCell){const x=this.grid.editingCell,C=this.grid.columns.findIndex(_=>String(_.field)===x.field);q(this),K(this),this.grid.cancelEdit(),C>=0&&H(this,x.rowIndex,C)}this.grid.selectedRows.length>0&&this.grid.clearSelection(),this.grid.selectedColumns.length>0&&this.grid.clearColumnSelection(),Ai(this,f,w,a);return}else this.grid.selectedCellRange&&(this.grid.clearCellSelection(),G())}}if(l.closest(".wg__date-trigger")){n.preventDefault(),n.stopPropagation();const f=l.closest(".wg__cell-date-display"),w=l.closest(".wg__editor--date");if(w){const p=w.querySelector(".wg__date-input");p&&this.openDatePicker(p,w)}else if(f){const p=parseInt(f.dataset.row||"0",10),m=f.dataset.field||"",v=this.grid.columns.findIndex(y=>String(y.field)===m);if(v>=0){if(this.clearAllSelections(),this.isTransitioningCells=!0,this.grid.editingCell){const y=this.grid.editingCell,x=this.grid.columns.findIndex(C=>String(C.field)===y.field);q(this),K(this),this.grid.cancelEdit(),this.grid.setFocusedCell(p,v),x>=0&&H(this,y.rowIndex,x)}se(this,p,v),requestAnimationFrame(()=>{var _;this.isTransitioningCells=!1;const y=(_=this.shadowRoot)==null?void 0:_.querySelector(`.wg__cell[data-row="${p}"][data-field="${m}"]`),x=y==null?void 0:y.querySelector(".wg__date-input"),C=y==null?void 0:y.querySelector(".wg__editor--date");x&&C&&this.openDatePicker(x,C)})}}return}if(this.dropdownOpen||this.grid.editingCell){const f=l.closest(".wg__cell");if(f&&!l.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete, .wg__editor--date")){const w=parseInt(f.dataset.row||"0",10),p=parseInt(f.dataset.col||"0",10),m=this.grid.editingCell,v=l.matches(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(m&&!v){const y=this.grid.columns.findIndex(x=>String(x.field)===m.field);if(w!==m.rowIndex||p!==y){n.preventDefault(),this.isTransitioningCells=!0;const x=m.rowIndex,C=y;q(this),K(this),this.grid.cancelEdit(),this.grid.setFocusedCell(w,p),C>=0&&H(this,x,C);const _=this.grid.columns[p],S=(_==null?void 0:_.editTrigger)||this.grid.editTrigger,E=n.clientX;requestAnimationFrame(()=>{if(this.isTransitioningCells=!1,S==="click"&&_&&this.grid.isCellEditable(_)){const R=this.shadow.querySelector(`td[data-row="${w}"][data-col="${p}"]`),I=R?ht({clientX:E},R):void 0;se(this,w,p,{cursorPosition:I??void 0})}else V(this,w,p)});return}}}}if(l.matches(".wg__cell-dropdown-display")){n.preventDefault(),n.stopPropagation();const f=l.closest(".wg__cell-dropdown-display");if(f){const w=parseInt(f.dataset.row||"0",10),p=f.dataset.field||"",m=this.grid.columns.findIndex(v=>String(v.field)===p);if(m>=0){this.isTransitioningCells=!0;const v=this.grid.editingCell,y=v?this.grid.columns.findIndex(x=>String(x.field)===v.field):-1;v&&(q(this),K(this),this.grid.cancelEdit(),this.grid.setFocusedCell(w,m),y>=0&&H(this,v.rowIndex,y)),se(this,w,m),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||we(this)})}}}}),o.addEventListener("click",n=>{const l=n.target;if(l.matches(".wg__select-trigger, .wg__select-value")){const a=l.closest(".wg__cell");if(a){const d=parseInt(a.dataset.col||"",10),c=this.grid.columns[d];if(((c==null?void 0:c.editTrigger)??this.grid.editTrigger)==="always")return}n.preventDefault(),n.stopPropagation(),Ms(this)}}),o.addEventListener("mousedown",n=>{const l=n.target,a=l.closest(".wg__resize-handle");if(a){n.preventDefault(),n.stopPropagation(),this.clearAllSelections();const g=a.dataset.field;g&&js(this,n,g);return}if(this.grid.isColumnReorderAllowed){const g=n;if(!g.ctrlKey&&!g.metaKey&&!g.shiftKey){const h=l.closest(".wg__header");if(h&&!h.classList.contains("wg__header--frozen")&&!h.classList.contains("wg__row-number-header")){this.clearAllSelections();const f=h.dataset.field;f&&Zs(this,n,f)}}}if((!this.grid.isColumnReorderAllowed||n.shiftKey)&&n.button===0){const g=l.closest(".wg__header:not(.wg__row-number-header):not(.wg__inline-actions-header):not(.wg__actions-column):not(.wg__filler)");if(g&&!l.closest(".wg__resize-handle")&&!l.closest(".wg__sort-indicator")){const h=g.dataset.field;if(h){const f=this.grid.visualColumns.findIndex(w=>String(w.column.field)===h);f>=0&&Cl(this,f,n)}}}const d=l.closest(".wg__row-number[data-row-number]");if(d&&n.button===0){const g=parseInt(d.dataset.rowNumber||"-1",10);g>=0&&pl(this,g,n)}l.closest(".wg__row-number-header")&&n.button===0&&(n.preventDefault(),this.grid.selectAll(),this.grid.selectedCellRange&&Ot(this),this.render(),requestAnimationFrame(()=>{const g=this.shadow.querySelector(".wg");g==null||g.focus({preventScroll:!0})}));const u=l.closest(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");if(u&&!l.closest(".wg__header")&&!yo()&&!$i()){const g=parseInt(u.dataset.row||"-1",10);if(g>=0){const h=this.grid.focusedRowIndex;this.grid.setFocusedRow(g),this.updateRowFocusVisual(h,g)}}if(l.closest(".wg__cell")&&!l.closest(".wg__row-number, .wg__header")&&!yo()){let g=!1;this.grid.selectedRows.length>0&&(this.grid.clearSelection(),g=!0),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),g=!0),g&&this.render()}if(!l.closest(".wg__cell, .wg__row-number, .wg__header, .wg__toolbar, button, input, select, textarea")){let g=!1;this.grid.selectedCellRange&&(this.grid.clearCellSelection(),G(),g=!0),this.grid.selectedRows.length>0&&(this.grid.clearSelection(),g=!0),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),g=!0),g&&this.render()}}),o.addEventListener("click",n=>{const l=n,a=l.target;if(a.closest(".wg__resize-handle")||a.closest(".wg__sort-indicator")||Ii()||!this.grid.isColumnReorderAllowed)return;const d=a.closest(".wg__header:not(.wg__row-number-header):not(.wg__inline-actions-header):not(.wg__actions-column):not(.wg__filler)");if(d){n.preventDefault();const c=d.dataset.field;if(!c)return;const u=this.grid.visualColumns.findIndex(g=>String(g.column.field)===c);if(u===-1)return;G(),l.ctrlKey||l.metaKey?this.grid.selectColumn(u,"toggle"):l.shiftKey?this.grid.selectColumn(u,"range"):this.grid.selectColumn(u,"replace"),this.render(),requestAnimationFrame(()=>{const g=this.shadow.querySelector(".wg");g==null||g.focus({preventScroll:!0})})}}),o.addEventListener("contextmenu",n=>{this.handleContextMenu(n)}),o.addEventListener("change",n=>{const l=n.target;l.matches(".wg__editor--checkbox")&&ds(this,l)}),o.addEventListener("input",n=>{const l=n.target;l.matches(".wg__combobox-input")?$s(this,n):l.matches(".wg__autocomplete-input")&&As(this,n)}),this.focusEventsSubscribed||(this.focusEvents.subscribe("blur",(n,l)=>{this.focusEvents.shouldSkipBlur()||!l||!this.shadow.contains(l)||(n.matches(".wg__editor--text, .wg__editor--number")?gs(this,n):n.matches(".wg__date-input")?this.datepicker||this.commitDateEditor(n):n.matches(".wg__select-trigger")?this.handleSelectBlur(l):n.matches(".wg__combobox-input, .wg__autocomplete-input")&&this.handleComboboxBlur(n))}),this.focusEventsSubscribed=!0);const i=this.shadow.querySelector(".wg"),r=this.grid.tableBorderOnly&&this.shadow.querySelector(".wg__table-container")||i;i&&(i.setAttribute("tabindex","-1"),i.addEventListener("keydown",n=>{const l=this.grid.selectedRows,a=this.grid.selectedColumns,d=!!this.grid.selectedCellRange;if(l.length===0&&a.length===0&&!d||n.target.matches('input, textarea, select, [contenteditable="true"]'))return;if(n.key==="Escape"){n.preventDefault(),this.grid.selectedCellRange?(this.grid.clearCellSelection(),G()):a.length>0?this.grid.clearColumnSelection():this.grid.clearSelection();return}if((n.ctrlKey||n.metaKey)&&n.key==="c"){n.preventDefault(),d?this.grid.copyCellSelectionToClipboard():a.length>0?this.grid.copySelectedColumnsToClipboard():l.length>0&&this.grid.copySelectedRowsToClipboard();return}const u=this.grid.rangeShortcuts;if(u!=null&&u.length)for(const g of u){const h=wt(g.key);if(pt(n,h)){const f=d?{rows:[],rowIndices:[],cellRange:this.grid.selectedCellRange,cells:this.grid.getSelectedCells()}:{rows:this.grid.getSelectedRowsData(),rowIndices:l};if(!(typeof g.disabled=="function"?g.disabled(f):g.disabled===!0)){n.preventDefault(),g.action(f);return}}}}),this.scrollEvents.init(r),this.scrollEvents.subscribe("container",()=>{const n=r.scrollLeft>0;i.classList.toggle("wg--scrolled-horizontal",n),this.dropdownOpen&&!this.isTransitioningCells&&!this.isOpeningDropdown&&this.handleScrollCloseDropdown(),this.grid.shouldUseVirtualScroll()&&this.handleVirtualScroll(r),this.grid.isInfiniteScrollEnabled&&this.grid.hasMoreItems&&!this.isLoadingMoreItems&&this.handleInfiniteScroll(r),We()!==null&&(ii(this,this.grid.displayItems),this.renderConnector()),Lt(this),this.grid.selectedCellRange&&qi(this),_l(this)}),this.scrollEvents.subscribe("window",()=>{this.dropdownOpen&&!this.isTransitioningCells&&this.handleScrollCloseDropdown(),We()!==null&&this.closeToolbarAndReset()}),this.clickEventsSubscribed||(this.clickEvents.init(i,this),this.clickEvents.subscribe("outsideClick",()=>{let n=!1;if(this.grid.focusedCell){const{rowIndex:l,colIndex:a}=this.grid.focusedCell,d=this.shadow.querySelector(`.wg__cell[data-row="${l}"][data-col="${a}"]`);d==null||d.classList.remove("wg__cell--focused","wg__cell--always-edit-focused"),this.grid.clearFocusedCell()}if(this.grid.focusedRowIndex!==null&&(this.grid.clearRowFocus(),n=!0),this.dropdownOpen||this.grid.editingCell){const l=this.grid.editingCell,a=l?this.grid.columns.findIndex(d=>String(d.field)===l.field):-1;q(this),K(this),this.grid.cancelEdit(),l&&a>=0&&H(this,l.rowIndex,a)}this.grid.selectedCellRange&&(this.grid.clearCellSelection(),G(),n=!0),this.grid.selectedRows.length>0&&(this.grid.clearSelection(),n=!0),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),n=!0),n&&this.render()}),this.clickEvents.subscribe("sortClick",n=>{Ii()||(this.grid.selectedCellRange&&(this.grid.clearCellSelection(),G()),this.grid.selectedRows.length>0&&(this.grid.clearSelection(),et()),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),tt()),Ys(this,n.event,n.field),this.render())}),this.clickEventsSubscribed=!0)),o.addEventListener("mouseenter",n=>{const l=n.target,a=l.closest("[data-tooltip-html]");if(a){const c=a.getAttribute("data-tooltip-html");vo(this,a,c,this._tooltipShowDelay,!0);return}const d=l.closest("[data-tooltip]");if(d){const c=d.getAttribute("data-tooltip");vo(this,d,c,this._tooltipShowDelay,!1)}},!0),o.addEventListener("mouseleave",n=>{const l=n,a=l.target,d=l.relatedTarget,c=a.closest("[data-tooltip], [data-tooltip-html]");c&&(d==null?void 0:d.closest("[data-tooltip], [data-tooltip-html]"))===c||c&&zt(this,this._tooltipHideDelay)},!0),o.addEventListener("click",n=>{const a=n.target.closest(".wg__toolbar-trigger");if(a&&this.grid.toolbarTrigger==="button"){n.preventDefault(),n.stopPropagation();const d=parseInt(a.dataset.toolbarTrigger||"0",10),c=o.querySelector(`tr[data-row-index="${d}"]`);c&&(lo(d)?this.closeToolbarAndReset():this.showToolbarForRow(c,d))}}),o.addEventListener("click",n=>{if(this.grid.toolbarPosition!=="inline")return;const a=n.target.closest(".wg__inline-action-btn");if(a&&!a.disabled){n.preventDefault(),n.stopPropagation();const d=a.dataset.actionId,c=parseInt(a.dataset.row||"0",10);this.handleInlineActionClick(d,c,n,a)}}),o.addEventListener("mouseenter",n=>{const l=n,d=l.target.closest(".wg__row");if(d){const c=parseInt(d.dataset.rowIndex||"0",10);this.grid.setHoveredRow(c),this.grid.toolbarPosition==="inline"&&this.setupInlineShortcuts(),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline"&&(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),lo(c)||this.showToolbarForRow(d,c,l.clientX))}},!0),o.addEventListener("mouseleave",n=>{if(n.target.closest(".wg__row")&&(this.grid.toolbarPosition==="inline"&&setTimeout(()=>{o.matches(":hover")||(this.grid.setHoveredRow(null),this.removeInlineShortcuts())},50),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline")){if(this.toolbarMoveInProgress)return;this.toolbarHideTimeout&&clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=setTimeout(()=>{const c=this.shadow.querySelector(".wg__toolbar-container"),u=c==null?void 0:c.matches(":hover"),g=o.matches(":hover");!u&&!g&&(this.grid.setHoveredRow(null),this.closeToolbarAndReset())},150)}},!0),o.addEventListener("mousemove",n=>{const l=n,a=l.target,d=a.closest(".wg__row");if(!d)return;const c=parseInt(d.dataset.rowIndex||"0",10);if(!(We()!==c||this.grid.toolbarPosition!=="top")){if(this.grid.toolbarFollowsCursor&&!this.grid.cellToolbar&&this.grid.toolbarColumn===void 0){const g=a.closest(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");if(g){const h=g.getBoundingClientRect(),f=so(h,this.grid.cellToolbarOffset);ao(f,d,"start")}else ao(l.clientX)}if(this.grid.cellToolbar){const g=a.closest(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");if(g){const h=g.dataset.field||"",f=this.grid.visualColumns.findIndex(p=>String(p.column.field)===h);if(!this.hoveredCell||this.hoveredCell.rowIndex!==c||this.hoveredCell.field!==h){this.hoveredCell={rowIndex:c,colIndex:f,field:h};const p=this.grid.displayItems[c];if(p){const v=this.grid.cellToolbar(p,c,h,f)||this.grid.rowToolbar,y=JSON.stringify(v);y!==this.currentCellToolbarItems&&(this.currentCellToolbarItems=y,this.updateToolbarWithCellItems(c,v));const x=g.getBoundingClientRect(),C=so(x,this.grid.cellToolbarOffset);ao(C,d,"start")}}}}}}),o.addEventListener("click",n=>{if(this.grid.toolbarTrigger!=="click")return;const l=n,a=l.target,d=a.closest(".wg__row");if(d&&!a.closest(".wg__cell--editing")){const c=parseInt(d.dataset.rowIndex||"0",10);lo(c)?this.closeToolbarAndReset():this.showToolbarForRow(d,c,l.clientX)}}),this.toolbarOutsideClickAdded||(this.toolbarOutsideClickAdded=!0,document.addEventListener("click",n=>{if(!oi(this.shadow))return;const l=n.composedPath(),a=l.some(u=>{var g;return(g=u.classList)==null?void 0:g.contains("wg__toolbar-container")}),d=l.some(u=>{var g;return(g=u.classList)==null?void 0:g.contains("wg__toolbar-trigger")});a||d||l.includes(this)&&(this.grid.toolbarTrigger==="hover"||this.grid.toolbarTrigger==="click")||We()!==null&&this.closeToolbarAndReset()})),this.shadow.querySelectorAll(".wg__pagination").forEach(n=>{n.addEventListener("click",a=>{Us(this,a)&&this.render()});const l=n.querySelector(".wg__pagination-select");l&&l.addEventListener("change",()=>{Ks(this,l)&&this.render()})})}scrollToRowProgrammatically(o){const i=this.shadow.querySelector(".wg");if(!i)return;const{scrollTop:r,startIndex:s,endIndex:n}=Bs({targetRow:o,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,viewportHeight:i.clientHeight,scrollHeight:i.scrollHeight,clientHeight:i.clientHeight});(s!==this.virtualScrollStart||n!==this.virtualScrollEnd)&&(this.virtualScrollStart=s,this.virtualScrollEnd=n,this.renderVirtualRows(i)),this.isProgrammaticScroll=!0,i.scrollTop=r,queueMicrotask(()=>{this.isProgrammaticScroll=!1})}handleVirtualScroll(o){var s;if(this.isProgrammaticScroll)return;const{startIndex:i,endIndex:r}=Ns({scrollTop:o.scrollTop,viewportHeight:o.clientHeight,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,editingRowIndex:(s=this.grid.editingCell)==null?void 0:s.rowIndex});(i!==this.virtualScrollStart||r!==this.virtualScrollEnd)&&(this.virtualScrollStart=i,this.virtualScrollEnd=r,this.renderVirtualRows(o))}renderVirtualRows(o){const i=o.querySelector("tbody");if(!i)return;const r=this.grid.displayItems,s={startIndex:this.virtualScrollStart,endIndex:this.virtualScrollEnd,rowHeight:this.grid.virtualScrollRowHeight,totalItems:r.length},n=this.grid.focusedCell;if(i.innerHTML=si(this,s),n){this.grid.setFocusedCell(n.rowIndex,n.colIndex);const l=i.querySelector(`td[data-row="${n.rowIndex}"][data-col="${n.colIndex}"]`);l&&(l.focus({preventScroll:!0}),J(this,null,n))}}handleInfiniteScroll(o){Ws(o.scrollTop,o.scrollHeight,o.clientHeight,this.grid.infiniteScrollThreshold)&&(this.isLoadingMoreItems=!0,this.grid.fireDataRequest("loadMore"))}renderShortcutsHelpIcon(){var n,l,a;if(!this.grid.isShortcutsHelpVisible||!((n=this.grid.rowShortcuts)!=null&&n.length))return"";const i=this.grid.shortcutsHelpPosition==="top-left"?"wg__shortcuts-help--left":"",r=this.grid.rowShortcuts.map(d=>`<div class="wg__shortcuts-help-item">
663
- <span class="wg__shortcuts-help-key">${qs(d.key)}</span>
658
+ `?(o.push(i),o.some(a=>a!=="")&&e.push(o),o=[],i="",n==="\r"&&s++):n!=="\r"&&(i+=n)}return(i!==""||o.length>0)&&(o.push(i),o.some(s=>s!=="")&&e.push(o)),e}function Ml(t,e){const o=new Map,i=new Map;e.forEach((a,d)=>{var h;if(a.isHidden)return;const c=String(a.field),u=((h=a.title)==null?void 0:h.toLowerCase().trim())||"";u&&o.set(u,{field:c,colIndex:d}),i.set(c.toLowerCase(),{field:c,colIndex:d})});const r=[];let s=0;for(const a of t){const d=a.trim().toLowerCase();if(!d)continue;const c=o.get(d)||i.get(d);c&&(s++,r.push({pastedHeader:a,gridField:c.field,colIndex:c.colIndex}))}const n=t.filter(a=>a.trim()!=="").length,l=Math.max(2,Math.floor(n*.5));return s>=l?r:null}async function $l(t,e,o,i){var v;const r=t.grid,s=Tl(e);if(s.length===0)return{totalCells:0,successfulCells:0,failedCells:0,skippedCells:0,newRowsCreated:0,cellResults:[],hadHeaders:!1};const n=Ml(s[0],r.columns),l=n!==null,a=l?s.slice(1):s;if(a.length===0)return{totalCells:0,successfulCells:0,failedCells:0,skippedCells:0,newRowsCreated:0,cellResults:[],hadHeaders:l};const d=r.visualColumns,c=r.isEmptyRowIndex(o),u=r.items.length;let h;if(c)h=a.length;else{const x=o+a.length-1;h=Math.max(0,x-u+1)}const g={rawText:e,parsedRows:s,hasHeaders:l,headerMapping:n,targetRowIndex:o,targetColIndex:i,newRowsCount:h,cancel:!1,skipCells:new Set};if(r.onbeforepaste&&(r.onbeforepaste(g),g.cancel))return{totalCells:a.reduce((x,k)=>x+k.length,0),successfulCells:0,failedCells:0,skippedCells:a.reduce((x,k)=>x+k.length,0),newRowsCreated:0,cellResults:[],hadHeaders:l};let f=0,w=u;if(h>0){const x=[];for(let k=0;k<h;k++){const E=c?k:u+k-o,I=a[E],R={};l&&n?I==null||I.forEach((D,M)=>{const A=n[M];A&&(R[A.gridField]=D)}):I==null||I.forEach((D,M)=>{const A=i+M;if(A<d.length){const F=String(d[A].column.field);R[F]=D}});let P;r.createRowCallback?P=r.createRowCallback(R,u+k):P=R,x.push(P),f++}c&&r.newRowPosition==="top"?(r.items=[...x,...r.items],w=0):(r.items=[...r.items,...x],w=u)}const p=[],m=r.pasteMode;for(let x=0;x<a.length;x++){const k=a[x],E=c?w+x:o+x,I=c?r.newRowPosition==="top"?1+x:r.items.length-a.length+x:o+x,R=E;for(let P=0;P<k.length;P++){const D=k[P];let M,A;if(l&&n){const K=n[P];if(!K)continue;M=K.gridField,A=K.colIndex}else{if(A=i+P,A>=d.length){p.push({rowIndex:I,field:"",value:D,isValid:!1,wasSkipped:!0,skipReason:"out-of-bounds"});continue}M=String(d[A].column.field)}const F=`${x}-${P}`;if(g.skipCells.has(F)){p.push({rowIndex:I,field:M,value:D,isValid:!0,wasSkipped:!0,skipReason:"user-canceled"});continue}const T=r.columns.find(K=>String(K.field)===M);if(!T)continue;const $=r.displayItems[I];if(!r.isCellEditable(T,$)){if(m==="editable-only"){p.push({rowIndex:I,field:M,value:D,isValid:!1,wasSkipped:!0,skipReason:"non-editable"});continue}else if(m==="skip-non-editable"){p.push({rowIndex:I,field:M,value:D,isValid:!0,wasSkipped:!0,skipReason:"non-editable"});continue}}const U=c?r.items[R]:r.displayItems[R];if(U&&r.isRowLocked(U)){p.push({rowIndex:I,field:M,value:D,isValid:!0,wasSkipped:!0,skipReason:"locked"});continue}let ge=D;if(T.beforePasteCallback&&U&&(ge=T.beforePasteCallback(D,U)),c){const K=r.items[R];if(K&&r.shouldValidateOnPaste&&T.beforeCommitCallback){const _e={value:ge,oldValue:void 0,row:K,rowIndex:R,field:M},J=await Promise.resolve(T.beforeCommitCallback(_e)),Me=J===!0||J===void 0||typeof J=="object"&&J!==null&&J.valid!==!1,te=typeof J=="object"&&J!==null?J.error||J.message:typeof J=="string"?J:void 0;Me||(r.addInvalidCell(I,M,te||"Invalid value"),(v=r.onvalidationerror)==null||v.call(r,{row:K,rowIndex:I,field:M,error:te||"Invalid value"})),p.push({rowIndex:I,field:M,value:ge,isValid:Me,validationError:Me?void 0:te,wasSkipped:!1})}else p.push({rowIndex:I,field:M,value:ge,isValid:!0,wasSkipped:!1})}else if(r.shouldValidateOnPaste){await r.commitEdit(I,M,ge);const K=r.displayItems[I]!==void 0?r.getStableRowKey(r.displayItems[I],I):null,_e=K!==null?r.invalidCells.find(J=>J.rowKey===K&&J.field===M):void 0;p.push({rowIndex:I,field:M,value:ge,isValid:!_e,validationError:_e==null?void 0:_e.error,wasSkipped:!1})}else{const K=r.items[R];K&&(K[M]=ge),p.push({rowIndex:I,field:M,value:ge,isValid:!0,wasSkipped:!1})}}}const _=p.filter(x=>!x.wasSkipped&&x.isValid).length,y=p.filter(x=>!x.wasSkipped&&!x.isValid).length,C=p.filter(x=>x.wasSkipped).length,S={totalCells:p.length,successfulCells:_,failedCells:y,skippedCells:C,newRowsCreated:f,cellResults:p,hadHeaders:l};return r.onpaste&&r.onpaste(S),S}class Pl{constructor(e){b(this,"executors",new Map);b(this,"ctx");this.ctx=e}registerExecutor(e){for(const o of e.handles)this.executors.set(o,e)}dispatch(e){const o=[e];for(;o.length>0;){const i=o.shift(),r=this.executors.get(i.type);if(!r){console.warn(`[ActionPipeline] No executor for action type: ${i.type}`);continue}const s=new Proxy(this.ctx,{get:(l,a)=>a==="dispatch"?d=>this.dispatch(d):l[a],set:(l,a,d)=>(l[a]=d,!0)}),n=r.execute(s,i);n&&n.length>0&&o.unshift(...n)}}}function Al(t){return new Pl(t)}const Ll={handles:["focusCell","blurCell"],execute(t,e){switch(e.type){case"focusCell":return zl(t,e);case"blurCell":return Ol(t)}}};function zl(t,e){const{rowIndex:o,colIndex:i}=e.target,r=t.grid.columns[i];if(!r)return;const s=r.editTrigger??t.grid.editTrigger,n=s==="always",l=t.grid.focusedCell;(!l||l.rowIndex!==o||l.colIndex!==i)&&(t.filterText="",t.searchDebounceTimer&&(clearTimeout(t.searchDebounceTimer),t.searchDebounceTimer=null),t.searchAbortController&&(t.searchAbortController.abort(),t.searchAbortController=null)),t.grid.setFocusedCell(o,i),ee(t,l,{rowIndex:o,colIndex:i});const d=t.shadow.querySelector(`td[data-row="${o}"][data-col="${i}"]`);if(!d)return;if(n){let g=d.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger");g||(g=d.querySelector(".wg__editor")),g&&(g.focus({preventScroll:!0}),e.selectText!==!1&&g instanceof HTMLInputElement&&g.type==="text"&&g.select())}else d.hasAttribute("tabindex")||d.setAttribute("tabindex","-1"),d.focus({preventScroll:!0});d.scrollIntoView({block:"nearest",inline:"nearest"}),Ht(t);const c=r.editor,u=c==="select"||c==="combobox"||c==="autocomplete",h=s==="navigate";if(n&&t.grid.shouldShowDropdownOnFocus&&!t.justSelected&&u)return[{type:"openDropdown"}];if(h&&t.grid.shouldShowDropdownOnFocus&&u)return[{type:"startEdit",target:{rowIndex:o,colIndex:i}},{type:"openDropdown"}]}function Ol(t,e){const o=t.grid.focusedCell;t.grid.clearFocusedCell(),ee(t,o,null)}const Hl={handles:["navigate"],execute(t,e){if(e.type==="navigate")return Fl(t,e)}};function Fl(t,e){const o=e.from??t.grid.focusedCell;if(!o)return;const i=ql(t,o,e),r=t.grid.columns[o.colIndex],s=r?String(r.field):"",n=t.grid.editingCell&&t.grid.editingCell.rowIndex===o.rowIndex&&t.grid.editingCell.field===s;return i?i.rowIndex===o.rowIndex&&i.colIndex===o.colIndex?void 0:[{type:"transitionCell",from:o,to:i,selectText:!0}]:n?[{type:"commitEdit"},{type:"renderCell",target:o},{type:"focusCell",target:o,selectText:!1}]:void 0}function ql(t,e,o){const{direction:i,ctrlKey:r}=o,{rowIndex:s,colIndex:n}=e,l=t.grid.columns,a=t.grid.displayItems,d=a.length-1,c=l.length-1,u=a[s],h=t.grid.getEditableColumns(u);switch(i!=="tab"&&i!=="tab-back"&&i!=="enter"&&(t.grid.tabTraversalStartColIndex=null),i){case"up":if(s>0)return{rowIndex:s-1,colIndex:n};break;case"down":if(s<d)return{rowIndex:s+1,colIndex:n};break;case"left":if(n>0)return{rowIndex:s,colIndex:n-1};break;case"right":if(n<c)return{rowIndex:s,colIndex:n+1};break;case"tab":{if(h.length===0){const w=t.grid.findNextEditableCell(s,-1,"forward");if(w)return w;if(n<c)return{rowIndex:s,colIndex:n+1};if(s<d)return{rowIndex:s+1,colIndex:0};break}t.grid.tabTraversalStartColIndex===null&&(t.grid.tabTraversalStartColIndex=n);const g=h.findIndex(w=>w.index===n);if(g===-1){const w=h.find(m=>m.index>n);if(w)return{rowIndex:s,colIndex:w.index};const p=t.grid.findNextEditableCell(s,h.length-1,"forward");if(p)return p;break}const f=t.grid.findNextEditableCell(s,g,"forward");if(f)return f;if(t.grid.isEmptyRowIndex(s))return{rowIndex:s,colIndex:h[0].index};break}case"tab-back":{if(h.length===0){const w=t.grid.findNextEditableCell(s,0,"backward");if(w)return w;if(n>0)return{rowIndex:s,colIndex:n-1};if(s>0)return{rowIndex:s-1,colIndex:c};break}t.grid.tabTraversalStartColIndex===null&&(t.grid.tabTraversalStartColIndex=n);const g=h.findIndex(w=>w.index===n);if(g===-1){const w=[...h].reverse().find(m=>m.index<n);if(w)return{rowIndex:s,colIndex:w.index};const p=t.grid.findNextEditableCell(s,0,"backward");if(p)return p;break}const f=t.grid.findNextEditableCell(s,g,"backward");if(f)return f;break}case"enter":{const g=t.grid.tabTraversalStartColIndex??n;if(t.grid.tabTraversalStartColIndex=null,s<d)return{rowIndex:s+1,colIndex:g};break}case"home":return r?{rowIndex:0,colIndex:0}:{rowIndex:s,colIndex:0};case"end":return r?{rowIndex:d,colIndex:c}:{rowIndex:s,colIndex:c};case"page-up":return r?{rowIndex:0,colIndex:n}:{rowIndex:Math.max(0,s-10),colIndex:n};case"page-down":return r?{rowIndex:d,colIndex:n}:{rowIndex:Math.min(d,s+10),colIndex:n}}return null}const Vl={handles:["transitionCell"],execute(t,e){if(e.type==="transitionCell")return Nl(t,e)}};function Nl(t,e){const{from:o,to:i,selectText:r}=e,s=[],n=t.grid.editingCell,l=n&&n.rowIndex===o.rowIndex&&t.grid.columns.findIndex(h=>String(h.field)===n.field)===o.colIndex,a=t.grid.columns[o.colIndex],c=((a==null?void 0:a.editTrigger)??t.grid.editTrigger)==="always";if(o.rowIndex!==i.rowIndex||o.colIndex!==i.colIndex)if(l)s.push({type:"commitEdit"});else if(c)s.push({type:"commitEdit",target:o});else{const h={type:"renderCell",target:o};s.push(h)}const u={type:"focusCell",target:i,selectText:r};return s.push(u),s}const Bl={handles:["renderCell"],execute(t,e){e.type==="renderCell"&&Wl(t,e)}};function Wl(t,e){const{target:o,focusEditor:i,cursorPosition:r,initialSearchQuery:s}=e;O(t,o.rowIndex,o.colIndex,{focusEditor:i,cursorPosition:r,initialSearchQuery:s})}const Ul={handles:["openDropdown","closeDropdown","toggleDropdown","dropdownNavigate","dropdownSelect"],execute(t,e){switch(e.type){case"openDropdown":pe(t);break;case"closeDropdown":V(t);break;case"toggleDropdown":t.dropdownOpen?V(t):pe(t);break;case"dropdownNavigate":return Yl(t,e);case"dropdownSelect":return Kl(t,e)}}},rr=10;function Yl(t,e){if(!t.dropdownOpen)return;const o=t.getCurrentEditorOptions();let i=t.highlightedIndex;const r=t.dropdownOptions.length;switch(e.direction){case"up":for(i=t.highlightedIndex-1;i>=0&&de(t.dropdownOptions[i],o);)i--;if(i<0)return;break;case"down":for(i=t.highlightedIndex+1;i<r&&de(t.dropdownOptions[i],o);)i++;if(i>=r)return;break;case"page-up":for(i=Math.max(0,t.highlightedIndex-rr);i<t.highlightedIndex&&de(t.dropdownOptions[i],o);)i++;if(i>=t.highlightedIndex)return;break;case"page-down":for(i=Math.min(r-1,t.highlightedIndex+rr);i>t.highlightedIndex&&de(t.dropdownOptions[i],o);)i--;if(i<=t.highlightedIndex)return;break;case"home":for(i=0;i<r&&de(t.dropdownOptions[i],o);)i++;if(i>=r)return;break;case"end":for(i=r-1;i>=0&&de(t.dropdownOptions[i],o);)i--;if(i<0)return;break}t.highlightedIndex=i,t.dropdownUserInteracted=!0,we(t),Co(t)}function Kl(t,e){var g;if(!t.dropdownOpen||t.highlightedIndex<0)return V(t),e.thenNavigate?[{type:"navigate",direction:e.thenNavigate}]:void 0;const o=t.dropdownOptions[t.highlightedIndex];if(!o)return;const i=t.grid.editingCell,r=t.grid.focusedCell,s=i?{rowIndex:i.rowIndex,field:i.field,colIndex:t.grid.columns.findIndex(f=>String(f.field)===i.field)}:r?{rowIndex:r.rowIndex,field:String((g=t.grid.columns[r.colIndex])==null?void 0:g.field),colIndex:r.colIndex}:null;if(!s)return;const{rowIndex:n,field:l,colIndex:a}=s,d=t.grid.columns[a],c=(d==null?void 0:d.editorOptions)||{};if(de(o,c))return;const u=ze(o,c),h=t.grid.displayItems[n];if(c.onselect&&h&&c.onselect(o,h),t.justSelected=!0,t.isCommittingFromKeyboard=!0,V(t),t.grid.commitEdit(n,l,u,e.commitEmptyRow??!1),e.thenNavigate)return O(t,n,a),t.justSelected=!1,[{type:"navigate",direction:e.thenNavigate,from:{rowIndex:n,colIndex:a}}];e.moveAfterSelect?t.moveFocusAfterCommit(n,l,"down"):O(t,n,a),requestAnimationFrame(()=>{t.justSelected=!1})}const jl={handles:["noop"],execute(){}},Xl={handles:["toggleCheckbox"],execute(t,e){e.type==="toggleCheckbox"&&Gl(t,e)}};function Gl(t,e){const{rowIndex:o,colIndex:i}=e.target,r=t.grid.columns[i];if(!r)return;const s=t.grid.displayItems[o];if(!s||!t.grid.isCellEditable(r,s))return;const n=String(r.field),l=r.editorOptions||{},a=l.trueValue??!0,d=l.falseValue??!1,u=t.grid.getCellRawValue(s,o,n)===a?d:a;t.grid.startEdit(o,n),t.grid.updateDraftValue(o,n,u),O(t,o,i,{focusEditor:!0})}const Ql={handles:["openDatePicker","closeDatePicker","toggleDatePicker"],execute(t,e){switch(e.type){case"openDatePicker":nr(t);break;case"closeDatePicker":ea(t);break;case"toggleDatePicker":ta(t);break}}};function nr(t){const e=t.grid.focusedCell;if(!e)return;const{rowIndex:o,colIndex:i}=e,r=t.grid.columns[i];if(!r||r.editor!=="date")return;const s=String(r.field),n=t.shadow.querySelector(`.wg__cell[data-row="${o}"][data-col="${i}"]`);if(!n)return;const l=n.querySelector(".wg__editor--date"),a=n.querySelector(".wg__date-input");if(!l||!a)return;t.datepicker&&(t.datepicker.close(!0),t.datepicker=null);const d=a.dataset.dateFormat||"YYYY-MM-DD",c=a.dataset.minDate,u=a.dataset.maxDate,h=a.dataset.dateValue||"",g=o,f=i,w=s;t.datepicker=new Mt({dateFormat:d,minDate:c||void 0,maxDate:u||void 0,onSelect:(p,m)=>{Jl(t,g,f,w,p,m)},onClose:()=>{Zl(t,g,f)}}),t.datepicker.open(l,h||null)}function Jl(t,e,o,i,r,s){var c;t.datepicker=null;const n=t.grid.columns[o],l=((c=n==null?void 0:n.editorOptions)==null?void 0:c.outputFormat)??"iso";let a;switch(l){case"date":a=r;break;case"timestamp":a=r.getTime();break;case"iso":default:a=Tt(r);break}t.grid.commitEdit(e,i,a),O(t,e,o);const d=t.shadow.querySelector(`.wg__cell[data-row="${e}"][data-col="${o}"]`);d&&d.focus(),s==="down"?t.dispatch({type:"navigate",direction:"down"}):s==="next"&&t.dispatch({type:"navigate",direction:"tab"})}function Zl(t,e,o){t.datepicker=null;const i=t.grid.columns[o];if(!i)return;if((i.editTrigger??t.grid.editTrigger)==="always")O(t,e,o);else{G(t),t.grid.cancelEdit(),O(t,e,o);const s=t.shadow.querySelector(`.wg__cell[data-row="${e}"][data-col="${o}"]`);s&&s.focus()}}function ea(t){t.datepicker&&(t.datepicker.close(!0),t.datepicker=null)}function ta(t){t.datepicker?t.datepicker.close(!1):nr(t)}const oa={handles:["startEdit","commitEdit","cancelEdit","escapeEdit","deleteCell"],execute(t,e){switch(e.type){case"startEdit":ia(t,e);break;case"commitEdit":ra(t,e.commitEmptyRow,e.target);break;case"cancelEdit":na(t);break;case"escapeEdit":return sa(t,e);case"deleteCell":la(t,e);break}}};function ia(t,e){const{rowIndex:o,colIndex:i}=e.target;re(t,o,i,{initialSearchQuery:e.initialSearchQuery,cursorPosition:e.cursorPosition})}async function ra(t,e,o){const i=t.grid.editingCell;let r,s,n;if(o){r=o.rowIndex,s=o.colIndex;const c=t.grid.columns[s];if(!c)return;n=String(c.field)}else if(i){if(r=i.rowIndex,n=i.field,s=t.grid.columns.findIndex(c=>String(c.field)===n),s<0)return}else return;const l=t.shadow.querySelector(`.wg__cell[data-row="${r}"][data-col="${s}"]`);if(!l)return;let a=l.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger");if(a||(a=l.querySelector(".wg__editor")),!a)return;let d;if(t.grid.columns[s],a instanceof HTMLInputElement)if(a.type==="checkbox"){const c=t.grid.displayItems[r];d=t.grid.getCellRawValue(c,r,n)}else if(a.classList.contains("wg__date-input"))d=a.dataset.dateValue||a.value;else if(a.classList.contains("wg__editor--number")){const c=a.value.trim();if(c==="")d=null;else{const u=parseFloat(c);d=isNaN(u)?c:u}}else d=a.value;else a instanceof HTMLSelectElement?d=a.value:d=a.dataset.value||"";t.dropdownOpen&&V(t),G(t),await t.grid.commitEdit(r,n,d,e),O(t,r,s)}function na(t){const e=t.grid.editingCell;if(!e)return;const{rowIndex:o,field:i}=e,r=t.grid.columns.findIndex(n=>String(n.field)===i),s=t.grid.columns[r];t.dropdownOpen&&V(t),G(t),(s==null?void 0:s.editor)==="checkbox"&&t.grid.discardCellDraft(o,i),t.grid.cancelEdit(),r>=0&&O(t,o,r)}function sa(t,e){const o=t.grid.editingCell,i=t.grid.focusedCell;if(e.phase==="dropdown"){const r=o||i;if(!r)return;const s=o?t.grid.columns.findIndex(a=>String(a.field)===o.field):(i==null?void 0:i.colIndex)??-1,n=t.grid.columns[s],l=n==null?void 0:n.editor;if(l==="select"&&t.filterText){t.filterText="",V(t),t.dispatch({type:"openDropdown"});return}if(l==="autocomplete"||l==="combobox"){const a=t.shadow.querySelector(`.wg__cell[data-row="${r.rowIndex}"][data-col="${s}"]`),d=a==null?void 0:a.querySelector(".wg__combobox-input, .wg__autocomplete-input"),c=t.grid.displayItems[r.rowIndex],u=n==null?void 0:n.field,h=c&&u?c[u]:void 0,g=(n==null?void 0:n.editorOptions)||{},f=g.initialOptions||g.options||[],w=ut(h,f,g),p=(d==null?void 0:d.value)??"";if(d&&p!==w){t.filterText="",d.value=w,d.focus(),d.select(),V(t),t.dispatch({type:"openDropdown"});return}}V(t),o&&(G(t),l==="checkbox"&&t.grid.discardCellDraft(r.rowIndex,o.field),t.grid.cancelEdit(),O(t,r.rowIndex,s),ft(t,r.rowIndex,s));return}if(o){const{rowIndex:r,field:s}=o,n=t.grid.columns.findIndex(a=>String(a.field)===s),l=t.grid.columns[n];t.dropdownOpen&&V(t),t.datepicker&&(t.datepicker.close(!0),t.datepicker=null),G(t),(l==null?void 0:l.editor)==="checkbox"&&t.grid.discardCellDraft(r,s),t.grid.cancelEdit(),n>=0&&(O(t,r,n),ft(t,r,n))}else if(i){const{rowIndex:r,colIndex:s}=i;t.grid.clearFocusedCell(),O(t,r,s)}}function la(t,e){const o=e.target||t.grid.focusedCell;if(!o)return;const{rowIndex:i,colIndex:r}=o,s=t.grid.columns[r];if(!s)return;const n=t.grid.displayItems[i];if(!t.grid.isCellEditable(s,n))return;const l=String(s.field);t.grid.commitEdit(i,l,null),O(t,i,r)}const aa={handles:["selectRow","selectColumn","clearSelection"],execute(t,e){switch(e.type){case"selectRow":da(t,e);break;case"selectColumn":ca(t,e);break;case"clearSelection":ga(t);break}}};function da(t,e){const{rowIndex:o,addToSelection:i,extendSelection:r}=e;t.grid.selectedColumns.length>0&&t.grid.clearColumnSelection(),t.grid.selectedCellRange&&(t.grid.clearCellSelection(),Q(),Re(),Io(t)),r&&t.grid.selectedRows.length>0?t.grid.selectRow(o,"range"):i?t.grid.selectRow(o,"toggle"):t.grid.selectRow(o,"replace"),sr(t)}function ca(t,e){const{colIndex:o,addToSelection:i,extendSelection:r}=e;t.grid.selectedRows.length>0&&t.grid.clearSelection(),t.grid.selectedCellRange&&(t.grid.clearCellSelection(),Q(),Re(),Io(t)),r&&t.grid.selectedColumns.length>0?t.grid.selectColumn(o,"range"):i?t.grid.selectColumn(o,"toggle"):t.grid.selectColumn(o,"replace"),lr(t)}function ga(t){if(console.log("[clearSelection] rows:",t.grid.selectedRows.length,"cols:",t.grid.selectedColumns.length,"cellRange:",!!t.grid.selectedCellRange),t.grid.selectedRows.length>0&&(console.log("[clearSelection] clearing rows"),t.grid.clearSelection_noRender(),it(),sr(t)),t.grid.selectedColumns.length>0){console.log("[clearSelection] clearing columns, removing visual classes"),t.grid.clearColumnSelection_noRender(),rt(),lr(t),console.log("[clearSelection] after clear, selectedColumns:",t.grid.selectedColumns.length);const e=t.shadow.querySelectorAll(".wg__header--selected");console.log("[clearSelection] remaining header--selected elements:",e.length)}t.grid.selectedCellRange&&(t.grid.clearCellSelection_noRender(),Q(),Re(),Io(t))}function sr(t){t.shadow.querySelectorAll(".wg__row--selected").forEach(o=>o.classList.remove("wg__row--selected"));for(const o of t.grid.selectedRows){const i=t.shadow.querySelector(`tr[data-row="${o}"]`);i&&i.classList.add("wg__row--selected")}}function lr(t){t.shadow.querySelectorAll(".wg__cell--column-selected").forEach(i=>i.classList.remove("wg__cell--column-selected")),t.shadow.querySelectorAll(".wg__header--selected").forEach(i=>i.classList.remove("wg__header--selected"));for(const i of t.grid.selectedColumns){t.shadow.querySelectorAll(`.wg__cell[data-col="${i}"]`).forEach(n=>n.classList.add("wg__cell--column-selected"));const s=t.shadow.querySelector(`.wg__header[data-col="${i}"]`);s&&s.classList.add("wg__header--selected")}}function Io(t){t.shadow.querySelectorAll(".wg__cell--in-range").forEach(u=>u.classList.remove("wg__cell--in-range"));const o=t.grid.selectedCellRange;if(!o)return;const{startRowIndex:i,endRowIndex:r,startColIndex:s,endColIndex:n}=o,l=Math.min(i,r),a=Math.max(i,r),d=Math.min(s,n),c=Math.max(s,n);for(let u=l;u<=a;u++)for(let h=d;h<=c;h++){const g=t.shadow.querySelector(`.wg__cell[data-row="${u}"][data-col="${h}"]`);g&&g.classList.add("wg__cell--in-range")}}const ua={handles:["copy","paste"],execute(t,e){switch(e.type){case"copy":ha(t);break}}};async function ha(t){var o,i;let e="";if(t.grid.selectedCellRange){const r=t.grid.selectedCellRange,{startRowIndex:s,endRowIndex:n,startColIndex:l,endColIndex:a}=r,d=Math.min(s,n),c=Math.max(s,n),u=Math.min(l,a),h=Math.max(l,a),g=[];for(let f=d;f<=c;f++){const w=[];for(let p=u;p<=h;p++){const m=t.grid.displayItems[f],_=(o=t.grid.visualColumns[p])==null?void 0:o.column;if(m&&_){const y=m[String(_.field)];w.push(Ut(y))}else w.push("")}g.push(w.join(" "))}e=g.join(`
659
+ `)}else if(t.grid.selectedColumns.length>0){const r=[],s=t.grid.displayItems;for(let n=0;n<s.length;n++){const l=[];for(const a of t.grid.selectedColumns){const d=s[n],c=(i=t.grid.visualColumns[a])==null?void 0:i.column;if(d&&c){const u=d[String(c.field)];l.push(Ut(u))}else l.push("")}r.push(l.join(" "))}e=r.join(`
660
+ `)}else if(t.grid.selectedRows.length>0){const r=[],s=t.grid.visualColumns;for(const n of t.grid.selectedRows){const l=t.grid.displayItems[n];if(l){const a=[];for(const d of s){const c=l[String(d.column.field)];a.push(Ut(c))}r.push(a.join(" "))}}e=r.join(`
661
+ `)}else if(t.grid.focusedCell){const{rowIndex:r,colIndex:s}=t.grid.focusedCell,n=t.grid.displayItems[r],l=t.grid.columns[s];if(n&&l){const a=n[String(l.field)];e=Ut(a)}}if(e)try{await navigator.clipboard.writeText(e)}catch{console.warn("Failed to copy to clipboard")}}function Ut(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}const fa={handles:["openContextMenu","closeContextMenu"],execute(t,e){switch(e.type){case"openContextMenu":wa(t,e);break;case"closeContextMenu":pa(t);break}}};function wa(t,e){e.target&&t.dispatch({type:"focusCell",target:e.target,selectText:!1})}function pa(t){t.contextMenuElement&&(ce(t.contextMenuElement),t.contextMenuElement=null),t.headerContextMenuElement&&(ce(t.headerContextMenuElement),t.headerContextMenuElement=null)}const ma={handles:["startFillDrag","updateFillDrag","completeFillDrag"],execute(t,e){switch(e.type){}}},ba={handles:["startCellSelection"],execute(t,e){if(e.type==="startCellSelection")return _a(t,e)}};function _a(t,e){Vi(t,e.rowIndex,e.colIndex,{clientX:e.clientX,clientY:e.clientY,shiftKey:e.shiftKey})}const va={handles:["resetState"],execute(t,e){if(e.type==="resetState")return ya(t,e)}};function ya(t,e){const o=e.edit!==!1,i=e.selections!==!1,r=e.overlays!==!1,s=e.focus===!0,n=[];return r&&((t.contextMenuElement||t.headerContextMenuElement)&&n.push({type:"closeContextMenu"}),t.datepicker&&n.push({type:"closeDatePicker"})),o&&t.grid.editingCell&&n.push({type:"cancelEdit"}),i&&(t.grid.selectedRows.length>0||t.grid.selectedColumns.length>0||t.grid.selectedCellRange)&&n.push({type:"clearSelection"}),s&&t.grid.focusedCell&&n.push({type:"blurCell"}),n}const Ca={handles:["openCustomEditor"],execute(t,e){if(e.type!=="openCustomEditor")return;const{rowIndex:o,colIndex:i}=e.target;t.openCustomEditor(o,i)}};function Eo(t,e){const{currentCell:o,dropdownOpen:i,isDropdownEditor:r}=e;if(!o)return null;const s=t.ctrlKey||t.metaKey;if(i)switch(t.key){case"ArrowUp":return{type:"dropdownNavigate",direction:"up"};case"ArrowDown":return{type:"dropdownNavigate",direction:"down"};case"ArrowLeft":case"ArrowRight":return e.editorType==="autocomplete"?null:{type:"noop"};case"Home":return e.editorType==="autocomplete"?null:{type:"dropdownNavigate",direction:"home"};case"End":return e.editorType==="autocomplete"?null:{type:"dropdownNavigate",direction:"end"};case"PageUp":return{type:"dropdownNavigate",direction:"page-up"};case"PageDown":return{type:"dropdownNavigate",direction:"page-down"};case"Enter":return{type:"dropdownSelect",moveAfterSelect:!0,commitEmptyRow:!0};case"Tab":return{type:"dropdownSelect",moveAfterSelect:!1,commitEmptyRow:!1,thenNavigate:t.shiftKey?"tab-back":"tab"};case"Escape":return{type:"escapeEdit",phase:"dropdown"}}if(t.key==="Escape")return{type:"escapeEdit",phase:"edit"};if(e.isCheckboxEditor){if(t.key===" ")return{type:"toggleCheckbox",target:o};if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")return{type:"noop"}}if(r&&!i)switch(t.key){case" ":case"F2":return{type:"openDropdown"};case"Enter":return{type:"openDropdown"}}let n=null;switch(t.key){case"Tab":n=t.shiftKey?"tab-back":"tab";break;case"Enter":n="enter";break;case"ArrowUp":n="up";break;case"ArrowDown":n="down";break;case"ArrowLeft":n="left";break;case"ArrowRight":n="right";break;case"Home":n="home";break;case"End":n="end";break;case"PageUp":n="page-up";break;case"PageDown":n="page-down";break;default:return null}return n?{type:"navigate",direction:n,from:o,ctrlKey:s}:null}function ar(t,e,o,i=!1){return!!(["Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"].includes(t)||t==="Escape"||o&&!e&&(t===" "||t==="F2")||i&&t===" ")}function dr(t,e){const{cell:o,dropdownOpen:i,isToggleClick:r,isDateTriggerClick:s,isCheckboxClick:n,isCellClick:l}=e,a=[];if(n)return a.push({type:"toggleCheckbox",target:o}),a;if(s)return a.push({type:"focusCell",target:o,selectText:!1}),a.push({type:"startEdit",target:o}),a.push({type:"toggleDatePicker"}),a;i&&!r&&a.push({type:"closeDropdown"});const{isDropdownEditor:d}=e,c=!r&&(!l||d);return a.push({type:"focusCell",target:o,selectText:c}),r&&(i?a.push({type:"closeDropdown"}):(a.push({type:"startEdit",target:o}),a.push({type:"openDropdown"}))),a}class Sa{constructor(e){b(this,"pipeline");b(this,"ctx");this.ctx=e,this.pipeline=Al(e),this.pipeline.registerExecutor(Ll),this.pipeline.registerExecutor(Hl),this.pipeline.registerExecutor(Vl),this.pipeline.registerExecutor(Bl),this.pipeline.registerExecutor(Ul),this.pipeline.registerExecutor(Xl),this.pipeline.registerExecutor(Ql),this.pipeline.registerExecutor(oa),this.pipeline.registerExecutor(aa),this.pipeline.registerExecutor(ua),this.pipeline.registerExecutor(fa),this.pipeline.registerExecutor(ma),this.pipeline.registerExecutor(ba),this.pipeline.registerExecutor(va),this.pipeline.registerExecutor(Ca),this.pipeline.registerExecutor(jl)}getEditTrigger(e){const o=this.ctx.grid.columns[e];return o?o.editTrigger??this.ctx.grid.editTrigger:"navigate"}isAlwaysMode(e){return this.ctx.grid.isEditable?this.getEditTrigger(e)==="always":!1}isEditingCell(e,o){const i=this.ctx.grid.editingCell;if(!i)return!1;const r=this.ctx.grid.columns[o];return r?i.rowIndex===e&&i.field===String(r.field):!1}isDropdownEditor(e){const o=this.ctx.grid.columns[e];if(!o)return!1;const i=o.editor;return i==="select"||i==="combobox"||i==="autocomplete"}isCheckboxEditor(e){const o=this.ctx.grid.columns[e];return o?o.editor==="checkbox":!1}isDateEditor(e){const o=this.ctx.grid.columns[e];return o?o.editor==="date":!1}isCustomEditor(e){const o=this.ctx.grid.columns[e];return o?o.editor==="custom":!1}getDropdownEditorType(e){const o=this.ctx.grid.columns[e];if(!o)return;const i=o.editor;if(i==="select"||i==="combobox"||i==="autocomplete")return i}getCellFromTarget(e){const o=e.closest(".wg__cell");if(!o)return null;const i=parseInt(o.dataset.row||"",10),r=parseInt(o.dataset.col||"",10);return isNaN(i)||isNaN(r)?null:{rowIndex:i,colIndex:r}}tryHandleKeyDown(e){const o=e.target,i=this.getCellFromTarget(o);if(!i||this.ctx.datepicker&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(e.key))return!1;const r=this.getEditTrigger(i.colIndex),s=this.isAlwaysMode(i.colIndex),n=this.isEditingCell(i.rowIndex,i.colIndex),l=this.ctx.dropdownOpen,a=this.isDropdownEditor(i.colIndex),d=this.isCheckboxEditor(i.colIndex),c=this.isDateEditor(i.colIndex);if(s){if(!ar(e.key,l,a,d))return!1;const h=Eo(e,{currentCell:i,dropdownOpen:l,isDropdownEditor:a,isCheckboxEditor:d,editorType:this.getDropdownEditorType(i.colIndex)});return h?(e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch(h),!0):!1}if(n){const h=e.key==="ArrowLeft"||e.key==="ArrowRight";if(h&&r==="navigate"&&a)return e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"navigate",direction:e.key==="ArrowLeft"?"left":"right",from:i}),!0;if(e.key==="Tab"&&r==="navigate"&&l)return e.preventDefault(),e.stopPropagation(),this.ctx.dropdownUserInteracted?this.pipeline.dispatch({type:"dropdownSelect",moveAfterSelect:!1,thenNavigate:e.shiftKey?"tab-back":"tab"}):(this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"navigate",direction:e.shiftKey?"tab-back":"tab",from:i})),!0;if(!ar(e.key,l,a,d)||!a&&!d&&!c&&h&&!l)return!1;const w=Eo(e,{currentCell:i,dropdownOpen:l,isDropdownEditor:a,isCheckboxEditor:d,editorType:this.getDropdownEditorType(i.colIndex)});return w?(e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch(w),!0):!1}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","PageUp","PageDown"].includes(e.key)){const h=Eo(e,{currentCell:i,dropdownOpen:!1,isDropdownEditor:!1,isCheckboxEditor:!1});return h?(e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch(h),!0):!1}if(e.key==="F2"){const h=this.isCustomEditor(i.colIndex);return e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch({type:"startEdit",target:i}),a?this.pipeline.dispatch({type:"openDropdown"}):c?this.pipeline.dispatch({type:"openDatePicker"}):h&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}if(e.key==="Enter"){if(c)return e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch({type:"startEdit",target:i}),this.pipeline.dispatch({type:"openDatePicker"}),!0;if(a){const h=this.ctx.grid.columns[i.colIndex];return h&&this.ctx.grid.getEffectiveShouldOpenDropdownOnEnter(h)?(e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch({type:"startEdit",target:i}),this.pipeline.dispatch({type:"openDropdown"}),!0):!1}return!1}if(e.key===" "){const h=this.isCustomEditor(i.colIndex);if(a||c||d||h)return e.preventDefault(),e.stopPropagation(),d?this.pipeline.dispatch({type:"toggleCheckbox",target:i}):(this.pipeline.dispatch({type:"startEdit",target:i}),a?this.pipeline.dispatch({type:"openDropdown"}):c?this.pipeline.dispatch({type:"openDatePicker"}):h&&this.pipeline.dispatch({type:"openCustomEditor",target:i})),!0}if(e.key==="Delete")return e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch({type:"deleteCell",target:i}),!0;if((e.ctrlKey||e.metaKey)&&e.key==="c")return e.preventDefault(),e.stopPropagation(),this.pipeline.dispatch({type:"copy"}),!0;if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){if(this.isEditingCell(i.rowIndex,i.colIndex))return!1;e.preventDefault(),e.stopPropagation();const h=this.isCustomEditor(i.colIndex);return this.pipeline.dispatch({type:"startEdit",target:i,initialSearchQuery:e.key}),a?this.pipeline.dispatch({type:"openDropdown"}):h&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}return!1}tryHandleFocus(e){const o=e.target,i=this.getCellFromTarget(o);if(!i||!this.isAlwaysMode(i.colIndex)||!o.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger"))return!1;const s=this.ctx.grid.focusedCell;return(!s||s.rowIndex!==i.rowIndex||s.colIndex!==i.colIndex)&&this.pipeline.dispatch({type:"focusCell",target:i,selectText:!1}),!0}tryHandleMouseDown(e){const o=e.target,i=o.matches(".wg__combobox-toggle, .wg__select-toggle"),r=!!o.closest(".wg__date-trigger"),s=o.matches('.wg__checkbox-input, input[type="checkbox"]'),n=!i&&!r&&!s&&(o.matches(".wg__cell")||o.closest(".wg__cell")!==null);let l=null;if(i){const w=o.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete")||o.closest(".wg__cell-dropdown-display");if(w){const p=parseInt(w.dataset.row||"",10),m=w.dataset.field||"",_=this.ctx.grid.columns.findIndex(y=>String(y.field)===m);!isNaN(p)&&_>=0&&(l={rowIndex:p,colIndex:_})}}else if(r){const w=o.closest(".wg__editor--date")||o.closest(".wg__cell-date-display");if(w){const p=parseInt(w.dataset.row||"",10),m=w.dataset.field||"",_=this.ctx.grid.columns.findIndex(y=>String(y.field)===m);!isNaN(p)&&_>=0&&(l={rowIndex:p,colIndex:_})}}else l=this.getCellFromTarget(o);if(!l)return!1;this.ctx.grid.tabTraversalStartColIndex=null;const a=this.isAlwaysMode(l.colIndex),d=this.isEditingCell(l.rowIndex,l.colIndex);if(!i&&!r&&!s&&!n)return!1;const c=this.ctx.grid.cellSelectionMode,u=e.shiftKey;if(c==="shift"&&u&&n)return this.pipeline.dispatch({type:"startCellSelection",rowIndex:l.rowIndex,colIndex:l.colIndex,clientX:e.clientX,clientY:e.clientY,shiftKey:!0}),e.preventDefault(),!0;if(a||d){const w=o.matches(".wg__editor--text, .wg__editor--number, .wg__date-input"),p=o.matches(".wg__combobox-input, .wg__autocomplete-input"),m=this.ctx.grid.focusedCell,_=m&&m.rowIndex===l.rowIndex&&m.colIndex===l.colIndex;if((w||p)&&_&&n)return!0;const y=n&&this.ctx.grid.selectedCellRange;n&&(y||this.ctx.grid.selectedRows.length>0||this.ctx.grid.selectedColumns.length>0)&&(y&&(this.ctx.isTransitioningCells=!0),this.pipeline.dispatch({type:"clearSelection"}));const S=this.ctx.dropdownOpen,v=this.isDropdownEditor(l.colIndex),x=dr(e,{cell:l,dropdownOpen:S,isDropdownEditor:v,isDateEditor:this.isDateEditor(l.colIndex),isCheckboxEditor:this.isCheckboxEditor(l.colIndex),isToggleClick:i,isDateTriggerClick:r,isCheckboxClick:s,isCellClick:n});if(x.length===0)return y&&(this.ctx.isTransitioningCells=!1),!1;w||(e.preventDefault(),e.stopPropagation());for(const k of x)this.pipeline.dispatch(k);return y&&requestAnimationFrame(()=>{this.ctx.isTransitioningCells=!1}),!0}if(i)return e.preventDefault(),e.stopPropagation(),this.ctx.grid.editingCell&&this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"focusCell",target:l,selectText:!1}),this.pipeline.dispatch({type:"startEdit",target:l}),this.pipeline.dispatch({type:"openDropdown"}),!0;if(r)return e.preventDefault(),e.stopPropagation(),this.ctx.grid.editingCell&&this.pipeline.dispatch({type:"cancelEdit"}),this.pipeline.dispatch({type:"focusCell",target:l,selectText:!1}),this.pipeline.dispatch({type:"startEdit",target:l}),this.pipeline.dispatch({type:"openDatePicker"}),!0;if(n&&!i&&!s){e.preventDefault(),this.ctx.grid.editingCell&&(this.ctx.isTransitioningCells=!0,this.pipeline.dispatch({type:"cancelEdit"})),(this.ctx.grid.selectedRows.length>0||this.ctx.grid.selectedColumns.length>0||this.ctx.grid.selectedCellRange)&&this.pipeline.dispatch({type:"clearSelection"}),this.pipeline.dispatch({type:"focusCell",target:l,selectText:!1});const w=this.ctx.grid.cellSelectionMode,p=e.shiftKey;return w!=="disabled"&&(w==="click"&&!p||w==="shift"&&p)&&this.pipeline.dispatch({type:"startCellSelection",rowIndex:l.rowIndex,colIndex:l.colIndex,clientX:e.clientX,clientY:e.clientY,shiftKey:e.shiftKey}),this.ctx.isTransitioningCells&&requestAnimationFrame(()=>{this.ctx.isTransitioningCells=!1}),!0}const h=this.ctx.dropdownOpen,g=this.isDropdownEditor(l.colIndex),f=dr(e,{cell:l,dropdownOpen:h,isDropdownEditor:g,isDateEditor:this.isDateEditor(l.colIndex),isCheckboxEditor:this.isCheckboxEditor(l.colIndex),isToggleClick:i,isDateTriggerClick:r,isCheckboxClick:s,isCellClick:n});if(f.length===0)return!1;e.preventDefault(),e.stopPropagation();for(const w of f)this.pipeline.dispatch(w);return!0}tryHandleClick(e){const o=e.target,i=this.getCellFromTarget(o);if(!i||this.getEditTrigger(i.colIndex)!=="click"||this.isEditingCell(i.rowIndex,i.colIndex))return!1;e.preventDefault();const s=this.isDropdownEditor(i.colIndex),n=this.isDateEditor(i.colIndex),l=this.isCustomEditor(i.colIndex);(s||n||l)&&e.stopImmediatePropagation();const a=o.closest(".wg__cell"),d=a?tt(e,a):null;return this.pipeline.dispatch({type:"startEdit",target:i,cursorPosition:d??void 0}),s?this.pipeline.dispatch({type:"openDropdown"}):n?this.pipeline.dispatch({type:"openDatePicker"}):l&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}tryHandleDblClick(e){const o=e.target,i=this.getCellFromTarget(o);if(!i)return!1;const r=this.getEditTrigger(i.colIndex);if(r!=="dblclick"&&r!=="navigate"||this.isEditingCell(i.rowIndex,i.colIndex))return!1;e.preventDefault();const s=this.isDropdownEditor(i.colIndex),n=this.isDateEditor(i.colIndex),l=this.isCustomEditor(i.colIndex),a=o.closest(".wg__cell"),d=a?tt(e,a):null;return this.pipeline.dispatch({type:"startEdit",target:i,cursorPosition:d??void 0}),s?this.pipeline.dispatch({type:"openDropdown"}):n?this.pipeline.dispatch({type:"openDatePicker"}):l&&this.pipeline.dispatch({type:"openCustomEditor",target:i}),!0}isDatepickerOpen(){return!!this.ctx.datepicker}clearSelection(){this.pipeline.dispatch({type:"clearSelection"})}}function xa(t){return new Sa(t)}class Ro extends HTMLElement{constructor(){super();b(this,"grid");b(this,"shadow");b(this,"styleElement");b(this,"customStyleElement",null);b(this,"updatePending",!1);b(this,"isCommittingFromKeyboard",!1);b(this,"isTransitioningCells",!1);b(this,"toolbarOutsideClickAdded",!1);b(this,"clickEventsSubscribed",!1);b(this,"focusEventsSubscribed",!1);b(this,"toolbarMoveInProgress",!1);b(this,"toolbarHideTimeout",null);b(this,"toolbarHovered",!1);b(this,"toolbarShortcutHandler",null);b(this,"hoveredCell",null);b(this,"currentCellToolbarItems",null);b(this,"toolbarMousemoveHandler",null);b(this,"inlineShortcutHandler",null);b(this,"dropdownOpen",!1);b(this,"dropdownOptions",[]);b(this,"highlightedIndex",-1);b(this,"filterText","");b(this,"isUserFiltering",!1);b(this,"justSelected",!1);b(this,"isOpeningDropdown",!1);b(this,"dropdownUserInteracted",!1);b(this,"isClosingViaToggle",!1);b(this,"isProgrammaticScroll",!1);b(this,"searchDebounceTimer",null);b(this,"searchAbortController",null);b(this,"isSearching",!1);b(this,"tooltipElement",null);b(this,"tooltipArrowElement",null);b(this,"tooltipAnchor",null);b(this,"tooltipShowTimer",null);b(this,"tooltipHideTimer",null);b(this,"_tooltipShowDelay",200);b(this,"_tooltipHideDelay",100);b(this,"datepicker",null);b(this,"contextMenuElement",null);b(this,"headerContextMenuElement",null);b(this,"virtualScrollStart",0);b(this,"virtualScrollEnd",0);b(this,"isLoadingMoreItems",!1);b(this,"scrollEvents");b(this,"focusEvents");b(this,"clickEvents");b(this,"pipelineAdapter",null);b(this,"_isMouseDown",!1);b(this,"handlePaste",async o=>{var l;if(!this.grid.isNavigateMode||this.grid.editingCell||!this.grid.focusedCell)return;const{rowIndex:i,colIndex:r}=this.grid.focusedCell,s=((l=o.clipboardData)==null?void 0:l.getData("text"))||"";if(!s)return;if(s.includes(" ")||s.includes(`
662
+ `))o.preventDefault(),await $l(this,s,i,r),this.render();else{const a=this.grid.columns[r],d=this.grid.displayItems[i];if(!a||!d||!this.grid.isCellEditable(a,d))return;o.preventDefault();let c=s;a.beforePasteCallback&&(c=a.beforePasteCallback(s,d));const u=String(a.field);await this.grid.commitEdit(i,u,c),this.render()}});this.shadow=this.attachShadow({mode:"open"}),this.grid=new ni,Object.defineProperty(this,"onpaste",{configurable:!0,enumerable:!0,get:()=>this.grid.onpaste,set:o=>{this.grid.onpaste=o}}),this.scrollEvents=gl(),this.clickEvents=hl(),this.focusEvents=ul(()=>({isCommittingFromKeyboard:this.isCommittingFromKeyboard,isTransitioningCells:this.isTransitioningCells,isClosingViaToggle:this.isClosingViaToggle,isOpeningDropdown:this.isOpeningDropdown}),()=>{this.isClosingViaToggle=!1}),this.styleElement=document.createElement("style"),this.styleElement.textContent=Xn,this.shadow.appendChild(this.styleElement),this.grid.requestUpdate=()=>{this.grid.invalidateDisplayCache(),this.requestUpdate()},this.grid._onInteractionChange=(o,i)=>{o==="editingCell"&&i.current===null&&V(this)}}get tooltipShowDelay(){return this._tooltipShowDelay}set tooltipShowDelay(o){this._tooltipShowDelay=o}get tooltipHideDelay(){return this._tooltipHideDelay}set tooltipHideDelay(o){this._tooltipHideDelay=o}connectedCallback(){ao.debug("connectedCallback — grid attached to DOM"),this.grid.gridName&&this.grid.shouldPersistColumnWidths&&this.grid.loadPersistedWidths(),this.pipelineAdapter=xa(this),this.render(),this.addEventListener("paste",this.handlePaste)}disconnectedCallback(){ao.debug("disconnectedCallback — grid removed from DOM"),this.scrollEvents.destroy(),this.focusEvents.destroy(),this.clickEvents.destroy(),this.clickEventsSubscribed=!1,this.focusEventsSubscribed=!1,this.removeEventListener("paste",this.handlePaste),this.datepicker&&(this.datepicker.destroy(),this.datepicker=null),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null),At(),this.removeInlineShortcuts(),kl()}get items(){return this.grid.items}set items(o){this.grid.items=o,this.isLoadingMoreItems=!1}get columns(){return this.grid.columns}set columns(o){this.grid.columns=o}get isFilterable(){return this.grid.isFilterable}set isFilterable(o){this.grid.isFilterable=o}get onfilterchange(){return this.grid.onfilterchange}set onfilterchange(o){this.grid.onfilterchange=o}get columnMinWidth(){return this.grid.columnMinWidth}set columnMinWidth(o){this.grid.columnMinWidth=o}get filters(){return this.grid.filters}set filters(o){this.grid.filters=o}setFilter(o,i){this.grid.setFilter(o,i)}get isPageable(){return this.grid.isPageable}set isPageable(o){this.grid.isPageable=o}get pageSize(){return this.grid.pageSize}set pageSize(o){this.grid.pageSize=o}get pageSizes(){return this.grid.pageSizes}set pageSizes(o){this.grid.pageSizes=o}get paginationMode(){return this.grid.paginationMode}set paginationMode(o){this.grid.paginationMode=o}get isStriped(){return this.grid.isStriped}set isStriped(o){this.grid.isStriped=o}get isHoverable(){return this.grid.isHoverable}set isHoverable(o){this.grid.isHoverable=o}get isEditable(){return this.grid.isEditable}set isEditable(o){this.grid.isEditable=o}get isRowEditable(){return this.grid.isRowEditable}set isRowEditable(o){this.grid.isRowEditable=o}get editTrigger(){return this.grid.editTrigger}set editTrigger(o){this.grid.editTrigger=o}get editStartSelection(){return this.grid.editStartSelection}set editStartSelection(o){this.grid.editStartSelection=o}get mode(){return this.grid.mode}set mode(o){this.grid.mode=o}get dropdownToggleVisibility(){return this.grid.dropdownToggleVisibility}set dropdownToggleVisibility(o){this.grid.dropdownToggleVisibility=o}get shouldShowDropdownOnFocus(){return this.grid.shouldShowDropdownOnFocus}set shouldShowDropdownOnFocus(o){this.grid.shouldShowDropdownOnFocus=o}get shouldOpenDropdownOnEnter(){return this.grid.shouldOpenDropdownOnEnter}set shouldOpenDropdownOnEnter(o){this.grid.shouldOpenDropdownOnEnter=o}get isCheckboxAlwaysEditable(){return this.grid.isCheckboxAlwaysEditable}set isCheckboxAlwaysEditable(o){this.grid.isCheckboxAlwaysEditable=o}get isRowNumbersVisible(){return this.grid.isRowNumbersVisible}set isRowNumbersVisible(o){this.grid.isRowNumbersVisible=o}get isDirtyIndicatorVisible(){return this.grid.isDirtyIndicatorVisible}set isDirtyIndicatorVisible(o){this.grid.isDirtyIndicatorVisible=o}isCellDirty(o,i){return this.grid.isCellDirty(o,i)}isRowDirty(o){return this.grid.isRowDirty(o)}get isStickyRowNumbers(){return this.grid.isStickyRowNumbers}set isStickyRowNumbers(o){this.grid.isStickyRowNumbers=o}get freezeColumns(){return this.grid.freezeColumns}set freezeColumns(o){this.grid.freezeColumns=o}get invalidCells(){return this.grid.invalidCells}set invalidCells(o){this.grid.invalidCells=o}get isRowToolbarVisible(){return this.grid.isRowToolbarVisible}set isRowToolbarVisible(o){this.grid.isRowToolbarVisible=o}get rowToolbar(){return this.grid.rowToolbar}set rowToolbar(o){this.grid.rowToolbar=o}get toolbarVerticalAlign(){return this.grid.toolbarVerticalAlign}set toolbarVerticalAlign(o){this.grid.toolbarVerticalAlign=o}get toolbarHorizontalAlign(){return this.grid.toolbarHorizontalAlign}set toolbarHorizontalAlign(o){this.grid.toolbarHorizontalAlign=o}get toolbarAlign(){return this.grid.toolbarVerticalAlign}set toolbarAlign(o){this.grid.toolbarVerticalAlign=o}get toolbarTopPosition(){return this.grid.toolbarHorizontalAlign}set toolbarTopPosition(o){this.grid.toolbarHorizontalAlign=o}get toolbarTrigger(){return this.grid.toolbarTrigger}set toolbarTrigger(o){this.grid.toolbarTrigger=o}get toolbarPosition(){return this.grid.toolbarPosition}set toolbarPosition(o){this.grid.toolbarPosition=o}get toolbarColumn(){return this.grid.toolbarColumn}set toolbarColumn(o){this.grid.toolbarColumn=o}get toolbarFollowsCursor(){return this.grid.toolbarFollowsCursor}set toolbarFollowsCursor(o){this.grid.toolbarFollowsCursor=o}get cellToolbar(){return this.grid.cellToolbar}set cellToolbar(o){this.grid.cellToolbar=o}get cellToolbarOffset(){return this.grid.cellToolbarOffset}set cellToolbarOffset(o){this.grid.cellToolbarOffset=o}get toolbarBtnMinWidth(){return this.grid.toolbarBtnMinWidth}set toolbarBtnMinWidth(o){this.grid.toolbarBtnMinWidth=o}get inlineActionsTitle(){return this.grid.inlineActionsTitle}set inlineActionsTitle(o){this.grid.inlineActionsTitle=o}get contextMenu(){return this.grid.contextMenu}set contextMenu(o){this.grid.contextMenu=o}get contextMenuXOffset(){return this.grid.contextMenuXOffset}set contextMenuXOffset(o){this.grid.contextMenuXOffset=o}get contextMenuYOffset(){return this.grid.contextMenuYOffset}set contextMenuYOffset(o){this.grid.contextMenuYOffset=o}get headerContextMenu(){return this.grid.headerContextMenu}set headerContextMenu(o){this.grid.headerContextMenu=o}set onheadercontextmenuopen(o){this.grid.onheadercontextmenuopen=o}get rowShortcuts(){return this.grid.rowShortcuts}set rowShortcuts(o){this.grid.rowShortcuts=o}get rangeShortcuts(){return this.grid.rangeShortcuts}set rangeShortcuts(o){this.grid.rangeShortcuts=o}get selectedRows(){return this.grid.selectedRows}selectRow(o,i="replace"){this.grid.selectRow(o,i)}selectRowRange(o,i){this.grid.selectRowRange(o,i)}clearSelection(){this.grid.clearSelection()}isRowSelected(o){return this.grid.isRowSelected(o)}getSelectedRowsData(){return this.grid.getSelectedRowsData()}copySelectedRowsToClipboard(){return this.grid.copySelectedRowsToClipboard()}get cellSelectionMode(){return this.grid.cellSelectionMode}set cellSelectionMode(o){this.grid.cellSelectionMode=o}get selectedCellRange(){return this.grid.selectedCellRange}selectCellRange(o){this.grid.selectCellRange(o)}clearCellSelection(){this.grid.clearCellSelection()}getSelectedCells(){return this.grid.getSelectedCells()}copyCellSelectionToClipboard(){return this.grid.copyCellSelectionToClipboard()}get shouldCopyWithHeaders(){return this.grid.shouldCopyWithHeaders}set shouldCopyWithHeaders(o){this.grid.shouldCopyWithHeaders=o}get oncellselectionchange(){return this.grid.oncellselectionchange}set oncellselectionchange(o){this.grid.oncellselectionchange=o}get isNewRowEnabled(){return this.grid.isNewRowEnabled}set isNewRowEnabled(o){this.grid.isNewRowEnabled=o}get newRowPosition(){return this.grid.newRowPosition}set newRowPosition(o){this.grid.newRowPosition=o}get newRowIndicator(){return this.grid.newRowIndicator}set newRowIndicator(o){this.grid.newRowIndicator=o}get createEmptyRowCallback(){return this.grid.createEmptyRowCallback}set createEmptyRowCallback(o){this.grid.createEmptyRowCallback=o}get idMember(){return this.grid.idMember}set idMember(o){this.grid.idMember=o}get treePathMember(){return this.grid.treePathMember}set treePathMember(o){this.grid.treePathMember=o}get treeLevelMember(){return this.grid.treeLevelMember}set treeLevelMember(o){this.grid.treeLevelMember=o}get treeParentMember(){return this.grid.treeParentMember}set treeParentMember(o){this.grid.treeParentMember=o}get treeSeparator(){return this.grid.treeSeparator}set treeSeparator(o){this.grid.treeSeparator=o}get treeDataSorted(){return this.grid.treeDataSorted}set treeDataSorted(o){this.grid.treeDataSorted=o}get expandedPaths(){return this.grid.expandedPaths}set expandedPaths(o){this.grid.expandedPaths=o}get defaultExpandDepth(){return this.grid.defaultExpandDepth}set defaultExpandDepth(o){this.grid.defaultExpandDepth=o}set onexpandedpathschange(o){this.grid.onexpandedpathschange=o}get onexpandedpathschange(){return this.grid.onexpandedpathschange}isPathExpanded(o){return this.grid.isPathExpanded(o)}toggleExpandedPath(o){this.grid.toggleExpandedPath(o)}expandAll(){this.grid.expandAll()}collapseAll(){this.grid.collapseAll()}get treeDoubleClickBehavior(){return this.grid.treeDoubleClickBehavior}set treeDoubleClickBehavior(o){this.grid.treeDoubleClickBehavior=o}get treeExpandedGlyph(){return this.grid.treeExpandedGlyph}set treeExpandedGlyph(o){this.grid.treeExpandedGlyph=o}get treeCollapsedGlyph(){return this.grid.treeCollapsedGlyph}set treeCollapsedGlyph(o){this.grid.treeCollapsedGlyph=o}get treeChevronCallback(){return this.grid.treeChevronCallback}set treeChevronCallback(o){this.grid.treeChevronCallback=o}get isShortcutsHelpVisible(){return this.grid.isShortcutsHelpVisible}set isShortcutsHelpVisible(o){this.grid.isShortcutsHelpVisible=o}get shortcutsHelpPosition(){return this.grid.shortcutsHelpPosition}set shortcutsHelpPosition(o){this.grid.shortcutsHelpPosition=o}get shortcutsHelpContentCallback(){return this.grid.shortcutsHelpContentCallback}set shortcutsHelpContentCallback(o){this.grid.shortcutsHelpContentCallback=o}set onrowchange(o){this.grid.onrowchange=o}set onroweditstart(o){this.grid.onroweditstart=o}set onroweditcancel(o){this.grid.onroweditcancel=o}set onvalidationerror(o){this.grid.onvalidationerror=o}get validationTooltipCallback(){return this.grid.validationTooltipCallback}set validationTooltipCallback(o){this.grid.validationTooltipCallback=o}set ontoolbarclick(o){this.grid.ontoolbarclick=o}set onrowaction(o){this.grid.onrowaction=o}get oncontextmenuopen(){return this.grid.oncontextmenuopen}set oncontextmenuopen(o){this.grid.oncontextmenuopen=o}get ondatarequest(){return this.grid.ondatarequest}set ondatarequest(o){this.grid.ondatarequest=o}get onrowdelete(){return this.grid.onrowdelete}set onrowdelete(o){this.grid.onrowdelete=o}get onrowfocus(){return this.grid.onrowfocus}set onrowfocus(o){this.grid.onrowfocus=o}get focusedRowIndex(){return this.grid.focusedRowIndex}set focusedRowIndex(o){this.grid.focusedRowIndex=o}get sort(){return this.grid.sort}set sort(o){this.grid.sort=o}get sortMode(){return this.grid.sortMode}set sortMode(o){this.grid.sortMode=o}get currentPage(){return this.grid.currentPage}set currentPage(o){this.grid.currentPage=o}get totalItems(){return this.grid.totalItems}set totalItems(o){this.grid.totalItems=o}get showPagination(){return this.grid.showPagination}set showPagination(o){this.grid.showPagination=o}get paginationPosition(){return this.grid.paginationPosition}set paginationPosition(o){this.grid.paginationPosition=o}get paginationLabelsCallback(){return this.grid.paginationLabelsCallback}set paginationLabelsCallback(o){this.grid.paginationLabelsCallback=o}get paginationLayout(){return this.grid.paginationLayout}set paginationLayout(o){this.grid.paginationLayout=o}get summaryPosition(){return this.grid.summaryPosition}set summaryPosition(o){this.grid.summaryPosition=o}get summaryContentCallback(){return this.grid.summaryContentCallback}set summaryContentCallback(o){this.grid.summaryContentCallback=o}get customStylesCallback(){return this.grid.customStylesCallback}set customStylesCallback(o){this.grid.customStylesCallback=o,this.updateCustomStyles()}get rowClassCallback(){return this.grid.rowClassCallback}set rowClassCallback(o){this.grid.rowClassCallback=o}get labels(){return this.grid.labels}set labels(o){this.grid.labels=o}get summaryMetadata(){return this.grid.summaryMetadata}set summaryMetadata(o){this.grid.summaryMetadata=o}get isSummaryInline(){return this.grid.isSummaryInline}set isSummaryInline(o){this.grid.isSummaryInline=o}get idValueMember(){return this.grid.idValueMember}set idValueMember(o){this.grid.idValueMember=o}get idValueCallback(){return this.grid.idValueCallback}set idValueCallback(o){this.grid.idValueCallback=o}get rowLocking(){return this.grid.rowLocking}set rowLocking(o){this.grid.rowLocking=o}get onrowlockchange(){return this.grid.onrowlockchange}set onrowlockchange(o){this.grid.onrowlockchange=o}get gridName(){return this.grid.gridName}set gridName(o){this.grid.gridName=o,this.tryLoadPersistedWidths()}get shouldPersistColumnWidths(){return this.grid.shouldPersistColumnWidths}set shouldPersistColumnWidths(o){this.grid.shouldPersistColumnWidths=o,this.tryLoadPersistedState()}get isColumnReorderAllowed(){return this.grid.isColumnReorderAllowed}set isColumnReorderAllowed(o){this.grid.isColumnReorderAllowed=o}get shouldPersistColumnOrder(){return this.grid.shouldPersistColumnOrder}set shouldPersistColumnOrder(o){this.grid.shouldPersistColumnOrder=o,this.tryLoadPersistedState()}tryLoadPersistedState(){this.grid.gridName&&(this.grid.shouldPersistColumnWidths||this.grid.shouldPersistColumnOrder)&&(this.grid.loadPersistedState(),this.isConnected&&this.render())}tryLoadPersistedWidths(){this.tryLoadPersistedState()}get oncolumnresize(){return this.grid.oncolumnresize}set oncolumnresize(o){this.grid.oncolumnresize=o}get oncolumnreorder(){return this.grid.oncolumnreorder}set oncolumnreorder(o){this.grid.oncolumnreorder=o}get fillDragCallback(){return this.grid.fillDragCallback}set fillDragCallback(o){this.grid.fillDragCallback=o}get isScrollable(){return this.grid.isScrollable}set isScrollable(o){this.grid.isScrollable=o}get scrollMaxHeight(){return this.grid.scrollMaxHeight}set scrollMaxHeight(o){this.grid.scrollMaxHeight=o}get tableBorderOnly(){return this.grid.tableBorderOnly}set tableBorderOnly(o){this.grid.tableBorderOnly=o}get isVirtualScrollEnabled(){return this.grid.isVirtualScrollEnabled}set isVirtualScrollEnabled(o){this.grid.isVirtualScrollEnabled=o}get virtualScrollThreshold(){return this.grid.virtualScrollThreshold}set virtualScrollThreshold(o){this.grid.virtualScrollThreshold=o}get virtualScrollRowHeight(){return this.grid.virtualScrollRowHeight}set virtualScrollRowHeight(o){this.grid.virtualScrollRowHeight=o}get virtualScrollBuffer(){return this.grid.virtualScrollBuffer}set virtualScrollBuffer(o){this.grid.virtualScrollBuffer=o}get isInfiniteScrollEnabled(){return this.grid.isInfiniteScrollEnabled}set isInfiniteScrollEnabled(o){this.grid.isInfiniteScrollEnabled=o}get infiniteScrollThreshold(){return this.grid.infiniteScrollThreshold}set infiniteScrollThreshold(o){this.grid.infiniteScrollThreshold=o}get hasMoreItems(){return this.grid.hasMoreItems}set hasMoreItems(o){this.grid.hasMoreItems=o}get onbeforepaste(){return this.grid.onbeforepaste}set onbeforepaste(o){this.grid.onbeforepaste=o}get pasteMode(){return this.grid.pasteMode}set pasteMode(o){this.grid.pasteMode=o}get shouldValidateOnPaste(){return this.grid.shouldValidateOnPaste}set shouldValidateOnPaste(o){this.grid.shouldValidateOnPaste=o}get displayItems(){return this.grid.displayItems}get totalPages(){return this.grid.totalPages}get isNavigateMode(){return this.grid.isNavigateMode}getRowDraft(o){return this.grid.getRowDraft(o)}hasRowDraft(o){return this.grid.hasRowDraft(o)}discardRowDraft(o){this.grid.discardRowDraft(o)}getDraftRowIndices(){return this.grid.getDraftRowIndices()}discardAllDrafts(){this.grid.discardAllDrafts()}isCellInvalid(o,i){return this.grid.isCellInvalid(o,i)}getCellValidationError(o,i){return this.grid.getCellValidationError(o,i)}getRowId(o){return this.grid.getRowId(o)}findRowById(o){return this.grid.findRowById(o)}isRowLocked(o){return this.grid.isRowLocked(o)}getRowLockInfo(o){return this.grid.getRowLockInfo(o)}lockRowById(o,i){return this.grid.lockRowById(o,i)}unlockRowById(o){return this.grid.unlockRowById(o)}getExternalLocks(){return this.grid.getExternalLocks()}clearExternalLocks(){this.grid.clearExternalLocks()}updateRowById(o,i){return this.grid.updateRowById(o,i)}replaceRowById(o,i){return this.grid.replaceRowById(o,i)}canEditCell(o,i){return this.grid.canEditCell(o,i)}setColumnWidth(o,i){this.grid.setColumnWidth(o,i)}setColumnWidths(o){this.grid.setColumnWidths(o)}getColumnWidthsState(){return this.grid.getColumnWidthsState()}setColumnOrder(o){this.grid.setColumnOrder(o)}getColumnOrderState(){return this.grid.getColumnOrderState()}focusCell(o,i){const r=this.grid.columns,s=this.grid.displayItems;o<0||o>=s.length||i<0||i>=r.length||(this.grid.setFocusedCell(o,i),requestAnimationFrame(()=>{N(this,o,i)}))}startEditing(o,i){const r=this.grid.columns;if(i<0||i>=r.length)return;const s=r[i],n=String(s.field);this.grid.startEdit(o,n);const l=this.shadow.querySelector(`td[data-row="${o}"][data-col="${i}"]`);l&&(l.classList.remove("wg__cell--focused"),l.classList.add("wg__cell--editing"),l.innerHTML=Ot(this,o,i,s))}escapeHtml(o){const i=document.createElement("div");return i.textContent=o,i.innerHTML}getCurrentEditingColumn(){const o=this.grid.editingCell;return o&&this.grid.columns.find(i=>String(i.field)===o.field)||null}getCurrentEditorOptions(){const o=this.getCurrentEditingColumn();return(o==null?void 0:o.editorOptions)||{}}moveFocusAfterCommit(o,i,r){_o(this,o,i,r)}requestUpdate(){if(this.updatePending)return;Ee.debug("requestUpdate: scheduling render"),this.updatePending=!0;const o=performance.now();queueMicrotask(()=>{this.updatePending=!1;const i=performance.now();$t.debug("microtask delay:",(i-o).toFixed(2),"ms"),this.render(),$t.debug("render() total:",(performance.now()-i).toFixed(2),"ms")})}updateCustomStyles(){const o=this.grid.customStylesCallback;if(o){const i=o();this.customStyleElement||(this.customStyleElement=document.createElement("style"),this.shadow.appendChild(this.customStyleElement)),this.customStyleElement.textContent=i}else this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}handleCellKeyDown(o,i,r){var h;if(!this.grid.isNavigateMode)return;const s=this.grid.columns,n=this.grid.displayItems,l=n[i],a=this.grid.getEditableColumns(l),d=a.findIndex(g=>g.index===r);if((o.ctrlKey||o.metaKey)&&o.key==="c"){if(this.grid.selectedCellRange){o.preventDefault(),this.grid.copyCellSelectionToClipboard();return}const g=s[r],f=n[i];if(g&&f){let w=this.grid.getCellRawValue(f,i,String(g.field));g.beforeCopyCallback&&(w=g.beforeCopyCallback(w,f));const p=w!=null?String(w):"";navigator.clipboard.writeText(p)}return}const c=this.grid.selectedRows;if(c.length>0){const g=this.grid.rangeShortcuts;if(g&&g.length>0)for(const f of g){const w=pt(f.key);if(mt(o,w)){const p={rows:this.grid.getSelectedRowsData(),rowIndices:c};if(!(typeof f.disabled=="function"?f.disabled(p):f.disabled===!0)){o.preventDefault(),f.action(p);return}}}}const u=this.grid.rowShortcuts;if(u&&u.length>0){const g=s[r],f=n[i];if(g&&f)for(const w of u){const p=pt(w.key);if(mt(o,p)){const m={row:f,rowIndex:i,colIndex:r,column:g,cellValue:this.grid.getCellRawValue(f,i,String(g.field))};if(!(typeof w.disabled=="function"?w.disabled(m):w.disabled===!0)){o.preventDefault(),w.action(m);return}}}}switch(o.key){case"ArrowUp":o.preventDefault(),i>0&&N(this,i-1,r);break;case"ArrowDown":o.preventDefault(),i<n.length-1&&N(this,i+1,r);break;case"ArrowLeft":o.preventDefault(),r>0&&N(this,i,r-1);break;case"ArrowRight":o.preventDefault(),r<s.length-1&&N(this,i,r+1);break;case"Tab":{o.preventDefault();const g=o.shiftKey?"backward":"forward";let f=d;if(f===-1&&a.length>0)if(g==="forward"){const p=a.find(m=>m.index>r);if(p){N(this,i,p.index);break}f=a.length-1}else{const p=[...a].reverse().find(m=>m.index<r);if(p){N(this,i,p.index);break}f=0}const w=this.grid.findNextEditableCell(i,f,g);w?N(this,w.rowIndex,w.colIndex):g==="forward"&&this.grid.isEmptyRowIndex(i)&&a.length>0&&N(this,i,a[0].index);break}case"Home":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(0,0),this.scrollToRowProgrammatically(0);const f=this.shadow.querySelector('td[data-row="0"][data-col="0"]');f&&(f.focus({preventScroll:!0}),ee(this,g,{rowIndex:0,colIndex:0}))}else N(this,0,0);else N(this,i,0);break;case"End":if(o.preventDefault(),o.ctrlKey){const g=n.length-1,f=s.length-1;if(this.grid.shouldUseVirtualScroll()){const w=this.grid.focusedCell;this.grid.setFocusedCell(g,f),this.scrollToRowProgrammatically(g);const p=this.shadow.querySelector(`td[data-row="${g}"][data-col="${f}"]`);p&&(p.focus({preventScroll:!0}),ee(this,w,{rowIndex:g,colIndex:f}))}else N(this,g,f)}else N(this,i,s.length-1);break;case"PageUp":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(0,r),this.scrollToRowProgrammatically(0);const f=this.shadow.querySelector(`td[data-row="0"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),ee(this,g,{rowIndex:0,colIndex:r}))}else N(this,0,r);else{const g=Math.max(0,i-10);if(this.grid.shouldUseVirtualScroll()){const f=this.grid.focusedCell;this.grid.setFocusedCell(g,r),this.scrollToRowProgrammatically(g);const w=this.shadow.querySelector(`td[data-row="${g}"][data-col="${r}"]`);w&&(w.focus({preventScroll:!0}),ee(this,f,{rowIndex:g,colIndex:r}))}else N(this,g,r)}break;case"PageDown":if(o.preventDefault(),o.ctrlKey){const g=n.length-1;if(this.grid.shouldUseVirtualScroll()){const f=this.grid.focusedCell;this.grid.setFocusedCell(g,r),this.scrollToRowProgrammatically(g);const w=this.shadow.querySelector(`td[data-row="${g}"][data-col="${r}"]`);w&&(w.focus({preventScroll:!0}),ee(this,f,{rowIndex:g,colIndex:r}))}else N(this,g,r)}else{const g=Math.min(n.length-1,i+10);if(this.grid.shouldUseVirtualScroll()){const f=this.grid.focusedCell;this.grid.setFocusedCell(g,r),this.scrollToRowProgrammatically(g);const w=this.shadow.querySelector(`td[data-row="${g}"][data-col="${r}"]`);w&&(w.focus({preventScroll:!0}),ee(this,f,{rowIndex:g,colIndex:r}))}else N(this,g,r)}break;case"g":case"G":o.ctrlKey&&(o.preventDefault(),this.showGoToRowDialog(r));break;case"Enter":{o.preventDefault();const g=s[r],f=(g==null?void 0:g.editor)==="select"||(g==null?void 0:g.editor)==="combobox"||(g==null?void 0:g.editor)==="autocomplete",w=this.grid.isEmptyRowIndex(i);if(f&&this.grid.getEffectiveShouldOpenDropdownOnEnter(g))re(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||pe(this)});else if(w&&g&&this.grid.isCellEditable(g))re(this,i,r);else if(i<n.length-1){const p=this.grid.tabTraversalStartColIndex??r;this.grid.tabTraversalStartColIndex=null,N(this,i+1,p)}break}case"F2":{o.preventDefault();const g=s[r],f=(g==null?void 0:g.editor)==="select"||(g==null?void 0:g.editor)==="combobox"||(g==null?void 0:g.editor)==="autocomplete",w=(g==null?void 0:g.editor)==="custom";re(this,i,r),f?requestAnimationFrame(()=>{this.dropdownOpen||pe(this)}):w&&requestAnimationFrame(()=>{this.openCustomEditor(i,r)});break}case" ":{o.preventDefault();const g=s[r],f=(g==null?void 0:g.editor)==="checkbox",w=(g==null?void 0:g.editor)==="select"||(g==null?void 0:g.editor)==="combobox"||(g==null?void 0:g.editor)==="autocomplete",p=(g==null?void 0:g.editor)==="date",m=(g==null?void 0:g.editor)==="custom";f&&g&&this.grid.isCellEditable(g,n[i])?fs(this,i,r):w?(re(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||pe(this)})):p?(re(this,i,r),requestAnimationFrame(()=>{var S;const _=(S=this.shadowRoot)==null?void 0:S.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`),y=_==null?void 0:_.querySelector(".wg__date-input"),C=_==null?void 0:_.querySelector(".wg__editor--date");y&&C&&this.openDatePicker(y,C)})):m&&(re(this,i,r),requestAnimationFrame(()=>{this.openCustomEditor(i,r)}));break}case"Escape":if(o.preventDefault(),this.grid.editingCell)G(this),this.grid.cancelEdit();else if(this.grid.selectedRows.length>0)this.grid.clearSelection();else{const g=this.grid.focusedCell;this.grid.clearFocusedCell(),ee(this,g,null),(h=o.target)==null||h.blur()}break;case"Delete":{o.preventDefault();const g=s[r],f=n[i];if(o.ctrlKey){if(f){const w={rowIndex:i,row:f};this.grid.onrowdelete&&this.grid.onrowdelete(w),this.dispatchEvent(new CustomEvent("rowdelete",{detail:w}))}}else g&&this.grid.isCellEditable(g,f)&&(this.grid.commitEdit(i,String(g.field),null),this.render(),requestAnimationFrame(()=>{const w=this.shadow.querySelector(`td[data-row="${i}"][data-col="${r}"]`);w==null||w.focus()}));break}default:if(o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey){const g=s[r];if((g==null?void 0:g.editor)==="number"&&!/[\d.\-]/.test(o.key))return;re(this,i,r,{initialSearchQuery:o.key}),o.preventDefault()}break}}async handleEditorKeyDown(o,i){const r=parseInt(i.dataset.row||"0",10),s=i.dataset.field||"",n=this.grid.columns.find(c=>c.field===s),l=(n==null?void 0:n.editor)||"text",a=l==="select"||l==="combobox"||l==="autocomplete",d=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"];if(a&&!this.dropdownOpen&&d.includes(o.key)){o.preventDefault(),o.stopPropagation();const c=this.grid.columns.findIndex(m=>m.field===s),u=this.grid.columns.map((m,_)=>({index:_,column:m})).filter(m=>m.column.isEditable!==!1),h=u.findIndex(m=>m.index===c),g=this.grid.displayItems;let f=r,w=c,p=!1;switch(o.key){case"ArrowUp":r>0&&(f=r-1,p=!0);break;case"ArrowDown":r<g.length-1&&(f=r+1,p=!0);break;case"ArrowLeft":h>0&&(w=u[h-1].index,p=!0);break;case"ArrowRight":h<u.length-1&&(w=u[h+1].index,p=!0);break;case"PageUp":f=Math.max(0,r-10),p=!0;break;case"PageDown":f=Math.min(g.length-1,r+10),p=!0;break;case"Home":o.ctrlKey&&(f=0),w=0,p=!0;break;case"End":o.ctrlKey?(f=g.length-1,w=this.grid.columns.length-1):w=this.grid.columns.length-1,p=!0;break}p&&(G(this),this.grid.cancelEdit(),queueMicrotask(()=>{N(this,f,w)}));return}switch(o.key){case"ArrowDown":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const m=this.getCurrentEditorOptions();let _=this.highlightedIndex+1;for(;_<this.dropdownOptions.length&&de(this.dropdownOptions[_],m);)_++;_<this.dropdownOptions.length&&(this.highlightedIndex=_,we(this),Co(this))}break;case"ArrowUp":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const m=this.getCurrentEditorOptions();let _=this.highlightedIndex-1;for(;_>=0&&de(this.dropdownOptions[_],m);)_--;_>=0&&(this.highlightedIndex=_,we(this),Co(this))}break;case"Enter":if(this.datepicker)return;o.preventDefault(),o.stopPropagation(),this.dropdownOpen&&this.highlightedIndex>=0?Ci(this,this.highlightedIndex,!0,!0):a&&!this.dropdownOpen?pe(this):(this.isCommittingFromKeyboard=!0,V(this),l==="date"&&i instanceof HTMLInputElement?await this.commitDateEditor(i,!0):await zt(this,i,!0),_o(this,r,s,"down"));break;case"Tab":if(this.datepicker)return;o.preventDefault(),o.stopPropagation(),this.isCommittingFromKeyboard=!0;const c=this.grid.displayItems[r],u=this.grid.getEditableColumns(c),h=this.grid.columns.findIndex(m=>String(m.field)===s),g=u.findIndex(m=>m.index===h),f=this.grid.isEmptyRowIndex(r),w=g===u.length-1,p=f&&w&&!o.shiftKey;if(this.dropdownOpen&&this.highlightedIndex>=0&&a){const m=this.dropdownOptions[this.highlightedIndex],_=this.getCurrentEditorOptions();if(m&&!de(m,_)){const y=ze(m,_);await this.grid.commitEdit(r,s,y,p)}V(this)}else V(this),l==="date"&&i instanceof HTMLInputElement?await this.commitDateEditor(i,p):a||await zt(this,i,p);if(p){Lt(this,r,h);const m=u.length>0?u[0].index:0;queueMicrotask(()=>{const _=this.grid.newRowPosition==="top"?0:this.grid.displayItems.length-1;N(this,_,m),this.isCommittingFromKeyboard=!1})}else _o(this,r,s,o.shiftKey?"prev":"next");break;case"Escape":if(o.preventDefault(),o.stopPropagation(),this.dropdownOpen){V(this),(l==="autocomplete"||l==="combobox")&&(this.filterText="",i instanceof HTMLInputElement&&(i.value="",i.focus()));return}if(this.datepicker){this.datepicker.close(!0),this.datepicker=null;return}this.isCommittingFromKeyboard=!0,G(this),this.grid.cancelEdit(),ps(this,r,s);break;case"F2":o.preventDefault(),o.stopPropagation(),a&&!this.dropdownOpen&&pe(this);break;case"Backspace":l==="select"&&(o.preventDefault(),o.stopPropagation(),this.filterText.length>0&&(this.filterText=this.filterText.slice(0,-1),Si(this,n.editorOptions||{})));break;default:l==="select"&&o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),o.stopPropagation(),this.filterText+=o.key,Si(this,n.editorOptions||{}));break}}attachEventListeners(){const o=this.shadow.querySelector(".wg__table");if(!o)return;o.addEventListener("mousedown",()=>{this._isMouseDown=!0},!0),document.addEventListener("mouseup",()=>{this._isMouseDown=!1},!0),o.addEventListener("focus",n=>{const l=n.target;if(l.matches(".wg__cell")){const a=parseInt(l.dataset.row||"0",10),d=parseInt(l.dataset.col||"0",10);if(cs(this,a,d),Ht(this),!this._isMouseDown&&!ko()&&!qi()){const c=this.grid.focusedRowIndex;this.grid.setFocusedRow(a),this.updateRowFocusVisual(c,a)}bo(this,l,a)}if(l.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input, .wg__select-trigger")){const a=l.closest(".wg__cell");if(a){const d=parseInt(a.dataset.row||"0",10),c=parseInt(a.dataset.col||"0",10),u=this.grid.columns[c];if(((u==null?void 0:u.editTrigger)??this.grid.editTrigger)==="always"){const g=this.grid.focusedCell;if(!g||g.rowIndex!==d||g.colIndex!==c){if(this.grid.setFocusedCell(d,c),g){const f=this.shadow.querySelector(`td[data-row="${g.rowIndex}"][data-col="${g.colIndex}"]`);f&&f.classList.remove("wg__cell--always-edit-focused")}if(a.classList.add("wg__cell--always-edit-focused"),!this._isMouseDown){const f=this.grid.focusedRowIndex;this.grid.setFocusedRow(d),this.updateRowFocusVisual(f,d)}}}}}},!0),o.addEventListener("keydown",n=>{var d;const l=n.target,a=n;if(this.grid.isTreeMode&&this.grid.focusedCell&&!this.grid.editingCell&&(a.ctrlKey||a.metaKey)&&(a.key==="ArrowLeft"||a.key==="ArrowRight")){const{rowIndex:c,colIndex:u}=this.grid.focusedCell,h=this.grid.displayItems[c],g=h?this.grid.getRowTreeInfo(h):null;if(g){n.preventDefault(),n.stopPropagation();let f=null;if(a.key==="ArrowRight")g.hasChildren&&!this.grid.isPathExpanded(g.path)&&(this.grid.toggleExpandedPath(g.path),f=g.path);else if(g.hasChildren&&this.grid.isPathExpanded(g.path))this.grid.toggleExpandedPath(g.path),f=g.path;else{const w=this.grid.findNearestExpandedAncestor(g.path);w!==null&&(this.grid.toggleExpandedPath(w),f=w)}if(f!==null){const w=f;queueMicrotask(()=>{const p=this.grid.displayItems.findIndex(m=>{var _;return((_=this.grid.getRowTreeInfo(m))==null?void 0:_.path)===w});p>=0&&N(this,p,u)})}return}}if(!((d=this.pipelineAdapter)!=null&&d.tryHandleKeyDown(n))){if(this.datepicker){const c=n.key;if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(c))return}if(l.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input")){this.handleEditorKeyDown(n,l);return}if(l.matches(".wg__cell")){const c=parseInt(l.dataset.row||"0",10),u=parseInt(l.dataset.col||"0",10);this.handleCellKeyDown(n,c,u)}}}),this.focusEvents.init(o),this.focusEvents.subscribe("focusout",(n,l)=>{(!l||!o.contains(l))&&gs(this,{relatedTarget:l})}),o.addEventListener("dblclick",n=>{var d;const l=n.target;if((d=this.pipelineAdapter)!=null&&d.tryHandleDblClick(n))return;n.preventDefault();const a=l.closest(".wg__cell");if(a){const c=parseInt(a.dataset.row||"0",10),u=parseInt(a.dataset.col||"0",10),h=this.grid.columns[u];if(h){const g=h.editTrigger||this.grid.editTrigger;if(g==="dblclick"||g==="navigate"){const f=tt(n,a);re(this,c,u,{cursorPosition:f??void 0});const w=h.editor;w==="select"||w==="combobox"||w==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||pe(this)}):w==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(c,u)})}}}}),Ee.debug("attaching click handler on table"),o.addEventListener("click",n=>{var c;const l=n.target;Ee.debug("CLICK fired | target:",l.tagName,l.className,"| connected:",l.isConnected);const a=l.closest(".wg__tree-chevron[data-tree-toggle]");if(a){n.preventDefault(),n.stopPropagation();const u=a.getAttribute("data-tree-toggle");Ee.debug("chevron click:",u,"| target:",l.tagName,l.className),u!==null&&this.grid.toggleExpandedPath(u);return}if((c=this.pipelineAdapter)!=null&&c.tryHandleClick(n))return;const d=l.closest(".wg__cell");if(d&&!d.classList.contains("wg__cell--editing")){const u=parseInt(d.dataset.row||"0",10),h=parseInt(d.dataset.col||"0",10),g=this.grid.columns[h];if(g&&(g.editTrigger||this.grid.editTrigger)==="click"){n.preventDefault();const w=tt(n,d);re(this,u,h,{cursorPosition:w??void 0});const p=g.editor;p==="select"||p==="combobox"||p==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||pe(this)}):p==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(u,h)})}}}),o.addEventListener("mousedown",n=>{var h,g;const l=n.target,a=n;if(Ee.debug("MOUSEDOWN fired | target:",l.tagName,l.className,"| connected:",l.isConnected,"| detail:",a.detail,"| button:",a.button),l.closest(".wg__tree-chevron[data-tree-toggle]")){Ee.debug("chevron mousedown intercepted (suppress focus/selection)"),n.preventDefault(),n.stopPropagation();return}if(a.detail===2&&a.button===0&&this.grid.isTreeMode){const f=l.closest(".wg__cell");if(f&&!l.closest(".wg__tree-chevron")){const w=parseInt(f.dataset.col||"-1",10),p=parseInt(f.dataset.row||"-1",10),m=w>=0?this.grid.columns[w]:null;if(m!=null&&m.isTree&&p>=0){if(this.grid.treeDoubleClickBehavior==="toggle"){const y=this.grid.displayItems[p],C=y?this.grid.getRowTreeInfo(y):null;if(C!=null&&C.hasChildren){Ee.debug("tree dblclick (mousedown.detail=2) toggle:",C.path),n.preventDefault(),n.stopPropagation(),this.grid.toggleExpandedPath(C.path);return}}const _=m.editTrigger||this.grid.editTrigger;if((_==="dblclick"||_==="navigate")&&this.grid.canEditCell(p,String(m.field))){const y=tt(a,f);Ee.debug("tree dblclick (mousedown.detail=2) start edit:",String(m.field),"| trigger:",_),n.preventDefault(),n.stopPropagation(),re(this,p,w,{cursorPosition:y??void 0});return}}}}if((h=this.pipelineAdapter)!=null&&h.tryHandleMouseDown(a))return;const d=l.closest(".wg__cell"),c=l.closest(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(d&&!d.classList.contains("wg__cell--editing")&&!l.closest(".wg__row-number")&&!c){const f=parseInt(d.dataset.row||"0",10),w=parseInt(d.dataset.col||"0",10),p=(g=this.grid.visualColumns[w])==null?void 0:g.column;if(p){const m=this.grid.cellSelectionMode,_=a.shiftKey;if(p.editTrigger||this.grid.editTrigger,m!=="disabled"&&(m==="click"&&!_||m==="shift"&&_)){if(this.grid.editingCell){const C=this.grid.editingCell,S=this.grid.columns.findIndex(v=>String(v.field)===C.field);V(this),G(this),this.grid.cancelEdit(),S>=0&&O(this,C.rowIndex,S)}this.grid.selectedRows.length>0&&this.grid.clearSelection(),this.grid.selectedColumns.length>0&&this.grid.clearColumnSelection(),Vi(this,f,w,a);return}else this.grid.selectedCellRange&&(this.grid.clearCellSelection(),Q())}}if(l.closest(".wg__date-trigger")){n.preventDefault(),n.stopPropagation();const f=l.closest(".wg__cell-date-display"),w=l.closest(".wg__editor--date");if(w){const p=w.querySelector(".wg__date-input");p&&this.openDatePicker(p,w)}else if(f){const p=parseInt(f.dataset.row||"0",10),m=f.dataset.field||"",_=this.grid.columns.findIndex(y=>String(y.field)===m);if(_>=0){if(this.clearAllSelections(),this.isTransitioningCells=!0,this.grid.editingCell){const y=this.grid.editingCell,C=this.grid.columns.findIndex(S=>String(S.field)===y.field);V(this),G(this),this.grid.cancelEdit(),this.grid.setFocusedCell(p,_),C>=0&&O(this,y.rowIndex,C)}re(this,p,_),requestAnimationFrame(()=>{var v;this.isTransitioningCells=!1;const y=(v=this.shadowRoot)==null?void 0:v.querySelector(`.wg__cell[data-row="${p}"][data-field="${m}"]`),C=y==null?void 0:y.querySelector(".wg__date-input"),S=y==null?void 0:y.querySelector(".wg__editor--date");C&&S&&this.openDatePicker(C,S)})}}return}if(this.dropdownOpen||this.grid.editingCell){const f=l.closest(".wg__cell");if(f&&!l.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete, .wg__editor--date")){const w=parseInt(f.dataset.row||"0",10),p=parseInt(f.dataset.col||"0",10),m=this.grid.editingCell,_=l.matches(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(m&&!_){const y=this.grid.columns.findIndex(C=>String(C.field)===m.field);if(w!==m.rowIndex||p!==y){n.preventDefault(),this.isTransitioningCells=!0;const C=m.rowIndex,S=y;V(this),G(this),this.grid.cancelEdit(),this.grid.setFocusedCell(w,p),S>=0&&O(this,C,S);const v=this.grid.columns[p],x=(v==null?void 0:v.editTrigger)||this.grid.editTrigger,E=n.clientX;requestAnimationFrame(()=>{if(this.isTransitioningCells=!1,x==="click"&&v&&this.grid.isCellEditable(v,this.grid.displayItems[w])){const I=this.shadow.querySelector(`td[data-row="${w}"][data-col="${p}"]`),R=I?tt({clientX:E},I):void 0;re(this,w,p,{cursorPosition:R??void 0})}else N(this,w,p)});return}}}}if(l.matches(".wg__cell-dropdown-display")){n.preventDefault(),n.stopPropagation();const f=l.closest(".wg__cell-dropdown-display");if(f){const w=parseInt(f.dataset.row||"0",10),p=f.dataset.field||"",m=this.grid.columns.findIndex(_=>String(_.field)===p);if(m>=0){this.isTransitioningCells=!0;const _=this.grid.editingCell,y=_?this.grid.columns.findIndex(C=>String(C.field)===_.field):-1;_&&(V(this),G(this),this.grid.cancelEdit(),this.grid.setFocusedCell(w,m),y>=0&&O(this,_.rowIndex,y)),re(this,w,m),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||pe(this)})}}}}),o.addEventListener("click",n=>{const l=n.target;if(l.matches(".wg__select-trigger, .wg__select-value")){const a=l.closest(".wg__cell");if(a){const d=parseInt(a.dataset.col||"",10),c=this.grid.columns[d];if(((c==null?void 0:c.editTrigger)??this.grid.editTrigger)==="always")return}n.preventDefault(),n.stopPropagation(),Ls(this)}}),o.addEventListener("mousedown",n=>{const l=n.target,a=l.closest(".wg__resize-handle");if(a){n.preventDefault(),n.stopPropagation(),this.clearAllSelections();const h=a.dataset.field;h&&Zs(this,n,h);return}if(this.grid.isColumnReorderAllowed){const h=n;if(!h.ctrlKey&&!h.metaKey&&!h.shiftKey){const g=l.closest(".wg__header");if(g&&!g.classList.contains("wg__header--frozen")&&!g.classList.contains("wg__row-number-header")){this.clearAllSelections();const f=g.dataset.field;f&&rl(this,n,f)}}}if((!this.grid.isColumnReorderAllowed||n.shiftKey)&&n.button===0){const h=l.closest(".wg__header:not(.wg__row-number-header):not(.wg__inline-actions-header):not(.wg__actions-column):not(.wg__filler)");if(h&&!l.closest(".wg__resize-handle")&&!l.closest(".wg__sort-indicator")){const g=h.dataset.field;if(g){const f=this.grid.visualColumns.findIndex(w=>String(w.column.field)===g);f>=0&&El(this,f,n)}}}const d=l.closest(".wg__row-number[data-row-number]");if(d&&n.button===0){const h=parseInt(d.dataset.rowNumber||"-1",10);h>=0&&yl(this,h,n)}l.closest(".wg__row-number-header")&&n.button===0&&(n.preventDefault(),this.grid.selectAll(),this.grid.selectedCellRange&&Vt(this),this.render(),requestAnimationFrame(()=>{const h=this.shadow.querySelector(".wg");h==null||h.focus({preventScroll:!0})}));const u=l.closest(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");if(u&&!l.closest(".wg__header")&&!ko()&&!qi()){const h=parseInt(u.dataset.row||"-1",10);if(h>=0){const g=this.grid.focusedRowIndex;this.grid.setFocusedRow(h),this.updateRowFocusVisual(g,h)}}if(l.closest(".wg__cell")&&!l.closest(".wg__row-number, .wg__header")&&!ko()){let h=!1;this.grid.selectedRows.length>0&&(this.grid.clearSelection(),h=!0),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),h=!0),h&&this.render()}if(!l.closest(".wg__cell, .wg__row-number, .wg__header, .wg__toolbar, button, input, select, textarea")){let h=!1;this.grid.selectedCellRange&&(this.grid.clearCellSelection(),Q(),h=!0),this.grid.selectedRows.length>0&&(this.grid.clearSelection(),h=!0),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),h=!0),h&&this.render()}}),o.addEventListener("click",n=>{const l=n,a=l.target;if(a.closest(".wg__resize-handle")||a.closest(".wg__sort-indicator")||zi()||!this.grid.isColumnReorderAllowed)return;const d=a.closest(".wg__header:not(.wg__row-number-header):not(.wg__inline-actions-header):not(.wg__actions-column):not(.wg__filler)");if(d){n.preventDefault();const c=d.dataset.field;if(!c)return;const u=this.grid.visualColumns.findIndex(h=>String(h.column.field)===c);if(u===-1)return;Q(),l.ctrlKey||l.metaKey?this.grid.selectColumn(u,"toggle"):l.shiftKey?this.grid.selectColumn(u,"range"):this.grid.selectColumn(u,"replace"),this.render(),requestAnimationFrame(()=>{const h=this.shadow.querySelector(".wg");h==null||h.focus({preventScroll:!0})})}}),o.addEventListener("contextmenu",n=>{this.handleContextMenu(n)}),o.addEventListener("change",n=>{const l=n.target;l.matches(".wg__editor--checkbox")&&hs(this,l)}),o.addEventListener("input",n=>{const l=n.target;l.matches(".wg__combobox-input")?zs(this,n):l.matches(".wg__autocomplete-input")&&Os(this,n)}),this.focusEventsSubscribed||(this.focusEvents.subscribe("blur",(n,l)=>{this.focusEvents.shouldSkipBlur()||!l||!this.shadow.contains(l)||(n.matches(".wg__editor--text, .wg__editor--number")?ws(this,n):n.matches(".wg__date-input")?this.datepicker||this.commitDateEditor(n):n.matches(".wg__select-trigger")?this.handleSelectBlur(l):n.matches(".wg__combobox-input, .wg__autocomplete-input")&&this.handleComboboxBlur(n))}),this.focusEventsSubscribed=!0);const i=this.shadow.querySelector(".wg"),r=this.grid.tableBorderOnly&&this.shadow.querySelector(".wg__table-container")||i;if(i&&(i.setAttribute("tabindex","-1"),i.addEventListener("keydown",n=>{const l=this.grid.selectedRows,a=this.grid.selectedColumns,d=!!this.grid.selectedCellRange;if(l.length===0&&a.length===0&&!d||n.target.matches('input, textarea, select, [contenteditable="true"]'))return;if(n.key==="Escape"){n.preventDefault(),this.grid.selectedCellRange?(this.grid.clearCellSelection(),Q()):a.length>0?this.grid.clearColumnSelection():this.grid.clearSelection();return}if((n.ctrlKey||n.metaKey)&&n.key==="c"){n.preventDefault(),d?this.grid.copyCellSelectionToClipboard():a.length>0?this.grid.copySelectedColumnsToClipboard():l.length>0&&this.grid.copySelectedRowsToClipboard();return}const u=this.grid.rangeShortcuts;if(u!=null&&u.length)for(const h of u){const g=pt(h.key);if(mt(n,g)){const f=d?{rows:[],rowIndices:[],cellRange:this.grid.selectedCellRange,cells:this.grid.getSelectedCells()}:{rows:this.grid.getSelectedRowsData(),rowIndices:l};if(!(typeof h.disabled=="function"?h.disabled(f):h.disabled===!0)){n.preventDefault(),h.action(f);return}}}}),this.scrollEvents.init(r),this.scrollEvents.subscribe("container",()=>{const n=r.scrollLeft>0;i.classList.toggle("wg--scrolled-horizontal",n),this.dropdownOpen&&!this.isTransitioningCells&&!this.isOpeningDropdown&&this.handleScrollCloseDropdown(),this.grid.shouldUseVirtualScroll()&&this.handleVirtualScroll(r),this.grid.isInfiniteScrollEnabled&&this.grid.hasMoreItems&&!this.isLoadingMoreItems&&this.handleInfiniteScroll(r),Ye()!==null&&(ai(this,this.grid.displayItems),this.renderConnector()),Ht(this),this.grid.selectedCellRange&&Xi(this),xl(this)}),this.scrollEvents.subscribe("window",()=>{this.dropdownOpen&&!this.isTransitioningCells&&this.handleScrollCloseDropdown(),Ye()!==null&&this.closeToolbarAndReset()}),!this.clickEventsSubscribed)){const n=l=>{var d;const a=((d=this.datepicker)==null?void 0:d.getElement())??null;for(const c of l)if(a&&a===c||this.contextMenuElement&&this.contextMenuElement===c||this.headerContextMenuElement&&this.headerContextMenuElement===c)return!0;return!1};this.clickEvents.init(i,this,n),this.clickEvents.subscribe("outsideClick",()=>{let l=!1;if(this.grid.focusedCell){const{rowIndex:a,colIndex:d}=this.grid.focusedCell,c=this.shadow.querySelector(`.wg__cell[data-row="${a}"][data-col="${d}"]`);c==null||c.classList.remove("wg__cell--focused","wg__cell--always-edit-focused"),this.grid.clearFocusedCell()}if(this.grid.focusedRowIndex!==null&&(this.grid.clearRowFocus(),l=!0),this.dropdownOpen||this.grid.editingCell){const a=this.grid.editingCell,d=a?this.grid.columns.findIndex(c=>String(c.field)===a.field):-1;V(this),G(this),this.grid.cancelEdit(),a&&d>=0&&O(this,a.rowIndex,d)}this.grid.selectedCellRange&&(this.grid.clearCellSelection(),Q(),l=!0),this.grid.selectedRows.length>0&&(this.grid.clearSelection(),l=!0),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),l=!0),l&&this.render()}),this.clickEvents.subscribe("sortClick",l=>{zi()||(this.grid.selectedCellRange&&(this.grid.clearCellSelection(),Q()),this.grid.selectedRows.length>0&&(this.grid.clearSelection(),it()),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection(),rt()),Gs(this,l.event,l.field),this.render())}),this.clickEventsSubscribed=!0}o.addEventListener("mouseenter",n=>{const l=n.target,a=l.closest("[data-tooltip-html]");if(a){const c=a.getAttribute("data-tooltip-html");xo(this,a,c,this._tooltipShowDelay,!0);return}const d=l.closest("[data-tooltip]");if(d){const c=d.getAttribute("data-tooltip");xo(this,d,c,this._tooltipShowDelay,!1)}},!0),o.addEventListener("mouseleave",n=>{const l=n,a=l.target,d=l.relatedTarget,c=a.closest("[data-tooltip], [data-tooltip-html]");c&&(d==null?void 0:d.closest("[data-tooltip], [data-tooltip-html]"))===c||c&&Ft(this,this._tooltipHideDelay)},!0),o.addEventListener("click",n=>{const a=n.target.closest(".wg__toolbar-trigger");if(a&&this.grid.toolbarTrigger==="button"){n.preventDefault(),n.stopPropagation();const d=parseInt(a.dataset.toolbarTrigger||"0",10),c=o.querySelector(`tr[data-row-index="${d}"]`);c&&(uo(d)?this.closeToolbarAndReset():this.showToolbarForRow(c,d))}}),o.addEventListener("click",n=>{if(this.grid.toolbarPosition!=="inline")return;const a=n.target.closest(".wg__inline-action-btn");if(a&&!a.disabled){n.preventDefault(),n.stopPropagation();const d=a.dataset.actionId,c=parseInt(a.dataset.row||"0",10);this.handleInlineActionClick(d,c,n,a)}}),o.addEventListener("mouseenter",n=>{const l=n,d=l.target.closest(".wg__row");if(d){const c=parseInt(d.dataset.rowIndex||"0",10);this.grid.setHoveredRow(c),this.grid.toolbarPosition==="inline"&&this.setupInlineShortcuts(),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline"&&(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),uo(c)||this.showToolbarForRow(d,c,l.clientX))}},!0),o.addEventListener("mouseleave",n=>{if(n.target.closest(".wg__row")&&(this.grid.toolbarPosition==="inline"&&setTimeout(()=>{o.matches(":hover")||(this.grid.setHoveredRow(null),this.removeInlineShortcuts())},50),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline")){if(this.toolbarMoveInProgress)return;this.toolbarHideTimeout&&clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=setTimeout(()=>{const c=this.shadow.querySelector(".wg__toolbar-container"),u=c==null?void 0:c.matches(":hover"),h=o.matches(":hover");!u&&!h&&(this.grid.setHoveredRow(null),this.closeToolbarAndReset())},150)}},!0),o.addEventListener("mousemove",n=>{const l=n,a=l.target,d=a.closest(".wg__row");if(!d)return;const c=parseInt(d.dataset.rowIndex||"0",10);if(!(Ye()!==c||this.grid.toolbarPosition!=="top")){if(this.grid.toolbarFollowsCursor&&!this.grid.cellToolbar&&this.grid.toolbarColumn===void 0){const h=a.closest(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");if(h){const g=h.getBoundingClientRect(),f=go(g,this.grid.cellToolbarOffset);ho(f,d,"start")}else ho(l.clientX)}if(this.grid.cellToolbar){const h=a.closest(".wg__cell:not(.wg__row-number):not(.wg__inline-actions-cell)");if(h){const g=h.dataset.field||"",f=this.grid.visualColumns.findIndex(p=>String(p.column.field)===g);if(!this.hoveredCell||this.hoveredCell.rowIndex!==c||this.hoveredCell.field!==g){this.hoveredCell={rowIndex:c,colIndex:f,field:g};const p=this.grid.displayItems[c];if(p){const _=this.grid.cellToolbar(p,c,g,f)||this.grid.rowToolbar,y=JSON.stringify(_);y!==this.currentCellToolbarItems&&(this.currentCellToolbarItems=y,this.updateToolbarWithCellItems(c,_));const C=h.getBoundingClientRect(),S=go(C,this.grid.cellToolbarOffset);ho(S,d,"start")}}}}}}),o.addEventListener("click",n=>{if(this.grid.toolbarTrigger!=="click")return;const l=n,a=l.target,d=a.closest(".wg__row");if(d&&!a.closest(".wg__cell--editing")){const c=parseInt(d.dataset.rowIndex||"0",10);uo(c)?this.closeToolbarAndReset():this.showToolbarForRow(d,c,l.clientX)}}),this.toolbarOutsideClickAdded||(this.toolbarOutsideClickAdded=!0,document.addEventListener("click",n=>{if(!li(this.shadow))return;const l=n.composedPath(),a=l.some(u=>{var h;return(h=u.classList)==null?void 0:h.contains("wg__toolbar-container")}),d=l.some(u=>{var h;return(h=u.classList)==null?void 0:h.contains("wg__toolbar-trigger")});a||d||l.includes(this)&&(this.grid.toolbarTrigger==="hover"||this.grid.toolbarTrigger==="click")||Ye()!==null&&this.closeToolbarAndReset()}));const s=this.shadow.querySelector(".wg");s&&(s.addEventListener("click",n=>{n.target.closest(".wg__pagination-btn")&&Qs(this,n)&&this.render()}),s.addEventListener("change",n=>{const l=n.target;l.matches(".wg__pagination-select")&&Js(this,l)&&this.render()}))}scrollToRowProgrammatically(o){const i=this.shadow.querySelector(".wg");if(!i)return;const{scrollTop:r,startIndex:s,endIndex:n}=js({targetRow:o,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,viewportHeight:i.clientHeight,scrollHeight:i.scrollHeight,clientHeight:i.clientHeight});(s!==this.virtualScrollStart||n!==this.virtualScrollEnd)&&(this.virtualScrollStart=s,this.virtualScrollEnd=n,this.renderVirtualRows(i)),this.isProgrammaticScroll=!0,i.scrollTop=r,queueMicrotask(()=>{this.isProgrammaticScroll=!1})}handleVirtualScroll(o){var s;if(this.isProgrammaticScroll)return;const{startIndex:i,endIndex:r}=Ks({scrollTop:o.scrollTop,viewportHeight:o.clientHeight,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,editingRowIndex:(s=this.grid.editingCell)==null?void 0:s.rowIndex});(i!==this.virtualScrollStart||r!==this.virtualScrollEnd)&&(this.virtualScrollStart=i,this.virtualScrollEnd=r,this.renderVirtualRows(o))}renderVirtualRows(o){const i=o.querySelector("tbody");if(!i)return;const r=this.grid.displayItems,s={startIndex:this.virtualScrollStart,endIndex:this.virtualScrollEnd,rowHeight:this.grid.virtualScrollRowHeight,totalItems:r.length},n=this.grid.focusedCell;if(i.innerHTML=ui(this,s),n){this.grid.setFocusedCell(n.rowIndex,n.colIndex);const l=i.querySelector(`td[data-row="${n.rowIndex}"][data-col="${n.colIndex}"]`);l&&(l.focus({preventScroll:!0}),ee(this,null,n))}}handleInfiniteScroll(o){Xs(o.scrollTop,o.scrollHeight,o.clientHeight,this.grid.infiniteScrollThreshold)&&(this.isLoadingMoreItems=!0,this.grid.fireDataRequest("loadMore"))}renderShortcutsHelpIcon(){var n,l,a;if(!this.grid.isShortcutsHelpVisible||!((n=this.grid.rowShortcuts)!=null&&n.length))return"";const i=this.grid.shortcutsHelpPosition==="top-left"?"wg__shortcuts-help--left":"",r=this.grid.rowShortcuts.map(d=>`<div class="wg__shortcuts-help-item">
663
+ <span class="wg__shortcuts-help-key">${Ys(d.key)}</span>
664
664
  <span class="wg__shortcuts-help-label">${d.label}</span>
665
665
  </div>`).join(""),s=((a=(l=this.grid).shortcutsHelpContentCallback)==null?void 0:a.call(l))||"";return`
666
666
  <div class="wg__shortcuts-help ${i}">
@@ -679,30 +679,25 @@ toolbarColumn takes priority — cursor following is disabled.`,r)}requestUpdate
679
679
  </div>
680
680
  </div>
681
681
  </div>
682
- `}render(){var x;Jo.debug("render:",this.grid.displayItems.length,"rows,",this.grid.visualColumns.length,"columns");const o=this.shadow.querySelector(".wg"),i=this.grid.tableBorderOnly&&this.shadow.querySelector(".wg__table-container")||o,r=(i==null?void 0:i.scrollTop)||0,s=(i==null?void 0:i.scrollLeft)||0,n=this.grid.focusedCell;o&&o.remove();const l=document.createElement("div");l.className=es(this),this.grid.isScrollable&&this.grid.scrollMaxHeight!=="100vh"&&l.style.setProperty("--wg-scroll-max-height",this.grid.scrollMaxHeight);const a=this.grid.paginationPosition.split("|").map(C=>C.trim()),d=this.grid.summaryPosition?this.grid.summaryPosition.split("|").map(C=>C.trim()):[],c=(C,_)=>{const S=a.filter(M=>_?M.startsWith("top-"):M.startsWith("bottom-")),k=d.filter(M=>_?M.startsWith("top-"):M.startsWith("bottom-")),E=S.length>0,R=k.length>0;return!E&&!R?"":R&&E&&this.grid.isSummaryInline?`<div class="wg__footer${_?" wg__footer--top":""}">
683
- ${ho(this,k[0])}
684
- ${uo(this,S[0])}
685
- </div>`:[...new Set([...S,...k])].map(M=>{const z=S.includes(M),D=k.includes(M);return D&&z?`<div class="wg__footer${_?" wg__footer--top":""}">
686
- ${ho(this,M)}
687
- ${uo(this,M)}
688
- </div>`:D?ho(this,M):uo(this,M)}).join("")},u=c(a,!0),g=c(a,!1),h=this.grid.shouldUseVirtualScroll();let f;if(h){const C=this.grid.displayItems,_=this.grid.virtualScrollRowHeight,S=this.grid.virtualScrollBuffer,k=(o==null?void 0:o.clientHeight)||400,E=Math.max(0,Math.floor(r/_)-S),R=Math.ceil(k/_)+S*2,I=Math.min(C.length,E+R);this.virtualScrollStart=E,this.virtualScrollEnd=I;const M={startIndex:E,endIndex:I,rowHeight:_,totalItems:C.length};f=si(this,M)}else f=os(this);h&&l.classList.add("wg--virtual-scroll");const w=this.renderShortcutsHelpIcon(),p=`
689
- <table class="wg__table">
690
- <thead>
691
- ${ts(this)}
692
- </thead>
693
- <tbody>
694
- ${f}
695
- </tbody>
696
- </table>
697
- `,m=this.grid.tableBorderOnly?`<div class="wg__table-container">${p}</div>`:p,v=`
698
- ${w}
699
- ${u}
700
- ${m}
701
- ${g}
702
- `;l.innerHTML=v,this.shadow.appendChild(l);const y=this.grid.tableBorderOnly&&l.querySelector(".wg__table-container")||l;if(h){const C=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-y.clientHeight);y.scrollTop=Math.min(r,C)}else y.scrollTop=r;if(y.scrollLeft=s,this.attachEventListeners(),this.grid.editingCell){const{rowIndex:C,field:_}=this.grid.editingCell;let S=this.shadow.querySelector(`.wg__combobox-input[data-row="${C}"][data-field="${_}"],
703
- .wg__autocomplete-input[data-row="${C}"][data-field="${_}"],
704
- .wg__select-trigger[data-row="${C}"][data-field="${_}"],
705
- .wg__date-input[data-row="${C}"][data-field="${_}"]`);if(S||(S=this.shadow.querySelector(`.wg__editor[data-row="${C}"][data-field="${_}"]`)),S&&(S.focus(),S instanceof HTMLInputElement&&S.type==="text")){const k=this.grid.editingCell.cursorPosition,E=this.getCurrentEditingColumn(),R=((x=E==null?void 0:E.editorOptions)==null?void 0:x.editStartSelection)||this.grid.editStartSelection;if(this.grid.editingCell.initialSearchQuery!==void 0){const I=S.value.length;S.setSelectionRange(I,I)}else switch(R){case"mousePosition":if(k!==void 0){const I=Math.min(k,S.value.length);S.setSelectionRange(I,I)}else S.setSelectionRange(S.value.length,S.value.length);break;case"cursorAtStart":S.setSelectionRange(0,0);break;case"cursorAtEnd":S.setSelectionRange(S.value.length,S.value.length);break;case"selectAll":default:S.select();break}}}else if(n&&!this.grid.editingCell){const C=l.querySelector(`td[data-row="${n.rowIndex}"][data-col="${n.colIndex}"]`);C&&setTimeout(()=>C.focus(),0)}h&&requestAnimationFrame(()=>{l.style.pointerEvents="none",requestAnimationFrame(()=>{l.style.pointerEvents=""})}),this.renderConnector(),Lt(this),this.grid.selectedCellRange&&qi(this),this.grid.selectedRows.length>0?Ui(this):et(),this.grid.selectedColumns.length>0?Ki(this):tt()}renderConnector(){const o=this.shadow.querySelector(".wg__connector");o&&o.remove();const i=Jn();if(!i.path||!i.arrowPos)return;const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","wg__connector"),r.setAttribute("style","position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999;");const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",i.path),s.setAttribute("stroke","var(--wg-accent-color, #0078d4)"),s.setAttribute("stroke-width","2"),s.setAttribute("fill","none"),r.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","polygon"),l=i.arrowDir==="down"?"-4,0 4,0 0,8":i.arrowDir==="up"?"-4,0 4,0 0,-8":i.arrowDir==="left"?"0,-4 -8,0 0,4":"0,-4 8,0 0,4";n.setAttribute("points",l),n.setAttribute("fill","var(--wg-accent-color, #0078d4)"),n.setAttribute("transform",`translate(${i.arrowPos.x}, ${i.arrowPos.y})`),r.appendChild(n),this.shadow.appendChild(r)}clearAllSelections(){this.grid.selectedCellRange&&(this.grid.clearCellSelection_noRender(),G(),this.shadow.querySelectorAll(".wg__cell--in-range").forEach(i=>i.classList.remove("wg__cell--in-range"))),this.grid.selectedRows.length>0&&(this.grid.clearSelection_noRender(),et(),this.shadow.querySelectorAll(".wg__row--selected").forEach(i=>i.classList.remove("wg__row--selected"))),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection_noRender(),tt(),this.shadow.querySelectorAll(".wg__cell--column-selected").forEach(r=>r.classList.remove("wg__cell--column-selected")),this.shadow.querySelectorAll(".wg__header--selected").forEach(r=>r.classList.remove("wg__header--selected")))}updateRowFocusVisual(o,i){if(o!==i){if(o!==null){const r=this.shadow.querySelector(`tr[data-row-index="${o}"]`);r==null||r.classList.remove("wg__row--focused")}if(i!==null){const r=this.shadow.querySelector(`tr[data-row-index="${i}"]`);r==null||r.classList.add("wg__row--focused")}}}openDatePicker(o,i){console.trace("[LEGACY] openDatePicker"),this.datepicker&&(this.datepicker.close(!0),this.datepicker=null);const r=o.dataset.dateFormat||"YYYY-MM-DD",s=o.dataset.minDate,n=o.dataset.maxDate,l=o.dataset.dateValue||"";this.datepicker=new Dt({dateFormat:r,minDate:s||void 0,maxDate:n||void 0,onSelect:(a,d)=>{this.handleDatePickerSelect(o,a,d)},onClose:()=>{const a=this.grid.editingCell,d=a?this.grid.columns.findIndex(u=>String(u.field)===a.field):-1,c=(a==null?void 0:a.rowIndex)??-1;if(this.datepicker=null,K(this),this.grid.cancelEdit(),c>=0&&d>=0){ns(this,c,d);const u=this.shadow.querySelector(`.wg__cell[data-row="${c}"][data-col="${d}"]`);u&&u.focus()}}}),this.datepicker.open(i,l||null)}handleDatePickerSelect(o,i,r){console.trace("[LEGACY] handleDatePickerSelect");const s=o.dataset.dateFormat||"YYYY-MM-DD",n=Et(s);o.value=Zt(i,n),o.dataset.dateValue=It(i),this.datepicker=null,this.isCommittingFromKeyboard=!0;const l=r==="down"||r===void 0;this.commitDateEditor(o,l);const a=parseInt(o.dataset.row||"0",10),d=o.dataset.field||"";this.moveFocusAfterCommit(a,d,r||"down")}async commitDateEditor(o,i=!1){if(console.trace("[LEGACY] commitDateEditor"),!this.grid.editingCell)return;const r=parseInt(o.dataset.row||"0",10),s=o.dataset.field||"",n=o.dataset.outputFormat||"iso",l=o.dataset.dateFormat||"YYYY-MM-DD",a=Et(l),d=o.value?this.parseDateInput(o.value,a):null;let c=null;if(d)switch(n){case"date":c=d;break;case"timestamp":c=d.getTime();break;case"iso":default:c=It(d);break}await this.grid.commitEdit(r,s,c,i)}parseDateInput(o,i){if(!o)return null;const r=o.split(i.separator);let s=null,n=null,l=null;if(r.forEach((d,c)=>{var g,h,f;if(!d)return;const u=parseInt(d,10);((g=i.parts.year)==null?void 0:g.index)===c?s=u<100?u+2e3:u:((h=i.parts.month)==null?void 0:h.index)===c?n=u:((f=i.parts.day)==null?void 0:f.index)===c&&(l=u)}),s===null||n===null||l===null)return null;const a=new Date(s,n-1,l);return a.getMonth()!==n-1||a.getDate()!==l?null:a}showGoToRowDialog(o){const i=this.grid.displayItems;if(i.length===0)return;const r=document.createElement("div");r.className="wg__goto-overlay",r.innerHTML=`
682
+ `}render(){var I;this.grid.invalidateDisplayCache(),ie.reset();const o=performance.now();Ee.debug("render:",this.grid.displayItems.length,"rows,",this.grid.visualColumns.length,"columns");const i=this.shadow.querySelector(".wg"),r=this.grid.tableBorderOnly&&this.shadow.querySelector(".wg__table-container")||i,s=(r==null?void 0:r.scrollTop)||0,n=(r==null?void 0:r.scrollLeft)||0,l=this.grid.focusedCell,a=this.grid.paginationPosition.split("|").map(R=>R.trim()),d=this.grid.summaryPosition?this.grid.summaryPosition.split("|").map(R=>R.trim()):[],c=(R,P)=>{const D=a.filter($=>P?$.startsWith("top-"):$.startsWith("bottom-")),M=d.filter($=>P?$.startsWith("top-"):$.startsWith("bottom-")),A=D.length>0,F=M.length>0;return!A&&!F?"":F&&A&&this.grid.isSummaryInline?`<div class="wg__footer${P?" wg__footer--top":""}">
683
+ ${mo(this,M[0])}
684
+ ${po(this,D[0])}
685
+ </div>`:[...new Set([...D,...M])].map($=>{const Y=D.includes($),U=M.includes($);return U&&Y?`<div class="wg__footer${P?" wg__footer--top":""}">
686
+ ${mo(this,$)}
687
+ ${po(this,$)}
688
+ </div>`:U?mo(this,$):po(this,$)}).join("")},u=c(a,!0),h=c(a,!1),g=this.grid.shouldUseVirtualScroll();let f;if(g){const R=this.grid.displayItems,P=this.grid.virtualScrollRowHeight,D=this.grid.virtualScrollBuffer,M=(i==null?void 0:i.clientHeight)||400,A=Math.max(0,Math.floor(s/P)-D),F=Math.ceil(M/P)+D*2,T=Math.min(R.length,A+F);this.virtualScrollStart=A,this.virtualScrollEnd=T;const $={startIndex:A,endIndex:T,rowHeight:P,totalItems:R.length};f=ui(this,$)}else f=ss(this);const w=this.renderShortcutsHelpIcon(),p=ns(this),m=i==null?void 0:i.querySelector(".wg__table"),_=m==null?void 0:m.querySelector("thead"),y=m==null?void 0:m.querySelector("tbody"),C=i==null?void 0:i.querySelector(":scope > .wg__top-area"),S=i==null?void 0:i.querySelector(":scope > .wg__bottom-area"),v=!!(i!=null&&i.querySelector(":scope > .wg__table-container")),x=!!this.grid.tableBorderOnly,k=!!i&&!!m&&!!_&&!!y&&!!C&&!!S&&v===x;let E;if(k){if(E=i,E.className=ci(this),g&&E.classList.add("wg--virtual-scroll"),this.grid.isScrollable&&this.grid.scrollMaxHeight!=="100vh"?E.style.setProperty("--wg-scroll-max-height",this.grid.scrollMaxHeight):E.style.removeProperty("--wg-scroll-max-height"),C.innerHTML=`${w}${u}`,_.innerHTML=p,y.innerHTML=f,S.innerHTML=h,g){const R=this.grid.tableBorderOnly&&E.querySelector(".wg__table-container")||E,P=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-R.clientHeight);R.scrollTop>P&&(R.scrollTop=P)}}else{i&&i.remove(),E=document.createElement("div"),E.className=ci(this),g&&E.classList.add("wg--virtual-scroll"),this.grid.isScrollable&&this.grid.scrollMaxHeight!=="100vh"&&E.style.setProperty("--wg-scroll-max-height",this.grid.scrollMaxHeight);const R=`
689
+ <table class="wg__table">
690
+ <thead>${p}</thead>
691
+ <tbody>${f}</tbody>
692
+ </table>
693
+ `,P=this.grid.tableBorderOnly?`<div class="wg__table-container">${R}</div>`:R;E.innerHTML=`
694
+ <div class="wg__top-area">${w}${u}</div>
695
+ ${P}
696
+ <div class="wg__bottom-area">${h}</div>
697
+ `,this.shadow.appendChild(E);const D=this.grid.tableBorderOnly&&E.querySelector(".wg__table-container")||E;if(g){const M=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-D.clientHeight);D.scrollTop=Math.min(s,M)}else D.scrollTop=s;D.scrollLeft=n,this.attachEventListeners()}if(this.grid.editingCell){const{rowIndex:R,field:P}=this.grid.editingCell;let D=this.shadow.querySelector(`.wg__combobox-input[data-row="${R}"][data-field="${P}"],
698
+ .wg__autocomplete-input[data-row="${R}"][data-field="${P}"],
699
+ .wg__select-trigger[data-row="${R}"][data-field="${P}"],
700
+ .wg__date-input[data-row="${R}"][data-field="${P}"]`);if(D||(D=this.shadow.querySelector(`.wg__editor[data-row="${R}"][data-field="${P}"]`)),D&&(D.focus(),D instanceof HTMLInputElement&&D.type==="text")){const M=this.grid.editingCell.cursorPosition,A=this.getCurrentEditingColumn(),F=((I=A==null?void 0:A.editorOptions)==null?void 0:I.editStartSelection)||this.grid.editStartSelection;if(this.grid.editingCell.initialSearchQuery!==void 0){const T=D.value.length;D.setSelectionRange(T,T)}else switch(F){case"mousePosition":if(M!==void 0){const T=Math.min(M,D.value.length);D.setSelectionRange(T,T)}else D.setSelectionRange(D.value.length,D.value.length);break;case"cursorAtStart":D.setSelectionRange(0,0);break;case"cursorAtEnd":D.setSelectionRange(D.value.length,D.value.length);break;case"selectAll":default:D.select();break}}}else if(l&&!this.grid.editingCell){const R=E.querySelector(`td[data-row="${l.rowIndex}"][data-col="${l.colIndex}"]`);R&&setTimeout(()=>R.focus(),0)}g&&requestAnimationFrame(()=>{E.style.pointerEvents="none",requestAnimationFrame(()=>{E.style.pointerEvents=""})}),this.renderConnector(),Ht(this),this.grid.selectedCellRange&&Xi(this),this.grid.selectedRows.length>0?er(this):it(),this.grid.selectedColumns.length>0?tr(this):rt(),$t.debug("render() body:",(performance.now()-o).toFixed(2),"ms |",ie.summary())}renderConnector(){const o=this.shadow.querySelector(".wg__connector");o&&o.remove();const i=is();if(!i.path||!i.arrowPos)return;const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","wg__connector"),r.setAttribute("style","position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999;");const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",i.path),s.setAttribute("stroke","var(--wg-accent-color, #0078d4)"),s.setAttribute("stroke-width","2"),s.setAttribute("fill","none"),r.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","polygon"),l=i.arrowDir==="down"?"-4,0 4,0 0,8":i.arrowDir==="up"?"-4,0 4,0 0,-8":i.arrowDir==="left"?"0,-4 -8,0 0,4":"0,-4 8,0 0,4";n.setAttribute("points",l),n.setAttribute("fill","var(--wg-accent-color, #0078d4)"),n.setAttribute("transform",`translate(${i.arrowPos.x}, ${i.arrowPos.y})`),r.appendChild(n),this.shadow.appendChild(r)}clearAllSelections(){this.grid.selectedCellRange&&(this.grid.clearCellSelection_noRender(),Q(),this.shadow.querySelectorAll(".wg__cell--in-range").forEach(i=>i.classList.remove("wg__cell--in-range"))),this.grid.selectedRows.length>0&&(this.grid.clearSelection_noRender(),it(),this.shadow.querySelectorAll(".wg__row--selected").forEach(i=>i.classList.remove("wg__row--selected"))),this.grid.selectedColumns.length>0&&(this.grid.clearColumnSelection_noRender(),rt(),this.shadow.querySelectorAll(".wg__cell--column-selected").forEach(r=>r.classList.remove("wg__cell--column-selected")),this.shadow.querySelectorAll(".wg__header--selected").forEach(r=>r.classList.remove("wg__header--selected")))}updateRowFocusVisual(o,i){if(o!==i){if(o!==null){const r=this.shadow.querySelector(`tr[data-row-index="${o}"]`);r==null||r.classList.remove("wg__row--focused")}if(i!==null){const r=this.shadow.querySelector(`tr[data-row-index="${i}"]`);r==null||r.classList.add("wg__row--focused")}}}openDatePicker(o,i){this.datepicker&&(this.datepicker.close(!0),this.datepicker=null);const r=o.dataset.dateFormat||"YYYY-MM-DD",s=o.dataset.minDate,n=o.dataset.maxDate,l=o.dataset.dateValue||"";this.datepicker=new Mt({dateFormat:r,minDate:s||void 0,maxDate:n||void 0,onSelect:(a,d)=>{this.handleDatePickerSelect(o,a,d)},onClose:()=>{const a=this.grid.editingCell,d=a?this.grid.columns.findIndex(u=>String(u.field)===a.field):-1,c=(a==null?void 0:a.rowIndex)??-1;if(this.datepicker=null,G(this),this.grid.cancelEdit(),c>=0&&d>=0){ds(this,c,d);const u=this.shadow.querySelector(`.wg__cell[data-row="${c}"][data-col="${d}"]`);u&&u.focus()}}}),this.datepicker.open(i,l||null)}handleDatePickerSelect(o,i,r){const s=o.dataset.dateFormat||"YYYY-MM-DD",n=Dt(s);o.value=io(i,n),o.dataset.dateValue=Tt(i),this.datepicker=null,this.isCommittingFromKeyboard=!0;const l=r==="down"||r===void 0;this.commitDateEditor(o,l);const a=parseInt(o.dataset.row||"0",10),d=o.dataset.field||"";this.moveFocusAfterCommit(a,d,r||"down")}async commitDateEditor(o,i=!1){if(!this.grid.editingCell)return;const r=parseInt(o.dataset.row||"0",10),s=o.dataset.field||"",n=o.dataset.outputFormat||"iso",l=o.dataset.dateFormat||"YYYY-MM-DD",a=Dt(l),d=o.value?this.parseDateInput(o.value,a):null;let c=null;if(d)switch(n){case"date":c=d;break;case"timestamp":c=d.getTime();break;case"iso":default:c=Tt(d);break}await this.grid.commitEdit(r,s,c,i)}parseDateInput(o,i){if(!o)return null;const r=o.split(i.separator);let s=null,n=null,l=null;if(r.forEach((d,c)=>{var h,g,f;if(!d)return;const u=parseInt(d,10);((h=i.parts.year)==null?void 0:h.index)===c?s=u<100?u+2e3:u:((g=i.parts.month)==null?void 0:g.index)===c?n=u:((f=i.parts.day)==null?void 0:f.index)===c&&(l=u)}),s===null||n===null||l===null)return null;const a=new Date(s,n-1,l);return a.getMonth()!==n-1||a.getDate()!==l?null:a}showGoToRowDialog(o){const i=this.grid.displayItems;if(i.length===0)return;const r=document.createElement("div");r.className="wg__goto-overlay",r.innerHTML=`
706
701
  <div class="wg__goto-dialog">
707
702
  <label class="wg__goto-label">Go to row (1-${i.length}):</label>
708
703
  <input type="number" class="wg__goto-input" min="1" max="${i.length}" value="1" />
@@ -711,4 +706,4 @@ toolbarColumn takes priority — cursor following is disabled.`,r)}requestUpdate
711
706
  <button type="button" class="wg__goto-btn wg__goto-btn--go">Go</button>
712
707
  </div>
713
708
  </div>
714
- `;const s=r.querySelector(".wg__goto-input"),n=r.querySelector(".wg__goto-btn--go"),l=r.querySelector(".wg__goto-btn--cancel"),a=()=>{r.remove()},d=()=>{const c=parseInt(s.value,10);if(isNaN(c)||c<1||c>i.length){s.focus(),s.select();return}a();const u=c-1,g=this.grid.focusedCell;if(this.grid.setFocusedCell(u,o),this.grid.shouldUseVirtualScroll())this.scrollToRowProgrammatically(u),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const h=this.shadow.querySelector(`td[data-row="${u}"][data-col="${o}"]`);h==null||h.focus()})});else{const h=this.shadow.querySelector(`td[data-row="${u}"][data-col="${o}"]`);h&&(h.scrollIntoView({block:"nearest",behavior:"auto"}),h.focus(),J(this,g,{rowIndex:u,colIndex:o}))}};n.addEventListener("click",d),l.addEventListener("click",a),r.addEventListener("click",c=>{c.target===r&&a()}),s.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),d()):c.key==="Escape"&&(c.preventDefault(),a())}),this.shadow.appendChild(r),s.focus(),s.select()}openCustomEditor(o,i){const r=this.grid.columns[i];if(!r||r.editor!=="custom"||!r.cellEditCallback)return;const s=String(r.field),n=this.grid.displayItems[o];if(!n)return;const a={value:this.grid.getCellRawValue(n,o,s),row:n,rowIndex:o,field:s,commit:d=>{this.grid.commitEdit(o,s,d),K(this),requestAnimationFrame(()=>{V(this,o,i)})},cancel:()=>{K(this),this.grid.cancelEdit(),requestAnimationFrame(()=>{V(this,o,i)})}};r.cellEditCallback(a)}handleContextMenu(o){const i=o.target,r=i.closest(".wg__header");if(r){this.handleHeaderContextMenu(o,r);return}if(i.closest("th.wg__filler")){this.handleFillerContextMenu(o);return}const n=this.grid.contextMenu;if(!n||n.length===0)return;const l=i.closest(".wg__cell");if(!l)return;o.preventDefault(),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null);const a=parseInt(l.dataset.row||"0",10),d=parseInt(l.dataset.col||"0",10),c=this.grid.columns[d];if(!c)return;const u=this.grid.displayItems[a];if(!u)return;const g=String(c.field),h=this.grid.getCellRawValue(u,a,g),f={row:u,rowIndex:a,colIndex:d,column:c,cellValue:h};this.grid.oncontextmenuopen&&this.grid.oncontextmenuopen(f);const w=Object.getOwnPropertyDescriptor(this,"contextMenuXOffset"),p=Object.getOwnPropertyDescriptor(this,"contextMenuYOffset");w&&"value"in w&&(this.grid.contextMenuXOffset=w.value,delete this.contextMenuXOffset),p&&"value"in p&&(this.grid.contextMenuYOffset=p.value,delete this.contextMenuYOffset),this.contextMenuElement=Hs(this,o.clientX,o.clientY,this.grid.contextMenuXOffset,this.grid.contextMenuYOffset,n,f,m=>{const v=n.find(y=>y.id===m);v!=null&&v.onclick&&v.onclick(f),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null)},()=>{this.contextMenuElement=null})}handleHeaderContextMenu(o,i){const r=this.grid.headerContextMenu;if(!r||r.length===0)return;o.preventDefault(),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null);const s=i.dataset.field;if(!s)return;const n=this.grid.columns.findIndex(f=>String(f.field)===s);if(n===-1)return;const l=this.grid.columns[n],a=this.grid.freezeColumns,d=n<a,c=this.grid.sort.find(f=>f.column===s),u=(c==null?void 0:c.direction)??null,g={column:l,field:s,columnIndex:n,sortDirection:u,isFrozen:d,allColumns:this.grid.columns,labels:this.grid.labels};this.grid.onheadercontextmenuopen&&this.grid.onheadercontextmenuopen(g);const h=_i(r,g);h.length!==0&&(this.headerContextMenuElement=xi(this,o.clientX,o.clientY,h,g,(f,w,p)=>{if(["sortAsc","sortDesc","clearSort","hideColumn","freezeColumn","unfreezeColumn"].includes(f)&&Vs(this,f,g,p),f==="show-all-columns"){this.grid.columns.forEach(y=>{y.isHidden=!1}),this.grid.columns=[...this.grid.columns];return}if(f.startsWith("toggle-col-")){const y=f.replace("toggle-col-",""),x=this.grid.columns.find(C=>String(C.field)===y);x&&(x.isHidden=!x.isHidden,this.grid.columns=[...this.grid.columns]);return}const v=h.find(y=>y.id===f);v!=null&&v.onclick&&v.onclick(g),!w&&this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}handleFillerContextMenu(o){const i=this.grid.headerContextMenu;if(!i||i.length===0)return;o.preventDefault(),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null);const r=i.filter(l=>l==="columnVisibility"?!0:typeof l=="object"&&l.id?!(typeof l.label=="function"||typeof l.icon=="function"):(typeof l=="string"||typeof l=="object"&&l.dividerBefore&&!l.id&&!l.label,!1));if(r.length===0)return;const s={column:null,field:"",columnIndex:-1,sortDirection:null,isFrozen:!1,allColumns:this.grid.columns,labels:this.grid.labels},n=_i(r,s);n.length!==0&&(this.headerContextMenuElement=xi(this,o.clientX,o.clientY,n,s,(l,a,d)=>{if(l==="show-all-columns"){this.grid.columns.forEach(u=>{u.isHidden=!1}),this.grid.columns=[...this.grid.columns];return}if(l.startsWith("toggle-col-")){const u=l.replace("toggle-col-",""),g=this.grid.columns.find(h=>String(h.field)===u);g&&(g.isHidden=!g.isHidden,this.grid.columns=[...this.grid.columns]);return}const c=n.find(u=>u.id===l);c!=null&&c.onclick&&c.onclick(s),!a&&this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}setupToolbarShortcuts(){this.toolbarShortcutHandler&&document.removeEventListener("keydown",this.toolbarShortcutHandler);const o=this.grid.rowShortcuts;o!=null&&o.length&&(this.toolbarShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const s=We();if(s===null||!oi(this.shadow))return;const n=this.grid.displayItems[s];if(!n)return;const l=this.grid.columns;for(const a of o){const d=wt(a.key);if(pt(i,d)){const c={row:n,rowIndex:s,colIndex:0,column:l[0],cellValue:null};if(!(typeof a.disabled=="function"?a.disabled(c):a.disabled===!0)){i.preventDefault(),i.stopPropagation(),a.action(c);return}}}},document.addEventListener("keydown",this.toolbarShortcutHandler))}setupInlineShortcuts(){this.removeInlineShortcuts();const o=this.grid.rowShortcuts;!(o!=null&&o.length)||this.grid.hoveredRowIndex===null||(this.inlineShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const s=this.grid.hoveredRowIndex;if(s===null)return;const n=this.grid.displayItems[s];if(!n)return;const l=this.grid.columns;for(const a of o){const d=wt(a.key);if(pt(i,d)){const c={row:n,rowIndex:s,colIndex:0,column:l[0],cellValue:null};if(!(typeof a.disabled=="function"?a.disabled(c):a.disabled===!0)){i.preventDefault(),i.stopPropagation(),a.action(c);return}}}},document.addEventListener("keydown",this.inlineShortcutHandler))}removeInlineShortcuts(){this.inlineShortcutHandler&&(document.removeEventListener("keydown",this.inlineShortcutHandler),this.inlineShortcutHandler=null)}setupToolbarTooltips(o,i,r){const s=this.shadow.querySelector(".wg__toolbar-container");if(!s)return;s.querySelectorAll(".wg__toolbar-btn").forEach(l=>{var g;const a=l,d=a.dataset.toolbarItem,c=o.find(h=>h.id===d);if(!c)return;const u=(g=this.grid.rowShortcuts)==null?void 0:g.find(h=>h.id===c.id);a.addEventListener("mouseenter",()=>{const h=c.tooltipCallback?c.tooltipCallback(i,r):Gn(c,u==null?void 0:u.key);vo(this,a,h,0,!0)}),a.addEventListener("mouseleave",()=>{zt(this)})})}showToolbarForRow(o,i,r){if(this.grid.toolbarPosition==="inline"||!this.grid.isRowToolbarVisible||!this.grid.rowToolbar.length)return;const s=Je(this.grid.rowToolbar),n=this.grid.displayItems[i];if(!n)return;if(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),zt(this,0),this.currentCellToolbarItems=null,Qn(this,o,i,s,n,(a,d,c)=>{this.handleToolbarItemClick(a,i,n,d,c)},r),this.setupToolbarShortcuts(),this.renderConnector(),this.setupToolbarTooltips(s,n,i),this.grid.toolbarTrigger==="hover"){const a=this.shadow.querySelector(".wg__toolbar-container");a&&(a.addEventListener("mouseenter",()=>{this.toolbarHovered=!0,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null)}),a.addEventListener("mouseleave",()=>{this.toolbarHovered=!1,!this.toolbarMoveInProgress&&(this.toolbarHideTimeout=setTimeout(()=>{const d=this.shadow.querySelector(".wg__table"),c=d==null?void 0:d.matches(":hover"),u=a.matches(":hover");!c&&!u&&this.closeToolbarAndReset()},150))}))}const l=this.shadow.querySelector(`[data-toolbar-trigger="${i}"]`);l&&(this.shadow.querySelectorAll(".wg__toolbar-trigger--active").forEach(a=>{a.classList.remove("wg__toolbar-trigger--active")}),l.classList.add("wg__toolbar-trigger--active"))}closeToolbarAndReset(){this.toolbarMoveInProgress=!1,this.toolbarHovered=!1,this.hoveredCell=null,this.currentCellToolbarItems=null,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),this.toolbarShortcutHandler&&(document.removeEventListener("keydown",this.toolbarShortcutHandler),this.toolbarShortcutHandler=null),zt(this,0),Tt()}updateToolbarWithCellItems(o,i){const r=this.grid.displayItems[o];if(!r)return;const s=Je(this.grid.rowToolbar),n=Je(i),l=new Map(n.map(f=>[f.id,f])),a=[...n];for(const f of s)l.has(f.id)||a.push(f);a.sort((f,w)=>f.row!==w.row?f.row-w.row:f.group-w.group);const d=this.grid.toolbarVerticalAlign!=="top",c=Zn();if(!c)return;const u=ti(a,r,o,d),g=document.createElement("div");g.innerHTML=u;const h=g.querySelector(".wg__toolbar");if(h){const{left:f,top:w,position:p,visibility:m}=c.toolbar.style;c.toolbar.innerHTML=h.innerHTML,c.toolbar.style.left=f,c.toolbar.style.top=w,c.toolbar.style.position=p,c.toolbar.style.visibility=m,this.setupToolbarTooltips(a,r,o)}}handleScrollCloseDropdown(){const o=this.grid.editingCell,i=o?this.grid.columns.findIndex(r=>String(r.field)===o.field):-1;q(this),K(this),this.grid.cancelEdit(),o&&i>=0&&H(this,o.rowIndex,i)}handleSelectBlur(o){if(this.isOpeningDropdown||o!=null&&o.closest(".wg__dropdown"))return;const i=this.grid.editingCell,r=i?this.grid.columns.findIndex(s=>String(s.field)===i.field):-1;q(this),K(this),this.grid.cancelEdit(),i&&r>=0&&H(this,i.rowIndex,r)}handleComboboxBlur(o){if(q(this),this.grid.editingCell){const i=this.grid.editingCell,r=this.grid.columns.findIndex(n=>String(n.field)===i.field),s=this.getCurrentEditingColumn();if(s){const n=s.editorOptions||{},a=(n.options||n.initialOptions||[]).find(c=>Be(c,n).toLowerCase()===o.value.toLowerCase()),d=a?Ae(a,n):o.value;K(this),this.grid.commitEdit(i.rowIndex,i.field,d),r>=0&&H(this,i.rowIndex,r)}}}handleToolbarItemClick(o,i,r,s,n){var d;(d=this.pipelineAdapter)==null||d.clearSelection();const l=this.grid.displayItems.findIndex(c=>c===r);if(l===-1){this.closeToolbarAndReset();return}const a=o.id==="moveUp"||o.id==="moveDown";if(a&&(this.toolbarMoveInProgress=!0),o.onclick&&o.onclick({row:r,rowIndex:l}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:o,rowIndex:l,row:r,event:s,triggerElement:n}),o.id==="delete"){this.closeToolbarAndReset();return}a?(this.render(),ii(this,this.grid.displayItems),this.renderConnector()):this.render()}handleInlineActionClick(o,i,r,s){var d;if(!o)return;(d=this.pipelineAdapter)==null||d.clearSelection();const l=Je(this.grid.rowToolbar).find(c=>c.id===o),a=this.grid.displayItems[i];!l||!a||(l.onclick&&l.onclick({row:a,rowIndex:i}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:l,rowIndex:i,row:a,event:r,triggerElement:s}))}}typeof customElements<"u"&&!customElements.get("web-grid")&&customElements.define("web-grid",xo),typeof window<"u"&&(window.components=window.components||{},window.components["web-grid"]={version:()=>"1.0.5",config:{name:"@keenmate/web-grid",version:"1.0.5",author:"KeenMate",license:"MIT",repository:"git+https://github.com/KeenMate/web-grid.git",homepage:"https://github.com/KeenMate/web-grid#readme"},logging:{enableLogging:Vn,disableLogging:qn,setLogLevel:Nn,setCategoryLevel:Bn,getCategories:()=>[...Fn]}}),oe.GridElement=xo,oe.WebGrid=ei,oe.default=xo,Object.defineProperties(oe,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
709
+ `;const s=r.querySelector(".wg__goto-input"),n=r.querySelector(".wg__goto-btn--go"),l=r.querySelector(".wg__goto-btn--cancel"),a=()=>{r.remove()},d=()=>{const c=parseInt(s.value,10);if(isNaN(c)||c<1||c>i.length){s.focus(),s.select();return}a();const u=c-1,h=this.grid.focusedCell;if(this.grid.setFocusedCell(u,o),this.grid.shouldUseVirtualScroll())this.scrollToRowProgrammatically(u),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const g=this.shadow.querySelector(`td[data-row="${u}"][data-col="${o}"]`);g==null||g.focus()})});else{const g=this.shadow.querySelector(`td[data-row="${u}"][data-col="${o}"]`);g&&(g.scrollIntoView({block:"nearest",behavior:"auto"}),g.focus(),ee(this,h,{rowIndex:u,colIndex:o}))}};n.addEventListener("click",d),l.addEventListener("click",a),r.addEventListener("click",c=>{c.target===r&&a()}),s.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),d()):c.key==="Escape"&&(c.preventDefault(),a())}),this.shadow.appendChild(r),s.focus(),s.select()}openCustomEditor(o,i){const r=this.grid.columns[i];if(!r||r.editor!=="custom"||!r.cellEditCallback)return;const s=String(r.field),n=this.grid.displayItems[o];if(!n)return;const a={value:this.grid.getCellRawValue(n,o,s),row:n,rowIndex:o,field:s,commit:async d=>{G(this),await this.grid.commitEdit(o,s,d),O(this,o,i),requestAnimationFrame(()=>{N(this,o,i)})},cancel:()=>{G(this),this.grid.cancelEdit(),O(this,o,i),requestAnimationFrame(()=>{N(this,o,i)})}};r.cellEditCallback(a)}handleContextMenu(o){const i=o.target,r=i.closest(".wg__header");if(r){this.handleHeaderContextMenu(o,r);return}if(i.closest("th.wg__filler")){this.handleFillerContextMenu(o);return}const n=this.grid.contextMenu;if(!n||n.length===0)return;const l=qs(n,this.grid),a=i.closest(".wg__cell");if(!a)return;o.preventDefault(),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null);const d=parseInt(a.dataset.row||"0",10),c=parseInt(a.dataset.col||"0",10),u=this.grid.columns[c];if(!u)return;const h=this.grid.displayItems[d];if(!h)return;const g=String(u.field),f=this.grid.getCellRawValue(h,d,g),w={row:h,rowIndex:d,colIndex:c,column:u,cellValue:f};this.grid.oncontextmenuopen&&this.grid.oncontextmenuopen(w);const p=Object.getOwnPropertyDescriptor(this,"contextMenuXOffset"),m=Object.getOwnPropertyDescriptor(this,"contextMenuYOffset");p&&"value"in p&&(this.grid.contextMenuXOffset=p.value,delete this.contextMenuXOffset),m&&"value"in m&&(this.grid.contextMenuYOffset=m.value,delete this.contextMenuYOffset),this.contextMenuElement=Bs(this,o.clientX,o.clientY,this.grid.contextMenuXOffset,this.grid.contextMenuYOffset,l,w,_=>{const y=l.find(C=>C.id===_);y!=null&&y.onclick&&y.onclick(w),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null)},()=>{this.contextMenuElement=null})}handleHeaderContextMenu(o,i){const r=this.grid.headerContextMenu;if(!r||r.length===0)return;o.preventDefault(),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null);const s=i.dataset.field;if(!s)return;const n=this.grid.columns.findIndex(f=>String(f.field)===s);if(n===-1)return;const l=this.grid.columns[n],a=this.grid.freezeColumns,d=n<a,c=this.grid.sort.find(f=>f.column===s),u=(c==null?void 0:c.direction)??null,h={column:l,field:s,columnIndex:n,sortDirection:u,isFrozen:d,isTreeMode:this.grid.isTreeMode,allColumns:this.grid.columns,labels:this.grid.labels};this.grid.onheadercontextmenuopen&&this.grid.onheadercontextmenuopen(h);const g=Ei(r,h);g.length!==0&&(this.headerContextMenuElement=$i(this,o.clientX,o.clientY,g,h,(f,w,p)=>{if(["sortAsc","sortDesc","clearSort","hideColumn","freezeColumn","unfreezeColumn"].includes(f)&&Us(this,f,h,p),f==="show-all-columns"){this.grid.columns.forEach(y=>{y.isHidden=!1}),this.grid.columns=[...this.grid.columns];return}if(f.startsWith("toggle-col-")){const y=f.replace("toggle-col-",""),C=this.grid.columns.find(S=>String(S.field)===y);C&&(C.isHidden=!C.isHidden,this.grid.columns=[...this.grid.columns]);return}const _=g.find(y=>y.id===f);_!=null&&_.onclick&&_.onclick(h),!w&&this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}handleFillerContextMenu(o){const i=this.grid.headerContextMenu;if(!i||i.length===0)return;o.preventDefault(),this.contextMenuElement&&(ce(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null);const r=i.filter(l=>l==="columnVisibility"?!0:typeof l=="object"&&l.id?!(typeof l.label=="function"||typeof l.icon=="function"):(typeof l=="string"||typeof l=="object"&&l.dividerBefore&&!l.id&&!l.label,!1));if(r.length===0)return;const s={column:null,field:"",columnIndex:-1,sortDirection:null,isFrozen:!1,isTreeMode:this.grid.isTreeMode,allColumns:this.grid.columns,labels:this.grid.labels},n=Ei(r,s);n.length!==0&&(this.headerContextMenuElement=$i(this,o.clientX,o.clientY,n,s,(l,a,d)=>{if(l==="show-all-columns"){this.grid.columns.forEach(u=>{u.isHidden=!1}),this.grid.columns=[...this.grid.columns];return}if(l.startsWith("toggle-col-")){const u=l.replace("toggle-col-",""),h=this.grid.columns.find(g=>String(g.field)===u);h&&(h.isHidden=!h.isHidden,this.grid.columns=[...this.grid.columns]);return}const c=n.find(u=>u.id===l);c!=null&&c.onclick&&c.onclick(s),!a&&this.headerContextMenuElement&&(ce(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}setupToolbarShortcuts(){this.toolbarShortcutHandler&&document.removeEventListener("keydown",this.toolbarShortcutHandler);const o=this.grid.rowShortcuts;o!=null&&o.length&&(this.toolbarShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const s=Ye();if(s===null||!li(this.shadow))return;const n=this.grid.displayItems[s];if(!n)return;const l=this.grid.columns;for(const a of o){const d=pt(a.key);if(mt(i,d)){const c={row:n,rowIndex:s,colIndex:0,column:l[0],cellValue:null};if(!(typeof a.disabled=="function"?a.disabled(c):a.disabled===!0)){i.preventDefault(),i.stopPropagation(),a.action(c);return}}}},document.addEventListener("keydown",this.toolbarShortcutHandler))}setupInlineShortcuts(){this.removeInlineShortcuts();const o=this.grid.rowShortcuts;!(o!=null&&o.length)||this.grid.hoveredRowIndex===null||(this.inlineShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const s=this.grid.hoveredRowIndex;if(s===null)return;const n=this.grid.displayItems[s];if(!n)return;const l=this.grid.columns;for(const a of o){const d=pt(a.key);if(mt(i,d)){const c={row:n,rowIndex:s,colIndex:0,column:l[0],cellValue:null};if(!(typeof a.disabled=="function"?a.disabled(c):a.disabled===!0)){i.preventDefault(),i.stopPropagation(),a.action(c);return}}}},document.addEventListener("keydown",this.inlineShortcutHandler))}removeInlineShortcuts(){this.inlineShortcutHandler&&(document.removeEventListener("keydown",this.inlineShortcutHandler),this.inlineShortcutHandler=null)}setupToolbarTooltips(o,i,r){const s=this.shadow.querySelector(".wg__toolbar-container");if(!s)return;s.querySelectorAll(".wg__toolbar-btn").forEach(l=>{var h;const a=l,d=a.dataset.toolbarItem,c=o.find(g=>g.id===d);if(!c)return;const u=(h=this.grid.rowShortcuts)==null?void 0:h.find(g=>g.id===c.id);a.addEventListener("mouseenter",()=>{const g=c.tooltipCallback?c.tooltipCallback(i,r):ts(c,u==null?void 0:u.key);xo(this,a,g,0,!0)}),a.addEventListener("mouseleave",()=>{Ft(this)})})}showToolbarForRow(o,i,r){if(this.grid.toolbarPosition==="inline"||!this.grid.isRowToolbarVisible||!this.grid.rowToolbar.length)return;const s=et(this.grid.rowToolbar),n=this.grid.displayItems[i];if(!n)return;if(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),Ft(this,0),this.currentCellToolbarItems=null,os(this,o,i,s,n,(a,d,c)=>{this.handleToolbarItemClick(a,i,n,d,c)},r),this.setupToolbarShortcuts(),this.renderConnector(),this.setupToolbarTooltips(s,n,i),this.grid.toolbarTrigger==="hover"){const a=this.shadow.querySelector(".wg__toolbar-container");a&&(a.addEventListener("mouseenter",()=>{this.toolbarHovered=!0,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null)}),a.addEventListener("mouseleave",()=>{this.toolbarHovered=!1,!this.toolbarMoveInProgress&&(this.toolbarHideTimeout=setTimeout(()=>{const d=this.shadow.querySelector(".wg__table"),c=d==null?void 0:d.matches(":hover"),u=a.matches(":hover");!c&&!u&&this.closeToolbarAndReset()},150))}))}const l=this.shadow.querySelector(`[data-toolbar-trigger="${i}"]`);l&&(this.shadow.querySelectorAll(".wg__toolbar-trigger--active").forEach(a=>{a.classList.remove("wg__toolbar-trigger--active")}),l.classList.add("wg__toolbar-trigger--active"))}closeToolbarAndReset(){this.toolbarMoveInProgress=!1,this.toolbarHovered=!1,this.hoveredCell=null,this.currentCellToolbarItems=null,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),this.toolbarShortcutHandler&&(document.removeEventListener("keydown",this.toolbarShortcutHandler),this.toolbarShortcutHandler=null),Ft(this,0),At()}updateToolbarWithCellItems(o,i){const r=this.grid.displayItems[o];if(!r)return;const s=et(this.grid.rowToolbar),n=et(i),l=new Map(n.map(f=>[f.id,f])),a=[...n];for(const f of s)l.has(f.id)||a.push(f);a.sort((f,w)=>f.row!==w.row?f.row-w.row:f.group-w.group);const d=this.grid.toolbarVerticalAlign!=="top",c=rs();if(!c)return;const u=si(a,r,o,d),h=document.createElement("div");h.innerHTML=u;const g=h.querySelector(".wg__toolbar");if(g){const{left:f,top:w,position:p,visibility:m}=c.toolbar.style;c.toolbar.innerHTML=g.innerHTML,c.toolbar.style.left=f,c.toolbar.style.top=w,c.toolbar.style.position=p,c.toolbar.style.visibility=m,this.setupToolbarTooltips(a,r,o)}}handleScrollCloseDropdown(){const o=this.grid.editingCell,i=o?this.grid.columns.findIndex(r=>String(r.field)===o.field):-1;V(this),G(this),this.grid.cancelEdit(),o&&i>=0&&O(this,o.rowIndex,i)}handleSelectBlur(o){if(this.isOpeningDropdown||o!=null&&o.closest(".wg__dropdown"))return;const i=this.grid.editingCell,r=i?this.grid.columns.findIndex(s=>String(s.field)===i.field):-1;V(this),G(this),this.grid.cancelEdit(),i&&r>=0&&O(this,i.rowIndex,r)}handleComboboxBlur(o){if(V(this),this.grid.editingCell){const i=this.grid.editingCell,r=this.grid.columns.findIndex(n=>String(n.field)===i.field),s=this.getCurrentEditingColumn();if(s){const n=s.editorOptions||{},a=(n.options||n.initialOptions||[]).find(c=>Ue(c,n).toLowerCase()===o.value.toLowerCase()),d=a?ze(a,n):o.value;G(this),this.grid.commitEdit(i.rowIndex,i.field,d),r>=0&&O(this,i.rowIndex,r)}}}handleToolbarItemClick(o,i,r,s,n){var d;(d=this.pipelineAdapter)==null||d.clearSelection();const l=this.grid.displayItems.findIndex(c=>c===r);if(l===-1){this.closeToolbarAndReset();return}const a=o.id==="moveUp"||o.id==="moveDown";if(a&&(this.toolbarMoveInProgress=!0),o.onclick&&o.onclick({row:r,rowIndex:l}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:o,rowIndex:l,row:r,event:s,triggerElement:n}),o.id==="delete"){this.closeToolbarAndReset();return}a?(this.render(),ai(this,this.grid.displayItems),this.renderConnector()):this.render()}handleInlineActionClick(o,i,r,s){var d;if(!o)return;(d=this.pipelineAdapter)==null||d.clearSelection();const l=et(this.grid.rowToolbar).find(c=>c.id===o),a=this.grid.displayItems[i];!l||!a||(l.onclick&&l.onclick({row:a,rowIndex:i}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:l,rowIndex:i,row:a,event:r,triggerElement:s}))}}typeof customElements<"u"&&!customElements.get("web-grid")&&customElements.define("web-grid",Ro),typeof window<"u"&&(window.components=window.components||{},window.components["web-grid"]={version:()=>"1.2.0-rc01",config:{name:"@keenmate/web-grid",version:"1.2.0-rc01",author:"KeenMate",license:"MIT",repository:"git+https://github.com/KeenMate/web-grid.git",homepage:"https://github.com/KeenMate/web-grid#readme"},logging:{enableLogging:Un,disableLogging:Yn,setLogLevel:Kn,setCategoryLevel:jn,getCategories:()=>[...Wn]}}),ne.GridElement=Ro,ne.WebGrid=ni,ne.default=Ro,Object.defineProperties(ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});