evalution 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
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}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/data-grid-overlay-editor-BuUUbLjU.js","assets/index-BK0ALIOn.js","assets/index-KCv8AeiY.css","assets/number-overlay-editor-DIsrCfnq.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-BK0ALIOn.js";function mf(e,t){const n=`Delete “${e.name}” and its ${t} row${t===1?"":"s"}?`;return e.synced?`${n}
3
3
 
4
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
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(`
@@ -11,7 +11,7 @@ It's synced with Evalution Cloud, so it will also be deleted from the cloud and
11
11
  `?(r.push(e.slice(o,a)),o=a+1,s===`
12
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===`
13
13
  `)&&(r.push(Hl(e.slice(o,a))),o=a+1,s===`
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(`
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-BuUUbLjU.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(`
15
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(`
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(`
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-DIsrCfnq.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
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};