evalution 1.0.8 → 2.0.1

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.
Files changed (30) hide show
  1. package/LICENSING.md +26 -44
  2. package/README.md +11 -11
  3. package/dist/{check-CR4fU1S5.d.ts → check-BKU5_IhU.d.ts} +18 -868
  4. package/dist/checks/index.d.ts +2 -1
  5. package/dist/cli/index.js +809 -372
  6. package/dist/client/assets/{DatasetView-BqSWI_pm.js → DatasetView-DZ2uLHKV.js} +12 -10
  7. package/dist/client/assets/{EvalRunView-CR6ZksSu.js → EvalRunView-T610dLVw.js} +1 -1
  8. package/dist/client/assets/{EvalView-JPEM5IY8.js → EvalView-Cae68vPB.js} +1 -1
  9. package/dist/client/assets/{data-grid-overlay-editor-B_nPhXKR.js → data-grid-overlay-editor-PtH7A6E4.js} +1 -1
  10. package/dist/client/assets/{highlighted-body-KPVGNVTW-dPpneB8R.js → highlighted-body-KPVGNVTW-CPtwvSJb.js} +1 -1
  11. package/dist/client/assets/{index-CwjMcK6S.js → index-BFH07Ynk.js} +147 -147
  12. package/dist/client/assets/index-KCv8AeiY.css +32 -0
  13. package/dist/client/assets/{number-overlay-editor-CRWFlaQs.js → number-overlay-editor-BbQhagHP.js} +1 -1
  14. package/dist/client/index.html +2 -2
  15. package/dist/cost-fetching-trace-sink-Dz8gniQ6.js +262 -0
  16. package/dist/{dataset-types-Dqi5vVg-.d.ts → dataset-types-D-Fsbg8B.d.ts} +7 -247
  17. package/dist/index.d.ts +844 -1426
  18. package/dist/index.js +151 -480
  19. package/dist/ingest.d.ts +119 -0
  20. package/dist/ingest.js +3 -0
  21. package/dist/{trace-event-ingestor-BghQcCHe.js → local-database-trace-provider-87-WGqfS.js} +1976 -7362
  22. package/dist/{trace-DGj5oW7z.d.ts → trace-BLjFYF9G.d.ts} +2 -1
  23. package/dist/trace-event-ingestor-B1DYEg2H.js +798 -0
  24. package/dist/trace-event-ingestor-JNpe-OrX.d.ts +109 -0
  25. package/dist/views/datasets/index.d.ts +1 -1
  26. package/dist/views/index.d.ts +3 -2
  27. package/dist/views/index.js +0 -4
  28. package/dist/views/react/index.d.ts +1 -1
  29. package/package.json +32 -30
  30. package/dist/client/assets/index-BGcZZetP.css +0 -32
@@ -1,15 +1,17 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/data-grid-overlay-editor-B_nPhXKR.js","assets/index-CwjMcK6S.js","assets/index-BGcZZetP.css","assets/number-overlay-editor-CRWFlaQs.js"])))=>i.map(i=>d[i]);
2
- var ld=Object.defineProperty;var cd=(e,t,n)=>t in e?ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xe=(e,t,n)=>cd(e,typeof t!="symbol"?t+"":t,n);import{ae as bi,af as zr,r as c,ad as zt,ag as ec,ah as ud,ai as tc,aj as dd,ak as Zo,ac as mo,j as v,al as fd,a1 as Di,aa as hd,am as gd,an as nc,ao as md,ap as rc,aq as pd,ar as bd,as as Ea,at as Mi,a7 as yd,X as vd,a8 as wd,Y as xd,au as Cd,av as oc,aw as ic,ax as kd,ay as Sd,az as Rd,aA as Ta,aB as Md,aC as Ms,a2 as Id,R as Ed,M as Td,H as Dd,a4 as $d,a6 as Ad,aD as Fd,E as sc,aE as _d,aF as Da,aG as Pd,aH as Od,aI as jd,w as Nd,aJ as Hd,C as Bd,aK as Ld,aL as zd,aM as $a,aN as Wd,aO as Gd,aP as Aa,aQ as Ud,aR as Xd,aS as Kd,aT as Yd,T as yi,aU as Fa,J as qd,I as Vd,aV as Jd,f as Qd,K as _a,P as Zd,aW as ef,aX as tf,aY as nf,aZ as Pa,a_ as rf,a$ as of,b0 as sf,b1 as af,b2 as lf,b3 as cf,b4 as uf,b5 as df,b6 as ff,N as hf,Q as gf}from"./index-CwjMcK6S.js";var mf=Object.prototype,pf=mf.hasOwnProperty;function bf(e,t){return e!=null&&pf.call(e,t)}var yf=bf,vf=Array.isArray,Jn=vf,wf=typeof bi=="object"&&bi&&bi.Object===Object&&bi,ac=wf,xf=ac,Cf=typeof self=="object"&&self&&self.Object===Object&&self,kf=xf||Cf||Function("return this")(),Qn=kf,Sf=Qn,Rf=Sf.Symbol,ei=Rf,Oa=ei,lc=Object.prototype,Mf=lc.hasOwnProperty,If=lc.toString,Oo=Oa?Oa.toStringTag:void 0;function Ef(e){var t=Mf.call(e,Oo),n=e[Oo];try{e[Oo]=void 0;var r=!0}catch{}var o=If.call(e);return r&&(t?e[Oo]=n:delete e[Oo]),o}var Tf=Ef,Df=Object.prototype,$f=Df.toString;function Af(e){return $f.call(e)}var Ff=Af,ja=ei,_f=Tf,Pf=Ff,Of="[object Null]",jf="[object Undefined]",Na=ja?ja.toStringTag:void 0;function Nf(e){return e==null?e===void 0?jf:Of:Na&&Na in Object(e)?_f(e):Pf(e)}var ti=Nf;function Hf(e){return e!=null&&typeof e=="object"}var ni=Hf,Bf=ti,Lf=ni,zf="[object Symbol]";function Wf(e){return typeof e=="symbol"||Lf(e)&&Bf(e)==zf}var Li=Wf,Gf=Jn,Uf=Li,Xf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Kf=/^\w*$/;function Yf(e,t){if(Gf(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Uf(e)?!0:Kf.test(e)||!Xf.test(e)||t!=null&&e in Object(t)}var Ws=Yf;function qf(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var yo=qf,Vf=ti,Jf=yo,Qf="[object AsyncFunction]",Zf="[object Function]",eh="[object GeneratorFunction]",th="[object Proxy]";function nh(e){if(!Jf(e))return!1;var t=Vf(e);return t==Zf||t==eh||t==Qf||t==th}var cc=nh,rh=Qn,oh=rh["__core-js_shared__"],ih=oh,cs=ih,Ha=function(){var e=/[^.]+$/.exec(cs&&cs.keys&&cs.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function sh(e){return!!Ha&&Ha in e}var ah=sh,lh=Function.prototype,ch=lh.toString;function uh(e){if(e!=null){try{return ch.call(e)}catch{}try{return e+""}catch{}}return""}var uc=uh,dh=cc,fh=ah,hh=yo,gh=uc,mh=/[\\^$.*+?()[\]{}|]/g,ph=/^\[object .+?Constructor\]$/,bh=Function.prototype,yh=Object.prototype,vh=bh.toString,wh=yh.hasOwnProperty,xh=RegExp("^"+vh.call(wh).replace(mh,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ch(e){if(!hh(e)||fh(e))return!1;var t=dh(e)?xh:ph;return t.test(gh(e))}var kh=Ch;function Sh(e,t){return e==null?void 0:e[t]}var Rh=Sh,Mh=kh,Ih=Rh;function Eh(e,t){var n=Ih(e,t);return Mh(n)?n:void 0}var Wr=Eh,Th=Wr,Dh=Th(Object,"create"),zi=Dh,Ba=zi;function $h(){this.__data__=Ba?Ba(null):{},this.size=0}var Ah=$h;function Fh(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _h=Fh,Ph=zi,Oh="__lodash_hash_undefined__",jh=Object.prototype,Nh=jh.hasOwnProperty;function Hh(e){var t=this.__data__;if(Ph){var n=t[e];return n===Oh?void 0:n}return Nh.call(t,e)?t[e]:void 0}var Bh=Hh,Lh=zi,zh=Object.prototype,Wh=zh.hasOwnProperty;function Gh(e){var t=this.__data__;return Lh?t[e]!==void 0:Wh.call(t,e)}var Uh=Gh,Xh=zi,Kh="__lodash_hash_undefined__";function Yh(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Xh&&t===void 0?Kh:t,this}var qh=Yh,Vh=Ah,Jh=_h,Qh=Bh,Zh=Uh,eg=qh;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=Vh;vo.prototype.delete=Jh;vo.prototype.get=Qh;vo.prototype.has=Zh;vo.prototype.set=eg;var tg=vo;function ng(){this.__data__=[],this.size=0}var rg=ng;function og(e,t){return e===t||e!==e&&t!==t}var Gs=og,ig=Gs;function sg(e,t){for(var n=e.length;n--;)if(ig(e[n][0],t))return n;return-1}var Wi=sg,ag=Wi,lg=Array.prototype,cg=lg.splice;function ug(e){var t=this.__data__,n=ag(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():cg.call(t,n,1),--this.size,!0}var dg=ug,fg=Wi;function hg(e){var t=this.__data__,n=fg(t,e);return n<0?void 0:t[n][1]}var gg=hg,mg=Wi;function pg(e){return mg(this.__data__,e)>-1}var bg=pg,yg=Wi;function vg(e,t){var n=this.__data__,r=yg(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var wg=vg,xg=rg,Cg=dg,kg=gg,Sg=bg,Rg=wg;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=xg;wo.prototype.delete=Cg;wo.prototype.get=kg;wo.prototype.has=Sg;wo.prototype.set=Rg;var Gi=wo,Mg=Wr,Ig=Qn,Eg=Mg(Ig,"Map"),Us=Eg,La=tg,Tg=Gi,Dg=Us;function $g(){this.size=0,this.__data__={hash:new La,map:new(Dg||Tg),string:new La}}var Ag=$g;function Fg(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var _g=Fg,Pg=_g;function Og(e,t){var n=e.__data__;return Pg(t)?n[typeof t=="string"?"string":"hash"]:n.map}var Ui=Og,jg=Ui;function Ng(e){var t=jg(this,e).delete(e);return this.size-=t?1:0,t}var Hg=Ng,Bg=Ui;function Lg(e){return Bg(this,e).get(e)}var zg=Lg,Wg=Ui;function Gg(e){return Wg(this,e).has(e)}var Ug=Gg,Xg=Ui;function Kg(e,t){var n=Xg(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var Yg=Kg,qg=Ag,Vg=Hg,Jg=zg,Qg=Ug,Zg=Yg;function xo(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])}}xo.prototype.clear=qg;xo.prototype.delete=Vg;xo.prototype.get=Jg;xo.prototype.has=Qg;xo.prototype.set=Zg;var Xs=xo,dc=Xs,em="Expected a function";function Ks(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(em);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||dc),n}Ks.Cache=dc;var tm=Ks,nm=tm,rm=500;function om(e){var t=nm(e,function(r){return n.size===rm&&n.clear(),r}),n=t.cache;return t}var im=om,sm=im,am=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lm=/\\(\\)?/g,cm=sm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(am,function(n,r,o,i){t.push(o?i.replace(lm,"$1"):r||n)}),t}),um=cm;function dm(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 fm=dm,za=ei,hm=fm,gm=Jn,mm=Li,Wa=za?za.prototype:void 0,Ga=Wa?Wa.toString:void 0;function fc(e){if(typeof e=="string")return e;if(gm(e))return hm(e,fc)+"";if(mm(e))return Ga?Ga.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var pm=fc,bm=pm;function ym(e){return e==null?"":bm(e)}var vm=ym,wm=Jn,xm=Ws,Cm=um,km=vm;function Sm(e,t){return wm(e)?e:xm(e,t)?[e]:Cm(km(e))}var hc=Sm,Rm=ti,Mm=ni,Im="[object Arguments]";function Em(e){return Mm(e)&&Rm(e)==Im}var Tm=Em,Ua=Tm,Dm=ni,gc=Object.prototype,$m=gc.hasOwnProperty,Am=gc.propertyIsEnumerable,Fm=Ua(function(){return arguments}())?Ua:function(e){return Dm(e)&&$m.call(e,"callee")&&!Am.call(e,"callee")},Ys=Fm,_m=9007199254740991,Pm=/^(?:0|[1-9]\d*)$/;function Om(e,t){var n=typeof e;return t=t??_m,!!t&&(n=="number"||n!="symbol"&&Pm.test(e))&&e>-1&&e%1==0&&e<t}var qs=Om,jm=9007199254740991;function Nm(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=jm}var Vs=Nm,Hm=Li;function Bm(e){if(typeof e=="string"||Hm(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var Xi=Bm,Lm=hc,zm=Ys,Wm=Jn,Gm=qs,Um=Vs,Xm=Xi;function Km(e,t,n){t=Lm(t,e);for(var r=-1,o=t.length,i=!1;++r<o;){var a=Xm(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&&Um(o)&&Gm(a,o)&&(Wm(e)||zm(e)))}var mc=Km,Ym=yf,qm=mc;function Vm(e,t){return e!=null&&qm(e,t,Ym)}var Jm=Vm;const Qm=zr(Jm);function pc(e="This should not happen"){throw new Error(e)}function pn(e,t="Assertion failed"){if(!e)return pc(t)}function qo(e,t){return pc(t??"Hell froze over")}function Zm(e,t){try{return e()}catch{return t}}const Xa=Object.prototype.hasOwnProperty;function po(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--&&po(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(Xa.call(e,n)&&++r&&!Xa.call(t,n)||!(n in t)||!po(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}const $i=null,Js=void 0;var ce;(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"})(ce||(ce={}));var Ka;(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"})(Ka||(Ka={}));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 Ya(e){return typeof e=="object"?e:await e()}function so(e){return!(e.kind===ce.Loading||e.kind===ce.Bubble||e.kind===ce.RowID||e.kind===ce.Protected||e.kind===ce.Drilldown)}function co(e){return e.kind===Tn.Marker||e.kind===Tn.NewRow}function ao(e){if(!so(e)||e.kind===ce.Image)return!1;switch(e.kind){case ce.Text:case ce.Number:case ce.Markdown:case ce.Uri:case ce.Custom:case ce.Boolean:return e.readonly!==!0;default:qo(e,"A cell was passed with an invalid kind")}}function ep(e){return Qm(e,"editor")}function Qs(e){return!(e.readonly??!1)}var Tn;(function(e){e.NewRow="new-row",e.Marker="marker"})(Tn||(Tn={}));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 qa;const un=class un{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 un(n)}add(t){const n=typeof t=="number"?[t,t+1]:t,r=us([...this.items,n]);return new un(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 un(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(un,"create",t=>new un(us(t))),Xe(un,"empty",()=>qa??(qa=new un([]))),Xe(un,"fromSingleSelection",t=>un.empty().add(t)),Xe(un,"fromArray",t=>{if(t.length===0)return un.empty();const n=t.map(o=>[o,o+1]),r=us(n);return new un(r)});let lt=un;function tp(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var np=/^((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=tp(function(e){return np.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),rp=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(" ")},Va=rp,op=e=>e.toUpperCase()===e,ip=e=>t=>e.indexOf(t)===-1,bc=(e,t)=>{const n={};return Object.keys(e).filter(ip(t)).forEach(r=>{n[r]=e[r]}),n};function sp(e,t,n){const r=bc(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 ap=(e,t)=>{};function lp(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&&!op(s[0])):n.propsAsIs,d=sp(u,i,["as","class"]);d.ref=a,d.className=n.atomic?Va(n.class,d.className||l):Va(d.className||l,n.class);const{vars:h}=n;if(h){const m={};for(const b in h){const x=h[b],C=x[0],w=x[1]||"",M=typeof C=="function"?C(i):C;ap(M,n.name),m[`--${b}`]=`${M}${w}`}const p=d.style||{},g=Object.keys(p);g.length>0&&g.forEach(b=>{m[b]=p[b]}),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=bc(i,["innerRef"]);return r(a,i.innerRef)};return o.displayName=n.name,o.__wyw_meta={className:n.class||t,extends:e},o}}var Sr=lp,cp=Qn,up=function(){return cp.Date.now()},dp=up,fp=/\s/;function hp(e){for(var t=e.length;t--&&fp.test(e.charAt(t)););return t}var gp=hp,mp=gp,pp=/^\s+/;function bp(e){return e&&e.slice(0,mp(e)+1).replace(pp,"")}var yp=bp,vp=yp,Ja=yo,wp=Li,Qa=NaN,xp=/^[-+]0x[0-9a-f]+$/i,Cp=/^0b[01]+$/i,kp=/^0o[0-7]+$/i,Sp=parseInt;function Rp(e){if(typeof e=="number")return e;if(wp(e))return Qa;if(Ja(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ja(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=vp(e);var n=Cp.test(e);return n||kp.test(e)?Sp(e.slice(2),n?2:8):xp.test(e)?Qa:+e}var Zs=Rp,Mp=yo,fs=dp,Za=Zs,Ip="Expected a function",Ep=Math.max,Tp=Math.min;function Dp(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(Ip);t=Za(t)||0,Mp(n)&&(d=!!n.leading,h="maxWait"in n,i=h?Ep(Za(n.maxWait)||0,t):i,m="trailing"in n?!!n.trailing:m);function p(A){var L=r,V=o;return r=o=void 0,u=A,a=e.apply(V,L),a}function g(A){return u=A,s=setTimeout(C,t),d?p(A):a}function b(A){var L=A-l,V=A-u,k=t-L;return h?Tp(k,i-V):k}function x(A){var L=A-l,V=A-u;return l===void 0||L>=t||L<0||h&&V>=i}function C(){var A=fs();if(x(A))return w(A);s=setTimeout(C,b(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 G(){return s===void 0?a:w(fs())}function B(){var A=fs(),L=x(A);if(r=arguments,o=this,l=A,L){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 B.cancel=M,B.flush=G,B}var $p=Dp;const yc=zr($p);function an(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 xr(e,t){return e===void 0?void 0:t}const vc=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),wc=(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}},xc=(e,t,n)=>Math.min(e,t-n*2),Cc=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2;function Ap(e,t,n){const[r,o]=c.useState(e),i=c.useRef(!0);c.useEffect(()=>()=>{i.current=!1},[]);const a=c.useRef(yc(s=>{i.current&&o(s)},n));return c.useLayoutEffect(()=>{i.current&&a.current(()=>e())},t),r}const Fp="֑-߿יִ-﷽ﹰ-ﻼ",_p="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Pp=new RegExp("^[^"+_p+"]*["+Fp+"]");function ea(e){return Pp.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 jr=Symbol();function Op(e){const t=c.useRef([jr,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!==jr&&(s=typeof s=="function"?s(l):s,s===l)||(l!==jr&&o({}),r(u=>typeof s=="function"?s(l===jr?u:l):s),t.current[0]=jr)},[]),a=c.useCallback(()=>{t.current[0]=jr,o({})},[]);return[t.current[0]===jr?n:t.current[0],i,a]}function jp(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 Np(e){const t=c.useRef(e);return po(e,t.current)||(t.current=e),t.current}const Hp=Sr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),Bp=Sr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),Lp=Sr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let el=0;const zp=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-"+(el=(el+1)%1e7));c.useEffect(()=>{const g=d.current;if(g===null||g.disabled)return;const b=h.toString().length;g.focus(),g.setSelectionRange(o?0:b,b)},[]),c.useLayoutEffect(()=>{var g;if(a!==void 0){const b=typeof a=="number"?[a,null]:a;(g=d.current)==null||g.setSelectionRange(b[0],b[1])}},[a]);const p=c.useCallback(g=>{g.key==="Enter"&&g.shiftKey&&i===!0||r==null||r(g)},[i,r]);return c.createElement(Lp,{className:"gdg-growing-entry"},c.createElement(Bp,{className:u},h+`
3
- `),c.createElement(Hp,{...s,className:(u??"")+" gdg-input",id:m,ref:d,onKeyDown:p,value:h,placeholder:t,dir:"auto"}))},hs={};let vr=null;function Wp(){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];vr=vr||Wp(),vr.style.color="#000",vr.style.color=t;const n=getComputedStyle(vr).color;vr.style.color="#fff",vr.style.color=t;const r=getComputedStyle(vr).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 Lr(e,t){const[n,r,o]=Es(e);return`rgba(${n}, ${r}, ${o}, ${t})`}const tl=new Map;function nl(e,t){const n=`${e}-${t}`,r=tl.get(n);if(r!==void 0)return r;const o=bn(e,t);return tl.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 lo=new Map,uo=new Map,Ts=new Map;function Gp(){lo.clear(),Ts.clear(),uo.clear()}function Up(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,b=d*g*r/m,x=p+b;n.set(h,x)}}function Xp(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 Uo(e,t,n,r){var o,i;let a=uo.get(n);if(r&&a!==void 0&&a.count>2e4){let u=Ts.get(n);if(u===void 0&&(u=Xp(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 Up(t,d.width,u,Math.max(.05,1-a.count/2e5),a.size),uo.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)uo.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;uo.set(n,{count:a.count+t.length,size:h})}return s.width}function Kp(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=Uo(e,t.slice(0,Math.max(0,l)),r,a);if(u!==n)if(u<n){for(;u<n;)l++,u=Uo(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=Uo(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 Yp(e,t,n,r,o,i){let a=`${t}_${n}_${r}px`,s=lo.get(a);if(s!==void 0)return s;if(r<=0)return[];let l=[],u=t.split(`
4
- `),d=uo.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=Uo(e,p.slice(0,Math.max(0,h)),n,m),b=Math.min(p.length,h);if(g<=r)l.push(p);else{for(;g>r;){let x=Kp(e,p,r,n,g,b,m),C=p.slice(0,Math.max(0,x));p=p.slice(C.length),l.push(C),g=Uo(e,p.slice(0,Math.max(0,h)),n,m),b=Math.min(p.length,h)}g>0&&l.push(p)}}return l=l.map((p,g)=>g===0?p.trimEnd():p.trim()),lo.set(a,l),lo.size>500&&lo.delete(lo.keys().next().value),l}function qp(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 Vp(e,t){const[n,r]=t;if(e.columns.hasIndex(n)||e.rows.hasIndex(r))return!0;if(e.current!==void 0){if(Xo(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 Vo(e,t){return(e??"")===(t??"")}function Jp(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 kc(e,t){const[n,r]=e;return n>=t.x&&n<t.x+t.width&&r>=t.y&&r<t.y+t.height}function Xo(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 Sc(e){return[e.x+e.width-1,e.y+e.height-1]}function rl(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 Qp(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)&&rl(e,t,i)&&o++;for(const a of n.current.rangeStack)rl(e,t,a)&&o++;return o}function Rc(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 bo(e,t){let n=0;const r=Rc(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 Gr(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=Rc(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 Zp(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 eb(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 b=i-1-g,x=typeof a=="number"?a:a(b);if(h-=x,e>=h)return b}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 b=s;b<m;b++){const x=a(b);if(p<=g+x)return b;g+=x}return}}let Ii=0,Ko={};const tb=typeof window>"u";async function nb(){var e;tb||((e=document==null?void 0:document.fonts)==null?void 0:e.ready)===void 0||(await document.fonts.ready,Ii=0,Ko={},Gp())}nb();function Mc(e,t,n,r){return`${e}_${r??(t==null?void 0:t.font)}_${n}`}function Ki(e,t,n,r="middle"){const o=Mc(e,t,r,n);let i=Ko[o];return i===void 0&&(i=t.measureText(e),Ko[o]=i,Ii++),Ii>1e4&&(Ko={},Ii=0),i}function rb(e,t){const n=Mc(e,void 0,"middle",t);return Ko[n]}function Co(e,t){return typeof t!="string"&&(t=t.baseFontFull),ob(e,t)}function ol(e,t){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";e.save(),e.textBaseline=t;const r=e.measureText(n);return e.restore(),r}const il=[];function ob(e,t){for(const i of il)if(i.key===t)return i.val;const n=ol(e,"alphabetic"),o=-(ol(e,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return il.push({key:t,val:o}),o}function ib(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 Ic(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 Ec(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 sb(e,t){const n=Ki("ABCi09jgqpy",e,t);return n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}function ab(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 lb(e,t,n,r,o,i,a,s,l,u){const d=s.baseFontFull,h=Yp(e,t,d,o-s.cellHorizontalPadding*2,u??!1),m=sb(e,d),p=s.lineHeight*m,g=m+p*(h.length-1),b=g+s.cellVerticalPadding>i;b&&(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(Ec(e,w,n,C,o,m,a,s,l),C+=p,C>r+i)break;b&&e.restore()}function Tc(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=ab(t,d));const m=Co(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?lb(i,t,l,u,d,h,m,s,n,o):Ec(i,t,l,u,d,h,m,s,n),g&&(i.textAlign="start"),p&&(i.direction="inherit")}}function ho(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 cb(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 ub(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),b=1,x=!1;p<0?g<0?g=Math.PI+g:(g=Math.PI-g,b=-1,x=!0):g>0&&(b=-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 G=l.x+h.nx*w,B=l.y+h.ny*w;G+=-h.ny*M*b,B+=h.nx*M*b,e.arc(G,B,M,d.ang+Math.PI/2*b,h.ang-Math.PI/2*b,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 b={x:0,y:i+u,width:0,height:0};if(e>=p.length||t>=d||t<-2||e<0)return b;const x=i-o;if(e>=h){const C=a>e?-1:1,w=bo(p);b.x+=w+l;for(let M=a;M!==e;M+=C)b.x+=p[C===1?M:M-1].width*C}else for(let C=0;C<e;C++)b.x+=p[C].width;if(b.width=p[e].width+1,t===-1)b.y=o,b.height=x;else if(t===-2){b.y=0,b.height=o;let C=e;const w=p[e].group,M=p[e].sticky;for(;C>0&&Vo(p[C-1].group,w)&&p[C-1].sticky===M;){const B=p[C-1];b.x-=B.width,b.width+=B.width,C--}let G=e;for(;G+1<p.length&&Vo(p[G+1].group,w)&&p[G+1].sticky===M;){const B=p[G+1];b.width+=B.width,G++}if(!M){const B=bo(p),A=b.x-B;A<0&&(b.x-=A,b.width+=A),b.x+b.width>n&&(b.width=n-b.x)}}else if(t>=d-m){let C=d-t;for(b.y=r;C>0;){const w=t+C-1;b.height=typeof g=="number"?g:g(w),b.y-=b.height,C--}b.height+=1}else{const C=s>t?-1:1;if(typeof g=="number"){const w=t-s;b.y+=w*g}else for(let w=s;w!==t;w+=C)b.y+=g(w)*C;b.height=(typeof g=="number"?g:g(t))+1}return b}const ta=1<<21;function or(e,t){return(t+2)*ta+e}function Dc(e){return e%ta}function na(e){return Math.floor(e/ta)-2}function $c(e){const t=Dc(e),n=na(e);return[t,n]}class db{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=Dc(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&&po(this.freezeRows,r)||(this.visibleWindow=t,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class fb extends db{constructor(){super(...arguments);Xe(this,"cache",new Map);Xe(this,"setValue",(n,r)=>{this.cache.set(or(n[0],n[1]),r)});Xe(this,"getValue",n=>this.cache.get(or(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=>or(n[0],n[1])))}add(t){this.cells.add(or(t[0],t[1]))}has(t){return t===void 0?!1:this.cells.has(or(t[0],t[1]))}remove(t){this.cells.delete(or(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(or(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 $c(t)}}function hb(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 Ac={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 Fc(){return Ac}const gb=zt.createContext(Ac);function ir(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 mb(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 _c(e,t,n,r,o,i,a,s,l){let u=0;const d=o===void 0?[]:o.map(p=>{const g=mb(e,p[r],t,l);return u=Math.max(u,g),g});if(d.length>5&&s){u=0;let p=0;for(const b of d)p+=b;const g=p/d.length;for(let b=0;b<d.length;b++)d[b]>=g*2?d[b]=0:u=Math.max(u,d[b])}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 pb(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({}),b=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)),G=0;M<u.current&&M>1&&(M--,G=1);const B={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 V=w(B,l.signal),k=G>0?w(A,l.signal):void 0;let F;typeof V=="object"?F=V:F=await Ya(V),k!==void 0&&(typeof k=="object"?F=[...F,...k]:F=[...F,...await Ya(k)]),b.current=e,C(F)})()},[l.signal,e]),c.useMemo(()=>{let M=e.every(vi)?e:p===null?e.map(L=>vi(L)?L:{...L,width:As}):(p.font=h.current.baseFontFull,e.map((L,V)=>{if(vi(L))return L;if(g.current[L.id]!==void 0)return{...L,width:g.current[L.id]};if(x===void 0||b.current!==e||L.id===void 0)return{...L,width:As};const k=_c(p,a,L,V,x,o,i,!0,s);return g.current[L.id]=k.width,k})),G=0,B=0;const A=[];for(const[L,V]of M.entries())G+=V.width,V.grow!==void 0&&V.grow>0&&(B+=V.grow,A.push(L));if(G<r&&A.length>0){const L=[...M],V=r-G;let k=V;for(let F=0;F<A.length;F++){const H=A[F],j=(M[H].grow??0)/B,_=F===A.length-1?k:Math.min(k,Math.floor(V*j));L[H]={...M[H],growOffset:_,width:M[H].width+_},k-=_}M=L}return{sizedColumns:M,nonGrowWidth:G}},[r,e,p,x,a,o,i,s])}function bb(e,t,n){return e===e&&(n!==void 0&&(e=e<=n?e:n),t!==void 0&&(e=e>=t?e:t)),e}var yb=bb,vb=yb,gs=Zs;function wb(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),vb(gs(e),t,n)}var xb=wb;const En=zr(xb);var Cb="__lodash_hash_undefined__";function kb(e){return this.__data__.set(e,Cb),this}var Sb=kb;function Rb(e){return this.__data__.has(e)}var Mb=Rb,Ib=Xs,Eb=Sb,Tb=Mb;function _i(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ib;++t<n;)this.add(e[t])}_i.prototype.add=_i.prototype.push=Eb;_i.prototype.has=Tb;var Pc=_i;function Db(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 $b=Db;function Ab(e){return e!==e}var Fb=Ab;function _b(e,t,n){for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}var Pb=_b,Ob=$b,jb=Fb,Nb=Pb;function Hb(e,t,n){return t===t?Nb(e,t,n):Ob(e,jb,n)}var Bb=Hb,Lb=Bb;function zb(e,t){var n=e==null?0:e.length;return!!n&&Lb(e,t,0)>-1}var Wb=zb;function Gb(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 Ub=Gb;function Xb(e,t){return e.has(t)}var Oc=Xb,Kb=Wr,Yb=Qn,qb=Kb(Yb,"Set"),jc=qb;function Vb(){}var Jb=Vb;function Qb(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ra=Qb,ms=jc,Zb=Jb,ey=ra,ty=1/0,ny=ms&&1/ey(new ms([,-0]))[1]==ty?function(e){return new ms(e)}:Zb,ry=ny,oy=Pc,iy=Wb,sy=Ub,ay=Oc,ly=ry,cy=ra,uy=200;function dy(e,t,n){var r=-1,o=iy,i=e.length,a=!0,s=[],l=s;if(n)a=!1,o=sy;else if(i>=uy){var u=t?null:ly(e);if(u)return cy(u);a=!1,o=ay,l=new oy}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 fy=dy,hy=fy;function gy(e){return e&&e.length?hy(e):[]}var my=gy;const py=zr(my);function by(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}var Nc=by,sl=ei,yy=Ys,vy=Jn,al=sl?sl.isConcatSpreadable:void 0;function wy(e){return vy(e)||yy(e)||!!(al&&e&&e[al])}var xy=wy,Cy=Nc,ky=xy;function Hc(e,t,n,r,o){var i=-1,a=e.length;for(n||(n=ky),o||(o=[]);++i<a;){var s=e[i];t>0&&n(s)?t>1?Hc(s,t-1,n,r,o):Cy(o,s):r||(o[o.length]=s)}return o}var Sy=Hc,Ry=Sy;function My(e){var t=e==null?0:e.length;return t?Ry(e,1):[]}var Iy=My;const ll=zr(Iy);var Ey=Math.ceil,Ty=Math.max;function Dy(e,t,n,r){for(var o=-1,i=Ty(Ey((t-e)/(n||1)),0),a=Array(i);i--;)a[r?i:++o]=e,e+=n;return a}var $y=Dy,Ay=cc,Fy=Vs;function _y(e){return e!=null&&Fy(e.length)&&!Ay(e)}var oa=_y,Py=Gs,Oy=oa,jy=qs,Ny=yo;function Hy(e,t,n){if(!Ny(n))return!1;var r=typeof t;return(r=="number"?Oy(n)&&jy(t,n.length):r=="string"&&t in n)?Py(n[t],e):!1}var By=Hy,Ly=Zs,cl=1/0,zy=17976931348623157e292;function Wy(e){if(!e)return e===0?e:0;if(e=Ly(e),e===cl||e===-cl){var t=e<0?-1:1;return t*zy}return e===e?e:0}var Gy=Wy,Uy=$y,Xy=By,ps=Gy;function Ky(e){return function(t,n,r){return r&&typeof r!="number"&&Xy(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),Uy(t,n,r,e)}}var Yy=Ky,qy=Yy,Vy=qy(),Jy=Vy;const Br=zr(Jy);function Qy(e,t){return e==="normal"?[t.bgIconHeader,t.fgIconHeader]:e==="selected"?["white",t.accentColor]:[t.accentColor,t.bgHeader]}class Zy{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]=Qy(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 b=p.getContext("2d");if(b===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(()=>{b.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 Bc(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 Rr(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 Lc(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&&Vo(e[u].group,l.group)&&e[u].sticky===e[s].sticky;){const b=e[u];d+=b.width,u++,s++,b.sticky&&(a+=b.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 zc(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,b=r;for(let x=i.sourceIndex-1;x>=p;x--)g-=a[x].width,b+=a[x].width;for(let x=i.sourceIndex+1;x<=l;x++)b+=a[x].width;d={x:g,y:n,width:b,height:o}}if(h>s){const p=Math.min(l,h-1);let g=t,b=r;for(let x=i.sourceIndex-1;x>=s;x--)g-=a[x].width,b+=a[x].width;for(let x=i.sourceIndex+1;x<=p;x++)b+=a[x].width;u={x:g,y:n,width:b,height:o}}return[u,d]}function e0(e,t,n,r){if(r==="any")return Wc(e,{x:t,y:n,width:1,height:1});if(r==="vertical"&&(t=e.x),r==="horizontal"&&(n=e.y),kc([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 Jo(e,t,n,r,o,i,a,s){return e<=o+a&&o<=e+n&&t<=i+s&&i<=t+r}function go(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function Wc(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 t0(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 n0(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,b=h>0?e.y+e.height-Math.floor(h/r)*r:e.y+e.height;return{x:m,y:g,width:p-m,height:b-g}}function r0(e,t,n,r,o){const[i,a,s,l]=t,[u,d,h,m]=o,{x:p,y:g,width:b,height:x}=e,C=[];if(b<=0||x<=0)return C;const w=p+b,M=g+x,G=p<i,B=g<a,A=p+b>s,L=g+x>l,V=p>=i&&p<s||w>i&&w<=s||p<i&&w>s,k=g>=a&&g<l||M>a&&M<=l||g<a&&M>l;if(V&&k){const H=Math.max(p,i),j=Math.max(g,a),_=Math.min(w,s),D=Math.min(M,l);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:u,y:d,width:h-u+1,height:m-d+1}})}if(G&&B){const H=p,j=g,_=Math.min(w,i),D=Math.min(M,a);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:0,y:0,width:u+1,height:d+1}})}if(B&&V){const H=Math.max(p,i),j=g,_=Math.min(w,s),D=Math.min(M,a);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:u,y:0,width:h-u+1,height:d+1}})}if(B&&A){const H=Math.max(p,s),j=g,_=w,D=Math.min(M,a);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:h,y:0,width:n-h+1,height:d+1}})}if(G&&k){const H=p,j=Math.max(g,a),_=Math.min(w,i),D=Math.min(M,l);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:0,y:d,width:u+1,height:m-d+1}})}if(A&&k){const H=Math.max(p,s),j=Math.max(g,a),_=w,D=Math.min(M,l);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:h,y:d,width:n-h+1,height:m-d+1}})}if(G&&L){const H=p,j=Math.max(g,l),_=Math.min(w,i),D=M;C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:0,y:m,width:u+1,height:r-m+1}})}if(L&&V){const H=Math.max(p,i),j=Math.max(g,l),_=Math.min(w,s),D=M;C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:u,y:m,width:h-u+1,height:r-m+1}})}if(A&&L){const H=Math.max(p,s),j=Math.max(g,l),_=w,D=M;C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:h,y:m,width:n-h+1,height:r-m+1}})}return C}const o0={kind:ce.Loading,allowOverlay:!1};function ul(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w,M,G,B,A,L,V,k,F,H,j,_,D,fe,U,Z,he){let de=(M==null?void 0:M.size)??Number.MAX_SAFE_INTEGER;const ee=performance.now();let q=_.baseFontFull;e.font=q;const Se={ctx:e},se=[0,0],oe=x>0?Gr(l,x,u):0;let Ee,J;const ae=Bc(w);return Rr(t,s,i,a,o,(pe,Ge,Oe,rt,je)=>{const Te=Math.max(0,rt-Ge),Fe=Ge+Te,_e=o+1,mt=pe.width-Te,xt=r-o-1;if(w.length>0){let ot=!1;for(let Le=0;Le<w.length;Le++){const Ke=w[Le];if(Jo(Fe,_e,mt,xt,Ke.x,Ke.y,Ke.width,Ke.height)){ot=!0;break}}if(!ot)return}const pt=()=>{e.save(),e.beginPath(),e.rect(Fe,_e,mt,xt),e.clip()},ie=G.columns.hasIndex(pe.sourceIndex),be=h(pe.group??"").overrideTheme,Me=pe.themeOverride===void 0&&be===void 0?_:ir(_,be,pe.themeOverride),De=Me.baseFontFull;De!==q&&(q=De,e.font=De),pt();let ke;return Yi(je,Oe,r,l,u,x,C,ae,(ot,Le,Ke,ue,ye)=>{var Je,It,$t;if(Le<0||(se[0]=pe.sourceIndex,se[1]=Le,M!==void 0&&!M.has(se)))return;if(w.length>0){let tt=!1;for(let Rt=0;Rt<w.length;Rt++){const gt=w[Rt];if(Jo(Ge,ot,pe.width,Ke,gt.x,gt.y,gt.width,gt.height)){tt=!0;break}}if(!tt)return}const Ye=G.rows.hasIndex(Le),Ve=p.hasIndex(Le),it=Le<l?d(se):o0;let xe=Ge,dt=pe.width,Ne=!1,He=!1;if(it.span!==void 0){const[tt,Rt]=it.span,gt=`${Le},${tt},${Rt},${pe.sticky}`;if(J===void 0&&(J=new Set),J.has(gt)){de--;return}else{const qt=zc(it.span,Ge,ot,pe.width,Ke,pe,n),Nt=pe.sticky?qt[0]:qt[1];if(!pe.sticky&&qt[0]!==void 0&&(He=!0),Nt!==void 0){xe=Nt.x,dt=Nt.width,J.add(gt),e.restore(),ke=void 0,e.save(),e.beginPath();const Ot=Math.max(0,rt-Nt.x);e.rect(Nt.x+Ot,ot,Nt.width-Ot,Ke),Ee===void 0&&(Ee=[]),Ee.push({x:Nt.x+Ot,y:ot,width:Nt.width-Ot,height:Ke}),e.clip(),Ne=!0}}}const st=m==null?void 0:m(Le),Wt=ye&&((Je=pe.trailingRowOptions)==null?void 0:Je.themeOverride)!==void 0?(It=pe.trailingRowOptions)==null?void 0:It.themeOverride:void 0,ct=it.themeOverride===void 0&&st===void 0&&Wt===void 0?Me:ir(Me,st,Wt,it.themeOverride);e.beginPath();const $e=Jp(se,it,G);let bt=Qp(se,it,G,b);const Ht=it.span!==void 0&&G.columns.some(tt=>it.span!==void 0&&tt>=it.span[0]&&tt<=it.span[1]);$e&&!g&&b?bt=0:$e&&b&&(bt=Math.max(bt,1)),Ht&&bt++,$e||(Ye&&bt++,ie&&!ye&&bt++);const Yt=it.kind===ce.Protected?ct.bgCellMedium:ct.bgCell;let vt;if((ue||Yt!==_.bgCell)&&(vt=bn(Yt,vt)),bt>0||Ve){Ve&&(vt=bn(ct.bgHeader,vt));for(let tt=0;tt<bt;tt++)vt=bn(ct.accentLight,vt)}else if(B!==void 0){for(const tt of B)if(tt[0]===pe.sourceIndex&&tt[1]===Le){vt=bn(ct.bgSearchResult,vt);break}}if(A!==void 0)for(let tt=0;tt<A.length;tt++){const Rt=A[tt],gt=Rt.range;Rt.style!=="solid-outline"&&gt.x<=pe.sourceIndex&&pe.sourceIndex<gt.x+gt.width&&gt.y<=Le&&Le<gt.y+gt.height&&(vt=bn(Rt.color,vt))}let yn=!1;if(M!==void 0){const tt=ot+1,gt=(ue?tt+Ke-1:Math.min(tt+Ke-1,r-oe))-tt;(gt!==Ke-1||xe+1<=rt)&&(yn=!0,e.save(),e.beginPath(),e.rect(xe+1,tt,dt-1,gt),e.clip()),vt=vt===void 0?ct.bgCell:bn(vt,ct.bgCell)}const dn=pe.sourceIndex===n.length-1,kt=Le===l-1;vt!==void 0&&(e.fillStyle=vt,ke!==void 0&&(ke.fillStyle=vt),M!==void 0?e.fillRect(xe+1,ot+1,dt-(dn?2:1),Ke-(kt?2:1)):e.fillRect(xe,ot,dt,Ke)),it.style==="faded"&&(e.globalAlpha=.6);let Ut;for(let tt=0;tt<k.length;tt++){const Rt=k[tt];if(Rt.item[0]===pe.sourceIndex&&Rt.item[1]===Le){Ut=Rt;break}}if(dt>he&&!He){const tt=ct.baseFontFull;tt!==q&&(e.font=tt,q=tt),ke=Gc(e,it,pe.sourceIndex,Le,dn,kt,xe,ot,dt,Ke,bt>0,ct,vt??ct.bgCell,L,V,(Ut==null?void 0:Ut.hoverAmount)??0,F,j,ee,H,ke,D,fe,U,Z)}return yn&&e.restore(),it.style==="faded"&&(e.globalAlpha=1),de--,Ne&&(e.restore(),($t=ke==null?void 0:ke.deprep)==null||$t.call(ke,Se),ke=void 0,pt(),q=De,e.font=De),de<=0}),e.restore(),de<=0}),Ee}const jo=[0,0],No={x:0,y:0,width:0,height:0},bs=[void 0,()=>{}];let Fs=!1;function i0(){Fs=!0}function Gc(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w,M,G,B,A,L,V){var fe,U;let k,F;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(k=x[1][0],F=x[1][1]);let H;jo[0]=n,jo[1]=r,No.x=a,No.y=s,No.width=l,No.height=u,bs[0]=A.getValue(jo),bs[1]=Z=>A.setValue(jo,Z),Fs=!1;const j={ctx:e,theme:h,col:n,row:r,cell:t,rect:No,highlighted:d,cellFillColor:m,hoverAmount:b,frameTime:w,hoverX:k,drawState:bs,hoverY:F,imageLoader:p,spriteManager:g,hyperWrapping:C,overrideCursor:k!==void 0?V:void 0,requestAnimationFrame:i0},_=ib(j,t.lastUpdated,w,G,o,i),D=L(t);if(D!==void 0){(G==null?void 0:G.renderer)!==D&&((fe=G==null?void 0:G.deprep)==null||fe.call(G,j),G=void 0);const Z=(U=D.drawPrep)==null?void 0:U.call(D,j,G);M!==void 0&&!co(j.cell)?M(j,()=>D.draw(j,t)):D.draw(j,t),H=Z===void 0?void 0:{deprep:Z==null?void 0:Z.deprep,fillStyle:Z==null?void 0:Z.fillStyle,font:Z==null?void 0:Z.font,renderer:D}}return(_||Fs)&&(B==null||B(jo)),H}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 b=xc(d??t.checkboxMaxSize,a,t.cellVerticalPadding),x=b/2;const C=wc(h,r,i,t.cellHorizontalPadding,b),w=vc(C,p,b),M=Cc(r+l,o+u,w);switch(n){case!0:{e.beginPath(),ho(e,C-b/2,p-b/2,b,b,g),m==="circle"&&(x*=.8,b*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(C-x+b/4.23,p-x+b/1.97),e.lineTo(C-x+b/2.42,p-x+b/1.44),e.lineTo(C-x+b/1.29,p-x+b/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(),ho(e,C-b/2+.5,p-b/2+.5,b-1,b-1,g),e.lineWidth=1,e.strokeStyle=M?t.textDark:t.textMedium,e.stroke();break}case Js:{e.beginPath(),ho(e,C-b/2,p-b/2,b,b,g),e.fillStyle=M?t.textMedium:t.textLight,e.fill(),m==="circle"&&(x*=.8,b*=.8),e.beginPath(),e.moveTo(C-b/3,p),e.lineTo(C+b/3,p),e.strokeStyle=t.bgCell,e.lineCap="round",e.lineWidth=1.9,e.stroke();break}default:qo()}}function s0(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w){var k,F,H,j;const M=a+s;if(M<=0)return;e.fillStyle=h.bgHeader,e.fillRect(0,0,o,M);const G=(k=r==null?void 0:r[0])==null?void 0:k[0],B=(F=r==null?void 0:r[0])==null?void 0:F[1],A=(H=r==null?void 0:r[1])==null?void 0:H[0],L=(j=r==null?void 0:r[1])==null?void 0:j[1],V=h.headerFontFull;e.font=V,Rr(t,0,i,0,M,(_,D,fe,U)=>{var pe;if(x!==void 0&&!x.has([_.sourceIndex,-1]))return;const Z=Math.max(0,U-D);e.save(),e.beginPath(),e.rect(D+Z,s,_.width-Z,a),e.clip();const he=b(_.group??"").overrideTheme,de=_.themeOverride===void 0&&he===void 0?h:ir(h,he,_.themeOverride);de.bgHeader!==h.bgHeader&&(e.fillStyle=de.bgHeader,e.fill()),de!==h&&(e.font=de.headerFontFull);const ee=d.columns.hasIndex(_.sourceIndex),q=l!==void 0||u||_.headerRowMarkerDisabled===!0,Se=!q&&B===-1&&G===_.sourceIndex,se=q?0:((pe=p.find(Ge=>Ge.item[0]===_.sourceIndex&&Ge.item[1]===-1))==null?void 0:pe.hoverAmount)??0,oe=(d==null?void 0:d.current)!==void 0&&d.current.cell[0]===_.sourceIndex,Ee=ee?de.accentColor:oe?de.bgHeaderHasFocus:de.bgHeader,J=n?s:0,ae=_.sourceIndex===0?0:1;ee?(e.fillStyle=Ee,e.fillRect(D+ae,J,_.width-ae,a)):(oe||se>0)&&(e.beginPath(),e.rect(D+ae,J,_.width-ae,a),oe&&(e.fillStyle=de.bgHeaderHasFocus,e.fill()),se>0&&(e.globalAlpha=se,e.fillStyle=de.bgHeaderHovered,e.fill(),e.globalAlpha=1)),Kc(e,D,J,_.width,a,_,ee,de,Se,Se?A:void 0,Se?L:void 0,oe,se,m,C,w),e.restore()}),n&&a0(e,t,o,i,s,r,h,m,p,g,b,x)}function a0(e,t,n,r,o,i,a,s,l,u,d,h){const[p,g]=(i==null?void 0:i[0])??[];let b=0;Lc(t,n,r,o,(x,C,w,M,G,B)=>{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,G,B),e.clip();const A=d(C),L=(A==null?void 0:A.overrideTheme)===void 0?a:ir(a,A.overrideTheme),V=g===-2&&p!==void 0&&p>=x[0]&&p<=x[1],k=V?L.bgGroupHeaderHovered??L.bgHeaderHovered:L.bgGroupHeader??L.bgHeader;if(k!==a.bgHeader&&(e.fillStyle=k,e.fill()),e.fillStyle=L.textGroupHeader??L.textHeader,A!==void 0){let F=w;if(A.icon!==void 0&&(s.drawSprite(A.icon,"normal",e,F+8,(o-20)/2,20,L),F+=26),e.fillText(A.name,F+8,o/2+Co(e,a.headerFontFull)),A.actions!==void 0&&V){const H=Uc({x:w,y:M,width:G,height:B},A.actions);e.beginPath();const j=H[0].x-10,_=w+G-j;e.rect(j,0,_,o);const D=e.createLinearGradient(j,0,j+_,0),fe=Lr(k,0);D.addColorStop(0,fe),D.addColorStop(10/_,k),D.addColorStop(1,k),e.fillStyle=D,e.fill(),e.globalAlpha=.6;const[U,Z]=(i==null?void 0:i[1])??[-1,-1];for(let he=0;he<A.actions.length;he++){const de=A.actions[he],ee=H[he],q=go(ee,U+w,Z);q&&(e.globalAlpha=1),s.drawSprite(de.icon,"normal",e,ee.x+ee.width/2-10,ee.y+ee.height/2-10,20,L),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(),b=w+G}),e.beginPath(),e.moveTo(b+.5,0),e.lineTo(b+.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 l0(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 Uc(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 Ho(e,t,n){return!n||e===void 0||(e.x=t-(e.x-t)-e.width),e}function Xc(e,t,n,r,o,i,a,s){var C;const l=a.cellHorizontalPadding,u=a.headerIconSize,d=l0(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 b;if(t.indicatorIcon!==void 0){const w=e===void 0?((C=rb(t.title,a.headerFontFull))==null?void 0:C.width)??0:Ki(t.title,e,a.headerFontFull).width;g.width=w,h+=w+l,b={x:h,y:r+(i-u)/2,width:u,height:u}}const x=n+o/2;return{menuBounds:Ho(d,x,s),iconBounds:Ho(m,x,s),iconOverlayBounds:Ho(p,x,s),textBounds:Ho(g,x,s),indicatorIconBounds:Ho(b,x,s)}}function dl(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b){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?ir(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)&&b.menuBounds!==void 0;if(i.icon!==void 0&&b.iconBounds!==void 0){let w=a?"selected":"normal";i.style==="highlight"&&(w=a?"selected":"special"),m.drawSprite(i.icon,w,e,b.iconBounds.x,b.iconBounds.y,b.iconBounds.width,s),i.overlayIcon!==void 0&&b.iconOverlayBounds!==void 0&&m.drawSprite(i.overlayIcon,a?"selected":"special",e,b.iconOverlayBounds.x,b.iconOverlayBounds.y,b.iconOverlayBounds.width,s)}if(C&&r>35){const M=g?35:r-35,G=g?35*.7:r-35*.7,B=M/r,A=G/r,L=e.createLinearGradient(t,0,t+r,0),V=Lr(x,0);L.addColorStop(g?1:0,x),L.addColorStop(B,x),L.addColorStop(A,V),L.addColorStop(g?0:1,V),e.fillStyle=L}else e.fillStyle=x;if(g&&(e.textAlign="right"),b.textBounds!==void 0&&e.fillText(i.title,g?b.textBounds.x+b.textBounds.width:b.textBounds.x,n+o/2+Co(e,s.headerFontFull)),g&&(e.textAlign="left"),i.indicatorIcon!==void 0&&b.indicatorIconBounds!==void 0&&(!C||!Jo(b.menuBounds.x,b.menuBounds.y,b.menuBounds.width,b.menuBounds.height,b.indicatorIconBounds.x,b.indicatorIconBounds.y,b.indicatorIconBounds.width,b.indicatorIconBounds.height))){let w=a?"selected":"normal";i.style==="highlight"&&(w=a?"selected":"special"),m.drawSprite(i.indicatorIcon,w,e,b.indicatorIconBounds.x,b.indicatorIconBounds.y,b.indicatorIconBounds.width,s)}if(C&&b.menuBounds!==void 0){const w=b.menuBounds,M=u!==void 0&&d!==void 0&&go(w,u+t,d+n);if(M||(e.globalAlpha=.7),i.menuIcon===void 0||i.menuIcon===Ai.Triangle){e.beginPath();const G=w.x+w.width/2-5.5,B=w.y+w.height/2-3;ub(e,[{x:G,y:B},{x:G+11,y:B},{x:G+5.5,y:B+6}],1),e.fillStyle=x,e.fill()}else if(i.menuIcon===Ai.Dots){e.beginPath();const G=w.x+w.width/2,B=w.y+w.height/2;cb(e,G,B),e.fillStyle=x,e.fill()}else{const G=w.x+(w.width-s.headerIconSize)/2,B=w.y+(w.height-s.headerIconSize)/2;m.drawSprite(i.menuIcon,"normal",e,G,B,s.headerIconSize,s)}M||(e.globalAlpha=1)}}function Kc(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b){const x=ea(i.title)==="rtl",C=Xc(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},()=>dl(e,t,n,r,o,i,a,s,l,u,d,m,p,b,x,C)):dl(e,t,n,r,o,i,a,s,l,u,d,m,p,b,x,C)}var c0=Wr,u0=function(){try{var e=c0(Object,"defineProperty");return e({},"",{}),e}catch{}}(),d0=u0,fl=d0;function f0(e,t,n){t=="__proto__"&&fl?fl(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var h0=f0;function g0(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 m0=g0;function p0(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 b0=p0,y0=b0,v0=y0(),w0=v0;function x0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var C0=x0,Pi={exports:{}};function k0(){return!1}var S0=k0;Pi.exports;(function(e,t){var n=Qn,r=S0,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 Yc=Pi.exports,R0=ti,M0=Vs,I0=ni,E0="[object Arguments]",T0="[object Array]",D0="[object Boolean]",$0="[object Date]",A0="[object Error]",F0="[object Function]",_0="[object Map]",P0="[object Number]",O0="[object Object]",j0="[object RegExp]",N0="[object Set]",H0="[object String]",B0="[object WeakMap]",L0="[object ArrayBuffer]",z0="[object DataView]",W0="[object Float32Array]",G0="[object Float64Array]",U0="[object Int8Array]",X0="[object Int16Array]",K0="[object Int32Array]",Y0="[object Uint8Array]",q0="[object Uint8ClampedArray]",V0="[object Uint16Array]",J0="[object Uint32Array]",Tt={};Tt[W0]=Tt[G0]=Tt[U0]=Tt[X0]=Tt[K0]=Tt[Y0]=Tt[q0]=Tt[V0]=Tt[J0]=!0;Tt[E0]=Tt[T0]=Tt[L0]=Tt[D0]=Tt[z0]=Tt[$0]=Tt[A0]=Tt[F0]=Tt[_0]=Tt[P0]=Tt[O0]=Tt[j0]=Tt[N0]=Tt[H0]=Tt[B0]=!1;function Q0(e){return I0(e)&&M0(e.length)&&!!Tt[R0(e)]}var Z0=Q0;function ev(e){return function(t){return e(t)}}var tv=ev,Oi={exports:{}};Oi.exports;(function(e,t){var n=ac,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 nv=Oi.exports,rv=Z0,ov=tv,hl=nv,gl=hl&&hl.isTypedArray,iv=gl?ov(gl):rv,qc=iv,sv=C0,av=Ys,lv=Jn,cv=Yc,uv=qs,dv=qc,fv=Object.prototype,hv=fv.hasOwnProperty;function gv(e,t){var n=lv(e),r=!n&&av(e),o=!n&&!r&&cv(e),i=!n&&!r&&!o&&dv(e),a=n||r||o||i,s=a?sv(e.length,String):[],l=s.length;for(var u in e)(t||hv.call(e,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||uv(u,l)))&&s.push(u);return s}var mv=gv,pv=Object.prototype;function bv(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||pv;return e===n}var yv=bv;function vv(e,t){return function(n){return e(t(n))}}var wv=vv,xv=wv,Cv=xv(Object.keys,Object),kv=Cv,Sv=yv,Rv=kv,Mv=Object.prototype,Iv=Mv.hasOwnProperty;function Ev(e){if(!Sv(e))return Rv(e);var t=[];for(var n in Object(e))Iv.call(e,n)&&n!="constructor"&&t.push(n);return t}var Tv=Ev,Dv=mv,$v=Tv,Av=oa;function Fv(e){return Av(e)?Dv(e):$v(e)}var sa=Fv,_v=w0,Pv=sa;function Ov(e,t){return e&&_v(e,t,Pv)}var jv=Ov,Nv=oa;function Hv(e,t){return function(n,r){if(n==null)return n;if(!Nv(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 Bv=Hv,Lv=jv,zv=Bv,Wv=zv(Lv),Gv=Wv,Uv=Gv;function Xv(e,t,n,r){return Uv(e,function(o,i,a){t(r,o,n(o),a)}),r}var Kv=Xv,Yv=Gi;function qv(){this.__data__=new Yv,this.size=0}var Vv=qv;function Jv(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var Qv=Jv;function Zv(e){return this.__data__.get(e)}var ew=Zv;function tw(e){return this.__data__.has(e)}var nw=tw,rw=Gi,ow=Us,iw=Xs,sw=200;function aw(e,t){var n=this.__data__;if(n instanceof rw){var r=n.__data__;if(!ow||r.length<sw-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new iw(r)}return n.set(e,t),this.size=n.size,this}var lw=aw,cw=Gi,uw=Vv,dw=Qv,fw=ew,hw=nw,gw=lw;function ko(e){var t=this.__data__=new cw(e);this.size=t.size}ko.prototype.clear=uw;ko.prototype.delete=dw;ko.prototype.get=fw;ko.prototype.has=hw;ko.prototype.set=gw;var Vc=ko;function mw(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 pw=mw,bw=Pc,yw=pw,vw=Oc,ww=1,xw=2;function Cw(e,t,n,r,o,i){var a=n&ww,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&xw?new bw:void 0;for(i.set(e,t),i.set(t,e);++h<s;){var g=e[h],b=t[h];if(r)var x=a?r(b,g,h,t,e,i):r(g,b,h,e,t,i);if(x!==void 0){if(x)continue;m=!1;break}if(p){if(!yw(t,function(C,w){if(!vw(p,w)&&(g===C||o(g,C,n,r,i)))return p.push(w)})){m=!1;break}}else if(!(g===b||o(g,b,n,r,i))){m=!1;break}}return i.delete(e),i.delete(t),m}var Jc=Cw,kw=Qn,Sw=kw.Uint8Array,Rw=Sw;function Mw(e){var t=-1,n=Array(e.size);return e.forEach(function(r,o){n[++t]=[o,r]}),n}var Iw=Mw,ml=ei,pl=Rw,Ew=Gs,Tw=Jc,Dw=Iw,$w=ra,Aw=1,Fw=2,_w="[object Boolean]",Pw="[object Date]",Ow="[object Error]",jw="[object Map]",Nw="[object Number]",Hw="[object RegExp]",Bw="[object Set]",Lw="[object String]",zw="[object Symbol]",Ww="[object ArrayBuffer]",Gw="[object DataView]",bl=ml?ml.prototype:void 0,ys=bl?bl.valueOf:void 0;function Uw(e,t,n,r,o,i,a){switch(n){case Gw:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Ww:return!(e.byteLength!=t.byteLength||!i(new pl(e),new pl(t)));case _w:case Pw:case Nw:return Ew(+e,+t);case Ow:return e.name==t.name&&e.message==t.message;case Hw:case Lw:return e==t+"";case jw:var s=Dw;case Bw:var l=r&Aw;if(s||(s=$w),e.size!=t.size&&!l)return!1;var u=a.get(e);if(u)return u==t;r|=Fw,a.set(e,t);var d=Tw(s(e),s(t),r,o,i,a);return a.delete(e),d;case zw:if(ys)return ys.call(e)==ys.call(t)}return!1}var Xw=Uw,Kw=Nc,Yw=Jn;function qw(e,t,n){var r=t(e);return Yw(e)?r:Kw(r,n(e))}var Vw=qw;function Jw(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 Qw=Jw;function Zw(){return[]}var ex=Zw,tx=Qw,nx=ex,rx=Object.prototype,ox=rx.propertyIsEnumerable,yl=Object.getOwnPropertySymbols,ix=yl?function(e){return e==null?[]:(e=Object(e),tx(yl(e),function(t){return ox.call(e,t)}))}:nx,sx=ix,ax=Vw,lx=sx,cx=sa;function ux(e){return ax(e,cx,lx)}var dx=ux,vl=dx,fx=1,hx=Object.prototype,gx=hx.hasOwnProperty;function mx(e,t,n,r,o,i){var a=n&fx,s=vl(e),l=s.length,u=vl(t),d=u.length;if(l!=d&&!a)return!1;for(var h=l;h--;){var m=s[h];if(!(a?m in t:gx.call(t,m)))return!1}var p=i.get(e),g=i.get(t);if(p&&g)return p==t&&g==e;var b=!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)){b=!1;break}x||(x=m=="constructor")}if(b&&!x){var G=e.constructor,B=t.constructor;G!=B&&"constructor"in e&&"constructor"in t&&!(typeof G=="function"&&G instanceof G&&typeof B=="function"&&B instanceof B)&&(b=!1)}return i.delete(e),i.delete(t),b}var px=mx,bx=Wr,yx=Qn,vx=bx(yx,"DataView"),wx=vx,xx=Wr,Cx=Qn,kx=xx(Cx,"Promise"),Sx=kx,Rx=Wr,Mx=Qn,Ix=Rx(Mx,"WeakMap"),Ex=Ix,_s=wx,Ps=Us,Os=Sx,js=jc,Ns=Ex,Qc=ti,So=uc,wl="[object Map]",Tx="[object Object]",xl="[object Promise]",Cl="[object Set]",kl="[object WeakMap]",Sl="[object DataView]",Dx=So(_s),$x=So(Ps),Ax=So(Os),Fx=So(js),_x=So(Ns),Hr=Qc;(_s&&Hr(new _s(new ArrayBuffer(1)))!=Sl||Ps&&Hr(new Ps)!=wl||Os&&Hr(Os.resolve())!=xl||js&&Hr(new js)!=Cl||Ns&&Hr(new Ns)!=kl)&&(Hr=function(e){var t=Qc(e),n=t==Tx?e.constructor:void 0,r=n?So(n):"";if(r)switch(r){case Dx:return Sl;case $x:return wl;case Ax:return xl;case Fx:return Cl;case _x:return kl}return t});var Px=Hr,vs=Vc,Ox=Jc,jx=Xw,Nx=px,Rl=Px,Ml=Jn,Il=Yc,Hx=qc,Bx=1,El="[object Arguments]",Tl="[object Array]",Ci="[object Object]",Lx=Object.prototype,Dl=Lx.hasOwnProperty;function zx(e,t,n,r,o,i){var a=Ml(e),s=Ml(t),l=a?Tl:Rl(e),u=s?Tl:Rl(t);l=l==El?Ci:l,u=u==El?Ci:u;var d=l==Ci,h=u==Ci,m=l==u;if(m&&Il(e)){if(!Il(t))return!1;a=!0,d=!1}if(m&&!d)return i||(i=new vs),a||Hx(e)?Ox(e,t,n,r,o,i):jx(e,t,l,n,r,o,i);if(!(n&Bx)){var p=d&&Dl.call(e,"__wrapped__"),g=h&&Dl.call(t,"__wrapped__");if(p||g){var b=p?e.value():e,x=g?t.value():t;return i||(i=new vs),o(b,x,n,r,i)}}return m?(i||(i=new vs),Nx(e,t,n,r,o,i)):!1}var Wx=zx,Gx=Wx,$l=ni;function Zc(e,t,n,r,o){return e===t?!0:e==null||t==null||!$l(e)&&!$l(t)?e!==e&&t!==t:Gx(e,t,n,r,Zc,o)}var eu=Zc,Ux=Vc,Xx=eu,Kx=1,Yx=2;function qx(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 Ux;if(r)var m=r(u,d,l,e,t,h);if(!(m===void 0?Xx(d,u,Kx|Yx,r,h):m))return!1}}return!0}var Vx=qx,Jx=yo;function Qx(e){return e===e&&!Jx(e)}var tu=Qx,Zx=tu,e1=sa;function t1(e){for(var t=e1(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,Zx(o)]}return t}var n1=t1;function r1(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}var nu=r1,o1=Vx,i1=n1,s1=nu;function a1(e){var t=i1(e);return t.length==1&&t[0][2]?s1(t[0][0],t[0][1]):function(n){return n===e||o1(n,e,t)}}var l1=a1,c1=hc,u1=Xi;function d1(e,t){t=c1(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[u1(t[n++])];return n&&n==r?e:void 0}var ru=d1,f1=ru;function h1(e,t,n){var r=e==null?void 0:f1(e,t);return r===void 0?n:r}var g1=h1;function m1(e,t){return e!=null&&t in Object(e)}var p1=m1,b1=p1,y1=mc;function v1(e,t){return e!=null&&y1(e,t,b1)}var w1=v1,x1=eu,C1=g1,k1=w1,S1=Ws,R1=tu,M1=nu,I1=Xi,E1=1,T1=2;function D1(e,t){return S1(e)&&R1(t)?M1(I1(e),t):function(n){var r=C1(n,e);return r===void 0&&r===t?k1(n,e):x1(t,r,E1|T1)}}var $1=D1;function A1(e){return e}var F1=A1;function _1(e){return function(t){return t==null?void 0:t[e]}}var P1=_1,O1=ru;function j1(e){return function(t){return O1(t,e)}}var N1=j1,H1=P1,B1=N1,L1=Ws,z1=Xi;function W1(e){return L1(e)?H1(z1(e)):B1(e)}var G1=W1,U1=l1,X1=$1,K1=F1,Y1=Jn,q1=G1;function V1(e){return typeof e=="function"?e:e==null?K1:typeof e=="object"?Y1(e)?X1(e[0],e[1]):U1(e):q1(e)}var J1=V1,Q1=m0,Z1=Kv,eC=J1,tC=Jn;function nC(e,t){return function(n,r){var o=tC(n)?Q1:Z1,i=t?t():{};return o(n,e,eC(r),i)}}var rC=nC,oC=h0,iC=rC,sC=Object.prototype,aC=sC.hasOwnProperty,lC=iC(function(e,t,n){aC.call(e,n)?e[n].push(t):oC(e,n,[t])}),cC=lC;const uC=zr(cC);function dC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w){if(C!==void 0||t[t.length-1]!==n[t.length-1])return;const M=Bc(x);Rr(t,l,a,s,i,(G,B,A,L,V)=>{if(G!==t[t.length-1])return;B+=G.width;const k=Math.max(B,L);k>r||(e.save(),e.beginPath(),e.rect(k,i+1,1e4,o-i-1),e.clip(),Yi(V,A,o,u,d,g,b,M,(F,H,j,_)=>{if(!_&&x.length>0&&!x.some(he=>Jo(B,F,1e4,j,he.x,he.y,he.width,he.height)))return;const D=m.hasIndex(H),fe=p.hasIndex(H);e.beginPath();const U=h==null?void 0:h(H),Z=U===void 0?w:ir(w,U);Z.bgCell!==w.bgCell&&(e.fillStyle=Z.bgCell,e.fillRect(B,F,1e4,j)),fe&&(e.fillStyle=Z.bgHeader,e.fillRect(B,F,1e4,j)),D&&(e.fillStyle=Z.accentLight,e.fillRect(B,F,1e4,j))}),e.restore())})}function fC(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?bo(t):0;let p;if(m!==0&&(p=nl(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:nl(d,l.bgCell),b=Gr(i,o,s);e.beginPath(),e.moveTo(0,r-b+.5),e.lineTo(n,r-b+.5),e.strokeStyle=g,e.stroke()}}const ou=(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 hC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g){var j;const b=g.bgCell,{minX:x,maxX:C,minY:w,maxY:M}=ou(s,i,a),G=[],B=a-Gr(p,m,u);let A=l,L=n,V=0;for(;A+o<B;){const _=A+o,D=u(L);if(_>=w&&_<=M-1){const fe=d==null?void 0:d(L),U=fe==null?void 0:fe.bgCell;U!==void 0&&U!==b&&L>=p-m&&G.push({x,y:_,w:C-x,h:D,color:U})}A+=D,L<p-m&&(V=A),L++}let k=0;const F=Math.min(B,M)-V;if(F>0)for(let _=0;_<t.length;_++){const D=t[_];if(D.width===0)continue;const fe=D.sticky?k:k+r,U=(j=D.themeOverride)==null?void 0:j.bgCell;U!==void 0&&U!==b&&fe>=x&&fe<=C&&h(_+1)&&G.push({x:fe,y:V,w:D.width,h:F,color:U}),k+=D.width}if(G.length===0)return;let H;e.beginPath();for(let _=G.length-1;_>=0;_--){const D=G[_];H===void 0?H=D.color:D.color!==H&&(e.fillStyle=H,e.fill(),e.beginPath(),H=D.color),e.rect(D.x,D.y,D.w,D.h)}H!==void 0&&(e.fillStyle=H,e.fill()),e.beginPath()}function Al(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C=!1){if(l!==void 0){e.beginPath(),e.save(),e.rect(0,0,i,a);for(const j of l)e.rect(j.x+1,j.y+1,j.width-1,j.height-1);e.clip("evenodd")}const w=x.horizontalBorderColor??x.borderColor,M=x.borderColor,{minX:G,maxX:B,minY:A,maxY:L}=ou(s,i,a),V=[];e.beginPath();let k=.5;for(let j=0;j<t.length;j++){const _=t[j];if(_.width===0)continue;k+=_.width;const D=_.sticky?k:k+r;D>=G&&D<=B&&p(j+1)&&V.push({x1:D,y1:Math.max(u,A),x2:D,y2:Math.min(a,L),color:M})}let F=a+.5;for(let j=b-g;j<b;j++){const _=h(j);F-=_,V.push({x1:G,y1:F,x2:B,y2:F,color:w})}if(C!==!0){let j=d+.5,_=n;const D=F;for(;j+o<D;){const fe=j+o;if(fe>=A&&fe<=L-1){const U=m==null?void 0:m(_);V.push({x1:G,y1:fe,x2:B,y2:fe,color:(U==null?void 0:U.horizontalBorderColor)??(U==null?void 0:U.borderColor)??w})}j+=h(_),_++}}const H=uC(V,j=>j.color);for(const j of Object.keys(H)){e.strokeStyle=j;for(const _ of H[j])e.moveTo(_.x1,_.y1),e.lineTo(_.x2,_.y2);e.stroke(),e.beginPath()}l!==void 0&&e.restore()}function gC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w){const M=[];e.imageSmoothingEnabled=!1;const G=Math.min(o.cellYOffset,a),B=Math.max(o.cellYOffset,a);let A=0;if(typeof C=="number")A+=(B-G)*C;else for(let D=G;D<B;D++)A+=C(D);a>o.cellYOffset&&(A=-A),A+=l-o.translateY;const L=Math.min(o.cellXOffset,i),V=Math.max(o.cellXOffset,i);let k=0;for(let D=L;D<V;D++)k+=b[D].width;i>o.cellXOffset&&(k=-k),k+=s-o.translateX;const F=bo(x);if(k!==0&&A!==0)return{regions:[]};const H=u>0?Gr(m,u,C):0,j=d-F-Math.abs(k),_=h-p-H-Math.abs(A)-1;if(j>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-H,width:d,height:-A+H})),k>0?(D.sx=F*g,D.sw=j*g,D.dx=(k+F)*g,D.dw=j*g,M.push({x:F-1,y:0,width:k+2,height:h})):k<0&&(D.sx=(F-k)*g,D.sw=j*g,D.dx=F*g,D.dw=j*g,M.push({x:d+k,y:0,width:-k,height:h})),e.setTransform(1,0,0,1,0,0),w){if(F>0&&k!==0&&A===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const fe=F*g,U=h*g;e.drawImage(t,0,0,fe,U,0,0,fe,U)}if(H>0&&k===0&&A!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const fe=(h-H)*g,U=d*g,Z=H*g;e.drawImage(t,0,fe,U,Z,0,fe,U,Z)}}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 mC(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||Rr(l,n,r,o,s,(h,m,p,g)=>{if(h.sourceIndex===u){const b=Math.max(m,g)+1;return d.push({x:b,y:0,width:i-b,height:a}),!0}}),d}function pC(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(po(o,i))continue;if(n!==void 0||o.width===i.width)return!1;const{width:a,...s}=o,{width:l,...u}=i;if(!po(s,u))return!1;n=r}return n===void 0?!0:n}return!0}function Fl(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b){const x=g==null?void 0:g.filter(L=>L.style!=="no-outline");if(x===void 0||x.length===0)return;const C=bo(s),w=Gr(p,m,h),M=[l,0,s.length,p-m],G=[C,0,t,n-w],B=x.map(L=>{const V=L.range,k=L.style??"dashed";return r0(V,M,t,n,G).map(F=>{const H=F.rect,j=$s(H.x,H.y,t,n,d,u+d,r,o,i,a,p,l,m,s,h),_=H.width===1&&H.height===1?j:$s(H.x+H.width-1,H.y+H.height-1,t,n,d,u+d,r,o,i,a,p,l,m,s,h);return H.x+H.width>=s.length&&(_.width-=1),H.y+H.height>=p&&(_.height-=1),{color:L.color,style:k,clip:F.clip,rect:n0({x:j.x,y:j.y,width:_.x+_.width-j.x,height:_.y+_.height-j.y},t,n,8)}})}),A=()=>{e.lineWidth=1;let L=!1;for(const V of B)for(const k of V)if((k==null?void 0:k.rect)!==void 0&&Jo(0,0,t,n,k.rect.x,k.rect.y,k.rect.width,k.rect.height)){const F=L,H=!t0(k.clip,k.rect);e.beginPath(),H&&(e.save(),e.rect(k.clip.x,k.clip.y,k.clip.width,k.clip.height),e.clip()),k.style==="dashed"&&!L?(e.setLineDash([5,3]),L=!0):(k.style==="solid"||k.style==="solid-outline")&&L&&(e.setLineDash([]),L=!1),e.strokeStyle=k.style==="solid-outline"?bn(bn(k.color,b.borderColor),b.bgCell):Lr(k.color,1),e.closePath(),e.strokeRect(k.rect.x+.5,k.rect.y+.5,k.rect.width-1,k.rect.height-1),H&&(e.restore(),L=F)}L&&e.setLineDash([])};return A(),A}function _l(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,b,x){if(d.current===void 0)return;const C=b!==!1&&b!==void 0;if(!C)return;const w=typeof b=="object"?{...Fi,...b}:Fi,M=d.current.range,G=d.current.cell,B=[M.x+M.width-1,M.y+M.height-1];if(G[1]>=x&&B[1]>=x||!a.some(U=>U.sourceIndex===G[0]||U.sourceIndex===B[0]))return;const[L,V]=d.current.cell,k=m(d.current.cell),F=k.span??[L,L],H=V>=x-p,j=p>0&&!H?Gr(x,p,h)-1:0,_=B[1];let D;if(Rr(a,r,o,i,u,(U,Z,he,de,ee)=>{if(U.sticky&&L>U.sourceIndex)return;const q=U.sourceIndex<F[0],Se=U.sourceIndex>F[1],se=U.sourceIndex===B[0];if(!(!se&&(q||Se)))return Yi(ee,he,n,x,h,p,g,void 0,(oe,Ee,J)=>{if(Ee!==V&&Ee!==_)return;let ae=Z,pe=U.width;if(k.span!==void 0){const Oe=zc(k.span,Z,oe,U.width,J,U,s),rt=U.sticky?Oe[0]:Oe[1];rt!==void 0&&(ae=rt.x,pe=rt.width)}return Ee===_&&se&&C&&(D=()=>{var Fe;de>ae&&!U.sticky&&(e.beginPath(),e.rect(de,0,t-de,n),e.clip());const Oe=w.size,rt=Oe/2,je=ae+pe+w.offsetX-rt+.5,Te=oe+J+w.offsetY-rt+.5;e.beginPath(),w.shape==="circle"?e.arc(je+rt,Te+rt,rt,0,Math.PI*2):e.rect(je,Te,Oe,Oe),e.fillStyle=((Fe=U.themeOverride)==null?void 0:Fe.accentColor)??l.accentColor,e.fill(),w.outline>0&&(e.lineWidth=w.outline,e.strokeStyle=l.bgCell,w.shape==="circle"?(e.beginPath(),e.arc(je+rt,Te+rt,rt+w.outline/2,0,Math.PI*2),e.stroke()):e.strokeRect(je-w.outline/2,Te-w.outline/2,Oe+w.outline,Oe+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-j),e.clip(),D==null||D(),e.restore()};return fe(),fe}function bC(e,t,n,r,o,i,a,s,l){l===void 0||l.size===0||(e.beginPath(),Lc(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)}),Rr(t,s,i,a,o,(u,d,h,m)=>{const p=Math.max(0,m-d),g=d+p+1,b=u.width-p-1;l.has([u.sourceIndex,-1])&&e.rect(g,r,b,o-r)}),e.clip())}function yC(e,t,n,r,o,i,a,s,l,u){let d=0;return Rr(e,i,r,o,n,(h,m,p,g,b)=>(Yi(b,p,t,a,s,l,u,void 0,(x,C,w,M)=>{M||(d=Math.max(C,d))}),!0)),d}function Pl(e,t){var dn;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:b,headerHeight:x,groupHeaderHeight:C,disabledRows:w,rowHeight:M,verticalBorder:G,overrideCursor:B,isResizing:A,selection:L,fillHandle:V,freezeTrailingRows:k,rows:F,getCellContent:H,getGroupDetails:j,getRowThemeOverride:_,isFocused:D,drawHeaderCallback:fe,prelightCells:U,drawCellCallback:Z,highlightRegions:he,resizeCol:de,imageLoader:ee,lastBlitData:q,hoverValues:Se,hyperWrapping:se,hoverInfo:oe,spriteManager:Ee,maxScaleFactor:J,hasAppendRow:ae,touchMode:pe,enqueue:Ge,renderStateProvider:Oe,getCellRenderer:rt,renderStrategy:je,bufferACtx:Te,bufferBCtx:Fe,damage:_e,minimumCellWidth:mt,resizeIndicator:xt}=e;if(o===0||i===0)return;const pt=je==="double-buffer",ie=Math.min(J,Math.ceil(window.devicePixelRatio??1)),be=je!=="direct"&&pC(e,t),Me=n.canvas;(Me.width!==o*ie||Me.height!==i*ie)&&(Me.width=o*ie,Me.height=i*ie,Me.style.width=o+"px",Me.style.height=i+"px");const De=r.canvas,ke=h?C+x:x,ot=ke+1;(De.width!==o*ie||De.height!==ot*ie)&&(De.width=o*ie,De.height=ot*ie,De.style.width=o+"px",De.style.height=ot+"px");const Le=Te.canvas,Ke=Fe.canvas;pt&&(Le.width!==o*ie||Le.height!==i*ie)&&(Le.width=o*ie,Le.height=i*ie,q.current!==void 0&&(q.current.aBufferScroll=void 0)),pt&&(Ke.width!==o*ie||Ke.height!==i*ie)&&(Ke.width=o*ie,Ke.height=i*ie,q.current!==void 0&&(q.current.bBufferScroll=void 0));const ue=q.current;if(be===!0&&a===(ue==null?void 0:ue.cellXOffset)&&s===(ue==null?void 0:ue.cellYOffset)&&l===(ue==null?void 0:ue.translateX)&&u===(ue==null?void 0:ue.translateY))return;let ye=null;pt&&(ye=n);const Ye=r;let Ve;pt?_e!==void 0?Ve=(ue==null?void 0:ue.lastBuffer)==="b"?Fe:Te:Ve=(ue==null?void 0:ue.lastBuffer)==="b"?Te:Fe:Ve=n;const it=Ve.canvas,xe=pt?it===Le?Ke:Le:Me,dt=typeof M=="number"?()=>M:M;Ye.save(),Ve.save(),Ye.beginPath(),Ve.beginPath(),Ye.textBaseline="middle",Ve.textBaseline="middle",ie!==1&&(Ye.scale(ie,ie),Ve.scale(ie,ie));const Ne=Ds(d,a,o,p,l);let He=[];const st=b&&((dn=L.current)==null?void 0:dn.cell[1])===s&&u===0;let Wt=!1;if(he!==void 0){for(const kt of he)if(kt.style!=="no-outline"&&kt.range.y===s&&u===0){Wt=!0;break}}const ct=()=>{s0(Ye,Ne,h,oe,o,l,x,C,p,A,L,g,Ee,Se,G,j,_e,fe,pe),Al(Ye,Ne,s,l,u,o,i,void 0,void 0,C,ke,dt,_,G,k,F,g,!0),Ye.beginPath(),Ye.moveTo(0,ot-.5),Ye.lineTo(o,ot-.5),Ye.strokeStyle=bn(g.headerBottomBorderColor??g.horizontalBorderColor??g.borderColor,g.bgHeader),Ye.stroke(),Wt&&Fl(Ye,o,i,a,s,l,u,d,m,x,C,M,k,F,he,g),st&&ws(Ye,o,i,s,l,u,Ne,d,g,ke,L,dt,H,k,ae,V,F)};if(_e!==void 0){const kt=Ne[Ne.length-1].sourceIndex+1,Ut=_e.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-k,width:kt,height:k,when:k>0}]),Je=It=>{ul(It,Ne,d,i,ke,l,u,s,F,dt,H,j,_,w,D,b,k,ae,He,_e,L,U,he,ee,Ee,Se,oe,Z,se,g,Ge,Oe,rt,B,mt);const $t=L.current;V!==!1&&V!==void 0&&b&&$t!==void 0&&_e.has(Sc($t.range))&&ws(It,o,i,s,l,u,Ne,d,g,ke,L,dt,H,k,ae,V,F)};Ut&&(Je(Ve),ye!==null&&(ye.save(),ye.scale(ie,ie),ye.textBaseline="middle",Je(ye),ye.restore()),_e.hasHeader()&&(bC(Ye,Ne,o,C,ke,l,u,s,_e),ct())),Ve.restore(),Ye.restore();return}if((be!==!0||a!==(ue==null?void 0:ue.cellXOffset)||l!==(ue==null?void 0:ue.translateX)||st!==(ue==null?void 0:ue.mustDrawFocusOnHeader)||Wt!==(ue==null?void 0:ue.mustDrawHighlightRingsOnHeader))&&ct(),be===!0){pn(xe!==void 0&&ue!==void 0);const{regions:kt}=gC(Ve,xe,xe===Le?ue.aBufferScroll:ue.bBufferScroll,xe===Le?ue.bBufferScroll:ue.aBufferScroll,ue,a,s,l,u,k,o,i,F,ke,ie,d,Ne,M,pt);He=kt}else be!==!1&&(pn(ue!==void 0),He=mC(ue,a,s,l,u,o,i,ke,Ne,be));fC(Ve,Ne,o,i,k,F,G,dt,g);const $e=Fl(Ve,o,i,a,s,l,u,d,m,x,C,M,k,F,he,g),bt=b?ws(Ve,o,i,s,l,u,Ne,d,g,ke,L,dt,H,k,ae,V,F):void 0;if(Ve.fillStyle=g.bgCell,He.length>0){Ve.beginPath();for(const kt of He)Ve.rect(kt.x,kt.y,kt.width,kt.height);Ve.clip(),Ve.fill(),Ve.beginPath()}else Ve.fillRect(0,0,o,i);const Ht=ul(Ve,Ne,d,i,ke,l,u,s,F,dt,H,j,_,w,D,b,k,ae,He,_e,L,U,he,ee,Ee,Se,oe,Z,se,g,Ge,Oe,rt,B,mt);dC(Ve,Ne,d,o,i,ke,l,u,s,F,dt,_,L.rows,w,k,ae,He,_e,g),hC(Ve,Ne,s,l,u,o,i,He,ke,dt,_,G,k,F,g),Al(Ve,Ne,s,l,u,o,i,He,Ht,C,ke,dt,_,G,k,F,g),$e==null||$e(),bt==null||bt(),A&&xt!=="none"&&Rr(Ne,0,l,0,ke,(kt,Ut)=>kt.sourceIndex===de?(_l(Ye,Ut+kt.width,0,ke+1,bn(g.resizeIndicatorColor??g.accentLight,g.bgHeader)),xt==="full"&&_l(Ve,Ut+kt.width,ke,i,bn(g.resizeIndicatorColor??g.accentLight,g.bgCell)),!0):!1),ye!==null&&(ye.fillStyle=g.bgCell,ye.fillRect(0,0,o,i),ye.drawImage(Ve.canvas,0,0));const Yt=yC(Ne,i,ke,l,u,s,F,dt,k,ae);ee==null||ee.setWindow({x:a,y:s,width:Ne.length,height:Yt-s},m,Array.from({length:k},(kt,Ut)=>F-1-Ut));const vt=ue!==void 0&&(a!==ue.cellXOffset||l!==ue.translateX),yn=ue!==void 0&&(s!==ue.cellYOffset||u!==ue.translateY);q.current={cellXOffset:a,cellYOffset:s,translateX:l,translateY:u,mustDrawFocusOnHeader:st,mustDrawHighlightRingsOnHeader:Wt,lastBuffer:pt?it===Le?"a":"b":void 0,aBufferScroll:it===Le?[vt,yn]:ue==null?void 0:ue.aBufferScroll,bBufferScroll:it===Ke?[vt,yn]:ue==null?void 0:ue.bBufferScroll},Ve.restore(),Ye.restore()}const vC=80;function wC(e){const t=e-1;return t*t*t+1}class xC{constructor(t){Xe(this,"callback");Xe(this,"currentHoveredItem");Xe(this,"leavingItems",[]);Xe(this,"lastAnimationTime");Xe(this,"addToLeavingItems",t=>{this.leavingItems.some(r=>Xo(r.item,t.item))||this.leavingItems.push(t)});Xe(this,"removeFromLeavingItems",t=>{const n=this.leavingItems.find(r=>Xo(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:wC(t.hoverAmount)})));Xe(this,"step",t=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=t;else{const r=(t-this.lastAnimationTime)/vC;for(const i of this.leavingItems)i.hoverAmount=En(i.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=En(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(!Xo((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 CC{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 CC(e)}const kC=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 SC(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($c);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=or(i[0],i[1]);t.current.includes(a)||t.current.push(a)},[o])}const Cr="header",Ln="group-header",Hi="out-of-bounds";var fo;(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"})(fo||(fo={}));function iu(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 RC=(e,t)=>{if(e.kind===ce.Custom)return e.copyData;const n=t==null?void 0:t(e);return(n==null?void 0:n.getAccessibilityString(e))??""},MC=(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:b,onHeaderIndicatorClick:x,enableGroups:C,isFilling:w,onCanvasFocused:M,onCanvasBlur:G,isFocused:B,selection:A,freezeColumns:L,onContextMenu:V,freezeTrailingRows:k,fixedShadowX:F=!0,fixedShadowY:H=!0,drawFocusRing:j,onMouseDown:_,onMouseUp:D,onMouseMoveRaw:fe,onMouseMove:U,onItemHovered:Z,dragAndDropState:he,firstColAccessible:de,onKeyDown:ee,onKeyUp:q,highlightRegions:Se,canvasRef:se,onDragStart:oe,onDragEnd:Ee,eventTargetRef:J,isResizing:ae,resizeColumn:pe,isDragging:Ge,isDraggable:Oe=!1,allowResize:rt,disabledRows:je,hasAppendRow:Te,getGroupDetails:Fe,theme:_e,prelightCells:mt,headerIcons:xt,verticalBorder:pt,drawCell:ie,drawHeader:be,onCellFocused:Me,onDragOverCell:De,onDrop:ke,onDragLeave:ot,imageWindowLoader:Le,smoothScrollX:Ke=!1,smoothScrollY:ue=!1,experimental:ye,getCellRenderer:Ye,resizeIndicator:Ve="full"}=e,it=e.translateX??0,xe=e.translateY??0,dt=Math.max(L,Math.min(i.length-1,a)),Ne=c.useRef(null),He=c.useRef((ye==null?void 0:ye.eventTarget)??window),st=He.current,Wt=Le,ct=c.useRef(),[$e,bt]=c.useState(!1),Ht=c.useRef([]),Yt=c.useRef(),[vt,yn]=c.useState(),[dn,kt]=c.useState(),Ut=c.useRef(null),[Je,It]=c.useState(),[$t,tt]=c.useState(!1),Rt=c.useRef($t);Rt.current=$t;const gt=c.useMemo(()=>new Zy(xt,()=>{rn.current=void 0,Gn.current()}),[xt]),qt=C?d+l:l,Nt=c.useRef(-1),Ot=((ye==null?void 0:ye.enableFirefoxRescaling)??!1)&&kC.value,Gt=((ye==null?void 0:ye.enableSafariRescaling)??!1)&&ji.value;c.useLayoutEffect(()=>{window.devicePixelRatio===1||!Ot&&!Gt||(Nt.current!==-1&&bt(!0),window.clearTimeout(Nt.current),Nt.current=window.setTimeout(()=>{bt(!1),Nt.current=-1},200))},[s,dt,it,xe,Ot,Gt]);const Be=qp(i,L),$n=c.useMemo(()=>F?bo(Be,he):0,[Be,he,F]),At=c.useCallback((I,Y,ge)=>{const me=I.getBoundingClientRect();if(Y>=Be.length||ge>=m)return;const y=me.width/n,T=$s(Y,ge,n,r,d,qt,dt,s,it,xe,m,L,k,Be,h);return y!==1&&(T.x*=y,T.y*=y,T.width*=y,T.height*=y),T.x+=me.x,T.y+=me.y,T},[n,r,d,qt,dt,s,it,xe,m,L,k,Be,h]),nt=c.useCallback((I,Y,ge,me)=>{const y=I.getBoundingClientRect(),T=y.width/n,z=(Y-y.left)/T,ne=(ge-y.top)/T,te=5,ft=Ds(Be,dt,n,void 0,it);let Ce=0,at=0;const Ue=typeof PointerEvent<"u"&&me instanceof PointerEvent&&me.pointerType==="mouse"||typeof MouseEvent<"u"&&me instanceof MouseEvent,qe=typeof PointerEvent<"u"&&me instanceof PointerEvent&&me.pointerType==="touch"||typeof TouchEvent<"u"&&me instanceof TouchEvent;Ue&&(Ce=me.button,at=me.buttons);const ze=Zp(z,ft,it),ut=eb(ne,r,C,l,d,m,h,s,xe,k),_t=(me==null?void 0:me.shiftKey)===!0,On=(me==null?void 0:me.ctrlKey)===!0,jn=(me==null?void 0:me.metaKey)===!0,Mt=[z<0?-1:n<z?1:0,ne<qt?-1:r<ne?1:0];let jt;if(ze===-1||ne<0||z<0||ut===void 0||z>n||ne>r){const wt=z>n?1:z<0?-1:0,Rn=ne>r?1:ne<0?-1:0;let tn=wt*2,Qr=Rn*2;wt===0&&(tn=ze===-1?fo.EndPadding:fo.Center),Rn===0&&(Qr=ut===void 0?fo.EndPadding:fo.Center);let nr=!1;if(ze===-1&&ut===-1){const Bt=At(I,Be.length-1,-1);pn(Bt!==void 0),nr=Y<Bt.x+Bt.width+te}const Qe=z>n&&z<n+Is()||ne>r&&ne<r+Is();jt={kind:Hi,location:[ze!==-1?ze:z<0?0:Be.length-1,ut??m-1],region:[tn,Qr],shiftKey:_t,ctrlKey:On,metaKey:jn,isEdge:nr,isTouch:qe,button:Ce,buttons:at,scrollEdge:Mt,isMaybeScrollbar:Qe}}else if(ut<=-1){let wt=At(I,ze,ut);pn(wt!==void 0);let Rn=wt!==void 0&&wt.x+wt.width-Y<=te;const tn=ze-1;Y-wt.x<=te&&tn>=0?(Rn=!0,wt=At(I,tn,ut),pn(wt!==void 0),jt={kind:C&&ut===-2?Ln:Cr,location:[tn,ut],bounds:wt,group:Be[tn].group??"",isEdge:Rn,shiftKey:_t,ctrlKey:On,metaKey:jn,isTouch:qe,localEventX:Y-wt.x,localEventY:ge-wt.y,button:Ce,buttons:at,scrollEdge:Mt}):jt={kind:C&&ut===-2?Ln:Cr,group:Be[ze].group??"",location:[ze,ut],bounds:wt,isEdge:Rn,shiftKey:_t,ctrlKey:On,metaKey:jn,isTouch:qe,localEventX:Y-wt.x,localEventY:ge-wt.y,button:Ce,buttons:at,scrollEdge:Mt}}else{const wt=At(I,ze,ut);pn(wt!==void 0);const Rn=wt!==void 0&&wt.x+wt.width-Y<te;let tn=!1;if(u!==!1&&u!==void 0&&A.current!==void 0){const nr=typeof u=="object"?{...Fi,...u}:Fi,Qe=nr.size,Bt=Qe/2,Ar=Sc(A.current.range),mr=At(I,Ar[0],Ar[1]);if(mr!==void 0){const rr=mr.x+mr.width+nr.offsetX-Bt+.5,St=mr.y+mr.height+nr.offsetY-Bt+.5;tn=Math.abs(rr-Y)<Qe&&Math.abs(St-ge)<Qe}}jt={kind:"cell",location:[ze,ut],bounds:wt,isEdge:Rn,shiftKey:_t,ctrlKey:On,isFillHandle:tn,metaKey:jn,isTouch:qe,localEventX:Y-wt.x,localEventY:ge-wt.y,button:Ce,buttons:at,scrollEdge:Mt}}return jt},[n,Be,dt,it,r,C,l,d,m,h,s,xe,k,At,u,A,qt]),[Xt]=vt??[],Et=c.useRef(()=>{}),Qt=c.useRef(vt);Qt.current=vt;const[ln,Ft]=c.useMemo(()=>{const I=document.createElement("canvas"),Y=document.createElement("canvas");return I.style.display="none",I.style.opacity="0",I.style.position="fixed",Y.style.display="none",Y.style.opacity="0",Y.style.position="fixed",[I.getContext("2d",{alpha:!1}),Y.getContext("2d",{alpha:!1})]},[]);c.useLayoutEffect(()=>{if(!(ln===null||Ft===null))return document.documentElement.append(ln.canvas),document.documentElement.append(Ft.canvas),()=>{ln.canvas.remove(),Ft.canvas.remove()}},[ln,Ft]);const Zn=c.useMemo(()=>new fb,[]),Ir=Ot&&$e?1:Gt&&$e?2:5,vn=(ye==null?void 0:ye.disableMinimumCellWidth)===!0?1:10,rn=c.useRef(),wn=c.useRef(null),zn=c.useRef(null),Wn=c.useCallback(()=>{var z;const I=Ne.current,Y=Ut.current;if(I===null||Y===null||(wn.current===null&&(wn.current=I.getContext("2d",{alpha:!1}),I.width=0,I.height=0),zn.current===null&&(zn.current=Y.getContext("2d",{alpha:!1}),Y.width=0,Y.height=0),wn.current===null||zn.current===null||ln===null||Ft===null))return;let ge=!1;const me=ne=>{ge=!0,It(ne)},y=rn.current,T={headerCanvasCtx:zn.current,canvasCtx:wn.current,bufferACtx:ln,bufferBCtx:Ft,width:n,height:r,cellXOffset:dt,cellYOffset:s,translateX:Math.round(it),translateY:Math.round(xe),mappedColumns:Be,enableGroups:C,freezeColumns:L,dragAndDropState:he,theme:_e,headerHeight:l,groupHeaderHeight:d,disabledRows:je??lt.empty(),rowHeight:h,verticalBorder:pt,isResizing:ae,resizeCol:pe,isFocused:B,selection:A,fillHandle:u,drawCellCallback:ie,hasAppendRow:Te,overrideCursor:me,maxScaleFactor:Ir,freezeTrailingRows:k,rows:m,drawFocus:j,getCellContent:p,getGroupDetails:Fe??(ne=>({name:ne})),getRowThemeOverride:g,drawHeaderCallback:be,prelightCells:mt,highlightRegions:Se,imageLoader:Wt,lastBlitData:Yt,damage:ct.current,hoverValues:Ht.current,hoverInfo:Qt.current,spriteManager:gt,scrolling:$e,hyperWrapping:(ye==null?void 0:ye.hyperWrapping)??!1,touchMode:$t,enqueue:Et.current,renderStateProvider:Zn,renderStrategy:(ye==null?void 0:ye.renderStrategy)??(ji.value?"double-buffer":"single-buffer"),getCellRenderer:Ye,minimumCellWidth:vn,resizeIndicator:Ve};T.damage===void 0?(rn.current=T,Pl(T,y)):Pl(T,void 0),!ge&&(T.damage===void 0||T.damage.has((z=Qt==null?void 0:Qt.current)==null?void 0:z[0]))&&It(void 0)},[ln,Ft,n,r,dt,s,it,xe,Be,C,L,he,_e,l,d,je,h,pt,ae,Te,pe,B,A,u,k,m,j,Ir,p,Fe,g,ie,be,mt,Se,Wt,gt,$e,ye==null?void 0:ye.hyperWrapping,ye==null?void 0:ye.renderStrategy,$t,Zn,Ye,vn,Ve]),Gn=c.useRef(Wn);c.useLayoutEffect(()=>{Wn(),Gn.current=Wn},[Wn]),c.useLayoutEffect(()=>{(async()=>{var Y;((Y=document==null?void 0:document.fonts)==null?void 0:Y.ready)!==void 0&&(await document.fonts.ready,rn.current=void 0,Gn.current())})()},[]);const An=c.useCallback(I=>{ct.current=I,Gn.current(),ct.current=void 0},[]),Ro=SC(An);Et.current=Ro;const Ur=c.useCallback(I=>{An(new Ei(I.map(Y=>Y.cell)))},[An]);Wt.setCallback(An);const[Mo,er]=c.useState(!1),[fn,xn]=Xt??[],Io=fn!==void 0&&xn===-1&&fn>=0&&fn<Be.length&&Be[fn].headerRowMarkerDisabled!==!0,Xr=fn!==void 0&&xn===-2;let sr=!1,Kr=!1,Cn=Je;if(Cn===void 0&&fn!==void 0&&xn!==void 0&&xn>-1&&xn<m){const I=p([fn,xn],!0);sr=I.kind===Tn.NewRow||I.kind===Tn.Marker&&I.markerKind!=="number",Kr=I.kind===ce.Boolean&&Qs(I),Cn=I.cursor}const Yr=Ge?"grabbing":(dn??!1)||ae?"col-resize":Mo||w?"crosshair":Cn!==void 0?Cn:Io||sr||Kr||Xr?"pointer":"default",lr=c.useMemo(()=>({contain:"strict",display:"block",cursor:Yr}),[Yr]),yt=c.useRef("default"),Vt=J==null?void 0:J.current;Vt!=null&&yt.current!==lr.cursor&&(Vt.style.cursor=yt.current=lr.cursor);const cr=c.useCallback((I,Y,ge,me)=>{if(Fe===void 0)return;const y=Fe(I);if(y.actions!==void 0){const T=Uc(Y,y.actions);for(const[z,ne]of T.entries())if(go(ne,ge+Y.x,me+ne.y))return y.actions[z]}},[Fe]),Fn=c.useCallback((I,Y,ge,me)=>{const y=Be[Y];if(!Ge&&!ae&&!(dn??!1)){const T=At(I,Y,-1);pn(T!==void 0);const z=Xc(void 0,y,T.x,T.y,T.width,T.height,_e,ea(y.title)==="rtl");if(y.hasMenu===!0&&z.menuBounds!==void 0&&go(z.menuBounds,ge,me))return{area:"menu",bounds:z.menuBounds};if(y.indicatorIcon!==void 0&&z.indicatorIconBounds!==void 0&&go(z.indicatorIconBounds,ge,me))return{area:"indicator",bounds:z.indicatorIconBounds}}},[Be,At,dn,Ge,ae,_e]),ur=c.useRef(0),Un=c.useRef(),dr=c.useRef(!1),fr=c.useCallback(I=>{const Y=Ne.current,ge=J==null?void 0:J.current;if(Y===null||I.target!==Y&&I.target!==ge)return;dr.current=!0;const me=I.clientX,y=I.clientY;if(I.target===ge&&ge!==null){const z=ge.getBoundingClientRect();if(me>z.right||y>z.bottom)return}const T=nt(Y,me,y,I);Un.current=T.location,T.isTouch&&(ur.current=Date.now()),Rt.current!==T.isTouch&&tt(T.isTouch),!(T.kind===Cr&&Fn(Y,T.location[0],me,y)!==void 0)&&(T.kind===Ln&&cr(T.group,T.bounds,T.localEventX,T.localEventY)!==void 0||(_==null||_(T),!T.isTouch&&Oe!==!0&&Oe!==T.kind&&T.button<3&&T.button!==1&&I.preventDefault()))},[J,Oe,nt,cr,Fn,_]);an("pointerdown",fr,st,!1);const on=c.useRef(0),hn=c.useCallback(I=>{var at,Ue;const Y=on.current;on.current=Date.now();const ge=Ne.current;if(dr.current=!1,D===void 0||ge===null)return;const me=J==null?void 0:J.current,y=I.target!==ge&&I.target!==me,T=I.clientX,z=I.clientY,ne=I.pointerType==="mouse"?I.button<3:!0;let te=nt(ge,T,z,I);te.isTouch&&ur.current!==0&&Date.now()-ur.current>500&&(te={...te,isLongTouch:!0}),Y!==0&&Date.now()-Y<(te.isTouch?1e3:500)&&(te={...te,isDoubleClick:!0}),Rt.current!==te.isTouch&&tt(te.isTouch),!y&&I.cancelable&&ne&&I.preventDefault();const[ft]=te.location,Ce=Fn(ge,ft,T,z);if(te.kind===Cr&&Ce!==void 0){(te.button!==0||((at=Un.current)==null?void 0:at[0])!==ft||((Ue=Un.current)==null?void 0:Ue[1])!==-1)&&D(te,!0);return}else if(te.kind===Ln){const qe=cr(te.group,te.bounds,te.localEventX,te.localEventY);if(qe!==void 0){te.button===0&&qe.onClick(te);return}}D(te,y)},[D,J,nt,Fn,cr]);an("pointerup",hn,st,!1);const Jt=c.useCallback(I=>{var ft,Ce;const Y=Ne.current;if(Y===null)return;const ge=J==null?void 0:J.current,me=I.target!==Y&&I.target!==ge;let y,T,z=!0;I instanceof MouseEvent?(y=I.clientX,T=I.clientY,z=I.button<3):(y=I.changedTouches[0].clientX,T=I.changedTouches[0].clientY);const ne=nt(Y,y,T,I);Rt.current!==ne.isTouch&&tt(ne.isTouch),!me&&I.cancelable&&z&&I.preventDefault();const[te]=ne.location;if(ne.kind===Cr){const at=Fn(Y,te,y,T);at!==void 0&&ne.button===0&&((ft=Un.current)==null?void 0:ft[0])===te&&((Ce=Un.current)==null?void 0:Ce[1])===-1&&(at.area==="menu"?b==null||b(te,at.bounds):at.area==="indicator"&&(x==null||x(te,at.bounds)))}},[J,nt,Fn,b,x]);an("click",Jt,st,!1);const Eo=c.useCallback(I=>{const Y=Ne.current,ge=J==null?void 0:J.current;if(Y===null||I.target!==Y&&I.target!==ge||V===void 0)return;const me=nt(Y,I.clientX,I.clientY,I);V(me,()=>{I.cancelable&&I.preventDefault()})},[J,nt,V]);an("contextmenu",Eo,(J==null?void 0:J.current)??null,!1);const Er=c.useCallback(I=>{ct.current=new Ei(I.map(Y=>Y.item)),Ht.current=I,Gn.current(),ct.current=void 0},[]),Re=c.useMemo(()=>new xC(Er),[Er]),hr=c.useRef(Re);hr.current=Re,c.useLayoutEffect(()=>{const I=hr.current;if(Xt===void 0||Xt[1]<0){I.setHovered(Xt);return}const Y=p(Xt,!0),ge=Ye(Y),me=ge===void 0&&Y.kind===ce.Custom||(ge==null?void 0:ge.needsHover)!==void 0&&(typeof ge.needsHover=="boolean"?ge.needsHover:ge.needsHover(Y));I.setHovered(me?Xt:void 0)},[p,Ye,Xt]);const _n=c.useRef(),Zt=c.useCallback(I=>{var ne;const Y=Ne.current;if(Y===null)return;const ge=J==null?void 0:J.current,me=I.target!==Y&&I.target!==ge,y=nt(Y,I.clientX,I.clientY,I);if(y.kind!=="out-of-bounds"&&me&&!dr.current&&!y.isTouch)return;const T=(te,ft)=>{yn(Ce=>Ce===te||(Ce==null?void 0:Ce[0][0])===(te==null?void 0:te[0][0])&&(Ce==null?void 0:Ce[0][1])===(te==null?void 0:te[0][1])&&((Ce==null?void 0:Ce[1][0])===(te==null?void 0:te[1][0])&&(Ce==null?void 0:Ce[1][1])===(te==null?void 0:te[1][1])||!ft)?Ce:te)};if(!iu(y,_n.current))It(void 0),Z==null||Z(y),T(y.kind===Hi?void 0:[y.location,[y.localEventX,y.localEventY]],!0),_n.current=y;else if(y.kind==="cell"||y.kind===Cr||y.kind===Ln){let te=!1,ft=!0;if(y.kind==="cell"){const at=p(y.location);ft=((ne=Ye(at))==null?void 0:ne.needsHoverPosition)??at.kind===ce.Custom,te=ft}else te=!0;const Ce=[y.location,[y.localEventX,y.localEventY]];T(Ce,ft),Qt.current=Ce,te&&An(new Ei([y.location]))}const z=y.location[0]>=(de?0:1);kt(y.kind===Cr&&y.isEdge&&z&&rt===!0),er(y.kind==="cell"&&y.isFillHandle),fe==null||fe(I),U(y)},[J,nt,de,rt,fe,U,Z,p,Ye,An]);an("pointermove",Zt,st,!0);const Tr=c.useCallback(I=>{const Y=Ne.current;if(Y===null)return;let ge,me;A.current!==void 0&&(ge=At(Y,A.current.cell[0],A.current.cell[1]),me=A.current.cell),ee==null||ee({bounds:ge,stopPropagation:()=>I.stopPropagation(),preventDefault:()=>I.preventDefault(),cancel:()=>{},ctrlKey:I.ctrlKey,metaKey:I.metaKey,shiftKey:I.shiftKey,altKey:I.altKey,key:I.key,keyCode:I.keyCode,rawEvent:I,location:me})},[ee,A,At]),kn=c.useCallback(I=>{const Y=Ne.current;if(Y===null)return;let ge,me;A.current!==void 0&&(ge=At(Y,A.current.cell[0],A.current.cell[1]),me=A.current.cell),q==null||q({bounds:ge,stopPropagation:()=>I.stopPropagation(),preventDefault:()=>I.preventDefault(),cancel:()=>{},ctrlKey:I.ctrlKey,metaKey:I.metaKey,shiftKey:I.shiftKey,altKey:I.altKey,key:I.key,keyCode:I.keyCode,rawEvent:I,location:me})},[q,A,At]),Dr=c.useCallback(I=>{if(Ne.current=I,se!==void 0&&(se.current=I),ye!=null&&ye.eventTarget)He.current=ye.eventTarget;else if(I===null)He.current=window;else{const Y=I.getRootNode();Y===document&&(He.current=window),He.current=Y}},[se,ye==null?void 0:ye.eventTarget]),$r=c.useCallback(I=>{const Y=Ne.current;if(Y===null||Oe===!1||ae){I.preventDefault();return}let ge,me;const y=nt(Y,I.clientX,I.clientY);if(Oe!==!0&&y.kind!==Oe){I.preventDefault();return}const T=(at,Ue)=>{ge=at,me=Ue};let z,ne,te;const ft=(at,Ue,qe)=>{z=at,ne=Ue,te=qe};let Ce=!1;if(oe==null||oe({...y,setData:T,setDragImage:ft,preventDefault:()=>Ce=!0,defaultPrevented:()=>Ce}),!Ce&&ge!==void 0&&me!==void 0&&I.dataTransfer!==null)if(I.dataTransfer.setData(ge,me),I.dataTransfer.effectAllowed="copyLink",z!==void 0&&ne!==void 0&&te!==void 0)I.dataTransfer.setDragImage(z,ne,te);else{const[at,Ue]=y.location;if(Ue!==void 0){const qe=document.createElement("canvas"),ze=At(Y,at,Ue);pn(ze!==void 0);const ut=Math.ceil(window.devicePixelRatio??1);qe.width=ze.width*ut,qe.height=ze.height*ut;const _t=qe.getContext("2d");_t!==null&&(_t.scale(ut,ut),_t.textBaseline="middle",Ue===-1?(_t.font=_e.headerFontFull,_t.fillStyle=_e.bgHeader,_t.fillRect(0,0,qe.width,qe.height),Kc(_t,0,0,ze.width,ze.height,Be[at],!1,_e,!1,void 0,void 0,!1,0,gt,be,!1)):(_t.font=_e.baseFontFull,_t.fillStyle=_e.bgCell,_t.fillRect(0,0,qe.width,qe.height),Gc(_t,p([at,Ue]),0,Ue,!1,!1,0,0,ze.width,ze.height,!1,_e,_e.bgCell,Wt,gt,1,void 0,!1,0,void 0,void 0,void 0,Zn,Ye,()=>{}))),qe.style.left="-100%",qe.style.position="absolute",qe.style.width=`${ze.width}px`,qe.style.height=`${ze.height}px`,document.body.append(qe),I.dataTransfer.setDragImage(qe,ze.width/2,ze.height/2),window.setTimeout(()=>{qe.remove()},0)}}else I.preventDefault()},[Oe,ae,nt,oe,At,_e,Be,gt,be,p,Wt,Zn,Ye]);an("dragstart",$r,(J==null?void 0:J.current)??null,!1,!1);const tr=c.useRef(),qr=c.useCallback(I=>{const Y=Ne.current;if(ke!==void 0&&I.preventDefault(),Y===null||De===void 0)return;const ge=nt(Y,I.clientX,I.clientY),[me,y]=ge.location,T=me-(de?0:1),[z,ne]=tr.current??[];(z!==T||ne!==y)&&(tr.current=[T,y],De([T,y],I.dataTransfer))},[de,nt,De,ke]);an("dragover",qr,(J==null?void 0:J.current)??null,!1,!1);const Vr=c.useCallback(()=>{tr.current=void 0,Ee==null||Ee()},[Ee]);an("dragend",Vr,(J==null?void 0:J.current)??null,!1,!1);const gn=c.useCallback(I=>{const Y=Ne.current;if(Y===null||ke===void 0)return;I.preventDefault();const ge=nt(Y,I.clientX,I.clientY),[me,y]=ge.location,T=me-(de?0:1);ke([T,y],I.dataTransfer)},[de,nt,ke]);an("drop",gn,(J==null?void 0:J.current)??null,!1,!1);const Xn=c.useCallback(()=>{ot==null||ot()},[ot]);an("dragleave",Xn,(J==null?void 0:J.current)??null,!1,!1);const en=c.useRef(A);en.current=A;const $=c.useRef(null),Ct=c.useCallback(I=>{var Y;Ne.current===null||!Ne.current.contains(document.activeElement)||(I===null&&en.current.current!==void 0?(Y=se==null?void 0:se.current)==null||Y.focus({preventScroll:!0}):I!==null&&I.focus({preventScroll:!0}),$.current=I)},[se]);c.useImperativeHandle(t,()=>({focus:()=>{var Y;const I=$.current;I===null||!document.contains(I)?(Y=se==null?void 0:se.current)==null||Y.focus({preventScroll:!0}):I.focus({preventScroll:!0})},getBounds:(I,Y)=>{if(!(se===void 0||se.current===null))return At(se.current,I??0,Y??-1)},damage:Ur,getMouseArgsForPosition:(I,Y,ge)=>{if(!(se===void 0||se.current===null))return nt(se.current,I,Y,ge)}}),[se,Ur,At,nt]);const Sn=c.useRef(),Jr=Ap(()=>{var ne,te,ft;if(n<50||(ye==null?void 0:ye.disableAccessibilityTree)===!0)return null;let I=Ds(Be,dt,n,he,it);const Y=de?0:-1;!de&&((ne=I[0])==null?void 0:ne.sourceIndex)===0&&(I=I.slice(1));const[ge,me]=((te=A.current)==null?void 0:te.cell)??[],y=(ft=A.current)==null?void 0:ft.range,T=I.map(Ce=>Ce.sourceIndex),z=Br(s,Math.min(m,s+o));return ge!==void 0&&me!==void 0&&!(T.includes(ge)&&z.includes(me))&&Ct(null),c.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":m+1,"aria-multiselectable":"true","aria-colcount":Be.length+Y},c.createElement("thead",{role:"rowgroup"},c.createElement("tr",{role:"row","aria-rowindex":1},I.map(Ce=>c.createElement("th",{role:"columnheader","aria-selected":A.columns.hasIndex(Ce.sourceIndex),"aria-colindex":Ce.sourceIndex+1+Y,tabIndex:-1,onFocus:at=>{if(at.target!==$.current)return Me==null?void 0:Me([Ce.sourceIndex,-1])},key:Ce.sourceIndex},Ce.title)))),c.createElement("tbody",{role:"rowgroup"},z.map(Ce=>c.createElement("tr",{role:"row","aria-selected":A.rows.hasIndex(Ce),key:Ce,"aria-rowindex":Ce+2},I.map(at=>{const Ue=at.sourceIndex,qe=or(Ue,Ce),ze=ge===Ue&&me===Ce,ut=y!==void 0&&Ue>=y.x&&Ue<y.x+y.width&&Ce>=y.y&&Ce<y.y+y.height,_t=`glide-cell-${Ue}-${Ce}`,On=[Ue,Ce],jn=p(On,!0);return c.createElement("td",{key:qe,role:"gridcell","aria-colindex":Ue+1+Y,"aria-selected":ut,"aria-readonly":co(jn)||!ao(jn),id:_t,"data-testid":_t,onClick:()=>{const Mt=se==null?void 0:se.current;if(Mt!=null)return ee==null?void 0:ee({bounds:At(Mt,Ue,Ce),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:On})},onFocusCapture:Mt=>{var jt,wt;if(!(Mt.target===$.current||((jt=Sn.current)==null?void 0:jt[0])===Ue&&((wt=Sn.current)==null?void 0:wt[1])===Ce))return Sn.current=On,Me==null?void 0:Me(On)},ref:ze?Ct:void 0,tabIndex:-1},RC(jn,Ye))})))))},[n,Be,dt,he,it,m,s,o,A,Ct,p,se,ee,At,Me],200),Pn=L===0||!F?0:dt>L?1:En(-it/100,0,1),To=-s*32+xe,gr=H?En(-To/100,0,1):0,ri=c.useMemo(()=>{if(!Pn&&!gr)return null;const I={position:"absolute",top:0,left:$n,width:n-$n,height:r,opacity:Pn,pointerEvents:"none",transition:Ke?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},Y={position:"absolute",top:qt,left:0,width:n,height:r,opacity:gr,pointerEvents:"none",transition:ue?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return c.createElement(c.Fragment,null,Pn>0&&c.createElement("div",{id:"shadow-x",style:I}),gr>0&&c.createElement("div",{id:"shadow-y",style:Y}))},[Pn,gr,$n,n,Ke,qt,r,ue]),W=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:Tr,onKeyUp:kn,onFocus:M,onBlur:G,ref:Dr,style:lr},Jr),c.createElement("canvas",{ref:Ut,style:W}),ri)},IC=c.memo(c.forwardRef(MC));function Bo(e,t,n,r){return En(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}const EC=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(),[b,x]=c.useState(),[C,w]=c.useState(!1),[M,G]=c.useState(),{onHeaderMenuClick:B,onHeaderIndicatorClick:A,getCellContent:L,onColumnMoved:V,onColumnResize:k,onColumnResizeStart:F,onColumnResizeEnd:H,gridRef:j,maxColumnWidth:_,minColumnWidth:D,onRowMoved:fe,lockColumns:U,onColumnProposeMove:Z,onMouseDown:he,onMouseUp:de,onItemHovered:ee,onDragStart:q,canvasRef:Se}=e,se=(k??H??F)!==void 0,{columns:oe,selection:Ee}=e,J=Ee.columns,ae=c.useCallback(ie=>{const[be,Me]=ie.location;i!==void 0&&s!==be&&be>=U?(d(!0),l(be)):p!==void 0&&Me!==void 0?(w(!0),x(Math.max(0,Me))):r===void 0&&!u&&!C&&(ee==null||ee(ie))},[i,p,s,ee,U,r,u,C]),pe=V!==void 0,Ge=c.useCallback(ie=>{var be;if(ie.button===0){const[Me,De]=ie.location;if(ie.kind==="out-of-bounds"&&ie.isEdge&&se){const ke=(be=j==null?void 0:j.current)==null?void 0:be.getBounds(oe.length-1,-1);ke!==void 0&&(n(ke.x),o(oe.length-1))}else if(ie.kind==="header"&&Me>=U){const ke=Se==null?void 0:Se.current;if(ie.isEdge&&se&&ke){n(ie.bounds.x),o(Me);const Le=ke.getBoundingClientRect().width/ke.offsetWidth,Ke=ie.bounds.width/Le;F==null||F(oe[Me],Ke,Me,Ke+(oe[Me].growOffset??0))}else ie.kind==="header"&&pe&&(m(ie.bounds.x),a(Me))}else ie.kind==="cell"&&U>0&&Me===0&&De!==void 0&&fe!==void 0&&(G(ie.bounds.y),g(De))}he==null||he(ie)},[he,se,U,fe,j,oe,pe,F,Se]),Oe=c.useCallback((ie,be)=>{u||C||B==null||B(ie,be)},[u,C,B]),rt=c.useCallback((ie,be)=>{u||C||A==null||A(ie,be)},[u,C,A]),je=c.useRef(-1),Te=c.useCallback(()=>{je.current=-1,g(void 0),x(void 0),G(void 0),w(!1),a(void 0),l(void 0),m(void 0),d(!1),o(void 0),n(void 0)},[]),Fe=c.useCallback((ie,be)=>{if(ie.button===0){if(r!==void 0){if((J==null?void 0:J.hasIndex(r))===!0)for(const De of J){if(De===r)continue;const ke=oe[De],ot=Bo(ke,je.current,D,_);k==null||k(ke,ot,De,ot+(ke.growOffset??0))}const Me=Bo(oe[r],je.current,D,_);if(H==null||H(oe[r],Me,r,Me+(oe[r].growOffset??0)),J.hasIndex(r))for(const De of J){if(De===r)continue;const ke=oe[De],ot=Bo(ke,je.current,D,_);H==null||H(ke,ot,De,ot+(ke.growOffset??0))}}Te(),i!==void 0&&s!==void 0&&(Z==null?void 0:Z(i,s))!==!1&&(V==null||V(i,s)),p!==void 0&&b!==void 0&&(fe==null||fe(p,b))}de==null||de(ie,be)},[de,r,i,s,p,b,J,H,oe,D,_,k,V,fe,Te,Z]),_e=c.useMemo(()=>{if(!(i===void 0||s===void 0)&&i!==s&&(Z==null?void 0:Z(i,s))!==!1)return{src:i,dest:s}},[i,s,Z]),mt=c.useCallback(ie=>{const be=Se==null?void 0:Se.current;if(i!==void 0&&h!==void 0)Math.abs(ie.clientX-h)>20&&d(!0);else if(p!==void 0&&M!==void 0)Math.abs(ie.clientY-M)>20&&w(!0);else if(r!==void 0&&t!==void 0&&be){const De=be.getBoundingClientRect().width/be.offsetWidth,ke=(ie.clientX-t)/De,ot=oe[r],Le=Bo(ot,ke,D,_);if(k==null||k(ot,Le,r,Le+(ot.growOffset??0)),je.current=ke,(J==null?void 0:J.first())===r)for(const Ke of J){if(Ke===r)continue;const ue=oe[Ke],ye=Bo(ue,je.current,D,_);k==null||k(ue,ye,Ke,ye+(ue.growOffset??0))}}},[i,h,p,M,r,t,oe,D,_,k,J,Se]),xt=c.useCallback((ie,be)=>{if(p===void 0||b===void 0)return L(ie,be);let[Me,De]=ie;return De===b?De=p:(De>b&&(De-=1),De>=p&&(De+=1)),L([Me,De],be)},[p,b,L]),pt=c.useCallback(ie=>{q==null||q(ie),ie.defaultPrevented()||Te()},[Te,q]);return c.createElement(IC,{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:xt,isResizing:r!==void 0,onHeaderMenuClick:Oe,onHeaderIndicatorClick:rt,isDragging:u,onItemHovered:ae,onDragStart:pt,onMouseDown:Ge,allowResize:se,onMouseUp:Fe,dragAndDropState:_e,onMouseMoveRaw:mt,ref:j})};function TC(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 DC=(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])},$C=()=>e=>e.isSafari?"scroll":"auto",AC=Sr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[$C()]}}),FC=33554400,_C=5e6;function PC(e){const[t,n]=c.useState(!1),r=typeof window>"u"?null:window,o=c.useRef(0);return an("touchstart",c.useCallback(()=>{window.clearTimeout(o.current),n(!0)},[]),r,!0,!1),an("touchend",c.useCallback(i=>{i.touches.length===0&&(o.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}const OC=e=>{var Ee,J;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:b}=e,x=[],C=(m==null?void 0:m.sticky)??!1,w=(m==null?void 0:m.fill)??!1,M=c.useRef(0),G=c.useRef(0),B=c.useRef(null),A=typeof window>"u"?1:window.devicePixelRatio,L=c.useRef(A);c.useEffect(()=>{if(L.current!==A){M.current=0,G.current=0,L.current=A;const ae=B.current;ae!==null&&fe.current(ae.scrollLeft,ae.scrollTop)}},[A]);const V=c.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),k=c.useRef(null),F=PC(200),[H,j]=c.useState(!0),_=c.useRef(0);c.useLayoutEffect(()=>{if(!H||F||V.current.lockDirection===void 0)return;const ae=B.current;if(ae===null)return;const[pe,Ge]=V.current.lockDirection;pe!==void 0?ae.scrollLeft=pe:Ge!==void 0&&(ae.scrollTop=Ge),V.current.lockDirection=void 0},[F,H]);const D=c.useCallback((ae,pe)=>{var Me;const Ge=B.current;if(Ge===null)return;pe=pe??Ge.scrollTop,ae=ae??Ge.scrollLeft;const Oe=V.current.scrollTop,rt=V.current.scrollLeft,je=ae-rt,Te=pe-Oe;F&&je!==0&&Te!==0&&(Math.abs(je)>3||Math.abs(Te)>3)&&l&&V.current.lockDirection===void 0&&(V.current.lockDirection=Math.abs(je)<Math.abs(Te)?[rt,void 0]:[void 0,Oe]);const Fe=V.current.lockDirection;ae=(Fe==null?void 0:Fe[0])??ae,pe=(Fe==null?void 0:Fe[1])??pe,V.current.scrollLeft=ae,V.current.scrollTop=pe;const _e=Ge.clientWidth,mt=Ge.clientHeight,xt=pe,pt=G.current-xt,ie=Ge.scrollHeight-mt;G.current=xt;let be;if(ie>0&&r>Ge.scrollHeight+5)if(Math.abs(pt)>2e3||xt===0||xt===ie){const De=Math.max(0,Math.min(1,xt/ie)),ke=r-mt;be=De*ke,M.current=be}else M.current-=pt,be=M.current;else be=xt,M.current=be;be=Math.max(0,Math.min(be,r-mt)),M.current=be,Fe!==void 0&&(window.clearTimeout(_.current),j(!1),_.current=window.setTimeout(()=>j(!0),200)),i({x:ae,y:be,width:_e-d,height:mt-u,paddingRight:((Me=k.current)==null?void 0:Me.clientWidth)??0})},[u,d,r,i,l,F]);DC(p&&ji.value,D,B);const fe=c.useRef(D);fe.current=D;const U=c.useRef(),Z=c.useRef(!1);c.useLayoutEffect(()=>{Z.current?D():Z.current=!0},[D,u,d]);const he=c.useCallback(ae=>{B.current=ae,g!==void 0&&(g.current=ae)},[g]);let de=0,ee=0;const q=Math.min(r,FC);for(x.push(c.createElement("div",{key:de++,style:{width:o,height:0}}));ee<q;){const ae=Math.min(_C,q-ee);x.push(c.createElement("div",{key:de++,style:{width:0,height:ae}})),ee+=ae}const{ref:Se,width:se,height:oe}=TC(b);return typeof window<"u"&&(((Ee=U.current)==null?void 0:Ee.height)!==oe||((J=U.current)==null?void 0:J.width)!==se)&&(window.setTimeout(()=>fe.current(),0),U.current={width:se,height:oe}),(se??0)===0||(oe??0)===0?c.createElement("div",{ref:Se}):c.createElement("div",{ref:Se},c.createElement(AC,{isSafari:ji.value},c.createElement("div",{className:"dvn-underlay"},t),c.createElement("div",{ref:he,style:U.current,draggable:a,onDragStart:ae=>{a||(ae.stopPropagation(),ae.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:k,style:{height:oe,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))))))},jC=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:b,rightElementProps:x,overscrollX:C,overscrollY:w,initialSize:M,smoothScrollX:G=!1,smoothScrollY:B=!1,isDraggable:A}=e,{paddingRight:L,paddingBottom:V}=l??{},[k,F]=d,H=c.useRef(),j=c.useRef(),_=c.useRef(),D=c.useRef(),fe=u+Math.max(0,C??0);let U=a?o+i:o;if(typeof r=="number")U+=n*r;else for(let ee=0;ee<n;ee++)U+=r(ee);w!==void 0&&(U+=w);const Z=c.useRef(),he=c.useCallback(()=>{var rt,je;if(Z.current===void 0)return;const ee={...Z.current};let q=0,Se=ee.x<0?-ee.x:0,se=0,oe=0;ee.x=ee.x<0?0:ee.x;let Ee=0;for(let Te=0;Te<s;Te++)Ee+=t[Te].width;for(const Te of t){const Fe=q-Ee;if(ee.x>=Fe+Te.width)q+=Te.width,oe++,se++;else if(ee.x>Fe)q+=Te.width,G?Se+=Fe-ee.x:oe++,se++;else if(ee.x+ee.width>Fe)q+=Te.width,se++;else break}let J=0,ae=0,pe=0;if(typeof r=="number")B?(ae=Math.floor(ee.y/r),J=ae*r-ee.y):ae=Math.ceil(ee.y/r),pe=Math.ceil(ee.height/r)+ae,J<0&&pe++;else{let Te=0;for(let Fe=0;Fe<n;Fe++){const _e=r(Fe),mt=Te+(B?0:_e/2);if(ee.y>=Te+_e)Te+=_e,ae++,pe++;else if(ee.y>mt)Te+=_e,B?J+=mt-ee.y:ae++,pe++;else if(ee.y+ee.height>_e/2+Te)Te+=_e,pe++;else break}}ae=Math.max(0,Math.min(ae,n-1)),pe=Math.max(ae,Math.min(pe,n));const Ge={x:oe,y:ae,width:se-oe,height:pe-ae},Oe=H.current;(Oe===void 0||Oe.y!==Ge.y||Oe.x!==Ge.x||Oe.height!==Ge.height||Oe.width!==Ge.width||j.current!==Se||_.current!==J||ee.width!==((rt=D.current)==null?void 0:rt[0])||ee.height!==((je=D.current)==null?void 0:je[1]))&&(m==null||m({x:oe,y:ae,width:se-oe,height:pe-ae},ee.width,ee.height,ee.paddingRight??0,Se,J),H.current=Ge,j.current=Se,_.current=J,D.current=[ee.width,ee.height])},[t,r,n,m,s,G,B]),de=c.useCallback(ee=>{Z.current=ee,he()},[he]);return c.useEffect(()=>{he()},[he]),c.createElement(OC,{scrollRef:p,className:h,kineticScrollPerfHack:l==null?void 0:l.kineticScrollPerfHack,preventDiagonalScrolling:g,draggable:A===!0||typeof A=="string",scrollWidth:fe+(L??0),scrollHeight:U+(V??0),clientHeight:F,rightElement:b,paddingBottom:V,paddingRight:L,rightElementProps:x,update:de,initialSize:M},c.createElement(EC,{eventTargetRef:p,width:k,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}))},NC=Sr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),HC=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"})),BC=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"})),LC=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"})),zC=10,WC=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,b]=c.useState(""),x=a??g,C=c.useCallback(q=>{b(q),l==null||l(q)},[l]),[w,M]=c.useState(),G=c.useRef(w);G.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 B=c.useRef();B.current===void 0&&(B.current=new AbortController);const A=c.useRef(),[L,V]=c.useState([]),k=s??L,F=c.useCallback(()=>{A.current!==void 0&&(window.cancelAnimationFrame(A.current),A.current=void 0),B.current!==void 0&&B.current.abort(),B.current=new AbortController},[]),H=c.useRef(n);H.current=n;const j=c.useCallback(q=>{const Se=new RegExp(q.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let se=H.current,oe=Math.min(10,r),Ee=0;M(void 0),V([]);const J=[],ae=async()=>{var xt;if(u===void 0)return;const pe=performance.now(),Ge=r-Ee;let Oe=u({x:0,y:se,width:o.length,height:Math.min(oe,Ge,r-se)},B.current.signal);typeof Oe=="function"&&(Oe=await Oe());let rt=!1;for(const[pt,ie]of Oe.entries())for(const[be,Me]of ie.entries()){let De;switch(Me.kind){case ce.Text:case ce.Number:De=Me.displayData;break;case ce.Uri:case ce.Markdown:De=Me.data;break;case ce.Boolean:De=typeof Me.data=="boolean"?Me.data.toString():void 0;break;case ce.Image:case ce.Bubble:De=Me.data.join("🐳");break;case ce.Custom:De=Me.copyData;break}De!==void 0&&Se.test(De)&&(J.push([be,pt+se]),rt=!0)}const je=performance.now();rt&&V([...J]),Ee+=Oe.length,pn(Ee<=r);const Te=((xt=G.current)==null?void 0:xt.selectedIndex)??-1;M({results:J.length,rowsSearched:Ee,selectedIndex:Te}),d==null||d(J,Te),se+oe>=r?se=0:se+=oe;const Fe=je-pe,_e=Math.max(Fe,1),mt=zC/_e;oe=Math.ceil(oe*mt),Ee<r&&J.length<1e3&&(A.current=window.requestAnimationFrame(ae))};F(),A.current=window.requestAnimationFrame(ae)},[F,o.length,u,d,r]),_=c.useCallback(()=>{var q;m==null||m(),M(void 0),V([]),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),V([]),F()):j(q.target.value))},[j,F,C,s]);c.useEffect(()=>{i.current!==null&&(C(""),M(void 0),L.length>0&&(V([]),d==null||d([],-1)),h?i.current.focus({preventScroll:!0}):F())},[h,i]);const fe=c.useCallback(q=>{var se;if((se=q==null?void 0:q.stopPropagation)==null||se.call(q),w===void 0||w.results===0)return;const Se=(w.selectedIndex+1)%w.results;M({...w,selectedIndex:Se}),d==null||d(k,Se)},[w,d,k]),U=c.useCallback(q=>{var se;if((se=q==null?void 0:q.stopPropagation)==null||se.call(q),w===void 0||w.results===0)return;let Se=(w.selectedIndex-1)%w.results;Se<0&&(Se+=w.results),M({...w,selectedIndex:Se}),d==null||d(k,Se)},[d,k,w]),Z=c.useCallback(q=>{(q.ctrlKey||q.metaKey)&&q.nativeEvent.code==="KeyF"||q.key==="Escape"?(_(),q.stopPropagation(),q.preventDefault()):q.key==="Enter"&&(q.shiftKey?U():fe())},[_,fe,U]);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 ee=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 Se=Ee=>{Ee.stopPropagation()},oe={width:`${r>0?Math.floor(((w==null?void 0:w.rowsSearched)??0)/r*100):0}%`};return c.createElement(NC,{className:"gdg-search-bar"+(h?"":" out"),onMouseDown:Se,onMouseMove:Se,onMouseUp:Se,onClick:Se},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:Z}),c.createElement("button",{type:"button","aria-label":"Previous Result","aria-hidden":!h,tabIndex:h?void 0:-1,onClick:U,disabled:((w==null?void 0:w.results)??0)===0},HC),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},BC),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:_},LC)),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:oe})):c.createElement("div",{className:"gdg-search-status"},c.createElement("label",{htmlFor:p},"Type to search")))},[h,he,w,r,p,i,D,x,Z,U,fe,m,_]);return c.createElement(c.Fragment,null,c.createElement(jC,{prelightCells:k,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}),ee)};class GC 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 UC=()=>e=>Math.max(16,e.targetHeight-10),XC=Sr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[UC(),"px"]}}),KC=e=>{const{bounds:t,group:n,onClose:r,canvasBounds:o,onFinish:i}=e,[a,s]=zt.useState(n);return zt.createElement(GC,{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(XC,{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 YC(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=su(e,t);return r&&(n.didMatch=!0),r}function su(e,t){if(e.length===0)return!1;if(e.includes("|")){const l=e.split("|");for(const u of l)if(su(u,t))return!0;return!1}let n=!1,r=!1,o=!1,i=!1;const a=e.split("+"),s=a.pop();if(!YC(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 qC(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",b=(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:b?e.columns:lt.empty(),rows:x?e.rows:lt.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:lt.empty(),rows:d};else{const g=m&&n==="mixed"||n==="additive",b=m&&r==="mixed"||r==="additive";p={current:g?e.current:void 0,columns:b?e.columns:lt.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:lt.empty(),columns:d};else{const g=m&&n==="mixed"||n==="additive",b=m&&o==="mixed"||o==="additive";p={current:g?e.current:void 0,rows:b?e.rows:lt.empty(),columns:d}}t(p,!1)},[r,e,n,o,t]);return[s,l,u]}function VC(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:ce.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:ce.Loading,allowOverlay:!1},...m]):h.map(m=>[{kind:ce.Loading,allowOverlay:!1},...m])}return a(d,r.signal)},[r.signal,a,n]);return[e!==void 0?s:void 0,a]}function JC(e){if(e.copyData!==void 0)return{formatted:e.copyData,rawValue:e.copyData,format:"string",doNotEscape:!0};switch(e.kind){case ce.Boolean:return{formatted:e.data===!0?"TRUE":e.data===!1?"FALSE":e.data===Js?"INDETERMINATE":"",rawValue:e.data,format:"boolean"};case ce.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:"string"};case ce.Image:case ce.Bubble:return{formatted:e.data,rawValue:e.data,format:"string-array"};case ce.Drilldown:return{formatted:e.data.map(t=>t.text),rawValue:e.data.map(t=>t.text),format:"string-array"};case ce.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:"string"};case ce.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:"url"};case ce.Markdown:case ce.RowID:return{formatted:e.data,rawValue:e.data,format:"string"};case ce.Number:return{formatted:e.displayData,rawValue:e.data,format:"number"};case ce.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case ce.Protected:return{formatted:"************",rawValue:"",format:"string"};default:qo()}}function QC(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"}:JC(a))})}function Ol(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,'""')}"`),e}function ZC(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=>Ol(a,!0)).join(",")):o.push(i.doNotEscape===!0?i.formatted:Ol(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 jl(e){return'"'+e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")+'"'}function ek(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function tk(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=${jl(o.rawValue[s])}>`+xs(a)+"</li>").join("")}</ol></td>`):t.push(`<td gdg-raw-value=${jl(((n=o.rawValue)==null?void 0:n.toString())??"")} ${i}>${xs(o.formatted)}</td>`)}t.push("</tr>")}return t.push("</tbody></table>"),t.join("")}function nk(e,t){const n=QC(e,t),r=ZC(n),o=tk(n);return{textPlain:r,textHtml:o}}function Nl(e){var a;const t=document.createElement("html");t.innerHTML=e.replace(/&nbsp;/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 b of m)b.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 b=l.querySelectorAll("li");i==null||i.push({rawValue:[...b].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...b].map(x=>x.textContent??""),format:"string-array"})}else if(p!==null)i==null||i.push({rawValue:ek(p),formatted:l.textContent??"",format:g});else{let b=l.textContent??"";h&&(b=b.replace(/\n(?!\n)/g,"")),i==null||i.push({rawValue:b??"",formatted:b??"",format:g})}}}return i!==void 0&&o.push(i),o}function rk(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 Hl(e){return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).replace(/""/g,'"')),e}function ok(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,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/data-grid-overlay-editor-PtH7A6E4.js","assets/index-BFH07Ynk.js","assets/index-KCv8AeiY.css","assets/number-overlay-editor-BbQhagHP.js"])))=>i.map(i=>d[i]);
2
+ var ld=Object.defineProperty;var cd=(e,t,n)=>t in e?ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xe=(e,t,n)=>cd(e,typeof t!="symbol"?t+"":t,n);import{ae as bi,af as zr,r as c,ad as zt,ag as ec,ah as ud,ai as tc,aj as dd,ak as Zo,ac as mo,j as v,al as fd,a1 as Di,aa as hd,am as gd,an as nc,ao as md,ap as rc,aq as pd,ar as bd,as as Ea,at as Mi,a7 as yd,X as vd,a8 as wd,Y as xd,au as Cd,av as oc,aw as ic,ax as kd,ay as Sd,az as Rd,aA as Ta,aB as Md,aC as Ms,a2 as Id,R as Ed,M as Td,H as Dd,a4 as $d,a6 as Ad,aD as Fd,E as sc,aE as _d,aF as Da,aG as Pd,aH as Od,aI as jd,w as Nd,aJ as Hd,C as Bd,aK as Ld,aL as zd,aM as $a,aN as Wd,aO as Gd,aP as Aa,aQ as Ud,aR as Xd,aS as Kd,aT as Yd,T as yi,aU as Fa,J as qd,I as Vd,aV as Jd,f as Qd,K as _a,P as Zd,aW as ef,aX as tf,aY as nf,aZ as Pa,a_ as rf,a$ as of,b0 as sf,b1 as af,b2 as lf,b3 as cf,b4 as uf,b5 as df,b6 as ff,N as hf,Q as gf}from"./index-BFH07Ynk.js";function mf(e,t){const n=`Delete “${e.name}” and its ${t} row${t===1?"":"s"}?`;return e.synced?`${n}
3
+
4
+ It's synced with Evalution Cloud, so it will also be deleted from the cloud and from every project member's machine.`:n}var pf=Object.prototype,bf=pf.hasOwnProperty;function yf(e,t){return e!=null&&bf.call(e,t)}var vf=yf,wf=Array.isArray,Jn=wf,xf=typeof bi=="object"&&bi&&bi.Object===Object&&bi,ac=xf,Cf=ac,kf=typeof self=="object"&&self&&self.Object===Object&&self,Sf=Cf||kf||Function("return this")(),Qn=Sf,Rf=Qn,Mf=Rf.Symbol,ei=Mf,Oa=ei,lc=Object.prototype,If=lc.hasOwnProperty,Ef=lc.toString,Oo=Oa?Oa.toStringTag:void 0;function Tf(e){var t=If.call(e,Oo),n=e[Oo];try{e[Oo]=void 0;var r=!0}catch{}var o=Ef.call(e);return r&&(t?e[Oo]=n:delete e[Oo]),o}var Df=Tf,$f=Object.prototype,Af=$f.toString;function Ff(e){return Af.call(e)}var _f=Ff,ja=ei,Pf=Df,Of=_f,jf="[object Null]",Nf="[object Undefined]",Na=ja?ja.toStringTag:void 0;function Hf(e){return e==null?e===void 0?Nf:jf:Na&&Na in Object(e)?Pf(e):Of(e)}var ti=Hf;function Bf(e){return e!=null&&typeof e=="object"}var ni=Bf,Lf=ti,zf=ni,Wf="[object Symbol]";function Gf(e){return typeof e=="symbol"||zf(e)&&Lf(e)==Wf}var Li=Gf,Uf=Jn,Xf=Li,Kf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yf=/^\w*$/;function qf(e,t){if(Uf(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Xf(e)?!0:Yf.test(e)||!Kf.test(e)||t!=null&&e in Object(t)}var Ws=qf;function Vf(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var yo=Vf,Jf=ti,Qf=yo,Zf="[object AsyncFunction]",eh="[object Function]",th="[object GeneratorFunction]",nh="[object Proxy]";function rh(e){if(!Qf(e))return!1;var t=Jf(e);return t==eh||t==th||t==Zf||t==nh}var cc=rh,oh=Qn,ih=oh["__core-js_shared__"],sh=ih,cs=sh,Ha=function(){var e=/[^.]+$/.exec(cs&&cs.keys&&cs.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ah(e){return!!Ha&&Ha in e}var lh=ah,ch=Function.prototype,uh=ch.toString;function dh(e){if(e!=null){try{return uh.call(e)}catch{}try{return e+""}catch{}}return""}var uc=dh,fh=cc,hh=lh,gh=yo,mh=uc,ph=/[\\^$.*+?()[\]{}|]/g,bh=/^\[object .+?Constructor\]$/,yh=Function.prototype,vh=Object.prototype,wh=yh.toString,xh=vh.hasOwnProperty,Ch=RegExp("^"+wh.call(xh).replace(ph,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function kh(e){if(!gh(e)||hh(e))return!1;var t=fh(e)?Ch:bh;return t.test(mh(e))}var Sh=kh;function Rh(e,t){return e==null?void 0:e[t]}var Mh=Rh,Ih=Sh,Eh=Mh;function Th(e,t){var n=Eh(e,t);return Ih(n)?n:void 0}var Wr=Th,Dh=Wr,$h=Dh(Object,"create"),zi=$h,Ba=zi;function Ah(){this.__data__=Ba?Ba(null):{},this.size=0}var Fh=Ah;function _h(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ph=_h,Oh=zi,jh="__lodash_hash_undefined__",Nh=Object.prototype,Hh=Nh.hasOwnProperty;function Bh(e){var t=this.__data__;if(Oh){var n=t[e];return n===jh?void 0:n}return Hh.call(t,e)?t[e]:void 0}var Lh=Bh,zh=zi,Wh=Object.prototype,Gh=Wh.hasOwnProperty;function Uh(e){var t=this.__data__;return zh?t[e]!==void 0:Gh.call(t,e)}var Xh=Uh,Kh=zi,Yh="__lodash_hash_undefined__";function qh(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Kh&&t===void 0?Yh:t,this}var Vh=qh,Jh=Fh,Qh=Ph,Zh=Lh,eg=Xh,tg=Vh;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=Jh;vo.prototype.delete=Qh;vo.prototype.get=Zh;vo.prototype.has=eg;vo.prototype.set=tg;var ng=vo;function rg(){this.__data__=[],this.size=0}var og=rg;function ig(e,t){return e===t||e!==e&&t!==t}var Gs=ig,sg=Gs;function ag(e,t){for(var n=e.length;n--;)if(sg(e[n][0],t))return n;return-1}var Wi=ag,lg=Wi,cg=Array.prototype,ug=cg.splice;function dg(e){var t=this.__data__,n=lg(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():ug.call(t,n,1),--this.size,!0}var fg=dg,hg=Wi;function gg(e){var t=this.__data__,n=hg(t,e);return n<0?void 0:t[n][1]}var mg=gg,pg=Wi;function bg(e){return pg(this.__data__,e)>-1}var yg=bg,vg=Wi;function wg(e,t){var n=this.__data__,r=vg(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var xg=wg,Cg=og,kg=fg,Sg=mg,Rg=yg,Mg=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=Cg;wo.prototype.delete=kg;wo.prototype.get=Sg;wo.prototype.has=Rg;wo.prototype.set=Mg;var Gi=wo,Ig=Wr,Eg=Qn,Tg=Ig(Eg,"Map"),Us=Tg,La=ng,Dg=Gi,$g=Us;function Ag(){this.size=0,this.__data__={hash:new La,map:new($g||Dg),string:new La}}var Fg=Ag;function _g(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Pg=_g,Og=Pg;function jg(e,t){var n=e.__data__;return Og(t)?n[typeof t=="string"?"string":"hash"]:n.map}var Ui=jg,Ng=Ui;function Hg(e){var t=Ng(this,e).delete(e);return this.size-=t?1:0,t}var Bg=Hg,Lg=Ui;function zg(e){return Lg(this,e).get(e)}var Wg=zg,Gg=Ui;function Ug(e){return Gg(this,e).has(e)}var Xg=Ug,Kg=Ui;function Yg(e,t){var n=Kg(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var qg=Yg,Vg=Fg,Jg=Bg,Qg=Wg,Zg=Xg,em=qg;function xo(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])}}xo.prototype.clear=Vg;xo.prototype.delete=Jg;xo.prototype.get=Qg;xo.prototype.has=Zg;xo.prototype.set=em;var Xs=xo,dc=Xs,tm="Expected a function";function Ks(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(tm);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||dc),n}Ks.Cache=dc;var nm=Ks,rm=nm,om=500;function im(e){var t=rm(e,function(r){return n.size===om&&n.clear(),r}),n=t.cache;return t}var sm=im,am=sm,lm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cm=/\\(\\)?/g,um=am(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(lm,function(n,r,o,i){t.push(o?i.replace(cm,"$1"):r||n)}),t}),dm=um;function fm(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 hm=fm,za=ei,gm=hm,mm=Jn,pm=Li,Wa=za?za.prototype:void 0,Ga=Wa?Wa.toString:void 0;function fc(e){if(typeof e=="string")return e;if(mm(e))return gm(e,fc)+"";if(pm(e))return Ga?Ga.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var bm=fc,ym=bm;function vm(e){return e==null?"":ym(e)}var wm=vm,xm=Jn,Cm=Ws,km=dm,Sm=wm;function Rm(e,t){return xm(e)?e:Cm(e,t)?[e]:km(Sm(e))}var hc=Rm,Mm=ti,Im=ni,Em="[object Arguments]";function Tm(e){return Im(e)&&Mm(e)==Em}var Dm=Tm,Ua=Dm,$m=ni,gc=Object.prototype,Am=gc.hasOwnProperty,Fm=gc.propertyIsEnumerable,_m=Ua(function(){return arguments}())?Ua:function(e){return $m(e)&&Am.call(e,"callee")&&!Fm.call(e,"callee")},Ys=_m,Pm=9007199254740991,Om=/^(?:0|[1-9]\d*)$/;function jm(e,t){var n=typeof e;return t=t??Pm,!!t&&(n=="number"||n!="symbol"&&Om.test(e))&&e>-1&&e%1==0&&e<t}var qs=jm,Nm=9007199254740991;function Hm(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Nm}var Vs=Hm,Bm=Li;function Lm(e){if(typeof e=="string"||Bm(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var Xi=Lm,zm=hc,Wm=Ys,Gm=Jn,Um=qs,Xm=Vs,Km=Xi;function Ym(e,t,n){t=zm(t,e);for(var r=-1,o=t.length,i=!1;++r<o;){var a=Km(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&&Xm(o)&&Um(a,o)&&(Gm(e)||Wm(e)))}var mc=Ym,qm=vf,Vm=mc;function Jm(e,t){return e!=null&&Vm(e,t,qm)}var Qm=Jm;const Zm=zr(Qm);function pc(e="This should not happen"){throw new Error(e)}function pn(e,t="Assertion failed"){if(!e)return pc(t)}function qo(e,t){return pc(t??"Hell froze over")}function ep(e,t){try{return e()}catch{return t}}const Xa=Object.prototype.hasOwnProperty;function po(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--&&po(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(Xa.call(e,n)&&++r&&!Xa.call(t,n)||!(n in t)||!po(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}const $i=null,Js=void 0;var ce;(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"})(ce||(ce={}));var Ka;(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"})(Ka||(Ka={}));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 Ya(e){return typeof e=="object"?e:await e()}function so(e){return!(e.kind===ce.Loading||e.kind===ce.Bubble||e.kind===ce.RowID||e.kind===ce.Protected||e.kind===ce.Drilldown)}function co(e){return e.kind===Tn.Marker||e.kind===Tn.NewRow}function ao(e){if(!so(e)||e.kind===ce.Image)return!1;switch(e.kind){case ce.Text:case ce.Number:case ce.Markdown:case ce.Uri:case ce.Custom:case ce.Boolean:return e.readonly!==!0;default:qo(e,"A cell was passed with an invalid kind")}}function tp(e){return Zm(e,"editor")}function Qs(e){return!(e.readonly??!1)}var Tn;(function(e){e.NewRow="new-row",e.Marker="marker"})(Tn||(Tn={}));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 qa;const un=class un{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 un(n)}add(t){const n=typeof t=="number"?[t,t+1]:t,r=us([...this.items,n]);return new un(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 un(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(un,"create",t=>new un(us(t))),Xe(un,"empty",()=>qa??(qa=new un([]))),Xe(un,"fromSingleSelection",t=>un.empty().add(t)),Xe(un,"fromArray",t=>{if(t.length===0)return un.empty();const n=t.map(o=>[o,o+1]),r=us(n);return new un(r)});let lt=un;function np(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var rp=/^((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=np(function(e){return rp.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),op=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(" ")},Va=op,ip=e=>e.toUpperCase()===e,sp=e=>t=>e.indexOf(t)===-1,bc=(e,t)=>{const n={};return Object.keys(e).filter(sp(t)).forEach(r=>{n[r]=e[r]}),n};function ap(e,t,n){const r=bc(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 lp=(e,t)=>{};function cp(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&&!ip(s[0])):n.propsAsIs,d=ap(u,i,["as","class"]);d.ref=a,d.className=n.atomic?Va(n.class,d.className||l):Va(d.className||l,n.class);const{vars:h}=n;if(h){const m={};for(const b in h){const x=h[b],C=x[0],w=x[1]||"",M=typeof C=="function"?C(i):C;lp(M,n.name),m[`--${b}`]=`${M}${w}`}const p=d.style||{},g=Object.keys(p);g.length>0&&g.forEach(b=>{m[b]=p[b]}),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=bc(i,["innerRef"]);return r(a,i.innerRef)};return o.displayName=n.name,o.__wyw_meta={className:n.class||t,extends:e},o}}var Sr=cp,up=Qn,dp=function(){return up.Date.now()},fp=dp,hp=/\s/;function gp(e){for(var t=e.length;t--&&hp.test(e.charAt(t)););return t}var mp=gp,pp=mp,bp=/^\s+/;function yp(e){return e&&e.slice(0,pp(e)+1).replace(bp,"")}var vp=yp,wp=vp,Ja=yo,xp=Li,Qa=NaN,Cp=/^[-+]0x[0-9a-f]+$/i,kp=/^0b[01]+$/i,Sp=/^0o[0-7]+$/i,Rp=parseInt;function Mp(e){if(typeof e=="number")return e;if(xp(e))return Qa;if(Ja(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ja(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=wp(e);var n=kp.test(e);return n||Sp.test(e)?Rp(e.slice(2),n?2:8):Cp.test(e)?Qa:+e}var Zs=Mp,Ip=yo,fs=fp,Za=Zs,Ep="Expected a function",Tp=Math.max,Dp=Math.min;function $p(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(Ep);t=Za(t)||0,Ip(n)&&(d=!!n.leading,h="maxWait"in n,i=h?Tp(Za(n.maxWait)||0,t):i,m="trailing"in n?!!n.trailing:m);function p(A){var L=r,V=o;return r=o=void 0,u=A,a=e.apply(V,L),a}function g(A){return u=A,s=setTimeout(C,t),d?p(A):a}function b(A){var L=A-l,V=A-u,k=t-L;return h?Dp(k,i-V):k}function x(A){var L=A-l,V=A-u;return l===void 0||L>=t||L<0||h&&V>=i}function C(){var A=fs();if(x(A))return w(A);s=setTimeout(C,b(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 G(){return s===void 0?a:w(fs())}function B(){var A=fs(),L=x(A);if(r=arguments,o=this,l=A,L){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 B.cancel=M,B.flush=G,B}var Ap=$p;const yc=zr(Ap);function an(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 xr(e,t){return e===void 0?void 0:t}const vc=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),wc=(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}},xc=(e,t,n)=>Math.min(e,t-n*2),Cc=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2;function Fp(e,t,n){const[r,o]=c.useState(e),i=c.useRef(!0);c.useEffect(()=>()=>{i.current=!1},[]);const a=c.useRef(yc(s=>{i.current&&o(s)},n));return c.useLayoutEffect(()=>{i.current&&a.current(()=>e())},t),r}const _p="֑-߿יִ-﷽ﹰ-ﻼ",Pp="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Op=new RegExp("^[^"+Pp+"]*["+_p+"]");function ea(e){return Op.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 jr=Symbol();function jp(e){const t=c.useRef([jr,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!==jr&&(s=typeof s=="function"?s(l):s,s===l)||(l!==jr&&o({}),r(u=>typeof s=="function"?s(l===jr?u:l):s),t.current[0]=jr)},[]),a=c.useCallback(()=>{t.current[0]=jr,o({})},[]);return[t.current[0]===jr?n:t.current[0],i,a]}function Np(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 Hp(e){const t=c.useRef(e);return po(e,t.current)||(t.current=e),t.current}const Bp=Sr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),Lp=Sr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),zp=Sr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let el=0;const Wp=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-"+(el=(el+1)%1e7));c.useEffect(()=>{const g=d.current;if(g===null||g.disabled)return;const b=h.toString().length;g.focus(),g.setSelectionRange(o?0:b,b)},[]),c.useLayoutEffect(()=>{var g;if(a!==void 0){const b=typeof a=="number"?[a,null]:a;(g=d.current)==null||g.setSelectionRange(b[0],b[1])}},[a]);const p=c.useCallback(g=>{g.key==="Enter"&&g.shiftKey&&i===!0||r==null||r(g)},[i,r]);return c.createElement(zp,{className:"gdg-growing-entry"},c.createElement(Lp,{className:u},h+`
5
+ `),c.createElement(Bp,{...s,className:(u??"")+" gdg-input",id:m,ref:d,onKeyDown:p,value:h,placeholder:t,dir:"auto"}))},hs={};let vr=null;function Gp(){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];vr=vr||Gp(),vr.style.color="#000",vr.style.color=t;const n=getComputedStyle(vr).color;vr.style.color="#fff",vr.style.color=t;const r=getComputedStyle(vr).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 Lr(e,t){const[n,r,o]=Es(e);return`rgba(${n}, ${r}, ${o}, ${t})`}const tl=new Map;function nl(e,t){const n=`${e}-${t}`,r=tl.get(n);if(r!==void 0)return r;const o=bn(e,t);return tl.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 lo=new Map,uo=new Map,Ts=new Map;function Up(){lo.clear(),Ts.clear(),uo.clear()}function Xp(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,b=d*g*r/m,x=p+b;n.set(h,x)}}function Kp(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 Uo(e,t,n,r){var o,i;let a=uo.get(n);if(r&&a!==void 0&&a.count>2e4){let u=Ts.get(n);if(u===void 0&&(u=Kp(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 Xp(t,d.width,u,Math.max(.05,1-a.count/2e5),a.size),uo.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)uo.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;uo.set(n,{count:a.count+t.length,size:h})}return s.width}function Yp(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=Uo(e,t.slice(0,Math.max(0,l)),r,a);if(u!==n)if(u<n){for(;u<n;)l++,u=Uo(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=Uo(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 qp(e,t,n,r,o,i){let a=`${t}_${n}_${r}px`,s=lo.get(a);if(s!==void 0)return s;if(r<=0)return[];let l=[],u=t.split(`
6
+ `),d=uo.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=Uo(e,p.slice(0,Math.max(0,h)),n,m),b=Math.min(p.length,h);if(g<=r)l.push(p);else{for(;g>r;){let x=Yp(e,p,r,n,g,b,m),C=p.slice(0,Math.max(0,x));p=p.slice(C.length),l.push(C),g=Uo(e,p.slice(0,Math.max(0,h)),n,m),b=Math.min(p.length,h)}g>0&&l.push(p)}}return l=l.map((p,g)=>g===0?p.trimEnd():p.trim()),lo.set(a,l),lo.size>500&&lo.delete(lo.keys().next().value),l}function Vp(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 Jp(e,t){const[n,r]=t;if(e.columns.hasIndex(n)||e.rows.hasIndex(r))return!0;if(e.current!==void 0){if(Xo(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 Vo(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 kc(e,t){const[n,r]=e;return n>=t.x&&n<t.x+t.width&&r>=t.y&&r<t.y+t.height}function Xo(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 Sc(e){return[e.x+e.width-1,e.y+e.height-1]}function rl(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 Zp(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)&&rl(e,t,i)&&o++;for(const a of n.current.rangeStack)rl(e,t,a)&&o++;return o}function Rc(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 bo(e,t){let n=0;const r=Rc(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 Gr(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=Rc(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 eb(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 tb(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 b=i-1-g,x=typeof a=="number"?a:a(b);if(h-=x,e>=h)return b}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 b=s;b<m;b++){const x=a(b);if(p<=g+x)return b;g+=x}return}}let Ii=0,Ko={};const nb=typeof window>"u";async function rb(){var e;nb||((e=document==null?void 0:document.fonts)==null?void 0:e.ready)===void 0||(await document.fonts.ready,Ii=0,Ko={},Up())}rb();function Mc(e,t,n,r){return`${e}_${r??(t==null?void 0:t.font)}_${n}`}function Ki(e,t,n,r="middle"){const o=Mc(e,t,r,n);let i=Ko[o];return i===void 0&&(i=t.measureText(e),Ko[o]=i,Ii++),Ii>1e4&&(Ko={},Ii=0),i}function ob(e,t){const n=Mc(e,void 0,"middle",t);return Ko[n]}function Co(e,t){return typeof t!="string"&&(t=t.baseFontFull),ib(e,t)}function ol(e,t){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";e.save(),e.textBaseline=t;const r=e.measureText(n);return e.restore(),r}const il=[];function ib(e,t){for(const i of il)if(i.key===t)return i.val;const n=ol(e,"alphabetic"),o=-(ol(e,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return il.push({key:t,val:o}),o}function sb(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 Ic(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 Ec(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 ab(e,t){const n=Ki("ABCi09jgqpy",e,t);return n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}function lb(e,t){e.includes(`
7
+ `)&&(e=e.split(/\r?\n/,1)[0]);const n=t/4;return e.length>n&&(e=e.slice(0,n)),e}function cb(e,t,n,r,o,i,a,s,l,u){const d=s.baseFontFull,h=qp(e,t,d,o-s.cellHorizontalPadding*2,u??!1),m=ab(e,d),p=s.lineHeight*m,g=m+p*(h.length-1),b=g+s.cellVerticalPadding>i;b&&(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(Ec(e,w,n,C,o,m,a,s,l),C+=p,C>r+i)break;b&&e.restore()}function Tc(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=lb(t,d));const m=Co(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?cb(i,t,l,u,d,h,m,s,n,o):Ec(i,t,l,u,d,h,m,s,n),g&&(i.textAlign="start"),p&&(i.direction="inherit")}}function ho(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 ub(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 db(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),b=1,x=!1;p<0?g<0?g=Math.PI+g:(g=Math.PI-g,b=-1,x=!0):g>0&&(b=-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 G=l.x+h.nx*w,B=l.y+h.ny*w;G+=-h.ny*M*b,B+=h.nx*M*b,e.arc(G,B,M,d.ang+Math.PI/2*b,h.ang-Math.PI/2*b,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 b={x:0,y:i+u,width:0,height:0};if(e>=p.length||t>=d||t<-2||e<0)return b;const x=i-o;if(e>=h){const C=a>e?-1:1,w=bo(p);b.x+=w+l;for(let M=a;M!==e;M+=C)b.x+=p[C===1?M:M-1].width*C}else for(let C=0;C<e;C++)b.x+=p[C].width;if(b.width=p[e].width+1,t===-1)b.y=o,b.height=x;else if(t===-2){b.y=0,b.height=o;let C=e;const w=p[e].group,M=p[e].sticky;for(;C>0&&Vo(p[C-1].group,w)&&p[C-1].sticky===M;){const B=p[C-1];b.x-=B.width,b.width+=B.width,C--}let G=e;for(;G+1<p.length&&Vo(p[G+1].group,w)&&p[G+1].sticky===M;){const B=p[G+1];b.width+=B.width,G++}if(!M){const B=bo(p),A=b.x-B;A<0&&(b.x-=A,b.width+=A),b.x+b.width>n&&(b.width=n-b.x)}}else if(t>=d-m){let C=d-t;for(b.y=r;C>0;){const w=t+C-1;b.height=typeof g=="number"?g:g(w),b.y-=b.height,C--}b.height+=1}else{const C=s>t?-1:1;if(typeof g=="number"){const w=t-s;b.y+=w*g}else for(let w=s;w!==t;w+=C)b.y+=g(w)*C;b.height=(typeof g=="number"?g:g(t))+1}return b}const ta=1<<21;function or(e,t){return(t+2)*ta+e}function Dc(e){return e%ta}function na(e){return Math.floor(e/ta)-2}function $c(e){const t=Dc(e),n=na(e);return[t,n]}class fb{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=Dc(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&&po(this.freezeRows,r)||(this.visibleWindow=t,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class hb extends fb{constructor(){super(...arguments);Xe(this,"cache",new Map);Xe(this,"setValue",(n,r)=>{this.cache.set(or(n[0],n[1]),r)});Xe(this,"getValue",n=>this.cache.get(or(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=>or(n[0],n[1])))}add(t){this.cells.add(or(t[0],t[1]))}has(t){return t===void 0?!1:this.cells.has(or(t[0],t[1]))}remove(t){this.cells.delete(or(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(or(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 $c(t)}}function gb(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 Ac={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 Fc(){return Ac}const mb=zt.createContext(Ac);function ir(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 pb(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 _c(e,t,n,r,o,i,a,s,l){let u=0;const d=o===void 0?[]:o.map(p=>{const g=pb(e,p[r],t,l);return u=Math.max(u,g),g});if(d.length>5&&s){u=0;let p=0;for(const b of d)p+=b;const g=p/d.length;for(let b=0;b<d.length;b++)d[b]>=g*2?d[b]=0:u=Math.max(u,d[b])}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 bb(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({}),b=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)),G=0;M<u.current&&M>1&&(M--,G=1);const B={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 V=w(B,l.signal),k=G>0?w(A,l.signal):void 0;let F;typeof V=="object"?F=V:F=await Ya(V),k!==void 0&&(typeof k=="object"?F=[...F,...k]:F=[...F,...await Ya(k)]),b.current=e,C(F)})()},[l.signal,e]),c.useMemo(()=>{let M=e.every(vi)?e:p===null?e.map(L=>vi(L)?L:{...L,width:As}):(p.font=h.current.baseFontFull,e.map((L,V)=>{if(vi(L))return L;if(g.current[L.id]!==void 0)return{...L,width:g.current[L.id]};if(x===void 0||b.current!==e||L.id===void 0)return{...L,width:As};const k=_c(p,a,L,V,x,o,i,!0,s);return g.current[L.id]=k.width,k})),G=0,B=0;const A=[];for(const[L,V]of M.entries())G+=V.width,V.grow!==void 0&&V.grow>0&&(B+=V.grow,A.push(L));if(G<r&&A.length>0){const L=[...M],V=r-G;let k=V;for(let F=0;F<A.length;F++){const H=A[F],j=(M[H].grow??0)/B,_=F===A.length-1?k:Math.min(k,Math.floor(V*j));L[H]={...M[H],growOffset:_,width:M[H].width+_},k-=_}M=L}return{sizedColumns:M,nonGrowWidth:G}},[r,e,p,x,a,o,i,s])}function yb(e,t,n){return e===e&&(n!==void 0&&(e=e<=n?e:n),t!==void 0&&(e=e>=t?e:t)),e}var vb=yb,wb=vb,gs=Zs;function xb(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),wb(gs(e),t,n)}var Cb=xb;const En=zr(Cb);var kb="__lodash_hash_undefined__";function Sb(e){return this.__data__.set(e,kb),this}var Rb=Sb;function Mb(e){return this.__data__.has(e)}var Ib=Mb,Eb=Xs,Tb=Rb,Db=Ib;function _i(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Eb;++t<n;)this.add(e[t])}_i.prototype.add=_i.prototype.push=Tb;_i.prototype.has=Db;var Pc=_i;function $b(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 Ab=$b;function Fb(e){return e!==e}var _b=Fb;function Pb(e,t,n){for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}var Ob=Pb,jb=Ab,Nb=_b,Hb=Ob;function Bb(e,t,n){return t===t?Hb(e,t,n):jb(e,Nb,n)}var Lb=Bb,zb=Lb;function Wb(e,t){var n=e==null?0:e.length;return!!n&&zb(e,t,0)>-1}var Gb=Wb;function Ub(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 Xb=Ub;function Kb(e,t){return e.has(t)}var Oc=Kb,Yb=Wr,qb=Qn,Vb=Yb(qb,"Set"),jc=Vb;function Jb(){}var Qb=Jb;function Zb(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ra=Zb,ms=jc,ey=Qb,ty=ra,ny=1/0,ry=ms&&1/ty(new ms([,-0]))[1]==ny?function(e){return new ms(e)}:ey,oy=ry,iy=Pc,sy=Gb,ay=Xb,ly=Oc,cy=oy,uy=ra,dy=200;function fy(e,t,n){var r=-1,o=sy,i=e.length,a=!0,s=[],l=s;if(n)a=!1,o=ay;else if(i>=dy){var u=t?null:cy(e);if(u)return uy(u);a=!1,o=ly,l=new iy}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 hy=fy,gy=hy;function my(e){return e&&e.length?gy(e):[]}var py=my;const by=zr(py);function yy(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}var Nc=yy,sl=ei,vy=Ys,wy=Jn,al=sl?sl.isConcatSpreadable:void 0;function xy(e){return wy(e)||vy(e)||!!(al&&e&&e[al])}var Cy=xy,ky=Nc,Sy=Cy;function Hc(e,t,n,r,o){var i=-1,a=e.length;for(n||(n=Sy),o||(o=[]);++i<a;){var s=e[i];t>0&&n(s)?t>1?Hc(s,t-1,n,r,o):ky(o,s):r||(o[o.length]=s)}return o}var Ry=Hc,My=Ry;function Iy(e){var t=e==null?0:e.length;return t?My(e,1):[]}var Ey=Iy;const ll=zr(Ey);var Ty=Math.ceil,Dy=Math.max;function $y(e,t,n,r){for(var o=-1,i=Dy(Ty((t-e)/(n||1)),0),a=Array(i);i--;)a[r?i:++o]=e,e+=n;return a}var Ay=$y,Fy=cc,_y=Vs;function Py(e){return e!=null&&_y(e.length)&&!Fy(e)}var oa=Py,Oy=Gs,jy=oa,Ny=qs,Hy=yo;function By(e,t,n){if(!Hy(n))return!1;var r=typeof t;return(r=="number"?jy(n)&&Ny(t,n.length):r=="string"&&t in n)?Oy(n[t],e):!1}var Ly=By,zy=Zs,cl=1/0,Wy=17976931348623157e292;function Gy(e){if(!e)return e===0?e:0;if(e=zy(e),e===cl||e===-cl){var t=e<0?-1:1;return t*Wy}return e===e?e:0}var Uy=Gy,Xy=Ay,Ky=Ly,ps=Uy;function Yy(e){return function(t,n,r){return r&&typeof r!="number"&&Ky(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),Xy(t,n,r,e)}}var qy=Yy,Vy=qy,Jy=Vy(),Qy=Jy;const Br=zr(Qy);function Zy(e,t){return e==="normal"?[t.bgIconHeader,t.fgIconHeader]:e==="selected"?["white",t.accentColor]:[t.accentColor,t.bgHeader]}class e0{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]=Zy(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 b=p.getContext("2d");if(b===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(()=>{b.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 Bc(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 Rr(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 Lc(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&&Vo(e[u].group,l.group)&&e[u].sticky===e[s].sticky;){const b=e[u];d+=b.width,u++,s++,b.sticky&&(a+=b.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 zc(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,b=r;for(let x=i.sourceIndex-1;x>=p;x--)g-=a[x].width,b+=a[x].width;for(let x=i.sourceIndex+1;x<=l;x++)b+=a[x].width;d={x:g,y:n,width:b,height:o}}if(h>s){const p=Math.min(l,h-1);let g=t,b=r;for(let x=i.sourceIndex-1;x>=s;x--)g-=a[x].width,b+=a[x].width;for(let x=i.sourceIndex+1;x<=p;x++)b+=a[x].width;u={x:g,y:n,width:b,height:o}}return[u,d]}function t0(e,t,n,r){if(r==="any")return Wc(e,{x:t,y:n,width:1,height:1});if(r==="vertical"&&(t=e.x),r==="horizontal"&&(n=e.y),kc([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 Jo(e,t,n,r,o,i,a,s){return e<=o+a&&o<=e+n&&t<=i+s&&i<=t+r}function go(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function Wc(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 n0(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 r0(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,b=h>0?e.y+e.height-Math.floor(h/r)*r:e.y+e.height;return{x:m,y:g,width:p-m,height:b-g}}function o0(e,t,n,r,o){const[i,a,s,l]=t,[u,d,h,m]=o,{x:p,y:g,width:b,height:x}=e,C=[];if(b<=0||x<=0)return C;const w=p+b,M=g+x,G=p<i,B=g<a,A=p+b>s,L=g+x>l,V=p>=i&&p<s||w>i&&w<=s||p<i&&w>s,k=g>=a&&g<l||M>a&&M<=l||g<a&&M>l;if(V&&k){const H=Math.max(p,i),j=Math.max(g,a),_=Math.min(w,s),D=Math.min(M,l);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:u,y:d,width:h-u+1,height:m-d+1}})}if(G&&B){const H=p,j=g,_=Math.min(w,i),D=Math.min(M,a);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:0,y:0,width:u+1,height:d+1}})}if(B&&V){const H=Math.max(p,i),j=g,_=Math.min(w,s),D=Math.min(M,a);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:u,y:0,width:h-u+1,height:d+1}})}if(B&&A){const H=Math.max(p,s),j=g,_=w,D=Math.min(M,a);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:h,y:0,width:n-h+1,height:d+1}})}if(G&&k){const H=p,j=Math.max(g,a),_=Math.min(w,i),D=Math.min(M,l);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:0,y:d,width:u+1,height:m-d+1}})}if(A&&k){const H=Math.max(p,s),j=Math.max(g,a),_=w,D=Math.min(M,l);C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:h,y:d,width:n-h+1,height:m-d+1}})}if(G&&L){const H=p,j=Math.max(g,l),_=Math.min(w,i),D=M;C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:0,y:m,width:u+1,height:r-m+1}})}if(L&&V){const H=Math.max(p,i),j=Math.max(g,l),_=Math.min(w,s),D=M;C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:u,y:m,width:h-u+1,height:r-m+1}})}if(A&&L){const H=Math.max(p,s),j=Math.max(g,l),_=w,D=M;C.push({rect:{x:H,y:j,width:_-H,height:D-j},clip:{x:h,y:m,width:n-h+1,height:r-m+1}})}return C}const i0={kind:ce.Loading,allowOverlay:!1};function ul(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w,M,G,B,A,L,V,k,F,H,j,_,D,fe,U,Z,he){let de=(M==null?void 0:M.size)??Number.MAX_SAFE_INTEGER;const ee=performance.now();let q=_.baseFontFull;e.font=q;const Se={ctx:e},se=[0,0],oe=x>0?Gr(l,x,u):0;let Ee,J;const ae=Bc(w);return Rr(t,s,i,a,o,(pe,Ge,Oe,rt,je)=>{const Te=Math.max(0,rt-Ge),Fe=Ge+Te,_e=o+1,mt=pe.width-Te,xt=r-o-1;if(w.length>0){let ot=!1;for(let Le=0;Le<w.length;Le++){const Ke=w[Le];if(Jo(Fe,_e,mt,xt,Ke.x,Ke.y,Ke.width,Ke.height)){ot=!0;break}}if(!ot)return}const pt=()=>{e.save(),e.beginPath(),e.rect(Fe,_e,mt,xt),e.clip()},ie=G.columns.hasIndex(pe.sourceIndex),be=h(pe.group??"").overrideTheme,Me=pe.themeOverride===void 0&&be===void 0?_:ir(_,be,pe.themeOverride),De=Me.baseFontFull;De!==q&&(q=De,e.font=De),pt();let ke;return Yi(je,Oe,r,l,u,x,C,ae,(ot,Le,Ke,ue,ye)=>{var Je,It,$t;if(Le<0||(se[0]=pe.sourceIndex,se[1]=Le,M!==void 0&&!M.has(se)))return;if(w.length>0){let tt=!1;for(let Rt=0;Rt<w.length;Rt++){const gt=w[Rt];if(Jo(Ge,ot,pe.width,Ke,gt.x,gt.y,gt.width,gt.height)){tt=!0;break}}if(!tt)return}const Ye=G.rows.hasIndex(Le),Ve=p.hasIndex(Le),it=Le<l?d(se):i0;let xe=Ge,dt=pe.width,Ne=!1,He=!1;if(it.span!==void 0){const[tt,Rt]=it.span,gt=`${Le},${tt},${Rt},${pe.sticky}`;if(J===void 0&&(J=new Set),J.has(gt)){de--;return}else{const qt=zc(it.span,Ge,ot,pe.width,Ke,pe,n),Nt=pe.sticky?qt[0]:qt[1];if(!pe.sticky&&qt[0]!==void 0&&(He=!0),Nt!==void 0){xe=Nt.x,dt=Nt.width,J.add(gt),e.restore(),ke=void 0,e.save(),e.beginPath();const Ot=Math.max(0,rt-Nt.x);e.rect(Nt.x+Ot,ot,Nt.width-Ot,Ke),Ee===void 0&&(Ee=[]),Ee.push({x:Nt.x+Ot,y:ot,width:Nt.width-Ot,height:Ke}),e.clip(),Ne=!0}}}const st=m==null?void 0:m(Le),Wt=ye&&((Je=pe.trailingRowOptions)==null?void 0:Je.themeOverride)!==void 0?(It=pe.trailingRowOptions)==null?void 0:It.themeOverride:void 0,ct=it.themeOverride===void 0&&st===void 0&&Wt===void 0?Me:ir(Me,st,Wt,it.themeOverride);e.beginPath();const $e=Qp(se,it,G);let bt=Zp(se,it,G,b);const Ht=it.span!==void 0&&G.columns.some(tt=>it.span!==void 0&&tt>=it.span[0]&&tt<=it.span[1]);$e&&!g&&b?bt=0:$e&&b&&(bt=Math.max(bt,1)),Ht&&bt++,$e||(Ye&&bt++,ie&&!ye&&bt++);const Yt=it.kind===ce.Protected?ct.bgCellMedium:ct.bgCell;let vt;if((ue||Yt!==_.bgCell)&&(vt=bn(Yt,vt)),bt>0||Ve){Ve&&(vt=bn(ct.bgHeader,vt));for(let tt=0;tt<bt;tt++)vt=bn(ct.accentLight,vt)}else if(B!==void 0){for(const tt of B)if(tt[0]===pe.sourceIndex&&tt[1]===Le){vt=bn(ct.bgSearchResult,vt);break}}if(A!==void 0)for(let tt=0;tt<A.length;tt++){const Rt=A[tt],gt=Rt.range;Rt.style!=="solid-outline"&&gt.x<=pe.sourceIndex&&pe.sourceIndex<gt.x+gt.width&&gt.y<=Le&&Le<gt.y+gt.height&&(vt=bn(Rt.color,vt))}let yn=!1;if(M!==void 0){const tt=ot+1,gt=(ue?tt+Ke-1:Math.min(tt+Ke-1,r-oe))-tt;(gt!==Ke-1||xe+1<=rt)&&(yn=!0,e.save(),e.beginPath(),e.rect(xe+1,tt,dt-1,gt),e.clip()),vt=vt===void 0?ct.bgCell:bn(vt,ct.bgCell)}const dn=pe.sourceIndex===n.length-1,kt=Le===l-1;vt!==void 0&&(e.fillStyle=vt,ke!==void 0&&(ke.fillStyle=vt),M!==void 0?e.fillRect(xe+1,ot+1,dt-(dn?2:1),Ke-(kt?2:1)):e.fillRect(xe,ot,dt,Ke)),it.style==="faded"&&(e.globalAlpha=.6);let Ut;for(let tt=0;tt<k.length;tt++){const Rt=k[tt];if(Rt.item[0]===pe.sourceIndex&&Rt.item[1]===Le){Ut=Rt;break}}if(dt>he&&!He){const tt=ct.baseFontFull;tt!==q&&(e.font=tt,q=tt),ke=Gc(e,it,pe.sourceIndex,Le,dn,kt,xe,ot,dt,Ke,bt>0,ct,vt??ct.bgCell,L,V,(Ut==null?void 0:Ut.hoverAmount)??0,F,j,ee,H,ke,D,fe,U,Z)}return yn&&e.restore(),it.style==="faded"&&(e.globalAlpha=1),de--,Ne&&(e.restore(),($t=ke==null?void 0:ke.deprep)==null||$t.call(ke,Se),ke=void 0,pt(),q=De,e.font=De),de<=0}),e.restore(),de<=0}),Ee}const jo=[0,0],No={x:0,y:0,width:0,height:0},bs=[void 0,()=>{}];let Fs=!1;function s0(){Fs=!0}function Gc(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w,M,G,B,A,L,V){var fe,U;let k,F;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(k=x[1][0],F=x[1][1]);let H;jo[0]=n,jo[1]=r,No.x=a,No.y=s,No.width=l,No.height=u,bs[0]=A.getValue(jo),bs[1]=Z=>A.setValue(jo,Z),Fs=!1;const j={ctx:e,theme:h,col:n,row:r,cell:t,rect:No,highlighted:d,cellFillColor:m,hoverAmount:b,frameTime:w,hoverX:k,drawState:bs,hoverY:F,imageLoader:p,spriteManager:g,hyperWrapping:C,overrideCursor:k!==void 0?V:void 0,requestAnimationFrame:s0},_=sb(j,t.lastUpdated,w,G,o,i),D=L(t);if(D!==void 0){(G==null?void 0:G.renderer)!==D&&((fe=G==null?void 0:G.deprep)==null||fe.call(G,j),G=void 0);const Z=(U=D.drawPrep)==null?void 0:U.call(D,j,G);M!==void 0&&!co(j.cell)?M(j,()=>D.draw(j,t)):D.draw(j,t),H=Z===void 0?void 0:{deprep:Z==null?void 0:Z.deprep,fillStyle:Z==null?void 0:Z.fillStyle,font:Z==null?void 0:Z.font,renderer:D}}return(_||Fs)&&(B==null||B(jo)),H}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 b=xc(d??t.checkboxMaxSize,a,t.cellVerticalPadding),x=b/2;const C=wc(h,r,i,t.cellHorizontalPadding,b),w=vc(C,p,b),M=Cc(r+l,o+u,w);switch(n){case!0:{e.beginPath(),ho(e,C-b/2,p-b/2,b,b,g),m==="circle"&&(x*=.8,b*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(C-x+b/4.23,p-x+b/1.97),e.lineTo(C-x+b/2.42,p-x+b/1.44),e.lineTo(C-x+b/1.29,p-x+b/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(),ho(e,C-b/2+.5,p-b/2+.5,b-1,b-1,g),e.lineWidth=1,e.strokeStyle=M?t.textDark:t.textMedium,e.stroke();break}case Js:{e.beginPath(),ho(e,C-b/2,p-b/2,b,b,g),e.fillStyle=M?t.textMedium:t.textLight,e.fill(),m==="circle"&&(x*=.8,b*=.8),e.beginPath(),e.moveTo(C-b/3,p),e.lineTo(C+b/3,p),e.strokeStyle=t.bgCell,e.lineCap="round",e.lineWidth=1.9,e.stroke();break}default:qo()}}function a0(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w){var k,F,H,j;const M=a+s;if(M<=0)return;e.fillStyle=h.bgHeader,e.fillRect(0,0,o,M);const G=(k=r==null?void 0:r[0])==null?void 0:k[0],B=(F=r==null?void 0:r[0])==null?void 0:F[1],A=(H=r==null?void 0:r[1])==null?void 0:H[0],L=(j=r==null?void 0:r[1])==null?void 0:j[1],V=h.headerFontFull;e.font=V,Rr(t,0,i,0,M,(_,D,fe,U)=>{var pe;if(x!==void 0&&!x.has([_.sourceIndex,-1]))return;const Z=Math.max(0,U-D);e.save(),e.beginPath(),e.rect(D+Z,s,_.width-Z,a),e.clip();const he=b(_.group??"").overrideTheme,de=_.themeOverride===void 0&&he===void 0?h:ir(h,he,_.themeOverride);de.bgHeader!==h.bgHeader&&(e.fillStyle=de.bgHeader,e.fill()),de!==h&&(e.font=de.headerFontFull);const ee=d.columns.hasIndex(_.sourceIndex),q=l!==void 0||u||_.headerRowMarkerDisabled===!0,Se=!q&&B===-1&&G===_.sourceIndex,se=q?0:((pe=p.find(Ge=>Ge.item[0]===_.sourceIndex&&Ge.item[1]===-1))==null?void 0:pe.hoverAmount)??0,oe=(d==null?void 0:d.current)!==void 0&&d.current.cell[0]===_.sourceIndex,Ee=ee?de.accentColor:oe?de.bgHeaderHasFocus:de.bgHeader,J=n?s:0,ae=_.sourceIndex===0?0:1;ee?(e.fillStyle=Ee,e.fillRect(D+ae,J,_.width-ae,a)):(oe||se>0)&&(e.beginPath(),e.rect(D+ae,J,_.width-ae,a),oe&&(e.fillStyle=de.bgHeaderHasFocus,e.fill()),se>0&&(e.globalAlpha=se,e.fillStyle=de.bgHeaderHovered,e.fill(),e.globalAlpha=1)),Kc(e,D,J,_.width,a,_,ee,de,Se,Se?A:void 0,Se?L:void 0,oe,se,m,C,w),e.restore()}),n&&l0(e,t,o,i,s,r,h,m,p,g,b,x)}function l0(e,t,n,r,o,i,a,s,l,u,d,h){const[p,g]=(i==null?void 0:i[0])??[];let b=0;Lc(t,n,r,o,(x,C,w,M,G,B)=>{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,G,B),e.clip();const A=d(C),L=(A==null?void 0:A.overrideTheme)===void 0?a:ir(a,A.overrideTheme),V=g===-2&&p!==void 0&&p>=x[0]&&p<=x[1],k=V?L.bgGroupHeaderHovered??L.bgHeaderHovered:L.bgGroupHeader??L.bgHeader;if(k!==a.bgHeader&&(e.fillStyle=k,e.fill()),e.fillStyle=L.textGroupHeader??L.textHeader,A!==void 0){let F=w;if(A.icon!==void 0&&(s.drawSprite(A.icon,"normal",e,F+8,(o-20)/2,20,L),F+=26),e.fillText(A.name,F+8,o/2+Co(e,a.headerFontFull)),A.actions!==void 0&&V){const H=Uc({x:w,y:M,width:G,height:B},A.actions);e.beginPath();const j=H[0].x-10,_=w+G-j;e.rect(j,0,_,o);const D=e.createLinearGradient(j,0,j+_,0),fe=Lr(k,0);D.addColorStop(0,fe),D.addColorStop(10/_,k),D.addColorStop(1,k),e.fillStyle=D,e.fill(),e.globalAlpha=.6;const[U,Z]=(i==null?void 0:i[1])??[-1,-1];for(let he=0;he<A.actions.length;he++){const de=A.actions[he],ee=H[he],q=go(ee,U+w,Z);q&&(e.globalAlpha=1),s.drawSprite(de.icon,"normal",e,ee.x+ee.width/2-10,ee.y+ee.height/2-10,20,L),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(),b=w+G}),e.beginPath(),e.moveTo(b+.5,0),e.lineTo(b+.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 c0(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 Uc(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 Ho(e,t,n){return!n||e===void 0||(e.x=t-(e.x-t)-e.width),e}function Xc(e,t,n,r,o,i,a,s){var C;const l=a.cellHorizontalPadding,u=a.headerIconSize,d=c0(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 b;if(t.indicatorIcon!==void 0){const w=e===void 0?((C=ob(t.title,a.headerFontFull))==null?void 0:C.width)??0:Ki(t.title,e,a.headerFontFull).width;g.width=w,h+=w+l,b={x:h,y:r+(i-u)/2,width:u,height:u}}const x=n+o/2;return{menuBounds:Ho(d,x,s),iconBounds:Ho(m,x,s),iconOverlayBounds:Ho(p,x,s),textBounds:Ho(g,x,s),indicatorIconBounds:Ho(b,x,s)}}function dl(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b){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?ir(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)&&b.menuBounds!==void 0;if(i.icon!==void 0&&b.iconBounds!==void 0){let w=a?"selected":"normal";i.style==="highlight"&&(w=a?"selected":"special"),m.drawSprite(i.icon,w,e,b.iconBounds.x,b.iconBounds.y,b.iconBounds.width,s),i.overlayIcon!==void 0&&b.iconOverlayBounds!==void 0&&m.drawSprite(i.overlayIcon,a?"selected":"special",e,b.iconOverlayBounds.x,b.iconOverlayBounds.y,b.iconOverlayBounds.width,s)}if(C&&r>35){const M=g?35:r-35,G=g?35*.7:r-35*.7,B=M/r,A=G/r,L=e.createLinearGradient(t,0,t+r,0),V=Lr(x,0);L.addColorStop(g?1:0,x),L.addColorStop(B,x),L.addColorStop(A,V),L.addColorStop(g?0:1,V),e.fillStyle=L}else e.fillStyle=x;if(g&&(e.textAlign="right"),b.textBounds!==void 0&&e.fillText(i.title,g?b.textBounds.x+b.textBounds.width:b.textBounds.x,n+o/2+Co(e,s.headerFontFull)),g&&(e.textAlign="left"),i.indicatorIcon!==void 0&&b.indicatorIconBounds!==void 0&&(!C||!Jo(b.menuBounds.x,b.menuBounds.y,b.menuBounds.width,b.menuBounds.height,b.indicatorIconBounds.x,b.indicatorIconBounds.y,b.indicatorIconBounds.width,b.indicatorIconBounds.height))){let w=a?"selected":"normal";i.style==="highlight"&&(w=a?"selected":"special"),m.drawSprite(i.indicatorIcon,w,e,b.indicatorIconBounds.x,b.indicatorIconBounds.y,b.indicatorIconBounds.width,s)}if(C&&b.menuBounds!==void 0){const w=b.menuBounds,M=u!==void 0&&d!==void 0&&go(w,u+t,d+n);if(M||(e.globalAlpha=.7),i.menuIcon===void 0||i.menuIcon===Ai.Triangle){e.beginPath();const G=w.x+w.width/2-5.5,B=w.y+w.height/2-3;db(e,[{x:G,y:B},{x:G+11,y:B},{x:G+5.5,y:B+6}],1),e.fillStyle=x,e.fill()}else if(i.menuIcon===Ai.Dots){e.beginPath();const G=w.x+w.width/2,B=w.y+w.height/2;ub(e,G,B),e.fillStyle=x,e.fill()}else{const G=w.x+(w.width-s.headerIconSize)/2,B=w.y+(w.height-s.headerIconSize)/2;m.drawSprite(i.menuIcon,"normal",e,G,B,s.headerIconSize,s)}M||(e.globalAlpha=1)}}function Kc(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b){const x=ea(i.title)==="rtl",C=Xc(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},()=>dl(e,t,n,r,o,i,a,s,l,u,d,m,p,b,x,C)):dl(e,t,n,r,o,i,a,s,l,u,d,m,p,b,x,C)}var u0=Wr,d0=function(){try{var e=u0(Object,"defineProperty");return e({},"",{}),e}catch{}}(),f0=d0,fl=f0;function h0(e,t,n){t=="__proto__"&&fl?fl(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var g0=h0;function m0(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 p0=m0;function b0(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 y0=b0,v0=y0,w0=v0(),x0=w0;function C0(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var k0=C0,Pi={exports:{}};function S0(){return!1}var R0=S0;Pi.exports;(function(e,t){var n=Qn,r=R0,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 Yc=Pi.exports,M0=ti,I0=Vs,E0=ni,T0="[object Arguments]",D0="[object Array]",$0="[object Boolean]",A0="[object Date]",F0="[object Error]",_0="[object Function]",P0="[object Map]",O0="[object Number]",j0="[object Object]",N0="[object RegExp]",H0="[object Set]",B0="[object String]",L0="[object WeakMap]",z0="[object ArrayBuffer]",W0="[object DataView]",G0="[object Float32Array]",U0="[object Float64Array]",X0="[object Int8Array]",K0="[object Int16Array]",Y0="[object Int32Array]",q0="[object Uint8Array]",V0="[object Uint8ClampedArray]",J0="[object Uint16Array]",Q0="[object Uint32Array]",Tt={};Tt[G0]=Tt[U0]=Tt[X0]=Tt[K0]=Tt[Y0]=Tt[q0]=Tt[V0]=Tt[J0]=Tt[Q0]=!0;Tt[T0]=Tt[D0]=Tt[z0]=Tt[$0]=Tt[W0]=Tt[A0]=Tt[F0]=Tt[_0]=Tt[P0]=Tt[O0]=Tt[j0]=Tt[N0]=Tt[H0]=Tt[B0]=Tt[L0]=!1;function Z0(e){return E0(e)&&I0(e.length)&&!!Tt[M0(e)]}var ev=Z0;function tv(e){return function(t){return e(t)}}var nv=tv,Oi={exports:{}};Oi.exports;(function(e,t){var n=ac,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 rv=Oi.exports,ov=ev,iv=nv,hl=rv,gl=hl&&hl.isTypedArray,sv=gl?iv(gl):ov,qc=sv,av=k0,lv=Ys,cv=Jn,uv=Yc,dv=qs,fv=qc,hv=Object.prototype,gv=hv.hasOwnProperty;function mv(e,t){var n=cv(e),r=!n&&lv(e),o=!n&&!r&&uv(e),i=!n&&!r&&!o&&fv(e),a=n||r||o||i,s=a?av(e.length,String):[],l=s.length;for(var u in e)(t||gv.call(e,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||dv(u,l)))&&s.push(u);return s}var pv=mv,bv=Object.prototype;function yv(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||bv;return e===n}var vv=yv;function wv(e,t){return function(n){return e(t(n))}}var xv=wv,Cv=xv,kv=Cv(Object.keys,Object),Sv=kv,Rv=vv,Mv=Sv,Iv=Object.prototype,Ev=Iv.hasOwnProperty;function Tv(e){if(!Rv(e))return Mv(e);var t=[];for(var n in Object(e))Ev.call(e,n)&&n!="constructor"&&t.push(n);return t}var Dv=Tv,$v=pv,Av=Dv,Fv=oa;function _v(e){return Fv(e)?$v(e):Av(e)}var sa=_v,Pv=x0,Ov=sa;function jv(e,t){return e&&Pv(e,t,Ov)}var Nv=jv,Hv=oa;function Bv(e,t){return function(n,r){if(n==null)return n;if(!Hv(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 Lv=Bv,zv=Nv,Wv=Lv,Gv=Wv(zv),Uv=Gv,Xv=Uv;function Kv(e,t,n,r){return Xv(e,function(o,i,a){t(r,o,n(o),a)}),r}var Yv=Kv,qv=Gi;function Vv(){this.__data__=new qv,this.size=0}var Jv=Vv;function Qv(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var Zv=Qv;function ew(e){return this.__data__.get(e)}var tw=ew;function nw(e){return this.__data__.has(e)}var rw=nw,ow=Gi,iw=Us,sw=Xs,aw=200;function lw(e,t){var n=this.__data__;if(n instanceof ow){var r=n.__data__;if(!iw||r.length<aw-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new sw(r)}return n.set(e,t),this.size=n.size,this}var cw=lw,uw=Gi,dw=Jv,fw=Zv,hw=tw,gw=rw,mw=cw;function ko(e){var t=this.__data__=new uw(e);this.size=t.size}ko.prototype.clear=dw;ko.prototype.delete=fw;ko.prototype.get=hw;ko.prototype.has=gw;ko.prototype.set=mw;var Vc=ko;function pw(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 bw=pw,yw=Pc,vw=bw,ww=Oc,xw=1,Cw=2;function kw(e,t,n,r,o,i){var a=n&xw,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&Cw?new yw:void 0;for(i.set(e,t),i.set(t,e);++h<s;){var g=e[h],b=t[h];if(r)var x=a?r(b,g,h,t,e,i):r(g,b,h,e,t,i);if(x!==void 0){if(x)continue;m=!1;break}if(p){if(!vw(t,function(C,w){if(!ww(p,w)&&(g===C||o(g,C,n,r,i)))return p.push(w)})){m=!1;break}}else if(!(g===b||o(g,b,n,r,i))){m=!1;break}}return i.delete(e),i.delete(t),m}var Jc=kw,Sw=Qn,Rw=Sw.Uint8Array,Mw=Rw;function Iw(e){var t=-1,n=Array(e.size);return e.forEach(function(r,o){n[++t]=[o,r]}),n}var Ew=Iw,ml=ei,pl=Mw,Tw=Gs,Dw=Jc,$w=Ew,Aw=ra,Fw=1,_w=2,Pw="[object Boolean]",Ow="[object Date]",jw="[object Error]",Nw="[object Map]",Hw="[object Number]",Bw="[object RegExp]",Lw="[object Set]",zw="[object String]",Ww="[object Symbol]",Gw="[object ArrayBuffer]",Uw="[object DataView]",bl=ml?ml.prototype:void 0,ys=bl?bl.valueOf:void 0;function Xw(e,t,n,r,o,i,a){switch(n){case Uw:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Gw:return!(e.byteLength!=t.byteLength||!i(new pl(e),new pl(t)));case Pw:case Ow:case Hw:return Tw(+e,+t);case jw:return e.name==t.name&&e.message==t.message;case Bw:case zw:return e==t+"";case Nw:var s=$w;case Lw:var l=r&Fw;if(s||(s=Aw),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=Dw(s(e),s(t),r,o,i,a);return a.delete(e),d;case Ww:if(ys)return ys.call(e)==ys.call(t)}return!1}var Kw=Xw,Yw=Nc,qw=Jn;function Vw(e,t,n){var r=t(e);return qw(e)?r:Yw(r,n(e))}var Jw=Vw;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 Zw=Qw;function ex(){return[]}var tx=ex,nx=Zw,rx=tx,ox=Object.prototype,ix=ox.propertyIsEnumerable,yl=Object.getOwnPropertySymbols,sx=yl?function(e){return e==null?[]:(e=Object(e),nx(yl(e),function(t){return ix.call(e,t)}))}:rx,ax=sx,lx=Jw,cx=ax,ux=sa;function dx(e){return lx(e,ux,cx)}var fx=dx,vl=fx,hx=1,gx=Object.prototype,mx=gx.hasOwnProperty;function px(e,t,n,r,o,i){var a=n&hx,s=vl(e),l=s.length,u=vl(t),d=u.length;if(l!=d&&!a)return!1;for(var h=l;h--;){var m=s[h];if(!(a?m in t:mx.call(t,m)))return!1}var p=i.get(e),g=i.get(t);if(p&&g)return p==t&&g==e;var b=!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)){b=!1;break}x||(x=m=="constructor")}if(b&&!x){var G=e.constructor,B=t.constructor;G!=B&&"constructor"in e&&"constructor"in t&&!(typeof G=="function"&&G instanceof G&&typeof B=="function"&&B instanceof B)&&(b=!1)}return i.delete(e),i.delete(t),b}var bx=px,yx=Wr,vx=Qn,wx=yx(vx,"DataView"),xx=wx,Cx=Wr,kx=Qn,Sx=Cx(kx,"Promise"),Rx=Sx,Mx=Wr,Ix=Qn,Ex=Mx(Ix,"WeakMap"),Tx=Ex,_s=xx,Ps=Us,Os=Rx,js=jc,Ns=Tx,Qc=ti,So=uc,wl="[object Map]",Dx="[object Object]",xl="[object Promise]",Cl="[object Set]",kl="[object WeakMap]",Sl="[object DataView]",$x=So(_s),Ax=So(Ps),Fx=So(Os),_x=So(js),Px=So(Ns),Hr=Qc;(_s&&Hr(new _s(new ArrayBuffer(1)))!=Sl||Ps&&Hr(new Ps)!=wl||Os&&Hr(Os.resolve())!=xl||js&&Hr(new js)!=Cl||Ns&&Hr(new Ns)!=kl)&&(Hr=function(e){var t=Qc(e),n=t==Dx?e.constructor:void 0,r=n?So(n):"";if(r)switch(r){case $x:return Sl;case Ax:return wl;case Fx:return xl;case _x:return Cl;case Px:return kl}return t});var Ox=Hr,vs=Vc,jx=Jc,Nx=Kw,Hx=bx,Rl=Ox,Ml=Jn,Il=Yc,Bx=qc,Lx=1,El="[object Arguments]",Tl="[object Array]",Ci="[object Object]",zx=Object.prototype,Dl=zx.hasOwnProperty;function Wx(e,t,n,r,o,i){var a=Ml(e),s=Ml(t),l=a?Tl:Rl(e),u=s?Tl:Rl(t);l=l==El?Ci:l,u=u==El?Ci:u;var d=l==Ci,h=u==Ci,m=l==u;if(m&&Il(e)){if(!Il(t))return!1;a=!0,d=!1}if(m&&!d)return i||(i=new vs),a||Bx(e)?jx(e,t,n,r,o,i):Nx(e,t,l,n,r,o,i);if(!(n&Lx)){var p=d&&Dl.call(e,"__wrapped__"),g=h&&Dl.call(t,"__wrapped__");if(p||g){var b=p?e.value():e,x=g?t.value():t;return i||(i=new vs),o(b,x,n,r,i)}}return m?(i||(i=new vs),Hx(e,t,n,r,o,i)):!1}var Gx=Wx,Ux=Gx,$l=ni;function Zc(e,t,n,r,o){return e===t?!0:e==null||t==null||!$l(e)&&!$l(t)?e!==e&&t!==t:Ux(e,t,n,r,Zc,o)}var eu=Zc,Xx=Vc,Kx=eu,Yx=1,qx=2;function Vx(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 Xx;if(r)var m=r(u,d,l,e,t,h);if(!(m===void 0?Kx(d,u,Yx|qx,r,h):m))return!1}}return!0}var Jx=Vx,Qx=yo;function Zx(e){return e===e&&!Qx(e)}var tu=Zx,e1=tu,t1=sa;function n1(e){for(var t=t1(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,e1(o)]}return t}var r1=n1;function o1(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}var nu=o1,i1=Jx,s1=r1,a1=nu;function l1(e){var t=s1(e);return t.length==1&&t[0][2]?a1(t[0][0],t[0][1]):function(n){return n===e||i1(n,e,t)}}var c1=l1,u1=hc,d1=Xi;function f1(e,t){t=u1(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[d1(t[n++])];return n&&n==r?e:void 0}var ru=f1,h1=ru;function g1(e,t,n){var r=e==null?void 0:h1(e,t);return r===void 0?n:r}var m1=g1;function p1(e,t){return e!=null&&t in Object(e)}var b1=p1,y1=b1,v1=mc;function w1(e,t){return e!=null&&v1(e,t,y1)}var x1=w1,C1=eu,k1=m1,S1=x1,R1=Ws,M1=tu,I1=nu,E1=Xi,T1=1,D1=2;function $1(e,t){return R1(e)&&M1(t)?I1(E1(e),t):function(n){var r=k1(n,e);return r===void 0&&r===t?S1(n,e):C1(t,r,T1|D1)}}var A1=$1;function F1(e){return e}var _1=F1;function P1(e){return function(t){return t==null?void 0:t[e]}}var O1=P1,j1=ru;function N1(e){return function(t){return j1(t,e)}}var H1=N1,B1=O1,L1=H1,z1=Ws,W1=Xi;function G1(e){return z1(e)?B1(W1(e)):L1(e)}var U1=G1,X1=c1,K1=A1,Y1=_1,q1=Jn,V1=U1;function J1(e){return typeof e=="function"?e:e==null?Y1:typeof e=="object"?q1(e)?K1(e[0],e[1]):X1(e):V1(e)}var Q1=J1,Z1=p0,eC=Yv,tC=Q1,nC=Jn;function rC(e,t){return function(n,r){var o=nC(n)?Z1:eC,i=t?t():{};return o(n,e,tC(r),i)}}var oC=rC,iC=g0,sC=oC,aC=Object.prototype,lC=aC.hasOwnProperty,cC=sC(function(e,t,n){lC.call(e,n)?e[n].push(t):iC(e,n,[t])}),uC=cC;const dC=zr(uC);function fC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w){if(C!==void 0||t[t.length-1]!==n[t.length-1])return;const M=Bc(x);Rr(t,l,a,s,i,(G,B,A,L,V)=>{if(G!==t[t.length-1])return;B+=G.width;const k=Math.max(B,L);k>r||(e.save(),e.beginPath(),e.rect(k,i+1,1e4,o-i-1),e.clip(),Yi(V,A,o,u,d,g,b,M,(F,H,j,_)=>{if(!_&&x.length>0&&!x.some(he=>Jo(B,F,1e4,j,he.x,he.y,he.width,he.height)))return;const D=m.hasIndex(H),fe=p.hasIndex(H);e.beginPath();const U=h==null?void 0:h(H),Z=U===void 0?w:ir(w,U);Z.bgCell!==w.bgCell&&(e.fillStyle=Z.bgCell,e.fillRect(B,F,1e4,j)),fe&&(e.fillStyle=Z.bgHeader,e.fillRect(B,F,1e4,j)),D&&(e.fillStyle=Z.accentLight,e.fillRect(B,F,1e4,j))}),e.restore())})}function hC(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?bo(t):0;let p;if(m!==0&&(p=nl(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:nl(d,l.bgCell),b=Gr(i,o,s);e.beginPath(),e.moveTo(0,r-b+.5),e.lineTo(n,r-b+.5),e.strokeStyle=g,e.stroke()}}const ou=(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 gC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g){var j;const b=g.bgCell,{minX:x,maxX:C,minY:w,maxY:M}=ou(s,i,a),G=[],B=a-Gr(p,m,u);let A=l,L=n,V=0;for(;A+o<B;){const _=A+o,D=u(L);if(_>=w&&_<=M-1){const fe=d==null?void 0:d(L),U=fe==null?void 0:fe.bgCell;U!==void 0&&U!==b&&L>=p-m&&G.push({x,y:_,w:C-x,h:D,color:U})}A+=D,L<p-m&&(V=A),L++}let k=0;const F=Math.min(B,M)-V;if(F>0)for(let _=0;_<t.length;_++){const D=t[_];if(D.width===0)continue;const fe=D.sticky?k:k+r,U=(j=D.themeOverride)==null?void 0:j.bgCell;U!==void 0&&U!==b&&fe>=x&&fe<=C&&h(_+1)&&G.push({x:fe,y:V,w:D.width,h:F,color:U}),k+=D.width}if(G.length===0)return;let H;e.beginPath();for(let _=G.length-1;_>=0;_--){const D=G[_];H===void 0?H=D.color:D.color!==H&&(e.fillStyle=H,e.fill(),e.beginPath(),H=D.color),e.rect(D.x,D.y,D.w,D.h)}H!==void 0&&(e.fillStyle=H,e.fill()),e.beginPath()}function Al(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C=!1){if(l!==void 0){e.beginPath(),e.save(),e.rect(0,0,i,a);for(const j of l)e.rect(j.x+1,j.y+1,j.width-1,j.height-1);e.clip("evenodd")}const w=x.horizontalBorderColor??x.borderColor,M=x.borderColor,{minX:G,maxX:B,minY:A,maxY:L}=ou(s,i,a),V=[];e.beginPath();let k=.5;for(let j=0;j<t.length;j++){const _=t[j];if(_.width===0)continue;k+=_.width;const D=_.sticky?k:k+r;D>=G&&D<=B&&p(j+1)&&V.push({x1:D,y1:Math.max(u,A),x2:D,y2:Math.min(a,L),color:M})}let F=a+.5;for(let j=b-g;j<b;j++){const _=h(j);F-=_,V.push({x1:G,y1:F,x2:B,y2:F,color:w})}if(C!==!0){let j=d+.5,_=n;const D=F;for(;j+o<D;){const fe=j+o;if(fe>=A&&fe<=L-1){const U=m==null?void 0:m(_);V.push({x1:G,y1:fe,x2:B,y2:fe,color:(U==null?void 0:U.horizontalBorderColor)??(U==null?void 0:U.borderColor)??w})}j+=h(_),_++}}const H=dC(V,j=>j.color);for(const j of Object.keys(H)){e.strokeStyle=j;for(const _ of H[j])e.moveTo(_.x1,_.y1),e.lineTo(_.x2,_.y2);e.stroke(),e.beginPath()}l!==void 0&&e.restore()}function mC(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b,x,C,w){const M=[];e.imageSmoothingEnabled=!1;const G=Math.min(o.cellYOffset,a),B=Math.max(o.cellYOffset,a);let A=0;if(typeof C=="number")A+=(B-G)*C;else for(let D=G;D<B;D++)A+=C(D);a>o.cellYOffset&&(A=-A),A+=l-o.translateY;const L=Math.min(o.cellXOffset,i),V=Math.max(o.cellXOffset,i);let k=0;for(let D=L;D<V;D++)k+=b[D].width;i>o.cellXOffset&&(k=-k),k+=s-o.translateX;const F=bo(x);if(k!==0&&A!==0)return{regions:[]};const H=u>0?Gr(m,u,C):0,j=d-F-Math.abs(k),_=h-p-H-Math.abs(A)-1;if(j>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-H,width:d,height:-A+H})),k>0?(D.sx=F*g,D.sw=j*g,D.dx=(k+F)*g,D.dw=j*g,M.push({x:F-1,y:0,width:k+2,height:h})):k<0&&(D.sx=(F-k)*g,D.sw=j*g,D.dx=F*g,D.dw=j*g,M.push({x:d+k,y:0,width:-k,height:h})),e.setTransform(1,0,0,1,0,0),w){if(F>0&&k!==0&&A===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const fe=F*g,U=h*g;e.drawImage(t,0,0,fe,U,0,0,fe,U)}if(H>0&&k===0&&A!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const fe=(h-H)*g,U=d*g,Z=H*g;e.drawImage(t,0,fe,U,Z,0,fe,U,Z)}}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 pC(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||Rr(l,n,r,o,s,(h,m,p,g)=>{if(h.sourceIndex===u){const b=Math.max(m,g)+1;return d.push({x:b,y:0,width:i-b,height:a}),!0}}),d}function bC(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(po(o,i))continue;if(n!==void 0||o.width===i.width)return!1;const{width:a,...s}=o,{width:l,...u}=i;if(!po(s,u))return!1;n=r}return n===void 0?!0:n}return!0}function Fl(e,t,n,r,o,i,a,s,l,u,d,h,m,p,g,b){const x=g==null?void 0:g.filter(L=>L.style!=="no-outline");if(x===void 0||x.length===0)return;const C=bo(s),w=Gr(p,m,h),M=[l,0,s.length,p-m],G=[C,0,t,n-w],B=x.map(L=>{const V=L.range,k=L.style??"dashed";return o0(V,M,t,n,G).map(F=>{const H=F.rect,j=$s(H.x,H.y,t,n,d,u+d,r,o,i,a,p,l,m,s,h),_=H.width===1&&H.height===1?j:$s(H.x+H.width-1,H.y+H.height-1,t,n,d,u+d,r,o,i,a,p,l,m,s,h);return H.x+H.width>=s.length&&(_.width-=1),H.y+H.height>=p&&(_.height-=1),{color:L.color,style:k,clip:F.clip,rect:r0({x:j.x,y:j.y,width:_.x+_.width-j.x,height:_.y+_.height-j.y},t,n,8)}})}),A=()=>{e.lineWidth=1;let L=!1;for(const V of B)for(const k of V)if((k==null?void 0:k.rect)!==void 0&&Jo(0,0,t,n,k.rect.x,k.rect.y,k.rect.width,k.rect.height)){const F=L,H=!n0(k.clip,k.rect);e.beginPath(),H&&(e.save(),e.rect(k.clip.x,k.clip.y,k.clip.width,k.clip.height),e.clip()),k.style==="dashed"&&!L?(e.setLineDash([5,3]),L=!0):(k.style==="solid"||k.style==="solid-outline")&&L&&(e.setLineDash([]),L=!1),e.strokeStyle=k.style==="solid-outline"?bn(bn(k.color,b.borderColor),b.bgCell):Lr(k.color,1),e.closePath(),e.strokeRect(k.rect.x+.5,k.rect.y+.5,k.rect.width-1,k.rect.height-1),H&&(e.restore(),L=F)}L&&e.setLineDash([])};return A(),A}function _l(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,b,x){if(d.current===void 0)return;const C=b!==!1&&b!==void 0;if(!C)return;const w=typeof b=="object"?{...Fi,...b}:Fi,M=d.current.range,G=d.current.cell,B=[M.x+M.width-1,M.y+M.height-1];if(G[1]>=x&&B[1]>=x||!a.some(U=>U.sourceIndex===G[0]||U.sourceIndex===B[0]))return;const[L,V]=d.current.cell,k=m(d.current.cell),F=k.span??[L,L],H=V>=x-p,j=p>0&&!H?Gr(x,p,h)-1:0,_=B[1];let D;if(Rr(a,r,o,i,u,(U,Z,he,de,ee)=>{if(U.sticky&&L>U.sourceIndex)return;const q=U.sourceIndex<F[0],Se=U.sourceIndex>F[1],se=U.sourceIndex===B[0];if(!(!se&&(q||Se)))return Yi(ee,he,n,x,h,p,g,void 0,(oe,Ee,J)=>{if(Ee!==V&&Ee!==_)return;let ae=Z,pe=U.width;if(k.span!==void 0){const Oe=zc(k.span,Z,oe,U.width,J,U,s),rt=U.sticky?Oe[0]:Oe[1];rt!==void 0&&(ae=rt.x,pe=rt.width)}return Ee===_&&se&&C&&(D=()=>{var Fe;de>ae&&!U.sticky&&(e.beginPath(),e.rect(de,0,t-de,n),e.clip());const Oe=w.size,rt=Oe/2,je=ae+pe+w.offsetX-rt+.5,Te=oe+J+w.offsetY-rt+.5;e.beginPath(),w.shape==="circle"?e.arc(je+rt,Te+rt,rt,0,Math.PI*2):e.rect(je,Te,Oe,Oe),e.fillStyle=((Fe=U.themeOverride)==null?void 0:Fe.accentColor)??l.accentColor,e.fill(),w.outline>0&&(e.lineWidth=w.outline,e.strokeStyle=l.bgCell,w.shape==="circle"?(e.beginPath(),e.arc(je+rt,Te+rt,rt+w.outline/2,0,Math.PI*2),e.stroke()):e.strokeRect(je-w.outline/2,Te-w.outline/2,Oe+w.outline,Oe+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-j),e.clip(),D==null||D(),e.restore()};return fe(),fe}function yC(e,t,n,r,o,i,a,s,l){l===void 0||l.size===0||(e.beginPath(),Lc(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)}),Rr(t,s,i,a,o,(u,d,h,m)=>{const p=Math.max(0,m-d),g=d+p+1,b=u.width-p-1;l.has([u.sourceIndex,-1])&&e.rect(g,r,b,o-r)}),e.clip())}function vC(e,t,n,r,o,i,a,s,l,u){let d=0;return Rr(e,i,r,o,n,(h,m,p,g,b)=>(Yi(b,p,t,a,s,l,u,void 0,(x,C,w,M)=>{M||(d=Math.max(C,d))}),!0)),d}function Pl(e,t){var dn;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:b,headerHeight:x,groupHeaderHeight:C,disabledRows:w,rowHeight:M,verticalBorder:G,overrideCursor:B,isResizing:A,selection:L,fillHandle:V,freezeTrailingRows:k,rows:F,getCellContent:H,getGroupDetails:j,getRowThemeOverride:_,isFocused:D,drawHeaderCallback:fe,prelightCells:U,drawCellCallback:Z,highlightRegions:he,resizeCol:de,imageLoader:ee,lastBlitData:q,hoverValues:Se,hyperWrapping:se,hoverInfo:oe,spriteManager:Ee,maxScaleFactor:J,hasAppendRow:ae,touchMode:pe,enqueue:Ge,renderStateProvider:Oe,getCellRenderer:rt,renderStrategy:je,bufferACtx:Te,bufferBCtx:Fe,damage:_e,minimumCellWidth:mt,resizeIndicator:xt}=e;if(o===0||i===0)return;const pt=je==="double-buffer",ie=Math.min(J,Math.ceil(window.devicePixelRatio??1)),be=je!=="direct"&&bC(e,t),Me=n.canvas;(Me.width!==o*ie||Me.height!==i*ie)&&(Me.width=o*ie,Me.height=i*ie,Me.style.width=o+"px",Me.style.height=i+"px");const De=r.canvas,ke=h?C+x:x,ot=ke+1;(De.width!==o*ie||De.height!==ot*ie)&&(De.width=o*ie,De.height=ot*ie,De.style.width=o+"px",De.style.height=ot+"px");const Le=Te.canvas,Ke=Fe.canvas;pt&&(Le.width!==o*ie||Le.height!==i*ie)&&(Le.width=o*ie,Le.height=i*ie,q.current!==void 0&&(q.current.aBufferScroll=void 0)),pt&&(Ke.width!==o*ie||Ke.height!==i*ie)&&(Ke.width=o*ie,Ke.height=i*ie,q.current!==void 0&&(q.current.bBufferScroll=void 0));const ue=q.current;if(be===!0&&a===(ue==null?void 0:ue.cellXOffset)&&s===(ue==null?void 0:ue.cellYOffset)&&l===(ue==null?void 0:ue.translateX)&&u===(ue==null?void 0:ue.translateY))return;let ye=null;pt&&(ye=n);const Ye=r;let Ve;pt?_e!==void 0?Ve=(ue==null?void 0:ue.lastBuffer)==="b"?Fe:Te:Ve=(ue==null?void 0:ue.lastBuffer)==="b"?Te:Fe:Ve=n;const it=Ve.canvas,xe=pt?it===Le?Ke:Le:Me,dt=typeof M=="number"?()=>M:M;Ye.save(),Ve.save(),Ye.beginPath(),Ve.beginPath(),Ye.textBaseline="middle",Ve.textBaseline="middle",ie!==1&&(Ye.scale(ie,ie),Ve.scale(ie,ie));const Ne=Ds(d,a,o,p,l);let He=[];const st=b&&((dn=L.current)==null?void 0:dn.cell[1])===s&&u===0;let Wt=!1;if(he!==void 0){for(const kt of he)if(kt.style!=="no-outline"&&kt.range.y===s&&u===0){Wt=!0;break}}const ct=()=>{a0(Ye,Ne,h,oe,o,l,x,C,p,A,L,g,Ee,Se,G,j,_e,fe,pe),Al(Ye,Ne,s,l,u,o,i,void 0,void 0,C,ke,dt,_,G,k,F,g,!0),Ye.beginPath(),Ye.moveTo(0,ot-.5),Ye.lineTo(o,ot-.5),Ye.strokeStyle=bn(g.headerBottomBorderColor??g.horizontalBorderColor??g.borderColor,g.bgHeader),Ye.stroke(),Wt&&Fl(Ye,o,i,a,s,l,u,d,m,x,C,M,k,F,he,g),st&&ws(Ye,o,i,s,l,u,Ne,d,g,ke,L,dt,H,k,ae,V,F)};if(_e!==void 0){const kt=Ne[Ne.length-1].sourceIndex+1,Ut=_e.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-k,width:kt,height:k,when:k>0}]),Je=It=>{ul(It,Ne,d,i,ke,l,u,s,F,dt,H,j,_,w,D,b,k,ae,He,_e,L,U,he,ee,Ee,Se,oe,Z,se,g,Ge,Oe,rt,B,mt);const $t=L.current;V!==!1&&V!==void 0&&b&&$t!==void 0&&_e.has(Sc($t.range))&&ws(It,o,i,s,l,u,Ne,d,g,ke,L,dt,H,k,ae,V,F)};Ut&&(Je(Ve),ye!==null&&(ye.save(),ye.scale(ie,ie),ye.textBaseline="middle",Je(ye),ye.restore()),_e.hasHeader()&&(yC(Ye,Ne,o,C,ke,l,u,s,_e),ct())),Ve.restore(),Ye.restore();return}if((be!==!0||a!==(ue==null?void 0:ue.cellXOffset)||l!==(ue==null?void 0:ue.translateX)||st!==(ue==null?void 0:ue.mustDrawFocusOnHeader)||Wt!==(ue==null?void 0:ue.mustDrawHighlightRingsOnHeader))&&ct(),be===!0){pn(xe!==void 0&&ue!==void 0);const{regions:kt}=mC(Ve,xe,xe===Le?ue.aBufferScroll:ue.bBufferScroll,xe===Le?ue.bBufferScroll:ue.aBufferScroll,ue,a,s,l,u,k,o,i,F,ke,ie,d,Ne,M,pt);He=kt}else be!==!1&&(pn(ue!==void 0),He=pC(ue,a,s,l,u,o,i,ke,Ne,be));hC(Ve,Ne,o,i,k,F,G,dt,g);const $e=Fl(Ve,o,i,a,s,l,u,d,m,x,C,M,k,F,he,g),bt=b?ws(Ve,o,i,s,l,u,Ne,d,g,ke,L,dt,H,k,ae,V,F):void 0;if(Ve.fillStyle=g.bgCell,He.length>0){Ve.beginPath();for(const kt of He)Ve.rect(kt.x,kt.y,kt.width,kt.height);Ve.clip(),Ve.fill(),Ve.beginPath()}else Ve.fillRect(0,0,o,i);const Ht=ul(Ve,Ne,d,i,ke,l,u,s,F,dt,H,j,_,w,D,b,k,ae,He,_e,L,U,he,ee,Ee,Se,oe,Z,se,g,Ge,Oe,rt,B,mt);fC(Ve,Ne,d,o,i,ke,l,u,s,F,dt,_,L.rows,w,k,ae,He,_e,g),gC(Ve,Ne,s,l,u,o,i,He,ke,dt,_,G,k,F,g),Al(Ve,Ne,s,l,u,o,i,He,Ht,C,ke,dt,_,G,k,F,g),$e==null||$e(),bt==null||bt(),A&&xt!=="none"&&Rr(Ne,0,l,0,ke,(kt,Ut)=>kt.sourceIndex===de?(_l(Ye,Ut+kt.width,0,ke+1,bn(g.resizeIndicatorColor??g.accentLight,g.bgHeader)),xt==="full"&&_l(Ve,Ut+kt.width,ke,i,bn(g.resizeIndicatorColor??g.accentLight,g.bgCell)),!0):!1),ye!==null&&(ye.fillStyle=g.bgCell,ye.fillRect(0,0,o,i),ye.drawImage(Ve.canvas,0,0));const Yt=vC(Ne,i,ke,l,u,s,F,dt,k,ae);ee==null||ee.setWindow({x:a,y:s,width:Ne.length,height:Yt-s},m,Array.from({length:k},(kt,Ut)=>F-1-Ut));const vt=ue!==void 0&&(a!==ue.cellXOffset||l!==ue.translateX),yn=ue!==void 0&&(s!==ue.cellYOffset||u!==ue.translateY);q.current={cellXOffset:a,cellYOffset:s,translateX:l,translateY:u,mustDrawFocusOnHeader:st,mustDrawHighlightRingsOnHeader:Wt,lastBuffer:pt?it===Le?"a":"b":void 0,aBufferScroll:it===Le?[vt,yn]:ue==null?void 0:ue.aBufferScroll,bBufferScroll:it===Ke?[vt,yn]:ue==null?void 0:ue.bBufferScroll},Ve.restore(),Ye.restore()}const wC=80;function xC(e){const t=e-1;return t*t*t+1}class CC{constructor(t){Xe(this,"callback");Xe(this,"currentHoveredItem");Xe(this,"leavingItems",[]);Xe(this,"lastAnimationTime");Xe(this,"addToLeavingItems",t=>{this.leavingItems.some(r=>Xo(r.item,t.item))||this.leavingItems.push(t)});Xe(this,"removeFromLeavingItems",t=>{const n=this.leavingItems.find(r=>Xo(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:xC(t.hoverAmount)})));Xe(this,"step",t=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=t;else{const r=(t-this.lastAnimationTime)/wC;for(const i of this.leavingItems)i.hoverAmount=En(i.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=En(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(!Xo((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 kC{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 kC(e)}const SC=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 RC(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($c);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=or(i[0],i[1]);t.current.includes(a)||t.current.push(a)},[o])}const Cr="header",Ln="group-header",Hi="out-of-bounds";var fo;(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"})(fo||(fo={}));function iu(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 MC=(e,t)=>{if(e.kind===ce.Custom)return e.copyData;const n=t==null?void 0:t(e);return(n==null?void 0:n.getAccessibilityString(e))??""},IC=(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:b,onHeaderIndicatorClick:x,enableGroups:C,isFilling:w,onCanvasFocused:M,onCanvasBlur:G,isFocused:B,selection:A,freezeColumns:L,onContextMenu:V,freezeTrailingRows:k,fixedShadowX:F=!0,fixedShadowY:H=!0,drawFocusRing:j,onMouseDown:_,onMouseUp:D,onMouseMoveRaw:fe,onMouseMove:U,onItemHovered:Z,dragAndDropState:he,firstColAccessible:de,onKeyDown:ee,onKeyUp:q,highlightRegions:Se,canvasRef:se,onDragStart:oe,onDragEnd:Ee,eventTargetRef:J,isResizing:ae,resizeColumn:pe,isDragging:Ge,isDraggable:Oe=!1,allowResize:rt,disabledRows:je,hasAppendRow:Te,getGroupDetails:Fe,theme:_e,prelightCells:mt,headerIcons:xt,verticalBorder:pt,drawCell:ie,drawHeader:be,onCellFocused:Me,onDragOverCell:De,onDrop:ke,onDragLeave:ot,imageWindowLoader:Le,smoothScrollX:Ke=!1,smoothScrollY:ue=!1,experimental:ye,getCellRenderer:Ye,resizeIndicator:Ve="full"}=e,it=e.translateX??0,xe=e.translateY??0,dt=Math.max(L,Math.min(i.length-1,a)),Ne=c.useRef(null),He=c.useRef((ye==null?void 0:ye.eventTarget)??window),st=He.current,Wt=Le,ct=c.useRef(),[$e,bt]=c.useState(!1),Ht=c.useRef([]),Yt=c.useRef(),[vt,yn]=c.useState(),[dn,kt]=c.useState(),Ut=c.useRef(null),[Je,It]=c.useState(),[$t,tt]=c.useState(!1),Rt=c.useRef($t);Rt.current=$t;const gt=c.useMemo(()=>new e0(xt,()=>{rn.current=void 0,Gn.current()}),[xt]),qt=C?d+l:l,Nt=c.useRef(-1),Ot=((ye==null?void 0:ye.enableFirefoxRescaling)??!1)&&SC.value,Gt=((ye==null?void 0:ye.enableSafariRescaling)??!1)&&ji.value;c.useLayoutEffect(()=>{window.devicePixelRatio===1||!Ot&&!Gt||(Nt.current!==-1&&bt(!0),window.clearTimeout(Nt.current),Nt.current=window.setTimeout(()=>{bt(!1),Nt.current=-1},200))},[s,dt,it,xe,Ot,Gt]);const Be=Vp(i,L),$n=c.useMemo(()=>F?bo(Be,he):0,[Be,he,F]),At=c.useCallback((I,Y,ge)=>{const me=I.getBoundingClientRect();if(Y>=Be.length||ge>=m)return;const y=me.width/n,T=$s(Y,ge,n,r,d,qt,dt,s,it,xe,m,L,k,Be,h);return y!==1&&(T.x*=y,T.y*=y,T.width*=y,T.height*=y),T.x+=me.x,T.y+=me.y,T},[n,r,d,qt,dt,s,it,xe,m,L,k,Be,h]),nt=c.useCallback((I,Y,ge,me)=>{const y=I.getBoundingClientRect(),T=y.width/n,z=(Y-y.left)/T,ne=(ge-y.top)/T,te=5,ft=Ds(Be,dt,n,void 0,it);let Ce=0,at=0;const Ue=typeof PointerEvent<"u"&&me instanceof PointerEvent&&me.pointerType==="mouse"||typeof MouseEvent<"u"&&me instanceof MouseEvent,qe=typeof PointerEvent<"u"&&me instanceof PointerEvent&&me.pointerType==="touch"||typeof TouchEvent<"u"&&me instanceof TouchEvent;Ue&&(Ce=me.button,at=me.buttons);const ze=eb(z,ft,it),ut=tb(ne,r,C,l,d,m,h,s,xe,k),_t=(me==null?void 0:me.shiftKey)===!0,On=(me==null?void 0:me.ctrlKey)===!0,jn=(me==null?void 0:me.metaKey)===!0,Mt=[z<0?-1:n<z?1:0,ne<qt?-1:r<ne?1:0];let jt;if(ze===-1||ne<0||z<0||ut===void 0||z>n||ne>r){const wt=z>n?1:z<0?-1:0,Rn=ne>r?1:ne<0?-1:0;let tn=wt*2,Qr=Rn*2;wt===0&&(tn=ze===-1?fo.EndPadding:fo.Center),Rn===0&&(Qr=ut===void 0?fo.EndPadding:fo.Center);let nr=!1;if(ze===-1&&ut===-1){const Bt=At(I,Be.length-1,-1);pn(Bt!==void 0),nr=Y<Bt.x+Bt.width+te}const Qe=z>n&&z<n+Is()||ne>r&&ne<r+Is();jt={kind:Hi,location:[ze!==-1?ze:z<0?0:Be.length-1,ut??m-1],region:[tn,Qr],shiftKey:_t,ctrlKey:On,metaKey:jn,isEdge:nr,isTouch:qe,button:Ce,buttons:at,scrollEdge:Mt,isMaybeScrollbar:Qe}}else if(ut<=-1){let wt=At(I,ze,ut);pn(wt!==void 0);let Rn=wt!==void 0&&wt.x+wt.width-Y<=te;const tn=ze-1;Y-wt.x<=te&&tn>=0?(Rn=!0,wt=At(I,tn,ut),pn(wt!==void 0),jt={kind:C&&ut===-2?Ln:Cr,location:[tn,ut],bounds:wt,group:Be[tn].group??"",isEdge:Rn,shiftKey:_t,ctrlKey:On,metaKey:jn,isTouch:qe,localEventX:Y-wt.x,localEventY:ge-wt.y,button:Ce,buttons:at,scrollEdge:Mt}):jt={kind:C&&ut===-2?Ln:Cr,group:Be[ze].group??"",location:[ze,ut],bounds:wt,isEdge:Rn,shiftKey:_t,ctrlKey:On,metaKey:jn,isTouch:qe,localEventX:Y-wt.x,localEventY:ge-wt.y,button:Ce,buttons:at,scrollEdge:Mt}}else{const wt=At(I,ze,ut);pn(wt!==void 0);const Rn=wt!==void 0&&wt.x+wt.width-Y<te;let tn=!1;if(u!==!1&&u!==void 0&&A.current!==void 0){const nr=typeof u=="object"?{...Fi,...u}:Fi,Qe=nr.size,Bt=Qe/2,Ar=Sc(A.current.range),mr=At(I,Ar[0],Ar[1]);if(mr!==void 0){const rr=mr.x+mr.width+nr.offsetX-Bt+.5,St=mr.y+mr.height+nr.offsetY-Bt+.5;tn=Math.abs(rr-Y)<Qe&&Math.abs(St-ge)<Qe}}jt={kind:"cell",location:[ze,ut],bounds:wt,isEdge:Rn,shiftKey:_t,ctrlKey:On,isFillHandle:tn,metaKey:jn,isTouch:qe,localEventX:Y-wt.x,localEventY:ge-wt.y,button:Ce,buttons:at,scrollEdge:Mt}}return jt},[n,Be,dt,it,r,C,l,d,m,h,s,xe,k,At,u,A,qt]),[Xt]=vt??[],Et=c.useRef(()=>{}),Jt=c.useRef(vt);Jt.current=vt;const[ln,Ft]=c.useMemo(()=>{const I=document.createElement("canvas"),Y=document.createElement("canvas");return I.style.display="none",I.style.opacity="0",I.style.position="fixed",Y.style.display="none",Y.style.opacity="0",Y.style.position="fixed",[I.getContext("2d",{alpha:!1}),Y.getContext("2d",{alpha:!1})]},[]);c.useLayoutEffect(()=>{if(!(ln===null||Ft===null))return document.documentElement.append(ln.canvas),document.documentElement.append(Ft.canvas),()=>{ln.canvas.remove(),Ft.canvas.remove()}},[ln,Ft]);const Zn=c.useMemo(()=>new hb,[]),Ir=Ot&&$e?1:Gt&&$e?2:5,vn=(ye==null?void 0:ye.disableMinimumCellWidth)===!0?1:10,rn=c.useRef(),wn=c.useRef(null),zn=c.useRef(null),Wn=c.useCallback(()=>{var z;const I=Ne.current,Y=Ut.current;if(I===null||Y===null||(wn.current===null&&(wn.current=I.getContext("2d",{alpha:!1}),I.width=0,I.height=0),zn.current===null&&(zn.current=Y.getContext("2d",{alpha:!1}),Y.width=0,Y.height=0),wn.current===null||zn.current===null||ln===null||Ft===null))return;let ge=!1;const me=ne=>{ge=!0,It(ne)},y=rn.current,T={headerCanvasCtx:zn.current,canvasCtx:wn.current,bufferACtx:ln,bufferBCtx:Ft,width:n,height:r,cellXOffset:dt,cellYOffset:s,translateX:Math.round(it),translateY:Math.round(xe),mappedColumns:Be,enableGroups:C,freezeColumns:L,dragAndDropState:he,theme:_e,headerHeight:l,groupHeaderHeight:d,disabledRows:je??lt.empty(),rowHeight:h,verticalBorder:pt,isResizing:ae,resizeCol:pe,isFocused:B,selection:A,fillHandle:u,drawCellCallback:ie,hasAppendRow:Te,overrideCursor:me,maxScaleFactor:Ir,freezeTrailingRows:k,rows:m,drawFocus:j,getCellContent:p,getGroupDetails:Fe??(ne=>({name:ne})),getRowThemeOverride:g,drawHeaderCallback:be,prelightCells:mt,highlightRegions:Se,imageLoader:Wt,lastBlitData:Yt,damage:ct.current,hoverValues:Ht.current,hoverInfo:Jt.current,spriteManager:gt,scrolling:$e,hyperWrapping:(ye==null?void 0:ye.hyperWrapping)??!1,touchMode:$t,enqueue:Et.current,renderStateProvider:Zn,renderStrategy:(ye==null?void 0:ye.renderStrategy)??(ji.value?"double-buffer":"single-buffer"),getCellRenderer:Ye,minimumCellWidth:vn,resizeIndicator:Ve};T.damage===void 0?(rn.current=T,Pl(T,y)):Pl(T,void 0),!ge&&(T.damage===void 0||T.damage.has((z=Jt==null?void 0:Jt.current)==null?void 0:z[0]))&&It(void 0)},[ln,Ft,n,r,dt,s,it,xe,Be,C,L,he,_e,l,d,je,h,pt,ae,Te,pe,B,A,u,k,m,j,Ir,p,Fe,g,ie,be,mt,Se,Wt,gt,$e,ye==null?void 0:ye.hyperWrapping,ye==null?void 0:ye.renderStrategy,$t,Zn,Ye,vn,Ve]),Gn=c.useRef(Wn);c.useLayoutEffect(()=>{Wn(),Gn.current=Wn},[Wn]),c.useLayoutEffect(()=>{(async()=>{var Y;((Y=document==null?void 0:document.fonts)==null?void 0:Y.ready)!==void 0&&(await document.fonts.ready,rn.current=void 0,Gn.current())})()},[]);const An=c.useCallback(I=>{ct.current=I,Gn.current(),ct.current=void 0},[]),Ro=RC(An);Et.current=Ro;const Ur=c.useCallback(I=>{An(new Ei(I.map(Y=>Y.cell)))},[An]);Wt.setCallback(An);const[Mo,er]=c.useState(!1),[fn,xn]=Xt??[],Io=fn!==void 0&&xn===-1&&fn>=0&&fn<Be.length&&Be[fn].headerRowMarkerDisabled!==!0,Xr=fn!==void 0&&xn===-2;let sr=!1,Kr=!1,Cn=Je;if(Cn===void 0&&fn!==void 0&&xn!==void 0&&xn>-1&&xn<m){const I=p([fn,xn],!0);sr=I.kind===Tn.NewRow||I.kind===Tn.Marker&&I.markerKind!=="number",Kr=I.kind===ce.Boolean&&Qs(I),Cn=I.cursor}const Yr=Ge?"grabbing":(dn??!1)||ae?"col-resize":Mo||w?"crosshair":Cn!==void 0?Cn:Io||sr||Kr||Xr?"pointer":"default",lr=c.useMemo(()=>({contain:"strict",display:"block",cursor:Yr}),[Yr]),yt=c.useRef("default"),Vt=J==null?void 0:J.current;Vt!=null&&yt.current!==lr.cursor&&(Vt.style.cursor=yt.current=lr.cursor);const cr=c.useCallback((I,Y,ge,me)=>{if(Fe===void 0)return;const y=Fe(I);if(y.actions!==void 0){const T=Uc(Y,y.actions);for(const[z,ne]of T.entries())if(go(ne,ge+Y.x,me+ne.y))return y.actions[z]}},[Fe]),Fn=c.useCallback((I,Y,ge,me)=>{const y=Be[Y];if(!Ge&&!ae&&!(dn??!1)){const T=At(I,Y,-1);pn(T!==void 0);const z=Xc(void 0,y,T.x,T.y,T.width,T.height,_e,ea(y.title)==="rtl");if(y.hasMenu===!0&&z.menuBounds!==void 0&&go(z.menuBounds,ge,me))return{area:"menu",bounds:z.menuBounds};if(y.indicatorIcon!==void 0&&z.indicatorIconBounds!==void 0&&go(z.indicatorIconBounds,ge,me))return{area:"indicator",bounds:z.indicatorIconBounds}}},[Be,At,dn,Ge,ae,_e]),ur=c.useRef(0),Un=c.useRef(),dr=c.useRef(!1),fr=c.useCallback(I=>{const Y=Ne.current,ge=J==null?void 0:J.current;if(Y===null||I.target!==Y&&I.target!==ge)return;dr.current=!0;const me=I.clientX,y=I.clientY;if(I.target===ge&&ge!==null){const z=ge.getBoundingClientRect();if(me>z.right||y>z.bottom)return}const T=nt(Y,me,y,I);Un.current=T.location,T.isTouch&&(ur.current=Date.now()),Rt.current!==T.isTouch&&tt(T.isTouch),!(T.kind===Cr&&Fn(Y,T.location[0],me,y)!==void 0)&&(T.kind===Ln&&cr(T.group,T.bounds,T.localEventX,T.localEventY)!==void 0||(_==null||_(T),!T.isTouch&&Oe!==!0&&Oe!==T.kind&&T.button<3&&T.button!==1&&I.preventDefault()))},[J,Oe,nt,cr,Fn,_]);an("pointerdown",fr,st,!1);const on=c.useRef(0),hn=c.useCallback(I=>{var at,Ue;const Y=on.current;on.current=Date.now();const ge=Ne.current;if(dr.current=!1,D===void 0||ge===null)return;const me=J==null?void 0:J.current,y=I.target!==ge&&I.target!==me,T=I.clientX,z=I.clientY,ne=I.pointerType==="mouse"?I.button<3:!0;let te=nt(ge,T,z,I);te.isTouch&&ur.current!==0&&Date.now()-ur.current>500&&(te={...te,isLongTouch:!0}),Y!==0&&Date.now()-Y<(te.isTouch?1e3:500)&&(te={...te,isDoubleClick:!0}),Rt.current!==te.isTouch&&tt(te.isTouch),!y&&I.cancelable&&ne&&I.preventDefault();const[ft]=te.location,Ce=Fn(ge,ft,T,z);if(te.kind===Cr&&Ce!==void 0){(te.button!==0||((at=Un.current)==null?void 0:at[0])!==ft||((Ue=Un.current)==null?void 0:Ue[1])!==-1)&&D(te,!0);return}else if(te.kind===Ln){const qe=cr(te.group,te.bounds,te.localEventX,te.localEventY);if(qe!==void 0){te.button===0&&qe.onClick(te);return}}D(te,y)},[D,J,nt,Fn,cr]);an("pointerup",hn,st,!1);const Qt=c.useCallback(I=>{var ft,Ce;const Y=Ne.current;if(Y===null)return;const ge=J==null?void 0:J.current,me=I.target!==Y&&I.target!==ge;let y,T,z=!0;I instanceof MouseEvent?(y=I.clientX,T=I.clientY,z=I.button<3):(y=I.changedTouches[0].clientX,T=I.changedTouches[0].clientY);const ne=nt(Y,y,T,I);Rt.current!==ne.isTouch&&tt(ne.isTouch),!me&&I.cancelable&&z&&I.preventDefault();const[te]=ne.location;if(ne.kind===Cr){const at=Fn(Y,te,y,T);at!==void 0&&ne.button===0&&((ft=Un.current)==null?void 0:ft[0])===te&&((Ce=Un.current)==null?void 0:Ce[1])===-1&&(at.area==="menu"?b==null||b(te,at.bounds):at.area==="indicator"&&(x==null||x(te,at.bounds)))}},[J,nt,Fn,b,x]);an("click",Qt,st,!1);const Eo=c.useCallback(I=>{const Y=Ne.current,ge=J==null?void 0:J.current;if(Y===null||I.target!==Y&&I.target!==ge||V===void 0)return;const me=nt(Y,I.clientX,I.clientY,I);V(me,()=>{I.cancelable&&I.preventDefault()})},[J,nt,V]);an("contextmenu",Eo,(J==null?void 0:J.current)??null,!1);const Er=c.useCallback(I=>{ct.current=new Ei(I.map(Y=>Y.item)),Ht.current=I,Gn.current(),ct.current=void 0},[]),Re=c.useMemo(()=>new CC(Er),[Er]),hr=c.useRef(Re);hr.current=Re,c.useLayoutEffect(()=>{const I=hr.current;if(Xt===void 0||Xt[1]<0){I.setHovered(Xt);return}const Y=p(Xt,!0),ge=Ye(Y),me=ge===void 0&&Y.kind===ce.Custom||(ge==null?void 0:ge.needsHover)!==void 0&&(typeof ge.needsHover=="boolean"?ge.needsHover:ge.needsHover(Y));I.setHovered(me?Xt:void 0)},[p,Ye,Xt]);const _n=c.useRef(),Zt=c.useCallback(I=>{var ne;const Y=Ne.current;if(Y===null)return;const ge=J==null?void 0:J.current,me=I.target!==Y&&I.target!==ge,y=nt(Y,I.clientX,I.clientY,I);if(y.kind!=="out-of-bounds"&&me&&!dr.current&&!y.isTouch)return;const T=(te,ft)=>{yn(Ce=>Ce===te||(Ce==null?void 0:Ce[0][0])===(te==null?void 0:te[0][0])&&(Ce==null?void 0:Ce[0][1])===(te==null?void 0:te[0][1])&&((Ce==null?void 0:Ce[1][0])===(te==null?void 0:te[1][0])&&(Ce==null?void 0:Ce[1][1])===(te==null?void 0:te[1][1])||!ft)?Ce:te)};if(!iu(y,_n.current))It(void 0),Z==null||Z(y),T(y.kind===Hi?void 0:[y.location,[y.localEventX,y.localEventY]],!0),_n.current=y;else if(y.kind==="cell"||y.kind===Cr||y.kind===Ln){let te=!1,ft=!0;if(y.kind==="cell"){const at=p(y.location);ft=((ne=Ye(at))==null?void 0:ne.needsHoverPosition)??at.kind===ce.Custom,te=ft}else te=!0;const Ce=[y.location,[y.localEventX,y.localEventY]];T(Ce,ft),Jt.current=Ce,te&&An(new Ei([y.location]))}const z=y.location[0]>=(de?0:1);kt(y.kind===Cr&&y.isEdge&&z&&rt===!0),er(y.kind==="cell"&&y.isFillHandle),fe==null||fe(I),U(y)},[J,nt,de,rt,fe,U,Z,p,Ye,An]);an("pointermove",Zt,st,!0);const Tr=c.useCallback(I=>{const Y=Ne.current;if(Y===null)return;let ge,me;A.current!==void 0&&(ge=At(Y,A.current.cell[0],A.current.cell[1]),me=A.current.cell),ee==null||ee({bounds:ge,stopPropagation:()=>I.stopPropagation(),preventDefault:()=>I.preventDefault(),cancel:()=>{},ctrlKey:I.ctrlKey,metaKey:I.metaKey,shiftKey:I.shiftKey,altKey:I.altKey,key:I.key,keyCode:I.keyCode,rawEvent:I,location:me})},[ee,A,At]),kn=c.useCallback(I=>{const Y=Ne.current;if(Y===null)return;let ge,me;A.current!==void 0&&(ge=At(Y,A.current.cell[0],A.current.cell[1]),me=A.current.cell),q==null||q({bounds:ge,stopPropagation:()=>I.stopPropagation(),preventDefault:()=>I.preventDefault(),cancel:()=>{},ctrlKey:I.ctrlKey,metaKey:I.metaKey,shiftKey:I.shiftKey,altKey:I.altKey,key:I.key,keyCode:I.keyCode,rawEvent:I,location:me})},[q,A,At]),Dr=c.useCallback(I=>{if(Ne.current=I,se!==void 0&&(se.current=I),ye!=null&&ye.eventTarget)He.current=ye.eventTarget;else if(I===null)He.current=window;else{const Y=I.getRootNode();Y===document&&(He.current=window),He.current=Y}},[se,ye==null?void 0:ye.eventTarget]),$r=c.useCallback(I=>{const Y=Ne.current;if(Y===null||Oe===!1||ae){I.preventDefault();return}let ge,me;const y=nt(Y,I.clientX,I.clientY);if(Oe!==!0&&y.kind!==Oe){I.preventDefault();return}const T=(at,Ue)=>{ge=at,me=Ue};let z,ne,te;const ft=(at,Ue,qe)=>{z=at,ne=Ue,te=qe};let Ce=!1;if(oe==null||oe({...y,setData:T,setDragImage:ft,preventDefault:()=>Ce=!0,defaultPrevented:()=>Ce}),!Ce&&ge!==void 0&&me!==void 0&&I.dataTransfer!==null)if(I.dataTransfer.setData(ge,me),I.dataTransfer.effectAllowed="copyLink",z!==void 0&&ne!==void 0&&te!==void 0)I.dataTransfer.setDragImage(z,ne,te);else{const[at,Ue]=y.location;if(Ue!==void 0){const qe=document.createElement("canvas"),ze=At(Y,at,Ue);pn(ze!==void 0);const ut=Math.ceil(window.devicePixelRatio??1);qe.width=ze.width*ut,qe.height=ze.height*ut;const _t=qe.getContext("2d");_t!==null&&(_t.scale(ut,ut),_t.textBaseline="middle",Ue===-1?(_t.font=_e.headerFontFull,_t.fillStyle=_e.bgHeader,_t.fillRect(0,0,qe.width,qe.height),Kc(_t,0,0,ze.width,ze.height,Be[at],!1,_e,!1,void 0,void 0,!1,0,gt,be,!1)):(_t.font=_e.baseFontFull,_t.fillStyle=_e.bgCell,_t.fillRect(0,0,qe.width,qe.height),Gc(_t,p([at,Ue]),0,Ue,!1,!1,0,0,ze.width,ze.height,!1,_e,_e.bgCell,Wt,gt,1,void 0,!1,0,void 0,void 0,void 0,Zn,Ye,()=>{}))),qe.style.left="-100%",qe.style.position="absolute",qe.style.width=`${ze.width}px`,qe.style.height=`${ze.height}px`,document.body.append(qe),I.dataTransfer.setDragImage(qe,ze.width/2,ze.height/2),window.setTimeout(()=>{qe.remove()},0)}}else I.preventDefault()},[Oe,ae,nt,oe,At,_e,Be,gt,be,p,Wt,Zn,Ye]);an("dragstart",$r,(J==null?void 0:J.current)??null,!1,!1);const tr=c.useRef(),qr=c.useCallback(I=>{const Y=Ne.current;if(ke!==void 0&&I.preventDefault(),Y===null||De===void 0)return;const ge=nt(Y,I.clientX,I.clientY),[me,y]=ge.location,T=me-(de?0:1),[z,ne]=tr.current??[];(z!==T||ne!==y)&&(tr.current=[T,y],De([T,y],I.dataTransfer))},[de,nt,De,ke]);an("dragover",qr,(J==null?void 0:J.current)??null,!1,!1);const Vr=c.useCallback(()=>{tr.current=void 0,Ee==null||Ee()},[Ee]);an("dragend",Vr,(J==null?void 0:J.current)??null,!1,!1);const gn=c.useCallback(I=>{const Y=Ne.current;if(Y===null||ke===void 0)return;I.preventDefault();const ge=nt(Y,I.clientX,I.clientY),[me,y]=ge.location,T=me-(de?0:1);ke([T,y],I.dataTransfer)},[de,nt,ke]);an("drop",gn,(J==null?void 0:J.current)??null,!1,!1);const Xn=c.useCallback(()=>{ot==null||ot()},[ot]);an("dragleave",Xn,(J==null?void 0:J.current)??null,!1,!1);const en=c.useRef(A);en.current=A;const $=c.useRef(null),Ct=c.useCallback(I=>{var Y;Ne.current===null||!Ne.current.contains(document.activeElement)||(I===null&&en.current.current!==void 0?(Y=se==null?void 0:se.current)==null||Y.focus({preventScroll:!0}):I!==null&&I.focus({preventScroll:!0}),$.current=I)},[se]);c.useImperativeHandle(t,()=>({focus:()=>{var Y;const I=$.current;I===null||!document.contains(I)?(Y=se==null?void 0:se.current)==null||Y.focus({preventScroll:!0}):I.focus({preventScroll:!0})},getBounds:(I,Y)=>{if(!(se===void 0||se.current===null))return At(se.current,I??0,Y??-1)},damage:Ur,getMouseArgsForPosition:(I,Y,ge)=>{if(!(se===void 0||se.current===null))return nt(se.current,I,Y,ge)}}),[se,Ur,At,nt]);const Sn=c.useRef(),Jr=Fp(()=>{var ne,te,ft;if(n<50||(ye==null?void 0:ye.disableAccessibilityTree)===!0)return null;let I=Ds(Be,dt,n,he,it);const Y=de?0:-1;!de&&((ne=I[0])==null?void 0:ne.sourceIndex)===0&&(I=I.slice(1));const[ge,me]=((te=A.current)==null?void 0:te.cell)??[],y=(ft=A.current)==null?void 0:ft.range,T=I.map(Ce=>Ce.sourceIndex),z=Br(s,Math.min(m,s+o));return ge!==void 0&&me!==void 0&&!(T.includes(ge)&&z.includes(me))&&Ct(null),c.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":m+1,"aria-multiselectable":"true","aria-colcount":Be.length+Y},c.createElement("thead",{role:"rowgroup"},c.createElement("tr",{role:"row","aria-rowindex":1},I.map(Ce=>c.createElement("th",{role:"columnheader","aria-selected":A.columns.hasIndex(Ce.sourceIndex),"aria-colindex":Ce.sourceIndex+1+Y,tabIndex:-1,onFocus:at=>{if(at.target!==$.current)return Me==null?void 0:Me([Ce.sourceIndex,-1])},key:Ce.sourceIndex},Ce.title)))),c.createElement("tbody",{role:"rowgroup"},z.map(Ce=>c.createElement("tr",{role:"row","aria-selected":A.rows.hasIndex(Ce),key:Ce,"aria-rowindex":Ce+2},I.map(at=>{const Ue=at.sourceIndex,qe=or(Ue,Ce),ze=ge===Ue&&me===Ce,ut=y!==void 0&&Ue>=y.x&&Ue<y.x+y.width&&Ce>=y.y&&Ce<y.y+y.height,_t=`glide-cell-${Ue}-${Ce}`,On=[Ue,Ce],jn=p(On,!0);return c.createElement("td",{key:qe,role:"gridcell","aria-colindex":Ue+1+Y,"aria-selected":ut,"aria-readonly":co(jn)||!ao(jn),id:_t,"data-testid":_t,onClick:()=>{const Mt=se==null?void 0:se.current;if(Mt!=null)return ee==null?void 0:ee({bounds:At(Mt,Ue,Ce),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:On})},onFocusCapture:Mt=>{var jt,wt;if(!(Mt.target===$.current||((jt=Sn.current)==null?void 0:jt[0])===Ue&&((wt=Sn.current)==null?void 0:wt[1])===Ce))return Sn.current=On,Me==null?void 0:Me(On)},ref:ze?Ct:void 0,tabIndex:-1},MC(jn,Ye))})))))},[n,Be,dt,he,it,m,s,o,A,Ct,p,se,ee,At,Me],200),Pn=L===0||!F?0:dt>L?1:En(-it/100,0,1),To=-s*32+xe,gr=H?En(-To/100,0,1):0,ri=c.useMemo(()=>{if(!Pn&&!gr)return null;const I={position:"absolute",top:0,left:$n,width:n-$n,height:r,opacity:Pn,pointerEvents:"none",transition:Ke?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},Y={position:"absolute",top:qt,left:0,width:n,height:r,opacity:gr,pointerEvents:"none",transition:ue?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return c.createElement(c.Fragment,null,Pn>0&&c.createElement("div",{id:"shadow-x",style:I}),gr>0&&c.createElement("div",{id:"shadow-y",style:Y}))},[Pn,gr,$n,n,Ke,qt,r,ue]),W=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:Tr,onKeyUp:kn,onFocus:M,onBlur:G,ref:Dr,style:lr},Jr),c.createElement("canvas",{ref:Ut,style:W}),ri)},EC=c.memo(c.forwardRef(IC));function Bo(e,t,n,r){return En(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}const TC=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(),[b,x]=c.useState(),[C,w]=c.useState(!1),[M,G]=c.useState(),{onHeaderMenuClick:B,onHeaderIndicatorClick:A,getCellContent:L,onColumnMoved:V,onColumnResize:k,onColumnResizeStart:F,onColumnResizeEnd:H,gridRef:j,maxColumnWidth:_,minColumnWidth:D,onRowMoved:fe,lockColumns:U,onColumnProposeMove:Z,onMouseDown:he,onMouseUp:de,onItemHovered:ee,onDragStart:q,canvasRef:Se}=e,se=(k??H??F)!==void 0,{columns:oe,selection:Ee}=e,J=Ee.columns,ae=c.useCallback(ie=>{const[be,Me]=ie.location;i!==void 0&&s!==be&&be>=U?(d(!0),l(be)):p!==void 0&&Me!==void 0?(w(!0),x(Math.max(0,Me))):r===void 0&&!u&&!C&&(ee==null||ee(ie))},[i,p,s,ee,U,r,u,C]),pe=V!==void 0,Ge=c.useCallback(ie=>{var be;if(ie.button===0){const[Me,De]=ie.location;if(ie.kind==="out-of-bounds"&&ie.isEdge&&se){const ke=(be=j==null?void 0:j.current)==null?void 0:be.getBounds(oe.length-1,-1);ke!==void 0&&(n(ke.x),o(oe.length-1))}else if(ie.kind==="header"&&Me>=U){const ke=Se==null?void 0:Se.current;if(ie.isEdge&&se&&ke){n(ie.bounds.x),o(Me);const Le=ke.getBoundingClientRect().width/ke.offsetWidth,Ke=ie.bounds.width/Le;F==null||F(oe[Me],Ke,Me,Ke+(oe[Me].growOffset??0))}else ie.kind==="header"&&pe&&(m(ie.bounds.x),a(Me))}else ie.kind==="cell"&&U>0&&Me===0&&De!==void 0&&fe!==void 0&&(G(ie.bounds.y),g(De))}he==null||he(ie)},[he,se,U,fe,j,oe,pe,F,Se]),Oe=c.useCallback((ie,be)=>{u||C||B==null||B(ie,be)},[u,C,B]),rt=c.useCallback((ie,be)=>{u||C||A==null||A(ie,be)},[u,C,A]),je=c.useRef(-1),Te=c.useCallback(()=>{je.current=-1,g(void 0),x(void 0),G(void 0),w(!1),a(void 0),l(void 0),m(void 0),d(!1),o(void 0),n(void 0)},[]),Fe=c.useCallback((ie,be)=>{if(ie.button===0){if(r!==void 0){if((J==null?void 0:J.hasIndex(r))===!0)for(const De of J){if(De===r)continue;const ke=oe[De],ot=Bo(ke,je.current,D,_);k==null||k(ke,ot,De,ot+(ke.growOffset??0))}const Me=Bo(oe[r],je.current,D,_);if(H==null||H(oe[r],Me,r,Me+(oe[r].growOffset??0)),J.hasIndex(r))for(const De of J){if(De===r)continue;const ke=oe[De],ot=Bo(ke,je.current,D,_);H==null||H(ke,ot,De,ot+(ke.growOffset??0))}}Te(),i!==void 0&&s!==void 0&&(Z==null?void 0:Z(i,s))!==!1&&(V==null||V(i,s)),p!==void 0&&b!==void 0&&(fe==null||fe(p,b))}de==null||de(ie,be)},[de,r,i,s,p,b,J,H,oe,D,_,k,V,fe,Te,Z]),_e=c.useMemo(()=>{if(!(i===void 0||s===void 0)&&i!==s&&(Z==null?void 0:Z(i,s))!==!1)return{src:i,dest:s}},[i,s,Z]),mt=c.useCallback(ie=>{const be=Se==null?void 0:Se.current;if(i!==void 0&&h!==void 0)Math.abs(ie.clientX-h)>20&&d(!0);else if(p!==void 0&&M!==void 0)Math.abs(ie.clientY-M)>20&&w(!0);else if(r!==void 0&&t!==void 0&&be){const De=be.getBoundingClientRect().width/be.offsetWidth,ke=(ie.clientX-t)/De,ot=oe[r],Le=Bo(ot,ke,D,_);if(k==null||k(ot,Le,r,Le+(ot.growOffset??0)),je.current=ke,(J==null?void 0:J.first())===r)for(const Ke of J){if(Ke===r)continue;const ue=oe[Ke],ye=Bo(ue,je.current,D,_);k==null||k(ue,ye,Ke,ye+(ue.growOffset??0))}}},[i,h,p,M,r,t,oe,D,_,k,J,Se]),xt=c.useCallback((ie,be)=>{if(p===void 0||b===void 0)return L(ie,be);let[Me,De]=ie;return De===b?De=p:(De>b&&(De-=1),De>=p&&(De+=1)),L([Me,De],be)},[p,b,L]),pt=c.useCallback(ie=>{q==null||q(ie),ie.defaultPrevented()||Te()},[Te,q]);return c.createElement(EC,{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:xt,isResizing:r!==void 0,onHeaderMenuClick:Oe,onHeaderIndicatorClick:rt,isDragging:u,onItemHovered:ae,onDragStart:pt,onMouseDown:Ge,allowResize:se,onMouseUp:Fe,dragAndDropState:_e,onMouseMoveRaw:mt,ref:j})};function DC(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 $C=(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])},AC=()=>e=>e.isSafari?"scroll":"auto",FC=Sr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[AC()]}}),_C=33554400,PC=5e6;function OC(e){const[t,n]=c.useState(!1),r=typeof window>"u"?null:window,o=c.useRef(0);return an("touchstart",c.useCallback(()=>{window.clearTimeout(o.current),n(!0)},[]),r,!0,!1),an("touchend",c.useCallback(i=>{i.touches.length===0&&(o.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}const jC=e=>{var Ee,J;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:b}=e,x=[],C=(m==null?void 0:m.sticky)??!1,w=(m==null?void 0:m.fill)??!1,M=c.useRef(0),G=c.useRef(0),B=c.useRef(null),A=typeof window>"u"?1:window.devicePixelRatio,L=c.useRef(A);c.useEffect(()=>{if(L.current!==A){M.current=0,G.current=0,L.current=A;const ae=B.current;ae!==null&&fe.current(ae.scrollLeft,ae.scrollTop)}},[A]);const V=c.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),k=c.useRef(null),F=OC(200),[H,j]=c.useState(!0),_=c.useRef(0);c.useLayoutEffect(()=>{if(!H||F||V.current.lockDirection===void 0)return;const ae=B.current;if(ae===null)return;const[pe,Ge]=V.current.lockDirection;pe!==void 0?ae.scrollLeft=pe:Ge!==void 0&&(ae.scrollTop=Ge),V.current.lockDirection=void 0},[F,H]);const D=c.useCallback((ae,pe)=>{var Me;const Ge=B.current;if(Ge===null)return;pe=pe??Ge.scrollTop,ae=ae??Ge.scrollLeft;const Oe=V.current.scrollTop,rt=V.current.scrollLeft,je=ae-rt,Te=pe-Oe;F&&je!==0&&Te!==0&&(Math.abs(je)>3||Math.abs(Te)>3)&&l&&V.current.lockDirection===void 0&&(V.current.lockDirection=Math.abs(je)<Math.abs(Te)?[rt,void 0]:[void 0,Oe]);const Fe=V.current.lockDirection;ae=(Fe==null?void 0:Fe[0])??ae,pe=(Fe==null?void 0:Fe[1])??pe,V.current.scrollLeft=ae,V.current.scrollTop=pe;const _e=Ge.clientWidth,mt=Ge.clientHeight,xt=pe,pt=G.current-xt,ie=Ge.scrollHeight-mt;G.current=xt;let be;if(ie>0&&r>Ge.scrollHeight+5)if(Math.abs(pt)>2e3||xt===0||xt===ie){const De=Math.max(0,Math.min(1,xt/ie)),ke=r-mt;be=De*ke,M.current=be}else M.current-=pt,be=M.current;else be=xt,M.current=be;be=Math.max(0,Math.min(be,r-mt)),M.current=be,Fe!==void 0&&(window.clearTimeout(_.current),j(!1),_.current=window.setTimeout(()=>j(!0),200)),i({x:ae,y:be,width:_e-d,height:mt-u,paddingRight:((Me=k.current)==null?void 0:Me.clientWidth)??0})},[u,d,r,i,l,F]);$C(p&&ji.value,D,B);const fe=c.useRef(D);fe.current=D;const U=c.useRef(),Z=c.useRef(!1);c.useLayoutEffect(()=>{Z.current?D():Z.current=!0},[D,u,d]);const he=c.useCallback(ae=>{B.current=ae,g!==void 0&&(g.current=ae)},[g]);let de=0,ee=0;const q=Math.min(r,_C);for(x.push(c.createElement("div",{key:de++,style:{width:o,height:0}}));ee<q;){const ae=Math.min(PC,q-ee);x.push(c.createElement("div",{key:de++,style:{width:0,height:ae}})),ee+=ae}const{ref:Se,width:se,height:oe}=DC(b);return typeof window<"u"&&(((Ee=U.current)==null?void 0:Ee.height)!==oe||((J=U.current)==null?void 0:J.width)!==se)&&(window.setTimeout(()=>fe.current(),0),U.current={width:se,height:oe}),(se??0)===0||(oe??0)===0?c.createElement("div",{ref:Se}):c.createElement("div",{ref:Se},c.createElement(FC,{isSafari:ji.value},c.createElement("div",{className:"dvn-underlay"},t),c.createElement("div",{ref:he,style:U.current,draggable:a,onDragStart:ae=>{a||(ae.stopPropagation(),ae.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:k,style:{height:oe,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))))))},NC=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:b,rightElementProps:x,overscrollX:C,overscrollY:w,initialSize:M,smoothScrollX:G=!1,smoothScrollY:B=!1,isDraggable:A}=e,{paddingRight:L,paddingBottom:V}=l??{},[k,F]=d,H=c.useRef(),j=c.useRef(),_=c.useRef(),D=c.useRef(),fe=u+Math.max(0,C??0);let U=a?o+i:o;if(typeof r=="number")U+=n*r;else for(let ee=0;ee<n;ee++)U+=r(ee);w!==void 0&&(U+=w);const Z=c.useRef(),he=c.useCallback(()=>{var rt,je;if(Z.current===void 0)return;const ee={...Z.current};let q=0,Se=ee.x<0?-ee.x:0,se=0,oe=0;ee.x=ee.x<0?0:ee.x;let Ee=0;for(let Te=0;Te<s;Te++)Ee+=t[Te].width;for(const Te of t){const Fe=q-Ee;if(ee.x>=Fe+Te.width)q+=Te.width,oe++,se++;else if(ee.x>Fe)q+=Te.width,G?Se+=Fe-ee.x:oe++,se++;else if(ee.x+ee.width>Fe)q+=Te.width,se++;else break}let J=0,ae=0,pe=0;if(typeof r=="number")B?(ae=Math.floor(ee.y/r),J=ae*r-ee.y):ae=Math.ceil(ee.y/r),pe=Math.ceil(ee.height/r)+ae,J<0&&pe++;else{let Te=0;for(let Fe=0;Fe<n;Fe++){const _e=r(Fe),mt=Te+(B?0:_e/2);if(ee.y>=Te+_e)Te+=_e,ae++,pe++;else if(ee.y>mt)Te+=_e,B?J+=mt-ee.y:ae++,pe++;else if(ee.y+ee.height>_e/2+Te)Te+=_e,pe++;else break}}ae=Math.max(0,Math.min(ae,n-1)),pe=Math.max(ae,Math.min(pe,n));const Ge={x:oe,y:ae,width:se-oe,height:pe-ae},Oe=H.current;(Oe===void 0||Oe.y!==Ge.y||Oe.x!==Ge.x||Oe.height!==Ge.height||Oe.width!==Ge.width||j.current!==Se||_.current!==J||ee.width!==((rt=D.current)==null?void 0:rt[0])||ee.height!==((je=D.current)==null?void 0:je[1]))&&(m==null||m({x:oe,y:ae,width:se-oe,height:pe-ae},ee.width,ee.height,ee.paddingRight??0,Se,J),H.current=Ge,j.current=Se,_.current=J,D.current=[ee.width,ee.height])},[t,r,n,m,s,G,B]),de=c.useCallback(ee=>{Z.current=ee,he()},[he]);return c.useEffect(()=>{he()},[he]),c.createElement(jC,{scrollRef:p,className:h,kineticScrollPerfHack:l==null?void 0:l.kineticScrollPerfHack,preventDiagonalScrolling:g,draggable:A===!0||typeof A=="string",scrollWidth:fe+(L??0),scrollHeight:U+(V??0),clientHeight:F,rightElement:b,paddingBottom:V,paddingRight:L,rightElementProps:x,update:de,initialSize:M},c.createElement(TC,{eventTargetRef:p,width:k,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}))},HC=Sr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),BC=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"})),LC=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"})),zC=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"})),WC=10,GC=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,b]=c.useState(""),x=a??g,C=c.useCallback(q=>{b(q),l==null||l(q)},[l]),[w,M]=c.useState(),G=c.useRef(w);G.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 B=c.useRef();B.current===void 0&&(B.current=new AbortController);const A=c.useRef(),[L,V]=c.useState([]),k=s??L,F=c.useCallback(()=>{A.current!==void 0&&(window.cancelAnimationFrame(A.current),A.current=void 0),B.current!==void 0&&B.current.abort(),B.current=new AbortController},[]),H=c.useRef(n);H.current=n;const j=c.useCallback(q=>{const Se=new RegExp(q.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let se=H.current,oe=Math.min(10,r),Ee=0;M(void 0),V([]);const J=[],ae=async()=>{var xt;if(u===void 0)return;const pe=performance.now(),Ge=r-Ee;let Oe=u({x:0,y:se,width:o.length,height:Math.min(oe,Ge,r-se)},B.current.signal);typeof Oe=="function"&&(Oe=await Oe());let rt=!1;for(const[pt,ie]of Oe.entries())for(const[be,Me]of ie.entries()){let De;switch(Me.kind){case ce.Text:case ce.Number:De=Me.displayData;break;case ce.Uri:case ce.Markdown:De=Me.data;break;case ce.Boolean:De=typeof Me.data=="boolean"?Me.data.toString():void 0;break;case ce.Image:case ce.Bubble:De=Me.data.join("🐳");break;case ce.Custom:De=Me.copyData;break}De!==void 0&&Se.test(De)&&(J.push([be,pt+se]),rt=!0)}const je=performance.now();rt&&V([...J]),Ee+=Oe.length,pn(Ee<=r);const Te=((xt=G.current)==null?void 0:xt.selectedIndex)??-1;M({results:J.length,rowsSearched:Ee,selectedIndex:Te}),d==null||d(J,Te),se+oe>=r?se=0:se+=oe;const Fe=je-pe,_e=Math.max(Fe,1),mt=WC/_e;oe=Math.ceil(oe*mt),Ee<r&&J.length<1e3&&(A.current=window.requestAnimationFrame(ae))};F(),A.current=window.requestAnimationFrame(ae)},[F,o.length,u,d,r]),_=c.useCallback(()=>{var q;m==null||m(),M(void 0),V([]),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),V([]),F()):j(q.target.value))},[j,F,C,s]);c.useEffect(()=>{i.current!==null&&(C(""),M(void 0),L.length>0&&(V([]),d==null||d([],-1)),h?i.current.focus({preventScroll:!0}):F())},[h,i]);const fe=c.useCallback(q=>{var se;if((se=q==null?void 0:q.stopPropagation)==null||se.call(q),w===void 0||w.results===0)return;const Se=(w.selectedIndex+1)%w.results;M({...w,selectedIndex:Se}),d==null||d(k,Se)},[w,d,k]),U=c.useCallback(q=>{var se;if((se=q==null?void 0:q.stopPropagation)==null||se.call(q),w===void 0||w.results===0)return;let Se=(w.selectedIndex-1)%w.results;Se<0&&(Se+=w.results),M({...w,selectedIndex:Se}),d==null||d(k,Se)},[d,k,w]),Z=c.useCallback(q=>{(q.ctrlKey||q.metaKey)&&q.nativeEvent.code==="KeyF"||q.key==="Escape"?(_(),q.stopPropagation(),q.preventDefault()):q.key==="Enter"&&(q.shiftKey?U():fe())},[_,fe,U]);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 ee=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 Se=Ee=>{Ee.stopPropagation()},oe={width:`${r>0?Math.floor(((w==null?void 0:w.rowsSearched)??0)/r*100):0}%`};return c.createElement(HC,{className:"gdg-search-bar"+(h?"":" out"),onMouseDown:Se,onMouseMove:Se,onMouseUp:Se,onClick:Se},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:Z}),c.createElement("button",{type:"button","aria-label":"Previous Result","aria-hidden":!h,tabIndex:h?void 0:-1,onClick:U,disabled:((w==null?void 0:w.results)??0)===0},BC),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},LC),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:_},zC)),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:oe})):c.createElement("div",{className:"gdg-search-status"},c.createElement("label",{htmlFor:p},"Type to search")))},[h,he,w,r,p,i,D,x,Z,U,fe,m,_]);return c.createElement(c.Fragment,null,c.createElement(NC,{prelightCells:k,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}),ee)};class UC 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 XC=()=>e=>Math.max(16,e.targetHeight-10),KC=Sr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[XC(),"px"]}}),YC=e=>{const{bounds:t,group:n,onClose:r,canvasBounds:o,onFinish:i}=e,[a,s]=zt.useState(n);return zt.createElement(UC,{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(KC,{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 qC(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=su(e,t);return r&&(n.didMatch=!0),r}function su(e,t){if(e.length===0)return!1;if(e.includes("|")){const l=e.split("|");for(const u of l)if(su(u,t))return!0;return!1}let n=!1,r=!1,o=!1,i=!1;const a=e.split("+"),s=a.pop();if(!qC(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 VC(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",b=(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:b?e.columns:lt.empty(),rows:x?e.rows:lt.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:lt.empty(),rows:d};else{const g=m&&n==="mixed"||n==="additive",b=m&&r==="mixed"||r==="additive";p={current:g?e.current:void 0,columns:b?e.columns:lt.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:lt.empty(),columns:d};else{const g=m&&n==="mixed"||n==="additive",b=m&&o==="mixed"||o==="additive";p={current:g?e.current:void 0,rows:b?e.rows:lt.empty(),columns:d}}t(p,!1)},[r,e,n,o,t]);return[s,l,u]}function JC(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:ce.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:ce.Loading,allowOverlay:!1},...m]):h.map(m=>[{kind:ce.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 ce.Boolean:return{formatted:e.data===!0?"TRUE":e.data===!1?"FALSE":e.data===Js?"INDETERMINATE":"",rawValue:e.data,format:"boolean"};case ce.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:"string"};case ce.Image:case ce.Bubble:return{formatted:e.data,rawValue:e.data,format:"string-array"};case ce.Drilldown:return{formatted:e.data.map(t=>t.text),rawValue:e.data.map(t=>t.text),format:"string-array"};case ce.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:"string"};case ce.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:"url"};case ce.Markdown:case ce.RowID:return{formatted:e.data,rawValue:e.data,format:"string"};case ce.Number:return{formatted:e.displayData,rawValue:e.data,format:"number"};case ce.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case ce.Protected:return{formatted:"************",rawValue:"",format:"string"};default:qo()}}function ZC(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 Ol(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,'""')}"`),e}function ek(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=>Ol(a,!0)).join(",")):o.push(i.doNotEscape===!0?i.formatted:Ol(i.formatted,!1));t.push(o.join(" "))}return t.join(`
8
+ `)}function xs(e){return e.replace(/\t/g," ").replace(/ {2,}/g,t=>"<span> </span>".repeat(t.length))}function jl(e){return'"'+e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")+'"'}function tk(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function nk(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=${jl(o.rawValue[s])}>`+xs(a)+"</li>").join("")}</ol></td>`):t.push(`<td gdg-raw-value=${jl(((n=o.rawValue)==null?void 0:n.toString())??"")} ${i}>${xs(o.formatted)}</td>`)}t.push("</tr>")}return t.push("</tbody></table>"),t.join("")}function rk(e,t){const n=ZC(e,t),r=ek(n),o=nk(n);return{textPlain:r,textHtml:o}}function Nl(e){var a;const t=document.createElement("html");t.innerHTML=e.replace(/&nbsp;/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 b of m)b.replaceWith(`
9
+ `);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 b=l.querySelectorAll("li");i==null||i.push({rawValue:[...b].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...b].map(x=>x.textContent??""),format:"string-array"})}else if(p!==null)i==null||i.push({rawValue:tk(p),formatted:l.textContent??"",format:g});else{let b=l.textContent??"";h&&(b=b.replace(/\n(?!\n)/g,"")),i==null||i.push({rawValue:b??"",formatted:b??"",format:g})}}}return i!==void 0&&o.push(i),o}function ok(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 Hl(e){return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).replace(/""/g,'"')),e}function ik(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
10
  `);let a=0;for(const s of e){switch(i){case t.None:s===" "||s===`
9
11
  `?(r.push(e.slice(o,a)),o=a+1,s===`
10
12
  `&&(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
13
  `)&&(r.push(Hl(e.slice(o,a))),o=a+1,s===`
12
- `&&(n.push(r),r=[])),i=t.None);break}a++}return o<e.length&&r.push(Hl(e.slice(o,e.length))),n.push(r),n.map(s=>s.map(l=>({rawValue:l,formatted:l,format:"string"})))}function Bl(e,t,n){var s;const r=nk(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 au(e){return e!==!0}function Ll(e){return typeof e=="string"?e:`${e}px`}const ik=()=>e=>e.innerWidth,sk=()=>e=>e.innerHeight,ak=Sr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[ik()],"wmyidgi-1":[sk()]}}),lk=e=>{const{inWidth:t,inHeight:n,children:r,...o}=e;return c.createElement(ak,{innerHeight:Ll(n),innerWidth:Ll(t),...o},r)},ck=2,uk=1300;function dk(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/uk);const m=r.current**1.618*h*ck;(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 fk({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,b=e,x=Fc();return[typeof b=="number"?b*g:C=>Math.ceil(b(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 wr={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 et(e,t){return e===!0?t:e===!1?"":e}function zl(e){const t=Ni.value;return{activateCell:et(e.activateCell," |Enter|shift+Enter"),clear:et(e.clear,"any+Escape"),closeOverlay:et(e.closeOverlay,"any+Escape"),acceptOverlayDown:et(e.acceptOverlayDown,"Enter"),acceptOverlayUp:et(e.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:et(e.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:et(e.acceptOverlayRight,"Tab"),copy:e.copy,cut:e.cut,delete:et(e.delete,t?"Backspace|Delete":"Delete"),downFill:et(e.downFill,"primary+_68"),scrollToSelectedCell:et(e.scrollToSelectedCell,"primary+Enter"),goDownCell:et(e.goDownCell,"ArrowDown"),goDownCellRetainSelection:et(e.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:et(e.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:et(e.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:et(e.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:et(e.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:et(e.goUpCell,"ArrowUp"),goUpCellRetainSelection:et(e.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:et(e.goToFirstCell,"primary+Home"),goToFirstColumn:et(e.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:et(e.goToFirstRow,"primary+ArrowUp"),goToLastCell:et(e.goToLastCell,"primary+End"),goToLastColumn:et(e.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:et(e.goToLastRow,"primary+ArrowDown"),goToNextPage:et(e.goToNextPage,"PageDown"),goToPreviousPage:et(e.goToPreviousPage,"PageUp"),paste:e.paste,rightFill:et(e.rightFill,"primary+_82"),search:et(e.search,"primary+f"),selectAll:et(e.selectAll,"primary+a"),selectColumn:et(e.selectColumn,"ctrl+ "),selectGrowDown:et(e.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:et(e.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:et(e.selectGrowRight,"shift+ArrowRight"),selectGrowUp:et(e.selectGrowUp,"shift+ArrowUp"),selectRow:et(e.selectRow,"shift+ "),selectToFirstCell:et(e.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:et(e.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:et(e.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:et(e.selectToLastCell,"primary+shift+End"),selectToLastColumn:et(e.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:et(e.selectToLastRow,"primary+shift+ArrowDown")}}function hk(e){const t=Np(e);return zt.useMemo(()=>{if(t===void 0)return zl(wr);const n={...t,goToNextPage:(t==null?void 0:t.goToNextPage)??(t==null?void 0:t.pageDown)??wr.goToNextPage,goToPreviousPage:(t==null?void 0:t.goToPreviousPage)??(t==null?void 0:t.pageUp)??wr.goToPreviousPage,goToFirstCell:(t==null?void 0:t.goToFirstCell)??(t==null?void 0:t.first)??wr.goToFirstCell,goToLastCell:(t==null?void 0:t.goToLastCell)??(t==null?void 0:t.last)??wr.goToLastCell,selectToFirstCell:(t==null?void 0:t.selectToFirstCell)??(t==null?void 0:t.first)??wr.selectToFirstCell,selectToLastCell:(t==null?void 0:t.selectToLastCell)??(t==null?void 0:t.last)??wr.selectToLastCell};return zl({...wr,...n})},[t])}function gk(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=gk(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 mk(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=xr(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 pk(e,t){const n=zt.useMemo(()=>e===void 0?void 0:la(e,t),[e,t]);return{getRowGroupingForPath:cu,updateRowGroupingByPath:lu,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 lu(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:lu(i.subGroups??[],o,n)}:i)}function cu(e,t){const[n,...r]=t;return r[0]===-1?e[n]:cu(e[n].subGroups??[],r)}function bk(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 yk(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]=Op(s),h=c.useRef(o);h.current=o;const m=bk(null,b=>{b!==null&&t!==void 0?b.scrollTop=t:b!==null&&e!==void 0&&(b.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 vk=c.lazy(async()=>await ec(()=>import("./data-grid-overlay-editor-B_nPhXKR.js"),__vite__mapDeps([0,1,2])));let wk=0;function xk(e){return py(ll(ll(e).filter(t=>t.span!==void 0).map(t=>{var n,r;return Br((((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:ce.Loading,allowOverlay:!1},Ri={columns:lt.empty(),rows:lt.empty(),current:void 0},Ck=(e,t)=>{var Ra,Ma,Ia;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:b,height:x,columns:C,rows:w,getCellContent:M,onCellClicked:G,onCellActivated:B,onFillPattern:A,onFinishedEditing:L,coercePasteValue:V,drawHeader:k,drawCell:F,editorBloom:H,onHeaderClicked:j,onColumnProposeMove:_,rangeSelectionColumnSpanning:D=!0,spanRangeBehavior:fe="default",onGroupHeaderClicked:U,onCellContextMenu:Z,className:he,onHeaderContextMenu:de,getCellsForSelection:ee,onGroupHeaderContextMenu:q,onGroupHeaderRenamed:Se,onCellEdited:se,onCellsEdited:oe,onSearchResultsChanged:Ee,searchResults:J,onSearchValueChange:ae,searchValue:pe,onKeyDown:Ge,onKeyUp:Oe,keybindings:rt,editOnType:je=!0,onRowAppended:Te,onColumnAppended:Fe,onColumnMoved:_e,validateCell:mt,highlightRegions:xt,rangeSelect:pt="rect",columnSelect:ie="multi",rowSelect:be="multi",rangeSelectionBlending:Me="exclusive",columnSelectionBlending:De="exclusive",rowSelectionBlending:ke="exclusive",onDelete:ot,onDragStart:Le,onMouseMove:Ke,onPaste:ue,copyHeaders:ye=!1,freezeColumns:Ye=0,cellActivationBehavior:Ve="second-click",rowSelectionMode:it="auto",columnSelectionMode:xe="auto",onHeaderMenuClick:dt,onHeaderIndicatorClick:Ne,getGroupDetails:He,rowGrouping:st,onSearchClose:Wt,onItemHovered:ct,onSelectionCleared:$e,showSearch:bt,onVisibleRegionChanged:Ht,gridSelection:Yt,onGridSelectionChange:vt,minColumnWidth:yn=50,maxColumnWidth:dn=500,maxColumnAutoWidth:kt,provideEditor:Ut,trailingRowOptions:Je,freezeTrailingRows:It=0,allowedFillDirections:$t="orthogonal",scrollOffsetX:tt,scrollOffsetY:Rt,verticalBorder:gt,onDragOverCell:qt,onDrop:Nt,onColumnResize:Ot,onColumnResizeEnd:Gt,onColumnResizeStart:Be,customRenderers:$n,fillHandle:At,experimental:nt,fixedShadowX:Xt,fixedShadowY:Et,headerIcons:Qt,imageWindowLoader:ln,initialSize:Ft,isDraggable:Zn,onDragLeave:Ir,onRowMoved:vn,overscrollX:rn,overscrollY:wn,preventDiagonalScrolling:zn,rightElement:Wn,rightElementProps:Gn,trapFocus:An=!1,smoothScrollX:Ro,smoothScrollY:Ur,scaleToRem:Mo=!1,rowHeight:er=34,headerHeight:fn=36,groupHeaderHeight:xn=fn,theme:Io,isOutsideClick:Xr,renderers:sr,resizeIndicator:Kr,scrollToActiveCell:Cn=!0,drawFocusRing:ar=!0,portalElementRef:Yr}=e,lr=ar==="no-editor"?o===void 0:ar,yt=typeof e.rowMarkers=="string"?void 0:e.rowMarkers,Vt=(yt==null?void 0:yt.kind)??e.rowMarkers??"none",cr=(yt==null?void 0:yt.width)??e.rowMarkerWidth,Fn=(yt==null?void 0:yt.startIndex)??e.rowMarkerStartIndex??1,ur=(yt==null?void 0:yt.theme)??e.rowMarkerTheme,Un=yt==null?void 0:yt.headerTheme,dr=yt==null?void 0:yt.headerAlwaysVisible,fr=be!=="multi"||(yt==null?void 0:yt.headerDisabled)===!0,on=(yt==null?void 0:yt.checkboxStyle)??"square",hn=Math.max(yn,20),Jt=Math.max(dn,hn),Eo=Math.max(kt??Jt,hn),Er=c.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),{rows:Re,rowNumberMapper:hr,rowHeight:_n,getRowThemeOverride:Zt}=mk(st,w,er,p),Tr=c.useMemo(()=>Number.parseFloat(Er.fontSize),[Er]),{rowHeight:kn,headerHeight:Dr,groupHeaderHeight:$r,theme:tr,overscrollX:qr,overscrollY:Vr}=fk({groupHeaderHeight:xn,headerHeight:fn,overscrollX:rn,overscrollY:wn,remSize:Tr,rowHeight:_n,scaleToRem:Mo,theme:Io}),gn=hk(rt),Xn=cr??(w>1e4?48:w>1e3?44:w>100?36:32),en=Vt!=="none",$=en?1:0,Ct=Je!==void 0,Sn=(Je==null?void 0:Je.sticky)===!0,[Jr,Pn]=c.useState(!1),To=bt??Jr,gr=c.useCallback(()=>{Wt!==void 0?Wt():Pn(!1)},[Wt]),W=c.useMemo(()=>Yt===void 0?void 0:ki(Yt,$),[Yt,$])??n,I=c.useRef();I.current===void 0&&(I.current=new AbortController),c.useEffect(()=>()=>I==null?void 0:I.current.abort(),[]);const[Y,ge]=VC(ee,M,$,I.current,Re),me=c.useCallback((f,S,R)=>{if(mt===void 0)return!0;const E=[f[0]-$,f[1]];return mt==null?void 0:mt(E,S,R)},[$,mt]),y=c.useRef(Yt),T=c.useCallback((f,S)=>{S&&(f=rk(f,Y,$,fe,I.current)),vt!==void 0?(y.current=ki(f,-$),vt(y.current)):r(f)},[vt,Y,$,fe]),z=xr(Ot,c.useCallback((f,S,R,E)=>{Ot==null||Ot(C[R-$],S,R-$,E)},[Ot,$,C])),ne=xr(Gt,c.useCallback((f,S,R,E)=>{Gt==null||Gt(C[R-$],S,R-$,E)},[Gt,$,C])),te=xr(Be,c.useCallback((f,S,R,E)=>{Be==null||Be(C[R-$],S,R-$,E)},[Be,$,C])),ft=xr(k,c.useCallback((f,S)=>(k==null?void 0:k({...f,columnIndex:f.columnIndex-$},S))??!1,[k,$])),Ce=xr(F,c.useCallback((f,S)=>(F==null?void 0:F({...f,col:f.col-$},S))??!1,[F,$])),at=c.useCallback(f=>{if(ot!==void 0){const S=ot(ki(f,-$));return typeof S=="boolean"?S:ki(S,$)}return!0},[ot,$]),[Ue,qe,ze]=qC(W,T,Me,De,ke,pt,D),ut=c.useMemo(()=>ir(Fc(),tr),[tr]),[_t,On]=c.useState([0,0,0]),jn=c.useMemo(()=>{if(sr===void 0)return{};const f={};for(const S of sr)f[S.kind]=S;return f},[sr]),Mt=c.useCallback(f=>f.kind!==ce.Custom?jn[f.kind]:$n==null?void 0:$n.find(S=>S.isMatch(f)),[$n,jn]);let{sizedColumns:jt,nonGrowWidth:wt}=pb(C,Re,ge,_t[0]-($===0?0:Xn)-_t[2],hn,Eo,ut,Mt,I.current);Vt!=="none"&&(wt+=Xn);const Rn=c.useMemo(()=>jt.some(f=>f.group!==void 0),[jt]),tn=Rn?Dr+$r:Dr,Qr=W.rows.length,nr=Vt==="none"?void 0:Qr===0?!1:Qr===Re?!0:void 0,Qe=c.useMemo(()=>Vt==="none"?jt:[{title:"",width:Xn,icon:void 0,hasMenu:!1,style:"normal",themeOverride:ur,rowMarker:on,rowMarkerChecked:nr,headerRowMarkerTheme:Un,headerRowMarkerAlwaysVisible:dr,headerRowMarkerDisabled:fr},...jt],[Vt,jt,Xn,ur,on,nr,Un,dr,fr]),Bt=c.useRef({height:1,width:1,x:0,y:0}),Ar=c.useRef(!1),{setVisibleRegion:mr,visibleRegion:rr,scrollRef:St}=yk(tt,Rt,kn,Bt,()=>Ar.current=!0);Bt.current=rr;const $u=rr.x+$,oi=rr.y,Kt=c.useRef(null),sn=c.useCallback(f=>{var S;f===!0?(S=Kt.current)==null||S.focus():window.requestAnimationFrame(()=>{var R;(R=Kt.current)==null||R.focus()})},[]),nn=Ct?Re+1:Re,Mn=c.useCallback(f=>{const S=$===0?f:f.map(E=>({...E,location:[E.location[0]-$,E.location[1]]})),R=oe==null?void 0:oe(S);if(R!==!0)for(const E of S)se==null||se(E.location,E.value);return R},[se,oe,$]),[Fr,qi]=c.useState(),ii=W.current!==void 0&&W.current.range.width*W.current.range.height>1?W.current.range:void 0,Zr=lr?(Ra=W.current)==null?void 0:Ra.cell:void 0,si=Zr==null?void 0:Zr[0],ai=Zr==null?void 0:Zr[1],Au=c.useMemo(()=>{if((xt===void 0||xt.length===0)&&(ii??si??ai??Fr)===void 0)return;const f=[];if(xt!==void 0)for(const S of xt){const R=Qe.length-S.range.x-$;R>0&&f.push({color:S.color,range:{...S.range,x:S.range.x+$,width:Math.min(R,S.range.width)},style:S.style})}return Fr!==void 0&&f.push({color:Lr(ut.accentColor,0),range:Fr,style:"dashed"}),ii!==void 0&&f.push({color:Lr(ut.accentColor,.5),range:ii,style:"solid-outline"}),si!==void 0&&ai!==void 0&&f.push({color:ut.accentColor,range:{x:si,y:ai,width:1,height:1},style:"solid-outline"}),f.length>0?f:void 0},[Fr,ii,si,ai,xt,Qe.length,ut.accentColor,$]),fa=c.useRef(Qe);fa.current=Qe;const mn=c.useCallback(([f,S],R=!1)=>{var X,P,N,K,Q,le,ve;const E=Ct&&S===nn-1;if(f===0&&en){if(E)return Si;const re=hr(S);return re===void 0?Si:{kind:Tn.Marker,allowOverlay:!1,checkboxStyle:on,checked:(W==null?void 0:W.rows.hasIndex(S))===!0,markerKind:Vt==="clickable-number"?"number":Vt,row:Fn+re,drawHandle:vn!==void 0,cursor:Vt==="clickable-number"?"pointer":void 0}}else if(E){const Ae=f===$?(Je==null?void 0:Je.hint)??"":"",we=fa.current[f];if(((X=we==null?void 0:we.trailingRowOptions)==null?void 0:X.disabled)===!0)return Si;{const We=((P=we==null?void 0:we.trailingRowOptions)==null?void 0:P.hint)??Ae,Pe=((N=we==null?void 0:we.trailingRowOptions)==null?void 0:N.addIcon)??(Je==null?void 0:Je.addIcon);return{kind:Tn.NewRow,hint:We,allowOverlay:!1,icon:Pe}}}else{const re=f-$;if(R||(nt==null?void 0:nt.strict)===!0){const we=Bt.current,We=we.x>re||re>we.x+we.width||we.y>S||S>we.y+we.height||S>=Zi.current,Pe=re===((Q=(K=we.extras)==null?void 0:K.selected)==null?void 0:Q[0])&&S===((le=we.extras)==null?void 0:le.selected[1]);let Ie=!1;if(((ve=we.extras)==null?void 0:ve.freezeRegions)!==void 0){for(const ht of we.extras.freezeRegions)if(go(ht,re,S)){Ie=!0;break}}if(We&&!Pe&&!Ie)return Si}let Ae=M([re,S]);return $!==0&&Ae.span!==void 0&&(Ae={...Ae,span:[Ae.span[0]+$,Ae.span[1]+$]}),Ae}},[Ct,nn,en,hr,on,W==null?void 0:W.rows,Vt,Fn,vn,$,Je==null?void 0:Je.hint,Je==null?void 0:Je.addIcon,nt==null?void 0:nt.strict,M]),Vi=c.useCallback(f=>{let S=(He==null?void 0:He(f))??{name:f};return Se!==void 0&&f!==""&&(S={icon:S.icon,name:S.name,overrideTheme:S.overrideTheme,actions:[...S.actions??[],{title:"Rename",icon:"renameIcon",onClick:R=>ts({group:S.name,bounds:R.bounds})}]}),S},[He,Se]),li=c.useCallback(f=>{var N;const[S,R]=f.cell,E=Qe[S],O=(E==null?void 0:E.group)!==void 0?(N=Vi(E.group))==null?void 0:N.overrideTheme:void 0,X=E==null?void 0:E.themeOverride,P=Zt==null?void 0:Zt(R);i({...f,theme:ir(ut,O,X,P,f.content.themeOverride)})},[Zt,Qe,Vi,ut]),eo=c.useCallback((f,S,R)=>{var P;if(W.current===void 0)return;const[E,O]=W.current.cell,X=mn([E,O]);if(X.kind!==ce.Boolean&&X.allowOverlay){let N=X;if(R!==void 0)switch(N.kind){case ce.Number:{const K=Zm(()=>R==="-"?-0:Number.parseFloat(R),0);N={...N,data:Number.isNaN(K)?0:K};break}case ce.Text:case ce.Markdown:case ce.Uri:N={...N,data:R};break}li({target:f,content:N,initialValue:R,cell:[E,O],highlight:R===void 0,forceEditMode:R!==void 0,activation:S})}else X.kind===ce.Boolean&&S.inputType==="keyboard"&&X.readonly!==!0&&(Mn([{location:W.current.cell,value:{...X,data:au(X.data)}}]),(P=Kt.current)==null||P.damage([{cell:W.current.cell}]))},[mn,W,Mn,li]),ha=c.useCallback((f,S)=>{var O;const R=(O=Kt.current)==null?void 0:O.getBounds(f,S);if(R===void 0||St.current===null)return;const E=mn([f,S]);E.allowOverlay&&li({target:R,content:E,initialValue:void 0,highlight:!0,cell:[f,S],forceEditMode:!0,activation:{inputType:"keyboard",key:"Enter"}})},[mn,St,li]),Pt=c.useCallback((f,S,R="both",E=0,O=0,X=void 0)=>{if(St.current!==null){const P=Kt.current,N=s.current,K=typeof f!="number"?f.unit==="cell"?f.amount:void 0:f,Q=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,le=typeof f!="number"&&f.unit==="px"?f.amount:void 0,ve=typeof S!="number"&&S.unit==="px"?S.amount:void 0;if(P!==null&&N!==null){let re={x:0,y:0,width:0,height:0},Ae=0,we=0;if((K!==void 0||Q!==void 0)&&(re=P.getBounds((K??0)+$,Q??0)??re,re.width===0||re.height===0))return;const We=N.getBoundingClientRect(),Pe=We.width/N.offsetWidth;if(le!==void 0&&(re={...re,x:le-We.left-St.current.scrollLeft,width:1}),ve!==void 0&&(re={...re,y:ve+We.top-St.current.scrollTop,height:1}),re!==void 0){const Ie={x:re.x-E,y:re.y-O,width:re.width+2*E,height:re.height+2*O};let ht=0;for(let ls=0;ls<Ye;ls++)ht+=jt[ls].width;let Dt=0;const Lt=It+(Sn?1:0);Lt>0&&(Dt=Gr(nn,Lt,kn));let cn=ht*Pe+We.left+$*Xn*Pe,Yn=We.right,Bn=We.top+tn*Pe,qn=We.bottom-Dt*Pe;const mi=re.width+E*2;switch(X==null?void 0:X.hAlign){case"start":Yn=cn+mi;break;case"end":cn=Yn-mi;break;case"center":cn=Math.floor((cn+Yn)/2)-mi/2,Yn=cn+mi;break}const pi=re.height+O*2;switch(X==null?void 0:X.vAlign){case"start":qn=Bn+pi;break;case"end":Bn=qn-pi;break;case"center":Bn=Math.floor((Bn+qn)/2)-pi/2,qn=Bn+pi;break}cn>Ie.x?Ae=Ie.x-cn:Yn<Ie.x+Ie.width&&(Ae=Ie.x+Ie.width-Yn),Bn>Ie.y?we=Ie.y-Bn:qn<Ie.y+Ie.height&&(we=Ie.y+Ie.height-qn),R==="vertical"||typeof f=="number"&&f<Ye?Ae=0:(R==="horizontal"||typeof S=="number"&&S>=nn-Lt)&&(we=0),(Ae!==0||we!==0)&&(Pe!==1&&(Ae/=Pe,we/=Pe),St.current.scrollTo({left:Ae+St.current.scrollLeft,top:we+St.current.scrollTop,behavior:(X==null?void 0:X.behavior)??"auto"}))}}}},[$,It,Xn,St,tn,Ye,jt,nn,Sn,kn]),Ji=c.useRef(ha),Qi=c.useRef(M);Ji.current=ha,Qi.current=M;const Zi=c.useRef(Re);Zi.current=Re;const ga=c.useRef(Qe.length);ga.current=Qe.length;const pr=c.useCallback(async(f,S=!0,R)=>{var Q;const E=Qe[f];if(((Q=E==null?void 0:E.trailingRowOptions)==null?void 0:Q.disabled)===!0)return;const O=Te==null?void 0:Te();let X,P=!0;O!==void 0&&(X=await O,X==="top"&&(P=!1),typeof X=="number"&&(P=!1));let N=0;const K=()=>{if(Zi.current<=Re){N<500&&window.setTimeout(K,N),N=50+N*2;return}const le=typeof X=="number"?X:P?Re:0;gi.current(f-$,le,"both",0,0,R?{behavior:R}:void 0),Ue({cell:[f,le],range:{x:f,y:le,width:1,height:1}},!1,!1,"edit");const ve=Qi.current([f-$,le]);ve.allowOverlay&&ao(ve)&&ve.readonly!==!0&&S&&window.setTimeout(()=>{Ji.current(f,le)},0)};K()},[Qe,Te,$,Re,Ue]),ci=c.useCallback(async(f,S=!0)=>{const R=Fe==null?void 0:Fe();let E,O=!0;R!==void 0&&(E=await R,E==="left"&&(O=!1),typeof E=="number"&&(O=!1));let X=0;const P=()=>{if(ga.current<=Qe.length){X<500&&window.setTimeout(P,X),X=50+X*2;return}const N=typeof E=="number"?E:O?Qe.length:0;Pt(N-$,f),Ue({cell:[N,f],range:{x:N,y:f,width:1,height:1}},!1,!1,"edit");const K=Qi.current([N-$,f]);K.allowOverlay&&ao(K)&&K.readonly!==!0&&S&&window.setTimeout(()=>{Ji.current(N,f)},0)};P()},[Qe,Fe,$,Pt,Ue]),to=c.useCallback(f=>{var R,E;const S=((E=(R=jt[f])==null?void 0:R.trailingRowOptions)==null?void 0:E.targetColumn)??(Je==null?void 0:Je.targetColumn);if(typeof S=="number")return S+(en?1:0);if(typeof S=="object"){const O=C.indexOf(S);if(O>=0)return O+(en?1:0)}},[jt,C,en,Je==null?void 0:Je.targetColumn]),br=c.useRef(),no=c.useRef(),Do=c.useCallback((f,S)=>{var O;const[R,E]=S;return ir(ut,(O=Qe[R])==null?void 0:O.themeOverride,Zt==null?void 0:Zt(E),f.themeOverride)},[Zt,Qe,ut]),{mapper:_r}=pk(st,w),Nn=st==null?void 0:st.navigationBehavior,$o=c.useCallback(f=>{var Q,le,ve;const S=Ni.value?f.metaKey:f.ctrlKey,R=S&&be==="multi",[E,O]=f.location,X=W.columns,P=W.rows,[N,K]=((Q=W.current)==null?void 0:Q.cell)??[];if(f.kind==="cell"){if(no.current=void 0,Pr.current=[E,O],E===0&&en){if(Ct===!0&&O===Re||Vt==="number"||be==="none")return;const re=mn(f.location);if(re.kind!==Tn.Marker)return;if(vn!==void 0){const We=Mt(re);pn((We==null?void 0:We.kind)===Tn.Marker);const Pe=(le=We==null?void 0:We.onClick)==null?void 0:le.call(We,{...f,cell:re,posX:f.localEventX,posY:f.localEventY,bounds:f.bounds,theme:Do(re,f.location),preventDefault:()=>{}});if(Pe===void 0||Pe.checked===re.checked)return}i(void 0),sn();const Ae=P.hasIndex(O),we=br.current;if(be==="multi"&&(f.shiftKey||f.isLongTouch===!0)&&we!==void 0&&P.hasIndex(we)){const We=[Math.min(we,O),Math.max(we,O)+1];R||it==="multi"?qe(void 0,We,!0):qe(lt.fromSingleSelection(We),void 0,R)}else be==="multi"&&(R||f.isTouch||it==="multi")?Ae?qe(P.remove(O),void 0,!0):(qe(void 0,O,!0),br.current=O):Ae&&P.length===1?qe(lt.empty(),void 0,S):(qe(lt.fromSingleSelection(O),void 0,S),br.current=O)}else if(E>=$&&Ct&&O===Re){const re=to(E);pr(re??E)}else if(N!==E||K!==O){const re=mn(f.location),Ae=Mt(re);if((Ae==null?void 0:Ae.onSelect)!==void 0){let Pe=!1;if(Ae.onSelect({...f,cell:re,posX:f.localEventX,posY:f.localEventY,bounds:f.bounds,preventDefault:()=>Pe=!0,theme:Do(re,f.location)}),Pe)return}if(Nn==="block"&&_r(O).isGroupHeader)return;const we=Sn&&O===Re,We=Sn&&W!==void 0&&((ve=W.current)==null?void 0:ve.cell[1])===Re;if((f.shiftKey||f.isLongTouch===!0)&&N!==void 0&&K!==void 0&&W.current!==void 0&&!We){if(we)return;const Pe=Math.min(E,N),Ie=Math.max(E,N),ht=Math.min(O,K),Dt=Math.max(O,K);Ue({...W.current,range:{x:Pe,y:ht,width:Ie-Pe+1,height:Dt-ht+1}},!0,S,"click"),br.current=void 0,sn()}else Ue({cell:[E,O],range:{x:E,y:O,width:1,height:1}},!0,S,"click"),br.current=void 0,i(void 0),sn()}}else if(f.kind==="header")if(Pr.current=[E,O],i(void 0),en&&E===0)br.current=void 0,no.current=void 0,!fr&&be==="multi"&&(P.length!==Re?qe(lt.fromSingleSelection([0,Re]),void 0,S):qe(lt.empty(),void 0,S),sn());else{const re=no.current;if(ie==="multi"&&(f.shiftKey||f.isLongTouch===!0)&&re!==void 0&&X.hasIndex(re)){const Ae=[Math.min(re,E),Math.max(re,E)+1];S||f.isTouch||xe==="multi"?ze(void 0,Ae,S):ze(lt.fromSingleSelection(Ae),void 0,S)}else ie==="multi"&&(S||f.isTouch||xe==="multi")?(X.hasIndex(E)?ze(X.remove(E),void 0,S):ze(void 0,E,S),no.current=E):ie!=="none"&&(X.hasIndex(E)?ze(X.remove(E),void 0,S):ze(lt.fromSingleSelection(E),void 0,S),no.current=E);br.current=void 0,sn()}else f.kind===Ln?Pr.current=[E,O]:f.kind===Hi&&!f.isMaybeScrollbar&&(T(Ri,!1),i(void 0),sn(),$e==null||$e(),br.current=void 0,no.current=void 0)},[be,ie,W,en,$,Ct,Re,Vt,mn,vn,sn,it,xe,Mt,Do,qe,to,pr,Nn,_r,Sn,Ue,fr,ze,T,$e]),Ao=c.useRef(!1),Pr=c.useRef(),ma=c.useRef(rr),In=c.useRef(),Fu=c.useCallback(f=>{if(ro.current=!1,ma.current=Bt.current,f.button!==0&&f.button!==1){In.current=void 0;return}const S=performance.now();In.current={button:f.button,time:S,location:f.location},(f==null?void 0:f.kind)==="header"&&(Ao.current=!0);const R=f.kind==="cell"&&f.isFillHandle;!R&&f.kind!=="cell"&&f.isEdge||(u({previousSelection:W,fillHandle:R}),Pr.current=void 0,!f.isTouch&&f.button===0&&!R?$o(f):!f.isTouch&&f.button===1&&(Pr.current=f.location))},[W,$o]),[es,ts]=c.useState(),pa=c.useCallback(f=>{if(f.kind!==Ln||ie!=="multi")return;const S=Ni.value?f.metaKey:f.ctrlKey,[R]=f.location,E=W.columns;if(R<$)return;const O=Qe[R];let X=R,P=R;for(let N=R-1;N>=$&&Vo(O.group,Qe[N].group);N--)X--;for(let N=R+1;N<Qe.length&&Vo(O.group,Qe[N].group);N++)P++;if(sn(),S||f.isTouch||xe==="multi")if(E.hasAll([X,P+1])){let N=E;for(let K=X;K<=P;K++)N=N.remove(K);ze(N,void 0,S)}else ze(void 0,[X,P+1],S);else ze(lt.fromSingleSelection([X,P+1]),void 0,S)},[ie,sn,W.columns,Qe,$,ze,xe]),ro=c.useRef(!1),ui=c.useCallback(async f=>{if(Y!==void 0&&z!==void 0){const S=Bt.current.y,R=Bt.current.height;let E=Y({x:f,y:S,width:1,height:Math.min(R,Re-S)},I.current.signal);typeof E!="object"&&(E=await E());const O=jt[f-$],P=document.createElement("canvas").getContext("2d",{alpha:!1});if(P!==null){P.font=ut.baseFontFull;const N=_c(P,ut,O,0,E,hn,Jt,!1,Mt);z==null||z(O,N.width,f,N.width)}}},[jt,Y,Jt,ut,hn,z,$,Re,Mt]),[_u,ns]=c.useState(),oo=c.useCallback(async(f,S)=>{var N,K;const R=(N=f.current)==null?void 0:N.range;if(R===void 0||Y===void 0||S.current===void 0)return;const E=S.current.range;if(A!==void 0){let Q=!1;if(A({fillDestination:{...E,x:E.x-$},patternSource:{...R,x:R.x-$},preventDefault:()=>Q=!0}),Q)return}let O=Y(R,I.current.signal);typeof O!="object"&&(O=await O());const X=O,P=[];for(let Q=0;Q<E.width;Q++)for(let le=0;le<E.height;le++){const ve=[E.x+Q,E.y+le];if(kc(ve,R))continue;const re=X[le%R.height][Q%R.width];co(re)||!ao(re)||P.push({location:ve,value:{...re}})}Mn(P),(K=Kt.current)==null||K.damage(P.map(Q=>({cell:Q.location})))},[Y,Mn,A,$]),ba=c.useCallback(()=>{if(W.current===void 0||W.current.range.width<=1)return;const f={...W,current:{...W.current,range:{...W.current.range,width:1}}};oo(f,W)},[oo,W]),ya=c.useCallback(()=>{if(W.current===void 0||W.current.range.height<=1)return;const f={...W,current:{...W.current,range:{...W.current.range,height:1}}};oo(f,W)},[oo,W]),Pu=c.useCallback((f,S)=>{var le,ve;const R=l;if(u(void 0),qi(void 0),ns(void 0),Ao.current=!1,S)return;if((R==null?void 0:R.fillHandle)===!0&&W.current!==void 0&&((le=R.previousSelection)==null?void 0:le.current)!==void 0){if(Fr===void 0)return;const re={...W,current:{...W.current,range:Wc(R.previousSelection.current.range,Fr)}};oo(R.previousSelection,re),T(re,!0);return}const[E,O]=f.location,[X,P]=Pr.current??[],N=()=>{ro.current=!0},K=re=>{var we,We,Pe;const Ae=re.isTouch||X===E&&P===O;if(Ae&&(G==null||G([E-$,O],{...re,preventDefault:N})),re.button===1)return!ro.current;if(!ro.current){const Ie=mn(f.location),ht=Mt(Ie);if(ht!==void 0&&ht.onClick!==void 0&&Ae){const Lt=ht.onClick({...re,cell:Ie,posX:re.localEventX,posY:re.localEventY,bounds:re.bounds,theme:Do(Ie,f.location),preventDefault:N});Lt!==void 0&&!co(Lt)&&so(Lt)&&(Mn([{location:re.location,value:Lt}]),(we=Kt.current)==null||we.damage([{cell:re.location}]))}if(ro.current||W.current===void 0)return!1;let Dt=!1;switch(Ie.activationBehaviorOverride??Ve){case"double-click":case"second-click":{if(((Pe=(We=R==null?void 0:R.previousSelection)==null?void 0:We.current)==null?void 0:Pe.cell)===void 0)break;const[Lt,cn]=W.current.cell,[Yn,Bn]=R.previousSelection.current.cell;Dt=E===Lt&&E===Yn&&O===cn&&O===Bn&&(re.isDoubleClick===!0||Ve==="second-click");break}case"single-click":{Dt=!0;break}}if(Dt){const cn={inputType:"pointer",pointerActivation:re.isDoubleClick===!0?"double-click":Ie.activationBehaviorOverride??Ve,pointerType:re.isTouch?"touch":"mouse"};return B==null||B([E-$,O],cn),eo(re.bounds,cn),!0}}return!1},Q=f.location[0]-$;if(f.isTouch){const re=Bt.current,Ae=ma.current;if(re.x!==Ae.x||re.y!==Ae.y)return;if(f.isLongTouch===!0){if(f.kind==="cell"&&Xo((ve=W.current)==null?void 0:ve.cell,f.location)){Z==null||Z([Q,f.location[1]],{...f,preventDefault:N});return}else if(f.kind==="header"&&W.columns.hasIndex(E)){de==null||de(Q,{...f,preventDefault:N});return}else if(f.kind===Ln){if(Q<0)return;q==null||q(Q,{...f,preventDefault:N});return}}f.kind==="cell"?K(f)||$o(f):f.kind===Ln?U==null||U(Q,{...f,preventDefault:N}):(f.kind===Cr&&(j==null||j(Q,{...f,preventDefault:N})),$o(f));return}if(f.kind==="header"){if(Q<0)return;f.isEdge?f.isDoubleClick===!0&&ui(E):f.button===0&&E===X&&O===P&&(j==null||j(Q,{...f,preventDefault:N}))}if(f.kind===Ln){if(Q<0)return;f.button===0&&E===X&&O===P&&(U==null||U(Q,{...f,preventDefault:N}),ro.current||pa(f))}f.kind==="cell"&&(f.button===0||f.button===1)&&K(f),Pr.current=void 0},[l,W,$,Fr,oo,T,G,mn,Mt,Ve,Do,Mn,B,eo,Z,de,q,$o,U,j,ui,pa]),Ou=c.useCallback(f=>{const S={...f,location:[f.location[0]-$,f.location[1]]};Ke==null||Ke(S),l!==void 0&&f.buttons===0&&(u(void 0),qi(void 0),ns(void 0),Ao.current=!1),ns(R=>{var E;return Ao.current?[f.scrollEdge[0],0]:f.scrollEdge[0]===(R==null?void 0:R[0])&&f.scrollEdge[1]===R[1]?R:l===void 0||(((E=In.current)==null?void 0:E.location[0])??0)<$?void 0:f.scrollEdge})},[l,Ke,$]),ju=c.useCallback((f,S)=>{dt==null||dt(f-$,S)},[dt,$]),Nu=c.useCallback((f,S)=>{Ne==null||Ne(f-$,S)},[Ne,$]),Kn=(Ma=W==null?void 0:W.current)==null?void 0:Ma.cell,Hu=c.useCallback((f,S,R,E,O,X)=>{Ar.current=!1;let P=Kn;P!==void 0&&(P=[P[0]-$,P[1]]);const N=Ye===0?void 0:{x:0,y:f.y,width:Ye,height:f.height},K=[];N!==void 0&&K.push(N),It>0&&(K.push({x:f.x-$,y:Re-It,width:f.width,height:It}),Ye>0&&K.push({x:0,y:Re-It,width:Ye,height:It}));const Q={x:f.x-$,y:f.y,width:f.width,height:Ct&&f.y+f.height>=Re?f.height-1:f.height,tx:O,ty:X,extras:{selected:P,freezeRegion:N,freezeRegions:K}};Bt.current=Q,mr(Q),On([S,R,E]),Ht==null||Ht(Q,Q.tx,Q.ty,Q.extras)},[Kn,$,Ct,Re,Ye,It,mr,Ht]),Bu=xr(_,c.useCallback((f,S)=>(_==null?void 0:_(f-$,S-$))!==!1,[_,$])),Lu=xr(_e,c.useCallback((f,S)=>{_e==null||_e(f-$,S-$),ie!=="none"&&ze(lt.fromSingleSelection(S),void 0,!0)},[ie,_e,$,ze])),rs=c.useRef(!1),zu=c.useCallback(f=>{if(f.location[0]===0&&$>0){f.preventDefault();return}Le==null||Le({...f,location:[f.location[0]-$,f.location[1]]}),f.defaultPrevented()||(rs.current=!0),u(void 0)},[Le,$]),Wu=c.useCallback(()=>{rs.current=!1},[]),va=st==null?void 0:st.selectionBehavior,di=c.useCallback(f=>{if(va!=="block-spanning")return;const{isGroupHeader:S,path:R,groupRows:E}=_r(f);if(S)return[f,f];const O=R[R.length-1],X=f-O,P=f+E-O-1;return[X,P]},[_r,va]),os=c.useRef(),is=c.useCallback(f=>{var S,R,E;if(!iu(f,os.current)&&(os.current=f,!(((S=In==null?void 0:In.current)==null?void 0:S.button)!==void 0&&In.current.button>=1))){if(f.buttons!==0&&l!==void 0&&((R=In.current)==null?void 0:R.location[0])===0&&$===1&&be==="multi"&&l.previousSelection&&!l.previousSelection.rows.hasIndex(In.current.location[1])&&W.rows.hasIndex(In.current.location[1])){const O=Math.min(In.current.location[1],f.location[1]),X=Math.max(In.current.location[1],f.location[1])+1;qe(lt.fromSingleSelection([O,X]),void 0,!1)}else if(f.buttons!==0&&l!==void 0&&W.current!==void 0&&!rs.current&&!Ao.current&&(pt==="rect"||pt==="multi-rect")){const[O,X]=W.current.cell;let[P,N]=f.location;if(N<0&&(N=Bt.current.y),l.fillHandle===!0&&((E=l.previousSelection)==null?void 0:E.current)!==void 0){const K=l.previousSelection.current.range;N=Math.min(N,Ct?Re-1:Re);const Q=e0(K,P,N,$t);qi(Q)}else{if(Ct&&X===Re)return;if(Ct&&N===Re)if(f.kind===Hi)N--;else return;P=Math.max(P,$);const le=di(X);N=le===void 0?N:En(N,le[0],le[1]);const ve=P-O,re=N-X,Ae={x:ve>=0?O:P,y:re>=0?X:N,width:Math.abs(ve)+1,height:Math.abs(re)+1};Ue({...W.current,range:Ae},!0,!1,"drag")}}ct==null||ct({...f,location:[f.location[0]-$,f.location[1]]})}},[l,$,be,W,pt,ct,qe,Ct,Re,$t,di,Ue]),Gu=c.useCallback(()=>{var P,N;const f=os.current;if(f===void 0)return;const[S,R]=f.scrollEdge;let[E,O]=f.location;const X=Bt.current;S===-1?E=((N=(P=X.extras)==null?void 0:P.freezeRegion)==null?void 0:N.x)??X.x:S===1&&(E=X.x+X.width),R===-1?O=Math.max(0,X.y):R===1&&(O=Math.min(Re-1,X.y+X.height)),E=En(E,0,Qe.length-1),O=En(O,0,Re-1),is({...f,location:[E,O]})},[Qe.length,is,Re]);dk(_u,St,Gu);const Hn=c.useCallback(f=>{if(W.current===void 0)return;const[S,R]=f,[E,O]=W.current.cell,X=W.current.range;let P=X.x,N=X.x+X.width,K=X.y,Q=X.y+X.height;const[le,ve]=di(O)??[0,Re-1],re=ve+1;if(R!==0)switch(R){case 2:{Q=re,K=O,Pt(0,Q,"vertical");break}case-2:{K=le,Q=O+1,Pt(0,K,"vertical");break}case 1:{K<O?(K++,Pt(0,K,"vertical")):(Q=Math.min(re,Q+1),Pt(0,Q,"vertical"));break}case-1:{Q>O+1?(Q--,Pt(0,Q,"vertical")):(K=Math.max(le,K-1),Pt(0,K,"vertical"));break}default:qo()}if(S!==0)if(S===2)N=Qe.length,P=E,Pt(N-1-$,0,"horizontal");else if(S===-2)P=$,N=E+1,Pt(P-$,0,"horizontal");else{let Ae=[];if(Y!==void 0){const we=Y({x:P,y:K,width:N-P-$,height:Q-K},I.current.signal);typeof we=="object"&&(Ae=xk(we))}if(S===1){let we=!1;if(P<E){if(Ae.length>0){const We=Br(P+1,E+1).find(Pe=>!Ae.includes(Pe-$));We!==void 0&&(P=We,we=!0)}else P++,we=!0;we&&Pt(P,0,"horizontal")}we||(N=Math.min(Qe.length,N+1),Pt(N-1-$,0,"horizontal"))}else if(S===-1){let we=!1;if(N>E+1){if(Ae.length>0){const We=Br(N-1,E,-1).find(Pe=>!Ae.includes(Pe-$));We!==void 0&&(N=We,we=!0)}else N--,we=!0;we&&Pt(N-$,0,"horizontal")}we||(P=Math.max($,P-1),Pt(P-$,0,"horizontal"))}else qo()}Ue({cell:W.current.cell,range:{x:P,y:K,width:N-P,height:Q-K}},!0,!1,"keyboard-select")},[Y,di,W,Qe.length,$,Re,Pt,Ue]),ss=c.useRef(Cn);ss.current=Cn;const yr=c.useCallback((f,S,R,E)=>{const O=nn-(R?0:1);f=En(f,$,jt.length-1+$),S=En(S,0,O);const X=Kn==null?void 0:Kn[0],P=Kn==null?void 0:Kn[1];if(f===X&&S===P)return!1;if(E&&W.current!==void 0){const N=[...W.current.rangeStack];(W.current.range.width>1||W.current.range.height>1)&&N.push(W.current.range),T({...W,current:{cell:[f,S],range:{x:f,y:S,width:1,height:1},rangeStack:N}},!0)}else Ue({cell:[f,S],range:{x:f,y:S,width:1,height:1}},!0,!1,"keyboard-nav");return d.current!==void 0&&d.current[0]===f&&d.current[1]===S&&(d.current=void 0),ss.current&&Pt(f-$,S),!0},[nn,$,jt.length,Kn,W,Pt,T,Ue]),Uu=c.useCallback((f,S)=>{(o==null?void 0:o.cell)!==void 0&&f!==void 0&&so(f)&&(Mn([{location:o.cell,value:f}]),window.requestAnimationFrame(()=>{var O;(O=Kt.current)==null||O.damage([{cell:o.cell}])})),sn(!0),i(void 0);const[R,E]=S;if(W.current!==void 0&&(R!==0||E!==0)){const O=W.current.cell[1]===nn-1&&f!==void 0,X=W.current.cell[0]===Qe.length-1&&f!==void 0;let P=!0;if(O&&E===1&&Te!==void 0){P=!1;const N=W.current.cell[0]+R,K=to(N);pr(K??N,!1)}if(X&&R===1&&Fe!==void 0){P=!1;const N=W.current.cell[1]+E;ci(N,!1)}P&&yr(En(W.current.cell[0]+R,0,Qe.length-1),En(W.current.cell[1]+E,0,nn-1),O,!1)}L==null||L(f,S)},[o==null?void 0:o.cell,sn,W,L,Mn,nn,yr,Qe.length,pr,ci,Te,Fe,to]),Xu=c.useMemo(()=>`gdg-overlay-${wk++}`,[]),Or=c.useCallback(f=>{var R,E,O,X;sn();const S=[];for(let P=f.x;P<f.x+f.width;P++)for(let N=f.y;N<f.y+f.height;N++){const K=M([P-$,N]);if(!K.allowOverlay&&K.kind!==ce.Boolean)continue;let Q;if(K.kind===ce.Custom){const le=Mt(K),ve=(R=le==null?void 0:le.provideEditor)==null?void 0:R.call(le,{...K,location:[P-$,N]});(le==null?void 0:le.onDelete)!==void 0?Q=le.onDelete(K):ep(ve)&&(Q=(E=ve==null?void 0:ve.deletedValue)==null?void 0:E.call(ve,K))}else if(so(K)&&K.allowOverlay||K.kind===ce.Boolean){const le=Mt(K);Q=(O=le==null?void 0:le.onDelete)==null?void 0:O.call(le,K)}Q!==void 0&&!co(Q)&&so(Q)&&S.push({location:[P,N],value:Q})}Mn(S),(X=Kt.current)==null||X.damage(S.map(P=>({cell:P.location})))},[sn,M,Mt,Mn,$]),Fo=o!==void 0,wa=c.useCallback(f=>{var We,Pe;const S=()=>{f.stopPropagation(),f.preventDefault()},R={didMatch:!1},{bounds:E}=f,O=W.columns,X=W.rows,P=gn;if(!Fo&&Ze(P.clear,f,R))T(Ri,!1),$e==null||$e();else if(!Fo&&Ze(P.selectAll,f,R))T({columns:lt.empty(),rows:lt.empty(),current:{cell:((We=W.current)==null?void 0:We.cell)??[$,0],range:{x:$,y:0,width:C.length,height:Re},rangeStack:[]}},!1);else if(Ze(P.search,f,R))(Pe=a==null?void 0:a.current)==null||Pe.focus({preventScroll:!0}),Pn(!0);else if(Ze(P.delete,f,R)){const Ie=(at==null?void 0:at(W))??!0;if(Ie!==!1){const ht=Ie===!0?W:Ie;if(ht.current!==void 0){Or(ht.current.range);for(const Dt of ht.current.rangeStack)Or(Dt)}for(const Dt of ht.rows)Or({x:$,y:Dt,width:C.length,height:1});for(const Dt of ht.columns)Or({x:Dt,y:0,width:1,height:Re})}}if(R.didMatch)return S(),!0;if(W.current===void 0)return!1;let[N,K]=W.current.cell;const[,Q]=W.current.cell;let le=!1,ve=!1;if(Ze(P.scrollToSelectedCell,f,R))gi.current(N-$,K);else if(ie!=="none"&&Ze(P.selectColumn,f,R))O.hasIndex(N)?ze(O.remove(N),void 0,!0):ie==="single"?ze(lt.fromSingleSelection(N),void 0,!0):ze(void 0,N,!0);else if(be!=="none"&&Ze(P.selectRow,f,R))X.hasIndex(K)?qe(X.remove(K),void 0,!0):be==="single"?qe(lt.fromSingleSelection(K),void 0,!0):qe(void 0,K,!0);else if(!Fo&&E!==void 0&&Ze(P.activateCell,f,R))if(K===Re&&Ct)window.setTimeout(()=>{const Ie=to(N);pr(Ie??N)},0);else{const Ie={inputType:"keyboard",key:f.key};B==null||B([N-$,K],Ie),eo(E,Ie)}else W.current.range.height>1&&Ze(P.downFill,f,R)?ya():W.current.range.width>1&&Ze(P.rightFill,f,R)?ba():Ze(P.goToNextPage,f,R)?K+=Math.max(1,Bt.current.height-4):Ze(P.goToPreviousPage,f,R)?K-=Math.max(1,Bt.current.height-4):Ze(P.goToFirstCell,f,R)?(i(void 0),K=0,N=0):Ze(P.goToLastCell,f,R)?(i(void 0),K=Number.MAX_SAFE_INTEGER,N=Number.MAX_SAFE_INTEGER):Ze(P.selectToFirstCell,f,R)?(i(void 0),Hn([-2,-2])):Ze(P.selectToLastCell,f,R)?(i(void 0),Hn([2,2])):Fo?(Ze(P.closeOverlay,f,R)&&i(void 0),Ze(P.acceptOverlayDown,f,R)&&(i(void 0),K++),Ze(P.acceptOverlayUp,f,R)&&(i(void 0),K--),Ze(P.acceptOverlayLeft,f,R)&&(i(void 0),N--),Ze(P.acceptOverlayRight,f,R)&&(i(void 0),N++)):(Ze(P.goDownCell,f,R)?K+=1:Ze(P.goUpCell,f,R)?K-=1:Ze(P.goRightCell,f,R)?N+=1:Ze(P.goLeftCell,f,R)?N-=1:Ze(P.goDownCellRetainSelection,f,R)?(K+=1,le=!0):Ze(P.goUpCellRetainSelection,f,R)?(K-=1,le=!0):Ze(P.goRightCellRetainSelection,f,R)?(N+=1,le=!0):Ze(P.goLeftCellRetainSelection,f,R)?(N-=1,le=!0):Ze(P.goToLastRow,f,R)?K=Re-1:Ze(P.goToFirstRow,f,R)?K=Number.MIN_SAFE_INTEGER:Ze(P.goToLastColumn,f,R)?N=Number.MAX_SAFE_INTEGER:Ze(P.goToFirstColumn,f,R)?N=Number.MIN_SAFE_INTEGER:(pt==="rect"||pt==="multi-rect")&&(Ze(P.selectGrowDown,f,R)?Hn([0,1]):Ze(P.selectGrowUp,f,R)?Hn([0,-1]):Ze(P.selectGrowRight,f,R)?Hn([1,0]):Ze(P.selectGrowLeft,f,R)?Hn([-1,0]):Ze(P.selectToLastRow,f,R)?Hn([0,2]):Ze(P.selectToFirstRow,f,R)?Hn([0,-2]):Ze(P.selectToLastColumn,f,R)?Hn([2,0]):Ze(P.selectToFirstColumn,f,R)&&Hn([-2,0])),ve=R.didMatch);if(Nn!==void 0&&Nn!=="normal"&&K!==Q){const Ie=Nn==="skip-up"||Nn==="skip"||Nn==="block",ht=Nn==="skip-down"||Nn==="skip"||Nn==="block",Dt=K<Q;if(Dt&&Ie){for(;K>=0&&_r(K).isGroupHeader;)K--;K<0&&(K=Q)}else if(!Dt&&ht){for(;K<Re&&_r(K).isGroupHeader;)K++;K>=Re&&(K=Q)}}const Ae=yr(N,K,!1,le),we=R.didMatch;return we&&(Ae||!ve||An)&&S(),we},[Nn,Fo,W,gn,ie,be,pt,$,_r,Re,yr,T,$e,C.length,at,An,Or,ze,qe,Ct,to,pr,B,eo,ya,ba,Hn]),_o=c.useCallback(f=>{let S=!1;if(Ge!==void 0&&Ge({...f,...f.location&&{location:[f.location[0]-$,f.location[1]]},cancel:()=>{S=!0}}),S||wa(f)||W.current===void 0)return;const[R,E]=W.current.cell,O=Bt.current;if(je&&!f.metaKey&&!f.ctrlKey&&W.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&&ao(M([R-$,Math.max(0,Math.min(E,Re-1))]))){if((!Ct||E!==Re)&&(O.y>E||E>O.y+O.height||O.x>R||R>O.x+O.width))return;const X={inputType:"keyboard",key:f.key};B==null||B([R-$,E],X),eo(f.bounds,X,f.key),f.stopPropagation(),f.preventDefault()}},[je,Ge,wa,W,M,$,Re,Ct,B,eo]),Ku=c.useCallback((f,S)=>{const R=f.location[0]-$;if(f.kind==="header"&&(de==null||de(R,{...f,preventDefault:S})),f.kind===Ln){if(R<0)return;q==null||q(R,{...f,preventDefault:S})}if(f.kind==="cell"){const[E,O]=f.location;Z==null||Z([R,O],{...f,preventDefault:S}),Vp(W,f.location)||yr(E,O,!1,!1)}},[W,Z,q,de,$,yr]),as=c.useCallback(async f=>{var P,N,K;if(!gn.paste)return;function S(Q,le,ve,re){var we,We;const Ae=typeof ve=="object"?(ve==null?void 0:ve.join(`
14
+ `&&(n.push(r),r=[])),i=t.None);break}a++}return o<e.length&&r.push(Hl(e.slice(o,e.length))),n.push(r),n.map(s=>s.map(l=>({rawValue:l,formatted:l,format:"string"})))}function Bl(e,t,n){var s;const r=rk(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 au(e){return e!==!0}function Ll(e){return typeof e=="string"?e:`${e}px`}const sk=()=>e=>e.innerWidth,ak=()=>e=>e.innerHeight,lk=Sr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[sk()],"wmyidgi-1":[ak()]}}),ck=e=>{const{inWidth:t,inHeight:n,children:r,...o}=e;return c.createElement(lk,{innerHeight:Ll(n),innerWidth:Ll(t),...o},r)},uk=2,dk=1300;function fk(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/dk);const m=r.current**1.618*h*uk;(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 hk({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,b=e,x=Fc();return[typeof b=="number"?b*g:C=>Math.ceil(b(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 wr={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 et(e,t){return e===!0?t:e===!1?"":e}function zl(e){const t=Ni.value;return{activateCell:et(e.activateCell," |Enter|shift+Enter"),clear:et(e.clear,"any+Escape"),closeOverlay:et(e.closeOverlay,"any+Escape"),acceptOverlayDown:et(e.acceptOverlayDown,"Enter"),acceptOverlayUp:et(e.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:et(e.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:et(e.acceptOverlayRight,"Tab"),copy:e.copy,cut:e.cut,delete:et(e.delete,t?"Backspace|Delete":"Delete"),downFill:et(e.downFill,"primary+_68"),scrollToSelectedCell:et(e.scrollToSelectedCell,"primary+Enter"),goDownCell:et(e.goDownCell,"ArrowDown"),goDownCellRetainSelection:et(e.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:et(e.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:et(e.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:et(e.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:et(e.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:et(e.goUpCell,"ArrowUp"),goUpCellRetainSelection:et(e.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:et(e.goToFirstCell,"primary+Home"),goToFirstColumn:et(e.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:et(e.goToFirstRow,"primary+ArrowUp"),goToLastCell:et(e.goToLastCell,"primary+End"),goToLastColumn:et(e.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:et(e.goToLastRow,"primary+ArrowDown"),goToNextPage:et(e.goToNextPage,"PageDown"),goToPreviousPage:et(e.goToPreviousPage,"PageUp"),paste:e.paste,rightFill:et(e.rightFill,"primary+_82"),search:et(e.search,"primary+f"),selectAll:et(e.selectAll,"primary+a"),selectColumn:et(e.selectColumn,"ctrl+ "),selectGrowDown:et(e.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:et(e.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:et(e.selectGrowRight,"shift+ArrowRight"),selectGrowUp:et(e.selectGrowUp,"shift+ArrowUp"),selectRow:et(e.selectRow,"shift+ "),selectToFirstCell:et(e.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:et(e.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:et(e.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:et(e.selectToLastCell,"primary+shift+End"),selectToLastColumn:et(e.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:et(e.selectToLastRow,"primary+shift+ArrowDown")}}function gk(e){const t=Hp(e);return zt.useMemo(()=>{if(t===void 0)return zl(wr);const n={...t,goToNextPage:(t==null?void 0:t.goToNextPage)??(t==null?void 0:t.pageDown)??wr.goToNextPage,goToPreviousPage:(t==null?void 0:t.goToPreviousPage)??(t==null?void 0:t.pageUp)??wr.goToPreviousPage,goToFirstCell:(t==null?void 0:t.goToFirstCell)??(t==null?void 0:t.first)??wr.goToFirstCell,goToLastCell:(t==null?void 0:t.goToLastCell)??(t==null?void 0:t.last)??wr.goToLastCell,selectToFirstCell:(t==null?void 0:t.selectToFirstCell)??(t==null?void 0:t.first)??wr.selectToFirstCell,selectToLastCell:(t==null?void 0:t.selectToLastCell)??(t==null?void 0:t.last)??wr.selectToLastCell};return zl({...wr,...n})},[t])}function mk(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=mk(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 pk(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=xr(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 bk(e,t){const n=zt.useMemo(()=>e===void 0?void 0:la(e,t),[e,t]);return{getRowGroupingForPath:cu,updateRowGroupingByPath:lu,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 lu(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:lu(i.subGroups??[],o,n)}:i)}function cu(e,t){const[n,...r]=t;return r[0]===-1?e[n]:cu(e[n].subGroups??[],r)}function yk(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 vk(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]=jp(s),h=c.useRef(o);h.current=o;const m=yk(null,b=>{b!==null&&t!==void 0?b.scrollTop=t:b!==null&&e!==void 0&&(b.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 wk=c.lazy(async()=>await ec(()=>import("./data-grid-overlay-editor-PtH7A6E4.js"),__vite__mapDeps([0,1,2])));let xk=0;function Ck(e){return by(ll(ll(e).filter(t=>t.span!==void 0).map(t=>{var n,r;return Br((((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:ce.Loading,allowOverlay:!1},Ri={columns:lt.empty(),rows:lt.empty(),current:void 0},kk=(e,t)=>{var Ra,Ma,Ia;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:b,height:x,columns:C,rows:w,getCellContent:M,onCellClicked:G,onCellActivated:B,onFillPattern:A,onFinishedEditing:L,coercePasteValue:V,drawHeader:k,drawCell:F,editorBloom:H,onHeaderClicked:j,onColumnProposeMove:_,rangeSelectionColumnSpanning:D=!0,spanRangeBehavior:fe="default",onGroupHeaderClicked:U,onCellContextMenu:Z,className:he,onHeaderContextMenu:de,getCellsForSelection:ee,onGroupHeaderContextMenu:q,onGroupHeaderRenamed:Se,onCellEdited:se,onCellsEdited:oe,onSearchResultsChanged:Ee,searchResults:J,onSearchValueChange:ae,searchValue:pe,onKeyDown:Ge,onKeyUp:Oe,keybindings:rt,editOnType:je=!0,onRowAppended:Te,onColumnAppended:Fe,onColumnMoved:_e,validateCell:mt,highlightRegions:xt,rangeSelect:pt="rect",columnSelect:ie="multi",rowSelect:be="multi",rangeSelectionBlending:Me="exclusive",columnSelectionBlending:De="exclusive",rowSelectionBlending:ke="exclusive",onDelete:ot,onDragStart:Le,onMouseMove:Ke,onPaste:ue,copyHeaders:ye=!1,freezeColumns:Ye=0,cellActivationBehavior:Ve="second-click",rowSelectionMode:it="auto",columnSelectionMode:xe="auto",onHeaderMenuClick:dt,onHeaderIndicatorClick:Ne,getGroupDetails:He,rowGrouping:st,onSearchClose:Wt,onItemHovered:ct,onSelectionCleared:$e,showSearch:bt,onVisibleRegionChanged:Ht,gridSelection:Yt,onGridSelectionChange:vt,minColumnWidth:yn=50,maxColumnWidth:dn=500,maxColumnAutoWidth:kt,provideEditor:Ut,trailingRowOptions:Je,freezeTrailingRows:It=0,allowedFillDirections:$t="orthogonal",scrollOffsetX:tt,scrollOffsetY:Rt,verticalBorder:gt,onDragOverCell:qt,onDrop:Nt,onColumnResize:Ot,onColumnResizeEnd:Gt,onColumnResizeStart:Be,customRenderers:$n,fillHandle:At,experimental:nt,fixedShadowX:Xt,fixedShadowY:Et,headerIcons:Jt,imageWindowLoader:ln,initialSize:Ft,isDraggable:Zn,onDragLeave:Ir,onRowMoved:vn,overscrollX:rn,overscrollY:wn,preventDiagonalScrolling:zn,rightElement:Wn,rightElementProps:Gn,trapFocus:An=!1,smoothScrollX:Ro,smoothScrollY:Ur,scaleToRem:Mo=!1,rowHeight:er=34,headerHeight:fn=36,groupHeaderHeight:xn=fn,theme:Io,isOutsideClick:Xr,renderers:sr,resizeIndicator:Kr,scrollToActiveCell:Cn=!0,drawFocusRing:ar=!0,portalElementRef:Yr}=e,lr=ar==="no-editor"?o===void 0:ar,yt=typeof e.rowMarkers=="string"?void 0:e.rowMarkers,Vt=(yt==null?void 0:yt.kind)??e.rowMarkers??"none",cr=(yt==null?void 0:yt.width)??e.rowMarkerWidth,Fn=(yt==null?void 0:yt.startIndex)??e.rowMarkerStartIndex??1,ur=(yt==null?void 0:yt.theme)??e.rowMarkerTheme,Un=yt==null?void 0:yt.headerTheme,dr=yt==null?void 0:yt.headerAlwaysVisible,fr=be!=="multi"||(yt==null?void 0:yt.headerDisabled)===!0,on=(yt==null?void 0:yt.checkboxStyle)??"square",hn=Math.max(yn,20),Qt=Math.max(dn,hn),Eo=Math.max(kt??Qt,hn),Er=c.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),{rows:Re,rowNumberMapper:hr,rowHeight:_n,getRowThemeOverride:Zt}=pk(st,w,er,p),Tr=c.useMemo(()=>Number.parseFloat(Er.fontSize),[Er]),{rowHeight:kn,headerHeight:Dr,groupHeaderHeight:$r,theme:tr,overscrollX:qr,overscrollY:Vr}=hk({groupHeaderHeight:xn,headerHeight:fn,overscrollX:rn,overscrollY:wn,remSize:Tr,rowHeight:_n,scaleToRem:Mo,theme:Io}),gn=gk(rt),Xn=cr??(w>1e4?48:w>1e3?44:w>100?36:32),en=Vt!=="none",$=en?1:0,Ct=Je!==void 0,Sn=(Je==null?void 0:Je.sticky)===!0,[Jr,Pn]=c.useState(!1),To=bt??Jr,gr=c.useCallback(()=>{Wt!==void 0?Wt():Pn(!1)},[Wt]),W=c.useMemo(()=>Yt===void 0?void 0:ki(Yt,$),[Yt,$])??n,I=c.useRef();I.current===void 0&&(I.current=new AbortController),c.useEffect(()=>()=>I==null?void 0:I.current.abort(),[]);const[Y,ge]=JC(ee,M,$,I.current,Re),me=c.useCallback((f,S,R)=>{if(mt===void 0)return!0;const E=[f[0]-$,f[1]];return mt==null?void 0:mt(E,S,R)},[$,mt]),y=c.useRef(Yt),T=c.useCallback((f,S)=>{S&&(f=ok(f,Y,$,fe,I.current)),vt!==void 0?(y.current=ki(f,-$),vt(y.current)):r(f)},[vt,Y,$,fe]),z=xr(Ot,c.useCallback((f,S,R,E)=>{Ot==null||Ot(C[R-$],S,R-$,E)},[Ot,$,C])),ne=xr(Gt,c.useCallback((f,S,R,E)=>{Gt==null||Gt(C[R-$],S,R-$,E)},[Gt,$,C])),te=xr(Be,c.useCallback((f,S,R,E)=>{Be==null||Be(C[R-$],S,R-$,E)},[Be,$,C])),ft=xr(k,c.useCallback((f,S)=>(k==null?void 0:k({...f,columnIndex:f.columnIndex-$},S))??!1,[k,$])),Ce=xr(F,c.useCallback((f,S)=>(F==null?void 0:F({...f,col:f.col-$},S))??!1,[F,$])),at=c.useCallback(f=>{if(ot!==void 0){const S=ot(ki(f,-$));return typeof S=="boolean"?S:ki(S,$)}return!0},[ot,$]),[Ue,qe,ze]=VC(W,T,Me,De,ke,pt,D),ut=c.useMemo(()=>ir(Fc(),tr),[tr]),[_t,On]=c.useState([0,0,0]),jn=c.useMemo(()=>{if(sr===void 0)return{};const f={};for(const S of sr)f[S.kind]=S;return f},[sr]),Mt=c.useCallback(f=>f.kind!==ce.Custom?jn[f.kind]:$n==null?void 0:$n.find(S=>S.isMatch(f)),[$n,jn]);let{sizedColumns:jt,nonGrowWidth:wt}=bb(C,Re,ge,_t[0]-($===0?0:Xn)-_t[2],hn,Eo,ut,Mt,I.current);Vt!=="none"&&(wt+=Xn);const Rn=c.useMemo(()=>jt.some(f=>f.group!==void 0),[jt]),tn=Rn?Dr+$r:Dr,Qr=W.rows.length,nr=Vt==="none"?void 0:Qr===0?!1:Qr===Re?!0:void 0,Qe=c.useMemo(()=>Vt==="none"?jt:[{title:"",width:Xn,icon:void 0,hasMenu:!1,style:"normal",themeOverride:ur,rowMarker:on,rowMarkerChecked:nr,headerRowMarkerTheme:Un,headerRowMarkerAlwaysVisible:dr,headerRowMarkerDisabled:fr},...jt],[Vt,jt,Xn,ur,on,nr,Un,dr,fr]),Bt=c.useRef({height:1,width:1,x:0,y:0}),Ar=c.useRef(!1),{setVisibleRegion:mr,visibleRegion:rr,scrollRef:St}=vk(tt,Rt,kn,Bt,()=>Ar.current=!0);Bt.current=rr;const $u=rr.x+$,oi=rr.y,Kt=c.useRef(null),sn=c.useCallback(f=>{var S;f===!0?(S=Kt.current)==null||S.focus():window.requestAnimationFrame(()=>{var R;(R=Kt.current)==null||R.focus()})},[]),nn=Ct?Re+1:Re,Mn=c.useCallback(f=>{const S=$===0?f:f.map(E=>({...E,location:[E.location[0]-$,E.location[1]]})),R=oe==null?void 0:oe(S);if(R!==!0)for(const E of S)se==null||se(E.location,E.value);return R},[se,oe,$]),[Fr,qi]=c.useState(),ii=W.current!==void 0&&W.current.range.width*W.current.range.height>1?W.current.range:void 0,Zr=lr?(Ra=W.current)==null?void 0:Ra.cell:void 0,si=Zr==null?void 0:Zr[0],ai=Zr==null?void 0:Zr[1],Au=c.useMemo(()=>{if((xt===void 0||xt.length===0)&&(ii??si??ai??Fr)===void 0)return;const f=[];if(xt!==void 0)for(const S of xt){const R=Qe.length-S.range.x-$;R>0&&f.push({color:S.color,range:{...S.range,x:S.range.x+$,width:Math.min(R,S.range.width)},style:S.style})}return Fr!==void 0&&f.push({color:Lr(ut.accentColor,0),range:Fr,style:"dashed"}),ii!==void 0&&f.push({color:Lr(ut.accentColor,.5),range:ii,style:"solid-outline"}),si!==void 0&&ai!==void 0&&f.push({color:ut.accentColor,range:{x:si,y:ai,width:1,height:1},style:"solid-outline"}),f.length>0?f:void 0},[Fr,ii,si,ai,xt,Qe.length,ut.accentColor,$]),fa=c.useRef(Qe);fa.current=Qe;const mn=c.useCallback(([f,S],R=!1)=>{var X,P,N,K,Q,le,ve;const E=Ct&&S===nn-1;if(f===0&&en){if(E)return Si;const re=hr(S);return re===void 0?Si:{kind:Tn.Marker,allowOverlay:!1,checkboxStyle:on,checked:(W==null?void 0:W.rows.hasIndex(S))===!0,markerKind:Vt==="clickable-number"?"number":Vt,row:Fn+re,drawHandle:vn!==void 0,cursor:Vt==="clickable-number"?"pointer":void 0}}else if(E){const Ae=f===$?(Je==null?void 0:Je.hint)??"":"",we=fa.current[f];if(((X=we==null?void 0:we.trailingRowOptions)==null?void 0:X.disabled)===!0)return Si;{const We=((P=we==null?void 0:we.trailingRowOptions)==null?void 0:P.hint)??Ae,Pe=((N=we==null?void 0:we.trailingRowOptions)==null?void 0:N.addIcon)??(Je==null?void 0:Je.addIcon);return{kind:Tn.NewRow,hint:We,allowOverlay:!1,icon:Pe}}}else{const re=f-$;if(R||(nt==null?void 0:nt.strict)===!0){const we=Bt.current,We=we.x>re||re>we.x+we.width||we.y>S||S>we.y+we.height||S>=Zi.current,Pe=re===((Q=(K=we.extras)==null?void 0:K.selected)==null?void 0:Q[0])&&S===((le=we.extras)==null?void 0:le.selected[1]);let Ie=!1;if(((ve=we.extras)==null?void 0:ve.freezeRegions)!==void 0){for(const ht of we.extras.freezeRegions)if(go(ht,re,S)){Ie=!0;break}}if(We&&!Pe&&!Ie)return Si}let Ae=M([re,S]);return $!==0&&Ae.span!==void 0&&(Ae={...Ae,span:[Ae.span[0]+$,Ae.span[1]+$]}),Ae}},[Ct,nn,en,hr,on,W==null?void 0:W.rows,Vt,Fn,vn,$,Je==null?void 0:Je.hint,Je==null?void 0:Je.addIcon,nt==null?void 0:nt.strict,M]),Vi=c.useCallback(f=>{let S=(He==null?void 0:He(f))??{name:f};return Se!==void 0&&f!==""&&(S={icon:S.icon,name:S.name,overrideTheme:S.overrideTheme,actions:[...S.actions??[],{title:"Rename",icon:"renameIcon",onClick:R=>ts({group:S.name,bounds:R.bounds})}]}),S},[He,Se]),li=c.useCallback(f=>{var N;const[S,R]=f.cell,E=Qe[S],O=(E==null?void 0:E.group)!==void 0?(N=Vi(E.group))==null?void 0:N.overrideTheme:void 0,X=E==null?void 0:E.themeOverride,P=Zt==null?void 0:Zt(R);i({...f,theme:ir(ut,O,X,P,f.content.themeOverride)})},[Zt,Qe,Vi,ut]),eo=c.useCallback((f,S,R)=>{var P;if(W.current===void 0)return;const[E,O]=W.current.cell,X=mn([E,O]);if(X.kind!==ce.Boolean&&X.allowOverlay){let N=X;if(R!==void 0)switch(N.kind){case ce.Number:{const K=ep(()=>R==="-"?-0:Number.parseFloat(R),0);N={...N,data:Number.isNaN(K)?0:K};break}case ce.Text:case ce.Markdown:case ce.Uri:N={...N,data:R};break}li({target:f,content:N,initialValue:R,cell:[E,O],highlight:R===void 0,forceEditMode:R!==void 0,activation:S})}else X.kind===ce.Boolean&&S.inputType==="keyboard"&&X.readonly!==!0&&(Mn([{location:W.current.cell,value:{...X,data:au(X.data)}}]),(P=Kt.current)==null||P.damage([{cell:W.current.cell}]))},[mn,W,Mn,li]),ha=c.useCallback((f,S)=>{var O;const R=(O=Kt.current)==null?void 0:O.getBounds(f,S);if(R===void 0||St.current===null)return;const E=mn([f,S]);E.allowOverlay&&li({target:R,content:E,initialValue:void 0,highlight:!0,cell:[f,S],forceEditMode:!0,activation:{inputType:"keyboard",key:"Enter"}})},[mn,St,li]),Pt=c.useCallback((f,S,R="both",E=0,O=0,X=void 0)=>{if(St.current!==null){const P=Kt.current,N=s.current,K=typeof f!="number"?f.unit==="cell"?f.amount:void 0:f,Q=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,le=typeof f!="number"&&f.unit==="px"?f.amount:void 0,ve=typeof S!="number"&&S.unit==="px"?S.amount:void 0;if(P!==null&&N!==null){let re={x:0,y:0,width:0,height:0},Ae=0,we=0;if((K!==void 0||Q!==void 0)&&(re=P.getBounds((K??0)+$,Q??0)??re,re.width===0||re.height===0))return;const We=N.getBoundingClientRect(),Pe=We.width/N.offsetWidth;if(le!==void 0&&(re={...re,x:le-We.left-St.current.scrollLeft,width:1}),ve!==void 0&&(re={...re,y:ve+We.top-St.current.scrollTop,height:1}),re!==void 0){const Ie={x:re.x-E,y:re.y-O,width:re.width+2*E,height:re.height+2*O};let ht=0;for(let ls=0;ls<Ye;ls++)ht+=jt[ls].width;let Dt=0;const Lt=It+(Sn?1:0);Lt>0&&(Dt=Gr(nn,Lt,kn));let cn=ht*Pe+We.left+$*Xn*Pe,Yn=We.right,Bn=We.top+tn*Pe,qn=We.bottom-Dt*Pe;const mi=re.width+E*2;switch(X==null?void 0:X.hAlign){case"start":Yn=cn+mi;break;case"end":cn=Yn-mi;break;case"center":cn=Math.floor((cn+Yn)/2)-mi/2,Yn=cn+mi;break}const pi=re.height+O*2;switch(X==null?void 0:X.vAlign){case"start":qn=Bn+pi;break;case"end":Bn=qn-pi;break;case"center":Bn=Math.floor((Bn+qn)/2)-pi/2,qn=Bn+pi;break}cn>Ie.x?Ae=Ie.x-cn:Yn<Ie.x+Ie.width&&(Ae=Ie.x+Ie.width-Yn),Bn>Ie.y?we=Ie.y-Bn:qn<Ie.y+Ie.height&&(we=Ie.y+Ie.height-qn),R==="vertical"||typeof f=="number"&&f<Ye?Ae=0:(R==="horizontal"||typeof S=="number"&&S>=nn-Lt)&&(we=0),(Ae!==0||we!==0)&&(Pe!==1&&(Ae/=Pe,we/=Pe),St.current.scrollTo({left:Ae+St.current.scrollLeft,top:we+St.current.scrollTop,behavior:(X==null?void 0:X.behavior)??"auto"}))}}}},[$,It,Xn,St,tn,Ye,jt,nn,Sn,kn]),Ji=c.useRef(ha),Qi=c.useRef(M);Ji.current=ha,Qi.current=M;const Zi=c.useRef(Re);Zi.current=Re;const ga=c.useRef(Qe.length);ga.current=Qe.length;const pr=c.useCallback(async(f,S=!0,R)=>{var Q;const E=Qe[f];if(((Q=E==null?void 0:E.trailingRowOptions)==null?void 0:Q.disabled)===!0)return;const O=Te==null?void 0:Te();let X,P=!0;O!==void 0&&(X=await O,X==="top"&&(P=!1),typeof X=="number"&&(P=!1));let N=0;const K=()=>{if(Zi.current<=Re){N<500&&window.setTimeout(K,N),N=50+N*2;return}const le=typeof X=="number"?X:P?Re:0;gi.current(f-$,le,"both",0,0,R?{behavior:R}:void 0),Ue({cell:[f,le],range:{x:f,y:le,width:1,height:1}},!1,!1,"edit");const ve=Qi.current([f-$,le]);ve.allowOverlay&&ao(ve)&&ve.readonly!==!0&&S&&window.setTimeout(()=>{Ji.current(f,le)},0)};K()},[Qe,Te,$,Re,Ue]),ci=c.useCallback(async(f,S=!0)=>{const R=Fe==null?void 0:Fe();let E,O=!0;R!==void 0&&(E=await R,E==="left"&&(O=!1),typeof E=="number"&&(O=!1));let X=0;const P=()=>{if(ga.current<=Qe.length){X<500&&window.setTimeout(P,X),X=50+X*2;return}const N=typeof E=="number"?E:O?Qe.length:0;Pt(N-$,f),Ue({cell:[N,f],range:{x:N,y:f,width:1,height:1}},!1,!1,"edit");const K=Qi.current([N-$,f]);K.allowOverlay&&ao(K)&&K.readonly!==!0&&S&&window.setTimeout(()=>{Ji.current(N,f)},0)};P()},[Qe,Fe,$,Pt,Ue]),to=c.useCallback(f=>{var R,E;const S=((E=(R=jt[f])==null?void 0:R.trailingRowOptions)==null?void 0:E.targetColumn)??(Je==null?void 0:Je.targetColumn);if(typeof S=="number")return S+(en?1:0);if(typeof S=="object"){const O=C.indexOf(S);if(O>=0)return O+(en?1:0)}},[jt,C,en,Je==null?void 0:Je.targetColumn]),br=c.useRef(),no=c.useRef(),Do=c.useCallback((f,S)=>{var O;const[R,E]=S;return ir(ut,(O=Qe[R])==null?void 0:O.themeOverride,Zt==null?void 0:Zt(E),f.themeOverride)},[Zt,Qe,ut]),{mapper:_r}=bk(st,w),Nn=st==null?void 0:st.navigationBehavior,$o=c.useCallback(f=>{var Q,le,ve;const S=Ni.value?f.metaKey:f.ctrlKey,R=S&&be==="multi",[E,O]=f.location,X=W.columns,P=W.rows,[N,K]=((Q=W.current)==null?void 0:Q.cell)??[];if(f.kind==="cell"){if(no.current=void 0,Pr.current=[E,O],E===0&&en){if(Ct===!0&&O===Re||Vt==="number"||be==="none")return;const re=mn(f.location);if(re.kind!==Tn.Marker)return;if(vn!==void 0){const We=Mt(re);pn((We==null?void 0:We.kind)===Tn.Marker);const Pe=(le=We==null?void 0:We.onClick)==null?void 0:le.call(We,{...f,cell:re,posX:f.localEventX,posY:f.localEventY,bounds:f.bounds,theme:Do(re,f.location),preventDefault:()=>{}});if(Pe===void 0||Pe.checked===re.checked)return}i(void 0),sn();const Ae=P.hasIndex(O),we=br.current;if(be==="multi"&&(f.shiftKey||f.isLongTouch===!0)&&we!==void 0&&P.hasIndex(we)){const We=[Math.min(we,O),Math.max(we,O)+1];R||it==="multi"?qe(void 0,We,!0):qe(lt.fromSingleSelection(We),void 0,R)}else be==="multi"&&(R||f.isTouch||it==="multi")?Ae?qe(P.remove(O),void 0,!0):(qe(void 0,O,!0),br.current=O):Ae&&P.length===1?qe(lt.empty(),void 0,S):(qe(lt.fromSingleSelection(O),void 0,S),br.current=O)}else if(E>=$&&Ct&&O===Re){const re=to(E);pr(re??E)}else if(N!==E||K!==O){const re=mn(f.location),Ae=Mt(re);if((Ae==null?void 0:Ae.onSelect)!==void 0){let Pe=!1;if(Ae.onSelect({...f,cell:re,posX:f.localEventX,posY:f.localEventY,bounds:f.bounds,preventDefault:()=>Pe=!0,theme:Do(re,f.location)}),Pe)return}if(Nn==="block"&&_r(O).isGroupHeader)return;const we=Sn&&O===Re,We=Sn&&W!==void 0&&((ve=W.current)==null?void 0:ve.cell[1])===Re;if((f.shiftKey||f.isLongTouch===!0)&&N!==void 0&&K!==void 0&&W.current!==void 0&&!We){if(we)return;const Pe=Math.min(E,N),Ie=Math.max(E,N),ht=Math.min(O,K),Dt=Math.max(O,K);Ue({...W.current,range:{x:Pe,y:ht,width:Ie-Pe+1,height:Dt-ht+1}},!0,S,"click"),br.current=void 0,sn()}else Ue({cell:[E,O],range:{x:E,y:O,width:1,height:1}},!0,S,"click"),br.current=void 0,i(void 0),sn()}}else if(f.kind==="header")if(Pr.current=[E,O],i(void 0),en&&E===0)br.current=void 0,no.current=void 0,!fr&&be==="multi"&&(P.length!==Re?qe(lt.fromSingleSelection([0,Re]),void 0,S):qe(lt.empty(),void 0,S),sn());else{const re=no.current;if(ie==="multi"&&(f.shiftKey||f.isLongTouch===!0)&&re!==void 0&&X.hasIndex(re)){const Ae=[Math.min(re,E),Math.max(re,E)+1];S||f.isTouch||xe==="multi"?ze(void 0,Ae,S):ze(lt.fromSingleSelection(Ae),void 0,S)}else ie==="multi"&&(S||f.isTouch||xe==="multi")?(X.hasIndex(E)?ze(X.remove(E),void 0,S):ze(void 0,E,S),no.current=E):ie!=="none"&&(X.hasIndex(E)?ze(X.remove(E),void 0,S):ze(lt.fromSingleSelection(E),void 0,S),no.current=E);br.current=void 0,sn()}else f.kind===Ln?Pr.current=[E,O]:f.kind===Hi&&!f.isMaybeScrollbar&&(T(Ri,!1),i(void 0),sn(),$e==null||$e(),br.current=void 0,no.current=void 0)},[be,ie,W,en,$,Ct,Re,Vt,mn,vn,sn,it,xe,Mt,Do,qe,to,pr,Nn,_r,Sn,Ue,fr,ze,T,$e]),Ao=c.useRef(!1),Pr=c.useRef(),ma=c.useRef(rr),In=c.useRef(),Fu=c.useCallback(f=>{if(ro.current=!1,ma.current=Bt.current,f.button!==0&&f.button!==1){In.current=void 0;return}const S=performance.now();In.current={button:f.button,time:S,location:f.location},(f==null?void 0:f.kind)==="header"&&(Ao.current=!0);const R=f.kind==="cell"&&f.isFillHandle;!R&&f.kind!=="cell"&&f.isEdge||(u({previousSelection:W,fillHandle:R}),Pr.current=void 0,!f.isTouch&&f.button===0&&!R?$o(f):!f.isTouch&&f.button===1&&(Pr.current=f.location))},[W,$o]),[es,ts]=c.useState(),pa=c.useCallback(f=>{if(f.kind!==Ln||ie!=="multi")return;const S=Ni.value?f.metaKey:f.ctrlKey,[R]=f.location,E=W.columns;if(R<$)return;const O=Qe[R];let X=R,P=R;for(let N=R-1;N>=$&&Vo(O.group,Qe[N].group);N--)X--;for(let N=R+1;N<Qe.length&&Vo(O.group,Qe[N].group);N++)P++;if(sn(),S||f.isTouch||xe==="multi")if(E.hasAll([X,P+1])){let N=E;for(let K=X;K<=P;K++)N=N.remove(K);ze(N,void 0,S)}else ze(void 0,[X,P+1],S);else ze(lt.fromSingleSelection([X,P+1]),void 0,S)},[ie,sn,W.columns,Qe,$,ze,xe]),ro=c.useRef(!1),ui=c.useCallback(async f=>{if(Y!==void 0&&z!==void 0){const S=Bt.current.y,R=Bt.current.height;let E=Y({x:f,y:S,width:1,height:Math.min(R,Re-S)},I.current.signal);typeof E!="object"&&(E=await E());const O=jt[f-$],P=document.createElement("canvas").getContext("2d",{alpha:!1});if(P!==null){P.font=ut.baseFontFull;const N=_c(P,ut,O,0,E,hn,Qt,!1,Mt);z==null||z(O,N.width,f,N.width)}}},[jt,Y,Qt,ut,hn,z,$,Re,Mt]),[_u,ns]=c.useState(),oo=c.useCallback(async(f,S)=>{var N,K;const R=(N=f.current)==null?void 0:N.range;if(R===void 0||Y===void 0||S.current===void 0)return;const E=S.current.range;if(A!==void 0){let Q=!1;if(A({fillDestination:{...E,x:E.x-$},patternSource:{...R,x:R.x-$},preventDefault:()=>Q=!0}),Q)return}let O=Y(R,I.current.signal);typeof O!="object"&&(O=await O());const X=O,P=[];for(let Q=0;Q<E.width;Q++)for(let le=0;le<E.height;le++){const ve=[E.x+Q,E.y+le];if(kc(ve,R))continue;const re=X[le%R.height][Q%R.width];co(re)||!ao(re)||P.push({location:ve,value:{...re}})}Mn(P),(K=Kt.current)==null||K.damage(P.map(Q=>({cell:Q.location})))},[Y,Mn,A,$]),ba=c.useCallback(()=>{if(W.current===void 0||W.current.range.width<=1)return;const f={...W,current:{...W.current,range:{...W.current.range,width:1}}};oo(f,W)},[oo,W]),ya=c.useCallback(()=>{if(W.current===void 0||W.current.range.height<=1)return;const f={...W,current:{...W.current,range:{...W.current.range,height:1}}};oo(f,W)},[oo,W]),Pu=c.useCallback((f,S)=>{var le,ve;const R=l;if(u(void 0),qi(void 0),ns(void 0),Ao.current=!1,S)return;if((R==null?void 0:R.fillHandle)===!0&&W.current!==void 0&&((le=R.previousSelection)==null?void 0:le.current)!==void 0){if(Fr===void 0)return;const re={...W,current:{...W.current,range:Wc(R.previousSelection.current.range,Fr)}};oo(R.previousSelection,re),T(re,!0);return}const[E,O]=f.location,[X,P]=Pr.current??[],N=()=>{ro.current=!0},K=re=>{var we,We,Pe;const Ae=re.isTouch||X===E&&P===O;if(Ae&&(G==null||G([E-$,O],{...re,preventDefault:N})),re.button===1)return!ro.current;if(!ro.current){const Ie=mn(f.location),ht=Mt(Ie);if(ht!==void 0&&ht.onClick!==void 0&&Ae){const Lt=ht.onClick({...re,cell:Ie,posX:re.localEventX,posY:re.localEventY,bounds:re.bounds,theme:Do(Ie,f.location),preventDefault:N});Lt!==void 0&&!co(Lt)&&so(Lt)&&(Mn([{location:re.location,value:Lt}]),(we=Kt.current)==null||we.damage([{cell:re.location}]))}if(ro.current||W.current===void 0)return!1;let Dt=!1;switch(Ie.activationBehaviorOverride??Ve){case"double-click":case"second-click":{if(((Pe=(We=R==null?void 0:R.previousSelection)==null?void 0:We.current)==null?void 0:Pe.cell)===void 0)break;const[Lt,cn]=W.current.cell,[Yn,Bn]=R.previousSelection.current.cell;Dt=E===Lt&&E===Yn&&O===cn&&O===Bn&&(re.isDoubleClick===!0||Ve==="second-click");break}case"single-click":{Dt=!0;break}}if(Dt){const cn={inputType:"pointer",pointerActivation:re.isDoubleClick===!0?"double-click":Ie.activationBehaviorOverride??Ve,pointerType:re.isTouch?"touch":"mouse"};return B==null||B([E-$,O],cn),eo(re.bounds,cn),!0}}return!1},Q=f.location[0]-$;if(f.isTouch){const re=Bt.current,Ae=ma.current;if(re.x!==Ae.x||re.y!==Ae.y)return;if(f.isLongTouch===!0){if(f.kind==="cell"&&Xo((ve=W.current)==null?void 0:ve.cell,f.location)){Z==null||Z([Q,f.location[1]],{...f,preventDefault:N});return}else if(f.kind==="header"&&W.columns.hasIndex(E)){de==null||de(Q,{...f,preventDefault:N});return}else if(f.kind===Ln){if(Q<0)return;q==null||q(Q,{...f,preventDefault:N});return}}f.kind==="cell"?K(f)||$o(f):f.kind===Ln?U==null||U(Q,{...f,preventDefault:N}):(f.kind===Cr&&(j==null||j(Q,{...f,preventDefault:N})),$o(f));return}if(f.kind==="header"){if(Q<0)return;f.isEdge?f.isDoubleClick===!0&&ui(E):f.button===0&&E===X&&O===P&&(j==null||j(Q,{...f,preventDefault:N}))}if(f.kind===Ln){if(Q<0)return;f.button===0&&E===X&&O===P&&(U==null||U(Q,{...f,preventDefault:N}),ro.current||pa(f))}f.kind==="cell"&&(f.button===0||f.button===1)&&K(f),Pr.current=void 0},[l,W,$,Fr,oo,T,G,mn,Mt,Ve,Do,Mn,B,eo,Z,de,q,$o,U,j,ui,pa]),Ou=c.useCallback(f=>{const S={...f,location:[f.location[0]-$,f.location[1]]};Ke==null||Ke(S),l!==void 0&&f.buttons===0&&(u(void 0),qi(void 0),ns(void 0),Ao.current=!1),ns(R=>{var E;return Ao.current?[f.scrollEdge[0],0]:f.scrollEdge[0]===(R==null?void 0:R[0])&&f.scrollEdge[1]===R[1]?R:l===void 0||(((E=In.current)==null?void 0:E.location[0])??0)<$?void 0:f.scrollEdge})},[l,Ke,$]),ju=c.useCallback((f,S)=>{dt==null||dt(f-$,S)},[dt,$]),Nu=c.useCallback((f,S)=>{Ne==null||Ne(f-$,S)},[Ne,$]),Kn=(Ma=W==null?void 0:W.current)==null?void 0:Ma.cell,Hu=c.useCallback((f,S,R,E,O,X)=>{Ar.current=!1;let P=Kn;P!==void 0&&(P=[P[0]-$,P[1]]);const N=Ye===0?void 0:{x:0,y:f.y,width:Ye,height:f.height},K=[];N!==void 0&&K.push(N),It>0&&(K.push({x:f.x-$,y:Re-It,width:f.width,height:It}),Ye>0&&K.push({x:0,y:Re-It,width:Ye,height:It}));const Q={x:f.x-$,y:f.y,width:f.width,height:Ct&&f.y+f.height>=Re?f.height-1:f.height,tx:O,ty:X,extras:{selected:P,freezeRegion:N,freezeRegions:K}};Bt.current=Q,mr(Q),On([S,R,E]),Ht==null||Ht(Q,Q.tx,Q.ty,Q.extras)},[Kn,$,Ct,Re,Ye,It,mr,Ht]),Bu=xr(_,c.useCallback((f,S)=>(_==null?void 0:_(f-$,S-$))!==!1,[_,$])),Lu=xr(_e,c.useCallback((f,S)=>{_e==null||_e(f-$,S-$),ie!=="none"&&ze(lt.fromSingleSelection(S),void 0,!0)},[ie,_e,$,ze])),rs=c.useRef(!1),zu=c.useCallback(f=>{if(f.location[0]===0&&$>0){f.preventDefault();return}Le==null||Le({...f,location:[f.location[0]-$,f.location[1]]}),f.defaultPrevented()||(rs.current=!0),u(void 0)},[Le,$]),Wu=c.useCallback(()=>{rs.current=!1},[]),va=st==null?void 0:st.selectionBehavior,di=c.useCallback(f=>{if(va!=="block-spanning")return;const{isGroupHeader:S,path:R,groupRows:E}=_r(f);if(S)return[f,f];const O=R[R.length-1],X=f-O,P=f+E-O-1;return[X,P]},[_r,va]),os=c.useRef(),is=c.useCallback(f=>{var S,R,E;if(!iu(f,os.current)&&(os.current=f,!(((S=In==null?void 0:In.current)==null?void 0:S.button)!==void 0&&In.current.button>=1))){if(f.buttons!==0&&l!==void 0&&((R=In.current)==null?void 0:R.location[0])===0&&$===1&&be==="multi"&&l.previousSelection&&!l.previousSelection.rows.hasIndex(In.current.location[1])&&W.rows.hasIndex(In.current.location[1])){const O=Math.min(In.current.location[1],f.location[1]),X=Math.max(In.current.location[1],f.location[1])+1;qe(lt.fromSingleSelection([O,X]),void 0,!1)}else if(f.buttons!==0&&l!==void 0&&W.current!==void 0&&!rs.current&&!Ao.current&&(pt==="rect"||pt==="multi-rect")){const[O,X]=W.current.cell;let[P,N]=f.location;if(N<0&&(N=Bt.current.y),l.fillHandle===!0&&((E=l.previousSelection)==null?void 0:E.current)!==void 0){const K=l.previousSelection.current.range;N=Math.min(N,Ct?Re-1:Re);const Q=t0(K,P,N,$t);qi(Q)}else{if(Ct&&X===Re)return;if(Ct&&N===Re)if(f.kind===Hi)N--;else return;P=Math.max(P,$);const le=di(X);N=le===void 0?N:En(N,le[0],le[1]);const ve=P-O,re=N-X,Ae={x:ve>=0?O:P,y:re>=0?X:N,width:Math.abs(ve)+1,height:Math.abs(re)+1};Ue({...W.current,range:Ae},!0,!1,"drag")}}ct==null||ct({...f,location:[f.location[0]-$,f.location[1]]})}},[l,$,be,W,pt,ct,qe,Ct,Re,$t,di,Ue]),Gu=c.useCallback(()=>{var P,N;const f=os.current;if(f===void 0)return;const[S,R]=f.scrollEdge;let[E,O]=f.location;const X=Bt.current;S===-1?E=((N=(P=X.extras)==null?void 0:P.freezeRegion)==null?void 0:N.x)??X.x:S===1&&(E=X.x+X.width),R===-1?O=Math.max(0,X.y):R===1&&(O=Math.min(Re-1,X.y+X.height)),E=En(E,0,Qe.length-1),O=En(O,0,Re-1),is({...f,location:[E,O]})},[Qe.length,is,Re]);fk(_u,St,Gu);const Hn=c.useCallback(f=>{if(W.current===void 0)return;const[S,R]=f,[E,O]=W.current.cell,X=W.current.range;let P=X.x,N=X.x+X.width,K=X.y,Q=X.y+X.height;const[le,ve]=di(O)??[0,Re-1],re=ve+1;if(R!==0)switch(R){case 2:{Q=re,K=O,Pt(0,Q,"vertical");break}case-2:{K=le,Q=O+1,Pt(0,K,"vertical");break}case 1:{K<O?(K++,Pt(0,K,"vertical")):(Q=Math.min(re,Q+1),Pt(0,Q,"vertical"));break}case-1:{Q>O+1?(Q--,Pt(0,Q,"vertical")):(K=Math.max(le,K-1),Pt(0,K,"vertical"));break}default:qo()}if(S!==0)if(S===2)N=Qe.length,P=E,Pt(N-1-$,0,"horizontal");else if(S===-2)P=$,N=E+1,Pt(P-$,0,"horizontal");else{let Ae=[];if(Y!==void 0){const we=Y({x:P,y:K,width:N-P-$,height:Q-K},I.current.signal);typeof we=="object"&&(Ae=Ck(we))}if(S===1){let we=!1;if(P<E){if(Ae.length>0){const We=Br(P+1,E+1).find(Pe=>!Ae.includes(Pe-$));We!==void 0&&(P=We,we=!0)}else P++,we=!0;we&&Pt(P,0,"horizontal")}we||(N=Math.min(Qe.length,N+1),Pt(N-1-$,0,"horizontal"))}else if(S===-1){let we=!1;if(N>E+1){if(Ae.length>0){const We=Br(N-1,E,-1).find(Pe=>!Ae.includes(Pe-$));We!==void 0&&(N=We,we=!0)}else N--,we=!0;we&&Pt(N-$,0,"horizontal")}we||(P=Math.max($,P-1),Pt(P-$,0,"horizontal"))}else qo()}Ue({cell:W.current.cell,range:{x:P,y:K,width:N-P,height:Q-K}},!0,!1,"keyboard-select")},[Y,di,W,Qe.length,$,Re,Pt,Ue]),ss=c.useRef(Cn);ss.current=Cn;const yr=c.useCallback((f,S,R,E)=>{const O=nn-(R?0:1);f=En(f,$,jt.length-1+$),S=En(S,0,O);const X=Kn==null?void 0:Kn[0],P=Kn==null?void 0:Kn[1];if(f===X&&S===P)return!1;if(E&&W.current!==void 0){const N=[...W.current.rangeStack];(W.current.range.width>1||W.current.range.height>1)&&N.push(W.current.range),T({...W,current:{cell:[f,S],range:{x:f,y:S,width:1,height:1},rangeStack:N}},!0)}else Ue({cell:[f,S],range:{x:f,y:S,width:1,height:1}},!0,!1,"keyboard-nav");return d.current!==void 0&&d.current[0]===f&&d.current[1]===S&&(d.current=void 0),ss.current&&Pt(f-$,S),!0},[nn,$,jt.length,Kn,W,Pt,T,Ue]),Uu=c.useCallback((f,S)=>{(o==null?void 0:o.cell)!==void 0&&f!==void 0&&so(f)&&(Mn([{location:o.cell,value:f}]),window.requestAnimationFrame(()=>{var O;(O=Kt.current)==null||O.damage([{cell:o.cell}])})),sn(!0),i(void 0);const[R,E]=S;if(W.current!==void 0&&(R!==0||E!==0)){const O=W.current.cell[1]===nn-1&&f!==void 0,X=W.current.cell[0]===Qe.length-1&&f!==void 0;let P=!0;if(O&&E===1&&Te!==void 0){P=!1;const N=W.current.cell[0]+R,K=to(N);pr(K??N,!1)}if(X&&R===1&&Fe!==void 0){P=!1;const N=W.current.cell[1]+E;ci(N,!1)}P&&yr(En(W.current.cell[0]+R,0,Qe.length-1),En(W.current.cell[1]+E,0,nn-1),O,!1)}L==null||L(f,S)},[o==null?void 0:o.cell,sn,W,L,Mn,nn,yr,Qe.length,pr,ci,Te,Fe,to]),Xu=c.useMemo(()=>`gdg-overlay-${xk++}`,[]),Or=c.useCallback(f=>{var R,E,O,X;sn();const S=[];for(let P=f.x;P<f.x+f.width;P++)for(let N=f.y;N<f.y+f.height;N++){const K=M([P-$,N]);if(!K.allowOverlay&&K.kind!==ce.Boolean)continue;let Q;if(K.kind===ce.Custom){const le=Mt(K),ve=(R=le==null?void 0:le.provideEditor)==null?void 0:R.call(le,{...K,location:[P-$,N]});(le==null?void 0:le.onDelete)!==void 0?Q=le.onDelete(K):tp(ve)&&(Q=(E=ve==null?void 0:ve.deletedValue)==null?void 0:E.call(ve,K))}else if(so(K)&&K.allowOverlay||K.kind===ce.Boolean){const le=Mt(K);Q=(O=le==null?void 0:le.onDelete)==null?void 0:O.call(le,K)}Q!==void 0&&!co(Q)&&so(Q)&&S.push({location:[P,N],value:Q})}Mn(S),(X=Kt.current)==null||X.damage(S.map(P=>({cell:P.location})))},[sn,M,Mt,Mn,$]),Fo=o!==void 0,wa=c.useCallback(f=>{var We,Pe;const S=()=>{f.stopPropagation(),f.preventDefault()},R={didMatch:!1},{bounds:E}=f,O=W.columns,X=W.rows,P=gn;if(!Fo&&Ze(P.clear,f,R))T(Ri,!1),$e==null||$e();else if(!Fo&&Ze(P.selectAll,f,R))T({columns:lt.empty(),rows:lt.empty(),current:{cell:((We=W.current)==null?void 0:We.cell)??[$,0],range:{x:$,y:0,width:C.length,height:Re},rangeStack:[]}},!1);else if(Ze(P.search,f,R))(Pe=a==null?void 0:a.current)==null||Pe.focus({preventScroll:!0}),Pn(!0);else if(Ze(P.delete,f,R)){const Ie=(at==null?void 0:at(W))??!0;if(Ie!==!1){const ht=Ie===!0?W:Ie;if(ht.current!==void 0){Or(ht.current.range);for(const Dt of ht.current.rangeStack)Or(Dt)}for(const Dt of ht.rows)Or({x:$,y:Dt,width:C.length,height:1});for(const Dt of ht.columns)Or({x:Dt,y:0,width:1,height:Re})}}if(R.didMatch)return S(),!0;if(W.current===void 0)return!1;let[N,K]=W.current.cell;const[,Q]=W.current.cell;let le=!1,ve=!1;if(Ze(P.scrollToSelectedCell,f,R))gi.current(N-$,K);else if(ie!=="none"&&Ze(P.selectColumn,f,R))O.hasIndex(N)?ze(O.remove(N),void 0,!0):ie==="single"?ze(lt.fromSingleSelection(N),void 0,!0):ze(void 0,N,!0);else if(be!=="none"&&Ze(P.selectRow,f,R))X.hasIndex(K)?qe(X.remove(K),void 0,!0):be==="single"?qe(lt.fromSingleSelection(K),void 0,!0):qe(void 0,K,!0);else if(!Fo&&E!==void 0&&Ze(P.activateCell,f,R))if(K===Re&&Ct)window.setTimeout(()=>{const Ie=to(N);pr(Ie??N)},0);else{const Ie={inputType:"keyboard",key:f.key};B==null||B([N-$,K],Ie),eo(E,Ie)}else W.current.range.height>1&&Ze(P.downFill,f,R)?ya():W.current.range.width>1&&Ze(P.rightFill,f,R)?ba():Ze(P.goToNextPage,f,R)?K+=Math.max(1,Bt.current.height-4):Ze(P.goToPreviousPage,f,R)?K-=Math.max(1,Bt.current.height-4):Ze(P.goToFirstCell,f,R)?(i(void 0),K=0,N=0):Ze(P.goToLastCell,f,R)?(i(void 0),K=Number.MAX_SAFE_INTEGER,N=Number.MAX_SAFE_INTEGER):Ze(P.selectToFirstCell,f,R)?(i(void 0),Hn([-2,-2])):Ze(P.selectToLastCell,f,R)?(i(void 0),Hn([2,2])):Fo?(Ze(P.closeOverlay,f,R)&&i(void 0),Ze(P.acceptOverlayDown,f,R)&&(i(void 0),K++),Ze(P.acceptOverlayUp,f,R)&&(i(void 0),K--),Ze(P.acceptOverlayLeft,f,R)&&(i(void 0),N--),Ze(P.acceptOverlayRight,f,R)&&(i(void 0),N++)):(Ze(P.goDownCell,f,R)?K+=1:Ze(P.goUpCell,f,R)?K-=1:Ze(P.goRightCell,f,R)?N+=1:Ze(P.goLeftCell,f,R)?N-=1:Ze(P.goDownCellRetainSelection,f,R)?(K+=1,le=!0):Ze(P.goUpCellRetainSelection,f,R)?(K-=1,le=!0):Ze(P.goRightCellRetainSelection,f,R)?(N+=1,le=!0):Ze(P.goLeftCellRetainSelection,f,R)?(N-=1,le=!0):Ze(P.goToLastRow,f,R)?K=Re-1:Ze(P.goToFirstRow,f,R)?K=Number.MIN_SAFE_INTEGER:Ze(P.goToLastColumn,f,R)?N=Number.MAX_SAFE_INTEGER:Ze(P.goToFirstColumn,f,R)?N=Number.MIN_SAFE_INTEGER:(pt==="rect"||pt==="multi-rect")&&(Ze(P.selectGrowDown,f,R)?Hn([0,1]):Ze(P.selectGrowUp,f,R)?Hn([0,-1]):Ze(P.selectGrowRight,f,R)?Hn([1,0]):Ze(P.selectGrowLeft,f,R)?Hn([-1,0]):Ze(P.selectToLastRow,f,R)?Hn([0,2]):Ze(P.selectToFirstRow,f,R)?Hn([0,-2]):Ze(P.selectToLastColumn,f,R)?Hn([2,0]):Ze(P.selectToFirstColumn,f,R)&&Hn([-2,0])),ve=R.didMatch);if(Nn!==void 0&&Nn!=="normal"&&K!==Q){const Ie=Nn==="skip-up"||Nn==="skip"||Nn==="block",ht=Nn==="skip-down"||Nn==="skip"||Nn==="block",Dt=K<Q;if(Dt&&Ie){for(;K>=0&&_r(K).isGroupHeader;)K--;K<0&&(K=Q)}else if(!Dt&&ht){for(;K<Re&&_r(K).isGroupHeader;)K++;K>=Re&&(K=Q)}}const Ae=yr(N,K,!1,le),we=R.didMatch;return we&&(Ae||!ve||An)&&S(),we},[Nn,Fo,W,gn,ie,be,pt,$,_r,Re,yr,T,$e,C.length,at,An,Or,ze,qe,Ct,to,pr,B,eo,ya,ba,Hn]),_o=c.useCallback(f=>{let S=!1;if(Ge!==void 0&&Ge({...f,...f.location&&{location:[f.location[0]-$,f.location[1]]},cancel:()=>{S=!0}}),S||wa(f)||W.current===void 0)return;const[R,E]=W.current.cell,O=Bt.current;if(je&&!f.metaKey&&!f.ctrlKey&&W.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&&ao(M([R-$,Math.max(0,Math.min(E,Re-1))]))){if((!Ct||E!==Re)&&(O.y>E||E>O.y+O.height||O.x>R||R>O.x+O.width))return;const X={inputType:"keyboard",key:f.key};B==null||B([R-$,E],X),eo(f.bounds,X,f.key),f.stopPropagation(),f.preventDefault()}},[je,Ge,wa,W,M,$,Re,Ct,B,eo]),Ku=c.useCallback((f,S)=>{const R=f.location[0]-$;if(f.kind==="header"&&(de==null||de(R,{...f,preventDefault:S})),f.kind===Ln){if(R<0)return;q==null||q(R,{...f,preventDefault:S})}if(f.kind==="cell"){const[E,O]=f.location;Z==null||Z([R,O],{...f,preventDefault:S}),Jp(W,f.location)||yr(E,O,!1,!1)}},[W,Z,q,de,$,yr]),as=c.useCallback(async f=>{var P,N,K;if(!gn.paste)return;function S(Q,le,ve,re){var we,We;const Ae=typeof ve=="object"?(ve==null?void 0:ve.join(`
13
15
  `))??"":(ve==null?void 0:ve.toString())??"";if(!co(Q)&&ao(Q)&&Q.readonly!==!0){const Pe=V==null?void 0:V(Ae,Q);if(Pe!==void 0&&so(Pe))return{location:le,value:Pe};const Ie=Mt(Q);if(Ie===void 0)return;if(Ie.kind===ce.Custom){pn(Q.kind===ce.Custom);const ht=(we=Ie.onPaste)==null?void 0:we.call(Ie,Ae,Q.data);return ht===void 0?void 0:{location:le,value:{...Q,data:ht}}}else{const ht=(We=Ie.onPaste)==null?void 0:We.call(Ie,Ae,Q,{formatted:re,formattedString:typeof re=="string"?re:re==null?void 0:re.join(`
14
- `),rawValue:ve});return ht===void 0?void 0:(pn(ht.kind===Q.kind),{location:le,value:ht})}}}const R=W.columns,E=W.rows,O=((P=St.current)==null?void 0:P.contains(document.activeElement))===!0||((N=s.current)==null?void 0:N.contains(document.activeElement))===!0;let X;if(W.current!==void 0?X=[W.current.range.x,W.current.range.y]:R.length===1?X=[R.first()??0,0]:E.length===1&&(X=[$,E.first()??0]),O&&X!==void 0){let Q,le;const ve="text/plain",re="text/html";if(navigator.clipboard.read!==void 0){const Pe=await navigator.clipboard.read();for(const Ie of Pe){if(Ie.types.includes(re)){const Dt=await(await Ie.getType(re)).text(),Lt=Nl(Dt);if(Lt!==void 0){Q=Lt;break}}Ie.types.includes(ve)&&(le=await(await Ie.getType(ve)).text())}}else if(navigator.clipboard.readText!==void 0)le=await navigator.clipboard.readText();else if(f!==void 0&&(f==null?void 0:f.clipboardData)!==null){if(f.clipboardData.types.includes(re)){const Pe=f.clipboardData.getData(re);Q=Nl(Pe)}Q===void 0&&f.clipboardData.types.includes(ve)&&(le=f.clipboardData.getData(ve))}else return;const[Ae,we]=X,We=[];do{if(ue===void 0){const Pe=mn(X),Ie=le??(Q==null?void 0:Q.map(Dt=>Dt.map(Lt=>Lt.rawValue).join(" ")).join(" "))??"",ht=S(Pe,X,Ie,void 0);ht!==void 0&&We.push(ht);break}if(Q===void 0){if(le===void 0)return;Q=ok(le)}if(ue===!1||typeof ue=="function"&&(ue==null?void 0:ue([X[0]-$,X[1]],Q.map(Pe=>Pe.map(Ie=>{var ht;return((ht=Ie.rawValue)==null?void 0:ht.toString())??""}))))!==!0)return;for(const[Pe,Ie]of Q.entries()){if(Pe+we>=Re)break;for(const[ht,Dt]of Ie.entries()){const Lt=[ht+Ae,Pe+we],[cn,Yn]=Lt;if(cn>=Qe.length||Yn>=nn)continue;const Bn=mn(Lt),qn=S(Bn,Lt,Dt.rawValue,Dt.formatted);qn!==void 0&&We.push(qn)}}}while(!1);Mn(We),(K=Kt.current)==null||K.damage(We.map(Pe=>({cell:Pe.location})))}},[V,Mt,mn,W,gn.paste,St,Qe.length,Mn,nn,ue,$,Re]);an("paste",as,h,!1,!0);const Po=c.useCallback(async(f,S)=>{var P,N;if(!gn.copy)return;const R=S===!0||((P=St.current)==null?void 0:P.contains(document.activeElement))===!0||((N=s.current)==null?void 0:N.contains(document.activeElement))===!0,E=W.columns,O=W.rows,X=(K,Q)=>{if(!ye)Bl(K,Q,f);else{const le=Q.map(ve=>({kind:ce.Text,data:C[ve].title,displayData:C[ve].title,allowOverlay:!1}));Bl([le,...K],Q,f)}};if(R&&Y!==void 0){if(W.current!==void 0){let K=Y(W.current.range,I.current.signal);typeof K!="object"&&(K=await K()),X(K,Br(W.current.range.x-$,W.current.range.x+W.current.range.width-$))}else if(O!==void 0&&O.length>0){const Q=[...O].map(le=>{const ve=Y({x:$,y:le,width:C.length,height:1},I.current.signal);return typeof ve=="object"?ve[0]:ve().then(re=>re[0])});if(Q.some(le=>le instanceof Promise)){const le=await Promise.all(Q);X(le,Br(C.length))}else X(Q,Br(C.length))}else if(E.length>0){const K=[],Q=[];for(const le of E){let ve=Y({x:le,y:0,width:1,height:Re},I.current.signal);typeof ve!="object"&&(ve=await ve()),K.push(ve),Q.push(le-$)}if(K.length===1)X(K[0],Q);else{const le=K.reduce((ve,re)=>ve.map((Ae,we)=>[...Ae,...re[we]]));X(le,Q)}}}},[C,Y,W,gn.copy,$,St,Re,ye]);an("copy",Po,h,!1,!1);const Yu=c.useCallback(async f=>{var R,E;if(!(!gn.cut||!(((R=St.current)==null?void 0:R.contains(document.activeElement))===!0||((E=s.current)==null?void 0:E.contains(document.activeElement))===!0))&&(await Po(f),W.current!==void 0)){let O={current:{cell:W.current.cell,range:W.current.range,rangeStack:[]},rows:lt.empty(),columns:lt.empty()};const X=at==null?void 0:at(O);if(X===!1||(O=X===!0?O:X,O.current===void 0))return;Or(O.current.range)}},[Or,W,gn.cut,Po,St,at]);an("cut",Yu,h,!1,!1);const qu=c.useCallback((f,S)=>{if(Ee!==void 0){$!==0&&(f=f.map(O=>[O[0]-$,O[1]])),Ee(f,S);return}if(f.length===0||S===-1)return;const[R,E]=f[S];d.current!==void 0&&d.current[0]===R&&d.current[1]===E||(d.current=[R,E],yr(R,E,!1,!1))},[Ee,$,yr]),[fi,hi]=((Ia=Yt==null?void 0:Yt.current)==null?void 0:Ia.cell)??[],gi=c.useRef(Pt);gi.current=Pt,c.useLayoutEffect(()=>{var f,S,R,E;ss.current&&!Ar.current&&fi!==void 0&&hi!==void 0&&(fi!==((S=(f=y.current)==null?void 0:f.current)==null?void 0:S.cell[0])||hi!==((E=(R=y.current)==null?void 0:R.current)==null?void 0:E.cell[1]))&&gi.current(fi,hi),Ar.current=!1},[fi,hi]);const xa=W.current!==void 0&&(W.current.cell[0]>=Qe.length||W.current.cell[1]>=nn);c.useLayoutEffect(()=>{xa&&T(Ri,!1)},[xa,T]);const Vu=c.useMemo(()=>Ct===!0&&(Je==null?void 0:Je.tint)===!0?lt.fromSingleSelection(nn-1):lt.empty(),[nn,Ct,Je==null?void 0:Je.tint]),Ju=c.useCallback(f=>typeof gt=="boolean"?gt:(gt==null?void 0:gt(f-$))??!0,[$,gt]),Qu=c.useMemo(()=>{if(es===void 0||s.current===null)return null;const{bounds:f,group:S}=es,R=s.current.getBoundingClientRect();return c.createElement(KC,{bounds:f,group:S,canvasBounds:R,onClose:()=>ts(void 0),onFinish:E=>{ts(void 0),Se==null||Se(S,E)}})},[Se,es]),Zu=Math.min(Qe.length,Ye+(en?1:0));c.useImperativeHandle(t,()=>({appendRow:(f,S)=>pr(f+$,S),appendColumn:(f,S)=>ci(f,S),updateCells:f=>{var S;return $!==0&&(f=f.map(R=>({cell:[R.cell[0]+$,R.cell[1]]}))),(S=Kt.current)==null?void 0:S.damage(f)},getBounds:(f,S)=>{var R;if(!((s==null?void 0:s.current)===null||(St==null?void 0:St.current)===null)){if(f===void 0&&S===void 0){const E=s.current.getBoundingClientRect(),O=E.width/St.current.clientWidth;return{x:E.x-St.current.scrollLeft*O,y:E.y-St.current.scrollTop*O,width:St.current.scrollWidth*O,height:St.current.scrollHeight*O}}return(R=Kt.current)==null?void 0:R.getBounds((f??0)+$,S)}},focus:()=>{var f;return(f=Kt.current)==null?void 0:f.focus()},emit:async f=>{switch(f){case"delete":_o({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":_o({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":_o({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 Po(void 0,!0);break;case"paste":await as();break}},scrollTo:Pt,remeasureColumns:f=>{for(const S of f)ui(S+$)},getMouseArgsForPosition:(f,S,R)=>{if((Kt==null?void 0:Kt.current)===null)return;const E=Kt.current.getMouseArgsForPosition(f,S,R);if(E!==void 0)return{...E,location:[E.location[0]-$,E.location[1]]}}}),[pr,ci,ui,St,Po,_o,as,$,Pt]);const[Ca,ka]=Kn??[],ed=c.useCallback(f=>{const[S,R]=f;if(R===-1){ie!=="none"&&(ze(lt.fromSingleSelection(S),void 0,!1),sn());return}Ca===S&&ka===R||(Ue({cell:f,range:{x:S,y:R,width:1,height:1}},!0,!1,"keyboard-nav"),Pt(S,R))},[ie,sn,Pt,Ca,ka,Ue,ze]),[td,nd]=c.useState(!1),Sa=c.useRef(yc(f=>{nd(f)},5)),rd=c.useCallback(()=>{Sa.current(!0),W.current===void 0&&W.columns.length===0&&W.rows.length===0&&l===void 0&&Ue({cell:[$,oi],range:{x:$,y:oi,width:1,height:1}},!0,!1,"keyboard-select")},[oi,W,l,$,Ue]),od=c.useCallback(()=>{Sa.current(!1)},[]),[id,sd]=c.useMemo(()=>{let f;const S=(nt==null?void 0:nt.scrollbarWidthOverride)??Is(),R=Re+(Ct?1:0);if(typeof kn=="number")f=tn+R*kn;else{let O=0;const X=Math.min(R,10);for(let P=0;P<X;P++)O+=kn(P);O=Math.floor(O/X),f=tn+R*O}f+=S;const E=Qe.reduce((O,X)=>X.width+O,0)+S;return[`${Math.min(1e5,E)}px`,`${Math.min(1e5,f)}px`]},[Qe,nt==null?void 0:nt.scrollbarWidthOverride,kn,Re,Ct,tn]),ad=c.useMemo(()=>hb(ut),[ut]);return c.createElement(gb.Provider,{value:ut},c.createElement(lk,{style:ad,className:he,inWidth:b??id,inHeight:x??sd},c.createElement(WC,{fillHandle:At,drawFocusRing:lr,experimental:nt,fixedShadowX:Xt,fixedShadowY:Et,getRowThemeOverride:Zt,headerIcons:Qt,imageWindowLoader:ln,initialSize:Ft,isDraggable:Zn,onDragLeave:Ir,onRowMoved:vn,overscrollX:qr,overscrollY:Vr,preventDiagonalScrolling:zn,rightElement:Wn,rightElementProps:Gn,smoothScrollX:Ro,smoothScrollY:Ur,className:he,enableGroups:Rn,onCanvasFocused:rd,onCanvasBlur:od,canvasRef:s,onContextMenu:Ku,theme:ut,cellXOffset:$u,cellYOffset:oi,accessibilityHeight:rr.height,onDragEnd:Wu,columns:Qe,nonGrowWidth:wt,drawHeader:ft,onColumnProposeMove:Bu,drawCell:Ce,disabledRows:Vu,freezeColumns:Zu,lockColumns:$,firstColAccessible:$===0,getCellContent:mn,minColumnWidth:hn,maxColumnWidth:Jt,searchInputRef:a,showSearch:To,onSearchClose:gr,highlightRegions:Au,getCellsForSelection:Y,getGroupDetails:Vi,headerHeight:Dr,isFocused:td,groupHeaderHeight:Rn?$r:0,freezeTrailingRows:It+(Ct&&(Je==null?void 0:Je.sticky)===!0?1:0),hasAppendRow:Ct,onColumnResize:z,onColumnResizeEnd:ne,onColumnResizeStart:te,onCellFocused:ed,onColumnMoved:Lu,onDragStart:zu,onHeaderMenuClick:ju,onHeaderIndicatorClick:Nu,onItemHovered:is,isFilling:(l==null?void 0:l.fillHandle)===!0,onMouseMove:Ou,onKeyDown:_o,onKeyUp:Oe,onMouseDown:Fu,onMouseUp:Pu,onDragOverCell:qt,onDrop:Nt,onSearchResultsChanged:qu,onVisibleRegionChanged:Hu,clientSize:_t,rowHeight:kn,searchResults:J,searchValue:pe,onSearchValueChange:ae,rows:nn,scrollRef:St,selection:W,translateX:rr.tx,translateY:rr.ty,verticalBorder:Ju,gridRef:Kt,getCellRenderer:Mt,resizeIndicator:Kr}),Qu,o!==void 0&&c.createElement(c.Suspense,{fallback:null},c.createElement(vk,{...o,validateCell:me,bloom:H,id:Xu,getCellRenderer:Mt,className:(nt==null?void 0:nt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Ut,imageEditorOverride:m,portalElementRef:Yr,onFinishEditing:Uu,markdownDivCreateNode:g,isOutsideClick:Xr,customEventTarget:nt==null?void 0:nt.eventTarget}))))},kk=c.forwardRef(Ck);function Wl(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=xc(d,s,i.cellVerticalPadding),p=wc(t.contentAlign??"center",l,a,i.cellHorizontalPadding,m),g=vc(p,h,m),b=Cc(l+n,u+r,g);return Qs(t)&&b}const Sk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??"false"},kind:ce.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>Rk(e,e.cell.data,Qs(e.cell),e.cell.maxSize??e.theme.checkboxMaxSize,e.cell.hoverEffectIntensity??.35),onDelete:e=>({...e,data:!1}),onSelect:e=>{Wl(e)&&e.preventDefault()},onClick:e=>{if(Wl(e))return{...e.cell,data:au(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 Rk(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:b,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,b,x,u,d,h,r,m),C&&(i.globalAlpha=1)}const Mk=Sr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),Ik=e=>{const{bubbles:t}=e;return c.createElement(Mk,null,t.map((n,r)=>c.createElement("div",{key:r,className:"boe-bubble"},n)),c.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},Ek={getAccessibilityString:e=>jp(e.data),kind:ce.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=>Tk(e,e.cell.data),provideEditor:()=>e=>{const{value:t}=e;return c.createElement(Ik,{bubbles:t.data})},onPaste:()=>{}};function Tk(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)ho(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+Co(o,r))}function Dk(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const $k={getAccessibilityString:()=>"",kind:ce.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(Dk(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);ho(o,i.x+l,i.y+(i.height-u)/2,s,u,a.roundingRadius??3),o.fillStyle=Lr(a.textDark,.1),o.fill()},onPaste:()=>{}},Ak={getAccessibilityString:e=>e.row.toString(),kind:Tn.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:Fk,measure:()=>44,draw:e=>Pk(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 Fk(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=_k,n.textAlign="center",i}function _k(e){const{ctx:t}=e;t.textAlign="start"}function Pk(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 b=7*(n?l:1);if(ia(a,u,n,o?d+b:d,h,o?m-b: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 b=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(b,C,h+p/2+Co(a,x)),l!==0&&(a.globalAlpha=1)}}const Ok={getAccessibilityString:()=>"",kind:Tn.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:e=>jk(e,e.cell.hint,e.cell.icon),onPaste:()=>{}};function jk(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 b=h-8,x=l+8/2,C=u+8/2;s.drawSprite(n,"normal",r,x,C,b,a,m?1:i),p=b}else{p=24;const g=12,b=m?g:i*g,x=m?0:(1-i)*g*.5,C=a.cellHorizontalPadding+4;b>0&&(r.moveTo(l+C+x,u+h/2),r.lineTo(l+C+x+b,u+h/2),r.moveTo(l+C+x+b*.5,u+h/2-b*.5),r.lineTo(l+C+x+b*.5,u+h/2+b*.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+Co(r,a)),r.beginPath()}function uu(e,t,n,r,o,i,a){e.textBaseline="alphabetic";const s=Nk(e,o,r,t,(n==null?void 0:n.fullSize)??!1);e.beginPath(),ho(e,s.x,s.y,s.width,s.height,t.roundingRadius??4),e.globalAlpha=i,e.fillStyle=(n==null?void 0:n.bgColor)??Lr(t.textDark,.1),e.fill(),e.globalAlpha=1,e.fillStyle=t.textDark,e.textBaseline="middle",a==null||a("text")}function Nk(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 Hk=c.lazy(async()=>await ec(()=>import("./number-overlay-editor-CRWFlaQs.js"),__vite__mapDeps([3,1,2]))),Bk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??""},kind:ce.Number,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,useLabel:!0,drawPrep:Ic,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&&uu(r,o,u,l,i,t,a),Tc(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(Hk,{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}}},Lk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??""},kind:ce.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Ic,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&&uu(o,a,m,l,i,n,s),Tc(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(zp,{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}},zk=new Set(["path","source"]);function Wk(e){return zk.has(e.kind)}const Gk=16;function kr(e,t=[]){return{root:{field:e},keys:t}}function Uk(e,t=[]){return{root:{instance:e},keys:t}}function Mr(e){return"field"in e.root?e.root.field:void 0}function ca(e){return"instance"in e.root?e.root.instance:void 0}function Xk(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 Kk(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 du(e,t){const n=Kk(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>Gk)return{value:"n/a"};o={instance:r.name,arg:a}}const s=Xk(e,r).find(([l])=>l===a);if(!s)return{value:"n/a"};r=s[1]}return o?{value:r,argument:o}:{value:r}}function fu(e,t){return du(e,t).value}const Yk=e=>e.replaceAll("%","%25").replaceAll("/","%2F");function Dn(e){return("field"in e.root?e.root.field:`@${e.root.instance}`)+e.keys.map(n=>`/${Yk(n)}`).join("")}function ua(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)&&ua(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 qk(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 Vk(e){const t=e.resources??{};return qk(e).filter(n=>!Object.hasOwn(t,n.to))}function Jk(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 io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qk(e){if(!io(e))return"an update must be an object";if(typeof e.rowId!="string")return"an update needs a rowId";if(!io(e.cells))return"an update needs cells (use {} for none)";for(const[t,n]of Object.entries(e.cells))if(n!==null&&!(io(n)&&typeof n.kind=="string"))return`cell ${t} must be an input or null`;if(e.resources!==void 0){if(!io(e.resources))return"resources must be an object";for(const[t,n]of Object.entries(e.resources)){if(!ud(t))return`'${t}' isn't a valid instance name`;if(n!==null){if(!io(n)||typeof n.uri!="string")return`instance ${t} needs a resource uri`;if(n.args!==void 0&&!io(n.args))return`instance ${t}'s args must be an object`}}}}const Gl={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=Qk(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 Zk(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=tc(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 eS(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 tS(e,t,n=[]){if(dd(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 nS(e){return e.kind==="primitive"?"":e.option.def.name}function rS(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 oS=60;function iS(e,t=oS){return e.length>t?`${e.slice(0,t-1)}…`:e}function hu(e){return e.value.map(t=>typeof t=="string"?t:`\${${t.expr}}`).join("")}function da(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`"${hu(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 sS(e){const t=e.lastIndexOf("#");return t>=0?e.slice(t+1):e}const aS="(unsupported)";function Vn(e){switch(e.kind){case"value":return iS(da(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 aS}}function Yo(e){switch(e.kind){case"primitive":return e.value??null;case"template":return hu(e);case"object":return Object.fromEntries(Object.entries(e.properties).map(([t,n])=>[t,Yo(n)]));case"array":case"tuple":return e.elements.map(Yo);default:return da(e)}}function lS({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}=Zo({open:i,onClose:s,matchTriggerWidth:!1}),h=i&&mo.createPortal(v.jsx("div",{className:"trace-column-picker dataset-column-picker",ref:u,style:d,role:"dialog","aria-label":"Add column",children:v.jsx(gu,{...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 gu({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(cS,{...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:kr(u.id),label:u.def.name,depth:0,describePath:n,onPick:r},u.id)),Object.entries(t).map(([u,d])=>v.jsx(Ls,{path:Uk(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 cS({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(()=>Zk(n,r),[n,r]),g=c.useMemo(()=>eS(n),[n]),b=tS(s,p,g)??{kind:"primitive",type:"string"},x=rS(i,b),C=async()=>{if(!(!x||h)){m(!0);try{await hd(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:nS(b)||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:[fd.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:Vn(p.sample)},depth:r+1,describePath:o,onPick:i},p.key))]})]})}function uS({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:b,popoverRef:x,style:C}=Zo({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(G){m((G==null?void 0:G.message)??String(G)),g(!1)}}};return mo.createPortal(v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:b,"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 dS(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(!Wk(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,b=Dn(p);if(a.has(b))continue;const x=Mr(p);if(x!==void 0&&!r.has(x))continue;const[C,...w]=p.keys;if(x!==void 0&&C===void 0){a.add(b);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(b),l(x).keys.push({key:C,hidden:m,...g!==void 0&&{title:g}});continue}if(!h.added)continue}a.add(b),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 Lo=e=>e?{hidden:!0}:{};function fS(e){return e.flatMap(hS)}function hS(e){switch(e.kind){case"field":return[{kind:"path",path:kr(e.fieldId),...e.title!==void 0&&{title:e.title},...Lo(e.hidden)},...e.keys.map(t=>({kind:"path",path:kr(e.fieldId,[t.key]),...t.title!==void 0&&{title:t.title},...Lo(t.hidden)}))];case"added":return[{kind:"path",path:e.path,...e.title!==void 0&&{title:e.title},...Lo(e.hidden),added:!0}];case"source":return[{kind:"source",...Lo(e.hidden)}];case"unknown":{const{hidden:t,...n}=e.spec;return[{...n,...Lo(e.hidden)}]}}}function mu(e){if(e.kind==="field")return kr(e.fieldId);if(e.kind==="added")return e.path}function pu(e,t){const n=e[t.index];if(n)return t.key!==void 0?n.kind==="field"?kr(n.fieldId,[t.key]):void 0:mu(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 bu(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 gS(e,t,n){return bu(e,t,n)}function mS(e,t,n,r){return e.map((o,i)=>i===t&&o.kind==="field"?{...o,keys:bu(o.keys,n,r)}:o)}function pS(e,t){var n;return((n=e[t])==null?void 0:n.kind)==="added"?e.filter((r,o)=>o!==t):e}function bS(e,t){const n=Dn(t);for(const[r,o]of e.entries()){const i=mu(o);if(i&&Dn(i)===n)return{index:r};if(o.kind==="field"){for(const{key:a}of o.keys)if(Dn(kr(o.fieldId,[a]))===n)return{index:r,key:a}}}}function yS(e,t){const n=bS(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 Ul(e,t,n){const r=[...n];return e.map(o=>t(o)?r.shift()??o:o)}function Xl(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 yu="disclosureCollapsed",vu="disclosureExpanded",vS={[yu]:Xl("8.75,6.75 11.9,10 8.75,13.25"),[vu]:Xl("6.75,8.75 10,11.9 13.25,8.75")},zo={whole:240,key:160,added:200,source:96,unknown:120};function wS(e){return e.def.name}function wu(e,t){var o;const n=e.keys.at(-1);if(n!==void 0)return n;const r=Mr(e);return r===void 0?ca(e)??"":((o=t.find(i=>i.id===r))==null?void 0:o.def.name)??r}function xS(e,t){var o;const n=Mr(e);return[n===void 0?`◆ ${ca(e)}`:((o=t.find(i=>i.id===n))==null?void 0:o.def.name)??n,...e.keys].join(" › ")}function CS({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=gd(u.def.type),m={id:u.id,title:u.def.name,type:d,role:"whole",path:kr(u.id),width:zo.whole,slot:l,...h&&{base:h}};if(s.keys.length===0){i.push(m);break}const p=wS(u),g=s.keys.filter(b=>!b.hidden);if(!n.has(u.id)||g.length===0){i.push({...m,group:p});break}for(const{key:b}of g){const x=kr(u.id,[b]);i.push({id:Dn(x),title:b,group:p,role:"key",path:x,width:zo.key,slot:{index:a,key:b}})}break}case"added":i.push({id:Dn(s.path),title:s.title??wu(s.path,e),role:"added",path:s.path,width:zo.added,slot:l});break;case"source":i.push({id:"source",title:"source",role:"source",width:zo.source,slot:l});break;case"unknown":i.push({id:`?${a}`,title:"Unknown column",type:s.spec.kind,role:"unknown",kind:s.spec.kind,width:zo.unknown,slot:l});break}}return i}function kS(e){return(e==null?void 0:e.role)==="whole"?Mr(e.path):void 0}function xu(e){return e&&"path"in e?e.path:void 0}function SS(e){const t=xu(e);if(!t)return;const n=Mr(t);if(n!==void 0)return{field:n};const r=ca(t);return r!==void 0?{instance:r}:void 0}function Cu(e,t,n){const r=[...e],[o]=r.splice(t,1);return r.splice(n,0,o),r}function ku(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=Cu(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 RS(e,t,n,r){const o=t[n];if(!o||n===r||!ku(t,n,r))return e;const i=Cu(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=Ul(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 Ul(e.map((d,h)=>h),d=>u.has(d),l).map(d=>e[d])}function MS(e){const t=new Map;for(const n of e){const r="path"in n?Mr(n.path):void 0;n.group!==void 0&&r!==void 0&&(t.has(n.group)||t.set(n.group,r))}return t}function IS(e,t,n){const r=t.get(e);return r===void 0?{name:e}:{name:e,icon:n.has(r)?vu:yu}}function ES(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 TS(e,t.path);if(t.role!=="whole"||!t.base)return;const{base:n}=t,r=Mr(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 TS(e,t){var s;const{value:n,argument:r}=du(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=ES(i);if(a)return{base:a,instance:r.instance,arg:r.arg,spec:o,value:i}}function Su(e,t){return t==null||t===""?!0:e==="number"?typeof t=="number"&&Number.isFinite(t):typeof t===e}function DS(e,t){if(Su(e,t))return nc({kind:"primitive",value:t??void 0})}function Ru(e){return"fieldId"in e?{fieldId:e.fieldId}:{instance:e.instance,arg:e.arg,spec:e.spec}}function $S(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=DS(l.base,a);u===void 0||u===null&&!("fieldId"in l)||r.push({rowId:s.id,...Ru(l),cell:u})}return r}function AS(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,...Ru(h),cell:null})}}return r}function FS(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 Mu(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 _S(e){const t=Object.entries(e.properties);return t.length===0?"{}":`{ ${t.map(([n,r])=>`${n}: ${r.kind==="instance"?`◆ ${Vn(r)}`:Vn(r)}`).join(", ")} }`}function PS(e){const t=Object.entries(e.properties);return t.length===0?"{}":`{ ${t.map(([n,r])=>`${n}: ${da(r)}`).join(", ")} }`}function OS(e){switch(e.kind){case"instance":return{kind:"chip",text:`◆ ${Vn(e)}`};case"object":return{kind:"text",text:_S(e)};default:return{kind:"text",text:e.kind==="value"&&e.value.kind==="object"?PS(e.value):Vn(e)}}}function jS(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=fu(e,t.path),i=Qo(e,t);return i?{kind:"edit",base:i.base,value:i.value,text:typeof o=="object"?Vn(o):"—"}:o==="absent"?{kind:"empty"}:o==="n/a"?{kind:"n/a"}:OS(o)}}}function Cs(e,t){const n=fu(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 Vn(n)}}class NS{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]=Mu(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 Iu={expanded:new Set,widths:{}};function HS(e,t){return`dataset-layout:${e}:${t}`}function BS(e){if(typeof e!="object"||e===null)return Iu;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 LS(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 zS(e){return JSON.stringify({expanded:[...e.expanded],widths:e.widths})}const Kl=e=>e.key===void 0?`${e.index}`:`${e.index}/${e.key}`;function WS({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),[b,x]=c.useState(null),[C,w]=c.useState(null),[M,G]=c.useState(new Set),B=()=>{m(!1),g(!1)},{triggerRef:A,popoverRef:L,style:V}=Zo({open:h,onClose:B,matchTriggerWidth:!1}),k=b??e,F=r&&Dn(r),H=U=>{var Z;return((Z=t.find(he=>he.id===U))==null?void 0:Z.def.name)??U},j=U=>{if(!C||!b)return!1;if(C.key===void 0&&U.key===void 0)return U.index!==C.index&&(x(gS(b,C.index,U.index)),w({index:U.index})),!0;const Z=b[C.index];if(C.key===void 0||U.key===void 0||U.index!==C.index||(Z==null?void 0:Z.kind)!=="field")return!1;if(U.key!==C.key){const he=Z.keys.findIndex(ee=>ee.key===C.key),de=Z.keys.findIndex(ee=>ee.key===U.key);x(mS(b,C.index,he,de))}return!0},_=()=>{b&&b!==e&&o(b),x(null),w(null)},D=({slot:U,title:Z,detail:he,hidden:de,removable:ee,disclosure:q,dim:Se})=>{const se=Kl(U),oe=pu(k,U),Ee=!!oe&&Dn(oe)===F;return v.jsxs("div",{className:`trace-column-picker-row dataset-column-picker-row${U.key!==void 0?" dataset-column-picker-key":""}${C&&Kl(C)===se?" trace-column-picker-row-dragging":""}${Se?" dataset-column-picker-dim":""}`,onDragOver:J=>{j(U)&&J.preventDefault()},onDrop:J=>J.preventDefault(),children:[v.jsx("span",{className:"trace-column-picker-grab",draggable:!0,onDragStart:J=>{J.dataTransfer.effectAllowed="move",J.dataTransfer.setData("text/plain",se),x(e),w(U)},onDragEnd:_,title:"Drag to reorder",children:v.jsx(pd,{})}),q?v.jsx("button",{type:"button",className:"dataset-column-picker-disclosure","aria-label":`${q.open?"Hide":"Show"} ${Z}'s keys`,"aria-expanded":q.open,onClick:q.toggle,children:q.open?"▾":"▸"}):U.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 ${Z}`,checked:!de,onChange:()=>o(Bi(e,U,!de))}),v.jsx("span",{className:"dataset-column-picker-title",children:Z}),he&&v.jsx("span",{className:"dataset-column-picker-detail",children:he})]}),oe&&v.jsxs("span",{className:"dataset-column-picker-actions",children:[ee&&v.jsx("button",{type:"button",className:"dataset-column-picker-icon-btn","aria-label":`Remove column ${Z}`,title:"Remove column",onClick:()=>s(U.index),children:"✕"}),v.jsx("button",{type:"button",className:`dataset-column-picker-icon-btn${Ee?" dataset-column-picker-icon-btn-on":""}`,"aria-label":`Use ${Z} as row label`,"aria-pressed":Ee,title:Ee?"Don't use as row label":"Use as row label",onClick:()=>i(Ee?void 0:oe),children:v.jsx(bd,{filled:Ee})})]})]},se)},fe=(U,Z)=>{const he={index:Z};switch(U.kind){case"field":{const de=M.has(U.fieldId),ee=D({slot:he,title:H(U.fieldId),hidden:U.hidden,...U.keys.length>0&&{disclosure:{open:de,toggle:()=>{const q=new Set(M);q.delete(U.fieldId)||q.add(U.fieldId),G(q)}}}});return de?[ee,...U.keys.map(q=>D({slot:{index:Z,key:q.key},title:q.key,hidden:q.hidden}))]:ee}case"added":return D({slot:he,title:U.title??wu(U.path,t),detail:xS(U.path,t),hidden:U.hidden,removable:!0});case"source":return D({slot:he,title:"source",hidden:U.hidden});case"unknown":return D({slot:he,title:"Unknown column",detail:U.spec.kind,hidden:U.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?B():m(!0),children:[v.jsx(md,{}),"Columns",v.jsx(rc,{})]}),h&&mo.createPortal(v.jsx("div",{className:"trace-column-picker dataset-column-picker",ref:L,style:V,role:"dialog","aria-label":"Columns",children:p?v.jsx(gu,{fields:t,instances:n,describePath:l,onPick:U=>{a(U),g(!1)},newField:u,onFieldAdded:()=>{d(),g(!1)},onBack:()=>g(!1)}):v.jsxs(v.Fragment,{children:[k.flatMap((U,Z)=>fe(U,Z)),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 GS(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 US(e,t,n=[]){const r=[...t?[t]:[],...n.filter(u=>!tc(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=GS(r),a={};for(const u of e){const d=Ea(u.def),h=o.find(g=>g.defs.some(b=>Ea(b)===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 b=i.get(g.type.syntax);b&&(p[g.path]=[...new Set([...p[g.path]??[],...b])])}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]=yd(r);return{selections:t,instances:vd(e.resources)}}function XS(e,t,n){const r={};for(const s of e){const l=wd(t.selections[s]),u=(l==null?void 0:l.kind)==="value"?nc(l.value):l??null;Go(u)!==Go(n.cells[s]??null)&&(r[s]=u)}const o=n.resources??{},i=xd(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:""};Go(l)!==Go(o[s]?d:null)&&(a[s]=l)}return{cells:r,...Object.keys(a).length>0&&{resources:a}}}function KS(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 YS(e){return Object.keys(e.cells).length>0||Object.keys(e.resources??{}).length>0}function Yl(e){const t=n=>Object.fromEntries(Object.entries(n).flatMap(([r,o])=>o.resources&&Object.keys(o.resources).length>0?[[r,o.resources]]:[]));return Go([t(e.selections),Object.entries(e.instances).map(([n,r])=>[n,r.uri,t(r.args)])])}function Go(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 qS({value:e}){return e.kind==="primitive"&&typeof e.value=="string"||e.kind==="template"?v.jsx("div",{className:"dataset-detail-text",children:Yo(e)}):e.kind==="object"||e.kind==="array"||e.kind==="tuple"?v.jsx(Fd,{data:Yo(e)}):v.jsx("code",{className:"dataset-detail-scalar",children:String(Yo(e))})}function Eu({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(Tu,{input:n})]},t))})}function Tu({input:e}){switch(e.kind){case"value":return v.jsx(qS,{value:e.value});case"object":return v.jsx(Eu,{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:"◆"}),Vn(e)]});case"dataset":case"input":return v.jsx("code",{className:"dataset-detail-scalar",children:Vn(e)});default:return v.jsx("span",{className:"dataset-detail-scalar",children:Vn(e)})}}function VS(e){const t=document.querySelector(`[data-field-id="${CSS.escape(e)}"]`);t&&Cd(t,"nearest")}const JS=[];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:sS(r.uri)}),r.args&&Object.keys(r.args).length>0&&v.jsx(Eu,{inputs:r.args})]})]},n))})})}function ZS({fields:e,row:t,sources:n,onChangeRow:r}){const o=(n==null?void 0:n.resources)??JS,i=c.useMemo(()=>new Map(o.map(k=>[k.uri,k])),[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 k=ks(t);l.current=k,s(k)}const p=k=>{const F=t.cells[k.id];return!!r&&(!!n||!F||F.kind==="value")},g=e.filter(p).map(k=>k.id),b=k=>{d(!1);const F=XS(g,n?k:{...k,instances:ks(t).instances},t);YS(F)&&(r==null||r(F))},x=k=>{const F=l.current,H=typeof k=="function"?k(F):k;l.current=H,s(H),Yl(H)!==Yl(F)?b(H):d(!0)},C=()=>{u&&b(l.current)},w=k=>{k.key!=="Enter"||k.shiftKey||k.defaultPrevented||k.nativeEvent.isComposing||(k.preventDefault(),C())},M=c.useRef(C);M.current=C,c.useEffect(()=>()=>M.current(),[]);const{instances:G}=a,B=c.useMemo(()=>({resources:Md(o,G),functionSlots:{},executeSlots:{},resourceSlots:Object.fromEntries(Object.entries((n==null?void 0:n.resourceSlots)??{}).map(([k,F])=>[k,Ta(F,o,G)]))}),[o,G,n]),A=(k,F)=>x(H=>{const j=typeof k=="function"?k(H.instances):k;if(!F)return{...H,instances:j};const[_,D]=F.kind==="rename"?[F.from,F.to]:[F.name,null];return{instances:j,selections:Ad(H.selections,_,D)}}),L=Dd({instances:G,catalogByUri:i,adopt:k=>{const F=$d(l.current.instances,k,i),j={...l.current,instances:F.instances};return l.current=j,s(j),d(!0),F.uri}}),V=!!r&&!!n;return v.jsxs(v.Fragment,{children:[e.map(k=>{const F=t.cells[k.id];return v.jsx(Ms,{"data-field-id":k.id,label:v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"dataset-detail-field",children:k.def.name}),v.jsx("span",{className:"dataset-detail-type",title:k.def.type.syntax,children:Di(k.def.type.syntax,32)})]}),children:v.jsxs("div",{className:"dataset-detail-cell",children:[p(k)?v.jsx("div",{className:"dataset-detail-editor",onBlur:H=>{H.currentTarget.contains(H.relatedTarget)||C()},onKeyDown:w,children:v.jsx(Id,{propDef:k.def,selection:a.selections[k.id]??{},onChange:H=>x(j=>({...j,selections:{...j.selections,[k.id]:H}})),resources:B.resources,slots:Ta(n==null?void 0:n.fieldSlots[k.id],o,G),context:n&&L})}):F?v.jsx(Tu,{input:F}):v.jsx("span",{className:"dataset-cell-empty",children:"—"}),r&&F&&v.jsx("button",{type:"button",className:"dataset-detail-clear",title:`Clear ${k.def.name}`,"aria-label":`Clear ${k.def.name}`,onClick:()=>r({cells:{[k.id]:null}}),children:"×"})]})},k.id)}),V?v.jsx(Ms,{label:v.jsx("span",{className:"dataset-detail-field"}),children:v.jsx("div",{className:"dataset-detail-editor",onBlur:k=>{k.currentTarget.contains(k.relatedTarget)||C()},onKeyDown:w,children:v.jsx(Ed,{instances:G,onChange:A,sources:B,catalog:o,referencedBy:k=>Td(k,G,[{selections:Object.fromEntries(e.flatMap(F=>a.selections[F.id]?[[F.def.name,a.selections[F.id]]]:[]))}]),context:L})})}):v.jsx(QS,{row:t})]})}function eR({dataset:e,row:t,onOpenTrace:n,onChangeRow:r,sources:o}){const i=[{label:"Added",icon:v.jsx(ic,{}),value:oc(t.createdAt)}],{source:a}=t;return a&&i.push({label:"Source",icon:v.jsx(kd,{}),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(Sd,{children:v.jsx(Rd,{facts:i})}),v.jsx(ZS,{fields:e.fields,row:t,sources:o,onChangeRow:r},t.id)]})})}function tR(e){const[t,n]=c.useState(!1),r=()=>n(!1),{triggerRef:o,popoverRef:i,style:a}=Zo({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(sc,{size:14}),"Evals",v.jsx(rc,{})]}),t&&mo.createPortal(v.jsx("div",{className:"trace-header-menu",ref:i,style:a,role:"menu",children:v.jsx(Du,{...e,onChosen:r})}),document.body)]})}function Du({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(sc,{size:14})}),v.jsx("span",{className:"trace-header-menu-item-label",children:"New eval…"})]})]})]})}const Nr=30;function nR({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/Nr),p=m+Math.ceil(h.clientHeight/Nr)+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*Nr;m<h.scrollTop?h.scrollTop=m:m+Nr>h.scrollTop+h.clientHeight&&(h.scrollTop=m+Nr-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*Nr},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*Nr},children:d})})}function rR({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 oR(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 iR(e,t,n){return e&&e.rowId===n.rowId?{...e,update:oR(e.update,n)}:{rowId:t.id,base:t,update:n}}function zs(e){return Mu(e.base,e.update)}function ql(e,t){return t!==void 0&&!ua(t,e.base)}function Ti(e){return!!e&&!ua(zs(e),e.base)}function sR(e,t){return(e==null?void 0:e.rowId)===t&&Ti(e)?e.base:void 0}const aR='"Geist Mono", ui-monospace, monospace';function Vl(){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 lR(){const[e,t]=c.useState(Vl);return c.useEffect(()=>_d(()=>t(Vl())),[]),e}const cR=[Ak,Lk,Bk,Sk,Ek,$k,Ok];function Jl(e){switch(e.kind){case ce.Text:case ce.Number:case ce.Boolean:return{value:e.data};default:return}}const uR={setWindow:()=>{},loadOrGetImage:()=>{},setCallback:()=>{}};function Ql(e){try{const t=localStorage.getItem(e);if(t)return BS(JSON.parse(t))}catch{}return Iu}function dR(e,t){try{localStorage.setItem(e,zS(t))}catch{}}function fR(e){try{localStorage.removeItem(e)}catch{}}const Zl=32,Ss=32,Rs=26,hR=300,gR=[],mR=[],pR=[],Wo={columns:lt.empty(),rows:lt.empty()};function bR(e,t){const n=e.value===void 0&&{themeOverride:{textDark:t.textLight}};switch(e.base){case"boolean":return{kind:ce.Boolean,data:typeof e.value=="boolean"?e.value:null,allowOverlay:!1,readonly:!1};case"number":return{kind:ce.Number,data:typeof e.value=="number"?e.value:void 0,displayData:e.text,allowOverlay:!0,readonly:!1,...n};case"string":return{kind:ce.Text,data:typeof e.value=="string"?e.value:"",displayData:e.text,allowOverlay:!0,readonly:!1,...n}}}function yR(e,t){const n=(r,o={})=>({kind:ce.Text,data:r,displayData:r,allowOverlay:!1,readonly:!0,...o});switch(e.kind){case"loading":return{kind:ce.Loading,allowOverlay:!1};case"edit":return bR(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:ce.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 vR({providerId:e,datasetId:t,version:n,findPrompt:r,prompts:o=gR,onOpenPrompt:i,onOpenInPlayground:a,onOpenTrace:s,onDeleted:l,onNewEval:u,evals:d=mR,onRunStarted:h,agents:m=pR,onAskAgent:p}){var Y,ge,me;const[g,b]=c.useState(null),[x,C]=c.useState({rowCount:0,fields:{},instances:{}}),[w,M]=c.useState(null),[G,B]=c.useState(0),[A,L]=c.useState(0),V=c.useRef({count:0}),k=c.useRef(null),F=HS(e,t),[H,j]=c.useState(()=>Ql(F)),{expanded:_,widths:D}=H,fe=c.useCallback(y=>{j(y),dR(F,y)},[F]),U=c.useRef(F);c.useEffect(()=>{U.current!==F&&(U.current=F,j(Ql(F)))},[F]);const[Z,he]=c.useState(Wo),de=c.useRef(null),ee=`evalution.datasetTab:${e}/${t}`,[q,Se]=c.useState(()=>Da(ee)??"grid"),se=c.useRef(ee);c.useEffect(()=>{se.current!==ee&&(se.current=ee,Se(Da(ee)??"grid"))},[ee]);const[oe,Ee]=c.useState(null),[J,ae]=c.useState(),[pe,Ge]=c.useState(null),[Oe,rt]=c.useState(null),[je,Te]=c.useState(),Fe=c.useMemo(()=>new Pd(Gl,{selected:null}),[e,t]),[_e,mt]=c.useState(!1),[xt,pt]=c.useState(""),[ie,be]=c.useState(!1),Me=c.useCallback(()=>be(!1),[]),{triggerRef:De,popoverRef:ke,style:ot}=Zo({open:ie,onClose:Me,matchTriggerWidth:!1}),[Le,Ke]=c.useState(null),ue=c.useCallback(()=>Ke(null),[]),ye=lR(),Ye=c.useRef(null),{ref:Ve,isWide:it}=Od(760),xe=c.useMemo(()=>new NS((y,T)=>jd(e,t,y,T),()=>L(y=>y+1),y=>M(y.message)),[e,t]),dt=c.useCallback((y,T)=>xe.ensure(y,T),[xe]),Ne=c.useRef({start:0,end:0});c.useEffect(()=>{V.current={count:0},k.current=null},[e,t]),c.useEffect(()=>{let y=!1;return Nd(e,t).then(({dataset:T,rowCount:z,fields:ne,instances:te})=>{if(y)return;b(T),C({rowCount:z+V.current.count,fields:ne,instances:te??{}}),M(k.current),k.current=null,xe.invalidate();const{start:ft,end:Ce}=Ne.current;xe.ensure(ft,Math.min(Ce,z))}).catch(T=>!y&&M(T.message)),()=>{y=!0}},[e,t,n,G,xe]),c.useEffect(()=>{g&&Fe.setSubject({dataset:g,overview:x})},[Fe,g,x]);const He=g!=null&&g.prompt?r(g.prompt):void 0,st=c.useMemo(()=>{if(!g||!He)return g;const y=Hd(g.fields,He);return y===g.fields?g:{...g,fields:y}},[g,He]),Wt=Bd(st&&(!st.prompt||He)?US(st.fields,He,o):void 0),ct=c.useMemo(()=>st?dS(st.columns,st.fields,x.fields):[],[st,x.fields]),$e=c.useMemo(()=>st?CS({fields:st.fields,layout:ct,expanded:_,shortType:y=>Di(y,24)}):[],[st,ct,_]),bt=g==null?void 0:g.rowLabel,Ht=c.useCallback((y,T=bt??null)=>{const z=fS(y);b(ne=>{if(!ne)return ne;const{rowLabel:te,...ft}=ne;return{...ft,columns:z,...T&&{rowLabel:T}}}),Ld(e,t,z,T).catch(ne=>{M(`Couldn't save the columns: ${ne.message}`),B(te=>te+1)})},[e,t,bt]),Yt=c.useMemo(()=>MS($e),[$e]),vt=c.useCallback(y=>IS(y,Yt,_),[Yt,_]),yn=c.useMemo(()=>new Map($e.map(y=>[y.id,y])),[$e]),dn=c.useMemo(()=>$e.map(y=>({id:y.id,title:y.title,width:D[y.id]??y.width,hasMenu:!0,...y.group!==void 0&&{group:y.group},...y.role==="unknown"&&{themeOverride:{textHeader:ye.textLight}}})),[$e,D,ye]),kt=c.useCallback(([y,T])=>yR(jS(xe.get(T),$e[y]),ye),[$e,xe,ye,A]),Ut=c.useCallback(y=>{const T=y.y,z=y.y+y.height;Ne.current={start:T,end:z},xe.ensure(T,Math.min(z,x.rowCount)),Ke(null)},[xe,x.rowCount]),Je=c.useCallback((y,T)=>{T();const z=yn.get(y.column.id??"");if(!(z!=null&&z.type))return;const{ctx:ne,rect:te,theme:ft}=y;ne.save(),ne.beginPath(),ne.rect(te.x,te.y,te.width,te.height),ne.clip(),ne.font=`${ft.headerFontStyle} ${ft.fontFamily}`,ne.textBaseline="middle";const Ce=ne.measureText(z.title);ne.font=`10.5px ${aR}`,ne.fillStyle=ft.textLight,ne.textBaseline="alphabetic",ne.fillText(z.type,te.x+ft.cellHorizontalPadding+Ce.width+6,te.y+te.height/2-Ce.alphabeticBaseline+.5),ne.restore()},[yn]),It=((Y=Z.current)==null?void 0:Y.cell[1])??Z.rows.first()??null,$t=It!==null&&It<x.rowCount?It:null,tt=$t!==null?xe.get($t):void 0,Rt=c.useRef(null);tt&&$t!==null&&(Rt.current={index:$t,row:tt});const gt=tt??($t!==null&&((ge=Rt.current)==null?void 0:ge.index)===$t?Rt.current.row:void 0),qt=c.useRef(void 0);c.useEffect(()=>()=>clearTimeout(qt.current),[]);const Nt=c.useCallback(y=>{if(he(y),clearTimeout(qt.current),!y.current&&y.rows.length===0)ae(T=>T&&void 0);else{if(J!==void 0)return;y.rows.length>0?ae(!0):qt.current=setTimeout(()=>ae(T=>T??!0),hR)}},[J]),Ot=c.useRef(je),Gt=c.useCallback(y=>{Ot.current=y,Te(y)},[]),Be=oe!==null&&oe<x.rowCount?xe.get(oe):void 0,$n=()=>{const y=Ot.current;return Ti(y)?window.confirm("Discard the unsaved changes to this row?")?(Gt(void 0),!0):!1:(y&&Gt(void 0),!0)},At=y=>{y===oe||!$n()||Ee(y)},nt=y=>{switch(y.name){case"selectRow":At(y.args.index);return;case"showInstance":{const{name:T}=y.args;if(!Be||!Object.hasOwn(Be.resources??{},T))return`the row has no stored instance ${T}`;ae(!0),Ge(T);return}case"proposeUpdate":{const{update:T}=y.args;if(!Be||Be.id!==T.rowId)return"the row isn't loaded";const z=Ot.current,ne=iR((z==null?void 0:z.rowId)===Be.id?z:void 0,Be,T),te=Vk(zs(ne));if(te.length>0)return`That would leave references to instances the row doesn't declare: ${te.map(Jk).join("; ")}`;Gt(ne);return}default:return`no action ${y.name}`}},Xt=zd({surface:Gl,channel:Fe,activeUri:q.startsWith("view:")?q.slice(5):null,onAction:nt}),Et=Xt.shownUri!==null,Qt=c.useMemo(()=>Et?[]:Z.rows.toArray().filter(y=>y<x.rowCount),[Et,Z.rows,x.rowCount]);c.useEffect(()=>{pe&&($a(pe),Ge(null))},[pe]);const ln=J?Et?oe:$t:null,Ft=J?Et?Be:gt:void 0,Zn=Ft==null?void 0:Ft.id;c.useEffect(()=>{!Oe||Zn===void 0||("field"in Oe?VS(Oe.field):$a(Oe.instance),rt(null))},[Oe,Zn]);const Ir=((me=Xt.tabs.find(y=>y.uri===Xt.shownUri))==null?void 0:me.label)??Wd(Xt.shownUri??"");c.useEffect(()=>{if(!Et)return;const{rowCount:y}=x;y===0?Ee(null):oe===null?Ee(0):oe>=y&&Ee(y-1)},[Et,oe,x]),c.useEffect(()=>{Et&&oe!==null&&xe.ensure(oe,Math.min(oe+1,x.rowCount))},[Et,oe,xe,x.rowCount]);const vn=Et?oe:$t,rn=Et?Be:gt,wn=c.useMemo(()=>rn&&(je==null?void 0:je.rowId)===rn.id?zs(je):rn,[rn,je]),zn=wn&&bt?Cs(wn,bt):void 0,Wn=rn&&sR(je,rn.id);c.useEffect(()=>{Fe.setContext({selected:wn&&vn!==null?{index:vn,row:wn,...Wn&&{stored:Wn},...zn!==void 0&&{label:zn}}:null})},[Fe,wn,vn,zn,Wn]);const Gn=y=>{if(!(y===q||!$n())){if(y.startsWith("view:")&&!Et)Ee($t);else if(y==="grid"&&Et&&oe!==null){he({columns:lt.empty(),rows:lt.fromSingleSelection(oe)}),ae(z=>z??!0);const T=oe;requestAnimationFrame(()=>{var z;return(z=de.current)==null?void 0:z.scrollTo(0,T)})}Se(y),df(ee,y)}},An=()=>{const y=Ot.current;if(y){if(!Be||Be.id!==y.rowId||ql(y,Be)){M("This row changed since you started; discard and redo.");return}Gt(void 0),Cn([y.update]).then(T=>{!T&&!Ot.current&&Gt(y)})}},Ro=Et&&Ti(je)&&(Be==null?void 0:Be.id)===je.rowId,Ur=!!je&&!!Be&&Be.id===je.rowId&&ql(je,Be),Mo=y=>{const T=xe.get(y);!g||!He||!T||a(He,rf(of(g,T),He,{type:"dataset",description:`${g.name}, row ${y+1}`,providerId:e,datasetId:t,name:g.name},T.resources))},er=!!g&&g.fields.length>0,fn=$e.some(y=>y.group!==void 0),xn=(fn?Rs:0)+Ss+(x.rowCount+(er?1:0))*Zl+1,{ref:Io,matches:Xr}=Gd(c.useCallback(y=>xn>y.height,[xn])),sr=c.useMemo(()=>er?{hint:"New row",sticky:Xr}:void 0,[er,Xr]),Kr=c.useCallback(()=>{const y=V.current;y.count++,C(z=>({...z,rowCount:z.rowCount+1}));const T=()=>{y.count--,y===V.current&&B(z=>z+1)};return Aa(e,t,[{cells:{}}]).then(T,z=>{y===V.current&&(k.current=z.message,M(z.message)),T()}),Promise.resolve("bottom")},[e,t]),Cn=c.useCallback(async y=>{if(y.length===0)return!0;xe.patch(y),L(T=>T+1);try{return await Ud(e,t,y),!0}catch(T){M(`Couldn't save: ${T.message}`),xe.invalidate();const{start:z,end:ne}=Ne.current;return xe.ensure(z,Math.min(ne,x.rowCount)),oe!==null&&xe.ensure(oe,oe+1),!1}},[xe,e,t,x.rowCount,oe]),ar=c.useCallback(y=>Cn(FS(y)),[Cn]),Yr=c.useCallback(y=>{const T=[];for(const{location:z,value:ne}of y){const te=Jl(ne);te&&T.push({col:z[0],row:z[1],...te})}return ar($S(T,$e,z=>xe.get(z))),!0},[$e,xe,ar]),lr=c.useCallback(([y,T],z)=>{var ft;const ne=(ft=Qo(xe.get(T),$e[y]))==null?void 0:ft.base,te=Jl(z);return ne!==void 0&&!!te&&Su(ne,te.value)},[$e,xe]),yt=c.useCallback(async y=>{var z;if(y.length===0)return;const T=y.length===1?`row ${y[0]+1}`:`${y.length} rows`;if(window.confirm(`Delete ${T}?`))try{const ne=(await xe.rowsAt(y)).map(ft=>ft.id);await Xd(e,t,ne),Nt(Wo);const te=(z=Ot.current)==null?void 0:z.rowId;te!==void 0&&ne.includes(te)&&Gt(void 0),B(ft=>ft+1)}catch(ne){M(ne.message)}},[xe,e,t,Nt,Gt]),Vt=c.useCallback(y=>{const{current:T}=y;return T?ar(AS([T.range,...T.rangeStack],$e,z=>xe.get(z))):y.rows.length>0&&yt(y.rows.toArray()),!1},[$e,xe,ar,yt]),cr=c.useCallback(([y,T])=>{var te;const z=$e[y],ne=(te=xe.get(T))==null?void 0:te.source;(z==null?void 0:z.role)==="source"&&(ne==null?void 0:ne.kind)==="trace"&&s(ne.traceProviderId,ne.traceId),rt(J===!1?null:SS(z)??null)},[$e,xe,s,J]),Fn=c.useCallback(([y,T])=>{Qo(xe.get(T),$e[y])&&(clearTimeout(qt.current),rt(null))},[$e,xe]),ur=c.useCallback((y,T)=>{const z=$e[y],ne=z&&"path"in z?Mr(z.path):void 0;if(ne===void 0)return;T.preventDefault();const te=new Set(_);te.delete(ne)||te.add(ne),fe({...H,expanded:te})},[$e,_,H,fe]),Un=c.useCallback((y,T)=>{const z=$e[y];z&&Ke({columnId:z.id,anchor:T})},[$e]),dr=c.useCallback((y,T)=>ku($e,y,T),[$e]),fr=c.useCallback((y,T)=>{const z=RS(ct,$e,y,T);z!==ct&&Ht(z)},[ct,$e,Ht]),on=async y=>{try{await y()}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 hn=He?Kd(g.fields,He):[],{rowCount:Jt}=x,Eo=()=>on(async()=>{const y=xt.trim();mt(!1),!(!y||y===g.name)&&b(await sf(e,t,y))}),Er=()=>{pt(g.name),mt(!0)},Re=Le?$e.find(y=>y.id===Le.columnId):void 0,hr=kS(Re),_n=hr!==void 0?g.fields.find(y=>y.id===hr):void 0,Zt=xu(Re),Tr=bt&&Dn(bt),kn=async(y,T)=>{const z=await cf(e,t,y.id,T);b({...g,fields:g.fields.map(ne=>ne.id===z.id?z:ne)}),B(ne=>ne+1)},Dr=y=>{Ke(null),window.confirm(`Delete the field “${y.def.name}” and its values in every row?`)&&on(async()=>{await lf(e,t,y.id),fe(LS(H,y.id)),Nt(Wo),B(T=>T+1)})},$r=y=>af(e,t,y),tr=y=>Ht(yS(ct,y)),qr=()=>B(y=>y+1),Vr={providerId:e,datasetId:t,prompts:o,...g.prompt&&{linked:g.prompt}},gn=()=>{window.confirm(`Delete “${g.name}” and its ${Jt} row${Jt===1?"":"s"}?`)&&on(async()=>{await ff(e,t),fR(F),l()})},Xn=()=>u==null?void 0:u({dataset:{providerId:e,id:t},...(He==null?void 0:He.providerId)&&{prompt:{id:He.id,providerId:He.providerId}}}),en=async()=>(await xe.rowsAt(Qt)).map(y=>y.id),$=y=>on(async()=>{const T=Qt.length>0?await en():void 0;try{const z=await hf(y.providerId,y.id,{...T&&{rowIds:T}});h==null||h(y,z)}catch(z){throw z instanceof gf?new Error(`Can't run ${y.name}: ${z.problems.join("; ")}`):z}}),Ct=y=>on(async()=>{Qt.length>0?p==null||p(y,await en()):p==null||p(y,rn&&[rn.id])}),Sn=d.filter(y=>y.dataset.providerId===e&&y.dataset.id===t),Jr={evals:Sn,selectedRows:Qt.length,onRun:$,...u&&{onNewEval:Xn}},Pn=Sn.length>0||!!u,To=ie&&mo.createPortal(v.jsxs("div",{className:"trace-header-menu",ref:ke,style:ot,children:[Pn&&v.jsx(Du,{...Jr,onChosen:Me}),p&&v.jsx(Yd,{agents:m.filter(y=>!y.disabledReason),onAsk:y=>{be(!1),Ct(y)}}),(Pn||p)&&v.jsx("hr",{className:"ask-agent-menu-divider"}),v.jsxs("button",{type:"button",className:"trace-header-menu-item dataset-menu-delete",onClick:()=>{be(!1),gn()},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),gr=Ft&&bt?Cs(Ft,bt):void 0,ri=y=>on(async()=>{const T=x.rowCount;await Aa(e,t,[KS(y)]),B(z=>z+1),Et||(he({columns:lt.empty(),rows:lt.fromSingleSelection(T)}),requestAnimationFrame(()=>{var z;return(z=de.current)==null?void 0:z.scrollTo(0,T)}))}),W=()=>{var T,z;if(ae(!J),J||Et||It!==null)return;const y=Math.min(((T=Rt.current)==null?void 0:T.index)??0,Jt-1);he({columns:lt.empty(),rows:lt.fromSingleSelection(y)}),(z=de.current)==null||z.scrollTo(0,y)},I=J&&Qt.length>1?v.jsx(Fa,{title:v.jsxs("span",{className:"trace-row-name",children:[Qt.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 yt(Qt),children:v.jsx(yi,{})})}):Ft&&ln!==null&&v.jsxs(v.Fragment,{children:[v.jsx(Fa,{title:v.jsxs("span",{className:"trace-row-name",children:["Row ",ln+1,v.jsxs("code",{className:"dataset-row-id",children:[" · ",Ft.id]})]}),subtitle:gr,actions:v.jsxs(v.Fragment,{children:[He&&v.jsx("button",{type:"button",className:"dataset-row-btn",title:`Open in playground (${He.name})`,"aria-label":"Open row in playground",onClick:()=>Mo(ln),children:"▶"}),v.jsx("button",{type:"button",className:"dataset-row-btn",title:"Duplicate row","aria-label":"Duplicate row",onClick:()=>void ri(Ft),children:v.jsx(qd,{})}),v.jsx("button",{type:"button",className:"dataset-row-btn dataset-row-delete",title:"Delete row","aria-label":"Delete row",onClick:()=>{window.confirm(`Delete row ${ln+1}?`)&&on(async()=>{var y;await uf(e,t,Ft.id),Et?he(Wo):Nt(Wo),((y=Ot.current)==null?void 0:y.rowId)===Ft.id&&Gt(void 0),B(T=>T+1)})},children:v.jsx(yi,{})})]})}),Ti(je)&&je.rowId===Ft.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(eR,{dataset:st??g,row:Ft,onOpenTrace:s,onChangeRow:y=>Cn([{rowId:Ft.id,...y}]),sources:Wt})]});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:_e?v.jsx("form",{className:"dataset-view-rename",onSubmit:y=>{y.preventDefault(),Eo()},children:v.jsx("input",{autoFocus:!0,"aria-label":"Dataset name",value:xt,onChange:y=>pt(y.target.value),onFocus:y=>y.target.select(),onBlur:()=>mt(!1),onKeyDown:y=>y.key==="Escape"&&mt(!1)})}):v.jsx("span",{className:"trace-view-name",onDoubleClick:Er,title:"Double-click to rename",children:g.name})}),v.jsxs("div",{className:"trace-view-header-actions",children:[v.jsx(WS,{layout:ct,fields:(st==null?void 0:st.fields)??g.fields,instances:x.instances,rowLabel:bt,onChange:y=>Ht(y),onRowLabel:y=>Ht(ct,y??null),onAdd:tr,onRemove:y=>{const T=pu(ct,{index:y});Ht(pS(ct,y),T&&Dn(T)===Tr?null:bt??null)},describePath:$r,newField:Vr,onFieldAdded:qr}),v.jsxs("div",{className:"trace-view-header-actions-full",children:[Pn&&v.jsx(tR,{...Jr}),p&&v.jsx(Vd,{agents:m,onAsk:Ct}),v.jsx("button",{type:"button",className:"trace-view-prompt-btn trace-view-delete-btn",onClick:gn,title:"Delete dataset","aria-label":"Delete dataset",children:v.jsx(yi,{})})]}),v.jsx("button",{type:"button",ref:De,className:"trace-view-header-menu-trigger",onClick:()=>be(y=>!y),title:"More actions","aria-label":"More actions",children:v.jsx(Jd,{})})]})]}),v.jsxs("div",{className:"trace-view-meta",children:[v.jsxs("span",{className:"trace-view-meta-item",title:"Last updated",children:[v.jsx(ic,{}),v.jsx("span",{className:"trace-view-date-full",children:oc(g.updatedAt)}),v.jsx("span",{className:"trace-view-date-compact",children:Qd(g.updatedAt)})]}),v.jsxs("span",{className:"trace-view-meta-item",title:"Row count",children:[v.jsx(_a,{}),Jt," row",Jt===1?"":"s"]}),He&&v.jsxs("button",{type:"button",className:"trace-view-meta-item trace-view-prompt-link",onClick:()=>i(He),title:"Open the linked prompt",children:[v.jsx(Zd,{}),v.jsx("span",{className:"trace-view-prompt-link-name",children:He.name}),"↗"]})]})]}),To,Le&&Re&&v.jsx(uS,{..._n&&{field:_n},anchor:Le.anchor,onRename:async y=>{_n&&await kn(_n,y)},onDelete:()=>_n&&Dr(_n),onHide:()=>Ht(Bi(ct,Re.slot,!0)),...Zt&&{rowLabel:{isLabel:Dn(Zt)===Tr,toggle:()=>Ht(ct,Dn(Zt)===Tr?null:Zt)}},onClose:ue},Re.id),mo.createPortal(v.jsx("div",{ref:Ye,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:"×"})]}),He&&hn.length>0&&v.jsxs("div",{className:"dataset-view-stale",children:[hn.length," field",hn.length===1?"":"s"," no longer match"," ",v.jsx("code",{children:He.name}),"'s parameters:"," ",hn.map((y,T)=>v.jsxs("span",{children:[T>0&&", ",v.jsx("code",{children:y.def.name})]},y.id))]}),v.jsxs("div",{className:"trace-view-body dataset-view-body",ref:Ve,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${Et?"":" trace-view-tab-active"}`,onClick:()=>Gn("grid"),children:[v.jsx(_a,{}),"Grid"]}),v.jsx(ef,{tabs:Xt.tabs,active:Xt.shownUri,onSelect:y=>Gn(`view:${y}`)}),v.jsx(tf,{problems:Xt.problems})]}),v.jsx("button",{type:"button",className:`dataset-pane-toggle${J?" dataset-pane-toggle-active":""}`,onClick:W,disabled:Jt===0,title:"Row details","aria-label":"Row details","aria-pressed":!!J,children:v.jsx(nf,{})})]}),Ro&&v.jsx(rR,{viewLabel:Ir,rowName:`Row ${(oe??0)+1}`,stale:Ur,onSave:An,onDiscard:()=>Gt(void 0)}),v.jsxs("div",{className:"dataset-view-main",children:[Et&&v.jsx(nR,{rowCount:Jt,getRow:y=>xe.get(y),ensure:dt,label:y=>bt?Cs(y,bt):void 0,selected:oe,onSelect:At}),v.jsxs("div",{className:"view-stack",children:[v.jsxs("div",{className:"dataset-grid",ref:Io,style:Et?{display:"none"}:void 0,children:[v.jsx(kk,{ref:de,renderers:cR,imageWindowLoader:uR,headerIcons:vS,getGroupDetails:vt,width:"100%",height:"100%",theme:ye,columns:dn,rows:Jt,trailingRowOptions:sr,onRowAppended:er?Kr:void 0,getCellContent:kt,onVisibleRegionChanged:Ut,drawHeader:Je,rowMarkers:"both",rowSelect:"multi",rangeSelect:"rect",columnSelect:"none",gridSelection:Z,onGridSelectionChange:Nt,onCellClicked:cr,onCellActivated:Fn,onGroupHeaderClicked:ur,onHeaderMenuClick:Un,onColumnProposeMove:dr,onColumnMoved:fr,onCellsEdited:Yr,validateCell:lr,onDelete:Vt,onPaste:!0,getCellsForSelection:!0,fillHandle:!0,onColumnResize:(y,T)=>y.id&&fe({...H,widths:{...D,[y.id]:T}}),rowHeight:Zl,headerHeight:Ss,groupHeaderHeight:Rs,smoothScrollX:!0,smoothScrollY:!0,portalElementRef:Ye,rightElement:v.jsx(lS,{fields:(st==null?void 0:st.fields)??g.fields,instances:x.instances,describePath:$r,onPick:tr,newField:Vr,onFieldAdded:qr,top:fn?Rs:0,height:Ss}),rightElementProps:{sticky:!1,fill:!0}}),v.jsx("div",{className:"dataset-grid-fill",style:{top:xn},children:Jt===0&&!er&&v.jsx("p",{className:"dataset-grid-empty",children:"No fields yet. Add one with the “+” to start filling this dataset in by hand."})})]}),Et&&Jt===0&&v.jsx("div",{className:"view-frame-message",children:"No rows"}),Xt.layer]})]}),!it&&I&&v.jsx(Pa,{placement:"bottom",label:"Row details",children:I})]}),it&&I&&v.jsx(Pa,{placement:"side",label:"Row details",children:I})]})]})}const CR=Object.freeze(Object.defineProperty({__proto__:null,default:vR},Symbol.toStringTag,{value:"Module"}));export{GC as C,CR as D,gb as T,co as a,ep as b,so as i,hb as m,Sr as s};
16
+ `),rawValue:ve});return ht===void 0?void 0:(pn(ht.kind===Q.kind),{location:le,value:ht})}}}const R=W.columns,E=W.rows,O=((P=St.current)==null?void 0:P.contains(document.activeElement))===!0||((N=s.current)==null?void 0:N.contains(document.activeElement))===!0;let X;if(W.current!==void 0?X=[W.current.range.x,W.current.range.y]:R.length===1?X=[R.first()??0,0]:E.length===1&&(X=[$,E.first()??0]),O&&X!==void 0){let Q,le;const ve="text/plain",re="text/html";if(navigator.clipboard.read!==void 0){const Pe=await navigator.clipboard.read();for(const Ie of Pe){if(Ie.types.includes(re)){const Dt=await(await Ie.getType(re)).text(),Lt=Nl(Dt);if(Lt!==void 0){Q=Lt;break}}Ie.types.includes(ve)&&(le=await(await Ie.getType(ve)).text())}}else if(navigator.clipboard.readText!==void 0)le=await navigator.clipboard.readText();else if(f!==void 0&&(f==null?void 0:f.clipboardData)!==null){if(f.clipboardData.types.includes(re)){const Pe=f.clipboardData.getData(re);Q=Nl(Pe)}Q===void 0&&f.clipboardData.types.includes(ve)&&(le=f.clipboardData.getData(ve))}else return;const[Ae,we]=X,We=[];do{if(ue===void 0){const Pe=mn(X),Ie=le??(Q==null?void 0:Q.map(Dt=>Dt.map(Lt=>Lt.rawValue).join(" ")).join(" "))??"",ht=S(Pe,X,Ie,void 0);ht!==void 0&&We.push(ht);break}if(Q===void 0){if(le===void 0)return;Q=ik(le)}if(ue===!1||typeof ue=="function"&&(ue==null?void 0:ue([X[0]-$,X[1]],Q.map(Pe=>Pe.map(Ie=>{var ht;return((ht=Ie.rawValue)==null?void 0:ht.toString())??""}))))!==!0)return;for(const[Pe,Ie]of Q.entries()){if(Pe+we>=Re)break;for(const[ht,Dt]of Ie.entries()){const Lt=[ht+Ae,Pe+we],[cn,Yn]=Lt;if(cn>=Qe.length||Yn>=nn)continue;const Bn=mn(Lt),qn=S(Bn,Lt,Dt.rawValue,Dt.formatted);qn!==void 0&&We.push(qn)}}}while(!1);Mn(We),(K=Kt.current)==null||K.damage(We.map(Pe=>({cell:Pe.location})))}},[V,Mt,mn,W,gn.paste,St,Qe.length,Mn,nn,ue,$,Re]);an("paste",as,h,!1,!0);const Po=c.useCallback(async(f,S)=>{var P,N;if(!gn.copy)return;const R=S===!0||((P=St.current)==null?void 0:P.contains(document.activeElement))===!0||((N=s.current)==null?void 0:N.contains(document.activeElement))===!0,E=W.columns,O=W.rows,X=(K,Q)=>{if(!ye)Bl(K,Q,f);else{const le=Q.map(ve=>({kind:ce.Text,data:C[ve].title,displayData:C[ve].title,allowOverlay:!1}));Bl([le,...K],Q,f)}};if(R&&Y!==void 0){if(W.current!==void 0){let K=Y(W.current.range,I.current.signal);typeof K!="object"&&(K=await K()),X(K,Br(W.current.range.x-$,W.current.range.x+W.current.range.width-$))}else if(O!==void 0&&O.length>0){const Q=[...O].map(le=>{const ve=Y({x:$,y:le,width:C.length,height:1},I.current.signal);return typeof ve=="object"?ve[0]:ve().then(re=>re[0])});if(Q.some(le=>le instanceof Promise)){const le=await Promise.all(Q);X(le,Br(C.length))}else X(Q,Br(C.length))}else if(E.length>0){const K=[],Q=[];for(const le of E){let ve=Y({x:le,y:0,width:1,height:Re},I.current.signal);typeof ve!="object"&&(ve=await ve()),K.push(ve),Q.push(le-$)}if(K.length===1)X(K[0],Q);else{const le=K.reduce((ve,re)=>ve.map((Ae,we)=>[...Ae,...re[we]]));X(le,Q)}}}},[C,Y,W,gn.copy,$,St,Re,ye]);an("copy",Po,h,!1,!1);const Yu=c.useCallback(async f=>{var R,E;if(!(!gn.cut||!(((R=St.current)==null?void 0:R.contains(document.activeElement))===!0||((E=s.current)==null?void 0:E.contains(document.activeElement))===!0))&&(await Po(f),W.current!==void 0)){let O={current:{cell:W.current.cell,range:W.current.range,rangeStack:[]},rows:lt.empty(),columns:lt.empty()};const X=at==null?void 0:at(O);if(X===!1||(O=X===!0?O:X,O.current===void 0))return;Or(O.current.range)}},[Or,W,gn.cut,Po,St,at]);an("cut",Yu,h,!1,!1);const qu=c.useCallback((f,S)=>{if(Ee!==void 0){$!==0&&(f=f.map(O=>[O[0]-$,O[1]])),Ee(f,S);return}if(f.length===0||S===-1)return;const[R,E]=f[S];d.current!==void 0&&d.current[0]===R&&d.current[1]===E||(d.current=[R,E],yr(R,E,!1,!1))},[Ee,$,yr]),[fi,hi]=((Ia=Yt==null?void 0:Yt.current)==null?void 0:Ia.cell)??[],gi=c.useRef(Pt);gi.current=Pt,c.useLayoutEffect(()=>{var f,S,R,E;ss.current&&!Ar.current&&fi!==void 0&&hi!==void 0&&(fi!==((S=(f=y.current)==null?void 0:f.current)==null?void 0:S.cell[0])||hi!==((E=(R=y.current)==null?void 0:R.current)==null?void 0:E.cell[1]))&&gi.current(fi,hi),Ar.current=!1},[fi,hi]);const xa=W.current!==void 0&&(W.current.cell[0]>=Qe.length||W.current.cell[1]>=nn);c.useLayoutEffect(()=>{xa&&T(Ri,!1)},[xa,T]);const Vu=c.useMemo(()=>Ct===!0&&(Je==null?void 0:Je.tint)===!0?lt.fromSingleSelection(nn-1):lt.empty(),[nn,Ct,Je==null?void 0:Je.tint]),Ju=c.useCallback(f=>typeof gt=="boolean"?gt:(gt==null?void 0:gt(f-$))??!0,[$,gt]),Qu=c.useMemo(()=>{if(es===void 0||s.current===null)return null;const{bounds:f,group:S}=es,R=s.current.getBoundingClientRect();return c.createElement(YC,{bounds:f,group:S,canvasBounds:R,onClose:()=>ts(void 0),onFinish:E=>{ts(void 0),Se==null||Se(S,E)}})},[Se,es]),Zu=Math.min(Qe.length,Ye+(en?1:0));c.useImperativeHandle(t,()=>({appendRow:(f,S)=>pr(f+$,S),appendColumn:(f,S)=>ci(f,S),updateCells:f=>{var S;return $!==0&&(f=f.map(R=>({cell:[R.cell[0]+$,R.cell[1]]}))),(S=Kt.current)==null?void 0:S.damage(f)},getBounds:(f,S)=>{var R;if(!((s==null?void 0:s.current)===null||(St==null?void 0:St.current)===null)){if(f===void 0&&S===void 0){const E=s.current.getBoundingClientRect(),O=E.width/St.current.clientWidth;return{x:E.x-St.current.scrollLeft*O,y:E.y-St.current.scrollTop*O,width:St.current.scrollWidth*O,height:St.current.scrollHeight*O}}return(R=Kt.current)==null?void 0:R.getBounds((f??0)+$,S)}},focus:()=>{var f;return(f=Kt.current)==null?void 0:f.focus()},emit:async f=>{switch(f){case"delete":_o({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":_o({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":_o({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 Po(void 0,!0);break;case"paste":await as();break}},scrollTo:Pt,remeasureColumns:f=>{for(const S of f)ui(S+$)},getMouseArgsForPosition:(f,S,R)=>{if((Kt==null?void 0:Kt.current)===null)return;const E=Kt.current.getMouseArgsForPosition(f,S,R);if(E!==void 0)return{...E,location:[E.location[0]-$,E.location[1]]}}}),[pr,ci,ui,St,Po,_o,as,$,Pt]);const[Ca,ka]=Kn??[],ed=c.useCallback(f=>{const[S,R]=f;if(R===-1){ie!=="none"&&(ze(lt.fromSingleSelection(S),void 0,!1),sn());return}Ca===S&&ka===R||(Ue({cell:f,range:{x:S,y:R,width:1,height:1}},!0,!1,"keyboard-nav"),Pt(S,R))},[ie,sn,Pt,Ca,ka,Ue,ze]),[td,nd]=c.useState(!1),Sa=c.useRef(yc(f=>{nd(f)},5)),rd=c.useCallback(()=>{Sa.current(!0),W.current===void 0&&W.columns.length===0&&W.rows.length===0&&l===void 0&&Ue({cell:[$,oi],range:{x:$,y:oi,width:1,height:1}},!0,!1,"keyboard-select")},[oi,W,l,$,Ue]),od=c.useCallback(()=>{Sa.current(!1)},[]),[id,sd]=c.useMemo(()=>{let f;const S=(nt==null?void 0:nt.scrollbarWidthOverride)??Is(),R=Re+(Ct?1:0);if(typeof kn=="number")f=tn+R*kn;else{let O=0;const X=Math.min(R,10);for(let P=0;P<X;P++)O+=kn(P);O=Math.floor(O/X),f=tn+R*O}f+=S;const E=Qe.reduce((O,X)=>X.width+O,0)+S;return[`${Math.min(1e5,E)}px`,`${Math.min(1e5,f)}px`]},[Qe,nt==null?void 0:nt.scrollbarWidthOverride,kn,Re,Ct,tn]),ad=c.useMemo(()=>gb(ut),[ut]);return c.createElement(mb.Provider,{value:ut},c.createElement(ck,{style:ad,className:he,inWidth:b??id,inHeight:x??sd},c.createElement(GC,{fillHandle:At,drawFocusRing:lr,experimental:nt,fixedShadowX:Xt,fixedShadowY:Et,getRowThemeOverride:Zt,headerIcons:Jt,imageWindowLoader:ln,initialSize:Ft,isDraggable:Zn,onDragLeave:Ir,onRowMoved:vn,overscrollX:qr,overscrollY:Vr,preventDiagonalScrolling:zn,rightElement:Wn,rightElementProps:Gn,smoothScrollX:Ro,smoothScrollY:Ur,className:he,enableGroups:Rn,onCanvasFocused:rd,onCanvasBlur:od,canvasRef:s,onContextMenu:Ku,theme:ut,cellXOffset:$u,cellYOffset:oi,accessibilityHeight:rr.height,onDragEnd:Wu,columns:Qe,nonGrowWidth:wt,drawHeader:ft,onColumnProposeMove:Bu,drawCell:Ce,disabledRows:Vu,freezeColumns:Zu,lockColumns:$,firstColAccessible:$===0,getCellContent:mn,minColumnWidth:hn,maxColumnWidth:Qt,searchInputRef:a,showSearch:To,onSearchClose:gr,highlightRegions:Au,getCellsForSelection:Y,getGroupDetails:Vi,headerHeight:Dr,isFocused:td,groupHeaderHeight:Rn?$r:0,freezeTrailingRows:It+(Ct&&(Je==null?void 0:Je.sticky)===!0?1:0),hasAppendRow:Ct,onColumnResize:z,onColumnResizeEnd:ne,onColumnResizeStart:te,onCellFocused:ed,onColumnMoved:Lu,onDragStart:zu,onHeaderMenuClick:ju,onHeaderIndicatorClick:Nu,onItemHovered:is,isFilling:(l==null?void 0:l.fillHandle)===!0,onMouseMove:Ou,onKeyDown:_o,onKeyUp:Oe,onMouseDown:Fu,onMouseUp:Pu,onDragOverCell:qt,onDrop:Nt,onSearchResultsChanged:qu,onVisibleRegionChanged:Hu,clientSize:_t,rowHeight:kn,searchResults:J,searchValue:pe,onSearchValueChange:ae,rows:nn,scrollRef:St,selection:W,translateX:rr.tx,translateY:rr.ty,verticalBorder:Ju,gridRef:Kt,getCellRenderer:Mt,resizeIndicator:Kr}),Qu,o!==void 0&&c.createElement(c.Suspense,{fallback:null},c.createElement(wk,{...o,validateCell:me,bloom:H,id:Xu,getCellRenderer:Mt,className:(nt==null?void 0:nt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Ut,imageEditorOverride:m,portalElementRef:Yr,onFinishEditing:Uu,markdownDivCreateNode:g,isOutsideClick:Xr,customEventTarget:nt==null?void 0:nt.eventTarget}))))},Sk=c.forwardRef(kk);function Wl(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=xc(d,s,i.cellVerticalPadding),p=wc(t.contentAlign??"center",l,a,i.cellHorizontalPadding,m),g=vc(p,h,m),b=Cc(l+n,u+r,g);return Qs(t)&&b}const Rk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??"false"},kind:ce.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>Mk(e,e.cell.data,Qs(e.cell),e.cell.maxSize??e.theme.checkboxMaxSize,e.cell.hoverEffectIntensity??.35),onDelete:e=>({...e,data:!1}),onSelect:e=>{Wl(e)&&e.preventDefault()},onClick:e=>{if(Wl(e))return{...e.cell,data:au(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 Mk(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:b,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,b,x,u,d,h,r,m),C&&(i.globalAlpha=1)}const Ik=Sr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),Ek=e=>{const{bubbles:t}=e;return c.createElement(Ik,null,t.map((n,r)=>c.createElement("div",{key:r,className:"boe-bubble"},n)),c.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},Tk={getAccessibilityString:e=>Np(e.data),kind:ce.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=>Dk(e,e.cell.data),provideEditor:()=>e=>{const{value:t}=e;return c.createElement(Ek,{bubbles:t.data})},onPaste:()=>{}};function Dk(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)ho(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+Co(o,r))}function $k(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const Ak={getAccessibilityString:()=>"",kind:ce.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($k(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);ho(o,i.x+l,i.y+(i.height-u)/2,s,u,a.roundingRadius??3),o.fillStyle=Lr(a.textDark,.1),o.fill()},onPaste:()=>{}},Fk={getAccessibilityString:e=>e.row.toString(),kind:Tn.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:_k,measure:()=>44,draw:e=>Ok(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=Pk,n.textAlign="center",i}function Pk(e){const{ctx:t}=e;t.textAlign="start"}function Ok(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 b=7*(n?l:1);if(ia(a,u,n,o?d+b:d,h,o?m-b: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 b=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(b,C,h+p/2+Co(a,x)),l!==0&&(a.globalAlpha=1)}}const jk={getAccessibilityString:()=>"",kind:Tn.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:e=>Nk(e,e.cell.hint,e.cell.icon),onPaste:()=>{}};function Nk(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 b=h-8,x=l+8/2,C=u+8/2;s.drawSprite(n,"normal",r,x,C,b,a,m?1:i),p=b}else{p=24;const g=12,b=m?g:i*g,x=m?0:(1-i)*g*.5,C=a.cellHorizontalPadding+4;b>0&&(r.moveTo(l+C+x,u+h/2),r.lineTo(l+C+x+b,u+h/2),r.moveTo(l+C+x+b*.5,u+h/2-b*.5),r.lineTo(l+C+x+b*.5,u+h/2+b*.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+Co(r,a)),r.beginPath()}function uu(e,t,n,r,o,i,a){e.textBaseline="alphabetic";const s=Hk(e,o,r,t,(n==null?void 0:n.fullSize)??!1);e.beginPath(),ho(e,s.x,s.y,s.width,s.height,t.roundingRadius??4),e.globalAlpha=i,e.fillStyle=(n==null?void 0:n.bgColor)??Lr(t.textDark,.1),e.fill(),e.globalAlpha=1,e.fillStyle=t.textDark,e.textBaseline="middle",a==null||a("text")}function Hk(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 Bk=c.lazy(async()=>await ec(()=>import("./number-overlay-editor-BbQhagHP.js"),__vite__mapDeps([3,1,2]))),Lk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??""},kind:ce.Number,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,useLabel:!0,drawPrep:Ic,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&&uu(r,o,u,l,i,t,a),Tc(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(Bk,{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}}},zk={getAccessibilityString:e=>{var t;return((t=e.data)==null?void 0:t.toString())??""},kind:ce.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Ic,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&&uu(o,a,m,l,i,n,s),Tc(e,l,u,h,r)},measure:(e,t,n)=>{const r=t.displayData.split(`
17
+ `,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(Wp,{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}},Wk=new Set(["path","source"]);function Gk(e){return Wk.has(e.kind)}const Uk=16;function kr(e,t=[]){return{root:{field:e},keys:t}}function Xk(e,t=[]){return{root:{instance:e},keys:t}}function Mr(e){return"field"in e.root?e.root.field:void 0}function ca(e){return"instance"in e.root?e.root.instance:void 0}function Kk(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 Yk(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 du(e,t){const n=Yk(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>Uk)return{value:"n/a"};o={instance:r.name,arg:a}}const s=Kk(e,r).find(([l])=>l===a);if(!s)return{value:"n/a"};r=s[1]}return o?{value:r,argument:o}:{value:r}}function fu(e,t){return du(e,t).value}const qk=e=>e.replaceAll("%","%25").replaceAll("/","%2F");function Dn(e){return("field"in e.root?e.root.field:`@${e.root.instance}`)+e.keys.map(n=>`/${qk(n)}`).join("")}function ua(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)&&ua(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 Vk(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 Jk(e){const t=e.resources??{};return Vk(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 io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zk(e){if(!io(e))return"an update must be an object";if(typeof e.rowId!="string")return"an update needs a rowId";if(!io(e.cells))return"an update needs cells (use {} for none)";for(const[t,n]of Object.entries(e.cells))if(n!==null&&!(io(n)&&typeof n.kind=="string"))return`cell ${t} must be an input or null`;if(e.resources!==void 0){if(!io(e.resources))return"resources must be an object";for(const[t,n]of Object.entries(e.resources)){if(!ud(t))return`'${t}' isn't a valid instance name`;if(n!==null){if(!io(n)||typeof n.uri!="string")return`instance ${t} needs a resource uri`;if(n.args!==void 0&&!io(n.args))return`instance ${t}'s args must be an object`}}}}const Gl={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=Zk(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 eS(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=tc(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 tS(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 nS(e,t,n=[]){if(dd(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 rS(e){return e.kind==="primitive"?"":e.option.def.name}function oS(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 iS=60;function sS(e,t=iS){return e.length>t?`${e.slice(0,t-1)}…`:e}function hu(e){return e.value.map(t=>typeof t=="string"?t:`\${${t.expr}}`).join("")}function da(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`"${hu(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 aS(e){const t=e.lastIndexOf("#");return t>=0?e.slice(t+1):e}const lS="(unsupported)";function Vn(e){switch(e.kind){case"value":return sS(da(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 lS}}function Yo(e){switch(e.kind){case"primitive":return e.value??null;case"template":return hu(e);case"object":return Object.fromEntries(Object.entries(e.properties).map(([t,n])=>[t,Yo(n)]));case"array":case"tuple":return e.elements.map(Yo);default:return da(e)}}function cS({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}=Zo({open:i,onClose:s,matchTriggerWidth:!1}),h=i&&mo.createPortal(v.jsx("div",{className:"trace-column-picker dataset-column-picker",ref:u,style:d,role:"dialog","aria-label":"Add column",children:v.jsx(gu,{...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 gu({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(uS,{...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:kr(u.id),label:u.def.name,depth:0,describePath:n,onPick:r},u.id)),Object.entries(t).map(([u,d])=>v.jsx(Ls,{path:Xk(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 uS({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(()=>eS(n,r),[n,r]),g=c.useMemo(()=>tS(n),[n]),b=nS(s,p,g)??{kind:"primitive",type:"string"},x=oS(i,b),C=async()=>{if(!(!x||h)){m(!0);try{await hd(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:rS(b)||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:[fd.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:Vn(p.sample)},depth:r+1,describePath:o,onPick:i},p.key))]})]})}function dS({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:b,popoverRef:x,style:C}=Zo({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(G){m((G==null?void 0:G.message)??String(G)),g(!1)}}};return mo.createPortal(v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:b,"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 fS(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(!Gk(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,b=Dn(p);if(a.has(b))continue;const x=Mr(p);if(x!==void 0&&!r.has(x))continue;const[C,...w]=p.keys;if(x!==void 0&&C===void 0){a.add(b);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(b),l(x).keys.push({key:C,hidden:m,...g!==void 0&&{title:g}});continue}if(!h.added)continue}a.add(b),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 Lo=e=>e?{hidden:!0}:{};function hS(e){return e.flatMap(gS)}function gS(e){switch(e.kind){case"field":return[{kind:"path",path:kr(e.fieldId),...e.title!==void 0&&{title:e.title},...Lo(e.hidden)},...e.keys.map(t=>({kind:"path",path:kr(e.fieldId,[t.key]),...t.title!==void 0&&{title:t.title},...Lo(t.hidden)}))];case"added":return[{kind:"path",path:e.path,...e.title!==void 0&&{title:e.title},...Lo(e.hidden),added:!0}];case"source":return[{kind:"source",...Lo(e.hidden)}];case"unknown":{const{hidden:t,...n}=e.spec;return[{...n,...Lo(e.hidden)}]}}}function mu(e){if(e.kind==="field")return kr(e.fieldId);if(e.kind==="added")return e.path}function pu(e,t){const n=e[t.index];if(n)return t.key!==void 0?n.kind==="field"?kr(n.fieldId,[t.key]):void 0:mu(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 bu(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 mS(e,t,n){return bu(e,t,n)}function pS(e,t,n,r){return e.map((o,i)=>i===t&&o.kind==="field"?{...o,keys:bu(o.keys,n,r)}:o)}function bS(e,t){var n;return((n=e[t])==null?void 0:n.kind)==="added"?e.filter((r,o)=>o!==t):e}function yS(e,t){const n=Dn(t);for(const[r,o]of e.entries()){const i=mu(o);if(i&&Dn(i)===n)return{index:r};if(o.kind==="field"){for(const{key:a}of o.keys)if(Dn(kr(o.fieldId,[a]))===n)return{index:r,key:a}}}}function vS(e,t){const n=yS(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 Ul(e,t,n){const r=[...n];return e.map(o=>t(o)?r.shift()??o:o)}function Xl(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 yu="disclosureCollapsed",vu="disclosureExpanded",wS={[yu]:Xl("8.75,6.75 11.9,10 8.75,13.25"),[vu]:Xl("6.75,8.75 10,11.9 13.25,8.75")},zo={whole:240,key:160,added:200,source:96,unknown:120};function xS(e){return e.def.name}function wu(e,t){var o;const n=e.keys.at(-1);if(n!==void 0)return n;const r=Mr(e);return r===void 0?ca(e)??"":((o=t.find(i=>i.id===r))==null?void 0:o.def.name)??r}function CS(e,t){var o;const n=Mr(e);return[n===void 0?`◆ ${ca(e)}`:((o=t.find(i=>i.id===n))==null?void 0:o.def.name)??n,...e.keys].join(" › ")}function kS({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=gd(u.def.type),m={id:u.id,title:u.def.name,type:d,role:"whole",path:kr(u.id),width:zo.whole,slot:l,...h&&{base:h}};if(s.keys.length===0){i.push(m);break}const p=xS(u),g=s.keys.filter(b=>!b.hidden);if(!n.has(u.id)||g.length===0){i.push({...m,group:p});break}for(const{key:b}of g){const x=kr(u.id,[b]);i.push({id:Dn(x),title:b,group:p,role:"key",path:x,width:zo.key,slot:{index:a,key:b}})}break}case"added":i.push({id:Dn(s.path),title:s.title??wu(s.path,e),role:"added",path:s.path,width:zo.added,slot:l});break;case"source":i.push({id:"source",title:"source",role:"source",width:zo.source,slot:l});break;case"unknown":i.push({id:`?${a}`,title:"Unknown column",type:s.spec.kind,role:"unknown",kind:s.spec.kind,width:zo.unknown,slot:l});break}}return i}function SS(e){return(e==null?void 0:e.role)==="whole"?Mr(e.path):void 0}function xu(e){return e&&"path"in e?e.path:void 0}function RS(e){const t=xu(e);if(!t)return;const n=Mr(t);if(n!==void 0)return{field:n};const r=ca(t);return r!==void 0?{instance:r}:void 0}function Cu(e,t,n){const r=[...e],[o]=r.splice(t,1);return r.splice(n,0,o),r}function ku(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=Cu(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 MS(e,t,n,r){const o=t[n];if(!o||n===r||!ku(t,n,r))return e;const i=Cu(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=Ul(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 Ul(e.map((d,h)=>h),d=>u.has(d),l).map(d=>e[d])}function IS(e){const t=new Map;for(const n of e){const r="path"in n?Mr(n.path):void 0;n.group!==void 0&&r!==void 0&&(t.has(n.group)||t.set(n.group,r))}return t}function ES(e,t,n){const r=t.get(e);return r===void 0?{name:e}:{name:e,icon:n.has(r)?vu:yu}}function TS(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 DS(e,t.path);if(t.role!=="whole"||!t.base)return;const{base:n}=t,r=Mr(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 DS(e,t){var s;const{value:n,argument:r}=du(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=TS(i);if(a)return{base:a,instance:r.instance,arg:r.arg,spec:o,value:i}}function Su(e,t){return t==null||t===""?!0:e==="number"?typeof t=="number"&&Number.isFinite(t):typeof t===e}function $S(e,t){if(Su(e,t))return nc({kind:"primitive",value:t??void 0})}function Ru(e){return"fieldId"in e?{fieldId:e.fieldId}:{instance:e.instance,arg:e.arg,spec:e.spec}}function AS(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=$S(l.base,a);u===void 0||u===null&&!("fieldId"in l)||r.push({rowId:s.id,...Ru(l),cell:u})}return r}function FS(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,...Ru(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 Mu(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 PS(e){const t=Object.entries(e.properties);return t.length===0?"{}":`{ ${t.map(([n,r])=>`${n}: ${r.kind==="instance"?`◆ ${Vn(r)}`:Vn(r)}`).join(", ")} }`}function OS(e){const t=Object.entries(e.properties);return t.length===0?"{}":`{ ${t.map(([n,r])=>`${n}: ${da(r)}`).join(", ")} }`}function jS(e){switch(e.kind){case"instance":return{kind:"chip",text:`◆ ${Vn(e)}`};case"object":return{kind:"text",text:PS(e)};default:return{kind:"text",text:e.kind==="value"&&e.value.kind==="object"?OS(e.value):Vn(e)}}}function NS(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=fu(e,t.path),i=Qo(e,t);return i?{kind:"edit",base:i.base,value:i.value,text:typeof o=="object"?Vn(o):"—"}:o==="absent"?{kind:"empty"}:o==="n/a"?{kind:"n/a"}:jS(o)}}}function Cs(e,t){const n=fu(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 Vn(n)}}class HS{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]=Mu(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 Iu={expanded:new Set,widths:{}};function BS(e,t){return`dataset-layout:${e}:${t}`}function LS(e){if(typeof e!="object"||e===null)return Iu;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 zS(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 WS(e){return JSON.stringify({expanded:[...e.expanded],widths:e.widths})}const Kl=e=>e.key===void 0?`${e.index}`:`${e.index}/${e.key}`;function GS({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),[b,x]=c.useState(null),[C,w]=c.useState(null),[M,G]=c.useState(new Set),B=()=>{m(!1),g(!1)},{triggerRef:A,popoverRef:L,style:V}=Zo({open:h,onClose:B,matchTriggerWidth:!1}),k=b??e,F=r&&Dn(r),H=U=>{var Z;return((Z=t.find(he=>he.id===U))==null?void 0:Z.def.name)??U},j=U=>{if(!C||!b)return!1;if(C.key===void 0&&U.key===void 0)return U.index!==C.index&&(x(mS(b,C.index,U.index)),w({index:U.index})),!0;const Z=b[C.index];if(C.key===void 0||U.key===void 0||U.index!==C.index||(Z==null?void 0:Z.kind)!=="field")return!1;if(U.key!==C.key){const he=Z.keys.findIndex(ee=>ee.key===C.key),de=Z.keys.findIndex(ee=>ee.key===U.key);x(pS(b,C.index,he,de))}return!0},_=()=>{b&&b!==e&&o(b),x(null),w(null)},D=({slot:U,title:Z,detail:he,hidden:de,removable:ee,disclosure:q,dim:Se})=>{const se=Kl(U),oe=pu(k,U),Ee=!!oe&&Dn(oe)===F;return v.jsxs("div",{className:`trace-column-picker-row dataset-column-picker-row${U.key!==void 0?" dataset-column-picker-key":""}${C&&Kl(C)===se?" trace-column-picker-row-dragging":""}${Se?" dataset-column-picker-dim":""}`,onDragOver:J=>{j(U)&&J.preventDefault()},onDrop:J=>J.preventDefault(),children:[v.jsx("span",{className:"trace-column-picker-grab",draggable:!0,onDragStart:J=>{J.dataTransfer.effectAllowed="move",J.dataTransfer.setData("text/plain",se),x(e),w(U)},onDragEnd:_,title:"Drag to reorder",children:v.jsx(pd,{})}),q?v.jsx("button",{type:"button",className:"dataset-column-picker-disclosure","aria-label":`${q.open?"Hide":"Show"} ${Z}'s keys`,"aria-expanded":q.open,onClick:q.toggle,children:q.open?"▾":"▸"}):U.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 ${Z}`,checked:!de,onChange:()=>o(Bi(e,U,!de))}),v.jsx("span",{className:"dataset-column-picker-title",children:Z}),he&&v.jsx("span",{className:"dataset-column-picker-detail",children:he})]}),oe&&v.jsxs("span",{className:"dataset-column-picker-actions",children:[ee&&v.jsx("button",{type:"button",className:"dataset-column-picker-icon-btn","aria-label":`Remove column ${Z}`,title:"Remove column",onClick:()=>s(U.index),children:"✕"}),v.jsx("button",{type:"button",className:`dataset-column-picker-icon-btn${Ee?" dataset-column-picker-icon-btn-on":""}`,"aria-label":`Use ${Z} as row label`,"aria-pressed":Ee,title:Ee?"Don't use as row label":"Use as row label",onClick:()=>i(Ee?void 0:oe),children:v.jsx(bd,{filled:Ee})})]})]},se)},fe=(U,Z)=>{const he={index:Z};switch(U.kind){case"field":{const de=M.has(U.fieldId),ee=D({slot:he,title:H(U.fieldId),hidden:U.hidden,...U.keys.length>0&&{disclosure:{open:de,toggle:()=>{const q=new Set(M);q.delete(U.fieldId)||q.add(U.fieldId),G(q)}}}});return de?[ee,...U.keys.map(q=>D({slot:{index:Z,key:q.key},title:q.key,hidden:q.hidden}))]:ee}case"added":return D({slot:he,title:U.title??wu(U.path,t),detail:CS(U.path,t),hidden:U.hidden,removable:!0});case"source":return D({slot:he,title:"source",hidden:U.hidden});case"unknown":return D({slot:he,title:"Unknown column",detail:U.spec.kind,hidden:U.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?B():m(!0),children:[v.jsx(md,{}),"Columns",v.jsx(rc,{})]}),h&&mo.createPortal(v.jsx("div",{className:"trace-column-picker dataset-column-picker",ref:L,style:V,role:"dialog","aria-label":"Columns",children:p?v.jsx(gu,{fields:t,instances:n,describePath:l,onPick:U=>{a(U),g(!1)},newField:u,onFieldAdded:()=>{d(),g(!1)},onBack:()=>g(!1)}):v.jsxs(v.Fragment,{children:[k.flatMap((U,Z)=>fe(U,Z)),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 US(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 XS(e,t,n=[]){const r=[...t?[t]:[],...n.filter(u=>!tc(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=US(r),a={};for(const u of e){const d=Ea(u.def),h=o.find(g=>g.defs.some(b=>Ea(b)===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 b=i.get(g.type.syntax);b&&(p[g.path]=[...new Set([...p[g.path]??[],...b])])}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]=yd(r);return{selections:t,instances:vd(e.resources)}}function KS(e,t,n){const r={};for(const s of e){const l=wd(t.selections[s]),u=(l==null?void 0:l.kind)==="value"?nc(l.value):l??null;Go(u)!==Go(n.cells[s]??null)&&(r[s]=u)}const o=n.resources??{},i=xd(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:""};Go(l)!==Go(o[s]?d:null)&&(a[s]=l)}return{cells:r,...Object.keys(a).length>0&&{resources:a}}}function YS(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 qS(e){return Object.keys(e.cells).length>0||Object.keys(e.resources??{}).length>0}function Yl(e){const t=n=>Object.fromEntries(Object.entries(n).flatMap(([r,o])=>o.resources&&Object.keys(o.resources).length>0?[[r,o.resources]]:[]));return Go([t(e.selections),Object.entries(e.instances).map(([n,r])=>[n,r.uri,t(r.args)])])}function Go(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 VS({value:e}){return e.kind==="primitive"&&typeof e.value=="string"||e.kind==="template"?v.jsx("div",{className:"dataset-detail-text",children:Yo(e)}):e.kind==="object"||e.kind==="array"||e.kind==="tuple"?v.jsx(Fd,{data:Yo(e)}):v.jsx("code",{className:"dataset-detail-scalar",children:String(Yo(e))})}function Eu({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(Tu,{input:n})]},t))})}function Tu({input:e}){switch(e.kind){case"value":return v.jsx(VS,{value:e.value});case"object":return v.jsx(Eu,{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:"◆"}),Vn(e)]});case"dataset":case"input":return v.jsx("code",{className:"dataset-detail-scalar",children:Vn(e)});default:return v.jsx("span",{className:"dataset-detail-scalar",children:Vn(e)})}}function JS(e){const t=document.querySelector(`[data-field-id="${CSS.escape(e)}"]`);t&&Cd(t,"nearest")}const QS=[];function ZS({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:aS(r.uri)}),r.args&&Object.keys(r.args).length>0&&v.jsx(Eu,{inputs:r.args})]})]},n))})})}function eR({fields:e,row:t,sources:n,onChangeRow:r}){const o=(n==null?void 0:n.resources)??QS,i=c.useMemo(()=>new Map(o.map(k=>[k.uri,k])),[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 k=ks(t);l.current=k,s(k)}const p=k=>{const F=t.cells[k.id];return!!r&&(!!n||!F||F.kind==="value")},g=e.filter(p).map(k=>k.id),b=k=>{d(!1);const F=KS(g,n?k:{...k,instances:ks(t).instances},t);qS(F)&&(r==null||r(F))},x=k=>{const F=l.current,H=typeof k=="function"?k(F):k;l.current=H,s(H),Yl(H)!==Yl(F)?b(H):d(!0)},C=()=>{u&&b(l.current)},w=k=>{k.key!=="Enter"||k.shiftKey||k.defaultPrevented||k.nativeEvent.isComposing||(k.preventDefault(),C())},M=c.useRef(C);M.current=C,c.useEffect(()=>()=>M.current(),[]);const{instances:G}=a,B=c.useMemo(()=>({resources:Md(o,G),functionSlots:{},executeSlots:{},resourceSlots:Object.fromEntries(Object.entries((n==null?void 0:n.resourceSlots)??{}).map(([k,F])=>[k,Ta(F,o,G)]))}),[o,G,n]),A=(k,F)=>x(H=>{const j=typeof k=="function"?k(H.instances):k;if(!F)return{...H,instances:j};const[_,D]=F.kind==="rename"?[F.from,F.to]:[F.name,null];return{instances:j,selections:Ad(H.selections,_,D)}}),L=Dd({instances:G,catalogByUri:i,adopt:k=>{const F=$d(l.current.instances,k,i),j={...l.current,instances:F.instances};return l.current=j,s(j),d(!0),F.uri}}),V=!!r&&!!n;return v.jsxs(v.Fragment,{children:[e.map(k=>{const F=t.cells[k.id];return v.jsx(Ms,{"data-field-id":k.id,label:v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"dataset-detail-field",children:k.def.name}),v.jsx("span",{className:"dataset-detail-type",title:k.def.type.syntax,children:Di(k.def.type.syntax,32)})]}),children:v.jsxs("div",{className:"dataset-detail-cell",children:[p(k)?v.jsx("div",{className:"dataset-detail-editor",onBlur:H=>{H.currentTarget.contains(H.relatedTarget)||C()},onKeyDown:w,children:v.jsx(Id,{propDef:k.def,selection:a.selections[k.id]??{},onChange:H=>x(j=>({...j,selections:{...j.selections,[k.id]:H}})),resources:B.resources,slots:Ta(n==null?void 0:n.fieldSlots[k.id],o,G),context:n&&L})}):F?v.jsx(Tu,{input:F}):v.jsx("span",{className:"dataset-cell-empty",children:"—"}),r&&F&&v.jsx("button",{type:"button",className:"dataset-detail-clear",title:`Clear ${k.def.name}`,"aria-label":`Clear ${k.def.name}`,onClick:()=>r({cells:{[k.id]:null}}),children:"×"})]})},k.id)}),V?v.jsx(Ms,{label:v.jsx("span",{className:"dataset-detail-field"}),children:v.jsx("div",{className:"dataset-detail-editor",onBlur:k=>{k.currentTarget.contains(k.relatedTarget)||C()},onKeyDown:w,children:v.jsx(Ed,{instances:G,onChange:A,sources:B,catalog:o,referencedBy:k=>Td(k,G,[{selections:Object.fromEntries(e.flatMap(F=>a.selections[F.id]?[[F.def.name,a.selections[F.id]]]:[]))}]),context:L})})}):v.jsx(ZS,{row:t})]})}function tR({dataset:e,row:t,onOpenTrace:n,onChangeRow:r,sources:o}){const i=[{label:"Added",icon:v.jsx(ic,{}),value:oc(t.createdAt)}],{source:a}=t;return a&&i.push({label:"Source",icon:v.jsx(kd,{}),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(Sd,{children:v.jsx(Rd,{facts:i})}),v.jsx(eR,{fields:e.fields,row:t,sources:o,onChangeRow:r},t.id)]})})}function nR(e){const[t,n]=c.useState(!1),r=()=>n(!1),{triggerRef:o,popoverRef:i,style:a}=Zo({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(sc,{size:14}),"Evals",v.jsx(rc,{})]}),t&&mo.createPortal(v.jsx("div",{className:"trace-header-menu",ref:i,style:a,role:"menu",children:v.jsx(Du,{...e,onChosen:r})}),document.body)]})}function Du({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(sc,{size:14})}),v.jsx("span",{className:"trace-header-menu-item-label",children:"New eval…"})]})]})]})}const Nr=30;function rR({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/Nr),p=m+Math.ceil(h.clientHeight/Nr)+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*Nr;m<h.scrollTop?h.scrollTop=m:m+Nr>h.scrollTop+h.clientHeight&&(h.scrollTop=m+Nr-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*Nr},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*Nr},children:d})})}function oR({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 iR(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 sR(e,t,n){return e&&e.rowId===n.rowId?{...e,update:iR(e.update,n)}:{rowId:t.id,base:t,update:n}}function zs(e){return Mu(e.base,e.update)}function ql(e,t){return t!==void 0&&!ua(t,e.base)}function Ti(e){return!!e&&!ua(zs(e),e.base)}function aR(e,t){return(e==null?void 0:e.rowId)===t&&Ti(e)?e.base:void 0}const lR='"Geist Mono", ui-monospace, monospace';function Vl(){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 cR(){const[e,t]=c.useState(Vl);return c.useEffect(()=>_d(()=>t(Vl())),[]),e}const uR=[Fk,zk,Lk,Rk,Tk,Ak,jk];function Jl(e){switch(e.kind){case ce.Text:case ce.Number:case ce.Boolean:return{value:e.data};default:return}}const dR={setWindow:()=>{},loadOrGetImage:()=>{},setCallback:()=>{}};function Ql(e){try{const t=localStorage.getItem(e);if(t)return LS(JSON.parse(t))}catch{}return Iu}function fR(e,t){try{localStorage.setItem(e,WS(t))}catch{}}function hR(e){try{localStorage.removeItem(e)}catch{}}const Zl=32,Ss=32,Rs=26,gR=300,mR=[],pR=[],bR=[],Wo={columns:lt.empty(),rows:lt.empty()};function yR(e,t){const n=e.value===void 0&&{themeOverride:{textDark:t.textLight}};switch(e.base){case"boolean":return{kind:ce.Boolean,data:typeof e.value=="boolean"?e.value:null,allowOverlay:!1,readonly:!1};case"number":return{kind:ce.Number,data:typeof e.value=="number"?e.value:void 0,displayData:e.text,allowOverlay:!0,readonly:!1,...n};case"string":return{kind:ce.Text,data:typeof e.value=="string"?e.value:"",displayData:e.text,allowOverlay:!0,readonly:!1,...n}}}function vR(e,t){const n=(r,o={})=>({kind:ce.Text,data:r,displayData:r,allowOverlay:!1,readonly:!0,...o});switch(e.kind){case"loading":return{kind:ce.Loading,allowOverlay:!1};case"edit":return yR(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:ce.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 wR({providerId:e,datasetId:t,version:n,findPrompt:r,prompts:o=mR,onOpenPrompt:i,onOpenInPlayground:a,onOpenTrace:s,onDeleted:l,onNewEval:u,evals:d=pR,onRunStarted:h,agents:m=bR,onAskAgent:p}){var Y,ge,me;const[g,b]=c.useState(null),[x,C]=c.useState({rowCount:0,fields:{},instances:{}}),[w,M]=c.useState(null),[G,B]=c.useState(0),[A,L]=c.useState(0),V=c.useRef({count:0}),k=c.useRef(null),F=BS(e,t),[H,j]=c.useState(()=>Ql(F)),{expanded:_,widths:D}=H,fe=c.useCallback(y=>{j(y),fR(F,y)},[F]),U=c.useRef(F);c.useEffect(()=>{U.current!==F&&(U.current=F,j(Ql(F)))},[F]);const[Z,he]=c.useState(Wo),de=c.useRef(null),ee=`evalution.datasetTab:${e}/${t}`,[q,Se]=c.useState(()=>Da(ee)??"grid"),se=c.useRef(ee);c.useEffect(()=>{se.current!==ee&&(se.current=ee,Se(Da(ee)??"grid"))},[ee]);const[oe,Ee]=c.useState(null),[J,ae]=c.useState(),[pe,Ge]=c.useState(null),[Oe,rt]=c.useState(null),[je,Te]=c.useState(),Fe=c.useMemo(()=>new Pd(Gl,{selected:null}),[e,t]),[_e,mt]=c.useState(!1),[xt,pt]=c.useState(""),[ie,be]=c.useState(!1),Me=c.useCallback(()=>be(!1),[]),{triggerRef:De,popoverRef:ke,style:ot}=Zo({open:ie,onClose:Me,matchTriggerWidth:!1}),[Le,Ke]=c.useState(null),ue=c.useCallback(()=>Ke(null),[]),ye=cR(),Ye=c.useRef(null),{ref:Ve,isWide:it}=Od(760),xe=c.useMemo(()=>new HS((y,T)=>jd(e,t,y,T),()=>L(y=>y+1),y=>M(y.message)),[e,t]),dt=c.useCallback((y,T)=>xe.ensure(y,T),[xe]),Ne=c.useRef({start:0,end:0});c.useEffect(()=>{V.current={count:0},k.current=null},[e,t]),c.useEffect(()=>{let y=!1;return Nd(e,t).then(({dataset:T,rowCount:z,fields:ne,instances:te})=>{if(y)return;b(T),C({rowCount:z+V.current.count,fields:ne,instances:te??{}}),M(k.current),k.current=null,xe.invalidate();const{start:ft,end:Ce}=Ne.current;xe.ensure(ft,Math.min(Ce,z))}).catch(T=>!y&&M(T.message)),()=>{y=!0}},[e,t,n,G,xe]),c.useEffect(()=>{g&&Fe.setSubject({dataset:g,overview:x})},[Fe,g,x]);const He=g!=null&&g.prompt?r(g.prompt):void 0,st=c.useMemo(()=>{if(!g||!He)return g;const y=Hd(g.fields,He);return y===g.fields?g:{...g,fields:y}},[g,He]),Wt=Bd(st&&(!st.prompt||He)?XS(st.fields,He,o):void 0),ct=c.useMemo(()=>st?fS(st.columns,st.fields,x.fields):[],[st,x.fields]),$e=c.useMemo(()=>st?kS({fields:st.fields,layout:ct,expanded:_,shortType:y=>Di(y,24)}):[],[st,ct,_]),bt=g==null?void 0:g.rowLabel,Ht=c.useCallback((y,T=bt??null)=>{const z=hS(y);b(ne=>{if(!ne)return ne;const{rowLabel:te,...ft}=ne;return{...ft,columns:z,...T&&{rowLabel:T}}}),Ld(e,t,z,T).catch(ne=>{M(`Couldn't save the columns: ${ne.message}`),B(te=>te+1)})},[e,t,bt]),Yt=c.useMemo(()=>IS($e),[$e]),vt=c.useCallback(y=>ES(y,Yt,_),[Yt,_]),yn=c.useMemo(()=>new Map($e.map(y=>[y.id,y])),[$e]),dn=c.useMemo(()=>$e.map(y=>({id:y.id,title:y.title,width:D[y.id]??y.width,hasMenu:!0,...y.group!==void 0&&{group:y.group},...y.role==="unknown"&&{themeOverride:{textHeader:ye.textLight}}})),[$e,D,ye]),kt=c.useCallback(([y,T])=>vR(NS(xe.get(T),$e[y]),ye),[$e,xe,ye,A]),Ut=c.useCallback(y=>{const T=y.y,z=y.y+y.height;Ne.current={start:T,end:z},xe.ensure(T,Math.min(z,x.rowCount)),Ke(null)},[xe,x.rowCount]),Je=c.useCallback((y,T)=>{T();const z=yn.get(y.column.id??"");if(!(z!=null&&z.type))return;const{ctx:ne,rect:te,theme:ft}=y;ne.save(),ne.beginPath(),ne.rect(te.x,te.y,te.width,te.height),ne.clip(),ne.font=`${ft.headerFontStyle} ${ft.fontFamily}`,ne.textBaseline="middle";const Ce=ne.measureText(z.title);ne.font=`10.5px ${lR}`,ne.fillStyle=ft.textLight,ne.textBaseline="alphabetic",ne.fillText(z.type,te.x+ft.cellHorizontalPadding+Ce.width+6,te.y+te.height/2-Ce.alphabeticBaseline+.5),ne.restore()},[yn]),It=((Y=Z.current)==null?void 0:Y.cell[1])??Z.rows.first()??null,$t=It!==null&&It<x.rowCount?It:null,tt=$t!==null?xe.get($t):void 0,Rt=c.useRef(null);tt&&$t!==null&&(Rt.current={index:$t,row:tt});const gt=tt??($t!==null&&((ge=Rt.current)==null?void 0:ge.index)===$t?Rt.current.row:void 0),qt=c.useRef(void 0);c.useEffect(()=>()=>clearTimeout(qt.current),[]);const Nt=c.useCallback(y=>{if(he(y),clearTimeout(qt.current),!y.current&&y.rows.length===0)ae(T=>T&&void 0);else{if(J!==void 0)return;y.rows.length>0?ae(!0):qt.current=setTimeout(()=>ae(T=>T??!0),gR)}},[J]),Ot=c.useRef(je),Gt=c.useCallback(y=>{Ot.current=y,Te(y)},[]),Be=oe!==null&&oe<x.rowCount?xe.get(oe):void 0,$n=()=>{const y=Ot.current;return Ti(y)?window.confirm("Discard the unsaved changes to this row?")?(Gt(void 0),!0):!1:(y&&Gt(void 0),!0)},At=y=>{y===oe||!$n()||Ee(y)},nt=y=>{switch(y.name){case"selectRow":At(y.args.index);return;case"showInstance":{const{name:T}=y.args;if(!Be||!Object.hasOwn(Be.resources??{},T))return`the row has no stored instance ${T}`;ae(!0),Ge(T);return}case"proposeUpdate":{const{update:T}=y.args;if(!Be||Be.id!==T.rowId)return"the row isn't loaded";const z=Ot.current,ne=sR((z==null?void 0:z.rowId)===Be.id?z:void 0,Be,T),te=Jk(zs(ne));if(te.length>0)return`That would leave references to instances the row doesn't declare: ${te.map(Qk).join("; ")}`;Gt(ne);return}default:return`no action ${y.name}`}},Xt=zd({surface:Gl,channel:Fe,activeUri:q.startsWith("view:")?q.slice(5):null,onAction:nt}),Et=Xt.shownUri!==null,Jt=c.useMemo(()=>Et?[]:Z.rows.toArray().filter(y=>y<x.rowCount),[Et,Z.rows,x.rowCount]);c.useEffect(()=>{pe&&($a(pe),Ge(null))},[pe]);const ln=J?Et?oe:$t:null,Ft=J?Et?Be:gt:void 0,Zn=Ft==null?void 0:Ft.id;c.useEffect(()=>{!Oe||Zn===void 0||("field"in Oe?JS(Oe.field):$a(Oe.instance),rt(null))},[Oe,Zn]);const Ir=((me=Xt.tabs.find(y=>y.uri===Xt.shownUri))==null?void 0:me.label)??Wd(Xt.shownUri??"");c.useEffect(()=>{if(!Et)return;const{rowCount:y}=x;y===0?Ee(null):oe===null?Ee(0):oe>=y&&Ee(y-1)},[Et,oe,x]),c.useEffect(()=>{Et&&oe!==null&&xe.ensure(oe,Math.min(oe+1,x.rowCount))},[Et,oe,xe,x.rowCount]);const vn=Et?oe:$t,rn=Et?Be:gt,wn=c.useMemo(()=>rn&&(je==null?void 0:je.rowId)===rn.id?zs(je):rn,[rn,je]),zn=wn&&bt?Cs(wn,bt):void 0,Wn=rn&&aR(je,rn.id);c.useEffect(()=>{Fe.setContext({selected:wn&&vn!==null?{index:vn,row:wn,...Wn&&{stored:Wn},...zn!==void 0&&{label:zn}}:null})},[Fe,wn,vn,zn,Wn]);const Gn=y=>{if(!(y===q||!$n())){if(y.startsWith("view:")&&!Et)Ee($t);else if(y==="grid"&&Et&&oe!==null){he({columns:lt.empty(),rows:lt.fromSingleSelection(oe)}),ae(z=>z??!0);const T=oe;requestAnimationFrame(()=>{var z;return(z=de.current)==null?void 0:z.scrollTo(0,T)})}Se(y),df(ee,y)}},An=()=>{const y=Ot.current;if(y){if(!Be||Be.id!==y.rowId||ql(y,Be)){M("This row changed since you started; discard and redo.");return}Gt(void 0),Cn([y.update]).then(T=>{!T&&!Ot.current&&Gt(y)})}},Ro=Et&&Ti(je)&&(Be==null?void 0:Be.id)===je.rowId,Ur=!!je&&!!Be&&Be.id===je.rowId&&ql(je,Be),Mo=y=>{const T=xe.get(y);!g||!He||!T||a(He,rf(of(g,T),He,{type:"dataset",description:`${g.name}, row ${y+1}`,providerId:e,datasetId:t,name:g.name},T.resources))},er=!!g&&g.fields.length>0,fn=$e.some(y=>y.group!==void 0),xn=(fn?Rs:0)+Ss+(x.rowCount+(er?1:0))*Zl+1,{ref:Io,matches:Xr}=Gd(c.useCallback(y=>xn>y.height,[xn])),sr=c.useMemo(()=>er?{hint:"New row",sticky:Xr}:void 0,[er,Xr]),Kr=c.useCallback(()=>{const y=V.current;y.count++,C(z=>({...z,rowCount:z.rowCount+1}));const T=()=>{y.count--,y===V.current&&B(z=>z+1)};return Aa(e,t,[{cells:{}}]).then(T,z=>{y===V.current&&(k.current=z.message,M(z.message)),T()}),Promise.resolve("bottom")},[e,t]),Cn=c.useCallback(async y=>{if(y.length===0)return!0;xe.patch(y),L(T=>T+1);try{return await Ud(e,t,y),!0}catch(T){M(`Couldn't save: ${T.message}`),xe.invalidate();const{start:z,end:ne}=Ne.current;return xe.ensure(z,Math.min(ne,x.rowCount)),oe!==null&&xe.ensure(oe,oe+1),!1}},[xe,e,t,x.rowCount,oe]),ar=c.useCallback(y=>Cn(_S(y)),[Cn]),Yr=c.useCallback(y=>{const T=[];for(const{location:z,value:ne}of y){const te=Jl(ne);te&&T.push({col:z[0],row:z[1],...te})}return ar(AS(T,$e,z=>xe.get(z))),!0},[$e,xe,ar]),lr=c.useCallback(([y,T],z)=>{var ft;const ne=(ft=Qo(xe.get(T),$e[y]))==null?void 0:ft.base,te=Jl(z);return ne!==void 0&&!!te&&Su(ne,te.value)},[$e,xe]),yt=c.useCallback(async y=>{var z;if(y.length===0)return;const T=y.length===1?`row ${y[0]+1}`:`${y.length} rows`;if(window.confirm(`Delete ${T}?`))try{const ne=(await xe.rowsAt(y)).map(ft=>ft.id);await Xd(e,t,ne),Nt(Wo);const te=(z=Ot.current)==null?void 0:z.rowId;te!==void 0&&ne.includes(te)&&Gt(void 0),B(ft=>ft+1)}catch(ne){M(ne.message)}},[xe,e,t,Nt,Gt]),Vt=c.useCallback(y=>{const{current:T}=y;return T?ar(FS([T.range,...T.rangeStack],$e,z=>xe.get(z))):y.rows.length>0&&yt(y.rows.toArray()),!1},[$e,xe,ar,yt]),cr=c.useCallback(([y,T])=>{var te;const z=$e[y],ne=(te=xe.get(T))==null?void 0:te.source;(z==null?void 0:z.role)==="source"&&(ne==null?void 0:ne.kind)==="trace"&&s(ne.traceProviderId,ne.traceId),rt(J===!1?null:RS(z)??null)},[$e,xe,s,J]),Fn=c.useCallback(([y,T])=>{Qo(xe.get(T),$e[y])&&(clearTimeout(qt.current),rt(null))},[$e,xe]),ur=c.useCallback((y,T)=>{const z=$e[y],ne=z&&"path"in z?Mr(z.path):void 0;if(ne===void 0)return;T.preventDefault();const te=new Set(_);te.delete(ne)||te.add(ne),fe({...H,expanded:te})},[$e,_,H,fe]),Un=c.useCallback((y,T)=>{const z=$e[y];z&&Ke({columnId:z.id,anchor:T})},[$e]),dr=c.useCallback((y,T)=>ku($e,y,T),[$e]),fr=c.useCallback((y,T)=>{const z=MS(ct,$e,y,T);z!==ct&&Ht(z)},[ct,$e,Ht]),on=async y=>{try{await y()}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 hn=He?Kd(g.fields,He):[],{rowCount:Qt}=x,Eo=()=>on(async()=>{const y=xt.trim();mt(!1),!(!y||y===g.name)&&b(await sf(e,t,y))}),Er=()=>{pt(g.name),mt(!0)},Re=Le?$e.find(y=>y.id===Le.columnId):void 0,hr=SS(Re),_n=hr!==void 0?g.fields.find(y=>y.id===hr):void 0,Zt=xu(Re),Tr=bt&&Dn(bt),kn=async(y,T)=>{const z=await cf(e,t,y.id,T);b({...g,fields:g.fields.map(ne=>ne.id===z.id?z:ne)}),B(ne=>ne+1)},Dr=y=>{Ke(null),window.confirm(`Delete the field “${y.def.name}” and its values in every row?`)&&on(async()=>{await lf(e,t,y.id),fe(zS(H,y.id)),Nt(Wo),B(T=>T+1)})},$r=y=>af(e,t,y),tr=y=>Ht(vS(ct,y)),qr=()=>B(y=>y+1),Vr={providerId:e,datasetId:t,prompts:o,...g.prompt&&{linked:g.prompt}},gn=()=>{window.confirm(mf(g,Qt))&&on(async()=>{await ff(e,t),hR(F),l()})},Xn=()=>u==null?void 0:u({dataset:{providerId:e,id:t},...(He==null?void 0:He.providerId)&&{prompt:{id:He.id,providerId:He.providerId}}}),en=async()=>(await xe.rowsAt(Jt)).map(y=>y.id),$=y=>on(async()=>{const T=Jt.length>0?await en():void 0;try{const z=await hf(y.providerId,y.id,{...T&&{rowIds:T}});h==null||h(y,z)}catch(z){throw z instanceof gf?new Error(`Can't run ${y.name}: ${z.problems.join("; ")}`):z}}),Ct=y=>on(async()=>{Jt.length>0?p==null||p(y,await en()):p==null||p(y,rn&&[rn.id])}),Sn=d.filter(y=>y.dataset.providerId===e&&y.dataset.id===t),Jr={evals:Sn,selectedRows:Jt.length,onRun:$,...u&&{onNewEval:Xn}},Pn=Sn.length>0||!!u,To=ie&&mo.createPortal(v.jsxs("div",{className:"trace-header-menu",ref:ke,style:ot,children:[Pn&&v.jsx(Du,{...Jr,onChosen:Me}),p&&v.jsx(Yd,{agents:m.filter(y=>!y.disabledReason),onAsk:y=>{be(!1),Ct(y)}}),(Pn||p)&&v.jsx("hr",{className:"ask-agent-menu-divider"}),v.jsxs("button",{type:"button",className:"trace-header-menu-item dataset-menu-delete",onClick:()=>{be(!1),gn()},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),gr=Ft&&bt?Cs(Ft,bt):void 0,ri=y=>on(async()=>{const T=x.rowCount;await Aa(e,t,[YS(y)]),B(z=>z+1),Et||(he({columns:lt.empty(),rows:lt.fromSingleSelection(T)}),requestAnimationFrame(()=>{var z;return(z=de.current)==null?void 0:z.scrollTo(0,T)}))}),W=()=>{var T,z;if(ae(!J),J||Et||It!==null)return;const y=Math.min(((T=Rt.current)==null?void 0:T.index)??0,Qt-1);he({columns:lt.empty(),rows:lt.fromSingleSelection(y)}),(z=de.current)==null||z.scrollTo(0,y)},I=J&&Jt.length>1?v.jsx(Fa,{title:v.jsxs("span",{className:"trace-row-name",children:[Jt.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 yt(Jt),children:v.jsx(yi,{})})}):Ft&&ln!==null&&v.jsxs(v.Fragment,{children:[v.jsx(Fa,{title:v.jsxs("span",{className:"trace-row-name",children:["Row ",ln+1,v.jsxs("code",{className:"dataset-row-id",children:[" · ",Ft.id]})]}),subtitle:gr,actions:v.jsxs(v.Fragment,{children:[He&&v.jsx("button",{type:"button",className:"dataset-row-btn",title:`Open in playground (${He.name})`,"aria-label":"Open row in playground",onClick:()=>Mo(ln),children:"▶"}),v.jsx("button",{type:"button",className:"dataset-row-btn",title:"Duplicate row","aria-label":"Duplicate row",onClick:()=>void ri(Ft),children:v.jsx(qd,{})}),v.jsx("button",{type:"button",className:"dataset-row-btn dataset-row-delete",title:"Delete row","aria-label":"Delete row",onClick:()=>{window.confirm(`Delete row ${ln+1}?`)&&on(async()=>{var y;await uf(e,t,Ft.id),Et?he(Wo):Nt(Wo),((y=Ot.current)==null?void 0:y.rowId)===Ft.id&&Gt(void 0),B(T=>T+1)})},children:v.jsx(yi,{})})]})}),Ti(je)&&je.rowId===Ft.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(tR,{dataset:st??g,row:Ft,onOpenTrace:s,onChangeRow:y=>Cn([{rowId:Ft.id,...y}]),sources:Wt})]});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:_e?v.jsx("form",{className:"dataset-view-rename",onSubmit:y=>{y.preventDefault(),Eo()},children:v.jsx("input",{autoFocus:!0,"aria-label":"Dataset name",value:xt,onChange:y=>pt(y.target.value),onFocus:y=>y.target.select(),onBlur:()=>mt(!1),onKeyDown:y=>y.key==="Escape"&&mt(!1)})}):v.jsx("span",{className:"trace-view-name",onDoubleClick:Er,title:"Double-click to rename",children:g.name})}),v.jsxs("div",{className:"trace-view-header-actions",children:[v.jsx(GS,{layout:ct,fields:(st==null?void 0:st.fields)??g.fields,instances:x.instances,rowLabel:bt,onChange:y=>Ht(y),onRowLabel:y=>Ht(ct,y??null),onAdd:tr,onRemove:y=>{const T=pu(ct,{index:y});Ht(bS(ct,y),T&&Dn(T)===Tr?null:bt??null)},describePath:$r,newField:Vr,onFieldAdded:qr}),v.jsxs("div",{className:"trace-view-header-actions-full",children:[Pn&&v.jsx(nR,{...Jr}),p&&v.jsx(Vd,{agents:m,onAsk:Ct}),v.jsx("button",{type:"button",className:"trace-view-prompt-btn trace-view-delete-btn",onClick:gn,title:"Delete dataset","aria-label":"Delete dataset",children:v.jsx(yi,{})})]}),v.jsx("button",{type:"button",ref:De,className:"trace-view-header-menu-trigger",onClick:()=>be(y=>!y),title:"More actions","aria-label":"More actions",children:v.jsx(Jd,{})})]})]}),v.jsxs("div",{className:"trace-view-meta",children:[v.jsxs("span",{className:"trace-view-meta-item",title:"Last updated",children:[v.jsx(ic,{}),v.jsx("span",{className:"trace-view-date-full",children:oc(g.updatedAt)}),v.jsx("span",{className:"trace-view-date-compact",children:Qd(g.updatedAt)})]}),v.jsxs("span",{className:"trace-view-meta-item",title:"Row count",children:[v.jsx(_a,{}),Qt," row",Qt===1?"":"s"]}),He&&v.jsxs("button",{type:"button",className:"trace-view-meta-item trace-view-prompt-link",onClick:()=>i(He),title:"Open the linked prompt",children:[v.jsx(Zd,{}),v.jsx("span",{className:"trace-view-prompt-link-name",children:He.name}),"↗"]})]})]}),To,Le&&Re&&v.jsx(dS,{..._n&&{field:_n},anchor:Le.anchor,onRename:async y=>{_n&&await kn(_n,y)},onDelete:()=>_n&&Dr(_n),onHide:()=>Ht(Bi(ct,Re.slot,!0)),...Zt&&{rowLabel:{isLabel:Dn(Zt)===Tr,toggle:()=>Ht(ct,Dn(Zt)===Tr?null:Zt)}},onClose:ue},Re.id),mo.createPortal(v.jsx("div",{ref:Ye,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:"×"})]}),He&&hn.length>0&&v.jsxs("div",{className:"dataset-view-stale",children:[hn.length," field",hn.length===1?"":"s"," no longer match"," ",v.jsx("code",{children:He.name}),"'s parameters:"," ",hn.map((y,T)=>v.jsxs("span",{children:[T>0&&", ",v.jsx("code",{children:y.def.name})]},y.id))]}),v.jsxs("div",{className:"trace-view-body dataset-view-body",ref:Ve,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${Et?"":" trace-view-tab-active"}`,onClick:()=>Gn("grid"),children:[v.jsx(_a,{}),"Grid"]}),v.jsx(ef,{tabs:Xt.tabs,active:Xt.shownUri,onSelect:y=>Gn(`view:${y}`)}),v.jsx(tf,{problems:Xt.problems})]}),v.jsx("button",{type:"button",className:`dataset-pane-toggle${J?" dataset-pane-toggle-active":""}`,onClick:W,disabled:Qt===0,title:"Row details","aria-label":"Row details","aria-pressed":!!J,children:v.jsx(nf,{})})]}),Ro&&v.jsx(oR,{viewLabel:Ir,rowName:`Row ${(oe??0)+1}`,stale:Ur,onSave:An,onDiscard:()=>Gt(void 0)}),v.jsxs("div",{className:"dataset-view-main",children:[Et&&v.jsx(rR,{rowCount:Qt,getRow:y=>xe.get(y),ensure:dt,label:y=>bt?Cs(y,bt):void 0,selected:oe,onSelect:At}),v.jsxs("div",{className:"view-stack",children:[v.jsxs("div",{className:"dataset-grid",ref:Io,style:Et?{display:"none"}:void 0,children:[v.jsx(Sk,{ref:de,renderers:uR,imageWindowLoader:dR,headerIcons:wS,getGroupDetails:vt,width:"100%",height:"100%",theme:ye,columns:dn,rows:Qt,trailingRowOptions:sr,onRowAppended:er?Kr:void 0,getCellContent:kt,onVisibleRegionChanged:Ut,drawHeader:Je,rowMarkers:"both",rowSelect:"multi",rangeSelect:"rect",columnSelect:"none",gridSelection:Z,onGridSelectionChange:Nt,onCellClicked:cr,onCellActivated:Fn,onGroupHeaderClicked:ur,onHeaderMenuClick:Un,onColumnProposeMove:dr,onColumnMoved:fr,onCellsEdited:Yr,validateCell:lr,onDelete:Vt,onPaste:!0,getCellsForSelection:!0,fillHandle:!0,onColumnResize:(y,T)=>y.id&&fe({...H,widths:{...D,[y.id]:T}}),rowHeight:Zl,headerHeight:Ss,groupHeaderHeight:Rs,smoothScrollX:!0,smoothScrollY:!0,portalElementRef:Ye,rightElement:v.jsx(cS,{fields:(st==null?void 0:st.fields)??g.fields,instances:x.instances,describePath:$r,onPick:tr,newField:Vr,onFieldAdded:qr,top:fn?Rs:0,height:Ss}),rightElementProps:{sticky:!1,fill:!0}}),v.jsx("div",{className:"dataset-grid-fill",style:{top:xn},children:Qt===0&&!er&&v.jsx("p",{className:"dataset-grid-empty",children:"No fields yet. Add one with the “+” to start filling this dataset in by hand."})})]}),Et&&Qt===0&&v.jsx("div",{className:"view-frame-message",children:"No rows"}),Xt.layer]})]}),!it&&I&&v.jsx(Pa,{placement:"bottom",label:"Row details",children:I})]}),it&&I&&v.jsx(Pa,{placement:"side",label:"Row details",children:I})]})]})}const kR=Object.freeze(Object.defineProperty({__proto__:null,default:wR},Symbol.toStringTag,{value:"Module"}));export{UC as C,kR as D,mb as T,co as a,tp as b,so as i,gb as m,Sr as s};