react-semaphor 0.0.204 → 0.0.205

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.
@@ -85,7 +85,7 @@ __p += '`),Mt&&(Re+=`' +
85
85
  function print() { __p += __j.call(arguments, '') }
86
86
  `:`;
87
87
  `)+Re+`return __p
88
- }`;var yt=kE(function(){return jt(j,Ye+"return "+Re).apply(n,U)});if(yt.source=Re,ub(yt))throw yt;return yt}function _8(d){return Ut(d).toLowerCase()}function S8(d){return Ut(d).toUpperCase()}function C8(d,p,y){if(d=Ut(d),d&&(y||p===n))return VS(d);if(!d||!(p=Vr(p)))return d;var E=jo(d),M=jo(p),j=HS(E,M),U=WS(E,M)+1;return Os(E,j,U).join("")}function E8(d,p,y){if(d=Ut(d),d&&(y||p===n))return d.slice(0,qS(d)+1);if(!d||!(p=Vr(p)))return d;var E=jo(d),M=WS(E,jo(p))+1;return Os(E,0,M).join("")}function R8(d,p,y){if(d=Ut(d),d&&(y||p===n))return d.replace(jn,"");if(!d||!(p=Vr(p)))return d;var E=jo(d),M=HS(E,jo(p));return Os(E,M).join("")}function O8(d,p){var y=I,E=F;if(wn(p)){var M="separator"in p?p.separator:M;y="length"in p?pt(p.length):y,E="omission"in p?Vr(p.omission):E}d=Ut(d);var j=d.length;if(Nl(d)){var U=jo(d);j=U.length}if(y>=j)return d;var X=y-Ll(E);if(X<1)return E;var se=U?Os(U,0,X).join(""):d.slice(0,X);if(M===n)return se+E;if(U&&(X+=se.length-X),db(M)){if(d.slice(X).search(M)){var xe,we=se;for(M.global||(M=Ov(M.source,Ut(qe.exec(M))+"g")),M.lastIndex=0;xe=M.exec(we);)var Re=xe.index;se=se.slice(0,Re===n?X:Re)}}else if(d.indexOf(Vr(M),X)!=X){var je=se.lastIndexOf(M);je>-1&&(se=se.slice(0,je))}return se+E}function P8(d){return d=Ut(d),d&&Rn.test(d)?d.replace(Xt,rF):d}var T8=Wl(function(d,p,y){return d+(y?" ":"")+p.toUpperCase()}),pb=MC("toUpperCase");function AE(d,p,y){return d=Ut(d),p=y?n:p,p===n?J3(d)?sF(d):H3(d):d.match(p)||[]}var kE=St(function(d,p){try{return zr(d,n,p)}catch(y){return ub(y)?y:new ct(y)}}),D8=Fi(function(d,p){return mo(p,function(y){y=ai(y),Ni(d,y,lb(d[y],d))}),d});function $8(d){var p=d==null?0:d.length,y=Je();return d=p?yn(d,function(E){if(typeof E[1]!="function")throw new vo(s);return[y(E[0]),E[1]]}):[],St(function(E){for(var M=-1;++M<p;){var j=d[M];if(zr(j[0],this,E))return zr(j[1],this,E)}})}function A8(d){return r7(yo(d,f))}function gb(d){return function(){return d}}function k8(d,p){return d==null||d!==d?p:d}var M8=NC(),I8=NC(!0);function Er(d){return d}function mb(d){return fC(typeof d=="function"?d:yo(d,f))}function N8(d){return pC(yo(d,f))}function L8(d,p){return gC(d,yo(p,f))}var F8=St(function(d,p){return function(y){return _u(y,d,p)}}),j8=St(function(d,p){return function(y){return _u(d,y,p)}});function vb(d,p,y){var E=Bn(p),M=wh(p,E);y==null&&!(wn(p)&&(M.length||!E.length))&&(y=p,p=d,d=this,M=wh(p,Bn(p)));var j=!(wn(y)&&"chain"in y)||!!y.chain,U=zi(d);return mo(M,function(X){var se=p[X];d[X]=se,U&&(d.prototype[X]=function(){var xe=this.__chain__;if(j||xe){var we=d(this.__wrapped__),Re=we.__actions__=_r(this.__actions__);return Re.push({func:se,args:arguments,thisArg:d}),we.__chain__=xe,we}return se.apply(d,ws([this.value()],arguments))})}),d}function z8(){return qn._===this&&(qn._=fF),this}function bb(){}function B8(d){return d=pt(d),St(function(p){return mC(p,d)})}var V8=Kv(yn),H8=Kv(LS),W8=Kv(xv);function ME(d){return nb(d)?wv(ai(d)):x7(d)}function U8(d){return function(p){return d==null?n:Ea(d,p)}}var q8=FC(),G8=FC(!0);function yb(){return[]}function xb(){return!1}function Y8(){return{}}function K8(){return""}function X8(){return!0}function Q8(d,p){if(d=pt(d),d<1||d>Y)return[];var y=H,E=nr(d,H);p=Je(p),d-=H;for(var M=Cv(E,p);++y<d;)p(y);return M}function J8(d){return ut(d)?yn(d,ai):Hr(d)?[d]:_r(eE(Ut(d)))}function Z8(d){var p=++uF;return Ut(d)+p}var ej=Oh(function(d,p){return d+p},0),tj=Xv("ceil"),nj=Oh(function(d,p){return d/p},1),rj=Xv("floor");function oj(d){return d&&d.length?xh(d,Er,Iv):n}function ij(d,p){return d&&d.length?xh(d,Je(p,2),Iv):n}function sj(d){return zS(d,Er)}function aj(d,p){return zS(d,Je(p,2))}function lj(d){return d&&d.length?xh(d,Er,jv):n}function cj(d,p){return d&&d.length?xh(d,Je(p,2),jv):n}var uj=Oh(function(d,p){return d*p},1),dj=Xv("round"),fj=Oh(function(d,p){return d-p},0);function hj(d){return d&&d.length?Sv(d,Er):0}function pj(d,p){return d&&d.length?Sv(d,Je(p,2)):0}return L.after=N9,L.ary=dE,L.assign=S4,L.assignIn=EE,L.assignInWith=zh,L.assignWith=C4,L.at=E4,L.before=fE,L.bind=lb,L.bindAll=D8,L.bindKey=hE,L.castArray=Y9,L.chain=lE,L.chunk=r6,L.compact=o6,L.concat=i6,L.cond=$8,L.conforms=A8,L.constant=gb,L.countBy=h9,L.create=R4,L.curry=pE,L.curryRight=gE,L.debounce=mE,L.defaults=O4,L.defaultsDeep=P4,L.defer=L9,L.delay=F9,L.difference=s6,L.differenceBy=a6,L.differenceWith=l6,L.drop=c6,L.dropRight=u6,L.dropRightWhile=d6,L.dropWhile=f6,L.fill=h6,L.filter=g9,L.flatMap=b9,L.flatMapDeep=y9,L.flatMapDepth=x9,L.flatten=oE,L.flattenDeep=p6,L.flattenDepth=g6,L.flip=j9,L.flow=M8,L.flowRight=I8,L.fromPairs=m6,L.functions=I4,L.functionsIn=N4,L.groupBy=w9,L.initial=b6,L.intersection=y6,L.intersectionBy=x6,L.intersectionWith=w6,L.invert=F4,L.invertBy=j4,L.invokeMap=S9,L.iteratee=mb,L.keyBy=C9,L.keys=Bn,L.keysIn=Cr,L.map=Mh,L.mapKeys=B4,L.mapValues=V4,L.matches=N8,L.matchesProperty=L8,L.memoize=Nh,L.merge=H4,L.mergeWith=RE,L.method=F8,L.methodOf=j8,L.mixin=vb,L.negate=Lh,L.nthArg=B8,L.omit=W4,L.omitBy=U4,L.once=z9,L.orderBy=E9,L.over=V8,L.overArgs=B9,L.overEvery=H8,L.overSome=W8,L.partial=cb,L.partialRight=vE,L.partition=R9,L.pick=q4,L.pickBy=OE,L.property=ME,L.propertyOf=U8,L.pull=E6,L.pullAll=sE,L.pullAllBy=R6,L.pullAllWith=O6,L.pullAt=P6,L.range=q8,L.rangeRight=G8,L.rearg=V9,L.reject=T9,L.remove=T6,L.rest=H9,L.reverse=sb,L.sampleSize=$9,L.set=Y4,L.setWith=K4,L.shuffle=A9,L.slice=D6,L.sortBy=I9,L.sortedUniq=L6,L.sortedUniqBy=F6,L.split=b8,L.spread=W9,L.tail=j6,L.take=z6,L.takeRight=B6,L.takeRightWhile=V6,L.takeWhile=H6,L.tap=o9,L.throttle=U9,L.thru=kh,L.toArray=_E,L.toPairs=PE,L.toPairsIn=TE,L.toPath=J8,L.toPlainObject=CE,L.transform=X4,L.unary=q9,L.union=W6,L.unionBy=U6,L.unionWith=q6,L.uniq=G6,L.uniqBy=Y6,L.uniqWith=K6,L.unset=Q4,L.unzip=ab,L.unzipWith=aE,L.update=J4,L.updateWith=Z4,L.values=Gl,L.valuesIn=e8,L.without=X6,L.words=AE,L.wrap=G9,L.xor=Q6,L.xorBy=J6,L.xorWith=Z6,L.zip=e9,L.zipObject=t9,L.zipObjectDeep=n9,L.zipWith=r9,L.entries=PE,L.entriesIn=TE,L.extend=EE,L.extendWith=zh,vb(L,L),L.add=ej,L.attempt=kE,L.camelCase=o8,L.capitalize=DE,L.ceil=tj,L.clamp=t8,L.clone=K9,L.cloneDeep=Q9,L.cloneDeepWith=J9,L.cloneWith=X9,L.conformsTo=Z9,L.deburr=$E,L.defaultTo=k8,L.divide=nj,L.endsWith=i8,L.eq=Bo,L.escape=s8,L.escapeRegExp=a8,L.every=p9,L.find=m9,L.findIndex=nE,L.findKey=T4,L.findLast=v9,L.findLastIndex=rE,L.findLastKey=D4,L.floor=rj,L.forEach=cE,L.forEachRight=uE,L.forIn=$4,L.forInRight=A4,L.forOwn=k4,L.forOwnRight=M4,L.get=fb,L.gt=e4,L.gte=t4,L.has=L4,L.hasIn=hb,L.head=iE,L.identity=Er,L.includes=_9,L.indexOf=v6,L.inRange=n8,L.invoke=z4,L.isArguments=Pa,L.isArray=ut,L.isArrayBuffer=n4,L.isArrayLike=Sr,L.isArrayLikeObject=On,L.isBoolean=r4,L.isBuffer=Ps,L.isDate=o4,L.isElement=i4,L.isEmpty=s4,L.isEqual=a4,L.isEqualWith=l4,L.isError=ub,L.isFinite=c4,L.isFunction=zi,L.isInteger=bE,L.isLength=Fh,L.isMap=yE,L.isMatch=u4,L.isMatchWith=d4,L.isNaN=f4,L.isNative=h4,L.isNil=g4,L.isNull=p4,L.isNumber=xE,L.isObject=wn,L.isObjectLike=Sn,L.isPlainObject=Pu,L.isRegExp=db,L.isSafeInteger=m4,L.isSet=wE,L.isString=jh,L.isSymbol=Hr,L.isTypedArray=ql,L.isUndefined=v4,L.isWeakMap=b4,L.isWeakSet=y4,L.join=_6,L.kebabCase=l8,L.last=wo,L.lastIndexOf=S6,L.lowerCase=c8,L.lowerFirst=u8,L.lt=x4,L.lte=w4,L.max=oj,L.maxBy=ij,L.mean=sj,L.meanBy=aj,L.min=lj,L.minBy=cj,L.stubArray=yb,L.stubFalse=xb,L.stubObject=Y8,L.stubString=K8,L.stubTrue=X8,L.multiply=uj,L.nth=C6,L.noConflict=z8,L.noop=bb,L.now=Ih,L.pad=d8,L.padEnd=f8,L.padStart=h8,L.parseInt=p8,L.random=r8,L.reduce=O9,L.reduceRight=P9,L.repeat=g8,L.replace=m8,L.result=G4,L.round=dj,L.runInContext=ne,L.sample=D9,L.size=k9,L.snakeCase=v8,L.some=M9,L.sortedIndex=$6,L.sortedIndexBy=A6,L.sortedIndexOf=k6,L.sortedLastIndex=M6,L.sortedLastIndexBy=I6,L.sortedLastIndexOf=N6,L.startCase=y8,L.startsWith=x8,L.subtract=fj,L.sum=hj,L.sumBy=pj,L.template=w8,L.times=Q8,L.toFinite=Bi,L.toInteger=pt,L.toLength=SE,L.toLower=_8,L.toNumber=_o,L.toSafeInteger=_4,L.toString=Ut,L.toUpper=S8,L.trim=C8,L.trimEnd=E8,L.trimStart=R8,L.truncate=O8,L.unescape=P8,L.uniqueId=Z8,L.upperCase=T8,L.upperFirst=pb,L.each=cE,L.eachRight=uE,L.first=iE,vb(L,function(){var d={};return ii(L,function(p,y){Qt.call(L.prototype,y)||(d[y]=p)}),d}(),{chain:!1}),L.VERSION=r,mo(["bind","bindKey","curry","curryRight","partial","partialRight"],function(d){L[d].placeholder=L}),mo(["drop","take"],function(d,p){kt.prototype[d]=function(y){y=y===n?1:Mn(pt(y),0);var E=this.__filtered__&&!p?new kt(this):this.clone();return E.__filtered__?E.__takeCount__=nr(y,E.__takeCount__):E.__views__.push({size:nr(y,H),type:d+(E.__dir__<0?"Right":"")}),E},kt.prototype[d+"Right"]=function(y){return this.reverse()[d](y).reverse()}}),mo(["filter","map","takeWhile"],function(d,p){var y=p+1,E=y==Z||y==Q;kt.prototype[d]=function(M){var j=this.clone();return j.__iteratees__.push({iteratee:Je(M,3),type:y}),j.__filtered__=j.__filtered__||E,j}}),mo(["head","last"],function(d,p){var y="take"+(p?"Right":"");kt.prototype[d]=function(){return this[y](1).value()[0]}}),mo(["initial","tail"],function(d,p){var y="drop"+(p?"":"Right");kt.prototype[d]=function(){return this.__filtered__?new kt(this):this[y](1)}}),kt.prototype.compact=function(){return this.filter(Er)},kt.prototype.find=function(d){return this.filter(d).head()},kt.prototype.findLast=function(d){return this.reverse().find(d)},kt.prototype.invokeMap=St(function(d,p){return typeof d=="function"?new kt(this):this.map(function(y){return _u(y,d,p)})}),kt.prototype.reject=function(d){return this.filter(Lh(Je(d)))},kt.prototype.slice=function(d,p){d=pt(d);var y=this;return y.__filtered__&&(d>0||p<0)?new kt(y):(d<0?y=y.takeRight(-d):d&&(y=y.drop(d)),p!==n&&(p=pt(p),y=p<0?y.dropRight(-p):y.take(p-d)),y)},kt.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},kt.prototype.toArray=function(){return this.take(H)},ii(kt.prototype,function(d,p){var y=/^(?:filter|find|map|reject)|While$/.test(p),E=/^(?:head|last)$/.test(p),M=L[E?"take"+(p=="last"?"Right":""):p],j=E||/^find/.test(p);M&&(L.prototype[p]=function(){var U=this.__wrapped__,X=E?[1]:arguments,se=U instanceof kt,xe=X[0],we=se||ut(U),Re=function(Pt){var Mt=M.apply(L,ws([Pt],X));return E&&je?Mt[0]:Mt};we&&y&&typeof xe=="function"&&xe.length!=1&&(se=we=!1);var je=this.__chain__,Ye=!!this.__actions__.length,et=j&&!je,yt=se&&!Ye;if(!j&&we){U=yt?U:new kt(this);var tt=d.apply(U,X);return tt.__actions__.push({func:kh,args:[Re],thisArg:n}),new bo(tt,je)}return et&&yt?d.apply(this,X):(tt=this.thru(Re),et?E?tt.value()[0]:tt.value():tt)})}),mo(["pop","push","shift","sort","splice","unshift"],function(d){var p=ih[d],y=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",E=/^(?:pop|shift)$/.test(d);L.prototype[d]=function(){var M=arguments;if(E&&!this.__chain__){var j=this.value();return p.apply(ut(j)?j:[],M)}return this[y](function(U){return p.apply(ut(U)?U:[],M)})}}),ii(kt.prototype,function(d,p){var y=L[p];if(y){var E=y.name+"";Qt.call(Bl,E)||(Bl[E]=[]),Bl[E].push({name:p,func:y})}}),Bl[Rh(n,w).name]=[{name:"wrapper",func:n}],kt.prototype.clone=PF,kt.prototype.reverse=TF,kt.prototype.value=DF,L.prototype.at=i9,L.prototype.chain=s9,L.prototype.commit=a9,L.prototype.next=l9,L.prototype.plant=u9,L.prototype.reverse=d9,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=f9,L.prototype.first=L.prototype.head,gu&&(L.prototype[gu]=c9),L},Fl=aF();xa?((xa.exports=Fl)._=Fl,mv._=Fl):qn._=Fl}).call(Vs)})(hg,hg.exports);var uc=hg.exports;const ol=nu(uc);function eR({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10};return t||(t={}),vw.forEach(l=>{t!=null&&t[l]||(t={...t,[l]:[]});const c=t[l].reduce((u,f)=>Math.max(u,f.y+f.h),0);a.y=a.y===0?0:c,t[l].push(a)}),t}function tR(e,t){t&&vw.forEach(n=>{t!=null&&t[n]&&(t[n]=t[n].filter(r=>r.i!==e))})}const ke=X2()(rD((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:x0},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{deleteSheet:n=>{e(r=>{var i,s,a,l;const o=(i=r.dashboard.sheets)==null?void 0:i.findIndex(c=>c.id===n);o!==void 0&&o>-1&&((s=r.dashboard.sheets)==null||s.splice(o,1),r.selectedSheetId=(l=(a=r.dashboard.sheets)==null?void 0:a[0])==null?void 0:l.id)})},addSheet:n=>{e(r=>{r.dashboard.sheets||(r.dashboard.sheets=[]);const o=r.dashboard.filters;let i={};o==null||o.forEach(a=>{vw.forEach(l=>{i!=null&&i[l]||(i={...i,[l]:[]});const c={i:a.id,x:0,y:0,w:10,h:8};i[l].push(c)})});const s={...n,layouts:i};r.dashboard.sheets.push(s)})},setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&uc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.python=r)})})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setBookmarkKey:n=>{e(()=>({bookmarkKey:n}))},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.title=r)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&uc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.title=o)})})},setCardInfo:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&uc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.info=r)})})},setCardDescription:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&uc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.description=o)})})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){const f=(c=s.cards)==null?void 0:c.find(h=>h.id===r);f&&(f.sql=o,(u=i.onUpdateCard)==null||u.call(i,f,n))}})},setFrameCardData:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&uc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.data=o)})})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n];const o=(s=r.dashboard.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId);eR({id:n.id,layouts:o==null?void 0:o.layouts,y:0,initialHeight:8,minH:7,w:10})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1);const l=(s=r.dashboard.sheets)==null?void 0:s.find(c=>c.id===r.selectedSheetId);tR(n,l==null?void 0:l.layouts)}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,f,h;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(g=>g.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(g=>g.id===r);if(a){const g=(f=a.cards)==null?void 0:f.findIndex(v=>v.id===o.id);g>-1&&((h=a.cards)==null||h.splice(g,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let f=1/0,h=0;o==="start"&&(f=0),eR({id:r.id,layouts:s.layouts,minH:10,x:h,y:f}),(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(i){const f=(l=i.frames)==null?void 0:l.findIndex(h=>h.id===r);console.log(f),typeof f=="number"&&f>-1&&((c=i.frames)==null||c.splice(f,1),(u=i.layout)==null||u.splice(f,1),tR(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(f=>f.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r))})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(f=o.onUpdateCard)==null||f.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,f,h;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(g=>g.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(g=>g.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(f=i.layout)==null||f.splice(s,1),(h=o.onRemoveCard)==null||h.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},getCardSheet(n){var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return r[s]}}},handleDataPointClickAction:(n,r)=>{Iz({card:n,dataPoint:r,set:e,get:t})}}}))),Mo=()=>ke(e=>e.actions);var Pf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Hc=typeof window>"u"||"Deno"in window;function Oo(){}function Nz(e,t){return typeof e=="function"?e(t):e}function _0(e){return typeof e=="number"&&e>=0&&e!==1/0}function cD(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nR(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==xw(s,t.options))return!1}else if(!Dd(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof o<"u"&&o!==t.state.fetchStatus||i&&!i(t))}function rR(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Td(t.options.mutationKey)!==Td(i))return!1}else if(!Dd(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function xw(e,t){return((t==null?void 0:t.queryKeyHashFn)||Td)(e)}function Td(e){return JSON.stringify(e,(t,n)=>C0(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Dd(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Dd(e[n],t[n])):!1}function uD(e,t){if(e===t)return e;const n=oR(e)&&oR(t);if(n||C0(e)&&C0(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];!n&&e[u]===void 0&&t[u]===void 0&&r.includes(u)?(a[u]=void 0,l++):(a[u]=uD(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function S0(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function oR(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function C0(e){if(!iR(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!iR(n)||!n.hasOwnProperty("isPrototypeOf"))}function iR(e){return Object.prototype.toString.call(e)==="[object Object]"}function Lz(e){return new Promise(t=>{setTimeout(t,e)})}function E0(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?uD(e,t):t}function Fz(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function jz(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Xa,Hs,Cc,A2,zz=(A2=class extends Pf{constructor(){super();Xe(this,Xa,void 0);Xe(this,Hs,void 0);Xe(this,Cc,void 0);Ve(this,Cc,t=>{if(!Hc&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){re(this,Hs)||this.setEventListener(re(this,Cc))}onUnsubscribe(){var t;this.hasListeners()||((t=re(this,Hs))==null||t.call(this),Ve(this,Hs,void 0))}setEventListener(t){var n;Ve(this,Cc,t),(n=re(this,Hs))==null||n.call(this),Ve(this,Hs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){re(this,Xa)!==t&&(Ve(this,Xa,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof re(this,Xa)=="boolean"?re(this,Xa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Xa=new WeakMap,Hs=new WeakMap,Cc=new WeakMap,A2),pg=new zz,Ec,Ws,Rc,k2,Bz=(k2=class extends Pf{constructor(){super();Xe(this,Ec,!0);Xe(this,Ws,void 0);Xe(this,Rc,void 0);Ve(this,Rc,t=>{if(!Hc&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){re(this,Ws)||this.setEventListener(re(this,Rc))}onUnsubscribe(){var t;this.hasListeners()||((t=re(this,Ws))==null||t.call(this),Ve(this,Ws,void 0))}setEventListener(t){var n;Ve(this,Rc,t),(n=re(this,Ws))==null||n.call(this),Ve(this,Ws,t(this.setOnline.bind(this)))}setOnline(t){re(this,Ec)!==t&&(Ve(this,Ec,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return re(this,Ec)}},Ec=new WeakMap,Ws=new WeakMap,Rc=new WeakMap,k2),gg=new Bz;function Vz(e){return Math.min(1e3*2**e,3e4)}function om(e){return(e??"online")==="online"?gg.isOnline():!0}var dD=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Tb(e){return e instanceof dD}function fD(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((x,w)=>{i=x,s=w}),l=x=>{var w;r||(g(new dD(x)),(w=e.abort)==null||w.call(e))},c=()=>{t=!0},u=()=>{t=!1},f=()=>!pg.isFocused()||e.networkMode!=="always"&&!gg.isOnline(),h=x=>{var w;r||(r=!0,(w=e.onSuccess)==null||w.call(e,x),o==null||o(),i(x))},g=x=>{var w;r||(r=!0,(w=e.onError)==null||w.call(e,x),o==null||o(),s(x))},v=()=>new Promise(x=>{var w;o=_=>{const S=r||!f();return S&&x(_),S},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;o=void 0,r||(x=e.onContinue)==null||x.call(e)}),b=()=>{if(r)return;let x;try{x=e.fn()}catch(w){x=Promise.reject(w)}Promise.resolve(x).then(h).catch(w=>{var P;if(r)return;const _=e.retry??(Hc?0:3),S=e.retryDelay??Vz,R=typeof S=="function"?S(n,w):S,C=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,w);if(t||!C){g(w);return}n++,(P=e.onFail)==null||P.call(e,n,w),Lz(R).then(()=>{if(f())return v()}).then(()=>{t?g(w):b()})})};return om(e.networkMode)?b():v().then(b),{promise:a,cancel:l,continue:()=>(o==null?void 0:o())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}function Hz(){let e=[],t=0,n=h=>{h()},r=h=>{h()},o=h=>setTimeout(h,0);const i=h=>{o=h},s=h=>{let g;t++;try{g=h()}finally{t--,t||c()}return g},a=h=>{t?e.push(h):o(()=>{n(h)})},l=h=>(...g)=>{a(()=>{h(...g)})},c=()=>{const h=e;e=[],h.length&&o(()=>{r(()=>{h.forEach(g=>{n(g)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:h=>{n=h},setBatchNotifyFunction:h=>{r=h},setScheduler:i}}var Xn=Hz(),Qa,M2,hD=(M2=class{constructor(){Xe(this,Qa,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_0(this.gcTime)&&Ve(this,Qa,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Hc?1/0:5*60*1e3))}clearGcTimeout(){re(this,Qa)&&(clearTimeout(re(this,Qa)),Ve(this,Qa,void 0))}},Qa=new WeakMap,M2),Oc,Pc,Co,Us,Eo,Vn,pf,Ja,Tc,Kp,Go,qi,I2,Wz=(I2=class extends hD{constructor(t){super();Xe(this,Tc);Xe(this,Go);Xe(this,Oc,void 0);Xe(this,Pc,void 0);Xe(this,Co,void 0);Xe(this,Us,void 0);Xe(this,Eo,void 0);Xe(this,Vn,void 0);Xe(this,pf,void 0);Xe(this,Ja,void 0);Ve(this,Ja,!1),Ve(this,pf,t.defaultOptions),Ct(this,Tc,Kp).call(this,t.options),Ve(this,Vn,[]),Ve(this,Co,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ve(this,Oc,t.state||Uz(this.options)),this.state=re(this,Oc),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!re(this,Vn).length&&this.state.fetchStatus==="idle"&&re(this,Co).remove(this)}setData(t,n){const r=E0(this.state.data,t,this.options);return Ct(this,Go,qi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ct(this,Go,qi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=re(this,Us);return(r=re(this,Eo))==null||r.cancel(t),n?n.then(Oo).catch(Oo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(re(this,Oc))}isActive(){return re(this,Vn).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||re(this,Vn).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!cD(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=re(this,Vn).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=re(this,Eo))==null||n.continue()}onOnline(){var n;const t=re(this,Vn).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=re(this,Eo))==null||n.continue()}addObserver(t){re(this,Vn).includes(t)||(re(this,Vn).push(t),this.clearGcTimeout(),re(this,Co).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){re(this,Vn).includes(t)&&(Ve(this,Vn,re(this,Vn).filter(n=>n!==t)),re(this,Vn).length||(re(this,Eo)&&(re(this,Ja)?re(this,Eo).cancel({revert:!0}):re(this,Eo).cancelRetry()),this.scheduleGc()),re(this,Co).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return re(this,Vn).length}invalidate(){this.state.isInvalidated||Ct(this,Go,qi).call(this,{type:"invalidate"})}fetch(t,n){var c,u,f,h;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(re(this,Us))return(c=re(this,Eo))==null||c.continueRetry(),re(this,Us)}if(t&&Ct(this,Tc,Kp).call(this,t),!this.options.queryFn){const g=re(this,Vn).find(v=>v.options.queryFn);g&&Ct(this,Tc,Kp).call(this,g.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o={queryKey:this.queryKey,meta:this.meta},i=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Ve(this,Ja,!0),r.signal)})};i(o);const s=()=>this.options.queryFn?(Ve(this,Ja,!1),this.options.persister?this.options.persister(this.options.queryFn,o,this):this.options.queryFn(o)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(a),(u=this.options.behavior)==null||u.onFetch(a,this),Ve(this,Pc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&Ct(this,Go,qi).call(this,{type:"fetch",meta:(h=a.fetchOptions)==null?void 0:h.meta});const l=g=>{var v,b,x,w;Tb(g)&&g.silent||Ct(this,Go,qi).call(this,{type:"error",error:g}),Tb(g)||((b=(v=re(this,Co).config).onError)==null||b.call(v,g,this),(w=(x=re(this,Co).config).onSettled)==null||w.call(x,this.state.data,g,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Ve(this,Eo,fD({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var v,b,x,w;if(typeof g>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(g),(b=(v=re(this,Co).config).onSuccess)==null||b.call(v,g,this),(w=(x=re(this,Co).config).onSettled)==null||w.call(x,g,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(g,v)=>{Ct(this,Go,qi).call(this,{type:"failed",failureCount:g,error:v})},onPause:()=>{Ct(this,Go,qi).call(this,{type:"pause"})},onContinue:()=>{Ct(this,Go,qi).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Ve(this,Us,re(this,Eo).promise),re(this,Us)}},Oc=new WeakMap,Pc=new WeakMap,Co=new WeakMap,Us=new WeakMap,Eo=new WeakMap,Vn=new WeakMap,pf=new WeakMap,Ja=new WeakMap,Tc=new WeakSet,Kp=function(t){this.options={...re(this,pf),...t},this.updateGcTime(this.options.gcTime)},Go=new WeakSet,qi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:om(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Tb(o)&&o.revert&&re(this,Pc)?{...re(this,Pc),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Xn.batch(()=>{re(this,Vn).forEach(r=>{r.onQueryUpdate()}),re(this,Co).notify({query:this,type:"updated",action:t})})},I2);function Uz(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var fi,N2,pD=(N2=class extends Pf{constructor(t={}){super();Xe(this,fi,void 0);this.config=t,Ve(this,fi,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??xw(o,n);let s=this.get(i);return s||(s=new Wz({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){re(this,fi).has(t.queryHash)||(re(this,fi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=re(this,fi).get(t.queryHash);n&&(t.destroy(),n===t&&re(this,fi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Xn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return re(this,fi).get(t)}getAll(){return[...re(this,fi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>nR(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>nR(t,r)):n}notify(t){Xn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Xn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Xn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},fi=new WeakMap,N2),hi,gf,Xr,Dc,pi,Ls,L2,qz=(L2=class extends hD{constructor(t){super();Xe(this,pi);Xe(this,hi,void 0);Xe(this,gf,void 0);Xe(this,Xr,void 0);Xe(this,Dc,void 0);this.mutationId=t.mutationId,Ve(this,gf,t.defaultOptions),Ve(this,Xr,t.mutationCache),Ve(this,hi,[]),this.state=t.state||Gz(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...re(this,gf),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){re(this,hi).includes(t)||(re(this,hi).push(t),this.clearGcTimeout(),re(this,Xr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ve(this,hi,re(this,hi).filter(n=>n!==t)),this.scheduleGc(),re(this,Xr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){re(this,hi).length||(this.state.status==="pending"?this.scheduleGc():re(this,Xr).remove(this))}continue(){var t;return((t=re(this,Dc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,f,h,g,v,b,x,w,_,S,R,C,P,A;const n=()=>(Ve(this,Dc,fD({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(k,D)=>{Ct(this,pi,Ls).call(this,{type:"failed",failureCount:k,error:D})},onPause:()=>{Ct(this,pi,Ls).call(this,{type:"pause"})},onContinue:()=>{Ct(this,pi,Ls).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),re(this,Dc).promise),r=this.state.status==="pending";try{if(!r){Ct(this,pi,Ls).call(this,{type:"pending",variables:t}),await((i=(o=re(this,Xr).config).onMutate)==null?void 0:i.call(o,t,this));const D=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));D!==this.state.context&&Ct(this,pi,Ls).call(this,{type:"pending",context:D,variables:t})}const k=await n();return await((c=(l=re(this,Xr).config).onSuccess)==null?void 0:c.call(l,k,t,this.state.context,this)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,k,t,this.state.context)),await((g=(h=re(this,Xr).config).onSettled)==null?void 0:g.call(h,k,null,this.state.variables,this.state.context,this)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,k,null,t,this.state.context)),Ct(this,pi,Ls).call(this,{type:"success",data:k}),k}catch(k){try{throw await((w=(x=re(this,Xr).config).onError)==null?void 0:w.call(x,k,t,this.state.context,this)),await((S=(_=this.options).onError)==null?void 0:S.call(_,k,t,this.state.context)),await((C=(R=re(this,Xr).config).onSettled)==null?void 0:C.call(R,void 0,k,this.state.variables,this.state.context,this)),await((A=(P=this.options).onSettled)==null?void 0:A.call(P,void 0,k,t,this.state.context)),k}finally{Ct(this,pi,Ls).call(this,{type:"error",error:k})}}}},hi=new WeakMap,gf=new WeakMap,Xr=new WeakMap,Dc=new WeakMap,pi=new WeakSet,Ls=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!om(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Xn.batch(()=>{re(this,hi).forEach(r=>{r.onMutationUpdate(t)}),re(this,Xr).notify({mutation:this,type:"updated",action:t})})},L2);function Gz(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ro,mf,Za,F2,Yz=(F2=class extends Pf{constructor(t={}){super();Xe(this,Ro,void 0);Xe(this,mf,void 0);Xe(this,Za,void 0);this.config=t,Ve(this,Ro,[]),Ve(this,mf,0)}build(t,n,r){const o=new qz({mutationCache:this,mutationId:++Bh(this,mf)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){re(this,Ro).push(t),this.notify({type:"added",mutation:t})}remove(t){Ve(this,Ro,re(this,Ro).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){Xn.batch(()=>{re(this,Ro).forEach(t=>{this.remove(t)})})}getAll(){return re(this,Ro)}find(t){const n={exact:!0,...t};return re(this,Ro).find(r=>rR(n,r))}findAll(t={}){return re(this,Ro).filter(n=>rR(t,n))}notify(t){Xn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Ve(this,Za,(re(this,Za)??Promise.resolve()).then(()=>{const t=re(this,Ro).filter(n=>n.state.isPaused);return Xn.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(Oo)),Promise.resolve()))}).then(()=>{Ve(this,Za,void 0)})),re(this,Za)}},Ro=new WeakMap,mf=new WeakMap,Za=new WeakMap,F2);function Kz(e){return{onFetch:(t,n)=>{const r=async()=>{var v,b,x,w,_;const o=t.options,i=(x=(b=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:b.fetchMore)==null?void 0:x.direction,s=((w=t.state.data)==null?void 0:w.pages)||[],a=((_=t.state.data)==null?void 0:_.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const u=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),h=async(S,R,C)=>{if(c)return Promise.reject();if(R==null&&S.pages.length)return Promise.resolve(S);const P={queryKey:t.queryKey,pageParam:R,direction:C?"backward":"forward",meta:t.options.meta};u(P);const A=await f(P),{maxPages:k}=t.options,D=C?jz:Fz;return{pages:D(S.pages,A,k),pageParams:D(S.pageParams,R,k)}};let g;if(i&&s.length){const S=i==="backward",R=S?Xz:sR,C={pages:s,pageParams:a},P=R(o,C);g=await h(C,P,S)}else{g=await h(l,a[0]??o.initialPageParam);const S=e??s.length;for(let R=1;R<S;R++){const C=sR(o,g);g=await h(g,C)}}return g};t.options.persister?t.fetchFn=()=>{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function sR(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function Xz(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var In,qs,Gs,$c,Ac,Ys,kc,Mc,j2,Qz=(j2=class{constructor(e={}){Xe(this,In,void 0);Xe(this,qs,void 0);Xe(this,Gs,void 0);Xe(this,$c,void 0);Xe(this,Ac,void 0);Xe(this,Ys,void 0);Xe(this,kc,void 0);Xe(this,Mc,void 0);Ve(this,In,e.queryCache||new pD),Ve(this,qs,e.mutationCache||new Yz),Ve(this,Gs,e.defaultOptions||{}),Ve(this,$c,new Map),Ve(this,Ac,new Map),Ve(this,Ys,0)}mount(){Bh(this,Ys)._++,re(this,Ys)===1&&(Ve(this,kc,pg.subscribe(()=>{pg.isFocused()&&(this.resumePausedMutations(),re(this,In).onFocus())})),Ve(this,Mc,gg.subscribe(()=>{gg.isOnline()&&(this.resumePausedMutations(),re(this,In).onOnline())})))}unmount(){var e,t;Bh(this,Ys)._--,re(this,Ys)===0&&((e=re(this,kc))==null||e.call(this),Ve(this,kc,void 0),(t=re(this,Mc))==null||t.call(this),Ve(this,Mc,void 0))}isFetching(e){return re(this,In).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return re(this,qs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=re(this,In).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=re(this,In).find({queryKey:e}),o=r==null?void 0:r.state.data,i=Nz(t,o);if(typeof i>"u")return;const s=this.defaultQueryOptions({queryKey:e});return re(this,In).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Xn.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=re(this,In).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=re(this,In);Xn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=re(this,In),r={type:"active",...e};return Xn.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=Xn.batch(()=>re(this,In).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Oo).catch(Oo)}invalidateQueries(e={},t={}){return Xn.batch(()=>{if(re(this,In).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=Xn.batch(()=>re(this,In).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Oo)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Oo)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=re(this,In).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Oo).catch(Oo)}fetchInfiniteQuery(e){return e.behavior=Kz(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Oo).catch(Oo)}resumePausedMutations(){return re(this,qs).resumePausedMutations()}getQueryCache(){return re(this,In)}getMutationCache(){return re(this,qs)}getDefaultOptions(){return re(this,Gs)}setDefaultOptions(e){Ve(this,Gs,e)}setQueryDefaults(e,t){re(this,$c).set(Td(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...re(this,$c).values()];let n={};return t.forEach(r=>{Dd(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){re(this,Ac).set(Td(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...re(this,Ac).values()];let n={};return t.forEach(r=>{Dd(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...re(this,Gs).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xw(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...re(this,Gs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){re(this,In).clear(),re(this,qs).clear()}},In=new WeakMap,qs=new WeakMap,Gs=new WeakMap,$c=new WeakMap,Ac=new WeakMap,Ys=new WeakMap,kc=new WeakMap,Mc=new WeakMap,j2),$r,fn,vf,vr,el,Ic,gi,bf,Nc,Lc,tl,nl,Ks,Fc,rl,Zu,yf,R0,xf,O0,wf,P0,_f,T0,Sf,D0,Cf,$0,Ef,A0,Jg,gD,z2,Jz=(z2=class extends Pf{constructor(t,n){super();Xe(this,rl);Xe(this,yf);Xe(this,xf);Xe(this,wf);Xe(this,_f);Xe(this,Sf);Xe(this,Cf);Xe(this,Ef);Xe(this,Jg);Xe(this,$r,void 0);Xe(this,fn,void 0);Xe(this,vf,void 0);Xe(this,vr,void 0);Xe(this,el,void 0);Xe(this,Ic,void 0);Xe(this,gi,void 0);Xe(this,bf,void 0);Xe(this,Nc,void 0);Xe(this,Lc,void 0);Xe(this,tl,void 0);Xe(this,nl,void 0);Xe(this,Ks,void 0);Xe(this,Fc,new Set);this.options=n,Ve(this,$r,t),Ve(this,gi,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(re(this,fn).addObserver(this),aR(re(this,fn),this.options)?Ct(this,rl,Zu).call(this):this.updateResult(),Ct(this,_f,T0).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return k0(re(this,fn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return k0(re(this,fn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ct(this,Sf,D0).call(this),Ct(this,Cf,$0).call(this),re(this,fn).removeObserver(this)}setOptions(t,n){const r=this.options,o=re(this,fn);if(this.options=re(this,$r).defaultQueryOptions(t),S0(r,this.options)||re(this,$r).getQueryCache().notify({type:"observerOptionsUpdated",query:re(this,fn),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),Ct(this,Ef,A0).call(this);const i=this.hasListeners();i&&lR(re(this,fn),o,this.options,r)&&Ct(this,rl,Zu).call(this),this.updateResult(n),i&&(re(this,fn)!==o||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&Ct(this,yf,R0).call(this);const s=Ct(this,xf,O0).call(this);i&&(re(this,fn)!==o||this.options.enabled!==r.enabled||s!==re(this,Ks))&&Ct(this,wf,P0).call(this,s)}getOptimisticResult(t){const n=re(this,$r).getQueryCache().build(re(this,$r),t),r=this.createResult(n,t);return eB(this,r)&&(Ve(this,vr,r),Ve(this,Ic,this.options),Ve(this,el,re(this,fn).state)),r}getCurrentResult(){return re(this,vr)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(re(this,Fc).add(r),t[r])})}),n}getCurrentQuery(){return re(this,fn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=re(this,$r).defaultQueryOptions(t),r=re(this,$r).getQueryCache().build(re(this,$r),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ct(this,rl,Zu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),re(this,vr)))}createResult(t,n){var P;const r=re(this,fn),o=this.options,i=re(this,vr),s=re(this,el),a=re(this,Ic),c=t!==r?t.state:re(this,vf),{state:u}=t;let{error:f,errorUpdatedAt:h,fetchStatus:g,status:v}=u,b=!1,x;if(n._optimisticResults){const A=this.hasListeners(),k=!A&&aR(t,n),D=A&&lR(t,r,n,o);(k||D)&&(g=om(t.options.networkMode)?"fetching":"paused",u.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(g="idle")}if(n.select&&typeof u.data<"u")if(i&&u.data===(s==null?void 0:s.data)&&n.select===re(this,bf))x=re(this,Nc);else try{Ve(this,bf,n.select),x=n.select(u.data),x=E0(i==null?void 0:i.data,x,n),Ve(this,Nc,x),Ve(this,gi,null)}catch(A){Ve(this,gi,A)}else x=u.data;if(typeof n.placeholderData<"u"&&typeof x>"u"&&v==="pending"){let A;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))A=i.data;else if(A=typeof n.placeholderData=="function"?n.placeholderData((P=re(this,Lc))==null?void 0:P.state.data,re(this,Lc)):n.placeholderData,n.select&&typeof A<"u")try{A=n.select(A),Ve(this,gi,null)}catch(k){Ve(this,gi,k)}typeof A<"u"&&(v="success",x=E0(i==null?void 0:i.data,A,n),b=!0)}re(this,gi)&&(f=re(this,gi),x=re(this,Nc),h=Date.now(),v="error");const w=g==="fetching",_=v==="pending",S=v==="error",R=_&&w;return{status:v,fetchStatus:g,isPending:_,isSuccess:v==="success",isError:S,isInitialLoading:R,isLoading:R,data:x,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!_,isLoadingError:S&&u.dataUpdatedAt===0,isPaused:g==="paused",isPlaceholderData:b,isRefetchError:S&&u.dataUpdatedAt!==0,isStale:ww(t,n),refetch:this.refetch}}updateResult(t){const n=re(this,vr),r=this.createResult(re(this,fn),this.options);if(Ve(this,el,re(this,fn).state),Ve(this,Ic,this.options),re(this,el).data!==void 0&&Ve(this,Lc,re(this,fn)),S0(r,n))return;Ve(this,vr,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!re(this,Fc).size)return!0;const l=new Set(a??re(this,Fc));return this.options.throwOnError&&l.add("error"),Object.keys(re(this,vr)).some(c=>{const u=c;return re(this,vr)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),Ct(this,Jg,gD).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ct(this,_f,T0).call(this)}},$r=new WeakMap,fn=new WeakMap,vf=new WeakMap,vr=new WeakMap,el=new WeakMap,Ic=new WeakMap,gi=new WeakMap,bf=new WeakMap,Nc=new WeakMap,Lc=new WeakMap,tl=new WeakMap,nl=new WeakMap,Ks=new WeakMap,Fc=new WeakMap,rl=new WeakSet,Zu=function(t){Ct(this,Ef,A0).call(this);let n=re(this,fn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Oo)),n},yf=new WeakSet,R0=function(){if(Ct(this,Sf,D0).call(this),Hc||re(this,vr).isStale||!_0(this.options.staleTime))return;const n=cD(re(this,vr).dataUpdatedAt,this.options.staleTime)+1;Ve(this,tl,setTimeout(()=>{re(this,vr).isStale||this.updateResult()},n))},xf=new WeakSet,O0=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(re(this,fn)):this.options.refetchInterval)??!1},wf=new WeakSet,P0=function(t){Ct(this,Cf,$0).call(this),Ve(this,Ks,t),!(Hc||this.options.enabled===!1||!_0(re(this,Ks))||re(this,Ks)===0)&&Ve(this,nl,setInterval(()=>{(this.options.refetchIntervalInBackground||pg.isFocused())&&Ct(this,rl,Zu).call(this)},re(this,Ks)))},_f=new WeakSet,T0=function(){Ct(this,yf,R0).call(this),Ct(this,wf,P0).call(this,Ct(this,xf,O0).call(this))},Sf=new WeakSet,D0=function(){re(this,tl)&&(clearTimeout(re(this,tl)),Ve(this,tl,void 0))},Cf=new WeakSet,$0=function(){re(this,nl)&&(clearInterval(re(this,nl)),Ve(this,nl,void 0))},Ef=new WeakSet,A0=function(){const t=re(this,$r).getQueryCache().build(re(this,$r),this.options);if(t===re(this,fn))return;const n=re(this,fn);Ve(this,fn,t),Ve(this,vf,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Jg=new WeakSet,gD=function(t){Xn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(re(this,vr))}),re(this,$r).getQueryCache().notify({query:re(this,fn),type:"observerResultsUpdated"})})},z2);function Zz(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function aR(e,t){return Zz(e,t)||e.state.dataUpdatedAt>0&&k0(e,t,t.refetchOnMount)}function k0(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ww(e,t)}return!1}function lR(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&ww(e,n)}function ww(e,t){return e.isStaleByTime(t.staleTime)}function eB(e,t){return!S0(e.getCurrentResult(),t)}var mD=V.createContext(void 0),vD=e=>{const t=V.useContext(mD);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},tB=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),V.createElement(mD.Provider,{value:e},t)),bD=V.createContext(!1),nB=()=>V.useContext(bD);bD.Provider;function rB(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oB=V.createContext(rB()),iB=()=>V.useContext(oB);function sB(e,t){return typeof e=="function"?e(...t):!!e}var aB=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},lB=e=>{V.useEffect(()=>{e.clearReset()},[e])},cB=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&sB(n,[e.error,r]),uB=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},dB=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,fB=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function hB(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=vD(n),o=nB(),i=iB(),s=r.defaultQueryOptions(e);s._optimisticResults=o?"isRestoring":"optimistic",uB(s),aB(s,i),lB(i);const[a]=V.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(V.useSyncExternalStore(V.useCallback(c=>{const u=o?()=>{}:a.subscribe(Xn.batchCalls(c));return a.updateResult(),u},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),V.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),dB(s,l))throw fB(s,a,i);if(cB({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Tf(e,t){return hB(e,Jz,t)}const pB={theme:"system",setTheme:()=>null},yD=m.createContext(pB);function gB({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=m.useState(()=>localStorage.getItem(n)||t);m.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return O.jsx(yD.Provider,{...r,value:s,children:e})}const xD=()=>{const e=m.useContext(yD);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};async function mB(e){return await(await fetch("https://semaphor.cloud/api/v1/dashboard",{headers:{Authorization:`Bearer ${e}`}})).json()}function wD(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function cR(e,t){const n=wD(e);return n==="dark"?ol.merge({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function vB({authToken:e,customStyle:t,currentTheme:n,onSave:r,onEvent:o}){const{data:i,refetch:s,isLoading:a,isError:l}=Tf({queryKey:["dashboard",e==null?void 0:e.accessToken],queryFn:()=>mB(e==null?void 0:e.accessToken),enabled:!1}),{theme:c,setTheme:u}=xD(),f=ke(A=>A.dashboard.globalStyle),{setDashboard:h,setSelectedSheetId:g,setStyle:v,setOnSaveFunction:b}=ke(A=>A.actions);ke(A=>A.actions.setCustomCards);const x=ke(A=>A.actions.setFilterValues),w=ke(A=>A.actions.setBookmarkKey),_=ke(A=>A.actions.setAuthToken),S=ke(A=>A.actions.setThemeStyle),R=ke(A=>A.actions.setDashboardTheme),C=ke(A=>A.actions.setOnEvent);m.useEffect(()=>{if(c){const A=wD(c);R(A)}},[c,R]),m.useEffect(()=>{n&&u(n)},[n,u]);function P(){const A=ol.cloneDeep(x0),k=ol.merge(A,f);if(t){const D=ol.merge(k,t),I=cR(c,D);S(I),v(D)}else{const D=cR(c,k);S(D),v(x0)}}return m.useEffect(()=>{i&&i.dashboard&&P()},[c,t,f]),m.useEffect(()=>{var F;if(!i||!i.dashboard)return;const A=i.dashboard,k=yL(A.id),D=JSON.parse(localStorage.getItem(k)||"[]"),I=D.find(B=>B.default===!0);if(I)h(I.template),P(),w(I.name),I.filterValues&&x(I.filterValues);else{h(A),P();const B=D.find(K=>(K==null?void 0:K.name)==="Original");B?B.template=A:D.push({name:"Original",template:A,default:!1}),localStorage.setItem(k,JSON.stringify(D))}g((F=A.sheets)==null?void 0:F[0].id)},[i,h,g,x,w]),m.useEffect(()=>{r&&b(r),o&&C(o)},[r,b,o,C]),m.useEffect(()=>{e&&e.accessToken&&(_(e),s())},[e,s,_]),{isLoading:a,isError:l}}function im({className:e,...t}){return O.jsx("div",{className:Ee("animate-pulse rounded-md bg-muted",e),...t})}const _w=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));_w.displayName="Card";const sm=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("flex flex-col space-y-1.5 p-6",e),...t}));sm.displayName="CardHeader";const Df=V.forwardRef(({className:e,...t},n)=>O.jsx("h3",{ref:n,className:Ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));Df.displayName="CardTitle";const Sw=V.forwardRef(({className:e,...t},n)=>O.jsx("p",{ref:n,className:Ee("text-sm text-muted-foreground",e),...t}));Sw.displayName="CardDescription";const am=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("px-6 pt-0",e),...t}));am.displayName="CardContent";const Cw=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("flex items-center p-6 pt-0",e),...t}));Cw.displayName="CardFooter";function _D({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:f,showAssistant:h,...g}){ke(_=>_.selectedSheetId);const v=ke(_=>_.themeStyle),b=ke(_=>_.isSessionExpired),{isLoading:x,isError:w}=vB({authToken:l,customStyle:t,currentTheme:c,onSave:n,onEvent:r});return x||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?O.jsx(o,{message:"loading"}):O.jsx("div",{className:"flex items-center gap-3",children:O.jsx(im,{className:"h-1 w-full dark:h-[2px]"})})):w?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),O.jsx(i,{})):O.jsx("div",{children:"Error"})):b?(r==null||r({type:"error",message:"Session Expired"}),O.jsx("div",{className:"flex h-full items-center justify-center",children:O.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[O.jsx(Df,{children:"Session Expired"}),O.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):O.jsx("div",{className:Ee("flex h-full grow flex-col justify-between",v==null?void 0:v.dashboardPanel,e),role:"dashboard-panel",...g})}function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},he.apply(this,arguments)}function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Zn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:h,children:g,...v}=f,b=(h==null?void 0:h[e][l])||a,x=m.useMemo(()=>v,Object.values(v));return m.createElement(b.Provider,{value:x},g)}function u(f,h){const g=(h==null?void 0:h[e][l])||a,v=m.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>m.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,bB(o,...t)]}function bB(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function yB(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function cs(...e){return t=>e.forEach(n=>yB(n,t))}function _t(...e){return m.useCallback(cs(...e),e)}const M0=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(wB);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(I0,he({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(I0,he({},r,{ref:t}),n)});M0.displayName="Slot";const I0=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{..._B(r,n.props),ref:t?cs(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});I0.displayName="SlotClone";const xB=({children:e})=>m.createElement(m.Fragment,null,e);function wB(e){return m.isValidElement(e)&&e.type===xB}function _B(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function lm(e){const t=e+"CollectionProvider",[n,r]=Zn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:v,children:b}=g,x=m.useRef(null),w=m.useRef(new Map).current;return m.createElement(o,{scope:v,itemMap:w,collectionRef:x},b)},a=e+"CollectionSlot",l=m.forwardRef((g,v)=>{const{scope:b,children:x}=g,w=i(a,b),_=_t(v,w.collectionRef);return m.createElement(M0,{ref:_},x)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",f=m.forwardRef((g,v)=>{const{scope:b,children:x,...w}=g,_=m.useRef(null),S=_t(v,_),R=i(c,b);return m.useEffect(()=>(R.itemMap.set(_,{ref:_,...w}),()=>void R.itemMap.delete(_))),m.createElement(M0,{[u]:"",ref:S},x)});function h(g){const v=i(e+"CollectionConsumer",g);return m.useCallback(()=>{const x=v.collectionRef.current;if(!x)return[];const w=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((R,C)=>w.indexOf(R.ref.current)-w.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},h,r]}const ur=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},SB=V.useId||(()=>{});let CB=0;function Jo(e){const[t,n]=V.useState(SB());return ur(()=>{e||n(r=>r??String(CB++))},[e]),e||(t?`radix-${t}`:"")}const SD=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(RB);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(N0,he({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(N0,he({},r,{ref:t}),n)});SD.displayName="Slot";const N0=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...OB(r,n.props),ref:t?cs(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});N0.displayName="SlotClone";const EB=({children:e})=>m.createElement(m.Fragment,null,e);function RB(e){return m.isValidElement(e)&&e.type===EB}function OB(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const PB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Qe=PB.reduce((e,t)=>{const n=m.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?SD:t;return m.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),m.createElement(a,he({},s,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function CD(e,t){e&&ko.flushSync(()=>e.dispatchEvent(t))}function Ln(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function xr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=TB({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Ln(n),l=m.useCallback(c=>{if(i){const f=typeof c=="function"?c(e):c;f!==e&&a(f)}else o(c)},[i,e,o,a]);return[s,l]}function TB({defaultProp:e,onChange:t}){const n=m.useState(e),[r]=n,o=m.useRef(r),i=Ln(t);return m.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}const DB=m.createContext(void 0);function _l(e){const t=m.useContext(DB);return e||t||"ltr"}const Db="rovingFocusGroup.onEntryFocus",$B={bubbles:!1,cancelable:!0},Ew="RovingFocusGroup",[L0,ED,AB]=lm(Ew),[kB,ou]=Zn(Ew,[AB]),[MB,IB]=kB(Ew),NB=m.forwardRef((e,t)=>m.createElement(L0.Provider,{scope:e.__scopeRovingFocusGroup},m.createElement(L0.Slot,{scope:e.__scopeRovingFocusGroup},m.createElement(LB,he({},e,{ref:t}))))),LB=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,f=m.useRef(null),h=_t(t,f),g=_l(i),[v=null,b]=xr({prop:s,defaultProp:a,onChange:l}),[x,w]=m.useState(!1),_=Ln(c),S=ED(n),R=m.useRef(!1),[C,P]=m.useState(0);return m.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Db,_),()=>A.removeEventListener(Db,_)},[_]),m.createElement(MB,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>b(A),[b]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>P(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>P(A=>A-1),[])},m.createElement(Qe.div,he({tabIndex:x||C===0?-1:0,"data-orientation":r},u,{ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{R.current=!0}),onFocus:Me(e.onFocus,A=>{const k=!R.current;if(A.target===A.currentTarget&&k&&!x){const D=new CustomEvent(Db,$B);if(A.currentTarget.dispatchEvent(D),!D.defaultPrevented){const I=S().filter(z=>z.focusable),F=I.find(z=>z.active),B=I.find(z=>z.id===v),Z=[F,B,...I].filter(Boolean).map(z=>z.ref.current);RD(Z)}}R.current=!1}),onBlur:Me(e.onBlur,()=>w(!1))})))}),FB="RovingFocusGroupItem",jB=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=Jo(),l=i||a,c=IB(FB,n),u=c.currentTabStopId===l,f=ED(n),{onFocusableItemAdd:h,onFocusableItemRemove:g}=c;return m.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),m.createElement(L0.ItemSlot,{scope:n,id:l,focusable:r,active:o},m.createElement(Qe.span,he({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:Me(e.onMouseDown,v=>{r?c.onItemFocus(l):v.preventDefault()}),onFocus:Me(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:Me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=VB(v,c.orientation,c.dir);if(b!==void 0){v.preventDefault();let w=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const _=w.indexOf(v.currentTarget);w=c.loop?HB(w,_+1):w.slice(_+1)}setTimeout(()=>RD(w))}})})))}),zB={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function BB(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function VB(e,t,n){const r=BB(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return zB[r]}function RD(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function HB(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const Rw=NB,Ow=jB;function WB(e,t){return m.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const er=e=>{const{present:t,children:n}=e,r=UB(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=_t(r.ref,o.ref);return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};er.displayName="Presence";function UB(e){const[t,n]=m.useState(),r=m.useRef({}),o=m.useRef(e),i=m.useRef("none"),s=e?"mounted":"unmounted",[a,l]=WB(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=Uh(r.current);i.current=a==="mounted"?c:"none"},[a]),ur(()=>{const c=r.current,u=o.current;if(u!==e){const h=i.current,g=Uh(c);e?l("MOUNT"):g==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),ur(()=>{if(t){const c=f=>{const g=Uh(r.current).includes(f.animationName);f.target===t&&g&&ko.flushSync(()=>l("ANIMATION_END"))},u=f=>{f.target===t&&(i.current=Uh(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Uh(e){return(e==null?void 0:e.animationName)||"none"}const OD="Tabs",[qB,tye]=Zn(OD,[ou]),PD=ou(),[GB,Pw]=qB(OD),YB=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=_l(a),[f,h]=xr({prop:r,onChange:o,defaultProp:i});return m.createElement(GB,{scope:n,baseId:Jo(),value:f,onValueChange:h,orientation:s,dir:u,activationMode:l},m.createElement(Qe.div,he({dir:u,"data-orientation":s},c,{ref:t})))}),KB="TabsList",XB=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Pw(KB,n),s=PD(n);return m.createElement(Rw,he({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:r}),m.createElement(Qe.div,he({role:"tablist","aria-orientation":i.orientation},o,{ref:t})))}),QB="TabsTrigger",JB=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Pw(QB,n),a=PD(n),l=TD(s.baseId,r),c=DD(s.baseId,r),u=r===s.value;return m.createElement(Ow,he({asChild:!0},a,{focusable:!o,active:u}),m.createElement(Qe.button,he({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Me(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})))}),ZB="TabsContent",eV=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Pw(ZB,n),l=TD(a.baseId,r),c=DD(a.baseId,r),u=r===a.value,f=m.useRef(u);return m.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),m.createElement(er,{present:o||u},({present:h})=>m.createElement(Qe.div,he({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),h&&i))});function TD(e,t){return`${e}-trigger-${t}`}function DD(e,t){return`${e}-content-${t}`}const tV=YB,$D=XB,AD=JB,kD=eV,MD=tV,Tw=V.forwardRef(({className:e,...t},n)=>O.jsx($D,{ref:n,className:Ee("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Tw.displayName=$D.displayName;const Dw=V.forwardRef(({className:e,...t},n)=>O.jsx(AD,{ref:n,className:Ee("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Dw.displayName=AD.displayName;const $w=V.forwardRef(({className:e,...t},n)=>O.jsx(kD,{ref:n,className:Ee("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));$w.displayName=kD.displayName;var ID={exports:{}},$f={},F0={exports:{}};(function(e,t){(function(n,r){r(t)})(Vs,function(n){function r(ie){return function(ae,ye,G,be,_e,Pe,Te){return ie(ae,ye,Te)}}function o(ie){return function(ae,ye,G,be){if(!ae||!ye||typeof ae!="object"||typeof ye!="object")return ie(ae,ye,G,be);var _e=be.get(ae),Pe=be.get(ye);if(_e&&Pe)return _e===ye&&Pe===ae;be.set(ae,ye),be.set(ye,ae);var Te=ie(ae,ye,G,be);return be.delete(ae),be.delete(ye),Te}}function i(ie,te){var ae={};for(var ye in ie)ae[ye]=ie[ye];for(var ye in te)ae[ye]=te[ye];return ae}function s(ie){return ie.constructor===Object||ie.constructor==null}function a(ie){return typeof ie.then=="function"}function l(ie,te){return ie===te||ie!==ie&&te!==te}var c="[object Arguments]",u="[object Boolean]",f="[object Date]",h="[object RegExp]",g="[object Map]",v="[object Number]",b="[object Object]",x="[object Set]",w="[object String]",_=Object.prototype.toString;function S(ie){var te=ie.areArraysEqual,ae=ie.areDatesEqual,ye=ie.areMapsEqual,G=ie.areObjectsEqual,be=ie.areRegExpsEqual,_e=ie.areSetsEqual,Pe=ie.createIsNestedEqual,Te=Pe(Ue);function Ue(Be,Ie,Ke){if(Be===Ie)return!0;if(!Be||!Ie||typeof Be!="object"||typeof Ie!="object")return Be!==Be&&Ie!==Ie;if(s(Be)&&s(Ie))return G(Be,Ie,Te,Ke);var lt=Array.isArray(Be),It=Array.isArray(Ie);if(lt||It)return lt===It&&te(Be,Ie,Te,Ke);var $t=_.call(Be);return $t!==_.call(Ie)?!1:$t===f?ae(Be,Ie,Te,Ke):$t===h?be(Be,Ie,Te,Ke):$t===g?ye(Be,Ie,Te,Ke):$t===x?_e(Be,Ie,Te,Ke):$t===b||$t===c?a(Be)||a(Ie)?!1:G(Be,Ie,Te,Ke):$t===u||$t===v||$t===w?l(Be.valueOf(),Ie.valueOf()):!1}return Ue}function R(ie,te,ae,ye){var G=ie.length;if(te.length!==G)return!1;for(;G-- >0;)if(!ae(ie[G],te[G],G,G,ie,te,ye))return!1;return!0}var C=o(R);function P(ie,te){return l(ie.valueOf(),te.valueOf())}function A(ie,te,ae,ye){var G=ie.size===te.size;if(!G)return!1;if(!ie.size)return!0;var be={},_e=0;return ie.forEach(function(Pe,Te){if(G){var Ue=!1,Be=0;te.forEach(function(Ie,Ke){!Ue&&!be[Be]&&(Ue=ae(Te,Ke,_e,Be,ie,te,ye)&&ae(Pe,Ie,Te,Ke,ie,te,ye))&&(be[Be]=!0),Be++}),_e++,G=Ue}}),G}var k=o(A),D="_owner",I=Object.prototype.hasOwnProperty;function F(ie,te,ae,ye){var G=Object.keys(ie),be=G.length;if(Object.keys(te).length!==be)return!1;for(var _e;be-- >0;){if(_e=G[be],_e===D){var Pe=!!ie.$$typeof,Te=!!te.$$typeof;if((Pe||Te)&&Pe!==Te)return!1}if(!I.call(te,_e)||!ae(ie[_e],te[_e],_e,_e,ie,te,ye))return!1}return!0}var B=o(F);function K(ie,te){return ie.source===te.source&&ie.flags===te.flags}function Z(ie,te,ae,ye){var G=ie.size===te.size;if(!G)return!1;if(!ie.size)return!0;var be={};return ie.forEach(function(_e,Pe){if(G){var Te=!1,Ue=0;te.forEach(function(Be,Ie){!Te&&!be[Ue]&&(Te=ae(_e,Be,Pe,Ie,ie,te,ye))&&(be[Ue]=!0),Ue++}),G=Te}}),G}var z=o(Z),Q=Object.freeze({areArraysEqual:R,areDatesEqual:P,areMapsEqual:A,areObjectsEqual:F,areRegExpsEqual:K,areSetsEqual:Z,createIsNestedEqual:r}),W=Object.freeze({areArraysEqual:C,areDatesEqual:P,areMapsEqual:k,areObjectsEqual:B,areRegExpsEqual:K,areSetsEqual:z,createIsNestedEqual:r}),Y=S(Q);function oe(ie,te){return Y(ie,te,void 0)}var $=S(i(Q,{createIsNestedEqual:function(){return l}}));function H(ie,te){return $(ie,te,void 0)}var J=S(W);function N(ie,te){return J(ie,te,new WeakMap)}var ce=S(i(W,{createIsNestedEqual:function(){return l}}));function le(ie,te){return ce(ie,te,new WeakMap)}function de(ie){return S(i(Q,ie(Q)))}function pe(ie){var te=S(i(W,ie(W)));return function(ae,ye,G){return G===void 0&&(G=new WeakMap),te(ae,ye,G)}}n.circularDeepEqual=N,n.circularShallowEqual=le,n.createCustomCircularEqual=pe,n.createCustomEqual=de,n.deepEqual=oe,n.sameValueZeroEqual=l,n.shallowEqual=H,Object.defineProperty(n,"__esModule",{value:!0})})})(F0,F0.exports);var Aw=F0.exports;const kw=dw(yj);var Ot={},nV=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Ot,"__esModule",{value:!0});Ot.bottom=Mw;Ot.childrenEqual=sV;Ot.cloneLayout=ND;Ot.cloneLayoutItem=il;Ot.collides=cm;Ot.compact=FD;Ot.compactItem=jD;Ot.compactType=xV;Ot.correctBounds=zD;Ot.fastPositionEqual=lV;Ot.fastRGLPropsEqual=void 0;Ot.getAllCollisions=BD;Ot.getFirstCollision=qa;Ot.getLayoutItem=Iw;Ot.getStatics=Nw;Ot.modifyLayout=LD;Ot.moveElement=td;Ot.moveElementAwayFromCollision=z0;Ot.noop=void 0;Ot.perc=uV;Ot.resizeItemInDirection=mV;Ot.setTopLeft=bV;Ot.setTransform=vV;Ot.sortLayoutItems=Vw;Ot.sortLayoutItemsByColRow=qD;Ot.sortLayoutItemsByRowCol=UD;Ot.synchronizeLayoutWithChildren=yV;Ot.validateLayout=GD;Ot.withLayoutItem=iV;var uR=Aw,ed=rV(m);function rV(e){return e&&e.__esModule?e:{default:e}}const oV=process.env.NODE_ENV==="production";function Mw(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function ND(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=il(e[n]);return t}function LD(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function iV(e,t,n){let r=Iw(e,t);return r?(r=n(il(r)),e=LD(e,r),[e,r]):[e,null]}function il(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function sV(e,t){return(0,uR.deepEqual)(ed.default.Children.map(e,n=>n==null?void 0:n.key),ed.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,uR.deepEqual)(ed.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),ed.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}const aV=nV;Ot.fastRGLPropsEqual=aV;function lV(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function cm(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function FD(e,t,n,r){const o=Nw(e),i=Vw(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=il(i[a]);c.static||(c=jD(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const cV={x:"w",y:"h"};function j0(e,t,n,r){const o=cV[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;cm(t,a)&&j0(e,a,n+t[o],r)}}t[r]=n}function jD(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min(Mw(e),t.y);t.y>0&&!qa(e,t);)t.y--;else if(a)for(;t.x>0&&!qa(e,t);)t.x--;let l;for(;(l=qa(e,t))&&!(n===null&&i);)if(a?j0(o,t,l.x+l.w,"x"):j0(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!qa(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function zD(e,t){const n=Nw(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;qa(n,i);)i.y++}return e}function Iw(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function qa(e,t){for(let n=0,r=e.length;n<r;n++)if(cm(e[n],t))return e[n]}function BD(e,t){return e.filter(n=>cm(n,t))}function Nw(e){return e.filter(t=>t.static)}function td(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;"Moving element ".concat(t.i," to [").concat(String(n),",").concat(String(r),"] from [").concat(t.x,",").concat(t.y,"]");const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=Vw(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(f=f.reverse());const g=BD(f,t),v=g.length>0;if(v&&l)return ND(e);if(v&&i)return"Collision prevented on ".concat(t.i,", reverting."),t.x=c,t.y=u,t.moved=!1,e;for(let b=0,x=g.length;b<x;b++){const w=g[b];"Resolving collision between ".concat(t.i," at [").concat(t.x,",").concat(t.y,"] and ").concat(w.i," at [").concat(w.x,",").concat(w.y,"]"),!w.moved&&(w.static?e=z0(e,w,t,o,s):e=z0(e,t,w,o,s))}return e}function z0(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const f={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=qa(e,f),g=h&&h.y+h.h>t.y,v=h&&t.x+t.w>h.x;if(h){if(g&&a)return td(e,n,void 0,t.y+1,r,l,o);if(g&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(v&&s)return td(e,t,n.x,void 0,r,l,o)}else return"Doing reverse collision on ".concat(n.i," up to [").concat(f.x,",").concat(f.y,"]."),td(e,n,s?f.x:void 0,a?f.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:td(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function uV(e){return e*100+"%"}const VD=(e,t,n,r)=>e+n>r?t:n,HD=(e,t,n)=>e<0?t:n,WD=e=>Math.max(0,e),Lw=e=>Math.max(0,e),Fw=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:HD(s,e.height,o),top:Lw(s)}},jw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:VD(e.left,e.width,s,n),left:WD(o)}},zw=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:VD(e.left,e.width,i,n),top:Lw(r),left:WD(s)}},Bw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:HD(r,e.height,i),top:Lw(r)}},dV=function(){return Fw(arguments.length<=0?void 0:arguments[0],jw(...arguments))},fV=function(){return Fw(arguments.length<=0?void 0:arguments[0],zw(...arguments))},hV=function(){return Bw(arguments.length<=0?void 0:arguments[0],jw(...arguments))},pV=function(){return Bw(arguments.length<=0?void 0:arguments[0],zw(...arguments))},gV={n:Fw,ne:dV,e:jw,se:hV,s:Bw,sw:pV,w:zw,nw:fV};function mV(e,t,n,r){const o=gV[e];return o?o(t,{...t,...n},r):n}function vV(e){let{top:t,left:n,width:r,height:o}=e;const i="translate(".concat(n,"px,").concat(t,"px)");return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function bV(e){let{top:t,left:n,width:r,height:o}=e;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Vw(e,t){return t==="horizontal"?qD(e):t==="vertical"?UD(e):e}function UD(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function qD(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function yV(e,t,n,r,o){e=e||[];const i=[];ed.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=Iw(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(il(l)):c?(oV||GD([c],"ReactGridLayout.children"),i.push(il({...c,i:a.key}))):i.push(il({w:1,h:1,x:0,y:Mw(i),i:String(a.key)}))});const s=zD(i,{cols:n});return o?s:FD(s,r,n)}function GD(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++)if(typeof i[n[s]]!="number")throw new Error("ReactGridLayout: "+t+"["+r+"]."+n[s]+" must be a number!")}}function xV(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const wV=()=>{};Ot.noop=wV;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});Ri.calcGridColWidth=um;Ri.calcGridItemPosition=_V;Ri.calcGridItemWHPx=B0;Ri.calcWH=CV;Ri.calcXY=SV;Ri.clamp=Ga;function um(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function B0(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function _V(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=um(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=B0(r,c,s[0]),u.height=B0(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function SV(e,t,n,r,o){const{margin:i,cols:s,rowHeight:a,maxRows:l}=e,c=um(e);let u=Math.round((n-i[0])/(c+i[0])),f=Math.round((t-i[1])/(a+i[1]));return u=Ga(u,0,s-r),f=Ga(f,0,l-o),{x:u,y:f}}function CV(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=um(e);let f=Math.round((t+s[0])/(u+s[0])),h=Math.round((n+s[1])/(c+s[1])),g=Ga(f,0,l-r),v=Ga(h,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(g=Ga(f,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(v=Ga(h,0,a)),{w:g,h:v}}function Ga(e,t,n){return Math.max(Math.min(e,n),t)}var dm={},V0={exports:{}},$b,dR;function Hw(){if(dR)return $b;dR=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return $b=e,$b}var Ab,fR;function EV(){if(fR)return Ab;fR=1;var e=Hw();function t(){}function n(){}return n.resetWarningCache=t,Ab=function(){function r(s,a,l,c,u,f){if(f!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},Ab}var qh={exports:{}},qt={};/** @license React v16.13.1
88
+ }`;var yt=kE(function(){return jt(j,Ye+"return "+Re).apply(n,U)});if(yt.source=Re,ub(yt))throw yt;return yt}function _8(d){return Ut(d).toLowerCase()}function S8(d){return Ut(d).toUpperCase()}function C8(d,p,y){if(d=Ut(d),d&&(y||p===n))return VS(d);if(!d||!(p=Vr(p)))return d;var E=jo(d),M=jo(p),j=HS(E,M),U=WS(E,M)+1;return Os(E,j,U).join("")}function E8(d,p,y){if(d=Ut(d),d&&(y||p===n))return d.slice(0,qS(d)+1);if(!d||!(p=Vr(p)))return d;var E=jo(d),M=WS(E,jo(p))+1;return Os(E,0,M).join("")}function R8(d,p,y){if(d=Ut(d),d&&(y||p===n))return d.replace(jn,"");if(!d||!(p=Vr(p)))return d;var E=jo(d),M=HS(E,jo(p));return Os(E,M).join("")}function O8(d,p){var y=I,E=F;if(wn(p)){var M="separator"in p?p.separator:M;y="length"in p?pt(p.length):y,E="omission"in p?Vr(p.omission):E}d=Ut(d);var j=d.length;if(Nl(d)){var U=jo(d);j=U.length}if(y>=j)return d;var X=y-Ll(E);if(X<1)return E;var se=U?Os(U,0,X).join(""):d.slice(0,X);if(M===n)return se+E;if(U&&(X+=se.length-X),db(M)){if(d.slice(X).search(M)){var xe,we=se;for(M.global||(M=Ov(M.source,Ut(qe.exec(M))+"g")),M.lastIndex=0;xe=M.exec(we);)var Re=xe.index;se=se.slice(0,Re===n?X:Re)}}else if(d.indexOf(Vr(M),X)!=X){var je=se.lastIndexOf(M);je>-1&&(se=se.slice(0,je))}return se+E}function P8(d){return d=Ut(d),d&&Rn.test(d)?d.replace(Xt,rF):d}var T8=Wl(function(d,p,y){return d+(y?" ":"")+p.toUpperCase()}),pb=MC("toUpperCase");function AE(d,p,y){return d=Ut(d),p=y?n:p,p===n?J3(d)?sF(d):H3(d):d.match(p)||[]}var kE=St(function(d,p){try{return zr(d,n,p)}catch(y){return ub(y)?y:new ct(y)}}),D8=Fi(function(d,p){return mo(p,function(y){y=ai(y),Ni(d,y,lb(d[y],d))}),d});function $8(d){var p=d==null?0:d.length,y=Je();return d=p?yn(d,function(E){if(typeof E[1]!="function")throw new vo(s);return[y(E[0]),E[1]]}):[],St(function(E){for(var M=-1;++M<p;){var j=d[M];if(zr(j[0],this,E))return zr(j[1],this,E)}})}function A8(d){return r7(yo(d,f))}function gb(d){return function(){return d}}function k8(d,p){return d==null||d!==d?p:d}var M8=NC(),I8=NC(!0);function Er(d){return d}function mb(d){return fC(typeof d=="function"?d:yo(d,f))}function N8(d){return pC(yo(d,f))}function L8(d,p){return gC(d,yo(p,f))}var F8=St(function(d,p){return function(y){return _u(y,d,p)}}),j8=St(function(d,p){return function(y){return _u(d,y,p)}});function vb(d,p,y){var E=Bn(p),M=wh(p,E);y==null&&!(wn(p)&&(M.length||!E.length))&&(y=p,p=d,d=this,M=wh(p,Bn(p)));var j=!(wn(y)&&"chain"in y)||!!y.chain,U=zi(d);return mo(M,function(X){var se=p[X];d[X]=se,U&&(d.prototype[X]=function(){var xe=this.__chain__;if(j||xe){var we=d(this.__wrapped__),Re=we.__actions__=_r(this.__actions__);return Re.push({func:se,args:arguments,thisArg:d}),we.__chain__=xe,we}return se.apply(d,ws([this.value()],arguments))})}),d}function z8(){return qn._===this&&(qn._=fF),this}function bb(){}function B8(d){return d=pt(d),St(function(p){return mC(p,d)})}var V8=Kv(yn),H8=Kv(LS),W8=Kv(xv);function ME(d){return nb(d)?wv(ai(d)):x7(d)}function U8(d){return function(p){return d==null?n:Ea(d,p)}}var q8=FC(),G8=FC(!0);function yb(){return[]}function xb(){return!1}function Y8(){return{}}function K8(){return""}function X8(){return!0}function Q8(d,p){if(d=pt(d),d<1||d>Y)return[];var y=H,E=nr(d,H);p=Je(p),d-=H;for(var M=Cv(E,p);++y<d;)p(y);return M}function J8(d){return ut(d)?yn(d,ai):Hr(d)?[d]:_r(eE(Ut(d)))}function Z8(d){var p=++uF;return Ut(d)+p}var ej=Oh(function(d,p){return d+p},0),tj=Xv("ceil"),nj=Oh(function(d,p){return d/p},1),rj=Xv("floor");function oj(d){return d&&d.length?xh(d,Er,Iv):n}function ij(d,p){return d&&d.length?xh(d,Je(p,2),Iv):n}function sj(d){return zS(d,Er)}function aj(d,p){return zS(d,Je(p,2))}function lj(d){return d&&d.length?xh(d,Er,jv):n}function cj(d,p){return d&&d.length?xh(d,Je(p,2),jv):n}var uj=Oh(function(d,p){return d*p},1),dj=Xv("round"),fj=Oh(function(d,p){return d-p},0);function hj(d){return d&&d.length?Sv(d,Er):0}function pj(d,p){return d&&d.length?Sv(d,Je(p,2)):0}return L.after=N9,L.ary=dE,L.assign=S4,L.assignIn=EE,L.assignInWith=zh,L.assignWith=C4,L.at=E4,L.before=fE,L.bind=lb,L.bindAll=D8,L.bindKey=hE,L.castArray=Y9,L.chain=lE,L.chunk=r6,L.compact=o6,L.concat=i6,L.cond=$8,L.conforms=A8,L.constant=gb,L.countBy=h9,L.create=R4,L.curry=pE,L.curryRight=gE,L.debounce=mE,L.defaults=O4,L.defaultsDeep=P4,L.defer=L9,L.delay=F9,L.difference=s6,L.differenceBy=a6,L.differenceWith=l6,L.drop=c6,L.dropRight=u6,L.dropRightWhile=d6,L.dropWhile=f6,L.fill=h6,L.filter=g9,L.flatMap=b9,L.flatMapDeep=y9,L.flatMapDepth=x9,L.flatten=oE,L.flattenDeep=p6,L.flattenDepth=g6,L.flip=j9,L.flow=M8,L.flowRight=I8,L.fromPairs=m6,L.functions=I4,L.functionsIn=N4,L.groupBy=w9,L.initial=b6,L.intersection=y6,L.intersectionBy=x6,L.intersectionWith=w6,L.invert=F4,L.invertBy=j4,L.invokeMap=S9,L.iteratee=mb,L.keyBy=C9,L.keys=Bn,L.keysIn=Cr,L.map=Mh,L.mapKeys=B4,L.mapValues=V4,L.matches=N8,L.matchesProperty=L8,L.memoize=Nh,L.merge=H4,L.mergeWith=RE,L.method=F8,L.methodOf=j8,L.mixin=vb,L.negate=Lh,L.nthArg=B8,L.omit=W4,L.omitBy=U4,L.once=z9,L.orderBy=E9,L.over=V8,L.overArgs=B9,L.overEvery=H8,L.overSome=W8,L.partial=cb,L.partialRight=vE,L.partition=R9,L.pick=q4,L.pickBy=OE,L.property=ME,L.propertyOf=U8,L.pull=E6,L.pullAll=sE,L.pullAllBy=R6,L.pullAllWith=O6,L.pullAt=P6,L.range=q8,L.rangeRight=G8,L.rearg=V9,L.reject=T9,L.remove=T6,L.rest=H9,L.reverse=sb,L.sampleSize=$9,L.set=Y4,L.setWith=K4,L.shuffle=A9,L.slice=D6,L.sortBy=I9,L.sortedUniq=L6,L.sortedUniqBy=F6,L.split=b8,L.spread=W9,L.tail=j6,L.take=z6,L.takeRight=B6,L.takeRightWhile=V6,L.takeWhile=H6,L.tap=o9,L.throttle=U9,L.thru=kh,L.toArray=_E,L.toPairs=PE,L.toPairsIn=TE,L.toPath=J8,L.toPlainObject=CE,L.transform=X4,L.unary=q9,L.union=W6,L.unionBy=U6,L.unionWith=q6,L.uniq=G6,L.uniqBy=Y6,L.uniqWith=K6,L.unset=Q4,L.unzip=ab,L.unzipWith=aE,L.update=J4,L.updateWith=Z4,L.values=Gl,L.valuesIn=e8,L.without=X6,L.words=AE,L.wrap=G9,L.xor=Q6,L.xorBy=J6,L.xorWith=Z6,L.zip=e9,L.zipObject=t9,L.zipObjectDeep=n9,L.zipWith=r9,L.entries=PE,L.entriesIn=TE,L.extend=EE,L.extendWith=zh,vb(L,L),L.add=ej,L.attempt=kE,L.camelCase=o8,L.capitalize=DE,L.ceil=tj,L.clamp=t8,L.clone=K9,L.cloneDeep=Q9,L.cloneDeepWith=J9,L.cloneWith=X9,L.conformsTo=Z9,L.deburr=$E,L.defaultTo=k8,L.divide=nj,L.endsWith=i8,L.eq=Bo,L.escape=s8,L.escapeRegExp=a8,L.every=p9,L.find=m9,L.findIndex=nE,L.findKey=T4,L.findLast=v9,L.findLastIndex=rE,L.findLastKey=D4,L.floor=rj,L.forEach=cE,L.forEachRight=uE,L.forIn=$4,L.forInRight=A4,L.forOwn=k4,L.forOwnRight=M4,L.get=fb,L.gt=e4,L.gte=t4,L.has=L4,L.hasIn=hb,L.head=iE,L.identity=Er,L.includes=_9,L.indexOf=v6,L.inRange=n8,L.invoke=z4,L.isArguments=Pa,L.isArray=ut,L.isArrayBuffer=n4,L.isArrayLike=Sr,L.isArrayLikeObject=On,L.isBoolean=r4,L.isBuffer=Ps,L.isDate=o4,L.isElement=i4,L.isEmpty=s4,L.isEqual=a4,L.isEqualWith=l4,L.isError=ub,L.isFinite=c4,L.isFunction=zi,L.isInteger=bE,L.isLength=Fh,L.isMap=yE,L.isMatch=u4,L.isMatchWith=d4,L.isNaN=f4,L.isNative=h4,L.isNil=g4,L.isNull=p4,L.isNumber=xE,L.isObject=wn,L.isObjectLike=Sn,L.isPlainObject=Pu,L.isRegExp=db,L.isSafeInteger=m4,L.isSet=wE,L.isString=jh,L.isSymbol=Hr,L.isTypedArray=ql,L.isUndefined=v4,L.isWeakMap=b4,L.isWeakSet=y4,L.join=_6,L.kebabCase=l8,L.last=wo,L.lastIndexOf=S6,L.lowerCase=c8,L.lowerFirst=u8,L.lt=x4,L.lte=w4,L.max=oj,L.maxBy=ij,L.mean=sj,L.meanBy=aj,L.min=lj,L.minBy=cj,L.stubArray=yb,L.stubFalse=xb,L.stubObject=Y8,L.stubString=K8,L.stubTrue=X8,L.multiply=uj,L.nth=C6,L.noConflict=z8,L.noop=bb,L.now=Ih,L.pad=d8,L.padEnd=f8,L.padStart=h8,L.parseInt=p8,L.random=r8,L.reduce=O9,L.reduceRight=P9,L.repeat=g8,L.replace=m8,L.result=G4,L.round=dj,L.runInContext=ne,L.sample=D9,L.size=k9,L.snakeCase=v8,L.some=M9,L.sortedIndex=$6,L.sortedIndexBy=A6,L.sortedIndexOf=k6,L.sortedLastIndex=M6,L.sortedLastIndexBy=I6,L.sortedLastIndexOf=N6,L.startCase=y8,L.startsWith=x8,L.subtract=fj,L.sum=hj,L.sumBy=pj,L.template=w8,L.times=Q8,L.toFinite=Bi,L.toInteger=pt,L.toLength=SE,L.toLower=_8,L.toNumber=_o,L.toSafeInteger=_4,L.toString=Ut,L.toUpper=S8,L.trim=C8,L.trimEnd=E8,L.trimStart=R8,L.truncate=O8,L.unescape=P8,L.uniqueId=Z8,L.upperCase=T8,L.upperFirst=pb,L.each=cE,L.eachRight=uE,L.first=iE,vb(L,function(){var d={};return ii(L,function(p,y){Qt.call(L.prototype,y)||(d[y]=p)}),d}(),{chain:!1}),L.VERSION=r,mo(["bind","bindKey","curry","curryRight","partial","partialRight"],function(d){L[d].placeholder=L}),mo(["drop","take"],function(d,p){kt.prototype[d]=function(y){y=y===n?1:Mn(pt(y),0);var E=this.__filtered__&&!p?new kt(this):this.clone();return E.__filtered__?E.__takeCount__=nr(y,E.__takeCount__):E.__views__.push({size:nr(y,H),type:d+(E.__dir__<0?"Right":"")}),E},kt.prototype[d+"Right"]=function(y){return this.reverse()[d](y).reverse()}}),mo(["filter","map","takeWhile"],function(d,p){var y=p+1,E=y==Z||y==Q;kt.prototype[d]=function(M){var j=this.clone();return j.__iteratees__.push({iteratee:Je(M,3),type:y}),j.__filtered__=j.__filtered__||E,j}}),mo(["head","last"],function(d,p){var y="take"+(p?"Right":"");kt.prototype[d]=function(){return this[y](1).value()[0]}}),mo(["initial","tail"],function(d,p){var y="drop"+(p?"":"Right");kt.prototype[d]=function(){return this.__filtered__?new kt(this):this[y](1)}}),kt.prototype.compact=function(){return this.filter(Er)},kt.prototype.find=function(d){return this.filter(d).head()},kt.prototype.findLast=function(d){return this.reverse().find(d)},kt.prototype.invokeMap=St(function(d,p){return typeof d=="function"?new kt(this):this.map(function(y){return _u(y,d,p)})}),kt.prototype.reject=function(d){return this.filter(Lh(Je(d)))},kt.prototype.slice=function(d,p){d=pt(d);var y=this;return y.__filtered__&&(d>0||p<0)?new kt(y):(d<0?y=y.takeRight(-d):d&&(y=y.drop(d)),p!==n&&(p=pt(p),y=p<0?y.dropRight(-p):y.take(p-d)),y)},kt.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},kt.prototype.toArray=function(){return this.take(H)},ii(kt.prototype,function(d,p){var y=/^(?:filter|find|map|reject)|While$/.test(p),E=/^(?:head|last)$/.test(p),M=L[E?"take"+(p=="last"?"Right":""):p],j=E||/^find/.test(p);M&&(L.prototype[p]=function(){var U=this.__wrapped__,X=E?[1]:arguments,se=U instanceof kt,xe=X[0],we=se||ut(U),Re=function(Pt){var Mt=M.apply(L,ws([Pt],X));return E&&je?Mt[0]:Mt};we&&y&&typeof xe=="function"&&xe.length!=1&&(se=we=!1);var je=this.__chain__,Ye=!!this.__actions__.length,et=j&&!je,yt=se&&!Ye;if(!j&&we){U=yt?U:new kt(this);var tt=d.apply(U,X);return tt.__actions__.push({func:kh,args:[Re],thisArg:n}),new bo(tt,je)}return et&&yt?d.apply(this,X):(tt=this.thru(Re),et?E?tt.value()[0]:tt.value():tt)})}),mo(["pop","push","shift","sort","splice","unshift"],function(d){var p=ih[d],y=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",E=/^(?:pop|shift)$/.test(d);L.prototype[d]=function(){var M=arguments;if(E&&!this.__chain__){var j=this.value();return p.apply(ut(j)?j:[],M)}return this[y](function(U){return p.apply(ut(U)?U:[],M)})}}),ii(kt.prototype,function(d,p){var y=L[p];if(y){var E=y.name+"";Qt.call(Bl,E)||(Bl[E]=[]),Bl[E].push({name:p,func:y})}}),Bl[Rh(n,w).name]=[{name:"wrapper",func:n}],kt.prototype.clone=PF,kt.prototype.reverse=TF,kt.prototype.value=DF,L.prototype.at=i9,L.prototype.chain=s9,L.prototype.commit=a9,L.prototype.next=l9,L.prototype.plant=u9,L.prototype.reverse=d9,L.prototype.toJSON=L.prototype.valueOf=L.prototype.value=f9,L.prototype.first=L.prototype.head,gu&&(L.prototype[gu]=c9),L},Fl=aF();xa?((xa.exports=Fl)._=Fl,mv._=Fl):qn._=Fl}).call(Vs)})(hg,hg.exports);var uc=hg.exports;const ol=nu(uc);function eR({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10};return t||(t={}),vw.forEach(l=>{t!=null&&t[l]||(t={...t,[l]:[]});const c=t[l].reduce((u,f)=>Math.max(u,f.y+f.h),0);a.y=a.y===0?0:c,t[l].push(a)}),t}function tR(e,t){t&&vw.forEach(n=>{t!=null&&t[n]&&(t[n]=t[n].filter(r=>r.i!==e))})}const ke=X2()(rD((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:x0},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{deleteSheet:n=>{e(r=>{var i,s,a,l;const o=(i=r.dashboard.sheets)==null?void 0:i.findIndex(c=>c.id===n);o!==void 0&&o>-1&&((s=r.dashboard.sheets)==null||s.splice(o,1),r.selectedSheetId=(l=(a=r.dashboard.sheets)==null?void 0:a[0])==null?void 0:l.id)})},addSheet:n=>{e(r=>{r.dashboard.sheets||(r.dashboard.sheets=[]);const o=r.dashboard.filters;let i={};o==null||o.forEach(a=>{vw.forEach(l=>{i!=null&&i[l]||(i={...i,[l]:[]});const c={i:a.id,x:0,y:0,w:10,h:8};i[l].push(c)})});const s={...n,layouts:i};r.dashboard.sheets.push(s)})},setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&uc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.python=r)})})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setBookmarkKey:n=>{e(()=>({bookmarkKey:n}))},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.title=r)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&uc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.title=o)})})},setCardInfo:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&uc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.info=r)})})},setCardDescription:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&uc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.description=o)})})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){const f=(c=s.cards)==null?void 0:c.find(h=>h.id===r);f&&(f.sql=o,(u=i.onUpdateCard)==null||u.call(i,f,n))}})},setFrameCardData:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&uc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.data=o)})})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n];const o=(s=r.dashboard.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId);eR({id:n.id,layouts:o==null?void 0:o.layouts,y:0,initialHeight:8,minH:7,w:10})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1);const l=(s=r.dashboard.sheets)==null?void 0:s.find(c=>c.id===r.selectedSheetId);tR(n,l==null?void 0:l.layouts)}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,f,h;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(g=>g.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(g=>g.id===r);if(a){const g=(f=a.cards)==null?void 0:f.findIndex(v=>v.id===o.id);g>-1&&((h=a.cards)==null||h.splice(g,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let f=1/0,h=0;o==="start"&&(f=0),eR({id:r.id,layouts:s.layouts,minH:10,x:h,y:f}),(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(i){const f=(l=i.frames)==null?void 0:l.findIndex(h=>h.id===r);console.log(f),typeof f=="number"&&f>-1&&((c=i.frames)==null||c.splice(f,1),(u=i.layout)==null||u.splice(f,1),tR(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(f=>f.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r))})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(f=o.onUpdateCard)==null||f.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,f,h;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(g=>g.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(g=>g.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(f=i.layout)==null||f.splice(s,1),(h=o.onRemoveCard)==null||h.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},getCardSheet(n){var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return r[s]}}},handleDataPointClickAction:(n,r)=>{Iz({card:n,dataPoint:r,set:e,get:t})}}}))),Mo=()=>ke(e=>e.actions);var Pf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Hc=typeof window>"u"||"Deno"in window;function Oo(){}function Nz(e,t){return typeof e=="function"?e(t):e}function _0(e){return typeof e=="number"&&e>=0&&e!==1/0}function cD(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nR(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==xw(s,t.options))return!1}else if(!Dd(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof o<"u"&&o!==t.state.fetchStatus||i&&!i(t))}function rR(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Td(t.options.mutationKey)!==Td(i))return!1}else if(!Dd(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function xw(e,t){return((t==null?void 0:t.queryKeyHashFn)||Td)(e)}function Td(e){return JSON.stringify(e,(t,n)=>C0(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Dd(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Dd(e[n],t[n])):!1}function uD(e,t){if(e===t)return e;const n=oR(e)&&oR(t);if(n||C0(e)&&C0(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];!n&&e[u]===void 0&&t[u]===void 0&&r.includes(u)?(a[u]=void 0,l++):(a[u]=uD(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function S0(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function oR(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function C0(e){if(!iR(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!iR(n)||!n.hasOwnProperty("isPrototypeOf"))}function iR(e){return Object.prototype.toString.call(e)==="[object Object]"}function Lz(e){return new Promise(t=>{setTimeout(t,e)})}function E0(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?uD(e,t):t}function Fz(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function jz(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Xa,Hs,Cc,A2,zz=(A2=class extends Pf{constructor(){super();Xe(this,Xa,void 0);Xe(this,Hs,void 0);Xe(this,Cc,void 0);Ve(this,Cc,t=>{if(!Hc&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){re(this,Hs)||this.setEventListener(re(this,Cc))}onUnsubscribe(){var t;this.hasListeners()||((t=re(this,Hs))==null||t.call(this),Ve(this,Hs,void 0))}setEventListener(t){var n;Ve(this,Cc,t),(n=re(this,Hs))==null||n.call(this),Ve(this,Hs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){re(this,Xa)!==t&&(Ve(this,Xa,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof re(this,Xa)=="boolean"?re(this,Xa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Xa=new WeakMap,Hs=new WeakMap,Cc=new WeakMap,A2),pg=new zz,Ec,Ws,Rc,k2,Bz=(k2=class extends Pf{constructor(){super();Xe(this,Ec,!0);Xe(this,Ws,void 0);Xe(this,Rc,void 0);Ve(this,Rc,t=>{if(!Hc&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){re(this,Ws)||this.setEventListener(re(this,Rc))}onUnsubscribe(){var t;this.hasListeners()||((t=re(this,Ws))==null||t.call(this),Ve(this,Ws,void 0))}setEventListener(t){var n;Ve(this,Rc,t),(n=re(this,Ws))==null||n.call(this),Ve(this,Ws,t(this.setOnline.bind(this)))}setOnline(t){re(this,Ec)!==t&&(Ve(this,Ec,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return re(this,Ec)}},Ec=new WeakMap,Ws=new WeakMap,Rc=new WeakMap,k2),gg=new Bz;function Vz(e){return Math.min(1e3*2**e,3e4)}function om(e){return(e??"online")==="online"?gg.isOnline():!0}var dD=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Tb(e){return e instanceof dD}function fD(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((x,w)=>{i=x,s=w}),l=x=>{var w;r||(g(new dD(x)),(w=e.abort)==null||w.call(e))},c=()=>{t=!0},u=()=>{t=!1},f=()=>!pg.isFocused()||e.networkMode!=="always"&&!gg.isOnline(),h=x=>{var w;r||(r=!0,(w=e.onSuccess)==null||w.call(e,x),o==null||o(),i(x))},g=x=>{var w;r||(r=!0,(w=e.onError)==null||w.call(e,x),o==null||o(),s(x))},v=()=>new Promise(x=>{var w;o=_=>{const S=r||!f();return S&&x(_),S},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;o=void 0,r||(x=e.onContinue)==null||x.call(e)}),b=()=>{if(r)return;let x;try{x=e.fn()}catch(w){x=Promise.reject(w)}Promise.resolve(x).then(h).catch(w=>{var P;if(r)return;const _=e.retry??(Hc?0:3),S=e.retryDelay??Vz,R=typeof S=="function"?S(n,w):S,C=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,w);if(t||!C){g(w);return}n++,(P=e.onFail)==null||P.call(e,n,w),Lz(R).then(()=>{if(f())return v()}).then(()=>{t?g(w):b()})})};return om(e.networkMode)?b():v().then(b),{promise:a,cancel:l,continue:()=>(o==null?void 0:o())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}function Hz(){let e=[],t=0,n=h=>{h()},r=h=>{h()},o=h=>setTimeout(h,0);const i=h=>{o=h},s=h=>{let g;t++;try{g=h()}finally{t--,t||c()}return g},a=h=>{t?e.push(h):o(()=>{n(h)})},l=h=>(...g)=>{a(()=>{h(...g)})},c=()=>{const h=e;e=[],h.length&&o(()=>{r(()=>{h.forEach(g=>{n(g)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:h=>{n=h},setBatchNotifyFunction:h=>{r=h},setScheduler:i}}var Xn=Hz(),Qa,M2,hD=(M2=class{constructor(){Xe(this,Qa,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_0(this.gcTime)&&Ve(this,Qa,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Hc?1/0:5*60*1e3))}clearGcTimeout(){re(this,Qa)&&(clearTimeout(re(this,Qa)),Ve(this,Qa,void 0))}},Qa=new WeakMap,M2),Oc,Pc,Co,Us,Eo,Vn,pf,Ja,Tc,Kp,Go,qi,I2,Wz=(I2=class extends hD{constructor(t){super();Xe(this,Tc);Xe(this,Go);Xe(this,Oc,void 0);Xe(this,Pc,void 0);Xe(this,Co,void 0);Xe(this,Us,void 0);Xe(this,Eo,void 0);Xe(this,Vn,void 0);Xe(this,pf,void 0);Xe(this,Ja,void 0);Ve(this,Ja,!1),Ve(this,pf,t.defaultOptions),Ct(this,Tc,Kp).call(this,t.options),Ve(this,Vn,[]),Ve(this,Co,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ve(this,Oc,t.state||Uz(this.options)),this.state=re(this,Oc),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!re(this,Vn).length&&this.state.fetchStatus==="idle"&&re(this,Co).remove(this)}setData(t,n){const r=E0(this.state.data,t,this.options);return Ct(this,Go,qi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ct(this,Go,qi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=re(this,Us);return(r=re(this,Eo))==null||r.cancel(t),n?n.then(Oo).catch(Oo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(re(this,Oc))}isActive(){return re(this,Vn).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||re(this,Vn).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!cD(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=re(this,Vn).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=re(this,Eo))==null||n.continue()}onOnline(){var n;const t=re(this,Vn).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=re(this,Eo))==null||n.continue()}addObserver(t){re(this,Vn).includes(t)||(re(this,Vn).push(t),this.clearGcTimeout(),re(this,Co).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){re(this,Vn).includes(t)&&(Ve(this,Vn,re(this,Vn).filter(n=>n!==t)),re(this,Vn).length||(re(this,Eo)&&(re(this,Ja)?re(this,Eo).cancel({revert:!0}):re(this,Eo).cancelRetry()),this.scheduleGc()),re(this,Co).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return re(this,Vn).length}invalidate(){this.state.isInvalidated||Ct(this,Go,qi).call(this,{type:"invalidate"})}fetch(t,n){var c,u,f,h;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(re(this,Us))return(c=re(this,Eo))==null||c.continueRetry(),re(this,Us)}if(t&&Ct(this,Tc,Kp).call(this,t),!this.options.queryFn){const g=re(this,Vn).find(v=>v.options.queryFn);g&&Ct(this,Tc,Kp).call(this,g.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o={queryKey:this.queryKey,meta:this.meta},i=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Ve(this,Ja,!0),r.signal)})};i(o);const s=()=>this.options.queryFn?(Ve(this,Ja,!1),this.options.persister?this.options.persister(this.options.queryFn,o,this):this.options.queryFn(o)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(a),(u=this.options.behavior)==null||u.onFetch(a,this),Ve(this,Pc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&Ct(this,Go,qi).call(this,{type:"fetch",meta:(h=a.fetchOptions)==null?void 0:h.meta});const l=g=>{var v,b,x,w;Tb(g)&&g.silent||Ct(this,Go,qi).call(this,{type:"error",error:g}),Tb(g)||((b=(v=re(this,Co).config).onError)==null||b.call(v,g,this),(w=(x=re(this,Co).config).onSettled)==null||w.call(x,this.state.data,g,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Ve(this,Eo,fD({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:g=>{var v,b,x,w;if(typeof g>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(g),(b=(v=re(this,Co).config).onSuccess)==null||b.call(v,g,this),(w=(x=re(this,Co).config).onSettled)==null||w.call(x,g,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(g,v)=>{Ct(this,Go,qi).call(this,{type:"failed",failureCount:g,error:v})},onPause:()=>{Ct(this,Go,qi).call(this,{type:"pause"})},onContinue:()=>{Ct(this,Go,qi).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Ve(this,Us,re(this,Eo).promise),re(this,Us)}},Oc=new WeakMap,Pc=new WeakMap,Co=new WeakMap,Us=new WeakMap,Eo=new WeakMap,Vn=new WeakMap,pf=new WeakMap,Ja=new WeakMap,Tc=new WeakSet,Kp=function(t){this.options={...re(this,pf),...t},this.updateGcTime(this.options.gcTime)},Go=new WeakSet,qi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:om(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Tb(o)&&o.revert&&re(this,Pc)?{...re(this,Pc),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Xn.batch(()=>{re(this,Vn).forEach(r=>{r.onQueryUpdate()}),re(this,Co).notify({query:this,type:"updated",action:t})})},I2);function Uz(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var fi,N2,pD=(N2=class extends Pf{constructor(t={}){super();Xe(this,fi,void 0);this.config=t,Ve(this,fi,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??xw(o,n);let s=this.get(i);return s||(s=new Wz({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){re(this,fi).has(t.queryHash)||(re(this,fi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=re(this,fi).get(t.queryHash);n&&(t.destroy(),n===t&&re(this,fi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Xn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return re(this,fi).get(t)}getAll(){return[...re(this,fi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>nR(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>nR(t,r)):n}notify(t){Xn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Xn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Xn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},fi=new WeakMap,N2),hi,gf,Xr,Dc,pi,Ls,L2,qz=(L2=class extends hD{constructor(t){super();Xe(this,pi);Xe(this,hi,void 0);Xe(this,gf,void 0);Xe(this,Xr,void 0);Xe(this,Dc,void 0);this.mutationId=t.mutationId,Ve(this,gf,t.defaultOptions),Ve(this,Xr,t.mutationCache),Ve(this,hi,[]),this.state=t.state||Gz(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...re(this,gf),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){re(this,hi).includes(t)||(re(this,hi).push(t),this.clearGcTimeout(),re(this,Xr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ve(this,hi,re(this,hi).filter(n=>n!==t)),this.scheduleGc(),re(this,Xr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){re(this,hi).length||(this.state.status==="pending"?this.scheduleGc():re(this,Xr).remove(this))}continue(){var t;return((t=re(this,Dc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,f,h,g,v,b,x,w,_,S,R,C,P,A;const n=()=>(Ve(this,Dc,fD({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(k,D)=>{Ct(this,pi,Ls).call(this,{type:"failed",failureCount:k,error:D})},onPause:()=>{Ct(this,pi,Ls).call(this,{type:"pause"})},onContinue:()=>{Ct(this,pi,Ls).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),re(this,Dc).promise),r=this.state.status==="pending";try{if(!r){Ct(this,pi,Ls).call(this,{type:"pending",variables:t}),await((i=(o=re(this,Xr).config).onMutate)==null?void 0:i.call(o,t,this));const D=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));D!==this.state.context&&Ct(this,pi,Ls).call(this,{type:"pending",context:D,variables:t})}const k=await n();return await((c=(l=re(this,Xr).config).onSuccess)==null?void 0:c.call(l,k,t,this.state.context,this)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,k,t,this.state.context)),await((g=(h=re(this,Xr).config).onSettled)==null?void 0:g.call(h,k,null,this.state.variables,this.state.context,this)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,k,null,t,this.state.context)),Ct(this,pi,Ls).call(this,{type:"success",data:k}),k}catch(k){try{throw await((w=(x=re(this,Xr).config).onError)==null?void 0:w.call(x,k,t,this.state.context,this)),await((S=(_=this.options).onError)==null?void 0:S.call(_,k,t,this.state.context)),await((C=(R=re(this,Xr).config).onSettled)==null?void 0:C.call(R,void 0,k,this.state.variables,this.state.context,this)),await((A=(P=this.options).onSettled)==null?void 0:A.call(P,void 0,k,t,this.state.context)),k}finally{Ct(this,pi,Ls).call(this,{type:"error",error:k})}}}},hi=new WeakMap,gf=new WeakMap,Xr=new WeakMap,Dc=new WeakMap,pi=new WeakSet,Ls=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!om(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Xn.batch(()=>{re(this,hi).forEach(r=>{r.onMutationUpdate(t)}),re(this,Xr).notify({mutation:this,type:"updated",action:t})})},L2);function Gz(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ro,mf,Za,F2,Yz=(F2=class extends Pf{constructor(t={}){super();Xe(this,Ro,void 0);Xe(this,mf,void 0);Xe(this,Za,void 0);this.config=t,Ve(this,Ro,[]),Ve(this,mf,0)}build(t,n,r){const o=new qz({mutationCache:this,mutationId:++Bh(this,mf)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){re(this,Ro).push(t),this.notify({type:"added",mutation:t})}remove(t){Ve(this,Ro,re(this,Ro).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){Xn.batch(()=>{re(this,Ro).forEach(t=>{this.remove(t)})})}getAll(){return re(this,Ro)}find(t){const n={exact:!0,...t};return re(this,Ro).find(r=>rR(n,r))}findAll(t={}){return re(this,Ro).filter(n=>rR(t,n))}notify(t){Xn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Ve(this,Za,(re(this,Za)??Promise.resolve()).then(()=>{const t=re(this,Ro).filter(n=>n.state.isPaused);return Xn.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(Oo)),Promise.resolve()))}).then(()=>{Ve(this,Za,void 0)})),re(this,Za)}},Ro=new WeakMap,mf=new WeakMap,Za=new WeakMap,F2);function Kz(e){return{onFetch:(t,n)=>{const r=async()=>{var v,b,x,w,_;const o=t.options,i=(x=(b=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:b.fetchMore)==null?void 0:x.direction,s=((w=t.state.data)==null?void 0:w.pages)||[],a=((_=t.state.data)==null?void 0:_.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const u=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),h=async(S,R,C)=>{if(c)return Promise.reject();if(R==null&&S.pages.length)return Promise.resolve(S);const P={queryKey:t.queryKey,pageParam:R,direction:C?"backward":"forward",meta:t.options.meta};u(P);const A=await f(P),{maxPages:k}=t.options,D=C?jz:Fz;return{pages:D(S.pages,A,k),pageParams:D(S.pageParams,R,k)}};let g;if(i&&s.length){const S=i==="backward",R=S?Xz:sR,C={pages:s,pageParams:a},P=R(o,C);g=await h(C,P,S)}else{g=await h(l,a[0]??o.initialPageParam);const S=e??s.length;for(let R=1;R<S;R++){const C=sR(o,g);g=await h(g,C)}}return g};t.options.persister?t.fetchFn=()=>{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function sR(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function Xz(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var In,qs,Gs,$c,Ac,Ys,kc,Mc,j2,Qz=(j2=class{constructor(e={}){Xe(this,In,void 0);Xe(this,qs,void 0);Xe(this,Gs,void 0);Xe(this,$c,void 0);Xe(this,Ac,void 0);Xe(this,Ys,void 0);Xe(this,kc,void 0);Xe(this,Mc,void 0);Ve(this,In,e.queryCache||new pD),Ve(this,qs,e.mutationCache||new Yz),Ve(this,Gs,e.defaultOptions||{}),Ve(this,$c,new Map),Ve(this,Ac,new Map),Ve(this,Ys,0)}mount(){Bh(this,Ys)._++,re(this,Ys)===1&&(Ve(this,kc,pg.subscribe(()=>{pg.isFocused()&&(this.resumePausedMutations(),re(this,In).onFocus())})),Ve(this,Mc,gg.subscribe(()=>{gg.isOnline()&&(this.resumePausedMutations(),re(this,In).onOnline())})))}unmount(){var e,t;Bh(this,Ys)._--,re(this,Ys)===0&&((e=re(this,kc))==null||e.call(this),Ve(this,kc,void 0),(t=re(this,Mc))==null||t.call(this),Ve(this,Mc,void 0))}isFetching(e){return re(this,In).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return re(this,qs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=re(this,In).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=re(this,In).find({queryKey:e}),o=r==null?void 0:r.state.data,i=Nz(t,o);if(typeof i>"u")return;const s=this.defaultQueryOptions({queryKey:e});return re(this,In).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Xn.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=re(this,In).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=re(this,In);Xn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=re(this,In),r={type:"active",...e};return Xn.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=Xn.batch(()=>re(this,In).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Oo).catch(Oo)}invalidateQueries(e={},t={}){return Xn.batch(()=>{if(re(this,In).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=Xn.batch(()=>re(this,In).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(Oo)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Oo)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=re(this,In).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Oo).catch(Oo)}fetchInfiniteQuery(e){return e.behavior=Kz(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Oo).catch(Oo)}resumePausedMutations(){return re(this,qs).resumePausedMutations()}getQueryCache(){return re(this,In)}getMutationCache(){return re(this,qs)}getDefaultOptions(){return re(this,Gs)}setDefaultOptions(e){Ve(this,Gs,e)}setQueryDefaults(e,t){re(this,$c).set(Td(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...re(this,$c).values()];let n={};return t.forEach(r=>{Dd(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){re(this,Ac).set(Td(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...re(this,Ac).values()];let n={};return t.forEach(r=>{Dd(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...re(this,Gs).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=xw(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...re(this,Gs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){re(this,In).clear(),re(this,qs).clear()}},In=new WeakMap,qs=new WeakMap,Gs=new WeakMap,$c=new WeakMap,Ac=new WeakMap,Ys=new WeakMap,kc=new WeakMap,Mc=new WeakMap,j2),$r,fn,vf,vr,el,Ic,gi,bf,Nc,Lc,tl,nl,Ks,Fc,rl,Zu,yf,R0,xf,O0,wf,P0,_f,T0,Sf,D0,Cf,$0,Ef,A0,Jg,gD,z2,Jz=(z2=class extends Pf{constructor(t,n){super();Xe(this,rl);Xe(this,yf);Xe(this,xf);Xe(this,wf);Xe(this,_f);Xe(this,Sf);Xe(this,Cf);Xe(this,Ef);Xe(this,Jg);Xe(this,$r,void 0);Xe(this,fn,void 0);Xe(this,vf,void 0);Xe(this,vr,void 0);Xe(this,el,void 0);Xe(this,Ic,void 0);Xe(this,gi,void 0);Xe(this,bf,void 0);Xe(this,Nc,void 0);Xe(this,Lc,void 0);Xe(this,tl,void 0);Xe(this,nl,void 0);Xe(this,Ks,void 0);Xe(this,Fc,new Set);this.options=n,Ve(this,$r,t),Ve(this,gi,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(re(this,fn).addObserver(this),aR(re(this,fn),this.options)?Ct(this,rl,Zu).call(this):this.updateResult(),Ct(this,_f,T0).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return k0(re(this,fn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return k0(re(this,fn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ct(this,Sf,D0).call(this),Ct(this,Cf,$0).call(this),re(this,fn).removeObserver(this)}setOptions(t,n){const r=this.options,o=re(this,fn);if(this.options=re(this,$r).defaultQueryOptions(t),S0(r,this.options)||re(this,$r).getQueryCache().notify({type:"observerOptionsUpdated",query:re(this,fn),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),Ct(this,Ef,A0).call(this);const i=this.hasListeners();i&&lR(re(this,fn),o,this.options,r)&&Ct(this,rl,Zu).call(this),this.updateResult(n),i&&(re(this,fn)!==o||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&Ct(this,yf,R0).call(this);const s=Ct(this,xf,O0).call(this);i&&(re(this,fn)!==o||this.options.enabled!==r.enabled||s!==re(this,Ks))&&Ct(this,wf,P0).call(this,s)}getOptimisticResult(t){const n=re(this,$r).getQueryCache().build(re(this,$r),t),r=this.createResult(n,t);return eB(this,r)&&(Ve(this,vr,r),Ve(this,Ic,this.options),Ve(this,el,re(this,fn).state)),r}getCurrentResult(){return re(this,vr)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(re(this,Fc).add(r),t[r])})}),n}getCurrentQuery(){return re(this,fn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=re(this,$r).defaultQueryOptions(t),r=re(this,$r).getQueryCache().build(re(this,$r),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ct(this,rl,Zu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),re(this,vr)))}createResult(t,n){var P;const r=re(this,fn),o=this.options,i=re(this,vr),s=re(this,el),a=re(this,Ic),c=t!==r?t.state:re(this,vf),{state:u}=t;let{error:f,errorUpdatedAt:h,fetchStatus:g,status:v}=u,b=!1,x;if(n._optimisticResults){const A=this.hasListeners(),k=!A&&aR(t,n),D=A&&lR(t,r,n,o);(k||D)&&(g=om(t.options.networkMode)?"fetching":"paused",u.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(g="idle")}if(n.select&&typeof u.data<"u")if(i&&u.data===(s==null?void 0:s.data)&&n.select===re(this,bf))x=re(this,Nc);else try{Ve(this,bf,n.select),x=n.select(u.data),x=E0(i==null?void 0:i.data,x,n),Ve(this,Nc,x),Ve(this,gi,null)}catch(A){Ve(this,gi,A)}else x=u.data;if(typeof n.placeholderData<"u"&&typeof x>"u"&&v==="pending"){let A;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))A=i.data;else if(A=typeof n.placeholderData=="function"?n.placeholderData((P=re(this,Lc))==null?void 0:P.state.data,re(this,Lc)):n.placeholderData,n.select&&typeof A<"u")try{A=n.select(A),Ve(this,gi,null)}catch(k){Ve(this,gi,k)}typeof A<"u"&&(v="success",x=E0(i==null?void 0:i.data,A,n),b=!0)}re(this,gi)&&(f=re(this,gi),x=re(this,Nc),h=Date.now(),v="error");const w=g==="fetching",_=v==="pending",S=v==="error",R=_&&w;return{status:v,fetchStatus:g,isPending:_,isSuccess:v==="success",isError:S,isInitialLoading:R,isLoading:R,data:x,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!_,isLoadingError:S&&u.dataUpdatedAt===0,isPaused:g==="paused",isPlaceholderData:b,isRefetchError:S&&u.dataUpdatedAt!==0,isStale:ww(t,n),refetch:this.refetch}}updateResult(t){const n=re(this,vr),r=this.createResult(re(this,fn),this.options);if(Ve(this,el,re(this,fn).state),Ve(this,Ic,this.options),re(this,el).data!==void 0&&Ve(this,Lc,re(this,fn)),S0(r,n))return;Ve(this,vr,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!re(this,Fc).size)return!0;const l=new Set(a??re(this,Fc));return this.options.throwOnError&&l.add("error"),Object.keys(re(this,vr)).some(c=>{const u=c;return re(this,vr)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),Ct(this,Jg,gD).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ct(this,_f,T0).call(this)}},$r=new WeakMap,fn=new WeakMap,vf=new WeakMap,vr=new WeakMap,el=new WeakMap,Ic=new WeakMap,gi=new WeakMap,bf=new WeakMap,Nc=new WeakMap,Lc=new WeakMap,tl=new WeakMap,nl=new WeakMap,Ks=new WeakMap,Fc=new WeakMap,rl=new WeakSet,Zu=function(t){Ct(this,Ef,A0).call(this);let n=re(this,fn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Oo)),n},yf=new WeakSet,R0=function(){if(Ct(this,Sf,D0).call(this),Hc||re(this,vr).isStale||!_0(this.options.staleTime))return;const n=cD(re(this,vr).dataUpdatedAt,this.options.staleTime)+1;Ve(this,tl,setTimeout(()=>{re(this,vr).isStale||this.updateResult()},n))},xf=new WeakSet,O0=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(re(this,fn)):this.options.refetchInterval)??!1},wf=new WeakSet,P0=function(t){Ct(this,Cf,$0).call(this),Ve(this,Ks,t),!(Hc||this.options.enabled===!1||!_0(re(this,Ks))||re(this,Ks)===0)&&Ve(this,nl,setInterval(()=>{(this.options.refetchIntervalInBackground||pg.isFocused())&&Ct(this,rl,Zu).call(this)},re(this,Ks)))},_f=new WeakSet,T0=function(){Ct(this,yf,R0).call(this),Ct(this,wf,P0).call(this,Ct(this,xf,O0).call(this))},Sf=new WeakSet,D0=function(){re(this,tl)&&(clearTimeout(re(this,tl)),Ve(this,tl,void 0))},Cf=new WeakSet,$0=function(){re(this,nl)&&(clearInterval(re(this,nl)),Ve(this,nl,void 0))},Ef=new WeakSet,A0=function(){const t=re(this,$r).getQueryCache().build(re(this,$r),this.options);if(t===re(this,fn))return;const n=re(this,fn);Ve(this,fn,t),Ve(this,vf,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Jg=new WeakSet,gD=function(t){Xn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(re(this,vr))}),re(this,$r).getQueryCache().notify({query:re(this,fn),type:"observerResultsUpdated"})})},z2);function Zz(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function aR(e,t){return Zz(e,t)||e.state.dataUpdatedAt>0&&k0(e,t,t.refetchOnMount)}function k0(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ww(e,t)}return!1}function lR(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&ww(e,n)}function ww(e,t){return e.isStaleByTime(t.staleTime)}function eB(e,t){return!S0(e.getCurrentResult(),t)}var mD=V.createContext(void 0),vD=e=>{const t=V.useContext(mD);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},tB=({client:e,children:t})=>(V.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),V.createElement(mD.Provider,{value:e},t)),bD=V.createContext(!1),nB=()=>V.useContext(bD);bD.Provider;function rB(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oB=V.createContext(rB()),iB=()=>V.useContext(oB);function sB(e,t){return typeof e=="function"?e(...t):!!e}var aB=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},lB=e=>{V.useEffect(()=>{e.clearReset()},[e])},cB=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&sB(n,[e.error,r]),uB=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},dB=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,fB=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function hB(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=vD(n),o=nB(),i=iB(),s=r.defaultQueryOptions(e);s._optimisticResults=o?"isRestoring":"optimistic",uB(s),aB(s,i),lB(i);const[a]=V.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(V.useSyncExternalStore(V.useCallback(c=>{const u=o?()=>{}:a.subscribe(Xn.batchCalls(c));return a.updateResult(),u},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),V.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),dB(s,l))throw fB(s,a,i);if(cB({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Tf(e,t){return hB(e,Jz,t)}const pB={theme:"system",setTheme:()=>null},yD=m.createContext(pB);function gB({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=m.useState(()=>localStorage.getItem(n)||t);m.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return O.jsx(yD.Provider,{...r,value:s,children:e})}const xD=()=>{const e=m.useContext(yD);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};async function mB(e){return await(await fetch("https://semaphor.cloud/api/v1/dashboard",{headers:{Authorization:`Bearer ${e}`}})).json()}function wD(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function cR(e,t){const n=wD(e);return n==="dark"?ol.merge({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function vB({authToken:e,customStyle:t,currentTheme:n,onSave:r,onEvent:o}){const{data:i,refetch:s,isLoading:a,isError:l}=Tf({queryKey:["dashboard",e==null?void 0:e.accessToken],queryFn:()=>mB(e==null?void 0:e.accessToken),enabled:!1}),{theme:c,setTheme:u}=xD(),f=ke(A=>A.dashboard.globalStyle),{setDashboard:h,setSelectedSheetId:g,setStyle:v,setOnSaveFunction:b}=ke(A=>A.actions);ke(A=>A.actions.setCustomCards);const x=ke(A=>A.actions.setFilterValues),w=ke(A=>A.actions.setBookmarkKey),_=ke(A=>A.actions.setAuthToken),S=ke(A=>A.actions.setThemeStyle),R=ke(A=>A.actions.setDashboardTheme),C=ke(A=>A.actions.setOnEvent);m.useEffect(()=>{if(c){const A=wD(c);R(A)}},[c,R]),m.useEffect(()=>{n&&u(n)},[n,u]);function P(){const A=ol.cloneDeep(x0),k=ol.merge(A,f);if(t){const D=ol.merge(k,t),I=cR(c,D);S(I),v(D)}else{const D=cR(c,k);S(D),v(x0)}}return m.useEffect(()=>{i&&i.dashboard&&P()},[c,t,f]),m.useEffect(()=>{var F;if(!i||!i.dashboard)return;const A=i.dashboard,k=yL(A.id),D=JSON.parse(localStorage.getItem(k)||"[]"),I=D.find(B=>B.default===!0);if(I)h(I.template),P(),w(I.name),I.filterValues&&x(I.filterValues);else{h(A),P();const B=D.find(K=>(K==null?void 0:K.name)==="Original");B?B.template=A:D.push({name:"Original",template:A,default:!1}),localStorage.setItem(k,JSON.stringify(D))}g((F=A.sheets)==null?void 0:F[0].id)},[i,h,g,x,w]),m.useEffect(()=>{r&&b(r),o&&C(o)},[r,b,o,C]),m.useEffect(()=>{e&&e.accessToken&&(_(e),s())},[e,s,_]),{isLoading:a,isError:l}}function im({className:e,...t}){return O.jsx("div",{className:Ee("animate-pulse rounded-md bg-muted",e),...t})}const _w=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));_w.displayName="Card";const sm=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("flex flex-col space-y-1.5 p-6",e),...t}));sm.displayName="CardHeader";const Df=V.forwardRef(({className:e,...t},n)=>O.jsx("h3",{ref:n,className:Ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));Df.displayName="CardTitle";const Sw=V.forwardRef(({className:e,...t},n)=>O.jsx("p",{ref:n,className:Ee("text-sm text-muted-foreground",e),...t}));Sw.displayName="CardDescription";const am=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("px-6 pt-0",e),...t}));am.displayName="CardContent";const Cw=V.forwardRef(({className:e,...t},n)=>O.jsx("div",{ref:n,className:Ee("flex items-center p-6 pt-0",e),...t}));Cw.displayName="CardFooter";function _D({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:f,showAssistant:h,...g}){ke(_=>_.selectedSheetId);const v=ke(_=>_.themeStyle),b=ke(_=>_.isSessionExpired),{isLoading:x,isError:w}=vB({authToken:l,customStyle:t,currentTheme:c,onSave:n,onEvent:r});return x||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?O.jsx(o,{message:"loading"}):O.jsx("div",{className:"flex items-center gap-3",children:O.jsx(im,{className:"h-1 w-full dark:h-[2px]"})})):w?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),O.jsx(i,{})):O.jsx("div",{children:"Error"})):b?(r==null||r({type:"error",message:"Session Expired"}),O.jsx("div",{className:"flex h-full items-center justify-center",children:O.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[O.jsx(Df,{children:"Session Expired"}),O.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):O.jsx("div",{className:Ee("flex h-full flex-col justify-between",v==null?void 0:v.dashboardPanel,e),role:"dashboard-panel",...g})}function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},he.apply(this,arguments)}function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Zn(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:h,children:g,...v}=f,b=(h==null?void 0:h[e][l])||a,x=m.useMemo(()=>v,Object.values(v));return m.createElement(b.Provider,{value:x},g)}function u(f,h){const g=(h==null?void 0:h[e][l])||a,v=m.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>m.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,bB(o,...t)]}function bB(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function yB(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function cs(...e){return t=>e.forEach(n=>yB(n,t))}function _t(...e){return m.useCallback(cs(...e),e)}const M0=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(wB);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(I0,he({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(I0,he({},r,{ref:t}),n)});M0.displayName="Slot";const I0=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{..._B(r,n.props),ref:t?cs(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});I0.displayName="SlotClone";const xB=({children:e})=>m.createElement(m.Fragment,null,e);function wB(e){return m.isValidElement(e)&&e.type===xB}function _B(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function lm(e){const t=e+"CollectionProvider",[n,r]=Zn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:v,children:b}=g,x=m.useRef(null),w=m.useRef(new Map).current;return m.createElement(o,{scope:v,itemMap:w,collectionRef:x},b)},a=e+"CollectionSlot",l=m.forwardRef((g,v)=>{const{scope:b,children:x}=g,w=i(a,b),_=_t(v,w.collectionRef);return m.createElement(M0,{ref:_},x)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",f=m.forwardRef((g,v)=>{const{scope:b,children:x,...w}=g,_=m.useRef(null),S=_t(v,_),R=i(c,b);return m.useEffect(()=>(R.itemMap.set(_,{ref:_,...w}),()=>void R.itemMap.delete(_))),m.createElement(M0,{[u]:"",ref:S},x)});function h(g){const v=i(e+"CollectionConsumer",g);return m.useCallback(()=>{const x=v.collectionRef.current;if(!x)return[];const w=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((R,C)=>w.indexOf(R.ref.current)-w.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},h,r]}const ur=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},SB=V.useId||(()=>{});let CB=0;function Jo(e){const[t,n]=V.useState(SB());return ur(()=>{e||n(r=>r??String(CB++))},[e]),e||(t?`radix-${t}`:"")}const SD=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(RB);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(N0,he({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(N0,he({},r,{ref:t}),n)});SD.displayName="Slot";const N0=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...OB(r,n.props),ref:t?cs(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});N0.displayName="SlotClone";const EB=({children:e})=>m.createElement(m.Fragment,null,e);function RB(e){return m.isValidElement(e)&&e.type===EB}function OB(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const PB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Qe=PB.reduce((e,t)=>{const n=m.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?SD:t;return m.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),m.createElement(a,he({},s,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function CD(e,t){e&&ko.flushSync(()=>e.dispatchEvent(t))}function Ln(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function xr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=TB({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Ln(n),l=m.useCallback(c=>{if(i){const f=typeof c=="function"?c(e):c;f!==e&&a(f)}else o(c)},[i,e,o,a]);return[s,l]}function TB({defaultProp:e,onChange:t}){const n=m.useState(e),[r]=n,o=m.useRef(r),i=Ln(t);return m.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}const DB=m.createContext(void 0);function _l(e){const t=m.useContext(DB);return e||t||"ltr"}const Db="rovingFocusGroup.onEntryFocus",$B={bubbles:!1,cancelable:!0},Ew="RovingFocusGroup",[L0,ED,AB]=lm(Ew),[kB,ou]=Zn(Ew,[AB]),[MB,IB]=kB(Ew),NB=m.forwardRef((e,t)=>m.createElement(L0.Provider,{scope:e.__scopeRovingFocusGroup},m.createElement(L0.Slot,{scope:e.__scopeRovingFocusGroup},m.createElement(LB,he({},e,{ref:t}))))),LB=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,f=m.useRef(null),h=_t(t,f),g=_l(i),[v=null,b]=xr({prop:s,defaultProp:a,onChange:l}),[x,w]=m.useState(!1),_=Ln(c),S=ED(n),R=m.useRef(!1),[C,P]=m.useState(0);return m.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(Db,_),()=>A.removeEventListener(Db,_)},[_]),m.createElement(MB,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>b(A),[b]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>P(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>P(A=>A-1),[])},m.createElement(Qe.div,he({tabIndex:x||C===0?-1:0,"data-orientation":r},u,{ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{R.current=!0}),onFocus:Me(e.onFocus,A=>{const k=!R.current;if(A.target===A.currentTarget&&k&&!x){const D=new CustomEvent(Db,$B);if(A.currentTarget.dispatchEvent(D),!D.defaultPrevented){const I=S().filter(z=>z.focusable),F=I.find(z=>z.active),B=I.find(z=>z.id===v),Z=[F,B,...I].filter(Boolean).map(z=>z.ref.current);RD(Z)}}R.current=!1}),onBlur:Me(e.onBlur,()=>w(!1))})))}),FB="RovingFocusGroupItem",jB=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=Jo(),l=i||a,c=IB(FB,n),u=c.currentTabStopId===l,f=ED(n),{onFocusableItemAdd:h,onFocusableItemRemove:g}=c;return m.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),m.createElement(L0.ItemSlot,{scope:n,id:l,focusable:r,active:o},m.createElement(Qe.span,he({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:Me(e.onMouseDown,v=>{r?c.onItemFocus(l):v.preventDefault()}),onFocus:Me(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:Me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=VB(v,c.orientation,c.dir);if(b!==void 0){v.preventDefault();let w=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const _=w.indexOf(v.currentTarget);w=c.loop?HB(w,_+1):w.slice(_+1)}setTimeout(()=>RD(w))}})})))}),zB={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function BB(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function VB(e,t,n){const r=BB(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return zB[r]}function RD(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function HB(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const Rw=NB,Ow=jB;function WB(e,t){return m.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const er=e=>{const{present:t,children:n}=e,r=UB(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=_t(r.ref,o.ref);return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};er.displayName="Presence";function UB(e){const[t,n]=m.useState(),r=m.useRef({}),o=m.useRef(e),i=m.useRef("none"),s=e?"mounted":"unmounted",[a,l]=WB(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=Uh(r.current);i.current=a==="mounted"?c:"none"},[a]),ur(()=>{const c=r.current,u=o.current;if(u!==e){const h=i.current,g=Uh(c);e?l("MOUNT"):g==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),ur(()=>{if(t){const c=f=>{const g=Uh(r.current).includes(f.animationName);f.target===t&&g&&ko.flushSync(()=>l("ANIMATION_END"))},u=f=>{f.target===t&&(i.current=Uh(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Uh(e){return(e==null?void 0:e.animationName)||"none"}const OD="Tabs",[qB,tye]=Zn(OD,[ou]),PD=ou(),[GB,Pw]=qB(OD),YB=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=_l(a),[f,h]=xr({prop:r,onChange:o,defaultProp:i});return m.createElement(GB,{scope:n,baseId:Jo(),value:f,onValueChange:h,orientation:s,dir:u,activationMode:l},m.createElement(Qe.div,he({dir:u,"data-orientation":s},c,{ref:t})))}),KB="TabsList",XB=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Pw(KB,n),s=PD(n);return m.createElement(Rw,he({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:r}),m.createElement(Qe.div,he({role:"tablist","aria-orientation":i.orientation},o,{ref:t})))}),QB="TabsTrigger",JB=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Pw(QB,n),a=PD(n),l=TD(s.baseId,r),c=DD(s.baseId,r),u=r===s.value;return m.createElement(Ow,he({asChild:!0},a,{focusable:!o,active:u}),m.createElement(Qe.button,he({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Me(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})))}),ZB="TabsContent",eV=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Pw(ZB,n),l=TD(a.baseId,r),c=DD(a.baseId,r),u=r===a.value,f=m.useRef(u);return m.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),m.createElement(er,{present:o||u},({present:h})=>m.createElement(Qe.div,he({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),h&&i))});function TD(e,t){return`${e}-trigger-${t}`}function DD(e,t){return`${e}-content-${t}`}const tV=YB,$D=XB,AD=JB,kD=eV,MD=tV,Tw=V.forwardRef(({className:e,...t},n)=>O.jsx($D,{ref:n,className:Ee("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Tw.displayName=$D.displayName;const Dw=V.forwardRef(({className:e,...t},n)=>O.jsx(AD,{ref:n,className:Ee("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Dw.displayName=AD.displayName;const $w=V.forwardRef(({className:e,...t},n)=>O.jsx(kD,{ref:n,className:Ee("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));$w.displayName=kD.displayName;var ID={exports:{}},$f={},F0={exports:{}};(function(e,t){(function(n,r){r(t)})(Vs,function(n){function r(ie){return function(ae,ye,G,be,_e,Pe,Te){return ie(ae,ye,Te)}}function o(ie){return function(ae,ye,G,be){if(!ae||!ye||typeof ae!="object"||typeof ye!="object")return ie(ae,ye,G,be);var _e=be.get(ae),Pe=be.get(ye);if(_e&&Pe)return _e===ye&&Pe===ae;be.set(ae,ye),be.set(ye,ae);var Te=ie(ae,ye,G,be);return be.delete(ae),be.delete(ye),Te}}function i(ie,te){var ae={};for(var ye in ie)ae[ye]=ie[ye];for(var ye in te)ae[ye]=te[ye];return ae}function s(ie){return ie.constructor===Object||ie.constructor==null}function a(ie){return typeof ie.then=="function"}function l(ie,te){return ie===te||ie!==ie&&te!==te}var c="[object Arguments]",u="[object Boolean]",f="[object Date]",h="[object RegExp]",g="[object Map]",v="[object Number]",b="[object Object]",x="[object Set]",w="[object String]",_=Object.prototype.toString;function S(ie){var te=ie.areArraysEqual,ae=ie.areDatesEqual,ye=ie.areMapsEqual,G=ie.areObjectsEqual,be=ie.areRegExpsEqual,_e=ie.areSetsEqual,Pe=ie.createIsNestedEqual,Te=Pe(Ue);function Ue(Be,Ie,Ke){if(Be===Ie)return!0;if(!Be||!Ie||typeof Be!="object"||typeof Ie!="object")return Be!==Be&&Ie!==Ie;if(s(Be)&&s(Ie))return G(Be,Ie,Te,Ke);var lt=Array.isArray(Be),It=Array.isArray(Ie);if(lt||It)return lt===It&&te(Be,Ie,Te,Ke);var $t=_.call(Be);return $t!==_.call(Ie)?!1:$t===f?ae(Be,Ie,Te,Ke):$t===h?be(Be,Ie,Te,Ke):$t===g?ye(Be,Ie,Te,Ke):$t===x?_e(Be,Ie,Te,Ke):$t===b||$t===c?a(Be)||a(Ie)?!1:G(Be,Ie,Te,Ke):$t===u||$t===v||$t===w?l(Be.valueOf(),Ie.valueOf()):!1}return Ue}function R(ie,te,ae,ye){var G=ie.length;if(te.length!==G)return!1;for(;G-- >0;)if(!ae(ie[G],te[G],G,G,ie,te,ye))return!1;return!0}var C=o(R);function P(ie,te){return l(ie.valueOf(),te.valueOf())}function A(ie,te,ae,ye){var G=ie.size===te.size;if(!G)return!1;if(!ie.size)return!0;var be={},_e=0;return ie.forEach(function(Pe,Te){if(G){var Ue=!1,Be=0;te.forEach(function(Ie,Ke){!Ue&&!be[Be]&&(Ue=ae(Te,Ke,_e,Be,ie,te,ye)&&ae(Pe,Ie,Te,Ke,ie,te,ye))&&(be[Be]=!0),Be++}),_e++,G=Ue}}),G}var k=o(A),D="_owner",I=Object.prototype.hasOwnProperty;function F(ie,te,ae,ye){var G=Object.keys(ie),be=G.length;if(Object.keys(te).length!==be)return!1;for(var _e;be-- >0;){if(_e=G[be],_e===D){var Pe=!!ie.$$typeof,Te=!!te.$$typeof;if((Pe||Te)&&Pe!==Te)return!1}if(!I.call(te,_e)||!ae(ie[_e],te[_e],_e,_e,ie,te,ye))return!1}return!0}var B=o(F);function K(ie,te){return ie.source===te.source&&ie.flags===te.flags}function Z(ie,te,ae,ye){var G=ie.size===te.size;if(!G)return!1;if(!ie.size)return!0;var be={};return ie.forEach(function(_e,Pe){if(G){var Te=!1,Ue=0;te.forEach(function(Be,Ie){!Te&&!be[Ue]&&(Te=ae(_e,Be,Pe,Ie,ie,te,ye))&&(be[Ue]=!0),Ue++}),G=Te}}),G}var z=o(Z),Q=Object.freeze({areArraysEqual:R,areDatesEqual:P,areMapsEqual:A,areObjectsEqual:F,areRegExpsEqual:K,areSetsEqual:Z,createIsNestedEqual:r}),W=Object.freeze({areArraysEqual:C,areDatesEqual:P,areMapsEqual:k,areObjectsEqual:B,areRegExpsEqual:K,areSetsEqual:z,createIsNestedEqual:r}),Y=S(Q);function oe(ie,te){return Y(ie,te,void 0)}var $=S(i(Q,{createIsNestedEqual:function(){return l}}));function H(ie,te){return $(ie,te,void 0)}var J=S(W);function N(ie,te){return J(ie,te,new WeakMap)}var ce=S(i(W,{createIsNestedEqual:function(){return l}}));function le(ie,te){return ce(ie,te,new WeakMap)}function de(ie){return S(i(Q,ie(Q)))}function pe(ie){var te=S(i(W,ie(W)));return function(ae,ye,G){return G===void 0&&(G=new WeakMap),te(ae,ye,G)}}n.circularDeepEqual=N,n.circularShallowEqual=le,n.createCustomCircularEqual=pe,n.createCustomEqual=de,n.deepEqual=oe,n.sameValueZeroEqual=l,n.shallowEqual=H,Object.defineProperty(n,"__esModule",{value:!0})})})(F0,F0.exports);var Aw=F0.exports;const kw=dw(yj);var Ot={},nV=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Ot,"__esModule",{value:!0});Ot.bottom=Mw;Ot.childrenEqual=sV;Ot.cloneLayout=ND;Ot.cloneLayoutItem=il;Ot.collides=cm;Ot.compact=FD;Ot.compactItem=jD;Ot.compactType=xV;Ot.correctBounds=zD;Ot.fastPositionEqual=lV;Ot.fastRGLPropsEqual=void 0;Ot.getAllCollisions=BD;Ot.getFirstCollision=qa;Ot.getLayoutItem=Iw;Ot.getStatics=Nw;Ot.modifyLayout=LD;Ot.moveElement=td;Ot.moveElementAwayFromCollision=z0;Ot.noop=void 0;Ot.perc=uV;Ot.resizeItemInDirection=mV;Ot.setTopLeft=bV;Ot.setTransform=vV;Ot.sortLayoutItems=Vw;Ot.sortLayoutItemsByColRow=qD;Ot.sortLayoutItemsByRowCol=UD;Ot.synchronizeLayoutWithChildren=yV;Ot.validateLayout=GD;Ot.withLayoutItem=iV;var uR=Aw,ed=rV(m);function rV(e){return e&&e.__esModule?e:{default:e}}const oV=process.env.NODE_ENV==="production";function Mw(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function ND(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=il(e[n]);return t}function LD(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function iV(e,t,n){let r=Iw(e,t);return r?(r=n(il(r)),e=LD(e,r),[e,r]):[e,null]}function il(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function sV(e,t){return(0,uR.deepEqual)(ed.default.Children.map(e,n=>n==null?void 0:n.key),ed.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,uR.deepEqual)(ed.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),ed.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}const aV=nV;Ot.fastRGLPropsEqual=aV;function lV(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function cm(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function FD(e,t,n,r){const o=Nw(e),i=Vw(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=il(i[a]);c.static||(c=jD(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const cV={x:"w",y:"h"};function j0(e,t,n,r){const o=cV[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;cm(t,a)&&j0(e,a,n+t[o],r)}}t[r]=n}function jD(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min(Mw(e),t.y);t.y>0&&!qa(e,t);)t.y--;else if(a)for(;t.x>0&&!qa(e,t);)t.x--;let l;for(;(l=qa(e,t))&&!(n===null&&i);)if(a?j0(o,t,l.x+l.w,"x"):j0(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!qa(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function zD(e,t){const n=Nw(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;qa(n,i);)i.y++}return e}function Iw(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function qa(e,t){for(let n=0,r=e.length;n<r;n++)if(cm(e[n],t))return e[n]}function BD(e,t){return e.filter(n=>cm(n,t))}function Nw(e){return e.filter(t=>t.static)}function td(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;"Moving element ".concat(t.i," to [").concat(String(n),",").concat(String(r),"] from [").concat(t.x,",").concat(t.y,"]");const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=Vw(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(f=f.reverse());const g=BD(f,t),v=g.length>0;if(v&&l)return ND(e);if(v&&i)return"Collision prevented on ".concat(t.i,", reverting."),t.x=c,t.y=u,t.moved=!1,e;for(let b=0,x=g.length;b<x;b++){const w=g[b];"Resolving collision between ".concat(t.i," at [").concat(t.x,",").concat(t.y,"] and ").concat(w.i," at [").concat(w.x,",").concat(w.y,"]"),!w.moved&&(w.static?e=z0(e,w,t,o,s):e=z0(e,t,w,o,s))}return e}function z0(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const f={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=qa(e,f),g=h&&h.y+h.h>t.y,v=h&&t.x+t.w>h.x;if(h){if(g&&a)return td(e,n,void 0,t.y+1,r,l,o);if(g&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(v&&s)return td(e,t,n.x,void 0,r,l,o)}else return"Doing reverse collision on ".concat(n.i," up to [").concat(f.x,",").concat(f.y,"]."),td(e,n,s?f.x:void 0,a?f.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:td(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function uV(e){return e*100+"%"}const VD=(e,t,n,r)=>e+n>r?t:n,HD=(e,t,n)=>e<0?t:n,WD=e=>Math.max(0,e),Lw=e=>Math.max(0,e),Fw=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:HD(s,e.height,o),top:Lw(s)}},jw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:VD(e.left,e.width,s,n),left:WD(o)}},zw=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:VD(e.left,e.width,i,n),top:Lw(r),left:WD(s)}},Bw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:HD(r,e.height,i),top:Lw(r)}},dV=function(){return Fw(arguments.length<=0?void 0:arguments[0],jw(...arguments))},fV=function(){return Fw(arguments.length<=0?void 0:arguments[0],zw(...arguments))},hV=function(){return Bw(arguments.length<=0?void 0:arguments[0],jw(...arguments))},pV=function(){return Bw(arguments.length<=0?void 0:arguments[0],zw(...arguments))},gV={n:Fw,ne:dV,e:jw,se:hV,s:Bw,sw:pV,w:zw,nw:fV};function mV(e,t,n,r){const o=gV[e];return o?o(t,{...t,...n},r):n}function vV(e){let{top:t,left:n,width:r,height:o}=e;const i="translate(".concat(n,"px,").concat(t,"px)");return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function bV(e){let{top:t,left:n,width:r,height:o}=e;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Vw(e,t){return t==="horizontal"?qD(e):t==="vertical"?UD(e):e}function UD(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function qD(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function yV(e,t,n,r,o){e=e||[];const i=[];ed.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=Iw(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(il(l)):c?(oV||GD([c],"ReactGridLayout.children"),i.push(il({...c,i:a.key}))):i.push(il({w:1,h:1,x:0,y:Mw(i),i:String(a.key)}))});const s=zD(i,{cols:n});return o?s:FD(s,r,n)}function GD(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++)if(typeof i[n[s]]!="number")throw new Error("ReactGridLayout: "+t+"["+r+"]."+n[s]+" must be a number!")}}function xV(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const wV=()=>{};Ot.noop=wV;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});Ri.calcGridColWidth=um;Ri.calcGridItemPosition=_V;Ri.calcGridItemWHPx=B0;Ri.calcWH=CV;Ri.calcXY=SV;Ri.clamp=Ga;function um(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function B0(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function _V(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=um(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=B0(r,c,s[0]),u.height=B0(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function SV(e,t,n,r,o){const{margin:i,cols:s,rowHeight:a,maxRows:l}=e,c=um(e);let u=Math.round((n-i[0])/(c+i[0])),f=Math.round((t-i[1])/(a+i[1]));return u=Ga(u,0,s-r),f=Ga(f,0,l-o),{x:u,y:f}}function CV(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=um(e);let f=Math.round((t+s[0])/(u+s[0])),h=Math.round((n+s[1])/(c+s[1])),g=Ga(f,0,l-r),v=Ga(h,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(g=Ga(f,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(v=Ga(h,0,a)),{w:g,h:v}}function Ga(e,t,n){return Math.max(Math.min(e,n),t)}var dm={},V0={exports:{}},$b,dR;function Hw(){if(dR)return $b;dR=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return $b=e,$b}var Ab,fR;function EV(){if(fR)return Ab;fR=1;var e=Hw();function t(){}function n(){}return n.resetWarningCache=t,Ab=function(){function r(s,a,l,c,u,f){if(f!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},Ab}var qh={exports:{}},qt={};/** @license React v16.13.1
89
89
  * react-is.development.js
90
90
  *
91
91
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -250,7 +250,7 @@ Valid keys: `+JSON.stringify(Object.keys($),null," "));var G=ye(pe,ae,ce,le,de+
250
250
  * This source code is licensed under the ISC license.
251
251
  * See the LICENSE file in the root directory of this source tree.
252
252
  */const Pm=Dn("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),rQ=({data:e,filename:t="output.csv"})=>{const n=()=>{if(e.length===0)return;const r=[],o=Object.keys(e[0]);r.push(o.join(","));for(const c of e){const u=o.map(f=>`"${(""+c[f]).replace(/"/g,'""')}"`);r.push(u.join(","))}const i=r.join(`
