react-semaphor 0.1.457 → 0.1.459

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +1 -1
  3. package/dist/chunks/{dashboard-briefing-launcher-DujsUIww.js → dashboard-briefing-launcher-ClCj98sq.js} +3 -3
  4. package/dist/chunks/{dashboard-briefing-launcher-W5sKgsYF.cjs → dashboard-briefing-launcher-DHtEouuH.cjs} +1 -1
  5. package/dist/chunks/{dashboard-controls-DZ5SgVcR.js → dashboard-controls-B8gsKlxc.js} +4 -4
  6. package/dist/chunks/{dashboard-controls-Cbw_M-lb.cjs → dashboard-controls-VRShl9J0.cjs} +1 -1
  7. package/dist/chunks/{dashboard-json-D9V7Vsvn.cjs → dashboard-json-BhvPMpZA.cjs} +1 -1
  8. package/dist/chunks/{dashboard-json-CHfML8Ff.js → dashboard-json-i_Auue_K.js} +2 -2
  9. package/dist/chunks/{edit-dashboard-visual-CLqJGsMx.js → edit-dashboard-visual-B3JF0fe4.js} +646 -640
  10. package/dist/chunks/{edit-dashboard-visual-BLmOGhEP.cjs → edit-dashboard-visual-DWWyT55u.cjs} +10 -10
  11. package/dist/chunks/{editor-action-buttons-C87bPAfR.cjs → editor-action-buttons-BTlCsP63.cjs} +1 -1
  12. package/dist/chunks/{editor-action-buttons-BVN1okyo.js → editor-action-buttons-C9x3nGnb.js} +2 -2
  13. package/dist/chunks/{index--A6SZu3V.js → index-BS2-ZZGf.js} +3833 -3798
  14. package/dist/chunks/{index-BFar58xY.cjs → index-DHF-2AqS.cjs} +3 -3
  15. package/dist/chunks/{report-preferences-dialog-DQtQZ3fF.js → report-preferences-dialog-BDpkcUtz.js} +2 -2
  16. package/dist/chunks/{report-preferences-dialog-DajdnPvA.cjs → report-preferences-dialog-BK0yAJnQ.cjs} +1 -1
  17. package/dist/chunks/{switch-BOBLNHUj.js → switch-DQR-Va05.js} +457 -439
  18. package/dist/chunks/{switch-BHOdIXq3.cjs → switch-f3TuZNLr.cjs} +16 -16
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/data-app-builder/index.cjs +1 -1
  22. package/dist/data-app-builder/index.js +2 -2
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +6 -6
  25. package/dist/surfboard/index.cjs +1 -1
  26. package/dist/surfboard/index.js +2 -2
  27. package/dist/types/briefings.d.ts +2 -0
  28. package/dist/types/dashboard-authoring.d.ts +2 -0
  29. package/dist/types/dashboard.d.ts +2 -0
  30. package/dist/types/main.d.ts +2 -0
  31. package/dist/types/shared.d.ts +2 -0
  32. package/dist/types/surfboard.d.ts +2 -0
  33. package/dist/types/types.d.ts +2 -0
  34. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";var Lxe=Object.defineProperty;var sB=e=>{throw TypeError(e)};var $xe=(e,t,n)=>t in e?Lxe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ne=(e,t,n)=>$xe(e,typeof t!="symbol"?t+"":t,n),$T=(e,t,n)=>t.has(e)||sB("Cannot "+n);var ve=(e,t,n)=>($T(e,t,"read from private field"),n?n.call(e):t.get(e)),At=(e,t,n)=>t.has(e)?sB("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),yt=(e,t,n,r)=>($T(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Qt=(e,t,n)=>($T(e,t,"access private method"),n);var hC=(e,t,n,r)=>({set _(o){yt(e,t,o,n)},get _(){return ve(e,t,r)}});const l=require("react/jsx-runtime"),v=require("react"),br=require("react-dom"),p=require("./switch-BHOdIXq3.cjs"),je=require("./x-B6ghREd2.cjs"),dt=require("./saved-temporal-bucket-format-CFfWXRl9.cjs"),va=require("./validators-BDYprKI9.cjs");require("./analyze-result-contract-LPDNldic.cjs");const Li=require("../value-format-preferences/index.cjs"),cf=require("./index-ByFbacH7.cjs"),zxe=require("react-dom/client"),qc=require("./temporal-bucket-authoring-o3Emn05L.cjs"),Ft=require("./search-BqqhaMx9.cjs"),Tk=require("./canonical-result-keys-BA0HCP4e.cjs"),Bxe=require("./color-CyB5o13F.cjs"),Vxe=require("./token-types-D7CaaI80.cjs"),it=require("./index-k8tEp0ys.cjs"),$r=require("./temporal-bucket-DHY1y9lq.cjs"),fn=require("./pivot-header-presentation-B9nXXKlW.cjs"),wa=require("./pivot-result-identity-Bb4EixVN.cjs"),$t=require("./pivot-result-lifecycle-DTLRuDEW.cjs"),Kt=require("./format-types-PSZZ7hG8.cjs"),Oi=require("./matrix-result-contract-zamd9euI.cjs"),Ho=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.cjs"),xr=require("./common-types-C57kJ59w.cjs"),nY=require("../dashboard-assistant/index.cjs"),rY=require("./report-runtime-context-DqxS4wbi.cjs"),Hxe=require("./contracts-CtB2VONT.cjs"),qxe=require("../layouts/index.cjs"),iB=require("./index-F25jnH0p.cjs");function rO(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const aB=rO(l),te=rO(v),V2=rO(br);function Uxe(e){return Kt.toDate(e).getMonth()}function Wxe(e){return Kt.toDate(e).getFullYear()}function Xx(e,t){const r=Zxe(e);let o;if(r.date){const c=Xxe(r.date,2);o=Qxe(c.restDateString,c.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const s=o.getTime();let i=0,a;if(r.time&&(i=Jxe(r.time),isNaN(i)))return new Date(NaN);if(r.timezone){if(a=eye(r.timezone),isNaN(a))return new Date(NaN)}else{const c=new Date(s+i),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(s+i+a)}const mC={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Kxe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Gxe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Yxe=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Zxe(e){const t={},n=e.split(mC.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],mC.timeZoneDelimiter.test(t.date)&&(t.date=e.split(mC.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const o=mC.timezone.exec(r);o?(t.time=r.replace(o[1],""),t.timezone=o[1]):t.time=r}return t}function Xxe(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const o=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?o:s*100,restDateString:e.slice((r[1]||r[2]).length)}}function Qxe(e,t){if(t===null)return new Date(NaN);const n=e.match(Kxe);if(!n)return new Date(NaN);const r=!!n[4],o=ux(n[1]),s=ux(n[2])-1,i=ux(n[3]),a=ux(n[4]),c=ux(n[5])-1;if(r)return sye(t,a,c)?tye(t,a,c):new Date(NaN);{const u=new Date(0);return!rye(t,s,i)||!oye(t,o)?new Date(NaN):(u.setUTCFullYear(t,s,Math.max(o,i)),u)}}function ux(e){return e?parseInt(e):1}function Jxe(e){const t=e.match(Gxe);if(!t)return NaN;const n=zT(t[1]),r=zT(t[2]),o=zT(t[3]);return iye(n,r,o)?n*Kt.millisecondsInHour+r*Kt.millisecondsInMinute+o*1e3:NaN}function zT(e){return e&&parseFloat(e.replace(",","."))||0}function eye(e){if(e==="Z")return 0;const t=e.match(Yxe);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return aye(r,o)?n*(r*Kt.millisecondsInHour+o*Kt.millisecondsInMinute):NaN}function tye(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const o=r.getUTCDay()||7,s=(t-1)*7+n+1-o;return r.setUTCDate(r.getUTCDate()+s),r}const nye=[31,null,31,30,31,30,31,31,30,31,30,31];function oY(e){return e%400===0||e%4===0&&e%100!==0}function rye(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(nye[t]||(oY(e)?29:28))}function oye(e,t){return t>=1&&t<=(oY(e)?366:365)}function sye(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function iye(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function aye(e,t){return t>=0&&t<=59}var sN={exports:{}};sN.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=800,s=16,i=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",h="[object Error]",m="[object Function]",g="[object GeneratorFunction]",b="[object Map]",x="[object Number]",y="[object Null]",w="[object Object]",C="[object Proxy]",N="[object RegExp]",S="[object Set]",j="[object String]",_="[object Undefined]",k="[object WeakMap]",T="[object ArrayBuffer]",I="[object DataView]",E="[object Float32Array]",D="[object Float64Array]",R="[object Int8Array]",A="[object Int16Array]",F="[object Int32Array]",z="[object Uint8Array]",L="[object Uint8ClampedArray]",$="[object Uint16Array]",H="[object Uint32Array]",M=/[\\^$.*+?()[\]{}|]/g,B=/^\[object .+?Constructor\]$/,W=/^(?:0|[1-9]\d*)$/,P={};P[E]=P[D]=P[R]=P[A]=P[F]=P[z]=P[L]=P[$]=P[H]=!0,P[a]=P[c]=P[T]=P[d]=P[I]=P[f]=P[h]=P[m]=P[b]=P[x]=P[w]=P[N]=P[S]=P[j]=P[k]=!1;var G=typeof dt.commonjsGlobal=="object"&&dt.commonjsGlobal&&dt.commonjsGlobal.Object===Object&&dt.commonjsGlobal,Z=typeof self=="object"&&self&&self.Object===Object&&self,X=G||Z||Function("return this")(),Y=t&&!t.nodeType&&t,O=Y&&!0&&e&&!e.nodeType&&e,q=O&&O.exports===Y,U=q&&G.process,V=function(){try{var be=O&&O.require&&O.require("util").types;return be||U&&U.binding&&U.binding("util")}catch{}}(),K=V&&V.isTypedArray;function Q(be,_e,qe){switch(qe.length){case 0:return be.call(_e);case 1:return be.call(_e,qe[0]);case 2:return be.call(_e,qe[0],qe[1]);case 3:return be.call(_e,qe[0],qe[1],qe[2])}return be.apply(_e,qe)}function se(be,_e){for(var qe=-1,Ot=Array(be);++qe<be;)Ot[qe]=_e(qe);return Ot}function oe(be){return function(_e){return be(_e)}}function me(be,_e){return be==null?void 0:be[_e]}function le(be,_e){return function(qe){return be(_e(qe))}}var ue=Array.prototype,ne=Function.prototype,de=Object.prototype,Ce=X["__core-js_shared__"],ce=ne.toString,ie=de.hasOwnProperty,we=function(){var be=/[^.]+$/.exec(Ce&&Ce.keys&&Ce.keys.IE_PROTO||"");return be?"Symbol(src)_1."+be:""}(),fe=de.toString,ae=ce.call(Object),ee=RegExp("^"+ce.call(ie).replace(M,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),J=q?X.Buffer:void 0,re=X.Symbol,pe=X.Uint8Array;J&&J.allocUnsafe;var Ee=le(Object.getPrototypeOf,Object),Te=Object.create,ze=de.propertyIsEnumerable,Pe=ue.splice,He=re?re.toStringTag:void 0,ye=function(){try{var be=Co(Object,"defineProperty");return be({},"",{}),be}catch{}}(),Ke=J?J.isBuffer:void 0,We=Math.max,Qe=Date.now,xe=Co(X,"Map"),Ve=Co(Object,"create"),Ae=function(){function be(){}return function(_e){if(!Ht(_e))return{};if(Te)return Te(_e);be.prototype=_e;var qe=new be;return be.prototype=void 0,qe}}();function ke(be){var _e=-1,qe=be==null?0:be.length;for(this.clear();++_e<qe;){var Ot=be[_e];this.set(Ot[0],Ot[1])}}function Be(){this.__data__=Ve?Ve(null):{},this.size=0}function Ie(be){var _e=this.has(be)&&delete this.__data__[be];return this.size-=_e?1:0,_e}function $e(be){var _e=this.__data__;if(Ve){var qe=_e[be];return qe===r?void 0:qe}return ie.call(_e,be)?_e[be]:void 0}function st(be){var _e=this.__data__;return Ve?_e[be]!==void 0:ie.call(_e,be)}function ct(be,_e){var qe=this.__data__;return this.size+=this.has(be)?0:1,qe[be]=Ve&&_e===void 0?r:_e,this}ke.prototype.clear=Be,ke.prototype.delete=Ie,ke.prototype.get=$e,ke.prototype.has=st,ke.prototype.set=ct;function rt(be){var _e=-1,qe=be==null?0:be.length;for(this.clear();++_e<qe;){var Ot=be[_e];this.set(Ot[0],Ot[1])}}function Ct(){this.__data__=[],this.size=0}function Lt(be){var _e=this.__data__,qe=ot(_e,be);if(qe<0)return!1;var Ot=_e.length-1;return qe==Ot?_e.pop():Pe.call(_e,qe,1),--this.size,!0}function vt(be){var _e=this.__data__,qe=ot(_e,be);return qe<0?void 0:_e[qe][1]}function Tt(be){return ot(this.__data__,be)>-1}function Me(be,_e){var qe=this.__data__,Ot=ot(qe,be);return Ot<0?(++this.size,qe.push([be,_e])):qe[Ot][1]=_e,this}rt.prototype.clear=Ct,rt.prototype.delete=Lt,rt.prototype.get=vt,rt.prototype.has=Tt,rt.prototype.set=Me;function Je(be){var _e=-1,qe=be==null?0:be.length;for(this.clear();++_e<qe;){var Ot=be[_e];this.set(Ot[0],Ot[1])}}function kt(){this.size=0,this.__data__={hash:new ke,map:new(xe||rt),string:new ke}}function mt(be){var _e=Lr(this,be).delete(be);return this.size-=_e?1:0,_e}function _t(be){return Lr(this,be).get(be)}function Rt(be){return Lr(this,be).has(be)}function Pt(be,_e){var qe=Lr(this,be),Ot=qe.size;return qe.set(be,_e),this.size+=qe.size==Ot?0:1,this}Je.prototype.clear=kt,Je.prototype.delete=mt,Je.prototype.get=_t,Je.prototype.has=Rt,Je.prototype.set=Pt;function wt(be){var _e=this.__data__=new rt(be);this.size=_e.size}function Et(){this.__data__=new rt,this.size=0}function Bt(be){var _e=this.__data__,qe=_e.delete(be);return this.size=_e.size,qe}function un(be){return this.__data__.get(be)}function Ge(be){return this.__data__.has(be)}function Re(be,_e){var qe=this.__data__;if(qe instanceof rt){var Ot=qe.__data__;if(!xe||Ot.length<n-1)return Ot.push([be,_e]),this.size=++qe.size,this;qe=this.__data__=new Je(Ot)}return qe.set(be,_e),this.size=qe.size,this}wt.prototype.clear=Et,wt.prototype.delete=Bt,wt.prototype.get=un,wt.prototype.has=Ge,wt.prototype.set=Re;function De(be,_e){var qe=vc(be),Ot=!qe&&yc(be),gn=!qe&&!Ot&&us(be),Vn=!qe&&!Ot&&!gn&&Gt(be),mr=qe||Ot||gn||Vn,Hn=mr?se(be.length,String):[],cr=Hn.length;for(var _i in be)mr&&(_i=="length"||gn&&(_i=="offset"||_i=="parent")||Vn&&(_i=="buffer"||_i=="byteLength"||_i=="byteOffset")||xl(_i,cr))||Hn.push(_i);return Hn}function he(be,_e,qe){(qe!==void 0&&!yl(be[_e],qe)||qe===void 0&&!(_e in be))&&Dt(be,_e,qe)}function Fe(be,_e,qe){var Ot=be[_e];(!(ie.call(be,_e)&&yl(Ot,qe))||qe===void 0&&!(_e in be))&&Dt(be,_e,qe)}function ot(be,_e){for(var qe=be.length;qe--;)if(yl(be[qe][0],_e))return qe;return-1}function Dt(be,_e,qe){_e=="__proto__"&&ye?ye(be,_e,{configurable:!0,enumerable:!0,value:qe,writable:!0}):be[_e]=qe}var nt=Rs();function ge(be){return be==null?be===void 0?_:y:He&&He in Object(be)?Qi(be):oi(be)}function Se(be){return wn(be)&&ge(be)==a}function Oe(be){if(!Ht(be)||Ps(be))return!1;var _e=Wu(be)?ee:B;return _e.test(Uu(be))}function Ye(be){return wn(be)&&Xe(be.length)&&!!P[ge(be)]}function bt(be){if(!Ht(be))return qu(be);var _e=If(be),qe=[];for(var Ot in be)Ot=="constructor"&&(_e||!ie.call(be,Ot))||qe.push(Ot);return qe}function St(be,_e,qe,Ot,gn){be!==_e&&nt(_e,function(Vn,mr){if(gn||(gn=new wt),Ht(Vn))on(be,_e,mr,qe,St,Ot,gn);else{var Hn=Ot?Ot($n(be,mr),Vn,mr+"",be,_e,gn):void 0;Hn===void 0&&(Hn=Vn),he(be,mr,Hn)}},An)}function on(be,_e,qe,Ot,gn,Vn,mr){var Hn=$n(be,qe),cr=$n(_e,qe),_i=mr.get(cr);if(_i){he(be,qe,_i);return}var Fs=Vn?Vn(Hn,cr,qe+"",be,_e,mr):void 0,Gu=Fs===void 0;if(Gu){var lx=vc(cr),cx=!lx&&us(cr),fC=!lx&&!cx&&Gt(cr);Fs=cr,lx||cx||fC?vc(Hn)?Fs=Hn:So(Hn)?Fs=Vt(Hn):cx?(Gu=!1,Fs=et(cr)):fC?(Gu=!1,Fs=ht(cr)):Fs=[]:nn(cr)||yc(cr)?(Fs=Hn,yc(Hn)?Fs=or(Hn):(!Ht(Hn)||Wu(Hn))&&(Fs=Hu(cr))):Gu=!1}Gu&&(mr.set(cr,Fs),gn(Fs,cr,Ot,Vn,mr),mr.delete(cr)),he(be,qe,Fs)}function sn(be,_e){return Tf(xc(be,_e,co),be+"")}var Le=ye?function(be,_e){return ye(be,"toString",{configurable:!0,enumerable:!1,value:Nr(_e),writable:!0})}:co;function et(be,_e){return be.slice()}function at(be){var _e=new be.constructor(be.byteLength);return new pe(_e).set(new pe(be)),_e}function ht(be,_e){var qe=at(be.buffer);return new be.constructor(qe,be.byteOffset,be.length)}function Vt(be,_e){var qe=-1,Ot=be.length;for(_e||(_e=Array(Ot));++qe<Ot;)_e[qe]=be[qe];return _e}function Xn(be,_e,qe,Ot){var gn=!qe;qe||(qe={});for(var Vn=-1,mr=_e.length;++Vn<mr;){var Hn=_e[Vn],cr=void 0;cr===void 0&&(cr=be[Hn]),gn?Dt(qe,Hn,cr):Fe(qe,Hn,cr)}return qe}function Go(be){return sn(function(_e,qe){var Ot=-1,gn=qe.length,Vn=gn>1?qe[gn-1]:void 0,mr=gn>2?qe[2]:void 0;for(Vn=be.length>3&&typeof Vn=="function"?(gn--,Vn):void 0,mr&&ki(qe[0],qe[1],mr)&&(Vn=gn<3?void 0:Vn,gn=1),_e=Object(_e);++Ot<gn;){var Hn=qe[Ot];Hn&&be(_e,Hn,Ot,Vn)}return _e})}function Rs(be){return function(_e,qe,Ot){for(var gn=-1,Vn=Object(_e),mr=Ot(_e),Hn=mr.length;Hn--;){var cr=mr[++gn];if(qe(Vn[cr],cr,Vn)===!1)break}return _e}}function Lr(be,_e){var qe=be.__data__;return As(_e)?qe[typeof _e=="string"?"string":"hash"]:qe.map}function Co(be,_e){var qe=me(be,_e);return Oe(qe)?qe:void 0}function Qi(be){var _e=ie.call(be,He),qe=be[He];try{be[He]=void 0;var Ot=!0}catch{}var gn=fe.call(be);return Ot&&(_e?be[He]=qe:delete be[He]),gn}function Hu(be){return typeof be.constructor=="function"&&!If(be)?Ae(Ee(be)):{}}function xl(be,_e){var qe=typeof be;return _e=_e??i,!!_e&&(qe=="number"||qe!="symbol"&&W.test(be))&&be>-1&&be%1==0&&be<_e}function ki(be,_e,qe){if(!Ht(qe))return!1;var Ot=typeof _e;return(Ot=="number"?vl(qe)&&xl(_e,qe.length):Ot=="string"&&_e in qe)?yl(qe[_e],be):!1}function As(be){var _e=typeof be;return _e=="string"||_e=="number"||_e=="symbol"||_e=="boolean"?be!=="__proto__":be===null}function Ps(be){return!!we&&we in be}function If(be){var _e=be&&be.constructor,qe=typeof _e=="function"&&_e.prototype||de;return be===qe}function qu(be){var _e=[];if(be!=null)for(var qe in Object(be))_e.push(qe);return _e}function oi(be){return fe.call(be)}function xc(be,_e,qe){return _e=We(_e===void 0?be.length-1:_e,0),function(){for(var Ot=arguments,gn=-1,Vn=We(Ot.length-_e,0),mr=Array(Vn);++gn<Vn;)mr[gn]=Ot[_e+gn];gn=-1;for(var Hn=Array(_e+1);++gn<_e;)Hn[gn]=Ot[gn];return Hn[_e]=qe(mr),Q(be,this,Hn)}}function $n(be,_e){if(!(_e==="constructor"&&typeof be[_e]=="function")&&_e!="__proto__")return be[_e]}var Tf=Ma(Le);function Ma(be){var _e=0,qe=0;return function(){var Ot=Qe(),gn=s-(Ot-qe);if(qe=Ot,gn>0){if(++_e>=o)return arguments[0]}else _e=0;return be.apply(void 0,arguments)}}function Uu(be){if(be!=null){try{return ce.call(be)}catch{}try{return be+""}catch{}}return""}function yl(be,_e){return be===_e||be!==be&&_e!==_e}var yc=Se(function(){return arguments}())?Se:function(be){return wn(be)&&ie.call(be,"callee")&&!ze.call(be,"callee")},vc=Array.isArray;function vl(be){return be!=null&&Xe(be.length)&&!Wu(be)}function So(be){return wn(be)&&vl(be)}var us=Ke||Ku;function Wu(be){if(!Ht(be))return!1;var _e=ge(be);return _e==m||_e==g||_e==u||_e==C}function Xe(be){return typeof be=="number"&&be>-1&&be%1==0&&be<=i}function Ht(be){var _e=typeof be;return be!=null&&(_e=="object"||_e=="function")}function wn(be){return be!=null&&typeof be=="object"}function nn(be){if(!wn(be)||ge(be)!=w)return!1;var _e=Ee(be);if(_e===null)return!0;var qe=ie.call(_e,"constructor")&&_e.constructor;return typeof qe=="function"&&qe instanceof qe&&ce.call(qe)==ae}var Gt=K?oe(K):Ye;function or(be){return Xn(be,An(be))}function An(be){return vl(be)?De(be):bt(be)}var Dr=Go(function(be,_e,qe){St(be,_e,qe)});function Nr(be){return function(){return be}}function co(be){return be}function Ku(){return!1}e.exports=Dr})(sN,sN.exports);var lye=sN.exports;const Jl=dt.getDefaultExportFromCjs(lye),cye={theme:"system",setTheme:()=>null},sY=v.createContext(cye);function iN(e,t="system"){return uye(e)?e:t}function uye(e){return e==="light"||e==="dark"||e==="system"}const oO=()=>{const e=v.useContext(sY);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},iY=(e,t)=>{const n={};if(e===null||t===null)return t;const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const o of r){if(!(o in e)&&o in t){n[o]=t[o];continue}if(o in e&&!(o in t)){n[o]=void 0;continue}const s=e[o],i=t[o];if(!H2(s,i))if(Array.isArray(s)&&Array.isArray(i))n[o]=i;else if(lB(s)&&lB(i)){const a=iY(s,i);Object.keys(a).length>0&&(n[o]=a)}else n[o]=i}return n},H2=(e,t)=>{if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((o,s)=>H2(o,t[s]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(o=>H2(e[o],t[o]))}return!1},lB=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ks=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(Array.isArray(e))return e.map(n=>Ks(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=Ks(e[n]));return t},aY="__semaphorAuthoredFontFamily";var VG,HG;const dye=(HG=(VG=dt.DEFAULT_STYLE.default.chart)==null?void 0:VG.font)==null?void 0:HG.family,fye=new Set([dye,"Open Sans, Arial, sans-serif",'"Open Sans", Arial, sans-serif'].filter(Boolean));function hye(e,t){if(!e)return t?{family:t}:void 0;const{[aY]:n,...r}=e,o=mye(r.family,t,!!n);return{...r,...o?{family:o}:void 0}}function mye(e,t,n=!1){return n&&e||e&&!pye(e)?e:t||e}function pye(e){return fye.has(e.trim())}function gye(e,t){if(!t)return e;const n={...e,font:sa(e.font,t)},r=yye(e.plugins,t);r&&(n.plugins=r);const o=vye(e.scales,t);return o&&(n.scales=o),n}function bye(e,t){return!e||!t?e:e.map(n=>{if(!n||typeof n!="object")return n;const r=n,o=r.datalabels;return!o||typeof o!="object"?n:{...r,datalabels:{...o,font:sa(o.font,t)}}})}function xye(e,t){if(!e||typeof e!="object"||!t)return e;const n=e.datasets;return Array.isArray(n)?{...e,datasets:bye(n,t)}:e}function yye(e,t){var n;return e&&{...e,title:e.title?{...e.title,font:sa(e.title.font,t)}:e.title,subtitle:e.subtitle?{...e.subtitle,font:sa(e.subtitle.font,t)}:e.subtitle,legend:e.legend?{...e.legend,labels:e.legend.labels?{...e.legend.labels,font:sa(e.legend.labels.font,t)}:e.legend.labels}:e.legend,tooltip:e.tooltip?{...e.tooltip,titleFont:sa(e.tooltip.titleFont,t),bodyFont:sa(e.tooltip.bodyFont,t),footerFont:sa(e.tooltip.footerFont,t)}:e.tooltip,datalabels:e.datalabels?{...e.datalabels,font:sa((n=e.datalabels)==null?void 0:n.font,t)}:e.datalabels}}function vye(e,t){return e&&Object.entries(e).reduce((n,[r,o])=>{if(!o||typeof o!="object")return n[r]=o,n;const s=o;return n[r]={...s,ticks:s.ticks?{...s.ticks,font:sa(s.ticks.font,t)}:s.ticks,title:s.title?{...s.title,font:sa(s.title.font,t)}:s.title,pointLabels:s.pointLabels?{...s.pointLabels,font:sa(s.pointLabels.font,t)}:s.pointLabels},n},{})}function sa(e,t){return typeof e=="function"?e:{...t,...e&&typeof e=="object"?e:{}}}function wye(e,t){const n=Ks(e??{}),r=Cye(t);if(!r)return n;const o=Jl(n,r);return jye(o,r),o}function Cye(e){var h,m,g,b;const t=(h=e.scheme.components)==null?void 0:h.chart,n=cf.SEMAPHOR_DEFAULT_APPEARANCE_SPEC.schemes[e.mode],r=(m=n.components)==null?void 0:m.chart,o=(g=n.tokens)==null?void 0:g.typography,s={};Nye(t==null?void 0:t.palette,r==null?void 0:r.palette)&&(s.dataset={backgroundColor:[...t.palette],borderColor:[...t.palette]});const i=(b=e.scheme.tokens)==null?void 0:b.typography,a=ap(i==null?void 0:i.fontFamily,o==null?void 0:o.fontFamily),c=ap(i==null?void 0:i.baseFontSize,o==null?void 0:o.baseFontSize);if(a||c!==void 0){const x={...a?{family:a}:void 0,...c!==void 0?{size:c}:void 0};a&&(x[aY]=!0),s.font=x}const u=ap(t==null?void 0:t.gridColor,r==null?void 0:r.gridColor),d=ap(t==null?void 0:t.axisColor,r==null?void 0:r.axisColor)??ap(t==null?void 0:t.foreground,r==null?void 0:r.foreground);(u||d)&&(s.options={scales:{x:BT({gridColor:u,axisColor:d}),y:BT({gridColor:u,axisColor:d}),y2:BT({gridColor:u,axisColor:d}),r:Sye({gridColor:u,axisColor:d})}});const f=ap(t==null?void 0:t.foreground,r==null?void 0:r.foreground);return f&&(s.options=Jl(s.options??{},{plugins:{legend:{labels:{color:f}}}})),Object.keys(s).length>0?{chart:s}:void 0}function BT({gridColor:e,axisColor:t}){return{...e?{grid:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t}}:void 0}}function Sye({gridColor:e,axisColor:t}){return{...e?{grid:{color:e},angleLines:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t},pointLabels:{color:t}}:void 0}}function Nye(e,t){return e!=null&&e.length?!(t!=null&&t.length)||e.length!==t.length?!0:e.some((n,r)=>n!==t[r]):!1}function ap(e,t){return e!==void 0&&e!==t?e:void 0}function jye(e,t){var r;const n=(r=t.chart)==null?void 0:r.dataset;n&&(e.chart=e.chart??{},e.chart.dataset=e.chart.dataset??{},Array.isArray(n.backgroundColor)&&(e.chart.dataset.backgroundColor=[...n.backgroundColor]),Array.isArray(n.borderColor)&&(e.chart.dataset.borderColor=[...n.borderColor]))}var Em=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},kye={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Rl,wh,qG,_ye=(qG=class{constructor(){At(this,Rl,kye);At(this,wh,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&ve(this,wh)&&e!==ve(this,Rl)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:ve(this,Rl),provider:e}),yt(this,Rl,e),process.env.NODE_ENV!=="production"&&yt(this,wh,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&yt(this,wh,!0),ve(this,Rl).setTimeout(e,t)}clearTimeout(e){ve(this,Rl).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&yt(this,wh,!0),ve(this,Rl).setInterval(e,t)}clearInterval(e){ve(this,Rl).clearInterval(e)}},Rl=new WeakMap,wh=new WeakMap,qG),lh=new _ye;function Iye(e){setTimeout(e,0)}var Zh=typeof window>"u"||"Deno"in globalThis;function gs(){}function Tye(e,t){return typeof e=="function"?e(t):e}function q2(e){return typeof e=="number"&&e>=0&&e!==1/0}function lY(e,t){return Math.max(e+(t||0)-Date.now(),0)}function _d(e,t){return typeof e=="function"?e(t):e}function ia(e,t){return typeof e=="function"?e(t):e}function cB(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:s,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==sO(i,t.options))return!1}else if(!f0(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||s&&!s(t))}function uB(e,t){const{exact:n,status:r,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(Xh(t.options.mutationKey)!==Xh(s))return!1}else if(!f0(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function sO(e,t){return((t==null?void 0:t.queryKeyHashFn)||Xh)(e)}function Xh(e){return JSON.stringify(e,(t,n)=>U2(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function f0(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>f0(e[n],t[n])):!1}var Eye=Object.prototype.hasOwnProperty;function aN(e,t){if(e===t)return e;const n=dB(e)&&dB(t);if(!n&&!(U2(e)&&U2(t)))return t;const o=(n?e:Object.keys(e)).length,s=n?t:Object.keys(t),i=s.length,a=n?new Array(i):{};let c=0;for(let u=0;u<i;u++){const d=n?u:s[u],f=e[d],h=t[d];if(f===h){a[d]=f,(n?u<o:Eye.call(e,d))&&c++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){a[d]=h;continue}const m=aN(f,h);a[d]=m,m===f&&c++}return o===i&&c===o?e:a}function h0(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function dB(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function U2(e){if(!fB(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!fB(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function fB(e){return Object.prototype.toString.call(e)==="[object Object]"}function Dye(e){return new Promise(t=>{lh.setTimeout(t,e)})}function W2(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return aN(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return aN(e,t)}return t}function Mye(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Rye(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var lN=Symbol();function cY(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===lN&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===lN?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function uY(e,t){return typeof e=="function"?e(...t):!!e}var Ch,id,hg,UG,Aye=(UG=class extends Em{constructor(){super();At(this,Ch);At(this,id);At(this,hg);yt(this,hg,t=>{if(!Zh&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){ve(this,id)||this.setEventListener(ve(this,hg))}onUnsubscribe(){var t;this.hasListeners()||((t=ve(this,id))==null||t.call(this),yt(this,id,void 0))}setEventListener(t){var n;yt(this,hg,t),(n=ve(this,id))==null||n.call(this),yt(this,id,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){ve(this,Ch)!==t&&(yt(this,Ch,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof ve(this,Ch)=="boolean"?ve(this,Ch):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ch=new WeakMap,id=new WeakMap,hg=new WeakMap,UG),iO=new Aye;function K2(){let e,t;const n=new Promise((o,s)=>{e=o,t=s});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}var Pye=Iye;function Fye(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Pye;const s=a=>{t?e.push(a):o(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{s(()=>{a(...c)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var Ur=Fye(),mg,ad,pg,WG,Oye=(WG=class extends Em{constructor(){super();At(this,mg,!0);At(this,ad);At(this,pg);yt(this,pg,t=>{if(!Zh&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){ve(this,ad)||this.setEventListener(ve(this,pg))}onUnsubscribe(){var t;this.hasListeners()||((t=ve(this,ad))==null||t.call(this),yt(this,ad,void 0))}setEventListener(t){var n;yt(this,pg,t),(n=ve(this,ad))==null||n.call(this),yt(this,ad,t(this.setOnline.bind(this)))}setOnline(t){ve(this,mg)!==t&&(yt(this,mg,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return ve(this,mg)}},mg=new WeakMap,ad=new WeakMap,pg=new WeakMap,WG),cN=new Oye;function Lye(e){return Math.min(1e3*2**e,3e4)}function dY(e){return(e??"online")==="online"?cN.isOnline():!0}var G2=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function fY(e){let t=!1,n=0,r;const o=K2(),s=()=>o.status!=="pending",i=b=>{var x;if(!s()){const y=new G2(b);h(y),(x=e.onCancel)==null||x.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>iO.isFocused()&&(e.networkMode==="always"||cN.isOnline())&&e.canRun(),d=()=>dY(e.networkMode)&&e.canRun(),f=b=>{s()||(r==null||r(),o.resolve(b))},h=b=>{s()||(r==null||r(),o.reject(b))},m=()=>new Promise(b=>{var x;r=y=>{(s()||u())&&b(y)},(x=e.onPause)==null||x.call(e)}).then(()=>{var b;r=void 0,s()||(b=e.onContinue)==null||b.call(e)}),g=()=>{if(s())return;let b;const x=n===0?e.initialPromise:void 0;try{b=x??e.fn()}catch(y){b=Promise.reject(y)}Promise.resolve(b).then(f).catch(y=>{var j;if(s())return;const w=e.retry??(Zh?0:3),C=e.retryDelay??Lye,N=typeof C=="function"?C(n,y):C,S=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!S){h(y);return}n++,(j=e.onFail)==null||j.call(e,n,y),Dye(N).then(()=>u()?void 0:m()).then(()=>{t?h(y):g()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(r==null||r(),o),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?g():m().then(g),o)}}var Sh,KG,hY=(KG=class{constructor(){At(this,Sh)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),q2(this.gcTime)&&yt(this,Sh,lh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zh?1/0:5*60*1e3))}clearGcTimeout(){ve(this,Sh)&&(lh.clearTimeout(ve(this,Sh)),yt(this,Sh,void 0))}},Sh=new WeakMap,KG),Nh,gg,ra,jh,Ao,kv,kh,Oa,kc,GG,$ye=(GG=class extends hY{constructor(t){super();At(this,Oa);At(this,Nh);At(this,gg);At(this,ra);At(this,jh);At(this,Ao);At(this,kv);At(this,kh);yt(this,kh,!1),yt(this,kv,t.defaultOptions),this.setOptions(t.options),this.observers=[],yt(this,jh,t.client),yt(this,ra,ve(this,jh).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,yt(this,Nh,mB(this.options)),this.state=t.state??ve(this,Nh),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=ve(this,Ao))==null?void 0:t.promise}setOptions(t){if(this.options={...ve(this,kv),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=mB(this.options);n.data!==void 0&&(this.setState(hB(n.data,n.dataUpdatedAt)),yt(this,Nh,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ve(this,ra).remove(this)}setData(t,n){const r=W2(this.state.data,t,this.options);return Qt(this,Oa,kc).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Qt(this,Oa,kc).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=ve(this,Ao))==null?void 0:r.promise;return(o=ve(this,Ao))==null||o.cancel(t),n?n.then(gs).catch(gs):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ve(this,Nh))}isActive(){return this.observers.some(t=>ia(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===lN||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>_d(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lY(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=ve(this,Ao))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=ve(this,Ao))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),ve(this,ra).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(ve(this,Ao)&&(ve(this,kh)?ve(this,Ao).cancel({revert:!0}):ve(this,Ao).cancelRetry()),this.scheduleGc()),ve(this,ra).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Qt(this,Oa,kc).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,h,m,g,b,x,y,w,C;if(this.state.fetchStatus!=="idle"&&((c=ve(this,Ao))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(ve(this,Ao))return ve(this,Ao).continueRetry(),ve(this,Ao).promise}if(t&&this.setOptions(t),!this.options.queryFn){const N=this.observers.find(S=>S.options.queryFn);N&&this.setOptions(N.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=N=>{Object.defineProperty(N,"signal",{enumerable:!0,get:()=>(yt(this,kh,!0),r.signal)})},s=()=>{const N=cY(this.options,n),j=(()=>{const _={client:ve(this,jh),queryKey:this.queryKey,meta:this.meta};return o(_),_})();return yt(this,kh,!1),this.options.persister?this.options.persister(N,j,this):N(j)},a=(()=>{const N={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:ve(this,jh),state:this.state,fetchFn:s};return o(N),N})();(u=this.options.behavior)==null||u.onFetch(a,this),yt(this,gg,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&Qt(this,Oa,kc).call(this,{type:"fetch",meta:(f=a.fetchOptions)==null?void 0:f.meta}),yt(this,Ao,fY({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:N=>{N instanceof G2&&N.revert&&this.setState({...ve(this,gg),fetchStatus:"idle"}),r.abort()},onFail:(N,S)=>{Qt(this,Oa,kc).call(this,{type:"failed",failureCount:N,error:S})},onPause:()=>{Qt(this,Oa,kc).call(this,{type:"pause"})},onContinue:()=>{Qt(this,Oa,kc).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const N=await ve(this,Ao).start();if(N===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(N),(m=(h=ve(this,ra).config).onSuccess)==null||m.call(h,N,this),(b=(g=ve(this,ra).config).onSettled)==null||b.call(g,N,this.state.error,this),N}catch(N){if(N instanceof G2){if(N.silent)return ve(this,Ao).promise;if(N.revert){if(this.state.data===void 0)throw N;return this.state.data}}throw Qt(this,Oa,kc).call(this,{type:"error",error:N}),(y=(x=ve(this,ra).config).onError)==null||y.call(x,N,this),(C=(w=ve(this,ra).config).onSettled)==null||C.call(w,this.state.data,N,this),N}finally{this.scheduleGc()}}},Nh=new WeakMap,gg=new WeakMap,ra=new WeakMap,jh=new WeakMap,Ao=new WeakMap,kv=new WeakMap,kh=new WeakMap,Oa=new WeakSet,kc=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...mY(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,...hB(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return yt(this,gg,t.manual?o:void 0),o;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ur.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),ve(this,ra).notify({query:this,type:"updated",action:t})})},GG);function mY(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:dY(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function hB(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function mB(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var di,Pn,_v,Hs,_h,bg,Pc,ld,Iv,xg,yg,Ih,Th,cd,vg,rr,Qx,Y2,Z2,X2,Q2,J2,eR,tR,pY,YG,aO=(YG=class extends Em{constructor(t,n){super();At(this,rr);At(this,di);At(this,Pn);At(this,_v);At(this,Hs);At(this,_h);At(this,bg);At(this,Pc);At(this,ld);At(this,Iv);At(this,xg);At(this,yg);At(this,Ih);At(this,Th);At(this,cd);At(this,vg,new Set);this.options=n,yt(this,di,t),yt(this,ld,null),yt(this,Pc,K2()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ve(this,Pn).addObserver(this),pB(ve(this,Pn),this.options)?Qt(this,rr,Qx).call(this):this.updateResult(),Qt(this,rr,Q2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nR(ve(this,Pn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nR(ve(this,Pn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Qt(this,rr,J2).call(this),Qt(this,rr,eR).call(this),ve(this,Pn).removeObserver(this)}setOptions(t){const n=this.options,r=ve(this,Pn);if(this.options=ve(this,di).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ia(this.options.enabled,ve(this,Pn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Qt(this,rr,tR).call(this),ve(this,Pn).setOptions(this.options),n._defaulted&&!h0(this.options,n)&&ve(this,di).getQueryCache().notify({type:"observerOptionsUpdated",query:ve(this,Pn),observer:this});const o=this.hasListeners();o&&gB(ve(this,Pn),r,this.options,n)&&Qt(this,rr,Qx).call(this),this.updateResult(),o&&(ve(this,Pn)!==r||ia(this.options.enabled,ve(this,Pn))!==ia(n.enabled,ve(this,Pn))||_d(this.options.staleTime,ve(this,Pn))!==_d(n.staleTime,ve(this,Pn)))&&Qt(this,rr,Y2).call(this);const s=Qt(this,rr,Z2).call(this);o&&(ve(this,Pn)!==r||ia(this.options.enabled,ve(this,Pn))!==ia(n.enabled,ve(this,Pn))||s!==ve(this,cd))&&Qt(this,rr,X2).call(this,s)}getOptimisticResult(t){const n=ve(this,di).getQueryCache().build(ve(this,di),t),r=this.createResult(n,t);return Bye(this,r)&&(yt(this,Hs,r),yt(this,bg,this.options),yt(this,_h,ve(this,Pn).state)),r}getCurrentResult(){return ve(this,Hs)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&ve(this,Pc).status==="pending"&&ve(this,Pc).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(t){ve(this,vg).add(t)}getCurrentQuery(){return ve(this,Pn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=ve(this,di).defaultQueryOptions(t),r=ve(this,di).getQueryCache().build(ve(this,di),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Qt(this,rr,Qx).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ve(this,Hs)))}createResult(t,n){var T;const r=ve(this,Pn),o=this.options,s=ve(this,Hs),i=ve(this,_h),a=ve(this,bg),u=t!==r?t.state:ve(this,_v),{state:d}=t;let f={...d},h=!1,m;if(n._optimisticResults){const I=this.hasListeners(),E=!I&&pB(t,n),D=I&&gB(t,r,n,o);(E||D)&&(f={...f,...mY(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=f;m=f.data;let y=!1;if(n.placeholderData!==void 0&&m===void 0&&x==="pending"){let I;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(I=s.data,y=!0):I=typeof n.placeholderData=="function"?n.placeholderData((T=ve(this,yg))==null?void 0:T.state.data,ve(this,yg)):n.placeholderData,I!==void 0&&(x="success",m=W2(s==null?void 0:s.data,I,n),h=!0)}if(n.select&&m!==void 0&&!y)if(s&&m===(i==null?void 0:i.data)&&n.select===ve(this,Iv))m=ve(this,xg);else try{yt(this,Iv,n.select),m=n.select(m),m=W2(s==null?void 0:s.data,m,n),yt(this,xg,m),yt(this,ld,null)}catch(I){yt(this,ld,I)}ve(this,ld)&&(g=ve(this,ld),m=ve(this,xg),b=Date.now(),x="error");const w=f.fetchStatus==="fetching",C=x==="pending",N=x==="error",S=C&&w,j=m!==void 0,k={status:x,fetchStatus:f.fetchStatus,isPending:C,isSuccess:x==="success",isError:N,isInitialLoading:S,isLoading:S,data:m,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!C,isLoadingError:N&&!j,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&j,isStale:lO(t,n),refetch:this.refetch,promise:ve(this,Pc),isEnabled:ia(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=R=>{k.status==="error"?R.reject(k.error):k.data!==void 0&&R.resolve(k.data)},E=()=>{const R=yt(this,Pc,k.promise=K2());I(R)},D=ve(this,Pc);switch(D.status){case"pending":t.queryHash===r.queryHash&&I(D);break;case"fulfilled":(k.status==="error"||k.data!==D.value)&&E();break;case"rejected":(k.status!=="error"||k.error!==D.reason)&&E();break}}return k}updateResult(){const t=ve(this,Hs),n=this.createResult(ve(this,Pn),this.options);if(yt(this,_h,ve(this,Pn).state),yt(this,bg,this.options),ve(this,_h).data!==void 0&&yt(this,yg,ve(this,Pn)),h0(n,t))return;yt(this,Hs,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,s=typeof o=="function"?o():o;if(s==="all"||!s&&!ve(this,vg).size)return!0;const i=new Set(s??ve(this,vg));return this.options.throwOnError&&i.add("error"),Object.keys(ve(this,Hs)).some(a=>{const c=a;return ve(this,Hs)[c]!==t[c]&&i.has(c)})};Qt(this,rr,pY).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Qt(this,rr,Q2).call(this)}},di=new WeakMap,Pn=new WeakMap,_v=new WeakMap,Hs=new WeakMap,_h=new WeakMap,bg=new WeakMap,Pc=new WeakMap,ld=new WeakMap,Iv=new WeakMap,xg=new WeakMap,yg=new WeakMap,Ih=new WeakMap,Th=new WeakMap,cd=new WeakMap,vg=new WeakMap,rr=new WeakSet,Qx=function(t){Qt(this,rr,tR).call(this);let n=ve(this,Pn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(gs)),n},Y2=function(){Qt(this,rr,J2).call(this);const t=_d(this.options.staleTime,ve(this,Pn));if(Zh||ve(this,Hs).isStale||!q2(t))return;const r=lY(ve(this,Hs).dataUpdatedAt,t)+1;yt(this,Ih,lh.setTimeout(()=>{ve(this,Hs).isStale||this.updateResult()},r))},Z2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ve(this,Pn)):this.options.refetchInterval)??!1},X2=function(t){Qt(this,rr,eR).call(this),yt(this,cd,t),!(Zh||ia(this.options.enabled,ve(this,Pn))===!1||!q2(ve(this,cd))||ve(this,cd)===0)&&yt(this,Th,lh.setInterval(()=>{(this.options.refetchIntervalInBackground||iO.isFocused())&&Qt(this,rr,Qx).call(this)},ve(this,cd)))},Q2=function(){Qt(this,rr,Y2).call(this),Qt(this,rr,X2).call(this,Qt(this,rr,Z2).call(this))},J2=function(){ve(this,Ih)&&(lh.clearTimeout(ve(this,Ih)),yt(this,Ih,void 0))},eR=function(){ve(this,Th)&&(lh.clearInterval(ve(this,Th)),yt(this,Th,void 0))},tR=function(){const t=ve(this,di).getQueryCache().build(ve(this,di),this.options);if(t===ve(this,Pn))return;const n=ve(this,Pn);yt(this,Pn,t),yt(this,_v,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},pY=function(t){Ur.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(ve(this,Hs))}),ve(this,di).getQueryCache().notify({query:ve(this,Pn),type:"observerResultsUpdated"})})},YG);function zye(e,t){return ia(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function pB(e,t){return zye(e,t)||e.state.data!==void 0&&nR(e,t,t.refetchOnMount)}function nR(e,t,n){if(ia(t.enabled,e)!==!1&&_d(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&lO(e,t)}return!1}function gB(e,t,n,r){return(e!==t||ia(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&lO(e,n)}function lO(e,t){return ia(t.enabled,e)!==!1&&e.isStaleByTime(_d(t.staleTime,e))}function Bye(e,t){return!h0(e.getCurrentResult(),t)}function bB(e){return{onFetch:(t,n)=>{var d,f,h,m,g;const r=t.options,o=(h=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,s=((m=t.state.data)==null?void 0:m.pages)||[],i=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let b=!1;const x=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(t.signal.aborted?b=!0:t.signal.addEventListener("abort",()=>{b=!0}),t.signal)})},y=cY(t.options,t.fetchOptions),w=async(C,N,S)=>{if(b)return Promise.reject();if(N==null&&C.pages.length)return Promise.resolve(C);const _=(()=>{const E={client:t.client,queryKey:t.queryKey,pageParam:N,direction:S?"backward":"forward",meta:t.options.meta};return x(E),E})(),k=await y(_),{maxPages:T}=t.options,I=S?Rye:Mye;return{pages:I(C.pages,k,T),pageParams:I(C.pageParams,N,T)}};if(o&&s.length){const C=o==="backward",N=C?Vye:xB,S={pages:s,pageParams:i},j=N(r,S);a=await w(S,j,C)}else{const C=e??s.length;do{const N=c===0?i[0]??r.initialPageParam:xB(r,a);if(c>0&&N==null)break;a=await w(a,N),c++}while(c<C)}return a};t.options.persister?t.fetchFn=()=>{var b,x;return(x=(b=t.options).persister)==null?void 0:x.call(b,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function xB(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Vye(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Tv,Al,qs,Eh,Pl,Ju,ZG,Hye=(ZG=class extends hY{constructor(t){super();At(this,Pl);At(this,Tv);At(this,Al);At(this,qs);At(this,Eh);yt(this,Tv,t.client),this.mutationId=t.mutationId,yt(this,qs,t.mutationCache),yt(this,Al,[]),this.state=t.state||gY(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ve(this,Al).includes(t)||(ve(this,Al).push(t),this.clearGcTimeout(),ve(this,qs).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){yt(this,Al,ve(this,Al).filter(n=>n!==t)),this.scheduleGc(),ve(this,qs).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ve(this,Al).length||(this.state.status==="pending"?this.scheduleGc():ve(this,qs).remove(this))}continue(){var t;return((t=ve(this,Eh))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,a,c,u,d,f,h,m,g,b,x,y,w,C,N,S,j,_,k,T;const n=()=>{Qt(this,Pl,Ju).call(this,{type:"continue"})},r={client:ve(this,Tv),meta:this.options.meta,mutationKey:this.options.mutationKey};yt(this,Eh,fY({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(I,E)=>{Qt(this,Pl,Ju).call(this,{type:"failed",failureCount:I,error:E})},onPause:()=>{Qt(this,Pl,Ju).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ve(this,qs).canRun(this)}));const o=this.state.status==="pending",s=!ve(this,Eh).canStart();try{if(o)n();else{Qt(this,Pl,Ju).call(this,{type:"pending",variables:t,isPaused:s}),await((a=(i=ve(this,qs).config).onMutate)==null?void 0:a.call(i,t,this,r));const E=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));E!==this.state.context&&Qt(this,Pl,Ju).call(this,{type:"pending",context:E,variables:t,isPaused:s})}const I=await ve(this,Eh).start();return await((f=(d=ve(this,qs).config).onSuccess)==null?void 0:f.call(d,I,t,this.state.context,this,r)),await((m=(h=this.options).onSuccess)==null?void 0:m.call(h,I,t,this.state.context,r)),await((b=(g=ve(this,qs).config).onSettled)==null?void 0:b.call(g,I,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,I,null,t,this.state.context,r)),Qt(this,Pl,Ju).call(this,{type:"success",data:I}),I}catch(I){try{throw await((C=(w=ve(this,qs).config).onError)==null?void 0:C.call(w,I,t,this.state.context,this,r)),await((S=(N=this.options).onError)==null?void 0:S.call(N,I,t,this.state.context,r)),await((_=(j=ve(this,qs).config).onSettled)==null?void 0:_.call(j,void 0,I,this.state.variables,this.state.context,this,r)),await((T=(k=this.options).onSettled)==null?void 0:T.call(k,void 0,I,t,this.state.context,r)),I}finally{Qt(this,Pl,Ju).call(this,{type:"error",error:I})}}finally{ve(this,qs).runNext(this)}}},Tv=new WeakMap,Al=new WeakMap,qs=new WeakMap,Eh=new WeakMap,Pl=new WeakSet,Ju=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ur.batch(()=>{ve(this,Al).forEach(r=>{r.onMutationUpdate(t)}),ve(this,qs).notify({mutation:this,type:"updated",action:t})})},ZG);function gY(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Fc,La,Ev,XG,qye=(XG=class extends Em{constructor(t={}){super();At(this,Fc);At(this,La);At(this,Ev);this.config=t,yt(this,Fc,new Set),yt(this,La,new Map),yt(this,Ev,0)}build(t,n,r){const o=new Hye({client:t,mutationCache:this,mutationId:++hC(this,Ev)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){ve(this,Fc).add(t);const n=pC(t);if(typeof n=="string"){const r=ve(this,La).get(n);r?r.push(t):ve(this,La).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(ve(this,Fc).delete(t)){const n=pC(t);if(typeof n=="string"){const r=ve(this,La).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&ve(this,La).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=pC(t);if(typeof n=="string"){const r=ve(this,La).get(n),o=r==null?void 0:r.find(s=>s.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=pC(t);if(typeof n=="string"){const o=(r=ve(this,La).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ur.batch(()=>{ve(this,Fc).forEach(t=>{this.notify({type:"removed",mutation:t})}),ve(this,Fc).clear(),ve(this,La).clear()})}getAll(){return Array.from(ve(this,Fc))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>uB(n,r))}findAll(t={}){return this.getAll().filter(n=>uB(t,n))}notify(t){Ur.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ur.batch(()=>Promise.all(t.map(n=>n.continue().catch(gs))))}},Fc=new WeakMap,La=new WeakMap,Ev=new WeakMap,XG);function pC(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Oc,ud,fi,Lc,hu,d1,rR,QG,Uye=(QG=class extends Em{constructor(n,r){super();At(this,hu);At(this,Oc);At(this,ud);At(this,fi);At(this,Lc);yt(this,Oc,n),this.setOptions(r),this.bindMethods(),Qt(this,hu,d1).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=ve(this,Oc).defaultMutationOptions(n),h0(this.options,r)||ve(this,Oc).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ve(this,fi),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Xh(r.mutationKey)!==Xh(this.options.mutationKey)?this.reset():((o=ve(this,fi))==null?void 0:o.state.status)==="pending"&&ve(this,fi).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=ve(this,fi))==null||n.removeObserver(this)}onMutationUpdate(n){Qt(this,hu,d1).call(this),Qt(this,hu,rR).call(this,n)}getCurrentResult(){return ve(this,ud)}reset(){var n;(n=ve(this,fi))==null||n.removeObserver(this),yt(this,fi,void 0),Qt(this,hu,d1).call(this),Qt(this,hu,rR).call(this)}mutate(n,r){var o;return yt(this,Lc,r),(o=ve(this,fi))==null||o.removeObserver(this),yt(this,fi,ve(this,Oc).getMutationCache().build(ve(this,Oc),this.options)),ve(this,fi).addObserver(this),ve(this,fi).execute(n)}},Oc=new WeakMap,ud=new WeakMap,fi=new WeakMap,Lc=new WeakMap,hu=new WeakSet,d1=function(){var r;const n=((r=ve(this,fi))==null?void 0:r.state)??gY();yt(this,ud,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},rR=function(n){Ur.batch(()=>{var r,o,s,i,a,c,u,d;if(ve(this,Lc)&&this.hasListeners()){const f=ve(this,ud).variables,h=ve(this,ud).context,m={client:ve(this,Oc),meta:this.options.meta,mutationKey:this.options.mutationKey};(n==null?void 0:n.type)==="success"?((o=(r=ve(this,Lc)).onSuccess)==null||o.call(r,n.data,f,h,m),(i=(s=ve(this,Lc)).onSettled)==null||i.call(s,n.data,null,f,h,m)):(n==null?void 0:n.type)==="error"&&((c=(a=ve(this,Lc)).onError)==null||c.call(a,n.error,f,h,m),(d=(u=ve(this,Lc)).onSettled)==null||d.call(u,void 0,n.error,f,h,m))}this.listeners.forEach(f=>{f(ve(this,ud))})})},QG);function yB(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function Wye(e,t,n){const r=e.slice(0);return r[t]=n,r}var Dh,Mi,wg,Cg,oa,dd,Dv,Mv,Rv,cs,oR,sR,iR,aR,lR,JG,Kye=(JG=class extends Em{constructor(t,n,r){super();At(this,cs);At(this,Dh);At(this,Mi);At(this,wg);At(this,Cg);At(this,oa);At(this,dd);At(this,Dv);At(this,Mv);At(this,Rv,[]);yt(this,Dh,t),yt(this,Cg,r),yt(this,wg,[]),yt(this,oa,[]),yt(this,Mi,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&ve(this,oa).forEach(t=>{t.subscribe(n=>{Qt(this,cs,aR).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,ve(this,oa).forEach(t=>{t.destroy()})}setQueries(t,n){if(yt(this,wg,t),yt(this,Cg,n),process.env.NODE_ENV!=="production"){const r=t.map(o=>ve(this,Dh).defaultQueryOptions(o).queryHash);new Set(r).size!==r.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}Ur.batch(()=>{const r=ve(this,oa),o=Qt(this,cs,iR).call(this,ve(this,wg));yt(this,Rv,o),o.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const s=o.map(f=>f.observer),i=s.map(f=>f.getCurrentResult()),a=r.length!==s.length,c=s.some((f,h)=>f!==r[h]),u=a||c,d=u?!0:i.some((f,h)=>{const m=ve(this,Mi)[h];return!m||!h0(f,m)});!u&&!d||(u&&yt(this,oa,s),yt(this,Mi,i),this.hasListeners()&&(u&&(yB(r,s).forEach(f=>{f.destroy()}),yB(s,r).forEach(f=>{f.subscribe(h=>{Qt(this,cs,aR).call(this,f,h)})})),Qt(this,cs,lR).call(this)))})}getCurrentResult(){return ve(this,Mi)}getQueries(){return ve(this,oa).map(t=>t.getCurrentQuery())}getObservers(){return ve(this,oa)}getOptimisticResult(t,n){const r=Qt(this,cs,iR).call(this,t),o=r.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions));return[o,s=>Qt(this,cs,sR).call(this,s??o,n),()=>Qt(this,cs,oR).call(this,o,r)]}},Dh=new WeakMap,Mi=new WeakMap,wg=new WeakMap,Cg=new WeakMap,oa=new WeakMap,dd=new WeakMap,Dv=new WeakMap,Mv=new WeakMap,Rv=new WeakMap,cs=new WeakSet,oR=function(t,n){return n.map((r,o)=>{const s=t[o];return r.defaultedQueryOptions.notifyOnChangeProps?s:r.observer.trackResult(s,i=>{n.forEach(a=>{a.observer.trackProp(i)})})})},sR=function(t,n){return n?((!ve(this,dd)||ve(this,Mi)!==ve(this,Mv)||n!==ve(this,Dv))&&(yt(this,Dv,n),yt(this,Mv,ve(this,Mi)),yt(this,dd,aN(ve(this,dd),n(t)))),ve(this,dd)):t},iR=function(t){const n=new Map;ve(this,oa).forEach(o=>{const s=o.options.queryHash;if(!s)return;const i=n.get(s);i?i.push(o):n.set(s,[o])});const r=[];return t.forEach(o=>{var c;const s=ve(this,Dh).defaultQueryOptions(o),a=((c=n.get(s.queryHash))==null?void 0:c.shift())??new aO(ve(this,Dh),s);r.push({defaultedQueryOptions:s,observer:a})}),r},aR=function(t,n){const r=ve(this,oa).indexOf(t);r!==-1&&(yt(this,Mi,Wye(ve(this,Mi),r,n)),Qt(this,cs,lR).call(this))},lR=function(){var t;if(this.hasListeners()){const n=ve(this,dd),r=Qt(this,cs,oR).call(this,ve(this,Mi),ve(this,Rv)),o=Qt(this,cs,sR).call(this,r,(t=ve(this,Cg))==null?void 0:t.combine);n!==o&&Ur.batch(()=>{this.listeners.forEach(s=>{s(ve(this,Mi))})})}},JG),Fl,eY,bY=(eY=class extends Em{constructor(t={}){super();At(this,Fl);this.config=t,yt(this,Fl,new Map)}build(t,n,r){const o=n.queryKey,s=n.queryHash??sO(o,n);let i=this.get(s);return i||(i=new $ye({client:t,queryKey:o,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){ve(this,Fl).has(t.queryHash)||(ve(this,Fl).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=ve(this,Fl).get(t.queryHash);n&&(t.destroy(),n===t&&ve(this,Fl).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ur.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ve(this,Fl).get(t)}getAll(){return[...ve(this,Fl).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>cB(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>cB(t,r)):n}notify(t){Ur.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ur.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ur.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Fl=new WeakMap,eY),Zr,fd,hd,Sg,Ng,md,jg,kg,tY,Gye=(tY=class{constructor(e={}){At(this,Zr);At(this,fd);At(this,hd);At(this,Sg);At(this,Ng);At(this,md);At(this,jg);At(this,kg);yt(this,Zr,e.queryCache||new bY),yt(this,fd,e.mutationCache||new qye),yt(this,hd,e.defaultOptions||{}),yt(this,Sg,new Map),yt(this,Ng,new Map),yt(this,md,0)}mount(){hC(this,md)._++,ve(this,md)===1&&(yt(this,jg,iO.subscribe(async e=>{e&&(await this.resumePausedMutations(),ve(this,Zr).onFocus())})),yt(this,kg,cN.subscribe(async e=>{e&&(await this.resumePausedMutations(),ve(this,Zr).onOnline())})))}unmount(){var e,t;hC(this,md)._--,ve(this,md)===0&&((e=ve(this,jg))==null||e.call(this),yt(this,jg,void 0),(t=ve(this,kg))==null||t.call(this),yt(this,kg,void 0))}isFetching(e){return ve(this,Zr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ve(this,fd).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=ve(this,Zr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=ve(this,Zr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(_d(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return ve(this,Zr).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=ve(this,Zr).get(r.queryHash),s=o==null?void 0:o.state.data,i=Tye(t,s);if(i!==void 0)return ve(this,Zr).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ur.batch(()=>ve(this,Zr).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=ve(this,Zr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=ve(this,Zr);Ur.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=ve(this,Zr);return Ur.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ur.batch(()=>ve(this,Zr).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(gs).catch(gs)}invalidateQueries(e,t={}){return Ur.batch(()=>(ve(this,Zr).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ur.batch(()=>ve(this,Zr).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(gs)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(gs)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=ve(this,Zr).build(this,t);return n.isStaleByTime(_d(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(gs).catch(gs)}fetchInfiniteQuery(e){return e.behavior=bB(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(gs).catch(gs)}ensureInfiniteQueryData(e){return e.behavior=bB(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return cN.isOnline()?ve(this,fd).resumePausedMutations():Promise.resolve()}getQueryCache(){return ve(this,Zr)}getMutationCache(){return ve(this,fd)}getDefaultOptions(){return ve(this,hd)}setDefaultOptions(e){yt(this,hd,e)}setQueryDefaults(e,t){ve(this,Sg).set(Xh(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ve(this,Sg).values()],n={};return t.forEach(r=>{f0(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){ve(this,Ng).set(Xh(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ve(this,Ng).values()],n={};return t.forEach(r=>{f0(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...ve(this,hd).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=sO(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===lN&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ve(this,hd).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ve(this,Zr).clear(),ve(this,fd).clear()}},Zr=new WeakMap,fd=new WeakMap,hd=new WeakMap,Sg=new WeakMap,Ng=new WeakMap,md=new WeakMap,jg=new WeakMap,kg=new WeakMap,tY),cO=te.createContext(void 0),Wr=e=>{const t=te.useContext(cO);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Yye=({client:e,children:t})=>(te.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(cO.Provider,{value:e,children:t})),xY=te.createContext(!1),yY=()=>te.useContext(xY);xY.Provider;function Zye(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Xye=te.createContext(Zye()),vY=()=>te.useContext(Xye),wY=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},CY=e=>{te.useEffect(()=>{e.clearReset()},[e])},SY=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||uY(n,[e.error,r])),NY=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>n(r(...o)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},jY=(e,t)=>e.isLoading&&e.isFetching&&!t,cR=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,uN=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ib({queries:e,...t},n){const r=Wr(),o=yY(),s=vY(),i=te.useMemo(()=>e.map(b=>{const x=r.defaultQueryOptions(b);return x._optimisticResults=o?"isRestoring":"optimistic",x}),[e,r,o]);i.forEach(b=>{NY(b),wY(b,s)}),CY(s);const[a]=te.useState(()=>new Kye(r,i,t)),[c,u,d]=a.getOptimisticResult(i,t.combine),f=!o&&t.subscribed!==!1;te.useSyncExternalStore(te.useCallback(b=>f?a.subscribe(Ur.batchCalls(b)):gs,[a,f]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),te.useEffect(()=>{a.setQueries(i,t)},[i,t,a]);const m=c.some((b,x)=>cR(i[x],b))?c.flatMap((b,x)=>{const y=i[x];if(y){const w=new aO(r,y);if(cR(y,b))return uN(y,w,s);jY(b,o)&&uN(y,w,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const g=c.find((b,x)=>{const y=i[x];return y&&SY({result:b,errorResetBoundary:s,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(g!=null&&g.error)throw g.error;return u(d())}function Qye(e,t,n){var f,h,m,g,b;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=yY(),o=vY(),s=Wr(),i=s.defaultQueryOptions(e);(h=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=r?"isRestoring":"optimistic",NY(i),wY(i,o),CY(o);const a=!s.getQueryCache().get(i.queryHash),[c]=te.useState(()=>new t(s,i)),u=c.getOptimisticResult(i),d=!r&&e.subscribed!==!1;if(te.useSyncExternalStore(te.useCallback(x=>{const y=d?c.subscribe(Ur.batchCalls(x)):gs;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),te.useEffect(()=>{c.setOptions(i)},[i,c]),cR(i,u))throw uN(i,c,o);if(SY({result:u,errorResetBoundary:o,throwOnError:i.throwOnError,query:s.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if((g=(m=s.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||g.call(m,i,u),i.experimental_prefetchInRender&&!Zh&&jY(u,r)){const x=a?uN(i,c,o):(b=s.getQueryCache().get(i.queryHash))==null?void 0:b.promise;x==null||x.catch(gs).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?u:c.trackResult(u)}function Un(e,t){return Qye(e,aO)}function Jye(e,t){const n=Wr(),r=n.getQueryCache();return te.useSyncExternalStore(te.useCallback(o=>r.subscribe(Ur.batchCalls(o)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function ks(e,t){const n=Wr(),[r]=te.useState(()=>new Uye(n,e));te.useEffect(()=>{r.setOptions(e)},[r,e]);const o=te.useSyncExternalStore(te.useCallback(i=>r.subscribe(Ur.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=te.useCallback((i,a)=>{r.mutate(i,a).catch(gs)},[r]);if(o.error&&uY(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}function e0e(){const e=v.useContext(cO);if(e&&e.isSemaphorClient)return e}function kY({children:e}){const{setIsSessionExpired:t}=p.useDashboardActions(),n=e0e(),[r]=v.useState(()=>{const o=new Gye({queryCache:new bY({onError:s=>{s instanceof Error?(console.error(`Something went wrong: ${s.message}`),s.message==="invalid token"&&t(!0)):console.error("Something went wrong:",s)}}),defaultOptions:{queries:{gcTime:36e5,staleTime:3e5,refetchOnWindowFocus:!1,retry:!1}}});return o.isSemaphorClient=!0,o});return n?l.jsx(l.Fragment,{children:e}):l.jsx(Yye,{client:r,children:e})}const t0e={id:"",authToken:void 0,tokenProps:{}},Av=v.createContext(t0e),uO=({children:e,dashboardProps:t})=>{const n=v.useMemo(()=>{let r={};const o=t.authToken;return o&&(r=je.jwtDecode(o.accessToken)),{...t,tokenProps:r}},[t]);return l.jsx(kY,{children:l.jsx(Av.Provider,{value:n,children:e})})};function It(){const e=v.useContext(Av);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}const _s=p.create()(p.immer(e=>({initialDashboard:null,selectedDashboard:null,selectedVisual:null,lastSelectedDashboard:null,lastSelectedVisual:null,showHub:!1,actions:{setInitialDashboard:t=>{e(n=>{n.initialDashboard=t})},selectDashboard:t=>{e(n=>{var r;((r=n.selectedDashboard)==null?void 0:r.id)!==t.id&&(n.lastSelectedDashboard=n.selectedDashboard,n.selectedDashboard=t),n.showHub=!1})},updateSelectedDashboard:t=>{e(n=>{n.selectedDashboard=t})},selectVisual:t=>{e(n=>{n.lastSelectedVisual=n.selectedVisual,n.selectedVisual=t})},clearSelectedDashboard:()=>{e(t=>{t.lastSelectedDashboard=t.selectedDashboard,t.selectedDashboard=null,t.showHub=!0})},clearSelectedVisual:()=>{e(t=>{t.lastSelectedVisual=t.selectedVisual,t.selectedVisual=null})},setShowHub:t=>{e(n=>{n.showHub=t})}}}))),n0e=()=>_s(e=>e.selectedVisual),Dm=()=>_s(e=>e.actions);function Pv(){const{authToken:e,version:t,tokenProps:n,id:r}=It(),o=_s(g=>g.selectedDashboard),s=_s(g=>g.showHub),i=p.useDashboardStore(g=>g.selectedLensId),a=r0e({showHub:s,selectedDashboardId:o==null?void 0:o.id,dashboardId:r,tokenDashboardId:n==null?void 0:n.dashboard_id});function c(){return!(!(e!=null&&e.accessToken)||!a)}const{data:u,isLoading:d,isFetching:f,isError:h,refetch:m}=Un({queryKey:["dashboard",i,e==null?void 0:e.accessToken,a],queryFn:()=>p.getDashboard(n.apiServiceUrl,e==null?void 0:e.accessToken,{lensId:i,version:t,dashboardId:a}),enabled:c()});return{data:u,isLoading:d,isFetching:f,isError:h,refetch:m,dashboardIdToFetch:a}}function r0e({showHub:e,selectedDashboardId:t,dashboardId:n,tokenDashboardId:r}){return e?null:t||n||r||null}function o0e(){const{authToken:e}=It(),t=p.useDashboardStore(r=>r.authToken),{setAuthToken:n}=p.useDashboardActions();return v.useLayoutEffect(()=>{const r=e==null?void 0:e.accessToken,o=t==null?void 0:t.accessToken;e&&r!==o&&n(e)},[e,t,n]),e}function _Y(e){const t=v.useCallback(s=>`semaphor-default-sheet-${s}`,[]),n=v.useCallback(()=>{if(!e)return null;try{const s=t(e);return localStorage.getItem(s)}catch(s){return console.error("Error reading default sheet preference:",s),null}},[e,t]),r=v.useCallback(s=>{if(!(!e||!s))try{const i=t(e);localStorage.setItem(i,s)}catch(i){console.error("Error saving default sheet preference:",i)}},[e,t]),o=v.useCallback(()=>{if(e)try{const s=t(e);localStorage.removeItem(s)}catch(s){console.error("Error clearing default sheet preference:",s)}},[e,t]);return{getDefaultSheetId:n,setDefaultSheetId:r,clearDefaultSheetId:o}}const vB=/\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g,wB=/\bparam\s*\(\s*(['"])([^'"]+)\1/g;function s0e(e){const t=[];let n=0;for(;n<e.length;){const r=e.indexOf("{{",n),o=e.indexOf("{%",n);let s=-1,i="";if(r===-1?(s=o,i="%}"):o===-1||r<o?(s=r,i="}}"):(s=o,i="%}"),s===-1)break;const a=e.indexOf(i,s+2);if(a===-1){n=s+2;continue}t.push(e.slice(s+2,a)),n=a+2}return t}function dO(e){var r,o;if(!e)return[];const t=new Set;let n;for(vB.lastIndex=0;(n=vB.exec(e))!==null;){const s=(r=n[1])==null?void 0:r.trim();s&&t.add(s)}for(const s of s0e(e))for(wB.lastIndex=0;(n=wB.exec(s))!==null;){const i=(o=n[2])==null?void 0:o.trim();i&&t.add(i)}return Array.from(t)}function Ek(e){const t=new Set,n=new Map;for(const r of e.controlBindings||[])t.add(r.controlId),r.target==="sql_param"&&n.set(r.paramId,r.controlId);for(const r of dO(e.sql))t.add(n.get(r)??r);return Array.from(t)}function IY(e){const t=new Map,n=new Map;for(const r of e.controlBindings||[])r.target==="sql_param"&&n.set(r.paramId,r.controlId);for(const r of dO(e.sql))t.set(r,{paramId:r,controlId:n.get(r)??r});return Array.from(t.values())}const i0e=["kpi","table","detailTable","aggregateTable","pivotTable","bar","horizontalBar","stackedBar","line","stackedLine","area","stackedArea","combo","pie","doughnut","polarArea","radar","scatter","bubble","tornado","pyramid","range","funnel","bullet","heatmap","treemap","map","matrixTable"],a0e=new Set(i0e),l0e=["table","detailTable","aggregateTable","pivotTable","matrixTable"],c0e=new Set(l0e);function TY(e){return typeof e=="string"&&c0e.has(e)}function Fv(e){return typeof e=="string"&&a0e.has(e)}function dN(e){return(e==null?void 0:e.type)==="number"||(e==null?void 0:e.type)==="currency"}function EY(e){var n,r;const t=(r=(n=e.preferences)==null?void 0:n.formatNumber)==null?void 0:r.enabled;return t===!1||t==="false"}function DY(e){return(e==null?void 0:e.type)==="number"}function u0e(e){var n;if(!DY(e))return!1;const t=(n=e==null?void 0:e.numberFormat)==null?void 0:n.style;return t===void 0||t==="decimal"||t==="currency"}function Dk(e,t){const n=t==null?void 0:t.type;if(n&&n!=="none"&&n!=="number")return{currencyBindable:!1};const r=n==="number"?t!=null&&t.numberFormat?p.fromColumnNumberFormat(t.numberFormat,{preserveOmittedProperties:!0}):{type:"number"}:void 0,o=p.fromSemanticFormat(e.format,{preserveOmittedProperties:!0}),s=va.normalizeAnalyticsCatalogDataType(e.dataType)==="number"?{type:"number"}:void 0,a=(t==null?void 0:t.inheritMetricFormat)===!1||!!(t!=null&&t.numberFormat)&&(t==null?void 0:t.inheritMetricFormat)!==!0?r:o||s||r;return{authoredFormat:a,currencyBindable:dN(a)}}function fO(e,t){var c,u;const n=p.fromSemanticFormat(t.format,{preserveOmittedProperties:!0}),r=p.fromNumberAxisFormat((c=e.preferences)==null?void 0:c.numberAxisFormat),o=EY(e)?void 0:p.fromLegacyFormatNumber((u=e.preferences)==null?void 0:u.formatNumber),s=va.normalizeAnalyticsCatalogDataType(t.dataType)==="number"?{type:"number"}:void 0,i=n||r||o||s;return{authoredFormat:i,source:n?"semantic":r?"number_axis":o?"legacy":s?"inferred":void 0,currencyBindable:dN(i)}}function m0(e,t={}){var h,m,g,b,x,y;const n=t.metricIndex??0,r=!!((h=e.sql)!=null&&h.trim()),o=p.fromPersistedKpiFormatOptions((g=(m=e.preferences)==null?void 0:m.kpiVisualOptions)==null?void 0:g.formatOptions),s=n===0?p.fromLegacyFormatNumber((b=e.preferences)==null?void 0:b.formatNumber):void 0,i=EY(e);if(r){const w=t.resultColumnKey?{kind:"column",columnKey:t.resultColumnKey}:void 0;return{target:w,authoredFormat:o||s,currencyBindable:!i&&!!w&&dN(o)}}const a=(y=(x=e.config)==null?void 0:x.metricColumns)==null?void 0:y[n],c=a!=null&&a.id?{kind:"metric",metricId:a.id}:void 0,u=p.fromSemanticFormat(a==null?void 0:a.format,{preserveOmittedProperties:!0}),d=va.normalizeAnalyticsCatalogDataType(a==null?void 0:a.dataType)==="number"?{type:"number"}:void 0,f=o||u||s||d;return{target:c,authoredFormat:f,currencyBindable:!i&&Fv(e.type)&&!!c&&dN(f)}}function hO(){const e=new Set;return(t,n,r)=>{const o=t.id||t.alias||t.name||`field_${n+1}`,s=[o];r.kind==="axis"&&r.grain&&s.push(`${o}-${r.grain}`),r.kind==="value"&&s.push(`${o}-${r.aggregate.toLowerCase()}`),s.push(`${o}-${n+1}`);for(const c of s)if(!e.has(c))return e.add(c),c;let i=n+1,a=`${o}-${i}`;for(;e.has(a);)i+=1,a=`${o}-${i}`;return e.add(a),a}}function MY(e){return e==="COUNT"||e==="SUM"||e==="AVG"||e==="MIN"||e==="MAX"||e==="MEDIAN"||e==="DISTINCT"?e:"SUM"}function CB(e){return`measure:${e}`}function Mk(e){var o,s,i,a,c,u,d;const t=(o=e.config)==null?void 0:o.metricColumns;if(Array.isArray(t)){const f=hO();return t.map((h,m)=>{const g=f(h,m,{kind:"value",aggregate:MY(h.aggregate)});return{measureId:CB(g),format:h.format,metric:h}})}const n=((i=(s=e.config)==null?void 0:s.matrixIntent)==null?void 0:i.values)||((a=e.config)==null?void 0:a.values)||[],r=((u=(c=e.config)==null?void 0:c.matrixIntent)==null?void 0:u.source)||((d=e.config)==null?void 0:d.source);return n.map((f,h)=>{const m=d0e(f.field,f.aggregate,r),g=f.id||`${m}-${h}`;return{measureId:CB(g),format:f.format,value:f}})}function d0e(e,t,n){const r=e.source||n;return[r==null?void 0:r.kind,(r==null?void 0:r.kind)==="semantic"?r.domainId:void 0,(r==null?void 0:r.kind)==="semantic"?r.datasetId:void 0,(r==null?void 0:r.kind)==="semantic"?r.datasetName:void 0,(r==null?void 0:r.kind)==="physical"?r.connectionId:void 0,(r==null?void 0:r.kind)==="physical"?r.databaseName:void 0,(r==null?void 0:r.kind)==="physical"?r.schemaName:void 0,(r==null?void 0:r.kind)==="physical"?r.tableName:void 0,e.name,e.role,t].filter(Boolean).join(":")}function RY(e){const t=new Map;if(!e.result||!e.presentation.preferences)return t;const n=new Map((e.card?Mk(e.card):[]).map(r=>[r.measureId,r]));for(const[r,o]of Object.entries(e.result.measuresById)){const s=n.get(r),i=mO(s?s.format:o.format);i&&t.set(r,$t.resolveNumericPresentation(i,e.presentation.preferences,e.presentation.resolveBoundCurrency({kind:"matrix_measure",measureId:r})))}return t}function AY(e){const{cell:t}=e;if(t.presence==="missing"||t.presence==="densified")return"—";if(t.presence==="presentNull"||t.value===null||t.value===void 0)return"";const n=f0e(t.value),r=e.formatsByMeasureId.get(t.measureId);return n!==void 0&&r?$t.formatNumericCanonical(n,r):n!==void 0?new Intl.NumberFormat("en-US",{maximumFractionDigits:6}).format(n):String(t.value)}function mO(e){if(typeof e=="object"&&(e==null?void 0:e.type)==="datetime")return;const t=p.fromSemanticFormat(e,{preserveOmittedProperties:!0});if(!t)return{type:"number"};if(Kt.isNumericCanonicalFormat(t))return t}function f0e(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||!e.trim())return;const t=Number(e);return Number.isFinite(t)?t:void 0}function pO(e){var t,n;return e.type==="detailTable"?((t=e.config)==null?void 0:t.detailColumns)||[]:((n=e.config)==null?void 0:n.metricColumns)||[]}function PY(e){return new Set(p.getDashboardCards(e).flatMap(t=>(t.controlBindings||[]).filter(Ov).map(n=>n.controlId)))}function h0e(e,t){const n=[t.id,t.alias,t.label,t.name,t.qualifiedFieldName].filter(s=>!!s);for(const s of n)if(e[s])return e[s];const r=new Set(n.map(s=>s.trim().toLowerCase())),o=Object.entries(e).find(([s])=>r.has(s.trim().toLowerCase()));return o==null?void 0:o[1]}function SB(e){return[...new Map(e.map(t=>[ba(t),t])).values()]}function m0e(e){if(e.metric)return Dk(e.metric,void 0).currencyBindable;const t=mO(e.format);return(t==null?void 0:t.type)==="number"||(t==null?void 0:t.type)==="currency"}function gO(e,t=[]){var C,N,S;const n=!!((C=e.sql)!=null&&C.trim()),r=Fv(e.type),o=n&&r&&e.type!=="kpi"&&e.type!=="matrixTable",s=pO(e),i=((S=(N=e.preferences)==null?void 0:N.tablePrefs)==null?void 0:S.columnSettingsMap)||{},a=!n&&e.type==="kpi"?s.map((j,_)=>m0(e,{metricIndex:_})):[],c=!n&&e.type==="matrixTable"?Mk(e):[],u=(n?[]:s).map(j=>({kind:"metric",metricId:j.id})),d=c.map(j=>({kind:"matrix_measure",measureId:j.measureId})),f=c.filter(m0e).map(j=>({kind:"matrix_measure",measureId:j.measureId})),h=e.type==="matrixTable"?[]:e.type==="kpi"?a.filter(j=>j.currencyBindable).flatMap(j=>j.target?[j.target]:[]):(n||!r?[]:s).filter(j=>(TY(e.type)?Dk(j,h0e(i,j)):fO(e,j)).currencyBindable).map(j=>({kind:"metric",metricId:j.id})),m=[...new Set(t)],g=(o?m:[]).map(j=>({kind:"column",columnKey:j})),b=(o?m:[]).filter(j=>u0e(i[j])).map(j=>({kind:"column",columnKey:j})),x=(n&&e.type==="kpi"?m.slice(0,1):[]).map(j=>({kind:"column",columnKey:j})),y=n&&e.type==="kpi"?m0(e,{resultColumnKey:m[0]}):void 0,w=r&&(y!=null&&y.currencyBindable)?x:[];return{knownTargets:SB([...e.type==="matrixTable"?d:u,...g,...x]),eligibleTargets:SB([...h,...f,...b,...w])}}function FY(e,t){const n=m0(e,{resultColumnKey:t});return n.currencyBindable?n.target:void 0}function ec(e){var t;return(t=e.card.sql)!=null&&t.trim()?{kind:"column",columnKey:e.columnKey}:e.metricId?{kind:"metric",metricId:e.metricId}:void 0}function ba(e){return e.kind==="metric"?`metric:${e.metricId}`:e.kind==="column"?`column:${e.columnKey}`:`matrix_measure:${e.measureId}`}function p0e(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e;if(t.kind==="metric"&&typeof t.metricId=="string"&&t.metricId.trim())return{kind:"metric",metricId:t.metricId};if(t.kind==="column"&&typeof t.columnKey=="string"&&t.columnKey.trim())return{kind:"column",columnKey:t.columnKey};if(t.kind==="matrix_measure"&&typeof t.measureId=="string"&&t.measureId.trim())return{kind:"matrix_measure",measureId:t.measureId}}function Ov(e){return e.target==="presentation_currency"}function g0e(e){return e.target!=="sql_param"&&e.target!=="presentation_currency"}function NB(e){const t=Li.canonicalizeSupportedCurrencyCode(e);return typeof e=="string"&&e===t?t:void 0}function OY(e){if(e.type!=="enum"||e.source.kind!=="manual")return{diagnostic:"invalid_control_type"};const t=e.source.options.map(n=>NB(n.value));if(t.length===0||t.some(n=>!n))return{diagnostic:"invalid_currency_option"};if(e.requiredAtExecution){const n=e.initialValueStrategy==="saved_default"?NB(e.defaultValue):void 0;if(!n||!t.includes(n))return{diagnostic:"invalid_control_default"}}return{control:e,currencies:t}}function b0e(e){return"control"in OY(e)}function LY(e){const t=PY(e.dashboard);if(t.size===0)return{definitions:e.definitions||[],values:e.values||{}};const n=new Set([...t].filter(r=>!e.referencedControlIds.has(r)));return{definitions:(e.definitions||[]).filter(r=>!n.has(r.id)),values:Object.fromEntries(Object.entries(e.values||{}).filter(([r])=>!n.has(r)))}}function $Y(e){return LY({...e,referencedControlIds:new Set(Ek({sql:e.filterSql,controlBindings:[]}))})}function x0e(e){var t;return LY({...e,referencedControlIds:new Set(Ek({sql:(t=e.source)==null?void 0:t.sql,controlBindings:[]}))})}function zY(e){return{knownKeys:new Set(e.knownTargets.map(ba)),eligibleKeys:new Set(e.eligibleTargets.map(ba)),controlsById:new Map((e.controls||[]).map(t=>[t.id,t]))}}function BY(e,t){if(!e||typeof e!="object"||e.target!=="presentation_currency")return{};const n=e,r=typeof n.controlId=="string"&&n.controlId.trim()?n.controlId:void 0;if(!r)return{diagnostic:{code:"invalid_binding_shape"}};const o=p0e(n.presentationTarget);if(!o)return{diagnostic:{code:"missing_target",controlId:r}};const s=ba(o);if(!t.knownKeys.has(s))return{diagnostic:{code:"stale_target",controlId:r}};if(!t.eligibleKeys.has(s))return{diagnostic:{code:"inapplicable_target",controlId:r}};const i=t.controlsById.get(r);if(!i)return{diagnostic:{code:"missing_control",controlId:r}};const a=OY(i);return"diagnostic"in a?{diagnostic:{code:a.diagnostic,controlId:r}}:{binding:{controlId:r,presentationTarget:o,control:a.control,currencies:a.currencies}}}function y0e(e){const t=zY(e);return(e.bindings||[]).flatMap(n=>{const r=BY(n,t);return"diagnostic"in r?[r.diagnostic]:[]})}function VY(e){var o;const t=[],n=ba(e.target),r=zY(e);for(const s of e.bindings||[]){const i=BY(s,r);if("diagnostic"in i){t.push(i.diagnostic);continue}const a=i.binding;if(!a||ba(a.presentationTarget)!==n)continue;const u=Li.canonicalizeSupportedCurrencyCode((o=e.values)==null?void 0:o[a.control.id]);if(!(!u||!a.currencies.includes(u)))return{currency:u,diagnostics:t}}return{diagnostics:t}}function v0e(e,t){if(!e||typeof e!="object"||!("kind"in e))return e;switch(e.kind){case"manual":return{kind:"manual",...t!=null&&t.includePresentation?{options:e.options.map(n=>({value:n.value,label:n.label,presentation:n.presentation}))}:{optionValues:e.options.map(n=>n.value).sort()}};case"dataset_values":return{kind:"dataset_values",fieldId:e.fieldId,connectionId:e.connectionId||""};case"field_allowlist":return{kind:"field_allowlist",fieldIds:[...e.fieldIds].sort()};case"metric_allowlist":return{kind:"metric_allowlist",metricIds:[...e.metricIds].sort()};case"sql_query":return{kind:"sql_query",connectionId:e.connectionId,sql:e.sql,valueColumn:e.valueColumn,labelColumn:e.labelColumn};default:return e}}function w0e(e,t){return{id:e.id,scope:e.scope,type:e.type,source:v0e(e.source,t),initialValueStrategy:e.initialValueStrategy,defaultValue:e.defaultValue,requiredAtExecution:e.requiredAtExecution,...t!=null&&t.includePresentation?{label:e.label,helpText:e.helpText,hidden:e.hidden,locked:e.locked,placement:e.placement,showLabel:e.showLabel,toolbarWidth:e.toolbarWidth}:{}}}function C0e(e,t){return e.target==="sql_param"||e.target==="presentation_currency"?e:e.target==="config_field_selector"&&!(t!=null&&t.includePresentation)?{...e,mapping:Object.fromEntries(Object.entries(e.mapping).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>{const o={...r};return delete o.format,delete o.dateFormat,delete o.customFormat,delete o.semanticTemporalPresentation,[n,o]}))}:{...e,mapping:Object.fromEntries(Object.entries(e.mapping).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,r&&typeof r=="object"&&!Array.isArray(r)?Object.fromEntries(Object.entries(r).sort(([o],[s])=>o.localeCompare(s))):r]))}}function jB(e=[],t){return[...e].map(n=>w0e(n,t)).sort((n,r)=>n.id.localeCompare(r.id)||n.scope.localeCompare(r.scope)||n.type.localeCompare(r.type))}function S0e(e=[],t){return e.filter(n=>(t==null?void 0:t.includePresentation)||!Ov(n)).map(n=>C0e(n,t)).sort((n,r)=>Ho.stableSerialize(n).localeCompare(Ho.stableSerialize(r)))}function uR(e,t){return e?Ho.stableSerialize({controlDefinitions:jB(e.controlDefinitions,t),cardControlDefinitions:jB(e.cardControlDefinitions,t),controlBindings:S0e(e.controlBindings,t)}):"__none__"}function VT(e,t){return e&&t.has(e)?e:null}function N0e({selectedSheetId:e,preservedSelectedSheetId:t,defaultSheetId:n,sheets:r}){var s;const o=new Set((r||[]).map(i=>i.id).filter(i=>typeof i=="string"));return VT(e,o)||VT(t,o)||VT(n,o)||((s=r==null?void 0:r[0])==null?void 0:s.id)||null}function HY(e){const t=e.trim().split(/[^A-Za-z0-9]+/).filter(Boolean).map(r=>r.toLowerCase());if(!t.length)return"input";const n=t.map((r,o)=>o===0?r:_B(r)).join("");return/^[A-Za-z]/.test(n)?n:`input${_B(n)}`}function bO(e,t){const n=HY(e);return qY(n,t)}function Lv(e){const n=e.trim().replace(/^\{\{\s*/,"").replace(/\s*\}\}$/,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"");return n?/^[A-Za-z]/.test(n)?n:`input_${n}`:"input"}function Od(e,t){return qY(Lv(e),t)}function qY(e,t){const n=new Set(t.map(o=>o.variableName).filter(o=>!!o));if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r+=1;return`${e}${r}`}function xO(e){return p.getDataType(e.dataType)==="date"?["label","start","end","range"]:["label","value"]}function yO(e){return k0e(e)?["label","value"]:["value"]}function kB(e){return e.kind==="filter"?`filter:${e.filter.id}`:`control:${e.control.id}`}function j0e(e){return{placement:e.hide||e.displayMode==="canvas"?"hidden":"toolbar",...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function UY(e){return{placement:e.hidden?"hidden":e.placement||(e.scope==="card"?"card_header":"toolbar"),...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function fN(e){return!!e.compatibility}function k0e(e){return e.type==="enum"||e.type==="multi_enum"||e.type==="field_selector"||e.type==="metric_selector"||e.type==="aggregation_selector"||e.type==="grain_selector"}function _B(e){return e&&e[0].toUpperCase()+e.slice(1)}function _0e(e){var i,a;const t=[...e.inputs||[]],n=new Set(t.map(c=>c.id)),r=new Set((e.sheets||[]).filter(c=>c.kind==="document").map(c=>c.id));let o=!1;for(const c of e.sheets||[])if(!(c.kind!=="document"||!((a=(i=c.document)==null?void 0:i.inputs)!=null&&a.length)))for(const u of c.document.inputs)n.has(u.id)||(t.push(I0e(u,c.id)),n.add(u.id),o=!0);const s=t.map(c=>{if(c.kind==="filter"&&IB(c,r)&&c.filter.variableName!==c.variableName)return o=!0,{...c,filter:{...c.filter,variableName:c.variableName}};if(c.kind!=="control"||!IB(c,r))return c;const u=Od(c.control.id||c.variableName,t.filter(d=>d.id!==c.id));return c.variableName===u&&c.control.id===u?c:(o=!0,{...c,variableName:u,control:{...c.control,id:u}})});return o?{...e,inputs:s}:e}function I0e(e,t){const n={id:e.id,label:e.label,variableName:e.variableName,description:e.description,requiredAtExecution:e.requiredAtExecution,scope:{kind:"sheets",sheetIds:[t]},runtimeScope:"perSheet",presentation:{placement:"toolbar"},exports:e.exports,compatibility:{source:"documentInput",sheetId:t,inputId:e.id}};return e.kind==="filter"?{...n,kind:"filter",filter:e.filter}:{...n,kind:"control",control:e.control}}function IB(e,t){var n;switch(e.scope.kind){case"allSheets":return!((n=e.scope.sheetKinds)!=null&&n.length)||e.scope.sheetKinds.includes("document");case"sheets":return e.scope.sheetIds.some(r=>t.has(r));case"documentSections":return t.has(e.scope.sheetId);default:return!1}}function T0e(e,t={}){if(!e)return[];const n=[],r=[...t.existingInputs||[]];for(const o of e.inlineFilters||[]){const s=o.title||o.column||o.id,i=E0e(o),a={id:Oi.getCardInlineFilterCompatInputId(e.id,o.id),kind:"filter",label:s,variableName:o.variableName?Od(o.variableName,r):bO(s,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:{placement:"card_header"},filter:i,exports:xO(i),compatibility:{source:"cardInlineFilter",cardId:e.id,filterId:o.id}};r.push(a),n.push(a)}for(const o of e.controls||[]){const s=o.label||o.id,i={id:Oi.getCardControlCompatInputId(e.id,o.id),kind:"control",label:s,variableName:Od(o.id,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:UY(o),control:o,exports:yO(o),requiredAtExecution:o.requiredAtExecution,compatibility:{source:"cardControl",cardId:e.id,controlId:o.id}};r.push(i),n.push(i)}return n}function E0e(e){return{kind:"field",id:e.id,variableName:e.variableName,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel,toolbarWidth:e.width,displayMode:"toolbar"}}function D0e(e,t={}){const n=[],r=[...t.existingInputs||[]];for(const o of e.controls||[]){const s=o.label||o.id,i={id:Oi.getDashboardControlCompatInputId(o.id),kind:"control",label:s,variableName:Od(o.id,r),scope:{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:UY(o),control:o,exports:yO(o),requiredAtExecution:o.requiredAtExecution,compatibility:{source:"dashboardControl",controlId:o.id}};r.push(i),n.push(i)}return n}function M0e(e,t={}){const n=[],r=[...t.existingInputs||[]],o=t.availableSheetIds||(e.sheets||[]).filter(u=>u.kind!=="document").map(u=>u.id),s=p.getDashboardCardEntries({sheets:e.sheets}),i=t.availableCardIds?new Set(t.availableCardIds):void 0,a=s.filter(u=>!i||i.has(u.card.id)),c=t.availableCardIds||a.map(u=>u.card.id);for(const u of e.filters||[]){const d=u.title||u.column||u.id,f={id:Oi.getDashboardFilterCompatInputId(u.id),kind:"filter",label:d,variableName:u.variableName?Od(u.variableName,r):bO(d,r),scope:R0e(u,{availableDashboardSheetIds:o,availableCardEntries:a,availableCardIds:c}),runtimeScope:"shared",presentation:j0e(u),filter:u,exports:xO(u),compatibility:{source:"dashboardFilter",filterId:u.id}};r.push(f),n.push(f)}return n}function R0e(e,t){if(e.applyToCardIds!==void 0){const n=new Set(TB(e,t));return{kind:"cards",cardIds:e.applyToCardIds.filter(r=>n.has(r))}}if(e.excludeCardIds!==void 0){const n=new Set(e.excludeCardIds);return{kind:"cards",cardIds:TB(e,t).filter(o=>!n.has(o))}}if(e.sheetId)return{kind:"sheets",sheetIds:[e.sheetId]};if(e.applyToSheetIds!==void 0)return{kind:"sheets",sheetIds:e.applyToSheetIds};if(e.excludeSheetIds!==void 0){const n=new Set(e.excludeSheetIds);return{kind:"sheets",sheetIds:t.availableDashboardSheetIds.filter(r=>!n.has(r))}}return{kind:"allSheets",sheetKinds:["dashboard"]}}function TB(e,t){return!e.sheetId&&e.applyToSheetIds===void 0&&e.excludeSheetIds===void 0?t.availableCardIds:t.availableCardEntries.filter(n=>A0e(e,n.sheet.id)).map(n=>n.card.id)}function A0e(e,t){return e.sheetId&&e.sheetId!==t?!1:e.applyToSheetIds!==void 0?e.applyToSheetIds.includes(t):e.excludeSheetIds!==void 0?!e.excludeSheetIds.includes(t):!0}function uf({dashboard:e,dashboardInputValues:t}){var r,o;const n=!!(Object.keys((t==null?void 0:t.shared)||{}).length||Object.values((t==null?void 0:t.bySheetId)||{}).some(s=>Object.keys(s).length>0)||Object.values((t==null?void 0:t.byCardId)||{}).some(s=>Object.keys(s).length>0)||Object.values((t==null?void 0:t.byDocumentSectionId)||{}).some(s=>Object.keys(s).length>0));return!!((r=e.inputs)!=null&&r.length||e.defaultInputValues||(o=e.filters)!=null&&o.some(s=>s.kind==="global-date")||n)}function ab({dashboard:e,card:t,availableSheetIds:n,availableCardIds:r}){const o=e.inputs||[],s=[],i=[...o],a=M0e(e,{existingInputs:i,availableSheetIds:n,availableCardIds:r});s.push(...a),i.push(...a);const c=D0e(e,{existingInputs:i});s.push(...c),i.push(...c);const u=T0e(t,{existingInputs:i});return s.push(...u),{authoredInputs:o,compatibilityInputs:s,allInputs:[...o,...s]}}function Yi({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,runtimeValues:s,mode:i="interactive",timezone:a}){var y;const c={sheetId:t,cardId:n==null?void 0:n.id,sectionId:r,sheetKind:o||K0e(e,t)},u=ab({dashboard:e,card:n}),d=Rk(u.allInputs);P0e(d);const f=d.filter(w=>Qh(w,c));W0e(f);const h=f.map(w=>O0e({dashboard:e,input:w,runtimeValues:s,target:c,timezone:a})),m=$0e({resolvedInputs:h,card:n}),g=z0e(h),b=(y=h.find(w=>w.kind==="filter"&&p.isGlobalDateFilter(w.filter)))==null?void 0:y.comparisonSelection,x=h.flatMap((w,C)=>{var j;const N=f[C];if(!N||!p.isComparisonCapableDashboardDateInput(N)||!w.comparisonSelection)return[];const S=((j=w.slot)==null?void 0:j.status)==="set"&&w.slot.value.kind==="filter"?w.slot.value.filterValue:void 0;return[{inputId:w.id,filterId:N.filter.id,label:w.label,filter:N.filter,filterValue:S,selection:w.comparisonSelection}]});return{inputs:f,resolvedInputs:h,...m,...g,...b?{globalDateComparisonSelection:b}:{},dateComparisonInputs:x,missingRequiredInputs:h.filter(w=>w.missingRequiredValue)}}function P0e(e){if(e.filter(n=>n.kind==="filter"&&p.isGlobalDateFilter(n.filter)).length>1)throw new Error("Dashboard input contract allows exactly one Global Date input.")}function Qh(e,t){var n;if(!F0e(e,t))return!1;switch(e.scope.kind){case"allSheets":return(n=e.scope.sheetKinds)!=null&&n.length?t.sheetKind?e.scope.sheetKinds.includes(t.sheetKind):!1:!!t.sheetId||!!t.cardId;case"sheets":return!!t.sheetId&&e.scope.sheetIds.includes(t.sheetId);case"cards":return!!t.cardId&&e.scope.cardIds.includes(t.cardId);case"documentSections":return!!t.sheetId&&!!t.sectionId&&e.scope.sheetId===t.sheetId&&e.scope.sectionIds.includes(t.sectionId);default:return!1}}function F0e(e,t){return t.sheetKind!=="document"||!e.compatibility||e.compatibility.source==="documentInput"?!0:e.compatibility.source==="cardInlineFilter"||e.compatibility.source==="cardControl"?!!t.cardId&&e.compatibility.cardId===t.cardId:!1}function Rk(e){const t=new Set(e.filter(n=>!fN(n)).map(kB));return e.filter(n=>!fN(n)||!t.has(kB(n)))}function O0e(e){var d,f;const t=p.getDashboardInputRuntimeSlot(e.runtimeValues.dashboardInputValues,e.input,e.target),n=p.getDashboardInputRuntimeSlot(e.dashboard.defaultInputValues,e.input,e.target),r=(t==null?void 0:t.comparisonSelection)??(n==null?void 0:n.comparisonSelection),o=p.isComparisonCapableDashboardDateInput(e.input);if(r&&!o)throw new Error(`Dashboard input "${e.input.id}" carries comparison state but is not a supported dashboard date filter.`);const i=fN(e.input)&&((d=e.input.compatibility)==null?void 0:d.source)!=="documentInput"?B0e(e):p.hydrateAuthoredDashboardInputSlot({dashboard:e.dashboard,input:e.input,runtimeValues:e.runtimeValues.dashboardInputValues,target:e.target,timezone:e.timezone}),a=(i==null?void 0:i.status)==="set"&&i.value.kind===e.input.kind?i.value:void 0;if(i!=null&&i.comparisonSelection){if(!o)throw new Error(`Dashboard input "${e.input.id}" carries comparison state but is not a supported dashboard date filter.`);const h=$r.validateGlobalDateComparisonSelection(i.comparisonSelection,`dashboardInputValues.${e.input.id}.comparisonSelection`);if(!h.ok)throw new Error(((f=h.errors[0])==null?void 0:f.message)||"Invalid comparison selection.")}if(e.input.kind==="filter"){const h=(a==null?void 0:a.kind)==="filter"?WY(e.input,a.filterValue):void 0,m=H0e({input:e.input,filterValue:h,timezone:e.timezone});return{id:e.input.id,kind:"filter",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:i,rawValue:h?G0e(h.values):void 0,displayValue:EB(m.label??m.value),exports:m,filter:e.input.filter,filterValue:h,missingRequiredValue:!!e.input.requiredAtExecution&&!h,...o&&(i!=null&&i.comparisonSelection)?{comparisonSelection:i.comparisonSelection}:{}}}const c=(a==null?void 0:a.kind)==="control"?a.value:void 0,u=q0e({input:e.input,value:c});return{id:e.input.id,kind:"control",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:i,rawValue:c,displayValue:EB(u.label??u.value),exports:u,control:e.input.control,controlValue:c,missingRequiredValue:!!e.input.requiredAtExecution&&!L0e(c)}}function L0e(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function $0e({resolvedInputs:e,card:t}){const n=[],r=new Map,o=new Map,s={};for(const c of e){if(c.kind==="filter"){c.filter&&c.filterValue&&n.push(c.filterValue);continue}c.control&&(U0e(c)?o.set(c.control.id,c.control):r.set(c.control.id,c.control),c.controlValue!==void 0&&(s[c.control.id]=c.controlValue))}const i=new Set([...r.keys(),...o.keys()]),a=((t==null?void 0:t.controlBindings)||[]).filter(c=>i.has(c.controlId));return{activeFilters:n,controlDefinitions:Array.from(r.values()),cardControlDefinitions:Array.from(o.values()),controlBindings:a,controlValues:s}}function z0e(e){const t={},n={};for(const r of e)n[r.id]=r,t[r.variableName]=r;return{variablesByName:t,variablesById:n}}function B0e(e){var i,a,c,u;const t=(i=e.input.compatibility)==null?void 0:i.source,n=p.getDashboardInputRuntimeSlot(e.runtimeValues.dashboardInputValues,e.input,e.target),r=p.hydrateAuthoredDashboardInputSlot({dashboard:e.dashboard,input:e.input,runtimeValues:e.runtimeValues.dashboardInputValues,target:e.target,timezone:e.timezone});if((n==null?void 0:n.status)==="set"||(n==null?void 0:n.status)==="cleared")return r;if(e.input.kind==="filter"){const d=e.input.filter.id,f=t==="cardInlineFilter"?e.target.cardId?(c=(a=e.runtimeValues.inlineFilterValuesMap)==null?void 0:a[e.target.cardId])==null?void 0:c.find(m=>m.filterId===d):void 0:(u=e.runtimeValues.filterValues)==null?void 0:u.find(m=>m.filterId===d),h=p.isComparisonCapableDashboardDateInput(e.input)?(r==null?void 0:r.comparisonSelection)??(f?{mode:"off"}:void 0):void 0;if(f){const m=p.createFilterDashboardInputSlot(WY(e.input,f));return(m==null?void 0:m.status)==="set"?{...m,...h?{comparisonSelection:h}:{}}:h?{comparisonSelection:h}:void 0}return h?{comparisonSelection:h}:void 0}const o=e.input.control.id,s=V0e({source:t,target:e.target,runtimeValues:e.runtimeValues});if(s.values&&Object.prototype.hasOwnProperty.call(s.values,o))return p.createControlDashboardInputSlot(s.values[o]);if(!s.isExplicit)return t==="dashboardControl"?p.createControlDashboardInputSlot(p.resolveSavedDefaultValue(e.input.control,e.dashboard.defaultControlValues)):p.getBackingDefaultSlot(e.input,e.timezone)}function V0e({source:e,target:t,runtimeValues:n}){var r;return e==="cardControl"&&t.cardId?{values:(r=n.cardControlValuesMap)==null?void 0:r[t.cardId],isExplicit:!!(n.cardControlValuesMap&&Object.prototype.hasOwnProperty.call(n.cardControlValuesMap,t.cardId))}:{values:n.controlValues,isExplicit:n.controlValues!==void 0}}function WY(e,t){const n=t.filterId===e.filter.id?t:{...t,filterId:e.filter.id};if(p.isCompatibleFilterValue(e.filter,n))return p.normalizeDashboardDateComparisonFilterValue(e,n)}function H0e({input:e,filterValue:t,timezone:n}){const r=e.exports||xO(e.filter),o=(t==null?void 0:t.values)||[],s=p.getDataType(e.filter.dataType)==="date",i=o.map(X0e),a=s?i.length>1?`${i[0]} - ${i[1]}`:i[0]||"":i.join(", "),c={};for(const u of r)u==="start"?c.start=i[0]||null:u==="end"?c.end=i[1]||null:u==="range"?c.range=a||null:c[u]=a||null;return c}function q0e({input:e,value:t}){const n=e.exports||yO(e.control),r=Y0e(t),o=r.map(a=>Z0e(e.control,a)).join(", "),s=r.map(KY).join(", "),i={};for(const a of n)i[a]=a==="label"?o||null:s||null;return i}function U0e(e){return e.control?e.control.scope==="card"||e.id.startsWith("compat-card-control:"):!1}function W0e(e){const t=new Map;for(const n of e){if(fN(n))continue;const r=t.get(n.variableName);if(r)throw new Error(`Duplicate dashboard input variableName "${n.variableName}" for inputs "${r}" and "${n.id}" in the same resolved scope.`);t.set(n.variableName,n.id)}}function K0e(e,t){var r;if(!t)return;const n=(r=e.sheets)==null?void 0:r.find(o=>o.id===t);return(n==null?void 0:n.kind)==="document"?"document":"dashboard"}function G0e(e){return e.length>1?e:e[0]??null}function Y0e(e){return e==null?[]:Array.isArray(e)?e:[e]}function Z0e(e,t){var r;const n=KY(t);return e.source.kind==="manual"&&((r=e.source.options.find(o=>o.value===n))==null?void 0:r.label)||n}function KY(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function X0e(e){return e instanceof Date?e.toISOString():typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function EB(e){return e==null?"":String(e)}function dR({dashboard:e,dashboardInputValues:t,sheetId:n,cardId:r}){let o=p.compactDashboardInputValues(t||{});const s=J0e({dashboard:e,sheetId:n,cardId:r});if(s.status==="unresolved")return{};o=Q0e({dashboardInputValues:o,savedSheetId:n,cardId:r,targets:s.targets});for(const i of s.targets){const a=Rk(ab({dashboard:e,card:i.card}).allInputs).filter(c=>p.canAddressDashboardInputRuntimeSlot(c,i)&&Qh(c,i));for(const c of a){const u=p.getDashboardInputRuntimeSlot(o,c,i);if(!u||u.status===void 0){o=p.setDashboardInputRuntimeSlot(o,c,i,{status:"cleared",comparisonSelection:u==null?void 0:u.comparisonSelection});continue}u.status==="set"&&p.isComparisonCapableDashboardDateInput(c)&&!u.comparisonSelection&&(o=p.setDashboardInputRuntimeSlot(o,c,i,{...u,comparisonSelection:{mode:"off"}}))}}return p.compactDashboardInputValues(o)}function Q0e({dashboardInputValues:e,savedSheetId:t,cardId:n,targets:r}){var c,u,d,f;const o={},s=new Set(r.flatMap(h=>h.sheetId?[h.sheetId]:[])),i=new Set(r.flatMap(h=>h.cardId?[h.cardId]:[])),a=new Set(r.flatMap(h=>h.sectionId?[h.sectionId]:[]));if(e.shared&&(o.shared={...e.shared}),n){const h=r[0],m=(t?(c=e.bySheetId)==null?void 0:c[t]:void 0)??(h.sheetId?(u=e.bySheetId)==null?void 0:u[h.sheetId]:void 0);h.sheetId&&m&&(o.bySheetId={[h.sheetId]:{...m}});const g=h.cardId?(d=e.byCardId)==null?void 0:d[h.cardId]:void 0;h.cardId&&g&&(o.byCardId={[h.cardId]:{...g}});const b=Object.entries(e.byDocumentSectionId||{}),x=(h.sectionId?(f=e.byDocumentSectionId)==null?void 0:f[h.sectionId]:void 0)??(b.length===1?b[0][1]:void 0);return h.sectionId&&x&&(o.byDocumentSectionId={[h.sectionId]:{...x}}),p.compactDashboardInputValues(o)}return o.bySheetId=HT(e.bySheetId,s),o.byCardId=HT(e.byCardId,i),o.byDocumentSectionId=HT(e.byDocumentSectionId,a),p.compactDashboardInputValues(o)}function HT(e,t){if(!e)return;const n=Object.entries(e).filter(([r])=>t.has(r));return n.length>0?Object.fromEntries(n.map(([r,o])=>[r,{...o}])):void 0}function J0e({dashboard:e,sheetId:t,cardId:n}){var i;if(n){const a=eve(e,n);return a?{status:"resolved",targets:[a]}:{status:"unresolved",targetKind:"card"}}const r=(e.sheets||[]).filter(a=>!t||a.id===t);if(t&&r.length===0)return{status:"unresolved",targetKind:"sheet"};const o=r.map(a=>({sheetId:a.id,sheetKind:a.kind||"dashboard"})),s=new Set(r.map(a=>a.id));for(const a of p.getDashboardCardEntries(e))s.has(a.sheet.id)&&o.push({sheetId:a.sheet.id,cardId:a.card.id,card:a.card,sheetKind:a.sheet.kind||"dashboard"});for(const a of r)if(a.kind==="document")for(const c of((i=a.document)==null?void 0:i.sections)||[])o.push({sheetId:a.id,sectionId:c.id,...(c.type==="table"||c.type==="chart")&&{cardId:c.card.id,card:c.card},sheetKind:"document"});return{status:"resolved",targets:o.length>0?o:[{}]}}function eve(e,t){var r;const n=p.findCardLocationById(e,t);if(n)return{sheetId:n.sheet.id,cardId:n.card.id,card:n.card,sheetKind:n.sheet.kind||"dashboard"};for(const o of e.sheets||[])if(o.kind==="document"){for(const s of((r=o.document)==null?void 0:r.sections)||[])if((s.type==="table"||s.type==="chart")&&s.card.id===t)return{sheetId:o.id,sectionId:s.id,cardId:s.card.id,card:s.card,sheetKind:"document"}}}function GY({dashboardInputValues:e,dashboard:t,filterValues:n,sheetId:r,cardId:o,sectionId:s,sheetKind:i}){var u;if(!((u=t.inputs)!=null&&u.length))return e;const a=new Map(n.map(d=>[d.filterId,d]));let c=e||{};for(const d of t.inputs){if(d.kind!=="filter"||!Qh(d,{sheetId:r,cardId:o,sectionId:s,sheetKind:i}))continue;const f=a.get(d.filter.id),h=f?p.createFilterDashboardInputSlot(f):void 0,m=(h==null?void 0:h.status)==="set"?h:{status:"cleared"};c=p.setDashboardInputRuntimeValueAspect(c,d,{sheetId:r,cardId:o,sectionId:s},m)}return c}function ru({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,mode:s,runtimeValues:i,generatedAt:a,timezone:c}){const u=f1({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,mode:s,runtimeValues:i,timezone:c});return{context:u,snapshot:{...t?{sheetId:t}:{},...n!=null&&n.id?{cardId:n.id}:{},mode:s,dashboardInputValues:nve({inputs:u.inputs,context:u,sheetId:t,cardId:n==null?void 0:n.id,sectionId:r}),generatedAt:a,timezone:c}}}function YY({sectionIds:e,...t}){const n=new Set,r=o=>{for(const s of o.missingRequiredInputs)n.add(s.label)};r(f1(t));for(const o of e)r(f1({...t,sectionId:o}));for(const{sectionId:o,card:s}of XY(t.dashboard,t.sheetId,e))r(f1({...t,sectionId:o,card:s}));return Array.from(n)}function vO({sheetIds:e,sheetKind:t="dashboard",...n}){const r=e.map(a=>ru({...n,sheetId:a,sheetKind:t})),o=e.flatMap(a=>tve(n.dashboard,a).map(c=>ru({...n,sheetId:a,card:c,sheetKind:t}))),s=r[0]||o[0]||ru({...n,sheetKind:t}),i=QY(...r.map(a=>a.snapshot.dashboardInputValues),...o.map(a=>a.snapshot.dashboardInputValues));return{context:s.context,snapshot:{...e.length===1?{sheetId:e[0]}:{},mode:n.mode,dashboardInputValues:i,generatedAt:n.generatedAt,timezone:n.timezone}}}function tve(e,t){var i;const n=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),r=[],o=new Set,s=a=>{!(a!=null&&a.id)||o.has(a.id)||(o.add(a.id),r.push(a))};for(const a of(n==null?void 0:n.cards)||[])s(a);for(const a of(n==null?void 0:n.frames)||[])for(const c of(a==null?void 0:a.cards)||[])s(c);return r}function ZY({sectionIds:e,...t}){const n=ru(t),r=e.map(s=>ru({...t,sectionId:s})),o=XY(t.dashboard,t.sheetId,e).map(({sectionId:s,card:i})=>ru({...t,sectionId:s,card:i}));return{...n,snapshot:{...n.snapshot,dashboardInputValues:QY(n.snapshot.dashboardInputValues,...r.map(s=>s.snapshot.dashboardInputValues),...o.map(s=>s.snapshot.dashboardInputValues))}}}function XY(e,t,n){var i,a;const r=new Set(n),o=(i=e.sheets)==null?void 0:i.find(c=>c.id===t);return(((a=o==null?void 0:o.document)==null?void 0:a.sections)||[]).flatMap(c=>c.id&&r.has(c.id)&&c.card?[{sectionId:c.id,card:c.card}]:[])}function nve({inputs:e,context:t,sheetId:n,cardId:r,sectionId:o}){const s=new Map(t.resolvedInputs.map(a=>[a.id,a]));let i={};for(const a of e){const c=s.get(a.id),u=(c==null?void 0:c.slot)||{status:"cleared"};i=p.setDashboardInputRuntimeSlot(i,a,{sheetId:n,cardId:r,sectionId:o},u)}return p.compactDashboardInputValues(i)}function rve(e){return e==="document"||e==="visual"?"export":"print"}function f1({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,mode:s,runtimeValues:i,timezone:a}){return Yi({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,runtimeValues:i,mode:rve(s),timezone:a})}function QY(...e){const t={};for(const n of e)n.shared&&(t.shared={...t.shared,...n.shared}),qT(t,"bySheetId",n.bySheetId),qT(t,"byCardId",n.byCardId),qT(t,"byDocumentSectionId",n.byDocumentSectionId);return p.compactDashboardInputValues(t)}function qT(e,t,n){if(n){e[t]||(e[t]={});for(const[r,o]of Object.entries(n))e[t][r]={...e[t][r],...o}}}function JY(e){var n;return typeof window>"u"||new URLSearchParams(window.location.search).get("isPdfRender")!=="true"?null:((n=lb(e))==null?void 0:n.reportContext)??null}function lb(e){if(typeof window>"u")return e?$t.parsePresentationExecutionSnapshot(e):null;const t=new URLSearchParams(window.location.search);if(t.get("isPdfRender")!=="true")return null;if(e)return $t.parsePresentationExecutionSnapshot(e);const n=t.get("presentationExecutionSnapshot");if(!n)return null;let r;try{r=JSON.parse(n)}catch{throw new $t.PresentationExecutionSnapshotError("Internal print presentation snapshot JSON is invalid.")}return $t.parsePresentationExecutionSnapshot(r)}function $v(){if(typeof window>"u")return;const e=new URLSearchParams(window.location.search).get("presentationAttachmentIndex");if(e===null)return;const t=Number(e);if(!Number.isInteger(t)||t<0)throw new Error("Internal print presentation attachment index is invalid");return t}function ove(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function sve(e,t){const n=ove(e);return n==="dark"?Jl({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function DB(e,t,n){return wye(sve(e,t),n)}function ive(e){return Ho.stableSerialize({hasExplicitDefaultControlValues:e!==void 0,values:e??null})}function ave(e,t){const{controlContractOverrides:n,cardId:r}=t;if(!n||(n.controlDefinitions!==void 0&&(e.controls=n.controlDefinitions),typeof r!="string"||r.trim().length===0))return e;const o=p.findCardById(e,r);return o&&(n.cardControlDefinitions!==void 0&&(o.controls=n.cardControlDefinitions),n.controlBindings!==void 0&&(o.controlBindings=n.controlBindings)),e}function lve(e,t){const n=v.useRef({key:t,value:e});return n.current.key!==t&&(n.current={key:t,value:e}),n.current.value}function cve({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o,defaultControlValues:s,controlContractOverrides:i,dashboardInputExecutionSnapshot:a,interactionExecutionSnapshot:c,presentationExecutionSnapshot:u,type:d,cardId:f,selectedSheetId:h,onFilterValuesChange:m}){var ie,we;const{authToken:g,tokenProps:b}=It(),x=g==null?void 0:g.accessToken,y=g==null?void 0:g.refreshToken,w=v.useMemo(()=>JY(u),[u]);o0e();const C=p.useDashboardStore(fe=>fe.selectedLensId),N=p.useDashboardStore(fe=>fe.relaodToken),{data:S,isLoading:j,isFetching:_,isError:k,refetch:T,dashboardIdToFetch:I}=Pv(),E=(ie=S==null?void 0:S.dashboard)==null?void 0:ie.id,{getDefaultSheetId:D,clearDefaultSheetId:R}=_Y(E),[A,F]=v.useState(o||[]),z=v.useRef(null),L=v.useRef(null),$=ive(s),H=uR(i),M=uR(i,{includePresentation:!0}),B=v.useRef(s);B.current=s;const W=v.useRef($);W.current=$;const P=lve(i,M),G=v.useRef(null),Z=v.useRef(!1),X=v.useRef({dashboardId:null,defaultControlValuesKey:$,controlContractOverridesKey:H}),{setTheme:Y}=oO(),{compiledAppearance:O}=p.useAppearance(),q=p.useDashboardStore(fe=>fe.dashboard.globalStyle),U=v.useMemo(()=>S!=null&&S.dashboard?_0e(ave(Ks(S.dashboard),{controlContractOverrides:P,cardId:f})):void 0,[S==null?void 0:S.dashboard,P,d,f]),{setDashboardWithFilterValues:V,hydrateRuntimeControlValues:K,setStyle:Q,setOnSaveFunction:se,setLenses:oe,setSelectedLensId:me,setInlineFilterValuesMap:le}=p.useDashboardActions();p.useDashboardStore(fe=>fe.actions.setCustomCards);const ue=p.useDashboardStore(fe=>fe.filterValues),ne=p.useDashboardStore(fe=>fe.actions.setThemeStyle),de=p.useDashboardStore(fe=>fe.actions.setDashboardTheme),Ce=p.useDashboardStore(fe=>fe.actions.setOnEvent);v.useEffect(()=>{const fe=L.current;fe&&fe!==I&&p.storeEvents.emit("dashboard:unload"),L.current=I},[I]),v.useEffect(()=>{N&&T()},[T,N]),v.useEffect(()=>{var ee;const fe=((ee=S==null?void 0:S.dashboard)==null?void 0:ee.id)||null,ae=z.current;fe&&fe!==ae&&p.storeEvents.emit("dashboard:load"),z.current=fe},[(we=S==null?void 0:S.dashboard)==null?void 0:we.id]),v.useEffect(()=>{de(O.mode)},[O.mode,de]),v.useEffect(()=>{t&&Y(t)},[t,Y]);const ce=v.useCallback(()=>{const fe=Ks(dt.DEFAULT_STYLE),ae=Jl(fe,q);if(e){const ee=Jl(ae,e),J=DB(O.mode,ee,O);ne(J),Q(ee)}else{const ee=DB(O.mode,ae,O);ne(ee),Q(dt.DEFAULT_STYLE)}},[O,e,q,ne,Q]);return v.useEffect(()=>{S&&S.dashboard&&ce()},[O.mode,e,q,ce,S]),v.useEffect(()=>{var ct,rt,Ct,Lt,vt,Tt;function fe(Me,Je){const kt=Me.filters||[],mt=[];for(const _t of Je){const Rt=kt.find(Pt=>Pt.id===_t.filterId);Rt&&mt.push({filterId:_t.filterId,name:Rt.column,operation:_t.operation,valueType:p.getFilterValueType(Rt),values:_t.values,dataType:Rt.dataType,fieldMeta:Rt.fieldMeta,semanticContext:Rt.semanticContext})}return mt}if(!S||!U)return;const ae=U,ee=p.useDashboardStore.getState(),J=ee.reportContextSessionAccessToken===x&&((ct=ee.dashboard)==null?void 0:ct.id)===U.id&&ee.reportContext!==null,re=w??S.initialReportContext,pe=(J?(rt=ee.reportContext)==null?void 0:rt.calendar.tz:void 0)??re.calendar.tz,{filterValues:Ee,defaultLensId:Te,lenses:ze}=S;function Pe(){if(Ee&&(Ee==null?void 0:Ee.length)>0)return Ee;const Je=[...p.buildFilterValuesFromDefaults(ae.filters,pe)];if(ae.defaultFilterValues&&ae.defaultFilterValues.length>0)for(const _t of ae.defaultFilterValues){const Rt=Je.findIndex(Pt=>Pt.filterId===_t.filterId);Rt>=0?Je[Rt]=_t:Je.push(_t)}const kt=fe(ae,A||[]),mt=[...Je];for(const _t of kt){const Rt=mt.findIndex(Pt=>Pt.filterId===_t.filterId);Rt>=0?mt[Rt]=_t:mt.push(_t)}return mt}const He=G.current===U.id&&((Ct=ee.dashboard)==null?void 0:Ct.id)===U.id,ye=Pe(),Ke=He?p.resolveSameDashboardFilterValues({previousFilters:(Lt=ee.dashboard)==null?void 0:Lt.filters,nextFilters:ae.filters,currentFilterValues:ee.filterValues,defaultFilterValues:ye}):ye,We=p.computeInlineFilterDefaults(ae,pe),Qe=He&&X.current.controlContractOverridesKey===H?p.flattenRuntimeControlValues({dashboardValues:ee.controlValues,cardValuesMap:ee.cardControlValuesMap}):B.current,xe=ee.selectedSheetId;let Ve=D(),Ae=xe;Ae&&((vt=U==null?void 0:U.sheets)!=null&&vt.some(Je=>Je.id===Ae)||(Ae=null)),Ve&&((Tt=U==null?void 0:U.sheets)!=null&&Tt.some(Je=>Je.id===Ve)||(R(),Ve=null));const ke=N0e({selectedSheetId:h,preservedSelectedSheetId:Ae,defaultSheetId:Ve,sheets:U==null?void 0:U.sheets}),Be=!!a,Ie=!!(C||S!=null&&S.defaultLensId),$e=!Be&&Z.current,st=a?dR({dashboard:ae,dashboardInputValues:a.dashboardInputValues,sheetId:a.sheetId,cardId:a.cardId}):(S==null?void 0:S.inputValues)!=null?dR({dashboard:ae,dashboardInputValues:S.inputValues.dashboardInputValues}):void 0;V(ae,Ke||[],Qe,{selectedSheetId:ke,reportContext:J?void 0:re,authToken:x?{accessToken:x,refreshToken:y}:void 0,...S!=null&&S.semanticExecutionPayload?{semanticExecutionPayload:S.semanticExecutionPayload}:{},...a?{dashboardInputValues:st,dashboardInputReferenceTime:a.generatedAt}:Ie?{dashboardInputValues:st||{},dashboardInputReferenceTime:(S==null?void 0:S.inputValues)!=null?S.inputValues.generatedAt:void 0}:$e?{dashboardInputValues:{},dashboardInputReferenceTime:void 0}:{}}),c&&p.useInteractionStore.setState({interactionStates:Ks(c)}),Z.current=Be,G.current=U.id,X.current.dashboardId!==U.id&&(X.current={dashboardId:U.id,defaultControlValuesKey:W.current,controlContractOverridesKey:H}),le(We),ze&&oe(ze),Te&&me(Te)},[S,C,oe,V,me,le,A,h,D,R,H,a,c,U,x,y,w]),v.useEffect(()=>{if(!(U!=null&&U.id))return;const fe=X.current;if(fe.dashboardId!==U.id){X.current={dashboardId:U.id,defaultControlValuesKey:$,controlContractOverridesKey:H};return}fe.defaultControlValuesKey===$&&fe.controlContractOverridesKey===H||(K(U,B.current),X.current={dashboardId:U.id,defaultControlValuesKey:$,controlContractOverridesKey:H})},[U,$,H,K]),v.useEffect(()=>{m&&ue&&m(ue)},[ue,m]),v.useEffect(()=>{n&&se(n),r&&Ce(r)},[n,se,r,Ce]),{isFetching:_,isLoading:j,isError:k,refetch:T}}const hN=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));hN.displayName="Card";const wO=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex flex-col space-y-1.5 p-6",e),...t}));wO.displayName="CardHeader";const cb=te.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:p.cn("text-2xl font-semibold leading-none tracking-tight",e),...t}));cb.displayName="CardTitle";const uve=te.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));uve.displayName="CardDescription";const CO=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("px-6 pt-0",e),...t}));CO.displayName="CardContent";const eZ=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex items-center p-6 pt-0",e),...t}));eZ.displayName="CardFooter";/**
1
+ "use strict";var Lxe=Object.defineProperty;var sB=e=>{throw TypeError(e)};var $xe=(e,t,n)=>t in e?Lxe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ne=(e,t,n)=>$xe(e,typeof t!="symbol"?t+"":t,n),$T=(e,t,n)=>t.has(e)||sB("Cannot "+n);var ve=(e,t,n)=>($T(e,t,"read from private field"),n?n.call(e):t.get(e)),At=(e,t,n)=>t.has(e)?sB("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),yt=(e,t,n,r)=>($T(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Qt=(e,t,n)=>($T(e,t,"access private method"),n);var hC=(e,t,n,r)=>({set _(o){yt(e,t,o,n)},get _(){return ve(e,t,r)}});const l=require("react/jsx-runtime"),v=require("react"),br=require("react-dom"),p=require("./switch-f3TuZNLr.cjs"),je=require("./x-B6ghREd2.cjs"),dt=require("./saved-temporal-bucket-format-CFfWXRl9.cjs"),va=require("./validators-BDYprKI9.cjs");require("./analyze-result-contract-LPDNldic.cjs");const Li=require("../value-format-preferences/index.cjs"),cf=require("./index-ByFbacH7.cjs"),zxe=require("react-dom/client"),qc=require("./temporal-bucket-authoring-o3Emn05L.cjs"),Ft=require("./search-BqqhaMx9.cjs"),Tk=require("./canonical-result-keys-BA0HCP4e.cjs"),Bxe=require("./color-CyB5o13F.cjs"),Vxe=require("./token-types-D7CaaI80.cjs"),it=require("./index-k8tEp0ys.cjs"),$r=require("./temporal-bucket-DHY1y9lq.cjs"),fn=require("./pivot-header-presentation-B9nXXKlW.cjs"),wa=require("./pivot-result-identity-Bb4EixVN.cjs"),$t=require("./pivot-result-lifecycle-DTLRuDEW.cjs"),Kt=require("./format-types-PSZZ7hG8.cjs"),Oi=require("./matrix-result-contract-zamd9euI.cjs"),Ho=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.cjs"),xr=require("./common-types-C57kJ59w.cjs"),nY=require("../dashboard-assistant/index.cjs"),rY=require("./report-runtime-context-DqxS4wbi.cjs"),Hxe=require("./contracts-CtB2VONT.cjs"),qxe=require("../layouts/index.cjs"),iB=require("./index-F25jnH0p.cjs");function rO(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const aB=rO(l),te=rO(v),V2=rO(br);function Uxe(e){return Kt.toDate(e).getMonth()}function Wxe(e){return Kt.toDate(e).getFullYear()}function Xx(e,t){const r=Zxe(e);let o;if(r.date){const c=Xxe(r.date,2);o=Qxe(c.restDateString,c.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);const s=o.getTime();let i=0,a;if(r.time&&(i=Jxe(r.time),isNaN(i)))return new Date(NaN);if(r.timezone){if(a=eye(r.timezone),isNaN(a))return new Date(NaN)}else{const c=new Date(s+i),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(s+i+a)}const mC={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Kxe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Gxe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Yxe=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Zxe(e){const t={},n=e.split(mC.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],mC.timeZoneDelimiter.test(t.date)&&(t.date=e.split(mC.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const o=mC.timezone.exec(r);o?(t.time=r.replace(o[1],""),t.timezone=o[1]):t.time=r}return t}function Xxe(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const o=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?o:s*100,restDateString:e.slice((r[1]||r[2]).length)}}function Qxe(e,t){if(t===null)return new Date(NaN);const n=e.match(Kxe);if(!n)return new Date(NaN);const r=!!n[4],o=ux(n[1]),s=ux(n[2])-1,i=ux(n[3]),a=ux(n[4]),c=ux(n[5])-1;if(r)return sye(t,a,c)?tye(t,a,c):new Date(NaN);{const u=new Date(0);return!rye(t,s,i)||!oye(t,o)?new Date(NaN):(u.setUTCFullYear(t,s,Math.max(o,i)),u)}}function ux(e){return e?parseInt(e):1}function Jxe(e){const t=e.match(Gxe);if(!t)return NaN;const n=zT(t[1]),r=zT(t[2]),o=zT(t[3]);return iye(n,r,o)?n*Kt.millisecondsInHour+r*Kt.millisecondsInMinute+o*1e3:NaN}function zT(e){return e&&parseFloat(e.replace(",","."))||0}function eye(e){if(e==="Z")return 0;const t=e.match(Yxe);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return aye(r,o)?n*(r*Kt.millisecondsInHour+o*Kt.millisecondsInMinute):NaN}function tye(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const o=r.getUTCDay()||7,s=(t-1)*7+n+1-o;return r.setUTCDate(r.getUTCDate()+s),r}const nye=[31,null,31,30,31,30,31,31,30,31,30,31];function oY(e){return e%400===0||e%4===0&&e%100!==0}function rye(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(nye[t]||(oY(e)?29:28))}function oye(e,t){return t>=1&&t<=(oY(e)?366:365)}function sye(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function iye(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function aye(e,t){return t>=0&&t<=59}var sN={exports:{}};sN.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=800,s=16,i=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",h="[object Error]",m="[object Function]",g="[object GeneratorFunction]",b="[object Map]",x="[object Number]",y="[object Null]",w="[object Object]",C="[object Proxy]",N="[object RegExp]",S="[object Set]",j="[object String]",_="[object Undefined]",k="[object WeakMap]",T="[object ArrayBuffer]",I="[object DataView]",E="[object Float32Array]",D="[object Float64Array]",R="[object Int8Array]",A="[object Int16Array]",F="[object Int32Array]",z="[object Uint8Array]",L="[object Uint8ClampedArray]",$="[object Uint16Array]",H="[object Uint32Array]",M=/[\\^$.*+?()[\]{}|]/g,B=/^\[object .+?Constructor\]$/,W=/^(?:0|[1-9]\d*)$/,P={};P[E]=P[D]=P[R]=P[A]=P[F]=P[z]=P[L]=P[$]=P[H]=!0,P[a]=P[c]=P[T]=P[d]=P[I]=P[f]=P[h]=P[m]=P[b]=P[x]=P[w]=P[N]=P[S]=P[j]=P[k]=!1;var G=typeof dt.commonjsGlobal=="object"&&dt.commonjsGlobal&&dt.commonjsGlobal.Object===Object&&dt.commonjsGlobal,Z=typeof self=="object"&&self&&self.Object===Object&&self,X=G||Z||Function("return this")(),Y=t&&!t.nodeType&&t,O=Y&&!0&&e&&!e.nodeType&&e,q=O&&O.exports===Y,U=q&&G.process,V=function(){try{var be=O&&O.require&&O.require("util").types;return be||U&&U.binding&&U.binding("util")}catch{}}(),K=V&&V.isTypedArray;function Q(be,_e,qe){switch(qe.length){case 0:return be.call(_e);case 1:return be.call(_e,qe[0]);case 2:return be.call(_e,qe[0],qe[1]);case 3:return be.call(_e,qe[0],qe[1],qe[2])}return be.apply(_e,qe)}function se(be,_e){for(var qe=-1,Ot=Array(be);++qe<be;)Ot[qe]=_e(qe);return Ot}function oe(be){return function(_e){return be(_e)}}function me(be,_e){return be==null?void 0:be[_e]}function le(be,_e){return function(qe){return be(_e(qe))}}var ue=Array.prototype,ne=Function.prototype,de=Object.prototype,Ce=X["__core-js_shared__"],ce=ne.toString,ie=de.hasOwnProperty,we=function(){var be=/[^.]+$/.exec(Ce&&Ce.keys&&Ce.keys.IE_PROTO||"");return be?"Symbol(src)_1."+be:""}(),fe=de.toString,ae=ce.call(Object),ee=RegExp("^"+ce.call(ie).replace(M,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),J=q?X.Buffer:void 0,re=X.Symbol,pe=X.Uint8Array;J&&J.allocUnsafe;var Ee=le(Object.getPrototypeOf,Object),Te=Object.create,ze=de.propertyIsEnumerable,Pe=ue.splice,He=re?re.toStringTag:void 0,ye=function(){try{var be=Co(Object,"defineProperty");return be({},"",{}),be}catch{}}(),Ke=J?J.isBuffer:void 0,We=Math.max,Qe=Date.now,xe=Co(X,"Map"),Ve=Co(Object,"create"),Ae=function(){function be(){}return function(_e){if(!Ht(_e))return{};if(Te)return Te(_e);be.prototype=_e;var qe=new be;return be.prototype=void 0,qe}}();function ke(be){var _e=-1,qe=be==null?0:be.length;for(this.clear();++_e<qe;){var Ot=be[_e];this.set(Ot[0],Ot[1])}}function Be(){this.__data__=Ve?Ve(null):{},this.size=0}function Ie(be){var _e=this.has(be)&&delete this.__data__[be];return this.size-=_e?1:0,_e}function $e(be){var _e=this.__data__;if(Ve){var qe=_e[be];return qe===r?void 0:qe}return ie.call(_e,be)?_e[be]:void 0}function st(be){var _e=this.__data__;return Ve?_e[be]!==void 0:ie.call(_e,be)}function ct(be,_e){var qe=this.__data__;return this.size+=this.has(be)?0:1,qe[be]=Ve&&_e===void 0?r:_e,this}ke.prototype.clear=Be,ke.prototype.delete=Ie,ke.prototype.get=$e,ke.prototype.has=st,ke.prototype.set=ct;function rt(be){var _e=-1,qe=be==null?0:be.length;for(this.clear();++_e<qe;){var Ot=be[_e];this.set(Ot[0],Ot[1])}}function Ct(){this.__data__=[],this.size=0}function Lt(be){var _e=this.__data__,qe=ot(_e,be);if(qe<0)return!1;var Ot=_e.length-1;return qe==Ot?_e.pop():Pe.call(_e,qe,1),--this.size,!0}function vt(be){var _e=this.__data__,qe=ot(_e,be);return qe<0?void 0:_e[qe][1]}function Tt(be){return ot(this.__data__,be)>-1}function Me(be,_e){var qe=this.__data__,Ot=ot(qe,be);return Ot<0?(++this.size,qe.push([be,_e])):qe[Ot][1]=_e,this}rt.prototype.clear=Ct,rt.prototype.delete=Lt,rt.prototype.get=vt,rt.prototype.has=Tt,rt.prototype.set=Me;function Je(be){var _e=-1,qe=be==null?0:be.length;for(this.clear();++_e<qe;){var Ot=be[_e];this.set(Ot[0],Ot[1])}}function kt(){this.size=0,this.__data__={hash:new ke,map:new(xe||rt),string:new ke}}function mt(be){var _e=Lr(this,be).delete(be);return this.size-=_e?1:0,_e}function _t(be){return Lr(this,be).get(be)}function Rt(be){return Lr(this,be).has(be)}function Pt(be,_e){var qe=Lr(this,be),Ot=qe.size;return qe.set(be,_e),this.size+=qe.size==Ot?0:1,this}Je.prototype.clear=kt,Je.prototype.delete=mt,Je.prototype.get=_t,Je.prototype.has=Rt,Je.prototype.set=Pt;function wt(be){var _e=this.__data__=new rt(be);this.size=_e.size}function Et(){this.__data__=new rt,this.size=0}function Bt(be){var _e=this.__data__,qe=_e.delete(be);return this.size=_e.size,qe}function un(be){return this.__data__.get(be)}function Ge(be){return this.__data__.has(be)}function Re(be,_e){var qe=this.__data__;if(qe instanceof rt){var Ot=qe.__data__;if(!xe||Ot.length<n-1)return Ot.push([be,_e]),this.size=++qe.size,this;qe=this.__data__=new Je(Ot)}return qe.set(be,_e),this.size=qe.size,this}wt.prototype.clear=Et,wt.prototype.delete=Bt,wt.prototype.get=un,wt.prototype.has=Ge,wt.prototype.set=Re;function De(be,_e){var qe=vc(be),Ot=!qe&&yc(be),gn=!qe&&!Ot&&us(be),Vn=!qe&&!Ot&&!gn&&Gt(be),mr=qe||Ot||gn||Vn,Hn=mr?se(be.length,String):[],cr=Hn.length;for(var _i in be)mr&&(_i=="length"||gn&&(_i=="offset"||_i=="parent")||Vn&&(_i=="buffer"||_i=="byteLength"||_i=="byteOffset")||xl(_i,cr))||Hn.push(_i);return Hn}function he(be,_e,qe){(qe!==void 0&&!yl(be[_e],qe)||qe===void 0&&!(_e in be))&&Dt(be,_e,qe)}function Fe(be,_e,qe){var Ot=be[_e];(!(ie.call(be,_e)&&yl(Ot,qe))||qe===void 0&&!(_e in be))&&Dt(be,_e,qe)}function ot(be,_e){for(var qe=be.length;qe--;)if(yl(be[qe][0],_e))return qe;return-1}function Dt(be,_e,qe){_e=="__proto__"&&ye?ye(be,_e,{configurable:!0,enumerable:!0,value:qe,writable:!0}):be[_e]=qe}var nt=Rs();function ge(be){return be==null?be===void 0?_:y:He&&He in Object(be)?Qi(be):oi(be)}function Se(be){return wn(be)&&ge(be)==a}function Oe(be){if(!Ht(be)||Ps(be))return!1;var _e=Wu(be)?ee:B;return _e.test(Uu(be))}function Ye(be){return wn(be)&&Xe(be.length)&&!!P[ge(be)]}function bt(be){if(!Ht(be))return qu(be);var _e=If(be),qe=[];for(var Ot in be)Ot=="constructor"&&(_e||!ie.call(be,Ot))||qe.push(Ot);return qe}function St(be,_e,qe,Ot,gn){be!==_e&&nt(_e,function(Vn,mr){if(gn||(gn=new wt),Ht(Vn))on(be,_e,mr,qe,St,Ot,gn);else{var Hn=Ot?Ot($n(be,mr),Vn,mr+"",be,_e,gn):void 0;Hn===void 0&&(Hn=Vn),he(be,mr,Hn)}},An)}function on(be,_e,qe,Ot,gn,Vn,mr){var Hn=$n(be,qe),cr=$n(_e,qe),_i=mr.get(cr);if(_i){he(be,qe,_i);return}var Fs=Vn?Vn(Hn,cr,qe+"",be,_e,mr):void 0,Gu=Fs===void 0;if(Gu){var lx=vc(cr),cx=!lx&&us(cr),fC=!lx&&!cx&&Gt(cr);Fs=cr,lx||cx||fC?vc(Hn)?Fs=Hn:So(Hn)?Fs=Vt(Hn):cx?(Gu=!1,Fs=et(cr)):fC?(Gu=!1,Fs=ht(cr)):Fs=[]:nn(cr)||yc(cr)?(Fs=Hn,yc(Hn)?Fs=or(Hn):(!Ht(Hn)||Wu(Hn))&&(Fs=Hu(cr))):Gu=!1}Gu&&(mr.set(cr,Fs),gn(Fs,cr,Ot,Vn,mr),mr.delete(cr)),he(be,qe,Fs)}function sn(be,_e){return Tf(xc(be,_e,co),be+"")}var Le=ye?function(be,_e){return ye(be,"toString",{configurable:!0,enumerable:!1,value:Nr(_e),writable:!0})}:co;function et(be,_e){return be.slice()}function at(be){var _e=new be.constructor(be.byteLength);return new pe(_e).set(new pe(be)),_e}function ht(be,_e){var qe=at(be.buffer);return new be.constructor(qe,be.byteOffset,be.length)}function Vt(be,_e){var qe=-1,Ot=be.length;for(_e||(_e=Array(Ot));++qe<Ot;)_e[qe]=be[qe];return _e}function Xn(be,_e,qe,Ot){var gn=!qe;qe||(qe={});for(var Vn=-1,mr=_e.length;++Vn<mr;){var Hn=_e[Vn],cr=void 0;cr===void 0&&(cr=be[Hn]),gn?Dt(qe,Hn,cr):Fe(qe,Hn,cr)}return qe}function Go(be){return sn(function(_e,qe){var Ot=-1,gn=qe.length,Vn=gn>1?qe[gn-1]:void 0,mr=gn>2?qe[2]:void 0;for(Vn=be.length>3&&typeof Vn=="function"?(gn--,Vn):void 0,mr&&ki(qe[0],qe[1],mr)&&(Vn=gn<3?void 0:Vn,gn=1),_e=Object(_e);++Ot<gn;){var Hn=qe[Ot];Hn&&be(_e,Hn,Ot,Vn)}return _e})}function Rs(be){return function(_e,qe,Ot){for(var gn=-1,Vn=Object(_e),mr=Ot(_e),Hn=mr.length;Hn--;){var cr=mr[++gn];if(qe(Vn[cr],cr,Vn)===!1)break}return _e}}function Lr(be,_e){var qe=be.__data__;return As(_e)?qe[typeof _e=="string"?"string":"hash"]:qe.map}function Co(be,_e){var qe=me(be,_e);return Oe(qe)?qe:void 0}function Qi(be){var _e=ie.call(be,He),qe=be[He];try{be[He]=void 0;var Ot=!0}catch{}var gn=fe.call(be);return Ot&&(_e?be[He]=qe:delete be[He]),gn}function Hu(be){return typeof be.constructor=="function"&&!If(be)?Ae(Ee(be)):{}}function xl(be,_e){var qe=typeof be;return _e=_e??i,!!_e&&(qe=="number"||qe!="symbol"&&W.test(be))&&be>-1&&be%1==0&&be<_e}function ki(be,_e,qe){if(!Ht(qe))return!1;var Ot=typeof _e;return(Ot=="number"?vl(qe)&&xl(_e,qe.length):Ot=="string"&&_e in qe)?yl(qe[_e],be):!1}function As(be){var _e=typeof be;return _e=="string"||_e=="number"||_e=="symbol"||_e=="boolean"?be!=="__proto__":be===null}function Ps(be){return!!we&&we in be}function If(be){var _e=be&&be.constructor,qe=typeof _e=="function"&&_e.prototype||de;return be===qe}function qu(be){var _e=[];if(be!=null)for(var qe in Object(be))_e.push(qe);return _e}function oi(be){return fe.call(be)}function xc(be,_e,qe){return _e=We(_e===void 0?be.length-1:_e,0),function(){for(var Ot=arguments,gn=-1,Vn=We(Ot.length-_e,0),mr=Array(Vn);++gn<Vn;)mr[gn]=Ot[_e+gn];gn=-1;for(var Hn=Array(_e+1);++gn<_e;)Hn[gn]=Ot[gn];return Hn[_e]=qe(mr),Q(be,this,Hn)}}function $n(be,_e){if(!(_e==="constructor"&&typeof be[_e]=="function")&&_e!="__proto__")return be[_e]}var Tf=Ma(Le);function Ma(be){var _e=0,qe=0;return function(){var Ot=Qe(),gn=s-(Ot-qe);if(qe=Ot,gn>0){if(++_e>=o)return arguments[0]}else _e=0;return be.apply(void 0,arguments)}}function Uu(be){if(be!=null){try{return ce.call(be)}catch{}try{return be+""}catch{}}return""}function yl(be,_e){return be===_e||be!==be&&_e!==_e}var yc=Se(function(){return arguments}())?Se:function(be){return wn(be)&&ie.call(be,"callee")&&!ze.call(be,"callee")},vc=Array.isArray;function vl(be){return be!=null&&Xe(be.length)&&!Wu(be)}function So(be){return wn(be)&&vl(be)}var us=Ke||Ku;function Wu(be){if(!Ht(be))return!1;var _e=ge(be);return _e==m||_e==g||_e==u||_e==C}function Xe(be){return typeof be=="number"&&be>-1&&be%1==0&&be<=i}function Ht(be){var _e=typeof be;return be!=null&&(_e=="object"||_e=="function")}function wn(be){return be!=null&&typeof be=="object"}function nn(be){if(!wn(be)||ge(be)!=w)return!1;var _e=Ee(be);if(_e===null)return!0;var qe=ie.call(_e,"constructor")&&_e.constructor;return typeof qe=="function"&&qe instanceof qe&&ce.call(qe)==ae}var Gt=K?oe(K):Ye;function or(be){return Xn(be,An(be))}function An(be){return vl(be)?De(be):bt(be)}var Dr=Go(function(be,_e,qe){St(be,_e,qe)});function Nr(be){return function(){return be}}function co(be){return be}function Ku(){return!1}e.exports=Dr})(sN,sN.exports);var lye=sN.exports;const Jl=dt.getDefaultExportFromCjs(lye),cye={theme:"system",setTheme:()=>null},sY=v.createContext(cye);function iN(e,t="system"){return uye(e)?e:t}function uye(e){return e==="light"||e==="dark"||e==="system"}const oO=()=>{const e=v.useContext(sY);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},iY=(e,t)=>{const n={};if(e===null||t===null)return t;const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const o of r){if(!(o in e)&&o in t){n[o]=t[o];continue}if(o in e&&!(o in t)){n[o]=void 0;continue}const s=e[o],i=t[o];if(!H2(s,i))if(Array.isArray(s)&&Array.isArray(i))n[o]=i;else if(lB(s)&&lB(i)){const a=iY(s,i);Object.keys(a).length>0&&(n[o]=a)}else n[o]=i}return n},H2=(e,t)=>{if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((o,s)=>H2(o,t[s]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(o=>H2(e[o],t[o]))}return!1},lB=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ks=e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(Array.isArray(e))return e.map(n=>Ks(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=Ks(e[n]));return t},aY="__semaphorAuthoredFontFamily";var VG,HG;const dye=(HG=(VG=dt.DEFAULT_STYLE.default.chart)==null?void 0:VG.font)==null?void 0:HG.family,fye=new Set([dye,"Open Sans, Arial, sans-serif",'"Open Sans", Arial, sans-serif'].filter(Boolean));function hye(e,t){if(!e)return t?{family:t}:void 0;const{[aY]:n,...r}=e,o=mye(r.family,t,!!n);return{...r,...o?{family:o}:void 0}}function mye(e,t,n=!1){return n&&e||e&&!pye(e)?e:t||e}function pye(e){return fye.has(e.trim())}function gye(e,t){if(!t)return e;const n={...e,font:sa(e.font,t)},r=yye(e.plugins,t);r&&(n.plugins=r);const o=vye(e.scales,t);return o&&(n.scales=o),n}function bye(e,t){return!e||!t?e:e.map(n=>{if(!n||typeof n!="object")return n;const r=n,o=r.datalabels;return!o||typeof o!="object"?n:{...r,datalabels:{...o,font:sa(o.font,t)}}})}function xye(e,t){if(!e||typeof e!="object"||!t)return e;const n=e.datasets;return Array.isArray(n)?{...e,datasets:bye(n,t)}:e}function yye(e,t){var n;return e&&{...e,title:e.title?{...e.title,font:sa(e.title.font,t)}:e.title,subtitle:e.subtitle?{...e.subtitle,font:sa(e.subtitle.font,t)}:e.subtitle,legend:e.legend?{...e.legend,labels:e.legend.labels?{...e.legend.labels,font:sa(e.legend.labels.font,t)}:e.legend.labels}:e.legend,tooltip:e.tooltip?{...e.tooltip,titleFont:sa(e.tooltip.titleFont,t),bodyFont:sa(e.tooltip.bodyFont,t),footerFont:sa(e.tooltip.footerFont,t)}:e.tooltip,datalabels:e.datalabels?{...e.datalabels,font:sa((n=e.datalabels)==null?void 0:n.font,t)}:e.datalabels}}function vye(e,t){return e&&Object.entries(e).reduce((n,[r,o])=>{if(!o||typeof o!="object")return n[r]=o,n;const s=o;return n[r]={...s,ticks:s.ticks?{...s.ticks,font:sa(s.ticks.font,t)}:s.ticks,title:s.title?{...s.title,font:sa(s.title.font,t)}:s.title,pointLabels:s.pointLabels?{...s.pointLabels,font:sa(s.pointLabels.font,t)}:s.pointLabels},n},{})}function sa(e,t){return typeof e=="function"?e:{...t,...e&&typeof e=="object"?e:{}}}function wye(e,t){const n=Ks(e??{}),r=Cye(t);if(!r)return n;const o=Jl(n,r);return jye(o,r),o}function Cye(e){var h,m,g,b;const t=(h=e.scheme.components)==null?void 0:h.chart,n=cf.SEMAPHOR_DEFAULT_APPEARANCE_SPEC.schemes[e.mode],r=(m=n.components)==null?void 0:m.chart,o=(g=n.tokens)==null?void 0:g.typography,s={};Nye(t==null?void 0:t.palette,r==null?void 0:r.palette)&&(s.dataset={backgroundColor:[...t.palette],borderColor:[...t.palette]});const i=(b=e.scheme.tokens)==null?void 0:b.typography,a=ap(i==null?void 0:i.fontFamily,o==null?void 0:o.fontFamily),c=ap(i==null?void 0:i.baseFontSize,o==null?void 0:o.baseFontSize);if(a||c!==void 0){const x={...a?{family:a}:void 0,...c!==void 0?{size:c}:void 0};a&&(x[aY]=!0),s.font=x}const u=ap(t==null?void 0:t.gridColor,r==null?void 0:r.gridColor),d=ap(t==null?void 0:t.axisColor,r==null?void 0:r.axisColor)??ap(t==null?void 0:t.foreground,r==null?void 0:r.foreground);(u||d)&&(s.options={scales:{x:BT({gridColor:u,axisColor:d}),y:BT({gridColor:u,axisColor:d}),y2:BT({gridColor:u,axisColor:d}),r:Sye({gridColor:u,axisColor:d})}});const f=ap(t==null?void 0:t.foreground,r==null?void 0:r.foreground);return f&&(s.options=Jl(s.options??{},{plugins:{legend:{labels:{color:f}}}})),Object.keys(s).length>0?{chart:s}:void 0}function BT({gridColor:e,axisColor:t}){return{...e?{grid:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t}}:void 0}}function Sye({gridColor:e,axisColor:t}){return{...e?{grid:{color:e},angleLines:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t},pointLabels:{color:t}}:void 0}}function Nye(e,t){return e!=null&&e.length?!(t!=null&&t.length)||e.length!==t.length?!0:e.some((n,r)=>n!==t[r]):!1}function ap(e,t){return e!==void 0&&e!==t?e:void 0}function jye(e,t){var r;const n=(r=t.chart)==null?void 0:r.dataset;n&&(e.chart=e.chart??{},e.chart.dataset=e.chart.dataset??{},Array.isArray(n.backgroundColor)&&(e.chart.dataset.backgroundColor=[...n.backgroundColor]),Array.isArray(n.borderColor)&&(e.chart.dataset.borderColor=[...n.borderColor]))}var Em=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},kye={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Rl,wh,qG,_ye=(qG=class{constructor(){At(this,Rl,kye);At(this,wh,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&ve(this,wh)&&e!==ve(this,Rl)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:ve(this,Rl),provider:e}),yt(this,Rl,e),process.env.NODE_ENV!=="production"&&yt(this,wh,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&yt(this,wh,!0),ve(this,Rl).setTimeout(e,t)}clearTimeout(e){ve(this,Rl).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&yt(this,wh,!0),ve(this,Rl).setInterval(e,t)}clearInterval(e){ve(this,Rl).clearInterval(e)}},Rl=new WeakMap,wh=new WeakMap,qG),lh=new _ye;function Iye(e){setTimeout(e,0)}var Zh=typeof window>"u"||"Deno"in globalThis;function gs(){}function Tye(e,t){return typeof e=="function"?e(t):e}function q2(e){return typeof e=="number"&&e>=0&&e!==1/0}function lY(e,t){return Math.max(e+(t||0)-Date.now(),0)}function _d(e,t){return typeof e=="function"?e(t):e}function ia(e,t){return typeof e=="function"?e(t):e}function cB(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:s,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==sO(i,t.options))return!1}else if(!f0(t.queryKey,i))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||s&&!s(t))}function uB(e,t){const{exact:n,status:r,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(Xh(t.options.mutationKey)!==Xh(s))return!1}else if(!f0(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function sO(e,t){return((t==null?void 0:t.queryKeyHashFn)||Xh)(e)}function Xh(e){return JSON.stringify(e,(t,n)=>U2(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function f0(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>f0(e[n],t[n])):!1}var Eye=Object.prototype.hasOwnProperty;function aN(e,t){if(e===t)return e;const n=dB(e)&&dB(t);if(!n&&!(U2(e)&&U2(t)))return t;const o=(n?e:Object.keys(e)).length,s=n?t:Object.keys(t),i=s.length,a=n?new Array(i):{};let c=0;for(let u=0;u<i;u++){const d=n?u:s[u],f=e[d],h=t[d];if(f===h){a[d]=f,(n?u<o:Eye.call(e,d))&&c++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){a[d]=h;continue}const m=aN(f,h);a[d]=m,m===f&&c++}return o===i&&c===o?e:a}function h0(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function dB(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function U2(e){if(!fB(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!fB(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function fB(e){return Object.prototype.toString.call(e)==="[object Object]"}function Dye(e){return new Promise(t=>{lh.setTimeout(t,e)})}function W2(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return aN(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return aN(e,t)}return t}function Mye(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Rye(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var lN=Symbol();function cY(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===lN&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===lN?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function uY(e,t){return typeof e=="function"?e(...t):!!e}var Ch,id,hg,UG,Aye=(UG=class extends Em{constructor(){super();At(this,Ch);At(this,id);At(this,hg);yt(this,hg,t=>{if(!Zh&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){ve(this,id)||this.setEventListener(ve(this,hg))}onUnsubscribe(){var t;this.hasListeners()||((t=ve(this,id))==null||t.call(this),yt(this,id,void 0))}setEventListener(t){var n;yt(this,hg,t),(n=ve(this,id))==null||n.call(this),yt(this,id,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){ve(this,Ch)!==t&&(yt(this,Ch,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof ve(this,Ch)=="boolean"?ve(this,Ch):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ch=new WeakMap,id=new WeakMap,hg=new WeakMap,UG),iO=new Aye;function K2(){let e,t;const n=new Promise((o,s)=>{e=o,t=s});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}var Pye=Iye;function Fye(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Pye;const s=a=>{t?e.push(a):o(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{s(()=>{a(...c)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var Ur=Fye(),mg,ad,pg,WG,Oye=(WG=class extends Em{constructor(){super();At(this,mg,!0);At(this,ad);At(this,pg);yt(this,pg,t=>{if(!Zh&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){ve(this,ad)||this.setEventListener(ve(this,pg))}onUnsubscribe(){var t;this.hasListeners()||((t=ve(this,ad))==null||t.call(this),yt(this,ad,void 0))}setEventListener(t){var n;yt(this,pg,t),(n=ve(this,ad))==null||n.call(this),yt(this,ad,t(this.setOnline.bind(this)))}setOnline(t){ve(this,mg)!==t&&(yt(this,mg,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return ve(this,mg)}},mg=new WeakMap,ad=new WeakMap,pg=new WeakMap,WG),cN=new Oye;function Lye(e){return Math.min(1e3*2**e,3e4)}function dY(e){return(e??"online")==="online"?cN.isOnline():!0}var G2=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function fY(e){let t=!1,n=0,r;const o=K2(),s=()=>o.status!=="pending",i=b=>{var x;if(!s()){const y=new G2(b);h(y),(x=e.onCancel)==null||x.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>iO.isFocused()&&(e.networkMode==="always"||cN.isOnline())&&e.canRun(),d=()=>dY(e.networkMode)&&e.canRun(),f=b=>{s()||(r==null||r(),o.resolve(b))},h=b=>{s()||(r==null||r(),o.reject(b))},m=()=>new Promise(b=>{var x;r=y=>{(s()||u())&&b(y)},(x=e.onPause)==null||x.call(e)}).then(()=>{var b;r=void 0,s()||(b=e.onContinue)==null||b.call(e)}),g=()=>{if(s())return;let b;const x=n===0?e.initialPromise:void 0;try{b=x??e.fn()}catch(y){b=Promise.reject(y)}Promise.resolve(b).then(f).catch(y=>{var j;if(s())return;const w=e.retry??(Zh?0:3),C=e.retryDelay??Lye,N=typeof C=="function"?C(n,y):C,S=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!S){h(y);return}n++,(j=e.onFail)==null||j.call(e,n,y),Dye(N).then(()=>u()?void 0:m()).then(()=>{t?h(y):g()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(r==null||r(),o),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?g():m().then(g),o)}}var Sh,KG,hY=(KG=class{constructor(){At(this,Sh)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),q2(this.gcTime)&&yt(this,Sh,lh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Zh?1/0:5*60*1e3))}clearGcTimeout(){ve(this,Sh)&&(lh.clearTimeout(ve(this,Sh)),yt(this,Sh,void 0))}},Sh=new WeakMap,KG),Nh,gg,ra,jh,Ao,kv,kh,Oa,kc,GG,$ye=(GG=class extends hY{constructor(t){super();At(this,Oa);At(this,Nh);At(this,gg);At(this,ra);At(this,jh);At(this,Ao);At(this,kv);At(this,kh);yt(this,kh,!1),yt(this,kv,t.defaultOptions),this.setOptions(t.options),this.observers=[],yt(this,jh,t.client),yt(this,ra,ve(this,jh).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,yt(this,Nh,mB(this.options)),this.state=t.state??ve(this,Nh),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=ve(this,Ao))==null?void 0:t.promise}setOptions(t){if(this.options={...ve(this,kv),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=mB(this.options);n.data!==void 0&&(this.setState(hB(n.data,n.dataUpdatedAt)),yt(this,Nh,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ve(this,ra).remove(this)}setData(t,n){const r=W2(this.state.data,t,this.options);return Qt(this,Oa,kc).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Qt(this,Oa,kc).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=ve(this,Ao))==null?void 0:r.promise;return(o=ve(this,Ao))==null||o.cancel(t),n?n.then(gs).catch(gs):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ve(this,Nh))}isActive(){return this.observers.some(t=>ia(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===lN||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>_d(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lY(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=ve(this,Ao))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=ve(this,Ao))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),ve(this,ra).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(ve(this,Ao)&&(ve(this,kh)?ve(this,Ao).cancel({revert:!0}):ve(this,Ao).cancelRetry()),this.scheduleGc()),ve(this,ra).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Qt(this,Oa,kc).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,h,m,g,b,x,y,w,C;if(this.state.fetchStatus!=="idle"&&((c=ve(this,Ao))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(ve(this,Ao))return ve(this,Ao).continueRetry(),ve(this,Ao).promise}if(t&&this.setOptions(t),!this.options.queryFn){const N=this.observers.find(S=>S.options.queryFn);N&&this.setOptions(N.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=N=>{Object.defineProperty(N,"signal",{enumerable:!0,get:()=>(yt(this,kh,!0),r.signal)})},s=()=>{const N=cY(this.options,n),j=(()=>{const _={client:ve(this,jh),queryKey:this.queryKey,meta:this.meta};return o(_),_})();return yt(this,kh,!1),this.options.persister?this.options.persister(N,j,this):N(j)},a=(()=>{const N={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:ve(this,jh),state:this.state,fetchFn:s};return o(N),N})();(u=this.options.behavior)==null||u.onFetch(a,this),yt(this,gg,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&Qt(this,Oa,kc).call(this,{type:"fetch",meta:(f=a.fetchOptions)==null?void 0:f.meta}),yt(this,Ao,fY({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:N=>{N instanceof G2&&N.revert&&this.setState({...ve(this,gg),fetchStatus:"idle"}),r.abort()},onFail:(N,S)=>{Qt(this,Oa,kc).call(this,{type:"failed",failureCount:N,error:S})},onPause:()=>{Qt(this,Oa,kc).call(this,{type:"pause"})},onContinue:()=>{Qt(this,Oa,kc).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const N=await ve(this,Ao).start();if(N===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(N),(m=(h=ve(this,ra).config).onSuccess)==null||m.call(h,N,this),(b=(g=ve(this,ra).config).onSettled)==null||b.call(g,N,this.state.error,this),N}catch(N){if(N instanceof G2){if(N.silent)return ve(this,Ao).promise;if(N.revert){if(this.state.data===void 0)throw N;return this.state.data}}throw Qt(this,Oa,kc).call(this,{type:"error",error:N}),(y=(x=ve(this,ra).config).onError)==null||y.call(x,N,this),(C=(w=ve(this,ra).config).onSettled)==null||C.call(w,this.state.data,N,this),N}finally{this.scheduleGc()}}},Nh=new WeakMap,gg=new WeakMap,ra=new WeakMap,jh=new WeakMap,Ao=new WeakMap,kv=new WeakMap,kh=new WeakMap,Oa=new WeakSet,kc=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...mY(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,...hB(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return yt(this,gg,t.manual?o:void 0),o;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ur.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),ve(this,ra).notify({query:this,type:"updated",action:t})})},GG);function mY(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:dY(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function hB(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function mB(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var di,Pn,_v,Hs,_h,bg,Pc,ld,Iv,xg,yg,Ih,Th,cd,vg,rr,Qx,Y2,Z2,X2,Q2,J2,eR,tR,pY,YG,aO=(YG=class extends Em{constructor(t,n){super();At(this,rr);At(this,di);At(this,Pn);At(this,_v);At(this,Hs);At(this,_h);At(this,bg);At(this,Pc);At(this,ld);At(this,Iv);At(this,xg);At(this,yg);At(this,Ih);At(this,Th);At(this,cd);At(this,vg,new Set);this.options=n,yt(this,di,t),yt(this,ld,null),yt(this,Pc,K2()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ve(this,Pn).addObserver(this),pB(ve(this,Pn),this.options)?Qt(this,rr,Qx).call(this):this.updateResult(),Qt(this,rr,Q2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nR(ve(this,Pn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nR(ve(this,Pn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Qt(this,rr,J2).call(this),Qt(this,rr,eR).call(this),ve(this,Pn).removeObserver(this)}setOptions(t){const n=this.options,r=ve(this,Pn);if(this.options=ve(this,di).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ia(this.options.enabled,ve(this,Pn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Qt(this,rr,tR).call(this),ve(this,Pn).setOptions(this.options),n._defaulted&&!h0(this.options,n)&&ve(this,di).getQueryCache().notify({type:"observerOptionsUpdated",query:ve(this,Pn),observer:this});const o=this.hasListeners();o&&gB(ve(this,Pn),r,this.options,n)&&Qt(this,rr,Qx).call(this),this.updateResult(),o&&(ve(this,Pn)!==r||ia(this.options.enabled,ve(this,Pn))!==ia(n.enabled,ve(this,Pn))||_d(this.options.staleTime,ve(this,Pn))!==_d(n.staleTime,ve(this,Pn)))&&Qt(this,rr,Y2).call(this);const s=Qt(this,rr,Z2).call(this);o&&(ve(this,Pn)!==r||ia(this.options.enabled,ve(this,Pn))!==ia(n.enabled,ve(this,Pn))||s!==ve(this,cd))&&Qt(this,rr,X2).call(this,s)}getOptimisticResult(t){const n=ve(this,di).getQueryCache().build(ve(this,di),t),r=this.createResult(n,t);return Bye(this,r)&&(yt(this,Hs,r),yt(this,bg,this.options),yt(this,_h,ve(this,Pn).state)),r}getCurrentResult(){return ve(this,Hs)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&ve(this,Pc).status==="pending"&&ve(this,Pc).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(t){ve(this,vg).add(t)}getCurrentQuery(){return ve(this,Pn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=ve(this,di).defaultQueryOptions(t),r=ve(this,di).getQueryCache().build(ve(this,di),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Qt(this,rr,Qx).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ve(this,Hs)))}createResult(t,n){var T;const r=ve(this,Pn),o=this.options,s=ve(this,Hs),i=ve(this,_h),a=ve(this,bg),u=t!==r?t.state:ve(this,_v),{state:d}=t;let f={...d},h=!1,m;if(n._optimisticResults){const I=this.hasListeners(),E=!I&&pB(t,n),D=I&&gB(t,r,n,o);(E||D)&&(f={...f,...mY(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=f;m=f.data;let y=!1;if(n.placeholderData!==void 0&&m===void 0&&x==="pending"){let I;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(I=s.data,y=!0):I=typeof n.placeholderData=="function"?n.placeholderData((T=ve(this,yg))==null?void 0:T.state.data,ve(this,yg)):n.placeholderData,I!==void 0&&(x="success",m=W2(s==null?void 0:s.data,I,n),h=!0)}if(n.select&&m!==void 0&&!y)if(s&&m===(i==null?void 0:i.data)&&n.select===ve(this,Iv))m=ve(this,xg);else try{yt(this,Iv,n.select),m=n.select(m),m=W2(s==null?void 0:s.data,m,n),yt(this,xg,m),yt(this,ld,null)}catch(I){yt(this,ld,I)}ve(this,ld)&&(g=ve(this,ld),m=ve(this,xg),b=Date.now(),x="error");const w=f.fetchStatus==="fetching",C=x==="pending",N=x==="error",S=C&&w,j=m!==void 0,k={status:x,fetchStatus:f.fetchStatus,isPending:C,isSuccess:x==="success",isError:N,isInitialLoading:S,isLoading:S,data:m,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!C,isLoadingError:N&&!j,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&j,isStale:lO(t,n),refetch:this.refetch,promise:ve(this,Pc),isEnabled:ia(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=R=>{k.status==="error"?R.reject(k.error):k.data!==void 0&&R.resolve(k.data)},E=()=>{const R=yt(this,Pc,k.promise=K2());I(R)},D=ve(this,Pc);switch(D.status){case"pending":t.queryHash===r.queryHash&&I(D);break;case"fulfilled":(k.status==="error"||k.data!==D.value)&&E();break;case"rejected":(k.status!=="error"||k.error!==D.reason)&&E();break}}return k}updateResult(){const t=ve(this,Hs),n=this.createResult(ve(this,Pn),this.options);if(yt(this,_h,ve(this,Pn).state),yt(this,bg,this.options),ve(this,_h).data!==void 0&&yt(this,yg,ve(this,Pn)),h0(n,t))return;yt(this,Hs,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,s=typeof o=="function"?o():o;if(s==="all"||!s&&!ve(this,vg).size)return!0;const i=new Set(s??ve(this,vg));return this.options.throwOnError&&i.add("error"),Object.keys(ve(this,Hs)).some(a=>{const c=a;return ve(this,Hs)[c]!==t[c]&&i.has(c)})};Qt(this,rr,pY).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Qt(this,rr,Q2).call(this)}},di=new WeakMap,Pn=new WeakMap,_v=new WeakMap,Hs=new WeakMap,_h=new WeakMap,bg=new WeakMap,Pc=new WeakMap,ld=new WeakMap,Iv=new WeakMap,xg=new WeakMap,yg=new WeakMap,Ih=new WeakMap,Th=new WeakMap,cd=new WeakMap,vg=new WeakMap,rr=new WeakSet,Qx=function(t){Qt(this,rr,tR).call(this);let n=ve(this,Pn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(gs)),n},Y2=function(){Qt(this,rr,J2).call(this);const t=_d(this.options.staleTime,ve(this,Pn));if(Zh||ve(this,Hs).isStale||!q2(t))return;const r=lY(ve(this,Hs).dataUpdatedAt,t)+1;yt(this,Ih,lh.setTimeout(()=>{ve(this,Hs).isStale||this.updateResult()},r))},Z2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ve(this,Pn)):this.options.refetchInterval)??!1},X2=function(t){Qt(this,rr,eR).call(this),yt(this,cd,t),!(Zh||ia(this.options.enabled,ve(this,Pn))===!1||!q2(ve(this,cd))||ve(this,cd)===0)&&yt(this,Th,lh.setInterval(()=>{(this.options.refetchIntervalInBackground||iO.isFocused())&&Qt(this,rr,Qx).call(this)},ve(this,cd)))},Q2=function(){Qt(this,rr,Y2).call(this),Qt(this,rr,X2).call(this,Qt(this,rr,Z2).call(this))},J2=function(){ve(this,Ih)&&(lh.clearTimeout(ve(this,Ih)),yt(this,Ih,void 0))},eR=function(){ve(this,Th)&&(lh.clearInterval(ve(this,Th)),yt(this,Th,void 0))},tR=function(){const t=ve(this,di).getQueryCache().build(ve(this,di),this.options);if(t===ve(this,Pn))return;const n=ve(this,Pn);yt(this,Pn,t),yt(this,_v,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},pY=function(t){Ur.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(ve(this,Hs))}),ve(this,di).getQueryCache().notify({query:ve(this,Pn),type:"observerResultsUpdated"})})},YG);function zye(e,t){return ia(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function pB(e,t){return zye(e,t)||e.state.data!==void 0&&nR(e,t,t.refetchOnMount)}function nR(e,t,n){if(ia(t.enabled,e)!==!1&&_d(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&lO(e,t)}return!1}function gB(e,t,n,r){return(e!==t||ia(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&lO(e,n)}function lO(e,t){return ia(t.enabled,e)!==!1&&e.isStaleByTime(_d(t.staleTime,e))}function Bye(e,t){return!h0(e.getCurrentResult(),t)}function bB(e){return{onFetch:(t,n)=>{var d,f,h,m,g;const r=t.options,o=(h=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,s=((m=t.state.data)==null?void 0:m.pages)||[],i=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let b=!1;const x=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(t.signal.aborted?b=!0:t.signal.addEventListener("abort",()=>{b=!0}),t.signal)})},y=cY(t.options,t.fetchOptions),w=async(C,N,S)=>{if(b)return Promise.reject();if(N==null&&C.pages.length)return Promise.resolve(C);const _=(()=>{const E={client:t.client,queryKey:t.queryKey,pageParam:N,direction:S?"backward":"forward",meta:t.options.meta};return x(E),E})(),k=await y(_),{maxPages:T}=t.options,I=S?Rye:Mye;return{pages:I(C.pages,k,T),pageParams:I(C.pageParams,N,T)}};if(o&&s.length){const C=o==="backward",N=C?Vye:xB,S={pages:s,pageParams:i},j=N(r,S);a=await w(S,j,C)}else{const C=e??s.length;do{const N=c===0?i[0]??r.initialPageParam:xB(r,a);if(c>0&&N==null)break;a=await w(a,N),c++}while(c<C)}return a};t.options.persister?t.fetchFn=()=>{var b,x;return(x=(b=t.options).persister)==null?void 0:x.call(b,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function xB(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Vye(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Tv,Al,qs,Eh,Pl,Ju,ZG,Hye=(ZG=class extends hY{constructor(t){super();At(this,Pl);At(this,Tv);At(this,Al);At(this,qs);At(this,Eh);yt(this,Tv,t.client),this.mutationId=t.mutationId,yt(this,qs,t.mutationCache),yt(this,Al,[]),this.state=t.state||gY(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ve(this,Al).includes(t)||(ve(this,Al).push(t),this.clearGcTimeout(),ve(this,qs).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){yt(this,Al,ve(this,Al).filter(n=>n!==t)),this.scheduleGc(),ve(this,qs).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ve(this,Al).length||(this.state.status==="pending"?this.scheduleGc():ve(this,qs).remove(this))}continue(){var t;return((t=ve(this,Eh))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,a,c,u,d,f,h,m,g,b,x,y,w,C,N,S,j,_,k,T;const n=()=>{Qt(this,Pl,Ju).call(this,{type:"continue"})},r={client:ve(this,Tv),meta:this.options.meta,mutationKey:this.options.mutationKey};yt(this,Eh,fY({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(I,E)=>{Qt(this,Pl,Ju).call(this,{type:"failed",failureCount:I,error:E})},onPause:()=>{Qt(this,Pl,Ju).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ve(this,qs).canRun(this)}));const o=this.state.status==="pending",s=!ve(this,Eh).canStart();try{if(o)n();else{Qt(this,Pl,Ju).call(this,{type:"pending",variables:t,isPaused:s}),await((a=(i=ve(this,qs).config).onMutate)==null?void 0:a.call(i,t,this,r));const E=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));E!==this.state.context&&Qt(this,Pl,Ju).call(this,{type:"pending",context:E,variables:t,isPaused:s})}const I=await ve(this,Eh).start();return await((f=(d=ve(this,qs).config).onSuccess)==null?void 0:f.call(d,I,t,this.state.context,this,r)),await((m=(h=this.options).onSuccess)==null?void 0:m.call(h,I,t,this.state.context,r)),await((b=(g=ve(this,qs).config).onSettled)==null?void 0:b.call(g,I,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,I,null,t,this.state.context,r)),Qt(this,Pl,Ju).call(this,{type:"success",data:I}),I}catch(I){try{throw await((C=(w=ve(this,qs).config).onError)==null?void 0:C.call(w,I,t,this.state.context,this,r)),await((S=(N=this.options).onError)==null?void 0:S.call(N,I,t,this.state.context,r)),await((_=(j=ve(this,qs).config).onSettled)==null?void 0:_.call(j,void 0,I,this.state.variables,this.state.context,this,r)),await((T=(k=this.options).onSettled)==null?void 0:T.call(k,void 0,I,t,this.state.context,r)),I}finally{Qt(this,Pl,Ju).call(this,{type:"error",error:I})}}finally{ve(this,qs).runNext(this)}}},Tv=new WeakMap,Al=new WeakMap,qs=new WeakMap,Eh=new WeakMap,Pl=new WeakSet,Ju=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ur.batch(()=>{ve(this,Al).forEach(r=>{r.onMutationUpdate(t)}),ve(this,qs).notify({mutation:this,type:"updated",action:t})})},ZG);function gY(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Fc,La,Ev,XG,qye=(XG=class extends Em{constructor(t={}){super();At(this,Fc);At(this,La);At(this,Ev);this.config=t,yt(this,Fc,new Set),yt(this,La,new Map),yt(this,Ev,0)}build(t,n,r){const o=new Hye({client:t,mutationCache:this,mutationId:++hC(this,Ev)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){ve(this,Fc).add(t);const n=pC(t);if(typeof n=="string"){const r=ve(this,La).get(n);r?r.push(t):ve(this,La).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(ve(this,Fc).delete(t)){const n=pC(t);if(typeof n=="string"){const r=ve(this,La).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&ve(this,La).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=pC(t);if(typeof n=="string"){const r=ve(this,La).get(n),o=r==null?void 0:r.find(s=>s.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=pC(t);if(typeof n=="string"){const o=(r=ve(this,La).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ur.batch(()=>{ve(this,Fc).forEach(t=>{this.notify({type:"removed",mutation:t})}),ve(this,Fc).clear(),ve(this,La).clear()})}getAll(){return Array.from(ve(this,Fc))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>uB(n,r))}findAll(t={}){return this.getAll().filter(n=>uB(t,n))}notify(t){Ur.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ur.batch(()=>Promise.all(t.map(n=>n.continue().catch(gs))))}},Fc=new WeakMap,La=new WeakMap,Ev=new WeakMap,XG);function pC(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Oc,ud,fi,Lc,hu,d1,rR,QG,Uye=(QG=class extends Em{constructor(n,r){super();At(this,hu);At(this,Oc);At(this,ud);At(this,fi);At(this,Lc);yt(this,Oc,n),this.setOptions(r),this.bindMethods(),Qt(this,hu,d1).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=ve(this,Oc).defaultMutationOptions(n),h0(this.options,r)||ve(this,Oc).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ve(this,fi),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Xh(r.mutationKey)!==Xh(this.options.mutationKey)?this.reset():((o=ve(this,fi))==null?void 0:o.state.status)==="pending"&&ve(this,fi).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=ve(this,fi))==null||n.removeObserver(this)}onMutationUpdate(n){Qt(this,hu,d1).call(this),Qt(this,hu,rR).call(this,n)}getCurrentResult(){return ve(this,ud)}reset(){var n;(n=ve(this,fi))==null||n.removeObserver(this),yt(this,fi,void 0),Qt(this,hu,d1).call(this),Qt(this,hu,rR).call(this)}mutate(n,r){var o;return yt(this,Lc,r),(o=ve(this,fi))==null||o.removeObserver(this),yt(this,fi,ve(this,Oc).getMutationCache().build(ve(this,Oc),this.options)),ve(this,fi).addObserver(this),ve(this,fi).execute(n)}},Oc=new WeakMap,ud=new WeakMap,fi=new WeakMap,Lc=new WeakMap,hu=new WeakSet,d1=function(){var r;const n=((r=ve(this,fi))==null?void 0:r.state)??gY();yt(this,ud,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},rR=function(n){Ur.batch(()=>{var r,o,s,i,a,c,u,d;if(ve(this,Lc)&&this.hasListeners()){const f=ve(this,ud).variables,h=ve(this,ud).context,m={client:ve(this,Oc),meta:this.options.meta,mutationKey:this.options.mutationKey};(n==null?void 0:n.type)==="success"?((o=(r=ve(this,Lc)).onSuccess)==null||o.call(r,n.data,f,h,m),(i=(s=ve(this,Lc)).onSettled)==null||i.call(s,n.data,null,f,h,m)):(n==null?void 0:n.type)==="error"&&((c=(a=ve(this,Lc)).onError)==null||c.call(a,n.error,f,h,m),(d=(u=ve(this,Lc)).onSettled)==null||d.call(u,void 0,n.error,f,h,m))}this.listeners.forEach(f=>{f(ve(this,ud))})})},QG);function yB(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function Wye(e,t,n){const r=e.slice(0);return r[t]=n,r}var Dh,Mi,wg,Cg,oa,dd,Dv,Mv,Rv,cs,oR,sR,iR,aR,lR,JG,Kye=(JG=class extends Em{constructor(t,n,r){super();At(this,cs);At(this,Dh);At(this,Mi);At(this,wg);At(this,Cg);At(this,oa);At(this,dd);At(this,Dv);At(this,Mv);At(this,Rv,[]);yt(this,Dh,t),yt(this,Cg,r),yt(this,wg,[]),yt(this,oa,[]),yt(this,Mi,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&ve(this,oa).forEach(t=>{t.subscribe(n=>{Qt(this,cs,aR).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,ve(this,oa).forEach(t=>{t.destroy()})}setQueries(t,n){if(yt(this,wg,t),yt(this,Cg,n),process.env.NODE_ENV!=="production"){const r=t.map(o=>ve(this,Dh).defaultQueryOptions(o).queryHash);new Set(r).size!==r.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}Ur.batch(()=>{const r=ve(this,oa),o=Qt(this,cs,iR).call(this,ve(this,wg));yt(this,Rv,o),o.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const s=o.map(f=>f.observer),i=s.map(f=>f.getCurrentResult()),a=r.length!==s.length,c=s.some((f,h)=>f!==r[h]),u=a||c,d=u?!0:i.some((f,h)=>{const m=ve(this,Mi)[h];return!m||!h0(f,m)});!u&&!d||(u&&yt(this,oa,s),yt(this,Mi,i),this.hasListeners()&&(u&&(yB(r,s).forEach(f=>{f.destroy()}),yB(s,r).forEach(f=>{f.subscribe(h=>{Qt(this,cs,aR).call(this,f,h)})})),Qt(this,cs,lR).call(this)))})}getCurrentResult(){return ve(this,Mi)}getQueries(){return ve(this,oa).map(t=>t.getCurrentQuery())}getObservers(){return ve(this,oa)}getOptimisticResult(t,n){const r=Qt(this,cs,iR).call(this,t),o=r.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions));return[o,s=>Qt(this,cs,sR).call(this,s??o,n),()=>Qt(this,cs,oR).call(this,o,r)]}},Dh=new WeakMap,Mi=new WeakMap,wg=new WeakMap,Cg=new WeakMap,oa=new WeakMap,dd=new WeakMap,Dv=new WeakMap,Mv=new WeakMap,Rv=new WeakMap,cs=new WeakSet,oR=function(t,n){return n.map((r,o)=>{const s=t[o];return r.defaultedQueryOptions.notifyOnChangeProps?s:r.observer.trackResult(s,i=>{n.forEach(a=>{a.observer.trackProp(i)})})})},sR=function(t,n){return n?((!ve(this,dd)||ve(this,Mi)!==ve(this,Mv)||n!==ve(this,Dv))&&(yt(this,Dv,n),yt(this,Mv,ve(this,Mi)),yt(this,dd,aN(ve(this,dd),n(t)))),ve(this,dd)):t},iR=function(t){const n=new Map;ve(this,oa).forEach(o=>{const s=o.options.queryHash;if(!s)return;const i=n.get(s);i?i.push(o):n.set(s,[o])});const r=[];return t.forEach(o=>{var c;const s=ve(this,Dh).defaultQueryOptions(o),a=((c=n.get(s.queryHash))==null?void 0:c.shift())??new aO(ve(this,Dh),s);r.push({defaultedQueryOptions:s,observer:a})}),r},aR=function(t,n){const r=ve(this,oa).indexOf(t);r!==-1&&(yt(this,Mi,Wye(ve(this,Mi),r,n)),Qt(this,cs,lR).call(this))},lR=function(){var t;if(this.hasListeners()){const n=ve(this,dd),r=Qt(this,cs,oR).call(this,ve(this,Mi),ve(this,Rv)),o=Qt(this,cs,sR).call(this,r,(t=ve(this,Cg))==null?void 0:t.combine);n!==o&&Ur.batch(()=>{this.listeners.forEach(s=>{s(ve(this,Mi))})})}},JG),Fl,eY,bY=(eY=class extends Em{constructor(t={}){super();At(this,Fl);this.config=t,yt(this,Fl,new Map)}build(t,n,r){const o=n.queryKey,s=n.queryHash??sO(o,n);let i=this.get(s);return i||(i=new $ye({client:t,queryKey:o,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){ve(this,Fl).has(t.queryHash)||(ve(this,Fl).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=ve(this,Fl).get(t.queryHash);n&&(t.destroy(),n===t&&ve(this,Fl).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ur.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ve(this,Fl).get(t)}getAll(){return[...ve(this,Fl).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>cB(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>cB(t,r)):n}notify(t){Ur.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ur.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ur.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Fl=new WeakMap,eY),Zr,fd,hd,Sg,Ng,md,jg,kg,tY,Gye=(tY=class{constructor(e={}){At(this,Zr);At(this,fd);At(this,hd);At(this,Sg);At(this,Ng);At(this,md);At(this,jg);At(this,kg);yt(this,Zr,e.queryCache||new bY),yt(this,fd,e.mutationCache||new qye),yt(this,hd,e.defaultOptions||{}),yt(this,Sg,new Map),yt(this,Ng,new Map),yt(this,md,0)}mount(){hC(this,md)._++,ve(this,md)===1&&(yt(this,jg,iO.subscribe(async e=>{e&&(await this.resumePausedMutations(),ve(this,Zr).onFocus())})),yt(this,kg,cN.subscribe(async e=>{e&&(await this.resumePausedMutations(),ve(this,Zr).onOnline())})))}unmount(){var e,t;hC(this,md)._--,ve(this,md)===0&&((e=ve(this,jg))==null||e.call(this),yt(this,jg,void 0),(t=ve(this,kg))==null||t.call(this),yt(this,kg,void 0))}isFetching(e){return ve(this,Zr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ve(this,fd).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=ve(this,Zr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=ve(this,Zr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(_d(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return ve(this,Zr).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=ve(this,Zr).get(r.queryHash),s=o==null?void 0:o.state.data,i=Tye(t,s);if(i!==void 0)return ve(this,Zr).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Ur.batch(()=>ve(this,Zr).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=ve(this,Zr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=ve(this,Zr);Ur.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=ve(this,Zr);return Ur.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ur.batch(()=>ve(this,Zr).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(gs).catch(gs)}invalidateQueries(e,t={}){return Ur.batch(()=>(ve(this,Zr).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ur.batch(()=>ve(this,Zr).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let s=o.fetch(void 0,n);return n.throwOnError||(s=s.catch(gs)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(gs)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=ve(this,Zr).build(this,t);return n.isStaleByTime(_d(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(gs).catch(gs)}fetchInfiniteQuery(e){return e.behavior=bB(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(gs).catch(gs)}ensureInfiniteQueryData(e){return e.behavior=bB(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return cN.isOnline()?ve(this,fd).resumePausedMutations():Promise.resolve()}getQueryCache(){return ve(this,Zr)}getMutationCache(){return ve(this,fd)}getDefaultOptions(){return ve(this,hd)}setDefaultOptions(e){yt(this,hd,e)}setQueryDefaults(e,t){ve(this,Sg).set(Xh(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ve(this,Sg).values()],n={};return t.forEach(r=>{f0(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){ve(this,Ng).set(Xh(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ve(this,Ng).values()],n={};return t.forEach(r=>{f0(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...ve(this,hd).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=sO(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===lN&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ve(this,hd).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ve(this,Zr).clear(),ve(this,fd).clear()}},Zr=new WeakMap,fd=new WeakMap,hd=new WeakMap,Sg=new WeakMap,Ng=new WeakMap,md=new WeakMap,jg=new WeakMap,kg=new WeakMap,tY),cO=te.createContext(void 0),Wr=e=>{const t=te.useContext(cO);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Yye=({client:e,children:t})=>(te.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(cO.Provider,{value:e,children:t})),xY=te.createContext(!1),yY=()=>te.useContext(xY);xY.Provider;function Zye(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Xye=te.createContext(Zye()),vY=()=>te.useContext(Xye),wY=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},CY=e=>{te.useEffect(()=>{e.clearReset()},[e])},SY=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||uY(n,[e.error,r])),NY=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>n(r(...o)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},jY=(e,t)=>e.isLoading&&e.isFetching&&!t,cR=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,uN=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ib({queries:e,...t},n){const r=Wr(),o=yY(),s=vY(),i=te.useMemo(()=>e.map(b=>{const x=r.defaultQueryOptions(b);return x._optimisticResults=o?"isRestoring":"optimistic",x}),[e,r,o]);i.forEach(b=>{NY(b),wY(b,s)}),CY(s);const[a]=te.useState(()=>new Kye(r,i,t)),[c,u,d]=a.getOptimisticResult(i,t.combine),f=!o&&t.subscribed!==!1;te.useSyncExternalStore(te.useCallback(b=>f?a.subscribe(Ur.batchCalls(b)):gs,[a,f]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),te.useEffect(()=>{a.setQueries(i,t)},[i,t,a]);const m=c.some((b,x)=>cR(i[x],b))?c.flatMap((b,x)=>{const y=i[x];if(y){const w=new aO(r,y);if(cR(y,b))return uN(y,w,s);jY(b,o)&&uN(y,w,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const g=c.find((b,x)=>{const y=i[x];return y&&SY({result:b,errorResetBoundary:s,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(g!=null&&g.error)throw g.error;return u(d())}function Qye(e,t,n){var f,h,m,g,b;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=yY(),o=vY(),s=Wr(),i=s.defaultQueryOptions(e);(h=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,i),process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=r?"isRestoring":"optimistic",NY(i),wY(i,o),CY(o);const a=!s.getQueryCache().get(i.queryHash),[c]=te.useState(()=>new t(s,i)),u=c.getOptimisticResult(i),d=!r&&e.subscribed!==!1;if(te.useSyncExternalStore(te.useCallback(x=>{const y=d?c.subscribe(Ur.batchCalls(x)):gs;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),te.useEffect(()=>{c.setOptions(i)},[i,c]),cR(i,u))throw uN(i,c,o);if(SY({result:u,errorResetBoundary:o,throwOnError:i.throwOnError,query:s.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if((g=(m=s.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||g.call(m,i,u),i.experimental_prefetchInRender&&!Zh&&jY(u,r)){const x=a?uN(i,c,o):(b=s.getQueryCache().get(i.queryHash))==null?void 0:b.promise;x==null||x.catch(gs).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?u:c.trackResult(u)}function Un(e,t){return Qye(e,aO)}function Jye(e,t){const n=Wr(),r=n.getQueryCache();return te.useSyncExternalStore(te.useCallback(o=>r.subscribe(Ur.batchCalls(o)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function ks(e,t){const n=Wr(),[r]=te.useState(()=>new Uye(n,e));te.useEffect(()=>{r.setOptions(e)},[r,e]);const o=te.useSyncExternalStore(te.useCallback(i=>r.subscribe(Ur.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=te.useCallback((i,a)=>{r.mutate(i,a).catch(gs)},[r]);if(o.error&&uY(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}function e0e(){const e=v.useContext(cO);if(e&&e.isSemaphorClient)return e}function kY({children:e}){const{setIsSessionExpired:t}=p.useDashboardActions(),n=e0e(),[r]=v.useState(()=>{const o=new Gye({queryCache:new bY({onError:s=>{s instanceof Error?(console.error(`Something went wrong: ${s.message}`),s.message==="invalid token"&&t(!0)):console.error("Something went wrong:",s)}}),defaultOptions:{queries:{gcTime:36e5,staleTime:3e5,refetchOnWindowFocus:!1,retry:!1}}});return o.isSemaphorClient=!0,o});return n?l.jsx(l.Fragment,{children:e}):l.jsx(Yye,{client:r,children:e})}const t0e={id:"",authToken:void 0,tokenProps:{}},Av=v.createContext(t0e),uO=({children:e,dashboardProps:t})=>{const n=v.useMemo(()=>{let r={};const o=t.authToken;return o&&(r=je.jwtDecode(o.accessToken)),{...t,tokenProps:r}},[t]);return l.jsx(kY,{children:l.jsx(Av.Provider,{value:n,children:e})})};function It(){const e=v.useContext(Av);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}const _s=p.create()(p.immer(e=>({initialDashboard:null,selectedDashboard:null,selectedVisual:null,lastSelectedDashboard:null,lastSelectedVisual:null,showHub:!1,actions:{setInitialDashboard:t=>{e(n=>{n.initialDashboard=t})},selectDashboard:t=>{e(n=>{var r;((r=n.selectedDashboard)==null?void 0:r.id)!==t.id&&(n.lastSelectedDashboard=n.selectedDashboard,n.selectedDashboard=t),n.showHub=!1})},updateSelectedDashboard:t=>{e(n=>{n.selectedDashboard=t})},selectVisual:t=>{e(n=>{n.lastSelectedVisual=n.selectedVisual,n.selectedVisual=t})},clearSelectedDashboard:()=>{e(t=>{t.lastSelectedDashboard=t.selectedDashboard,t.selectedDashboard=null,t.showHub=!0})},clearSelectedVisual:()=>{e(t=>{t.lastSelectedVisual=t.selectedVisual,t.selectedVisual=null})},setShowHub:t=>{e(n=>{n.showHub=t})}}}))),n0e=()=>_s(e=>e.selectedVisual),Dm=()=>_s(e=>e.actions);function Pv(){const{authToken:e,version:t,tokenProps:n,id:r}=It(),o=_s(g=>g.selectedDashboard),s=_s(g=>g.showHub),i=p.useDashboardStore(g=>g.selectedLensId),a=r0e({showHub:s,selectedDashboardId:o==null?void 0:o.id,dashboardId:r,tokenDashboardId:n==null?void 0:n.dashboard_id});function c(){return!(!(e!=null&&e.accessToken)||!a)}const{data:u,isLoading:d,isFetching:f,isError:h,refetch:m}=Un({queryKey:["dashboard",i,e==null?void 0:e.accessToken,a],queryFn:()=>p.getDashboard(n.apiServiceUrl,e==null?void 0:e.accessToken,{lensId:i,version:t,dashboardId:a}),enabled:c()});return{data:u,isLoading:d,isFetching:f,isError:h,refetch:m,dashboardIdToFetch:a}}function r0e({showHub:e,selectedDashboardId:t,dashboardId:n,tokenDashboardId:r}){return e?null:t||n||r||null}function o0e(){const{authToken:e}=It(),t=p.useDashboardStore(r=>r.authToken),{setAuthToken:n}=p.useDashboardActions();return v.useLayoutEffect(()=>{const r=e==null?void 0:e.accessToken,o=t==null?void 0:t.accessToken;e&&r!==o&&n(e)},[e,t,n]),e}function _Y(e){const t=v.useCallback(s=>`semaphor-default-sheet-${s}`,[]),n=v.useCallback(()=>{if(!e)return null;try{const s=t(e);return localStorage.getItem(s)}catch(s){return console.error("Error reading default sheet preference:",s),null}},[e,t]),r=v.useCallback(s=>{if(!(!e||!s))try{const i=t(e);localStorage.setItem(i,s)}catch(i){console.error("Error saving default sheet preference:",i)}},[e,t]),o=v.useCallback(()=>{if(e)try{const s=t(e);localStorage.removeItem(s)}catch(s){console.error("Error clearing default sheet preference:",s)}},[e,t]);return{getDefaultSheetId:n,setDefaultSheetId:r,clearDefaultSheetId:o}}const vB=/\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g,wB=/\bparam\s*\(\s*(['"])([^'"]+)\1/g;function s0e(e){const t=[];let n=0;for(;n<e.length;){const r=e.indexOf("{{",n),o=e.indexOf("{%",n);let s=-1,i="";if(r===-1?(s=o,i="%}"):o===-1||r<o?(s=r,i="}}"):(s=o,i="%}"),s===-1)break;const a=e.indexOf(i,s+2);if(a===-1){n=s+2;continue}t.push(e.slice(s+2,a)),n=a+2}return t}function dO(e){var r,o;if(!e)return[];const t=new Set;let n;for(vB.lastIndex=0;(n=vB.exec(e))!==null;){const s=(r=n[1])==null?void 0:r.trim();s&&t.add(s)}for(const s of s0e(e))for(wB.lastIndex=0;(n=wB.exec(s))!==null;){const i=(o=n[2])==null?void 0:o.trim();i&&t.add(i)}return Array.from(t)}function Ek(e){const t=new Set,n=new Map;for(const r of e.controlBindings||[])t.add(r.controlId),r.target==="sql_param"&&n.set(r.paramId,r.controlId);for(const r of dO(e.sql))t.add(n.get(r)??r);return Array.from(t)}function IY(e){const t=new Map,n=new Map;for(const r of e.controlBindings||[])r.target==="sql_param"&&n.set(r.paramId,r.controlId);for(const r of dO(e.sql))t.set(r,{paramId:r,controlId:n.get(r)??r});return Array.from(t.values())}const i0e=["kpi","table","detailTable","aggregateTable","pivotTable","bar","horizontalBar","stackedBar","line","stackedLine","area","stackedArea","combo","pie","doughnut","polarArea","radar","scatter","bubble","tornado","pyramid","range","funnel","bullet","heatmap","treemap","map","matrixTable"],a0e=new Set(i0e),l0e=["table","detailTable","aggregateTable","pivotTable","matrixTable"],c0e=new Set(l0e);function TY(e){return typeof e=="string"&&c0e.has(e)}function Fv(e){return typeof e=="string"&&a0e.has(e)}function dN(e){return(e==null?void 0:e.type)==="number"||(e==null?void 0:e.type)==="currency"}function EY(e){var n,r;const t=(r=(n=e.preferences)==null?void 0:n.formatNumber)==null?void 0:r.enabled;return t===!1||t==="false"}function DY(e){return(e==null?void 0:e.type)==="number"}function u0e(e){var n;if(!DY(e))return!1;const t=(n=e==null?void 0:e.numberFormat)==null?void 0:n.style;return t===void 0||t==="decimal"||t==="currency"}function Dk(e,t){const n=t==null?void 0:t.type;if(n&&n!=="none"&&n!=="number")return{currencyBindable:!1};const r=n==="number"?t!=null&&t.numberFormat?p.fromColumnNumberFormat(t.numberFormat,{preserveOmittedProperties:!0}):{type:"number"}:void 0,o=p.fromSemanticFormat(e.format,{preserveOmittedProperties:!0}),s=va.normalizeAnalyticsCatalogDataType(e.dataType)==="number"?{type:"number"}:void 0,a=(t==null?void 0:t.inheritMetricFormat)===!1||!!(t!=null&&t.numberFormat)&&(t==null?void 0:t.inheritMetricFormat)!==!0?r:o||s||r;return{authoredFormat:a,currencyBindable:dN(a)}}function fO(e,t){var c,u;const n=p.fromSemanticFormat(t.format,{preserveOmittedProperties:!0}),r=p.fromNumberAxisFormat((c=e.preferences)==null?void 0:c.numberAxisFormat),o=EY(e)?void 0:p.fromLegacyFormatNumber((u=e.preferences)==null?void 0:u.formatNumber),s=va.normalizeAnalyticsCatalogDataType(t.dataType)==="number"?{type:"number"}:void 0,i=n||r||o||s;return{authoredFormat:i,source:n?"semantic":r?"number_axis":o?"legacy":s?"inferred":void 0,currencyBindable:dN(i)}}function m0(e,t={}){var h,m,g,b,x,y;const n=t.metricIndex??0,r=!!((h=e.sql)!=null&&h.trim()),o=p.fromPersistedKpiFormatOptions((g=(m=e.preferences)==null?void 0:m.kpiVisualOptions)==null?void 0:g.formatOptions),s=n===0?p.fromLegacyFormatNumber((b=e.preferences)==null?void 0:b.formatNumber):void 0,i=EY(e);if(r){const w=t.resultColumnKey?{kind:"column",columnKey:t.resultColumnKey}:void 0;return{target:w,authoredFormat:o||s,currencyBindable:!i&&!!w&&dN(o)}}const a=(y=(x=e.config)==null?void 0:x.metricColumns)==null?void 0:y[n],c=a!=null&&a.id?{kind:"metric",metricId:a.id}:void 0,u=p.fromSemanticFormat(a==null?void 0:a.format,{preserveOmittedProperties:!0}),d=va.normalizeAnalyticsCatalogDataType(a==null?void 0:a.dataType)==="number"?{type:"number"}:void 0,f=o||u||s||d;return{target:c,authoredFormat:f,currencyBindable:!i&&Fv(e.type)&&!!c&&dN(f)}}function hO(){const e=new Set;return(t,n,r)=>{const o=t.id||t.alias||t.name||`field_${n+1}`,s=[o];r.kind==="axis"&&r.grain&&s.push(`${o}-${r.grain}`),r.kind==="value"&&s.push(`${o}-${r.aggregate.toLowerCase()}`),s.push(`${o}-${n+1}`);for(const c of s)if(!e.has(c))return e.add(c),c;let i=n+1,a=`${o}-${i}`;for(;e.has(a);)i+=1,a=`${o}-${i}`;return e.add(a),a}}function MY(e){return e==="COUNT"||e==="SUM"||e==="AVG"||e==="MIN"||e==="MAX"||e==="MEDIAN"||e==="DISTINCT"?e:"SUM"}function CB(e){return`measure:${e}`}function Mk(e){var o,s,i,a,c,u,d;const t=(o=e.config)==null?void 0:o.metricColumns;if(Array.isArray(t)){const f=hO();return t.map((h,m)=>{const g=f(h,m,{kind:"value",aggregate:MY(h.aggregate)});return{measureId:CB(g),format:h.format,metric:h}})}const n=((i=(s=e.config)==null?void 0:s.matrixIntent)==null?void 0:i.values)||((a=e.config)==null?void 0:a.values)||[],r=((u=(c=e.config)==null?void 0:c.matrixIntent)==null?void 0:u.source)||((d=e.config)==null?void 0:d.source);return n.map((f,h)=>{const m=d0e(f.field,f.aggregate,r),g=f.id||`${m}-${h}`;return{measureId:CB(g),format:f.format,value:f}})}function d0e(e,t,n){const r=e.source||n;return[r==null?void 0:r.kind,(r==null?void 0:r.kind)==="semantic"?r.domainId:void 0,(r==null?void 0:r.kind)==="semantic"?r.datasetId:void 0,(r==null?void 0:r.kind)==="semantic"?r.datasetName:void 0,(r==null?void 0:r.kind)==="physical"?r.connectionId:void 0,(r==null?void 0:r.kind)==="physical"?r.databaseName:void 0,(r==null?void 0:r.kind)==="physical"?r.schemaName:void 0,(r==null?void 0:r.kind)==="physical"?r.tableName:void 0,e.name,e.role,t].filter(Boolean).join(":")}function RY(e){const t=new Map;if(!e.result||!e.presentation.preferences)return t;const n=new Map((e.card?Mk(e.card):[]).map(r=>[r.measureId,r]));for(const[r,o]of Object.entries(e.result.measuresById)){const s=n.get(r),i=mO(s?s.format:o.format);i&&t.set(r,$t.resolveNumericPresentation(i,e.presentation.preferences,e.presentation.resolveBoundCurrency({kind:"matrix_measure",measureId:r})))}return t}function AY(e){const{cell:t}=e;if(t.presence==="missing"||t.presence==="densified")return"—";if(t.presence==="presentNull"||t.value===null||t.value===void 0)return"";const n=f0e(t.value),r=e.formatsByMeasureId.get(t.measureId);return n!==void 0&&r?$t.formatNumericCanonical(n,r):n!==void 0?new Intl.NumberFormat("en-US",{maximumFractionDigits:6}).format(n):String(t.value)}function mO(e){if(typeof e=="object"&&(e==null?void 0:e.type)==="datetime")return;const t=p.fromSemanticFormat(e,{preserveOmittedProperties:!0});if(!t)return{type:"number"};if(Kt.isNumericCanonicalFormat(t))return t}function f0e(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||!e.trim())return;const t=Number(e);return Number.isFinite(t)?t:void 0}function pO(e){var t,n;return e.type==="detailTable"?((t=e.config)==null?void 0:t.detailColumns)||[]:((n=e.config)==null?void 0:n.metricColumns)||[]}function PY(e){return new Set(p.getDashboardCards(e).flatMap(t=>(t.controlBindings||[]).filter(Ov).map(n=>n.controlId)))}function h0e(e,t){const n=[t.id,t.alias,t.label,t.name,t.qualifiedFieldName].filter(s=>!!s);for(const s of n)if(e[s])return e[s];const r=new Set(n.map(s=>s.trim().toLowerCase())),o=Object.entries(e).find(([s])=>r.has(s.trim().toLowerCase()));return o==null?void 0:o[1]}function SB(e){return[...new Map(e.map(t=>[ba(t),t])).values()]}function m0e(e){if(e.metric)return Dk(e.metric,void 0).currencyBindable;const t=mO(e.format);return(t==null?void 0:t.type)==="number"||(t==null?void 0:t.type)==="currency"}function gO(e,t=[]){var C,N,S;const n=!!((C=e.sql)!=null&&C.trim()),r=Fv(e.type),o=n&&r&&e.type!=="kpi"&&e.type!=="matrixTable",s=pO(e),i=((S=(N=e.preferences)==null?void 0:N.tablePrefs)==null?void 0:S.columnSettingsMap)||{},a=!n&&e.type==="kpi"?s.map((j,_)=>m0(e,{metricIndex:_})):[],c=!n&&e.type==="matrixTable"?Mk(e):[],u=(n?[]:s).map(j=>({kind:"metric",metricId:j.id})),d=c.map(j=>({kind:"matrix_measure",measureId:j.measureId})),f=c.filter(m0e).map(j=>({kind:"matrix_measure",measureId:j.measureId})),h=e.type==="matrixTable"?[]:e.type==="kpi"?a.filter(j=>j.currencyBindable).flatMap(j=>j.target?[j.target]:[]):(n||!r?[]:s).filter(j=>(TY(e.type)?Dk(j,h0e(i,j)):fO(e,j)).currencyBindable).map(j=>({kind:"metric",metricId:j.id})),m=[...new Set(t)],g=(o?m:[]).map(j=>({kind:"column",columnKey:j})),b=(o?m:[]).filter(j=>u0e(i[j])).map(j=>({kind:"column",columnKey:j})),x=(n&&e.type==="kpi"?m.slice(0,1):[]).map(j=>({kind:"column",columnKey:j})),y=n&&e.type==="kpi"?m0(e,{resultColumnKey:m[0]}):void 0,w=r&&(y!=null&&y.currencyBindable)?x:[];return{knownTargets:SB([...e.type==="matrixTable"?d:u,...g,...x]),eligibleTargets:SB([...h,...f,...b,...w])}}function FY(e,t){const n=m0(e,{resultColumnKey:t});return n.currencyBindable?n.target:void 0}function ec(e){var t;return(t=e.card.sql)!=null&&t.trim()?{kind:"column",columnKey:e.columnKey}:e.metricId?{kind:"metric",metricId:e.metricId}:void 0}function ba(e){return e.kind==="metric"?`metric:${e.metricId}`:e.kind==="column"?`column:${e.columnKey}`:`matrix_measure:${e.measureId}`}function p0e(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e;if(t.kind==="metric"&&typeof t.metricId=="string"&&t.metricId.trim())return{kind:"metric",metricId:t.metricId};if(t.kind==="column"&&typeof t.columnKey=="string"&&t.columnKey.trim())return{kind:"column",columnKey:t.columnKey};if(t.kind==="matrix_measure"&&typeof t.measureId=="string"&&t.measureId.trim())return{kind:"matrix_measure",measureId:t.measureId}}function Ov(e){return e.target==="presentation_currency"}function g0e(e){return e.target!=="sql_param"&&e.target!=="presentation_currency"}function NB(e){const t=Li.canonicalizeSupportedCurrencyCode(e);return typeof e=="string"&&e===t?t:void 0}function OY(e){if(e.type!=="enum"||e.source.kind!=="manual")return{diagnostic:"invalid_control_type"};const t=e.source.options.map(n=>NB(n.value));if(t.length===0||t.some(n=>!n))return{diagnostic:"invalid_currency_option"};if(e.requiredAtExecution){const n=e.initialValueStrategy==="saved_default"?NB(e.defaultValue):void 0;if(!n||!t.includes(n))return{diagnostic:"invalid_control_default"}}return{control:e,currencies:t}}function b0e(e){return"control"in OY(e)}function LY(e){const t=PY(e.dashboard);if(t.size===0)return{definitions:e.definitions||[],values:e.values||{}};const n=new Set([...t].filter(r=>!e.referencedControlIds.has(r)));return{definitions:(e.definitions||[]).filter(r=>!n.has(r.id)),values:Object.fromEntries(Object.entries(e.values||{}).filter(([r])=>!n.has(r)))}}function $Y(e){return LY({...e,referencedControlIds:new Set(Ek({sql:e.filterSql,controlBindings:[]}))})}function x0e(e){var t;return LY({...e,referencedControlIds:new Set(Ek({sql:(t=e.source)==null?void 0:t.sql,controlBindings:[]}))})}function zY(e){return{knownKeys:new Set(e.knownTargets.map(ba)),eligibleKeys:new Set(e.eligibleTargets.map(ba)),controlsById:new Map((e.controls||[]).map(t=>[t.id,t]))}}function BY(e,t){if(!e||typeof e!="object"||e.target!=="presentation_currency")return{};const n=e,r=typeof n.controlId=="string"&&n.controlId.trim()?n.controlId:void 0;if(!r)return{diagnostic:{code:"invalid_binding_shape"}};const o=p0e(n.presentationTarget);if(!o)return{diagnostic:{code:"missing_target",controlId:r}};const s=ba(o);if(!t.knownKeys.has(s))return{diagnostic:{code:"stale_target",controlId:r}};if(!t.eligibleKeys.has(s))return{diagnostic:{code:"inapplicable_target",controlId:r}};const i=t.controlsById.get(r);if(!i)return{diagnostic:{code:"missing_control",controlId:r}};const a=OY(i);return"diagnostic"in a?{diagnostic:{code:a.diagnostic,controlId:r}}:{binding:{controlId:r,presentationTarget:o,control:a.control,currencies:a.currencies}}}function y0e(e){const t=zY(e);return(e.bindings||[]).flatMap(n=>{const r=BY(n,t);return"diagnostic"in r?[r.diagnostic]:[]})}function VY(e){var o;const t=[],n=ba(e.target),r=zY(e);for(const s of e.bindings||[]){const i=BY(s,r);if("diagnostic"in i){t.push(i.diagnostic);continue}const a=i.binding;if(!a||ba(a.presentationTarget)!==n)continue;const u=Li.canonicalizeSupportedCurrencyCode((o=e.values)==null?void 0:o[a.control.id]);if(!(!u||!a.currencies.includes(u)))return{currency:u,diagnostics:t}}return{diagnostics:t}}function v0e(e,t){if(!e||typeof e!="object"||!("kind"in e))return e;switch(e.kind){case"manual":return{kind:"manual",...t!=null&&t.includePresentation?{options:e.options.map(n=>({value:n.value,label:n.label,presentation:n.presentation}))}:{optionValues:e.options.map(n=>n.value).sort()}};case"dataset_values":return{kind:"dataset_values",fieldId:e.fieldId,connectionId:e.connectionId||""};case"field_allowlist":return{kind:"field_allowlist",fieldIds:[...e.fieldIds].sort()};case"metric_allowlist":return{kind:"metric_allowlist",metricIds:[...e.metricIds].sort()};case"sql_query":return{kind:"sql_query",connectionId:e.connectionId,sql:e.sql,valueColumn:e.valueColumn,labelColumn:e.labelColumn};default:return e}}function w0e(e,t){return{id:e.id,scope:e.scope,type:e.type,source:v0e(e.source,t),initialValueStrategy:e.initialValueStrategy,defaultValue:e.defaultValue,requiredAtExecution:e.requiredAtExecution,...t!=null&&t.includePresentation?{label:e.label,helpText:e.helpText,hidden:e.hidden,locked:e.locked,placement:e.placement,showLabel:e.showLabel,toolbarWidth:e.toolbarWidth}:{}}}function C0e(e,t){return e.target==="sql_param"||e.target==="presentation_currency"?e:e.target==="config_field_selector"&&!(t!=null&&t.includePresentation)?{...e,mapping:Object.fromEntries(Object.entries(e.mapping).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>{const o={...r};return delete o.format,delete o.dateFormat,delete o.customFormat,delete o.semanticTemporalPresentation,[n,o]}))}:{...e,mapping:Object.fromEntries(Object.entries(e.mapping).sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>[n,r&&typeof r=="object"&&!Array.isArray(r)?Object.fromEntries(Object.entries(r).sort(([o],[s])=>o.localeCompare(s))):r]))}}function jB(e=[],t){return[...e].map(n=>w0e(n,t)).sort((n,r)=>n.id.localeCompare(r.id)||n.scope.localeCompare(r.scope)||n.type.localeCompare(r.type))}function S0e(e=[],t){return e.filter(n=>(t==null?void 0:t.includePresentation)||!Ov(n)).map(n=>C0e(n,t)).sort((n,r)=>Ho.stableSerialize(n).localeCompare(Ho.stableSerialize(r)))}function uR(e,t){return e?Ho.stableSerialize({controlDefinitions:jB(e.controlDefinitions,t),cardControlDefinitions:jB(e.cardControlDefinitions,t),controlBindings:S0e(e.controlBindings,t)}):"__none__"}function VT(e,t){return e&&t.has(e)?e:null}function N0e({selectedSheetId:e,preservedSelectedSheetId:t,defaultSheetId:n,sheets:r}){var s;const o=new Set((r||[]).map(i=>i.id).filter(i=>typeof i=="string"));return VT(e,o)||VT(t,o)||VT(n,o)||((s=r==null?void 0:r[0])==null?void 0:s.id)||null}function HY(e){const t=e.trim().split(/[^A-Za-z0-9]+/).filter(Boolean).map(r=>r.toLowerCase());if(!t.length)return"input";const n=t.map((r,o)=>o===0?r:_B(r)).join("");return/^[A-Za-z]/.test(n)?n:`input${_B(n)}`}function bO(e,t){const n=HY(e);return qY(n,t)}function Lv(e){const n=e.trim().replace(/^\{\{\s*/,"").replace(/\s*\}\}$/,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"");return n?/^[A-Za-z]/.test(n)?n:`input_${n}`:"input"}function Od(e,t){return qY(Lv(e),t)}function qY(e,t){const n=new Set(t.map(o=>o.variableName).filter(o=>!!o));if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r+=1;return`${e}${r}`}function xO(e){return p.getDataType(e.dataType)==="date"?["label","start","end","range"]:["label","value"]}function yO(e){return k0e(e)?["label","value"]:["value"]}function kB(e){return e.kind==="filter"?`filter:${e.filter.id}`:`control:${e.control.id}`}function j0e(e){return{placement:e.hide||e.displayMode==="canvas"?"hidden":"toolbar",...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function UY(e){return{placement:e.hidden?"hidden":e.placement||(e.scope==="card"?"card_header":"toolbar"),...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function fN(e){return!!e.compatibility}function k0e(e){return e.type==="enum"||e.type==="multi_enum"||e.type==="field_selector"||e.type==="metric_selector"||e.type==="aggregation_selector"||e.type==="grain_selector"}function _B(e){return e&&e[0].toUpperCase()+e.slice(1)}function _0e(e){var i,a;const t=[...e.inputs||[]],n=new Set(t.map(c=>c.id)),r=new Set((e.sheets||[]).filter(c=>c.kind==="document").map(c=>c.id));let o=!1;for(const c of e.sheets||[])if(!(c.kind!=="document"||!((a=(i=c.document)==null?void 0:i.inputs)!=null&&a.length)))for(const u of c.document.inputs)n.has(u.id)||(t.push(I0e(u,c.id)),n.add(u.id),o=!0);const s=t.map(c=>{if(c.kind==="filter"&&IB(c,r)&&c.filter.variableName!==c.variableName)return o=!0,{...c,filter:{...c.filter,variableName:c.variableName}};if(c.kind!=="control"||!IB(c,r))return c;const u=Od(c.control.id||c.variableName,t.filter(d=>d.id!==c.id));return c.variableName===u&&c.control.id===u?c:(o=!0,{...c,variableName:u,control:{...c.control,id:u}})});return o?{...e,inputs:s}:e}function I0e(e,t){const n={id:e.id,label:e.label,variableName:e.variableName,description:e.description,requiredAtExecution:e.requiredAtExecution,scope:{kind:"sheets",sheetIds:[t]},runtimeScope:"perSheet",presentation:{placement:"toolbar"},exports:e.exports,compatibility:{source:"documentInput",sheetId:t,inputId:e.id}};return e.kind==="filter"?{...n,kind:"filter",filter:e.filter}:{...n,kind:"control",control:e.control}}function IB(e,t){var n;switch(e.scope.kind){case"allSheets":return!((n=e.scope.sheetKinds)!=null&&n.length)||e.scope.sheetKinds.includes("document");case"sheets":return e.scope.sheetIds.some(r=>t.has(r));case"documentSections":return t.has(e.scope.sheetId);default:return!1}}function T0e(e,t={}){if(!e)return[];const n=[],r=[...t.existingInputs||[]];for(const o of e.inlineFilters||[]){const s=o.title||o.column||o.id,i=E0e(o),a={id:Oi.getCardInlineFilterCompatInputId(e.id,o.id),kind:"filter",label:s,variableName:o.variableName?Od(o.variableName,r):bO(s,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:{placement:"card_header"},filter:i,exports:xO(i),compatibility:{source:"cardInlineFilter",cardId:e.id,filterId:o.id}};r.push(a),n.push(a)}for(const o of e.controls||[]){const s=o.label||o.id,i={id:Oi.getCardControlCompatInputId(e.id,o.id),kind:"control",label:s,variableName:Od(o.id,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:UY(o),control:o,exports:yO(o),requiredAtExecution:o.requiredAtExecution,compatibility:{source:"cardControl",cardId:e.id,controlId:o.id}};r.push(i),n.push(i)}return n}function E0e(e){return{kind:"field",id:e.id,variableName:e.variableName,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel,toolbarWidth:e.width,displayMode:"toolbar"}}function D0e(e,t={}){const n=[],r=[...t.existingInputs||[]];for(const o of e.controls||[]){const s=o.label||o.id,i={id:Oi.getDashboardControlCompatInputId(o.id),kind:"control",label:s,variableName:Od(o.id,r),scope:{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:UY(o),control:o,exports:yO(o),requiredAtExecution:o.requiredAtExecution,compatibility:{source:"dashboardControl",controlId:o.id}};r.push(i),n.push(i)}return n}function M0e(e,t={}){const n=[],r=[...t.existingInputs||[]],o=t.availableSheetIds||(e.sheets||[]).filter(u=>u.kind!=="document").map(u=>u.id),s=p.getDashboardCardEntries({sheets:e.sheets}),i=t.availableCardIds?new Set(t.availableCardIds):void 0,a=s.filter(u=>!i||i.has(u.card.id)),c=t.availableCardIds||a.map(u=>u.card.id);for(const u of e.filters||[]){const d=u.title||u.column||u.id,f={id:Oi.getDashboardFilterCompatInputId(u.id),kind:"filter",label:d,variableName:u.variableName?Od(u.variableName,r):bO(d,r),scope:R0e(u,{availableDashboardSheetIds:o,availableCardEntries:a,availableCardIds:c}),runtimeScope:"shared",presentation:j0e(u),filter:u,exports:xO(u),compatibility:{source:"dashboardFilter",filterId:u.id}};r.push(f),n.push(f)}return n}function R0e(e,t){if(e.applyToCardIds!==void 0){const n=new Set(TB(e,t));return{kind:"cards",cardIds:e.applyToCardIds.filter(r=>n.has(r))}}if(e.excludeCardIds!==void 0){const n=new Set(e.excludeCardIds);return{kind:"cards",cardIds:TB(e,t).filter(o=>!n.has(o))}}if(e.sheetId)return{kind:"sheets",sheetIds:[e.sheetId]};if(e.applyToSheetIds!==void 0)return{kind:"sheets",sheetIds:e.applyToSheetIds};if(e.excludeSheetIds!==void 0){const n=new Set(e.excludeSheetIds);return{kind:"sheets",sheetIds:t.availableDashboardSheetIds.filter(r=>!n.has(r))}}return{kind:"allSheets",sheetKinds:["dashboard"]}}function TB(e,t){return!e.sheetId&&e.applyToSheetIds===void 0&&e.excludeSheetIds===void 0?t.availableCardIds:t.availableCardEntries.filter(n=>A0e(e,n.sheet.id)).map(n=>n.card.id)}function A0e(e,t){return e.sheetId&&e.sheetId!==t?!1:e.applyToSheetIds!==void 0?e.applyToSheetIds.includes(t):e.excludeSheetIds!==void 0?!e.excludeSheetIds.includes(t):!0}function uf({dashboard:e,dashboardInputValues:t}){var r,o;const n=!!(Object.keys((t==null?void 0:t.shared)||{}).length||Object.values((t==null?void 0:t.bySheetId)||{}).some(s=>Object.keys(s).length>0)||Object.values((t==null?void 0:t.byCardId)||{}).some(s=>Object.keys(s).length>0)||Object.values((t==null?void 0:t.byDocumentSectionId)||{}).some(s=>Object.keys(s).length>0));return!!((r=e.inputs)!=null&&r.length||e.defaultInputValues||(o=e.filters)!=null&&o.some(s=>s.kind==="global-date")||n)}function ab({dashboard:e,card:t,availableSheetIds:n,availableCardIds:r}){const o=e.inputs||[],s=[],i=[...o],a=M0e(e,{existingInputs:i,availableSheetIds:n,availableCardIds:r});s.push(...a),i.push(...a);const c=D0e(e,{existingInputs:i});s.push(...c),i.push(...c);const u=T0e(t,{existingInputs:i});return s.push(...u),{authoredInputs:o,compatibilityInputs:s,allInputs:[...o,...s]}}function Yi({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,runtimeValues:s,mode:i="interactive",timezone:a}){var y;const c={sheetId:t,cardId:n==null?void 0:n.id,sectionId:r,sheetKind:o||K0e(e,t)},u=ab({dashboard:e,card:n}),d=Rk(u.allInputs);P0e(d);const f=d.filter(w=>Qh(w,c));W0e(f);const h=f.map(w=>O0e({dashboard:e,input:w,runtimeValues:s,target:c,timezone:a})),m=$0e({resolvedInputs:h,card:n}),g=z0e(h),b=(y=h.find(w=>w.kind==="filter"&&p.isGlobalDateFilter(w.filter)))==null?void 0:y.comparisonSelection,x=h.flatMap((w,C)=>{var j;const N=f[C];if(!N||!p.isComparisonCapableDashboardDateInput(N)||!w.comparisonSelection)return[];const S=((j=w.slot)==null?void 0:j.status)==="set"&&w.slot.value.kind==="filter"?w.slot.value.filterValue:void 0;return[{inputId:w.id,filterId:N.filter.id,label:w.label,filter:N.filter,filterValue:S,selection:w.comparisonSelection}]});return{inputs:f,resolvedInputs:h,...m,...g,...b?{globalDateComparisonSelection:b}:{},dateComparisonInputs:x,missingRequiredInputs:h.filter(w=>w.missingRequiredValue)}}function P0e(e){if(e.filter(n=>n.kind==="filter"&&p.isGlobalDateFilter(n.filter)).length>1)throw new Error("Dashboard input contract allows exactly one Global Date input.")}function Qh(e,t){var n;if(!F0e(e,t))return!1;switch(e.scope.kind){case"allSheets":return(n=e.scope.sheetKinds)!=null&&n.length?t.sheetKind?e.scope.sheetKinds.includes(t.sheetKind):!1:!!t.sheetId||!!t.cardId;case"sheets":return!!t.sheetId&&e.scope.sheetIds.includes(t.sheetId);case"cards":return!!t.cardId&&e.scope.cardIds.includes(t.cardId);case"documentSections":return!!t.sheetId&&!!t.sectionId&&e.scope.sheetId===t.sheetId&&e.scope.sectionIds.includes(t.sectionId);default:return!1}}function F0e(e,t){return t.sheetKind!=="document"||!e.compatibility||e.compatibility.source==="documentInput"?!0:e.compatibility.source==="cardInlineFilter"||e.compatibility.source==="cardControl"?!!t.cardId&&e.compatibility.cardId===t.cardId:!1}function Rk(e){const t=new Set(e.filter(n=>!fN(n)).map(kB));return e.filter(n=>!fN(n)||!t.has(kB(n)))}function O0e(e){var d,f;const t=p.getDashboardInputRuntimeSlot(e.runtimeValues.dashboardInputValues,e.input,e.target),n=p.getDashboardInputRuntimeSlot(e.dashboard.defaultInputValues,e.input,e.target),r=(t==null?void 0:t.comparisonSelection)??(n==null?void 0:n.comparisonSelection),o=p.isComparisonCapableDashboardDateInput(e.input);if(r&&!o)throw new Error(`Dashboard input "${e.input.id}" carries comparison state but is not a supported dashboard date filter.`);const i=fN(e.input)&&((d=e.input.compatibility)==null?void 0:d.source)!=="documentInput"?B0e(e):p.hydrateAuthoredDashboardInputSlot({dashboard:e.dashboard,input:e.input,runtimeValues:e.runtimeValues.dashboardInputValues,target:e.target,timezone:e.timezone}),a=(i==null?void 0:i.status)==="set"&&i.value.kind===e.input.kind?i.value:void 0;if(i!=null&&i.comparisonSelection){if(!o)throw new Error(`Dashboard input "${e.input.id}" carries comparison state but is not a supported dashboard date filter.`);const h=$r.validateGlobalDateComparisonSelection(i.comparisonSelection,`dashboardInputValues.${e.input.id}.comparisonSelection`);if(!h.ok)throw new Error(((f=h.errors[0])==null?void 0:f.message)||"Invalid comparison selection.")}if(e.input.kind==="filter"){const h=(a==null?void 0:a.kind)==="filter"?WY(e.input,a.filterValue):void 0,m=H0e({input:e.input,filterValue:h,timezone:e.timezone});return{id:e.input.id,kind:"filter",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:i,rawValue:h?G0e(h.values):void 0,displayValue:EB(m.label??m.value),exports:m,filter:e.input.filter,filterValue:h,missingRequiredValue:!!e.input.requiredAtExecution&&!h,...o&&(i!=null&&i.comparisonSelection)?{comparisonSelection:i.comparisonSelection}:{}}}const c=(a==null?void 0:a.kind)==="control"?a.value:void 0,u=q0e({input:e.input,value:c});return{id:e.input.id,kind:"control",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:i,rawValue:c,displayValue:EB(u.label??u.value),exports:u,control:e.input.control,controlValue:c,missingRequiredValue:!!e.input.requiredAtExecution&&!L0e(c)}}function L0e(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function $0e({resolvedInputs:e,card:t}){const n=[],r=new Map,o=new Map,s={};for(const c of e){if(c.kind==="filter"){c.filter&&c.filterValue&&n.push(c.filterValue);continue}c.control&&(U0e(c)?o.set(c.control.id,c.control):r.set(c.control.id,c.control),c.controlValue!==void 0&&(s[c.control.id]=c.controlValue))}const i=new Set([...r.keys(),...o.keys()]),a=((t==null?void 0:t.controlBindings)||[]).filter(c=>i.has(c.controlId));return{activeFilters:n,controlDefinitions:Array.from(r.values()),cardControlDefinitions:Array.from(o.values()),controlBindings:a,controlValues:s}}function z0e(e){const t={},n={};for(const r of e)n[r.id]=r,t[r.variableName]=r;return{variablesByName:t,variablesById:n}}function B0e(e){var i,a,c,u;const t=(i=e.input.compatibility)==null?void 0:i.source,n=p.getDashboardInputRuntimeSlot(e.runtimeValues.dashboardInputValues,e.input,e.target),r=p.hydrateAuthoredDashboardInputSlot({dashboard:e.dashboard,input:e.input,runtimeValues:e.runtimeValues.dashboardInputValues,target:e.target,timezone:e.timezone});if((n==null?void 0:n.status)==="set"||(n==null?void 0:n.status)==="cleared")return r;if(e.input.kind==="filter"){const d=e.input.filter.id,f=t==="cardInlineFilter"?e.target.cardId?(c=(a=e.runtimeValues.inlineFilterValuesMap)==null?void 0:a[e.target.cardId])==null?void 0:c.find(m=>m.filterId===d):void 0:(u=e.runtimeValues.filterValues)==null?void 0:u.find(m=>m.filterId===d),h=p.isComparisonCapableDashboardDateInput(e.input)?(r==null?void 0:r.comparisonSelection)??(f?{mode:"off"}:void 0):void 0;if(f){const m=p.createFilterDashboardInputSlot(WY(e.input,f));return(m==null?void 0:m.status)==="set"?{...m,...h?{comparisonSelection:h}:{}}:h?{comparisonSelection:h}:void 0}return h?{comparisonSelection:h}:void 0}const o=e.input.control.id,s=V0e({source:t,target:e.target,runtimeValues:e.runtimeValues});if(s.values&&Object.prototype.hasOwnProperty.call(s.values,o))return p.createControlDashboardInputSlot(s.values[o]);if(!s.isExplicit)return t==="dashboardControl"?p.createControlDashboardInputSlot(p.resolveSavedDefaultValue(e.input.control,e.dashboard.defaultControlValues)):p.getBackingDefaultSlot(e.input,e.timezone)}function V0e({source:e,target:t,runtimeValues:n}){var r;return e==="cardControl"&&t.cardId?{values:(r=n.cardControlValuesMap)==null?void 0:r[t.cardId],isExplicit:!!(n.cardControlValuesMap&&Object.prototype.hasOwnProperty.call(n.cardControlValuesMap,t.cardId))}:{values:n.controlValues,isExplicit:n.controlValues!==void 0}}function WY(e,t){const n=t.filterId===e.filter.id?t:{...t,filterId:e.filter.id};if(p.isCompatibleFilterValue(e.filter,n))return p.normalizeDashboardDateComparisonFilterValue(e,n)}function H0e({input:e,filterValue:t,timezone:n}){const r=e.exports||xO(e.filter),o=(t==null?void 0:t.values)||[],s=p.getDataType(e.filter.dataType)==="date",i=o.map(X0e),a=s?i.length>1?`${i[0]} - ${i[1]}`:i[0]||"":i.join(", "),c={};for(const u of r)u==="start"?c.start=i[0]||null:u==="end"?c.end=i[1]||null:u==="range"?c.range=a||null:c[u]=a||null;return c}function q0e({input:e,value:t}){const n=e.exports||yO(e.control),r=Y0e(t),o=r.map(a=>Z0e(e.control,a)).join(", "),s=r.map(KY).join(", "),i={};for(const a of n)i[a]=a==="label"?o||null:s||null;return i}function U0e(e){return e.control?e.control.scope==="card"||e.id.startsWith("compat-card-control:"):!1}function W0e(e){const t=new Map;for(const n of e){if(fN(n))continue;const r=t.get(n.variableName);if(r)throw new Error(`Duplicate dashboard input variableName "${n.variableName}" for inputs "${r}" and "${n.id}" in the same resolved scope.`);t.set(n.variableName,n.id)}}function K0e(e,t){var r;if(!t)return;const n=(r=e.sheets)==null?void 0:r.find(o=>o.id===t);return(n==null?void 0:n.kind)==="document"?"document":"dashboard"}function G0e(e){return e.length>1?e:e[0]??null}function Y0e(e){return e==null?[]:Array.isArray(e)?e:[e]}function Z0e(e,t){var r;const n=KY(t);return e.source.kind==="manual"&&((r=e.source.options.find(o=>o.value===n))==null?void 0:r.label)||n}function KY(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function X0e(e){return e instanceof Date?e.toISOString():typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function EB(e){return e==null?"":String(e)}function dR({dashboard:e,dashboardInputValues:t,sheetId:n,cardId:r}){let o=p.compactDashboardInputValues(t||{});const s=J0e({dashboard:e,sheetId:n,cardId:r});if(s.status==="unresolved")return{};o=Q0e({dashboardInputValues:o,savedSheetId:n,cardId:r,targets:s.targets});for(const i of s.targets){const a=Rk(ab({dashboard:e,card:i.card}).allInputs).filter(c=>p.canAddressDashboardInputRuntimeSlot(c,i)&&Qh(c,i));for(const c of a){const u=p.getDashboardInputRuntimeSlot(o,c,i);if(!u||u.status===void 0){o=p.setDashboardInputRuntimeSlot(o,c,i,{status:"cleared",comparisonSelection:u==null?void 0:u.comparisonSelection});continue}u.status==="set"&&p.isComparisonCapableDashboardDateInput(c)&&!u.comparisonSelection&&(o=p.setDashboardInputRuntimeSlot(o,c,i,{...u,comparisonSelection:{mode:"off"}}))}}return p.compactDashboardInputValues(o)}function Q0e({dashboardInputValues:e,savedSheetId:t,cardId:n,targets:r}){var c,u,d,f;const o={},s=new Set(r.flatMap(h=>h.sheetId?[h.sheetId]:[])),i=new Set(r.flatMap(h=>h.cardId?[h.cardId]:[])),a=new Set(r.flatMap(h=>h.sectionId?[h.sectionId]:[]));if(e.shared&&(o.shared={...e.shared}),n){const h=r[0],m=(t?(c=e.bySheetId)==null?void 0:c[t]:void 0)??(h.sheetId?(u=e.bySheetId)==null?void 0:u[h.sheetId]:void 0);h.sheetId&&m&&(o.bySheetId={[h.sheetId]:{...m}});const g=h.cardId?(d=e.byCardId)==null?void 0:d[h.cardId]:void 0;h.cardId&&g&&(o.byCardId={[h.cardId]:{...g}});const b=Object.entries(e.byDocumentSectionId||{}),x=(h.sectionId?(f=e.byDocumentSectionId)==null?void 0:f[h.sectionId]:void 0)??(b.length===1?b[0][1]:void 0);return h.sectionId&&x&&(o.byDocumentSectionId={[h.sectionId]:{...x}}),p.compactDashboardInputValues(o)}return o.bySheetId=HT(e.bySheetId,s),o.byCardId=HT(e.byCardId,i),o.byDocumentSectionId=HT(e.byDocumentSectionId,a),p.compactDashboardInputValues(o)}function HT(e,t){if(!e)return;const n=Object.entries(e).filter(([r])=>t.has(r));return n.length>0?Object.fromEntries(n.map(([r,o])=>[r,{...o}])):void 0}function J0e({dashboard:e,sheetId:t,cardId:n}){var i;if(n){const a=eve(e,n);return a?{status:"resolved",targets:[a]}:{status:"unresolved",targetKind:"card"}}const r=(e.sheets||[]).filter(a=>!t||a.id===t);if(t&&r.length===0)return{status:"unresolved",targetKind:"sheet"};const o=r.map(a=>({sheetId:a.id,sheetKind:a.kind||"dashboard"})),s=new Set(r.map(a=>a.id));for(const a of p.getDashboardCardEntries(e))s.has(a.sheet.id)&&o.push({sheetId:a.sheet.id,cardId:a.card.id,card:a.card,sheetKind:a.sheet.kind||"dashboard"});for(const a of r)if(a.kind==="document")for(const c of((i=a.document)==null?void 0:i.sections)||[])o.push({sheetId:a.id,sectionId:c.id,...(c.type==="table"||c.type==="chart")&&{cardId:c.card.id,card:c.card},sheetKind:"document"});return{status:"resolved",targets:o.length>0?o:[{}]}}function eve(e,t){var r;const n=p.findCardLocationById(e,t);if(n)return{sheetId:n.sheet.id,cardId:n.card.id,card:n.card,sheetKind:n.sheet.kind||"dashboard"};for(const o of e.sheets||[])if(o.kind==="document"){for(const s of((r=o.document)==null?void 0:r.sections)||[])if((s.type==="table"||s.type==="chart")&&s.card.id===t)return{sheetId:o.id,sectionId:s.id,cardId:s.card.id,card:s.card,sheetKind:"document"}}}function GY({dashboardInputValues:e,dashboard:t,filterValues:n,sheetId:r,cardId:o,sectionId:s,sheetKind:i}){var u;if(!((u=t.inputs)!=null&&u.length))return e;const a=new Map(n.map(d=>[d.filterId,d]));let c=e||{};for(const d of t.inputs){if(d.kind!=="filter"||!Qh(d,{sheetId:r,cardId:o,sectionId:s,sheetKind:i}))continue;const f=a.get(d.filter.id),h=f?p.createFilterDashboardInputSlot(f):void 0,m=(h==null?void 0:h.status)==="set"?h:{status:"cleared"};c=p.setDashboardInputRuntimeValueAspect(c,d,{sheetId:r,cardId:o,sectionId:s},m)}return c}function ru({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,mode:s,runtimeValues:i,generatedAt:a,timezone:c}){const u=f1({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,mode:s,runtimeValues:i,timezone:c});return{context:u,snapshot:{...t?{sheetId:t}:{},...n!=null&&n.id?{cardId:n.id}:{},mode:s,dashboardInputValues:nve({inputs:u.inputs,context:u,sheetId:t,cardId:n==null?void 0:n.id,sectionId:r}),generatedAt:a,timezone:c}}}function YY({sectionIds:e,...t}){const n=new Set,r=o=>{for(const s of o.missingRequiredInputs)n.add(s.label)};r(f1(t));for(const o of e)r(f1({...t,sectionId:o}));for(const{sectionId:o,card:s}of XY(t.dashboard,t.sheetId,e))r(f1({...t,sectionId:o,card:s}));return Array.from(n)}function vO({sheetIds:e,sheetKind:t="dashboard",...n}){const r=e.map(a=>ru({...n,sheetId:a,sheetKind:t})),o=e.flatMap(a=>tve(n.dashboard,a).map(c=>ru({...n,sheetId:a,card:c,sheetKind:t}))),s=r[0]||o[0]||ru({...n,sheetKind:t}),i=QY(...r.map(a=>a.snapshot.dashboardInputValues),...o.map(a=>a.snapshot.dashboardInputValues));return{context:s.context,snapshot:{...e.length===1?{sheetId:e[0]}:{},mode:n.mode,dashboardInputValues:i,generatedAt:n.generatedAt,timezone:n.timezone}}}function tve(e,t){var i;const n=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),r=[],o=new Set,s=a=>{!(a!=null&&a.id)||o.has(a.id)||(o.add(a.id),r.push(a))};for(const a of(n==null?void 0:n.cards)||[])s(a);for(const a of(n==null?void 0:n.frames)||[])for(const c of(a==null?void 0:a.cards)||[])s(c);return r}function ZY({sectionIds:e,...t}){const n=ru(t),r=e.map(s=>ru({...t,sectionId:s})),o=XY(t.dashboard,t.sheetId,e).map(({sectionId:s,card:i})=>ru({...t,sectionId:s,card:i}));return{...n,snapshot:{...n.snapshot,dashboardInputValues:QY(n.snapshot.dashboardInputValues,...r.map(s=>s.snapshot.dashboardInputValues),...o.map(s=>s.snapshot.dashboardInputValues))}}}function XY(e,t,n){var i,a;const r=new Set(n),o=(i=e.sheets)==null?void 0:i.find(c=>c.id===t);return(((a=o==null?void 0:o.document)==null?void 0:a.sections)||[]).flatMap(c=>c.id&&r.has(c.id)&&c.card?[{sectionId:c.id,card:c.card}]:[])}function nve({inputs:e,context:t,sheetId:n,cardId:r,sectionId:o}){const s=new Map(t.resolvedInputs.map(a=>[a.id,a]));let i={};for(const a of e){const c=s.get(a.id),u=(c==null?void 0:c.slot)||{status:"cleared"};i=p.setDashboardInputRuntimeSlot(i,a,{sheetId:n,cardId:r,sectionId:o},u)}return p.compactDashboardInputValues(i)}function rve(e){return e==="document"||e==="visual"?"export":"print"}function f1({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,mode:s,runtimeValues:i,timezone:a}){return Yi({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:o,runtimeValues:i,mode:rve(s),timezone:a})}function QY(...e){const t={};for(const n of e)n.shared&&(t.shared={...t.shared,...n.shared}),qT(t,"bySheetId",n.bySheetId),qT(t,"byCardId",n.byCardId),qT(t,"byDocumentSectionId",n.byDocumentSectionId);return p.compactDashboardInputValues(t)}function qT(e,t,n){if(n){e[t]||(e[t]={});for(const[r,o]of Object.entries(n))e[t][r]={...e[t][r],...o}}}function JY(e){var n;return typeof window>"u"||new URLSearchParams(window.location.search).get("isPdfRender")!=="true"?null:((n=lb(e))==null?void 0:n.reportContext)??null}function lb(e){if(typeof window>"u")return e?$t.parsePresentationExecutionSnapshot(e):null;const t=new URLSearchParams(window.location.search);if(t.get("isPdfRender")!=="true")return null;if(e)return $t.parsePresentationExecutionSnapshot(e);const n=t.get("presentationExecutionSnapshot");if(!n)return null;let r;try{r=JSON.parse(n)}catch{throw new $t.PresentationExecutionSnapshotError("Internal print presentation snapshot JSON is invalid.")}return $t.parsePresentationExecutionSnapshot(r)}function $v(){if(typeof window>"u")return;const e=new URLSearchParams(window.location.search).get("presentationAttachmentIndex");if(e===null)return;const t=Number(e);if(!Number.isInteger(t)||t<0)throw new Error("Internal print presentation attachment index is invalid");return t}function ove(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function sve(e,t){const n=ove(e);return n==="dark"?Jl({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function DB(e,t,n){return wye(sve(e,t),n)}function ive(e){return Ho.stableSerialize({hasExplicitDefaultControlValues:e!==void 0,values:e??null})}function ave(e,t){const{controlContractOverrides:n,cardId:r}=t;if(!n||(n.controlDefinitions!==void 0&&(e.controls=n.controlDefinitions),typeof r!="string"||r.trim().length===0))return e;const o=p.findCardById(e,r);return o&&(n.cardControlDefinitions!==void 0&&(o.controls=n.cardControlDefinitions),n.controlBindings!==void 0&&(o.controlBindings=n.controlBindings)),e}function lve(e,t){const n=v.useRef({key:t,value:e});return n.current.key!==t&&(n.current={key:t,value:e}),n.current.value}function cve({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o,defaultControlValues:s,controlContractOverrides:i,dashboardInputExecutionSnapshot:a,interactionExecutionSnapshot:c,presentationExecutionSnapshot:u,type:d,cardId:f,selectedSheetId:h,onFilterValuesChange:m}){var ie,we;const{authToken:g,tokenProps:b}=It(),x=g==null?void 0:g.accessToken,y=g==null?void 0:g.refreshToken,w=v.useMemo(()=>JY(u),[u]);o0e();const C=p.useDashboardStore(fe=>fe.selectedLensId),N=p.useDashboardStore(fe=>fe.relaodToken),{data:S,isLoading:j,isFetching:_,isError:k,refetch:T,dashboardIdToFetch:I}=Pv(),E=(ie=S==null?void 0:S.dashboard)==null?void 0:ie.id,{getDefaultSheetId:D,clearDefaultSheetId:R}=_Y(E),[A,F]=v.useState(o||[]),z=v.useRef(null),L=v.useRef(null),$=ive(s),H=uR(i),M=uR(i,{includePresentation:!0}),B=v.useRef(s);B.current=s;const W=v.useRef($);W.current=$;const P=lve(i,M),G=v.useRef(null),Z=v.useRef(!1),X=v.useRef({dashboardId:null,defaultControlValuesKey:$,controlContractOverridesKey:H}),{setTheme:Y}=oO(),{compiledAppearance:O}=p.useAppearance(),q=p.useDashboardStore(fe=>fe.dashboard.globalStyle),U=v.useMemo(()=>S!=null&&S.dashboard?_0e(ave(Ks(S.dashboard),{controlContractOverrides:P,cardId:f})):void 0,[S==null?void 0:S.dashboard,P,d,f]),{setDashboardWithFilterValues:V,hydrateRuntimeControlValues:K,setStyle:Q,setOnSaveFunction:se,setLenses:oe,setSelectedLensId:me,setInlineFilterValuesMap:le}=p.useDashboardActions();p.useDashboardStore(fe=>fe.actions.setCustomCards);const ue=p.useDashboardStore(fe=>fe.filterValues),ne=p.useDashboardStore(fe=>fe.actions.setThemeStyle),de=p.useDashboardStore(fe=>fe.actions.setDashboardTheme),Ce=p.useDashboardStore(fe=>fe.actions.setOnEvent);v.useEffect(()=>{const fe=L.current;fe&&fe!==I&&p.storeEvents.emit("dashboard:unload"),L.current=I},[I]),v.useEffect(()=>{N&&T()},[T,N]),v.useEffect(()=>{var ee;const fe=((ee=S==null?void 0:S.dashboard)==null?void 0:ee.id)||null,ae=z.current;fe&&fe!==ae&&p.storeEvents.emit("dashboard:load"),z.current=fe},[(we=S==null?void 0:S.dashboard)==null?void 0:we.id]),v.useEffect(()=>{de(O.mode)},[O.mode,de]),v.useEffect(()=>{t&&Y(t)},[t,Y]);const ce=v.useCallback(()=>{const fe=Ks(dt.DEFAULT_STYLE),ae=Jl(fe,q);if(e){const ee=Jl(ae,e),J=DB(O.mode,ee,O);ne(J),Q(ee)}else{const ee=DB(O.mode,ae,O);ne(ee),Q(dt.DEFAULT_STYLE)}},[O,e,q,ne,Q]);return v.useEffect(()=>{S&&S.dashboard&&ce()},[O.mode,e,q,ce,S]),v.useEffect(()=>{var ct,rt,Ct,Lt,vt,Tt;function fe(Me,Je){const kt=Me.filters||[],mt=[];for(const _t of Je){const Rt=kt.find(Pt=>Pt.id===_t.filterId);Rt&&mt.push({filterId:_t.filterId,name:Rt.column,operation:_t.operation,valueType:p.getFilterValueType(Rt),values:_t.values,dataType:Rt.dataType,fieldMeta:Rt.fieldMeta,semanticContext:Rt.semanticContext})}return mt}if(!S||!U)return;const ae=U,ee=p.useDashboardStore.getState(),J=ee.reportContextSessionAccessToken===x&&((ct=ee.dashboard)==null?void 0:ct.id)===U.id&&ee.reportContext!==null,re=w??S.initialReportContext,pe=(J?(rt=ee.reportContext)==null?void 0:rt.calendar.tz:void 0)??re.calendar.tz,{filterValues:Ee,defaultLensId:Te,lenses:ze}=S;function Pe(){if(Ee&&(Ee==null?void 0:Ee.length)>0)return Ee;const Je=[...p.buildFilterValuesFromDefaults(ae.filters,pe)];if(ae.defaultFilterValues&&ae.defaultFilterValues.length>0)for(const _t of ae.defaultFilterValues){const Rt=Je.findIndex(Pt=>Pt.filterId===_t.filterId);Rt>=0?Je[Rt]=_t:Je.push(_t)}const kt=fe(ae,A||[]),mt=[...Je];for(const _t of kt){const Rt=mt.findIndex(Pt=>Pt.filterId===_t.filterId);Rt>=0?mt[Rt]=_t:mt.push(_t)}return mt}const He=G.current===U.id&&((Ct=ee.dashboard)==null?void 0:Ct.id)===U.id,ye=Pe(),Ke=He?p.resolveSameDashboardFilterValues({previousFilters:(Lt=ee.dashboard)==null?void 0:Lt.filters,nextFilters:ae.filters,currentFilterValues:ee.filterValues,defaultFilterValues:ye}):ye,We=p.computeInlineFilterDefaults(ae,pe),Qe=He&&X.current.controlContractOverridesKey===H?p.flattenRuntimeControlValues({dashboardValues:ee.controlValues,cardValuesMap:ee.cardControlValuesMap}):B.current,xe=ee.selectedSheetId;let Ve=D(),Ae=xe;Ae&&((vt=U==null?void 0:U.sheets)!=null&&vt.some(Je=>Je.id===Ae)||(Ae=null)),Ve&&((Tt=U==null?void 0:U.sheets)!=null&&Tt.some(Je=>Je.id===Ve)||(R(),Ve=null));const ke=N0e({selectedSheetId:h,preservedSelectedSheetId:Ae,defaultSheetId:Ve,sheets:U==null?void 0:U.sheets}),Be=!!a,Ie=!!(C||S!=null&&S.defaultLensId),$e=!Be&&Z.current,st=a?dR({dashboard:ae,dashboardInputValues:a.dashboardInputValues,sheetId:a.sheetId,cardId:a.cardId}):(S==null?void 0:S.inputValues)!=null?dR({dashboard:ae,dashboardInputValues:S.inputValues.dashboardInputValues}):void 0;V(ae,Ke||[],Qe,{selectedSheetId:ke,reportContext:J?void 0:re,authToken:x?{accessToken:x,refreshToken:y}:void 0,...S!=null&&S.semanticExecutionPayload?{semanticExecutionPayload:S.semanticExecutionPayload}:{},...a?{dashboardInputValues:st,dashboardInputReferenceTime:a.generatedAt}:Ie?{dashboardInputValues:st||{},dashboardInputReferenceTime:(S==null?void 0:S.inputValues)!=null?S.inputValues.generatedAt:void 0}:$e?{dashboardInputValues:{},dashboardInputReferenceTime:void 0}:{}}),c&&p.useInteractionStore.setState({interactionStates:Ks(c)}),Z.current=Be,G.current=U.id,X.current.dashboardId!==U.id&&(X.current={dashboardId:U.id,defaultControlValuesKey:W.current,controlContractOverridesKey:H}),le(We),ze&&oe(ze),Te&&me(Te)},[S,C,oe,V,me,le,A,h,D,R,H,a,c,U,x,y,w]),v.useEffect(()=>{if(!(U!=null&&U.id))return;const fe=X.current;if(fe.dashboardId!==U.id){X.current={dashboardId:U.id,defaultControlValuesKey:$,controlContractOverridesKey:H};return}fe.defaultControlValuesKey===$&&fe.controlContractOverridesKey===H||(K(U,B.current),X.current={dashboardId:U.id,defaultControlValuesKey:$,controlContractOverridesKey:H})},[U,$,H,K]),v.useEffect(()=>{m&&ue&&m(ue)},[ue,m]),v.useEffect(()=>{n&&se(n),r&&Ce(r)},[n,se,r,Ce]),{isFetching:_,isLoading:j,isError:k,refetch:T}}const hN=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));hN.displayName="Card";const wO=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex flex-col space-y-1.5 p-6",e),...t}));wO.displayName="CardHeader";const cb=te.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:p.cn("text-2xl font-semibold leading-none tracking-tight",e),...t}));cb.displayName="CardTitle";const uve=te.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));uve.displayName="CardDescription";const CO=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("px-6 pt-0",e),...t}));CO.displayName="CardContent";const eZ=te.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex items-center p-6 pt-0",e),...t}));eZ.displayName="CardFooter";/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -958,7 +958,7 @@ ${(e*100).toLocaleString()}%`}}},scales:{_index_:{display:!1,padding:10,grid:{di
958
958
  * This source code is licensed under the MIT license found in the
959
959
  * LICENSE file in the root directory of this source tree.
960
960
  */var bq;function BWe(){return bq||(bq=1,process.env.NODE_ENV!=="production"&&function(){function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=v,n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,o=t.useRef,s=t.useEffect,i=t.useMemo,a=t.useDebugValue;iM.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var m=o(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=i(function(){function x(S){if(!y){if(y=!0,w=S,S=f(S),h!==void 0&&g.hasValue){var j=g.value;if(h(j,S))return C=j}return C=S}if(j=C,n(w,S))return j;var _=f(S);return h!==void 0&&h(j,_)?(w=S,j):(w=S,C=_)}var y=!1,w,C,N=d===void 0?null:d;return[function(){return x(u())},N===null?void 0:function(){return x(N())}]},[u,d,f,h]);var b=r(c,m[0],m[1]);return s(function(){g.hasValue=!0,g.value=b},[b]),a(b),b},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),iM}process.env.NODE_ENV==="production"?LP.exports=zWe():LP.exports=BWe();var VWe=LP.exports;function Bo(e,t,n=Gle){return VWe.useSyncExternalStoreWithSelector(Ln(r=>e.subscribe(HWe,r)),Ln(()=>e.state),Ln(()=>e.state),Ln(t),n)}function HWe(e){return e}function Xle(e,t){let n=v.useId(),r=y$.get(t),[o,s]=Bo(r,v.useCallback(i=>[r.selectors.isTop(i,n),r.selectors.inStack(i,n)],[r,n]));return vo(()=>{if(e)return r.actions.push(n),()=>r.actions.pop(n)},[r,e,n]),e?s?o:!0:!1}let $P=new Map,t0=new Map;function xq(e){var t;let n=(t=t0.get(e))!=null?t:0;return t0.set(e,n+1),n!==0?()=>yq(e):($P.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>yq(e))}function yq(e){var t;let n=(t=t0.get(e))!=null?t:1;if(n===1?t0.delete(e):t0.set(e,n-1),n!==1)return;let r=$P.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,$P.delete(e))}function qWe(e,{allowed:t,disallowed:n}={}){let r=Xle(e,"inert-others");vo(()=>{var o,s;if(!r)return;let i=Da();for(let c of(o=n==null?void 0:n())!=null?o:[])c&&i.add(xq(c));let a=(s=t==null?void 0:t())!=null?s:[];for(let c of a){if(!c)continue;let u=Dw(c);if(!u)continue;let d=c.parentElement;for(;d&&d!==u.body;){for(let f of d.children)a.some(h=>f.contains(h))||i.add(xq(f));d=d.parentElement}}return i.dispose},[r,t,n])}function UWe(e,t,n){let r=tp(o=>{let s=o.getBoundingClientRect();s.x===0&&s.y===0&&s.width===0&&s.height===0&&n()});v.useEffect(()=>{if(!e)return;let o=t===null?null:kf(t)?t:t.current;if(!o)return;let s=Da();if(typeof ResizeObserver<"u"){let i=new ResizeObserver(()=>r.current(o));i.observe(o),s.add(()=>i.disconnect())}if(typeof IntersectionObserver<"u"){let i=new IntersectionObserver(()=>r.current(o));i.observe(o),s.add(()=>i.disconnect())}return()=>s.dispose()},[t,r,e])}let zP=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var WWe=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(WWe||{}),KWe=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(KWe||{}),GWe=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(GWe||{}),Qle=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(Qle||{});function YWe(e,t=0){var n;return e===((n=Dw(e))==null?void 0:n.body)?!1:ac(t,{0(){return e.matches(zP)},1(){let r=e;for(;r!==null;){if(r.matches(zP))return!0;r=r.parentElement}return!1}})}var ZWe=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(ZWe||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function XWe(e,t=n=>n){return e.slice().sort((n,r)=>{let o=t(n),s=t(r);if(o===null||s===null)return 0;let i=o.compareDocumentPosition(s);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function Jle(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function QWe(){return/Android/gi.test(window.navigator.userAgent)}function BP(){return Jle()||QWe()}function Xp(e,t,n,r){let o=tp(n);v.useEffect(()=>{if(!e)return;function s(i){o.current(i)}return document.addEventListener(t,s,r),()=>document.removeEventListener(t,s,r)},[e,t,r])}function JWe(e,t,n,r){let o=tp(n);v.useEffect(()=>{if(!e)return;function s(i){o.current(i)}return window.addEventListener(t,s,r),()=>window.removeEventListener(t,s,r)},[e,t,r])}const vq=30;function eKe(e,t,n){let r=tp(n),o=v.useCallback(function(a,c){if(a.defaultPrevented)return;let u=c(a);if(u===null||!u.getRootNode().contains(u)||!u.isConnected)return;let d=function f(h){return typeof h=="function"?f(h()):Array.isArray(h)||h instanceof Set?h:[h]}(t);for(let f of d)if(f!==null&&(f.contains(u)||a.composed&&a.composedPath().includes(f)))return;return!YWe(u,Qle.Loose)&&u.tabIndex!==-1&&a.preventDefault(),r.current(a,u)},[r,t]),s=v.useRef(null);Xp(e,"pointerdown",a=>{var c,u;BP()||(s.current=((u=(c=a.composedPath)==null?void 0:c.call(a))==null?void 0:u[0])||a.target)},!0),Xp(e,"pointerup",a=>{if(BP()||!s.current)return;let c=s.current;return s.current=null,o(a,()=>c)},!0);let i=v.useRef({x:0,y:0});Xp(e,"touchstart",a=>{i.current.x=a.touches[0].clientX,i.current.y=a.touches[0].clientY},!0),Xp(e,"touchend",a=>{let c={x:a.changedTouches[0].clientX,y:a.changedTouches[0].clientY};if(!(Math.abs(c.x-i.current.x)>=vq||Math.abs(c.y-i.current.y)>=vq))return o(a,()=>gh(a.target)?a.target:null)},!0),JWe(e,"blur",a=>o(a,()=>gWe(window.document.activeElement)?window.document.activeElement:null),!0)}function VP(...e){return v.useMemo(()=>Dw(...e),[...e])}var tKe=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(tKe||{});const Ax={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},nKe=200,wq=5;function rKe(e,{trigger:t,action:n,close:r,select:o}){let s=v.useRef(null),i=v.useRef(null),a=v.useRef(null);Xp(e&&t!==null,"pointerdown",c=>{zle(c==null?void 0:c.target)&&t!=null&&t.contains(c.target)&&(i.current=c.x,a.current=c.y,s.current=c.timeStamp)}),Xp(e&&t!==null,"pointerup",c=>{var u,d;let f=s.current;if(f===null||(s.current=null,!gh(c.target))||Math.abs(c.x-((u=i.current)!=null?u:c.x))<wq&&Math.abs(c.y-((d=a.current)!=null?d:c.y))<wq)return;let h=n(c);switch(h.kind){case 0:return;case 1:{c.timeStamp-f>nKe&&(o(h.target),r());break}case 2:{r();break}}},{capture:!0})}function oKe(e,t,n,r){let o=tp(n);v.useEffect(()=>{e=e??window;function s(i){o.current(i)}return e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)},[e,t,r])}function ece(e){let t=v.useRef({value:"",selectionStart:null,selectionEnd:null});return oKe(e,"blur",n=>{let r=n.target;Mj(r)&&(t.current={value:r.value,selectionStart:r.selectionStart,selectionEnd:r.selectionEnd})}),Ln(()=>{if(!Mle(e)&&Mj(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:"",selectionStart:null,selectionEnd:null}}})}function sKe(e,t){return v.useMemo(()=>{var n;if(e.type)return e.type;let r=(n=e.as)!=null?n:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function iKe(e){return v.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function aKe(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...s){let i=t[o].call(n,...s);i&&(n=i,r.forEach(a=>a()))}}}function lKe(){let e;return{before({doc:t}){var n;let r=t.documentElement,o=(n=t.defaultView)!=null?n:window;e=Math.max(0,o.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,o=Math.max(0,r.clientWidth-r.offsetWidth),s=Math.max(0,e-o);n.style(r,"paddingRight",`${s}px`)}}}function cKe(){return Jle()?{before({doc:e,d:t,meta:n}){function r(o){for(let s of n().containers)for(let i of s())if(i.contains(o))return!0;return!1}t.microTask(()=>{var o;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=Da();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let s=(o=window.scrollY)!=null?o:window.pageYOffset,i=null;t.addEventListener(e,"click",a=>{if(gh(a.target))try{let c=a.target.closest("a");if(!c)return;let{hash:u}=new URL(c.href),d=e.querySelector(u);gh(d)&&!r(d)&&(i=d)}catch{}},!0),t.group(a=>{t.addEventListener(e,"touchstart",c=>{if(a.dispose(),gh(c.target)&&pWe(c.target))if(r(c.target)){let u=c.target;for(;u.parentElement&&r(u.parentElement);)u=u.parentElement;a.style(u,"overscrollBehavior","contain")}else a.style(c.target,"touchAction","none")})}),t.addEventListener(e,"touchmove",a=>{if(gh(a.target)){if(Mj(a.target))return;if(r(a.target)){let c=a.target;for(;c.parentElement&&c.dataset.headlessuiPortal!==""&&!(c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth);)c=c.parentElement;c.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let c=(a=window.scrollY)!=null?a:window.pageYOffset;s!==c&&window.scrollTo(0,s),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})})}}:{}}function uKe(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Cq(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let bh=aKe(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:Da(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(t),r.computedMeta=Cq(r.meta),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t),n.computedMeta=Cq(n.meta)),this},SCROLL_PREVENT(e){let t={doc:e.doc,d:e.d,meta(){return e.computedMeta}},n=[cKe(),lKe(),uKe()];n.forEach(({before:r})=>r==null?void 0:r(t)),n.forEach(({after:r})=>r==null?void 0:r(t))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});bh.subscribe(()=>{let e=bh.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",o=n.count!==0;(o&&!r||!o&&r)&&bh.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&bh.dispatch("TEARDOWN",n)}});function dKe(e,t,n=()=>({containers:[]})){let r=iKe(bh),o=t?r.get(t):void 0,s=o?o.count>0:!1;return vo(()=>{if(!(!t||!e))return bh.dispatch("PUSH",t,n),()=>bh.dispatch("POP",t,n)},[e,t]),s}function fKe(e,t,n=()=>[document.body]){let r=Xle(e,"scroll-lock");dKe(r,t,o=>{var s;return{containers:[...(s=o.containers)!=null?s:[],n]}})}function Sq(e){return[e.screenX,e.screenY]}function hKe(){let e=v.useRef([-1,-1]);return{wasMoved(t){let n=Sq(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=Sq(t)}}}function mKe(e=0){let[t,n]=v.useState(e),r=v.useCallback(c=>n(c),[]),o=v.useCallback(c=>n(u=>u|c),[]),s=v.useCallback(c=>(t&c)===c,[t]),i=v.useCallback(c=>n(u=>u&~c),[]),a=v.useCallback(c=>n(u=>u^c),[]);return{flags:t,setFlag:r,addFlag:o,hasFlag:s,removeFlag:i,toggleFlag:a}}var Nq,jq;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Nq=process==null?void 0:process.env)==null?void 0:Nq.NODE_ENV)==="test"&&typeof((jq=Element==null?void 0:Element.prototype)==null?void 0:jq.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
961
- `)),[]});var pKe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(pKe||{});function gKe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function bKe(e,t,n,r){let[o,s]=v.useState(n),{hasFlag:i,addFlag:a,removeFlag:c}=mKe(e&&o?3:0),u=v.useRef(!1),d=v.useRef(!1),f=Hb();return vo(()=>{var h;if(e){if(n&&s(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),xKe(t,{inFlight:u,prepare(){d.current?d.current=!1:d.current=u.current,u.current=!0,!d.current&&(n?(a(3),c(4)):(a(4),c(2)))},run(){d.current?n?(c(3),a(4)):(c(4),a(3)):n?c(1):a(1)},done(){var m;d.current&&wKe(t)||(u.current=!1,c(7),n||s(!1),(m=void 0)==null||m.call(r,n))}})}},[e,n,t,f]),e?[o,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function xKe(e,{prepare:t,run:n,done:r,inFlight:o}){let s=Da();return vKe(e,{prepare:t,inFlight:o}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(yKe(e,r))})}),s.dispose}function yKe(e,t){var n,r;let o=Da();if(!e)return o.dispose;let s=!1;o.add(()=>{s=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),o.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{s||t()}),o.dispose)}function vKe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function wKe(e){var t,n;return((n=(t=e.getAnimations)==null?void 0:t.call(e))!=null?n:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function CKe(e,{container:t,accept:n,walk:r}){let o=v.useRef(n),s=v.useRef(r);v.useEffect(()=>{o.current=n,s.current=r},[n,r]),vo(()=>{if(!t||!e)return;let i=Dw(t);if(!i)return;let a=o.current,c=s.current,u=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,u,!1);for(;d.nextNode();)c(d.currentNode)},[t,e,o,s])}function kq(e,t){let n=v.useRef([]),r=Ln(e);v.useEffect(()=>{let o=[...n.current];for(let[s,i]of t.entries())if(n.current[s]!==i){let a=r(t,o);return n.current=t,a}},[r,...t])}function SKe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const tce={...te},NKe=tce.useInsertionEffect,jKe=NKe||(e=>e());function nce(e){const t=te.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return jKe(()=>{t.current=e}),te.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var HP=typeof document<"u"?v.useLayoutEffect:v.useEffect;let _q=!1,kKe=0;const Iq=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+kKe++;function _Ke(){const[e,t]=te.useState(()=>_q?Iq():void 0);return HP(()=>{e==null&&t(Iq())},[]),te.useEffect(()=>{_q=!0},[]),e}const IKe=tce.useId,TKe=IKe||_Ke;let Z0;process.env.NODE_ENV!=="production"&&(Z0=new Set);function EKe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=Z0)!=null&&e.has(o))){var s;(s=Z0)==null||s.add(o),console.warn(o)}}function DKe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=Z0)!=null&&e.has(o))){var s;(s=Z0)==null||s.add(o),console.error(o)}}function MKe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}const RKe=te.createContext(null),AKe=te.createContext(null),PKe=()=>{var e;return((e=te.useContext(RKe))==null?void 0:e.id)||null},FKe=()=>te.useContext(AKe),OKe="data-floating-ui-focusable";function LKe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=TKe(),s=te.useRef({}),[i]=te.useState(()=>MKe()),a=PKe()!=null;if(process.env.NODE_ENV!=="production"){const m=r.reference;m&&!p.isElement(m)&&DKe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[c,u]=te.useState(r.reference),d=nce((m,g,b)=>{s.current.openEvent=m?g:void 0,i.emit("openchange",{open:m,event:g,reason:b,nested:a}),n==null||n(m,g,b)}),f=te.useMemo(()=>({setPositionReference:u}),[]),h=te.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return te.useMemo(()=>({dataRef:s,open:t,onOpenChange:d,elements:h,events:i,floatingId:o,refs:f}),[t,d,h,i,o,f])}function $Ke(e){e===void 0&&(e={});const{nodeId:t}=e,n=LKe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[s,i]=te.useState(null),[a,c]=te.useState(null),d=(o==null?void 0:o.domReference)||s,f=te.useRef(null),h=FKe();HP(()=>{d&&(f.current=d)},[d]);const m=p.useFloating({...e,elements:{...o,...a&&{reference:a}}}),g=te.useCallback(C=>{const N=p.isElement(C)?{getBoundingClientRect:()=>C.getBoundingClientRect(),contextElement:C}:C;c(N),m.refs.setReference(N)},[m.refs]),b=te.useCallback(C=>{(p.isElement(C)||C===null)&&(f.current=C,i(C)),(p.isElement(m.refs.reference.current)||m.refs.reference.current===null||C!==null&&!p.isElement(C))&&m.refs.setReference(C)},[m.refs]),x=te.useMemo(()=>({...m.refs,setReference:b,setPositionReference:g,domReference:f}),[m.refs,b,g]),y=te.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),w=te.useMemo(()=>({...m,...r,refs:x,elements:y,nodeId:t}),[m,x,y,t,r]);return HP(()=>{r.dataRef.current.floatingContext=w;const C=h==null?void 0:h.nodesRef.current.find(N=>N.id===t);C&&(C.context=w)}),te.useMemo(()=>({...m,context:w,refs:x,elements:y}),[m,x,y,w])}const Tq="active",Eq="selected";function aM(e,t,n){const r=new Map,o=n==="item";let s=e;if(o&&e){const{[Tq]:i,[Eq]:a,...c}=e;s=c}return{...n==="floating"&&{tabIndex:-1,[OKe]:""},...s,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(c=>{let[u,d]=c;if(!(o&&[Tq,Eq].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),i[u]=function(){for(var h,m=arguments.length,g=new Array(m),b=0;b<m;b++)g[b]=arguments[b];return(h=r.get(u))==null?void 0:h.map(x=>x(...g)).find(x=>x!==void 0)}}}else i[u]=d}),i),{})}}function zKe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),o=te.useCallback(a=>aM(a,e,"reference"),t),s=te.useCallback(a=>aM(a,e,"floating"),n),i=te.useCallback(a=>aM(a,e,"item"),r);return te.useMemo(()=>({getReferenceProps:o,getFloatingProps:s,getItemProps:i}),[o,s,i])}function Dq(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const BKe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:o,offset:s=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:c=0,scrollRef:u,...d}=p.evaluate(e,t),{rects:f,elements:{floating:h}}=t,m=n.current[i],g=(u==null?void 0:u.current)||h,b=h.clientTop||g.clientTop,x=h.clientTop!==0,y=g.clientTop!==0,w=h===g;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||EKe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!m)return{};const C={...t,...await p.offset(-m.offsetTop-h.clientTop-f.reference.height/2-m.offsetHeight/2-s).fn(t)},N=await p.detectOverflow(Dq(C,g.scrollHeight+b+h.clientTop),d),S=await p.detectOverflow(C,{...d,elementContext:"reference"}),j=p.max(0,N.top),_=C.y+j,I=(g.scrollHeight>g.clientHeight?E=>E:p.round)(p.max(0,g.scrollHeight+(x&&w||y?b*2:0)-j-p.max(0,N.bottom)));if(g.style.maxHeight=I+"px",g.scrollTop=j,o){const E=g.offsetHeight<m.offsetHeight*p.min(a,n.current.length)-1||S.top>=-c||S.bottom>=-c;V2.flushSync(()=>o(E))}return r&&(r.current=await p.detectOverflow(Dq({...C,y:_},g.offsetHeight+b+h.clientTop),d)),{y:_}}});function VKe(e,t){const{open:n,elements:r}=e,{enabled:o=!0,overflowRef:s,scrollRef:i,onChange:a}=t,c=nce(a),u=te.useRef(!1),d=te.useRef(null),f=te.useRef(null);te.useEffect(()=>{if(!o)return;function m(b){if(b.ctrlKey||!g||s.current==null)return;const x=b.deltaY,y=s.current.top>=-.5,w=s.current.bottom>=-.5,C=g.scrollHeight-g.clientHeight,N=x<0?-1:1,S=x<0?"max":"min";g.scrollHeight<=g.clientHeight||(!y&&x>0||!w&&x<0?(b.preventDefault(),V2.flushSync(()=>{c(j=>j+Math[S](x,C*N))})):/firefox/i.test(SKe())&&(g.scrollTop+=x))}const g=(i==null?void 0:i.current)||r.floating;if(n&&g)return g.addEventListener("wheel",m),requestAnimationFrame(()=>{d.current=g.scrollTop,s.current!=null&&(f.current={...s.current})}),()=>{d.current=null,f.current=null,g.removeEventListener("wheel",m)}},[o,n,r.floating,s,i,c]);const h=te.useMemo(()=>({onKeyDown(){u.current=!0},onWheel(){u.current=!1},onPointerMove(){u.current=!1},onScroll(){const m=(i==null?void 0:i.current)||r.floating;if(!(!s.current||!m||!u.current)){if(d.current!==null){const g=m.scrollTop-d.current;(s.current.bottom<-.5&&g<-1||s.current.top<-.5&&g>1)&&V2.flushSync(()=>c(b=>b+g))}requestAnimationFrame(()=>{d.current=m.scrollTop})}}}),[r.floating,c,s,i]);return te.useMemo(()=>o?{floating:h}:{},[o,h])}let Mw=v.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Mw.displayName="FloatingContext";let v$=v.createContext(null);v$.displayName="PlacementContext";function HKe(e){return v.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function qKe(){return v.useContext(Mw).setReference}function UKe(){let{getFloatingProps:e,slot:t}=v.useContext(Mw);return v.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function WKe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=v.useContext(v$),n=v.useMemo(()=>e,[JSON.stringify(e,(o,s)=>{var i;return(i=s==null?void 0:s.outerHTML)!=null?i:s})]);vo(()=>{t==null||t(n??null)},[t,n]);let r=v.useContext(Mw);return v.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Mq=4;function KKe({children:e,enabled:t=!0}){let[n,r]=v.useState(null),[o,s]=v.useState(0),i=v.useRef(null),[a,c]=v.useState(null);GKe(a);let u=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:m=0,inner:g}=YKe(n,a),[b,x="center"]=d.split(" ");vo(()=>{u&&s(0)},[u]);let{refs:y,floatingStyles:w,context:C}=$Ke({open:u,placement:b==="selection"?x==="center"?"bottom":`bottom-${x}`:x==="center"?`${b}`:`${b}-${x}`,strategy:"absolute",transform:!1,middleware:[p.offset({mainAxis:b==="selection"?0:f,crossAxis:h}),p.shift({padding:m}),b!=="selection"&&p.flip({padding:m}),b==="selection"&&g?BKe({...g,padding:m,overflowRef:i,offset:o,minItemsVisible:Mq,referenceOverflowThreshold:m,onFallbackChange(E){var D,R;if(!E)return;let A=C.elements.floating;if(!A)return;let F=parseFloat(getComputedStyle(A).scrollPaddingBottom)||0,z=Math.min(Mq,A.childElementCount),L=0,$=0;for(let H of(R=(D=C.elements.floating)==null?void 0:D.childNodes)!=null?R:[])if(kf(H)){let M=H.offsetTop,B=M+H.clientHeight+F,W=A.scrollTop,P=W+A.clientHeight;if(M>=W&&B<=P)z--;else{$=Math.max(0,Math.min(B,P)-Math.max(M,W)),L=H.clientHeight;break}}z>=1&&s(H=>{let M=L*z-$+F;return H>=M?H:M})}}):null,p.size({padding:m,apply({availableWidth:E,availableHeight:D,elements:R}){Object.assign(R.floating.style,{overflow:"auto",maxWidth:`${E}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${D}px)`})}})].filter(Boolean),whileElementsMounted:p.autoUpdate}),[N=b,S=x]=C.placement.split("-");b==="selection"&&(N="selection");let j=v.useMemo(()=>({anchor:[N,S].filter(Boolean).join(" ")}),[N,S]),_=VKe(C,{overflowRef:i,onChange:s}),{getReferenceProps:k,getFloatingProps:T}=zKe([_]),I=Ln(E=>{c(E),y.setFloating(E)});return te.createElement(v$.Provider,{value:r},te.createElement(Mw.Provider,{value:{setFloating:I,setReference:y.setReference,styles:w,getReferenceProps:k,getFloatingProps:T,slot:j}},e))}function GKe(e){vo(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let o=parseInt(n);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function YKe(e,t){var n,r,o;let s=lM((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=lM((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=lM((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",t);return{...e,gap:s,offset:i,padding:a}}function lM(e,t,n=void 0){let r=Hb(),o=Ln((c,u)=>{if(c==null)return[n,null];if(typeof c=="number")return[c,null];if(typeof c=="string"){if(!u)return[n,null];let d=Rq(c,u);return[d,f=>{let h=rce(c);{let m=h.map(g=>window.getComputedStyle(u).getPropertyValue(g));r.requestAnimationFrame(function g(){r.nextFrame(g);let b=!1;for(let[y,w]of h.entries()){let C=window.getComputedStyle(u).getPropertyValue(w);if(m[y]!==C){m[y]=C,b=!0;break}}if(!b)return;let x=Rq(c,u);d!==x&&(f(x),d=x)})}return r.dispose}]}return[n,null]}),s=v.useMemo(()=>o(e,t)[0],[e,t]),[i=s,a]=v.useState();return vo(()=>{let[c,u]=o(e,t);if(a(c),!!u)return u(a)},[e,t]),i}function rce(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),o=t[1].slice(n+1).trim();return o?[r,...rce(o)]:[r]}return[]}function Rq(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function ZKe({children:e,freeze:t},n){let r=qP(t,e);return v.isValidElement(r)?v.cloneElement(r,{ref:n}):v.createElement(v.Fragment,null,r)}const XKe=v.forwardRef(ZKe);function qP(e,t){let[n,r]=v.useState(t);return!e&&n!==t&&r(t),e?n:t}let w$=v.createContext(null);w$.displayName="OpenClosedContext";var X0=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(X0||{});function QKe(){return v.useContext(w$)}function JKe({value:e,children:t}){return v.createElement(w$.Provider,{value:e},t)}function eGe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let oh=[];eGe(()=>{function e(t){if(!gh(t.target)||t.target===document.body||oh[0]===t.target)return;let n=t.target;n=n.closest(zP),oh.unshift(n??t.target),oh=oh.filter(r=>r!=null&&r.isConnected),oh.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function tGe(e){throw new Error("Unexpected object: "+e)}var Po=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(Po||{});function Aq(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let s=0;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 1:{o===-1&&(o=n.length);for(let s=o-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 2:{for(let s=o+1;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 3:{for(let s=n.length-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 4:{for(let s=0;s<n.length;++s)if(t.resolveId(n[s],s,n)===e.id)return s;return r}case 5:return null;default:tGe(e)}}function oce(e){let t=Ln(e),n=v.useRef(!1);v.useEffect(()=>(n.current=!1,()=>{n.current=!0,Rle(()=>{n.current&&t()})}),[t])}let nGe=v.createContext(!1);function rGe(){return v.useContext(nGe)}function oGe(e){let t=rGe(),n=v.useContext(ice),[r,o]=v.useState(()=>{var s;if(!t&&n!==null)return(s=n.current)!=null?s:null;if(Gh.isServer)return null;let i=e==null?void 0:e.getElementById("headlessui-portal-root");if(i)return i;if(e===null)return null;let a=e.createElement("div");return a.setAttribute("id","headlessui-portal-root"),e.body.appendChild(a)});return v.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),v.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),r}let sce=v.Fragment,sGe=gl(function(e,t){let{ownerDocument:n=null,...r}=e,o=v.useRef(null),s=Bu(vWe(h=>{o.current=h}),t),i=VP(o.current),a=n??i,c=oGe(a),u=v.useContext(cGe),d=Hb(),f=pl();return oce(()=>{var h;c&&c.childNodes.length<=0&&((h=c.parentElement)==null||h.removeChild(c))}),c?br.createPortal(v.createElement("div",{"data-headlessui-portal":"",ref:h=>{d.dispose(),u&&h&&d.add(u.register(h))}},f({ourProps:{ref:s},theirProps:r,slot:{},defaultTag:sce,name:"Portal"})),c):null});function iGe(e,t){let n=Bu(t),{enabled:r=!0,ownerDocument:o,...s}=e,i=pl();return r?v.createElement(sGe,{...s,ownerDocument:o,ref:n}):i({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:sce,name:"Portal"})}let aGe=v.Fragment,ice=v.createContext(null);function lGe(e,t){let{target:n,...r}=e,o={ref:Bu(t)},s=pl();return v.createElement(ice.Provider,{value:n},s({ourProps:o,theirProps:r,defaultTag:aGe,name:"Popover.Group"}))}let cGe=v.createContext(null),uGe=gl(iGe),dGe=gl(lGe),fGe=Object.assign(uGe,{Group:dGe});const by={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function ace(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function hGe(e,t,n){let r=Da();if(t.kind==="Tracked"){let o=function(){s!==ace(e)&&(r.dispose(),n())},{position:s}=t,i=new ResizeObserver(o);i.observe(e),r.add(()=>i.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}var mGe=Object.defineProperty,pGe=(e,t,n)=>t in e?mGe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pq=(e,t,n)=>(pGe(e,typeof t!="symbol"?t+"":t,n),n),Dn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Dn||{}),Fi=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Fi||{}),Xl=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(Xl||{}),lce=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(lce||{});function cM(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),o=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):XWe(r,i=>i.dataRef.current.domRef.current),s=n?o.indexOf(n):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let gGe={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?by.Tracked(ace(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1,inputPositionState:by.Idle}}return{...e,comboboxState:0,inputPositionState:by.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,o,s;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:u,disabled:d}=e.virtual,f=t.focus===Po.Specific?t.idx:Aq(t,{resolveItems:()=>u,resolveActiveIndex:()=>{var m,g;return(g=(m=e.activeOptionIndex)!=null?m:u.findIndex(b=>!d(b)))!=null?g:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=cM(e);if(i.activeOptionIndex===null){let u=i.options.findIndex(d=>!d.dataRef.current.disabled);u!==-1&&(i.activeOptionIndex=u)}let a=t.focus===Po.Specific?t.idx:Aq(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),c=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===a&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:c,__demoMode:!1}},4:(e,t)=>{var n,r,o,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let i=t.payload,a=cM(e,u=>(u.push(i),u));e.activeOptionIndex===null&&(o=(r=e.dataRef.current).isSelected)!=null&&o.call(r,t.payload.dataRef.current.value)&&(a.activeOptionIndex=a.options.indexOf(i));let c={...e,...a,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(o=>o.id!==t.id)};let r=cM(e,o=>{let s=o.findIndex(i=>i.id===t.id);return s!==-1&&o.splice(s,1),o});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:by.Moved}}};class C$ extends Kle{constructor(t){super(t),Pq(this,"actions",{onChange:n=>{let{onChange:r,compare:o,mode:s,value:i}=this.state.dataRef.current;return ac(s,{0:()=>r==null?void 0:r(n),1:()=>{let a=i.slice(),c=a.findIndex(u=>o(u,n));return c===-1?a.push(n):a.splice(c,1),r==null?void 0:r(a)}})},registerOption:(n,r)=>(this.send({type:4,payload:{id:n,dataRef:r}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(r.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:n})}),goToOption:(n,r)=>(this.send({type:6,value:!1}),this.send({type:2,...n,trigger:r})),setIsTyping:n=>{this.send({type:3,isTyping:n})},closeCombobox:()=>{var n,r;this.send({type:1}),this.send({type:6,value:!1}),(r=(n=this.state.dataRef.current).onClose)==null||r.call(n)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:n=>{this.send({type:7,trigger:n})},selectActiveOption:()=>{let n=this.selectors.activeOptionIndex(this.state);if(n!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[n]);else{let{dataRef:r}=this.state.options[n];this.actions.onChange(r.current.value)}this.actions.goToOption({focus:Po.Specific,idx:n})}},setInputElement:n=>{this.send({type:9,element:n})},setButtonElement:n=>{this.send({type:10,element:n})},setOptionsElement:n=>{this.send({type:11,element:n})}}),Pq(this,"selectors",{activeDescendantId:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);if(s!==null)return n.virtual?(o=n.options.find(i=>!i.dataRef.current.disabled&&n.dataRef.current.compare(i.dataRef.current.value,n.virtual.options[s])))==null?void 0:o.id:(r=n.options[s])==null?void 0:r.id},activeOptionIndex:n=>{if(n.defaultToFirstOption&&n.activeOptionIndex===null&&(n.virtual?n.virtual.options.length>0:n.options.length>0)){if(n.virtual){let{options:o,disabled:s}=n.virtual,i=o.findIndex(a=>{var c;return!((c=s==null?void 0:s(a))!=null&&c)});if(i!==-1)return i}let r=n.options.findIndex(o=>!o.dataRef.current.disabled);if(r!==-1)return r}return n.activeOptionIndex},activeOption:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);return s===null?null:n.virtual?n.virtual.options[s??0]:(o=(r=n.options[s])==null?void 0:r.dataRef.current.value)!=null?o:null},isActive:(n,r,o)=>{var s;let i=this.selectors.activeOptionIndex(n);return i===null?!1:n.virtual?i===n.dataRef.current.calculateIndex(r):((s=n.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(n,r,o)=>!(n.virtual||n.__demoMode||n.comboboxState!==0||n.activationTrigger===0||!this.selectors.isActive(n,r,o)),didInputMove(n){return n.inputPositionState.kind==="Moved"}});{let n=this.state.id,r=y$.get(null);this.disposables.add(r.on(Yle.Push,o=>{!r.selectors.isTop(o,n)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>r.actions.push(n)),this.on(1,()=>r.actions.pop(n))}this.disposables.group(n=>{this.on(1,r=>{r.inputElement&&(n.dispose(),n.add(hGe(r.inputElement,r.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){var o;return new C$({id:t,dataRef:{current:{}},comboboxState:r?0:1,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:(o=n.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:by.Idle})}reduce(t,n){return ac(n.type,gGe,t,n)}}const cce=v.createContext(null);function Rw(e){let t=v.useContext(cce);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,uce),n}return t}function uce({id:e,virtual:t=null,__demoMode:n=!1}){let r=v.useMemo(()=>C$.new({id:e,virtual:t,__demoMode:n}),[]);return oce(()=>r.dispose()),r}let Q0=v.createContext(null);Q0.displayName="ComboboxDataContext";function qb(e){let t=v.useContext(Q0);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,qb),n}return t}let dce=v.createContext(null);function bGe(e){let t=Rw("VirtualProvider"),n=qb("VirtualProvider"),{options:r}=n.virtual,o=Bo(t,m=>m.optionsElement),[s,i]=v.useMemo(()=>{let m=o;if(!m)return[0,0];let g=window.getComputedStyle(m);return[parseFloat(g.paddingBlockStart||g.paddingTop),parseFloat(g.paddingBlockEnd||g.paddingBottom)]},[o]),a=uI({enabled:r.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:r.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[c,u]=v.useState(0);vo(()=>{u(m=>m+1)},[r]);let d=a.getVirtualItems(),f=Bo(t,m=>m.activationTrigger===Xl.Pointer),h=Bo(t,t.selectors.activeOptionIndex);return d.length===0?null:v.createElement(dce.Provider,{value:a},v.createElement("div",{style:{position:"relative",width:"100%",height:`${a.getTotalSize()}px`},ref:m=>{m&&(f||h!==null&&r.length>h&&a.scrollToIndex(h))}},d.map(m=>{var g;return v.createElement(v.Fragment,{key:m.key},v.cloneElement((g=e.children)==null?void 0:g.call(e,{...e.slot,option:r[m.index]}),{key:`${c}-${m.key}`,"data-index":m.index,"aria-setsize":r.length,"aria-posinset":m.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${m.start}px)`,overflowAnchor:"none"}}))})))}let xGe=v.Fragment;function yGe(e,t){let n=v.useId(),r=m$(),{value:o,defaultValue:s,onChange:i,form:a,name:c,by:u,invalid:d=!1,disabled:f=r||!1,onClose:h,__demoMode:m=!1,multiple:g=!1,immediate:b=!1,virtual:x=null,nullable:y,...w}=e,C=iWe(s),[N=g?[]:void 0,S]=sWe(o,i,C),j=uce({id:n,virtual:x,__demoMode:m}),_=v.useRef({static:!1,hold:!1}),k=DWe(u),T=Ln(O=>x?u===null?x.options.indexOf(O):x.options.findIndex(q=>k(q,O)):j.state.options.findIndex(q=>k(q.dataRef.current.value,O))),I=v.useCallback(O=>ac(R.mode,{[Fi.Multi]:()=>N.some(q=>k(q,O)),[Fi.Single]:()=>k(N,O)}),[N]),E=Bo(j,O=>O.virtual),D=Ln(()=>h==null?void 0:h()),R=v.useMemo(()=>({__demoMode:m,immediate:b,optionsPropsRef:_,value:N,defaultValue:C,disabled:f,invalid:d,mode:g?Fi.Multi:Fi.Single,virtual:x?E:null,onChange:S,isSelected:I,calculateIndex:T,compare:k,onClose:D}),[m,b,_,N,C,f,d,g,x,E,S,I,T,k,D]);vo(()=>{var O;x&&j.send({type:lce.UpdateVirtualConfiguration,options:x.options,disabled:(O=x.disabled)!=null?O:null})},[x,x==null?void 0:x.options,x==null?void 0:x.disabled]),vo(()=>{j.state.dataRef.current=R},[R]);let[A,F,z,L]=Bo(j,O=>[O.comboboxState,O.buttonElement,O.inputElement,O.optionsElement]),$=y$.get(null),H=Bo($,v.useCallback(O=>$.selectors.isTop(O,n),[$,n]));eKe(H,[F,z,L],()=>j.actions.closeCombobox());let M=Bo(j,j.selectors.activeOptionIndex),B=Bo(j,j.selectors.activeOption),W=np({open:A===Dn.Open,disabled:f,invalid:d,activeIndex:M,activeOption:B,value:N}),[P,G]=jWe(),Z=t===null?{}:{ref:t},X=v.useCallback(()=>{if(C!==void 0)return S==null?void 0:S(C)},[S,C]),Y=pl();return v.createElement(G,{value:P,props:{htmlFor:z==null?void 0:z.id},slot:{open:A===Dn.Open,disabled:f}},v.createElement(KKe,null,v.createElement(Q0.Provider,{value:R},v.createElement(cce.Provider,{value:j},v.createElement(JKe,{value:ac(A,{[Dn.Open]:X0.Open,[Dn.Closed]:X0.Closed})},c!=null&&v.createElement(fWe,{disabled:f,data:N!=null?{[c]:N}:{},form:a,onReset:X}),Y({ourProps:Z,theirProps:w,slot:W,defaultTag:xGe,name:"Combobox"}))))))}let vGe="input";function wGe(e,t){var n,r;let o=Rw("Combobox.Input"),s=qb("Combobox.Input"),i=v.useId(),a=$le(),{id:c=a||`headlessui-combobox-input-${i}`,onChange:u,displayValue:d,disabled:f=s.disabled||!1,autoFocus:h=!1,type:m="text",...g}=e,b=v.useRef(null),x=Bu(b,t,qKe(),o.actions.setInputElement),[y,w]=Bo(o,W=>[W.comboboxState,W.isTyping]),C=Hb(),N=Ln(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:Po.Nothing})}),S=v.useMemo(()=>{var W;return typeof d=="function"&&s.value!==void 0?(W=d(s.value))!=null?W:"":typeof s.value=="string"?s.value:""},[s.value,d]);kq(([W,P],[G,Z])=>{if(o.state.isTyping)return;let X=b.current;X&&((Z===Dn.Open&&P===Dn.Closed||W!==G)&&(X.value=W),requestAnimationFrame(()=>{if(o.state.isTyping||!X||Mle(X))return;let{selectionStart:Y,selectionEnd:O}=X;Math.abs((O??0)-(Y??0))===0&&Y===0&&X.setSelectionRange(X.value.length,X.value.length)}))},[S,y,w]),kq(([W],[P])=>{if(W===Dn.Open&&P===Dn.Closed){if(o.state.isTyping)return;let G=b.current;if(!G)return;let Z=G.value,{selectionStart:X,selectionEnd:Y,selectionDirection:O}=G;G.value="",G.value=Z,O!==null?G.setSelectionRange(X,Y,O):G.setSelectionRange(X,Y)}},[y]);let j=v.useRef(!1),_=Ln(()=>{j.current=!0}),k=Ln(()=>{C.nextFrame(()=>{j.current=!1})}),T=Ln(W=>{switch(o.actions.setIsTyping(!0),W.key){case Ws.Enter:if(o.state.comboboxState!==Dn.Open||j.current)return;if(W.preventDefault(),W.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===Fi.Single&&o.actions.closeCombobox();break;case Ws.ArrowDown:return W.preventDefault(),W.stopPropagation(),ac(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:Po.Next}),[Dn.Closed]:()=>o.actions.openCombobox()});case Ws.ArrowUp:return W.preventDefault(),W.stopPropagation(),ac(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:Po.Previous}),[Dn.Closed]:()=>{br.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:Po.Last})}});case Ws.Home:if(o.state.comboboxState===Dn.Closed||W.shiftKey)break;return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.First});case Ws.PageUp:return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.First});case Ws.End:if(o.state.comboboxState===Dn.Closed||W.shiftKey)break;return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.Last});case Ws.PageDown:return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.Last});case Ws.Escape:return o.state.comboboxState!==Dn.Open?void 0:(W.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&W.stopPropagation(),s.mode===Fi.Single&&s.value===null&&N(),o.actions.closeCombobox());case Ws.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==Dn.Open)return;s.mode===Fi.Single&&o.state.activationTrigger!==Xl.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),I=Ln(W=>{u==null||u(W),s.mode===Fi.Single&&W.target.value===""&&N(),o.actions.openCombobox()}),E=Ln(W=>{var P,G,Z;let X=(P=W.relatedTarget)!=null?P:oh.find(Y=>Y!==W.currentTarget);if(!((G=o.state.optionsElement)!=null&&G.contains(X))&&!((Z=o.state.buttonElement)!=null&&Z.contains(X))&&o.state.comboboxState===Dn.Open)return W.preventDefault(),s.mode===Fi.Single&&s.value===null&&N(),o.actions.closeCombobox()}),D=Ln(W=>{var P,G,Z;let X=(P=W.relatedTarget)!=null?P:oh.find(Y=>Y!==W.currentTarget);(G=o.state.buttonElement)!=null&&G.contains(X)||(Z=o.state.optionsElement)!=null&&Z.contains(X)||s.disabled||s.immediate&&o.state.comboboxState!==Dn.Open&&C.microTask(()=>{br.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(Xl.Focus)})}),R=RI(),A=wWe(),{isFocused:F,focusProps:z}=Dle({autoFocus:h}),{isHovered:L,hoverProps:$}=Ele({isDisabled:f}),H=Bo(o,W=>W.optionsElement),M=np({open:y===Dn.Open,disabled:f,invalid:s.invalid,hover:L,focus:F,autofocus:h}),B=p$({ref:x,id:c,role:"combobox",type:m,"aria-controls":H==null?void 0:H.id,"aria-expanded":y===Dn.Open,"aria-activedescendant":Bo(o,o.selectors.activeDescendantId),"aria-labelledby":R,"aria-describedby":A,"aria-autocomplete":"list",defaultValue:(r=(n=e.defaultValue)!=null?n:s.defaultValue!==void 0?d==null?void 0:d(s.defaultValue):null)!=null?r:s.defaultValue,disabled:f||void 0,autoFocus:h,onCompositionStart:_,onCompositionEnd:k,onKeyDown:T,onChange:I,onFocus:D,onBlur:E},z,$);return pl()({ourProps:B,theirProps:g,slot:M,defaultTag:vGe,name:"Combobox.Input"})}let CGe="button";function SGe(e,t){let n=Rw("Combobox.Button"),r=qb("Combobox.Button"),[o,s]=v.useState(null),i=Bu(t,s,n.actions.setButtonElement),a=v.useId(),{id:c=`headlessui-combobox-button-${a}`,disabled:u=r.disabled||!1,autoFocus:d=!1,...f}=e,[h,m,g]=Bo(n,D=>[D.comboboxState,D.inputElement,D.optionsElement]),b=ece(m),x=h===Dn.Open;rKe(x,{trigger:o,action:v.useCallback(D=>{if(o!=null&&o.contains(D.target)||m!=null&&m.contains(D.target))return Ax.Ignore;let R=D.target.closest('[role="option"]:not([data-disabled])');return kf(R)?Ax.Select(R):g!=null&&g.contains(D.target)?Ax.Ignore:Ax.Close},[o,m,g]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let y=Ln(D=>{switch(D.key){case Ws.Space:case Ws.Enter:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&br.flushSync(()=>n.actions.openCombobox()),b();return;case Ws.ArrowDown:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(br.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:Po.First})),b();return;case Ws.ArrowUp:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(br.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:Po.Last})),b();return;case Ws.Escape:if(n.state.comboboxState!==Dn.Open)return;D.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&D.stopPropagation(),br.flushSync(()=>n.actions.closeCombobox()),b();return;default:return}}),w=MWe(()=>{n.state.comboboxState===Dn.Open?n.actions.closeCombobox():n.actions.openCombobox(),b()}),C=RI([c]),{isFocusVisible:N,focusProps:S}=Dle({autoFocus:d}),{isHovered:j,hoverProps:_}=Ele({isDisabled:u}),{pressed:k,pressProps:T}=XUe({disabled:u}),I=np({open:h===Dn.Open,active:k||h===Dn.Open,disabled:u,invalid:r.invalid,value:r.value,hover:j,focus:N}),E=p$({ref:i,id:c,type:sKe(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":g==null?void 0:g.id,"aria-expanded":h===Dn.Open,"aria-labelledby":C,disabled:u||void 0,autoFocus:d,onKeyDown:y},w,S,_,T);return pl()({ourProps:E,theirProps:f,slot:I,defaultTag:CGe,name:"Combobox.Button"})}let NGe="div",jGe=OP.RenderStrategy|OP.Static;function kGe(e,t){var n,r,o;let s=v.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:a=!1,anchor:c,portal:u=!1,modal:d=!0,transition:f=!1,...h}=e,m=Rw("Combobox.Options"),g=qb("Combobox.Options"),b=HKe(c);b&&(u=!0);let[x,y]=WKe(b),[w,C]=v.useState(null),N=UKe(),S=Bu(t,b?x:null,m.actions.setOptionsElement,C),[j,_,k,T,I]=Bo(m,V=>[V.comboboxState,V.inputElement,V.buttonElement,V.optionsElement,V.activationTrigger]),E=VP(_||k),D=VP(T),R=QKe(),[A,F]=bKe(f,w,R!==null?(R&X0.Open)===X0.Open:j===Dn.Open);UWe(A,_,m.actions.closeCombobox);let z=g.__demoMode?!1:d&&j===Dn.Open;fKe(z,D);let L=g.__demoMode?!1:d&&j===Dn.Open;qWe(L,{allowed:v.useCallback(()=>[_,k,T],[_,k,T])});let $=Bo(m,m.selectors.didInputMove)?!1:A;vo(()=>{var V;g.optionsPropsRef.current.static=(V=e.static)!=null?V:!1},[g.optionsPropsRef,e.static]),vo(()=>{g.optionsPropsRef.current.hold=a},[g.optionsPropsRef,a]),CKe(j===Dn.Open,{container:T,accept(V){return V.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:V.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(V){V.setAttribute("role","none")}});let H=RI([k==null?void 0:k.id]),M=np({open:j===Dn.Open,option:void 0}),B=Ln(()=>{m.actions.setActivationTrigger(Xl.Pointer)}),W=Ln(V=>{V.preventDefault(),m.actions.setActivationTrigger(Xl.Pointer)}),P=p$(b?N():{},{"aria-labelledby":H,role:"listbox","aria-multiselectable":g.mode===Fi.Multi?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":fq(A,_,!0).width,"--button-width":fq(A,k,!0).width},onWheel:I===Xl.Pointer?void 0:B,onMouseDown:W,...gKe(F)}),G=A&&j===Dn.Closed&&!e.static,Z=qP(G,(n=g.virtual)==null?void 0:n.options),X=qP(G,g.value),Y=v.useCallback(V=>g.compare(X,V),[g.compare,X]),O=v.useMemo(()=>{if(!g.virtual)return g;if(Z===void 0)throw new Error("Missing `options` in virtual mode");return Z!==g.virtual.options?{...g,virtual:{...g.virtual,options:Z}}:g},[g,Z,(r=g.virtual)==null?void 0:r.options]);g.virtual&&Object.assign(h,{children:v.createElement(Q0.Provider,{value:O},v.createElement(bGe,{slot:M},h.children))});let q=pl(),U=v.useMemo(()=>g.mode===Fi.Multi?g:{...g,isSelected:Y},[g,Y]);return v.createElement(fGe,{enabled:u?e.static||A:!1,ownerDocument:E},v.createElement(Q0.Provider,{value:U},q({ourProps:P,theirProps:{...h,children:v.createElement(XKe,{freeze:G},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,M):h.children)},slot:M,defaultTag:NGe,features:jGe,visible:$,name:"Combobox.Options"})))}let _Ge="div";function IGe(e,t){var n,r,o;let s=qb("Combobox.Option"),i=Rw("Combobox.Option"),a=v.useId(),{id:c=`headlessui-combobox-option-${a}`,value:u,disabled:d=(o=(r=(n=s.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,u))!=null?o:!1,order:f=null,...h}=e,[m]=Bo(i,F=>[F.inputElement]),g=ece(m),b=Bo(i,v.useCallback(F=>i.selectors.isActive(F,u,c),[u,c])),x=s.isSelected(u),y=v.useRef(null),w=tp({disabled:d,value:u,domRef:y,order:f}),C=v.useContext(dce),N=Bu(t,y,C?C.measureElement:null),S=Ln(()=>{i.actions.setIsTyping(!1),i.actions.onChange(u)});vo(()=>i.actions.registerOption(c,w),[w,c]);let j=Bo(i,v.useCallback(F=>i.selectors.shouldScrollIntoView(F,u,c),[u,c]));vo(()=>{if(j)return Da().requestAnimationFrame(()=>{var F,z;(z=(F=y.current)==null?void 0:F.scrollIntoView)==null||z.call(F,{block:"nearest"})})},[j,y]);let _=Ln(F=>{F.preventDefault(),F.button===x$.Left&&(d||(S(),BP()||requestAnimationFrame(()=>g()),s.mode===Fi.Single&&i.actions.closeCombobox()))}),k=Ln(()=>{if(d)return i.actions.goToOption({focus:Po.Nothing});let F=s.calculateIndex(u);i.actions.goToOption({focus:Po.Specific,idx:F})}),T=hKe(),I=Ln(F=>T.update(F)),E=Ln(F=>{if(!T.wasMoved(F)||d||b&&i.state.activationTrigger===Xl.Pointer)return;let z=s.calculateIndex(u);i.actions.goToOption({focus:Po.Specific,idx:z},Xl.Pointer)}),D=Ln(F=>{T.wasMoved(F)&&(d||b&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===Xl.Pointer&&i.actions.goToOption({focus:Po.Nothing})))}),R=np({active:b,focus:b,selected:x,disabled:d}),A={id:c,ref:N,role:"option",tabIndex:d===!0?void 0:-1,"aria-disabled":d===!0?!0:void 0,"aria-selected":x,disabled:void 0,onMouseDown:_,onFocus:k,onPointerEnter:I,onMouseEnter:I,onPointerMove:E,onMouseMove:E,onPointerLeave:D,onMouseLeave:D};return pl()({ourProps:A,theirProps:h,slot:R,defaultTag:_Ge,name:"Combobox.Option"})}let TGe=gl(yGe),fce=gl(SGe),hce=gl(wGe),EGe=TWe,mce=gl(kGe),pce=gl(IGe),DGe=Object.assign(TGe,{Input:hce,Button:fce,Label:EGe,Options:mce,Option:pce});const MGe="var(--semaphor-control-radius, var(--radius, 0.3125rem))",UP="max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)",RGe="var(--semaphor-radius, var(--semaphor-control-radius, var(--radius, 0.3125rem)))",AGe=v.memo(({option:e})=>l.jsxs(pce,{style:{borderRadius:UP},value:e,className:p.cn("group mx-1 my-1 flex cursor-default select-none items-center gap-3 px-3 py-2.5","text-sm text-foreground transition-colors","data-[selected]:bg-primary/8 data-[focus]:bg-muted/80 data-[selected]:text-foreground"),children:[l.jsx("span",{className:p.cn("flex size-5 shrink-0 items-center justify-center rounded-full border border-border bg-background text-transparent transition-colors","group-data-[selected]:border-primary group-data-[selected]:bg-primary group-data-[selected]:text-primary-foreground","group-data-[focus]:border-muted-foreground/60"),children:l.jsx(p.Check,{className:"size-3.5"})}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.value})]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value),gce=v.forwardRef(({className:e,style:t,children:n,...r},o)=>{const{scopeProps:s}=p.useAppearance();return l.jsx("div",{className:p.cn("semaphor-scope",s.className),"data-semaphor-theme":s["data-semaphor-theme"],"data-semaphor-appearance-instance":s["data-semaphor-appearance-instance"],style:s.style,children:l.jsx("div",{ref:o,className:e,style:t,...r,children:n})})});gce.displayName="ScopedComboboxOptionsPanel";function PGe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:o,selectAllChecked:s,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:c,showNegativeIndicator:u,isSearching:d,isLoadingOptions:f=!1,resultSource:h="local",searchError:m,query:g,onQueryChange:b,filterDataType:x,onEnterKey:y,activeFilterValue:w,filterTitle:C,onClear:N,hasActiveFilter:S,placeholder:j,closedDisplayFallback:_,searchPlaceholder:k,selectedCount:T=0}){const[I,E]=v.useState(""),D=v.useRef(null),[R,A]=v.useState(null),F=g!==void 0?g:I,z=b||E,L=o||e;v.useLayoutEffect(()=>{const O=D.current;if(!O)return;const q=()=>{const V=Math.ceil(O.getBoundingClientRect().width);A(K=>K===V?K:V)};if(q(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(()=>{q()});return U.observe(O),()=>{U.disconnect()}},[]);function $(O,q){if(q)return"";const U=[">","<",">=","<=","="];if((x?p.isNumberDataType(x):!1)&&w&&U.includes(w.operation))return`${w.operation}${w.values[0]}`;if(_)return _;const K=Array.isArray(O)?O:O?[O]:[];return K.length?K.map(Q=>Q.value).join(", "):""}function H(O){if(O===null){t([]);return}Array.isArray(O)||(O=[O]),t(O)}const M=r?n:n[0]??null;function B(){return d||f||L&&L.length>0?null:l.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function W(){return d&&(L==null?void 0:L.length)>0?l.jsxs("div",{className:"mx-1 mb-2 flex items-center gap-2 rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):m&&F?l.jsx("div",{className:"mx-1 mb-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600 dark:text-amber-400",children:"Search unavailable. Showing available results."}):null}function P(){return f?l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((O,q)=>l.jsx("div",{style:{borderRadius:UP},className:"h-11 bg-muted/70","aria-hidden":"true"},q))})]}):!d||(L==null?void 0:L.length)>0?null:l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((O,q)=>l.jsx("div",{style:{borderRadius:UP},className:"h-11 bg-muted/70","aria-hidden":"true"},q))})]})}function G(){return null}function Z(){return!r||!(L!=null&&L.length)||f?null:l.jsxs("div",{className:"flex items-center justify-between gap-3 border-y border-border/80 px-5 py-3",children:[c==null?void 0:c(),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-muted-foreground",children:"All"}),l.jsx(Tn,{className:"size-5 rounded-control border-input text-primary data-[state=checked]:bg-primary",checked:s,onCheckedChange:i})]})]})}function X(){return C?l.jsxs("div",{className:"flex items-center justify-between px-5 pb-3 pt-4",children:[l.jsx("span",{className:"text-[15px] font-semibold text-foreground",children:C}),S&&N&&l.jsx("button",{onClick:O=>{O.stopPropagation(),N()},className:"text-sm font-medium text-muted-foreground transition-colors hover:text-foreground","aria-label":"Clear filter",children:"Clear all"})]}):null}function Y(){if(!r||f)return null;const O=Math.max(T,n.length);return l.jsx("div",{className:"border-t border-border/80 bg-muted/35 px-5 py-3 text-sm text-muted-foreground",children:`${O} selected`})}return l.jsx(DGe,{immediate:!0,multiple:r,value:M,onChange:H,onClose:()=>{z("")},by:(O,q)=>Array.isArray(O)||Array.isArray(q)?!1:!O||!q?O===q:O.id===q.id,children:({open:O})=>l.jsxs("div",{children:[l.jsxs("div",{ref:D,className:"relative flex items-center gap-0.5",children:[l.jsx(Ft.Search,{className:"pointer-events-none absolute left-3 size-4 text-muted-foreground"}),l.jsx(hce,{className:p.cn("h-10 w-full cursor-default border border-input bg-background py-2 pl-10 pr-10 text-sm text-foreground shadow-sm transition-colors","hover:border-input/80 focus:border-ring",u&&"border-destructive/35 bg-destructive/[0.03] hover:border-destructive/45 focus:border-destructive/45","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:MGe},placeholder:O?k||"Search options...":j,displayValue:q=>$(q,O),onChange:q=>z(q.target.value),onKeyDown:q=>{if(q.key==="Enter"&&y){const U=/^(>=|<=|>|<|=)/.test(F.trim()),V=x?p.isNumberDataType(x):!1;U&&V&&(q.preventDefault(),y()&&q.target.blur())}}}),l.jsx(fce,{className:"group absolute inset-y-0 right-0 px-2.5",children:l.jsx(je.ChevronDown,{className:"size-4 text-muted-foreground transition-colors group-hover:text-foreground"})})]}),l.jsxs(mce,{as:gce,anchor:"bottom",transition:!0,style:{borderRadius:RGe,width:R?`${R}px`:"16rem"},className:p.clsx$1("mt-2 overflow-hidden border border-border/80 bg-popover text-sm text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] [--anchor-gap:var(--spacing-2)] empty:invisible dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[X(),Z(),l.jsxs("div",{className:"max-h-72 overflow-y-auto px-2 py-2",children:[W(),P(),G(),B(),!f&&(L==null?void 0:L.map(q=>l.jsx(AGe,{option:q},q.id)))]}),Y()]})]})})}const Fq=[{value:"=",label:"Equal to",symbol:"="},{value:">",label:"Greater than",symbol:">"},{value:">=",label:"Greater than or equal",symbol:"≥"},{value:"<",label:"Less than",symbol:"<"},{value:"<=",label:"Less than or equal",symbol:"≤"},{value:"between",label:"Between",symbol:"⟷"},{value:"not between",label:"Not Between",symbol:"⇎"}],FGe=new Set(["=",">","<",">=","<=","between","not between"]);function OGe(e){return FGe.has(e)?e:">="}function LGe({filter:e,storageOptions:t}){var G;const{cardId:n,dashboardInput:r,inlineFilterValues:o,removeInlineFilterValue:s,sheetId:i,setInlineFilterValue:a,storageTarget:c}=t??{},u=c==="card",d=c==="dashboardInput",[f,h]=v.useState(">="),[m,g]=v.useState(""),[b,x]=v.useState(""),[y,w]=v.useState(""),[C,N]=v.useState(!0),S=v.useRef(null),j=v.useRef(!1),[,_]=v.useTransition(),k=Jy(m,300),T=Jy(b,300),I=Jy(y,300),E=p.useDashboardStore(Z=>Z.filterValues),D=p.useDashboardStore(Z=>Z.dashboard),R=p.useDashboardStore(Z=>Z.dashboardInputValues);p.useDashboardStore(Z=>Z.themeStyle);const A=p.useDashboardStore(Z=>Z.actions.setDashboardInputSlot),F=p.useDashboardStore(Z=>Z.actions.clearDashboardInputSlot),z=p.useDashboardStore(Z=>Z.actions.setCardInlineFilterValue),L=p.useDashboardStore(Z=>Z.actions.removeCardInlineFilterValue),{addOrUpdateFilterValue:$,removeFilterValues:H}=p.useDashboardActions(),M=v.useMemo(()=>{if(!d||!r)return;const Z=p.hydrateAuthoredDashboardInputSlot({dashboard:D,input:r,runtimeValues:R,target:{sheetId:i}});return(Z==null?void 0:Z.status)==="set"&&Z.value.kind==="filter"?Z.value.filterValue:void 0},[D,R,d,r,i]),B=v.useMemo(()=>d?M?[M]:[]:u?o:E,[E,M,o,u,d]),W=v.useCallback(Z=>{if(d){if(!r)return;const X=p.createFilterDashboardInputSlot(Z);if(!X)return;A(r,{sheetId:i},X);return}if(u){if(a){a(Z);return}z(n??"",Z)}else $(Z)},[d,r,i,A,u,a,z,n,$]),P=v.useCallback(()=>{if(d){if(!r)return;F(r,{sheetId:i});return}if(u){if(s){s(e.id);return}L(n??"",e.id)}else H(e.id)},[d,r,i,F,u,e.id,s,L,n,H]);return v.useEffect(()=>()=>{S.current=null,j.current=!1},[]),v.useEffect(()=>{const Z=B==null?void 0:B.find(X=>X.filterId===e.id);if(Z&&Z.operation!=="in"){const X=OGe(Z.operation);if(S.current!==X&&(h(X),S.current=X,j.current=!1),X==="between"||X==="not between"){const O=Z.values[0],q=Z.values[1];x(O!=null?String(O):""),w(q!=null?String(q):""),g("")}else{const O=Z.values[0];g(O!=null?String(O):""),x(""),w("")}}else S.current!==null&&(g(""),x(""),w(""),!j.current&&S.current!==f&&(h(">="),j.current=!1),S.current=null),N(!1)},[B,e.id,f]),v.useEffect(()=>{C&&(f==="between"||f==="not between"?T===b&&I===y&&N(!1):k===m&&N(!1))},[C,f,m,k,b,y,T,I]),v.useEffect(()=>{if(!C)if(f==="between"||f==="not between"){const Z=T&&T.trim()!=="",X=I&&I.trim()!=="";if(!Z||!X){!Z&&!X&&(_(()=>{P()}),S.current=f);return}const Y=Number(T),O=Number(I);if(isNaN(Y)||isNaN(O))return;const q={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[Y,O],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};_(()=>{W(q)}),S.current=f}else{if(!k||k.trim()===""){_(()=>{P()}),S.current=null;return}const Z=Number(k);if(isNaN(Z))return;const X={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[Z],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};_(()=>{W(X)}),S.current=f}},[f,k,T,I,e.id,e.column,e.database,C,W,P,e]),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs(p.Select,{value:f,onValueChange:Z=>{j.current=!0,h(Z)},children:[l.jsx(p.SelectTrigger,{className:"h-7 w-14 shrink-0 border-input bg-background text-[12px]",children:l.jsx("span",{className:"font-mono text-[13px]",children:(G=Fq.find(Z=>Z.value===f))==null?void 0:G.symbol})}),l.jsx(p.SelectContent,{children:Fq.map(Z=>l.jsx(p.SelectItem,{value:Z.value,children:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-mono text-[12px]",children:Z.symbol}),l.jsx("span",{className:"text-[12px]",children:Z.label})]})},Z.value))})]}),f==="between"||f==="not between"?l.jsxs(l.Fragment,{children:[l.jsx(p.Input,{type:"number",placeholder:"Min",value:b,onChange:Z=>x(Z.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"}),l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"–"}),l.jsx(p.Input,{type:"number",placeholder:"Max",value:y,onChange:Z=>w(Z.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]}):l.jsx(p.Input,{type:"number",placeholder:"Value",value:m,onChange:Z=>g(Z.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]})}function S$({isCardStorage:e=!1,message:t="Error",className:n}){return l.jsx("div",{className:p.cn("flex w-full items-center bg-muted px-2 text-sm",e?"h-8":"h-9",n),children:t})}function bce({filter:e,storageOptions:t}){var $,H;const n=e.searchMode==="numeric",r=(t==null?void 0:t.storageTarget)==="card",o=r?"h-8":"h-9",s=r?"h-[31px]":"h-[35px]",{removeFilterValues:i}=p.useDashboardActions(),a=p.useDashboardStore(M=>M.actions.removeCardInlineFilterValue),{filteredRecords:c,isSingleSelect:u,allSelected:d,handleChange:f,handleSelectAll:h,handleApplyOperatorExpression:m,query:g,setQuery:b,isLoading:x,isFetching:y,isPlaceholderData:w,isError:C,selectedRecords:N,isSearching:S,searchError:j,resultSource:_,activeFilterValue:k}=Vb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),I=x||y&&w,E=k&&(k.operation==="in"||k.operation==="not in")&&(($=k.values)!=null&&$.length)?k.values.map(M=>String(M)).join(", "):void 0,D=(k==null?void 0:k.operation)==="not in"||e.operation==="not in",A=`Search ${(e.title||e.column||"options").toLowerCase()}`,{clearDashboardInputSlot:F}=p.useDashboardActions(),z=v.useCallback(()=>{if((t==null?void 0:t.storageTarget)==="dashboardInput"&&t.dashboardInput){F(t.dashboardInput,{sheetId:t.sheetId});return}if((t==null?void 0:t.storageTarget)==="card"&&(t!=null&&t.cardId)){if(t.removeInlineFilterValue){t.removeInlineFilterValue(e.id);return}a(t.cardId,e.id)}else i(e.id)},[t,e.id,F,i,a]);return x&&!E?l.jsx(Xs,{className:p.cn(s,"w-full rounded-control bg-foreground/10")}):C?l.jsx(S$,{isCardStorage:r}):n?l.jsx(LGe,{filter:e,storageOptions:t}):l.jsx(PGe,{showNegativeIndicator:D,renderFilterModeButton:()=>l.jsx(xce,{filter:e,storageOptions:t}),inputClassName:o,options:c,selectedOptions:N,onChange:f,multiple:!u,selectAllChecked:d,onSelectAllCheckedChange:h,isSearching:S,isLoadingOptions:I,resultSource:_,searchError:j,query:g,onQueryChange:b,filterDataType:e.dataType,activeFilterValue:k,onEnterKey:m,filterTitle:e.title||e.column,onClear:z,hasActiveFilter:!!k,placeholder:e.showLabel===!1?e.title||e.column:void 0,closedDisplayFallback:E,searchPlaceholder:A,selectedCount:((H=k==null?void 0:k.values)==null?void 0:H.length)??N.length})}function xce({filter:e,storageOptions:t}){const n={borderRadius:"max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)"},r=(t==null?void 0:t.storageTarget)==="card",o=(t==null?void 0:t.storageTarget)==="dashboardInput",{setFilterMode:s}=p.useDashboardActions(),i=p.useDashboardStore(N=>N.dashboard),a=p.useDashboardStore(N=>N.dashboardInputValues),c=p.useDashboardStore(N=>N.isVisualEditing),u=p.useDashboardStore(N=>N.actions.setDashboardInputSlot),d=p.useDashboardStore(N=>N.actions.upsertDashboardInput),f=p.useDashboardStore(N=>N.actions.setCardInlineFilterMode),h=p.useDashboardStore(N=>N.actions.setCardInlineFilterValue),m=p.useEditorStore(N=>N.card),{setCard:g}=p.useEditorActions(),b=v.useMemo(()=>{if(!o||!(t!=null&&t.dashboardInput))return;const N=p.hydrateAuthoredDashboardInputSlot({dashboard:i,input:t.dashboardInput,runtimeValues:a,target:{sheetId:t.sheetId}});return(N==null?void 0:N.status)==="set"&&N.value.kind==="filter"?N.value.filterValue:void 0},[i,a,o,t==null?void 0:t.dashboardInput,t==null?void 0:t.sheetId]),y=(b&&(b.operation==="in"||b.operation==="not in")?b.operation:e.operation)==="not in"?"exclude":"include";function w(N){var j;if(N===y)return;const S=N==="exclude"?"not in":"in";if(o){if(!(t!=null&&t.dashboardInput)||t.dashboardInput.kind!=="filter")return;const _=t.dashboardInput;if(d({..._,filter:{..._.filter,operation:S}}),(j=b==null?void 0:b.values)!=null&&j.length){const k={...b,operation:S},T=p.createFilterDashboardInputSlot(k);T&&u(_,{sheetId:t.sheetId},T)}return}if(r){if(t!=null&&t.setInlineFilterMode){t.setInlineFilterMode(e.id,N);return}if(c){const _=(m.inlineFilters||[]).map(T=>T.id===e.id?{...T,operation:S}:T);g({...m,inlineFilters:_});const k=C==null?void 0:C.find(T=>T.filterId===e.id);if(k&&(k.operation==="in"||k.operation==="not in")){const T={...k,operation:S};t!=null&&t.setInlineFilterValue?t.setInlineFilterValue(T):h((t==null?void 0:t.cardId)??"",T)}}else f((t==null?void 0:t.sheetId)??"",(t==null?void 0:t.cardId)??"",e.id,N)}else s(e.id,N)}const C=t==null?void 0:t.inlineFilterValues;return l.jsxs("div",{className:"inline-flex items-center gap-0.5 rounded-control bg-muted/80 p-0.5",children:[l.jsx(p.Button,{onClick:()=>w("include"),variant:"ghost",size:"sm",style:n,className:p.cn("h-6 px-3 text-[12px] font-medium leading-none text-muted-foreground",y==="include"&&"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 hover:text-primary-foreground",y!=="include"&&"hover:bg-background/80 hover:text-foreground"),children:"Include"}),l.jsx(p.Button,{onClick:()=>w("exclude"),variant:"ghost",size:"sm",style:n,className:p.cn("h-6 px-3 text-[12px] font-medium leading-none text-muted-foreground",y==="exclude"&&"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:text-destructive-foreground",y!=="exclude"&&"hover:bg-background/80 hover:text-foreground"),children:"Exclude"})]})}function yce({filter:e,storageOptions:t}){var a;const{filteredRecords:n,handleChange:r,selectedRecords:o}=Vb(e,t),s=((a=o==null?void 0:o[0])==null?void 0:a.value)||"";function i(c){r([{value:c,id:c}])}return l.jsx(rl,{onValueChange:i,value:s,className:"flex flex-col gap-0.5",children:n==null?void 0:n.map(c=>{const u=`radio-${e.id}-${c.value}`,d=s===c.value;return l.jsxs(p.Label,{htmlFor:u,className:p.cn("flex w-full cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-[13px] transition-colors",d?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:[l.jsx(vs,{value:c.value,id:u,className:"h-3.5 w-3.5"}),l.jsx("span",{className:"truncate",children:c.value})]},c.value)})})}function vce({filter:e,storageOptions:t}){var h;const n=(t==null?void 0:t.storageTarget)==="card",{filteredRecords:r,handleChange:o,selectedRecords:s,isLoading:i,isFetching:a,isError:c}=Vb(e,t),u=((h=s==null?void 0:s[0])==null?void 0:h.value)||"",d=r&&r.length>10;function f(m){o([{value:m,id:m}])}return i||a?l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((m,g)=>l.jsx(Xs,{className:"h-7 w-full rounded-control bg-foreground/[0.06]"},g))}):c?l.jsx(S$,{isCardStorage:n,message:"Error loading filter options"}):l.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("div",{className:"mb-1 inline-flex items-center gap-1 rounded-[4px] bg-amber-500/10 px-1.5 py-0.5 text-[11px] text-amber-700 dark:text-amber-300",children:[l.jsx(p.Info,{className:"h-3 w-3"}),l.jsxs("span",{children:["Many options (",r.length,")"]})]})}),l.jsx(p.TooltipContent,{side:"bottom",className:"max-w-xs",children:l.jsxs("p",{className:"text-xs",children:["This filter has ",r.length," options. Consider switching to a dropdown for better usability with many options."]})})]})}),l.jsx("div",{role:"radiogroup",className:"flex flex-col gap-0.5",children:r==null?void 0:r.map(m=>{const g=u===m.value;return l.jsx("button",{type:"button",role:"radio","aria-checked":g,onClick:()=>f(m.value),className:p.cn("flex w-full items-center rounded-control px-2 py-1.5 text-left text-[13px] transition-colors",g?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:l.jsx("span",{className:"truncate",children:m.value})},m.value)})})]})}const $Ge=v.createContext(null),uM={didCatch:!1,error:null};class Si extends v.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=uM}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:s,reason:"imperative-api"}),this.setState(uM)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&zGe(t.resetKeys,o)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(uM)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(c);else if(r)a=v.createElement(r,c);else if(o!==void 0)a=o;else throw i}return v.createElement($Ge.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function zGe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function BGe(e,t){const[n,r]=v.useState(t),[o,s]=v.useState(),i=v.useMemo(()=>t,[t]);return v.useEffect(()=>{if(e&&(e==null?void 0:e.length)>0){const a=e[0];if(!a.min||!a.max)return;const c={from:new Date(a.min),to:new Date(a.max)};s(c),i||r(c)}},[e,i]),v.useEffect(()=>{i&&r(i)},[i]),{dateRange:n,setDateRange:r,initialDateRange:o,setInitialDateRange:s}}function VGe(e){const t=p.useDashboardStore(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}=N$(t||{});return r}function N$(e,t){const{cardId:n,dashboardInput:r,filterQueryContext:o,inlineFilterValues:s,removeInlineFilterValue:i,setInlineFilterValue:a,sheetId:c,storageTarget:u}=t??{},d=u==="card",f=u==="dashboardInput",h=p.useDashboardStore(O=>{var q;return((q=O.reportContext)==null?void 0:q.calendar)??null}),m=h==null?void 0:h.tz,g=p.useDashboardStore(O=>O.filterValues),b=p.useDashboardStore(O=>O.dashboard),x=p.useDashboardStore(O=>O.dashboardInputValues),y=v.useMemo(()=>{if(!f||!r)return;const O={sheetId:c};return p.hydrateAuthoredDashboardInputSlot({dashboard:b,input:r,runtimeValues:x,target:O,timezone:m})},[b,x,f,r,c,m]),w=v.useMemo(()=>{if(!(!f||!r))return Yi({dashboard:b,sheetId:c,sheetKind:"dashboard",runtimeValues:{dashboardInputValues:x},timezone:m}).activeFilters},[b,x,f,r,c,m]),C=p.useDashboardStore(O=>O.actions.addOrUpdateFilterValue),N=p.useDashboardStore(O=>O.actions.setDashboardInputSlot),S=p.useDashboardStore(O=>O.actions.clearDashboardInputSlot),j=p.useDashboardStore(O=>O.actions.setCardInlineFilterValue),_=p.useDashboardStore(O=>O.actions.removeCardInlineFilterValue),{removeFilterValues:k}=p.useDashboardActions(),T=(y==null?void 0:y.status)==="set"&&y.value.kind==="filter"?y.value.filterValue:void 0,I=v.useMemo(()=>f?T?[T]:[]:d?s:g,[T,g,s,d,f]),E=I==null?void 0:I.find(O=>O.filterId===e.id),D=v.useMemo(()=>f?{...o,activeFilterValues:w}:o,[w,o,f]),{data:R,isLoading:A,isFetching:F,isError:z}=c$(e,{additionalFilterValues:d?s:void 0,filterQueryContext:D}),L=v.useCallback(O=>{if(f){if(!r)return;const q=p.createFilterDashboardInputSlot(O);if(!q)return;N(r,{sheetId:c},q);return}if(d){if(a){a(O);return}if(!n)return;j(n,O)}else C(O)},[f,r,c,N,d,a,j,n,C]),$=v.useCallback(()=>{if(f){if(!r)return;S(r,{sheetId:c});return}if(d){if(i){i(e.id);return}if(!n)return;_(n,e.id)}else k(e.id)},[f,r,c,S,d,e.id,i,_,n,k]),H=v.useMemo(()=>{const O=U=>{if(!U)return;const V=U instanceof Date?U:new Date(U);return isNaN(V.getTime())?void 0:V};if(!E||!Array.isArray(E.values))return;const q=E.operation;if((q==="between"||q==="not between")&&E.values.length===2){const[U,V]=E.values,K=O(U),Q=O(V);return!K&&!Q?void 0:{from:K,to:Q}}if(["=","!=",">",">=","<","<="].includes(q)&&E.values.length===1){const[U]=E.values,V=O(U);return V?{from:V,to:V}:void 0}},[E]),{dateRange:M,setDateRange:B,initialDateRange:W}=BGe(R==null?void 0:R.records,H);function P(){$(),B(void 0)}function G(){B(W)}function Z(O,q="between",U={}){if(!O)return;if(q==="is null"||q==="is not null"){B(void 0),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:q,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext});return}if(q==="between"||q==="not between"){const K=p.normalizeDateFilterRange(O,{temporalPrecision:U.temporalPrecision});B({from:K.from,to:K.to}),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:q,values:K.values,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...U.temporalPrecision?{temporalPrecision:U.temporalPrecision}:{}});return}const V=O.from||O.to;V&&(B({from:V,to:V}),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:q,values:[V],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...U.temporalPrecision?{temporalPrecision:U.temporalPrecision}:{}}))}function X(O){B(void 0),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:O,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext})}function Y(O,q,U={}){if(!O)return;const V=U.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(q),K=p.normalizeDateFilterRange(O,{temporalPrecision:V});B({from:K.from,to:K.to});const Q={filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:"between",values:K.values,relativeMeta:q,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...V?{temporalPrecision:V}:{}};L(Q)}return{records:R==null?void 0:R.records,isLoading:A,isFetching:F,isError:z,initialDateRange:W,dateRange:M,setDateRange:B,activeFilterValue:E,handleClear:P,handleChange:Z,handleNullOperation:X,handleRelativeChange:Y,handleReset:G}}function Aw(e){var n;const t=e.scheme.tokens;return{colors:[...e.chartPalette],mode:e.mode,appearance:{version:cf.APPEARANCE_SPEC_VERSION,mode:e.mode,colors:Ks(e.colorValues),typography:Ks(t==null?void 0:t.typography),radius:Ks(t==null?void 0:t.radius),spacing:Ks(t==null?void 0:t.spacing),shadow:Ks(t==null?void 0:t.shadow),density:(n=t==null?void 0:t.typography)==null?void 0:n.density,chartPalette:[...e.chartPalette],table:Ks(e.table)}}}function HGe(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const dM={},xy={};function xh(e,t){try{const r=(dM[e]||(dM[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in xy?xy[r]:Oq(r,r.split(":"))}catch{if(e in xy)return xy[e];const n=e==null?void 0:e.match(qGe);return n?Oq(e,n.slice(1)):NaN}}const qGe=/([+-]\d\d):?(\d\d)?/;function Oq(e,t){const n=+(t[0]||0),r=+(t[1]||0),o=+(t[2]||0)/60;return xy[e]=n*60+r>0?n*60+r+o:n*60-r-o}class Vl extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(xh(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),wce(this),WP(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new Vl(...n,t):new Vl(Date.now(),t)}withTimeZone(t){return new Vl(+this,t)}getTimezoneOffset(){const t=-xh(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),WP(this),+this}[Symbol.for("constructDateFrom")](t){return new Vl(+new Date(t),this.timeZone)}}const Lq=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!Lq.test(e))return;const t=e.replace(Lq,"$1UTC");Vl.prototype[t]&&(e.startsWith("get")?Vl.prototype[e]=function(){return this.internal[t]()}:(Vl.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),UGe(this),+this},Vl.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),WP(this),+this}))});function WP(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-xh(e.timeZone,e)*60))}function UGe(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),wce(e)}function wce(e){const t=xh(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const o=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=o-s,a=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&a&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=o-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const u=new Date(+e);u.setUTCSeconds(0);const d=o>0?u.getSeconds():(u.getSeconds()-60)%60,f=Math.round(-(xh(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=xh(e.timeZone,e),m=h>0?Math.floor(h):Math.ceil(h),b=-new Date(+e).getTimezoneOffset()-m,x=m!==n,y=b-c;if(x&&y){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+y);const w=xh(e.timeZone,e),C=w>0?Math.floor(w):Math.ceil(w),N=m-C;N&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+N),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+N))}}class Qc extends Vl{static tz(t,...n){return n.length?new Qc(...n,t):new Qc(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),o=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+o}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,o]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${o}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,o]=this.tzComponents();return`${t} GMT${n}${r}${o} (${HGe(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),o=String(Math.abs(t)%60).padStart(2,"0");return[n,r,o]}withTimeZone(t){return new Qc(+this,t)}[Symbol.for("constructDateFrom")](t){return new Qc(+new Date(t),this.timeZone)}}const Cce=6048e5,WGe=864e5,$q=Symbol.for("constructDateFrom");function wo(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&$q in e?e[$q](t):e instanceof Date?new e.constructor(t):new Date(t)}function hr(e,t){return wo(t||e,e)}function Sce(e,t,n){const r=hr(e,n==null?void 0:n.in);return isNaN(t)?wo(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Nce(e,t,n){const r=hr(e,n==null?void 0:n.in);if(isNaN(t))return wo(e,NaN);if(!t)return r;const o=r.getDate(),s=wo(e,r.getTime());s.setMonth(r.getMonth()+t+1,0);const i=s.getDate();return o>=i?s:(r.setFullYear(s.getFullYear(),s.getMonth(),o),r)}let KGe={};function Pw(){return KGe}function eb(e,t){var a,c,u,d;const n=Pw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=hr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?7:0)+s-r;return o.setDate(o.getDate()-i),o.setHours(0,0,0,0),o}function J0(e,t){return eb(e,{...t,weekStartsOn:1})}function jce(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getFullYear(),o=wo(n,0);o.setFullYear(r+1,0,4),o.setHours(0,0,0,0);const s=J0(o),i=wo(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=J0(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function zq(e){const t=hr(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Ub(e,...t){const n=wo.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function ev(e,t){const n=hr(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function kce(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t),s=ev(r),i=ev(o),a=+s-zq(s),c=+i-zq(i);return Math.round((a-c)/WGe)}function GGe(e,t){const n=jce(e,t),r=wo(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),J0(r)}function YGe(e,t,n){return Sce(e,t*7,n)}function ZGe(e,t,n){return Nce(e,t*12,n)}function XGe(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=wo.bind(null,o));const s=hr(o,r);(!n||n<s||isNaN(+s))&&(n=s)}),wo(r,n||NaN)}function QGe(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=wo.bind(null,o));const s=hr(o,r);(!n||n>s||isNaN(+s))&&(n=s)}),wo(r,n||NaN)}function JGe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t);return+ev(r)==+ev(o)}function _ce(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function eYe(e){return!(!_ce(e)&&typeof e!="number"||isNaN(+hr(e)))}function tYe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t),s=r.getFullYear()-o.getFullYear(),i=r.getMonth()-o.getMonth();return s*12+i}function nYe(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Ice(e,t){const[n,r]=Ub(e,t.start,t.end);return{start:n,end:r}}function rYe(e,t){const{start:n,end:r}=Ice(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setDate(1);let a=1;const c=[];for(;+i<=s;)c.push(wo(n,i)),i.setMonth(i.getMonth()+a);return o?c.reverse():c}function oYe(e,t){const n=hr(e,t==null?void 0:t.in);return n.setDate(1),n.setHours(0,0,0,0),n}function sYe(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Tce(e,t){const n=hr(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function iYe(e,t){const{start:n,end:r}=Ice(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setMonth(0,1);let a=1;const c=[];for(;+i<=s;)c.push(wo(n,i)),i.setFullYear(i.getFullYear()+a);return o?c.reverse():c}function Ece(e,t){var a,c,u,d;const n=Pw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=hr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?-7:0)+6-(s-r);return o.setDate(o.getDate()+i),o.setHours(23,59,59,999),o}function aYe(e,t){return Ece(e,{...t,weekStartsOn:1})}const lYe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},cYe=(e,t,n)=>{let r;const o=lYe[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function fM(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const uYe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},dYe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},fYe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hYe={date:fM({formats:uYe,defaultWidth:"full"}),time:fM({formats:dYe,defaultWidth:"full"}),dateTime:fM({formats:fYe,defaultWidth:"full"})},mYe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pYe=(e,t,n,r)=>mYe[e];function Px(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):i;o=e.formattingValues[a]||e.formattingValues[i]}else{const i=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[a]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}const gYe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},bYe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},xYe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},yYe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},vYe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},wYe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},CYe=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},SYe={ordinalNumber:CYe,era:Px({values:gYe,defaultWidth:"wide"}),quarter:Px({values:bYe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Px({values:xYe,defaultWidth:"wide"}),day:Px({values:yYe,defaultWidth:"wide"}),dayPeriod:Px({values:vYe,defaultWidth:"wide",formattingValues:wYe,defaultFormattingWidth:"wide"})};function Fx(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;const i=s[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?jYe(a,f=>f.test(i)):NYe(a,f=>f.test(i));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(i.length);return{value:u,rest:d}}}function NYe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function jYe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function kYe(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const a=t.slice(o.length);return{value:i,rest:a}}}const _Ye=/^(\d+)(th|st|nd|rd)?/i,IYe=/\d+/i,TYe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},EYe={any:[/^b/i,/^(a|c)/i]},DYe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},MYe={any:[/1/i,/2/i,/3/i,/4/i]},RYe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},AYe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},PYe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},FYe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},OYe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},LYe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},$Ye={ordinalNumber:kYe({matchPattern:_Ye,parsePattern:IYe,valueCallback:e=>parseInt(e,10)}),era:Fx({matchPatterns:TYe,defaultMatchWidth:"wide",parsePatterns:EYe,defaultParseWidth:"any"}),quarter:Fx({matchPatterns:DYe,defaultMatchWidth:"wide",parsePatterns:MYe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Fx({matchPatterns:RYe,defaultMatchWidth:"wide",parsePatterns:AYe,defaultParseWidth:"any"}),day:Fx({matchPatterns:PYe,defaultMatchWidth:"wide",parsePatterns:FYe,defaultParseWidth:"any"}),dayPeriod:Fx({matchPatterns:OYe,defaultMatchWidth:"any",parsePatterns:LYe,defaultParseWidth:"any"})},j$={code:"en-US",formatDistance:cYe,formatLong:hYe,formatRelative:pYe,localize:SYe,match:$Ye,options:{weekStartsOn:0,firstWeekContainsDate:1}};function zYe(e,t){const n=hr(e,t==null?void 0:t.in);return kce(n,Tce(n))+1}function Dce(e,t){const n=hr(e,t==null?void 0:t.in),r=+J0(n)-+GGe(n);return Math.round(r/Cce)+1}function Mce(e,t){var d,f,h,m;const n=hr(e,t==null?void 0:t.in),r=n.getFullYear(),o=Pw(),s=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??o.firstWeekContainsDate??((m=(h=o.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=wo((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const a=eb(i,t),c=wo((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const u=eb(c,t);return+n>=+a?r+1:+n>=+u?r:r-1}function BYe(e,t){var a,c,u,d;const n=Pw(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=Mce(e,t),s=wo((t==null?void 0:t.in)||e,0);return s.setFullYear(o,0,r),s.setHours(0,0,0,0),eb(s,t)}function Rce(e,t){const n=hr(e,t==null?void 0:t.in),r=+eb(n,t)-+BYe(n,t);return Math.round(r/Cce)+1}function ir(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Xu={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ir(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ir(n+1,2)},d(e,t){return ir(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ir(e.getHours()%12||12,t.length)},H(e,t){return ir(e.getHours(),t.length)},m(e,t){return ir(e.getMinutes(),t.length)},s(e,t){return ir(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return ir(o,t.length)}},Np={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Bq={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return Xu.y(e,t)},Y:function(e,t,n,r){const o=Mce(e,r),s=o>0?o:1-o;if(t==="YY"){const i=s%100;return ir(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ir(s,t.length)},R:function(e,t){const n=jce(e);return ir(n,t.length)},u:function(e,t){const n=e.getFullYear();return ir(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ir(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ir(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Xu.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ir(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=Rce(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):ir(o,t.length)},I:function(e,t,n){const r=Dce(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ir(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Xu.d(e,t)},D:function(e,t,n){const r=zYe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ir(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ir(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ir(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return ir(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=Np.noon:r===0?o=Np.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=Np.evening:r>=12?o=Np.afternoon:r>=4?o=Np.morning:o=Np.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Xu.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Xu.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ir(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ir(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xu.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Xu.s(e,t)},S:function(e,t){return Xu.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Hq(r);case"XXXX":case"XX":return Xf(r);case"XXXXX":case"XXX":default:return Xf(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Hq(r);case"xxxx":case"xx":return Xf(r);case"xxxxx":case"xxx":default:return Xf(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Vq(r,":");case"OOOO":default:return"GMT"+Xf(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Vq(r,":");case"zzzz":default:return"GMT"+Xf(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ir(r,t.length)},T:function(e,t,n){return ir(+e,t.length)}};function Vq(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),s=r%60;return s===0?n+String(o):n+String(o)+t+ir(s,2)}function Hq(e,t){return e%60===0?(e>0?"-":"+")+ir(Math.abs(e)/60,2):Xf(e,t)}function Xf(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=ir(Math.trunc(r/60),2),s=ir(r%60,2);return n+o+t+s}const qq=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},Ace=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},VYe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return qq(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",qq(r,t)).replace("{{time}}",Ace(o,t))},HYe={p:Ace,P:VYe},qYe=/^D+$/,UYe=/^Y+$/,WYe=["D","DD","YY","YYYY"];function KYe(e){return qYe.test(e)}function GYe(e){return UYe.test(e)}function YYe(e,t,n){const r=ZYe(e,t,n);if(console.warn(r),WYe.includes(e))throw new RangeError(r)}function ZYe(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const XYe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,QYe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,JYe=/^'([^]*?)'?$/,eZe=/''/g,tZe=/[a-zA-Z]/;function nZe(e,t,n){var d,f,h,m,g,b,x,y;const r=Pw(),o=(n==null?void 0:n.locale)??r.locale??j$,s=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(h=r.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((b=(g=n==null?void 0:n.locale)==null?void 0:g.options)==null?void 0:b.weekStartsOn)??r.weekStartsOn??((y=(x=r.locale)==null?void 0:x.options)==null?void 0:y.weekStartsOn)??0,a=hr(e,n==null?void 0:n.in);if(!eYe(a))throw new RangeError("Invalid time value");let c=t.match(QYe).map(w=>{const C=w[0];if(C==="p"||C==="P"){const N=HYe[C];return N(w,o.formatLong)}return w}).join("").match(XYe).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const C=w[0];if(C==="'")return{isToken:!1,value:rZe(w)};if(Bq[C])return{isToken:!0,value:w};if(C.match(tZe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:w}});o.localize.preprocessor&&(c=o.localize.preprocessor(a,c));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:o};return c.map(w=>{if(!w.isToken)return w.value;const C=w.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&GYe(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&KYe(C))&&YYe(C,t,String(e));const N=Bq[C[0]];return N(a,C,o.localize,u)}).join("")}function rZe(e){const t=e.match(JYe);return t?t[1].replace(eZe,"'"):e}function oZe(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getFullYear(),o=n.getMonth(),s=wo(n,0);return s.setFullYear(r,o+1,0),s.setHours(0,0,0,0),s.getDate()}function sZe(e,t){return hr(e,t==null?void 0:t.in).getMonth()}function iZe(e,t){return hr(e,t==null?void 0:t.in).getFullYear()}function aZe(e,t){return+hr(e)>+hr(t)}function lZe(e,t){return+hr(e)<+hr(t)}function cZe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}function uZe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()}function dZe(e,t,n){const r=hr(e,n==null?void 0:n.in),o=r.getFullYear(),s=r.getDate(),i=wo(e,0);i.setFullYear(o,t,15),i.setHours(0,0,0,0);const a=oZe(i);return r.setMonth(t,Math.min(s,a)),r}function fZe(e,t,n){const r=hr(e,n==null?void 0:n.in);return isNaN(+r)?wo(e,NaN):(r.setFullYear(t),r)}const Uq=5,hZe=4;function mZe(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,o=t.addDays(e,-r+1),s=t.addDays(o,Uq*7-1);return t.getMonth(e)===t.getMonth(s)?Uq:hZe}function Pce(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-1*6):t.addDays(n,-1*(r-1))}function pZe(e,t){const n=Pce(e,t),r=mZe(e,t);return t.addDays(n,r*7-1)}class Wi{constructor(t,n){this.Date=Date,this.today=()=>{var r;return(r=this.overrides)!=null&&r.today?this.overrides.today():this.options.timeZone?Qc.tz(this.options.timeZone):new this.Date},this.newDate=(r,o,s)=>{var i;return(i=this.overrides)!=null&&i.newDate?this.overrides.newDate(r,o,s):this.options.timeZone?new Qc(r,o,s,this.options.timeZone):new Date(r,o,s)},this.addDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addDays?this.overrides.addDays(r,o):Sce(r,o)},this.addMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addMonths?this.overrides.addMonths(r,o):Nce(r,o)},this.addWeeks=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addWeeks?this.overrides.addWeeks(r,o):YGe(r,o)},this.addYears=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addYears?this.overrides.addYears(r,o):ZGe(r,o)},this.differenceInCalendarDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,o):kce(r,o)},this.differenceInCalendarMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,o):tYe(r,o)},this.eachMonthOfInterval=r=>{var o;return(o=this.overrides)!=null&&o.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):rYe(r)},this.eachYearOfInterval=r=>{var a;const o=(a=this.overrides)!=null&&a.eachYearOfInterval?this.overrides.eachYearOfInterval(r):iYe(r),s=new Set(o.map(c=>this.getYear(c)));if(s.size===o.length)return o;const i=[];return s.forEach(c=>{i.push(new Date(c,0,1))}),i},this.endOfBroadcastWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):pZe(r,this)},this.endOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfISOWeek?this.overrides.endOfISOWeek(r):aYe(r)},this.endOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.endOfMonth?this.overrides.endOfMonth(r):nYe(r)},this.endOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.endOfWeek?this.overrides.endOfWeek(r,o):Ece(r,this.options)},this.endOfYear=r=>{var o;return(o=this.overrides)!=null&&o.endOfYear?this.overrides.endOfYear(r):sYe(r)},this.format=(r,o,s)=>{var a;const i=(a=this.overrides)!=null&&a.format?this.overrides.format(r,o,this.options):nZe(r,o,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.getISOWeek?this.overrides.getISOWeek(r):Dce(r)},this.getMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getMonth?this.overrides.getMonth(r,this.options):sZe(r,this.options)},this.getYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getYear?this.overrides.getYear(r,this.options):iZe(r,this.options)},this.getWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getWeek?this.overrides.getWeek(r,this.options):Rce(r,this.options)},this.isAfter=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isAfter?this.overrides.isAfter(r,o):aZe(r,o)},this.isBefore=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isBefore?this.overrides.isBefore(r,o):lZe(r,o)},this.isDate=r=>{var o;return(o=this.overrides)!=null&&o.isDate?this.overrides.isDate(r):_ce(r)},this.isSameDay=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameDay?this.overrides.isSameDay(r,o):JGe(r,o)},this.isSameMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameMonth?this.overrides.isSameMonth(r,o):cZe(r,o)},this.isSameYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameYear?this.overrides.isSameYear(r,o):uZe(r,o)},this.max=r=>{var o;return(o=this.overrides)!=null&&o.max?this.overrides.max(r):XGe(r)},this.min=r=>{var o;return(o=this.overrides)!=null&&o.min?this.overrides.min(r):QGe(r)},this.setMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setMonth?this.overrides.setMonth(r,o):dZe(r,o)},this.setYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setYear?this.overrides.setYear(r,o):fZe(r,o)},this.startOfBroadcastWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):Pce(r,this)},this.startOfDay=r=>{var o;return(o=this.overrides)!=null&&o.startOfDay?this.overrides.startOfDay(r):ev(r)},this.startOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.startOfISOWeek?this.overrides.startOfISOWeek(r):J0(r)},this.startOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.startOfMonth?this.overrides.startOfMonth(r):oYe(r)},this.startOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfWeek?this.overrides.startOfWeek(r,this.options):eb(r,this.options)},this.startOfYear=r=>{var o;return(o=this.overrides)!=null&&o.startOfYear?this.overrides.startOfYear(r):Tce(r)},this.options={locale:j$,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let o=0;o<10;o++)r[o.toString()]=n.format(o);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){var n;const t=(n=this.options.locale)==null?void 0:n.code;return t&&Wi.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:r,numerals:o}=this.options,s=n==null?void 0:n.code;if(s&&Wi.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:o}).format(t)}catch{}const i=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,i)}}Wi.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const gc=new Wi;class Fce{constructor(t,n,r=gc){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r,this.isoDate=r.format(t,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class gZe{constructor(t,n){this.date=t,this.weeks=n}}class bZe{constructor(t,n){this.days=n,this.weekNumber=t}}function xZe(e){return v.createElement("button",{...e})}function yZe(e){return v.createElement("span",{...e})}function vZe(e){const{size:t=24,orientation:n="left",className:r}=e;return v.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&v.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&v.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&v.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&v.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function wZe(e){const{day:t,modifiers:n,...r}=e;return v.createElement("td",{...r})}function CZe(e){const{day:t,modifiers:n,...r}=e,o=v.useRef(null);return v.useEffect(()=>{var s;n.focused&&((s=o.current)==null||s.focus())},[n.focused]),v.createElement("button",{ref:o,...r})}var qt;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(qt||(qt={}));var qr;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(qr||(qr={}));var Ha;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Ha||(Ha={}));var Ai;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Ai||(Ai={}));function SZe(e){const{options:t,className:n,components:r,classNames:o,...s}=e,i=[o[qt.Dropdown],n].join(" "),a=t==null?void 0:t.find(({value:c})=>c===s.value);return v.createElement("span",{"data-disabled":s.disabled,className:o[qt.DropdownRoot]},v.createElement(r.Select,{className:i,...s},t==null?void 0:t.map(({value:c,label:u,disabled:d})=>v.createElement(r.Option,{key:c,value:c,disabled:d},u))),v.createElement("span",{className:o[qt.CaptionLabel],"aria-hidden":!0},a==null?void 0:a.label,v.createElement(r.Chevron,{orientation:"down",size:18,className:o[qt.Chevron]})))}function NZe(e){return v.createElement("div",{...e})}function jZe(e){return v.createElement("div",{...e})}function kZe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r},e.children)}function _Ze(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r})}function IZe(e){return v.createElement("table",{...e})}function TZe(e){return v.createElement("div",{...e})}const Oce=v.createContext(void 0);function Fw(){const e=v.useContext(Oce);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function EZe(e){const{components:t}=Fw();return v.createElement(t.Dropdown,{...e})}function DZe(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:o,...s}=e,{components:i,classNames:a,labels:{labelPrevious:c,labelNext:u}}=Fw(),d=v.useCallback(h=>{o&&(n==null||n(h))},[o,n]),f=v.useCallback(h=>{r&&(t==null||t(h))},[r,t]);return v.createElement("nav",{...s},v.createElement(i.PreviousMonthButton,{type:"button",className:a[qt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:f},v.createElement(i.Chevron,{disabled:r?void 0:!0,className:a[qt.Chevron],orientation:"left"})),v.createElement(i.NextMonthButton,{type:"button",className:a[qt.NextMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":u(o),onClick:d},v.createElement(i.Chevron,{disabled:o?void 0:!0,orientation:"right",className:a[qt.Chevron]})))}function MZe(e){const{components:t}=Fw();return v.createElement(t.Button,{...e})}function RZe(e){return v.createElement("option",{...e})}function AZe(e){const{components:t}=Fw();return v.createElement(t.Button,{...e})}function PZe(e){const{rootRef:t,...n}=e;return v.createElement("div",{...n,ref:t})}function FZe(e){return v.createElement("select",{...e})}function OZe(e){const{week:t,...n}=e;return v.createElement("tr",{...n})}function LZe(e){return v.createElement("th",{...e})}function $Ze(e){return v.createElement("thead",{"aria-hidden":!0},v.createElement("tr",{...e}))}function zZe(e){const{week:t,...n}=e;return v.createElement("th",{...n})}function BZe(e){return v.createElement("th",{...e})}function VZe(e){return v.createElement("tbody",{...e})}function HZe(e){const{components:t}=Fw();return v.createElement(t.Dropdown,{...e})}const qZe=Object.freeze(Object.defineProperty({__proto__:null,Button:xZe,CaptionLabel:yZe,Chevron:vZe,Day:wZe,DayButton:CZe,Dropdown:SZe,DropdownNav:NZe,Footer:jZe,Month:kZe,MonthCaption:_Ze,MonthGrid:IZe,Months:TZe,MonthsDropdown:EZe,Nav:DZe,NextMonthButton:MZe,Option:RZe,PreviousMonthButton:AZe,Root:PZe,Select:FZe,Week:OZe,WeekNumber:zZe,WeekNumberHeader:BZe,Weekday:LZe,Weekdays:$Ze,Weeks:VZe,YearsDropdown:HZe},Symbol.toStringTag,{value:"Module"}));function Jc(e,t,n=!1,r=gc){let{from:o,to:s}=e;const{differenceInCalendarDays:i,isSameDay:a}=r;return o&&s?(i(s,o)<0&&([o,s]=[s,o]),i(t,o)>=(n?1:0)&&i(s,t)>=(n?1:0)):!n&&s?a(s,t):!n&&o?a(o,t):!1}function k$(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function AI(e){return!!(e&&typeof e=="object"&&"from"in e)}function _$(e){return!!(e&&typeof e=="object"&&"after"in e)}function I$(e){return!!(e&&typeof e=="object"&&"before"in e)}function Lce(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function $ce(e,t){return Array.isArray(e)&&e.every(t.isDate)}function eu(e,t,n=gc){const r=Array.isArray(t)?t:[t],{isSameDay:o,differenceInCalendarDays:s,isAfter:i}=n;return r.some(a=>{if(typeof a=="boolean")return a;if(n.isDate(a))return o(e,a);if($ce(a,n))return a.includes(e);if(AI(a))return Jc(a,e,!1,n);if(Lce(a))return Array.isArray(a.dayOfWeek)?a.dayOfWeek.includes(e.getDay()):a.dayOfWeek===e.getDay();if(k$(a)){const c=s(a.before,e),u=s(a.after,e),d=c>0,f=u<0;return i(a.before,a.after)?f&&d:d||f}return _$(a)?s(e,a.after)>0:I$(a)?s(a.before,e)>0:typeof a=="function"?a(e):!1})}function UZe(e,t,n,r,o){const{disabled:s,hidden:i,modifiers:a,showOutsideDays:c,broadcastCalendar:u,today:d=o.today()}=t,{isSameDay:f,isSameMonth:h,startOfMonth:m,isBefore:g,endOfMonth:b,isAfter:x}=o,y=n&&m(n),w=r&&b(r),C={[qr.focused]:[],[qr.outside]:[],[qr.disabled]:[],[qr.hidden]:[],[qr.today]:[]},N={};for(const S of e){const{date:j,displayMonth:_}=S,k=!!(_&&!h(j,_)),T=!!(y&&g(j,y)),I=!!(w&&x(j,w)),E=!!(s&&eu(j,s,o)),D=!!(i&&eu(j,i,o))||T||I||!u&&!c&&k||u&&c===!1&&k,R=f(j,d);k&&C.outside.push(S),E&&C.disabled.push(S),D&&C.hidden.push(S),R&&C.today.push(S),a&&Object.keys(a).forEach(A=>{const F=a==null?void 0:a[A];F&&eu(j,F,o)&&(N[A]?N[A].push(S):N[A]=[S])})}return S=>{const j={[qr.focused]:!1,[qr.disabled]:!1,[qr.hidden]:!1,[qr.outside]:!1,[qr.today]:!1},_={};for(const k in C){const T=C[k];j[k]=T.some(I=>I===S)}for(const k in N)_[k]=N[k].some(T=>T===S);return{...j,..._}}}function WZe(e,t,n={}){return Object.entries(e).filter(([,o])=>o===!0).reduce((o,[s])=>(n[s]?o.push(n[s]):t[qr[s]]?o.push(t[qr[s]]):t[Ha[s]]&&o.push(t[Ha[s]]),o),[t[qt.Day]])}function KZe(e){return{...qZe,...e}}function GZe(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function T$(){const e={};for(const t in qt)e[qt[t]]=`rdp-${qt[t]}`;for(const t in qr)e[qr[t]]=`rdp-${qr[t]}`;for(const t in Ha)e[Ha[t]]=`rdp-${Ha[t]}`;for(const t in Ai)e[Ai[t]]=`rdp-${Ai[t]}`;return e}function zce(e,t,n){return(n??new Wi(t)).formatMonthYear(e)}const YZe=zce;function ZZe(e,t,n){return(n??new Wi(t)).format(e,"d")}function XZe(e,t=gc){return t.format(e,"LLLL")}function QZe(e,t,n){return(n??new Wi(t)).format(e,"cccccc")}function JZe(e,t=gc){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function eXe(){return""}function Bce(e,t=gc){return t.format(e,"yyyy")}const tXe=Bce,nXe=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:zce,formatDay:ZZe,formatMonthCaption:YZe,formatMonthDropdown:XZe,formatWeekNumber:JZe,formatWeekNumberHeader:eXe,formatWeekdayName:QZe,formatYearCaption:tXe,formatYearDropdown:Bce},Symbol.toStringTag,{value:"Module"}));function rXe(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...nXe,...e}}function oXe(e,t,n,r,o){const{startOfMonth:s,startOfYear:i,endOfYear:a,eachMonthOfInterval:c,getMonth:u}=o;return c({start:i(e),end:a(e)}).map(h=>{const m=r.formatMonthDropdown(h,o),g=u(h),b=t&&h<s(t)||n&&h>s(n)||!1;return{value:g,label:m,disabled:b}})}function sXe(e,t={},n={}){let r={...t==null?void 0:t[qt.Day]};return Object.entries(e).filter(([,o])=>o===!0).forEach(([o])=>{r={...r,...n==null?void 0:n[o]}}),r}function iXe(e,t,n,r){const o=r??e.today(),s=n?e.startOfBroadcastWeek(o,e):t?e.startOfISOWeek(o):e.startOfWeek(o),i=[];for(let a=0;a<7;a++){const c=e.addDays(s,a);i.push(c)}return i}function aXe(e,t,n,r,o=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:i,eachYearOfInterval:a,getYear:c}=r,u=s(e),d=i(t),f=a({start:u,end:d});return o&&f.reverse(),f.map(h=>{const m=n.formatYearDropdown(h,r);return{value:c(h),label:m,disabled:!1}})}function Vce(e,t,n,r){let o=(r??new Wi(n)).format(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o}const lXe=Vce;function Hce(e,t,n){return(n??new Wi(t)).formatMonthYear(e)}const cXe=Hce;function uXe(e,t,n,r){let o=(r??new Wi(n)).format(e,"PPPP");return t!=null&&t.today&&(o=`Today, ${o}`),o}function dXe(e){return"Choose the Month"}function fXe(){return""}function hXe(e){return"Go to the Next Month"}function mXe(e){return"Go to the Previous Month"}function pXe(e,t,n){return(n??new Wi(t)).format(e,"cccc")}function gXe(e,t){return`Week ${e}`}function bXe(e){return"Week Number"}function xXe(e){return"Choose the Year"}const yXe=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:cXe,labelDay:lXe,labelDayButton:Vce,labelGrid:Hce,labelGridcell:uXe,labelMonthDropdown:dXe,labelNav:fXe,labelNext:hXe,labelPrevious:mXe,labelWeekNumber:gXe,labelWeekNumberHeader:bXe,labelWeekday:pXe,labelYearDropdown:xXe},Symbol.toStringTag,{value:"Module"})),Ow=e=>e instanceof HTMLElement?e:null,hM=e=>[...e.querySelectorAll("[data-animated-month]")??[]],vXe=e=>Ow(e.querySelector("[data-animated-month]")),mM=e=>Ow(e.querySelector("[data-animated-caption]")),pM=e=>Ow(e.querySelector("[data-animated-weeks]")),wXe=e=>Ow(e.querySelector("[data-animated-nav]")),CXe=e=>Ow(e.querySelector("[data-animated-weekdays]"));function SXe(e,t,{classNames:n,months:r,focused:o,dateLib:s}){const i=v.useRef(null),a=v.useRef(r),c=v.useRef(!1);v.useLayoutEffect(()=>{const u=a.current;if(a.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const d=s.isSameMonth(r[0].date,u[0].date),f=s.isAfter(r[0].date,u[0].date),h=f?n[Ai.caption_after_enter]:n[Ai.caption_before_enter],m=f?n[Ai.weeks_after_enter]:n[Ai.weeks_before_enter],g=i.current,b=e.current.cloneNode(!0);if(b instanceof HTMLElement?(hM(b).forEach(C=>{if(!(C instanceof HTMLElement))return;const N=vXe(C);N&&C.contains(N)&&C.removeChild(N);const S=mM(C);S&&S.classList.remove(h);const j=pM(C);j&&j.classList.remove(m)}),i.current=b):i.current=null,c.current||d||o)return;const x=g instanceof HTMLElement?hM(g):[],y=hM(e.current);if(y!=null&&y.every(w=>w instanceof HTMLElement)&&x&&x.every(w=>w instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const w=wXe(e.current);w&&(w.style.zIndex="1"),y.forEach((C,N)=>{const S=x[N];if(!S)return;C.style.position="relative",C.style.overflow="hidden";const j=mM(C);j&&j.classList.add(h);const _=pM(C);_&&_.classList.add(m);const k=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),w&&(w.style.zIndex=""),j&&j.classList.remove(h),_&&_.classList.remove(m),C.style.position="",C.style.overflow="",C.contains(S)&&C.removeChild(S)};S.style.pointerEvents="none",S.style.position="absolute",S.style.overflow="hidden",S.setAttribute("aria-hidden","true");const T=CXe(S);T&&(T.style.opacity="0");const I=mM(S);I&&(I.classList.add(f?n[Ai.caption_before_exit]:n[Ai.caption_after_exit]),I.addEventListener("animationend",k));const E=pM(S);E&&E.classList.add(f?n[Ai.weeks_before_exit]:n[Ai.weeks_after_exit]),C.insertBefore(S,C.firstChild)})}})}function NXe(e,t,n,r){const o=e[0],s=e[e.length-1],{ISOWeek:i,fixedWeeks:a,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:m,endOfMonth:g,endOfWeek:b,isAfter:x,startOfBroadcastWeek:y,startOfISOWeek:w,startOfWeek:C}=r,N=c?y(o,r):i?w(o):C(o),S=c?h(s):i?m(g(s)):b(g(s)),j=t&&(c?h(t):i?m(t):b(t)),_=j&&x(S,j)?j:S,k=d(_,N),T=f(s,o)+1,I=[];for(let R=0;R<=k;R++){const A=u(N,R);I.push(A)}const D=(c?35:42)*T;if(a&&I.length<D){const R=D-I.length;for(let A=0;A<R;A++){const F=u(I[I.length-1],1);I.push(F)}}return I}function jXe(e){const t=[];return e.reduce((n,r)=>{const o=r.weeks.reduce((s,i)=>s.concat(i.days.slice()),t.slice());return n.concat(o.slice())},t.slice())}function kXe(e,t,n,r){const{numberOfMonths:o=1}=n,s=[];for(let i=0;i<o;i++){const a=r.addMonths(e,i);if(t&&a>t)break;s.push(a)}return s}function Wq(e,t,n,r){const{month:o,defaultMonth:s,today:i=r.today(),numberOfMonths:a=1}=e;let c=o||s||i;const{differenceInCalendarMonths:u,addMonths:d,startOfMonth:f}=r;if(n&&u(n,c)<a-1){const h=-1*(a-1);c=d(n,h)}return t&&u(c,t)<0&&(c=t),f(c)}function _Xe(e,t,n,r){const{addDays:o,endOfBroadcastWeek:s,endOfISOWeek:i,endOfMonth:a,endOfWeek:c,getISOWeek:u,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:m}=r,g=e.reduce((b,x)=>{const y=n.broadcastCalendar?f(x,r):n.ISOWeek?h(x):m(x),w=n.broadcastCalendar?s(x):n.ISOWeek?i(a(x)):c(a(x)),C=t.filter(_=>_>=y&&_<=w),N=n.broadcastCalendar?35:42;if(n.fixedWeeks&&C.length<N){const _=t.filter(k=>{const T=N-C.length;return k>w&&k<=o(w,T)});C.push(..._)}const S=C.reduce((_,k)=>{const T=n.ISOWeek?u(k):d(k),I=_.find(D=>D.weekNumber===T),E=new Fce(k,x,r);return I?I.days.push(E):_.push(new bZe(T,[E])),_},[]),j=new gZe(x,S);return b.push(j),b},[]);return n.reverseMonths?g.reverse():g}function IXe(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:o,startOfDay:s,startOfMonth:i,endOfMonth:a,addYears:c,endOfYear:u,newDate:d,today:f}=t,{fromYear:h,toYear:m,fromMonth:g,toMonth:b}=e;!n&&g&&(n=g),!n&&h&&(n=t.newDate(h,0,1)),!r&&b&&(r=b),!r&&m&&(r=d(m,11,31));const x=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=i(n):h?n=d(h,0,1):!n&&x&&(n=o(c(e.today??f(),-100))),r?r=a(r):m?r=d(m,11,31):!r&&x&&(r=u(e.today??f())),[n&&s(n),r&&s(r)]}function TXe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s=1}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s:1,d=i(e);if(!t)return a(d,u);if(!(c(t,e)<s))return a(d,u)}function EXe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s??1:1,d=i(e);if(!t)return a(d,-u);if(!(c(d,t)<=0))return a(d,-u)}function DXe(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function PI(e,t){const[n,r]=v.useState(e);return[t===void 0?n:t,r]}function MXe(e,t){var N;const[n,r]=IXe(e,t),{startOfMonth:o,endOfMonth:s}=t,i=Wq(e,n,r,t),[a,c]=PI(i,e.month?i:void 0);v.useEffect(()=>{const S=Wq(e,n,r,t);c(S)},[e.timeZone]);const{months:u,weeks:d,days:f,previousMonth:h,nextMonth:m}=v.useMemo(()=>{const S=kXe(a,r,{numberOfMonths:e.numberOfMonths},t),j=NXe(S,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),_=_Xe(S,j,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),k=DXe(_),T=jXe(_),I=EXe(a,n,e,t),E=TXe(a,r,e,t);return{months:_,weeks:k,days:T,previousMonth:I,nextMonth:E}},[t,a.getTime(),r==null?void 0:r.getTime(),n==null?void 0:n.getTime(),e.disableNavigation,e.broadcastCalendar,(N=e.endMonth)==null?void 0:N.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:g,onMonthChange:b}=e,x=S=>d.some(j=>j.days.some(_=>_.isEqualTo(S))),y=S=>{if(g)return;let j=o(S);n&&j<o(n)&&(j=o(n)),r&&j>o(r)&&(j=o(r)),c(j),b==null||b(j)};return{months:u,weeks:d,days:f,navStart:n,navEnd:r,previousMonth:h,nextMonth:m,goToMonth:y,goToDay:S=>{x(S)||y(S.date)}}}var El;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(El||(El={}));function Kq(e){return!e[qr.disabled]&&!e[qr.hidden]&&!e[qr.outside]}function RXe(e,t,n,r){let o,s=-1;for(const i of e){const a=t(i);Kq(a)&&(a[qr.focused]&&s<El.FocusedModifier?(o=i,s=El.FocusedModifier):r!=null&&r.isEqualTo(i)&&s<El.LastFocused?(o=i,s=El.LastFocused):n(i.date)&&s<El.Selected?(o=i,s=El.Selected):a[qr.today]&&s<El.Today&&(o=i,s=El.Today))}return o||(o=e.find(i=>Kq(t(i)))),o}function AXe(e,t,n,r,o,s,i){const{ISOWeek:a,broadcastCalendar:c}=s,{addDays:u,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfWeek:b,max:x,min:y,startOfBroadcastWeek:w,startOfISOWeek:C,startOfWeek:N}=i;let j={day:u,week:f,month:d,year:h,startOfWeek:_=>c?w(_,i):a?C(_):N(_),endOfWeek:_=>c?m(_):a?g(_):b(_)}[e](n,t==="after"?1:-1);return t==="before"&&r?j=x([r,j]):t==="after"&&o&&(j=y([o,j])),j}function qce(e,t,n,r,o,s,i,a=0){if(a>365)return;const c=AXe(e,t,n.date,r,o,s,i),u=!!(s.disabled&&eu(c,s.disabled,i)),d=!!(s.hidden&&eu(c,s.hidden,i)),f=c,h=new Fce(c,f,i);return!u&&!d?h:qce(e,t,h,r,o,s,i,a+1)}function PXe(e,t,n,r,o){const{autoFocus:s}=e,[i,a]=v.useState(),c=RXe(t.days,n,r||(()=>!1),i),[u,d]=v.useState(s?c:void 0);return{isFocusTarget:b=>!!(c!=null&&c.isEqualTo(b)),setFocused:d,focused:u,blur:()=>{a(u),d(void 0)},moveFocus:(b,x)=>{if(!u)return;const y=qce(b,x,u,t.navStart,t.navEnd,e,o);y&&(e.disableNavigation&&!t.days.some(C=>C.isEqualTo(y))||(t.goToDay(y),d(y)))}}}function FXe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=PI(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t,u=m=>(a==null?void 0:a.some(g=>c(g,m)))??!1,{min:d,max:f}=e;return{selected:a,select:(m,g,b)=>{let x=[...a??[]];if(u(m)){if((a==null?void 0:a.length)===d||r&&(a==null?void 0:a.length)===1)return;x=a==null?void 0:a.filter(y=>!c(y,m))}else(a==null?void 0:a.length)===f?x=[m]:x=[...x,m];return o||i(x),o==null||o(x,m,g,b),x},isSelected:u}}function OXe(e,t,n=0,r=0,o=!1,s=gc){const{from:i,to:a}=t||{},{isSameDay:c,isAfter:u,isBefore:d}=s;let f;if(!i&&!a)f={from:e,to:n>0?void 0:e};else if(i&&!a)c(i,e)?n===0?f={from:i,to:e}:o?f={from:i,to:void 0}:f=void 0:d(e,i)?f={from:e,to:i}:f={from:i,to:e};else if(i&&a)if(c(i,e)&&c(a,e))o?f={from:i,to:a}:f=void 0;else if(c(i,e))f={from:i,to:n>0?void 0:e};else if(c(a,e))f={from:e,to:n>0?void 0:e};else if(d(e,i))f={from:e,to:a};else if(u(e,i))f={from:i,to:e};else if(u(e,a))f={from:i,to:e};else throw new Error("Invalid range");if(f!=null&&f.from&&(f!=null&&f.to)){const h=s.differenceInCalendarDays(f.to,f.from);r>0&&h>r?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function LXe(e,t,n=gc){const r=Array.isArray(t)?t:[t];let o=e.from;const s=n.differenceInCalendarDays(e.to,e.from),i=Math.min(s,6);for(let a=0;a<=i;a++){if(r.includes(o.getDay()))return!0;o=n.addDays(o,1)}return!1}function Gq(e,t,n=gc){return Jc(e,t.from,!1,n)||Jc(e,t.to,!1,n)||Jc(t,e.from,!1,n)||Jc(t,e.to,!1,n)}function $Xe(e,t,n=gc){const r=Array.isArray(t)?t:[t];if(r.filter(a=>typeof a!="function").some(a=>typeof a=="boolean"?a:n.isDate(a)?Jc(e,a,!1,n):$ce(a,n)?a.some(c=>Jc(e,c,!1,n)):AI(a)?a.from&&a.to?Gq(e,{from:a.from,to:a.to},n):!1:Lce(a)?LXe(e,a.dayOfWeek,n):k$(a)?n.isAfter(a.before,a.after)?Gq(e,{from:n.addDays(a.after,1),to:n.addDays(a.before,-1)},n):eu(e.from,a,n)||eu(e.to,a,n):_$(a)||I$(a)?eu(e.from,a,n)||eu(e.to,a,n):!1))return!0;const i=r.filter(a=>typeof a=="function");if(i.length){let a=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let u=0;u<=c;u++){if(i.some(d=>d(a)))return!0;a=n.addDays(a,1)}}return!1}function zXe(e,t){const{disabled:n,excludeDisabled:r,selected:o,required:s,onSelect:i}=e,[a,c]=PI(o,i?o:void 0),u=i?o:a;return{selected:u,select:(h,m,g)=>{const{min:b,max:x}=e,y=h?OXe(h,u,b,x,s,t):void 0;return r&&n&&(y!=null&&y.from)&&y.to&&$Xe({from:y.from,to:y.to},n,t)&&(y.from=h,y.to=void 0),i||c(y),i==null||i(y,h,m,g),y},isSelected:h=>u&&Jc(u,h,!1,t)}}function BXe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=PI(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t;return{selected:a,select:(f,h,m)=>{let g=f;return!r&&a&&a&&c(f,a)&&(g=void 0),o||i(g),o==null||o(g,f,h,m),g},isSelected:f=>a?c(a,f):!1}}function VXe(e,t){const n=BXe(e,t),r=FXe(e,t),o=zXe(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return o;default:return}}function Qo(e,t){return e instanceof Qc&&e.timeZone===t?e:new Qc(e,t)}function Yq(e,t){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Qo(e,t):Array.isArray(e)?e.map(n=>n instanceof Date?Qo(n,t):n):AI(e)?{...e,from:e.from?Qo(e.from,t):e.from,to:e.to?Qo(e.to,t):e.to}:k$(e)?{before:Qo(e.before,t),after:Qo(e.after,t)}:_$(e)?{after:Qo(e.after,t)}:I$(e)?{before:Qo(e.before,t)}:e}function gM(e,t){return e&&(Array.isArray(e)?e.map(n=>Yq(n,t)):Yq(e,t))}function HXe(e){var Qe;let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=Qo(t.today,n)),t.month&&(t.month=Qo(t.month,n)),t.defaultMonth&&(t.defaultMonth=Qo(t.defaultMonth,n)),t.startMonth&&(t.startMonth=Qo(t.startMonth,n)),t.endMonth&&(t.endMonth=Qo(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=Qo(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=(Qe=t.selected)==null?void 0:Qe.map(xe=>Qo(xe,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?Qo(t.selected.from,n):t.selected.from,to:t.selected.to?Qo(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=gM(t.disabled,n)),t.hidden!==void 0&&(t.hidden=gM(t.hidden,n)),t.modifiers)){const xe={};Object.keys(t.modifiers).forEach(Ve=>{var Ae;xe[Ve]=gM((Ae=t.modifiers)==null?void 0:Ae[Ve],n)}),t.modifiers=xe}const{components:r,formatters:o,labels:s,dateLib:i,locale:a,classNames:c}=v.useMemo(()=>{const xe={...j$,...t.locale};return{dateLib:new Wi({locale:xe,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:KZe(t.components),formatters:rXe(t.formatters),labels:{...yXe,...t.labels},locale:xe,classNames:{...T$(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:i.today()});const{captionLayout:u,mode:d,navLayout:f,numberOfMonths:h=1,onDayBlur:m,onDayClick:g,onDayFocus:b,onDayKeyDown:x,onDayMouseEnter:y,onDayMouseLeave:w,onNextClick:C,onPrevClick:N,showWeekNumber:S,styles:j}=t,{formatCaption:_,formatDay:k,formatMonthDropdown:T,formatWeekNumber:I,formatWeekNumberHeader:E,formatWeekdayName:D,formatYearDropdown:R}=o,A=MXe(t,i),{days:F,months:z,navStart:L,navEnd:$,previousMonth:H,nextMonth:M,goToMonth:B}=A,W=UZe(F,t,L,$,i),{isSelected:P,select:G,selected:Z}=VXe(t,i)??{},{blur:X,focused:Y,isFocusTarget:O,moveFocus:q,setFocused:U}=PXe(t,A,W,P??(()=>!1),i),{labelDayButton:V,labelGridcell:K,labelGrid:Q,labelMonthDropdown:se,labelNav:oe,labelPrevious:me,labelNext:le,labelWeekday:ue,labelWeekNumber:ne,labelWeekNumberHeader:de,labelYearDropdown:Ce}=s,ce=v.useMemo(()=>iXe(i,t.ISOWeek,t.broadcastCalendar,t.today),[i,t.ISOWeek,t.broadcastCalendar,t.today]),ie=d!==void 0||g!==void 0,we=v.useCallback(()=>{H&&(B(H),N==null||N(H))},[H,B,N]),fe=v.useCallback(()=>{M&&(B(M),C==null||C(M))},[B,M,C]),ae=v.useCallback((xe,Ve)=>Ae=>{Ae.preventDefault(),Ae.stopPropagation(),U(xe),!Ve.disabled&&(G==null||G(xe.date,Ve,Ae),g==null||g(xe.date,Ve,Ae))},[G,g,U]),ee=v.useCallback((xe,Ve)=>Ae=>{U(xe),b==null||b(xe.date,Ve,Ae)},[b,U]),J=v.useCallback((xe,Ve)=>Ae=>{X(),m==null||m(xe.date,Ve,Ae)},[X,m]),re=v.useCallback((xe,Ve)=>Ae=>{const ke={ArrowLeft:[Ae.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Ae.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Ae.shiftKey?"year":"week","after"],ArrowUp:[Ae.shiftKey?"year":"week","before"],PageUp:[Ae.shiftKey?"year":"month","before"],PageDown:[Ae.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ke[Ae.key]){Ae.preventDefault(),Ae.stopPropagation();const[Be,Ie]=ke[Ae.key];q(Be,Ie)}x==null||x(xe.date,Ve,Ae)},[q,x,t.dir]),pe=v.useCallback((xe,Ve)=>Ae=>{y==null||y(xe.date,Ve,Ae)},[y]),Ee=v.useCallback((xe,Ve)=>Ae=>{w==null||w(xe.date,Ve,Ae)},[w]),Te=v.useCallback(xe=>Ve=>{const Ae=Number(Ve.target.value),ke=i.setMonth(i.startOfMonth(xe),Ae);B(ke)},[i,B]),ze=v.useCallback(xe=>Ve=>{const Ae=Number(Ve.target.value),ke=i.setYear(i.startOfMonth(xe),Ae);B(ke)},[i,B]),{className:Pe,style:He}=v.useMemo(()=>({className:[c[qt.Root],t.className].filter(Boolean).join(" "),style:{...j==null?void 0:j[qt.Root],...t.style}}),[c,t.className,t.style,j]),ye=GZe(t),Ke=v.useRef(null);SXe(Ke,!!t.animate,{classNames:c,months:z,focused:Y,dateLib:i});const We={dayPickerProps:t,selected:Z,select:G,isSelected:P,months:z,nextMonth:M,previousMonth:H,goToMonth:B,getModifiers:W,components:r,classNames:c,styles:j,labels:s,formatters:o};return v.createElement(Oce.Provider,{value:We},v.createElement(r.Root,{rootRef:t.animate?Ke:void 0,className:Pe,style:He,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...ye},v.createElement(r.Months,{className:c[qt.Months],style:j==null?void 0:j[qt.Months]},!t.hideNavigation&&!f&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":oe(),onPreviousClick:we,onNextClick:fe,previousMonth:H,nextMonth:M}),z.map((xe,Ve)=>v.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:c[qt.Month],style:j==null?void 0:j[qt.Month],key:Ve,displayIndex:Ve,calendarMonth:xe},f==="around"&&!t.hideNavigation&&Ve===0&&v.createElement(r.PreviousMonthButton,{type:"button",className:c[qt.PreviousMonthButton],tabIndex:H?void 0:-1,"aria-disabled":H?void 0:!0,"aria-label":me(H),onClick:we,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:H?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"right":"left"})),v.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[qt.MonthCaption],style:j==null?void 0:j[qt.MonthCaption],calendarMonth:xe,displayIndex:Ve},u!=null&&u.startsWith("dropdown")?v.createElement(r.DropdownNav,{className:c[qt.Dropdowns],style:j==null?void 0:j[qt.Dropdowns]},(()=>{const Ae=u==="dropdown"||u==="dropdown-months"?v.createElement(r.MonthsDropdown,{key:"month",className:c[qt.MonthsDropdown],"aria-label":se(),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:Te(xe.date),options:oXe(xe.date,L,$,o,i),style:j==null?void 0:j[qt.Dropdown],value:i.getMonth(xe.date)}):v.createElement("span",{key:"month"},T(xe.date,i)),ke=u==="dropdown"||u==="dropdown-years"?v.createElement(r.YearsDropdown,{key:"year",className:c[qt.YearsDropdown],"aria-label":Ce(i.options),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:ze(xe.date),options:aXe(L,$,o,i,!!t.reverseYears),style:j==null?void 0:j[qt.Dropdown],value:i.getYear(xe.date)}):v.createElement("span",{key:"year"},R(xe.date,i));return i.getMonthYearOrder()==="year-first"?[ke,Ae]:[Ae,ke]})(),v.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},_(xe.date,i.options,i))):v.createElement(r.CaptionLabel,{className:c[qt.CaptionLabel],role:"status","aria-live":"polite"},_(xe.date,i.options,i))),f==="around"&&!t.hideNavigation&&Ve===h-1&&v.createElement(r.NextMonthButton,{type:"button",className:c[qt.NextMonthButton],tabIndex:M?void 0:-1,"aria-disabled":M?void 0:!0,"aria-label":le(M),onClick:fe,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:M?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"left":"right"})),Ve===h-1&&f==="after"&&!t.hideNavigation&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":oe(),onPreviousClick:we,onNextClick:fe,previousMonth:H,nextMonth:M}),v.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Q(xe.date,i.options,i)||void 0,className:c[qt.MonthGrid],style:j==null?void 0:j[qt.MonthGrid]},!t.hideWeekdays&&v.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[qt.Weekdays],style:j==null?void 0:j[qt.Weekdays]},S&&v.createElement(r.WeekNumberHeader,{"aria-label":de(i.options),className:c[qt.WeekNumberHeader],style:j==null?void 0:j[qt.WeekNumberHeader],scope:"col"},E()),ce.map(Ae=>v.createElement(r.Weekday,{"aria-label":ue(Ae,i.options,i),className:c[qt.Weekday],key:String(Ae),style:j==null?void 0:j[qt.Weekday],scope:"col"},D(Ae,i.options,i)))),v.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[qt.Weeks],style:j==null?void 0:j[qt.Weeks]},xe.weeks.map(Ae=>v.createElement(r.Week,{className:c[qt.Week],key:Ae.weekNumber,style:j==null?void 0:j[qt.Week],week:Ae},S&&v.createElement(r.WeekNumber,{week:Ae,style:j==null?void 0:j[qt.WeekNumber],"aria-label":ne(Ae.weekNumber,{locale:a}),className:c[qt.WeekNumber],scope:"row",role:"rowheader"},I(Ae.weekNumber,i)),Ae.days.map(ke=>{const{date:Be}=ke,Ie=W(ke);if(Ie[qr.focused]=!Ie.hidden&&!!(Y!=null&&Y.isEqualTo(ke)),Ie[Ha.selected]=(P==null?void 0:P(Be))||Ie.selected,AI(Z)){const{from:rt,to:Ct}=Z;Ie[Ha.range_start]=!!(rt&&Ct&&i.isSameDay(Be,rt)),Ie[Ha.range_end]=!!(rt&&Ct&&i.isSameDay(Be,Ct)),Ie[Ha.range_middle]=Jc(Z,Be,!0,i)}const $e=sXe(Ie,j,t.modifiersStyles),st=WZe(Ie,c,t.modifiersClassNames),ct=!ie&&!Ie.hidden?K(Be,Ie,i.options,i):void 0;return v.createElement(r.Day,{key:`${ke.isoDate}_${ke.displayMonthId}`,day:ke,modifiers:Ie,className:st.join(" "),style:$e,role:"gridcell","aria-selected":Ie.selected||void 0,"aria-label":ct,"data-day":ke.isoDate,"data-month":ke.outside?ke.dateMonthId:void 0,"data-selected":Ie.selected||void 0,"data-disabled":Ie.disabled||void 0,"data-hidden":Ie.hidden||void 0,"data-outside":ke.outside||void 0,"data-focused":Ie.focused||void 0,"data-today":Ie.today||void 0},!Ie.hidden&&ie?v.createElement(r.DayButton,{className:c[qt.DayButton],style:j==null?void 0:j[qt.DayButton],type:"button",day:ke,modifiers:Ie,disabled:!Ie.focused&&Ie.disabled||void 0,"aria-disabled":Ie.focused&&Ie.disabled||void 0,tabIndex:O(ke)?0:-1,"aria-label":V(Be,Ie,i.options,i),onClick:ae(ke,Ie),onBlur:J(ke,Ie),onFocus:ee(ke,Ie),onKeyDown:re(ke,Ie),onMouseEnter:pe(ke,Ie),onMouseLeave:Ee(ke,Ie)},k(Be,i.options,i)):!Ie.hidden&&k(ke.date,i.options,i))})))))))),t.footer&&v.createElement(r.Footer,{className:c[qt.Footer],style:j==null?void 0:j[qt.Footer],role:"status","aria-live":"polite"},t.footer)))}function bM({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r="label",buttonVariant:o="ghost",formatters:s,components:i,...a}){const c=T$();return l.jsx(HXe,{showOutsideDays:n,className:p.cn("bg-background group/calendar p-2.5 [--cell-size:1.75rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...s},classNames:{root:p.cn("w-fit",c.root),months:p.cn("relative flex flex-col gap-3 md:flex-row",c.months),month:p.cn("flex w-full flex-col gap-3",c.month),nav:p.cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",c.nav),button_previous:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_previous),button_next:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_next),month_caption:p.cn("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",c.month_caption),dropdowns:p.cn("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-[13px] font-medium",c.dropdowns),dropdown_root:p.cn("has-focus:border-ring border-input has-focus:ring-ring/40 has-focus:ring-[2px] relative rounded-md border",c.dropdown_root),dropdown:p.cn("bg-popover absolute inset-0 opacity-0",c.dropdown),caption_label:p.cn("select-none font-medium text-foreground",r==="label"?"text-[13px]":"[&>svg]:text-muted-foreground flex h-7 items-center gap-1 rounded-md pl-2 pr-1 text-[13px] [&>svg]:size-3",c.caption_label),table:"w-full border-collapse",weekdays:p.cn("flex",c.weekdays),weekday:p.cn("text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",c.weekday),week:p.cn("mt-1 flex w-full",c.week),week_number_header:p.cn("w-[--cell-size] select-none",c.week_number_header),week_number:p.cn("text-muted-foreground select-none text-[10px]",c.week_number),day:p.cn("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",c.day),range_start:p.cn("bg-accent rounded-l-md",c.range_start),range_middle:p.cn("rounded-none",c.range_middle),range_end:p.cn("bg-accent rounded-r-md",c.range_end),today:p.cn("rounded-md text-foreground font-medium [&>button]:ring-1 [&>button]:ring-inset [&>button]:ring-border",c.today),outside:p.cn("text-muted-foreground/60 aria-selected:text-muted-foreground/60",c.outside),disabled:p.cn("text-muted-foreground/50",c.disabled),hidden:p.cn("invisible",c.hidden),...t},components:{Root:({className:u,rootRef:d,...f})=>l.jsx("div",{"data-slot":"calendar",ref:d,className:p.cn(u),...f}),Chevron:({className:u,orientation:d,...f})=>d==="left"?l.jsx(Mm,{className:p.cn("size-4",u),...f}):d==="right"?l.jsx(Ft.ChevronRight,{className:p.cn("size-4",u),...f}):l.jsx(je.ChevronDown,{className:p.cn("size-4",u),...f}),DayButton:qXe,WeekNumber:({children:u,...d})=>l.jsx("td",{...d,children:l.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:u})}),...i},...a})}function qXe({className:e,day:t,modifiers:n,...r}){const o=T$(),s=te.useRef(null);return te.useEffect(()=>{var i;n.focused&&((i=s.current)==null||i.focus())},[n.focused]),l.jsx(p.Button,{ref:s,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:p.cn("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/40 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-0.5 rounded-md p-0 text-[12px] font-normal leading-none tabular-nums data-[range-end=true]:rounded-r-md data-[range-end=true]:rounded-l-none data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-l-md data-[range-start=true]:rounded-r-none group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[2px] [&>span]:text-[10px] [&>span]:opacity-70",o.day,e),...r})}const UXe={time:"Time",day:"Day",week:"Week",month:"Month",quarter:"Quarter",year:"Year"},Zq=(e,t)=>e?e.unit==="minute"||e.unit==="hour"?t?"time":"day":e.unit:"day",WXe=["Last 30 minutes","Last 1 hour","Last 4 hours","Last 12 hours","Last 24 hours"],KXe=(e=!1)=>{const t=[{label:"Today",value:n=>{const r=new Date;return{from:p.startOfDayInTimezone(r,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 7 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-6);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 30 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-29);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 90 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-89);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"This week",value:n=>{const r=new Date,o=p.startOfWeekInTimezone(r,n),s=p.endOfWeekInTimezone(r,n);return{from:o,to:s}},category:"week"},{label:"Last week",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-1),s=p.startOfWeekInTimezone(o,n),i=p.endOfWeekInTimezone(o,n);return{from:s,to:i}},category:"week"},{label:"Last 2 weeks",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-2),s=p.shiftDateByWeeksInTimezone(r,n,-1);return{from:p.startOfWeekInTimezone(o,n),to:p.endOfWeekInTimezone(s,n)}},category:"week"},{label:"This month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n),s=p.endOfMonthInTimezone(r,n);return{from:o,to:s}},category:"month"},{label:"Last month",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-1),s=p.startOfMonthInTimezone(o,n),i=p.endOfMonthInTimezone(o,n);return{from:s,to:i}},category:"month"},{label:"Last 3 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-3),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 6 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-6),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 9 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-9),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 12 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-12),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"This quarter",value:n=>{const r=new Date,o=p.startOfQuarterInTimezone(r,n),s=p.endOfQuarterInTimezone(r,n);return{from:o,to:s}},category:"quarter"},{label:"Last quarter",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-1),s=p.startOfQuarterInTimezone(o,n),i=p.endOfQuarterInTimezone(o,n);return{from:s,to:i}},category:"quarter"},{label:"Last 4 quarters",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-4),s=p.shiftDateByQuartersInTimezone(r,n,-1);return{from:p.startOfQuarterInTimezone(o,n),to:p.endOfQuarterInTimezone(s,n)}},category:"quarter"},{label:"This year",value:n=>{const r=new Date,o=p.startOfYearInTimezone(r,n),s=p.endOfYearInTimezone(r,n);return{from:o,to:s}},category:"year"},{label:"Last year",value:n=>{const r=new Date,o=p.shiftDateByYearsInTimezone(r,n,-1),s=p.startOfYearInTimezone(o,n),i=p.endOfYearInTimezone(o,n);return{from:s,to:i}},category:"year"}];return e?[...WXe.map(n=>({label:n,value:()=>{const r=p.presetMetadata[n],o=p.resolveSubDayRelativeDateRange(r);return o?{from:o[0],to:o[1]}:{from:new Date,to:new Date}},category:"time"})),...t]:t},Xq=[{label:"2 days ago",value:-2},{label:"Yesterday",value:-1},{label:"Today",value:0},{label:"Tomorrow",value:1},{label:"2 days ahead",value:2}],Qq=[{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}],Jq=[{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}],eU=[{label:"9 months ago",value:-9},{label:"6 months ago",value:-6},{label:"3 months ago",value:-3},{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}],tU=[{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 E$({value:e,onChange:t,selectionMode:n="range",singleValue:r,onSingleChange:o,comparisonOptions:s,comparisonValue:i,onComparisonChange:a,comparisonLabel:c="Condition",hideDateInputs:u=!1,onRelativeSelect:d,relativeValue:f,placeholder:h="All time",className:m,timezone:g,showRelativeTab:b=!0,hideCalendar:x=!1,disabled:y=!1,enableTimePrecision:w=!1,temporalPrecision:C,buttonClassName:N,buttonLabelSuffix:S,contentClassName:j,overlayContentClassName:_,targetColumns:k,selectedColumn:T,onColumnChange:I,inline:E=!1,onApplied:D,supplementalFooter:R,onOpenChange:A}){var vt,Tt;const[F,z]=v.useState(!1),[L,$]=v.useState(n==="range"?"presets":"static"),[H,M]=v.useState(()=>Zq(f,w)),[B,W]=v.useState(!1),[P,G]=v.useState(!1),[Z,X]=v.useState("Days"),[Y,O]=v.useState("0"),[q,U]=v.useState("0"),[V,K]=v.useState(w&&C==="minute"),[Q,se]=v.useState("00:00"),[oe,me]=v.useState("23:59"),[le,ue]=v.useState("00:00"),[ne,de]=v.useState(E?e:void 0),[Ce,ce]=v.useState(E?r:void 0),ie=dc("interactive"),we=ie.controlStyle,fe=ie.contentStyle;v.useEffect(()=>{E&&de(e)},[E,e]),v.useEffect(()=>{E&&ce(r)},[E,r]);const ae=p.getEffectiveTimezone(g),ee=w&&C==="minute",J=v.useMemo(()=>KXe(w),[w]),re=v.useMemo(()=>[...w?["time"]:[],"day","week","month","quarter","year"],[w]),pe=v.useMemo(()=>J.filter(Me=>Me.category===H),[H,J]),Ee=Zq(f,w),Te=b&&n==="range",ze=n==="range";v.useEffect(()=>{M(Ee)},[Ee]),v.useEffect(()=>{const Me=w&&C==="minute";K(Me),Me?(e!=null&&e.from&&se(p.formatTimeInTimezone(e.from,ae)),e!=null&&e.to&&me(p.formatTimeInTimezone(e.to,ae)),r&&ue(p.formatTimeInTimezone(r,ae))):(se("00:00"),me("23:59"),ue("00:00"))},[ae,w,r,C,e==null?void 0:e.from,e==null?void 0:e.to]),v.useEffect(()=>{if(!ze&&L!=="static"){$("static");return}!Te&&L==="relative"&&$("static")},[Te,ze,L]);const Pe=()=>{if(n==="single")return r?Kt.formatInTimeZone(r,ae,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"):h;if(e!=null&&e.from&&(e!=null&&e.to)){const Me=Kt.formatInTimeZone(e.from,ae,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"),Je=Kt.formatInTimeZone(e.to,ae,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy");return`${Me} - ${Je}`}return h},He=n==="single"?!!r:!!(e!=null&&e.from||e!=null&&e.to),ye=!!(k&&k.length>1&&I),Ke=((vt=k==null?void 0:k.find(Me=>Me.column===T))==null?void 0:vt.label)||((Tt=k==null?void 0:k[0])==null?void 0:Tt.label)||"Date",We=Me=>{const Je=Me.value(ae),kt=p.presetMetadata[Me.label],mt=w?p.getTemporalPrecisionForRelativeMeta(kt):void 0,_t=mt?{temporalPrecision:mt}:void 0;t==null||t(Je,_t),Te&&(d==null||d(Je,kt,_t)),rt(!1)},Qe=(Me,Je)=>{var Pt,wt;const kt=re.indexOf(Je);let mt;if(Me.key==="ArrowRight"||Me.key==="ArrowDown"?mt=(kt+1)%re.length:Me.key==="ArrowLeft"||Me.key==="ArrowUp"?mt=(kt-1+re.length)%re.length:Me.key==="Home"?mt=0:Me.key==="End"&&(mt=re.length-1),mt===void 0)return;Me.preventDefault();const _t=re[mt];M(_t);const Rt=(Pt=Me.currentTarget.parentElement)==null?void 0:Pt.querySelectorAll('[role="radio"]');(wt=Rt==null?void 0:Rt[mt])==null||wt.focus()},xe=()=>{n==="single"?o==null||o(void 0):t==null||t(void 0),rt(!1)},Ve=(Me,Je)=>{if(!Je)return;const kt=Me==="from"?Je:ne==null?void 0:ne.from,mt=Me==="to"?Je:ne==null?void 0:ne.to;de({from:kt,to:mt}),Me==="from"?W(!1):G(!1)},Ae=Me=>{const Je=Me===!0;if(K(Je),!Je){se("00:00"),me("23:59"),ue("00:00");return}ne!=null&&ne.from&&se(p.formatTimeInTimezone(ne.from,ae)),ne!=null&&ne.to&&me(p.formatTimeInTimezone(ne.to,ae)),Ce&&ue(p.formatTimeInTimezone(Ce,ae))},ke=()=>{if(ne!=null&&ne.from&&(ne!=null&&ne.to)){if(w&&V){const kt=p.composeDateTimeInTimezone(ne.from,Q,ae),mt=p.composeDateTimeInTimezone(ne.to,oe,ae,{boundary:"end"});if(!kt||!mt||mt.getTime()<kt.getTime())return;t==null||t({from:kt,to:mt},{temporalPrecision:"minute"}),rt(!1);return}const Me=p.startOfDayInTimezone(ne.from,ae),Je=p.endOfDayInTimezone(ne.to,ae);t==null||t({from:Me,to:Je}),rt(!1)}},Be=()=>{de(e)},Ie=()=>{if(Ce&&w&&V){const Me=i==="<="?"end":"start",Je=p.composeDateTimeInTimezone(Ce,le,ae,{boundary:Me});if(!Je)return;o==null||o(Je,{temporalPrecision:"minute"}),rt(!1);return}o==null||o(Ce),rt(!1)},$e=()=>{ce(r)},st=()=>{ce(p.startOfDayInTimezone(new Date,ae))},ct=()=>{const Me=new Date,Je=parseInt(Y,10),kt=parseInt(q,10);let mt,_t;if(Z==="Days"){const Et=p.shiftDateByDaysInTimezone(Me,ae,Je),Bt=p.shiftDateByDaysInTimezone(Me,ae,kt);mt=p.startOfDayInTimezone(Et,ae),_t=p.endOfDayInTimezone(Bt,ae)}else if(Z==="Weeks"){const Et=p.shiftDateByWeeksInTimezone(Me,ae,Je),Bt=p.shiftDateByWeeksInTimezone(Me,ae,kt);mt=p.startOfWeekInTimezone(Et,ae),_t=p.endOfWeekInTimezone(Bt,ae)}else if(Z==="Months"){const Et=p.shiftDateByMonthsInTimezone(Me,ae,Je),Bt=p.shiftDateByMonthsInTimezone(Me,ae,kt);mt=p.startOfMonthInTimezone(Et,ae),_t=p.endOfMonthInTimezone(Bt,ae)}else if(Z==="Quarters"){const Et=p.shiftDateByQuartersInTimezone(Me,ae,Je),Bt=p.shiftDateByQuartersInTimezone(Me,ae,kt);mt=p.startOfQuarterInTimezone(Et,ae),_t=p.endOfQuarterInTimezone(Bt,ae)}else{const Et=p.shiftDateByYearsInTimezone(Me,ae,Je),Bt=p.shiftDateByYearsInTimezone(Me,ae,kt);mt=p.startOfYearInTimezone(Et,ae),_t=p.endOfYearInTimezone(Bt,ae)}const Pt={mode:"between",unit:{Days:"day",Weeks:"week",Months:"month",Quarters:"quarter",Years:"year"}[Z],from:Je,to:kt},wt={from:mt,to:_t};t==null||t(wt),d==null||d(wt,Pt),rt(!1)};function rt(Me){z(Me),A==null||A(Me)}const Ct=Me=>{rt(Me),Me&&(de(e),ce(r),K(w&&C==="minute"))},Lt=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"min-w-0 flex-1",children:ye&&k?l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(za,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsxs(p.Select,{value:T,onValueChange:I,children:[l.jsx(p.SelectTrigger,{className:"h-7 max-w-[210px] rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[52]","rounded-control"),style:fe,children:k.map(Me=>l.jsx(p.SelectItem,{value:Me.column,children:Me.label},Me.column))})]})]}):l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(za,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate text-[13px] font-medium",children:Ke})]})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Using ${NN(ae)} timezone`,children:[l.jsx(hR,{className:"h-3 w-3"}),l.jsx("span",{children:fn.getTimezoneAbbreviation(ae)})]})]}),(e==null?void 0:e.from)&&(e==null?void 0:e.to)&&l.jsxs("p",{className:"mt-1 pl-[18px] font-mono text-[11px] tabular-nums text-muted-foreground",children:[Kt.formatInTimeZone(e.from,ae,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")," – ",Kt.formatInTimeZone(e.to,ae,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")]})]}),l.jsxs(p.Tabs,{value:L,onValueChange:Me=>{$(Me),Me==="static"&&de(e)},className:"w-full",children:[ze&&l.jsx("div",{className:"px-2 pt-2",children:l.jsxs(p.TabsList,{style:we,className:p.cn("inline-flex h-[30px] w-full items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5 text-muted-foreground"),children:[l.jsx(p.TabsTrigger,{value:"presets",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Presets"}),l.jsx(p.TabsTrigger,{value:"static",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Static"}),Te&&l.jsx(p.TabsTrigger,{value:"relative",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Relative"})]})}),ze&&l.jsx(p.TabsContent,{value:"presets",className:"mt-0",children:!u&&l.jsxs("div",{children:[l.jsx("div",{className:"border-b border-border px-2 py-1.5",children:l.jsx("div",{role:"radiogroup","aria-label":"Preset interval","aria-orientation":"horizontal",className:"flex items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:re.map(Me=>{const Je=Me===H;return l.jsx("button",{type:"button",role:"radio","aria-checked":Je,tabIndex:Je?0:-1,onClick:()=>M(Me),onKeyDown:kt=>Qe(kt,Me),className:p.cn("h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",Je?"bg-background text-foreground shadow-sm ring-1 ring-border":"text-muted-foreground hover:text-foreground"),children:UXe[Me]},Me)})})}),l.jsx("div",{className:"space-y-0.5 p-2",children:pe.map(Me=>l.jsx("button",{type:"button",onClick:()=>{We(Me),E&&(D==null||D())},className:"w-full rounded-control px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",children:Me.label},Me.label))})]})}),l.jsx(p.TabsContent,{value:"static",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[s&&s.length>0&&i&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:c}),l.jsxs(p.Select,{value:i,onValueChange:Me=>a==null?void 0:a(Me),children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[52]","rounded-control"),style:fe,children:s.map(Me=>l.jsx(p.SelectItem,{value:Me.value,children:Me.label},Me.value))})]})]}),!x&&!u&&(n==="single"?l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date"}),l.jsxs("div",{className:"flex items-center gap-2.5",children:[w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(Tn,{checked:V,onCheckedChange:Ae,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]}),l.jsx("button",{type:"button",onClick:st,className:"rounded-control px-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Today"})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:B,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:we,children:[l.jsx(za,{className:"mr-1.5 h-3 w-3"}),Ce?Kt.formatInTimeZone(Ce,ae,"MM/dd/yyyy"):"Select date"]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(_??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(bM,{mode:"single",selected:Ce,defaultMonth:Ce,captionLayout:"dropdown",onSelect:Me=>{ce(Me),W(!1)},className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),V&&w&&l.jsx(p.Input,{size:"xs",value:le,onChange:Me=>ue(Me.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(le),title:"Use 24-hour HH:mm time",className:"w-20 shrink-0 font-mono tabular-nums"})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom range"}),w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(Tn,{checked:V,onCheckedChange:Ae,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]})]}),l.jsxs("div",{className:p.cn(V&&w?"space-y-1.5":"flex items-center gap-1.5"),children:[l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:B,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:we,children:[l.jsx(za,{className:"mr-1.5 h-3 w-3"}),ne!=null&&ne.from?Kt.formatInTimeZone(ne.from,ae,"MM/dd/yyyy"):"From date"]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(_??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(bM,{mode:"single",selected:ne==null?void 0:ne.from,defaultMonth:ne==null?void 0:ne.from,captionLayout:"dropdown",onSelect:Me=>Ve("from",Me),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),V&&w&&l.jsx(p.Input,{size:"xs",value:Q,onChange:Me=>se(Me.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(Q),title:"Start time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]}),l.jsx("span",{className:p.cn("text-[12px] text-muted-foreground",V&&w&&"block text-center"),children:"–"}),l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:P,onOpenChange:G,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:we,children:[l.jsx(za,{className:"mr-1.5 h-3 w-3"}),ne!=null&&ne.to?Kt.formatInTimeZone(ne.to,ae,"MM/dd/yyyy"):"To date"]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(_??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(bM,{mode:"single",selected:ne==null?void 0:ne.to,defaultMonth:ne==null?void 0:ne.to,captionLayout:"dropdown",onSelect:Me=>Ve("to",Me),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),V&&w&&l.jsx(p.Input,{size:"xs",value:oe,onChange:Me=>me(Me.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(oe),title:"End time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]})]})]}))]})}),Te&&l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[l.jsx("div",{className:"inline-flex w-full items-center gap-0.5 rounded-control border border-border bg-background p-0.5",style:we,children:["Days","Weeks","Months","Quarters","Years"].map(Me=>l.jsx("button",{onClick:()=>X(Me),className:p.cn("flex-1 rounded-control px-2 py-1 text-[11px] font-medium transition-colors",Z===Me?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:Me},Me))}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:Y,onValueChange:O,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{placeholder:"From"})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[51]","rounded-control"),style:fe,children:(Z==="Years"?Qq:Z==="Quarters"?Jq:Z==="Months"?eU:Z==="Weeks"?tU:Xq).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})}),l.jsx("span",{className:"text-[12px] text-muted-foreground",children:"to"}),l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:q,onValueChange:U,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{placeholder:"To"})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[51]","rounded-control"),style:fe,children:(Z==="Years"?Qq:Z==="Quarters"?Jq:Z==="Months"?eU:Z==="Weeks"?tU:Xq).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})})]})]})})]}),R,(()=>{const Me=L==="static"&&n==="single",Je=L==="static"&&n==="range",kt=L==="relative",mt=Me&&!!Ce||Je&&!!(ne!=null&&ne.from)&&!!(ne!=null&&ne.to),_t=mt||kt,Rt=mt,Pt=w&&V,wt=Pt&&(ne!=null&&ne.from)?p.composeDateTimeInTimezone(ne.from,Q,ae):null,Et=Pt&&(ne!=null&&ne.to)?p.composeDateTimeInTimezone(ne.to,oe,ae,{boundary:"end"}):null,Bt=Je&&Pt&&(!p.isValidTimeInput(Q)||!p.isValidTimeInput(oe)||!wt||!Et||Et.getTime()<wt.getTime()),un=Me&&Pt&&!p.isValidTimeInput(le);if(!He&&!_t)return null;const Ge=()=>{Me?Ie():Je?ke():kt&&ct(),E&&(D==null||D())},Re=()=>{Me?$e():Je&&Be()},De=Me&&!Ce||Je&&(!(ne!=null&&ne.from)||!(ne!=null&&ne.to))||Bt||un;return l.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[He?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>{xe(),E&&(D==null||D())},children:"Clear"}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-1",children:[Rt&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:Re,children:"Cancel"}),_t&&l.jsx(p.Button,{type:"button",variant:"default",size:"xs",onClick:Ge,disabled:De,children:"Apply"})]})]})})()]});return E?l.jsx("div",{className:p.cn("w-full overflow-hidden bg-popover text-popover-foreground",m),style:fe,children:Lt}):l.jsx("div",{className:p.cn("w-full",m),children:l.jsxs(p.Popover,{open:F,onOpenChange:Ct,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",className:p.cn("h-8 min-w-0 w-full justify-between gap-2 rounded-control border-border bg-background text-left text-[13px] font-normal text-foreground transition-colors hover:border-border/80 hover:bg-background",N),style:we,title:`Timezone: ${NN(ae)} (${fn.getTimezoneAbbreviation(ae)})`,disabled:y,children:[l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:S?`${Pe()} · ${S}`:Pe()}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[l.jsx(hR,{className:"h-3 w-3 opacity-50"}),l.jsx(je.ChevronDown,{className:"h-3 w-3 opacity-50"})]})]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(j??"z-[51]","w-[320px] overflow-hidden rounded-control border border-border/80 bg-popover p-0 text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]"),align:"start",children:Lt})]})})}function Uce(e,t){var o,s;const n=(o=t==null?void 0:t.find(i=>i.filterId===e.id))==null?void 0:o.name,r=new Set([e.column,...((s=e.targetColumns)==null?void 0:s.map(i=>i.column))??[]]);return n&&r.has(n)?n:e.column}function GXe(e,t){const n=v.useMemo(()=>{const h={column:e.column,label:e.title};return e.targetColumns&&e.targetColumns.length>0?[h,...e.targetColumns]:[h]},[e.targetColumns,e.column,e.title]),r=(t==null?void 0:t.storageTarget)==="card",o=p.useDashboardStore(h=>h.filterValues),s=r?t==null?void 0:t.inlineFilterValues:o,i=s==null?void 0:s.find(h=>h.filterId===e.id),a=!!i,c=v.useMemo(()=>Uce(e,s),[e,s]),[u,d]=v.useState(c);v.useEffect(()=>{const h=n.some(m=>m.column===u);(i!=null&&i.name&&c!==u||!h)&&d(c)},[c,i==null?void 0:i.name,n]);const f=v.useMemo(()=>u&&u!==e.column?{...e,column:u}:e,[e,u]);return{selectedColumn:u,setSelectedColumn:d,effectiveFilter:f,targetColumns:n,hasActiveFilter:a,storedFilterValue:i}}const YXe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ZXe=["January","February","March","April","May","June","July","August","September","October","November","December"];function Wce({value:e,onChange:t,onClear:n,placeholder:r="Select month",className:o,buttonClassName:s}){const[i,a]=v.useState(!1),[c,u]=v.useState((e==null?void 0:e.year)??new Date().getFullYear()),[d,f]=v.useState(e);v.useEffect(()=>{e?(f(e),u(e.year)):(f(void 0),u(new Date().getFullYear()))},[e]);const h=x=>{u(y=>y+x)},m=x=>{f({year:c,month:x}),t==null||t(c,x),a(!1)},g=()=>{f(void 0),n==null||n(),a(!1)},b=d?`${ZXe[d.month]} ${d.year}`:r;return l.jsxs(p.Popover,{open:i,onOpenChange:a,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsx(p.Button,{variant:"outline",role:"combobox","aria-expanded":i,className:p.cn("min-w-0 w-full justify-between gap-2 px-3 text-sm font-normal",s??"h-9",!d&&"text-muted-foreground",o),children:l.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx(mN,{className:"h-4 w-4 shrink-0 opacity-50"}),l.jsx("span",{className:"truncate",children:b})]})})}),l.jsx(p.PopoverContent,{className:"z-[52] w-80 p-0",align:"start",children:l.jsxs("div",{className:"p-3",children:[l.jsxs("div",{className:"mb-3 flex items-center justify-between border-b pb-3",children:[l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(-1),"aria-label":"Previous year",children:l.jsx(Mm,{className:"h-4 w-4"})}),l.jsx("h2",{className:"text-sm font-semibold",children:c}),l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(1),"aria-label":"Next year",children:l.jsx(Ft.ChevronRight,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:YXe.map((x,y)=>{const w=(d==null?void 0:d.month)===y&&(d==null?void 0:d.year)===c;return l.jsx(p.Button,{variant:w?"outline":"ghost",className:p.cn("h-9 text-sm font-medium",!w&&"hover:bg-muted",w&&"border-foreground"),onClick:()=>m(y),children:x},x)})}),d&&l.jsx("div",{className:"mt-3 border-t pt-3",children:l.jsx(p.Button,{variant:"ghost",onClick:g,className:"h-9 w-full justify-center text-sm",children:"Clear selection"})})]})})]})}const V1=[{value:"between",label:"Is between"},{value:"<",label:"Is before"},{value:">",label:"Is after"},{value:"<=",label:"Is on or before"},{value:">=",label:"Is on or after"},{value:"=",label:"Is exactly"}],XXe=new Set(V1.map(e=>e.value)),QXe=new Set(["between","not between","=","!=",">",">=","<","<="]),JXe={"not between":"Is not between","!=":"Is not exactly"},xM=e=>typeof e=="string"&&QXe.has(e);function Kce({filter:e,className:t,isCardStorage:n,timezone:r,selectedColumn:o,setSelectedColumn:s,targetColumns:i,hasActiveFilter:a,enableTimePrecision:c,storedFilterValue:u,activeFilterValue:d,dateRange:f,isLoading:h,isFetching:m,isError:g,hasData:b,setDateRange:x,handleChange:y,handleRelativeChange:w,handleClear:C,inline:N=!1,onApplied:S,supplementalFooter:j}){const _=n?"h-8":"h-9",k=n?"h-[31px]":"h-[35px]",T=e.dateSelectionMode==="months"?"months":"range",I=a?f:void 0,E=xM(e.operation)?e.operation:"between",[D,R]=v.useState(o),[A,F]=v.useState(E);v.useEffect(()=>{if(d&&xM(d.operation)){F(d.operation);return}F(E)},[d,E]);const z=v.useMemo(()=>{if(XXe.has(A))return V1;const V=JXe[A];return V?[...V1,{value:A,label:V}]:V1},[A]);if(v.useEffect(()=>{if(o!==void 0&&s&&o!==D){if(R(o),!a)return;const V=xM(u==null?void 0:u.operation)?u.operation:A,K=(u==null?void 0:u.temporalPrecision)==="minute"?{temporalPrecision:"minute"}:void 0,Q=u==null?void 0:u.relativeMeta;if(Q&&V==="between"&&f){w(f,Q,K);return}if(V==="between"||V==="not between"){f&&y(f,V,K);return}const se=(f==null?void 0:f.from)||(f==null?void 0:f.to);se&&y({from:se,to:se},V,K)}},[o,D,f,y,w,s,u,a,A]),!N&&(h||m))return l.jsx("div",{children:l.jsx(Xs,{className:p.cn(k,"w-full bg-foreground/10")})});if(g)return l.jsx(S$,{isCardStorage:n});if(!N&&!b)return l.jsx(p.Label,{className:p.cn("flex w-full items-center bg-muted px-2",_),children:"No Data"});const L=A==="between"||A==="not between",$=(c||p.getFilterTemporalCapability(e)==="datetime")&&p.supportsMinutePrecisionForOperation(A),H=d,M=$&&(H==null?void 0:H.temporalPrecision)==="minute"?"minute":$?p.getTemporalPrecisionForRelativeMeta(H==null?void 0:H.relativeMeta):void 0,B=e.showLabel===!1?e.title||e.column:void 0,W=V=>{if(!V)return;const K=V instanceof Date?V:new Date(V);return isNaN(K.getTime())?void 0:K},P=()=>{const V=d==null?void 0:d.operation,K=d==null?void 0:d.values;if(!V||!Array.isArray(K)||K.length<2||V!=="between"&&V!=="not between")return;const Q=W(K[0]),se=W(K[1]);if(!(!Q&&!se))return{from:Q,to:se}},G=()=>{const V=d==null?void 0:d.operation,K=d==null?void 0:d.values;if(!(!V||!Array.isArray(K)||K.length<1||!["=","!=",">",">=","<","<="].includes(V)))return W(K[0])},Z=V=>{const K=P();if(K){if(V==="<"||V==="<=")return K.to||K.from;if(V===">"||V===">="||V==="=")return K.from||K.to}return G()},X=(V,K,Q={})=>Q.temporalPrecision==="minute"?V:K==="<="||K===">"?p.endOfDayInTimezone(V,r):p.startOfDayInTimezone(V,r),Y=(V,K)=>{if(!V){C();return}y(V,L?A:"between",K)},O=(V,K)=>{if(!V){C();return}const Q=X(V,A,K);x({from:Q,to:Q}),y({from:Q,to:Q},A,K)},q=V=>{if(F(V),!a||!d)return;if(V==="between"||V==="not between"){const Q=P();if(Q!=null&&Q.from||Q!=null&&Q.to){y({from:Q.from,to:Q.to},V,M?{temporalPrecision:M}:{});return}const se=G();if(se){const oe={from:p.startOfDayInTimezone(se,r),to:p.endOfDayInTimezone(se,r)};y(oe,V)}return}const K=Z(V);if(K){const Q=M&&p.supportsMinutePrecisionForOperation(V)?{temporalPrecision:M}:{},se=X(K,V,Q);x({from:se,to:se}),y({from:se,to:se},V,Q);return}},U=(V,K,Q)=>{w(V,K,Q)};if(T==="months"){const V=I!=null&&I.from?(()=>{const se=Kt.toZonedTime(I.from,r);return{year:Wxe(se),month:Uxe(se)}})():void 0,K=se=>`${se}`.padStart(2,"0"),Q=(se,oe)=>{const me=`${se}-${K(oe+1)}-01T00:00:00`,le=oe===11?se+1:se,ue=(oe+1)%12,ne=`${le}-${K(ue+1)}-01T00:00:00`;return{from:iB.fromZonedTime(me,r),to:iB.fromZonedTime(ne,r)}};return l.jsx(Wce,{className:t,buttonClassName:_,value:V,placeholder:B||"All months",onClear:C,onChange:(se,oe)=>{const{from:me,to:le}=Q(se,oe);y({from:me,to:le})}})}return l.jsx(E$,{value:L?I:void 0,singleValue:L||I==null?void 0:I.from,selectionMode:L?"range":"single",buttonClassName:_,onChange:Y,onSingleChange:O,onRelativeSelect:U,relativeValue:H==null?void 0:H.relativeMeta,comparisonOptions:z,comparisonValue:A,onComparisonChange:q,comparisonLabel:"Condition",timezone:r,enableTimePrecision:$,temporalPrecision:M,showRelativeTab:A==="between",className:t,placeholder:B||(L?"All time":"Select date"),targetColumns:i&&i.length>1?i:void 0,selectedColumn:o,onColumnChange:s,inline:N,onApplied:S,supplementalFooter:j})}function eQe({filter:e,className:t,storageOptions:n,inline:r,onApplied:o,supplementalFooter:s}){const i=dl(),{selectedColumn:a,setSelectedColumn:c,effectiveFilter:u,targetColumns:d,hasActiveFilter:f,storedFilterValue:h}=GXe(e,n),{records:m,dateRange:g,isLoading:b,isFetching:x,isError:y,setDateRange:w,activeFilterValue:C,handleChange:N,handleRelativeChange:S,handleClear:j}=N$(u,n);return l.jsx(Kce,{filter:u,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:i,selectedColumn:a,setSelectedColumn:c,targetColumns:d,hasActiveFilter:f,storedFilterValue:h,activeFilterValue:C,dateRange:g,isLoading:b,isFetching:x,isError:y,hasData:!!m,setDateRange:w,handleChange:N,handleRelativeChange:S,handleClear:j,inline:r,onApplied:o,supplementalFooter:s})}function tQe({filter:e,className:t,storageOptions:n,managedState:r,inline:o,onApplied:s,supplementalFooter:i}){const a=dl();return l.jsx(Kce,{filter:e,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:a,hasActiveFilter:r.hasActiveFilter??!!r.activeFilterValue,enableTimePrecision:r.enableTimePrecision,storedFilterValue:r.storedFilterValue??r.activeFilterValue,activeFilterValue:r.activeFilterValue,dateRange:r.dateRange,isLoading:r.isLoading??!1,isFetching:r.isFetching??!1,isError:r.isError??!1,hasData:r.hasData??!0,setDateRange:r.setDateRange??(()=>{}),handleChange:r.handleChange,handleRelativeChange:r.handleRelativeChange,handleClear:r.handleClear,inline:o,onApplied:s,supplementalFooter:i})}function D$(e){return"managedState"in e?l.jsx(tQe,{...e}):l.jsx(eQe,{...e})}function nU({filter:e,storageOptions:t}){return p.isDateDataType(e.dataType)?l.jsx(D$,{filter:e,storageOptions:t}):e.uiType==="radio"&&e.type==="single"?l.jsx(yce,{filter:e,storageOptions:t}):e.uiType==="tabs"&&e.type==="single"?l.jsx(vce,{filter:e,storageOptions:t}):l.jsx(bce,{filter:e,storageOptions:t})}function nQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var N;const{filteredRecords:o,selectedRecords:s,handleChange:i,handleClear:a,handleSelectAll:c,query:u,setQuery:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:b,allSelected:x,activeFilterValue:y}=Vb(e,{enableServerSearch:!0,...r}),w={filter:e,options:o||[],selectedValues:s||[],onChange:i,onClear:a,onSelectAll:c,searchQuery:u,onSearchChange:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:b,allSelected:x,activeFilterValue:y,theme:n,settings:(N=e.customFilterPreferences)==null?void 0:N.settings},C=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(Xs,{className:`${C} w-full bg-foreground/10`}),children:l.jsx(t,{...w})})}function rQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var x;const{dateRange:o,initialDateRange:s,handleChange:i,handleRelativeChange:a,handleClear:c,handleReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m}=N$(e,r),g={filter:e,dateRange:o,initialDateRange:s,onDateChange:i,onRelativeDateChange:a,onClear:c,onReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m,theme:n,settings:(x=e.customFilterPreferences)==null?void 0:x.settings},b=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(Xs,{className:`${b} w-full bg-foreground/10`}),children:l.jsx(t,{...g})})}function oQe({filter:e,storageOptions:t}){var h,m,g;const{compiledAppearance:n}=p.useAppearance(),r=(t==null?void 0:t.storageTarget)==="card"?"h-[31px]":"h-[35px]",o=v.useMemo(()=>Aw(n),[n]),{getFilter:s,isLoading:i,isError:a}=Nf(((h=e.customFilterPreferences)==null?void 0:h.url)||""),c=(m=e.customFilterPreferences)==null?void 0:m.componentName,u=c?s(c):null;if(!c||!((g=e.customFilterPreferences)!=null&&g.url)||a||!i&&!u)return l.jsx(nU,{filter:e,storageOptions:t});if(i||!u)return l.jsx(Xs,{className:`${r} w-full bg-foreground/10`});const f=p.isDateDataType(e.dataType);return l.jsx(Si,{fallback:l.jsx(nU,{filter:e,storageOptions:t}),onError:b=>console.error("Custom filter runtime error:",b),children:f?l.jsx(rQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t}):l.jsx(nQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t})})}const sQe=v.memo(oQe);function Lw(e,t){return Rk(ab({dashboard:e}).allInputs).find(n=>n.kind==="filter"&&n.filter.id===t)}function Gce({selection:e,controlLabel:t,onChange:n}){const r=v.useId(),o=e.mode==="period"?e.spec:void 0,s=(o==null?void 0:o.kind)==="previous_year"?o.offsetYears||1:(o==null?void 0:o.kind)==="previous_period"&&o.offsetPeriods||1,i=(o==null?void 0:o.kind)||"off",a=`${r}-comparison`,c=d=>{o&&n({mode:"period",spec:{...o,...d}})},u=d=>{if(d==="off"){n({mode:"off"});return}n({mode:"period",spec:d==="previous_year"?{kind:"previous_year",toDate:!0}:{kind:"previous_period",toDate:!0}})};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{role:"radiogroup","aria-label":`${t} comparison`,className:"grid grid-cols-3 gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:[["off","Off"],["previous_period","Previous period"],["previous_year","Previous year"]].map(([d,f])=>{const h=i===d;return l.jsxs("label",{className:"cursor-pointer",children:[l.jsx("input",{type:"radio",name:a,value:d,checked:h,onChange:()=>u(d),className:"peer sr-only"}),l.jsx("span",{className:p.cn("flex h-6 items-center justify-center rounded-control px-1.5 text-center text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/20",h&&"bg-background text-foreground shadow-sm ring-1 ring-border"),children:f})]},d)})}),o?l.jsxs("div",{className:"space-y-2 rounded-control bg-muted/35 p-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(p.Label,{htmlFor:r,className:"text-xs",children:"Offset"}),l.jsx(p.Input,{id:r,"aria-label":"Comparison offset",type:"number",min:1,step:1,className:"h-7 w-20 text-xs",value:s,onFocus:d=>d.currentTarget.select(),onChange:d=>{const f=Number.parseInt(d.target.value,10);!Number.isInteger(f)||f<1||c(o.kind==="previous_year"?{offsetYears:f}:{offsetPeriods:f})}})]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(Tn,{checked:o.toDate===!0,onCheckedChange:d=>c({toDate:d===!0})}),"To date"]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(Tn,{checked:o.alignment==="weekday",onCheckedChange:d=>c({alignment:d===!0?"weekday":"calendar"})}),"Match weekdays"]})]}):null]})}function Yce({selection:e,controlLabel:t,scopeMessage:n,authorControlledCardCount:r,activeDateFilterValue:o,hasRuntimeOverride:s,onChange:i,onReset:a}){const c=e.mode==="period"?e.spec:void 0,u=p.hasFiniteDateComparisonRange(o);return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),s?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Reset"}):null]}),l.jsx(Gce,{selection:e,controlLabel:t,onChange:i}),l.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[u?n:c?`Choose a ${t} range to activate this comparison.`:`Choose a ${t} range to enable comparison.`,r>0?` ${r} visual${r===1?" contains":"s contain"} author-controlled comparison settings, which take precedence.`:""]})]})}function M$(e,t){const n=p.useDashboardStore(s=>s.dashboard),r=p.useDashboardStore(s=>s.selectedSheetId),o=p.useDashboardStore(s=>s.dashboardInputValues);return v.useMemo(()=>{var a;if((t==null?void 0:t.storageTarget)==="card")return t;const s=((a=t==null?void 0:t.dashboardInput)==null?void 0:a.kind)==="filter"?t.dashboardInput:Lw(n,e.id);if(!s)return t;const i=p.getDashboardInputRuntimeSlot(o,s,{sheetId:(t==null?void 0:t.sheetId)||r});return(i==null?void 0:i.status)!=="set"&&(i==null?void 0:i.status)!=="cleared"?t:{...t,storageTarget:"dashboardInput",dashboardInput:s,sheetId:(t==null?void 0:t.sheetId)||r||void 0}},[n,o,e.id,r,t])}function yM(e){if(!e)return;const t=e instanceof Date?e:new Date(e);return isNaN(t.getTime())?void 0:t}function Zce({filter:e,storageOptions:t,inline:n,onApplied:r}){var A;const o=M$(e,t),s=p.useDashboardStore(F=>F.filterValues),i=p.useDashboardStore(F=>F.dashboard),a=p.useDashboardStore(F=>F.dashboardInputValues),c=p.useDashboardStore(F=>F.selectedSheetId),u=p.useDashboardStore(F=>F.semanticExecutionPayload),{addOrUpdateFilterValue:d,removeFilterValues:f,setDashboardInputSlot:h,clearDashboardInputSlot:m,setDashboardInputComparisonSelection:g,resetDashboardInputComparisonSelection:b}=p.useDashboardActions(),x=v.useMemo(()=>p.getGlobalDateFilterCoverage(i,u,e),[i,e,u]),y=v.useMemo(()=>{const F=o==null?void 0:o.dashboardInput;return(F==null?void 0:F.kind)==="filter"?F:Lw(i,e.id)},[i,e.id,o==null?void 0:o.dashboardInput]),w=v.useMemo(()=>({sheetId:(o==null?void 0:o.sheetId)||c}),[c,o==null?void 0:o.sheetId]),C=!!(y&&p.canAddressDashboardInputRuntimeSlot(y,w)),N=v.useMemo(()=>y&&C?p.hydrateAuthoredDashboardInputSlot({dashboard:i,input:y,runtimeValues:a,target:w}):void 0,[C,i,y,w,a]),S=(N==null?void 0:N.comparisonSelection)||{mode:"off"},j=(N==null?void 0:N.status)==="set"&&N.value.kind==="filter"?N.value.filterValue:void 0,_=(o==null?void 0:o.storageTarget)==="dashboardInput",k=_?j:s==null?void 0:s.find(F=>F.filterId===e.id),T=v.useCallback(F=>{if(_){if(!y)return;const z=p.createFilterDashboardInputSlot(F);z&&h(y,w,z);return}d(F)},[d,y,w,_,h]),I=v.useCallback(()=>{if(_){if(!y)return;m(y,w);return}f(e.id)},[m,y,w,e.id,_,f]),E=y?C&&((A=p.getDashboardInputRuntimeSlot(a,y,w))==null?void 0:A.comparisonSelection)!==void 0:!1,D=v.useMemo(()=>{const F=new Set(x.eligibleCardIds);return p.getDashboardCards(i).filter(z=>{var L,$;return F.has(z.id)?((L=z.preferences)==null?void 0:L.inheritGlobalComparison)===!1?!0:((($=z.config)==null?void 0:$.metricColumns)||[]).some(H=>H.comparison!==void 0):!1}).length},[i,x.eligibleCardIds]),R=v.useMemo(()=>{var F;return{hasData:!0,hasActiveFilter:!!k,enableTimePrecision:x.allEligibleTargetsAreDateTime,activeFilterValue:k,storedFilterValue:k,dateRange:(F=k==null?void 0:k.values)!=null&&F.length?{from:yM(k.values[0]),to:k.values.length>1?yM(k.values[1]):yM(k.values[0])}:void 0,handleChange:(z,L="between",$={})=>{if(!z){I();return}let H;if(L==="between"||L==="not between")H={filterId:e.id,name:e.column,valueType:"date",operation:L,values:p.normalizeDateFilterRange(z,{temporalPrecision:$.temporalPrecision}).values,dataType:e.dataType,...$.temporalPrecision?{temporalPrecision:$.temporalPrecision}:{}};else{const M=z.from||z.to;if(!M){I();return}H={filterId:e.id,name:e.column,valueType:"date",operation:L,values:[M],dataType:e.dataType,...$.temporalPrecision?{temporalPrecision:$.temporalPrecision}:{}}}T(H)},handleRelativeChange:(z,L,$={})=>{if(!z)return;const H=$.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(L),M={filterId:e.id,name:e.column,valueType:"date",operation:"between",values:p.normalizeDateFilterRange(z,{temporalPrecision:H}).values,dataType:e.dataType,relativeMeta:L,...H?{temporalPrecision:H}:{}};T(M)},handleClear:I}},[k,I,e,x.allEligibleTargetsAreDateTime,T]);return l.jsx(D$,{filter:e,managedState:R,inline:n,onApplied:r,supplementalFooter:y&&C?l.jsx(Yce,{selection:S,controlLabel:"Global Date",scopeMessage:x.eligibleCardCount>0?`Comparison applies to ${x.eligibleCardCount} of ${x.totalCardCount} date-based visuals.`:"No visuals use Global Date for comparison.",authorControlledCardCount:D,activeDateFilterValue:k,hasRuntimeOverride:E,onChange:F=>g(y,w,F),onReset:()=>b(y,w)}):void 0})}function iQe(e){const t=p.getGlobalDateFilterCoverage(e.dashboard,e.semanticExecutionPayload),n=[];for(const{sheet:r,card:o}of p.getDashboardCardEntries(e.dashboard)){if(!p.dashboardInputRuntimeTargetsShareSlot(e.dashboardInput,e.dashboardInputTarget,{sheetId:r.id,cardId:o.id}))continue;const s=Yi({dashboard:e.dashboard,sheetId:r.id,card:o,runtimeValues:e.runtimeValues,mode:"interactive",timezone:e.timezone}),i=hb({card:o,dashboard:e.dashboard,interactionStates:e.interactionStates,currentDashboardId:e.dashboard.id,filters:e.dashboard.filters,filterValues:e.runtimeValues.filterValues,selectedSheetId:r.id,inlineFilterValuesMap:e.runtimeValues.inlineFilterValuesMap,dashboardControls:e.dashboard.controls,dashboardControlValues:e.runtimeValues.controlValues,cardControlValuesMap:e.runtimeValues.cardControlValuesMap,dashboardInputContext:s}),a=Jv({card:o,queryContext:i,semanticExecutionPayload:e.semanticExecutionPayload,timezone:e.timezone,allowMinutePrecision:t.allEligibleTargetsAreDateTime});n.push({card:o,plan:a.dateComparisonPlan})}return O_e({inputId:e.dashboardInput.id,targets:n})}function aQe(e){const t=[];return e.ownerCardCount>0&&t.push(`Comparison applies to ${e.ownerCardCount} of ${e.matchingCardCount} visuals using this date field.`),e.globalPrecedenceCardCount>0&&t.push(`Global Date controls comparison for ${e.globalPrecedenceCardCount} of those visual${e.globalPrecedenceCardCount===1?"":"s"}.`),e.ambiguousCardCount>0&&t.push(`Comparison is unavailable for ${e.ambiguousCardCount} visual${e.ambiguousCardCount===1?"":"s"} because more than one active filter uses this date field.`),t.length>0?t.join(" "):e.matchingCardCount>0?`Comparison is available for ${e.matchingCardCount} visual${e.matchingCardCount===1?"":"s"} using this date field.`:"No visuals use this date filter for comparison."}function Xce({filter:e,storageOptions:t,inline:n,onApplied:r}){var E;const o=p.useDashboardStore(D=>D.dashboard),s=p.useDashboardStore(D=>D.filterValues),i=p.useDashboardStore(D=>D.controlValues),a=p.useDashboardStore(D=>D.dashboardInputValues),c=p.useDashboardStore(D=>D.inlineFilterValuesMap),u=p.useDashboardStore(D=>D.cardControlValuesMap),d=p.useDashboardStore(D=>D.selectedSheetId),f=p.useDashboardStore(D=>D.semanticExecutionPayload),h=p.useInteractionStore(D=>D.interactionStates),{setDashboardInputComparisonSelection:m,resetDashboardInputComparisonSelection:g}=p.useDashboardActions(),b=dl(),x=v.useMemo(()=>{const D=t==null?void 0:t.dashboardInput;return(D==null?void 0:D.kind)==="filter"?D:Lw(o,e.id)},[o,e.id,t==null?void 0:t.dashboardInput]),y=v.useMemo(()=>({sheetId:(t==null?void 0:t.sheetId)||d}),[d,t==null?void 0:t.sheetId]),w=!!(x&&p.canAddressDashboardInputRuntimeSlot(x,y)),C=v.useMemo(()=>x&&w?p.hydrateAuthoredDashboardInputSlot({dashboard:o,input:x,runtimeValues:a,target:y,timezone:b}):void 0,[o,x,y,a,w,b]),N=(C==null?void 0:C.status)==="set"&&C.value.kind==="filter"?C.value.filterValue:void 0,S=(t==null?void 0:t.storageTarget)==="dashboardInput"?N:s==null?void 0:s.find(D=>D.filterId===e.id),j=(C==null?void 0:C.comparisonSelection)||{mode:"off"},_=x?w&&((E=p.getDashboardInputRuntimeSlot(a,x,y))==null?void 0:E.comparisonSelection)!==void 0:!1,k=!!(x&&w&&(t==null?void 0:t.storageTarget)!=="card"&&p.isComparisonCapableDashboardDateInput(x)),T=v.useMemo(()=>!x||!k?{ownerCardCount:0,matchingCardCount:0,globalPrecedenceCardCount:0,ambiguousCardCount:0,authorControlledCardCount:0}:iQe({dashboard:o,dashboardInput:x,dashboardInputTarget:y,interactionStates:h,semanticExecutionPayload:f,runtimeValues:{dashboardInputValues:a,filterValues:s,controlValues:i,inlineFilterValuesMap:c,cardControlValuesMap:u},timezone:b}),[u,i,o,x,y,a,s,c,h,k,f,b]),I=v.useMemo(()=>aQe(T),[T]);return l.jsx(D$,{filter:e,storageOptions:t,inline:n,onApplied:r,supplementalFooter:x&&k?l.jsx(Yce,{selection:j,controlLabel:x.label||e.title||"date",scopeMessage:I,authorControlledCardCount:T.authorControlledCardCount,activeDateFilterValue:S,hasRuntimeOverride:_,onChange:D=>m(x,y,D),onReset:()=>g(x,y)}):void 0})}function FI({filter:e,storageOptions:t}){var r,o;const n=M$(e,t);return e.kind==="global-date"?l.jsx(Zce,{filter:e,storageOptions:n}):(r=e.customFilterPreferences)!=null&&r.url&&((o=e.customFilterPreferences)!=null&&o.componentName)?l.jsx(sQe,{filter:e,storageOptions:n}):p.isDateDataType(e.dataType)?l.jsx(Xce,{filter:e,storageOptions:n}):e.uiType==="radio"&&e.type==="single"?l.jsx(yce,{filter:e,storageOptions:n}):e.uiType==="tabs"&&e.type==="single"?l.jsx(vce,{filter:e,storageOptions:n}):l.jsx(bce,{filter:e,storageOptions:n})}function Qce({className:e,message:t="Failed to load options"}){return l.jsx("p",{className:p.cn("px-2 py-2 text-[12px] text-destructive",e),children:t})}function lQe({filter:e,storageOptions:t,onApplied:n}){var H;const{filteredRecords:r,selectedRecords:o,handleChange:s,query:i,setQuery:a,isLoading:c,isFetching:u,isPlaceholderData:d,isError:f,isSearching:h,searchError:m,isSingleSelect:g,activeFilterValue:b}=Vb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),y=`Search ${(e.title||e.column||"options").toLowerCase()}`,[w,C]=v.useState(o),[N,S]=v.useState(!1);v.useEffect(()=>{N||C(o)},[o,N]);const j=v.useMemo(()=>new Set(w.map(M=>M.value)),[w]),_=(b==null?void 0:b.operation)==="is null"||(b==null?void 0:b.operation)==="is not null",k=(((H=b==null?void 0:b.values)==null?void 0:H.length)??0)>0||_,I=c||u&&d,E=M=>{if(g){C([M]),S(!0);return}S(!0),C(B=>B.some(P=>P.value===M.value)?B.filter(P=>P.value!==M.value):[...B,M])},D=(M,B)=>{M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),E(B))},R=r.length>0&&r.every(M=>j.has(M.value)),A=!r.some(M=>j.has(M.value)),F=R?"checked":A?"unchecked":"indeterminate",z=()=>{if(S(!0),F==="checked"){const M=new Set(r.map(B=>B.value));C(B=>B.filter(W=>!M.has(W.value)))}else C(M=>{const B=new Map(M.map(W=>[W.value,W]));return r.forEach(W=>B.set(W.value,W)),Array.from(B.values())})},L=()=>{s(w),S(!1),n==null||n()},$=()=>{C([]),S(!0)};return f?l.jsx(Qce,{}):l.jsxs("div",{className:"flex flex-col p-2",children:[l.jsxs("div",{className:"mb-2 flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[h?l.jsx(p.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground","aria-label":"Searching","aria-live":"polite"}):l.jsx(Ft.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:i,onChange:M=>a(M.target.value),placeholder:y,"aria-label":y,className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),i&&l.jsx("button",{type:"button",onClick:()=>a(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(je.X,{className:"h-3 w-3"})})]}),m&&l.jsxs("div",{className:"mb-2 flex items-start gap-1.5 rounded-[4px] border border-destructive/30 bg-destructive/5 px-2 py-1 text-[11px] text-destructive",children:[l.jsx(Ca,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:typeof m=="string"?m:"Search failed — showing local results"})]}),l.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[!g&&l.jsx(xce,{filter:e,storageOptions:t}),!g&&r.length>0&&l.jsxs("label",{className:"ml-auto inline-flex cursor-pointer items-center gap-1.5 text-[12px] text-muted-foreground",children:[l.jsx("span",{children:"All"}),l.jsx(Tn,{checked:F==="checked"?!0:F==="indeterminate"?"indeterminate":!1,onCheckedChange:z,"aria-label":"Select all"})]})]}),l.jsx("div",{className:"-mx-1 max-h-[260px] overflow-y-auto px-1",role:"listbox","aria-multiselectable":!g,children:I?l.jsx("div",{className:"space-y-0.5",children:Array.from({length:6}).map((M,B)=>{const W=["w-32","w-24","w-40","w-28","w-36","w-20"];return l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5","aria-hidden":"true",children:[l.jsx(Xs,{className:"h-3.5 w-3.5 shrink-0 rounded-[3px] bg-foreground/[0.06]"}),l.jsx(Xs,{className:p.cn("h-3 rounded-[3px] bg-foreground/[0.06]",W[B%W.length])})]},B)})}):r.length===0?l.jsx("div",{className:"px-2 py-6 text-center text-[12px] text-muted-foreground",children:i?"No matches":"No options"}):r.map(M=>{var P;const B=j.has(M.value),W=((P=M.label)==null?void 0:P.toString())||String(M.value);return l.jsxs("div",{role:"option",tabIndex:0,"aria-selected":B,onClick:()=>E(M),onKeyDown:G=>D(G,M),className:p.cn("flex w-full cursor-pointer select-none items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px] text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",B?"bg-muted hover:bg-foreground/[0.08]":"hover:bg-muted"),children:[l.jsx(Tn,{checked:B,className:"pointer-events-none",tabIndex:-1,"aria-hidden":"true"}),l.jsx("span",{className:"truncate",children:W})]},`${M.id}:${M.value}`)})}),l.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border-t border-border pt-2",children:[l.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"tabular-nums text-foreground",children:_&&!N&&w.length===0?1:w.length})," ","selected"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[(N||k)&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:$,children:"Clear"}),l.jsx(p.Button,{type:"button",variant:"default",size:"xs",onClick:L,disabled:!N,children:"Apply"})]})]})]})}function cQe({filter:e,onUpdate:t}){const[n,r]=v.useState(""),o=p.useDashboardStore(N=>N.dashboard.sheets),s=v.useMemo(()=>p.getDashboardSheets(o??[]),[o]),i=p.useDashboardStore(N=>N.selectedSheetId),a=v.useMemo(()=>{const N=[];return s.forEach(S=>{var j;(j=S.frames)==null||j.forEach(_=>{var k;(k=_.cards)==null||k.forEach(T=>{N.push({...T,sheetId:S.id,sheetTitle:S.title||S.id})})})}),N},[s]),c=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",u=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",d=N=>{const S={};switch(N){case"all-sheets":S.applyToSheetIds=void 0,S.excludeSheetIds=void 0;break;case"specific-sheets":S.applyToSheetIds=[],S.excludeSheetIds=void 0;break;case"all-except-specific":S.applyToSheetIds=void 0,S.excludeSheetIds=[];break}t(S)},f=N=>{const S={};switch(N){case"all-cards":S.applyToCardIds=void 0,S.excludeCardIds=void 0;break;case"specific-cards":S.applyToCardIds=[],S.excludeCardIds=void 0;break;case"all-except-specific":S.applyToCardIds=void 0,S.excludeCardIds=[];break}t(S)},h=(N,S)=>{if(S==="specific-sheets"){const j=e.applyToSheetIds||[];t({applyToSheetIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}else if(S==="all-except-specific"){const j=e.excludeSheetIds||[];t({excludeSheetIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}},m=(N,S)=>{if(S==="specific-cards"){const j=e.applyToCardIds||[];t({applyToCardIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}else if(S==="all-except-specific"){const j=e.excludeCardIds||[];t({excludeCardIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}},g=v.useMemo(()=>e.applyToSheetIds!==void 0?e.applyToSheetIds:e.excludeSheetIds!==void 0?s.filter(N=>{var S;return!((S=e.excludeSheetIds)!=null&&S.includes(N.id))}).map(N=>N.id):s.map(N=>N.id),[s,e.applyToSheetIds,e.excludeSheetIds]),b=v.useMemo(()=>a.filter(N=>g.includes(N.sheetId)),[a,g]),x=v.useMemo(()=>{if(!n.trim())return b;const N=n.toLowerCase();return b.filter(S=>{var j;return(j=S==null?void 0:S.title)==null?void 0:j.toLowerCase().includes(N)})},[n,b]),y=c(),w=u(),C=(N,S,j,_)=>l.jsxs("label",{htmlFor:S,className:"flex cursor-pointer items-start gap-2 rounded-control px-1 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsx(vs,{value:N,id:S,className:"mt-0.5"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("span",{className:"text-[13px] text-foreground",children:j}),_?l.jsx("p",{className:"text-[11px] text-muted-foreground",children:_}):null]})]});return l.jsxs("div",{className:"space-y-5",children:[l.jsxs("section",{className:"space-y-2",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Sheet scope"}),l.jsxs(rl,{value:y,onValueChange:N=>d(N),className:"space-y-0.5",children:[C("all-sheets","all-sheets","All sheets",`Display on every dashboard sheet (${s.length} total)`),C("specific-sheets","specific-sheets","Only specific sheets"),y==="specific-sheets"&&l.jsx("div",{className:"ml-6 mt-1 flex max-h-40 flex-col gap-0.5 overflow-y-auto border-l border-border/60 pl-3",children:s.map(N=>{const S=(e.applyToSheetIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`sheet-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`sheet-${N.id}`,checked:S,onCheckedChange:()=>h(N.id,"specific-sheets")}),l.jsx("span",{className:"truncate text-[13px] text-foreground",children:N.title||N.id}),N.id===i&&l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"· current"})]},N.id)})}),C("all-except-specific","all-sheets-except","All except specific sheets"),y==="all-except-specific"&&l.jsx("div",{className:"ml-6 mt-1 flex max-h-40 flex-col gap-0.5 overflow-y-auto border-l border-border/60 pl-3",children:s.map(N=>{const S=(e.excludeSheetIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`sheet-exclude-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`sheet-exclude-${N.id}`,checked:S,onCheckedChange:()=>h(N.id,"all-except-specific")}),l.jsx("span",{className:"truncate text-[13px] text-foreground",children:N.title||N.id}),N.id===i&&l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"· current"})]},N.id)})})]})]}),l.jsxs("section",{className:"space-y-2 border-t border-border/60 pt-4",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Card scope"}),l.jsxs(rl,{value:w,onValueChange:N=>f(N),className:"space-y-0.5",children:[C("all-cards","all-cards","All cards",`Apply to every card in applicable sheets (${b.length} total)`),C("specific-cards","specific-cards","Only specific cards"),w==="specific-cards"&&l.jsxs("div",{className:"ml-6 mt-1 space-y-1 border-l border-border/60 pl-3",children:[l.jsx(p.Input,{size:"xs",placeholder:"Search cards…",value:n,onChange:N=>r(N.target.value)}),l.jsx("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto pt-1",children:x.length>0?x.map(N=>{const S=(e.applyToCardIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`card-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`card-${N.id}`,checked:S,onCheckedChange:()=>m(N.id,"specific-cards")}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[13px] text-foreground",children:N.title}),l.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:N.sheetTitle})]})]},N.id)}):l.jsxs("p",{className:"py-4 text-center text-[12px] text-muted-foreground",children:["No cards match “",n,"”."]})})]}),C("all-except-specific","all-cards-except","All except specific cards"),w==="all-except-specific"&&l.jsxs("div",{className:"ml-6 mt-1 space-y-1 border-l border-border/60 pl-3",children:[l.jsx(p.Input,{size:"xs",placeholder:"Search cards…",value:n,onChange:N=>r(N.target.value)}),l.jsx("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto pt-1",children:x.length>0?x.map(N=>{const S=(e.excludeCardIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`card-exclude-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`card-exclude-${N.id}`,checked:S,onCheckedChange:()=>m(N.id,"all-except-specific")}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[13px] text-foreground",children:N.title}),l.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:N.sheetTitle})]})]},N.id)}):l.jsxs("p",{className:"py-4 text-center text-[12px] text-muted-foreground",children:["No cards match “",n,"”."]})})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Card scope is restricted to cards in the sheets selected above."})]})}function OI(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var uQe=["color"],dQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,uQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),fQe=["color"],hQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,fQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),mQe=["color"],pQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,mQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),gQe=["color"],bQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,gQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function Pd({text:e,className:t,ariaLabel:n,onCopy:r,disabled:o=!1,label:s,copiedLabel:i="Copied",showIcon:a=!0,variant:c="ghost",size:u}){const[d,f]=v.useState(!1),h=!!s,m=v.useRef(void 0);return v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),l.jsxs(p.Button,{className:p.cn(!h&&"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:c,size:u??(h?"xs":"icon"),"aria-label":n,disabled:o,onClick:async()=>{try{let g=!1;if(r)g=await r();else if(typeof e=="string"){if(typeof navigator>"u"||!navigator.clipboard)return;await navigator.clipboard.writeText(e),g=!0}if(!g)return;f(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(!1),m.current=void 0},1e3)}catch(g){console.error("Failed to copy text",g)}},children:[a?d?l.jsx(pQe,{className:"size-3.5"}):l.jsx(Jh,{className:"size-3.5"}):null,h?l.jsx("span",{children:d?i:s}):null]})}function Jce(){const{authToken:e,tokenProps:t}=It(),{data:n,isLoading:r,isFetching:o,isError:s}=Un({queryKey:["plugins",e==null?void 0:e.accessToken],queryFn:()=>p.getPlugins(t.apiServiceUrl,e==null?void 0:e.accessToken)});return{data:n,isLoading:r,isFetching:o,isError:s}}function R$(){const{data:e,isLoading:t,isError:n}=Jce(),r=ib({queries:((e==null?void 0:e.plugins)||[]).map(c=>({queryKey:["manifest",c.value],queryFn:()=>gle(c.value),enabled:!!c.value,staleTime:5*60*1e3,gcTime:10*60*1e3,retry:2,retryDelay:u=>Math.min(1e3*2**u,3e4)}))}),o=[],s=[];let i=t,a=n;return r.forEach((c,u)=>{var d;if(c.isLoading&&(i=!0),c.isError&&(a=!0),c.data&&((d=e==null?void 0:e.plugins)!=null&&d[u])){const f=e.plugins[u],h=c.data.visuals.map(m=>({name:m.name,pluginName:f.label,componentType:m.componentType,pluginType:f.type,icon:m.icon,chartType:m.chartType,visualType:m.visualType||(m.dataInputs&&m.dataInputs.length>1?"multiple":"single"),minInputs:m.minInputs,maxInputs:m.maxInputs,slots:m.slots,url:f.value}));if(o.push(...h),c.data.filters){const m=c.data.filters.map(g=>({name:g.name,component:g.component,pluginName:f.label,pluginType:f.type,icon:g.icon,filterType:g.filterType,supportedDataTypes:g.supportedDataTypes,url:f.value}));s.push(...m)}}}),{data:o,filters:s,isLoading:i,isError:a}}function xQe(e){const[t,n]=v.useState(null);return t}function yQe({pluginFilter:e}){const t=xQe(e.icon||""),n=e.name.charAt(0).toUpperCase();return l.jsxs("div",{className:"flex items-center gap-2",children:[t?l.jsx(t,{className:"h-4 w-4"}):l.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted text-xs font-medium",children:n}),l.jsx("span",{children:e.name}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",e.pluginName,")"]})]})}function vQe({filter:e,onSelect:t,onClear:n}){const{filters:r,isLoading:o}=R$(),s=p.getDataType(e.dataType),i=r==null?void 0:r.filter(u=>!u.supportedDataTypes||u.supportedDataTypes.length===0?!0:u.supportedDataTypes.some(d=>s.toLowerCase()===d.toLowerCase())),a=e.customFilterPreferences,c=a?`${a.url}::${a.componentName}`:"";return o?l.jsx("div",{className:"flex h-7 items-center rounded-control border border-input bg-background px-2 text-[12px] text-muted-foreground",children:"Checking available custom filters…"}):!i||i.length===0?l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No custom filters available."}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(p.Select,{value:c,onValueChange:u=>{if(!u)return;const[d,f]=u.split("::"),h=i.find(m=>m.url===d&&m.component===f);h&&t({url:d,componentName:h.component,pluginFilterType:h.filterType,icon:h.icon})},children:[l.jsx(p.SelectTrigger,{className:"h-9 flex-1",children:l.jsx(p.SelectValue,{placeholder:"Use default UI"})}),l.jsx(p.SelectContent,{children:i.map(u=>l.jsx(p.SelectItem,{value:`${u.url}::${u.component}`,children:l.jsx(yQe,{pluginFilter:u})},`${u.url}::${u.component}`))})]}),a&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:n,title:"Clear custom filter selection",children:l.jsx(je.X,{className:"h-4 w-4"})})]})}function eue(e){if((e==null?void 0:e.mode)!=="period")return;const t=e.spec;if(t.kind==="previous_year"){const r=t.offsetYears??1;return r===1?"vs previous year":`vs ${r} years ago`}const n=t.offsetPeriods??1;return n===1?"vs previous period":`vs ${n} periods ago`}function wQe(e){for(const[n,r]of Object.entries(p.presetMetadata))if(JSON.stringify(r)===JSON.stringify(e))return n;const t={minute:"minute",hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter",year:"year"};switch(e.mode){case"last":{const n=e.complete?" (complete)":"",r=e.n>1?"s":"";return`Last ${e.n} ${t[e.unit]}${r}${n}`}case"this":{const n=e.toDate?" to date":"";return`This ${t[e.unit]}${n}`}case"previous":return`Previous ${t[e.unit]}`;case"between":return`Between ${e.from} and ${e.to} ${t[e.unit]}s`}}const CQe=["January","February","March","April","May","June","July","August","September","October","November","December"];function SQe(e){return p.isFixedMonthDefaultDateFilter(e)?`${CQe[e.month]} ${e.year}`:wQe(e)}function vM(e){return e&&p.isRelativeDateFilter(e)?"relative":"fixed"}function LI(e){return"kind"in e&&e.kind==="global-date"}function $S(e){return LI(e)?p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column}function NQe({selection:e,controlLabel:t,onChange:n}){return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),l.jsx(Gce,{selection:e,controlLabel:t,onChange:n})]})}function jQe({filter:e,onUpdate:t,variableName:n,reservedVariableNames:r=[],onUpdateInputMetadata:o,showFilterId:s=!0,filterOptionsData:i,timezone:a,variant:c="dashboard",defaultComparisonSelection:u,onDefaultComparisonChange:d,onDefaultDatePickerOpenChange:f}){var Y;const h=LI(e),[m,g]=v.useState(e.title===$S(e)?"":e.title||""),[b,x]=v.useState(((Y=e.defaultValues)==null?void 0:Y.map(O=>String(O)))||[]),[y,w]=v.useState(e.defaultDateFilter),[C,N]=v.useState(vM(e.defaultDateFilter)),[S,j]=v.useState(e.targetColumns||[]),[_,k]=v.useState(n||""),[T,I]=v.useState(null),E=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),D=a||Intl.DateTimeFormat().resolvedOptions().timeZone,R=c==="inline"||c==="document"?"z-[80]":void 0,A=u&&d?l.jsx(NQe,{selection:u,controlLabel:e.title||"Date",onChange:d}):void 0,F=eue(u),z=v.useMemo(()=>{if(!y)return;const O=p.resolveDefaultDateFilterForDefaults(y,D);if(!O)return;const[q,U]=O;return{from:q,to:U}},[y,D]),L=v.useMemo(()=>{if(y&&p.isFixedMonthDefaultDateFilter(y))return{year:y.year,month:y.month}},[y]),$=v.useMemo(()=>{if(!(!y||!p.isRelativeDateFilter(y)))return y},[y]);v.useEffect(()=>{var q;g(e.title===$S(e)?"":e.title||""),x(((q=e.defaultValues)==null?void 0:q.map(U=>String(U)))||[]);const O=e.defaultDateFilter;w(O),N(vM(O)),j(e.targetColumns||[])},[e]),v.useEffect(()=>{k(n||""),I(null)},[n]);function H(){const O=m.trim();t({title:O||$S(e)})}function M(){if(!o||n===void 0)return;const O=_.trim();if(!O){k(n),I(null);return}const q=Lv(O);if(q!==n&&r.includes(q)){I(`"${q}" is already used by another input.`);return}I(null),k(q),q!==n&&o({variableName:q})}function B(O){x(O);const q=O.length>0?O.map(U=>{const V=Number(U);return!isNaN(V)&&p.isNumberDataType(e.dataType)?V:U}):void 0;t({defaultValues:q})}function W(O){w(O),O&&N(vM(O)),t({defaultDateFilter:O})}function P(O){j(O),t({targetColumns:O.length>0?O:void 0})}function G(){P([...S,{column:"",label:""}])}function Z(O){const q=S.filter((U,V)=>V!==O);P(q)}function X(O,q,U){const V=S.map((K,Q)=>Q===O?{...K,[q]:U}:K);P(V)}return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-[12px]",children:"Leave empty to use the column name. Provide a custom label to override it."}),s&&l.jsxs("div",{className:"space-y-1 border-t pt-2",children:[l.jsx("p",{className:"text-[12px] font-medium",children:"Filter ID"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),l.jsx(Pd,{text:e.id})]})]})]})})]})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[l.jsx(Tn,{id:"hideLabel",checked:e.showLabel===!1,onCheckedChange:O=>{t({showLabel:!O})}}),l.jsx(p.Label,{htmlFor:"hideLabel",className:"cursor-pointer text-[11px] text-muted-foreground",children:"Hide label"})]})]}),l.jsx(p.Input,{size:"xs",value:m,onChange:O=>g(O.target.value),onBlur:H,placeholder:$S(e)})]}),n!==void 0&&o?l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),l.jsx(p.Input,{size:"xs",value:_,onChange:O=>k(O.target.value),onBlur:M,"aria-invalid":!!T,className:"font-mono",placeholder:"input_name"}),T?l.jsx("p",{className:"text-[10px] leading-3 text-destructive",children:T}):null]}):null,E?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Date Filter"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial date selection on load and previews it immediately while editing. Relative defaults recalculate on each load and scheduled execution, while fixed month defaults stay unchanged."})})]})})]}),e.dateSelectionMode==="months"?l.jsxs(p.Tabs,{value:C,onValueChange:O=>N(O),className:"space-y-2",children:[l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"fixed",className:"h-7 text-[12px] leading-none",children:"Fixed"}),l.jsx(p.TabsTrigger,{value:"relative",className:"h-7 text-[12px] leading-none",children:"Relative"})]}),l.jsx(p.TabsContent,{value:"fixed",className:"mt-0",children:l.jsx(Wce,{value:L,placeholder:"Select default month...",className:"w-full",onClear:()=>W(void 0),onChange:(O,q)=>W({mode:"fixed",unit:"month",year:O,month:q})})}),l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs(p.Select,{value:$?JSON.stringify($):"__none__",onValueChange:O=>{if(O==="__none__"){W(void 0);return}try{const q=JSON.parse(O);W(q)}catch(q){console.error("Failed to parse relative date filter",q)}},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select default month range..."})}),l.jsxs(p.SelectContent,{className:R,children:[l.jsx(p.SelectItem,{value:"__none__",children:"None"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"this",unit:"month"}),children:"This month"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"previous",unit:"month"}),children:"Last month"})]})]})})]}):l.jsx(E$,{value:z,relativeValue:p.isRelativeDateFilter(y)?y:void 0,onRelativeSelect:(O,q)=>{W(q)},showRelativeTab:!0,hideCalendar:!0,timezone:D,placeholder:"Select default date range…",buttonClassName:"h-7 text-[12px]",buttonLabelSuffix:F,contentClassName:R,overlayContentClassName:R,supplementalFooter:A,onOpenChange:f}),y&&l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[SQe(y),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>W(void 0),"aria-label":"Clear default date",children:l.jsx(je.X,{className:"h-3 w-3"})})]})}),e.dateSelectionMode==="months"?A:null]}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Values"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial selection on load and previews it immediately while editing. Works like a filter selection."})})]})})]}),i!=null&&i.records&&i.records.length>0?l.jsxs(p.Select,{value:"",onValueChange:O=>{O&&!b.includes(O)&&B([...b,O])},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select values to add..."})}),l.jsxs(p.SelectContent,{className:R,children:[i.records.filter(O=>{var V;const q=(V=e.column.split(".").pop())==null?void 0:V.replace(/"/g,""),U=q?O[q]:O.value;return U!=null&&!b.includes(String(U))}).map(O=>{var V;const q=(V=e.column.split(".").pop())==null?void 0:V.replace(/"/g,""),U=q?O[q]:O.value;return l.jsx(p.SelectItem,{value:String(U),children:String(U)},String(U))}),i.records.every(O=>{var V;const q=(V=e.column.split(".").pop())==null?void 0:V.replace(/"/g,""),U=q?O[q]:O.value;return U==null||b.includes(String(U))})&&l.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All values selected"})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading filter options…"}),b.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Selected · ",b.length]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:b.map(O=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[String(O),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>{B(b.filter(q=>q!==O))},"aria-label":`Remove ${O}`,children:l.jsx(je.X,{className:"h-3 w-3"})})]},O))})]})]}),E&&!h&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Target Columns"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Add multiple date columns to let users choose which field to filter at runtime. Leave empty to use only the primary column above."})})]})})]}),S.length>0&&l.jsx("div",{className:"space-y-2",children:S.map((O,q)=>l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Input,{size:"xs",placeholder:"Column name",value:O.column,onChange:U=>X(q,"column",U.target.value),className:"flex-1 font-mono"}),l.jsx(p.Input,{size:"xs",placeholder:"Label",value:O.label,onChange:U=>X(q,"label",U.target.value),className:"flex-1"}),l.jsx(p.Button,{variant:"ghost",size:"xs",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>Z(q),"aria-label":"Remove target column",children:l.jsx(je.X,{className:"h-3.5 w-3.5"})})]},q))}),l.jsxs(p.Button,{variant:"outline",size:"xs",onClick:G,children:[l.jsx(Tr,{className:"h-3.5 w-3.5"}),"Add column"]})]})]})}function kQe({filter:e,onUpdate:t,variant:n="dashboard"}){const r=LI(e),{filters:o,isLoading:s}=R$(),i=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),a=n==="inline"||n==="document"?"z-[80]":void 0,c=v.useMemo(()=>{const b=p.getDataType(e.dataType);return(o==null?void 0:o.filter(x=>!x.supportedDataTypes||x.supportedDataTypes.length===0?!0:x.supportedDataTypes.some(y=>b.toLowerCase()===y.toLowerCase())))??[]},[e.dataType,o]),u=!r&&(s||!!e.customFilterPreferences||c.length>0);function d(b){t({type:b})}function f(b){t({dateSelectionMode:b})}function h(b){t({uiType:b})}function m(b){t({customFilterPreferences:b})}function g(){t({customFilterPreferences:void 0})}return l.jsxs("div",{className:"space-y-4",children:[i?l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date Picker Type"}),l.jsxs(p.Select,{value:e.dateSelectionMode||"range",onValueChange:b=>f(b),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"range",children:"Date Range Picker"}),l.jsx(p.SelectItem,{value:"months",children:"Month Picker"})]})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Selection Type"}),l.jsxs(p.Select,{value:e.type||"multiple",onValueChange:d,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"multiple",children:"Multiple"}),l.jsx(p.SelectItem,{value:"single",children:"Single"})]})]})]}),!i&&e.type==="single"&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"UI Component"}),l.jsxs(p.Select,{value:e.uiType||"dropdown",onValueChange:h,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"dropdown",children:"Dropdown"}),l.jsx(p.SelectItem,{value:"radio",children:"Radio"}),l.jsx(p.SelectItem,{value:"tabs",children:"Tabs"})]})]})]}),u&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom Filter Component"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Select a custom filter component from an installed plugin to replace the default filter UI with a custom implementation."})})]})})]}),l.jsx(vQe,{filter:e,onSelect:m,onClear:g})]}),n==="dashboard"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:`Choose how this filter is displayed. "Inherit" uses the dashboard's default setting. Override with "Canvas Card" or "Toolbar" to always display this filter in a specific mode.`})})]})})]}),l.jsxs(p.Select,{value:e.displayMode||"inherit",onValueChange:b=>t({displayMode:b}),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",children:"Inherit (use dashboard default)"}),l.jsx(p.SelectItem,{value:"canvas",children:"Canvas Card"}),l.jsx(p.SelectItem,{value:"toolbar",children:"Toolbar"})]})]})]}),n==="inline"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Width (px)"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Set the width of this inline filter in pixels. Default is 250px."})})]})})]}),l.jsx(p.Input,{size:"xs",type:"number",min:100,max:500,value:e.width??250,onChange:b=>{const x=parseInt(b.target.value,10);isNaN(x)||t({width:x})},className:"w-24"})]})]})}function _Qe({filter:e,onUpdate:t}){const[n,r]=v.useState(e.column);v.useEffect(()=>{r(e.column)},[e.column]);function o(){const s=n.trim();if(s&&s!==e.column){const i=!e.title||e.title===e.column;t(i?{column:s,title:s}:{column:s})}}return l.jsx(p.Input,{size:"xs",value:n,onChange:s=>r(s.target.value),onBlur:o,placeholder:"Enter column name",className:"font-mono"})}function IQe({filter:e,onUpdate:t,variant:n="dashboard"}){return LI(e)?l.jsx("div",{className:"rounded-control border border-border/60 bg-muted/30 p-3 text-[12px] text-muted-foreground",children:"Global date filters are not bound to a specific column. Configure the picker type, layout, and scope in the other tabs."}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter column name"}),l.jsx(_Qe,{filter:e,onUpdate:t})]}),l.jsx(TQe,{filter:e,onUpdate:t,variant:n})]})}function TQe({filter:e,onUpdate:t,variant:n="dashboard"}){const[r,o]=v.useState(e.sql),[s,i]=v.useState(e.searchMode||"auto"),a=n==="inline"||n==="document"?"z-[80]":void 0;v.useEffect(()=>{o(e.sql),i(e.searchMode||"auto")},[e]);function c(){t({sql:r})}function u(d){i(d),t({searchMode:d})}return l.jsxs("div",{className:"space-y-4",children:[p.isNumberDataType(e.dataType)&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Search Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2 text-xs",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Text Search:"}),' Treats numbers as text (e.g., ZIP codes, IDs). Search for "90210".']}),l.jsxs("p",{children:[l.jsx("strong",{children:"Numeric Operators:"})," Supports comparison operators (e.g., >100, <=50, =100) for quantities, prices."]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Auto-detect:"})," Tries numeric first, falls back to text search."]})]})})]})})]}),l.jsxs(p.Select,{value:s,onValueChange:u,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"text",children:"Text Search"}),l.jsx(p.SelectItem,{value:"numeric",children:"Numeric Operators"}),l.jsx(p.SelectItem,{value:"auto",children:"Auto-detect"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter values custom SQL"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"This SQL will be used to fetch the filter values"})})]})})]}),l.jsx("div",{className:"h-36 w-full overflow-hidden rounded-control border border-input",onBlur:c,onKeyDown:d=>d.stopPropagation(),children:l.jsx(p.CodeEditor,{value:r,onValueChange:o,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,dense:!0,ariaLabel:"Filter values custom SQL",placeholder:`SELECT ${e.column.split(".").pop()||"value"} FROM ... {{ filters | where }}`})})]})]})}const EQe=[{id:"basic",label:"Basic"},{id:"scope",label:"Scope"},{id:"advanced",label:"Advanced"}];function A$({filter:e,variant:t="dashboard",onAccept:n,inputVariableName:r,reservedInputVariableNames:o,open:s,onOpenChange:i,trigger:a,isEditing:c=!1,filterQueryContext:u,onDelete:d}){const f=dc("interactive");function h(K){if(!K)return"Unknown";const Q=p.getDataType(K),se=Q==="date"?"Datetime":Q==="string"?"Text":Q==="number"?"Number":Q==="boolean"?"Boolean":Q==="json"?"JSON":"Geo";return/nullable/i.test(K)?`${se} (nullable)`:se}const[m,g]=v.useState(!1),b=s??m,x=i??g,[y,w]=v.useState("basic"),C="kind"in e&&e.kind==="global-date",[N,S]=v.useState({}),[j,_]=v.useState({}),[k,T]=v.useState({mode:"off"}),[I,E]=v.useState(!1),[D,R]=v.useState(!1),A=p.useDashboardStore(K=>K.dashboard),F=p.useDashboardStore(K=>K.selectedSheetId),{updateFilter:z,addOrUpdateFilterValue:L,removeFilterValues:$,setDefaultDashboardInputComparisonSelection:H}=p.useDashboardActions(),M=v.useMemo(()=>{if(t!=="dashboard")return;const K=Lw(A,e.id);if(!(!K||!p.isComparisonCapableDashboardDateInput(K)||!p.canAddressDashboardInputRuntimeSlot(K,{sheetId:F})))return K},[A,e.id,F,t]),B=v.useMemo(()=>EQe.filter(K=>!(t!=="dashboard"&&K.id==="scope"||C&&K.id==="advanced")),[C,t]),{tokenProps:W}=It(),P=dl()??void 0,{data:G}=c$(e,{filterQueryContext:u}),Z={...e,...N};function X(){let K={...N};j.variableName&&!n&&(K={...K,variableName:j.variableName});const Q=Object.prototype.hasOwnProperty.call(K,"defaultValues")||Object.prototype.hasOwnProperty.call(K,"defaultDateFilter");if(t==="inline"&&"width"in K){const se=K.width;K={...K,width:Math.min(500,Math.max(100,se))}}if(n)n(K,j);else{const se={...e,...K};if(z(se),Q){const oe=p.buildFilterValueFromDefaults(se,P);oe?L(oe):$(e.id)}}I&&M&&H(M,{sheetId:F},k.mode==="off"?void 0:k),S({}),_({}),E(!1),x(!1)}function Y(K){S(Q=>({...Q,...K}))}function O(K){_(Q=>({...Q,...K}))}v.useEffect(()=>{var K;b&&(R(!1),S({}),_({}),T(M?((K=p.getDashboardInputRuntimeSlot(A.defaultInputValues,M,{sheetId:F}))==null?void 0:K.comparisonSelection)||{mode:"off"}:{mode:"off"}),E(!1),w("basic"))},[A.defaultInputValues,M,b,F]);const q=C?e.title||p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column.split(".").pop()||e.column,U=C?q:e.column,V=C?"Global date":h(e.dataType);return l.jsxs(p.Popover,{open:b,onOpenChange:x,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:a??l.jsx("button",{type:"button",className:p.cn("rounded p-0.5 hover:bg-muted focus:visible focus:outline-none focus:ring-1 focus:ring-ring",c?"visible":"invisible group-hover:visible"),"aria-label":"Filter settings",children:l.jsx(Fm,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})}),l.jsxs(p.PopoverContent,{collisionPadding:12,onMouseDown:K=>{D||K.stopPropagation()},onDoubleClick:K=>K.stopPropagation(),style:f.controlStyle,className:p.cn("flex h-[440px] max-h-[85vh] w-[480px] flex-col overflow-hidden rounded-control border border-border/60 p-0 shadow-sm",t==="inline"||t==="document"?"z-[70]":"z-50"),children:[l.jsxs("div",{className:"flex min-h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[l.jsx($d,{"aria-hidden":!0,className:"mt-1 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",title:q,children:q}),l.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",title:e.dataType,children:V})]}),l.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] leading-3 text-muted-foreground/70",title:U,children:U})]})]}),l.jsx("button",{type:"button",onClick:()=>x(!1),"aria-label":"Close",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx("svg",{"aria-hidden":!0,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.75,className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M5 5l10 10M15 5L5 15",strokeLinecap:"round"})})})]}),l.jsx("nav",{role:"tablist","aria-label":"Filter settings sections",className:"flex h-9 shrink-0 items-stretch gap-4 border-b border-border/60 px-4",children:B.map(K=>l.jsxs("button",{role:"tab","aria-selected":y===K.id,onClick:()=>w(K.id),className:p.cn("relative -mb-px inline-flex items-center text-[13px] transition-colors focus-visible:outline-none",y===K.id?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[K.label,y===K.id&&l.jsx("span",{"aria-hidden":!0,className:"absolute inset-x-0 -bottom-px h-[2px] bg-foreground"})]},K.id))}),l.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:[y==="basic"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx(jQe,{filter:Z,onUpdate:Y,variableName:j.variableName??r,reservedVariableNames:o,onUpdateInputMetadata:r===void 0?void 0:O,showFilterId:!0,filterOptionsData:G,timezone:P,variant:t,defaultComparisonSelection:M?k:void 0,onDefaultComparisonChange:M?K=>{T(K),E(!0)}:void 0,onDefaultDatePickerOpenChange:R}),l.jsx(kQe,{filter:Z,onUpdate:Y,variant:t})]}),y==="advanced"&&l.jsx(IQe,{filter:Z,onUpdate:Y,variant:t}),y==="scope"&&t==="dashboard"&&l.jsx(cQe,{filter:Z,onUpdate:Y})]}),l.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 bg-background px-4 py-2.5",children:[d?l.jsxs(p.Button,{variant:"ghost",size:"xs",onClick:()=>{d(),x(!1)},className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:[l.jsx(je.X,{className:"h-3 w-3"}),"Delete"]}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:()=>x(!1),children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:X,children:"Accept"})]})]})]})]})}function DQe(e,t){const n=e?ab({dashboard:e}).allInputs.find(r=>r.id===Oi.getDashboardFilterCompatInputId(t.id)):void 0;return(n==null?void 0:n.variableName)||t.variableName||HY(t.title||t.column||t.id)}function tue(e,t){if(!e)return[];const n=MQe(t),r=new Set;for(const o of ab({dashboard:e}).allInputs)o.id!==n&&r.add(o.variableName);return Array.from(r)}function MQe(e){if(e)return e.source==="dashboardFilter"?Oi.getDashboardFilterCompatInputId(e.filterId):Oi.getDashboardControlCompatInputId(e.controlId)}function RQe(e,t={}){const{enabled:n=!0,eventType:r="mousedown"}=t,o=v.useRef(null);return v.useEffect(()=>{const s=i=>{const a=i.target;o.current&&o.current.contains(a)||a instanceof Element&&(a.closest("[data-radix-popper-content-wrapper]")||a.closest("[data-radix-select-content]")||a.closest("[data-radix-popover-content]")||a.closest("[data-radix-dropdown-menu-content]")||a.closest("[data-radix-tooltip-content]")||a.closest('[role="listbox"]')||a.closest('[role="option"]')||a.closest('[role="combobox"]'))||a instanceof Element&&a.hasAttribute("data-radix-")||e()};return n&&document.addEventListener(r,s),()=>{document.removeEventListener(r,s)}},[e,n,r]),o}const AQe=24;function Ox(e,t=AQe){return e.length<=t?e:`${e.slice(0,t-1)}…`}function PQe(e,t,n){if(!t)return null;if(t.operation==="is null")return"is empty";if(t.operation==="is not null")return"is not empty";const r=t.values;if(!r||r.length===0)return null;const o=p.getDataType(e.dataType),s=a=>{try{return Kt.formatInTimeZone(new Date(a),n,"MMM d")}catch{return String(a)}},i={"=":"=","!=":"≠","<":"<","<=":"≤",">":">",">=":"≥"};if(o==="date"){const a=t.relativeMeta,c=p.getRelativeDateLabel(a);if(c)return c;const u=r[0],d=r[1];if(!u)return null;if(d){const m=`${s(u)} – ${s(d)}`;return t.operation==="not between"?`not ${m}`:m}const f=i[t.operation],h=s(u);return f?`${f} ${h}`:h}if(o==="number"&&(t.operation==="between"||t.operation==="not between")&&r.length>=2){const a=`${String(r[0])} – ${String(r[1])}`;return t.operation==="not between"?`not ${a}`:a}if(o==="number"&&r.length===1&&t.operation!=="in"&&t.operation!=="not in"){const a=i[t.operation];if(a)return Ox(`${a} ${String(r[0])}`)}return t.operation==="not in"?r.length===1?Ox(`not ${String(r[0])}`):`${r.length} excluded`:t.operation==="not like"?Ox(`not ${String(r[0])}`):t.operation==="like"?Ox(`contains ${String(r[0])}`):r.length===1?Ox(String(r[0])):`${r.length} selected`}function FQe(e){return p.getDataType(e.dataType)==="date"||e.kind==="global-date"?mN:(e.searchMode==="numeric",null)}function OQe(e){return p.getDataType(e.dataType)==="date"||e.kind==="global-date"?360:e.uiType==="tabs"?320:e.uiType==="radio"?260:e.searchMode==="numeric"?240:300}function rU(e){var t;return!((t=e.customFilterPreferences)!=null&&t.url||e.kind==="global-date"||p.isDateDataType(e.dataType)||e.searchMode==="numeric"||e.type==="single"&&(e.uiType==="radio"||e.uiType==="tabs"))}function LQe(e,t){var o;const n=(t==null?void 0:t.name)||e.column;if(n===e.column)return e.title||e.column;const r=(o=e.targetColumns)==null?void 0:o.find(s=>s.column===n);return(r==null?void 0:r.label)||n}function P$({filter:e,isEditing:t=!1,dragListeners:n,storageOptions:r,settingsVariant:o="dashboard",filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){var O,q,U;const d=M$(e,r),f=dc("interactive"),h=p.useDashboardStore(V=>V.dashboard),m=p.useDashboardStore(V=>V.semanticExecutionPayload),{removeFilterValues:g,removeFilter:b,clearDashboardInputSlot:x}=p.useDashboardActions(),y=p.useDashboardStore(V=>V.actions.removeCardInlineFilterValue),w=(d==null?void 0:d.storageTarget)==="card",C=(d==null?void 0:d.storageTarget)==="dashboardInput",N=d==null?void 0:d.cardId,S=p.useDashboardStore(V=>V.dashboardInputValues),j=p.useDashboardStore(V=>V.selectedSheetId),_=dl(),k=v.useMemo(()=>{if(!C||!(d!=null&&d.dashboardInput))return;const V={sheetId:d.sheetId},K=p.hydrateAuthoredDashboardInputSlot({dashboard:h,input:d.dashboardInput,runtimeValues:S,target:V,timezone:_});return(K==null?void 0:K.status)==="set"&&K.value.kind==="filter"?K.value.filterValue:void 0},[h,S,C,d==null?void 0:d.dashboardInput,d==null?void 0:d.sheetId,_]),T=p.useDashboardStore(V=>{var K,Q,se;return w?N?(Q=(K=V.inlineFilterValuesMap)==null?void 0:K[N])==null?void 0:Q.find(oe=>oe.filterId===e.id):void 0:(se=V.filterValues)==null?void 0:se.find(oe=>oe.filterId===e.id)}),E=w&&(d==null?void 0:d.inlineFilterValues)!==void 0?(O=d.inlineFilterValues)==null?void 0:O.find(V=>V.filterId===e.id):C?k:T,D=v.useMemo(()=>p.isGlobalDateFilter(e)?I5({globalDateFilter:e,globalDateFilterValue:E,timezone:_,allowMinutePrecision:p.getGlobalDateFilterCoverage(h,m).allEligibleTargetsAreDateTime}):E,[h,e,E,m,_]),[R,A]=v.useState(!1),F=RQe(()=>A(!1),{enabled:R,eventType:"pointerdown"}),z=i??(o==="dashboard"?DQe(h,e):void 0),L=a??(o==="dashboard"?tue(h,{source:"dashboardFilter",filterId:e.id}):void 0),$=PQe(e,D,_),H=p.isDateDataType(e.dataType)||e.kind==="global-date",M=v.useMemo(()=>{var se;if(!H)return null;const K=(((se=d==null?void 0:d.dashboardInput)==null?void 0:se.kind)==="filter"?d.dashboardInput:void 0)||Lw(h,e.id);if(!K||!p.isComparisonCapableDashboardDateInput(K))return null;const Q=p.hydrateAuthoredDashboardInputSlot({dashboard:h,input:K,runtimeValues:S,target:{sheetId:(d==null?void 0:d.sheetId)||j},timezone:_});return eue(Q==null?void 0:Q.comparisonSelection)??null},[h,S,e,H,j,d==null?void 0:d.dashboardInput,d==null?void 0:d.sheetId,_]),B=$!==null,W=LQe(e,D),P=FQe(e),G=!!((q=e.customFilterPreferences)!=null&&q.url&&((U=e.customFilterPreferences)!=null&&U.componentName)),Z=H&&!G,X=V=>{if(V.preventDefault(),V.stopPropagation(),C&&(d!=null&&d.dashboardInput)){x(d.dashboardInput,{sheetId:d.sheetId});return}if(w&&e.id){if(d!=null&&d.removeInlineFilterValue){d.removeInlineFilterValue(e.id);return}N&&y(N,e.id);return}g(e.id)},Y=()=>{if(u){u(e.id);return}g(e.id),b(e.id)};return l.jsxs("div",{className:"group/chip flex shrink-0 items-center gap-2",children:[t&&n&&l.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Drag to reorder",className:"inline-flex h-7 cursor-grab items-center justify-center px-0.5 text-muted-foreground/50 transition-colors hover:text-muted-foreground active:cursor-grabbing",...n,children:l.jsx(Nu,{className:"size-3"})}),l.jsxs(p.Popover,{open:R,onOpenChange:A,children:[l.jsxs("div",{className:p.cn("inline-flex h-7 items-stretch overflow-hidden rounded-control border border-border text-[12px] transition-colors",B?f.hasAppearance?"bg-accent/80 hover:bg-accent":"bg-muted/80 hover:bg-muted":f.hasAppearance?"bg-muted/40 hover:bg-accent/50":"bg-muted/40 hover:bg-muted/70"),style:f.chipStyle,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-2 focus:outline-none",children:[P&&l.jsx(P,{className:p.cn("h-3 w-3 shrink-0",B?"text-muted-foreground":"text-muted-foreground/70")}),l.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:W}),B&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"max-w-[160px] truncate whitespace-nowrap font-medium text-foreground",children:$})]}),M&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"whitespace-nowrap text-[11px] font-medium text-muted-foreground",children:M})]}),l.jsx(je.ChevronDown,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"})]})}),B&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",className:"w-px bg-border"}),l.jsx("button",{type:"button",onClick:X,"aria-label":`Clear ${e.title||e.column}`,className:"inline-flex w-6 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(je.X,{className:"h-3 w-3"})})]})]}),l.jsx(p.PopoverContent,{ref:F,align:"start",sideOffset:4,style:{width:OQe(e),...f.contentStyle},className:p.cn(Z?"p-0":rU(e)?"p-1":"p-3"),onMouseDown:V=>V.stopPropagation(),onClick:V=>V.stopPropagation(),children:(()=>{const V=()=>A(!1);return Z?p.isGlobalDateFilter(e)?l.jsx(Zce,{filter:e,storageOptions:d,inline:!0,onApplied:V}):l.jsx(Xce,{filter:e,storageOptions:d,inline:!0,onApplied:V}):rU(e)?l.jsx(lQe,{filter:e,storageOptions:d,onApplied:V}):l.jsx(FI,{filter:e,storageOptions:d})})()})]}),t&&l.jsx("div",{className:p.cn("flex shrink-0 items-center transition-opacity",R?"opacity-100":"opacity-0 group-hover/chip:opacity-100 focus-within:opacity-100"),children:l.jsx(A$,{filter:e,variant:o,isEditing:t,filterQueryContext:s,inputVariableName:z,reservedInputVariableNames:L,onAccept:c?(V,K)=>c({...e,...V},K):void 0,onDelete:Y})})]})}function $Qe(e){return{id:e.id,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel}}function nue({inlineFilter:e,sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s}){const i=$Qe(e),a={storageTarget:"card",sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s};return l.jsx(P$,{filter:i,isEditing:!1,storageOptions:a})}function F$({card:e,sheetId:t,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o}){return!e.inlineFilters||e.inlineFilters.length===0?[]:e.inlineFilters.map(s=>l.jsx(nue,{inlineFilter:s,sheetId:t,cardId:e.id,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o},s.id))}function zQe(e){switch(e.type){case"kpi":return BQe(e);case"detailTable":case"table":return HQe(e);case"aggregateTable":case"pivotTable":return qQe(e);default:return VQe(e)}}function rue(e){return UQe(zQe(e))}function BQe(e){var i,a,c,u,d,f;const t=(i=e.preferences)==null?void 0:i.kpiVisualOptions,n=(a=e.preferences)==null?void 0:a.formatNumber,r=t==null?void 0:t.formatOptions,o=p.toTFormatOptions(p.fromSemanticFormat((d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.format));return{kpi:{primary:r?{...r,currency:r.currency||(r.type==="currency"?"USD":void 0)}:o?{...o,currency:o.currency||(o.type==="currency"?"USD":void 0)}:WQe(n),colorRanges:n==null?void 0:n.colorRanges},legacy:{formatNumber:n,numberAxisFormat:(f=e.preferences)==null?void 0:f.numberAxisFormat}}}function VQe(e){var n,r,o,s;const t=e.preferences;return{dataLabels:(n=t==null?void 0:t.dataLabelsConfig)==null?void 0:n.formatOptions,yAxis:(r=t==null?void 0:t.yAxisConfig)==null?void 0:r.formatOptions,xAxis:(o=t==null?void 0:t.xAxisConfig)==null?void 0:o.formatOptions,secondaryYAxis:(s=t==null?void 0:t.secondaryYAxisConfig)==null?void 0:s.formatOptions,legacy:{formatNumber:t==null?void 0:t.formatNumber,numberAxisFormat:t==null?void 0:t.numberAxisFormat}}}function HQe(e){var n,r;return{tableColumnSettingsMap:(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.columnSettingsMap}}function qQe(e){var n;return{tableColumnSettings:(n=e.preferences)==null?void 0:n.columnSettings}}function UQe(e){const t=[],n={};return e.tableColumnSettingsMap&&Object.entries(e.tableColumnSettingsMap).forEach(([r,o])=>{const s=o==null?void 0:o.numberFormat;t.push({id:r,numberFormat:s}),n&&(n[r]={numberFormat:s})}),e.tableColumnSettings&&e.tableColumnSettings.forEach((r,o)=>{r.type==="number"&&t.push({position:r.columnIdx??o,numberFormat:KQe(r)})}),{kpi:e.kpi,axes:{xAxis:e.xAxis,yAxis:e.yAxis,secondaryYAxis:e.secondaryYAxis},dataLabels:e.dataLabels,tables:t.length>0||Object.keys(n).length>0?{columns:t.length?t:void 0,columnMap:Object.keys(n).length>0?n:void 0}:void 0,legacy:e.legacy}}function WQe(e){const t=p.fromLegacyFormatNumber(e);return p.toTFormatOptions(t)}function KQe(e){var n,r,o,s,i,a;if(e.type!=="number")return;const t=e.options;if(!(!t||typeof t!="object")&&"options"in t){const c=t,u=((n=c.options)==null?void 0:n.style)==="currency"||((r=c.options)==null?void 0:r.style)==="percent"?c.options.style:"decimal",d=p.fromColumnNumberFormat({style:u,currency:c.currency||"USD",locale:c.locale||"en-US",minimumFractionDigits:((o=c.options)==null?void 0:o.minimumFractionDigits)??0,maximumFractionDigits:((s=c.options)==null?void 0:s.maximumFractionDigits)??((i=c.options)==null?void 0:i.minimumFractionDigits)??2,useGrouping:typeof((a=c.options)==null?void 0:a.useGrouping)=="boolean"?c.options.useGrouping:!0,percentValueMode:u==="percent"?"whole":void 0});return p.toTFormatOptions(d)}}function Rj(e,t){if(!t)return e;const n=e?{...e}:{},r=n.title!==void 0,o=n.description!==void 0;return!r&&t.title!==void 0&&(n.title=t.title),!o&&t.description!==void 0&&(n.description=t.description),Object.keys(n).length>0?n:e}function GQe({inputCard:e,slotType:t,slotIndex:n,multiInputData:r}){var s,i,a,c,u,d,f,h;if(!e)return{cardType:"unknown",title:`Tab ${n+1}`};const o=rue(e);return{cardType:t??"unknown",title:e.tabTitle||e.title||`Tab ${n+1}`,description:e.description,formatConfig:o,kpiConfig:t==="kpi"?{comparisonMetadata:(i=(s=r==null?void 0:r[e.id])==null?void 0:s.metadata)==null?void 0:i.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((c=(a=e.config)==null?void 0:a.metricColumns)==null?void 0:c[0]),comparisonPresentation:(u=e.preferences)==null?void 0:u.comparisonPresentation,showComparison:((f=(d=e.preferences)==null?void 0:d.comparisonPresentation)==null?void 0:f.showComparison)!==!1},formatNumber:(h=e.preferences)==null?void 0:h.formatNumber}:void 0}}function oue({card:e,dataMetadata:t}){var n,r,o,s,i,a;return{cardType:e.type||"unknown",title:e.tabTitle||e.title||"Tab 1",description:e.description,formatConfig:rue(e),kpiConfig:e.type==="kpi"?{comparisonMetadata:t==null?void 0:t.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((r=(n=e.config)==null?void 0:n.metricColumns)==null?void 0:r[0]),comparisonPresentation:(o=e.preferences)==null?void 0:o.comparisonPresentation,showComparison:((i=(s=e.preferences)==null?void 0:s.comparisonPresentation)==null?void 0:i.showComparison)!==!1},formatNumber:(a=e.preferences)==null?void 0:a.formatNumber}:void 0}}function O$({configCard:e,slotOrderedCards:t,slotTypes:n,multiInputData:r,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u,formatTemporalBucketValue:d}){var w;const f=n.map(C=>C??"unknown"),h=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.records)||[]:[]}),m=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.columns)||[]:[]}),g=Rj((w=e==null?void 0:e.customCardPreferences)==null?void 0:w.settings,e),b=t.map(C=>{var N;return Rj((N=C==null?void 0:C.customCardPreferences)==null?void 0:N.slotSettings,C)}),x={titles:t.map((C,N)=>C?C.tabTitle||C.title:`Tab ${N+1}`),cardTypes:f,cardIds:t.map((C,N)=>C?C.id:`missing-${N}`)},y=t.map((C,N)=>GQe({inputCard:C,slotType:f[N],slotIndex:N,multiInputData:r}));return{data:h,columns:m,formatTemporalBucketValue:d,settings:g,slotSettings:b,tabMetadata:x,cardMetadata:y,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u}}function L$(e){return e.slotOrderedCards.flatMap(t=>{if(!t)return[];const n=e.multiInputData[t.id];return[{card:t,cardConfig:n==null?void 0:n.effectiveCardConfig,columns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,executionSnapshot:e.executionSnapshot,dashboardId:e.dashboardId,attachmentIndex:e.attachmentIndex,valueFormatPreferences:e.valueFormatPreferences}]})}class YQe extends Error{constructor(n){super(`invalid_custom_visual_temporal_column: Column "${n}" is not an activated canonical temporal column from this custom-visual input. Pass the exact descriptor supplied in columns.`);Ne(this,"code","invalid_custom_visual_temporal_column");this.name="CustomVisualTemporalColumnError"}}function $$(e){const t=new Map;return e.forEach(n=>{const r=mb({card:n.card,cardConfig:n.cardConfig,columns:n.columns,columnKeyMap:n.columnKeyMap,executionSnapshot:n.executionSnapshot,dashboardId:n.dashboardId,attachmentIndex:n.attachmentIndex,valueFormatPreferences:n.valueFormatPreferences});(n.columns||[]).forEach(o=>{const s=r.byColumnKey.get(o.key);s&&t.set(o,s)})}),(n,r)=>{const o=t.get(r);if(!o)throw new YQe(r.key);return it.formatGroupedTemporalValue({value:n,presentation:o})}}function ZQe({card:e,frame:t}){var Z,X,Y,O,q,U;const n=e,r=fl(),[o,s]=v.useState({}),{authToken:i,presentationExecutionSnapshot:a}=It(),c=p.getTokenParams(i==null?void 0:i.accessToken),{compiledAppearance:u}=p.useAppearance(),d=v.useMemo(()=>Aw(u),[u]),[f,h]=v.useState(()=>new Set),{getCard:m,manifest:g}=Nf(((Z=n.customCardPreferences)==null?void 0:Z.url)||""),b=(X=n.customCardPreferences)==null?void 0:X.componentName,x=(Y=g==null?void 0:g.visuals)==null?void 0:Y.find(V=>V.name===b),y=it.resolveMultiInputType(n,x)??"single",w=v.useMemo(()=>y==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:e,[e,y]),{data:C,effectiveCardConfig:N}=pu(w),S=p.useInteractionStore(V=>V.interactionStates),j=p.useDashboardStore(V=>{var K;return(K=V.dashboard)==null?void 0:K.id}),_=p.useDashboardStore(V=>V.dashboard.filters),k=p.useDashboardStore(V=>V.filterValues),T=p.useDashboardStore(V=>V.selectedSheetId),I=v.useMemo(()=>lb(a),[a]),E=v.useMemo(()=>$v(),[]),D=p.useDashboardStore(V=>V.inlineFilterValuesMap[e.id]),R=v.useMemo(()=>F$({card:e,sheetId:T||"",inlineFilterValues:D}),[e,T,D]),{cardFilters:A,cardFilterValues:F}=v.useMemo(()=>Qv({card:e,interactionStates:S,currentDashboardId:j,filters:_,filterValues:k,selectedSheetId:T}),[e,S,j,_,k,T]),z=v.useCallback((V,K)=>{const Q=it.normalizeMultiInputPayload(K);s(se=>({...se,[V]:Q}))},[]),L=b?m(b):null,$=v.useMemo(()=>it.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:y==="multiple"}),[t,n,y]),H=v.useMemo(()=>it.buildSlotOrderedCards($),[$]),M=v.useMemo(()=>H.map((V,K)=>it.getEffectiveCardTypeForSlot(V,K,x==null?void 0:x.slots)),[H,x==null?void 0:x.slots]),B=v.useMemo(()=>$$(y==="multiple"?L$({slotOrderedCards:H,multiInputData:o,executionSnapshot:I,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}):[{card:e,cardConfig:N,columns:C==null?void 0:C.columns,columnKeyMap:C==null?void 0:C.columnKeyMap,executionSnapshot:I,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}]),[e,j,C==null?void 0:C.columnKeyMap,C==null?void 0:C.columns,N,o,E,I,H,y,r]),W=v.useCallback((V,K)=>{h(Q=>{const se=new Set(Q);return K?se.add(V):se.delete(V),se})},[]),P=Rj((O=n.customCardPreferences)==null?void 0:O.settings,n);if(!b)return null;const G=((U=(q=e.preferences)==null?void 0:q.displayOptions)==null?void 0:U.allowScroll)??!0;return l.jsx("div",{className:p.cn("semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2",G?"overflow-y-auto":"h-full overflow-hidden"),children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[L&&y==="single"&&l.jsx(L,{params:c,theme:d,chartSettings:P,settings:P,cardMetadata:oue({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:z,data:(C==null?void 0:C.records)||[],columns:(C==null?void 0:C.columns)||[],formatTemporalBucketValue:B,filters:A,filterValues:[...F||[],...D||[]],inlineFilters:R}),L&&y==="multiple"&&l.jsxs(l.Fragment,{children:[$.map((V,K)=>{if(!V)return null;const Q=it.getSlotIndexForCard(V,K),se=it.getEffectiveCardTypeForSlot(V,Q,x==null?void 0:x.slots);return l.jsx(a$,{onLoadingStatus:W,onDataChange:z,card:V,effectiveCardType:se},`${V.id}-${Q}`)}),l.jsxs("div",{className:p.cn("relative flex h-full min-h-0 flex-1 flex-col gap-2"),children:[f.size>0&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center",children:l.jsx(xu,{size:"md",color:"muted","aria-label":"Loading data"})}),l.jsx(L,{onDataChange:z,...O$({configCard:n,slotOrderedCards:H,slotTypes:M,multiInputData:o,params:c,theme:d,chartSettings:P,filters:A,filterValues:[...F||[],...D||[]],inlineFilters:R,formatTemporalBucketValue:B})})]})]})]},e.id)})}const Aj=ZQe;function Pj({children:e,containerClassName:t,className:n,text:r,onSave:o,type:s="input",placeholder:i,enabled:a}){const[c,u]=v.useState(!1),[d,f]=v.useState(r),h=p.useDashboardStore(y=>y.isDashboardEditing);v.useEffect(()=>{f(y=>y!==r?r:y)},[r]);const m=y=>{y.stopPropagation(),h&&u(!0)};function g(y){if(y.stopPropagation(),y.key==="Escape"){u(!1);return}y.key==="Enter"&&y.shiftKey||(y.key==="Enter"||y.key==="Tab")&&(u(!1),o(d))}function b(){return s==="textarea"?l.jsx("textarea",{className:p.cn("resize rounded-sm bg-background px-2 py-1 text-sm outline-[0.5px] outline-muted",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g}):l.jsx("input",{onMouseDown:y=>y.stopPropagation(),type:"text",className:p.cn("rounded-sm bg-background outline-none",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g})}function x(){return a?l.jsx("div",{className:"flex grow items-center",children:l.jsx("div",{children:c?b():e})}):e}return l.jsx("div",{className:p.cn("flex",a&&!c&&"cursor-text",t),role:"editable",onDoubleClick:m,onMouseDown:y=>y.stopPropagation(),children:l.jsx("div",{className:"flex grow items-center",children:x()})})}function $I(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function xi(e){const t=e.isEditable!==!1&&e.isPending!==!0?"editable":"read-only";return l.jsx(XQe,{...e},t)}function XQe({value:e,displayTitle:t=!0,onSave:n,placeholder:r,inputClassName:o,displayClassName:s,isEditable:i=!0,isPending:a=!1,onEditingChange:c}){const[u,d]=v.useState(!1),[f,h]=v.useState(e||""),m=x=>{d(x),c==null||c(x)},g=()=>{m(!1),f!==e&&n(f)},b=x=>{x.key==="Enter"?(m(!1),n(f)):x.key==="Escape"&&(m(!1),h(e||""))};return u?l.jsx("div",{className:"flex",children:l.jsx("input",{type:"text",value:f,onChange:x=>h(x.target.value),onBlur:g,onKeyDown:b,onMouseDown:x=>x.stopPropagation(),className:p.cn("m-0 w-full border-0 bg-transparent p-0 outline-none focus:ring-1 focus:ring-ring/40 focus:ring-offset-2 focus:ring-offset-background",o),autoFocus:!0})}):l.jsxs("div",{className:p.cn("relative truncate transition-colors",s,{"cursor-default":!i,"cursor-text":i}),onClick:()=>{!i||a||(m(!0),h(e||""))},title:t?e||r:void 0,children:[l.jsx("div",{className:"flex items-center justify-between gap-2",children:l.jsx("span",{className:p.cn("truncate",{"text-muted-foreground":a}),children:e||l.jsx("span",{className:"text-muted-foreground",children:r})})}),a&&l.jsx("div",{className:"absolute inset-0 animate-pulse rounded bg-gradient-to-r from-transparent via-blue-100/30 to-transparent"})]})}function wM(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function sue({card:e,preferences:t,boundCurrency:n}){var w,C,N,S,j,_;const r=t===void 0?Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,o=(w=e==null?void 0:e.preferences)==null?void 0:w.formatNumber,s=(N=(C=e==null?void 0:e.preferences)==null?void 0:C.kpiVisualOptions)==null?void 0:N.formatOptions,i=(e==null?void 0:e.type)==="kpi"?m0(e):void 0,a=e&&e.type!=="kpi"?p.fromSemanticFormat((_=(j=(S=e.config)==null?void 0:S.metricColumns)==null?void 0:j[0])==null?void 0:_.format,{preserveOmittedProperties:!0}):void 0,c=(e==null?void 0:e.type)==="kpi"?i==null?void 0:i.authoredFormat:p.fromPersistedKpiFormatOptions(s)||a||p.fromLegacyFormatNumber(o),u=c&&r&&Kt.isNumericCanonicalFormat(c)?$t.resolveNumericPresentation(c,r,n):c,d=(u==null?void 0:u.type)==="currency"?u.currency:void 0,f=wM(o==null?void 0:o.currency),h=d||f,m=u&&"locale"in u&&wM(u.locale),g=wM(o==null?void 0:o.locale),b=m||g||(r==null?void 0:r.locale)||Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,x=o==null?void 0:o.enabled;return{currency:h,locale:b,canonicalPrimaryFormat:u,isFormattingDisabled:x===!1||x==="false"}}function iue(e){var c,u,d;const{preferences:t,resolveBoundCurrency:n}=Ta(e),r=(d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.id,o=sue({card:e,preferences:t,boundCurrency:r?n({kind:"metric",metricId:r}):void 0});function s(){return o.currency}function i(){return o.locale}function a(){return o.canonicalPrimaryFormat}return{getCurrency:s,getLocale:i,getPrimaryFormat:a}}const QQe={"currentPeriod.start":"Current Start","currentPeriod.end":"Current End","comparisonPeriod.start":"Previous Start","comparisonPeriod.end":"Previous End"},JQe=e=>e.filter(t=>t.segment==="meta"||t.Segment==="meta"),eJe=e=>{switch(e){case"target":return"Target";case"previous_year":return"Last Year";case"previous_period":default:return"Previous"}};function CM({label:e,value:t,formatCurrency:n,emphasize:r=!1,signed:o=!1}){const s=n(o?Math.abs(t):t),i=o?t>0?`+${s}`:t<0?`−${s}`:s:s;return l.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:e}),l.jsx("span",{className:r?"font-medium tabular-nums text-foreground":"tabular-nums text-foreground",children:i})]})}function tJe({metaKey:e,value:t}){const n=QQe[e]??e;return l.jsxs("div",{className:"flex items-center justify-between gap-4 text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:n}),l.jsx("span",{className:"tabular-nums text-foreground",children:t})]})}function nJe({currentValue:e,comparisonValue:t,formatCurrency:n,comparisonLabel:r="Previous"}){return l.jsxs("div",{className:"space-y-1",children:[l.jsx(CM,{label:"Current",value:e,formatCurrency:n,emphasize:!0}),l.jsx(CM,{label:r,value:t,formatCurrency:n}),l.jsx(CM,{label:"Change",value:e-t,formatCurrency:n,signed:!0})]})}function rJe({data:e,comparisonMetadata:t}){const n=t==null?void 0:t.output.currentWindow,r=t==null?void 0:t.output.comparisonWindow,o=t==null?void 0:t.output.windowGrain,s=n?LA({start:n.startInclusive,end:n.endExclusive},n.timezone,o):void 0,i=r?LA({start:r.startInclusive,end:r.endExclusive},r.timezone,o):void 0,a=s&&i?[{key:"currentPeriod.start",value:s.start},{key:"currentPeriod.end",value:s.end},{key:"comparisonPeriod.start",value:i.start},{key:"comparisonPeriod.end",value:i.end}]:JQe(e);return a.length===0?null:l.jsxs("div",{className:"space-y-1 border-t border-border/60 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Period Details"}),l.jsx("div",{className:"space-y-1",children:a.map((c,u)=>l.jsx(tJe,{metaKey:c.key??c.Key,value:c.value??c.Value},u))})]})}function oJe({currentValue:e,comparisonValue:t,sentiment:n,data:r,comparisonMetadata:o,comparisonKind:s,formatCurrency:i,conditionalLabel:a}){const c=eJe((o==null?void 0:o.type)??s);return l.jsxs(p.TooltipContent,{side:"right",sideOffset:8,className:"w-[260px] rounded-[6px] border border-border bg-popover p-0 text-popover-foreground shadow-md",children:[a&&l.jsx("div",{className:`border-b border-border/60 px-3 py-2 text-[12px] font-medium ${n==="favorable"?"text-emerald-600 dark:text-emerald-400":n==="unfavorable"?"text-rose-600 dark:text-rose-400":"text-muted-foreground"}`,children:a}),l.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Key Metrics"}),l.jsx(nJe,{currentValue:e,comparisonValue:t,formatCurrency:i,comparisonLabel:c})]}),l.jsx(rJe,{data:r,comparisonMetadata:o})]})}const sJe=[{id:"us",name:"United States",flag:"🇺🇸",code:"US",region:"North America"},{id:"ca",name:"Canada",flag:"🇨🇦",code:"CA",region:"North America"},{id:"mx",name:"Mexico",flag:"🇲🇽",code:"MX",region:"North America"},{id:"gb",name:"United Kingdom",flag:"🇬🇧",code:"GB",region:"Europe"},{id:"de",name:"Germany",flag:"🇩🇪",code:"DE",region:"Europe"},{id:"fr",name:"France",flag:"🇫🇷",code:"FR",region:"Europe"},{id:"it",name:"Italy",flag:"🇮🇹",code:"IT",region:"Europe"},{id:"es",name:"Spain",flag:"🇪🇸",code:"ES",region:"Europe"},{id:"nl",name:"Netherlands",flag:"🇳🇱",code:"NL",region:"Europe"},{id:"be",name:"Belgium",flag:"🇧🇪",code:"BE",region:"Europe"},{id:"ch",name:"Switzerland",flag:"🇨🇭",code:"CH",region:"Europe"},{id:"at",name:"Austria",flag:"🇦🇹",code:"AT",region:"Europe"},{id:"se",name:"Sweden",flag:"🇸🇪",code:"SE",region:"Europe"},{id:"no",name:"Norway",flag:"🇳🇴",code:"NO",region:"Europe"},{id:"dk",name:"Denmark",flag:"🇩🇰",code:"DK",region:"Europe"},{id:"fi",name:"Finland",flag:"🇫🇮",code:"FI",region:"Europe"},{id:"pl",name:"Poland",flag:"🇵🇱",code:"PL",region:"Europe"},{id:"cz",name:"Czech Republic",flag:"🇨🇿",code:"CZ",region:"Europe"},{id:"hu",name:"Hungary",flag:"🇭🇺",code:"HU",region:"Europe"},{id:"pt",name:"Portugal",flag:"🇵🇹",code:"PT",region:"Europe"},{id:"ie",name:"Ireland",flag:"🇮🇪",code:"IE",region:"Europe"},{id:"gr",name:"Greece",flag:"🇬🇷",code:"GR",region:"Europe"},{id:"jp",name:"Japan",flag:"🇯🇵",code:"JP",region:"Asia"},{id:"cn",name:"China",flag:"🇨🇳",code:"CN",region:"Asia"},{id:"in",name:"India",flag:"🇮🇳",code:"IN",region:"Asia"},{id:"kr",name:"South Korea",flag:"🇰🇷",code:"KR",region:"Asia"},{id:"sg",name:"Singapore",flag:"🇸🇬",code:"SG",region:"Asia"},{id:"hk",name:"Hong Kong",flag:"🇭🇰",code:"HK",region:"Asia"},{id:"tw",name:"Taiwan",flag:"🇹🇼",code:"TW",region:"Asia"},{id:"th",name:"Thailand",flag:"🇹🇭",code:"TH",region:"Asia"},{id:"my",name:"Malaysia",flag:"🇲🇾",code:"MY",region:"Asia"},{id:"id",name:"Indonesia",flag:"🇮🇩",code:"ID",region:"Asia"},{id:"ph",name:"Philippines",flag:"🇵🇭",code:"PH",region:"Asia"},{id:"vn",name:"Vietnam",flag:"🇻🇳",code:"VN",region:"Asia"},{id:"ae",name:"United Arab Emirates",flag:"🇦🇪",code:"AE",region:"Asia"},{id:"sa",name:"Saudi Arabia",flag:"🇸🇦",code:"SA",region:"Asia"},{id:"il",name:"Israel",flag:"🇮🇱",code:"IL",region:"Asia"},{id:"tr",name:"Turkey",flag:"🇹🇷",code:"TR",region:"Asia"},{id:"au",name:"Australia",flag:"🇦🇺",code:"AU",region:"Oceania"},{id:"nz",name:"New Zealand",flag:"🇳🇿",code:"NZ",region:"Oceania"},{id:"br",name:"Brazil",flag:"🇧🇷",code:"BR",region:"South America"},{id:"ar",name:"Argentina",flag:"🇦🇷",code:"AR",region:"South America"},{id:"cl",name:"Chile",flag:"🇨🇱",code:"CL",region:"South America"},{id:"co",name:"Colombia",flag:"🇨🇴",code:"CO",region:"South America"},{id:"pe",name:"Peru",flag:"🇵🇪",code:"PE",region:"South America"},{id:"uy",name:"Uruguay",flag:"🇺🇾",code:"UY",region:"South America"},{id:"ec",name:"Ecuador",flag:"🇪🇨",code:"EC",region:"South America"},{id:"ve",name:"Venezuela",flag:"🇻🇪",code:"VE",region:"South America"},{id:"za",name:"South Africa",flag:"🇿🇦",code:"ZA",region:"Africa"},{id:"ng",name:"Nigeria",flag:"🇳🇬",code:"NG",region:"Africa"},{id:"eg",name:"Egypt",flag:"🇪🇬",code:"EG",region:"Africa"},{id:"ma",name:"Morocco",flag:"🇲🇦",code:"MA",region:"Africa"},{id:"ke",name:"Kenya",flag:"🇰🇪",code:"KE",region:"Africa"},{id:"gh",name:"Ghana",flag:"🇬🇭",code:"GH",region:"Africa"},{id:"et",name:"Ethiopia",flag:"🇪🇹",code:"ET",region:"Africa"},{id:"tz",name:"Tanzania",flag:"🇹🇿",code:"TZ",region:"Africa"},{id:"ru",name:"Russia",flag:"🇷🇺",code:"RU",region:"Europe/Asia"},{id:"ua",name:"Ukraine",flag:"🇺🇦",code:"UA",region:"Europe"},{id:"by",name:"Belarus",flag:"🇧🇾",code:"BY",region:"Europe"},{id:"lt",name:"Lithuania",flag:"🇱🇹",code:"LT",region:"Europe"},{id:"lv",name:"Latvia",flag:"🇱🇻",code:"LV",region:"Europe"},{id:"ee",name:"Estonia",flag:"🇪🇪",code:"EE",region:"Europe"},{id:"ro",name:"Romania",flag:"🇷🇴",code:"RO",region:"Europe"},{id:"bg",name:"Bulgaria",flag:"🇧🇬",code:"BG",region:"Europe"},{id:"hr",name:"Croatia",flag:"🇭🇷",code:"HR",region:"Europe"},{id:"si",name:"Slovenia",flag:"🇸🇮",code:"SI",region:"Europe"},{id:"sk",name:"Slovakia",flag:"🇸🇰",code:"SK",region:"Europe"},{id:"rs",name:"Serbia",flag:"🇷🇸",code:"RS",region:"Europe"},{id:"ba",name:"Bosnia and Herzegovina",flag:"🇧🇦",code:"BA",region:"Europe"},{id:"me",name:"Montenegro",flag:"🇲🇪",code:"ME",region:"Europe"},{id:"mk",name:"North Macedonia",flag:"🇲🇰",code:"MK",region:"Europe"},{id:"al",name:"Albania",flag:"🇦🇱",code:"AL",region:"Europe"},{id:"xk",name:"Kosovo",flag:"🇽🇰",code:"XK",region:"Europe"},{id:"md",name:"Moldova",flag:"🇲🇩",code:"MD",region:"Europe"},{id:"is",name:"Iceland",flag:"🇮🇸",code:"IS",region:"Europe"},{id:"lu",name:"Luxembourg",flag:"🇱🇺",code:"LU",region:"Europe"},{id:"mt",name:"Malta",flag:"🇲🇹",code:"MT",region:"Europe"},{id:"cy",name:"Cyprus",flag:"🇨🇾",code:"CY",region:"Europe"},{id:"mc",name:"Monaco",flag:"🇲🇨",code:"MC",region:"Europe"},{id:"ad",name:"Andorra",flag:"🇦🇩",code:"AD",region:"Europe"},{id:"sm",name:"San Marino",flag:"🇸🇲",code:"SM",region:"Europe"},{id:"va",name:"Vatican City",flag:"🇻🇦",code:"VA",region:"Europe"},{id:"li",name:"Liechtenstein",flag:"🇱🇮",code:"LI",region:"Europe"},{id:"pk",name:"Pakistan",flag:"🇵🇰",code:"PK",region:"Asia"},{id:"bd",name:"Bangladesh",flag:"🇧🇩",code:"BD",region:"Asia"},{id:"lk",name:"Sri Lanka",flag:"🇱🇰",code:"LK",region:"Asia"},{id:"np",name:"Nepal",flag:"🇳🇵",code:"NP",region:"Asia"},{id:"bt",name:"Bhutan",flag:"🇧🇹",code:"BT",region:"Asia"},{id:"mv",name:"Maldives",flag:"🇲🇻",code:"MV",region:"Asia"},{id:"af",name:"Afghanistan",flag:"🇦🇫",code:"AF",region:"Asia"},{id:"ir",name:"Iran",flag:"🇮🇷",code:"IR",region:"Asia"},{id:"iq",name:"Iraq",flag:"🇮🇶",code:"IQ",region:"Asia"},{id:"sy",name:"Syria",flag:"🇸🇾",code:"SY",region:"Asia"},{id:"lb",name:"Lebanon",flag:"🇱🇧",code:"LB",region:"Asia"},{id:"jo",name:"Jordan",flag:"🇯🇴",code:"JO",region:"Asia"},{id:"kw",name:"Kuwait",flag:"🇰🇼",code:"KW",region:"Asia"},{id:"qa",name:"Qatar",flag:"🇶🇦",code:"QA",region:"Asia"},{id:"bh",name:"Bahrain",flag:"🇧🇭",code:"BH",region:"Asia"},{id:"om",name:"Oman",flag:"🇴🇲",code:"OM",region:"Asia"},{id:"ye",name:"Yemen",flag:"🇾🇪",code:"YE",region:"Asia"},{id:"ge",name:"Georgia",flag:"🇬🇪",code:"GE",region:"Asia"},{id:"am",name:"Armenia",flag:"🇦🇲",code:"AM",region:"Asia"},{id:"az",name:"Azerbaijan",flag:"🇦🇿",code:"AZ",region:"Asia"},{id:"kz",name:"Kazakhstan",flag:"🇰🇿",code:"KZ",region:"Asia"},{id:"kg",name:"Kyrgyzstan",flag:"🇰🇬",code:"KG",region:"Asia"},{id:"tj",name:"Tajikistan",flag:"🇹🇯",code:"TJ",region:"Asia"},{id:"tm",name:"Turkmenistan",flag:"🇹🇲",code:"TM",region:"Asia"},{id:"uz",name:"Uzbekistan",flag:"🇺🇿",code:"UZ",region:"Asia"},{id:"mn",name:"Mongolia",flag:"🇲🇳",code:"MN",region:"Asia"},{id:"kp",name:"North Korea",flag:"🇰🇵",code:"KP",region:"Asia"},{id:"mm",name:"Myanmar",flag:"🇲🇲",code:"MM",region:"Asia"},{id:"la",name:"Laos",flag:"🇱🇦",code:"LA",region:"Asia"},{id:"kh",name:"Cambodia",flag:"🇰🇭",code:"KH",region:"Asia"},{id:"bn",name:"Brunei",flag:"🇧🇳",code:"BN",region:"Asia"},{id:"tl",name:"East Timor",flag:"🇹🇱",code:"TL",region:"Asia"},{id:"dz",name:"Algeria",flag:"🇩🇿",code:"DZ",region:"Africa"},{id:"tn",name:"Tunisia",flag:"🇹🇳",code:"TN",region:"Africa"},{id:"ly",name:"Libya",flag:"🇱🇾",code:"LY",region:"Africa"},{id:"sd",name:"Sudan",flag:"🇸🇩",code:"SD",region:"Africa"},{id:"ss",name:"South Sudan",flag:"🇸🇸",code:"SS",region:"Africa"},{id:"td",name:"Chad",flag:"🇹🇩",code:"TD",region:"Africa"},{id:"ne",name:"Niger",flag:"🇳🇪",code:"NE",region:"Africa"},{id:"ml",name:"Mali",flag:"🇲🇱",code:"ML",region:"Africa"},{id:"bf",name:"Burkina Faso",flag:"🇧🇫",code:"BF",region:"Africa"},{id:"sn",name:"Senegal",flag:"🇸🇳",code:"SN",region:"Africa"},{id:"gm",name:"Gambia",flag:"🇬🇲",code:"GM",region:"Africa"},{id:"gw",name:"Guinea-Bissau",flag:"🇬🇼",code:"GW",region:"Africa"},{id:"gn",name:"Guinea",flag:"🇬🇳",code:"GN",region:"Africa"},{id:"sl",name:"Sierra Leone",flag:"🇸🇱",code:"SL",region:"Africa"},{id:"lr",name:"Liberia",flag:"🇱🇷",code:"LR",region:"Africa"},{id:"ci",name:"Ivory Coast",flag:"🇨🇮",code:"CI",region:"Africa"},{id:"tg",name:"Togo",flag:"🇹🇬",code:"TG",region:"Africa"},{id:"bj",name:"Benin",flag:"🇧🇯",code:"BJ",region:"Africa"},{id:"zw",name:"Zimbabwe",flag:"🇿🇼",code:"ZW",region:"Africa"},{id:"zm",name:"Zambia",flag:"🇿🇲",code:"ZM",region:"Africa"}];function aue(e){const t=p.useDashboardStore(c=>c.isDashboardEditing),n=p.useDashboardStore(c=>c.isVisualEditing),{setCardTitle:r,setCountryLogo:o}=p.useEditorActions();return{setTitle:c=>{n&&r(c)},setCountryLogo:c=>{n&&o(c)},isEditable:n,isDashboardEditing:t,isVisualEditing:n}}function iJe(e,t){var r,o;if(!e)return e;const n=(o=(r=e.config)==null?void 0:r.metricColumns)==null?void 0:o[t];return{...e,config:{...e.config,metricColumns:n?[n]:[]},preferences:e.preferences}}function aJe(e){var b,x,y,w,C,N;if(!e)return e;const t=(x=(b=e.config)==null?void 0:b.metricColumns)==null?void 0:x[0],n=(y=e.preferences)==null?void 0:y.formatNumber,r=(C=(w=e.preferences)==null?void 0:w.kpiVisualOptions)==null?void 0:C.formatOptions,o=p.fromTFormatOptions(r),s=(o==null?void 0:o.type)==="date"?oU(r==null?void 0:r.locale):void 0,i=o&&(Kt.isNumericCanonicalFormat(o)||o.type==="duration")?r:void 0,a=p.fromSemanticFormat(t==null?void 0:t.format),c=a&&(a.type==="date"||a.type==="string")&&"locale"in a?oU(a.locale):void 0,u=s||c,d=a&&(Kt.isNumericCanonicalFormat(a)||a.type==="duration")&&t?[u&&t.format&&typeof t.format=="object"?{...t,format:{...t.format,locale:u}}:t]:[],h=((o==null?void 0:o.type)==="date"||(o==null?void 0:o.type)==="string"||(o==null?void 0:o.type)==="temporal_bucket"||(a==null?void 0:a.type)==="date"||(a==null?void 0:a.type)==="string"||(a==null?void 0:a.type)==="temporal_bucket")&&!i&&d.length===0,m=!i&&u?{locale:u}:void 0,g=h?{...n,locale:u||(n==null?void 0:n.locale),currency:void 0,prefix:void 0,suffix:void 0,percentValueMode:void 0}:n;return{...e,config:{...e.config,metricColumns:d},preferences:{...e.preferences,formatNumber:g,kpiVisualOptions:{...(N=e.preferences)==null?void 0:N.kpiVisualOptions,formatOptions:i||m}}}}function lJe(e){return e!=="date"}function oU(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function rp({card:e,preferences:t,boundCurrency:n}){const r=t===void 0?Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,{canonicalPrimaryFormat:o,isFormattingDisabled:s}=sue({card:e,preferences:t,boundCurrency:n}),i=o&&Kt.isNumericCanonicalFormat(o)?o:void 0,a=o&&(o.type==="date"||o.type==="duration")?p.toTFormatOptions(o):void 0,c={type:"number",locale:(r==null?void 0:r.locale)||Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,minimumFractionDigits:0,maximumFractionDigits:0,useGrouping:!0},u=o==null?void 0:o.type,d=(g,{forceCompact:b=!1,forceSign:x=!1}={})=>{if(g==null)return"n/a";if(s){const w=String(g);return x&&g>0?`+${w}`:w}const y=a!=null&&a.type&&a.type!=="auto"?gr(g,a.type,a):$t.formatNumericCanonical(g,{...i||c,compact:b?!0:i==null?void 0:i.compact});return x&&g>0?`+${y}`:y};return{format:g=>d(g),formatCompact:g=>d(g,{forceCompact:!0}),formatSigned:g=>d(g,{forceSign:!0}),supportsComparisonDeltaInheritance:lJe(u)}}function sU({card:e,preferences:t,boundCurrency:n,metricIndex:r}){return rp({card:iJe(e,r),preferences:t,boundCurrency:n})}function lue({card:e,preferences:t,boundCurrency:n}){return rp({card:aJe(e),preferences:t,boundCurrency:n})}function cJe({card:e,data:t,isPending:n,headerAction:r,headerTrailingAction:o}){var X,Y,O,q,U,V,K,Q,se,oe,me,le,ue,ne,de,Ce,ce,ie,we,fe,ae,ee;const s=e.config,{setTitle:i,isEditable:a,isVisualEditing:c}=aue(),{setCardDescription:u}=p.useEditorActions(),{getLocale:d}=iue(e),{preferences:f,boundCurrency:h,resolveBoundCurrency:m}=W_(e,t),g=(O=(Y=(X=e.config)==null?void 0:X.metricColumns)==null?void 0:Y[1])==null?void 0:O.id,b=(V=(U=(q=e.config)==null?void 0:q.metricColumns)==null?void 0:U[2])==null?void 0:V.id,x=g?m({kind:"metric",metricId:g}):void 0,y=b?m({kind:"metric",metricId:b}):void 0,w=v.useMemo(()=>rp({card:e,preferences:f,boundCurrency:h}),[e,h,f]),C=v.useMemo(()=>sU({card:e,preferences:f,boundCurrency:x,metricIndex:1}),[e,x,f]),N=v.useMemo(()=>sU({card:e,preferences:f,boundCurrency:y,metricIndex:2}),[e,y,f]),S=(s==null?void 0:s.metricColumns)||[],j=((K=e.preferences)==null?void 0:K.metricPairComparisonEnabled)===!0,_=J=>w.format(J),k=J=>w.formatCompact(J),T=J=>C.format(J),I=J=>N.format(J),E=!!p.fromSemanticFormat((Q=S[1])==null?void 0:Q.format),D=J=>E||x?T(J):_(J),R=J=>{const re=t==null?void 0:t.find(pe=>{var Ee,Te;return pe.segment===J||pe.Segment===J||((Ee=pe.segment)==null?void 0:Ee.toLowerCase())===J.toLowerCase()||((Te=pe.Segment)==null?void 0:Te.toLowerCase())===J.toLowerCase()});return(re==null?void 0:re.value)??(re==null?void 0:re.Value)??0},A=R("current"),F=R("comparison"),z=R("tertiary"),L=p.getMetricComparisonPolarity(S[0]),$=(oe=(se=e.preferences)==null?void 0:se.formatNumber)==null?void 0:oe.colorRanges,H=$I(A,$);function M(){return e.title?e.title:a?"Enter title":""}if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const B=j&&S.length===2,W=S.length>=2&&F!==void 0,P=S.length>2&&z!==void 0,Z=((me=e==null?void 0:e.kpiPreferences)==null?void 0:me.format)==="compact"?k(A):_(A);return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:M(),isEditable:a,onSave:i}),(e.description||c)&&l.jsx(xi,{isEditable:c,value:e.description||(c?"Enter description":""),placeholder:c?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:u})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r,B&&l.jsx("div",{className:"shrink-0",children:l.jsx(u3,{primaryValue:A,secondaryValue:F,presentation:(le=e.preferences)==null?void 0:le.comparisonPresentation,metricFormatOptions:(ne=(ue=e.preferences)==null?void 0:ue.kpiVisualOptions)==null?void 0:ne.formatOptions,locale:d()||"en-US",decimalPlaces:(Ce=(de=e.preferences)==null?void 0:de.formatNumber)==null?void 0:Ce.decimalPlaces,suffix:(ie=(ce=e.preferences)==null?void 0:ce.formatNumber)==null?void 0:ie.suffix,polarity:L,signedValueFormatter:w.formatSigned,allowSignedValueFormatter:w.supportsComparisonDeltaInheritance})}),o]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:H?{color:H}:void 0,children:Z}),W&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[((we=S[1])==null?void 0:we.label)||((fe=S[1])==null?void 0:fe.name),l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:D(F)})]})]}),P&&l.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-4 py-2",children:[l.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:((ae=S[2])==null?void 0:ae.label)||((ee=S[2])==null?void 0:ee.name)}),l.jsx("span",{className:"text-[12px] font-medium tabular-nums text-foreground",children:I(z)})]})]})}function uJe(e){var t;return e.comparisonKind==="target"&&e.targetValue>0&&((t=e.presentation)==null?void 0:t.showComparison)!==!1}function dJe(e){const{comparisonKind:t,comparisonValue:n,targetValue:r}=e;return t==="target"?typeof r=="number"&&!Number.isNaN(r)?r:null:n}function fJe(e){return typeof e=="number"?"number":typeof e=="boolean"?"boolean":e instanceof Date?"date":"string"}function hJe(e){const t=Array.isArray(e.payload.filters)?e.payload.filters:[];return t.length>0?t:[{field:e.payload.field,operator:e.payload.operator,value:e.payload.value}]}function mJe(e,t){return t?`summary:${e}:${t}`:`summary:${e}`}function cue({addOrUpdateFilterValues:e,onEvent:t,refresh:n,selectedSheetId:r,cardId:o,onChangeComparison:s}){return async i=>{if(i.type==="apply_filter"){const a=hJe(i),c=[];for(const u of a){const d=String(u.field||"").trim(),f=String(u.operator||"=").trim(),h=u.value,m=Array.isArray(h)?h[0]:h;if(!d||m==null)continue;const g={filterId:mJe(d,r),name:d,operation:f==="eq"?"=":f==="in"?"in":"=",valueType:fJe(m),values:Array.isArray(h)?h:[m]};c.push(g)}c.length>0&&e(c),t==null||t({type:"info",message:{event:"summary_driver_chip_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}if(i.type==="refresh"){await n(),t==null||t({type:"info",message:{event:"summary_retry_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}i.type==="change_comparison"&&s&&await s(i)}}function pJe(e){return e==="kpi"}function uue(e){var t,n;return pJe(e==null?void 0:e.type)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.enabled)===!0}function z$(e){var n;const t=(n=e==null?void 0:e.config)==null?void 0:n.summary;return uue(e)&&((t==null?void 0:t.showOnCard)===!0||((t==null?void 0:t.breakdownDimensions)||[]).length>0)}function iU(e){var t,n;return uue(e)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.includeInDashboardSummary)===!0}function B$(e,t){var H,M;const{authToken:n,tokenProps:r}=It(),o=p.useDashboardStore(B=>B.selectedSheetId),s=p.useDashboardStore(B=>B.dashboard),i=p.useDashboardStore(B=>B.selectedLensId),a=p.useDashboardStore(B=>B.dashboardInputReferenceTime),c=p.useDashboardStore(B=>B.onEvent),u=Wr(),{addOrUpdateFilterValues:d}=p.useDashboardActions(),f=JL(e),{cardFilterValues:h,finalConfig:m,finalFiltersKey:g,queryRelevantConfig:b}=f,x=v.useMemo(()=>p.getDashboardCards(s),[s]),y=v.useMemo(()=>x.length>0?x:[e],[e,x]),w=v.useMemo(()=>Object.fromEntries(y.map(B=>[B.id,B.id===e.id?b:B.config])),[e.id,b,y]),C=u_(y,{authority:"runtime",queryRelevantConfigsByCardId:w}).payload,N=p.useDashboardStore(B=>{var W;return((W=B.reportContext)==null?void 0:W.calendar)??null}),S=N==null?void 0:N.tz,j=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,C),[s,C]),{cardFilterValues:_,globalDateComparison:k}=v.useMemo(()=>Jv({card:e,queryContext:f,semanticExecutionPayload:C,timezone:S,allowMinutePrecision:j.allEligibleTargetsAreDateTime,comparisonReferenceTime:a}),[e,f,C,S,a,j.allEligibleTargetsAreDateTime]),T=(t==null?void 0:t.enabled)??!0,I=v.useMemo(()=>({id:e.id,title:e.title,type:e.type,config:m,dataSource:e.dataSource,preferences:e.preferences}),[e.id,e.title,e.type,m,e.dataSource,e.preferences]),E=v.useMemo(()=>JSON.stringify({type:e.type,config:m,dataSource:e.dataSource}),[e.type,m,e.dataSource]),D=(s==null?void 0:s.id)||(r==null?void 0:r.dashboard_id),R=o||((M=(H=s==null?void 0:s.sheets)==null?void 0:H[0])==null?void 0:M.id)||null,A=!!(n!=null&&n.accessToken&&(r!=null&&r.apiServiceUrl)&&D&&R&&(e!=null&&e.id)&&N&&T&&z$(e)),F=v.useMemo(()=>["card-summary",D,R,e.id,i,g,JSON.stringify(_||[]),E,k,N],[D,R,e.id,i,g,_,E,k,N]),z=Un({queryKey:F,enabled:A,staleTime:1e3,queryFn:async()=>{const B=`${r.apiServiceUrl}/v1/dashboard/${D}/cards/${e.id}/summary`;return p.postRequestRegular(B,(n==null?void 0:n.accessToken)||"",{selectedSheetId:R,activeFilters:_||[],lensId:i,cardOverride:I,globalDateComparison:k,calendarContext:N})}}),L=ks({mutationFn:async()=>{const B=`${r.apiServiceUrl}/v1/dashboard/${D}/cards/${e.id}/summary`;return p.postRequestRegular(B,(n==null?void 0:n.accessToken)||"",{selectedSheetId:R,activeFilters:_||[],lensId:i,cardOverride:I,globalDateComparison:k,calendarContext:N,refresh:!0})},onSuccess:B=>{u.setQueryData(F,B)}}),$=v.useMemo(()=>cue({addOrUpdateFilterValues:d,onEvent:c,refresh:()=>L.mutateAsync(),selectedSheetId:R,cardId:e.id}),[d,c,L,R,e.id]);return{data:z.data,isLoading:z.isLoading,isFetching:z.isFetching,isError:z.isError,error:z.error,refresh:L.mutateAsync,isRefreshing:L.isPending,applyAction:$,enabled:A}}function gJe(e,t){var r;if(!((r=e==null?void 0:e.sheets)!=null&&r.length)||!t)return[];const n=e.sheets.find(o=>o.id===t)||e.sheets[0];return n?[...n.cards||[],...(n.frames||[]).flatMap(o=>o.cards||[])]:[]}function due(){var z,L;const{authToken:e,tokenProps:t}=It(),n=p.useDashboardStore($=>{var H;return((H=$.reportContext)==null?void 0:H.calendar)??null}),r=n==null?void 0:n.tz,o=p.useDashboardStore($=>$.selectedSheetId),s=p.useDashboardStore($=>$.dashboard),i=p.useDashboardStore($=>$.dashboard.filters),a=p.useDashboardStore($=>$.semanticExecutionPayload),c=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,a),[s,a]),u=p.useDashboardStore($=>$.filterValues),d=p.useDashboardStore($=>$.inlineFilterValuesMap),f=p.useDashboardStore($=>$.dashboardInputValues),h=p.useDashboardStore($=>$.dashboardInputReferenceTime),m=p.useDashboardStore($=>$.controlValues),g=p.useDashboardStore($=>$.cardControlValuesMap),b=p.useDashboardStore($=>$.selectedLensId),x=p.useDashboardStore($=>$.onEvent),y=p.useInteractionStore($=>$.interactionStates),w=Wr(),{addOrUpdateFilterValues:C}=p.useDashboardActions(),N=(s==null?void 0:s.id)||(t==null?void 0:t.dashboard_id),S=o||((L=(z=s==null?void 0:s.sheets)==null?void 0:z[0])==null?void 0:L.id)||null,j=v.useMemo(()=>gJe(s,S),[s,S]),_=v.useMemo(()=>j.some($=>iU($)),[j]),k=!!(e!=null&&e.accessToken&&(t!=null&&t.apiServiceUrl)&&N&&S&&n&&_),T=v.useMemo(()=>{const $={};for(const H of j){if(!iU(H))continue;const M=hb({card:H,dashboard:s,interactionStates:y,currentDashboardId:s==null?void 0:s.id,filters:i,filterValues:u,selectedSheetId:S,inlineFilterValuesMap:d,dashboardInputContext:Yi({dashboard:s,sheetId:S,card:H,runtimeValues:{dashboardInputValues:f,filterValues:u,controlValues:m,inlineFilterValuesMap:d,cardControlValuesMap:g}})}),{cardFilterValues:B,globalDateComparison:W}=Jv({card:H,queryContext:M,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime,comparisonReferenceTime:h});$[H.id]={activeFilters:B,cardOverride:{id:H.id,title:H.title,type:H.type,config:M.finalConfig,dataSource:H.dataSource,preferences:H.preferences},globalDateComparison:W}}return $},[j,y,s,i,a,c.allEligibleTargetsAreDateTime,u,S,d,f,h,m,g,r]),I=v.useMemo(()=>JJ({filters:i,filterValues:u||[],dashboard:s,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime}),[i,u,s,a,r,c.allEligibleTargetsAreDateTime]),E=v.useMemo(()=>JSON.stringify(T),[T]),D=v.useMemo(()=>["dashboard-summary",N,S,b,JSON.stringify(I),E,n],[N,S,b,I,E,n]),R=Un({queryKey:D,enabled:k,staleTime:1e3,queryFn:async()=>{const $=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular($,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:I,lensId:b,cardContexts:T,calendarContext:n})}}),A=ks({mutationFn:async()=>{const $=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular($,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:I,lensId:b,refresh:!0,cardContexts:T,calendarContext:n})},onSuccess:$=>{w.setQueryData(D,$)}}),F=v.useMemo(()=>cue({addOrUpdateFilterValues:C,onEvent:x,refresh:()=>A.mutateAsync(),selectedSheetId:S,onChangeComparison:$=>{x==null||x({type:"info",message:{event:"summary_action_clicked",actionType:"change_comparison",payload:$.payload}})}}),[C,x,A,S]);return{data:R.data,isLoading:R.isLoading,isFetching:R.isFetching,isError:R.isError,error:R.error,refetch:R.refetch,refresh:A.mutateAsync,isRefreshing:A.isPending,applyAction:F,enabled:k}}var zI="Collapsible",[bJe,fue]=p.createContextScope(zI),[xJe,V$]=bJe(zI),hue=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=p.useControllableState({prop:r,defaultProp:o??!1,onChange:i,caller:zI});return l.jsx(xJe,{scope:n,disabled:s,contentId:p.useId(),open:c,onOpenToggle:te.useCallback(()=>u(d=>!d),[u]),children:l.jsx(p.Primitive.div,{"data-state":W$(c),"data-disabled":s?"":void 0,...a,ref:t})})});hue.displayName=zI;var mue="CollapsibleTrigger",H$=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=V$(mue,n);return l.jsx(p.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":W$(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:p.composeEventHandlers(e.onClick,o.onOpenToggle)})});H$.displayName=mue;var q$="CollapsibleContent",U$=te.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=V$(q$,e.__scopeCollapsible);return l.jsx(p.Presence,{present:n||o.open,children:({present:s})=>l.jsx(yJe,{...r,ref:t,present:s})})});U$.displayName=q$;var yJe=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=V$(q$,n),[a,c]=te.useState(r),u=te.useRef(null),d=p.useComposedRefs(t,u),f=te.useRef(0),h=f.current,m=te.useRef(0),g=m.current,b=i.open||a,x=te.useRef(b),y=te.useRef(void 0);return te.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),p.useLayoutEffect2(()=>{const w=u.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,m.current=C.width,x.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),c(r)}},[i.open,r]),l.jsx(p.Primitive.div,{"data-state":W$(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:b&&o})});function W$(e){return e?"open":"closed"}var pue=hue,vJe=H$,wJe=U$;const vu=pue,wu=H$,Cu=U$;function CJe(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function K$({card:e,preferences:t,boundCurrency:n}){const r=rp({card:e,preferences:t,boundCurrency:n}),o=lue({card:e,preferences:t,boundCurrency:n});return{formatValue:a=>r.format(a),formatSigned:a=>o.formatSigned(a),formatPct:CJe}}const SJe=new Set(["PARTIAL_TIMEOUT","DRIVER_DATA_INSUFFICIENT","UNSUPPORTED_CARD_EXCLUDED","CARD_QUERY_FAILED"]);function $w(e){return e.filter(t=>SJe.has(t))}function G$({partial:e,warnings:t}){return e?t.length===0?!0:$w(t).length>0:!1}const Fj="Summary may be incomplete. Refresh to try again.",NJe={PARTIAL_TIMEOUT:"Summary is partial because generation exceeded the response time budget.",LLM_TIMEOUT_FALLBACK:"Using deterministic summary because narrative generation timed out.",DRIVER_DATA_INSUFFICIENT:"There is not enough breakdown data to compute reliable drivers.",UNSUPPORTED_CARD_EXCLUDED:"Some unsupported chart types were excluded from summary computation.",CARD_QUERY_FAILED:"One or more card summary queries failed; showing available summary results."};function jJe(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function tv(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function KP(e){return NJe[e]||e}function kJe(e){return e.kind==="value_contributor"}function Y$({className:e,message:t=Fj,showLabel:n=!1}){return l.jsxs("span",{title:t,"aria-label":t,className:p.cn("inline-flex items-center gap-1 text-amber-600",n&&"rounded border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700",e),children:[l.jsx(Zs,{className:"h-3.5 w-3.5"}),n&&l.jsx("span",{children:"Summary issue"})]})}function _Je(e){const t=$w(e.metadata.warnings);return t.length===1?KP(t[0]):t.length>1?`Summary has ${t.length} warnings: ${t.map(KP).join(" ")}`:(G$(e.metadata),Fj)}function gue(e,t){if(e==null)return null;const n=t.formatPct(e);return e>0?`+${n}`:n}function Z$(e){return e==="up"?"text-emerald-600 dark:text-emerald-400":e==="down"?"text-rose-600 dark:text-rose-400":"text-foreground"}function bue(e,t){if(e.length===0)return t;const n=e[0].dimension;return e.every(o=>o.dimension===n)&&n?`${t} by ${n}`:t}function xue(e,t){return kJe(e)?`${t.formatValue(e.current)} · ${t.formatPct(e.contributionPct)}`:t.formatSigned(e.delta)}function IJe({data:e,formatter:t}){const n=e.keyChanges[0];if(!n)return e.narrative?l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:e.narrative})]}):null;const r=n.direction==="up";n.direction;const o=Z$(n.direction);if(n.comparison==null)return l.jsx("div",{className:"px-4 py-3",children:l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," is"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","in the current view."]})});if(n.direction==="flat")return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," was unchanged at"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","versus comparison."]})]});const s=r?"rose to":"fell to",i=r?"up":"down",a=n.delta!=null?t.formatSigned(n.delta):null,c=gue(n.deltaPct,t);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," ",s," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)}),a&&l.jsxs(l.Fragment,{children:[", ",i," ",l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:a}),c&&l.jsxs(l.Fragment,{children:[" (",l.jsx("span",{className:p.cn("tabular-nums",o),children:c}),")"]})]})," ","versus comparison."]})]})}function TJe(e,t){if(e.comparison==null)return t.formatValue(e.current);if(e.direction==="flat")return`${t.formatValue(e.current)} · unchanged`;const n=t.formatSigned(e.delta),r=gue(e.deltaPct,t);return r?`${t.formatValue(e.current)} · ${n} (${r})`:`${t.formatValue(e.current)} · ${n}`}function EJe({changes:e,formatter:t}){return e.length<=1?null:l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Metrics"}),l.jsx("ul",{className:"space-y-1",children:e.map(n=>l.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-[12px]",children:[l.jsx("span",{className:"min-w-0 truncate text-foreground",children:n.label}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",Z$(n.direction)),children:TJe(n,t)})]},n.metricId))})]})}function DJe(e,t){if(e==="up")return"Where it grew";if(e==="down")return"Where it declined";const n=t.every(o=>(o.delta??0)>0),r=t.every(o=>(o.delta??0)<0);return n?"Where it grew":r?"Where it declined":"Where it changed"}function MJe({drivers:e,formatter:t,applyAction:n,headlineDirection:r}){const o=e.filter(a=>a.kind==="period_delta_driver"&&a.delta!=null&&Number.isFinite(a.delta)).slice(0,3);if(o.length===0)return null;const s=DJe(r,o),i=bue(o,s);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:i}),l.jsx("ul",{className:"space-y-1",children:o.map(a=>{const c=Z$(a.direction),u=`${tv(a.key)} (${xue(a,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(a.action),"aria-label":u,className:"group/row flex w-full items-baseline justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsx("span",{className:"min-w-0 truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:tv(a.key)}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",c),"aria-hidden":"true",children:t.formatSigned(a.delta)})]})},`${a.metricId}-${a.key}`)})})]})}function RJe({drivers:e,formatter:t,applyAction:n}){const r=e.filter(s=>s.kind==="value_contributor").slice(0,3);if(r.length===0)return null;const o=bue(r,"Top Contributors");return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:o}),l.jsx("ul",{className:"space-y-1",children:r.map((s,i)=>{const a=`${tv(s.key)} (${xue(s,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(s.action),"aria-label":a,className:"group/row flex w-full items-center justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:p.cn("flex size-4 shrink-0 items-center justify-center rounded-[3px] text-[9px] font-semibold tabular-nums",i===0?"bg-foreground text-background":"bg-muted text-muted-foreground"),"aria-hidden":"true",children:i+1}),l.jsx("span",{className:"truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:tv(s.key)})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums","aria-hidden":"true",children:[l.jsx("span",{className:"text-muted-foreground",children:t.formatValue(s.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:t.formatPct(s.contributionPct)})]})]})},`${s.metricId}-${s.key}`)})})]})}function AJe(e){if(e.type!=="apply_filter")return e.label;const[t,n]=e.label.split(":");return n?`${t}: ${tv(n)}`:e.label}function Oj({data:e,applyAction:t,numberFormatter:n,audience:r="dashboard"}){var c;const o=n||{formatSigned:u=>u==null?"n/a":`${u>0?"+":""}${Math.round(u*100)/100}`,formatValue:u=>u==null?"n/a":`${Math.round(u*100)/100}`,formatPct:jJe},s=$w(e.metadata.warnings),i=e.suggestedActions.filter(u=>u.type!=="refresh"&&u.type!=="apply_filter"),a=r==="author"&&s.length>0;return l.jsxs("div",{className:"divide-y divide-border/60",children:[l.jsx(IJe,{data:e,formatter:o}),l.jsx(EJe,{changes:e.keyChanges,formatter:o}),l.jsx(MJe,{drivers:e.drivers,formatter:o,applyAction:t,headlineDirection:(c=e.keyChanges[0])==null?void 0:c.direction}),l.jsx(RJe,{drivers:e.drivers,formatter:o,applyAction:t}),i.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 px-4 py-3",children:i.map(u=>l.jsx(p.Button,{size:"sm",variant:"secondary",className:"h-7 px-2 text-xs",onClick:()=>t(u),children:AJe(u)},u.idempotencyKey))}),a&&l.jsx("div",{className:"px-4 py-3",children:l.jsx("div",{className:"rounded-[4px] bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:s.map(u=>l.jsx("div",{children:KP(u)},u))})})]})}const PJe=new Set(["up","rose","grew","gained","increased","climbed","surged","jumped","rising"]),FJe=new Set(["down","fell","declined","dipped","dropped","lost","decreased","slipped","falling"]),aU=/(\(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?)\))|(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?))|(\d[\d,]*(?:\.\d+)?[KkMmBb]?(?:%)?)/g;function OJe(e){const t=/^(\(?)([+−-]?)(\d[\d,]*)(\.\d+)?([KkMmBb]?)(%?)(\)?)$/.exec(e);if(!t)return e;const[,n,r,o,s,i,a,c]=t;if(i||o.includes(",")||o.length<4)return e;const u=Number(o);if(!Number.isFinite(u))return e;const d=u.toLocaleString("en-US");return`${n}${r}${d}${s??""}${i}${a}${c}`}function LJe(e){const t=[];let n=0,r;for(aU.lastIndex=0;(r=aU.exec(e))!==null;){r.index>n&&t.push({kind:"plain",text:e.slice(n,r.index)});const o=r[0],s=r[2]||r[6],i=OJe(o);s==="+"?t.push({kind:"pos",text:i}):s==="-"||s==="−"?t.push({kind:"neg",text:i}):t.push({kind:"num",text:i}),n=r.index+o.length}return n<e.length&&t.push({kind:"plain",text:e.slice(n)}),t}function $Je(e){return e.map((t,n)=>{if(t.kind!=="num"||!t.text.endsWith("%"))return t;const r=e[n-1];if(!r||r.kind!=="plain")return t;const o=r.text.replace(/\s+$/,"").split(/[\s.,;:!?(]+/).pop();if(!o)return t;const s=o.toLowerCase();return PJe.has(s)?{kind:"pos",text:t.text}:FJe.has(s)?{kind:"neg",text:t.text}:t})}function zJe({narrative:e}){const t=v.useMemo(()=>$Je(LJe(e)),[e]);return l.jsx("div",{className:"px-4 py-3",children:l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:t.map((n,r)=>{if(n.kind==="plain")return l.jsx("span",{children:n.text},r);const o=n.kind==="pos"?"text-emerald-600 dark:text-emerald-400":n.kind==="neg"?"text-rose-600 dark:text-rose-400":"";return l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:n.text},r)})})})}function GP(){var w;const e=p.useDashboardStore(C=>C.dashboard),{preferences:t}=Ta(),n=p.useDashboardStore(C=>C.semanticExecutionPayload),r=p.useDashboardStore(C=>C.isDashboardEditing),o=((w=e==null?void 0:e.summary)==null?void 0:w.position)||"top",{setDashboard:s}=p.useDashboardActions(),{data:i,isLoading:a,isRefreshing:c,enabled:u,applyAction:d,refresh:f}=due(),[h,m]=v.useState(!0),g=v.useMemo(()=>K$({preferences:t}),[t]),b=i?G$(i.metadata)||$w(i.metadata.warnings).length>0:!1,x=i?_Je(i):Fj,y=C=>{e&&o!==C&&s({...e,summary:{...e.summary,position:C}},{semanticExecutionPayload:n})};return u?a&&!i?l.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"}),l.jsx("div",{className:"h-4 w-4/5 animate-pulse rounded bg-muted"})]})}):i?l.jsx("div",{className:"mx-3 mb-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs(vu,{open:h,onOpenChange:m,children:[l.jsxs("div",{className:p.cn("flex items-center justify-between gap-2 px-4",h?"border-b border-border/60 py-2.5":"py-1.5"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(wu,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6","aria-label":h?"Collapse summary":"Expand summary",children:l.jsx(je.ChevronDown,{className:p.cn("h-3.5 w-3.5 transition-transform",!h&&"-rotate-90")})})}),l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),b&&l.jsx(Y$,{message:x,showLabel:!0})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[r&&l.jsx("div",{className:"flex h-6 items-center overflow-hidden rounded-[4px] border border-border/60","aria-label":"Summary position",children:["top","bottom"].map(C=>l.jsx(p.Button,{size:"xs",variant:"ghost",className:p.cn("h-6 rounded-none px-2 text-[11px] capitalize text-muted-foreground hover:text-foreground",o===C&&"bg-muted text-foreground hover:bg-muted"),onClick:()=>y(C),"aria-pressed":o===C,children:C},C))}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>f(),disabled:c,"aria-label":"Refresh summary",children:l.jsx(tc,{className:p.cn("h-3 w-3",c&&"animate-spin")})})]})]}),l.jsx(Cu,{children:i.narrative?l.jsx(zJe,{narrative:i.narrative}):l.jsx(Oj,{data:{narrative:i.narrative,generatedAt:i.generatedAt,keyChanges:i.keyChanges,drivers:i.drivers,suggestedActions:i.suggestedActions,metadata:i.metadata},applyAction:d,audience:"dashboard",numberFormatter:g})})]})}):null:null}function yue({action:e,className:t,description:n,density:r="default",role:o="alert",title:s="This visual can’t be loaded"}){const i=v.useId();return l.jsx("div",{"aria-labelledby":i,className:p.cn("flex h-full min-h-0 w-full items-center justify-center text-center",r==="compact"?"px-0 py-1":"px-6 py-10",t),role:o,children:l.jsxs("div",{className:p.cn("flex flex-col items-center",r==="compact"?"max-w-[280px]":"max-w-[360px]"),children:[l.jsx(p.ChartColumn,{"aria-hidden":"true",className:p.cn("text-muted-foreground",r==="compact"?"mb-1.5 size-4":"mb-3 size-5"),strokeWidth:1.75}),l.jsx("h2",{id:i,className:p.cn("font-medium text-foreground",r==="compact"?"text-[12px]":"text-[14px]"),children:s}),n?l.jsx("p",{className:p.cn("text-muted-foreground",r==="compact"?"mt-0.5 text-[11px] leading-4":"mt-1 text-[12px] leading-5"),children:n}):null,e?l.jsx(p.Button,{className:r==="compact"?"mt-2":"mt-3",onClick:e.onClick,size:"xs",variant:"outline",children:e.label}):null]})})}function zw(e){if(!e||typeof e!="object")return{};const t=e.code,n=e.message;return e.deliveryBlocking!==!0||typeof t!="string"||typeof n!="string"?{}:{"data-semaphor-render-error-code":t,"data-semaphor-render-error-message":n}}function Bw({onRetry:e,density:t="default",showOwnerGuidance:n=!0}){return l.jsx(yue,{action:e?{label:"Try Again",onClick:e}:void 0,density:t,description:n?"Contact the dashboard owner for help resolving this issue.":void 0,role:"status"})}function lU({error:e,resetErrorBoundary:t}){return l.jsx("div",{...zw(e),className:"contents",children:l.jsx(Bw,{onRetry:t})})}const vue=4,BJe=.005,VJe="hsl(var(--semaphor-primary))",HJe="hsl(var(--semaphor-muted-foreground) / 0.35)",SM=[1,.65,.4,.25];function wue(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function qJe(e){return(e||[]).filter(t=>t.kind==="value_contributor"&&Number.isFinite(t.current)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0)}function UJe(e){return(e||[]).filter(t=>t.kind==="period_delta_driver"&&Number.isFinite(t.delta)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0).slice(0,vue).map(t=>({id:`${t.metricId}-${t.key}`,label:wue(t.key),delta:t.delta,contributionPct:t.contributionPct,direction:t.direction,action:t.action}))}function WJe(e,t){const n=e.slice(0,vue);if(n.length===0)return[];const r=t[0]||VJe,o=SM[SM.length-1]??.25,s=n.map((c,u)=>({id:`${c.metricId}-${c.key}`,label:wue(c.key),current:c.current,contributionPct:c.contributionPct,color:r,opacity:SM[u]??o,action:c.action})),i=n.reduce((c,u)=>c+u.contributionPct,0),a=Math.max(0,1-i);return a>=BJe&&s.push({id:"other",label:"Other",current:null,contributionPct:a,color:HJe,opacity:1,action:null}),s}function KJe({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){var Ee,Te,ze,Pe,He,ye,Ke,We,Qe,xe,Ve,Ae;const{setTitle:a,isEditable:c,isVisualEditing:u}=aue(),{setCardDescription:d}=p.useEditorActions(),{getLocale:f}=iue(e),{preferences:h,boundCurrency:m}=W_(e,t),{compiledAppearance:g}=p.useAppearance(),b=(Te=(Ee=e.preferences)==null?void 0:Ee.kpiVisualOptions)==null?void 0:Te.countryLogoId;v.useMemo(()=>sJe.find(ke=>ke.id===b),[b]);const x=e.config,y=x==null?void 0:x.summary,w=((y==null?void 0:y.breakdownDimensions)||[]).length>0,C=(y==null?void 0:y.enabled)===!0&&((y==null?void 0:y.showOnCard)===!0||w),N=!u&&C,S=(x==null?void 0:x.groupByColumns)&&x.groupByColumns.length>0,j=(x==null?void 0:x.metricColumns)||[],_=j[0],k=(_==null?void 0:_.id)||(_==null?void 0:_.name),T=j.some(ke=>p.getMetricComparisonKind(ke)==="target"),I=!S&&j.length>1&&!T,E=C&&!I&&!r,{data:D,isLoading:R,isRefreshing:A,refresh:F,applyAction:z}=B$(e,{enabled:E}),L=v.useMemo(()=>K$({card:e,preferences:h,boundCurrency:m}),[e,m,h]),$=v.useMemo(()=>qJe(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),H=v.useMemo(()=>UJe(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),M=g.chartPalette,B=v.useMemo(()=>rp({card:e,preferences:h,boundCurrency:m}),[e,m,h]),W=v.useMemo(()=>lue({card:e,preferences:h,boundCurrency:m}),[e,m,h]),P=v.useMemo(()=>{if(_)return U5(o,_)},[o,_]),G=P==null?void 0:P.metadata,Z=ke=>B.format(ke),X=ke=>B.formatCompact(ke),Y=ke=>W.format(ke),O=ke=>{const Be=t==null?void 0:t.find($e=>$e.segment===ke||$e.Segment===ke?k?$e.metricId===k||$e.metricId===void 0:!0:!1),Ie=(Be==null?void 0:Be.value)??(Be==null?void 0:Be.Value);if(typeof Ie=="number"&&Number.isFinite(Ie))return Ie;if(typeof Ie=="string"&&Ie.trim()){const $e=Number(Ie);return Number.isFinite($e)?$e:null}return null},q=O("current")??0,U=O("comparison"),V=(P==null?void 0:P.comparisonKind)??p.getMetricComparisonKind(_),K=p.getMetricComparisonPolarity(_),Q=(ze=e.preferences)==null?void 0:ze.comparisonPresentation,se=p.getMetricComparisonTarget(_),oe=typeof q=="number"&&!isNaN(q)?q:0,me=v.useMemo(()=>WJe($,M),[$,M]),le=typeof se=="number"&&!isNaN(se)?se:0,ue=le>0?Math.min(oe/le,1):0,ne=le>0?Math.max(le-oe,0):0,de=le>0?Math.max(oe-le,0):0,Ce=uJe({comparisonKind:V,targetValue:le,presentation:Q}),ce=dJe({comparisonKind:V,comparisonValue:U,targetValue:le}),ie=V==="target"?typeof se=="number"&&Number.isFinite(se):ce!==null,we=V!=="none"&&ie&&(Q==null?void 0:Q.showComparison)!==!1,fe=(He=(Pe=e.preferences)==null?void 0:Pe.formatNumber)==null?void 0:He.colorRanges,ae=$I(q,fe);function ee(){return e.title?e.title:c?"Enter title":""}const J=e.description||(u?"Enter description":"");if(r)return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),(e.description||u)&&l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",value:J,placeholder:u?"Enter description":"",isEditable:u,onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,i]})]}),l.jsx("div",{className:"flex min-h-0 flex-1 px-4 py-3",children:l.jsx(Bw,{density:"compact",showOwnerGuidance:!1})})]})});if(I)return l.jsx(cJe,{card:e,data:t,isPending:n,headerAction:s,headerTrailingAction:i});if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const pe=((ye=e==null?void 0:e.kpiPreferences)==null?void 0:ye.format)==="compact"?X(q):Z(q);return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),N&&l.jsxs(Xm,{openDelay:180,closeDelay:120,children:[l.jsx(Yd,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-4 shrink-0 rounded-[3px] p-0 text-muted-foreground hover:text-foreground","aria-label":"Show summary",children:l.jsx(p.Info,{className:"h-3 w-3"})})}),l.jsxs(bu,{align:"start",className:"ml-2 w-[360px] overflow-hidden p-0",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),D&&(D.metadata.partial||D.metadata.warnings.length>0)&&l.jsx(Y$,{className:"text-amber-500"})]}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>F(),disabled:A,"aria-label":"Refresh summary",children:l.jsx(tc,{className:p.cn("h-3 w-3",A&&"animate-spin")})})]}),R&&!D?l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-5/6 animate-pulse rounded bg-foreground/[0.06]"})]}):D?l.jsx(Oj,{data:{narrative:D.narrative,generatedAt:D.generatedAt,keyChanges:D.keyChanges,drivers:D.drivers,suggestedActions:D.suggestedActions,metadata:D.metadata},applyAction:z,audience:"dashboard",numberFormatter:L}):l.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"Summary is unavailable for this card."})]})]})]}),(e.description||u)&&l.jsx(xi,{isEditable:u,value:J,placeholder:u?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,we&&ce!==null&&l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx("div",{className:"shrink-0 cursor-help [&_.inline-flex]:h-[18px] [&_.inline-flex]:gap-1 [&_.inline-flex]:px-1.5 [&_.inline-flex]:py-0 [&_.inline-flex]:text-[11px] [&_.inline-flex]:font-medium",children:l.jsx(u3,{primaryValue:q,secondaryValue:ce,presentation:Q,metricFormatOptions:(We=(Ke=e.preferences)==null?void 0:Ke.kpiVisualOptions)==null?void 0:We.formatOptions,locale:f()||"en-US",decimalPlaces:(xe=(Qe=e.preferences)==null?void 0:Qe.formatNumber)==null?void 0:xe.decimalPlaces,suffix:(Ae=(Ve=e.preferences)==null?void 0:Ve.formatNumber)==null?void 0:Ae.suffix,polarity:K,signedValueFormatter:B.formatSigned,allowSignedValueFormatter:B.supportsComparisonDeltaInheritance})})}),l.jsx(oJe,{currentValue:q,comparisonValue:ce,comparisonKind:V,sentiment:$r.evaluateMetricComparison({currentValue:q,comparisonValue:ce,polarity:K}).sentiment,data:t,comparisonMetadata:G,formatCurrency:Z,conditionalLabel:(()=>{if(Q!=null&&Q.conditionalLabel){const{conditionalLabels:ke}=Q,Be=q-ce;return Be>0?(ke==null?void 0:ke.increase)||"Increase":Be<0?(ke==null?void 0:ke.decrease)||"Decrease":(ke==null?void 0:ke.neutral)||"No change"}})()})]}),i]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:ae?{color:ae}:void 0,children:pe}),we&&ce!==null&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[V==="target"?(Q==null?void 0:Q.labelName)||"Target":(Q==null?void 0:Q.labelName)||"Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:Z(ce)})]})]}),Ce&&l.jsxs("div",{className:"space-y-1.5 border-t border-border/60 px-4 py-2.5",children:[l.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(Math.round(ue*100),100)}%`,backgroundColor:ae||void 0}})}),l.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:[l.jsx("span",{children:oe>=le?de>0?`${Y(de)} above target`:"Target reached":`${Y(ne)} remaining`}),l.jsxs("span",{className:"tabular-nums",children:[Math.round(ue*100),"%"]})]})]}),C&&R&&!D&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-2.5","data-testid":"kpi-composition-loading","aria-hidden":"true",children:[l.jsxs("div",{className:"flex h-1 w-full gap-px overflow-hidden rounded-[2px]",children:[l.jsx("div",{className:"h-full w-[40%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[26%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[16%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full flex-1 animate-pulse bg-foreground/[0.06]"})]}),l.jsx("ul",{className:"space-y-1",children:["58%","44%","36%"].map((ke,Be)=>l.jsxs("li",{className:"flex items-center justify-between gap-3",children:[l.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 animate-pulse rounded-[2px] bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 animate-pulse rounded bg-foreground/[0.06]",style:{width:ke}})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2",children:[l.jsx("span",{className:"h-2.5 w-7 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 w-10 animate-pulse rounded bg-foreground/[0.06]"})]})]},`composition-skeleton-${Be}`))})]}),C&&me.length>0&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-3",children:[l.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-[2px]",children:me.map(ke=>l.jsx("div",{"data-testid":"kpi-composition-segment",className:"h-full",style:{width:`${Math.max(ke.contributionPct*100,2)}%`,backgroundColor:ke.color,opacity:ke.opacity}},ke.id))}),l.jsx("ul",{className:"space-y-1",children:me.map(ke=>{const Be=l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 rounded-[2px]",style:{backgroundColor:ke.color,opacity:ke.opacity}}),l.jsx("span",{className:p.cn("truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",ke.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:ke.label})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[ke.current!=null&&l.jsx("span",{className:"text-muted-foreground",children:L.formatValue(ke.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:L.formatPct(ke.contributionPct)})]})]});return l.jsx("li",{children:ke.action?l.jsx("button",{type:"button",onClick:()=>z(ke.action),"aria-label":`Filter to ${ke.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:Be}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:Be})},`${ke.id}-legend`)})})]}),C&&me.length===0&&H.length>0&&l.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:l.jsx("ul",{className:"space-y-1",children:H.map(ke=>{const Be=ke.direction==="up"?"text-emerald-600 dark:text-emerald-400":ke.direction==="down"?"text-rose-600 dark:text-rose-400":"text-foreground",Ie=l.jsxs(l.Fragment,{children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",ke.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:ke.label}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[l.jsx("span",{className:p.cn("font-medium",Be),children:L.formatSigned(ke.delta)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:L.formatPct(ke.contributionPct)})]})]});return l.jsx("li",{"data-testid":"kpi-period-driver-row",children:ke.action?l.jsx("button",{type:"button",onClick:()=>z(ke.action),"aria-label":`Filter to ${ke.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:Ie}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:Ie})},`${ke.id}-driver`)})})})]})})}function GJe({card:e,data:t,isPending:n,isError:r,headerAction:o,headerTrailingAction:s}){var A,F,z,L;const i=p.useDashboardStore($=>$.isVisualEditing),a=p.useEditorStore($=>$.card),c=p.useEditorStore($=>$.actions.setCard);p.useEditorStore($=>$.actions.setNumberFormat);const u=(F=(A=e.preferences)==null?void 0:A.formatNumber)==null?void 0:F.colorRanges,d=$=>{if(typeof $=="number")return Number.isFinite($)?$:null;if(typeof $=="string"){const H=$.trim();if(!H)return null;const M=Number(H.replace(/,/g,""));return Number.isFinite(M)?M:null}return null},f=(t==null?void 0:t[0])??{},h=mw(t),m=h[0],g=h[1],{preferences:b,boundCurrency:x}=W_(e,t),y=rp({card:e,preferences:b,boundCurrency:x}),w=m!==void 0?d(f[m]):null,C=g!==void 0?d(f[g]):null,N=Array.isArray(t)&&t.length>0,S=t==null?void 0:t.some($=>Object.values($).some(H=>H!=null)),j=N&&w!==null,_=N&&S?"KPI needs a numeric metric. Add a numeric field or aggregation.":"No data available for this KPI.";function k($){i&&c({...a,title:$})}function T($){i&&c({...a,description:$})}const I=w!==null&&C!==null&&C!==0?(w-C)/C:null,E=w!==null?y.format(w):"--";let D="";C!==null&&(D=y.format(C));const R=$I(w??0,u);return l.jsx(YJe,{isPending:n,isError:r,title:e.title,formattedCurrentValue:E,formattedPreviousValue:D,description:e.description,valueColor:R,onTitleChange:k,onDescriptionChange:T,percentDifference:I,polarity:((L=(z=e.preferences)==null?void 0:z.kpiVisualOptions)==null?void 0:L.queryComparisonPolarity)??$r.DEFAULT_METRIC_COMPARISON_POLARITY,show:j,emptyStateMessage:_,headerAction:o,headerTrailingAction:s})}function tf({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){return!Wre(e)&&dt.hasValidCardConfig(e.config)?l.jsx("div",{className:"flex h-full min-h-0 grow overflow-auto",children:l.jsx(KJe,{card:e,data:t||[],isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i})}):l.jsx(GJe,{card:e,data:t,isPending:n,isError:r,headerAction:s,headerTrailingAction:i})}function YJe({title:e,formattedCurrentValue:t,formattedPreviousValue:n,description:r,valueColor:o,onTitleChange:s,onDescriptionChange:i,percentDifference:a,show:c,emptyStateMessage:u,isPending:d,isError:f,polarity:h,headerAction:m,headerTrailingAction:g}){const b=p.useDashboardStore(C=>C.isVisualEditing),x=p.useEditorStore(C=>C.card),y=r??"",w=y||(b?"Enter description":"");return l.jsxs("div",{className:"kpi-card flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Pj,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",containerClassName:"min-w-0",enabled:b,text:b?x.title:e,onSave:s,children:l.jsx(cb,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})}),(y||b)&&l.jsx(Pj,{className:"min-w-0 truncate text-[11px] text-muted-foreground/80",containerClassName:"min-w-0",enabled:b,text:w,placeholder:b?"Enter description":"",onSave:i,children:l.jsx("span",{className:"block min-w-0 truncate text-[11px] text-muted-foreground/80",children:w})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[m,a!=null&&a!==0&&!f&&!d&&l.jsx(Cue,{polarity:h,children:a}),g]})]}),l.jsx("div",{className:"flex flex-1 flex-col justify-between gap-2 px-4 py-3",children:f?l.jsx(Bw,{density:"compact",showOwnerGuidance:!1}):d?l.jsxs("div",{className:"space-y-2",children:[l.jsx(Xs,{className:"h-7 w-32 bg-foreground/[0.06]"}),l.jsx(Xs,{className:"h-3 w-24 bg-foreground/[0.06]"})]}):c?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:o?{color:o}:void 0,children:t}),n&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:n})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:u})})]})}function Cue({children:e,className:t,polarity:n}){const r=e>0,o=n==="lower_is_better"?!r:n==="higher_is_better"?r:null,s=r?bs:es,i=`${Math.abs(e*100).toFixed(0)}%`;return l.jsxs("span",{className:p.cn("inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[4px] px-1.5 text-[11px] font-medium tabular-nums",o===!0?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":o===!1?"bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300":"bg-gray-50 text-gray-700 dark:bg-gray-900 dark:text-gray-400",t),children:[l.jsx(s,{className:"h-3 w-3"}),i]})}function Vw({customerFacingMessage:e,error:t,resetErrorBoundary:n}){return l.jsxs("div",{...zw(t),className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[l.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:l.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),l.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),l.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||"Couldn't display this chart right now. Please try refreshing or check your data configuration."}),l.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[l.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),l.jsxs("details",{className:"mt-4 w-full text-left",children:[l.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground hover:text-foreground",children:"Show technical details"}),l.jsxs("div",{className:"mt-2 rounded border bg-background p-3",children:[l.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"Error Details:"}),l.jsx("pre",{className:"text-xs text-muted-foreground",children:t.message})]})]})]})}function BI({error:e}){return l.jsx("div",{...zw(e),className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:l.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[l.jsx("p",{className:"text-sm",children:"Something went wrong:"}),l.jsx("pre",{className:"text-xs",children:e.message})]})})}function ZJe({error:e,frame:t}){return l.jsxs("div",{...zw(e),className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[l.jsx(ZP,{frame:t,isHovered:!1}),l.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),l.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[l.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),l.jsx("p",{className:"text-sm",children:"Something went wrong:"}),l.jsx("pre",{className:"text-xs",children:e.message})]})]})}function XJe(e={},t){const{displayPreferences:n,shouldShowElement:r}=cl(),o=mf(n.mode),s=e.enabled??!0,i=e.serverSide??!1,a=o?Number.MAX_SAFE_INTEGER:e.pageSize||50,c=e.currentPage!==void 0,[u,d]=v.useState(0),[f,h]=v.useState(a),m=c?(e.currentPage||1)-1:u,g=o?Number.MAX_SAFE_INTEGER:c?e.pageSize||a:f,b=v.useMemo(()=>s&&r("showPagination")&&!o,[s,r,o]),x=v.useMemo(()=>i?e.pageCount:Math.ceil(t/g),[i,e.pageCount,t,g]),y=v.useMemo(()=>i?e.totalCount||0:t,[i,e.totalCount,t]),w=v.useMemo(()=>i?(e.currentPage||1)>1:m>0,[i,e.currentPage,m]),C=v.useMemo(()=>i?(e.currentPage||1)<(e.pageCount||1):m<(x||1)-1,[i,e.currentPage,e.pageCount,m,x]);return{pageIndex:m,pageSize:g,isServerSidePagination:i,showPagination:b,paginationEnabled:s,isTablePrintDisplayMode:o,setPageIndex:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},setPageSize:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,1,k):(d(0),h(k))},canPreviousPage:w,canNextPage:C,previousPage:()=>{var T;if(!w)return;const k=m-1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},nextPage:()=>{var T;if(!C)return;const k=m+1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},pageCount:x,totalCount:y}}function QJe(e,t){const n=e.subtotalLevel,r=K_(t.groupByColumns,n);if(r<0)throw new Error(`invalid_pivot_subtotal_identity: Subtotal level "${n||""}" does not match a configured row-axis field.`);return r}function JJe(e,t,n){var c;if(!t.length)return e;const r=t[0].id,o=t[0].desc?-1:1,s=((c=n.groupByColumns)==null?void 0:c.length)||0,i=r.startsWith("rowLevel"),a=i?parseInt(r.replace("rowLevel","")):-1;return i?eet(e,a,o):tet(e,r,o,s,n)}function eet(e,t,n){const r=[...e],o=new Map,s=[];r.forEach(c=>{if(c.isGrandTotal)return;const u=t>0?JSON.stringify((c.canonicalFieldValues||c.fieldValues).slice(0,t)):"root";o.has(u)||(o.set(u,[]),s.push(u)),o.get(u).push(c)});const i=[];s.forEach(c=>{const u=o.get(c),d=u.filter(h=>!h.isSubtotal),f=u.filter(h=>h.isSubtotal);d.sort((h,m)=>{const g=ws(h,t),b=ws(m,t);return g===b?0:g==null?1:b==null?-1:String(g).localeCompare(String(b))*n}),i.push(...d),i.push(...f)});const a=e.find(c=>c.isGrandTotal);return a&&i.push(a),i}function tet(e,t,n,r,o){const s={rows:[],children:new Map};let i;e.forEach(f=>{if(f.isGrandTotal){i=f;return}const h=f.isSubtotal?QJe(f,o)+1:r;let m=s;for(let g=0;g<h;g++){const b=JSON.stringify(ws(f,g));m.children.has(b)||m.children.set(b,{rows:[],children:new Map}),m=m.children.get(b)}f.isSubtotal?m.subtotal=f:m.rows.push(f)});function a(f){var h;return t==="rowTotal"?o.columnHeaders.reduce((m,g)=>{var x;const b=(x=f.cells[g])==null?void 0:x.value;return m+(typeof b=="number"?b:0)},0):(h=f.cells[t])==null?void 0:h.value}function c(f){let h=0;return f.rows.forEach(m=>{const g=a(m);typeof g=="number"&&(h+=g)}),f.children.forEach(m=>{if(m.subtotal){const g=a(m.subtotal);typeof g=="number"&&(h+=g)}else h+=c(m)}),h}function u(f){const h=[],m=[...f.rows].sort((b,x)=>{const y=a(b),w=a(x);return y===w?0:y==null?1:w==null?-1:y>w?n:-n});return h.push(...m),Array.from(f.children.entries()).sort(([,b],[,x])=>{const y=b.subtotal?a(b.subtotal):c(b),w=x.subtotal?a(x.subtotal):c(x);return y===w?0:y==null?1:w==null?-1:y>w?n:-n}).forEach(([,b])=>{h.push(...u(b))}),f.subtotal&&h.push(f.subtotal),h}const d=u(s);return i&&d.push(i),d}function net(e,t){const[n,r]=v.useState([]),o=v.useMemo(()=>JJe(e,n,t),[e,n,t]),s=v.useCallback(c=>{r(u=>{const d=u.find(f=>f.id===c);return d?d.desc?[]:[{id:c,desc:!0}]:[{id:c,desc:!1}]})},[]),i=v.useCallback(()=>{r([])},[]),a=v.useCallback(c=>{const u=n.find(d=>d.id===c);return u?u.desc?"desc":"asc":!1},[n]);return{sorting:n,setSorting:r,sortedTableData:o,toggleColumnSort:s,clearSorting:i,getSortDirection:a}}function NM({columnName:e,groupByFields:t,pivotByFields:n,currentAggregation:r,onAggregationChange:o,onOpenChange:s}){const i=[{value:"SUM",label:"Sum"},{value:"MAX",label:"Max"},{value:"MIN",label:"Min"},{value:"AVG",label:"Avg"},{value:"MEDIAN",label:"Median"}],a=(u,d,f)=>{o({function:u,rowLevel:d,columnLevel:f})},c=(u,d,f)=>{if(!r)return!1;if(d!==void 0&&f===void 0){if(r.rowAggregates){const h=d==="all"?"ALL":d;return r.rowAggregates.some(m=>m.function===u&&m.groupLevel===h)}return!1}if(f!==void 0&&d===void 0){if(r.columnAggregates){const h=f==="all"?"ALL":f;return r.columnAggregates.some(m=>m.function===u&&m.pivotLevel===h)}return!1}return!1};return l.jsxs(Uo,{modal:!1,onOpenChange:s,children:[l.jsx(Wo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 hover:bg-accent hover:text-accent-foreground",children:l.jsx(Rm,{className:"size-3"})})}),l.jsxs(Do,{align:"start",className:"w-56",children:[l.jsx(qa,{className:"text-xs font-normal text-muted-foreground",children:"AGGREGATE"}),i.map(u=>{var m,g;const d=((m=r==null?void 0:r.rowAggregates)==null?void 0:m.some(b=>b.function===u.value))||!1,f=((g=r==null?void 0:r.columnAggregates)==null?void 0:g.some(b=>b.function===u.value))||!1,h=d||f;return l.jsxs(qO,{children:[l.jsx(Lk,{className:"text-xs",children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:u.label}),h&&l.jsxs("div",{className:"ml-2 flex items-center gap-1 text-xs",children:[d&&l.jsx("span",{className:"rounded bg-blue-100 px-1 py-0.5 text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"R"}),f&&l.jsx("span",{className:"rounded bg-green-100 px-1 py-0.5 text-green-700 dark:bg-green-900 dark:text-green-300",children:"C"})]})]})}),l.jsxs($k,{className:"w-48",children:[l.jsx(qa,{className:"text-xs font-normal text-muted-foreground",children:"ROWS"}),l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all rows"}),c(u.value,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),t.map(b=>l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,b.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",b.label||b.name]}),c(u.value,b.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},b.id)),n.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Sa,{}),l.jsx(qa,{className:"text-xs font-normal text-muted-foreground",children:"COLUMNS"}),l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,void 0,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all columns"}),c(u.value,void 0,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),n.map(b=>l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,void 0,b.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",b.label||b.name]}),c(u.value,void 0,b.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},b.id))]})]})]},`${u.value}-${u.label}`)})]})]})}function Lj(e,t,n,r,o=!1){if(t){const s=M_(e,t,n,r,o),i=typeof e=="object"&&e!==null&&"value"in e?e.value:e,a=UEe(i,t);return s==="-"||s===0?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):a?l.jsx("span",{style:{backgroundColor:a.backgroundColor,color:a.color,padding:"0.125rem 0.25rem",borderRadius:"0.25rem"},children:s}):s}return typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0?e.formattedValue==="-"||e.formattedValue===0?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):e.formattedValue:typeof e=="number"?e===0||e===null?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):e.toLocaleString():e==null?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):(e==null?void 0:e.toString())||l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})})}function ret(e){return(e==null?void 0:e.includes("__subtotal__"))||(e==null?void 0:e.includes("_SUM_"))||(e==null?void 0:e.includes("_AVG_"))||(e==null?void 0:e.includes("_COUNT_"))||(e==null?void 0:e.includes("_MIN_"))||(e==null?void 0:e.includes("_MAX_"))}function oet(e,t){const n=(e==null?void 0:e.includes("__subtotal__"))&&(e==null?void 0:e.includes("__ALL__"))||(e==null?void 0:e.includes("_SUM_ALL"))||(e==null?void 0:e.includes("_AVG_ALL"))||(e==null?void 0:e.includes("_COUNT_ALL"))||(e==null?void 0:e.includes("_MIN_ALL"))||(e==null?void 0:e.includes("_MAX_ALL")),r=(t==null?void 0:t.some(o=>o.columnName===e&&(o.subtotalScope==="grand-total"||o.subtotalLevel==="grandTotal"||o.subtotalLevel==="ALL")))??!1;return n||r}function set({data:e,card:t,table:n,sorting:r,setSorting:o,showRowTotals:s,onAggregationChange:i,onOpenColumnSettings:a,suppressSortControls:c=!1,tableAppearance:u}){const[,d]=v.useState(null),f=p.useDashboardStore(g=>g.isVisualEditing),h=v.useCallback(g=>{var b;return(b=n.getHeaderGroups()[0])==null?void 0:b.headers.find(x=>x.column.id===g)},[n]);return{buildColumnHeaderRows:v.useCallback(()=>{var k,T;const g=((k=t.config)==null?void 0:k.pivotByColumns)||[],b=g.length,x=((T=e.groupByColumns)==null?void 0:T.length)||1,y=e.columnHeaders.length;function w(I,E,D,R=[]){I.forEach((A,F)=>{const z=A.level;if(z<b){const L=A.columnKey||`${z}-${R.join("-")}-${A.name}-${F}`,$=A.children?1:b-z;if(D[z].push(l.jsx(mo,{colSpan:A.colspan,rowSpan:$,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 px-3 py-1.5 text-center text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,z===0?"bg-muted/95":"bg-muted/90"),children:l.jsx("div",{className:"flex items-center justify-center",children:l.jsx("span",{className:"whitespace-nowrap",children:A.name})})},L)),A.children){const H=[...R,A.name];w(A.children,z+1,D,H)}}})}function C(I,E=[]){const D=[];return I.forEach((R,A)=>{var F,z,L,$,H,M,B,W;if(R.columnKey){const P=R.columnKey||`metric-${E.join("-")}-${R.name}-${A}`,G=ret(R.columnKey),Z=oet(R.columnKey,e.columnSubtotalMeta),X=n.getColumn(R.columnKey),Y=h(R.columnKey);D.push(l.jsx(mo,{"data-column-id":R.columnKey,className:p.cn("group/header h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,Z?"bg-muted/95 font-semibold":G?"bg-muted/90 font-medium":""),style:{...u.headerCellStyle,width:Y==null?void 0:Y.getSize(),minWidth:Y==null?void 0:Y.getSize(),maxWidth:Y==null?void 0:Y.getSize(),position:"relative",transition:"none"},children:X?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:(($=e.columnDisplayNames)==null?void 0:$[R.columnKey])||R.name||"Metric",children:((H=e.columnDisplayNames)==null?void 0:H[R.columnKey])||R.name||"Metric"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const O=X.getIsSorted();o(O?O==="asc"?[{id:X.id,desc:!0}]:[]:[{id:X.id,desc:!1}])},"aria-label":`Sort ${((F=e.columnDisplayNames)==null?void 0:F[R.columnKey])||R.name||"Metric"}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((z=e.columnDisplayNames)==null?void 0:z[R.columnKey])||R.name||"Metric",children:((L=e.columnDisplayNames)==null?void 0:L[R.columnKey])||R.name||"Metric"}),l.jsx(bs,{className:p.cn("h-3 w-3",X.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3",X.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(Y!=null&&Y.column.getIsResizing())&&l.jsxs(Uo,{modal:!1,children:[l.jsx(Wo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((M=e.columnDisplayNames)==null?void 0:M[R.columnKey])||R.name||"Metric"} column`,className:"h-5 w-5 shrink-0 p-0",onClick:O=>O.stopPropagation(),children:l.jsx(Ci,{className:"h-3 w-3"})})}),l.jsxs(Do,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:X.id,desc:!1}]),children:[l.jsx(bs,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:X.id,desc:!0}]),children:[l.jsx(es,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Sa,{})]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>a(R.columnKey),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),Y&&f&&l.jsx(nh,{header:Y,isResizing:Y.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((B=e.columnDisplayNames)==null?void 0:B[R.columnKey])||R.name||"Metric",children:((W=e.columnDisplayNames)==null?void 0:W[R.columnKey])||R.name||"Metric"})},P))}else if(R.children){const P=[...E,R.name];D.push(...C(R.children,P))}}),D}const N=l.jsxs(Ar,{"data-header-type":"pivot-hierarchy","data-header-row-index":"0","data-repeat-header":"true",children:[e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((I,E)=>{var F,z,L,$,H;const D=(F=n.getHeaderGroups()[0])==null?void 0:F.headers.find(M=>M.column.id===`rowLevel${E}`),R=D==null?void 0:D.getSize(),A=`row-header-${E}`;return l.jsx(mo,{rowSpan:b+2,"data-column-id":`rowLevel${E}`,className:p.cn("group/rowheader h-8 whitespace-nowrap border-b border-r border-border/40 bg-muted/95 px-3 py-1.5 text-left align-bottom text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:R,minWidth:R,maxWidth:R,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex h-full min-w-0 items-end justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(NM,{columnName:I.label||I.name,groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(z=t.config)==null?void 0:z.rowAggregates,columnAggregates:(L=t.config)==null?void 0:L.columnAggregates},onAggregationChange:i,onOpenChange:M=>d(M?A:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:M=>{M.stopPropagation(),M.preventDefault(),o(B=>{const W=B.find(P=>P.id===`rowLevel${E}`);return W?W.desc?[]:[{id:`rowLevel${E}`,desc:!0}]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name}),l.jsx(bs,{className:p.cn("h-3 w-3 flex-shrink-0",(($=r.find(M=>M.id===`rowLevel${E}`))==null?void 0:$.desc)===!1?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3 flex-shrink-0",((H=r.find(M=>M.id===`rowLevel${E}`))==null?void 0:H.desc)===!0?"block":"hidden")})]})]}),D&&f&&l.jsx(nh,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-corner-${E}`)}):l.jsx(mo,{colSpan:x,rowSpan:b+2,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:""}),l.jsx(mo,{colSpan:y,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:l.jsxs("div",{className:"group/pivot-main relative flex items-center",children:[i&&(()=>{var E,D;const I="pivot-main";return l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(NM,{columnName:"Pivot Columns",groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(E=t.config)==null?void 0:E.rowAggregates,columnAggregates:(D=t.config)==null?void 0:D.columnAggregates},onAggregationChange:i,onOpenChange:R=>d(R?I:null)})})})(),l.jsx("div",{className:p.cn("transition-all duration-200",i&&"pl-7"),children:g.map((I,E)=>l.jsxs("span",{className:"inline-flex items-center",children:[I.label,E<g.length-1&&l.jsx(Ft.ChevronRight,{className:"mx-1 inline-block h-4 w-4 text-muted-foreground"})]},I.id))})]})},"pivot-hierarchy"),s&&(()=>{var D;const I=(D=n.getHeaderGroups()[0])==null?void 0:D.headers.find(R=>R.column.id==="rowTotal"),E=I==null?void 0:I.getSize();return l.jsx(mo,{"data-column-id":"rowTotal",className:p.cn("group/total h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-center text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),rowSpan:b+2,style:{...u.headerCellStyle,width:E,minWidth:E,maxWidth:E,position:"relative",transition:"none"},children:(()=>{const R=n.getColumn("rowTotal");return R?l.jsxs("div",{className:"flex w-full items-center justify-end",children:[c?l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const A=R.getIsSorted();o(A?A==="asc"?[{id:R.id,desc:!0}]:[]:[{id:R.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}),l.jsx(bs,{className:p.cn("h-3 w-3",R.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3",R.getIsSorted()==="desc"?"block":"hidden")})]}),I&&f&&l.jsx(nh,{header:I,isResizing:I.column.getIsResizing()})]}):"Total"})()},"pivot-hierarchy-total")})()]},"pivot-hierarchy"),S=[];if(e.columnGroups&&e.columnGroups.length>0){const I=Array.from({length:b},()=>[]);w(e.columnGroups,0,I,[]);for(let E=0;E<b;E++)S.push(l.jsx(Ar,{"data-header-type":"pivot-values","data-header-row-index":E+1,"data-repeat-header":"true",children:I[E]},`pivot-row-${E}`))}let j=[];e.columnGroups&&e.columnGroups.length>0?j=C(e.columnGroups,[]):e.columnHeaders.forEach(I=>{var R,A,F,z,L,$,H,M,B;const E=n.getColumn(I),D=(R=n.getHeaderGroups()[0])==null?void 0:R.headers.find(W=>W.column.id===I);j.push(l.jsx(mo,{"data-column-id":I,className:p.cn("group/colheader h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:D==null?void 0:D.getSize(),minWidth:D==null?void 0:D.getSize(),maxWidth:D==null?void 0:D.getSize(),position:"relative",transition:"none"},children:E?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((L=e.columnDisplayNames)==null?void 0:L[I])||I,children:(($=e.columnDisplayNames)==null?void 0:$[I])||I}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const W=E.getIsSorted();o(W?W==="asc"?[{id:E.id,desc:!0}]:[]:[{id:E.id,desc:!1}])},"aria-label":`Sort ${((A=e.columnDisplayNames)==null?void 0:A[I])||I}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((F=e.columnDisplayNames)==null?void 0:F[I])||I,children:((z=e.columnDisplayNames)==null?void 0:z[I])||I}),l.jsx(bs,{className:p.cn("h-3 w-3",E.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3",E.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(D!=null&&D.column.getIsResizing())&&l.jsxs(Uo,{modal:!1,children:[l.jsx(Wo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((H=e.columnDisplayNames)==null?void 0:H[I])||I} column`,className:"h-5 w-5 shrink-0 p-0",onClick:W=>W.stopPropagation(),children:l.jsx(Ci,{className:"h-3 w-3"})})}),l.jsxs(Do,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!1}]),children:[l.jsx(bs,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!0}]),children:[l.jsx(es,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Sa,{})]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>a(I),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),D&&f&&l.jsx(nh,{header:D,isResizing:D.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((M=e.columnDisplayNames)==null?void 0:M[I])||I,children:((B=e.columnDisplayNames)==null?void 0:B[I])||I})},I))});const _=l.jsxs(Ar,{"data-header-type":"metrics","data-header-row-index":b>0?b+1:0,"data-repeat-header":"true",children:[b===0&&(e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((I,E)=>{var F,z,L,$;const D=(F=n.getHeaderGroups()[0])==null?void 0:F.headers.find(H=>H.column.id===`rowLevel${E}`),R=D==null?void 0:D.getSize(),A=`metric-row-${E}`;return l.jsx(mo,{"data-column-id":`rowLevel${E}`,className:p.cn("group/metricrow h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:R,minWidth:R,maxWidth:R,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(NM,{columnName:I.label||I.name,groupByFields:e.groupByColumns||[],pivotByFields:((z=t.config)==null?void 0:z.pivotByColumns)||[],currentAggregation:{rowAggregates:(L=t.config)==null?void 0:L.rowAggregates,columnAggregates:($=t.config)==null?void 0:$.columnAggregates},onAggregationChange:i,onOpenChange:H=>d(H?A:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:()=>{o(H=>{const M=H.find(B=>B.id===`rowLevel${E}`);return M?M.desc===!1?[{id:`rowLevel${E}`,desc:!0}]:[]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name}),(()=>{const H=r.find(M=>M.id===`rowLevel${E}`);return l.jsxs(l.Fragment,{children:[l.jsx(es,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!0?"block":"hidden")}),l.jsx(bs,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!1?"block":"hidden")})]})})()]})]}),D&&f&&l.jsx(nh,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-title-${E}`)}):Array.from({length:x}).map((I,E)=>l.jsx(mo,{style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:`Level ${E+1}`},`empty-header-metric-${E}`))),j]},"metric-row");return b>0?[N,...S,_]:[_]},[e,t,n,r,o,s,i,h,d,f,a,c,u])}}function iet(e,t,n){var k,T;const r=p.useDashboardStore(I=>I.isVisualEditing);p.useDashboardStore(I=>I.isDashboardEditing),p.useDashboardStore(I=>I.selectedSheetId);const{updateCurrentDashboardCard:o,updateFrame:s}=p.useDashboardActions(),i=p.useEditorStore(I=>{var E;return(E=I.actions)==null?void 0:E.setCardPreferences}),a=p.useEditorStore(I=>I.card),c=((T=(k=e==null?void 0:e.preferences)==null?void 0:k.tablePrefs)==null?void 0:T.columnSettingsMap)??p.EMPTY_COLUMN_SETTINGS,u=v.useMemo(()=>nc(c),[c]),[d,f]=v.useState(!1),[h,m]=v.useState(null),[g,b]=v.useState(To()),[x,y]=v.useState(!1),w=v.useRef(To()),C=v.useCallback(I=>{var D,R;m(I);let E=u[I];if(!E){const A=t==null?void 0:t.map(F=>{var z,L;return{[I]:(L=(z=F.cells)==null?void 0:z[I])==null?void 0:L.value}});E=A&&A.length>0?O0(I,A,n):To()}E=Bi({card:e,columnId:I,resolvedSettings:E,metricId:(D=n==null?void 0:n[I])==null?void 0:D.metricId,metricAlias:(R=n==null?void 0:n[I])==null?void 0:R.metricAlias,preserveOmittedProperties:!0})||E,w.current=E,b(E),y(!1),f(!0)},[e,u,t,n]),N=v.useCallback(()=>{var I,E;if(h&&g){const D=L5({persisted:c,columnId:h,baseline:w.current,next:g,reset:x});if(r&&i){const R={...a.preferences,tablePrefs:{...(I=a.preferences)==null?void 0:I.tablePrefs,columnSettingsMap:D}};i(R)}else if(o){const R={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:D}}};o(R)}}f(!1)},[h,g,x,c,r,i,a,o,e]),S=v.useCallback(()=>{h&&(b(To()),y(!0))},[h]),j=v.useCallback(I=>{y(!1),b(I)},[]),_=v.useCallback(()=>{var I,E;if(r&&i){const D={...a.preferences,tablePrefs:{...(I=a.preferences)==null?void 0:I.tablePrefs,columnSettingsMap:{}}};i(D)}else if(o){const D={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:{}}}};o(D)}f(!1)},[r,i,a,o,e]);return{columnSettings:u,columnSettingsOpen:d,activeColumnId:h,tempColumnSettings:g,isVisualEditing:r,openColumnSettings:C,applyColumnSettings:N,resetColumnSettings:S,resetAllColumnSettings:_,setColumnSettingsOpen:f,setTempColumnSettings:j}}function aet({table:e,data:t,columns:n,subtotalColumnKeys:r,grandTotalColumnKeys:o,isTablePrintDisplayMode:s=!1,shouldVirtualizeRows:i=!1,virtualRows:a,paddingTop:c=0,paddingBottom:u=0,measureElement:d,disableRowTransitions:f=!1,suppressEmptyState:h=!1,tableAppearance:m}){var C;const g=e.getRowModel().rows,b=((C=t.groupByColumns)==null?void 0:C.length)||1,y=i&&a&&a.length>0?a:g,w=n.length||1;return g!=null&&g.length?l.jsxs(l.Fragment,{children:[i&&c>0&&l.jsx(Ar,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(qn,{colSpan:w,style:{height:c,padding:0,border:"none"}})}),y.map((N,S)=>{const j=i?N.index:S,_=i?g[j]:N;if(!_)return null;const k=_.original,T=e.getRowModel().rows,I=j===T.length-1;return l.jsx(Ar,{ref:i&&d?E=>d(E):void 0,style:k.isSubtotal?m.subtotalRowStyle:m.getDataRowStyle(j),className:p.cn("border-border/40",(f||m.hasHoverRowStyle)&&"!transition-none",!f&&!m.hasHoverRowStyle&&"transition-colors duration-150",!k.isSubtotal&&m.dataRowClassName,k.isSubtotal?"border-t border-t-border/50 bg-muted/70 font-medium":"hover:bg-muted/40"),"data-row-type":k.isSubtotal?"subtotal":"data","data-row-index":j,...k.isSubtotal&&{"data-subtotal-level":k.subtotalLevel},children:_.getVisibleCells().map(E=>{const D=E.column.id;if(D.startsWith("rowLevel")){const F=parseInt(D.replace("rowLevel",""));if(k.isSubtotal&&k.subtotalLevel){const L=K_(t.groupByColumns,k.subtotalLevel);return F===L?l.jsx(qn,{colSpan:s?1:b-F,...Cd({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!I&&"border-b border-b-border/35")}),children:gi(E.column.columnDef.cell,E.getContext())},E.id):F<L?l.jsx(qn,{...Cd({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!I&&"border-b border-b-border/35")}),children:gi(E.column.columnDef.cell,E.getContext())},E.id):s?l.jsx(qn,{...Cd({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!I&&"border-b border-b-border/35")})},E.id):null}if(!i&&!s&&j>0)for(let L=j-1;L>=0;L--){const $=T[L].original;if($.isSubtotal||$.isGrandTotal)break;let H=!0;for(let M=0;M<=F;M++)if(ws(k,M)!==ws($,M)){H=!1;break}if(H)return null}let z=1;if(!i&&!s)for(let L=j+1;L<T.length;L++){const $=T[L].original;if($.isSubtotal||$.isGrandTotal)break;let H=!0;for(let M=0;M<=F;M++)if(ws(k,M)!==ws($,M)){H=!1;break}if(H)z++;else break}return l.jsx(qn,{rowSpan:i?void 0:z,...zh({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!I&&"border-b border-b-border/35")}),children:gi(E.column.columnDef.cell,E.getContext())},E.id)}const R=o.has(D),A=r.has(D);return l.jsx(qn,{"data-column-id":D,...k.isSubtotal?Cd({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!I&&"border-b border-b-border/35",R?"bg-muted/50":A?"bg-muted/30":void 0)}):zh({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!I&&"border-b border-b-border/35",R?"bg-muted/50":A?"bg-muted/30":void 0)}),children:gi(E.column.columnDef.cell,E.getContext())},E.id)})},_.id)}),i&&u>0&&l.jsx(Ar,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(qn,{colSpan:w,style:{height:u,padding:0,border:"none"}})})]}):h?null:l.jsx(Ar,{className:"h-8",children:l.jsx(qn,{colSpan:n.length,className:"text-center",children:"No results."})})}function cet({grandTotalRows:e,data:t,card:n,table:r,showRowTotals:o,columnSettings:s,isSqlCard:i=!1,contextTimezone:a,browserTimezone:c,onAggregationLabelChange:u,tableAppearance:d,valueFormatPreferences:f,resolveBoundCurrency:h}){return e.length===0?null:l.jsx(l.Fragment,{children:e.map((m,g)=>{var b;return l.jsxs(Ar,{style:d.grandTotalRowStyle,className:"h-8 border-border/40 font-semibold","data-row-type":"grandtotal","data-grandtotal":"true","data-grandtotal-index":g,children:[l.jsx(qn,{colSpan:((b=t.groupByColumns)==null?void 0:b.length)||1,...Gc({tableAppearance:d,overflow:"visible",className:"border-r border-t-2 border-border/40 border-t-border/60 px-4 font-semibold text-foreground/90"}),children:u?l.jsx(xi,{value:(()=>{var w,C,N;const x=m.aggregateFunction||"SUM";return((N=(C=(w=n.config)==null?void 0:w.rowAggregates)==null?void 0:C.find(S=>S.function===x&&S.groupLevel==="ALL"))==null?void 0:N.label)||m.fieldValues[0]})(),placeholder:m.fieldValues[0],onSave:x=>{const y=m.aggregateFunction||"SUM";u({type:"row",level:"ALL",function:y,label:x})},displayClassName:"text-right"}):m.fieldValues[0]}),t.columnHeaders.map(x=>{var j,_,k,T,I,E;const y=(_=(j=t.columnMetadata)==null?void 0:j[x])==null?void 0:_.metricId,w=ec({card:n,columnKey:x,metricId:y}),C=Bi({card:n,columnId:x,resolvedSettings:s==null?void 0:s[x],metricId:y,metricAlias:(T=(k=t.columnMetadata)==null?void 0:k[x])==null?void 0:T.metricAlias,valueFormatPreferences:f,boundCurrency:w?h(w):void 0}),N=(I=r.getHeaderGroups()[0])==null?void 0:I.headers.find(D=>D.column.id===x),S=Gc({tableAppearance:d,style:{width:N==null?void 0:N.getSize(),minWidth:N==null?void 0:N.getSize(),maxWidth:N==null?void 0:N.getSize(),transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(qn,{"data-column-id":x,className:S.className,style:S.style,children:Lj((E=m.cells[x])==null?void 0:E.value,C,a,c,i)},x)}),o&&(()=>{var N;const x=dL({card:n,columnHeaders:t.columnHeaders,columnMetadata:t.columnMetadata,columnSettings:s,valueFormatPreferences:f,resolveBoundCurrency:h}),y=(N=r.getHeaderGroups()[0])==null?void 0:N.headers.find(S=>S.column.id==="rowTotal"),w=y==null?void 0:y.getSize(),C=Gc({tableAppearance:d,style:{width:w,minWidth:w,maxWidth:w,transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(qn,{className:C.className,"data-column-id":"rowTotal",style:C.style,children:Lj(jte(m,t.columnHeaders),x,a,c,i)})})()]},m.id)})})}function uet({groupByColumns:e,numRowLevels:t,onAggregationLabelChange:n,isTablePrintDisplayMode:r=!1,isCellWrapping:o=!1,cellContentClassName:s,onCellClick:i}){const a=[];return e&&e.length>0?e.forEach((c,u)=>{a.push({id:`rowLevel${u}`,header:()=>l.jsx("div",{className:"group px-3 py-1 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:l.jsx("div",{className:"flex items-center gap-1",children:l.jsx("span",{className:"whitespace-nowrap",children:c.label||c.name})})}),accessorFn:d=>d.fieldValues[u],cell:({row:d,table:f})=>{const h=d.original;if(h.isSubtotal&&h.subtotalLevel){const x=K_(e,h.subtotalLevel);if(u===x){const y=h.fieldValues[u];return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),style:{gridColumn:`span ${t-u}`},children:y.includes(" Total")&&n?l.jsx(xi,{value:y,placeholder:y,onSave:w=>{const C=h.aggregateFunction||"SUM";if(h.subtotalLevel&&e){const N=P3e(e,h.subtotalLevel);N&&n({type:"row",level:N.id,function:C,label:w})}},displayClassName:"text-left"}):y})}else if(u<x)return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),children:h.fieldValues[u]});return r?l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s)}):null}const m=f.getRowModel().rows,g=m.findIndex(x=>x.id===d.id);if(!r&&g>0)for(let x=g-1;x>=0;x--){const y=m[x].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(ws(h,C)!==ws(y,C)){w=!1;break}if(w)return null}let b=1;if(!r)for(let x=g+1;x<m.length;x++){const y=m[x].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(ws(h,C)!==ws(y,C)){w=!1;break}if(w)b++;else break}return l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s),onClick:i&&!h.isGrandTotal?x=>i(x,h,`rowLevel${u}`):void 0,style:{gridRow:r?void 0:`span ${b}`},children:h.fieldValues[u]})}})}):a.push({id:"rowHeader",header:()=>l.jsx("div",{className:"px-3 py-1 text-left font-medium",children:"Row"}),accessorFn:c=>c.rowKey,cell:({getValue:c})=>l.jsx("div",{className:p.cn("min-w-[150px] max-w-[300px] border-x border-y border-border px-3 py-1",s),children:String(c())})}),a}function det({columnHeaders:e,columnDisplayNames:t,setSorting:n,columnSettings:r,card:o,columnMetadata:s,contextTimezone:i,browserTimezone:a,isSqlCard:c=!1,suppressSortControls:u=!1,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:h}){return e.map(m=>({id:m,accessorFn:g=>{var b;return(b=g.cells[m])==null?void 0:b.value},header:({column:g})=>{const b=(t==null?void 0:t[m])||m;return l.jsx("div",{className:"flex w-full items-center justify-end",children:u?l.jsx("span",{className:"text-sm font-medium",children:b}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const x=g.getIsSorted();n(x?x==="asc"?[{id:g.id,desc:!0}]:[]:[{id:g.id,desc:!1}])},"aria-label":`Sort ${b}`,children:[l.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:b}),g.getIsSorted()==="asc"?l.jsx(bs,{className:"h-3 w-3"}):g.getIsSorted()==="desc"?l.jsx(es,{className:"h-3 w-3"}):null]})})},cell:({getValue:g,row:b})=>{var S,j,_;const x=g(),y=o?ec({card:o,columnKey:m,metricId:(S=s==null?void 0:s[m])==null?void 0:S.metricId}):void 0,w=Bi({card:o,columnId:m,resolvedSettings:r==null?void 0:r[m],metricId:(j=s==null?void 0:s[m])==null?void 0:j.metricId,metricAlias:(_=s==null?void 0:s[m])==null?void 0:_.metricAlias,valueFormatPreferences:d,boundCurrency:y?f(y):void 0}),C=(w==null?void 0:w.textAlign)||"right",N=C==="left"?"text-left":C==="center"?"text-center":"text-right";return l.jsx("div",{className:N,onClick:h?k=>h(k,b.original,m):void 0,children:Lj(x,w,i,a,c)})}}))}function fet({columnHeaders:e,setSorting:t,suppressSortControls:n=!1,settings:r}){return{id:"rowTotal",header:({column:o})=>l.jsx("div",{className:"flex w-full items-center justify-end",children:n?l.jsx("span",{className:"text-sm font-medium",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const s=o.getIsSorted();t(s?s==="asc"?[{id:o.id,desc:!0}]:[]:[{id:o.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:"text-sm font-medium",children:"Total"}),o.getIsSorted()==="asc"?l.jsx(bs,{className:"h-3 w-3"}):o.getIsSorted()==="desc"?l.jsx(es,{className:"h-3 w-3"}):null]})}),cell:({row:o})=>{const s=o.original,i=jte(s,e);return l.jsx("div",{className:"text-right text-sm font-medium",children:Lj(i,r)})}}}function cU(e){const t=it.resolveGroupedTemporalFieldPresentationByRole({presentation:e.presentation,fieldId:e.field.id,role:e.field.role});return e.value===null?{field:e.field,operator:"isNull",value:null,...t?{label:"(Blank)",temporalBucket:t.metadata}:{}}:{field:e.field,operator:"=",value:e.value,...t?{label:it.formatGroupedTemporalFieldValue({fieldId:e.field.id,role:e.field.role,value:e.value,presentation:e.presentation}),temporalBucket:t.metadata}:{}}}function het(e){var m,g,b;if(e.row.isSubtotal||e.row.isGrandTotal||!e.card.config)return;const t=e.card.config,n=e.row.canonicalFieldValues||e.row.fieldValues,r=(t.groupByColumns||[]).map((x,y)=>cU({field:x,value:n[y]??null,presentation:e.temporalPresentation})),o=(m=e.resultColumns)==null?void 0:m.find(x=>x.key===e.columnKey);if((((g=o==null?void 0:o.pivotIdentity)==null?void 0:g.members)??[]).forEach(x=>{const y=(t.pivotByColumns||[]).find(w=>w.id===x.fieldId);y&&r.push(cU({field:y,value:x.value,presentation:e.temporalPresentation}))}),r.length===0)return;const i=o==null?void 0:o.pivotIdentity,a=t.metricColumns||[],c=i?a.find(x=>$r.resolveMetricResultAlias(x)===i.metricAlias):void 0,u=i?a.filter(x=>x.id===i.metricId):[],d=c||(u.length===1?u[0]:void 0),f=(b=e.row.cells[e.columnKey])==null?void 0:b.value,h=d&&typeof f=="number"?[{field:d,value:f}]:[];return{conditions:r,...h.length?{metrics:h}:{}}}function Wb({data:e,card:t,options:n={},onAggregationChange:r,onAggregationLabelChange:o,suppressSortControls:s=!1,renderPlainWrapper:i=!1,frameId:a,sheetId:c,onMultipleInteractions:u}){var ee,J,re,pe,Ee;const{preferences:d,resolveBoundCurrency:f}=Ta(t,e.columnHeaders),{displayPreferences:h,shouldShowElement:m}=cl(),g=v.useRef(null),b=v.useMemo(()=>f3(),[]),{updatePageSize:x}=p.useEditorActions(),y=v.useMemo(()=>typeof document<"u"&&"onscrollend"in document,[]),w=!!(t!=null&&t.sql),C=typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0,N=void 0,S=v.useMemo(()=>p.getInteractions(t.interactionConfig).some(p.isInteractionConfiguredForExecution),[t.interactionConfig]),{handlePointerInteraction:j}=p.useEventEngine(t,a||"",c||"",u),_=v.useCallback((Te,ze,Pe)=>{if(!S||!a||!c)return;const He=het({card:t,row:ze,columnKey:Pe,resultColumns:e.resultColumns,temporalPresentation:e.temporalPresentation});He&&(Te.stopPropagation(),j({context:He,gesture:"leftClick",modifierKeys:{shift:Te.shiftKey,ctrl:Te.ctrlKey,meta:Te.metaKey},position:{x:Te.clientX,y:Te.clientY}}))},[t,e.resultColumns,e.temporalPresentation,a,j,S,c]),k=n.showRowTotals??!1,{columnSizing:T,onColumnSizingChange:I}=d3({card:t}),{subtotalColumnKeys:E,grandTotalColumnKeys:D}=v.useMemo(()=>VEe(e.columnSubtotalMeta),[e.columnSubtotalMeta]),{tableData:R,grandTotalRows:A}=v.useMemo(()=>uL(e),[e]),{sorting:F,setSorting:z,sortedTableData:L}=net(R,e),{columnSettings:$,columnSettingsOpen:H,activeColumnId:M,tempColumnSettings:B,isVisualEditing:W,openColumnSettings:P,applyColumnSettings:G,resetColumnSettings:Z,resetAllColumnSettings:X,setColumnSettingsOpen:Y,setTempColumnSettings:O}=iet(t,L,e.columnMetadata),q=m3({displayMode:h.mode,isVisualEditing:W,printBehavior:"any-print",renderPlainWrapper:i}),U=q.isPrint,V=dI("pivotTable",(J=(ee=t==null?void 0:t.preferences)==null?void 0:ee.tablePrefs)==null?void 0:J.density,q.mode==="document-print"?"document":"appearance"),K={...n.pagination},Q=XJe(K,L.length),se=v.useMemo(()=>{var ye;const Te=[],ze=((ye=e.groupByColumns)==null?void 0:ye.length)||1,Pe=uet({groupByColumns:e.groupByColumns,numRowLevels:ze,onAggregationLabelChange:o,isTablePrintDisplayMode:U,isCellWrapping:V.isCellWrapping,cellContentClassName:V.cellContentClassName,onCellClick:_});Te.push(...Pe);const He=det({columnHeaders:e.columnHeaders,columnDisplayNames:e.columnDisplayNames,setSorting:z,suppressSortControls:s,columnSettings:$,card:t,columnMetadata:e.columnMetadata,contextTimezone:N,browserTimezone:C,isSqlCard:w,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:_});if(Te.push(...He),k){const Ke=fet({columnHeaders:e.columnHeaders,setSorting:z,suppressSortControls:s,settings:dL({card:t,columnHeaders:e.columnHeaders,columnMetadata:e.columnMetadata,columnSettings:$,valueFormatPreferences:d,resolveBoundCurrency:f})});Te.push(Ke)}return Te},[t,e,k,o,z,s,U,$,N,C,w,V.cellContentClassName,V.isCellWrapping,d,f,_]),oe=nI({data:L,columns:se,state:{sorting:F,columnSizing:T,pagination:{pageIndex:Q.pageIndex,pageSize:Q.pageSize}},onSortingChange:z,onPaginationChange:void 0,getCoreRowModel:eI(),getPaginationRowModel:!Q.isServerSidePagination&&q.allowPagination?tI():void 0,manualPagination:Q.isServerSidePagination||!q.allowPagination,manualSorting:!0,pageCount:Q.pageCount,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:I}),me=oe.getRowModel().rows,ue=q.allowVirtualization&&me.length>75,ne=ue&&(!b||V.isCellWrapping),de=uI({count:ue?me.length:0,getScrollElement:()=>g.current,estimateSize:()=>V.dataRowHeight??32,overscan:b?5:10,useScrollendEvent:b&&y,isScrollingResetDelay:b?240:150}),Ce=ue?de.getVirtualItems():[],ce=ue&&Ce.length>0?Ce[0].start:0,ie=ue&&Ce.length>0?de.getTotalSize()-Ce[Ce.length-1].end:0,{buildColumnHeaderRows:we}=set({data:e,card:t,table:oe,sorting:F,setSorting:z,showRowTotals:k,onAggregationChange:r,onOpenColumnSettings:P,suppressSortControls:s,tableAppearance:V}),fe=we(),ae=l.jsxs("table",{className:"w-full border-separate border-spacing-0 text-sm [border-spacing:0]",onMouseDown:Te=>Te.stopPropagation(),"data-pivot-table":"true","data-row-levels":((re=e.groupByColumns)==null?void 0:re.length)||1,"data-pivot-levels":e.columnGroups&&((Ee=(pe=t.config)==null?void 0:pe.pivotByColumns)==null?void 0:Ee.length)||0,children:[l.jsx(Zm,{style:V.headerStyle,className:p.cn("bg-muted/95 [&_tr]:border-b-0",q.allowStickyHeader&&V.isHeaderSticky&&"sticky top-0 z-20 supports-[backdrop-filter]:bg-muted/80 supports-[backdrop-filter]:backdrop-blur-sm"),children:fe}),l.jsx(Gd,{children:l.jsx(aet,{table:oe,data:e,columns:se,subtotalColumnKeys:E,grandTotalColumnKeys:D,isTablePrintDisplayMode:U,shouldVirtualizeRows:ue,virtualRows:Ce,paddingTop:ce,paddingBottom:ie,measureElement:ne?de.measureElement:void 0,disableRowTransitions:b,suppressEmptyState:A.length>0,tableAppearance:V})}),A.length>0&&l.jsx("tfoot",{className:p.cn("border-t border-t-border/60 bg-muted/95",q.allowStickyHeader&&"sticky bottom-0 z-10"),"data-grandtotal":"true",style:V.grandTotalRowStyle,children:l.jsx(cet,{grandTotalRows:A,data:e,card:t,table:oe,showRowTotals:k,columnSettings:$,isSqlCard:w,contextTimezone:N,browserTimezone:C,onAggregationLabelChange:o,tableAppearance:V,valueFormatPreferences:d,resolveBoundCurrency:f})})]});return l.jsxs("div",{className:"flex h-full w-full flex-col gap-2",children:[q.usePlainWrapper?l.jsx("div",{ref:g,style:V.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:Te=>Te.stopPropagation(),children:ae}):l.jsxs(hl,{ref:g,style:V.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:Te=>Te.stopPropagation(),children:[ae,l.jsx(p.ScrollBar,{orientation:"horizontal",className:"z-20"})]}),q.allowPagination&&Q.showPagination&&l.jsx(rI,{totalColumns:se.length,pageCount:Q.pageCount||oe.getPageCount(),pageIndex:Q.pageIndex,pageSize:Q.pageSize,rowCount:Q.totalCount,selectedRowCount:0,setPageIndex:Q.setPageIndex,setPageSize:Q.setPageSize,canPreviousPage:Q.canPreviousPage,canNextPage:Q.canNextPage,previousPage:Q.previousPage,nextPage:Q.nextPage,onPageSizePreferenceChange:q.showEditorControls?x:void 0,onClearSelection:()=>{},appearance:V.pagination}),M&&l.jsx(l3,{column:oe.getColumn(M)||null,settings:B,onSettingsChange:O,onApply:G,onReset:Z,onResetAll:X,open:H,onOpenChange:Y,tableType:"pivot",isSqlCard:w})]})}const met=420,pet=360,get="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js";function bet(e){return`<!DOCTYPE html>
961
+ `)),[]});var pKe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(pKe||{});function gKe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function bKe(e,t,n,r){let[o,s]=v.useState(n),{hasFlag:i,addFlag:a,removeFlag:c}=mKe(e&&o?3:0),u=v.useRef(!1),d=v.useRef(!1),f=Hb();return vo(()=>{var h;if(e){if(n&&s(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),xKe(t,{inFlight:u,prepare(){d.current?d.current=!1:d.current=u.current,u.current=!0,!d.current&&(n?(a(3),c(4)):(a(4),c(2)))},run(){d.current?n?(c(3),a(4)):(c(4),a(3)):n?c(1):a(1)},done(){var m;d.current&&wKe(t)||(u.current=!1,c(7),n||s(!1),(m=void 0)==null||m.call(r,n))}})}},[e,n,t,f]),e?[o,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function xKe(e,{prepare:t,run:n,done:r,inFlight:o}){let s=Da();return vKe(e,{prepare:t,inFlight:o}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(yKe(e,r))})}),s.dispose}function yKe(e,t){var n,r;let o=Da();if(!e)return o.dispose;let s=!1;o.add(()=>{s=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),o.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{s||t()}),o.dispose)}function vKe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function wKe(e){var t,n;return((n=(t=e.getAnimations)==null?void 0:t.call(e))!=null?n:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function CKe(e,{container:t,accept:n,walk:r}){let o=v.useRef(n),s=v.useRef(r);v.useEffect(()=>{o.current=n,s.current=r},[n,r]),vo(()=>{if(!t||!e)return;let i=Dw(t);if(!i)return;let a=o.current,c=s.current,u=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,u,!1);for(;d.nextNode();)c(d.currentNode)},[t,e,o,s])}function kq(e,t){let n=v.useRef([]),r=Ln(e);v.useEffect(()=>{let o=[...n.current];for(let[s,i]of t.entries())if(n.current[s]!==i){let a=r(t,o);return n.current=t,a}},[r,...t])}function SKe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const tce={...te},NKe=tce.useInsertionEffect,jKe=NKe||(e=>e());function nce(e){const t=te.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return jKe(()=>{t.current=e}),te.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var HP=typeof document<"u"?v.useLayoutEffect:v.useEffect;let _q=!1,kKe=0;const Iq=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+kKe++;function _Ke(){const[e,t]=te.useState(()=>_q?Iq():void 0);return HP(()=>{e==null&&t(Iq())},[]),te.useEffect(()=>{_q=!0},[]),e}const IKe=tce.useId,TKe=IKe||_Ke;let Z0;process.env.NODE_ENV!=="production"&&(Z0=new Set);function EKe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=Z0)!=null&&e.has(o))){var s;(s=Z0)==null||s.add(o),console.warn(o)}}function DKe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=Z0)!=null&&e.has(o))){var s;(s=Z0)==null||s.add(o),console.error(o)}}function MKe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}const RKe=te.createContext(null),AKe=te.createContext(null),PKe=()=>{var e;return((e=te.useContext(RKe))==null?void 0:e.id)||null},FKe=()=>te.useContext(AKe),OKe="data-floating-ui-focusable";function LKe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=TKe(),s=te.useRef({}),[i]=te.useState(()=>MKe()),a=PKe()!=null;if(process.env.NODE_ENV!=="production"){const m=r.reference;m&&!p.isElement(m)&&DKe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[c,u]=te.useState(r.reference),d=nce((m,g,b)=>{s.current.openEvent=m?g:void 0,i.emit("openchange",{open:m,event:g,reason:b,nested:a}),n==null||n(m,g,b)}),f=te.useMemo(()=>({setPositionReference:u}),[]),h=te.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return te.useMemo(()=>({dataRef:s,open:t,onOpenChange:d,elements:h,events:i,floatingId:o,refs:f}),[t,d,h,i,o,f])}function $Ke(e){e===void 0&&(e={});const{nodeId:t}=e,n=LKe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[s,i]=te.useState(null),[a,c]=te.useState(null),d=(o==null?void 0:o.domReference)||s,f=te.useRef(null),h=FKe();HP(()=>{d&&(f.current=d)},[d]);const m=p.useFloating({...e,elements:{...o,...a&&{reference:a}}}),g=te.useCallback(C=>{const N=p.isElement(C)?{getBoundingClientRect:()=>C.getBoundingClientRect(),contextElement:C}:C;c(N),m.refs.setReference(N)},[m.refs]),b=te.useCallback(C=>{(p.isElement(C)||C===null)&&(f.current=C,i(C)),(p.isElement(m.refs.reference.current)||m.refs.reference.current===null||C!==null&&!p.isElement(C))&&m.refs.setReference(C)},[m.refs]),x=te.useMemo(()=>({...m.refs,setReference:b,setPositionReference:g,domReference:f}),[m.refs,b,g]),y=te.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),w=te.useMemo(()=>({...m,...r,refs:x,elements:y,nodeId:t}),[m,x,y,t,r]);return HP(()=>{r.dataRef.current.floatingContext=w;const C=h==null?void 0:h.nodesRef.current.find(N=>N.id===t);C&&(C.context=w)}),te.useMemo(()=>({...m,context:w,refs:x,elements:y}),[m,x,y,w])}const Tq="active",Eq="selected";function aM(e,t,n){const r=new Map,o=n==="item";let s=e;if(o&&e){const{[Tq]:i,[Eq]:a,...c}=e;s=c}return{...n==="floating"&&{tabIndex:-1,[OKe]:""},...s,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(c=>{let[u,d]=c;if(!(o&&[Tq,Eq].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),i[u]=function(){for(var h,m=arguments.length,g=new Array(m),b=0;b<m;b++)g[b]=arguments[b];return(h=r.get(u))==null?void 0:h.map(x=>x(...g)).find(x=>x!==void 0)}}}else i[u]=d}),i),{})}}function zKe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),o=te.useCallback(a=>aM(a,e,"reference"),t),s=te.useCallback(a=>aM(a,e,"floating"),n),i=te.useCallback(a=>aM(a,e,"item"),r);return te.useMemo(()=>({getReferenceProps:o,getFloatingProps:s,getItemProps:i}),[o,s,i])}function Dq(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const BKe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:o,offset:s=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:c=0,scrollRef:u,...d}=p.evaluate(e,t),{rects:f,elements:{floating:h}}=t,m=n.current[i],g=(u==null?void 0:u.current)||h,b=h.clientTop||g.clientTop,x=h.clientTop!==0,y=g.clientTop!==0,w=h===g;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||EKe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!m)return{};const C={...t,...await p.offset(-m.offsetTop-h.clientTop-f.reference.height/2-m.offsetHeight/2-s).fn(t)},N=await p.detectOverflow(Dq(C,g.scrollHeight+b+h.clientTop),d),S=await p.detectOverflow(C,{...d,elementContext:"reference"}),j=p.max(0,N.top),_=C.y+j,I=(g.scrollHeight>g.clientHeight?E=>E:p.round)(p.max(0,g.scrollHeight+(x&&w||y?b*2:0)-j-p.max(0,N.bottom)));if(g.style.maxHeight=I+"px",g.scrollTop=j,o){const E=g.offsetHeight<m.offsetHeight*p.min(a,n.current.length)-1||S.top>=-c||S.bottom>=-c;V2.flushSync(()=>o(E))}return r&&(r.current=await p.detectOverflow(Dq({...C,y:_},g.offsetHeight+b+h.clientTop),d)),{y:_}}});function VKe(e,t){const{open:n,elements:r}=e,{enabled:o=!0,overflowRef:s,scrollRef:i,onChange:a}=t,c=nce(a),u=te.useRef(!1),d=te.useRef(null),f=te.useRef(null);te.useEffect(()=>{if(!o)return;function m(b){if(b.ctrlKey||!g||s.current==null)return;const x=b.deltaY,y=s.current.top>=-.5,w=s.current.bottom>=-.5,C=g.scrollHeight-g.clientHeight,N=x<0?-1:1,S=x<0?"max":"min";g.scrollHeight<=g.clientHeight||(!y&&x>0||!w&&x<0?(b.preventDefault(),V2.flushSync(()=>{c(j=>j+Math[S](x,C*N))})):/firefox/i.test(SKe())&&(g.scrollTop+=x))}const g=(i==null?void 0:i.current)||r.floating;if(n&&g)return g.addEventListener("wheel",m),requestAnimationFrame(()=>{d.current=g.scrollTop,s.current!=null&&(f.current={...s.current})}),()=>{d.current=null,f.current=null,g.removeEventListener("wheel",m)}},[o,n,r.floating,s,i,c]);const h=te.useMemo(()=>({onKeyDown(){u.current=!0},onWheel(){u.current=!1},onPointerMove(){u.current=!1},onScroll(){const m=(i==null?void 0:i.current)||r.floating;if(!(!s.current||!m||!u.current)){if(d.current!==null){const g=m.scrollTop-d.current;(s.current.bottom<-.5&&g<-1||s.current.top<-.5&&g>1)&&V2.flushSync(()=>c(b=>b+g))}requestAnimationFrame(()=>{d.current=m.scrollTop})}}}),[r.floating,c,s,i]);return te.useMemo(()=>o?{floating:h}:{},[o,h])}let Mw=v.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Mw.displayName="FloatingContext";let v$=v.createContext(null);v$.displayName="PlacementContext";function HKe(e){return v.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function qKe(){return v.useContext(Mw).setReference}function UKe(){let{getFloatingProps:e,slot:t}=v.useContext(Mw);return v.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function WKe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=v.useContext(v$),n=v.useMemo(()=>e,[JSON.stringify(e,(o,s)=>{var i;return(i=s==null?void 0:s.outerHTML)!=null?i:s})]);vo(()=>{t==null||t(n??null)},[t,n]);let r=v.useContext(Mw);return v.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Mq=4;function KKe({children:e,enabled:t=!0}){let[n,r]=v.useState(null),[o,s]=v.useState(0),i=v.useRef(null),[a,c]=v.useState(null);GKe(a);let u=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:m=0,inner:g}=YKe(n,a),[b,x="center"]=d.split(" ");vo(()=>{u&&s(0)},[u]);let{refs:y,floatingStyles:w,context:C}=$Ke({open:u,placement:b==="selection"?x==="center"?"bottom":`bottom-${x}`:x==="center"?`${b}`:`${b}-${x}`,strategy:"absolute",transform:!1,middleware:[p.offset({mainAxis:b==="selection"?0:f,crossAxis:h}),p.shift({padding:m}),b!=="selection"&&p.flip({padding:m}),b==="selection"&&g?BKe({...g,padding:m,overflowRef:i,offset:o,minItemsVisible:Mq,referenceOverflowThreshold:m,onFallbackChange(E){var D,R;if(!E)return;let A=C.elements.floating;if(!A)return;let F=parseFloat(getComputedStyle(A).scrollPaddingBottom)||0,z=Math.min(Mq,A.childElementCount),L=0,$=0;for(let H of(R=(D=C.elements.floating)==null?void 0:D.childNodes)!=null?R:[])if(kf(H)){let M=H.offsetTop,B=M+H.clientHeight+F,W=A.scrollTop,P=W+A.clientHeight;if(M>=W&&B<=P)z--;else{$=Math.max(0,Math.min(B,P)-Math.max(M,W)),L=H.clientHeight;break}}z>=1&&s(H=>{let M=L*z-$+F;return H>=M?H:M})}}):null,p.size({padding:m,apply({availableWidth:E,availableHeight:D,elements:R}){Object.assign(R.floating.style,{overflow:"auto",maxWidth:`${E}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${D}px)`})}})].filter(Boolean),whileElementsMounted:p.autoUpdate}),[N=b,S=x]=C.placement.split("-");b==="selection"&&(N="selection");let j=v.useMemo(()=>({anchor:[N,S].filter(Boolean).join(" ")}),[N,S]),_=VKe(C,{overflowRef:i,onChange:s}),{getReferenceProps:k,getFloatingProps:T}=zKe([_]),I=Ln(E=>{c(E),y.setFloating(E)});return te.createElement(v$.Provider,{value:r},te.createElement(Mw.Provider,{value:{setFloating:I,setReference:y.setReference,styles:w,getReferenceProps:k,getFloatingProps:T,slot:j}},e))}function GKe(e){vo(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let o=parseInt(n);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function YKe(e,t){var n,r,o;let s=lM((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=lM((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=lM((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",t);return{...e,gap:s,offset:i,padding:a}}function lM(e,t,n=void 0){let r=Hb(),o=Ln((c,u)=>{if(c==null)return[n,null];if(typeof c=="number")return[c,null];if(typeof c=="string"){if(!u)return[n,null];let d=Rq(c,u);return[d,f=>{let h=rce(c);{let m=h.map(g=>window.getComputedStyle(u).getPropertyValue(g));r.requestAnimationFrame(function g(){r.nextFrame(g);let b=!1;for(let[y,w]of h.entries()){let C=window.getComputedStyle(u).getPropertyValue(w);if(m[y]!==C){m[y]=C,b=!0;break}}if(!b)return;let x=Rq(c,u);d!==x&&(f(x),d=x)})}return r.dispose}]}return[n,null]}),s=v.useMemo(()=>o(e,t)[0],[e,t]),[i=s,a]=v.useState();return vo(()=>{let[c,u]=o(e,t);if(a(c),!!u)return u(a)},[e,t]),i}function rce(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),o=t[1].slice(n+1).trim();return o?[r,...rce(o)]:[r]}return[]}function Rq(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function ZKe({children:e,freeze:t},n){let r=qP(t,e);return v.isValidElement(r)?v.cloneElement(r,{ref:n}):v.createElement(v.Fragment,null,r)}const XKe=v.forwardRef(ZKe);function qP(e,t){let[n,r]=v.useState(t);return!e&&n!==t&&r(t),e?n:t}let w$=v.createContext(null);w$.displayName="OpenClosedContext";var X0=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(X0||{});function QKe(){return v.useContext(w$)}function JKe({value:e,children:t}){return v.createElement(w$.Provider,{value:e},t)}function eGe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let oh=[];eGe(()=>{function e(t){if(!gh(t.target)||t.target===document.body||oh[0]===t.target)return;let n=t.target;n=n.closest(zP),oh.unshift(n??t.target),oh=oh.filter(r=>r!=null&&r.isConnected),oh.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function tGe(e){throw new Error("Unexpected object: "+e)}var Po=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(Po||{});function Aq(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let s=0;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 1:{o===-1&&(o=n.length);for(let s=o-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 2:{for(let s=o+1;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 3:{for(let s=n.length-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 4:{for(let s=0;s<n.length;++s)if(t.resolveId(n[s],s,n)===e.id)return s;return r}case 5:return null;default:tGe(e)}}function oce(e){let t=Ln(e),n=v.useRef(!1);v.useEffect(()=>(n.current=!1,()=>{n.current=!0,Rle(()=>{n.current&&t()})}),[t])}let nGe=v.createContext(!1);function rGe(){return v.useContext(nGe)}function oGe(e){let t=rGe(),n=v.useContext(ice),[r,o]=v.useState(()=>{var s;if(!t&&n!==null)return(s=n.current)!=null?s:null;if(Gh.isServer)return null;let i=e==null?void 0:e.getElementById("headlessui-portal-root");if(i)return i;if(e===null)return null;let a=e.createElement("div");return a.setAttribute("id","headlessui-portal-root"),e.body.appendChild(a)});return v.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),v.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),r}let sce=v.Fragment,sGe=gl(function(e,t){let{ownerDocument:n=null,...r}=e,o=v.useRef(null),s=Bu(vWe(h=>{o.current=h}),t),i=VP(o.current),a=n??i,c=oGe(a),u=v.useContext(cGe),d=Hb(),f=pl();return oce(()=>{var h;c&&c.childNodes.length<=0&&((h=c.parentElement)==null||h.removeChild(c))}),c?br.createPortal(v.createElement("div",{"data-headlessui-portal":"",ref:h=>{d.dispose(),u&&h&&d.add(u.register(h))}},f({ourProps:{ref:s},theirProps:r,slot:{},defaultTag:sce,name:"Portal"})),c):null});function iGe(e,t){let n=Bu(t),{enabled:r=!0,ownerDocument:o,...s}=e,i=pl();return r?v.createElement(sGe,{...s,ownerDocument:o,ref:n}):i({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:sce,name:"Portal"})}let aGe=v.Fragment,ice=v.createContext(null);function lGe(e,t){let{target:n,...r}=e,o={ref:Bu(t)},s=pl();return v.createElement(ice.Provider,{value:n},s({ourProps:o,theirProps:r,defaultTag:aGe,name:"Popover.Group"}))}let cGe=v.createContext(null),uGe=gl(iGe),dGe=gl(lGe),fGe=Object.assign(uGe,{Group:dGe});const by={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function ace(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function hGe(e,t,n){let r=Da();if(t.kind==="Tracked"){let o=function(){s!==ace(e)&&(r.dispose(),n())},{position:s}=t,i=new ResizeObserver(o);i.observe(e),r.add(()=>i.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}var mGe=Object.defineProperty,pGe=(e,t,n)=>t in e?mGe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pq=(e,t,n)=>(pGe(e,typeof t!="symbol"?t+"":t,n),n),Dn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Dn||{}),Fi=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Fi||{}),Xl=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(Xl||{}),lce=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(lce||{});function cM(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),o=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):XWe(r,i=>i.dataRef.current.domRef.current),s=n?o.indexOf(n):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let gGe={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?by.Tracked(ace(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1,inputPositionState:by.Idle}}return{...e,comboboxState:0,inputPositionState:by.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,o,s;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:u,disabled:d}=e.virtual,f=t.focus===Po.Specific?t.idx:Aq(t,{resolveItems:()=>u,resolveActiveIndex:()=>{var m,g;return(g=(m=e.activeOptionIndex)!=null?m:u.findIndex(b=>!d(b)))!=null?g:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=cM(e);if(i.activeOptionIndex===null){let u=i.options.findIndex(d=>!d.dataRef.current.disabled);u!==-1&&(i.activeOptionIndex=u)}let a=t.focus===Po.Specific?t.idx:Aq(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),c=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===a&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:c,__demoMode:!1}},4:(e,t)=>{var n,r,o,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let i=t.payload,a=cM(e,u=>(u.push(i),u));e.activeOptionIndex===null&&(o=(r=e.dataRef.current).isSelected)!=null&&o.call(r,t.payload.dataRef.current.value)&&(a.activeOptionIndex=a.options.indexOf(i));let c={...e,...a,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(o=>o.id!==t.id)};let r=cM(e,o=>{let s=o.findIndex(i=>i.id===t.id);return s!==-1&&o.splice(s,1),o});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:by.Moved}}};class C$ extends Kle{constructor(t){super(t),Pq(this,"actions",{onChange:n=>{let{onChange:r,compare:o,mode:s,value:i}=this.state.dataRef.current;return ac(s,{0:()=>r==null?void 0:r(n),1:()=>{let a=i.slice(),c=a.findIndex(u=>o(u,n));return c===-1?a.push(n):a.splice(c,1),r==null?void 0:r(a)}})},registerOption:(n,r)=>(this.send({type:4,payload:{id:n,dataRef:r}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(r.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:n})}),goToOption:(n,r)=>(this.send({type:6,value:!1}),this.send({type:2,...n,trigger:r})),setIsTyping:n=>{this.send({type:3,isTyping:n})},closeCombobox:()=>{var n,r;this.send({type:1}),this.send({type:6,value:!1}),(r=(n=this.state.dataRef.current).onClose)==null||r.call(n)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:n=>{this.send({type:7,trigger:n})},selectActiveOption:()=>{let n=this.selectors.activeOptionIndex(this.state);if(n!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[n]);else{let{dataRef:r}=this.state.options[n];this.actions.onChange(r.current.value)}this.actions.goToOption({focus:Po.Specific,idx:n})}},setInputElement:n=>{this.send({type:9,element:n})},setButtonElement:n=>{this.send({type:10,element:n})},setOptionsElement:n=>{this.send({type:11,element:n})}}),Pq(this,"selectors",{activeDescendantId:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);if(s!==null)return n.virtual?(o=n.options.find(i=>!i.dataRef.current.disabled&&n.dataRef.current.compare(i.dataRef.current.value,n.virtual.options[s])))==null?void 0:o.id:(r=n.options[s])==null?void 0:r.id},activeOptionIndex:n=>{if(n.defaultToFirstOption&&n.activeOptionIndex===null&&(n.virtual?n.virtual.options.length>0:n.options.length>0)){if(n.virtual){let{options:o,disabled:s}=n.virtual,i=o.findIndex(a=>{var c;return!((c=s==null?void 0:s(a))!=null&&c)});if(i!==-1)return i}let r=n.options.findIndex(o=>!o.dataRef.current.disabled);if(r!==-1)return r}return n.activeOptionIndex},activeOption:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);return s===null?null:n.virtual?n.virtual.options[s??0]:(o=(r=n.options[s])==null?void 0:r.dataRef.current.value)!=null?o:null},isActive:(n,r,o)=>{var s;let i=this.selectors.activeOptionIndex(n);return i===null?!1:n.virtual?i===n.dataRef.current.calculateIndex(r):((s=n.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(n,r,o)=>!(n.virtual||n.__demoMode||n.comboboxState!==0||n.activationTrigger===0||!this.selectors.isActive(n,r,o)),didInputMove(n){return n.inputPositionState.kind==="Moved"}});{let n=this.state.id,r=y$.get(null);this.disposables.add(r.on(Yle.Push,o=>{!r.selectors.isTop(o,n)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>r.actions.push(n)),this.on(1,()=>r.actions.pop(n))}this.disposables.group(n=>{this.on(1,r=>{r.inputElement&&(n.dispose(),n.add(hGe(r.inputElement,r.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){var o;return new C$({id:t,dataRef:{current:{}},comboboxState:r?0:1,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:(o=n.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:by.Idle})}reduce(t,n){return ac(n.type,gGe,t,n)}}const cce=v.createContext(null);function Rw(e){let t=v.useContext(cce);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,uce),n}return t}function uce({id:e,virtual:t=null,__demoMode:n=!1}){let r=v.useMemo(()=>C$.new({id:e,virtual:t,__demoMode:n}),[]);return oce(()=>r.dispose()),r}let Q0=v.createContext(null);Q0.displayName="ComboboxDataContext";function qb(e){let t=v.useContext(Q0);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,qb),n}return t}let dce=v.createContext(null);function bGe(e){let t=Rw("VirtualProvider"),n=qb("VirtualProvider"),{options:r}=n.virtual,o=Bo(t,m=>m.optionsElement),[s,i]=v.useMemo(()=>{let m=o;if(!m)return[0,0];let g=window.getComputedStyle(m);return[parseFloat(g.paddingBlockStart||g.paddingTop),parseFloat(g.paddingBlockEnd||g.paddingBottom)]},[o]),a=uI({enabled:r.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:r.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[c,u]=v.useState(0);vo(()=>{u(m=>m+1)},[r]);let d=a.getVirtualItems(),f=Bo(t,m=>m.activationTrigger===Xl.Pointer),h=Bo(t,t.selectors.activeOptionIndex);return d.length===0?null:v.createElement(dce.Provider,{value:a},v.createElement("div",{style:{position:"relative",width:"100%",height:`${a.getTotalSize()}px`},ref:m=>{m&&(f||h!==null&&r.length>h&&a.scrollToIndex(h))}},d.map(m=>{var g;return v.createElement(v.Fragment,{key:m.key},v.cloneElement((g=e.children)==null?void 0:g.call(e,{...e.slot,option:r[m.index]}),{key:`${c}-${m.key}`,"data-index":m.index,"aria-setsize":r.length,"aria-posinset":m.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${m.start}px)`,overflowAnchor:"none"}}))})))}let xGe=v.Fragment;function yGe(e,t){let n=v.useId(),r=m$(),{value:o,defaultValue:s,onChange:i,form:a,name:c,by:u,invalid:d=!1,disabled:f=r||!1,onClose:h,__demoMode:m=!1,multiple:g=!1,immediate:b=!1,virtual:x=null,nullable:y,...w}=e,C=iWe(s),[N=g?[]:void 0,S]=sWe(o,i,C),j=uce({id:n,virtual:x,__demoMode:m}),_=v.useRef({static:!1,hold:!1}),k=DWe(u),T=Ln(O=>x?u===null?x.options.indexOf(O):x.options.findIndex(q=>k(q,O)):j.state.options.findIndex(q=>k(q.dataRef.current.value,O))),I=v.useCallback(O=>ac(R.mode,{[Fi.Multi]:()=>N.some(q=>k(q,O)),[Fi.Single]:()=>k(N,O)}),[N]),E=Bo(j,O=>O.virtual),D=Ln(()=>h==null?void 0:h()),R=v.useMemo(()=>({__demoMode:m,immediate:b,optionsPropsRef:_,value:N,defaultValue:C,disabled:f,invalid:d,mode:g?Fi.Multi:Fi.Single,virtual:x?E:null,onChange:S,isSelected:I,calculateIndex:T,compare:k,onClose:D}),[m,b,_,N,C,f,d,g,x,E,S,I,T,k,D]);vo(()=>{var O;x&&j.send({type:lce.UpdateVirtualConfiguration,options:x.options,disabled:(O=x.disabled)!=null?O:null})},[x,x==null?void 0:x.options,x==null?void 0:x.disabled]),vo(()=>{j.state.dataRef.current=R},[R]);let[A,F,z,L]=Bo(j,O=>[O.comboboxState,O.buttonElement,O.inputElement,O.optionsElement]),$=y$.get(null),H=Bo($,v.useCallback(O=>$.selectors.isTop(O,n),[$,n]));eKe(H,[F,z,L],()=>j.actions.closeCombobox());let M=Bo(j,j.selectors.activeOptionIndex),B=Bo(j,j.selectors.activeOption),W=np({open:A===Dn.Open,disabled:f,invalid:d,activeIndex:M,activeOption:B,value:N}),[P,G]=jWe(),Z=t===null?{}:{ref:t},X=v.useCallback(()=>{if(C!==void 0)return S==null?void 0:S(C)},[S,C]),Y=pl();return v.createElement(G,{value:P,props:{htmlFor:z==null?void 0:z.id},slot:{open:A===Dn.Open,disabled:f}},v.createElement(KKe,null,v.createElement(Q0.Provider,{value:R},v.createElement(cce.Provider,{value:j},v.createElement(JKe,{value:ac(A,{[Dn.Open]:X0.Open,[Dn.Closed]:X0.Closed})},c!=null&&v.createElement(fWe,{disabled:f,data:N!=null?{[c]:N}:{},form:a,onReset:X}),Y({ourProps:Z,theirProps:w,slot:W,defaultTag:xGe,name:"Combobox"}))))))}let vGe="input";function wGe(e,t){var n,r;let o=Rw("Combobox.Input"),s=qb("Combobox.Input"),i=v.useId(),a=$le(),{id:c=a||`headlessui-combobox-input-${i}`,onChange:u,displayValue:d,disabled:f=s.disabled||!1,autoFocus:h=!1,type:m="text",...g}=e,b=v.useRef(null),x=Bu(b,t,qKe(),o.actions.setInputElement),[y,w]=Bo(o,W=>[W.comboboxState,W.isTyping]),C=Hb(),N=Ln(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:Po.Nothing})}),S=v.useMemo(()=>{var W;return typeof d=="function"&&s.value!==void 0?(W=d(s.value))!=null?W:"":typeof s.value=="string"?s.value:""},[s.value,d]);kq(([W,P],[G,Z])=>{if(o.state.isTyping)return;let X=b.current;X&&((Z===Dn.Open&&P===Dn.Closed||W!==G)&&(X.value=W),requestAnimationFrame(()=>{if(o.state.isTyping||!X||Mle(X))return;let{selectionStart:Y,selectionEnd:O}=X;Math.abs((O??0)-(Y??0))===0&&Y===0&&X.setSelectionRange(X.value.length,X.value.length)}))},[S,y,w]),kq(([W],[P])=>{if(W===Dn.Open&&P===Dn.Closed){if(o.state.isTyping)return;let G=b.current;if(!G)return;let Z=G.value,{selectionStart:X,selectionEnd:Y,selectionDirection:O}=G;G.value="",G.value=Z,O!==null?G.setSelectionRange(X,Y,O):G.setSelectionRange(X,Y)}},[y]);let j=v.useRef(!1),_=Ln(()=>{j.current=!0}),k=Ln(()=>{C.nextFrame(()=>{j.current=!1})}),T=Ln(W=>{switch(o.actions.setIsTyping(!0),W.key){case Ws.Enter:if(o.state.comboboxState!==Dn.Open||j.current)return;if(W.preventDefault(),W.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===Fi.Single&&o.actions.closeCombobox();break;case Ws.ArrowDown:return W.preventDefault(),W.stopPropagation(),ac(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:Po.Next}),[Dn.Closed]:()=>o.actions.openCombobox()});case Ws.ArrowUp:return W.preventDefault(),W.stopPropagation(),ac(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:Po.Previous}),[Dn.Closed]:()=>{br.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:Po.Last})}});case Ws.Home:if(o.state.comboboxState===Dn.Closed||W.shiftKey)break;return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.First});case Ws.PageUp:return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.First});case Ws.End:if(o.state.comboboxState===Dn.Closed||W.shiftKey)break;return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.Last});case Ws.PageDown:return W.preventDefault(),W.stopPropagation(),o.actions.goToOption({focus:Po.Last});case Ws.Escape:return o.state.comboboxState!==Dn.Open?void 0:(W.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&W.stopPropagation(),s.mode===Fi.Single&&s.value===null&&N(),o.actions.closeCombobox());case Ws.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==Dn.Open)return;s.mode===Fi.Single&&o.state.activationTrigger!==Xl.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),I=Ln(W=>{u==null||u(W),s.mode===Fi.Single&&W.target.value===""&&N(),o.actions.openCombobox()}),E=Ln(W=>{var P,G,Z;let X=(P=W.relatedTarget)!=null?P:oh.find(Y=>Y!==W.currentTarget);if(!((G=o.state.optionsElement)!=null&&G.contains(X))&&!((Z=o.state.buttonElement)!=null&&Z.contains(X))&&o.state.comboboxState===Dn.Open)return W.preventDefault(),s.mode===Fi.Single&&s.value===null&&N(),o.actions.closeCombobox()}),D=Ln(W=>{var P,G,Z;let X=(P=W.relatedTarget)!=null?P:oh.find(Y=>Y!==W.currentTarget);(G=o.state.buttonElement)!=null&&G.contains(X)||(Z=o.state.optionsElement)!=null&&Z.contains(X)||s.disabled||s.immediate&&o.state.comboboxState!==Dn.Open&&C.microTask(()=>{br.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(Xl.Focus)})}),R=RI(),A=wWe(),{isFocused:F,focusProps:z}=Dle({autoFocus:h}),{isHovered:L,hoverProps:$}=Ele({isDisabled:f}),H=Bo(o,W=>W.optionsElement),M=np({open:y===Dn.Open,disabled:f,invalid:s.invalid,hover:L,focus:F,autofocus:h}),B=p$({ref:x,id:c,role:"combobox",type:m,"aria-controls":H==null?void 0:H.id,"aria-expanded":y===Dn.Open,"aria-activedescendant":Bo(o,o.selectors.activeDescendantId),"aria-labelledby":R,"aria-describedby":A,"aria-autocomplete":"list",defaultValue:(r=(n=e.defaultValue)!=null?n:s.defaultValue!==void 0?d==null?void 0:d(s.defaultValue):null)!=null?r:s.defaultValue,disabled:f||void 0,autoFocus:h,onCompositionStart:_,onCompositionEnd:k,onKeyDown:T,onChange:I,onFocus:D,onBlur:E},z,$);return pl()({ourProps:B,theirProps:g,slot:M,defaultTag:vGe,name:"Combobox.Input"})}let CGe="button";function SGe(e,t){let n=Rw("Combobox.Button"),r=qb("Combobox.Button"),[o,s]=v.useState(null),i=Bu(t,s,n.actions.setButtonElement),a=v.useId(),{id:c=`headlessui-combobox-button-${a}`,disabled:u=r.disabled||!1,autoFocus:d=!1,...f}=e,[h,m,g]=Bo(n,D=>[D.comboboxState,D.inputElement,D.optionsElement]),b=ece(m),x=h===Dn.Open;rKe(x,{trigger:o,action:v.useCallback(D=>{if(o!=null&&o.contains(D.target)||m!=null&&m.contains(D.target))return Ax.Ignore;let R=D.target.closest('[role="option"]:not([data-disabled])');return kf(R)?Ax.Select(R):g!=null&&g.contains(D.target)?Ax.Ignore:Ax.Close},[o,m,g]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let y=Ln(D=>{switch(D.key){case Ws.Space:case Ws.Enter:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&br.flushSync(()=>n.actions.openCombobox()),b();return;case Ws.ArrowDown:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(br.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:Po.First})),b();return;case Ws.ArrowUp:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(br.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:Po.Last})),b();return;case Ws.Escape:if(n.state.comboboxState!==Dn.Open)return;D.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&D.stopPropagation(),br.flushSync(()=>n.actions.closeCombobox()),b();return;default:return}}),w=MWe(()=>{n.state.comboboxState===Dn.Open?n.actions.closeCombobox():n.actions.openCombobox(),b()}),C=RI([c]),{isFocusVisible:N,focusProps:S}=Dle({autoFocus:d}),{isHovered:j,hoverProps:_}=Ele({isDisabled:u}),{pressed:k,pressProps:T}=XUe({disabled:u}),I=np({open:h===Dn.Open,active:k||h===Dn.Open,disabled:u,invalid:r.invalid,value:r.value,hover:j,focus:N}),E=p$({ref:i,id:c,type:sKe(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":g==null?void 0:g.id,"aria-expanded":h===Dn.Open,"aria-labelledby":C,disabled:u||void 0,autoFocus:d,onKeyDown:y},w,S,_,T);return pl()({ourProps:E,theirProps:f,slot:I,defaultTag:CGe,name:"Combobox.Button"})}let NGe="div",jGe=OP.RenderStrategy|OP.Static;function kGe(e,t){var n,r,o;let s=v.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:a=!1,anchor:c,portal:u=!1,modal:d=!0,transition:f=!1,...h}=e,m=Rw("Combobox.Options"),g=qb("Combobox.Options"),b=HKe(c);b&&(u=!0);let[x,y]=WKe(b),[w,C]=v.useState(null),N=UKe(),S=Bu(t,b?x:null,m.actions.setOptionsElement,C),[j,_,k,T,I]=Bo(m,V=>[V.comboboxState,V.inputElement,V.buttonElement,V.optionsElement,V.activationTrigger]),E=VP(_||k),D=VP(T),R=QKe(),[A,F]=bKe(f,w,R!==null?(R&X0.Open)===X0.Open:j===Dn.Open);UWe(A,_,m.actions.closeCombobox);let z=g.__demoMode?!1:d&&j===Dn.Open;fKe(z,D);let L=g.__demoMode?!1:d&&j===Dn.Open;qWe(L,{allowed:v.useCallback(()=>[_,k,T],[_,k,T])});let $=Bo(m,m.selectors.didInputMove)?!1:A;vo(()=>{var V;g.optionsPropsRef.current.static=(V=e.static)!=null?V:!1},[g.optionsPropsRef,e.static]),vo(()=>{g.optionsPropsRef.current.hold=a},[g.optionsPropsRef,a]),CKe(j===Dn.Open,{container:T,accept(V){return V.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:V.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(V){V.setAttribute("role","none")}});let H=RI([k==null?void 0:k.id]),M=np({open:j===Dn.Open,option:void 0}),B=Ln(()=>{m.actions.setActivationTrigger(Xl.Pointer)}),W=Ln(V=>{V.preventDefault(),m.actions.setActivationTrigger(Xl.Pointer)}),P=p$(b?N():{},{"aria-labelledby":H,role:"listbox","aria-multiselectable":g.mode===Fi.Multi?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":fq(A,_,!0).width,"--button-width":fq(A,k,!0).width},onWheel:I===Xl.Pointer?void 0:B,onMouseDown:W,...gKe(F)}),G=A&&j===Dn.Closed&&!e.static,Z=qP(G,(n=g.virtual)==null?void 0:n.options),X=qP(G,g.value),Y=v.useCallback(V=>g.compare(X,V),[g.compare,X]),O=v.useMemo(()=>{if(!g.virtual)return g;if(Z===void 0)throw new Error("Missing `options` in virtual mode");return Z!==g.virtual.options?{...g,virtual:{...g.virtual,options:Z}}:g},[g,Z,(r=g.virtual)==null?void 0:r.options]);g.virtual&&Object.assign(h,{children:v.createElement(Q0.Provider,{value:O},v.createElement(bGe,{slot:M},h.children))});let q=pl(),U=v.useMemo(()=>g.mode===Fi.Multi?g:{...g,isSelected:Y},[g,Y]);return v.createElement(fGe,{enabled:u?e.static||A:!1,ownerDocument:E},v.createElement(Q0.Provider,{value:U},q({ourProps:P,theirProps:{...h,children:v.createElement(XKe,{freeze:G},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,M):h.children)},slot:M,defaultTag:NGe,features:jGe,visible:$,name:"Combobox.Options"})))}let _Ge="div";function IGe(e,t){var n,r,o;let s=qb("Combobox.Option"),i=Rw("Combobox.Option"),a=v.useId(),{id:c=`headlessui-combobox-option-${a}`,value:u,disabled:d=(o=(r=(n=s.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,u))!=null?o:!1,order:f=null,...h}=e,[m]=Bo(i,F=>[F.inputElement]),g=ece(m),b=Bo(i,v.useCallback(F=>i.selectors.isActive(F,u,c),[u,c])),x=s.isSelected(u),y=v.useRef(null),w=tp({disabled:d,value:u,domRef:y,order:f}),C=v.useContext(dce),N=Bu(t,y,C?C.measureElement:null),S=Ln(()=>{i.actions.setIsTyping(!1),i.actions.onChange(u)});vo(()=>i.actions.registerOption(c,w),[w,c]);let j=Bo(i,v.useCallback(F=>i.selectors.shouldScrollIntoView(F,u,c),[u,c]));vo(()=>{if(j)return Da().requestAnimationFrame(()=>{var F,z;(z=(F=y.current)==null?void 0:F.scrollIntoView)==null||z.call(F,{block:"nearest"})})},[j,y]);let _=Ln(F=>{F.preventDefault(),F.button===x$.Left&&(d||(S(),BP()||requestAnimationFrame(()=>g()),s.mode===Fi.Single&&i.actions.closeCombobox()))}),k=Ln(()=>{if(d)return i.actions.goToOption({focus:Po.Nothing});let F=s.calculateIndex(u);i.actions.goToOption({focus:Po.Specific,idx:F})}),T=hKe(),I=Ln(F=>T.update(F)),E=Ln(F=>{if(!T.wasMoved(F)||d||b&&i.state.activationTrigger===Xl.Pointer)return;let z=s.calculateIndex(u);i.actions.goToOption({focus:Po.Specific,idx:z},Xl.Pointer)}),D=Ln(F=>{T.wasMoved(F)&&(d||b&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===Xl.Pointer&&i.actions.goToOption({focus:Po.Nothing})))}),R=np({active:b,focus:b,selected:x,disabled:d}),A={id:c,ref:N,role:"option",tabIndex:d===!0?void 0:-1,"aria-disabled":d===!0?!0:void 0,"aria-selected":x,disabled:void 0,onMouseDown:_,onFocus:k,onPointerEnter:I,onMouseEnter:I,onPointerMove:E,onMouseMove:E,onPointerLeave:D,onMouseLeave:D};return pl()({ourProps:A,theirProps:h,slot:R,defaultTag:_Ge,name:"Combobox.Option"})}let TGe=gl(yGe),fce=gl(SGe),hce=gl(wGe),EGe=TWe,mce=gl(kGe),pce=gl(IGe),DGe=Object.assign(TGe,{Input:hce,Button:fce,Label:EGe,Options:mce,Option:pce});const MGe="var(--semaphor-control-radius, var(--radius, 0.3125rem))",UP="max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)",RGe="var(--semaphor-radius, var(--semaphor-control-radius, var(--radius, 0.3125rem)))",AGe=v.memo(({option:e})=>l.jsxs(pce,{style:{borderRadius:UP},value:e,className:p.cn("group mx-1 my-1 flex cursor-default select-none items-center gap-3 px-3 py-2.5","text-sm text-foreground transition-colors","data-[selected]:bg-primary/8 data-[focus]:bg-muted/80 data-[selected]:text-foreground"),children:[l.jsx("span",{className:p.cn("flex size-5 shrink-0 items-center justify-center rounded-full border border-border bg-background text-transparent transition-colors","group-data-[selected]:border-primary group-data-[selected]:bg-primary group-data-[selected]:text-primary-foreground","group-data-[focus]:border-muted-foreground/60"),children:l.jsx(p.Check,{className:"size-3.5"})}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.value})]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value),gce=v.forwardRef(({className:e,style:t,children:n,...r},o)=>{const{scopeProps:s}=p.useAppearance();return l.jsx("div",{className:p.cn("semaphor-scope",s.className),"data-semaphor-theme":s["data-semaphor-theme"],"data-semaphor-appearance-instance":s["data-semaphor-appearance-instance"],style:s.style,children:l.jsx("div",{ref:o,className:e,style:t,...r,children:n})})});gce.displayName="ScopedComboboxOptionsPanel";function PGe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:o,selectAllChecked:s,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:c,showNegativeIndicator:u,isSearching:d,isLoadingOptions:f=!1,resultSource:h="local",searchError:m,query:g,onQueryChange:b,filterDataType:x,onEnterKey:y,activeFilterValue:w,filterTitle:C,onClear:N,hasActiveFilter:S,placeholder:j,closedDisplayFallback:_,searchPlaceholder:k,selectedCount:T=0}){const[I,E]=v.useState(""),D=v.useRef(null),[R,A]=v.useState(null),F=g!==void 0?g:I,z=b||E,L=o||e;v.useLayoutEffect(()=>{const O=D.current;if(!O)return;const q=()=>{const V=Math.ceil(O.getBoundingClientRect().width);A(K=>K===V?K:V)};if(q(),typeof ResizeObserver>"u")return;const U=new ResizeObserver(()=>{q()});return U.observe(O),()=>{U.disconnect()}},[]);function $(O,q){if(q)return"";const U=[">","<",">=","<=","="];if((x?p.isNumberDataType(x):!1)&&w&&U.includes(w.operation))return`${w.operation}${w.values[0]}`;if(_)return _;const K=Array.isArray(O)?O:O?[O]:[];return K.length?K.map(Q=>Q.value).join(", "):""}function H(O){if(O===null){t([]);return}Array.isArray(O)||(O=[O]),t(O)}const M=r?n:n[0]??null;function B(){return d||f||L&&L.length>0?null:l.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function W(){return d&&(L==null?void 0:L.length)>0?l.jsxs("div",{className:"mx-1 mb-2 flex items-center gap-2 rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):m&&F?l.jsx("div",{className:"mx-1 mb-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600 dark:text-amber-400",children:"Search unavailable. Showing available results."}):null}function P(){return f?l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((O,q)=>l.jsx("div",{style:{borderRadius:UP},className:"h-11 bg-muted/70","aria-hidden":"true"},q))})]}):!d||(L==null?void 0:L.length)>0?null:l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((O,q)=>l.jsx("div",{style:{borderRadius:UP},className:"h-11 bg-muted/70","aria-hidden":"true"},q))})]})}function G(){return null}function Z(){return!r||!(L!=null&&L.length)||f?null:l.jsxs("div",{className:"flex items-center justify-between gap-3 border-y border-border/80 px-5 py-3",children:[c==null?void 0:c(),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-muted-foreground",children:"All"}),l.jsx(Tn,{className:"size-5 rounded-control border-input text-primary data-[state=checked]:bg-primary",checked:s,onCheckedChange:i})]})]})}function X(){return C?l.jsxs("div",{className:"flex items-center justify-between px-5 pb-3 pt-4",children:[l.jsx("span",{className:"text-[15px] font-semibold text-foreground",children:C}),S&&N&&l.jsx("button",{onClick:O=>{O.stopPropagation(),N()},className:"text-sm font-medium text-muted-foreground transition-colors hover:text-foreground","aria-label":"Clear filter",children:"Clear all"})]}):null}function Y(){if(!r||f)return null;const O=Math.max(T,n.length);return l.jsx("div",{className:"border-t border-border/80 bg-muted/35 px-5 py-3 text-sm text-muted-foreground",children:`${O} selected`})}return l.jsx(DGe,{immediate:!0,multiple:r,value:M,onChange:H,onClose:()=>{z("")},by:(O,q)=>Array.isArray(O)||Array.isArray(q)?!1:!O||!q?O===q:O.id===q.id,children:({open:O})=>l.jsxs("div",{children:[l.jsxs("div",{ref:D,className:"relative flex items-center gap-0.5",children:[l.jsx(Ft.Search,{className:"pointer-events-none absolute left-3 size-4 text-muted-foreground"}),l.jsx(hce,{className:p.cn("h-10 w-full cursor-default border border-input bg-background py-2 pl-10 pr-10 text-sm text-foreground shadow-sm transition-colors","hover:border-input/80 focus:border-ring",u&&"border-destructive/35 bg-destructive/[0.03] hover:border-destructive/45 focus:border-destructive/45","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:MGe},placeholder:O?k||"Search options...":j,displayValue:q=>$(q,O),onChange:q=>z(q.target.value),onKeyDown:q=>{if(q.key==="Enter"&&y){const U=/^(>=|<=|>|<|=)/.test(F.trim()),V=x?p.isNumberDataType(x):!1;U&&V&&(q.preventDefault(),y()&&q.target.blur())}}}),l.jsx(fce,{className:"group absolute inset-y-0 right-0 px-2.5",children:l.jsx(je.ChevronDown,{className:"size-4 text-muted-foreground transition-colors group-hover:text-foreground"})})]}),l.jsxs(mce,{as:gce,anchor:"bottom",transition:!0,style:{borderRadius:RGe,width:R?`${R}px`:"16rem"},className:p.clsx$1("mt-2 overflow-hidden border border-border/80 bg-popover text-sm text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] [--anchor-gap:var(--spacing-2)] empty:invisible dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[X(),Z(),l.jsxs("div",{className:"max-h-72 overflow-y-auto px-2 py-2",children:[W(),P(),G(),B(),!f&&(L==null?void 0:L.map(q=>l.jsx(AGe,{option:q},q.id)))]}),Y()]})]})})}const Fq=[{value:"=",label:"Equal to",symbol:"="},{value:">",label:"Greater than",symbol:">"},{value:">=",label:"Greater than or equal",symbol:"≥"},{value:"<",label:"Less than",symbol:"<"},{value:"<=",label:"Less than or equal",symbol:"≤"},{value:"between",label:"Between",symbol:"⟷"},{value:"not between",label:"Not Between",symbol:"⇎"}],FGe=new Set(["=",">","<",">=","<=","between","not between"]);function OGe(e){return FGe.has(e)?e:">="}function LGe({filter:e,storageOptions:t}){var G;const{cardId:n,dashboardInput:r,inlineFilterValues:o,removeInlineFilterValue:s,sheetId:i,setInlineFilterValue:a,storageTarget:c}=t??{},u=c==="card",d=c==="dashboardInput",[f,h]=v.useState(">="),[m,g]=v.useState(""),[b,x]=v.useState(""),[y,w]=v.useState(""),[C,N]=v.useState(!0),S=v.useRef(null),j=v.useRef(!1),[,_]=v.useTransition(),k=Jy(m,300),T=Jy(b,300),I=Jy(y,300),E=p.useDashboardStore(Z=>Z.filterValues),D=p.useDashboardStore(Z=>Z.dashboard),R=p.useDashboardStore(Z=>Z.dashboardInputValues);p.useDashboardStore(Z=>Z.themeStyle);const A=p.useDashboardStore(Z=>Z.actions.setDashboardInputSlot),F=p.useDashboardStore(Z=>Z.actions.clearDashboardInputSlot),z=p.useDashboardStore(Z=>Z.actions.setCardInlineFilterValue),L=p.useDashboardStore(Z=>Z.actions.removeCardInlineFilterValue),{addOrUpdateFilterValue:$,removeFilterValues:H}=p.useDashboardActions(),M=v.useMemo(()=>{if(!d||!r)return;const Z=p.hydrateAuthoredDashboardInputSlot({dashboard:D,input:r,runtimeValues:R,target:{sheetId:i}});return(Z==null?void 0:Z.status)==="set"&&Z.value.kind==="filter"?Z.value.filterValue:void 0},[D,R,d,r,i]),B=v.useMemo(()=>d?M?[M]:[]:u?o:E,[E,M,o,u,d]),W=v.useCallback(Z=>{if(d){if(!r)return;const X=p.createFilterDashboardInputSlot(Z);if(!X)return;A(r,{sheetId:i},X);return}if(u){if(a){a(Z);return}z(n??"",Z)}else $(Z)},[d,r,i,A,u,a,z,n,$]),P=v.useCallback(()=>{if(d){if(!r)return;F(r,{sheetId:i});return}if(u){if(s){s(e.id);return}L(n??"",e.id)}else H(e.id)},[d,r,i,F,u,e.id,s,L,n,H]);return v.useEffect(()=>()=>{S.current=null,j.current=!1},[]),v.useEffect(()=>{const Z=B==null?void 0:B.find(X=>X.filterId===e.id);if(Z&&Z.operation!=="in"){const X=OGe(Z.operation);if(S.current!==X&&(h(X),S.current=X,j.current=!1),X==="between"||X==="not between"){const O=Z.values[0],q=Z.values[1];x(O!=null?String(O):""),w(q!=null?String(q):""),g("")}else{const O=Z.values[0];g(O!=null?String(O):""),x(""),w("")}}else S.current!==null&&(g(""),x(""),w(""),!j.current&&S.current!==f&&(h(">="),j.current=!1),S.current=null),N(!1)},[B,e.id,f]),v.useEffect(()=>{C&&(f==="between"||f==="not between"?T===b&&I===y&&N(!1):k===m&&N(!1))},[C,f,m,k,b,y,T,I]),v.useEffect(()=>{if(!C)if(f==="between"||f==="not between"){const Z=T&&T.trim()!=="",X=I&&I.trim()!=="";if(!Z||!X){!Z&&!X&&(_(()=>{P()}),S.current=f);return}const Y=Number(T),O=Number(I);if(isNaN(Y)||isNaN(O))return;const q={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[Y,O],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};_(()=>{W(q)}),S.current=f}else{if(!k||k.trim()===""){_(()=>{P()}),S.current=null;return}const Z=Number(k);if(isNaN(Z))return;const X={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[Z],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};_(()=>{W(X)}),S.current=f}},[f,k,T,I,e.id,e.column,e.database,C,W,P,e]),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs(p.Select,{value:f,onValueChange:Z=>{j.current=!0,h(Z)},children:[l.jsx(p.SelectTrigger,{className:"h-7 w-14 shrink-0 border-input bg-background text-[12px]",children:l.jsx("span",{className:"font-mono text-[13px]",children:(G=Fq.find(Z=>Z.value===f))==null?void 0:G.symbol})}),l.jsx(p.SelectContent,{children:Fq.map(Z=>l.jsx(p.SelectItem,{value:Z.value,children:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-mono text-[12px]",children:Z.symbol}),l.jsx("span",{className:"text-[12px]",children:Z.label})]})},Z.value))})]}),f==="between"||f==="not between"?l.jsxs(l.Fragment,{children:[l.jsx(p.Input,{type:"number",placeholder:"Min",value:b,onChange:Z=>x(Z.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"}),l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"–"}),l.jsx(p.Input,{type:"number",placeholder:"Max",value:y,onChange:Z=>w(Z.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]}):l.jsx(p.Input,{type:"number",placeholder:"Value",value:m,onChange:Z=>g(Z.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]})}function S$({isCardStorage:e=!1,message:t="Error",className:n}){return l.jsx("div",{className:p.cn("flex w-full items-center bg-muted px-2 text-sm",e?"h-8":"h-9",n),children:t})}function bce({filter:e,storageOptions:t}){var $,H;const n=e.searchMode==="numeric",r=(t==null?void 0:t.storageTarget)==="card",o=r?"h-8":"h-9",s=r?"h-[31px]":"h-[35px]",{removeFilterValues:i}=p.useDashboardActions(),a=p.useDashboardStore(M=>M.actions.removeCardInlineFilterValue),{filteredRecords:c,isSingleSelect:u,allSelected:d,handleChange:f,handleSelectAll:h,handleApplyOperatorExpression:m,query:g,setQuery:b,isLoading:x,isFetching:y,isPlaceholderData:w,isError:C,selectedRecords:N,isSearching:S,searchError:j,resultSource:_,activeFilterValue:k}=Vb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),I=x||y&&w,E=k&&(k.operation==="in"||k.operation==="not in")&&(($=k.values)!=null&&$.length)?k.values.map(M=>String(M)).join(", "):void 0,D=(k==null?void 0:k.operation)==="not in"||e.operation==="not in",A=`Search ${(e.title||e.column||"options").toLowerCase()}`,{clearDashboardInputSlot:F}=p.useDashboardActions(),z=v.useCallback(()=>{if((t==null?void 0:t.storageTarget)==="dashboardInput"&&t.dashboardInput){F(t.dashboardInput,{sheetId:t.sheetId});return}if((t==null?void 0:t.storageTarget)==="card"&&(t!=null&&t.cardId)){if(t.removeInlineFilterValue){t.removeInlineFilterValue(e.id);return}a(t.cardId,e.id)}else i(e.id)},[t,e.id,F,i,a]);return x&&!E?l.jsx(Xs,{className:p.cn(s,"w-full rounded-control bg-foreground/10")}):C?l.jsx(S$,{isCardStorage:r}):n?l.jsx(LGe,{filter:e,storageOptions:t}):l.jsx(PGe,{showNegativeIndicator:D,renderFilterModeButton:()=>l.jsx(xce,{filter:e,storageOptions:t}),inputClassName:o,options:c,selectedOptions:N,onChange:f,multiple:!u,selectAllChecked:d,onSelectAllCheckedChange:h,isSearching:S,isLoadingOptions:I,resultSource:_,searchError:j,query:g,onQueryChange:b,filterDataType:e.dataType,activeFilterValue:k,onEnterKey:m,filterTitle:e.title||e.column,onClear:z,hasActiveFilter:!!k,placeholder:e.showLabel===!1?e.title||e.column:void 0,closedDisplayFallback:E,searchPlaceholder:A,selectedCount:((H=k==null?void 0:k.values)==null?void 0:H.length)??N.length})}function xce({filter:e,storageOptions:t}){const n={borderRadius:"max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)"},r=(t==null?void 0:t.storageTarget)==="card",o=(t==null?void 0:t.storageTarget)==="dashboardInput",{setFilterMode:s}=p.useDashboardActions(),i=p.useDashboardStore(N=>N.dashboard),a=p.useDashboardStore(N=>N.dashboardInputValues),c=p.useDashboardStore(N=>N.isVisualEditing),u=p.useDashboardStore(N=>N.actions.setDashboardInputSlot),d=p.useDashboardStore(N=>N.actions.upsertDashboardInput),f=p.useDashboardStore(N=>N.actions.setCardInlineFilterMode),h=p.useDashboardStore(N=>N.actions.setCardInlineFilterValue),m=p.useEditorStore(N=>N.card),{setCard:g}=p.useEditorActions(),b=v.useMemo(()=>{if(!o||!(t!=null&&t.dashboardInput))return;const N=p.hydrateAuthoredDashboardInputSlot({dashboard:i,input:t.dashboardInput,runtimeValues:a,target:{sheetId:t.sheetId}});return(N==null?void 0:N.status)==="set"&&N.value.kind==="filter"?N.value.filterValue:void 0},[i,a,o,t==null?void 0:t.dashboardInput,t==null?void 0:t.sheetId]),y=(b&&(b.operation==="in"||b.operation==="not in")?b.operation:e.operation)==="not in"?"exclude":"include";function w(N){var j;if(N===y)return;const S=N==="exclude"?"not in":"in";if(o){if(!(t!=null&&t.dashboardInput)||t.dashboardInput.kind!=="filter")return;const _=t.dashboardInput;if(d({..._,filter:{..._.filter,operation:S}}),(j=b==null?void 0:b.values)!=null&&j.length){const k={...b,operation:S},T=p.createFilterDashboardInputSlot(k);T&&u(_,{sheetId:t.sheetId},T)}return}if(r){if(t!=null&&t.setInlineFilterMode){t.setInlineFilterMode(e.id,N);return}if(c){const _=(m.inlineFilters||[]).map(T=>T.id===e.id?{...T,operation:S}:T);g({...m,inlineFilters:_});const k=C==null?void 0:C.find(T=>T.filterId===e.id);if(k&&(k.operation==="in"||k.operation==="not in")){const T={...k,operation:S};t!=null&&t.setInlineFilterValue?t.setInlineFilterValue(T):h((t==null?void 0:t.cardId)??"",T)}}else f((t==null?void 0:t.sheetId)??"",(t==null?void 0:t.cardId)??"",e.id,N)}else s(e.id,N)}const C=t==null?void 0:t.inlineFilterValues;return l.jsxs("div",{className:"inline-flex items-center gap-0.5 rounded-control bg-muted/80 p-0.5",children:[l.jsx(p.Button,{onClick:()=>w("include"),variant:"ghost",size:"sm",style:n,className:p.cn("h-6 px-3 text-[12px] font-medium leading-none text-muted-foreground",y==="include"&&"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 hover:text-primary-foreground",y!=="include"&&"hover:bg-background/80 hover:text-foreground"),children:"Include"}),l.jsx(p.Button,{onClick:()=>w("exclude"),variant:"ghost",size:"sm",style:n,className:p.cn("h-6 px-3 text-[12px] font-medium leading-none text-muted-foreground",y==="exclude"&&"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:text-destructive-foreground",y!=="exclude"&&"hover:bg-background/80 hover:text-foreground"),children:"Exclude"})]})}function yce({filter:e,storageOptions:t}){var a;const{filteredRecords:n,handleChange:r,selectedRecords:o}=Vb(e,t),s=((a=o==null?void 0:o[0])==null?void 0:a.value)||"";function i(c){r([{value:c,id:c}])}return l.jsx(rl,{onValueChange:i,value:s,className:"flex flex-col gap-0.5",children:n==null?void 0:n.map(c=>{const u=`radio-${e.id}-${c.value}`,d=s===c.value;return l.jsxs(p.Label,{htmlFor:u,className:p.cn("flex w-full cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-[13px] transition-colors",d?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:[l.jsx(vs,{value:c.value,id:u,className:"h-3.5 w-3.5"}),l.jsx("span",{className:"truncate",children:c.value})]},c.value)})})}function vce({filter:e,storageOptions:t}){var h;const n=(t==null?void 0:t.storageTarget)==="card",{filteredRecords:r,handleChange:o,selectedRecords:s,isLoading:i,isFetching:a,isError:c}=Vb(e,t),u=((h=s==null?void 0:s[0])==null?void 0:h.value)||"",d=r&&r.length>10;function f(m){o([{value:m,id:m}])}return i||a?l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((m,g)=>l.jsx(Xs,{className:"h-7 w-full rounded-control bg-foreground/[0.06]"},g))}):c?l.jsx(S$,{isCardStorage:n,message:"Error loading filter options"}):l.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("div",{className:"mb-1 inline-flex items-center gap-1 rounded-[4px] bg-amber-500/10 px-1.5 py-0.5 text-[11px] text-amber-700 dark:text-amber-300",children:[l.jsx(p.Info,{className:"h-3 w-3"}),l.jsxs("span",{children:["Many options (",r.length,")"]})]})}),l.jsx(p.TooltipContent,{side:"bottom",className:"max-w-xs",children:l.jsxs("p",{className:"text-xs",children:["This filter has ",r.length," options. Consider switching to a dropdown for better usability with many options."]})})]})}),l.jsx("div",{role:"radiogroup",className:"flex flex-col gap-0.5",children:r==null?void 0:r.map(m=>{const g=u===m.value;return l.jsx("button",{type:"button",role:"radio","aria-checked":g,onClick:()=>f(m.value),className:p.cn("flex w-full items-center rounded-control px-2 py-1.5 text-left text-[13px] transition-colors",g?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:l.jsx("span",{className:"truncate",children:m.value})},m.value)})})]})}const $Ge=v.createContext(null),uM={didCatch:!1,error:null};class Si extends v.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=uM}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:s,reason:"imperative-api"}),this.setState(uM)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&zGe(t.resetKeys,o)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(uM)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(c);else if(r)a=v.createElement(r,c);else if(o!==void 0)a=o;else throw i}return v.createElement($Ge.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function zGe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function BGe(e,t){const[n,r]=v.useState(t),[o,s]=v.useState(),i=v.useMemo(()=>t,[t]);return v.useEffect(()=>{if(e&&(e==null?void 0:e.length)>0){const a=e[0];if(!a.min||!a.max)return;const c={from:new Date(a.min),to:new Date(a.max)};s(c),i||r(c)}},[e,i]),v.useEffect(()=>{i&&r(i)},[i]),{dateRange:n,setDateRange:r,initialDateRange:o,setInitialDateRange:s}}function VGe(e){const t=p.useDashboardStore(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}=N$(t||{});return r}function N$(e,t){const{cardId:n,dashboardInput:r,filterQueryContext:o,inlineFilterValues:s,removeInlineFilterValue:i,setInlineFilterValue:a,sheetId:c,storageTarget:u}=t??{},d=u==="card",f=u==="dashboardInput",h=p.useDashboardStore(O=>{var q;return((q=O.reportContext)==null?void 0:q.calendar)??null}),m=h==null?void 0:h.tz,g=p.useDashboardStore(O=>O.filterValues),b=p.useDashboardStore(O=>O.dashboard),x=p.useDashboardStore(O=>O.dashboardInputValues),y=v.useMemo(()=>{if(!f||!r)return;const O={sheetId:c};return p.hydrateAuthoredDashboardInputSlot({dashboard:b,input:r,runtimeValues:x,target:O,timezone:m})},[b,x,f,r,c,m]),w=v.useMemo(()=>{if(!(!f||!r))return Yi({dashboard:b,sheetId:c,sheetKind:"dashboard",runtimeValues:{dashboardInputValues:x},timezone:m}).activeFilters},[b,x,f,r,c,m]),C=p.useDashboardStore(O=>O.actions.addOrUpdateFilterValue),N=p.useDashboardStore(O=>O.actions.setDashboardInputSlot),S=p.useDashboardStore(O=>O.actions.clearDashboardInputSlot),j=p.useDashboardStore(O=>O.actions.setCardInlineFilterValue),_=p.useDashboardStore(O=>O.actions.removeCardInlineFilterValue),{removeFilterValues:k}=p.useDashboardActions(),T=(y==null?void 0:y.status)==="set"&&y.value.kind==="filter"?y.value.filterValue:void 0,I=v.useMemo(()=>f?T?[T]:[]:d?s:g,[T,g,s,d,f]),E=I==null?void 0:I.find(O=>O.filterId===e.id),D=v.useMemo(()=>f?{...o,activeFilterValues:w}:o,[w,o,f]),{data:R,isLoading:A,isFetching:F,isError:z}=c$(e,{additionalFilterValues:d?s:void 0,filterQueryContext:D}),L=v.useCallback(O=>{if(f){if(!r)return;const q=p.createFilterDashboardInputSlot(O);if(!q)return;N(r,{sheetId:c},q);return}if(d){if(a){a(O);return}if(!n)return;j(n,O)}else C(O)},[f,r,c,N,d,a,j,n,C]),$=v.useCallback(()=>{if(f){if(!r)return;S(r,{sheetId:c});return}if(d){if(i){i(e.id);return}if(!n)return;_(n,e.id)}else k(e.id)},[f,r,c,S,d,e.id,i,_,n,k]),H=v.useMemo(()=>{const O=U=>{if(!U)return;const V=U instanceof Date?U:new Date(U);return isNaN(V.getTime())?void 0:V};if(!E||!Array.isArray(E.values))return;const q=E.operation;if((q==="between"||q==="not between")&&E.values.length===2){const[U,V]=E.values,K=O(U),Q=O(V);return!K&&!Q?void 0:{from:K,to:Q}}if(["=","!=",">",">=","<","<="].includes(q)&&E.values.length===1){const[U]=E.values,V=O(U);return V?{from:V,to:V}:void 0}},[E]),{dateRange:M,setDateRange:B,initialDateRange:W}=BGe(R==null?void 0:R.records,H);function P(){$(),B(void 0)}function G(){B(W)}function Z(O,q="between",U={}){if(!O)return;if(q==="is null"||q==="is not null"){B(void 0),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:q,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext});return}if(q==="between"||q==="not between"){const K=p.normalizeDateFilterRange(O,{temporalPrecision:U.temporalPrecision});B({from:K.from,to:K.to}),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:q,values:K.values,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...U.temporalPrecision?{temporalPrecision:U.temporalPrecision}:{}});return}const V=O.from||O.to;V&&(B({from:V,to:V}),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:q,values:[V],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...U.temporalPrecision?{temporalPrecision:U.temporalPrecision}:{}}))}function X(O){B(void 0),L({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:O,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext})}function Y(O,q,U={}){if(!O)return;const V=U.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(q),K=p.normalizeDateFilterRange(O,{temporalPrecision:V});B({from:K.from,to:K.to});const Q={filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:"between",values:K.values,relativeMeta:q,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...V?{temporalPrecision:V}:{}};L(Q)}return{records:R==null?void 0:R.records,isLoading:A,isFetching:F,isError:z,initialDateRange:W,dateRange:M,setDateRange:B,activeFilterValue:E,handleClear:P,handleChange:Z,handleNullOperation:X,handleRelativeChange:Y,handleReset:G}}function Aw(e){var n;const t=e.scheme.tokens;return{colors:[...e.chartPalette],mode:e.mode,appearance:{version:cf.APPEARANCE_SPEC_VERSION,mode:e.mode,colors:Ks(e.colorValues),typography:Ks(t==null?void 0:t.typography),radius:Ks(t==null?void 0:t.radius),spacing:Ks(t==null?void 0:t.spacing),shadow:Ks(t==null?void 0:t.shadow),density:(n=t==null?void 0:t.typography)==null?void 0:n.density,chartPalette:[...e.chartPalette],table:Ks(e.table)}}}function HGe(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const dM={},xy={};function xh(e,t){try{const r=(dM[e]||(dM[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in xy?xy[r]:Oq(r,r.split(":"))}catch{if(e in xy)return xy[e];const n=e==null?void 0:e.match(qGe);return n?Oq(e,n.slice(1)):NaN}}const qGe=/([+-]\d\d):?(\d\d)?/;function Oq(e,t){const n=+(t[0]||0),r=+(t[1]||0),o=+(t[2]||0)/60;return xy[e]=n*60+r>0?n*60+r+o:n*60-r-o}class Vl extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(xh(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),wce(this),WP(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new Vl(...n,t):new Vl(Date.now(),t)}withTimeZone(t){return new Vl(+this,t)}getTimezoneOffset(){const t=-xh(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),WP(this),+this}[Symbol.for("constructDateFrom")](t){return new Vl(+new Date(t),this.timeZone)}}const Lq=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!Lq.test(e))return;const t=e.replace(Lq,"$1UTC");Vl.prototype[t]&&(e.startsWith("get")?Vl.prototype[e]=function(){return this.internal[t]()}:(Vl.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),UGe(this),+this},Vl.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),WP(this),+this}))});function WP(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-xh(e.timeZone,e)*60))}function UGe(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),wce(e)}function wce(e){const t=xh(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const o=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=o-s,a=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&a&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=o-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const u=new Date(+e);u.setUTCSeconds(0);const d=o>0?u.getSeconds():(u.getSeconds()-60)%60,f=Math.round(-(xh(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=xh(e.timeZone,e),m=h>0?Math.floor(h):Math.ceil(h),b=-new Date(+e).getTimezoneOffset()-m,x=m!==n,y=b-c;if(x&&y){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+y);const w=xh(e.timeZone,e),C=w>0?Math.floor(w):Math.ceil(w),N=m-C;N&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+N),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+N))}}class Qc extends Vl{static tz(t,...n){return n.length?new Qc(...n,t):new Qc(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),o=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+o}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,o]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${o}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,o]=this.tzComponents();return`${t} GMT${n}${r}${o} (${HGe(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),o=String(Math.abs(t)%60).padStart(2,"0");return[n,r,o]}withTimeZone(t){return new Qc(+this,t)}[Symbol.for("constructDateFrom")](t){return new Qc(+new Date(t),this.timeZone)}}const Cce=6048e5,WGe=864e5,$q=Symbol.for("constructDateFrom");function wo(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&$q in e?e[$q](t):e instanceof Date?new e.constructor(t):new Date(t)}function hr(e,t){return wo(t||e,e)}function Sce(e,t,n){const r=hr(e,n==null?void 0:n.in);return isNaN(t)?wo(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Nce(e,t,n){const r=hr(e,n==null?void 0:n.in);if(isNaN(t))return wo(e,NaN);if(!t)return r;const o=r.getDate(),s=wo(e,r.getTime());s.setMonth(r.getMonth()+t+1,0);const i=s.getDate();return o>=i?s:(r.setFullYear(s.getFullYear(),s.getMonth(),o),r)}let KGe={};function Pw(){return KGe}function eb(e,t){var a,c,u,d;const n=Pw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=hr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?7:0)+s-r;return o.setDate(o.getDate()-i),o.setHours(0,0,0,0),o}function J0(e,t){return eb(e,{...t,weekStartsOn:1})}function jce(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getFullYear(),o=wo(n,0);o.setFullYear(r+1,0,4),o.setHours(0,0,0,0);const s=J0(o),i=wo(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=J0(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function zq(e){const t=hr(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Ub(e,...t){const n=wo.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function ev(e,t){const n=hr(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function kce(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t),s=ev(r),i=ev(o),a=+s-zq(s),c=+i-zq(i);return Math.round((a-c)/WGe)}function GGe(e,t){const n=jce(e,t),r=wo(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),J0(r)}function YGe(e,t,n){return Sce(e,t*7,n)}function ZGe(e,t,n){return Nce(e,t*12,n)}function XGe(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=wo.bind(null,o));const s=hr(o,r);(!n||n<s||isNaN(+s))&&(n=s)}),wo(r,n||NaN)}function QGe(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=wo.bind(null,o));const s=hr(o,r);(!n||n>s||isNaN(+s))&&(n=s)}),wo(r,n||NaN)}function JGe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t);return+ev(r)==+ev(o)}function _ce(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function eYe(e){return!(!_ce(e)&&typeof e!="number"||isNaN(+hr(e)))}function tYe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t),s=r.getFullYear()-o.getFullYear(),i=r.getMonth()-o.getMonth();return s*12+i}function nYe(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Ice(e,t){const[n,r]=Ub(e,t.start,t.end);return{start:n,end:r}}function rYe(e,t){const{start:n,end:r}=Ice(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setDate(1);let a=1;const c=[];for(;+i<=s;)c.push(wo(n,i)),i.setMonth(i.getMonth()+a);return o?c.reverse():c}function oYe(e,t){const n=hr(e,t==null?void 0:t.in);return n.setDate(1),n.setHours(0,0,0,0),n}function sYe(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Tce(e,t){const n=hr(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function iYe(e,t){const{start:n,end:r}=Ice(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setMonth(0,1);let a=1;const c=[];for(;+i<=s;)c.push(wo(n,i)),i.setFullYear(i.getFullYear()+a);return o?c.reverse():c}function Ece(e,t){var a,c,u,d;const n=Pw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=hr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?-7:0)+6-(s-r);return o.setDate(o.getDate()+i),o.setHours(23,59,59,999),o}function aYe(e,t){return Ece(e,{...t,weekStartsOn:1})}const lYe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},cYe=(e,t,n)=>{let r;const o=lYe[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function fM(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const uYe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},dYe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},fYe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hYe={date:fM({formats:uYe,defaultWidth:"full"}),time:fM({formats:dYe,defaultWidth:"full"}),dateTime:fM({formats:fYe,defaultWidth:"full"})},mYe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},pYe=(e,t,n,r)=>mYe[e];function Px(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):i;o=e.formattingValues[a]||e.formattingValues[i]}else{const i=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[a]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}const gYe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},bYe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},xYe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},yYe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},vYe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},wYe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},CYe=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},SYe={ordinalNumber:CYe,era:Px({values:gYe,defaultWidth:"wide"}),quarter:Px({values:bYe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Px({values:xYe,defaultWidth:"wide"}),day:Px({values:yYe,defaultWidth:"wide"}),dayPeriod:Px({values:vYe,defaultWidth:"wide",formattingValues:wYe,defaultFormattingWidth:"wide"})};function Fx(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;const i=s[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?jYe(a,f=>f.test(i)):NYe(a,f=>f.test(i));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(i.length);return{value:u,rest:d}}}function NYe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function jYe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function kYe(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const a=t.slice(o.length);return{value:i,rest:a}}}const _Ye=/^(\d+)(th|st|nd|rd)?/i,IYe=/\d+/i,TYe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},EYe={any:[/^b/i,/^(a|c)/i]},DYe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},MYe={any:[/1/i,/2/i,/3/i,/4/i]},RYe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},AYe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},PYe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},FYe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},OYe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},LYe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},$Ye={ordinalNumber:kYe({matchPattern:_Ye,parsePattern:IYe,valueCallback:e=>parseInt(e,10)}),era:Fx({matchPatterns:TYe,defaultMatchWidth:"wide",parsePatterns:EYe,defaultParseWidth:"any"}),quarter:Fx({matchPatterns:DYe,defaultMatchWidth:"wide",parsePatterns:MYe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Fx({matchPatterns:RYe,defaultMatchWidth:"wide",parsePatterns:AYe,defaultParseWidth:"any"}),day:Fx({matchPatterns:PYe,defaultMatchWidth:"wide",parsePatterns:FYe,defaultParseWidth:"any"}),dayPeriod:Fx({matchPatterns:OYe,defaultMatchWidth:"any",parsePatterns:LYe,defaultParseWidth:"any"})},j$={code:"en-US",formatDistance:cYe,formatLong:hYe,formatRelative:pYe,localize:SYe,match:$Ye,options:{weekStartsOn:0,firstWeekContainsDate:1}};function zYe(e,t){const n=hr(e,t==null?void 0:t.in);return kce(n,Tce(n))+1}function Dce(e,t){const n=hr(e,t==null?void 0:t.in),r=+J0(n)-+GGe(n);return Math.round(r/Cce)+1}function Mce(e,t){var d,f,h,m;const n=hr(e,t==null?void 0:t.in),r=n.getFullYear(),o=Pw(),s=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??o.firstWeekContainsDate??((m=(h=o.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=wo((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const a=eb(i,t),c=wo((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const u=eb(c,t);return+n>=+a?r+1:+n>=+u?r:r-1}function BYe(e,t){var a,c,u,d;const n=Pw(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=Mce(e,t),s=wo((t==null?void 0:t.in)||e,0);return s.setFullYear(o,0,r),s.setHours(0,0,0,0),eb(s,t)}function Rce(e,t){const n=hr(e,t==null?void 0:t.in),r=+eb(n,t)-+BYe(n,t);return Math.round(r/Cce)+1}function ir(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Xu={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ir(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ir(n+1,2)},d(e,t){return ir(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ir(e.getHours()%12||12,t.length)},H(e,t){return ir(e.getHours(),t.length)},m(e,t){return ir(e.getMinutes(),t.length)},s(e,t){return ir(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return ir(o,t.length)}},Np={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Bq={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return Xu.y(e,t)},Y:function(e,t,n,r){const o=Mce(e,r),s=o>0?o:1-o;if(t==="YY"){const i=s%100;return ir(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ir(s,t.length)},R:function(e,t){const n=jce(e);return ir(n,t.length)},u:function(e,t){const n=e.getFullYear();return ir(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ir(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ir(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Xu.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ir(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=Rce(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):ir(o,t.length)},I:function(e,t,n){const r=Dce(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ir(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Xu.d(e,t)},D:function(e,t,n){const r=zYe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ir(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ir(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ir(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return ir(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=Np.noon:r===0?o=Np.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=Np.evening:r>=12?o=Np.afternoon:r>=4?o=Np.morning:o=Np.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Xu.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Xu.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ir(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ir(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Xu.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Xu.s(e,t)},S:function(e,t){return Xu.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Hq(r);case"XXXX":case"XX":return Xf(r);case"XXXXX":case"XXX":default:return Xf(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Hq(r);case"xxxx":case"xx":return Xf(r);case"xxxxx":case"xxx":default:return Xf(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Vq(r,":");case"OOOO":default:return"GMT"+Xf(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Vq(r,":");case"zzzz":default:return"GMT"+Xf(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ir(r,t.length)},T:function(e,t,n){return ir(+e,t.length)}};function Vq(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),s=r%60;return s===0?n+String(o):n+String(o)+t+ir(s,2)}function Hq(e,t){return e%60===0?(e>0?"-":"+")+ir(Math.abs(e)/60,2):Xf(e,t)}function Xf(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=ir(Math.trunc(r/60),2),s=ir(r%60,2);return n+o+t+s}const qq=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},Ace=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},VYe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return qq(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",qq(r,t)).replace("{{time}}",Ace(o,t))},HYe={p:Ace,P:VYe},qYe=/^D+$/,UYe=/^Y+$/,WYe=["D","DD","YY","YYYY"];function KYe(e){return qYe.test(e)}function GYe(e){return UYe.test(e)}function YYe(e,t,n){const r=ZYe(e,t,n);if(console.warn(r),WYe.includes(e))throw new RangeError(r)}function ZYe(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const XYe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,QYe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,JYe=/^'([^]*?)'?$/,eZe=/''/g,tZe=/[a-zA-Z]/;function nZe(e,t,n){var d,f,h,m,g,b,x,y;const r=Pw(),o=(n==null?void 0:n.locale)??r.locale??j$,s=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(h=r.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((b=(g=n==null?void 0:n.locale)==null?void 0:g.options)==null?void 0:b.weekStartsOn)??r.weekStartsOn??((y=(x=r.locale)==null?void 0:x.options)==null?void 0:y.weekStartsOn)??0,a=hr(e,n==null?void 0:n.in);if(!eYe(a))throw new RangeError("Invalid time value");let c=t.match(QYe).map(w=>{const C=w[0];if(C==="p"||C==="P"){const N=HYe[C];return N(w,o.formatLong)}return w}).join("").match(XYe).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const C=w[0];if(C==="'")return{isToken:!1,value:rZe(w)};if(Bq[C])return{isToken:!0,value:w};if(C.match(tZe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:w}});o.localize.preprocessor&&(c=o.localize.preprocessor(a,c));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:o};return c.map(w=>{if(!w.isToken)return w.value;const C=w.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&GYe(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&KYe(C))&&YYe(C,t,String(e));const N=Bq[C[0]];return N(a,C,o.localize,u)}).join("")}function rZe(e){const t=e.match(JYe);return t?t[1].replace(eZe,"'"):e}function oZe(e,t){const n=hr(e,t==null?void 0:t.in),r=n.getFullYear(),o=n.getMonth(),s=wo(n,0);return s.setFullYear(r,o+1,0),s.setHours(0,0,0,0),s.getDate()}function sZe(e,t){return hr(e,t==null?void 0:t.in).getMonth()}function iZe(e,t){return hr(e,t==null?void 0:t.in).getFullYear()}function aZe(e,t){return+hr(e)>+hr(t)}function lZe(e,t){return+hr(e)<+hr(t)}function cZe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}function uZe(e,t,n){const[r,o]=Ub(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()}function dZe(e,t,n){const r=hr(e,n==null?void 0:n.in),o=r.getFullYear(),s=r.getDate(),i=wo(e,0);i.setFullYear(o,t,15),i.setHours(0,0,0,0);const a=oZe(i);return r.setMonth(t,Math.min(s,a)),r}function fZe(e,t,n){const r=hr(e,n==null?void 0:n.in);return isNaN(+r)?wo(e,NaN):(r.setFullYear(t),r)}const Uq=5,hZe=4;function mZe(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,o=t.addDays(e,-r+1),s=t.addDays(o,Uq*7-1);return t.getMonth(e)===t.getMonth(s)?Uq:hZe}function Pce(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-1*6):t.addDays(n,-1*(r-1))}function pZe(e,t){const n=Pce(e,t),r=mZe(e,t);return t.addDays(n,r*7-1)}class Wi{constructor(t,n){this.Date=Date,this.today=()=>{var r;return(r=this.overrides)!=null&&r.today?this.overrides.today():this.options.timeZone?Qc.tz(this.options.timeZone):new this.Date},this.newDate=(r,o,s)=>{var i;return(i=this.overrides)!=null&&i.newDate?this.overrides.newDate(r,o,s):this.options.timeZone?new Qc(r,o,s,this.options.timeZone):new Date(r,o,s)},this.addDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addDays?this.overrides.addDays(r,o):Sce(r,o)},this.addMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addMonths?this.overrides.addMonths(r,o):Nce(r,o)},this.addWeeks=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addWeeks?this.overrides.addWeeks(r,o):YGe(r,o)},this.addYears=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addYears?this.overrides.addYears(r,o):ZGe(r,o)},this.differenceInCalendarDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,o):kce(r,o)},this.differenceInCalendarMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,o):tYe(r,o)},this.eachMonthOfInterval=r=>{var o;return(o=this.overrides)!=null&&o.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):rYe(r)},this.eachYearOfInterval=r=>{var a;const o=(a=this.overrides)!=null&&a.eachYearOfInterval?this.overrides.eachYearOfInterval(r):iYe(r),s=new Set(o.map(c=>this.getYear(c)));if(s.size===o.length)return o;const i=[];return s.forEach(c=>{i.push(new Date(c,0,1))}),i},this.endOfBroadcastWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):pZe(r,this)},this.endOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfISOWeek?this.overrides.endOfISOWeek(r):aYe(r)},this.endOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.endOfMonth?this.overrides.endOfMonth(r):nYe(r)},this.endOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.endOfWeek?this.overrides.endOfWeek(r,o):Ece(r,this.options)},this.endOfYear=r=>{var o;return(o=this.overrides)!=null&&o.endOfYear?this.overrides.endOfYear(r):sYe(r)},this.format=(r,o,s)=>{var a;const i=(a=this.overrides)!=null&&a.format?this.overrides.format(r,o,this.options):nZe(r,o,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.getISOWeek?this.overrides.getISOWeek(r):Dce(r)},this.getMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getMonth?this.overrides.getMonth(r,this.options):sZe(r,this.options)},this.getYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getYear?this.overrides.getYear(r,this.options):iZe(r,this.options)},this.getWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getWeek?this.overrides.getWeek(r,this.options):Rce(r,this.options)},this.isAfter=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isAfter?this.overrides.isAfter(r,o):aZe(r,o)},this.isBefore=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isBefore?this.overrides.isBefore(r,o):lZe(r,o)},this.isDate=r=>{var o;return(o=this.overrides)!=null&&o.isDate?this.overrides.isDate(r):_ce(r)},this.isSameDay=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameDay?this.overrides.isSameDay(r,o):JGe(r,o)},this.isSameMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameMonth?this.overrides.isSameMonth(r,o):cZe(r,o)},this.isSameYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameYear?this.overrides.isSameYear(r,o):uZe(r,o)},this.max=r=>{var o;return(o=this.overrides)!=null&&o.max?this.overrides.max(r):XGe(r)},this.min=r=>{var o;return(o=this.overrides)!=null&&o.min?this.overrides.min(r):QGe(r)},this.setMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setMonth?this.overrides.setMonth(r,o):dZe(r,o)},this.setYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setYear?this.overrides.setYear(r,o):fZe(r,o)},this.startOfBroadcastWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):Pce(r,this)},this.startOfDay=r=>{var o;return(o=this.overrides)!=null&&o.startOfDay?this.overrides.startOfDay(r):ev(r)},this.startOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.startOfISOWeek?this.overrides.startOfISOWeek(r):J0(r)},this.startOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.startOfMonth?this.overrides.startOfMonth(r):oYe(r)},this.startOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfWeek?this.overrides.startOfWeek(r,this.options):eb(r,this.options)},this.startOfYear=r=>{var o;return(o=this.overrides)!=null&&o.startOfYear?this.overrides.startOfYear(r):Tce(r)},this.options={locale:j$,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let o=0;o<10;o++)r[o.toString()]=n.format(o);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){var n;const t=(n=this.options.locale)==null?void 0:n.code;return t&&Wi.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:r,numerals:o}=this.options,s=n==null?void 0:n.code;if(s&&Wi.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:o}).format(t)}catch{}const i=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,i)}}Wi.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const gc=new Wi;class Fce{constructor(t,n,r=gc){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r,this.isoDate=r.format(t,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class gZe{constructor(t,n){this.date=t,this.weeks=n}}class bZe{constructor(t,n){this.days=n,this.weekNumber=t}}function xZe(e){return v.createElement("button",{...e})}function yZe(e){return v.createElement("span",{...e})}function vZe(e){const{size:t=24,orientation:n="left",className:r}=e;return v.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&v.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&v.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&v.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&v.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function wZe(e){const{day:t,modifiers:n,...r}=e;return v.createElement("td",{...r})}function CZe(e){const{day:t,modifiers:n,...r}=e,o=v.useRef(null);return v.useEffect(()=>{var s;n.focused&&((s=o.current)==null||s.focus())},[n.focused]),v.createElement("button",{ref:o,...r})}var qt;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(qt||(qt={}));var qr;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(qr||(qr={}));var Ha;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Ha||(Ha={}));var Ai;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Ai||(Ai={}));function SZe(e){const{options:t,className:n,components:r,classNames:o,...s}=e,i=[o[qt.Dropdown],n].join(" "),a=t==null?void 0:t.find(({value:c})=>c===s.value);return v.createElement("span",{"data-disabled":s.disabled,className:o[qt.DropdownRoot]},v.createElement(r.Select,{className:i,...s},t==null?void 0:t.map(({value:c,label:u,disabled:d})=>v.createElement(r.Option,{key:c,value:c,disabled:d},u))),v.createElement("span",{className:o[qt.CaptionLabel],"aria-hidden":!0},a==null?void 0:a.label,v.createElement(r.Chevron,{orientation:"down",size:18,className:o[qt.Chevron]})))}function NZe(e){return v.createElement("div",{...e})}function jZe(e){return v.createElement("div",{...e})}function kZe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r},e.children)}function _Ze(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r})}function IZe(e){return v.createElement("table",{...e})}function TZe(e){return v.createElement("div",{...e})}const Oce=v.createContext(void 0);function Fw(){const e=v.useContext(Oce);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function EZe(e){const{components:t}=Fw();return v.createElement(t.Dropdown,{...e})}function DZe(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:o,...s}=e,{components:i,classNames:a,labels:{labelPrevious:c,labelNext:u}}=Fw(),d=v.useCallback(h=>{o&&(n==null||n(h))},[o,n]),f=v.useCallback(h=>{r&&(t==null||t(h))},[r,t]);return v.createElement("nav",{...s},v.createElement(i.PreviousMonthButton,{type:"button",className:a[qt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:f},v.createElement(i.Chevron,{disabled:r?void 0:!0,className:a[qt.Chevron],orientation:"left"})),v.createElement(i.NextMonthButton,{type:"button",className:a[qt.NextMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":u(o),onClick:d},v.createElement(i.Chevron,{disabled:o?void 0:!0,orientation:"right",className:a[qt.Chevron]})))}function MZe(e){const{components:t}=Fw();return v.createElement(t.Button,{...e})}function RZe(e){return v.createElement("option",{...e})}function AZe(e){const{components:t}=Fw();return v.createElement(t.Button,{...e})}function PZe(e){const{rootRef:t,...n}=e;return v.createElement("div",{...n,ref:t})}function FZe(e){return v.createElement("select",{...e})}function OZe(e){const{week:t,...n}=e;return v.createElement("tr",{...n})}function LZe(e){return v.createElement("th",{...e})}function $Ze(e){return v.createElement("thead",{"aria-hidden":!0},v.createElement("tr",{...e}))}function zZe(e){const{week:t,...n}=e;return v.createElement("th",{...n})}function BZe(e){return v.createElement("th",{...e})}function VZe(e){return v.createElement("tbody",{...e})}function HZe(e){const{components:t}=Fw();return v.createElement(t.Dropdown,{...e})}const qZe=Object.freeze(Object.defineProperty({__proto__:null,Button:xZe,CaptionLabel:yZe,Chevron:vZe,Day:wZe,DayButton:CZe,Dropdown:SZe,DropdownNav:NZe,Footer:jZe,Month:kZe,MonthCaption:_Ze,MonthGrid:IZe,Months:TZe,MonthsDropdown:EZe,Nav:DZe,NextMonthButton:MZe,Option:RZe,PreviousMonthButton:AZe,Root:PZe,Select:FZe,Week:OZe,WeekNumber:zZe,WeekNumberHeader:BZe,Weekday:LZe,Weekdays:$Ze,Weeks:VZe,YearsDropdown:HZe},Symbol.toStringTag,{value:"Module"}));function Jc(e,t,n=!1,r=gc){let{from:o,to:s}=e;const{differenceInCalendarDays:i,isSameDay:a}=r;return o&&s?(i(s,o)<0&&([o,s]=[s,o]),i(t,o)>=(n?1:0)&&i(s,t)>=(n?1:0)):!n&&s?a(s,t):!n&&o?a(o,t):!1}function k$(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function AI(e){return!!(e&&typeof e=="object"&&"from"in e)}function _$(e){return!!(e&&typeof e=="object"&&"after"in e)}function I$(e){return!!(e&&typeof e=="object"&&"before"in e)}function Lce(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function $ce(e,t){return Array.isArray(e)&&e.every(t.isDate)}function eu(e,t,n=gc){const r=Array.isArray(t)?t:[t],{isSameDay:o,differenceInCalendarDays:s,isAfter:i}=n;return r.some(a=>{if(typeof a=="boolean")return a;if(n.isDate(a))return o(e,a);if($ce(a,n))return a.includes(e);if(AI(a))return Jc(a,e,!1,n);if(Lce(a))return Array.isArray(a.dayOfWeek)?a.dayOfWeek.includes(e.getDay()):a.dayOfWeek===e.getDay();if(k$(a)){const c=s(a.before,e),u=s(a.after,e),d=c>0,f=u<0;return i(a.before,a.after)?f&&d:d||f}return _$(a)?s(e,a.after)>0:I$(a)?s(a.before,e)>0:typeof a=="function"?a(e):!1})}function UZe(e,t,n,r,o){const{disabled:s,hidden:i,modifiers:a,showOutsideDays:c,broadcastCalendar:u,today:d=o.today()}=t,{isSameDay:f,isSameMonth:h,startOfMonth:m,isBefore:g,endOfMonth:b,isAfter:x}=o,y=n&&m(n),w=r&&b(r),C={[qr.focused]:[],[qr.outside]:[],[qr.disabled]:[],[qr.hidden]:[],[qr.today]:[]},N={};for(const S of e){const{date:j,displayMonth:_}=S,k=!!(_&&!h(j,_)),T=!!(y&&g(j,y)),I=!!(w&&x(j,w)),E=!!(s&&eu(j,s,o)),D=!!(i&&eu(j,i,o))||T||I||!u&&!c&&k||u&&c===!1&&k,R=f(j,d);k&&C.outside.push(S),E&&C.disabled.push(S),D&&C.hidden.push(S),R&&C.today.push(S),a&&Object.keys(a).forEach(A=>{const F=a==null?void 0:a[A];F&&eu(j,F,o)&&(N[A]?N[A].push(S):N[A]=[S])})}return S=>{const j={[qr.focused]:!1,[qr.disabled]:!1,[qr.hidden]:!1,[qr.outside]:!1,[qr.today]:!1},_={};for(const k in C){const T=C[k];j[k]=T.some(I=>I===S)}for(const k in N)_[k]=N[k].some(T=>T===S);return{...j,..._}}}function WZe(e,t,n={}){return Object.entries(e).filter(([,o])=>o===!0).reduce((o,[s])=>(n[s]?o.push(n[s]):t[qr[s]]?o.push(t[qr[s]]):t[Ha[s]]&&o.push(t[Ha[s]]),o),[t[qt.Day]])}function KZe(e){return{...qZe,...e}}function GZe(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function T$(){const e={};for(const t in qt)e[qt[t]]=`rdp-${qt[t]}`;for(const t in qr)e[qr[t]]=`rdp-${qr[t]}`;for(const t in Ha)e[Ha[t]]=`rdp-${Ha[t]}`;for(const t in Ai)e[Ai[t]]=`rdp-${Ai[t]}`;return e}function zce(e,t,n){return(n??new Wi(t)).formatMonthYear(e)}const YZe=zce;function ZZe(e,t,n){return(n??new Wi(t)).format(e,"d")}function XZe(e,t=gc){return t.format(e,"LLLL")}function QZe(e,t,n){return(n??new Wi(t)).format(e,"cccccc")}function JZe(e,t=gc){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function eXe(){return""}function Bce(e,t=gc){return t.format(e,"yyyy")}const tXe=Bce,nXe=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:zce,formatDay:ZZe,formatMonthCaption:YZe,formatMonthDropdown:XZe,formatWeekNumber:JZe,formatWeekNumberHeader:eXe,formatWeekdayName:QZe,formatYearCaption:tXe,formatYearDropdown:Bce},Symbol.toStringTag,{value:"Module"}));function rXe(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...nXe,...e}}function oXe(e,t,n,r,o){const{startOfMonth:s,startOfYear:i,endOfYear:a,eachMonthOfInterval:c,getMonth:u}=o;return c({start:i(e),end:a(e)}).map(h=>{const m=r.formatMonthDropdown(h,o),g=u(h),b=t&&h<s(t)||n&&h>s(n)||!1;return{value:g,label:m,disabled:b}})}function sXe(e,t={},n={}){let r={...t==null?void 0:t[qt.Day]};return Object.entries(e).filter(([,o])=>o===!0).forEach(([o])=>{r={...r,...n==null?void 0:n[o]}}),r}function iXe(e,t,n,r){const o=r??e.today(),s=n?e.startOfBroadcastWeek(o,e):t?e.startOfISOWeek(o):e.startOfWeek(o),i=[];for(let a=0;a<7;a++){const c=e.addDays(s,a);i.push(c)}return i}function aXe(e,t,n,r,o=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:i,eachYearOfInterval:a,getYear:c}=r,u=s(e),d=i(t),f=a({start:u,end:d});return o&&f.reverse(),f.map(h=>{const m=n.formatYearDropdown(h,r);return{value:c(h),label:m,disabled:!1}})}function Vce(e,t,n,r){let o=(r??new Wi(n)).format(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o}const lXe=Vce;function Hce(e,t,n){return(n??new Wi(t)).formatMonthYear(e)}const cXe=Hce;function uXe(e,t,n,r){let o=(r??new Wi(n)).format(e,"PPPP");return t!=null&&t.today&&(o=`Today, ${o}`),o}function dXe(e){return"Choose the Month"}function fXe(){return""}function hXe(e){return"Go to the Next Month"}function mXe(e){return"Go to the Previous Month"}function pXe(e,t,n){return(n??new Wi(t)).format(e,"cccc")}function gXe(e,t){return`Week ${e}`}function bXe(e){return"Week Number"}function xXe(e){return"Choose the Year"}const yXe=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:cXe,labelDay:lXe,labelDayButton:Vce,labelGrid:Hce,labelGridcell:uXe,labelMonthDropdown:dXe,labelNav:fXe,labelNext:hXe,labelPrevious:mXe,labelWeekNumber:gXe,labelWeekNumberHeader:bXe,labelWeekday:pXe,labelYearDropdown:xXe},Symbol.toStringTag,{value:"Module"})),Ow=e=>e instanceof HTMLElement?e:null,hM=e=>[...e.querySelectorAll("[data-animated-month]")??[]],vXe=e=>Ow(e.querySelector("[data-animated-month]")),mM=e=>Ow(e.querySelector("[data-animated-caption]")),pM=e=>Ow(e.querySelector("[data-animated-weeks]")),wXe=e=>Ow(e.querySelector("[data-animated-nav]")),CXe=e=>Ow(e.querySelector("[data-animated-weekdays]"));function SXe(e,t,{classNames:n,months:r,focused:o,dateLib:s}){const i=v.useRef(null),a=v.useRef(r),c=v.useRef(!1);v.useLayoutEffect(()=>{const u=a.current;if(a.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const d=s.isSameMonth(r[0].date,u[0].date),f=s.isAfter(r[0].date,u[0].date),h=f?n[Ai.caption_after_enter]:n[Ai.caption_before_enter],m=f?n[Ai.weeks_after_enter]:n[Ai.weeks_before_enter],g=i.current,b=e.current.cloneNode(!0);if(b instanceof HTMLElement?(hM(b).forEach(C=>{if(!(C instanceof HTMLElement))return;const N=vXe(C);N&&C.contains(N)&&C.removeChild(N);const S=mM(C);S&&S.classList.remove(h);const j=pM(C);j&&j.classList.remove(m)}),i.current=b):i.current=null,c.current||d||o)return;const x=g instanceof HTMLElement?hM(g):[],y=hM(e.current);if(y!=null&&y.every(w=>w instanceof HTMLElement)&&x&&x.every(w=>w instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const w=wXe(e.current);w&&(w.style.zIndex="1"),y.forEach((C,N)=>{const S=x[N];if(!S)return;C.style.position="relative",C.style.overflow="hidden";const j=mM(C);j&&j.classList.add(h);const _=pM(C);_&&_.classList.add(m);const k=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),w&&(w.style.zIndex=""),j&&j.classList.remove(h),_&&_.classList.remove(m),C.style.position="",C.style.overflow="",C.contains(S)&&C.removeChild(S)};S.style.pointerEvents="none",S.style.position="absolute",S.style.overflow="hidden",S.setAttribute("aria-hidden","true");const T=CXe(S);T&&(T.style.opacity="0");const I=mM(S);I&&(I.classList.add(f?n[Ai.caption_before_exit]:n[Ai.caption_after_exit]),I.addEventListener("animationend",k));const E=pM(S);E&&E.classList.add(f?n[Ai.weeks_before_exit]:n[Ai.weeks_after_exit]),C.insertBefore(S,C.firstChild)})}})}function NXe(e,t,n,r){const o=e[0],s=e[e.length-1],{ISOWeek:i,fixedWeeks:a,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:m,endOfMonth:g,endOfWeek:b,isAfter:x,startOfBroadcastWeek:y,startOfISOWeek:w,startOfWeek:C}=r,N=c?y(o,r):i?w(o):C(o),S=c?h(s):i?m(g(s)):b(g(s)),j=t&&(c?h(t):i?m(t):b(t)),_=j&&x(S,j)?j:S,k=d(_,N),T=f(s,o)+1,I=[];for(let R=0;R<=k;R++){const A=u(N,R);I.push(A)}const D=(c?35:42)*T;if(a&&I.length<D){const R=D-I.length;for(let A=0;A<R;A++){const F=u(I[I.length-1],1);I.push(F)}}return I}function jXe(e){const t=[];return e.reduce((n,r)=>{const o=r.weeks.reduce((s,i)=>s.concat(i.days.slice()),t.slice());return n.concat(o.slice())},t.slice())}function kXe(e,t,n,r){const{numberOfMonths:o=1}=n,s=[];for(let i=0;i<o;i++){const a=r.addMonths(e,i);if(t&&a>t)break;s.push(a)}return s}function Wq(e,t,n,r){const{month:o,defaultMonth:s,today:i=r.today(),numberOfMonths:a=1}=e;let c=o||s||i;const{differenceInCalendarMonths:u,addMonths:d,startOfMonth:f}=r;if(n&&u(n,c)<a-1){const h=-1*(a-1);c=d(n,h)}return t&&u(c,t)<0&&(c=t),f(c)}function _Xe(e,t,n,r){const{addDays:o,endOfBroadcastWeek:s,endOfISOWeek:i,endOfMonth:a,endOfWeek:c,getISOWeek:u,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:m}=r,g=e.reduce((b,x)=>{const y=n.broadcastCalendar?f(x,r):n.ISOWeek?h(x):m(x),w=n.broadcastCalendar?s(x):n.ISOWeek?i(a(x)):c(a(x)),C=t.filter(_=>_>=y&&_<=w),N=n.broadcastCalendar?35:42;if(n.fixedWeeks&&C.length<N){const _=t.filter(k=>{const T=N-C.length;return k>w&&k<=o(w,T)});C.push(..._)}const S=C.reduce((_,k)=>{const T=n.ISOWeek?u(k):d(k),I=_.find(D=>D.weekNumber===T),E=new Fce(k,x,r);return I?I.days.push(E):_.push(new bZe(T,[E])),_},[]),j=new gZe(x,S);return b.push(j),b},[]);return n.reverseMonths?g.reverse():g}function IXe(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:o,startOfDay:s,startOfMonth:i,endOfMonth:a,addYears:c,endOfYear:u,newDate:d,today:f}=t,{fromYear:h,toYear:m,fromMonth:g,toMonth:b}=e;!n&&g&&(n=g),!n&&h&&(n=t.newDate(h,0,1)),!r&&b&&(r=b),!r&&m&&(r=d(m,11,31));const x=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=i(n):h?n=d(h,0,1):!n&&x&&(n=o(c(e.today??f(),-100))),r?r=a(r):m?r=d(m,11,31):!r&&x&&(r=u(e.today??f())),[n&&s(n),r&&s(r)]}function TXe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s=1}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s:1,d=i(e);if(!t)return a(d,u);if(!(c(t,e)<s))return a(d,u)}function EXe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s??1:1,d=i(e);if(!t)return a(d,-u);if(!(c(d,t)<=0))return a(d,-u)}function DXe(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function PI(e,t){const[n,r]=v.useState(e);return[t===void 0?n:t,r]}function MXe(e,t){var N;const[n,r]=IXe(e,t),{startOfMonth:o,endOfMonth:s}=t,i=Wq(e,n,r,t),[a,c]=PI(i,e.month?i:void 0);v.useEffect(()=>{const S=Wq(e,n,r,t);c(S)},[e.timeZone]);const{months:u,weeks:d,days:f,previousMonth:h,nextMonth:m}=v.useMemo(()=>{const S=kXe(a,r,{numberOfMonths:e.numberOfMonths},t),j=NXe(S,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),_=_Xe(S,j,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),k=DXe(_),T=jXe(_),I=EXe(a,n,e,t),E=TXe(a,r,e,t);return{months:_,weeks:k,days:T,previousMonth:I,nextMonth:E}},[t,a.getTime(),r==null?void 0:r.getTime(),n==null?void 0:n.getTime(),e.disableNavigation,e.broadcastCalendar,(N=e.endMonth)==null?void 0:N.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:g,onMonthChange:b}=e,x=S=>d.some(j=>j.days.some(_=>_.isEqualTo(S))),y=S=>{if(g)return;let j=o(S);n&&j<o(n)&&(j=o(n)),r&&j>o(r)&&(j=o(r)),c(j),b==null||b(j)};return{months:u,weeks:d,days:f,navStart:n,navEnd:r,previousMonth:h,nextMonth:m,goToMonth:y,goToDay:S=>{x(S)||y(S.date)}}}var El;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(El||(El={}));function Kq(e){return!e[qr.disabled]&&!e[qr.hidden]&&!e[qr.outside]}function RXe(e,t,n,r){let o,s=-1;for(const i of e){const a=t(i);Kq(a)&&(a[qr.focused]&&s<El.FocusedModifier?(o=i,s=El.FocusedModifier):r!=null&&r.isEqualTo(i)&&s<El.LastFocused?(o=i,s=El.LastFocused):n(i.date)&&s<El.Selected?(o=i,s=El.Selected):a[qr.today]&&s<El.Today&&(o=i,s=El.Today))}return o||(o=e.find(i=>Kq(t(i)))),o}function AXe(e,t,n,r,o,s,i){const{ISOWeek:a,broadcastCalendar:c}=s,{addDays:u,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfWeek:b,max:x,min:y,startOfBroadcastWeek:w,startOfISOWeek:C,startOfWeek:N}=i;let j={day:u,week:f,month:d,year:h,startOfWeek:_=>c?w(_,i):a?C(_):N(_),endOfWeek:_=>c?m(_):a?g(_):b(_)}[e](n,t==="after"?1:-1);return t==="before"&&r?j=x([r,j]):t==="after"&&o&&(j=y([o,j])),j}function qce(e,t,n,r,o,s,i,a=0){if(a>365)return;const c=AXe(e,t,n.date,r,o,s,i),u=!!(s.disabled&&eu(c,s.disabled,i)),d=!!(s.hidden&&eu(c,s.hidden,i)),f=c,h=new Fce(c,f,i);return!u&&!d?h:qce(e,t,h,r,o,s,i,a+1)}function PXe(e,t,n,r,o){const{autoFocus:s}=e,[i,a]=v.useState(),c=RXe(t.days,n,r||(()=>!1),i),[u,d]=v.useState(s?c:void 0);return{isFocusTarget:b=>!!(c!=null&&c.isEqualTo(b)),setFocused:d,focused:u,blur:()=>{a(u),d(void 0)},moveFocus:(b,x)=>{if(!u)return;const y=qce(b,x,u,t.navStart,t.navEnd,e,o);y&&(e.disableNavigation&&!t.days.some(C=>C.isEqualTo(y))||(t.goToDay(y),d(y)))}}}function FXe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=PI(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t,u=m=>(a==null?void 0:a.some(g=>c(g,m)))??!1,{min:d,max:f}=e;return{selected:a,select:(m,g,b)=>{let x=[...a??[]];if(u(m)){if((a==null?void 0:a.length)===d||r&&(a==null?void 0:a.length)===1)return;x=a==null?void 0:a.filter(y=>!c(y,m))}else(a==null?void 0:a.length)===f?x=[m]:x=[...x,m];return o||i(x),o==null||o(x,m,g,b),x},isSelected:u}}function OXe(e,t,n=0,r=0,o=!1,s=gc){const{from:i,to:a}=t||{},{isSameDay:c,isAfter:u,isBefore:d}=s;let f;if(!i&&!a)f={from:e,to:n>0?void 0:e};else if(i&&!a)c(i,e)?n===0?f={from:i,to:e}:o?f={from:i,to:void 0}:f=void 0:d(e,i)?f={from:e,to:i}:f={from:i,to:e};else if(i&&a)if(c(i,e)&&c(a,e))o?f={from:i,to:a}:f=void 0;else if(c(i,e))f={from:i,to:n>0?void 0:e};else if(c(a,e))f={from:e,to:n>0?void 0:e};else if(d(e,i))f={from:e,to:a};else if(u(e,i))f={from:i,to:e};else if(u(e,a))f={from:i,to:e};else throw new Error("Invalid range");if(f!=null&&f.from&&(f!=null&&f.to)){const h=s.differenceInCalendarDays(f.to,f.from);r>0&&h>r?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function LXe(e,t,n=gc){const r=Array.isArray(t)?t:[t];let o=e.from;const s=n.differenceInCalendarDays(e.to,e.from),i=Math.min(s,6);for(let a=0;a<=i;a++){if(r.includes(o.getDay()))return!0;o=n.addDays(o,1)}return!1}function Gq(e,t,n=gc){return Jc(e,t.from,!1,n)||Jc(e,t.to,!1,n)||Jc(t,e.from,!1,n)||Jc(t,e.to,!1,n)}function $Xe(e,t,n=gc){const r=Array.isArray(t)?t:[t];if(r.filter(a=>typeof a!="function").some(a=>typeof a=="boolean"?a:n.isDate(a)?Jc(e,a,!1,n):$ce(a,n)?a.some(c=>Jc(e,c,!1,n)):AI(a)?a.from&&a.to?Gq(e,{from:a.from,to:a.to},n):!1:Lce(a)?LXe(e,a.dayOfWeek,n):k$(a)?n.isAfter(a.before,a.after)?Gq(e,{from:n.addDays(a.after,1),to:n.addDays(a.before,-1)},n):eu(e.from,a,n)||eu(e.to,a,n):_$(a)||I$(a)?eu(e.from,a,n)||eu(e.to,a,n):!1))return!0;const i=r.filter(a=>typeof a=="function");if(i.length){let a=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let u=0;u<=c;u++){if(i.some(d=>d(a)))return!0;a=n.addDays(a,1)}}return!1}function zXe(e,t){const{disabled:n,excludeDisabled:r,selected:o,required:s,onSelect:i}=e,[a,c]=PI(o,i?o:void 0),u=i?o:a;return{selected:u,select:(h,m,g)=>{const{min:b,max:x}=e,y=h?OXe(h,u,b,x,s,t):void 0;return r&&n&&(y!=null&&y.from)&&y.to&&$Xe({from:y.from,to:y.to},n,t)&&(y.from=h,y.to=void 0),i||c(y),i==null||i(y,h,m,g),y},isSelected:h=>u&&Jc(u,h,!1,t)}}function BXe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=PI(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t;return{selected:a,select:(f,h,m)=>{let g=f;return!r&&a&&a&&c(f,a)&&(g=void 0),o||i(g),o==null||o(g,f,h,m),g},isSelected:f=>a?c(a,f):!1}}function VXe(e,t){const n=BXe(e,t),r=FXe(e,t),o=zXe(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return o;default:return}}function Qo(e,t){return e instanceof Qc&&e.timeZone===t?e:new Qc(e,t)}function Yq(e,t){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Qo(e,t):Array.isArray(e)?e.map(n=>n instanceof Date?Qo(n,t):n):AI(e)?{...e,from:e.from?Qo(e.from,t):e.from,to:e.to?Qo(e.to,t):e.to}:k$(e)?{before:Qo(e.before,t),after:Qo(e.after,t)}:_$(e)?{after:Qo(e.after,t)}:I$(e)?{before:Qo(e.before,t)}:e}function gM(e,t){return e&&(Array.isArray(e)?e.map(n=>Yq(n,t)):Yq(e,t))}function HXe(e){var Qe;let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=Qo(t.today,n)),t.month&&(t.month=Qo(t.month,n)),t.defaultMonth&&(t.defaultMonth=Qo(t.defaultMonth,n)),t.startMonth&&(t.startMonth=Qo(t.startMonth,n)),t.endMonth&&(t.endMonth=Qo(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=Qo(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=(Qe=t.selected)==null?void 0:Qe.map(xe=>Qo(xe,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?Qo(t.selected.from,n):t.selected.from,to:t.selected.to?Qo(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=gM(t.disabled,n)),t.hidden!==void 0&&(t.hidden=gM(t.hidden,n)),t.modifiers)){const xe={};Object.keys(t.modifiers).forEach(Ve=>{var Ae;xe[Ve]=gM((Ae=t.modifiers)==null?void 0:Ae[Ve],n)}),t.modifiers=xe}const{components:r,formatters:o,labels:s,dateLib:i,locale:a,classNames:c}=v.useMemo(()=>{const xe={...j$,...t.locale};return{dateLib:new Wi({locale:xe,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:KZe(t.components),formatters:rXe(t.formatters),labels:{...yXe,...t.labels},locale:xe,classNames:{...T$(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:i.today()});const{captionLayout:u,mode:d,navLayout:f,numberOfMonths:h=1,onDayBlur:m,onDayClick:g,onDayFocus:b,onDayKeyDown:x,onDayMouseEnter:y,onDayMouseLeave:w,onNextClick:C,onPrevClick:N,showWeekNumber:S,styles:j}=t,{formatCaption:_,formatDay:k,formatMonthDropdown:T,formatWeekNumber:I,formatWeekNumberHeader:E,formatWeekdayName:D,formatYearDropdown:R}=o,A=MXe(t,i),{days:F,months:z,navStart:L,navEnd:$,previousMonth:H,nextMonth:M,goToMonth:B}=A,W=UZe(F,t,L,$,i),{isSelected:P,select:G,selected:Z}=VXe(t,i)??{},{blur:X,focused:Y,isFocusTarget:O,moveFocus:q,setFocused:U}=PXe(t,A,W,P??(()=>!1),i),{labelDayButton:V,labelGridcell:K,labelGrid:Q,labelMonthDropdown:se,labelNav:oe,labelPrevious:me,labelNext:le,labelWeekday:ue,labelWeekNumber:ne,labelWeekNumberHeader:de,labelYearDropdown:Ce}=s,ce=v.useMemo(()=>iXe(i,t.ISOWeek,t.broadcastCalendar,t.today),[i,t.ISOWeek,t.broadcastCalendar,t.today]),ie=d!==void 0||g!==void 0,we=v.useCallback(()=>{H&&(B(H),N==null||N(H))},[H,B,N]),fe=v.useCallback(()=>{M&&(B(M),C==null||C(M))},[B,M,C]),ae=v.useCallback((xe,Ve)=>Ae=>{Ae.preventDefault(),Ae.stopPropagation(),U(xe),!Ve.disabled&&(G==null||G(xe.date,Ve,Ae),g==null||g(xe.date,Ve,Ae))},[G,g,U]),ee=v.useCallback((xe,Ve)=>Ae=>{U(xe),b==null||b(xe.date,Ve,Ae)},[b,U]),J=v.useCallback((xe,Ve)=>Ae=>{X(),m==null||m(xe.date,Ve,Ae)},[X,m]),re=v.useCallback((xe,Ve)=>Ae=>{const ke={ArrowLeft:[Ae.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Ae.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Ae.shiftKey?"year":"week","after"],ArrowUp:[Ae.shiftKey?"year":"week","before"],PageUp:[Ae.shiftKey?"year":"month","before"],PageDown:[Ae.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ke[Ae.key]){Ae.preventDefault(),Ae.stopPropagation();const[Be,Ie]=ke[Ae.key];q(Be,Ie)}x==null||x(xe.date,Ve,Ae)},[q,x,t.dir]),pe=v.useCallback((xe,Ve)=>Ae=>{y==null||y(xe.date,Ve,Ae)},[y]),Ee=v.useCallback((xe,Ve)=>Ae=>{w==null||w(xe.date,Ve,Ae)},[w]),Te=v.useCallback(xe=>Ve=>{const Ae=Number(Ve.target.value),ke=i.setMonth(i.startOfMonth(xe),Ae);B(ke)},[i,B]),ze=v.useCallback(xe=>Ve=>{const Ae=Number(Ve.target.value),ke=i.setYear(i.startOfMonth(xe),Ae);B(ke)},[i,B]),{className:Pe,style:He}=v.useMemo(()=>({className:[c[qt.Root],t.className].filter(Boolean).join(" "),style:{...j==null?void 0:j[qt.Root],...t.style}}),[c,t.className,t.style,j]),ye=GZe(t),Ke=v.useRef(null);SXe(Ke,!!t.animate,{classNames:c,months:z,focused:Y,dateLib:i});const We={dayPickerProps:t,selected:Z,select:G,isSelected:P,months:z,nextMonth:M,previousMonth:H,goToMonth:B,getModifiers:W,components:r,classNames:c,styles:j,labels:s,formatters:o};return v.createElement(Oce.Provider,{value:We},v.createElement(r.Root,{rootRef:t.animate?Ke:void 0,className:Pe,style:He,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...ye},v.createElement(r.Months,{className:c[qt.Months],style:j==null?void 0:j[qt.Months]},!t.hideNavigation&&!f&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":oe(),onPreviousClick:we,onNextClick:fe,previousMonth:H,nextMonth:M}),z.map((xe,Ve)=>v.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:c[qt.Month],style:j==null?void 0:j[qt.Month],key:Ve,displayIndex:Ve,calendarMonth:xe},f==="around"&&!t.hideNavigation&&Ve===0&&v.createElement(r.PreviousMonthButton,{type:"button",className:c[qt.PreviousMonthButton],tabIndex:H?void 0:-1,"aria-disabled":H?void 0:!0,"aria-label":me(H),onClick:we,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:H?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"right":"left"})),v.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[qt.MonthCaption],style:j==null?void 0:j[qt.MonthCaption],calendarMonth:xe,displayIndex:Ve},u!=null&&u.startsWith("dropdown")?v.createElement(r.DropdownNav,{className:c[qt.Dropdowns],style:j==null?void 0:j[qt.Dropdowns]},(()=>{const Ae=u==="dropdown"||u==="dropdown-months"?v.createElement(r.MonthsDropdown,{key:"month",className:c[qt.MonthsDropdown],"aria-label":se(),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:Te(xe.date),options:oXe(xe.date,L,$,o,i),style:j==null?void 0:j[qt.Dropdown],value:i.getMonth(xe.date)}):v.createElement("span",{key:"month"},T(xe.date,i)),ke=u==="dropdown"||u==="dropdown-years"?v.createElement(r.YearsDropdown,{key:"year",className:c[qt.YearsDropdown],"aria-label":Ce(i.options),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:ze(xe.date),options:aXe(L,$,o,i,!!t.reverseYears),style:j==null?void 0:j[qt.Dropdown],value:i.getYear(xe.date)}):v.createElement("span",{key:"year"},R(xe.date,i));return i.getMonthYearOrder()==="year-first"?[ke,Ae]:[Ae,ke]})(),v.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},_(xe.date,i.options,i))):v.createElement(r.CaptionLabel,{className:c[qt.CaptionLabel],role:"status","aria-live":"polite"},_(xe.date,i.options,i))),f==="around"&&!t.hideNavigation&&Ve===h-1&&v.createElement(r.NextMonthButton,{type:"button",className:c[qt.NextMonthButton],tabIndex:M?void 0:-1,"aria-disabled":M?void 0:!0,"aria-label":le(M),onClick:fe,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:M?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"left":"right"})),Ve===h-1&&f==="after"&&!t.hideNavigation&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":oe(),onPreviousClick:we,onNextClick:fe,previousMonth:H,nextMonth:M}),v.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Q(xe.date,i.options,i)||void 0,className:c[qt.MonthGrid],style:j==null?void 0:j[qt.MonthGrid]},!t.hideWeekdays&&v.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[qt.Weekdays],style:j==null?void 0:j[qt.Weekdays]},S&&v.createElement(r.WeekNumberHeader,{"aria-label":de(i.options),className:c[qt.WeekNumberHeader],style:j==null?void 0:j[qt.WeekNumberHeader],scope:"col"},E()),ce.map(Ae=>v.createElement(r.Weekday,{"aria-label":ue(Ae,i.options,i),className:c[qt.Weekday],key:String(Ae),style:j==null?void 0:j[qt.Weekday],scope:"col"},D(Ae,i.options,i)))),v.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[qt.Weeks],style:j==null?void 0:j[qt.Weeks]},xe.weeks.map(Ae=>v.createElement(r.Week,{className:c[qt.Week],key:Ae.weekNumber,style:j==null?void 0:j[qt.Week],week:Ae},S&&v.createElement(r.WeekNumber,{week:Ae,style:j==null?void 0:j[qt.WeekNumber],"aria-label":ne(Ae.weekNumber,{locale:a}),className:c[qt.WeekNumber],scope:"row",role:"rowheader"},I(Ae.weekNumber,i)),Ae.days.map(ke=>{const{date:Be}=ke,Ie=W(ke);if(Ie[qr.focused]=!Ie.hidden&&!!(Y!=null&&Y.isEqualTo(ke)),Ie[Ha.selected]=(P==null?void 0:P(Be))||Ie.selected,AI(Z)){const{from:rt,to:Ct}=Z;Ie[Ha.range_start]=!!(rt&&Ct&&i.isSameDay(Be,rt)),Ie[Ha.range_end]=!!(rt&&Ct&&i.isSameDay(Be,Ct)),Ie[Ha.range_middle]=Jc(Z,Be,!0,i)}const $e=sXe(Ie,j,t.modifiersStyles),st=WZe(Ie,c,t.modifiersClassNames),ct=!ie&&!Ie.hidden?K(Be,Ie,i.options,i):void 0;return v.createElement(r.Day,{key:`${ke.isoDate}_${ke.displayMonthId}`,day:ke,modifiers:Ie,className:st.join(" "),style:$e,role:"gridcell","aria-selected":Ie.selected||void 0,"aria-label":ct,"data-day":ke.isoDate,"data-month":ke.outside?ke.dateMonthId:void 0,"data-selected":Ie.selected||void 0,"data-disabled":Ie.disabled||void 0,"data-hidden":Ie.hidden||void 0,"data-outside":ke.outside||void 0,"data-focused":Ie.focused||void 0,"data-today":Ie.today||void 0},!Ie.hidden&&ie?v.createElement(r.DayButton,{className:c[qt.DayButton],style:j==null?void 0:j[qt.DayButton],type:"button",day:ke,modifiers:Ie,disabled:!Ie.focused&&Ie.disabled||void 0,"aria-disabled":Ie.focused&&Ie.disabled||void 0,tabIndex:O(ke)?0:-1,"aria-label":V(Be,Ie,i.options,i),onClick:ae(ke,Ie),onBlur:J(ke,Ie),onFocus:ee(ke,Ie),onKeyDown:re(ke,Ie),onMouseEnter:pe(ke,Ie),onMouseLeave:Ee(ke,Ie)},k(Be,i.options,i)):!Ie.hidden&&k(ke.date,i.options,i))})))))))),t.footer&&v.createElement(r.Footer,{className:c[qt.Footer],style:j==null?void 0:j[qt.Footer],role:"status","aria-live":"polite"},t.footer)))}function bM({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r="label",buttonVariant:o="ghost",formatters:s,components:i,...a}){const c=T$();return l.jsx(HXe,{showOutsideDays:n,className:p.cn("bg-background group/calendar p-2.5 [--cell-size:1.75rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...s},classNames:{root:p.cn("w-fit",c.root),months:p.cn("relative flex flex-col gap-3 md:flex-row",c.months),month:p.cn("flex w-full flex-col gap-3",c.month),nav:p.cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",c.nav),button_previous:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_previous),button_next:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_next),month_caption:p.cn("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",c.month_caption),dropdowns:p.cn("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-[13px] font-medium",c.dropdowns),dropdown_root:p.cn("has-focus:border-ring border-input has-focus:ring-ring/40 has-focus:ring-[2px] relative rounded-md border",c.dropdown_root),dropdown:p.cn("bg-popover absolute inset-0 opacity-0",c.dropdown),caption_label:p.cn("select-none font-medium text-foreground",r==="label"?"text-[13px]":"[&>svg]:text-muted-foreground flex h-7 items-center gap-1 rounded-md pl-2 pr-1 text-[13px] [&>svg]:size-3",c.caption_label),table:"w-full border-collapse",weekdays:p.cn("flex",c.weekdays),weekday:p.cn("text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",c.weekday),week:p.cn("mt-1 flex w-full",c.week),week_number_header:p.cn("w-[--cell-size] select-none",c.week_number_header),week_number:p.cn("text-muted-foreground select-none text-[10px]",c.week_number),day:p.cn("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",c.day),range_start:p.cn("bg-accent rounded-l-md",c.range_start),range_middle:p.cn("rounded-none",c.range_middle),range_end:p.cn("bg-accent rounded-r-md",c.range_end),today:p.cn("rounded-md text-foreground font-medium [&>button]:ring-1 [&>button]:ring-inset [&>button]:ring-border",c.today),outside:p.cn("text-muted-foreground/60 aria-selected:text-muted-foreground/60",c.outside),disabled:p.cn("text-muted-foreground/50",c.disabled),hidden:p.cn("invisible",c.hidden),...t},components:{Root:({className:u,rootRef:d,...f})=>l.jsx("div",{"data-slot":"calendar",ref:d,className:p.cn(u),...f}),Chevron:({className:u,orientation:d,...f})=>d==="left"?l.jsx(Mm,{className:p.cn("size-4",u),...f}):d==="right"?l.jsx(Ft.ChevronRight,{className:p.cn("size-4",u),...f}):l.jsx(je.ChevronDown,{className:p.cn("size-4",u),...f}),DayButton:qXe,WeekNumber:({children:u,...d})=>l.jsx("td",{...d,children:l.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:u})}),...i},...a})}function qXe({className:e,day:t,modifiers:n,...r}){const o=T$(),s=te.useRef(null);return te.useEffect(()=>{var i;n.focused&&((i=s.current)==null||i.focus())},[n.focused]),l.jsx(p.Button,{ref:s,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:p.cn("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/40 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-0.5 rounded-md p-0 text-[12px] font-normal leading-none tabular-nums data-[range-end=true]:rounded-r-md data-[range-end=true]:rounded-l-none data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-l-md data-[range-start=true]:rounded-r-none group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[2px] [&>span]:text-[10px] [&>span]:opacity-70",o.day,e),...r})}const UXe={time:"Time",day:"Day",week:"Week",month:"Month",quarter:"Quarter",year:"Year"},Zq=(e,t)=>!e||e.mode==="this"&&e.boundary?"day":e.unit==="minute"||e.unit==="hour"?t?"time":"day":e.unit,WXe=["Last 30 minutes","Last 1 hour","Last 4 hours","Last 12 hours","Last 24 hours"],KXe=(e=!1)=>{const t=[{label:"Today",value:n=>{const r=new Date;return{from:p.startOfDayInTimezone(r,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Yesterday",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-1);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"First day of the month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"Last day of the month",value:n=>{const r=new Date,o=p.endOfMonthInTimezone(r,n);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"Last 7 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-6);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 30 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-29);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 90 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-89);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"This week",value:n=>{const r=new Date,o=p.startOfWeekInTimezone(r,n),s=p.endOfWeekInTimezone(r,n);return{from:o,to:s}},category:"week"},{label:"Last week",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-1),s=p.startOfWeekInTimezone(o,n),i=p.endOfWeekInTimezone(o,n);return{from:s,to:i}},category:"week"},{label:"Last 2 weeks",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-2),s=p.shiftDateByWeeksInTimezone(r,n,-1);return{from:p.startOfWeekInTimezone(o,n),to:p.endOfWeekInTimezone(s,n)}},category:"week"},{label:"This month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n),s=p.endOfMonthInTimezone(r,n);return{from:o,to:s}},category:"month"},{label:"Last month",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-1),s=p.startOfMonthInTimezone(o,n),i=p.endOfMonthInTimezone(o,n);return{from:s,to:i}},category:"month"},{label:"Last 3 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-3),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 6 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-6),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 9 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-9),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 12 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-12),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"This quarter",value:n=>{const r=new Date,o=p.startOfQuarterInTimezone(r,n),s=p.endOfQuarterInTimezone(r,n);return{from:o,to:s}},category:"quarter"},{label:"Last quarter",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-1),s=p.startOfQuarterInTimezone(o,n),i=p.endOfQuarterInTimezone(o,n);return{from:s,to:i}},category:"quarter"},{label:"Last 4 quarters",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-4),s=p.shiftDateByQuartersInTimezone(r,n,-1);return{from:p.startOfQuarterInTimezone(o,n),to:p.endOfQuarterInTimezone(s,n)}},category:"quarter"},{label:"This year",value:n=>{const r=new Date,o=p.startOfYearInTimezone(r,n),s=p.endOfYearInTimezone(r,n);return{from:o,to:s}},category:"year"},{label:"Last year",value:n=>{const r=new Date,o=p.shiftDateByYearsInTimezone(r,n,-1),s=p.startOfYearInTimezone(o,n),i=p.endOfYearInTimezone(o,n);return{from:s,to:i}},category:"year"}];return e?[...WXe.map(n=>({label:n,value:()=>{const r=p.presetMetadata[n],o=p.resolveSubDayRelativeDateRange(r);return o?{from:o[0],to:o[1]}:{from:new Date,to:new Date}},category:"time"})),...t]:t},Xq=[{label:"2 days ago",value:-2},{label:"Yesterday",value:-1},{label:"Today",value:0},{label:"Tomorrow",value:1},{label:"2 days ahead",value:2}],Qq=[{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}],Jq=[{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}],eU=[{label:"9 months ago",value:-9},{label:"6 months ago",value:-6},{label:"3 months ago",value:-3},{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}],tU=[{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 E$({value:e,onChange:t,selectionMode:n="range",singleValue:r,onSingleChange:o,comparisonOptions:s,comparisonValue:i,onComparisonChange:a,comparisonLabel:c="Condition",hideDateInputs:u=!1,onRelativeSelect:d,relativeValue:f,placeholder:h="All time",className:m,timezone:g,showRelativeTab:b=!0,hideCalendar:x=!1,disabled:y=!1,enableTimePrecision:w=!1,temporalPrecision:C,buttonClassName:N,buttonLabelSuffix:S,contentClassName:j,overlayContentClassName:_,targetColumns:k,selectedColumn:T,onColumnChange:I,inline:E=!1,onApplied:D,supplementalFooter:R,onOpenChange:A}){var vt,Tt;const[F,z]=v.useState(!1),[L,$]=v.useState(n==="range"?"presets":"static"),[H,M]=v.useState(()=>Zq(f,w)),[B,W]=v.useState(!1),[P,G]=v.useState(!1),[Z,X]=v.useState("Days"),[Y,O]=v.useState("0"),[q,U]=v.useState("0"),[V,K]=v.useState(w&&C==="minute"),[Q,se]=v.useState("00:00"),[oe,me]=v.useState("23:59"),[le,ue]=v.useState("00:00"),[ne,de]=v.useState(E?e:void 0),[Ce,ce]=v.useState(E?r:void 0),ie=dc("interactive"),we=ie.controlStyle,fe=ie.contentStyle;v.useEffect(()=>{E&&de(e)},[E,e]),v.useEffect(()=>{E&&ce(r)},[E,r]);const ae=p.getEffectiveTimezone(g),ee=w&&C==="minute",J=v.useMemo(()=>KXe(w),[w]),re=v.useMemo(()=>[...w?["time"]:[],"day","week","month","quarter","year"],[w]),pe=v.useMemo(()=>J.filter(Me=>Me.category===H),[H,J]),Ee=Zq(f,w),Te=b&&n==="range",ze=n==="range";v.useEffect(()=>{M(Ee)},[Ee]),v.useEffect(()=>{const Me=w&&C==="minute";K(Me),Me?(e!=null&&e.from&&se(p.formatTimeInTimezone(e.from,ae)),e!=null&&e.to&&me(p.formatTimeInTimezone(e.to,ae)),r&&ue(p.formatTimeInTimezone(r,ae))):(se("00:00"),me("23:59"),ue("00:00"))},[ae,w,r,C,e==null?void 0:e.from,e==null?void 0:e.to]),v.useEffect(()=>{if(!ze&&L!=="static"){$("static");return}!Te&&L==="relative"&&$("static")},[Te,ze,L]);const Pe=()=>{if(n==="single")return r?Kt.formatInTimeZone(r,ae,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"):h;if(e!=null&&e.from&&(e!=null&&e.to)){const Me=Kt.formatInTimeZone(e.from,ae,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"),Je=Kt.formatInTimeZone(e.to,ae,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy");return`${Me} - ${Je}`}return h},He=n==="single"?!!r:!!(e!=null&&e.from||e!=null&&e.to),ye=!!(k&&k.length>1&&I),Ke=((vt=k==null?void 0:k.find(Me=>Me.column===T))==null?void 0:vt.label)||((Tt=k==null?void 0:k[0])==null?void 0:Tt.label)||"Date",We=Me=>{const Je=Me.value(ae),kt=p.presetMetadata[Me.label],mt=w?p.getTemporalPrecisionForRelativeMeta(kt):void 0,_t=mt?{temporalPrecision:mt}:void 0;t==null||t(Je,_t),Te&&(d==null||d(Je,kt,_t)),rt(!1)},Qe=(Me,Je)=>{var Pt,wt;const kt=re.indexOf(Je);let mt;if(Me.key==="ArrowRight"||Me.key==="ArrowDown"?mt=(kt+1)%re.length:Me.key==="ArrowLeft"||Me.key==="ArrowUp"?mt=(kt-1+re.length)%re.length:Me.key==="Home"?mt=0:Me.key==="End"&&(mt=re.length-1),mt===void 0)return;Me.preventDefault();const _t=re[mt];M(_t);const Rt=(Pt=Me.currentTarget.parentElement)==null?void 0:Pt.querySelectorAll('[role="radio"]');(wt=Rt==null?void 0:Rt[mt])==null||wt.focus()},xe=()=>{n==="single"?o==null||o(void 0):t==null||t(void 0),rt(!1)},Ve=(Me,Je)=>{if(!Je)return;const kt=Me==="from"?Je:ne==null?void 0:ne.from,mt=Me==="to"?Je:ne==null?void 0:ne.to;de({from:kt,to:mt}),Me==="from"?W(!1):G(!1)},Ae=Me=>{const Je=Me===!0;if(K(Je),!Je){se("00:00"),me("23:59"),ue("00:00");return}ne!=null&&ne.from&&se(p.formatTimeInTimezone(ne.from,ae)),ne!=null&&ne.to&&me(p.formatTimeInTimezone(ne.to,ae)),Ce&&ue(p.formatTimeInTimezone(Ce,ae))},ke=()=>{if(ne!=null&&ne.from&&(ne!=null&&ne.to)){if(w&&V){const kt=p.composeDateTimeInTimezone(ne.from,Q,ae),mt=p.composeDateTimeInTimezone(ne.to,oe,ae,{boundary:"end"});if(!kt||!mt||mt.getTime()<kt.getTime())return;t==null||t({from:kt,to:mt},{temporalPrecision:"minute"}),rt(!1);return}const Me=p.startOfDayInTimezone(ne.from,ae),Je=p.endOfDayInTimezone(ne.to,ae);t==null||t({from:Me,to:Je}),rt(!1)}},Be=()=>{de(e)},Ie=()=>{if(Ce&&w&&V){const Me=i==="<="?"end":"start",Je=p.composeDateTimeInTimezone(Ce,le,ae,{boundary:Me});if(!Je)return;o==null||o(Je,{temporalPrecision:"minute"}),rt(!1);return}o==null||o(Ce),rt(!1)},$e=()=>{ce(r)},st=()=>{ce(p.startOfDayInTimezone(new Date,ae))},ct=()=>{const Me=new Date,Je=parseInt(Y,10),kt=parseInt(q,10);let mt,_t;if(Z==="Days"){const Et=p.shiftDateByDaysInTimezone(Me,ae,Je),Bt=p.shiftDateByDaysInTimezone(Me,ae,kt);mt=p.startOfDayInTimezone(Et,ae),_t=p.endOfDayInTimezone(Bt,ae)}else if(Z==="Weeks"){const Et=p.shiftDateByWeeksInTimezone(Me,ae,Je),Bt=p.shiftDateByWeeksInTimezone(Me,ae,kt);mt=p.startOfWeekInTimezone(Et,ae),_t=p.endOfWeekInTimezone(Bt,ae)}else if(Z==="Months"){const Et=p.shiftDateByMonthsInTimezone(Me,ae,Je),Bt=p.shiftDateByMonthsInTimezone(Me,ae,kt);mt=p.startOfMonthInTimezone(Et,ae),_t=p.endOfMonthInTimezone(Bt,ae)}else if(Z==="Quarters"){const Et=p.shiftDateByQuartersInTimezone(Me,ae,Je),Bt=p.shiftDateByQuartersInTimezone(Me,ae,kt);mt=p.startOfQuarterInTimezone(Et,ae),_t=p.endOfQuarterInTimezone(Bt,ae)}else{const Et=p.shiftDateByYearsInTimezone(Me,ae,Je),Bt=p.shiftDateByYearsInTimezone(Me,ae,kt);mt=p.startOfYearInTimezone(Et,ae),_t=p.endOfYearInTimezone(Bt,ae)}const Pt={mode:"between",unit:{Days:"day",Weeks:"week",Months:"month",Quarters:"quarter",Years:"year"}[Z],from:Je,to:kt},wt={from:mt,to:_t};t==null||t(wt),d==null||d(wt,Pt),rt(!1)};function rt(Me){z(Me),A==null||A(Me)}const Ct=Me=>{rt(Me),Me&&(de(e),ce(r),K(w&&C==="minute"))},Lt=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"min-w-0 flex-1",children:ye&&k?l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(za,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsxs(p.Select,{value:T,onValueChange:I,children:[l.jsx(p.SelectTrigger,{className:"h-7 max-w-[210px] rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[52]","rounded-control"),style:fe,children:k.map(Me=>l.jsx(p.SelectItem,{value:Me.column,children:Me.label},Me.column))})]})]}):l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(za,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate text-[13px] font-medium",children:Ke})]})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Using ${NN(ae)} timezone`,children:[l.jsx(hR,{className:"h-3 w-3"}),l.jsx("span",{children:fn.getTimezoneAbbreviation(ae)})]})]}),(e==null?void 0:e.from)&&(e==null?void 0:e.to)&&l.jsxs("p",{className:"mt-1 pl-[18px] font-mono text-[11px] tabular-nums text-muted-foreground",children:[Kt.formatInTimeZone(e.from,ae,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")," – ",Kt.formatInTimeZone(e.to,ae,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")]})]}),l.jsxs(p.Tabs,{value:L,onValueChange:Me=>{$(Me),Me==="static"&&de(e)},className:"w-full",children:[ze&&l.jsx("div",{className:"px-2 pt-2",children:l.jsxs(p.TabsList,{style:we,className:p.cn("inline-flex h-[30px] w-full items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5 text-muted-foreground"),children:[l.jsx(p.TabsTrigger,{value:"presets",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Presets"}),l.jsx(p.TabsTrigger,{value:"static",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Static"}),Te&&l.jsx(p.TabsTrigger,{value:"relative",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Relative"})]})}),ze&&l.jsx(p.TabsContent,{value:"presets",className:"mt-0",children:!u&&l.jsxs("div",{children:[l.jsx("div",{className:"border-b border-border px-2 py-1.5",children:l.jsx("div",{role:"radiogroup","aria-label":"Preset interval","aria-orientation":"horizontal",className:"flex items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:re.map(Me=>{const Je=Me===H;return l.jsx("button",{type:"button",role:"radio","aria-checked":Je,tabIndex:Je?0:-1,onClick:()=>M(Me),onKeyDown:kt=>Qe(kt,Me),className:p.cn("h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",Je?"bg-background text-foreground shadow-sm ring-1 ring-border":"text-muted-foreground hover:text-foreground"),children:UXe[Me]},Me)})})}),l.jsx("div",{className:"space-y-0.5 p-2",children:pe.map(Me=>l.jsx("button",{type:"button",onClick:()=>{We(Me),E&&(D==null||D())},className:"w-full rounded-control px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",children:Me.label},Me.label))})]})}),l.jsx(p.TabsContent,{value:"static",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[s&&s.length>0&&i&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:c}),l.jsxs(p.Select,{value:i,onValueChange:Me=>a==null?void 0:a(Me),children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[52]","rounded-control"),style:fe,children:s.map(Me=>l.jsx(p.SelectItem,{value:Me.value,children:Me.label},Me.value))})]})]}),!x&&!u&&(n==="single"?l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date"}),l.jsxs("div",{className:"flex items-center gap-2.5",children:[w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(Tn,{checked:V,onCheckedChange:Ae,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]}),l.jsx("button",{type:"button",onClick:st,className:"rounded-control px-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Today"})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:B,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:we,children:[l.jsx(za,{className:"mr-1.5 h-3 w-3"}),Ce?Kt.formatInTimeZone(Ce,ae,"MM/dd/yyyy"):"Select date"]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(_??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(bM,{mode:"single",selected:Ce,defaultMonth:Ce,captionLayout:"dropdown",onSelect:Me=>{ce(Me),W(!1)},className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),V&&w&&l.jsx(p.Input,{size:"xs",value:le,onChange:Me=>ue(Me.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(le),title:"Use 24-hour HH:mm time",className:"w-20 shrink-0 font-mono tabular-nums"})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom range"}),w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(Tn,{checked:V,onCheckedChange:Ae,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]})]}),l.jsxs("div",{className:p.cn(V&&w?"space-y-1.5":"flex items-center gap-1.5"),children:[l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:B,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:we,children:[l.jsx(za,{className:"mr-1.5 h-3 w-3"}),ne!=null&&ne.from?Kt.formatInTimeZone(ne.from,ae,"MM/dd/yyyy"):"From date"]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(_??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(bM,{mode:"single",selected:ne==null?void 0:ne.from,defaultMonth:ne==null?void 0:ne.from,captionLayout:"dropdown",onSelect:Me=>Ve("from",Me),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),V&&w&&l.jsx(p.Input,{size:"xs",value:Q,onChange:Me=>se(Me.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(Q),title:"Start time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]}),l.jsx("span",{className:p.cn("text-[12px] text-muted-foreground",V&&w&&"block text-center"),children:"–"}),l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:P,onOpenChange:G,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:we,children:[l.jsx(za,{className:"mr-1.5 h-3 w-3"}),ne!=null&&ne.to?Kt.formatInTimeZone(ne.to,ae,"MM/dd/yyyy"):"To date"]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(_??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(bM,{mode:"single",selected:ne==null?void 0:ne.to,defaultMonth:ne==null?void 0:ne.to,captionLayout:"dropdown",onSelect:Me=>Ve("to",Me),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),V&&w&&l.jsx(p.Input,{size:"xs",value:oe,onChange:Me=>me(Me.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(oe),title:"End time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]})]})]}))]})}),Te&&l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[l.jsx("div",{className:"inline-flex w-full items-center gap-0.5 rounded-control border border-border bg-background p-0.5",style:we,children:["Days","Weeks","Months","Quarters","Years"].map(Me=>l.jsx("button",{onClick:()=>X(Me),className:p.cn("flex-1 rounded-control px-2 py-1 text-[11px] font-medium transition-colors",Z===Me?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:Me},Me))}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:Y,onValueChange:O,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{placeholder:"From"})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[51]","rounded-control"),style:fe,children:(Z==="Years"?Qq:Z==="Quarters"?Jq:Z==="Months"?eU:Z==="Weeks"?tU:Xq).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})}),l.jsx("span",{className:"text-[12px] text-muted-foreground",children:"to"}),l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:q,onValueChange:U,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:we,children:l.jsx(p.SelectValue,{placeholder:"To"})}),l.jsx(p.SelectContent,{className:p.cn(_??"z-[51]","rounded-control"),style:fe,children:(Z==="Years"?Qq:Z==="Quarters"?Jq:Z==="Months"?eU:Z==="Weeks"?tU:Xq).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})})]})]})})]}),R,(()=>{const Me=L==="static"&&n==="single",Je=L==="static"&&n==="range",kt=L==="relative",mt=Me&&!!Ce||Je&&!!(ne!=null&&ne.from)&&!!(ne!=null&&ne.to),_t=mt||kt,Rt=mt,Pt=w&&V,wt=Pt&&(ne!=null&&ne.from)?p.composeDateTimeInTimezone(ne.from,Q,ae):null,Et=Pt&&(ne!=null&&ne.to)?p.composeDateTimeInTimezone(ne.to,oe,ae,{boundary:"end"}):null,Bt=Je&&Pt&&(!p.isValidTimeInput(Q)||!p.isValidTimeInput(oe)||!wt||!Et||Et.getTime()<wt.getTime()),un=Me&&Pt&&!p.isValidTimeInput(le);if(!He&&!_t)return null;const Ge=()=>{Me?Ie():Je?ke():kt&&ct(),E&&(D==null||D())},Re=()=>{Me?$e():Je&&Be()},De=Me&&!Ce||Je&&(!(ne!=null&&ne.from)||!(ne!=null&&ne.to))||Bt||un;return l.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[He?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>{xe(),E&&(D==null||D())},children:"Clear"}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-1",children:[Rt&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:Re,children:"Cancel"}),_t&&l.jsx(p.Button,{type:"button",variant:"default",size:"xs",onClick:Ge,disabled:De,children:"Apply"})]})]})})()]});return E?l.jsx("div",{className:p.cn("w-full overflow-hidden bg-popover text-popover-foreground",m),style:fe,children:Lt}):l.jsx("div",{className:p.cn("w-full",m),children:l.jsxs(p.Popover,{open:F,onOpenChange:Ct,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",className:p.cn("h-8 min-w-0 w-full justify-between gap-2 rounded-control border-border bg-background text-left text-[13px] font-normal text-foreground transition-colors hover:border-border/80 hover:bg-background",N),style:we,title:`Timezone: ${NN(ae)} (${fn.getTimezoneAbbreviation(ae)})`,disabled:y,children:[l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:S?`${Pe()} · ${S}`:Pe()}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[l.jsx(hR,{className:"h-3 w-3 opacity-50"}),l.jsx(je.ChevronDown,{className:"h-3 w-3 opacity-50"})]})]})}),l.jsx(p.PopoverContent,{style:fe,className:p.cn(j??"z-[51]","w-[320px] overflow-hidden rounded-control border border-border/80 bg-popover p-0 text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]"),align:"start",children:Lt})]})})}function Uce(e,t){var o,s;const n=(o=t==null?void 0:t.find(i=>i.filterId===e.id))==null?void 0:o.name,r=new Set([e.column,...((s=e.targetColumns)==null?void 0:s.map(i=>i.column))??[]]);return n&&r.has(n)?n:e.column}function GXe(e,t){const n=v.useMemo(()=>{const h={column:e.column,label:e.title};return e.targetColumns&&e.targetColumns.length>0?[h,...e.targetColumns]:[h]},[e.targetColumns,e.column,e.title]),r=(t==null?void 0:t.storageTarget)==="card",o=p.useDashboardStore(h=>h.filterValues),s=r?t==null?void 0:t.inlineFilterValues:o,i=s==null?void 0:s.find(h=>h.filterId===e.id),a=!!i,c=v.useMemo(()=>Uce(e,s),[e,s]),[u,d]=v.useState(c);v.useEffect(()=>{const h=n.some(m=>m.column===u);(i!=null&&i.name&&c!==u||!h)&&d(c)},[c,i==null?void 0:i.name,n]);const f=v.useMemo(()=>u&&u!==e.column?{...e,column:u}:e,[e,u]);return{selectedColumn:u,setSelectedColumn:d,effectiveFilter:f,targetColumns:n,hasActiveFilter:a,storedFilterValue:i}}const YXe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ZXe=["January","February","March","April","May","June","July","August","September","October","November","December"];function Wce({value:e,onChange:t,onClear:n,placeholder:r="Select month",className:o,buttonClassName:s}){const[i,a]=v.useState(!1),[c,u]=v.useState((e==null?void 0:e.year)??new Date().getFullYear()),[d,f]=v.useState(e);v.useEffect(()=>{e?(f(e),u(e.year)):(f(void 0),u(new Date().getFullYear()))},[e]);const h=x=>{u(y=>y+x)},m=x=>{f({year:c,month:x}),t==null||t(c,x),a(!1)},g=()=>{f(void 0),n==null||n(),a(!1)},b=d?`${ZXe[d.month]} ${d.year}`:r;return l.jsxs(p.Popover,{open:i,onOpenChange:a,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsx(p.Button,{variant:"outline",role:"combobox","aria-expanded":i,className:p.cn("min-w-0 w-full justify-between gap-2 px-3 text-sm font-normal",s??"h-9",!d&&"text-muted-foreground",o),children:l.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx(mN,{className:"h-4 w-4 shrink-0 opacity-50"}),l.jsx("span",{className:"truncate",children:b})]})})}),l.jsx(p.PopoverContent,{className:"z-[52] w-80 p-0",align:"start",children:l.jsxs("div",{className:"p-3",children:[l.jsxs("div",{className:"mb-3 flex items-center justify-between border-b pb-3",children:[l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(-1),"aria-label":"Previous year",children:l.jsx(Mm,{className:"h-4 w-4"})}),l.jsx("h2",{className:"text-sm font-semibold",children:c}),l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(1),"aria-label":"Next year",children:l.jsx(Ft.ChevronRight,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:YXe.map((x,y)=>{const w=(d==null?void 0:d.month)===y&&(d==null?void 0:d.year)===c;return l.jsx(p.Button,{variant:w?"outline":"ghost",className:p.cn("h-9 text-sm font-medium",!w&&"hover:bg-muted",w&&"border-foreground"),onClick:()=>m(y),children:x},x)})}),d&&l.jsx("div",{className:"mt-3 border-t pt-3",children:l.jsx(p.Button,{variant:"ghost",onClick:g,className:"h-9 w-full justify-center text-sm",children:"Clear selection"})})]})})]})}const V1=[{value:"between",label:"Is between"},{value:"<",label:"Is before"},{value:">",label:"Is after"},{value:"<=",label:"Is on or before"},{value:">=",label:"Is on or after"},{value:"=",label:"Is exactly"}],XXe=new Set(V1.map(e=>e.value)),QXe=new Set(["between","not between","=","!=",">",">=","<","<="]),JXe={"not between":"Is not between","!=":"Is not exactly"},xM=e=>typeof e=="string"&&QXe.has(e);function Kce({filter:e,className:t,isCardStorage:n,timezone:r,selectedColumn:o,setSelectedColumn:s,targetColumns:i,hasActiveFilter:a,enableTimePrecision:c,storedFilterValue:u,activeFilterValue:d,dateRange:f,isLoading:h,isFetching:m,isError:g,hasData:b,setDateRange:x,handleChange:y,handleRelativeChange:w,handleClear:C,inline:N=!1,onApplied:S,supplementalFooter:j}){const _=n?"h-8":"h-9",k=n?"h-[31px]":"h-[35px]",T=e.dateSelectionMode==="months"?"months":"range",I=a?f:void 0,E=xM(e.operation)?e.operation:"between",[D,R]=v.useState(o),[A,F]=v.useState(E);v.useEffect(()=>{if(d&&xM(d.operation)){F(d.operation);return}F(E)},[d,E]);const z=v.useMemo(()=>{if(XXe.has(A))return V1;const V=JXe[A];return V?[...V1,{value:A,label:V}]:V1},[A]);if(v.useEffect(()=>{if(o!==void 0&&s&&o!==D){if(R(o),!a)return;const V=xM(u==null?void 0:u.operation)?u.operation:A,K=(u==null?void 0:u.temporalPrecision)==="minute"?{temporalPrecision:"minute"}:void 0,Q=u==null?void 0:u.relativeMeta;if(Q&&V==="between"&&f){w(f,Q,K);return}if(V==="between"||V==="not between"){f&&y(f,V,K);return}const se=(f==null?void 0:f.from)||(f==null?void 0:f.to);se&&y({from:se,to:se},V,K)}},[o,D,f,y,w,s,u,a,A]),!N&&(h||m))return l.jsx("div",{children:l.jsx(Xs,{className:p.cn(k,"w-full bg-foreground/10")})});if(g)return l.jsx(S$,{isCardStorage:n});if(!N&&!b)return l.jsx(p.Label,{className:p.cn("flex w-full items-center bg-muted px-2",_),children:"No Data"});const L=A==="between"||A==="not between",$=(c||p.getFilterTemporalCapability(e)==="datetime")&&p.supportsMinutePrecisionForOperation(A),H=d,M=$&&(H==null?void 0:H.temporalPrecision)==="minute"?"minute":$?p.getTemporalPrecisionForRelativeMeta(H==null?void 0:H.relativeMeta):void 0,B=e.showLabel===!1?e.title||e.column:void 0,W=V=>{if(!V)return;const K=V instanceof Date?V:new Date(V);return isNaN(K.getTime())?void 0:K},P=()=>{const V=d==null?void 0:d.operation,K=d==null?void 0:d.values;if(!V||!Array.isArray(K)||K.length<2||V!=="between"&&V!=="not between")return;const Q=W(K[0]),se=W(K[1]);if(!(!Q&&!se))return{from:Q,to:se}},G=()=>{const V=d==null?void 0:d.operation,K=d==null?void 0:d.values;if(!(!V||!Array.isArray(K)||K.length<1||!["=","!=",">",">=","<","<="].includes(V)))return W(K[0])},Z=V=>{const K=P();if(K){if(V==="<"||V==="<=")return K.to||K.from;if(V===">"||V===">="||V==="=")return K.from||K.to}return G()},X=(V,K,Q={})=>Q.temporalPrecision==="minute"?V:K==="<="||K===">"?p.endOfDayInTimezone(V,r):p.startOfDayInTimezone(V,r),Y=(V,K)=>{if(!V){C();return}y(V,L?A:"between",K)},O=(V,K)=>{if(!V){C();return}const Q=X(V,A,K);x({from:Q,to:Q}),y({from:Q,to:Q},A,K)},q=V=>{if(F(V),!a||!d)return;if(V==="between"||V==="not between"){const Q=P();if(Q!=null&&Q.from||Q!=null&&Q.to){y({from:Q.from,to:Q.to},V,M?{temporalPrecision:M}:{});return}const se=G();if(se){const oe={from:p.startOfDayInTimezone(se,r),to:p.endOfDayInTimezone(se,r)};y(oe,V)}return}const K=Z(V);if(K){const Q=M&&p.supportsMinutePrecisionForOperation(V)?{temporalPrecision:M}:{},se=X(K,V,Q);x({from:se,to:se}),y({from:se,to:se},V,Q);return}},U=(V,K,Q)=>{w(V,K,Q)};if(T==="months"){const V=I!=null&&I.from?(()=>{const se=Kt.toZonedTime(I.from,r);return{year:Wxe(se),month:Uxe(se)}})():void 0,K=se=>`${se}`.padStart(2,"0"),Q=(se,oe)=>{const me=`${se}-${K(oe+1)}-01T00:00:00`,le=oe===11?se+1:se,ue=(oe+1)%12,ne=`${le}-${K(ue+1)}-01T00:00:00`;return{from:iB.fromZonedTime(me,r),to:iB.fromZonedTime(ne,r)}};return l.jsx(Wce,{className:t,buttonClassName:_,value:V,placeholder:B||"All months",onClear:C,onChange:(se,oe)=>{const{from:me,to:le}=Q(se,oe);y({from:me,to:le})}})}return l.jsx(E$,{value:L?I:void 0,singleValue:L||I==null?void 0:I.from,selectionMode:L?"range":"single",buttonClassName:_,onChange:Y,onSingleChange:O,onRelativeSelect:U,relativeValue:H==null?void 0:H.relativeMeta,comparisonOptions:z,comparisonValue:A,onComparisonChange:q,comparisonLabel:"Condition",timezone:r,enableTimePrecision:$,temporalPrecision:M,showRelativeTab:A==="between",className:t,placeholder:B||(L?"All time":"Select date"),targetColumns:i&&i.length>1?i:void 0,selectedColumn:o,onColumnChange:s,inline:N,onApplied:S,supplementalFooter:j})}function eQe({filter:e,className:t,storageOptions:n,inline:r,onApplied:o,supplementalFooter:s}){const i=dl(),{selectedColumn:a,setSelectedColumn:c,effectiveFilter:u,targetColumns:d,hasActiveFilter:f,storedFilterValue:h}=GXe(e,n),{records:m,dateRange:g,isLoading:b,isFetching:x,isError:y,setDateRange:w,activeFilterValue:C,handleChange:N,handleRelativeChange:S,handleClear:j}=N$(u,n);return l.jsx(Kce,{filter:u,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:i,selectedColumn:a,setSelectedColumn:c,targetColumns:d,hasActiveFilter:f,storedFilterValue:h,activeFilterValue:C,dateRange:g,isLoading:b,isFetching:x,isError:y,hasData:!!m,setDateRange:w,handleChange:N,handleRelativeChange:S,handleClear:j,inline:r,onApplied:o,supplementalFooter:s})}function tQe({filter:e,className:t,storageOptions:n,managedState:r,inline:o,onApplied:s,supplementalFooter:i}){const a=dl();return l.jsx(Kce,{filter:e,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:a,hasActiveFilter:r.hasActiveFilter??!!r.activeFilterValue,enableTimePrecision:r.enableTimePrecision,storedFilterValue:r.storedFilterValue??r.activeFilterValue,activeFilterValue:r.activeFilterValue,dateRange:r.dateRange,isLoading:r.isLoading??!1,isFetching:r.isFetching??!1,isError:r.isError??!1,hasData:r.hasData??!0,setDateRange:r.setDateRange??(()=>{}),handleChange:r.handleChange,handleRelativeChange:r.handleRelativeChange,handleClear:r.handleClear,inline:o,onApplied:s,supplementalFooter:i})}function D$(e){return"managedState"in e?l.jsx(tQe,{...e}):l.jsx(eQe,{...e})}function nU({filter:e,storageOptions:t}){return p.isDateDataType(e.dataType)?l.jsx(D$,{filter:e,storageOptions:t}):e.uiType==="radio"&&e.type==="single"?l.jsx(yce,{filter:e,storageOptions:t}):e.uiType==="tabs"&&e.type==="single"?l.jsx(vce,{filter:e,storageOptions:t}):l.jsx(bce,{filter:e,storageOptions:t})}function nQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var N;const{filteredRecords:o,selectedRecords:s,handleChange:i,handleClear:a,handleSelectAll:c,query:u,setQuery:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:b,allSelected:x,activeFilterValue:y}=Vb(e,{enableServerSearch:!0,...r}),w={filter:e,options:o||[],selectedValues:s||[],onChange:i,onClear:a,onSelectAll:c,searchQuery:u,onSearchChange:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:b,allSelected:x,activeFilterValue:y,theme:n,settings:(N=e.customFilterPreferences)==null?void 0:N.settings},C=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(Xs,{className:`${C} w-full bg-foreground/10`}),children:l.jsx(t,{...w})})}function rQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var x;const{dateRange:o,initialDateRange:s,handleChange:i,handleRelativeChange:a,handleClear:c,handleReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m}=N$(e,r),g={filter:e,dateRange:o,initialDateRange:s,onDateChange:i,onRelativeDateChange:a,onClear:c,onReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m,theme:n,settings:(x=e.customFilterPreferences)==null?void 0:x.settings},b=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(Xs,{className:`${b} w-full bg-foreground/10`}),children:l.jsx(t,{...g})})}function oQe({filter:e,storageOptions:t}){var h,m,g;const{compiledAppearance:n}=p.useAppearance(),r=(t==null?void 0:t.storageTarget)==="card"?"h-[31px]":"h-[35px]",o=v.useMemo(()=>Aw(n),[n]),{getFilter:s,isLoading:i,isError:a}=Nf(((h=e.customFilterPreferences)==null?void 0:h.url)||""),c=(m=e.customFilterPreferences)==null?void 0:m.componentName,u=c?s(c):null;if(!c||!((g=e.customFilterPreferences)!=null&&g.url)||a||!i&&!u)return l.jsx(nU,{filter:e,storageOptions:t});if(i||!u)return l.jsx(Xs,{className:`${r} w-full bg-foreground/10`});const f=p.isDateDataType(e.dataType);return l.jsx(Si,{fallback:l.jsx(nU,{filter:e,storageOptions:t}),onError:b=>console.error("Custom filter runtime error:",b),children:f?l.jsx(rQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t}):l.jsx(nQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t})})}const sQe=v.memo(oQe);function Lw(e,t){return Rk(ab({dashboard:e}).allInputs).find(n=>n.kind==="filter"&&n.filter.id===t)}function Gce({selection:e,controlLabel:t,onChange:n}){const r=v.useId(),o=e.mode==="period"?e.spec:void 0,s=(o==null?void 0:o.kind)==="previous_year"?o.offsetYears||1:(o==null?void 0:o.kind)==="previous_period"&&o.offsetPeriods||1,i=(o==null?void 0:o.kind)||"off",a=`${r}-comparison`,c=d=>{o&&n({mode:"period",spec:{...o,...d}})},u=d=>{if(d==="off"){n({mode:"off"});return}n({mode:"period",spec:d==="previous_year"?{kind:"previous_year",toDate:!0}:{kind:"previous_period",toDate:!0}})};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{role:"radiogroup","aria-label":`${t} comparison`,className:"grid grid-cols-3 gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:[["off","Off"],["previous_period","Previous period"],["previous_year","Previous year"]].map(([d,f])=>{const h=i===d;return l.jsxs("label",{className:"cursor-pointer",children:[l.jsx("input",{type:"radio",name:a,value:d,checked:h,onChange:()=>u(d),className:"peer sr-only"}),l.jsx("span",{className:p.cn("flex h-6 items-center justify-center rounded-control px-1.5 text-center text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/20",h&&"bg-background text-foreground shadow-sm ring-1 ring-border"),children:f})]},d)})}),o?l.jsxs("div",{className:"space-y-2 rounded-control bg-muted/35 p-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(p.Label,{htmlFor:r,className:"text-xs",children:"Offset"}),l.jsx(p.Input,{id:r,"aria-label":"Comparison offset",type:"number",min:1,step:1,className:"h-7 w-20 text-xs",value:s,onFocus:d=>d.currentTarget.select(),onChange:d=>{const f=Number.parseInt(d.target.value,10);!Number.isInteger(f)||f<1||c(o.kind==="previous_year"?{offsetYears:f}:{offsetPeriods:f})}})]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(Tn,{checked:o.toDate===!0,onCheckedChange:d=>c({toDate:d===!0})}),"To date"]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(Tn,{checked:o.alignment==="weekday",onCheckedChange:d=>c({alignment:d===!0?"weekday":"calendar"})}),"Match weekdays"]})]}):null]})}function Yce({selection:e,controlLabel:t,scopeMessage:n,authorControlledCardCount:r,activeDateFilterValue:o,hasRuntimeOverride:s,onChange:i,onReset:a}){const c=e.mode==="period"?e.spec:void 0,u=p.hasFiniteDateComparisonRange(o);return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),s?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Reset"}):null]}),l.jsx(Gce,{selection:e,controlLabel:t,onChange:i}),l.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[u?n:c?`Choose a ${t} range to activate this comparison.`:`Choose a ${t} range to enable comparison.`,r>0?` ${r} visual${r===1?" contains":"s contain"} author-controlled comparison settings, which take precedence.`:""]})]})}function M$(e,t){const n=p.useDashboardStore(s=>s.dashboard),r=p.useDashboardStore(s=>s.selectedSheetId),o=p.useDashboardStore(s=>s.dashboardInputValues);return v.useMemo(()=>{var a;if((t==null?void 0:t.storageTarget)==="card")return t;const s=((a=t==null?void 0:t.dashboardInput)==null?void 0:a.kind)==="filter"?t.dashboardInput:Lw(n,e.id);if(!s)return t;const i=p.getDashboardInputRuntimeSlot(o,s,{sheetId:(t==null?void 0:t.sheetId)||r});return(i==null?void 0:i.status)!=="set"&&(i==null?void 0:i.status)!=="cleared"?t:{...t,storageTarget:"dashboardInput",dashboardInput:s,sheetId:(t==null?void 0:t.sheetId)||r||void 0}},[n,o,e.id,r,t])}function yM(e){if(!e)return;const t=e instanceof Date?e:new Date(e);return isNaN(t.getTime())?void 0:t}function Zce({filter:e,storageOptions:t,inline:n,onApplied:r}){var A;const o=M$(e,t),s=p.useDashboardStore(F=>F.filterValues),i=p.useDashboardStore(F=>F.dashboard),a=p.useDashboardStore(F=>F.dashboardInputValues),c=p.useDashboardStore(F=>F.selectedSheetId),u=p.useDashboardStore(F=>F.semanticExecutionPayload),{addOrUpdateFilterValue:d,removeFilterValues:f,setDashboardInputSlot:h,clearDashboardInputSlot:m,setDashboardInputComparisonSelection:g,resetDashboardInputComparisonSelection:b}=p.useDashboardActions(),x=v.useMemo(()=>p.getGlobalDateFilterCoverage(i,u,e),[i,e,u]),y=v.useMemo(()=>{const F=o==null?void 0:o.dashboardInput;return(F==null?void 0:F.kind)==="filter"?F:Lw(i,e.id)},[i,e.id,o==null?void 0:o.dashboardInput]),w=v.useMemo(()=>({sheetId:(o==null?void 0:o.sheetId)||c}),[c,o==null?void 0:o.sheetId]),C=!!(y&&p.canAddressDashboardInputRuntimeSlot(y,w)),N=v.useMemo(()=>y&&C?p.hydrateAuthoredDashboardInputSlot({dashboard:i,input:y,runtimeValues:a,target:w}):void 0,[C,i,y,w,a]),S=(N==null?void 0:N.comparisonSelection)||{mode:"off"},j=(N==null?void 0:N.status)==="set"&&N.value.kind==="filter"?N.value.filterValue:void 0,_=(o==null?void 0:o.storageTarget)==="dashboardInput",k=_?j:s==null?void 0:s.find(F=>F.filterId===e.id),T=v.useCallback(F=>{if(_){if(!y)return;const z=p.createFilterDashboardInputSlot(F);z&&h(y,w,z);return}d(F)},[d,y,w,_,h]),I=v.useCallback(()=>{if(_){if(!y)return;m(y,w);return}f(e.id)},[m,y,w,e.id,_,f]),E=y?C&&((A=p.getDashboardInputRuntimeSlot(a,y,w))==null?void 0:A.comparisonSelection)!==void 0:!1,D=v.useMemo(()=>{const F=new Set(x.eligibleCardIds);return p.getDashboardCards(i).filter(z=>{var L,$;return F.has(z.id)?((L=z.preferences)==null?void 0:L.inheritGlobalComparison)===!1?!0:((($=z.config)==null?void 0:$.metricColumns)||[]).some(H=>H.comparison!==void 0):!1}).length},[i,x.eligibleCardIds]),R=v.useMemo(()=>{var F;return{hasData:!0,hasActiveFilter:!!k,enableTimePrecision:x.allEligibleTargetsAreDateTime,activeFilterValue:k,storedFilterValue:k,dateRange:(F=k==null?void 0:k.values)!=null&&F.length?{from:yM(k.values[0]),to:k.values.length>1?yM(k.values[1]):yM(k.values[0])}:void 0,handleChange:(z,L="between",$={})=>{if(!z){I();return}let H;if(L==="between"||L==="not between")H={filterId:e.id,name:e.column,valueType:"date",operation:L,values:p.normalizeDateFilterRange(z,{temporalPrecision:$.temporalPrecision}).values,dataType:e.dataType,...$.temporalPrecision?{temporalPrecision:$.temporalPrecision}:{}};else{const M=z.from||z.to;if(!M){I();return}H={filterId:e.id,name:e.column,valueType:"date",operation:L,values:[M],dataType:e.dataType,...$.temporalPrecision?{temporalPrecision:$.temporalPrecision}:{}}}T(H)},handleRelativeChange:(z,L,$={})=>{if(!z)return;const H=$.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(L),M={filterId:e.id,name:e.column,valueType:"date",operation:"between",values:p.normalizeDateFilterRange(z,{temporalPrecision:H}).values,dataType:e.dataType,relativeMeta:L,...H?{temporalPrecision:H}:{}};T(M)},handleClear:I}},[k,I,e,x.allEligibleTargetsAreDateTime,T]);return l.jsx(D$,{filter:e,managedState:R,inline:n,onApplied:r,supplementalFooter:y&&C?l.jsx(Yce,{selection:S,controlLabel:"Global Date",scopeMessage:x.eligibleCardCount>0?`Comparison applies to ${x.eligibleCardCount} of ${x.totalCardCount} date-based visuals.`:"No visuals use Global Date for comparison.",authorControlledCardCount:D,activeDateFilterValue:k,hasRuntimeOverride:E,onChange:F=>g(y,w,F),onReset:()=>b(y,w)}):void 0})}function iQe(e){const t=p.getGlobalDateFilterCoverage(e.dashboard,e.semanticExecutionPayload),n=[];for(const{sheet:r,card:o}of p.getDashboardCardEntries(e.dashboard)){if(!p.dashboardInputRuntimeTargetsShareSlot(e.dashboardInput,e.dashboardInputTarget,{sheetId:r.id,cardId:o.id}))continue;const s=Yi({dashboard:e.dashboard,sheetId:r.id,card:o,runtimeValues:e.runtimeValues,mode:"interactive",timezone:e.timezone}),i=hb({card:o,dashboard:e.dashboard,interactionStates:e.interactionStates,currentDashboardId:e.dashboard.id,filters:e.dashboard.filters,filterValues:e.runtimeValues.filterValues,selectedSheetId:r.id,inlineFilterValuesMap:e.runtimeValues.inlineFilterValuesMap,dashboardControls:e.dashboard.controls,dashboardControlValues:e.runtimeValues.controlValues,cardControlValuesMap:e.runtimeValues.cardControlValuesMap,dashboardInputContext:s}),a=Jv({card:o,queryContext:i,semanticExecutionPayload:e.semanticExecutionPayload,timezone:e.timezone,allowMinutePrecision:t.allEligibleTargetsAreDateTime});n.push({card:o,plan:a.dateComparisonPlan})}return O_e({inputId:e.dashboardInput.id,targets:n})}function aQe(e){const t=[];return e.ownerCardCount>0&&t.push(`Comparison applies to ${e.ownerCardCount} of ${e.matchingCardCount} visuals using this date field.`),e.globalPrecedenceCardCount>0&&t.push(`Global Date controls comparison for ${e.globalPrecedenceCardCount} of those visual${e.globalPrecedenceCardCount===1?"":"s"}.`),e.ambiguousCardCount>0&&t.push(`Comparison is unavailable for ${e.ambiguousCardCount} visual${e.ambiguousCardCount===1?"":"s"} because more than one active filter uses this date field.`),t.length>0?t.join(" "):e.matchingCardCount>0?`Comparison is available for ${e.matchingCardCount} visual${e.matchingCardCount===1?"":"s"} using this date field.`:"No visuals use this date filter for comparison."}function Xce({filter:e,storageOptions:t,inline:n,onApplied:r}){var E;const o=p.useDashboardStore(D=>D.dashboard),s=p.useDashboardStore(D=>D.filterValues),i=p.useDashboardStore(D=>D.controlValues),a=p.useDashboardStore(D=>D.dashboardInputValues),c=p.useDashboardStore(D=>D.inlineFilterValuesMap),u=p.useDashboardStore(D=>D.cardControlValuesMap),d=p.useDashboardStore(D=>D.selectedSheetId),f=p.useDashboardStore(D=>D.semanticExecutionPayload),h=p.useInteractionStore(D=>D.interactionStates),{setDashboardInputComparisonSelection:m,resetDashboardInputComparisonSelection:g}=p.useDashboardActions(),b=dl(),x=v.useMemo(()=>{const D=t==null?void 0:t.dashboardInput;return(D==null?void 0:D.kind)==="filter"?D:Lw(o,e.id)},[o,e.id,t==null?void 0:t.dashboardInput]),y=v.useMemo(()=>({sheetId:(t==null?void 0:t.sheetId)||d}),[d,t==null?void 0:t.sheetId]),w=!!(x&&p.canAddressDashboardInputRuntimeSlot(x,y)),C=v.useMemo(()=>x&&w?p.hydrateAuthoredDashboardInputSlot({dashboard:o,input:x,runtimeValues:a,target:y,timezone:b}):void 0,[o,x,y,a,w,b]),N=(C==null?void 0:C.status)==="set"&&C.value.kind==="filter"?C.value.filterValue:void 0,S=(t==null?void 0:t.storageTarget)==="dashboardInput"?N:s==null?void 0:s.find(D=>D.filterId===e.id),j=(C==null?void 0:C.comparisonSelection)||{mode:"off"},_=x?w&&((E=p.getDashboardInputRuntimeSlot(a,x,y))==null?void 0:E.comparisonSelection)!==void 0:!1,k=!!(x&&w&&(t==null?void 0:t.storageTarget)!=="card"&&p.isComparisonCapableDashboardDateInput(x)),T=v.useMemo(()=>!x||!k?{ownerCardCount:0,matchingCardCount:0,globalPrecedenceCardCount:0,ambiguousCardCount:0,authorControlledCardCount:0}:iQe({dashboard:o,dashboardInput:x,dashboardInputTarget:y,interactionStates:h,semanticExecutionPayload:f,runtimeValues:{dashboardInputValues:a,filterValues:s,controlValues:i,inlineFilterValuesMap:c,cardControlValuesMap:u},timezone:b}),[u,i,o,x,y,a,s,c,h,k,f,b]),I=v.useMemo(()=>aQe(T),[T]);return l.jsx(D$,{filter:e,storageOptions:t,inline:n,onApplied:r,supplementalFooter:x&&k?l.jsx(Yce,{selection:j,controlLabel:x.label||e.title||"date",scopeMessage:I,authorControlledCardCount:T.authorControlledCardCount,activeDateFilterValue:S,hasRuntimeOverride:_,onChange:D=>m(x,y,D),onReset:()=>g(x,y)}):void 0})}function FI({filter:e,storageOptions:t}){var r,o;const n=M$(e,t);return e.kind==="global-date"?l.jsx(Zce,{filter:e,storageOptions:n}):(r=e.customFilterPreferences)!=null&&r.url&&((o=e.customFilterPreferences)!=null&&o.componentName)?l.jsx(sQe,{filter:e,storageOptions:n}):p.isDateDataType(e.dataType)?l.jsx(Xce,{filter:e,storageOptions:n}):e.uiType==="radio"&&e.type==="single"?l.jsx(yce,{filter:e,storageOptions:n}):e.uiType==="tabs"&&e.type==="single"?l.jsx(vce,{filter:e,storageOptions:n}):l.jsx(bce,{filter:e,storageOptions:n})}function Qce({className:e,message:t="Failed to load options"}){return l.jsx("p",{className:p.cn("px-2 py-2 text-[12px] text-destructive",e),children:t})}function lQe({filter:e,storageOptions:t,onApplied:n}){var H;const{filteredRecords:r,selectedRecords:o,handleChange:s,query:i,setQuery:a,isLoading:c,isFetching:u,isPlaceholderData:d,isError:f,isSearching:h,searchError:m,isSingleSelect:g,activeFilterValue:b}=Vb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),y=`Search ${(e.title||e.column||"options").toLowerCase()}`,[w,C]=v.useState(o),[N,S]=v.useState(!1);v.useEffect(()=>{N||C(o)},[o,N]);const j=v.useMemo(()=>new Set(w.map(M=>M.value)),[w]),_=(b==null?void 0:b.operation)==="is null"||(b==null?void 0:b.operation)==="is not null",k=(((H=b==null?void 0:b.values)==null?void 0:H.length)??0)>0||_,I=c||u&&d,E=M=>{if(g){C([M]),S(!0);return}S(!0),C(B=>B.some(P=>P.value===M.value)?B.filter(P=>P.value!==M.value):[...B,M])},D=(M,B)=>{M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),E(B))},R=r.length>0&&r.every(M=>j.has(M.value)),A=!r.some(M=>j.has(M.value)),F=R?"checked":A?"unchecked":"indeterminate",z=()=>{if(S(!0),F==="checked"){const M=new Set(r.map(B=>B.value));C(B=>B.filter(W=>!M.has(W.value)))}else C(M=>{const B=new Map(M.map(W=>[W.value,W]));return r.forEach(W=>B.set(W.value,W)),Array.from(B.values())})},L=()=>{s(w),S(!1),n==null||n()},$=()=>{C([]),S(!0)};return f?l.jsx(Qce,{}):l.jsxs("div",{className:"flex flex-col p-2",children:[l.jsxs("div",{className:"mb-2 flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[h?l.jsx(p.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground","aria-label":"Searching","aria-live":"polite"}):l.jsx(Ft.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:i,onChange:M=>a(M.target.value),placeholder:y,"aria-label":y,className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),i&&l.jsx("button",{type:"button",onClick:()=>a(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(je.X,{className:"h-3 w-3"})})]}),m&&l.jsxs("div",{className:"mb-2 flex items-start gap-1.5 rounded-[4px] border border-destructive/30 bg-destructive/5 px-2 py-1 text-[11px] text-destructive",children:[l.jsx(Ca,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:typeof m=="string"?m:"Search failed — showing local results"})]}),l.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[!g&&l.jsx(xce,{filter:e,storageOptions:t}),!g&&r.length>0&&l.jsxs("label",{className:"ml-auto inline-flex cursor-pointer items-center gap-1.5 text-[12px] text-muted-foreground",children:[l.jsx("span",{children:"All"}),l.jsx(Tn,{checked:F==="checked"?!0:F==="indeterminate"?"indeterminate":!1,onCheckedChange:z,"aria-label":"Select all"})]})]}),l.jsx("div",{className:"-mx-1 max-h-[260px] overflow-y-auto px-1",role:"listbox","aria-multiselectable":!g,children:I?l.jsx("div",{className:"space-y-0.5",children:Array.from({length:6}).map((M,B)=>{const W=["w-32","w-24","w-40","w-28","w-36","w-20"];return l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5","aria-hidden":"true",children:[l.jsx(Xs,{className:"h-3.5 w-3.5 shrink-0 rounded-[3px] bg-foreground/[0.06]"}),l.jsx(Xs,{className:p.cn("h-3 rounded-[3px] bg-foreground/[0.06]",W[B%W.length])})]},B)})}):r.length===0?l.jsx("div",{className:"px-2 py-6 text-center text-[12px] text-muted-foreground",children:i?"No matches":"No options"}):r.map(M=>{var P;const B=j.has(M.value),W=((P=M.label)==null?void 0:P.toString())||String(M.value);return l.jsxs("div",{role:"option",tabIndex:0,"aria-selected":B,onClick:()=>E(M),onKeyDown:G=>D(G,M),className:p.cn("flex w-full cursor-pointer select-none items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px] text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",B?"bg-muted hover:bg-foreground/[0.08]":"hover:bg-muted"),children:[l.jsx(Tn,{checked:B,className:"pointer-events-none",tabIndex:-1,"aria-hidden":"true"}),l.jsx("span",{className:"truncate",children:W})]},`${M.id}:${M.value}`)})}),l.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border-t border-border pt-2",children:[l.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"tabular-nums text-foreground",children:_&&!N&&w.length===0?1:w.length})," ","selected"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[(N||k)&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:$,children:"Clear"}),l.jsx(p.Button,{type:"button",variant:"default",size:"xs",onClick:L,disabled:!N,children:"Apply"})]})]})]})}function cQe({filter:e,onUpdate:t}){const[n,r]=v.useState(""),o=p.useDashboardStore(N=>N.dashboard.sheets),s=v.useMemo(()=>p.getDashboardSheets(o??[]),[o]),i=p.useDashboardStore(N=>N.selectedSheetId),a=v.useMemo(()=>{const N=[];return s.forEach(S=>{var j;(j=S.frames)==null||j.forEach(_=>{var k;(k=_.cards)==null||k.forEach(T=>{N.push({...T,sheetId:S.id,sheetTitle:S.title||S.id})})})}),N},[s]),c=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",u=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",d=N=>{const S={};switch(N){case"all-sheets":S.applyToSheetIds=void 0,S.excludeSheetIds=void 0;break;case"specific-sheets":S.applyToSheetIds=[],S.excludeSheetIds=void 0;break;case"all-except-specific":S.applyToSheetIds=void 0,S.excludeSheetIds=[];break}t(S)},f=N=>{const S={};switch(N){case"all-cards":S.applyToCardIds=void 0,S.excludeCardIds=void 0;break;case"specific-cards":S.applyToCardIds=[],S.excludeCardIds=void 0;break;case"all-except-specific":S.applyToCardIds=void 0,S.excludeCardIds=[];break}t(S)},h=(N,S)=>{if(S==="specific-sheets"){const j=e.applyToSheetIds||[];t({applyToSheetIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}else if(S==="all-except-specific"){const j=e.excludeSheetIds||[];t({excludeSheetIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}},m=(N,S)=>{if(S==="specific-cards"){const j=e.applyToCardIds||[];t({applyToCardIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}else if(S==="all-except-specific"){const j=e.excludeCardIds||[];t({excludeCardIds:j.includes(N)?j.filter(_=>_!==N):[...j,N]})}},g=v.useMemo(()=>e.applyToSheetIds!==void 0?e.applyToSheetIds:e.excludeSheetIds!==void 0?s.filter(N=>{var S;return!((S=e.excludeSheetIds)!=null&&S.includes(N.id))}).map(N=>N.id):s.map(N=>N.id),[s,e.applyToSheetIds,e.excludeSheetIds]),b=v.useMemo(()=>a.filter(N=>g.includes(N.sheetId)),[a,g]),x=v.useMemo(()=>{if(!n.trim())return b;const N=n.toLowerCase();return b.filter(S=>{var j;return(j=S==null?void 0:S.title)==null?void 0:j.toLowerCase().includes(N)})},[n,b]),y=c(),w=u(),C=(N,S,j,_)=>l.jsxs("label",{htmlFor:S,className:"flex cursor-pointer items-start gap-2 rounded-control px-1 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsx(vs,{value:N,id:S,className:"mt-0.5"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("span",{className:"text-[13px] text-foreground",children:j}),_?l.jsx("p",{className:"text-[11px] text-muted-foreground",children:_}):null]})]});return l.jsxs("div",{className:"space-y-5",children:[l.jsxs("section",{className:"space-y-2",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Sheet scope"}),l.jsxs(rl,{value:y,onValueChange:N=>d(N),className:"space-y-0.5",children:[C("all-sheets","all-sheets","All sheets",`Display on every dashboard sheet (${s.length} total)`),C("specific-sheets","specific-sheets","Only specific sheets"),y==="specific-sheets"&&l.jsx("div",{className:"ml-6 mt-1 flex max-h-40 flex-col gap-0.5 overflow-y-auto border-l border-border/60 pl-3",children:s.map(N=>{const S=(e.applyToSheetIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`sheet-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`sheet-${N.id}`,checked:S,onCheckedChange:()=>h(N.id,"specific-sheets")}),l.jsx("span",{className:"truncate text-[13px] text-foreground",children:N.title||N.id}),N.id===i&&l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"· current"})]},N.id)})}),C("all-except-specific","all-sheets-except","All except specific sheets"),y==="all-except-specific"&&l.jsx("div",{className:"ml-6 mt-1 flex max-h-40 flex-col gap-0.5 overflow-y-auto border-l border-border/60 pl-3",children:s.map(N=>{const S=(e.excludeSheetIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`sheet-exclude-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`sheet-exclude-${N.id}`,checked:S,onCheckedChange:()=>h(N.id,"all-except-specific")}),l.jsx("span",{className:"truncate text-[13px] text-foreground",children:N.title||N.id}),N.id===i&&l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"· current"})]},N.id)})})]})]}),l.jsxs("section",{className:"space-y-2 border-t border-border/60 pt-4",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Card scope"}),l.jsxs(rl,{value:w,onValueChange:N=>f(N),className:"space-y-0.5",children:[C("all-cards","all-cards","All cards",`Apply to every card in applicable sheets (${b.length} total)`),C("specific-cards","specific-cards","Only specific cards"),w==="specific-cards"&&l.jsxs("div",{className:"ml-6 mt-1 space-y-1 border-l border-border/60 pl-3",children:[l.jsx(p.Input,{size:"xs",placeholder:"Search cards…",value:n,onChange:N=>r(N.target.value)}),l.jsx("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto pt-1",children:x.length>0?x.map(N=>{const S=(e.applyToCardIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`card-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`card-${N.id}`,checked:S,onCheckedChange:()=>m(N.id,"specific-cards")}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[13px] text-foreground",children:N.title}),l.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:N.sheetTitle})]})]},N.id)}):l.jsxs("p",{className:"py-4 text-center text-[12px] text-muted-foreground",children:["No cards match “",n,"”."]})})]}),C("all-except-specific","all-cards-except","All except specific cards"),w==="all-except-specific"&&l.jsxs("div",{className:"ml-6 mt-1 space-y-1 border-l border-border/60 pl-3",children:[l.jsx(p.Input,{size:"xs",placeholder:"Search cards…",value:n,onChange:N=>r(N.target.value)}),l.jsx("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto pt-1",children:x.length>0?x.map(N=>{const S=(e.excludeCardIds||[]).includes(N.id);return l.jsxs("label",{htmlFor:`card-exclude-${N.id}`,className:"flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 hover:bg-muted/50",children:[l.jsx(Tn,{id:`card-exclude-${N.id}`,checked:S,onCheckedChange:()=>m(N.id,"all-except-specific")}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[13px] text-foreground",children:N.title}),l.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:N.sheetTitle})]})]},N.id)}):l.jsxs("p",{className:"py-4 text-center text-[12px] text-muted-foreground",children:["No cards match “",n,"”."]})})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Card scope is restricted to cards in the sheets selected above."})]})}function OI(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var uQe=["color"],dQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,uQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),fQe=["color"],hQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,fQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),mQe=["color"],pQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,mQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),gQe=["color"],bQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=OI(e,gQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function Pd({text:e,className:t,ariaLabel:n,onCopy:r,disabled:o=!1,label:s,copiedLabel:i="Copied",showIcon:a=!0,variant:c="ghost",size:u}){const[d,f]=v.useState(!1),h=!!s,m=v.useRef(void 0);return v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),l.jsxs(p.Button,{className:p.cn(!h&&"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:c,size:u??(h?"xs":"icon"),"aria-label":n,disabled:o,onClick:async()=>{try{let g=!1;if(r)g=await r();else if(typeof e=="string"){if(typeof navigator>"u"||!navigator.clipboard)return;await navigator.clipboard.writeText(e),g=!0}if(!g)return;f(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(!1),m.current=void 0},1e3)}catch(g){console.error("Failed to copy text",g)}},children:[a?d?l.jsx(pQe,{className:"size-3.5"}):l.jsx(Jh,{className:"size-3.5"}):null,h?l.jsx("span",{children:d?i:s}):null]})}function Jce(){const{authToken:e,tokenProps:t}=It(),{data:n,isLoading:r,isFetching:o,isError:s}=Un({queryKey:["plugins",e==null?void 0:e.accessToken],queryFn:()=>p.getPlugins(t.apiServiceUrl,e==null?void 0:e.accessToken)});return{data:n,isLoading:r,isFetching:o,isError:s}}function R$(){const{data:e,isLoading:t,isError:n}=Jce(),r=ib({queries:((e==null?void 0:e.plugins)||[]).map(c=>({queryKey:["manifest",c.value],queryFn:()=>gle(c.value),enabled:!!c.value,staleTime:5*60*1e3,gcTime:10*60*1e3,retry:2,retryDelay:u=>Math.min(1e3*2**u,3e4)}))}),o=[],s=[];let i=t,a=n;return r.forEach((c,u)=>{var d;if(c.isLoading&&(i=!0),c.isError&&(a=!0),c.data&&((d=e==null?void 0:e.plugins)!=null&&d[u])){const f=e.plugins[u],h=c.data.visuals.map(m=>({name:m.name,pluginName:f.label,componentType:m.componentType,pluginType:f.type,icon:m.icon,chartType:m.chartType,visualType:m.visualType||(m.dataInputs&&m.dataInputs.length>1?"multiple":"single"),minInputs:m.minInputs,maxInputs:m.maxInputs,slots:m.slots,url:f.value}));if(o.push(...h),c.data.filters){const m=c.data.filters.map(g=>({name:g.name,component:g.component,pluginName:f.label,pluginType:f.type,icon:g.icon,filterType:g.filterType,supportedDataTypes:g.supportedDataTypes,url:f.value}));s.push(...m)}}}),{data:o,filters:s,isLoading:i,isError:a}}function xQe(e){const[t,n]=v.useState(null);return t}function yQe({pluginFilter:e}){const t=xQe(e.icon||""),n=e.name.charAt(0).toUpperCase();return l.jsxs("div",{className:"flex items-center gap-2",children:[t?l.jsx(t,{className:"h-4 w-4"}):l.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted text-xs font-medium",children:n}),l.jsx("span",{children:e.name}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",e.pluginName,")"]})]})}function vQe({filter:e,onSelect:t,onClear:n}){const{filters:r,isLoading:o}=R$(),s=p.getDataType(e.dataType),i=r==null?void 0:r.filter(u=>!u.supportedDataTypes||u.supportedDataTypes.length===0?!0:u.supportedDataTypes.some(d=>s.toLowerCase()===d.toLowerCase())),a=e.customFilterPreferences,c=a?`${a.url}::${a.componentName}`:"";return o?l.jsx("div",{className:"flex h-7 items-center rounded-control border border-input bg-background px-2 text-[12px] text-muted-foreground",children:"Checking available custom filters…"}):!i||i.length===0?l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No custom filters available."}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(p.Select,{value:c,onValueChange:u=>{if(!u)return;const[d,f]=u.split("::"),h=i.find(m=>m.url===d&&m.component===f);h&&t({url:d,componentName:h.component,pluginFilterType:h.filterType,icon:h.icon})},children:[l.jsx(p.SelectTrigger,{className:"h-9 flex-1",children:l.jsx(p.SelectValue,{placeholder:"Use default UI"})}),l.jsx(p.SelectContent,{children:i.map(u=>l.jsx(p.SelectItem,{value:`${u.url}::${u.component}`,children:l.jsx(yQe,{pluginFilter:u})},`${u.url}::${u.component}`))})]}),a&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:n,title:"Clear custom filter selection",children:l.jsx(je.X,{className:"h-4 w-4"})})]})}function eue(e){if((e==null?void 0:e.mode)!=="period")return;const t=e.spec;if(t.kind==="previous_year"){const r=t.offsetYears??1;return r===1?"vs previous year":`vs ${r} years ago`}const n=t.offsetPeriods??1;return n===1?"vs previous period":`vs ${n} periods ago`}function wQe(e){for(const[n,r]of Object.entries(p.presetMetadata))if(JSON.stringify(r)===JSON.stringify(e))return n;const t={minute:"minute",hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter",year:"year"};switch(e.mode){case"last":{const n=e.complete?" (complete)":"",r=e.n>1?"s":"";return`Last ${e.n} ${t[e.unit]}${r}${n}`}case"this":{if(e.boundary==="first_day")return"First day of the month";if(e.boundary==="last_day")return"Last day of the month";const n=e.toDate?" to date":"";return`This ${t[e.unit]}${n}`}case"previous":return`Previous ${t[e.unit]}`;case"between":return`Between ${e.from} and ${e.to} ${t[e.unit]}s`}}const CQe=["January","February","March","April","May","June","July","August","September","October","November","December"];function SQe(e){return p.isFixedMonthDefaultDateFilter(e)?`${CQe[e.month]} ${e.year}`:wQe(e)}function vM(e){return e&&p.isRelativeDateFilter(e)?"relative":"fixed"}function LI(e){return"kind"in e&&e.kind==="global-date"}function $S(e){return LI(e)?p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column}function NQe({selection:e,controlLabel:t,onChange:n}){return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),l.jsx(Gce,{selection:e,controlLabel:t,onChange:n})]})}function jQe({filter:e,onUpdate:t,variableName:n,reservedVariableNames:r=[],onUpdateInputMetadata:o,showFilterId:s=!0,filterOptionsData:i,timezone:a,variant:c="dashboard",defaultComparisonSelection:u,onDefaultComparisonChange:d,onDefaultDatePickerOpenChange:f}){var Y;const h=LI(e),[m,g]=v.useState(e.title===$S(e)?"":e.title||""),[b,x]=v.useState(((Y=e.defaultValues)==null?void 0:Y.map(O=>String(O)))||[]),[y,w]=v.useState(e.defaultDateFilter),[C,N]=v.useState(vM(e.defaultDateFilter)),[S,j]=v.useState(e.targetColumns||[]),[_,k]=v.useState(n||""),[T,I]=v.useState(null),E=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),D=a||Intl.DateTimeFormat().resolvedOptions().timeZone,R=c==="inline"||c==="document"?"z-[80]":void 0,A=u&&d?l.jsx(NQe,{selection:u,controlLabel:e.title||"Date",onChange:d}):void 0,F=eue(u),z=v.useMemo(()=>{if(!y)return;const O=p.resolveDefaultDateFilterForDefaults(y,D);if(!O)return;const[q,U]=O;return{from:q,to:U}},[y,D]),L=v.useMemo(()=>{if(y&&p.isFixedMonthDefaultDateFilter(y))return{year:y.year,month:y.month}},[y]),$=v.useMemo(()=>{if(!(!y||!p.isRelativeDateFilter(y)))return y},[y]);v.useEffect(()=>{var q;g(e.title===$S(e)?"":e.title||""),x(((q=e.defaultValues)==null?void 0:q.map(U=>String(U)))||[]);const O=e.defaultDateFilter;w(O),N(vM(O)),j(e.targetColumns||[])},[e]),v.useEffect(()=>{k(n||""),I(null)},[n]);function H(){const O=m.trim();t({title:O||$S(e)})}function M(){if(!o||n===void 0)return;const O=_.trim();if(!O){k(n),I(null);return}const q=Lv(O);if(q!==n&&r.includes(q)){I(`"${q}" is already used by another input.`);return}I(null),k(q),q!==n&&o({variableName:q})}function B(O){x(O);const q=O.length>0?O.map(U=>{const V=Number(U);return!isNaN(V)&&p.isNumberDataType(e.dataType)?V:U}):void 0;t({defaultValues:q})}function W(O){w(O),O&&N(vM(O)),t({defaultDateFilter:O})}function P(O){j(O),t({targetColumns:O.length>0?O:void 0})}function G(){P([...S,{column:"",label:""}])}function Z(O){const q=S.filter((U,V)=>V!==O);P(q)}function X(O,q,U){const V=S.map((K,Q)=>Q===O?{...K,[q]:U}:K);P(V)}return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-[12px]",children:"Leave empty to use the column name. Provide a custom label to override it."}),s&&l.jsxs("div",{className:"space-y-1 border-t pt-2",children:[l.jsx("p",{className:"text-[12px] font-medium",children:"Filter ID"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),l.jsx(Pd,{text:e.id})]})]})]})})]})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[l.jsx(Tn,{id:"hideLabel",checked:e.showLabel===!1,onCheckedChange:O=>{t({showLabel:!O})}}),l.jsx(p.Label,{htmlFor:"hideLabel",className:"cursor-pointer text-[11px] text-muted-foreground",children:"Hide label"})]})]}),l.jsx(p.Input,{size:"xs",value:m,onChange:O=>g(O.target.value),onBlur:H,placeholder:$S(e)})]}),n!==void 0&&o?l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),l.jsx(p.Input,{size:"xs",value:_,onChange:O=>k(O.target.value),onBlur:M,"aria-invalid":!!T,className:"font-mono",placeholder:"input_name"}),T?l.jsx("p",{className:"text-[10px] leading-3 text-destructive",children:T}):null]}):null,E?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Date Filter"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial date selection on load and previews it immediately while editing. Relative defaults recalculate on each load and scheduled execution, while fixed month defaults stay unchanged."})})]})})]}),e.dateSelectionMode==="months"?l.jsxs(p.Tabs,{value:C,onValueChange:O=>N(O),className:"space-y-2",children:[l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"fixed",className:"h-7 text-[12px] leading-none",children:"Fixed"}),l.jsx(p.TabsTrigger,{value:"relative",className:"h-7 text-[12px] leading-none",children:"Relative"})]}),l.jsx(p.TabsContent,{value:"fixed",className:"mt-0",children:l.jsx(Wce,{value:L,placeholder:"Select default month...",className:"w-full",onClear:()=>W(void 0),onChange:(O,q)=>W({mode:"fixed",unit:"month",year:O,month:q})})}),l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs(p.Select,{value:$?JSON.stringify($):"__none__",onValueChange:O=>{if(O==="__none__"){W(void 0);return}try{const q=JSON.parse(O);W(q)}catch(q){console.error("Failed to parse relative date filter",q)}},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select default month range..."})}),l.jsxs(p.SelectContent,{className:R,children:[l.jsx(p.SelectItem,{value:"__none__",children:"None"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"this",unit:"month"}),children:"This month"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"previous",unit:"month"}),children:"Last month"})]})]})})]}):l.jsx(E$,{value:z,relativeValue:p.isRelativeDateFilter(y)?y:void 0,onRelativeSelect:(O,q)=>{W(q)},showRelativeTab:!0,hideCalendar:!0,timezone:D,placeholder:"Select default date range…",buttonClassName:"h-7 text-[12px]",buttonLabelSuffix:F,contentClassName:R,overlayContentClassName:R,supplementalFooter:A,onOpenChange:f}),y&&l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[SQe(y),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>W(void 0),"aria-label":"Clear default date",children:l.jsx(je.X,{className:"h-3 w-3"})})]})}),e.dateSelectionMode==="months"?A:null]}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Values"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial selection on load and previews it immediately while editing. Works like a filter selection."})})]})})]}),i!=null&&i.records&&i.records.length>0?l.jsxs(p.Select,{value:"",onValueChange:O=>{O&&!b.includes(O)&&B([...b,O])},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select values to add..."})}),l.jsxs(p.SelectContent,{className:R,children:[i.records.filter(O=>{var V;const q=(V=e.column.split(".").pop())==null?void 0:V.replace(/"/g,""),U=q?O[q]:O.value;return U!=null&&!b.includes(String(U))}).map(O=>{var V;const q=(V=e.column.split(".").pop())==null?void 0:V.replace(/"/g,""),U=q?O[q]:O.value;return l.jsx(p.SelectItem,{value:String(U),children:String(U)},String(U))}),i.records.every(O=>{var V;const q=(V=e.column.split(".").pop())==null?void 0:V.replace(/"/g,""),U=q?O[q]:O.value;return U==null||b.includes(String(U))})&&l.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All values selected"})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading filter options…"}),b.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Selected · ",b.length]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:b.map(O=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[String(O),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>{B(b.filter(q=>q!==O))},"aria-label":`Remove ${O}`,children:l.jsx(je.X,{className:"h-3 w-3"})})]},O))})]})]}),E&&!h&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Target Columns"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Add multiple date columns to let users choose which field to filter at runtime. Leave empty to use only the primary column above."})})]})})]}),S.length>0&&l.jsx("div",{className:"space-y-2",children:S.map((O,q)=>l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Input,{size:"xs",placeholder:"Column name",value:O.column,onChange:U=>X(q,"column",U.target.value),className:"flex-1 font-mono"}),l.jsx(p.Input,{size:"xs",placeholder:"Label",value:O.label,onChange:U=>X(q,"label",U.target.value),className:"flex-1"}),l.jsx(p.Button,{variant:"ghost",size:"xs",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>Z(q),"aria-label":"Remove target column",children:l.jsx(je.X,{className:"h-3.5 w-3.5"})})]},q))}),l.jsxs(p.Button,{variant:"outline",size:"xs",onClick:G,children:[l.jsx(Tr,{className:"h-3.5 w-3.5"}),"Add column"]})]})]})}function kQe({filter:e,onUpdate:t,variant:n="dashboard"}){const r=LI(e),{filters:o,isLoading:s}=R$(),i=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),a=n==="inline"||n==="document"?"z-[80]":void 0,c=v.useMemo(()=>{const b=p.getDataType(e.dataType);return(o==null?void 0:o.filter(x=>!x.supportedDataTypes||x.supportedDataTypes.length===0?!0:x.supportedDataTypes.some(y=>b.toLowerCase()===y.toLowerCase())))??[]},[e.dataType,o]),u=!r&&(s||!!e.customFilterPreferences||c.length>0);function d(b){t({type:b})}function f(b){t({dateSelectionMode:b})}function h(b){t({uiType:b})}function m(b){t({customFilterPreferences:b})}function g(){t({customFilterPreferences:void 0})}return l.jsxs("div",{className:"space-y-4",children:[i?l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date Picker Type"}),l.jsxs(p.Select,{value:e.dateSelectionMode||"range",onValueChange:b=>f(b),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"range",children:"Date Range Picker"}),l.jsx(p.SelectItem,{value:"months",children:"Month Picker"})]})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Selection Type"}),l.jsxs(p.Select,{value:e.type||"multiple",onValueChange:d,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"multiple",children:"Multiple"}),l.jsx(p.SelectItem,{value:"single",children:"Single"})]})]})]}),!i&&e.type==="single"&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"UI Component"}),l.jsxs(p.Select,{value:e.uiType||"dropdown",onValueChange:h,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"dropdown",children:"Dropdown"}),l.jsx(p.SelectItem,{value:"radio",children:"Radio"}),l.jsx(p.SelectItem,{value:"tabs",children:"Tabs"})]})]})]}),u&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom Filter Component"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Select a custom filter component from an installed plugin to replace the default filter UI with a custom implementation."})})]})})]}),l.jsx(vQe,{filter:e,onSelect:m,onClear:g})]}),n==="dashboard"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:`Choose how this filter is displayed. "Inherit" uses the dashboard's default setting. Override with "Canvas Card" or "Toolbar" to always display this filter in a specific mode.`})})]})})]}),l.jsxs(p.Select,{value:e.displayMode||"inherit",onValueChange:b=>t({displayMode:b}),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",children:"Inherit (use dashboard default)"}),l.jsx(p.SelectItem,{value:"canvas",children:"Canvas Card"}),l.jsx(p.SelectItem,{value:"toolbar",children:"Toolbar"})]})]})]}),n==="inline"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Width (px)"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Set the width of this inline filter in pixels. Default is 250px."})})]})})]}),l.jsx(p.Input,{size:"xs",type:"number",min:100,max:500,value:e.width??250,onChange:b=>{const x=parseInt(b.target.value,10);isNaN(x)||t({width:x})},className:"w-24"})]})]})}function _Qe({filter:e,onUpdate:t}){const[n,r]=v.useState(e.column);v.useEffect(()=>{r(e.column)},[e.column]);function o(){const s=n.trim();if(s&&s!==e.column){const i=!e.title||e.title===e.column;t(i?{column:s,title:s}:{column:s})}}return l.jsx(p.Input,{size:"xs",value:n,onChange:s=>r(s.target.value),onBlur:o,placeholder:"Enter column name",className:"font-mono"})}function IQe({filter:e,onUpdate:t,variant:n="dashboard"}){return LI(e)?l.jsx("div",{className:"rounded-control border border-border/60 bg-muted/30 p-3 text-[12px] text-muted-foreground",children:"Global date filters are not bound to a specific column. Configure the picker type, layout, and scope in the other tabs."}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter column name"}),l.jsx(_Qe,{filter:e,onUpdate:t})]}),l.jsx(TQe,{filter:e,onUpdate:t,variant:n})]})}function TQe({filter:e,onUpdate:t,variant:n="dashboard"}){const[r,o]=v.useState(e.sql),[s,i]=v.useState(e.searchMode||"auto"),a=n==="inline"||n==="document"?"z-[80]":void 0;v.useEffect(()=>{o(e.sql),i(e.searchMode||"auto")},[e]);function c(){t({sql:r})}function u(d){i(d),t({searchMode:d})}return l.jsxs("div",{className:"space-y-4",children:[p.isNumberDataType(e.dataType)&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Search Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2 text-xs",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Text Search:"}),' Treats numbers as text (e.g., ZIP codes, IDs). Search for "90210".']}),l.jsxs("p",{children:[l.jsx("strong",{children:"Numeric Operators:"})," Supports comparison operators (e.g., >100, <=50, =100) for quantities, prices."]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Auto-detect:"})," Tries numeric first, falls back to text search."]})]})})]})})]}),l.jsxs(p.Select,{value:s,onValueChange:u,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"text",children:"Text Search"}),l.jsx(p.SelectItem,{value:"numeric",children:"Numeric Operators"}),l.jsx(p.SelectItem,{value:"auto",children:"Auto-detect"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter values custom SQL"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"This SQL will be used to fetch the filter values"})})]})})]}),l.jsx("div",{className:"h-36 w-full overflow-hidden rounded-control border border-input",onBlur:c,onKeyDown:d=>d.stopPropagation(),children:l.jsx(p.CodeEditor,{value:r,onValueChange:o,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,dense:!0,ariaLabel:"Filter values custom SQL",placeholder:`SELECT ${e.column.split(".").pop()||"value"} FROM ... {{ filters | where }}`})})]})]})}const EQe=[{id:"basic",label:"Basic"},{id:"scope",label:"Scope"},{id:"advanced",label:"Advanced"}];function A$({filter:e,variant:t="dashboard",onAccept:n,inputVariableName:r,reservedInputVariableNames:o,open:s,onOpenChange:i,trigger:a,isEditing:c=!1,filterQueryContext:u,onDelete:d}){const f=dc("interactive");function h(K){if(!K)return"Unknown";const Q=p.getDataType(K),se=Q==="date"?"Datetime":Q==="string"?"Text":Q==="number"?"Number":Q==="boolean"?"Boolean":Q==="json"?"JSON":"Geo";return/nullable/i.test(K)?`${se} (nullable)`:se}const[m,g]=v.useState(!1),b=s??m,x=i??g,[y,w]=v.useState("basic"),C="kind"in e&&e.kind==="global-date",[N,S]=v.useState({}),[j,_]=v.useState({}),[k,T]=v.useState({mode:"off"}),[I,E]=v.useState(!1),[D,R]=v.useState(!1),A=p.useDashboardStore(K=>K.dashboard),F=p.useDashboardStore(K=>K.selectedSheetId),{updateFilter:z,addOrUpdateFilterValue:L,removeFilterValues:$,setDefaultDashboardInputComparisonSelection:H}=p.useDashboardActions(),M=v.useMemo(()=>{if(t!=="dashboard")return;const K=Lw(A,e.id);if(!(!K||!p.isComparisonCapableDashboardDateInput(K)||!p.canAddressDashboardInputRuntimeSlot(K,{sheetId:F})))return K},[A,e.id,F,t]),B=v.useMemo(()=>EQe.filter(K=>!(t!=="dashboard"&&K.id==="scope"||C&&K.id==="advanced")),[C,t]),{tokenProps:W}=It(),P=dl()??void 0,{data:G}=c$(e,{filterQueryContext:u}),Z={...e,...N};function X(){let K={...N};j.variableName&&!n&&(K={...K,variableName:j.variableName});const Q=Object.prototype.hasOwnProperty.call(K,"defaultValues")||Object.prototype.hasOwnProperty.call(K,"defaultDateFilter");if(t==="inline"&&"width"in K){const se=K.width;K={...K,width:Math.min(500,Math.max(100,se))}}if(n)n(K,j);else{const se={...e,...K};if(z(se),Q){const oe=p.buildFilterValueFromDefaults(se,P);oe?L(oe):$(e.id)}}I&&M&&H(M,{sheetId:F},k.mode==="off"?void 0:k),S({}),_({}),E(!1),x(!1)}function Y(K){S(Q=>({...Q,...K}))}function O(K){_(Q=>({...Q,...K}))}v.useEffect(()=>{var K;b&&(R(!1),S({}),_({}),T(M?((K=p.getDashboardInputRuntimeSlot(A.defaultInputValues,M,{sheetId:F}))==null?void 0:K.comparisonSelection)||{mode:"off"}:{mode:"off"}),E(!1),w("basic"))},[A.defaultInputValues,M,b,F]);const q=C?e.title||p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column.split(".").pop()||e.column,U=C?q:e.column,V=C?"Global date":h(e.dataType);return l.jsxs(p.Popover,{open:b,onOpenChange:x,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:a??l.jsx("button",{type:"button",className:p.cn("rounded p-0.5 hover:bg-muted focus:visible focus:outline-none focus:ring-1 focus:ring-ring",c?"visible":"invisible group-hover:visible"),"aria-label":"Filter settings",children:l.jsx(Fm,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})}),l.jsxs(p.PopoverContent,{collisionPadding:12,onMouseDown:K=>{D||K.stopPropagation()},onDoubleClick:K=>K.stopPropagation(),style:f.controlStyle,className:p.cn("flex h-[440px] max-h-[85vh] w-[480px] flex-col overflow-hidden rounded-control border border-border/60 p-0 shadow-sm",t==="inline"||t==="document"?"z-[70]":"z-50"),children:[l.jsxs("div",{className:"flex min-h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[l.jsx($d,{"aria-hidden":!0,className:"mt-1 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",title:q,children:q}),l.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",title:e.dataType,children:V})]}),l.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] leading-3 text-muted-foreground/70",title:U,children:U})]})]}),l.jsx("button",{type:"button",onClick:()=>x(!1),"aria-label":"Close",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx("svg",{"aria-hidden":!0,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.75,className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M5 5l10 10M15 5L5 15",strokeLinecap:"round"})})})]}),l.jsx("nav",{role:"tablist","aria-label":"Filter settings sections",className:"flex h-9 shrink-0 items-stretch gap-4 border-b border-border/60 px-4",children:B.map(K=>l.jsxs("button",{role:"tab","aria-selected":y===K.id,onClick:()=>w(K.id),className:p.cn("relative -mb-px inline-flex items-center text-[13px] transition-colors focus-visible:outline-none",y===K.id?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[K.label,y===K.id&&l.jsx("span",{"aria-hidden":!0,className:"absolute inset-x-0 -bottom-px h-[2px] bg-foreground"})]},K.id))}),l.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:[y==="basic"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx(jQe,{filter:Z,onUpdate:Y,variableName:j.variableName??r,reservedVariableNames:o,onUpdateInputMetadata:r===void 0?void 0:O,showFilterId:!0,filterOptionsData:G,timezone:P,variant:t,defaultComparisonSelection:M?k:void 0,onDefaultComparisonChange:M?K=>{T(K),E(!0)}:void 0,onDefaultDatePickerOpenChange:R}),l.jsx(kQe,{filter:Z,onUpdate:Y,variant:t})]}),y==="advanced"&&l.jsx(IQe,{filter:Z,onUpdate:Y,variant:t}),y==="scope"&&t==="dashboard"&&l.jsx(cQe,{filter:Z,onUpdate:Y})]}),l.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 bg-background px-4 py-2.5",children:[d?l.jsxs(p.Button,{variant:"ghost",size:"xs",onClick:()=>{d(),x(!1)},className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:[l.jsx(je.X,{className:"h-3 w-3"}),"Delete"]}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:()=>x(!1),children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:X,children:"Accept"})]})]})]})]})}function DQe(e,t){const n=e?ab({dashboard:e}).allInputs.find(r=>r.id===Oi.getDashboardFilterCompatInputId(t.id)):void 0;return(n==null?void 0:n.variableName)||t.variableName||HY(t.title||t.column||t.id)}function tue(e,t){if(!e)return[];const n=MQe(t),r=new Set;for(const o of ab({dashboard:e}).allInputs)o.id!==n&&r.add(o.variableName);return Array.from(r)}function MQe(e){if(e)return e.source==="dashboardFilter"?Oi.getDashboardFilterCompatInputId(e.filterId):Oi.getDashboardControlCompatInputId(e.controlId)}function RQe(e,t={}){const{enabled:n=!0,eventType:r="mousedown"}=t,o=v.useRef(null);return v.useEffect(()=>{const s=i=>{const a=i.target;o.current&&o.current.contains(a)||a instanceof Element&&(a.closest("[data-radix-popper-content-wrapper]")||a.closest("[data-radix-select-content]")||a.closest("[data-radix-popover-content]")||a.closest("[data-radix-dropdown-menu-content]")||a.closest("[data-radix-tooltip-content]")||a.closest('[role="listbox"]')||a.closest('[role="option"]')||a.closest('[role="combobox"]'))||a instanceof Element&&a.hasAttribute("data-radix-")||e()};return n&&document.addEventListener(r,s),()=>{document.removeEventListener(r,s)}},[e,n,r]),o}const AQe=24;function Ox(e,t=AQe){return e.length<=t?e:`${e.slice(0,t-1)}…`}function PQe(e,t,n){if(!t)return null;if(t.operation==="is null")return"is empty";if(t.operation==="is not null")return"is not empty";const r=t.values;if(!r||r.length===0)return null;const o=p.getDataType(e.dataType),s=a=>{try{return Kt.formatInTimeZone(new Date(a),n,"MMM d")}catch{return String(a)}},i={"=":"=","!=":"≠","<":"<","<=":"≤",">":">",">=":"≥"};if(o==="date"){const a=t.relativeMeta,c=p.getRelativeDateLabel(a);if(c)return c;const u=r[0],d=r[1];if(!u)return null;if(d){const m=`${s(u)} – ${s(d)}`;return t.operation==="not between"?`not ${m}`:m}const f=i[t.operation],h=s(u);return f?`${f} ${h}`:h}if(o==="number"&&(t.operation==="between"||t.operation==="not between")&&r.length>=2){const a=`${String(r[0])} – ${String(r[1])}`;return t.operation==="not between"?`not ${a}`:a}if(o==="number"&&r.length===1&&t.operation!=="in"&&t.operation!=="not in"){const a=i[t.operation];if(a)return Ox(`${a} ${String(r[0])}`)}return t.operation==="not in"?r.length===1?Ox(`not ${String(r[0])}`):`${r.length} excluded`:t.operation==="not like"?Ox(`not ${String(r[0])}`):t.operation==="like"?Ox(`contains ${String(r[0])}`):r.length===1?Ox(String(r[0])):`${r.length} selected`}function FQe(e){return p.getDataType(e.dataType)==="date"||e.kind==="global-date"?mN:(e.searchMode==="numeric",null)}function OQe(e){return p.getDataType(e.dataType)==="date"||e.kind==="global-date"?360:e.uiType==="tabs"?320:e.uiType==="radio"?260:e.searchMode==="numeric"?240:300}function rU(e){var t;return!((t=e.customFilterPreferences)!=null&&t.url||e.kind==="global-date"||p.isDateDataType(e.dataType)||e.searchMode==="numeric"||e.type==="single"&&(e.uiType==="radio"||e.uiType==="tabs"))}function LQe(e,t){var o;const n=(t==null?void 0:t.name)||e.column;if(n===e.column)return e.title||e.column;const r=(o=e.targetColumns)==null?void 0:o.find(s=>s.column===n);return(r==null?void 0:r.label)||n}function P$({filter:e,isEditing:t=!1,dragListeners:n,storageOptions:r,settingsVariant:o="dashboard",filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){var O,q,U;const d=M$(e,r),f=dc("interactive"),h=p.useDashboardStore(V=>V.dashboard),m=p.useDashboardStore(V=>V.semanticExecutionPayload),{removeFilterValues:g,removeFilter:b,clearDashboardInputSlot:x}=p.useDashboardActions(),y=p.useDashboardStore(V=>V.actions.removeCardInlineFilterValue),w=(d==null?void 0:d.storageTarget)==="card",C=(d==null?void 0:d.storageTarget)==="dashboardInput",N=d==null?void 0:d.cardId,S=p.useDashboardStore(V=>V.dashboardInputValues),j=p.useDashboardStore(V=>V.selectedSheetId),_=dl(),k=v.useMemo(()=>{if(!C||!(d!=null&&d.dashboardInput))return;const V={sheetId:d.sheetId},K=p.hydrateAuthoredDashboardInputSlot({dashboard:h,input:d.dashboardInput,runtimeValues:S,target:V,timezone:_});return(K==null?void 0:K.status)==="set"&&K.value.kind==="filter"?K.value.filterValue:void 0},[h,S,C,d==null?void 0:d.dashboardInput,d==null?void 0:d.sheetId,_]),T=p.useDashboardStore(V=>{var K,Q,se;return w?N?(Q=(K=V.inlineFilterValuesMap)==null?void 0:K[N])==null?void 0:Q.find(oe=>oe.filterId===e.id):void 0:(se=V.filterValues)==null?void 0:se.find(oe=>oe.filterId===e.id)}),E=w&&(d==null?void 0:d.inlineFilterValues)!==void 0?(O=d.inlineFilterValues)==null?void 0:O.find(V=>V.filterId===e.id):C?k:T,D=v.useMemo(()=>p.isGlobalDateFilter(e)?I5({globalDateFilter:e,globalDateFilterValue:E,timezone:_,allowMinutePrecision:p.getGlobalDateFilterCoverage(h,m).allEligibleTargetsAreDateTime}):E,[h,e,E,m,_]),[R,A]=v.useState(!1),F=RQe(()=>A(!1),{enabled:R,eventType:"pointerdown"}),z=i??(o==="dashboard"?DQe(h,e):void 0),L=a??(o==="dashboard"?tue(h,{source:"dashboardFilter",filterId:e.id}):void 0),$=PQe(e,D,_),H=p.isDateDataType(e.dataType)||e.kind==="global-date",M=v.useMemo(()=>{var se;if(!H)return null;const K=(((se=d==null?void 0:d.dashboardInput)==null?void 0:se.kind)==="filter"?d.dashboardInput:void 0)||Lw(h,e.id);if(!K||!p.isComparisonCapableDashboardDateInput(K))return null;const Q=p.hydrateAuthoredDashboardInputSlot({dashboard:h,input:K,runtimeValues:S,target:{sheetId:(d==null?void 0:d.sheetId)||j},timezone:_});return eue(Q==null?void 0:Q.comparisonSelection)??null},[h,S,e,H,j,d==null?void 0:d.dashboardInput,d==null?void 0:d.sheetId,_]),B=$!==null,W=LQe(e,D),P=FQe(e),G=!!((q=e.customFilterPreferences)!=null&&q.url&&((U=e.customFilterPreferences)!=null&&U.componentName)),Z=H&&!G,X=V=>{if(V.preventDefault(),V.stopPropagation(),C&&(d!=null&&d.dashboardInput)){x(d.dashboardInput,{sheetId:d.sheetId});return}if(w&&e.id){if(d!=null&&d.removeInlineFilterValue){d.removeInlineFilterValue(e.id);return}N&&y(N,e.id);return}g(e.id)},Y=()=>{if(u){u(e.id);return}g(e.id),b(e.id)};return l.jsxs("div",{className:"group/chip flex shrink-0 items-center gap-2",children:[t&&n&&l.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Drag to reorder",className:"inline-flex h-7 cursor-grab items-center justify-center px-0.5 text-muted-foreground/50 transition-colors hover:text-muted-foreground active:cursor-grabbing",...n,children:l.jsx(Nu,{className:"size-3"})}),l.jsxs(p.Popover,{open:R,onOpenChange:A,children:[l.jsxs("div",{className:p.cn("inline-flex h-7 items-stretch overflow-hidden rounded-control border border-border text-[12px] transition-colors",B?f.hasAppearance?"bg-accent/80 hover:bg-accent":"bg-muted/80 hover:bg-muted":f.hasAppearance?"bg-muted/40 hover:bg-accent/50":"bg-muted/40 hover:bg-muted/70"),style:f.chipStyle,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-2 focus:outline-none",children:[P&&l.jsx(P,{className:p.cn("h-3 w-3 shrink-0",B?"text-muted-foreground":"text-muted-foreground/70")}),l.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:W}),B&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"max-w-[160px] truncate whitespace-nowrap font-medium text-foreground",children:$})]}),M&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"whitespace-nowrap text-[11px] font-medium text-muted-foreground",children:M})]}),l.jsx(je.ChevronDown,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"})]})}),B&&l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",className:"w-px bg-border"}),l.jsx("button",{type:"button",onClick:X,"aria-label":`Clear ${e.title||e.column}`,className:"inline-flex w-6 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(je.X,{className:"h-3 w-3"})})]})]}),l.jsx(p.PopoverContent,{ref:F,align:"start",sideOffset:4,style:{width:OQe(e),...f.contentStyle},className:p.cn(Z?"p-0":rU(e)?"p-1":"p-3"),onMouseDown:V=>V.stopPropagation(),onClick:V=>V.stopPropagation(),children:(()=>{const V=()=>A(!1);return Z?p.isGlobalDateFilter(e)?l.jsx(Zce,{filter:e,storageOptions:d,inline:!0,onApplied:V}):l.jsx(Xce,{filter:e,storageOptions:d,inline:!0,onApplied:V}):rU(e)?l.jsx(lQe,{filter:e,storageOptions:d,onApplied:V}):l.jsx(FI,{filter:e,storageOptions:d})})()})]}),t&&l.jsx("div",{className:p.cn("flex shrink-0 items-center transition-opacity",R?"opacity-100":"opacity-0 group-hover/chip:opacity-100 focus-within:opacity-100"),children:l.jsx(A$,{filter:e,variant:o,isEditing:t,filterQueryContext:s,inputVariableName:z,reservedInputVariableNames:L,onAccept:c?(V,K)=>c({...e,...V},K):void 0,onDelete:Y})})]})}function $Qe(e){return{id:e.id,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel}}function nue({inlineFilter:e,sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s}){const i=$Qe(e),a={storageTarget:"card",sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s};return l.jsx(P$,{filter:i,isEditing:!1,storageOptions:a})}function F$({card:e,sheetId:t,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o}){return!e.inlineFilters||e.inlineFilters.length===0?[]:e.inlineFilters.map(s=>l.jsx(nue,{inlineFilter:s,sheetId:t,cardId:e.id,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o},s.id))}function zQe(e){switch(e.type){case"kpi":return BQe(e);case"detailTable":case"table":return HQe(e);case"aggregateTable":case"pivotTable":return qQe(e);default:return VQe(e)}}function rue(e){return UQe(zQe(e))}function BQe(e){var i,a,c,u,d,f;const t=(i=e.preferences)==null?void 0:i.kpiVisualOptions,n=(a=e.preferences)==null?void 0:a.formatNumber,r=t==null?void 0:t.formatOptions,o=p.toTFormatOptions(p.fromSemanticFormat((d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.format));return{kpi:{primary:r?{...r,currency:r.currency||(r.type==="currency"?"USD":void 0)}:o?{...o,currency:o.currency||(o.type==="currency"?"USD":void 0)}:WQe(n),colorRanges:n==null?void 0:n.colorRanges},legacy:{formatNumber:n,numberAxisFormat:(f=e.preferences)==null?void 0:f.numberAxisFormat}}}function VQe(e){var n,r,o,s;const t=e.preferences;return{dataLabels:(n=t==null?void 0:t.dataLabelsConfig)==null?void 0:n.formatOptions,yAxis:(r=t==null?void 0:t.yAxisConfig)==null?void 0:r.formatOptions,xAxis:(o=t==null?void 0:t.xAxisConfig)==null?void 0:o.formatOptions,secondaryYAxis:(s=t==null?void 0:t.secondaryYAxisConfig)==null?void 0:s.formatOptions,legacy:{formatNumber:t==null?void 0:t.formatNumber,numberAxisFormat:t==null?void 0:t.numberAxisFormat}}}function HQe(e){var n,r;return{tableColumnSettingsMap:(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.columnSettingsMap}}function qQe(e){var n;return{tableColumnSettings:(n=e.preferences)==null?void 0:n.columnSettings}}function UQe(e){const t=[],n={};return e.tableColumnSettingsMap&&Object.entries(e.tableColumnSettingsMap).forEach(([r,o])=>{const s=o==null?void 0:o.numberFormat;t.push({id:r,numberFormat:s}),n&&(n[r]={numberFormat:s})}),e.tableColumnSettings&&e.tableColumnSettings.forEach((r,o)=>{r.type==="number"&&t.push({position:r.columnIdx??o,numberFormat:KQe(r)})}),{kpi:e.kpi,axes:{xAxis:e.xAxis,yAxis:e.yAxis,secondaryYAxis:e.secondaryYAxis},dataLabels:e.dataLabels,tables:t.length>0||Object.keys(n).length>0?{columns:t.length?t:void 0,columnMap:Object.keys(n).length>0?n:void 0}:void 0,legacy:e.legacy}}function WQe(e){const t=p.fromLegacyFormatNumber(e);return p.toTFormatOptions(t)}function KQe(e){var n,r,o,s,i,a;if(e.type!=="number")return;const t=e.options;if(!(!t||typeof t!="object")&&"options"in t){const c=t,u=((n=c.options)==null?void 0:n.style)==="currency"||((r=c.options)==null?void 0:r.style)==="percent"?c.options.style:"decimal",d=p.fromColumnNumberFormat({style:u,currency:c.currency||"USD",locale:c.locale||"en-US",minimumFractionDigits:((o=c.options)==null?void 0:o.minimumFractionDigits)??0,maximumFractionDigits:((s=c.options)==null?void 0:s.maximumFractionDigits)??((i=c.options)==null?void 0:i.minimumFractionDigits)??2,useGrouping:typeof((a=c.options)==null?void 0:a.useGrouping)=="boolean"?c.options.useGrouping:!0,percentValueMode:u==="percent"?"whole":void 0});return p.toTFormatOptions(d)}}function Rj(e,t){if(!t)return e;const n=e?{...e}:{},r=n.title!==void 0,o=n.description!==void 0;return!r&&t.title!==void 0&&(n.title=t.title),!o&&t.description!==void 0&&(n.description=t.description),Object.keys(n).length>0?n:e}function GQe({inputCard:e,slotType:t,slotIndex:n,multiInputData:r}){var s,i,a,c,u,d,f,h;if(!e)return{cardType:"unknown",title:`Tab ${n+1}`};const o=rue(e);return{cardType:t??"unknown",title:e.tabTitle||e.title||`Tab ${n+1}`,description:e.description,formatConfig:o,kpiConfig:t==="kpi"?{comparisonMetadata:(i=(s=r==null?void 0:r[e.id])==null?void 0:s.metadata)==null?void 0:i.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((c=(a=e.config)==null?void 0:a.metricColumns)==null?void 0:c[0]),comparisonPresentation:(u=e.preferences)==null?void 0:u.comparisonPresentation,showComparison:((f=(d=e.preferences)==null?void 0:d.comparisonPresentation)==null?void 0:f.showComparison)!==!1},formatNumber:(h=e.preferences)==null?void 0:h.formatNumber}:void 0}}function oue({card:e,dataMetadata:t}){var n,r,o,s,i,a;return{cardType:e.type||"unknown",title:e.tabTitle||e.title||"Tab 1",description:e.description,formatConfig:rue(e),kpiConfig:e.type==="kpi"?{comparisonMetadata:t==null?void 0:t.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((r=(n=e.config)==null?void 0:n.metricColumns)==null?void 0:r[0]),comparisonPresentation:(o=e.preferences)==null?void 0:o.comparisonPresentation,showComparison:((i=(s=e.preferences)==null?void 0:s.comparisonPresentation)==null?void 0:i.showComparison)!==!1},formatNumber:(a=e.preferences)==null?void 0:a.formatNumber}:void 0}}function O$({configCard:e,slotOrderedCards:t,slotTypes:n,multiInputData:r,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u,formatTemporalBucketValue:d}){var w;const f=n.map(C=>C??"unknown"),h=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.records)||[]:[]}),m=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.columns)||[]:[]}),g=Rj((w=e==null?void 0:e.customCardPreferences)==null?void 0:w.settings,e),b=t.map(C=>{var N;return Rj((N=C==null?void 0:C.customCardPreferences)==null?void 0:N.slotSettings,C)}),x={titles:t.map((C,N)=>C?C.tabTitle||C.title:`Tab ${N+1}`),cardTypes:f,cardIds:t.map((C,N)=>C?C.id:`missing-${N}`)},y=t.map((C,N)=>GQe({inputCard:C,slotType:f[N],slotIndex:N,multiInputData:r}));return{data:h,columns:m,formatTemporalBucketValue:d,settings:g,slotSettings:b,tabMetadata:x,cardMetadata:y,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u}}function L$(e){return e.slotOrderedCards.flatMap(t=>{if(!t)return[];const n=e.multiInputData[t.id];return[{card:t,cardConfig:n==null?void 0:n.effectiveCardConfig,columns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,executionSnapshot:e.executionSnapshot,dashboardId:e.dashboardId,attachmentIndex:e.attachmentIndex,valueFormatPreferences:e.valueFormatPreferences}]})}class YQe extends Error{constructor(n){super(`invalid_custom_visual_temporal_column: Column "${n}" is not an activated canonical temporal column from this custom-visual input. Pass the exact descriptor supplied in columns.`);Ne(this,"code","invalid_custom_visual_temporal_column");this.name="CustomVisualTemporalColumnError"}}function $$(e){const t=new Map;return e.forEach(n=>{const r=mb({card:n.card,cardConfig:n.cardConfig,columns:n.columns,columnKeyMap:n.columnKeyMap,executionSnapshot:n.executionSnapshot,dashboardId:n.dashboardId,attachmentIndex:n.attachmentIndex,valueFormatPreferences:n.valueFormatPreferences});(n.columns||[]).forEach(o=>{const s=r.byColumnKey.get(o.key);s&&t.set(o,s)})}),(n,r)=>{const o=t.get(r);if(!o)throw new YQe(r.key);return it.formatGroupedTemporalValue({value:n,presentation:o})}}function ZQe({card:e,frame:t}){var Z,X,Y,O,q,U;const n=e,r=fl(),[o,s]=v.useState({}),{authToken:i,presentationExecutionSnapshot:a}=It(),c=p.getTokenParams(i==null?void 0:i.accessToken),{compiledAppearance:u}=p.useAppearance(),d=v.useMemo(()=>Aw(u),[u]),[f,h]=v.useState(()=>new Set),{getCard:m,manifest:g}=Nf(((Z=n.customCardPreferences)==null?void 0:Z.url)||""),b=(X=n.customCardPreferences)==null?void 0:X.componentName,x=(Y=g==null?void 0:g.visuals)==null?void 0:Y.find(V=>V.name===b),y=it.resolveMultiInputType(n,x)??"single",w=v.useMemo(()=>y==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:e,[e,y]),{data:C,effectiveCardConfig:N}=pu(w),S=p.useInteractionStore(V=>V.interactionStates),j=p.useDashboardStore(V=>{var K;return(K=V.dashboard)==null?void 0:K.id}),_=p.useDashboardStore(V=>V.dashboard.filters),k=p.useDashboardStore(V=>V.filterValues),T=p.useDashboardStore(V=>V.selectedSheetId),I=v.useMemo(()=>lb(a),[a]),E=v.useMemo(()=>$v(),[]),D=p.useDashboardStore(V=>V.inlineFilterValuesMap[e.id]),R=v.useMemo(()=>F$({card:e,sheetId:T||"",inlineFilterValues:D}),[e,T,D]),{cardFilters:A,cardFilterValues:F}=v.useMemo(()=>Qv({card:e,interactionStates:S,currentDashboardId:j,filters:_,filterValues:k,selectedSheetId:T}),[e,S,j,_,k,T]),z=v.useCallback((V,K)=>{const Q=it.normalizeMultiInputPayload(K);s(se=>({...se,[V]:Q}))},[]),L=b?m(b):null,$=v.useMemo(()=>it.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:y==="multiple"}),[t,n,y]),H=v.useMemo(()=>it.buildSlotOrderedCards($),[$]),M=v.useMemo(()=>H.map((V,K)=>it.getEffectiveCardTypeForSlot(V,K,x==null?void 0:x.slots)),[H,x==null?void 0:x.slots]),B=v.useMemo(()=>$$(y==="multiple"?L$({slotOrderedCards:H,multiInputData:o,executionSnapshot:I,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}):[{card:e,cardConfig:N,columns:C==null?void 0:C.columns,columnKeyMap:C==null?void 0:C.columnKeyMap,executionSnapshot:I,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}]),[e,j,C==null?void 0:C.columnKeyMap,C==null?void 0:C.columns,N,o,E,I,H,y,r]),W=v.useCallback((V,K)=>{h(Q=>{const se=new Set(Q);return K?se.add(V):se.delete(V),se})},[]),P=Rj((O=n.customCardPreferences)==null?void 0:O.settings,n);if(!b)return null;const G=((U=(q=e.preferences)==null?void 0:q.displayOptions)==null?void 0:U.allowScroll)??!0;return l.jsx("div",{className:p.cn("semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2",G?"overflow-y-auto":"h-full overflow-hidden"),children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[L&&y==="single"&&l.jsx(L,{params:c,theme:d,chartSettings:P,settings:P,cardMetadata:oue({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:z,data:(C==null?void 0:C.records)||[],columns:(C==null?void 0:C.columns)||[],formatTemporalBucketValue:B,filters:A,filterValues:[...F||[],...D||[]],inlineFilters:R}),L&&y==="multiple"&&l.jsxs(l.Fragment,{children:[$.map((V,K)=>{if(!V)return null;const Q=it.getSlotIndexForCard(V,K),se=it.getEffectiveCardTypeForSlot(V,Q,x==null?void 0:x.slots);return l.jsx(a$,{onLoadingStatus:W,onDataChange:z,card:V,effectiveCardType:se},`${V.id}-${Q}`)}),l.jsxs("div",{className:p.cn("relative flex h-full min-h-0 flex-1 flex-col gap-2"),children:[f.size>0&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center",children:l.jsx(xu,{size:"md",color:"muted","aria-label":"Loading data"})}),l.jsx(L,{onDataChange:z,...O$({configCard:n,slotOrderedCards:H,slotTypes:M,multiInputData:o,params:c,theme:d,chartSettings:P,filters:A,filterValues:[...F||[],...D||[]],inlineFilters:R,formatTemporalBucketValue:B})})]})]})]},e.id)})}const Aj=ZQe;function Pj({children:e,containerClassName:t,className:n,text:r,onSave:o,type:s="input",placeholder:i,enabled:a}){const[c,u]=v.useState(!1),[d,f]=v.useState(r),h=p.useDashboardStore(y=>y.isDashboardEditing);v.useEffect(()=>{f(y=>y!==r?r:y)},[r]);const m=y=>{y.stopPropagation(),h&&u(!0)};function g(y){if(y.stopPropagation(),y.key==="Escape"){u(!1);return}y.key==="Enter"&&y.shiftKey||(y.key==="Enter"||y.key==="Tab")&&(u(!1),o(d))}function b(){return s==="textarea"?l.jsx("textarea",{className:p.cn("resize rounded-sm bg-background px-2 py-1 text-sm outline-[0.5px] outline-muted",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g}):l.jsx("input",{onMouseDown:y=>y.stopPropagation(),type:"text",className:p.cn("rounded-sm bg-background outline-none",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g})}function x(){return a?l.jsx("div",{className:"flex grow items-center",children:l.jsx("div",{children:c?b():e})}):e}return l.jsx("div",{className:p.cn("flex",a&&!c&&"cursor-text",t),role:"editable",onDoubleClick:m,onMouseDown:y=>y.stopPropagation(),children:l.jsx("div",{className:"flex grow items-center",children:x()})})}function $I(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function xi(e){const t=e.isEditable!==!1&&e.isPending!==!0?"editable":"read-only";return l.jsx(XQe,{...e},t)}function XQe({value:e,displayTitle:t=!0,onSave:n,placeholder:r,inputClassName:o,displayClassName:s,isEditable:i=!0,isPending:a=!1,onEditingChange:c}){const[u,d]=v.useState(!1),[f,h]=v.useState(e||""),m=x=>{d(x),c==null||c(x)},g=()=>{m(!1),f!==e&&n(f)},b=x=>{x.key==="Enter"?(m(!1),n(f)):x.key==="Escape"&&(m(!1),h(e||""))};return u?l.jsx("div",{className:"flex",children:l.jsx("input",{type:"text",value:f,onChange:x=>h(x.target.value),onBlur:g,onKeyDown:b,onMouseDown:x=>x.stopPropagation(),className:p.cn("m-0 w-full border-0 bg-transparent p-0 outline-none focus:ring-1 focus:ring-ring/40 focus:ring-offset-2 focus:ring-offset-background",o),autoFocus:!0})}):l.jsxs("div",{className:p.cn("relative truncate transition-colors",s,{"cursor-default":!i,"cursor-text":i}),onClick:()=>{!i||a||(m(!0),h(e||""))},title:t?e||r:void 0,children:[l.jsx("div",{className:"flex items-center justify-between gap-2",children:l.jsx("span",{className:p.cn("truncate",{"text-muted-foreground":a}),children:e||l.jsx("span",{className:"text-muted-foreground",children:r})})}),a&&l.jsx("div",{className:"absolute inset-0 animate-pulse rounded bg-gradient-to-r from-transparent via-blue-100/30 to-transparent"})]})}function wM(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function sue({card:e,preferences:t,boundCurrency:n}){var w,C,N,S,j,_;const r=t===void 0?Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,o=(w=e==null?void 0:e.preferences)==null?void 0:w.formatNumber,s=(N=(C=e==null?void 0:e.preferences)==null?void 0:C.kpiVisualOptions)==null?void 0:N.formatOptions,i=(e==null?void 0:e.type)==="kpi"?m0(e):void 0,a=e&&e.type!=="kpi"?p.fromSemanticFormat((_=(j=(S=e.config)==null?void 0:S.metricColumns)==null?void 0:j[0])==null?void 0:_.format,{preserveOmittedProperties:!0}):void 0,c=(e==null?void 0:e.type)==="kpi"?i==null?void 0:i.authoredFormat:p.fromPersistedKpiFormatOptions(s)||a||p.fromLegacyFormatNumber(o),u=c&&r&&Kt.isNumericCanonicalFormat(c)?$t.resolveNumericPresentation(c,r,n):c,d=(u==null?void 0:u.type)==="currency"?u.currency:void 0,f=wM(o==null?void 0:o.currency),h=d||f,m=u&&"locale"in u&&wM(u.locale),g=wM(o==null?void 0:o.locale),b=m||g||(r==null?void 0:r.locale)||Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,x=o==null?void 0:o.enabled;return{currency:h,locale:b,canonicalPrimaryFormat:u,isFormattingDisabled:x===!1||x==="false"}}function iue(e){var c,u,d;const{preferences:t,resolveBoundCurrency:n}=Ta(e),r=(d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.id,o=sue({card:e,preferences:t,boundCurrency:r?n({kind:"metric",metricId:r}):void 0});function s(){return o.currency}function i(){return o.locale}function a(){return o.canonicalPrimaryFormat}return{getCurrency:s,getLocale:i,getPrimaryFormat:a}}const QQe={"currentPeriod.start":"Current Start","currentPeriod.end":"Current End","comparisonPeriod.start":"Previous Start","comparisonPeriod.end":"Previous End"},JQe=e=>e.filter(t=>t.segment==="meta"||t.Segment==="meta"),eJe=e=>{switch(e){case"target":return"Target";case"previous_year":return"Last Year";case"previous_period":default:return"Previous"}};function CM({label:e,value:t,formatCurrency:n,emphasize:r=!1,signed:o=!1}){const s=n(o?Math.abs(t):t),i=o?t>0?`+${s}`:t<0?`−${s}`:s:s;return l.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:e}),l.jsx("span",{className:r?"font-medium tabular-nums text-foreground":"tabular-nums text-foreground",children:i})]})}function tJe({metaKey:e,value:t}){const n=QQe[e]??e;return l.jsxs("div",{className:"flex items-center justify-between gap-4 text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:n}),l.jsx("span",{className:"tabular-nums text-foreground",children:t})]})}function nJe({currentValue:e,comparisonValue:t,formatCurrency:n,comparisonLabel:r="Previous"}){return l.jsxs("div",{className:"space-y-1",children:[l.jsx(CM,{label:"Current",value:e,formatCurrency:n,emphasize:!0}),l.jsx(CM,{label:r,value:t,formatCurrency:n}),l.jsx(CM,{label:"Change",value:e-t,formatCurrency:n,signed:!0})]})}function rJe({data:e,comparisonMetadata:t}){const n=t==null?void 0:t.output.currentWindow,r=t==null?void 0:t.output.comparisonWindow,o=t==null?void 0:t.output.windowGrain,s=n?LA({start:n.startInclusive,end:n.endExclusive},n.timezone,o):void 0,i=r?LA({start:r.startInclusive,end:r.endExclusive},r.timezone,o):void 0,a=s&&i?[{key:"currentPeriod.start",value:s.start},{key:"currentPeriod.end",value:s.end},{key:"comparisonPeriod.start",value:i.start},{key:"comparisonPeriod.end",value:i.end}]:JQe(e);return a.length===0?null:l.jsxs("div",{className:"space-y-1 border-t border-border/60 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Period Details"}),l.jsx("div",{className:"space-y-1",children:a.map((c,u)=>l.jsx(tJe,{metaKey:c.key??c.Key,value:c.value??c.Value},u))})]})}function oJe({currentValue:e,comparisonValue:t,sentiment:n,data:r,comparisonMetadata:o,comparisonKind:s,formatCurrency:i,conditionalLabel:a}){const c=eJe((o==null?void 0:o.type)??s);return l.jsxs(p.TooltipContent,{side:"right",sideOffset:8,className:"w-[260px] rounded-[6px] border border-border bg-popover p-0 text-popover-foreground shadow-md",children:[a&&l.jsx("div",{className:`border-b border-border/60 px-3 py-2 text-[12px] font-medium ${n==="favorable"?"text-emerald-600 dark:text-emerald-400":n==="unfavorable"?"text-rose-600 dark:text-rose-400":"text-muted-foreground"}`,children:a}),l.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Key Metrics"}),l.jsx(nJe,{currentValue:e,comparisonValue:t,formatCurrency:i,comparisonLabel:c})]}),l.jsx(rJe,{data:r,comparisonMetadata:o})]})}const sJe=[{id:"us",name:"United States",flag:"🇺🇸",code:"US",region:"North America"},{id:"ca",name:"Canada",flag:"🇨🇦",code:"CA",region:"North America"},{id:"mx",name:"Mexico",flag:"🇲🇽",code:"MX",region:"North America"},{id:"gb",name:"United Kingdom",flag:"🇬🇧",code:"GB",region:"Europe"},{id:"de",name:"Germany",flag:"🇩🇪",code:"DE",region:"Europe"},{id:"fr",name:"France",flag:"🇫🇷",code:"FR",region:"Europe"},{id:"it",name:"Italy",flag:"🇮🇹",code:"IT",region:"Europe"},{id:"es",name:"Spain",flag:"🇪🇸",code:"ES",region:"Europe"},{id:"nl",name:"Netherlands",flag:"🇳🇱",code:"NL",region:"Europe"},{id:"be",name:"Belgium",flag:"🇧🇪",code:"BE",region:"Europe"},{id:"ch",name:"Switzerland",flag:"🇨🇭",code:"CH",region:"Europe"},{id:"at",name:"Austria",flag:"🇦🇹",code:"AT",region:"Europe"},{id:"se",name:"Sweden",flag:"🇸🇪",code:"SE",region:"Europe"},{id:"no",name:"Norway",flag:"🇳🇴",code:"NO",region:"Europe"},{id:"dk",name:"Denmark",flag:"🇩🇰",code:"DK",region:"Europe"},{id:"fi",name:"Finland",flag:"🇫🇮",code:"FI",region:"Europe"},{id:"pl",name:"Poland",flag:"🇵🇱",code:"PL",region:"Europe"},{id:"cz",name:"Czech Republic",flag:"🇨🇿",code:"CZ",region:"Europe"},{id:"hu",name:"Hungary",flag:"🇭🇺",code:"HU",region:"Europe"},{id:"pt",name:"Portugal",flag:"🇵🇹",code:"PT",region:"Europe"},{id:"ie",name:"Ireland",flag:"🇮🇪",code:"IE",region:"Europe"},{id:"gr",name:"Greece",flag:"🇬🇷",code:"GR",region:"Europe"},{id:"jp",name:"Japan",flag:"🇯🇵",code:"JP",region:"Asia"},{id:"cn",name:"China",flag:"🇨🇳",code:"CN",region:"Asia"},{id:"in",name:"India",flag:"🇮🇳",code:"IN",region:"Asia"},{id:"kr",name:"South Korea",flag:"🇰🇷",code:"KR",region:"Asia"},{id:"sg",name:"Singapore",flag:"🇸🇬",code:"SG",region:"Asia"},{id:"hk",name:"Hong Kong",flag:"🇭🇰",code:"HK",region:"Asia"},{id:"tw",name:"Taiwan",flag:"🇹🇼",code:"TW",region:"Asia"},{id:"th",name:"Thailand",flag:"🇹🇭",code:"TH",region:"Asia"},{id:"my",name:"Malaysia",flag:"🇲🇾",code:"MY",region:"Asia"},{id:"id",name:"Indonesia",flag:"🇮🇩",code:"ID",region:"Asia"},{id:"ph",name:"Philippines",flag:"🇵🇭",code:"PH",region:"Asia"},{id:"vn",name:"Vietnam",flag:"🇻🇳",code:"VN",region:"Asia"},{id:"ae",name:"United Arab Emirates",flag:"🇦🇪",code:"AE",region:"Asia"},{id:"sa",name:"Saudi Arabia",flag:"🇸🇦",code:"SA",region:"Asia"},{id:"il",name:"Israel",flag:"🇮🇱",code:"IL",region:"Asia"},{id:"tr",name:"Turkey",flag:"🇹🇷",code:"TR",region:"Asia"},{id:"au",name:"Australia",flag:"🇦🇺",code:"AU",region:"Oceania"},{id:"nz",name:"New Zealand",flag:"🇳🇿",code:"NZ",region:"Oceania"},{id:"br",name:"Brazil",flag:"🇧🇷",code:"BR",region:"South America"},{id:"ar",name:"Argentina",flag:"🇦🇷",code:"AR",region:"South America"},{id:"cl",name:"Chile",flag:"🇨🇱",code:"CL",region:"South America"},{id:"co",name:"Colombia",flag:"🇨🇴",code:"CO",region:"South America"},{id:"pe",name:"Peru",flag:"🇵🇪",code:"PE",region:"South America"},{id:"uy",name:"Uruguay",flag:"🇺🇾",code:"UY",region:"South America"},{id:"ec",name:"Ecuador",flag:"🇪🇨",code:"EC",region:"South America"},{id:"ve",name:"Venezuela",flag:"🇻🇪",code:"VE",region:"South America"},{id:"za",name:"South Africa",flag:"🇿🇦",code:"ZA",region:"Africa"},{id:"ng",name:"Nigeria",flag:"🇳🇬",code:"NG",region:"Africa"},{id:"eg",name:"Egypt",flag:"🇪🇬",code:"EG",region:"Africa"},{id:"ma",name:"Morocco",flag:"🇲🇦",code:"MA",region:"Africa"},{id:"ke",name:"Kenya",flag:"🇰🇪",code:"KE",region:"Africa"},{id:"gh",name:"Ghana",flag:"🇬🇭",code:"GH",region:"Africa"},{id:"et",name:"Ethiopia",flag:"🇪🇹",code:"ET",region:"Africa"},{id:"tz",name:"Tanzania",flag:"🇹🇿",code:"TZ",region:"Africa"},{id:"ru",name:"Russia",flag:"🇷🇺",code:"RU",region:"Europe/Asia"},{id:"ua",name:"Ukraine",flag:"🇺🇦",code:"UA",region:"Europe"},{id:"by",name:"Belarus",flag:"🇧🇾",code:"BY",region:"Europe"},{id:"lt",name:"Lithuania",flag:"🇱🇹",code:"LT",region:"Europe"},{id:"lv",name:"Latvia",flag:"🇱🇻",code:"LV",region:"Europe"},{id:"ee",name:"Estonia",flag:"🇪🇪",code:"EE",region:"Europe"},{id:"ro",name:"Romania",flag:"🇷🇴",code:"RO",region:"Europe"},{id:"bg",name:"Bulgaria",flag:"🇧🇬",code:"BG",region:"Europe"},{id:"hr",name:"Croatia",flag:"🇭🇷",code:"HR",region:"Europe"},{id:"si",name:"Slovenia",flag:"🇸🇮",code:"SI",region:"Europe"},{id:"sk",name:"Slovakia",flag:"🇸🇰",code:"SK",region:"Europe"},{id:"rs",name:"Serbia",flag:"🇷🇸",code:"RS",region:"Europe"},{id:"ba",name:"Bosnia and Herzegovina",flag:"🇧🇦",code:"BA",region:"Europe"},{id:"me",name:"Montenegro",flag:"🇲🇪",code:"ME",region:"Europe"},{id:"mk",name:"North Macedonia",flag:"🇲🇰",code:"MK",region:"Europe"},{id:"al",name:"Albania",flag:"🇦🇱",code:"AL",region:"Europe"},{id:"xk",name:"Kosovo",flag:"🇽🇰",code:"XK",region:"Europe"},{id:"md",name:"Moldova",flag:"🇲🇩",code:"MD",region:"Europe"},{id:"is",name:"Iceland",flag:"🇮🇸",code:"IS",region:"Europe"},{id:"lu",name:"Luxembourg",flag:"🇱🇺",code:"LU",region:"Europe"},{id:"mt",name:"Malta",flag:"🇲🇹",code:"MT",region:"Europe"},{id:"cy",name:"Cyprus",flag:"🇨🇾",code:"CY",region:"Europe"},{id:"mc",name:"Monaco",flag:"🇲🇨",code:"MC",region:"Europe"},{id:"ad",name:"Andorra",flag:"🇦🇩",code:"AD",region:"Europe"},{id:"sm",name:"San Marino",flag:"🇸🇲",code:"SM",region:"Europe"},{id:"va",name:"Vatican City",flag:"🇻🇦",code:"VA",region:"Europe"},{id:"li",name:"Liechtenstein",flag:"🇱🇮",code:"LI",region:"Europe"},{id:"pk",name:"Pakistan",flag:"🇵🇰",code:"PK",region:"Asia"},{id:"bd",name:"Bangladesh",flag:"🇧🇩",code:"BD",region:"Asia"},{id:"lk",name:"Sri Lanka",flag:"🇱🇰",code:"LK",region:"Asia"},{id:"np",name:"Nepal",flag:"🇳🇵",code:"NP",region:"Asia"},{id:"bt",name:"Bhutan",flag:"🇧🇹",code:"BT",region:"Asia"},{id:"mv",name:"Maldives",flag:"🇲🇻",code:"MV",region:"Asia"},{id:"af",name:"Afghanistan",flag:"🇦🇫",code:"AF",region:"Asia"},{id:"ir",name:"Iran",flag:"🇮🇷",code:"IR",region:"Asia"},{id:"iq",name:"Iraq",flag:"🇮🇶",code:"IQ",region:"Asia"},{id:"sy",name:"Syria",flag:"🇸🇾",code:"SY",region:"Asia"},{id:"lb",name:"Lebanon",flag:"🇱🇧",code:"LB",region:"Asia"},{id:"jo",name:"Jordan",flag:"🇯🇴",code:"JO",region:"Asia"},{id:"kw",name:"Kuwait",flag:"🇰🇼",code:"KW",region:"Asia"},{id:"qa",name:"Qatar",flag:"🇶🇦",code:"QA",region:"Asia"},{id:"bh",name:"Bahrain",flag:"🇧🇭",code:"BH",region:"Asia"},{id:"om",name:"Oman",flag:"🇴🇲",code:"OM",region:"Asia"},{id:"ye",name:"Yemen",flag:"🇾🇪",code:"YE",region:"Asia"},{id:"ge",name:"Georgia",flag:"🇬🇪",code:"GE",region:"Asia"},{id:"am",name:"Armenia",flag:"🇦🇲",code:"AM",region:"Asia"},{id:"az",name:"Azerbaijan",flag:"🇦🇿",code:"AZ",region:"Asia"},{id:"kz",name:"Kazakhstan",flag:"🇰🇿",code:"KZ",region:"Asia"},{id:"kg",name:"Kyrgyzstan",flag:"🇰🇬",code:"KG",region:"Asia"},{id:"tj",name:"Tajikistan",flag:"🇹🇯",code:"TJ",region:"Asia"},{id:"tm",name:"Turkmenistan",flag:"🇹🇲",code:"TM",region:"Asia"},{id:"uz",name:"Uzbekistan",flag:"🇺🇿",code:"UZ",region:"Asia"},{id:"mn",name:"Mongolia",flag:"🇲🇳",code:"MN",region:"Asia"},{id:"kp",name:"North Korea",flag:"🇰🇵",code:"KP",region:"Asia"},{id:"mm",name:"Myanmar",flag:"🇲🇲",code:"MM",region:"Asia"},{id:"la",name:"Laos",flag:"🇱🇦",code:"LA",region:"Asia"},{id:"kh",name:"Cambodia",flag:"🇰🇭",code:"KH",region:"Asia"},{id:"bn",name:"Brunei",flag:"🇧🇳",code:"BN",region:"Asia"},{id:"tl",name:"East Timor",flag:"🇹🇱",code:"TL",region:"Asia"},{id:"dz",name:"Algeria",flag:"🇩🇿",code:"DZ",region:"Africa"},{id:"tn",name:"Tunisia",flag:"🇹🇳",code:"TN",region:"Africa"},{id:"ly",name:"Libya",flag:"🇱🇾",code:"LY",region:"Africa"},{id:"sd",name:"Sudan",flag:"🇸🇩",code:"SD",region:"Africa"},{id:"ss",name:"South Sudan",flag:"🇸🇸",code:"SS",region:"Africa"},{id:"td",name:"Chad",flag:"🇹🇩",code:"TD",region:"Africa"},{id:"ne",name:"Niger",flag:"🇳🇪",code:"NE",region:"Africa"},{id:"ml",name:"Mali",flag:"🇲🇱",code:"ML",region:"Africa"},{id:"bf",name:"Burkina Faso",flag:"🇧🇫",code:"BF",region:"Africa"},{id:"sn",name:"Senegal",flag:"🇸🇳",code:"SN",region:"Africa"},{id:"gm",name:"Gambia",flag:"🇬🇲",code:"GM",region:"Africa"},{id:"gw",name:"Guinea-Bissau",flag:"🇬🇼",code:"GW",region:"Africa"},{id:"gn",name:"Guinea",flag:"🇬🇳",code:"GN",region:"Africa"},{id:"sl",name:"Sierra Leone",flag:"🇸🇱",code:"SL",region:"Africa"},{id:"lr",name:"Liberia",flag:"🇱🇷",code:"LR",region:"Africa"},{id:"ci",name:"Ivory Coast",flag:"🇨🇮",code:"CI",region:"Africa"},{id:"tg",name:"Togo",flag:"🇹🇬",code:"TG",region:"Africa"},{id:"bj",name:"Benin",flag:"🇧🇯",code:"BJ",region:"Africa"},{id:"zw",name:"Zimbabwe",flag:"🇿🇼",code:"ZW",region:"Africa"},{id:"zm",name:"Zambia",flag:"🇿🇲",code:"ZM",region:"Africa"}];function aue(e){const t=p.useDashboardStore(c=>c.isDashboardEditing),n=p.useDashboardStore(c=>c.isVisualEditing),{setCardTitle:r,setCountryLogo:o}=p.useEditorActions();return{setTitle:c=>{n&&r(c)},setCountryLogo:c=>{n&&o(c)},isEditable:n,isDashboardEditing:t,isVisualEditing:n}}function iJe(e,t){var r,o;if(!e)return e;const n=(o=(r=e.config)==null?void 0:r.metricColumns)==null?void 0:o[t];return{...e,config:{...e.config,metricColumns:n?[n]:[]},preferences:e.preferences}}function aJe(e){var b,x,y,w,C,N;if(!e)return e;const t=(x=(b=e.config)==null?void 0:b.metricColumns)==null?void 0:x[0],n=(y=e.preferences)==null?void 0:y.formatNumber,r=(C=(w=e.preferences)==null?void 0:w.kpiVisualOptions)==null?void 0:C.formatOptions,o=p.fromTFormatOptions(r),s=(o==null?void 0:o.type)==="date"?oU(r==null?void 0:r.locale):void 0,i=o&&(Kt.isNumericCanonicalFormat(o)||o.type==="duration")?r:void 0,a=p.fromSemanticFormat(t==null?void 0:t.format),c=a&&(a.type==="date"||a.type==="string")&&"locale"in a?oU(a.locale):void 0,u=s||c,d=a&&(Kt.isNumericCanonicalFormat(a)||a.type==="duration")&&t?[u&&t.format&&typeof t.format=="object"?{...t,format:{...t.format,locale:u}}:t]:[],h=((o==null?void 0:o.type)==="date"||(o==null?void 0:o.type)==="string"||(o==null?void 0:o.type)==="temporal_bucket"||(a==null?void 0:a.type)==="date"||(a==null?void 0:a.type)==="string"||(a==null?void 0:a.type)==="temporal_bucket")&&!i&&d.length===0,m=!i&&u?{locale:u}:void 0,g=h?{...n,locale:u||(n==null?void 0:n.locale),currency:void 0,prefix:void 0,suffix:void 0,percentValueMode:void 0}:n;return{...e,config:{...e.config,metricColumns:d},preferences:{...e.preferences,formatNumber:g,kpiVisualOptions:{...(N=e.preferences)==null?void 0:N.kpiVisualOptions,formatOptions:i||m}}}}function lJe(e){return e!=="date"}function oU(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function rp({card:e,preferences:t,boundCurrency:n}){const r=t===void 0?Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,{canonicalPrimaryFormat:o,isFormattingDisabled:s}=sue({card:e,preferences:t,boundCurrency:n}),i=o&&Kt.isNumericCanonicalFormat(o)?o:void 0,a=o&&(o.type==="date"||o.type==="duration")?p.toTFormatOptions(o):void 0,c={type:"number",locale:(r==null?void 0:r.locale)||Li.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,minimumFractionDigits:0,maximumFractionDigits:0,useGrouping:!0},u=o==null?void 0:o.type,d=(g,{forceCompact:b=!1,forceSign:x=!1}={})=>{if(g==null)return"n/a";if(s){const w=String(g);return x&&g>0?`+${w}`:w}const y=a!=null&&a.type&&a.type!=="auto"?gr(g,a.type,a):$t.formatNumericCanonical(g,{...i||c,compact:b?!0:i==null?void 0:i.compact});return x&&g>0?`+${y}`:y};return{format:g=>d(g),formatCompact:g=>d(g,{forceCompact:!0}),formatSigned:g=>d(g,{forceSign:!0}),supportsComparisonDeltaInheritance:lJe(u)}}function sU({card:e,preferences:t,boundCurrency:n,metricIndex:r}){return rp({card:iJe(e,r),preferences:t,boundCurrency:n})}function lue({card:e,preferences:t,boundCurrency:n}){return rp({card:aJe(e),preferences:t,boundCurrency:n})}function cJe({card:e,data:t,isPending:n,headerAction:r,headerTrailingAction:o}){var X,Y,O,q,U,V,K,Q,se,oe,me,le,ue,ne,de,Ce,ce,ie,we,fe,ae,ee;const s=e.config,{setTitle:i,isEditable:a,isVisualEditing:c}=aue(),{setCardDescription:u}=p.useEditorActions(),{getLocale:d}=iue(e),{preferences:f,boundCurrency:h,resolveBoundCurrency:m}=W_(e,t),g=(O=(Y=(X=e.config)==null?void 0:X.metricColumns)==null?void 0:Y[1])==null?void 0:O.id,b=(V=(U=(q=e.config)==null?void 0:q.metricColumns)==null?void 0:U[2])==null?void 0:V.id,x=g?m({kind:"metric",metricId:g}):void 0,y=b?m({kind:"metric",metricId:b}):void 0,w=v.useMemo(()=>rp({card:e,preferences:f,boundCurrency:h}),[e,h,f]),C=v.useMemo(()=>sU({card:e,preferences:f,boundCurrency:x,metricIndex:1}),[e,x,f]),N=v.useMemo(()=>sU({card:e,preferences:f,boundCurrency:y,metricIndex:2}),[e,y,f]),S=(s==null?void 0:s.metricColumns)||[],j=((K=e.preferences)==null?void 0:K.metricPairComparisonEnabled)===!0,_=J=>w.format(J),k=J=>w.formatCompact(J),T=J=>C.format(J),I=J=>N.format(J),E=!!p.fromSemanticFormat((Q=S[1])==null?void 0:Q.format),D=J=>E||x?T(J):_(J),R=J=>{const re=t==null?void 0:t.find(pe=>{var Ee,Te;return pe.segment===J||pe.Segment===J||((Ee=pe.segment)==null?void 0:Ee.toLowerCase())===J.toLowerCase()||((Te=pe.Segment)==null?void 0:Te.toLowerCase())===J.toLowerCase()});return(re==null?void 0:re.value)??(re==null?void 0:re.Value)??0},A=R("current"),F=R("comparison"),z=R("tertiary"),L=p.getMetricComparisonPolarity(S[0]),$=(oe=(se=e.preferences)==null?void 0:se.formatNumber)==null?void 0:oe.colorRanges,H=$I(A,$);function M(){return e.title?e.title:a?"Enter title":""}if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const B=j&&S.length===2,W=S.length>=2&&F!==void 0,P=S.length>2&&z!==void 0,Z=((me=e==null?void 0:e.kpiPreferences)==null?void 0:me.format)==="compact"?k(A):_(A);return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:M(),isEditable:a,onSave:i}),(e.description||c)&&l.jsx(xi,{isEditable:c,value:e.description||(c?"Enter description":""),placeholder:c?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:u})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r,B&&l.jsx("div",{className:"shrink-0",children:l.jsx(u3,{primaryValue:A,secondaryValue:F,presentation:(le=e.preferences)==null?void 0:le.comparisonPresentation,metricFormatOptions:(ne=(ue=e.preferences)==null?void 0:ue.kpiVisualOptions)==null?void 0:ne.formatOptions,locale:d()||"en-US",decimalPlaces:(Ce=(de=e.preferences)==null?void 0:de.formatNumber)==null?void 0:Ce.decimalPlaces,suffix:(ie=(ce=e.preferences)==null?void 0:ce.formatNumber)==null?void 0:ie.suffix,polarity:L,signedValueFormatter:w.formatSigned,allowSignedValueFormatter:w.supportsComparisonDeltaInheritance})}),o]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:H?{color:H}:void 0,children:Z}),W&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[((we=S[1])==null?void 0:we.label)||((fe=S[1])==null?void 0:fe.name),l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:D(F)})]})]}),P&&l.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-4 py-2",children:[l.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:((ae=S[2])==null?void 0:ae.label)||((ee=S[2])==null?void 0:ee.name)}),l.jsx("span",{className:"text-[12px] font-medium tabular-nums text-foreground",children:I(z)})]})]})}function uJe(e){var t;return e.comparisonKind==="target"&&e.targetValue>0&&((t=e.presentation)==null?void 0:t.showComparison)!==!1}function dJe(e){const{comparisonKind:t,comparisonValue:n,targetValue:r}=e;return t==="target"?typeof r=="number"&&!Number.isNaN(r)?r:null:n}function fJe(e){return typeof e=="number"?"number":typeof e=="boolean"?"boolean":e instanceof Date?"date":"string"}function hJe(e){const t=Array.isArray(e.payload.filters)?e.payload.filters:[];return t.length>0?t:[{field:e.payload.field,operator:e.payload.operator,value:e.payload.value}]}function mJe(e,t){return t?`summary:${e}:${t}`:`summary:${e}`}function cue({addOrUpdateFilterValues:e,onEvent:t,refresh:n,selectedSheetId:r,cardId:o,onChangeComparison:s}){return async i=>{if(i.type==="apply_filter"){const a=hJe(i),c=[];for(const u of a){const d=String(u.field||"").trim(),f=String(u.operator||"=").trim(),h=u.value,m=Array.isArray(h)?h[0]:h;if(!d||m==null)continue;const g={filterId:mJe(d,r),name:d,operation:f==="eq"?"=":f==="in"?"in":"=",valueType:fJe(m),values:Array.isArray(h)?h:[m]};c.push(g)}c.length>0&&e(c),t==null||t({type:"info",message:{event:"summary_driver_chip_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}if(i.type==="refresh"){await n(),t==null||t({type:"info",message:{event:"summary_retry_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}i.type==="change_comparison"&&s&&await s(i)}}function pJe(e){return e==="kpi"}function uue(e){var t,n;return pJe(e==null?void 0:e.type)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.enabled)===!0}function z$(e){var n;const t=(n=e==null?void 0:e.config)==null?void 0:n.summary;return uue(e)&&((t==null?void 0:t.showOnCard)===!0||((t==null?void 0:t.breakdownDimensions)||[]).length>0)}function iU(e){var t,n;return uue(e)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.includeInDashboardSummary)===!0}function B$(e,t){var H,M;const{authToken:n,tokenProps:r}=It(),o=p.useDashboardStore(B=>B.selectedSheetId),s=p.useDashboardStore(B=>B.dashboard),i=p.useDashboardStore(B=>B.selectedLensId),a=p.useDashboardStore(B=>B.dashboardInputReferenceTime),c=p.useDashboardStore(B=>B.onEvent),u=Wr(),{addOrUpdateFilterValues:d}=p.useDashboardActions(),f=JL(e),{cardFilterValues:h,finalConfig:m,finalFiltersKey:g,queryRelevantConfig:b}=f,x=v.useMemo(()=>p.getDashboardCards(s),[s]),y=v.useMemo(()=>x.length>0?x:[e],[e,x]),w=v.useMemo(()=>Object.fromEntries(y.map(B=>[B.id,B.id===e.id?b:B.config])),[e.id,b,y]),C=u_(y,{authority:"runtime",queryRelevantConfigsByCardId:w}).payload,N=p.useDashboardStore(B=>{var W;return((W=B.reportContext)==null?void 0:W.calendar)??null}),S=N==null?void 0:N.tz,j=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,C),[s,C]),{cardFilterValues:_,globalDateComparison:k}=v.useMemo(()=>Jv({card:e,queryContext:f,semanticExecutionPayload:C,timezone:S,allowMinutePrecision:j.allEligibleTargetsAreDateTime,comparisonReferenceTime:a}),[e,f,C,S,a,j.allEligibleTargetsAreDateTime]),T=(t==null?void 0:t.enabled)??!0,I=v.useMemo(()=>({id:e.id,title:e.title,type:e.type,config:m,dataSource:e.dataSource,preferences:e.preferences}),[e.id,e.title,e.type,m,e.dataSource,e.preferences]),E=v.useMemo(()=>JSON.stringify({type:e.type,config:m,dataSource:e.dataSource}),[e.type,m,e.dataSource]),D=(s==null?void 0:s.id)||(r==null?void 0:r.dashboard_id),R=o||((M=(H=s==null?void 0:s.sheets)==null?void 0:H[0])==null?void 0:M.id)||null,A=!!(n!=null&&n.accessToken&&(r!=null&&r.apiServiceUrl)&&D&&R&&(e!=null&&e.id)&&N&&T&&z$(e)),F=v.useMemo(()=>["card-summary",D,R,e.id,i,g,JSON.stringify(_||[]),E,k,N],[D,R,e.id,i,g,_,E,k,N]),z=Un({queryKey:F,enabled:A,staleTime:1e3,queryFn:async()=>{const B=`${r.apiServiceUrl}/v1/dashboard/${D}/cards/${e.id}/summary`;return p.postRequestRegular(B,(n==null?void 0:n.accessToken)||"",{selectedSheetId:R,activeFilters:_||[],lensId:i,cardOverride:I,globalDateComparison:k,calendarContext:N})}}),L=ks({mutationFn:async()=>{const B=`${r.apiServiceUrl}/v1/dashboard/${D}/cards/${e.id}/summary`;return p.postRequestRegular(B,(n==null?void 0:n.accessToken)||"",{selectedSheetId:R,activeFilters:_||[],lensId:i,cardOverride:I,globalDateComparison:k,calendarContext:N,refresh:!0})},onSuccess:B=>{u.setQueryData(F,B)}}),$=v.useMemo(()=>cue({addOrUpdateFilterValues:d,onEvent:c,refresh:()=>L.mutateAsync(),selectedSheetId:R,cardId:e.id}),[d,c,L,R,e.id]);return{data:z.data,isLoading:z.isLoading,isFetching:z.isFetching,isError:z.isError,error:z.error,refresh:L.mutateAsync,isRefreshing:L.isPending,applyAction:$,enabled:A}}function gJe(e,t){var r;if(!((r=e==null?void 0:e.sheets)!=null&&r.length)||!t)return[];const n=e.sheets.find(o=>o.id===t)||e.sheets[0];return n?[...n.cards||[],...(n.frames||[]).flatMap(o=>o.cards||[])]:[]}function due(){var z,L;const{authToken:e,tokenProps:t}=It(),n=p.useDashboardStore($=>{var H;return((H=$.reportContext)==null?void 0:H.calendar)??null}),r=n==null?void 0:n.tz,o=p.useDashboardStore($=>$.selectedSheetId),s=p.useDashboardStore($=>$.dashboard),i=p.useDashboardStore($=>$.dashboard.filters),a=p.useDashboardStore($=>$.semanticExecutionPayload),c=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,a),[s,a]),u=p.useDashboardStore($=>$.filterValues),d=p.useDashboardStore($=>$.inlineFilterValuesMap),f=p.useDashboardStore($=>$.dashboardInputValues),h=p.useDashboardStore($=>$.dashboardInputReferenceTime),m=p.useDashboardStore($=>$.controlValues),g=p.useDashboardStore($=>$.cardControlValuesMap),b=p.useDashboardStore($=>$.selectedLensId),x=p.useDashboardStore($=>$.onEvent),y=p.useInteractionStore($=>$.interactionStates),w=Wr(),{addOrUpdateFilterValues:C}=p.useDashboardActions(),N=(s==null?void 0:s.id)||(t==null?void 0:t.dashboard_id),S=o||((L=(z=s==null?void 0:s.sheets)==null?void 0:z[0])==null?void 0:L.id)||null,j=v.useMemo(()=>gJe(s,S),[s,S]),_=v.useMemo(()=>j.some($=>iU($)),[j]),k=!!(e!=null&&e.accessToken&&(t!=null&&t.apiServiceUrl)&&N&&S&&n&&_),T=v.useMemo(()=>{const $={};for(const H of j){if(!iU(H))continue;const M=hb({card:H,dashboard:s,interactionStates:y,currentDashboardId:s==null?void 0:s.id,filters:i,filterValues:u,selectedSheetId:S,inlineFilterValuesMap:d,dashboardInputContext:Yi({dashboard:s,sheetId:S,card:H,runtimeValues:{dashboardInputValues:f,filterValues:u,controlValues:m,inlineFilterValuesMap:d,cardControlValuesMap:g}})}),{cardFilterValues:B,globalDateComparison:W}=Jv({card:H,queryContext:M,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime,comparisonReferenceTime:h});$[H.id]={activeFilters:B,cardOverride:{id:H.id,title:H.title,type:H.type,config:M.finalConfig,dataSource:H.dataSource,preferences:H.preferences},globalDateComparison:W}}return $},[j,y,s,i,a,c.allEligibleTargetsAreDateTime,u,S,d,f,h,m,g,r]),I=v.useMemo(()=>JJ({filters:i,filterValues:u||[],dashboard:s,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime}),[i,u,s,a,r,c.allEligibleTargetsAreDateTime]),E=v.useMemo(()=>JSON.stringify(T),[T]),D=v.useMemo(()=>["dashboard-summary",N,S,b,JSON.stringify(I),E,n],[N,S,b,I,E,n]),R=Un({queryKey:D,enabled:k,staleTime:1e3,queryFn:async()=>{const $=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular($,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:I,lensId:b,cardContexts:T,calendarContext:n})}}),A=ks({mutationFn:async()=>{const $=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular($,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:I,lensId:b,refresh:!0,cardContexts:T,calendarContext:n})},onSuccess:$=>{w.setQueryData(D,$)}}),F=v.useMemo(()=>cue({addOrUpdateFilterValues:C,onEvent:x,refresh:()=>A.mutateAsync(),selectedSheetId:S,onChangeComparison:$=>{x==null||x({type:"info",message:{event:"summary_action_clicked",actionType:"change_comparison",payload:$.payload}})}}),[C,x,A,S]);return{data:R.data,isLoading:R.isLoading,isFetching:R.isFetching,isError:R.isError,error:R.error,refetch:R.refetch,refresh:A.mutateAsync,isRefreshing:A.isPending,applyAction:F,enabled:k}}var zI="Collapsible",[bJe,fue]=p.createContextScope(zI),[xJe,V$]=bJe(zI),hue=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=p.useControllableState({prop:r,defaultProp:o??!1,onChange:i,caller:zI});return l.jsx(xJe,{scope:n,disabled:s,contentId:p.useId(),open:c,onOpenToggle:te.useCallback(()=>u(d=>!d),[u]),children:l.jsx(p.Primitive.div,{"data-state":W$(c),"data-disabled":s?"":void 0,...a,ref:t})})});hue.displayName=zI;var mue="CollapsibleTrigger",H$=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=V$(mue,n);return l.jsx(p.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":W$(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:p.composeEventHandlers(e.onClick,o.onOpenToggle)})});H$.displayName=mue;var q$="CollapsibleContent",U$=te.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=V$(q$,e.__scopeCollapsible);return l.jsx(p.Presence,{present:n||o.open,children:({present:s})=>l.jsx(yJe,{...r,ref:t,present:s})})});U$.displayName=q$;var yJe=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=V$(q$,n),[a,c]=te.useState(r),u=te.useRef(null),d=p.useComposedRefs(t,u),f=te.useRef(0),h=f.current,m=te.useRef(0),g=m.current,b=i.open||a,x=te.useRef(b),y=te.useRef(void 0);return te.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),p.useLayoutEffect2(()=>{const w=u.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,m.current=C.width,x.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),c(r)}},[i.open,r]),l.jsx(p.Primitive.div,{"data-state":W$(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:b&&o})});function W$(e){return e?"open":"closed"}var pue=hue,vJe=H$,wJe=U$;const vu=pue,wu=H$,Cu=U$;function CJe(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function K$({card:e,preferences:t,boundCurrency:n}){const r=rp({card:e,preferences:t,boundCurrency:n}),o=lue({card:e,preferences:t,boundCurrency:n});return{formatValue:a=>r.format(a),formatSigned:a=>o.formatSigned(a),formatPct:CJe}}const SJe=new Set(["PARTIAL_TIMEOUT","DRIVER_DATA_INSUFFICIENT","UNSUPPORTED_CARD_EXCLUDED","CARD_QUERY_FAILED"]);function $w(e){return e.filter(t=>SJe.has(t))}function G$({partial:e,warnings:t}){return e?t.length===0?!0:$w(t).length>0:!1}const Fj="Summary may be incomplete. Refresh to try again.",NJe={PARTIAL_TIMEOUT:"Summary is partial because generation exceeded the response time budget.",LLM_TIMEOUT_FALLBACK:"Using deterministic summary because narrative generation timed out.",DRIVER_DATA_INSUFFICIENT:"There is not enough breakdown data to compute reliable drivers.",UNSUPPORTED_CARD_EXCLUDED:"Some unsupported chart types were excluded from summary computation.",CARD_QUERY_FAILED:"One or more card summary queries failed; showing available summary results."};function jJe(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function tv(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function KP(e){return NJe[e]||e}function kJe(e){return e.kind==="value_contributor"}function Y$({className:e,message:t=Fj,showLabel:n=!1}){return l.jsxs("span",{title:t,"aria-label":t,className:p.cn("inline-flex items-center gap-1 text-amber-600",n&&"rounded border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700",e),children:[l.jsx(Zs,{className:"h-3.5 w-3.5"}),n&&l.jsx("span",{children:"Summary issue"})]})}function _Je(e){const t=$w(e.metadata.warnings);return t.length===1?KP(t[0]):t.length>1?`Summary has ${t.length} warnings: ${t.map(KP).join(" ")}`:(G$(e.metadata),Fj)}function gue(e,t){if(e==null)return null;const n=t.formatPct(e);return e>0?`+${n}`:n}function Z$(e){return e==="up"?"text-emerald-600 dark:text-emerald-400":e==="down"?"text-rose-600 dark:text-rose-400":"text-foreground"}function bue(e,t){if(e.length===0)return t;const n=e[0].dimension;return e.every(o=>o.dimension===n)&&n?`${t} by ${n}`:t}function xue(e,t){return kJe(e)?`${t.formatValue(e.current)} · ${t.formatPct(e.contributionPct)}`:t.formatSigned(e.delta)}function IJe({data:e,formatter:t}){const n=e.keyChanges[0];if(!n)return e.narrative?l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:e.narrative})]}):null;const r=n.direction==="up";n.direction;const o=Z$(n.direction);if(n.comparison==null)return l.jsx("div",{className:"px-4 py-3",children:l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," is"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","in the current view."]})});if(n.direction==="flat")return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," was unchanged at"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","versus comparison."]})]});const s=r?"rose to":"fell to",i=r?"up":"down",a=n.delta!=null?t.formatSigned(n.delta):null,c=gue(n.deltaPct,t);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," ",s," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)}),a&&l.jsxs(l.Fragment,{children:[", ",i," ",l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:a}),c&&l.jsxs(l.Fragment,{children:[" (",l.jsx("span",{className:p.cn("tabular-nums",o),children:c}),")"]})]})," ","versus comparison."]})]})}function TJe(e,t){if(e.comparison==null)return t.formatValue(e.current);if(e.direction==="flat")return`${t.formatValue(e.current)} · unchanged`;const n=t.formatSigned(e.delta),r=gue(e.deltaPct,t);return r?`${t.formatValue(e.current)} · ${n} (${r})`:`${t.formatValue(e.current)} · ${n}`}function EJe({changes:e,formatter:t}){return e.length<=1?null:l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Metrics"}),l.jsx("ul",{className:"space-y-1",children:e.map(n=>l.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-[12px]",children:[l.jsx("span",{className:"min-w-0 truncate text-foreground",children:n.label}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",Z$(n.direction)),children:TJe(n,t)})]},n.metricId))})]})}function DJe(e,t){if(e==="up")return"Where it grew";if(e==="down")return"Where it declined";const n=t.every(o=>(o.delta??0)>0),r=t.every(o=>(o.delta??0)<0);return n?"Where it grew":r?"Where it declined":"Where it changed"}function MJe({drivers:e,formatter:t,applyAction:n,headlineDirection:r}){const o=e.filter(a=>a.kind==="period_delta_driver"&&a.delta!=null&&Number.isFinite(a.delta)).slice(0,3);if(o.length===0)return null;const s=DJe(r,o),i=bue(o,s);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:i}),l.jsx("ul",{className:"space-y-1",children:o.map(a=>{const c=Z$(a.direction),u=`${tv(a.key)} (${xue(a,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(a.action),"aria-label":u,className:"group/row flex w-full items-baseline justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsx("span",{className:"min-w-0 truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:tv(a.key)}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",c),"aria-hidden":"true",children:t.formatSigned(a.delta)})]})},`${a.metricId}-${a.key}`)})})]})}function RJe({drivers:e,formatter:t,applyAction:n}){const r=e.filter(s=>s.kind==="value_contributor").slice(0,3);if(r.length===0)return null;const o=bue(r,"Top Contributors");return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:o}),l.jsx("ul",{className:"space-y-1",children:r.map((s,i)=>{const a=`${tv(s.key)} (${xue(s,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(s.action),"aria-label":a,className:"group/row flex w-full items-center justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:p.cn("flex size-4 shrink-0 items-center justify-center rounded-[3px] text-[9px] font-semibold tabular-nums",i===0?"bg-foreground text-background":"bg-muted text-muted-foreground"),"aria-hidden":"true",children:i+1}),l.jsx("span",{className:"truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:tv(s.key)})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums","aria-hidden":"true",children:[l.jsx("span",{className:"text-muted-foreground",children:t.formatValue(s.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:t.formatPct(s.contributionPct)})]})]})},`${s.metricId}-${s.key}`)})})]})}function AJe(e){if(e.type!=="apply_filter")return e.label;const[t,n]=e.label.split(":");return n?`${t}: ${tv(n)}`:e.label}function Oj({data:e,applyAction:t,numberFormatter:n,audience:r="dashboard"}){var c;const o=n||{formatSigned:u=>u==null?"n/a":`${u>0?"+":""}${Math.round(u*100)/100}`,formatValue:u=>u==null?"n/a":`${Math.round(u*100)/100}`,formatPct:jJe},s=$w(e.metadata.warnings),i=e.suggestedActions.filter(u=>u.type!=="refresh"&&u.type!=="apply_filter"),a=r==="author"&&s.length>0;return l.jsxs("div",{className:"divide-y divide-border/60",children:[l.jsx(IJe,{data:e,formatter:o}),l.jsx(EJe,{changes:e.keyChanges,formatter:o}),l.jsx(MJe,{drivers:e.drivers,formatter:o,applyAction:t,headlineDirection:(c=e.keyChanges[0])==null?void 0:c.direction}),l.jsx(RJe,{drivers:e.drivers,formatter:o,applyAction:t}),i.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 px-4 py-3",children:i.map(u=>l.jsx(p.Button,{size:"sm",variant:"secondary",className:"h-7 px-2 text-xs",onClick:()=>t(u),children:AJe(u)},u.idempotencyKey))}),a&&l.jsx("div",{className:"px-4 py-3",children:l.jsx("div",{className:"rounded-[4px] bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:s.map(u=>l.jsx("div",{children:KP(u)},u))})})]})}const PJe=new Set(["up","rose","grew","gained","increased","climbed","surged","jumped","rising"]),FJe=new Set(["down","fell","declined","dipped","dropped","lost","decreased","slipped","falling"]),aU=/(\(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?)\))|(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?))|(\d[\d,]*(?:\.\d+)?[KkMmBb]?(?:%)?)/g;function OJe(e){const t=/^(\(?)([+−-]?)(\d[\d,]*)(\.\d+)?([KkMmBb]?)(%?)(\)?)$/.exec(e);if(!t)return e;const[,n,r,o,s,i,a,c]=t;if(i||o.includes(",")||o.length<4)return e;const u=Number(o);if(!Number.isFinite(u))return e;const d=u.toLocaleString("en-US");return`${n}${r}${d}${s??""}${i}${a}${c}`}function LJe(e){const t=[];let n=0,r;for(aU.lastIndex=0;(r=aU.exec(e))!==null;){r.index>n&&t.push({kind:"plain",text:e.slice(n,r.index)});const o=r[0],s=r[2]||r[6],i=OJe(o);s==="+"?t.push({kind:"pos",text:i}):s==="-"||s==="−"?t.push({kind:"neg",text:i}):t.push({kind:"num",text:i}),n=r.index+o.length}return n<e.length&&t.push({kind:"plain",text:e.slice(n)}),t}function $Je(e){return e.map((t,n)=>{if(t.kind!=="num"||!t.text.endsWith("%"))return t;const r=e[n-1];if(!r||r.kind!=="plain")return t;const o=r.text.replace(/\s+$/,"").split(/[\s.,;:!?(]+/).pop();if(!o)return t;const s=o.toLowerCase();return PJe.has(s)?{kind:"pos",text:t.text}:FJe.has(s)?{kind:"neg",text:t.text}:t})}function zJe({narrative:e}){const t=v.useMemo(()=>$Je(LJe(e)),[e]);return l.jsx("div",{className:"px-4 py-3",children:l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:t.map((n,r)=>{if(n.kind==="plain")return l.jsx("span",{children:n.text},r);const o=n.kind==="pos"?"text-emerald-600 dark:text-emerald-400":n.kind==="neg"?"text-rose-600 dark:text-rose-400":"";return l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:n.text},r)})})})}function GP(){var w;const e=p.useDashboardStore(C=>C.dashboard),{preferences:t}=Ta(),n=p.useDashboardStore(C=>C.semanticExecutionPayload),r=p.useDashboardStore(C=>C.isDashboardEditing),o=((w=e==null?void 0:e.summary)==null?void 0:w.position)||"top",{setDashboard:s}=p.useDashboardActions(),{data:i,isLoading:a,isRefreshing:c,enabled:u,applyAction:d,refresh:f}=due(),[h,m]=v.useState(!0),g=v.useMemo(()=>K$({preferences:t}),[t]),b=i?G$(i.metadata)||$w(i.metadata.warnings).length>0:!1,x=i?_Je(i):Fj,y=C=>{e&&o!==C&&s({...e,summary:{...e.summary,position:C}},{semanticExecutionPayload:n})};return u?a&&!i?l.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"}),l.jsx("div",{className:"h-4 w-4/5 animate-pulse rounded bg-muted"})]})}):i?l.jsx("div",{className:"mx-3 mb-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs(vu,{open:h,onOpenChange:m,children:[l.jsxs("div",{className:p.cn("flex items-center justify-between gap-2 px-4",h?"border-b border-border/60 py-2.5":"py-1.5"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(wu,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6","aria-label":h?"Collapse summary":"Expand summary",children:l.jsx(je.ChevronDown,{className:p.cn("h-3.5 w-3.5 transition-transform",!h&&"-rotate-90")})})}),l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),b&&l.jsx(Y$,{message:x,showLabel:!0})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[r&&l.jsx("div",{className:"flex h-6 items-center overflow-hidden rounded-[4px] border border-border/60","aria-label":"Summary position",children:["top","bottom"].map(C=>l.jsx(p.Button,{size:"xs",variant:"ghost",className:p.cn("h-6 rounded-none px-2 text-[11px] capitalize text-muted-foreground hover:text-foreground",o===C&&"bg-muted text-foreground hover:bg-muted"),onClick:()=>y(C),"aria-pressed":o===C,children:C},C))}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>f(),disabled:c,"aria-label":"Refresh summary",children:l.jsx(tc,{className:p.cn("h-3 w-3",c&&"animate-spin")})})]})]}),l.jsx(Cu,{children:i.narrative?l.jsx(zJe,{narrative:i.narrative}):l.jsx(Oj,{data:{narrative:i.narrative,generatedAt:i.generatedAt,keyChanges:i.keyChanges,drivers:i.drivers,suggestedActions:i.suggestedActions,metadata:i.metadata},applyAction:d,audience:"dashboard",numberFormatter:g})})]})}):null:null}function yue({action:e,className:t,description:n,density:r="default",role:o="alert",title:s="This visual can’t be loaded"}){const i=v.useId();return l.jsx("div",{"aria-labelledby":i,className:p.cn("flex h-full min-h-0 w-full items-center justify-center text-center",r==="compact"?"px-0 py-1":"px-6 py-10",t),role:o,children:l.jsxs("div",{className:p.cn("flex flex-col items-center",r==="compact"?"max-w-[280px]":"max-w-[360px]"),children:[l.jsx(p.ChartColumn,{"aria-hidden":"true",className:p.cn("text-muted-foreground",r==="compact"?"mb-1.5 size-4":"mb-3 size-5"),strokeWidth:1.75}),l.jsx("h2",{id:i,className:p.cn("font-medium text-foreground",r==="compact"?"text-[12px]":"text-[14px]"),children:s}),n?l.jsx("p",{className:p.cn("text-muted-foreground",r==="compact"?"mt-0.5 text-[11px] leading-4":"mt-1 text-[12px] leading-5"),children:n}):null,e?l.jsx(p.Button,{className:r==="compact"?"mt-2":"mt-3",onClick:e.onClick,size:"xs",variant:"outline",children:e.label}):null]})})}function zw(e){if(!e||typeof e!="object")return{};const t=e.code,n=e.message;return e.deliveryBlocking!==!0||typeof t!="string"||typeof n!="string"?{}:{"data-semaphor-render-error-code":t,"data-semaphor-render-error-message":n}}function Bw({onRetry:e,density:t="default",showOwnerGuidance:n=!0}){return l.jsx(yue,{action:e?{label:"Try Again",onClick:e}:void 0,density:t,description:n?"Contact the dashboard owner for help resolving this issue.":void 0,role:"status"})}function lU({error:e,resetErrorBoundary:t}){return l.jsx("div",{...zw(e),className:"contents",children:l.jsx(Bw,{onRetry:t})})}const vue=4,BJe=.005,VJe="hsl(var(--semaphor-primary))",HJe="hsl(var(--semaphor-muted-foreground) / 0.35)",SM=[1,.65,.4,.25];function wue(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function qJe(e){return(e||[]).filter(t=>t.kind==="value_contributor"&&Number.isFinite(t.current)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0)}function UJe(e){return(e||[]).filter(t=>t.kind==="period_delta_driver"&&Number.isFinite(t.delta)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0).slice(0,vue).map(t=>({id:`${t.metricId}-${t.key}`,label:wue(t.key),delta:t.delta,contributionPct:t.contributionPct,direction:t.direction,action:t.action}))}function WJe(e,t){const n=e.slice(0,vue);if(n.length===0)return[];const r=t[0]||VJe,o=SM[SM.length-1]??.25,s=n.map((c,u)=>({id:`${c.metricId}-${c.key}`,label:wue(c.key),current:c.current,contributionPct:c.contributionPct,color:r,opacity:SM[u]??o,action:c.action})),i=n.reduce((c,u)=>c+u.contributionPct,0),a=Math.max(0,1-i);return a>=BJe&&s.push({id:"other",label:"Other",current:null,contributionPct:a,color:HJe,opacity:1,action:null}),s}function KJe({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){var Ee,Te,ze,Pe,He,ye,Ke,We,Qe,xe,Ve,Ae;const{setTitle:a,isEditable:c,isVisualEditing:u}=aue(),{setCardDescription:d}=p.useEditorActions(),{getLocale:f}=iue(e),{preferences:h,boundCurrency:m}=W_(e,t),{compiledAppearance:g}=p.useAppearance(),b=(Te=(Ee=e.preferences)==null?void 0:Ee.kpiVisualOptions)==null?void 0:Te.countryLogoId;v.useMemo(()=>sJe.find(ke=>ke.id===b),[b]);const x=e.config,y=x==null?void 0:x.summary,w=((y==null?void 0:y.breakdownDimensions)||[]).length>0,C=(y==null?void 0:y.enabled)===!0&&((y==null?void 0:y.showOnCard)===!0||w),N=!u&&C,S=(x==null?void 0:x.groupByColumns)&&x.groupByColumns.length>0,j=(x==null?void 0:x.metricColumns)||[],_=j[0],k=(_==null?void 0:_.id)||(_==null?void 0:_.name),T=j.some(ke=>p.getMetricComparisonKind(ke)==="target"),I=!S&&j.length>1&&!T,E=C&&!I&&!r,{data:D,isLoading:R,isRefreshing:A,refresh:F,applyAction:z}=B$(e,{enabled:E}),L=v.useMemo(()=>K$({card:e,preferences:h,boundCurrency:m}),[e,m,h]),$=v.useMemo(()=>qJe(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),H=v.useMemo(()=>UJe(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),M=g.chartPalette,B=v.useMemo(()=>rp({card:e,preferences:h,boundCurrency:m}),[e,m,h]),W=v.useMemo(()=>lue({card:e,preferences:h,boundCurrency:m}),[e,m,h]),P=v.useMemo(()=>{if(_)return U5(o,_)},[o,_]),G=P==null?void 0:P.metadata,Z=ke=>B.format(ke),X=ke=>B.formatCompact(ke),Y=ke=>W.format(ke),O=ke=>{const Be=t==null?void 0:t.find($e=>$e.segment===ke||$e.Segment===ke?k?$e.metricId===k||$e.metricId===void 0:!0:!1),Ie=(Be==null?void 0:Be.value)??(Be==null?void 0:Be.Value);if(typeof Ie=="number"&&Number.isFinite(Ie))return Ie;if(typeof Ie=="string"&&Ie.trim()){const $e=Number(Ie);return Number.isFinite($e)?$e:null}return null},q=O("current")??0,U=O("comparison"),V=(P==null?void 0:P.comparisonKind)??p.getMetricComparisonKind(_),K=p.getMetricComparisonPolarity(_),Q=(ze=e.preferences)==null?void 0:ze.comparisonPresentation,se=p.getMetricComparisonTarget(_),oe=typeof q=="number"&&!isNaN(q)?q:0,me=v.useMemo(()=>WJe($,M),[$,M]),le=typeof se=="number"&&!isNaN(se)?se:0,ue=le>0?Math.min(oe/le,1):0,ne=le>0?Math.max(le-oe,0):0,de=le>0?Math.max(oe-le,0):0,Ce=uJe({comparisonKind:V,targetValue:le,presentation:Q}),ce=dJe({comparisonKind:V,comparisonValue:U,targetValue:le}),ie=V==="target"?typeof se=="number"&&Number.isFinite(se):ce!==null,we=V!=="none"&&ie&&(Q==null?void 0:Q.showComparison)!==!1,fe=(He=(Pe=e.preferences)==null?void 0:Pe.formatNumber)==null?void 0:He.colorRanges,ae=$I(q,fe);function ee(){return e.title?e.title:c?"Enter title":""}const J=e.description||(u?"Enter description":"");if(r)return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),(e.description||u)&&l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",value:J,placeholder:u?"Enter description":"",isEditable:u,onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,i]})]}),l.jsx("div",{className:"flex min-h-0 flex-1 px-4 py-3",children:l.jsx(Bw,{density:"compact",showOwnerGuidance:!1})})]})});if(I)return l.jsx(cJe,{card:e,data:t,isPending:n,headerAction:s,headerTrailingAction:i});if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const pe=((ye=e==null?void 0:e.kpiPreferences)==null?void 0:ye.format)==="compact"?X(q):Z(q);return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[l.jsx(xi,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),N&&l.jsxs(Xm,{openDelay:180,closeDelay:120,children:[l.jsx(Yd,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-4 shrink-0 rounded-[3px] p-0 text-muted-foreground hover:text-foreground","aria-label":"Show summary",children:l.jsx(p.Info,{className:"h-3 w-3"})})}),l.jsxs(bu,{align:"start",className:"ml-2 w-[360px] overflow-hidden p-0",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),D&&(D.metadata.partial||D.metadata.warnings.length>0)&&l.jsx(Y$,{className:"text-amber-500"})]}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>F(),disabled:A,"aria-label":"Refresh summary",children:l.jsx(tc,{className:p.cn("h-3 w-3",A&&"animate-spin")})})]}),R&&!D?l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-5/6 animate-pulse rounded bg-foreground/[0.06]"})]}):D?l.jsx(Oj,{data:{narrative:D.narrative,generatedAt:D.generatedAt,keyChanges:D.keyChanges,drivers:D.drivers,suggestedActions:D.suggestedActions,metadata:D.metadata},applyAction:z,audience:"dashboard",numberFormatter:L}):l.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"Summary is unavailable for this card."})]})]})]}),(e.description||u)&&l.jsx(xi,{isEditable:u,value:J,placeholder:u?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,we&&ce!==null&&l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx("div",{className:"shrink-0 cursor-help [&_.inline-flex]:h-[18px] [&_.inline-flex]:gap-1 [&_.inline-flex]:px-1.5 [&_.inline-flex]:py-0 [&_.inline-flex]:text-[11px] [&_.inline-flex]:font-medium",children:l.jsx(u3,{primaryValue:q,secondaryValue:ce,presentation:Q,metricFormatOptions:(We=(Ke=e.preferences)==null?void 0:Ke.kpiVisualOptions)==null?void 0:We.formatOptions,locale:f()||"en-US",decimalPlaces:(xe=(Qe=e.preferences)==null?void 0:Qe.formatNumber)==null?void 0:xe.decimalPlaces,suffix:(Ae=(Ve=e.preferences)==null?void 0:Ve.formatNumber)==null?void 0:Ae.suffix,polarity:K,signedValueFormatter:B.formatSigned,allowSignedValueFormatter:B.supportsComparisonDeltaInheritance})})}),l.jsx(oJe,{currentValue:q,comparisonValue:ce,comparisonKind:V,sentiment:$r.evaluateMetricComparison({currentValue:q,comparisonValue:ce,polarity:K}).sentiment,data:t,comparisonMetadata:G,formatCurrency:Z,conditionalLabel:(()=>{if(Q!=null&&Q.conditionalLabel){const{conditionalLabels:ke}=Q,Be=q-ce;return Be>0?(ke==null?void 0:ke.increase)||"Increase":Be<0?(ke==null?void 0:ke.decrease)||"Decrease":(ke==null?void 0:ke.neutral)||"No change"}})()})]}),i]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:ae?{color:ae}:void 0,children:pe}),we&&ce!==null&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[V==="target"?(Q==null?void 0:Q.labelName)||"Target":(Q==null?void 0:Q.labelName)||"Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:Z(ce)})]})]}),Ce&&l.jsxs("div",{className:"space-y-1.5 border-t border-border/60 px-4 py-2.5",children:[l.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(Math.round(ue*100),100)}%`,backgroundColor:ae||void 0}})}),l.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:[l.jsx("span",{children:oe>=le?de>0?`${Y(de)} above target`:"Target reached":`${Y(ne)} remaining`}),l.jsxs("span",{className:"tabular-nums",children:[Math.round(ue*100),"%"]})]})]}),C&&R&&!D&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-2.5","data-testid":"kpi-composition-loading","aria-hidden":"true",children:[l.jsxs("div",{className:"flex h-1 w-full gap-px overflow-hidden rounded-[2px]",children:[l.jsx("div",{className:"h-full w-[40%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[26%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[16%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full flex-1 animate-pulse bg-foreground/[0.06]"})]}),l.jsx("ul",{className:"space-y-1",children:["58%","44%","36%"].map((ke,Be)=>l.jsxs("li",{className:"flex items-center justify-between gap-3",children:[l.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 animate-pulse rounded-[2px] bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 animate-pulse rounded bg-foreground/[0.06]",style:{width:ke}})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2",children:[l.jsx("span",{className:"h-2.5 w-7 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 w-10 animate-pulse rounded bg-foreground/[0.06]"})]})]},`composition-skeleton-${Be}`))})]}),C&&me.length>0&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-3",children:[l.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-[2px]",children:me.map(ke=>l.jsx("div",{"data-testid":"kpi-composition-segment",className:"h-full",style:{width:`${Math.max(ke.contributionPct*100,2)}%`,backgroundColor:ke.color,opacity:ke.opacity}},ke.id))}),l.jsx("ul",{className:"space-y-1",children:me.map(ke=>{const Be=l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 rounded-[2px]",style:{backgroundColor:ke.color,opacity:ke.opacity}}),l.jsx("span",{className:p.cn("truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",ke.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:ke.label})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[ke.current!=null&&l.jsx("span",{className:"text-muted-foreground",children:L.formatValue(ke.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:L.formatPct(ke.contributionPct)})]})]});return l.jsx("li",{children:ke.action?l.jsx("button",{type:"button",onClick:()=>z(ke.action),"aria-label":`Filter to ${ke.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:Be}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:Be})},`${ke.id}-legend`)})})]}),C&&me.length===0&&H.length>0&&l.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:l.jsx("ul",{className:"space-y-1",children:H.map(ke=>{const Be=ke.direction==="up"?"text-emerald-600 dark:text-emerald-400":ke.direction==="down"?"text-rose-600 dark:text-rose-400":"text-foreground",Ie=l.jsxs(l.Fragment,{children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",ke.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:ke.label}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[l.jsx("span",{className:p.cn("font-medium",Be),children:L.formatSigned(ke.delta)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:L.formatPct(ke.contributionPct)})]})]});return l.jsx("li",{"data-testid":"kpi-period-driver-row",children:ke.action?l.jsx("button",{type:"button",onClick:()=>z(ke.action),"aria-label":`Filter to ${ke.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:Ie}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:Ie})},`${ke.id}-driver`)})})})]})})}function GJe({card:e,data:t,isPending:n,isError:r,headerAction:o,headerTrailingAction:s}){var A,F,z,L;const i=p.useDashboardStore($=>$.isVisualEditing),a=p.useEditorStore($=>$.card),c=p.useEditorStore($=>$.actions.setCard);p.useEditorStore($=>$.actions.setNumberFormat);const u=(F=(A=e.preferences)==null?void 0:A.formatNumber)==null?void 0:F.colorRanges,d=$=>{if(typeof $=="number")return Number.isFinite($)?$:null;if(typeof $=="string"){const H=$.trim();if(!H)return null;const M=Number(H.replace(/,/g,""));return Number.isFinite(M)?M:null}return null},f=(t==null?void 0:t[0])??{},h=mw(t),m=h[0],g=h[1],{preferences:b,boundCurrency:x}=W_(e,t),y=rp({card:e,preferences:b,boundCurrency:x}),w=m!==void 0?d(f[m]):null,C=g!==void 0?d(f[g]):null,N=Array.isArray(t)&&t.length>0,S=t==null?void 0:t.some($=>Object.values($).some(H=>H!=null)),j=N&&w!==null,_=N&&S?"KPI needs a numeric metric. Add a numeric field or aggregation.":"No data available for this KPI.";function k($){i&&c({...a,title:$})}function T($){i&&c({...a,description:$})}const I=w!==null&&C!==null&&C!==0?(w-C)/C:null,E=w!==null?y.format(w):"--";let D="";C!==null&&(D=y.format(C));const R=$I(w??0,u);return l.jsx(YJe,{isPending:n,isError:r,title:e.title,formattedCurrentValue:E,formattedPreviousValue:D,description:e.description,valueColor:R,onTitleChange:k,onDescriptionChange:T,percentDifference:I,polarity:((L=(z=e.preferences)==null?void 0:z.kpiVisualOptions)==null?void 0:L.queryComparisonPolarity)??$r.DEFAULT_METRIC_COMPARISON_POLARITY,show:j,emptyStateMessage:_,headerAction:o,headerTrailingAction:s})}function tf({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){return!Wre(e)&&dt.hasValidCardConfig(e.config)?l.jsx("div",{className:"flex h-full min-h-0 grow overflow-auto",children:l.jsx(KJe,{card:e,data:t||[],isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i})}):l.jsx(GJe,{card:e,data:t,isPending:n,isError:r,headerAction:s,headerTrailingAction:i})}function YJe({title:e,formattedCurrentValue:t,formattedPreviousValue:n,description:r,valueColor:o,onTitleChange:s,onDescriptionChange:i,percentDifference:a,show:c,emptyStateMessage:u,isPending:d,isError:f,polarity:h,headerAction:m,headerTrailingAction:g}){const b=p.useDashboardStore(C=>C.isVisualEditing),x=p.useEditorStore(C=>C.card),y=r??"",w=y||(b?"Enter description":"");return l.jsxs("div",{className:"kpi-card flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Pj,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",containerClassName:"min-w-0",enabled:b,text:b?x.title:e,onSave:s,children:l.jsx(cb,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})}),(y||b)&&l.jsx(Pj,{className:"min-w-0 truncate text-[11px] text-muted-foreground/80",containerClassName:"min-w-0",enabled:b,text:w,placeholder:b?"Enter description":"",onSave:i,children:l.jsx("span",{className:"block min-w-0 truncate text-[11px] text-muted-foreground/80",children:w})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[m,a!=null&&a!==0&&!f&&!d&&l.jsx(Cue,{polarity:h,children:a}),g]})]}),l.jsx("div",{className:"flex flex-1 flex-col justify-between gap-2 px-4 py-3",children:f?l.jsx(Bw,{density:"compact",showOwnerGuidance:!1}):d?l.jsxs("div",{className:"space-y-2",children:[l.jsx(Xs,{className:"h-7 w-32 bg-foreground/[0.06]"}),l.jsx(Xs,{className:"h-3 w-24 bg-foreground/[0.06]"})]}):c?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:o?{color:o}:void 0,children:t}),n&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:n})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:u})})]})}function Cue({children:e,className:t,polarity:n}){const r=e>0,o=n==="lower_is_better"?!r:n==="higher_is_better"?r:null,s=r?bs:es,i=`${Math.abs(e*100).toFixed(0)}%`;return l.jsxs("span",{className:p.cn("inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[4px] px-1.5 text-[11px] font-medium tabular-nums",o===!0?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":o===!1?"bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300":"bg-gray-50 text-gray-700 dark:bg-gray-900 dark:text-gray-400",t),children:[l.jsx(s,{className:"h-3 w-3"}),i]})}function Vw({customerFacingMessage:e,error:t,resetErrorBoundary:n}){return l.jsxs("div",{...zw(t),className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[l.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:l.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),l.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),l.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||"Couldn't display this chart right now. Please try refreshing or check your data configuration."}),l.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[l.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),l.jsxs("details",{className:"mt-4 w-full text-left",children:[l.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground hover:text-foreground",children:"Show technical details"}),l.jsxs("div",{className:"mt-2 rounded border bg-background p-3",children:[l.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"Error Details:"}),l.jsx("pre",{className:"text-xs text-muted-foreground",children:t.message})]})]})]})}function BI({error:e}){return l.jsx("div",{...zw(e),className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:l.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[l.jsx("p",{className:"text-sm",children:"Something went wrong:"}),l.jsx("pre",{className:"text-xs",children:e.message})]})})}function ZJe({error:e,frame:t}){return l.jsxs("div",{...zw(e),className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[l.jsx(ZP,{frame:t,isHovered:!1}),l.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),l.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[l.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),l.jsx("p",{className:"text-sm",children:"Something went wrong:"}),l.jsx("pre",{className:"text-xs",children:e.message})]})]})}function XJe(e={},t){const{displayPreferences:n,shouldShowElement:r}=cl(),o=mf(n.mode),s=e.enabled??!0,i=e.serverSide??!1,a=o?Number.MAX_SAFE_INTEGER:e.pageSize||50,c=e.currentPage!==void 0,[u,d]=v.useState(0),[f,h]=v.useState(a),m=c?(e.currentPage||1)-1:u,g=o?Number.MAX_SAFE_INTEGER:c?e.pageSize||a:f,b=v.useMemo(()=>s&&r("showPagination")&&!o,[s,r,o]),x=v.useMemo(()=>i?e.pageCount:Math.ceil(t/g),[i,e.pageCount,t,g]),y=v.useMemo(()=>i?e.totalCount||0:t,[i,e.totalCount,t]),w=v.useMemo(()=>i?(e.currentPage||1)>1:m>0,[i,e.currentPage,m]),C=v.useMemo(()=>i?(e.currentPage||1)<(e.pageCount||1):m<(x||1)-1,[i,e.currentPage,e.pageCount,m,x]);return{pageIndex:m,pageSize:g,isServerSidePagination:i,showPagination:b,paginationEnabled:s,isTablePrintDisplayMode:o,setPageIndex:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},setPageSize:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,1,k):(d(0),h(k))},canPreviousPage:w,canNextPage:C,previousPage:()=>{var T;if(!w)return;const k=m-1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},nextPage:()=>{var T;if(!C)return;const k=m+1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},pageCount:x,totalCount:y}}function QJe(e,t){const n=e.subtotalLevel,r=K_(t.groupByColumns,n);if(r<0)throw new Error(`invalid_pivot_subtotal_identity: Subtotal level "${n||""}" does not match a configured row-axis field.`);return r}function JJe(e,t,n){var c;if(!t.length)return e;const r=t[0].id,o=t[0].desc?-1:1,s=((c=n.groupByColumns)==null?void 0:c.length)||0,i=r.startsWith("rowLevel"),a=i?parseInt(r.replace("rowLevel","")):-1;return i?eet(e,a,o):tet(e,r,o,s,n)}function eet(e,t,n){const r=[...e],o=new Map,s=[];r.forEach(c=>{if(c.isGrandTotal)return;const u=t>0?JSON.stringify((c.canonicalFieldValues||c.fieldValues).slice(0,t)):"root";o.has(u)||(o.set(u,[]),s.push(u)),o.get(u).push(c)});const i=[];s.forEach(c=>{const u=o.get(c),d=u.filter(h=>!h.isSubtotal),f=u.filter(h=>h.isSubtotal);d.sort((h,m)=>{const g=ws(h,t),b=ws(m,t);return g===b?0:g==null?1:b==null?-1:String(g).localeCompare(String(b))*n}),i.push(...d),i.push(...f)});const a=e.find(c=>c.isGrandTotal);return a&&i.push(a),i}function tet(e,t,n,r,o){const s={rows:[],children:new Map};let i;e.forEach(f=>{if(f.isGrandTotal){i=f;return}const h=f.isSubtotal?QJe(f,o)+1:r;let m=s;for(let g=0;g<h;g++){const b=JSON.stringify(ws(f,g));m.children.has(b)||m.children.set(b,{rows:[],children:new Map}),m=m.children.get(b)}f.isSubtotal?m.subtotal=f:m.rows.push(f)});function a(f){var h;return t==="rowTotal"?o.columnHeaders.reduce((m,g)=>{var x;const b=(x=f.cells[g])==null?void 0:x.value;return m+(typeof b=="number"?b:0)},0):(h=f.cells[t])==null?void 0:h.value}function c(f){let h=0;return f.rows.forEach(m=>{const g=a(m);typeof g=="number"&&(h+=g)}),f.children.forEach(m=>{if(m.subtotal){const g=a(m.subtotal);typeof g=="number"&&(h+=g)}else h+=c(m)}),h}function u(f){const h=[],m=[...f.rows].sort((b,x)=>{const y=a(b),w=a(x);return y===w?0:y==null?1:w==null?-1:y>w?n:-n});return h.push(...m),Array.from(f.children.entries()).sort(([,b],[,x])=>{const y=b.subtotal?a(b.subtotal):c(b),w=x.subtotal?a(x.subtotal):c(x);return y===w?0:y==null?1:w==null?-1:y>w?n:-n}).forEach(([,b])=>{h.push(...u(b))}),f.subtotal&&h.push(f.subtotal),h}const d=u(s);return i&&d.push(i),d}function net(e,t){const[n,r]=v.useState([]),o=v.useMemo(()=>JJe(e,n,t),[e,n,t]),s=v.useCallback(c=>{r(u=>{const d=u.find(f=>f.id===c);return d?d.desc?[]:[{id:c,desc:!0}]:[{id:c,desc:!1}]})},[]),i=v.useCallback(()=>{r([])},[]),a=v.useCallback(c=>{const u=n.find(d=>d.id===c);return u?u.desc?"desc":"asc":!1},[n]);return{sorting:n,setSorting:r,sortedTableData:o,toggleColumnSort:s,clearSorting:i,getSortDirection:a}}function NM({columnName:e,groupByFields:t,pivotByFields:n,currentAggregation:r,onAggregationChange:o,onOpenChange:s}){const i=[{value:"SUM",label:"Sum"},{value:"MAX",label:"Max"},{value:"MIN",label:"Min"},{value:"AVG",label:"Avg"},{value:"MEDIAN",label:"Median"}],a=(u,d,f)=>{o({function:u,rowLevel:d,columnLevel:f})},c=(u,d,f)=>{if(!r)return!1;if(d!==void 0&&f===void 0){if(r.rowAggregates){const h=d==="all"?"ALL":d;return r.rowAggregates.some(m=>m.function===u&&m.groupLevel===h)}return!1}if(f!==void 0&&d===void 0){if(r.columnAggregates){const h=f==="all"?"ALL":f;return r.columnAggregates.some(m=>m.function===u&&m.pivotLevel===h)}return!1}return!1};return l.jsxs(Uo,{modal:!1,onOpenChange:s,children:[l.jsx(Wo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 hover:bg-accent hover:text-accent-foreground",children:l.jsx(Rm,{className:"size-3"})})}),l.jsxs(Do,{align:"start",className:"w-56",children:[l.jsx(qa,{className:"text-xs font-normal text-muted-foreground",children:"AGGREGATE"}),i.map(u=>{var m,g;const d=((m=r==null?void 0:r.rowAggregates)==null?void 0:m.some(b=>b.function===u.value))||!1,f=((g=r==null?void 0:r.columnAggregates)==null?void 0:g.some(b=>b.function===u.value))||!1,h=d||f;return l.jsxs(qO,{children:[l.jsx(Lk,{className:"text-xs",children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:u.label}),h&&l.jsxs("div",{className:"ml-2 flex items-center gap-1 text-xs",children:[d&&l.jsx("span",{className:"rounded bg-blue-100 px-1 py-0.5 text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"R"}),f&&l.jsx("span",{className:"rounded bg-green-100 px-1 py-0.5 text-green-700 dark:bg-green-900 dark:text-green-300",children:"C"})]})]})}),l.jsxs($k,{className:"w-48",children:[l.jsx(qa,{className:"text-xs font-normal text-muted-foreground",children:"ROWS"}),l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all rows"}),c(u.value,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),t.map(b=>l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,b.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",b.label||b.name]}),c(u.value,b.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},b.id)),n.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Sa,{}),l.jsx(qa,{className:"text-xs font-normal text-muted-foreground",children:"COLUMNS"}),l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,void 0,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all columns"}),c(u.value,void 0,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),n.map(b=>l.jsx(kn,{className:"text-xs",onClick:()=>a(u.value,void 0,b.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",b.label||b.name]}),c(u.value,void 0,b.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},b.id))]})]})]},`${u.value}-${u.label}`)})]})]})}function Lj(e,t,n,r,o=!1){if(t){const s=M_(e,t,n,r,o),i=typeof e=="object"&&e!==null&&"value"in e?e.value:e,a=UEe(i,t);return s==="-"||s===0?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):a?l.jsx("span",{style:{backgroundColor:a.backgroundColor,color:a.color,padding:"0.125rem 0.25rem",borderRadius:"0.25rem"},children:s}):s}return typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0?e.formattedValue==="-"||e.formattedValue===0?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):e.formattedValue:typeof e=="number"?e===0||e===null?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):e.toLocaleString():e==null?l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})}):(e==null?void 0:e.toString())||l.jsx("div",{className:"flex justify-end",children:l.jsx($c,{className:"h-3 w-3 text-muted-foreground"})})}function ret(e){return(e==null?void 0:e.includes("__subtotal__"))||(e==null?void 0:e.includes("_SUM_"))||(e==null?void 0:e.includes("_AVG_"))||(e==null?void 0:e.includes("_COUNT_"))||(e==null?void 0:e.includes("_MIN_"))||(e==null?void 0:e.includes("_MAX_"))}function oet(e,t){const n=(e==null?void 0:e.includes("__subtotal__"))&&(e==null?void 0:e.includes("__ALL__"))||(e==null?void 0:e.includes("_SUM_ALL"))||(e==null?void 0:e.includes("_AVG_ALL"))||(e==null?void 0:e.includes("_COUNT_ALL"))||(e==null?void 0:e.includes("_MIN_ALL"))||(e==null?void 0:e.includes("_MAX_ALL")),r=(t==null?void 0:t.some(o=>o.columnName===e&&(o.subtotalScope==="grand-total"||o.subtotalLevel==="grandTotal"||o.subtotalLevel==="ALL")))??!1;return n||r}function set({data:e,card:t,table:n,sorting:r,setSorting:o,showRowTotals:s,onAggregationChange:i,onOpenColumnSettings:a,suppressSortControls:c=!1,tableAppearance:u}){const[,d]=v.useState(null),f=p.useDashboardStore(g=>g.isVisualEditing),h=v.useCallback(g=>{var b;return(b=n.getHeaderGroups()[0])==null?void 0:b.headers.find(x=>x.column.id===g)},[n]);return{buildColumnHeaderRows:v.useCallback(()=>{var k,T;const g=((k=t.config)==null?void 0:k.pivotByColumns)||[],b=g.length,x=((T=e.groupByColumns)==null?void 0:T.length)||1,y=e.columnHeaders.length;function w(I,E,D,R=[]){I.forEach((A,F)=>{const z=A.level;if(z<b){const L=A.columnKey||`${z}-${R.join("-")}-${A.name}-${F}`,$=A.children?1:b-z;if(D[z].push(l.jsx(mo,{colSpan:A.colspan,rowSpan:$,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 px-3 py-1.5 text-center text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,z===0?"bg-muted/95":"bg-muted/90"),children:l.jsx("div",{className:"flex items-center justify-center",children:l.jsx("span",{className:"whitespace-nowrap",children:A.name})})},L)),A.children){const H=[...R,A.name];w(A.children,z+1,D,H)}}})}function C(I,E=[]){const D=[];return I.forEach((R,A)=>{var F,z,L,$,H,M,B,W;if(R.columnKey){const P=R.columnKey||`metric-${E.join("-")}-${R.name}-${A}`,G=ret(R.columnKey),Z=oet(R.columnKey,e.columnSubtotalMeta),X=n.getColumn(R.columnKey),Y=h(R.columnKey);D.push(l.jsx(mo,{"data-column-id":R.columnKey,className:p.cn("group/header h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,Z?"bg-muted/95 font-semibold":G?"bg-muted/90 font-medium":""),style:{...u.headerCellStyle,width:Y==null?void 0:Y.getSize(),minWidth:Y==null?void 0:Y.getSize(),maxWidth:Y==null?void 0:Y.getSize(),position:"relative",transition:"none"},children:X?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:(($=e.columnDisplayNames)==null?void 0:$[R.columnKey])||R.name||"Metric",children:((H=e.columnDisplayNames)==null?void 0:H[R.columnKey])||R.name||"Metric"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const O=X.getIsSorted();o(O?O==="asc"?[{id:X.id,desc:!0}]:[]:[{id:X.id,desc:!1}])},"aria-label":`Sort ${((F=e.columnDisplayNames)==null?void 0:F[R.columnKey])||R.name||"Metric"}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((z=e.columnDisplayNames)==null?void 0:z[R.columnKey])||R.name||"Metric",children:((L=e.columnDisplayNames)==null?void 0:L[R.columnKey])||R.name||"Metric"}),l.jsx(bs,{className:p.cn("h-3 w-3",X.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3",X.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(Y!=null&&Y.column.getIsResizing())&&l.jsxs(Uo,{modal:!1,children:[l.jsx(Wo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((M=e.columnDisplayNames)==null?void 0:M[R.columnKey])||R.name||"Metric"} column`,className:"h-5 w-5 shrink-0 p-0",onClick:O=>O.stopPropagation(),children:l.jsx(Ci,{className:"h-3 w-3"})})}),l.jsxs(Do,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:X.id,desc:!1}]),children:[l.jsx(bs,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:X.id,desc:!0}]),children:[l.jsx(es,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Sa,{})]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>a(R.columnKey),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),Y&&f&&l.jsx(nh,{header:Y,isResizing:Y.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((B=e.columnDisplayNames)==null?void 0:B[R.columnKey])||R.name||"Metric",children:((W=e.columnDisplayNames)==null?void 0:W[R.columnKey])||R.name||"Metric"})},P))}else if(R.children){const P=[...E,R.name];D.push(...C(R.children,P))}}),D}const N=l.jsxs(Ar,{"data-header-type":"pivot-hierarchy","data-header-row-index":"0","data-repeat-header":"true",children:[e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((I,E)=>{var F,z,L,$,H;const D=(F=n.getHeaderGroups()[0])==null?void 0:F.headers.find(M=>M.column.id===`rowLevel${E}`),R=D==null?void 0:D.getSize(),A=`row-header-${E}`;return l.jsx(mo,{rowSpan:b+2,"data-column-id":`rowLevel${E}`,className:p.cn("group/rowheader h-8 whitespace-nowrap border-b border-r border-border/40 bg-muted/95 px-3 py-1.5 text-left align-bottom text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:R,minWidth:R,maxWidth:R,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex h-full min-w-0 items-end justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(NM,{columnName:I.label||I.name,groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(z=t.config)==null?void 0:z.rowAggregates,columnAggregates:(L=t.config)==null?void 0:L.columnAggregates},onAggregationChange:i,onOpenChange:M=>d(M?A:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:M=>{M.stopPropagation(),M.preventDefault(),o(B=>{const W=B.find(P=>P.id===`rowLevel${E}`);return W?W.desc?[]:[{id:`rowLevel${E}`,desc:!0}]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name}),l.jsx(bs,{className:p.cn("h-3 w-3 flex-shrink-0",(($=r.find(M=>M.id===`rowLevel${E}`))==null?void 0:$.desc)===!1?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3 flex-shrink-0",((H=r.find(M=>M.id===`rowLevel${E}`))==null?void 0:H.desc)===!0?"block":"hidden")})]})]}),D&&f&&l.jsx(nh,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-corner-${E}`)}):l.jsx(mo,{colSpan:x,rowSpan:b+2,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:""}),l.jsx(mo,{colSpan:y,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:l.jsxs("div",{className:"group/pivot-main relative flex items-center",children:[i&&(()=>{var E,D;const I="pivot-main";return l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(NM,{columnName:"Pivot Columns",groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(E=t.config)==null?void 0:E.rowAggregates,columnAggregates:(D=t.config)==null?void 0:D.columnAggregates},onAggregationChange:i,onOpenChange:R=>d(R?I:null)})})})(),l.jsx("div",{className:p.cn("transition-all duration-200",i&&"pl-7"),children:g.map((I,E)=>l.jsxs("span",{className:"inline-flex items-center",children:[I.label,E<g.length-1&&l.jsx(Ft.ChevronRight,{className:"mx-1 inline-block h-4 w-4 text-muted-foreground"})]},I.id))})]})},"pivot-hierarchy"),s&&(()=>{var D;const I=(D=n.getHeaderGroups()[0])==null?void 0:D.headers.find(R=>R.column.id==="rowTotal"),E=I==null?void 0:I.getSize();return l.jsx(mo,{"data-column-id":"rowTotal",className:p.cn("group/total h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-center text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),rowSpan:b+2,style:{...u.headerCellStyle,width:E,minWidth:E,maxWidth:E,position:"relative",transition:"none"},children:(()=>{const R=n.getColumn("rowTotal");return R?l.jsxs("div",{className:"flex w-full items-center justify-end",children:[c?l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const A=R.getIsSorted();o(A?A==="asc"?[{id:R.id,desc:!0}]:[]:[{id:R.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}),l.jsx(bs,{className:p.cn("h-3 w-3",R.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3",R.getIsSorted()==="desc"?"block":"hidden")})]}),I&&f&&l.jsx(nh,{header:I,isResizing:I.column.getIsResizing()})]}):"Total"})()},"pivot-hierarchy-total")})()]},"pivot-hierarchy"),S=[];if(e.columnGroups&&e.columnGroups.length>0){const I=Array.from({length:b},()=>[]);w(e.columnGroups,0,I,[]);for(let E=0;E<b;E++)S.push(l.jsx(Ar,{"data-header-type":"pivot-values","data-header-row-index":E+1,"data-repeat-header":"true",children:I[E]},`pivot-row-${E}`))}let j=[];e.columnGroups&&e.columnGroups.length>0?j=C(e.columnGroups,[]):e.columnHeaders.forEach(I=>{var R,A,F,z,L,$,H,M,B;const E=n.getColumn(I),D=(R=n.getHeaderGroups()[0])==null?void 0:R.headers.find(W=>W.column.id===I);j.push(l.jsx(mo,{"data-column-id":I,className:p.cn("group/colheader h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:D==null?void 0:D.getSize(),minWidth:D==null?void 0:D.getSize(),maxWidth:D==null?void 0:D.getSize(),position:"relative",transition:"none"},children:E?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((L=e.columnDisplayNames)==null?void 0:L[I])||I,children:(($=e.columnDisplayNames)==null?void 0:$[I])||I}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const W=E.getIsSorted();o(W?W==="asc"?[{id:E.id,desc:!0}]:[]:[{id:E.id,desc:!1}])},"aria-label":`Sort ${((A=e.columnDisplayNames)==null?void 0:A[I])||I}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((F=e.columnDisplayNames)==null?void 0:F[I])||I,children:((z=e.columnDisplayNames)==null?void 0:z[I])||I}),l.jsx(bs,{className:p.cn("h-3 w-3",E.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(es,{className:p.cn("h-3 w-3",E.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(D!=null&&D.column.getIsResizing())&&l.jsxs(Uo,{modal:!1,children:[l.jsx(Wo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((H=e.columnDisplayNames)==null?void 0:H[I])||I} column`,className:"h-5 w-5 shrink-0 p-0",onClick:W=>W.stopPropagation(),children:l.jsx(Ci,{className:"h-3 w-3"})})}),l.jsxs(Do,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!1}]),children:[l.jsx(bs,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!0}]),children:[l.jsx(es,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Sa,{})]}),l.jsxs(kn,{className:"gap-2 text-xs",onSelect:()=>a(I),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),D&&f&&l.jsx(nh,{header:D,isResizing:D.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((M=e.columnDisplayNames)==null?void 0:M[I])||I,children:((B=e.columnDisplayNames)==null?void 0:B[I])||I})},I))});const _=l.jsxs(Ar,{"data-header-type":"metrics","data-header-row-index":b>0?b+1:0,"data-repeat-header":"true",children:[b===0&&(e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((I,E)=>{var F,z,L,$;const D=(F=n.getHeaderGroups()[0])==null?void 0:F.headers.find(H=>H.column.id===`rowLevel${E}`),R=D==null?void 0:D.getSize(),A=`metric-row-${E}`;return l.jsx(mo,{"data-column-id":`rowLevel${E}`,className:p.cn("group/metricrow h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:R,minWidth:R,maxWidth:R,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(NM,{columnName:I.label||I.name,groupByFields:e.groupByColumns||[],pivotByFields:((z=t.config)==null?void 0:z.pivotByColumns)||[],currentAggregation:{rowAggregates:(L=t.config)==null?void 0:L.rowAggregates,columnAggregates:($=t.config)==null?void 0:$.columnAggregates},onAggregationChange:i,onOpenChange:H=>d(H?A:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:()=>{o(H=>{const M=H.find(B=>B.id===`rowLevel${E}`);return M?M.desc===!1?[{id:`rowLevel${E}`,desc:!0}]:[]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:I.label||I.name,children:I.label||I.name}),(()=>{const H=r.find(M=>M.id===`rowLevel${E}`);return l.jsxs(l.Fragment,{children:[l.jsx(es,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!0?"block":"hidden")}),l.jsx(bs,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!1?"block":"hidden")})]})})()]})]}),D&&f&&l.jsx(nh,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-title-${E}`)}):Array.from({length:x}).map((I,E)=>l.jsx(mo,{style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:`Level ${E+1}`},`empty-header-metric-${E}`))),j]},"metric-row");return b>0?[N,...S,_]:[_]},[e,t,n,r,o,s,i,h,d,f,a,c,u])}}function iet(e,t,n){var k,T;const r=p.useDashboardStore(I=>I.isVisualEditing);p.useDashboardStore(I=>I.isDashboardEditing),p.useDashboardStore(I=>I.selectedSheetId);const{updateCurrentDashboardCard:o,updateFrame:s}=p.useDashboardActions(),i=p.useEditorStore(I=>{var E;return(E=I.actions)==null?void 0:E.setCardPreferences}),a=p.useEditorStore(I=>I.card),c=((T=(k=e==null?void 0:e.preferences)==null?void 0:k.tablePrefs)==null?void 0:T.columnSettingsMap)??p.EMPTY_COLUMN_SETTINGS,u=v.useMemo(()=>nc(c),[c]),[d,f]=v.useState(!1),[h,m]=v.useState(null),[g,b]=v.useState(To()),[x,y]=v.useState(!1),w=v.useRef(To()),C=v.useCallback(I=>{var D,R;m(I);let E=u[I];if(!E){const A=t==null?void 0:t.map(F=>{var z,L;return{[I]:(L=(z=F.cells)==null?void 0:z[I])==null?void 0:L.value}});E=A&&A.length>0?O0(I,A,n):To()}E=Bi({card:e,columnId:I,resolvedSettings:E,metricId:(D=n==null?void 0:n[I])==null?void 0:D.metricId,metricAlias:(R=n==null?void 0:n[I])==null?void 0:R.metricAlias,preserveOmittedProperties:!0})||E,w.current=E,b(E),y(!1),f(!0)},[e,u,t,n]),N=v.useCallback(()=>{var I,E;if(h&&g){const D=L5({persisted:c,columnId:h,baseline:w.current,next:g,reset:x});if(r&&i){const R={...a.preferences,tablePrefs:{...(I=a.preferences)==null?void 0:I.tablePrefs,columnSettingsMap:D}};i(R)}else if(o){const R={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:D}}};o(R)}}f(!1)},[h,g,x,c,r,i,a,o,e]),S=v.useCallback(()=>{h&&(b(To()),y(!0))},[h]),j=v.useCallback(I=>{y(!1),b(I)},[]),_=v.useCallback(()=>{var I,E;if(r&&i){const D={...a.preferences,tablePrefs:{...(I=a.preferences)==null?void 0:I.tablePrefs,columnSettingsMap:{}}};i(D)}else if(o){const D={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:{}}}};o(D)}f(!1)},[r,i,a,o,e]);return{columnSettings:u,columnSettingsOpen:d,activeColumnId:h,tempColumnSettings:g,isVisualEditing:r,openColumnSettings:C,applyColumnSettings:N,resetColumnSettings:S,resetAllColumnSettings:_,setColumnSettingsOpen:f,setTempColumnSettings:j}}function aet({table:e,data:t,columns:n,subtotalColumnKeys:r,grandTotalColumnKeys:o,isTablePrintDisplayMode:s=!1,shouldVirtualizeRows:i=!1,virtualRows:a,paddingTop:c=0,paddingBottom:u=0,measureElement:d,disableRowTransitions:f=!1,suppressEmptyState:h=!1,tableAppearance:m}){var C;const g=e.getRowModel().rows,b=((C=t.groupByColumns)==null?void 0:C.length)||1,y=i&&a&&a.length>0?a:g,w=n.length||1;return g!=null&&g.length?l.jsxs(l.Fragment,{children:[i&&c>0&&l.jsx(Ar,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(qn,{colSpan:w,style:{height:c,padding:0,border:"none"}})}),y.map((N,S)=>{const j=i?N.index:S,_=i?g[j]:N;if(!_)return null;const k=_.original,T=e.getRowModel().rows,I=j===T.length-1;return l.jsx(Ar,{ref:i&&d?E=>d(E):void 0,style:k.isSubtotal?m.subtotalRowStyle:m.getDataRowStyle(j),className:p.cn("border-border/40",(f||m.hasHoverRowStyle)&&"!transition-none",!f&&!m.hasHoverRowStyle&&"transition-colors duration-150",!k.isSubtotal&&m.dataRowClassName,k.isSubtotal?"border-t border-t-border/50 bg-muted/70 font-medium":"hover:bg-muted/40"),"data-row-type":k.isSubtotal?"subtotal":"data","data-row-index":j,...k.isSubtotal&&{"data-subtotal-level":k.subtotalLevel},children:_.getVisibleCells().map(E=>{const D=E.column.id;if(D.startsWith("rowLevel")){const F=parseInt(D.replace("rowLevel",""));if(k.isSubtotal&&k.subtotalLevel){const L=K_(t.groupByColumns,k.subtotalLevel);return F===L?l.jsx(qn,{colSpan:s?1:b-F,...Cd({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!I&&"border-b border-b-border/35")}),children:gi(E.column.columnDef.cell,E.getContext())},E.id):F<L?l.jsx(qn,{...Cd({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!I&&"border-b border-b-border/35")}),children:gi(E.column.columnDef.cell,E.getContext())},E.id):s?l.jsx(qn,{...Cd({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!I&&"border-b border-b-border/35")})},E.id):null}if(!i&&!s&&j>0)for(let L=j-1;L>=0;L--){const $=T[L].original;if($.isSubtotal||$.isGrandTotal)break;let H=!0;for(let M=0;M<=F;M++)if(ws(k,M)!==ws($,M)){H=!1;break}if(H)return null}let z=1;if(!i&&!s)for(let L=j+1;L<T.length;L++){const $=T[L].original;if($.isSubtotal||$.isGrandTotal)break;let H=!0;for(let M=0;M<=F;M++)if(ws(k,M)!==ws($,M)){H=!1;break}if(H)z++;else break}return l.jsx(qn,{rowSpan:i?void 0:z,...zh({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!I&&"border-b border-b-border/35")}),children:gi(E.column.columnDef.cell,E.getContext())},E.id)}const R=o.has(D),A=r.has(D);return l.jsx(qn,{"data-column-id":D,...k.isSubtotal?Cd({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!I&&"border-b border-b-border/35",R?"bg-muted/50":A?"bg-muted/30":void 0)}):zh({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!I&&"border-b border-b-border/35",R?"bg-muted/50":A?"bg-muted/30":void 0)}),children:gi(E.column.columnDef.cell,E.getContext())},E.id)})},_.id)}),i&&u>0&&l.jsx(Ar,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(qn,{colSpan:w,style:{height:u,padding:0,border:"none"}})})]}):h?null:l.jsx(Ar,{className:"h-8",children:l.jsx(qn,{colSpan:n.length,className:"text-center",children:"No results."})})}function cet({grandTotalRows:e,data:t,card:n,table:r,showRowTotals:o,columnSettings:s,isSqlCard:i=!1,contextTimezone:a,browserTimezone:c,onAggregationLabelChange:u,tableAppearance:d,valueFormatPreferences:f,resolveBoundCurrency:h}){return e.length===0?null:l.jsx(l.Fragment,{children:e.map((m,g)=>{var b;return l.jsxs(Ar,{style:d.grandTotalRowStyle,className:"h-8 border-border/40 font-semibold","data-row-type":"grandtotal","data-grandtotal":"true","data-grandtotal-index":g,children:[l.jsx(qn,{colSpan:((b=t.groupByColumns)==null?void 0:b.length)||1,...Gc({tableAppearance:d,overflow:"visible",className:"border-r border-t-2 border-border/40 border-t-border/60 px-4 font-semibold text-foreground/90"}),children:u?l.jsx(xi,{value:(()=>{var w,C,N;const x=m.aggregateFunction||"SUM";return((N=(C=(w=n.config)==null?void 0:w.rowAggregates)==null?void 0:C.find(S=>S.function===x&&S.groupLevel==="ALL"))==null?void 0:N.label)||m.fieldValues[0]})(),placeholder:m.fieldValues[0],onSave:x=>{const y=m.aggregateFunction||"SUM";u({type:"row",level:"ALL",function:y,label:x})},displayClassName:"text-right"}):m.fieldValues[0]}),t.columnHeaders.map(x=>{var j,_,k,T,I,E;const y=(_=(j=t.columnMetadata)==null?void 0:j[x])==null?void 0:_.metricId,w=ec({card:n,columnKey:x,metricId:y}),C=Bi({card:n,columnId:x,resolvedSettings:s==null?void 0:s[x],metricId:y,metricAlias:(T=(k=t.columnMetadata)==null?void 0:k[x])==null?void 0:T.metricAlias,valueFormatPreferences:f,boundCurrency:w?h(w):void 0}),N=(I=r.getHeaderGroups()[0])==null?void 0:I.headers.find(D=>D.column.id===x),S=Gc({tableAppearance:d,style:{width:N==null?void 0:N.getSize(),minWidth:N==null?void 0:N.getSize(),maxWidth:N==null?void 0:N.getSize(),transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(qn,{"data-column-id":x,className:S.className,style:S.style,children:Lj((E=m.cells[x])==null?void 0:E.value,C,a,c,i)},x)}),o&&(()=>{var N;const x=dL({card:n,columnHeaders:t.columnHeaders,columnMetadata:t.columnMetadata,columnSettings:s,valueFormatPreferences:f,resolveBoundCurrency:h}),y=(N=r.getHeaderGroups()[0])==null?void 0:N.headers.find(S=>S.column.id==="rowTotal"),w=y==null?void 0:y.getSize(),C=Gc({tableAppearance:d,style:{width:w,minWidth:w,maxWidth:w,transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(qn,{className:C.className,"data-column-id":"rowTotal",style:C.style,children:Lj(jte(m,t.columnHeaders),x,a,c,i)})})()]},m.id)})})}function uet({groupByColumns:e,numRowLevels:t,onAggregationLabelChange:n,isTablePrintDisplayMode:r=!1,isCellWrapping:o=!1,cellContentClassName:s,onCellClick:i}){const a=[];return e&&e.length>0?e.forEach((c,u)=>{a.push({id:`rowLevel${u}`,header:()=>l.jsx("div",{className:"group px-3 py-1 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:l.jsx("div",{className:"flex items-center gap-1",children:l.jsx("span",{className:"whitespace-nowrap",children:c.label||c.name})})}),accessorFn:d=>d.fieldValues[u],cell:({row:d,table:f})=>{const h=d.original;if(h.isSubtotal&&h.subtotalLevel){const x=K_(e,h.subtotalLevel);if(u===x){const y=h.fieldValues[u];return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),style:{gridColumn:`span ${t-u}`},children:y.includes(" Total")&&n?l.jsx(xi,{value:y,placeholder:y,onSave:w=>{const C=h.aggregateFunction||"SUM";if(h.subtotalLevel&&e){const N=P3e(e,h.subtotalLevel);N&&n({type:"row",level:N.id,function:C,label:w})}},displayClassName:"text-left"}):y})}else if(u<x)return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),children:h.fieldValues[u]});return r?l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s)}):null}const m=f.getRowModel().rows,g=m.findIndex(x=>x.id===d.id);if(!r&&g>0)for(let x=g-1;x>=0;x--){const y=m[x].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(ws(h,C)!==ws(y,C)){w=!1;break}if(w)return null}let b=1;if(!r)for(let x=g+1;x<m.length;x++){const y=m[x].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(ws(h,C)!==ws(y,C)){w=!1;break}if(w)b++;else break}return l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s),onClick:i&&!h.isGrandTotal?x=>i(x,h,`rowLevel${u}`):void 0,style:{gridRow:r?void 0:`span ${b}`},children:h.fieldValues[u]})}})}):a.push({id:"rowHeader",header:()=>l.jsx("div",{className:"px-3 py-1 text-left font-medium",children:"Row"}),accessorFn:c=>c.rowKey,cell:({getValue:c})=>l.jsx("div",{className:p.cn("min-w-[150px] max-w-[300px] border-x border-y border-border px-3 py-1",s),children:String(c())})}),a}function det({columnHeaders:e,columnDisplayNames:t,setSorting:n,columnSettings:r,card:o,columnMetadata:s,contextTimezone:i,browserTimezone:a,isSqlCard:c=!1,suppressSortControls:u=!1,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:h}){return e.map(m=>({id:m,accessorFn:g=>{var b;return(b=g.cells[m])==null?void 0:b.value},header:({column:g})=>{const b=(t==null?void 0:t[m])||m;return l.jsx("div",{className:"flex w-full items-center justify-end",children:u?l.jsx("span",{className:"text-sm font-medium",children:b}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const x=g.getIsSorted();n(x?x==="asc"?[{id:g.id,desc:!0}]:[]:[{id:g.id,desc:!1}])},"aria-label":`Sort ${b}`,children:[l.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:b}),g.getIsSorted()==="asc"?l.jsx(bs,{className:"h-3 w-3"}):g.getIsSorted()==="desc"?l.jsx(es,{className:"h-3 w-3"}):null]})})},cell:({getValue:g,row:b})=>{var S,j,_;const x=g(),y=o?ec({card:o,columnKey:m,metricId:(S=s==null?void 0:s[m])==null?void 0:S.metricId}):void 0,w=Bi({card:o,columnId:m,resolvedSettings:r==null?void 0:r[m],metricId:(j=s==null?void 0:s[m])==null?void 0:j.metricId,metricAlias:(_=s==null?void 0:s[m])==null?void 0:_.metricAlias,valueFormatPreferences:d,boundCurrency:y?f(y):void 0}),C=(w==null?void 0:w.textAlign)||"right",N=C==="left"?"text-left":C==="center"?"text-center":"text-right";return l.jsx("div",{className:N,onClick:h?k=>h(k,b.original,m):void 0,children:Lj(x,w,i,a,c)})}}))}function fet({columnHeaders:e,setSorting:t,suppressSortControls:n=!1,settings:r}){return{id:"rowTotal",header:({column:o})=>l.jsx("div",{className:"flex w-full items-center justify-end",children:n?l.jsx("span",{className:"text-sm font-medium",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const s=o.getIsSorted();t(s?s==="asc"?[{id:o.id,desc:!0}]:[]:[{id:o.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:"text-sm font-medium",children:"Total"}),o.getIsSorted()==="asc"?l.jsx(bs,{className:"h-3 w-3"}):o.getIsSorted()==="desc"?l.jsx(es,{className:"h-3 w-3"}):null]})}),cell:({row:o})=>{const s=o.original,i=jte(s,e);return l.jsx("div",{className:"text-right text-sm font-medium",children:Lj(i,r)})}}}function cU(e){const t=it.resolveGroupedTemporalFieldPresentationByRole({presentation:e.presentation,fieldId:e.field.id,role:e.field.role});return e.value===null?{field:e.field,operator:"isNull",value:null,...t?{label:"(Blank)",temporalBucket:t.metadata}:{}}:{field:e.field,operator:"=",value:e.value,...t?{label:it.formatGroupedTemporalFieldValue({fieldId:e.field.id,role:e.field.role,value:e.value,presentation:e.presentation}),temporalBucket:t.metadata}:{}}}function het(e){var m,g,b;if(e.row.isSubtotal||e.row.isGrandTotal||!e.card.config)return;const t=e.card.config,n=e.row.canonicalFieldValues||e.row.fieldValues,r=(t.groupByColumns||[]).map((x,y)=>cU({field:x,value:n[y]??null,presentation:e.temporalPresentation})),o=(m=e.resultColumns)==null?void 0:m.find(x=>x.key===e.columnKey);if((((g=o==null?void 0:o.pivotIdentity)==null?void 0:g.members)??[]).forEach(x=>{const y=(t.pivotByColumns||[]).find(w=>w.id===x.fieldId);y&&r.push(cU({field:y,value:x.value,presentation:e.temporalPresentation}))}),r.length===0)return;const i=o==null?void 0:o.pivotIdentity,a=t.metricColumns||[],c=i?a.find(x=>$r.resolveMetricResultAlias(x)===i.metricAlias):void 0,u=i?a.filter(x=>x.id===i.metricId):[],d=c||(u.length===1?u[0]:void 0),f=(b=e.row.cells[e.columnKey])==null?void 0:b.value,h=d&&typeof f=="number"?[{field:d,value:f}]:[];return{conditions:r,...h.length?{metrics:h}:{}}}function Wb({data:e,card:t,options:n={},onAggregationChange:r,onAggregationLabelChange:o,suppressSortControls:s=!1,renderPlainWrapper:i=!1,frameId:a,sheetId:c,onMultipleInteractions:u}){var ee,J,re,pe,Ee;const{preferences:d,resolveBoundCurrency:f}=Ta(t,e.columnHeaders),{displayPreferences:h,shouldShowElement:m}=cl(),g=v.useRef(null),b=v.useMemo(()=>f3(),[]),{updatePageSize:x}=p.useEditorActions(),y=v.useMemo(()=>typeof document<"u"&&"onscrollend"in document,[]),w=!!(t!=null&&t.sql),C=typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0,N=void 0,S=v.useMemo(()=>p.getInteractions(t.interactionConfig).some(p.isInteractionConfiguredForExecution),[t.interactionConfig]),{handlePointerInteraction:j}=p.useEventEngine(t,a||"",c||"",u),_=v.useCallback((Te,ze,Pe)=>{if(!S||!a||!c)return;const He=het({card:t,row:ze,columnKey:Pe,resultColumns:e.resultColumns,temporalPresentation:e.temporalPresentation});He&&(Te.stopPropagation(),j({context:He,gesture:"leftClick",modifierKeys:{shift:Te.shiftKey,ctrl:Te.ctrlKey,meta:Te.metaKey},position:{x:Te.clientX,y:Te.clientY}}))},[t,e.resultColumns,e.temporalPresentation,a,j,S,c]),k=n.showRowTotals??!1,{columnSizing:T,onColumnSizingChange:I}=d3({card:t}),{subtotalColumnKeys:E,grandTotalColumnKeys:D}=v.useMemo(()=>VEe(e.columnSubtotalMeta),[e.columnSubtotalMeta]),{tableData:R,grandTotalRows:A}=v.useMemo(()=>uL(e),[e]),{sorting:F,setSorting:z,sortedTableData:L}=net(R,e),{columnSettings:$,columnSettingsOpen:H,activeColumnId:M,tempColumnSettings:B,isVisualEditing:W,openColumnSettings:P,applyColumnSettings:G,resetColumnSettings:Z,resetAllColumnSettings:X,setColumnSettingsOpen:Y,setTempColumnSettings:O}=iet(t,L,e.columnMetadata),q=m3({displayMode:h.mode,isVisualEditing:W,printBehavior:"any-print",renderPlainWrapper:i}),U=q.isPrint,V=dI("pivotTable",(J=(ee=t==null?void 0:t.preferences)==null?void 0:ee.tablePrefs)==null?void 0:J.density,q.mode==="document-print"?"document":"appearance"),K={...n.pagination},Q=XJe(K,L.length),se=v.useMemo(()=>{var ye;const Te=[],ze=((ye=e.groupByColumns)==null?void 0:ye.length)||1,Pe=uet({groupByColumns:e.groupByColumns,numRowLevels:ze,onAggregationLabelChange:o,isTablePrintDisplayMode:U,isCellWrapping:V.isCellWrapping,cellContentClassName:V.cellContentClassName,onCellClick:_});Te.push(...Pe);const He=det({columnHeaders:e.columnHeaders,columnDisplayNames:e.columnDisplayNames,setSorting:z,suppressSortControls:s,columnSettings:$,card:t,columnMetadata:e.columnMetadata,contextTimezone:N,browserTimezone:C,isSqlCard:w,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:_});if(Te.push(...He),k){const Ke=fet({columnHeaders:e.columnHeaders,setSorting:z,suppressSortControls:s,settings:dL({card:t,columnHeaders:e.columnHeaders,columnMetadata:e.columnMetadata,columnSettings:$,valueFormatPreferences:d,resolveBoundCurrency:f})});Te.push(Ke)}return Te},[t,e,k,o,z,s,U,$,N,C,w,V.cellContentClassName,V.isCellWrapping,d,f,_]),oe=nI({data:L,columns:se,state:{sorting:F,columnSizing:T,pagination:{pageIndex:Q.pageIndex,pageSize:Q.pageSize}},onSortingChange:z,onPaginationChange:void 0,getCoreRowModel:eI(),getPaginationRowModel:!Q.isServerSidePagination&&q.allowPagination?tI():void 0,manualPagination:Q.isServerSidePagination||!q.allowPagination,manualSorting:!0,pageCount:Q.pageCount,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:I}),me=oe.getRowModel().rows,ue=q.allowVirtualization&&me.length>75,ne=ue&&(!b||V.isCellWrapping),de=uI({count:ue?me.length:0,getScrollElement:()=>g.current,estimateSize:()=>V.dataRowHeight??32,overscan:b?5:10,useScrollendEvent:b&&y,isScrollingResetDelay:b?240:150}),Ce=ue?de.getVirtualItems():[],ce=ue&&Ce.length>0?Ce[0].start:0,ie=ue&&Ce.length>0?de.getTotalSize()-Ce[Ce.length-1].end:0,{buildColumnHeaderRows:we}=set({data:e,card:t,table:oe,sorting:F,setSorting:z,showRowTotals:k,onAggregationChange:r,onOpenColumnSettings:P,suppressSortControls:s,tableAppearance:V}),fe=we(),ae=l.jsxs("table",{className:"w-full border-separate border-spacing-0 text-sm [border-spacing:0]",onMouseDown:Te=>Te.stopPropagation(),"data-pivot-table":"true","data-row-levels":((re=e.groupByColumns)==null?void 0:re.length)||1,"data-pivot-levels":e.columnGroups&&((Ee=(pe=t.config)==null?void 0:pe.pivotByColumns)==null?void 0:Ee.length)||0,children:[l.jsx(Zm,{style:V.headerStyle,className:p.cn("bg-muted/95 [&_tr]:border-b-0",q.allowStickyHeader&&V.isHeaderSticky&&"sticky top-0 z-20 supports-[backdrop-filter]:bg-muted/80 supports-[backdrop-filter]:backdrop-blur-sm"),children:fe}),l.jsx(Gd,{children:l.jsx(aet,{table:oe,data:e,columns:se,subtotalColumnKeys:E,grandTotalColumnKeys:D,isTablePrintDisplayMode:U,shouldVirtualizeRows:ue,virtualRows:Ce,paddingTop:ce,paddingBottom:ie,measureElement:ne?de.measureElement:void 0,disableRowTransitions:b,suppressEmptyState:A.length>0,tableAppearance:V})}),A.length>0&&l.jsx("tfoot",{className:p.cn("border-t border-t-border/60 bg-muted/95",q.allowStickyHeader&&"sticky bottom-0 z-10"),"data-grandtotal":"true",style:V.grandTotalRowStyle,children:l.jsx(cet,{grandTotalRows:A,data:e,card:t,table:oe,showRowTotals:k,columnSettings:$,isSqlCard:w,contextTimezone:N,browserTimezone:C,onAggregationLabelChange:o,tableAppearance:V,valueFormatPreferences:d,resolveBoundCurrency:f})})]});return l.jsxs("div",{className:"flex h-full w-full flex-col gap-2",children:[q.usePlainWrapper?l.jsx("div",{ref:g,style:V.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:Te=>Te.stopPropagation(),children:ae}):l.jsxs(hl,{ref:g,style:V.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:Te=>Te.stopPropagation(),children:[ae,l.jsx(p.ScrollBar,{orientation:"horizontal",className:"z-20"})]}),q.allowPagination&&Q.showPagination&&l.jsx(rI,{totalColumns:se.length,pageCount:Q.pageCount||oe.getPageCount(),pageIndex:Q.pageIndex,pageSize:Q.pageSize,rowCount:Q.totalCount,selectedRowCount:0,setPageIndex:Q.setPageIndex,setPageSize:Q.setPageSize,canPreviousPage:Q.canPreviousPage,canNextPage:Q.canNextPage,previousPage:Q.previousPage,nextPage:Q.nextPage,onPageSizePreferenceChange:q.showEditorControls?x:void 0,onClearSelection:()=>{},appearance:V.pagination}),M&&l.jsx(l3,{column:oe.getColumn(M)||null,settings:B,onSettingsChange:O,onApply:G,onReset:Z,onResetAll:X,open:H,onOpenChange:Y,tableType:"pivot",isSqlCard:w})]})}const met=420,pet=360,get="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js";function bet(e){return`<!DOCTYPE html>
962
962
  <html lang="en">
963
963
  <head>
964
964
  <meta charset="utf-8" />
@@ -1389,4 +1389,4 @@ Defaulting to \`null\`.`}var Dbe=_be,sjt=Tbe;const L4=te.forwardRef(({className:
1389
1389
  More info: ${o.docs}`:"",a=typeof o.message=="string"&&o.message.trim()?o.message.trim():typeof o.error=="string"&&o.error.trim()?o.error.trim():null;if(a){const c=s?` (code: ${s})`:"",u=s==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1390
1390
 
1391
1391
  Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${c}${i}${u}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const o=JSON.parse(r),s=t(o);if(s)return s}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function q4({errorMessage:e}){return l.jsxs("div",{className:"flex items-start gap-2 rounded-control border border-red-300 bg-red-50/60 p-2 text-[12px] text-red-700 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-300",children:[l.jsx(Zs,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"whitespace-pre-wrap break-words leading-[1.55]",children:Ckt(e)})]})}function Skt({error:e,resetErrorBoundary:t}){return l.jsxs("div",{className:"my-3 space-y-2 rounded-control border border-border/60 bg-muted/20 p-2.5",children:[l.jsx(q4,{errorMessage:e==null?void 0:e.message}),l.jsx("button",{type:"button",className:"text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:t,children:"Try again"})]})}function Nkt({text:e,files:t}){return l.jsxs(exe,{who:"You",children:[e&&l.jsx("div",{className:"whitespace-pre-line text-[13px] leading-[1.55] text-foreground",children:e}),t&&t.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 pt-0.5",children:t.map(n=>l.jsx(ajt,{file:n},n.id))})]})}function jkt({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",o=JSON.parse(r);return l.jsxs("div",{className:"space-y-1 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),l.jsx(_jt,{children:JSON.stringify(o,null,2)})]})]})}function txe(e,t){return!e||e.role!=="assistant"?!1:(e.parts??[]).some(r=>{if(!r)return!1;switch(r.type){case"text":return typeof r.text=="string"&&r.text.trim().length>0;case"reasoning":return typeof r.text=="string"&&r.text.trim().length>0||r.state==="streaming";case"error":return!0;default:return typeof r.type=="string"&&(r.type.startsWith("tool-")||r.type==="dynamic-tool")?H4(r,t):!1}})}function FG(){return l.jsx("span",{className:"relative grid h-2 w-2 shrink-0 place-items-center",children:l.jsx("span",{className:"absolute inset-0 animate-pulse rounded-full bg-muted-foreground/70"})})}function kkt({status:e,errorMessage:t,activeToolText:n}){return n?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(FG,{}),l.jsx("span",{children:n})]}):e==="submitted"||e==="streaming"?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(FG,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(q4,{errorMessage:t}):null}function _kt(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(o=>o.type==="text"&&typeof o.text=="string"&&o.text.trim().length>0))}))==null?void 0:t.id:void 0}function Ikt({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:o,showSystemMessage:s=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,w,C,N;const u=_kt(n),d=e.id===u;if(e.role==="user"){const S=((y=e.parts)==null?void 0:y.filter(T=>T.type==="text"))||[],j=((w=e.parts)==null?void 0:w.filter(T=>T.type==="file"))||[],_=S.map(T=>T.text).join(`
1392
- `).trim(),k=j.map((T,I)=>{var R,A;let E="",D;if((R=T.url)!=null&&R.startsWith("data:")){const F=T.url.match(/data:[^;]+;base64,(.+)/);F&&(E=F[1],(A=T.mediaType)!=null&&A.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${I}`,name:T.filename||`File ${I+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(Nkt,{text:_||void 0,files:k.length>0?k:void 0})}const f=((C=e.parts)==null?void 0:C.filter(S=>S.type==="reasoning"))||[],h=f.length>0,m=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),b=h&&(g.length>0||m)?l.jsxs(vu,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(wu,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Ft.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:m?"animate-pulse":"",children:m?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(Cu,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:j+1}),l.jsx(IG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,x=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const _=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:I,quickReplies:E}=vkt(T),D=I.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(IG,{text:I,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:R,value:A},F)=>l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(A),children:l.jsx("span",{className:"truncate",children:R})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:A})})]},`${_}-qr-${F}`))})]})]},_)}return e.role==="system"&&s?l.jsx(jkt,{text:T},_):null}case"error":{const T=S,I=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(q4,{errorMessage:I})},_)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&H4(S,r)?l.jsx(Si,{FallbackComponent:({error:T,resetErrorBoundary:I})=>l.jsx(Skt,{error:T,resetErrorBoundary:I}),children:l.jsx(pkt,{part:S,idx:_,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},_):null}});return e.role==="assistant"?txe(e,r)?l.jsxs(exe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const Tkt=8,Ekt=24,Dkt=20;function Mkt(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function nxe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:m,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),w=v.useRef(!1),C=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,_]=v.useState(!0),[k,T]=v.useState(0),[I,E]=v.useState(Ekt);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],R=txe(D,t),A=Mkt(a,c,u,R),F=uI({count:e.length,getScrollElement:()=>b.current,estimateSize:H=>{const M=e[H];return(M==null?void 0:M.role)==="user"?88:180},getItemKey:H=>{const M=e[H];return(M==null?void 0:M.id)||`message-${H}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:Tkt,overscan:6,gap:20,paddingEnd:A?I+Dkt:0,useAnimationFrameWithResizeObserver:!0,onChange:H=>{const M=H.isAtEnd();_(B=>B===M?B:M),M&&T(0)}}),z=v.useCallback((H="smooth")=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null,F.scrollToEnd({behavior:H})}),T(0),_(!0)},[F]);v.useLayoutEffect(()=>{w.current||(w.current=!0,z("auto"))},[z]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,z("auto"))},[e.length,g,z]),v.useEffect(()=>{const H=y.current;y.current=e.length,e.length>H&&!F.isAtEnd()&&T(M=>M+e.length-H),e.length===0&&(T(0),_(!0),w.current=!1,N.current=!1)},[e.length,F]);const L=F.getVirtualItems(),$=F.getTotalSize();return v.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]),v.useLayoutEffect(()=>{const H=x.current;if(!H||!A)return;const M=()=>{const W=Math.ceil(H.getBoundingClientRect().height);W>0&&E(P=>P===W?P:W)};if(M(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(M);return B.observe(H),()=>B.disconnect()},[A,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(hl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:p.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:$},children:[L.map(H=>{const M=e[H.index];return M?l.jsx("div",{ref:F.measureElement,"data-index":H.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${H.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(Ikt,{message:M,messageIndex:H.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},H.key):null}),A&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max($-I,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(kkt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>z("smooth"),"aria-label":"Scroll to latest",className:p.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",m),children:[l.jsx(es,{className:"h-3 w-3"}),"Latest",k>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:k>9?"9+":k})]})]})}function Rkt(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const Akt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function Pkt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(dt.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[m,g]=v.useState(!1),[b,x]=v.useState(!1),[y,w]=v.useState(0),C=n??b,{isLocalDev:N,isConsoleMode:S}=Lm(),j=N||S||a,_=v.useRef(null);p.useDashboardStore(re=>re.dashboard.aiScopeTables),p.useDashboardStore(re=>re.isDashboardEditing);const k=p.useDashboardStore(re=>re.selectedSheetId),{setDataSource:T}=p.useEditorActions(),{setSelectedFrameId:I,setIsDashboardEditing:E}=p.useDashboardActions(),D=Q$(),{clearAssistantMessageContexts:R}=p.useAIActions(),{clearQueue:A}=p.useQueueActions(),{clearFileAttachments:F,getFileAttachments:z}=p.useFileActions(),L=p.useFileAttachments("dashboard"),$=p.useEditorStore(re=>re.card.dataSource),{assistantProfile:H}=vbe(),M=p.useDashboardStore(re=>re.handleOpenAssistantProfile),{selectedEntities:B,applyDashboardDefaultEntities:W}=eT("dashboard"),{sendMessage:P,isLoading:G,messages:Z,setMessages:X,status:Y,stop:O,errorMessage:q,clearError:U}=zNt({dynamicVisualMode:f}),V=v.useCallback(()=>{w(re=>re+1)},[]),K=v.useCallback(re=>{r==null||r(re),n===void 0&&x(re)},[n,r]),Q=v.useCallback(()=>{K(!C)},[C,K]);v.useEffect(()=>{if(!C)return;function re(pe){pe.key==="Escape"&&K(!1)}return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re)}},[C,K]);const[se,oe]=v.useState(""),me=re=>{oe(re.target.value)};async function le({sql:re,cardTitle:pe,connectionId:Ee,cardType:Te,python:ze,cardConfig:Pe,dataSource:He,customVisualPreferences:ye,visualizationMode:Ke,dynamicCardPreferences:We}){if(!k)return;const Qe=Ke==="dynamic",xe=dt.hasValidCardConfig(Pe),Ve=Ee||(He==null?void 0:He.connectionId)||"",Ae=He?{...He,connectionId:Ve||He.connectionId,connectionType:He.connectionType||"",mode:He.mode||"database",selectedEntities:He.selectedEntities||[]}:Ve?{connectionId:Ve,connectionType:"",mode:"database",selectedEntities:[]}:sb,Be=!(xe&&(!Qe||(We==null?void 0:We.provenance)==="card-config"||(We==null?void 0:We.provenance)==="query_spec")),Ie=Be?Rkt(re):"",$e=Be?ze:"",st={id:dt.v4(),title:pe||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Te==="horizontalBar"?"y":"x"},...Qe&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Te,sql:Ie,python:$e,dataSource:Ae,config:Pe,connectionId:Ve,visualizationMode:Ke,dynamicCardPreferences:We,customCardPreferences:ye?{url:ye.url,componentName:ye.componentName,pluginChartType:ye.pluginChartType,settings:ye.settings,type:"component"}:void 0},ct={id:dt.v4(),cards:[st],activeCardId:st.id};try{await D(k,ct,"end"),E(!0),I(ct.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),lt.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const ue=re=>{re.preventDefault();const pe=se.trim();if(!pe&&L.length===0)return;const Ee=[];pe&&Ee.push({type:"text",text:pe}),L.forEach(Te=>{Te.data&&Ee.push({type:"file",mediaType:Te.type,filename:Te.name,url:`data:${Te.type};base64,${Te.data}`})}),P({role:"user",parts:Ee}),oe(""),F("dashboard"),V()};v.useEffect(()=>{var re;e&&((re=_.current)==null||re.focus())},[e]),Obe({assistantType:"dashboard",status:Y,isLoading:G,sendMessage:P});const{hasActiveTools:ne,activeToolText:de}=Lbe(Z);function Ce(re){const pe={role:"user",parts:[{type:"text",text:re.title+" "+re.subtitle}]};P(pe),V()}function ce(re){P({role:"user",parts:[{type:"text",text:re}]}),V()}function ie(re){P({role:"user",parts:[{type:"text",text:re}]}),V()}const we=v.useCallback(async()=>{const re=JSON.stringify(Z??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(re),lt.success("Conversation copied")}catch(pe){console.error("Failed to copy conversation",pe),lt.error("Unable to copy conversation")}},[Z]),fe=(se==null?void 0:se.length)===0&&(Z==null?void 0:Z.filter(re=>re.role==="user").length)===0;function ae(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ee(){return l.jsxs(Uo,{children:[l.jsx(Wo,{asChild:!0,children:l.jsx(nu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Rm,{className:"size-3.5"})})}),l.jsxs(Do,{align:"end",children:[l.jsx(qa,{children:"Options"}),l.jsx(Sa,{}),l.jsx(nd,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(nd,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(nd,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Sa,{}),l.jsx(qa,{children:"Dynamic Visuals"}),l.jsx(nd,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(nd,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(nd,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const J=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",C&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[ae(),M&&l.jsxs("button",{type:"button",onClick:M,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(H==null?void 0:H.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[S&&ee(),j&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:we,children:"Copy Conversation"}),l.jsx(nu,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:C?"Exit fullscreen":"Expand",onClick:Q,children:C?l.jsx(Ft.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(nu,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const re=Z.filter(pe=>pe.role==="assistant").map(pe=>pe.id).filter(pe=>!!pe);X([]),A("dashboard"),U(),R(re)},children:l.jsx(DO,{className:"h-3.5 w-3.5"})}),l.jsx(nu,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(je.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(nxe,{messages:Z,showTools:a,showSystemMessage:u,onAddToDashboard:le,onQuickReply:ie,disableQuickReplies:G,status:Y,errorMessage:q,activeToolText:G&&ne?de:void 0,className:p.cn(C?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(C&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!H&&fe&&l.jsx(Xpe,{onClick:Ce,placeholders:Akt}),fe&&H&&l.jsx(wbe,{seedQuestions:H.seedQuestions||[],handleSeedQuestionClick:ce}),l.jsx(Fbe,{assistantType:"dashboard"}),l.jsx(V4,{ref:_,setInput:oe,stop:O,input:se,handleInputChange:me,handleSubmit:re=>{ue(re)},isLoading:G,status:Y,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(B4,{incomingSelectedEntities:B,open:m,onOpenChange:g,dataSource:$||sb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:re=>W()})]});return C&&o?br.createPortal(l.jsx(Kb,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:J})}),o):J}function Fkt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=_ue(),s=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=p.useDashboardStore(d=>d.isDashboardEditing),u=p.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(m){if(Okt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),lt.success("Card copied to clipboard"),m.preventDefault()):g&&m.key==="v"&&(await h(),m.preventDefault())}async function f(){try{const m=n();m&&await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy text:",m)}}async function h(){if(!a)return null;try{const m=await navigator.clipboard.readText(),g=Lkt(m);if(g!=null&&g.id){const b=Nue(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),lt.success("Card pasted from clipboard")}return m}catch(m){return console.error("Failed to paste text:",m),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function Okt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function Lkt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function $kt(e,t){switch(e.interactionMode){case"drillToDetail":zkt(e,t);break;case"drillThrough":Bkt(e,t);break;case"drillToURL":Vkt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function zkt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function Bkt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function Vkt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function Hkt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(Mo,{open:e,onOpenChange:t,children:l.jsxs(go,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Is,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(bo,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Ro,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(Mue,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(Bfe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function qkt(){const e=p.useInteractionStore(N=>N.interactionStates),t=p.useInteractionStore(N=>N.setInteractionState),n=p.useInteractionStore(N=>N.clearLastInteractionEvent),r=p.useInteractionStore(N=>N.replaceCardWithInsight),o=p.useInteractionStore(N=>N.setPendingDrillThrough),s=p.useInteractionStore(N=>N.pendingDrillThrough),i=p.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Dm(),d=p.useDashboardStore(N=>N.dashboard),f=p.useDashboardStore(N=>N.filterValues),{data:h,isLoading:m}=UX((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=Vfe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),w=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{b({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:_})=>{r(N,S,j,_)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:_,targetDashboardId:k})=>{const T={filters:N},I={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...p.createInitialInteractionState(),appliedClickFilters:[I],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:_,targetDashboardId:k};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,_=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(_))return;y.current.add(_);try{$kt(j,w)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(_)},5e3)}}})},[e,n,w]),v.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,m,u,c,i]);const C=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(Hkt,{open:g.open,onOpenChange:C,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&m&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(p.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function Ukt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=Wkt(ez(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function Wkt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function Kkt(e){return e?`Back to ${e}`:"Back"}function Gkt(){var y,w,C,N,S;const e=p.useInteractionStore(j=>j.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(j=>j.actions.goBackFromDrill),n=p.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Dm(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},_=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(C=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:C[0])==null?void 0:N.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((S=e.appliedClickFilters)!=null&&S.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},b=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};Ukt(f);const x=Kkt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((j,_)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(mi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},_)})})]}),l.jsx(p.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(je.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(p.Button,{variant:"secondary",size:"sm",onClick:m,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(zv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function Ykt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function Zkt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:m,transition:g,isDragging:b}=tx({id:`filter:${e.id}`,disabled:n||!t}),x={transform:Ki.Translate.toString(m),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(P$,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const OG="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Xkt=[];function rxe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(X=>{var Y;return(Y=X.dashboard)==null?void 0:Y.sheets}),u=p.useDashboardStore(X=>X.dashboard),d=p.useDashboardStore(X=>X.dashboardInputValues),f=p.useDashboardStore(X=>X.filterValues),h=p.useDashboardStore(X=>X.controlValues),m=p.useDashboardStore(X=>X.inlineFilterValuesMap),g=p.useDashboardStore(X=>X.cardControlValuesMap),b=p.useDashboardStore(X=>X.selectedSheetId),x=p.useDashboardStore(X=>X.selectedSheetId?X.documentInputRuntimeBySheetId[X.selectedSheetId]:void 0),y=p.useDashboardStore(X=>X.isDownloadingPdf),w=p.useDashboardStore(X=>X.reportContext),{authToken:C,tokenProps:N}=It(),S=c==null?void 0:c.find(X=>X.id===b),j=v.useMemo(()=>p.getDashboardExportSheets(c),[c]),_=p.isDocumentSheet(S),k=_&&S?S.document:void 0,T=v.useMemo(()=>_&&S?rx(u,S.id):[],[S,_,u]),I=T.length>0,E=v.useMemo(()=>_&&S?kpe(u,S.id):!1,[S,_,u]),D=v.useMemo(()=>I?T.map(lC):(k==null?void 0:k.inputs)||Xkt,[k,T,I]),R=w==null?void 0:w.calendar.tz,A=v.useMemo(()=>Nme(D),[D]),F=v.useMemo(()=>Cme(D,R),[D,R]),z=v.useMemo(()=>Sme(D),[D]),L=x?x.filterValuesByInputId:F,$=x?x.controlValuesByInputId:z,H=v.useMemo(()=>_?E&&S&&k?YY({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(X=>X.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:R}):_me(D,L,$,A,A):[],[k,D,S,_,u,g,h,f,m,d,$,L,A,R,E]),M=!!S,B=j.length>0,W=((c==null?void 0:c.length)||0)>1||_,P=i.sheetSelection==="current"&&(!M||_&&H.length>0)||i.sheetSelection==="all"&&!B;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!B&&a(X=>({...X,sheetSelection:"current"}))},[B,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function Z(){if(y){lt.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){lt.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!M){lt.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!B){lt.error("No dashboard sheets are available to export");return}s(!0);const X=i.sheetSelection==="current"&&_,Y=X?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",O=lt.loading(Y);try{if(X){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(H.length>0){lt.dismiss(O),lt.error(`Set ${H.join(", ")} before exporting`);return}const U=new Date().toISOString(),V=E?ZY({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(K=>K.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:U,timezone:R}).snapshot:void 0;await Q5(N.apiServiceUrl,C,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:R,password:i.protectPdf?i.password:void 0,inputSnapshot:V,...V?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:L,controlValuesByInputId:$,generatedAt:U}}})}else{const U=eoe();await Uee(N.apiServiceUrl,C,i.protectPdf?i.password:void 0,i.sheetSelection,U)}lt.dismiss(O);const q=X?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";lt.success(q,{duration:2e3}),G()}catch(q){lt.dismiss(O),lt.error("Failed to download PDF",{description:j_(q,"Please try again or contact support."),descriptionClassName:N_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",q)}finally{s(!1)}}return l.jsx(Mo,{open:e,onOpenChange:X=>{if(!X){G();return}t(!0)},children:l.jsxs(go,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Is,{children:[l.jsx(bo,{className:"text-[15px]",children:_?"Export document":"Export dashboard"}),l.jsx(Ro,{className:"text-[13px] leading-5",children:_?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[W&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:OG,children:"Export scope"}),l.jsxs(rl,{value:i.sheetSelection,onValueChange:X=>a({...i,sheetSelection:X}),className:"gap-1.5",children:[l.jsxs(p.Label,{htmlFor:"scope-current",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!M&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(vs,{value:"current",id:"scope-current",disabled:!M}),_?"This document":"This sheet"," (",(S==null?void 0:S.title)||"Current",")"]}),l.jsxs(p.Label,{htmlFor:"scope-all",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!B&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(vs,{value:"all",id:"scope-all",disabled:!B}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),_&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:H.length>0?`Set ${H.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(p.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(p.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(Tn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:X=>{a({...i,protectPdf:X,password:X?i.password:""}),X||r(!1)}}),l.jsx(Vv,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(p.Label,{htmlFor:"pdf-password",className:OG,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(p.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:X=>a({...i,password:X.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:X=>{X.key==="Enter"&&i.password&&Z()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(Ak,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(tl,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:Z,disabled:o||y||P,children:o?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Su,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function oxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(Su,{className:p.cn("size-4",e)})}),l.jsx(rxe,{open:i,onOpenChange:a})]})}function LG(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Qkt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=tx({id:`control:${e.id}`,disabled:!n}),d={transform:Ki.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(qme,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function $G(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function zG(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Jkt(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return zG(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=zG(t,n).filter(a=>!s.has(a));return[...o,...i]}function e_t(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function t_t(e){return Qh(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Qh(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function F2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function n_t(e){return sxe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function sxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=e_t(e.dashboard,t);return Rk(ab({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!t_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function r_t(e,t){return"toolbar"}function o_t(){const e=dc("interactive"),t=p.useDashboardStore(q=>q.selectedSheetId),n=p.useDashboardStore(q=>q.dashboard.filters),r=p.useDashboardStore(q=>q.dashboard.filterLayout),o=p.useDashboardStore(q=>q.isDashboardEditing),s=p.useDashboardStore(q=>q.controlValues),i=p.useDashboardStore(q=>q.filterValues);p.useDashboardStore(q=>q.filteringCards);const a=p.useDashboardStore(q=>q.inlineFilterValuesMap),c=p.useDashboardStore(q=>q.dashboardInputValues),u=p.useInteractionStore(q=>q.clearAllClickFilters),d=p.useInteractionStore(q=>Object.entries(q.interactionStates).reduce((U,[V,K])=>{var Q;return V===p.DRILL_CONTEXT_CARD_ID?U:U+(((Q=K.appliedClickFilters)==null?void 0:Q.length)??0)},0)),f=p.useDashboardStore(q=>q.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:C,upsertDashboardInput:N}=p.useDashboardActions(),S=oT(nb(Jb,{activationConstraint:{distance:5}})),j=p.useDashboardStore(q=>q.dashboard),_=n_t({dashboard:j,selectedSheetId:t}).filter(q=>r_t(q.filter)==="toolbar"),k=sxe({dashboard:j,selectedSheetId:t}),T=_.map(q=>q.filter),I=new Map(_.map(q=>[`filter:${q.filter.id}`,q])),E=stt(j),D=E.filter(q=>!q.hidden&&nv(q)==="toolbar"),R=E.filter(q=>!q.hidden&&nv(q)==="advanced"),A=Jkt(r==null?void 0:r.toolbarItemOrder,T,D),F=new Map(T.map(q=>[`filter:${q.id}`,q])),z=new Map(D.map(q=>[`control:${q.id}`,q]));function L(q){const{active:U,over:V}=q;if(!V||U.id===V.id)return;const K=String(U.id),Q=String(V.id),se=A.findIndex(ce=>ce===K),oe=A.findIndex(ce=>ce===Q);if(se===-1||oe===-1)return;const me=ex(A,se,oe);y({toolbarItemOrder:me});const le=new Set((n||[]).map(ce=>ce.id)),ue=A.filter(ce=>ce.startsWith("filter:")).map(ce=>ce.replace("filter:","")).filter(ce=>le.has(ce)),ne=me.filter(ce=>ce.startsWith("filter:")).map(ce=>ce.replace("filter:","")).filter(ce=>le.has(ce)),de=A.filter(ce=>ce.startsWith("control:")).map(ce=>ce.replace("control:","")),Ce=me.filter(ce=>ce.startsWith("control:")).map(ce=>ce.replace("control:",""));h(LG(n||[],ue,ne)),g(LG(j.controls||[],de,Ce))}const $=(r==null?void 0:r.toolbarWrap)??!1,H=(r==null?void 0:r.showDownloadButton)??!1,M=k.filter(F2),B=k.filter(q=>{if(F2(q))return!1;const U=p.getDashboardInputRuntimeSlot(c,q,{sheetId:t});return(U==null?void 0:U.status)==="set"||(U==null?void 0:U.status)==="cleared"}),W=new Set([...M,...B].map(q=>q.filter.id)),P=(i==null?void 0:i.filter(q=>!W.has(q.filterId)&&$G(q)).length)??0,G=[...M,...B],Z=G.filter(q=>{const U=p.hydrateAuthoredDashboardInputSlot({dashboard:j,input:q,runtimeValues:c,target:{sheetId:t}});return(U==null?void 0:U.status)==="set"&&U.value.kind==="filter"&&$G(U.value.filterValue)}).length,X=a?Object.values(a).reduce((q,U)=>q+((U==null?void 0:U.length)??0),0):0,Y=P+Z+X+d,O=()=>{w([]),G.forEach(q=>{m(q,{sheetId:t})}),C([]),u(),a&&Object.entries(a).forEach(([q,U])=>{U==null||U.forEach(V=>{f(q,V.filterId)})})};return!T.length&&!D.length&&!R.length&&!H&&Y===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(nC,{sensors:S,collisionDetection:Jw,onDragEnd:L,children:l.jsxs("div",{className:p.cn("flex items-center",$?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(rC,{items:A,strategy:Oz,children:l.jsx(MF,{className:"gap-3 pr-0",wrap:$,children:A.map(q=>{const U=F.get(q);if(U){const K=I.get(q),Q=K&&F2(K);return l.jsx(Zkt,{filter:U,isEditing:o,storageOptions:Q?{storageTarget:"dashboardInput",dashboardInput:K,sheetId:t??void 0}:void 0,inputVariableName:Q?K.variableName:void 0,onUpdateFilter:Q?(se,oe)=>{N({...K,variableName:(oe==null?void 0:oe.variableName)||K.variableName,filter:se})}:void 0,onRemoveFilter:Q?()=>{w((i||[]).filter(se=>se.filterId!==U.id)),b(K.id)}:void 0},q)}const V=z.get(q);return V?l.jsx(Qkt,{control:V,value:s==null?void 0:s[V.id],isEditing:o,onChange:K=>x(V.id,K)},q):null})})}),R.length>0&&l.jsx(zue,{title:"",controls:R,values:s,onChange:(q,U)=>x(q.id,U),immediatePlacement:"toolbar",advancedLabel:"More controls"}),Y>0&&l.jsxs("button",{type:"button",onClick:O,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(je.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:Y})]}),H&&l.jsx("div",{className:p.cn(Y>0?"ml-1.5":"ml-auto"),children:l.jsx(oxe,{})})]})})})}function ixe(){var ie,we;const{showAssistant:e,tokenProps:t,renderMode:n}=It(),r=Ykt((ie=t.config)==null?void 0:ie.showDashboardAssistant,e),{preferences:o}=Lm(),s=(we=o==null?void 0:o.cardDisplay)==null?void 0:we.mode,i=mf(s),a=eee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),[d,f]=v.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=I0t({initialPosition:"bottom-right"}),x=Mh(fe=>fe.setFullscreen),y=Mh(fe=>fe.setPanelOpen),w=Mh(fe=>fe.setContainer),C=GQ("dashboard"),N=YQ(),S=ZQ("dashboard"),j=C.isOpen,_=N==="dashboard",k=p.useDashboardStore(fe=>fe.isVisualEditing),T=p.useDashboardStore(fe=>fe.themeStyle),I=Ru(),E=p.useDashboardStore(fe=>{var ae;return(ae=fe.dashboard)==null?void 0:ae.sheets}),D=p.useDashboardStore(fe=>fe.showFilters),R=p.useDashboardStore(fe=>fe.isDashboardEditing),A=p.useDashboardStore(fe=>fe.selectedSheetId),F=E==null?void 0:E.find(fe=>fe.id===A),z=p.useDashboardStore(fe=>{var ae,ee,J;return(J=(ee=(ae=fe.dashboard)==null?void 0:ae.sheets)==null?void 0:ee.find(re=>re.id===fe.selectedSheetId))==null?void 0:J.kind}),L=p.useDashboardStore(fe=>{var ae,ee;return((ee=(ae=fe.dashboard)==null?void 0:ae.summary)==null?void 0:ee.position)||"top"}),$=z==="document",H=p.useDashboardStore(fe=>{var ae;return(ae=fe.dashboard)==null?void 0:ae.id}),{getDefaultSheetId:M,setDefaultSheetId:B,clearDefaultSheetId:W}=_Y(H),[P,G]=v.useState(null),{setSelectedSheetId:Z,setSheetTitle:X,addSheet:Y,setSheets:O}=p.useDashboardActions();Fkt(u);const{setActiveAssistantType:q}=p.useAIActions();v.useEffect(()=>{if(H){const fe=M();G(fe)}},[H,M]),v.useEffect(()=>{j?q("dashboard"):N==="dashboard"&&x(null)},[j,q,N,x]),v.useEffect(()=>{var fe;j||(fe=c.current)==null||fe.resize(0)},[j]);function U(fe){var ae,ee;fe?((ae=c.current)==null||ae.resize(40),y("dashboard",!0),x("dashboard"),q("dashboard")):(y("dashboard",!1),x(null),(ee=c.current)==null||ee.resize(0),q(null))}function V(fe="dashboard"){const ae={id:dt.v4(),title:fe==="document"?"New Document":"New Sheet",...fe==="document"?{kind:fe,document:p.createDefaultDocumentDefinition()}:{}};Y(ae),Z(ae.id)}function K(fe,ae){if(!H)return;P===fe?(W(),G(null),lt.success("Default sheet cleared")):(B(fe),G(fe),lt.success(`"${ae}" set as default sheet`))}function Q(fe){var ae;fe<1?(y("dashboard",!1),x(null),q(null),(ae=c.current)==null||ae.resize(0)):(j||y("dashboard",!0),q("dashboard"))}function se(){return(T==null?void 0:T.canvasTheme)==="muted"||!(T!=null&&T.canvasTheme)?"hsl(var(--semaphor-muted))":(T==null?void 0:T.canvasTheme)==="clear"?"":T==null?void 0:T.canvasTheme}const oe=(fe,ae)=>{fe.dataTransfer.setData("tabIndex",ae.toString())},me=fe=>{fe.preventDefault()},le=(fe,ae)=>{const ee=fe.dataTransfer.getData("tabIndex");if(ee===ae.toString())return;const J=Array.from(E||[]),[re]=J.splice(parseInt(ee),1);J.splice(ae,0,re),O(J)},ue=r===!0&&!i&&!j&&!k&&!D;function ne(){if(E&&E.length>1||R)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[E==null?void 0:E.map((fe,ae)=>{const ee=A===fe.id,J=P===fe.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:re=>oe(re,ae),onDragOver:me,onDrop:re=>le(re,ae),onClick:()=>Z(fe.id),className:p.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:fe.id,children:[fe.kind==="document"&&l.jsx(Qs,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Pj,{enabled:R&&ee,text:fe.title,onSave:re=>X(fe.id,re),children:fe.title},fe.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":J?"Clear default sheet":"Set as default sheet",title:J?"Clear default sheet":"Set as default sheet",onClick:re=>{re.stopPropagation(),K(fe.id,fe.title||"Sheet")},onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),re.stopPropagation(),K(fe.id,fe.title||"Sheet"))},className:p.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ee||J?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(FZ,{className:p.cn("h-3 w-3 transition-colors",J?"fill-current text-amber-500":"text-muted-foreground")})}),R&&ee&&E.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:re=>{re.stopPropagation(),f(!0)},onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),re.stopPropagation(),f(!0))},children:l.jsx(je.X,{className:"h-3 w-3"})})]},fe.id)}),R&&l.jsxs(Uo,{children:[l.jsx(Wo,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(Tr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(Do,{align:"start",className:"w-48",children:[l.jsxs(kn,{onSelect:()=>V("dashboard"),children:[l.jsx(em,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(kn,{onSelect:()=>V("document"),children:[l.jsx(Qs,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function de(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(fe=>l.jsx(p.TabsContent,{style:{backgroundColor:se(),...I.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:fe.id,children:l.jsx(RK,{sheet:fe})},fe.id))})}function Ce(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",T==null?void 0:T.dashboardTabsContainer),onValueChange:fe=>{Z(fe)},value:A||void 0,children:[ne(),L==="top"&&!$&&l.jsx(GP,{}),A&&!$&&l.jsx(o_t,{}),$?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:de()}):l.jsx(hl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:de()}),L==="bottom"&&!$&&l.jsx(GP,{}),l.jsx(T0t,{open:d,setOpen:f})]})}const ce=v.useCallback(fe=>{w("dashboard",fe)},[w]);return E?a&&A&&!$?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',A,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&$&&F?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(RK,{sheet:F})}):l.jsxs(l.Fragment,{children:[l.jsx(qkt,{}),l.jsx(Gkt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Zpe,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",_&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(OF,{children:Ce()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(_0t,{open:j,onTabClick:U,withHandle:!0,disabled:!j}),l.jsx(OF,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:Q,defaultSize:j?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(Pkt,{open:j,setOpen:U,isFullscreen:_,onFullscreenChange:fe=>x(fe?"dashboard":null),fullscreenContainer:S})})})]})]}),l.jsx("div",{ref:ce,className:p.cn("absolute inset-0",!_&&"pointer-events-none")}),ue&&l.jsx("div",{className:p.cn("absolute z-50 transition-all duration-300 ease-in-out",b().horizontal,b().vertical),style:g(),children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{m.current||U(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(_ve,{className:"h-5 w-5"})})})]})]}):null}const axe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,children:s,className:i,style:a,...c},u)=>{const d=v.useId(),f=v.useMemo(()=>s_t(d),[d]),{theme:h}=oO(),m=i_t(h),g=v.useMemo(()=>o??cf.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,o,n]),b=v.useMemo(()=>p.compileAppearance({spec:g,systemMode:m}),[g,m]),x=v.useMemo(()=>p.createAppearanceContextValue(f,b),[b,f]);return l.jsx(p.AppearanceContext.Provider,{value:x,children:l.jsx(Kb,{...c,ref:u,className:i,style:a,children:s})})});axe.displayName="AppearanceProvider";function s_t(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function i_t(e){const t=iN(e),[n,r]=v.useState(()=>a_t());return v.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const o=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!o)return;const s=()=>{r(o.matches?"dark":"light")};return s(),typeof o.addEventListener=="function"?(o.addEventListener("change",s),()=>o.removeEventListener("change",s)):((a=o.addListener)==null||a.call(o,s),()=>{var c;return(c=o.removeListener)==null?void 0:c.call(o,s)})},[t]),t==="system"?n:t}function a_t(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const lxe=v.createContext({openBrandStudioPreview:()=>{}}),l_t=lxe.Provider;function c_t(){return v.useContext(lxe)}function u_t({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=iN(t),[s,i]=v.useState(()=>d_t(n)||o),a=v.useCallback(u=>{const d=iN(u);f_t(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(sY.Provider,{...r,value:c,children:e})}function d_t(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=iN(t,"system");return n===t?n:null}catch{return null}}function f_t(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const h_t=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function U4({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=It(),s=Pv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,m]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,C=Un({queryKey:zX({resourceType:lo.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:R=>(R==null?void 0:R.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),v.useEffect(()=>{C.data!==void 0&&y({scopeKey:w,appearance:C.data})},[C.data,w]);const N=(x==null?void 0:x.scopeKey)===w?x.appearance:null,S=i!==void 0?i:C.data!==void 0?C.data:N,j=v.useMemo(()=>cf.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),_=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:_}),[_]),I=g??h??e;return l.jsx(u_t,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(l_t,{value:T,children:l.jsx(axe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:I,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(h_t,{appearance:d,onDraftChange:b,onSave:R=>{m(R),b(R),f(R)},onCancel:k})})})]})})})})}function cxe({children:e,preferences:t}){const{currentUser:n}=ti(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(OX.Provider,{value:r,children:l.jsx(HI,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function m_t(e=2e3,t=500){const n=Jye(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function W4({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=m_t(e,t);return v.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function uxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(Si,{FallbackComponent:BI,children:l.jsx(uO,{dashboardProps:e,children:l.jsxs(JI,{children:[l.jsx(W4,{componentType:"dashboard",componentId:e.id}),l.jsx(U4,{appearance:e.appearance,children:l.jsx(cxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(JO,{...e,type:"dashboard",children:l.jsx(ixe,{})})})})})]})})})}function p_t(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=v.useState(),i=v.useCallback(()=>{var m,g,b;const a=((m=t.current)==null?void 0:m.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function g_t({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=Lm(),r=mf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=p.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=p_t([t,s,r]);return v.useEffect(()=>{m()},[e.title,m]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(p.Label,{className:"my-1 block w-full text-sm",children:l.jsx(xi,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(A$,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(je.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function b_t(){const e=p.useDashboardStore(r=>r.dashboard.filters),t=p.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:p.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(g_t,{filter:r}),l.jsx(FI,{filter:r})]},r.id))}):null}function x_t(){var s;const e=p.useDashboardStore(i=>i.dashboard),t=p.useDashboardStore(i=>i.selectedSheetId),n=p.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=p.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(b_t,{}),l.jsx(ixe,{})]})})}const y_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-Cbw_M-lb.cjs"))),v_t=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-BLmOGhEP.cjs"))),w_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-D9V7Vsvn.cjs")));function C_t({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),o=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(Si,{FallbackComponent:BI,children:l.jsx(uO,{dashboardProps:n,children:l.jsxs(JI,{children:[l.jsx(W4,{componentType:"surfboard",componentId:n.id}),l.jsxs(U4,{appearance:s,children:[l.jsx(RCe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(cxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(w_t,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(y_t,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(JO,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(v_t,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(x_t,{})})]})})})]})]})]})]})})})}const XF=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],dxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),S_t=Li.getSupportedCurrencyCodes(),N_t=S_t.filter(e=>!dxe.has(e)),fxe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],BG="2026-07-31",O2="2026-07-31T14:30:45";function QF(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function L2(e){var t;return((t=fxe.find(n=>n.value===e))==null?void 0:t.label)??e}function j_t(e){const t=XF.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function $2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function z2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${L2(r)}`:L2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(p.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(p.SelectTrigger,{id:e,size:"xs",children:l.jsx(p.SelectValue,{children:c})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",QF(o)," ·"," ",L2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),fxe.map(u=>l.jsx(p.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function k_t({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,_,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:Li.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,m={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((_=e.dateTime)==null?void 0:_.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),b=$t.resolveRawTemporalFormat({preferences:m,calendar:{tz:"UTC"}}),x=$t.formatRawTemporalValue({value:BG,metadata:{kind:"raw_temporal",valueKind:"date"},format:b}).text,y=$t.formatRawTemporalValue({value:O2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:b}).text,w=$2(I=>$t.formatRawTemporalValue({value:BG,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateStyle:I},calendar:{tz:"UTC"}})}).text),C=$2(I=>$t.formatRawTemporalValue({value:O2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,dateStyle:I}},calendar:{tz:"UTC"}})}).text),N=$2(I=>$t.formatRawTemporalValue({value:O2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,timeStyle:I}},calendar:{tz:"UTC"}})}).text),S=(I,E)=>{const D={...e.dateTime,[I]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(p.Select,{value:e.locale??"inherit",disabled:o,onValueChange:I=>r({...e,locale:I==="inherit"?void 0:I}),children:[l.jsx(p.SelectTrigger,{id:s,size:"xs",children:l.jsx(p.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:j_t(e.locale)})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",QF(n.locale)," ·"," ",t.locale]}),e.locale&&!XF.some(I=>I.value===e.locale)&&l.jsx(p.SelectItem,{value:e.locale,children:e.locale}),XF.map(I=>l.jsxs(p.SelectItem,{value:I.value,children:[I.label," — ",I.value]},I.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(z2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:w,disabled:o,onValueChange:I=>r({...e,dateStyle:I==="inherit"?void 0:I})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(z2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:C,disabled:o,onValueChange:I=>S("dateStyle",I)}),l.jsx(z2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:I=>S("timeStyle",I)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(p.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:I=>r({...e,defaultCurrency:I==="inherit"?void 0:I}),children:[l.jsx(p.SelectTrigger,{id:i,size:"xs",children:l.jsx(p.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",QF(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...dxe].map(I=>l.jsx(p.SelectItem,{value:I,children:I},I)),N_t.map(I=>l.jsx(p.SelectItem,{value:I,children:I},I))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:x})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const JF=new Set;function hxe(e){return JF.add(e),()=>{JF.delete(e)}}function K4(){JF.forEach(e=>{e()})}var __t=Object.defineProperty,I_t=(e,t,n)=>t in e?__t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,l1=(e,t,n)=>I_t(e,typeof t!="symbol"?t+"":t,n);const T_t={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},E_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},D_t={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function M_t(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function mxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const R_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=mxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},A_t={stringify:e=>`${e}`,parse:e=>parseFloat(e)},P_t={stringify:e=>e,parse:e=>e},B2={string:P_t,number:A_t,boolean:T_t,function:E_t,method:R_t,json:D_t},Zx=Symbol.for("r2wc.render"),c1=Symbol.for("r2wc.connected"),qf=Symbol.for("r2wc.context"),Ii=Symbol.for("r2wc.props");function F_t(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const m of i){c[m]=Array.isArray(t.props)?"string":t.props[m];const g=M_t(m);d[m]=g,f[g]=m}for(const m of a)u[m]=Array.isArray(t.events)?{}:t.events[m];class h extends HTMLElement{constructor(){super(),l1(this,s,!0),l1(this,o),l1(this,r,{}),l1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Ii].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?B2[y]:null;if(y==="method"){const C=mxe(b);Object.defineProperty(this[Ii].container,C,{enumerable:!0,configurable:!0,get(){return this[Ii][C]},set(N){this[Ii][C]=N,this[Zx]()}}),this[Ii][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Ii][g]=w.parse(x,b,this))}for(const g of a)this[Ii][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[c1]=!0,this[Zx]()}disconnectedCallback(){this[c1]=!1,this[qf]&&n.unmount(this[qf]),delete this[qf]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],C=w?B2[w]:null;y in c&&C!=null&&C.parse&&x&&(this[Ii][y]=C.parse(x,g,this),this[Zx]())}[(s=c1,o=qf,r=Ii,Zx)](){this[c1]&&(this[qf]?n.update(this[qf],this[Ii]):this[qf]=n.mount(this.container,e,this[Ii]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Ii][m]},set(x){this[Ii][m]=x;const y=b?B2[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Zx]()}})}return h}function O_t(e,t,n){const r=zxe.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function L_t({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function $_t({root:e}){e.unmount()}function z_t(e,t={}){return F_t(e,t,{mount:O_t,update:L_t,unmount:$_t})}const B_t={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},V_t=z_t(uxe,{props:B_t}),H_t=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(a4,{context:t})," "]})});var pxe="Toggle",gxe=te.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=p.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:pxe});return l.jsx(p.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:p.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});gxe.displayName=pxe;var bxe=gxe;const q_t=p.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),xxe=te.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(bxe,{ref:o,className:p.cn(q_t({variant:t,size:n,className:e})),...r}));xxe.displayName=bxe.displayName;function G4(){var c,u;const e=p.useEditorStore(d=>d.card),t=p.useEditorStore(d=>d.frame),n=v.useMemo(()=>it.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=Nf(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=it.resolveMultiInputType(n,o),i=v.useMemo(()=>it.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:it.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:it.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function yxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const m=h??t;u.current=!0,a.current=m,s(m)},[t]);return{value:o,onChange:f,flush:d}}const U_t=300;function W_t({onExpand:e},t){const n=p.useEditorStore(C=>C.card.sql),r=p.useEditorStore(C=>C.sqlGen),o=p.useEditorStore(C=>C.card),s=G4(),{setCardSql:i,setSqlGen:a,setRunSql:c}=p.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=pb(u),f=Wr(),h=v.useRef(d);h.current=d;const m=v.useRef(r);m.current=r;const g=v.useCallback(C=>{i(C)},[i]),{value:b,onChange:x,flush:y}=yxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:U_t});v.useEffect(()=>hxe(y),[y]);function w(C){x(C),p.isObjectEmpty(m.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(p.CodeEditor,{ref:t,value:b??"",onValueChange:w,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:C=>{C.key==="Enter"&&C.shiftKey&&(C.preventDefault(),K4(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(p.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const K_t=v.forwardRef(W_t),G_t=300;function Y_t(e,t){const n=p.useEditorStore(g=>g.card.python),r=p.useEditorStore(g=>g.card),o=G4(),{setCardPython:s,setRunSql:i}=p.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=pb(a),u=Wr(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:m}=yxe({storeValue:n,defaultValue:it.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:G_t});return v.useEffect(()=>hxe(m),[m]),l.jsx(p.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),K4(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const Z_t=v.forwardRef(Y_t),vxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),X_t=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),Q_t=Array.from(vxe).join(", "),J_t=3,eIt="Self-heal",tIt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function nIt({card:e}){var W,P,G,Z,X;const t=fl(),[n,r]=v.useState({}),{authToken:o}=It(),s=p.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=p.useAppearance(),a=v.useMemo(()=>Aw(i),[i]),c=p.useEditorStore(Y=>Y.frame),u=p.useEditorStore(Y=>Y.inlineFilterValuesMap[e.id]),d=p.useEditorStore(Y=>Y.actions.setCardInlineFilterValue),f=p.useEditorStore(Y=>Y.actions.removeCardInlineFilterValue),h=e,{getCard:m,manifest:g}=Nf(((W=h.customCardPreferences)==null?void 0:W.url)||""),b=(P=g==null?void 0:g.visuals)==null?void 0:P.find(Y=>{var O;return Y.name===((O=h.customCardPreferences)==null?void 0:O.componentName)}),x=it.resolveMultiInputType(h,b)??"single",y=v.useMemo(()=>it.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:x==="multiple"}),[c,h,x]),w=v.useMemo(()=>{const Y=y.findIndex(O=>(O==null?void 0:O.id)===e.id);return Y<0?-1:it.getSlotIndexForCard(e,Y)},[y,e]),C=v.useMemo(()=>x!=="multiple"||w<0?e.type:it.getEffectiveCardTypeForSlot(e,w,b==null?void 0:b.slots)??e.type,[x,w,e,b==null?void 0:b.slots]),N=v.useMemo(()=>x==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:C!==e.type?{...e,type:C}:e,[e,C,x]),{data:S,effectiveCardConfig:j}=pb(N),_=p.useInteractionStore(Y=>Y.interactionStates),k=p.useDashboardStore(Y=>{var O;return(O=Y.dashboard)==null?void 0:O.id}),T=p.useDashboardStore(Y=>Y.dashboard.filters),I=p.useDashboardStore(Y=>Y.filterValues),E=p.useDashboardStore(Y=>Y.selectedSheetId),D=v.useMemo(()=>F$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:Y=>d(e.id,Y),removeInlineFilterValue:Y=>f(e.id,Y)}),[e,E,u,d,f]),{cardFilters:R,cardFilterValues:A}=v.useMemo(()=>Qv({card:e,interactionStates:_,currentDashboardId:k,filters:T,filterValues:I,selectedSheetId:E}),[e,_,k,T,I,E]),F=v.useCallback((Y,O)=>{const q=it.normalizeMultiInputPayload(O);r(U=>({...U,[Y]:q}))},[]),z=(G=h.customCardPreferences)==null?void 0:G.componentName,L=z?m(z):null,$=Rj((Z=h.customCardPreferences)==null?void 0:Z.settings,h),H=v.useMemo(()=>it.buildSlotOrderedCards(y),[y]),M=v.useMemo(()=>H.map((Y,O)=>it.getEffectiveCardTypeForSlot(Y,O,b==null?void 0:b.slots)),[H,b==null?void 0:b.slots]),B=v.useMemo(()=>$$(x==="multiple"?L$({slotOrderedCards:H,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,H,x,t]);return z?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[L&&x==="single"&&l.jsx(L,{editing:!0,params:s,theme:a,settings:$,cardMetadata:oue({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:F,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:B,filters:R,filterValues:[...A||[],...u||[]],inlineFilters:D}),L&&x==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((Y,O)=>{if(!Y)return null;const q=it.getSlotIndexForCard(Y,O),U=it.getEffectiveCardTypeForSlot(Y,q,b==null?void 0:b.slots);return l.jsx(a$,{onDataChange:F,card:Y,effectiveCardType:U},`${Y.id}-${q}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(L,{editing:!0,onDataChange:F,...O$({configCard:h,slotOrderedCards:H,slotTypes:M,multiInputData:n,params:s,theme:a,chartSettings:$,filters:R,filterValues:[...A||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:B})})})]})]},(X=h.customCardPreferences)==null?void 0:X.componentName)}):null}const rIt=v.memo(nIt),oIt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var wxe=["PageUp","PageDown"],Cxe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Sxe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ax="Slider",[eO,sIt,iIt]=p.createCollection(ax),[Nxe]=p.createContextScope(ax,[iIt]),[aIt,LT]=Nxe(ax),jxe=te.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:g,...b}=e,x=te.useRef(new Set),y=te.useRef(0),C=i==="horizontal"?lIt:cIt,[N=[],S]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var R;(R=[...x.current][y.current])==null||R.focus(),f(E)}}),j=te.useRef(N);function _(E){const D=mIt(N,E);I(E,D)}function k(E){I(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function I(E,D,{commit:R}={commit:!1}){const A=xIt(s),F=yIt(Math.round((E-r)/s)*s+r,A),z=p.clamp(F,[r,o]);S((L=[])=>{const $=fIt(L,z,D);if(bIt($,c*s)){y.current=$.indexOf(z);const H=String($)!==String(L);return H&&R&&h($),H?$:L}else return L})}return l.jsx(aIt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:N,orientation:i,form:g,children:l.jsx(eO.Provider,{scope:e.__scopeSlider,children:l.jsx(eO.Slot,{scope:e.__scopeSlider,children:l.jsx(C,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:p.composeEventHandlers(b.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:_,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&I(r,0,{commit:!0}),onEndKeyDown:()=>!a&&I(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const F=wxe.includes(E.key)||E.shiftKey&&Cxe.includes(E.key)?10:1,z=y.current,L=N[z],$=s*F*D;I(L+$,z,{commit:!0})}}})})})})});jxe.displayName=ax;var[kxe,_xe]=Nxe(ax,{startEdge:"left",endEdge:"right",size:"width",direction:1}),lIt=te.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=te.useState(null),m=p.useComposedRefs(t,C=>h(C)),g=te.useRef(void 0),b=p.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(C){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],_=Y4(S,y?[n,r]:[r,n]);return g.current=N,_(C-N.left)}return l.jsx(kxe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(Ixe,{dir:b,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const N=w(C.clientX);i==null||i(N)},onSlideMove:C=>{const N=w(C.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:C=>{const S=Sxe[y?"from-left":"from-right"].includes(C.key);u==null||u({event:C,direction:S?-1:1})}})})}),cIt=te.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=te.useRef(null),f=p.useComposedRefs(t,d),h=te.useRef(void 0),m=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],C=Y4(y,m?[r,n]:[n,r]);return h.current=x,C(b-x.top)}return l.jsx(kxe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(Ixe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=Sxe[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),Ixe=te.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=LT(ax,n);return l.jsx(p.Primitive.span,{...u,ref:t,onKeyDown:p.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):wxe.concat(Cxe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:p.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:p.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),Txe="SliderTrack",Exe=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=LT(Txe,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});Exe.displayName=Txe;var tO="SliderRange",Dxe=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=LT(tO,n),s=_xe(tO,n),i=te.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>Axe(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});Dxe.displayName=tO;var nO="SliderThumb",Mxe=te.forwardRef((e,t)=>{const n=sIt(e.__scopeSlider),[r,o]=te.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=te.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(uIt,{...e,ref:s,index:i})}),uIt=te.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=LT(nO,n),a=_xe(nO,n),[c,u]=te.useState(null),d=p.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=p.useSize(c),m=i.values[r],g=m===void 0?0:Axe(m,i.min,i.max),b=hIt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?pIt(x,g,a.direction):0;return te.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(eO.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(p.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(Rxe,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});Mxe.displayName=nO;var dIt="RadioBubbleInput",Rxe=te.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=te.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return te.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(p.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});Rxe.displayName=dIt;function fIt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function Axe(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function hIt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function mIt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function pIt(e,t,n){const r=e/2,s=Y4([0,50],[0,r]);return(r-s(t)*n)*n}function gIt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function bIt(e,t){if(t>0){const n=gIt(e);return Math.min(...n)>=t}return!0}function Y4(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function xIt(e){return(String(e).split(".")[1]||"").length}function yIt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Pxe=jxe,vIt=Exe,wIt=Dxe,CIt=Mxe;const Fxe=te.forwardRef(({className:e,...t},n)=>l.jsxs(Pxe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(vIt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(wIt,{className:"absolute h-full bg-primary"})}),l.jsx(CIt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Fxe.displayName=Pxe.displayName;exports.Accordion=Jz;exports.AccordionContent=mv;exports.AccordionItem=fv;exports.AccordionTrigger=hv;exports.AddDataPicker=B4;exports.AggregateTable=hI;exports.Alert=rL;exports.AlertDescription=oL;exports.AlertDialog=ff;exports.AlertDialogAction=Du;exports.AlertDialogCancel=Mu;exports.AlertDialogContent=ku;exports.AlertDialogDescription=Eu;exports.AlertDialogFooter=Iu;exports.AlertDialogHeader=_u;exports.AlertDialogTitle=Tu;exports.AlertDialogTrigger=JSe;exports.AlertTitle=mte;exports.ArrowDown=es;exports.ArrowDownIcon=dQe;exports.ArrowLeft=zv;exports.ArrowRight=Bv;exports.ArrowUp=bs;exports.ArrowUpIcon=hQe;exports.AssistantContextEntityControls=YF;exports.AssistantVirtualizedMessages=nxe;exports.AxisConfigurator=Wm;exports.BackgroundRunPill=kct;exports.Badge=mi;exports.Bell=h1;exports.BookType=oZ;exports.BriefingAuthor=Pfe;exports.BriefingAuthorDialog=Ffe;exports.BriefingUiCapabilitiesBoundary=Gct;exports.BriefingUiCapabilitiesProvider=JI;exports.BriefingsApiError=Uw;exports.BulletChartIcon=Gbe;exports.CSS=Ki;exports.CalculatedFieldEditor=fme;exports.Calculator=iZ;exports.Calendar=za;exports.CalendarClock=SO;exports.Card=hN;exports.CardContent=CO;exports.CardHeader=wO;exports.CardSummary=tF;exports.CardTitle=cb;exports.ChartArea=fR;exports.ChartColumnIncreasing=lZ;exports.ChartColumnStacked=cZ;exports.ChartJsVisual=Tw;exports.ChartLine=uZ;exports.ChartNoAxesGantt=fZ;exports.ChartPie=hZ;exports.ChartScatter=mZ;exports.ChatInputWithContext=V4;exports.Checkbox=Tn;exports.ChevronLeft=Mm;exports.ChevronsUpDown=bZ;exports.Circle=NO;exports.CircleAlert=Ca;exports.CircleCheck=xZ;exports.CircleHelp=yZ;exports.Clock=vZ;exports.CodeHighlighter=Fd;exports.CodeXml=m1;exports.Collapsible=vu;exports.CollapsibleContent=Cu;exports.CollapsibleTrigger=wu;exports.ColorField=da;exports.Command=cT;exports.CommandEmpty=dT;exports.CommandGroup=fT;exports.CommandInput=Bz;exports.CommandItem=hT;exports.CommandList=uT;exports.CommandSeparator=Dhe;exports.ComparisonMetadataBadge=Foe;exports.Container=JO;exports.ControlDefaultValueEditor=Pme;exports.ControlDefinitionOptionsEditor=Ame;exports.ControlIdInput=Eme;exports.ControlVisibilitySettings=fgt;exports.Copy=Jh;exports.CopyButton=Pd;exports.CopyPlus=mR;exports.Cross2Icon=bQe;exports.CustomFilterPopover=A$;exports.CustomScrollArea=hl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Are;exports.Dashboard=uxe;exports.DashboardCard=zfe;exports.DashboardCreateDialogBase=hQ;exports.DashboardExportDialog=rxe;exports.DashboardPlus=C_t;exports.DashboardWC=V_t;exports.DataTableConditionalFormattingSettings=Npe;exports.DataTablePagination=rI;exports.Database=ss;exports.DateRangePicker=E$;exports.DefaultChatTransport=M4;exports.Dialog=Mo;exports.DialogContent=go;exports.DialogDescription=Ro;exports.DialogFooter=tl;exports.DialogHeader=Is;exports.DialogTitle=bo;exports.DialogTrigger=uQ;exports.DisplayFormatPreferencesFields=k_t;exports.DisplayPreferencesProvider=HI;exports.DndContext=nC;exports.Donut=wZ;exports.Download=Su;exports.DownloadPdf=oxe;exports.DragOverlay=bhe;exports.DropdownMenu=Uo;exports.DropdownMenuCheckboxItem=nd;exports.DropdownMenuContent=Do;exports.DropdownMenuItem=kn;exports.DropdownMenuLabel=qa;exports.DropdownMenuRadioGroup=iCe;exports.DropdownMenuRadioItem=FX;exports.DropdownMenuSeparator=Sa;exports.DropdownMenuSub=qO;exports.DropdownMenuSubContent=$k;exports.DropdownMenuSubTrigger=Lk;exports.DropdownMenuTrigger=Wo;exports.EMPTY_DATA_SOURCE=sb;exports.Editable=Pj;exports.EditableText=xi;exports.EditorCustomVisual=rIt;exports.Ellipsis=Ci;exports.EllipsisVertical=Rm;exports.ErrorBoundary=Si;exports.ExportError=kb;exports.ExternalLink=Ld;exports.EyeOff=Ak;exports.Fallback=BI;exports.FallbackVisual=Vw;exports.FeedbackCategory=lf;exports.FeedbackDialog=jv;exports.FieldsList=a4;exports.FieldsSection=H_t;exports.FileCode=CZ;exports.FileText=Qs;exports.Filter=$d;exports.FilterComponent=FI;exports.FilterInfo=XP;exports.FilterableFieldsPanel=mme;exports.Grid3x3=pR;exports.GripVertical=Nu;exports.HEATMAP_PRESET_PALETTES=_A;exports.Hash=ub;exports.House=SZ;exports.HoverCard=Xm;exports.HoverCardContent=bu;exports.HoverCardTrigger=Yd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=vxe;exports.INLINE_ALLOWED_TOOL_LIST=Q_t;exports.INLINE_BLOCKED_MUTATING_TOOLS=X_t;exports.IconButton=nu;exports.IconForFieldType=Q1;exports.Inbox=kO;exports.InfoHover=J$;exports.InlineFilterBar=Rue;exports.KPICard=tf;exports.KeyboardSensor=eC;exports.Layers=Pm;exports.Link=_O;exports.LoadingDots=xu;exports.MAX_SELF_HEAL_ATTEMPTS=J_t;exports.Map=_Z;exports.Markdown=Sz;exports.MatrixTableVisual=fI;exports.MdStackedLineChart=Wbe;exports.MultiInputEmptyRenderer=a$;exports.PanelResizeHandle=ET;exports.Pause=IZ;exports.PenLine=xR;exports.Pencil=yR;exports.PendingMessagesDisplay=Fbe;exports.PersistedDynamicVisual=VI;exports.PiChartPolar=Vbe;exports.Pin=EZ;exports.PinOff=TZ;exports.PivotTableTanstack=Wb;exports.Placeholders=Xpe;exports.Play=DZ;exports.Plus=Tr;exports.PointerSensor=Jb;exports.Progress=L4;exports.PythonEditor=Z_t;exports.RECOVERABLE_SQL_ERROR_CODES=tIt;exports.Radar=MZ;exports.RadioGroup=rl;exports.RadioGroupItem=vs;exports.RefreshCw=tc;exports.ResizableHandle=k0t;exports.ResizablePanel=OF;exports.ResizablePanelGroup=Zpe;exports.ResourceEditDialog=HQ;exports.ResourceType=lo;exports.Rows3=RZ;exports.RunCompletionBanner=_ct;exports.SELF_HEAL_TIMELINE_STEP=eIt;exports.SeedQuestions=wbe;exports.SemaphorContext=Av;exports.SemaphorContextProvider=uO;exports.SemaphorQueryClient=kY;exports.SemaphorReadyIndicator=W4;exports.SemaphorStyleWrapper=Kb;exports.Send=TO;exports.SendHorizontal=AZ;exports.Settings=EO;exports.Settings2=Fm;exports.Share2=PZ;exports.ShareDialog=VQ;exports.Sheet=a3;exports.SheetContent=oI;exports.SheetDescription=iI;exports.SheetHeader=koe;exports.SheetTitle=sI;exports.SheetTrigger=Wze;exports.Slider=Fxe;exports.SortableContext=rC;exports.Sparkles=p0;exports.SqlEditor=K_t;exports.Square=MO;exports.SquarePen=DO;exports.Star=FZ;exports.StructuralParticipantSelector=Dme;exports.SummaryCard=GP;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Rd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=ha;exports.TableBody=Gd;exports.TableCell=qn;exports.TableColumnVisibilitySettings=fpe;exports.TableHead=mo;exports.TableHeader=Zm;exports.TablePresentationSettings=mpe;exports.TableRow=Ar;exports.TableSkeleton=tz;exports.TableVisual=Zd;exports.Tag=OZ;exports.TbChartBubble=Hbe;exports.TbChartFunnel=qbe;exports.TbChartTreemap=Ube;exports.TextCard=Xg;exports.Textarea=zm;exports.TiSortNumerically=Kbe;exports.Toggle=xxe;exports.Tornado=LZ;exports.Trash2=el;exports.TriangleAlert=Zs;exports.TypeGlyph=Yw;exports.UXProvider=U4;exports.Undo2=$Z;exports.User=AO;exports.Users=Pk;exports.UsersRound=PO;exports.VisualErrorState=yue;exports.Zap=vR;exports.applyBriefingFormPatch=rv;exports.areContextEntitiesEqual=ar;exports.areEntitiesJoined=Lre;exports.arrayMove=ex;exports.briefingFormDraftToCreateRequest=rF;exports.briefingFormDraftToUpdateRequest=pde;exports.briefingToFormDraft=Qp;exports.briefingTone=_r;exports.buildCardControlUsageById=mgt;exports.buildCustomCardTheme=Aw;exports.buildDashboardControlUsageById=hgt;exports.buildDashboardSheetsInputExecutionSnapshot=vO;exports.buildDashboardStructuralParticipantIdsByControlId=Lme;exports.buildFilterFieldMeta=Kz;exports.buildFilterSemanticContext=Gz;exports.buildInlineFilterNodes=F$;exports.buildMultiInputCustomVisualProps=O$;exports.buildMultiInputTemporalPresentationInputs=L$;exports.calculateCardFilterValues=S5;exports.calculateContextAwareFilters=Qv;exports.calculateFieldState=GL;exports.canUserAccessVisuals=sNe;exports.canUserCreateDashboards=WQ;exports.canUserEdit=nNe;exports.canUserManageDashboards=oNe;exports.canUserManageGroups=iNe;exports.canUserUseFilters=rNe;exports.cancelBriefingPreviewRun=rde;exports.cancelBriefingRun=sde;exports.cancelExport=r$e;exports.chartSupportsDataLabels=Dne;exports.chartSupportsLegend=Tne;exports.chartTypes=OT;exports.cleanupKpiMetricComparisonMode=zhe;exports.cloneDeep=Ks;exports.cloneLinkedFrameWithSourceMapping=Iet;exports.closestCenter=Jw;exports.commitSharedCalculatedFields=Jf;exports.createAssistantConversationId=Hp;exports.createAssistantRequestId=ybe;exports.createBriefing=Yue;exports.createBriefingFormDraft=nF;exports.createChartConfig=Nb;exports.createCustomVisualTemporalBucketFormatter=$$;exports.createDashboardControlInputFromControl=hyt;exports.createExport=toe;exports.createUniqueDashboardInputVariableNameFromName=Od;exports.currencyPresentationTargetKey=ba;exports.dedup=wNt;exports.dedupeContextEntities=Dz;exports.deleteBriefing=Que;exports.deleteBriefingRun=ide;exports.diagnoseCurrencyPresentationBindings=y0e;exports.doesStoredFilterMatchField=rb;exports.downloadDocumentPdf=Q5;exports.downloadPdf=Uee;exports.extractSqlParamReferences=IY;exports.extractTableMetadata=Wz;exports.fieldAlreadyExists=zre;exports.flexRender=gi;exports.flushPendingEditorDrafts=K4;exports.formatDisplayFormula=cmt;exports.formatFileSize=i$e;exports.getAutoDetectedChartIcon=Xjt;exports.getBriefing=Gue;exports.getBriefingArtifact=Ttt;exports.getBriefingEvidence=Ett;exports.getBriefingPreviewRun=nde;exports.getBriefingRun=ode;exports.getCardCurrencyPresentationFields=pO;exports.getCardCurrencyPresentationTargets=gO;exports.getChartGridStyle=eDe;exports.getChartIconByType=Qjt;exports.getColorForValue=BR;exports.getCoreRowModel=eI;exports.getDefaultAxisConfig=WR;exports.getDefaultChartColors=Um;exports.getDefaultDataLabelsConfig=dw;exports.getDefaultLegendConfig=EL;exports.getDefaultRunningTotalPartitionByFieldIds=l0;exports.getDisplayedKpiResultColumnKeys=mw;exports.getDocumentSectionEditorCard=Wpt;exports.getDocumentSheetDashboardInputs=rx;exports.getDownloadUrl=n$e;exports.getEntityIcon=Nk;exports.getErrorMessage=sbe;exports.getExportStatus=t$e;exports.getExports=e$e;exports.getExpressionFieldKind=rf;exports.getFieldExpressionAnnotation=Yz;exports.getFilterCount=zj;exports.getGranularityOptionsForFieldType=Tme;exports.getKeys=yr;exports.getMatrixVisualLoadingState=X_;exports.getMetricDisplayLabel=g3e;exports.getNewField=Ure;exports.getObjectDiff=iY;exports.getPaginationRowModel=tI;exports.getRoleBasedDisplayOverrides=UQ;exports.getRunningTotalOrderByCandidates=Mht;exports.getSelectedDateFilterColumn=Uce;exports.getSortedRowModel=Soe;exports.getTableConditionalFormattingColumnOptions=xpe;exports.getTableOutputColumnOptions=ype;exports.getTablePageSizeOptions=Jre;exports.handleAggregationChange=QP;exports.handleAggregationLabelChange=Due;exports.hasFlatTableTotalsBehavior=qm;exports.hasMatrixResultData=gw;exports.horizontalListSortingStrategy=Oz;exports.inferSemanticDomainIdFromSelectedEntities=Sk;exports.isActiveBriefingRunStatus=Wj;exports.isCardSummaryVisibleOnCard=z$;exports.isCurrencyPresentationControl=b0e;exports.isDefaultColor=xTe;exports.isEligibleFlatTableTotalsCard=rw;exports.isExportComplete=s$e;exports.isExportInProgress=o$e;exports.isInAiScopeArray=vNt;exports.isManagedCalculatedExpressionField=Qa;exports.isMetricTransformEnabled=Eht;exports.isPresentationCurrencyBinding=Ov;exports.isPromiseLike=GF;exports.isSqlBackedKpi=Wre;exports.isStructuralControlBinding=g0e;exports.isSubtotalEnabledAggregateTable=Uz;exports.isSupportedDocumentTableCardType=Kpt;exports.isTableType=zEe;exports.isTerminalBriefingRunStatus=Uj;exports.lastAssistantMessageIsCompleteWithToolCalls=tbe;exports.listBriefingRuns=Itt;exports.listBriefingTenantSummaries=_tt;exports.listBriefings=ktt;exports.merge=Jl;exports.mergeAxisConfig=KR;exports.normalizeConditionalFormatting=A5;exports.normalizeContextFormatMode=yee;exports.normalizeDashboardInputVariableName=Lv;exports.pauseBriefing=Zue;exports.pivotData=sw;exports.polishBriefingText=ade;exports.prepareFeedbackData=FT;exports.previewBriefingPlan=ede;exports.remarkGfm=_z;exports.removeFromScopeArray=CNt;exports.requiresDashboardInputResolution=uf;exports.resolveCurrencyPresentationTargetFormat=See;exports.resolveDashboardBriefingsVisibility=Ofe;exports.resolveDashboardControlsVisibility=uNe;exports.resolveDashboardInputContext=Yi;exports.resolveDashboardTitleEditability=cNe;exports.resolveDomainCalculatedFieldForEdit=opt;exports.resolveMatrixCardMeasureInstances=Mk;exports.resolvePendingPivotTableResultState=q3e;exports.resolveTablePageSize=G_;exports.resolveTablePresentationStyle=p3;exports.resumeBriefing=Xue;exports.runBriefingNow=Jue;exports.runBriefingPreview=tde;exports.sanitizeAIScope=obe;exports.saveCalculatedFieldToCardScope=IF;exports.saveCalculatedFieldToSharedScope=hme;exports.saveCalculatedFieldToSheetScope=TF;exports.seedSemanticMetricFormatDefaults=Vhe;exports.setTableColumnVisibility=ooe;exports.setupEditorWithCard=S_;exports.showAllTableColumns=g$e;exports.showJoinRequiredNotification=$re;exports.sortByColumnsToSortState=Woe;exports.sortStateToSortByColumns=Koe;exports.sortableKeyboardCoordinates=$z;exports.supportsLiveNumericPresentation=Fv;exports.supportsMetricTransformForMetric=Bhe;exports.supportsTableConditionalFormatting=ppe;exports.toEntityArray=Xa;exports.ue=lt;exports.updateBriefing=UI;exports.useActiveExports=gNe;exports.useActiveToolStatus=Lbe;exports.useAddFrameWithFreshSemanticExecutionPayload=Q$;exports.useAddNewFrame=Kfe;exports.useAssistantContainer=ZQ;exports.useAssistantContextEntities=eT;exports.useAssistantLayoutStore=Mh;exports.useAssistantPanel=GQ;exports.useAssistantProfile=vbe;exports.useAutoSubmitQueue=Obe;exports.useBrandStudioPreview=c_t;exports.useBriefingRunPolling=sF;exports.useBriefingUiCapabilities=Lfe;exports.useCalendarContext=_3e;exports.useCard=A3e;exports.useCardNumericPresentation=Ta;exports.useCardSummary=B$;exports.useChartNumericPresentation=jb;exports.useChat=rbe;exports.useColumns=Vz;exports.useCreateVisualWithFrame=nSe;exports.useCurrentUserInfo=ti;exports.useCustomVisual=Nf;exports.useCustomVisualsQuery=R$;exports.useDashboardAppearance=Ru;exports.useDashboardById=UX;exports.useDashboardInteractionMode=Iue;exports.useDashboardPreferences=Lm;exports.useDashboardQuery=Pv;exports.useDashboardStructuralParticipants=$me;exports.useDashboardSummary=due;exports.useDataColumns=qhe;exports.useDateFilterHook=VGe;exports.useDefaultDashboardMutation=LX;exports.useDisplayPreferences=cl;exports.useDroppable=ghe;exports.useEditorAside=mT;exports.useEditorCardQuery=pb;exports.useEffectiveEditorCardType=G4;exports.useEnsureReactGlobals=ble;exports.useExportActions=XQ;exports.useExportStore=Gk;exports.useFieldManagement=Hhe;exports.useFilterableFields=Ohe;exports.useFullscreenAssistant=YQ;exports.useGroupMembers=o1e;exports.useGroups=XO;exports.useHasDashboardId=QQ;exports.useInProgressExportsCount=bNe;exports.useJoinabilityMap=qz;exports.useManagementActions=Dm;exports.useManagementStore=_s;exports.useMutation=ks;exports.usePivotTableConfig=Gm;exports.usePluginQuery=Jce;exports.useQuery=Un;exports.useQueryClient=Wr;exports.useReactTable=nI;exports.useResolveExistingFrameSemanticExecutionPayload=Met;exports.useResolvedDefaultCurrency=XL;exports.useResolvedTemporalStylePreferences=fl;exports.useResolvedValueFormatLocale=ZL;exports.useResourceManagement=WO;exports.useResourceUpdateState=WX;exports.useScopedFields=Fhe;exports.useSelectedVisual=n0e;exports.useSemaphorContext=It;exports.useSensor=nb;exports.useSensors=oT;exports.useSortable=tx;exports.useStarredChartsStore=oIt;exports.useSurfaceAppearance=dc;exports.useTableQueryState=Ooe;exports.useTextFilterHook=bUe;exports.useTheme=oO;exports.useTimezone=dl;exports.useTopoJson=hw;exports.useUnifiedUsers=Wk;exports.useUpdateResource=BX;exports.useUpdateVisualMutation=rSe;exports.useUserPreferences=mQ;exports.useVisualById=Bk;exports.useVisualManagement=tSe;exports.validateBriefingFormDraft=oF;exports.validateFieldForChartType=$he;exports.verticalListSortingStrategy=Lz;
1392
+ `).trim(),k=j.map((T,I)=>{var R,A;let E="",D;if((R=T.url)!=null&&R.startsWith("data:")){const F=T.url.match(/data:[^;]+;base64,(.+)/);F&&(E=F[1],(A=T.mediaType)!=null&&A.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${I}`,name:T.filename||`File ${I+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(Nkt,{text:_||void 0,files:k.length>0?k:void 0})}const f=((C=e.parts)==null?void 0:C.filter(S=>S.type==="reasoning"))||[],h=f.length>0,m=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),b=h&&(g.length>0||m)?l.jsxs(vu,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(wu,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Ft.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:m?"animate-pulse":"",children:m?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(Cu,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:j+1}),l.jsx(IG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,x=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const _=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:I,quickReplies:E}=vkt(T),D=I.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(IG,{text:I,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:R,value:A},F)=>l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(A),children:l.jsx("span",{className:"truncate",children:R})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:A})})]},`${_}-qr-${F}`))})]})]},_)}return e.role==="system"&&s?l.jsx(jkt,{text:T},_):null}case"error":{const T=S,I=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(q4,{errorMessage:I})},_)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&H4(S,r)?l.jsx(Si,{FallbackComponent:({error:T,resetErrorBoundary:I})=>l.jsx(Skt,{error:T,resetErrorBoundary:I}),children:l.jsx(pkt,{part:S,idx:_,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},_):null}});return e.role==="assistant"?txe(e,r)?l.jsxs(exe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const Tkt=8,Ekt=24,Dkt=20;function Mkt(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function nxe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:m,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),w=v.useRef(!1),C=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,_]=v.useState(!0),[k,T]=v.useState(0),[I,E]=v.useState(Ekt);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],R=txe(D,t),A=Mkt(a,c,u,R),F=uI({count:e.length,getScrollElement:()=>b.current,estimateSize:H=>{const M=e[H];return(M==null?void 0:M.role)==="user"?88:180},getItemKey:H=>{const M=e[H];return(M==null?void 0:M.id)||`message-${H}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:Tkt,overscan:6,gap:20,paddingEnd:A?I+Dkt:0,useAnimationFrameWithResizeObserver:!0,onChange:H=>{const M=H.isAtEnd();_(B=>B===M?B:M),M&&T(0)}}),z=v.useCallback((H="smooth")=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null,F.scrollToEnd({behavior:H})}),T(0),_(!0)},[F]);v.useLayoutEffect(()=>{w.current||(w.current=!0,z("auto"))},[z]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,z("auto"))},[e.length,g,z]),v.useEffect(()=>{const H=y.current;y.current=e.length,e.length>H&&!F.isAtEnd()&&T(M=>M+e.length-H),e.length===0&&(T(0),_(!0),w.current=!1,N.current=!1)},[e.length,F]);const L=F.getVirtualItems(),$=F.getTotalSize();return v.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]),v.useLayoutEffect(()=>{const H=x.current;if(!H||!A)return;const M=()=>{const W=Math.ceil(H.getBoundingClientRect().height);W>0&&E(P=>P===W?P:W)};if(M(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(M);return B.observe(H),()=>B.disconnect()},[A,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(hl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:p.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:$},children:[L.map(H=>{const M=e[H.index];return M?l.jsx("div",{ref:F.measureElement,"data-index":H.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${H.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(Ikt,{message:M,messageIndex:H.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},H.key):null}),A&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max($-I,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(kkt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>z("smooth"),"aria-label":"Scroll to latest",className:p.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",m),children:[l.jsx(es,{className:"h-3 w-3"}),"Latest",k>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:k>9?"9+":k})]})]})}function Rkt(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const Akt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function Pkt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(dt.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[m,g]=v.useState(!1),[b,x]=v.useState(!1),[y,w]=v.useState(0),C=n??b,{isLocalDev:N,isConsoleMode:S}=Lm(),j=N||S||a,_=v.useRef(null);p.useDashboardStore(re=>re.dashboard.aiScopeTables),p.useDashboardStore(re=>re.isDashboardEditing);const k=p.useDashboardStore(re=>re.selectedSheetId),{setDataSource:T}=p.useEditorActions(),{setSelectedFrameId:I,setIsDashboardEditing:E}=p.useDashboardActions(),D=Q$(),{clearAssistantMessageContexts:R}=p.useAIActions(),{clearQueue:A}=p.useQueueActions(),{clearFileAttachments:F,getFileAttachments:z}=p.useFileActions(),L=p.useFileAttachments("dashboard"),$=p.useEditorStore(re=>re.card.dataSource),{assistantProfile:H}=vbe(),M=p.useDashboardStore(re=>re.handleOpenAssistantProfile),{selectedEntities:B,applyDashboardDefaultEntities:W}=eT("dashboard"),{sendMessage:P,isLoading:G,messages:Z,setMessages:X,status:Y,stop:O,errorMessage:q,clearError:U}=zNt({dynamicVisualMode:f}),V=v.useCallback(()=>{w(re=>re+1)},[]),K=v.useCallback(re=>{r==null||r(re),n===void 0&&x(re)},[n,r]),Q=v.useCallback(()=>{K(!C)},[C,K]);v.useEffect(()=>{if(!C)return;function re(pe){pe.key==="Escape"&&K(!1)}return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re)}},[C,K]);const[se,oe]=v.useState(""),me=re=>{oe(re.target.value)};async function le({sql:re,cardTitle:pe,connectionId:Ee,cardType:Te,python:ze,cardConfig:Pe,dataSource:He,customVisualPreferences:ye,visualizationMode:Ke,dynamicCardPreferences:We}){if(!k)return;const Qe=Ke==="dynamic",xe=dt.hasValidCardConfig(Pe),Ve=Ee||(He==null?void 0:He.connectionId)||"",Ae=He?{...He,connectionId:Ve||He.connectionId,connectionType:He.connectionType||"",mode:He.mode||"database",selectedEntities:He.selectedEntities||[]}:Ve?{connectionId:Ve,connectionType:"",mode:"database",selectedEntities:[]}:sb,Be=!(xe&&(!Qe||(We==null?void 0:We.provenance)==="card-config"||(We==null?void 0:We.provenance)==="query_spec")),Ie=Be?Rkt(re):"",$e=Be?ze:"",st={id:dt.v4(),title:pe||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Te==="horizontalBar"?"y":"x"},...Qe&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Te,sql:Ie,python:$e,dataSource:Ae,config:Pe,connectionId:Ve,visualizationMode:Ke,dynamicCardPreferences:We,customCardPreferences:ye?{url:ye.url,componentName:ye.componentName,pluginChartType:ye.pluginChartType,settings:ye.settings,type:"component"}:void 0},ct={id:dt.v4(),cards:[st],activeCardId:st.id};try{await D(k,ct,"end"),E(!0),I(ct.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),lt.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const ue=re=>{re.preventDefault();const pe=se.trim();if(!pe&&L.length===0)return;const Ee=[];pe&&Ee.push({type:"text",text:pe}),L.forEach(Te=>{Te.data&&Ee.push({type:"file",mediaType:Te.type,filename:Te.name,url:`data:${Te.type};base64,${Te.data}`})}),P({role:"user",parts:Ee}),oe(""),F("dashboard"),V()};v.useEffect(()=>{var re;e&&((re=_.current)==null||re.focus())},[e]),Obe({assistantType:"dashboard",status:Y,isLoading:G,sendMessage:P});const{hasActiveTools:ne,activeToolText:de}=Lbe(Z);function Ce(re){const pe={role:"user",parts:[{type:"text",text:re.title+" "+re.subtitle}]};P(pe),V()}function ce(re){P({role:"user",parts:[{type:"text",text:re}]}),V()}function ie(re){P({role:"user",parts:[{type:"text",text:re}]}),V()}const we=v.useCallback(async()=>{const re=JSON.stringify(Z??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(re),lt.success("Conversation copied")}catch(pe){console.error("Failed to copy conversation",pe),lt.error("Unable to copy conversation")}},[Z]),fe=(se==null?void 0:se.length)===0&&(Z==null?void 0:Z.filter(re=>re.role==="user").length)===0;function ae(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ee(){return l.jsxs(Uo,{children:[l.jsx(Wo,{asChild:!0,children:l.jsx(nu,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Rm,{className:"size-3.5"})})}),l.jsxs(Do,{align:"end",children:[l.jsx(qa,{children:"Options"}),l.jsx(Sa,{}),l.jsx(nd,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(nd,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(nd,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Sa,{}),l.jsx(qa,{children:"Dynamic Visuals"}),l.jsx(nd,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(nd,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(nd,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const J=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",C&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[ae(),M&&l.jsxs("button",{type:"button",onClick:M,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(H==null?void 0:H.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[S&&ee(),j&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:we,children:"Copy Conversation"}),l.jsx(nu,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:C?"Exit fullscreen":"Expand",onClick:Q,children:C?l.jsx(Ft.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(nu,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const re=Z.filter(pe=>pe.role==="assistant").map(pe=>pe.id).filter(pe=>!!pe);X([]),A("dashboard"),U(),R(re)},children:l.jsx(DO,{className:"h-3.5 w-3.5"})}),l.jsx(nu,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(je.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(nxe,{messages:Z,showTools:a,showSystemMessage:u,onAddToDashboard:le,onQuickReply:ie,disableQuickReplies:G,status:Y,errorMessage:q,activeToolText:G&&ne?de:void 0,className:p.cn(C?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(C&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!H&&fe&&l.jsx(Xpe,{onClick:Ce,placeholders:Akt}),fe&&H&&l.jsx(wbe,{seedQuestions:H.seedQuestions||[],handleSeedQuestionClick:ce}),l.jsx(Fbe,{assistantType:"dashboard"}),l.jsx(V4,{ref:_,setInput:oe,stop:O,input:se,handleInputChange:me,handleSubmit:re=>{ue(re)},isLoading:G,status:Y,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(B4,{incomingSelectedEntities:B,open:m,onOpenChange:g,dataSource:$||sb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:re=>W()})]});return C&&o?br.createPortal(l.jsx(Kb,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:J})}),o):J}function Fkt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=_ue(),s=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=p.useDashboardStore(d=>d.isDashboardEditing),u=p.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(m){if(Okt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),lt.success("Card copied to clipboard"),m.preventDefault()):g&&m.key==="v"&&(await h(),m.preventDefault())}async function f(){try{const m=n();m&&await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy text:",m)}}async function h(){if(!a)return null;try{const m=await navigator.clipboard.readText(),g=Lkt(m);if(g!=null&&g.id){const b=Nue(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),lt.success("Card pasted from clipboard")}return m}catch(m){return console.error("Failed to paste text:",m),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function Okt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function Lkt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function $kt(e,t){switch(e.interactionMode){case"drillToDetail":zkt(e,t);break;case"drillThrough":Bkt(e,t);break;case"drillToURL":Vkt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function zkt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function Bkt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function Vkt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function Hkt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(Mo,{open:e,onOpenChange:t,children:l.jsxs(go,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Is,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(bo,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Ro,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(Mue,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(Bfe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function qkt(){const e=p.useInteractionStore(N=>N.interactionStates),t=p.useInteractionStore(N=>N.setInteractionState),n=p.useInteractionStore(N=>N.clearLastInteractionEvent),r=p.useInteractionStore(N=>N.replaceCardWithInsight),o=p.useInteractionStore(N=>N.setPendingDrillThrough),s=p.useInteractionStore(N=>N.pendingDrillThrough),i=p.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Dm(),d=p.useDashboardStore(N=>N.dashboard),f=p.useDashboardStore(N=>N.filterValues),{data:h,isLoading:m}=UX((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=Vfe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),w=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{b({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:_})=>{r(N,S,j,_)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:_,targetDashboardId:k})=>{const T={filters:N},I={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...p.createInitialInteractionState(),appliedClickFilters:[I],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:_,targetDashboardId:k};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,_=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(_))return;y.current.add(_);try{$kt(j,w)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(_)},5e3)}}})},[e,n,w]),v.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,m,u,c,i]);const C=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(Hkt,{open:g.open,onOpenChange:C,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&m&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(p.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function Ukt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=Wkt(ez(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function Wkt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function Kkt(e){return e?`Back to ${e}`:"Back"}function Gkt(){var y,w,C,N,S;const e=p.useInteractionStore(j=>j.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(j=>j.actions.goBackFromDrill),n=p.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Dm(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},_=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(C=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:C[0])==null?void 0:N.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((S=e.appliedClickFilters)!=null&&S.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},b=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};Ukt(f);const x=Kkt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((j,_)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(mi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},_)})})]}),l.jsx(p.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(je.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(p.Button,{variant:"secondary",size:"sm",onClick:m,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(zv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function Ykt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function Zkt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:m,transition:g,isDragging:b}=tx({id:`filter:${e.id}`,disabled:n||!t}),x={transform:Ki.Translate.toString(m),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(P$,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const OG="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Xkt=[];function rxe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(X=>{var Y;return(Y=X.dashboard)==null?void 0:Y.sheets}),u=p.useDashboardStore(X=>X.dashboard),d=p.useDashboardStore(X=>X.dashboardInputValues),f=p.useDashboardStore(X=>X.filterValues),h=p.useDashboardStore(X=>X.controlValues),m=p.useDashboardStore(X=>X.inlineFilterValuesMap),g=p.useDashboardStore(X=>X.cardControlValuesMap),b=p.useDashboardStore(X=>X.selectedSheetId),x=p.useDashboardStore(X=>X.selectedSheetId?X.documentInputRuntimeBySheetId[X.selectedSheetId]:void 0),y=p.useDashboardStore(X=>X.isDownloadingPdf),w=p.useDashboardStore(X=>X.reportContext),{authToken:C,tokenProps:N}=It(),S=c==null?void 0:c.find(X=>X.id===b),j=v.useMemo(()=>p.getDashboardExportSheets(c),[c]),_=p.isDocumentSheet(S),k=_&&S?S.document:void 0,T=v.useMemo(()=>_&&S?rx(u,S.id):[],[S,_,u]),I=T.length>0,E=v.useMemo(()=>_&&S?kpe(u,S.id):!1,[S,_,u]),D=v.useMemo(()=>I?T.map(lC):(k==null?void 0:k.inputs)||Xkt,[k,T,I]),R=w==null?void 0:w.calendar.tz,A=v.useMemo(()=>Nme(D),[D]),F=v.useMemo(()=>Cme(D,R),[D,R]),z=v.useMemo(()=>Sme(D),[D]),L=x?x.filterValuesByInputId:F,$=x?x.controlValuesByInputId:z,H=v.useMemo(()=>_?E&&S&&k?YY({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(X=>X.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:R}):_me(D,L,$,A,A):[],[k,D,S,_,u,g,h,f,m,d,$,L,A,R,E]),M=!!S,B=j.length>0,W=((c==null?void 0:c.length)||0)>1||_,P=i.sheetSelection==="current"&&(!M||_&&H.length>0)||i.sheetSelection==="all"&&!B;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!B&&a(X=>({...X,sheetSelection:"current"}))},[B,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function Z(){if(y){lt.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){lt.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!M){lt.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!B){lt.error("No dashboard sheets are available to export");return}s(!0);const X=i.sheetSelection==="current"&&_,Y=X?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",O=lt.loading(Y);try{if(X){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(H.length>0){lt.dismiss(O),lt.error(`Set ${H.join(", ")} before exporting`);return}const U=new Date().toISOString(),V=E?ZY({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(K=>K.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:U,timezone:R}).snapshot:void 0;await Q5(N.apiServiceUrl,C,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:R,password:i.protectPdf?i.password:void 0,inputSnapshot:V,...V?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:L,controlValuesByInputId:$,generatedAt:U}}})}else{const U=eoe();await Uee(N.apiServiceUrl,C,i.protectPdf?i.password:void 0,i.sheetSelection,U)}lt.dismiss(O);const q=X?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";lt.success(q,{duration:2e3}),G()}catch(q){lt.dismiss(O),lt.error("Failed to download PDF",{description:j_(q,"Please try again or contact support."),descriptionClassName:N_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",q)}finally{s(!1)}}return l.jsx(Mo,{open:e,onOpenChange:X=>{if(!X){G();return}t(!0)},children:l.jsxs(go,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Is,{children:[l.jsx(bo,{className:"text-[15px]",children:_?"Export document":"Export dashboard"}),l.jsx(Ro,{className:"text-[13px] leading-5",children:_?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[W&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:OG,children:"Export scope"}),l.jsxs(rl,{value:i.sheetSelection,onValueChange:X=>a({...i,sheetSelection:X}),className:"gap-1.5",children:[l.jsxs(p.Label,{htmlFor:"scope-current",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!M&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(vs,{value:"current",id:"scope-current",disabled:!M}),_?"This document":"This sheet"," (",(S==null?void 0:S.title)||"Current",")"]}),l.jsxs(p.Label,{htmlFor:"scope-all",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!B&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(vs,{value:"all",id:"scope-all",disabled:!B}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),_&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:H.length>0?`Set ${H.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(p.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(p.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(Tn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:X=>{a({...i,protectPdf:X,password:X?i.password:""}),X||r(!1)}}),l.jsx(Vv,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(p.Label,{htmlFor:"pdf-password",className:OG,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(p.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:X=>a({...i,password:X.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:X=>{X.key==="Enter"&&i.password&&Z()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(Ak,{className:"h-3.5 w-3.5"}):l.jsx(Ft.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(tl,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:Z,disabled:o||y||P,children:o?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Su,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function oxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(Su,{className:p.cn("size-4",e)})}),l.jsx(rxe,{open:i,onOpenChange:a})]})}function LG(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Qkt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=tx({id:`control:${e.id}`,disabled:!n}),d={transform:Ki.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(qme,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function $G(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function zG(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Jkt(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return zG(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=zG(t,n).filter(a=>!s.has(a));return[...o,...i]}function e_t(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function t_t(e){return Qh(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Qh(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function F2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function n_t(e){return sxe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function sxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=e_t(e.dashboard,t);return Rk(ab({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!t_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function r_t(e,t){return"toolbar"}function o_t(){const e=dc("interactive"),t=p.useDashboardStore(q=>q.selectedSheetId),n=p.useDashboardStore(q=>q.dashboard.filters),r=p.useDashboardStore(q=>q.dashboard.filterLayout),o=p.useDashboardStore(q=>q.isDashboardEditing),s=p.useDashboardStore(q=>q.controlValues),i=p.useDashboardStore(q=>q.filterValues);p.useDashboardStore(q=>q.filteringCards);const a=p.useDashboardStore(q=>q.inlineFilterValuesMap),c=p.useDashboardStore(q=>q.dashboardInputValues),u=p.useInteractionStore(q=>q.clearAllClickFilters),d=p.useInteractionStore(q=>Object.entries(q.interactionStates).reduce((U,[V,K])=>{var Q;return V===p.DRILL_CONTEXT_CARD_ID?U:U+(((Q=K.appliedClickFilters)==null?void 0:Q.length)??0)},0)),f=p.useDashboardStore(q=>q.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:C,upsertDashboardInput:N}=p.useDashboardActions(),S=oT(nb(Jb,{activationConstraint:{distance:5}})),j=p.useDashboardStore(q=>q.dashboard),_=n_t({dashboard:j,selectedSheetId:t}).filter(q=>r_t(q.filter)==="toolbar"),k=sxe({dashboard:j,selectedSheetId:t}),T=_.map(q=>q.filter),I=new Map(_.map(q=>[`filter:${q.filter.id}`,q])),E=stt(j),D=E.filter(q=>!q.hidden&&nv(q)==="toolbar"),R=E.filter(q=>!q.hidden&&nv(q)==="advanced"),A=Jkt(r==null?void 0:r.toolbarItemOrder,T,D),F=new Map(T.map(q=>[`filter:${q.id}`,q])),z=new Map(D.map(q=>[`control:${q.id}`,q]));function L(q){const{active:U,over:V}=q;if(!V||U.id===V.id)return;const K=String(U.id),Q=String(V.id),se=A.findIndex(ce=>ce===K),oe=A.findIndex(ce=>ce===Q);if(se===-1||oe===-1)return;const me=ex(A,se,oe);y({toolbarItemOrder:me});const le=new Set((n||[]).map(ce=>ce.id)),ue=A.filter(ce=>ce.startsWith("filter:")).map(ce=>ce.replace("filter:","")).filter(ce=>le.has(ce)),ne=me.filter(ce=>ce.startsWith("filter:")).map(ce=>ce.replace("filter:","")).filter(ce=>le.has(ce)),de=A.filter(ce=>ce.startsWith("control:")).map(ce=>ce.replace("control:","")),Ce=me.filter(ce=>ce.startsWith("control:")).map(ce=>ce.replace("control:",""));h(LG(n||[],ue,ne)),g(LG(j.controls||[],de,Ce))}const $=(r==null?void 0:r.toolbarWrap)??!1,H=(r==null?void 0:r.showDownloadButton)??!1,M=k.filter(F2),B=k.filter(q=>{if(F2(q))return!1;const U=p.getDashboardInputRuntimeSlot(c,q,{sheetId:t});return(U==null?void 0:U.status)==="set"||(U==null?void 0:U.status)==="cleared"}),W=new Set([...M,...B].map(q=>q.filter.id)),P=(i==null?void 0:i.filter(q=>!W.has(q.filterId)&&$G(q)).length)??0,G=[...M,...B],Z=G.filter(q=>{const U=p.hydrateAuthoredDashboardInputSlot({dashboard:j,input:q,runtimeValues:c,target:{sheetId:t}});return(U==null?void 0:U.status)==="set"&&U.value.kind==="filter"&&$G(U.value.filterValue)}).length,X=a?Object.values(a).reduce((q,U)=>q+((U==null?void 0:U.length)??0),0):0,Y=P+Z+X+d,O=()=>{w([]),G.forEach(q=>{m(q,{sheetId:t})}),C([]),u(),a&&Object.entries(a).forEach(([q,U])=>{U==null||U.forEach(V=>{f(q,V.filterId)})})};return!T.length&&!D.length&&!R.length&&!H&&Y===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(nC,{sensors:S,collisionDetection:Jw,onDragEnd:L,children:l.jsxs("div",{className:p.cn("flex items-center",$?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(rC,{items:A,strategy:Oz,children:l.jsx(MF,{className:"gap-3 pr-0",wrap:$,children:A.map(q=>{const U=F.get(q);if(U){const K=I.get(q),Q=K&&F2(K);return l.jsx(Zkt,{filter:U,isEditing:o,storageOptions:Q?{storageTarget:"dashboardInput",dashboardInput:K,sheetId:t??void 0}:void 0,inputVariableName:Q?K.variableName:void 0,onUpdateFilter:Q?(se,oe)=>{N({...K,variableName:(oe==null?void 0:oe.variableName)||K.variableName,filter:se})}:void 0,onRemoveFilter:Q?()=>{w((i||[]).filter(se=>se.filterId!==U.id)),b(K.id)}:void 0},q)}const V=z.get(q);return V?l.jsx(Qkt,{control:V,value:s==null?void 0:s[V.id],isEditing:o,onChange:K=>x(V.id,K)},q):null})})}),R.length>0&&l.jsx(zue,{title:"",controls:R,values:s,onChange:(q,U)=>x(q.id,U),immediatePlacement:"toolbar",advancedLabel:"More controls"}),Y>0&&l.jsxs("button",{type:"button",onClick:O,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(je.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:Y})]}),H&&l.jsx("div",{className:p.cn(Y>0?"ml-1.5":"ml-auto"),children:l.jsx(oxe,{})})]})})})}function ixe(){var ie,we;const{showAssistant:e,tokenProps:t,renderMode:n}=It(),r=Ykt((ie=t.config)==null?void 0:ie.showDashboardAssistant,e),{preferences:o}=Lm(),s=(we=o==null?void 0:o.cardDisplay)==null?void 0:we.mode,i=mf(s),a=eee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),[d,f]=v.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=I0t({initialPosition:"bottom-right"}),x=Mh(fe=>fe.setFullscreen),y=Mh(fe=>fe.setPanelOpen),w=Mh(fe=>fe.setContainer),C=GQ("dashboard"),N=YQ(),S=ZQ("dashboard"),j=C.isOpen,_=N==="dashboard",k=p.useDashboardStore(fe=>fe.isVisualEditing),T=p.useDashboardStore(fe=>fe.themeStyle),I=Ru(),E=p.useDashboardStore(fe=>{var ae;return(ae=fe.dashboard)==null?void 0:ae.sheets}),D=p.useDashboardStore(fe=>fe.showFilters),R=p.useDashboardStore(fe=>fe.isDashboardEditing),A=p.useDashboardStore(fe=>fe.selectedSheetId),F=E==null?void 0:E.find(fe=>fe.id===A),z=p.useDashboardStore(fe=>{var ae,ee,J;return(J=(ee=(ae=fe.dashboard)==null?void 0:ae.sheets)==null?void 0:ee.find(re=>re.id===fe.selectedSheetId))==null?void 0:J.kind}),L=p.useDashboardStore(fe=>{var ae,ee;return((ee=(ae=fe.dashboard)==null?void 0:ae.summary)==null?void 0:ee.position)||"top"}),$=z==="document",H=p.useDashboardStore(fe=>{var ae;return(ae=fe.dashboard)==null?void 0:ae.id}),{getDefaultSheetId:M,setDefaultSheetId:B,clearDefaultSheetId:W}=_Y(H),[P,G]=v.useState(null),{setSelectedSheetId:Z,setSheetTitle:X,addSheet:Y,setSheets:O}=p.useDashboardActions();Fkt(u);const{setActiveAssistantType:q}=p.useAIActions();v.useEffect(()=>{if(H){const fe=M();G(fe)}},[H,M]),v.useEffect(()=>{j?q("dashboard"):N==="dashboard"&&x(null)},[j,q,N,x]),v.useEffect(()=>{var fe;j||(fe=c.current)==null||fe.resize(0)},[j]);function U(fe){var ae,ee;fe?((ae=c.current)==null||ae.resize(40),y("dashboard",!0),x("dashboard"),q("dashboard")):(y("dashboard",!1),x(null),(ee=c.current)==null||ee.resize(0),q(null))}function V(fe="dashboard"){const ae={id:dt.v4(),title:fe==="document"?"New Document":"New Sheet",...fe==="document"?{kind:fe,document:p.createDefaultDocumentDefinition()}:{}};Y(ae),Z(ae.id)}function K(fe,ae){if(!H)return;P===fe?(W(),G(null),lt.success("Default sheet cleared")):(B(fe),G(fe),lt.success(`"${ae}" set as default sheet`))}function Q(fe){var ae;fe<1?(y("dashboard",!1),x(null),q(null),(ae=c.current)==null||ae.resize(0)):(j||y("dashboard",!0),q("dashboard"))}function se(){return(T==null?void 0:T.canvasTheme)==="muted"||!(T!=null&&T.canvasTheme)?"hsl(var(--semaphor-muted))":(T==null?void 0:T.canvasTheme)==="clear"?"":T==null?void 0:T.canvasTheme}const oe=(fe,ae)=>{fe.dataTransfer.setData("tabIndex",ae.toString())},me=fe=>{fe.preventDefault()},le=(fe,ae)=>{const ee=fe.dataTransfer.getData("tabIndex");if(ee===ae.toString())return;const J=Array.from(E||[]),[re]=J.splice(parseInt(ee),1);J.splice(ae,0,re),O(J)},ue=r===!0&&!i&&!j&&!k&&!D;function ne(){if(E&&E.length>1||R)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[E==null?void 0:E.map((fe,ae)=>{const ee=A===fe.id,J=P===fe.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:re=>oe(re,ae),onDragOver:me,onDrop:re=>le(re,ae),onClick:()=>Z(fe.id),className:p.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:fe.id,children:[fe.kind==="document"&&l.jsx(Qs,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Pj,{enabled:R&&ee,text:fe.title,onSave:re=>X(fe.id,re),children:fe.title},fe.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":J?"Clear default sheet":"Set as default sheet",title:J?"Clear default sheet":"Set as default sheet",onClick:re=>{re.stopPropagation(),K(fe.id,fe.title||"Sheet")},onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),re.stopPropagation(),K(fe.id,fe.title||"Sheet"))},className:p.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ee||J?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(FZ,{className:p.cn("h-3 w-3 transition-colors",J?"fill-current text-amber-500":"text-muted-foreground")})}),R&&ee&&E.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:re=>{re.stopPropagation(),f(!0)},onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),re.stopPropagation(),f(!0))},children:l.jsx(je.X,{className:"h-3 w-3"})})]},fe.id)}),R&&l.jsxs(Uo,{children:[l.jsx(Wo,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(Tr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(Do,{align:"start",className:"w-48",children:[l.jsxs(kn,{onSelect:()=>V("dashboard"),children:[l.jsx(em,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(kn,{onSelect:()=>V("document"),children:[l.jsx(Qs,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function de(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(fe=>l.jsx(p.TabsContent,{style:{backgroundColor:se(),...I.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:fe.id,children:l.jsx(RK,{sheet:fe})},fe.id))})}function Ce(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",T==null?void 0:T.dashboardTabsContainer),onValueChange:fe=>{Z(fe)},value:A||void 0,children:[ne(),L==="top"&&!$&&l.jsx(GP,{}),A&&!$&&l.jsx(o_t,{}),$?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:de()}):l.jsx(hl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:de()}),L==="bottom"&&!$&&l.jsx(GP,{}),l.jsx(T0t,{open:d,setOpen:f})]})}const ce=v.useCallback(fe=>{w("dashboard",fe)},[w]);return E?a&&A&&!$?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',A,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&$&&F?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(RK,{sheet:F})}):l.jsxs(l.Fragment,{children:[l.jsx(qkt,{}),l.jsx(Gkt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Zpe,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",_&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(OF,{children:Ce()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(_0t,{open:j,onTabClick:U,withHandle:!0,disabled:!j}),l.jsx(OF,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:Q,defaultSize:j?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(Pkt,{open:j,setOpen:U,isFullscreen:_,onFullscreenChange:fe=>x(fe?"dashboard":null),fullscreenContainer:S})})})]})]}),l.jsx("div",{ref:ce,className:p.cn("absolute inset-0",!_&&"pointer-events-none")}),ue&&l.jsx("div",{className:p.cn("absolute z-50 transition-all duration-300 ease-in-out",b().horizontal,b().vertical),style:g(),children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{m.current||U(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(_ve,{className:"h-5 w-5"})})})]})]}):null}const axe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,children:s,className:i,style:a,...c},u)=>{const d=v.useId(),f=v.useMemo(()=>s_t(d),[d]),{theme:h}=oO(),m=i_t(h),g=v.useMemo(()=>o??cf.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,o,n]),b=v.useMemo(()=>p.compileAppearance({spec:g,systemMode:m}),[g,m]),x=v.useMemo(()=>p.createAppearanceContextValue(f,b),[b,f]);return l.jsx(p.AppearanceContext.Provider,{value:x,children:l.jsx(Kb,{...c,ref:u,className:i,style:a,children:s})})});axe.displayName="AppearanceProvider";function s_t(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function i_t(e){const t=iN(e),[n,r]=v.useState(()=>a_t());return v.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const o=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!o)return;const s=()=>{r(o.matches?"dark":"light")};return s(),typeof o.addEventListener=="function"?(o.addEventListener("change",s),()=>o.removeEventListener("change",s)):((a=o.addListener)==null||a.call(o,s),()=>{var c;return(c=o.removeListener)==null?void 0:c.call(o,s)})},[t]),t==="system"?n:t}function a_t(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const lxe=v.createContext({openBrandStudioPreview:()=>{}}),l_t=lxe.Provider;function c_t(){return v.useContext(lxe)}function u_t({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=iN(t),[s,i]=v.useState(()=>d_t(n)||o),a=v.useCallback(u=>{const d=iN(u);f_t(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(sY.Provider,{...r,value:c,children:e})}function d_t(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=iN(t,"system");return n===t?n:null}catch{return null}}function f_t(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const h_t=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function U4({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=It(),s=Pv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,m]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,C=Un({queryKey:zX({resourceType:lo.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:R=>(R==null?void 0:R.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),v.useEffect(()=>{C.data!==void 0&&y({scopeKey:w,appearance:C.data})},[C.data,w]);const N=(x==null?void 0:x.scopeKey)===w?x.appearance:null,S=i!==void 0?i:C.data!==void 0?C.data:N,j=v.useMemo(()=>cf.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),_=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:_}),[_]),I=g??h??e;return l.jsx(u_t,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(l_t,{value:T,children:l.jsx(axe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:I,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(h_t,{appearance:d,onDraftChange:b,onSave:R=>{m(R),b(R),f(R)},onCancel:k})})})]})})})})}function cxe({children:e,preferences:t}){const{currentUser:n}=ti(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(OX.Provider,{value:r,children:l.jsx(HI,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function m_t(e=2e3,t=500){const n=Jye(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function W4({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=m_t(e,t);return v.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function uxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(Si,{FallbackComponent:BI,children:l.jsx(uO,{dashboardProps:e,children:l.jsxs(JI,{children:[l.jsx(W4,{componentType:"dashboard",componentId:e.id}),l.jsx(U4,{appearance:e.appearance,children:l.jsx(cxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(JO,{...e,type:"dashboard",children:l.jsx(ixe,{})})})})})]})})})}function p_t(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=v.useState(),i=v.useCallback(()=>{var m,g,b;const a=((m=t.current)==null?void 0:m.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function g_t({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=Lm(),r=mf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=p.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=p_t([t,s,r]);return v.useEffect(()=>{m()},[e.title,m]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(p.Label,{className:"my-1 block w-full text-sm",children:l.jsx(xi,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(A$,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(je.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function b_t(){const e=p.useDashboardStore(r=>r.dashboard.filters),t=p.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:p.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(g_t,{filter:r}),l.jsx(FI,{filter:r})]},r.id))}):null}function x_t(){var s;const e=p.useDashboardStore(i=>i.dashboard),t=p.useDashboardStore(i=>i.selectedSheetId),n=p.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=p.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(b_t,{}),l.jsx(ixe,{})]})})}const y_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-VRShl9J0.cjs"))),v_t=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-DWWyT55u.cjs"))),w_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-BhvPMpZA.cjs")));function C_t({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),o=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(Si,{FallbackComponent:BI,children:l.jsx(uO,{dashboardProps:n,children:l.jsxs(JI,{children:[l.jsx(W4,{componentType:"surfboard",componentId:n.id}),l.jsxs(U4,{appearance:s,children:[l.jsx(RCe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(cxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(w_t,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(y_t,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(JO,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(v_t,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(x_t,{})})]})})})]})]})]})]})})})}const XF=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],dxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),S_t=Li.getSupportedCurrencyCodes(),N_t=S_t.filter(e=>!dxe.has(e)),fxe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],BG="2026-07-31",O2="2026-07-31T14:30:45";function QF(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function L2(e){var t;return((t=fxe.find(n=>n.value===e))==null?void 0:t.label)??e}function j_t(e){const t=XF.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function $2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function z2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${L2(r)}`:L2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(p.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(p.SelectTrigger,{id:e,size:"xs",children:l.jsx(p.SelectValue,{children:c})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",QF(o)," ·"," ",L2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),fxe.map(u=>l.jsx(p.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function k_t({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,_,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:Li.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,m={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((_=e.dateTime)==null?void 0:_.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),b=$t.resolveRawTemporalFormat({preferences:m,calendar:{tz:"UTC"}}),x=$t.formatRawTemporalValue({value:BG,metadata:{kind:"raw_temporal",valueKind:"date"},format:b}).text,y=$t.formatRawTemporalValue({value:O2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:b}).text,w=$2(I=>$t.formatRawTemporalValue({value:BG,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateStyle:I},calendar:{tz:"UTC"}})}).text),C=$2(I=>$t.formatRawTemporalValue({value:O2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,dateStyle:I}},calendar:{tz:"UTC"}})}).text),N=$2(I=>$t.formatRawTemporalValue({value:O2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,timeStyle:I}},calendar:{tz:"UTC"}})}).text),S=(I,E)=>{const D={...e.dateTime,[I]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(p.Select,{value:e.locale??"inherit",disabled:o,onValueChange:I=>r({...e,locale:I==="inherit"?void 0:I}),children:[l.jsx(p.SelectTrigger,{id:s,size:"xs",children:l.jsx(p.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:j_t(e.locale)})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",QF(n.locale)," ·"," ",t.locale]}),e.locale&&!XF.some(I=>I.value===e.locale)&&l.jsx(p.SelectItem,{value:e.locale,children:e.locale}),XF.map(I=>l.jsxs(p.SelectItem,{value:I.value,children:[I.label," — ",I.value]},I.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(z2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:w,disabled:o,onValueChange:I=>r({...e,dateStyle:I==="inherit"?void 0:I})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(z2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:C,disabled:o,onValueChange:I=>S("dateStyle",I)}),l.jsx(z2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:I=>S("timeStyle",I)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(p.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:I=>r({...e,defaultCurrency:I==="inherit"?void 0:I}),children:[l.jsx(p.SelectTrigger,{id:i,size:"xs",children:l.jsx(p.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",QF(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...dxe].map(I=>l.jsx(p.SelectItem,{value:I,children:I},I)),N_t.map(I=>l.jsx(p.SelectItem,{value:I,children:I},I))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:x})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const JF=new Set;function hxe(e){return JF.add(e),()=>{JF.delete(e)}}function K4(){JF.forEach(e=>{e()})}var __t=Object.defineProperty,I_t=(e,t,n)=>t in e?__t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,l1=(e,t,n)=>I_t(e,typeof t!="symbol"?t+"":t,n);const T_t={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},E_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},D_t={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function M_t(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function mxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const R_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=mxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},A_t={stringify:e=>`${e}`,parse:e=>parseFloat(e)},P_t={stringify:e=>e,parse:e=>e},B2={string:P_t,number:A_t,boolean:T_t,function:E_t,method:R_t,json:D_t},Zx=Symbol.for("r2wc.render"),c1=Symbol.for("r2wc.connected"),qf=Symbol.for("r2wc.context"),Ii=Symbol.for("r2wc.props");function F_t(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const m of i){c[m]=Array.isArray(t.props)?"string":t.props[m];const g=M_t(m);d[m]=g,f[g]=m}for(const m of a)u[m]=Array.isArray(t.events)?{}:t.events[m];class h extends HTMLElement{constructor(){super(),l1(this,s,!0),l1(this,o),l1(this,r,{}),l1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Ii].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?B2[y]:null;if(y==="method"){const C=mxe(b);Object.defineProperty(this[Ii].container,C,{enumerable:!0,configurable:!0,get(){return this[Ii][C]},set(N){this[Ii][C]=N,this[Zx]()}}),this[Ii][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Ii][g]=w.parse(x,b,this))}for(const g of a)this[Ii][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[c1]=!0,this[Zx]()}disconnectedCallback(){this[c1]=!1,this[qf]&&n.unmount(this[qf]),delete this[qf]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],C=w?B2[w]:null;y in c&&C!=null&&C.parse&&x&&(this[Ii][y]=C.parse(x,g,this),this[Zx]())}[(s=c1,o=qf,r=Ii,Zx)](){this[c1]&&(this[qf]?n.update(this[qf],this[Ii]):this[qf]=n.mount(this.container,e,this[Ii]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Ii][m]},set(x){this[Ii][m]=x;const y=b?B2[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Zx]()}})}return h}function O_t(e,t,n){const r=zxe.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function L_t({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function $_t({root:e}){e.unmount()}function z_t(e,t={}){return F_t(e,t,{mount:O_t,update:L_t,unmount:$_t})}const B_t={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},V_t=z_t(uxe,{props:B_t}),H_t=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(a4,{context:t})," "]})});var pxe="Toggle",gxe=te.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=p.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:pxe});return l.jsx(p.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:p.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});gxe.displayName=pxe;var bxe=gxe;const q_t=p.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),xxe=te.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(bxe,{ref:o,className:p.cn(q_t({variant:t,size:n,className:e})),...r}));xxe.displayName=bxe.displayName;function G4(){var c,u;const e=p.useEditorStore(d=>d.card),t=p.useEditorStore(d=>d.frame),n=v.useMemo(()=>it.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=Nf(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=it.resolveMultiInputType(n,o),i=v.useMemo(()=>it.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:it.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:it.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function yxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const m=h??t;u.current=!0,a.current=m,s(m)},[t]);return{value:o,onChange:f,flush:d}}const U_t=300;function W_t({onExpand:e},t){const n=p.useEditorStore(C=>C.card.sql),r=p.useEditorStore(C=>C.sqlGen),o=p.useEditorStore(C=>C.card),s=G4(),{setCardSql:i,setSqlGen:a,setRunSql:c}=p.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=pb(u),f=Wr(),h=v.useRef(d);h.current=d;const m=v.useRef(r);m.current=r;const g=v.useCallback(C=>{i(C)},[i]),{value:b,onChange:x,flush:y}=yxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:U_t});v.useEffect(()=>hxe(y),[y]);function w(C){x(C),p.isObjectEmpty(m.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(p.CodeEditor,{ref:t,value:b??"",onValueChange:w,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:C=>{C.key==="Enter"&&C.shiftKey&&(C.preventDefault(),K4(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(p.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Ft.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const K_t=v.forwardRef(W_t),G_t=300;function Y_t(e,t){const n=p.useEditorStore(g=>g.card.python),r=p.useEditorStore(g=>g.card),o=G4(),{setCardPython:s,setRunSql:i}=p.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=pb(a),u=Wr(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:m}=yxe({storeValue:n,defaultValue:it.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:G_t});return v.useEffect(()=>hxe(m),[m]),l.jsx(p.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),K4(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const Z_t=v.forwardRef(Y_t),vxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),X_t=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),Q_t=Array.from(vxe).join(", "),J_t=3,eIt="Self-heal",tIt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function nIt({card:e}){var W,P,G,Z,X;const t=fl(),[n,r]=v.useState({}),{authToken:o}=It(),s=p.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=p.useAppearance(),a=v.useMemo(()=>Aw(i),[i]),c=p.useEditorStore(Y=>Y.frame),u=p.useEditorStore(Y=>Y.inlineFilterValuesMap[e.id]),d=p.useEditorStore(Y=>Y.actions.setCardInlineFilterValue),f=p.useEditorStore(Y=>Y.actions.removeCardInlineFilterValue),h=e,{getCard:m,manifest:g}=Nf(((W=h.customCardPreferences)==null?void 0:W.url)||""),b=(P=g==null?void 0:g.visuals)==null?void 0:P.find(Y=>{var O;return Y.name===((O=h.customCardPreferences)==null?void 0:O.componentName)}),x=it.resolveMultiInputType(h,b)??"single",y=v.useMemo(()=>it.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:x==="multiple"}),[c,h,x]),w=v.useMemo(()=>{const Y=y.findIndex(O=>(O==null?void 0:O.id)===e.id);return Y<0?-1:it.getSlotIndexForCard(e,Y)},[y,e]),C=v.useMemo(()=>x!=="multiple"||w<0?e.type:it.getEffectiveCardTypeForSlot(e,w,b==null?void 0:b.slots)??e.type,[x,w,e,b==null?void 0:b.slots]),N=v.useMemo(()=>x==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:C!==e.type?{...e,type:C}:e,[e,C,x]),{data:S,effectiveCardConfig:j}=pb(N),_=p.useInteractionStore(Y=>Y.interactionStates),k=p.useDashboardStore(Y=>{var O;return(O=Y.dashboard)==null?void 0:O.id}),T=p.useDashboardStore(Y=>Y.dashboard.filters),I=p.useDashboardStore(Y=>Y.filterValues),E=p.useDashboardStore(Y=>Y.selectedSheetId),D=v.useMemo(()=>F$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:Y=>d(e.id,Y),removeInlineFilterValue:Y=>f(e.id,Y)}),[e,E,u,d,f]),{cardFilters:R,cardFilterValues:A}=v.useMemo(()=>Qv({card:e,interactionStates:_,currentDashboardId:k,filters:T,filterValues:I,selectedSheetId:E}),[e,_,k,T,I,E]),F=v.useCallback((Y,O)=>{const q=it.normalizeMultiInputPayload(O);r(U=>({...U,[Y]:q}))},[]),z=(G=h.customCardPreferences)==null?void 0:G.componentName,L=z?m(z):null,$=Rj((Z=h.customCardPreferences)==null?void 0:Z.settings,h),H=v.useMemo(()=>it.buildSlotOrderedCards(y),[y]),M=v.useMemo(()=>H.map((Y,O)=>it.getEffectiveCardTypeForSlot(Y,O,b==null?void 0:b.slots)),[H,b==null?void 0:b.slots]),B=v.useMemo(()=>$$(x==="multiple"?L$({slotOrderedCards:H,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,H,x,t]);return z?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[L&&x==="single"&&l.jsx(L,{editing:!0,params:s,theme:a,settings:$,cardMetadata:oue({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:F,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:B,filters:R,filterValues:[...A||[],...u||[]],inlineFilters:D}),L&&x==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((Y,O)=>{if(!Y)return null;const q=it.getSlotIndexForCard(Y,O),U=it.getEffectiveCardTypeForSlot(Y,q,b==null?void 0:b.slots);return l.jsx(a$,{onDataChange:F,card:Y,effectiveCardType:U},`${Y.id}-${q}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(L,{editing:!0,onDataChange:F,...O$({configCard:h,slotOrderedCards:H,slotTypes:M,multiInputData:n,params:s,theme:a,chartSettings:$,filters:R,filterValues:[...A||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:B})})})]})]},(X=h.customCardPreferences)==null?void 0:X.componentName)}):null}const rIt=v.memo(nIt),oIt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var wxe=["PageUp","PageDown"],Cxe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Sxe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ax="Slider",[eO,sIt,iIt]=p.createCollection(ax),[Nxe]=p.createContextScope(ax,[iIt]),[aIt,LT]=Nxe(ax),jxe=te.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:g,...b}=e,x=te.useRef(new Set),y=te.useRef(0),C=i==="horizontal"?lIt:cIt,[N=[],S]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var R;(R=[...x.current][y.current])==null||R.focus(),f(E)}}),j=te.useRef(N);function _(E){const D=mIt(N,E);I(E,D)}function k(E){I(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function I(E,D,{commit:R}={commit:!1}){const A=xIt(s),F=yIt(Math.round((E-r)/s)*s+r,A),z=p.clamp(F,[r,o]);S((L=[])=>{const $=fIt(L,z,D);if(bIt($,c*s)){y.current=$.indexOf(z);const H=String($)!==String(L);return H&&R&&h($),H?$:L}else return L})}return l.jsx(aIt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:N,orientation:i,form:g,children:l.jsx(eO.Provider,{scope:e.__scopeSlider,children:l.jsx(eO.Slot,{scope:e.__scopeSlider,children:l.jsx(C,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:p.composeEventHandlers(b.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:_,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&I(r,0,{commit:!0}),onEndKeyDown:()=>!a&&I(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const F=wxe.includes(E.key)||E.shiftKey&&Cxe.includes(E.key)?10:1,z=y.current,L=N[z],$=s*F*D;I(L+$,z,{commit:!0})}}})})})})});jxe.displayName=ax;var[kxe,_xe]=Nxe(ax,{startEdge:"left",endEdge:"right",size:"width",direction:1}),lIt=te.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=te.useState(null),m=p.useComposedRefs(t,C=>h(C)),g=te.useRef(void 0),b=p.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(C){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],_=Y4(S,y?[n,r]:[r,n]);return g.current=N,_(C-N.left)}return l.jsx(kxe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(Ixe,{dir:b,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const N=w(C.clientX);i==null||i(N)},onSlideMove:C=>{const N=w(C.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:C=>{const S=Sxe[y?"from-left":"from-right"].includes(C.key);u==null||u({event:C,direction:S?-1:1})}})})}),cIt=te.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=te.useRef(null),f=p.useComposedRefs(t,d),h=te.useRef(void 0),m=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],C=Y4(y,m?[r,n]:[n,r]);return h.current=x,C(b-x.top)}return l.jsx(kxe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(Ixe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=Sxe[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),Ixe=te.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=LT(ax,n);return l.jsx(p.Primitive.span,{...u,ref:t,onKeyDown:p.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):wxe.concat(Cxe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:p.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:p.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),Txe="SliderTrack",Exe=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=LT(Txe,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});Exe.displayName=Txe;var tO="SliderRange",Dxe=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=LT(tO,n),s=_xe(tO,n),i=te.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>Axe(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});Dxe.displayName=tO;var nO="SliderThumb",Mxe=te.forwardRef((e,t)=>{const n=sIt(e.__scopeSlider),[r,o]=te.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=te.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(uIt,{...e,ref:s,index:i})}),uIt=te.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=LT(nO,n),a=_xe(nO,n),[c,u]=te.useState(null),d=p.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=p.useSize(c),m=i.values[r],g=m===void 0?0:Axe(m,i.min,i.max),b=hIt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?pIt(x,g,a.direction):0;return te.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(eO.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(p.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(Rxe,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});Mxe.displayName=nO;var dIt="RadioBubbleInput",Rxe=te.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=te.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return te.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(p.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});Rxe.displayName=dIt;function fIt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function Axe(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function hIt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function mIt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function pIt(e,t,n){const r=e/2,s=Y4([0,50],[0,r]);return(r-s(t)*n)*n}function gIt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function bIt(e,t){if(t>0){const n=gIt(e);return Math.min(...n)>=t}return!0}function Y4(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function xIt(e){return(String(e).split(".")[1]||"").length}function yIt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Pxe=jxe,vIt=Exe,wIt=Dxe,CIt=Mxe;const Fxe=te.forwardRef(({className:e,...t},n)=>l.jsxs(Pxe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(vIt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(wIt,{className:"absolute h-full bg-primary"})}),l.jsx(CIt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Fxe.displayName=Pxe.displayName;exports.Accordion=Jz;exports.AccordionContent=mv;exports.AccordionItem=fv;exports.AccordionTrigger=hv;exports.AddDataPicker=B4;exports.AggregateTable=hI;exports.Alert=rL;exports.AlertDescription=oL;exports.AlertDialog=ff;exports.AlertDialogAction=Du;exports.AlertDialogCancel=Mu;exports.AlertDialogContent=ku;exports.AlertDialogDescription=Eu;exports.AlertDialogFooter=Iu;exports.AlertDialogHeader=_u;exports.AlertDialogTitle=Tu;exports.AlertDialogTrigger=JSe;exports.AlertTitle=mte;exports.ArrowDown=es;exports.ArrowDownIcon=dQe;exports.ArrowLeft=zv;exports.ArrowRight=Bv;exports.ArrowUp=bs;exports.ArrowUpIcon=hQe;exports.AssistantContextEntityControls=YF;exports.AssistantVirtualizedMessages=nxe;exports.AxisConfigurator=Wm;exports.BackgroundRunPill=kct;exports.Badge=mi;exports.Bell=h1;exports.BookType=oZ;exports.BriefingAuthor=Pfe;exports.BriefingAuthorDialog=Ffe;exports.BriefingUiCapabilitiesBoundary=Gct;exports.BriefingUiCapabilitiesProvider=JI;exports.BriefingsApiError=Uw;exports.BulletChartIcon=Gbe;exports.CSS=Ki;exports.CalculatedFieldEditor=fme;exports.Calculator=iZ;exports.Calendar=za;exports.CalendarClock=SO;exports.Card=hN;exports.CardContent=CO;exports.CardHeader=wO;exports.CardSummary=tF;exports.CardTitle=cb;exports.ChartArea=fR;exports.ChartColumnIncreasing=lZ;exports.ChartColumnStacked=cZ;exports.ChartJsVisual=Tw;exports.ChartLine=uZ;exports.ChartNoAxesGantt=fZ;exports.ChartPie=hZ;exports.ChartScatter=mZ;exports.ChatInputWithContext=V4;exports.Checkbox=Tn;exports.ChevronLeft=Mm;exports.ChevronsUpDown=bZ;exports.Circle=NO;exports.CircleAlert=Ca;exports.CircleCheck=xZ;exports.CircleHelp=yZ;exports.Clock=vZ;exports.CodeHighlighter=Fd;exports.CodeXml=m1;exports.Collapsible=vu;exports.CollapsibleContent=Cu;exports.CollapsibleTrigger=wu;exports.ColorField=da;exports.Command=cT;exports.CommandEmpty=dT;exports.CommandGroup=fT;exports.CommandInput=Bz;exports.CommandItem=hT;exports.CommandList=uT;exports.CommandSeparator=Dhe;exports.ComparisonMetadataBadge=Foe;exports.Container=JO;exports.ControlDefaultValueEditor=Pme;exports.ControlDefinitionOptionsEditor=Ame;exports.ControlIdInput=Eme;exports.ControlVisibilitySettings=fgt;exports.Copy=Jh;exports.CopyButton=Pd;exports.CopyPlus=mR;exports.Cross2Icon=bQe;exports.CustomFilterPopover=A$;exports.CustomScrollArea=hl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Are;exports.Dashboard=uxe;exports.DashboardCard=zfe;exports.DashboardCreateDialogBase=hQ;exports.DashboardExportDialog=rxe;exports.DashboardPlus=C_t;exports.DashboardWC=V_t;exports.DataTableConditionalFormattingSettings=Npe;exports.DataTablePagination=rI;exports.Database=ss;exports.DateRangePicker=E$;exports.DefaultChatTransport=M4;exports.Dialog=Mo;exports.DialogContent=go;exports.DialogDescription=Ro;exports.DialogFooter=tl;exports.DialogHeader=Is;exports.DialogTitle=bo;exports.DialogTrigger=uQ;exports.DisplayFormatPreferencesFields=k_t;exports.DisplayPreferencesProvider=HI;exports.DndContext=nC;exports.Donut=wZ;exports.Download=Su;exports.DownloadPdf=oxe;exports.DragOverlay=bhe;exports.DropdownMenu=Uo;exports.DropdownMenuCheckboxItem=nd;exports.DropdownMenuContent=Do;exports.DropdownMenuItem=kn;exports.DropdownMenuLabel=qa;exports.DropdownMenuRadioGroup=iCe;exports.DropdownMenuRadioItem=FX;exports.DropdownMenuSeparator=Sa;exports.DropdownMenuSub=qO;exports.DropdownMenuSubContent=$k;exports.DropdownMenuSubTrigger=Lk;exports.DropdownMenuTrigger=Wo;exports.EMPTY_DATA_SOURCE=sb;exports.Editable=Pj;exports.EditableText=xi;exports.EditorCustomVisual=rIt;exports.Ellipsis=Ci;exports.EllipsisVertical=Rm;exports.ErrorBoundary=Si;exports.ExportError=kb;exports.ExternalLink=Ld;exports.EyeOff=Ak;exports.Fallback=BI;exports.FallbackVisual=Vw;exports.FeedbackCategory=lf;exports.FeedbackDialog=jv;exports.FieldsList=a4;exports.FieldsSection=H_t;exports.FileCode=CZ;exports.FileText=Qs;exports.Filter=$d;exports.FilterComponent=FI;exports.FilterInfo=XP;exports.FilterableFieldsPanel=mme;exports.Grid3x3=pR;exports.GripVertical=Nu;exports.HEATMAP_PRESET_PALETTES=_A;exports.Hash=ub;exports.House=SZ;exports.HoverCard=Xm;exports.HoverCardContent=bu;exports.HoverCardTrigger=Yd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=vxe;exports.INLINE_ALLOWED_TOOL_LIST=Q_t;exports.INLINE_BLOCKED_MUTATING_TOOLS=X_t;exports.IconButton=nu;exports.IconForFieldType=Q1;exports.Inbox=kO;exports.InfoHover=J$;exports.InlineFilterBar=Rue;exports.KPICard=tf;exports.KeyboardSensor=eC;exports.Layers=Pm;exports.Link=_O;exports.LoadingDots=xu;exports.MAX_SELF_HEAL_ATTEMPTS=J_t;exports.Map=_Z;exports.Markdown=Sz;exports.MatrixTableVisual=fI;exports.MdStackedLineChart=Wbe;exports.MultiInputEmptyRenderer=a$;exports.PanelResizeHandle=ET;exports.Pause=IZ;exports.PenLine=xR;exports.Pencil=yR;exports.PendingMessagesDisplay=Fbe;exports.PersistedDynamicVisual=VI;exports.PiChartPolar=Vbe;exports.Pin=EZ;exports.PinOff=TZ;exports.PivotTableTanstack=Wb;exports.Placeholders=Xpe;exports.Play=DZ;exports.Plus=Tr;exports.PointerSensor=Jb;exports.Progress=L4;exports.PythonEditor=Z_t;exports.RECOVERABLE_SQL_ERROR_CODES=tIt;exports.Radar=MZ;exports.RadioGroup=rl;exports.RadioGroupItem=vs;exports.RefreshCw=tc;exports.ResizableHandle=k0t;exports.ResizablePanel=OF;exports.ResizablePanelGroup=Zpe;exports.ResourceEditDialog=HQ;exports.ResourceType=lo;exports.Rows3=RZ;exports.RunCompletionBanner=_ct;exports.SELF_HEAL_TIMELINE_STEP=eIt;exports.SeedQuestions=wbe;exports.SemaphorContext=Av;exports.SemaphorContextProvider=uO;exports.SemaphorQueryClient=kY;exports.SemaphorReadyIndicator=W4;exports.SemaphorStyleWrapper=Kb;exports.Send=TO;exports.SendHorizontal=AZ;exports.Settings=EO;exports.Settings2=Fm;exports.Share2=PZ;exports.ShareDialog=VQ;exports.Sheet=a3;exports.SheetContent=oI;exports.SheetDescription=iI;exports.SheetHeader=koe;exports.SheetTitle=sI;exports.SheetTrigger=Wze;exports.Slider=Fxe;exports.SortableContext=rC;exports.Sparkles=p0;exports.SqlEditor=K_t;exports.Square=MO;exports.SquarePen=DO;exports.Star=FZ;exports.StructuralParticipantSelector=Dme;exports.SummaryCard=GP;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Rd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=ha;exports.TableBody=Gd;exports.TableCell=qn;exports.TableColumnVisibilitySettings=fpe;exports.TableHead=mo;exports.TableHeader=Zm;exports.TablePresentationSettings=mpe;exports.TableRow=Ar;exports.TableSkeleton=tz;exports.TableVisual=Zd;exports.Tag=OZ;exports.TbChartBubble=Hbe;exports.TbChartFunnel=qbe;exports.TbChartTreemap=Ube;exports.TextCard=Xg;exports.Textarea=zm;exports.TiSortNumerically=Kbe;exports.Toggle=xxe;exports.Tornado=LZ;exports.Trash2=el;exports.TriangleAlert=Zs;exports.TypeGlyph=Yw;exports.UXProvider=U4;exports.Undo2=$Z;exports.User=AO;exports.Users=Pk;exports.UsersRound=PO;exports.VisualErrorState=yue;exports.Zap=vR;exports.applyBriefingFormPatch=rv;exports.areContextEntitiesEqual=ar;exports.areEntitiesJoined=Lre;exports.arrayMove=ex;exports.briefingFormDraftToCreateRequest=rF;exports.briefingFormDraftToUpdateRequest=pde;exports.briefingToFormDraft=Qp;exports.briefingTone=_r;exports.buildCardControlUsageById=mgt;exports.buildCustomCardTheme=Aw;exports.buildDashboardControlUsageById=hgt;exports.buildDashboardSheetsInputExecutionSnapshot=vO;exports.buildDashboardStructuralParticipantIdsByControlId=Lme;exports.buildFilterFieldMeta=Kz;exports.buildFilterSemanticContext=Gz;exports.buildInlineFilterNodes=F$;exports.buildMultiInputCustomVisualProps=O$;exports.buildMultiInputTemporalPresentationInputs=L$;exports.calculateCardFilterValues=S5;exports.calculateContextAwareFilters=Qv;exports.calculateFieldState=GL;exports.canUserAccessVisuals=sNe;exports.canUserCreateDashboards=WQ;exports.canUserEdit=nNe;exports.canUserManageDashboards=oNe;exports.canUserManageGroups=iNe;exports.canUserUseFilters=rNe;exports.cancelBriefingPreviewRun=rde;exports.cancelBriefingRun=sde;exports.cancelExport=r$e;exports.chartSupportsDataLabels=Dne;exports.chartSupportsLegend=Tne;exports.chartTypes=OT;exports.cleanupKpiMetricComparisonMode=zhe;exports.cloneDeep=Ks;exports.cloneLinkedFrameWithSourceMapping=Iet;exports.closestCenter=Jw;exports.commitSharedCalculatedFields=Jf;exports.createAssistantConversationId=Hp;exports.createAssistantRequestId=ybe;exports.createBriefing=Yue;exports.createBriefingFormDraft=nF;exports.createChartConfig=Nb;exports.createCustomVisualTemporalBucketFormatter=$$;exports.createDashboardControlInputFromControl=hyt;exports.createExport=toe;exports.createUniqueDashboardInputVariableNameFromName=Od;exports.currencyPresentationTargetKey=ba;exports.dedup=wNt;exports.dedupeContextEntities=Dz;exports.deleteBriefing=Que;exports.deleteBriefingRun=ide;exports.diagnoseCurrencyPresentationBindings=y0e;exports.doesStoredFilterMatchField=rb;exports.downloadDocumentPdf=Q5;exports.downloadPdf=Uee;exports.extractSqlParamReferences=IY;exports.extractTableMetadata=Wz;exports.fieldAlreadyExists=zre;exports.flexRender=gi;exports.flushPendingEditorDrafts=K4;exports.formatDisplayFormula=cmt;exports.formatFileSize=i$e;exports.getAutoDetectedChartIcon=Xjt;exports.getBriefing=Gue;exports.getBriefingArtifact=Ttt;exports.getBriefingEvidence=Ett;exports.getBriefingPreviewRun=nde;exports.getBriefingRun=ode;exports.getCardCurrencyPresentationFields=pO;exports.getCardCurrencyPresentationTargets=gO;exports.getChartGridStyle=eDe;exports.getChartIconByType=Qjt;exports.getColorForValue=BR;exports.getCoreRowModel=eI;exports.getDefaultAxisConfig=WR;exports.getDefaultChartColors=Um;exports.getDefaultDataLabelsConfig=dw;exports.getDefaultLegendConfig=EL;exports.getDefaultRunningTotalPartitionByFieldIds=l0;exports.getDisplayedKpiResultColumnKeys=mw;exports.getDocumentSectionEditorCard=Wpt;exports.getDocumentSheetDashboardInputs=rx;exports.getDownloadUrl=n$e;exports.getEntityIcon=Nk;exports.getErrorMessage=sbe;exports.getExportStatus=t$e;exports.getExports=e$e;exports.getExpressionFieldKind=rf;exports.getFieldExpressionAnnotation=Yz;exports.getFilterCount=zj;exports.getGranularityOptionsForFieldType=Tme;exports.getKeys=yr;exports.getMatrixVisualLoadingState=X_;exports.getMetricDisplayLabel=g3e;exports.getNewField=Ure;exports.getObjectDiff=iY;exports.getPaginationRowModel=tI;exports.getRoleBasedDisplayOverrides=UQ;exports.getRunningTotalOrderByCandidates=Mht;exports.getSelectedDateFilterColumn=Uce;exports.getSortedRowModel=Soe;exports.getTableConditionalFormattingColumnOptions=xpe;exports.getTableOutputColumnOptions=ype;exports.getTablePageSizeOptions=Jre;exports.handleAggregationChange=QP;exports.handleAggregationLabelChange=Due;exports.hasFlatTableTotalsBehavior=qm;exports.hasMatrixResultData=gw;exports.horizontalListSortingStrategy=Oz;exports.inferSemanticDomainIdFromSelectedEntities=Sk;exports.isActiveBriefingRunStatus=Wj;exports.isCardSummaryVisibleOnCard=z$;exports.isCurrencyPresentationControl=b0e;exports.isDefaultColor=xTe;exports.isEligibleFlatTableTotalsCard=rw;exports.isExportComplete=s$e;exports.isExportInProgress=o$e;exports.isInAiScopeArray=vNt;exports.isManagedCalculatedExpressionField=Qa;exports.isMetricTransformEnabled=Eht;exports.isPresentationCurrencyBinding=Ov;exports.isPromiseLike=GF;exports.isSqlBackedKpi=Wre;exports.isStructuralControlBinding=g0e;exports.isSubtotalEnabledAggregateTable=Uz;exports.isSupportedDocumentTableCardType=Kpt;exports.isTableType=zEe;exports.isTerminalBriefingRunStatus=Uj;exports.lastAssistantMessageIsCompleteWithToolCalls=tbe;exports.listBriefingRuns=Itt;exports.listBriefingTenantSummaries=_tt;exports.listBriefings=ktt;exports.merge=Jl;exports.mergeAxisConfig=KR;exports.normalizeConditionalFormatting=A5;exports.normalizeContextFormatMode=yee;exports.normalizeDashboardInputVariableName=Lv;exports.pauseBriefing=Zue;exports.pivotData=sw;exports.polishBriefingText=ade;exports.prepareFeedbackData=FT;exports.previewBriefingPlan=ede;exports.remarkGfm=_z;exports.removeFromScopeArray=CNt;exports.requiresDashboardInputResolution=uf;exports.resolveCurrencyPresentationTargetFormat=See;exports.resolveDashboardBriefingsVisibility=Ofe;exports.resolveDashboardControlsVisibility=uNe;exports.resolveDashboardInputContext=Yi;exports.resolveDashboardTitleEditability=cNe;exports.resolveDomainCalculatedFieldForEdit=opt;exports.resolveMatrixCardMeasureInstances=Mk;exports.resolvePendingPivotTableResultState=q3e;exports.resolveTablePageSize=G_;exports.resolveTablePresentationStyle=p3;exports.resumeBriefing=Xue;exports.runBriefingNow=Jue;exports.runBriefingPreview=tde;exports.sanitizeAIScope=obe;exports.saveCalculatedFieldToCardScope=IF;exports.saveCalculatedFieldToSharedScope=hme;exports.saveCalculatedFieldToSheetScope=TF;exports.seedSemanticMetricFormatDefaults=Vhe;exports.setTableColumnVisibility=ooe;exports.setupEditorWithCard=S_;exports.showAllTableColumns=g$e;exports.showJoinRequiredNotification=$re;exports.sortByColumnsToSortState=Woe;exports.sortStateToSortByColumns=Koe;exports.sortableKeyboardCoordinates=$z;exports.supportsLiveNumericPresentation=Fv;exports.supportsMetricTransformForMetric=Bhe;exports.supportsTableConditionalFormatting=ppe;exports.toEntityArray=Xa;exports.ue=lt;exports.updateBriefing=UI;exports.useActiveExports=gNe;exports.useActiveToolStatus=Lbe;exports.useAddFrameWithFreshSemanticExecutionPayload=Q$;exports.useAddNewFrame=Kfe;exports.useAssistantContainer=ZQ;exports.useAssistantContextEntities=eT;exports.useAssistantLayoutStore=Mh;exports.useAssistantPanel=GQ;exports.useAssistantProfile=vbe;exports.useAutoSubmitQueue=Obe;exports.useBrandStudioPreview=c_t;exports.useBriefingRunPolling=sF;exports.useBriefingUiCapabilities=Lfe;exports.useCalendarContext=_3e;exports.useCard=A3e;exports.useCardNumericPresentation=Ta;exports.useCardSummary=B$;exports.useChartNumericPresentation=jb;exports.useChat=rbe;exports.useColumns=Vz;exports.useCreateVisualWithFrame=nSe;exports.useCurrentUserInfo=ti;exports.useCustomVisual=Nf;exports.useCustomVisualsQuery=R$;exports.useDashboardAppearance=Ru;exports.useDashboardById=UX;exports.useDashboardInteractionMode=Iue;exports.useDashboardPreferences=Lm;exports.useDashboardQuery=Pv;exports.useDashboardStructuralParticipants=$me;exports.useDashboardSummary=due;exports.useDataColumns=qhe;exports.useDateFilterHook=VGe;exports.useDefaultDashboardMutation=LX;exports.useDisplayPreferences=cl;exports.useDroppable=ghe;exports.useEditorAside=mT;exports.useEditorCardQuery=pb;exports.useEffectiveEditorCardType=G4;exports.useEnsureReactGlobals=ble;exports.useExportActions=XQ;exports.useExportStore=Gk;exports.useFieldManagement=Hhe;exports.useFilterableFields=Ohe;exports.useFullscreenAssistant=YQ;exports.useGroupMembers=o1e;exports.useGroups=XO;exports.useHasDashboardId=QQ;exports.useInProgressExportsCount=bNe;exports.useJoinabilityMap=qz;exports.useManagementActions=Dm;exports.useManagementStore=_s;exports.useMutation=ks;exports.usePivotTableConfig=Gm;exports.usePluginQuery=Jce;exports.useQuery=Un;exports.useQueryClient=Wr;exports.useReactTable=nI;exports.useResolveExistingFrameSemanticExecutionPayload=Met;exports.useResolvedDefaultCurrency=XL;exports.useResolvedTemporalStylePreferences=fl;exports.useResolvedValueFormatLocale=ZL;exports.useResourceManagement=WO;exports.useResourceUpdateState=WX;exports.useScopedFields=Fhe;exports.useSelectedVisual=n0e;exports.useSemaphorContext=It;exports.useSensor=nb;exports.useSensors=oT;exports.useSortable=tx;exports.useStarredChartsStore=oIt;exports.useSurfaceAppearance=dc;exports.useTableQueryState=Ooe;exports.useTextFilterHook=bUe;exports.useTheme=oO;exports.useTimezone=dl;exports.useTopoJson=hw;exports.useUnifiedUsers=Wk;exports.useUpdateResource=BX;exports.useUpdateVisualMutation=rSe;exports.useUserPreferences=mQ;exports.useVisualById=Bk;exports.useVisualManagement=tSe;exports.validateBriefingFormDraft=oF;exports.validateFieldForChartType=$he;exports.verticalListSortingStrategy=Lz;