react-semaphor 0.0.688 → 0.0.689
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-plus-szKmVTpB.js → dashboard-plus-CvIEcQve.js} +746 -746
- package/dist/chunks/{dashboard-plus-BxKFGvfL.js → dashboard-plus-DzJwjJjJ.js} +12 -12
- package/dist/chunks/{index-BRk9PMc7.js → index-BATJPB8E.js} +1 -1
- package/dist/chunks/{index-BtBIrWSP.js → index-CVe9Ly3u.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
|
@@ -69200,7 +69200,7 @@ function g4({
|
|
|
69200
69200
|
/* @__PURE__ */ p(EAe, { cardId: e }),
|
|
69201
69201
|
H()
|
|
69202
69202
|
] }),
|
|
69203
|
-
s && Z()
|
|
69203
|
+
s && !a && Z()
|
|
69204
69204
|
] })
|
|
69205
69205
|
] })
|
|
69206
69206
|
)
|
|
@@ -874,7 +874,7 @@ Your scheduled email is ready. The attachments you requested are included for yo
|
|
|
874
874
|
- less than the value passed to \`max\` (or ${w1} if no \`max\` prop is set)
|
|
875
875
|
- \`null\` if the progress is indeterminate.
|
|
876
876
|
|
|
877
|
-
Defaulting to \`null\`.`}const Yq=Wq,cAe=sAe,AM=k.forwardRef(({className:e,value:t,...n},r)=>u.jsx(Yq,{ref:r,className:Z("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:u.jsx(cAe,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));AM.displayName=Yq.displayName;function ak({primaryValue:e,secondaryValue:t,comparisonConfig:n,locale:r,currency:o,decimalPlaces:s=0,suffix:i,lowerIsBetter:a=!1}){const{calculationType:l="difference",formatOptions:c,showArrow:d=!0,showColor:f=!0,conditionalLabel:h=!1,labelName:p,conditionalLabels:m}=n,g=(c==null?void 0:c.type)||"auto",b=(()=>{if(g==="auto"||!c)return{decimalPlaces:s??0,suffix:i??"",prefix:"",useSuffix:!1,currency:o||"USD",locale:(c==null?void 0:c.locale)||r};const R=g==="currency"?2:g==="percent"?1:0;return{decimalPlaces:c.decimalPlaces??R,suffix:c.suffix??"",prefix:c.prefix??"",useSuffix:c.useSuffix??!1,currency:c.currency||o||"USD",locale:c.locale||r,negativeInParentheses:c.negativeInParentheses??!1,multiplyBy:c.multiplyBy}})();let x=0,v="";switch(l){case"difference":x=e-t;break;case"change":x=t!==0?(e-t)/t*100:0;break;case"change_difference":x=t!==0?(e-t)/t*100:0;break;case"ratio":x=t!==0?e/t:0;break}const w=(R,P=!1)=>{const M=Math.abs(R),F=P&&R>=0?"+":R<0?"-":"";if(g==="percent"){const O=b.multiplyBy?M*b.multiplyBy:M;return`${F}${O.toFixed(b.decimalPlaces)}%`}if(g==="currency"){const O=ko({number:M,decimalPlaces:b.decimalPlaces,useSuffix:b.useSuffix,customSuffix:"",locale:b.locale,currency:b.currency});return P&&R>=0?`+${O}`:R<0?`-${O}`:O}if(g==="scientific")return`${F}${M.toExponential(b.decimalPlaces)}`;const I=ko({number:M,decimalPlaces:b.decimalPlaces,useSuffix:b.useSuffix,customSuffix:b.suffix,locale:b.locale,currency:""}),A=b.prefix?`${b.prefix}${I}`:I;return b.negativeInParentheses&&R<0?`(${A})`:`${F}${A}`};if(l==="difference")v=w(x,!0);else if(l==="change")v=`${x>=0?"+":""}${Math.abs(x).toFixed(b.decimalPlaces)}%`;else if(l==="change_difference"){const R=e-t,P=x>=0?"+":"",M=Math.abs(x).toFixed(b.decimalPlaces),F=w(R,!0);v=`${P}${M}% (${F})`}else l==="ratio"&&(v=`${(x*100).toFixed(b.decimalPlaces)}%`);let S="text-gray-600",E={};if(f){const{colorConfig:R}=n,P=(M,F)=>M?M==="green"?"text-green-600":M==="red"?"text-red-600":M==="neutral"?"text-gray-600":M.startsWith("#")?(E={color:M},""):F:F;if(l==="ratio"){const M=x*100;M>=100?S=P(R==null?void 0:R.increase,"text-green-600"):M>=80?S="text-yellow-600":S=P(R==null?void 0:R.decrease,"text-red-600")}else x>0?a?S=P(R==null?void 0:R.increase,"text-red-600"):S=P(R==null?void 0:R.increase,"text-green-600"):x<0?a?S=P(R==null?void 0:R.decrease,"text-green-600"):S=P(R==null?void 0:R.decrease,"text-red-600"):S=P(R==null?void 0:R.noChange,"text-gray-600")}let C=null;d&&(l==="ratio"?C=null:x>0?C=Bo:x<0?C=zs:C=kne);let _="";return h?x>0?_=(m==null?void 0:m.increase)||"Increase":x<0?_=(m==null?void 0:m.decrease)||"Decrease":_=(m==null?void 0:m.noChange)||"No change":p&&(_=p),u.jsxs("div",{className:"inline-flex flex-col items-center",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[d&&C&&u.jsx(C,{className:`h-3 w-3 ${S}`,style:E}),u.jsx("div",{className:`text-sm font-semibold ${S}`,style:E,children:v})]}),_&&u.jsx("span",{className:"text-[10px] text-muted-foreground/70 mt-0.5 text-center",children:_}),!1]})}function Zq(e){const t=ee(f=>f.isDashboardEditing),n=ee(f=>f.isVisualEditing),r=ee(f=>f.selectedSheetId),{setCardTitle:o,setCardKpiOptions:s}=ee(f=>f.actions),{setCardTitle:i,setCountryLogo:a}=lo();return{setTitle:f=>{n?i(f):t&&r&&o(r,e.id,f)},setCountryLogo:f=>{n?a(f):t&&r&&s(r,e.id,{countryLogoId:f||void 0})},isEditable:t||n,isDashboardEditing:t,isVisualEditing:n}}function uAe({card:e,data:t,isPending:n}){var R,P,M,F,I,A,O,U,W,$,T,z,L,D,H,q,Y,V,B,G,X,re,J,ue,te,se,oe,Ne,fe,ye,Pe,it,Ve,We,vn,Rn,ie,be,Me,Be,Ze,Ct,sn,zt,Gt,xe,xt,An;const r=e.config,{setTitle:o,setCountryLogo:s,isEditable:i,isVisualEditing:a}=Zq(e),{setValueAlignment:l}=lo(),{getCurrency:c,getLocale:d}=v1(e),f=(r==null?void 0:r.metricColumns)||[],h=(M=(P=(R=e.preferences)==null?void 0:R.kpiVisualOptions)==null?void 0:P.metricComparison)==null?void 0:M.enabled,p=(le,me=!1)=>{var Fe,Ye,et,Vt,Rt,Ht,Xn,un,In,mi,Zr,Mo,gi,sl;const je=(Ye=(Fe=e.preferences)==null?void 0:Fe.formatNumber)==null?void 0:Ye.enabled,Ce=(Vt=(et=e.preferences)==null?void 0:et.kpiVisualOptions)==null?void 0:Vt.formatOptions;if(je===!1||je==="false")return le.toString();if(Ce!=null&&Ce.type&&Ce.type!=="auto")return iu(le,Ce.type,{...Ce,useSuffix:me?!0:Ce.useSuffix,locale:Ce.locale||d()||"en-US",currency:Ce.currency||c()||"USD"});const Re=c()||((Ht=(Rt=e.preferences)==null?void 0:Rt.formatNumber)==null?void 0:Ht.currency)||"",ze=d()||((un=(Xn=e.preferences)==null?void 0:Xn.formatNumber)==null?void 0:un.locale)||"en-US",Ie=(mi=(In=e.preferences)==null?void 0:In.formatNumber)==null?void 0:mi.decimalPlaces;return ko({number:le,decimalPlaces:Ie??(Re?2:0),useSuffix:me||!!((Mo=(Zr=e.preferences)==null?void 0:Zr.formatNumber)!=null&&Mo.suffix),customSuffix:((sl=(gi=e.preferences)==null?void 0:gi.formatNumber)==null?void 0:sl.suffix)||"",locale:ze,currency:Re})},m=le=>p(le,!0);let g=0,y=0,b=0;if(t&&t.length>0){const le=t[0];if(le&&f.length>0){const me=Object.keys(le),je=f[0];let Ce=me.find(Re=>Re===je.label||Re===je.name||Re.includes(je.name)||je.label&&Re.includes(je.label));if(!Ce&&me.length>0&&(Ce=me[0]),g=Ce&&le[Ce]||0,f.length>1){const Re=f[1];let ze=me.find(Ie=>Ie===Re.label||Ie===Re.name||Ie.includes(Re.name)||Re.label&&Ie.includes(Re.label));!ze&&me.length>1&&(ze=me[1]),y=ze&&le[ze]||0}if(f.length>2){const Re=f[2];let ze=me.find(Ie=>Ie===Re.label||Ie===Re.name||Ie.includes(Re.name)||Re.label&&Ie.includes(Re.label));!ze&&me.length>2&&(ze=me[2]),b=ze&&le[ze]||0}}}const x=(I=(F=e.preferences)==null?void 0:F.kpiVisualOptions)==null?void 0:I.lowerIsBetter,v=((O=(A=e.preferences)==null?void 0:A.kpiVisualOptions)==null?void 0:O.valueAlignment)||"center",w=(W=(U=e.preferences)==null?void 0:U.formatNumber)==null?void 0:W.colorRanges,S=Kw(g,w),E=(T=($=e.preferences)==null?void 0:$.kpiVisualOptions)==null?void 0:T.countryLogoId,C=N.useMemo(()=>Wd.find(le=>le.id===E),[E]),_=le=>{s(le)};if(n)return u.jsxs(Li,{className:"grow border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[C&&u.jsx("span",{className:"text-2xl",title:C.name,children:C.flag}),u.jsx(Bi,{className:"text-sm font-medium text-gray-600",children:e.title})]})}),u.jsx(Wa,{children:u.jsxs("div",{className:"animate-pulse",children:[u.jsx("div",{className:"mb-2 h-8 rounded bg-muted"}),e.description&&u.jsx("div",{className:"h-4 w-3/4 rounded bg-muted"})]})})]});function j(){return e.title?e.title:i?"Enter title":""}return u.jsxs(Li,{className:"flex grow flex-col border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[i?u.jsx(Bq,{selectedCountryId:E||void 0,onCountrySelect:_,size:"sm",showRegionBadges:!0,maxDisplayResults:20}):C&&u.jsx("span",{className:"text-2xl",title:C.name,children:C.flag}),u.jsx(Bi,{className:"text-base font-medium text-gray-600",children:u.jsx(Oi,{displayClassName:"text-base font-medium text-gray-600",inputClassName:"text-base font-medium text-gray-600",value:j(),isEditable:i,onSave:o})})]})}),u.jsxs(Wa,{className:"w-full grow pb-4",children:[h&&f.length>=2?u.jsxs("div",{className:"space-y-4",children:[((D=(L=(z=e.preferences)==null?void 0:z.kpiVisualOptions)==null?void 0:L.metricComparison)==null?void 0:D.position)==="top"?u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsx("div",{children:u.jsx("div",{className:"text-3xl font-bold tabular-nums",style:{color:S},children:((H=e==null?void 0:e.kpiPreferences)==null?void 0:H.format)==="compact"?m(g):p(g)})}),u.jsx("div",{className:"text-right",children:u.jsx(ak,{primaryValue:g,secondaryValue:y,comparisonConfig:((Y=(q=e.preferences)==null?void 0:q.kpiVisualOptions)==null?void 0:Y.metricComparison)||{},locale:d()||"en-US",currency:c(),decimalPlaces:(B=(V=e.preferences)==null?void 0:V.formatNumber)==null?void 0:B.decimalPlaces,suffix:(X=(G=e.preferences)==null?void 0:G.formatNumber)==null?void 0:X.suffix,lowerIsBetter:x})})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-3xl font-bold tabular-nums",style:{color:S},children:((re=e==null?void 0:e.kpiPreferences)==null?void 0:re.format)==="compact"?m(g):p(g)}),!1]}),u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsx("div",{className:`flex flex-col ${((te=(ue=(J=e.preferences)==null?void 0:J.kpiVisualOptions)==null?void 0:ue.metricComparison)==null?void 0:te.position)==="right"?"order-2 items-end":"order-1 items-start"}`,children:u.jsx(ak,{primaryValue:g,secondaryValue:y,comparisonConfig:((oe=(se=e.preferences)==null?void 0:se.kpiVisualOptions)==null?void 0:oe.metricComparison)||{},locale:d()||"en-US",currency:c(),decimalPlaces:(fe=(Ne=e.preferences)==null?void 0:Ne.formatNumber)==null?void 0:fe.decimalPlaces,suffix:(Pe=(ye=e.preferences)==null?void 0:ye.formatNumber)==null?void 0:Pe.suffix,lowerIsBetter:x})}),u.jsxs("div",{className:`flex flex-col ${((We=(Ve=(it=e.preferences)==null?void 0:it.kpiVisualOptions)==null?void 0:Ve.metricComparison)==null?void 0:We.position)==="right"?"order-1 items-start":"order-2 items-end"}`,children:[u.jsx("div",{className:"text-xl font-semibold tabular-nums text-muted-foreground",children:p(y)}),u.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:((vn=f[1])==null?void 0:vn.label)||((Rn=f[1])==null?void 0:Rn.name)})]})]})]}),((Me=(be=(ie=e.preferences)==null?void 0:ie.kpiVisualOptions)==null?void 0:be.metricComparison)==null?void 0:Me.position)==="top"&&u.jsxs("div",{children:[u.jsx("div",{className:"text-xl font-semibold tabular-nums text-muted-foreground",children:p(y)}),u.jsx("span",{className:"text-xs text-muted-foreground",children:((Be=f[1])==null?void 0:Be.label)||((Ze=f[1])==null?void 0:Ze.name)})]}),f.length>2&&b!==0&&u.jsx("div",{className:"border-t pt-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:((Ct=f[2])==null?void 0:Ct.label)||((sn=f[2])==null?void 0:sn.name)}),u.jsx("div",{className:"text-sm font-semibold tabular-nums",children:p(b)})]})})]}):u.jsxs("div",{className:`flex flex-col ${v==="left"?"items-start":"items-center justify-center"} space-y-4`,children:[u.jsx("div",{className:v==="left"?"":"text-center",children:u.jsx("div",{className:"text-3xl font-bold",style:{color:S},children:((zt=e==null?void 0:e.kpiPreferences)==null?void 0:zt.format)==="compact"?m(g):p(g)})}),f.length>1&&y>0&&u.jsxs("div",{className:v==="left"?"":"text-center",children:[u.jsx("div",{className:"text-xl font-semibold text-muted-foreground",children:p(y)}),u.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:((Gt=f[1])==null?void 0:Gt.label)||((xe=f[1])==null?void 0:xe.name)})]}),f.length>2&&b>0&&u.jsxs("div",{className:v==="left"?"":"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-muted-foreground",children:p(b)}),u.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:((xt=f[2])==null?void 0:xt.label)||((An=f[2])==null?void 0:An.name)})]})]}),a&&!h&&u.jsx("div",{className:"mt-4 flex justify-end",children:u.jsxs(Fh,{pressed:v==="left",className:"h-7",variant:"outline",onPressedChange:le=>l(le?"left":"center"),children:[v==="left"?u.jsx(Nne,{className:"mr-2 h-4 w-4"}):u.jsx(Ene,{className:"mr-2 h-4 w-4"}),u.jsx("span",{children:v==="left"?"Left aligned":"Center aligned"})]})})]})]})}function dAe({card:e,data:t,isPending:n}){var T,z,L,D,H,q,Y,V,B,G,X,re,J,ue,te,se,oe,Ne;const{setTitle:r,setCountryLogo:o,isEditable:s,isVisualEditing:i}=Zq(e),{setCardDescription:a,setLowerIsBetter:l}=lo(),{getCurrency:c,getLocale:d}=v1(e),f=(z=(T=e.preferences)==null?void 0:T.kpiVisualOptions)==null?void 0:z.countryLogoId,h=N.useMemo(()=>Wd.find(fe=>fe.id===f),[f]),p=e.config,m=(p==null?void 0:p.groupByColumns)&&p.groupByColumns.length>0,g=(p==null?void 0:p.metricColumns)&&p.metricColumns.length>0;if(!m&&g)return u.jsx(uAe,{card:e,data:t,isPending:n});const y=(fe,ye=!1)=>{var it,Ve,We,vn,Rn,ie,be,Me;const Pe=(Ve=(it=e.preferences)==null?void 0:it.kpiVisualOptions)==null?void 0:Ve.formatOptions;return Pe!=null&&Pe.type&&Pe.type!=="auto"?iu(fe,Pe.type,{...Pe,useSuffix:ye?!0:Pe.useSuffix,locale:Pe.locale||d()||"en-US",currency:Pe.currency||c()||"USD"}):ko({number:fe,decimalPlaces:((vn=(We=e.preferences)==null?void 0:We.formatNumber)==null?void 0:vn.decimalPlaces)||0,useSuffix:ye?!0:!!((ie=(Rn=e.preferences)==null?void 0:Rn.formatNumber)!=null&&ie.suffix),customSuffix:((Me=(be=e.preferences)==null?void 0:be.formatNumber)==null?void 0:Me.suffix)||"",locale:d()||"en-US",currency:c()||""})},b=fe=>y(fe,!0),x=((L=t==null?void 0:t.find(fe=>fe.segment==="current"))==null?void 0:L.value)||0,v=((D=t==null?void 0:t.find(fe=>fe.segment==="comparison"))==null?void 0:D.value)||0,w=((H=e.config)==null?void 0:H.comparisonType)||"none",S=(Y=(q=e.preferences)==null?void 0:q.kpiVisualOptions)==null?void 0:Y.lowerIsBetter,E=(B=(V=e.preferences)==null?void 0:V.kpiVisualOptions)==null?void 0:B.metricComparison,C=m&&(E==null?void 0:E.enabled)&&v!==0,_=(G=e.config)==null?void 0:G.targetValue,j=typeof x=="number"&&!isNaN(x)?x:0,R=typeof _=="number"&&!isNaN(_)?_:0,P=R>0?Math.min(j/R,1):0,M=R>0?Math.max(R-j,0):0,F=R>0?Math.max(j-R,0):0,I=m&&w==="target"&&R>0,A=m&&(w==="previous_period"||w==="same_period_last_year"),O=(re=(X=e.preferences)==null?void 0:X.formatNumber)==null?void 0:re.colorRanges,U=Kw(x,O),W=fe=>{o(fe)};if(n){const fe=e.description;return u.jsxs(Li,{className:"grow border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[h&&u.jsx("span",{className:"text-2xl",title:h.name,children:h.flag}),u.jsx(Bi,{className:"text-sm font-medium text-gray-600",children:e.title})]})}),u.jsx(Wa,{children:u.jsxs("div",{className:"animate-pulse",children:[u.jsx("div",{className:"mb-2 h-8 rounded bg-muted"}),fe&&u.jsx("div",{className:"h-4 w-3/4 rounded bg-muted"})]})})]})}function $(){return e.title?e.title:s?"Enter title":""}return u.jsx(ed,{children:u.jsxs(Li,{className:"group flex grow flex-col border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[s?u.jsx(Bq,{selectedCountryId:f||void 0,onCountrySelect:W,size:"sm",showRegionBadges:!0,maxDisplayResults:20}):h&&u.jsx("span",{className:"text-2xl",title:h.name,children:h.flag}),u.jsx(Bi,{className:"text-base font-medium text-gray-600",children:u.jsx(Oi,{displayClassName:"text-base font-medium text-gray-600",inputClassName:"text-base font-medium text-gray-600",value:$(),isEditable:s,onSave:r})})]})}),u.jsxs(Wa,{className:"w-full grow pb-4",children:[u.jsxs("div",{className:"flex items-baseline space-x-2",children:[u.jsx("div",{className:"text-2xl font-bold",style:{color:U},children:((J=e==null?void 0:e.kpiPreferences)==null?void 0:J.format)==="compact"?b(x):y(x)}),C&&u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ak,{primaryValue:x,secondaryValue:v,comparisonConfig:E||{},locale:d()||"en-US",currency:c(),decimalPlaces:(te=(ue=e.preferences)==null?void 0:ue.formatNumber)==null?void 0:te.decimalPlaces,suffix:(oe=(se=e.preferences)==null?void 0:se.formatNumber)==null?void 0:oe.suffix,lowerIsBetter:S}),u.jsxs(oi,{children:[u.jsx(si,{asChild:!0,children:u.jsx(uh,{className:"h-3 w-3 cursor-pointer text-muted-foreground opacity-0 transition-all hover:text-foreground group-hover:opacity-100"})}),u.jsx(qTe,{currentValue:x,comparisonValue:v,percentageChange:(x-v)/v*100,isPositive:S?x<v:x>v,data:t,formatCurrency:y,showTrendline:((Ne=e.config)==null?void 0:Ne.showTrendline)||!1})]})]})]}),I&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[u.jsxs("div",{className:"text-base text-gray-400",children:["Target: ",y(R)]}),u.jsxs("div",{className:"text-lg font-semibold text-gray-900",children:[Math.round(P*100),"%"]})]}),u.jsx(AM,{style:{width:`${Math.round(P*100)}%`,backgroundColor:U},value:Math.round(P*100),className:"h-2"}),u.jsx("div",{className:"mt-2 text-sm text-gray-400",children:j>=R?F>0?`${y(F)} above target`:"Target reached!":`${y(M)} remaining to reach target`})]}),u.jsx("div",{className:"mt-1",children:u.jsx(Oi,{isEditable:i,value:e.description||(i?"Enter description":""),placeholder:i?"No value":"",displayClassName:"text-sm text-gray-500",inputClassName:"text-sm text-gray-500",onSave:a})}),i&&u.jsx("div",{className:"mt-2 flex items-center justify-end gap-1",children:A&&u.jsxs(Fh,{pressed:S===!0,className:"h-7",variant:"outline",onPressedChange:fe=>l(fe),children:[S?u.jsx(mL,{className:"mr-2 h-4 w-4"}):u.jsx(Q0,{className:"mr-2 h-4 w-4"}),u.jsx("span",{children:S?"Lower is better":"Higher is better"})]})})]})]})})}const rv=e=>e.config&&typeof e.config=="object"&&Object.keys(e.config).length>0;function fAe({card:e,data:t,isPending:n}){var E,C,_,j,R,P,M,F,I,A,O,U,W,$,T,z,L,D;const r=ee(H=>H.actions.setCardTitle),o=ee(H=>H.actions.setCardDescription),s=ee(H=>H.isVisualEditing),i=Ae(H=>H.card),a=Ae(H=>H.actions.setCard);Ae(H=>H.actions.setNumberFormat);const{getCurrency:l,getLocale:c}=v1(e),d=ee(H=>H.selectedSheetId),f=(C=(E=e.preferences)==null?void 0:E.formatNumber)==null?void 0:C.colorRanges,{keys:h}=Jn(t),p=(_=t==null?void 0:t[0])==null?void 0:_[h==null?void 0:h[0]],m=(j=t==null?void 0:t[0])==null?void 0:j[h==null?void 0:h[1]],g=t&&t.length>0;function y(H){s?a({...i,title:H}):r(d,e.id,H)}function b(H){s?a({...i,description:H}):o(d,e.id,H)}const x=m&&m-p!==0?(p-m)/m:null,v=ko({number:p,decimalPlaces:((P=(R=e.preferences)==null?void 0:R.formatNumber)==null?void 0:P.decimalPlaces)||0,useSuffix:!!((F=(M=e.preferences)==null?void 0:M.formatNumber)!=null&&F.suffix),customSuffix:((A=(I=e.preferences)==null?void 0:I.formatNumber)==null?void 0:A.suffix)||"",locale:c()||"",currency:l()||""});let w="";m&&(w=ko({number:m,decimalPlaces:((U=(O=e.preferences)==null?void 0:O.formatNumber)==null?void 0:U.decimalPlaces)||0,useSuffix:!!(($=(W=e.preferences)==null?void 0:W.formatNumber)!=null&&$.suffix),customSuffix:((z=(T=e.preferences)==null?void 0:T.formatNumber)==null?void 0:z.suffix)||"",locale:c()||"",currency:l()||""}));const S=Kw(p,f);return u.jsx(hAe,{isPending:n,title:e.title,formattedCurrentValue:v,formattedPreviousValue:w,description:e.description,valueColor:S,onTitleChange:y,onDescriptionChange:b,percentDifference:x,isLowerIsBetter:(D=(L=e.preferences)==null?void 0:L.kpiVisualOptions)==null?void 0:D.lowerIsBetter,show:g})}function ov({card:e,data:t,isPending:n}){return rv(e)?u.jsx("div",{className:"flex h-full min-h-0 grow overflow-auto",children:u.jsx(dAe,{card:e,data:t,isPending:n})}):u.jsx(fAe,{card:e,data:t,isPending:n})}function hAe({title:e,formattedCurrentValue:t,formattedPreviousValue:n,description:r,valueColor:o,onTitleChange:s,onDescriptionChange:i,percentDifference:a,show:l,isPending:c,isLowerIsBetter:d}){const f=ee(g=>g.isDashboardEditing),h=ee(g=>g.isVisualEditing),p=Ae(g=>g.card);Ae(g=>g.actions.setCard);let m=r||"";return h&&(m=r||"from description"),u.jsxs("div",{className:"kpi-card flex grow flex-col overflow-auto",children:[u.jsxs(zi,{className:"grow pb-3",children:[u.jsx(rg,{className:"text-base font-medium tracking-tight text-muted-foreground",enabled:f,text:h?p.title:e,onSave:s,children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx(Bi,{className:"text-base font-medium text-muted-foreground",children:e})})}),c&&u.jsxs("div",{className:"space-y-2",children:[u.jsx($a,{className:"h-4 w-3/4"}),u.jsx($a,{className:"h-4 w-1/2"})]}),l&&u.jsxs("div",{className:"2 flex flex-wrap items-end text-foreground",children:[u.jsx("p",{style:{color:o},className:"text-3xl font-semibold",children:t}),n&&u.jsxs("span",{className:"min-w-fit -translate-y-[1px] text-base font-normal text-muted-foreground",children:[" from ",n]})]})]}),a&&u.jsxs("div",{className:"flex grow items-center gap-1 px-6 pb-4 text-sm",children:[u.jsx(Kq,{isLowerIsBetter:d,children:a}),u.jsxs("div",{className:"flex gap-1 text-muted-foreground",children:[a>0?"up ":"down ",u.jsx(rg,{enabled:f,text:m,onSave:i,children:m})]}),h&&u.jsx("div",{className:"ml-auto",children:u.jsx(pAe,{})})]})]})}function Kq({children:e,className:t,isLowerIsBetter:n}){const r=ee(a=>a.themeStyle),o=e>0?u.jsx("span",{children:"+"}):u.jsx("span",{children:"-"}),s=`${Math.abs(e*100).toFixed(0)}%`,i=n?e<0:e>0;return u.jsxs("div",{style:{borderRadius:(r==null?void 0:r.controlInputRadius)||"2px"},className:Z("flex items-center px-1 text-sm font-semibold",{"bg-green-600/10 text-green-600":i,"bg-destructive/10 text-destructive":!i},t),children:[o,u.jsx("span",{className:"ml-[1px]",children:s})]})}function pAe(){const e=Ae(n=>{var r,o;return(o=(r=n.card.preferences)==null?void 0:r.kpiVisualOptions)==null?void 0:o.lowerIsBetter}),{setLowerIsBetter:t}=lo();return u.jsx("div",{className:"flex items-center gap-1",children:u.jsx(Fh,{pressed:e===!0,className:"h-7",variant:"outline",onPressedChange:n=>t(n),children:u.jsx("span",{children:"Lower is better"})})})}var t2,IM="HoverCard",[Xq,MXe]=mr(IM,[ia]),S1=ia(),[mAe,C1]=Xq(IM),Qq=e=>{const{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:s,openDelay:i=700,closeDelay:a=300}=e,l=S1(t),c=k.useRef(0),d=k.useRef(0),f=k.useRef(!1),h=k.useRef(!1),[p=!1,m]=Rr({prop:r,defaultProp:o,onChange:s}),g=k.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>m(!0),i)},[i,m]),y=k.useCallback(()=>{clearTimeout(c.current),!f.current&&!h.current&&(d.current=window.setTimeout(()=>m(!1),a))},[a,m]),b=k.useCallback(()=>m(!1),[m]);return k.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),u.jsx(mAe,{scope:t,open:p,onOpenChange:m,onOpen:g,onClose:y,onDismiss:b,hasSelectionRef:f,isPointerDownOnContentRef:h,children:u.jsx(Sh,{...l,children:n})})};Qq.displayName=IM;var Jq="HoverCardTrigger",eG=k.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=C1(Jq,n),s=S1(n);return u.jsx(Ch,{asChild:!0,...s,children:u.jsx(Te.a,{"data-state":o.open?"open":"closed",...r,ref:t,onPointerEnter:we(e.onPointerEnter,iv(o.onOpen)),onPointerLeave:we(e.onPointerLeave,iv(o.onClose)),onFocus:we(e.onFocus,o.onOpen),onBlur:we(e.onBlur,o.onClose),onTouchStart:we(e.onTouchStart,i=>i.preventDefault())})})});eG.displayName=Jq;var OM="HoverCardPortal",[gAe,bAe]=Xq(OM,{forceMount:void 0}),tG=e=>{const{__scopeHoverCard:t,forceMount:n,children:r,container:o}=e,s=C1(OM,t);return u.jsx(gAe,{scope:t,forceMount:n,children:u.jsx(Zn,{present:n||s.open,children:u.jsx(Ku,{asChild:!0,container:o,children:r})})})};tG.displayName=OM;var sv="HoverCardContent",nG=k.forwardRef((e,t)=>{const n=bAe(sv,e.__scopeHoverCard),{forceMount:r=n.forceMount,...o}=e,s=C1(sv,e.__scopeHoverCard);return u.jsx(Zn,{present:r||s.open,children:u.jsx(yAe,{"data-state":s.open?"open":"closed",...o,onPointerEnter:we(e.onPointerEnter,iv(s.onOpen)),onPointerLeave:we(e.onPointerLeave,iv(s.onClose)),ref:t})})});nG.displayName=sv;var yAe=k.forwardRef((e,t)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,...a}=e,l=C1(sv,n),c=S1(n),d=k.useRef(null),f=ot(t,d),[h,p]=k.useState(!1);return k.useEffect(()=>{if(h){const m=document.body;return t2=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=t2,m.style.webkitUserSelect=t2}}},[h]),k.useEffect(()=>{if(d.current){const m=()=>{p(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var y;((y=document.getSelection())==null?void 0:y.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",m),()=>{document.removeEventListener("pointerup",m),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),k.useEffect(()=>{d.current&&wAe(d.current).forEach(g=>g.setAttribute("tabindex","-1"))}),u.jsx(Zu,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:we(s,m=>{m.preventDefault()}),onDismiss:l.onDismiss,children:u.jsx(Gg,{...c,...a,onPointerDown:we(a.onPointerDown,m=>{m.currentTarget.contains(m.target)&&p(!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)"}})})}),xAe="HoverCardArrow",vAe=k.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=S1(n);return u.jsx(Yg,{...o,...r,ref:t})});vAe.displayName=xAe;function iv(e){return t=>t.pointerType==="touch"?void 0:e()}function wAe(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}var SAe=Qq,CAe=eG,rG=nG;const E1=SAe,N1=CAe,mb=k.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>u.jsx(rG,{ref:o,align:t,sideOffset:n,className:Z("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}));mb.displayName=rG.displayName;function oG({card:e}){const t=ee(r=>r.isDashboardEditing),{setCardInfo:n}=en();return u.jsxs(E1,{openDelay:0,children:[u.jsx(N1,{children:u.jsx(uh,{className:"size-4 text-muted-foreground/40"})}),u.jsx(mb,{align:"start",className:"w-[300px] text-sm text-muted-foreground",onMouseDown:r=>r.stopPropagation(),children:u.jsx(rg,{enabled:t,type:"textarea",text:e.info||"",onSave:r=>n(e.id,r),children:e.info||"Describe what this card shows"})})]})}function EAe({card:e,renderFilterInfo:t}){var m,g,y,b,x,v,w,S,E,C,_,j,R,P,M,F,I,A;ee(O=>O.themeStyle);const{data:n,isLoading:r}=Ga(e),o=(n==null?void 0:n.records)||[],s=ee(O=>O.isDashboardEditing),{getCurrency:i,getLocale:a}=v1(e),l=(g=(m=e.preferences)==null?void 0:m.formatNumber)==null?void 0:g.colorRanges,{keys:c}=Jn(o||[]),d=(y=o==null?void 0:o[0])==null?void 0:y[c==null?void 0:c[0]],f=(b=o==null?void 0:o[0])==null?void 0:b[c==null?void 0:c[1]],h=(o==null?void 0:o.length)>0,p=f&&f-d!==0?(d-f)/f:null;return u.jsx("div",{className:"flex min-w-fit grow flex-col overflow-auto",children:u.jsxs("div",{className:"grow",children:[h?u.jsx("div",{className:"",children:u.jsxs("div",{className:Z("flex items-end gap-1.5",{"animate-pulse":r}),children:[u.jsx("p",{style:{color:Kw(d,l)},className:"text-3xl font-semibold",children:ko({number:d,decimalPlaces:((v=(x=e.preferences)==null?void 0:x.formatNumber)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((S=(w=e.preferences)==null?void 0:w.formatNumber)!=null&&S.suffix),customSuffix:((C=(E=e.preferences)==null?void 0:E.formatNumber)==null?void 0:C.suffix)||"",locale:a()||"",currency:i()||""})}),p&&u.jsxs("div",{className:"flex items-end gap-1",children:[u.jsx(Kq,{isLowerIsBetter:(j=(_=e.preferences)==null?void 0:_.kpiVisualOptions)==null?void 0:j.lowerIsBetter,className:"",children:p}),f&&u.jsx("div",{className:"ml-0.5 mr-1 min-w-fit text-sm font-normal text-muted-foreground",children:`from ${ko({number:f,decimalPlaces:((P=(R=e.preferences)==null?void 0:R.formatNumber)==null?void 0:P.decimalPlaces)||0,useSuffix:!!((F=(M=e.preferences)==null?void 0:M.formatNumber)!=null&&F.suffix),customSuffix:((A=(I=e.preferences)==null?void 0:I.formatNumber)==null?void 0:A.suffix)||"",locale:a()||"",currency:i()||""})}`})]})]})}):u.jsx("div",{className:"flex h-9 items-center justify-center"}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs(Bi,{className:"flex items-center gap-2 text-base font-medium text-muted-foreground",children:[e.title,(s||e.info)&&u.jsx(oG,{card:e})]}),t==null?void 0:t()]})]})})}function NAe({children:e,className:t,...n}){return u.jsx(tG,{children:u.jsx(li,{children:u.jsx(mb,{...n,className:t,children:e})})})}function kAe({cardId:e}){const t=u6(e||""),n=Uo(l=>l.removeClickFiltersByValue),r=t.map((l,c)=>{const d=l.filterGroups.flatMap(f=>f.filters.map(h=>({field:h.field.label||h.field.name,value:h.value})));return{id:`click-filter-${l.sourceCardId}-${c}`,sourceCardId:l.sourceCardId,name:`Click Filter from ${l.sourceCardId}`,values:d,applyToCardIds:l.applyToCardIds,excludeCardIds:l.excludeCardIds,originalEvent:l}}),o=r.reduce((l,c)=>(c.values.forEach(d=>{var h,p;const f=l.find(m=>m.fieldName===d.field);f?f.filters.some(g=>g.values.some(y=>y.field===d.field&&y.value===d.value))||f.filters.push(c):l.push({fieldName:d.field,fieldLabel:d.field,filters:[c],targetingInfo:(h=c.applyToCardIds)!=null&&h.length?`Applied to: ${c.applyToCardIds.join(", ")}`:(p=c.excludeCardIds)!=null&&p.length?`Excluded from: ${c.excludeCardIds.join(", ")}`:"Applied to all cards"})}),l),[]);function s(l,c){const d=r.filter(f=>f.values.some(h=>h.field===l&&h.value===c));if(d.length>0){const h=d.sort((p,m)=>{const g=t.findIndex(b=>Bs(b,p.originalEvent));return t.findIndex(b=>Bs(b,m.originalEvent))-g})[0];n(h.sourceCardId,l,c)}}function i(l){const c=r.flatMap(f=>f.values.filter(h=>h.field===l)).map(f=>f.value);[...new Set(c)].forEach(f=>{s(l,f)})}function a(l){const c=l.filters.flatMap(h=>h.values.filter(p=>p.field===l.fieldName)).map(h=>h.value),d=[...new Set(c)],f=d.filter(h=>{const g=l.filters.filter(x=>x.values.some(v=>v.field===l.fieldName&&v.value===h)).sort((x,v)=>{const w=t.findIndex(E=>Bs(E,x.originalEvent));return t.findIndex(E=>Bs(E,v.originalEvent))-w})[0];return t.findIndex(x=>Bs(x,g.originalEvent))===t.length-1});return u.jsxs("div",{className:"space-y-3 rounded-lg border border-border/50 bg-muted/30 p-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"h-2 w-2 flex-shrink-0 rounded-full bg-blue-500"}),u.jsx(de,{className:"text-sm font-medium text-foreground",children:l.fieldLabel})]}),u.jsxs(ae,{variant:"ghost",size:"sm",onClick:()=>i(l.fieldName),className:"h-7 px-2.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:[u.jsx(fh,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear"]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map((h,p)=>{const m=f.includes(h);return u.jsxs(Tt,{variant:"secondary",className:`group relative ${m?"cursor-pointer border border-blue-500/20 bg-blue-500/10 text-blue-600 transition-colors hover:bg-blue-500/15":"cursor-not-allowed border border-border/30 bg-muted/50 text-muted-foreground"}`,onClick:()=>{m&&s(l.fieldName,h)},children:[h,u.jsx(Xt,{className:`ml-1.5 h-3 w-3 ${m?"opacity-60 transition-opacity group-hover:opacity-100":"cursor-not-allowed opacity-40"}`})]},p)})}),d.length>1&&u.jsx("div",{className:"text-xs text-muted-foreground",children:'Clear filters in sequence (most recent first) or use "Clear" to remove all'})]})]})}return o.length===0?null:u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(zne,{className:"h-3.5 w-3.5 text-muted-foreground"}),u.jsx("span",{className:"text-xs font-medium text-foreground",children:"Click Filters"})]}),u.jsx("div",{className:"space-y-3",children:o==null?void 0:o.map(l=>u.jsx("div",{children:a(l)},l.fieldName))})]})}function lk({cardId:e,cardFilters:t,cardFilterCount:n=0,onFiltersClick:r}){const[o,s]=N.useState(!1),i=ee(V=>V.isDashboardEditing),a=ee(V=>V.isVisualEditing),l=ee(V=>V.dashboard.defaultFilterValues),c=ee(V=>V.themeStyle),d=ee(V=>V.filterValues),f=ee(V=>V.dashboard.filters),h=ee(V=>V.filteringCards),p=ee(V=>V.selectedSheetId),m=ee(V=>V.onSaveFunction),{removeFilterValues:g,removeFilteringCard:y,setFilterValues:b,setFilteringCards:x,setDefaultFilterValues:v,getDashboard:w}=en(),{updateFilters:S,clearFilters:E}=lo(),{updateCardFilters:C,clearCardFilters:_}=en(),j=Uo(V=>V.clearAllClickFilters),R=e?hj(f,d,p,e).cardFilterValues:(()=>{const V=Qg(f,p);return d==null?void 0:d.filter(B=>(V==null?void 0:V.some(G=>G.id===B.filterId))||B.filterId.endsWith(p))})(),P=(R==null?void 0:R.map(V=>{const B=f==null?void 0:f.find(G=>G.id===V.filterId);return{filterId:V.filterId,fieldName:(B==null?void 0:B.title)||V.name,fieldLabel:(B==null?void 0:B.title)||V.name,values:V.values,dataType:B==null?void 0:B.dataType,operation:B==null?void 0:B.operation,isDateFilter:Vu((B==null?void 0:B.dataType)||"")}}))||[],M=u6(e||"");if(!a&&P.length===0&&M.length===0&&n===0)return null;const F=P.length+M.length+n;function I(V){return V instanceof Date?V.toLocaleDateString():V}function A(V){const B=h==null?void 0:h.find(G=>V.filterId.startsWith(G.id));B&&y(B),g(V.filterId)}function O(V){P.filter(G=>G.fieldName===V).forEach(G=>{A(G)})}function U(){x([]),b([]),j(),e&&a&&E(e)}function W(V){function B(){return V.values.map((X,re)=>u.jsxs(Tt,{variant:"secondary",className:"group relative cursor-pointer border border-primary/20 bg-primary/10 text-primary transition-colors hover:bg-primary/15",onClick:()=>A(V),children:[I(X),u.jsx(Xt,{className:"ml-1.5 h-3 w-3 opacity-60 transition-opacity group-hover:opacity-100"})]},(X==null?void 0:X.toString())+re))}function G(){const X=V.values[0],re=V.values[1];if(!X||!re)return null;const J=new Date(X),ue=new Date(re);return u.jsxs(Tt,{variant:"secondary",className:"group relative cursor-pointer border border-primary/20 bg-primary/10 text-primary transition-colors hover:bg-primary/15",onClick:()=>A(V),children:[`${J.toLocaleDateString()} - ${ue.toLocaleDateString()}`,u.jsx(Xt,{className:"ml-1.5 h-3 w-3 opacity-60 transition-opacity group-hover:opacity-100"})]})}return u.jsxs("div",{className:"group space-y-3 rounded-lg border border-border/50 bg-muted/30 p-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de,{className:"text-sm font-medium text-foreground",children:V.fieldLabel}),!V.isDateFilter&&V.operation==="not in"&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Lv(V.operation)})]}),u.jsx(ae,{variant:"ghost",size:"sm",onClick:()=>O(V.fieldName),className:"h-6 w-6 p-0 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100","aria-label":"Clear filter",children:u.jsx(Xt,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.isDateFilter?G():B()})]})}function $(V){return{"=":"equals","!=":"not equals",">":"greater than",">=":"greater than or equals","<":"less than","<=":"less than or equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",in:"in","not in":"not in",between:"between",isNull:"is null",isNotNull:"is not null"}[V]||V}function T(V){return Array.isArray(V.value)?V.operator==="between"?`${V.value[0]} and ${V.value[1]}`:V.value.join(", "):V.value instanceof Date?V.value.toLocaleDateString():String(V.value||"")}function z(V){if(!t||!e)return;const B=X=>({...X,conditions:X.conditions.filter(re=>re.id!==V),groups:X.groups.map(B)}),G=B(t);a?S(e,G):C(e,G)}function L(){e&&(a?E(e):_(e))}function D(V){const B=[...V.conditions];return V.groups.forEach(G=>{B.push(...D(G))}),B}function H(){if(!t)return null;const V=D(t);return V.length===0?null:u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Card Filters"}),a&&u.jsxs(ae,{variant:"ghost",size:"sm",onClick:L,className:"h-7 px-2.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:[u.jsx(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear All"]})]}),u.jsx("div",{className:"space-y-3",children:V.map(B=>u.jsxs("div",{className:"group space-y-3 rounded-lg border border-blue-200/50 bg-blue-50/30 p-3 dark:border-blue-800/50 dark:bg-blue-950/30",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de,{className:"text-sm font-medium text-foreground",children:B.field.label||B.field.name}),u.jsx("span",{className:"text-xs text-muted-foreground",children:$(B.operator)})]}),a&&u.jsx(ae,{variant:"ghost",size:"sm",onClick:()=>z(B.id),className:"h-6 w-6 p-0 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100","aria-label":"Clear filter",children:u.jsx(Xt,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.jsx(Tt,{variant:"secondary",className:"border border-blue-300/30 bg-blue-100/50 text-blue-900 dark:border-blue-700/30 dark:bg-blue-900/50 dark:text-blue-100",children:T(B)})})]},B.id))})]})}function q(V){const B=w();B&&(m==null||m(B,V))}function Y(){return u.jsxs(u.Fragment,{children:[u.jsx(Wi,{className:"my-4"}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:"Start with these filters? Set them as default."}),u.jsxs("div",{className:"flex flex-row-reverse gap-2",children:[u.jsxs(ae,{onClick:()=>{v(d||[]),q("Default filters saved successfully")},style:{borderRadius:c==null?void 0:c.controlInputRadius},className:"h-8 text-xs font-medium",variant:"outline",children:[l&&(l==null?void 0:l.length)>0&&u.jsx(_r,{className:"mr-1.5 h-3.5 w-3.5 text-green-500"}),"Set Default"]}),u.jsx(ae,{onClick:()=>{v(void 0),q("Default filters cleared")},style:{borderRadius:c==null?void 0:c.controlInputRadius},className:"h-8 text-xs font-medium",variant:"secondary",children:"Reset"})]})]})]})}return u.jsxs(E1,{open:o,onOpenChange:s,openDelay:50,children:[u.jsx(N1,{asChild:!0,children:u.jsxs("div",{className:"flex h-7 cursor-pointer items-center gap-1.5 rounded-md border border-border bg-background px-2.5 py-1.5 transition-all hover:border-border/60 hover:bg-muted",onClick:V=>{V.stopPropagation(),s(!1),r==null||r()},children:[u.jsx(Fd,{className:"h-3.5 w-3.5 text-muted-foreground"}),F>0&&u.jsx("span",{className:"text-xs font-medium text-foreground",children:F})]})}),u.jsx(NAe,{onMouseDown:V=>V.stopPropagation(),style:{borderRadius:c==null?void 0:c.cardBorderRadius},className:"w-[380px] border border-border/50 p-0 text-xs shadow-lg",align:"start",children:F===0?u.jsxs("div",{className:"p-6 text-center",children:[u.jsx(Fd,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground/50"}),u.jsx("p",{className:"text-sm font-medium text-foreground",children:"No filters applied"}),u.jsx("p",{className:"mb-4 mt-1 text-xs text-muted-foreground",children:"Add filters to narrow down your data"}),u.jsxs(ae,{variant:"outline",size:"sm",onClick:V=>{V.stopPropagation(),s(!1),r==null||r()},className:"mx-auto",children:[u.jsx(Fd,{className:"mr-2 h-3.5 w-3.5"}),"Add Filters"]})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-b border-border/50 bg-muted/30 px-4 py-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Fd,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm font-medium text-foreground",children:"Active Filters"}),u.jsx(Tt,{variant:"secondary",className:"text-xs font-medium",children:F})]}),u.jsxs(ae,{variant:"ghost",size:"sm",onClick:U,className:"h-7 px-2.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:[u.jsx(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear All"]})]})}),u.jsxs("div",{className:"space-y-4 p-4",children:[u.jsxs("div",{className:"max-h-[280px] space-y-4 overflow-y-auto",children:[P.length>0&&u.jsxs("div",{className:"space-y-3",children:[u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Dashboard Filters"}),u.jsx("div",{className:"space-y-3",children:P==null?void 0:P.map(V=>u.jsx("div",{children:W(V)},V.filterId))})]}),u.jsx(kAe,{cardId:e}),H()]}),i&&Y()]})]})})]})}const av=e=>{if(!e)return 0;let t=e.conditions.length;return e.groups.forEach(n=>{t+=av(n)}),t};function ck(e,t){const{function:n,rowLevel:r,columnLevel:o}=e,s={...t};if(r!==void 0){const i=s.rowAggregates||[],a=r==="all"?"ALL":r,l=i.findIndex(c=>c.groupLevel===a&&c.function===n);l>=0?s.rowAggregates=i.filter((c,d)=>d!==l):s.rowAggregates=[...i,{function:n,groupLevel:a}]}if(o!==void 0){const i=s.columnAggregates||[],a=o==="all"?"ALL":o,l=i.findIndex(c=>c.pivotLevel===a&&c.function===n);l>=0?s.columnAggregates=i.filter((c,d)=>d!==l):s.columnAggregates=[...i,{function:n,pivotLevel:a}]}return s}function sG(e,t){const n={...t};return e.type==="row"&&n.rowAggregates?n.rowAggregates=n.rowAggregates.map(r=>r.function===e.function&&r.groupLevel===e.level?{...r,label:e.label}:r):e.type==="column"&&n.columnAggregates&&(n.columnAggregates=n.columnAggregates.map(r=>r.function===e.function&&r.pivotLevel===e.level?{...r,label:e.label}:r)),n}const ur=e=>O7(new Date,e),_Ae=()=>[{label:"Last 7 days",value:e=>{const t=ur(e);return{from:Tc(t,7),to:t}},category:"day"},{label:"Last 30 days",value:e=>{const t=ur(e);return{from:Tc(t,30),to:t}},category:"day"},{label:"Last 90 days",value:e=>{const t=ur(e);return{from:Tc(t,90),to:t}},category:"day"},{label:"This week",value:e=>({from:Di(ur(e)),to:Up(ur(e))}),category:"week"},{label:"Last week",value:e=>{const t=ur(e),n=Tc(t,7);return{from:Di(n),to:Up(n)}},category:"week"},{label:"Last 2 weeks",value:e=>{const t=ur(e);return{from:Tc(t,14),to:t}},category:"week"},{label:"This month",value:e=>({from:Vp(ur(e)),to:of(ur(e))}),category:"month"},{label:"Last month",value:e=>{const t=ur(e);return{from:Vp(qp(t,1)),to:of(qp(t,1))}},category:"month"},{label:"Last 12 months",value:e=>{const t=ur(e);return{from:qp(t,12),to:t}},category:"month"},{label:"This quarter",value:e=>({from:sf(ur(e)),to:Wp(ur(e))}),category:"quarter"},{label:"Last quarter",value:e=>{const t=ur(e);return{from:sf(Gp(t,1)),to:Wp(Gp(t,1))}},category:"quarter"},{label:"Last 4 quarters",value:e=>{const t=ur(e);return{from:sf(Gp(t,4)),to:t}},category:"quarter"},{label:"This year",value:e=>({from:af(ur(e)),to:Hp(ur(e))}),category:"year"},{label:"Last year",value:e=>{const t=ur(e);return{from:af(xx(t,1)),to:Hp(xx(t,1))}},category:"year"}],U5=[{label:"2 days ago",value:-2},{label:"yesterday",value:-1},{label:"today",value:0},{label:"tomorrow",value:1},{label:"2 days ahead",value:2}],W5=[{label:"2 years ago",value:-2},{label:"last year",value:-1},{label:"this year",value:0},{label:"next year",value:1},{label:"2 years ahead",value:2}],q5=[{label:"2 quarters ago",value:-2},{label:"last quarter",value:-1},{label:"this quarter",value:0},{label:"next quarter",value:1},{label:"2 quarters ahead",value:2}],G5=[{label:"2 months ago",value:-2},{label:"last month",value:-1},{label:"this month",value:0},{label:"next month",value:1},{label:"2 months ahead",value:2}],Y5=[{label:"2 weeks ago",value:-2},{label:"last week",value:-1},{label:"this week",value:0},{label:"next week",value:1},{label:"2 weeks ahead",value:2}];function iG({value:e,onChange:t,placeholder:n="All time",className:r,timezone:o,showRelativeTab:s=!0,disabled:i=!1,buttonClassName:a,contentClassName:l}){const[c,d]=N.useState(!1),[f,h]=N.useState("static"),[p,m]=N.useState(!1),[g,y]=N.useState(!1),[b,x]=N.useState("Days"),[v,w]=N.useState("0"),[S,E]=N.useState("0"),[C,_]=N.useState(void 0),j=Intl.DateTimeFormat().resolvedOptions().timeZone,R=o||j,P=N.useMemo(()=>_Ae(),[]),M=()=>{if(e!=null&&e.from&&(e!=null&&e.to)){const T=cN(e.from,R,"MMM dd, yyyy"),z=cN(e.to,R,"MMM dd, yyyy");return`${T} - ${z}`}return n},F=T=>{const z=T.value(R);t==null||t(z),d(!1)},I=()=>{t==null||t(void 0),d(!1)},A=(T,z)=>{if(!z)return;const L=T==="from"?z:C==null?void 0:C.from,D=T==="to"?z:C==null?void 0:C.to;_({from:L,to:D}),T==="from"?m(!1):y(!1)},O=()=>{C!=null&&C.from&&(C!=null&&C.to)&&(t==null||t(C),d(!1))},U=()=>{_(e)},W=()=>{const T=ur(R),z=parseInt(v),L=parseInt(S);let D,H;b==="Days"?(D=z===0?Bp(T):z>0?Bp(mx(T,z)):Bp(Tc(T,Math.abs(z))),H=L===0?C0(T):L>0?C0(mx(T,L)):C0(Tc(T,Math.abs(L)))):b==="Weeks"?(D=z===0?Di(T):z>0?Di(iN(T,z)):Di(PA(T,Math.abs(z))),H=L===0?Up(T):L>0?Up(iN(T,L)):Up(PA(T,Math.abs(L)))):b==="Months"?(D=z===0?Vp(T):z>0?Vp(Tm(T,z)):Vp(qp(T,Math.abs(z))),H=L===0?of(T):L>0?of(Tm(T,L)):of(qp(T,Math.abs(L)))):b==="Quarters"?(D=z===0?sf(T):z>0?sf(sN(T,z)):sf(Gp(T,Math.abs(z))),H=L===0?Wp(T):L>0?Wp(sN(T,L)):Wp(Gp(T,Math.abs(L)))):(D=z===0?af(T):z>0?af(aN(T,z)):af(xx(T,Math.abs(z))),H=L===0?Hp(T):L>0?Hp(aN(T,L)):Hp(xx(T,Math.abs(L)))),t==null||t({from:D,to:H}),d(!1)},$=T=>{d(T),T&&_(e)};return u.jsx("div",{className:Z("w-full",r),children:u.jsxs(qs,{open:c,onOpenChange:$,children:[u.jsx(Gs,{asChild:!0,children:u.jsxs(ae,{variant:"outline",className:Z("h-10 w-full justify-between text-left font-normal",a),title:`Timezone: ${wx(R)} (${zd(R)})`,disabled:i,children:[u.jsx("span",{className:"text-sm",children:M()}),u.jsxs("div",{className:"flex items-center gap-1",children:[R!==j&&u.jsx(gE,{className:"h-3 w-3 opacity-50"}),u.jsx(No,{className:"h-4 w-4 opacity-50"})]})]})}),u.jsxs(Ys,{className:Z("z-[51] w-[320px] p-0",l),align:"start",children:[R!==j&&u.jsxs("div",{className:"flex items-center gap-1 border-b bg-muted/50 px-3 py-1.5 text-xs text-muted-foreground",children:[u.jsx(gE,{className:"h-3 w-3"}),u.jsxs("span",{children:["Using ",wx(R)," timezone"]})]}),u.jsxs(di,{value:f,onValueChange:T=>{h(T),T==="static"&&_(e)},className:"w-full",children:[s&&u.jsx("div",{className:"border-b",children:u.jsxs(Rs,{className:"grid h-9 w-full grid-cols-2 rounded-none bg-transparent",children:[u.jsx(Ln,{value:"static",className:"rounded-none text-sm data-[state=active]:border-b-2 data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"Static"}),u.jsx(Ln,{value:"relative",className:"rounded-none text-sm data-[state=active]:border-b-2 data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"Relative"})]})}),u.jsx(xr,{value:"static",className:"mt-0",children:u.jsxs("div",{className:"space-y-3 p-3",children:[u.jsx(ae,{variant:"outline",onClick:I,className:"h-9 w-full justify-center",children:"All time"}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(de,{className:"text-xs text-muted-foreground",children:"Custom range"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("div",{className:"relative flex-1",children:u.jsxs(qs,{open:p,onOpenChange:m,children:[u.jsx(Gs,{asChild:!0,children:u.jsxs(ae,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[u.jsx(Ss,{className:"mr-2 h-4 w-4"}),C!=null&&C.from?Hs(C.from,"MM/dd/yyyy"):"From date"]})}),u.jsx(Ys,{className:"z-[52] w-auto p-0",align:"start",children:u.jsx(ng,{mode:"single",selected:C==null?void 0:C.from,captionLayout:"dropdown",onSelect:T=>A("from",T)})})]})}),u.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),u.jsx("div",{className:"relative flex-1",children:u.jsxs(qs,{open:g,onOpenChange:y,children:[u.jsx(Gs,{asChild:!0,children:u.jsxs(ae,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[u.jsx(Ss,{className:"mr-2 h-4 w-4"}),C!=null&&C.to?Hs(C.to,"MM/dd/yyyy"):"To date"]})}),u.jsx(Ys,{className:"z-[52] w-auto p-0",align:"start",children:u.jsx(ng,{mode:"single",selected:C==null?void 0:C.to,captionLayout:"dropdown",onSelect:T=>A("to",T)})})]})})]}),((C==null?void 0:C.from)||(C==null?void 0:C.to))&&u.jsxs("div",{className:"flex gap-2 pt-1",children:[u.jsx(ae,{size:"sm",variant:"outline",className:"h-8 flex-1",onClick:U,children:"Cancel"}),u.jsx(ae,{size:"sm",className:"h-8 flex-1",disabled:!(C!=null&&C.from)||!(C!=null&&C.to),onClick:O,children:"Apply"})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(de,{className:"text-xs text-muted-foreground",children:"Quick select"}),u.jsx(Yi,{className:"h-[240px] w-full",children:u.jsx("div",{className:"space-y-1",children:["day","week","month","quarter","year"].map(T=>u.jsxs("div",{className:"mt-2 space-y-1",children:[u.jsx(de,{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:T}),P.filter(z=>z.category===T).map(z=>u.jsx("button",{onClick:()=>F(z),className:"w-full rounded px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:z.label},z.label))]},T))})})]})]})}),s&&u.jsx(xr,{value:"relative",className:"mt-0",children:u.jsxs("div",{className:"space-y-3 p-3",children:[u.jsx("div",{className:"flex gap-1 rounded-md bg-muted p-1",children:["Days","Weeks","Months","Quarters","Years"].map(T=>u.jsx("button",{onClick:()=>x(T),className:Z("flex-1 rounded px-2 py-1 text-xs transition-colors",b===T?"bg-background shadow-sm":"hover:bg-background/50"),children:T},T))}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsxs(Dt,{value:v,onValueChange:w,children:[u.jsx(_t,{className:"h-9",children:u.jsx(Ft,{placeholder:"From"})}),u.jsx(jt,{className:"z-[51]",children:(b==="Years"?W5:b==="Quarters"?q5:b==="Months"?G5:b==="Weeks"?Y5:U5).map(z=>u.jsx(ve,{value:z.value.toString(),children:z.label},z.value))})]})}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),u.jsx("div",{className:"flex-1",children:u.jsxs(Dt,{value:S,onValueChange:E,children:[u.jsx(_t,{className:"h-9",children:u.jsx(Ft,{placeholder:"To"})}),u.jsx(jt,{className:"z-[51]",children:(b==="Years"?W5:b==="Quarters"?q5:b==="Months"?G5:b==="Weeks"?Y5:U5).map(z=>u.jsx(ve,{value:z.value.toString(),children:z.label},z.value))})]})})]}),u.jsx("div",{className:"pt-2",children:u.jsx(ae,{onClick:W,size:"sm",className:"h-8 w-full",children:"Apply"})})]})})]})]})]})})}function FM(e){const{authToken:t,tokenProps:n}=qe(),r=ee(S=>S.authToken),o=t||r,s=ee(S=>S.dashboard.filters),i=ee(S=>S.selectedSheetId),a=ee(S=>S.filterValues),[l,c]=N.useState(!0),d=Qg(s,i),f=a==null?void 0:a.filter(S=>(d==null?void 0:d.some(E=>E.id===S.filterId))||S.filterId.endsWith(i));function h(S){return l?{allowQuery:!0,filterValues:S.filter(_=>_.filterId!==e.id)}:(S==null?void 0:S.find(C=>C.filterId===e.id))?{allowQuery:!1,filterValues:S}:{allowQuery:!0,filterValues:S}}const{allowQuery:p,filterValues:m}=h(f||[]),{data:g,isLoading:y,isFetching:b,isError:x,refetch:v,isSuccess:w}=yn({queryKey:["filter",e.id,e.sql,JSON.stringify(m)],queryFn:()=>a3(`${n.apiServiceUrl}/v1/query`,(o==null?void 0:o.accessToken)||"",{connection_id:e.connectionId,sql:e.sql,active_filters:m,cache_config:l_({filter:e})}),enabled:!!e.sql&&!!e.connectionId&&p&&!!(o!=null&&o.accessToken),placeholderData:S=>S});return N.useEffect(()=>{w&&l&&c(!1)},[w,l]),{data:g,isLoading:y,isFetching:b,isError:x,refetch:v}}function aG(e,t){const[n,r]=N.useState(t),[o,s]=N.useState(),i=N.useMemo(()=>t,[t]);return N.useEffect(()=>{if(e&&(e==null?void 0:e.length)>0){const a=e[0];if(!a.min||!a.max)return;const l={from:new Date(a.min),to:new Date(a.max)};s(l),i||r(l)}},[e,i]),N.useEffect(()=>{i&&r(i)},[i]),{dateRange:n,setDateRange:r,initialDateRange:o,setInitialDateRange:s}}function jAe(e){const t=ee(o=>{var s,i;return(i=(s=o.dashboard)==null?void 0:s.filters)==null?void 0:i.find(a=>a.id===e)}),{setDateRange:n,...r}=lG(t||{});return r}function lG(e){const t=ee(g=>g.filterValues),n=ee(g=>g.actions.addOrUpdateFilterValue),{removeFilterValues:r}=en(),{data:o,isLoading:s,isFetching:i,isError:a}=FM(e),l=N.useMemo(()=>{var g;if(t){const y=t.find(b=>b.filterId===e.id);if(y&&((g=y.values)==null?void 0:g.length)===2){const[b,x]=y.values;return{from:b?new Date(b):void 0,to:x?new Date(x):void 0}}}},[t,e.id]),{dateRange:c,setDateRange:d,initialDateRange:f}=aG(o==null?void 0:o.records,l);function h(){r(e.id),d(void 0)}function p(){d(f)}function m(g){if(!g)return;let y=[g==null?void 0:g.from,g==null?void 0:g.to];g.from&&g.to===void 0?y=[g.from,gx(g.from,24)]:g.from&&g.to&&g.from.getTime()===g.to.getTime()?y=[g.from,gx(g.to,24)]:y=[g.from,g.to],d({from:y[0],to:y[1]});const b={filterId:e.id,connectionType:e.database==="NA"?"api":"database",valueType:Xd(e),name:e.column,operation:"between",values:y};n(b)}return{records:o==null?void 0:o.records,isLoading:s,isFetching:i,isError:a,initialDateRange:f,dateRange:c,setDateRange:d,handleClear:h,handleChange:m,handleReset:p}}function RAe({filter:e,className:t}){var g;const{tokenProps:n}=qe(),r=(g=n==null?void 0:n.params)==null?void 0:g.timeZone,{records:o,dateRange:s,isLoading:i,isFetching:a,isError:l,setDateRange:c,handleChange:d,handleClear:f}=lG(e),h=ee(y=>y.filterValues),p=h==null?void 0:h.some(y=>y.filterId===e.id);if(i||a)return u.jsx("div",{children:u.jsx($a,{className:"h-8 w-full bg-foreground/10"})});if(l)return u.jsx("div",{className:"h-8 w-full bg-muted px-2",children:"Error"});if(!o)return u.jsx(de,{className:"flex h-8 w-full items-center bg-muted px-2",children:"No Data"});const m=y=>{if(!y){f();return}let b=[y==null?void 0:y.from,y==null?void 0:y.to];y.from&&y.to===void 0?b=[y.from,gx(y.from,24)]:y.from&&y.to&&y.from.getTime()===y.to.getTime()?b=[y.from,gx(y.to,24)]:b=[y.from,y.to],c({from:b[0],to:b[1]}),d({from:b[0],to:b[1]})};return u.jsx(iG,{value:p?s:void 0,buttonClassName:"h-8",onChange:m,timezone:r,showRelativeTab:!0,className:t,placeholder:"All time"})}function MAe(e){const t=/(>=|<=|>|<|=)/,n=e.match(t);if(n){const r=n[0],[o,s]=e.split(r);return{operation:r,value:s.trim()}}else return null}function DAe(e,t,n){const r=`SELECT ${n}, COUNT(*) FROM ${t} {{ filters | where }} GROUP BY ${n} ORDER BY ${n} ASC LIMIT 50`,o=`SELECT min(${n}) as min, max(${n}) as max FROM ${t} {{ filters | where }}`;return Vu(e)?o:r}function PAe(e){const t=ee(s=>{var i,a;return(a=(i=s==null?void 0:s.dashboard)==null?void 0:i.filters)==null?void 0:a.find(l=>l.id===e)}),{query:n,setQuery:r,...o}=$M(t||{});return o}function $M(e){const[t,n]=N.useState([]),[r,o]=N.useState(""),s=ee(E=>E.filterValues),i=ee(E=>E.selectedSheetId),{addOrUpdateFilterValue:a,removeFilterValues:l}=en(),{data:c,isLoading:d,isFetching:f,isError:h}=FM(e),p=N.useMemo(()=>{var C;return e.column?(C=c==null?void 0:c.records)==null?void 0:C.map((_,j)=>{let R=e.column.split(".").slice(-1)[0].replace(/"/g,"");return _[R]===void 0&&(R=R.toLowerCase()),{id:`${e.id}-${j}`,value:_[R]}}):[]},[c,e.column,e.id]);N.useEffect(()=>{if(s){const E=s.find(C=>C.filterId===e.id);if(!E){n([]);return}if(E.operation==="in"){const C=p==null?void 0:p.filter(_=>E.values.includes(_.value));C&&n(C)}}},[c,i,s,e.id,p]),N.useEffect(()=>{if(s&&!s.find(C=>C.filterId===e.id)){n([]);return}},[s,e.id]);function m(E){const C=MAe(E[0].toString());if(!(C!=null&&C.value)||!(C!=null&&C.operation))return;const _={filterId:e.id,connectionType:e.database==="NA"?"api":"database",valueType:Xd(e),name:e.column,operation:C.operation,values:[Number(C.value)]};a(_)}function g(E){if(Array.isArray(E)||(E=[E]),E.length===1&&p.find(_=>_.value===E[0].value)===void 0){m(E);return}if(n(E),E.length===0){l(e.id);return}const C={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:Xd(e),operation:e.operation,values:E.map(_=>_.value)};a(C)}function y(){n([]),l(e.id)}function b(E){if(E){n(p);const C={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:Xd(e),operation:e.operation,values:p.map(_=>_.value)};a(C)}else y()}function x(){if(Object.keys(e).length===0||jg(e.dataType))return p;const E=r.toLowerCase().replace(/\s+/g,"");return r===""?p:p.filter(C=>C.value.toLowerCase().replace(/\s+/g,"").includes(E))}const v=x(),w=e.type==="single",S=t.length===(p==null?void 0:p.length);return{isLoading:d,isFetching:f,isError:h,records:p,selectedRecords:t,handleChange:g,handleClear:y,handleSelectAll:b,query:r,setQuery:o,filteredRecords:v,isSingleSelect:w,allSelected:S}}const cG=typeof document<"u"?N.useLayoutEffect:()=>{};function TAe(e){const t=N.useRef(null);return cG(()=>{t.current=e},[e]),N.useCallback((...n)=>{const r=t.current;return r==null?void 0:r(...n)},[])}const gb=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},Hc=e=>e&&"window"in e&&e.window===e?e:gb(e).defaultView||window;function AAe(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function IAe(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function uG(e){let t=null;return()=>(t==null&&(t=e()),t)}const OAe=uG(function(){return IAe(/^Mac/i)}),FAe=uG(function(){return AAe(/Android/i)});function $Ae(e){return e.mozInputSource===0&&e.isTrusted?!0:FAe()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}class LAe{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(t,n){this.nativeEvent=n,this.target=n.target,this.currentTarget=n.currentTarget,this.relatedTarget=n.relatedTarget,this.bubbles=n.bubbles,this.cancelable=n.cancelable,this.defaultPrevented=n.defaultPrevented,this.eventPhase=n.eventPhase,this.isTrusted=n.isTrusted,this.timeStamp=n.timeStamp,this.type=t}}function dG(e){let t=N.useRef({isFocused:!1,observer:null});cG(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let n=TAe(r=>{e==null||e(r)});return N.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let o=r.target,s=i=>{t.current.isFocused=!1,o.disabled&&n(new LAe("blur",i)),t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};o.addEventListener("focusout",s,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&o.disabled){var i;(i=t.current.observer)===null||i===void 0||i.disconnect();let a=o===document.activeElement?null:document.activeElement;o.dispatchEvent(new FocusEvent("blur",{relatedTarget:a})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:a}))}}),t.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[n])}function zAe(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:o}=e;const s=N.useCallback(l=>{if(l.target===l.currentTarget)return r&&r(l),o&&o(!1),!0},[r,o]),i=dG(s),a=N.useCallback(l=>{const c=gb(l.target);l.target===l.currentTarget&&c.activeElement===l.target&&(n&&n(l),o&&o(!0),i(l))},[o,n,i]);return{focusProps:{onFocus:!t&&(n||o||r)?a:void 0,onBlur:!t&&(r||o)?s:void 0}}}let bb=null,uk=new Set,cm=new Map,Ou=!1,dk=!1;const BAe={Tab:!0,Escape:!0};function LM(e,t){for(let n of uk)n(e,t)}function VAe(e){return!(e.metaKey||!OAe()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function lv(e){Ou=!0,VAe(e)&&(bb="keyboard",LM("keyboard",e))}function hs(e){bb="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(Ou=!0,LM("pointer",e))}function fG(e){$Ae(e)&&(Ou=!0,bb="virtual")}function hG(e){e.target===window||e.target===document||(!Ou&&!dk&&(bb="virtual",LM("virtual",e)),Ou=!1,dk=!1)}function pG(){Ou=!1,dk=!0}function fk(e){if(typeof window>"u"||cm.get(Hc(e)))return;const t=Hc(e),n=gb(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){Ou=!0,r.apply(this,arguments)},n.addEventListener("keydown",lv,!0),n.addEventListener("keyup",lv,!0),n.addEventListener("click",fG,!0),t.addEventListener("focus",hG,!0),t.addEventListener("blur",pG,!1),typeof PointerEvent<"u"?(n.addEventListener("pointerdown",hs,!0),n.addEventListener("pointermove",hs,!0),n.addEventListener("pointerup",hs,!0)):(n.addEventListener("mousedown",hs,!0),n.addEventListener("mousemove",hs,!0),n.addEventListener("mouseup",hs,!0)),t.addEventListener("beforeunload",()=>{mG(e)},{once:!0}),cm.set(t,{focus:r})}const mG=(e,t)=>{const n=Hc(e),r=gb(e);t&&r.removeEventListener("DOMContentLoaded",t),cm.has(n)&&(n.HTMLElement.prototype.focus=cm.get(n).focus,r.removeEventListener("keydown",lv,!0),r.removeEventListener("keyup",lv,!0),r.removeEventListener("click",fG,!0),n.removeEventListener("focus",hG,!0),n.removeEventListener("blur",pG,!1),typeof PointerEvent<"u"?(r.removeEventListener("pointerdown",hs,!0),r.removeEventListener("pointermove",hs,!0),r.removeEventListener("pointerup",hs,!0)):(r.removeEventListener("mousedown",hs,!0),r.removeEventListener("mousemove",hs,!0),r.removeEventListener("mouseup",hs,!0)),cm.delete(n))};function HAe(e){const t=gb(e);let n;return t.readyState!=="loading"?fk(e):(n=()=>{fk(e)},t.addEventListener("DOMContentLoaded",n)),()=>mG(e,n)}typeof document<"u"&&HAe();function gG(){return bb!=="pointer"}const UAe=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function WAe(e,t,n){var r;const o=typeof window<"u"?Hc(n==null?void 0:n.target).HTMLInputElement:HTMLInputElement,s=typeof window<"u"?Hc(n==null?void 0:n.target).HTMLTextAreaElement:HTMLTextAreaElement,i=typeof window<"u"?Hc(n==null?void 0:n.target).HTMLElement:HTMLElement,a=typeof window<"u"?Hc(n==null?void 0:n.target).KeyboardEvent:KeyboardEvent;return e=e||(n==null?void 0:n.target)instanceof o&&!UAe.has(n==null||(r=n.target)===null||r===void 0?void 0:r.type)||(n==null?void 0:n.target)instanceof s||(n==null?void 0:n.target)instanceof i&&(n==null?void 0:n.target.isContentEditable),!(e&&t==="keyboard"&&n instanceof a&&!BAe[n.key])}function qAe(e,t,n){fk(),N.useEffect(()=>{let r=(o,s)=>{WAe(!!(n!=null&&n.isTextInput),o,s)&&e(gG())};return uk.add(r),()=>{uk.delete(r)}},t)}function GAe(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:o}=e,s=N.useRef({isFocusWithin:!1}),i=N.useCallback(c=>{s.current.isFocusWithin&&!c.currentTarget.contains(c.relatedTarget)&&(s.current.isFocusWithin=!1,n&&n(c),o&&o(!1))},[n,o,s]),a=dG(i),l=N.useCallback(c=>{!s.current.isFocusWithin&&document.activeElement===c.target&&(r&&r(c),o&&o(!0),s.current.isFocusWithin=!0,a(c))},[r,o,a]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:l,onBlur:i}}}let cv=!1,n2=0;function hk(){cv=!0,setTimeout(()=>{cv=!1},50)}function Z5(e){e.pointerType==="touch"&&hk()}function YAe(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Z5):document.addEventListener("touchend",hk),n2++,()=>{n2--,!(n2>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",Z5):document.removeEventListener("touchend",hk))}}function bG(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,isDisabled:o}=e,[s,i]=N.useState(!1),a=N.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;N.useEffect(YAe,[]);let{hoverProps:l,triggerHoverEnd:c}=N.useMemo(()=>{let d=(p,m)=>{if(a.pointerType=m,o||m==="touch"||a.isHovered||!p.currentTarget.contains(p.target))return;a.isHovered=!0;let g=p.currentTarget;a.target=g,t&&t({type:"hoverstart",target:g,pointerType:m}),n&&n(!0),i(!0)},f=(p,m)=>{if(a.pointerType="",a.target=null,m==="touch"||!a.isHovered)return;a.isHovered=!1;let g=p.currentTarget;r&&r({type:"hoverend",target:g,pointerType:m}),n&&n(!1),i(!1)},h={};return typeof PointerEvent<"u"?(h.onPointerEnter=p=>{cv&&p.pointerType==="mouse"||d(p,p.pointerType)},h.onPointerLeave=p=>{!o&&p.currentTarget.contains(p.target)&&f(p,p.pointerType)}):(h.onTouchStart=()=>{a.ignoreEmulatedMouseEvents=!0},h.onMouseEnter=p=>{!a.ignoreEmulatedMouseEvents&&!cv&&d(p,"mouse"),a.ignoreEmulatedMouseEvents=!1},h.onMouseLeave=p=>{!o&&p.currentTarget.contains(p.target)&&f(p,"mouse")}),{hoverProps:h,triggerHoverEnd:f}},[t,n,r,o,a]);return N.useEffect(()=>{o&&c({currentTarget:a.target},a.pointerType)},[o]),{hoverProps:l,isHovered:s}}function yG(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,o=N.useRef({isFocused:!1,isFocusVisible:t||gG()}),[s,i]=N.useState(!1),[a,l]=N.useState(()=>o.current.isFocused&&o.current.isFocusVisible),c=N.useCallback(()=>l(o.current.isFocused&&o.current.isFocusVisible),[]),d=N.useCallback(p=>{o.current.isFocused=p,i(p),c()},[c]);qAe(p=>{o.current.isFocusVisible=p,c()},[],{isTextInput:n});let{focusProps:f}=zAe({isDisabled:r,onFocusChange:d}),{focusWithinProps:h}=GAe({isDisabled:!r,onFocusWithinChange:d});return{isFocused:s,isFocusVisible:a,focusProps:r?h:f}}var ZAe=Object.defineProperty,KAe=(e,t,n)=>t in e?ZAe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,r2=(e,t,n)=>(KAe(e,typeof t!="symbol"?t+"":t,n),n);let XAe=class{constructor(){r2(this,"current",this.detect()),r2(this,"handoffState","pending"),r2(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},gu=new XAe;function yb(e){return gu.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function xG(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function Ki(){let e=[],t={addEventListener(n,r,o,s){return n.addEventListener(r,o,s),t.add(()=>n.removeEventListener(r,o,s))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return xG(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,o){let s=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:o}),this.add(()=>{Object.assign(n.style,{[r]:s})})},group(n){let r=Ki();return n(r),this.add(()=>r.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let n of e.splice(0))n()}};return t}function xb(){let[e]=N.useState(Ki);return N.useEffect(()=>()=>e.dispose(),[e]),e}let zn=(e,t)=>{gu.isServer?N.useEffect(e,t):N.useLayoutEffect(e,t)};function od(e){let t=N.useRef(e);return zn(()=>{t.current=e},[e]),t}let ut=function(e){let t=od(e);return N.useCallback((...n)=>t.current(...n),[t])};function QAe(e){let t=e.width/2,n=e.height/2;return{top:e.clientY-n,right:e.clientX+t,bottom:e.clientY+n,left:e.clientX-t}}function JAe(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function eIe({disabled:e=!1}={}){let t=N.useRef(null),[n,r]=N.useState(!1),o=xb(),s=ut(()=>{t.current=null,r(!1),o.dispose()}),i=ut(a=>{if(o.dispose(),t.current===null){t.current=a.currentTarget,r(!0);{let l=yb(a.currentTarget);o.addEventListener(l,"pointerup",s,!1),o.addEventListener(l,"pointermove",c=>{if(t.current){let d=QAe(c);r(JAe(d,t.current.getBoundingClientRect()))}},!1),o.addEventListener(l,"pointercancel",s,!1)}}});return{pressed:n,pressProps:e?{}:{onPointerDown:i,onPointerUp:s,onClick:s}}}let tIe=N.createContext(void 0);function zM(){return N.useContext(tIe)}function K5(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function Va(e,t,...n){if(e in t){let o=t[e];return typeof o=="function"?o(...n):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Va),r}var pk=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(pk||{}),nIe=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(nIe||{});function hi(){let e=oIe();return N.useCallback(t=>rIe({mergeRefs:e,...t}),[e])}function rIe({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:o,visible:s=!0,name:i,mergeRefs:a}){a=a??sIe;let l=vG(t,e);if(s)return Ky(l,n,r,i,a);let c=o??0;if(c&2){let{static:d=!1,...f}=l;if(d)return Ky(f,n,r,i,a)}if(c&1){let{unmount:d=!0,...f}=l;return Va(d?0:1,{0(){return null},1(){return Ky({...f,hidden:!0,style:{display:"none"}},n,r,i,a)}})}return Ky(l,n,r,i,a)}function Ky(e,t={},n,r,o){let{as:s=n,children:i,refName:a="ref",...l}=o2(e,["unmount","static"]),c=e.ref!==void 0?{[a]:e.ref}:{},d=typeof i=="function"?i(t):i;"className"in l&&l.className&&typeof l.className=="function"&&(l.className=l.className(t)),l["aria-labelledby"]&&l["aria-labelledby"]===l.id&&(l["aria-labelledby"]=void 0);let f={};if(t){let h=!1,p=[];for(let[m,g]of Object.entries(t))typeof g=="boolean"&&(h=!0),g===!0&&p.push(m.replace(/([A-Z])/g,y=>`-${y.toLowerCase()}`));if(h){f["data-headlessui-state"]=p.join(" ");for(let m of p)f[`data-${m}`]=""}}if(s===N.Fragment&&(Object.keys(Mc(l)).length>0||Object.keys(Mc(f)).length>0))if(!N.isValidElement(d)||Array.isArray(d)&&d.length>1){if(Object.keys(Mc(l)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Mc(l)).concat(Object.keys(Mc(f))).map(h=>` - ${h}`).join(`
|
|
877
|
+
Defaulting to \`null\`.`}const Yq=Wq,cAe=sAe,AM=k.forwardRef(({className:e,value:t,...n},r)=>u.jsx(Yq,{ref:r,className:Z("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:u.jsx(cAe,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));AM.displayName=Yq.displayName;function ak({primaryValue:e,secondaryValue:t,comparisonConfig:n,locale:r,currency:o,decimalPlaces:s=0,suffix:i,lowerIsBetter:a=!1}){const{calculationType:l="difference",formatOptions:c,showArrow:d=!0,showColor:f=!0,conditionalLabel:h=!1,labelName:p,conditionalLabels:m}=n,g=(c==null?void 0:c.type)||"auto",b=(()=>{if(g==="auto"||!c)return{decimalPlaces:s??0,suffix:i??"",prefix:"",useSuffix:!1,currency:o||"USD",locale:(c==null?void 0:c.locale)||r};const R=g==="currency"?2:g==="percent"?1:0;return{decimalPlaces:c.decimalPlaces??R,suffix:c.suffix??"",prefix:c.prefix??"",useSuffix:c.useSuffix??!1,currency:c.currency||o||"USD",locale:c.locale||r,negativeInParentheses:c.negativeInParentheses??!1,multiplyBy:c.multiplyBy}})();let x=0,v="";switch(l){case"difference":x=e-t;break;case"change":x=t!==0?(e-t)/t*100:0;break;case"change_difference":x=t!==0?(e-t)/t*100:0;break;case"ratio":x=t!==0?e/t:0;break}const w=(R,P=!1)=>{const M=Math.abs(R),F=P&&R>=0?"+":R<0?"-":"";if(g==="percent"){const O=b.multiplyBy?M*b.multiplyBy:M;return`${F}${O.toFixed(b.decimalPlaces)}%`}if(g==="currency"){const O=ko({number:M,decimalPlaces:b.decimalPlaces,useSuffix:b.useSuffix,customSuffix:"",locale:b.locale,currency:b.currency});return P&&R>=0?`+${O}`:R<0?`-${O}`:O}if(g==="scientific")return`${F}${M.toExponential(b.decimalPlaces)}`;const I=ko({number:M,decimalPlaces:b.decimalPlaces,useSuffix:b.useSuffix,customSuffix:b.suffix,locale:b.locale,currency:""}),A=b.prefix?`${b.prefix}${I}`:I;return b.negativeInParentheses&&R<0?`(${A})`:`${F}${A}`};if(l==="difference")v=w(x,!0);else if(l==="change")v=`${x>=0?"+":""}${Math.abs(x).toFixed(b.decimalPlaces)}%`;else if(l==="change_difference"){const R=e-t,P=x>=0?"+":"",M=Math.abs(x).toFixed(b.decimalPlaces),F=w(R,!0);v=`${P}${M}% (${F})`}else l==="ratio"&&(v=`${(x*100).toFixed(b.decimalPlaces)}%`);let S="text-gray-600",E={};if(f){const{colorConfig:R}=n,P=(M,F)=>M?M==="green"?"text-green-600":M==="red"?"text-red-600":M==="neutral"?"text-gray-600":M.startsWith("#")?(E={color:M},""):F:F;if(l==="ratio"){const M=x*100;M>=100?S=P(R==null?void 0:R.increase,"text-green-600"):M>=80?S="text-yellow-600":S=P(R==null?void 0:R.decrease,"text-red-600")}else x>0?a?S=P(R==null?void 0:R.increase,"text-red-600"):S=P(R==null?void 0:R.increase,"text-green-600"):x<0?a?S=P(R==null?void 0:R.decrease,"text-green-600"):S=P(R==null?void 0:R.decrease,"text-red-600"):S=P(R==null?void 0:R.noChange,"text-gray-600")}let C=null;d&&(l==="ratio"?C=null:x>0?C=Bo:x<0?C=zs:C=kne);let _="";return h?x>0?_=(m==null?void 0:m.increase)||"Increase":x<0?_=(m==null?void 0:m.decrease)||"Decrease":_=(m==null?void 0:m.noChange)||"No change":p&&(_=p),u.jsxs("div",{className:"inline-flex flex-col items-center",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[d&&C&&u.jsx(C,{className:`h-3 w-3 ${S}`,style:E}),u.jsx("div",{className:`text-sm font-semibold ${S}`,style:E,children:v})]}),_&&u.jsx("span",{className:"text-[10px] text-muted-foreground/70 mt-0.5 text-center",children:_}),!1]})}function Zq(e){const t=ee(f=>f.isDashboardEditing),n=ee(f=>f.isVisualEditing),r=ee(f=>f.selectedSheetId),{setCardTitle:o,setCardKpiOptions:s}=ee(f=>f.actions),{setCardTitle:i,setCountryLogo:a}=lo();return{setTitle:f=>{n?i(f):t&&r&&o(r,e.id,f)},setCountryLogo:f=>{n?a(f):t&&r&&s(r,e.id,{countryLogoId:f||void 0})},isEditable:t||n,isDashboardEditing:t,isVisualEditing:n}}function uAe({card:e,data:t,isPending:n}){var R,P,M,F,I,A,O,U,W,$,T,z,L,D,H,q,Y,V,B,G,X,re,J,ue,te,se,oe,Ne,fe,ye,Pe,it,Ve,We,vn,Rn,ie,be,Me,Be,Ze,Ct,sn,zt,Gt,xe,xt,An;const r=e.config,{setTitle:o,setCountryLogo:s,isEditable:i,isVisualEditing:a}=Zq(e),{setValueAlignment:l}=lo(),{getCurrency:c,getLocale:d}=v1(e),f=(r==null?void 0:r.metricColumns)||[],h=(M=(P=(R=e.preferences)==null?void 0:R.kpiVisualOptions)==null?void 0:P.metricComparison)==null?void 0:M.enabled,p=(le,me=!1)=>{var Fe,Ye,et,Vt,Rt,Ht,Xn,un,In,mi,Zr,Mo,gi,sl;const je=(Ye=(Fe=e.preferences)==null?void 0:Fe.formatNumber)==null?void 0:Ye.enabled,Ce=(Vt=(et=e.preferences)==null?void 0:et.kpiVisualOptions)==null?void 0:Vt.formatOptions;if(je===!1||je==="false")return le.toString();if(Ce!=null&&Ce.type&&Ce.type!=="auto")return iu(le,Ce.type,{...Ce,useSuffix:me?!0:Ce.useSuffix,locale:Ce.locale||d()||"en-US",currency:Ce.currency||c()||"USD"});const Re=c()||((Ht=(Rt=e.preferences)==null?void 0:Rt.formatNumber)==null?void 0:Ht.currency)||"",ze=d()||((un=(Xn=e.preferences)==null?void 0:Xn.formatNumber)==null?void 0:un.locale)||"en-US",Ie=(mi=(In=e.preferences)==null?void 0:In.formatNumber)==null?void 0:mi.decimalPlaces;return ko({number:le,decimalPlaces:Ie??(Re?2:0),useSuffix:me||!!((Mo=(Zr=e.preferences)==null?void 0:Zr.formatNumber)!=null&&Mo.suffix),customSuffix:((sl=(gi=e.preferences)==null?void 0:gi.formatNumber)==null?void 0:sl.suffix)||"",locale:ze,currency:Re})},m=le=>p(le,!0);let g=0,y=0,b=0;if(t&&t.length>0){const le=t[0];if(le&&f.length>0){const me=Object.keys(le),je=f[0];let Ce=me.find(Re=>Re===je.label||Re===je.name||Re.includes(je.name)||je.label&&Re.includes(je.label));if(!Ce&&me.length>0&&(Ce=me[0]),g=Ce&&le[Ce]||0,f.length>1){const Re=f[1];let ze=me.find(Ie=>Ie===Re.label||Ie===Re.name||Ie.includes(Re.name)||Re.label&&Ie.includes(Re.label));!ze&&me.length>1&&(ze=me[1]),y=ze&&le[ze]||0}if(f.length>2){const Re=f[2];let ze=me.find(Ie=>Ie===Re.label||Ie===Re.name||Ie.includes(Re.name)||Re.label&&Ie.includes(Re.label));!ze&&me.length>2&&(ze=me[2]),b=ze&&le[ze]||0}}}const x=(I=(F=e.preferences)==null?void 0:F.kpiVisualOptions)==null?void 0:I.lowerIsBetter,v=((O=(A=e.preferences)==null?void 0:A.kpiVisualOptions)==null?void 0:O.valueAlignment)||"center",w=(W=(U=e.preferences)==null?void 0:U.formatNumber)==null?void 0:W.colorRanges,S=Kw(g,w),E=(T=($=e.preferences)==null?void 0:$.kpiVisualOptions)==null?void 0:T.countryLogoId,C=N.useMemo(()=>Wd.find(le=>le.id===E),[E]),_=le=>{s(le)};if(n)return u.jsxs(Li,{className:"grow border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[C&&u.jsx("span",{className:"text-2xl",title:C.name,children:C.flag}),u.jsx(Bi,{className:"text-sm font-medium text-gray-600",children:e.title})]})}),u.jsx(Wa,{children:u.jsxs("div",{className:"animate-pulse",children:[u.jsx("div",{className:"mb-2 h-8 rounded bg-muted"}),e.description&&u.jsx("div",{className:"h-4 w-3/4 rounded bg-muted"})]})})]});function j(){return e.title?e.title:i?"Enter title":""}return u.jsxs(Li,{className:"flex grow flex-col border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[i?u.jsx(Bq,{selectedCountryId:E||void 0,onCountrySelect:_,size:"sm",showRegionBadges:!0,maxDisplayResults:20}):C&&u.jsx("span",{className:"text-2xl",title:C.name,children:C.flag}),u.jsx(Bi,{className:"text-base font-medium text-gray-600",children:u.jsx(Oi,{displayClassName:"text-base font-medium text-gray-600",inputClassName:"text-base font-medium text-gray-600",value:j(),isEditable:i,onSave:o})})]})}),u.jsxs(Wa,{className:"w-full grow pb-4",children:[h&&f.length>=2?u.jsxs("div",{className:"space-y-4",children:[((D=(L=(z=e.preferences)==null?void 0:z.kpiVisualOptions)==null?void 0:L.metricComparison)==null?void 0:D.position)==="top"?u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsx("div",{children:u.jsx("div",{className:"text-3xl font-bold tabular-nums",style:{color:S},children:((H=e==null?void 0:e.kpiPreferences)==null?void 0:H.format)==="compact"?m(g):p(g)})}),u.jsx("div",{className:"text-right",children:u.jsx(ak,{primaryValue:g,secondaryValue:y,comparisonConfig:((Y=(q=e.preferences)==null?void 0:q.kpiVisualOptions)==null?void 0:Y.metricComparison)||{},locale:d()||"en-US",currency:c(),decimalPlaces:(B=(V=e.preferences)==null?void 0:V.formatNumber)==null?void 0:B.decimalPlaces,suffix:(X=(G=e.preferences)==null?void 0:G.formatNumber)==null?void 0:X.suffix,lowerIsBetter:x})})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:[u.jsx("div",{className:"text-3xl font-bold tabular-nums",style:{color:S},children:((re=e==null?void 0:e.kpiPreferences)==null?void 0:re.format)==="compact"?m(g):p(g)}),!1]}),u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsx("div",{className:`flex flex-col ${((te=(ue=(J=e.preferences)==null?void 0:J.kpiVisualOptions)==null?void 0:ue.metricComparison)==null?void 0:te.position)==="right"?"order-2 items-end":"order-1 items-start"}`,children:u.jsx(ak,{primaryValue:g,secondaryValue:y,comparisonConfig:((oe=(se=e.preferences)==null?void 0:se.kpiVisualOptions)==null?void 0:oe.metricComparison)||{},locale:d()||"en-US",currency:c(),decimalPlaces:(fe=(Ne=e.preferences)==null?void 0:Ne.formatNumber)==null?void 0:fe.decimalPlaces,suffix:(Pe=(ye=e.preferences)==null?void 0:ye.formatNumber)==null?void 0:Pe.suffix,lowerIsBetter:x})}),u.jsxs("div",{className:`flex flex-col ${((We=(Ve=(it=e.preferences)==null?void 0:it.kpiVisualOptions)==null?void 0:Ve.metricComparison)==null?void 0:We.position)==="right"?"order-1 items-start":"order-2 items-end"}`,children:[u.jsx("div",{className:"text-xl font-semibold tabular-nums text-muted-foreground",children:p(y)}),u.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:((vn=f[1])==null?void 0:vn.label)||((Rn=f[1])==null?void 0:Rn.name)})]})]})]}),((Me=(be=(ie=e.preferences)==null?void 0:ie.kpiVisualOptions)==null?void 0:be.metricComparison)==null?void 0:Me.position)==="top"&&u.jsxs("div",{children:[u.jsx("div",{className:"text-xl font-semibold tabular-nums text-muted-foreground",children:p(y)}),u.jsx("span",{className:"text-xs text-muted-foreground",children:((Be=f[1])==null?void 0:Be.label)||((Ze=f[1])==null?void 0:Ze.name)})]}),f.length>2&&b!==0&&u.jsx("div",{className:"border-t pt-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-xs text-muted-foreground",children:((Ct=f[2])==null?void 0:Ct.label)||((sn=f[2])==null?void 0:sn.name)}),u.jsx("div",{className:"text-sm font-semibold tabular-nums",children:p(b)})]})})]}):u.jsxs("div",{className:`flex flex-col ${v==="left"?"items-start":"items-center justify-center"} space-y-4`,children:[u.jsx("div",{className:v==="left"?"":"text-center",children:u.jsx("div",{className:"text-3xl font-bold",style:{color:S},children:((zt=e==null?void 0:e.kpiPreferences)==null?void 0:zt.format)==="compact"?m(g):p(g)})}),f.length>1&&y>0&&u.jsxs("div",{className:v==="left"?"":"text-center",children:[u.jsx("div",{className:"text-xl font-semibold text-muted-foreground",children:p(y)}),u.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:((Gt=f[1])==null?void 0:Gt.label)||((xe=f[1])==null?void 0:xe.name)})]}),f.length>2&&b>0&&u.jsxs("div",{className:v==="left"?"":"text-center",children:[u.jsx("div",{className:"text-lg font-medium text-muted-foreground",children:p(b)}),u.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:((xt=f[2])==null?void 0:xt.label)||((An=f[2])==null?void 0:An.name)})]})]}),a&&!h&&u.jsx("div",{className:"mt-4 flex justify-end",children:u.jsxs(Fh,{pressed:v==="left",className:"h-7",variant:"outline",onPressedChange:le=>l(le?"left":"center"),children:[v==="left"?u.jsx(Nne,{className:"mr-2 h-4 w-4"}):u.jsx(Ene,{className:"mr-2 h-4 w-4"}),u.jsx("span",{children:v==="left"?"Left aligned":"Center aligned"})]})})]})]})}function dAe({card:e,data:t,isPending:n}){var T,z,L,D,H,q,Y,V,B,G,X,re,J,ue,te,se,oe,Ne;const{setTitle:r,setCountryLogo:o,isEditable:s,isVisualEditing:i}=Zq(e),{setCardDescription:a,setLowerIsBetter:l}=lo(),{getCurrency:c,getLocale:d}=v1(e),f=(z=(T=e.preferences)==null?void 0:T.kpiVisualOptions)==null?void 0:z.countryLogoId,h=N.useMemo(()=>Wd.find(fe=>fe.id===f),[f]),p=e.config,m=(p==null?void 0:p.groupByColumns)&&p.groupByColumns.length>0,g=(p==null?void 0:p.metricColumns)&&p.metricColumns.length>0;if(!m&&g)return u.jsx(uAe,{card:e,data:t,isPending:n});const y=(fe,ye=!1)=>{var it,Ve,We,vn,Rn,ie,be,Me;const Pe=(Ve=(it=e.preferences)==null?void 0:it.kpiVisualOptions)==null?void 0:Ve.formatOptions;return Pe!=null&&Pe.type&&Pe.type!=="auto"?iu(fe,Pe.type,{...Pe,useSuffix:ye?!0:Pe.useSuffix,locale:Pe.locale||d()||"en-US",currency:Pe.currency||c()||"USD"}):ko({number:fe,decimalPlaces:((vn=(We=e.preferences)==null?void 0:We.formatNumber)==null?void 0:vn.decimalPlaces)||0,useSuffix:ye?!0:!!((ie=(Rn=e.preferences)==null?void 0:Rn.formatNumber)!=null&&ie.suffix),customSuffix:((Me=(be=e.preferences)==null?void 0:be.formatNumber)==null?void 0:Me.suffix)||"",locale:d()||"en-US",currency:c()||""})},b=fe=>y(fe,!0),x=((L=t==null?void 0:t.find(fe=>fe.segment==="current"))==null?void 0:L.value)||0,v=((D=t==null?void 0:t.find(fe=>fe.segment==="comparison"))==null?void 0:D.value)||0,w=((H=e.config)==null?void 0:H.comparisonType)||"none",S=(Y=(q=e.preferences)==null?void 0:q.kpiVisualOptions)==null?void 0:Y.lowerIsBetter,E=(B=(V=e.preferences)==null?void 0:V.kpiVisualOptions)==null?void 0:B.metricComparison,C=m&&(E==null?void 0:E.enabled)&&v!==0,_=(G=e.config)==null?void 0:G.targetValue,j=typeof x=="number"&&!isNaN(x)?x:0,R=typeof _=="number"&&!isNaN(_)?_:0,P=R>0?Math.min(j/R,1):0,M=R>0?Math.max(R-j,0):0,F=R>0?Math.max(j-R,0):0,I=m&&w==="target"&&R>0,A=m&&(w==="previous_period"||w==="same_period_last_year"),O=(re=(X=e.preferences)==null?void 0:X.formatNumber)==null?void 0:re.colorRanges,U=Kw(x,O),W=fe=>{o(fe)};if(n){const fe=e.description;return u.jsxs(Li,{className:"grow border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[h&&u.jsx("span",{className:"text-2xl",title:h.name,children:h.flag}),u.jsx(Bi,{className:"text-sm font-medium text-gray-600",children:e.title})]})}),u.jsx(Wa,{children:u.jsxs("div",{className:"animate-pulse",children:[u.jsx("div",{className:"mb-2 h-8 rounded bg-muted"}),fe&&u.jsx("div",{className:"h-4 w-3/4 rounded bg-muted"})]})})]})}function $(){return e.title?e.title:s?"Enter title":""}return u.jsx(ed,{children:u.jsxs(Li,{className:"group flex grow flex-col border-none shadow-none",children:[u.jsx(zi,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:u.jsxs("div",{className:"flex items-center gap-2",children:[s?u.jsx(Bq,{selectedCountryId:f||void 0,onCountrySelect:W,size:"sm",showRegionBadges:!0,maxDisplayResults:20}):h&&u.jsx("span",{className:"text-2xl",title:h.name,children:h.flag}),u.jsx(Bi,{className:"text-base font-medium text-gray-600",children:u.jsx(Oi,{displayClassName:"text-base font-medium text-gray-600",inputClassName:"text-base font-medium text-gray-600",value:$(),isEditable:s,onSave:r})})]})}),u.jsxs(Wa,{className:"w-full grow pb-4",children:[u.jsxs("div",{className:"flex items-baseline space-x-2",children:[u.jsx("div",{className:"text-2xl font-bold",style:{color:U},children:((J=e==null?void 0:e.kpiPreferences)==null?void 0:J.format)==="compact"?b(x):y(x)}),C&&u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(ak,{primaryValue:x,secondaryValue:v,comparisonConfig:E||{},locale:d()||"en-US",currency:c(),decimalPlaces:(te=(ue=e.preferences)==null?void 0:ue.formatNumber)==null?void 0:te.decimalPlaces,suffix:(oe=(se=e.preferences)==null?void 0:se.formatNumber)==null?void 0:oe.suffix,lowerIsBetter:S}),u.jsxs(oi,{children:[u.jsx(si,{asChild:!0,children:u.jsx(uh,{className:"h-3 w-3 cursor-pointer text-muted-foreground opacity-0 transition-all hover:text-foreground group-hover:opacity-100"})}),u.jsx(qTe,{currentValue:x,comparisonValue:v,percentageChange:(x-v)/v*100,isPositive:S?x<v:x>v,data:t,formatCurrency:y,showTrendline:((Ne=e.config)==null?void 0:Ne.showTrendline)||!1})]})]})]}),I&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[u.jsxs("div",{className:"text-base text-gray-400",children:["Target: ",y(R)]}),u.jsxs("div",{className:"text-lg font-semibold text-gray-900",children:[Math.round(P*100),"%"]})]}),u.jsx(AM,{style:{width:`${Math.round(P*100)}%`,backgroundColor:U},value:Math.round(P*100),className:"h-2"}),u.jsx("div",{className:"mt-2 text-sm text-gray-400",children:j>=R?F>0?`${y(F)} above target`:"Target reached!":`${y(M)} remaining to reach target`})]}),u.jsx("div",{className:"mt-1",children:u.jsx(Oi,{isEditable:i,value:e.description||(i?"Enter description":""),placeholder:i?"No value":"",displayClassName:"text-sm text-gray-500",inputClassName:"text-sm text-gray-500",onSave:a})}),i&&u.jsx("div",{className:"mt-2 flex items-center justify-end gap-1",children:A&&u.jsxs(Fh,{pressed:S===!0,className:"h-7",variant:"outline",onPressedChange:fe=>l(fe),children:[S?u.jsx(mL,{className:"mr-2 h-4 w-4"}):u.jsx(Q0,{className:"mr-2 h-4 w-4"}),u.jsx("span",{children:S?"Lower is better":"Higher is better"})]})})]})]})})}const rv=e=>e.config&&typeof e.config=="object"&&Object.keys(e.config).length>0;function fAe({card:e,data:t,isPending:n}){var E,C,_,j,R,P,M,F,I,A,O,U,W,$,T,z,L,D;const r=ee(H=>H.actions.setCardTitle),o=ee(H=>H.actions.setCardDescription),s=ee(H=>H.isVisualEditing),i=Ae(H=>H.card),a=Ae(H=>H.actions.setCard);Ae(H=>H.actions.setNumberFormat);const{getCurrency:l,getLocale:c}=v1(e),d=ee(H=>H.selectedSheetId),f=(C=(E=e.preferences)==null?void 0:E.formatNumber)==null?void 0:C.colorRanges,{keys:h}=Jn(t),p=(_=t==null?void 0:t[0])==null?void 0:_[h==null?void 0:h[0]],m=(j=t==null?void 0:t[0])==null?void 0:j[h==null?void 0:h[1]],g=t&&t.length>0;function y(H){s?a({...i,title:H}):r(d,e.id,H)}function b(H){s?a({...i,description:H}):o(d,e.id,H)}const x=m&&m-p!==0?(p-m)/m:null,v=ko({number:p,decimalPlaces:((P=(R=e.preferences)==null?void 0:R.formatNumber)==null?void 0:P.decimalPlaces)||0,useSuffix:!!((F=(M=e.preferences)==null?void 0:M.formatNumber)!=null&&F.suffix),customSuffix:((A=(I=e.preferences)==null?void 0:I.formatNumber)==null?void 0:A.suffix)||"",locale:c()||"",currency:l()||""});let w="";m&&(w=ko({number:m,decimalPlaces:((U=(O=e.preferences)==null?void 0:O.formatNumber)==null?void 0:U.decimalPlaces)||0,useSuffix:!!(($=(W=e.preferences)==null?void 0:W.formatNumber)!=null&&$.suffix),customSuffix:((z=(T=e.preferences)==null?void 0:T.formatNumber)==null?void 0:z.suffix)||"",locale:c()||"",currency:l()||""}));const S=Kw(p,f);return u.jsx(hAe,{isPending:n,title:e.title,formattedCurrentValue:v,formattedPreviousValue:w,description:e.description,valueColor:S,onTitleChange:y,onDescriptionChange:b,percentDifference:x,isLowerIsBetter:(D=(L=e.preferences)==null?void 0:L.kpiVisualOptions)==null?void 0:D.lowerIsBetter,show:g})}function ov({card:e,data:t,isPending:n}){return rv(e)?u.jsx("div",{className:"flex h-full min-h-0 grow overflow-auto",children:u.jsx(dAe,{card:e,data:t,isPending:n})}):u.jsx(fAe,{card:e,data:t,isPending:n})}function hAe({title:e,formattedCurrentValue:t,formattedPreviousValue:n,description:r,valueColor:o,onTitleChange:s,onDescriptionChange:i,percentDifference:a,show:l,isPending:c,isLowerIsBetter:d}){const f=ee(g=>g.isDashboardEditing),h=ee(g=>g.isVisualEditing),p=Ae(g=>g.card);Ae(g=>g.actions.setCard);let m=r||"";return h&&(m=r||"from description"),u.jsxs("div",{className:"kpi-card flex grow flex-col overflow-auto",children:[u.jsxs(zi,{className:"grow pb-3",children:[u.jsx(rg,{className:"text-base font-medium tracking-tight text-muted-foreground",enabled:f,text:h?p.title:e,onSave:s,children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx(Bi,{className:"text-base font-medium text-muted-foreground",children:e})})}),c&&u.jsxs("div",{className:"space-y-2",children:[u.jsx($a,{className:"h-4 w-3/4"}),u.jsx($a,{className:"h-4 w-1/2"})]}),l&&u.jsxs("div",{className:"2 flex flex-wrap items-end text-foreground",children:[u.jsx("p",{style:{color:o},className:"text-3xl font-semibold",children:t}),n&&u.jsxs("span",{className:"min-w-fit -translate-y-[1px] text-base font-normal text-muted-foreground",children:[" from ",n]})]})]}),a&&u.jsxs("div",{className:"flex grow items-center gap-1 px-6 pb-4 text-sm",children:[u.jsx(Kq,{isLowerIsBetter:d,children:a}),u.jsxs("div",{className:"flex gap-1 text-muted-foreground",children:[a>0?"up ":"down ",u.jsx(rg,{enabled:f,text:m,onSave:i,children:m})]}),h&&u.jsx("div",{className:"ml-auto",children:u.jsx(pAe,{})})]})]})}function Kq({children:e,className:t,isLowerIsBetter:n}){const r=ee(a=>a.themeStyle),o=e>0?u.jsx("span",{children:"+"}):u.jsx("span",{children:"-"}),s=`${Math.abs(e*100).toFixed(0)}%`,i=n?e<0:e>0;return u.jsxs("div",{style:{borderRadius:(r==null?void 0:r.controlInputRadius)||"2px"},className:Z("flex items-center px-1 text-sm font-semibold",{"bg-green-600/10 text-green-600":i,"bg-destructive/10 text-destructive":!i},t),children:[o,u.jsx("span",{className:"ml-[1px]",children:s})]})}function pAe(){const e=Ae(n=>{var r,o;return(o=(r=n.card.preferences)==null?void 0:r.kpiVisualOptions)==null?void 0:o.lowerIsBetter}),{setLowerIsBetter:t}=lo();return u.jsx("div",{className:"flex items-center gap-1",children:u.jsx(Fh,{pressed:e===!0,className:"h-7",variant:"outline",onPressedChange:n=>t(n),children:u.jsx("span",{children:"Lower is better"})})})}var t2,IM="HoverCard",[Xq,MXe]=mr(IM,[ia]),S1=ia(),[mAe,C1]=Xq(IM),Qq=e=>{const{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:s,openDelay:i=700,closeDelay:a=300}=e,l=S1(t),c=k.useRef(0),d=k.useRef(0),f=k.useRef(!1),h=k.useRef(!1),[p=!1,m]=Rr({prop:r,defaultProp:o,onChange:s}),g=k.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>m(!0),i)},[i,m]),y=k.useCallback(()=>{clearTimeout(c.current),!f.current&&!h.current&&(d.current=window.setTimeout(()=>m(!1),a))},[a,m]),b=k.useCallback(()=>m(!1),[m]);return k.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),u.jsx(mAe,{scope:t,open:p,onOpenChange:m,onOpen:g,onClose:y,onDismiss:b,hasSelectionRef:f,isPointerDownOnContentRef:h,children:u.jsx(Sh,{...l,children:n})})};Qq.displayName=IM;var Jq="HoverCardTrigger",eG=k.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=C1(Jq,n),s=S1(n);return u.jsx(Ch,{asChild:!0,...s,children:u.jsx(Te.a,{"data-state":o.open?"open":"closed",...r,ref:t,onPointerEnter:we(e.onPointerEnter,iv(o.onOpen)),onPointerLeave:we(e.onPointerLeave,iv(o.onClose)),onFocus:we(e.onFocus,o.onOpen),onBlur:we(e.onBlur,o.onClose),onTouchStart:we(e.onTouchStart,i=>i.preventDefault())})})});eG.displayName=Jq;var OM="HoverCardPortal",[gAe,bAe]=Xq(OM,{forceMount:void 0}),tG=e=>{const{__scopeHoverCard:t,forceMount:n,children:r,container:o}=e,s=C1(OM,t);return u.jsx(gAe,{scope:t,forceMount:n,children:u.jsx(Zn,{present:n||s.open,children:u.jsx(Ku,{asChild:!0,container:o,children:r})})})};tG.displayName=OM;var sv="HoverCardContent",nG=k.forwardRef((e,t)=>{const n=bAe(sv,e.__scopeHoverCard),{forceMount:r=n.forceMount,...o}=e,s=C1(sv,e.__scopeHoverCard);return u.jsx(Zn,{present:r||s.open,children:u.jsx(yAe,{"data-state":s.open?"open":"closed",...o,onPointerEnter:we(e.onPointerEnter,iv(s.onOpen)),onPointerLeave:we(e.onPointerLeave,iv(s.onClose)),ref:t})})});nG.displayName=sv;var yAe=k.forwardRef((e,t)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,...a}=e,l=C1(sv,n),c=S1(n),d=k.useRef(null),f=ot(t,d),[h,p]=k.useState(!1);return k.useEffect(()=>{if(h){const m=document.body;return t2=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=t2,m.style.webkitUserSelect=t2}}},[h]),k.useEffect(()=>{if(d.current){const m=()=>{p(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var y;((y=document.getSelection())==null?void 0:y.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",m),()=>{document.removeEventListener("pointerup",m),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),k.useEffect(()=>{d.current&&wAe(d.current).forEach(g=>g.setAttribute("tabindex","-1"))}),u.jsx(Zu,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:we(s,m=>{m.preventDefault()}),onDismiss:l.onDismiss,children:u.jsx(Gg,{...c,...a,onPointerDown:we(a.onPointerDown,m=>{m.currentTarget.contains(m.target)&&p(!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)"}})})}),xAe="HoverCardArrow",vAe=k.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=S1(n);return u.jsx(Yg,{...o,...r,ref:t})});vAe.displayName=xAe;function iv(e){return t=>t.pointerType==="touch"?void 0:e()}function wAe(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}var SAe=Qq,CAe=eG,rG=nG;const E1=SAe,N1=CAe,mb=k.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>u.jsx(rG,{ref:o,align:t,sideOffset:n,className:Z("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}));mb.displayName=rG.displayName;function oG({card:e}){const t=ee(r=>r.isDashboardEditing),{setCardInfo:n}=en();return u.jsxs(E1,{openDelay:0,children:[u.jsx(N1,{children:u.jsx(uh,{className:"size-4 text-muted-foreground/40"})}),u.jsx(mb,{align:"start",className:"w-[300px] text-sm text-muted-foreground",onMouseDown:r=>r.stopPropagation(),children:u.jsx(rg,{enabled:t,type:"textarea",text:e.info||"",onSave:r=>n(e.id,r),children:e.info||"Describe what this card shows"})})]})}function EAe({card:e,renderFilterInfo:t}){var m,g,y,b,x,v,w,S,E,C,_,j,R,P,M,F,I,A;ee(O=>O.themeStyle);const{data:n,isLoading:r}=Ga(e),o=(n==null?void 0:n.records)||[],s=ee(O=>O.isDashboardEditing),{getCurrency:i,getLocale:a}=v1(e),l=(g=(m=e.preferences)==null?void 0:m.formatNumber)==null?void 0:g.colorRanges,{keys:c}=Jn(o||[]),d=(y=o==null?void 0:o[0])==null?void 0:y[c==null?void 0:c[0]],f=(b=o==null?void 0:o[0])==null?void 0:b[c==null?void 0:c[1]],h=(o==null?void 0:o.length)>0,p=f&&f-d!==0?(d-f)/f:null;return u.jsx("div",{className:"flex min-w-fit grow flex-col overflow-auto",children:u.jsxs("div",{className:"grow",children:[h?u.jsx("div",{className:"",children:u.jsxs("div",{className:Z("flex items-end gap-1.5",{"animate-pulse":r}),children:[u.jsx("p",{style:{color:Kw(d,l)},className:"text-3xl font-semibold",children:ko({number:d,decimalPlaces:((v=(x=e.preferences)==null?void 0:x.formatNumber)==null?void 0:v.decimalPlaces)||0,useSuffix:!!((S=(w=e.preferences)==null?void 0:w.formatNumber)!=null&&S.suffix),customSuffix:((C=(E=e.preferences)==null?void 0:E.formatNumber)==null?void 0:C.suffix)||"",locale:a()||"",currency:i()||""})}),p&&u.jsxs("div",{className:"flex items-end gap-1",children:[u.jsx(Kq,{isLowerIsBetter:(j=(_=e.preferences)==null?void 0:_.kpiVisualOptions)==null?void 0:j.lowerIsBetter,className:"",children:p}),f&&u.jsx("div",{className:"ml-0.5 mr-1 min-w-fit text-sm font-normal text-muted-foreground",children:`from ${ko({number:f,decimalPlaces:((P=(R=e.preferences)==null?void 0:R.formatNumber)==null?void 0:P.decimalPlaces)||0,useSuffix:!!((F=(M=e.preferences)==null?void 0:M.formatNumber)!=null&&F.suffix),customSuffix:((A=(I=e.preferences)==null?void 0:I.formatNumber)==null?void 0:A.suffix)||"",locale:a()||"",currency:i()||""})}`})]})]})}):u.jsx("div",{className:"flex h-9 items-center justify-center"}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs(Bi,{className:"flex items-center gap-2 text-base font-medium text-muted-foreground",children:[e.title,(s||e.info)&&u.jsx(oG,{card:e})]}),t==null?void 0:t()]})]})})}function NAe({children:e,className:t,...n}){return u.jsx(tG,{children:u.jsx(li,{children:u.jsx(mb,{...n,className:t,children:e})})})}function kAe({cardId:e}){const t=u6(e||""),n=Uo(l=>l.removeClickFiltersByValue),r=t.map((l,c)=>{const d=l.filterGroups.flatMap(f=>f.filters.map(h=>({field:h.field.label||h.field.name,value:h.value})));return{id:`click-filter-${l.sourceCardId}-${c}`,sourceCardId:l.sourceCardId,name:`Click Filter from ${l.sourceCardId}`,values:d,applyToCardIds:l.applyToCardIds,excludeCardIds:l.excludeCardIds,originalEvent:l}}),o=r.reduce((l,c)=>(c.values.forEach(d=>{var h,p;const f=l.find(m=>m.fieldName===d.field);f?f.filters.some(g=>g.values.some(y=>y.field===d.field&&y.value===d.value))||f.filters.push(c):l.push({fieldName:d.field,fieldLabel:d.field,filters:[c],targetingInfo:(h=c.applyToCardIds)!=null&&h.length?`Applied to: ${c.applyToCardIds.join(", ")}`:(p=c.excludeCardIds)!=null&&p.length?`Excluded from: ${c.excludeCardIds.join(", ")}`:"Applied to all cards"})}),l),[]);function s(l,c){const d=r.filter(f=>f.values.some(h=>h.field===l&&h.value===c));if(d.length>0){const h=d.sort((p,m)=>{const g=t.findIndex(b=>Bs(b,p.originalEvent));return t.findIndex(b=>Bs(b,m.originalEvent))-g})[0];n(h.sourceCardId,l,c)}}function i(l){const c=r.flatMap(f=>f.values.filter(h=>h.field===l)).map(f=>f.value);[...new Set(c)].forEach(f=>{s(l,f)})}function a(l){const c=l.filters.flatMap(h=>h.values.filter(p=>p.field===l.fieldName)).map(h=>h.value),d=[...new Set(c)],f=d.filter(h=>{const g=l.filters.filter(x=>x.values.some(v=>v.field===l.fieldName&&v.value===h)).sort((x,v)=>{const w=t.findIndex(E=>Bs(E,x.originalEvent));return t.findIndex(E=>Bs(E,v.originalEvent))-w})[0];return t.findIndex(x=>Bs(x,g.originalEvent))===t.length-1});return u.jsxs("div",{className:"space-y-3 rounded-lg border border-border/50 bg-muted/30 p-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"h-2 w-2 flex-shrink-0 rounded-full bg-blue-500"}),u.jsx(de,{className:"text-sm font-medium text-foreground",children:l.fieldLabel})]}),u.jsxs(ae,{variant:"ghost",size:"sm",onClick:()=>i(l.fieldName),className:"h-7 px-2.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:[u.jsx(fh,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear"]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.map((h,p)=>{const m=f.includes(h);return u.jsxs(Tt,{variant:"secondary",className:`group relative ${m?"cursor-pointer border border-blue-500/20 bg-blue-500/10 text-blue-600 transition-colors hover:bg-blue-500/15":"cursor-not-allowed border border-border/30 bg-muted/50 text-muted-foreground"}`,onClick:()=>{m&&s(l.fieldName,h)},children:[h,u.jsx(Xt,{className:`ml-1.5 h-3 w-3 ${m?"opacity-60 transition-opacity group-hover:opacity-100":"cursor-not-allowed opacity-40"}`})]},p)})}),d.length>1&&u.jsx("div",{className:"text-xs text-muted-foreground",children:'Clear filters in sequence (most recent first) or use "Clear" to remove all'})]})]})}return o.length===0?null:u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(zne,{className:"h-3.5 w-3.5 text-muted-foreground"}),u.jsx("span",{className:"text-xs font-medium text-foreground",children:"Click Filters"})]}),u.jsx("div",{className:"space-y-3",children:o==null?void 0:o.map(l=>u.jsx("div",{children:a(l)},l.fieldName))})]})}function lk({cardId:e,cardFilters:t,cardFilterCount:n=0,onFiltersClick:r}){const[o,s]=N.useState(!1),i=ee(V=>V.isDashboardEditing),a=ee(V=>V.isVisualEditing),l=ee(V=>V.dashboard.defaultFilterValues),c=ee(V=>V.themeStyle),d=ee(V=>V.filterValues),f=ee(V=>V.dashboard.filters),h=ee(V=>V.filteringCards),p=ee(V=>V.selectedSheetId),m=ee(V=>V.onSaveFunction),{removeFilterValues:g,removeFilteringCard:y,setFilterValues:b,setFilteringCards:x,setDefaultFilterValues:v,getDashboard:w}=en(),{updateFilters:S,clearFilters:E}=lo(),{updateCardFilters:C,clearCardFilters:_}=en(),j=Uo(V=>V.clearAllClickFilters),R=e?hj(f,d,p,e).cardFilterValues:(()=>{const V=Qg(f,p);return d==null?void 0:d.filter(B=>(V==null?void 0:V.some(G=>G.id===B.filterId))||B.filterId.endsWith(p))})(),P=(R==null?void 0:R.map(V=>{const B=f==null?void 0:f.find(G=>G.id===V.filterId);return{filterId:V.filterId,fieldName:(B==null?void 0:B.title)||V.name,fieldLabel:(B==null?void 0:B.title)||V.name,values:V.values,dataType:B==null?void 0:B.dataType,operation:B==null?void 0:B.operation,isDateFilter:Vu((B==null?void 0:B.dataType)||"")}}))||[],M=u6(e||"");if(!a&&P.length===0&&M.length===0&&n===0)return null;const F=P.length+M.length+n;function I(V){return V instanceof Date?V.toLocaleDateString():V}function A(V){const B=h==null?void 0:h.find(G=>V.filterId.startsWith(G.id));B&&y(B),g(V.filterId)}function O(V){P.filter(G=>G.fieldName===V).forEach(G=>{A(G)})}function U(){x([]),b([]),j(),e&&a&&E(e)}function W(V){function B(){return V.values.map((X,re)=>u.jsxs(Tt,{variant:"secondary",className:"group relative cursor-pointer border border-primary/20 bg-primary/10 text-primary transition-colors hover:bg-primary/15",onClick:()=>A(V),children:[I(X),u.jsx(Xt,{className:"ml-1.5 h-3 w-3 opacity-60 transition-opacity group-hover:opacity-100"})]},(X==null?void 0:X.toString())+re))}function G(){const X=V.values[0],re=V.values[1];if(!X||!re)return null;const J=new Date(X),ue=new Date(re);return u.jsxs(Tt,{variant:"secondary",className:"group relative cursor-pointer border border-primary/20 bg-primary/10 text-primary transition-colors hover:bg-primary/15",onClick:()=>A(V),children:[`${J.toLocaleDateString()} - ${ue.toLocaleDateString()}`,u.jsx(Xt,{className:"ml-1.5 h-3 w-3 opacity-60 transition-opacity group-hover:opacity-100"})]})}return u.jsxs("div",{className:"group space-y-3 rounded-lg border border-border/50 bg-muted/30 p-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de,{className:"text-sm font-medium text-foreground",children:V.fieldLabel}),!V.isDateFilter&&V.operation==="not in"&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Lv(V.operation)})]}),u.jsx(ae,{variant:"ghost",size:"sm",onClick:()=>O(V.fieldName),className:"h-6 w-6 p-0 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100","aria-label":"Clear filter",children:u.jsx(Xt,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.isDateFilter?G():B()})]})}function $(V){return{"=":"equals","!=":"not equals",">":"greater than",">=":"greater than or equals","<":"less than","<=":"less than or equals",contains:"contains",startsWith:"starts with",endsWith:"ends with",in:"in","not in":"not in",between:"between",isNull:"is null",isNotNull:"is not null"}[V]||V}function T(V){return Array.isArray(V.value)?V.operator==="between"?`${V.value[0]} and ${V.value[1]}`:V.value.join(", "):V.value instanceof Date?V.value.toLocaleDateString():String(V.value||"")}function z(V){if(!t||!e)return;const B=X=>({...X,conditions:X.conditions.filter(re=>re.id!==V),groups:X.groups.map(B)}),G=B(t);a?S(e,G):C(e,G)}function L(){e&&(a?E(e):_(e))}function D(V){const B=[...V.conditions];return V.groups.forEach(G=>{B.push(...D(G))}),B}function H(){if(!t)return null;const V=D(t);return V.length===0?null:u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Card Filters"}),a&&u.jsxs(ae,{variant:"ghost",size:"sm",onClick:L,className:"h-7 px-2.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:[u.jsx(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear All"]})]}),u.jsx("div",{className:"space-y-3",children:V.map(B=>u.jsxs("div",{className:"group space-y-3 rounded-lg border border-blue-200/50 bg-blue-50/30 p-3 dark:border-blue-800/50 dark:bg-blue-950/30",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de,{className:"text-sm font-medium text-foreground",children:B.field.label||B.field.name}),u.jsx("span",{className:"text-xs text-muted-foreground",children:$(B.operator)})]}),a&&u.jsx(ae,{variant:"ghost",size:"sm",onClick:()=>z(B.id),className:"h-6 w-6 p-0 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100","aria-label":"Clear filter",children:u.jsx(Xt,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.jsx(Tt,{variant:"secondary",className:"border border-blue-300/30 bg-blue-100/50 text-blue-900 dark:border-blue-700/30 dark:bg-blue-900/50 dark:text-blue-100",children:T(B)})})]},B.id))})]})}function q(V){const B=w();B&&(m==null||m(B,V))}function Y(){return u.jsxs(u.Fragment,{children:[u.jsx(Wi,{className:"my-4"}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-xs text-muted-foreground",children:"Start with these filters? Set them as default."}),u.jsxs("div",{className:"flex flex-row-reverse gap-2",children:[u.jsxs(ae,{onClick:()=>{v(d||[]),q("Default filters saved successfully")},style:{borderRadius:c==null?void 0:c.controlInputRadius},className:"h-8 text-xs font-medium",variant:"outline",children:[l&&(l==null?void 0:l.length)>0&&u.jsx(_r,{className:"mr-1.5 h-3.5 w-3.5 text-green-500"}),"Set Default"]}),u.jsx(ae,{onClick:()=>{v(void 0),q("Default filters cleared")},style:{borderRadius:c==null?void 0:c.controlInputRadius},className:"h-8 text-xs font-medium",variant:"secondary",children:"Reset"})]})]})]})}return u.jsxs(E1,{open:o,onOpenChange:s,openDelay:50,children:[u.jsx(N1,{asChild:!0,children:u.jsxs("div",{className:"flex h-7 cursor-pointer items-center gap-1.5 rounded-md border border-border bg-background px-2.5 py-1.5 transition-all hover:border-border/60 hover:bg-muted",onClick:V=>{V.stopPropagation(),s(!1),r==null||r()},children:[u.jsx(Fd,{className:"h-3.5 w-3.5 text-muted-foreground"}),F>0&&u.jsx("span",{className:"text-xs font-medium text-foreground",children:F})]})}),u.jsx(NAe,{onMouseDown:V=>V.stopPropagation(),style:{borderRadius:c==null?void 0:c.cardBorderRadius},className:"w-[380px] border border-border/50 p-0 text-xs shadow-lg",align:"start",children:F===0?u.jsxs("div",{className:"p-6 text-center",children:[u.jsx(Fd,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground/50"}),u.jsx("p",{className:"text-sm font-medium text-foreground",children:"No filters applied"}),u.jsx("p",{className:"mb-4 mt-1 text-xs text-muted-foreground",children:"Add filters to narrow down your data"}),u.jsxs(ae,{variant:"outline",size:"sm",onClick:V=>{V.stopPropagation(),s(!1),r==null||r()},className:"mx-auto",children:[u.jsx(Fd,{className:"mr-2 h-3.5 w-3.5"}),"Add Filters"]})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"border-b border-border/50 bg-muted/30 px-4 py-3",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Fd,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm font-medium text-foreground",children:"Active Filters"}),u.jsx(Tt,{variant:"secondary",className:"text-xs font-medium",children:F})]}),u.jsxs(ae,{variant:"ghost",size:"sm",onClick:U,className:"h-7 px-2.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",children:[u.jsx(Xt,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear All"]})]})}),u.jsxs("div",{className:"space-y-4 p-4",children:[u.jsxs("div",{className:"max-h-[280px] space-y-4 overflow-y-auto",children:[P.length>0&&u.jsxs("div",{className:"space-y-3",children:[u.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Dashboard Filters"}),u.jsx("div",{className:"space-y-3",children:P==null?void 0:P.map(V=>u.jsx("div",{children:W(V)},V.filterId))})]}),u.jsx(kAe,{cardId:e}),H()]}),i&&!a&&Y()]})]})})]})}const av=e=>{if(!e)return 0;let t=e.conditions.length;return e.groups.forEach(n=>{t+=av(n)}),t};function ck(e,t){const{function:n,rowLevel:r,columnLevel:o}=e,s={...t};if(r!==void 0){const i=s.rowAggregates||[],a=r==="all"?"ALL":r,l=i.findIndex(c=>c.groupLevel===a&&c.function===n);l>=0?s.rowAggregates=i.filter((c,d)=>d!==l):s.rowAggregates=[...i,{function:n,groupLevel:a}]}if(o!==void 0){const i=s.columnAggregates||[],a=o==="all"?"ALL":o,l=i.findIndex(c=>c.pivotLevel===a&&c.function===n);l>=0?s.columnAggregates=i.filter((c,d)=>d!==l):s.columnAggregates=[...i,{function:n,pivotLevel:a}]}return s}function sG(e,t){const n={...t};return e.type==="row"&&n.rowAggregates?n.rowAggregates=n.rowAggregates.map(r=>r.function===e.function&&r.groupLevel===e.level?{...r,label:e.label}:r):e.type==="column"&&n.columnAggregates&&(n.columnAggregates=n.columnAggregates.map(r=>r.function===e.function&&r.pivotLevel===e.level?{...r,label:e.label}:r)),n}const ur=e=>O7(new Date,e),_Ae=()=>[{label:"Last 7 days",value:e=>{const t=ur(e);return{from:Tc(t,7),to:t}},category:"day"},{label:"Last 30 days",value:e=>{const t=ur(e);return{from:Tc(t,30),to:t}},category:"day"},{label:"Last 90 days",value:e=>{const t=ur(e);return{from:Tc(t,90),to:t}},category:"day"},{label:"This week",value:e=>({from:Di(ur(e)),to:Up(ur(e))}),category:"week"},{label:"Last week",value:e=>{const t=ur(e),n=Tc(t,7);return{from:Di(n),to:Up(n)}},category:"week"},{label:"Last 2 weeks",value:e=>{const t=ur(e);return{from:Tc(t,14),to:t}},category:"week"},{label:"This month",value:e=>({from:Vp(ur(e)),to:of(ur(e))}),category:"month"},{label:"Last month",value:e=>{const t=ur(e);return{from:Vp(qp(t,1)),to:of(qp(t,1))}},category:"month"},{label:"Last 12 months",value:e=>{const t=ur(e);return{from:qp(t,12),to:t}},category:"month"},{label:"This quarter",value:e=>({from:sf(ur(e)),to:Wp(ur(e))}),category:"quarter"},{label:"Last quarter",value:e=>{const t=ur(e);return{from:sf(Gp(t,1)),to:Wp(Gp(t,1))}},category:"quarter"},{label:"Last 4 quarters",value:e=>{const t=ur(e);return{from:sf(Gp(t,4)),to:t}},category:"quarter"},{label:"This year",value:e=>({from:af(ur(e)),to:Hp(ur(e))}),category:"year"},{label:"Last year",value:e=>{const t=ur(e);return{from:af(xx(t,1)),to:Hp(xx(t,1))}},category:"year"}],U5=[{label:"2 days ago",value:-2},{label:"yesterday",value:-1},{label:"today",value:0},{label:"tomorrow",value:1},{label:"2 days ahead",value:2}],W5=[{label:"2 years ago",value:-2},{label:"last year",value:-1},{label:"this year",value:0},{label:"next year",value:1},{label:"2 years ahead",value:2}],q5=[{label:"2 quarters ago",value:-2},{label:"last quarter",value:-1},{label:"this quarter",value:0},{label:"next quarter",value:1},{label:"2 quarters ahead",value:2}],G5=[{label:"2 months ago",value:-2},{label:"last month",value:-1},{label:"this month",value:0},{label:"next month",value:1},{label:"2 months ahead",value:2}],Y5=[{label:"2 weeks ago",value:-2},{label:"last week",value:-1},{label:"this week",value:0},{label:"next week",value:1},{label:"2 weeks ahead",value:2}];function iG({value:e,onChange:t,placeholder:n="All time",className:r,timezone:o,showRelativeTab:s=!0,disabled:i=!1,buttonClassName:a,contentClassName:l}){const[c,d]=N.useState(!1),[f,h]=N.useState("static"),[p,m]=N.useState(!1),[g,y]=N.useState(!1),[b,x]=N.useState("Days"),[v,w]=N.useState("0"),[S,E]=N.useState("0"),[C,_]=N.useState(void 0),j=Intl.DateTimeFormat().resolvedOptions().timeZone,R=o||j,P=N.useMemo(()=>_Ae(),[]),M=()=>{if(e!=null&&e.from&&(e!=null&&e.to)){const T=cN(e.from,R,"MMM dd, yyyy"),z=cN(e.to,R,"MMM dd, yyyy");return`${T} - ${z}`}return n},F=T=>{const z=T.value(R);t==null||t(z),d(!1)},I=()=>{t==null||t(void 0),d(!1)},A=(T,z)=>{if(!z)return;const L=T==="from"?z:C==null?void 0:C.from,D=T==="to"?z:C==null?void 0:C.to;_({from:L,to:D}),T==="from"?m(!1):y(!1)},O=()=>{C!=null&&C.from&&(C!=null&&C.to)&&(t==null||t(C),d(!1))},U=()=>{_(e)},W=()=>{const T=ur(R),z=parseInt(v),L=parseInt(S);let D,H;b==="Days"?(D=z===0?Bp(T):z>0?Bp(mx(T,z)):Bp(Tc(T,Math.abs(z))),H=L===0?C0(T):L>0?C0(mx(T,L)):C0(Tc(T,Math.abs(L)))):b==="Weeks"?(D=z===0?Di(T):z>0?Di(iN(T,z)):Di(PA(T,Math.abs(z))),H=L===0?Up(T):L>0?Up(iN(T,L)):Up(PA(T,Math.abs(L)))):b==="Months"?(D=z===0?Vp(T):z>0?Vp(Tm(T,z)):Vp(qp(T,Math.abs(z))),H=L===0?of(T):L>0?of(Tm(T,L)):of(qp(T,Math.abs(L)))):b==="Quarters"?(D=z===0?sf(T):z>0?sf(sN(T,z)):sf(Gp(T,Math.abs(z))),H=L===0?Wp(T):L>0?Wp(sN(T,L)):Wp(Gp(T,Math.abs(L)))):(D=z===0?af(T):z>0?af(aN(T,z)):af(xx(T,Math.abs(z))),H=L===0?Hp(T):L>0?Hp(aN(T,L)):Hp(xx(T,Math.abs(L)))),t==null||t({from:D,to:H}),d(!1)},$=T=>{d(T),T&&_(e)};return u.jsx("div",{className:Z("w-full",r),children:u.jsxs(qs,{open:c,onOpenChange:$,children:[u.jsx(Gs,{asChild:!0,children:u.jsxs(ae,{variant:"outline",className:Z("h-10 w-full justify-between text-left font-normal",a),title:`Timezone: ${wx(R)} (${zd(R)})`,disabled:i,children:[u.jsx("span",{className:"text-sm",children:M()}),u.jsxs("div",{className:"flex items-center gap-1",children:[R!==j&&u.jsx(gE,{className:"h-3 w-3 opacity-50"}),u.jsx(No,{className:"h-4 w-4 opacity-50"})]})]})}),u.jsxs(Ys,{className:Z("z-[51] w-[320px] p-0",l),align:"start",children:[R!==j&&u.jsxs("div",{className:"flex items-center gap-1 border-b bg-muted/50 px-3 py-1.5 text-xs text-muted-foreground",children:[u.jsx(gE,{className:"h-3 w-3"}),u.jsxs("span",{children:["Using ",wx(R)," timezone"]})]}),u.jsxs(di,{value:f,onValueChange:T=>{h(T),T==="static"&&_(e)},className:"w-full",children:[s&&u.jsx("div",{className:"border-b",children:u.jsxs(Rs,{className:"grid h-9 w-full grid-cols-2 rounded-none bg-transparent",children:[u.jsx(Ln,{value:"static",className:"rounded-none text-sm data-[state=active]:border-b-2 data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"Static"}),u.jsx(Ln,{value:"relative",className:"rounded-none text-sm data-[state=active]:border-b-2 data-[state=active]:border-primary data-[state=active]:bg-transparent",children:"Relative"})]})}),u.jsx(xr,{value:"static",className:"mt-0",children:u.jsxs("div",{className:"space-y-3 p-3",children:[u.jsx(ae,{variant:"outline",onClick:I,className:"h-9 w-full justify-center",children:"All time"}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(de,{className:"text-xs text-muted-foreground",children:"Custom range"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("div",{className:"relative flex-1",children:u.jsxs(qs,{open:p,onOpenChange:m,children:[u.jsx(Gs,{asChild:!0,children:u.jsxs(ae,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[u.jsx(Ss,{className:"mr-2 h-4 w-4"}),C!=null&&C.from?Hs(C.from,"MM/dd/yyyy"):"From date"]})}),u.jsx(Ys,{className:"z-[52] w-auto p-0",align:"start",children:u.jsx(ng,{mode:"single",selected:C==null?void 0:C.from,captionLayout:"dropdown",onSelect:T=>A("from",T)})})]})}),u.jsx("span",{className:"flex items-center text-muted-foreground",children:"-"}),u.jsx("div",{className:"relative flex-1",children:u.jsxs(qs,{open:g,onOpenChange:y,children:[u.jsx(Gs,{asChild:!0,children:u.jsxs(ae,{variant:"outline",className:"h-9 w-full justify-start text-left font-normal",children:[u.jsx(Ss,{className:"mr-2 h-4 w-4"}),C!=null&&C.to?Hs(C.to,"MM/dd/yyyy"):"To date"]})}),u.jsx(Ys,{className:"z-[52] w-auto p-0",align:"start",children:u.jsx(ng,{mode:"single",selected:C==null?void 0:C.to,captionLayout:"dropdown",onSelect:T=>A("to",T)})})]})})]}),((C==null?void 0:C.from)||(C==null?void 0:C.to))&&u.jsxs("div",{className:"flex gap-2 pt-1",children:[u.jsx(ae,{size:"sm",variant:"outline",className:"h-8 flex-1",onClick:U,children:"Cancel"}),u.jsx(ae,{size:"sm",className:"h-8 flex-1",disabled:!(C!=null&&C.from)||!(C!=null&&C.to),onClick:O,children:"Apply"})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(de,{className:"text-xs text-muted-foreground",children:"Quick select"}),u.jsx(Yi,{className:"h-[240px] w-full",children:u.jsx("div",{className:"space-y-1",children:["day","week","month","quarter","year"].map(T=>u.jsxs("div",{className:"mt-2 space-y-1",children:[u.jsx(de,{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:T}),P.filter(z=>z.category===T).map(z=>u.jsx("button",{onClick:()=>F(z),className:"w-full rounded px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:z.label},z.label))]},T))})})]})]})}),s&&u.jsx(xr,{value:"relative",className:"mt-0",children:u.jsxs("div",{className:"space-y-3 p-3",children:[u.jsx("div",{className:"flex gap-1 rounded-md bg-muted p-1",children:["Days","Weeks","Months","Quarters","Years"].map(T=>u.jsx("button",{onClick:()=>x(T),className:Z("flex-1 rounded px-2 py-1 text-xs transition-colors",b===T?"bg-background shadow-sm":"hover:bg-background/50"),children:T},T))}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsxs(Dt,{value:v,onValueChange:w,children:[u.jsx(_t,{className:"h-9",children:u.jsx(Ft,{placeholder:"From"})}),u.jsx(jt,{className:"z-[51]",children:(b==="Years"?W5:b==="Quarters"?q5:b==="Months"?G5:b==="Weeks"?Y5:U5).map(z=>u.jsx(ve,{value:z.value.toString(),children:z.label},z.value))})]})}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),u.jsx("div",{className:"flex-1",children:u.jsxs(Dt,{value:S,onValueChange:E,children:[u.jsx(_t,{className:"h-9",children:u.jsx(Ft,{placeholder:"To"})}),u.jsx(jt,{className:"z-[51]",children:(b==="Years"?W5:b==="Quarters"?q5:b==="Months"?G5:b==="Weeks"?Y5:U5).map(z=>u.jsx(ve,{value:z.value.toString(),children:z.label},z.value))})]})})]}),u.jsx("div",{className:"pt-2",children:u.jsx(ae,{onClick:W,size:"sm",className:"h-8 w-full",children:"Apply"})})]})})]})]})]})})}function FM(e){const{authToken:t,tokenProps:n}=qe(),r=ee(S=>S.authToken),o=t||r,s=ee(S=>S.dashboard.filters),i=ee(S=>S.selectedSheetId),a=ee(S=>S.filterValues),[l,c]=N.useState(!0),d=Qg(s,i),f=a==null?void 0:a.filter(S=>(d==null?void 0:d.some(E=>E.id===S.filterId))||S.filterId.endsWith(i));function h(S){return l?{allowQuery:!0,filterValues:S.filter(_=>_.filterId!==e.id)}:(S==null?void 0:S.find(C=>C.filterId===e.id))?{allowQuery:!1,filterValues:S}:{allowQuery:!0,filterValues:S}}const{allowQuery:p,filterValues:m}=h(f||[]),{data:g,isLoading:y,isFetching:b,isError:x,refetch:v,isSuccess:w}=yn({queryKey:["filter",e.id,e.sql,JSON.stringify(m)],queryFn:()=>a3(`${n.apiServiceUrl}/v1/query`,(o==null?void 0:o.accessToken)||"",{connection_id:e.connectionId,sql:e.sql,active_filters:m,cache_config:l_({filter:e})}),enabled:!!e.sql&&!!e.connectionId&&p&&!!(o!=null&&o.accessToken),placeholderData:S=>S});return N.useEffect(()=>{w&&l&&c(!1)},[w,l]),{data:g,isLoading:y,isFetching:b,isError:x,refetch:v}}function aG(e,t){const[n,r]=N.useState(t),[o,s]=N.useState(),i=N.useMemo(()=>t,[t]);return N.useEffect(()=>{if(e&&(e==null?void 0:e.length)>0){const a=e[0];if(!a.min||!a.max)return;const l={from:new Date(a.min),to:new Date(a.max)};s(l),i||r(l)}},[e,i]),N.useEffect(()=>{i&&r(i)},[i]),{dateRange:n,setDateRange:r,initialDateRange:o,setInitialDateRange:s}}function jAe(e){const t=ee(o=>{var s,i;return(i=(s=o.dashboard)==null?void 0:s.filters)==null?void 0:i.find(a=>a.id===e)}),{setDateRange:n,...r}=lG(t||{});return r}function lG(e){const t=ee(g=>g.filterValues),n=ee(g=>g.actions.addOrUpdateFilterValue),{removeFilterValues:r}=en(),{data:o,isLoading:s,isFetching:i,isError:a}=FM(e),l=N.useMemo(()=>{var g;if(t){const y=t.find(b=>b.filterId===e.id);if(y&&((g=y.values)==null?void 0:g.length)===2){const[b,x]=y.values;return{from:b?new Date(b):void 0,to:x?new Date(x):void 0}}}},[t,e.id]),{dateRange:c,setDateRange:d,initialDateRange:f}=aG(o==null?void 0:o.records,l);function h(){r(e.id),d(void 0)}function p(){d(f)}function m(g){if(!g)return;let y=[g==null?void 0:g.from,g==null?void 0:g.to];g.from&&g.to===void 0?y=[g.from,gx(g.from,24)]:g.from&&g.to&&g.from.getTime()===g.to.getTime()?y=[g.from,gx(g.to,24)]:y=[g.from,g.to],d({from:y[0],to:y[1]});const b={filterId:e.id,connectionType:e.database==="NA"?"api":"database",valueType:Xd(e),name:e.column,operation:"between",values:y};n(b)}return{records:o==null?void 0:o.records,isLoading:s,isFetching:i,isError:a,initialDateRange:f,dateRange:c,setDateRange:d,handleClear:h,handleChange:m,handleReset:p}}function RAe({filter:e,className:t}){var g;const{tokenProps:n}=qe(),r=(g=n==null?void 0:n.params)==null?void 0:g.timeZone,{records:o,dateRange:s,isLoading:i,isFetching:a,isError:l,setDateRange:c,handleChange:d,handleClear:f}=lG(e),h=ee(y=>y.filterValues),p=h==null?void 0:h.some(y=>y.filterId===e.id);if(i||a)return u.jsx("div",{children:u.jsx($a,{className:"h-8 w-full bg-foreground/10"})});if(l)return u.jsx("div",{className:"h-8 w-full bg-muted px-2",children:"Error"});if(!o)return u.jsx(de,{className:"flex h-8 w-full items-center bg-muted px-2",children:"No Data"});const m=y=>{if(!y){f();return}let b=[y==null?void 0:y.from,y==null?void 0:y.to];y.from&&y.to===void 0?b=[y.from,gx(y.from,24)]:y.from&&y.to&&y.from.getTime()===y.to.getTime()?b=[y.from,gx(y.to,24)]:b=[y.from,y.to],c({from:b[0],to:b[1]}),d({from:b[0],to:b[1]})};return u.jsx(iG,{value:p?s:void 0,buttonClassName:"h-8",onChange:m,timezone:r,showRelativeTab:!0,className:t,placeholder:"All time"})}function MAe(e){const t=/(>=|<=|>|<|=)/,n=e.match(t);if(n){const r=n[0],[o,s]=e.split(r);return{operation:r,value:s.trim()}}else return null}function DAe(e,t,n){const r=`SELECT ${n}, COUNT(*) FROM ${t} {{ filters | where }} GROUP BY ${n} ORDER BY ${n} ASC LIMIT 50`,o=`SELECT min(${n}) as min, max(${n}) as max FROM ${t} {{ filters | where }}`;return Vu(e)?o:r}function PAe(e){const t=ee(s=>{var i,a;return(a=(i=s==null?void 0:s.dashboard)==null?void 0:i.filters)==null?void 0:a.find(l=>l.id===e)}),{query:n,setQuery:r,...o}=$M(t||{});return o}function $M(e){const[t,n]=N.useState([]),[r,o]=N.useState(""),s=ee(E=>E.filterValues),i=ee(E=>E.selectedSheetId),{addOrUpdateFilterValue:a,removeFilterValues:l}=en(),{data:c,isLoading:d,isFetching:f,isError:h}=FM(e),p=N.useMemo(()=>{var C;return e.column?(C=c==null?void 0:c.records)==null?void 0:C.map((_,j)=>{let R=e.column.split(".").slice(-1)[0].replace(/"/g,"");return _[R]===void 0&&(R=R.toLowerCase()),{id:`${e.id}-${j}`,value:_[R]}}):[]},[c,e.column,e.id]);N.useEffect(()=>{if(s){const E=s.find(C=>C.filterId===e.id);if(!E){n([]);return}if(E.operation==="in"){const C=p==null?void 0:p.filter(_=>E.values.includes(_.value));C&&n(C)}}},[c,i,s,e.id,p]),N.useEffect(()=>{if(s&&!s.find(C=>C.filterId===e.id)){n([]);return}},[s,e.id]);function m(E){const C=MAe(E[0].toString());if(!(C!=null&&C.value)||!(C!=null&&C.operation))return;const _={filterId:e.id,connectionType:e.database==="NA"?"api":"database",valueType:Xd(e),name:e.column,operation:C.operation,values:[Number(C.value)]};a(_)}function g(E){if(Array.isArray(E)||(E=[E]),E.length===1&&p.find(_=>_.value===E[0].value)===void 0){m(E);return}if(n(E),E.length===0){l(e.id);return}const C={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:Xd(e),operation:e.operation,values:E.map(_=>_.value)};a(C)}function y(){n([]),l(e.id)}function b(E){if(E){n(p);const C={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:Xd(e),operation:e.operation,values:p.map(_=>_.value)};a(C)}else y()}function x(){if(Object.keys(e).length===0||jg(e.dataType))return p;const E=r.toLowerCase().replace(/\s+/g,"");return r===""?p:p.filter(C=>C.value.toLowerCase().replace(/\s+/g,"").includes(E))}const v=x(),w=e.type==="single",S=t.length===(p==null?void 0:p.length);return{isLoading:d,isFetching:f,isError:h,records:p,selectedRecords:t,handleChange:g,handleClear:y,handleSelectAll:b,query:r,setQuery:o,filteredRecords:v,isSingleSelect:w,allSelected:S}}const cG=typeof document<"u"?N.useLayoutEffect:()=>{};function TAe(e){const t=N.useRef(null);return cG(()=>{t.current=e},[e]),N.useCallback((...n)=>{const r=t.current;return r==null?void 0:r(...n)},[])}const gb=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},Hc=e=>e&&"window"in e&&e.window===e?e:gb(e).defaultView||window;function AAe(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function IAe(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function uG(e){let t=null;return()=>(t==null&&(t=e()),t)}const OAe=uG(function(){return IAe(/^Mac/i)}),FAe=uG(function(){return AAe(/Android/i)});function $Ae(e){return e.mozInputSource===0&&e.isTrusted?!0:FAe()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}class LAe{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(t,n){this.nativeEvent=n,this.target=n.target,this.currentTarget=n.currentTarget,this.relatedTarget=n.relatedTarget,this.bubbles=n.bubbles,this.cancelable=n.cancelable,this.defaultPrevented=n.defaultPrevented,this.eventPhase=n.eventPhase,this.isTrusted=n.isTrusted,this.timeStamp=n.timeStamp,this.type=t}}function dG(e){let t=N.useRef({isFocused:!1,observer:null});cG(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let n=TAe(r=>{e==null||e(r)});return N.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let o=r.target,s=i=>{t.current.isFocused=!1,o.disabled&&n(new LAe("blur",i)),t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};o.addEventListener("focusout",s,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&o.disabled){var i;(i=t.current.observer)===null||i===void 0||i.disconnect();let a=o===document.activeElement?null:document.activeElement;o.dispatchEvent(new FocusEvent("blur",{relatedTarget:a})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:a}))}}),t.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[n])}function zAe(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:o}=e;const s=N.useCallback(l=>{if(l.target===l.currentTarget)return r&&r(l),o&&o(!1),!0},[r,o]),i=dG(s),a=N.useCallback(l=>{const c=gb(l.target);l.target===l.currentTarget&&c.activeElement===l.target&&(n&&n(l),o&&o(!0),i(l))},[o,n,i]);return{focusProps:{onFocus:!t&&(n||o||r)?a:void 0,onBlur:!t&&(r||o)?s:void 0}}}let bb=null,uk=new Set,cm=new Map,Ou=!1,dk=!1;const BAe={Tab:!0,Escape:!0};function LM(e,t){for(let n of uk)n(e,t)}function VAe(e){return!(e.metaKey||!OAe()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function lv(e){Ou=!0,VAe(e)&&(bb="keyboard",LM("keyboard",e))}function hs(e){bb="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(Ou=!0,LM("pointer",e))}function fG(e){$Ae(e)&&(Ou=!0,bb="virtual")}function hG(e){e.target===window||e.target===document||(!Ou&&!dk&&(bb="virtual",LM("virtual",e)),Ou=!1,dk=!1)}function pG(){Ou=!1,dk=!0}function fk(e){if(typeof window>"u"||cm.get(Hc(e)))return;const t=Hc(e),n=gb(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){Ou=!0,r.apply(this,arguments)},n.addEventListener("keydown",lv,!0),n.addEventListener("keyup",lv,!0),n.addEventListener("click",fG,!0),t.addEventListener("focus",hG,!0),t.addEventListener("blur",pG,!1),typeof PointerEvent<"u"?(n.addEventListener("pointerdown",hs,!0),n.addEventListener("pointermove",hs,!0),n.addEventListener("pointerup",hs,!0)):(n.addEventListener("mousedown",hs,!0),n.addEventListener("mousemove",hs,!0),n.addEventListener("mouseup",hs,!0)),t.addEventListener("beforeunload",()=>{mG(e)},{once:!0}),cm.set(t,{focus:r})}const mG=(e,t)=>{const n=Hc(e),r=gb(e);t&&r.removeEventListener("DOMContentLoaded",t),cm.has(n)&&(n.HTMLElement.prototype.focus=cm.get(n).focus,r.removeEventListener("keydown",lv,!0),r.removeEventListener("keyup",lv,!0),r.removeEventListener("click",fG,!0),n.removeEventListener("focus",hG,!0),n.removeEventListener("blur",pG,!1),typeof PointerEvent<"u"?(r.removeEventListener("pointerdown",hs,!0),r.removeEventListener("pointermove",hs,!0),r.removeEventListener("pointerup",hs,!0)):(r.removeEventListener("mousedown",hs,!0),r.removeEventListener("mousemove",hs,!0),r.removeEventListener("mouseup",hs,!0)),cm.delete(n))};function HAe(e){const t=gb(e);let n;return t.readyState!=="loading"?fk(e):(n=()=>{fk(e)},t.addEventListener("DOMContentLoaded",n)),()=>mG(e,n)}typeof document<"u"&&HAe();function gG(){return bb!=="pointer"}const UAe=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function WAe(e,t,n){var r;const o=typeof window<"u"?Hc(n==null?void 0:n.target).HTMLInputElement:HTMLInputElement,s=typeof window<"u"?Hc(n==null?void 0:n.target).HTMLTextAreaElement:HTMLTextAreaElement,i=typeof window<"u"?Hc(n==null?void 0:n.target).HTMLElement:HTMLElement,a=typeof window<"u"?Hc(n==null?void 0:n.target).KeyboardEvent:KeyboardEvent;return e=e||(n==null?void 0:n.target)instanceof o&&!UAe.has(n==null||(r=n.target)===null||r===void 0?void 0:r.type)||(n==null?void 0:n.target)instanceof s||(n==null?void 0:n.target)instanceof i&&(n==null?void 0:n.target.isContentEditable),!(e&&t==="keyboard"&&n instanceof a&&!BAe[n.key])}function qAe(e,t,n){fk(),N.useEffect(()=>{let r=(o,s)=>{WAe(!!(n!=null&&n.isTextInput),o,s)&&e(gG())};return uk.add(r),()=>{uk.delete(r)}},t)}function GAe(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:o}=e,s=N.useRef({isFocusWithin:!1}),i=N.useCallback(c=>{s.current.isFocusWithin&&!c.currentTarget.contains(c.relatedTarget)&&(s.current.isFocusWithin=!1,n&&n(c),o&&o(!1))},[n,o,s]),a=dG(i),l=N.useCallback(c=>{!s.current.isFocusWithin&&document.activeElement===c.target&&(r&&r(c),o&&o(!0),s.current.isFocusWithin=!0,a(c))},[r,o,a]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:l,onBlur:i}}}let cv=!1,n2=0;function hk(){cv=!0,setTimeout(()=>{cv=!1},50)}function Z5(e){e.pointerType==="touch"&&hk()}function YAe(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Z5):document.addEventListener("touchend",hk),n2++,()=>{n2--,!(n2>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",Z5):document.removeEventListener("touchend",hk))}}function bG(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,isDisabled:o}=e,[s,i]=N.useState(!1),a=N.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;N.useEffect(YAe,[]);let{hoverProps:l,triggerHoverEnd:c}=N.useMemo(()=>{let d=(p,m)=>{if(a.pointerType=m,o||m==="touch"||a.isHovered||!p.currentTarget.contains(p.target))return;a.isHovered=!0;let g=p.currentTarget;a.target=g,t&&t({type:"hoverstart",target:g,pointerType:m}),n&&n(!0),i(!0)},f=(p,m)=>{if(a.pointerType="",a.target=null,m==="touch"||!a.isHovered)return;a.isHovered=!1;let g=p.currentTarget;r&&r({type:"hoverend",target:g,pointerType:m}),n&&n(!1),i(!1)},h={};return typeof PointerEvent<"u"?(h.onPointerEnter=p=>{cv&&p.pointerType==="mouse"||d(p,p.pointerType)},h.onPointerLeave=p=>{!o&&p.currentTarget.contains(p.target)&&f(p,p.pointerType)}):(h.onTouchStart=()=>{a.ignoreEmulatedMouseEvents=!0},h.onMouseEnter=p=>{!a.ignoreEmulatedMouseEvents&&!cv&&d(p,"mouse"),a.ignoreEmulatedMouseEvents=!1},h.onMouseLeave=p=>{!o&&p.currentTarget.contains(p.target)&&f(p,"mouse")}),{hoverProps:h,triggerHoverEnd:f}},[t,n,r,o,a]);return N.useEffect(()=>{o&&c({currentTarget:a.target},a.pointerType)},[o]),{hoverProps:l,isHovered:s}}function yG(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,o=N.useRef({isFocused:!1,isFocusVisible:t||gG()}),[s,i]=N.useState(!1),[a,l]=N.useState(()=>o.current.isFocused&&o.current.isFocusVisible),c=N.useCallback(()=>l(o.current.isFocused&&o.current.isFocusVisible),[]),d=N.useCallback(p=>{o.current.isFocused=p,i(p),c()},[c]);qAe(p=>{o.current.isFocusVisible=p,c()},[],{isTextInput:n});let{focusProps:f}=zAe({isDisabled:r,onFocusChange:d}),{focusWithinProps:h}=GAe({isDisabled:!r,onFocusWithinChange:d});return{isFocused:s,isFocusVisible:a,focusProps:r?h:f}}var ZAe=Object.defineProperty,KAe=(e,t,n)=>t in e?ZAe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,r2=(e,t,n)=>(KAe(e,typeof t!="symbol"?t+"":t,n),n);let XAe=class{constructor(){r2(this,"current",this.detect()),r2(this,"handoffState","pending"),r2(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},gu=new XAe;function yb(e){return gu.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function xG(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function Ki(){let e=[],t={addEventListener(n,r,o,s){return n.addEventListener(r,o,s),t.add(()=>n.removeEventListener(r,o,s))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return xG(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,o){let s=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:o}),this.add(()=>{Object.assign(n.style,{[r]:s})})},group(n){let r=Ki();return n(r),this.add(()=>r.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let n of e.splice(0))n()}};return t}function xb(){let[e]=N.useState(Ki);return N.useEffect(()=>()=>e.dispose(),[e]),e}let zn=(e,t)=>{gu.isServer?N.useEffect(e,t):N.useLayoutEffect(e,t)};function od(e){let t=N.useRef(e);return zn(()=>{t.current=e},[e]),t}let ut=function(e){let t=od(e);return N.useCallback((...n)=>t.current(...n),[t])};function QAe(e){let t=e.width/2,n=e.height/2;return{top:e.clientY-n,right:e.clientX+t,bottom:e.clientY+n,left:e.clientX-t}}function JAe(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function eIe({disabled:e=!1}={}){let t=N.useRef(null),[n,r]=N.useState(!1),o=xb(),s=ut(()=>{t.current=null,r(!1),o.dispose()}),i=ut(a=>{if(o.dispose(),t.current===null){t.current=a.currentTarget,r(!0);{let l=yb(a.currentTarget);o.addEventListener(l,"pointerup",s,!1),o.addEventListener(l,"pointermove",c=>{if(t.current){let d=QAe(c);r(JAe(d,t.current.getBoundingClientRect()))}},!1),o.addEventListener(l,"pointercancel",s,!1)}}});return{pressed:n,pressProps:e?{}:{onPointerDown:i,onPointerUp:s,onClick:s}}}let tIe=N.createContext(void 0);function zM(){return N.useContext(tIe)}function K5(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function Va(e,t,...n){if(e in t){let o=t[e];return typeof o=="function"?o(...n):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Va),r}var pk=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(pk||{}),nIe=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(nIe||{});function hi(){let e=oIe();return N.useCallback(t=>rIe({mergeRefs:e,...t}),[e])}function rIe({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:o,visible:s=!0,name:i,mergeRefs:a}){a=a??sIe;let l=vG(t,e);if(s)return Ky(l,n,r,i,a);let c=o??0;if(c&2){let{static:d=!1,...f}=l;if(d)return Ky(f,n,r,i,a)}if(c&1){let{unmount:d=!0,...f}=l;return Va(d?0:1,{0(){return null},1(){return Ky({...f,hidden:!0,style:{display:"none"}},n,r,i,a)}})}return Ky(l,n,r,i,a)}function Ky(e,t={},n,r,o){let{as:s=n,children:i,refName:a="ref",...l}=o2(e,["unmount","static"]),c=e.ref!==void 0?{[a]:e.ref}:{},d=typeof i=="function"?i(t):i;"className"in l&&l.className&&typeof l.className=="function"&&(l.className=l.className(t)),l["aria-labelledby"]&&l["aria-labelledby"]===l.id&&(l["aria-labelledby"]=void 0);let f={};if(t){let h=!1,p=[];for(let[m,g]of Object.entries(t))typeof g=="boolean"&&(h=!0),g===!0&&p.push(m.replace(/([A-Z])/g,y=>`-${y.toLowerCase()}`));if(h){f["data-headlessui-state"]=p.join(" ");for(let m of p)f[`data-${m}`]=""}}if(s===N.Fragment&&(Object.keys(Mc(l)).length>0||Object.keys(Mc(f)).length>0))if(!N.isValidElement(d)||Array.isArray(d)&&d.length>1){if(Object.keys(Mc(l)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(Mc(l)).concat(Object.keys(Mc(f))).map(h=>` - ${h}`).join(`
|
|
878
878
|
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(h=>` - ${h}`).join(`
|
|
879
879
|
`)].join(`
|
|
880
880
|
`))}else{let h=d.props,p=h==null?void 0:h.className,m=typeof p=="function"?(...b)=>K5(p(...b),l.className):K5(p,l.className),g=m?{className:m}:{},y=vG(d.props,Mc(o2(l,["ref"])));for(let b in f)b in y&&delete f[b];return N.cloneElement(d,Object.assign({},y,f,c,{ref:o(iIe(d),c.ref)},g))}return N.createElement(s,Object.assign({},o2(l,["ref"]),s!==N.Fragment&&c,s!==N.Fragment&&f),d)}function oIe(){let e=N.useRef([]),t=N.useCallback(n=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return e.current=n,t}}function sIe(...e){return e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}function vG(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[o=>{var s;return(s=o==null?void 0:o.preventDefault)==null?void 0:s.call(o)}]);for(let r in n)Object.assign(t,{[r](o,...s){let i=n[r];for(let a of i){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;a(o,...s)}}});return t}function BM(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];for(let r in n)Object.assign(t,{[r](...o){let s=n[r];for(let i of s)i==null||i(...o)}});return t}function pi(e){var t;return Object.assign(N.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function Mc(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function o2(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function iIe(e){return N.version.split(".")[0]>="19"?e.props.ref:e.ref}function aIe(e,t,n){let[r,o]=N.useState(n),s=e!==void 0,i=N.useRef(s),a=N.useRef(!1),l=N.useRef(!1);return s&&!i.current&&!a.current?(a.current=!0,i.current=s,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!s&&i.current&&!l.current&&(l.current=!0,i.current=s,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[s?e:r,ut(c=>(s||o(c),t==null?void 0:t(c)))]}function lIe(e){let[t]=N.useState(e);return t}function wG(e={},t=null,n=[]){for(let[r,o]of Object.entries(e))CG(n,SG(t,r),o);return n}function SG(e,t){return e?e+"["+t+"]":t}function CG(e,t,n){if(Array.isArray(n))for(let[r,o]of n.entries())CG(e,SG(t,r.toString()),o);else n instanceof Date?e.push([t,n.toISOString()]):typeof n=="boolean"?e.push([t,n?"1":"0"]):typeof n=="string"?e.push([t,n]):typeof n=="number"?e.push([t,`${n}`]):n==null?e.push([t,""]):wG(n,t,e)}let cIe="span";var VM=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(VM||{});function uIe(e,t){var n;let{features:r=1,...o}=e,s={ref:t,"aria-hidden":(r&2)===2?!0:(n=o["aria-hidden"])!=null?n:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return hi()({ourProps:s,theirProps:o,slot:{},defaultTag:cIe,name:"Hidden"})}let EG=pi(uIe),dIe=N.createContext(null);function fIe({children:e}){let t=N.useContext(dIe);if(!t)return N.createElement(N.Fragment,null,e);let{target:n}=t;return n?Nn.createPortal(N.createElement(N.Fragment,null,e),n):null}function hIe({data:e,form:t,disabled:n,onReset:r,overrides:o}){let[s,i]=N.useState(null),a=xb();return N.useEffect(()=>{if(r&&s)return a.addEventListener(s,"reset",r)},[s,t,r]),N.createElement(fIe,null,N.createElement(pIe,{setForm:i,formId:t}),wG(e).map(([l,c])=>N.createElement(EG,{features:VM.Hidden,...Mc({key:l,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:t,disabled:n,name:l,value:c,...o})})))}function pIe({setForm:e,formId:t}){return N.useEffect(()=>{if(t){let n=document.getElementById(t);n&&e(n)}},[e,t]),t?null:N.createElement(EG,{features:VM.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:n=>{if(!n)return;let r=n.closest("form");r&&e(r)}})}let mIe=N.createContext(void 0);function NG(){return N.useContext(mIe)}function gIe(e){let t=e.parentElement,n=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(n=t),t=t.parentElement;let r=(t==null?void 0:t.getAttribute("disabled"))==="";return r&&bIe(n)?!1:r}function bIe(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}let kG=Symbol();function yIe(e,t=!0){return Object.assign(e,{[kG]:t})}function nl(...e){let t=N.useRef(e);N.useEffect(()=>{t.current=e},[e]);let n=ut(r=>{for(let o of t.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[kG]))?void 0:n}let HM=N.createContext(null);HM.displayName="DescriptionContext";function _G(){let e=N.useContext(HM);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,_G),t}return e}function xIe(){var e,t;return(t=(e=N.useContext(HM))==null?void 0:e.value)!=null?t:void 0}let vIe="p";function wIe(e,t){let n=N.useId(),r=zM(),{id:o=`headlessui-description-${n}`,...s}=e,i=_G(),a=nl(t);zn(()=>i.register(o),[o,i.register]);let l=r||!1,c=N.useMemo(()=>({...i.slot,disabled:l}),[i.slot,l]),d={ref:a,...i.props,id:o};return hi()({ourProps:d,theirProps:s,slot:c,defaultTag:vIe,name:i.name||"Description"})}let SIe=pi(wIe);Object.assign(SIe,{});var no=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(no||{});let k1=N.createContext(null);k1.displayName="LabelContext";function jG(){let e=N.useContext(k1);if(e===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,jG),t}return e}function _1(e){var t,n,r;let o=(n=(t=N.useContext(k1))==null?void 0:t.value)!=null?n:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[o,...e].filter(Boolean).join(" "):o}function CIe({inherit:e=!1}={}){let t=_1(),[n,r]=N.useState([]),o=e?[t,...n].filter(Boolean):n;return[o.length>0?o.join(" "):void 0,N.useMemo(()=>function(s){let i=ut(l=>(r(c=>[...c,l]),()=>r(c=>{let d=c.slice(),f=d.indexOf(l);return f!==-1&&d.splice(f,1),d}))),a=N.useMemo(()=>({register:i,slot:s.slot,name:s.name,props:s.props,value:s.value}),[i,s.slot,s.name,s.props,s.value]);return N.createElement(k1.Provider,{value:a},s.children)},[r])]}let EIe="label";function NIe(e,t){var n;let r=N.useId(),o=jG(),s=NG(),i=zM(),{id:a=`headlessui-label-${r}`,htmlFor:l=s??((n=o.props)==null?void 0:n.htmlFor),passive:c=!1,...d}=e,f=nl(t);zn(()=>o.register(a),[a,o.register]);let h=ut(y=>{let b=y.currentTarget;if(b instanceof HTMLLabelElement&&y.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(y),b instanceof HTMLLabelElement){let x=document.getElementById(b.htmlFor);if(x){let v=x.getAttribute("disabled");if(v==="true"||v==="")return;let w=x.getAttribute("aria-disabled");if(w==="true"||w==="")return;(x instanceof HTMLInputElement&&(x.type==="radio"||x.type==="checkbox")||x.role==="radio"||x.role==="checkbox"||x.role==="switch")&&x.click(),x.focus({preventScroll:!0})}}}),p=i||!1,m=N.useMemo(()=>({...o.slot,disabled:p}),[o.slot,p]),g={ref:f,...o.props,id:a,htmlFor:l,onClick:h};return c&&("onClick"in g&&(delete g.htmlFor,delete g.onClick),"onClick"in d&&delete d.onClick),hi()({ourProps:g,theirProps:d,slot:m,defaultTag:l?EIe:"div",name:o.name||"Label"})}let kIe=pi(NIe),_Ie=Object.assign(kIe,{});function Ed(e,t,n){let r=n.initialDeps??[],o;return()=>{var s,i,a,l;let c;n.key&&((s=n.debug)!=null&&s.call(n))&&(c=Date.now());const d=e();if(!(d.length!==r.length||d.some((p,m)=>r[m]!==p)))return o;r=d;let h;if(n.key&&((i=n.debug)!=null&&i.call(n))&&(h=Date.now()),o=t(...d),n.key&&((a=n.debug)!=null&&a.call(n))){const p=Math.round((Date.now()-c)*100)/100,m=Math.round((Date.now()-h)*100)/100,g=m/16,y=(b,x)=>{for(b=String(b);b.length<x;)b=" "+b;return b};console.info(`%c⏱ ${y(m,5)} /${y(p,5)} ms`,`
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-CVe9Ly3u.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-CVe9Ly3u.js"),C=require("./types/index.cjs"),s=require("./chunks/dashboard-plus-DzJwjJjJ.js"),o=require("react/jsx-runtime"),T=require("react");require("react-dom");function h(a){const{displayPreferences:i,...u}=a,d={...u,id:a.dashboardId};return o.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:o.jsx(e.SemaphorContextProvider,{dashboardProps:d,children:o.jsx(e.UXProvider,{children:o.jsx(e.DisplayPreferencesProvider,{displayPreferences:i,children:o.jsx(e.Container,{type:"visual",...d,children:o.jsx(g,{cardId:a.cardId})})})})})})}function g({cardId:a}){const i=e.useDashboardStore(t=>{var n;return(n=t.dashboard)==null?void 0:n.sheets}),{card:u,frame:d}=T.useMemo(()=>{const t=i==null?void 0:i.flatMap(r=>r.frames),n=t==null?void 0:t.flatMap(r=>r==null?void 0:r.cards),c=n==null?void 0:n.find(r=>(r==null?void 0:r.id)===a),M=t==null?void 0:t.find(r=>{var Y;return(Y=r==null?void 0:r.cards)==null?void 0:Y.find(l=>(l==null?void 0:l.id)===a)});return{card:c,frame:M}},[i,a]);return!u||!d?o.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${a}`}):o.jsx("main",{className:"flex h-full grow flex-col",children:o.jsx(e.ErrorBoundary,{FallbackComponent:({error:t,resetErrorBoundary:n})=>o.jsx(e.FallbackVisual,{error:t,resetErrorBoundary:n,customerFacingMessage:"Error creating visual. Please try again."}),children:o.jsx(e.DashboardCard,{card:u,frame:d})})})}const S=["MM-DD-YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","MMMM DD, YYYY","MMM DD, YYYY","DD MMM YYYY","Week of MMM DD, YYYY","Week of MMMM DD, YYYY","YYYY-WW","MMM YYYY","MMMM YYYY","YYYY-MM","MM/YYYY","YYYY MMM","Q1 YYYY","YYYY Q1","1st Quarter YYYY","YYYY-Q1","Quarter 1, YYYY","YYYY","YY","custom"];var D=(a=>(a.SUBTOTAL="__SUBTOTAL__",a.TOTAL="__TOTAL__",a.ALL="__ALL__",a))(D||{});exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.createSqlGenConfig=e.createSqlGenConfig;exports.downloadPdf=e.downloadPdf;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.useCard=e.useCard;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=C.EMPTY_SELECTION;exports.AdvancedModeToggle=s.AdvancedModeToggle;exports.ResourceManagementPanel=s.ResourceManagementPanel;exports.ScheduleDashboard=s.ScheduleDashboard;exports.SelectComponent=s.SelectComponent;exports.ShareDialog=s.ShareDialog;exports.Surfboard=s.DashboardPlus;exports.VisualBadge=s.VisualBadge;exports.VisualEditingControls=s.VisualEditingControls;exports.cleanCard=s.cleanCard;exports.getDashbaordStateWithoutData=s.getDashbaordStateWithoutData;exports.DATE_FORMAT_VALUES=S;exports.PivotMarkerEnum=D;exports.Visual=h;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as u, F as c, S as h, U as f, a as p, C as T, u as m, b as l, c as C } from "./chunks/index-
|
|
2
|
-
import { D as L, h as k, R as Q, f as V, f as B, r as w, j as N, l as O, t as W, s as R, x as U, y as q, q as I, i as G, p as H, v as j, o as z, n as J, m as K, z as X, w as $, g as Z, B as aa, H as ea, G as sa, I as ra, k as oa, d as ta, K as Ya, A as na, J as ia, e as da } from "./chunks/index-
|
|
1
|
+
import { E as u, F as c, S as h, U as f, a as p, C as T, u as m, b as l, c as C } from "./chunks/index-BATJPB8E.js";
|
|
2
|
+
import { D as L, h as k, R as Q, f as V, f as B, r as w, j as N, l as O, t as W, s as R, x as U, y as q, q as I, i as G, p as H, v as j, o as z, n as J, m as K, z as X, w as $, g as Z, B as aa, H as ea, G as sa, I as ra, k as oa, d as ta, K as Ya, A as na, J as ia, e as da } from "./chunks/index-BATJPB8E.js";
|
|
3
3
|
import { EMPTY_SELECTION as ua } from "./types/index.js";
|
|
4
|
-
import { A as Da, R as ca, b as ha, c as fa, S as pa, D as Ta, a as ma, V as Ca, d as ga, g as ba } from "./chunks/dashboard-plus-
|
|
4
|
+
import { A as Da, R as ca, b as ha, c as fa, S as pa, D as Ta, a as ma, V as Ca, d as ga, g as ba } from "./chunks/dashboard-plus-CvIEcQve.js";
|
|
5
5
|
import { jsx as s } from "react/jsx-runtime";
|
|
6
6
|
import { useMemo as g } from "react";
|
|
7
7
|
import "react-dom";
|
package/dist/surfboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/dashboard-plus-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/dashboard-plus-DzJwjJjJ.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
|
package/dist/surfboard/index.js
CHANGED