evalution 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{check-BTg6THHB.d.ts → check-CR4fU1S5.d.ts} +43 -15
- package/dist/checks/index.d.ts +1 -1
- package/dist/cli/index.js +50 -21
- package/dist/client/assets/DatasetView-BqSWI_pm.js +15 -0
- package/dist/client/assets/EvalRunView-CR6ZksSu.js +2 -0
- package/dist/client/assets/EvalView-JPEM5IY8.js +1 -0
- package/dist/client/assets/{data-grid-overlay-editor-CBVV2omk.js → data-grid-overlay-editor-B_nPhXKR.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-BqsjUFPI.js → highlighted-body-KPVGNVTW-dPpneB8R.js} +1 -1
- package/dist/client/assets/{index-B7OFMd2c.css → index-BGcZZetP.css} +1 -1
- package/dist/client/assets/{index-DOmAST6D.js → index-CwjMcK6S.js} +137 -137
- package/dist/client/assets/{number-overlay-editor-DhCVhD05.js → number-overlay-editor-CRWFlaQs.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/{dataset-types-CSjbM_Vz.d.ts → dataset-types-Dqi5vVg-.d.ts} +20 -5
- package/dist/index.d.ts +8 -7
- package/dist/index.js +22 -11
- package/dist/{trace-Dn6Pfcc5.d.ts → trace-DGj5oW7z.d.ts} +1 -1
- package/dist/{trace-event-ingestor-DI-HkA4Q.js → trace-event-ingestor-BghQcCHe.js} +124 -16
- package/dist/views/datasets/index.d.ts +1 -1
- package/dist/views/index.d.ts +2 -2
- package/dist/views/react/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/client/assets/DatasetView-CWw3B_XI.js +0 -15
- package/dist/client/assets/EvalRunView-DJNSAydj.js +0 -2
- package/dist/client/assets/EvalView-R0Nkikzs.js +0 -1
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/data-grid-overlay-editor-CBVV2omk.js","assets/index-DOmAST6D.js","assets/index-B7OFMd2c.css","assets/number-overlay-editor-DhCVhD05.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var sd=Object.defineProperty;var ad=(e,t,n)=>t in e?sd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xe=(e,t,n)=>ad(e,typeof t!="symbol"?t+"":t,n);import{ac as bi,ad as Lr,r as c,ab as zt,ae as Zl,af as ld,ag as Ql,ah as cd,ai as ei,aa as go,j as v,aj as ud,$ as Di,a8 as dd,ak as fd,al as ec,am as hd,an as tc,ao as gd,ap as md,aq as Ia,ar as Mi,a5 as pd,V as bd,a6 as yd,W as vd,as as nc,at as rc,au as wd,av as xd,aw as Cd,ax as Ea,ay as kd,az as Ms,a0 as Sd,R as Rd,L as Md,F as Id,a2 as Ed,a4 as Td,aA as Dd,E as oc,aB as $d,aC as Ta,aD as Ad,aE as Fd,aF as _d,v as Pd,aG as Od,A as jd,aH as Nd,aI as Hd,aJ as Bd,aK as Ld,aL as zd,aM as Da,aN as Wd,aO as Gd,aP as Ud,aQ as Xd,T as yi,aR as $a,H as Kd,G as Yd,aS as qd,f as Vd,I as Aa,P as Jd,aT as Zd,aU as Qd,aV as ef,aW as Fa,aX as tf,aY as nf,aZ as rf,a_ as of,a$ as sf,b0 as af,b1 as lf,b2 as cf,b3 as uf,M as df,N as ff}from"./index-DOmAST6D.js";var hf=Object.prototype,gf=hf.hasOwnProperty;function mf(e,t){return e!=null&&gf.call(e,t)}var pf=mf,bf=Array.isArray,Xn=bf,yf=typeof bi=="object"&&bi&&bi.Object===Object&&bi,ic=yf,vf=ic,wf=typeof self=="object"&&self&&self.Object===Object&&self,xf=vf||wf||Function("return this")(),Kn=xf,Cf=Kn,kf=Cf.Symbol,ti=kf,_a=ti,sc=Object.prototype,Sf=sc.hasOwnProperty,Rf=sc.toString,jo=_a?_a.toStringTag:void 0;function Mf(e){var t=Sf.call(e,jo),n=e[jo];try{e[jo]=void 0;var r=!0}catch{}var o=Rf.call(e);return r&&(t?e[jo]=n:delete e[jo]),o}var If=Mf,Ef=Object.prototype,Tf=Ef.toString;function Df(e){return Tf.call(e)}var $f=Df,Pa=ti,Af=If,Ff=$f,_f="[object Null]",Pf="[object Undefined]",Oa=Pa?Pa.toStringTag:void 0;function Of(e){return e==null?e===void 0?Pf:_f:Oa&&Oa in Object(e)?Af(e):Ff(e)}var ni=Of;function jf(e){return e!=null&&typeof e=="object"}var ri=jf,Nf=ni,Hf=ri,Bf="[object Symbol]";function Lf(e){return typeof e=="symbol"||Hf(e)&&Nf(e)==Bf}var Li=Lf,zf=Xn,Wf=Li,Gf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Uf=/^\w*$/;function Xf(e,t){if(zf(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Wf(e)?!0:Uf.test(e)||!Gf.test(e)||t!=null&&e in Object(t)}var Ws=Xf;function Kf(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var bo=Kf,Yf=ni,qf=bo,Vf="[object AsyncFunction]",Jf="[object Function]",Zf="[object GeneratorFunction]",Qf="[object Proxy]";function eh(e){if(!qf(e))return!1;var t=Yf(e);return t==Jf||t==Zf||t==Vf||t==Qf}var ac=eh,th=Kn,nh=th["__core-js_shared__"],rh=nh,cs=rh,ja=function(){var e=/[^.]+$/.exec(cs&&cs.keys&&cs.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function oh(e){return!!ja&&ja in e}var ih=oh,sh=Function.prototype,ah=sh.toString;function lh(e){if(e!=null){try{return ah.call(e)}catch{}try{return e+""}catch{}}return""}var lc=lh,ch=ac,uh=ih,dh=bo,fh=lc,hh=/[\\^$.*+?()[\]{}|]/g,gh=/^\[object .+?Constructor\]$/,mh=Function.prototype,ph=Object.prototype,bh=mh.toString,yh=ph.hasOwnProperty,vh=RegExp("^"+bh.call(yh).replace(hh,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function wh(e){if(!dh(e)||uh(e))return!1;var t=ch(e)?vh:gh;return t.test(fh(e))}var xh=wh;function Ch(e,t){return e==null?void 0:e[t]}var kh=Ch,Sh=xh,Rh=kh;function Mh(e,t){var n=Rh(e,t);return Sh(n)?n:void 0}var zr=Mh,Ih=zr,Eh=Ih(Object,"create"),zi=Eh,Na=zi;function Th(){this.__data__=Na?Na(null):{},this.size=0}var Dh=Th;function $h(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ah=$h,Fh=zi,_h="__lodash_hash_undefined__",Ph=Object.prototype,Oh=Ph.hasOwnProperty;function jh(e){var t=this.__data__;if(Fh){var n=t[e];return n===_h?void 0:n}return Oh.call(t,e)?t[e]:void 0}var Nh=jh,Hh=zi,Bh=Object.prototype,Lh=Bh.hasOwnProperty;function zh(e){var t=this.__data__;return Hh?t[e]!==void 0:Lh.call(t,e)}var Wh=zh,Gh=zi,Uh="__lodash_hash_undefined__";function Xh(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Gh&&t===void 0?Uh:t,this}var Kh=Xh,Yh=Dh,qh=Ah,Vh=Nh,Jh=Wh,Zh=Kh;function yo(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}yo.prototype.clear=Yh;yo.prototype.delete=qh;yo.prototype.get=Vh;yo.prototype.has=Jh;yo.prototype.set=Zh;var Qh=yo;function eg(){this.__data__=[],this.size=0}var tg=eg;function ng(e,t){return e===t||e!==e&&t!==t}var Gs=ng,rg=Gs;function og(e,t){for(var n=e.length;n--;)if(rg(e[n][0],t))return n;return-1}var Wi=og,ig=Wi,sg=Array.prototype,ag=sg.splice;function lg(e){var t=this.__data__,n=ig(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():ag.call(t,n,1),--this.size,!0}var cg=lg,ug=Wi;function dg(e){var t=this.__data__,n=ug(t,e);return n<0?void 0:t[n][1]}var fg=dg,hg=Wi;function gg(e){return hg(this.__data__,e)>-1}var mg=gg,pg=Wi;function bg(e,t){var n=this.__data__,r=pg(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var yg=bg,vg=tg,wg=cg,xg=fg,Cg=mg,kg=yg;function vo(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}vo.prototype.clear=vg;vo.prototype.delete=wg;vo.prototype.get=xg;vo.prototype.has=Cg;vo.prototype.set=kg;var Gi=vo,Sg=zr,Rg=Kn,Mg=Sg(Rg,"Map"),Us=Mg,Ha=Qh,Ig=Gi,Eg=Us;function Tg(){this.size=0,this.__data__={hash:new Ha,map:new(Eg||Ig),string:new Ha}}var Dg=Tg;function $g(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Ag=$g,Fg=Ag;function _g(e,t){var n=e.__data__;return Fg(t)?n[typeof t=="string"?"string":"hash"]:n.map}var Ui=_g,Pg=Ui;function Og(e){var t=Pg(this,e).delete(e);return this.size-=t?1:0,t}var jg=Og,Ng=Ui;function Hg(e){return Ng(this,e).get(e)}var Bg=Hg,Lg=Ui;function zg(e){return Lg(this,e).has(e)}var Wg=zg,Gg=Ui;function Ug(e,t){var n=Gg(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var Xg=Ug,Kg=Dg,Yg=jg,qg=Bg,Vg=Wg,Jg=Xg;function wo(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}wo.prototype.clear=Kg;wo.prototype.delete=Yg;wo.prototype.get=qg;wo.prototype.has=Vg;wo.prototype.set=Jg;var Xs=wo,cc=Xs,Zg="Expected a function";function Ks(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Zg);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var a=e.apply(this,r);return n.cache=i.set(o,a)||i,a};return n.cache=new(Ks.Cache||cc),n}Ks.Cache=cc;var Qg=Ks,em=Qg,tm=500;function nm(e){var t=em(e,function(r){return n.size===tm&&n.clear(),r}),n=t.cache;return t}var rm=nm,om=rm,im=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,sm=/\\(\\)?/g,am=om(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(im,function(n,r,o,i){t.push(o?i.replace(sm,"$1"):r||n)}),t}),lm=am;function cm(e,t){for(var n=-1,r=e==null?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}var um=cm,Ba=ti,dm=um,fm=Xn,hm=Li,La=Ba?Ba.prototype:void 0,za=La?La.toString:void 0;function uc(e){if(typeof e=="string")return e;if(fm(e))return dm(e,uc)+"";if(hm(e))return za?za.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var gm=uc,mm=gm;function pm(e){return e==null?"":mm(e)}var bm=pm,ym=Xn,vm=Ws,wm=lm,xm=bm;function Cm(e,t){return ym(e)?e:vm(e,t)?[e]:wm(xm(e))}var dc=Cm,km=ni,Sm=ri,Rm="[object Arguments]";function Mm(e){return Sm(e)&&km(e)==Rm}var Im=Mm,Wa=Im,Em=ri,fc=Object.prototype,Tm=fc.hasOwnProperty,Dm=fc.propertyIsEnumerable,$m=Wa(function(){return arguments}())?Wa:function(e){return Em(e)&&Tm.call(e,"callee")&&!Dm.call(e,"callee")},Ys=$m,Am=9007199254740991,Fm=/^(?:0|[1-9]\d*)$/;function _m(e,t){var n=typeof e;return t=t??Am,!!t&&(n=="number"||n!="symbol"&&Fm.test(e))&&e>-1&&e%1==0&&e<t}var qs=_m,Pm=9007199254740991;function Om(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Pm}var Vs=Om,jm=Li;function Nm(e){if(typeof e=="string"||jm(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var Xi=Nm,Hm=dc,Bm=Ys,Lm=Xn,zm=qs,Wm=Vs,Gm=Xi;function Um(e,t,n){t=Hm(t,e);for(var r=-1,o=t.length,i=!1;++r<o;){var a=Gm(t[r]);if(!(i=e!=null&&n(e,a)))break;e=e[a]}return i||++r!=o?i:(o=e==null?0:e.length,!!o&&Wm(o)&&zm(a,o)&&(Lm(e)||Bm(e)))}var hc=Um,Xm=pf,Km=hc;function Ym(e,t){return e!=null&&Km(e,t,Xm)}var qm=Ym;const Vm=Lr(qm);function gc(e="This should not happen"){throw new Error(e)}function pn(e,t="Assertion failed"){if(!e)return gc(t)}function Vo(e,t){return gc(t??"Hell froze over")}function Jm(e,t){try{return e()}catch{return t}}const Ga=Object.prototype.hasOwnProperty;function mo(e,t){let n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&mo(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(Ga.call(e,n)&&++r&&!Ga.call(t,n)||!(n in t)||!mo(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}const $i=null,Js=void 0;var ue;(function(e){e.Uri="uri",e.Text="text",e.Image="image",e.RowID="row-id",e.Number="number",e.Bubble="bubble",e.Boolean="boolean",e.Loading="loading",e.Markdown="markdown",e.Drilldown="drilldown",e.Protected="protected",e.Custom="custom"})(ue||(ue={}));var Ua;(function(e){e.HeaderRowID="headerRowID",e.HeaderCode="headerCode",e.HeaderNumber="headerNumber",e.HeaderString="headerString",e.HeaderBoolean="headerBoolean",e.HeaderAudioUri="headerAudioUri",e.HeaderVideoUri="headerVideoUri",e.HeaderEmoji="headerEmoji",e.HeaderImage="headerImage",e.HeaderUri="headerUri",e.HeaderPhone="headerPhone",e.HeaderMarkdown="headerMarkdown",e.HeaderDate="headerDate",e.HeaderTime="headerTime",e.HeaderEmail="headerEmail",e.HeaderReference="headerReference",e.HeaderIfThenElse="headerIfThenElse",e.HeaderSingleValue="headerSingleValue",e.HeaderLookup="headerLookup",e.HeaderTextTemplate="headerTextTemplate",e.HeaderMath="headerMath",e.HeaderRollup="headerRollup",e.HeaderJoinStrings="headerJoinStrings",e.HeaderSplitString="headerSplitString",e.HeaderGeoDistance="headerGeoDistance",e.HeaderArray="headerArray",e.RowOwnerOverlay="rowOwnerOverlay",e.ProtectedColumnOverlay="protectedColumnOverlay"})(Ua||(Ua={}));var Ai;(function(e){e.Triangle="triangle",e.Dots="dots"})(Ai||(Ai={}));function vi(e){return"width"in e&&typeof e.width=="number"}async function Xa(e){return typeof e=="object"?e:await e()}function io(e){return!(e.kind===ue.Loading||e.kind===ue.Bubble||e.kind===ue.RowID||e.kind===ue.Protected||e.kind===ue.Drilldown)}function lo(e){return e.kind===Mn.Marker||e.kind===Mn.NewRow}function so(e){if(!io(e)||e.kind===ue.Image)return!1;switch(e.kind){case ue.Text:case ue.Number:case ue.Markdown:case ue.Uri:case ue.Custom:case ue.Boolean:return e.readonly!==!0;default:Vo(e,"A cell was passed with an invalid kind")}}function Zm(e){return Vm(e,"editor")}function Zs(e){return!(e.readonly??!1)}var Mn;(function(e){e.NewRow="new-row",e.Marker="marker"})(Mn||(Mn={}));const Fi={shape:"square",size:4,offsetX:-2,offsetY:-2,outline:0};function us(e){if(e.length===0)return[];const t=[...e],n=[];t.sort(function(r,o){return r[0]-o[0]}),n.push([...t[0]]);for(const r of t.slice(1)){const o=n[n.length-1];o[1]<r[0]?n.push([...r]):o[1]<r[1]&&(o[1]=r[1])}return n}let Ka;const sn=class sn{constructor(t){Xe(this,"items");this.items=t}offset(t){if(t===0)return this;const n=this.items.map(r=>[r[0]+t,r[1]+t]);return new sn(n)}add(t){const n=typeof t=="number"?[t,t+1]:t,r=us([...this.items,n]);return new sn(r)}remove(t){const n=[...this.items],r=typeof t=="number"?t:t[0],o=typeof t=="number"?t+1:t[1];for(const[i,a]of n.entries()){const[s,l]=a;if(s<=o&&r<=l){const u=[];s<r&&u.push([s,r]),o<l&&u.push([o,l]),n.splice(i,1,...u)}}return new sn(n)}first(){if(this.items.length!==0)return this.items[0][0]}last(){if(this.items.length!==0)return this.items.slice(-1)[0][1]-1}hasIndex(t){for(let n=0;n<this.items.length;n++){const[r,o]=this.items[n];if(t>=r&&t<o)return!0}return!1}hasAll(t){for(let n=t[0];n<t[1];n++)if(!this.hasIndex(n))return!1;return!0}some(t){for(const n of this)if(t(n))return!0;return!1}equals(t){if(t===this)return!0;if(t.items.length!==this.items.length)return!1;for(let n=0;n<this.items.length;n++){const r=t.items[n],o=this.items[n];if(r[0]!==o[0]||r[1]!==o[1])return!1}return!0}toArray(){const t=[];for(const[n,r]of this.items)for(let o=n;o<r;o++)t.push(o);return t}get length(){let t=0;for(const[n,r]of this.items)t+=r-n;return t}*[Symbol.iterator](){for(const[t,n]of this.items)for(let r=t;r<n;r++)yield r}};Xe(sn,"create",t=>new sn(us(t))),Xe(sn,"empty",()=>Ka??(Ka=new sn([]))),Xe(sn,"fromSingleSelection",t=>sn.empty().add(t)),Xe(sn,"fromArray",t=>{if(t.length===0)return sn.empty();const n=t.map(o=>[o,o+1]),r=us(n);return new sn(r)});let rt=sn;function Qm(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var ep=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,ds=Qm(function(e){return ep.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),tp=function(){const t=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];t.forEach(i=>{(i?i.split(" "):[]).forEach(s=>{if(s.startsWith("atm_")){const[,l]=s.split("_");n[l]=s}else r.push(s)})});const o=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&o.push(n[i]);return o.push(...r),o.join(" ")},Ya=tp,np=e=>e.toUpperCase()===e,rp=e=>t=>e.indexOf(t)===-1,mc=(e,t)=>{const n={};return Object.keys(e).filter(rp(t)).forEach(r=>{n[r]=e[r]}),n};function op(e,t,n){const r=mc(t,n);if(!e){const o=typeof ds=="function"?{default:ds}:ds;Object.keys(r).forEach(i=>{o.default(i)||delete r[i]})}return r}var ip=(e,t)=>{};function sp(e){let t="";return n=>{const r=(i,a)=>{const{as:s=e,class:l=t}=i,u=n.propsAsIs===void 0?!(typeof s=="string"&&s.indexOf("-")===-1&&!np(s[0])):n.propsAsIs,d=op(u,i,["as","class"]);d.ref=a,d.className=n.atomic?Ya(n.class,d.className||l):Ya(d.className||l,n.class);const{vars:h}=n;if(h){const m={};for(const y in h){const x=h[y],C=x[0],w=x[1]||"",M=typeof C=="function"?C(i):C;ip(M,n.name),m[`--${y}`]=`${M}${w}`}const p=d.style||{},g=Object.keys(p);g.length>0&&g.forEach(y=>{m[y]=p[y]}),d.style=m}return e.__wyw_meta&&e!==s?(d.as=s,c.createElement(e,d)):c.createElement(s,d)},o=c.forwardRef?c.forwardRef(r):i=>{const a=mc(i,["innerRef"]);return r(a,i.innerRef)};return o.displayName=n.name,o.__wyw_meta={className:n.class||t,extends:e},o}}var Rr=sp,ap=Kn,lp=function(){return ap.Date.now()},cp=lp,up=/\s/;function dp(e){for(var t=e.length;t--&&up.test(e.charAt(t)););return t}var fp=dp,hp=fp,gp=/^\s+/;function mp(e){return e&&e.slice(0,hp(e)+1).replace(gp,"")}var pp=mp,bp=pp,qa=bo,yp=Li,Va=NaN,vp=/^[-+]0x[0-9a-f]+$/i,wp=/^0b[01]+$/i,xp=/^0o[0-7]+$/i,Cp=parseInt;function kp(e){if(typeof e=="number")return e;if(yp(e))return Va;if(qa(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=qa(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=bp(e);var n=wp.test(e);return n||xp.test(e)?Cp(e.slice(2),n?2:8):vp.test(e)?Va:+e}var Qs=kp,Sp=bo,fs=cp,Ja=Qs,Rp="Expected a function",Mp=Math.max,Ip=Math.min;function Ep(e,t,n){var r,o,i,a,s,l,u=0,d=!1,h=!1,m=!0;if(typeof e!="function")throw new TypeError(Rp);t=Ja(t)||0,Sp(n)&&(d=!!n.leading,h="maxWait"in n,i=h?Mp(Ja(n.maxWait)||0,t):i,m="trailing"in n?!!n.trailing:m);function p(A){var W=r,J=o;return r=o=void 0,u=A,a=e.apply(J,W),a}function g(A){return u=A,s=setTimeout(C,t),d?p(A):a}function y(A){var W=A-l,J=A-u,S=t-W;return h?Ip(S,i-J):S}function x(A){var W=A-l,J=A-u;return l===void 0||W>=t||W<0||h&&J>=i}function C(){var A=fs();if(x(A))return w(A);s=setTimeout(C,y(A))}function w(A){return s=void 0,m&&r?p(A):(r=o=void 0,a)}function M(){s!==void 0&&clearTimeout(s),u=0,r=l=o=s=void 0}function U(){return s===void 0?a:w(fs())}function z(){var A=fs(),W=x(A);if(r=arguments,o=this,l=A,W){if(s===void 0)return g(l);if(h)return clearTimeout(s),s=setTimeout(C,t),p(l)}return s===void 0&&(s=setTimeout(C,t)),a}return z.cancel=M,z.flush=U,z}var Tp=Ep;const pc=Lr(Tp);function nn(e,t,n,r,o=!1){const i=c.useRef();i.current=t,c.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const a=n,s=l=>{var u;(u=i.current)==null||u.call(a,l)};return a.addEventListener(e,s,{passive:r,capture:o}),()=>{a.removeEventListener(e,s,{capture:o})}},[e,n,r,o])}function Cr(e,t){return e===void 0?void 0:t}const bc=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),yc=(e,t,n,r,o)=>{switch(e){case"left":return Math.floor(t)+r+o/2;case"center":return Math.floor(t+n/2);case"right":return Math.floor(t+n)-r-o/2}},vc=(e,t,n)=>Math.min(e,t-n*2),wc=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2;function Dp(e,t,n){const[r,o]=c.useState(e),i=c.useRef(!0);c.useEffect(()=>()=>{i.current=!1},[]);const a=c.useRef(pc(s=>{i.current&&o(s)},n));return c.useLayoutEffect(()=>{i.current&&a.current(()=>e())},t),r}const $p="֑-߿יִ-﷽ﹰ-ﻼ",Ap="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",Fp=new RegExp("^[^"+Ap+"]*["+$p+"]");function ea(e){return Fp.test(e)?"rtl":"not-rtl"}let wi;function Is(){if(typeof document>"u")return 0;if(wi!==void 0)return wi;const e=document.createElement("p");e.style.width="100%",e.style.height="200px";const t=document.createElement("div");t.id="testScrollbar",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.visibility="hidden",t.style.width="200px",t.style.height="150px",t.style.overflow="hidden",t.append(e),document.body.append(t);const n=e.offsetWidth;t.style.overflow="scroll";let r=e.offsetWidth;return n===r&&(r=t.clientWidth),t.remove(),wi=n-r,wi}const Or=Symbol();function _p(e){const t=c.useRef([Or,e]);t.current[1]!==e&&(t.current[0]=e),t.current[1]=e;const[n,r]=c.useState(e),[,o]=c.useState(),i=c.useCallback(s=>{const l=t.current[0];l!==Or&&(s=typeof s=="function"?s(l):s,s===l)||(l!==Or&&o({}),r(u=>typeof s=="function"?s(l===Or?u:l):s),t.current[0]=Or)},[]),a=c.useCallback(()=>{t.current[0]=Or,o({})},[]);return[t.current[0]===Or?n:t.current[0],i,a]}function Pp(e){if(e.length===0)return"";let t=0,n=0;for(const r of e){if(n+=r.length,n>1e4)break;t++}return e.slice(0,t).join(", ")}function Op(e){const t=c.useRef(e);return mo(e,t.current)||(t.current=e),t.current}const jp=Rr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),Np=Rr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),Hp=Rr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let Za=0;const Bp=e=>{const{placeholder:t,value:n,onKeyDown:r,highlight:o,altNewline:i,validatedSelection:a,...s}=e,{onChange:l,className:u}=s,d=c.useRef(null),h=n??"";pn(l!==void 0,"GrowingEntry must be a controlled input area");const[m]=c.useState(()=>"input-box-"+(Za=(Za+1)%1e7));c.useEffect(()=>{const g=d.current;if(g===null||g.disabled)return;const y=h.toString().length;g.focus(),g.setSelectionRange(o?0:y,y)},[]),c.useLayoutEffect(()=>{var g;if(a!==void 0){const y=typeof a=="number"?[a,null]:a;(g=d.current)==null||g.setSelectionRange(y[0],y[1])}},[a]);const p=c.useCallback(g=>{g.key==="Enter"&&g.shiftKey&&i===!0||r==null||r(g)},[i,r]);return c.createElement(Hp,{className:"gdg-growing-entry"},c.createElement(Np,{className:u},h+`
|
|
3
|
-
`),c.createElement(jp,{...s,className:(u??"")+" gdg-input",id:m,ref:d,onKeyDown:p,value:h,placeholder:t,dir:"auto"}))},hs={};let wr=null;function Lp(){const e=document.createElement("div");return e.style.opacity="0",e.style.pointerEvents="none",e.style.position="fixed",document.body.append(e),e}function Es(e){const t=e.toLowerCase().trim();if(hs[t]!==void 0)return hs[t];wr=wr||Lp(),wr.style.color="#000",wr.style.color=t;const n=getComputedStyle(wr).color;wr.style.color="#fff",wr.style.color=t;const r=getComputedStyle(wr).color;if(r!==n)return[0,0,0,1];let o=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return o.length<4&&o.push(1),o=o.map(i=>Number.isNaN(i)?0:i),hs[t]=o,o}function Br(e,t){const[n,r,o]=Es(e);return`rgba(${n}, ${r}, ${o}, ${t})`}const Qa=new Map;function el(e,t){const n=`${e}-${t}`,r=Qa.get(n);if(r!==void 0)return r;const o=bn(e,t);return Qa.set(n,o),o}function bn(e,t){if(t===void 0)return e;const[n,r,o,i]=Es(e);if(i===1)return e;const[a,s,l,u]=Es(t),d=i+u*(1-i),h=(i*n+u*a*(1-i))/d,m=(i*r+u*s*(1-i))/d,p=(i*o+u*l*(1-i))/d;return`rgba(${h}, ${m}, ${p}, ${d})`}var ao=new Map,co=new Map,Ts=new Map;function zp(){ao.clear(),Ts.clear(),co.clear()}function Wp(e,t,n,r,o){var i,a,s;let l=0,u={};for(let h of e)l+=(i=n.get(h))!=null?i:o,u[h]=((a=u[h])!=null?a:0)+1;let d=t-l;for(let h of Object.keys(u)){let m=u[h],p=(s=n.get(h))!=null?s:o,g=p*m/l,y=d*g*r/m,x=p+y;n.set(h,x)}}function Gp(e,t){var n;let r=new Map,o=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let d=e.measureText(u).width;r.set(u,d),o+=d}let i=o/r.size,a=3,s=(t/i+a)/(a+1),l=r.keys();for(let u of l)r.set(u,((n=r.get(u))!=null?n:i)*s);return r}function Xo(e,t,n,r){var o,i;let a=co.get(n);if(r&&a!==void 0&&a.count>2e4){let u=Ts.get(n);if(u===void 0&&(u=Gp(e,a.size),Ts.set(n,u)),a.count>5e5){let h=0;for(let m of t)h+=(o=u.get(m))!=null?o:a.size;return h*1.01}let d=e.measureText(t);return Wp(t,d.width,u,Math.max(.05,1-a.count/2e5),a.size),co.set(n,{count:a.count+t.length,size:a.size}),d.width}let s=e.measureText(t),l=s.width/t.length;if(((i=a==null?void 0:a.count)!=null?i:0)>2e4)return s.width;if(a===void 0)co.set(n,{count:t.length,size:l});else{let u=l-a.size,d=t.length/(a.count+t.length),h=a.size+u*d;co.set(n,{count:a.count+t.length,size:h})}return s.width}function Up(e,t,n,r,o,i,a,s){if(t.length<=1)return t.length;if(o<n)return-1;let l=Math.floor(n/o*i),u=Xo(e,t.slice(0,Math.max(0,l)),r,a);if(u!==n)if(u<n){for(;u<n;)l++,u=Xo(e,t.slice(0,Math.max(0,l)),r,a);l--}else for(;u>n;){let d=t.lastIndexOf(" ",l-1);d>0?l=d:l--,u=Xo(e,t.slice(0,Math.max(0,l)),r,a)}if(t[l]!==" "){let d=0;d=t.lastIndexOf(" ",l),d>0&&(l=d)}return l}function Xp(e,t,n,r,o,i){let a=`${t}_${n}_${r}px`,s=ao.get(a);if(s!==void 0)return s;if(r<=0)return[];let l=[],u=t.split(`
|
|
4
|
-
`),d=co.get(n),h=d===void 0?t.length:r/d.size*1.5,m=o&&d!==void 0&&d.count>2e4;for(let p of u){let g=Xo(e,p.slice(0,Math.max(0,h)),n,m),y=Math.min(p.length,h);if(g<=r)l.push(p);else{for(;g>r;){let x=Up(e,p,r,n,g,y,m),C=p.slice(0,Math.max(0,x));p=p.slice(C.length),l.push(C),g=Xo(e,p.slice(0,Math.max(0,h)),n,m),y=Math.min(p.length,h)}g>0&&l.push(p)}}return l=l.map((p,g)=>g===0?p.trimEnd():p.trim()),ao.set(a,l),ao.size>500&&ao.delete(ao.keys().next().value),l}function Kp(e,t){return zt.useMemo(()=>e.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r<t,indicatorIcon:n.indicatorIcon,style:n.style,themeOverride:n.themeOverride,title:n.title,trailingRowOptions:n.trailingRowOptions,width:n.width,growOffset:n.growOffset,rowMarker:n.rowMarker,rowMarkerChecked:n.rowMarkerChecked,headerRowMarkerTheme:n.headerRowMarkerTheme,headerRowMarkerAlwaysVisible:n.headerRowMarkerAlwaysVisible,headerRowMarkerDisabled:n.headerRowMarkerDisabled})),[e,t])}function Yp(e,t){const[n,r]=t;if(e.columns.hasIndex(n)||e.rows.hasIndex(r))return!0;if(e.current!==void 0){if(Ko(e.current.cell,t))return!0;const o=[e.current.range,...e.current.rangeStack];for(const i of o)if(n>=i.x&&n<i.x+i.width&&r>=i.y&&r<i.y+i.height)return!0}return!1}function Jo(e,t){return(e??"")===(t??"")}function qp(e,t,n){return n.current===void 0||e[1]!==n.current.cell[1]?!1:t.span===void 0?n.current.cell[0]===e[0]:n.current.cell[0]>=t.span[0]&&n.current.cell[0]<=t.span[1]}function xc(e,t){const[n,r]=e;return n>=t.x&&n<t.x+t.width&&r>=t.y&&r<t.y+t.height}function Ko(e,t){return(e==null?void 0:e[0])===(t==null?void 0:t[0])&&(e==null?void 0:e[1])===(t==null?void 0:t[1])}function Cc(e){return[e.x+e.width-1,e.y+e.height-1]}function tl(e,t,n){const r=n.x,o=n.x+n.width-1,i=n.y,a=n.y+n.height-1,[s,l]=e;if(l<i||l>a)return!1;if(t.span===void 0)return s>=r&&s<=o;const[u,d]=t.span;return u>=r&&u<=o||d>=r&&u<=o||u<r&&d>o}function Vp(e,t,n,r){let o=0;if(n.current===void 0)return o;const i=n.current.range;(r||i.height*i.width>1)&&tl(e,t,i)&&o++;for(const a of n.current.rangeStack)tl(e,t,a)&&o++;return o}function kc(e,t){let n=e;if(t!==void 0){let r=[...e];const o=n[t.src];t.src>t.dest?(r.splice(t.src,1),r.splice(t.dest,0,o)):(r.splice(t.dest+1,0,o),r.splice(t.src,1)),r=r.map((i,a)=>({...i,sticky:e[a].sticky})),n=r}return n}function po(e,t){let n=0;const r=kc(e,t);for(let o=0;o<r.length;o++){const i=r[o];if(i.sticky)n+=i.width;else break}return n}function Wr(e,t,n){if(typeof n=="number")return t*n;{let r=0;for(let o=e-t;o<e;o++)r+=n(o);return r}}function Ds(e,t,n,r,o){const i=kc(e,r),a=[];for(const u of i)if(u.sticky)a.push(u);else break;if(a.length>0)for(const u of a)n-=u.width;let s=t,l=o??0;for(;l<=n&&s<i.length;)l+=i[s].width,s++;for(let u=t;u<s;u++){const d=i[u];d.sticky||a.push(d)}return a}function Jp(e,t,n){let r=0;for(const o of t){const i=o.sticky?r:r+(n??0);if(e<=i+o.width)return o.sourceIndex;r+=o.width}return-1}function Zp(e,t,n,r,o,i,a,s,l,u){const d=r+o;if(n&&e<=o)return-2;if(e<=d)return-1;let h=t;for(let g=0;g<u;g++){const y=i-1-g,x=typeof a=="number"?a:a(y);if(h-=x,e>=h)return y}const m=i-u,p=e-(l??0);if(typeof a=="number"){const g=Math.floor((p-d)/a)+s;return g>=m?void 0:g}else{let g=d;for(let y=s;y<m;y++){const x=a(y);if(p<=g+x)return y;g+=x}return}}let Ii=0,Yo={};const Qp=typeof window>"u";async function eb(){var e;Qp||((e=document==null?void 0:document.fonts)==null?void 0:e.ready)===void 0||(await document.fonts.ready,Ii=0,Yo={},zp())}eb();function Sc(e,t,n,r){return`${e}_${r??(t==null?void 0:t.font)}_${n}`}function Ki(e,t,n,r="middle"){const o=Sc(e,t,r,n);let i=Yo[o];return i===void 0&&(i=t.measureText(e),Yo[o]=i,Ii++),Ii>1e4&&(Yo={},Ii=0),i}function tb(e,t){const n=Sc(e,void 0,"middle",t);return Yo[n]}function xo(e,t){return typeof t!="string"&&(t=t.baseFontFull),nb(e,t)}function nl(e,t){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";e.save(),e.textBaseline=t;const r=e.measureText(n);return e.restore(),r}const rl=[];function nb(e,t){for(const i of rl)if(i.key===t)return i.val;const n=nl(e,"alphabetic"),o=-(nl(e,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return rl.push({key:t,val:o}),o}function rb(e,t,n,r,o,i){const{ctx:a,rect:s,theme:l}=e;let u=Number.MAX_SAFE_INTEGER;const d=500;if(t!==void 0&&(u=n-t,u<d)){const h=1-u/d;a.globalAlpha=h,a.fillStyle=l.bgSearchResult,a.fillRect(s.x+1,s.y+1,s.width-(o?2:1),s.height-(i?2:1)),a.globalAlpha=1,r!==void 0&&(r.fillStyle=l.bgSearchResult)}return u<d}function Rc(e,t,n){const{ctx:r,theme:o}=e,i=t??{},a=n??o.textDark;return a!==i.fillStyle&&(r.fillStyle=a,i.fillStyle=a),i}function Mc(e,t,n,r,o,i,a,s,l){l==="right"?e.fillText(t,n+o-(s.cellHorizontalPadding+.5),r+i/2+a):l==="center"?e.fillText(t,n+o/2,r+i/2+a):e.fillText(t,n+s.cellHorizontalPadding+.5,r+i/2+a)}function ob(e,t){const n=Ki("ABCi09jgqpy",e,t);return n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}function ib(e,t){e.includes(`
|
|
5
|
-
`)&&(e=e.split(/\r?\n/,1)[0]);const n=t/4;return e.length>n&&(e=e.slice(0,n)),e}function sb(e,t,n,r,o,i,a,s,l,u){const d=s.baseFontFull,h=Xp(e,t,d,o-s.cellHorizontalPadding*2,u??!1),m=ob(e,d),p=s.lineHeight*m,g=m+p*(h.length-1),y=g+s.cellVerticalPadding>i;y&&(e.save(),e.rect(n,r,o,i),e.clip());const x=r+i/2-g/2;let C=Math.max(r+s.cellVerticalPadding,x);for(const w of h)if(Mc(e,w,n,C,o,m,a,s,l),C+=p,C>r+i)break;y&&e.restore()}function Ic(e,t,n,r,o){const{ctx:i,rect:a,theme:s}=e,{x:l,y:u,width:d,height:h}=a;r=r??!1,r||(t=ib(t,d));const m=xo(i,s),p=ea(t)==="rtl";if(n===void 0&&p&&(n="right"),p&&(i.direction="rtl"),t.length>0){let g=!1;n==="right"?(i.textAlign="right",g=!0):n!==void 0&&n!=="left"&&(i.textAlign=n,g=!0),r?sb(i,t,l,u,d,h,m,s,n,o):Mc(i,t,l,u,d,h,m,s,n),g&&(i.textAlign="start"),p&&(i.direction="inherit")}}function fo(e,t,n,r,o,i){typeof i=="number"&&(i={tl:i,tr:i,br:i,bl:i}),i={tl:Math.max(0,Math.min(i.tl,o/2,r/2)),tr:Math.max(0,Math.min(i.tr,o/2,r/2)),bl:Math.max(0,Math.min(i.bl,o/2,r/2)),br:Math.max(0,Math.min(i.br,o/2,r/2))},e.moveTo(t+i.tl,n),e.arcTo(t+r,n,t+r,n+i.tr,i.tr),e.arcTo(t+r,n+o,t+r-i.br,n+o,i.br),e.arcTo(t,n+o,t,n+o-i.bl,i.bl),e.arcTo(t,n,t+i.tl,n,i.tl)}function ab(e,t,n){e.arc(t,n-1.25*3.5,1.25,0,2*Math.PI,!1),e.arc(t,n,1.25,0,2*Math.PI,!1),e.arc(t,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function lb(e,t,n){const r=function(s,l){const u=l.x-s.x,d=l.y-s.y,h=Math.sqrt(u*u+d*d),m=u/h,p=d/h;return{x:u,y:l.y-s.y,len:h,nx:m,ny:p,ang:Math.atan2(p,m)}};let o;const i=t.length;let a=t[i-1];for(let s=0;s<i;s++){let l=t[s%i];const u=t[(s+1)%i],d=r(l,a),h=r(l,u),m=d.nx*h.ny-d.ny*h.nx,p=d.nx*h.nx-d.ny*-h.ny;let g=Math.asin(m<-1?-1:m>1?1:m),y=1,x=!1;p<0?g<0?g=Math.PI+g:(g=Math.PI-g,y=-1,x=!0):g>0&&(y=-1,x=!0),o=l.radius!==void 0?l.radius:n;const C=g/2;let w=Math.abs(Math.cos(C)*o/Math.sin(C)),M;w>Math.min(d.len/2,h.len/2)?(w=Math.min(d.len/2,h.len/2),M=Math.abs(w*Math.sin(C)/Math.cos(C))):M=o;let U=l.x+h.nx*w,z=l.y+h.ny*w;U+=-h.ny*M*y,z+=h.nx*M*y,e.arc(U,z,M,d.ang+Math.PI/2*y,h.ang-Math.PI/2*y,x),a=l,l=u}e.closePath()}function $s(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g){const y={x:0,y:i+u,width:0,height:0};if(e>=p.length||t>=d||t<-2||e<0)return y;const x=i-o;if(e>=h){const C=a>e?-1:1,w=po(p);y.x+=w+l;for(let M=a;M!==e;M+=C)y.x+=p[C===1?M:M-1].width*C}else for(let C=0;C<e;C++)y.x+=p[C].width;if(y.width=p[e].width+1,t===-1)y.y=o,y.height=x;else if(t===-2){y.y=0,y.height=o;let C=e;const w=p[e].group,M=p[e].sticky;for(;C>0&&Jo(p[C-1].group,w)&&p[C-1].sticky===M;){const z=p[C-1];y.x-=z.width,y.width+=z.width,C--}let U=e;for(;U+1<p.length&&Jo(p[U+1].group,w)&&p[U+1].sticky===M;){const z=p[U+1];y.width+=z.width,U++}if(!M){const z=po(p),A=y.x-z;A<0&&(y.x-=A,y.width+=A),y.x+y.width>n&&(y.width=n-y.x)}}else if(t>=d-m){let C=d-t;for(y.y=r;C>0;){const w=t+C-1;y.height=typeof g=="number"?g:g(w),y.y-=y.height,C--}y.height+=1}else{const C=s>t?-1:1;if(typeof g=="number"){const w=t-s;y.y+=w*g}else for(let w=s;w!==t;w+=C)y.y+=g(w)*C;y.height=(typeof g=="number"?g:g(t))+1}return y}const ta=1<<21;function er(e,t){return(t+2)*ta+e}function Ec(e){return e%ta}function na(e){return Math.floor(e/ta)-2}function Tc(e){const t=Ec(e),n=na(e);return[t,n]}class cb{constructor(){Xe(this,"visibleWindow",{x:0,y:0,width:0,height:0});Xe(this,"freezeCols",0);Xe(this,"freezeRows",[]);Xe(this,"isInWindow",t=>{const n=Ec(t),r=na(t),o=this.visibleWindow,i=n>=o.x&&n<=o.x+o.width||n<this.freezeCols,a=r>=o.y&&r<=o.y+o.height||this.freezeRows.includes(r);return i&&a})}setWindow(t,n,r){this.visibleWindow.x===t.x&&this.visibleWindow.y===t.y&&this.visibleWindow.width===t.width&&this.visibleWindow.height===t.height&&this.freezeCols===n&&mo(this.freezeRows,r)||(this.visibleWindow=t,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class ub extends cb{constructor(){super(...arguments);Xe(this,"cache",new Map);Xe(this,"setValue",(n,r)=>{this.cache.set(er(n[0],n[1]),r)});Xe(this,"getValue",n=>this.cache.get(er(n[0],n[1])));Xe(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class Ei{constructor(t=[]){Xe(this,"cells");this.cells=new Set(t.map(n=>er(n[0],n[1])))}add(t){this.cells.add(er(t[0],t[1]))}has(t){return t===void 0?!1:this.cells.has(er(t[0],t[1]))}remove(t){this.cells.delete(er(t[0],t[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const t of this.cells)if(na(t)<0)return!0;return!1}hasItemInRectangle(t){for(let n=t.y;n<t.y+t.height;n++)for(let r=t.x;r<t.x+t.width;r++)if(this.cells.has(er(r,n)))return!0;return!1}hasItemInRegion(t){for(const n of t)if(this.hasItemInRectangle(n))return!0;return!1}*values(){for(const t of this.cells)yield Tc(t)}}function db(e){return{"--gdg-accent-color":e.accentColor,"--gdg-accent-fg":e.accentFg,"--gdg-accent-light":e.accentLight,"--gdg-text-dark":e.textDark,"--gdg-text-medium":e.textMedium,"--gdg-text-light":e.textLight,"--gdg-text-bubble":e.textBubble,"--gdg-bg-icon-header":e.bgIconHeader,"--gdg-fg-icon-header":e.fgIconHeader,"--gdg-text-header":e.textHeader,"--gdg-text-group-header":e.textGroupHeader??e.textHeader,"--gdg-bg-group-header":e.bgGroupHeader??e.bgHeader,"--gdg-bg-group-header-hovered":e.bgGroupHeaderHovered??e.bgHeaderHovered,"--gdg-text-header-selected":e.textHeaderSelected,"--gdg-bg-cell":e.bgCell,"--gdg-bg-cell-medium":e.bgCellMedium,"--gdg-bg-header":e.bgHeader,"--gdg-bg-header-has-focus":e.bgHeaderHasFocus,"--gdg-bg-header-hovered":e.bgHeaderHovered,"--gdg-bg-bubble":e.bgBubble,"--gdg-bg-bubble-selected":e.bgBubbleSelected,"--gdg-bubble-height":`${e.bubbleHeight}px`,"--gdg-bubble-padding":`${e.bubblePadding}px`,"--gdg-bubble-margin":`${e.bubbleMargin}px`,"--gdg-bg-search-result":e.bgSearchResult,"--gdg-border-color":e.borderColor,"--gdg-horizontal-border-color":e.horizontalBorderColor??e.borderColor,"--gdg-drilldown-border":e.drilldownBorder,"--gdg-link-color":e.linkColor,"--gdg-cell-horizontal-padding":`${e.cellHorizontalPadding}px`,"--gdg-cell-vertical-padding":`${e.cellVerticalPadding}px`,"--gdg-header-font-style":e.headerFontStyle,"--gdg-base-font-style":e.baseFontStyle,"--gdg-marker-font-style":e.markerFontStyle,"--gdg-font-family":e.fontFamily,"--gdg-editor-font-size":e.editorFontSize,"--gdg-checkbox-max-size":`${e.checkboxMaxSize}px`,...e.resizeIndicatorColor===void 0?{}:{"--gdg-resize-indicator-color":e.resizeIndicatorColor},...e.headerBottomBorderColor===void 0?{}:{"--gdg-header-bottom-border-color":e.headerBottomBorderColor},...e.roundingRadius===void 0?{}:{"--gdg-rounding-radius":`${e.roundingRadius}px`}}}const Dc={accentColor:"#4F5DFF",accentFg:"#FFFFFF",accentLight:"rgba(62, 116, 253, 0.1)",textDark:"#313139",textMedium:"#737383",textLight:"#B2B2C0",textBubble:"#313139",bgIconHeader:"#737383",fgIconHeader:"#FFFFFF",textHeader:"#313139",textGroupHeader:"#313139BB",textHeaderSelected:"#FFFFFF",bgCell:"#FFFFFF",bgCellMedium:"#FAFAFB",bgHeader:"#F7F7F8",bgHeaderHasFocus:"#E9E9EB",bgHeaderHovered:"#EFEFF1",bgBubble:"#EDEDF3",bgBubbleSelected:"#FFFFFF",bubbleHeight:20,bubblePadding:6,bubbleMargin:4,bgSearchResult:"#fff9e3",borderColor:"rgba(115, 116, 131, 0.16)",drilldownBorder:"rgba(0, 0, 0, 0)",linkColor:"#353fb5",cellHorizontalPadding:8,cellVerticalPadding:3,headerIconSize:18,headerFontStyle:"600 13px",baseFontStyle:"13px",markerFontStyle:"9px",fontFamily:"Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif",editorFontSize:"13px",lineHeight:1.4,checkboxMaxSize:18};function $c(){return Dc}const fb=zt.createContext(Dc);function tr(e,...t){const n={...e};for(const r of t)if(r!==void 0)for(const o in r)r.hasOwnProperty(o)&&(o==="bgCell"?n[o]=bn(r[o],n[o]):n[o]=r[o]);return(n.headerFontFull===void 0||e.fontFamily!==n.fontFamily||e.headerFontStyle!==n.headerFontStyle)&&(n.headerFontFull=`${n.headerFontStyle} ${n.fontFamily}`),(n.baseFontFull===void 0||e.fontFamily!==n.fontFamily||e.baseFontStyle!==n.baseFontStyle)&&(n.baseFontFull=`${n.baseFontStyle} ${n.fontFamily}`),(n.markerFontFull===void 0||e.fontFamily!==n.fontFamily||e.markerFontStyle!==n.markerFontStyle)&&(n.markerFontFull=`${n.markerFontStyle} ${n.fontFamily}`),n}const As=150;function hb(e,t,n,r){var i;const o=r(t);return((i=o==null?void 0:o.measure)==null?void 0:i.call(o,e,t,n))??As}function Ac(e,t,n,r,o,i,a,s,l){let u=0;const d=o===void 0?[]:o.map(p=>{const g=hb(e,p[r],t,l);return u=Math.max(u,g),g});if(d.length>5&&s){u=0;let p=0;for(const y of d)p+=y;const g=p/d.length;for(let y=0;y<d.length;y++)d[y]>=g*2?d[y]=0:u=Math.max(u,d[y])}const h=e.font;e.font=t.headerFontFull,u=Math.max(u,e.measureText(n.title).width+t.cellHorizontalPadding*2+(n.icon===void 0?0:28)),e.font=h;const m=Math.max(Math.ceil(i),Math.min(Math.floor(a),Math.ceil(u)));return{...n,width:m}}function gb(e,t,n,r,o,i,a,s,l){const u=c.useRef(t),d=c.useRef(n),h=c.useRef(a);u.current=t,d.current=n,h.current=a;const[m,p]=c.useMemo(()=>{if(typeof window>"u")return[null,null];const w=document.createElement("canvas");return w.style.display="none",w.style.opacity="0",w.style.position="fixed",[w,w.getContext("2d",{alpha:!1})]},[]);c.useLayoutEffect(()=>(m&&document.documentElement.append(m),()=>{m==null||m.remove()}),[m]);const g=c.useRef({}),y=c.useRef(),[x,C]=c.useState();return c.useLayoutEffect(()=>{const w=d.current;if(w===void 0||e.every(vi))return;let M=Math.max(1,10-Math.floor(e.length/1e4)),U=0;M<u.current&&M>1&&(M--,U=1);const z={x:0,y:0,width:e.length,height:Math.min(u.current,M)},A={x:0,y:u.current-1,width:e.length,height:1};(async()=>{const J=w(z,l.signal),S=U>0?w(A,l.signal):void 0;let F;typeof J=="object"?F=J:F=await Xa(J),S!==void 0&&(typeof S=="object"?F=[...F,...S]:F=[...F,...await Xa(S)]),y.current=e,C(F)})()},[l.signal,e]),c.useMemo(()=>{let M=e.every(vi)?e:p===null?e.map(W=>vi(W)?W:{...W,width:As}):(p.font=h.current.baseFontFull,e.map((W,J)=>{if(vi(W))return W;if(g.current[W.id]!==void 0)return{...W,width:g.current[W.id]};if(x===void 0||y.current!==e||W.id===void 0)return{...W,width:As};const S=Ac(p,a,W,J,x,o,i,!0,s);return g.current[W.id]=S.width,S})),U=0,z=0;const A=[];for(const[W,J]of M.entries())U+=J.width,J.grow!==void 0&&J.grow>0&&(z+=J.grow,A.push(W));if(U<r&&A.length>0){const W=[...M],J=r-U;let S=J;for(let F=0;F<A.length;F++){const B=A[F],N=(M[B].grow??0)/z,_=F===A.length-1?S:Math.min(S,Math.floor(J*N));W[B]={...M[B],growOffset:_,width:M[B].width+_},S-=_}M=W}return{sizedColumns:M,nonGrowWidth:U}},[r,e,p,x,a,o,i,s])}function mb(e,t,n){return e===e&&(n!==void 0&&(e=e<=n?e:n),t!==void 0&&(e=e>=t?e:t)),e}var pb=mb,bb=pb,gs=Qs;function yb(e,t,n){return n===void 0&&(n=t,t=void 0),n!==void 0&&(n=gs(n),n=n===n?n:0),t!==void 0&&(t=gs(t),t=t===t?t:0),bb(gs(e),t,n)}var vb=yb;const Rn=Lr(vb);var wb="__lodash_hash_undefined__";function xb(e){return this.__data__.set(e,wb),this}var Cb=xb;function kb(e){return this.__data__.has(e)}var Sb=kb,Rb=Xs,Mb=Cb,Ib=Sb;function _i(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Rb;++t<n;)this.add(e[t])}_i.prototype.add=_i.prototype.push=Mb;_i.prototype.has=Ib;var Fc=_i;function Eb(e,t,n,r){for(var o=e.length,i=n+(r?1:-1);r?i--:++i<o;)if(t(e[i],i,e))return i;return-1}var Tb=Eb;function Db(e){return e!==e}var $b=Db;function Ab(e,t,n){for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}var Fb=Ab,_b=Tb,Pb=$b,Ob=Fb;function jb(e,t,n){return t===t?Ob(e,t,n):_b(e,Pb,n)}var Nb=jb,Hb=Nb;function Bb(e,t){var n=e==null?0:e.length;return!!n&&Hb(e,t,0)>-1}var Lb=Bb;function zb(e,t,n){for(var r=-1,o=e==null?0:e.length;++r<o;)if(n(t,e[r]))return!0;return!1}var Wb=zb;function Gb(e,t){return e.has(t)}var _c=Gb,Ub=zr,Xb=Kn,Kb=Ub(Xb,"Set"),Pc=Kb;function Yb(){}var qb=Yb;function Vb(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ra=Vb,ms=Pc,Jb=qb,Zb=ra,Qb=1/0,ey=ms&&1/Zb(new ms([,-0]))[1]==Qb?function(e){return new ms(e)}:Jb,ty=ey,ny=Fc,ry=Lb,oy=Wb,iy=_c,sy=ty,ay=ra,ly=200;function cy(e,t,n){var r=-1,o=ry,i=e.length,a=!0,s=[],l=s;if(n)a=!1,o=oy;else if(i>=ly){var u=t?null:sy(e);if(u)return ay(u);a=!1,o=iy,l=new ny}else l=t?[]:s;e:for(;++r<i;){var d=e[r],h=t?t(d):d;if(d=n||d!==0?d:0,a&&h===h){for(var m=l.length;m--;)if(l[m]===h)continue e;t&&l.push(h),s.push(d)}else o(l,h,n)||(l!==s&&l.push(h),s.push(d))}return s}var uy=cy,dy=uy;function fy(e){return e&&e.length?dy(e):[]}var hy=fy;const gy=Lr(hy);function my(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}var Oc=my,ol=ti,py=Ys,by=Xn,il=ol?ol.isConcatSpreadable:void 0;function yy(e){return by(e)||py(e)||!!(il&&e&&e[il])}var vy=yy,wy=Oc,xy=vy;function jc(e,t,n,r,o){var i=-1,a=e.length;for(n||(n=xy),o||(o=[]);++i<a;){var s=e[i];t>0&&n(s)?t>1?jc(s,t-1,n,r,o):wy(o,s):r||(o[o.length]=s)}return o}var Cy=jc,ky=Cy;function Sy(e){var t=e==null?0:e.length;return t?ky(e,1):[]}var Ry=Sy;const sl=Lr(Ry);var My=Math.ceil,Iy=Math.max;function Ey(e,t,n,r){for(var o=-1,i=Iy(My((t-e)/(n||1)),0),a=Array(i);i--;)a[r?i:++o]=e,e+=n;return a}var Ty=Ey,Dy=ac,$y=Vs;function Ay(e){return e!=null&&$y(e.length)&&!Dy(e)}var oa=Ay,Fy=Gs,_y=oa,Py=qs,Oy=bo;function jy(e,t,n){if(!Oy(n))return!1;var r=typeof t;return(r=="number"?_y(n)&&Py(t,n.length):r=="string"&&t in n)?Fy(n[t],e):!1}var Ny=jy,Hy=Qs,al=1/0,By=17976931348623157e292;function Ly(e){if(!e)return e===0?e:0;if(e=Hy(e),e===al||e===-al){var t=e<0?-1:1;return t*By}return e===e?e:0}var zy=Ly,Wy=Ty,Gy=Ny,ps=zy;function Uy(e){return function(t,n,r){return r&&typeof r!="number"&&Gy(t,n,r)&&(n=r=void 0),t=ps(t),n===void 0?(n=t,t=0):n=ps(n),r=r===void 0?t<n?1:-1:ps(r),Wy(t,n,r,e)}}var Xy=Uy,Ky=Xy,Yy=Ky(),qy=Yy;const Hr=Lr(qy);function Vy(e,t){return e==="normal"?[t.bgIconHeader,t.fgIconHeader]:e==="selected"?["white",t.accentColor]:[t.accentColor,t.bgHeader]}class Jy{constructor(t,n){Xe(this,"onSettled");Xe(this,"spriteMap",new Map);Xe(this,"headerIcons");Xe(this,"inFlight",0);this.onSettled=n,this.headerIcons=t??{}}drawSprite(t,n,r,o,i,a,s,l=1){const[u,d]=Vy(n,s),h=a*Math.ceil(window.devicePixelRatio),m=`${u}_${d}_${h}_${t}`;let p=this.spriteMap.get(m);if(p===void 0){const g=this.headerIcons[t];if(g===void 0)return;p=document.createElement("canvas");const y=p.getContext("2d");if(y===null)return;const x=new Image;x.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(g({fgColor:d,bgColor:u}))}`,this.spriteMap.set(m,p);const C=x.decode();if(C===void 0)return;this.inFlight++,C.then(()=>{y.drawImage(x,0,0,h,h)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else l<1&&(r.globalAlpha=l),r.drawImage(p,0,0,h,h,o,i,a,a),l<1&&(r.globalAlpha=1)}}function Nc(e){if(e.length===0)return;let t;for(const n of e)t=Math.min(t??n.y,n.y);return t}function Yi(e,t,n,r,o,i,a,s,l){s=s??t;let u=t,d=e;const h=r-i;let m=!1;for(;u<n&&d<h;){const p=o(d);if(u+p>s&&l(u,d,p,!1,a&&d===r-1)===!0){m=!0;break}u+=p,d++}if(!m){u=n;for(let p=0;p<i;p++){d=r-1-p;const g=o(d);u-=g,l(u,d,g,!0,a&&d===r-1)}}}function Mr(e,t,n,r,o,i){let a=0,s=0;const l=o+r;for(const u of e){const d=u.sticky?s:a+n;if(i(u,d,l,u.sticky?0:s,t)===!0)break;a+=u.width,s+=u.sticky?u.width:0}}function Hc(e,t,n,r,o){let i=0,a=0;for(let s=0;s<e.length;s++){const l=e[s];let u=s+1,d=l.width;for(l.sticky&&(a+=d);u<e.length&&Jo(e[u].group,l.group)&&e[u].sticky===e[s].sticky;){const y=e[u];d+=y.width,u++,s++,y.sticky&&(a+=y.width)}const h=l.sticky?0:n,m=i+h,p=l.sticky?0:Math.max(0,a-m),g=Math.min(d-p,t-(m+p));o([l.sourceIndex,e[u-1].sourceIndex],l.group??"",m+p,0,g,r),i+=d}}function Bc(e,t,n,r,o,i,a){var m;const[s,l]=e;let u,d;const h=((m=a.find(p=>!p.sticky))==null?void 0:m.sourceIndex)??0;if(l>h){const p=Math.max(s,h);let g=t,y=r;for(let x=i.sourceIndex-1;x>=p;x--)g-=a[x].width,y+=a[x].width;for(let x=i.sourceIndex+1;x<=l;x++)y+=a[x].width;d={x:g,y:n,width:y,height:o}}if(h>s){const p=Math.min(l,h-1);let g=t,y=r;for(let x=i.sourceIndex-1;x>=s;x--)g-=a[x].width,y+=a[x].width;for(let x=i.sourceIndex+1;x<=p;x++)y+=a[x].width;u={x:g,y:n,width:y,height:o}}return[u,d]}function Zy(e,t,n,r){if(r==="any")return Lc(e,{x:t,y:n,width:1,height:1});if(r==="vertical"&&(t=e.x),r==="horizontal"&&(n=e.y),xc([t,n],e))return;const o=t-e.x,i=e.x+e.width-t,a=n-e.y+1,s=e.y+e.height-n,l=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:o,r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="horizontal"?Number.MAX_SAFE_INTEGER:a,r==="horizontal"?Number.MAX_SAFE_INTEGER:s);return l===s?{x:e.x,y:e.y+e.height,width:e.width,height:n-e.y-e.height+1}:l===a?{x:e.x,y:n,width:e.width,height:e.y-n}:l===i?{x:e.x+e.width,y:e.y,width:t-e.x-e.width+1,height:e.height}:{x:t,y:e.y,width:e.x-t,height:e.height}}function Zo(e,t,n,r,o,i,a,s){return e<=o+a&&o<=e+n&&t<=i+s&&i<=t+r}function ho(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function Lc(e,t){const n=Math.min(e.x,t.x),r=Math.min(e.y,t.y),o=Math.max(e.x+e.width,t.x+t.width)-n,i=Math.max(e.y+e.height,t.y+t.height)-r;return{x:n,y:r,width:o,height:i}}function Qy(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function e0(e,t,n,r){if(e.x>t||e.y>n||e.x<0&&e.y<0&&e.x+e.width>t&&e.y+e.height>n)return;if(e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n)return e;const o=-4,i=-4,a=t+4,s=n+4,l=o-e.x,u=e.x+e.width-a,d=i-e.y,h=e.y+e.height-s,m=l>0?e.x+Math.floor(l/r)*r:e.x,p=u>0?e.x+e.width-Math.floor(u/r)*r:e.x+e.width,g=d>0?e.y+Math.floor(d/r)*r:e.y,y=h>0?e.y+e.height-Math.floor(h/r)*r:e.y+e.height;return{x:m,y:g,width:p-m,height:y-g}}function t0(e,t,n,r,o){const[i,a,s,l]=t,[u,d,h,m]=o,{x:p,y:g,width:y,height:x}=e,C=[];if(y<=0||x<=0)return C;const w=p+y,M=g+x,U=p<i,z=g<a,A=p+y>s,W=g+x>l,J=p>=i&&p<s||w>i&&w<=s||p<i&&w>s,S=g>=a&&g<l||M>a&&M<=l||g<a&&M>l;if(J&&S){const B=Math.max(p,i),N=Math.max(g,a),_=Math.min(w,s),D=Math.min(M,l);C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:u,y:d,width:h-u+1,height:m-d+1}})}if(U&&z){const B=p,N=g,_=Math.min(w,i),D=Math.min(M,a);C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:0,y:0,width:u+1,height:d+1}})}if(z&&J){const B=Math.max(p,i),N=g,_=Math.min(w,s),D=Math.min(M,a);C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:u,y:0,width:h-u+1,height:d+1}})}if(z&&A){const B=Math.max(p,s),N=g,_=w,D=Math.min(M,a);C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:h,y:0,width:n-h+1,height:d+1}})}if(U&&S){const B=p,N=Math.max(g,a),_=Math.min(w,i),D=Math.min(M,l);C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:0,y:d,width:u+1,height:m-d+1}})}if(A&&S){const B=Math.max(p,s),N=Math.max(g,a),_=w,D=Math.min(M,l);C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:h,y:d,width:n-h+1,height:m-d+1}})}if(U&&W){const B=p,N=Math.max(g,l),_=Math.min(w,i),D=M;C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:0,y:m,width:u+1,height:r-m+1}})}if(W&&J){const B=Math.max(p,i),N=Math.max(g,l),_=Math.min(w,s),D=M;C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:u,y:m,width:h-u+1,height:r-m+1}})}if(A&&W){const B=Math.max(p,s),N=Math.max(g,l),_=w,D=M;C.push({rect:{x:B,y:N,width:_-B,height:D-N},clip:{x:h,y:m,width:n-h+1,height:r-m+1}})}return C}const n0={kind:ue.Loading,allowOverlay:!1};function ll(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x,C,w,M,U,z,A,W,J,S,F,B,N,_,D,fe,X,ee,he){let de=(M==null?void 0:M.size)??Number.MAX_SAFE_INTEGER;const te=performance.now();let q=_.baseFontFull;e.font=q;const Ce={ctx:e},ie=[0,0],re=x>0?Wr(l,x,u):0;let $e,Z;const se=Nc(w);return Mr(t,s,i,a,o,(me,ze,Me,ot,it)=>{const Ae=Math.max(0,ot-ze),Oe=ze+Ae,je=o+1,vt=me.width-Ae,wt=r-o-1;if(w.length>0){let Ke=!1;for(let Ye=0;Ye<w.length;Ye++){const We=w[Ye];if(Zo(Oe,je,vt,wt,We.x,We.y,We.width,We.height)){Ke=!0;break}}if(!Ke)return}const ut=()=>{e.save(),e.beginPath(),e.rect(Oe,je,vt,wt),e.clip()},oe=U.columns.hasIndex(me.sourceIndex),ve=h(me.group??"").overrideTheme,De=me.themeOverride===void 0&&ve===void 0?_:tr(_,ve,me.themeOverride),Fe=De.baseFontFull;Fe!==q&&(q=Fe,e.font=Fe),ut();let pe;return Yi(it,Me,r,l,u,x,C,se,(Ke,Ye,We,ce,Se)=>{var Pe,Dt,Gt;if(Ye<0||(ie[0]=me.sourceIndex,ie[1]=Ye,M!==void 0&&!M.has(ie)))return;if(w.length>0){let et=!1;for(let Rt=0;Rt<w.length;Rt++){const lt=w[Rt];if(Zo(ze,Ke,me.width,We,lt.x,lt.y,lt.width,lt.height)){et=!0;break}}if(!et)return}const qe=U.rows.hasIndex(Ye),le=p.hasIndex(Ye),tt=Ye<l?d(ie):n0;let mt=ze,Re=me.width,we=!1,It=!1;if(tt.span!==void 0){const[et,Rt]=tt.span,lt=`${Ye},${et},${Rt},${me.sticky}`;if(Z===void 0&&(Z=new Set),Z.has(lt)){de--;return}else{const jt=Bc(tt.span,ze,Ke,me.width,We,me,n),Et=me.sticky?jt[0]:jt[1];if(!me.sticky&&jt[0]!==void 0&&(It=!0),Et!==void 0){mt=Et.x,Re=Et.width,Z.add(lt),e.restore(),pe=void 0,e.save(),e.beginPath();const ft=Math.max(0,ot-Et.x);e.rect(Et.x+ft,Ke,Et.width-ft,We),$e===void 0&&($e=[]),$e.push({x:Et.x+ft,y:Ke,width:Et.width-ft,height:We}),e.clip(),we=!0}}}const dt=m==null?void 0:m(Ye),He=Se&&((Pe=me.trailingRowOptions)==null?void 0:Pe.themeOverride)!==void 0?(Dt=me.trailingRowOptions)==null?void 0:Dt.themeOverride:void 0,st=tt.themeOverride===void 0&&dt===void 0&&He===void 0?De:tr(De,dt,He,tt.themeOverride);e.beginPath();const pt=qp(ie,tt,U);let Pt=Vp(ie,tt,U,y);const an=tt.span!==void 0&&U.columns.some(et=>tt.span!==void 0&&et>=tt.span[0]&&et<=tt.span[1]);pt&&!g&&y?Pt=0:pt&&y&&(Pt=Math.max(Pt,1)),an&&Pt++,pt||(qe&&Pt++,oe&&!Se&&Pt++);const Kt=tt.kind===ue.Protected?st.bgCellMedium:st.bgCell;let bt;if((ce||Kt!==_.bgCell)&&(bt=bn(Kt,bt)),Pt>0||le){le&&(bt=bn(st.bgHeader,bt));for(let et=0;et<Pt;et++)bt=bn(st.accentLight,bt)}else if(z!==void 0){for(const et of z)if(et[0]===me.sourceIndex&&et[1]===Ye){bt=bn(st.bgSearchResult,bt);break}}if(A!==void 0)for(let et=0;et<A.length;et++){const Rt=A[et],lt=Rt.range;Rt.style!=="solid-outline"&<.x<=me.sourceIndex&&me.sourceIndex<lt.x+lt.width&<.y<=Ye&&Ye<lt.y+lt.height&&(bt=bn(Rt.color,bt))}let En=!1;if(M!==void 0){const et=Ke+1,lt=(ce?et+We-1:Math.min(et+We-1,r-re))-et;(lt!==We-1||mt+1<=ot)&&(En=!0,e.save(),e.beginPath(),e.rect(mt+1,et,Re-1,lt),e.clip()),bt=bt===void 0?st.bgCell:bn(bt,st.bgCell)}const ln=me.sourceIndex===n.length-1,kt=Ye===l-1;bt!==void 0&&(e.fillStyle=bt,pe!==void 0&&(pe.fillStyle=bt),M!==void 0?e.fillRect(mt+1,Ke+1,Re-(ln?2:1),We-(kt?2:1)):e.fillRect(mt,Ke,Re,We)),tt.style==="faded"&&(e.globalAlpha=.6);let Ot;for(let et=0;et<S.length;et++){const Rt=S[et];if(Rt.item[0]===me.sourceIndex&&Rt.item[1]===Ye){Ot=Rt;break}}if(Re>he&&!It){const et=st.baseFontFull;et!==q&&(e.font=et,q=et),pe=zc(e,tt,me.sourceIndex,Ye,ln,kt,mt,Ke,Re,We,Pt>0,st,bt??st.bgCell,W,J,(Ot==null?void 0:Ot.hoverAmount)??0,F,N,te,B,pe,D,fe,X,ee)}return En&&e.restore(),tt.style==="faded"&&(e.globalAlpha=1),de--,we&&(e.restore(),(Gt=pe==null?void 0:pe.deprep)==null||Gt.call(pe,Ce),pe=void 0,ut(),q=Fe,e.font=Fe),de<=0}),e.restore(),de<=0}),$e}const No=[0,0],Ho={x:0,y:0,width:0,height:0},bs=[void 0,()=>{}];let Fs=!1;function r0(){Fs=!0}function zc(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x,C,w,M,U,z,A,W,J){var fe,X;let S,F;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(S=x[1][0],F=x[1][1]);let B;No[0]=n,No[1]=r,Ho.x=a,Ho.y=s,Ho.width=l,Ho.height=u,bs[0]=A.getValue(No),bs[1]=ee=>A.setValue(No,ee),Fs=!1;const N={ctx:e,theme:h,col:n,row:r,cell:t,rect:Ho,highlighted:d,cellFillColor:m,hoverAmount:y,frameTime:w,hoverX:S,drawState:bs,hoverY:F,imageLoader:p,spriteManager:g,hyperWrapping:C,overrideCursor:S!==void 0?J:void 0,requestAnimationFrame:r0},_=rb(N,t.lastUpdated,w,U,o,i),D=W(t);if(D!==void 0){(U==null?void 0:U.renderer)!==D&&((fe=U==null?void 0:U.deprep)==null||fe.call(U,N),U=void 0);const ee=(X=D.drawPrep)==null?void 0:X.call(D,N,U);M!==void 0&&!lo(N.cell)?M(N,()=>D.draw(N,t)):D.draw(N,t),B=ee===void 0?void 0:{deprep:ee==null?void 0:ee.deprep,fillStyle:ee==null?void 0:ee.fillStyle,font:ee==null?void 0:ee.font,renderer:D}}return(_||Fs)&&(z==null||z(No)),B}function ia(e,t,n,r,o,i,a,s,l=-20,u=-20,d=void 0,h="center",m="square"){const p=Math.floor(o+a/2),g=m==="circle"?1e4:t.roundingRadius??4;let y=vc(d??t.checkboxMaxSize,a,t.cellVerticalPadding),x=y/2;const C=yc(h,r,i,t.cellHorizontalPadding,y),w=bc(C,p,y),M=wc(r+l,o+u,w);switch(n){case!0:{e.beginPath(),fo(e,C-y/2,p-y/2,y,y,g),m==="circle"&&(x*=.8,y*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(C-x+y/4.23,p-x+y/1.97),e.lineTo(C-x+y/2.42,p-x+y/1.44),e.lineTo(C-x+y/1.29,p-x+y/3.25),e.strokeStyle=t.bgCell,e.lineJoin="round",e.lineCap="round",e.lineWidth=1.9,e.stroke();break}case $i:case!1:{e.beginPath(),fo(e,C-y/2+.5,p-y/2+.5,y-1,y-1,g),e.lineWidth=1,e.strokeStyle=M?t.textDark:t.textMedium,e.stroke();break}case Js:{e.beginPath(),fo(e,C-y/2,p-y/2,y,y,g),e.fillStyle=M?t.textMedium:t.textLight,e.fill(),m==="circle"&&(x*=.8,y*=.8),e.beginPath(),e.moveTo(C-y/3,p),e.lineTo(C+y/3,p),e.strokeStyle=t.bgCell,e.lineCap="round",e.lineWidth=1.9,e.stroke();break}default:Vo()}}function o0(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x,C,w){var S,F,B,N;const M=a+s;if(M<=0)return;e.fillStyle=h.bgHeader,e.fillRect(0,0,o,M);const U=(S=r==null?void 0:r[0])==null?void 0:S[0],z=(F=r==null?void 0:r[0])==null?void 0:F[1],A=(B=r==null?void 0:r[1])==null?void 0:B[0],W=(N=r==null?void 0:r[1])==null?void 0:N[1],J=h.headerFontFull;e.font=J,Mr(t,0,i,0,M,(_,D,fe,X)=>{var me;if(x!==void 0&&!x.has([_.sourceIndex,-1]))return;const ee=Math.max(0,X-D);e.save(),e.beginPath(),e.rect(D+ee,s,_.width-ee,a),e.clip();const he=y(_.group??"").overrideTheme,de=_.themeOverride===void 0&&he===void 0?h:tr(h,he,_.themeOverride);de.bgHeader!==h.bgHeader&&(e.fillStyle=de.bgHeader,e.fill()),de!==h&&(e.font=de.headerFontFull);const te=d.columns.hasIndex(_.sourceIndex),q=l!==void 0||u||_.headerRowMarkerDisabled===!0,Ce=!q&&z===-1&&U===_.sourceIndex,ie=q?0:((me=p.find(ze=>ze.item[0]===_.sourceIndex&&ze.item[1]===-1))==null?void 0:me.hoverAmount)??0,re=(d==null?void 0:d.current)!==void 0&&d.current.cell[0]===_.sourceIndex,$e=te?de.accentColor:re?de.bgHeaderHasFocus:de.bgHeader,Z=n?s:0,se=_.sourceIndex===0?0:1;te?(e.fillStyle=$e,e.fillRect(D+se,Z,_.width-se,a)):(re||ie>0)&&(e.beginPath(),e.rect(D+se,Z,_.width-se,a),re&&(e.fillStyle=de.bgHeaderHasFocus,e.fill()),ie>0&&(e.globalAlpha=ie,e.fillStyle=de.bgHeaderHovered,e.fill(),e.globalAlpha=1)),Uc(e,D,Z,_.width,a,_,te,de,Ce,Ce?A:void 0,Ce?W:void 0,re,ie,m,C,w),e.restore()}),n&&i0(e,t,o,i,s,r,h,m,p,g,y,x)}function i0(e,t,n,r,o,i,a,s,l,u,d,h){const[p,g]=(i==null?void 0:i[0])??[];let y=0;Hc(t,n,r,o,(x,C,w,M,U,z)=>{if(h!==void 0&&!h.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;e.save(),e.beginPath(),e.rect(w,M,U,z),e.clip();const A=d(C),W=(A==null?void 0:A.overrideTheme)===void 0?a:tr(a,A.overrideTheme),J=g===-2&&p!==void 0&&p>=x[0]&&p<=x[1],S=J?W.bgGroupHeaderHovered??W.bgHeaderHovered:W.bgGroupHeader??W.bgHeader;if(S!==a.bgHeader&&(e.fillStyle=S,e.fill()),e.fillStyle=W.textGroupHeader??W.textHeader,A!==void 0){let F=w;if(A.icon!==void 0&&(s.drawSprite(A.icon,"normal",e,F+8,(o-20)/2,20,W),F+=26),e.fillText(A.name,F+8,o/2+xo(e,a.headerFontFull)),A.actions!==void 0&&J){const B=Wc({x:w,y:M,width:U,height:z},A.actions);e.beginPath();const N=B[0].x-10,_=w+U-N;e.rect(N,0,_,o);const D=e.createLinearGradient(N,0,N+_,0),fe=Br(S,0);D.addColorStop(0,fe),D.addColorStop(10/_,S),D.addColorStop(1,S),e.fillStyle=D,e.fill(),e.globalAlpha=.6;const[X,ee]=(i==null?void 0:i[1])??[-1,-1];for(let he=0;he<A.actions.length;he++){const de=A.actions[he],te=B[he],q=ho(te,X+w,ee);q&&(e.globalAlpha=1),s.drawSprite(de.icon,"normal",e,te.x+te.width/2-10,te.y+te.height/2-10,20,W),q&&(e.globalAlpha=.6)}e.globalAlpha=1}}w!==0&&u(x[0])&&(e.beginPath(),e.moveTo(w+.5,0),e.lineTo(w+.5,o),e.strokeStyle=a.borderColor,e.lineWidth=1,e.stroke()),e.restore(),y=w+U}),e.beginPath(),e.moveTo(y+.5,0),e.lineTo(y+.5,o),e.moveTo(0,o+.5),e.lineTo(n,o+.5),e.strokeStyle=a.borderColor,e.lineWidth=1,e.stroke()}const xi=30;function s0(e,t,n,r,o){return{x:e+n-xi,y:Math.max(t,t+r/2-xi/2),width:xi,height:Math.min(xi,r)}}function Wc(e,t){const n=[];let r=e.x+e.width-26*t.length;const o=e.y+e.height/2-13,i=26,a=26;for(let s=0;s<t.length;s++)n.push({x:r,y:o,width:a,height:i}),r+=26;return n}function Bo(e,t,n){return!n||e===void 0||(e.x=t-(e.x-t)-e.width),e}function Gc(e,t,n,r,o,i,a,s){var C;const l=a.cellHorizontalPadding,u=a.headerIconSize,d=s0(n,r,o,i);let h=n+l;const m=t.icon===void 0?void 0:{x:h,y:r+(i-u)/2,width:u,height:u},p=m===void 0||t.overlayIcon===void 0?void 0:{x:m.x+9,y:m.y+6,width:18,height:18};m!==void 0&&(h+=Math.ceil(u*1.3));const g={x:h,y:r,width:o-h,height:i};let y;if(t.indicatorIcon!==void 0){const w=e===void 0?((C=tb(t.title,a.headerFontFull))==null?void 0:C.width)??0:Ki(t.title,e,a.headerFontFull).width;g.width=w,h+=w+l,y={x:h,y:r+(i-u)/2,width:u,height:u}}const x=n+o/2;return{menuBounds:Bo(d,x,s),iconBounds:Bo(m,x,s),iconOverlayBounds:Bo(p,x,s),textBounds:Bo(g,x,s),indicatorIconBounds:Bo(y,x,s)}}function cl(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y){if(i.rowMarker!==void 0&&i.headerRowMarkerDisabled!==!0){const w=i.rowMarkerChecked;w!==!0&&i.headerRowMarkerAlwaysVisible!==!0&&(e.globalAlpha=h);const M=i.headerRowMarkerTheme!==void 0?tr(s,i.headerRowMarkerTheme):s;ia(e,M,w,t,n,r,o,!1,void 0,void 0,s.checkboxMaxSize,"center",i.rowMarker),w!==!0&&i.headerRowMarkerAlwaysVisible!==!0&&(e.globalAlpha=1);return}const x=a?s.textHeaderSelected:s.textHeader,C=i.hasMenu===!0&&(l||p&&a)&&y.menuBounds!==void 0;if(i.icon!==void 0&&y.iconBounds!==void 0){let w=a?"selected":"normal";i.style==="highlight"&&(w=a?"selected":"special"),m.drawSprite(i.icon,w,e,y.iconBounds.x,y.iconBounds.y,y.iconBounds.width,s),i.overlayIcon!==void 0&&y.iconOverlayBounds!==void 0&&m.drawSprite(i.overlayIcon,a?"selected":"special",e,y.iconOverlayBounds.x,y.iconOverlayBounds.y,y.iconOverlayBounds.width,s)}if(C&&r>35){const M=g?35:r-35,U=g?35*.7:r-35*.7,z=M/r,A=U/r,W=e.createLinearGradient(t,0,t+r,0),J=Br(x,0);W.addColorStop(g?1:0,x),W.addColorStop(z,x),W.addColorStop(A,J),W.addColorStop(g?0:1,J),e.fillStyle=W}else e.fillStyle=x;if(g&&(e.textAlign="right"),y.textBounds!==void 0&&e.fillText(i.title,g?y.textBounds.x+y.textBounds.width:y.textBounds.x,n+o/2+xo(e,s.headerFontFull)),g&&(e.textAlign="left"),i.indicatorIcon!==void 0&&y.indicatorIconBounds!==void 0&&(!C||!Zo(y.menuBounds.x,y.menuBounds.y,y.menuBounds.width,y.menuBounds.height,y.indicatorIconBounds.x,y.indicatorIconBounds.y,y.indicatorIconBounds.width,y.indicatorIconBounds.height))){let w=a?"selected":"normal";i.style==="highlight"&&(w=a?"selected":"special"),m.drawSprite(i.indicatorIcon,w,e,y.indicatorIconBounds.x,y.indicatorIconBounds.y,y.indicatorIconBounds.width,s)}if(C&&y.menuBounds!==void 0){const w=y.menuBounds,M=u!==void 0&&d!==void 0&&ho(w,u+t,d+n);if(M||(e.globalAlpha=.7),i.menuIcon===void 0||i.menuIcon===Ai.Triangle){e.beginPath();const U=w.x+w.width/2-5.5,z=w.y+w.height/2-3;lb(e,[{x:U,y:z},{x:U+11,y:z},{x:U+5.5,y:z+6}],1),e.fillStyle=x,e.fill()}else if(i.menuIcon===Ai.Dots){e.beginPath();const U=w.x+w.width/2,z=w.y+w.height/2;ab(e,U,z),e.fillStyle=x,e.fill()}else{const U=w.x+(w.width-s.headerIconSize)/2,z=w.y+(w.height-s.headerIconSize)/2;m.drawSprite(i.menuIcon,"normal",e,U,z,s.headerIconSize,s)}M||(e.globalAlpha=1)}}function Uc(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y){const x=ea(i.title)==="rtl",C=Gc(e,i,t,n,r,o,s,x);g!==void 0?g({ctx:e,theme:s,rect:{x:t,y:n,width:r,height:o},column:i,columnIndex:i.sourceIndex,isSelected:a,hoverAmount:m,isHovered:l,hasSelectedCell:h,spriteManager:p,menuBounds:(C==null?void 0:C.menuBounds)??{x:0,y:0,height:0,width:0},hoverX:u,hoverY:d},()=>cl(e,t,n,r,o,i,a,s,l,u,d,m,p,y,x,C)):cl(e,t,n,r,o,i,a,s,l,u,d,m,p,y,x,C)}var a0=zr,l0=function(){try{var e=a0(Object,"defineProperty");return e({},"",{}),e}catch{}}(),c0=l0,ul=c0;function u0(e,t,n){t=="__proto__"&&ul?ul(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var d0=u0;function f0(e,t,n,r){for(var o=-1,i=e==null?0:e.length;++o<i;){var a=e[o];t(r,a,n(a),e)}return r}var h0=f0;function g0(e){return function(t,n,r){for(var o=-1,i=Object(t),a=r(t),s=a.length;s--;){var l=a[e?s:++o];if(n(i[l],l,i)===!1)break}return t}}var m0=g0,p0=m0,b0=p0(),y0=b0;function v0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var w0=v0,Pi={exports:{}};function x0(){return!1}var C0=x0;Pi.exports;(function(e,t){var n=Kn,r=C0,o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?n.Buffer:void 0,l=s?s.isBuffer:void 0,u=l||r;e.exports=u})(Pi,Pi.exports);var Xc=Pi.exports,k0=ni,S0=Vs,R0=ri,M0="[object Arguments]",I0="[object Array]",E0="[object Boolean]",T0="[object Date]",D0="[object Error]",$0="[object Function]",A0="[object Map]",F0="[object Number]",_0="[object Object]",P0="[object RegExp]",O0="[object Set]",j0="[object String]",N0="[object WeakMap]",H0="[object ArrayBuffer]",B0="[object DataView]",L0="[object Float32Array]",z0="[object Float64Array]",W0="[object Int8Array]",G0="[object Int16Array]",U0="[object Int32Array]",X0="[object Uint8Array]",K0="[object Uint8ClampedArray]",Y0="[object Uint16Array]",q0="[object Uint32Array]",Tt={};Tt[L0]=Tt[z0]=Tt[W0]=Tt[G0]=Tt[U0]=Tt[X0]=Tt[K0]=Tt[Y0]=Tt[q0]=!0;Tt[M0]=Tt[I0]=Tt[H0]=Tt[E0]=Tt[B0]=Tt[T0]=Tt[D0]=Tt[$0]=Tt[A0]=Tt[F0]=Tt[_0]=Tt[P0]=Tt[O0]=Tt[j0]=Tt[N0]=!1;function V0(e){return R0(e)&&S0(e.length)&&!!Tt[k0(e)]}var J0=V0;function Z0(e){return function(t){return e(t)}}var Q0=Z0,Oi={exports:{}};Oi.exports;(function(e,t){var n=ic,r=t&&!t.nodeType&&t,o=r&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===r,a=i&&n.process,s=function(){try{var l=o&&o.require&&o.require("util").types;return l||a&&a.binding&&a.binding("util")}catch{}}();e.exports=s})(Oi,Oi.exports);var ev=Oi.exports,tv=J0,nv=Q0,dl=ev,fl=dl&&dl.isTypedArray,rv=fl?nv(fl):tv,Kc=rv,ov=w0,iv=Ys,sv=Xn,av=Xc,lv=qs,cv=Kc,uv=Object.prototype,dv=uv.hasOwnProperty;function fv(e,t){var n=sv(e),r=!n&&iv(e),o=!n&&!r&&av(e),i=!n&&!r&&!o&&cv(e),a=n||r||o||i,s=a?ov(e.length,String):[],l=s.length;for(var u in e)(t||dv.call(e,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||lv(u,l)))&&s.push(u);return s}var hv=fv,gv=Object.prototype;function mv(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||gv;return e===n}var pv=mv;function bv(e,t){return function(n){return e(t(n))}}var yv=bv,vv=yv,wv=vv(Object.keys,Object),xv=wv,Cv=pv,kv=xv,Sv=Object.prototype,Rv=Sv.hasOwnProperty;function Mv(e){if(!Cv(e))return kv(e);var t=[];for(var n in Object(e))Rv.call(e,n)&&n!="constructor"&&t.push(n);return t}var Iv=Mv,Ev=hv,Tv=Iv,Dv=oa;function $v(e){return Dv(e)?Ev(e):Tv(e)}var sa=$v,Av=y0,Fv=sa;function _v(e,t){return e&&Av(e,t,Fv)}var Pv=_v,Ov=oa;function jv(e,t){return function(n,r){if(n==null)return n;if(!Ov(n))return e(n,r);for(var o=n.length,i=t?o:-1,a=Object(n);(t?i--:++i<o)&&r(a[i],i,a)!==!1;);return n}}var Nv=jv,Hv=Pv,Bv=Nv,Lv=Bv(Hv),zv=Lv,Wv=zv;function Gv(e,t,n,r){return Wv(e,function(o,i,a){t(r,o,n(o),a)}),r}var Uv=Gv,Xv=Gi;function Kv(){this.__data__=new Xv,this.size=0}var Yv=Kv;function qv(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var Vv=qv;function Jv(e){return this.__data__.get(e)}var Zv=Jv;function Qv(e){return this.__data__.has(e)}var ew=Qv,tw=Gi,nw=Us,rw=Xs,ow=200;function iw(e,t){var n=this.__data__;if(n instanceof tw){var r=n.__data__;if(!nw||r.length<ow-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new rw(r)}return n.set(e,t),this.size=n.size,this}var sw=iw,aw=Gi,lw=Yv,cw=Vv,uw=Zv,dw=ew,fw=sw;function Co(e){var t=this.__data__=new aw(e);this.size=t.size}Co.prototype.clear=lw;Co.prototype.delete=cw;Co.prototype.get=uw;Co.prototype.has=dw;Co.prototype.set=fw;var Yc=Co;function hw(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var gw=hw,mw=Fc,pw=gw,bw=_c,yw=1,vw=2;function ww(e,t,n,r,o,i){var a=n&yw,s=e.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var u=i.get(e),d=i.get(t);if(u&&d)return u==t&&d==e;var h=-1,m=!0,p=n&vw?new mw:void 0;for(i.set(e,t),i.set(t,e);++h<s;){var g=e[h],y=t[h];if(r)var x=a?r(y,g,h,t,e,i):r(g,y,h,e,t,i);if(x!==void 0){if(x)continue;m=!1;break}if(p){if(!pw(t,function(C,w){if(!bw(p,w)&&(g===C||o(g,C,n,r,i)))return p.push(w)})){m=!1;break}}else if(!(g===y||o(g,y,n,r,i))){m=!1;break}}return i.delete(e),i.delete(t),m}var qc=ww,xw=Kn,Cw=xw.Uint8Array,kw=Cw;function Sw(e){var t=-1,n=Array(e.size);return e.forEach(function(r,o){n[++t]=[o,r]}),n}var Rw=Sw,hl=ti,gl=kw,Mw=Gs,Iw=qc,Ew=Rw,Tw=ra,Dw=1,$w=2,Aw="[object Boolean]",Fw="[object Date]",_w="[object Error]",Pw="[object Map]",Ow="[object Number]",jw="[object RegExp]",Nw="[object Set]",Hw="[object String]",Bw="[object Symbol]",Lw="[object ArrayBuffer]",zw="[object DataView]",ml=hl?hl.prototype:void 0,ys=ml?ml.valueOf:void 0;function Ww(e,t,n,r,o,i,a){switch(n){case zw:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Lw:return!(e.byteLength!=t.byteLength||!i(new gl(e),new gl(t)));case Aw:case Fw:case Ow:return Mw(+e,+t);case _w:return e.name==t.name&&e.message==t.message;case jw:case Hw:return e==t+"";case Pw:var s=Ew;case Nw:var l=r&Dw;if(s||(s=Tw),e.size!=t.size&&!l)return!1;var u=a.get(e);if(u)return u==t;r|=$w,a.set(e,t);var d=Iw(s(e),s(t),r,o,i,a);return a.delete(e),d;case Bw:if(ys)return ys.call(e)==ys.call(t)}return!1}var Gw=Ww,Uw=Oc,Xw=Xn;function Kw(e,t,n){var r=t(e);return Xw(e)?r:Uw(r,n(e))}var Yw=Kw;function qw(e,t){for(var n=-1,r=e==null?0:e.length,o=0,i=[];++n<r;){var a=e[n];t(a,n,e)&&(i[o++]=a)}return i}var Vw=qw;function Jw(){return[]}var Zw=Jw,Qw=Vw,ex=Zw,tx=Object.prototype,nx=tx.propertyIsEnumerable,pl=Object.getOwnPropertySymbols,rx=pl?function(e){return e==null?[]:(e=Object(e),Qw(pl(e),function(t){return nx.call(e,t)}))}:ex,ox=rx,ix=Yw,sx=ox,ax=sa;function lx(e){return ix(e,ax,sx)}var cx=lx,bl=cx,ux=1,dx=Object.prototype,fx=dx.hasOwnProperty;function hx(e,t,n,r,o,i){var a=n&ux,s=bl(e),l=s.length,u=bl(t),d=u.length;if(l!=d&&!a)return!1;for(var h=l;h--;){var m=s[h];if(!(a?m in t:fx.call(t,m)))return!1}var p=i.get(e),g=i.get(t);if(p&&g)return p==t&&g==e;var y=!0;i.set(e,t),i.set(t,e);for(var x=a;++h<l;){m=s[h];var C=e[m],w=t[m];if(r)var M=a?r(w,C,m,t,e,i):r(C,w,m,e,t,i);if(!(M===void 0?C===w||o(C,w,n,r,i):M)){y=!1;break}x||(x=m=="constructor")}if(y&&!x){var U=e.constructor,z=t.constructor;U!=z&&"constructor"in e&&"constructor"in t&&!(typeof U=="function"&&U instanceof U&&typeof z=="function"&&z instanceof z)&&(y=!1)}return i.delete(e),i.delete(t),y}var gx=hx,mx=zr,px=Kn,bx=mx(px,"DataView"),yx=bx,vx=zr,wx=Kn,xx=vx(wx,"Promise"),Cx=xx,kx=zr,Sx=Kn,Rx=kx(Sx,"WeakMap"),Mx=Rx,_s=yx,Ps=Us,Os=Cx,js=Pc,Ns=Mx,Vc=ni,ko=lc,yl="[object Map]",Ix="[object Object]",vl="[object Promise]",wl="[object Set]",xl="[object WeakMap]",Cl="[object DataView]",Ex=ko(_s),Tx=ko(Ps),Dx=ko(Os),$x=ko(js),Ax=ko(Ns),Nr=Vc;(_s&&Nr(new _s(new ArrayBuffer(1)))!=Cl||Ps&&Nr(new Ps)!=yl||Os&&Nr(Os.resolve())!=vl||js&&Nr(new js)!=wl||Ns&&Nr(new Ns)!=xl)&&(Nr=function(e){var t=Vc(e),n=t==Ix?e.constructor:void 0,r=n?ko(n):"";if(r)switch(r){case Ex:return Cl;case Tx:return yl;case Dx:return vl;case $x:return wl;case Ax:return xl}return t});var Fx=Nr,vs=Yc,_x=qc,Px=Gw,Ox=gx,kl=Fx,Sl=Xn,Rl=Xc,jx=Kc,Nx=1,Ml="[object Arguments]",Il="[object Array]",Ci="[object Object]",Hx=Object.prototype,El=Hx.hasOwnProperty;function Bx(e,t,n,r,o,i){var a=Sl(e),s=Sl(t),l=a?Il:kl(e),u=s?Il:kl(t);l=l==Ml?Ci:l,u=u==Ml?Ci:u;var d=l==Ci,h=u==Ci,m=l==u;if(m&&Rl(e)){if(!Rl(t))return!1;a=!0,d=!1}if(m&&!d)return i||(i=new vs),a||jx(e)?_x(e,t,n,r,o,i):Px(e,t,l,n,r,o,i);if(!(n&Nx)){var p=d&&El.call(e,"__wrapped__"),g=h&&El.call(t,"__wrapped__");if(p||g){var y=p?e.value():e,x=g?t.value():t;return i||(i=new vs),o(y,x,n,r,i)}}return m?(i||(i=new vs),Ox(e,t,n,r,o,i)):!1}var Lx=Bx,zx=Lx,Tl=ri;function Jc(e,t,n,r,o){return e===t?!0:e==null||t==null||!Tl(e)&&!Tl(t)?e!==e&&t!==t:zx(e,t,n,r,Jc,o)}var Zc=Jc,Wx=Yc,Gx=Zc,Ux=1,Xx=2;function Kx(e,t,n,r){var o=n.length,i=o,a=!r;if(e==null)return!i;for(e=Object(e);o--;){var s=n[o];if(a&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++o<i;){s=n[o];var l=s[0],u=e[l],d=s[1];if(a&&s[2]){if(u===void 0&&!(l in e))return!1}else{var h=new Wx;if(r)var m=r(u,d,l,e,t,h);if(!(m===void 0?Gx(d,u,Ux|Xx,r,h):m))return!1}}return!0}var Yx=Kx,qx=bo;function Vx(e){return e===e&&!qx(e)}var Qc=Vx,Jx=Qc,Zx=sa;function Qx(e){for(var t=Zx(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,Jx(o)]}return t}var e1=Qx;function t1(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}var eu=t1,n1=Yx,r1=e1,o1=eu;function i1(e){var t=r1(e);return t.length==1&&t[0][2]?o1(t[0][0],t[0][1]):function(n){return n===e||n1(n,e,t)}}var s1=i1,a1=dc,l1=Xi;function c1(e,t){t=a1(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[l1(t[n++])];return n&&n==r?e:void 0}var tu=c1,u1=tu;function d1(e,t,n){var r=e==null?void 0:u1(e,t);return r===void 0?n:r}var f1=d1;function h1(e,t){return e!=null&&t in Object(e)}var g1=h1,m1=g1,p1=hc;function b1(e,t){return e!=null&&p1(e,t,m1)}var y1=b1,v1=Zc,w1=f1,x1=y1,C1=Ws,k1=Qc,S1=eu,R1=Xi,M1=1,I1=2;function E1(e,t){return C1(e)&&k1(t)?S1(R1(e),t):function(n){var r=w1(n,e);return r===void 0&&r===t?x1(n,e):v1(t,r,M1|I1)}}var T1=E1;function D1(e){return e}var $1=D1;function A1(e){return function(t){return t==null?void 0:t[e]}}var F1=A1,_1=tu;function P1(e){return function(t){return _1(t,e)}}var O1=P1,j1=F1,N1=O1,H1=Ws,B1=Xi;function L1(e){return H1(e)?j1(B1(e)):N1(e)}var z1=L1,W1=s1,G1=T1,U1=$1,X1=Xn,K1=z1;function Y1(e){return typeof e=="function"?e:e==null?U1:typeof e=="object"?X1(e)?G1(e[0],e[1]):W1(e):K1(e)}var q1=Y1,V1=h0,J1=Uv,Z1=q1,Q1=Xn;function eC(e,t){return function(n,r){var o=Q1(n)?V1:J1,i=t?t():{};return o(n,e,Z1(r),i)}}var tC=eC,nC=d0,rC=tC,oC=Object.prototype,iC=oC.hasOwnProperty,sC=rC(function(e,t,n){iC.call(e,n)?e[n].push(t):nC(e,n,[t])}),aC=sC;const lC=Lr(aC);function cC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x,C,w){if(C!==void 0||t[t.length-1]!==n[t.length-1])return;const M=Nc(x);Mr(t,l,a,s,i,(U,z,A,W,J)=>{if(U!==t[t.length-1])return;z+=U.width;const S=Math.max(z,W);S>r||(e.save(),e.beginPath(),e.rect(S,i+1,1e4,o-i-1),e.clip(),Yi(J,A,o,u,d,g,y,M,(F,B,N,_)=>{if(!_&&x.length>0&&!x.some(he=>Zo(z,F,1e4,N,he.x,he.y,he.width,he.height)))return;const D=m.hasIndex(B),fe=p.hasIndex(B);e.beginPath();const X=h==null?void 0:h(B),ee=X===void 0?w:tr(w,X);ee.bgCell!==w.bgCell&&(e.fillStyle=ee.bgCell,e.fillRect(z,F,1e4,N)),fe&&(e.fillStyle=ee.bgHeader,e.fillRect(z,F,1e4,N)),D&&(e.fillStyle=ee.accentLight,e.fillRect(z,F,1e4,N))}),e.restore())})}function uC(e,t,n,r,o,i,a,s,l){let u=!1;for(const g of t)if(!g.sticky){u=a(g.sourceIndex);break}const d=l.horizontalBorderColor??l.borderColor,h=l.borderColor,m=u?po(t):0;let p;if(m!==0&&(p=el(h,l.bgCell),e.beginPath(),e.moveTo(m+.5,0),e.lineTo(m+.5,r),e.strokeStyle=p,e.stroke()),o>0){const g=h===d&&p!==void 0?p:el(d,l.bgCell),y=Wr(i,o,s);e.beginPath(),e.moveTo(0,r-y+.5),e.lineTo(n,r-y+.5),e.strokeStyle=g,e.stroke()}}const nu=(e,t,n)=>{let r=0,o=t,i=0,a=n;if(e!==void 0&&e.length>0){r=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER;for(const s of e)r=Math.min(r,s.x-1),o=Math.max(o,s.x+s.width+1),i=Math.min(i,s.y-1),a=Math.max(a,s.y+s.height+1)}return{minX:r,maxX:o,minY:i,maxY:a}};function dC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g){var N;const y=g.bgCell,{minX:x,maxX:C,minY:w,maxY:M}=nu(s,i,a),U=[],z=a-Wr(p,m,u);let A=l,W=n,J=0;for(;A+o<z;){const _=A+o,D=u(W);if(_>=w&&_<=M-1){const fe=d==null?void 0:d(W),X=fe==null?void 0:fe.bgCell;X!==void 0&&X!==y&&W>=p-m&&U.push({x,y:_,w:C-x,h:D,color:X})}A+=D,W<p-m&&(J=A),W++}let S=0;const F=Math.min(z,M)-J;if(F>0)for(let _=0;_<t.length;_++){const D=t[_];if(D.width===0)continue;const fe=D.sticky?S:S+r,X=(N=D.themeOverride)==null?void 0:N.bgCell;X!==void 0&&X!==y&&fe>=x&&fe<=C&&h(_+1)&&U.push({x:fe,y:J,w:D.width,h:F,color:X}),S+=D.width}if(U.length===0)return;let B;e.beginPath();for(let _=U.length-1;_>=0;_--){const D=U[_];B===void 0?B=D.color:D.color!==B&&(e.fillStyle=B,e.fill(),e.beginPath(),B=D.color),e.rect(D.x,D.y,D.w,D.h)}B!==void 0&&(e.fillStyle=B,e.fill()),e.beginPath()}function Dl(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x,C=!1){if(l!==void 0){e.beginPath(),e.save(),e.rect(0,0,i,a);for(const N of l)e.rect(N.x+1,N.y+1,N.width-1,N.height-1);e.clip("evenodd")}const w=x.horizontalBorderColor??x.borderColor,M=x.borderColor,{minX:U,maxX:z,minY:A,maxY:W}=nu(s,i,a),J=[];e.beginPath();let S=.5;for(let N=0;N<t.length;N++){const _=t[N];if(_.width===0)continue;S+=_.width;const D=_.sticky?S:S+r;D>=U&&D<=z&&p(N+1)&&J.push({x1:D,y1:Math.max(u,A),x2:D,y2:Math.min(a,W),color:M})}let F=a+.5;for(let N=y-g;N<y;N++){const _=h(N);F-=_,J.push({x1:U,y1:F,x2:z,y2:F,color:w})}if(C!==!0){let N=d+.5,_=n;const D=F;for(;N+o<D;){const fe=N+o;if(fe>=A&&fe<=W-1){const X=m==null?void 0:m(_);J.push({x1:U,y1:fe,x2:z,y2:fe,color:(X==null?void 0:X.horizontalBorderColor)??(X==null?void 0:X.borderColor)??w})}N+=h(_),_++}}const B=lC(J,N=>N.color);for(const N of Object.keys(B)){e.strokeStyle=N;for(const _ of B[N])e.moveTo(_.x1,_.y1),e.lineTo(_.x2,_.y2);e.stroke(),e.beginPath()}l!==void 0&&e.restore()}function fC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x,C,w){const M=[];e.imageSmoothingEnabled=!1;const U=Math.min(o.cellYOffset,a),z=Math.max(o.cellYOffset,a);let A=0;if(typeof C=="number")A+=(z-U)*C;else for(let D=U;D<z;D++)A+=C(D);a>o.cellYOffset&&(A=-A),A+=l-o.translateY;const W=Math.min(o.cellXOffset,i),J=Math.max(o.cellXOffset,i);let S=0;for(let D=W;D<J;D++)S+=y[D].width;i>o.cellXOffset&&(S=-S),S+=s-o.translateX;const F=po(x);if(S!==0&&A!==0)return{regions:[]};const B=u>0?Wr(m,u,C):0,N=d-F-Math.abs(S),_=h-p-B-Math.abs(A)-1;if(N>150&&_>150){const D={sx:0,sy:0,sw:d*g,sh:h*g,dx:0,dy:0,dw:d*g,dh:h*g};if(A>0?(D.sy=(p+1)*g,D.sh=_*g,D.dy=(A+p+1)*g,D.dh=_*g,M.push({x:0,y:p,width:d,height:A+1})):A<0&&(D.sy=(-A+p+1)*g,D.sh=_*g,D.dy=(p+1)*g,D.dh=_*g,M.push({x:0,y:h+A-B,width:d,height:-A+B})),S>0?(D.sx=F*g,D.sw=N*g,D.dx=(S+F)*g,D.dw=N*g,M.push({x:F-1,y:0,width:S+2,height:h})):S<0&&(D.sx=(F-S)*g,D.sw=N*g,D.dx=F*g,D.dw=N*g,M.push({x:d+S,y:0,width:-S,height:h})),e.setTransform(1,0,0,1,0,0),w){if(F>0&&S!==0&&A===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const fe=F*g,X=h*g;e.drawImage(t,0,0,fe,X,0,0,fe,X)}if(B>0&&S===0&&A!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const fe=(h-B)*g,X=d*g,ee=B*g;e.drawImage(t,0,fe,X,ee,0,fe,X,ee)}}e.drawImage(t,D.sx,D.sy,D.sw,D.sh,D.dx,D.dy,D.dw,D.dh),e.scale(g,g)}return e.imageSmoothingEnabled=!0,{regions:M}}function hC(e,t,n,r,o,i,a,s,l,u){const d=[];return t!==e.cellXOffset||n!==e.cellYOffset||r!==e.translateX||o!==e.translateY||Mr(l,n,r,o,s,(h,m,p,g)=>{if(h.sourceIndex===u){const y=Math.max(m,g)+1;return d.push({x:y,y:0,width:i-y,height:a}),!0}}),d}function gC(e,t){if(t===void 0||e.width!==t.width||e.height!==t.height||e.theme!==t.theme||e.headerHeight!==t.headerHeight||e.rowHeight!==t.rowHeight||e.rows!==t.rows||e.freezeColumns!==t.freezeColumns||e.getRowThemeOverride!==t.getRowThemeOverride||e.isFocused!==t.isFocused||e.isResizing!==t.isResizing||e.verticalBorder!==t.verticalBorder||e.getCellContent!==t.getCellContent||e.highlightRegions!==t.highlightRegions||e.selection!==t.selection||e.dragAndDropState!==t.dragAndDropState||e.prelightCells!==t.prelightCells||e.touchMode!==t.touchMode||e.maxScaleFactor!==t.maxScaleFactor)return!1;if(e.mappedColumns!==t.mappedColumns){if(e.mappedColumns.length>100||e.mappedColumns.length!==t.mappedColumns.length)return!1;let n;for(let r=0;r<e.mappedColumns.length;r++){const o=e.mappedColumns[r],i=t.mappedColumns[r];if(mo(o,i))continue;if(n!==void 0||o.width===i.width)return!1;const{width:a,...s}=o,{width:l,...u}=i;if(!mo(s,u))return!1;n=r}return n===void 0?!0:n}return!0}function $l(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y){const x=g==null?void 0:g.filter(W=>W.style!=="no-outline");if(x===void 0||x.length===0)return;const C=po(s),w=Wr(p,m,h),M=[l,0,s.length,p-m],U=[C,0,t,n-w],z=x.map(W=>{const J=W.range,S=W.style??"dashed";return t0(J,M,t,n,U).map(F=>{const B=F.rect,N=$s(B.x,B.y,t,n,d,u+d,r,o,i,a,p,l,m,s,h),_=B.width===1&&B.height===1?N:$s(B.x+B.width-1,B.y+B.height-1,t,n,d,u+d,r,o,i,a,p,l,m,s,h);return B.x+B.width>=s.length&&(_.width-=1),B.y+B.height>=p&&(_.height-=1),{color:W.color,style:S,clip:F.clip,rect:e0({x:N.x,y:N.y,width:_.x+_.width-N.x,height:_.y+_.height-N.y},t,n,8)}})}),A=()=>{e.lineWidth=1;let W=!1;for(const J of z)for(const S of J)if((S==null?void 0:S.rect)!==void 0&&Zo(0,0,t,n,S.rect.x,S.rect.y,S.rect.width,S.rect.height)){const F=W,B=!Qy(S.clip,S.rect);e.beginPath(),B&&(e.save(),e.rect(S.clip.x,S.clip.y,S.clip.width,S.clip.height),e.clip()),S.style==="dashed"&&!W?(e.setLineDash([5,3]),W=!0):(S.style==="solid"||S.style==="solid-outline")&&W&&(e.setLineDash([]),W=!1),e.strokeStyle=S.style==="solid-outline"?bn(bn(S.color,y.borderColor),y.bgCell):Br(S.color,1),e.closePath(),e.strokeRect(S.rect.x+.5,S.rect.y+.5,S.rect.width-1,S.rect.height-1),B&&(e.restore(),W=F)}W&&e.setLineDash([])};return A(),A}function Al(e,t,n,r,o){e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.lineWidth=2,e.strokeStyle=o,e.stroke(),e.globalAlpha=1}function ws(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,y,x){if(d.current===void 0)return;const C=y!==!1&&y!==void 0;if(!C)return;const w=typeof y=="object"?{...Fi,...y}:Fi,M=d.current.range,U=d.current.cell,z=[M.x+M.width-1,M.y+M.height-1];if(U[1]>=x&&z[1]>=x||!a.some(X=>X.sourceIndex===U[0]||X.sourceIndex===z[0]))return;const[W,J]=d.current.cell,S=m(d.current.cell),F=S.span??[W,W],B=J>=x-p,N=p>0&&!B?Wr(x,p,h)-1:0,_=z[1];let D;if(Mr(a,r,o,i,u,(X,ee,he,de,te)=>{if(X.sticky&&W>X.sourceIndex)return;const q=X.sourceIndex<F[0],Ce=X.sourceIndex>F[1],ie=X.sourceIndex===z[0];if(!(!ie&&(q||Ce)))return Yi(te,he,n,x,h,p,g,void 0,(re,$e,Z)=>{if($e!==J&&$e!==_)return;let se=ee,me=X.width;if(S.span!==void 0){const Me=Bc(S.span,ee,re,X.width,Z,X,s),ot=X.sticky?Me[0]:Me[1];ot!==void 0&&(se=ot.x,me=ot.width)}return $e===_&&ie&&C&&(D=()=>{var Oe;de>se&&!X.sticky&&(e.beginPath(),e.rect(de,0,t-de,n),e.clip());const Me=w.size,ot=Me/2,it=se+me+w.offsetX-ot+.5,Ae=re+Z+w.offsetY-ot+.5;e.beginPath(),w.shape==="circle"?e.arc(it+ot,Ae+ot,ot,0,Math.PI*2):e.rect(it,Ae,Me,Me),e.fillStyle=((Oe=X.themeOverride)==null?void 0:Oe.accentColor)??l.accentColor,e.fill(),w.outline>0&&(e.lineWidth=w.outline,e.strokeStyle=l.bgCell,w.shape==="circle"?(e.beginPath(),e.arc(it+ot,Ae+ot,ot+w.outline/2,0,Math.PI*2),e.stroke()):e.strokeRect(it-w.outline/2,Ae-w.outline/2,Me+w.outline,Me+w.outline))}),D!==void 0}),D!==void 0}),D===void 0)return;const fe=()=>{e.save(),e.beginPath(),e.rect(0,u,t,n-u-N),e.clip(),D==null||D(),e.restore()};return fe(),fe}function mC(e,t,n,r,o,i,a,s,l){l===void 0||l.size===0||(e.beginPath(),Hc(t,n,i,r,(u,d,h,m,p,g)=>{l.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&e.rect(h,m,p,g)}),Mr(t,s,i,a,o,(u,d,h,m)=>{const p=Math.max(0,m-d),g=d+p+1,y=u.width-p-1;l.has([u.sourceIndex,-1])&&e.rect(g,r,y,o-r)}),e.clip())}function pC(e,t,n,r,o,i,a,s,l,u){let d=0;return Mr(e,i,r,o,n,(h,m,p,g,y)=>(Yi(y,p,t,a,s,l,u,void 0,(x,C,w,M)=>{M||(d=Math.max(C,d))}),!0)),d}function Fl(e,t){var ln;const{canvasCtx:n,headerCanvasCtx:r,width:o,height:i,cellXOffset:a,cellYOffset:s,translateX:l,translateY:u,mappedColumns:d,enableGroups:h,freezeColumns:m,dragAndDropState:p,theme:g,drawFocus:y,headerHeight:x,groupHeaderHeight:C,disabledRows:w,rowHeight:M,verticalBorder:U,overrideCursor:z,isResizing:A,selection:W,fillHandle:J,freezeTrailingRows:S,rows:F,getCellContent:B,getGroupDetails:N,getRowThemeOverride:_,isFocused:D,drawHeaderCallback:fe,prelightCells:X,drawCellCallback:ee,highlightRegions:he,resizeCol:de,imageLoader:te,lastBlitData:q,hoverValues:Ce,hyperWrapping:ie,hoverInfo:re,spriteManager:$e,maxScaleFactor:Z,hasAppendRow:se,touchMode:me,enqueue:ze,renderStateProvider:Me,getCellRenderer:ot,renderStrategy:it,bufferACtx:Ae,bufferBCtx:Oe,damage:je,minimumCellWidth:vt,resizeIndicator:wt}=e;if(o===0||i===0)return;const ut=it==="double-buffer",oe=Math.min(Z,Math.ceil(window.devicePixelRatio??1)),ve=it!=="direct"&&gC(e,t),De=n.canvas;(De.width!==o*oe||De.height!==i*oe)&&(De.width=o*oe,De.height=i*oe,De.style.width=o+"px",De.style.height=i+"px");const Fe=r.canvas,pe=h?C+x:x,Ke=pe+1;(Fe.width!==o*oe||Fe.height!==Ke*oe)&&(Fe.width=o*oe,Fe.height=Ke*oe,Fe.style.width=o+"px",Fe.style.height=Ke+"px");const Ye=Ae.canvas,We=Oe.canvas;ut&&(Ye.width!==o*oe||Ye.height!==i*oe)&&(Ye.width=o*oe,Ye.height=i*oe,q.current!==void 0&&(q.current.aBufferScroll=void 0)),ut&&(We.width!==o*oe||We.height!==i*oe)&&(We.width=o*oe,We.height=i*oe,q.current!==void 0&&(q.current.bBufferScroll=void 0));const ce=q.current;if(ve===!0&&a===(ce==null?void 0:ce.cellXOffset)&&s===(ce==null?void 0:ce.cellYOffset)&&l===(ce==null?void 0:ce.translateX)&&u===(ce==null?void 0:ce.translateY))return;let Se=null;ut&&(Se=n);const qe=r;let le;ut?je!==void 0?le=(ce==null?void 0:ce.lastBuffer)==="b"?Oe:Ae:le=(ce==null?void 0:ce.lastBuffer)==="b"?Ae:Oe:le=n;const tt=le.canvas,mt=ut?tt===Ye?We:Ye:De,Re=typeof M=="number"?()=>M:M;qe.save(),le.save(),qe.beginPath(),le.beginPath(),qe.textBaseline="middle",le.textBaseline="middle",oe!==1&&(qe.scale(oe,oe),le.scale(oe,oe));const we=Ds(d,a,o,p,l);let It=[];const dt=y&&((ln=W.current)==null?void 0:ln.cell[1])===s&&u===0;let He=!1;if(he!==void 0){for(const kt of he)if(kt.style!=="no-outline"&&kt.range.y===s&&u===0){He=!0;break}}const st=()=>{o0(qe,we,h,re,o,l,x,C,p,A,W,g,$e,Ce,U,N,je,fe,me),Dl(qe,we,s,l,u,o,i,void 0,void 0,C,pe,Re,_,U,S,F,g,!0),qe.beginPath(),qe.moveTo(0,Ke-.5),qe.lineTo(o,Ke-.5),qe.strokeStyle=bn(g.headerBottomBorderColor??g.horizontalBorderColor??g.borderColor,g.bgHeader),qe.stroke(),He&&$l(qe,o,i,a,s,l,u,d,m,x,C,M,S,F,he,g),dt&&ws(qe,o,i,s,l,u,we,d,g,pe,W,Re,B,S,se,J,F)};if(je!==void 0){const kt=we[we.length-1].sourceIndex+1,Ot=je.hasItemInRegion([{x:a,y:-2,width:kt,height:2},{x:a,y:s,width:kt,height:300},{x:0,y:s,width:m,height:300},{x:0,y:-2,width:m,height:2},{x:a,y:F-S,width:kt,height:S,when:S>0}]),Pe=Dt=>{ll(Dt,we,d,i,pe,l,u,s,F,Re,B,N,_,w,D,y,S,se,It,je,W,X,he,te,$e,Ce,re,ee,ie,g,ze,Me,ot,z,vt);const Gt=W.current;J!==!1&&J!==void 0&&y&&Gt!==void 0&&je.has(Cc(Gt.range))&&ws(Dt,o,i,s,l,u,we,d,g,pe,W,Re,B,S,se,J,F)};Ot&&(Pe(le),Se!==null&&(Se.save(),Se.scale(oe,oe),Se.textBaseline="middle",Pe(Se),Se.restore()),je.hasHeader()&&(mC(qe,we,o,C,pe,l,u,s,je),st())),le.restore(),qe.restore();return}if((ve!==!0||a!==(ce==null?void 0:ce.cellXOffset)||l!==(ce==null?void 0:ce.translateX)||dt!==(ce==null?void 0:ce.mustDrawFocusOnHeader)||He!==(ce==null?void 0:ce.mustDrawHighlightRingsOnHeader))&&st(),ve===!0){pn(mt!==void 0&&ce!==void 0);const{regions:kt}=fC(le,mt,mt===Ye?ce.aBufferScroll:ce.bBufferScroll,mt===Ye?ce.bBufferScroll:ce.aBufferScroll,ce,a,s,l,u,S,o,i,F,pe,oe,d,we,M,ut);It=kt}else ve!==!1&&(pn(ce!==void 0),It=hC(ce,a,s,l,u,o,i,pe,we,ve));uC(le,we,o,i,S,F,U,Re,g);const pt=$l(le,o,i,a,s,l,u,d,m,x,C,M,S,F,he,g),Pt=y?ws(le,o,i,s,l,u,we,d,g,pe,W,Re,B,S,se,J,F):void 0;if(le.fillStyle=g.bgCell,It.length>0){le.beginPath();for(const kt of It)le.rect(kt.x,kt.y,kt.width,kt.height);le.clip(),le.fill(),le.beginPath()}else le.fillRect(0,0,o,i);const an=ll(le,we,d,i,pe,l,u,s,F,Re,B,N,_,w,D,y,S,se,It,je,W,X,he,te,$e,Ce,re,ee,ie,g,ze,Me,ot,z,vt);cC(le,we,d,o,i,pe,l,u,s,F,Re,_,W.rows,w,S,se,It,je,g),dC(le,we,s,l,u,o,i,It,pe,Re,_,U,S,F,g),Dl(le,we,s,l,u,o,i,It,an,C,pe,Re,_,U,S,F,g),pt==null||pt(),Pt==null||Pt(),A&&wt!=="none"&&Mr(we,0,l,0,pe,(kt,Ot)=>kt.sourceIndex===de?(Al(qe,Ot+kt.width,0,pe+1,bn(g.resizeIndicatorColor??g.accentLight,g.bgHeader)),wt==="full"&&Al(le,Ot+kt.width,pe,i,bn(g.resizeIndicatorColor??g.accentLight,g.bgCell)),!0):!1),Se!==null&&(Se.fillStyle=g.bgCell,Se.fillRect(0,0,o,i),Se.drawImage(le.canvas,0,0));const Kt=pC(we,i,pe,l,u,s,F,Re,S,se);te==null||te.setWindow({x:a,y:s,width:we.length,height:Kt-s},m,Array.from({length:S},(kt,Ot)=>F-1-Ot));const bt=ce!==void 0&&(a!==ce.cellXOffset||l!==ce.translateX),En=ce!==void 0&&(s!==ce.cellYOffset||u!==ce.translateY);q.current={cellXOffset:a,cellYOffset:s,translateX:l,translateY:u,mustDrawFocusOnHeader:dt,mustDrawHighlightRingsOnHeader:He,lastBuffer:ut?tt===Ye?"a":"b":void 0,aBufferScroll:tt===Ye?[bt,En]:ce==null?void 0:ce.aBufferScroll,bBufferScroll:tt===We?[bt,En]:ce==null?void 0:ce.bBufferScroll},le.restore(),qe.restore()}const bC=80;function yC(e){const t=e-1;return t*t*t+1}class vC{constructor(t){Xe(this,"callback");Xe(this,"currentHoveredItem");Xe(this,"leavingItems",[]);Xe(this,"lastAnimationTime");Xe(this,"addToLeavingItems",t=>{this.leavingItems.some(r=>Ko(r.item,t.item))||this.leavingItems.push(t)});Xe(this,"removeFromLeavingItems",t=>{const n=this.leavingItems.find(r=>Ko(r.item,t));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});Xe(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(t=>t.hoverAmount>0)});Xe(this,"shouldStep",()=>{const t=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return t||n});Xe(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(t=>({...t,hoverAmount:yC(t.hoverAmount)})));Xe(this,"step",t=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=t;else{const r=(t-this.lastAnimationTime)/bC;for(const i of this.leavingItems)i.hoverAmount=Rn(i.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Rn(this.currentHoveredItem.hoverAmount+r,0,1));const o=this.getAnimatingItems();this.callback(o),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=t,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});Xe(this,"setHovered",t=>{var n;if(!Ko((n=this.currentHoveredItem)==null?void 0:n.item,t)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),t!==void 0){const r=this.removeFromLeavingItems(t);this.currentHoveredItem={item:t,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=t}}class wC{constructor(t){Xe(this,"fn");Xe(this,"val");this.fn=t}get value(){return this.val??(this.val=this.fn())}}function aa(e){return new wC(e)}const xC=aa(()=>window.navigator.userAgent.includes("Firefox")),ji=aa(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Ni=aa(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function CC(e){const t=c.useRef([]),n=c.useRef(0),r=c.useRef(e);r.current=e;const o=c.useCallback(()=>{const i=()=>window.requestAnimationFrame(a),a=()=>{const s=t.current.map(Tc);t.current=[],r.current(new Ei(s)),t.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?i:a)},[]);return c.useCallback(i=>{t.current.length===0&&o();const a=er(i[0],i[1]);t.current.includes(a)||t.current.push(a)},[o])}const kr="header",Hn="group-header",Hi="out-of-bounds";var uo;(function(e){e[e.Start=-2]="Start",e[e.StartPadding=-1]="StartPadding",e[e.Center=0]="Center",e[e.EndPadding=1]="EndPadding",e[e.End=2]="End"})(uo||(uo={}));function ru(e,t){return e===t?!0:(e==null?void 0:e.kind)==="out-of-bounds"?(e==null?void 0:e.kind)===(t==null?void 0:t.kind)&&(e==null?void 0:e.location[0])===(t==null?void 0:t.location[0])&&(e==null?void 0:e.location[1])===(t==null?void 0:t.location[1])&&(e==null?void 0:e.region[0])===(t==null?void 0:t.region[0])&&(e==null?void 0:e.region[1])===(t==null?void 0:t.region[1]):(e==null?void 0:e.kind)===(t==null?void 0:t.kind)&&(e==null?void 0:e.location[0])===(t==null?void 0:t.location[0])&&(e==null?void 0:e.location[1])===(t==null?void 0:t.location[1])}const kC=(e,t)=>{if(e.kind===ue.Custom)return e.copyData;const n=t==null?void 0:t(e);return(n==null?void 0:n.getAccessibilityString(e))??""},SC=(e,t)=>{const{width:n,height:r,accessibilityHeight:o,columns:i,cellXOffset:a,cellYOffset:s,headerHeight:l,fillHandle:u=!1,groupHeaderHeight:d,rowHeight:h,rows:m,getCellContent:p,getRowThemeOverride:g,onHeaderMenuClick:y,onHeaderIndicatorClick:x,enableGroups:C,isFilling:w,onCanvasFocused:M,onCanvasBlur:U,isFocused:z,selection:A,freezeColumns:W,onContextMenu:J,freezeTrailingRows:S,fixedShadowX:F=!0,fixedShadowY:B=!0,drawFocusRing:N,onMouseDown:_,onMouseUp:D,onMouseMoveRaw:fe,onMouseMove:X,onItemHovered:ee,dragAndDropState:he,firstColAccessible:de,onKeyDown:te,onKeyUp:q,highlightRegions:Ce,canvasRef:ie,onDragStart:re,onDragEnd:$e,eventTargetRef:Z,isResizing:se,resizeColumn:me,isDragging:ze,isDraggable:Me=!1,allowResize:ot,disabledRows:it,hasAppendRow:Ae,getGroupDetails:Oe,theme:je,prelightCells:vt,headerIcons:wt,verticalBorder:ut,drawCell:oe,drawHeader:ve,onCellFocused:De,onDragOverCell:Fe,onDrop:pe,onDragLeave:Ke,imageWindowLoader:Ye,smoothScrollX:We=!1,smoothScrollY:ce=!1,experimental:Se,getCellRenderer:qe,resizeIndicator:le="full"}=e,tt=e.translateX??0,mt=e.translateY??0,Re=Math.max(W,Math.min(i.length-1,a)),we=c.useRef(null),It=c.useRef((Se==null?void 0:Se.eventTarget)??window),dt=It.current,He=Ye,st=c.useRef(),[pt,Pt]=c.useState(!1),an=c.useRef([]),Kt=c.useRef(),[bt,En]=c.useState(),[ln,kt]=c.useState(),Ot=c.useRef(null),[Pe,Dt]=c.useState(),[Gt,et]=c.useState(!1),Rt=c.useRef(Gt);Rt.current=Gt;const lt=c.useMemo(()=>new Jy(wt,()=>{rr.current=void 0,cn.current()}),[wt]),jt=C?d+l:l,Et=c.useRef(-1),ft=((Se==null?void 0:Se.enableFirefoxRescaling)??!1)&&xC.value,yn=((Se==null?void 0:Se.enableSafariRescaling)??!1)&&ji.value;c.useLayoutEffect(()=>{window.devicePixelRatio===1||!ft&&!yn||(Et.current!==-1&&Pt(!0),window.clearTimeout(Et.current),Et.current=window.setTimeout(()=>{Pt(!1),Et.current=-1},200))},[s,Re,tt,mt,ft,yn]);const ht=Kp(i,W),Bn=c.useMemo(()=>F?po(ht,he):0,[ht,he,F]),xt=c.useCallback((E,b,T)=>{const P=E.getBoundingClientRect();if(b>=ht.length||T>=m)return;const L=P.width/n,V=$s(b,T,n,r,d,jt,Re,s,tt,mt,m,W,S,ht,h);return L!==1&&(V.x*=L,V.y*=L,V.width*=L,V.height*=L),V.x+=P.x,V.y+=P.y,V},[n,r,d,jt,Re,s,tt,mt,m,W,S,ht,h]),xe=c.useCallback((E,b,T,P)=>{const L=E.getBoundingClientRect(),V=L.width/n,ge=(b-L.left)/V,Ge=(T-L.top)/V,ke=5,Ht=Ds(ht,Re,n,void 0,tt);let Ie=0,nt=0;const Ue=typeof PointerEvent<"u"&&P instanceof PointerEvent&&P.pointerType==="mouse"||typeof MouseEvent<"u"&&P instanceof MouseEvent,Ve=typeof PointerEvent<"u"&&P instanceof PointerEvent&&P.pointerType==="touch"||typeof TouchEvent<"u"&&P instanceof TouchEvent;Ue&&(Ie=P.button,nt=P.buttons);const Be=Jp(ge,Ht,tt),at=Zp(Ge,r,C,l,d,m,h,s,mt,S),At=(P==null?void 0:P.shiftKey)===!0,_n=(P==null?void 0:P.ctrlKey)===!0,Pn=(P==null?void 0:P.metaKey)===!0,Mt=[ge<0?-1:n<ge?1:0,Ge<jt?-1:r<Ge?1:0];let _t;if(Be===-1||Ge<0||ge<0||at===void 0||ge>n||Ge>r){const yt=ge>n?1:ge<0?-1:0,Cn=Ge>r?1:Ge<0?-1:0;let Zt=yt*2,Jr=Cn*2;yt===0&&(Zt=Be===-1?uo.EndPadding:uo.Center),Cn===0&&(Jr=at===void 0?uo.EndPadding:uo.Center);let Zn=!1;if(Be===-1&&at===-1){const Bt=xt(E,ht.length-1,-1);pn(Bt!==void 0),Zn=b<Bt.x+Bt.width+ke}const Je=ge>n&&ge<n+Is()||Ge>r&&Ge<r+Is();_t={kind:Hi,location:[Be!==-1?Be:ge<0?0:ht.length-1,at??m-1],region:[Zt,Jr],shiftKey:At,ctrlKey:_n,metaKey:Pn,isEdge:Zn,isTouch:Ve,button:Ie,buttons:nt,scrollEdge:Mt,isMaybeScrollbar:Je}}else if(at<=-1){let yt=xt(E,Be,at);pn(yt!==void 0);let Cn=yt!==void 0&&yt.x+yt.width-b<=ke;const Zt=Be-1;b-yt.x<=ke&&Zt>=0?(Cn=!0,yt=xt(E,Zt,at),pn(yt!==void 0),_t={kind:C&&at===-2?Hn:kr,location:[Zt,at],bounds:yt,group:ht[Zt].group??"",isEdge:Cn,shiftKey:At,ctrlKey:_n,metaKey:Pn,isTouch:Ve,localEventX:b-yt.x,localEventY:T-yt.y,button:Ie,buttons:nt,scrollEdge:Mt}):_t={kind:C&&at===-2?Hn:kr,group:ht[Be].group??"",location:[Be,at],bounds:yt,isEdge:Cn,shiftKey:At,ctrlKey:_n,metaKey:Pn,isTouch:Ve,localEventX:b-yt.x,localEventY:T-yt.y,button:Ie,buttons:nt,scrollEdge:Mt}}else{const yt=xt(E,Be,at);pn(yt!==void 0);const Cn=yt!==void 0&&yt.x+yt.width-b<ke;let Zt=!1;if(u!==!1&&u!==void 0&&A.current!==void 0){const Zn=typeof u=="object"?{...Fi,...u}:Fi,Je=Zn.size,Bt=Je/2,$r=Cc(A.current.range),pr=xt(E,$r[0],$r[1]);if(pr!==void 0){const Qn=pr.x+pr.width+Zn.offsetX-Bt+.5,St=pr.y+pr.height+Zn.offsetY-Bt+.5;Zt=Math.abs(Qn-b)<Je&&Math.abs(St-T)<Je}}_t={kind:"cell",location:[Be,at],bounds:yt,isEdge:Cn,shiftKey:At,ctrlKey:_n,isFillHandle:Zt,metaKey:Pn,isTouch:Ve,localEventX:b-yt.x,localEventY:T-yt.y,button:Ie,buttons:nt,scrollEdge:Mt}}return _t},[n,ht,Re,tt,r,C,l,d,m,h,s,mt,S,xt,u,A,jt]),[Yt]=bt??[],Ir=c.useRef(()=>{}),vn=c.useRef(bt);vn.current=bt;const[Ut,en]=c.useMemo(()=>{const E=document.createElement("canvas"),b=document.createElement("canvas");return E.style.display="none",E.style.opacity="0",E.style.position="fixed",b.style.display="none",b.style.opacity="0",b.style.position="fixed",[E.getContext("2d",{alpha:!1}),b.getContext("2d",{alpha:!1})]},[]);c.useLayoutEffect(()=>{if(!(Ut===null||en===null))return document.documentElement.append(Ut.canvas),document.documentElement.append(en.canvas),()=>{Ut.canvas.remove(),en.canvas.remove()}},[Ut,en]);const Ln=c.useMemo(()=>new ub,[]),nr=ft&&pt?1:yn&&pt?2:5,Tn=(Se==null?void 0:Se.disableMinimumCellWidth)===!0?1:10,rr=c.useRef(),or=c.useRef(null),ir=c.useRef(null),sr=c.useCallback(()=>{var ge;const E=we.current,b=Ot.current;if(E===null||b===null||(or.current===null&&(or.current=E.getContext("2d",{alpha:!1}),E.width=0,E.height=0),ir.current===null&&(ir.current=b.getContext("2d",{alpha:!1}),b.width=0,b.height=0),or.current===null||ir.current===null||Ut===null||en===null))return;let T=!1;const P=Ge=>{T=!0,Dt(Ge)},L=rr.current,V={headerCanvasCtx:ir.current,canvasCtx:or.current,bufferACtx:Ut,bufferBCtx:en,width:n,height:r,cellXOffset:Re,cellYOffset:s,translateX:Math.round(tt),translateY:Math.round(mt),mappedColumns:ht,enableGroups:C,freezeColumns:W,dragAndDropState:he,theme:je,headerHeight:l,groupHeaderHeight:d,disabledRows:it??rt.empty(),rowHeight:h,verticalBorder:ut,isResizing:se,resizeCol:me,isFocused:z,selection:A,fillHandle:u,drawCellCallback:oe,hasAppendRow:Ae,overrideCursor:P,maxScaleFactor:nr,freezeTrailingRows:S,rows:m,drawFocus:N,getCellContent:p,getGroupDetails:Oe??(Ge=>({name:Ge})),getRowThemeOverride:g,drawHeaderCallback:ve,prelightCells:vt,highlightRegions:Ce,imageLoader:He,lastBlitData:Kt,damage:st.current,hoverValues:an.current,hoverInfo:vn.current,spriteManager:lt,scrolling:pt,hyperWrapping:(Se==null?void 0:Se.hyperWrapping)??!1,touchMode:Gt,enqueue:Ir.current,renderStateProvider:Ln,renderStrategy:(Se==null?void 0:Se.renderStrategy)??(ji.value?"double-buffer":"single-buffer"),getCellRenderer:qe,minimumCellWidth:Tn,resizeIndicator:le};V.damage===void 0?(rr.current=V,Fl(V,L)):Fl(V,void 0),!T&&(V.damage===void 0||V.damage.has((ge=vn==null?void 0:vn.current)==null?void 0:ge[0]))&&Dt(void 0)},[Ut,en,n,r,Re,s,tt,mt,ht,C,W,he,je,l,d,it,h,ut,se,Ae,me,z,A,u,S,m,N,nr,p,Oe,g,oe,ve,vt,Ce,He,lt,pt,Se==null?void 0:Se.hyperWrapping,Se==null?void 0:Se.renderStrategy,Gt,Ln,qe,Tn,le]),cn=c.useRef(sr);c.useLayoutEffect(()=>{sr(),cn.current=sr},[sr]),c.useLayoutEffect(()=>{(async()=>{var b;((b=document==null?void 0:document.fonts)==null?void 0:b.ready)!==void 0&&(await document.fonts.ready,rr.current=void 0,cn.current())})()},[]);const wn=c.useCallback(E=>{st.current=E,cn.current(),st.current=void 0},[]),Er=CC(wn);Ir.current=Er;const Ur=c.useCallback(E=>{wn(new Ei(E.map(b=>b.cell)))},[wn]);He.setCallback(wn);const[Xr,So]=c.useState(!1),[xn,un]=Yt??[],ar=xn!==void 0&&un===-1&&xn>=0&&xn<ht.length&&ht[xn].headerRowMarkerDisabled!==!0,Ro=xn!==void 0&&un===-2;let lr=!1,cr=!1,Yn=Pe;if(Yn===void 0&&xn!==void 0&&un!==void 0&&un>-1&&un<m){const E=p([xn,un],!0);lr=E.kind===Mn.NewRow||E.kind===Mn.Marker&&E.markerKind!=="number",cr=E.kind===ue.Boolean&&Zs(E),Yn=E.cursor}const Kr=ze?"grabbing":(ln??!1)||se?"col-resize":Xr||w?"crosshair":Yn!==void 0?Yn:ar||lr||cr||Ro?"pointer":"default",ur=c.useMemo(()=>({contain:"strict",display:"block",cursor:Kr}),[Kr]),Ct=c.useRef("default"),qt=Z==null?void 0:Z.current;qt!=null&&Ct.current!==ur.cursor&&(qt.style.cursor=Ct.current=ur.cursor);const dr=c.useCallback((E,b,T,P)=>{if(Oe===void 0)return;const L=Oe(E);if(L.actions!==void 0){const V=Wc(b,L.actions);for(const[ge,Ge]of V.entries())if(ho(Ge,T+b.x,P+Ge.y))return L.actions[ge]}},[Oe]),Vt=c.useCallback((E,b,T,P)=>{const L=ht[b];if(!ze&&!se&&!(ln??!1)){const V=xt(E,b,-1);pn(V!==void 0);const ge=Gc(void 0,L,V.x,V.y,V.width,V.height,je,ea(L.title)==="rtl");if(L.hasMenu===!0&&ge.menuBounds!==void 0&&ho(ge.menuBounds,T,P))return{area:"menu",bounds:ge.menuBounds};if(L.indicatorIcon!==void 0&&ge.indicatorIconBounds!==void 0&&ho(ge.indicatorIconBounds,T,P))return{area:"indicator",bounds:ge.indicatorIconBounds}}},[ht,xt,ln,ze,se,je]),Dn=c.useRef(0),Wt=c.useRef(),fr=c.useRef(!1),hr=c.useCallback(E=>{const b=we.current,T=Z==null?void 0:Z.current;if(b===null||E.target!==b&&E.target!==T)return;fr.current=!0;const P=E.clientX,L=E.clientY;if(E.target===T&&T!==null){const ge=T.getBoundingClientRect();if(P>ge.right||L>ge.bottom)return}const V=xe(b,P,L,E);Wt.current=V.location,V.isTouch&&(Dn.current=Date.now()),Rt.current!==V.isTouch&&et(V.isTouch),!(V.kind===kr&&Vt(b,V.location[0],P,L)!==void 0)&&(V.kind===Hn&&dr(V.group,V.bounds,V.localEventX,V.localEventY)!==void 0||(_==null||_(V),!V.isTouch&&Me!==!0&&Me!==V.kind&&V.button<3&&V.button!==1&&E.preventDefault()))},[Z,Me,xe,dr,Vt,_]);nn("pointerdown",hr,dt,!1);const dn=c.useRef(0),$n=c.useCallback(E=>{var nt,Ue;const b=dn.current;dn.current=Date.now();const T=we.current;if(fr.current=!1,D===void 0||T===null)return;const P=Z==null?void 0:Z.current,L=E.target!==T&&E.target!==P,V=E.clientX,ge=E.clientY,Ge=E.pointerType==="mouse"?E.button<3:!0;let ke=xe(T,V,ge,E);ke.isTouch&&Dn.current!==0&&Date.now()-Dn.current>500&&(ke={...ke,isLongTouch:!0}),b!==0&&Date.now()-b<(ke.isTouch?1e3:500)&&(ke={...ke,isDoubleClick:!0}),Rt.current!==ke.isTouch&&et(ke.isTouch),!L&&E.cancelable&&Ge&&E.preventDefault();const[Ht]=ke.location,Ie=Vt(T,Ht,V,ge);if(ke.kind===kr&&Ie!==void 0){(ke.button!==0||((nt=Wt.current)==null?void 0:nt[0])!==Ht||((Ue=Wt.current)==null?void 0:Ue[1])!==-1)&&D(ke,!0);return}else if(ke.kind===Hn){const Ve=dr(ke.group,ke.bounds,ke.localEventX,ke.localEventY);if(Ve!==void 0){ke.button===0&&Ve.onClick(ke);return}}D(ke,L)},[D,Z,xe,Vt,dr]);nn("pointerup",$n,dt,!1);const fn=c.useCallback(E=>{var Ht,Ie;const b=we.current;if(b===null)return;const T=Z==null?void 0:Z.current,P=E.target!==b&&E.target!==T;let L,V,ge=!0;E instanceof MouseEvent?(L=E.clientX,V=E.clientY,ge=E.button<3):(L=E.changedTouches[0].clientX,V=E.changedTouches[0].clientY);const Ge=xe(b,L,V,E);Rt.current!==Ge.isTouch&&et(Ge.isTouch),!P&&E.cancelable&&ge&&E.preventDefault();const[ke]=Ge.location;if(Ge.kind===kr){const nt=Vt(b,ke,L,V);nt!==void 0&&Ge.button===0&&((Ht=Wt.current)==null?void 0:Ht[0])===ke&&((Ie=Wt.current)==null?void 0:Ie[1])===-1&&(nt.area==="menu"?y==null||y(ke,nt.bounds):nt.area==="indicator"&&(x==null||x(ke,nt.bounds)))}},[Z,xe,Vt,y,x]);nn("click",fn,dt,!1);const gr=c.useCallback(E=>{const b=we.current,T=Z==null?void 0:Z.current;if(b===null||E.target!==b&&E.target!==T||J===void 0)return;const P=xe(b,E.clientX,E.clientY,E);J(P,()=>{E.cancelable&&E.preventDefault()})},[Z,xe,J]);nn("contextmenu",gr,(Z==null?void 0:Z.current)??null,!1);const qn=c.useCallback(E=>{st.current=new Ei(E.map(b=>b.item)),an.current=E,cn.current(),st.current=void 0},[]),Ee=c.useMemo(()=>new vC(qn),[qn]),Tr=c.useRef(Ee);Tr.current=Ee,c.useLayoutEffect(()=>{const E=Tr.current;if(Yt===void 0||Yt[1]<0){E.setHovered(Yt);return}const b=p(Yt,!0),T=qe(b),P=T===void 0&&b.kind===ue.Custom||(T==null?void 0:T.needsHover)!==void 0&&(typeof T.needsHover=="boolean"?T.needsHover:T.needsHover(b));E.setHovered(P?Yt:void 0)},[p,qe,Yt]);const Dr=c.useRef(),rn=c.useCallback(E=>{var Ge;const b=we.current;if(b===null)return;const T=Z==null?void 0:Z.current,P=E.target!==b&&E.target!==T,L=xe(b,E.clientX,E.clientY,E);if(L.kind!=="out-of-bounds"&&P&&!fr.current&&!L.isTouch)return;const V=(ke,Ht)=>{En(Ie=>Ie===ke||(Ie==null?void 0:Ie[0][0])===(ke==null?void 0:ke[0][0])&&(Ie==null?void 0:Ie[0][1])===(ke==null?void 0:ke[0][1])&&((Ie==null?void 0:Ie[1][0])===(ke==null?void 0:ke[1][0])&&(Ie==null?void 0:Ie[1][1])===(ke==null?void 0:ke[1][1])||!Ht)?Ie:ke)};if(!ru(L,Dr.current))Dt(void 0),ee==null||ee(L),V(L.kind===Hi?void 0:[L.location,[L.localEventX,L.localEventY]],!0),Dr.current=L;else if(L.kind==="cell"||L.kind===kr||L.kind===Hn){let ke=!1,Ht=!0;if(L.kind==="cell"){const nt=p(L.location);Ht=((Ge=qe(nt))==null?void 0:Ge.needsHoverPosition)??nt.kind===ue.Custom,ke=Ht}else ke=!0;const Ie=[L.location,[L.localEventX,L.localEventY]];V(Ie,Ht),vn.current=Ie,ke&&wn(new Ei([L.location]))}const ge=L.location[0]>=(de?0:1);kt(L.kind===kr&&L.isEdge&&ge&&ot===!0),So(L.kind==="cell"&&L.isFillHandle),fe==null||fe(E),X(L)},[Z,xe,de,ot,fe,X,ee,p,qe,wn]);nn("pointermove",rn,dt,!0);const Yr=c.useCallback(E=>{const b=we.current;if(b===null)return;let T,P;A.current!==void 0&&(T=xt(b,A.current.cell[0],A.current.cell[1]),P=A.current.cell),te==null||te({bounds:T,stopPropagation:()=>E.stopPropagation(),preventDefault:()=>E.preventDefault(),cancel:()=>{},ctrlKey:E.ctrlKey,metaKey:E.metaKey,shiftKey:E.shiftKey,altKey:E.altKey,key:E.key,keyCode:E.keyCode,rawEvent:E,location:P})},[te,A,xt]),hn=c.useCallback(E=>{const b=we.current;if(b===null)return;let T,P;A.current!==void 0&&(T=xt(b,A.current.cell[0],A.current.cell[1]),P=A.current.cell),q==null||q({bounds:T,stopPropagation:()=>E.stopPropagation(),preventDefault:()=>E.preventDefault(),cancel:()=>{},ctrlKey:E.ctrlKey,metaKey:E.metaKey,shiftKey:E.shiftKey,altKey:E.altKey,key:E.key,keyCode:E.keyCode,rawEvent:E,location:P})},[q,A,xt]),mr=c.useCallback(E=>{if(we.current=E,ie!==void 0&&(ie.current=E),Se!=null&&Se.eventTarget)It.current=Se.eventTarget;else if(E===null)It.current=window;else{const b=E.getRootNode();b===document&&(It.current=window),It.current=b}},[ie,Se==null?void 0:Se.eventTarget]),qr=c.useCallback(E=>{const b=we.current;if(b===null||Me===!1||se){E.preventDefault();return}let T,P;const L=xe(b,E.clientX,E.clientY);if(Me!==!0&&L.kind!==Me){E.preventDefault();return}const V=(nt,Ue)=>{T=nt,P=Ue};let ge,Ge,ke;const Ht=(nt,Ue,Ve)=>{ge=nt,Ge=Ue,ke=Ve};let Ie=!1;if(re==null||re({...L,setData:V,setDragImage:Ht,preventDefault:()=>Ie=!0,defaultPrevented:()=>Ie}),!Ie&&T!==void 0&&P!==void 0&&E.dataTransfer!==null)if(E.dataTransfer.setData(T,P),E.dataTransfer.effectAllowed="copyLink",ge!==void 0&&Ge!==void 0&&ke!==void 0)E.dataTransfer.setDragImage(ge,Ge,ke);else{const[nt,Ue]=L.location;if(Ue!==void 0){const Ve=document.createElement("canvas"),Be=xt(b,nt,Ue);pn(Be!==void 0);const at=Math.ceil(window.devicePixelRatio??1);Ve.width=Be.width*at,Ve.height=Be.height*at;const At=Ve.getContext("2d");At!==null&&(At.scale(at,at),At.textBaseline="middle",Ue===-1?(At.font=je.headerFontFull,At.fillStyle=je.bgHeader,At.fillRect(0,0,Ve.width,Ve.height),Uc(At,0,0,Be.width,Be.height,ht[nt],!1,je,!1,void 0,void 0,!1,0,lt,ve,!1)):(At.font=je.baseFontFull,At.fillStyle=je.bgCell,At.fillRect(0,0,Ve.width,Ve.height),zc(At,p([nt,Ue]),0,Ue,!1,!1,0,0,Be.width,Be.height,!1,je,je.bgCell,He,lt,1,void 0,!1,0,void 0,void 0,void 0,Ln,qe,()=>{}))),Ve.style.left="-100%",Ve.style.position="absolute",Ve.style.width=`${Be.width}px`,Ve.style.height=`${Be.height}px`,document.body.append(Ve),E.dataTransfer.setDragImage(Ve,Be.width/2,Be.height/2),window.setTimeout(()=>{Ve.remove()},0)}}else E.preventDefault()},[Me,se,xe,re,xt,je,ht,lt,ve,p,He,Ln,qe]);nn("dragstart",qr,(Z==null?void 0:Z.current)??null,!1,!1);const Vn=c.useRef(),Io=c.useCallback(E=>{const b=we.current;if(pe!==void 0&&E.preventDefault(),b===null||Fe===void 0)return;const T=xe(b,E.clientX,E.clientY),[P,L]=T.location,V=P-(de?0:1),[ge,Ge]=Vn.current??[];(ge!==V||Ge!==L)&&(Vn.current=[V,L],Fe([V,L],E.dataTransfer))},[de,xe,Fe,pe]);nn("dragover",Io,(Z==null?void 0:Z.current)??null,!1,!1);const Vr=c.useCallback(()=>{Vn.current=void 0,$e==null||$e()},[$e]);nn("dragend",Vr,(Z==null?void 0:Z.current)??null,!1,!1);const gn=c.useCallback(E=>{const b=we.current;if(b===null||pe===void 0)return;E.preventDefault();const T=xe(b,E.clientX,E.clientY),[P,L]=T.location,V=P-(de?0:1);pe([V,L],E.dataTransfer)},[de,xe,pe]);nn("drop",gn,(Z==null?void 0:Z.current)??null,!1,!1);const An=c.useCallback(()=>{Ke==null||Ke()},[Ke]);nn("dragleave",An,(Z==null?void 0:Z.current)??null,!1,!1);const Jt=c.useRef(A);Jt.current=A;const $=c.useRef(null),gt=c.useCallback(E=>{var b;we.current===null||!we.current.contains(document.activeElement)||(E===null&&Jt.current.current!==void 0?(b=ie==null?void 0:ie.current)==null||b.focus({preventScroll:!0}):E!==null&&E.focus({preventScroll:!0}),$.current=E)},[ie]);c.useImperativeHandle(t,()=>({focus:()=>{var b;const E=$.current;E===null||!document.contains(E)?(b=ie==null?void 0:ie.current)==null||b.focus({preventScroll:!0}):E.focus({preventScroll:!0})},getBounds:(E,b)=>{if(!(ie===void 0||ie.current===null))return xt(ie.current,E??0,b??-1)},damage:Ur,getMouseArgsForPosition:(E,b,T)=>{if(!(ie===void 0||ie.current===null))return xe(ie.current,E,b,T)}}),[ie,Ur,xt,xe]);const Nt=c.useRef(),Eo=Dp(()=>{var Ge,ke,Ht;if(n<50||(Se==null?void 0:Se.disableAccessibilityTree)===!0)return null;let E=Ds(ht,Re,n,he,tt);const b=de?0:-1;!de&&((Ge=E[0])==null?void 0:Ge.sourceIndex)===0&&(E=E.slice(1));const[T,P]=((ke=A.current)==null?void 0:ke.cell)??[],L=(Ht=A.current)==null?void 0:Ht.range,V=E.map(Ie=>Ie.sourceIndex),ge=Hr(s,Math.min(m,s+o));return T!==void 0&&P!==void 0&&!(V.includes(T)&&ge.includes(P))&>(null),c.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":m+1,"aria-multiselectable":"true","aria-colcount":ht.length+b},c.createElement("thead",{role:"rowgroup"},c.createElement("tr",{role:"row","aria-rowindex":1},E.map(Ie=>c.createElement("th",{role:"columnheader","aria-selected":A.columns.hasIndex(Ie.sourceIndex),"aria-colindex":Ie.sourceIndex+1+b,tabIndex:-1,onFocus:nt=>{if(nt.target!==$.current)return De==null?void 0:De([Ie.sourceIndex,-1])},key:Ie.sourceIndex},Ie.title)))),c.createElement("tbody",{role:"rowgroup"},ge.map(Ie=>c.createElement("tr",{role:"row","aria-selected":A.rows.hasIndex(Ie),key:Ie,"aria-rowindex":Ie+2},E.map(nt=>{const Ue=nt.sourceIndex,Ve=er(Ue,Ie),Be=T===Ue&&P===Ie,at=L!==void 0&&Ue>=L.x&&Ue<L.x+L.width&&Ie>=L.y&&Ie<L.y+L.height,At=`glide-cell-${Ue}-${Ie}`,_n=[Ue,Ie],Pn=p(_n,!0);return c.createElement("td",{key:Ve,role:"gridcell","aria-colindex":Ue+1+b,"aria-selected":at,"aria-readonly":lo(Pn)||!so(Pn),id:At,"data-testid":At,onClick:()=>{const Mt=ie==null?void 0:ie.current;if(Mt!=null)return te==null?void 0:te({bounds:xt(Mt,Ue,Ie),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:_n})},onFocusCapture:Mt=>{var _t,yt;if(!(Mt.target===$.current||((_t=Nt.current)==null?void 0:_t[0])===Ue&&((yt=Nt.current)==null?void 0:yt[1])===Ie))return Nt.current=_n,De==null?void 0:De(_n)},ref:Be?gt:void 0,tabIndex:-1},kC(Pn,qe))})))))},[n,ht,Re,he,tt,m,s,o,A,gt,p,ie,te,xt,De],200),Jn=W===0||!F?0:Re>W?1:Rn(-tt/100,0,1),To=-s*32+mt,Fn=B?Rn(-To/100,0,1):0,Do=c.useMemo(()=>{if(!Jn&&!Fn)return null;const E={position:"absolute",top:0,left:Bn,width:n-Bn,height:r,opacity:Jn,pointerEvents:"none",transition:We?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},b={position:"absolute",top:jt,left:0,width:n,height:r,opacity:Fn,pointerEvents:"none",transition:ce?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return c.createElement(c.Fragment,null,Jn>0&&c.createElement("div",{id:"shadow-x",style:E}),Fn>0&&c.createElement("div",{id:"shadow-y",style:b}))},[Jn,Fn,Bn,n,We,jt,r,ce]),G=c.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return c.createElement(c.Fragment,null,c.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:Yr,onKeyUp:hn,onFocus:M,onBlur:U,ref:mr,style:ur},Eo),c.createElement("canvas",{ref:Ot,style:G}),Do)},RC=c.memo(c.forwardRef(SC));function Lo(e,t,n,r){return Rn(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}const MC=e=>{const[t,n]=c.useState(),[r,o]=c.useState(),[i,a]=c.useState(),[s,l]=c.useState(),[u,d]=c.useState(!1),[h,m]=c.useState(),[p,g]=c.useState(),[y,x]=c.useState(),[C,w]=c.useState(!1),[M,U]=c.useState(),{onHeaderMenuClick:z,onHeaderIndicatorClick:A,getCellContent:W,onColumnMoved:J,onColumnResize:S,onColumnResizeStart:F,onColumnResizeEnd:B,gridRef:N,maxColumnWidth:_,minColumnWidth:D,onRowMoved:fe,lockColumns:X,onColumnProposeMove:ee,onMouseDown:he,onMouseUp:de,onItemHovered:te,onDragStart:q,canvasRef:Ce}=e,ie=(S??B??F)!==void 0,{columns:re,selection:$e}=e,Z=$e.columns,se=c.useCallback(oe=>{const[ve,De]=oe.location;i!==void 0&&s!==ve&&ve>=X?(d(!0),l(ve)):p!==void 0&&De!==void 0?(w(!0),x(Math.max(0,De))):r===void 0&&!u&&!C&&(te==null||te(oe))},[i,p,s,te,X,r,u,C]),me=J!==void 0,ze=c.useCallback(oe=>{var ve;if(oe.button===0){const[De,Fe]=oe.location;if(oe.kind==="out-of-bounds"&&oe.isEdge&&ie){const pe=(ve=N==null?void 0:N.current)==null?void 0:ve.getBounds(re.length-1,-1);pe!==void 0&&(n(pe.x),o(re.length-1))}else if(oe.kind==="header"&&De>=X){const pe=Ce==null?void 0:Ce.current;if(oe.isEdge&&ie&&pe){n(oe.bounds.x),o(De);const Ye=pe.getBoundingClientRect().width/pe.offsetWidth,We=oe.bounds.width/Ye;F==null||F(re[De],We,De,We+(re[De].growOffset??0))}else oe.kind==="header"&&me&&(m(oe.bounds.x),a(De))}else oe.kind==="cell"&&X>0&&De===0&&Fe!==void 0&&fe!==void 0&&(U(oe.bounds.y),g(Fe))}he==null||he(oe)},[he,ie,X,fe,N,re,me,F,Ce]),Me=c.useCallback((oe,ve)=>{u||C||z==null||z(oe,ve)},[u,C,z]),ot=c.useCallback((oe,ve)=>{u||C||A==null||A(oe,ve)},[u,C,A]),it=c.useRef(-1),Ae=c.useCallback(()=>{it.current=-1,g(void 0),x(void 0),U(void 0),w(!1),a(void 0),l(void 0),m(void 0),d(!1),o(void 0),n(void 0)},[]),Oe=c.useCallback((oe,ve)=>{if(oe.button===0){if(r!==void 0){if((Z==null?void 0:Z.hasIndex(r))===!0)for(const Fe of Z){if(Fe===r)continue;const pe=re[Fe],Ke=Lo(pe,it.current,D,_);S==null||S(pe,Ke,Fe,Ke+(pe.growOffset??0))}const De=Lo(re[r],it.current,D,_);if(B==null||B(re[r],De,r,De+(re[r].growOffset??0)),Z.hasIndex(r))for(const Fe of Z){if(Fe===r)continue;const pe=re[Fe],Ke=Lo(pe,it.current,D,_);B==null||B(pe,Ke,Fe,Ke+(pe.growOffset??0))}}Ae(),i!==void 0&&s!==void 0&&(ee==null?void 0:ee(i,s))!==!1&&(J==null||J(i,s)),p!==void 0&&y!==void 0&&(fe==null||fe(p,y))}de==null||de(oe,ve)},[de,r,i,s,p,y,Z,B,re,D,_,S,J,fe,Ae,ee]),je=c.useMemo(()=>{if(!(i===void 0||s===void 0)&&i!==s&&(ee==null?void 0:ee(i,s))!==!1)return{src:i,dest:s}},[i,s,ee]),vt=c.useCallback(oe=>{const ve=Ce==null?void 0:Ce.current;if(i!==void 0&&h!==void 0)Math.abs(oe.clientX-h)>20&&d(!0);else if(p!==void 0&&M!==void 0)Math.abs(oe.clientY-M)>20&&w(!0);else if(r!==void 0&&t!==void 0&&ve){const Fe=ve.getBoundingClientRect().width/ve.offsetWidth,pe=(oe.clientX-t)/Fe,Ke=re[r],Ye=Lo(Ke,pe,D,_);if(S==null||S(Ke,Ye,r,Ye+(Ke.growOffset??0)),it.current=pe,(Z==null?void 0:Z.first())===r)for(const We of Z){if(We===r)continue;const ce=re[We],Se=Lo(ce,it.current,D,_);S==null||S(ce,Se,We,Se+(ce.growOffset??0))}}},[i,h,p,M,r,t,re,D,_,S,Z,Ce]),wt=c.useCallback((oe,ve)=>{if(p===void 0||y===void 0)return W(oe,ve);let[De,Fe]=oe;return Fe===y?Fe=p:(Fe>y&&(Fe-=1),Fe>=p&&(Fe+=1)),W([De,Fe],ve)},[p,y,W]),ut=c.useCallback(oe=>{q==null||q(oe),oe.defaultPrevented()||Ae()},[Ae,q]);return c.createElement(RC,{accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,enableGroups:e.enableGroups,eventTargetRef:e.eventTargetRef,experimental:e.experimental,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,headerIcons:e.headerIcons,height:e.height,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,resizeColumn:r,isDraggable:e.isDraggable,isFilling:e.isFilling,isFocused:e.isFocused,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDrop:e.onDrop,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,resizeIndicator:e.resizeIndicator,verticalBorder:e.verticalBorder,width:e.width,getCellContent:wt,isResizing:r!==void 0,onHeaderMenuClick:Me,onHeaderIndicatorClick:ot,isDragging:u,onItemHovered:se,onDragStart:ut,onMouseDown:ze,allowResize:ie,onMouseUp:Oe,dragAndDropState:je,onMouseMoveRaw:vt,ref:N})};function IC(e){const t=c.useRef(null),[n,r]=c.useState({width:e==null?void 0:e[0],height:e==null?void 0:e[1]});return c.useLayoutEffect(()=>{const o=a=>{for(const s of a){const{width:l,height:u}=s&&s.contentRect||{};r(d=>d.width===l&&d.height===u?d:{width:l,height:u})}},i=new window.ResizeObserver(o);return t.current&&i.observe(t.current,void 0),()=>{i.disconnect()}},[t.current]),{ref:t,...n}}const EC=(e,t,n)=>{const r=c.useRef(null),o=c.useRef(null),i=c.useRef(null),a=c.useRef(0),s=c.useRef(t);s.current=t;const l=n.current;c.useEffect(()=>{const u=()=>{var m,p;if(o.current===!1&&l!==null){const g=[l.scrollLeft,l.scrollTop];if(((m=i.current)==null?void 0:m[0])===g[0]&&((p=i.current)==null?void 0:p[1])===g[1])if(a.current>10){i.current=null,o.current=null;return}else a.current++;else a.current=0,s.current(g[0],g[1]),i.current=g;r.current=window.setTimeout(u,8.333333333333334)}},d=()=>{o.current=!0,i.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},h=m=>{m.touches.length===0&&(o.current=!1,a.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(e&&l!==null){const m=l;return m.addEventListener("touchstart",d),m.addEventListener("touchend",h),()=>{m.removeEventListener("touchstart",d),m.removeEventListener("touchend",h),r.current!==null&&window.clearTimeout(r.current)}}},[e,l])},TC=()=>e=>e.isSafari?"scroll":"auto",DC=Rr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[TC()]}}),$C=33554400,AC=5e6;function FC(e){const[t,n]=c.useState(!1),r=typeof window>"u"?null:window,o=c.useRef(0);return nn("touchstart",c.useCallback(()=>{window.clearTimeout(o.current),n(!0)},[]),r,!0,!1),nn("touchend",c.useCallback(i=>{i.touches.length===0&&(o.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}const _C=e=>{var $e,Z;const{children:t,clientHeight:n,scrollHeight:r,scrollWidth:o,update:i,draggable:a,className:s,preventDiagonalScrolling:l=!1,paddingBottom:u=0,paddingRight:d=0,rightElement:h,rightElementProps:m,kineticScrollPerfHack:p=!1,scrollRef:g,initialSize:y}=e,x=[],C=(m==null?void 0:m.sticky)??!1,w=(m==null?void 0:m.fill)??!1,M=c.useRef(0),U=c.useRef(0),z=c.useRef(null),A=typeof window>"u"?1:window.devicePixelRatio,W=c.useRef(A);c.useEffect(()=>{if(W.current!==A){M.current=0,U.current=0,W.current=A;const se=z.current;se!==null&&fe.current(se.scrollLeft,se.scrollTop)}},[A]);const J=c.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),S=c.useRef(null),F=FC(200),[B,N]=c.useState(!0),_=c.useRef(0);c.useLayoutEffect(()=>{if(!B||F||J.current.lockDirection===void 0)return;const se=z.current;if(se===null)return;const[me,ze]=J.current.lockDirection;me!==void 0?se.scrollLeft=me:ze!==void 0&&(se.scrollTop=ze),J.current.lockDirection=void 0},[F,B]);const D=c.useCallback((se,me)=>{var De;const ze=z.current;if(ze===null)return;me=me??ze.scrollTop,se=se??ze.scrollLeft;const Me=J.current.scrollTop,ot=J.current.scrollLeft,it=se-ot,Ae=me-Me;F&&it!==0&&Ae!==0&&(Math.abs(it)>3||Math.abs(Ae)>3)&&l&&J.current.lockDirection===void 0&&(J.current.lockDirection=Math.abs(it)<Math.abs(Ae)?[ot,void 0]:[void 0,Me]);const Oe=J.current.lockDirection;se=(Oe==null?void 0:Oe[0])??se,me=(Oe==null?void 0:Oe[1])??me,J.current.scrollLeft=se,J.current.scrollTop=me;const je=ze.clientWidth,vt=ze.clientHeight,wt=me,ut=U.current-wt,oe=ze.scrollHeight-vt;U.current=wt;let ve;if(oe>0&&r>ze.scrollHeight+5)if(Math.abs(ut)>2e3||wt===0||wt===oe){const Fe=Math.max(0,Math.min(1,wt/oe)),pe=r-vt;ve=Fe*pe,M.current=ve}else M.current-=ut,ve=M.current;else ve=wt,M.current=ve;ve=Math.max(0,Math.min(ve,r-vt)),M.current=ve,Oe!==void 0&&(window.clearTimeout(_.current),N(!1),_.current=window.setTimeout(()=>N(!0),200)),i({x:se,y:ve,width:je-d,height:vt-u,paddingRight:((De=S.current)==null?void 0:De.clientWidth)??0})},[u,d,r,i,l,F]);EC(p&&ji.value,D,z);const fe=c.useRef(D);fe.current=D;const X=c.useRef(),ee=c.useRef(!1);c.useLayoutEffect(()=>{ee.current?D():ee.current=!0},[D,u,d]);const he=c.useCallback(se=>{z.current=se,g!==void 0&&(g.current=se)},[g]);let de=0,te=0;const q=Math.min(r,$C);for(x.push(c.createElement("div",{key:de++,style:{width:o,height:0}}));te<q;){const se=Math.min(AC,q-te);x.push(c.createElement("div",{key:de++,style:{width:0,height:se}})),te+=se}const{ref:Ce,width:ie,height:re}=IC(y);return typeof window<"u"&&((($e=X.current)==null?void 0:$e.height)!==re||((Z=X.current)==null?void 0:Z.width)!==ie)&&(window.setTimeout(()=>fe.current(),0),X.current={width:ie,height:re}),(ie??0)===0||(re??0)===0?c.createElement("div",{ref:Ce}):c.createElement("div",{ref:Ce},c.createElement(DC,{isSafari:ji.value},c.createElement("div",{className:"dvn-underlay"},t),c.createElement("div",{ref:he,style:X.current,draggable:a,onDragStart:se=>{a||(se.stopPropagation(),se.preventDefault())},className:"dvn-scroller "+(s??""),onScroll:()=>D()},c.createElement("div",{className:"dvn-scroll-inner"+(h===void 0?" dvn-hidden":"")},c.createElement("div",{className:"dvn-stack"},x),h!==void 0&&c.createElement(c.Fragment,null,!w&&c.createElement("div",{className:"dvn-spacer"}),c.createElement("div",{ref:S,style:{height:re,maxHeight:n-Math.ceil(A%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:d,flexGrow:w?1:void 0,right:C?d??0:void 0,pointerEvents:"auto"}},h))))))},PC=e=>{const{columns:t,rows:n,rowHeight:r,headerHeight:o,groupHeaderHeight:i,enableGroups:a,freezeColumns:s,experimental:l,nonGrowWidth:u,clientSize:d,className:h,onVisibleRegionChanged:m,scrollRef:p,preventDiagonalScrolling:g,rightElement:y,rightElementProps:x,overscrollX:C,overscrollY:w,initialSize:M,smoothScrollX:U=!1,smoothScrollY:z=!1,isDraggable:A}=e,{paddingRight:W,paddingBottom:J}=l??{},[S,F]=d,B=c.useRef(),N=c.useRef(),_=c.useRef(),D=c.useRef(),fe=u+Math.max(0,C??0);let X=a?o+i:o;if(typeof r=="number")X+=n*r;else for(let te=0;te<n;te++)X+=r(te);w!==void 0&&(X+=w);const ee=c.useRef(),he=c.useCallback(()=>{var ot,it;if(ee.current===void 0)return;const te={...ee.current};let q=0,Ce=te.x<0?-te.x:0,ie=0,re=0;te.x=te.x<0?0:te.x;let $e=0;for(let Ae=0;Ae<s;Ae++)$e+=t[Ae].width;for(const Ae of t){const Oe=q-$e;if(te.x>=Oe+Ae.width)q+=Ae.width,re++,ie++;else if(te.x>Oe)q+=Ae.width,U?Ce+=Oe-te.x:re++,ie++;else if(te.x+te.width>Oe)q+=Ae.width,ie++;else break}let Z=0,se=0,me=0;if(typeof r=="number")z?(se=Math.floor(te.y/r),Z=se*r-te.y):se=Math.ceil(te.y/r),me=Math.ceil(te.height/r)+se,Z<0&&me++;else{let Ae=0;for(let Oe=0;Oe<n;Oe++){const je=r(Oe),vt=Ae+(z?0:je/2);if(te.y>=Ae+je)Ae+=je,se++,me++;else if(te.y>vt)Ae+=je,z?Z+=vt-te.y:se++,me++;else if(te.y+te.height>je/2+Ae)Ae+=je,me++;else break}}se=Math.max(0,Math.min(se,n-1)),me=Math.max(se,Math.min(me,n));const ze={x:re,y:se,width:ie-re,height:me-se},Me=B.current;(Me===void 0||Me.y!==ze.y||Me.x!==ze.x||Me.height!==ze.height||Me.width!==ze.width||N.current!==Ce||_.current!==Z||te.width!==((ot=D.current)==null?void 0:ot[0])||te.height!==((it=D.current)==null?void 0:it[1]))&&(m==null||m({x:re,y:se,width:ie-re,height:me-se},te.width,te.height,te.paddingRight??0,Ce,Z),B.current=ze,N.current=Ce,_.current=Z,D.current=[te.width,te.height])},[t,r,n,m,s,U,z]),de=c.useCallback(te=>{ee.current=te,he()},[he]);return c.useEffect(()=>{he()},[he]),c.createElement(_C,{scrollRef:p,className:h,kineticScrollPerfHack:l==null?void 0:l.kineticScrollPerfHack,preventDiagonalScrolling:g,draggable:A===!0||typeof A=="string",scrollWidth:fe+(W??0),scrollHeight:X+(J??0),clientHeight:F,rightElement:y,paddingBottom:J,paddingRight:W,rightElementProps:x,update:de,initialSize:M},c.createElement(MC,{eventTargetRef:p,width:S,height:F,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onHeaderIndicatorClick:e.onHeaderIndicatorClick,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,onColumnProposeMove:e.onColumnProposeMove,verticalBorder:e.verticalBorder,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,resizeIndicator:e.resizeIndicator}))},OC=Rr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),jC=c.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},c.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),NC=c.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},c.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),HC=c.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},c.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),BC=10,LC=e=>{const{canvasRef:t,cellYOffset:n,rows:r,columns:o,searchInputRef:i,searchValue:a,searchResults:s,onSearchValueChange:l,getCellsForSelection:u,onSearchResultsChanged:d,showSearch:h=!1,onSearchClose:m}=e,[p]=c.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[g,y]=c.useState(""),x=a??g,C=c.useCallback(q=>{y(q),l==null||l(q)},[l]),[w,M]=c.useState(),U=c.useRef(w);U.current=w,c.useEffect(()=>{s!==void 0&&(s.length>0?M(q=>({rowsSearched:r,results:s.length,selectedIndex:(q==null?void 0:q.selectedIndex)??-1})):M(void 0))},[r,s]);const z=c.useRef();z.current===void 0&&(z.current=new AbortController);const A=c.useRef(),[W,J]=c.useState([]),S=s??W,F=c.useCallback(()=>{A.current!==void 0&&(window.cancelAnimationFrame(A.current),A.current=void 0),z.current!==void 0&&z.current.abort(),z.current=new AbortController},[]),B=c.useRef(n);B.current=n;const N=c.useCallback(q=>{const Ce=new RegExp(q.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let ie=B.current,re=Math.min(10,r),$e=0;M(void 0),J([]);const Z=[],se=async()=>{var wt;if(u===void 0)return;const me=performance.now(),ze=r-$e;let Me=u({x:0,y:ie,width:o.length,height:Math.min(re,ze,r-ie)},z.current.signal);typeof Me=="function"&&(Me=await Me());let ot=!1;for(const[ut,oe]of Me.entries())for(const[ve,De]of oe.entries()){let Fe;switch(De.kind){case ue.Text:case ue.Number:Fe=De.displayData;break;case ue.Uri:case ue.Markdown:Fe=De.data;break;case ue.Boolean:Fe=typeof De.data=="boolean"?De.data.toString():void 0;break;case ue.Image:case ue.Bubble:Fe=De.data.join("🐳");break;case ue.Custom:Fe=De.copyData;break}Fe!==void 0&&Ce.test(Fe)&&(Z.push([ve,ut+ie]),ot=!0)}const it=performance.now();ot&&J([...Z]),$e+=Me.length,pn($e<=r);const Ae=((wt=U.current)==null?void 0:wt.selectedIndex)??-1;M({results:Z.length,rowsSearched:$e,selectedIndex:Ae}),d==null||d(Z,Ae),ie+re>=r?ie=0:ie+=re;const Oe=it-me,je=Math.max(Oe,1),vt=BC/je;re=Math.ceil(re*vt),$e<r&&Z.length<1e3&&(A.current=window.requestAnimationFrame(se))};F(),A.current=window.requestAnimationFrame(se)},[F,o.length,u,d,r]),_=c.useCallback(()=>{var q;m==null||m(),M(void 0),J([]),d==null||d([],-1),F(),(q=t==null?void 0:t.current)==null||q.focus()},[F,t,m,d]),D=c.useCallback(q=>{C(q.target.value),s===void 0&&(q.target.value===""?(M(void 0),J([]),F()):N(q.target.value))},[N,F,C,s]);c.useEffect(()=>{i.current!==null&&(C(""),M(void 0),W.length>0&&(J([]),d==null||d([],-1)),h?i.current.focus({preventScroll:!0}):F())},[h,i]);const fe=c.useCallback(q=>{var ie;if((ie=q==null?void 0:q.stopPropagation)==null||ie.call(q),w===void 0||w.results===0)return;const Ce=(w.selectedIndex+1)%w.results;M({...w,selectedIndex:Ce}),d==null||d(S,Ce)},[w,d,S]),X=c.useCallback(q=>{var ie;if((ie=q==null?void 0:q.stopPropagation)==null||ie.call(q),w===void 0||w.results===0)return;let Ce=(w.selectedIndex-1)%w.results;Ce<0&&(Ce+=w.results),M({...w,selectedIndex:Ce}),d==null||d(S,Ce)},[d,S,w]),ee=c.useCallback(q=>{(q.ctrlKey||q.metaKey)&&q.nativeEvent.code==="KeyF"||q.key==="Escape"?(_(),q.stopPropagation(),q.preventDefault()):q.key==="Enter"&&(q.shiftKey?X():fe())},[_,fe,X]);c.useEffect(()=>()=>{F()},[F]);const[he,de]=c.useState(!1);c.useEffect(()=>{if(h)de(!0);else{const q=setTimeout(()=>de(!1),150);return()=>clearTimeout(q)}},[h]);const te=c.useMemo(()=>{if(!h&&!he)return null;let q;w!==void 0&&(q=w.results>=1e3?"over 1000":`${w.results} result${w.results!==1?"s":""}`,w.selectedIndex>=0&&(q=`${w.selectedIndex+1} of ${q}`));const Ce=$e=>{$e.stopPropagation()},re={width:`${r>0?Math.floor(((w==null?void 0:w.rowsSearched)??0)/r*100):0}%`};return c.createElement(OC,{className:"gdg-search-bar"+(h?"":" out"),onMouseDown:Ce,onMouseMove:Ce,onMouseUp:Ce,onClick:Ce},c.createElement("div",{className:"gdg-search-bar-inner"},c.createElement("input",{id:p,"aria-hidden":!h,"data-testid":"search-input",ref:i,onChange:D,value:x,tabIndex:h?void 0:-1,onKeyDownCapture:ee}),c.createElement("button",{type:"button","aria-label":"Previous Result","aria-hidden":!h,tabIndex:h?void 0:-1,onClick:X,disabled:((w==null?void 0:w.results)??0)===0},jC),c.createElement("button",{type:"button","aria-label":"Next Result","aria-hidden":!h,tabIndex:h?void 0:-1,onClick:fe,disabled:((w==null?void 0:w.results)??0)===0},NC),m!==void 0&&c.createElement("button",{type:"button","aria-label":"Close Search","aria-hidden":!h,"data-testid":"search-close-button",tabIndex:h?void 0:-1,onClick:_},HC)),w!==void 0?c.createElement(c.Fragment,null,c.createElement("div",{className:"gdg-search-status"},c.createElement("div",{"data-testid":"search-result-area"},q)),c.createElement("div",{className:"gdg-search-progress",style:re})):c.createElement("div",{className:"gdg-search-status"},c.createElement("label",{htmlFor:p},"Type to search")))},[h,he,w,r,p,i,D,x,ee,X,fe,m,_]);return c.createElement(c.Fragment,null,c.createElement(PC,{prelightCells:S,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,className:e.className,clientSize:e.clientSize,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,nonGrowWidth:e.nonGrowWidth,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,initialSize:e.initialSize,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onHeaderIndicatorClick:e.onHeaderIndicatorClick,onMouseMove:e.onMouseMove,onVisibleRegionChanged:e.onVisibleRegionChanged,overscrollX:e.overscrollX,overscrollY:e.overscrollY,preventDiagonalScrolling:e.preventDiagonalScrolling,rightElement:e.rightElement,rightElementProps:e.rightElementProps,rowHeight:e.rowHeight,rows:e.rows,scrollRef:e.scrollRef,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,onColumnProposeMove:e.onColumnProposeMove,drawFocusRing:e.drawFocusRing,drawCell:e.drawCell,drawHeader:e.drawHeader,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,resizeIndicator:e.resizeIndicator}),te)};class zC extends c.PureComponent{constructor(){super(...arguments);Xe(this,"wrapperRef",c.createRef());Xe(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){const n=this.props.customEventTarget??document;n.addEventListener("pointerdown",this.clickOutside,!0),n.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){const n=this.props.customEventTarget??document;n.removeEventListener("pointerdown",this.clickOutside,!0),n.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,customEventTarget:o,...i}=this.props;return c.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const WC=()=>e=>Math.max(16,e.targetHeight-10),GC=Rr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[WC(),"px"]}}),UC=e=>{const{bounds:t,group:n,onClose:r,canvasBounds:o,onFinish:i}=e,[a,s]=zt.useState(n);return zt.createElement(zC,{style:{position:"absolute",left:t.x-o.left+1,top:t.y-o.top,width:t.width-2,height:t.height},className:"gdg-c1tqibwd",onClickOutside:r},zt.createElement(GC,{targetHeight:t.height,"data-testid":"group-rename-input",value:a,onBlur:r,onFocus:l=>l.target.setSelectionRange(0,a.length),onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"?i(a):l.key==="Escape"&&r()},autoFocus:!0}))};function XC(e,t){return e===void 0?!1:e.length>1&&e.startsWith("_")?Number.parseInt(e.slice(1))===t.keyCode:e.length===1&&e>="a"&&e<="z"?e.toUpperCase().codePointAt(0)===t.keyCode:e===t.key}function Ze(e,t,n){const r=ou(e,t);return r&&(n.didMatch=!0),r}function ou(e,t){if(e.length===0)return!1;if(e.includes("|")){const l=e.split("|");for(const u of l)if(ou(u,t))return!0;return!1}let n=!1,r=!1,o=!1,i=!1;const a=e.split("+"),s=a.pop();if(!XC(s,t))return!1;if(a[0]==="any")return!0;for(const l of a)switch(l){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":o=!0;break;case"meta":i=!0;break;case"primary":Ni.value?i=!0:n=!0;break}return t.altKey===o&&t.ctrlKey===n&&t.shiftKey===r&&t.metaKey===i}function KC(e,t,n,r,o,i,a){const s=zt.useCallback((d,h,m,p)=>{var M;(i==="cell"||i==="multi-cell")&&d!==void 0&&(d={...d,range:{x:d.cell[0],y:d.cell[1],width:1,height:1}}),!a&&d!==void 0&&d.range.width>1&&(d={...d,range:{...d.range,width:1,x:d.cell[0]}});const g=n==="mixed"&&(m||p==="drag")||n==="additive",y=(r==="mixed"||r==="additive")&&g,x=(o==="mixed"||o==="additive")&&g;let C={current:d===void 0?void 0:{...d,rangeStack:p==="drag"?((M=e.current)==null?void 0:M.rangeStack)??[]:[]},columns:y?e.columns:rt.empty(),rows:x?e.rows:rt.empty()};m&&(i==="multi-rect"||i==="multi-cell")&&C.current!==void 0&&e.current!==void 0&&(C={...C,current:{...C.current,rangeStack:[...e.current.rangeStack,e.current.range]}}),t(C,h)},[r,e,n,i,a,o,t]),l=zt.useCallback((d,h,m)=>{d=d??e.rows,h!==void 0&&(d=d.add(h));let p;if(o==="exclusive"&&d.length>0)p={current:void 0,columns:rt.empty(),rows:d};else{const g=m&&n==="mixed"||n==="additive",y=m&&r==="mixed"||r==="additive";p={current:g?e.current:void 0,columns:y?e.columns:rt.empty(),rows:d}}t(p,!1)},[r,e,n,o,t]),u=zt.useCallback((d,h,m)=>{d=d??e.columns,h!==void 0&&(d=d.add(h));let p;if(r==="exclusive"&&d.length>0)p={current:void 0,rows:rt.empty(),columns:d};else{const g=m&&n==="mixed"||n==="additive",y=m&&o==="mixed"||o==="additive";p={current:g?e.current:void 0,rows:y?e.rows:rt.empty(),columns:d}}t(p,!1)},[r,e,n,o,t]);return[s,l,u]}function YC(e,t,n,r,o){const i=c.useCallback(u=>{if(e===!0){const d=[];for(let h=u.y;h<u.y+u.height;h++){const m=[];for(let p=u.x;p<u.x+u.width;p++)p<0||h>=o?m.push({kind:ue.Loading,allowOverlay:!1}):m.push(t([p,h]));d.push(m)}return d}return(e==null?void 0:e(u,r.signal))??[]},[r.signal,t,e,o]),a=e!==void 0?i:void 0,s=c.useCallback(u=>{if(a===void 0)return[];const d={...u,x:u.x-n};if(d.x<0){d.x=0,d.width--;const h=a(d,r.signal);return typeof h=="function"?async()=>(await h()).map(m=>[{kind:ue.Loading,allowOverlay:!1},...m]):h.map(m=>[{kind:ue.Loading,allowOverlay:!1},...m])}return a(d,r.signal)},[r.signal,a,n]);return[e!==void 0?s:void 0,a]}function qC(e){if(e.copyData!==void 0)return{formatted:e.copyData,rawValue:e.copyData,format:"string",doNotEscape:!0};switch(e.kind){case ue.Boolean:return{formatted:e.data===!0?"TRUE":e.data===!1?"FALSE":e.data===Js?"INDETERMINATE":"",rawValue:e.data,format:"boolean"};case ue.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:"string"};case ue.Image:case ue.Bubble:return{formatted:e.data,rawValue:e.data,format:"string-array"};case ue.Drilldown:return{formatted:e.data.map(t=>t.text),rawValue:e.data.map(t=>t.text),format:"string-array"};case ue.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:"string"};case ue.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:"url"};case ue.Markdown:case ue.RowID:return{formatted:e.data,rawValue:e.data,format:"string"};case ue.Number:return{formatted:e.displayData,rawValue:e.data,format:"number"};case ue.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case ue.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Vo()}}function VC(e,t){return e.map((r,o)=>{const i=t[o];return r.map(a=>a.span!==void 0&&a.span[0]!==i?{formatted:"",rawValue:"",format:"string"}:qC(a))})}function _l(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,'""')}"`),e}function JC(e){var n;const t=[];for(const r of e){const o=[];for(const i of r)i.format==="url"?o.push(((n=i.rawValue)==null?void 0:n.toString())??""):i.format==="string-array"?o.push(i.formatted.map(a=>_l(a,!0)).join(",")):o.push(i.doNotEscape===!0?i.formatted:_l(i.formatted,!1));t.push(o.join(" "))}return t.join(`
|
|
6
|
-
`)}function xs(e){return e.replace(/\t/g," ").replace(/ {2,}/g,t=>"<span> </span>".repeat(t.length))}function Pl(e){return'"'+e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")+'"'}function ZC(e){return e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function QC(e){var n;const t=[];t.push('<style type="text/css"><!--br {mso-data-placement:same-cell;}--></style>',"<table><tbody>");for(const r of e){t.push("<tr>");for(const o of r){const i=`gdg-format="${o.format}"`;o.format==="url"?t.push(`<td ${i}><a href="${o.rawValue}">${xs(o.formatted)}</a></td>`):o.format==="string-array"?t.push(`<td ${i}><ol>${o.formatted.map((a,s)=>`<li gdg-raw-value=${Pl(o.rawValue[s])}>`+xs(a)+"</li>").join("")}</ol></td>`):t.push(`<td gdg-raw-value=${Pl(((n=o.rawValue)==null?void 0:n.toString())??"")} ${i}>${xs(o.formatted)}</td>`)}t.push("</tr>")}return t.push("</tbody></table>"),t.join("")}function ek(e,t){const n=VC(e,t),r=JC(n),o=QC(n);return{textPlain:r,textHtml:o}}function Ol(e){var a;const t=document.createElement("html");t.innerHTML=e.replace(/ /g," ");const n=t.querySelector("table");if(n===null)return;const r=[n],o=[];let i;for(;r.length>0;){const s=r.pop();if(s===void 0)break;if(s instanceof HTMLTableElement||s.nodeName==="TBODY")r.push(...[...s.children].reverse());else if(s instanceof HTMLTableRowElement)i!==void 0&&o.push(i),i=[],r.push(...[...s.children].reverse());else if(s instanceof HTMLTableCellElement){const l=s.cloneNode(!0),d=l.children.length===1&&l.children[0].nodeName==="P"?l.children[0]:null,h=(d==null?void 0:d.children.length)===1&&d.children[0].nodeName==="FONT",m=l.querySelectorAll("br");for(const y of m)y.replaceWith(`
|
|
7
|
-
`);const p=l.getAttribute("gdg-raw-value"),g=l.getAttribute("gdg-format")??"string";if(l.querySelector("a")!==null)i==null||i.push({rawValue:((a=l.querySelector("a"))==null?void 0:a.getAttribute("href"))??"",formatted:l.textContent??"",format:g});else if(l.querySelector("ol")!==null){const y=l.querySelectorAll("li");i==null||i.push({rawValue:[...y].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...y].map(x=>x.textContent??""),format:"string-array"})}else if(p!==null)i==null||i.push({rawValue:ZC(p),formatted:l.textContent??"",format:g});else{let y=l.textContent??"";h&&(y=y.replace(/\n(?!\n)/g,"")),i==null||i.push({rawValue:y??"",formatted:y??"",format:g})}}}return i!==void 0&&o.push(i),o}function tk(e,t,n,r,o){var s;const i=e;if(r==="allowPartial"||e.current===void 0||t===void 0)return e;let a=!1;do{if((e==null?void 0:e.current)===void 0)break;const l=(s=e.current)==null?void 0:s.range,u=[];if(l.width>2){const m=t({x:l.x,y:l.y,width:1,height:l.height},o.signal);if(typeof m=="function")return i;u.push(...m);const p=t({x:l.x+l.width-1,y:l.y,width:1,height:l.height},o.signal);if(typeof p=="function")return i;u.push(...p)}else{const m=t({x:l.x,y:l.y,width:l.width,height:l.height},o.signal);if(typeof m=="function")return i;u.push(...m)}let d=l.x-n,h=l.x+l.width-1-n;for(const m of u)for(const p of m)p.span!==void 0&&(d=Math.min(p.span[0],d),h=Math.max(p.span[1],h));d===l.x-n&&h===l.x+l.width-1-n?a=!0:e={current:{cell:e.current.cell??[0,0],range:{x:d+n,y:l.y,width:h-d+1,height:l.height},rangeStack:e.current.rangeStack},columns:e.columns,rows:e.rows}}while(!a);return e}function jl(e){return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).replace(/""/g,'"')),e}function nk(e){let t;(function(s){s[s.None=0]="None",s[s.inString=1]="inString",s[s.inStringPostQuote=2]="inStringPostQuote"})(t||(t={}));const n=[];let r=[],o=0,i=t.None;e=e.replace(/\r\n/g,`
|
|
8
|
-
`);let a=0;for(const s of e){switch(i){case t.None:s===" "||s===`
|
|
9
|
-
`?(r.push(e.slice(o,a)),o=a+1,s===`
|
|
10
|
-
`&&(n.push(r),r=[])):s==='"'&&(i=t.inString);break;case t.inString:s==='"'&&(i=t.inStringPostQuote);break;case t.inStringPostQuote:s==='"'?i=t.inString:((s===" "||s===`
|
|
11
|
-
`)&&(r.push(jl(e.slice(o,a))),o=a+1,s===`
|
|
12
|
-
`&&(n.push(r),r=[])),i=t.None);break}a++}return o<e.length&&r.push(jl(e.slice(o,e.length))),n.push(r),n.map(s=>s.map(l=>({rawValue:l,formatted:l,format:"string"})))}function Nl(e,t,n){var s;const r=ek(e,t),o=l=>{var u;(u=window.navigator.clipboard)==null||u.writeText(l)},i=(l,u)=>{var d;return((d=window.navigator.clipboard)==null?void 0:d.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([l],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},a=(l,u)=>{var d,h;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(d=n==null?void 0:n.clipboardData)==null||d.setData("text/plain",l),(h=n==null?void 0:n.clipboardData)==null||h.setData("text/html",u)}catch{i(l,u)||o(l)}};((s=window.navigator.clipboard)==null?void 0:s.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?a(r.textPlain,r.textHtml):o(r.textPlain),n==null||n.preventDefault()}function iu(e){return e!==!0}function Hl(e){return typeof e=="string"?e:`${e}px`}const rk=()=>e=>e.innerWidth,ok=()=>e=>e.innerHeight,ik=Rr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[rk()],"wmyidgi-1":[ok()]}}),sk=e=>{const{inWidth:t,inHeight:n,children:r,...o}=e;return c.createElement(ik,{innerHeight:Hl(n),innerWidth:Hl(t),...o},r)},ak=2,lk=1300;function ck(e,t,n){const r=zt.useRef(0),[o,i]=e??[0,0];zt.useEffect(()=>{if(o===0&&i===0){r.current=0;return}let a=!1,s=0;const l=u=>{var d;if(!a){if(s===0)s=u;else{const h=u-s;r.current=Math.min(1,r.current+h/lk);const m=r.current**1.618*h*ak;(d=t.current)==null||d.scrollBy(o*m,i*m),s=u,n==null||n()}window.requestAnimationFrame(l)}};return window.requestAnimationFrame(l),()=>{a=!0}},[t,o,i,n])}function uk({rowHeight:e,headerHeight:t,groupHeaderHeight:n,theme:r,overscrollX:o,overscrollY:i,scaleToRem:a,remSize:s}){const[l,u,d,h,m,p]=zt.useMemo(()=>{if(!a||s===16)return[e,t,n,r,o,i];const g=s/16,y=e,x=$c();return[typeof y=="number"?y*g:C=>Math.ceil(y(C)*g),Math.ceil(t*g),Math.ceil(n*g),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*g,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*g,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*g},Math.ceil((o??0)*g),Math.ceil((i??0)*g)]},[n,t,o,i,s,e,a,r]);return{rowHeight:l,headerHeight:u,groupHeaderHeight:d,theme:h,overscrollX:m,overscrollY:p}}const xr={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function Qe(e,t){return e===!0?t:e===!1?"":e}function Bl(e){const t=Ni.value;return{activateCell:Qe(e.activateCell," |Enter|shift+Enter"),clear:Qe(e.clear,"any+Escape"),closeOverlay:Qe(e.closeOverlay,"any+Escape"),acceptOverlayDown:Qe(e.acceptOverlayDown,"Enter"),acceptOverlayUp:Qe(e.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:Qe(e.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:Qe(e.acceptOverlayRight,"Tab"),copy:e.copy,cut:e.cut,delete:Qe(e.delete,t?"Backspace|Delete":"Delete"),downFill:Qe(e.downFill,"primary+_68"),scrollToSelectedCell:Qe(e.scrollToSelectedCell,"primary+Enter"),goDownCell:Qe(e.goDownCell,"ArrowDown"),goDownCellRetainSelection:Qe(e.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:Qe(e.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:Qe(e.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:Qe(e.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:Qe(e.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:Qe(e.goUpCell,"ArrowUp"),goUpCellRetainSelection:Qe(e.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:Qe(e.goToFirstCell,"primary+Home"),goToFirstColumn:Qe(e.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:Qe(e.goToFirstRow,"primary+ArrowUp"),goToLastCell:Qe(e.goToLastCell,"primary+End"),goToLastColumn:Qe(e.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:Qe(e.goToLastRow,"primary+ArrowDown"),goToNextPage:Qe(e.goToNextPage,"PageDown"),goToPreviousPage:Qe(e.goToPreviousPage,"PageUp"),paste:e.paste,rightFill:Qe(e.rightFill,"primary+_82"),search:Qe(e.search,"primary+f"),selectAll:Qe(e.selectAll,"primary+a"),selectColumn:Qe(e.selectColumn,"ctrl+ "),selectGrowDown:Qe(e.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:Qe(e.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:Qe(e.selectGrowRight,"shift+ArrowRight"),selectGrowUp:Qe(e.selectGrowUp,"shift+ArrowUp"),selectRow:Qe(e.selectRow,"shift+ "),selectToFirstCell:Qe(e.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:Qe(e.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:Qe(e.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:Qe(e.selectToLastCell,"primary+shift+End"),selectToLastColumn:Qe(e.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:Qe(e.selectToLastRow,"primary+shift+ArrowDown")}}function dk(e){const t=Op(e);return zt.useMemo(()=>{if(t===void 0)return Bl(xr);const n={...t,goToNextPage:(t==null?void 0:t.goToNextPage)??(t==null?void 0:t.pageDown)??xr.goToNextPage,goToPreviousPage:(t==null?void 0:t.goToPreviousPage)??(t==null?void 0:t.pageUp)??xr.goToPreviousPage,goToFirstCell:(t==null?void 0:t.goToFirstCell)??(t==null?void 0:t.first)??xr.goToFirstCell,goToLastCell:(t==null?void 0:t.goToLastCell)??(t==null?void 0:t.last)??xr.goToLastCell,selectToFirstCell:(t==null?void 0:t.selectToFirstCell)??(t==null?void 0:t.first)??xr.selectToFirstCell,selectToLastCell:(t==null?void 0:t.selectToLastCell)??(t==null?void 0:t.last)??xr.selectToLastCell};return Bl({...xr,...n})},[t])}function fk(e){function t(r,o,i){if(typeof r=="number")return{headerIndex:r,isCollapsed:!1,depth:o,path:i};const a={headerIndex:r.headerIndex,isCollapsed:r.isCollapsed,depth:o,path:i};return r.subGroups!==void 0&&(a.subGroups=r.subGroups.map((s,l)=>t(s,o+1,[...i,l])).sort((s,l)=>s.headerIndex-l.headerIndex)),a}return e.map((r,o)=>t(r,0,[o])).sort((r,o)=>r.headerIndex-o.headerIndex)}function la(e,t){const n=[];function r(s,l,u=!1){let d=l!==null?l-s.headerIndex:t-s.headerIndex;if(s.subGroups!==void 0&&(d=s.subGroups[0].headerIndex-s.headerIndex),d--,n.push({rowIndex:-1,headerIndex:s.headerIndex,contentIndex:-1,skip:u,isCollapsed:s.isCollapsed,depth:s.depth,path:s.path,rows:d}),s.subGroups)for(let h=0;h<s.subGroups.length;h++){const m=h<s.subGroups.length-1?s.subGroups[h+1].headerIndex:l;r(s.subGroups[h],m,u||s.isCollapsed)}}const o=fk(e.groups);for(let s=0;s<o.length;s++){const l=s<o.length-1?o[s+1].headerIndex:null;r(o[s],l)}let i=0,a=0;for(const s of n)s.contentIndex=a,a+=s.rows,s.rowIndex=i,i+=s.isCollapsed?1:s.rows+1;return n.filter(s=>s.skip===!1).map(s=>{const{skip:l,...u}=s;return u})}function Hs(e,t){if(t===void 0||la.length===0)return{path:[e],originalIndex:e,isGroupHeader:!1,groupIndex:e,contentIndex:e,groupRows:-1};let n=e;for(const r of t){if(n===0)return{path:[...r.path,-1],originalIndex:r.headerIndex,isGroupHeader:!0,groupIndex:-1,contentIndex:-1,groupRows:r.rows};if(r.isCollapsed)n--;else{if(n<=r.rows)return{path:[...r.path,n-1],originalIndex:r.headerIndex+n,isGroupHeader:!1,groupIndex:n-1,contentIndex:r.contentIndex+n-1,groupRows:r.rows};n=n-r.rows-1}}return{path:[e],originalIndex:e,isGroupHeader:!1,groupIndex:e,contentIndex:e,groupRows:-1}}function hk(e,t,n,r){const o=zt.useMemo(()=>e===void 0?void 0:la(e,t),[e,t]),i=zt.useMemo(()=>o==null?void 0:o.reduce((d,h)=>(d[h.rowIndex]=h,d),{}),[o]),a=zt.useMemo(()=>o===void 0?t:o.reduce((d,h)=>d+(h.isCollapsed?1:h.rows+1),0),[o,t]),s=zt.useMemo(()=>e===void 0||typeof n=="number"&&e.height===n?n:d=>i!=null&&i[d]?e.height:typeof n=="number"?n:n(d),[i,e,n]),l=zt.useCallback(d=>{if(o===void 0)return d;let h=d;for(const m of o){if(h===0)return;if(h--,!m.isCollapsed){if(h<m.rows)return m.contentIndex+h;h-=m.rows}}return d},[o]),u=Cr(r??(e==null?void 0:e.themeOverride),zt.useCallback(d=>{if(e===void 0)return r==null?void 0:r(d,d,d);if(r===void 0&&(e==null?void 0:e.themeOverride)===void 0)return;const{isGroupHeader:h,contentIndex:m,groupIndex:p}=Hs(d,o);return h?e.themeOverride:r==null?void 0:r(d,p,m)},[o,r,e]));return e===void 0?{rowHeight:s,rows:t,rowNumberMapper:l,getRowThemeOverride:u}:{rowHeight:s,rows:a,rowNumberMapper:l,getRowThemeOverride:u}}function gk(e,t){const n=zt.useMemo(()=>e===void 0?void 0:la(e,t),[e,t]);return{getRowGroupingForPath:au,updateRowGroupingByPath:su,mapper:zt.useCallback(r=>{if(typeof r=="number")return Hs(r,n);const o=Hs(r[1],n);return{...o,originalIndex:[r[0],o.originalIndex]}},[n])}}function su(e,t,n){const[r,...o]=t;return o[0]===-1?e.map((i,a)=>a===r?{...i,...n}:i):e.map((i,a)=>a===r?{...i,subGroups:su(i.subGroups??[],o,n)}:i)}function au(e,t){const[n,...r]=t;return r[0]===-1?e[n]:au(e[n].subGroups??[],r)}function mk(e,t){const[n]=c.useState(()=>({value:e,callback:t,facade:{get current(){return n.value},set current(r){const o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}));return n.callback=t,n.facade}function pk(e,t,n,r,o){const[i,a]=c.useMemo(()=>[t!==void 0&&typeof n=="number"?Math.floor(t/n):0,t!==void 0&&typeof n=="number"?-(t%n):0],[t,n]),s=c.useMemo(()=>({x:r.current.x,y:i,width:r.current.width??1,height:r.current.height??1,ty:a}),[r,a,i]),[l,u,d]=_p(s),h=c.useRef(o);h.current=o;const m=mk(null,y=>{y!==null&&t!==void 0?y.scrollTop=t:y!==null&&e!==void 0&&(y.scrollLeft=e)}),p=(l.height??1)>1;c.useLayoutEffect(()=>{if(t!==void 0&&m.current!==null&&p){if(m.current.scrollTop===t)return;m.current.scrollTop=t,m.current.scrollTop!==t&&d(),h.current()}},[t,p,d,m]);const g=(l.width??1)>1;return c.useLayoutEffect(()=>{if(e!==void 0&&m.current!==null&&g){if(m.current.scrollLeft===e)return;m.current.scrollLeft=e,m.current.scrollLeft!==e&&d(),h.current()}},[e,g,d,m]),{visibleRegion:l,setVisibleRegion:u,scrollRef:m}}const bk=c.lazy(async()=>await Zl(()=>import("./data-grid-overlay-editor-CBVV2omk.js"),__vite__mapDeps([0,1,2])));let yk=0;function vk(e){return gy(sl(sl(e).filter(t=>t.span!==void 0).map(t=>{var n,r;return Hr((((n=t.span)==null?void 0:n[0])??0)+1,(((r=t.span)==null?void 0:r[1])??0)+1)})))}function ki(e,t){return e===void 0||t===0||e.columns.length===0&&e.current===void 0?e:{current:e.current===void 0?void 0:{cell:[e.current.cell[0]+t,e.current.cell[1]],range:{...e.current.range,x:e.current.range.x+t},rangeStack:e.current.rangeStack.map(n=>({...n,x:n.x+t}))},rows:e.rows,columns:e.columns.offset(t)}}const Si={kind:ue.Loading,allowOverlay:!1},Ri={columns:rt.empty(),rows:rt.empty(),current:void 0},wk=(e,t)=>{var Sa,Ra,Ma;const[n,r]=c.useState(Ri),[o,i]=c.useState(),a=c.useRef(null),s=c.useRef(null),[l,u]=c.useState(),d=c.useRef(),h=typeof window>"u"?null:window,{imageEditorOverride:m,getRowThemeOverride:p,markdownDivCreateNode:g,width:y,height:x,columns:C,rows:w,getCellContent:M,onCellClicked:U,onCellActivated:z,onFillPattern:A,onFinishedEditing:W,coercePasteValue:J,drawHeader:S,drawCell:F,editorBloom:B,onHeaderClicked:N,onColumnProposeMove:_,rangeSelectionColumnSpanning:D=!0,spanRangeBehavior:fe="default",onGroupHeaderClicked:X,onCellContextMenu:ee,className:he,onHeaderContextMenu:de,getCellsForSelection:te,onGroupHeaderContextMenu:q,onGroupHeaderRenamed:Ce,onCellEdited:ie,onCellsEdited:re,onSearchResultsChanged:$e,searchResults:Z,onSearchValueChange:se,searchValue:me,onKeyDown:ze,onKeyUp:Me,keybindings:ot,editOnType:it=!0,onRowAppended:Ae,onColumnAppended:Oe,onColumnMoved:je,validateCell:vt,highlightRegions:wt,rangeSelect:ut="rect",columnSelect:oe="multi",rowSelect:ve="multi",rangeSelectionBlending:De="exclusive",columnSelectionBlending:Fe="exclusive",rowSelectionBlending:pe="exclusive",onDelete:Ke,onDragStart:Ye,onMouseMove:We,onPaste:ce,copyHeaders:Se=!1,freezeColumns:qe=0,cellActivationBehavior:le="second-click",rowSelectionMode:tt="auto",columnSelectionMode:mt="auto",onHeaderMenuClick:Re,onHeaderIndicatorClick:we,getGroupDetails:It,rowGrouping:dt,onSearchClose:He,onItemHovered:st,onSelectionCleared:pt,showSearch:Pt,onVisibleRegionChanged:an,gridSelection:Kt,onGridSelectionChange:bt,minColumnWidth:En=50,maxColumnWidth:ln=500,maxColumnAutoWidth:kt,provideEditor:Ot,trailingRowOptions:Pe,freezeTrailingRows:Dt=0,allowedFillDirections:Gt="orthogonal",scrollOffsetX:et,scrollOffsetY:Rt,verticalBorder:lt,onDragOverCell:jt,onDrop:Et,onColumnResize:ft,onColumnResizeEnd:yn,onColumnResizeStart:ht,customRenderers:Bn,fillHandle:xt,experimental:xe,fixedShadowX:Yt,fixedShadowY:Ir,headerIcons:vn,imageWindowLoader:Ut,initialSize:en,isDraggable:Ln,onDragLeave:nr,onRowMoved:Tn,overscrollX:rr,overscrollY:or,preventDiagonalScrolling:ir,rightElement:sr,rightElementProps:cn,trapFocus:wn=!1,smoothScrollX:Er,smoothScrollY:Ur,scaleToRem:Xr=!1,rowHeight:So=34,headerHeight:xn=36,groupHeaderHeight:un=xn,theme:ar,isOutsideClick:Ro,renderers:lr,resizeIndicator:cr,scrollToActiveCell:Yn=!0,drawFocusRing:Mo=!0,portalElementRef:Kr}=e,ur=Mo==="no-editor"?o===void 0:Mo,Ct=typeof e.rowMarkers=="string"?void 0:e.rowMarkers,qt=(Ct==null?void 0:Ct.kind)??e.rowMarkers??"none",dr=(Ct==null?void 0:Ct.width)??e.rowMarkerWidth,Vt=(Ct==null?void 0:Ct.startIndex)??e.rowMarkerStartIndex??1,Dn=(Ct==null?void 0:Ct.theme)??e.rowMarkerTheme,Wt=Ct==null?void 0:Ct.headerTheme,fr=Ct==null?void 0:Ct.headerAlwaysVisible,hr=ve!=="multi"||(Ct==null?void 0:Ct.headerDisabled)===!0,dn=(Ct==null?void 0:Ct.checkboxStyle)??"square",$n=Math.max(En,20),fn=Math.max(ln,$n),gr=Math.max(kt??fn,$n),qn=c.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),{rows:Ee,rowNumberMapper:Tr,rowHeight:Dr,getRowThemeOverride:rn}=hk(dt,w,So,p),Yr=c.useMemo(()=>Number.parseFloat(qn.fontSize),[qn]),{rowHeight:hn,headerHeight:mr,groupHeaderHeight:qr,theme:Vn,overscrollX:Io,overscrollY:Vr}=uk({groupHeaderHeight:un,headerHeight:xn,overscrollX:rr,overscrollY:or,remSize:Yr,rowHeight:Dr,scaleToRem:Xr,theme:ar}),gn=dk(ot),An=dr??(w>1e4?48:w>1e3?44:w>100?36:32),Jt=qt!=="none",$=Jt?1:0,gt=Pe!==void 0,Nt=(Pe==null?void 0:Pe.sticky)===!0,[Eo,Jn]=c.useState(!1),To=Pt??Eo,Fn=c.useCallback(()=>{He!==void 0?He():Jn(!1)},[He]),G=c.useMemo(()=>Kt===void 0?void 0:ki(Kt,$),[Kt,$])??n,E=c.useRef();E.current===void 0&&(E.current=new AbortController),c.useEffect(()=>()=>E==null?void 0:E.current.abort(),[]);const[b,T]=YC(te,M,$,E.current,Ee),P=c.useCallback((f,k,R)=>{if(vt===void 0)return!0;const I=[f[0]-$,f[1]];return vt==null?void 0:vt(I,k,R)},[$,vt]),L=c.useRef(Kt),V=c.useCallback((f,k)=>{k&&(f=tk(f,b,$,fe,E.current)),bt!==void 0?(L.current=ki(f,-$),bt(L.current)):r(f)},[bt,b,$,fe]),ge=Cr(ft,c.useCallback((f,k,R,I)=>{ft==null||ft(C[R-$],k,R-$,I)},[ft,$,C])),Ge=Cr(yn,c.useCallback((f,k,R,I)=>{yn==null||yn(C[R-$],k,R-$,I)},[yn,$,C])),ke=Cr(ht,c.useCallback((f,k,R,I)=>{ht==null||ht(C[R-$],k,R-$,I)},[ht,$,C])),Ht=Cr(S,c.useCallback((f,k)=>(S==null?void 0:S({...f,columnIndex:f.columnIndex-$},k))??!1,[S,$])),Ie=Cr(F,c.useCallback((f,k)=>(F==null?void 0:F({...f,col:f.col-$},k))??!1,[F,$])),nt=c.useCallback(f=>{if(Ke!==void 0){const k=Ke(ki(f,-$));return typeof k=="boolean"?k:ki(k,$)}return!0},[Ke,$]),[Ue,Ve,Be]=KC(G,V,De,Fe,pe,ut,D),at=c.useMemo(()=>tr($c(),Vn),[Vn]),[At,_n]=c.useState([0,0,0]),Pn=c.useMemo(()=>{if(lr===void 0)return{};const f={};for(const k of lr)f[k.kind]=k;return f},[lr]),Mt=c.useCallback(f=>f.kind!==ue.Custom?Pn[f.kind]:Bn==null?void 0:Bn.find(k=>k.isMatch(f)),[Bn,Pn]);let{sizedColumns:_t,nonGrowWidth:yt}=gb(C,Ee,T,At[0]-($===0?0:An)-At[2],$n,gr,at,Mt,E.current);qt!=="none"&&(yt+=An);const Cn=c.useMemo(()=>_t.some(f=>f.group!==void 0),[_t]),Zt=Cn?mr+qr:mr,Jr=G.rows.length,Zn=qt==="none"?void 0:Jr===0?!1:Jr===Ee?!0:void 0,Je=c.useMemo(()=>qt==="none"?_t:[{title:"",width:An,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Dn,rowMarker:dn,rowMarkerChecked:Zn,headerRowMarkerTheme:Wt,headerRowMarkerAlwaysVisible:fr,headerRowMarkerDisabled:hr},..._t],[qt,_t,An,Dn,dn,Zn,Wt,fr,hr]),Bt=c.useRef({height:1,width:1,x:0,y:0}),$r=c.useRef(!1),{setVisibleRegion:pr,visibleRegion:Qn,scrollRef:St}=pk(et,Rt,hn,Bt,()=>$r.current=!0);Bt.current=Qn;const Tu=Qn.x+$,oi=Qn.y,Xt=c.useRef(null),tn=c.useCallback(f=>{var k;f===!0?(k=Xt.current)==null||k.focus():window.requestAnimationFrame(()=>{var R;(R=Xt.current)==null||R.focus()})},[]),Qt=gt?Ee+1:Ee,kn=c.useCallback(f=>{const k=$===0?f:f.map(I=>({...I,location:[I.location[0]-$,I.location[1]]})),R=re==null?void 0:re(k);if(R!==!0)for(const I of k)ie==null||ie(I.location,I.value);return R},[ie,re,$]),[Ar,qi]=c.useState(),ii=G.current!==void 0&&G.current.range.width*G.current.range.height>1?G.current.range:void 0,Zr=ur?(Sa=G.current)==null?void 0:Sa.cell:void 0,si=Zr==null?void 0:Zr[0],ai=Zr==null?void 0:Zr[1],Du=c.useMemo(()=>{if((wt===void 0||wt.length===0)&&(ii??si??ai??Ar)===void 0)return;const f=[];if(wt!==void 0)for(const k of wt){const R=Je.length-k.range.x-$;R>0&&f.push({color:k.color,range:{...k.range,x:k.range.x+$,width:Math.min(R,k.range.width)},style:k.style})}return Ar!==void 0&&f.push({color:Br(at.accentColor,0),range:Ar,style:"dashed"}),ii!==void 0&&f.push({color:Br(at.accentColor,.5),range:ii,style:"solid-outline"}),si!==void 0&&ai!==void 0&&f.push({color:at.accentColor,range:{x:si,y:ai,width:1,height:1},style:"solid-outline"}),f.length>0?f:void 0},[Ar,ii,si,ai,wt,Je.length,at.accentColor,$]),da=c.useRef(Je);da.current=Je;const mn=c.useCallback(([f,k],R=!1)=>{var K,O,H,Y,Q,ae,be;const I=gt&&k===Qt-1;if(f===0&&Jt){if(I)return Si;const ne=Tr(k);return ne===void 0?Si:{kind:Mn.Marker,allowOverlay:!1,checkboxStyle:dn,checked:(G==null?void 0:G.rows.hasIndex(k))===!0,markerKind:qt==="clickable-number"?"number":qt,row:Vt+ne,drawHandle:Tn!==void 0,cursor:qt==="clickable-number"?"pointer":void 0}}else if(I){const _e=f===$?(Pe==null?void 0:Pe.hint)??"":"",ye=da.current[f];if(((K=ye==null?void 0:ye.trailingRowOptions)==null?void 0:K.disabled)===!0)return Si;{const Le=((O=ye==null?void 0:ye.trailingRowOptions)==null?void 0:O.hint)??_e,Ne=((H=ye==null?void 0:ye.trailingRowOptions)==null?void 0:H.addIcon)??(Pe==null?void 0:Pe.addIcon);return{kind:Mn.NewRow,hint:Le,allowOverlay:!1,icon:Ne}}}else{const ne=f-$;if(R||(xe==null?void 0:xe.strict)===!0){const ye=Bt.current,Le=ye.x>ne||ne>ye.x+ye.width||ye.y>k||k>ye.y+ye.height||k>=Qi.current,Ne=ne===((Q=(Y=ye.extras)==null?void 0:Y.selected)==null?void 0:Q[0])&&k===((ae=ye.extras)==null?void 0:ae.selected[1]);let Te=!1;if(((be=ye.extras)==null?void 0:be.freezeRegions)!==void 0){for(const ct of ye.extras.freezeRegions)if(ho(ct,ne,k)){Te=!0;break}}if(Le&&!Ne&&!Te)return Si}let _e=M([ne,k]);return $!==0&&_e.span!==void 0&&(_e={..._e,span:[_e.span[0]+$,_e.span[1]+$]}),_e}},[gt,Qt,Jt,Tr,dn,G==null?void 0:G.rows,qt,Vt,Tn,$,Pe==null?void 0:Pe.hint,Pe==null?void 0:Pe.addIcon,xe==null?void 0:xe.strict,M]),Vi=c.useCallback(f=>{let k=(It==null?void 0:It(f))??{name:f};return Ce!==void 0&&f!==""&&(k={icon:k.icon,name:k.name,overrideTheme:k.overrideTheme,actions:[...k.actions??[],{title:"Rename",icon:"renameIcon",onClick:R=>ts({group:k.name,bounds:R.bounds})}]}),k},[It,Ce]),li=c.useCallback(f=>{var H;const[k,R]=f.cell,I=Je[k],j=(I==null?void 0:I.group)!==void 0?(H=Vi(I.group))==null?void 0:H.overrideTheme:void 0,K=I==null?void 0:I.themeOverride,O=rn==null?void 0:rn(R);i({...f,theme:tr(at,j,K,O,f.content.themeOverride)})},[rn,Je,Vi,at]),Qr=c.useCallback((f,k,R)=>{var O;if(G.current===void 0)return;const[I,j]=G.current.cell,K=mn([I,j]);if(K.kind!==ue.Boolean&&K.allowOverlay){let H=K;if(R!==void 0)switch(H.kind){case ue.Number:{const Y=Jm(()=>R==="-"?-0:Number.parseFloat(R),0);H={...H,data:Number.isNaN(Y)?0:Y};break}case ue.Text:case ue.Markdown:case ue.Uri:H={...H,data:R};break}li({target:f,content:H,initialValue:R,cell:[I,j],highlight:R===void 0,forceEditMode:R!==void 0,activation:k})}else K.kind===ue.Boolean&&k.inputType==="keyboard"&&K.readonly!==!0&&(kn([{location:G.current.cell,value:{...K,data:iu(K.data)}}]),(O=Xt.current)==null||O.damage([{cell:G.current.cell}]))},[mn,G,kn,li]),fa=c.useCallback((f,k)=>{var j;const R=(j=Xt.current)==null?void 0:j.getBounds(f,k);if(R===void 0||St.current===null)return;const I=mn([f,k]);I.allowOverlay&&li({target:R,content:I,initialValue:void 0,highlight:!0,cell:[f,k],forceEditMode:!0,activation:{inputType:"keyboard",key:"Enter"}})},[mn,St,li]),Ft=c.useCallback((f,k,R="both",I=0,j=0,K=void 0)=>{if(St.current!==null){const O=Xt.current,H=s.current,Y=typeof f!="number"?f.unit==="cell"?f.amount:void 0:f,Q=typeof k!="number"?k.unit==="cell"?k.amount:void 0:k,ae=typeof f!="number"&&f.unit==="px"?f.amount:void 0,be=typeof k!="number"&&k.unit==="px"?k.amount:void 0;if(O!==null&&H!==null){let ne={x:0,y:0,width:0,height:0},_e=0,ye=0;if((Y!==void 0||Q!==void 0)&&(ne=O.getBounds((Y??0)+$,Q??0)??ne,ne.width===0||ne.height===0))return;const Le=H.getBoundingClientRect(),Ne=Le.width/H.offsetWidth;if(ae!==void 0&&(ne={...ne,x:ae-Le.left-St.current.scrollLeft,width:1}),be!==void 0&&(ne={...ne,y:be+Le.top-St.current.scrollTop,height:1}),ne!==void 0){const Te={x:ne.x-I,y:ne.y-j,width:ne.width+2*I,height:ne.height+2*j};let ct=0;for(let ls=0;ls<qe;ls++)ct+=_t[ls].width;let $t=0;const Lt=Dt+(Nt?1:0);Lt>0&&($t=Wr(Qt,Lt,hn));let on=ct*Ne+Le.left+$*An*Ne,Wn=Le.right,Nn=Le.top+Zt*Ne,Gn=Le.bottom-$t*Ne;const mi=ne.width+I*2;switch(K==null?void 0:K.hAlign){case"start":Wn=on+mi;break;case"end":on=Wn-mi;break;case"center":on=Math.floor((on+Wn)/2)-mi/2,Wn=on+mi;break}const pi=ne.height+j*2;switch(K==null?void 0:K.vAlign){case"start":Gn=Nn+pi;break;case"end":Nn=Gn-pi;break;case"center":Nn=Math.floor((Nn+Gn)/2)-pi/2,Gn=Nn+pi;break}on>Te.x?_e=Te.x-on:Wn<Te.x+Te.width&&(_e=Te.x+Te.width-Wn),Nn>Te.y?ye=Te.y-Nn:Gn<Te.y+Te.height&&(ye=Te.y+Te.height-Gn),R==="vertical"||typeof f=="number"&&f<qe?_e=0:(R==="horizontal"||typeof k=="number"&&k>=Qt-Lt)&&(ye=0),(_e!==0||ye!==0)&&(Ne!==1&&(_e/=Ne,ye/=Ne),St.current.scrollTo({left:_e+St.current.scrollLeft,top:ye+St.current.scrollTop,behavior:(K==null?void 0:K.behavior)??"auto"}))}}}},[$,Dt,An,St,Zt,qe,_t,Qt,Nt,hn]),Ji=c.useRef(fa),Zi=c.useRef(M);Ji.current=fa,Zi.current=M;const Qi=c.useRef(Ee);Qi.current=Ee;const ha=c.useRef(Je.length);ha.current=Je.length;const br=c.useCallback(async(f,k=!0,R)=>{var Q;const I=Je[f];if(((Q=I==null?void 0:I.trailingRowOptions)==null?void 0:Q.disabled)===!0)return;const j=Ae==null?void 0:Ae();let K,O=!0;j!==void 0&&(K=await j,K==="top"&&(O=!1),typeof K=="number"&&(O=!1));let H=0;const Y=()=>{if(Qi.current<=Ee){H<500&&window.setTimeout(Y,H),H=50+H*2;return}const ae=typeof K=="number"?K:O?Ee:0;gi.current(f-$,ae,"both",0,0,R?{behavior:R}:void 0),Ue({cell:[f,ae],range:{x:f,y:ae,width:1,height:1}},!1,!1,"edit");const be=Zi.current([f-$,ae]);be.allowOverlay&&so(be)&&be.readonly!==!0&&k&&window.setTimeout(()=>{Ji.current(f,ae)},0)};Y()},[Je,Ae,$,Ee,Ue]),ci=c.useCallback(async(f,k=!0)=>{const R=Oe==null?void 0:Oe();let I,j=!0;R!==void 0&&(I=await R,I==="left"&&(j=!1),typeof I=="number"&&(j=!1));let K=0;const O=()=>{if(ha.current<=Je.length){K<500&&window.setTimeout(O,K),K=50+K*2;return}const H=typeof I=="number"?I:j?Je.length:0;Ft(H-$,f),Ue({cell:[H,f],range:{x:H,y:f,width:1,height:1}},!1,!1,"edit");const Y=Zi.current([H-$,f]);Y.allowOverlay&&so(Y)&&Y.readonly!==!0&&k&&window.setTimeout(()=>{Ji.current(H,f)},0)};O()},[Je,Oe,$,Ft,Ue]),eo=c.useCallback(f=>{var R,I;const k=((I=(R=_t[f])==null?void 0:R.trailingRowOptions)==null?void 0:I.targetColumn)??(Pe==null?void 0:Pe.targetColumn);if(typeof k=="number")return k+(Jt?1:0);if(typeof k=="object"){const j=C.indexOf(k);if(j>=0)return j+(Jt?1:0)}},[_t,C,Jt,Pe==null?void 0:Pe.targetColumn]),yr=c.useRef(),to=c.useRef(),$o=c.useCallback((f,k)=>{var j;const[R,I]=k;return tr(at,(j=Je[R])==null?void 0:j.themeOverride,rn==null?void 0:rn(I),f.themeOverride)},[rn,Je,at]),{mapper:Fr}=gk(dt,w),On=dt==null?void 0:dt.navigationBehavior,Ao=c.useCallback(f=>{var Q,ae,be;const k=Ni.value?f.metaKey:f.ctrlKey,R=k&&ve==="multi",[I,j]=f.location,K=G.columns,O=G.rows,[H,Y]=((Q=G.current)==null?void 0:Q.cell)??[];if(f.kind==="cell"){if(to.current=void 0,_r.current=[I,j],I===0&&Jt){if(gt===!0&&j===Ee||qt==="number"||ve==="none")return;const ne=mn(f.location);if(ne.kind!==Mn.Marker)return;if(Tn!==void 0){const Le=Mt(ne);pn((Le==null?void 0:Le.kind)===Mn.Marker);const Ne=(ae=Le==null?void 0:Le.onClick)==null?void 0:ae.call(Le,{...f,cell:ne,posX:f.localEventX,posY:f.localEventY,bounds:f.bounds,theme:$o(ne,f.location),preventDefault:()=>{}});if(Ne===void 0||Ne.checked===ne.checked)return}i(void 0),tn();const _e=O.hasIndex(j),ye=yr.current;if(ve==="multi"&&(f.shiftKey||f.isLongTouch===!0)&&ye!==void 0&&O.hasIndex(ye)){const Le=[Math.min(ye,j),Math.max(ye,j)+1];R||tt==="multi"?Ve(void 0,Le,!0):Ve(rt.fromSingleSelection(Le),void 0,R)}else ve==="multi"&&(R||f.isTouch||tt==="multi")?_e?Ve(O.remove(j),void 0,!0):(Ve(void 0,j,!0),yr.current=j):_e&&O.length===1?Ve(rt.empty(),void 0,k):(Ve(rt.fromSingleSelection(j),void 0,k),yr.current=j)}else if(I>=$&>&&j===Ee){const ne=eo(I);br(ne??I)}else if(H!==I||Y!==j){const ne=mn(f.location),_e=Mt(ne);if((_e==null?void 0:_e.onSelect)!==void 0){let Ne=!1;if(_e.onSelect({...f,cell:ne,posX:f.localEventX,posY:f.localEventY,bounds:f.bounds,preventDefault:()=>Ne=!0,theme:$o(ne,f.location)}),Ne)return}if(On==="block"&&Fr(j).isGroupHeader)return;const ye=Nt&&j===Ee,Le=Nt&&G!==void 0&&((be=G.current)==null?void 0:be.cell[1])===Ee;if((f.shiftKey||f.isLongTouch===!0)&&H!==void 0&&Y!==void 0&&G.current!==void 0&&!Le){if(ye)return;const Ne=Math.min(I,H),Te=Math.max(I,H),ct=Math.min(j,Y),$t=Math.max(j,Y);Ue({...G.current,range:{x:Ne,y:ct,width:Te-Ne+1,height:$t-ct+1}},!0,k,"click"),yr.current=void 0,tn()}else Ue({cell:[I,j],range:{x:I,y:j,width:1,height:1}},!0,k,"click"),yr.current=void 0,i(void 0),tn()}}else if(f.kind==="header")if(_r.current=[I,j],i(void 0),Jt&&I===0)yr.current=void 0,to.current=void 0,!hr&&ve==="multi"&&(O.length!==Ee?Ve(rt.fromSingleSelection([0,Ee]),void 0,k):Ve(rt.empty(),void 0,k),tn());else{const ne=to.current;if(oe==="multi"&&(f.shiftKey||f.isLongTouch===!0)&&ne!==void 0&&K.hasIndex(ne)){const _e=[Math.min(ne,I),Math.max(ne,I)+1];k||f.isTouch||mt==="multi"?Be(void 0,_e,k):Be(rt.fromSingleSelection(_e),void 0,k)}else oe==="multi"&&(k||f.isTouch||mt==="multi")?(K.hasIndex(I)?Be(K.remove(I),void 0,k):Be(void 0,I,k),to.current=I):oe!=="none"&&(K.hasIndex(I)?Be(K.remove(I),void 0,k):Be(rt.fromSingleSelection(I),void 0,k),to.current=I);yr.current=void 0,tn()}else f.kind===Hn?_r.current=[I,j]:f.kind===Hi&&!f.isMaybeScrollbar&&(V(Ri,!1),i(void 0),tn(),pt==null||pt(),yr.current=void 0,to.current=void 0)},[ve,oe,G,Jt,$,gt,Ee,qt,mn,Tn,tn,tt,mt,Mt,$o,Ve,eo,br,On,Fr,Nt,Ue,hr,Be,V,pt]),Fo=c.useRef(!1),_r=c.useRef(),ga=c.useRef(Qn),Sn=c.useRef(),$u=c.useCallback(f=>{if(no.current=!1,ga.current=Bt.current,f.button!==0&&f.button!==1){Sn.current=void 0;return}const k=performance.now();Sn.current={button:f.button,time:k,location:f.location},(f==null?void 0:f.kind)==="header"&&(Fo.current=!0);const R=f.kind==="cell"&&f.isFillHandle;!R&&f.kind!=="cell"&&f.isEdge||(u({previousSelection:G,fillHandle:R}),_r.current=void 0,!f.isTouch&&f.button===0&&!R?Ao(f):!f.isTouch&&f.button===1&&(_r.current=f.location))},[G,Ao]),[es,ts]=c.useState(),ma=c.useCallback(f=>{if(f.kind!==Hn||oe!=="multi")return;const k=Ni.value?f.metaKey:f.ctrlKey,[R]=f.location,I=G.columns;if(R<$)return;const j=Je[R];let K=R,O=R;for(let H=R-1;H>=$&&Jo(j.group,Je[H].group);H--)K--;for(let H=R+1;H<Je.length&&Jo(j.group,Je[H].group);H++)O++;if(tn(),k||f.isTouch||mt==="multi")if(I.hasAll([K,O+1])){let H=I;for(let Y=K;Y<=O;Y++)H=H.remove(Y);Be(H,void 0,k)}else Be(void 0,[K,O+1],k);else Be(rt.fromSingleSelection([K,O+1]),void 0,k)},[oe,tn,G.columns,Je,$,Be,mt]),no=c.useRef(!1),ui=c.useCallback(async f=>{if(b!==void 0&&ge!==void 0){const k=Bt.current.y,R=Bt.current.height;let I=b({x:f,y:k,width:1,height:Math.min(R,Ee-k)},E.current.signal);typeof I!="object"&&(I=await I());const j=_t[f-$],O=document.createElement("canvas").getContext("2d",{alpha:!1});if(O!==null){O.font=at.baseFontFull;const H=Ac(O,at,j,0,I,$n,fn,!1,Mt);ge==null||ge(j,H.width,f,H.width)}}},[_t,b,fn,at,$n,ge,$,Ee,Mt]),[Au,ns]=c.useState(),ro=c.useCallback(async(f,k)=>{var H,Y;const R=(H=f.current)==null?void 0:H.range;if(R===void 0||b===void 0||k.current===void 0)return;const I=k.current.range;if(A!==void 0){let Q=!1;if(A({fillDestination:{...I,x:I.x-$},patternSource:{...R,x:R.x-$},preventDefault:()=>Q=!0}),Q)return}let j=b(R,E.current.signal);typeof j!="object"&&(j=await j());const K=j,O=[];for(let Q=0;Q<I.width;Q++)for(let ae=0;ae<I.height;ae++){const be=[I.x+Q,I.y+ae];if(xc(be,R))continue;const ne=K[ae%R.height][Q%R.width];lo(ne)||!so(ne)||O.push({location:be,value:{...ne}})}kn(O),(Y=Xt.current)==null||Y.damage(O.map(Q=>({cell:Q.location})))},[b,kn,A,$]),pa=c.useCallback(()=>{if(G.current===void 0||G.current.range.width<=1)return;const f={...G,current:{...G.current,range:{...G.current.range,width:1}}};ro(f,G)},[ro,G]),ba=c.useCallback(()=>{if(G.current===void 0||G.current.range.height<=1)return;const f={...G,current:{...G.current,range:{...G.current.range,height:1}}};ro(f,G)},[ro,G]),Fu=c.useCallback((f,k)=>{var ae,be;const R=l;if(u(void 0),qi(void 0),ns(void 0),Fo.current=!1,k)return;if((R==null?void 0:R.fillHandle)===!0&&G.current!==void 0&&((ae=R.previousSelection)==null?void 0:ae.current)!==void 0){if(Ar===void 0)return;const ne={...G,current:{...G.current,range:Lc(R.previousSelection.current.range,Ar)}};ro(R.previousSelection,ne),V(ne,!0);return}const[I,j]=f.location,[K,O]=_r.current??[],H=()=>{no.current=!0},Y=ne=>{var ye,Le,Ne;const _e=ne.isTouch||K===I&&O===j;if(_e&&(U==null||U([I-$,j],{...ne,preventDefault:H})),ne.button===1)return!no.current;if(!no.current){const Te=mn(f.location),ct=Mt(Te);if(ct!==void 0&&ct.onClick!==void 0&&_e){const Lt=ct.onClick({...ne,cell:Te,posX:ne.localEventX,posY:ne.localEventY,bounds:ne.bounds,theme:$o(Te,f.location),preventDefault:H});Lt!==void 0&&!lo(Lt)&&io(Lt)&&(kn([{location:ne.location,value:Lt}]),(ye=Xt.current)==null||ye.damage([{cell:ne.location}]))}if(no.current||G.current===void 0)return!1;let $t=!1;switch(Te.activationBehaviorOverride??le){case"double-click":case"second-click":{if(((Ne=(Le=R==null?void 0:R.previousSelection)==null?void 0:Le.current)==null?void 0:Ne.cell)===void 0)break;const[Lt,on]=G.current.cell,[Wn,Nn]=R.previousSelection.current.cell;$t=I===Lt&&I===Wn&&j===on&&j===Nn&&(ne.isDoubleClick===!0||le==="second-click");break}case"single-click":{$t=!0;break}}if($t){const on={inputType:"pointer",pointerActivation:ne.isDoubleClick===!0?"double-click":Te.activationBehaviorOverride??le,pointerType:ne.isTouch?"touch":"mouse"};return z==null||z([I-$,j],on),Qr(ne.bounds,on),!0}}return!1},Q=f.location[0]-$;if(f.isTouch){const ne=Bt.current,_e=ga.current;if(ne.x!==_e.x||ne.y!==_e.y)return;if(f.isLongTouch===!0){if(f.kind==="cell"&&Ko((be=G.current)==null?void 0:be.cell,f.location)){ee==null||ee([Q,f.location[1]],{...f,preventDefault:H});return}else if(f.kind==="header"&&G.columns.hasIndex(I)){de==null||de(Q,{...f,preventDefault:H});return}else if(f.kind===Hn){if(Q<0)return;q==null||q(Q,{...f,preventDefault:H});return}}f.kind==="cell"?Y(f)||Ao(f):f.kind===Hn?X==null||X(Q,{...f,preventDefault:H}):(f.kind===kr&&(N==null||N(Q,{...f,preventDefault:H})),Ao(f));return}if(f.kind==="header"){if(Q<0)return;f.isEdge?f.isDoubleClick===!0&&ui(I):f.button===0&&I===K&&j===O&&(N==null||N(Q,{...f,preventDefault:H}))}if(f.kind===Hn){if(Q<0)return;f.button===0&&I===K&&j===O&&(X==null||X(Q,{...f,preventDefault:H}),no.current||ma(f))}f.kind==="cell"&&(f.button===0||f.button===1)&&Y(f),_r.current=void 0},[l,G,$,Ar,ro,V,U,mn,Mt,le,$o,kn,z,Qr,ee,de,q,Ao,X,N,ui,ma]),_u=c.useCallback(f=>{const k={...f,location:[f.location[0]-$,f.location[1]]};We==null||We(k),l!==void 0&&f.buttons===0&&(u(void 0),qi(void 0),ns(void 0),Fo.current=!1),ns(R=>{var I;return Fo.current?[f.scrollEdge[0],0]:f.scrollEdge[0]===(R==null?void 0:R[0])&&f.scrollEdge[1]===R[1]?R:l===void 0||(((I=Sn.current)==null?void 0:I.location[0])??0)<$?void 0:f.scrollEdge})},[l,We,$]),Pu=c.useCallback((f,k)=>{Re==null||Re(f-$,k)},[Re,$]),Ou=c.useCallback((f,k)=>{we==null||we(f-$,k)},[we,$]),zn=(Ra=G==null?void 0:G.current)==null?void 0:Ra.cell,ju=c.useCallback((f,k,R,I,j,K)=>{$r.current=!1;let O=zn;O!==void 0&&(O=[O[0]-$,O[1]]);const H=qe===0?void 0:{x:0,y:f.y,width:qe,height:f.height},Y=[];H!==void 0&&Y.push(H),Dt>0&&(Y.push({x:f.x-$,y:Ee-Dt,width:f.width,height:Dt}),qe>0&&Y.push({x:0,y:Ee-Dt,width:qe,height:Dt}));const Q={x:f.x-$,y:f.y,width:f.width,height:gt&&f.y+f.height>=Ee?f.height-1:f.height,tx:j,ty:K,extras:{selected:O,freezeRegion:H,freezeRegions:Y}};Bt.current=Q,pr(Q),_n([k,R,I]),an==null||an(Q,Q.tx,Q.ty,Q.extras)},[zn,$,gt,Ee,qe,Dt,pr,an]),Nu=Cr(_,c.useCallback((f,k)=>(_==null?void 0:_(f-$,k-$))!==!1,[_,$])),Hu=Cr(je,c.useCallback((f,k)=>{je==null||je(f-$,k-$),oe!=="none"&&Be(rt.fromSingleSelection(k),void 0,!0)},[oe,je,$,Be])),rs=c.useRef(!1),Bu=c.useCallback(f=>{if(f.location[0]===0&&$>0){f.preventDefault();return}Ye==null||Ye({...f,location:[f.location[0]-$,f.location[1]]}),f.defaultPrevented()||(rs.current=!0),u(void 0)},[Ye,$]),Lu=c.useCallback(()=>{rs.current=!1},[]),ya=dt==null?void 0:dt.selectionBehavior,di=c.useCallback(f=>{if(ya!=="block-spanning")return;const{isGroupHeader:k,path:R,groupRows:I}=Fr(f);if(k)return[f,f];const j=R[R.length-1],K=f-j,O=f+I-j-1;return[K,O]},[Fr,ya]),os=c.useRef(),is=c.useCallback(f=>{var k,R,I;if(!ru(f,os.current)&&(os.current=f,!(((k=Sn==null?void 0:Sn.current)==null?void 0:k.button)!==void 0&&Sn.current.button>=1))){if(f.buttons!==0&&l!==void 0&&((R=Sn.current)==null?void 0:R.location[0])===0&&$===1&&ve==="multi"&&l.previousSelection&&!l.previousSelection.rows.hasIndex(Sn.current.location[1])&&G.rows.hasIndex(Sn.current.location[1])){const j=Math.min(Sn.current.location[1],f.location[1]),K=Math.max(Sn.current.location[1],f.location[1])+1;Ve(rt.fromSingleSelection([j,K]),void 0,!1)}else if(f.buttons!==0&&l!==void 0&&G.current!==void 0&&!rs.current&&!Fo.current&&(ut==="rect"||ut==="multi-rect")){const[j,K]=G.current.cell;let[O,H]=f.location;if(H<0&&(H=Bt.current.y),l.fillHandle===!0&&((I=l.previousSelection)==null?void 0:I.current)!==void 0){const Y=l.previousSelection.current.range;H=Math.min(H,gt?Ee-1:Ee);const Q=Zy(Y,O,H,Gt);qi(Q)}else{if(gt&&K===Ee)return;if(gt&&H===Ee)if(f.kind===Hi)H--;else return;O=Math.max(O,$);const ae=di(K);H=ae===void 0?H:Rn(H,ae[0],ae[1]);const be=O-j,ne=H-K,_e={x:be>=0?j:O,y:ne>=0?K:H,width:Math.abs(be)+1,height:Math.abs(ne)+1};Ue({...G.current,range:_e},!0,!1,"drag")}}st==null||st({...f,location:[f.location[0]-$,f.location[1]]})}},[l,$,ve,G,ut,st,Ve,gt,Ee,Gt,di,Ue]),zu=c.useCallback(()=>{var O,H;const f=os.current;if(f===void 0)return;const[k,R]=f.scrollEdge;let[I,j]=f.location;const K=Bt.current;k===-1?I=((H=(O=K.extras)==null?void 0:O.freezeRegion)==null?void 0:H.x)??K.x:k===1&&(I=K.x+K.width),R===-1?j=Math.max(0,K.y):R===1&&(j=Math.min(Ee-1,K.y+K.height)),I=Rn(I,0,Je.length-1),j=Rn(j,0,Ee-1),is({...f,location:[I,j]})},[Je.length,is,Ee]);ck(Au,St,zu);const jn=c.useCallback(f=>{if(G.current===void 0)return;const[k,R]=f,[I,j]=G.current.cell,K=G.current.range;let O=K.x,H=K.x+K.width,Y=K.y,Q=K.y+K.height;const[ae,be]=di(j)??[0,Ee-1],ne=be+1;if(R!==0)switch(R){case 2:{Q=ne,Y=j,Ft(0,Q,"vertical");break}case-2:{Y=ae,Q=j+1,Ft(0,Y,"vertical");break}case 1:{Y<j?(Y++,Ft(0,Y,"vertical")):(Q=Math.min(ne,Q+1),Ft(0,Q,"vertical"));break}case-1:{Q>j+1?(Q--,Ft(0,Q,"vertical")):(Y=Math.max(ae,Y-1),Ft(0,Y,"vertical"));break}default:Vo()}if(k!==0)if(k===2)H=Je.length,O=I,Ft(H-1-$,0,"horizontal");else if(k===-2)O=$,H=I+1,Ft(O-$,0,"horizontal");else{let _e=[];if(b!==void 0){const ye=b({x:O,y:Y,width:H-O-$,height:Q-Y},E.current.signal);typeof ye=="object"&&(_e=vk(ye))}if(k===1){let ye=!1;if(O<I){if(_e.length>0){const Le=Hr(O+1,I+1).find(Ne=>!_e.includes(Ne-$));Le!==void 0&&(O=Le,ye=!0)}else O++,ye=!0;ye&&Ft(O,0,"horizontal")}ye||(H=Math.min(Je.length,H+1),Ft(H-1-$,0,"horizontal"))}else if(k===-1){let ye=!1;if(H>I+1){if(_e.length>0){const Le=Hr(H-1,I,-1).find(Ne=>!_e.includes(Ne-$));Le!==void 0&&(H=Le,ye=!0)}else H--,ye=!0;ye&&Ft(H-$,0,"horizontal")}ye||(O=Math.max($,O-1),Ft(O-$,0,"horizontal"))}else Vo()}Ue({cell:G.current.cell,range:{x:O,y:Y,width:H-O,height:Q-Y}},!0,!1,"keyboard-select")},[b,di,G,Je.length,$,Ee,Ft,Ue]),ss=c.useRef(Yn);ss.current=Yn;const vr=c.useCallback((f,k,R,I)=>{const j=Qt-(R?0:1);f=Rn(f,$,_t.length-1+$),k=Rn(k,0,j);const K=zn==null?void 0:zn[0],O=zn==null?void 0:zn[1];if(f===K&&k===O)return!1;if(I&&G.current!==void 0){const H=[...G.current.rangeStack];(G.current.range.width>1||G.current.range.height>1)&&H.push(G.current.range),V({...G,current:{cell:[f,k],range:{x:f,y:k,width:1,height:1},rangeStack:H}},!0)}else Ue({cell:[f,k],range:{x:f,y:k,width:1,height:1}},!0,!1,"keyboard-nav");return d.current!==void 0&&d.current[0]===f&&d.current[1]===k&&(d.current=void 0),ss.current&&Ft(f-$,k),!0},[Qt,$,_t.length,zn,G,Ft,V,Ue]),Wu=c.useCallback((f,k)=>{(o==null?void 0:o.cell)!==void 0&&f!==void 0&&io(f)&&(kn([{location:o.cell,value:f}]),window.requestAnimationFrame(()=>{var j;(j=Xt.current)==null||j.damage([{cell:o.cell}])})),tn(!0),i(void 0);const[R,I]=k;if(G.current!==void 0&&(R!==0||I!==0)){const j=G.current.cell[1]===Qt-1&&f!==void 0,K=G.current.cell[0]===Je.length-1&&f!==void 0;let O=!0;if(j&&I===1&&Ae!==void 0){O=!1;const H=G.current.cell[0]+R,Y=eo(H);br(Y??H,!1)}if(K&&R===1&&Oe!==void 0){O=!1;const H=G.current.cell[1]+I;ci(H,!1)}O&&vr(Rn(G.current.cell[0]+R,0,Je.length-1),Rn(G.current.cell[1]+I,0,Qt-1),j,!1)}W==null||W(f,k)},[o==null?void 0:o.cell,tn,G,W,kn,Qt,vr,Je.length,br,ci,Ae,Oe,eo]),Gu=c.useMemo(()=>`gdg-overlay-${yk++}`,[]),Pr=c.useCallback(f=>{var R,I,j,K;tn();const k=[];for(let O=f.x;O<f.x+f.width;O++)for(let H=f.y;H<f.y+f.height;H++){const Y=M([O-$,H]);if(!Y.allowOverlay&&Y.kind!==ue.Boolean)continue;let Q;if(Y.kind===ue.Custom){const ae=Mt(Y),be=(R=ae==null?void 0:ae.provideEditor)==null?void 0:R.call(ae,{...Y,location:[O-$,H]});(ae==null?void 0:ae.onDelete)!==void 0?Q=ae.onDelete(Y):Zm(be)&&(Q=(I=be==null?void 0:be.deletedValue)==null?void 0:I.call(be,Y))}else if(io(Y)&&Y.allowOverlay||Y.kind===ue.Boolean){const ae=Mt(Y);Q=(j=ae==null?void 0:ae.onDelete)==null?void 0:j.call(ae,Y)}Q!==void 0&&!lo(Q)&&io(Q)&&k.push({location:[O,H],value:Q})}kn(k),(K=Xt.current)==null||K.damage(k.map(O=>({cell:O.location})))},[tn,M,Mt,kn,$]),_o=o!==void 0,va=c.useCallback(f=>{var Le,Ne;const k=()=>{f.stopPropagation(),f.preventDefault()},R={didMatch:!1},{bounds:I}=f,j=G.columns,K=G.rows,O=gn;if(!_o&&Ze(O.clear,f,R))V(Ri,!1),pt==null||pt();else if(!_o&&Ze(O.selectAll,f,R))V({columns:rt.empty(),rows:rt.empty(),current:{cell:((Le=G.current)==null?void 0:Le.cell)??[$,0],range:{x:$,y:0,width:C.length,height:Ee},rangeStack:[]}},!1);else if(Ze(O.search,f,R))(Ne=a==null?void 0:a.current)==null||Ne.focus({preventScroll:!0}),Jn(!0);else if(Ze(O.delete,f,R)){const Te=(nt==null?void 0:nt(G))??!0;if(Te!==!1){const ct=Te===!0?G:Te;if(ct.current!==void 0){Pr(ct.current.range);for(const $t of ct.current.rangeStack)Pr($t)}for(const $t of ct.rows)Pr({x:$,y:$t,width:C.length,height:1});for(const $t of ct.columns)Pr({x:$t,y:0,width:1,height:Ee})}}if(R.didMatch)return k(),!0;if(G.current===void 0)return!1;let[H,Y]=G.current.cell;const[,Q]=G.current.cell;let ae=!1,be=!1;if(Ze(O.scrollToSelectedCell,f,R))gi.current(H-$,Y);else if(oe!=="none"&&Ze(O.selectColumn,f,R))j.hasIndex(H)?Be(j.remove(H),void 0,!0):oe==="single"?Be(rt.fromSingleSelection(H),void 0,!0):Be(void 0,H,!0);else if(ve!=="none"&&Ze(O.selectRow,f,R))K.hasIndex(Y)?Ve(K.remove(Y),void 0,!0):ve==="single"?Ve(rt.fromSingleSelection(Y),void 0,!0):Ve(void 0,Y,!0);else if(!_o&&I!==void 0&&Ze(O.activateCell,f,R))if(Y===Ee&>)window.setTimeout(()=>{const Te=eo(H);br(Te??H)},0);else{const Te={inputType:"keyboard",key:f.key};z==null||z([H-$,Y],Te),Qr(I,Te)}else G.current.range.height>1&&Ze(O.downFill,f,R)?ba():G.current.range.width>1&&Ze(O.rightFill,f,R)?pa():Ze(O.goToNextPage,f,R)?Y+=Math.max(1,Bt.current.height-4):Ze(O.goToPreviousPage,f,R)?Y-=Math.max(1,Bt.current.height-4):Ze(O.goToFirstCell,f,R)?(i(void 0),Y=0,H=0):Ze(O.goToLastCell,f,R)?(i(void 0),Y=Number.MAX_SAFE_INTEGER,H=Number.MAX_SAFE_INTEGER):Ze(O.selectToFirstCell,f,R)?(i(void 0),jn([-2,-2])):Ze(O.selectToLastCell,f,R)?(i(void 0),jn([2,2])):_o?(Ze(O.closeOverlay,f,R)&&i(void 0),Ze(O.acceptOverlayDown,f,R)&&(i(void 0),Y++),Ze(O.acceptOverlayUp,f,R)&&(i(void 0),Y--),Ze(O.acceptOverlayLeft,f,R)&&(i(void 0),H--),Ze(O.acceptOverlayRight,f,R)&&(i(void 0),H++)):(Ze(O.goDownCell,f,R)?Y+=1:Ze(O.goUpCell,f,R)?Y-=1:Ze(O.goRightCell,f,R)?H+=1:Ze(O.goLeftCell,f,R)?H-=1:Ze(O.goDownCellRetainSelection,f,R)?(Y+=1,ae=!0):Ze(O.goUpCellRetainSelection,f,R)?(Y-=1,ae=!0):Ze(O.goRightCellRetainSelection,f,R)?(H+=1,ae=!0):Ze(O.goLeftCellRetainSelection,f,R)?(H-=1,ae=!0):Ze(O.goToLastRow,f,R)?Y=Ee-1:Ze(O.goToFirstRow,f,R)?Y=Number.MIN_SAFE_INTEGER:Ze(O.goToLastColumn,f,R)?H=Number.MAX_SAFE_INTEGER:Ze(O.goToFirstColumn,f,R)?H=Number.MIN_SAFE_INTEGER:(ut==="rect"||ut==="multi-rect")&&(Ze(O.selectGrowDown,f,R)?jn([0,1]):Ze(O.selectGrowUp,f,R)?jn([0,-1]):Ze(O.selectGrowRight,f,R)?jn([1,0]):Ze(O.selectGrowLeft,f,R)?jn([-1,0]):Ze(O.selectToLastRow,f,R)?jn([0,2]):Ze(O.selectToFirstRow,f,R)?jn([0,-2]):Ze(O.selectToLastColumn,f,R)?jn([2,0]):Ze(O.selectToFirstColumn,f,R)&&jn([-2,0])),be=R.didMatch);if(On!==void 0&&On!=="normal"&&Y!==Q){const Te=On==="skip-up"||On==="skip"||On==="block",ct=On==="skip-down"||On==="skip"||On==="block",$t=Y<Q;if($t&&Te){for(;Y>=0&&Fr(Y).isGroupHeader;)Y--;Y<0&&(Y=Q)}else if(!$t&&ct){for(;Y<Ee&&Fr(Y).isGroupHeader;)Y++;Y>=Ee&&(Y=Q)}}const _e=vr(H,Y,!1,ae),ye=R.didMatch;return ye&&(_e||!be||wn)&&k(),ye},[On,_o,G,gn,oe,ve,ut,$,Fr,Ee,vr,V,pt,C.length,nt,wn,Pr,Be,Ve,gt,eo,br,z,Qr,ba,pa,jn]),Po=c.useCallback(f=>{let k=!1;if(ze!==void 0&&ze({...f,...f.location&&{location:[f.location[0]-$,f.location[1]]},cancel:()=>{k=!0}}),k||va(f)||G.current===void 0)return;const[R,I]=G.current.cell,j=Bt.current;if(it&&!f.metaKey&&!f.ctrlKey&&G.current!==void 0&&f.key.length===1&&/[\p{L}\p{M}\p{N}\p{S}\p{P}]/u.test(f.key)&&f.bounds!==void 0&&so(M([R-$,Math.max(0,Math.min(I,Ee-1))]))){if((!gt||I!==Ee)&&(j.y>I||I>j.y+j.height||j.x>R||R>j.x+j.width))return;const K={inputType:"keyboard",key:f.key};z==null||z([R-$,I],K),Qr(f.bounds,K,f.key),f.stopPropagation(),f.preventDefault()}},[it,ze,va,G,M,$,Ee,gt,z,Qr]),Uu=c.useCallback((f,k)=>{const R=f.location[0]-$;if(f.kind==="header"&&(de==null||de(R,{...f,preventDefault:k})),f.kind===Hn){if(R<0)return;q==null||q(R,{...f,preventDefault:k})}if(f.kind==="cell"){const[I,j]=f.location;ee==null||ee([R,j],{...f,preventDefault:k}),Yp(G,f.location)||vr(I,j,!1,!1)}},[G,ee,q,de,$,vr]),as=c.useCallback(async f=>{var O,H,Y;if(!gn.paste)return;function k(Q,ae,be,ne){var ye,Le;const _e=typeof be=="object"?(be==null?void 0:be.join(`
|
|
13
|
-
`))??"":(be==null?void 0:be.toString())??"";if(!lo(Q)&&so(Q)&&Q.readonly!==!0){const Ne=J==null?void 0:J(_e,Q);if(Ne!==void 0&&io(Ne))return{location:ae,value:Ne};const Te=Mt(Q);if(Te===void 0)return;if(Te.kind===ue.Custom){pn(Q.kind===ue.Custom);const ct=(ye=Te.onPaste)==null?void 0:ye.call(Te,_e,Q.data);return ct===void 0?void 0:{location:ae,value:{...Q,data:ct}}}else{const ct=(Le=Te.onPaste)==null?void 0:Le.call(Te,_e,Q,{formatted:ne,formattedString:typeof ne=="string"?ne:ne==null?void 0:ne.join(`
|
|
14
|
-
`),rawValue:be});return ct===void 0?void 0:(pn(ct.kind===Q.kind),{location:ae,value:ct})}}}const R=G.columns,I=G.rows,j=((O=St.current)==null?void 0:O.contains(document.activeElement))===!0||((H=s.current)==null?void 0:H.contains(document.activeElement))===!0;let K;if(G.current!==void 0?K=[G.current.range.x,G.current.range.y]:R.length===1?K=[R.first()??0,0]:I.length===1&&(K=[$,I.first()??0]),j&&K!==void 0){let Q,ae;const be="text/plain",ne="text/html";if(navigator.clipboard.read!==void 0){const Ne=await navigator.clipboard.read();for(const Te of Ne){if(Te.types.includes(ne)){const $t=await(await Te.getType(ne)).text(),Lt=Ol($t);if(Lt!==void 0){Q=Lt;break}}Te.types.includes(be)&&(ae=await(await Te.getType(be)).text())}}else if(navigator.clipboard.readText!==void 0)ae=await navigator.clipboard.readText();else if(f!==void 0&&(f==null?void 0:f.clipboardData)!==null){if(f.clipboardData.types.includes(ne)){const Ne=f.clipboardData.getData(ne);Q=Ol(Ne)}Q===void 0&&f.clipboardData.types.includes(be)&&(ae=f.clipboardData.getData(be))}else return;const[_e,ye]=K,Le=[];do{if(ce===void 0){const Ne=mn(K),Te=ae??(Q==null?void 0:Q.map($t=>$t.map(Lt=>Lt.rawValue).join(" ")).join(" "))??"",ct=k(Ne,K,Te,void 0);ct!==void 0&&Le.push(ct);break}if(Q===void 0){if(ae===void 0)return;Q=nk(ae)}if(ce===!1||typeof ce=="function"&&(ce==null?void 0:ce([K[0]-$,K[1]],Q.map(Ne=>Ne.map(Te=>{var ct;return((ct=Te.rawValue)==null?void 0:ct.toString())??""}))))!==!0)return;for(const[Ne,Te]of Q.entries()){if(Ne+ye>=Ee)break;for(const[ct,$t]of Te.entries()){const Lt=[ct+_e,Ne+ye],[on,Wn]=Lt;if(on>=Je.length||Wn>=Qt)continue;const Nn=mn(Lt),Gn=k(Nn,Lt,$t.rawValue,$t.formatted);Gn!==void 0&&Le.push(Gn)}}}while(!1);kn(Le),(Y=Xt.current)==null||Y.damage(Le.map(Ne=>({cell:Ne.location})))}},[J,Mt,mn,G,gn.paste,St,Je.length,kn,Qt,ce,$,Ee]);nn("paste",as,h,!1,!0);const Oo=c.useCallback(async(f,k)=>{var O,H;if(!gn.copy)return;const R=k===!0||((O=St.current)==null?void 0:O.contains(document.activeElement))===!0||((H=s.current)==null?void 0:H.contains(document.activeElement))===!0,I=G.columns,j=G.rows,K=(Y,Q)=>{if(!Se)Nl(Y,Q,f);else{const ae=Q.map(be=>({kind:ue.Text,data:C[be].title,displayData:C[be].title,allowOverlay:!1}));Nl([ae,...Y],Q,f)}};if(R&&b!==void 0){if(G.current!==void 0){let Y=b(G.current.range,E.current.signal);typeof Y!="object"&&(Y=await Y()),K(Y,Hr(G.current.range.x-$,G.current.range.x+G.current.range.width-$))}else if(j!==void 0&&j.length>0){const Q=[...j].map(ae=>{const be=b({x:$,y:ae,width:C.length,height:1},E.current.signal);return typeof be=="object"?be[0]:be().then(ne=>ne[0])});if(Q.some(ae=>ae instanceof Promise)){const ae=await Promise.all(Q);K(ae,Hr(C.length))}else K(Q,Hr(C.length))}else if(I.length>0){const Y=[],Q=[];for(const ae of I){let be=b({x:ae,y:0,width:1,height:Ee},E.current.signal);typeof be!="object"&&(be=await be()),Y.push(be),Q.push(ae-$)}if(Y.length===1)K(Y[0],Q);else{const ae=Y.reduce((be,ne)=>be.map((_e,ye)=>[..._e,...ne[ye]]));K(ae,Q)}}}},[C,b,G,gn.copy,$,St,Ee,Se]);nn("copy",Oo,h,!1,!1);const Xu=c.useCallback(async f=>{var R,I;if(!(!gn.cut||!(((R=St.current)==null?void 0:R.contains(document.activeElement))===!0||((I=s.current)==null?void 0:I.contains(document.activeElement))===!0))&&(await Oo(f),G.current!==void 0)){let j={current:{cell:G.current.cell,range:G.current.range,rangeStack:[]},rows:rt.empty(),columns:rt.empty()};const K=nt==null?void 0:nt(j);if(K===!1||(j=K===!0?j:K,j.current===void 0))return;Pr(j.current.range)}},[Pr,G,gn.cut,Oo,St,nt]);nn("cut",Xu,h,!1,!1);const Ku=c.useCallback((f,k)=>{if($e!==void 0){$!==0&&(f=f.map(j=>[j[0]-$,j[1]])),$e(f,k);return}if(f.length===0||k===-1)return;const[R,I]=f[k];d.current!==void 0&&d.current[0]===R&&d.current[1]===I||(d.current=[R,I],vr(R,I,!1,!1))},[$e,$,vr]),[fi,hi]=((Ma=Kt==null?void 0:Kt.current)==null?void 0:Ma.cell)??[],gi=c.useRef(Ft);gi.current=Ft,c.useLayoutEffect(()=>{var f,k,R,I;ss.current&&!$r.current&&fi!==void 0&&hi!==void 0&&(fi!==((k=(f=L.current)==null?void 0:f.current)==null?void 0:k.cell[0])||hi!==((I=(R=L.current)==null?void 0:R.current)==null?void 0:I.cell[1]))&&gi.current(fi,hi),$r.current=!1},[fi,hi]);const wa=G.current!==void 0&&(G.current.cell[0]>=Je.length||G.current.cell[1]>=Qt);c.useLayoutEffect(()=>{wa&&V(Ri,!1)},[wa,V]);const Yu=c.useMemo(()=>gt===!0&&(Pe==null?void 0:Pe.tint)===!0?rt.fromSingleSelection(Qt-1):rt.empty(),[Qt,gt,Pe==null?void 0:Pe.tint]),qu=c.useCallback(f=>typeof lt=="boolean"?lt:(lt==null?void 0:lt(f-$))??!0,[$,lt]),Vu=c.useMemo(()=>{if(es===void 0||s.current===null)return null;const{bounds:f,group:k}=es,R=s.current.getBoundingClientRect();return c.createElement(UC,{bounds:f,group:k,canvasBounds:R,onClose:()=>ts(void 0),onFinish:I=>{ts(void 0),Ce==null||Ce(k,I)}})},[Ce,es]),Ju=Math.min(Je.length,qe+(Jt?1:0));c.useImperativeHandle(t,()=>({appendRow:(f,k)=>br(f+$,k),appendColumn:(f,k)=>ci(f,k),updateCells:f=>{var k;return $!==0&&(f=f.map(R=>({cell:[R.cell[0]+$,R.cell[1]]}))),(k=Xt.current)==null?void 0:k.damage(f)},getBounds:(f,k)=>{var R;if(!((s==null?void 0:s.current)===null||(St==null?void 0:St.current)===null)){if(f===void 0&&k===void 0){const I=s.current.getBoundingClientRect(),j=I.width/St.current.clientWidth;return{x:I.x-St.current.scrollLeft*j,y:I.y-St.current.scrollTop*j,width:St.current.scrollWidth*j,height:St.current.scrollHeight*j}}return(R=Xt.current)==null?void 0:R.getBounds((f??0)+$,k)}},focus:()=>{var f;return(f=Xt.current)==null?void 0:f.focus()},emit:async f=>{switch(f){case"delete":Po({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":Po({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":Po({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await Oo(void 0,!0);break;case"paste":await as();break}},scrollTo:Ft,remeasureColumns:f=>{for(const k of f)ui(k+$)},getMouseArgsForPosition:(f,k,R)=>{if((Xt==null?void 0:Xt.current)===null)return;const I=Xt.current.getMouseArgsForPosition(f,k,R);if(I!==void 0)return{...I,location:[I.location[0]-$,I.location[1]]}}}),[br,ci,ui,St,Oo,Po,as,$,Ft]);const[xa,Ca]=zn??[],Zu=c.useCallback(f=>{const[k,R]=f;if(R===-1){oe!=="none"&&(Be(rt.fromSingleSelection(k),void 0,!1),tn());return}xa===k&&Ca===R||(Ue({cell:f,range:{x:k,y:R,width:1,height:1}},!0,!1,"keyboard-nav"),Ft(k,R))},[oe,tn,Ft,xa,Ca,Ue,Be]),[Qu,ed]=c.useState(!1),ka=c.useRef(pc(f=>{ed(f)},5)),td=c.useCallback(()=>{ka.current(!0),G.current===void 0&&G.columns.length===0&&G.rows.length===0&&l===void 0&&Ue({cell:[$,oi],range:{x:$,y:oi,width:1,height:1}},!0,!1,"keyboard-select")},[oi,G,l,$,Ue]),nd=c.useCallback(()=>{ka.current(!1)},[]),[rd,od]=c.useMemo(()=>{let f;const k=(xe==null?void 0:xe.scrollbarWidthOverride)??Is(),R=Ee+(gt?1:0);if(typeof hn=="number")f=Zt+R*hn;else{let j=0;const K=Math.min(R,10);for(let O=0;O<K;O++)j+=hn(O);j=Math.floor(j/K),f=Zt+R*j}f+=k;const I=Je.reduce((j,K)=>K.width+j,0)+k;return[`${Math.min(1e5,I)}px`,`${Math.min(1e5,f)}px`]},[Je,xe==null?void 0:xe.scrollbarWidthOverride,hn,Ee,gt,Zt]),id=c.useMemo(()=>db(at),[at]);return c.createElement(fb.Provider,{value:at},c.createElement(sk,{style:id,className:he,inWidth:y??rd,inHeight:x??od},c.createElement(LC,{fillHandle:xt,drawFocusRing:ur,experimental:xe,fixedShadowX:Yt,fixedShadowY:Ir,getRowThemeOverride:rn,headerIcons:vn,imageWindowLoader:Ut,initialSize:en,isDraggable:Ln,onDragLeave:nr,onRowMoved:Tn,overscrollX:Io,overscrollY:Vr,preventDiagonalScrolling:ir,rightElement:sr,rightElementProps:cn,smoothScrollX:Er,smoothScrollY:Ur,className:he,enableGroups:Cn,onCanvasFocused:td,onCanvasBlur:nd,canvasRef:s,onContextMenu:Uu,theme:at,cellXOffset:Tu,cellYOffset:oi,accessibilityHeight:Qn.height,onDragEnd:Lu,columns:Je,nonGrowWidth:yt,drawHeader:Ht,onColumnProposeMove:Nu,drawCell:Ie,disabledRows:Yu,freezeColumns:Ju,lockColumns:$,firstColAccessible:$===0,getCellContent:mn,minColumnWidth:$n,maxColumnWidth:fn,searchInputRef:a,showSearch:To,onSearchClose:Fn,highlightRegions:Du,getCellsForSelection:b,getGroupDetails:Vi,headerHeight:mr,isFocused:Qu,groupHeaderHeight:Cn?qr:0,freezeTrailingRows:Dt+(gt&&(Pe==null?void 0:Pe.sticky)===!0?1:0),hasAppendRow:gt,onColumnResize:ge,onColumnResizeEnd:Ge,onColumnResizeStart:ke,onCellFocused:Zu,onColumnMoved:Hu,onDragStart:Bu,onHeaderMenuClick:Pu,onHeaderIndicatorClick:Ou,onItemHovered:is,isFilling:(l==null?void 0:l.fillHandle)===!0,onMouseMove:_u,onKeyDown:Po,onKeyUp:Me,onMouseDown:$u,onMouseUp:Fu,onDragOverCell:jt,onDrop:Et,onSearchResultsChanged:Ku,onVisibleRegionChanged:ju,clientSize:At,rowHeight:hn,searchResults:Z,searchValue:me,onSearchValueChange:se,rows:Qt,scrollRef:St,selection:G,translateX:Qn.tx,translateY:Qn.ty,verticalBorder:qu,gridRef:Xt,getCellRenderer:Mt,resizeIndicator:cr}),Vu,o!==void 0&&c.createElement(c.Suspense,{fallback:null},c.createElement(bk,{...o,validateCell:P,bloom:B,id:Gu,getCellRenderer:Mt,className:(xe==null?void 0:xe.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Ot,imageEditorOverride:m,portalElementRef:Kr,onFinishEditing:Wu,markdownDivCreateNode:g,isOutsideClick:Ro,customEventTarget:xe==null?void 0:xe.eventTarget}))))},xk=c.forwardRef(wk);function Ll(e){const{cell:t,posX:n,posY:r,bounds:o,theme:i}=e,{width:a,height:s,x:l,y:u}=o,d=t.maxSize??i.checkboxMaxSize,h=Math.floor(o.y+s/2),m=vc(d,s,i.cellVerticalPadding),p=yc(t.contentAlign??"center",l,a,i.cellHorizontalPadding,m),g=bc(p,h,m),y=wc(l+n,u+r,g);return Zs(t)&&y}const Ck={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??"false"},kind:ue.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>kk(e,e.cell.data,Zs(e.cell),e.cell.maxSize??e.theme.checkboxMaxSize,e.cell.hoverEffectIntensity??.35),onDelete:e=>({...e,data:!1}),onSelect:e=>{Ll(e)&&e.preventDefault()},onClick:e=>{if(Ll(e))return{...e.cell,data:iu(e.cell.data)}},onPaste:(e,t)=>{let n=$i;return e.toLowerCase()==="true"?n=!0:e.toLowerCase()==="false"?n=!1:e.toLowerCase()==="indeterminate"&&(n=Js),n===t.data?void 0:{...t,data:n}}};function kk(e,t,n,r,o){if(!n&&t===$i)return;const{ctx:i,hoverAmount:a,theme:s,rect:l,highlighted:u,hoverX:d,hoverY:h,cell:{contentAlign:m}}=e,{x:p,y:g,width:y,height:x}=l;let C=!1;if(o>0){let w=n?1-o+o*a:.4;if(t===$i&&(w*=a),w===0)return;w<1&&(C=!0,i.globalAlpha=w)}ia(i,s,t,p,g,y,x,u,d,h,r,m),C&&(i.globalAlpha=1)}const Sk=Rr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),Rk=e=>{const{bubbles:t}=e;return c.createElement(Sk,null,t.map((n,r)=>c.createElement("div",{key:r,className:"boe-bubble"},n)),c.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},Mk={getAccessibilityString:e=>Pp(e.data),kind:ue.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>{const r=t.data.reduce((o,i)=>e.measureText(i).width+o+n.bubblePadding*2+n.bubbleMargin,0);return t.data.length===0?n.cellHorizontalPadding*2:r+2*n.cellHorizontalPadding-n.bubbleMargin},draw:e=>Ik(e,e.cell.data),provideEditor:()=>e=>{const{value:t}=e;return c.createElement(Rk,{bubbles:t.data})},onPaste:()=>{}};function Ik(e,t){const{rect:n,theme:r,ctx:o,highlighted:i}=e,{x:a,y:s,width:l,height:u}=n;let d=a+r.cellHorizontalPadding;const h=[];for(const m of t){if(d>a+l)break;const p=Ki(m,o,r.baseFontFull).width;h.push({x:d,width:p}),d+=p+r.bubblePadding*2+r.bubbleMargin}o.beginPath();for(const m of h)fo(o,m.x,s+(u-r.bubbleHeight)/2,m.width+r.bubblePadding*2,r.bubbleHeight,r.roundingRadius??r.bubbleHeight/2);o.fillStyle=i?r.bgBubbleSelected:r.bgBubble,o.fill();for(const[m,p]of h.entries())o.beginPath(),o.fillStyle=r.textBubble,o.fillText(t[m],p.x+r.bubblePadding,s+u/2+xo(o,r))}function Ek(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const Tk={getAccessibilityString:()=>"",kind:ue.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:e=>{const{cell:t,col:n,row:r,ctx:o,rect:i,theme:a}=e;if(t.skeletonWidth===void 0||t.skeletonWidth===0)return;let s=t.skeletonWidth;t.skeletonWidthVariability!==void 0&&t.skeletonWidthVariability>0&&(s+=Math.round(Ek(n,r)*t.skeletonWidthVariability));const l=a.cellHorizontalPadding;s+l*2>=i.width&&(s=i.width-l*2-1);const u=t.skeletonHeight??Math.min(18,i.height-2*a.cellVerticalPadding);fo(o,i.x+l,i.y+(i.height-u)/2,s,u,a.roundingRadius??3),o.fillStyle=Br(a.textDark,.1),o.fill()},onPaste:()=>{}},Dk={getAccessibilityString:e=>e.row.toString(),kind:Mn.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:$k,measure:()=>44,draw:e=>Fk(e,e.cell.row,e.cell.checked,e.cell.markerKind,e.cell.drawHandle,e.cell.checkboxStyle),onClick:e=>{const{bounds:t,cell:n,posX:r,posY:o}=e,{width:i,height:a}=t,s=n.drawHandle?7+(i-7)/2:i/2,l=a/2;if(Math.abs(r-s)<=10&&Math.abs(o-l)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function $k(e,t){const{ctx:n,theme:r}=e,o=r.markerFontFull,i=t??{};return(i==null?void 0:i.font)!==o&&(n.font=o,i.font=o),i.deprep=Ak,n.textAlign="center",i}function Ak(e){const{ctx:t}=e;t.textAlign="start"}function Fk(e,t,n,r,o,i){const{ctx:a,rect:s,hoverAmount:l,theme:u}=e,{x:d,y:h,width:m,height:p}=s,g=n?1:r==="checkbox-visible"?.6+.4*l:l;if(r!=="number"&&g>0){a.globalAlpha=g;const y=7*(n?l:1);if(ia(a,u,n,o?d+y:d,h,o?m-y:m,p,!0,void 0,void 0,u.checkboxMaxSize,"center",i),o){a.globalAlpha=l,a.beginPath();for(const x of[3,6])for(const C of[-5,-1,3])a.rect(d+x,h+p/2+C,2,2);a.fillStyle=u.textLight,a.fill(),a.beginPath()}a.globalAlpha=1}if(r==="number"||r==="both"&&!n){const y=t.toString(),x=u.markerFontFull,C=d+m/2;r==="both"&&l!==0&&(a.globalAlpha=1-l),a.fillStyle=u.textLight,a.font=x,a.fillText(y,C,h+p/2+xo(a,x)),l!==0&&(a.globalAlpha=1)}}const _k={getAccessibilityString:()=>"",kind:Mn.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:e=>Pk(e,e.cell.hint,e.cell.icon),onPaste:()=>{}};function Pk(e,t,n){const{ctx:r,rect:o,hoverAmount:i,theme:a,spriteManager:s}=e,{x:l,y:u,width:d,height:h}=o;r.beginPath(),r.globalAlpha=i,r.rect(l+1,u+1,d,h-2),r.fillStyle=a.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const m=t!=="";let p=0;if(n!==void 0){const y=h-8,x=l+8/2,C=u+8/2;s.drawSprite(n,"normal",r,x,C,y,a,m?1:i),p=y}else{p=24;const g=12,y=m?g:i*g,x=m?0:(1-i)*g*.5,C=a.cellHorizontalPadding+4;y>0&&(r.moveTo(l+C+x,u+h/2),r.lineTo(l+C+x+y,u+h/2),r.moveTo(l+C+x+y*.5,u+h/2-y*.5),r.lineTo(l+C+x+y*.5,u+h/2+y*.5),r.lineWidth=2,r.strokeStyle=a.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=a.textMedium,r.fillText(t,p+l+a.cellHorizontalPadding+.5,u+h/2+xo(r,a)),r.beginPath()}function lu(e,t,n,r,o,i,a){e.textBaseline="alphabetic";const s=Ok(e,o,r,t,(n==null?void 0:n.fullSize)??!1);e.beginPath(),fo(e,s.x,s.y,s.width,s.height,t.roundingRadius??4),e.globalAlpha=i,e.fillStyle=(n==null?void 0:n.bgColor)??Br(t.textDark,.1),e.fill(),e.globalAlpha=1,e.fillStyle=t.textDark,e.textBaseline="middle",a==null||a("text")}function Ok(e,t,n,r,o){const i=r.cellHorizontalPadding,a=r.cellVerticalPadding;if(o)return{x:t.x+i/2,y:t.y+a/2+1,width:t.width-i,height:t.height-a-1};const s=Ki(n,e,r.baseFontFull,"alphabetic"),l=t.height-a,u=Math.min(l,s.actualBoundingBoxAscent*2.5);return{x:t.x+i/2,y:t.y+(t.height-u)/2+1,width:s.width+i*3,height:u-1}}const jk=c.lazy(async()=>await Zl(()=>import("./number-overlay-editor-DhCVhD05.js"),__vite__mapDeps([3,1,2]))),Nk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??""},kind:ue.Number,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,useLabel:!0,drawPrep:Rc,draw:e=>{const{hoverAmount:t,cell:n,ctx:r,theme:o,rect:i,overrideCursor:a}=e,{hoverEffect:s,displayData:l,hoverEffectTheme:u}=n;s===!0&&t>0&&lu(r,o,u,l,i,t,a),Ic(e,e.cell.displayData,e.cell.contentAlign)},measure:(e,t,n)=>e.measureText(t.displayData).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:void 0}),provideEditor:()=>e=>{const{isHighlighted:t,onChange:n,value:r,validatedSelection:o}=e;return c.createElement(c.Suspense,{fallback:null},c.createElement(jk,{highlight:t,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:o,onChange:i=>n({...r,data:Number.isNaN(i.floatValue??0)?0:i.floatValue})}))},onPaste:(e,t,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:e);if(!(Number.isNaN(r)||t.data===r))return{...t,data:r,displayData:n.formattedString??t.displayData}}},Hk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??""},kind:ue.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Rc,useLabel:!0,draw:e=>{const{cell:t,hoverAmount:n,hyperWrapping:r,ctx:o,rect:i,theme:a,overrideCursor:s}=e,{displayData:l,contentAlign:u,hoverEffect:d,allowWrapping:h,hoverEffectTheme:m}=t;d===!0&&n>0&&lu(o,a,m,l,i,n,s),Ic(e,l,u,h,r)},measure:(e,t,n)=>{const r=t.displayData.split(`
|
|
15
|
-
`,t.allowWrapping===!0?void 0:1);let o=0;for(const i of r)o=Math.max(o,e.measureText(i).width);return o+2*n.cellHorizontalPadding},onDelete:e=>({...e,data:""}),provideEditor:e=>({disablePadding:e.allowWrapping===!0,editor:t=>{const{isHighlighted:n,onChange:r,value:o,validatedSelection:i}=t;return c.createElement(Bp,{style:e.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:o.readonly!==!0,disabled:o.readonly===!0,altNewline:!0,value:o.data,validatedSelection:i,onChange:a=>r({...o,data:a.target.value})})}}),onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}},Bk=new Set(["path","source"]);function Lk(e){return Bk.has(e.kind)}const zk=16;function Sr(e,t=[]){return{root:{field:e},keys:t}}function Wk(e,t=[]){return{root:{instance:e},keys:t}}function Gr(e){return"field"in e.root?e.root.field:void 0}function cu(e){return"instance"in e.root?e.root.instance:void 0}function Gk(e,t){var n,r;switch(t.kind){case"value":return t.value.kind==="object"?Object.entries(t.value.properties).map(([o,i])=>[o,{kind:"value",value:i}]):[];case"object":return Object.entries(t.properties);case"instance":return Object.entries(((r=(n=e.resources)==null?void 0:n[t.name])==null?void 0:r.args)??{});default:return[]}}function Uk(e,t){if("field"in t.root)return e.cells[t.root.field]??"absent";const{instance:n}=t.root;return e.resources&&Object.hasOwn(e.resources,n)?{kind:"instance",name:n}:"absent"}function uu(e,t){const n=Uk(e,t);if(n==="absent")return{value:n};let r=n,o,i=0;for(const a of t.keys){if(o=void 0,r.kind==="instance"){if(++i>zk)return{value:"n/a"};o={instance:r.name,arg:a}}const s=Gk(e,r).find(([l])=>l===a);if(!s)return{value:"n/a"};r=s[1]}return o?{value:r,argument:o}:{value:r}}function du(e,t){return uu(e,t).value}const Xk=e=>e.replaceAll("%","%25").replaceAll("/","%2F");function In(e){return("field"in e.root?e.root.field:`@${e.root.instance}`)+e.keys.map(n=>`/${Xk(n)}`).join("")}function ca(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||!e||!t||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.hasOwn(t,r)&&ca(e[r],t[r]))}function Bs(e,t,n,r){switch(e.kind){case"instance":r.push({from:n(t),to:e.name,...e.output!==void 0&&{output:e.output}});break;case"object":for(const[o,i]of Object.entries(e.properties))Bs(i,[...t,o],n,r);break}}function Kk(e){const t=[];for(const[n,r]of Object.entries(e.cells))Bs(r,[],o=>({cell:n,path:o}),t);for(const[n,r]of Object.entries(e.resources??{}))for(const[o,i]of Object.entries(r.args??{}))Bs(i,[],a=>({instance:n,arg:o,path:a}),t);return t}function Yk(e){const t=e.resources??{};return Kk(e).filter(n=>!Object.hasOwn(t,n.to))}function qk(e){const t=e.from.path.length?` › ${e.from.path.join(" › ")}`:"";return`${"cell"in e.from?`cell ${e.from.cell}${t}`:`${e.from.instance}'s ${e.from.arg}${t}`} → ${e.to}${e.output?`.${e.output}`:""}`}function oo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Vk(e){if(!oo(e))return"an update must be an object";if(typeof e.rowId!="string")return"an update needs a rowId";if(!oo(e.cells))return"an update needs cells (use {} for none)";for(const[t,n]of Object.entries(e.cells))if(n!==null&&!(oo(n)&&typeof n.kind=="string"))return`cell ${t} must be an input or null`;if(e.resources!==void 0){if(!oo(e.resources))return"resources must be an object";for(const[t,n]of Object.entries(e.resources)){if(!ld(t))return`'${t}' isn't a valid instance name`;if(n!==null){if(!oo(n)||typeof n.uri!="string")return`instance ${t} needs a resource uri`;if(n.args!==void 0&&!oo(n.args))return`instance ${t}'s args must be an object`}}}}const zl={name:"datasets",helper:"datasetView",isFinal:()=>!0,actions:{selectRow:{effect:"ephemeral",check(e,{subject:t}){const n=e==null?void 0:e.index;return Number.isInteger(n)&&n>=0&&n<t.overview.rowCount?void 0:`no row ${String(n)}`}},showInstance:{effect:"ephemeral",check(e,{context:t}){var o;const n=e==null?void 0:e.name;if(typeof n!="string")return"an instance needs a name";const{resources:r}=((o=t.selected)==null?void 0:o.row)??{};return r&&Object.hasOwn(r,n)?void 0:`the selected row has no instance ${n}`}},proposeUpdate:{effect:"effectful",check(e,{context:t}){var i;const n=e==null?void 0:e.update,r=Vk(n);if(r)return r;const{rowId:o}=n;return o===((i=t.selected)==null?void 0:i.row.id)?void 0:"a view can only change the row it's showing"}}},props:({subject:e,context:t},n,r)=>({...r,dataset:e.dataset,overview:e.overview,selected:t.selected,selectRow:o=>n("selectRow",{index:o}),showInstance:o=>n("showInstance",{name:o}),proposeUpdate:o=>n("proposeUpdate",{update:o})})};function Jk(e,t){const n=[];for(const r of e){if(!r.providerId)continue;const{providerId:o,id:i}=r,a=(u,d)=>({value:JSON.stringify([o,i,u,d.name]),providerId:o,promptId:i,half:u,path:d.name,def:d}),s=[...r.functionParameters.map(u=>a("function",u)),...(r.executeParameters??[]).map(u=>a("execute",u))];if(s.length===0)continue;const l=Ql(r,t);n.push({key:JSON.stringify([o,i]),label:r.name,linked:l,options:s})}return n.sort((r,o)=>Number(o.linked)-Number(r.linked))}function Zk(e){var n,r;const t=new Map;for(const o of e){if(!o.providerId)continue;const{providerId:i,id:a}=o;for(const s of((n=o.inputSources)==null?void 0:n.resources)??[]){const l=JSON.stringify([i,s.uri]);t.has(l)||s.error||s.parent!==void 0||(r=s.parameters)!=null&&r.length&&t.set(l,{key:l,label:s.label,options:s.parameters.map(u=>({value:JSON.stringify(["resource",i,s.uri,u.name]),providerId:i,promptId:a,resourceUri:s.uri,path:u.name,def:u}))})}}return[...t.values()]}function Qk(e,t,n=[]){if(cd(e))return{kind:"primitive",type:e};for(const r of t){const o=r.options.find(i=>i.value===e);if(o)return{kind:"parameter",option:o}}for(const r of n){const o=r.options.find(i=>i.value===e);if(o)return{kind:"resource",option:o}}}function eS(e){return e.kind==="primitive"?"":e.option.def.name}function tS(e,t){const n=e.trim();if(t.kind==="primitive")return n?{name:n,type:t.type}:void 0;if(t.kind==="resource"){const{providerId:s,promptId:l,resourceUri:u,path:d}=t.option;return{from:{providerId:s,promptId:l,resourceUri:u,path:d},...n&&n!==t.option.def.name&&{name:n}}}const{providerId:r,promptId:o,half:i,path:a}=t.option;return{from:{providerId:r,promptId:o,half:i,path:a},...n&&n!==t.option.def.name&&{name:n}}}const nS=60;function rS(e,t=nS){return e.length>t?`${e.slice(0,t-1)}…`:e}function fu(e){return e.value.map(t=>typeof t=="string"?t:`\${${t.expr}}`).join("")}function ua(e){switch(e.kind){case"primitive":return e.value===void 0?"—":typeof e.value=="string"?JSON.stringify(e.value):String(e.value);case"template":return`"${fu(e)}"`;case"object":{const t=Object.keys(e.properties);return t.length===0?"{}":`{ ${t.join(", ")} }`}case"array":case"tuple":return`[${e.elements.length}]`;case"functionCall":return`${e.callee}(…)`;case"reference":return e.path.join(".");case"lambda":return`(${e.parameters.join(", ")}) => …`;case"raw":return e.sourceText}}function oS(e){const t=e.lastIndexOf("#");return t>=0?e.slice(t+1):e}const iS="(unsupported)";function Un(e){switch(e.kind){case"value":return rS(ua(e.value));case"object":return"{…}";case"instance":return e.output===void 0?e.name:`${e.name}.${e.output}`;case"dataset":return`= column ${e.field}`;case"input":return`= ${e.half==="execute"?"execute.":""}${e.path}`;default:return iS}}function qo(e){switch(e.kind){case"primitive":return e.value??null;case"template":return fu(e);case"object":return Object.fromEntries(Object.entries(e.properties).map(([t,n])=>[t,qo(n)]));case"array":case"tuple":return e.elements.map(qo);default:return ua(e)}}function sS({top:e,height:t,onPick:n,onFieldAdded:r,...o}){const[i,a]=c.useState(!1),s=c.useCallback(()=>a(!1),[]),{triggerRef:l,popoverRef:u,style:d}=ei({open:i,onClose:s,matchTriggerWidth:!1}),h=i&&go.createPortal(v.jsx("div",{className:"trace-column-picker dataset-column-picker",ref:u,style:d,role:"dialog","aria-label":"Add column",children:v.jsx(hu,{...o,onPick:m=>{n(m),s()},onFieldAdded:()=>{r(),s()}})}),document.body);return v.jsxs("div",{className:"dataset-add-field-slot",style:{paddingTop:e},children:[v.jsx("button",{type:"button",ref:l,className:"dataset-add-field-trigger",style:{height:t},onClick:()=>i?s():a(!0),title:"Add column","aria-label":"Add column","aria-expanded":i,children:"+"}),h]})}function hu({fields:e,instances:t,describePath:n,onPick:r,newField:o,onFieldAdded:i,onBack:a}){const[s,l]=c.useState(!1);return s?v.jsxs("div",{className:"dataset-path-tree",role:"group","aria-label":"New field",children:[v.jsx("button",{type:"button",className:"trace-header-menu-item dataset-path-tree-back",onClick:()=>l(!1),children:v.jsx("span",{className:"trace-header-menu-item-label",children:"‹ Add column"})}),v.jsx(aS,{...o,onAdded:i})]}):v.jsxs("div",{className:"dataset-path-tree",role:"group","aria-label":"Add column",children:[a&&v.jsx("button",{type:"button",className:"trace-header-menu-item dataset-path-tree-back",onClick:a,children:v.jsx("span",{className:"trace-header-menu-item-label",children:"‹ Columns"})}),e.map(u=>v.jsx(Ls,{path:Sr(u.id),label:u.def.name,depth:0,describePath:n,onPick:r},u.id)),Object.entries(t).map(([u,d])=>v.jsx(Ls,{path:Wk(u),label:`◆ ${u}`,detail:d.uri.slice(d.uri.lastIndexOf("#")+1),depth:0,describePath:n,onPick:r},`@${u}`)),v.jsx("button",{type:"button",className:"trace-header-menu-item dataset-path-tree-new",onClick:()=>l(!0),children:v.jsx("span",{className:"trace-header-menu-item-label",children:"New field…"})})]})}function aS({providerId:e,datasetId:t,prompts:n,linked:r,onAdded:o}){const[i,a]=c.useState(""),[s,l]=c.useState("string"),[u,d]=c.useState(null),[h,m]=c.useState(!1),p=c.useMemo(()=>Jk(n,r),[n,r]),g=c.useMemo(()=>Zk(n),[n]),y=Qk(s,p,g)??{kind:"primitive",type:"string"},x=tS(i,y),C=async()=>{if(!(!x||h)){m(!0);try{await dd(e,t,x),o()}catch(w){d((w==null?void 0:w.message)??String(w)),m(!1)}}};return v.jsx("div",{className:"dataset-add-field",children:v.jsxs("form",{onSubmit:w=>{w.preventDefault(),C()},children:[v.jsxs("label",{className:"dataset-add-field-row",children:[v.jsx("span",{children:"Name"}),v.jsx("input",{autoFocus:!0,"data-1p-ignore":!0,className:"add-to-dataset-name","aria-label":"Field name",value:i,placeholder:eS(y)||void 0,onChange:w=>{a(w.target.value),d(null)}})]}),v.jsxs("label",{className:"dataset-add-field-row",children:[v.jsx("span",{children:"Type"}),v.jsxs("select",{className:"add-to-dataset-name","aria-label":"Field type",value:s,onChange:w=>{l(w.target.value),d(null)},children:[ud.map(w=>v.jsx("option",{value:w,children:w},w)),p.map(w=>v.jsx("optgroup",{label:`Same type as a parameter of ${w.label}${w.linked?" (linked)":""}`,children:w.options.map(M=>v.jsxs("option",{value:M.value,children:[M.def.name,": ",Di(M.def.type.syntax,40)]},M.value))},w.key)),g.map(w=>v.jsx("optgroup",{label:`Same type as an input of resource ${w.label}`,children:w.options.map(M=>v.jsxs("option",{value:M.value,children:[M.def.name,": ",Di(M.def.type.syntax,40)]},M.value))},w.key))]})]}),u&&v.jsx("div",{className:"dataset-add-field-error",role:"alert",children:u}),v.jsx("div",{className:"dataset-add-field-actions",children:v.jsx("button",{type:"submit",className:"add-to-dataset-create",disabled:!x||h,children:"Add field"})})]})})}function Ls({path:e,label:t,detail:n,depth:r,describePath:o,onPick:i}){const[a,s]=c.useState(!1),[l,u]=c.useState(null),[d,h]=c.useState(null),m=()=>{const p=!a;s(p),p&&l===null&&o(e).then(u,g=>h(g.message))};return v.jsxs("div",{children:[v.jsxs("div",{className:"dataset-path-tree-node",style:{paddingLeft:4+r*14},children:[v.jsx("button",{type:"button",className:"dataset-column-picker-disclosure","aria-label":`${a?"Collapse":"Expand"} ${t}`,onClick:m,disabled:(l==null?void 0:l.length)===0,children:(l==null?void 0:l.length)===0?"":a?"▾":"▸"}),v.jsxs("button",{type:"button",className:"dataset-path-tree-pick",title:`Add a column at ${t}`,onClick:()=>i(e),children:[v.jsx("span",{className:"dataset-column-picker-title",children:t}),n&&v.jsx("span",{className:"dataset-column-picker-detail",children:n})]})]}),a&&v.jsxs("div",{role:"group",children:[d&&v.jsx("div",{className:"dataset-path-tree-note",children:d}),l===null&&!d&&v.jsx("div",{className:"dataset-path-tree-note",style:{paddingLeft:22+(r+1)*14},children:"Loading…"}),l==null?void 0:l.map(p=>v.jsx(Ls,{path:{root:e.root,keys:[...e.keys,p.key]},label:p.key,...p.sample&&{detail:Un(p.sample)},depth:r+1,describePath:o,onPick:i},p.key))]})]})}function lS({field:e,anchor:t,onRename:n,onDelete:r,onHide:o,rowLabel:i,onClose:a}){const[s,l]=c.useState(!1),[u,d]=c.useState((e==null?void 0:e.def.name)??""),[h,m]=c.useState(null),[p,g]=c.useState(!1),{triggerRef:y,popoverRef:x,style:C}=ei({open:!0,onClose:a,matchTriggerWidth:!1}),w=async()=>{const M=u.trim();if(!p){if(!M||M===(e==null?void 0:e.def.name))return a();g(!0);try{await n(M),a()}catch(U){m((U==null?void 0:U.message)??String(U)),g(!1)}}};return go.createPortal(v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:y,"aria-hidden":!0,style:{position:"fixed",left:t.x,top:t.y,width:t.width,height:t.height,pointerEvents:"none"}}),s?v.jsx("div",{className:"dataset-add-field dataset-add-field-popover",ref:x,style:C,role:"dialog","aria-label":"Rename field",children:v.jsxs("form",{onSubmit:M=>{M.preventDefault(),w()},children:[v.jsx("input",{autoFocus:!0,"data-1p-ignore":!0,className:"add-to-dataset-name","aria-label":"Field name",value:u,onChange:M=>{d(M.target.value),m(null)},onFocus:M=>M.target.select()}),h&&v.jsx("div",{className:"dataset-add-field-error",role:"alert",children:h}),v.jsx("div",{className:"dataset-add-field-actions",children:v.jsx("button",{type:"submit",className:"add-to-dataset-create",disabled:!u.trim()||p,children:"Rename"})})]})}):v.jsxs("div",{className:"trace-header-menu",ref:x,style:C,role:"menu",children:[v.jsx("button",{type:"button",role:"menuitem",className:"trace-header-menu-item",onClick:()=>{o(),a()},children:v.jsx("span",{className:"trace-header-menu-item-label",children:"Hide column"})}),i&&v.jsx("button",{type:"button",role:"menuitem",className:"trace-header-menu-item",onClick:()=>{i.toggle(),a()},children:v.jsx("span",{className:"trace-header-menu-item-label",children:i.isLabel?"Don't use as row label":"Use as row label"})}),e&&v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",role:"menuitem",className:"trace-header-menu-item",onClick:()=>l(!0),children:v.jsx("span",{className:"trace-header-menu-item-label",children:"Rename field…"})}),v.jsx("button",{type:"button",role:"menuitem",className:"trace-header-menu-item dataset-menu-delete",onClick:r,children:v.jsx("span",{className:"trace-header-menu-item-label",children:"Delete field"})})]})]})]}),document.body)}function cS(e,t,n){var u,d;const r=new Set(t.map(h=>h.id)),o=[],i=new Map,a=new Set;let s=!1;const l=h=>{let m=i.get(h);return m||(m={kind:"field",fieldId:h,hidden:!1,keys:[]},i.set(h,m),o.push(m)),m};for(const h of e??[]){const m=h.hidden===!0;if(!Lk(h)){o.push({kind:"unknown",spec:h,hidden:m});continue}if(h.kind==="source"){if(s)continue;s=!0,o.push({kind:"source",hidden:m});continue}const{path:p,title:g}=h,y=In(p);if(a.has(y))continue;const x=Gr(p);if(x!==void 0&&!r.has(x))continue;const[C,...w]=p.keys;if(x!==void 0&&C===void 0){a.add(y);const M=l(x);M.hidden=m,g!==void 0&&(M.title=g);continue}if(x!==void 0&&w.length===0){if((u=n[x])!=null&&u.keys.includes(C)){a.add(y),l(x).keys.push({key:C,hidden:m,...g!==void 0&&{title:g}});continue}if(!h.added)continue}a.add(y),o.push({kind:"added",path:p,hidden:m,...g!==void 0&&{title:g}})}for(const h of t){const m=l(h.id),p=new Set(m.keys.map(g=>g.key));for(const g of((d=n[h.id])==null?void 0:d.keys)??[])p.has(g)||m.keys.push({key:g,hidden:!1})}return s||o.push({kind:"source",hidden:!1}),o}const zo=e=>e?{hidden:!0}:{};function uS(e){return e.flatMap(dS)}function dS(e){switch(e.kind){case"field":return[{kind:"path",path:Sr(e.fieldId),...e.title!==void 0&&{title:e.title},...zo(e.hidden)},...e.keys.map(t=>({kind:"path",path:Sr(e.fieldId,[t.key]),...t.title!==void 0&&{title:t.title},...zo(t.hidden)}))];case"added":return[{kind:"path",path:e.path,...e.title!==void 0&&{title:e.title},...zo(e.hidden),added:!0}];case"source":return[{kind:"source",...zo(e.hidden)}];case"unknown":{const{hidden:t,...n}=e.spec;return[{...n,...zo(e.hidden)}]}}}function gu(e){if(e.kind==="field")return Sr(e.fieldId);if(e.kind==="added")return e.path}function mu(e,t){const n=e[t.index];if(n)return t.key!==void 0?n.kind==="field"?Sr(n.fieldId,[t.key]):void 0:gu(n)}function Bi(e,t,n){return e.map((r,o)=>o!==t.index?r:t.key===void 0?{...r,hidden:n}:r.kind!=="field"?r:{...r,keys:r.keys.map(i=>i.key===t.key?{...i,hidden:n}:i)})}function pu(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];const r=[...e],[o]=r.splice(t,1);return r.splice(n,0,o),r}function fS(e,t,n){return pu(e,t,n)}function hS(e,t,n,r){return e.map((o,i)=>i===t&&o.kind==="field"?{...o,keys:pu(o.keys,n,r)}:o)}function gS(e,t){var n;return((n=e[t])==null?void 0:n.kind)==="added"?e.filter((r,o)=>o!==t):e}function mS(e,t){const n=In(t);for(const[r,o]of e.entries()){const i=gu(o);if(i&&In(i)===n)return{index:r};if(o.kind==="field"){for(const{key:a}of o.keys)if(In(Sr(o.fieldId,[a]))===n)return{index:r,key:a}}}}function pS(e,t){const n=mS(e,t);if(n){let r=Bi(e,n,!1);return n.key!==void 0&&(r=Bi(r,{index:n.index},!1)),r}return[...e,{kind:"added",path:t,hidden:!1}]}function Wl(e,t,n){const r=[...n];return e.map(o=>t(o)?r.shift()??o:o)}function Gl(e){return({fgColor:t})=>`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><polyline points="${e}" fill="none" stroke="${t}" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`}const bu="disclosureCollapsed",yu="disclosureExpanded",bS={[bu]:Gl("8.75,6.75 11.9,10 8.75,13.25"),[yu]:Gl("6.75,8.75 10,11.9 13.25,8.75")},Wo={whole:240,key:160,added:200,source:96,unknown:120};function yS(e){return e.def.name}function vu(e,t){var o;const n=e.keys.at(-1);if(n!==void 0)return n;const r=Gr(e);return r===void 0?cu(e)??"":((o=t.find(i=>i.id===r))==null?void 0:o.def.name)??r}function vS(e,t){var o;const n=Gr(e);return[n===void 0?`◆ ${cu(e)}`:((o=t.find(i=>i.id===n))==null?void 0:o.def.name)??n,...e.keys].join(" › ")}function wS({fields:e,layout:t,expanded:n,shortType:r}){const o=new Map(e.map(a=>[a.id,a])),i=[];for(const[a,s]of t.entries()){if(s.hidden)continue;const l={index:a};switch(s.kind){case"field":{const u=o.get(s.fieldId);if(!u)break;const d=r(u.def.type.syntax),h=fd(u.def.type),m={id:u.id,title:u.def.name,type:d,role:"whole",path:Sr(u.id),width:Wo.whole,slot:l,...h&&{base:h}};if(s.keys.length===0){i.push(m);break}const p=yS(u),g=s.keys.filter(y=>!y.hidden);if(!n.has(u.id)||g.length===0){i.push({...m,group:p});break}for(const{key:y}of g){const x=Sr(u.id,[y]);i.push({id:In(x),title:y,group:p,role:"key",path:x,width:Wo.key,slot:{index:a,key:y}})}break}case"added":i.push({id:In(s.path),title:s.title??vu(s.path,e),role:"added",path:s.path,width:Wo.added,slot:l});break;case"source":i.push({id:"source",title:"source",role:"source",width:Wo.source,slot:l});break;case"unknown":i.push({id:`?${a}`,title:"Unknown column",type:s.spec.kind,role:"unknown",kind:s.spec.kind,width:Wo.unknown,slot:l});break}}return i}function xS(e){return(e==null?void 0:e.role)==="whole"?Gr(e.path):void 0}function CS(e){return e&&"path"in e?e.path:void 0}function wu(e,t,n){const r=[...e],[o]=r.splice(t,1);return r.splice(n,0,o),r}function xu(e,t,n){const r=e[t];if(!r||!e[n])return!1;if(t===n)return!0;if(r.role==="key"){const s=e[n];return s.role==="key"&&s.slot.index===r.slot.index}const o=wu(e,t,n),i=new Set;let a;for(const s of o){const l=s.role==="key"?s.slot.index:void 0;if(l!==a){if(a!==void 0&&i.add(a),l!==void 0&&i.has(l))return!1;a=l}}return!0}function kS(e,t,n,r){const o=t[n];if(!o||n===r||!xu(t,n,r))return e;const i=wu(t,n,r),{index:a}=o.slot,s=e[a];if(o.role==="key"&&(s==null?void 0:s.kind)==="field"){const d=i.flatMap(p=>p.role==="key"&&p.slot.index===a?[p.slot.key]:[]),h=new Set(d),m=Wl(s.keys,p=>h.has(p.key),d.flatMap(p=>s.keys.filter(g=>g.key===p)));return e.map((p,g)=>g===a?{...s,keys:m}:p)}const l=[];for(const d of i)l.at(-1)!==d.slot.index&&l.push(d.slot.index);const u=new Set(l);return Wl(e.map((d,h)=>h),d=>u.has(d),l).map(d=>e[d])}function SS(e){const t=new Map;for(const n of e){const r="path"in n?Gr(n.path):void 0;n.group!==void 0&&r!==void 0&&(t.has(n.group)||t.set(n.group,r))}return t}function RS(e,t,n){const r=t.get(e);return r===void 0?{name:e}:{name:e,icon:n.has(r)?yu:bu}}function MS(e){const t=typeof e;return t==="string"||t==="number"||t==="boolean"?t:void 0}function Qo(e,t){if(!e||!t)return;if(t.role==="added")return IS(e,t.path);if(t.role!=="whole"||!t.base)return;const{base:n}=t,r=Gr(t.path);if(r===void 0)return;const o=e.cells[r];if(!o)return{base:n,fieldId:r};if(o.kind!=="value"||o.value.kind!=="primitive")return;const{value:i}=o.value;return typeof i===n?{base:n,fieldId:r,value:i}:void 0}function IS(e,t){var s;const{value:n,argument:r}=uu(e,t),o=r&&((s=e.resources)==null?void 0:s[r.instance]);if(!r||!o||typeof n!="object"||n.kind!=="value"||n.value.kind!=="primitive")return;const{value:i}=n.value,a=MS(i);if(a)return{base:a,instance:r.instance,arg:r.arg,spec:o,value:i}}function Cu(e,t){return t==null||t===""?!0:e==="number"?typeof t=="number"&&Number.isFinite(t):typeof t===e}function ES(e,t){if(Cu(e,t))return ec({kind:"primitive",value:t??void 0})}function ku(e){return"fieldId"in e?{fieldId:e.fieldId}:{instance:e.instance,arg:e.arg,spec:e.spec}}function TS(e,t,n){const r=[];for(const{col:o,row:i,value:a}of e){const s=n(i),l=s&&Qo(s,t[o]);if(!l)continue;const u=ES(l.base,a);u===void 0||u===null&&!("fieldId"in l)||r.push({rowId:s.id,...ku(l),cell:u})}return r}function DS(e,t,n){const r=[];for(const{x:o,y:i,width:a,height:s}of e)for(let l=i;l<i+s;l++){const u=n(l);for(let d=o;d<o+a;d++){const h=u&&Qo(u,t[d]);h&&"fieldId"in h&&h.value!==void 0&&r.push({rowId:u.id,...ku(h),cell:null})}}return r}function $S(e){const t=new Map;for(const n of e){const{rowId:r,cell:o}=n;let i=t.get(r);if(i||(i={rowId:r,cells:{}},t.set(r,i)),"fieldId"in n){i.cells[n.fieldId]=o;continue}const a=i.resources??{};i.resources=a;const s=a[n.instance]??n.spec,{args:l,...u}=s,d={...s.args};o===null?delete d[n.arg]:d[n.arg]=o,a[n.instance]={...u,...Object.keys(d).length>0&&{args:d}}}return[...t.values()]}function Su(e,t){const n={...e.cells};for(const[a,s]of Object.entries(t.cells))s===null?delete n[a]:n[a]=s;if(!t.resources)return{...e,cells:n};const r={...e.resources};for(const[a,s]of Object.entries(t.resources))s===null?delete r[a]:r[a]=s;const{resources:o,...i}=e;return{...i,cells:n,...Object.keys(r).length>0&&{resources:r}}}function AS(e){const t=Object.entries(e.properties);return t.length===0?"{}":`{ ${t.map(([n,r])=>`${n}: ${r.kind==="instance"?`◆ ${Un(r)}`:Un(r)}`).join(", ")} }`}function FS(e){const t=Object.entries(e.properties);return t.length===0?"{}":`{ ${t.map(([n,r])=>`${n}: ${ua(r)}`).join(", ")} }`}function _S(e){switch(e.kind){case"instance":return{kind:"chip",text:`◆ ${Un(e)}`};case"object":return{kind:"text",text:AS(e)};default:return{kind:"text",text:e.kind==="value"&&e.value.kind==="object"?FS(e.value):Un(e)}}}function PS(e,t){var n,r;if(!t)return{kind:"empty"};if(!e)return{kind:"loading"};switch(t.role){case"source":return((n=e.source)==null?void 0:n.kind)==="trace"?{kind:"text",text:"trace ↗",tone:"link"}:((r=e.source)==null?void 0:r.kind)==="playground"?{kind:"text",text:"playground",tone:"dim"}:{kind:"empty"};case"unknown":return{kind:"unknown"};default:{const o=du(e,t.path),i=Qo(e,t);return i?{kind:"edit",base:i.base,value:i.value,text:typeof o=="object"?Un(o):"—"}:o==="absent"?{kind:"empty"}:o==="n/a"?{kind:"n/a"}:_S(o)}}}function Cs(e,t){const n=du(e,t);if(typeof n!="string"){if(n.kind==="value"&&n.value.kind==="primitive"){const{value:r}=n.value;return r==null||r===""?void 0:String(r)}return Un(n)}}class OS{constructor(t,n,r,o=100,i=20){Xe(this,"pages",new Map);Xe(this,"inFlight",new Map);Xe(this,"generation",0);Xe(this,"focus",{first:0,last:0});Xe(this,"fetchRows");Xe(this,"onLoad");Xe(this,"onError");Xe(this,"pageSize");Xe(this,"maxPages");this.fetchRows=t,this.onLoad=n,this.onError=r,this.pageSize=o,this.maxPages=i}get(t){const n=this.pages.get(Math.floor(t/this.pageSize));return n==null?void 0:n.rows[t%this.pageSize]}async rowsAt(t){const n=new Set(t.filter(o=>!this.get(o)).map(o=>Math.floor(o/this.pageSize))),r=new Map(await Promise.all(Array.from(n,async o=>[o,await this.fetchRows(o*this.pageSize,this.pageSize)])));return t.flatMap(o=>{var a;const i=this.get(o)??((a=r.get(Math.floor(o/this.pageSize)))==null?void 0:a[o%this.pageSize]);return i?[i]:[]})}ensure(t,n){var i;if(n<=t)return;const r=Math.floor(t/this.pageSize),o=Math.floor((n-1)/this.pageSize);this.focus={first:r,last:o};for(let a=r;a<=o;a++)((i=this.pages.get(a))==null?void 0:i.generation)!==this.generation&&this.inFlight.get(a)!==this.generation&&this.load(a)}patch(t){const n=new Map(t.map(o=>[o.rowId,o])),r=this.generation++;for(const[o,i]of this.pages){let a;i.rows.forEach((s,l)=>{const u=n.get(s.id);u&&(a??(a=[...i.rows]),a[l]=Su(s,u))}),a?this.pages.set(o,{rows:a,generation:this.generation}):i.generation===r&&this.pages.set(o,{...i,generation:this.generation})}}invalidate(){this.generation++}evict(){if(this.pages.size<=this.maxPages)return;const{first:t,last:n}=this.focus,r=i=>i<t?t-i:i>n?i-n:0,o=[...this.pages.keys()].sort((i,a)=>r(a)-r(i));for(const i of o.slice(0,this.pages.size-this.maxPages))r(i)>0&&this.pages.delete(i)}load(t){const n=this.generation;this.inFlight.set(t,n);const r=t*this.pageSize;this.fetchRows(r,this.pageSize).then(o=>{this.inFlight.get(t)===n&&this.inFlight.delete(t);const i=this.pages.get(t);i&&i.generation>n||(this.pages.set(t,{rows:o,generation:n}),this.evict(),this.onLoad(r,r+o.length))},o=>{this.inFlight.get(t)===n&&this.inFlight.delete(t),this.onError(o instanceof Error?o:new Error(String(o)))})}}const Ru={expanded:new Set,widths:{}};function jS(e,t){return`dataset-layout:${e}:${t}`}function NS(e){if(typeof e!="object"||e===null)return Ru;const{expanded:t,widths:n}=e,r={};if(typeof n=="object"&&n!==null)for(const[o,i]of Object.entries(n))typeof i=="number"&&Number.isFinite(i)&&i>0&&(r[o]=i);return{expanded:new Set(Array.isArray(t)?t.filter(o=>typeof o=="string"):[]),widths:r}}function HS(e,t){const n=new Set(e.expanded);n.delete(t);const r=Object.fromEntries(Object.entries(e.widths).filter(([o])=>o!==t&&!o.startsWith(`${t}/`)));return{expanded:n,widths:r}}function BS(e){return JSON.stringify({expanded:[...e.expanded],widths:e.widths})}const Ul=e=>e.key===void 0?`${e.index}`:`${e.index}/${e.key}`;function LS({layout:e,fields:t,instances:n,rowLabel:r,onChange:o,onRowLabel:i,onAdd:a,onRemove:s,describePath:l,newField:u,onFieldAdded:d}){const[h,m]=c.useState(!1),[p,g]=c.useState(!1),[y,x]=c.useState(null),[C,w]=c.useState(null),[M,U]=c.useState(new Set),z=()=>{m(!1),g(!1)},{triggerRef:A,popoverRef:W,style:J}=ei({open:h,onClose:z,matchTriggerWidth:!1}),S=y??e,F=r&&In(r),B=X=>{var ee;return((ee=t.find(he=>he.id===X))==null?void 0:ee.def.name)??X},N=X=>{if(!C||!y)return!1;if(C.key===void 0&&X.key===void 0)return X.index!==C.index&&(x(fS(y,C.index,X.index)),w({index:X.index})),!0;const ee=y[C.index];if(C.key===void 0||X.key===void 0||X.index!==C.index||(ee==null?void 0:ee.kind)!=="field")return!1;if(X.key!==C.key){const he=ee.keys.findIndex(te=>te.key===C.key),de=ee.keys.findIndex(te=>te.key===X.key);x(hS(y,C.index,he,de))}return!0},_=()=>{y&&y!==e&&o(y),x(null),w(null)},D=({slot:X,title:ee,detail:he,hidden:de,removable:te,disclosure:q,dim:Ce})=>{const ie=Ul(X),re=mu(S,X),$e=!!re&&In(re)===F;return v.jsxs("div",{className:`trace-column-picker-row dataset-column-picker-row${X.key!==void 0?" dataset-column-picker-key":""}${C&&Ul(C)===ie?" trace-column-picker-row-dragging":""}${Ce?" dataset-column-picker-dim":""}`,onDragOver:Z=>{N(X)&&Z.preventDefault()},onDrop:Z=>Z.preventDefault(),children:[v.jsx("span",{className:"trace-column-picker-grab",draggable:!0,onDragStart:Z=>{Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("text/plain",ie),x(e),w(X)},onDragEnd:_,title:"Drag to reorder",children:v.jsx(gd,{})}),q?v.jsx("button",{type:"button",className:"dataset-column-picker-disclosure","aria-label":`${q.open?"Hide":"Show"} ${ee}'s keys`,"aria-expanded":q.open,onClick:q.toggle,children:q.open?"▾":"▸"}):X.key===void 0&&v.jsx("span",{className:"dataset-column-picker-disclosure"}),v.jsxs("label",{className:"trace-column-picker-check",children:[v.jsx("input",{type:"checkbox","aria-label":`Show ${ee}`,checked:!de,onChange:()=>o(Bi(e,X,!de))}),v.jsx("span",{className:"dataset-column-picker-title",children:ee}),he&&v.jsx("span",{className:"dataset-column-picker-detail",children:he})]}),re&&v.jsxs("span",{className:"dataset-column-picker-actions",children:[te&&v.jsx("button",{type:"button",className:"dataset-column-picker-icon-btn","aria-label":`Remove column ${ee}`,title:"Remove column",onClick:()=>s(X.index),children:"✕"}),v.jsx("button",{type:"button",className:`dataset-column-picker-icon-btn${$e?" dataset-column-picker-icon-btn-on":""}`,"aria-label":`Use ${ee} as row label`,"aria-pressed":$e,title:$e?"Don't use as row label":"Use as row label",onClick:()=>i($e?void 0:re),children:v.jsx(md,{filled:$e})})]})]},ie)},fe=(X,ee)=>{const he={index:ee};switch(X.kind){case"field":{const de=M.has(X.fieldId),te=D({slot:he,title:B(X.fieldId),hidden:X.hidden,...X.keys.length>0&&{disclosure:{open:de,toggle:()=>{const q=new Set(M);q.delete(X.fieldId)||q.add(X.fieldId),U(q)}}}});return de?[te,...X.keys.map(q=>D({slot:{index:ee,key:q.key},title:q.key,hidden:q.hidden}))]:te}case"added":return D({slot:he,title:X.title??vu(X.path,t),detail:vS(X.path,t),hidden:X.hidden,removable:!0});case"source":return D({slot:he,title:"source",hidden:X.hidden});case"unknown":return D({slot:he,title:"Unknown column",detail:X.spec.kind,hidden:X.hidden,dim:!0})}};return v.jsxs(v.Fragment,{children:[v.jsxs("button",{ref:A,type:"button",className:`trace-view-prompt-btn${h?" dataset-columns-btn-active":""}`,title:"Show, hide, reorder and add columns","aria-label":"Columns","aria-expanded":h,onClick:()=>h?z():m(!0),children:[v.jsx(hd,{}),"Columns",v.jsx(tc,{})]}),h&&go.createPortal(v.jsx("div",{className:"trace-column-picker dataset-column-picker",ref:W,style:J,role:"dialog","aria-label":"Columns",children:p?v.jsx(hu,{fields:t,instances:n,describePath:l,onPick:X=>{a(X),g(!1)},newField:u,onFieldAdded:()=>{d(),g(!1)},onBack:()=>g(!1)}):v.jsxs(v.Fragment,{children:[S.flatMap((X,ee)=>fe(X,ee)),v.jsx("button",{type:"button",className:"trace-header-menu-item dataset-column-picker-add",onClick:()=>g(!0),children:v.jsx("span",{className:"trace-header-menu-item-label",children:"Add column…"})})]})}),document.body)]})}function zS(e){var r;const t=new Map,n=(o,i)=>{for(const a of o){const s=i==null?void 0:i[a.path];if(!(s!=null&&s.length))continue;const l=t.get(a.type.syntax)??[];t.set(a.type.syntax,[...new Set([...l,...s])])}};for(const{functionParameters:o,executeParameters:i,inputSources:a}of e)if(a){n(Mi(o),a.functionSlots),n(Mi(i??[]),a.executeSlots);for(const s of a.resources)s.parameters&&n(Mi(s.parameters),(r=a.resourceSlots)==null?void 0:r[s.uri])}return t}function WS(e,t,n=[]){const r=[...t?[t]:[],...n.filter(u=>!Ql(u,t)&&(!(t!=null&&t.providerId)||u.providerId===t.providerId))].filter(u=>u.inputSources);if(r.length===0)return;const o=t!=null&&t.inputSources?[{defs:t.functionParameters,slots:t.inputSources.functionSlots},{defs:t.executeParameters??[],slots:t.inputSources.executeSlots}]:[],i=zS(r),a={};for(const u of e){const d=Ia(u.def),h=o.find(g=>g.defs.some(y=>Ia(y)===d)),m=u.def.name,p=h?Object.fromEntries(Object.entries(h.slots).filter(([g])=>g===m||g.startsWith(`${m}.`))):{};for(const g of Mi([u.def])){const y=i.get(g.type.syntax);y&&(p[g.path]=[...new Set([...p[g.path]??[],...y])])}Object.keys(p).length>0&&(a[u.id]=p)}const s=new Map,l={};for(const{inputSources:u}of r){for(const d of(u==null?void 0:u.resources)??[])s.has(d.uri)||s.set(d.uri,d);for(const[d,h]of Object.entries((u==null?void 0:u.resourceSlots)??{}))l[d]??(l[d]=h)}return{resources:[...s.values()],fieldSlots:a,resourceSlots:l}}function ks(e){const t={};for(const[n,r]of Object.entries(e.cells))t[n]=pd(r);return{selections:t,instances:bd(e.resources)}}function GS(e,t,n){const r={};for(const s of e){const l=yd(t.selections[s]),u=(l==null?void 0:l.kind)==="value"?ec(l.value):l??null;Uo(u)!==Uo(n.cells[s]??null)&&(r[s]=u)}const o=n.resources??{},i=vd(t.instances)??{},a={};for(const s of new Set([...Object.keys(o),...Object.keys(i)])){const l=i[s]??null,{receipt:u,...d}=o[s]??{uri:""};Uo(l)!==Uo(o[s]?d:null)&&(a[s]=l)}return{cells:r,...Object.keys(a).length>0&&{resources:a}}}function US(e){const t=Object.fromEntries(Object.entries(e.resources??{}).map(([n,{receipt:r,...o}])=>[n,structuredClone(o)]));return{cells:structuredClone(e.cells),...Object.keys(t).length>0&&{resources:t}}}function XS(e){return Object.keys(e.cells).length>0||Object.keys(e.resources??{}).length>0}function Xl(e){const t=n=>Object.fromEntries(Object.entries(n).flatMap(([r,o])=>o.resources&&Object.keys(o.resources).length>0?[[r,o.resources]]:[]));return Uo([t(e.selections),Object.entries(e.instances).map(([n,r])=>[n,r.uri,t(r.args)])])}function Uo(e){return JSON.stringify(e,(t,n)=>n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort(([r],[o])=>r<o?-1:r>o?1:0)):n)}function KS({value:e}){return e.kind==="primitive"&&typeof e.value=="string"||e.kind==="template"?v.jsx("div",{className:"dataset-detail-text",children:qo(e)}):e.kind==="object"||e.kind==="array"||e.kind==="tuple"?v.jsx(Dd,{data:qo(e)}):v.jsx("code",{className:"dataset-detail-scalar",children:String(qo(e))})}function Mu({inputs:e}){return v.jsx("div",{className:"dataset-detail-keys",children:Object.entries(e).map(([t,n])=>v.jsxs("div",{className:"dataset-detail-key-row",children:[v.jsx("span",{className:"dataset-detail-key",children:t}),v.jsx(Iu,{input:n})]},t))})}function Iu({input:e}){switch(e.kind){case"value":return v.jsx(KS,{value:e.value});case"object":return v.jsx(Mu,{inputs:e.properties});case"instance":return v.jsxs("span",{className:"dataset-cell-chip",children:[v.jsx("span",{className:"dataset-cell-chip-icon","aria-hidden":!0,children:"◆"}),Un(e)]});case"dataset":case"input":return v.jsx("code",{className:"dataset-detail-scalar",children:Un(e)});default:return v.jsx("span",{className:"dataset-detail-scalar",children:Un(e)})}}const YS=[];function qS({row:e}){const t=Object.entries(e.resources??{});return t.length===0?null:v.jsx(Ms,{label:v.jsx("span",{className:"dataset-detail-field",children:"Resources"}),children:v.jsx("div",{className:"dataset-detail-keys",children:t.map(([n,r])=>v.jsxs("div",{className:"dataset-detail-key-row",children:[v.jsxs("span",{className:"dataset-detail-key",children:["◆ ",n]}),v.jsxs("div",{className:"dataset-detail-resource",children:[v.jsx("span",{className:"dataset-cell-chip",title:r.uri,children:oS(r.uri)}),r.args&&Object.keys(r.args).length>0&&v.jsx(Mu,{inputs:r.args})]})]},n))})})}function VS({fields:e,row:t,sources:n,onChangeRow:r}){const o=(n==null?void 0:n.resources)??YS,i=c.useMemo(()=>new Map(o.map(S=>[S.uri,S])),[o]),[a,s]=c.useState(()=>ks(t)),l=c.useRef(a),[u,d]=c.useState(!1),[h,m]=c.useState(t);if(h!==t&&(m(t),!u)){const S=ks(t);l.current=S,s(S)}const p=S=>{const F=t.cells[S.id];return!!r&&(!!n||!F||F.kind==="value")},g=e.filter(p).map(S=>S.id),y=S=>{d(!1);const F=GS(g,n?S:{...S,instances:ks(t).instances},t);XS(F)&&(r==null||r(F))},x=S=>{const F=l.current,B=typeof S=="function"?S(F):S;l.current=B,s(B),Xl(B)!==Xl(F)?y(B):d(!0)},C=()=>{u&&y(l.current)},w=S=>{S.key!=="Enter"||S.shiftKey||S.defaultPrevented||S.nativeEvent.isComposing||(S.preventDefault(),C())},M=c.useRef(C);M.current=C,c.useEffect(()=>()=>M.current(),[]);const{instances:U}=a,z=c.useMemo(()=>({resources:kd(o,U),functionSlots:{},executeSlots:{},resourceSlots:Object.fromEntries(Object.entries((n==null?void 0:n.resourceSlots)??{}).map(([S,F])=>[S,Ea(F,o,U)]))}),[o,U,n]),A=(S,F)=>x(B=>{const N=typeof S=="function"?S(B.instances):S;if(!F)return{...B,instances:N};const[_,D]=F.kind==="rename"?[F.from,F.to]:[F.name,null];return{instances:N,selections:Td(B.selections,_,D)}}),W=Id({instances:U,catalogByUri:i,adopt:S=>{const F=Ed(l.current.instances,S,i),N={...l.current,instances:F.instances};return l.current=N,s(N),d(!0),F.uri}}),J=!!r&&!!n;return v.jsxs(v.Fragment,{children:[e.map(S=>{const F=t.cells[S.id];return v.jsx(Ms,{label:v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"dataset-detail-field",children:S.def.name}),v.jsx("span",{className:"dataset-detail-type",title:S.def.type.syntax,children:Di(S.def.type.syntax,32)})]}),children:v.jsxs("div",{className:"dataset-detail-cell",children:[p(S)?v.jsx("div",{className:"dataset-detail-editor",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||C()},onKeyDown:w,children:v.jsx(Sd,{propDef:S.def,selection:a.selections[S.id]??{},onChange:B=>x(N=>({...N,selections:{...N.selections,[S.id]:B}})),resources:z.resources,slots:Ea(n==null?void 0:n.fieldSlots[S.id],o,U),context:n&&W})}):F?v.jsx(Iu,{input:F}):v.jsx("span",{className:"dataset-cell-empty",children:"—"}),r&&F&&v.jsx("button",{type:"button",className:"dataset-detail-clear",title:`Clear ${S.def.name}`,"aria-label":`Clear ${S.def.name}`,onClick:()=>r({cells:{[S.id]:null}}),children:"×"})]})},S.id)}),J?v.jsx(Ms,{label:v.jsx("span",{className:"dataset-detail-field"}),children:v.jsx("div",{className:"dataset-detail-editor",onBlur:S=>{S.currentTarget.contains(S.relatedTarget)||C()},onKeyDown:w,children:v.jsx(Rd,{instances:U,onChange:A,sources:z,catalog:o,referencedBy:S=>Md(S,U,[{selections:Object.fromEntries(e.flatMap(F=>a.selections[F.id]?[[F.def.name,a.selections[F.id]]]:[]))}]),context:W})})}):v.jsx(qS,{row:t})]})}function JS({dataset:e,row:t,onOpenTrace:n,onChangeRow:r,sources:o}){const i=[{label:"Added",icon:v.jsx(rc,{}),value:nc(t.createdAt)}],{source:a}=t;return a&&i.push({label:"Source",icon:v.jsx(wd,{}),value:a.kind==="trace"?v.jsx("button",{type:"button",className:"dataset-link-btn",onClick:()=>n(a.traceProviderId,a.traceId),title:"Open the trace this row came from",children:"trace ↗"}):"playground"}),v.jsx("div",{className:"span-details",children:v.jsxs("div",{className:"span-details-list",children:[v.jsx(xd,{children:v.jsx(Cd,{facts:i})}),v.jsx(VS,{fields:e.fields,row:t,sources:o,onChangeRow:r},t.id)]})})}function ZS(e){const[t,n]=c.useState(!1),r=()=>n(!1),{triggerRef:o,popoverRef:i,style:a}=ei({open:t,onClose:r,matchTriggerWidth:!1});return v.jsxs(v.Fragment,{children:[v.jsxs("button",{type:"button",ref:o,className:"trace-view-prompt-btn dataset-eval-btn",onClick:()=>n(s=>!s),"aria-haspopup":"menu","aria-expanded":t,title:"Run an eval on this dataset, or set up a new one",children:[v.jsx(oc,{size:14}),"Evals",v.jsx(tc,{})]}),t&&go.createPortal(v.jsx("div",{className:"trace-header-menu",ref:i,style:a,role:"menu",children:v.jsx(Eu,{...e,onChosen:r})}),document.body)]})}function Eu({evals:e,selectedRows:t,onRun:n,onNewEval:r,onChosen:o}){const i=t>0?` on ${t} row${t===1?"":"s"}`:"";return v.jsxs(v.Fragment,{children:[e.map(a=>v.jsxs("button",{type:"button",role:"menuitem",className:"trace-header-menu-item",onClick:()=>{o(),n(a)},children:[v.jsx("span",{className:"trace-header-menu-item-icon",children:"▶"}),v.jsxs("span",{className:"trace-header-menu-item-label",children:["Run ",a.name,i]})]},`${a.providerId}/${a.id}`)),r&&v.jsxs(v.Fragment,{children:[e.length>0&&v.jsx("hr",{className:"ask-agent-menu-divider"}),v.jsxs("button",{type:"button",role:"menuitem",className:"trace-header-menu-item",onClick:()=>{o(),r()},children:[v.jsx("span",{className:"trace-header-menu-item-icon",children:v.jsx(oc,{size:14})}),v.jsx("span",{className:"trace-header-menu-item-label",children:"New eval…"})]})]})]})}const jr=30;function QS({rowCount:e,getRow:t,ensure:n,label:r,selected:o,onSelect:i}){const a=c.useRef(null),[s,l]=c.useState({start:0,end:40}),u=()=>{const h=a.current;if(!h)return;const m=Math.floor(h.scrollTop/jr),p=m+Math.ceil(h.clientHeight/jr)+1;l(g=>g.start===m&&g.end===p?g:{start:m,end:p})};c.useEffect(u,[]),c.useEffect(()=>{n(s.start,Math.min(s.end,e))},[n,s,e]),c.useEffect(()=>{const h=a.current;if(!h||o===null)return;const m=o*jr;m<h.scrollTop?h.scrollTop=m:m+jr>h.scrollTop+h.clientHeight&&(h.scrollTop=m+jr-h.clientHeight)},[o]);const d=[];for(let h=s.start;h<Math.min(s.end,e);h++){const m=t(h),p=m?r(m):void 0;d.push(v.jsxs("div",{role:"option",tabIndex:-1,"aria-selected":h===o,className:`dataset-row-list-item${h===o?" dataset-row-list-item-selected":""}`,style:{top:h*jr},onClick:()=>i(h),children:[v.jsx("span",{className:"dataset-row-list-number",children:h+1}),v.jsx("span",{className:"dataset-row-list-label",children:m?p??`Row ${h+1}`:"…"})]},h))}return v.jsx("div",{ref:a,className:"dataset-row-list",role:"listbox","aria-label":"Rows",tabIndex:0,onScroll:u,onKeyDown:h=>{if(e===0)return;const m=h.key==="ArrowDown"?1:h.key==="ArrowUp"?-1:0;if(!m)return;h.preventDefault();const p=Math.min(e-1,Math.max(0,(o??-m)+m));p!==o&&i(p)},children:v.jsx("div",{className:"dataset-row-list-inner",style:{height:e*jr},children:d})})}function eR({viewLabel:e,rowName:t,stale:n,onSave:r,onDiscard:o}){return v.jsxs("div",{className:`row-draft-bar${n?" row-draft-bar-stale":""}`,role:"status",children:[v.jsx("span",{className:"row-draft-bar-text",children:n?`${t} changed since you started editing it in ${e}. Discard and redo the changes.`:`Unsaved changes to ${t} from ${e}`}),v.jsx("button",{type:"button",className:"dialog-btn-cancel",onClick:o,children:"Discard"}),v.jsx("button",{type:"button",className:"dialog-btn-create",onClick:r,disabled:n,children:"Save"})]})}function tR(e,t){const n=e.resources||t.resources?{...e.resources,...t.resources}:void 0;return{rowId:e.rowId,cells:{...e.cells,...t.cells},...n&&{resources:n}}}function nR(e,t,n){return e&&e.rowId===n.rowId?{...e,update:tR(e.update,n)}:{rowId:t.id,base:t,update:n}}function zs(e){return Su(e.base,e.update)}function Kl(e,t){return t!==void 0&&!ca(t,e.base)}function Ti(e){return!!e&&!ca(zs(e),e.base)}function rR(e,t){return(e==null?void 0:e.rowId)===t&&Ti(e)?e.base:void 0}const oR='"Geist Mono", ui-monospace, monospace';function Yl(){const e=getComputedStyle(document.documentElement),t=r=>e.getPropertyValue(r).trim(),n=getComputedStyle(document.body).fontFamily;return{accentColor:t("--link"),accentLight:t("--accent-faint"),textDark:t("--trace-text"),textMedium:t("--trace-text-dim"),textLight:t("--trace-text-dim"),textHeader:t("--trace-text"),textGroupHeader:t("--trace-text-dim"),fgIconHeader:t("--trace-text-dim"),textBubble:t("--pill-text"),bgCell:t("--trace-bg"),bgCellMedium:t("--trace-row-alt"),bgHeader:t("--trace-bg"),bgHeaderHasFocus:t("--trace-row-alt"),bgHeaderHovered:t("--trace-row-hover"),bgGroupHeader:t("--trace-bg"),bgGroupHeaderHovered:t("--trace-row-hover"),bgBubble:t("--pill-hover-bg"),bgBubbleSelected:t("--pill-hover-bg"),borderColor:t("--trace-border"),horizontalBorderColor:t("--trace-border"),linkColor:t("--link"),fontFamily:n,baseFontStyle:"12.5px",headerFontStyle:"600 11.5px",markerFontStyle:"11px",editorFontSize:"12.5px"}}function iR(){const[e,t]=c.useState(Yl);return c.useEffect(()=>$d(()=>t(Yl())),[]),e}const sR=[Dk,Hk,Nk,Ck,Mk,Tk,_k];function ql(e){switch(e.kind){case ue.Text:case ue.Number:case ue.Boolean:return{value:e.data};default:return}}const aR={setWindow:()=>{},loadOrGetImage:()=>{},setCallback:()=>{}};function Vl(e){try{const t=localStorage.getItem(e);if(t)return NS(JSON.parse(t))}catch{}return Ru}function lR(e,t){try{localStorage.setItem(e,BS(t))}catch{}}function cR(e){try{localStorage.removeItem(e)}catch{}}const Jl=32,Ss=32,Rs=26,uR=300,dR=[],fR=[],hR=[],Go={columns:rt.empty(),rows:rt.empty()};function gR(e,t){const n=e.value===void 0&&{themeOverride:{textDark:t.textLight}};switch(e.base){case"boolean":return{kind:ue.Boolean,data:typeof e.value=="boolean"?e.value:null,allowOverlay:!1,readonly:!1};case"number":return{kind:ue.Number,data:typeof e.value=="number"?e.value:void 0,displayData:e.text,allowOverlay:!0,readonly:!1,...n};case"string":return{kind:ue.Text,data:typeof e.value=="string"?e.value:"",displayData:e.text,allowOverlay:!0,readonly:!1,...n}}}function mR(e,t){const n=(r,o={})=>({kind:ue.Text,data:r,displayData:r,allowOverlay:!1,readonly:!0,...o});switch(e.kind){case"loading":return{kind:ue.Loading,allowOverlay:!1};case"edit":return gR(e,t);case"empty":return n("—",{themeOverride:{textDark:t.textLight}});case"n/a":return n("n/a",{themeOverride:{textDark:t.textLight,bgCell:t.bgCellMedium}});case"unknown":return n("",{themeOverride:{textDark:t.textLight,bgCell:t.bgCellMedium}});case"chip":return{kind:ue.Bubble,data:[e.text],allowOverlay:!1};case"text":return n(e.text,{...e.tone==="dim"&&{themeOverride:{textDark:t.textMedium}},...e.tone==="link"&&{themeOverride:{textDark:t.linkColor},cursor:"pointer"}})}}function pR({providerId:e,datasetId:t,version:n,findPrompt:r,prompts:o=dR,onOpenPrompt:i,onOpenInPlayground:a,onOpenTrace:s,onDeleted:l,onNewEval:u,evals:d=fR,onRunStarted:h,agents:m=hR,onAskAgent:p}){var Do,G,E;const[g,y]=c.useState(null),[x,C]=c.useState({rowCount:0,fields:{},instances:{}}),[w,M]=c.useState(null),[U,z]=c.useState(0),[A,W]=c.useState(0),J=c.useRef({count:0}),S=c.useRef(null),F=jS(e,t),[B,N]=c.useState(()=>Vl(F)),{expanded:_,widths:D}=B,fe=c.useCallback(b=>{N(b),lR(F,b)},[F]),X=c.useRef(F);c.useEffect(()=>{X.current!==F&&(X.current=F,N(Vl(F)))},[F]);const[ee,he]=c.useState(Go),de=c.useRef(null),te=`evalution.datasetTab:${e}/${t}`,[q,Ce]=c.useState(()=>Ta(te)??"grid"),ie=c.useRef(te);c.useEffect(()=>{ie.current!==te&&(ie.current=te,Ce(Ta(te)??"grid"))},[te]);const[re,$e]=c.useState(null),[Z,se]=c.useState(),[me,ze]=c.useState(null),[Me,ot]=c.useState(),it=c.useMemo(()=>new Ad(zl,{selected:null}),[e,t]),[Ae,Oe]=c.useState(!1),[je,vt]=c.useState(""),[wt,ut]=c.useState(!1),oe=c.useCallback(()=>ut(!1),[]),{triggerRef:ve,popoverRef:De,style:Fe}=ei({open:wt,onClose:oe,matchTriggerWidth:!1}),[pe,Ke]=c.useState(null),Ye=c.useCallback(()=>Ke(null),[]),We=iR(),ce=c.useRef(null),{ref:Se,isWide:qe}=Fd(760),le=c.useMemo(()=>new OS((b,T)=>_d(e,t,b,T),()=>W(b=>b+1),b=>M(b.message)),[e,t]),tt=c.useCallback((b,T)=>le.ensure(b,T),[le]),mt=c.useRef({start:0,end:0});c.useEffect(()=>{J.current={count:0},S.current=null},[e,t]),c.useEffect(()=>{let b=!1;return Pd(e,t).then(({dataset:T,rowCount:P,fields:L,instances:V})=>{if(b)return;y(T),C({rowCount:P+J.current.count,fields:L,instances:V??{}}),M(S.current),S.current=null,le.invalidate();const{start:ge,end:Ge}=mt.current;le.ensure(ge,Math.min(Ge,P))}).catch(T=>!b&&M(T.message)),()=>{b=!0}},[e,t,n,U,le]),c.useEffect(()=>{g&&it.setSubject({dataset:g,overview:x})},[it,g,x]);const Re=g!=null&&g.prompt?r(g.prompt):void 0,we=c.useMemo(()=>{if(!g||!Re)return g;const b=Od(g.fields,Re);return b===g.fields?g:{...g,fields:b}},[g,Re]),It=jd(we&&(!we.prompt||Re)?WS(we.fields,Re,o):void 0),dt=c.useMemo(()=>we?cS(we.columns,we.fields,x.fields):[],[we,x.fields]),He=c.useMemo(()=>we?wS({fields:we.fields,layout:dt,expanded:_,shortType:b=>Di(b,24)}):[],[we,dt,_]),st=g==null?void 0:g.rowLabel,pt=c.useCallback((b,T=st??null)=>{const P=uS(b);y(L=>{if(!L)return L;const{rowLabel:V,...ge}=L;return{...ge,columns:P,...T&&{rowLabel:T}}}),Nd(e,t,P,T).catch(L=>{M(`Couldn't save the columns: ${L.message}`),z(V=>V+1)})},[e,t,st]),Pt=c.useMemo(()=>SS(He),[He]),an=c.useCallback(b=>RS(b,Pt,_),[Pt,_]),Kt=c.useMemo(()=>new Map(He.map(b=>[b.id,b])),[He]),bt=c.useMemo(()=>He.map(b=>({id:b.id,title:b.title,width:D[b.id]??b.width,hasMenu:!0,...b.group!==void 0&&{group:b.group},...b.role==="unknown"&&{themeOverride:{textHeader:We.textLight}}})),[He,D,We]),En=c.useCallback(([b,T])=>mR(PS(le.get(T),He[b]),We),[He,le,We,A]),ln=c.useCallback(b=>{const T=b.y,P=b.y+b.height;mt.current={start:T,end:P},le.ensure(T,Math.min(P,x.rowCount)),Ke(null)},[le,x.rowCount]),kt=c.useCallback((b,T)=>{T();const P=Kt.get(b.column.id??"");if(!(P!=null&&P.type))return;const{ctx:L,rect:V,theme:ge}=b;L.save(),L.beginPath(),L.rect(V.x,V.y,V.width,V.height),L.clip(),L.font=`${ge.headerFontStyle} ${ge.fontFamily}`,L.textBaseline="middle";const Ge=L.measureText(P.title);L.font=`10.5px ${oR}`,L.fillStyle=ge.textLight,L.textBaseline="alphabetic",L.fillText(P.type,V.x+ge.cellHorizontalPadding+Ge.width+6,V.y+V.height/2-Ge.alphabeticBaseline+.5),L.restore()},[Kt]),Ot=((Do=ee.current)==null?void 0:Do.cell[1])??ee.rows.first()??null,Pe=Ot!==null&&Ot<x.rowCount?Ot:null,Dt=Pe!==null?le.get(Pe):void 0,Gt=c.useRef(null);Dt&&Pe!==null&&(Gt.current={index:Pe,row:Dt});const et=Dt??(Pe!==null&&((G=Gt.current)==null?void 0:G.index)===Pe?Gt.current.row:void 0),Rt=c.useRef(void 0);c.useEffect(()=>()=>clearTimeout(Rt.current),[]);const lt=c.useCallback(b=>{if(he(b),clearTimeout(Rt.current),!b.current&&b.rows.length===0)se(T=>T&&void 0);else{if(Z!==void 0)return;b.rows.length>0?se(!0):Rt.current=setTimeout(()=>se(T=>T??!0),uR)}},[Z]),jt=c.useRef(Me),Et=c.useCallback(b=>{jt.current=b,ot(b)},[]),ft=re!==null&&re<x.rowCount?le.get(re):void 0,yn=()=>{const b=jt.current;return Ti(b)?window.confirm("Discard the unsaved changes to this row?")?(Et(void 0),!0):!1:(b&&Et(void 0),!0)},ht=b=>{b===re||!yn()||$e(b)},Bn=b=>{switch(b.name){case"selectRow":ht(b.args.index);return;case"showInstance":{const{name:T}=b.args;if(!ft||!Object.hasOwn(ft.resources??{},T))return`the row has no stored instance ${T}`;se(!0),ze(T);return}case"proposeUpdate":{const{update:T}=b.args;if(!ft||ft.id!==T.rowId)return"the row isn't loaded";const P=jt.current,L=nR((P==null?void 0:P.rowId)===ft.id?P:void 0,ft,T),V=Yk(zs(L));if(V.length>0)return`That would leave references to instances the row doesn't declare: ${V.map(qk).join("; ")}`;Et(L);return}default:return`no action ${b.name}`}},xt=Hd({surface:zl,channel:it,activeUri:q.startsWith("view:")?q.slice(5):null,onAction:Bn}),xe=xt.shownUri!==null,Yt=c.useMemo(()=>xe?[]:ee.rows.toArray().filter(b=>b<x.rowCount),[xe,ee.rows,x.rowCount]);c.useEffect(()=>{me&&(Bd(me),ze(null))},[me]);const Ir=((E=xt.tabs.find(b=>b.uri===xt.shownUri))==null?void 0:E.label)??Ld(xt.shownUri??"");c.useEffect(()=>{if(!xe)return;const{rowCount:b}=x;b===0?$e(null):re===null?$e(0):re>=b&&$e(b-1)},[xe,re,x]),c.useEffect(()=>{xe&&re!==null&&le.ensure(re,Math.min(re+1,x.rowCount))},[xe,re,le,x.rowCount]);const vn=xe?re:Pe,Ut=xe?ft:et,en=c.useMemo(()=>Ut&&(Me==null?void 0:Me.rowId)===Ut.id?zs(Me):Ut,[Ut,Me]),Ln=en&&st?Cs(en,st):void 0,nr=Ut&&rR(Me,Ut.id);c.useEffect(()=>{it.setContext({selected:en&&vn!==null?{index:vn,row:en,...nr&&{stored:nr},...Ln!==void 0&&{label:Ln}}:null})},[it,en,vn,Ln,nr]);const Tn=b=>{if(!(b===q||!yn())){if(b.startsWith("view:")&&!xe)$e(Pe);else if(b==="grid"&&xe&&re!==null){he({columns:rt.empty(),rows:rt.fromSingleSelection(re)}),se(P=>P??!0);const T=re;requestAnimationFrame(()=>{var P;return(P=de.current)==null?void 0:P.scrollTo(0,T)})}Ce(b),cf(te,b)}},rr=()=>{const b=jt.current;if(b){if(!ft||ft.id!==b.rowId||Kl(b,ft)){M("This row changed since you started; discard and redo.");return}Et(void 0),un([b.update]).then(T=>{!T&&!jt.current&&Et(b)})}},or=xe&&Ti(Me)&&(ft==null?void 0:ft.id)===Me.rowId,ir=!!Me&&!!ft&&ft.id===Me.rowId&&Kl(Me,ft),sr=b=>{const T=le.get(b);!g||!Re||!T||a(Re,tf(nf(g,T),Re,{type:"dataset",description:`${g.name}, row ${b+1}`,providerId:e,datasetId:t,name:g.name},T.resources))},cn=!!g&&g.fields.length>0,wn=He.some(b=>b.group!==void 0),Er=(wn?Rs:0)+Ss+(x.rowCount+(cn?1:0))*Jl+1,{ref:Ur,matches:Xr}=zd(c.useCallback(b=>Er>b.height,[Er])),So=c.useMemo(()=>cn?{hint:"New row",sticky:Xr}:void 0,[cn,Xr]),xn=c.useCallback(()=>{const b=J.current;b.count++,C(P=>({...P,rowCount:P.rowCount+1}));const T=()=>{b.count--,b===J.current&&z(P=>P+1)};return Da(e,t,[{cells:{}}]).then(T,P=>{b===J.current&&(S.current=P.message,M(P.message)),T()}),Promise.resolve("bottom")},[e,t]),un=c.useCallback(async b=>{if(b.length===0)return!0;le.patch(b),W(T=>T+1);try{return await Wd(e,t,b),!0}catch(T){M(`Couldn't save: ${T.message}`),le.invalidate();const{start:P,end:L}=mt.current;return le.ensure(P,Math.min(L,x.rowCount)),re!==null&&le.ensure(re,re+1),!1}},[le,e,t,x.rowCount,re]),ar=c.useCallback(b=>un($S(b)),[un]),Ro=c.useCallback(b=>{const T=[];for(const{location:P,value:L}of b){const V=ql(L);V&&T.push({col:P[0],row:P[1],...V})}return ar(TS(T,He,P=>le.get(P))),!0},[He,le,ar]),lr=c.useCallback(([b,T],P)=>{var ge;const L=(ge=Qo(le.get(T),He[b]))==null?void 0:ge.base,V=ql(P);return L!==void 0&&!!V&&Cu(L,V.value)},[He,le]),cr=c.useCallback(async b=>{var P;if(b.length===0)return;const T=b.length===1?`row ${b[0]+1}`:`${b.length} rows`;if(window.confirm(`Delete ${T}?`))try{const L=(await le.rowsAt(b)).map(ge=>ge.id);await Gd(e,t,L),lt(Go);const V=(P=jt.current)==null?void 0:P.rowId;V!==void 0&&L.includes(V)&&Et(void 0),z(ge=>ge+1)}catch(L){M(L.message)}},[le,e,t,lt,Et]),Yn=c.useCallback(b=>{const{current:T}=b;return T?ar(DS([T.range,...T.rangeStack],He,P=>le.get(P))):b.rows.length>0&&cr(b.rows.toArray()),!1},[He,le,ar,cr]),Mo=c.useCallback(([b,T])=>{var V;const P=He[b],L=(V=le.get(T))==null?void 0:V.source;(P==null?void 0:P.role)==="source"&&(L==null?void 0:L.kind)==="trace"&&s(L.traceProviderId,L.traceId)},[He,le,s]),Kr=c.useCallback(([b,T])=>{Qo(le.get(T),He[b])&&clearTimeout(Rt.current)},[He,le]),ur=c.useCallback((b,T)=>{const P=He[b],L=P&&"path"in P?Gr(P.path):void 0;if(L===void 0)return;T.preventDefault();const V=new Set(_);V.delete(L)||V.add(L),fe({...B,expanded:V})},[He,_,B,fe]),Ct=c.useCallback((b,T)=>{const P=He[b];P&&Ke({columnId:P.id,anchor:T})},[He]),qt=c.useCallback((b,T)=>xu(He,b,T),[He]),dr=c.useCallback((b,T)=>{const P=kS(dt,He,b,T);P!==dt&&pt(P)},[dt,He,pt]),Vt=async b=>{try{await b()}catch(T){M(T.message)}};if(w&&!g)return v.jsxs("div",{className:"dataset-view dataset-view-error",children:["Error: ",w]});if(!g)return v.jsx("div",{className:"dataset-view",children:v.jsx("div",{className:"trace-view-loading",children:"Loading dataset…"})});const Dn=Re?Ud(g.fields,Re):[],{rowCount:Wt}=x,fr=()=>Vt(async()=>{const b=je.trim();Oe(!1),!(!b||b===g.name)&&y(await rf(e,t,b))}),hr=()=>{vt(g.name),Oe(!0)},dn=pe?He.find(b=>b.id===pe.columnId):void 0,$n=xS(dn),fn=$n!==void 0?g.fields.find(b=>b.id===$n):void 0,gr=CS(dn),qn=st&&In(st),Ee=async(b,T)=>{const P=await af(e,t,b.id,T);y({...g,fields:g.fields.map(L=>L.id===P.id?P:L)}),z(L=>L+1)},Tr=b=>{Ke(null),window.confirm(`Delete the field “${b.def.name}” and its values in every row?`)&&Vt(async()=>{await sf(e,t,b.id),fe(HS(B,b.id)),lt(Go),z(T=>T+1)})},Dr=b=>of(e,t,b),rn=b=>pt(pS(dt,b)),Yr=()=>z(b=>b+1),hn={providerId:e,datasetId:t,prompts:o,...g.prompt&&{linked:g.prompt}},mr=()=>{window.confirm(`Delete “${g.name}” and its ${Wt} row${Wt===1?"":"s"}?`)&&Vt(async()=>{await uf(e,t),cR(F),l()})},qr=()=>u==null?void 0:u({dataset:{providerId:e,id:t},...(Re==null?void 0:Re.providerId)&&{prompt:{id:Re.id,providerId:Re.providerId}}}),Vn=async()=>(await le.rowsAt(Yt)).map(b=>b.id),Io=b=>Vt(async()=>{const T=Yt.length>0?await Vn():void 0;try{const P=await df(b.providerId,b.id,{...T&&{rowIds:T}});h==null||h(b,P)}catch(P){throw P instanceof ff?new Error(`Can't run ${b.name}: ${P.problems.join("; ")}`):P}}),Vr=b=>Vt(async()=>{Yt.length>0?p==null||p(b,await Vn()):p==null||p(b,Ut&&[Ut.id])}),gn=d.filter(b=>b.dataset.providerId===e&&b.dataset.id===t),An={evals:gn,selectedRows:Yt.length,onRun:Io,...u&&{onNewEval:qr}},Jt=gn.length>0||!!u,$=wt&&go.createPortal(v.jsxs("div",{className:"trace-header-menu",ref:De,style:Fe,children:[Jt&&v.jsx(Eu,{...An,onChosen:oe}),p&&v.jsx(Xd,{agents:m.filter(b=>!b.disabledReason),onAsk:b=>{ut(!1),Vr(b)}}),(Jt||p)&&v.jsx("hr",{className:"ask-agent-menu-divider"}),v.jsxs("button",{type:"button",className:"trace-header-menu-item dataset-menu-delete",onClick:()=>{ut(!1),mr()},children:[v.jsx("span",{className:"trace-header-menu-item-icon",children:v.jsx(yi,{})}),v.jsx("span",{className:"trace-header-menu-item-label",children:"Delete dataset"})]})]}),document.body),gt=Z?xe?re:Pe:null,Nt=Z?xe?ft:et:void 0,Eo=Nt&&st?Cs(Nt,st):void 0,Jn=b=>Vt(async()=>{const T=x.rowCount;await Da(e,t,[US(b)]),z(P=>P+1),xe||(he({columns:rt.empty(),rows:rt.fromSingleSelection(T)}),requestAnimationFrame(()=>{var P;return(P=de.current)==null?void 0:P.scrollTo(0,T)}))}),To=()=>{var T,P;if(se(!Z),Z||xe||Ot!==null)return;const b=Math.min(((T=Gt.current)==null?void 0:T.index)??0,Wt-1);he({columns:rt.empty(),rows:rt.fromSingleSelection(b)}),(P=de.current)==null||P.scrollTo(0,b)},Fn=Z&&Yt.length>1?v.jsx($a,{title:v.jsxs("span",{className:"trace-row-name",children:[Yt.length," rows selected"]}),actions:v.jsx("button",{type:"button",className:"dataset-row-btn dataset-row-delete",title:"Delete rows","aria-label":"Delete rows",onClick:()=>void cr(Yt),children:v.jsx(yi,{})})}):Nt&>!==null&&v.jsxs(v.Fragment,{children:[v.jsx($a,{title:v.jsxs("span",{className:"trace-row-name",children:["Row ",gt+1,v.jsxs("code",{className:"dataset-row-id",children:[" · ",Nt.id]})]}),subtitle:Eo,actions:v.jsxs(v.Fragment,{children:[Re&&v.jsx("button",{type:"button",className:"dataset-row-btn",title:`Open in playground (${Re.name})`,"aria-label":"Open row in playground",onClick:()=>sr(gt),children:"▶"}),v.jsx("button",{type:"button",className:"dataset-row-btn",title:"Duplicate row","aria-label":"Duplicate row",onClick:()=>void Jn(Nt),children:v.jsx(Kd,{})}),v.jsx("button",{type:"button",className:"dataset-row-btn dataset-row-delete",title:"Delete row","aria-label":"Delete row",onClick:()=>{window.confirm(`Delete row ${gt+1}?`)&&Vt(async()=>{var b;await lf(e,t,Nt.id),xe?he(Go):lt(Go),((b=jt.current)==null?void 0:b.rowId)===Nt.id&&Et(void 0),z(T=>T+1)})},children:v.jsx(yi,{})})]})}),Ti(Me)&&Me.rowId===Nt.id&&v.jsxs("div",{className:"dataset-row-draft-banner",children:[Ir," has unsaved changes to this row. Edits here are saved at once, and will leave those changes stale."]}),v.jsx(JS,{dataset:we??g,row:Nt,onOpenTrace:s,onChangeRow:b=>un([{rowId:Nt.id,...b}]),sources:It})]});return v.jsxs("div",{className:"dataset-view",children:[v.jsxs("div",{className:"trace-view-header dataset-view-header",children:[v.jsxs("div",{className:"trace-view-header-row",children:[v.jsx("div",{className:"trace-view-title",children:Ae?v.jsx("form",{className:"dataset-view-rename",onSubmit:b=>{b.preventDefault(),fr()},children:v.jsx("input",{autoFocus:!0,"aria-label":"Dataset name",value:je,onChange:b=>vt(b.target.value),onFocus:b=>b.target.select(),onBlur:()=>Oe(!1),onKeyDown:b=>b.key==="Escape"&&Oe(!1)})}):v.jsx("span",{className:"trace-view-name",onDoubleClick:hr,title:"Double-click to rename",children:g.name})}),v.jsxs("div",{className:"trace-view-header-actions",children:[v.jsx(LS,{layout:dt,fields:(we==null?void 0:we.fields)??g.fields,instances:x.instances,rowLabel:st,onChange:b=>pt(b),onRowLabel:b=>pt(dt,b??null),onAdd:rn,onRemove:b=>{const T=mu(dt,{index:b});pt(gS(dt,b),T&&In(T)===qn?null:st??null)},describePath:Dr,newField:hn,onFieldAdded:Yr}),v.jsxs("div",{className:"trace-view-header-actions-full",children:[Jt&&v.jsx(ZS,{...An}),p&&v.jsx(Yd,{agents:m,onAsk:Vr}),v.jsx("button",{type:"button",className:"trace-view-prompt-btn trace-view-delete-btn",onClick:mr,title:"Delete dataset","aria-label":"Delete dataset",children:v.jsx(yi,{})})]}),v.jsx("button",{type:"button",ref:ve,className:"trace-view-header-menu-trigger",onClick:()=>ut(b=>!b),title:"More actions","aria-label":"More actions",children:v.jsx(qd,{})})]})]}),v.jsxs("div",{className:"trace-view-meta",children:[v.jsxs("span",{className:"trace-view-meta-item",title:"Last updated",children:[v.jsx(rc,{}),v.jsx("span",{className:"trace-view-date-full",children:nc(g.updatedAt)}),v.jsx("span",{className:"trace-view-date-compact",children:Vd(g.updatedAt)})]}),v.jsxs("span",{className:"trace-view-meta-item",title:"Row count",children:[v.jsx(Aa,{}),Wt," row",Wt===1?"":"s"]}),Re&&v.jsxs("button",{type:"button",className:"trace-view-meta-item trace-view-prompt-link",onClick:()=>i(Re),title:"Open the linked prompt",children:[v.jsx(Jd,{}),v.jsx("span",{className:"trace-view-prompt-link-name",children:Re.name}),"↗"]})]})]}),$,pe&&dn&&v.jsx(lS,{...fn&&{field:fn},anchor:pe.anchor,onRename:async b=>{fn&&await Ee(fn,b)},onDelete:()=>fn&&Tr(fn),onHide:()=>pt(Bi(dt,dn.slot,!0)),...gr&&{rowLabel:{isLabel:In(gr)===qn,toggle:()=>pt(dt,In(gr)===qn?null:gr)}},onClose:Ye},dn.id),go.createPortal(v.jsx("div",{ref:ce,className:"dataset-grid-portal"}),document.body),w&&v.jsxs("div",{className:"pg-exec-error dataset-view-action-error",children:[w,v.jsx("button",{type:"button",className:"pg-dismiss",onClick:()=>M(null),children:"×"})]}),Re&&Dn.length>0&&v.jsxs("div",{className:"dataset-view-stale",children:[Dn.length," field",Dn.length===1?"":"s"," no longer match"," ",v.jsx("code",{children:Re.name}),"'s parameters:"," ",Dn.map((b,T)=>v.jsxs("span",{children:[T>0&&", ",v.jsx("code",{children:b.def.name})]},b.id))]}),v.jsxs("div",{className:"trace-view-body dataset-view-body",ref:Se,children:[v.jsxs("div",{className:"trace-view-main-column",children:[v.jsxs("div",{className:"trace-view-tabs dataset-view-tabs",children:[v.jsxs("div",{className:"trace-view-tab-list",children:[v.jsxs("button",{type:"button",className:`trace-view-tab${xe?"":" trace-view-tab-active"}`,onClick:()=>Tn("grid"),children:[v.jsx(Aa,{}),"Grid"]}),v.jsx(Zd,{tabs:xt.tabs,active:xt.shownUri,onSelect:b=>Tn(`view:${b}`)}),v.jsx(Qd,{problems:xt.problems})]}),v.jsx("button",{type:"button",className:`dataset-pane-toggle${Z?" dataset-pane-toggle-active":""}`,onClick:To,disabled:Wt===0,title:"Row details","aria-label":"Row details","aria-pressed":!!Z,children:v.jsx(ef,{})})]}),or&&v.jsx(eR,{viewLabel:Ir,rowName:`Row ${(re??0)+1}`,stale:ir,onSave:rr,onDiscard:()=>Et(void 0)}),v.jsxs("div",{className:"dataset-view-main",children:[xe&&v.jsx(QS,{rowCount:Wt,getRow:b=>le.get(b),ensure:tt,label:b=>st?Cs(b,st):void 0,selected:re,onSelect:ht}),v.jsxs("div",{className:"view-stack",children:[v.jsxs("div",{className:"dataset-grid",ref:Ur,style:xe?{display:"none"}:void 0,children:[v.jsx(xk,{ref:de,renderers:sR,imageWindowLoader:aR,headerIcons:bS,getGroupDetails:an,width:"100%",height:"100%",theme:We,columns:bt,rows:Wt,trailingRowOptions:So,onRowAppended:cn?xn:void 0,getCellContent:En,onVisibleRegionChanged:ln,drawHeader:kt,rowMarkers:"both",rowSelect:"multi",rangeSelect:"rect",columnSelect:"none",gridSelection:ee,onGridSelectionChange:lt,onCellClicked:Mo,onCellActivated:Kr,onGroupHeaderClicked:ur,onHeaderMenuClick:Ct,onColumnProposeMove:qt,onColumnMoved:dr,onCellsEdited:Ro,validateCell:lr,onDelete:Yn,onPaste:!0,getCellsForSelection:!0,fillHandle:!0,onColumnResize:(b,T)=>b.id&&fe({...B,widths:{...D,[b.id]:T}}),rowHeight:Jl,headerHeight:Ss,groupHeaderHeight:Rs,smoothScrollX:!0,smoothScrollY:!0,portalElementRef:ce,rightElement:v.jsx(sS,{fields:(we==null?void 0:we.fields)??g.fields,instances:x.instances,describePath:Dr,onPick:rn,newField:hn,onFieldAdded:Yr,top:wn?Rs:0,height:Ss}),rightElementProps:{sticky:!1,fill:!0}}),v.jsx("div",{className:"dataset-grid-fill",style:{top:Er},children:Wt===0&&!cn&&v.jsx("p",{className:"dataset-grid-empty",children:"No fields yet. Add one with the “+” to start filling this dataset in by hand."})})]}),xe&&Wt===0&&v.jsx("div",{className:"view-frame-message",children:"No rows"}),xt.layer]})]}),!qe&&Fn&&v.jsx(Fa,{placement:"bottom",label:"Row details",children:Fn})]}),qe&&Fn&&v.jsx(Fa,{placement:"side",label:"Row details",children:Fn})]})]})}const vR=Object.freeze(Object.defineProperty({__proto__:null,default:pR},Symbol.toStringTag,{value:"Module"}));export{zC as C,vR as D,fb as T,lo as a,Zm as b,io as i,db as m,Rr as s};
|