253
- `),s=new Blob([i],{type:"text/csv"}),a=window.URL.createObjectURL(s),l=document.createElement("a");l.setAttribute("hidden",""),l.setAttribute("href",a),l.setAttribute("download",t),document.body.appendChild(l),l.click(),document.body.removeChild(l)};return O.jsx(XX,{onClick:n,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})};function oQ({frame:e}){var _;const t=ke(S=>S.isDashboardEditing),n=ke(S=>S.filterValues),r=ke(S=>S.isVisualEditing),o=ke(S=>S.selectedSheetId);ke(S=>S.currentBreakpoint);const{removeFrame:i}=ke(S=>S.actions),s=ke(S=>S.actions.setIsVisualEditing),a=Ar(S=>S.actions.setFilterValues),l=Ar(S=>S.actions.setApplyFilters),{setCard:c,setFrame:u,setQueryResultColumns:f}=Ar(S=>S.actions),h=Ar(S=>S.actions.setSelectedConnectionId),g=Ar(S=>S.actions.setSelectedDatabaseName),v=Ar(S=>S.actions.setSelectedSchemaName),b=Ar(S=>S.actions.setSelectedTableName),x=e.cards.find(S=>S.id===e.activeCardId);function w(){s(!r),c(x);const{dimensionKeys:S}=ar((x==null?void 0:x.data)||[]);f(S),u(e),x!=null&&x.connectionId&&h(x==null?void 0:x.connectionId),x!=null&&x.lastSelectedDatabase&&g(x==null?void 0:x.lastSelectedDatabase),x!=null&&x.lastSelectedSchema&&v(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&b(x==null?void 0:x.lastSelectedTable),n&&(a(n),l(!0))}return O.jsx("section",{className:"absolute right-2 top-2 z-10",children:O.jsxs("div",{className:"flex items-center gap-2",children:[t&&(r?O.jsx(_X,{onClick:()=>{s(!r)},className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"}):O.jsx(CX,{role:"edit-visual",onClick:w,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})),t&&O.jsx(TA,{onClick:()=>i(o,e.id),className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"}),((_=x.preferences)==null?void 0:_.allowDownload)===!0&&O.jsx(rQ,{data:(x==null?void 0:x.data)||[],filename:x.title})]})})}function iQ(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const px="dismissableLayer.update",sQ="dismissableLayer.pointerDownOutside",aQ="dismissableLayer.focusOutside";let sP;const lQ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ff=m.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=e,u=m.useContext(lQ),[f,h]=m.useState(null),g=(n=f==null?void 0:f.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,v]=m.useState({}),b=_t(t,k=>h(k)),x=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),_=x.indexOf(w),S=f?x.indexOf(f):-1,R=u.layersWithOutsidePointerEventsDisabled.size>0,C=S>=_,P=cQ(k=>{const D=k.target,I=[...u.branches].some(F=>F.contains(D));!C||I||(i==null||i(k),a==null||a(k),k.defaultPrevented||l==null||l())},g),A=uQ(k=>{const D=k.target;[...u.branches].some(F=>F.contains(D))||(s==null||s(k),a==null||a(k),k.defaultPrevented||l==null||l())},g);return iQ(k=>{S===u.layers.size-1&&(o==null||o(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},g),m.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(sP=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),aP(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=sP)}},[f,g,r,u]),m.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),aP())},[f,u]),m.useEffect(()=>{const k=()=>v({});return document.addEventListener(px,k),()=>document.removeEventListener(px,k)},[]),m.createElement(Qe.div,he({},c,{ref:b,style:{pointerEvents:R?C?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,A.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,P.onPointerDownCapture)}))});function cQ(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let c=function(){NA(sQ,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function uQ(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&NA(aQ,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function aP(){const e=new CustomEvent(px);document.dispatchEvent(e)}function NA(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?CD(o,i):o.dispatchEvent(i)}const dQ=["top","right","bottom","left"],ca=Math.min,no=Math.max,Tg=Math.round,mp=Math.floor,ua=e=>({x:e,y:e}),fQ={left:"right",right:"left",bottom:"top",top:"bottom"},hQ={start:"end",end:"start"};function gx(e,t,n){return no(e,ca(t,n))}function ss(e,t){return typeof e=="function"?e(t):e}function as(e){return e.split("-")[0]}function iu(e){return e.split("-")[1]}function R1(e){return e==="x"?"y":"x"}function O1(e){return e==="y"?"height":"width"}function su(e){return["top","bottom"].includes(as(e))?"y":"x"}function P1(e){return R1(su(e))}function pQ(e,t,n){n===void 0&&(n=!1);const r=iu(e),o=P1(e),i=O1(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Dg(s)),[s,Dg(s)]}function gQ(e){const t=Dg(e);return[mx(e),t,mx(t)]}function mx(e){return e.replace(/start|end/g,t=>hQ[t])}function mQ(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function vQ(e,t,n,r){const o=iu(e);let i=mQ(as(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(mx)))),i}function Dg(e){return e.replace(/left|right|bottom|top/g,t=>fQ[t])}function bQ(e){return{top:0,right:0,bottom:0,left:0,...e}}function LA(e){return typeof e!="number"?bQ(e):{top:e,right:e,bottom:e,left:e}}function $g(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function lP(e,t,n){let{reference:r,floating:o}=e;const i=su(t),s=P1(t),a=O1(s),l=as(t),c=i==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let g;switch(l){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-o.width,y:f};break;default:g={x:r.x,y:r.y}}switch(iu(t)){case"start":g[s]-=h*(n&&c?-1:1);break;case"end":g[s]+=h*(n&&c?-1:1);break}return g}const yQ=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=lP(c,r,l),h=r,g={},v=0;for(let b=0;b<a.length;b++){const{name:x,fn:w}=a[b],{x:_,y:S,data:R,reset:C}=await w({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:g,rects:c,platform:s,elements:{reference:e,floating:t}});if(u=_??u,f=S??f,g={...g,[x]:{...g[x],...R}},C&&v<=50){v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(c=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:f}=lP(c,h,l)),b=-1;continue}}return{x:u,y:f,placement:h,strategy:o,middlewareData:g}};async function Fd(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:g=0}=ss(t,e),v=LA(g),x=a[h?f==="floating"?"reference":"floating":f],w=$g(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),_=f==="floating"?{...s.floating,x:r,y:o}:s.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),R=await(i.isElement==null?void 0:i.isElement(S))?await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1}:{x:1,y:1},C=$g(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:_,offsetParent:S,strategy:l}):_);return{top:(w.top-C.top+v.top)/R.y,bottom:(C.bottom-w.bottom+v.bottom)/R.y,left:(w.left-C.left+v.left)/R.x,right:(C.right-w.right+v.right)/R.x}}const cP=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=ss(e,t)||{};if(c==null)return{};const f=LA(u),h={x:n,y:r},g=P1(o),v=O1(g),b=await s.getDimensions(c),x=g==="y",w=x?"top":"left",_=x?"bottom":"right",S=x?"clientHeight":"clientWidth",R=i.reference[v]+i.reference[g]-h[g]-i.floating[v],C=h[g]-i.reference[g],P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let A=P?P[S]:0;(!A||!await(s.isElement==null?void 0:s.isElement(P)))&&(A=a.floating[S]||i.floating[v]);const k=R/2-C/2,D=A/2-b[v]/2-1,I=ca(f[w],D),F=ca(f[_],D),B=I,K=A-b[v]-F,Z=A/2-b[v]/2+k,z=gx(B,Z,K),Q=!l.arrow&&iu(o)!=null&&Z!=z&&i.reference[v]/2-(Z<B?I:F)-b[v]/2<0,W=Q?Z<B?Z-B:Z-K:0;return{[g]:h[g]+W,data:{[g]:z,centerOffset:Z-z-W,...Q&&{alignmentOffset:W}},reset:Q}}}),xQ=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:b=!0,...x}=ss(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=as(o),_=as(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),R=h||(_||!b?[Dg(a)]:gQ(a));!h&&v!=="none"&&R.push(...vQ(a,b,v,S));const C=[a,...R],P=await Fd(t,x),A=[];let k=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&A.push(P[w]),f){const B=pQ(o,s,S);A.push(P[B[0]],P[B[1]])}if(k=[...k,{placement:o,overflows:A}],!A.every(B=>B<=0)){var D,I;const B=(((D=i.flip)==null?void 0:D.index)||0)+1,K=C[B];if(K)return{data:{index:B,overflows:k},reset:{placement:K}};let Z=(I=k.filter(z=>z.overflows[0]<=0).sort((z,Q)=>z.overflows[1]-Q.overflows[1])[0])==null?void 0:I.placement;if(!Z)switch(g){case"bestFit":{var F;const z=(F=k.map(Q=>[Q.placement,Q.overflows.filter(W=>W>0).reduce((W,Y)=>W+Y,0)]).sort((Q,W)=>Q[1]-W[1])[0])==null?void 0:F[0];z&&(Z=z);break}case"initialPlacement":Z=a;break}if(o!==Z)return{reset:{placement:Z}}}return{}}}};function uP(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function dP(e){return dQ.some(t=>e[t]>=0)}const wQ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ss(e,t);switch(r){case"referenceHidden":{const i=await Fd(t,{...o,elementContext:"reference"}),s=uP(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:dP(s)}}}case"escaped":{const i=await Fd(t,{...o,altBoundary:!0}),s=uP(i,n.floating);return{data:{escapedOffsets:s,escaped:dP(s)}}}default:return{}}}}};async function _Q(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=as(n),a=iu(n),l=su(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,f=ss(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof v=="number"&&(g=a==="end"?v*-1:v),l?{x:g*u,y:h*c}:{x:h*c,y:g*u}}const SQ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await _Q(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},CQ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:x=>{let{x:w,y:_}=x;return{x:w,y:_}}},...l}=ss(e,t),c={x:n,y:r},u=await Fd(t,l),f=su(as(o)),h=R1(f);let g=c[h],v=c[f];if(i){const x=h==="y"?"top":"left",w=h==="y"?"bottom":"right",_=g+u[x],S=g-u[w];g=gx(_,g,S)}if(s){const x=f==="y"?"top":"left",w=f==="y"?"bottom":"right",_=v+u[x],S=v-u[w];v=gx(_,v,S)}const b=a.fn({...t,[h]:g,[f]:v});return{...b,data:{x:b.x-n,y:b.y-r}}}}},EQ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=ss(e,t),u={x:n,y:r},f=su(o),h=R1(f);let g=u[h],v=u[f];const b=ss(a,t),x=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(l){const S=h==="y"?"height":"width",R=i.reference[h]-i.floating[S]+x.mainAxis,C=i.reference[h]+i.reference[S]-x.mainAxis;g<R?g=R:g>C&&(g=C)}if(c){var w,_;const S=h==="y"?"width":"height",R=["top","left"].includes(as(o)),C=i.reference[f]-i.floating[S]+(R&&((w=s.offset)==null?void 0:w[f])||0)+(R?0:x.crossAxis),P=i.reference[f]+i.reference[S]+(R?0:((_=s.offset)==null?void 0:_[f])||0)-(R?x.crossAxis:0);v<C?v=C:v>P&&(v=P)}return{[h]:g,[f]:v}}}},RQ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:i}=t,{apply:s=()=>{},...a}=ss(e,t),l=await Fd(t,a),c=as(n),u=iu(n),f=su(n)==="y",{width:h,height:g}=r.floating;let v,b;c==="top"||c==="bottom"?(v=c,b=u===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(b=c,v=u==="end"?"top":"bottom");const x=g-l[v],w=h-l[b],_=!t.middlewareData.shift;let S=x,R=w;if(f){const P=h-l.left-l.right;R=u||_?ca(w,P):P}else{const P=g-l.top-l.bottom;S=u||_?ca(x,P):P}if(_&&!u){const P=no(l.left,0),A=no(l.right,0),k=no(l.top,0),D=no(l.bottom,0);f?R=h-2*(P!==0||A!==0?P+A:no(l.left,l.right)):S=g-2*(k!==0||D!==0?k+D:no(l.top,l.bottom))}await s({...t,availableWidth:R,availableHeight:S});const C=await o.getDimensions(i.floating);return h!==C.width||g!==C.height?{reset:{rects:!0}}:{}}}};function da(e){return FA(e)?(e.nodeName||"").toLowerCase():"#document"}function so(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ds(e){var t;return(t=(FA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function FA(e){return e instanceof Node||e instanceof so(e).Node}function ls(e){return e instanceof Element||e instanceof so(e).Element}function Si(e){return e instanceof HTMLElement||e instanceof so(e).HTMLElement}function fP(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof so(e).ShadowRoot}function jf(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$o(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function OQ(e){return["table","td","th"].includes(da(e))}function T1(e){const t=D1(),n=$o(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function PQ(e){let t=Yc(e);for(;Si(t)&&!Tm(t);){if(T1(t))return t;t=Yc(t)}return null}function D1(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Tm(e){return["html","body","#document"].includes(da(e))}function $o(e){return so(e).getComputedStyle(e)}function Dm(e){return ls(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Yc(e){if(da(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fP(e)&&e.host||ds(e);return fP(t)?t.host:t}function jA(e){const t=Yc(e);return Tm(t)?e.ownerDocument?e.ownerDocument.body:e.body:Si(t)&&jf(t)?t:jA(t)}function jd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=jA(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=so(o);return i?t.concat(s,s.visualViewport||[],jf(o)?o:[],s.frameElement&&n?jd(s.frameElement):[]):t.concat(o,jd(o,[],n))}function zA(e){const t=$o(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Si(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Tg(n)!==i||Tg(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function $1(e){return ls(e)?e:e.contextElement}function yc(e){const t=$1(e);if(!Si(t))return ua(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=zA(t);let s=(i?Tg(n.width):n.width)/r,a=(i?Tg(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const TQ=ua(0);function BA(e){const t=so(e);return!D1()||!t.visualViewport?TQ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function DQ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==so(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=$1(e);let s=ua(1);t&&(r?ls(r)&&(s=yc(r)):s=yc(e));const a=DQ(i,n,r)?BA(i):ua(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,f=o.height/s.y;if(i){const h=so(i),g=r&&ls(r)?so(r):r;let v=h.frameElement;for(;v&&r&&g!==h;){const b=yc(v),x=v.getBoundingClientRect(),w=$o(v),_=x.left+(v.clientLeft+parseFloat(w.paddingLeft))*b.x,S=x.top+(v.clientTop+parseFloat(w.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=_,c+=S,v=so(v).frameElement}}return $g({width:u,height:f,x:l,y:c})}function $Q(e){let{rect:t,offsetParent:n,strategy:r}=e;const o=Si(n),i=ds(n);if(n===i)return t;let s={scrollLeft:0,scrollTop:0},a=ua(1);const l=ua(0);if((o||!o&&r!=="fixed")&&((da(n)!=="body"||jf(i))&&(s=Dm(n)),Si(n))){const c=ml(n);a=yc(n),l.x=c.x+n.clientLeft,l.y=c.y+n.clientTop}return{width:t.width*a.x,height:t.height*a.y,x:t.x*a.x-s.scrollLeft*a.x+l.x,y:t.y*a.y-s.scrollTop*a.y+l.y}}function AQ(e){return Array.from(e.getClientRects())}function VA(e){return ml(ds(e)).left+Dm(e).scrollLeft}function kQ(e){const t=ds(e),n=Dm(e),r=e.ownerDocument.body,o=no(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=no(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+VA(e);const a=-n.scrollTop;return $o(r).direction==="rtl"&&(s+=no(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function MQ(e,t){const n=so(e),r=ds(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=D1();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function IQ(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Si(e)?yc(e):ua(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function hP(e,t,n){let r;if(t==="viewport")r=MQ(e,n);else if(t==="document")r=kQ(ds(e));else if(ls(t))r=IQ(t,n);else{const o=BA(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return $g(r)}function HA(e,t){const n=Yc(e);return n===t||!ls(n)||Tm(n)?!1:$o(n).position==="fixed"||HA(n,t)}function NQ(e,t){const n=t.get(e);if(n)return n;let r=jd(e,[],!1).filter(a=>ls(a)&&da(a)!=="body"),o=null;const i=$o(e).position==="fixed";let s=i?Yc(e):e;for(;ls(s)&&!Tm(s);){const a=$o(s),l=T1(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||jf(s)&&!l&&HA(e,s))?r=r.filter(u=>u!==s):o=a,s=Yc(s)}return t.set(e,r),r}function LQ(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?NQ(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const f=hP(t,u,o);return c.top=no(f.top,c.top),c.right=ca(f.right,c.right),c.bottom=ca(f.bottom,c.bottom),c.left=no(f.left,c.left),c},hP(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function FQ(e){return zA(e)}function jQ(e,t,n){const r=Si(t),o=ds(t),i=n==="fixed",s=ml(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=ua(0);if(r||!r&&!i)if((da(t)!=="body"||jf(o))&&(a=Dm(t)),r){const c=ml(t,!0,i,t);l.x=c.x+t.clientLeft,l.y=c.y+t.clientTop}else o&&(l.x=VA(o));return{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function pP(e,t){return!Si(e)||$o(e).position==="fixed"?null:t?t(e):e.offsetParent}function WA(e,t){const n=so(e);if(!Si(e))return n;let r=pP(e,t);for(;r&&OQ(r)&&$o(r).position==="static";)r=pP(r,t);return r&&(da(r)==="html"||da(r)==="body"&&$o(r).position==="static"&&!T1(r))?n:r||PQ(e)||n}const zQ=async function(e){let{reference:t,floating:n,strategy:r}=e;const o=this.getOffsetParent||WA,i=this.getDimensions;return{reference:jQ(t,await o(n),r),floating:{x:0,y:0,...await i(n)}}};function BQ(e){return $o(e).direction==="rtl"}const VQ={convertOffsetParentRelativeRectToViewportRelativeRect:$Q,getDocumentElement:ds,getClippingRect:LQ,getOffsetParent:WA,getElementRects:zQ,getClientRects:AQ,getDimensions:FQ,getScale:yc,isElement:ls,isRTL:BQ};function HQ(e,t){let n=null,r;const o=ds(e);function i(){clearTimeout(r),n&&n.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:f,height:h}=e.getBoundingClientRect();if(a||t(),!f||!h)return;const g=mp(u),v=mp(o.clientWidth-(c+f)),b=mp(o.clientHeight-(u+h)),x=mp(c),_={rootMargin:-g+"px "+-v+"px "+-b+"px "+-x+"px",threshold:no(0,ca(1,l))||1};let S=!0;function R(C){const P=C[0].intersectionRatio;if(P!==l){if(!S)return s();P?s(!1,P):r=setTimeout(()=>{s(!1,1e-7)},100)}S=!1}try{n=new IntersectionObserver(R,{..._,root:o.ownerDocument})}catch{n=new IntersectionObserver(R,_)}n.observe(e)}return s(!0),i}function WQ(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=$1(e),u=o||i?[...c?jd(c):[],...jd(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const f=c&&a?HQ(c,n):null;let h=-1,g=null;s&&(g=new ResizeObserver(w=>{let[_]=w;_&&_.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{g&&g.observe(t)})),n()}),c&&!l&&g.observe(c),g.observe(t));let v,b=l?ml(e):null;l&&x();function x(){const w=ml(e);b&&(w.x!==b.x||w.y!==b.y||w.width!==b.width||w.height!==b.height)&&n(),b=w,v=requestAnimationFrame(x)}return n(),()=>{u.forEach(w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),f&&f(),g&&g.disconnect(),g=null,l&&cancelAnimationFrame(v)}}const UQ=(e,t,n)=>{const r=new Map,o={platform:VQ,...n},i={...o.platform,_c:r};return yQ(e,t,{...o,platform:i})},qQ=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?cP({element:r.current,padding:o}).fn(n):{}:r?cP({element:r,padding:o}).fn(n):{}}}};var og=typeof document<"u"?m.useLayoutEffect:m.useEffect;function Ag(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Ag(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ag(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function UA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gP(e,t){const n=UA(e);return Math.round(t*n)/n}function mP(e){const t=V.useRef(e);return og(()=>{t.current=e}),t}function GQ(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,f]=V.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=V.useState(r);Ag(h,r)||g(r);const[v,b]=V.useState(null),[x,w]=V.useState(null),_=V.useCallback(Q=>{Q!=P.current&&(P.current=Q,b(Q))},[b]),S=V.useCallback(Q=>{Q!==A.current&&(A.current=Q,w(Q))},[w]),R=i||v,C=s||x,P=V.useRef(null),A=V.useRef(null),k=V.useRef(u),D=mP(l),I=mP(o),F=V.useCallback(()=>{if(!P.current||!A.current)return;const Q={placement:t,strategy:n,middleware:h};I.current&&(Q.platform=I.current),UQ(P.current,A.current,Q).then(W=>{const Y={...W,isPositioned:!0};B.current&&!Ag(k.current,Y)&&(k.current=Y,uw.flushSync(()=>{f(Y)}))})},[h,t,n,I]);og(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,f(Q=>({...Q,isPositioned:!1})))},[c]);const B=V.useRef(!1);og(()=>(B.current=!0,()=>{B.current=!1}),[]),og(()=>{if(R&&(P.current=R),C&&(A.current=C),R&&C){if(D.current)return D.current(R,C,F);F()}},[R,C,F,D]);const K=V.useMemo(()=>({reference:P,floating:A,setReference:_,setFloating:S}),[_,S]),Z=V.useMemo(()=>({reference:R,floating:C}),[R,C]),z=V.useMemo(()=>{const Q={position:n,left:0,top:0};if(!Z.floating)return Q;const W=gP(Z.floating,u.x),Y=gP(Z.floating,u.y);return a?{...Q,transform:"translate("+W+"px, "+Y+"px)",...UA(Z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:Y}},[n,a,Z.floating,u.x,u.y]);return V.useMemo(()=>({...u,update:F,refs:K,elements:Z,floatingStyles:z}),[u,F,K,Z,z])}function $m(e){const[t,n]=m.useState(void 0);return ur(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const qA="Popper",[GA,Ti]=Zn(qA),[YQ,YA]=GA(qA),KQ=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return m.createElement(YQ,{scope:t,anchor:r,onAnchorChange:o},n)},XQ="PopperAnchor",QQ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=YA(XQ,n),s=m.useRef(null),a=_t(t,s);return m.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:m.createElement(Qe.div,he({},o,{ref:a}))}),KA="PopperContent",[JQ,aye]=GA(KA),ZQ=m.forwardRef((e,t)=>{var n,r,o,i,s,a,l,c;const{__scopePopper:u,side:f="bottom",sideOffset:h=0,align:g="center",alignOffset:v=0,arrowPadding:b=0,avoidCollisions:x=!0,collisionBoundary:w=[],collisionPadding:_=0,sticky:S="partial",hideWhenDetached:R=!1,updatePositionStrategy:C="optimized",onPlaced:P,...A}=e,k=YA(KA,u),[D,I]=m.useState(null),F=_t(t,Pe=>I(Pe)),[B,K]=m.useState(null),Z=$m(B),z=(n=Z==null?void 0:Z.width)!==null&&n!==void 0?n:0,Q=(r=Z==null?void 0:Z.height)!==null&&r!==void 0?r:0,W=f+(g!=="center"?"-"+g:""),Y=typeof _=="number"?_:{top:0,right:0,bottom:0,left:0,..._},oe=Array.isArray(w)?w:[w],$=oe.length>0,H={padding:Y,boundary:oe.filter(eJ),altBoundary:$},{refs:J,floatingStyles:N,placement:ce,isPositioned:le,middlewareData:de}=GQ({strategy:"fixed",placement:W,whileElementsMounted:(...Pe)=>WQ(...Pe,{animationFrame:C==="always"}),elements:{reference:k.anchor},middleware:[SQ({mainAxis:h+Q,alignmentAxis:v}),x&&CQ({mainAxis:!0,crossAxis:!1,limiter:S==="partial"?EQ():void 0,...H}),x&&xQ({...H}),RQ({...H,apply:({elements:Pe,rects:Te,availableWidth:Ue,availableHeight:Be})=>{const{width:Ie,height:Ke}=Te.reference,lt=Pe.floating.style;lt.setProperty("--radix-popper-available-width",`${Ue}px`),lt.setProperty("--radix-popper-available-height",`${Be}px`),lt.setProperty("--radix-popper-anchor-width",`${Ie}px`),lt.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),B&&qQ({element:B,padding:b}),tJ({arrowWidth:z,arrowHeight:Q}),R&&wQ({strategy:"referenceHidden",...H})]}),[pe,ie]=XA(ce),te=Ln(P);ur(()=>{le&&(te==null||te())},[le,te]);const ae=(o=de.arrow)===null||o===void 0?void 0:o.x,ye=(i=de.arrow)===null||i===void 0?void 0:i.y,G=((s=de.arrow)===null||s===void 0?void 0:s.centerOffset)!==0,[be,_e]=m.useState();return ur(()=>{D&&_e(window.getComputedStyle(D).zIndex)},[D]),m.createElement("div",{ref:J.setFloating,"data-radix-popper-content-wrapper":"",style:{...N,transform:le?N.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(a=de.transformOrigin)===null||a===void 0?void 0:a.x,(l=de.transformOrigin)===null||l===void 0?void 0:l.y].join(" ")},dir:e.dir},m.createElement(JQ,{scope:u,placedSide:pe,onArrowChange:K,arrowX:ae,arrowY:ye,shouldHideArrow:G},m.createElement(Qe.div,he({"data-side":pe,"data-align":ie},A,{ref:F,style:{...A.style,animation:le?void 0:"none",opacity:(c=de.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))});function eJ(e){return e!==null}const tJ=e=>({name:"transformOrigin",options:e,fn(t){var n,r,o,i,s;const{placement:a,rects:l,middlewareData:c}=t,f=((n=c.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,h=f?0:e.arrowWidth,g=f?0:e.arrowHeight,[v,b]=XA(a),x={start:"0%",center:"50%",end:"100%"}[b],w=((r=(o=c.arrow)===null||o===void 0?void 0:o.x)!==null&&r!==void 0?r:0)+h/2,_=((i=(s=c.arrow)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0)+g/2;let S="",R="";return v==="bottom"?(S=f?x:`${w}px`,R=`${-g}px`):v==="top"?(S=f?x:`${w}px`,R=`${l.floating.height+g}px`):v==="right"?(S=`${-g}px`,R=f?x:`${_}px`):v==="left"&&(S=`${l.floating.width+g}px`,R=f?x:`${_}px`),{data:{x:S,y:R}}}});function XA(e){const[t,n="center"]=e.split("-");return[t,n]}const zf=KQ,Bf=QQ,Vf=ZQ,A1=m.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...o}=e;return r?ko.createPortal(m.createElement(Qe.div,he({},o,{ref:t})),r):null}),nJ=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(rJ);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(vx,he({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(vx,he({},r,{ref:t}),n)});nJ.displayName="Slot";const vx=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...oJ(r,n.props),ref:t?cs(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});vx.displayName="SlotClone";const QA=({children:e})=>m.createElement(m.Fragment,null,e);function rJ(e){return m.isValidElement(e)&&e.type===QA}function oJ(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const JA=m.forwardRef((e,t)=>m.createElement(Qe.span,he({},e,{ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}))),iJ=JA,[Am,lye]=Zn("Tooltip",[Ti]),k1=Ti(),sJ="TooltipProvider",aJ=700,bx="tooltip.open",[lJ,M1]=Am(sJ),cJ=e=>{const{__scopeTooltip:t,delayDuration:n=aJ,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,[s,a]=m.useState(!0),l=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),m.createElement(lJ,{scope:t,isOpenDelayed:s,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:m.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(u=>{l.current=u},[]),disableHoverableContent:o},i)},I1="Tooltip",[uJ,km]=Am(I1),dJ=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:i,disableHoverableContent:s,delayDuration:a}=e,l=M1(I1,e.__scopeTooltip),c=k1(t),[u,f]=m.useState(null),h=Jo(),g=m.useRef(0),v=s??l.disableHoverableContent,b=a??l.delayDuration,x=m.useRef(!1),[w=!1,_]=xr({prop:r,defaultProp:o,onChange:A=>{A?(l.onOpen(),document.dispatchEvent(new CustomEvent(bx))):l.onClose(),i==null||i(A)}}),S=m.useMemo(()=>w?x.current?"delayed-open":"instant-open":"closed",[w]),R=m.useCallback(()=>{window.clearTimeout(g.current),x.current=!1,_(!0)},[_]),C=m.useCallback(()=>{window.clearTimeout(g.current),_(!1)},[_]),P=m.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{x.current=!0,_(!0)},b)},[b,_]);return m.useEffect(()=>()=>window.clearTimeout(g.current),[]),m.createElement(zf,c,m.createElement(uJ,{scope:t,contentId:h,open:w,stateAttribute:S,trigger:u,onTriggerChange:f,onTriggerEnter:m.useCallback(()=>{l.isOpenDelayed?P():R()},[l.isOpenDelayed,P,R]),onTriggerLeave:m.useCallback(()=>{v?C():window.clearTimeout(g.current)},[C,v]),onOpen:R,onClose:C,disableHoverableContent:v},n))},vP="TooltipTrigger",ZA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=km(vP,n),i=M1(vP,n),s=k1(n),a=m.useRef(null),l=_t(t,a,o.onTriggerChange),c=m.useRef(!1),u=m.useRef(!1),f=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),m.createElement(Bf,he({asChild:!0},s),m.createElement(Qe.button,he({"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute},r,{ref:l,onPointerMove:Me(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:Me(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:Me(e.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Me(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:Me(e.onBlur,o.onClose),onClick:Me(e.onClick,o.onClose)})))}),fJ="TooltipPortal",[cye,hJ]=Am(fJ,{forceMount:void 0}),zd="TooltipContent",pJ=m.forwardRef((e,t)=>{const n=hJ(zd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=km(zd,e.__scopeTooltip);return m.createElement(er,{present:r||s.open},s.disableHoverableContent?m.createElement(ek,he({side:o},i,{ref:t})):m.createElement(gJ,he({side:o},i,{ref:t})))}),gJ=m.forwardRef((e,t)=>{const n=km(zd,e.__scopeTooltip),r=M1(zd,e.__scopeTooltip),o=m.useRef(null),i=_t(t,o),[s,a]=m.useState(null),{trigger:l,onClose:c}=n,u=o.current,{onPointerInTransitChange:f}=r,h=m.useCallback(()=>{a(null),f(!1)},[f]),g=m.useCallback((v,b)=>{const x=v.currentTarget,w={x:v.clientX,y:v.clientY},_=vJ(w,x.getBoundingClientRect()),S=bJ(w,_),R=yJ(b.getBoundingClientRect()),C=wJ([...S,...R]);a(C),f(!0)},[f]);return m.useEffect(()=>()=>h(),[h]),m.useEffect(()=>{if(l&&u){const v=x=>g(x,u),b=x=>g(x,l);return l.addEventListener("pointerleave",v),u.addEventListener("pointerleave",b),()=>{l.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",b)}}},[l,u,g,h]),m.useEffect(()=>{if(s){const v=b=>{const x=b.target,w={x:b.clientX,y:b.clientY},_=(l==null?void 0:l.contains(x))||(u==null?void 0:u.contains(x)),S=!xJ(w,s);_?h():S&&(h(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,u,s,c,h]),m.createElement(ek,he({},e,{ref:i}))}),[mJ,uye]=Am(I1,{isInside:!1}),ek=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...a}=e,l=km(zd,n),c=k1(n),{onClose:u}=l;return m.useEffect(()=>(document.addEventListener(bx,u),()=>document.removeEventListener(bx,u)),[u]),m.useEffect(()=>{if(l.trigger){const f=h=>{const g=h.target;g!=null&&g.contains(l.trigger)&&u()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,u]),m.createElement(Ff,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:f=>f.preventDefault(),onDismiss:u},m.createElement(Vf,he({"data-state":l.stateAttribute},c,a,{ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"}}),m.createElement(QA,null,r),m.createElement(mJ,{scope:n,isInside:!0},m.createElement(iJ,{id:l.contentId,role:"tooltip"},o||r))))});function vJ(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function bJ(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function yJ(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function xJ(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i].x,l=t[i].y,c=t[s].x,u=t[s].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(o=!o)}return o}function wJ(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),_J(t)}function _J(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const SJ=cJ,CJ=dJ,EJ=ZA,tk=pJ,RJ=SJ,nk=CJ,rk=EJ,N1=V.forwardRef(({className:e,sideOffset:t=4,...n},r)=>O.jsx(tk,{ref:r,sideOffset:t,className:Ee("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));N1.displayName=tk.displayName;function ll({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:i="en-US"}){let s=1,a=r,l=i;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&i==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&i==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,f={maximumFractionDigits:c,minimumFractionDigits:c};if(o){f.style="currency",f.currency=o;try{new Intl.NumberFormat(i,f).format(0)}catch{f.currency="USD"}}try{new Intl.NumberFormat(i,f).format(0)}catch{l="en-US"}let g=new Intl.NumberFormat(l,f).format(u);return n&&(g+=a),g}function ok(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function ik({card:e,isLoading:t}){var w,_,S,R,C,P,A,k,D,I,F,B,K,Z,z,Q,W,Y,oe,$,H,J,N,ce;const n=ke(le=>le.actions.setCardTitle),r=ke(le=>le.actions.setCardDescription),o=ke(le=>le.isVisualEditing),i=Ar(le=>le.card),s=Ar(le=>le.actions.setCard);Ar(le=>le.actions.setNumberFormat);const a=ke(le=>le.selectedSheetId),l=e.data,c=(_=(w=e.preferences)==null?void 0:w.formatNumber)==null?void 0:_.colorRanges,{metricKeys:u}=ar(l||[]),f=(S=l==null?void 0:l[0])==null?void 0:S[u==null?void 0:u[0]],h=(R=l==null?void 0:l[0])==null?void 0:R[u==null?void 0:u[1]],g=!!e.data&&e.data.length>0;function v(le){o?s({...i,title:le}):n(a,e.id,le)}function b(le){o?s({...i,description:le}):r(a,e.id,le)}const x=h&&h-f!==0?(f-h)/h:null;return O.jsxs("div",{className:"kpi-card flex grow flex-col overflow-scroll",children:[O.jsxs(sm,{className:"grow pb-3",children:[O.jsx(is,{text:o?i.title:e.title,onSave:v,children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx(Df,{className:"text-base font-medium text-muted-foreground",children:e.title}),!e.refreshInterval&&t&&O.jsx(S1,{className:"h-4 w-4 animate-spin text-muted-foreground"})]})}),g&&O.jsxs("div",{className:"flex flex-wrap items-end gap-3 text-foreground",children:[O.jsx("p",{style:{color:ok(f,c)},className:"text-3xl font-semibold",children:ll({number:f,decimalPlaces:((P=(C=e.preferences)==null?void 0:C.formatNumber)==null?void 0:P.decimalPlaces)||0,useSuffix:!!((k=(A=e.preferences)==null?void 0:A.formatNumber)!=null&&k.suffix),customSuffix:((I=(D=e.preferences)==null?void 0:D.formatNumber)==null?void 0:I.suffix)||"",locale:((B=(F=e.preferences)==null?void 0:F.formatNumber)==null?void 0:B.locale)||"",currency:((Z=(K=e.preferences)==null?void 0:K.formatNumber)==null?void 0:Z.currency)||""})}),h&&O.jsxs("span",{className:"min-w-fit text-base font-normal text-muted-foreground",children:["from  ",ll({number:h,decimalPlaces:((Q=(z=e.preferences)==null?void 0:z.formatNumber)==null?void 0:Q.decimalPlaces)||0,useSuffix:!!((Y=(W=e.preferences)==null?void 0:W.formatNumber)!=null&&Y.suffix),customSuffix:(($=(oe=e.preferences)==null?void 0:oe.formatNumber)==null?void 0:$.suffix)||"",locale:((J=(H=e.preferences)==null?void 0:H.formatNumber)==null?void 0:J.locale)||"",currency:((ce=(N=e.preferences)==null?void 0:N.formatNumber)==null?void 0:ce.currency)||""})]})]})]}),x&&O.jsxs(am,{className:"grow items-start gap-1 pb-4 text-sm",children:[O.jsx(OJ,{children:x}),O.jsxs("div",{className:"flex gap-1 text-muted-foreground",children:[x>0?"up ":"down ",O.jsx(is,{text:e.description||"",onSave:b,children:e.description})]})]})]})}function OJ({children:e}){const t=e>0?O.jsx(w1,{className:"h-4 w-4"}):O.jsx(x1,{className:"h-4 w-4"}),n=`${Math.abs(e*100).toFixed(0)}%`;return O.jsxs("div",{className:Ee("flex items-center",{"text-green-600":e>0,"text-destructive":e<0}),children:[t,O.jsx("span",{className:"ml-[1px]",children:n})]})}var Kc=1e3,Xc=Kc*60,Qc=Xc*60,vl=Qc*24,PJ=vl*7,TJ=vl*365.25,DJ=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return $J(e);if(n==="number"&&isFinite(e))return t.long?kJ(e):AJ(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function $J(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*TJ;case"weeks":case"week":case"w":return n*PJ;case"days":case"day":case"d":return n*vl;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Qc;case"minutes":case"minute":case"mins":case"min":case"m":return n*Xc;case"seconds":case"second":case"secs":case"sec":case"s":return n*Kc;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function AJ(e){var t=Math.abs(e);return t>=vl?Math.round(e/vl)+"d":t>=Qc?Math.round(e/Qc)+"h":t>=Xc?Math.round(e/Xc)+"m":t>=Kc?Math.round(e/Kc)+"s":e+"ms"}function kJ(e){var t=Math.abs(e);return t>=vl?vp(e,t,vl,"day"):t>=Qc?vp(e,t,Qc,"hour"):t>=Xc?vp(e,t,Xc,"minute"):t>=Kc?vp(e,t,Kc,"second"):e+" ms"}function vp(e,t,n,r){var o=t>=n*1.5;return Math.round(e/n)+" "+r+(o?"s":"")}const MJ=nu(DJ);function sk({children:e}){const{setIsSessionExpired:t}=Mo(),n=new Qz({queryCache:new pD({onError:r=>{console.error(`Something went wrong: ${r.message}`),r.message==="invalid token"&&t(!0)}}),defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});return O.jsx(tB,{client:n,children:e})}const IJ={id:"",authToken:void 0},ak=m.createContext(IJ),lk=({children:e,dashboardProps:t})=>O.jsx(sk,{children:O.jsx(ak.Provider,{value:t,children:e})});function ma(){const e=m.useContext(ak);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}function NJ(e){ke(u=>u.bookmarkKey),ke(u=>u.selectedSheetId);const t=ke(u=>u.dashboard.baseQueries),n=ke(u=>u.actions.getCardSheet),{authToken:r}=ma(),o=ke(u=>u.authToken),i=ke(u=>u.filterValues),s=ke(u=>u.isDashboardEditing),a=MJ((e==null?void 0:e.refreshInterval)||"0");n(e.id);const l=Y2(e.sql,t);return Tf({queryKey:[e.id,l],queryFn:()=>Rf("https://semaphor.cloud/api/v1/query",(r==null?void 0:r.accessToken)||(o==null?void 0:o.accessToken)||"",{connection_id:e.connectionId,sql:l,python:e.python===aD?"":e.python,active_filters:i}),refetchInterval:a,enabled:!!e.connectionId&&!s})}function Ia({data:e,cfg:t,customCfg:n,preferences:r}){const{dimensionKeys:o,metricKeys:i}=ar(e),s=zX(i,e,r),a=rg(s,n),l=o[0],c=fx(e,l);L1(r,t),ck(r);const u=uk(t,r),f=qo((t==null?void 0:t.options)||{},r==null?void 0:r.chartOptions),h=qo(u,f),g=qo(h,(n==null?void 0:n.options)||{});return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:c,datasets:a},options:g}}function L1(e,t){var o,i,s;const n=((o=t==null?void 0:t.options)==null?void 0:o.indexAxis)==="y"?"x":"y";return(i=e==null?void 0:e.chartOptions)!=null&&i.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function ck(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function uk(e,t){var i,s,a,l,c,u,f,h,g,v,b,x;const n=L1(t,e),r=ck(t);return{...e==null?void 0:e.options,scales:{...(i=e==null?void 0:e.options)==null?void 0:i.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:w=>{var _,S,R,C;return ll({number:Number(w),decimalPlaces:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}},[r]:{...(g=(h=(f=e==null?void 0:e.options)==null?void 0:f.scales)==null?void 0:h[r])==null?void 0:g.ticks,callback:null}},plugins:{...(v=e==null?void 0:e.options)==null?void 0:v.plugins,datalabels:{...(x=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:x.datalabels,formatter:function(w){var _,S,R,C;return ll({number:Number(w),decimalPlaces:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}}}}function LJ(e){return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0},y:{display:!0}}}}}function FJ(e){return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{beginAtZero:!0,stack:1,reverse:!0},y:{stacked:!0,beginAtZero:!0}}}}}function jJ(e){return{...e,type:"bar",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}}}}}function zJ(e,t=!1){return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0,beginAtZero:!1},y:{display:!0,stacked:t}}}}}function BJ(e,t){var r,o,i,s;return{...e,type:t==="stackedBar"?"bar":"line",options:{...e==null?void 0:e.options,scales:{x:{...(o=(r=e==null?void 0:e.options)==null?void 0:r.scales)==null?void 0:o.x,display:!0,stacked:!0},y:{...(s=(i=e==null?void 0:e.options)==null?void 0:i.scales)==null?void 0:s.y,display:!0,stacked:!0}}}}}function VJ(e){return{...e,type:"line",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}}}}}function HJ(e,t){var r;return{...t,type:e,options:{...t==null?void 0:t.options,scales:{x:{display:!1},y:{display:!1}},plugins:{...(r=t==null?void 0:t.options)==null?void 0:r.plugins,legend:{position:"top",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},borderRadius:0}}}function WJ(e){return{...e,type:"radar",options:{...e==null?void 0:e.options,scales:{x:{display:!1},y:{display:!1}}}}}function UJ(e){const n=new Function("getDatalabelColor",e)(w0);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}function F1({data:e,cardType:t="bar",cfg:n,customCfg:r,provider:o="chartjs",userSettings:i,preferences:s}){var a,l,c;if(t==="bar"){const u=jJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="horizontalBar"){const u=LJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="pyramid"){const u=FJ(n),{dimensionKeys:f,metricKeys:h}=ar(e),g=Pg({dataArray:e,groupKey:f[0],pivotKey:f[1],valueKey:h[0]}),v=Ia({data:g,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s}),b="x2";return{...v,data:{...v.data,datasets:v.data.datasets.map((w,_)=>_===1?{...w,xAxisID:b}:w)},options:{...v.options,scales:{...(a=v==null?void 0:v.options)==null?void 0:a.scales,[b]:{beginAtZero:!0,stack:1}}}}}if(t==="stackedBar"||t==="stackedLine"){const u=BJ(n,t),{dimensionKeys:f,metricKeys:h}=ar(e),g=Pg({dataArray:e,groupKey:f[0],pivotKey:f[1],valueKey:h[0]});return Ia({data:g,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="line"){const u=VJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="range"){const u=zJ(n),f=HX(e),h=rg(f,r),{plugins:g,options:v}=UJ((s==null?void 0:s.customVisualCode)||""),b=qo((u==null?void 0:u.options)||{},(n==null?void 0:n.options)||{}),x=qo(b,(s==null?void 0:s.chartOptions)||{}),w=qo(x,(r==null?void 0:r.options)||{}),_=qo(w,v),S=uk(n,s),R=qo(_,S),C={...R,plugins:{...R==null?void 0:R.plugins,datalabels:{...(l=R==null?void 0:R.plugins)==null?void 0:l.datalabels,formatter:(I,F)=>I.map(K=>{var Z,z,Q,W;return ll({number:Number(K),decimalPlaces:((Z=s==null?void 0:s.numberAxisFormat)==null?void 0:Z.decimalPlaces)||0,useSuffix:!!((z=s==null?void 0:s.numberAxisFormat)!=null&&z.suffix),customSuffix:"",locale:((Q=s==null?void 0:s.numberAxisFormat)==null?void 0:Q.locale)||"",currency:((W=s==null?void 0:s.numberAxisFormat)==null?void 0:W.currency)||""})}).slice(0,2).join(" - ")}}},{dimensionKeys:P}=ar(e),A=P[0];return{type:"bar",data:{labels:[...new Set(fx(e,A))],datasets:h},options:C,plugins:[...g]}}if(t==="pie"||t==="doughnut"||t==="polarArea"){const u=HJ(t,n),{dimensionKeys:f,metricKeys:h}=ar(e),g=WX(h,e),v=rg(g,r),b=f[0],x=fx(e,b),w=qo((u==null?void 0:u.options)||{},(r==null?void 0:r.options)||{}),_=qo(w,(s==null?void 0:s.chartOptions)||{}),S={..._,plugins:{..._.plugins,datalabels:{...(c=_.plugins)==null?void 0:c.datalabels,formatter:(P,A)=>{var k,D,I,F;return ll({number:Number(P),decimalPlaces:((k=s==null?void 0:s.numberAxisFormat)==null?void 0:k.decimalPlaces)||0,useSuffix:!!((D=s==null?void 0:s.numberAxisFormat)!=null&&D.suffix),customSuffix:"",locale:((I=s==null?void 0:s.numberAxisFormat)==null?void 0:I.locale)||"",currency:((F=s==null?void 0:s.numberAxisFormat)==null?void 0:F.currency)||""})}}}};return{type:t,data:{labels:x,datasets:v},options:S,plugins:[t==="doughnut"?{id:"doughnutLabel",beforeDatasetsDraw:function(P,A,k){var Q,W,Y,oe;const{ctx:D,data:I}=P;D.save();const F=P.getDatasetMeta(0).data[0].x,B=P.getDatasetMeta(0).data[0].y,K=Bc(Od());D.font="1.2rem Arial",D.fontWeight="bolder",D.fillStyle=K,D.textAlign="center",D.textBaseline="middle";const Z=I.datasets[0].data.reduce(($,H)=>$+H,0),z=ll({number:Number(Z),decimalPlaces:((Q=s==null?void 0:s.numberAxisFormat)==null?void 0:Q.decimalPlaces)||0,useSuffix:!!((W=s==null?void 0:s.numberAxisFormat)!=null&&W.suffix),customSuffix:"",locale:((Y=s==null?void 0:s.numberAxisFormat)==null?void 0:Y.locale)||"",currency:((oe=s==null?void 0:s.numberAxisFormat)==null?void 0:oe.currency)||""});D.fillText(z,F,B)}}:""]}}if(t==="radar"){const u=WJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="bubble"||t==="scatter"){const{metricKeys:u}=ar(e);if(u.length<3){console.log("Bubble charts require 3 numeric columns");return}const f=VX(e),h=rg(f,r),g={plugins:{datalabels:{display:!0}},scales:{x:{title:{display:!0,text:u[0]},beginAtZero:!0,ticks:{precision:0}},y:{title:{display:!0,text:u[1]},beginAtZero:!0,ticks:{precision:0}}}},v=qo(g,(r==null?void 0:r.options)||{});return{type:t,data:{datasets:h},options:v}}return Ia({data:e,cfg:n,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}function qJ({chart:e,elementIndex:t,datasetIndex:n,cardType:r,cfg:o,apply:i}){const s=ke.getState().theme;if(!o)return;const a=s==="dark"?"rgb(238,238,238,0.2)":"rgb(238,238,238,0.8)";["bar","line","horizontalBar","bubble","scatter"].includes(r)&&YJ(e,t,o,i,a),["pie","doughnut","polarArea"].includes(r)&&KJ(e,t,o,i,a),["stackedBar","pyramid"].includes(r)&&GJ({chart:e,elementIndex:t,datasetIndex:n,cfg:o,apply:i,blurColor:a})}function GJ(e){var a,l,c,u;const{chart:t,elementIndex:n,datasetIndex:r,cfg:o,apply:i,blurColor:s}=e;i?(l=(a=t==null?void 0:t.data)==null?void 0:a.datasets)==null||l.forEach((f,h)=>{var g,v;typeof f.backgroundColor=="string"&&(f.backgroundColor=new Array(f.data.length).fill(f.backgroundColor),f.borderColor=new Array(f.data.length).fill(f.borderColor)),f.backgroundColor=(g=f==null?void 0:f.backgroundColor)==null?void 0:g.map((b,x)=>x===n&&h===r?b:s),f.borderColor=(v=f==null?void 0:f.borderColor)==null?void 0:v.map((b,x)=>x===n&&h===r?b:s)}):(u=(c=t==null?void 0:t.data)==null?void 0:c.datasets)==null||u.forEach((f,h)=>{var g,v,b,x,w,_;f.backgroundColor=new Array(f.data.length).fill((b=(v=(g=o==null?void 0:o.data)==null?void 0:g.datasets)==null?void 0:v[h])==null?void 0:b.backgroundColor),f.borderColor=new Array(f.data.length).fill((_=(w=(x=o==null?void 0:o.data)==null?void 0:x.datasets)==null?void 0:w[h])==null?void 0:_.borderColor)}),t==null||t.update()}function YJ(e,t,n,r,o){var i,s,a,l;console.log("clicked index",t),r?(s=(i=e==null?void 0:e.data)==null?void 0:i.datasets)==null||s.forEach(c=>{var u,f;typeof c.backgroundColor=="string"&&(c.backgroundColor=new Array(c.data.length).fill(c.backgroundColor),c.borderColor=new Array(c.data.length).fill(c.borderColor)),c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,g)=>g===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,g)=>g===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,g,v,b,x;c.backgroundColor=new Array(c.data.length).fill((g=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:g.backgroundColor),c.borderColor=new Array(c.data.length).fill((x=(b=(v=n==null?void 0:n.data)==null?void 0:v.datasets)==null?void 0:b[u])==null?void 0:x.borderColor)}),e==null||e.update()}function KJ(e,t,n,r,o){var i,s,a,l;r?(s=(i=e==null?void 0:e.data)==null?void 0:i.datasets)==null||s.forEach(c=>{var u,f;c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,g)=>g===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,g)=>g===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,g,v,b,x,w,_;typeof c.backgroundColor=="string"&&(c.backgroundColor=(g=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:g.backgroundColor,c.borderColor=(x=(b=(v=n==null?void 0:n.data)==null?void 0:v.datasets)==null?void 0:b[u])==null?void 0:x.borderColor),c.backgroundColor=(w=c==null?void 0:c.backgroundColor)==null?void 0:w.map((S,R)=>{var C;return(C=n.data.datasets[u].backgroundColor)==null?void 0:C[R]}),c.borderColor=(_=c==null?void 0:c.borderColor)==null?void 0:_.map((S,R)=>{var C;return(C=n.data.datasets[u].borderColor)==null?void 0:C[R]})}),e==null||e.update()}function XJ(e,t,n,r){var o,i;try{if(!e||!e.data)return;const{dimensionKeys:s,metricKeys:a}=ar(e.data);if(["bar","horizontalBar","line","pie","doughnut","radar","polarArea"].includes(e.type)){const l=s[0],c=(o=e.data[n])==null?void 0:o[l];return[{columnName:l,columnValue:c,metric:a[t],value:r}]}if(["stackedBar","pyramid"].includes(e.type)){const l=Pg({dataArray:e.data,groupKey:s[0],pivotKey:s[1],valueKey:a[0]}),c=s[0],u=(i=l[n])==null?void 0:i[c],f=s[1],{metricKeys:h}=ar(l),g=h[t];return[{columnName:c,columnValue:u,metric:a[0],value:r},{columnName:f,columnValue:g,metric:a[0],value:r}]}if(e.type==="bubble"||e.type==="scatter"){const l=s[0],c=r.label;return[{columnName:l,columnValue:c,metric1:a[0],value1:r.x,metric2:a[1],value2:r.y,metric3:a==null?void 0:a[2],value3:r==null?void 0:r.r}]}}catch(s){console.error("Error in getAdhocFilter",s)}}function QJ(e){var s,a;const[t]=m.useState({id:"",title:"",type:"bar",data:[]}),{getCard:n}=Mo(),r=n(e),o=j1(r||t),i={...r,data:((s=o==null?void 0:o.data)==null?void 0:s.records)||[]};return{...o,data:((a=o==null?void 0:o.data)==null?void 0:a.records)||[],card:i}}function j1(e){var B,K,Z;const{onChartElementClicked:t}=ma(),[n,r]=m.useState(0),o=((B=e==null?void 0:e.preferences)==null?void 0:B.filterOnClickColumnIndex)===void 0?0:(K=e.preferences)==null?void 0:K.filterOnClickColumnIndex,i=ke(z=>z.bookmarkKey);ke(z=>z.isVisualEditing);const s=ke(z=>z.filteringCards),a=ke(z=>z.selectedSheetId);ke(z=>z.selectedCardId),ke(z=>z.isDashboardEditing);const l=ke(z=>z.themeStyle),c=ke(z=>z.filterValues),u=m.useRef(c),f=(Z=e==null?void 0:e.preferences)==null?void 0:Z.onClickFilter,{addFrame:h,addFilteringCard:g,setFrameCardData:v,getSelectedFrame:b,addOrUpdateFilterValue:x,addOrUpdateFilterValues:w,removeFilterValue:_,removeFilteringCard:S}=Mo(),{data:R,isLoading:C,isFetching:P,isError:A,refetch:k}=NJ(e),D=s==null?void 0:s.find(z=>z.id===e.id);let I;e.data&&e.data.length>0&&(I=F1({data:e.data,cardType:e.type,cfg:e.cfg,customCfg:e.customCfg,preferences:e.preferences})),m.useEffect(()=>{!R||!R.records||v(a,e.id,(R==null?void 0:R.records)||[])},[R,a,e.id,v,c]),m.useEffect(()=>{e.data&&r(n+1)},[e.data,e.type,e.cfg,e.customCfg,e.preferences,l]),m.useEffect(()=>{e.connectionId&&!D&&(k(),u.current=c)},[c,i]);function F(z,Q,W,Y){var H,J;let oe=!1;if(!e.data)return;const $=XJ(e,Q,W,Y);if(console.log("fieldValues",$),t==null||t(e,$),!!(((H=e==null?void 0:e.preferences)==null?void 0:H.onClickFilter)??[]).length){if(D){const N=e.id;_(N),S(e)}else{if(oe=!0,!$)return;const N=[];$.forEach((ce,le)=>{const de=f==null?void 0:f.find(ie=>ie.columnIndex===le);if(!de)return;const pe={filterId:e.id+"-"+ce.columnName,connectionId:e==null?void 0:e.connectionId,tableName:e.lastSelectedTable,name:ce.columnName,expression:de.expression,valueType:Pd($[de.columnIndex].columnValue),operation:"=",values:[$[de.columnIndex].columnValue]};N.push(pe)}),e.id,e==null||e.connectionId,e.lastSelectedTable,$[o].columnName,(J=e.preferences)==null||J.filterOnClickField,Pd($[o].columnValue),$[o].columnValue,w(N),g(e)}qJ({chart:z,elementIndex:W,datasetIndex:Q,cardType:e.type,cfg:I,apply:oe})}}return{isError:A,isLoading:C,isFetching:P,data:R,visualKey:n,handleDatapointClick:F,cfg:I}}var JJ=e=>{switch(e){case"success":return tZ;case"info":return rZ;case"warning":return nZ;case"error":return oZ;default:return null}},ZJ=Array(12).fill(0),eZ=({visible:e})=>m.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},m.createElement("div",{className:"sonner-spinner"},ZJ.map((t,n)=>m.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),tZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),nZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),rZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),oZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),iZ=()=>{let[e,t]=m.useState(document.hidden);return m.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},yx=1,sZ=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;let{message:r,...o}=t,i=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:yx++,s=this.toasts.find(l=>l.id===i),a=t.dismissible===void 0?!0:t.dismissible;return s?this.toasts=this.toasts.map(l=>l.id===i?(this.publish({...l,...t,id:i,title:r}),{...l,...t,id:i,dismissible:a,title:r}):l):this.addToast({title:r,...o,dismissible:a,id:i}),i},this.dismiss=t=>(t||this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),this.subscribers.forEach(n=>n({id:t,dismiss:!0})),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));let o=t instanceof Promise?t:t(),i=r!==void 0;return o.then(async s=>{if(lZ(s)&&!s.ok){i=!1;let a=typeof n.error=="function"?await n.error(`HTTP error! status: ${s.status}`):n.error,l=typeof n.description=="function"?await n.description(`HTTP error! status: ${s.status}`):n.description;this.create({id:r,type:"error",message:a,description:l})}else if(n.success!==void 0){i=!1;let a=typeof n.success=="function"?await n.success(s):n.success,l=typeof n.description=="function"?await n.description(s):n.description;this.create({id:r,type:"success",message:a,description:l})}}).catch(async s=>{if(n.error!==void 0){i=!1;let a=typeof n.error=="function"?await n.error(s):n.error,l=typeof n.description=="function"?await n.description(s):n.description;this.create({id:r,type:"error",message:a,description:l})}}).finally(()=>{var s;i&&(this.dismiss(r),r=void 0),(s=n.finally)==null||s.call(n)}),r},this.custom=(t,n)=>{let r=(n==null?void 0:n.id)||yx++;return this.create({jsx:t(r),id:r,...n}),r},this.subscribers=[],this.toasts=[]}},Qr=new sZ,aZ=(e,t)=>{let n=(t==null?void 0:t.id)||yx++;return Qr.addToast({title:e,...t,id:n}),n},lZ=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",cZ=aZ,uZ=()=>Qr.toasts,dk=Object.assign(cZ,{success:Qr.success,info:Qr.info,warning:Qr.warning,error:Qr.error,custom:Qr.custom,message:Qr.message,promise:Qr.promise,dismiss:Qr.dismiss,loading:Qr.loading},{getHistory:uZ});function dZ(e,{insertAt:t}={}){if(!e||typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}dZ(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}:where([data-sonner-toaster][data-x-position="right"]){right:max(var(--offset),env(safe-area-inset-right))}:where([data-sonner-toaster][data-x-position="left"]){left:max(var(--offset),env(safe-area-inset-left))}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:max(var(--offset),env(safe-area-inset-top))}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:max(var(--offset),env(safe-area-inset-bottom))}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:0;right:0;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
253
+ `),s=new Blob([i],{type:"text/csv"}),a=window.URL.createObjectURL(s),l=document.createElement("a");l.setAttribute("hidden",""),l.setAttribute("href",a),l.setAttribute("download",t),document.body.appendChild(l),l.click(),document.body.removeChild(l)};return O.jsx(XX,{onClick:n,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})};function oQ({frame:e}){var _;const t=ke(S=>S.isDashboardEditing),n=ke(S=>S.filterValues),r=ke(S=>S.isVisualEditing),o=ke(S=>S.selectedSheetId);ke(S=>S.currentBreakpoint);const{removeFrame:i}=ke(S=>S.actions),s=ke(S=>S.actions.setIsVisualEditing),a=Ar(S=>S.actions.setFilterValues),l=Ar(S=>S.actions.setApplyFilters),{setCard:c,setFrame:u,setQueryResultColumns:f}=Ar(S=>S.actions),h=Ar(S=>S.actions.setSelectedConnectionId),g=Ar(S=>S.actions.setSelectedDatabaseName),v=Ar(S=>S.actions.setSelectedSchemaName),b=Ar(S=>S.actions.setSelectedTableName),x=e.cards.find(S=>S.id===e.activeCardId);function w(){s(!r),c(x);const{dimensionKeys:S}=ar((x==null?void 0:x.data)||[]);f(S),u(e),x!=null&&x.connectionId&&h(x==null?void 0:x.connectionId),x!=null&&x.lastSelectedDatabase&&g(x==null?void 0:x.lastSelectedDatabase),x!=null&&x.lastSelectedSchema&&v(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&b(x==null?void 0:x.lastSelectedTable),n&&(a(n),l(!0))}return O.jsx("section",{className:"absolute right-2 top-2 z-10",children:O.jsxs("div",{className:"flex items-center gap-2",children:[t&&(r?O.jsx(_X,{onClick:()=>{s(!r)},className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"}):O.jsx(CX,{role:"edit-visual",onClick:w,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})),t&&O.jsx(TA,{onClick:()=>i(o,e.id),className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"}),((_=x.preferences)==null?void 0:_.allowDownload)===!0&&O.jsx(rQ,{data:(x==null?void 0:x.data)||[],filename:x.title})]})})}function iQ(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const px="dismissableLayer.update",sQ="dismissableLayer.pointerDownOutside",aQ="dismissableLayer.focusOutside";let sP;const lQ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ff=m.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=e,u=m.useContext(lQ),[f,h]=m.useState(null),g=(n=f==null?void 0:f.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,v]=m.useState({}),b=_t(t,k=>h(k)),x=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),_=x.indexOf(w),S=f?x.indexOf(f):-1,R=u.layersWithOutsidePointerEventsDisabled.size>0,C=S>=_,P=cQ(k=>{const D=k.target,I=[...u.branches].some(F=>F.contains(D));!C||I||(i==null||i(k),a==null||a(k),k.defaultPrevented||l==null||l())},g),A=uQ(k=>{const D=k.target;[...u.branches].some(F=>F.contains(D))||(s==null||s(k),a==null||a(k),k.defaultPrevented||l==null||l())},g);return iQ(k=>{S===u.layers.size-1&&(o==null||o(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},g),m.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(sP=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),aP(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=sP)}},[f,g,r,u]),m.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),aP())},[f,u]),m.useEffect(()=>{const k=()=>v({});return document.addEventListener(px,k),()=>document.removeEventListener(px,k)},[]),m.createElement(Qe.div,he({},c,{ref:b,style:{pointerEvents:R?C?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,A.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,P.onPointerDownCapture)}))});function cQ(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let c=function(){NA(sQ,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function uQ(e,t=globalThis==null?void 0:globalThis.document){const n=Ln(e),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&NA(aQ,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function aP(){const e=new CustomEvent(px);document.dispatchEvent(e)}function NA(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?CD(o,i):o.dispatchEvent(i)}const dQ=["top","right","bottom","left"],ca=Math.min,no=Math.max,Tg=Math.round,mp=Math.floor,ua=e=>({x:e,y:e}),fQ={left:"right",right:"left",bottom:"top",top:"bottom"},hQ={start:"end",end:"start"};function gx(e,t,n){return no(e,ca(t,n))}function ss(e,t){return typeof e=="function"?e(t):e}function as(e){return e.split("-")[0]}function iu(e){return e.split("-")[1]}function R1(e){return e==="x"?"y":"x"}function O1(e){return e==="y"?"height":"width"}function su(e){return["top","bottom"].includes(as(e))?"y":"x"}function P1(e){return R1(su(e))}function pQ(e,t,n){n===void 0&&(n=!1);const r=iu(e),o=P1(e),i=O1(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Dg(s)),[s,Dg(s)]}function gQ(e){const t=Dg(e);return[mx(e),t,mx(t)]}function mx(e){return e.replace(/start|end/g,t=>hQ[t])}function mQ(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function vQ(e,t,n,r){const o=iu(e);let i=mQ(as(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(mx)))),i}function Dg(e){return e.replace(/left|right|bottom|top/g,t=>fQ[t])}function bQ(e){return{top:0,right:0,bottom:0,left:0,...e}}function LA(e){return typeof e!="number"?bQ(e):{top:e,right:e,bottom:e,left:e}}function $g(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function lP(e,t,n){let{reference:r,floating:o}=e;const i=su(t),s=P1(t),a=O1(s),l=as(t),c=i==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let g;switch(l){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-o.width,y:f};break;default:g={x:r.x,y:r.y}}switch(iu(t)){case"start":g[s]-=h*(n&&c?-1:1);break;case"end":g[s]+=h*(n&&c?-1:1);break}return g}const yQ=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=lP(c,r,l),h=r,g={},v=0;for(let b=0;b<a.length;b++){const{name:x,fn:w}=a[b],{x:_,y:S,data:R,reset:C}=await w({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:g,rects:c,platform:s,elements:{reference:e,floating:t}});if(u=_??u,f=S??f,g={...g,[x]:{...g[x],...R}},C&&v<=50){v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(c=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:f}=lP(c,h,l)),b=-1;continue}}return{x:u,y:f,placement:h,strategy:o,middlewareData:g}};async function Fd(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:g=0}=ss(t,e),v=LA(g),x=a[h?f==="floating"?"reference":"floating":f],w=$g(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),_=f==="floating"?{...s.floating,x:r,y:o}:s.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),R=await(i.isElement==null?void 0:i.isElement(S))?await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1}:{x:1,y:1},C=$g(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:_,offsetParent:S,strategy:l}):_);return{top:(w.top-C.top+v.top)/R.y,bottom:(C.bottom-w.bottom+v.bottom)/R.y,left:(w.left-C.left+v.left)/R.x,right:(C.right-w.right+v.right)/R.x}}const cP=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=ss(e,t)||{};if(c==null)return{};const f=LA(u),h={x:n,y:r},g=P1(o),v=O1(g),b=await s.getDimensions(c),x=g==="y",w=x?"top":"left",_=x?"bottom":"right",S=x?"clientHeight":"clientWidth",R=i.reference[v]+i.reference[g]-h[g]-i.floating[v],C=h[g]-i.reference[g],P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let A=P?P[S]:0;(!A||!await(s.isElement==null?void 0:s.isElement(P)))&&(A=a.floating[S]||i.floating[v]);const k=R/2-C/2,D=A/2-b[v]/2-1,I=ca(f[w],D),F=ca(f[_],D),B=I,K=A-b[v]-F,Z=A/2-b[v]/2+k,z=gx(B,Z,K),Q=!l.arrow&&iu(o)!=null&&Z!=z&&i.reference[v]/2-(Z<B?I:F)-b[v]/2<0,W=Q?Z<B?Z-B:Z-K:0;return{[g]:h[g]+W,data:{[g]:z,centerOffset:Z-z-W,...Q&&{alignmentOffset:W}},reset:Q}}}),xQ=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:b=!0,...x}=ss(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=as(o),_=as(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),R=h||(_||!b?[Dg(a)]:gQ(a));!h&&v!=="none"&&R.push(...vQ(a,b,v,S));const C=[a,...R],P=await Fd(t,x),A=[];let k=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&A.push(P[w]),f){const B=pQ(o,s,S);A.push(P[B[0]],P[B[1]])}if(k=[...k,{placement:o,overflows:A}],!A.every(B=>B<=0)){var D,I;const B=(((D=i.flip)==null?void 0:D.index)||0)+1,K=C[B];if(K)return{data:{index:B,overflows:k},reset:{placement:K}};let Z=(I=k.filter(z=>z.overflows[0]<=0).sort((z,Q)=>z.overflows[1]-Q.overflows[1])[0])==null?void 0:I.placement;if(!Z)switch(g){case"bestFit":{var F;const z=(F=k.map(Q=>[Q.placement,Q.overflows.filter(W=>W>0).reduce((W,Y)=>W+Y,0)]).sort((Q,W)=>Q[1]-W[1])[0])==null?void 0:F[0];z&&(Z=z);break}case"initialPlacement":Z=a;break}if(o!==Z)return{reset:{placement:Z}}}return{}}}};function uP(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function dP(e){return dQ.some(t=>e[t]>=0)}const wQ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ss(e,t);switch(r){case"referenceHidden":{const i=await Fd(t,{...o,elementContext:"reference"}),s=uP(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:dP(s)}}}case"escaped":{const i=await Fd(t,{...o,altBoundary:!0}),s=uP(i,n.floating);return{data:{escapedOffsets:s,escaped:dP(s)}}}default:return{}}}}};async function _Q(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=as(n),a=iu(n),l=su(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,f=ss(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof v=="number"&&(g=a==="end"?v*-1:v),l?{x:g*u,y:h*c}:{x:h*c,y:g*u}}const SQ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await _Q(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},CQ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:x=>{let{x:w,y:_}=x;return{x:w,y:_}}},...l}=ss(e,t),c={x:n,y:r},u=await Fd(t,l),f=su(as(o)),h=R1(f);let g=c[h],v=c[f];if(i){const x=h==="y"?"top":"left",w=h==="y"?"bottom":"right",_=g+u[x],S=g-u[w];g=gx(_,g,S)}if(s){const x=f==="y"?"top":"left",w=f==="y"?"bottom":"right",_=v+u[x],S=v-u[w];v=gx(_,v,S)}const b=a.fn({...t,[h]:g,[f]:v});return{...b,data:{x:b.x-n,y:b.y-r}}}}},EQ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=ss(e,t),u={x:n,y:r},f=su(o),h=R1(f);let g=u[h],v=u[f];const b=ss(a,t),x=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(l){const S=h==="y"?"height":"width",R=i.reference[h]-i.floating[S]+x.mainAxis,C=i.reference[h]+i.reference[S]-x.mainAxis;g<R?g=R:g>C&&(g=C)}if(c){var w,_;const S=h==="y"?"width":"height",R=["top","left"].includes(as(o)),C=i.reference[f]-i.floating[S]+(R&&((w=s.offset)==null?void 0:w[f])||0)+(R?0:x.crossAxis),P=i.reference[f]+i.reference[S]+(R?0:((_=s.offset)==null?void 0:_[f])||0)-(R?x.crossAxis:0);v<C?v=C:v>P&&(v=P)}return{[h]:g,[f]:v}}}},RQ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:i}=t,{apply:s=()=>{},...a}=ss(e,t),l=await Fd(t,a),c=as(n),u=iu(n),f=su(n)==="y",{width:h,height:g}=r.floating;let v,b;c==="top"||c==="bottom"?(v=c,b=u===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(b=c,v=u==="end"?"top":"bottom");const x=g-l[v],w=h-l[b],_=!t.middlewareData.shift;let S=x,R=w;if(f){const P=h-l.left-l.right;R=u||_?ca(w,P):P}else{const P=g-l.top-l.bottom;S=u||_?ca(x,P):P}if(_&&!u){const P=no(l.left,0),A=no(l.right,0),k=no(l.top,0),D=no(l.bottom,0);f?R=h-2*(P!==0||A!==0?P+A:no(l.left,l.right)):S=g-2*(k!==0||D!==0?k+D:no(l.top,l.bottom))}await s({...t,availableWidth:R,availableHeight:S});const C=await o.getDimensions(i.floating);return h!==C.width||g!==C.height?{reset:{rects:!0}}:{}}}};function da(e){return FA(e)?(e.nodeName||"").toLowerCase():"#document"}function so(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ds(e){var t;return(t=(FA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function FA(e){return e instanceof Node||e instanceof so(e).Node}function ls(e){return e instanceof Element||e instanceof so(e).Element}function Si(e){return e instanceof HTMLElement||e instanceof so(e).HTMLElement}function fP(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof so(e).ShadowRoot}function jf(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$o(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function OQ(e){return["table","td","th"].includes(da(e))}function T1(e){const t=D1(),n=$o(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function PQ(e){let t=Yc(e);for(;Si(t)&&!Tm(t);){if(T1(t))return t;t=Yc(t)}return null}function D1(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Tm(e){return["html","body","#document"].includes(da(e))}function $o(e){return so(e).getComputedStyle(e)}function Dm(e){return ls(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Yc(e){if(da(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fP(e)&&e.host||ds(e);return fP(t)?t.host:t}function jA(e){const t=Yc(e);return Tm(t)?e.ownerDocument?e.ownerDocument.body:e.body:Si(t)&&jf(t)?t:jA(t)}function jd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=jA(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=so(o);return i?t.concat(s,s.visualViewport||[],jf(o)?o:[],s.frameElement&&n?jd(s.frameElement):[]):t.concat(o,jd(o,[],n))}function zA(e){const t=$o(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Si(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Tg(n)!==i||Tg(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function $1(e){return ls(e)?e:e.contextElement}function yc(e){const t=$1(e);if(!Si(t))return ua(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=zA(t);let s=(i?Tg(n.width):n.width)/r,a=(i?Tg(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const TQ=ua(0);function BA(e){const t=so(e);return!D1()||!t.visualViewport?TQ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function DQ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==so(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=$1(e);let s=ua(1);t&&(r?ls(r)&&(s=yc(r)):s=yc(e));const a=DQ(i,n,r)?BA(i):ua(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,f=o.height/s.y;if(i){const h=so(i),g=r&&ls(r)?so(r):r;let v=h.frameElement;for(;v&&r&&g!==h;){const b=yc(v),x=v.getBoundingClientRect(),w=$o(v),_=x.left+(v.clientLeft+parseFloat(w.paddingLeft))*b.x,S=x.top+(v.clientTop+parseFloat(w.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=_,c+=S,v=so(v).frameElement}}return $g({width:u,height:f,x:l,y:c})}function $Q(e){let{rect:t,offsetParent:n,strategy:r}=e;const o=Si(n),i=ds(n);if(n===i)return t;let s={scrollLeft:0,scrollTop:0},a=ua(1);const l=ua(0);if((o||!o&&r!=="fixed")&&((da(n)!=="body"||jf(i))&&(s=Dm(n)),Si(n))){const c=ml(n);a=yc(n),l.x=c.x+n.clientLeft,l.y=c.y+n.clientTop}return{width:t.width*a.x,height:t.height*a.y,x:t.x*a.x-s.scrollLeft*a.x+l.x,y:t.y*a.y-s.scrollTop*a.y+l.y}}function AQ(e){return Array.from(e.getClientRects())}function VA(e){return ml(ds(e)).left+Dm(e).scrollLeft}function kQ(e){const t=ds(e),n=Dm(e),r=e.ownerDocument.body,o=no(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=no(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+VA(e);const a=-n.scrollTop;return $o(r).direction==="rtl"&&(s+=no(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function MQ(e,t){const n=so(e),r=ds(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=D1();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function IQ(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Si(e)?yc(e):ua(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function hP(e,t,n){let r;if(t==="viewport")r=MQ(e,n);else if(t==="document")r=kQ(ds(e));else if(ls(t))r=IQ(t,n);else{const o=BA(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return $g(r)}function HA(e,t){const n=Yc(e);return n===t||!ls(n)||Tm(n)?!1:$o(n).position==="fixed"||HA(n,t)}function NQ(e,t){const n=t.get(e);if(n)return n;let r=jd(e,[],!1).filter(a=>ls(a)&&da(a)!=="body"),o=null;const i=$o(e).position==="fixed";let s=i?Yc(e):e;for(;ls(s)&&!Tm(s);){const a=$o(s),l=T1(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||jf(s)&&!l&&HA(e,s))?r=r.filter(u=>u!==s):o=a,s=Yc(s)}return t.set(e,r),r}function LQ(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?NQ(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const f=hP(t,u,o);return c.top=no(f.top,c.top),c.right=ca(f.right,c.right),c.bottom=ca(f.bottom,c.bottom),c.left=no(f.left,c.left),c},hP(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function FQ(e){return zA(e)}function jQ(e,t,n){const r=Si(t),o=ds(t),i=n==="fixed",s=ml(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=ua(0);if(r||!r&&!i)if((da(t)!=="body"||jf(o))&&(a=Dm(t)),r){const c=ml(t,!0,i,t);l.x=c.x+t.clientLeft,l.y=c.y+t.clientTop}else o&&(l.x=VA(o));return{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function pP(e,t){return!Si(e)||$o(e).position==="fixed"?null:t?t(e):e.offsetParent}function WA(e,t){const n=so(e);if(!Si(e))return n;let r=pP(e,t);for(;r&&OQ(r)&&$o(r).position==="static";)r=pP(r,t);return r&&(da(r)==="html"||da(r)==="body"&&$o(r).position==="static"&&!T1(r))?n:r||PQ(e)||n}const zQ=async function(e){let{reference:t,floating:n,strategy:r}=e;const o=this.getOffsetParent||WA,i=this.getDimensions;return{reference:jQ(t,await o(n),r),floating:{x:0,y:0,...await i(n)}}};function BQ(e){return $o(e).direction==="rtl"}const VQ={convertOffsetParentRelativeRectToViewportRelativeRect:$Q,getDocumentElement:ds,getClippingRect:LQ,getOffsetParent:WA,getElementRects:zQ,getClientRects:AQ,getDimensions:FQ,getScale:yc,isElement:ls,isRTL:BQ};function HQ(e,t){let n=null,r;const o=ds(e);function i(){clearTimeout(r),n&&n.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:f,height:h}=e.getBoundingClientRect();if(a||t(),!f||!h)return;const g=mp(u),v=mp(o.clientWidth-(c+f)),b=mp(o.clientHeight-(u+h)),x=mp(c),_={rootMargin:-g+"px "+-v+"px "+-b+"px "+-x+"px",threshold:no(0,ca(1,l))||1};let S=!0;function R(C){const P=C[0].intersectionRatio;if(P!==l){if(!S)return s();P?s(!1,P):r=setTimeout(()=>{s(!1,1e-7)},100)}S=!1}try{n=new IntersectionObserver(R,{..._,root:o.ownerDocument})}catch{n=new IntersectionObserver(R,_)}n.observe(e)}return s(!0),i}function WQ(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=$1(e),u=o||i?[...c?jd(c):[],...jd(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const f=c&&a?HQ(c,n):null;let h=-1,g=null;s&&(g=new ResizeObserver(w=>{let[_]=w;_&&_.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{g&&g.observe(t)})),n()}),c&&!l&&g.observe(c),g.observe(t));let v,b=l?ml(e):null;l&&x();function x(){const w=ml(e);b&&(w.x!==b.x||w.y!==b.y||w.width!==b.width||w.height!==b.height)&&n(),b=w,v=requestAnimationFrame(x)}return n(),()=>{u.forEach(w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),f&&f(),g&&g.disconnect(),g=null,l&&cancelAnimationFrame(v)}}const UQ=(e,t,n)=>{const r=new Map,o={platform:VQ,...n},i={...o.platform,_c:r};return yQ(e,t,{...o,platform:i})},qQ=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?cP({element:r.current,padding:o}).fn(n):{}:r?cP({element:r,padding:o}).fn(n):{}}}};var og=typeof document<"u"?m.useLayoutEffect:m.useEffect;function Ag(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Ag(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ag(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function UA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gP(e,t){const n=UA(e);return Math.round(t*n)/n}function mP(e){const t=V.useRef(e);return og(()=>{t.current=e}),t}function GQ(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,f]=V.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=V.useState(r);Ag(h,r)||g(r);const[v,b]=V.useState(null),[x,w]=V.useState(null),_=V.useCallback(Q=>{Q!=P.current&&(P.current=Q,b(Q))},[b]),S=V.useCallback(Q=>{Q!==A.current&&(A.current=Q,w(Q))},[w]),R=i||v,C=s||x,P=V.useRef(null),A=V.useRef(null),k=V.useRef(u),D=mP(l),I=mP(o),F=V.useCallback(()=>{if(!P.current||!A.current)return;const Q={placement:t,strategy:n,middleware:h};I.current&&(Q.platform=I.current),UQ(P.current,A.current,Q).then(W=>{const Y={...W,isPositioned:!0};B.current&&!Ag(k.current,Y)&&(k.current=Y,uw.flushSync(()=>{f(Y)}))})},[h,t,n,I]);og(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,f(Q=>({...Q,isPositioned:!1})))},[c]);const B=V.useRef(!1);og(()=>(B.current=!0,()=>{B.current=!1}),[]),og(()=>{if(R&&(P.current=R),C&&(A.current=C),R&&C){if(D.current)return D.current(R,C,F);F()}},[R,C,F,D]);const K=V.useMemo(()=>({reference:P,floating:A,setReference:_,setFloating:S}),[_,S]),Z=V.useMemo(()=>({reference:R,floating:C}),[R,C]),z=V.useMemo(()=>{const Q={position:n,left:0,top:0};if(!Z.floating)return Q;const W=gP(Z.floating,u.x),Y=gP(Z.floating,u.y);return a?{...Q,transform:"translate("+W+"px, "+Y+"px)",...UA(Z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:Y}},[n,a,Z.floating,u.x,u.y]);return V.useMemo(()=>({...u,update:F,refs:K,elements:Z,floatingStyles:z}),[u,F,K,Z,z])}function $m(e){const[t,n]=m.useState(void 0);return ur(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const qA="Popper",[GA,Ti]=Zn(qA),[YQ,YA]=GA(qA),KQ=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return m.createElement(YQ,{scope:t,anchor:r,onAnchorChange:o},n)},XQ="PopperAnchor",QQ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=YA(XQ,n),s=m.useRef(null),a=_t(t,s);return m.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:m.createElement(Qe.div,he({},o,{ref:a}))}),KA="PopperContent",[JQ,aye]=GA(KA),ZQ=m.forwardRef((e,t)=>{var n,r,o,i,s,a,l,c;const{__scopePopper:u,side:f="bottom",sideOffset:h=0,align:g="center",alignOffset:v=0,arrowPadding:b=0,avoidCollisions:x=!0,collisionBoundary:w=[],collisionPadding:_=0,sticky:S="partial",hideWhenDetached:R=!1,updatePositionStrategy:C="optimized",onPlaced:P,...A}=e,k=YA(KA,u),[D,I]=m.useState(null),F=_t(t,Pe=>I(Pe)),[B,K]=m.useState(null),Z=$m(B),z=(n=Z==null?void 0:Z.width)!==null&&n!==void 0?n:0,Q=(r=Z==null?void 0:Z.height)!==null&&r!==void 0?r:0,W=f+(g!=="center"?"-"+g:""),Y=typeof _=="number"?_:{top:0,right:0,bottom:0,left:0,..._},oe=Array.isArray(w)?w:[w],$=oe.length>0,H={padding:Y,boundary:oe.filter(eJ),altBoundary:$},{refs:J,floatingStyles:N,placement:ce,isPositioned:le,middlewareData:de}=GQ({strategy:"fixed",placement:W,whileElementsMounted:(...Pe)=>WQ(...Pe,{animationFrame:C==="always"}),elements:{reference:k.anchor},middleware:[SQ({mainAxis:h+Q,alignmentAxis:v}),x&&CQ({mainAxis:!0,crossAxis:!1,limiter:S==="partial"?EQ():void 0,...H}),x&&xQ({...H}),RQ({...H,apply:({elements:Pe,rects:Te,availableWidth:Ue,availableHeight:Be})=>{const{width:Ie,height:Ke}=Te.reference,lt=Pe.floating.style;lt.setProperty("--radix-popper-available-width",`${Ue}px`),lt.setProperty("--radix-popper-available-height",`${Be}px`),lt.setProperty("--radix-popper-anchor-width",`${Ie}px`),lt.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),B&&qQ({element:B,padding:b}),tJ({arrowWidth:z,arrowHeight:Q}),R&&wQ({strategy:"referenceHidden",...H})]}),[pe,ie]=XA(ce),te=Ln(P);ur(()=>{le&&(te==null||te())},[le,te]);const ae=(o=de.arrow)===null||o===void 0?void 0:o.x,ye=(i=de.arrow)===null||i===void 0?void 0:i.y,G=((s=de.arrow)===null||s===void 0?void 0:s.centerOffset)!==0,[be,_e]=m.useState();return ur(()=>{D&&_e(window.getComputedStyle(D).zIndex)},[D]),m.createElement("div",{ref:J.setFloating,"data-radix-popper-content-wrapper":"",style:{...N,transform:le?N.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(a=de.transformOrigin)===null||a===void 0?void 0:a.x,(l=de.transformOrigin)===null||l===void 0?void 0:l.y].join(" ")},dir:e.dir},m.createElement(JQ,{scope:u,placedSide:pe,onArrowChange:K,arrowX:ae,arrowY:ye,shouldHideArrow:G},m.createElement(Qe.div,he({"data-side":pe,"data-align":ie},A,{ref:F,style:{...A.style,animation:le?void 0:"none",opacity:(c=de.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))});function eJ(e){return e!==null}const tJ=e=>({name:"transformOrigin",options:e,fn(t){var n,r,o,i,s;const{placement:a,rects:l,middlewareData:c}=t,f=((n=c.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,h=f?0:e.arrowWidth,g=f?0:e.arrowHeight,[v,b]=XA(a),x={start:"0%",center:"50%",end:"100%"}[b],w=((r=(o=c.arrow)===null||o===void 0?void 0:o.x)!==null&&r!==void 0?r:0)+h/2,_=((i=(s=c.arrow)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0)+g/2;let S="",R="";return v==="bottom"?(S=f?x:`${w}px`,R=`${-g}px`):v==="top"?(S=f?x:`${w}px`,R=`${l.floating.height+g}px`):v==="right"?(S=`${-g}px`,R=f?x:`${_}px`):v==="left"&&(S=`${l.floating.width+g}px`,R=f?x:`${_}px`),{data:{x:S,y:R}}}});function XA(e){const[t,n="center"]=e.split("-");return[t,n]}const zf=KQ,Bf=QQ,Vf=ZQ,A1=m.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...o}=e;return r?ko.createPortal(m.createElement(Qe.div,he({},o,{ref:t})),r):null}),nJ=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(rJ);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(vx,he({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(vx,he({},r,{ref:t}),n)});nJ.displayName="Slot";const vx=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...oJ(r,n.props),ref:t?cs(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});vx.displayName="SlotClone";const QA=({children:e})=>m.createElement(m.Fragment,null,e);function rJ(e){return m.isValidElement(e)&&e.type===QA}function oJ(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const JA=m.forwardRef((e,t)=>m.createElement(Qe.span,he({},e,{ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}))),iJ=JA,[Am,lye]=Zn("Tooltip",[Ti]),k1=Ti(),sJ="TooltipProvider",aJ=700,bx="tooltip.open",[lJ,M1]=Am(sJ),cJ=e=>{const{__scopeTooltip:t,delayDuration:n=aJ,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,[s,a]=m.useState(!0),l=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),m.createElement(lJ,{scope:t,isOpenDelayed:s,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:m.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(u=>{l.current=u},[]),disableHoverableContent:o},i)},I1="Tooltip",[uJ,km]=Am(I1),dJ=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:i,disableHoverableContent:s,delayDuration:a}=e,l=M1(I1,e.__scopeTooltip),c=k1(t),[u,f]=m.useState(null),h=Jo(),g=m.useRef(0),v=s??l.disableHoverableContent,b=a??l.delayDuration,x=m.useRef(!1),[w=!1,_]=xr({prop:r,defaultProp:o,onChange:A=>{A?(l.onOpen(),document.dispatchEvent(new CustomEvent(bx))):l.onClose(),i==null||i(A)}}),S=m.useMemo(()=>w?x.current?"delayed-open":"instant-open":"closed",[w]),R=m.useCallback(()=>{window.clearTimeout(g.current),x.current=!1,_(!0)},[_]),C=m.useCallback(()=>{window.clearTimeout(g.current),_(!1)},[_]),P=m.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{x.current=!0,_(!0)},b)},[b,_]);return m.useEffect(()=>()=>window.clearTimeout(g.current),[]),m.createElement(zf,c,m.createElement(uJ,{scope:t,contentId:h,open:w,stateAttribute:S,trigger:u,onTriggerChange:f,onTriggerEnter:m.useCallback(()=>{l.isOpenDelayed?P():R()},[l.isOpenDelayed,P,R]),onTriggerLeave:m.useCallback(()=>{v?C():window.clearTimeout(g.current)},[C,v]),onOpen:R,onClose:C,disableHoverableContent:v},n))},vP="TooltipTrigger",ZA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=km(vP,n),i=M1(vP,n),s=k1(n),a=m.useRef(null),l=_t(t,a,o.onTriggerChange),c=m.useRef(!1),u=m.useRef(!1),f=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),m.createElement(Bf,he({asChild:!0},s),m.createElement(Qe.button,he({"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute},r,{ref:l,onPointerMove:Me(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:Me(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:Me(e.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Me(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:Me(e.onBlur,o.onClose),onClick:Me(e.onClick,o.onClose)})))}),fJ="TooltipPortal",[cye,hJ]=Am(fJ,{forceMount:void 0}),zd="TooltipContent",pJ=m.forwardRef((e,t)=>{const n=hJ(zd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,s=km(zd,e.__scopeTooltip);return m.createElement(er,{present:r||s.open},s.disableHoverableContent?m.createElement(ek,he({side:o},i,{ref:t})):m.createElement(gJ,he({side:o},i,{ref:t})))}),gJ=m.forwardRef((e,t)=>{const n=km(zd,e.__scopeTooltip),r=M1(zd,e.__scopeTooltip),o=m.useRef(null),i=_t(t,o),[s,a]=m.useState(null),{trigger:l,onClose:c}=n,u=o.current,{onPointerInTransitChange:f}=r,h=m.useCallback(()=>{a(null),f(!1)},[f]),g=m.useCallback((v,b)=>{const x=v.currentTarget,w={x:v.clientX,y:v.clientY},_=vJ(w,x.getBoundingClientRect()),S=bJ(w,_),R=yJ(b.getBoundingClientRect()),C=wJ([...S,...R]);a(C),f(!0)},[f]);return m.useEffect(()=>()=>h(),[h]),m.useEffect(()=>{if(l&&u){const v=x=>g(x,u),b=x=>g(x,l);return l.addEventListener("pointerleave",v),u.addEventListener("pointerleave",b),()=>{l.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",b)}}},[l,u,g,h]),m.useEffect(()=>{if(s){const v=b=>{const x=b.target,w={x:b.clientX,y:b.clientY},_=(l==null?void 0:l.contains(x))||(u==null?void 0:u.contains(x)),S=!xJ(w,s);_?h():S&&(h(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,u,s,c,h]),m.createElement(ek,he({},e,{ref:i}))}),[mJ,uye]=Am(I1,{isInside:!1}),ek=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...a}=e,l=km(zd,n),c=k1(n),{onClose:u}=l;return m.useEffect(()=>(document.addEventListener(bx,u),()=>document.removeEventListener(bx,u)),[u]),m.useEffect(()=>{if(l.trigger){const f=h=>{const g=h.target;g!=null&&g.contains(l.trigger)&&u()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,u]),m.createElement(Ff,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:f=>f.preventDefault(),onDismiss:u},m.createElement(Vf,he({"data-state":l.stateAttribute},c,a,{ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"}}),m.createElement(QA,null,r),m.createElement(mJ,{scope:n,isInside:!0},m.createElement(iJ,{id:l.contentId,role:"tooltip"},o||r))))});function vJ(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function bJ(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function yJ(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function xJ(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const a=t[i].x,l=t[i].y,c=t[s].x,u=t[s].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(o=!o)}return o}function wJ(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),_J(t)}function _J(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const SJ=cJ,CJ=dJ,EJ=ZA,tk=pJ,RJ=SJ,nk=CJ,rk=EJ,N1=V.forwardRef(({className:e,sideOffset:t=4,...n},r)=>O.jsx(tk,{ref:r,sideOffset:t,className:Ee("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));N1.displayName=tk.displayName;function ll({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:i="en-US"}){let s=1,a=r,l=i;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&i==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&i==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,f={maximumFractionDigits:c,minimumFractionDigits:c};if(o){f.style="currency",f.currency=o;try{new Intl.NumberFormat(i,f).format(0)}catch{f.currency="USD"}}try{new Intl.NumberFormat(i,f).format(0)}catch{l="en-US"}let g=new Intl.NumberFormat(l,f).format(u);return n&&(g+=a),g}function ok(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function ik({card:e,isLoading:t}){var w,_,S,R,C,P,A,k,D,I,F,B,K,Z,z,Q,W,Y,oe,$,H,J,N,ce;const n=ke(le=>le.actions.setCardTitle),r=ke(le=>le.actions.setCardDescription),o=ke(le=>le.isVisualEditing),i=Ar(le=>le.card),s=Ar(le=>le.actions.setCard);Ar(le=>le.actions.setNumberFormat);const a=ke(le=>le.selectedSheetId),l=e.data,c=(_=(w=e.preferences)==null?void 0:w.formatNumber)==null?void 0:_.colorRanges,{metricKeys:u}=ar(l||[]),f=(S=l==null?void 0:l[0])==null?void 0:S[u==null?void 0:u[0]],h=(R=l==null?void 0:l[0])==null?void 0:R[u==null?void 0:u[1]],g=!!e.data&&e.data.length>0;function v(le){o?s({...i,title:le}):n(a,e.id,le)}function b(le){o?s({...i,description:le}):r(a,e.id,le)}const x=h&&h-f!==0?(f-h)/h:null;return O.jsxs("div",{className:"kpi-card flex grow flex-col overflow-scroll",children:[O.jsxs(sm,{className:"grow pb-3",children:[O.jsx(is,{text:o?i.title:e.title,onSave:v,children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx(Df,{className:"text-base font-medium text-muted-foreground",children:e.title}),!e.refreshInterval&&t&&O.jsx(S1,{className:"h-4 w-4 animate-spin text-muted-foreground"})]})}),g&&O.jsxs("div",{className:"flex flex-wrap items-end gap-3 text-foreground",children:[O.jsx("p",{style:{color:ok(f,c)},className:"text-3xl font-semibold",children:ll({number:f,decimalPlaces:((P=(C=e.preferences)==null?void 0:C.formatNumber)==null?void 0:P.decimalPlaces)||0,useSuffix:!!((k=(A=e.preferences)==null?void 0:A.formatNumber)!=null&&k.suffix),customSuffix:((I=(D=e.preferences)==null?void 0:D.formatNumber)==null?void 0:I.suffix)||"",locale:((B=(F=e.preferences)==null?void 0:F.formatNumber)==null?void 0:B.locale)||"",currency:((Z=(K=e.preferences)==null?void 0:K.formatNumber)==null?void 0:Z.currency)||""})}),h&&O.jsxs("span",{className:"min-w-fit text-base font-normal text-muted-foreground",children:["from  ",ll({number:h,decimalPlaces:((Q=(z=e.preferences)==null?void 0:z.formatNumber)==null?void 0:Q.decimalPlaces)||0,useSuffix:!!((Y=(W=e.preferences)==null?void 0:W.formatNumber)!=null&&Y.suffix),customSuffix:(($=(oe=e.preferences)==null?void 0:oe.formatNumber)==null?void 0:$.suffix)||"",locale:((J=(H=e.preferences)==null?void 0:H.formatNumber)==null?void 0:J.locale)||"",currency:((ce=(N=e.preferences)==null?void 0:N.formatNumber)==null?void 0:ce.currency)||""})]})]})]}),x&&O.jsxs(am,{className:"grow items-start gap-1 pb-4 text-sm",children:[O.jsx(OJ,{children:x}),O.jsxs("div",{className:"flex gap-1 text-muted-foreground",children:[x>0?"up ":"down ",O.jsx(is,{text:e.description||"",onSave:b,children:e.description})]})]})]})}function OJ({children:e}){const t=e>0?O.jsx(w1,{className:"h-4 w-4"}):O.jsx(x1,{className:"h-4 w-4"}),n=`${Math.abs(e*100).toFixed(0)}%`;return O.jsxs("div",{className:Ee("flex items-center",{"text-green-600":e>0,"text-destructive":e<0}),children:[t,O.jsx("span",{className:"ml-[1px]",children:n})]})}var Kc=1e3,Xc=Kc*60,Qc=Xc*60,vl=Qc*24,PJ=vl*7,TJ=vl*365.25,DJ=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return $J(e);if(n==="number"&&isFinite(e))return t.long?kJ(e):AJ(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function $J(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*TJ;case"weeks":case"week":case"w":return n*PJ;case"days":case"day":case"d":return n*vl;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Qc;case"minutes":case"minute":case"mins":case"min":case"m":return n*Xc;case"seconds":case"second":case"secs":case"sec":case"s":return n*Kc;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function AJ(e){var t=Math.abs(e);return t>=vl?Math.round(e/vl)+"d":t>=Qc?Math.round(e/Qc)+"h":t>=Xc?Math.round(e/Xc)+"m":t>=Kc?Math.round(e/Kc)+"s":e+"ms"}function kJ(e){var t=Math.abs(e);return t>=vl?vp(e,t,vl,"day"):t>=Qc?vp(e,t,Qc,"hour"):t>=Xc?vp(e,t,Xc,"minute"):t>=Kc?vp(e,t,Kc,"second"):e+" ms"}function vp(e,t,n,r){var o=t>=n*1.5;return Math.round(e/n)+" "+r+(o?"s":"")}const MJ=nu(DJ);function sk({children:e}){const{setIsSessionExpired:t}=Mo(),n=new Qz({queryCache:new pD({onError:r=>{console.error(`Something went wrong: ${r.message}`),r.message==="invalid token"&&t(!0)}}),defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});return O.jsx(tB,{client:n,children:e})}const IJ={id:"",authToken:void 0},ak=m.createContext(IJ),lk=({children:e,dashboardProps:t})=>O.jsx(sk,{children:O.jsx(ak.Provider,{value:t,children:O.jsx("div",{style:{height:"100%"},id:"semaphor-scope",children:e})})});function ma(){const e=m.useContext(ak);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}function NJ(e){ke(u=>u.bookmarkKey),ke(u=>u.selectedSheetId);const t=ke(u=>u.dashboard.baseQueries),n=ke(u=>u.actions.getCardSheet),{authToken:r}=ma(),o=ke(u=>u.authToken),i=ke(u=>u.filterValues),s=ke(u=>u.isDashboardEditing),a=MJ((e==null?void 0:e.refreshInterval)||"0");n(e.id);const l=Y2(e.sql,t);return Tf({queryKey:[e.id,l],queryFn:()=>Rf("https://semaphor.cloud/api/v1/query",(r==null?void 0:r.accessToken)||(o==null?void 0:o.accessToken)||"",{connection_id:e.connectionId,sql:l,python:e.python===aD?"":e.python,active_filters:i}),refetchInterval:a,enabled:!!e.connectionId&&!s})}function Ia({data:e,cfg:t,customCfg:n,preferences:r}){const{dimensionKeys:o,metricKeys:i}=ar(e),s=zX(i,e,r),a=rg(s,n),l=o[0],c=fx(e,l);L1(r,t),ck(r);const u=uk(t,r),f=qo((t==null?void 0:t.options)||{},r==null?void 0:r.chartOptions),h=qo(u,f),g=qo(h,(n==null?void 0:n.options)||{});return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:c,datasets:a},options:g}}function L1(e,t){var o,i,s;const n=((o=t==null?void 0:t.options)==null?void 0:o.indexAxis)==="y"?"x":"y";return(i=e==null?void 0:e.chartOptions)!=null&&i.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function ck(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function uk(e,t){var i,s,a,l,c,u,f,h,g,v,b,x;const n=L1(t,e),r=ck(t);return{...e==null?void 0:e.options,scales:{...(i=e==null?void 0:e.options)==null?void 0:i.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:w=>{var _,S,R,C;return ll({number:Number(w),decimalPlaces:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}},[r]:{...(g=(h=(f=e==null?void 0:e.options)==null?void 0:f.scales)==null?void 0:h[r])==null?void 0:g.ticks,callback:null}},plugins:{...(v=e==null?void 0:e.options)==null?void 0:v.plugins,datalabels:{...(x=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:x.datalabels,formatter:function(w){var _,S,R,C;return ll({number:Number(w),decimalPlaces:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}}}}function LJ(e){return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0},y:{display:!0}}}}}function FJ(e){return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{beginAtZero:!0,stack:1,reverse:!0},y:{stacked:!0,beginAtZero:!0}}}}}function jJ(e){return{...e,type:"bar",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}}}}}function zJ(e,t=!1){return{...e,type:"bar",options:{...e==null?void 0:e.options,indexAxis:"y",scales:{x:{display:!0,beginAtZero:!1},y:{display:!0,stacked:t}}}}}function BJ(e,t){var r,o,i,s;return{...e,type:t==="stackedBar"?"bar":"line",options:{...e==null?void 0:e.options,scales:{x:{...(o=(r=e==null?void 0:e.options)==null?void 0:r.scales)==null?void 0:o.x,display:!0,stacked:!0},y:{...(s=(i=e==null?void 0:e.options)==null?void 0:i.scales)==null?void 0:s.y,display:!0,stacked:!0}}}}}function VJ(e){return{...e,type:"line",options:{...e==null?void 0:e.options,scales:{x:{display:!0},y:{display:!0}}}}}function HJ(e,t){var r;return{...t,type:e,options:{...t==null?void 0:t.options,scales:{x:{display:!1},y:{display:!1}},plugins:{...(r=t==null?void 0:t.options)==null?void 0:r.plugins,legend:{position:"top",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},borderRadius:0}}}function WJ(e){return{...e,type:"radar",options:{...e==null?void 0:e.options,scales:{x:{display:!1},y:{display:!1}}}}}function UJ(e){const n=new Function("getDatalabelColor",e)(w0);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}function F1({data:e,cardType:t="bar",cfg:n,customCfg:r,provider:o="chartjs",userSettings:i,preferences:s}){var a,l,c;if(t==="bar"){const u=jJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="horizontalBar"){const u=LJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="pyramid"){const u=FJ(n),{dimensionKeys:f,metricKeys:h}=ar(e),g=Pg({dataArray:e,groupKey:f[0],pivotKey:f[1],valueKey:h[0]}),v=Ia({data:g,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s}),b="x2";return{...v,data:{...v.data,datasets:v.data.datasets.map((w,_)=>_===1?{...w,xAxisID:b}:w)},options:{...v.options,scales:{...(a=v==null?void 0:v.options)==null?void 0:a.scales,[b]:{beginAtZero:!0,stack:1}}}}}if(t==="stackedBar"||t==="stackedLine"){const u=BJ(n,t),{dimensionKeys:f,metricKeys:h}=ar(e),g=Pg({dataArray:e,groupKey:f[0],pivotKey:f[1],valueKey:h[0]});return Ia({data:g,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="line"){const u=VJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="range"){const u=zJ(n),f=HX(e),h=rg(f,r),{plugins:g,options:v}=UJ((s==null?void 0:s.customVisualCode)||""),b=qo((u==null?void 0:u.options)||{},(n==null?void 0:n.options)||{}),x=qo(b,(s==null?void 0:s.chartOptions)||{}),w=qo(x,(r==null?void 0:r.options)||{}),_=qo(w,v),S=uk(n,s),R=qo(_,S),C={...R,plugins:{...R==null?void 0:R.plugins,datalabels:{...(l=R==null?void 0:R.plugins)==null?void 0:l.datalabels,formatter:(I,F)=>I.map(K=>{var Z,z,Q,W;return ll({number:Number(K),decimalPlaces:((Z=s==null?void 0:s.numberAxisFormat)==null?void 0:Z.decimalPlaces)||0,useSuffix:!!((z=s==null?void 0:s.numberAxisFormat)!=null&&z.suffix),customSuffix:"",locale:((Q=s==null?void 0:s.numberAxisFormat)==null?void 0:Q.locale)||"",currency:((W=s==null?void 0:s.numberAxisFormat)==null?void 0:W.currency)||""})}).slice(0,2).join(" - ")}}},{dimensionKeys:P}=ar(e),A=P[0];return{type:"bar",data:{labels:[...new Set(fx(e,A))],datasets:h},options:C,plugins:[...g]}}if(t==="pie"||t==="doughnut"||t==="polarArea"){const u=HJ(t,n),{dimensionKeys:f,metricKeys:h}=ar(e),g=WX(h,e),v=rg(g,r),b=f[0],x=fx(e,b),w=qo((u==null?void 0:u.options)||{},(r==null?void 0:r.options)||{}),_=qo(w,(s==null?void 0:s.chartOptions)||{}),S={..._,plugins:{..._.plugins,datalabels:{...(c=_.plugins)==null?void 0:c.datalabels,formatter:(P,A)=>{var k,D,I,F;return ll({number:Number(P),decimalPlaces:((k=s==null?void 0:s.numberAxisFormat)==null?void 0:k.decimalPlaces)||0,useSuffix:!!((D=s==null?void 0:s.numberAxisFormat)!=null&&D.suffix),customSuffix:"",locale:((I=s==null?void 0:s.numberAxisFormat)==null?void 0:I.locale)||"",currency:((F=s==null?void 0:s.numberAxisFormat)==null?void 0:F.currency)||""})}}}};return{type:t,data:{labels:x,datasets:v},options:S,plugins:[t==="doughnut"?{id:"doughnutLabel",beforeDatasetsDraw:function(P,A,k){var Q,W,Y,oe;const{ctx:D,data:I}=P;D.save();const F=P.getDatasetMeta(0).data[0].x,B=P.getDatasetMeta(0).data[0].y,K=Bc(Od());D.font="1.2rem Arial",D.fontWeight="bolder",D.fillStyle=K,D.textAlign="center",D.textBaseline="middle";const Z=I.datasets[0].data.reduce(($,H)=>$+H,0),z=ll({number:Number(Z),decimalPlaces:((Q=s==null?void 0:s.numberAxisFormat)==null?void 0:Q.decimalPlaces)||0,useSuffix:!!((W=s==null?void 0:s.numberAxisFormat)!=null&&W.suffix),customSuffix:"",locale:((Y=s==null?void 0:s.numberAxisFormat)==null?void 0:Y.locale)||"",currency:((oe=s==null?void 0:s.numberAxisFormat)==null?void 0:oe.currency)||""});D.fillText(z,F,B)}}:""]}}if(t==="radar"){const u=WJ(n);return Ia({data:e,cfg:u,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}if(t==="bubble"||t==="scatter"){const{metricKeys:u}=ar(e);if(u.length<3){console.log("Bubble charts require 3 numeric columns");return}const f=VX(e),h=rg(f,r),g={plugins:{datalabels:{display:!0}},scales:{x:{title:{display:!0,text:u[0]},beginAtZero:!0,ticks:{precision:0}},y:{title:{display:!0,text:u[1]},beginAtZero:!0,ticks:{precision:0}}}},v=qo(g,(r==null?void 0:r.options)||{});return{type:t,data:{datasets:h},options:v}}return Ia({data:e,cfg:n,customCfg:r,cardType:t,userSettings:i,provider:o,preferences:s})}function qJ({chart:e,elementIndex:t,datasetIndex:n,cardType:r,cfg:o,apply:i}){const s=ke.getState().theme;if(!o)return;const a=s==="dark"?"rgb(238,238,238,0.2)":"rgb(238,238,238,0.8)";["bar","line","horizontalBar","bubble","scatter"].includes(r)&&YJ(e,t,o,i,a),["pie","doughnut","polarArea"].includes(r)&&KJ(e,t,o,i,a),["stackedBar","pyramid"].includes(r)&&GJ({chart:e,elementIndex:t,datasetIndex:n,cfg:o,apply:i,blurColor:a})}function GJ(e){var a,l,c,u;const{chart:t,elementIndex:n,datasetIndex:r,cfg:o,apply:i,blurColor:s}=e;i?(l=(a=t==null?void 0:t.data)==null?void 0:a.datasets)==null||l.forEach((f,h)=>{var g,v;typeof f.backgroundColor=="string"&&(f.backgroundColor=new Array(f.data.length).fill(f.backgroundColor),f.borderColor=new Array(f.data.length).fill(f.borderColor)),f.backgroundColor=(g=f==null?void 0:f.backgroundColor)==null?void 0:g.map((b,x)=>x===n&&h===r?b:s),f.borderColor=(v=f==null?void 0:f.borderColor)==null?void 0:v.map((b,x)=>x===n&&h===r?b:s)}):(u=(c=t==null?void 0:t.data)==null?void 0:c.datasets)==null||u.forEach((f,h)=>{var g,v,b,x,w,_;f.backgroundColor=new Array(f.data.length).fill((b=(v=(g=o==null?void 0:o.data)==null?void 0:g.datasets)==null?void 0:v[h])==null?void 0:b.backgroundColor),f.borderColor=new Array(f.data.length).fill((_=(w=(x=o==null?void 0:o.data)==null?void 0:x.datasets)==null?void 0:w[h])==null?void 0:_.borderColor)}),t==null||t.update()}function YJ(e,t,n,r,o){var i,s,a,l;console.log("clicked index",t),r?(s=(i=e==null?void 0:e.data)==null?void 0:i.datasets)==null||s.forEach(c=>{var u,f;typeof c.backgroundColor=="string"&&(c.backgroundColor=new Array(c.data.length).fill(c.backgroundColor),c.borderColor=new Array(c.data.length).fill(c.borderColor)),c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,g)=>g===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,g)=>g===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,g,v,b,x;c.backgroundColor=new Array(c.data.length).fill((g=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:g.backgroundColor),c.borderColor=new Array(c.data.length).fill((x=(b=(v=n==null?void 0:n.data)==null?void 0:v.datasets)==null?void 0:b[u])==null?void 0:x.borderColor)}),e==null||e.update()}function KJ(e,t,n,r,o){var i,s,a,l;r?(s=(i=e==null?void 0:e.data)==null?void 0:i.datasets)==null||s.forEach(c=>{var u,f;c.backgroundColor=(u=c==null?void 0:c.backgroundColor)==null?void 0:u.map((h,g)=>g===t?h:o),c.borderColor=(f=c==null?void 0:c.borderColor)==null?void 0:f.map((h,g)=>g===t?h:o)}):(l=(a=e==null?void 0:e.data)==null?void 0:a.datasets)==null||l.forEach((c,u)=>{var f,h,g,v,b,x,w,_;typeof c.backgroundColor=="string"&&(c.backgroundColor=(g=(h=(f=n==null?void 0:n.data)==null?void 0:f.datasets)==null?void 0:h[u])==null?void 0:g.backgroundColor,c.borderColor=(x=(b=(v=n==null?void 0:n.data)==null?void 0:v.datasets)==null?void 0:b[u])==null?void 0:x.borderColor),c.backgroundColor=(w=c==null?void 0:c.backgroundColor)==null?void 0:w.map((S,R)=>{var C;return(C=n.data.datasets[u].backgroundColor)==null?void 0:C[R]}),c.borderColor=(_=c==null?void 0:c.borderColor)==null?void 0:_.map((S,R)=>{var C;return(C=n.data.datasets[u].borderColor)==null?void 0:C[R]})}),e==null||e.update()}function XJ(e,t,n,r){var o,i;try{if(!e||!e.data)return;const{dimensionKeys:s,metricKeys:a}=ar(e.data);if(["bar","horizontalBar","line","pie","doughnut","radar","polarArea"].includes(e.type)){const l=s[0],c=(o=e.data[n])==null?void 0:o[l];return[{columnName:l,columnValue:c,metric:a[t],value:r}]}if(["stackedBar","pyramid"].includes(e.type)){const l=Pg({dataArray:e.data,groupKey:s[0],pivotKey:s[1],valueKey:a[0]}),c=s[0],u=(i=l[n])==null?void 0:i[c],f=s[1],{metricKeys:h}=ar(l),g=h[t];return[{columnName:c,columnValue:u,metric:a[0],value:r},{columnName:f,columnValue:g,metric:a[0],value:r}]}if(e.type==="bubble"||e.type==="scatter"){const l=s[0],c=r.label;return[{columnName:l,columnValue:c,metric1:a[0],value1:r.x,metric2:a[1],value2:r.y,metric3:a==null?void 0:a[2],value3:r==null?void 0:r.r}]}}catch(s){console.error("Error in getAdhocFilter",s)}}function QJ(e){var s,a;const[t]=m.useState({id:"",title:"",type:"bar",data:[]}),{getCard:n}=Mo(),r=n(e),o=j1(r||t),i={...r,data:((s=o==null?void 0:o.data)==null?void 0:s.records)||[]};return{...o,data:((a=o==null?void 0:o.data)==null?void 0:a.records)||[],card:i}}function j1(e){var B,K,Z;const{onChartElementClicked:t}=ma(),[n,r]=m.useState(0),o=((B=e==null?void 0:e.preferences)==null?void 0:B.filterOnClickColumnIndex)===void 0?0:(K=e.preferences)==null?void 0:K.filterOnClickColumnIndex,i=ke(z=>z.bookmarkKey);ke(z=>z.isVisualEditing);const s=ke(z=>z.filteringCards),a=ke(z=>z.selectedSheetId);ke(z=>z.selectedCardId),ke(z=>z.isDashboardEditing);const l=ke(z=>z.themeStyle),c=ke(z=>z.filterValues),u=m.useRef(c),f=(Z=e==null?void 0:e.preferences)==null?void 0:Z.onClickFilter,{addFrame:h,addFilteringCard:g,setFrameCardData:v,getSelectedFrame:b,addOrUpdateFilterValue:x,addOrUpdateFilterValues:w,removeFilterValue:_,removeFilteringCard:S}=Mo(),{data:R,isLoading:C,isFetching:P,isError:A,refetch:k}=NJ(e),D=s==null?void 0:s.find(z=>z.id===e.id);let I;e.data&&e.data.length>0&&(I=F1({data:e.data,cardType:e.type,cfg:e.cfg,customCfg:e.customCfg,preferences:e.preferences})),m.useEffect(()=>{!R||!R.records||v(a,e.id,(R==null?void 0:R.records)||[])},[R,a,e.id,v,c]),m.useEffect(()=>{e.data&&r(n+1)},[e.data,e.type,e.cfg,e.customCfg,e.preferences,l]),m.useEffect(()=>{e.connectionId&&!D&&(k(),u.current=c)},[c,i]);function F(z,Q,W,Y){var H,J;let oe=!1;if(!e.data)return;const $=XJ(e,Q,W,Y);if(console.log("fieldValues",$),t==null||t(e,$),!!(((H=e==null?void 0:e.preferences)==null?void 0:H.onClickFilter)??[]).length){if(D){const N=e.id;_(N),S(e)}else{if(oe=!0,!$)return;const N=[];$.forEach((ce,le)=>{const de=f==null?void 0:f.find(ie=>ie.columnIndex===le);if(!de)return;const pe={filterId:e.id+"-"+ce.columnName,connectionId:e==null?void 0:e.connectionId,tableName:e.lastSelectedTable,name:ce.columnName,expression:de.expression,valueType:Pd($[de.columnIndex].columnValue),operation:"=",values:[$[de.columnIndex].columnValue]};N.push(pe)}),e.id,e==null||e.connectionId,e.lastSelectedTable,$[o].columnName,(J=e.preferences)==null||J.filterOnClickField,Pd($[o].columnValue),$[o].columnValue,w(N),g(e)}qJ({chart:z,elementIndex:W,datasetIndex:Q,cardType:e.type,cfg:I,apply:oe})}}return{isError:A,isLoading:C,isFetching:P,data:R,visualKey:n,handleDatapointClick:F,cfg:I}}var JJ=e=>{switch(e){case"success":return tZ;case"info":return rZ;case"warning":return nZ;case"error":return oZ;default:return null}},ZJ=Array(12).fill(0),eZ=({visible:e})=>m.createElement("div",{className:"sonner-loading-wrapper","data-visible":e},m.createElement("div",{className:"sonner-spinner"},ZJ.map((t,n)=>m.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),tZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),nZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),rZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),oZ=m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},m.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),iZ=()=>{let[e,t]=m.useState(document.hidden);return m.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},yx=1,sZ=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;let{message:r,...o}=t,i=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:yx++,s=this.toasts.find(l=>l.id===i),a=t.dismissible===void 0?!0:t.dismissible;return s?this.toasts=this.toasts.map(l=>l.id===i?(this.publish({...l,...t,id:i,title:r}),{...l,...t,id:i,dismissible:a,title:r}):l):this.addToast({title:r,...o,dismissible:a,id:i}),i},this.dismiss=t=>(t||this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),this.subscribers.forEach(n=>n({id:t,dismiss:!0})),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));let o=t instanceof Promise?t:t(),i=r!==void 0;return o.then(async s=>{if(lZ(s)&&!s.ok){i=!1;let a=typeof n.error=="function"?await n.error(`HTTP error! status: ${s.status}`):n.error,l=typeof n.description=="function"?await n.description(`HTTP error! status: ${s.status}`):n.description;this.create({id:r,type:"error",message:a,description:l})}else if(n.success!==void 0){i=!1;let a=typeof n.success=="function"?await n.success(s):n.success,l=typeof n.description=="function"?await n.description(s):n.description;this.create({id:r,type:"success",message:a,description:l})}}).catch(async s=>{if(n.error!==void 0){i=!1;let a=typeof n.error=="function"?await n.error(s):n.error,l=typeof n.description=="function"?await n.description(s):n.description;this.create({id:r,type:"error",message:a,description:l})}}).finally(()=>{var s;i&&(this.dismiss(r),r=void 0),(s=n.finally)==null||s.call(n)}),r},this.custom=(t,n)=>{let r=(n==null?void 0:n.id)||yx++;return this.create({jsx:t(r),id:r,...n}),r},this.subscribers=[],this.toasts=[]}},Qr=new sZ,aZ=(e,t)=>{let n=(t==null?void 0:t.id)||yx++;return Qr.addToast({title:e,...t,id:n}),n},lZ=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",cZ=aZ,uZ=()=>Qr.toasts,dk=Object.assign(cZ,{success:Qr.success,info:Qr.info,warning:Qr.warning,error:Qr.error,custom:Qr.custom,message:Qr.message,promise:Qr.promise,dismiss:Qr.dismiss,loading:Qr.loading},{getHistory:uZ});function dZ(e,{insertAt:t}={}){if(!e||typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}dZ(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}:where([data-sonner-toaster][data-x-position="right"]){right:max(var(--offset),env(safe-area-inset-right))}:where([data-sonner-toaster][data-x-position="left"]){left:max(var(--offset),env(safe-area-inset-left))}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:max(var(--offset),env(safe-area-inset-top))}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:max(var(--offset),env(safe-area-inset-bottom))}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:0;right:0;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
254
254
  `);function bp(e){return e.label!==void 0}var fZ=3,hZ="32px",pZ=4e3,gZ=356,mZ=14,vZ=20,bZ=200;function yZ(...e){return e.filter(Boolean).join(" ")}var xZ=e=>{var t,n,r,o,i,s,a,l,c,u;let{invert:f,toast:h,unstyled:g,interacting:v,setHeights:b,visibleToasts:x,heights:w,index:_,toasts:S,expanded:R,removeToast:C,defaultRichColors:P,closeButton:A,style:k,cancelButtonStyle:D,actionButtonStyle:I,className:F="",descriptionClassName:B="",duration:K,position:Z,gap:z,loadingIcon:Q,expandByDefault:W,classNames:Y,icons:oe,closeButtonAriaLabel:$="Close toast",pauseWhenPageIsHidden:H,cn:J}=e,[N,ce]=m.useState(!1),[le,de]=m.useState(!1),[pe,ie]=m.useState(!1),[te,ae]=m.useState(!1),[ye,G]=m.useState(0),[be,_e]=m.useState(0),Pe=m.useRef(null),Te=m.useRef(null),Ue=_===0,Be=_+1<=x,Ie=h.type,Ke=h.dismissible!==!1,lt=h.className||"",It=h.descriptionClassName||"",$t=m.useMemo(()=>w.findIndex(nt=>nt.toastId===h.id)||0,[w,h.id]),Ht=m.useMemo(()=>{var nt;return(nt=h.closeButton)!=null?nt:A},[h.closeButton,A]),fe=m.useMemo(()=>h.duration||K||pZ,[h.duration,K]),Ce=m.useRef(0),Le=m.useRef(0),Ge=m.useRef(0),Ze=m.useRef(null),[Wt,Zt]=Z.split("-"),Kt=m.useMemo(()=>w.reduce((nt,ht,At)=>At>=$t?nt:nt+ht.height,0),[w,$t]),vn=iZ(),ln=h.invert||f,Lt=Ie==="loading";Le.current=m.useMemo(()=>$t*z+Kt,[$t,Kt]),m.useEffect(()=>{ce(!0)},[]),m.useLayoutEffect(()=>{if(!N)return;let nt=Te.current,ht=nt.style.height;nt.style.height="auto";let At=nt.getBoundingClientRect().height;nt.style.height=ht,_e(At),b(Xt=>Xt.find(bt=>bt.toastId===h.id)?Xt.map(bt=>bt.toastId===h.id?{...bt,height:At}:bt):[{toastId:h.id,height:At,position:h.position},...Xt])},[N,h.title,h.description,b,h.id]);let tn=m.useCallback(()=>{de(!0),G(Le.current),b(nt=>nt.filter(ht=>ht.toastId!==h.id)),setTimeout(()=>{C(h)},bZ)},[h,C,b,Le]);m.useEffect(()=>{if(h.promise&&Ie==="loading"||h.duration===1/0||h.type==="loading")return;let nt,ht=fe;return R||v||H&&vn?(()=>{if(Ge.current<Ce.current){let At=new Date().getTime()-Ce.current;ht=ht-At}Ge.current=new Date().getTime()})():ht!==1/0&&(Ce.current=new Date().getTime(),nt=setTimeout(()=>{var At;(At=h.onAutoClose)==null||At.call(h,h),tn()},ht)),()=>clearTimeout(nt)},[R,v,W,h,fe,tn,h.promise,Ie,H,vn]),m.useEffect(()=>{let nt=Te.current;if(nt){let ht=nt.getBoundingClientRect().height;return _e(ht),b(At=>[{toastId:h.id,height:ht,position:h.position},...At]),()=>b(At=>At.filter(Xt=>Xt.toastId!==h.id))}},[b,h.id]),m.useEffect(()=>{h.delete&&tn()},[tn,h.delete]);function xn(){return oe!=null&&oe.loading?m.createElement("div",{className:"sonner-loader","data-visible":Ie==="loading"},oe.loading):Q?m.createElement("div",{className:"sonner-loader","data-visible":Ie==="loading"},Q):m.createElement(eZ,{visible:Ie==="loading"})}return m.createElement("li",{"aria-live":h.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:Te,className:J(F,lt,Y==null?void 0:Y.toast,(t=h==null?void 0:h.classNames)==null?void 0:t.toast,Y==null?void 0:Y.default,Y==null?void 0:Y[Ie],(n=h==null?void 0:h.classNames)==null?void 0:n[Ie]),"data-sonner-toast":"","data-rich-colors":(r=h.richColors)!=null?r:P,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":N,"data-promise":!!h.promise,"data-removed":le,"data-visible":Be,"data-y-position":Wt,"data-x-position":Zt,"data-index":_,"data-front":Ue,"data-swiping":pe,"data-dismissible":Ke,"data-type":Ie,"data-invert":ln,"data-swipe-out":te,"data-expanded":!!(R||W&&N),style:{"--index":_,"--toasts-before":_,"--z-index":S.length-_,"--offset":`${le?ye:Le.current}px`,"--initial-height":W?"auto":`${be}px`,...k,...h.style},onPointerDown:nt=>{Lt||!Ke||(Pe.current=new Date,G(Le.current),nt.target.setPointerCapture(nt.pointerId),nt.target.tagName!=="BUTTON"&&(ie(!0),Ze.current={x:nt.clientX,y:nt.clientY}))},onPointerUp:()=>{var nt,ht,At,Xt;if(te||!Ke)return;Ze.current=null;let bt=Number(((nt=Te.current)==null?void 0:nt.style.getPropertyValue("--swipe-amount").replace("px",""))||0),Rn=new Date().getTime()-((ht=Pe.current)==null?void 0:ht.getTime()),Lo=Math.abs(bt)/Rn;if(Math.abs(bt)>=vZ||Lo>.11){G(Le.current),(At=h.onDismiss)==null||At.call(h,h),tn(),ae(!0);return}(Xt=Te.current)==null||Xt.style.setProperty("--swipe-amount","0px"),ie(!1)},onPointerMove:nt=>{var ht;if(!Ze.current||!Ke)return;let At=nt.clientY-Ze.current.y,Xt=nt.clientX-Ze.current.x,bt=(Wt==="top"?Math.min:Math.max)(0,At),Rn=nt.pointerType==="touch"?10:2;Math.abs(bt)>Rn?(ht=Te.current)==null||ht.style.setProperty("--swipe-amount",`${At}px`):Math.abs(Xt)>Rn&&(Ze.current=null)}},Ht&&!h.jsx?m.createElement("button",{"aria-label":$,"data-disabled":Lt,"data-close-button":!0,onClick:Lt||!Ke?()=>{}:()=>{var nt;tn(),(nt=h.onDismiss)==null||nt.call(h,h)},className:J(Y==null?void 0:Y.closeButton,(o=h==null?void 0:h.classNames)==null?void 0:o.closeButton)},m.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},m.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,h.jsx||m.isValidElement(h.title)?h.jsx||h.title:m.createElement(m.Fragment,null,Ie||h.icon||h.promise?m.createElement("div",{"data-icon":"",className:J(Y==null?void 0:Y.icon,(i=h==null?void 0:h.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||xn():null,h.type!=="loading"?h.icon||(oe==null?void 0:oe[Ie])||JJ(Ie):null):null,m.createElement("div",{"data-content":"",className:J(Y==null?void 0:Y.content,(s=h==null?void 0:h.classNames)==null?void 0:s.content)},m.createElement("div",{"data-title":"",className:J(Y==null?void 0:Y.title,(a=h==null?void 0:h.classNames)==null?void 0:a.title)},h.title),h.description?m.createElement("div",{"data-description":"",className:J(B,It,Y==null?void 0:Y.description,(l=h==null?void 0:h.classNames)==null?void 0:l.description)},h.description):null),m.isValidElement(h.cancel)?h.cancel:h.cancel&&bp(h.cancel)?m.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||D,onClick:nt=>{var ht,At;bp(h.cancel)&&Ke&&((At=(ht=h.cancel).onClick)==null||At.call(ht,nt),tn())},className:J(Y==null?void 0:Y.cancelButton,(c=h==null?void 0:h.classNames)==null?void 0:c.cancelButton)},h.cancel.label):null,m.isValidElement(h.action)?h.action:h.action&&bp(h.action)?m.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||I,onClick:nt=>{var ht,At;bp(h.action)&&(nt.defaultPrevented||((At=(ht=h.action).onClick)==null||At.call(ht,nt),tn()))},className:J(Y==null?void 0:Y.actionButton,(u=h==null?void 0:h.classNames)==null?void 0:u.actionButton)},h.action.label):null))};function bP(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}var wZ=e=>{let{invert:t,position:n="bottom-right",hotkey:r=["altKey","KeyT"],expand:o,closeButton:i,className:s,offset:a,theme:l="light",richColors:c,duration:u,style:f,visibleToasts:h=fZ,toastOptions:g,dir:v=bP(),gap:b=mZ,loadingIcon:x,icons:w,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:S,cn:R=yZ}=e,[C,P]=m.useState([]),A=m.useMemo(()=>Array.from(new Set([n].concat(C.filter(H=>H.position).map(H=>H.position)))),[C,n]),[k,D]=m.useState([]),[I,F]=m.useState(!1),[B,K]=m.useState(!1),[Z,z]=m.useState(l!=="system"?l:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Q=m.useRef(null),W=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),Y=m.useRef(null),oe=m.useRef(!1),$=m.useCallback(H=>{var J;(J=C.find(N=>N.id===H.id))!=null&&J.delete||Qr.dismiss(H.id),P(N=>N.filter(({id:ce})=>ce!==H.id))},[C]);return m.useEffect(()=>Qr.subscribe(H=>{if(H.dismiss){P(J=>J.map(N=>N.id===H.id?{...N,delete:!0}:N));return}setTimeout(()=>{ko.flushSync(()=>{P(J=>{let N=J.findIndex(ce=>ce.id===H.id);return N!==-1?[...J.slice(0,N),{...J[N],...H},...J.slice(N+1)]:[H,...J]})})})}),[]),m.useEffect(()=>{if(l!=="system"){z(l);return}l==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?z("dark"):z("light")),typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:H})=>{z(H?"dark":"light")})},[l]),m.useEffect(()=>{C.length<=1&&F(!1)},[C]),m.useEffect(()=>{let H=J=>{var N,ce;r.every(le=>J[le]||J.code===le)&&(F(!0),(N=Q.current)==null||N.focus()),J.code==="Escape"&&(document.activeElement===Q.current||(ce=Q.current)!=null&&ce.contains(document.activeElement))&&F(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[r]),m.useEffect(()=>{if(Q.current)return()=>{Y.current&&(Y.current.focus({preventScroll:!0}),Y.current=null,oe.current=!1)}},[Q.current]),C.length?m.createElement("section",{"aria-label":`${_} ${W}`,tabIndex:-1},A.map((H,J)=>{var N;let[ce,le]=H.split("-");return m.createElement("ol",{key:H,dir:v==="auto"?bP():v,tabIndex:-1,ref:Q,className:s,"data-sonner-toaster":!0,"data-theme":Z,"data-y-position":ce,"data-x-position":le,style:{"--front-toast-height":`${((N=k[0])==null?void 0:N.height)||0}px`,"--offset":typeof a=="number"?`${a}px`:a||hZ,"--width":`${gZ}px`,"--gap":`${b}px`,...f},onBlur:de=>{oe.current&&!de.currentTarget.contains(de.relatedTarget)&&(oe.current=!1,Y.current&&(Y.current.focus({preventScroll:!0}),Y.current=null))},onFocus:de=>{de.target instanceof HTMLElement&&de.target.dataset.dismissible==="false"||oe.current||(oe.current=!0,Y.current=de.relatedTarget)},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{B||F(!1)},onPointerDown:de=>{de.target instanceof HTMLElement&&de.target.dataset.dismissible==="false"||K(!0)},onPointerUp:()=>K(!1)},C.filter(de=>!de.position&&J===0||de.position===H).map((de,pe)=>{var ie,te;return m.createElement(xZ,{key:de.id,icons:w,index:pe,toast:de,defaultRichColors:c,duration:(ie=g==null?void 0:g.duration)!=null?ie:u,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:t,visibleToasts:h,closeButton:(te=g==null?void 0:g.closeButton)!=null?te:i,interacting:B,position:H,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:$,toasts:C.filter(ae=>ae.position==de.position),heights:k.filter(ae=>ae.position==de.position),setHeights:D,expandByDefault:o,gap:b,loadingIcon:x,expanded:I,pauseWhenPageIsHidden:S,cn:R})}))})):null};function _Z(e,t){const n=ke(u=>u.selectedSheetId),r=ke(u=>u.selectedFrameId),o=ke(u=>u.isDashboardEditing),i=ke(u=>u.isVisualEditing),{addFrame:s,getSelectedFrame:a,setSelectedFrameId:l}=ke(u=>u.actions);m.useEffect(()=>{const u=h=>{if(o&&((h.metaKey||h.ctrlKey)&&h.key==="c"&&(navigator.clipboard.writeText(JSON.stringify(a())),dk.success("Card copied to clipboard")),(h.ctrlKey||h.metaKey)&&h.key==="v")){console.log("Ctrl+V has been pressed");try{navigator.clipboard.readText().then(g=>{try{const v=JSON.parse(g);if(v&&v.id){v.id=la();const b=v.activeCardId;v.cards.forEach(x=>{const w=x.id;x.id=la(),w===b&&(v.activeCardId=x.id,x.title=`${x.title} (Copy)`)}),s(n,v),l(v.id)}}catch(v){console.error("Failed to parse clipboard contents: ",v)}})}catch(g){console.error("Failed to read clipboard contents: ",g)}}},f=t==null?void 0:t.current;return f==null||f.addEventListener("keydown",u),()=>{f==null||f.removeEventListener("keydown",u)}},[o,n,a,s,t,l]),m.useEffect(()=>{r===e.id&&o&&!i&&c()},[r,e.id,o,i]);function c(){const u=t==null?void 0:t.current;u==null||u.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}}let ry;const fk="HoverCard",[hk,fye]=Zn(fk,[Ti]),z1=Ti(),[SZ,B1]=hk(fk),CZ=e=>{const{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:i,openDelay:s=700,closeDelay:a=300}=e,l=z1(t),c=m.useRef(0),u=m.useRef(0),f=m.useRef(!1),h=m.useRef(!1),[g=!1,v]=xr({prop:r,defaultProp:o,onChange:i}),b=m.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>v(!0),s)},[s,v]),x=m.useCallback(()=>{clearTimeout(c.current),!f.current&&!h.current&&(u.current=window.setTimeout(()=>v(!1),a))},[a,v]),w=m.useCallback(()=>v(!1),[v]);return m.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),m.createElement(SZ,{scope:t,open:g,onOpenChange:v,onOpen:b,onClose:x,onDismiss:w,hasSelectionRef:f,isPointerDownOnContentRef:h},m.createElement(zf,l,n))},EZ="HoverCardTrigger",RZ=m.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=B1(EZ,n),i=z1(n);return m.createElement(Bf,he({asChild:!0},i),m.createElement(Qe.a,he({"data-state":o.open?"open":"closed"},r,{ref:t,onPointerEnter:Me(e.onPointerEnter,kg(o.onOpen)),onPointerLeave:Me(e.onPointerLeave,kg(o.onClose)),onFocus:Me(e.onFocus,o.onOpen),onBlur:Me(e.onBlur,o.onClose),onTouchStart:Me(e.onTouchStart,s=>s.preventDefault())})))}),OZ="HoverCardPortal",[hye,PZ]=hk(OZ,{forceMount:void 0}),xx="HoverCardContent",TZ=m.forwardRef((e,t)=>{const n=PZ(xx,e.__scopeHoverCard),{forceMount:r=n.forceMount,...o}=e,i=B1(xx,e.__scopeHoverCard);return m.createElement(er,{present:r||i.open},m.createElement(DZ,he({"data-state":i.open?"open":"closed"},o,{onPointerEnter:Me(e.onPointerEnter,kg(i.onOpen)),onPointerLeave:Me(e.onPointerLeave,kg(i.onClose)),ref:t})))}),DZ=m.forwardRef((e,t)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,...a}=e,l=B1(xx,n),c=z1(n),u=m.useRef(null),f=_t(t,u),[h,g]=m.useState(!1);return m.useEffect(()=>{if(h){const v=document.body;return ry=v.style.userSelect||v.style.webkitUserSelect,v.style.userSelect="none",v.style.webkitUserSelect="none",()=>{v.style.userSelect=ry,v.style.webkitUserSelect=ry}}},[h]),m.useEffect(()=>{if(u.current){const v=()=>{g(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var b;((b=document.getSelection())===null||b===void 0?void 0:b.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",v),()=>{document.removeEventListener("pointerup",v),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),m.useEffect(()=>{u.current&&$Z(u.current).forEach(b=>b.setAttribute("tabindex","-1"))}),m.createElement(Ff,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:s,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:Me(i,v=>{v.preventDefault()}),onDismiss:l.onDismiss},m.createElement(Vf,he({},c,a,{onPointerDown:Me(a.onPointerDown,v=>{v.currentTarget.contains(v.target)&&g(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:f,style:{...a.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})))});function kg(e){return t=>t.pointerType==="touch"?void 0:e()}function $Z(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)t.push(n.currentNode);return t}const AZ=CZ,kZ=RZ,pk=TZ,V1=AZ,H1=kZ,Mm=V.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>O.jsx(pk,{ref:o,align:t,sideOffset:n,className:Ee("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));Mm.displayName=pk.displayName;function MZ({card:e}){const{setCardInfo:t}=Mo();return O.jsxs(V1,{openDelay:0,children:[O.jsx(H1,{children:O.jsx(JX,{className:"size-4 text-muted-foreground/40"})}),O.jsx(Mm,{align:"start",className:"w-[300px]",onMouseDown:n=>n.stopPropagation(),children:O.jsx(is,{type:"textarea",text:e.info||"",onSave:n=>t(e.id,n),children:O.jsx("p",{className:"text-sm text-muted-foreground",children:e.info||"Double-click to add info"})})})]})}const W1=V.forwardRef(({className:e,containerClassName:t,containerStyle:n,...r},o)=>O.jsx("div",{style:n,className:Ee("relative w-full overflow-auto",t),children:O.jsx("table",{ref:o,className:Ee("w-full caption-bottom text-sm",e),...r})}));W1.displayName="Table";const U1=V.forwardRef(({className:e,...t},n)=>O.jsx("thead",{ref:n,className:Ee("[&_tr]:border-b",e),...t}));U1.displayName="TableHeader";const q1=V.forwardRef(({className:e,...t},n)=>O.jsx("tbody",{ref:n,className:Ee("[&_tr:last-child]:border-0",e),...t}));q1.displayName="TableBody";const IZ=V.forwardRef(({className:e,...t},n)=>O.jsx("tfoot",{ref:n,className:Ee("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));IZ.displayName="TableFooter";const bd=V.forwardRef(({className:e,...t},n)=>O.jsx("tr",{ref:n,className:Ee("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));bd.displayName="TableRow";const G1=V.forwardRef(({className:e,...t},n)=>O.jsx("th",{ref:n,className:Ee("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));G1.displayName="TableHead";const Mg=V.forwardRef(({className:e,...t},n)=>O.jsx("td",{ref:n,className:Ee("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));Mg.displayName="TableCell";const NZ=V.forwardRef(({className:e,...t},n)=>O.jsx("caption",{ref:n,className:Ee("mt-4 text-sm text-muted-foreground",e),...t}));NZ.displayName="TableCaption";/**
255
255
  * table-core
256
256
  *