react-semaphor 0.1.419 → 0.1.421
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +28 -27
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +2 -2
- package/dist/chunks/analyze-result-contract-B5Eeu7vD.js +1 -0
- package/dist/chunks/analyze-result-contract-sWcmvBOA.js +2070 -0
- package/dist/chunks/{calendar-preferences-dialog-f0Z7Kf-U.js → calendar-preferences-dialog-CscmhyuZ.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DIfAbE_y.js → calendar-preferences-dialog-cN3_2C-u.js} +3 -3
- package/dist/chunks/{dashboard-briefing-launcher-anh-Jy5v.js → dashboard-briefing-launcher-BYTBNetR.js} +4 -4
- package/dist/chunks/{dashboard-briefing-launcher-C3tNkGFG.js → dashboard-briefing-launcher-DmZkzIC3.js} +1 -1
- package/dist/chunks/{dashboard-controls-DQxlOxzy.js → dashboard-controls-9DFeKIP4.js} +1 -1
- package/dist/chunks/{dashboard-controls-8dCQaPaq.js → dashboard-controls-PhzuaTBj.js} +5 -5
- package/dist/chunks/{dashboard-json-i7Ae9KGD.js → dashboard-json-Cxhw2TZc.js} +3 -3
- package/dist/chunks/{dashboard-json-B309EInF.js → dashboard-json-DyRHI3mL.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-4HycwBHR.js → edit-dashboard-visual-3_jiBXsu.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-z3IqzYnj.js → edit-dashboard-visual-BigSJ3-x.js} +4 -4
- package/dist/chunks/{index-yxKWKFdr.js → index-BKDQw0aK.js} +2 -2
- package/dist/chunks/{index-B6DLEXRX.js → index-CH2ZzQo4.js} +5 -5
- package/dist/chunks/{switch-D6Ygf3wA.js → switch-CiOjVyVI.js} +1 -1
- package/dist/chunks/{switch-COWQU8aK.js → switch-TbCsyhv9.js} +1 -1
- package/dist/chunks/{update-policy-BzT2k4n6.js → update-policy-2MZ-Vf7v.js} +211 -187
- package/dist/chunks/update-policy-qpyAkOyO.js +3 -0
- package/dist/chunks/{use-create-flow-overlay-state-CX0D-6HM.js → use-create-flow-overlay-state-BzcJWNzh.js} +3 -3
- package/dist/chunks/{use-create-flow-overlay-state-DENfd7sW.js → use-create-flow-overlay-state-DUQmgb9H.js} +1 -1
- package/dist/chunks/{validators-Cxr9qbrR.js → validators-D0pfj3jJ.js} +93 -93
- package/dist/chunks/validators-Dj1Y-46V.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +14 -14
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +251 -139
- package/dist/data-app-codegen-node/index.js +806 -657
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +743 -693
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +51 -51
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +12 -5
- package/dist/types/dashboard-assistant.d.ts +0 -5
- package/dist/types/data-app-codegen-node.d.ts +12 -2
- package/dist/types/data-app-codegen.d.ts +12 -2
- package/dist/types/data-app-sdk-validation.d.ts +0 -5
- package/dist/types/data-app-sdk.d.ts +17 -5
- package/package.json +1 -1
- package/dist/chunks/analyze-result-contract-DdhEt99q.js +0 -2004
- package/dist/chunks/analyze-result-contract-DwRzl7yJ.js +0 -1
- package/dist/chunks/update-policy-VloD-0YM.js +0 -3
- package/dist/chunks/validators-BMQo93Y0.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Phe=Object.defineProperty;var l$=e=>{throw TypeError(e)};var Fhe=(e,t,n)=>t in e?Phe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>Fhe(e,typeof t!="symbol"?t+"":t,n),Jj=(e,t,n)=>t.has(e)||l$("Cannot "+n);var he=(e,t,n)=>(Jj(e,t,"read from private field"),n?n.call(e):t.get(e)),kt=(e,t,n)=>t.has(e)?l$("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ft=(e,t,n,r)=>(Jj(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ht=(e,t,n)=>(Jj(e,t,"access private method"),n);var rw=(e,t,n,r)=>({set _(o){ft(e,t,o,n)},get _(){return he(e,t,r)}});const l=require("react/jsx-runtime"),S=require("react"),br=require("react-dom"),p=require("./switch-
|
|
1
|
+
"use strict";var Phe=Object.defineProperty;var l$=e=>{throw TypeError(e)};var Fhe=(e,t,n)=>t in e?Phe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ve=(e,t,n)=>Fhe(e,typeof t!="symbol"?t+"":t,n),Jj=(e,t,n)=>t.has(e)||l$("Cannot "+n);var he=(e,t,n)=>(Jj(e,t,"read from private field"),n?n.call(e):t.get(e)),kt=(e,t,n)=>t.has(e)?l$("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ft=(e,t,n,r)=>(Jj(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ht=(e,t,n)=>(Jj(e,t,"access private method"),n);var rw=(e,t,n,r)=>({set _(o){ft(e,t,o,n)},get _(){return he(e,t,r)}});const l=require("react/jsx-runtime"),S=require("react"),br=require("react-dom"),p=require("./switch-CiOjVyVI.js"),Te=require("./x-B6ghREd2.js"),Ohe=require("./analyze-result-contract-B5Eeu7vD.js"),kc=require("./index-DRlMUglg.js"),Lhe=require("react-dom/client"),Pt=require("./search-DNCejM7Z.js"),$he=require("../types/index.cjs"),$n=require("./date-formatter-B4EBSe9C.js"),Sq=require("./catalog-field-grounding-Bnx-3tE0.js"),nn=require("./index-D7KJindZ.js"),Ss=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),lr=require("./common-types-C73-Ud1-.js"),Cq=require("../dashboard-assistant/index.cjs"),zhe=require("./contracts-CtB2VONT.js"),Bhe=require("../layouts/index.cjs");function zR(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 c$=zR(l),Q=zR(S),UD=zR(br),BR=`import pandas as pd
|
|
2
2
|
df = pd.DataFrame(data) # 'data' contains the query result
|
|
3
3
|
result = df.to_dict('records') # must return 'result' as [dict] type
|
|
4
4
|
`;function Vhe(e){return nn.toDate(e).getMonth()}function Hhe(e){return nn.toDate(e).getFullYear()}function V1(e,t){const r=Ghe(e);let o;if(r.date){const c=Yhe(r.date,2);o=Khe(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=Zhe(r.time),isNaN(i)))return new Date(NaN);if(r.timezone){if(a=Xhe(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 ow={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Uhe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,qhe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Whe=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ghe(e){const t={},n=e.split(ow.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],ow.timeZoneDelimiter.test(t.date)&&(t.date=e.split(ow.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const o=ow.timezone.exec(r);o?(t.time=r.replace(o[1],""),t.timezone=o[1]):t.time=r}return t}function Yhe(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 Khe(e,t){if(t===null)return new Date(NaN);const n=e.match(Uhe);if(!n)return new Date(NaN);const r=!!n[4],o=ob(n[1]),s=ob(n[2])-1,i=ob(n[3]),a=ob(n[4]),c=ob(n[5])-1;if(r)return nme(t,a,c)?Qhe(t,a,c):new Date(NaN);{const u=new Date(0);return!eme(t,s,i)||!tme(t,o)?new Date(NaN):(u.setUTCFullYear(t,s,Math.max(o,i)),u)}}function ob(e){return e?parseInt(e):1}function Zhe(e){const t=e.match(qhe);if(!t)return NaN;const n=eT(t[1]),r=eT(t[2]),o=eT(t[3]);return rme(n,r,o)?n*nn.millisecondsInHour+r*nn.millisecondsInMinute+o*1e3:NaN}function eT(e){return e&&parseFloat(e.replace(",","."))||0}function Xhe(e){if(e==="Z")return 0;const t=e.match(Whe);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),o=t[3]&&parseInt(t[3])||0;return ome(r,o)?n*(r*nn.millisecondsInHour+o*nn.millisecondsInMinute):NaN}function Qhe(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 Jhe=[31,null,31,30,31,30,31,31,30,31,30,31];function Nq(e){return e%400===0||e%4===0&&e%100!==0}function eme(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Jhe[t]||(Nq(e)?29:28))}function tme(e,t){return t>=1&&t<=(Nq(e)?366:365)}function nme(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function rme(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function ome(e,t){return t>=0&&t<=59}var H1={exports:{}};H1.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]",v="[object Proxy]",C="[object RegExp]",N="[object Set]",_="[object String]",k="[object Undefined]",j="[object WeakMap]",I="[object ArrayBuffer]",T="[object DataView]",E="[object Float32Array]",D="[object Float64Array]",A="[object Int8Array]",P="[object Int16Array]",M="[object Int32Array]",L="[object Uint8Array]",$="[object Uint8ClampedArray]",z="[object Uint16Array]",W="[object Uint32Array]",F=/[\\^$.*+?()[\]{}|]/g,X=/^\[object .+?Constructor\]$/,Y=/^(?:0|[1-9]\d*)$/,R={};R[E]=R[D]=R[A]=R[P]=R[M]=R[L]=R[$]=R[z]=R[W]=!0,R[a]=R[c]=R[I]=R[d]=R[T]=R[f]=R[h]=R[m]=R[b]=R[x]=R[w]=R[C]=R[N]=R[_]=R[j]=!1;var K=typeof p.commonjsGlobal=="object"&&p.commonjsGlobal&&p.commonjsGlobal.Object===Object&&p.commonjsGlobal,O=typeof self=="object"&&self&&self.Object===Object&&self,U=K||O||Function("return this")(),V=t&&!t.nodeType&&t,H=V&&!0&&e&&!e.nodeType&&e,q=H&&H.exports===V,B=q&&K.process,G=function(){try{var de=H&&H.require&&H.require("util").types;return de||B&&B.binding&&B.binding("util")}catch{}}(),Z=G&&G.isTypedArray;function J(de,ke,Le){switch(Le.length){case 0:return de.call(ke);case 1:return de.call(ke,Le[0]);case 2:return de.call(ke,Le[0],Le[1]);case 3:return de.call(ke,Le[0],Le[1],Le[2])}return de.apply(ke,Le)}function oe(de,ke){for(var Le=-1,Dt=Array(de);++Le<de;)Dt[Le]=ke(Le);return Dt}function ie(de){return function(ke){return de(ke)}}function ue(de,ke){return de==null?void 0:de[ke]}function xe(de,ke){return function(Le){return de(ke(Le))}}var te=Array.prototype,ye=Function.prototype,se=Object.prototype,Ie=U["__core-js_shared__"],fe=ye.toString,me=se.hasOwnProperty,we=function(){var de=/[^.]+$/.exec(Ie&&Ie.keys&&Ie.keys.IE_PROTO||"");return de?"Symbol(src)_1."+de:""}(),ee=se.toString,re=fe.call(Object),ne=RegExp("^"+fe.call(me).replace(F,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=q?U.Buffer:void 0,ae=U.Symbol,Ne=U.Uint8Array;ce&&ce.allocUnsafe;var Ee=xe(Object.getPrototypeOf,Object),Ve=Object.create,ge=se.propertyIsEnumerable,pe=te.splice,$e=ae?ae.toStringTag:void 0,Fe=function(){try{var de=Or(Object,"defineProperty");return de({},"",{}),de}catch{}}(),ze=ce?ce.isBuffer:void 0,Ze=Math.max,Je=Date.now,Ce=Or(U,"Map"),Qe=Or(Object,"create"),He=function(){function de(){}return function(ke){if(!Nd(ke))return{};if(Ve)return Ve(ke);de.prototype=ke;var Le=new de;return de.prototype=void 0,Le}}();function _e(de){var ke=-1,Le=de==null?0:de.length;for(this.clear();++ke<Le;){var Dt=de[ke];this.set(Dt[0],Dt[1])}}function Me(){this.__data__=Qe?Qe(null):{},this.size=0}function De(de){var ke=this.has(de)&&delete this.__data__[de];return this.size-=ke?1:0,ke}function je(de){var ke=this.__data__;if(Qe){var Le=ke[de];return Le===r?void 0:Le}return me.call(ke,de)?ke[de]:void 0}function Ue(de){var ke=this.__data__;return Qe?ke[de]!==void 0:me.call(ke,de)}function mt(de,ke){var Le=this.__data__;return this.size+=this.has(de)?0:1,Le[de]=Qe&&ke===void 0?r:ke,this}_e.prototype.clear=Me,_e.prototype.delete=De,_e.prototype.get=je,_e.prototype.has=Ue,_e.prototype.set=mt;function pt(de){var ke=-1,Le=de==null?0:de.length;for(this.clear();++ke<Le;){var Dt=de[ke];this.set(Dt[0],Dt[1])}}function ut(){this.__data__=[],this.size=0}function ht(de){var ke=this.__data__,Le=it(ke,de);if(Le<0)return!1;var Dt=ke.length-1;return Le==Dt?ke.pop():pe.call(ke,Le,1),--this.size,!0}function nt(de){var ke=this.__data__,Le=it(ke,de);return Le<0?void 0:ke[Le][1]}function At(de){return it(this.__data__,de)>-1}function Ae(de,ke){var Le=this.__data__,Dt=it(Le,de);return Dt<0?(++this.size,Le.push([de,ke])):Le[Dt][1]=ke,this}pt.prototype.clear=ut,pt.prototype.delete=ht,pt.prototype.get=nt,pt.prototype.has=At,pt.prototype.set=Ae;function Ke(de){var ke=-1,Le=de==null?0:de.length;for(this.clear();++ke<Le;){var Dt=de[ke];this.set(Dt[0],Dt[1])}}function et(){this.size=0,this.__data__={hash:new _e,map:new(Ce||pt),string:new _e}}function at(de){var ke=Xt(this,de).delete(de);return this.size-=ke?1:0,ke}function vt(de){return Xt(this,de).get(de)}function zt(de){return Xt(this,de).has(de)}function It(de,ke){var Le=Xt(this,de),Dt=Le.size;return Le.set(de,ke),this.size+=Le.size==Dt?0:1,this}Ke.prototype.clear=et,Ke.prototype.delete=at,Ke.prototype.get=vt,Ke.prototype.has=zt,Ke.prototype.set=It;function en(de){var ke=this.__data__=new pt(de);this.size=ke.size}function Tt(){this.__data__=new pt,this.size=0}function ot(de){var ke=this.__data__,Le=ke.delete(de);return this.size=ke.size,Le}function wt(de){return this.__data__.get(de)}function jt(de){return this.__data__.has(de)}function Oe(de,ke){var Le=this.__data__;if(Le instanceof pt){var Dt=Le.__data__;if(!Ce||Dt.length<n-1)return Dt.push([de,ke]),this.size=++Le.size,this;Le=this.__data__=new Ke(Dt)}return Le.set(de,ke),this.size=Le.size,this}en.prototype.clear=Tt,en.prototype.delete=ot,en.prototype.get=wt,en.prototype.has=jt,en.prototype.set=Oe;function Ge(de,ke){var Le=Mr(de),Dt=!Le&&Ln(de),In=!Le&&!Dt&&Cd(de),ir=!Le&&!Dt&&!In&&o$(de),Tr=Le||Dt||In||ir,Bn=Tr?oe(de.length,String):[],Ir=Bn.length;for(var ta in de)Tr&&(ta=="length"||In&&(ta=="offset"||ta=="parent")||ir&&(ta=="buffer"||ta=="byteLength"||ta=="byteOffset")||El(ta,Ir))||Bn.push(ta);return Bn}function le(de,ke,Le){(Le!==void 0&&!sr(de[ke],Le)||Le===void 0&&!(ke in de))&&Et(de,ke,Le)}function Be(de,ke,Le){var Dt=de[ke];(!(me.call(de,ke)&&sr(Dt,Le))||Le===void 0&&!(ke in de))&&Et(de,ke,Le)}function it(de,ke){for(var Le=de.length;Le--;)if(sr(de[Le][0],ke))return Le;return-1}function Et(de,ke,Le){ke=="__proto__"&&Fe?Fe(de,ke,{configurable:!0,enumerable:!0,value:Le,writable:!0}):de[ke]=Le}var Lt=Nt();function be(de){return de==null?de===void 0?k:y:$e&&$e in Object(de)?Ci(de):nw(de)}function Se(de){return nb(de)&&be(de)==a}function We(de){if(!Nd(de)||ew(de))return!1;var ke=eb(de)?ne:X;return ke.test(Zt(de))}function bt(de){return nb(de)&&tb(de.length)&&!!R[be(de)]}function $t(de){if(!Nd(de))return tw(de);var ke=Jg(de),Le=[];for(var Dt in de)Dt=="constructor"&&(ke||!me.call(de,Dt))||Le.push(Dt);return Le}function _t(de,ke,Le,Dt,In){de!==ke&&Lt(ke,function(ir,Tr){if(In||(In=new en),Nd(ir))Fn(de,ke,Tr,Le,_t,Dt,In);else{var Bn=Dt?Dt(Gt(de,Tr),ir,Tr+"",de,ke,In):void 0;Bn===void 0&&(Bn=ir),le(de,Tr,Bn)}},s$)}function Fn(de,ke,Le,Dt,In,ir,Tr){var Bn=Gt(de,Le),Ir=Gt(ke,Le),ta=Tr.get(Ir);if(ta){le(de,Le,ta);return}var Zs=ir?ir(Bn,Ir,Le+"",de,ke,Tr):void 0,rb=Zs===void 0;if(rb){var Xj=Mr(Ir),Qj=!Xj&&Cd(Ir),a$=!Xj&&!Qj&&o$(Ir);Zs=Ir,Xj||Qj||a$?Mr(Bn)?Zs=Bn:To(Bn)?Zs=qe(Bn):Qj?(rb=!1,Zs=Si(Ir)):a$?(rb=!1,Zs=Il(Ir)):Zs=[]:Ehe(Ir)||Ln(Ir)?(Zs=Bn,Ln(Bn)?Zs=Dhe(Bn):(!Nd(Bn)||eb(Bn))&&(Zs=Yh(Ir))):rb=!1}rb&&(Tr.set(Ir,Zs),In(Zs,Ir,Dt,ir,Tr),Tr.delete(Ir)),le(de,Le,Zs)}function On(de,ke){return pn(Re(de,ke,i$),de+"")}var jr=Fe?function(de,ke){return Fe(de,"toString",{configurable:!0,enumerable:!1,value:Ahe(ke),writable:!0})}:i$;function Si(de,ke){return de.slice()}function Is(de){var ke=new de.constructor(de.byteLength);return new Ne(ke).set(new Ne(de)),ke}function Il(de,ke){var Le=Is(de.buffer);return new de.constructor(Le,de.byteOffset,de.length)}function qe(de,ke){var Le=-1,Dt=de.length;for(ke||(ke=Array(Dt));++Le<Dt;)ke[Le]=de[Le];return ke}function lt(de,ke,Le,Dt){var In=!Le;Le||(Le={});for(var ir=-1,Tr=ke.length;++ir<Tr;){var Bn=ke[ir],Ir=void 0;Ir===void 0&&(Ir=de[Bn]),In?Et(Le,Bn,Ir):Be(Le,Bn,Ir)}return Le}function St(de){return On(function(ke,Le){var Dt=-1,In=Le.length,ir=In>1?Le[In-1]:void 0,Tr=In>2?Le[2]:void 0;for(ir=de.length>3&&typeof ir=="function"?(In--,ir):void 0,Tr&&Kh(Le[0],Le[1],Tr)&&(ir=In<3?void 0:ir,In=1),ke=Object(ke);++Dt<In;){var Bn=Le[Dt];Bn&&de(ke,Bn,Dt,ir)}return ke})}function Nt(de){return function(ke,Le,Dt){for(var In=-1,ir=Object(ke),Tr=Dt(ke),Bn=Tr.length;Bn--;){var Ir=Tr[++In];if(Le(ir[Ir],Ir,ir)===!1)break}return ke}}function Xt(de,ke){var Le=de.__data__;return Vc(ke)?Le[typeof ke=="string"?"string":"hash"]:Le.map}function Or(de,ke){var Le=ue(de,ke);return We(Le)?Le:void 0}function Ci(de){var ke=me.call(de,$e),Le=de[$e];try{de[$e]=void 0;var Dt=!0}catch{}var In=ee.call(de);return Dt&&(ke?de[$e]=Le:delete de[$e]),In}function Yh(de){return typeof de.constructor=="function"&&!Jg(de)?He(Ee(de)):{}}function El(de,ke){var Le=typeof de;return ke=ke??i,!!ke&&(Le=="number"||Le!="symbol"&&Y.test(de))&&de>-1&&de%1==0&&de<ke}function Kh(de,ke,Le){if(!Nd(Le))return!1;var Dt=typeof ke;return(Dt=="number"?mr(Le)&&El(ke,Le.length):Dt=="string"&&ke in Le)?sr(Le[ke],de):!1}function Vc(de){var ke=typeof de;return ke=="string"||ke=="number"||ke=="symbol"||ke=="boolean"?de!=="__proto__":de===null}function ew(de){return!!we&&we in de}function Jg(de){var ke=de&&de.constructor,Le=typeof ke=="function"&&ke.prototype||se;return de===Le}function tw(de){var ke=[];if(de!=null)for(var Le in Object(de))ke.push(Le);return ke}function nw(de){return ee.call(de)}function Re(de,ke,Le){return ke=Ze(ke===void 0?de.length-1:ke,0),function(){for(var Dt=arguments,In=-1,ir=Ze(Dt.length-ke,0),Tr=Array(ir);++In<ir;)Tr[In]=Dt[ke+In];In=-1;for(var Bn=Array(ke+1);++In<ke;)Bn[In]=Dt[In];return Bn[ke]=Le(Tr),J(de,this,Bn)}}function Gt(de,ke){if(!(ke==="constructor"&&typeof de[ke]=="function")&&ke!="__proto__")return de[ke]}var pn=tn(jr);function tn(de){var ke=0,Le=0;return function(){var Dt=Je(),In=s-(Dt-Le);if(Le=Dt,In>0){if(++ke>=o)return arguments[0]}else ke=0;return de.apply(void 0,arguments)}}function Zt(de){if(de!=null){try{return fe.call(de)}catch{}try{return de+""}catch{}}return""}function sr(de,ke){return de===ke||de!==de&&ke!==ke}var Ln=Se(function(){return arguments}())?Se:function(de){return nb(de)&&me.call(de,"callee")&&!ge.call(de,"callee")},Mr=Array.isArray;function mr(de){return de!=null&&tb(de.length)&&!eb(de)}function To(de){return nb(de)&&mr(de)}var Cd=ze||Rhe;function eb(de){if(!Nd(de))return!1;var ke=be(de);return ke==m||ke==g||ke==u||ke==v}function tb(de){return typeof de=="number"&&de>-1&&de%1==0&&de<=i}function Nd(de){var ke=typeof de;return de!=null&&(ke=="object"||ke=="function")}function nb(de){return de!=null&&typeof de=="object"}function Ehe(de){if(!nb(de)||be(de)!=w)return!1;var ke=Ee(de);if(ke===null)return!0;var Le=me.call(ke,"constructor")&&ke.constructor;return typeof Le=="function"&&Le instanceof Le&&fe.call(Le)==re}var o$=Z?ie(Z):bt;function Dhe(de){return lt(de,s$(de))}function s$(de){return mr(de)?Ge(de):$t(de)}var Mhe=St(function(de,ke,Le){_t(de,ke,Le)});function Ahe(de){return function(){return de}}function i$(de){return de}function Rhe(){return!1}e.exports=Mhe})(H1,H1.exports);var sme=H1.exports;const fl=p.getDefaultExportFromCjs(sme),ime={theme:"system",setTheme:()=>null},_q=S.createContext(ime);function U1(e,t="system"){return ame(e)?e:t}function ame(e){return e==="light"||e==="dark"||e==="system"}const VR=()=>{const e=S.useContext(_q);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},kq=(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(!qD(s,i))if(Array.isArray(s)&&Array.isArray(i))n[o]=i;else if(u$(s)&&u$(i)){const a=kq(s,i);Object.keys(a).length>0&&(n[o]=a)}else n[o]=i}return n},qD=(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)=>qD(o,t[s]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(o=>qD(e[o],t[o]))}return!1},u$=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$s=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=>$s(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=$s(e[n]));return t},jq="__semaphorAuthoredFontFamily";var lq,cq;const lme=(cq=(lq=p.DEFAULT_STYLE.default.chart)==null?void 0:lq.font)==null?void 0:cq.family,cme=new Set([lme,"Open Sans, Arial, sans-serif",'"Open Sans", Arial, sans-serif'].filter(Boolean));function ume(e,t){if(!e)return t?{family:t}:void 0;const{[jq]:n,...r}=e,o=dme(r.family,t,!!n);return{...r,...o?{family:o}:void 0}}function dme(e,t,n=!1){return n&&e||e&&!fme(e)?e:t||e}function fme(e){return cme.has(e.trim())}function hme(e,t){if(!t)return e;const n={...e,font:Ii(e.font,t)},r=gme(e.plugins,t);r&&(n.plugins=r);const o=bme(e.scales,t);return o&&(n.scales=o),n}function mme(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:Ii(o.font,t)}}})}function pme(e,t){if(!e||typeof e!="object"||!t)return e;const n=e.datasets;return Array.isArray(n)?{...e,datasets:mme(n,t)}:e}function gme(e,t){var n;return e&&{...e,title:e.title?{...e.title,font:Ii(e.title.font,t)}:e.title,subtitle:e.subtitle?{...e.subtitle,font:Ii(e.subtitle.font,t)}:e.subtitle,legend:e.legend?{...e.legend,labels:e.legend.labels?{...e.legend.labels,font:Ii(e.legend.labels.font,t)}:e.legend.labels}:e.legend,tooltip:e.tooltip?{...e.tooltip,titleFont:Ii(e.tooltip.titleFont,t),bodyFont:Ii(e.tooltip.bodyFont,t),footerFont:Ii(e.tooltip.footerFont,t)}:e.tooltip,datalabels:e.datalabels?{...e.datalabels,font:Ii((n=e.datalabels)==null?void 0:n.font,t)}:e.datalabels}}function bme(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:Ii(s.ticks.font,t)}:s.ticks,title:s.title?{...s.title,font:Ii(s.title.font,t)}:s.title,pointLabels:s.pointLabels?{...s.pointLabels,font:Ii(s.pointLabels.font,t)}:s.pointLabels},n},{})}function Ii(e,t){return typeof e=="function"?e:{...t,...e&&typeof e=="object"?e:{}}}function xme(e,t){const n=$s(e??{}),r=yme(t);if(!r)return n;const o=fl(n,r);return Sme(o,r),o}function yme(e){var h,m,g,b;const t=(h=e.scheme.components)==null?void 0:h.chart,n=kc.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={};wme(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=Zh(i==null?void 0:i.fontFamily,o==null?void 0:o.fontFamily),c=Zh(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[jq]=!0),s.font=x}const u=Zh(t==null?void 0:t.gridColor,r==null?void 0:r.gridColor),d=Zh(t==null?void 0:t.axisColor,r==null?void 0:r.axisColor)??Zh(t==null?void 0:t.foreground,r==null?void 0:r.foreground);(u||d)&&(s.options={scales:{x:tT({gridColor:u,axisColor:d}),y:tT({gridColor:u,axisColor:d}),y2:tT({gridColor:u,axisColor:d}),r:vme({gridColor:u,axisColor:d})}});const f=Zh(t==null?void 0:t.foreground,r==null?void 0:r.foreground);return f&&(s.options=fl(s.options??{},{plugins:{legend:{labels:{color:f}}}})),Object.keys(s).length>0?{chart:s}:void 0}function tT({gridColor:e,axisColor:t}){return{...e?{grid:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t}}:void 0}}function vme({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 wme(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 Zh(e,t){return e!==void 0&&e!==t?e:void 0}function Sme(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 wh=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(){}},Cme={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ga,pf,uq,Nme=(uq=class{constructor(){kt(this,Ga,Cme);kt(this,pf,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&he(this,pf)&&e!==he(this,Ga)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:he(this,Ga),provider:e}),ft(this,Ga,e),process.env.NODE_ENV!=="production"&&ft(this,pf,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ft(this,pf,!0),he(this,Ga).setTimeout(e,t)}clearTimeout(e){he(this,Ga).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ft(this,pf,!0),he(this,Ga).setInterval(e,t)}clearInterval(e){he(this,Ga).clearInterval(e)}},Ga=new WeakMap,pf=new WeakMap,uq),rf=new Nme;function _me(e){setTimeout(e,0)}var Uf=typeof window>"u"||"Deno"in globalThis;function Zo(){}function kme(e,t){return typeof e=="function"?e(t):e}function WD(e){return typeof e=="number"&&e>=0&&e!==1/0}function Tq(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vu(e,t){return typeof e=="function"?e(t):e}function Ei(e,t){return typeof e=="function"?e(t):e}function d$(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:s,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==HR(i,t.options))return!1}else if(!ay(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 f$(e,t){const{exact:n,status:r,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(qf(t.options.mutationKey)!==qf(s))return!1}else if(!ay(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function HR(e,t){return((t==null?void 0:t.queryKeyHashFn)||qf)(e)}function qf(e){return JSON.stringify(e,(t,n)=>GD(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function ay(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ay(e[n],t[n])):!1}var jme=Object.prototype.hasOwnProperty;function q1(e,t){if(e===t)return e;const n=h$(e)&&h$(t);if(!n&&!(GD(e)&&GD(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:jme.call(e,d))&&c++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){a[d]=h;continue}const m=q1(f,h);a[d]=m,m===f&&c++}return o===i&&c===o?e:a}function ly(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 h$(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function GD(e){if(!m$(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!m$(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function m$(e){return Object.prototype.toString.call(e)==="[object Object]"}function Tme(e){return new Promise(t=>{rf.setTimeout(t,e)})}function YD(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 q1(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 q1(e,t)}return t}function Ime(e){return e}function Eme(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Dme(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var W1=Symbol();function Iq(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===W1&&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===W1?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Eq(e,t){return typeof e=="function"?e(...t):!!e}var gf,Jc,rp,dq,Mme=(dq=class extends wh{constructor(){super();kt(this,gf);kt(this,Jc);kt(this,rp);ft(this,rp,t=>{if(!Uf&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){he(this,Jc)||this.setEventListener(he(this,rp))}onUnsubscribe(){var t;this.hasListeners()||((t=he(this,Jc))==null||t.call(this),ft(this,Jc,void 0))}setEventListener(t){var n;ft(this,rp,t),(n=he(this,Jc))==null||n.call(this),ft(this,Jc,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){he(this,gf)!==t&&(ft(this,gf,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof he(this,gf)=="boolean"?he(this,gf):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},gf=new WeakMap,Jc=new WeakMap,rp=new WeakMap,dq),UR=new Mme;function KD(){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 Ame=_me;function Rme(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=Ame;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 Pr=Rme(),op,eu,sp,fq,Pme=(fq=class extends wh{constructor(){super();kt(this,op,!0);kt(this,eu);kt(this,sp);ft(this,sp,t=>{if(!Uf&&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(){he(this,eu)||this.setEventListener(he(this,sp))}onUnsubscribe(){var t;this.hasListeners()||((t=he(this,eu))==null||t.call(this),ft(this,eu,void 0))}setEventListener(t){var n;ft(this,sp,t),(n=he(this,eu))==null||n.call(this),ft(this,eu,t(this.setOnline.bind(this)))}setOnline(t){he(this,op)!==t&&(ft(this,op,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return he(this,op)}},op=new WeakMap,eu=new WeakMap,sp=new WeakMap,fq),G1=new Pme;function Fme(e){return Math.min(1e3*2**e,3e4)}function Dq(e){return(e??"online")==="online"?G1.isOnline():!0}var ZD=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Mq(e){let t=!1,n=0,r;const o=KD(),s=()=>o.status!=="pending",i=b=>{var x;if(!s()){const y=new ZD(b);h(y),(x=e.onCancel)==null||x.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>UR.isFocused()&&(e.networkMode==="always"||G1.isOnline())&&e.canRun(),d=()=>Dq(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 _;if(s())return;const w=e.retry??(Uf?0:3),v=e.retryDelay??Fme,C=typeof v=="function"?v(n,y):v,N=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!N){h(y);return}n++,(_=e.onFail)==null||_.call(e,n,y),Tme(C).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 bf,hq,Aq=(hq=class{constructor(){kt(this,bf)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),WD(this.gcTime)&&ft(this,bf,rf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Uf?1/0:5*60*1e3))}clearGcTimeout(){he(this,bf)&&(rf.clearTimeout(he(this,bf)),ft(this,bf,void 0))}},bf=new WeakMap,hq),xf,ip,ji,yf,mo,C0,vf,ia,Pl,mq,Ome=(mq=class extends Aq{constructor(t){super();kt(this,ia);kt(this,xf);kt(this,ip);kt(this,ji);kt(this,yf);kt(this,mo);kt(this,C0);kt(this,vf);ft(this,vf,!1),ft(this,C0,t.defaultOptions),this.setOptions(t.options),this.observers=[],ft(this,yf,t.client),ft(this,ji,he(this,yf).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ft(this,xf,g$(this.options)),this.state=t.state??he(this,xf),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=he(this,mo))==null?void 0:t.promise}setOptions(t){if(this.options={...he(this,C0),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=g$(this.options);n.data!==void 0&&(this.setState(p$(n.data,n.dataUpdatedAt)),ft(this,xf,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&he(this,ji).remove(this)}setData(t,n){const r=YD(this.state.data,t,this.options);return Ht(this,ia,Pl).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ht(this,ia,Pl).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=he(this,mo))==null?void 0:r.promise;return(o=he(this,mo))==null||o.cancel(t),n?n.then(Zo).catch(Zo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(he(this,xf))}isActive(){return this.observers.some(t=>Ei(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===W1||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>vu(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:!Tq(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=he(this,mo))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=he(this,mo))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),he(this,ji).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(he(this,mo)&&(he(this,vf)?he(this,mo).cancel({revert:!0}):he(this,mo).cancelRetry()),this.scheduleGc()),he(this,ji).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ht(this,ia,Pl).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,h,m,g,b,x,y,w,v;if(this.state.fetchStatus!=="idle"&&((c=he(this,mo))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(he(this,mo))return he(this,mo).continueRetry(),he(this,mo).promise}if(t&&this.setOptions(t),!this.options.queryFn){const C=this.observers.find(N=>N.options.queryFn);C&&this.setOptions(C.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=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(ft(this,vf,!0),r.signal)})},s=()=>{const C=Iq(this.options,n),_=(()=>{const k={client:he(this,yf),queryKey:this.queryKey,meta:this.meta};return o(k),k})();return ft(this,vf,!1),this.options.persister?this.options.persister(C,_,this):C(_)},a=(()=>{const C={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:he(this,yf),state:this.state,fetchFn:s};return o(C),C})();(u=this.options.behavior)==null||u.onFetch(a,this),ft(this,ip,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&Ht(this,ia,Pl).call(this,{type:"fetch",meta:(f=a.fetchOptions)==null?void 0:f.meta}),ft(this,mo,Mq({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:C=>{C instanceof ZD&&C.revert&&this.setState({...he(this,ip),fetchStatus:"idle"}),r.abort()},onFail:(C,N)=>{Ht(this,ia,Pl).call(this,{type:"failed",failureCount:C,error:N})},onPause:()=>{Ht(this,ia,Pl).call(this,{type:"pause"})},onContinue:()=>{Ht(this,ia,Pl).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const C=await he(this,mo).start();if(C===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(C),(m=(h=he(this,ji).config).onSuccess)==null||m.call(h,C,this),(b=(g=he(this,ji).config).onSettled)==null||b.call(g,C,this.state.error,this),C}catch(C){if(C instanceof ZD){if(C.silent)return he(this,mo).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Ht(this,ia,Pl).call(this,{type:"error",error:C}),(y=(x=he(this,ji).config).onError)==null||y.call(x,C,this),(v=(w=he(this,ji).config).onSettled)==null||v.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},xf=new WeakMap,ip=new WeakMap,ji=new WeakMap,yf=new WeakMap,mo=new WeakMap,C0=new WeakMap,vf=new WeakMap,ia=new WeakSet,Pl=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,...Rq(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,...p$(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ft(this,ip,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),Pr.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),he(this,ji).notify({query:this,type:"updated",action:t})})},mq);function Rq(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Dq(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function p$(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function g$(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 Fs,Nn,N0,bs,wf,ap,ql,tu,_0,lp,cp,Sf,Cf,nu,up,Zn,Yb,XD,QD,JD,e2,t2,n2,r2,Pq,pq,qR=(pq=class extends wh{constructor(t,n){super();kt(this,Zn);kt(this,Fs);kt(this,Nn);kt(this,N0);kt(this,bs);kt(this,wf);kt(this,ap);kt(this,ql);kt(this,tu);kt(this,_0);kt(this,lp);kt(this,cp);kt(this,Sf);kt(this,Cf);kt(this,nu);kt(this,up,new Set);this.options=n,ft(this,Fs,t),ft(this,tu,null),ft(this,ql,KD()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(he(this,Nn).addObserver(this),b$(he(this,Nn),this.options)?Ht(this,Zn,Yb).call(this):this.updateResult(),Ht(this,Zn,e2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return o2(he(this,Nn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return o2(he(this,Nn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ht(this,Zn,t2).call(this),Ht(this,Zn,n2).call(this),he(this,Nn).removeObserver(this)}setOptions(t){const n=this.options,r=he(this,Nn);if(this.options=he(this,Fs).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ei(this.options.enabled,he(this,Nn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ht(this,Zn,r2).call(this),he(this,Nn).setOptions(this.options),n._defaulted&&!ly(this.options,n)&&he(this,Fs).getQueryCache().notify({type:"observerOptionsUpdated",query:he(this,Nn),observer:this});const o=this.hasListeners();o&&x$(he(this,Nn),r,this.options,n)&&Ht(this,Zn,Yb).call(this),this.updateResult(),o&&(he(this,Nn)!==r||Ei(this.options.enabled,he(this,Nn))!==Ei(n.enabled,he(this,Nn))||vu(this.options.staleTime,he(this,Nn))!==vu(n.staleTime,he(this,Nn)))&&Ht(this,Zn,XD).call(this);const s=Ht(this,Zn,QD).call(this);o&&(he(this,Nn)!==r||Ei(this.options.enabled,he(this,Nn))!==Ei(n.enabled,he(this,Nn))||s!==he(this,nu))&&Ht(this,Zn,JD).call(this,s)}getOptimisticResult(t){const n=he(this,Fs).getQueryCache().build(he(this,Fs),t),r=this.createResult(n,t);return $me(this,r)&&(ft(this,bs,r),ft(this,ap,this.options),ft(this,wf,he(this,Nn).state)),r}getCurrentResult(){return he(this,bs)}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&&he(this,ql).status==="pending"&&he(this,ql).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(t){he(this,up).add(t)}getCurrentQuery(){return he(this,Nn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=he(this,Fs).defaultQueryOptions(t),r=he(this,Fs).getQueryCache().build(he(this,Fs),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ht(this,Zn,Yb).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),he(this,bs)))}createResult(t,n){var I;const r=he(this,Nn),o=this.options,s=he(this,bs),i=he(this,wf),a=he(this,ap),u=t!==r?t.state:he(this,N0),{state:d}=t;let f={...d},h=!1,m;if(n._optimisticResults){const T=this.hasListeners(),E=!T&&b$(t,n),D=T&&x$(t,r,n,o);(E||D)&&(f={...f,...Rq(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 T;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(T=s.data,y=!0):T=typeof n.placeholderData=="function"?n.placeholderData((I=he(this,cp))==null?void 0:I.state.data,he(this,cp)):n.placeholderData,T!==void 0&&(x="success",m=YD(s==null?void 0:s.data,T,n),h=!0)}if(n.select&&m!==void 0&&!y)if(s&&m===(i==null?void 0:i.data)&&n.select===he(this,_0))m=he(this,lp);else try{ft(this,_0,n.select),m=n.select(m),m=YD(s==null?void 0:s.data,m,n),ft(this,lp,m),ft(this,tu,null)}catch(T){ft(this,tu,T)}he(this,tu)&&(g=he(this,tu),m=he(this,lp),b=Date.now(),x="error");const w=f.fetchStatus==="fetching",v=x==="pending",C=x==="error",N=v&&w,_=m!==void 0,j={status:x,fetchStatus:f.fetchStatus,isPending:v,isSuccess:x==="success",isError:C,isInitialLoading:N,isLoading:N,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&&!v,isLoadingError:C&&!_,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:C&&_,isStale:WR(t,n),refetch:this.refetch,promise:he(this,ql),isEnabled:Ei(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const T=A=>{j.status==="error"?A.reject(j.error):j.data!==void 0&&A.resolve(j.data)},E=()=>{const A=ft(this,ql,j.promise=KD());T(A)},D=he(this,ql);switch(D.status){case"pending":t.queryHash===r.queryHash&&T(D);break;case"fulfilled":(j.status==="error"||j.data!==D.value)&&E();break;case"rejected":(j.status!=="error"||j.error!==D.reason)&&E();break}}return j}updateResult(){const t=he(this,bs),n=this.createResult(he(this,Nn),this.options);if(ft(this,wf,he(this,Nn).state),ft(this,ap,this.options),he(this,wf).data!==void 0&&ft(this,cp,he(this,Nn)),ly(n,t))return;ft(this,bs,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,s=typeof o=="function"?o():o;if(s==="all"||!s&&!he(this,up).size)return!0;const i=new Set(s??he(this,up));return this.options.throwOnError&&i.add("error"),Object.keys(he(this,bs)).some(a=>{const c=a;return he(this,bs)[c]!==t[c]&&i.has(c)})};Ht(this,Zn,Pq).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ht(this,Zn,e2).call(this)}},Fs=new WeakMap,Nn=new WeakMap,N0=new WeakMap,bs=new WeakMap,wf=new WeakMap,ap=new WeakMap,ql=new WeakMap,tu=new WeakMap,_0=new WeakMap,lp=new WeakMap,cp=new WeakMap,Sf=new WeakMap,Cf=new WeakMap,nu=new WeakMap,up=new WeakMap,Zn=new WeakSet,Yb=function(t){Ht(this,Zn,r2).call(this);let n=he(this,Nn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Zo)),n},XD=function(){Ht(this,Zn,t2).call(this);const t=vu(this.options.staleTime,he(this,Nn));if(Uf||he(this,bs).isStale||!WD(t))return;const r=Tq(he(this,bs).dataUpdatedAt,t)+1;ft(this,Sf,rf.setTimeout(()=>{he(this,bs).isStale||this.updateResult()},r))},QD=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(he(this,Nn)):this.options.refetchInterval)??!1},JD=function(t){Ht(this,Zn,n2).call(this),ft(this,nu,t),!(Uf||Ei(this.options.enabled,he(this,Nn))===!1||!WD(he(this,nu))||he(this,nu)===0)&&ft(this,Cf,rf.setInterval(()=>{(this.options.refetchIntervalInBackground||UR.isFocused())&&Ht(this,Zn,Yb).call(this)},he(this,nu)))},e2=function(){Ht(this,Zn,XD).call(this),Ht(this,Zn,JD).call(this,Ht(this,Zn,QD).call(this))},t2=function(){he(this,Sf)&&(rf.clearTimeout(he(this,Sf)),ft(this,Sf,void 0))},n2=function(){he(this,Cf)&&(rf.clearInterval(he(this,Cf)),ft(this,Cf,void 0))},r2=function(){const t=he(this,Fs).getQueryCache().build(he(this,Fs),this.options);if(t===he(this,Nn))return;const n=he(this,Nn);ft(this,Nn,t),ft(this,N0,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Pq=function(t){Pr.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(he(this,bs))}),he(this,Fs).getQueryCache().notify({query:he(this,Nn),type:"observerResultsUpdated"})})},pq);function Lme(e,t){return Ei(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function b$(e,t){return Lme(e,t)||e.state.data!==void 0&&o2(e,t,t.refetchOnMount)}function o2(e,t,n){if(Ei(t.enabled,e)!==!1&&vu(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&WR(e,t)}return!1}function x$(e,t,n,r){return(e!==t||Ei(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&WR(e,n)}function WR(e,t){return Ei(t.enabled,e)!==!1&&e.isStaleByTime(vu(t.staleTime,e))}function $me(e,t){return!ly(e.getCurrentResult(),t)}function y$(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=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(t.signal.aborted?b=!0:t.signal.addEventListener("abort",()=>{b=!0}),t.signal)})},y=Iq(t.options,t.fetchOptions),w=async(v,C,N)=>{if(b)return Promise.reject();if(C==null&&v.pages.length)return Promise.resolve(v);const k=(()=>{const E={client:t.client,queryKey:t.queryKey,pageParam:C,direction:N?"backward":"forward",meta:t.options.meta};return x(E),E})(),j=await y(k),{maxPages:I}=t.options,T=N?Dme:Eme;return{pages:T(v.pages,j,I),pageParams:T(v.pageParams,C,I)}};if(o&&s.length){const v=o==="backward",C=v?zme:v$,N={pages:s,pageParams:i},_=C(r,N);a=await w(N,_,v)}else{const v=e??s.length;do{const C=c===0?i[0]??r.initialPageParam:v$(r,a);if(c>0&&C==null)break;a=await w(a,C),c++}while(c<v)}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 v$(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 zme(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 k0,Ya,xs,Nf,Ka,Gc,gq,Bme=(gq=class extends Aq{constructor(t){super();kt(this,Ka);kt(this,k0);kt(this,Ya);kt(this,xs);kt(this,Nf);ft(this,k0,t.client),this.mutationId=t.mutationId,ft(this,xs,t.mutationCache),ft(this,Ya,[]),this.state=t.state||Fq(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){he(this,Ya).includes(t)||(he(this,Ya).push(t),this.clearGcTimeout(),he(this,xs).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ft(this,Ya,he(this,Ya).filter(n=>n!==t)),this.scheduleGc(),he(this,xs).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){he(this,Ya).length||(this.state.status==="pending"?this.scheduleGc():he(this,xs).remove(this))}continue(){var t;return((t=he(this,Nf))==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,v,C,N,_,k,j,I;const n=()=>{Ht(this,Ka,Gc).call(this,{type:"continue"})},r={client:he(this,k0),meta:this.options.meta,mutationKey:this.options.mutationKey};ft(this,Nf,Mq({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(T,E)=>{Ht(this,Ka,Gc).call(this,{type:"failed",failureCount:T,error:E})},onPause:()=>{Ht(this,Ka,Gc).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>he(this,xs).canRun(this)}));const o=this.state.status==="pending",s=!he(this,Nf).canStart();try{if(o)n();else{Ht(this,Ka,Gc).call(this,{type:"pending",variables:t,isPaused:s}),await((a=(i=he(this,xs).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&&Ht(this,Ka,Gc).call(this,{type:"pending",context:E,variables:t,isPaused:s})}const T=await he(this,Nf).start();return await((f=(d=he(this,xs).config).onSuccess)==null?void 0:f.call(d,T,t,this.state.context,this,r)),await((m=(h=this.options).onSuccess)==null?void 0:m.call(h,T,t,this.state.context,r)),await((b=(g=he(this,xs).config).onSettled)==null?void 0:b.call(g,T,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,T,null,t,this.state.context,r)),Ht(this,Ka,Gc).call(this,{type:"success",data:T}),T}catch(T){try{throw await((v=(w=he(this,xs).config).onError)==null?void 0:v.call(w,T,t,this.state.context,this,r)),await((N=(C=this.options).onError)==null?void 0:N.call(C,T,t,this.state.context,r)),await((k=(_=he(this,xs).config).onSettled)==null?void 0:k.call(_,void 0,T,this.state.variables,this.state.context,this,r)),await((I=(j=this.options).onSettled)==null?void 0:I.call(j,void 0,T,t,this.state.context,r)),T}finally{Ht(this,Ka,Gc).call(this,{type:"error",error:T})}}finally{he(this,xs).runNext(this)}}},k0=new WeakMap,Ya=new WeakMap,xs=new WeakMap,Nf=new WeakMap,Ka=new WeakSet,Gc=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),Pr.batch(()=>{he(this,Ya).forEach(r=>{r.onMutationUpdate(t)}),he(this,xs).notify({mutation:this,type:"updated",action:t})})},gq);function Fq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Wl,aa,j0,bq,Vme=(bq=class extends wh{constructor(t={}){super();kt(this,Wl);kt(this,aa);kt(this,j0);this.config=t,ft(this,Wl,new Set),ft(this,aa,new Map),ft(this,j0,0)}build(t,n,r){const o=new Bme({client:t,mutationCache:this,mutationId:++rw(this,j0)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){he(this,Wl).add(t);const n=sw(t);if(typeof n=="string"){const r=he(this,aa).get(n);r?r.push(t):he(this,aa).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(he(this,Wl).delete(t)){const n=sw(t);if(typeof n=="string"){const r=he(this,aa).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&he(this,aa).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=sw(t);if(typeof n=="string"){const r=he(this,aa).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=sw(t);if(typeof n=="string"){const o=(r=he(this,aa).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(){Pr.batch(()=>{he(this,Wl).forEach(t=>{this.notify({type:"removed",mutation:t})}),he(this,Wl).clear(),he(this,aa).clear()})}getAll(){return Array.from(he(this,Wl))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>f$(n,r))}findAll(t={}){return this.getAll().filter(n=>f$(t,n))}notify(t){Pr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Pr.batch(()=>Promise.all(t.map(n=>n.continue().catch(Zo))))}},Wl=new WeakMap,aa=new WeakMap,j0=new WeakMap,bq);function sw(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Gl,ru,Os,Yl,yc,JS,s2,xq,Hme=(xq=class extends wh{constructor(n,r){super();kt(this,yc);kt(this,Gl);kt(this,ru);kt(this,Os);kt(this,Yl);ft(this,Gl,n),this.setOptions(r),this.bindMethods(),Ht(this,yc,JS).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=he(this,Gl).defaultMutationOptions(n),ly(this.options,r)||he(this,Gl).getMutationCache().notify({type:"observerOptionsUpdated",mutation:he(this,Os),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&qf(r.mutationKey)!==qf(this.options.mutationKey)?this.reset():((o=he(this,Os))==null?void 0:o.state.status)==="pending"&&he(this,Os).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=he(this,Os))==null||n.removeObserver(this)}onMutationUpdate(n){Ht(this,yc,JS).call(this),Ht(this,yc,s2).call(this,n)}getCurrentResult(){return he(this,ru)}reset(){var n;(n=he(this,Os))==null||n.removeObserver(this),ft(this,Os,void 0),Ht(this,yc,JS).call(this),Ht(this,yc,s2).call(this)}mutate(n,r){var o;return ft(this,Yl,r),(o=he(this,Os))==null||o.removeObserver(this),ft(this,Os,he(this,Gl).getMutationCache().build(he(this,Gl),this.options)),he(this,Os).addObserver(this),he(this,Os).execute(n)}},Gl=new WeakMap,ru=new WeakMap,Os=new WeakMap,Yl=new WeakMap,yc=new WeakSet,JS=function(){var r;const n=((r=he(this,Os))==null?void 0:r.state)??Fq();ft(this,ru,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},s2=function(n){Pr.batch(()=>{var r,o,s,i,a,c,u,d;if(he(this,Yl)&&this.hasListeners()){const f=he(this,ru).variables,h=he(this,ru).context,m={client:he(this,Gl),meta:this.options.meta,mutationKey:this.options.mutationKey};(n==null?void 0:n.type)==="success"?((o=(r=he(this,Yl)).onSuccess)==null||o.call(r,n.data,f,h,m),(i=(s=he(this,Yl)).onSettled)==null||i.call(s,n.data,null,f,h,m)):(n==null?void 0:n.type)==="error"&&((c=(a=he(this,Yl)).onError)==null||c.call(a,n.error,f,h,m),(d=(u=he(this,Yl)).onSettled)==null||d.call(u,void 0,n.error,f,h,m))}this.listeners.forEach(f=>{f(he(this,ru))})})},xq);function w$(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function Ume(e,t,n){const r=e.slice(0);return r[t]=n,r}var _f,ni,dp,fp,Ti,ou,T0,I0,E0,Uo,i2,a2,l2,c2,u2,yq,qme=(yq=class extends wh{constructor(t,n,r){super();kt(this,Uo);kt(this,_f);kt(this,ni);kt(this,dp);kt(this,fp);kt(this,Ti);kt(this,ou);kt(this,T0);kt(this,I0);kt(this,E0,[]);ft(this,_f,t),ft(this,fp,r),ft(this,dp,[]),ft(this,Ti,[]),ft(this,ni,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&he(this,Ti).forEach(t=>{t.subscribe(n=>{Ht(this,Uo,c2).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,he(this,Ti).forEach(t=>{t.destroy()})}setQueries(t,n){if(ft(this,dp,t),ft(this,fp,n),process.env.NODE_ENV!=="production"){const r=t.map(o=>he(this,_f).defaultQueryOptions(o).queryHash);new Set(r).size!==r.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}Pr.batch(()=>{const r=he(this,Ti),o=Ht(this,Uo,l2).call(this,he(this,dp));ft(this,E0,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=he(this,ni)[h];return!m||!ly(f,m)});!u&&!d||(u&&ft(this,Ti,s),ft(this,ni,i),this.hasListeners()&&(u&&(w$(r,s).forEach(f=>{f.destroy()}),w$(s,r).forEach(f=>{f.subscribe(h=>{Ht(this,Uo,c2).call(this,f,h)})})),Ht(this,Uo,u2).call(this)))})}getCurrentResult(){return he(this,ni)}getQueries(){return he(this,Ti).map(t=>t.getCurrentQuery())}getObservers(){return he(this,Ti)}getOptimisticResult(t,n){const r=Ht(this,Uo,l2).call(this,t),o=r.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions));return[o,s=>Ht(this,Uo,a2).call(this,s??o,n),()=>Ht(this,Uo,i2).call(this,o,r)]}},_f=new WeakMap,ni=new WeakMap,dp=new WeakMap,fp=new WeakMap,Ti=new WeakMap,ou=new WeakMap,T0=new WeakMap,I0=new WeakMap,E0=new WeakMap,Uo=new WeakSet,i2=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)})})})},a2=function(t,n){return n?((!he(this,ou)||he(this,ni)!==he(this,I0)||n!==he(this,T0))&&(ft(this,T0,n),ft(this,I0,he(this,ni)),ft(this,ou,q1(he(this,ou),n(t)))),he(this,ou)):t},l2=function(t){const n=new Map;he(this,Ti).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=he(this,_f).defaultQueryOptions(o),a=((c=n.get(s.queryHash))==null?void 0:c.shift())??new qR(he(this,_f),s);r.push({defaultedQueryOptions:s,observer:a})}),r},c2=function(t,n){const r=he(this,Ti).indexOf(t);r!==-1&&(ft(this,ni,Ume(he(this,ni),r,n)),Ht(this,Uo,u2).call(this))},u2=function(){var t;if(this.hasListeners()){const n=he(this,ou),r=Ht(this,Uo,i2).call(this,he(this,ni),he(this,E0)),o=Ht(this,Uo,a2).call(this,r,(t=he(this,fp))==null?void 0:t.combine);n!==o&&Pr.batch(()=>{this.listeners.forEach(s=>{s(he(this,ni))})})}},yq),Za,vq,Oq=(vq=class extends wh{constructor(t={}){super();kt(this,Za);this.config=t,ft(this,Za,new Map)}build(t,n,r){const o=n.queryKey,s=n.queryHash??HR(o,n);let i=this.get(s);return i||(i=new Ome({client:t,queryKey:o,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){he(this,Za).has(t.queryHash)||(he(this,Za).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=he(this,Za).get(t.queryHash);n&&(t.destroy(),n===t&&he(this,Za).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Pr.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return he(this,Za).get(t)}getAll(){return[...he(this,Za).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>d$(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>d$(t,r)):n}notify(t){Pr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Pr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Pr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Za=new WeakMap,vq),zr,su,iu,hp,mp,au,pp,gp,wq,Wme=(wq=class{constructor(e={}){kt(this,zr);kt(this,su);kt(this,iu);kt(this,hp);kt(this,mp);kt(this,au);kt(this,pp);kt(this,gp);ft(this,zr,e.queryCache||new Oq),ft(this,su,e.mutationCache||new Vme),ft(this,iu,e.defaultOptions||{}),ft(this,hp,new Map),ft(this,mp,new Map),ft(this,au,0)}mount(){rw(this,au)._++,he(this,au)===1&&(ft(this,pp,UR.subscribe(async e=>{e&&(await this.resumePausedMutations(),he(this,zr).onFocus())})),ft(this,gp,G1.subscribe(async e=>{e&&(await this.resumePausedMutations(),he(this,zr).onOnline())})))}unmount(){var e,t;rw(this,au)._--,he(this,au)===0&&((e=he(this,pp))==null||e.call(this),ft(this,pp,void 0),(t=he(this,gp))==null||t.call(this),ft(this,gp,void 0))}isFetching(e){return he(this,zr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return he(this,su).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=he(this,zr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=he(this,zr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(vu(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return he(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=he(this,zr).get(r.queryHash),s=o==null?void 0:o.state.data,i=kme(t,s);if(i!==void 0)return he(this,zr).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Pr.batch(()=>he(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=he(this,zr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=he(this,zr);Pr.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=he(this,zr);return Pr.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Pr.batch(()=>he(this,zr).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Zo).catch(Zo)}invalidateQueries(e,t={}){return Pr.batch(()=>(he(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=Pr.batch(()=>he(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(Zo)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Zo)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=he(this,zr).build(this,t);return n.isStaleByTime(vu(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Zo).catch(Zo)}fetchInfiniteQuery(e){return e.behavior=y$(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Zo).catch(Zo)}ensureInfiniteQueryData(e){return e.behavior=y$(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return G1.isOnline()?he(this,su).resumePausedMutations():Promise.resolve()}getQueryCache(){return he(this,zr)}getMutationCache(){return he(this,su)}getDefaultOptions(){return he(this,iu)}setDefaultOptions(e){ft(this,iu,e)}setQueryDefaults(e,t){he(this,hp).set(qf(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...he(this,hp).values()],n={};return t.forEach(r=>{ay(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){he(this,mp).set(qf(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...he(this,mp).values()],n={};return t.forEach(r=>{ay(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...he(this,iu).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=HR(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===W1&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...he(this,iu).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){he(this,zr).clear(),he(this,su).clear()}},zr=new WeakMap,su=new WeakMap,iu=new WeakMap,hp=new WeakMap,mp=new WeakMap,au=new WeakMap,pp=new WeakMap,gp=new WeakMap,wq),GR=Q.createContext(void 0),Xr=e=>{const t=Q.useContext(GR);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Gme=({client:e,children:t})=>(Q.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(GR.Provider,{value:e,children:t})),Lq=Q.createContext(!1),$q=()=>Q.useContext(Lq);Lq.Provider;function Yme(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Kme=Q.createContext(Yme()),zq=()=>Q.useContext(Kme),Bq=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Vq=e=>{Q.useEffect(()=>{e.clearReset()},[e])},Hq=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Eq(n,[e.error,r])),Uq=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))}},qq=(e,t)=>e.isLoading&&e.isFetching&&!t,d2=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Y1=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Qp({queries:e,...t},n){const r=Xr(),o=$q(),s=zq(),i=Q.useMemo(()=>e.map(b=>{const x=r.defaultQueryOptions(b);return x._optimisticResults=o?"isRestoring":"optimistic",x}),[e,r,o]);i.forEach(b=>{Uq(b),Bq(b,s)}),Vq(s);const[a]=Q.useState(()=>new qme(r,i,t)),[c,u,d]=a.getOptimisticResult(i,t.combine),f=!o&&t.subscribed!==!1;Q.useSyncExternalStore(Q.useCallback(b=>f?a.subscribe(Pr.batchCalls(b)):Zo,[a,f]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),Q.useEffect(()=>{a.setQueries(i,t)},[i,t,a]);const m=c.some((b,x)=>d2(i[x],b))?c.flatMap((b,x)=>{const y=i[x];if(y){const w=new qR(r,y);if(d2(y,b))return Y1(y,w,s);qq(b,o)&&Y1(y,w,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const g=c.find((b,x)=>{const y=i[x];return y&&Hq({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 Zme(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=$q(),o=zq(),s=Xr(),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",Uq(i),Bq(i,o),Vq(o);const a=!s.getQueryCache().get(i.queryHash),[c]=Q.useState(()=>new t(s,i)),u=c.getOptimisticResult(i),d=!r&&e.subscribed!==!1;if(Q.useSyncExternalStore(Q.useCallback(x=>{const y=d?c.subscribe(Pr.batchCalls(x)):Zo;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Q.useEffect(()=>{c.setOptions(i)},[i,c]),d2(i,u))throw Y1(i,c,o);if(Hq({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&&!Uf&&qq(u,r)){const x=a?Y1(i,c,o):(b=s.getQueryCache().get(i.queryHash))==null?void 0:b.promise;x==null||x.catch(Zo).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?u:c.trackResult(u)}function Rn(e,t){return Zme(e,qR)}function Xme(e,t){const n=Xr(),r=n.getQueryCache();return Q.useSyncExternalStore(Q.useCallback(o=>r.subscribe(Pr.batchCalls(o)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function ss(e,t){const n=Xr(),[r]=Q.useState(()=>new Hme(n,e));Q.useEffect(()=>{r.setOptions(e)},[r,e]);const o=Q.useSyncExternalStore(Q.useCallback(i=>r.subscribe(Pr.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=Q.useCallback((i,a)=>{r.mutate(i,a).catch(Zo)},[r]);if(o.error&&Eq(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}function Qme(){const e=S.useContext(GR);if(e&&e.isSemaphorClient)return e}function Wq({children:e}){const{setIsSessionExpired:t}=p.useDashboardActions(),n=Qme(),[r]=S.useState(()=>{const o=new Wme({queryCache:new Oq({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(Gme,{client:r,children:e})}const Jme={id:"",authToken:void 0,tokenProps:{}},D0=S.createContext(Jme),YR=({children:e,dashboardProps:t})=>{const n=S.useMemo(()=>{let r={};const o=t.authToken;return o&&(r=Te.jwtDecode(o.accessToken)),{...t,tokenProps:r}},[t]);return l.jsx(Wq,{children:l.jsx(D0.Provider,{value:n,children:e})})};function gt(){const e=S.useContext(D0);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}const $o=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})}}}))),epe=()=>$o(e=>e.selectedVisual),Sh=()=>$o(e=>e.actions);function M0(){const{authToken:e,version:t,tokenProps:n,id:r}=gt(),o=$o(g=>g.selectedDashboard),s=$o(g=>g.showHub),i=p.useDashboardStore(g=>g.selectedLensId),a=tpe({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}=Rn({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 tpe({showHub:e,selectedDashboardId:t,dashboardId:n,tokenDashboardId:r}){return e?null:t||n||r||null}function npe(){const{authToken:e}=gt(),t=p.useDashboardStore(r=>r.authToken),{setAuthToken:n}=p.useDashboardActions();return S.useEffect(()=>{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 Gq(e){const t=S.useCallback(s=>`semaphor-default-sheet-${s}`,[]),n=S.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=S.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=S.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}}function rpe(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 ope(e,t){return{id:e.id,scope:e.scope,type:e.type,source:rpe(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 spe(e){return e.target==="sql_param"?e:{...e,mapping:Object.fromEntries(Object.entries(e.mapping).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort(([r],[o])=>r.localeCompare(o))):n]))}}function S$(e=[],t){return[...e].map(n=>ope(n,t)).sort((n,r)=>n.id.localeCompare(r.id)||n.scope.localeCompare(r.scope)||n.type.localeCompare(r.type))}function ipe(e=[]){return[...e].map(spe).sort((t,n)=>Ss.stableSerialize(t).localeCompare(Ss.stableSerialize(n)))}function f2(e,t){return e?Ss.stableSerialize({controlDefinitions:S$(e.controlDefinitions,t),cardControlDefinitions:S$(e.cardControlDefinitions,t),controlBindings:ipe(e.controlBindings)}):"__none__"}function nT(e,t){return e&&t.has(e)?e:null}function ape({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 nT(e,o)||nT(t,o)||nT(n,o)||((s=r==null?void 0:r[0])==null?void 0:s.id)||null}function Yq(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:N$(r)).join("");return/^[A-Za-z]/.test(n)?n:`input${N$(n)}`}function KR(e,t){const n=Yq(e);return Kq(n,t)}function A0(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 Eu(e,t){return Kq(A0(e),t)}function Kq(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 ZR(e){return p.getDataType(e.dataType)==="date"?["label","start","end","range"]:["label","value"]}function XR(e){return cpe(e)?["label","value"]:["value"]}function C$(e){return e.kind==="filter"?`filter:${e.filter.id}`:`control:${e.control.id}`}function lpe(e){return{placement:e.hide||e.displayMode==="canvas"?"hidden":"toolbar",...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function Zq(e){return{placement:e.hidden?"hidden":e.placement||(e.scope==="card"?"card_header":"toolbar"),...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function K1(e){return!!e.compatibility}function cpe(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 N$(e){return e&&e[0].toUpperCase()+e.slice(1)}function upe(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(dpe(u,c.id)),n.add(u.id),o=!0);const s=t.map(c=>{if(c.kind==="filter"&&_$(c,r)&&c.filter.variableName!==c.variableName)return o=!0,{...c,filter:{...c.filter,variableName:c.variableName}};if(c.kind!=="control"||!_$(c,r))return c;const u=Eu(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 dpe(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 _$(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 fpe(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function hpe(e,t){const n=fpe(e);return n==="dark"?fl({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function k$(e,t,n){return xme(hpe(e,t),n)}function mpe(e){return Ss.stableSerialize({hasExplicitDefaultControlValues:e!==void 0,values:e??null})}function ppe(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 gpe(e,t){const n=S.useRef({key:t,value:e});return n.current.key!==t&&(n.current={key:t,value:e}),n.current.value}function bpe({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o,defaultControlValues:s,controlContractOverrides:i,dashboardInputExecutionSnapshot:a,type:c,cardId:u,selectedSheetId:d,onFilterValuesChange:f}){var ye,se,Ie,fe,me;const{authToken:h,tokenProps:m}=gt();npe();const g=p.useDashboardStore(we=>we.selectedLensId),b=p.useDashboardStore(we=>we.relaodToken),{data:x,isLoading:y,isFetching:w,isError:v,refetch:C,dashboardIdToFetch:N}=M0(),_=((se=(ye=m==null?void 0:m.params)==null?void 0:ye.calendarContext)==null?void 0:se.tz)||((Ie=m==null?void 0:m.params)==null?void 0:Ie.timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone,k=(fe=x==null?void 0:x.dashboard)==null?void 0:fe.id,{getDefaultSheetId:j,clearDefaultSheetId:I}=Gq(k),[T,E]=S.useState(o||[]),D=S.useRef(null),A=S.useRef(null),P=mpe(s),M=f2(i),L=f2(i,{includePresentation:!0}),$=S.useRef(s);$.current=s;const z=S.useRef(P);z.current=P;const W=gpe(i,L),F=S.useRef(null),X=S.useRef(!1),Y=S.useRef({dashboardId:null,defaultControlValuesKey:P,controlContractOverridesKey:M}),{setTheme:R}=VR(),{compiledAppearance:K}=p.useAppearance(),O=p.useDashboardStore(we=>we.dashboard.globalStyle),U=S.useMemo(()=>x!=null&&x.dashboard?upe(ppe($s(x.dashboard),{controlContractOverrides:W,cardId:u})):void 0,[x==null?void 0:x.dashboard,W,c,u]),{setDashboardWithFilterValues:V,hydrateRuntimeControlValues:H,setStyle:q,setOnSaveFunction:B,setLenses:G,setSelectedLensId:Z,setInlineFilterValuesMap:J}=p.useDashboardActions();p.useDashboardStore(we=>we.actions.setCustomCards);const oe=p.useDashboardStore(we=>we.filterValues),ie=p.useDashboardStore(we=>we.actions.setThemeStyle),ue=p.useDashboardStore(we=>we.actions.setDashboardTheme),xe=p.useDashboardStore(we=>we.actions.setOnEvent);S.useEffect(()=>{const we=A.current;we&&we!==N&&p.storeEvents.emit("dashboard:unload"),A.current=N},[N]),S.useEffect(()=>{b&&C()},[C,b]),S.useEffect(()=>{var re;const we=((re=x==null?void 0:x.dashboard)==null?void 0:re.id)||null,ee=D.current;we&&we!==ee&&p.storeEvents.emit("dashboard:load"),D.current=we},[(me=x==null?void 0:x.dashboard)==null?void 0:me.id]),S.useEffect(()=>{ue(K.mode)},[K.mode,ue]),S.useEffect(()=>{t&&R(t)},[t,R]);const te=S.useCallback(()=>{const we=$s(p.DEFAULT_STYLE),ee=fl(we,O);if(e){const re=fl(ee,e),ne=k$(K.mode,re,K);ie(ne),q(re)}else{const re=k$(K.mode,ee,K);ie(re),q(p.DEFAULT_STYLE)}},[K,e,O,ie,q]);return S.useEffect(()=>{x&&x.dashboard&&te()},[K.mode,e,O,te,x]),S.useEffect(()=>{var He,_e,Me,De;function we(je,Ue){const mt=je.filters||[],pt=[];for(const ut of Ue){const ht=mt.find(nt=>nt.id===ut.filterId);ht&&pt.push({filterId:ut.filterId,name:ht.column,operation:ut.operation,valueType:p.getFilterValueType(ht),values:ut.values,dataType:ht.dataType,fieldMeta:ht.fieldMeta,semanticContext:ht.semanticContext})}return pt}if(!x||!U)return;const ee=U,{filterValues:re,defaultLensId:ne,lenses:ce}=x;function ae(){if(re&&(re==null?void 0:re.length)>0)return re;const Ue=[...p.buildFilterValuesFromDefaults(ee.filters,_)];if(ee.defaultFilterValues&&ee.defaultFilterValues.length>0)for(const ut of ee.defaultFilterValues){const ht=Ue.findIndex(nt=>nt.filterId===ut.filterId);ht>=0?Ue[ht]=ut:Ue.push(ut)}const mt=we(ee,T||[]),pt=[...Ue];for(const ut of mt){const ht=pt.findIndex(nt=>nt.filterId===ut.filterId);ht>=0?pt[ht]=ut:pt.push(ut)}return pt}const Ne=p.useDashboardStore.getState(),Ee=F.current===U.id&&((He=Ne.dashboard)==null?void 0:He.id)===U.id,Ve=ae(),ge=Ee?p.resolveSameDashboardFilterValues({previousFilters:(_e=Ne.dashboard)==null?void 0:_e.filters,nextFilters:ee.filters,currentFilterValues:Ne.filterValues,defaultFilterValues:Ve}):Ve,pe=p.computeInlineFilterDefaults(ee,_),$e=Ee&&Y.current.controlContractOverridesKey===M?p.flattenRuntimeControlValues({dashboardValues:Ne.controlValues,cardValuesMap:Ne.cardControlValuesMap}):$.current,Fe=Ne.selectedSheetId;let ze=j(),Ze=Fe;Ze&&((Me=U==null?void 0:U.sheets)!=null&&Me.some(Ue=>Ue.id===Ze)||(Ze=null)),ze&&((De=U==null?void 0:U.sheets)!=null&&De.some(Ue=>Ue.id===ze)||(I(),ze=null));const Je=ape({selectedSheetId:d,preservedSelectedSheetId:Ze,defaultSheetId:ze,sheets:U==null?void 0:U.sheets}),Ce=!!a,Qe=!Ce&&X.current;V(ee,ge||[],$e,{selectedSheetId:Je,...x!=null&&x.semanticExecutionPayload?{semanticExecutionPayload:x.semanticExecutionPayload}:{},...a?{dashboardInputValues:a.dashboardInputValues,dashboardInputValuesAreAuthoritative:!0}:Qe?{dashboardInputValues:{},dashboardInputValuesAreAuthoritative:!1}:{}}),X.current=Ce,F.current=U.id,Y.current.dashboardId!==U.id&&(Y.current={dashboardId:U.id,defaultControlValuesKey:z.current,controlContractOverridesKey:M}),J(pe),ce&&G(ce),ne&&Z(ne)},[x,_,g,G,V,Z,J,T,d,j,I,M,a,U]),S.useEffect(()=>{if(!(U!=null&&U.id))return;const we=Y.current;if(we.dashboardId!==U.id){Y.current={dashboardId:U.id,defaultControlValuesKey:P,controlContractOverridesKey:M};return}we.defaultControlValuesKey===P&&we.controlContractOverridesKey===M||(H(U,$.current),Y.current={dashboardId:U.id,defaultControlValuesKey:P,controlContractOverridesKey:M})},[U,P,M,H]),S.useEffect(()=>{f&&oe&&f(oe)},[oe,f]),S.useEffect(()=>{n&&B(n),r&&xe(r)},[n,B,r,xe]),{isFetching:w,isLoading:y,isError:v}}const cy=Q.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}));cy.displayName="Card";const QR=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex flex-col space-y-1.5 p-6",e),...t}));QR.displayName="CardHeader";const Jp=Q.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:p.cn("text-2xl font-semibold leading-none tracking-tight",e),...t}));Jp.displayName="CardTitle";const xpe=Q.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));xpe.displayName="CardDescription";const JR=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("px-6 pt-0",e),...t}));JR.displayName="CardContent";const Xq=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex items-center p-6 pt-0",e),...t}));Xq.displayName="CardFooter";/**
|
|
@@ -1343,4 +1343,4 @@ prismjs/prism.js:
|
|
|
1343
1343
|
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")?`
|
|
1344
1344
|
|
|
1345
1345
|
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 e$({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(Vi,{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:J0t(e)})]})}function evt({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(e$,{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 tvt({text:e,files:t}){return l.jsxs(Jfe,{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(Jdt,{file:n},n.id))})]})}function nvt({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(bft,{children:JSON.stringify(o,null,2)})]})]})}function ehe(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")?J3(r,t):!1}})}function nq(){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 rvt({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(nq,{}),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(nq,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(e$,{errorMessage:t}):null}function ovt(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 svt({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:o,showSystemMessage:s=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,w,v,C;const u=ovt(n),d=e.id===u;if(e.role==="user"){const N=((y=e.parts)==null?void 0:y.filter(I=>I.type==="text"))||[],_=((w=e.parts)==null?void 0:w.filter(I=>I.type==="file"))||[],k=N.map(I=>I.text).join(`
|
|
1346
|
-
`).trim(),j=_.map((I,T)=>{var A,P;let E="",D;if((A=I.url)!=null&&A.startsWith("data:")){const M=I.url.match(/data:[^;]+;base64,(.+)/);M&&(E=M[1],(P=I.mediaType)!=null&&P.startsWith("image/")&&(D=I.url))}return{id:`${e.id||t}-file-${T}`,name:I.filename||`File ${T+1}`,size:0,type:I.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(tvt,{text:k||void 0,files:j.length>0?j:void 0})}const f=((v=e.parts)==null?void 0:v.filter(N=>N.type==="reasoning"))||[],h=f.length>0,m=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||m)?l.jsxs(Cc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Nc,{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(Pt.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(_c,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,_)=>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:_+1}),l.jsx(YU,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${_}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,_)=>{var j;const k=`${e.id||t}-${_}`;switch(N.type){case"text":{const I=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:T,quickReplies:E}=X0t(I),D=T.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(YU,{text:T,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:A,value:P},M)=>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(P),children:l.jsx("span",{className:"truncate",children:A})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${k}-qr-${M}`))})]})]},k)}return e.role==="system"&&s?l.jsx(nvt,{text:I},k):null}case"error":{const I=N,T=I.errorText??I.error??I.message;return l.jsx("div",{className:"my-4",children:l.jsx(e$,{errorMessage:T})},k)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&J3(N,r)?l.jsx(ka,{FallbackComponent:({error:I,resetErrorBoundary:T})=>l.jsx(evt,{error:I,resetErrorBoundary:T}),children:l.jsx(W0t,{part:N,idx:k,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},k):null}});return e.role==="assistant"?ehe(e,r)?l.jsxs(Jfe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const ivt=8,avt=24,lvt=20;function cvt(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function the({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=S.useRef(null),x=S.useRef(null),y=S.useRef(e.length),w=S.useRef(!1),v=S.useRef(null),C=S.useRef(!1),N=S.useRef(g),[_,k]=S.useState(!0),[j,I]=S.useState(0),[T,E]=S.useState(avt);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=ehe(D,t),P=cvt(a,c,u,A),M=gk({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const F=e[W];return(F==null?void 0:F.role)==="user"?88:180},getItemKey:W=>{const F=e[W];return(F==null?void 0:F.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:ivt,overscan:6,gap:20,paddingEnd:P?T+lvt:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const F=W.isAtEnd();k(X=>X===F?X:F),F&&I(0)}}),L=S.useCallback((W="smooth")=>{v.current!==null&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{v.current=null,M.scrollToEnd({behavior:W})}),I(0),k(!0)},[M]);S.useLayoutEffect(()=>{w.current||(w.current=!0,L("auto"))},[L]),S.useLayoutEffect(()=>{C.current&&(C.current=!1,L("auto"))},[e.length,g,L]),S.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!M.isAtEnd()&&I(F=>F+e.length-W),e.length===0&&(I(0),k(!0),w.current=!1,C.current=!1)},[e.length,M]);const $=M.getVirtualItems(),z=M.getTotalSize();return S.useEffect(()=>()=>{v.current!==null&&cancelAnimationFrame(v.current)},[]),S.useLayoutEffect(()=>{const W=x.current;if(!W||!P)return;const F=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&E(R=>R===Y?R:Y)};if(F(),typeof ResizeObserver>"u")return;const X=new ResizeObserver(F);return X.observe(W),()=>X.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{"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:z},children:[$.map(W=>{const F=e[W.index];return F?l.jsx("div",{ref:M.measureElement,"data-index":W.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${W.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(svt,{message:F,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},W.key):null}),P&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(z-T,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(rvt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!_&&l.jsxs("button",{type:"button",onClick:()=>L("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(bo,{className:"h-3 w-3"}),"Latest",j>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:j>9?"9+":j})]})]})}function uvt(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 dvt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function fvt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=S.useState(!1),[a,c]=S.useState(p.isDevEnv),[u,d]=S.useState(!1),[f,h]=S.useState("auto"),[m,g]=S.useState(!1),[b,x]=S.useState(!1),[y,w]=S.useState(0),v=n??b,{isLocalDev:C,isConsoleMode:N}=eg(),_=C||N||a,k=S.useRef(null);p.useDashboardStore(ae=>ae.dashboard.aiScopeTables),p.useDashboardStore(ae=>ae.isDashboardEditing);const j=p.useDashboardStore(ae=>ae.selectedSheetId),{setDataSource:I}=p.useEditorActions(),{setSelectedFrameId:T,setIsDashboardEditing:E}=p.useDashboardActions(),D=xL(),{clearAssistantMessageContexts:A}=p.useAIActions(),{clearQueue:P}=p.useQueueActions(),{clearFileAttachments:M,getFileAttachments:L}=p.useFileActions(),$=p.useFileAttachments("dashboard"),z=p.useEditorStore(ae=>ae.card.dataSource),{assistantProfile:W}=lde(),F=p.useDashboardStore(ae=>ae.handleOpenAssistantProfile),{selectedEntities:X,applyDashboardDefaultEntities:Y}=oj("dashboard"),{sendMessage:R,isLoading:K,messages:O,setMessages:U,status:V,stop:H,errorMessage:q,clearError:B}=Mdt({dynamicVisualMode:f}),G=S.useCallback(()=>{w(ae=>ae+1)},[]),Z=S.useCallback(ae=>{r==null||r(ae),n===void 0&&x(ae)},[n,r]),J=S.useCallback(()=>{Z(!v)},[v,Z]);S.useEffect(()=>{if(!v)return;function ae(Ne){Ne.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ae),()=>{window.removeEventListener("keydown",ae)}},[v,Z]);const[oe,ie]=S.useState(""),ue=ae=>{ie(ae.target.value)};async function xe({sql:ae,cardTitle:Ne,connectionId:Ee,cardType:Ve,python:ge,cardConfig:pe,dataSource:$e,customVisualPreferences:Fe,visualizationMode:ze,dynamicCardPreferences:Ze}){if(!j)return;const Je=ze==="dynamic",Ce=p.hasValidCardConfig(pe),Qe=Ee||($e==null?void 0:$e.connectionId)||"",He=$e?{...$e,connectionId:Qe||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:Qe?{connectionId:Qe,connectionType:"",mode:"database",selectedEntities:[]}:Zp,Me=!(Ce&&(!Je||(Ze==null?void 0:Ze.provenance)==="card-config"||(Ze==null?void 0:Ze.provenance)==="query_spec")),De=Me?uvt(ae):"",je=Me?ge:"",Ue={id:p.v4(),title:Ne||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Ve==="horizontalBar"?"y":"x"},...Je&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Ve,sql:De,python:je,dataSource:He,config:pe,connectionId:Qe,visualizationMode:ze,dynamicCardPreferences:Ze,customCardPreferences:Fe?{url:Fe.url,componentName:Fe.componentName,pluginChartType:Fe.pluginChartType,settings:Fe.settings,type:"component"}:void 0},mt={id:p.v4(),cards:[Ue],activeCardId:Ue.id};try{await D(j,mt,"end"),E(!0),T(mt.id)}catch(pt){console.error("Failed to add assistant visual to dashboard:",pt),rt.error(pt instanceof Error?pt.message:"Failed to prepare semantic metadata for the new visual")}}const te=ae=>{ae.preventDefault();const Ne=oe.trim();if(!Ne&&$.length===0)return;const Ee=[];Ne&&Ee.push({type:"text",text:Ne}),$.forEach(Ve=>{Ve.data&&Ee.push({type:"file",mediaType:Ve.type,filename:Ve.name,url:`data:${Ve.type};base64,${Ve.data}`})}),R({role:"user",parts:Ee}),ie(""),M("dashboard"),G()};S.useEffect(()=>{var ae;e&&((ae=k.current)==null||ae.focus())},[e]),_de({assistantType:"dashboard",status:V,isLoading:K,sendMessage:R});const{hasActiveTools:ye,activeToolText:se}=kde(O);function Ie(ae){const Ne={role:"user",parts:[{type:"text",text:ae.title+" "+ae.subtitle}]};R(Ne),G()}function fe(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}function me(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}const we=S.useCallback(async()=>{const ae=JSON.stringify(O??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ae),rt.success("Conversation copied")}catch(Ne){console.error("Failed to copy conversation",Ne),rt.error("Unable to copy conversation")}},[O]),ee=(oe==null?void 0:oe.length)===0&&(O==null?void 0:O.filter(ae=>ae.role==="user").length)===0;function re(){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 ne(){return l.jsxs(Bo,{children:[l.jsx(Vo,{asChild:!0,children:l.jsx(uc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Nh,{className:"size-3.5"})})}),l.jsxs(ko,{align:"end",children:[l.jsx(fa,{children:"Options"}),l.jsx(qi,{}),l.jsx(Zc,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(Zc,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Zc,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(qi,{}),l.jsx(fa,{children:"Dynamic Visuals"}),l.jsx(Zc,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Zc,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Zc,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ce=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",v&&"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:[re(),F&&l.jsxs("button",{type:"button",onClick:F,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:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&ne(),_&&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(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:v?"Exit fullscreen":"Expand",onClick:J,children:v?l.jsx(Pt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{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 ae=O.filter(Ne=>Ne.role==="assistant").map(Ne=>Ne.id).filter(Ne=>!!Ne);U([]),P("dashboard"),B(),A(ae)},children:l.jsx(oP,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{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(Te.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(the,{messages:O,showTools:a,showSystemMessage:u,onAddToDashboard:xe,onQuickReply:me,disableQuickReplies:K,status:V,errorMessage:q,activeToolText:K&&ye?se:void 0,className:p.cn(v?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(v&&"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:[!W&&ee&&l.jsx(Bce,{onClick:Ie,placeholders:dvt}),ee&&W&&l.jsx(cde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:fe}),l.jsx(Nde,{assistantType:"dashboard"}),l.jsx(M3,{ref:k,setInput:ie,stop:H,input:oe,handleInputChange:ue,handleSubmit:ae=>{te(ae)},isLoading:K,status:V,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(D3,{incomingSelectedEntities:X,open:m,onOpenChange:g,dataSource:z||Zp,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ae=>Y()})]});return v&&o?br.createPortal(l.jsx(Lg,{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:ce})}),o):ce}function hvt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=gie(),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);S.useEffect(()=>{if(!c||u)return;async function d(m){if(mvt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),rt.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=pvt(m);if(g!=null&&g.id){const b=hie(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),rt.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 mvt(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 pvt(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 gvt(e,t){switch(e.interactionMode){case"drillToDetail":bvt(e,t);break;case"drillThrough":xvt(e,t);break;case"drillToURL":yvt(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 bvt(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 xvt(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 yvt(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 vvt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(ks,{open:e,onOpenChange:t,children:l.jsxs(ls,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(Xi,{children:[l.jsx(cs,{children:i||"Insight Detail"}),l.jsx(Gs,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(yie,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(Aie,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function wvt(){const e=p.useInteractionStore(C=>C.interactionStates),t=p.useInteractionStore(C=>C.setInteractionState),n=p.useInteractionStore(C=>C.clearLastInteractionEvent),r=p.useInteractionStore(C=>C.replaceCardWithInsight),o=p.useInteractionStore(C=>C.setPendingDrillThrough),s=p.useInteractionStore(C=>C.pendingDrillThrough),i=p.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Sh(),d=p.useDashboardStore(C=>C.dashboard),f=p.useDashboardStore(C=>C.filterValues),{data:h,isLoading:m}=zG((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=S.useState({open:!1,insightId:""}),x=Rie(g.insightId,{enabled:g.open&&!!g.insightId}),y=S.useRef(new Set),w=S.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:_})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:_})},replaceCardContent:({cardId:C,insightId:N,filters:_,contextMode:k})=>{r(C,N,_,k)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j})=>{const I={filters:C},T={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[I]},E={...p.createInitialInteractionState(),appliedClickFilters:[T],contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);S.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const _=N.lastInteractionEvent,k=`${C}-${_.interactionMode}-${_.sourceCardId}-${Date.now()}`;if(y.current.has(k))return;y.current.add(k);try{gvt(_,w)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(k)},5e3)}}})},[e,n,w]),S.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[s,h,m,u,c,i]);const v=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(vvt,{open:g.open,onOpenChange:v,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 Svt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=Cvt(t.value);return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function Cvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function Nvt(e){return e?`Back to ${e}`:"Back"}function _vt(){var y,w,v,C,N;const e=p.useInteractionStore(_=>_.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(_=>_.actions.goBackFromDrill),n=p.useDashboardStore(_=>_.actions.clearDrillContext),{selectDashboard:r}=Sh(),[o,s]=S.useState({x:16,y:16}),[i,a]=S.useState(!1),c=S.useRef({x:0,y:0});S.useEffect(()=>{if(!i)return;const _=j=>{s({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},k=()=>{a(!1)};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",k)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(v=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:v[0])==null?void 0:C.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||!((N=e.appliedClickFilters)!=null&&N.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(_){console.error("[DrillBack] Error during back navigation:",_)}},g=()=>{n()},b=_=>{_.target.closest("button")||(a(!0),c.current={x:_.clientX-o.x,y:_.clientY-o.y})};Svt(f);const x=Nvt(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((_,k)=>{const j=_.field.label||_.field.name,I=String(_.value);return l.jsxs(co,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",I]},k)})})]}),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(Te.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(R0,{className:"mr-2 h-4 w-4"}),x]})})]})})}function kvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function jvt({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}=qg({id:`filter:${e.id}`,disabled:n||!t}),x={transform:bi.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(Q5,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const rq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Tvt=[];function nhe({open:e,onOpenChange:t}){var O,U,V;const[n,r]=S.useState(!1),[o,s]=S.useState(!1),[i,a]=S.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(H=>{var q;return(q=H.dashboard)==null?void 0:q.sheets}),u=p.useDashboardStore(H=>H.dashboard),d=p.useDashboardStore(H=>H.dashboardInputValues),f=p.useDashboardStore(H=>H.filterValues),h=p.useDashboardStore(H=>H.controlValues),m=p.useDashboardStore(H=>H.inlineFilterValuesMap),g=p.useDashboardStore(H=>H.cardControlValuesMap),b=p.useDashboardStore(H=>H.selectedSheetId),x=p.useDashboardStore(H=>H.selectedSheetId?H.documentInputRuntimeBySheetId[H.selectedSheetId]:void 0),y=p.useDashboardStore(H=>H.isDownloadingPdf),{authToken:w,tokenProps:v}=gt(),C=c==null?void 0:c.find(H=>H.id===b),N=S.useMemo(()=>p.getDashboardExportSheets(c),[c]),_=p.isDocumentSheet(C),k=_&&C?C.document:void 0,j=S.useMemo(()=>_&&C?Wv(u,C.id):[],[C,_,u]),I=j.length>0,T=S.useMemo(()=>_&&C?gce(u,C.id):!1,[C,_,u]),E=S.useMemo(()=>I?j.map(Gv):(k==null?void 0:k.inputs)||Tvt,[k,j,I]),D=((U=(O=v==null?void 0:v.params)==null?void 0:O.calendarContext)==null?void 0:U.tz)||((V=v==null?void 0:v.params)==null?void 0:V.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=S.useMemo(()=>gle(E),[E]),P=S.useMemo(()=>mle(E,D),[E,D]),M=S.useMemo(()=>ple(E),[E]),L=x?x.filterValuesByInputId:P,$=x?x.controlValuesByInputId:M,z=S.useMemo(()=>_?T&&C&&k?wZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(H=>H.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:D}):yle(E,L,$,A,A):[],[k,E,C,_,u,g,h,f,m,d,$,L,A,D,T]),W=!!C,F=N.length>0,X=((c==null?void 0:c.length)||0)>1||_,Y=i.sheetSelection==="current"&&(!W||_&&z.length>0)||i.sheetSelection==="all"&&!F;S.useEffect(()=>{e&&i.sheetSelection==="all"&&!F&&a(H=>({...H,sheetSelection:"current"}))},[F,e,i.sheetSelection]);const R=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){rt.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){rt.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){rt.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!F){rt.error("No dashboard sheets are available to export");return}s(!0);const H=i.sheetSelection==="current"&&_,q=H?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",B=rt.loading(q);try{if(H){if(!k||!C)throw new Error("Selected document sheet is missing document data");if(z.length>0){rt.dismiss(B),rt.error(`Set ${z.join(", ")} before exporting`);return}const Z=new Date().toISOString(),J=T?CZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(oe=>oe.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:Z,timezone:D}).snapshot:void 0;await bF(v.apiServiceUrl,w,{sheetId:C.id,title:C.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:J,...J?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:L,controlValuesByInputId:$,generatedAt:Z}}})}else{const Z=ZJ();await IZ(v.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,Z)}rt.dismiss(B);const G=H?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!";rt.success(G,{duration:2e3}),R()}catch(G){rt.dismiss(B),rt.error("Failed to download PDF",{description:z_(G,"Please try again or contact support."),descriptionClassName:$_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{s(!1)}}return l.jsx(ks,{open:e,onOpenChange:H=>{if(!H){R();return}t(!0)},children:l.jsxs(ls,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Xi,{children:[l.jsx(cs,{className:"text-[15px]",children:_?"Export document":"Export dashboard"}),l.jsx(Gs,{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:[X&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:rq,children:"Export scope"}),l.jsxs(Ca,{value:i.sheetSelection,onValueChange:H=>a({...i,sheetSelection:H}),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",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"current",id:"scope-current",disabled:!W}),_?"This document":"This sheet"," (",(C==null?void 0:C.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",!F&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"all",id:"scope-all",disabled:!F}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),_&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:z.length>0?`Set ${z.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:H=>{a({...i,protectPdf:H,password:H?i.password:""}),H||r(!1)}}),l.jsx(r_,{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:rq,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:H=>a({...i,password:H.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:H=>{H.key==="Enter"&&i.password&&K()}}),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(n_,{className:"h-3.5 w-3.5"}):l.jsx(Pt.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(Ic,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:R,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:K,disabled:o||y||Y,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(jc,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function rhe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=S.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(jc,{className:p.cn("size-4",e)})}),l.jsx(nhe,{open:i,onOpenChange:a})]})}function oq(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 Ivt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=qg({id:`control:${e.id}`,disabled:!n}),d={transform:bi.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(Ale,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function sq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function iq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Evt(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 iq(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=iq(t,n).filter(a=>!s.has(a));return[...o,...i]}function Dvt(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Mvt(e){return Cp(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Cp(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function aq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function Avt(e){const t={sheetId:e.selectedSheetId},n=p.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=p.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||p.getBackingDefaultSlot(e.dashboardInput)}function Rvt(e){return ohe(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 ohe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=Dvt(e.dashboard,t);return FK(D_({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Mvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function Pvt(e,t){return"toolbar"}function Fvt(){const e=Dc("interactive"),t=p.useDashboardStore(U=>U.selectedSheetId),n=p.useDashboardStore(U=>U.dashboard.filters),r=p.useDashboardStore(U=>U.dashboard.filterLayout),o=p.useDashboardStore(U=>U.isDashboardEditing),s=p.useDashboardStore(U=>U.controlValues),i=p.useDashboardStore(U=>U.filterValues);p.useDashboardStore(U=>U.filteringCards);const a=p.useDashboardStore(U=>U.inlineFilterValuesMap),c=p.useDashboardStore(U=>U.dashboardInputValues),u=p.useInteractionStore(U=>U.clearAllClickFilters),d=p.useInteractionStore(U=>Object.entries(U.interactionStates).reduce((V,[H,q])=>{var B;return H===p.DRILL_CONTEXT_CARD_ID?V:V+(((B=q.appliedClickFilters)==null?void 0:B.length)??0)},0)),f=p.useDashboardStore(U=>U.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:v,upsertDashboardInput:C}=p.useDashboardActions(),N=lj(Gp(Hg,{activationConstraint:{distance:5}})),_=p.useDashboardStore(U=>U.dashboard),k=Rvt({dashboard:_,selectedSheetId:t}).filter(U=>Pvt(U.filter)==="toolbar"),j=ohe({dashboard:_,selectedSheetId:t}),I=k.map(U=>U.filter),T=new Map(k.map(U=>[`filter:${U.filter.id}`,U])),E=HYe(_),D=E.filter(U=>!U.hidden&&t0(U)==="toolbar"),A=E.filter(U=>!U.hidden&&t0(U)==="advanced"),P=Evt(r==null?void 0:r.toolbarItemOrder,I,D),M=new Map(I.map(U=>[`filter:${U.id}`,U])),L=new Map(D.map(U=>[`control:${U.id}`,U]));function $(U){const{active:V,over:H}=U;if(!H||V.id===H.id)return;const q=String(V.id),B=String(H.id),G=P.findIndex(ye=>ye===q),Z=P.findIndex(ye=>ye===B);if(G===-1||Z===-1)return;const J=Ug(P,G,Z);y({toolbarItemOrder:J});const oe=new Set((n||[]).map(ye=>ye.id)),ie=P.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),ue=J.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),xe=P.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),te=J.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(oq(n||[],ie,ue)),g(oq(_.controls||[],xe,te))}const z=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,F=(i==null?void 0:i.filter(U=>sq(U)).length)??0,X=j.filter(aq),Y=X.filter(U=>{const V=Avt({dashboardInput:U,dashboardInputValues:c,defaultInputValues:_.defaultInputValues,selectedSheetId:t});return(V==null?void 0:V.status)==="set"&&V.value.kind==="filter"&&sq(V.value.filterValue)}).length,R=a?Object.values(a).reduce((U,V)=>U+((V==null?void 0:V.length)??0),0):0,K=F+Y+R+d,O=()=>{w([]),X.forEach(U=>{m(U,{sheetId:t})}),v([]),u(),a&&Object.entries(a).forEach(([U,V])=>{V==null||V.forEach(H=>{f(U,H.filterId)})})};return!I.length&&!D.length&&!A.length&&!W&&K===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(zv,{sensors:N,collisionDetection:Ov,onDragEnd:$,children:l.jsxs("div",{className:p.cn("flex items-center",z?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(Bv,{items:P,strategy:jL,children:l.jsx(sR,{className:"gap-3 pr-0",wrap:z,children:P.map(U=>{const V=M.get(U);if(V){const q=T.get(U),B=q&&aq(q);return l.jsx(jvt,{filter:V,isEditing:o,storageOptions:B?{storageTarget:"dashboardInput",dashboardInput:q,sheetId:t??void 0}:void 0,inputVariableName:B?q.variableName:void 0,onUpdateFilter:B?(G,Z)=>{C({...q,variableName:(Z==null?void 0:Z.variableName)||q.variableName,filter:G})}:void 0,onRemoveFilter:B?()=>{w((i||[]).filter(G=>G.filterId!==V.id)),b(q.id)}:void 0},U)}const H=L.get(U);return H?l.jsx(Ivt,{control:H,value:s==null?void 0:s[H.id],isEditing:o,onChange:q=>x(H.id,q)},U):null})})}),A.length>0&&l.jsx(Tie,{title:"",controls:A,values:s,onChange:(U,V)=>x(U.id,V),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>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(Te.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:K})]}),W&&l.jsx("div",{className:p.cn(K>0?"ml-1.5":"ml-auto"),children:l.jsx(rhe,{})})]})})})}function she(){var me,we;const{showAssistant:e,tokenProps:t,renderMode:n}=gt(),r=kvt((me=t.config)==null?void 0:me.showDashboardAssistant,e),{preferences:o}=eg(),s=(we=o==null?void 0:o.cardDisplay)==null?void 0:we.mode,i=Rh(s),a=sZ({displayMode:s,renderMode:n}),c=S.useRef(null),u=S.useRef(null),[d,f]=S.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=yst({initialPosition:"bottom-right"}),x=kf(ee=>ee.setFullscreen),y=kf(ee=>ee.setPanelOpen),w=kf(ee=>ee.setContainer),v=HY("dashboard"),C=UY(),N=qY("dashboard"),_=v.isOpen,k=C==="dashboard",j=p.useDashboardStore(ee=>ee.isVisualEditing),I=p.useDashboardStore(ee=>ee.themeStyle),T=Mc(),E=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.sheets}),D=p.useDashboardStore(ee=>ee.showFilters),A=p.useDashboardStore(ee=>ee.isDashboardEditing),P=p.useDashboardStore(ee=>ee.selectedSheetId),M=E==null?void 0:E.find(ee=>ee.id===P),L=p.useDashboardStore(ee=>{var re,ne,ce;return(ce=(ne=(re=ee.dashboard)==null?void 0:re.sheets)==null?void 0:ne.find(ae=>ae.id===ee.selectedSheetId))==null?void 0:ce.kind}),$=p.useDashboardStore(ee=>{var re,ne;return((ne=(re=ee.dashboard)==null?void 0:re.summary)==null?void 0:ne.position)||"top"}),z=L==="document",W=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.id}),{getDefaultSheetId:F,setDefaultSheetId:X,clearDefaultSheetId:Y}=Gq(W),[R,K]=S.useState(null),{setSelectedSheetId:O,setSheetTitle:U,addSheet:V,setSheets:H}=p.useDashboardActions();hvt(u);const{setActiveAssistantType:q}=p.useAIActions();S.useEffect(()=>{if(W){const ee=F();K(ee)}},[W,F]),S.useEffect(()=>{_?q("dashboard"):C==="dashboard"&&x(null)},[_,q,C,x]),S.useEffect(()=>{var ee;_||(ee=c.current)==null||ee.resize(0)},[_]);function B(ee){var re,ne;ee?((re=c.current)==null||re.resize(40),y("dashboard",!0),x("dashboard"),q("dashboard")):(y("dashboard",!1),x(null),(ne=c.current)==null||ne.resize(0),q(null))}function G(ee="dashboard"){const re={id:p.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:p.createDefaultDocumentDefinition()}:{}};V(re),O(re.id)}function Z(ee,re){if(!W)return;R===ee?(Y(),K(null),rt.success("Default sheet cleared")):(X(ee),K(ee),rt.success(`"${re}" set as default sheet`))}function J(ee){var re;ee<1?(y("dashboard",!1),x(null),q(null),(re=c.current)==null||re.resize(0)):(_||y("dashboard",!0),q("dashboard"))}function oe(){return(I==null?void 0:I.canvasTheme)==="muted"||!(I!=null&&I.canvasTheme)?"hsl(var(--semaphor-muted))":(I==null?void 0:I.canvasTheme)==="clear"?"":I==null?void 0:I.canvasTheme}const ie=(ee,re)=>{ee.dataTransfer.setData("tabIndex",re.toString())},ue=ee=>{ee.preventDefault()},xe=(ee,re)=>{const ne=ee.dataTransfer.getData("tabIndex");if(ne===re.toString())return;const ce=Array.from(E||[]),[ae]=ce.splice(parseInt(ne),1);ce.splice(re,0,ae),H(ce)},te=r===!0&&!i&&!_&&!j&&!D;function ye(){if(E&&E.length>1||A)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((ee,re)=>{const ne=P===ee.id,ce=R===ee.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:ae=>ie(ae,re),onDragOver:ue,onDrop:ae=>xe(ae,re),onClick:()=>O(ee.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:ee.id,children:[ee.kind==="document"&&l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(mN,{enabled:A&&ne,text:ee.title,onSave:ae=>U(ee.id,ae),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ce?"Clear default sheet":"Set as default sheet",title:ce?"Clear default sheet":"Set as default sheet",onClick:ae=>{ae.stopPropagation(),Z(ee.id,ee.title||"Sheet")},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),Z(ee.id,ee.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",ne||ce?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(DW,{className:p.cn("h-3 w-3 transition-colors",ce?"fill-current text-amber-500":"text-muted-foreground")})}),A&&ne&&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:ae=>{ae.stopPropagation(),f(!0)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),f(!0))},children:l.jsx(Te.X,{className:"h-3 w-3"})})]},ee.id)}),A&&l.jsxs(Bo,{children:[l.jsx(Vo,{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(kr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(ko,{align:"start",className:"w-48",children:[l.jsxs(Sn,{onSelect:()=>G("dashboard"),children:[l.jsx(Yf,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(Sn,{onSelect:()=>G("document"),children:[l.jsx(di,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function se(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(ee=>l.jsx(p.TabsContent,{style:{backgroundColor:oe(),...T.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(eH,{sheet:ee})},ee.id))})}function Ie(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",I==null?void 0:I.dashboardTabsContainer),onValueChange:ee=>{O(ee)},value:P||void 0,children:[ye(),$==="top"&&!z&&l.jsx($A,{}),P&&!z&&l.jsx(Fvt,{}),z?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:se()}):l.jsx(Ea,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:se()}),$==="bottom"&&!z&&l.jsx($A,{}),l.jsx(vst,{open:d,setOpen:f})]})}const fe=S.useCallback(ee=>{w("dashboard",ee)},[w]);return E?a&&P&&!z?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',P,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&z&&M?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(eH,{sheet:M})}):l.jsxs(l.Fragment,{children:[l.jsx(wvt,{}),l.jsx(_vt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(zce,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(uR,{children:Ie()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(xst,{open:_,onTabClick:B,withHandle:!0,disabled:!_}),l.jsx(uR,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:J,defaultSize:_?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(fvt,{open:_,setOpen:B,isFullscreen:k,onFullscreenChange:ee=>x(ee?"dashboard":null),fullscreenContainer:N})})})]})]}),l.jsx("div",{ref:fe,className:p.cn("absolute inset-0",!k&&"pointer-events-none")}),te&&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||B(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Fpe,{className:"h-5 w-5"})})})]})]}):null}const ihe=S.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,children:s,className:i,style:a,...c},u)=>{const d=S.useId(),f=S.useMemo(()=>Ovt(d),[d]),{theme:h}=VR(),m=Lvt(h),g=S.useMemo(()=>o??kc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,o,n]),b=S.useMemo(()=>p.compileAppearance({spec:g,systemMode:m}),[g,m]),x=S.useMemo(()=>p.createAppearanceContextValue(f,b),[b,f]);return l.jsx(p.AppearanceContext.Provider,{value:x,children:l.jsx(Lg,{...c,ref:u,className:i,style:a,children:s})})});ihe.displayName="AppearanceProvider";function Ovt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Lvt(e){const t=U1(e),[n,r]=S.useState(()=>$vt());return S.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 $vt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const ahe=S.createContext({openBrandStudioPreview:()=>{}}),zvt=ahe.Provider;function Bvt(){return S.useContext(ahe)}function Vvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=U1(t),[s,i]=S.useState(()=>Hvt(n)||o),a=S.useCallback(u=>{const d=U1(u);Uvt(n,d),i(d)},[n]),c=S.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(_q.Provider,{...r,value:c,children:e})}function Hvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=U1(t,"system");return n===t?n:null}catch{return null}}function Uvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const qvt=S.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function t$({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=gt(),s=M0(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=S.useState(!1),[d,f]=S.useState(null),[h,m]=S.useState(null),[g,b]=S.useState(null),[x,y]=S.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,v=Rn({queryKey:PG({resourceType:Zr.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:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});S.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),S.useEffect(()=>{v.data!==void 0&&y({scopeKey:w,appearance:v.data})},[v.data,w]);const C=(x==null?void 0:x.scopeKey)===w?x.appearance:null,N=i!==void 0?i:v.data!==void 0?v.data:C,_=S.useMemo(()=>kc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),k=S.useCallback(()=>{f(g??h??_),u(!0)},[g,h,_]),j=S.useCallback(()=>{u(!1)},[]);S.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const I=S.useMemo(()=>({openBrandStudioPreview:k}),[k]),T=g??h??e;return l.jsx(Vvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(zvt,{value:I,children:l.jsx(ihe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:T,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(S.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(qvt,{appearance:d,onDraftChange:b,onSave:A=>{m(A),b(A),f(A)},onCancel:j})})})]})})})})}function lhe({children:e,preferences:t}){const{currentUser:n}=Zi(),r=S.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(MG.Provider,{value:r,children:l.jsx(nj,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Wvt(e=2e3,t=500){const n=Xme(),[r,o]=S.useState(!1),[s,i]=S.useState(!1),a=S.useRef(null);return S.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),S.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 n$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=Wvt(e,t);return S.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 che(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:e,children:[l.jsx(n$,{componentType:"dashboard",componentId:e.id}),l.jsx(t$,{appearance:e.appearance,children:l.jsx(lhe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(_P,{...e,type:"dashboard",children:l.jsx(she,{})})})})})]})})}function Gvt(e=[]){const t=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[o,s]=S.useState(),i=S.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 S.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 Yvt({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=eg(),r=Rh((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}=Gvt([t,s,r]);return S.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(Hs,{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(X5,{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(Te.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Kvt(){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(Yvt,{filter:r}),l.jsx(Gk,{filter:r})]},r.id))}):null}function Zvt(){var i;const e=p.useDashboardStore(a=>a.dashboard),t=p.useDashboardStore(a=>a.selectedSheetId),n=p.useDashboardStore(a=>a.isVisualEditing),r=p.useDashboardStore(a=>a.isDashboardEditing),o=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),s=p.isDocumentSheet(o);return l.jsx("div",{role:"dashboard-plus-main",className:p.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!s&&l.jsx(Kvt,{}),l.jsx(she,{})]})})}const Xvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-DQxlOxzy.js"))),Qvt=S.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-4HycwBHR.js"))),Jvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-B309EInF.js")));function ewt({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(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:n,children:[l.jsx(n$,{componentType:"surfboard",componentId:n.id}),l.jsxs(t$,{appearance:s,children:[l.jsx(Vbe,{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(lhe,{preferences:i,children:[o&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Jvt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Xvt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(_P,{...n,type:"dashboard",children:[r&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Qvt,{})}),l.jsx(Zvt,{})]})})})]})]})]})]})})}var twt=Object.defineProperty,nwt=(e,t,n)=>t in e?twt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZS=(e,t,n)=>nwt(e,typeof t!="symbol"?t+"":t,n);const rwt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},owt={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}},swt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function iwt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function uhe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const awt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=uhe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},lwt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},cwt={stringify:e=>e,parse:e=>e},HD={string:cwt,number:lwt,boolean:rwt,function:owt,method:awt,json:swt},Gb=Symbol.for("r2wc.render"),XS=Symbol.for("r2wc.connected"),Ld=Symbol.for("r2wc.context"),Qs=Symbol.for("r2wc.props");function uwt(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=iwt(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(),ZS(this,s,!0),ZS(this,o),ZS(this,r,{}),ZS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Qs].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?HD[y]:null;if(y==="method"){const v=uhe(b);Object.defineProperty(this[Qs].container,v,{enumerable:!0,configurable:!0,get(){return this[Qs][v]},set(C){this[Qs][v]=C,this[Gb]()}}),this[Qs][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Qs][g]=w.parse(x,b,this))}for(const g of a)this[Qs][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[XS]=!0,this[Gb]()}disconnectedCallback(){this[XS]=!1,this[Ld]&&n.unmount(this[Ld]),delete this[Ld]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],v=w?HD[w]:null;y in c&&v!=null&&v.parse&&x&&(this[Qs][y]=v.parse(x,g,this),this[Gb]())}[(s=XS,o=Ld,r=Qs,Gb)](){this[XS]&&(this[Ld]?n.update(this[Ld],this[Qs]):this[Ld]=n.mount(this.container,e,this[Qs]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Qs][m]},set(x){this[Qs][m]=x;const y=b?HD[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Gb]()}})}return h}function dwt(e,t,n){const r=Lhe.createRoot(e),o=S.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function fwt({root:e,ReactComponent:t},n){const r=S.createElement(t,n);e.render(r)}function hwt({root:e}){e.unmount()}function mwt(e,t={}){return uwt(e,t,{mount:dwt,update:fwt,unmount:hwt})}const pwt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"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"},gwt=mwt(che,{props:pwt}),bwt=S.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(XL,{context:t})," "]})}),dhe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),xwt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),ywt=Array.from(dhe).join(", "),vwt=3,wwt="Self-heal",Swt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function Cwt({card:e}){var W,F,X,Y,R;const[t,n]=S.useState({}),{authToken:r}=gt(),o=p.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:s}=p.useAppearance(),i=S.useMemo(()=>Tv(s),[s]),a=p.useEditorStore(K=>K.frame),c=p.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),u=p.useEditorStore(K=>K.actions.setCardInlineFilterValue),d=p.useEditorStore(K=>K.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:m}=Vh(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(F=m==null?void 0:m.visuals)==null?void 0:F.find(K=>{var O;return K.name===((O=f.customCardPreferences)==null?void 0:O.componentName)}),b=Iv(f,g)??"single",x=S.useMemo(()=>nL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=S.useMemo(()=>{const K=x.findIndex(O=>(O==null?void 0:O.id)===e.id);return K<0?-1:Xy(e,K)},[x,e]),w=S.useMemo(()=>b!=="multiple"||y<0?e.type:Jm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),v=S.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:w!==e.type?{...e,type:w}:e,[e,w,b]),{data:C}=O_(v),N=p.useInteractionStore(K=>K.interactionStates),_=p.useDashboardStore(K=>{var O;return(O=K.dashboard)==null?void 0:O.id}),k=p.useDashboardStore(K=>K.dashboard.filters),j=p.useDashboardStore(K=>K.filterValues),I=p.useDashboardStore(K=>K.selectedSheetId),T=S.useMemo(()=>J5({card:e,sheetId:I||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,I,c,u,d]),{cardFilters:E,cardFilterValues:D}=S.useMemo(()=>W0({card:e,interactionStates:N,currentDashboardId:_,filters:k,filterValues:j,selectedSheetId:I}),[e,N,_,k,j,I]),A=S.useCallback((K,O)=>{const U=oL(O);n(V=>({...V,[K]:U}))},[]),P=(X=f.customCardPreferences)==null?void 0:X.componentName,M=P?h(P):null,L=fN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),$=S.useMemo(()=>tL(x),[x]),z=S.useMemo(()=>$.map((K,O)=>Jm(K,O,g==null?void 0:g.slots)),[$,g==null?void 0:g.slots]);return P?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(S.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[M&&b==="single"&&l.jsx(M,{editing:!0,params:o,theme:i,settings:L,cardMetadata:Wse({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T}),M&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,O)=>{if(!K)return null;const U=Xy(K,O),V=Jm(K,U,g==null?void 0:g.slots);return l.jsx(_5,{onDataChange:A,card:K,effectiveCardType:V},`${K.id}-${U}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(M,{editing:!0,onDataChange:A,...sL({configCard:f,slotOrderedCards:$,slotTypes:z,multiInputData:t,params:o,theme:i,chartSettings:L,filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T})})})]})]},(R=f.customCardPreferences)==null?void 0:R.componentName)}):null}const Nwt=S.memo(Cwt,(e,t)=>{var n,r,o,s,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((o=e.card.customCardPreferences)==null?void 0:o.slotSettings)===((s=t.card.customCardPreferences)==null?void 0:s.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),_wt=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 fhe=["PageUp","PageDown"],hhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],mhe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Qg="Slider",[OR,kwt,jwt]=p.createCollection(Qg),[phe]=p.createContextScope(Qg,[jwt]),[Twt,Zj]=phe(Qg),ghe=Q.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=Q.useRef(new Set),y=Q.useRef(0),v=i==="horizontal"?Iwt:Ewt,[C=[],N]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(E)}}),_=Q.useRef(C);function k(E){const D=Pwt(C,E);T(E,D)}function j(E){T(E,y.current)}function I(){const E=_.current[y.current];C[y.current]!==E&&h(C)}function T(E,D,{commit:A}={commit:!1}){const P=$wt(s),M=zwt(Math.round((E-r)/s)*s+r,P),L=p.clamp(M,[r,o]);N(($=[])=>{const z=Awt($,L,D);if(Lwt(z,c*s)){y.current=z.indexOf(L);const W=String(z)!==String($);return W&&A&&h(z),W?z:$}else return $})}return l.jsx(Twt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(OR.Provider,{scope:e.__scopeSlider,children:l.jsx(OR.Slot,{scope:e.__scopeSlider,children:l.jsx(v,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:p.composeEventHandlers(b.onPointerDown,()=>{a||(_.current=C)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:k,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:I,onHomeKeyDown:()=>!a&&T(r,0,{commit:!0}),onEndKeyDown:()=>!a&&T(o,C.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const M=fhe.includes(E.key)||E.shiftKey&&hhe.includes(E.key)?10:1,L=y.current,$=C[L],z=s*M*D;T($+z,L,{commit:!0})}}})})})})});ghe.displayName=Qg;var[bhe,xhe]=phe(Qg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Iwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),m=p.useComposedRefs(t,v=>h(v)),g=Q.useRef(void 0),b=p.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(v){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],k=r$(N,y?[n,r]:[r,n]);return g.current=C,k(v-C.left)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(yhe,{dir:b,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:v=>{const C=w(v.clientX);i==null||i(C)},onSlideMove:v=>{const C=w(v.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:v=>{const N=mhe[y?"from-left":"from-right"].includes(v.key);u==null||u({event:v,direction:N?-1:1})}})})}),Ewt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=p.useComposedRefs(t,d),h=Q.useRef(void 0),m=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],v=r$(y,m?[r,n]:[n,r]);return h.current=x,v(b-x.top)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(yhe,{"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=mhe[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),yhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=Zj(Qg,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()):fhe.concat(hhe).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))})})}),vhe="SliderTrack",whe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(vhe,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});whe.displayName=vhe;var LR="SliderRange",She=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(LR,n),s=xhe(LR,n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>_he(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+"%"}})});She.displayName=LR;var $R="SliderThumb",Che=Q.forwardRef((e,t)=>{const n=kwt(e.__scopeSlider),[r,o]=Q.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(Dwt,{...e,ref:s,index:i})}),Dwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=Zj($R,n),a=xhe($R,n),[c,u]=Q.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:_he(m,i.min,i.max),b=Rwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?Fwt(x,g,a.direction):0;return Q.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(OR.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(Nhe,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});Che.displayName=$R;var Mwt="RadioBubbleInput",Nhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=Q.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return Q.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})});Nhe.displayName=Mwt;function Awt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function _he(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function Rwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Pwt(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 Fwt(e,t,n){const r=e/2,s=r$([0,50],[0,r]);return(r-s(t)*n)*n}function Owt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Lwt(e,t){if(t>0){const n=Owt(e);return Math.min(...n)>=t}return!0}function r$(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 $wt(e){return(String(e).split(".")[1]||"").length}function zwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var khe=ghe,Bwt=whe,Vwt=She,Hwt=Che;const jhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(khe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(Bwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(Vwt,{className:"absolute h-full bg-primary"})}),l.jsx(Hwt,{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"})]}));jhe.displayName=khe.displayName;const The=["SUN","MON","TUE","WED","THU","FRI","SAT"],Uwt=The.reduce((e,t,n)=>({...e,[t]:n}),{}),$l={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function qwt(e){if(!e||!e.trim())return{...$l};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...$l,isCustom:!0};const[o,s,i,a,c]=r,u=Number(o),d=Number(s);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...$l,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...$l,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(m=>m.toUpperCase()).map(m=>Uwt[m]).filter(m=>typeof m=="number");if(h.length>0)return{...$l,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...$l,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...$l,repeats:"monthly",hour:d,minute:u}:{...$l,hour:d,minute:u,isCustom:!0}}function Wwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((o,s)=>o-s).map(o=>The[o]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Ihe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,o=t.toString().padStart(2,"0");return`${r}:${o} ${n}`}function Gwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Ywt(e){if(e.length===7)return"every day";const t=e.slice().sort((o,s)=>o-s);if(t.length===5&&t.every(o=>o>=1&&o<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(o=>r[o]).join(", ")}function Kwt(e,t,n,r){const o=Ihe(e.hour,e.minute),s=Gwt(t);let i;if(e.isCustom)i=`Custom schedule · ${o} ${s}`;else switch(e.repeats){case"daily":i=`Daily at ${o} ${s}`;break;case"weekly":i=`Weekly · ${Ywt(e.weekdays)} at ${o} ${s}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${o} ${s}`;break;case"monthly":i=`Monthly on the 1st at ${o} ${s}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Zwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=HL;exports.AccordionContent=c0;exports.AccordionItem=a0;exports.AccordionTrigger=l0;exports.AddDataPicker=D3;exports.AggregateTable=Sk;exports.Alert=wF;exports.AlertDescription=SF;exports.AlertDialog=jh;exports.AlertDialogAction=ld;exports.AlertDialogCancel=cd;exports.AlertDialogContent=rd;exports.AlertDialogDescription=ad;exports.AlertDialogFooter=sd;exports.AlertDialogHeader=od;exports.AlertDialogTitle=id;exports.AlertDialogTrigger=lye;exports.AlertTitle=JZ;exports.ArrowDown=bo;exports.ArrowDownIcon=Yqe;exports.ArrowLeft=R0;exports.ArrowRight=t_;exports.ArrowUp=Ro;exports.ArrowUpIcon=Zqe;exports.AssistantContextEntityControls=SR;exports.AssistantVirtualizedMessages=the;exports.AtSign=Qq;exports.AxisConfigurator=lg;exports.Badge=co;exports.Bell=e1;exports.BookType=eW;exports.BulletChartIcon=Gfe;exports.COMMON_TIMEZONES=Zwt;exports.CSS=bi;exports.CalculatedFieldEditor=ole;exports.Calculator=nW;exports.Calendar=ii;exports.Calendar$1=j1;exports.CalendarRange=rW;exports.Card=cy;exports.CardContent=JR;exports.CardHeader=QR;exports.CardSummary=WA;exports.CardTitle=Jp;exports.ChartArea=h2;exports.ChartColumnIncreasing=oW;exports.ChartColumnStacked=sW;exports.ChartJsVisual=vv;exports.ChartLine=iW;exports.ChartNoAxesGantt=lW;exports.ChartPie=cW;exports.ChartScatter=uW;exports.ChatInputWithContext=M3;exports.Checkbox=Tn;exports.ChevronLeft=Ch;exports.ChevronsUpDown=hW;exports.Circle=eP;exports.CircleAlert=Wf;exports.CircleCheck=mW;exports.CircleHelp=pW;exports.Clock=tP;exports.CodeHighlighter=Hf;exports.CodeXml=t1;exports.Collapsible=Cc;exports.CollapsibleContent=_c;exports.CollapsibleTrigger=Nc;exports.ColorField=Ri;exports.Command=hj;exports.CommandEmpty=pj;exports.CommandGroup=gj;exports.CommandInput=DL;exports.CommandItem=bj;exports.CommandList=mj;exports.CommandSeparator=Nae;exports.ComparisonMetadataBadge=Nee;exports.Container=_P;exports.ControlDefaultValueEditor=kle;exports.ControlDefinitionOptionsEditor=_le;exports.ControlIdInput=wle;exports.ControlVisibilitySettings=att;exports.Copy=Du;exports.CopyButton=Iu;exports.CopyPlus=p2;exports.Cross2Icon=eWe;exports.CustomFilterPopover=X5;exports.CustomScrollArea=Ea;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=kJ;exports.DEFAULT_SCHEDULE_VM=$l;exports.Dashboard=che;exports.DashboardCard=Eie;exports.DashboardCreateDialogBase=lY;exports.DashboardExportDialog=nhe;exports.DashboardPlus=ewt;exports.DashboardWC=gwt;exports.DataTableConditionalFormattingSettings=mce;exports.DataTablePagination=dk;exports.Database=Bi;exports.DateRangePicker=D5;exports.DefaultChatTransport=C3;exports.Dialog=ks;exports.DialogContent=ls;exports.DialogDescription=Gs;exports.DialogFooter=Ic;exports.DialogHeader=Xi;exports.DialogTitle=cs;exports.DialogTrigger=sY;exports.DisplayPreferencesProvider=nj;exports.DndContext=zv;exports.Donut=gW;exports.Download=jc;exports.DownloadPdf=rhe;exports.DragOverlay=uae;exports.DropdownMenu=Bo;exports.DropdownMenuCheckboxItem=Zc;exports.DropdownMenuContent=ko;exports.DropdownMenuItem=Sn;exports.DropdownMenuLabel=fa;exports.DropdownMenuRadioGroup=pbe;exports.DropdownMenuRadioItem=DG;exports.DropdownMenuSeparator=qi;exports.DropdownMenuSub=gP;exports.DropdownMenuSubContent=c_;exports.DropdownMenuSubTrigger=l_;exports.DropdownMenuTrigger=Vo;exports.EMPTY_DATA_SOURCE=Zp;exports.Editable=mN;exports.EditableText=Hs;exports.EditorCustomVisual=Nwt;exports.Ellipsis=ui;exports.EllipsisVertical=Nh;exports.ErrorBoundary=ka;exports.ExportError=pg;exports.ExternalLink=xp;exports.EyeOff=n_;exports.Fallback=ej;exports.FallbackVisual=Jy;exports.FeedbackCategory=td;exports.FeedbackDialog=S0;exports.FieldsList=XL;exports.FieldsSection=bwt;exports.FileCode=bW;exports.FileSpreadsheet=xW;exports.FileText=di;exports.Filter=Gf;exports.FilterComponent=Gk;exports.FilterInfo=VA;exports.FilterableFieldsPanel=ile;exports.Globe=_h;exports.Grid3x3=g2;exports.GripVertical=Tc;exports.HEATMAP_PRESET_PALETTES=CM;exports.Hash=yW;exports.House=vW;exports.HoverCard=gg;exports.HoverCardContent=Vu;exports.HoverCardTrigger=bg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=dhe;exports.INLINE_ALLOWED_TOOL_LIST=ywt;exports.INLINE_BLOCKED_MUTATING_TOOLS=xwt;exports.IconButton=uc;exports.IconForFieldType=R1;exports.InfoHover=yL;exports.InlineFilterBar=vie;exports.KPICard=Ku;exports.KeyboardSensor=Lv;exports.Layers=P0;exports.LayoutDashboard=Yf;exports.Link=nP;exports.LoadingDots=Uu;exports.Lock=r_;exports.MAX_SELF_HEAL_ATTEMPTS=vwt;exports.Map=CW;exports.Markdown=cfe;exports.MatrixTableVisual=wk;exports.MdStackedLineChart=qfe;exports.MultiInputEmptyRenderer=_5;exports.PYTHON_DEFAULT_CODE=BR;exports.PanelResizeHandle=Rj;exports.Paperclip=NW;exports.PenLine=b2;exports.Pencil=x2;exports.PendingMessagesDisplay=Nde;exports.PersistedDynamicVisual=tj;exports.PiChartPolar=Bfe;exports.Pin=kW;exports.PinOff=_W;exports.PivotTableTanstack=Og;exports.Placeholders=Bce;exports.Play=jW;exports.Plus=kr;exports.PointerSensor=Hg;exports.Progress=I3;exports.RECOVERABLE_SQL_ERROR_CODES=Swt;exports.Radar=TW;exports.RadioGroup=Ca;exports.RadioGroupItem=Co;exports.RefreshCw=Kf;exports.ResizableHandle=bst;exports.ResizablePanel=uR;exports.ResizablePanelGroup=zce;exports.ResourceEditDialog=$Y;exports.ResourceType=Zr;exports.SELF_HEAL_TIMELINE_STEP=wwt;exports.SeedQuestions=cde;exports.SemaphorContext=D0;exports.SemaphorContextProvider=YR;exports.SemaphorQueryClient=Wq;exports.SemaphorReadyIndicator=n$;exports.SemaphorStyleWrapper=Lg;exports.Send=IW;exports.Settings=rP;exports.Settings2=F0;exports.Share2=EW;exports.ShareDialog=LY;exports.Sheet=fee;exports.SheetContent=SO;exports.SheetDescription=NO;exports.SheetHeader=mee;exports.SheetTitle=CO;exports.SheetTrigger=lFe;exports.Slider=jhe;exports.SortableContext=Bv;exports.Sparkles=Z1;exports.Square=sP;exports.SquarePen=oP;exports.Star=DW;exports.StructuralParticipantSelector=Sle;exports.SummaryCard=$A;exports.TABLE_PRESENTATION_DEFAULT_STYLE=ju;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Oi;exports.TableBody=Bu;exports.TableCell=An;exports.TableColumnVisibilitySettings=nce;exports.TableHead=to;exports.TableHeader=Lh;exports.TablePresentationSettings=oce;exports.TableRow=Sr;exports.TableSkeleton=vL;exports.TableVisual=Hu;exports.TbChartBubble=Vfe;exports.TbChartFunnel=Hfe;exports.TbChartTreemap=Ufe;exports.TextCard=Hp;exports.Textarea=Ih;exports.TiSortNumerically=Wfe;exports.Toggle=Qk;exports.Tornado=MW;exports.Trash2=hl;exports.TreePalm=aP;exports.TrendingUp=AW;exports.TriangleAlert=Vi;exports.TypeGlyph=Av;exports.UXProvider=t$;exports.User=RW;exports.Users=s_;exports.applyFilterOverridesToDashboardInputSlots=vZ;exports.areContextEntitiesEqual=Jn;exports.areEntitiesJoined=DJ;exports.arrayMove=Ug;exports.buildCardControlUsageById=ctt;exports.buildCustomCardTheme=Tv;exports.buildDashboardCardExecutionSnapshot=yZ;exports.buildDashboardControlUsageById=ltt;exports.buildDashboardExecutionSnapshot=pF;exports.buildDashboardInputExecutionSnapshot=wu;exports.buildDashboardSheetsInputExecutionSnapshot=SZ;exports.buildDashboardStructuralParticipantIdsByControlId=Ile;exports.buildFilterFieldMeta=OL;exports.buildFilterSemanticContext=LL;exports.buildInlineFilterNodes=J5;exports.buildMultiInputCustomVisualProps=sL;exports.buildScheduleExpr=Wwt;exports.buildSchedulePreview=Kwt;exports.buildSlotOrderedCards=tL;exports.calculateContextAwareFilters=W0;exports.calculateFieldState=hO;exports.canUserAccessVisuals=m0e;exports.canUserCreateDashboards=VY;exports.canUserEdit=d0e;exports.canUserManageDashboards=h0e;exports.canUserManageGroups=p0e;exports.canUserUseFilters=f0e;exports.cancelExport=XRe;exports.chartSupportsDataLabels=CQ;exports.chartSupportsLegend=wQ;exports.chartTypes=Kj;exports.cleanupKpiMetricComparisonMode=Mae;exports.cloneDeep=$s;exports.cloneLinkedFrameWithSourceMapping=fYe;exports.closestCenter=Ov;exports.commitSharedCalculatedFields=Gd;exports.createAssistantConversationId=Am;exports.createAssistantRequestId=ade;exports.createCardsFromSlots=jWe;exports.createChartConfig=mg;exports.createDashboardControlInputFromControl=oot;exports.createDefaultGlobalDateFilter=k1e;exports.createExport=XJ;exports.createUniqueDashboardInputVariableNameFromName=Eu;exports.dedup=fdt;exports.doesStoredFilterMatchField=Yp;exports.downloadDocumentPdf=bF;exports.downloadPdf=IZ;exports.extractSqlParamReferences=Aoe;exports.extractTableMetadata=FL;exports.fieldAlreadyExists=AJ;exports.findCustomVisualConfigCard=rL;exports.findDashboardFrameById=h1e;exports.flexRender=Bs;exports.formatDisplayFormula=tJe;exports.formatFileSize=ePe;exports.formatFilterLine=tX;exports.formatTimeLabel=Ihe;exports.getAutoDetectedChartIcon=T0t;exports.getChartGridStyle=e_e;exports.getChartIconByType=I0t;exports.getColorForValue=z2;exports.getConfigSlotExpectedType=kWe;exports.getCoreRowModel=lk;exports.getCustomVisualInputCards=nL;exports.getDateFormatOptionsForGranularity=s0;exports.getDefaultAxisConfig=V2;exports.getDefaultChartColors=Ph;exports.getDefaultDataLabelsConfig=rv;exports.getDefaultExportFormat=xX;exports.getDefaultFilterSql=F5;exports.getDefaultLegendConfig=ZF;exports.getDefaultRunningTotalPartitionByFieldIds=ey;exports.getDocumentSectionEditorCard=zet;exports.getDocumentSheetDashboardInputs=Wv;exports.getDownloadUrl=ZRe;exports.getEffectiveCardTypeForSlot=Jm;exports.getEntityIcon=qN;exports.getErrorMessage=Kue;exports.getExportStatus=KRe;exports.getExports=YRe;exports.getExpressionFieldKind=Xu;exports.getFieldExpressionAnnotation=$L;exports.getFilterCount=yN;exports.getGlobalDateFilter=Ah;exports.getGlobalDateFilterCoverage=yi;exports.getGranularityOptionsForFieldType=r3;exports.getKeys=cr;exports.getMatrixVisualLoadingState=vk;exports.getMetricDisplayLabel=gRe;exports.getNewField=LJ;exports.getObjectDiff=kq;exports.getPaginationRowModel=ck;exports.getRoleBasedDisplayOverrides=BY;exports.getRunningTotalOrderByCandidates=NQe;exports.getSelectedDateFilterColumn=Poe;exports.getSheetScopedFilterValues=py;exports.getSlotDefinitionForIndex=eL;exports.getSlotExpectedChartType=Zk;exports.getSlotIndexForCard=Xy;exports.getSortedRowModel=uee;exports.getSupportedExportFormats=bX;exports.getTableConditionalFormattingColumnOptions=lce;exports.getTableOutputColumnOptions=cce;exports.getTablePageSizeOptions=YJ;exports.handleAggregationChange=HA;exports.handleAggregationLabelChange=xie;exports.hasFlatTableTotalsBehavior=NCe;exports.hasMatrixResultData=av;exports.horizontalListSortingStrategy=jL;exports.isCalculatedFilterField=i0;exports.isCardSummaryVisibleOnCard=iL;exports.isCustomVisualConfigCard=OA;exports.isDefaultColor=ACe;exports.isEligibleFlatTableTotalsCard=rg;exports.isExportComplete=JRe;exports.isExportInProgress=QRe;exports.isInAiScopeArray=ddt;exports.isManagedCalculatedExpressionField=ya;exports.isMetricTransformEnabled=SQe;exports.isPromiseLike=wR;exports.isSubtotalEnabledAggregateTable=PL;exports.isSupportedDocumentTableCardType=Bet;exports.lastAssistantMessageIsCompleteWithToolCalls=que;exports.merge=fl;exports.mergeAxisConfig=H2;exports.normalizeConditionalFormatting=lF;exports.normalizeContextFormatMode=aX;exports.normalizeDashboardInputVariableName=A0;exports.normalizeMultiInputPayload=oL;exports.parseScheduleExpr=qwt;exports.pivotData=Z0;exports.prepareFeedbackData=Yj;exports.purify=bA;exports.reindexSlotCards=_We;exports.remarkGfm=Ofe;exports.removeFromScopeArray=hdt;exports.resolveDashboardInputContext=_l;exports.resolveDomainCalculatedFieldForEdit=ZJe;exports.resolveMultiInputType=Iv;exports.resolveMultiInputTypeFromVisual=TWe;exports.resolveTablePageSize=sk;exports.resolveTablePresentationStyle=MO;exports.sanitizeAIScope=Yue;exports.saveCalculatedFieldToCardScope=tR;exports.saveCalculatedFieldToSharedScope=sle;exports.saveCalculatedFieldToSheetScope=nR;exports.seedSemanticMetricFormatDefaults=Rae;exports.setTableColumnVisibility=eee;exports.setupEditorWithCard=L_;exports.showAllTableColumns=oPe;exports.showJoinRequiredNotification=MJ;exports.sortByColumnsToSortState=Ree;exports.sortStateToSortByColumns=Pee;exports.sortableKeyboardCoordinates=IL;exports.supportsMetricTransformForMetric=Aae;exports.supportsTableConditionalFormatting=sce;exports.toEntityArray=xa;exports.ue=rt;exports.useActiveExports=C0e;exports.useActiveToolStatus=kde;exports.useAddFrameWithFreshSemanticExecutionPayload=xL;exports.useAddNewFrame=zie;exports.useAssistantContainer=qY;exports.useAssistantContextEntities=oj;exports.useAssistantLayoutStore=kf;exports.useAssistantPanel=HY;exports.useAssistantProfile=lde;exports.useAutoSubmitQueue=_de;exports.useBrandStudioPreview=Bvt;exports.useCard=TRe;exports.useCardFilterValues=zJ;exports.useCardSummary=aL;exports.useChat=Gue;exports.useColumns=ML;exports.useCreateVisualWithFrame=dxe;exports.useCurrentUserInfo=Zi;exports.useCustomVisual=Vh;exports.useCustomVisualsQuery=Z5;exports.useDashboardAppearance=Mc;exports.useDashboardById=zG;exports.useDashboardPreferences=eg;exports.useDashboardQuery=M0;exports.useDashboardStructuralParticipants=Ele;exports.useDashboardSummary=tie;exports.useDataColumns=Fae;exports.useDateFilterHook=i7e;exports.useDebounce=Yx;exports.useDefaultDashboardMutation=AG;exports.useDisplayPreferences=Nl;exports.useDroppable=cae;exports.useEditorAside=xj;exports.useEditorCardQuery=O_;exports.useEnsureReactGlobals=loe;exports.useExportActions=WY;exports.useExportStore=b_;exports.useFieldManagement=Pae;exports.useFilterableFields=Iae;exports.useFullscreenAssistant=UY;exports.useGroupMembers=hye;exports.useGroups=EY;exports.useHasDashboardId=GY;exports.useInProgressExportsCount=N0e;exports.useJoinabilityMap=RL;exports.useManagementActions=Sh;exports.useManagementStore=$o;exports.useMutation=ss;exports.usePivotTableConfig=Oh;exports.usePluginQuery=Bse;exports.useQuery=Rn;exports.useQueryClient=Xr;exports.useReactTable=uk;exports.useResolveExistingFrameSemanticExecutionPayload=gYe;exports.useResourceManagement=xP;exports.useResourceUpdateState=BG;exports.useScopedFields=Tae;exports.useSelectedVisual=epe;exports.useSemaphorContext=gt;exports.useSensor=Gp;exports.useSensors=lj;exports.useSortable=qg;exports.useStarredChartsStore=_wt;exports.useSurfaceAppearance=Dc;exports.useTableQueryState=_ee;exports.useTextFilterHook=b7e;exports.useTheme=VR;exports.useTopoJson=sv;exports.useUnifiedUsers=CP;exports.useUpdateResource=FG;exports.useUpdateVisualMutation=fxe;exports.useUserPreferences=cY;exports.useVisualById=d_;exports.useVisualManagement=uxe;exports.validateFieldForChartType=Dae;exports.verticalListSortingStrategy=TL;
|
|
1346
|
+
`).trim(),j=_.map((I,T)=>{var A,P;let E="",D;if((A=I.url)!=null&&A.startsWith("data:")){const M=I.url.match(/data:[^;]+;base64,(.+)/);M&&(E=M[1],(P=I.mediaType)!=null&&P.startsWith("image/")&&(D=I.url))}return{id:`${e.id||t}-file-${T}`,name:I.filename||`File ${T+1}`,size:0,type:I.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(tvt,{text:k||void 0,files:j.length>0?j:void 0})}const f=((v=e.parts)==null?void 0:v.filter(N=>N.type==="reasoning"))||[],h=f.length>0,m=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||m)?l.jsxs(Cc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Nc,{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(Pt.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(_c,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,_)=>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:_+1}),l.jsx(YU,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${_}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,_)=>{var j;const k=`${e.id||t}-${_}`;switch(N.type){case"text":{const I=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:T,quickReplies:E}=X0t(I),D=T.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(YU,{text:T,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:A,value:P},M)=>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(P),children:l.jsx("span",{className:"truncate",children:A})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${k}-qr-${M}`))})]})]},k)}return e.role==="system"&&s?l.jsx(nvt,{text:I},k):null}case"error":{const I=N,T=I.errorText??I.error??I.message;return l.jsx("div",{className:"my-4",children:l.jsx(e$,{errorMessage:T})},k)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&J3(N,r)?l.jsx(ka,{FallbackComponent:({error:I,resetErrorBoundary:T})=>l.jsx(evt,{error:I,resetErrorBoundary:T}),children:l.jsx(W0t,{part:N,idx:k,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},k):null}});return e.role==="assistant"?ehe(e,r)?l.jsxs(Jfe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const ivt=8,avt=24,lvt=20;function cvt(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function the({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=S.useRef(null),x=S.useRef(null),y=S.useRef(e.length),w=S.useRef(!1),v=S.useRef(null),C=S.useRef(!1),N=S.useRef(g),[_,k]=S.useState(!0),[j,I]=S.useState(0),[T,E]=S.useState(avt);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=ehe(D,t),P=cvt(a,c,u,A),M=gk({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const F=e[W];return(F==null?void 0:F.role)==="user"?88:180},getItemKey:W=>{const F=e[W];return(F==null?void 0:F.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:ivt,overscan:6,gap:20,paddingEnd:P?T+lvt:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const F=W.isAtEnd();k(X=>X===F?X:F),F&&I(0)}}),L=S.useCallback((W="smooth")=>{v.current!==null&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{v.current=null,M.scrollToEnd({behavior:W})}),I(0),k(!0)},[M]);S.useLayoutEffect(()=>{w.current||(w.current=!0,L("auto"))},[L]),S.useLayoutEffect(()=>{C.current&&(C.current=!1,L("auto"))},[e.length,g,L]),S.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!M.isAtEnd()&&I(F=>F+e.length-W),e.length===0&&(I(0),k(!0),w.current=!1,C.current=!1)},[e.length,M]);const $=M.getVirtualItems(),z=M.getTotalSize();return S.useEffect(()=>()=>{v.current!==null&&cancelAnimationFrame(v.current)},[]),S.useLayoutEffect(()=>{const W=x.current;if(!W||!P)return;const F=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&E(R=>R===Y?R:Y)};if(F(),typeof ResizeObserver>"u")return;const X=new ResizeObserver(F);return X.observe(W),()=>X.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{"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:z},children:[$.map(W=>{const F=e[W.index];return F?l.jsx("div",{ref:M.measureElement,"data-index":W.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${W.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(svt,{message:F,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},W.key):null}),P&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(z-T,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(rvt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!_&&l.jsxs("button",{type:"button",onClick:()=>L("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(bo,{className:"h-3 w-3"}),"Latest",j>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:j>9?"9+":j})]})]})}function uvt(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 dvt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function fvt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=S.useState(!1),[a,c]=S.useState(p.isDevEnv),[u,d]=S.useState(!1),[f,h]=S.useState("auto"),[m,g]=S.useState(!1),[b,x]=S.useState(!1),[y,w]=S.useState(0),v=n??b,{isLocalDev:C,isConsoleMode:N}=eg(),_=C||N||a,k=S.useRef(null);p.useDashboardStore(ae=>ae.dashboard.aiScopeTables),p.useDashboardStore(ae=>ae.isDashboardEditing);const j=p.useDashboardStore(ae=>ae.selectedSheetId),{setDataSource:I}=p.useEditorActions(),{setSelectedFrameId:T,setIsDashboardEditing:E}=p.useDashboardActions(),D=xL(),{clearAssistantMessageContexts:A}=p.useAIActions(),{clearQueue:P}=p.useQueueActions(),{clearFileAttachments:M,getFileAttachments:L}=p.useFileActions(),$=p.useFileAttachments("dashboard"),z=p.useEditorStore(ae=>ae.card.dataSource),{assistantProfile:W}=lde(),F=p.useDashboardStore(ae=>ae.handleOpenAssistantProfile),{selectedEntities:X,applyDashboardDefaultEntities:Y}=oj("dashboard"),{sendMessage:R,isLoading:K,messages:O,setMessages:U,status:V,stop:H,errorMessage:q,clearError:B}=Mdt({dynamicVisualMode:f}),G=S.useCallback(()=>{w(ae=>ae+1)},[]),Z=S.useCallback(ae=>{r==null||r(ae),n===void 0&&x(ae)},[n,r]),J=S.useCallback(()=>{Z(!v)},[v,Z]);S.useEffect(()=>{if(!v)return;function ae(Ne){Ne.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ae),()=>{window.removeEventListener("keydown",ae)}},[v,Z]);const[oe,ie]=S.useState(""),ue=ae=>{ie(ae.target.value)};async function xe({sql:ae,cardTitle:Ne,connectionId:Ee,cardType:Ve,python:ge,cardConfig:pe,dataSource:$e,customVisualPreferences:Fe,visualizationMode:ze,dynamicCardPreferences:Ze}){if(!j)return;const Je=ze==="dynamic",Ce=p.hasValidCardConfig(pe),Qe=Ee||($e==null?void 0:$e.connectionId)||"",He=$e?{...$e,connectionId:Qe||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:Qe?{connectionId:Qe,connectionType:"",mode:"database",selectedEntities:[]}:Zp,Me=!(Ce&&(!Je||(Ze==null?void 0:Ze.provenance)==="card-config"||(Ze==null?void 0:Ze.provenance)==="query_spec")),De=Me?uvt(ae):"",je=Me?ge:"",Ue={id:p.v4(),title:Ne||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Ve==="horizontalBar"?"y":"x"},...Je&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Ve,sql:De,python:je,dataSource:He,config:pe,connectionId:Qe,visualizationMode:ze,dynamicCardPreferences:Ze,customCardPreferences:Fe?{url:Fe.url,componentName:Fe.componentName,pluginChartType:Fe.pluginChartType,settings:Fe.settings,type:"component"}:void 0},mt={id:p.v4(),cards:[Ue],activeCardId:Ue.id};try{await D(j,mt,"end"),E(!0),T(mt.id)}catch(pt){console.error("Failed to add assistant visual to dashboard:",pt),rt.error(pt instanceof Error?pt.message:"Failed to prepare semantic metadata for the new visual")}}const te=ae=>{ae.preventDefault();const Ne=oe.trim();if(!Ne&&$.length===0)return;const Ee=[];Ne&&Ee.push({type:"text",text:Ne}),$.forEach(Ve=>{Ve.data&&Ee.push({type:"file",mediaType:Ve.type,filename:Ve.name,url:`data:${Ve.type};base64,${Ve.data}`})}),R({role:"user",parts:Ee}),ie(""),M("dashboard"),G()};S.useEffect(()=>{var ae;e&&((ae=k.current)==null||ae.focus())},[e]),_de({assistantType:"dashboard",status:V,isLoading:K,sendMessage:R});const{hasActiveTools:ye,activeToolText:se}=kde(O);function Ie(ae){const Ne={role:"user",parts:[{type:"text",text:ae.title+" "+ae.subtitle}]};R(Ne),G()}function fe(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}function me(ae){R({role:"user",parts:[{type:"text",text:ae}]}),G()}const we=S.useCallback(async()=>{const ae=JSON.stringify(O??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ae),rt.success("Conversation copied")}catch(Ne){console.error("Failed to copy conversation",Ne),rt.error("Unable to copy conversation")}},[O]),ee=(oe==null?void 0:oe.length)===0&&(O==null?void 0:O.filter(ae=>ae.role==="user").length)===0;function re(){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 ne(){return l.jsxs(Bo,{children:[l.jsx(Vo,{asChild:!0,children:l.jsx(uc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Nh,{className:"size-3.5"})})}),l.jsxs(ko,{align:"end",children:[l.jsx(fa,{children:"Options"}),l.jsx(qi,{}),l.jsx(Zc,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(Zc,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Zc,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(qi,{}),l.jsx(fa,{children:"Dynamic Visuals"}),l.jsx(Zc,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Zc,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Zc,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ce=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",v&&"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:[re(),F&&l.jsxs("button",{type:"button",onClick:F,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:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&ne(),_&&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(uc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:v?"Exit fullscreen":"Expand",onClick:J,children:v?l.jsx(Pt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{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 ae=O.filter(Ne=>Ne.role==="assistant").map(Ne=>Ne.id).filter(Ne=>!!Ne);U([]),P("dashboard"),B(),A(ae)},children:l.jsx(oP,{className:"h-3.5 w-3.5"})}),l.jsx(uc,{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(Te.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(the,{messages:O,showTools:a,showSystemMessage:u,onAddToDashboard:xe,onQuickReply:me,disableQuickReplies:K,status:V,errorMessage:q,activeToolText:K&&ye?se:void 0,className:p.cn(v?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(v&&"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:[!W&&ee&&l.jsx(Bce,{onClick:Ie,placeholders:dvt}),ee&&W&&l.jsx(cde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:fe}),l.jsx(Nde,{assistantType:"dashboard"}),l.jsx(M3,{ref:k,setInput:ie,stop:H,input:oe,handleInputChange:ue,handleSubmit:ae=>{te(ae)},isLoading:K,status:V,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(D3,{incomingSelectedEntities:X,open:m,onOpenChange:g,dataSource:z||Zp,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ae=>Y()})]});return v&&o?br.createPortal(l.jsx(Lg,{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:ce})}),o):ce}function hvt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=gie(),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);S.useEffect(()=>{if(!c||u)return;async function d(m){if(mvt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),rt.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=pvt(m);if(g!=null&&g.id){const b=hie(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),rt.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 mvt(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 pvt(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 gvt(e,t){switch(e.interactionMode){case"drillToDetail":bvt(e,t);break;case"drillThrough":xvt(e,t);break;case"drillToURL":yvt(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 bvt(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 xvt(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 yvt(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 vvt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(ks,{open:e,onOpenChange:t,children:l.jsxs(ls,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(Xi,{children:[l.jsx(cs,{children:i||"Insight Detail"}),l.jsx(Gs,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(yie,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(Aie,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function wvt(){const e=p.useInteractionStore(C=>C.interactionStates),t=p.useInteractionStore(C=>C.setInteractionState),n=p.useInteractionStore(C=>C.clearLastInteractionEvent),r=p.useInteractionStore(C=>C.replaceCardWithInsight),o=p.useInteractionStore(C=>C.setPendingDrillThrough),s=p.useInteractionStore(C=>C.pendingDrillThrough),i=p.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Sh(),d=p.useDashboardStore(C=>C.dashboard),f=p.useDashboardStore(C=>C.filterValues),{data:h,isLoading:m}=zG((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=S.useState({open:!1,insightId:""}),x=Rie(g.insightId,{enabled:g.open&&!!g.insightId}),y=S.useRef(new Set),w=S.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:_})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:_})},replaceCardContent:({cardId:C,insightId:N,filters:_,contextMode:k})=>{r(C,N,_,k)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j})=>{const I={filters:C},T={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[I]},E={...p.createInitialInteractionState(),appliedClickFilters:[T],contextMode:N,sourceDashboardId:_,sourceDashboardTitle:k,targetDashboardId:j};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);S.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const _=N.lastInteractionEvent,k=`${C}-${_.interactionMode}-${_.sourceCardId}-${Date.now()}`;if(y.current.has(k))return;y.current.add(k);try{gvt(_,w)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(k)},5e3)}}})},[e,n,w]),S.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[s,h,m,u,c,i]);const v=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(vvt,{open:g.open,onOpenChange:v,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 Svt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=Cvt(t.value);return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function Cvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function Nvt(e){return e?`Back to ${e}`:"Back"}function _vt(){var y,w,v,C,N;const e=p.useInteractionStore(_=>_.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(_=>_.actions.goBackFromDrill),n=p.useDashboardStore(_=>_.actions.clearDrillContext),{selectDashboard:r}=Sh(),[o,s]=S.useState({x:16,y:16}),[i,a]=S.useState(!1),c=S.useRef({x:0,y:0});S.useEffect(()=>{if(!i)return;const _=j=>{s({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},k=()=>{a(!1)};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",k)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(v=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:v[0])==null?void 0:C.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||!((N=e.appliedClickFilters)!=null&&N.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(_){console.error("[DrillBack] Error during back navigation:",_)}},g=()=>{n()},b=_=>{_.target.closest("button")||(a(!0),c.current={x:_.clientX-o.x,y:_.clientY-o.y})};Svt(f);const x=Nvt(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((_,k)=>{const j=_.field.label||_.field.name,I=String(_.value);return l.jsxs(co,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",I]},k)})})]}),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(Te.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(R0,{className:"mr-2 h-4 w-4"}),x]})})]})})}function kvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function jvt({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}=qg({id:`filter:${e.id}`,disabled:n||!t}),x={transform:bi.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(Q5,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const rq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Tvt=[];function nhe({open:e,onOpenChange:t}){var O,U,V;const[n,r]=S.useState(!1),[o,s]=S.useState(!1),[i,a]=S.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(H=>{var q;return(q=H.dashboard)==null?void 0:q.sheets}),u=p.useDashboardStore(H=>H.dashboard),d=p.useDashboardStore(H=>H.dashboardInputValues),f=p.useDashboardStore(H=>H.filterValues),h=p.useDashboardStore(H=>H.controlValues),m=p.useDashboardStore(H=>H.inlineFilterValuesMap),g=p.useDashboardStore(H=>H.cardControlValuesMap),b=p.useDashboardStore(H=>H.selectedSheetId),x=p.useDashboardStore(H=>H.selectedSheetId?H.documentInputRuntimeBySheetId[H.selectedSheetId]:void 0),y=p.useDashboardStore(H=>H.isDownloadingPdf),{authToken:w,tokenProps:v}=gt(),C=c==null?void 0:c.find(H=>H.id===b),N=S.useMemo(()=>p.getDashboardExportSheets(c),[c]),_=p.isDocumentSheet(C),k=_&&C?C.document:void 0,j=S.useMemo(()=>_&&C?Wv(u,C.id):[],[C,_,u]),I=j.length>0,T=S.useMemo(()=>_&&C?gce(u,C.id):!1,[C,_,u]),E=S.useMemo(()=>I?j.map(Gv):(k==null?void 0:k.inputs)||Tvt,[k,j,I]),D=((U=(O=v==null?void 0:v.params)==null?void 0:O.calendarContext)==null?void 0:U.tz)||((V=v==null?void 0:v.params)==null?void 0:V.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=S.useMemo(()=>gle(E),[E]),P=S.useMemo(()=>mle(E,D),[E,D]),M=S.useMemo(()=>ple(E),[E]),L=x?x.filterValuesByInputId:P,$=x?x.controlValuesByInputId:M,z=S.useMemo(()=>_?T&&C&&k?wZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(H=>H.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:D}):yle(E,L,$,A,A):[],[k,E,C,_,u,g,h,f,m,d,$,L,A,D,T]),W=!!C,F=N.length>0,X=((c==null?void 0:c.length)||0)>1||_,Y=i.sheetSelection==="current"&&(!W||_&&z.length>0)||i.sheetSelection==="all"&&!F;S.useEffect(()=>{e&&i.sheetSelection==="all"&&!F&&a(H=>({...H,sheetSelection:"current"}))},[F,e,i.sheetSelection]);const R=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){rt.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){rt.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){rt.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!F){rt.error("No dashboard sheets are available to export");return}s(!0);const H=i.sheetSelection==="current"&&_,q=H?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",B=rt.loading(q);try{if(H){if(!k||!C)throw new Error("Selected document sheet is missing document data");if(z.length>0){rt.dismiss(B),rt.error(`Set ${z.join(", ")} before exporting`);return}const Z=new Date().toISOString(),J=T?CZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:k.sections.map(oe=>oe.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:Z,timezone:D}).snapshot:void 0;await bF(v.apiServiceUrl,w,{sheetId:C.id,title:C.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:J,...J?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:L,controlValuesByInputId:$,generatedAt:Z}}})}else{const Z=ZJ();await IZ(v.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,Z)}rt.dismiss(B);const G=H?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!";rt.success(G,{duration:2e3}),R()}catch(G){rt.dismiss(B),rt.error("Failed to download PDF",{description:z_(G,"Please try again or contact support."),descriptionClassName:$_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{s(!1)}}return l.jsx(ks,{open:e,onOpenChange:H=>{if(!H){R();return}t(!0)},children:l.jsxs(ls,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Xi,{children:[l.jsx(cs,{className:"text-[15px]",children:_?"Export document":"Export dashboard"}),l.jsx(Gs,{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:[X&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:rq,children:"Export scope"}),l.jsxs(Ca,{value:i.sheetSelection,onValueChange:H=>a({...i,sheetSelection:H}),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",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"current",id:"scope-current",disabled:!W}),_?"This document":"This sheet"," (",(C==null?void 0:C.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",!F&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Co,{value:"all",id:"scope-all",disabled:!F}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),_&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:z.length>0?`Set ${z.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:H=>{a({...i,protectPdf:H,password:H?i.password:""}),H||r(!1)}}),l.jsx(r_,{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:rq,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:H=>a({...i,password:H.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:H=>{H.key==="Enter"&&i.password&&K()}}),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(n_,{className:"h-3.5 w-3.5"}):l.jsx(Pt.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(Ic,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:R,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:K,disabled:o||y||Y,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(jc,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function rhe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=S.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(jc,{className:p.cn("size-4",e)})}),l.jsx(nhe,{open:i,onOpenChange:a})]})}function oq(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 Ivt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=qg({id:`control:${e.id}`,disabled:!n}),d={transform:bi.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(Ale,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function sq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function iq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Evt(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 iq(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=iq(t,n).filter(a=>!s.has(a));return[...o,...i]}function Dvt(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Mvt(e){return Cp(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Cp(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function aq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function Avt(e){const t={sheetId:e.selectedSheetId},n=p.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=p.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||p.getBackingDefaultSlot(e.dashboardInput)}function Rvt(e){return ohe(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 ohe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=Dvt(e.dashboard,t);return FK(D_({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Mvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function Pvt(e,t){return"toolbar"}function Fvt(){const e=Dc("interactive"),t=p.useDashboardStore(U=>U.selectedSheetId),n=p.useDashboardStore(U=>U.dashboard.filters),r=p.useDashboardStore(U=>U.dashboard.filterLayout),o=p.useDashboardStore(U=>U.isDashboardEditing),s=p.useDashboardStore(U=>U.controlValues),i=p.useDashboardStore(U=>U.filterValues);p.useDashboardStore(U=>U.filteringCards);const a=p.useDashboardStore(U=>U.inlineFilterValuesMap),c=p.useDashboardStore(U=>U.dashboardInputValues),u=p.useInteractionStore(U=>U.clearAllClickFilters),d=p.useInteractionStore(U=>Object.entries(U.interactionStates).reduce((V,[H,q])=>{var B;return H===p.DRILL_CONTEXT_CARD_ID?V:V+(((B=q.appliedClickFilters)==null?void 0:B.length)??0)},0)),f=p.useDashboardStore(U=>U.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:v,upsertDashboardInput:C}=p.useDashboardActions(),N=lj(Gp(Hg,{activationConstraint:{distance:5}})),_=p.useDashboardStore(U=>U.dashboard),k=Rvt({dashboard:_,selectedSheetId:t}).filter(U=>Pvt(U.filter)==="toolbar"),j=ohe({dashboard:_,selectedSheetId:t}),I=k.map(U=>U.filter),T=new Map(k.map(U=>[`filter:${U.filter.id}`,U])),E=HYe(_),D=E.filter(U=>!U.hidden&&t0(U)==="toolbar"),A=E.filter(U=>!U.hidden&&t0(U)==="advanced"),P=Evt(r==null?void 0:r.toolbarItemOrder,I,D),M=new Map(I.map(U=>[`filter:${U.id}`,U])),L=new Map(D.map(U=>[`control:${U.id}`,U]));function $(U){const{active:V,over:H}=U;if(!H||V.id===H.id)return;const q=String(V.id),B=String(H.id),G=P.findIndex(ye=>ye===q),Z=P.findIndex(ye=>ye===B);if(G===-1||Z===-1)return;const J=Ug(P,G,Z);y({toolbarItemOrder:J});const oe=new Set((n||[]).map(ye=>ye.id)),ie=P.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),ue=J.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>oe.has(ye)),xe=P.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),te=J.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(oq(n||[],ie,ue)),g(oq(_.controls||[],xe,te))}const z=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,F=(i==null?void 0:i.filter(U=>sq(U)).length)??0,X=j.filter(aq),Y=X.filter(U=>{const V=Avt({dashboardInput:U,dashboardInputValues:c,defaultInputValues:_.defaultInputValues,selectedSheetId:t});return(V==null?void 0:V.status)==="set"&&V.value.kind==="filter"&&sq(V.value.filterValue)}).length,R=a?Object.values(a).reduce((U,V)=>U+((V==null?void 0:V.length)??0),0):0,K=F+Y+R+d,O=()=>{w([]),X.forEach(U=>{m(U,{sheetId:t})}),v([]),u(),a&&Object.entries(a).forEach(([U,V])=>{V==null||V.forEach(H=>{f(U,H.filterId)})})};return!I.length&&!D.length&&!A.length&&!W&&K===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(zv,{sensors:N,collisionDetection:Ov,onDragEnd:$,children:l.jsxs("div",{className:p.cn("flex items-center",z?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(Bv,{items:P,strategy:jL,children:l.jsx(sR,{className:"gap-3 pr-0",wrap:z,children:P.map(U=>{const V=M.get(U);if(V){const q=T.get(U),B=q&&aq(q);return l.jsx(jvt,{filter:V,isEditing:o,storageOptions:B?{storageTarget:"dashboardInput",dashboardInput:q,sheetId:t??void 0}:void 0,inputVariableName:B?q.variableName:void 0,onUpdateFilter:B?(G,Z)=>{C({...q,variableName:(Z==null?void 0:Z.variableName)||q.variableName,filter:G})}:void 0,onRemoveFilter:B?()=>{w((i||[]).filter(G=>G.filterId!==V.id)),b(q.id)}:void 0},U)}const H=L.get(U);return H?l.jsx(Ivt,{control:H,value:s==null?void 0:s[H.id],isEditing:o,onChange:q=>x(H.id,q)},U):null})})}),A.length>0&&l.jsx(Tie,{title:"",controls:A,values:s,onChange:(U,V)=>x(U.id,V),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>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(Te.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:K})]}),W&&l.jsx("div",{className:p.cn(K>0?"ml-1.5":"ml-auto"),children:l.jsx(rhe,{})})]})})})}function she(){var me,we;const{showAssistant:e,tokenProps:t,renderMode:n}=gt(),r=kvt((me=t.config)==null?void 0:me.showDashboardAssistant,e),{preferences:o}=eg(),s=(we=o==null?void 0:o.cardDisplay)==null?void 0:we.mode,i=Rh(s),a=sZ({displayMode:s,renderMode:n}),c=S.useRef(null),u=S.useRef(null),[d,f]=S.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=yst({initialPosition:"bottom-right"}),x=kf(ee=>ee.setFullscreen),y=kf(ee=>ee.setPanelOpen),w=kf(ee=>ee.setContainer),v=HY("dashboard"),C=UY(),N=qY("dashboard"),_=v.isOpen,k=C==="dashboard",j=p.useDashboardStore(ee=>ee.isVisualEditing),I=p.useDashboardStore(ee=>ee.themeStyle),T=Mc(),E=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.sheets}),D=p.useDashboardStore(ee=>ee.showFilters),A=p.useDashboardStore(ee=>ee.isDashboardEditing),P=p.useDashboardStore(ee=>ee.selectedSheetId),M=E==null?void 0:E.find(ee=>ee.id===P),L=p.useDashboardStore(ee=>{var re,ne,ce;return(ce=(ne=(re=ee.dashboard)==null?void 0:re.sheets)==null?void 0:ne.find(ae=>ae.id===ee.selectedSheetId))==null?void 0:ce.kind}),$=p.useDashboardStore(ee=>{var re,ne;return((ne=(re=ee.dashboard)==null?void 0:re.summary)==null?void 0:ne.position)||"top"}),z=L==="document",W=p.useDashboardStore(ee=>{var re;return(re=ee.dashboard)==null?void 0:re.id}),{getDefaultSheetId:F,setDefaultSheetId:X,clearDefaultSheetId:Y}=Gq(W),[R,K]=S.useState(null),{setSelectedSheetId:O,setSheetTitle:U,addSheet:V,setSheets:H}=p.useDashboardActions();hvt(u);const{setActiveAssistantType:q}=p.useAIActions();S.useEffect(()=>{if(W){const ee=F();K(ee)}},[W,F]),S.useEffect(()=>{_?q("dashboard"):C==="dashboard"&&x(null)},[_,q,C,x]),S.useEffect(()=>{var ee;_||(ee=c.current)==null||ee.resize(0)},[_]);function B(ee){var re,ne;ee?((re=c.current)==null||re.resize(40),y("dashboard",!0),x("dashboard"),q("dashboard")):(y("dashboard",!1),x(null),(ne=c.current)==null||ne.resize(0),q(null))}function G(ee="dashboard"){const re={id:p.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:p.createDefaultDocumentDefinition()}:{}};V(re),O(re.id)}function Z(ee,re){if(!W)return;R===ee?(Y(),K(null),rt.success("Default sheet cleared")):(X(ee),K(ee),rt.success(`"${re}" set as default sheet`))}function J(ee){var re;ee<1?(y("dashboard",!1),x(null),q(null),(re=c.current)==null||re.resize(0)):(_||y("dashboard",!0),q("dashboard"))}function oe(){return(I==null?void 0:I.canvasTheme)==="muted"||!(I!=null&&I.canvasTheme)?"hsl(var(--semaphor-muted))":(I==null?void 0:I.canvasTheme)==="clear"?"":I==null?void 0:I.canvasTheme}const ie=(ee,re)=>{ee.dataTransfer.setData("tabIndex",re.toString())},ue=ee=>{ee.preventDefault()},xe=(ee,re)=>{const ne=ee.dataTransfer.getData("tabIndex");if(ne===re.toString())return;const ce=Array.from(E||[]),[ae]=ce.splice(parseInt(ne),1);ce.splice(re,0,ae),H(ce)},te=r===!0&&!i&&!_&&!j&&!D;function ye(){if(E&&E.length>1||A)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((ee,re)=>{const ne=P===ee.id,ce=R===ee.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:ae=>ie(ae,re),onDragOver:ue,onDrop:ae=>xe(ae,re),onClick:()=>O(ee.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:ee.id,children:[ee.kind==="document"&&l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(mN,{enabled:A&&ne,text:ee.title,onSave:ae=>U(ee.id,ae),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ce?"Clear default sheet":"Set as default sheet",title:ce?"Clear default sheet":"Set as default sheet",onClick:ae=>{ae.stopPropagation(),Z(ee.id,ee.title||"Sheet")},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),Z(ee.id,ee.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",ne||ce?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(DW,{className:p.cn("h-3 w-3 transition-colors",ce?"fill-current text-amber-500":"text-muted-foreground")})}),A&&ne&&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:ae=>{ae.stopPropagation(),f(!0)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.stopPropagation(),f(!0))},children:l.jsx(Te.X,{className:"h-3 w-3"})})]},ee.id)}),A&&l.jsxs(Bo,{children:[l.jsx(Vo,{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(kr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(ko,{align:"start",className:"w-48",children:[l.jsxs(Sn,{onSelect:()=>G("dashboard"),children:[l.jsx(Yf,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(Sn,{onSelect:()=>G("document"),children:[l.jsx(di,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function se(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(ee=>l.jsx(p.TabsContent,{style:{backgroundColor:oe(),...T.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(eH,{sheet:ee})},ee.id))})}function Ie(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",I==null?void 0:I.dashboardTabsContainer),onValueChange:ee=>{O(ee)},value:P||void 0,children:[ye(),$==="top"&&!z&&l.jsx($A,{}),P&&!z&&l.jsx(Fvt,{}),z?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:se()}):l.jsx(Ea,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:se()}),$==="bottom"&&!z&&l.jsx($A,{}),l.jsx(vst,{open:d,setOpen:f})]})}const fe=S.useCallback(ee=>{w("dashboard",ee)},[w]);return E?a&&P&&!z?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',P,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&z&&M?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(eH,{sheet:M})}):l.jsxs(l.Fragment,{children:[l.jsx(wvt,{}),l.jsx(_vt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(zce,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(uR,{children:Ie()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(xst,{open:_,onTabClick:B,withHandle:!0,disabled:!_}),l.jsx(uR,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:J,defaultSize:_?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(fvt,{open:_,setOpen:B,isFullscreen:k,onFullscreenChange:ee=>x(ee?"dashboard":null),fullscreenContainer:N})})})]})]}),l.jsx("div",{ref:fe,className:p.cn("absolute inset-0",!k&&"pointer-events-none")}),te&&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||B(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Fpe,{className:"h-5 w-5"})})})]})]}):null}const ihe=S.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,children:s,className:i,style:a,...c},u)=>{const d=S.useId(),f=S.useMemo(()=>Ovt(d),[d]),{theme:h}=VR(),m=Lvt(h),g=S.useMemo(()=>o??kc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,o,n]),b=S.useMemo(()=>p.compileAppearance({spec:g,systemMode:m}),[g,m]),x=S.useMemo(()=>p.createAppearanceContextValue(f,b),[b,f]);return l.jsx(p.AppearanceContext.Provider,{value:x,children:l.jsx(Lg,{...c,ref:u,className:i,style:a,children:s})})});ihe.displayName="AppearanceProvider";function Ovt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Lvt(e){const t=U1(e),[n,r]=S.useState(()=>$vt());return S.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 $vt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const ahe=S.createContext({openBrandStudioPreview:()=>{}}),zvt=ahe.Provider;function Bvt(){return S.useContext(ahe)}function Vvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=U1(t),[s,i]=S.useState(()=>Hvt(n)||o),a=S.useCallback(u=>{const d=U1(u);Uvt(n,d),i(d)},[n]),c=S.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(_q.Provider,{...r,value:c,children:e})}function Hvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=U1(t,"system");return n===t?n:null}catch{return null}}function Uvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const qvt=S.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function t$({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=gt(),s=M0(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=S.useState(!1),[d,f]=S.useState(null),[h,m]=S.useState(null),[g,b]=S.useState(null),[x,y]=S.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,v=Rn({queryKey:PG({resourceType:Zr.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:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});S.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),S.useEffect(()=>{v.data!==void 0&&y({scopeKey:w,appearance:v.data})},[v.data,w]);const C=(x==null?void 0:x.scopeKey)===w?x.appearance:null,N=i!==void 0?i:v.data!==void 0?v.data:C,_=S.useMemo(()=>kc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),k=S.useCallback(()=>{f(g??h??_),u(!0)},[g,h,_]),j=S.useCallback(()=>{u(!1)},[]);S.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const I=S.useMemo(()=>({openBrandStudioPreview:k}),[k]),T=g??h??e;return l.jsx(Vvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(zvt,{value:I,children:l.jsx(ihe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:T,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(S.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(qvt,{appearance:d,onDraftChange:b,onSave:A=>{m(A),b(A),f(A)},onCancel:j})})})]})})})})}function lhe({children:e,preferences:t}){const{currentUser:n}=Zi(),r=S.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(MG.Provider,{value:r,children:l.jsx(nj,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Wvt(e=2e3,t=500){const n=Xme(),[r,o]=S.useState(!1),[s,i]=S.useState(!1),a=S.useRef(null);return S.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),S.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 n$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=Wvt(e,t);return S.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 che(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:e,children:[l.jsx(n$,{componentType:"dashboard",componentId:e.id}),l.jsx(t$,{appearance:e.appearance,children:l.jsx(lhe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(_P,{...e,type:"dashboard",children:l.jsx(she,{})})})})})]})})}function Gvt(e=[]){const t=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[o,s]=S.useState(),i=S.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 S.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 Yvt({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=eg(),r=Rh((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}=Gvt([t,s,r]);return S.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(Hs,{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(X5,{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(Te.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Kvt(){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(Yvt,{filter:r}),l.jsx(Gk,{filter:r})]},r.id))}):null}function Zvt(){var i;const e=p.useDashboardStore(a=>a.dashboard),t=p.useDashboardStore(a=>a.selectedSheetId),n=p.useDashboardStore(a=>a.isVisualEditing),r=p.useDashboardStore(a=>a.isDashboardEditing),o=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),s=p.isDocumentSheet(o);return l.jsx("div",{role:"dashboard-plus-main",className:p.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!s&&l.jsx(Kvt,{}),l.jsx(she,{})]})})}const Xvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-9DFeKIP4.js"))),Qvt=S.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-3_jiBXsu.js"))),Jvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-DyRHI3mL.js")));function ewt({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(ka,{FallbackComponent:ej,children:l.jsxs(YR,{dashboardProps:n,children:[l.jsx(n$,{componentType:"surfboard",componentId:n.id}),l.jsxs(t$,{appearance:s,children:[l.jsx(Vbe,{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(lhe,{preferences:i,children:[o&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Jvt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Xvt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(_P,{...n,type:"dashboard",children:[r&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Qvt,{})}),l.jsx(Zvt,{})]})})})]})]})]})]})})}var twt=Object.defineProperty,nwt=(e,t,n)=>t in e?twt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZS=(e,t,n)=>nwt(e,typeof t!="symbol"?t+"":t,n);const rwt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},owt={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}},swt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function iwt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function uhe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const awt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=uhe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},lwt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},cwt={stringify:e=>e,parse:e=>e},HD={string:cwt,number:lwt,boolean:rwt,function:owt,method:awt,json:swt},Gb=Symbol.for("r2wc.render"),XS=Symbol.for("r2wc.connected"),Ld=Symbol.for("r2wc.context"),Qs=Symbol.for("r2wc.props");function uwt(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=iwt(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(),ZS(this,s,!0),ZS(this,o),ZS(this,r,{}),ZS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Qs].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?HD[y]:null;if(y==="method"){const v=uhe(b);Object.defineProperty(this[Qs].container,v,{enumerable:!0,configurable:!0,get(){return this[Qs][v]},set(C){this[Qs][v]=C,this[Gb]()}}),this[Qs][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Qs][g]=w.parse(x,b,this))}for(const g of a)this[Qs][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[XS]=!0,this[Gb]()}disconnectedCallback(){this[XS]=!1,this[Ld]&&n.unmount(this[Ld]),delete this[Ld]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],v=w?HD[w]:null;y in c&&v!=null&&v.parse&&x&&(this[Qs][y]=v.parse(x,g,this),this[Gb]())}[(s=XS,o=Ld,r=Qs,Gb)](){this[XS]&&(this[Ld]?n.update(this[Ld],this[Qs]):this[Ld]=n.mount(this.container,e,this[Qs]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Qs][m]},set(x){this[Qs][m]=x;const y=b?HD[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Gb]()}})}return h}function dwt(e,t,n){const r=Lhe.createRoot(e),o=S.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function fwt({root:e,ReactComponent:t},n){const r=S.createElement(t,n);e.render(r)}function hwt({root:e}){e.unmount()}function mwt(e,t={}){return uwt(e,t,{mount:dwt,update:fwt,unmount:hwt})}const pwt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"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"},gwt=mwt(che,{props:pwt}),bwt=S.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(XL,{context:t})," "]})}),dhe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),xwt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),ywt=Array.from(dhe).join(", "),vwt=3,wwt="Self-heal",Swt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function Cwt({card:e}){var W,F,X,Y,R;const[t,n]=S.useState({}),{authToken:r}=gt(),o=p.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:s}=p.useAppearance(),i=S.useMemo(()=>Tv(s),[s]),a=p.useEditorStore(K=>K.frame),c=p.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),u=p.useEditorStore(K=>K.actions.setCardInlineFilterValue),d=p.useEditorStore(K=>K.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:m}=Vh(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(F=m==null?void 0:m.visuals)==null?void 0:F.find(K=>{var O;return K.name===((O=f.customCardPreferences)==null?void 0:O.componentName)}),b=Iv(f,g)??"single",x=S.useMemo(()=>nL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=S.useMemo(()=>{const K=x.findIndex(O=>(O==null?void 0:O.id)===e.id);return K<0?-1:Xy(e,K)},[x,e]),w=S.useMemo(()=>b!=="multiple"||y<0?e.type:Jm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),v=S.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:w!==e.type?{...e,type:w}:e,[e,w,b]),{data:C}=O_(v),N=p.useInteractionStore(K=>K.interactionStates),_=p.useDashboardStore(K=>{var O;return(O=K.dashboard)==null?void 0:O.id}),k=p.useDashboardStore(K=>K.dashboard.filters),j=p.useDashboardStore(K=>K.filterValues),I=p.useDashboardStore(K=>K.selectedSheetId),T=S.useMemo(()=>J5({card:e,sheetId:I||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,I,c,u,d]),{cardFilters:E,cardFilterValues:D}=S.useMemo(()=>W0({card:e,interactionStates:N,currentDashboardId:_,filters:k,filterValues:j,selectedSheetId:I}),[e,N,_,k,j,I]),A=S.useCallback((K,O)=>{const U=oL(O);n(V=>({...V,[K]:U}))},[]),P=(X=f.customCardPreferences)==null?void 0:X.componentName,M=P?h(P):null,L=fN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),$=S.useMemo(()=>tL(x),[x]),z=S.useMemo(()=>$.map((K,O)=>Jm(K,O,g==null?void 0:g.slots)),[$,g==null?void 0:g.slots]);return P?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(S.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[M&&b==="single"&&l.jsx(M,{editing:!0,params:o,theme:i,settings:L,cardMetadata:Wse({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T}),M&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,O)=>{if(!K)return null;const U=Xy(K,O),V=Jm(K,U,g==null?void 0:g.slots);return l.jsx(_5,{onDataChange:A,card:K,effectiveCardType:V},`${K.id}-${U}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(M,{editing:!0,onDataChange:A,...sL({configCard:f,slotOrderedCards:$,slotTypes:z,multiInputData:t,params:o,theme:i,chartSettings:L,filters:E,filterValues:[...D||[],...c||[]],inlineFilters:T})})})]})]},(R=f.customCardPreferences)==null?void 0:R.componentName)}):null}const Nwt=S.memo(Cwt,(e,t)=>{var n,r,o,s,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((o=e.card.customCardPreferences)==null?void 0:o.slotSettings)===((s=t.card.customCardPreferences)==null?void 0:s.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),_wt=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 fhe=["PageUp","PageDown"],hhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],mhe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Qg="Slider",[OR,kwt,jwt]=p.createCollection(Qg),[phe]=p.createContextScope(Qg,[jwt]),[Twt,Zj]=phe(Qg),ghe=Q.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=Q.useRef(new Set),y=Q.useRef(0),v=i==="horizontal"?Iwt:Ewt,[C=[],N]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(E)}}),_=Q.useRef(C);function k(E){const D=Pwt(C,E);T(E,D)}function j(E){T(E,y.current)}function I(){const E=_.current[y.current];C[y.current]!==E&&h(C)}function T(E,D,{commit:A}={commit:!1}){const P=$wt(s),M=zwt(Math.round((E-r)/s)*s+r,P),L=p.clamp(M,[r,o]);N(($=[])=>{const z=Awt($,L,D);if(Lwt(z,c*s)){y.current=z.indexOf(L);const W=String(z)!==String($);return W&&A&&h(z),W?z:$}else return $})}return l.jsx(Twt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(OR.Provider,{scope:e.__scopeSlider,children:l.jsx(OR.Slot,{scope:e.__scopeSlider,children:l.jsx(v,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:p.composeEventHandlers(b.onPointerDown,()=>{a||(_.current=C)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:k,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:I,onHomeKeyDown:()=>!a&&T(r,0,{commit:!0}),onEndKeyDown:()=>!a&&T(o,C.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const M=fhe.includes(E.key)||E.shiftKey&&hhe.includes(E.key)?10:1,L=y.current,$=C[L],z=s*M*D;T($+z,L,{commit:!0})}}})})})})});ghe.displayName=Qg;var[bhe,xhe]=phe(Qg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Iwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),m=p.useComposedRefs(t,v=>h(v)),g=Q.useRef(void 0),b=p.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(v){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],k=r$(N,y?[n,r]:[r,n]);return g.current=C,k(v-C.left)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(yhe,{dir:b,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:v=>{const C=w(v.clientX);i==null||i(C)},onSlideMove:v=>{const C=w(v.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:v=>{const N=mhe[y?"from-left":"from-right"].includes(v.key);u==null||u({event:v,direction:N?-1:1})}})})}),Ewt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=p.useComposedRefs(t,d),h=Q.useRef(void 0),m=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],v=r$(y,m?[r,n]:[n,r]);return h.current=x,v(b-x.top)}return l.jsx(bhe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(yhe,{"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=mhe[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),yhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=Zj(Qg,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()):fhe.concat(hhe).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))})})}),vhe="SliderTrack",whe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(vhe,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});whe.displayName=vhe;var LR="SliderRange",She=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Zj(LR,n),s=xhe(LR,n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>_he(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+"%"}})});She.displayName=LR;var $R="SliderThumb",Che=Q.forwardRef((e,t)=>{const n=kwt(e.__scopeSlider),[r,o]=Q.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(Dwt,{...e,ref:s,index:i})}),Dwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=Zj($R,n),a=xhe($R,n),[c,u]=Q.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:_he(m,i.min,i.max),b=Rwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?Fwt(x,g,a.direction):0;return Q.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(OR.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(Nhe,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});Che.displayName=$R;var Mwt="RadioBubbleInput",Nhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=Q.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return Q.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})});Nhe.displayName=Mwt;function Awt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function _he(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function Rwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Pwt(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 Fwt(e,t,n){const r=e/2,s=r$([0,50],[0,r]);return(r-s(t)*n)*n}function Owt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Lwt(e,t){if(t>0){const n=Owt(e);return Math.min(...n)>=t}return!0}function r$(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 $wt(e){return(String(e).split(".")[1]||"").length}function zwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var khe=ghe,Bwt=whe,Vwt=She,Hwt=Che;const jhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(khe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(Bwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(Vwt,{className:"absolute h-full bg-primary"})}),l.jsx(Hwt,{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"})]}));jhe.displayName=khe.displayName;const The=["SUN","MON","TUE","WED","THU","FRI","SAT"],Uwt=The.reduce((e,t,n)=>({...e,[t]:n}),{}),$l={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function qwt(e){if(!e||!e.trim())return{...$l};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...$l,isCustom:!0};const[o,s,i,a,c]=r,u=Number(o),d=Number(s);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...$l,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...$l,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(m=>m.toUpperCase()).map(m=>Uwt[m]).filter(m=>typeof m=="number");if(h.length>0)return{...$l,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...$l,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...$l,repeats:"monthly",hour:d,minute:u}:{...$l,hour:d,minute:u,isCustom:!0}}function Wwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((o,s)=>o-s).map(o=>The[o]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Ihe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,o=t.toString().padStart(2,"0");return`${r}:${o} ${n}`}function Gwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Ywt(e){if(e.length===7)return"every day";const t=e.slice().sort((o,s)=>o-s);if(t.length===5&&t.every(o=>o>=1&&o<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(o=>r[o]).join(", ")}function Kwt(e,t,n,r){const o=Ihe(e.hour,e.minute),s=Gwt(t);let i;if(e.isCustom)i=`Custom schedule · ${o} ${s}`;else switch(e.repeats){case"daily":i=`Daily at ${o} ${s}`;break;case"weekly":i=`Weekly · ${Ywt(e.weekdays)} at ${o} ${s}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${o} ${s}`;break;case"monthly":i=`Monthly on the 1st at ${o} ${s}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Zwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=HL;exports.AccordionContent=c0;exports.AccordionItem=a0;exports.AccordionTrigger=l0;exports.AddDataPicker=D3;exports.AggregateTable=Sk;exports.Alert=wF;exports.AlertDescription=SF;exports.AlertDialog=jh;exports.AlertDialogAction=ld;exports.AlertDialogCancel=cd;exports.AlertDialogContent=rd;exports.AlertDialogDescription=ad;exports.AlertDialogFooter=sd;exports.AlertDialogHeader=od;exports.AlertDialogTitle=id;exports.AlertDialogTrigger=lye;exports.AlertTitle=JZ;exports.ArrowDown=bo;exports.ArrowDownIcon=Yqe;exports.ArrowLeft=R0;exports.ArrowRight=t_;exports.ArrowUp=Ro;exports.ArrowUpIcon=Zqe;exports.AssistantContextEntityControls=SR;exports.AssistantVirtualizedMessages=the;exports.AtSign=Qq;exports.AxisConfigurator=lg;exports.Badge=co;exports.Bell=e1;exports.BookType=eW;exports.BulletChartIcon=Gfe;exports.COMMON_TIMEZONES=Zwt;exports.CSS=bi;exports.CalculatedFieldEditor=ole;exports.Calculator=nW;exports.Calendar=ii;exports.Calendar$1=j1;exports.CalendarRange=rW;exports.Card=cy;exports.CardContent=JR;exports.CardHeader=QR;exports.CardSummary=WA;exports.CardTitle=Jp;exports.ChartArea=h2;exports.ChartColumnIncreasing=oW;exports.ChartColumnStacked=sW;exports.ChartJsVisual=vv;exports.ChartLine=iW;exports.ChartNoAxesGantt=lW;exports.ChartPie=cW;exports.ChartScatter=uW;exports.ChatInputWithContext=M3;exports.Checkbox=Tn;exports.ChevronLeft=Ch;exports.ChevronsUpDown=hW;exports.Circle=eP;exports.CircleAlert=Wf;exports.CircleCheck=mW;exports.CircleHelp=pW;exports.Clock=tP;exports.CodeHighlighter=Hf;exports.CodeXml=t1;exports.Collapsible=Cc;exports.CollapsibleContent=_c;exports.CollapsibleTrigger=Nc;exports.ColorField=Ri;exports.Command=hj;exports.CommandEmpty=pj;exports.CommandGroup=gj;exports.CommandInput=DL;exports.CommandItem=bj;exports.CommandList=mj;exports.CommandSeparator=Nae;exports.ComparisonMetadataBadge=Nee;exports.Container=_P;exports.ControlDefaultValueEditor=kle;exports.ControlDefinitionOptionsEditor=_le;exports.ControlIdInput=wle;exports.ControlVisibilitySettings=att;exports.Copy=Du;exports.CopyButton=Iu;exports.CopyPlus=p2;exports.Cross2Icon=eWe;exports.CustomFilterPopover=X5;exports.CustomScrollArea=Ea;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=kJ;exports.DEFAULT_SCHEDULE_VM=$l;exports.Dashboard=che;exports.DashboardCard=Eie;exports.DashboardCreateDialogBase=lY;exports.DashboardExportDialog=nhe;exports.DashboardPlus=ewt;exports.DashboardWC=gwt;exports.DataTableConditionalFormattingSettings=mce;exports.DataTablePagination=dk;exports.Database=Bi;exports.DateRangePicker=D5;exports.DefaultChatTransport=C3;exports.Dialog=ks;exports.DialogContent=ls;exports.DialogDescription=Gs;exports.DialogFooter=Ic;exports.DialogHeader=Xi;exports.DialogTitle=cs;exports.DialogTrigger=sY;exports.DisplayPreferencesProvider=nj;exports.DndContext=zv;exports.Donut=gW;exports.Download=jc;exports.DownloadPdf=rhe;exports.DragOverlay=uae;exports.DropdownMenu=Bo;exports.DropdownMenuCheckboxItem=Zc;exports.DropdownMenuContent=ko;exports.DropdownMenuItem=Sn;exports.DropdownMenuLabel=fa;exports.DropdownMenuRadioGroup=pbe;exports.DropdownMenuRadioItem=DG;exports.DropdownMenuSeparator=qi;exports.DropdownMenuSub=gP;exports.DropdownMenuSubContent=c_;exports.DropdownMenuSubTrigger=l_;exports.DropdownMenuTrigger=Vo;exports.EMPTY_DATA_SOURCE=Zp;exports.Editable=mN;exports.EditableText=Hs;exports.EditorCustomVisual=Nwt;exports.Ellipsis=ui;exports.EllipsisVertical=Nh;exports.ErrorBoundary=ka;exports.ExportError=pg;exports.ExternalLink=xp;exports.EyeOff=n_;exports.Fallback=ej;exports.FallbackVisual=Jy;exports.FeedbackCategory=td;exports.FeedbackDialog=S0;exports.FieldsList=XL;exports.FieldsSection=bwt;exports.FileCode=bW;exports.FileSpreadsheet=xW;exports.FileText=di;exports.Filter=Gf;exports.FilterComponent=Gk;exports.FilterInfo=VA;exports.FilterableFieldsPanel=ile;exports.Globe=_h;exports.Grid3x3=g2;exports.GripVertical=Tc;exports.HEATMAP_PRESET_PALETTES=CM;exports.Hash=yW;exports.House=vW;exports.HoverCard=gg;exports.HoverCardContent=Vu;exports.HoverCardTrigger=bg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=dhe;exports.INLINE_ALLOWED_TOOL_LIST=ywt;exports.INLINE_BLOCKED_MUTATING_TOOLS=xwt;exports.IconButton=uc;exports.IconForFieldType=R1;exports.InfoHover=yL;exports.InlineFilterBar=vie;exports.KPICard=Ku;exports.KeyboardSensor=Lv;exports.Layers=P0;exports.LayoutDashboard=Yf;exports.Link=nP;exports.LoadingDots=Uu;exports.Lock=r_;exports.MAX_SELF_HEAL_ATTEMPTS=vwt;exports.Map=CW;exports.Markdown=cfe;exports.MatrixTableVisual=wk;exports.MdStackedLineChart=qfe;exports.MultiInputEmptyRenderer=_5;exports.PYTHON_DEFAULT_CODE=BR;exports.PanelResizeHandle=Rj;exports.Paperclip=NW;exports.PenLine=b2;exports.Pencil=x2;exports.PendingMessagesDisplay=Nde;exports.PersistedDynamicVisual=tj;exports.PiChartPolar=Bfe;exports.Pin=kW;exports.PinOff=_W;exports.PivotTableTanstack=Og;exports.Placeholders=Bce;exports.Play=jW;exports.Plus=kr;exports.PointerSensor=Hg;exports.Progress=I3;exports.RECOVERABLE_SQL_ERROR_CODES=Swt;exports.Radar=TW;exports.RadioGroup=Ca;exports.RadioGroupItem=Co;exports.RefreshCw=Kf;exports.ResizableHandle=bst;exports.ResizablePanel=uR;exports.ResizablePanelGroup=zce;exports.ResourceEditDialog=$Y;exports.ResourceType=Zr;exports.SELF_HEAL_TIMELINE_STEP=wwt;exports.SeedQuestions=cde;exports.SemaphorContext=D0;exports.SemaphorContextProvider=YR;exports.SemaphorQueryClient=Wq;exports.SemaphorReadyIndicator=n$;exports.SemaphorStyleWrapper=Lg;exports.Send=IW;exports.Settings=rP;exports.Settings2=F0;exports.Share2=EW;exports.ShareDialog=LY;exports.Sheet=fee;exports.SheetContent=SO;exports.SheetDescription=NO;exports.SheetHeader=mee;exports.SheetTitle=CO;exports.SheetTrigger=lFe;exports.Slider=jhe;exports.SortableContext=Bv;exports.Sparkles=Z1;exports.Square=sP;exports.SquarePen=oP;exports.Star=DW;exports.StructuralParticipantSelector=Sle;exports.SummaryCard=$A;exports.TABLE_PRESENTATION_DEFAULT_STYLE=ju;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Oi;exports.TableBody=Bu;exports.TableCell=An;exports.TableColumnVisibilitySettings=nce;exports.TableHead=to;exports.TableHeader=Lh;exports.TablePresentationSettings=oce;exports.TableRow=Sr;exports.TableSkeleton=vL;exports.TableVisual=Hu;exports.TbChartBubble=Vfe;exports.TbChartFunnel=Hfe;exports.TbChartTreemap=Ufe;exports.TextCard=Hp;exports.Textarea=Ih;exports.TiSortNumerically=Wfe;exports.Toggle=Qk;exports.Tornado=MW;exports.Trash2=hl;exports.TreePalm=aP;exports.TrendingUp=AW;exports.TriangleAlert=Vi;exports.TypeGlyph=Av;exports.UXProvider=t$;exports.User=RW;exports.Users=s_;exports.applyFilterOverridesToDashboardInputSlots=vZ;exports.areContextEntitiesEqual=Jn;exports.areEntitiesJoined=DJ;exports.arrayMove=Ug;exports.buildCardControlUsageById=ctt;exports.buildCustomCardTheme=Tv;exports.buildDashboardCardExecutionSnapshot=yZ;exports.buildDashboardControlUsageById=ltt;exports.buildDashboardExecutionSnapshot=pF;exports.buildDashboardInputExecutionSnapshot=wu;exports.buildDashboardSheetsInputExecutionSnapshot=SZ;exports.buildDashboardStructuralParticipantIdsByControlId=Ile;exports.buildFilterFieldMeta=OL;exports.buildFilterSemanticContext=LL;exports.buildInlineFilterNodes=J5;exports.buildMultiInputCustomVisualProps=sL;exports.buildScheduleExpr=Wwt;exports.buildSchedulePreview=Kwt;exports.buildSlotOrderedCards=tL;exports.calculateContextAwareFilters=W0;exports.calculateFieldState=hO;exports.canUserAccessVisuals=m0e;exports.canUserCreateDashboards=VY;exports.canUserEdit=d0e;exports.canUserManageDashboards=h0e;exports.canUserManageGroups=p0e;exports.canUserUseFilters=f0e;exports.cancelExport=XRe;exports.chartSupportsDataLabels=CQ;exports.chartSupportsLegend=wQ;exports.chartTypes=Kj;exports.cleanupKpiMetricComparisonMode=Mae;exports.cloneDeep=$s;exports.cloneLinkedFrameWithSourceMapping=fYe;exports.closestCenter=Ov;exports.commitSharedCalculatedFields=Gd;exports.createAssistantConversationId=Am;exports.createAssistantRequestId=ade;exports.createCardsFromSlots=jWe;exports.createChartConfig=mg;exports.createDashboardControlInputFromControl=oot;exports.createDefaultGlobalDateFilter=k1e;exports.createExport=XJ;exports.createUniqueDashboardInputVariableNameFromName=Eu;exports.dedup=fdt;exports.doesStoredFilterMatchField=Yp;exports.downloadDocumentPdf=bF;exports.downloadPdf=IZ;exports.extractSqlParamReferences=Aoe;exports.extractTableMetadata=FL;exports.fieldAlreadyExists=AJ;exports.findCustomVisualConfigCard=rL;exports.findDashboardFrameById=h1e;exports.flexRender=Bs;exports.formatDisplayFormula=tJe;exports.formatFileSize=ePe;exports.formatFilterLine=tX;exports.formatTimeLabel=Ihe;exports.getAutoDetectedChartIcon=T0t;exports.getChartGridStyle=e_e;exports.getChartIconByType=I0t;exports.getColorForValue=z2;exports.getConfigSlotExpectedType=kWe;exports.getCoreRowModel=lk;exports.getCustomVisualInputCards=nL;exports.getDateFormatOptionsForGranularity=s0;exports.getDefaultAxisConfig=V2;exports.getDefaultChartColors=Ph;exports.getDefaultDataLabelsConfig=rv;exports.getDefaultExportFormat=xX;exports.getDefaultFilterSql=F5;exports.getDefaultLegendConfig=ZF;exports.getDefaultRunningTotalPartitionByFieldIds=ey;exports.getDocumentSectionEditorCard=zet;exports.getDocumentSheetDashboardInputs=Wv;exports.getDownloadUrl=ZRe;exports.getEffectiveCardTypeForSlot=Jm;exports.getEntityIcon=qN;exports.getErrorMessage=Kue;exports.getExportStatus=KRe;exports.getExports=YRe;exports.getExpressionFieldKind=Xu;exports.getFieldExpressionAnnotation=$L;exports.getFilterCount=yN;exports.getGlobalDateFilter=Ah;exports.getGlobalDateFilterCoverage=yi;exports.getGranularityOptionsForFieldType=r3;exports.getKeys=cr;exports.getMatrixVisualLoadingState=vk;exports.getMetricDisplayLabel=gRe;exports.getNewField=LJ;exports.getObjectDiff=kq;exports.getPaginationRowModel=ck;exports.getRoleBasedDisplayOverrides=BY;exports.getRunningTotalOrderByCandidates=NQe;exports.getSelectedDateFilterColumn=Poe;exports.getSheetScopedFilterValues=py;exports.getSlotDefinitionForIndex=eL;exports.getSlotExpectedChartType=Zk;exports.getSlotIndexForCard=Xy;exports.getSortedRowModel=uee;exports.getSupportedExportFormats=bX;exports.getTableConditionalFormattingColumnOptions=lce;exports.getTableOutputColumnOptions=cce;exports.getTablePageSizeOptions=YJ;exports.handleAggregationChange=HA;exports.handleAggregationLabelChange=xie;exports.hasFlatTableTotalsBehavior=NCe;exports.hasMatrixResultData=av;exports.horizontalListSortingStrategy=jL;exports.isCalculatedFilterField=i0;exports.isCardSummaryVisibleOnCard=iL;exports.isCustomVisualConfigCard=OA;exports.isDefaultColor=ACe;exports.isEligibleFlatTableTotalsCard=rg;exports.isExportComplete=JRe;exports.isExportInProgress=QRe;exports.isInAiScopeArray=ddt;exports.isManagedCalculatedExpressionField=ya;exports.isMetricTransformEnabled=SQe;exports.isPromiseLike=wR;exports.isSubtotalEnabledAggregateTable=PL;exports.isSupportedDocumentTableCardType=Bet;exports.lastAssistantMessageIsCompleteWithToolCalls=que;exports.merge=fl;exports.mergeAxisConfig=H2;exports.normalizeConditionalFormatting=lF;exports.normalizeContextFormatMode=aX;exports.normalizeDashboardInputVariableName=A0;exports.normalizeMultiInputPayload=oL;exports.parseScheduleExpr=qwt;exports.pivotData=Z0;exports.prepareFeedbackData=Yj;exports.purify=bA;exports.reindexSlotCards=_We;exports.remarkGfm=Ofe;exports.removeFromScopeArray=hdt;exports.resolveDashboardInputContext=_l;exports.resolveDomainCalculatedFieldForEdit=ZJe;exports.resolveMultiInputType=Iv;exports.resolveMultiInputTypeFromVisual=TWe;exports.resolveTablePageSize=sk;exports.resolveTablePresentationStyle=MO;exports.sanitizeAIScope=Yue;exports.saveCalculatedFieldToCardScope=tR;exports.saveCalculatedFieldToSharedScope=sle;exports.saveCalculatedFieldToSheetScope=nR;exports.seedSemanticMetricFormatDefaults=Rae;exports.setTableColumnVisibility=eee;exports.setupEditorWithCard=L_;exports.showAllTableColumns=oPe;exports.showJoinRequiredNotification=MJ;exports.sortByColumnsToSortState=Ree;exports.sortStateToSortByColumns=Pee;exports.sortableKeyboardCoordinates=IL;exports.supportsMetricTransformForMetric=Aae;exports.supportsTableConditionalFormatting=sce;exports.toEntityArray=xa;exports.ue=rt;exports.useActiveExports=C0e;exports.useActiveToolStatus=kde;exports.useAddFrameWithFreshSemanticExecutionPayload=xL;exports.useAddNewFrame=zie;exports.useAssistantContainer=qY;exports.useAssistantContextEntities=oj;exports.useAssistantLayoutStore=kf;exports.useAssistantPanel=HY;exports.useAssistantProfile=lde;exports.useAutoSubmitQueue=_de;exports.useBrandStudioPreview=Bvt;exports.useCard=TRe;exports.useCardFilterValues=zJ;exports.useCardSummary=aL;exports.useChat=Gue;exports.useColumns=ML;exports.useCreateVisualWithFrame=dxe;exports.useCurrentUserInfo=Zi;exports.useCustomVisual=Vh;exports.useCustomVisualsQuery=Z5;exports.useDashboardAppearance=Mc;exports.useDashboardById=zG;exports.useDashboardPreferences=eg;exports.useDashboardQuery=M0;exports.useDashboardStructuralParticipants=Ele;exports.useDashboardSummary=tie;exports.useDataColumns=Fae;exports.useDateFilterHook=i7e;exports.useDebounce=Yx;exports.useDefaultDashboardMutation=AG;exports.useDisplayPreferences=Nl;exports.useDroppable=cae;exports.useEditorAside=xj;exports.useEditorCardQuery=O_;exports.useEnsureReactGlobals=loe;exports.useExportActions=WY;exports.useExportStore=b_;exports.useFieldManagement=Pae;exports.useFilterableFields=Iae;exports.useFullscreenAssistant=UY;exports.useGroupMembers=hye;exports.useGroups=EY;exports.useHasDashboardId=GY;exports.useInProgressExportsCount=N0e;exports.useJoinabilityMap=RL;exports.useManagementActions=Sh;exports.useManagementStore=$o;exports.useMutation=ss;exports.usePivotTableConfig=Oh;exports.usePluginQuery=Bse;exports.useQuery=Rn;exports.useQueryClient=Xr;exports.useReactTable=uk;exports.useResolveExistingFrameSemanticExecutionPayload=gYe;exports.useResourceManagement=xP;exports.useResourceUpdateState=BG;exports.useScopedFields=Tae;exports.useSelectedVisual=epe;exports.useSemaphorContext=gt;exports.useSensor=Gp;exports.useSensors=lj;exports.useSortable=qg;exports.useStarredChartsStore=_wt;exports.useSurfaceAppearance=Dc;exports.useTableQueryState=_ee;exports.useTextFilterHook=b7e;exports.useTheme=VR;exports.useTopoJson=sv;exports.useUnifiedUsers=CP;exports.useUpdateResource=FG;exports.useUpdateVisualMutation=fxe;exports.useUserPreferences=cY;exports.useVisualById=d_;exports.useVisualManagement=uxe;exports.validateFieldForChartType=Dae;exports.verticalListSortingStrategy=TL;
|