react-semaphor 0.1.381 → 0.1.382

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/DATA_APP_SDK.md +238 -0
  2. package/README.md +7 -0
  3. package/dist/analytics-protocol/index.cjs +1 -1
  4. package/dist/analytics-protocol/index.js +45 -41
  5. package/dist/brand-studio/index.cjs +1 -1
  6. package/dist/brand-studio/index.js +6 -6
  7. package/dist/chunks/analyze-result-contract-CtXfp3nv.js +1 -0
  8. package/dist/chunks/analyze-result-contract-DuhlklhI.js +102 -0
  9. package/dist/chunks/{braces-BT-ZyB-g.js → braces-CGi-YFZp.js} +1 -1
  10. package/dist/chunks/{braces-DOxxfERN.js → braces-CP8BEzl3.js} +1 -1
  11. package/dist/chunks/{calendar-preferences-dialog-Dsgs8WDv.js → calendar-preferences-dialog-CV4xF2Tp.js} +3 -3
  12. package/dist/chunks/{calendar-preferences-dialog-iZs8XqyH.js → calendar-preferences-dialog-rDDobeLo.js} +1 -1
  13. package/dist/chunks/catalog-field-grounding-Bnx-3tE0.js +1 -0
  14. package/dist/chunks/catalog-field-grounding-CJKAqtiC.js +100 -0
  15. package/dist/chunks/{dashboard-briefing-launcher-Coks66cV.js → dashboard-briefing-launcher-BT00MvGB.js} +5 -5
  16. package/dist/chunks/{dashboard-briefing-launcher-B5vPTl8P.js → dashboard-briefing-launcher-Dcbh-mjY.js} +1 -1
  17. package/dist/chunks/{dashboard-controls-BfkcnIdy.js → dashboard-controls-B6y7jkKO.js} +8 -8
  18. package/dist/chunks/{dashboard-controls-Dyqye6fh.js → dashboard-controls-CRqnPibB.js} +1 -1
  19. package/dist/chunks/{dashboard-json-DjXi4cI6.js → dashboard-json-CfIUG8k1.js} +3 -3
  20. package/dist/chunks/{dashboard-json-CV_LnO9x.js → dashboard-json-DEQqRR1x.js} +1 -1
  21. package/dist/chunks/{edit-dashboard-visual-DOW1Ap1N.js → edit-dashboard-visual-DMbf89xa.js} +5 -5
  22. package/dist/chunks/{edit-dashboard-visual-yinO0yU-.js → edit-dashboard-visual-wDOcHak3.js} +1 -1
  23. package/dist/chunks/{index-DlprYjr6.js → index-BAsWLkZ8.js} +169 -168
  24. package/dist/chunks/{index-CkoRCh3g.js → index-CrKxP9uF.js} +5 -5
  25. package/dist/chunks/{layout-grid-DTbOIOsE.js → layout-grid-BsKH3TgY.js} +1 -1
  26. package/dist/chunks/{layout-grid-DccceHv4.js → layout-grid-jJQUqDN9.js} +1 -1
  27. package/dist/chunks/operators-C8TxpM4C.js +48 -0
  28. package/dist/chunks/operators-DrTQsJXv.js +1 -0
  29. package/dist/chunks/{palette-SimHJELn.js → palette-9zLPGlj2.js} +1 -1
  30. package/dist/chunks/{palette-DCzLwqIw.js → palette-xU9Qt6bE.js} +1 -1
  31. package/dist/chunks/{save-D2O96E5A.js → save-8A_q6K4E.js} +1 -1
  32. package/dist/chunks/{save-zNVYH02T.js → save-DzciESDh.js} +1 -1
  33. package/dist/chunks/{source-identity-Dj3dryN9.js → source-identity-CN4xiyKJ.js} +5 -5
  34. package/dist/chunks/{switch-DMPsMpHW.js → switch-DArtNJZh.js} +292 -291
  35. package/dist/chunks/{switch-Jhyl63RF.js → switch-k7kj6NRg.js} +1 -1
  36. package/dist/chunks/{use-create-flow-overlay-state-r5JKyXU8.js → use-create-flow-overlay-state-BdG1DiSx.js} +4 -4
  37. package/dist/chunks/{use-create-flow-overlay-state-NsqFPwdB.js → use-create-flow-overlay-state-ipeaE65_.js} +1 -1
  38. package/dist/chunks/{validators-CtNmgsvG.js → validators-CHPH6ORs.js} +641 -498
  39. package/dist/chunks/validators-lWo8m0Q7.js +1 -0
  40. package/dist/dashboard/index.cjs +1 -1
  41. package/dist/dashboard/index.js +1 -1
  42. package/dist/dashboard-authoring/index.cjs +3 -3
  43. package/dist/dashboard-authoring/index.js +105 -92
  44. package/dist/data-app-builder/index.cjs +1 -1
  45. package/dist/data-app-builder/index.js +3 -3
  46. package/dist/data-app-sdk/index.cjs +1 -1
  47. package/dist/data-app-sdk/index.js +444 -380
  48. package/dist/data-app-sdk-adapters/index.cjs +1 -0
  49. package/dist/data-app-sdk-adapters/index.js +383 -0
  50. package/dist/data-app-sdk-validation/index.cjs +1 -1
  51. package/dist/data-app-sdk-validation/index.js +1073 -6
  52. package/dist/index.cjs +1 -1
  53. package/dist/index.js +7 -7
  54. package/dist/surfboard/index.cjs +1 -1
  55. package/dist/surfboard/index.js +2 -2
  56. package/dist/types/analytics-protocol.d.ts +58 -31
  57. package/dist/types/dashboard-assistant.d.ts +40 -15
  58. package/dist/types/dashboard-authoring.d.ts +36 -16
  59. package/dist/types/dashboard.d.ts +8 -8
  60. package/dist/types/data-app-builder.d.ts +35 -11
  61. package/dist/types/data-app-sdk-adapters.d.ts +733 -0
  62. package/dist/types/data-app-sdk-validation.d.ts +85 -25
  63. package/dist/types/data-app-sdk.d.ts +99 -155
  64. package/dist/types/main.d.ts +35 -11
  65. package/dist/types/shared.d.ts +8 -8
  66. package/dist/types/surfboard.d.ts +8 -8
  67. package/dist/types/types.d.ts +8 -8
  68. package/package.json +9 -2
  69. package/src/data-app-sdk/README.md +240 -0
  70. package/dist/chunks/catalog-field-grounding-8L9I0zdg.js +0 -1
  71. package/dist/chunks/catalog-field-grounding-BK4BX8sZ.js +0 -200
  72. package/dist/chunks/validation-BM3-ShHV.js +0 -1003
  73. package/dist/chunks/validation-BVpqRFar.js +0 -1
  74. package/dist/chunks/validators-jpoYhpHh.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var khe=Object.defineProperty;var t$=e=>{throw TypeError(e)};var _he=(e,t,n)=>t in e?khe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ye=(e,t,n)=>_he(e,typeof t!="symbol"?t+"":t,n),Kj=(e,t,n)=>t.has(e)||t$("Cannot "+n);var fe=(e,t,n)=>(Kj(e,t,"read from private field"),n?n.call(e):t.get(e)),jt=(e,t,n)=>t.has(e)?t$("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Kj(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Bt=(e,t,n)=>(Kj(e,t,"access private method"),n);var Jv=(e,t,n,r)=>({set _(s){ut(e,t,s,n)},get _(){return fe(e,t,r)}});const l=require("react/jsx-runtime"),S=require("react"),gr=require("react-dom"),p=require("./switch-Jhyl63RF.js"),jhe=require("./index-BxM99sFL.js"),Ihe=require("./catalog-field-grounding-8L9I0zdg.js"),kc=require("./index-DRlMUglg.js"),Ehe=require("react-dom/client"),The=require("../types/index.cjs"),On=require("./date-formatter-B4EBSe9C.js"),dn=require("./index-D7KJindZ.js"),So=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),ar=require("./common-types-C73-Ud1-.js"),Dhe=require("./source-identity-C-xaeE_I.js"),pq=require("../dashboard-assistant/index.cjs"),Mhe=require("./contracts-CtB2VONT.js"),Ahe=require("../layouts/index.cjs");function PR(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 n$=PR(l),Q=PR(S),zD=PR(gr),FR=`import pandas as pd
1
+ "use strict";var khe=Object.defineProperty;var t$=e=>{throw TypeError(e)};var _he=(e,t,n)=>t in e?khe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ye=(e,t,n)=>_he(e,typeof t!="symbol"?t+"":t,n),Kj=(e,t,n)=>t.has(e)||t$("Cannot "+n);var fe=(e,t,n)=>(Kj(e,t,"read from private field"),n?n.call(e):t.get(e)),jt=(e,t,n)=>t.has(e)?t$("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Kj(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Bt=(e,t,n)=>(Kj(e,t,"access private method"),n);var Jv=(e,t,n,r)=>({set _(s){ut(e,t,s,n)},get _(){return fe(e,t,r)}});const l=require("react/jsx-runtime"),S=require("react"),gr=require("react-dom"),p=require("./switch-k7kj6NRg.js"),jhe=require("./index-BxM99sFL.js");require("./analyze-result-contract-CtXfp3nv.js");const kc=require("./index-DRlMUglg.js"),Ihe=require("react-dom/client"),Ehe=require("../types/index.cjs"),On=require("./date-formatter-B4EBSe9C.js"),dn=require("./index-D7KJindZ.js"),So=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),ar=require("./common-types-C73-Ud1-.js"),The=require("./catalog-field-grounding-Bnx-3tE0.js"),Dhe=require("./source-identity-C-xaeE_I.js"),pq=require("../dashboard-assistant/index.cjs"),Mhe=require("./contracts-CtB2VONT.js"),Ahe=require("../layouts/index.cjs");function PR(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 n$=PR(l),Q=PR(S),zD=PR(gr),FR=`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 Rhe(e,t){const n=+dn.toDate(e);return dn.constructFrom(e,n+t)}function LS(e,t){return Rhe(e,t*dn.millisecondsInHour)}function Phe(e){return dn.toDate(e).getMonth()}function Fhe(e){return dn.toDate(e).getFullYear()}function $S(e,t){const r=zhe(e);let s;if(r.date){const c=Bhe(r.date,2);s=Vhe(c.restDateString,c.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const o=s.getTime();let i=0,a;if(r.time&&(i=Hhe(r.time),isNaN(i)))return new Date(NaN);if(r.timezone){if(a=Uhe(r.timezone),isNaN(a))return new Date(NaN)}else{const c=new Date(o+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(o+i+a)}const ew={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Ohe=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Lhe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,$he=/^([+-])(\d{2})(?::?(\d{2}))?$/;function zhe(e){const t={},n=e.split(ew.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],ew.timeZoneDelimiter.test(t.date)&&(t.date=e.split(ew.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const s=ew.timezone.exec(r);s?(t.time=r.replace(s[1],""),t.timezone=s[1]):t.time=r}return t}function Bhe(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 s=r[1]?parseInt(r[1]):null,o=r[2]?parseInt(r[2]):null;return{year:o===null?s:o*100,restDateString:e.slice((r[1]||r[2]).length)}}function Vhe(e,t){if(t===null)return new Date(NaN);const n=e.match(Ohe);if(!n)return new Date(NaN);const r=!!n[4],s=Jg(n[1]),o=Jg(n[2])-1,i=Jg(n[3]),a=Jg(n[4]),c=Jg(n[5])-1;if(r)return Khe(t,a,c)?qhe(t,a,c):new Date(NaN);{const u=new Date(0);return!Ghe(t,o,i)||!Yhe(t,s)?new Date(NaN):(u.setUTCFullYear(t,o,Math.max(s,i)),u)}}function Jg(e){return e?parseInt(e):1}function Hhe(e){const t=e.match(Lhe);if(!t)return NaN;const n=Zj(t[1]),r=Zj(t[2]),s=Zj(t[3]);return Zhe(n,r,s)?n*dn.millisecondsInHour+r*dn.millisecondsInMinute+s*1e3:NaN}function Zj(e){return e&&parseFloat(e.replace(",","."))||0}function Uhe(e){if(e==="Z")return 0;const t=e.match($he);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return Xhe(r,s)?n*(r*dn.millisecondsInHour+s*dn.millisecondsInMinute):NaN}function qhe(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const s=r.getUTCDay()||7,o=(t-1)*7+n+1-s;return r.setUTCDate(r.getUTCDate()+o),r}const Whe=[31,null,31,30,31,30,31,31,30,31,30,31];function gq(e){return e%400===0||e%4===0&&e%100!==0}function Ghe(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Whe[t]||(gq(e)?29:28))}function Yhe(e,t){return t>=1&&t<=(gq(e)?366:365)}function Khe(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Zhe(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Xhe(e,t){return t>=0&&t<=59}var zS={exports:{}};zS.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",s=800,o=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]",k="[object String]",_="[object Undefined]",j="[object WeakMap]",E="[object ArrayBuffer]",I="[object DataView]",T="[object Float32Array]",D="[object Float64Array]",R="[object Int8Array]",F="[object Int16Array]",A="[object Int32Array]",U="[object Uint8Array]",$="[object Uint8ClampedArray]",q="[object Uint16Array]",W="[object Uint32Array]",O=/[\\^$.*+?()[\]{}|]/g,Z=/^\[object .+?Constructor\]$/,Y=/^(?:0|[1-9]\d*)$/,M={};M[T]=M[D]=M[R]=M[F]=M[A]=M[U]=M[$]=M[q]=M[W]=!0,M[a]=M[c]=M[E]=M[d]=M[I]=M[f]=M[h]=M[m]=M[b]=M[x]=M[w]=M[C]=M[N]=M[k]=M[j]=!1;var K=typeof p.commonjsGlobal=="object"&&p.commonjsGlobal&&p.commonjsGlobal.Object===Object&&p.commonjsGlobal,L=typeof self=="object"&&self&&self.Object===Object&&self,z=K||L||Function("return this")(),B=t&&!t.nodeType&&t,V=B&&!0&&e&&!e.nodeType&&e,P=V&&V.exports===B,H=P&&K.process,G=function(){try{var ae=V&&V.require&&V.require("util").types;return ae||H&&H.binding&&H.binding("util")}catch{}}(),X=G&&G.isTypedArray;function ne(ae,_e,Re){switch(Re.length){case 0:return ae.call(_e);case 1:return ae.call(_e,Re[0]);case 2:return ae.call(_e,Re[0],Re[1]);case 3:return ae.call(_e,Re[0],Re[1],Re[2])}return ae.apply(_e,Re)}function de(ae,_e){for(var Re=-1,It=Array(ae);++Re<ae;)It[Re]=_e(Re);return It}function he(ae){return function(_e){return ae(_e)}}function pe(ae,_e){return ae==null?void 0:ae[_e]}function xe(ae,_e){return function(Re){return ae(_e(Re))}}var se=Array.prototype,ge=Function.prototype,ie=Object.prototype,Te=z["__core-js_shared__"],re=ge.toString,me=ie.hasOwnProperty,ve=function(){var ae=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||"");return ae?"Symbol(src)_1."+ae:""}(),J=ie.toString,ee=re.call(Object),te=RegExp("^"+re.call(me).replace(O,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ue=P?z.Buffer:void 0,le=z.Symbol,ke=z.Uint8Array;ue&&ue.allocUnsafe;var Se=xe(Object.getPrototypeOf,Object),oe=Object.create,je=ie.propertyIsEnumerable,Ne=se.splice,Oe=le?le.toStringTag:void 0,Ge=function(){try{var ae=Fr(Object,"defineProperty");return ae({},"",{}),ae}catch{}}(),Le=ue?ue.isBuffer:void 0,Be=Math.max,Ke=Date.now,Ce=Fr(z,"Map"),Je=Fr(Object,"create"),Pe=function(){function ae(){}return function(_e){if(!Cd(_e))return{};if(oe)return oe(_e);ae.prototype=_e;var Re=new ae;return ae.prototype=void 0,Re}}();function He(ae){var _e=-1,Re=ae==null?0:ae.length;for(this.clear();++_e<Re;){var It=ae[_e];this.set(It[0],It[1])}}function tt(){this.__data__=Je?Je(null):{},this.size=0}function Ae(ae){var _e=this.has(ae)&&delete this.__data__[ae];return this.size-=_e?1:0,_e}function Ie(ae){var _e=this.__data__;if(Je){var Re=_e[ae];return Re===r?void 0:Re}return me.call(_e,ae)?_e[ae]:void 0}function We(ae){var _e=this.__data__;return Je?_e[ae]!==void 0:me.call(_e,ae)}function xt(ae,_e){var Re=this.__data__;return this.size+=this.has(ae)?0:1,Re[ae]=Je&&_e===void 0?r:_e,this}He.prototype.clear=tt,He.prototype.delete=Ae,He.prototype.get=Ie,He.prototype.has=We,He.prototype.set=xt;function bt(ae){var _e=-1,Re=ae==null?0:ae.length;for(this.clear();++_e<Re;){var It=ae[_e];this.set(It[0],It[1])}}function dt(){this.__data__=[],this.size=0}function vt(ae){var _e=this.__data__,Re=ft(_e,ae);if(Re<0)return!1;var It=_e.length-1;return Re==It?_e.pop():Ne.call(_e,Re,1),--this.size,!0}function st(ae){var _e=this.__data__,Re=ft(_e,ae);return Re<0?void 0:_e[Re][1]}function Dt(ae){return ft(this.__data__,ae)>-1}function Ee(ae,_e){var Re=this.__data__,It=ft(Re,ae);return It<0?(++this.size,Re.push([ae,_e])):Re[It][1]=_e,this}bt.prototype.clear=dt,bt.prototype.delete=vt,bt.prototype.get=st,bt.prototype.has=Dt,bt.prototype.set=Ee;function Ze(ae){var _e=-1,Re=ae==null?0:ae.length;for(this.clear();++_e<Re;){var It=ae[_e];this.set(It[0],It[1])}}function Qe(){this.size=0,this.__data__={hash:new He,map:new(Ce||bt),string:new He}}function nt(ae){var _e=Kt(this,ae).delete(ae);return this.size-=_e?1:0,_e}function yt(ae){return Kt(this,ae).get(ae)}function Ft(ae){return Kt(this,ae).has(ae)}function At(ae,_e){var Re=Kt(this,ae),It=Re.size;return Re.set(ae,_e),this.size+=Re.size==It?0:1,this}Ze.prototype.clear=Qe,Ze.prototype.delete=nt,Ze.prototype.get=yt,Ze.prototype.has=Ft,Ze.prototype.set=At;function fn(ae){var _e=this.__data__=new bt(ae);this.size=_e.size}function $e(){this.__data__=new bt,this.size=0}function Ue(ae){var _e=this.__data__,Re=_e.delete(ae);return this.size=_e.size,Re}function lt(ae){return this.__data__.get(ae)}function Ct(ae){return this.__data__.has(ae)}function Nt(ae,_e){var Re=this.__data__;if(Re instanceof bt){var It=Re.__data__;if(!Ce||It.length<n-1)return It.push([ae,_e]),this.size=++Re.size,this;Re=this.__data__=new Ze(It)}return Re.set(ae,_e),this.size=Re.size,this}fn.prototype.clear=$e,fn.prototype.delete=Ue,fn.prototype.get=lt,fn.prototype.has=Ct,fn.prototype.set=Nt;function it(ae,_e){var Re=Dr(ae),It=!Re&&Fn(ae),_n=!Re&&!It&&Sd(ae),or=!Re&&!It&&!_n&&X3(ae),jr=Re||It||_n||or,$n=jr?de(ae.length,String):[],Ir=$n.length;for(var ea in ae)jr&&(ea=="length"||_n&&(ea=="offset"||ea=="parent")||or&&(ea=="buffer"||ea=="byteLength"||ea=="byteOffset")||El(ea,Ir))||$n.push(ea);return $n}function ce(ae,_e,Re){(Re!==void 0&&!sr(ae[_e],Re)||Re===void 0&&!(_e in ae))&&Tt(ae,_e,Re)}function ze(ae,_e,Re){var It=ae[_e];(!(me.call(ae,_e)&&sr(It,Re))||Re===void 0&&!(_e in ae))&&Tt(ae,_e,Re)}function ft(ae,_e){for(var Re=ae.length;Re--;)if(sr(ae[Re][0],_e))return Re;return-1}function Tt(ae,_e,Re){_e=="__proto__"&&Ge?Ge(ae,_e,{configurable:!0,enumerable:!0,value:Re,writable:!0}):ae[_e]=Re}var Ot=kt();function be(ae){return ae==null?ae===void 0?_:y:Oe&&Oe in Object(ae)?Si(ae):Qv(ae)}function we(ae){return Xg(ae)&&be(ae)==a}function Ve(ae){if(!Cd(ae)||Zv(ae))return!1;var _e=Kg(ae)?te:Z;return _e.test(Yt(ae))}function mt(ae){return Xg(ae)&&Zg(ae.length)&&!!M[be(ae)]}function Lt(ae){if(!Cd(ae))return Xv(ae);var _e=Yg(ae),Re=[];for(var It in ae)It=="constructor"&&(_e||!me.call(ae,It))||Re.push(It);return Re}function _t(ae,_e,Re,It,_n){ae!==_e&&Ot(_e,function(or,jr){if(_n||(_n=new fn),Cd(or))Rn(ae,_e,jr,Re,_t,It,_n);else{var $n=It?It(qt(ae,jr),or,jr+"",ae,_e,_n):void 0;$n===void 0&&($n=or),ce(ae,jr,$n)}},Q3)}function Rn(ae,_e,Re,It,_n,or,jr){var $n=qt(ae,Re),Ir=qt(_e,Re),ea=jr.get(Ir);if(ea){ce(ae,Re,ea);return}var Zo=or?or($n,Ir,Re+"",ae,_e,jr):void 0,Qg=Zo===void 0;if(Qg){var Gj=Dr(Ir),Yj=!Gj&&Sd(Ir),e$=!Gj&&!Yj&&X3(Ir);Zo=Ir,Gj||Yj||e$?Dr($n)?Zo=$n:_s($n)?Zo=Fe($n):Yj?(Qg=!1,Zo=wi(Ir)):e$?(Qg=!1,Zo=Il(Ir)):Zo=[]:vhe(Ir)||Fn(Ir)?(Zo=$n,Fn($n)?Zo=whe($n):(!Cd($n)||Kg($n))&&(Zo=qh(Ir))):Qg=!1}Qg&&(jr.set(Ir,Zo),_n(Zo,Ir,It,or,jr),jr.delete(Ir)),ce(ae,Re,Zo)}function Pn(ae,_e){return hn(De(ae,_e,J3),ae+"")}var _r=Ge?function(ae,_e){return Ge(ae,"toString",{configurable:!0,enumerable:!1,value:Che(_e),writable:!0})}:J3;function wi(ae,_e){return ae.slice()}function Eo(ae){var _e=new ae.constructor(ae.byteLength);return new ke(_e).set(new ke(ae)),_e}function Il(ae,_e){var Re=Eo(ae.buffer);return new ae.constructor(Re,ae.byteOffset,ae.length)}function Fe(ae,_e){var Re=-1,It=ae.length;for(_e||(_e=Array(It));++Re<It;)_e[Re]=ae[Re];return _e}function ot(ae,_e,Re,It){var _n=!Re;Re||(Re={});for(var or=-1,jr=_e.length;++or<jr;){var $n=_e[or],Ir=void 0;Ir===void 0&&(Ir=ae[$n]),_n?Tt(Re,$n,Ir):ze(Re,$n,Ir)}return Re}function wt(ae){return Pn(function(_e,Re){var It=-1,_n=Re.length,or=_n>1?Re[_n-1]:void 0,jr=_n>2?Re[2]:void 0;for(or=ae.length>3&&typeof or=="function"?(_n--,or):void 0,jr&&Wh(Re[0],Re[1],jr)&&(or=_n<3?void 0:or,_n=1),_e=Object(_e);++It<_n;){var $n=Re[It];$n&&ae(_e,$n,It,or)}return _e})}function kt(ae){return function(_e,Re,It){for(var _n=-1,or=Object(_e),jr=It(_e),$n=jr.length;$n--;){var Ir=jr[++_n];if(Re(or[Ir],Ir,or)===!1)break}return _e}}function Kt(ae,_e){var Re=ae.__data__;return Bc(_e)?Re[typeof _e=="string"?"string":"hash"]:Re.map}function Fr(ae,_e){var Re=pe(ae,_e);return Ve(Re)?Re:void 0}function Si(ae){var _e=me.call(ae,Oe),Re=ae[Oe];try{ae[Oe]=void 0;var It=!0}catch{}var _n=J.call(ae);return It&&(_e?ae[Oe]=Re:delete ae[Oe]),_n}function qh(ae){return typeof ae.constructor=="function"&&!Yg(ae)?Pe(Se(ae)):{}}function El(ae,_e){var Re=typeof ae;return _e=_e??i,!!_e&&(Re=="number"||Re!="symbol"&&Y.test(ae))&&ae>-1&&ae%1==0&&ae<_e}function Wh(ae,_e,Re){if(!Cd(Re))return!1;var It=typeof _e;return(It=="number"?hr(Re)&&El(_e,Re.length):It=="string"&&_e in Re)?sr(Re[_e],ae):!1}function Bc(ae){var _e=typeof ae;return _e=="string"||_e=="number"||_e=="symbol"||_e=="boolean"?ae!=="__proto__":ae===null}function Zv(ae){return!!ve&&ve in ae}function Yg(ae){var _e=ae&&ae.constructor,Re=typeof _e=="function"&&_e.prototype||ie;return ae===Re}function Xv(ae){var _e=[];if(ae!=null)for(var Re in Object(ae))_e.push(Re);return _e}function Qv(ae){return J.call(ae)}function De(ae,_e,Re){return _e=Be(_e===void 0?ae.length-1:_e,0),function(){for(var It=arguments,_n=-1,or=Be(It.length-_e,0),jr=Array(or);++_n<or;)jr[_n]=It[_e+_n];_n=-1;for(var $n=Array(_e+1);++_n<_e;)$n[_n]=It[_n];return $n[_e]=Re(jr),ne(ae,this,$n)}}function qt(ae,_e){if(!(_e==="constructor"&&typeof ae[_e]=="function")&&_e!="__proto__")return ae[_e]}var hn=Qt(_r);function Qt(ae){var _e=0,Re=0;return function(){var It=Ke(),_n=o-(It-Re);if(Re=It,_n>0){if(++_e>=s)return arguments[0]}else _e=0;return ae.apply(void 0,arguments)}}function Yt(ae){if(ae!=null){try{return re.call(ae)}catch{}try{return ae+""}catch{}}return""}function sr(ae,_e){return ae===_e||ae!==ae&&_e!==_e}var Fn=we(function(){return arguments}())?we:function(ae){return Xg(ae)&&me.call(ae,"callee")&&!je.call(ae,"callee")},Dr=Array.isArray;function hr(ae){return ae!=null&&Zg(ae.length)&&!Kg(ae)}function _s(ae){return Xg(ae)&&hr(ae)}var Sd=Le||Nhe;function Kg(ae){if(!Cd(ae))return!1;var _e=be(ae);return _e==m||_e==g||_e==u||_e==v}function Zg(ae){return typeof ae=="number"&&ae>-1&&ae%1==0&&ae<=i}function Cd(ae){var _e=typeof ae;return ae!=null&&(_e=="object"||_e=="function")}function Xg(ae){return ae!=null&&typeof ae=="object"}function vhe(ae){if(!Xg(ae)||be(ae)!=w)return!1;var _e=Se(ae);if(_e===null)return!0;var Re=me.call(_e,"constructor")&&_e.constructor;return typeof Re=="function"&&Re instanceof Re&&re.call(Re)==ee}var X3=X?he(X):mt;function whe(ae){return ot(ae,Q3(ae))}function Q3(ae){return hr(ae)?it(ae):Lt(ae)}var She=wt(function(ae,_e,Re){_t(ae,_e,Re)});function Che(ae){return function(){return ae}}function J3(ae){return ae}function Nhe(){return!1}e.exports=She})(zS,zS.exports);var Qhe=zS.exports;const dl=p.getDefaultExportFromCjs(Qhe),Jhe={theme:"system",setTheme:()=>null},bq=S.createContext(Jhe);function BS(e,t="system"){return eme(e)?e:t}function eme(e){return e==="light"||e==="dark"||e==="system"}const OR=()=>{const e=S.useContext(bq);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},xq=(e,t)=>{const n={};if(e===null||t===null)return t;const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const s of r){if(!(s in e)&&s in t){n[s]=t[s];continue}if(s in e&&!(s in t)){n[s]=void 0;continue}const o=e[s],i=t[s];if(!BD(o,i))if(Array.isArray(o)&&Array.isArray(i))n[s]=i;else if(r$(o)&&r$(i)){const a=xq(o,i);Object.keys(a).length>0&&(n[s]=a)}else n[s]=i}return n},BD=(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((s,o)=>BD(s,t[o]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>BD(e[s],t[s]))}return!1},r$=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$o=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=>$o(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=$o(e[n]));return t},yq="__semaphorAuthoredFontFamily";var tq,nq;const tme=(nq=(tq=p.DEFAULT_STYLE.default.chart)==null?void 0:tq.font)==null?void 0:nq.family,nme=new Set([tme,"Open Sans, Arial, sans-serif",'"Open Sans", Arial, sans-serif'].filter(Boolean));function rme(e,t){if(!e)return t?{family:t}:void 0;const{[yq]:n,...r}=e,s=sme(r.family,t,!!n);return{...r,...s?{family:s}:void 0}}function sme(e,t,n=!1){return n&&e||e&&!ome(e)?e:t||e}function ome(e){return nme.has(e.trim())}function ime(e,t){if(!t)return e;const n={...e,font:Ii(e.font,t)},r=cme(e.plugins,t);r&&(n.plugins=r);const s=ume(e.scales,t);return s&&(n.scales=s),n}function ame(e,t){return!e||!t?e:e.map(n=>{if(!n||typeof n!="object")return n;const r=n,s=r.datalabels;return!s||typeof s!="object"?n:{...r,datalabels:{...s,font:Ii(s.font,t)}}})}function lme(e,t){if(!e||typeof e!="object"||!t)return e;const n=e.datasets;return Array.isArray(n)?{...e,datasets:ame(n,t)}:e}function cme(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 ume(e,t){return e&&Object.entries(e).reduce((n,[r,s])=>{if(!s||typeof s!="object")return n[r]=s,n;const o=s;return n[r]={...o,ticks:o.ticks?{...o.ticks,font:Ii(o.ticks.font,t)}:o.ticks,title:o.title?{...o.title,font:Ii(o.title.font,t)}:o.title,pointLabels:o.pointLabels?{...o.pointLabels,font:Ii(o.pointLabels.font,t)}:o.pointLabels},n},{})}function Ii(e,t){return typeof e=="function"?e:{...t,...e&&typeof e=="object"?e:{}}}function dme(e,t){const n=$o(e??{}),r=fme(t);if(!r)return n;const s=dl(n,r);return pme(s,r),s}function fme(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,s=(g=n.tokens)==null?void 0:g.typography,o={};mme(t==null?void 0:t.palette,r==null?void 0:r.palette)&&(o.dataset={backgroundColor:[...t.palette],borderColor:[...t.palette]});const i=(b=e.scheme.tokens)==null?void 0:b.typography,a=Gh(i==null?void 0:i.fontFamily,s==null?void 0:s.fontFamily),c=Gh(i==null?void 0:i.baseFontSize,s==null?void 0:s.baseFontSize);if(a||c!==void 0){const x={...a?{family:a}:void 0,...c!==void 0?{size:c}:void 0};a&&(x[yq]=!0),o.font=x}const u=Gh(t==null?void 0:t.gridColor,r==null?void 0:r.gridColor),d=Gh(t==null?void 0:t.axisColor,r==null?void 0:r.axisColor)??Gh(t==null?void 0:t.foreground,r==null?void 0:r.foreground);(u||d)&&(o.options={scales:{x:Xj({gridColor:u,axisColor:d}),y:Xj({gridColor:u,axisColor:d}),y2:Xj({gridColor:u,axisColor:d}),r:hme({gridColor:u,axisColor:d})}});const f=Gh(t==null?void 0:t.foreground,r==null?void 0:r.foreground);return f&&(o.options=dl(o.options??{},{plugins:{legend:{labels:{color:f}}}})),Object.keys(o).length>0?{chart:o}:void 0}function Xj({gridColor:e,axisColor:t}){return{...e?{grid:{color:e}}:void 0,...t?{ticks:{color:t},title:{color:t}}:void 0}}function hme({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 mme(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 Gh(e,t){return e!==void 0&&e!==t?e:void 0}function pme(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 yh=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(){}},gme={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Wa,mf,rq,bme=(rq=class{constructor(){jt(this,Wa,gme);jt(this,mf,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&fe(this,mf)&&e!==fe(this,Wa)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:fe(this,Wa),provider:e}),ut(this,Wa,e),process.env.NODE_ENV!=="production"&&ut(this,mf,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ut(this,mf,!0),fe(this,Wa).setTimeout(e,t)}clearTimeout(e){fe(this,Wa).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ut(this,mf,!0),fe(this,Wa).setInterval(e,t)}clearInterval(e){fe(this,Wa).clearInterval(e)}},Wa=new WeakMap,mf=new WeakMap,rq),nf=new bme;function xme(e){setTimeout(e,0)}var Hf=typeof window>"u"||"Deno"in globalThis;function Ks(){}function yme(e,t){return typeof e=="function"?e(t):e}function VD(e){return typeof e=="number"&&e>=0&&e!==1/0}function vq(e,t){return Math.max(e+(t||0)-Date.now(),0)}function yu(e,t){return typeof e=="function"?e(t):e}function Ei(e,t){return typeof e=="function"?e(t):e}function s$(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:o,queryKey:i,stale:a}=e;if(i){if(r){if(t.queryHash!==LR(i,t.options))return!1}else if(!ty(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||s&&s!==t.state.fetchStatus||o&&!o(t))}function o$(e,t){const{exact:n,status:r,predicate:s,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(Uf(t.options.mutationKey)!==Uf(o))return!1}else if(!ty(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function LR(e,t){return((t==null?void 0:t.queryKeyHashFn)||Uf)(e)}function Uf(e){return JSON.stringify(e,(t,n)=>HD(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function ty(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ty(e[n],t[n])):!1}var vme=Object.prototype.hasOwnProperty;function VS(e,t){if(e===t)return e;const n=i$(e)&&i$(t);if(!n&&!(HD(e)&&HD(t)))return t;const s=(n?e:Object.keys(e)).length,o=n?t:Object.keys(t),i=o.length,a=n?new Array(i):{};let c=0;for(let u=0;u<i;u++){const d=n?u:o[u],f=e[d],h=t[d];if(f===h){a[d]=f,(n?u<s:vme.call(e,d))&&c++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){a[d]=h;continue}const m=VS(f,h);a[d]=m,m===f&&c++}return s===i&&c===s?e:a}function ny(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 i$(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function HD(e){if(!a$(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!a$(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function a$(e){return Object.prototype.toString.call(e)==="[object Object]"}function wme(e){return new Promise(t=>{nf.setTimeout(t,e)})}function UD(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 VS(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 VS(e,t)}return t}function Sme(e){return e}function Cme(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Nme(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var HS=Symbol();function wq(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===HS&&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===HS?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Sq(e,t){return typeof e=="function"?e(...t):!!e}var pf,Qc,Qm,sq,kme=(sq=class extends yh{constructor(){super();jt(this,pf);jt(this,Qc);jt(this,Qm);ut(this,Qm,t=>{if(!Hf&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){fe(this,Qc)||this.setEventListener(fe(this,Qm))}onUnsubscribe(){var t;this.hasListeners()||((t=fe(this,Qc))==null||t.call(this),ut(this,Qc,void 0))}setEventListener(t){var n;ut(this,Qm,t),(n=fe(this,Qc))==null||n.call(this),ut(this,Qc,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){fe(this,pf)!==t&&(ut(this,pf,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof fe(this,pf)=="boolean"?fe(this,pf):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},pf=new WeakMap,Qc=new WeakMap,Qm=new WeakMap,sq),$R=new kme;function qD(){let e,t;const n=new Promise((s,o)=>{e=s,t=o});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var _me=xme;function jme(){let e=[],t=0,n=a=>{a()},r=a=>{a()},s=_me;const o=a=>{t?e.push(a):s(()=>{n(a)})},i=()=>{const a=e;e=[],a.length&&s(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||i()}return c},batchCalls:a=>(...c)=>{o(()=>{a(...c)})},schedule:o,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{s=a}}}var Rr=jme(),Jm,Jc,ep,oq,Ime=(oq=class extends yh{constructor(){super();jt(this,Jm,!0);jt(this,Jc);jt(this,ep);ut(this,ep,t=>{if(!Hf&&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(){fe(this,Jc)||this.setEventListener(fe(this,ep))}onUnsubscribe(){var t;this.hasListeners()||((t=fe(this,Jc))==null||t.call(this),ut(this,Jc,void 0))}setEventListener(t){var n;ut(this,ep,t),(n=fe(this,Jc))==null||n.call(this),ut(this,Jc,t(this.setOnline.bind(this)))}setOnline(t){fe(this,Jm)!==t&&(ut(this,Jm,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return fe(this,Jm)}},Jm=new WeakMap,Jc=new WeakMap,ep=new WeakMap,oq),US=new Ime;function Eme(e){return Math.min(1e3*2**e,3e4)}function Cq(e){return(e??"online")==="online"?US.isOnline():!0}var WD=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Nq(e){let t=!1,n=0,r;const s=qD(),o=()=>s.status!=="pending",i=b=>{var x;if(!o()){const y=new WD(b);h(y),(x=e.onCancel)==null||x.call(e,y)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>$R.isFocused()&&(e.networkMode==="always"||US.isOnline())&&e.canRun(),d=()=>Cq(e.networkMode)&&e.canRun(),f=b=>{o()||(r==null||r(),s.resolve(b))},h=b=>{o()||(r==null||r(),s.reject(b))},m=()=>new Promise(b=>{var x;r=y=>{(o()||u())&&b(y)},(x=e.onPause)==null||x.call(e)}).then(()=>{var b;r=void 0,o()||(b=e.onContinue)==null||b.call(e)}),g=()=>{if(o())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 k;if(o())return;const w=e.retry??(Hf?0:3),v=e.retryDelay??Eme,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++,(k=e.onFail)==null||k.call(e,n,y),wme(C).then(()=>u()?void 0:m()).then(()=>{t?h(y):g()})})};return{promise:s,status:()=>s.status,cancel:i,continue:()=>(r==null||r(),s),cancelRetry:a,continueRetry:c,canStart:d,start:()=>(d()?g():m().then(g),s)}}var gf,iq,kq=(iq=class{constructor(){jt(this,gf)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),VD(this.gcTime)&&ut(this,gf,nf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Hf?1/0:5*60*1e3))}clearGcTimeout(){fe(this,gf)&&(nf.clearTimeout(fe(this,gf)),ut(this,gf,void 0))}},gf=new WeakMap,iq),bf,tp,_i,xf,fs,b0,yf,oa,Rl,aq,Tme=(aq=class extends kq{constructor(t){super();jt(this,oa);jt(this,bf);jt(this,tp);jt(this,_i);jt(this,xf);jt(this,fs);jt(this,b0);jt(this,yf);ut(this,yf,!1),ut(this,b0,t.defaultOptions),this.setOptions(t.options),this.observers=[],ut(this,xf,t.client),ut(this,_i,fe(this,xf).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ut(this,bf,c$(this.options)),this.state=t.state??fe(this,bf),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=fe(this,fs))==null?void 0:t.promise}setOptions(t){if(this.options={...fe(this,b0),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=c$(this.options);n.data!==void 0&&(this.setState(l$(n.data,n.dataUpdatedAt)),ut(this,bf,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&fe(this,_i).remove(this)}setData(t,n){const r=UD(this.state.data,t,this.options);return Bt(this,oa,Rl).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Bt(this,oa,Rl).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=fe(this,fs))==null?void 0:r.promise;return(s=fe(this,fs))==null||s.cancel(t),n?n.then(Ks).catch(Ks):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(fe(this,bf))}isActive(){return this.observers.some(t=>Ei(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===HS||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>yu(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:!vq(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=fe(this,fs))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=fe(this,fs))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),fe(this,_i).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(fe(this,fs)&&(fe(this,yf)?fe(this,fs).cancel({revert:!0}):fe(this,fs).cancelRetry()),this.scheduleGc()),fe(this,_i).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Bt(this,oa,Rl).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=fe(this,fs))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(fe(this,fs))return fe(this,fs).continueRetry(),fe(this,fs).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,s=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(ut(this,yf,!0),r.signal)})},o=()=>{const C=wq(this.options,n),k=(()=>{const _={client:fe(this,xf),queryKey:this.queryKey,meta:this.meta};return s(_),_})();return ut(this,yf,!1),this.options.persister?this.options.persister(C,k,this):C(k)},a=(()=>{const C={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:fe(this,xf),state:this.state,fetchFn:o};return s(C),C})();(u=this.options.behavior)==null||u.onFetch(a,this),ut(this,tp,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=a.fetchOptions)==null?void 0:d.meta))&&Bt(this,oa,Rl).call(this,{type:"fetch",meta:(f=a.fetchOptions)==null?void 0:f.meta}),ut(this,fs,Nq({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:C=>{C instanceof WD&&C.revert&&this.setState({...fe(this,tp),fetchStatus:"idle"}),r.abort()},onFail:(C,N)=>{Bt(this,oa,Rl).call(this,{type:"failed",failureCount:C,error:N})},onPause:()=>{Bt(this,oa,Rl).call(this,{type:"pause"})},onContinue:()=>{Bt(this,oa,Rl).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const C=await fe(this,fs).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=fe(this,_i).config).onSuccess)==null||m.call(h,C,this),(b=(g=fe(this,_i).config).onSettled)==null||b.call(g,C,this.state.error,this),C}catch(C){if(C instanceof WD){if(C.silent)return fe(this,fs).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Bt(this,oa,Rl).call(this,{type:"error",error:C}),(y=(x=fe(this,_i).config).onError)==null||y.call(x,C,this),(v=(w=fe(this,_i).config).onSettled)==null||v.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},bf=new WeakMap,tp=new WeakMap,_i=new WeakMap,xf=new WeakMap,fs=new WeakMap,b0=new WeakMap,yf=new WeakMap,oa=new WeakSet,Rl=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,..._q(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...l$(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ut(this,tp,t.manual?s:void 0),s;case"error":const o=t.error;return{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Rr.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),fe(this,_i).notify({query:this,type:"updated",action:t})})},aq);function _q(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Cq(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function l$(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function c$(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 Fo,Sn,x0,bo,vf,np,Ul,eu,y0,rp,sp,wf,Sf,tu,op,Kn,Vb,GD,YD,KD,ZD,XD,QD,JD,jq,lq,zR=(lq=class extends yh{constructor(t,n){super();jt(this,Kn);jt(this,Fo);jt(this,Sn);jt(this,x0);jt(this,bo);jt(this,vf);jt(this,np);jt(this,Ul);jt(this,eu);jt(this,y0);jt(this,rp);jt(this,sp);jt(this,wf);jt(this,Sf);jt(this,tu);jt(this,op,new Set);this.options=n,ut(this,Fo,t),ut(this,eu,null),ut(this,Ul,qD()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(fe(this,Sn).addObserver(this),u$(fe(this,Sn),this.options)?Bt(this,Kn,Vb).call(this):this.updateResult(),Bt(this,Kn,ZD).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return e2(fe(this,Sn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return e2(fe(this,Sn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Bt(this,Kn,XD).call(this),Bt(this,Kn,QD).call(this),fe(this,Sn).removeObserver(this)}setOptions(t){const n=this.options,r=fe(this,Sn);if(this.options=fe(this,Fo).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ei(this.options.enabled,fe(this,Sn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Bt(this,Kn,JD).call(this),fe(this,Sn).setOptions(this.options),n._defaulted&&!ny(this.options,n)&&fe(this,Fo).getQueryCache().notify({type:"observerOptionsUpdated",query:fe(this,Sn),observer:this});const s=this.hasListeners();s&&d$(fe(this,Sn),r,this.options,n)&&Bt(this,Kn,Vb).call(this),this.updateResult(),s&&(fe(this,Sn)!==r||Ei(this.options.enabled,fe(this,Sn))!==Ei(n.enabled,fe(this,Sn))||yu(this.options.staleTime,fe(this,Sn))!==yu(n.staleTime,fe(this,Sn)))&&Bt(this,Kn,GD).call(this);const o=Bt(this,Kn,YD).call(this);s&&(fe(this,Sn)!==r||Ei(this.options.enabled,fe(this,Sn))!==Ei(n.enabled,fe(this,Sn))||o!==fe(this,tu))&&Bt(this,Kn,KD).call(this,o)}getOptimisticResult(t){const n=fe(this,Fo).getQueryCache().build(fe(this,Fo),t),r=this.createResult(n,t);return Mme(this,r)&&(ut(this,bo,r),ut(this,np,this.options),ut(this,vf,fe(this,Sn).state)),r}getCurrentResult(){return fe(this,bo)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&fe(this,Ul).status==="pending"&&fe(this,Ul).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){fe(this,op).add(t)}getCurrentQuery(){return fe(this,Sn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=fe(this,Fo).defaultQueryOptions(t),r=fe(this,Fo).getQueryCache().build(fe(this,Fo),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Bt(this,Kn,Vb).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),fe(this,bo)))}createResult(t,n){var E;const r=fe(this,Sn),s=this.options,o=fe(this,bo),i=fe(this,vf),a=fe(this,np),u=t!==r?t.state:fe(this,x0),{state:d}=t;let f={...d},h=!1,m;if(n._optimisticResults){const I=this.hasListeners(),T=!I&&u$(t,n),D=I&&d$(t,r,n,s);(T||D)&&(f={...f,..._q(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:x}=f;m=f.data;let y=!1;if(n.placeholderData!==void 0&&m===void 0&&x==="pending"){let I;o!=null&&o.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(I=o.data,y=!0):I=typeof n.placeholderData=="function"?n.placeholderData((E=fe(this,sp))==null?void 0:E.state.data,fe(this,sp)):n.placeholderData,I!==void 0&&(x="success",m=UD(o==null?void 0:o.data,I,n),h=!0)}if(n.select&&m!==void 0&&!y)if(o&&m===(i==null?void 0:i.data)&&n.select===fe(this,y0))m=fe(this,rp);else try{ut(this,y0,n.select),m=n.select(m),m=UD(o==null?void 0:o.data,m,n),ut(this,rp,m),ut(this,eu,null)}catch(I){ut(this,eu,I)}fe(this,eu)&&(g=fe(this,eu),m=fe(this,rp),b=Date.now(),x="error");const w=f.fetchStatus==="fetching",v=x==="pending",C=x==="error",N=v&&w,k=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&&!k,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:C&&k,isStale:BR(t,n),refetch:this.refetch,promise:fe(this,Ul),isEnabled:Ei(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=R=>{j.status==="error"?R.reject(j.error):j.data!==void 0&&R.resolve(j.data)},T=()=>{const R=ut(this,Ul,j.promise=qD());I(R)},D=fe(this,Ul);switch(D.status){case"pending":t.queryHash===r.queryHash&&I(D);break;case"fulfilled":(j.status==="error"||j.data!==D.value)&&T();break;case"rejected":(j.status!=="error"||j.error!==D.reason)&&T();break}}return j}updateResult(){const t=fe(this,bo),n=this.createResult(fe(this,Sn),this.options);if(ut(this,vf,fe(this,Sn).state),ut(this,np,this.options),fe(this,vf).data!==void 0&&ut(this,sp,fe(this,Sn)),ny(n,t))return;ut(this,bo,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!fe(this,op).size)return!0;const i=new Set(o??fe(this,op));return this.options.throwOnError&&i.add("error"),Object.keys(fe(this,bo)).some(a=>{const c=a;return fe(this,bo)[c]!==t[c]&&i.has(c)})};Bt(this,Kn,jq).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Bt(this,Kn,ZD).call(this)}},Fo=new WeakMap,Sn=new WeakMap,x0=new WeakMap,bo=new WeakMap,vf=new WeakMap,np=new WeakMap,Ul=new WeakMap,eu=new WeakMap,y0=new WeakMap,rp=new WeakMap,sp=new WeakMap,wf=new WeakMap,Sf=new WeakMap,tu=new WeakMap,op=new WeakMap,Kn=new WeakSet,Vb=function(t){Bt(this,Kn,JD).call(this);let n=fe(this,Sn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ks)),n},GD=function(){Bt(this,Kn,XD).call(this);const t=yu(this.options.staleTime,fe(this,Sn));if(Hf||fe(this,bo).isStale||!VD(t))return;const r=vq(fe(this,bo).dataUpdatedAt,t)+1;ut(this,wf,nf.setTimeout(()=>{fe(this,bo).isStale||this.updateResult()},r))},YD=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(fe(this,Sn)):this.options.refetchInterval)??!1},KD=function(t){Bt(this,Kn,QD).call(this),ut(this,tu,t),!(Hf||Ei(this.options.enabled,fe(this,Sn))===!1||!VD(fe(this,tu))||fe(this,tu)===0)&&ut(this,Sf,nf.setInterval(()=>{(this.options.refetchIntervalInBackground||$R.isFocused())&&Bt(this,Kn,Vb).call(this)},fe(this,tu)))},ZD=function(){Bt(this,Kn,GD).call(this),Bt(this,Kn,KD).call(this,Bt(this,Kn,YD).call(this))},XD=function(){fe(this,wf)&&(nf.clearTimeout(fe(this,wf)),ut(this,wf,void 0))},QD=function(){fe(this,Sf)&&(nf.clearInterval(fe(this,Sf)),ut(this,Sf,void 0))},JD=function(){const t=fe(this,Fo).getQueryCache().build(fe(this,Fo),this.options);if(t===fe(this,Sn))return;const n=fe(this,Sn);ut(this,Sn,t),ut(this,x0,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},jq=function(t){Rr.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(fe(this,bo))}),fe(this,Fo).getQueryCache().notify({query:fe(this,Sn),type:"observerResultsUpdated"})})},lq);function Dme(e,t){return Ei(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function u$(e,t){return Dme(e,t)||e.state.data!==void 0&&e2(e,t,t.refetchOnMount)}function e2(e,t,n){if(Ei(t.enabled,e)!==!1&&yu(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&BR(e,t)}return!1}function d$(e,t,n,r){return(e!==t||Ei(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&BR(e,n)}function BR(e,t){return Ei(t.enabled,e)!==!1&&e.isStaleByTime(yu(t.staleTime,e))}function Mme(e,t){return!ny(e.getCurrentResult(),t)}function f$(e){return{onFetch:(t,n)=>{var d,f,h,m,g;const r=t.options,s=(h=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,o=((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=wq(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 _=(()=>{const T={client:t.client,queryKey:t.queryKey,pageParam:C,direction:N?"backward":"forward",meta:t.options.meta};return x(T),T})(),j=await y(_),{maxPages:E}=t.options,I=N?Nme:Cme;return{pages:I(v.pages,j,E),pageParams:I(v.pageParams,C,E)}};if(s&&o.length){const v=s==="backward",C=v?Ame:h$,N={pages:o,pageParams:i},k=C(r,N);a=await w(N,k,v)}else{const v=e??o.length;do{const C=c===0?i[0]??r.initialPageParam:h$(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 h$(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 Ame(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 v0,Ga,xo,Cf,Ya,Wc,cq,Rme=(cq=class extends kq{constructor(t){super();jt(this,Ya);jt(this,v0);jt(this,Ga);jt(this,xo);jt(this,Cf);ut(this,v0,t.client),this.mutationId=t.mutationId,ut(this,xo,t.mutationCache),ut(this,Ga,[]),this.state=t.state||Iq(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){fe(this,Ga).includes(t)||(fe(this,Ga).push(t),this.clearGcTimeout(),fe(this,xo).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ut(this,Ga,fe(this,Ga).filter(n=>n!==t)),this.scheduleGc(),fe(this,xo).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){fe(this,Ga).length||(this.state.status==="pending"?this.scheduleGc():fe(this,xo).remove(this))}continue(){var t;return((t=fe(this,Cf))==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,E;const n=()=>{Bt(this,Ya,Wc).call(this,{type:"continue"})},r={client:fe(this,v0),meta:this.options.meta,mutationKey:this.options.mutationKey};ut(this,Cf,Nq({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(I,T)=>{Bt(this,Ya,Wc).call(this,{type:"failed",failureCount:I,error:T})},onPause:()=>{Bt(this,Ya,Wc).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>fe(this,xo).canRun(this)}));const s=this.state.status==="pending",o=!fe(this,Cf).canStart();try{if(s)n();else{Bt(this,Ya,Wc).call(this,{type:"pending",variables:t,isPaused:o}),await((a=(i=fe(this,xo).config).onMutate)==null?void 0:a.call(i,t,this,r));const T=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));T!==this.state.context&&Bt(this,Ya,Wc).call(this,{type:"pending",context:T,variables:t,isPaused:o})}const I=await fe(this,Cf).start();return await((f=(d=fe(this,xo).config).onSuccess)==null?void 0:f.call(d,I,t,this.state.context,this,r)),await((m=(h=this.options).onSuccess)==null?void 0:m.call(h,I,t,this.state.context,r)),await((b=(g=fe(this,xo).config).onSettled)==null?void 0:b.call(g,I,null,this.state.variables,this.state.context,this,r)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,I,null,t,this.state.context,r)),Bt(this,Ya,Wc).call(this,{type:"success",data:I}),I}catch(I){try{throw await((v=(w=fe(this,xo).config).onError)==null?void 0:v.call(w,I,t,this.state.context,this,r)),await((N=(C=this.options).onError)==null?void 0:N.call(C,I,t,this.state.context,r)),await((_=(k=fe(this,xo).config).onSettled)==null?void 0:_.call(k,void 0,I,this.state.variables,this.state.context,this,r)),await((E=(j=this.options).onSettled)==null?void 0:E.call(j,void 0,I,t,this.state.context,r)),I}finally{Bt(this,Ya,Wc).call(this,{type:"error",error:I})}}finally{fe(this,xo).runNext(this)}}},v0=new WeakMap,Ga=new WeakMap,xo=new WeakMap,Cf=new WeakMap,Ya=new WeakSet,Wc=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),Rr.batch(()=>{fe(this,Ga).forEach(r=>{r.onMutationUpdate(t)}),fe(this,xo).notify({mutation:this,type:"updated",action:t})})},cq);function Iq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ql,ia,w0,uq,Pme=(uq=class extends yh{constructor(t={}){super();jt(this,ql);jt(this,ia);jt(this,w0);this.config=t,ut(this,ql,new Set),ut(this,ia,new Map),ut(this,w0,0)}build(t,n,r){const s=new Rme({client:t,mutationCache:this,mutationId:++Jv(this,w0)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){fe(this,ql).add(t);const n=tw(t);if(typeof n=="string"){const r=fe(this,ia).get(n);r?r.push(t):fe(this,ia).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(fe(this,ql).delete(t)){const n=tw(t);if(typeof n=="string"){const r=fe(this,ia).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&fe(this,ia).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=tw(t);if(typeof n=="string"){const r=fe(this,ia).get(n),s=r==null?void 0:r.find(o=>o.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=tw(t);if(typeof n=="string"){const s=(r=fe(this,ia).get(n))==null?void 0:r.find(o=>o!==t&&o.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Rr.batch(()=>{fe(this,ql).forEach(t=>{this.notify({type:"removed",mutation:t})}),fe(this,ql).clear(),fe(this,ia).clear()})}getAll(){return Array.from(fe(this,ql))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>o$(n,r))}findAll(t={}){return this.getAll().filter(n=>o$(t,n))}notify(t){Rr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Rr.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ks))))}},ql=new WeakMap,ia=new WeakMap,w0=new WeakMap,uq);function tw(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Wl,nu,Oo,Gl,xc,K1,t2,dq,Fme=(dq=class extends yh{constructor(n,r){super();jt(this,xc);jt(this,Wl);jt(this,nu);jt(this,Oo);jt(this,Gl);ut(this,Wl,n),this.setOptions(r),this.bindMethods(),Bt(this,xc,K1).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=fe(this,Wl).defaultMutationOptions(n),ny(this.options,r)||fe(this,Wl).getMutationCache().notify({type:"observerOptionsUpdated",mutation:fe(this,Oo),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Uf(r.mutationKey)!==Uf(this.options.mutationKey)?this.reset():((s=fe(this,Oo))==null?void 0:s.state.status)==="pending"&&fe(this,Oo).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=fe(this,Oo))==null||n.removeObserver(this)}onMutationUpdate(n){Bt(this,xc,K1).call(this),Bt(this,xc,t2).call(this,n)}getCurrentResult(){return fe(this,nu)}reset(){var n;(n=fe(this,Oo))==null||n.removeObserver(this),ut(this,Oo,void 0),Bt(this,xc,K1).call(this),Bt(this,xc,t2).call(this)}mutate(n,r){var s;return ut(this,Gl,r),(s=fe(this,Oo))==null||s.removeObserver(this),ut(this,Oo,fe(this,Wl).getMutationCache().build(fe(this,Wl),this.options)),fe(this,Oo).addObserver(this),fe(this,Oo).execute(n)}},Wl=new WeakMap,nu=new WeakMap,Oo=new WeakMap,Gl=new WeakMap,xc=new WeakSet,K1=function(){var r;const n=((r=fe(this,Oo))==null?void 0:r.state)??Iq();ut(this,nu,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},t2=function(n){Rr.batch(()=>{var r,s,o,i,a,c,u,d;if(fe(this,Gl)&&this.hasListeners()){const f=fe(this,nu).variables,h=fe(this,nu).context,m={client:fe(this,Wl),meta:this.options.meta,mutationKey:this.options.mutationKey};(n==null?void 0:n.type)==="success"?((s=(r=fe(this,Gl)).onSuccess)==null||s.call(r,n.data,f,h,m),(i=(o=fe(this,Gl)).onSettled)==null||i.call(o,n.data,null,f,h,m)):(n==null?void 0:n.type)==="error"&&((c=(a=fe(this,Gl)).onError)==null||c.call(a,n.error,f,h,m),(d=(u=fe(this,Gl)).onSettled)==null||d.call(u,void 0,n.error,f,h,m))}this.listeners.forEach(f=>{f(fe(this,nu))})})},dq);function m$(e,t){const n=new Set(t);return e.filter(r=>!n.has(r))}function Ome(e,t,n){const r=e.slice(0);return r[t]=n,r}var Nf,ni,ip,ap,ji,ru,S0,C0,N0,Hs,n2,r2,s2,o2,i2,fq,Lme=(fq=class extends yh{constructor(t,n,r){super();jt(this,Hs);jt(this,Nf);jt(this,ni);jt(this,ip);jt(this,ap);jt(this,ji);jt(this,ru);jt(this,S0);jt(this,C0);jt(this,N0,[]);ut(this,Nf,t),ut(this,ap,r),ut(this,ip,[]),ut(this,ji,[]),ut(this,ni,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&fe(this,ji).forEach(t=>{t.subscribe(n=>{Bt(this,Hs,o2).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,fe(this,ji).forEach(t=>{t.destroy()})}setQueries(t,n){if(ut(this,ip,t),ut(this,ap,n),process.env.NODE_ENV!=="production"){const r=t.map(s=>fe(this,Nf).defaultQueryOptions(s).queryHash);new Set(r).size!==r.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}Rr.batch(()=>{const r=fe(this,ji),s=Bt(this,Hs,s2).call(this,fe(this,ip));ut(this,N0,s),s.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const o=s.map(f=>f.observer),i=o.map(f=>f.getCurrentResult()),a=r.length!==o.length,c=o.some((f,h)=>f!==r[h]),u=a||c,d=u?!0:i.some((f,h)=>{const m=fe(this,ni)[h];return!m||!ny(f,m)});!u&&!d||(u&&ut(this,ji,o),ut(this,ni,i),this.hasListeners()&&(u&&(m$(r,o).forEach(f=>{f.destroy()}),m$(o,r).forEach(f=>{f.subscribe(h=>{Bt(this,Hs,o2).call(this,f,h)})})),Bt(this,Hs,i2).call(this)))})}getCurrentResult(){return fe(this,ni)}getQueries(){return fe(this,ji).map(t=>t.getCurrentQuery())}getObservers(){return fe(this,ji)}getOptimisticResult(t,n){const r=Bt(this,Hs,s2).call(this,t),s=r.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions));return[s,o=>Bt(this,Hs,r2).call(this,o??s,n),()=>Bt(this,Hs,n2).call(this,s,r)]}},Nf=new WeakMap,ni=new WeakMap,ip=new WeakMap,ap=new WeakMap,ji=new WeakMap,ru=new WeakMap,S0=new WeakMap,C0=new WeakMap,N0=new WeakMap,Hs=new WeakSet,n2=function(t,n){return n.map((r,s)=>{const o=t[s];return r.defaultedQueryOptions.notifyOnChangeProps?o:r.observer.trackResult(o,i=>{n.forEach(a=>{a.observer.trackProp(i)})})})},r2=function(t,n){return n?((!fe(this,ru)||fe(this,ni)!==fe(this,C0)||n!==fe(this,S0))&&(ut(this,S0,n),ut(this,C0,fe(this,ni)),ut(this,ru,VS(fe(this,ru),n(t)))),fe(this,ru)):t},s2=function(t){const n=new Map;fe(this,ji).forEach(s=>{const o=s.options.queryHash;if(!o)return;const i=n.get(o);i?i.push(s):n.set(o,[s])});const r=[];return t.forEach(s=>{var c;const o=fe(this,Nf).defaultQueryOptions(s),a=((c=n.get(o.queryHash))==null?void 0:c.shift())??new zR(fe(this,Nf),o);r.push({defaultedQueryOptions:o,observer:a})}),r},o2=function(t,n){const r=fe(this,ji).indexOf(t);r!==-1&&(ut(this,ni,Ome(fe(this,ni),r,n)),Bt(this,Hs,i2).call(this))},i2=function(){var t;if(this.hasListeners()){const n=fe(this,ru),r=Bt(this,Hs,n2).call(this,fe(this,ni),fe(this,N0)),s=Bt(this,Hs,r2).call(this,r,(t=fe(this,ap))==null?void 0:t.combine);n!==s&&Rr.batch(()=>{this.listeners.forEach(o=>{o(fe(this,ni))})})}},fq),Ka,hq,Eq=(hq=class extends yh{constructor(t={}){super();jt(this,Ka);this.config=t,ut(this,Ka,new Map)}build(t,n,r){const s=n.queryKey,o=n.queryHash??LR(s,n);let i=this.get(o);return i||(i=new Tme({client:t,queryKey:s,queryHash:o,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(i)),i}add(t){fe(this,Ka).has(t.queryHash)||(fe(this,Ka).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=fe(this,Ka).get(t.queryHash);n&&(t.destroy(),n===t&&fe(this,Ka).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Rr.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return fe(this,Ka).get(t)}getAll(){return[...fe(this,Ka).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>s$(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>s$(t,r)):n}notify(t){Rr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Rr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Rr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ka=new WeakMap,hq),$r,su,ou,lp,cp,iu,up,dp,mq,$me=(mq=class{constructor(e={}){jt(this,$r);jt(this,su);jt(this,ou);jt(this,lp);jt(this,cp);jt(this,iu);jt(this,up);jt(this,dp);ut(this,$r,e.queryCache||new Eq),ut(this,su,e.mutationCache||new Pme),ut(this,ou,e.defaultOptions||{}),ut(this,lp,new Map),ut(this,cp,new Map),ut(this,iu,0)}mount(){Jv(this,iu)._++,fe(this,iu)===1&&(ut(this,up,$R.subscribe(async e=>{e&&(await this.resumePausedMutations(),fe(this,$r).onFocus())})),ut(this,dp,US.subscribe(async e=>{e&&(await this.resumePausedMutations(),fe(this,$r).onOnline())})))}unmount(){var e,t;Jv(this,iu)._--,fe(this,iu)===0&&((e=fe(this,up))==null||e.call(this),ut(this,up,void 0),(t=fe(this,dp))==null||t.call(this),ut(this,dp,void 0))}isFetching(e){return fe(this,$r).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return fe(this,su).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=fe(this,$r).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=fe(this,$r).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(yu(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return fe(this,$r).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=fe(this,$r).get(r.queryHash),o=s==null?void 0:s.state.data,i=yme(t,o);if(i!==void 0)return fe(this,$r).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Rr.batch(()=>fe(this,$r).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=fe(this,$r).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=fe(this,$r);Rr.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=fe(this,$r);return Rr.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Rr.batch(()=>fe(this,$r).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ks).catch(Ks)}invalidateQueries(e,t={}){return Rr.batch(()=>(fe(this,$r).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=Rr.batch(()=>fe(this,$r).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,n);return n.throwOnError||(o=o.catch(Ks)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(Ks)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=fe(this,$r).build(this,t);return n.isStaleByTime(yu(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ks).catch(Ks)}fetchInfiniteQuery(e){return e.behavior=f$(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ks).catch(Ks)}ensureInfiniteQueryData(e){return e.behavior=f$(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return US.isOnline()?fe(this,su).resumePausedMutations():Promise.resolve()}getQueryCache(){return fe(this,$r)}getMutationCache(){return fe(this,su)}getDefaultOptions(){return fe(this,ou)}setDefaultOptions(e){ut(this,ou,e)}setQueryDefaults(e,t){fe(this,lp).set(Uf(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...fe(this,lp).values()],n={};return t.forEach(r=>{ty(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){fe(this,cp).set(Uf(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...fe(this,cp).values()],n={};return t.forEach(r=>{ty(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...fe(this,ou).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=LR(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===HS&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...fe(this,ou).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){fe(this,$r).clear(),fe(this,su).clear()}},$r=new WeakMap,su=new WeakMap,ou=new WeakMap,lp=new WeakMap,cp=new WeakMap,iu=new WeakMap,up=new WeakMap,dp=new WeakMap,mq),VR=Q.createContext(void 0),Zr=e=>{const t=Q.useContext(VR);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},zme=({client:e,children:t})=>(Q.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(VR.Provider,{value:e,children:t})),Tq=Q.createContext(!1),Dq=()=>Q.useContext(Tq);Tq.Provider;function Bme(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Vme=Q.createContext(Bme()),Mq=()=>Q.useContext(Vme),Aq=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Rq=e=>{Q.useEffect(()=>{e.clearReset()},[e])},Pq=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Sq(n,[e.error,r])),Fq=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Oq=(e,t)=>e.isLoading&&e.isFetching&&!t,a2=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,qS=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Wp({queries:e,...t},n){const r=Zr(),s=Dq(),o=Mq(),i=Q.useMemo(()=>e.map(b=>{const x=r.defaultQueryOptions(b);return x._optimisticResults=s?"isRestoring":"optimistic",x}),[e,r,s]);i.forEach(b=>{Fq(b),Aq(b,o)}),Rq(o);const[a]=Q.useState(()=>new Lme(r,i,t)),[c,u,d]=a.getOptimisticResult(i,t.combine),f=!s&&t.subscribed!==!1;Q.useSyncExternalStore(Q.useCallback(b=>f?a.subscribe(Rr.batchCalls(b)):Ks,[a,f]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),Q.useEffect(()=>{a.setQueries(i,t)},[i,t,a]);const m=c.some((b,x)=>a2(i[x],b))?c.flatMap((b,x)=>{const y=i[x];if(y){const w=new zR(r,y);if(a2(y,b))return qS(y,w,o);Oq(b,s)&&qS(y,w,o)}return[]}):[];if(m.length>0)throw Promise.all(m);const g=c.find((b,x)=>{const y=i[x];return y&&Pq({result:b,errorResetBoundary:o,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(g!=null&&g.error)throw g.error;return u(d())}function Hme(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=Dq(),s=Mq(),o=Zr(),i=o.defaultQueryOptions(e);(h=(f=o.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",Fq(i),Aq(i,s),Rq(s);const a=!o.getQueryCache().get(i.queryHash),[c]=Q.useState(()=>new t(o,i)),u=c.getOptimisticResult(i),d=!r&&e.subscribed!==!1;if(Q.useSyncExternalStore(Q.useCallback(x=>{const y=d?c.subscribe(Rr.batchCalls(x)):Ks;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Q.useEffect(()=>{c.setOptions(i)},[i,c]),a2(i,u))throw qS(i,c,s);if(Pq({result:u,errorResetBoundary:s,throwOnError:i.throwOnError,query:o.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if((g=(m=o.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||g.call(m,i,u),i.experimental_prefetchInRender&&!Hf&&Oq(u,r)){const x=a?qS(i,c,s):(b=o.getQueryCache().get(i.queryHash))==null?void 0:b.promise;x==null||x.catch(Ks).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?u:c.trackResult(u)}function Dn(e,t){return Hme(e,zR)}function Ume(e,t){const n=Zr(),r=n.getQueryCache();return Q.useSyncExternalStore(Q.useCallback(s=>r.subscribe(Rr.batchCalls(s)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function so(e,t){const n=Zr(),[r]=Q.useState(()=>new Fme(n,e));Q.useEffect(()=>{r.setOptions(e)},[r,e]);const s=Q.useSyncExternalStore(Q.useCallback(i=>r.subscribe(Rr.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=Q.useCallback((i,a)=>{r.mutate(i,a).catch(Ks)},[r]);if(s.error&&Sq(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:o,mutateAsync:s.mutate}}function qme(){const e=S.useContext(VR);if(e&&e.isSemaphorClient)return e}function Lq({children:e}){const{setIsSessionExpired:t}=p.useDashboardActions(),n=qme(),[r]=S.useState(()=>{const s=new $me({queryCache:new Eq({onError:o=>{o instanceof Error?(console.error(`Something went wrong: ${o.message}`),o.message==="invalid token"&&t(!0)):console.error("Something went wrong:",o)}}),defaultOptions:{queries:{gcTime:36e5,staleTime:3e5,refetchOnWindowFocus:!1,retry:!1}}});return s.isSemaphorClient=!0,s});return n?l.jsx(l.Fragment,{children:e}):l.jsx(zme,{client:r,children:e})}const Wme={id:"",authToken:void 0,tokenProps:{}},k0=S.createContext(Wme),HR=({children:e,dashboardProps:t})=>{const n=S.useMemo(()=>{let r={};const s=t.authToken;return s&&(r=jhe.jwtDecode(s.accessToken)),{...t,tokenProps:r}},[t]);return l.jsx(Lq,{children:l.jsx(k0.Provider,{value:n,children:e})})};function ht(){const e=S.useContext(k0);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}const Os=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})}}}))),Gme=()=>Os(e=>e.selectedVisual),vh=()=>Os(e=>e.actions);function _0(){const{authToken:e,version:t,tokenProps:n,id:r}=ht(),s=Os(g=>g.selectedDashboard),o=Os(g=>g.showHub),i=p.useDashboardStore(g=>g.selectedLensId),a=Yme({showHub:o,selectedDashboardId:s==null?void 0:s.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}=Dn({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 Yme({showHub:e,selectedDashboardId:t,dashboardId:n,tokenDashboardId:r}){return e?null:t||n||r||null}function Kme(){const{authToken:e}=ht(),t=p.useDashboardStore(r=>r.authToken),{setAuthToken:n}=p.useDashboardActions();return S.useEffect(()=>{const r=e==null?void 0:e.accessToken,s=t==null?void 0:t.accessToken;e&&r!==s&&n(e)},[e,t,n]),e}function $q(e){const t=S.useCallback(o=>`semaphor-default-sheet-${o}`,[]),n=S.useCallback(()=>{if(!e)return null;try{const o=t(e);return localStorage.getItem(o)}catch(o){return console.error("Error reading default sheet preference:",o),null}},[e,t]),r=S.useCallback(o=>{if(!(!e||!o))try{const i=t(e);localStorage.setItem(i,o)}catch(i){console.error("Error saving default sheet preference:",i)}},[e,t]),s=S.useCallback(()=>{if(e)try{const o=t(e);localStorage.removeItem(o)}catch(o){console.error("Error clearing default sheet preference:",o)}},[e,t]);return{getDefaultSheetId:n,setDefaultSheetId:r,clearDefaultSheetId:s}}function Zme(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 Xme(e,t){return{id:e.id,scope:e.scope,type:e.type,source:Zme(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 Qme(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],[s])=>r.localeCompare(s))):n]))}}function p$(e=[],t){return[...e].map(n=>Xme(n,t)).sort((n,r)=>n.id.localeCompare(r.id)||n.scope.localeCompare(r.scope)||n.type.localeCompare(r.type))}function Jme(e=[]){return[...e].map(Qme).sort((t,n)=>So.stableSerialize(t).localeCompare(So.stableSerialize(n)))}function l2(e,t){return e?So.stableSerialize({controlDefinitions:p$(e.controlDefinitions,t),cardControlDefinitions:p$(e.cardControlDefinitions,t),controlBindings:Jme(e.controlBindings)}):"__none__"}function Qj(e,t){return e&&t.has(e)?e:null}function epe({selectedSheetId:e,preservedSelectedSheetId:t,defaultSheetId:n,sheets:r}){var o;const s=new Set((r||[]).map(i=>i.id).filter(i=>typeof i=="string"));return Qj(e,s)||Qj(t,s)||Qj(n,s)||((o=r==null?void 0:r[0])==null?void 0:o.id)||null}function zq(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,s)=>s===0?r:b$(r)).join("");return/^[A-Za-z]/.test(n)?n:`input${b$(n)}`}function UR(e,t){const n=zq(e);return Bq(n,t)}function j0(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 Bq(j0(e),t)}function Bq(e,t){const n=new Set(t.map(s=>s.variableName).filter(s=>!!s));if(!n.has(e))return e;let r=2;for(;n.has(`${e}${r}`);)r+=1;return`${e}${r}`}function qR(e){return p.getDataType(e.dataType)==="date"?["label","start","end","range"]:["label","value"]}function WR(e){return npe(e)?["label","value"]:["value"]}function g$(e){return e.kind==="filter"?`filter:${e.filter.id}`:`control:${e.control.id}`}function tpe(e){return{placement:e.hide||e.displayMode==="canvas"?"hidden":"toolbar",...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function Vq(e){return{placement:e.hidden?"hidden":e.placement||(e.scope==="card"?"card_header":"toolbar"),...e.toolbarWidth?{widthPx:e.toolbarWidth}:{}}}function WS(e){return!!e.compatibility}function npe(e){return e.type==="enum"||e.type==="multi_enum"||e.type==="field_selector"||e.type==="metric_selector"||e.type==="aggregation_selector"||e.type==="grain_selector"}function b$(e){return e&&e[0].toUpperCase()+e.slice(1)}function rpe(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 s=!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(spe(u,c.id)),n.add(u.id),s=!0);const o=t.map(c=>{if(c.kind==="filter"&&x$(c,r)&&c.filter.variableName!==c.variableName)return s=!0,{...c,filter:{...c.filter,variableName:c.variableName}};if(c.kind!=="control"||!x$(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:(s=!0,{...c,variableName:u,control:{...c.control,id:u}})});return s?{...e,inputs:o}:e}function spe(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 x$(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 ope(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function ipe(e,t){const n=ope(e);return n==="dark"?dl({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function y$(e,t,n){return dme(ipe(e,t),n)}function ape(e){return So.stableSerialize({hasExplicitDefaultControlValues:e!==void 0,values:e??null})}function lpe(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 s=p.findCardById(e,r);return s&&(n.cardControlDefinitions!==void 0&&(s.controls=n.cardControlDefinitions),n.controlBindings!==void 0&&(s.controlBindings=n.controlBindings)),e}function cpe(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 upe({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:s,defaultControlValues:o,controlContractOverrides:i,dashboardInputExecutionSnapshot:a,type:c,cardId:u,selectedSheetId:d,onFilterValuesChange:f}){var ge,ie,Te,re,me;const{authToken:h,tokenProps:m}=ht();Kme();const g=p.useDashboardStore(ve=>ve.selectedLensId),b=p.useDashboardStore(ve=>ve.relaodToken),{data:x,isLoading:y,isFetching:w,isError:v,refetch:C,dashboardIdToFetch:N}=_0(),k=((ie=(ge=m==null?void 0:m.params)==null?void 0:ge.calendarContext)==null?void 0:ie.tz)||((Te=m==null?void 0:m.params)==null?void 0:Te.timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone,_=(re=x==null?void 0:x.dashboard)==null?void 0:re.id,{getDefaultSheetId:j,clearDefaultSheetId:E}=$q(_),[I,T]=S.useState(s||[]),D=S.useRef(null),R=S.useRef(null),F=ape(o),A=l2(i),U=l2(i,{includePresentation:!0}),$=S.useRef(o);$.current=o;const q=S.useRef(F);q.current=F;const W=cpe(i,U),O=S.useRef(null),Z=S.useRef(!1),Y=S.useRef({dashboardId:null,defaultControlValuesKey:F,controlContractOverridesKey:A}),{setTheme:M}=OR(),{compiledAppearance:K}=p.useAppearance(),L=p.useDashboardStore(ve=>ve.dashboard.globalStyle),z=S.useMemo(()=>x!=null&&x.dashboard?rpe(lpe($o(x.dashboard),{controlContractOverrides:W,cardId:u})):void 0,[x==null?void 0:x.dashboard,W,c,u]),{setDashboardWithFilterValues:B,hydrateRuntimeControlValues:V,setStyle:P,setOnSaveFunction:H,setLenses:G,setSelectedLensId:X,setInlineFilterValuesMap:ne}=p.useDashboardActions();p.useDashboardStore(ve=>ve.actions.setCustomCards);const de=p.useDashboardStore(ve=>ve.filterValues),he=p.useDashboardStore(ve=>ve.actions.setThemeStyle),pe=p.useDashboardStore(ve=>ve.actions.setDashboardTheme),xe=p.useDashboardStore(ve=>ve.actions.setOnEvent);S.useEffect(()=>{const ve=R.current;ve&&ve!==N&&p.storeEvents.emit("dashboard:unload"),R.current=N},[N]),S.useEffect(()=>{b&&C()},[C,b]),S.useEffect(()=>{var ee;const ve=((ee=x==null?void 0:x.dashboard)==null?void 0:ee.id)||null,J=D.current;ve&&ve!==J&&p.storeEvents.emit("dashboard:load"),D.current=ve},[(me=x==null?void 0:x.dashboard)==null?void 0:me.id]),S.useEffect(()=>{pe(K.mode)},[K.mode,pe]),S.useEffect(()=>{t&&M(t)},[t,M]);const se=S.useCallback(()=>{const ve=$o(p.DEFAULT_STYLE),J=dl(ve,L);if(e){const ee=dl(J,e),te=y$(K.mode,ee,K);he(te),P(ee)}else{const ee=y$(K.mode,J,K);he(ee),P(p.DEFAULT_STYLE)}},[K,e,L,he,P]);return S.useEffect(()=>{x&&x.dashboard&&se()},[K.mode,e,L,se,x]),S.useEffect(()=>{var Pe,He,tt,Ae;function ve(Ie,We){const xt=Ie.filters||[],bt=[];for(const dt of We){const vt=xt.find(st=>st.id===dt.filterId);vt&&bt.push({filterId:dt.filterId,name:vt.column,operation:dt.operation,valueType:p.getFilterValueType(vt),values:dt.values,dataType:vt.dataType,fieldMeta:vt.fieldMeta,semanticContext:vt.semanticContext})}return bt}if(!x||!z)return;const J=z,{filterValues:ee,defaultLensId:te,lenses:ue}=x;function le(){if(ee&&(ee==null?void 0:ee.length)>0)return ee;const We=[...p.buildFilterValuesFromDefaults(J.filters,k)];if(J.defaultFilterValues&&J.defaultFilterValues.length>0)for(const dt of J.defaultFilterValues){const vt=We.findIndex(st=>st.filterId===dt.filterId);vt>=0?We[vt]=dt:We.push(dt)}const xt=ve(J,I||[]),bt=[...We];for(const dt of xt){const vt=bt.findIndex(st=>st.filterId===dt.filterId);vt>=0?bt[vt]=dt:bt.push(dt)}return bt}const ke=p.useDashboardStore.getState(),Se=O.current===z.id&&((Pe=ke.dashboard)==null?void 0:Pe.id)===z.id,oe=le(),je=Se?p.resolveSameDashboardFilterValues({previousFilters:(He=ke.dashboard)==null?void 0:He.filters,nextFilters:J.filters,currentFilterValues:ke.filterValues,defaultFilterValues:oe}):oe,Ne=p.computeInlineFilterDefaults(J,k),Oe=Se&&Y.current.controlContractOverridesKey===A?p.flattenRuntimeControlValues({dashboardValues:ke.controlValues,cardValuesMap:ke.cardControlValuesMap}):$.current,Ge=ke.selectedSheetId;let Le=j(),Be=Ge;Be&&((tt=z==null?void 0:z.sheets)!=null&&tt.some(We=>We.id===Be)||(Be=null)),Le&&((Ae=z==null?void 0:z.sheets)!=null&&Ae.some(We=>We.id===Le)||(E(),Le=null));const Ke=epe({selectedSheetId:d,preservedSelectedSheetId:Be,defaultSheetId:Le,sheets:z==null?void 0:z.sheets}),Ce=!!a,Je=!Ce&&Z.current;B(J,je||[],Oe,{selectedSheetId:Ke,...x!=null&&x.semanticExecutionPayload?{semanticExecutionPayload:x.semanticExecutionPayload}:{},...a?{dashboardInputValues:a.dashboardInputValues,dashboardInputValuesAreAuthoritative:!0}:Je?{dashboardInputValues:{},dashboardInputValuesAreAuthoritative:!1}:{}}),Z.current=Ce,O.current=z.id,Y.current.dashboardId!==z.id&&(Y.current={dashboardId:z.id,defaultControlValuesKey:q.current,controlContractOverridesKey:A}),ne(Ne),ue&&G(ue),te&&X(te)},[x,k,g,G,B,X,ne,I,d,j,E,A,a,z]),S.useEffect(()=>{if(!(z!=null&&z.id))return;const ve=Y.current;if(ve.dashboardId!==z.id){Y.current={dashboardId:z.id,defaultControlValuesKey:F,controlContractOverridesKey:A};return}ve.defaultControlValuesKey===F&&ve.controlContractOverridesKey===A||(V(z,$.current),Y.current={dashboardId:z.id,defaultControlValuesKey:F,controlContractOverridesKey:A})},[z,F,A,V]),S.useEffect(()=>{f&&de&&f(de)},[de,f]),S.useEffect(()=>{n&&H(n),r&&xe(r)},[n,H,r,xe]),{isFetching:w,isLoading:y,isError:v}}const ry=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}));ry.displayName="Card";const GR=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}));GR.displayName="CardHeader";const Gp=Q.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:p.cn("text-2xl font-semibold leading-none tracking-tight",e),...t}));Gp.displayName="CardTitle";const dpe=Q.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));dpe.displayName="CardDescription";const YR=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("px-6 pt-0",e),...t}));YR.displayName="CardContent";const Hq=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("flex items-center p-6 pt-0",e),...t}));Hq.displayName="CardFooter";/**
@@ -611,7 +611,7 @@ result = df.to_dict('records') # must return 'result' as [dict] type
611
611
 
612
612
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
613
613
 
614
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return Q.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},wxe="DialogDescriptionWarning",Sxe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ZG(wxe).contentName}}.`;return Q.useEffect(()=>{var o;const s=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},uk=FG,xP=LG,dk=zG,Kp=BG,Zp=VG,P0=UG,F0=WG,fk=YG;const _o=uk,XG=xP,Cxe=dk,QG=Q.forwardRef(({className:e,...t},n)=>l.jsx(Kp,{ref:n,className:p.cn("fixed inset-0 z-50 bg-zinc-950/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));QG.displayName=Kp.displayName;const ao=Q.forwardRef(({className:e,children:t,showCloseButton:n=!0,hideOverlay:r=!1,...s},o)=>l.jsxs(Cxe,{children:[!r&&l.jsx(p.PortalScope,{children:l.jsx(QG,{})}),l.jsx(p.PortalScope,{children:l.jsxs(Zp,{ref:o,className:p.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 focus:outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...s,children:[t,n?l.jsxs(fk,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(p.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]}):null]})})]}));ao.displayName=Zp.displayName;const Zi=({className:e,...t})=>l.jsx("div",{className:p.cn("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Zi.displayName="DialogHeader";const Ic=({className:e,...t})=>l.jsx("div",{className:p.cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ic.displayName="DialogFooter";const lo=Q.forwardRef(({className:e,...t},n)=>l.jsx(P0,{ref:n,className:p.cn("text-lg font-semibold leading-none tracking-tight",e),...t}));lo.displayName=P0.displayName;const Go=Q.forwardRef(({className:e,...t},n)=>l.jsx(F0,{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));Go.displayName=F0.displayName;function Q1(e,t){return`${e.replace(/\/$/,"")}/dashboard-authoring${t}`}function Nxe(e=!0){const{authToken:t,tokenProps:n}=ht();return Dn({queryKey:["dashboard-authoring-sources",n.apiServiceUrl,n.project_id,n.tenantId,n.endUserId,n.orgUserId,t==null?void 0:t.accessToken],enabled:e&&!!(t!=null&&t.accessToken)&&!!n.apiServiceUrl,queryFn:async()=>(await p.getRequest(Q1(n.apiServiceUrl,"/sources"),(t==null?void 0:t.accessToken)||"")).sources||[]})}function kxe(){const{authToken:e,tokenProps:t}=ht(),n=(e==null?void 0:e.accessToken)||"",r=t.apiServiceUrl,s=so({mutationFn:async a=>(await p.postRequestRegular(Q1(r,"/plan"),n,a)).plan}),o=so({mutationFn:async a=>{const c="domainId"in a?{mode:"suggestions",domainId:a.domainId,datasetNames:a.datasetNames,instruction:a.instruction}:{mode:"suggestions",dataset:a.dataset,instruction:a.instruction};return(await p.postRequestRegular(Q1(r,"/plan"),n,c)).suggestions||[]}}),i=so({mutationFn:async a=>{const c="plan"in a?{plan:a.plan,sharing:a.sharing}:{plan:a};return p.postRequestRegular(Q1(r,"/create"),n,{...c})}});return{planDashboard:s,suggestDashboards:o,createDashboardFromPlan:i}}const Jj="__describe_own__",eb=6,_xe=350;function eI(e){return e.kind==="semantic"?e.label||e.datasetName:e.label||[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")||e.tableName}function C$(e){if(e){if(typeof e=="string")return e;if(typeof e=="object"){const t=e;return typeof t.label=="string"&&t.label||typeof t.name=="string"&&t.name||typeof t.qualifiedFieldName=="string"&&t.qualifiedFieldName||void 0}}}function N$(e){return e.kind==="semantic"?{kind:"semantic",domainId:e.domainId,datasetName:e.datasetName,datasetId:e.datasetId,label:e.label,connectionId:e.connectionId}:{kind:"physical",connectionId:e.connectionId,databaseName:e.databaseName,schemaName:e.schemaName,tableName:e.tableName,label:e.label}}function jxe(e){const t=new Map;for(const n of e){if(n.kind!=="semantic")continue;const r=n.domainId;t.has(r)||t.set(r,{id:r,label:n.domainLabel||n.domainName||"Semantic domain",items:[]}),t.get(r).items.push(n)}return Array.from(t.values())}function rw(e){return Array.from(new Set(Array.from(e).map(t=>t.trim()).filter(Boolean)))}function Ixe(e){switch(e){case"kpi":return"KPI";case"line":return"Trend";case"bar":case"stackedBar":return"Breakdown";case"table":return"Table";case"text":return"Text";default:return e?e.replace(/([A-Z])/g," $1"):"Card"}}function Exe(e){return(e==null?void 0:e.kind)==="semantic"?e.datasetName:void 0}function JG(e){var s,o,i,a,c,u,d;const t=e.analyticsIntent,n=new Set,r=f=>{const h=Exe(f);h&&n.add(h)};return t&&(r(t.source),t.kind==="metric"&&((s=t.metrics)==null||s.forEach(f=>r(f.source)),r((o=t.primaryMetric)==null?void 0:o.source),(i=t.dimensions)==null||i.forEach(f=>r(f.source)),r((a=t.dateField)==null?void 0:a.source),(c=t.filters)==null||c.forEach(f=>r(f.field.source))),t.kind==="records"&&((u=t.fields)==null||u.forEach(f=>r(f.source)),r((d=t.dateField)==null?void 0:d.source))),n}function Txe(e){var o;const t=e.sheets.flatMap(i=>i.cards),n=t.filter(i=>i.type!=="text"),r=n.filter(i=>JG(i).size>1),s=((o=e.filterInputs)==null?void 0:o.length)||0;return{cards:t,dataCards:n,joinedCards:r,filterCount:s,datasetCount:e.datasets.length}}function eY({open:e,onOpenChange:t,onCreateBlank:n,onAiCreateSuccess:r,isCreatingBlank:s,sources:o,sourcesLoading:i=!1,suggestDashboards:a,planDashboard:c,createDashboardFromPlan:u,settingsSlot:d,blankDescription:f="",description:h="Start blank, or pick a dataset to see starter ideas tailored to your data.",canCreate:m=!0}){const[g,b]=S.useState("blank"),[x,y]=S.useState(null),[w,v]=S.useState([]),[C,N]=S.useState(!1),[k,_]=S.useState(null),[j,E]=S.useState(""),[I,T]=S.useState(""),[D,R]=S.useState(""),[F,A]=S.useState(""),[U,$]=S.useState(""),[q,W]=S.useState("idle"),[O,Z]=S.useState("choose"),[Y,M]=S.useState(null),K=S.useRef(!1),L=S.useRef(0),[z,B]=S.useState(!1),V=()=>{L.current+=1,Z("choose"),M(null)},P=S.useMemo(()=>o.filter($e=>$e.kind==="semantic"),[o]),H=P.length>0,G=g,X=b,ne=G==="blank",de=G==="dataset",he=i?"Checking datasets...":H?void 0:"No datasets found",pe=S.useMemo(()=>{const $e=new Set;for(const Ue of P)Ue.kind==="semantic"&&$e.add(Ue.domainId);return $e.size===1},[P]),xe=S.useMemo(()=>jxe(P),[P]);S.useEffect(()=>{!x&&pe&&P.length>0&&(y(P[0]),v([P[0].datasetName]))},[x,pe,P]);const se=S.useMemo(()=>!x||x.kind!=="semantic"?[]:P.filter($e=>$e.kind==="semantic"&&$e.domainId===x.domainId),[x,P]);S.useEffect(()=>{if(!x||x.kind!=="semantic"){w.length>0&&v([]),C&&N(!1);return}const $e=new Set(se.map(lt=>lt.datasetName));let Ue=rw(w).filter(lt=>$e.has(lt));C||(Ue=Ue.slice(0,eb)),Ue.length===0&&Ue.push(x.datasetName),Ue.join("|")!==w.join("|")&&v(Ue),se.length<=1&&C&&N(!1)},[w,se,x,C]);const ge=S.useMemo(()=>new Set(w),[w]),ie=S.useMemo(()=>!x||x.kind!=="semantic"?[]:se.filter($e=>ge.has($e.datasetName)),[ge,se,x]),Te=C?se.length:ie.length,re=de&&!!x&&Te>0,me=S.useMemo(()=>C?new Set(se.map($e=>$e.datasetName)):ge,[C,se,ge]),ve=S.useMemo(()=>new Set(se.map($e=>$e.datasetName)),[se]),J=!C&&w.length<eb,ee=re&&!C&&ie.length>1?ie.map($e=>$e.datasetName):void 0,te=S.useMemo(()=>!x||!re?"":x.kind==="semantic"?C?`${x.domainId}:whole`:`${x.domainId}:${ie.map($e=>$e.datasetName).join(",")}`:[x.connectionId,x.databaseName,x.schemaName,x.tableName].filter(Boolean).join(":"),[re,ie,x,C]),[ue,le]=S.useState(te);S.useEffect(()=>{const $e=window.setTimeout(()=>{le(te)},_xe);return()=>window.clearTimeout($e)},[te]);const ke=te===ue;S.useEffect(()=>{e||(X("blank"),y(null),v([]),N(!1),_(null),E(""),T(""),R(""),A(""),$(""),W("idle"),V())},[e,X]);const Se=S.useMemo(()=>{if(!x||!re||!ke)return null;if(x.kind==="semantic"&&(C||ie.length>1))return["dashboard-suggestions","semantic-domain",x.domainId,C?"whole":ie.map($e=>$e.datasetName).join(","),I];if(x.kind==="semantic"){const $e=ie[0]||x;return["dashboard-suggestions","semantic",$e.domainId,$e.datasetName,I]}return["dashboard-suggestions","physical",x.connectionId,x.databaseName,x.schemaName,x.tableName,I]},[I,re,ie,x,ke,C]),oe=S.useMemo(()=>!x||!re||!ke?null:x.kind==="semantic"&&(C||ie.length>1)?{domainId:x.domainId,datasetNames:ee,instruction:I||void 0}:{dataset:N$(ie[0]||x),instruction:I||void 0},[I,re,ee,ie,x,ke,C]),je=Dn({queryKey:Se??["dashboard-suggestions","idle"],queryFn:()=>a(oe),enabled:!!oe&&e,staleTime:5*60*1e3,gcTime:10*60*1e3}),Ne=je.data??null,Oe=(Se==null?void 0:Se.join("|"))??"";S.useEffect(()=>{_(null),V()},[Oe]);const Ge=()=>{!x||!re||(_(null),V(),je.refetch())},Le=S.useMemo(()=>(Ne==null?void 0:Ne.find($e=>$e.id===k))||null,[Ne,k]),Be=(x==null?void 0:x.kind)==="semantic"&&xe.find($e=>$e.id===x.domainId)||null,Ke=(Be==null?void 0:Be.label)||"this domain",Ce=x?C?`All ${se.length} datasets in ${Ke}`:`${Te} of ${se.length} datasets in ${Ke}`:he||"Pick data to see recommendations",Je=$e=>{if($e.kind!=="semantic")return;const Ue=(x==null?void 0:x.kind)==="semantic"&&x.domainId===$e.domainId;y($e),N(!1),v(lt=>Ue&&lt.length>0&&!C?lt.slice(0,eb):[$e.datasetName]),_(null),V(),$("")},Pe=$e=>{if($e.kind!=="semantic")return;const Ue=(x==null?void 0:x.kind)==="semantic"&&x.domainId===$e.domainId;y($e),N(!1),v(lt=>{const Ct=Ue&&!C?lt:[],Nt=new Set(Ct);if(Nt.has($e.datasetName))Nt.delete($e.datasetName);else{if(Nt.size>=eb)return rw(Nt);Nt.add($e.datasetName)}return Nt.size===0&&Nt.add($e.datasetName),rw(Nt)}),_(null),V(),$("")},He=$e=>{const Ue=$e.items[0];Ue&&(y(Ue),v($e.items.map(lt=>lt.datasetName)),N(!0),_(null),V(),$(""))},tt=$e=>{const Ue=se.find(lt=>lt.datasetName===$e);Ue&&(me.has($e)||Pe(Ue))},Ae=j.trim(),Ie=re&&Ae!==I,We=()=>{Ie&&(T(Ae),_(null),V(),$(""))},xt=$e=>{$e.key!=="Enter"||$e.shiftKey||$e.nativeEvent.isComposing||($e.preventDefault(),We())},bt=k===Jj,dt=k!==null&&!bt,vt=D.trim().length>0,st=dt||bt&&vt,Dt=F.trim().length>0,Ee=de&&re&&!C&&ie.length===1,Ze=de&&re&&!st&&!Ee,Qe=ne||de&&!st&&Ee,nt=O==="review"&&!!Y,yt=ne?Dt:de&&re&&(st||Dt&&Ee),Ft=z||c.isPending||u.isPending||s,At=()=>{var Ct;if(!x)return null;const $e=(Le==null?void 0:Le.prompt)||D.trim()||"Create a starter dashboard.",Ue=rw(((Ct=Le==null?void 0:Le.datasets)==null?void 0:Ct.map(Nt=>Nt.name))||[]),lt=x.kind==="semantic"?Ue.length>1?Ue:ee:void 0;return x.kind==="semantic"&&(C||ie.length>1)?{prompt:$e,domainId:x.domainId,datasetNames:lt}:{prompt:$e,dataset:N$(ie[0]||x)}},fn=async()=>{if(K.current||Ft)return;K.current=!0,B(!0),$("");let $e=null;try{if(ne){await n({title:F.trim()||"Untitled dashboard",description:f});return}if(!x)return;if(!st){if(!Ee)return;await n({title:F.trim()||"Untitled dashboard",description:f,dataset:ie[0]||x});return}if(!Y){const Ct=At();if(!Ct)return;const Nt=L.current+1;L.current=Nt,$e=Nt,W("planning");const it=await c.mutateAsync(Ct);if(L.current!==Nt)return;M(it),Z("review");return}const Ue=F.trim()?{...Y,title:F.trim()}:Y;W("validating");const lt=await u.mutateAsync(Ue);r(lt)}catch(Ue){if($e!==null&&L.current!==$e)return;$(p.getRequestErrorMessage(Ue,"The dashboard could not be created from this recommendation."))}finally{K.current=!1,B(!1),W("idle")}};return l.jsx(_o,{open:e,onOpenChange:t,children:l.jsxs(ao,{className:`flex max-w-[94vw] flex-col gap-0 overflow-hidden p-0 transition-[width,height] duration-300 ease-out motion-reduce:transition-none ${de?"h-[720px] max-h-[88vh] w-[1120px]":"h-[440px] w-[520px]"}`,children:[l.jsx("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx(lo,{className:"text-[15px] font-semibold tracking-tight",children:"New dashboard"}),l.jsx(Go,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:de?he||"Pick data on the left, then choose a starter idea.":h})]}),de&&l.jsx("button",{type:"button",onClick:()=>{X("blank"),_(null),R(""),V(),$("")},className:"mr-6 mt-0.5 text-[11px] font-medium text-muted-foreground hover:text-foreground",children:"Start blank instead"})]})}),ne?l.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsx(k$,{kind:"blank",selected:!0,onClick:()=>{X("blank"),_(null),R(""),$("")}}),l.jsx(k$,{kind:"dataset",selected:!1,hint:he,onClick:()=>{X("dataset"),$("")}})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx(_$,{children:"Title"}),l.jsx("input",{type:"text",value:F,onChange:$e=>A($e.target.value),placeholder:"Name your dashboard",className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground focus:border-foreground/40 focus:outline-none"})]}),d?l.jsx("div",{className:"mt-4",children:d}):null]}):l.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[320px_1fr] overflow-hidden",children:[l.jsx(Rxe,{groups:xe,loading:i,selectedSource:x,selectedDatasetNames:ge,useWholeDomain:C,selectionLimit:eb,onPickSource:Je,onToggleDataset:Pe,onUseWholeDomain:He,summary:re?Ce:null}),l.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden",children:[O==="choose"&&l.jsx("div",{className:"shrink-0 border-b border-border px-4 py-3",children:l.jsxs("div",{className:"flex items-end gap-2 rounded-[6px] border border-border bg-background px-3 py-2 focus-within:border-foreground/40",children:[l.jsx("textarea",{rows:2,value:j,onChange:$e=>E($e.target.value),onKeyDown:xt,placeholder:"Add context to steer every idea. e.g. focus on last quarter, use USD, exclude internal accounts.",className:"block flex-1 resize-none bg-transparent text-[12px] leading-[1.55] text-foreground placeholder:text-muted-foreground focus:outline-none"}),l.jsx(p.Button,{type:"button",size:"xs",variant:Ae?"default":"secondary",disabled:!Ie,onClick:We,children:"Update ideas"})]})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-4 border-b border-border px-4 py-2",children:[l.jsx(Mxe,{step:nt?"review":"choose"}),!nt&&l.jsxs("button",{type:"button",onClick:Ge,disabled:!re||Ne===null,className:"ml-auto inline-flex h-6 items-center gap-1 rounded-[3px] px-1.5 text-[10.5px] text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50",children:[l.jsx(Yf,{className:"h-2.5 w-2.5"}),"Suggest more"]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[nt?l.jsx(Axe,{plan:Y,titleOverride:F.trim()}):re?l.jsx("div",{children:Ne===null?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(p.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Fetching recommendations…"]}),l.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:Array.from({length:4}).map(($e,Ue)=>l.jsx(Lxe,{},Ue))})]}):l.jsxs("div",{className:"grid grid-cols-2 gap-2.5",children:[Ne.slice(0,4).map($e=>l.jsx(Pxe,{suggestion:$e,selected:k===$e.id,selectedDatasetNames:me,domainDatasetNames:ve,canAddDataset:J,onAddDataset:tt,onClick:()=>{_(Ue=>Ue===$e.id?null:$e.id),R(""),V(),$("")}},$e.id)),l.jsx(Oxe,{selected:bt,onClick:()=>{_($e=>$e===Jj?null:Jj),V(),$("")}})]})}):l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 text-center",children:[l.jsx(zi,{className:"h-5 w-5 text-muted-foreground"}),l.jsx("div",{className:"mt-2 text-[12.5px] font-medium text-foreground",children:i?"Loading datasets…":"Pick data to see recommendations"}),l.jsx("div",{className:"max-w-[320px] text-[11.5px] leading-relaxed text-muted-foreground",children:"Pick one or more datasets on the left, or All datasets in a domain."})]}),bt&&l.jsx("div",{className:"mt-3 rounded-[5px] border border-border bg-background focus-within:border-foreground/40",children:l.jsx("textarea",{rows:3,autoFocus:!0,value:D,onChange:$e=>{R($e.target.value),V(),$("")},placeholder:"e.g. Executive view with revenue KPIs, weekly trend, and a top-customers table.",className:"block w-full resize-none bg-transparent px-2.5 py-2 text-[12px] leading-[1.55] text-foreground placeholder:text-muted-foreground focus:outline-none"})}),re&&(st||Ee)&&l.jsxs("div",{className:"mt-4",children:[l.jsx(_$,{children:Qe?"Title":"Title (optional)"}),l.jsx("input",{type:"text",value:F,onChange:$e=>A($e.target.value),placeholder:Qe?"Name your dashboard":(Le==null?void 0:Le.title)||"We will suggest one",className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground focus:border-foreground/40 focus:outline-none"})]}),Ze&&l.jsx("div",{className:"mt-4 rounded-[5px] border border-border bg-muted/30 px-3 py-2 text-[11.5px] leading-relaxed text-muted-foreground",children:"Choose a recommendation or describe what you want to create from this data scope."}),U&&l.jsx("div",{className:"mt-4 rounded-[5px] border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11.5px] leading-relaxed text-destructive",children:U}),d?l.jsx("div",{className:"mt-4",children:d}):null]})]})]}),l.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/30 px-5 py-2.5",children:[st&&Ft?l.jsx("span",{className:"text-[11px] text-muted-foreground",children:q==="validating"?"Validating cards against your data.":"This may take up to 30 seconds."}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>t(!1),disabled:Ft,children:"Cancel"}),nt?l.jsx(p.Button,{type:"button",variant:"secondary",size:"xs",onClick:()=>{V(),$("")},disabled:Ft,children:"Back to ideas"}):null,l.jsx(p.Button,{type:"button",size:"xs",disabled:!yt||!m||Ft,onClick:fn,children:Ft?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3 w-3 animate-spin"}),st?q==="planning"?"Planning Insights…":q==="validating"?"Validating cards…":"Building dashboard…":"Creating…"]}):l.jsxs(l.Fragment,{children:[st&&!nt?"Review plan":"Create dashboard",l.jsx(XN,{className:"h-3 w-3"})]})})]})]})]})})}function Dxe({open:e,onOpenChange:t,onCreateBlank:n,onAiCreateSuccess:r,isCreatingBlank:s}){const o=Nxe(e),{suggestDashboards:i,planDashboard:a,createDashboardFromPlan:c}=kxe();return l.jsx(eY,{open:e,onOpenChange:t,onCreateBlank:n,onAiCreateSuccess:r,isCreatingBlank:s,sources:o.data||[],sourcesLoading:o.isLoading,suggestDashboards:i.mutateAsync,planDashboard:a,createDashboardFromPlan:c})}function Mxe({step:e}){const t=[{id:"choose",label:"Choose idea"},{id:"review",label:"Review plan"}],n=t.findIndex(r=>r.id===e);return l.jsx("div",{className:"flex items-center gap-2",children:t.map((r,s)=>{const o=r.id===e,i=s<n;return l.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&l.jsx("span",{className:"h-px w-4 bg-border","aria-hidden":"true"}),l.jsxs("span",{className:`inline-flex h-5 items-center gap-1 rounded-full px-2 text-[10px] font-medium ${o?"bg-foreground text-background":i?"bg-muted text-foreground":"bg-transparent text-muted-foreground"}`,children:[i?l.jsx(p.Check,{className:"h-2.5 w-2.5"}):l.jsx("span",{children:s+1}),r.label]})]},r.id)})})}function Axe({plan:e,titleOverride:t}){const n=Txe(e),r=e.datasets.map(o=>o.kind==="semantic"?o.label||o.datasetName:o.kind==="physical"?o.label||[o.databaseName,o.schemaName,o.tableName].filter(Boolean).join(".")||o.tableName:o.label||"Dataset"),s=[...(e.warnings||[]).map(o=>o.message),...e.unresolvedRequests||[]].filter(Boolean);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:t||e.title||"Dashboard plan"}),e.description&&l.jsx("div",{className:"mt-1 max-w-[680px] text-[11.5px] leading-relaxed text-muted-foreground",children:e.description})]}),l.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[l.jsx(sw,{label:"Cards",value:n.dataCards.length}),l.jsx(sw,{label:"Datasets",value:n.datasetCount}),l.jsx(sw,{label:"Filters",value:n.filterCount}),l.jsx(sw,{label:"Joined cards",value:n.joinedCards.length})]}),l.jsxs("div",{children:[l.jsx("div",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Cards to create"}),l.jsx("div",{className:"divide-y divide-border rounded-[6px] border border-border",children:n.cards.slice(0,Mhe.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS).map(o=>{const i=Array.from(JG(o));return l.jsxs("div",{className:"grid grid-cols-[88px_1fr_auto] items-center gap-2 px-2.5 py-2",children:[l.jsx("span",{className:"rounded-[3px] bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:Ixe(o.type)}),l.jsx("span",{className:"min-w-0 truncate text-[12px] text-foreground",children:o.title}),i.length>0&&l.jsx("span",{className:"max-w-[220px] truncate text-[10.5px] text-muted-foreground",children:i.join(" + ")})]},o.id)})})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(tI,{title:"Datasets",empty:"No datasets selected",items:r}),l.jsx(tI,{title:"Filters",empty:"No dashboard filters planned",items:(e.filterInputs||[]).map(o=>o.label)})]}),n.joinedCards.length>0&&l.jsx(tI,{title:"Relationship-based cards",empty:"No relationship-based cards planned",items:n.joinedCards.map(o=>o.title)}),s.length>0&&l.jsx("div",{className:"rounded-[6px] border border-amber-300/60 bg-amber-50/60 px-3 py-2 text-[11.5px] leading-relaxed text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300",children:s.slice(0,3).map(o=>l.jsx("div",{children:o},o))})]})}function sw({label:e,value:t}){return l.jsxs("div",{className:"rounded-[6px] border border-border bg-muted/20 px-2.5 py-2",children:[l.jsx("div",{className:"text-[15px] font-semibold tabular-nums text-foreground",children:t}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:e})]})}function tI({title:e,empty:t,items:n}){return l.jsxs("div",{children:[l.jsx("div",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),l.jsx("div",{className:"min-h-10 rounded-[6px] border border-border px-2.5 py-2 text-[11.5px] leading-relaxed",children:n.length>0?l.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.slice(0,8).map(r=>l.jsx("span",{className:"max-w-full truncate rounded-[3px] bg-muted px-1.5 py-0.5 text-muted-foreground",children:r},r))}):l.jsx("span",{className:"text-muted-foreground",children:t})})]})}function Rxe({groups:e,loading:t,selectedSource:n,selectedDatasetNames:r,useWholeDomain:s,selectionLimit:o,onPickSource:i,onToggleDataset:a,onUseWholeDomain:c,summary:u}){const[d,f]=S.useState(""),[h,m]=S.useState({}),g=d.trim().toLowerCase(),b=(n==null?void 0:n.kind)==="semantic"?n.domainId:null,x=!s&&r.size>=o,y=C=>!g||(C||"").toLowerCase().includes(g),w=e.filter(C=>y(C.label)||C.items.some(N=>y(eI(N)))),v=C=>h[C.id]!==void 0?h[C.id]:g||e.length===1?!0:C.id===b;return l.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden border-r border-border",children:[l.jsxs("div",{className:"shrink-0 border-b border-border px-3 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[l.jsx($s,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("input",{value:d,onChange:C=>f(C.target.value),placeholder:"Search datasets…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),d&&l.jsx("button",{type:"button",onClick:()=>f(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]}),l.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Dashboard scope"}),x&&l.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Max ",o," · clear one to swap"]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[t&&l.jsxs("div",{className:"flex items-center gap-2 px-1 py-2 text-[11px] text-muted-foreground",children:[l.jsx(p.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Loading datasets…"]}),!t&&w.length===0&&l.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[l.jsx("div",{className:"text-[12px] text-foreground",children:"No datasets found"}),l.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:"Try a different search or connect a semantic domain."})]}),w.map(C=>{const N=v(C),k=C.items.filter(I=>b===C.id&&r.has(I.datasetName)).length,_=b===C.id&&s,j=y(C.label),E=g&&!j?C.items.filter(I=>y(eI(I))):C.items;return l.jsxs("div",{className:"mb-0.5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 rounded-[4px] px-1.5 py-1.5 hover:bg-accent/60",children:[l.jsxs("button",{type:"button",onClick:()=>m(I=>({...I,[C.id]:!N})),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[N?l.jsx(p.ChevronDown,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):l.jsx(Bn,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(zi,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate text-[12px] font-medium text-foreground",children:C.label}),l.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:k>0?`${k}/${C.items.length}`:C.items.length})]}),_?l.jsxs("button",{type:"button",onClick:()=>i(C.items[0]),className:"inline-flex h-5 items-center gap-1 rounded-[3px] bg-foreground px-1.5 text-[10px] font-medium text-background",title:"All datasets in this domain are selected. Click to go back to picking datasets.",children:[l.jsx(T0,{className:"h-2.5 w-2.5"}),"All datasets"]}):l.jsx("button",{type:"button",onClick:()=>c(C),className:"inline-flex h-5 items-center rounded-[3px] border border-border px-1.5 text-[10px] font-medium text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:"Use every dataset in this domain",children:"All datasets"})]}),N&&l.jsx("div",{className:"ml-3.5 border-l border-border pl-1.5",children:E.map(I=>{const T=b===C.id&&r.has(I.datasetName),D=b===C.id&&!s&&!T&&r.size>=o;return l.jsxs("button",{type:"button",onClick:()=>a(I),disabled:D,className:`flex w-full items-center gap-2 rounded-[4px] px-1.5 py-1.5 text-left ${T?"bg-accent":"hover:bg-accent/60"} ${D?"cursor-not-allowed opacity-45 hover:bg-transparent":""}`,children:[l.jsx("span",{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[4px] border ${T?"border-foreground bg-foreground text-background":"border-border"}`,children:T&&l.jsx(p.Check,{className:"h-2.5 w-2.5"})}),l.jsx(p.Table2,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"flex-1 truncate text-[12px] text-foreground/90",children:eI(I)}),C$(I.primaryDateField)&&l.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:C$(I.primaryDateField)})]},`${C.id}:${I.datasetName}`)})})]},C.id)})]}),l.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5 text-[11px] leading-relaxed",children:u?l.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[l.jsx(kpe,{className:"h-3 w-3 shrink-0"}),l.jsx("span",{className:"font-medium text-foreground",children:u})]}):l.jsx("span",{className:"text-muted-foreground",children:"Pick data to see recommendations."})})]})}function Pxe({suggestion:e,selected:t,selectedDatasetNames:n,domainDatasetNames:r,canAddDataset:s,onAddDataset:o,onClick:i}){var a;return l.jsxs("div",{className:`group relative flex flex-col overflow-hidden rounded-[5px] border bg-background transition-colors ${t?"border-foreground":"border-border hover:border-foreground/30"}`,children:[l.jsxs("button",{type:"button",onClick:i,className:"block w-full px-2.5 pt-2.5 pb-1.5 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/40",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",title:e.title,children:e.title}),l.jsx("div",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",title:e.description,children:e.description})]}),t&&l.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-foreground",children:l.jsx(p.Check,{className:"h-2.5 w-2.5 text-background"})})]}),l.jsx("div",{className:"mt-2 flex gap-1",children:e.preview.slice(0,5).map((c,u)=>l.jsx($xe,{kind:c},u))})]}),l.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-2.5 pb-2.5 pt-1.5 text-[10px] text-muted-foreground",children:(a=e.datasets)!=null&&a.length?l.jsx(Fxe,{datasets:e.datasets,relationshipHints:e.relationshipHints,selectedDatasetNames:n,domainDatasetNames:r,canAddDataset:s,onAddDataset:o}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{children:[e.cardCount," cards"]}),e.filterCount>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border",children:"·"}),l.jsxs("span",{children:[e.filterCount," filter",e.filterCount>1?"s":""]})]})]})})]})}function Fxe({datasets:e,relationshipHints:t,selectedDatasetNames:n,domainDatasetNames:r,canAddDataset:s,onAddDataset:o}){const i=t!=null&&t.length?t.join(`
614
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return Q.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},wxe="DialogDescriptionWarning",Sxe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ZG(wxe).contentName}}.`;return Q.useEffect(()=>{var o;const s=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},uk=FG,xP=LG,dk=zG,Kp=BG,Zp=VG,P0=UG,F0=WG,fk=YG;const _o=uk,XG=xP,Cxe=dk,QG=Q.forwardRef(({className:e,...t},n)=>l.jsx(Kp,{ref:n,className:p.cn("fixed inset-0 z-50 bg-zinc-950/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));QG.displayName=Kp.displayName;const ao=Q.forwardRef(({className:e,children:t,showCloseButton:n=!0,hideOverlay:r=!1,...s},o)=>l.jsxs(Cxe,{children:[!r&&l.jsx(p.PortalScope,{children:l.jsx(QG,{})}),l.jsx(p.PortalScope,{children:l.jsxs(Zp,{ref:o,className:p.cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 focus:outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...s,children:[t,n?l.jsxs(fk,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(p.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]}):null]})})]}));ao.displayName=Zp.displayName;const Zi=({className:e,...t})=>l.jsx("div",{className:p.cn("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Zi.displayName="DialogHeader";const Ic=({className:e,...t})=>l.jsx("div",{className:p.cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ic.displayName="DialogFooter";const lo=Q.forwardRef(({className:e,...t},n)=>l.jsx(P0,{ref:n,className:p.cn("text-lg font-semibold leading-none tracking-tight",e),...t}));lo.displayName=P0.displayName;const Go=Q.forwardRef(({className:e,...t},n)=>l.jsx(F0,{ref:n,className:p.cn("text-sm text-muted-foreground",e),...t}));Go.displayName=F0.displayName;function Q1(e,t){return`${e.replace(/\/$/,"")}/dashboard-authoring${t}`}function Nxe(e=!0){const{authToken:t,tokenProps:n}=ht();return Dn({queryKey:["dashboard-authoring-sources",n.apiServiceUrl,n.project_id,n.tenantId,n.endUserId,n.orgUserId,t==null?void 0:t.accessToken],enabled:e&&!!(t!=null&&t.accessToken)&&!!n.apiServiceUrl,queryFn:async()=>(await p.getRequest(Q1(n.apiServiceUrl,"/sources"),(t==null?void 0:t.accessToken)||"")).sources||[]})}function kxe(){const{authToken:e,tokenProps:t}=ht(),n=(e==null?void 0:e.accessToken)||"",r=t.apiServiceUrl,s=so({mutationFn:async a=>(await p.postRequestRegular(Q1(r,"/plan"),n,a)).plan}),o=so({mutationFn:async a=>{const c="domainId"in a?{mode:"suggestions",domainId:a.domainId,datasetNames:a.datasetNames,instruction:a.instruction}:{mode:"suggestions",dataset:a.dataset,instruction:a.instruction};return(await p.postRequestRegular(Q1(r,"/plan"),n,c)).suggestions||[]}}),i=so({mutationFn:async a=>{const c="plan"in a?{plan:a.plan,sharing:a.sharing}:{plan:a};return p.postRequestRegular(Q1(r,"/create"),n,{...c})}});return{planDashboard:s,suggestDashboards:o,createDashboardFromPlan:i}}const Jj="__describe_own__",eb=6,_xe=350;function eI(e){return e.kind==="semantic"?e.label||e.datasetName:e.label||[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")||e.tableName}function C$(e){if(e){if(typeof e=="string")return e;if(typeof e=="object"){const t=e;return typeof t.label=="string"&&t.label||typeof t.name=="string"&&t.name||typeof t.qualifiedFieldName=="string"&&t.qualifiedFieldName||void 0}}}function N$(e){return e.kind==="semantic"?{kind:"semantic",domainId:e.domainId,datasetName:e.datasetName,datasetId:e.datasetId,label:e.label,connectionId:e.connectionId}:{kind:"physical",connectionId:e.connectionId,databaseName:e.databaseName,schemaName:e.schemaName,tableName:e.tableName,label:e.label}}function jxe(e){const t=new Map;for(const n of e){if(n.kind!=="semantic")continue;const r=n.domainId;t.has(r)||t.set(r,{id:r,label:n.domainLabel||n.domainName||"Semantic domain",items:[]}),t.get(r).items.push(n)}return Array.from(t.values())}function rw(e){return Array.from(new Set(Array.from(e).map(t=>t.trim()).filter(Boolean)))}function Ixe(e){switch(e){case"kpi":return"KPI";case"line":return"Trend";case"bar":case"stackedBar":return"Breakdown";case"table":return"Table";case"text":return"Text";default:return e?e.replace(/([A-Z])/g," $1"):"Card"}}function Exe(e){return(e==null?void 0:e.kind)==="semantic"?e.datasetName:void 0}function JG(e){var s,o,i,a,c,u,d;const t=e.analyticsIntent,n=new Set,r=f=>{const h=Exe(f);h&&n.add(h)};return t&&(r(t.source),t.kind==="metric"&&((s=t.measures)==null||s.forEach(f=>r(f.source)),r((o=t.primaryMeasure)==null?void 0:o.source),(i=t.dimensions)==null||i.forEach(f=>r(f.source)),r((a=t.dateField)==null?void 0:a.source),(c=t.filters)==null||c.forEach(f=>r(f.field.source))),t.kind==="records"&&((u=t.fields)==null||u.forEach(f=>r(f.source)),r((d=t.dateField)==null?void 0:d.source))),n}function Txe(e){var o;const t=e.sheets.flatMap(i=>i.cards),n=t.filter(i=>i.type!=="text"),r=n.filter(i=>JG(i).size>1),s=((o=e.filterInputs)==null?void 0:o.length)||0;return{cards:t,dataCards:n,joinedCards:r,filterCount:s,datasetCount:e.datasets.length}}function eY({open:e,onOpenChange:t,onCreateBlank:n,onAiCreateSuccess:r,isCreatingBlank:s,sources:o,sourcesLoading:i=!1,suggestDashboards:a,planDashboard:c,createDashboardFromPlan:u,settingsSlot:d,blankDescription:f="",description:h="Start blank, or pick a dataset to see starter ideas tailored to your data.",canCreate:m=!0}){const[g,b]=S.useState("blank"),[x,y]=S.useState(null),[w,v]=S.useState([]),[C,N]=S.useState(!1),[k,_]=S.useState(null),[j,E]=S.useState(""),[I,T]=S.useState(""),[D,R]=S.useState(""),[F,A]=S.useState(""),[U,$]=S.useState(""),[q,W]=S.useState("idle"),[O,Z]=S.useState("choose"),[Y,M]=S.useState(null),K=S.useRef(!1),L=S.useRef(0),[z,B]=S.useState(!1),V=()=>{L.current+=1,Z("choose"),M(null)},P=S.useMemo(()=>o.filter($e=>$e.kind==="semantic"),[o]),H=P.length>0,G=g,X=b,ne=G==="blank",de=G==="dataset",he=i?"Checking datasets...":H?void 0:"No datasets found",pe=S.useMemo(()=>{const $e=new Set;for(const Ue of P)Ue.kind==="semantic"&&$e.add(Ue.domainId);return $e.size===1},[P]),xe=S.useMemo(()=>jxe(P),[P]);S.useEffect(()=>{!x&&pe&&P.length>0&&(y(P[0]),v([P[0].datasetName]))},[x,pe,P]);const se=S.useMemo(()=>!x||x.kind!=="semantic"?[]:P.filter($e=>$e.kind==="semantic"&&$e.domainId===x.domainId),[x,P]);S.useEffect(()=>{if(!x||x.kind!=="semantic"){w.length>0&&v([]),C&&N(!1);return}const $e=new Set(se.map(lt=>lt.datasetName));let Ue=rw(w).filter(lt=>$e.has(lt));C||(Ue=Ue.slice(0,eb)),Ue.length===0&&Ue.push(x.datasetName),Ue.join("|")!==w.join("|")&&v(Ue),se.length<=1&&C&&N(!1)},[w,se,x,C]);const ge=S.useMemo(()=>new Set(w),[w]),ie=S.useMemo(()=>!x||x.kind!=="semantic"?[]:se.filter($e=>ge.has($e.datasetName)),[ge,se,x]),Te=C?se.length:ie.length,re=de&&!!x&&Te>0,me=S.useMemo(()=>C?new Set(se.map($e=>$e.datasetName)):ge,[C,se,ge]),ve=S.useMemo(()=>new Set(se.map($e=>$e.datasetName)),[se]),J=!C&&w.length<eb,ee=re&&!C&&ie.length>1?ie.map($e=>$e.datasetName):void 0,te=S.useMemo(()=>!x||!re?"":x.kind==="semantic"?C?`${x.domainId}:whole`:`${x.domainId}:${ie.map($e=>$e.datasetName).join(",")}`:[x.connectionId,x.databaseName,x.schemaName,x.tableName].filter(Boolean).join(":"),[re,ie,x,C]),[ue,le]=S.useState(te);S.useEffect(()=>{const $e=window.setTimeout(()=>{le(te)},_xe);return()=>window.clearTimeout($e)},[te]);const ke=te===ue;S.useEffect(()=>{e||(X("blank"),y(null),v([]),N(!1),_(null),E(""),T(""),R(""),A(""),$(""),W("idle"),V())},[e,X]);const Se=S.useMemo(()=>{if(!x||!re||!ke)return null;if(x.kind==="semantic"&&(C||ie.length>1))return["dashboard-suggestions","semantic-domain",x.domainId,C?"whole":ie.map($e=>$e.datasetName).join(","),I];if(x.kind==="semantic"){const $e=ie[0]||x;return["dashboard-suggestions","semantic",$e.domainId,$e.datasetName,I]}return["dashboard-suggestions","physical",x.connectionId,x.databaseName,x.schemaName,x.tableName,I]},[I,re,ie,x,ke,C]),oe=S.useMemo(()=>!x||!re||!ke?null:x.kind==="semantic"&&(C||ie.length>1)?{domainId:x.domainId,datasetNames:ee,instruction:I||void 0}:{dataset:N$(ie[0]||x),instruction:I||void 0},[I,re,ee,ie,x,ke,C]),je=Dn({queryKey:Se??["dashboard-suggestions","idle"],queryFn:()=>a(oe),enabled:!!oe&&e,staleTime:5*60*1e3,gcTime:10*60*1e3}),Ne=je.data??null,Oe=(Se==null?void 0:Se.join("|"))??"";S.useEffect(()=>{_(null),V()},[Oe]);const Ge=()=>{!x||!re||(_(null),V(),je.refetch())},Le=S.useMemo(()=>(Ne==null?void 0:Ne.find($e=>$e.id===k))||null,[Ne,k]),Be=(x==null?void 0:x.kind)==="semantic"&&xe.find($e=>$e.id===x.domainId)||null,Ke=(Be==null?void 0:Be.label)||"this domain",Ce=x?C?`All ${se.length} datasets in ${Ke}`:`${Te} of ${se.length} datasets in ${Ke}`:he||"Pick data to see recommendations",Je=$e=>{if($e.kind!=="semantic")return;const Ue=(x==null?void 0:x.kind)==="semantic"&&x.domainId===$e.domainId;y($e),N(!1),v(lt=>Ue&&lt.length>0&&!C?lt.slice(0,eb):[$e.datasetName]),_(null),V(),$("")},Pe=$e=>{if($e.kind!=="semantic")return;const Ue=(x==null?void 0:x.kind)==="semantic"&&x.domainId===$e.domainId;y($e),N(!1),v(lt=>{const Ct=Ue&&!C?lt:[],Nt=new Set(Ct);if(Nt.has($e.datasetName))Nt.delete($e.datasetName);else{if(Nt.size>=eb)return rw(Nt);Nt.add($e.datasetName)}return Nt.size===0&&Nt.add($e.datasetName),rw(Nt)}),_(null),V(),$("")},He=$e=>{const Ue=$e.items[0];Ue&&(y(Ue),v($e.items.map(lt=>lt.datasetName)),N(!0),_(null),V(),$(""))},tt=$e=>{const Ue=se.find(lt=>lt.datasetName===$e);Ue&&(me.has($e)||Pe(Ue))},Ae=j.trim(),Ie=re&&Ae!==I,We=()=>{Ie&&(T(Ae),_(null),V(),$(""))},xt=$e=>{$e.key!=="Enter"||$e.shiftKey||$e.nativeEvent.isComposing||($e.preventDefault(),We())},bt=k===Jj,dt=k!==null&&!bt,vt=D.trim().length>0,st=dt||bt&&vt,Dt=F.trim().length>0,Ee=de&&re&&!C&&ie.length===1,Ze=de&&re&&!st&&!Ee,Qe=ne||de&&!st&&Ee,nt=O==="review"&&!!Y,yt=ne?Dt:de&&re&&(st||Dt&&Ee),Ft=z||c.isPending||u.isPending||s,At=()=>{var Ct;if(!x)return null;const $e=(Le==null?void 0:Le.prompt)||D.trim()||"Create a starter dashboard.",Ue=rw(((Ct=Le==null?void 0:Le.datasets)==null?void 0:Ct.map(Nt=>Nt.name))||[]),lt=x.kind==="semantic"?Ue.length>1?Ue:ee:void 0;return x.kind==="semantic"&&(C||ie.length>1)?{prompt:$e,domainId:x.domainId,datasetNames:lt}:{prompt:$e,dataset:N$(ie[0]||x)}},fn=async()=>{if(K.current||Ft)return;K.current=!0,B(!0),$("");let $e=null;try{if(ne){await n({title:F.trim()||"Untitled dashboard",description:f});return}if(!x)return;if(!st){if(!Ee)return;await n({title:F.trim()||"Untitled dashboard",description:f,dataset:ie[0]||x});return}if(!Y){const Ct=At();if(!Ct)return;const Nt=L.current+1;L.current=Nt,$e=Nt,W("planning");const it=await c.mutateAsync(Ct);if(L.current!==Nt)return;M(it),Z("review");return}const Ue=F.trim()?{...Y,title:F.trim()}:Y;W("validating");const lt=await u.mutateAsync(Ue);r(lt)}catch(Ue){if($e!==null&&L.current!==$e)return;$(p.getRequestErrorMessage(Ue,"The dashboard could not be created from this recommendation."))}finally{K.current=!1,B(!1),W("idle")}};return l.jsx(_o,{open:e,onOpenChange:t,children:l.jsxs(ao,{className:`flex max-w-[94vw] flex-col gap-0 overflow-hidden p-0 transition-[width,height] duration-300 ease-out motion-reduce:transition-none ${de?"h-[720px] max-h-[88vh] w-[1120px]":"h-[440px] w-[520px]"}`,children:[l.jsx("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx(lo,{className:"text-[15px] font-semibold tracking-tight",children:"New dashboard"}),l.jsx(Go,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:de?he||"Pick data on the left, then choose a starter idea.":h})]}),de&&l.jsx("button",{type:"button",onClick:()=>{X("blank"),_(null),R(""),V(),$("")},className:"mr-6 mt-0.5 text-[11px] font-medium text-muted-foreground hover:text-foreground",children:"Start blank instead"})]})}),ne?l.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsx(k$,{kind:"blank",selected:!0,onClick:()=>{X("blank"),_(null),R(""),$("")}}),l.jsx(k$,{kind:"dataset",selected:!1,hint:he,onClick:()=>{X("dataset"),$("")}})]}),l.jsxs("div",{className:"mt-4",children:[l.jsx(_$,{children:"Title"}),l.jsx("input",{type:"text",value:F,onChange:$e=>A($e.target.value),placeholder:"Name your dashboard",className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground focus:border-foreground/40 focus:outline-none"})]}),d?l.jsx("div",{className:"mt-4",children:d}):null]}):l.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[320px_1fr] overflow-hidden",children:[l.jsx(Rxe,{groups:xe,loading:i,selectedSource:x,selectedDatasetNames:ge,useWholeDomain:C,selectionLimit:eb,onPickSource:Je,onToggleDataset:Pe,onUseWholeDomain:He,summary:re?Ce:null}),l.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden",children:[O==="choose"&&l.jsx("div",{className:"shrink-0 border-b border-border px-4 py-3",children:l.jsxs("div",{className:"flex items-end gap-2 rounded-[6px] border border-border bg-background px-3 py-2 focus-within:border-foreground/40",children:[l.jsx("textarea",{rows:2,value:j,onChange:$e=>E($e.target.value),onKeyDown:xt,placeholder:"Add context to steer every idea. e.g. focus on last quarter, use USD, exclude internal accounts.",className:"block flex-1 resize-none bg-transparent text-[12px] leading-[1.55] text-foreground placeholder:text-muted-foreground focus:outline-none"}),l.jsx(p.Button,{type:"button",size:"xs",variant:Ae?"default":"secondary",disabled:!Ie,onClick:We,children:"Update ideas"})]})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-4 border-b border-border px-4 py-2",children:[l.jsx(Mxe,{step:nt?"review":"choose"}),!nt&&l.jsxs("button",{type:"button",onClick:Ge,disabled:!re||Ne===null,className:"ml-auto inline-flex h-6 items-center gap-1 rounded-[3px] px-1.5 text-[10.5px] text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50",children:[l.jsx(Yf,{className:"h-2.5 w-2.5"}),"Suggest more"]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[nt?l.jsx(Axe,{plan:Y,titleOverride:F.trim()}):re?l.jsx("div",{children:Ne===null?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(p.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Fetching recommendations…"]}),l.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:Array.from({length:4}).map(($e,Ue)=>l.jsx(Lxe,{},Ue))})]}):l.jsxs("div",{className:"grid grid-cols-2 gap-2.5",children:[Ne.slice(0,4).map($e=>l.jsx(Pxe,{suggestion:$e,selected:k===$e.id,selectedDatasetNames:me,domainDatasetNames:ve,canAddDataset:J,onAddDataset:tt,onClick:()=>{_(Ue=>Ue===$e.id?null:$e.id),R(""),V(),$("")}},$e.id)),l.jsx(Oxe,{selected:bt,onClick:()=>{_($e=>$e===Jj?null:Jj),V(),$("")}})]})}):l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 text-center",children:[l.jsx(zi,{className:"h-5 w-5 text-muted-foreground"}),l.jsx("div",{className:"mt-2 text-[12.5px] font-medium text-foreground",children:i?"Loading datasets…":"Pick data to see recommendations"}),l.jsx("div",{className:"max-w-[320px] text-[11.5px] leading-relaxed text-muted-foreground",children:"Pick one or more datasets on the left, or All datasets in a domain."})]}),bt&&l.jsx("div",{className:"mt-3 rounded-[5px] border border-border bg-background focus-within:border-foreground/40",children:l.jsx("textarea",{rows:3,autoFocus:!0,value:D,onChange:$e=>{R($e.target.value),V(),$("")},placeholder:"e.g. Executive view with revenue KPIs, weekly trend, and a top-customers table.",className:"block w-full resize-none bg-transparent px-2.5 py-2 text-[12px] leading-[1.55] text-foreground placeholder:text-muted-foreground focus:outline-none"})}),re&&(st||Ee)&&l.jsxs("div",{className:"mt-4",children:[l.jsx(_$,{children:Qe?"Title":"Title (optional)"}),l.jsx("input",{type:"text",value:F,onChange:$e=>A($e.target.value),placeholder:Qe?"Name your dashboard":(Le==null?void 0:Le.title)||"We will suggest one",className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground focus:border-foreground/40 focus:outline-none"})]}),Ze&&l.jsx("div",{className:"mt-4 rounded-[5px] border border-border bg-muted/30 px-3 py-2 text-[11.5px] leading-relaxed text-muted-foreground",children:"Choose a recommendation or describe what you want to create from this data scope."}),U&&l.jsx("div",{className:"mt-4 rounded-[5px] border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11.5px] leading-relaxed text-destructive",children:U}),d?l.jsx("div",{className:"mt-4",children:d}):null]})]})]}),l.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/30 px-5 py-2.5",children:[st&&Ft?l.jsx("span",{className:"text-[11px] text-muted-foreground",children:q==="validating"?"Validating cards against your data.":"This may take up to 30 seconds."}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>t(!1),disabled:Ft,children:"Cancel"}),nt?l.jsx(p.Button,{type:"button",variant:"secondary",size:"xs",onClick:()=>{V(),$("")},disabled:Ft,children:"Back to ideas"}):null,l.jsx(p.Button,{type:"button",size:"xs",disabled:!yt||!m||Ft,onClick:fn,children:Ft?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3 w-3 animate-spin"}),st?q==="planning"?"Planning Insights…":q==="validating"?"Validating cards…":"Building dashboard…":"Creating…"]}):l.jsxs(l.Fragment,{children:[st&&!nt?"Review plan":"Create dashboard",l.jsx(XN,{className:"h-3 w-3"})]})})]})]})]})})}function Dxe({open:e,onOpenChange:t,onCreateBlank:n,onAiCreateSuccess:r,isCreatingBlank:s}){const o=Nxe(e),{suggestDashboards:i,planDashboard:a,createDashboardFromPlan:c}=kxe();return l.jsx(eY,{open:e,onOpenChange:t,onCreateBlank:n,onAiCreateSuccess:r,isCreatingBlank:s,sources:o.data||[],sourcesLoading:o.isLoading,suggestDashboards:i.mutateAsync,planDashboard:a,createDashboardFromPlan:c})}function Mxe({step:e}){const t=[{id:"choose",label:"Choose idea"},{id:"review",label:"Review plan"}],n=t.findIndex(r=>r.id===e);return l.jsx("div",{className:"flex items-center gap-2",children:t.map((r,s)=>{const o=r.id===e,i=s<n;return l.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&l.jsx("span",{className:"h-px w-4 bg-border","aria-hidden":"true"}),l.jsxs("span",{className:`inline-flex h-5 items-center gap-1 rounded-full px-2 text-[10px] font-medium ${o?"bg-foreground text-background":i?"bg-muted text-foreground":"bg-transparent text-muted-foreground"}`,children:[i?l.jsx(p.Check,{className:"h-2.5 w-2.5"}):l.jsx("span",{children:s+1}),r.label]})]},r.id)})})}function Axe({plan:e,titleOverride:t}){const n=Txe(e),r=e.datasets.map(o=>o.kind==="semantic"?o.label||o.datasetName:o.kind==="physical"?o.label||[o.databaseName,o.schemaName,o.tableName].filter(Boolean).join(".")||o.tableName:o.label||"Dataset"),s=[...(e.warnings||[]).map(o=>o.message),...e.unresolvedRequests||[]].filter(Boolean);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:t||e.title||"Dashboard plan"}),e.description&&l.jsx("div",{className:"mt-1 max-w-[680px] text-[11.5px] leading-relaxed text-muted-foreground",children:e.description})]}),l.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[l.jsx(sw,{label:"Cards",value:n.dataCards.length}),l.jsx(sw,{label:"Datasets",value:n.datasetCount}),l.jsx(sw,{label:"Filters",value:n.filterCount}),l.jsx(sw,{label:"Joined cards",value:n.joinedCards.length})]}),l.jsxs("div",{children:[l.jsx("div",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Cards to create"}),l.jsx("div",{className:"divide-y divide-border rounded-[6px] border border-border",children:n.cards.slice(0,Mhe.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS).map(o=>{const i=Array.from(JG(o));return l.jsxs("div",{className:"grid grid-cols-[88px_1fr_auto] items-center gap-2 px-2.5 py-2",children:[l.jsx("span",{className:"rounded-[3px] bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:Ixe(o.type)}),l.jsx("span",{className:"min-w-0 truncate text-[12px] text-foreground",children:o.title}),i.length>0&&l.jsx("span",{className:"max-w-[220px] truncate text-[10.5px] text-muted-foreground",children:i.join(" + ")})]},o.id)})})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsx(tI,{title:"Datasets",empty:"No datasets selected",items:r}),l.jsx(tI,{title:"Filters",empty:"No dashboard filters planned",items:(e.filterInputs||[]).map(o=>o.label)})]}),n.joinedCards.length>0&&l.jsx(tI,{title:"Relationship-based cards",empty:"No relationship-based cards planned",items:n.joinedCards.map(o=>o.title)}),s.length>0&&l.jsx("div",{className:"rounded-[6px] border border-amber-300/60 bg-amber-50/60 px-3 py-2 text-[11.5px] leading-relaxed text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300",children:s.slice(0,3).map(o=>l.jsx("div",{children:o},o))})]})}function sw({label:e,value:t}){return l.jsxs("div",{className:"rounded-[6px] border border-border bg-muted/20 px-2.5 py-2",children:[l.jsx("div",{className:"text-[15px] font-semibold tabular-nums text-foreground",children:t}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:e})]})}function tI({title:e,empty:t,items:n}){return l.jsxs("div",{children:[l.jsx("div",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),l.jsx("div",{className:"min-h-10 rounded-[6px] border border-border px-2.5 py-2 text-[11.5px] leading-relaxed",children:n.length>0?l.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.slice(0,8).map(r=>l.jsx("span",{className:"max-w-full truncate rounded-[3px] bg-muted px-1.5 py-0.5 text-muted-foreground",children:r},r))}):l.jsx("span",{className:"text-muted-foreground",children:t})})]})}function Rxe({groups:e,loading:t,selectedSource:n,selectedDatasetNames:r,useWholeDomain:s,selectionLimit:o,onPickSource:i,onToggleDataset:a,onUseWholeDomain:c,summary:u}){const[d,f]=S.useState(""),[h,m]=S.useState({}),g=d.trim().toLowerCase(),b=(n==null?void 0:n.kind)==="semantic"?n.domainId:null,x=!s&&r.size>=o,y=C=>!g||(C||"").toLowerCase().includes(g),w=e.filter(C=>y(C.label)||C.items.some(N=>y(eI(N)))),v=C=>h[C.id]!==void 0?h[C.id]:g||e.length===1?!0:C.id===b;return l.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden border-r border-border",children:[l.jsxs("div",{className:"shrink-0 border-b border-border px-3 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[l.jsx($s,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("input",{value:d,onChange:C=>f(C.target.value),placeholder:"Search datasets…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),d&&l.jsx("button",{type:"button",onClick:()=>f(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]}),l.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Dashboard scope"}),x&&l.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Max ",o," · clear one to swap"]})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[t&&l.jsxs("div",{className:"flex items-center gap-2 px-1 py-2 text-[11px] text-muted-foreground",children:[l.jsx(p.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Loading datasets…"]}),!t&&w.length===0&&l.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[l.jsx("div",{className:"text-[12px] text-foreground",children:"No datasets found"}),l.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:"Try a different search or connect a semantic domain."})]}),w.map(C=>{const N=v(C),k=C.items.filter(I=>b===C.id&&r.has(I.datasetName)).length,_=b===C.id&&s,j=y(C.label),E=g&&!j?C.items.filter(I=>y(eI(I))):C.items;return l.jsxs("div",{className:"mb-0.5",children:[l.jsxs("div",{className:"flex items-center gap-1.5 rounded-[4px] px-1.5 py-1.5 hover:bg-accent/60",children:[l.jsxs("button",{type:"button",onClick:()=>m(I=>({...I,[C.id]:!N})),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[N?l.jsx(p.ChevronDown,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):l.jsx(Bn,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(zi,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate text-[12px] font-medium text-foreground",children:C.label}),l.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:k>0?`${k}/${C.items.length}`:C.items.length})]}),_?l.jsxs("button",{type:"button",onClick:()=>i(C.items[0]),className:"inline-flex h-5 items-center gap-1 rounded-[3px] bg-foreground px-1.5 text-[10px] font-medium text-background",title:"All datasets in this domain are selected. Click to go back to picking datasets.",children:[l.jsx(T0,{className:"h-2.5 w-2.5"}),"All datasets"]}):l.jsx("button",{type:"button",onClick:()=>c(C),className:"inline-flex h-5 items-center rounded-[3px] border border-border px-1.5 text-[10px] font-medium text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:"Use every dataset in this domain",children:"All datasets"})]}),N&&l.jsx("div",{className:"ml-3.5 border-l border-border pl-1.5",children:E.map(I=>{const T=b===C.id&&r.has(I.datasetName),D=b===C.id&&!s&&!T&&r.size>=o;return l.jsxs("button",{type:"button",onClick:()=>a(I),disabled:D,className:`flex w-full items-center gap-2 rounded-[4px] px-1.5 py-1.5 text-left ${T?"bg-accent":"hover:bg-accent/60"} ${D?"cursor-not-allowed opacity-45 hover:bg-transparent":""}`,children:[l.jsx("span",{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[4px] border ${T?"border-foreground bg-foreground text-background":"border-border"}`,children:T&&l.jsx(p.Check,{className:"h-2.5 w-2.5"})}),l.jsx(p.Table2,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"flex-1 truncate text-[12px] text-foreground/90",children:eI(I)}),C$(I.primaryDateField)&&l.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:C$(I.primaryDateField)})]},`${C.id}:${I.datasetName}`)})})]},C.id)})]}),l.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5 text-[11px] leading-relaxed",children:u?l.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[l.jsx(kpe,{className:"h-3 w-3 shrink-0"}),l.jsx("span",{className:"font-medium text-foreground",children:u})]}):l.jsx("span",{className:"text-muted-foreground",children:"Pick data to see recommendations."})})]})}function Pxe({suggestion:e,selected:t,selectedDatasetNames:n,domainDatasetNames:r,canAddDataset:s,onAddDataset:o,onClick:i}){var a;return l.jsxs("div",{className:`group relative flex flex-col overflow-hidden rounded-[5px] border bg-background transition-colors ${t?"border-foreground":"border-border hover:border-foreground/30"}`,children:[l.jsxs("button",{type:"button",onClick:i,className:"block w-full px-2.5 pt-2.5 pb-1.5 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/40",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",title:e.title,children:e.title}),l.jsx("div",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",title:e.description,children:e.description})]}),t&&l.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-foreground",children:l.jsx(p.Check,{className:"h-2.5 w-2.5 text-background"})})]}),l.jsx("div",{className:"mt-2 flex gap-1",children:e.preview.slice(0,5).map((c,u)=>l.jsx($xe,{kind:c},u))})]}),l.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-2.5 pb-2.5 pt-1.5 text-[10px] text-muted-foreground",children:(a=e.datasets)!=null&&a.length?l.jsx(Fxe,{datasets:e.datasets,relationshipHints:e.relationshipHints,selectedDatasetNames:n,domainDatasetNames:r,canAddDataset:s,onAddDataset:o}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{children:[e.cardCount," cards"]}),e.filterCount>0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border",children:"·"}),l.jsxs("span",{children:[e.filterCount," filter",e.filterCount>1?"s":""]})]})]})})]})}function Fxe({datasets:e,relationshipHints:t,selectedDatasetNames:n,domainDatasetNames:r,canAddDataset:s,onAddDataset:o}){const i=t!=null&&t.length?t.join(`
615
615
  `):e.map(a=>a.label||a.name).join(", ");return l.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",title:i,children:e.map(a=>{const c=n.has(a.name),u=!c&&s&&r.has(a.name),d=a.label||a.name;return u?l.jsxs("button",{type:"button",title:`Add ${d} to your selection`,"aria-label":`Add ${d} to your selection`,onClick:()=>o(a.name),className:"inline-flex max-w-[112px] cursor-pointer items-center gap-0.5 rounded-[3px] border border-amber-400/60 bg-amber-50 px-1.5 py-0.5 text-[9.5px] font-medium text-amber-700 hover:border-amber-500 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-400",children:[l.jsx(kr,{className:"h-2.5 w-2.5 shrink-0"}),l.jsx("span",{className:"truncate",children:d})]},a.name):l.jsx("span",{className:`max-w-[96px] truncate rounded-[3px] border px-1.5 py-0.5 text-[9.5px] ${c?"border-border bg-muted/40 text-muted-foreground":"border-amber-400/50 bg-amber-50/60 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/5 dark:text-amber-400/90"}`,title:c?void 0:`${d} is not in your selection`,children:d},a.name)})})}function k$({kind:e,selected:t,onClick:n,disabled:r=!1,hint:s}){const o=e==="blank"?Cpe:zi,i=e==="blank"?"Blank dashboard":"From a dataset",a=e==="blank"?"Empty canvas. Build it yourself.":"Pick a dataset and we'll suggest starter ideas.";return l.jsxs("button",{type:"button",onClick:n,disabled:r,className:`group relative flex h-full flex-col gap-2 rounded-[5px] border bg-background px-3 py-2.5 text-left transition-colors ${t?"border-foreground":"border-border enabled:hover:border-foreground/30"} disabled:cursor-not-allowed disabled:opacity-60`,title:r&&s?s:void 0,children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-muted/40 text-muted-foreground",children:l.jsx(o,{className:"h-3.5 w-3.5"})}),t&&l.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-foreground",children:l.jsx(p.Check,{className:"h-2.5 w-2.5 text-background"})})]}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:i}),l.jsx("div",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:s||a})]})]})}function Oxe({selected:e,onClick:t}){return l.jsxs("button",{type:"button",onClick:t,className:`group relative flex flex-col overflow-hidden rounded-[5px] border border-dashed bg-background p-2.5 text-left transition-colors ${e?"border-foreground":"border-border hover:border-foreground/40"}`,children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:"Describe what you want"}),l.jsx("div",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:"Tell us the key metrics, breakdowns, and views you want to see."})]}),e&&l.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-foreground",children:l.jsx(p.Check,{className:"h-2.5 w-2.5 text-background"})})]}),l.jsx("div",{className:"mt-2 flex h-[28px] items-center justify-start rounded-[3px] border border-dashed border-border px-2 text-[10px] text-muted-foreground",children:"Metrics, breakdowns, KPIs…"}),l.jsx("div",{className:"mt-1.5 text-[10px] text-muted-foreground",children:"Tailored to what you describe"})]})}function Lxe(){return l.jsxs("div",{className:"rounded-[5px] border border-border p-2.5",children:[l.jsx("div",{className:"h-3 w-32 rounded-[3px] bg-muted/60"}),l.jsx("div",{className:"mt-1 h-2 w-44 rounded-[3px] bg-muted/60"}),l.jsx("div",{className:"mt-2 flex gap-1",children:Array.from({length:4}).map((e,t)=>l.jsx("div",{className:"h-8 w-10 rounded-[3px] bg-muted/60"},t))})]})}function $xe({kind:e}){return l.jsx("div",{className:"flex h-8 w-10 items-center justify-center rounded-[3px] border border-border bg-muted/30",children:l.jsx(zxe,{kind:e})})}function zxe({kind:e}){return e==="kpi"?l.jsx("div",{className:"text-[8px] font-semibold tabular-nums text-foreground/80",children:"1.2M"}):e==="line"?l.jsx("svg",{viewBox:"0 0 40 16",className:"h-3 w-8 text-muted-foreground",children:l.jsx("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"1",points:"0,12 8,10 16,7 24,9 32,4 40,5"})}):e==="bar"?l.jsx("svg",{viewBox:"0 0 40 16",className:"h-3 w-8 text-muted-foreground",children:[6,10,7,12,9].map((t,n)=>l.jsx("rect",{x:n*8+1,y:15-t,width:"5",height:t,fill:"currentColor"},n))}):e==="donut"?l.jsxs("svg",{viewBox:"0 0 16 16",className:"h-3.5 w-3.5",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",strokeWidth:"2.5",className:"stroke-border"}),l.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",strokeWidth:"2.5",strokeDasharray:"22 60",transform:"rotate(-90 8 8)",className:"stroke-muted-foreground"})]}):e==="table"?l.jsxs("div",{className:"space-y-0.5",children:[l.jsx("div",{className:"h-[2px] w-7 rounded-full bg-muted-foreground/60"}),l.jsx("div",{className:"h-[2px] w-7 rounded-full bg-muted-foreground/60"}),l.jsx("div",{className:"h-[2px] w-7 rounded-full bg-muted-foreground/60"}),l.jsx("div",{className:"h-[2px] w-7 rounded-full bg-muted-foreground/60"})]}):null}function _$({children:e}){return l.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})}function tY(){const{authToken:e,tokenProps:t}=ht(),n=t==null?void 0:t.apiServiceUrl,r=t==null?void 0:t.project_id;return Dn({queryKey:["user-preferences",r],queryFn:async()=>{if(!n||!(e!=null&&e.accessToken))return{preference:null};try{return await p.getRequest(`${n}/management/v1/user-preferences`,e.accessToken)}catch(s){return console.error("Error fetching user preferences:",s),{preference:null}}},enabled:!!n&&!!(e!=null&&e.accessToken),staleTime:5*60*1e3,gcTime:10*60*1e3})}var Bxe=Symbol("radix.slottable");function Vxe(e){const t=({children:n})=>l.jsx(l.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Bxe,t}var nY="AlertDialog",[Hxe]=p.createContextScope(nY,[PG]),Ec=PG(),rY=e=>{const{__scopeAlertDialog:t,...n}=e,r=Ec(t);return l.jsx(uk,{...r,...n,modal:!0})};rY.displayName=nY;var Uxe="AlertDialogTrigger",sY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Ec(n);return l.jsx(xP,{...s,...r,ref:t})});sY.displayName=Uxe;var qxe="AlertDialogPortal",oY=e=>{const{__scopeAlertDialog:t,...n}=e,r=Ec(t);return l.jsx(dk,{...r,...n})};oY.displayName=qxe;var Wxe="AlertDialogOverlay",iY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Ec(n);return l.jsx(Kp,{...s,...r,ref:t})});iY.displayName=Wxe;var $m="AlertDialogContent",[Gxe,Yxe]=Hxe($m),Kxe=Vxe("AlertDialogContent"),aY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...s}=e,o=Ec(n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=Q.useRef(null);return l.jsx(yxe,{contentName:$m,titleName:lY,docsSlug:"alert-dialog",children:l.jsx(Gxe,{scope:n,cancelRef:c,children:l.jsxs(Zp,{role:"alertdialog",...o,...s,ref:a,onOpenAutoFocus:p.composeEventHandlers(s.onOpenAutoFocus,u=>{var d;u.preventDefault(),(d=c.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[l.jsx(Kxe,{children:r}),l.jsx(Xxe,{contentRef:i})]})})})});aY.displayName=$m;var lY="AlertDialogTitle",cY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Ec(n);return l.jsx(P0,{...s,...r,ref:t})});cY.displayName=lY;var uY="AlertDialogDescription",dY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Ec(n);return l.jsx(F0,{...s,...r,ref:t})});dY.displayName=uY;var Zxe="AlertDialogAction",fY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=Ec(n);return l.jsx(fk,{...s,...r,ref:t})});fY.displayName=Zxe;var hY="AlertDialogCancel",mY=Q.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:s}=Yxe(hY,n),o=Ec(n),i=p.useComposedRefs(t,s);return l.jsx(fk,{...o,...r,ref:i})});mY.displayName=hY;var Xxe=({contentRef:e})=>{const t=`\`${$m}\` requires a description for the component to be accessible for screen reader users.
616
616
 
617
617
  You can add a description to the \`${$m}\` by passing a \`${uY}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
@@ -720,7 +720,7 @@ object-assign
720
720
  */var iI,P$;function V0e(){if(P$)return iI;P$=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function s(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var i={},a=0;a<10;a++)i["_"+String.fromCharCode(a)]=a;var c=Object.getOwnPropertyNames(i).map(function(d){return i[d]});if(c.join("")!=="0123456789")return!1;var u={};return"abcdefghijklmnopqrst".split("").forEach(function(d){u[d]=d}),Object.keys(Object.assign({},u)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return iI=s()?Object.assign:function(o,i){for(var a,c=r(o),u,d=1;d<arguments.length;d++){a=Object(arguments[d]);for(var f in a)t.call(a,f)&&(c[f]=a[f]);if(e){u=e(a);for(var h=0;h<u.length;h++)n.call(a,u[h])&&(c[u[h]]=a[u[h]])}}return c},iI}var aI,F$;function MP(){if(F$)return aI;F$=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return aI=e,aI}var lI,O$;function eK(){return O$||(O$=1,lI=Function.call.bind(Object.prototype.hasOwnProperty)),lI}var cI,L$;function H0e(){if(L$)return cI;L$=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=MP(),n={},r=eK();e=function(o){var i="Warning: "+o;typeof console<"u"&&console.error(i);try{throw new Error(i)}catch{}}}function s(o,i,a,c,u){if(process.env.NODE_ENV!=="production"){for(var d in o)if(r(o,d)){var f;try{if(typeof o[d]!="function"){var h=Error((c||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw h.name="Invariant Violation",h}f=o[d](i,d,c,a,null,t)}catch(g){f=g}if(f&&!(f instanceof Error)&&e((c||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var m=u?u():"";e("Failed "+a+" type: "+f.message+(m??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},cI=s,cI}var uI,$$;function U0e(){if($$)return uI;$$=1;var e=JY(),t=V0e(),n=MP(),r=eK(),s=H0e(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(a){var c="Warning: "+a;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}});function i(){return null}return uI=function(a,c){var u=typeof Symbol=="function"&&Symbol.iterator,d="@@iterator";function f(O){var Z=O&&(u&&O[u]||O[d]);if(typeof Z=="function")return Z}var h="<<anonymous>>",m={array:y("array"),bigint:y("bigint"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:w(),arrayOf:v,element:C(),elementType:N(),instanceOf:k,node:I(),objectOf:j,oneOf:_,oneOfType:E,shape:D,exact:R};function g(O,Z){return O===Z?O!==0||1/O===1/Z:O!==O&&Z!==Z}function b(O,Z){this.message=O,this.data=Z&&typeof Z=="object"?Z:{},this.stack=""}b.prototype=Error.prototype;function x(O){if(process.env.NODE_ENV!=="production")var Z={},Y=0;function M(L,z,B,V,P,H,G){if(V=V||h,H=H||B,G!==n){if(c){var X=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw X.name="Invariant Violation",X}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ne=V+":"+B;!Z[ne]&&Y<3&&(o("You are manually calling a React.PropTypes validation function for the `"+H+"` prop on `"+V+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),Z[ne]=!0,Y++)}}return z[B]==null?L?z[B]===null?new b("The "+P+" `"+H+"` is marked as required "+("in `"+V+"`, but its value is `null`.")):new b("The "+P+" `"+H+"` is marked as required in "+("`"+V+"`, but its value is `undefined`.")):null:O(z,B,V,P,H)}var K=M.bind(null,!1);return K.isRequired=M.bind(null,!0),K}function y(O){function Z(Y,M,K,L,z,B){var V=Y[M],P=U(V);if(P!==O){var H=$(V);return new b("Invalid "+L+" `"+z+"` of type "+("`"+H+"` supplied to `"+K+"`, expected ")+("`"+O+"`."),{expectedType:O})}return null}return x(Z)}function w(){return x(i)}function v(O){function Z(Y,M,K,L,z){if(typeof O!="function")return new b("Property `"+z+"` of component `"+K+"` has invalid PropType notation inside arrayOf.");var B=Y[M];if(!Array.isArray(B)){var V=U(B);return new b("Invalid "+L+" `"+z+"` of type "+("`"+V+"` supplied to `"+K+"`, expected an array."))}for(var P=0;P<B.length;P++){var H=O(B,P,K,L,z+"["+P+"]",n);if(H instanceof Error)return H}return null}return x(Z)}function C(){function O(Z,Y,M,K,L){var z=Z[Y];if(!a(z)){var B=U(z);return new b("Invalid "+K+" `"+L+"` of type "+("`"+B+"` supplied to `"+M+"`, expected a single ReactElement."))}return null}return x(O)}function N(){function O(Z,Y,M,K,L){var z=Z[Y];if(!e.isValidElementType(z)){var B=U(z);return new b("Invalid "+K+" `"+L+"` of type "+("`"+B+"` supplied to `"+M+"`, expected a single ReactElement type."))}return null}return x(O)}function k(O){function Z(Y,M,K,L,z){if(!(Y[M]instanceof O)){var B=O.name||h,V=W(Y[M]);return new b("Invalid "+L+" `"+z+"` of type "+("`"+V+"` supplied to `"+K+"`, expected ")+("instance of `"+B+"`."))}return null}return x(Z)}function _(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),i;function Z(Y,M,K,L,z){for(var B=Y[M],V=0;V<O.length;V++)if(g(B,O[V]))return null;var P=JSON.stringify(O,function(G,X){var ne=$(X);return ne==="symbol"?String(X):X});return new b("Invalid "+L+" `"+z+"` of value `"+String(B)+"` "+("supplied to `"+K+"`, expected one of "+P+"."))}return x(Z)}function j(O){function Z(Y,M,K,L,z){if(typeof O!="function")return new b("Property `"+z+"` of component `"+K+"` has invalid PropType notation inside objectOf.");var B=Y[M],V=U(B);if(V!=="object")return new b("Invalid "+L+" `"+z+"` of type "+("`"+V+"` supplied to `"+K+"`, expected an object."));for(var P in B)if(r(B,P)){var H=O(B,P,K,L,z+"."+P,n);if(H instanceof Error)return H}return null}return x(Z)}function E(O){if(!Array.isArray(O))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var Z=0;Z<O.length;Z++){var Y=O[Z];if(typeof Y!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+q(Y)+" at index "+Z+"."),i}function M(K,L,z,B,V){for(var P=[],H=0;H<O.length;H++){var G=O[H],X=G(K,L,z,B,V,n);if(X==null)return null;X.data&&r(X.data,"expectedType")&&P.push(X.data.expectedType)}var ne=P.length>0?", expected one of type ["+P.join(", ")+"]":"";return new b("Invalid "+B+" `"+V+"` supplied to "+("`"+z+"`"+ne+"."))}return x(M)}function I(){function O(Z,Y,M,K,L){return F(Z[Y])?null:new b("Invalid "+K+" `"+L+"` supplied to "+("`"+M+"`, expected a ReactNode."))}return x(O)}function T(O,Z,Y,M,K){return new b((O||"React class")+": "+Z+" type `"+Y+"."+M+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+K+"`.")}function D(O){function Z(Y,M,K,L,z){var B=Y[M],V=U(B);if(V!=="object")return new b("Invalid "+L+" `"+z+"` of type `"+V+"` "+("supplied to `"+K+"`, expected `object`."));for(var P in O){var H=O[P];if(typeof H!="function")return T(K,L,z,P,$(H));var G=H(B,P,K,L,z+"."+P,n);if(G)return G}return null}return x(Z)}function R(O){function Z(Y,M,K,L,z){var B=Y[M],V=U(B);if(V!=="object")return new b("Invalid "+L+" `"+z+"` of type `"+V+"` "+("supplied to `"+K+"`, expected `object`."));var P=t({},Y[M],O);for(var H in P){var G=O[H];if(r(O,H)&&typeof G!="function")return T(K,L,z,H,$(G));if(!G)return new b("Invalid "+L+" `"+z+"` key `"+H+"` supplied to `"+K+"`.\nBad object: "+JSON.stringify(Y[M],null," ")+`
721
721
  Valid keys: `+JSON.stringify(Object.keys(O),null," "));var X=G(B,H,K,L,z+"."+H,n);if(X)return X}return null}return x(Z)}function F(O){switch(typeof O){case"number":case"string":case"undefined":return!0;case"boolean":return!O;case"object":if(Array.isArray(O))return O.every(F);if(O===null||a(O))return!0;var Z=f(O);if(Z){var Y=Z.call(O),M;if(Z!==O.entries){for(;!(M=Y.next()).done;)if(!F(M.value))return!1}else for(;!(M=Y.next()).done;){var K=M.value;if(K&&!F(K[1]))return!1}}else return!1;return!0;default:return!1}}function A(O,Z){return O==="symbol"?!0:Z?Z["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&Z instanceof Symbol:!1}function U(O){var Z=typeof O;return Array.isArray(O)?"array":O instanceof RegExp?"object":A(Z,O)?"symbol":Z}function $(O){if(typeof O>"u"||O===null)return""+O;var Z=U(O);if(Z==="object"){if(O instanceof Date)return"date";if(O instanceof RegExp)return"regexp"}return Z}function q(O){var Z=$(O);switch(Z){case"array":case"object":return"an "+Z;case"boolean":case"date":case"regexp":return"a "+Z;default:return Z}}function W(O){return!O.constructor||!O.constructor.name?h:O.constructor.name}return m.checkPropTypes=s,m.resetWarningCache=s.resetWarningCache,m.PropTypes=m,m},uI}var dI,z$;function q0e(){if(z$)return dI;z$=1;var e=MP();function t(){}function n(){}return n.resetWarningCache=t,dI=function(){function r(i,a,c,u,d,f){if(f!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function s(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:s,element:r,elementType:r,instanceOf:s,node:r,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:t};return o.PropTypes=o,o},dI}if(process.env.NODE_ENV!=="production"){var W0e=JY(),G0e=!0;w2.exports=U0e()(W0e.isElement,G0e)}else w2.exports=q0e()();var cd=w2.exports,yk={exports:{}},tK={},Ur={},wl={};Object.defineProperty(wl,"__esModule",{value:!0});wl.dontSetMe=Q0e;wl.findInArray=Y0e;wl.int=X0e;wl.isFunction=K0e;wl.isNum=Z0e;function Y0e(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function K0e(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Function]"}function Z0e(e){return typeof e=="number"&&!isNaN(e)}function X0e(e){return parseInt(e,10)}function Q0e(e,t,n){if(e[t])return new Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var Ih={};Object.defineProperty(Ih,"__esModule",{value:!0});Ih.browserPrefixToKey=rK;Ih.browserPrefixToStyle=J0e;Ih.default=void 0;Ih.getPrefix=nK;const fI=["Moz","Webkit","O","ms"];function nK(){var n,r;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const t=(r=(n=window.document)==null?void 0:n.documentElement)==null?void 0:r.style;if(!t||e in t)return"";for(let s=0;s<fI.length;s++)if(rK(e,fI[s])in t)return fI[s];return""}function rK(e,t){return t?`${t}${eve(e)}`:e}function J0e(e,t){return t?`-${t.toLowerCase()}-${e}`:e}function eve(e){let t="",n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]==="-"?n=!0:t+=e[r];return t}Ih.default=nK();Object.defineProperty(Ur,"__esModule",{value:!0});Ur.addClassName=iK;Ur.addEvent=nve;Ur.addUserSelectStyles=hve;Ur.createCSSTransform=cve;Ur.createSVGTransform=uve;Ur.getTouch=dve;Ur.getTouchIdentifier=fve;Ur.getTranslation=AP;Ur.innerHeight=ive;Ur.innerWidth=ave;Ur.matchesSelector=oK;Ur.matchesSelectorAndParentsTo=tve;Ur.offsetXYFromParent=lve;Ur.outerHeight=sve;Ur.outerWidth=ove;Ur.removeClassName=aK;Ur.removeEvent=rve;Ur.scheduleRemoveUserSelectStyles=mve;var li=wl,B$=sK(Ih);function sK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(sK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}let cw="";function oK(e,t){return cw||(cw=(0,li.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(n){return(0,li.isFunction)(e[n])})),(0,li.isFunction)(e[cw])?e[cw](t):!1}function tve(e,t,n){let r=e;do{if(oK(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function nve(e,t,n,r){if(!e)return;const s={capture:!0,...r};e.addEventListener?e.addEventListener(t,n,s):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n}function rve(e,t,n,r){if(!e)return;const s={capture:!0,...r};e.removeEventListener?e.removeEventListener(t,n,s):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null}function sve(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,li.int)(n.borderTopWidth),t+=(0,li.int)(n.borderBottomWidth),t}function ove(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,li.int)(n.borderLeftWidth),t+=(0,li.int)(n.borderRightWidth),t}function ive(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,li.int)(n.paddingTop),t-=(0,li.int)(n.paddingBottom),t}function ave(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,li.int)(n.paddingLeft),t-=(0,li.int)(n.paddingRight),t}function lve(e,t,n){const s=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),o=(e.clientX+t.scrollLeft-s.left)/n,i=(e.clientY+t.scrollTop-s.top)/n;return{x:o,y:i}}function cve(e,t){const n=AP(e,t,"px");return{[(0,B$.browserPrefixToKey)("transform",B$.default)]:n}}function uve(e,t){return AP(e,t,"")}function AP(e,t,n){let{x:r,y:s}=e,o=`translate(${r}${n},${s}${n})`;if(t){const i=`${typeof t.x=="string"?t.x:t.x+n}`,a=`${typeof t.y=="string"?t.y:t.y+n}`;o=`translate(${i}, ${a})`+o}return o}function dve(e,t){return e.targetTouches&&(0,li.findInArray)(e.targetTouches,n=>t===n.identifier)||e.changedTouches&&(0,li.findInArray)(e.changedTouches,n=>t===n.identifier)}function fve(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function hve(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
722
722
  `,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
723
- `,e.getElementsByTagName("head")[0].appendChild(t)),e.body&&iK(e.body,"react-draggable-transparent-selection")}function mve(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{V$(e)}):V$(e)}function V$(e){if(e)try{if(e.body&&aK(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&t.type!=="Caret"&&t.removeAllRanges()}}catch{}}function iK(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function aK(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp(`(?:^|\\s)${t}(?!\\S)`,"g"),"")}var Sl={};Object.defineProperty(Sl,"__esModule",{value:!0});Sl.canDragX=bve;Sl.canDragY=xve;Sl.createCoreData=vve;Sl.createDraggableData=wve;Sl.getBoundPosition=pve;Sl.getControlPosition=yve;Sl.snapToGrid=gve;var Jo=wl,Tm=Ur;function pve(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r=="string"?r:Sve(r);const s=RP(e);if(typeof r=="string"){const{ownerDocument:o}=s,i=o.defaultView;let a;if(r==="parent"?a=s.parentNode:a=s.getRootNode().querySelector(r),!(a instanceof i.HTMLElement))throw new Error('Bounds selector "'+r+'" could not find an element.');const c=a,u=i.getComputedStyle(s),d=i.getComputedStyle(c);r={left:-s.offsetLeft+(0,Jo.int)(d.paddingLeft)+(0,Jo.int)(u.marginLeft),top:-s.offsetTop+(0,Jo.int)(d.paddingTop)+(0,Jo.int)(u.marginTop),right:(0,Tm.innerWidth)(c)-(0,Tm.outerWidth)(s)-s.offsetLeft+(0,Jo.int)(d.paddingRight)-(0,Jo.int)(u.marginRight),bottom:(0,Tm.innerHeight)(c)-(0,Tm.outerHeight)(s)-s.offsetTop+(0,Jo.int)(d.paddingBottom)-(0,Jo.int)(u.marginBottom)}}return(0,Jo.isNum)(r.right)&&(t=Math.min(t,r.right)),(0,Jo.isNum)(r.bottom)&&(n=Math.min(n,r.bottom)),(0,Jo.isNum)(r.left)&&(t=Math.max(t,r.left)),(0,Jo.isNum)(r.top)&&(n=Math.max(n,r.top)),[t,n]}function gve(e,t,n){const r=Math.round(t/e[0])*e[0],s=Math.round(n/e[1])*e[1];return[r,s]}function bve(e){return e.props.axis==="both"||e.props.axis==="x"}function xve(e){return e.props.axis==="both"||e.props.axis==="y"}function yve(e,t,n){const r=typeof t=="number"?(0,Tm.getTouch)(e,t):null;if(typeof t=="number"&&!r)return null;const s=RP(n),o=n.props.offsetParent||s.offsetParent||s.ownerDocument.body;return(0,Tm.offsetXYFromParent)(r||e,o,n.props.scale)}function vve(e,t,n){const r=!(0,Jo.isNum)(e.lastX),s=RP(e);return r?{node:s,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:s,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function wve(e,t){const n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Sve(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function RP(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}var vk={},wk={};Object.defineProperty(wk,"__esModule",{value:!0});wk.default=Cve;function Cve(){}Object.defineProperty(vk,"__esModule",{value:!0});vk.default=void 0;var hI=lK(S),uo=PP(cd),Nve=PP(gr),Us=Ur,Vc=Sl,mI=wl,nb=PP(wk);function PP(e){return e&&e.__esModule?e:{default:e}}function lK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(lK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function go(e,t,n){return(t=kve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kve(e){var t=_ve(e,"string");return typeof t=="symbol"?t:t+""}function _ve(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const sa={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let Hc=sa.mouse,Sk=class extends hI.Component{constructor(){super(...arguments),go(this,"dragging",!1),go(this,"lastX",NaN),go(this,"lastY",NaN),go(this,"touchIdentifier",null),go(this,"mounted",!1),go(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&typeof t.button=="number"&&t.button!==0)return!1;const n=this.findDOMNode();if(!n||!n.ownerDocument||!n.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=n;if(this.props.disabled||!(t.target instanceof r.defaultView.Node)||this.props.handle&&!(0,Us.matchesSelectorAndParentsTo)(t.target,this.props.handle,n)||this.props.cancel&&(0,Us.matchesSelectorAndParentsTo)(t.target,this.props.cancel,n))return;t.type==="touchstart"&&!this.props.allowMobileScroll&&t.preventDefault();const s=(0,Us.getTouchIdentifier)(t);this.touchIdentifier=s;const o=(0,Vc.getControlPosition)(t,s,this);if(o==null)return;const{x:i,y:a}=o,c=(0,Vc.createCoreData)(this,i,a);(0,nb.default)("DraggableCore: handleDragStart: %j",c),(0,nb.default)("calling",this.props.onStart),!(this.props.onStart(t,c)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,Us.addUserSelectStyles)(r),this.dragging=!0,this.lastX=i,this.lastY=a,(0,Us.addEvent)(r,Hc.move,this.handleDrag),(0,Us.addEvent)(r,Hc.stop,this.handleDragStop))}),go(this,"handleDrag",t=>{const n=(0,Vc.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:s}=n;if(Array.isArray(this.props.grid)){let a=r-this.lastX,c=s-this.lastY;if([a,c]=(0,Vc.snapToGrid)(this.props.grid,a,c),!a&&!c)return;r=this.lastX+a,s=this.lastY+c}const o=(0,Vc.createCoreData)(this,r,s);if((0,nb.default)("DraggableCore: handleDrag: %j",o),this.props.onDrag(t,o)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const c=document.createEvent("MouseEvents");c.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(c)}return}this.lastX=r,this.lastY=s}),go(this,"handleDragStop",t=>{if(!this.dragging)return;const n=(0,Vc.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:s}=n;if(Array.isArray(this.props.grid)){let c=r-this.lastX||0,u=s-this.lastY||0;[c,u]=(0,Vc.snapToGrid)(this.props.grid,c,u),r=this.lastX+c,s=this.lastY+u}const o=(0,Vc.createCoreData)(this,r,s);if(this.props.onStop(t,o)===!1||this.mounted===!1)return!1;const a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,Us.scheduleRemoveUserSelectStyles)(a.ownerDocument),(0,nb.default)("DraggableCore: handleDragStop: %j",o),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,nb.default)("DraggableCore: Removing handlers"),(0,Us.removeEvent)(a.ownerDocument,Hc.move,this.handleDrag),(0,Us.removeEvent)(a.ownerDocument,Hc.stop,this.handleDragStop))}),go(this,"onMouseDown",t=>(Hc=sa.mouse,this.handleDragStart(t))),go(this,"onMouseUp",t=>(Hc=sa.mouse,this.handleDragStop(t))),go(this,"onTouchStart",t=>(Hc=sa.touch,this.handleDragStart(t))),go(this,"onTouchEnd",t=>(Hc=sa.touch,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;const t=this.findDOMNode();t&&(0,Us.addEvent)(t,sa.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const t=this.findDOMNode();if(t){const{ownerDocument:n}=t;(0,Us.removeEvent)(n,sa.mouse.move,this.handleDrag),(0,Us.removeEvent)(n,sa.touch.move,this.handleDrag),(0,Us.removeEvent)(n,sa.mouse.stop,this.handleDragStop),(0,Us.removeEvent)(n,sa.touch.stop,this.handleDragStop),(0,Us.removeEvent)(t,sa.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,Us.scheduleRemoveUserSelectStyles)(n)}}findDOMNode(){var t,n,r;return(t=this.props)!=null&&t.nodeRef?(r=(n=this.props)==null?void 0:n.nodeRef)==null?void 0:r.current:Nve.default.findDOMNode(this)}render(){return hI.cloneElement(hI.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};vk.default=Sk;go(Sk,"displayName","DraggableCore");go(Sk,"propTypes",{allowAnyClick:uo.default.bool,allowMobileScroll:uo.default.bool,children:uo.default.node.isRequired,disabled:uo.default.bool,enableUserSelectHack:uo.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:uo.default.arrayOf(uo.default.number),handle:uo.default.string,cancel:uo.default.string,nodeRef:uo.default.object,onStart:uo.default.func,onDrag:uo.default.func,onStop:uo.default.func,onMouseDown:uo.default.func,scale:uo.default.number,className:mI.dontSetMe,style:mI.dontSetMe,transform:mI.dontSetMe});go(Sk,"defaultProps",{allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1});(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return c.default}}),e.default=void 0;var t=f(S),n=d(cd),r=d(gr),s=pk,o=Ur,i=Sl,a=wl,c=d(vk),u=d(wk);function d(y){return y&&y.__esModule?y:{default:y}}function f(y,w){if(typeof WeakMap=="function")var v=new WeakMap,C=new WeakMap;return(f=function(N,k){if(!k&&N&&N.__esModule)return N;var _,j,E={__proto__:null,default:N};if(N===null||typeof N!="object"&&typeof N!="function")return E;if(_=k?C:v){if(_.has(N))return _.get(N);_.set(N,E)}for(const I in N)I!=="default"&&{}.hasOwnProperty.call(N,I)&&((j=(_=Object.defineProperty)&&Object.getOwnPropertyDescriptor(N,I))&&(j.get||j.set)?_(E,I,j):E[I]=N[I]);return E})(y,w)}function h(){return h=Object.assign?Object.assign.bind():function(y){for(var w=1;w<arguments.length;w++){var v=arguments[w];for(var C in v)({}).hasOwnProperty.call(v,C)&&(y[C]=v[C])}return y},h.apply(null,arguments)}function m(y,w,v){return(w=g(w))in y?Object.defineProperty(y,w,{value:v,enumerable:!0,configurable:!0,writable:!0}):y[w]=v,y}function g(y){var w=b(y,"string");return typeof w=="symbol"?w:w+""}function b(y,w){if(typeof y!="object"||!y)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var C=v.call(y,w);if(typeof C!="object")return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return(w==="string"?String:Number)(y)}class x extends t.Component{static getDerivedStateFromProps(w,v){let{position:C}=w,{prevPropsPosition:N}=v;return C&&(!N||C.x!==N.x||C.y!==N.y)?((0,u.default)("Draggable: getDerivedStateFromProps %j",{position:C,prevPropsPosition:N}),{x:C.x,y:C.y,prevPropsPosition:{...C}}):null}constructor(w){super(w),m(this,"onDragStart",(v,C)=>{if((0,u.default)("Draggable: onDragStart: %j",C),this.props.onStart(v,(0,i.createDraggableData)(this,C))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),m(this,"onDrag",(v,C)=>{if(!this.state.dragging)return!1;(0,u.default)("Draggable: onDrag: %j",C);const N=(0,i.createDraggableData)(this,C),k={x:N.x,y:N.y,slackX:0,slackY:0};if(this.props.bounds){const{x:j,y:E}=k;k.x+=this.state.slackX,k.y+=this.state.slackY;const[I,T]=(0,i.getBoundPosition)(this,k.x,k.y);k.x=I,k.y=T,k.slackX=this.state.slackX+(j-k.x),k.slackY=this.state.slackY+(E-k.y),N.x=k.x,N.y=k.y,N.deltaX=k.x-this.state.x,N.deltaY=k.y-this.state.y}if(this.props.onDrag(v,N)===!1)return!1;this.setState(k)}),m(this,"onDragStop",(v,C)=>{if(!this.state.dragging||this.props.onStop(v,(0,i.createDraggableData)(this,C))===!1)return!1;(0,u.default)("Draggable: onDragStop: %j",C);const k={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:j,y:E}=this.props.position;k.x=j,k.y=E}this.setState(k)}),this.state={dragging:!1,dragged:!1,x:w.position?w.position.x:w.defaultPosition.x,y:w.position?w.position.y:w.defaultPosition.y,prevPropsPosition:{...w.position},slackX:0,slackY:0,isElementSVG:!1},w.position&&!(w.onDrag||w.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){var w,v;return((v=(w=this.props)==null?void 0:w.nodeRef)==null?void 0:v.current)??r.default.findDOMNode(this)}render(){const{axis:w,bounds:v,children:C,defaultPosition:N,defaultClassName:k,defaultClassNameDragging:_,defaultClassNameDragged:j,position:E,positionOffset:I,scale:T,...D}=this.props;let R={},F=null;const U=!!!E||this.state.dragging,$=E||N,q={x:(0,i.canDragX)(this)&&U?this.state.x:$.x,y:(0,i.canDragY)(this)&&U?this.state.y:$.y};this.state.isElementSVG?F=(0,o.createSVGTransform)(q,I):R=(0,o.createCSSTransform)(q,I);const W=(0,s.clsx)(C.props.className||"",k,{[_]:this.state.dragging,[j]:this.state.dragged});return t.createElement(c.default,h({},D,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(C),{className:W,style:{...C.props.style,...R},transform:F}))}}e.default=x,m(x,"displayName","Draggable"),m(x,"propTypes",{...c.default.propTypes,axis:n.default.oneOf(["both","x","y","none"]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),m(x,"defaultProps",{...c.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})})(tK);const{default:cK,DraggableCore:jve}=tK;yk.exports=cK;yk.exports.default=cK;yk.exports.DraggableCore=jve;var uK=yk.exports,Ck={exports:{}},$0={},FP={};FP.__esModule=!0;FP.cloneElement=Ave;var Ive=Eve(S);function Eve(e){return e&&e.__esModule?e:{default:e}}function H$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function U$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?H$(Object(n),!0).forEach(function(r){Tve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Tve(e,t,n){return t=Dve(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dve(e){var t=Mve(e,"string");return typeof t=="symbol"?t:String(t)}function Mve(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ave(e,t){return t.style&&e.props.style&&(t.style=U$(U$({},e.props.style),t.style)),t.className&&e.props.className&&(t.className=e.props.className+" "+t.className),Ive.default.cloneElement(e,t)}var z0={};z0.__esModule=!0;z0.resizableProps=void 0;var rn=Rve(cd);function Rve(e){return e&&e.__esModule?e:{default:e}}var Pve={axis:rn.default.oneOf(["both","x","y","none"]),className:rn.default.string,children:rn.default.element.isRequired,draggableOpts:rn.default.shape({allowAnyClick:rn.default.bool,cancel:rn.default.string,children:rn.default.node,disabled:rn.default.bool,enableUserSelectHack:rn.default.bool,offsetParent:rn.default.node,grid:rn.default.arrayOf(rn.default.number),handle:rn.default.string,nodeRef:rn.default.object,onStart:rn.default.func,onDrag:rn.default.func,onStop:rn.default.func,onMouseDown:rn.default.func,scale:rn.default.number}),height:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var s=n[0];if(s.axis==="both"||s.axis==="y"){var o;return(o=rn.default.number).isRequired.apply(o,n)}return rn.default.number.apply(rn.default,n)},handle:rn.default.oneOfType([rn.default.node,rn.default.func]),handleSize:rn.default.arrayOf(rn.default.number),lockAspectRatio:rn.default.bool,maxConstraints:rn.default.arrayOf(rn.default.number),minConstraints:rn.default.arrayOf(rn.default.number),onResizeStop:rn.default.func,onResizeStart:rn.default.func,onResize:rn.default.func,resizeHandles:rn.default.arrayOf(rn.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:rn.default.number,width:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var s=n[0];if(s.axis==="both"||s.axis==="x"){var o;return(o=rn.default.number).isRequired.apply(o,n)}return rn.default.number.apply(rn.default,n)}};z0.resizableProps=Pve;$0.__esModule=!0;$0.default=void 0;var rb=zve(S),Fve=uK,Ove=FP,Lve=z0,$ve=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function dK(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(dK=function(s){return s?n:t})(e)}function zve(e,t){if(e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=dK(t);if(n&&n.has(e))return n.get(e);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(o!=="default"&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function S2(){return S2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S2.apply(this,arguments)}function Bve(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function q$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function pI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?q$(Object(n),!0).forEach(function(r){Vve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Vve(e,t,n){return t=Hve(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hve(e){var t=Uve(e,"string");return typeof t=="symbol"?t:String(t)}function Uve(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qve(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,C2(e,t)}function C2(e,t){return C2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},C2(e,t)}var OP=function(e){qve(t,e);function t(){for(var r,s=arguments.length,o=new Array(s),i=0;i<s;i++)o[i]=arguments[i];return r=e.call.apply(e,[this].concat(o))||this,r.handleRefs={},r.lastHandleRect=null,r.slack=null,r}var n=t.prototype;return n.componentWillUnmount=function(){this.resetData()},n.resetData=function(){this.lastHandleRect=this.slack=null},n.runConstraints=function(s,o){var i=this.props,a=i.minConstraints,c=i.maxConstraints,u=i.lockAspectRatio;if(!a&&!c&&!u)return[s,o];if(u){var d=this.props.width/this.props.height,f=s-this.props.width,h=o-this.props.height;Math.abs(f)>Math.abs(h*d)?o=s/d:s=o*d}var m=s,g=o,b=this.slack||[0,0],x=b[0],y=b[1];return s+=x,o+=y,a&&(s=Math.max(a[0],s),o=Math.max(a[1],o)),c&&(s=Math.min(c[0],s),o=Math.min(c[1],o)),this.slack=[x+(m-s),y+(g-o)],[s,o]},n.resizeHandler=function(s,o){var i=this;return function(a,c){var u=c.node,d=c.deltaX,f=c.deltaY;s==="onResizeStart"&&i.resetData();var h=(i.props.axis==="both"||i.props.axis==="x")&&o!=="n"&&o!=="s",m=(i.props.axis==="both"||i.props.axis==="y")&&o!=="e"&&o!=="w";if(!(!h&&!m)){var g=o[0],b=o[o.length-1],x=u.getBoundingClientRect();if(i.lastHandleRect!=null){if(b==="w"){var y=x.left-i.lastHandleRect.left;d+=y}if(g==="n"){var w=x.top-i.lastHandleRect.top;f+=w}}i.lastHandleRect=x,b==="w"&&(d=-d),g==="n"&&(f=-f);var v=i.props.width+(h?d/i.props.transformScale:0),C=i.props.height+(m?f/i.props.transformScale:0),N=i.runConstraints(v,C);v=N[0],C=N[1];var k=v!==i.props.width||C!==i.props.height,_=typeof i.props[s]=="function"?i.props[s]:null,j=s==="onResize"&&!k;_&&!j&&(a.persist==null||a.persist(),_(a,{node:u,size:{width:v,height:C},handle:o})),s==="onResizeStop"&&i.resetData()}}},n.renderResizeHandle=function(s,o){var i=this.props.handle;if(!i)return rb.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+s,ref:o});if(typeof i=="function")return i(s,o);var a=typeof i.type=="string",c=pI({ref:o},a?{}:{handleAxis:s});return rb.cloneElement(i,c)},n.render=function(){var s=this,o=this.props,i=o.children,a=o.className,c=o.draggableOpts;o.width,o.height,o.handle,o.handleSize,o.lockAspectRatio,o.axis,o.minConstraints,o.maxConstraints,o.onResize,o.onResizeStop,o.onResizeStart;var u=o.resizeHandles;o.transformScale;var d=Bve(o,$ve);return(0,Ove.cloneElement)(i,pI(pI({},d),{},{className:(a?a+" ":"")+"react-resizable",children:[].concat(i.props.children,u.map(function(f){var h,m=(h=s.handleRefs[f])!=null?h:s.handleRefs[f]=rb.createRef();return rb.createElement(Fve.DraggableCore,S2({},c,{nodeRef:m,key:"resizableHandle-"+f,onStop:s.resizeHandler("onResizeStop",f),onStart:s.resizeHandler("onResizeStart",f),onDrag:s.resizeHandler("onResize",f)}),s.renderResizeHandle(f,m))}))}))},t}(rb.Component);$0.default=OP;OP.propTypes=Lve.resizableProps;OP.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1};var Nk={};Nk.__esModule=!0;Nk.default=void 0;var gI=Zve(S),Wve=fK(cd),Gve=fK($0),Yve=z0,Kve=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function fK(e){return e&&e.__esModule?e:{default:e}}function hK(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(hK=function(s){return s?n:t})(e)}function Zve(e,t){if(e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=hK(t);if(n&&n.has(e))return n.get(e);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(o!=="default"&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function N2(){return N2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},N2.apply(this,arguments)}function W$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function JS(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?W$(Object(n),!0).forEach(function(r){Xve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Xve(e,t,n){return t=Qve(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qve(e){var t=Jve(e,"string");return typeof t=="symbol"?t:String(t)}function Jve(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ewe(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function twe(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,k2(e,t)}function k2(e,t){return k2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},k2(e,t)}var mK=function(e){twe(t,e);function t(){for(var r,s=arguments.length,o=new Array(s),i=0;i<s;i++)o[i]=arguments[i];return r=e.call.apply(e,[this].concat(o))||this,r.state={width:r.props.width,height:r.props.height,propsWidth:r.props.width,propsHeight:r.props.height},r.onResize=function(a,c){var u=c.size;r.props.onResize?(a.persist==null||a.persist(),r.setState(u,function(){return r.props.onResize&&r.props.onResize(a,c)})):r.setState(u)},r}t.getDerivedStateFromProps=function(s,o){return o.propsWidth!==s.width||o.propsHeight!==s.height?{width:s.width,height:s.height,propsWidth:s.width,propsHeight:s.height}:null};var n=t.prototype;return n.render=function(){var s=this.props,o=s.handle,i=s.handleSize;s.onResize;var a=s.onResizeStart,c=s.onResizeStop,u=s.draggableOpts,d=s.minConstraints,f=s.maxConstraints,h=s.lockAspectRatio,m=s.axis;s.width,s.height;var g=s.resizeHandles,b=s.style,x=s.transformScale,y=ewe(s,Kve);return gI.createElement(Gve.default,{axis:m,draggableOpts:u,handle:o,handleSize:i,height:this.state.height,lockAspectRatio:h,maxConstraints:f,minConstraints:d,onResizeStart:a,onResize:this.onResize,onResizeStop:c,resizeHandles:g,transformScale:x,width:this.state.width},gI.createElement("div",N2({},y,{style:JS(JS({},b),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},t}(gI.Component);Nk.default=mK;mK.propTypes=JS(JS({},Yve.resizableProps),{},{children:Wve.default.element});Ck.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")};Ck.exports.Resizable=$0.default;Ck.exports.ResizableBox=Nk.default;var nwe=Ck.exports,uc={};Object.defineProperty(uc,"__esModule",{value:!0});uc.resizeHandleType=uc.resizeHandleAxesType=uc.default=void 0;var ln=pK(cd),rwe=pK(S);function pK(e){return e&&e.__esModule?e:{default:e}}const swe=uc.resizeHandleAxesType=ln.default.arrayOf(ln.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),owe=uc.resizeHandleType=ln.default.oneOfType([ln.default.node,ln.default.func]);uc.default={className:ln.default.string,style:ln.default.object,width:ln.default.number,autoSize:ln.default.bool,cols:ln.default.number,draggableCancel:ln.default.string,draggableHandle:ln.default.string,verticalCompact:function(e){e.verticalCompact===!1&&process.env.NODE_ENV!=="production"&&console.warn('`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. Use `compactType`: "horizontal" | "vertical" | null.')},compactType:ln.default.oneOf(["vertical","horizontal"]),layout:function(e){var t=e.layout;t!==void 0&&bn.validateLayout(t,"layout")},margin:ln.default.arrayOf(ln.default.number),containerPadding:ln.default.arrayOf(ln.default.number),rowHeight:ln.default.number,maxRows:ln.default.number,isBounded:ln.default.bool,isDraggable:ln.default.bool,isResizable:ln.default.bool,allowOverlap:ln.default.bool,preventCollision:ln.default.bool,useCSSTransforms:ln.default.bool,transformScale:ln.default.number,isDroppable:ln.default.bool,resizeHandles:swe,resizeHandle:owe,onLayoutChange:ln.default.func,onDragStart:ln.default.func,onDrag:ln.default.func,onDragStop:ln.default.func,onResizeStart:ln.default.func,onResize:ln.default.func,onResizeStop:ln.default.func,onDrop:ln.default.func,droppingItem:ln.default.shape({i:ln.default.string.isRequired,w:ln.default.number.isRequired,h:ln.default.number.isRequired}),children:function(e,t){const n=e[t],r={};rwe.default.Children.forEach(n,function(s){if((s==null?void 0:s.key)!=null){if(r[s.key])throw new Error('Duplicate child key "'+s.key+'" found! This will cause problems in ReactGridLayout.');r[s.key]=!0}})},innerRef:ln.default.any};Object.defineProperty(xk,"__esModule",{value:!0});xk.default=void 0;var Yh=LP(S),G$=gr,zn=LP(cd),iwe=uK,awe=nwe,Kh=bn,js=vl,Y$=uc,lwe=LP(pk);function LP(e){return e&&e.__esModule?e:{default:e}}function za(e,t,n){return(t=cwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cwe(e){var t=uwe(e,"string");return typeof t=="symbol"?t:t+""}function uwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class $P extends Yh.default.Component{constructor(){super(...arguments),za(this,"state",{resizing:null,dragging:null,className:""}),za(this,"elementRef",Yh.default.createRef()),za(this,"onDragStart",(t,n)=>{let{node:r}=n;const{onDragStart:s,transformScale:o}=this.props;if(!s)return;const i={top:0,left:0},{offsetParent:a}=r;if(!a)return;const c=a.getBoundingClientRect(),u=r.getBoundingClientRect(),d=u.left/o,f=c.left/o,h=u.top/o,m=c.top/o;i.left=d-f+a.scrollLeft,i.top=h-m+a.scrollTop,this.setState({dragging:i});const{x:g,y:b}=(0,js.calcXY)(this.getPositionParams(),i.top,i.left,this.props.w,this.props.h);return s.call(this,this.props.i,g,b,{e:t,node:r,newPosition:i})}),za(this,"onDrag",(t,n,r)=>{let{node:s,deltaX:o,deltaY:i}=n;const{onDrag:a}=this.props;if(!a)return;if(!this.state.dragging)throw new Error("onDrag called before onDragStart.");let c=this.state.dragging.top+i,u=this.state.dragging.left+o;const{isBounded:d,i:f,w:h,h:m,containerWidth:g}=this.props,b=this.getPositionParams();if(d){const{offsetParent:v}=s;if(v){const{margin:C,rowHeight:N}=this.props,k=v.clientHeight-(0,js.calcGridItemWHPx)(m,N,C[1]);c=(0,js.clamp)(c,0,k);const _=(0,js.calcGridColWidth)(b),j=g-(0,js.calcGridItemWHPx)(h,_,C[0]);u=(0,js.clamp)(u,0,j)}}const x={top:c,left:u};r?this.setState({dragging:x}):(0,G$.flushSync)(()=>{this.setState({dragging:x})});const{x:y,y:w}=(0,js.calcXY)(b,c,u,h,m);return a.call(this,f,y,w,{e:t,node:s,newPosition:x})}),za(this,"onDragStop",(t,n)=>{let{node:r}=n;const{onDragStop:s}=this.props;if(!s)return;if(!this.state.dragging)throw new Error("onDragEnd called before onDragStart.");const{w:o,h:i,i:a}=this.props,{left:c,top:u}=this.state.dragging,d={top:u,left:c};this.setState({dragging:null});const{x:f,y:h}=(0,js.calcXY)(this.getPositionParams(),u,c,o,i);return s.call(this,a,f,h,{e:t,node:r,newPosition:d})}),za(this,"onResizeStop",(t,n,r)=>this.onResizeHandler(t,n,r,"onResizeStop")),za(this,"onResizeStart",(t,n,r)=>this.onResizeHandler(t,n,r,"onResizeStart")),za(this,"onResize",(t,n,r)=>this.onResizeHandler(t,n,r,"onResize"))}shouldComponentUpdate(t,n){if(this.props.children!==t.children||this.props.droppingPosition!==t.droppingPosition)return!0;const r=(0,js.calcGridItemPosition)(this.getPositionParams(this.props),this.props.x,this.props.y,this.props.w,this.props.h,this.state),s=(0,js.calcGridItemPosition)(this.getPositionParams(t),t.x,t.y,t.w,t.h,n);return!(0,Kh.fastPositionEqual)(r,s)||this.props.useCSSTransforms!==t.useCSSTransforms}componentDidMount(){this.moveDroppingItem({})}componentDidUpdate(t){this.moveDroppingItem(t)}moveDroppingItem(t){const{droppingPosition:n}=this.props;if(!n)return;const r=this.elementRef.current;if(!r)return;const s=t.droppingPosition||{left:0,top:0},{dragging:o}=this.state,i=o&&n.left!==s.left||n.top!==s.top;if(!o)this.onDragStart(n.e,{node:r,deltaX:n.left,deltaY:n.top});else if(i){const a=n.left-o.left,c=n.top-o.top;this.onDrag(n.e,{node:r,deltaX:a,deltaY:c},!0)}}getPositionParams(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return{cols:t.cols,containerPadding:t.containerPadding,containerWidth:t.containerWidth,margin:t.margin,maxRows:t.maxRows,rowHeight:t.rowHeight}}createStyle(t){const{usePercentages:n,containerWidth:r,useCSSTransforms:s}=this.props;let o;return s?o=(0,Kh.setTransform)(t):(o=(0,Kh.setTopLeft)(t),n&&(o.left=(0,Kh.perc)(t.left/r),o.width=(0,Kh.perc)(t.width/r))),o}mixinDraggable(t,n){return Yh.default.createElement(iwe.DraggableCore,{disabled:!n,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,handle:this.props.handle,cancel:".react-resizable-handle"+(this.props.cancel?","+this.props.cancel:""),scale:this.props.transformScale,nodeRef:this.elementRef},t)}curryResizeHandler(t,n){return(r,s)=>n(r,s,t)}mixinResizable(t,n,r){const{cols:s,minW:o,minH:i,maxW:a,maxH:c,transformScale:u,resizeHandles:d,resizeHandle:f}=this.props,h=this.getPositionParams(),m=(0,js.calcGridItemPosition)(h,0,0,s,0).width,g=(0,js.calcGridItemPosition)(h,0,0,o,i),b=(0,js.calcGridItemPosition)(h,0,0,a,c),x=[g.width,g.height],y=[Math.min(b.width,m),Math.min(b.height,1/0)];return Yh.default.createElement(awe.Resizable,{draggableOpts:{disabled:!r},className:r?void 0:"react-resizable-hide",width:n.width,height:n.height,minConstraints:x,maxConstraints:y,onResizeStop:this.curryResizeHandler(n,this.onResizeStop),onResizeStart:this.curryResizeHandler(n,this.onResizeStart),onResize:this.curryResizeHandler(n,this.onResize),transformScale:u,resizeHandles:d,handle:f},t)}onResizeHandler(t,n,r,s){let{node:o,size:i,handle:a}=n;const c=this.props[s];if(!c)return;const{x:u,y:d,i:f,maxH:h,minH:m,containerWidth:g}=this.props,{minW:b,maxW:x}=this.props;let y=i;o&&(y=(0,Kh.resizeItemInDirection)(a,r,i,g),(0,G$.flushSync)(()=>{this.setState({resizing:s==="onResizeStop"?null:y})}));let{w,h:v}=(0,js.calcWH)(this.getPositionParams(),y.width,y.height,u,d,a);w=(0,js.clamp)(w,Math.max(b,1),x),v=(0,js.clamp)(v,m,h),c.call(this,f,w,v,{e:t,node:o,size:y,handle:a})}render(){const{x:t,y:n,w:r,h:s,isDraggable:o,isResizable:i,droppingPosition:a,useCSSTransforms:c}=this.props,u=(0,js.calcGridItemPosition)(this.getPositionParams(),t,n,r,s,this.state),d=Yh.default.Children.only(this.props.children);let f=Yh.default.cloneElement(d,{ref:this.elementRef,className:(0,lwe.default)("react-grid-item",d.props.className,this.props.className,{static:this.props.static,resizing:!!this.state.resizing,"react-draggable":o,"react-draggable-dragging":!!this.state.dragging,dropping:!!a,cssTransforms:c}),style:{...this.props.style,...d.props.style,...this.createStyle(u)}});return f=this.mixinResizable(f,u,i),f=this.mixinDraggable(f,o),f}}xk.default=$P;za($P,"propTypes",{children:zn.default.element,cols:zn.default.number.isRequired,containerWidth:zn.default.number.isRequired,rowHeight:zn.default.number.isRequired,margin:zn.default.array.isRequired,maxRows:zn.default.number.isRequired,containerPadding:zn.default.array.isRequired,x:zn.default.number.isRequired,y:zn.default.number.isRequired,w:zn.default.number.isRequired,h:zn.default.number.isRequired,minW:function(e,t){const n=e[t];if(typeof n!="number")return new Error("minWidth not Number");if(n>e.w||n>e.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(e,t){const n=e[t];if(typeof n!="number")return new Error("maxWidth not Number");if(n<e.w||n<e.minW)return new Error("maxWidth smaller than item width/minWidth")},minH:function(e,t){const n=e[t];if(typeof n!="number")return new Error("minHeight not Number");if(n>e.h||n>e.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(e,t){const n=e[t];if(typeof n!="number")return new Error("maxHeight not Number");if(n<e.h||n<e.minH)return new Error("maxHeight smaller than item height/minHeight")},i:zn.default.string.isRequired,resizeHandles:Y$.resizeHandleAxesType,resizeHandle:Y$.resizeHandleType,onDragStop:zn.default.func,onDragStart:zn.default.func,onDrag:zn.default.func,onResizeStop:zn.default.func,onResizeStart:zn.default.func,onResize:zn.default.func,isDraggable:zn.default.bool.isRequired,isResizable:zn.default.bool.isRequired,isBounded:zn.default.bool.isRequired,static:zn.default.bool,useCSSTransforms:zn.default.bool.isRequired,transformScale:zn.default.number,className:zn.default.string,handle:zn.default.string,cancel:zn.default.string,droppingPosition:zn.default.shape({e:zn.default.object.isRequired,left:zn.default.number.isRequired,top:zn.default.number.isRequired})});za($P,"defaultProps",{className:"",cancel:"",handle:"",minH:1,minW:1,maxH:1/0,maxW:1/0,transformScale:1});Object.defineProperty(L0,"__esModule",{value:!0});L0.default=void 0;var Nd=gK(S),bI=SP,dwe=zP(pk),Wt=bn,fwe=vl,K$=zP(xk),hwe=zP(uc);function zP(e){return e&&e.__esModule?e:{default:e}}function gK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(gK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function Ws(e,t,n){return(t=mwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mwe(e){var t=pwe(e,"string");return typeof t=="symbol"?t:t+""}function pwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Z$="react-grid-layout";let bK=!1;try{bK=/firefox/i.test(navigator.userAgent)}catch{}class kk extends Nd.Component{constructor(){super(...arguments),Ws(this,"state",{activeDrag:null,layout:(0,Wt.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,(0,Wt.compactType)(this.props),this.props.allowOverlap),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null,resizing:!1,droppingDOMNode:null,children:[]}),Ws(this,"dragEnterCounter",0),Ws(this,"onDragStart",(t,n,r,s)=>{let{e:o,node:i}=s;const{layout:a}=this.state,c=(0,Wt.getLayoutItem)(a,t);if(!c)return;const u={w:c.w,h:c.h,x:c.x,y:c.y,placeholder:!0,i:t};return this.setState({oldDragItem:(0,Wt.cloneLayoutItem)(c),oldLayout:a,activeDrag:u}),this.props.onDragStart(a,c,c,null,o,i)}),Ws(this,"onDrag",(t,n,r,s)=>{let{e:o,node:i}=s;const{oldDragItem:a}=this.state;let{layout:c}=this.state;const{cols:u,allowOverlap:d,preventCollision:f}=this.props,h=(0,Wt.getLayoutItem)(c,t);if(!h)return;const m={w:h.w,h:h.h,x:h.x,y:h.y,placeholder:!0,i:t};c=(0,Wt.moveElement)(c,h,n,r,!0,f,(0,Wt.compactType)(this.props),u,d),this.props.onDrag(c,a,h,m,o,i),this.setState({layout:d?c:(0,Wt.compact)(c,(0,Wt.compactType)(this.props),u),activeDrag:m})}),Ws(this,"onDragStop",(t,n,r,s)=>{let{e:o,node:i}=s;if(!this.state.activeDrag)return;const{oldDragItem:a}=this.state;let{layout:c}=this.state;const{cols:u,preventCollision:d,allowOverlap:f}=this.props,h=(0,Wt.getLayoutItem)(c,t);if(!h)return;c=(0,Wt.moveElement)(c,h,n,r,!0,d,(0,Wt.compactType)(this.props),u,f);const g=f?c:(0,Wt.compact)(c,(0,Wt.compactType)(this.props),u);this.props.onDragStop(g,a,h,null,o,i);const{oldLayout:b}=this.state;this.setState({activeDrag:null,layout:g,oldDragItem:null,oldLayout:null}),this.onLayoutMaybeChanged(g,b)}),Ws(this,"onResizeStart",(t,n,r,s)=>{let{e:o,node:i}=s;const{layout:a}=this.state,c=(0,Wt.getLayoutItem)(a,t);c&&(this.setState({oldResizeItem:(0,Wt.cloneLayoutItem)(c),oldLayout:this.state.layout,resizing:!0}),this.props.onResizeStart(a,c,c,null,o,i))}),Ws(this,"onResize",(t,n,r,s)=>{let{e:o,node:i,size:a,handle:c}=s;const{oldResizeItem:u}=this.state,{layout:d}=this.state,{cols:f,preventCollision:h,allowOverlap:m}=this.props;let g=!1,b,x,y;const[w,v]=(0,Wt.withLayoutItem)(d,t,N=>{let k;return x=N.x,y=N.y,["sw","w","nw","n","ne"].indexOf(c)!==-1&&(["sw","nw","w"].indexOf(c)!==-1&&(x=N.x+(N.w-n),n=N.x!==x&&x<0?N.w:n,x=x<0?0:x),["ne","n","nw"].indexOf(c)!==-1&&(y=N.y+(N.h-r),r=N.y!==y&&y<0?N.h:r,y=y<0?0:y),g=!0),h&&!m&&(k=(0,Wt.getAllCollisions)(d,{...N,w:n,h:r,x,y}).filter(j=>j.i!==N.i).length>0,k&&(y=N.y,r=N.h,x=N.x,n=N.w,g=!1)),N.w=n,N.h=r,N});if(!v)return;b=w,g&&(b=(0,Wt.moveElement)(w,v,x,y,!0,this.props.preventCollision,(0,Wt.compactType)(this.props),f,m));const C={w:v.w,h:v.h,x:v.x,y:v.y,static:!0,i:t};this.props.onResize(b,u,v,C,o,i),this.setState({layout:m?b:(0,Wt.compact)(b,(0,Wt.compactType)(this.props),f),activeDrag:C})}),Ws(this,"onResizeStop",(t,n,r,s)=>{let{e:o,node:i}=s;const{layout:a,oldResizeItem:c}=this.state,{cols:u,allowOverlap:d}=this.props,f=(0,Wt.getLayoutItem)(a,t),h=d?a:(0,Wt.compact)(a,(0,Wt.compactType)(this.props),u);this.props.onResizeStop(h,c,f,null,o,i);const{oldLayout:m}=this.state;this.setState({activeDrag:null,layout:h,oldResizeItem:null,oldLayout:null,resizing:!1}),this.onLayoutMaybeChanged(h,m)}),Ws(this,"onDragOver",t=>{var w;if(t.preventDefault(),t.stopPropagation(),bK&&!((w=t.nativeEvent.target)!=null&&w.classList.contains(Z$)))return!1;const{droppingItem:n,onDropDragOver:r,margin:s,cols:o,rowHeight:i,maxRows:a,width:c,containerPadding:u,transformScale:d}=this.props,f=r==null?void 0:r(t);if(f===!1)return this.state.droppingDOMNode&&this.removeDroppingPlaceholder(),!1;const h={...n,...f},{layout:m}=this.state,g=t.currentTarget.getBoundingClientRect(),b=t.clientX-g.left,x=t.clientY-g.top,y={left:b/d,top:x/d,e:t};if(this.state.droppingDOMNode){if(this.state.droppingPosition){const{left:v,top:C}=this.state.droppingPosition;(v!=b||C!=x)&&this.setState({droppingPosition:y})}}else{const v={cols:o,margin:s,maxRows:a,rowHeight:i,containerWidth:c,containerPadding:u||s},C=(0,fwe.calcXY)(v,x,b,h.w,h.h);this.setState({droppingDOMNode:Nd.createElement("div",{key:h.i}),droppingPosition:y,layout:[...m,{...h,x:C.x,y:C.y,static:!1,isDraggable:!0}]})}}),Ws(this,"removeDroppingPlaceholder",()=>{const{droppingItem:t,cols:n}=this.props,{layout:r}=this.state,s=(0,Wt.compact)(r.filter(o=>o.i!==t.i),(0,Wt.compactType)(this.props),n,this.props.allowOverlap);this.setState({layout:s,droppingDOMNode:null,activeDrag:null,droppingPosition:void 0})}),Ws(this,"onDragLeave",t=>{t.preventDefault(),t.stopPropagation(),this.dragEnterCounter--,this.dragEnterCounter===0&&this.removeDroppingPlaceholder()}),Ws(this,"onDragEnter",t=>{t.preventDefault(),t.stopPropagation(),this.dragEnterCounter++}),Ws(this,"onDrop",t=>{t.preventDefault(),t.stopPropagation();const{droppingItem:n}=this.props,{layout:r}=this.state,s=r.find(o=>o.i===n.i);this.dragEnterCounter=0,this.removeDroppingPlaceholder(),this.props.onDrop(r,s,t)})}componentDidMount(){this.setState({mounted:!0}),this.onLayoutMaybeChanged(this.state.layout,this.props.layout)}static getDerivedStateFromProps(t,n){let r;return n.activeDrag?null:(!(0,bI.deepEqual)(t.layout,n.propsLayout)||t.compactType!==n.compactType?r=t.layout:(0,Wt.childrenEqual)(t.children,n.children)||(r=n.layout),r?{layout:(0,Wt.synchronizeLayoutWithChildren)(r,t.children,t.cols,(0,Wt.compactType)(t),t.allowOverlap),compactType:t.compactType,children:t.children,propsLayout:t.layout}:null)}shouldComponentUpdate(t,n){return this.props.children!==t.children||!(0,Wt.fastRGLPropsEqual)(this.props,t,bI.deepEqual)||this.state.activeDrag!==n.activeDrag||this.state.mounted!==n.mounted||this.state.droppingPosition!==n.droppingPosition}componentDidUpdate(t,n){if(!this.state.activeDrag){const r=this.state.layout,s=n.layout;this.onLayoutMaybeChanged(r,s)}}containerHeight(){if(!this.props.autoSize)return;const t=(0,Wt.bottom)(this.state.layout),n=this.props.containerPadding?this.props.containerPadding[1]:this.props.margin[1];return t*this.props.rowHeight+(t-1)*this.props.margin[1]+n*2+"px"}onLayoutMaybeChanged(t,n){n||(n=this.state.layout),(0,bI.deepEqual)(n,t)||this.props.onLayoutChange(t)}placeholder(){const{activeDrag:t}=this.state;if(!t)return null;const{width:n,cols:r,margin:s,containerPadding:o,rowHeight:i,maxRows:a,useCSSTransforms:c,transformScale:u}=this.props;return Nd.createElement(K$.default,{w:t.w,h:t.h,x:t.x,y:t.y,i:t.i,className:`react-grid-placeholder ${this.state.resizing?"placeholder-resizing":""}`,containerWidth:n,cols:r,margin:s,containerPadding:o||s,maxRows:a,rowHeight:i,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:c,transformScale:u},Nd.createElement("div",null))}processGridItem(t,n){if(!t||!t.key)return;const r=(0,Wt.getLayoutItem)(this.state.layout,String(t.key));if(!r)return null;const{width:s,cols:o,margin:i,containerPadding:a,rowHeight:c,maxRows:u,isDraggable:d,isResizable:f,isBounded:h,useCSSTransforms:m,transformScale:g,draggableCancel:b,draggableHandle:x,resizeHandles:y,resizeHandle:w}=this.props,{mounted:v,droppingPosition:C}=this.state,N=typeof r.isDraggable=="boolean"?r.isDraggable:!r.static&&d,k=typeof r.isResizable=="boolean"?r.isResizable:!r.static&&f,_=r.resizeHandles||y,j=N&&h&&r.isBounded!==!1;return Nd.createElement(K$.default,{containerWidth:s,cols:o,margin:i,containerPadding:a||i,maxRows:u,rowHeight:c,cancel:b,handle:x,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:N,isResizable:k,isBounded:j,useCSSTransforms:m&&v,usePercentages:!v,transformScale:g,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:n?C:void 0,resizeHandles:_,resizeHandle:w},t)}render(){const{className:t,style:n,isDroppable:r,innerRef:s}=this.props,o=(0,dwe.default)(Z$,t),i={height:this.containerHeight(),...n};return Nd.createElement("div",{ref:s,className:o,style:i,onDrop:r?this.onDrop:Wt.noop,onDragLeave:r?this.onDragLeave:Wt.noop,onDragEnter:r?this.onDragEnter:Wt.noop,onDragOver:r?this.onDragOver:Wt.noop},Nd.Children.map(this.props.children,a=>this.processGridItem(a)),r&&this.state.droppingDOMNode&&this.processGridItem(this.state.droppingDOMNode,!0),this.placeholder())}}L0.default=kk;Ws(kk,"displayName","ReactGridLayout");Ws(kk,"propTypes",hwe.default);Ws(kk,"defaultProps",{autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isBounded:!1,isDraggable:!0,isResizable:!0,allowOverlap:!1,isDroppable:!1,useCSSTransforms:!0,transformScale:1,verticalCompact:!0,compactType:"vertical",preventCollision:!1,droppingItem:{i:"__dropping-elem__",h:1,w:1},resizeHandles:["se"],onLayoutChange:Wt.noop,onDragStart:Wt.noop,onDrag:Wt.noop,onDragStop:Wt.noop,onResizeStart:Wt.noop,onResize:Wt.noop,onResizeStop:Wt.noop,onDrop:Wt.noop,onDropDragOver:Wt.noop});var _k={},Eh={};Object.defineProperty(Eh,"__esModule",{value:!0});Eh.findOrGenerateResponsiveLayout=xwe;Eh.getBreakpointFromWidth=gwe;Eh.getColsFromBreakpoint=bwe;Eh.sortBreakpoints=BP;var uw=bn;function gwe(e,t){const n=BP(e);let r=n[0];for(let s=1,o=n.length;s<o;s++){const i=n[s];t>e[i]&&(r=i)}return r}function bwe(e,t){if(!t[e])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+e+" is missing!");return t[e]}function xwe(e,t,n,r,s,o){if(e[n])return(0,uw.cloneLayout)(e[n]);let i=e[r];const a=BP(t),c=a.slice(a.indexOf(n));for(let u=0,d=c.length;u<d;u++){const f=c[u];if(e[f]){i=e[f];break}}return i=(0,uw.cloneLayout)(i||[]),(0,uw.compact)((0,uw.correctBounds)(i,{cols:s}),o,s)}function BP(e){return Object.keys(e).sort(function(n,r){return e[n]-e[r]})}Object.defineProperty(_k,"__esModule",{value:!0});_k.default=void 0;var X$=yK(S),To=xK(cd),xI=SP,zm=bn,kd=Eh,ywe=xK(L0);function xK(e){return e&&e.__esModule?e:{default:e}}function yK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(yK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function _2(){return _2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_2.apply(null,arguments)}function eC(e,t,n){return(t=vwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vwe(e){var t=wwe(e,"string");return typeof t=="symbol"?t:t+""}function wwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Q$=e=>Object.prototype.toString.call(e);function dw(e,t){return e==null?null:Array.isArray(e)?e:e[t]}class VP extends X$.Component{constructor(){super(...arguments),eC(this,"state",this.generateInitialState()),eC(this,"onLayoutChange",t=>{this.props.onLayoutChange(t,{...this.props.layouts,[this.state.breakpoint]:t})})}generateInitialState(){const{width:t,breakpoints:n,layouts:r,cols:s}=this.props,o=(0,kd.getBreakpointFromWidth)(n,t),i=(0,kd.getColsFromBreakpoint)(o,s),a=this.props.verticalCompact===!1?null:this.props.compactType;return{layout:(0,kd.findOrGenerateResponsiveLayout)(r,n,o,o,i,a),breakpoint:o,cols:i}}static getDerivedStateFromProps(t,n){if(!(0,xI.deepEqual)(t.layouts,n.layouts)){const{breakpoint:r,cols:s}=n;return{layout:(0,kd.findOrGenerateResponsiveLayout)(t.layouts,t.breakpoints,r,r,s,t.compactType),layouts:t.layouts}}return null}componentDidUpdate(t){(this.props.width!=t.width||this.props.breakpoint!==t.breakpoint||!(0,xI.deepEqual)(this.props.breakpoints,t.breakpoints)||!(0,xI.deepEqual)(this.props.cols,t.cols))&&this.onWidthChange(t)}onWidthChange(t){const{breakpoints:n,cols:r,layouts:s,compactType:o}=this.props,i=this.props.breakpoint||(0,kd.getBreakpointFromWidth)(this.props.breakpoints,this.props.width),a=this.state.breakpoint,c=(0,kd.getColsFromBreakpoint)(i,r),u={...s};if(a!==i||t.breakpoints!==n||t.cols!==r){a in u||(u[a]=(0,zm.cloneLayout)(this.state.layout));let h=(0,kd.findOrGenerateResponsiveLayout)(u,n,i,a,c,o);h=(0,zm.synchronizeLayoutWithChildren)(h,this.props.children,c,o,this.props.allowOverlap),u[i]=h,this.props.onBreakpointChange(i,c),this.props.onLayoutChange(h,u),this.setState({breakpoint:i,layout:h,cols:c})}const d=dw(this.props.margin,i),f=dw(this.props.containerPadding,i);this.props.onWidthChange(this.props.width,d,c,f)}render(){const{breakpoint:t,breakpoints:n,cols:r,layouts:s,margin:o,containerPadding:i,onBreakpointChange:a,onLayoutChange:c,onWidthChange:u,...d}=this.props;return X$.createElement(ywe.default,_2({},d,{margin:dw(o,this.state.breakpoint),containerPadding:dw(i,this.state.breakpoint),onLayoutChange:this.onLayoutChange,layout:this.state.layout,cols:this.state.cols}))}}_k.default=VP;eC(VP,"propTypes",{breakpoint:To.default.string,breakpoints:To.default.object,allowOverlap:To.default.bool,cols:To.default.object,margin:To.default.oneOfType([To.default.array,To.default.object]),containerPadding:To.default.oneOfType([To.default.array,To.default.object]),layouts(e,t){if(Q$(e[t])!=="[object Object]")throw new Error("Layout property must be an object. Received: "+Q$(e[t]));Object.keys(e[t]).forEach(n=>{if(!(n in e.breakpoints))throw new Error("Each key in layouts must align with a key in breakpoints.");(0,zm.validateLayout)(e.layouts[n],"layouts."+n)})},width:To.default.number.isRequired,onBreakpointChange:To.default.func,onLayoutChange:To.default.func,onWidthChange:To.default.func});eC(VP,"defaultProps",{breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},containerPadding:{lg:null,md:null,sm:null,xs:null,xxs:null},layouts:{},margin:[10,10],allowOverlap:!1,onBreakpointChange:zm.noop,onLayoutChange:zm.noop,onWidthChange:zm.noop});var HP={},vK=function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(s,o){return s[0]===n?(r=o,!0):!1}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),s=this.__entries__[r];return s&&s[1]},t.prototype.set=function(n,r){var s=e(this.__entries__,n);~s?this.__entries__[s][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,s=e(r,n);~s&&r.splice(s,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var s=0,o=this.__entries__;s<o.length;s++){var i=o[s];n.call(r,i[1],i[0])}},t}()}(),j2=typeof window<"u"&&typeof document<"u"&&window.document===document,tC=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),Swe=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(tC):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),Cwe=2;function Nwe(e,t){var n=!1,r=!1,s=0;function o(){n&&(n=!1,e()),r&&a()}function i(){Swe(o)}function a(){var c=Date.now();if(n){if(c-s<Cwe)return;r=!0}else n=!0,r=!1,setTimeout(i,t);s=c}return a}var kwe=20,_we=["top","right","bottom","left","width","height","size","weight"],jwe=typeof MutationObserver<"u",Iwe=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=Nwe(this.refresh.bind(this),kwe)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!j2||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),jwe?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!j2||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,s=_we.some(function(o){return!!~r.indexOf(o)});s&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),wK=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var s=r[n];Object.defineProperty(e,s,{value:t[s],enumerable:!1,writable:!1,configurable:!0})}return e},mp=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||tC},SK=jk(0,0,0,0);function nC(e){return parseFloat(e)||0}function J$(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,s){var o=e["border-"+s+"-width"];return r+nC(o)},0)}function Ewe(e){for(var t=["top","right","bottom","left"],n={},r=0,s=t;r<s.length;r++){var o=s[r],i=e["padding-"+o];n[o]=nC(i)}return n}function Twe(e){var t=e.getBBox();return jk(0,0,t.width,t.height)}function Dwe(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return SK;var r=mp(e).getComputedStyle(e),s=Ewe(r),o=s.left+s.right,i=s.top+s.bottom,a=nC(r.width),c=nC(r.height);if(r.boxSizing==="border-box"&&(Math.round(a+o)!==t&&(a-=J$(r,"left","right")+o),Math.round(c+i)!==n&&(c-=J$(r,"top","bottom")+i)),!Awe(e)){var u=Math.round(a+o)-t,d=Math.round(c+i)-n;Math.abs(u)!==1&&(a-=u),Math.abs(d)!==1&&(c-=d)}return jk(s.left,s.top,a,c)}var Mwe=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof mp(e).SVGGraphicsElement}:function(e){return e instanceof mp(e).SVGElement&&typeof e.getBBox=="function"}}();function Awe(e){return e===mp(e).document.documentElement}function Rwe(e){return j2?Mwe(e)?Twe(e):Dwe(e):SK}function Pwe(e){var t=e.x,n=e.y,r=e.width,s=e.height,o=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,i=Object.create(o.prototype);return wK(i,{x:t,y:n,width:r,height:s,top:n,right:t+r,bottom:s+n,left:t}),i}function jk(e,t,n,r){return{x:e,y:t,width:n,height:r}}var Fwe=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=jk(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=Rwe(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),Owe=function(){function e(t,n){var r=Pwe(n);wK(this,{target:t,contentRect:r})}return e}(),Lwe=function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new vK,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof mp(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new Fwe(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof mp(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new Owe(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),CK=typeof WeakMap<"u"?new WeakMap:new vK,NK=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=Iwe.getInstance(),r=new Lwe(t,n,this);CK.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){NK.prototype[e]=function(){var t;return(t=CK.get(this))[e].apply(t,arguments)}});var $we=function(){return typeof tC.ResizeObserver<"u"?tC.ResizeObserver:NK}();const zwe=Object.freeze(Object.defineProperty({__proto__:null,default:$we},Symbol.toStringTag,{value:"Module"})),Bwe=p.getAugmentedNamespace(zwe);Object.defineProperty(HP,"__esModule",{value:!0});HP.default=Ywe;var fw=kK(S),Vwe=UP(cd),Hwe=UP(Bwe),Uwe=UP(pk);function UP(e){return e&&e.__esModule?e:{default:e}}function kK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(kK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function I2(){return I2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I2.apply(null,arguments)}function Zh(e,t,n){return(t=qwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qwe(e){var t=Wwe(e,"string");return typeof t=="symbol"?t:t+""}function Wwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Gwe="react-grid-layout";function Ywe(e){var t;return t=class extends fw.Component{constructor(){super(...arguments),Zh(this,"state",{width:1280}),Zh(this,"elementRef",fw.createRef()),Zh(this,"mounted",!1),Zh(this,"resizeObserver",void 0)}componentDidMount(){this.mounted=!0,this.resizeObserver=new Hwe.default(s=>{if(this.elementRef.current instanceof HTMLElement){const i=s[0].contentRect.width;this.setState({width:i})}});const r=this.elementRef.current;r instanceof HTMLElement&&this.resizeObserver.observe(r)}componentWillUnmount(){this.mounted=!1;const r=this.elementRef.current;r instanceof HTMLElement&&this.resizeObserver.unobserve(r),this.resizeObserver.disconnect()}render(){const{measureBeforeMount:r,...s}=this.props;return r&&!this.mounted?fw.createElement("div",{className:(0,Uwe.default)(this.props.className,Gwe),style:this.props.style,ref:this.elementRef}):fw.createElement(e,I2({innerRef:this.elementRef},s,this.state))}},Zh(t,"defaultProps",{measureBeforeMount:!1}),Zh(t,"propTypes",{measureBeforeMount:Vwe.default.bool}),t}(function(e){e.exports=L0.default,e.exports.utils=bn,e.exports.calculateUtils=vl,e.exports.Responsive=_k.default,e.exports.Responsive.utils=Eh,e.exports.WidthProvider=HP.default})(zY);var e4=zY.exports;const _K=S.createContext(void 0);function Cl(){const e=S.useContext(_K);return e||{displayPreferences:{mode:"full"},shouldShowElement:()=>!0}}var pp=1e3,gp=pp*60,bp=gp*60,Zf=bp*24,Kwe=Zf*7,Zwe=Zf*365.25,Xwe=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return Qwe(e);if(n==="number"&&isFinite(e))return t.long?e1e(e):Jwe(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Qwe(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*Zwe;case"weeks":case"week":case"w":return n*Kwe;case"days":case"day":case"d":return n*Zf;case"hours":case"hour":case"hrs":case"hr":case"h":return n*bp;case"minutes":case"minute":case"mins":case"min":case"m":return n*gp;case"seconds":case"second":case"secs":case"sec":case"s":return n*pp;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function Jwe(e){var t=Math.abs(e);return t>=Zf?Math.round(e/Zf)+"d":t>=bp?Math.round(e/bp)+"h":t>=gp?Math.round(e/gp)+"m":t>=pp?Math.round(e/pp)+"s":e+"ms"}function e1e(e){var t=Math.abs(e);return t>=Zf?hw(e,t,Zf,"day"):t>=bp?hw(e,t,bp,"hour"):t>=gp?hw(e,t,gp,"minute"):t>=pp?hw(e,t,pp,"second"):e+" ms"}function hw(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}const t1e=p.getDefaultExportFromCjs(Xwe);function n1e(e,t={}){if(!e)return[];const n=[],r=[...t.existingInputs||[]];for(const s of e.inlineFilters||[]){const o=s.title||s.column||s.id,i=o1e(s),a={id:r1e(e.id,s.id),kind:"filter",label:o,variableName:s.variableName?Eu(s.variableName,r):UR(o,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:{placement:"card_header"},filter:i,exports:qR(i),compatibility:{source:"cardInlineFilter",cardId:e.id,filterId:s.id}};r.push(a),n.push(a)}for(const s of e.controls||[]){const o=s.label||s.id,i={id:s1e(e.id,s.id),kind:"control",label:o,variableName:Eu(s.id,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:Vq(s),control:s,exports:WR(s),requiredAtExecution:s.requiredAtExecution,compatibility:{source:"cardControl",cardId:e.id,controlId:s.id}};r.push(i),n.push(i)}return n}function r1e(e,t){return`compat-inline-filter:${e}:${t}`}function s1e(e,t){return`compat-card-control:${e}:${t}`}function o1e(e){return{kind:"field",id:e.id,variableName:e.variableName,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel,toolbarWidth:e.width,displayMode:"toolbar"}}function i1e(e,t={}){const n=[],r=[...t.existingInputs||[]];for(const s of e.controls||[]){const o=s.label||s.id,i={id:jK(s.id),kind:"control",label:o,variableName:Eu(s.id,r),scope:{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:Vq(s),control:s,exports:WR(s),requiredAtExecution:s.requiredAtExecution,compatibility:{source:"dashboardControl",controlId:s.id}};r.push(i),n.push(i)}return n}function jK(e){return`compat-control:${e}`}function a1e(e,t={}){const n=[],r=[...t.existingInputs||[]],s=t.availableSheetIds||(e.sheets||[]).filter(u=>u.kind!=="document").map(u=>u.id),o=p.getDashboardCardEntries({sheets:e.sheets}),i=t.availableCardIds?new Set(t.availableCardIds):void 0,a=o.filter(u=>!i||i.has(u.card.id)),c=t.availableCardIds||a.map(u=>u.card.id);for(const u of e.filters||[]){const d=u.title||u.column||u.id,f={id:qP(u.id),kind:"filter",label:d,variableName:u.variableName?Eu(u.variableName,r):UR(d,r),scope:l1e(u,{availableDashboardSheetIds:s,availableCardEntries:a,availableCardIds:c}),runtimeScope:"shared",presentation:tpe(u),filter:u,exports:qR(u),compatibility:{source:"dashboardFilter",filterId:u.id}};r.push(f),n.push(f)}return n}function qP(e){return`compat-filter:${e}`}function l1e(e,t){if(e.applyToCardIds!==void 0){const n=new Set(t4(e,t));return{kind:"cards",cardIds:e.applyToCardIds.filter(r=>n.has(r))}}if(e.excludeCardIds!==void 0){const n=new Set(e.excludeCardIds);return{kind:"cards",cardIds:t4(e,t).filter(s=>!n.has(s))}}if(e.sheetId)return{kind:"sheets",sheetIds:[e.sheetId]};if(e.applyToSheetIds!==void 0)return{kind:"sheets",sheetIds:e.applyToSheetIds};if(e.excludeSheetIds!==void 0){const n=new Set(e.excludeSheetIds);return{kind:"sheets",sheetIds:t.availableDashboardSheetIds.filter(r=>!n.has(r))}}return{kind:"allSheets",sheetKinds:["dashboard"]}}function t4(e,t){return!e.sheetId&&e.applyToSheetIds===void 0&&e.excludeSheetIds===void 0?t.availableCardIds:t.availableCardEntries.filter(n=>c1e(e,n.sheet.id)).map(n=>n.card.id)}function c1e(e,t){return e.sheetId&&e.sheetId!==t?!1:e.applyToSheetIds!==void 0?e.applyToSheetIds.includes(t):e.excludeSheetIds!==void 0?!e.excludeSheetIds.includes(t):!0}function Ik({dashboard:e,card:t,availableSheetIds:n,availableCardIds:r}){const s=e.inputs||[],o=[],i=[...s],a=a1e(e,{existingInputs:i,availableSheetIds:n,availableCardIds:r});o.push(...a),i.push(...a);const c=i1e(e,{existingInputs:i});o.push(...c),i.push(...c);const u=n1e(t,{existingInputs:i});return o.push(...u),{authoredInputs:s,compatibilityInputs:o,allInputs:[...s,...o]}}function Nl({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,runtimeValues:o,mode:i="interactive",timezone:a}){const c={sheetId:t,cardId:n==null?void 0:n.id,sectionId:r,sheetKind:s||w1e(e,t)},u=Ik({dashboard:e,card:n}),d=IK(u.allInputs.filter(g=>xp(g,c)));v1e(d);const f=d.map(g=>d1e({dashboard:e,input:g,runtimeValues:o,target:c,timezone:a})),h=h1e({resolvedInputs:f,card:n}),m=m1e(f);return{inputs:d,resolvedInputs:f,...h,...m,missingRequiredInputs:f.filter(g=>g.missingRequiredValue)}}function xp(e,t){var n;if(!u1e(e,t))return!1;switch(e.scope.kind){case"allSheets":return(n=e.scope.sheetKinds)!=null&&n.length?t.sheetKind?e.scope.sheetKinds.includes(t.sheetKind):!1:!!t.sheetId||!!t.cardId;case"sheets":return!!t.sheetId&&e.scope.sheetIds.includes(t.sheetId);case"cards":return!!t.cardId&&e.scope.cardIds.includes(t.cardId);case"documentSections":return!!t.sheetId&&!!t.sectionId&&e.scope.sheetId===t.sheetId&&e.scope.sectionIds.includes(t.sectionId);default:return!1}}function u1e(e,t){return t.sheetKind!=="document"||!e.compatibility||e.compatibility.source==="documentInput"?!0:e.compatibility.source==="cardInlineFilter"||e.compatibility.source==="cardControl"?!!t.cardId&&e.compatibility.cardId===t.cardId:!1}function IK(e){const t=new Set(e.filter(n=>!WS(n)).map(g$));return e.filter(n=>!WS(n)||!t.has(g$(n)))}function d1e(e){var a;const t=!!e.runtimeValues.dashboardInputValuesAreAuthoritative,n=!t&&WS(e.input)&&((a=e.input.compatibility)==null?void 0:a.source)!=="documentInput",r=t?p.getDashboardInputRuntimeSlot(e.runtimeValues.dashboardInputValues,e.input,e.target):n?p1e(e):p.hydrateAuthoredDashboardInputSlot({dashboard:e.dashboard,input:e.input,runtimeValues:e.runtimeValues.dashboardInputValues,target:e.target,timezone:e.timezone}),s=(r==null?void 0:r.status)==="set"&&r.value.kind===e.input.kind?r.value:void 0;if(e.input.kind==="filter"){const c=(s==null?void 0:s.kind)==="filter"?EK(e.input,s.filterValue):void 0,u=b1e({input:e.input,filterValue:c,timezone:e.timezone});return{id:e.input.id,kind:"filter",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:r,rawValue:c?S1e(c.values):void 0,displayValue:n4(u.label??u.value),exports:u,filter:e.input.filter,filterValue:c,missingRequiredValue:!!e.input.requiredAtExecution&&!c}}const o=(s==null?void 0:s.kind)==="control"?s.value:void 0,i=x1e({input:e.input,value:o});return{id:e.input.id,kind:"control",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:r,rawValue:o,displayValue:n4(i.label??i.value),exports:i,control:e.input.control,controlValue:o,missingRequiredValue:!!e.input.requiredAtExecution&&!f1e(o)}}function f1e(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function h1e({resolvedInputs:e,card:t}){const n=[],r=new Map,s=new Map,o={};for(const c of e){if(c.kind==="filter"){c.filter&&c.filterValue&&n.push(c.filterValue);continue}c.control&&(y1e(c)?s.set(c.control.id,c.control):r.set(c.control.id,c.control),c.controlValue!==void 0&&(o[c.control.id]=c.controlValue))}const i=new Set([...r.keys(),...s.keys()]),a=((t==null?void 0:t.controlBindings)||[]).filter(c=>i.has(c.controlId));return{activeFilters:n,controlDefinitions:Array.from(r.values()),cardControlDefinitions:Array.from(s.values()),controlBindings:a,controlValues:o}}function m1e(e){const t={},n={};for(const r of e)n[r.id]=r,t[r.variableName]=r;return{variablesByName:t,variablesById:n}}function p1e(e){var s,o,i,a;const t=(s=e.input.compatibility)==null?void 0:s.source;if(e.input.kind==="filter"){const c=e.input.filter.id,u=t==="cardInlineFilter"?e.target.cardId?(i=(o=e.runtimeValues.inlineFilterValuesMap)==null?void 0:o[e.target.cardId])==null?void 0:i.find(d=>d.filterId===c):void 0:(a=e.runtimeValues.filterValues)==null?void 0:a.find(d=>d.filterId===c);return u?p.createFilterDashboardInputSlot(EK(e.input,u)):void 0}const n=e.input.control.id,r=g1e({source:t,target:e.target,runtimeValues:e.runtimeValues});if(r.values&&Object.prototype.hasOwnProperty.call(r.values,n))return p.createControlDashboardInputSlot(r.values[n]);if(!r.isExplicit)return t==="dashboardControl"?p.createControlDashboardInputSlot(p.resolveSavedDefaultValue(e.input.control,e.dashboard.defaultControlValues)):p.getBackingDefaultSlot(e.input,e.timezone)}function g1e({source:e,target:t,runtimeValues:n}){var r;return e==="cardControl"&&t.cardId?{values:(r=n.cardControlValuesMap)==null?void 0:r[t.cardId],isExplicit:!!(n.cardControlValuesMap&&Object.prototype.hasOwnProperty.call(n.cardControlValuesMap,t.cardId))}:{values:n.controlValues,isExplicit:n.controlValues!==void 0}}function EK(e,t){const n=t.filterId===e.filter.id?t:{...t,filterId:e.filter.id};return p.isCompatibleFilterValue(e.filter,n)?n:void 0}function b1e({input:e,filterValue:t,timezone:n}){const r=e.exports||qR(e.filter),s=(t==null?void 0:t.values)||[],o=p.getDataType(e.filter.dataType)==="date",i=s.map(k1e),a=o?i.length>1?`${i[0]} - ${i[1]}`:i[0]||"":i.join(", "),c={};for(const u of r)u==="start"?c.start=i[0]||null:u==="end"?c.end=i[1]||null:u==="range"?c.range=a||null:c[u]=a||null;return c}function x1e({input:e,value:t}){const n=e.exports||WR(e.control),r=C1e(t),s=r.map(a=>N1e(e.control,a)).join(", "),o=r.map(TK).join(", "),i={};for(const a of n)i[a]=a==="label"?s||null:o||null;return i}function y1e(e){return e.control?e.control.scope==="card"||e.id.startsWith("compat-card-control:"):!1}function v1e(e){const t=new Map;for(const n of e){if(WS(n))continue;const r=t.get(n.variableName);if(r)throw new Error(`Duplicate dashboard input variableName "${n.variableName}" for inputs "${r}" and "${n.id}" in the same resolved scope.`);t.set(n.variableName,n.id)}}function w1e(e,t){var r;if(!t)return;const n=(r=e.sheets)==null?void 0:r.find(s=>s.id===t);return(n==null?void 0:n.kind)==="document"?"document":"dashboard"}function S1e(e){return e.length>1?e:e[0]??null}function C1e(e){return e==null?[]:Array.isArray(e)?e:[e]}function N1e(e,t){var r;const n=TK(t);return e.source.kind==="manual"&&((r=e.source.options.find(s=>s.value===n))==null?void 0:r.label)||n}function TK(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function k1e(e){return e instanceof Date?e.toISOString():typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function n4(e){return e==null?"":String(e)}function WP(e,t,n,r){const s=e==null?void 0:e.filter(a=>a.sheetId&&a.sheetId!==n?!1:a.applyToSheetIds!==void 0?a.applyToSheetIds.includes(n):a.excludeSheetIds!==void 0?!a.excludeSheetIds.includes(n):!0),o=s==null?void 0:s.filter(a=>a.applyToCardIds!==void 0?a.applyToCardIds.includes(r):a.excludeCardIds!==void 0?!a.excludeCardIds.includes(r):!0),i=t==null?void 0:t.filter(a=>(o==null?void 0:o.some(c=>c.id===a.filterId))||a.filterId.endsWith(n));return{cardFilters:o,cardFilterValues:i}}function B0({card:e,interactionStates:t,currentDashboardId:n,filters:r,filterValues:s,selectedSheetId:o}){const i=t==null?void 0:t.__DRILL_CONTEXT__,c=(i==null?void 0:i.targetDashboardId)===n?i==null?void 0:i.contextMode:void 0,u=t==null?void 0:t[e.id],d=u==null?void 0:u.contextMode,f=c||d,h=!f||f==="full",{cardFilters:m,cardFilterValues:g}=h?WP(r,s,o,e.id):{cardFilters:void 0,cardFilterValues:void 0};return{cardFilters:m,cardFilterValues:g,shouldApplyDashboardFilters:h,contextMode:f}}function sb(e){return e==null?void 0:e.map(({format:t,...n})=>n)}function DK(e){if(!e)return;const{format:t,...n}=e;return mm(n)}function _1e(e){return{...e,field:DK(e.field)}}function GP(e){if(e)return{...e,conditions:e.conditions.map(_1e),groups:e.groups.map(t=>GP(t))}}function mm(e){var n,r;const t={...e};return(n=t.calculatedFormula)!=null&&n.inputFields&&(t.calculatedFormula={...t.calculatedFormula,inputFields:t.calculatedFormula.inputFields.map(s=>DK(s))}),(r=t.parameters)!=null&&r.filters&&(t.parameters={...t.parameters,filters:GP(t.parameters.filters)}),t}function MK(e,t={}){var r,s,o,i,a;if(!e)return;const n={...e,groupByColumns:(r=sb(e.groupByColumns))==null?void 0:r.map(mm),metricColumns:(s=sb(e.metricColumns))==null?void 0:s.map(mm),pivotByColumns:(o=sb(e.pivotByColumns))==null?void 0:o.map(mm),sortByColumns:(i=sb(e.sortByColumns))==null?void 0:i.map(mm),detailColumns:(a=sb(e.detailColumns))==null?void 0:a.map(mm),filters:GP(e.filters)};return t.cardType!=="matrixTable"?n:j1e({outputConfig:n,shelfConfig:e,dataSource:t.dataSource})}function j1e(e){const{outputConfig:t,shelfConfig:n,dataSource:r}=e,s=E1e(t),o=T1e(r)||(s==null?void 0:s.source)||t.source;if(!o)return t;const i=Array.isArray(t.groupByColumns),a=Array.isArray(t.pivotByColumns),c=Array.isArray(t.metricColumns),u=i||a||c,d=i?r4(t.groupByColumns||[],o):(s==null?void 0:s.rows)||t.rows||[],f=a?r4(t.pivotByColumns||[],o):(s==null?void 0:s.columns)||t.columns||[],h=c?D1e(n.metricColumns||[],o):(s==null?void 0:s.values)||t.values||[],m=I1e({existingTotals:t.totals||(u||s==null?void 0:s.totals),hasColumnAxis:f.length>0}),g={kind:"matrix",version:1,source:o,rows:d,columns:f,values:h,...s!=null&&s.filters?{filters:s.filters}:{},...s!=null&&s.inputs||t.inputs?{inputs:(s==null?void 0:s.inputs)||t.inputs}:{},totals:m,...s!=null&&s.sort||t.sort?{sort:(s==null?void 0:s.sort)||t.sort}:{},...s!=null&&s.expansion||t.expansion?{expansion:(s==null?void 0:s.expansion)||t.expansion}:{},...s!=null&&s.layout||t.layout?{layout:(s==null?void 0:s.layout)||t.layout}:{},...s!=null&&s.displayLimits||t.displayLimits?{displayLimits:(s==null?void 0:s.displayLimits)||t.displayLimits}:{}},{source:b,rows:x,columns:y,values:w,inputs:v,totals:C,sort:N,expansion:k,layout:_,displayLimits:j,version:E,...I}=t;return{...I,matrixIntent:g}}function I1e(e){var t,n,r;return{rows:((t=e.existingTotals)==null?void 0:t.rows)??!0,columns:((n=e.existingTotals)==null?void 0:n.columns)??e.hasColumnAxis,grandTotal:((r=e.existingTotals)==null?void 0:r.grandTotal)??!0}}function E1e(e){var t;if(((t=e.matrixIntent)==null?void 0:t.kind)==="matrix")return e.matrixIntent;if(!(!e.source||!e.rows||!e.values))return{kind:"matrix",version:e.version||1,source:e.source,rows:e.rows,columns:e.columns,values:e.values,...e.inputs?{inputs:e.inputs}:{},...e.totals?{totals:e.totals}:{},...e.sort?{sort:e.sort}:{},...e.expansion?{expansion:e.expansion}:{},...e.layout?{layout:e.layout}:{},...e.displayLimits?{displayLimits:e.displayLimits}:{}}}function T1e(e){var n;const t=(n=e==null?void 0:e.selectedEntities)==null?void 0:n[0];if(!(!e||!t)){if(e.mode==="semanticDomain"&&e.semanticDomainId)return{kind:"semantic",domainId:e.semanticDomainId,datasetName:t.name,..."id"in t&&t.id?{datasetId:t.id}:{},..."label"in t&&t.label?{label:t.label}:{},connectionId:t.connectionId||e.connectionId};if(e.mode==="database")return{kind:"physical",connectionId:t.connectionId||e.connectionId,connectionType:t.connectionType||e.connectionType,tableName:t.name,databaseName:t.database,schemaName:t.schema,..."label"in t&&t.label?{label:t.label}:{},dialect:t.dialect}}}function r4(e,t){const n=RK();return e.map((r,s)=>M1e(r,s,t,n))}function D1e(e,t){const n=RK();return e.map((r,s)=>A1e(r,s,t,n))}function M1e(e,t,n,r){return{id:r(e,t,{kind:"axis",grain:yI(e.granularity)}),field:AK(e,n),...yI(e.granularity)?{grain:yI(e.granularity)}:{},label:e.label||e.name}}function A1e(e,t,n,r){return{id:r(e,t,{kind:"value",aggregate:E2(e.aggregate)}),field:AK(e,n),aggregate:E2(e.aggregate),label:e.label||e.name,...e.format?{format:e.format}:{}}}function AK(e,t){return{name:e.sourceField||e.name,label:e.label||e.name,role:F1e(e),dataType:PK(e.dataType),source:R1e(e,t),...e.aggregate?{aggregate:E2(e.aggregate)}:{}}}function R1e(e,t){if(t.kind!=="semantic"||!e.entityName)return t;const n=e.entityId,r=e.entityName;return n&&n===t.datasetId||r===t.datasetName?t:{kind:"semantic",domainId:t.domainId,datasetName:r,...n?{datasetId:n}:{}}}function RK(){const e=new Set;return(t,n,r)=>{const s=P1e(t,n),o=[s];r.kind==="axis"&&r.grain&&o.push(`${s}-${r.grain}`),r.kind==="value"&&o.push(`${s}-${r.aggregate.toLowerCase()}`),o.push(`${s}-${n+1}`);for(const c of o)if(!e.has(c))return e.add(c),c;let i=n+1,a=`${s}-${i}`;for(;e.has(a);)i+=1,a=`${s}-${i}`;return e.add(a),a}}function P1e(e,t){return e.id||e.alias||e.name||`field_${t+1}`}function F1e(e){if(e.role==="metric")return"measure";const t=PK(e.dataType);return t==="date"||t==="datetime"?"date":"dimension"}function PK(e){const t=Ihe.normalizeAnalyticsCatalogDataType(e);return t==="string"||t==="number"||t==="boolean"||t==="date"||t==="datetime"?t:"unknown"}function yI(e){if(e==="hour"||e==="day"||e==="week"||e==="month"||e==="quarter"||e==="year")return e}function E2(e){return e==="COUNT"||e==="SUM"||e==="AVG"||e==="MIN"||e==="MAX"||e==="MEDIAN"||e==="DISTINCT"?e:"SUM"}function O1e(e){const t=e.card.controlBindings||[],n=e.card.controls||[],s=e.dashboardControls||[],o=n,i=new Set([...s.map(u=>u.id),...o.map(u=>u.id)]),a=t.filter(u=>i.has(u.controlId));return{controlValues:p.mergeRelevantControlValues({relevantControlIds:i,dashboardValues:e.dashboardControlValues,cardValues:e.cardControlValues}),controlDefinitions:s,cardControlDefinitions:o,controlBindings:a}}function V0({card:e,interactionStates:t,currentDashboardId:n,filters:r,filterValues:s,selectedSheetId:o,inlineFilterValuesMap:i,dashboardControls:a,dashboardControlValues:c,cardControlValuesMap:u,dashboardInputContext:d}){var N;const{cardFilterValues:f,shouldApplyDashboardFilters:h}=B0({card:e,interactionStates:t,currentDashboardId:n,filters:r,filterValues:s,selectedSheetId:o}),m=d?$1e({dashboardInputFilterValues:L1e({dashboardInputContext:d,cardId:e.id,shouldApplyDashboardFilters:h}),dashboardFilterValues:f,filters:r,selectedSheetId:o}):[...f||[],...(i==null?void 0:i[e.id])||[]],g=t||{},b=p.resolveFiltersFromInteractionStates(e,g,n),x=p.resolveCardConfigFromInteractionStates(e,g,b),y=MK(x,{cardType:e.type,dataSource:e.dataSource})||x,w=p.getFinalFilterGroupKeyFromInteractionStates(e,g,b)||"",v=(N=g==null?void 0:g[e.id])==null?void 0:N.appliedClickFilters,C=d?{controlValues:d.controlValues,controlDefinitions:d.controlDefinitions,cardControlDefinitions:d.cardControlDefinitions,controlBindings:d.controlBindings}:O1e({card:e,dashboardControls:a,dashboardControlValues:c,cardControlValues:u==null?void 0:u[e.id]});return{cardFilterValues:m,...C,resolvedFilters:b,finalConfig:x,queryRelevantConfig:y,finalFiltersKey:w,appliedClickFilters:v}}function L1e({dashboardInputContext:e,cardId:t,shouldApplyDashboardFilters:n}){if(n)return e.activeFilters;const r=new Set(e.inputs.filter(s=>s.kind==="filter"&&s.scope.kind==="cards"&&s.scope.cardIds.includes(t)&&(!s.compatibility||s.compatibility.source==="cardInlineFilter")).map(s=>s.kind==="filter"&&s.filter.id).filter(s=>!!s));return e.activeFilters.filter(s=>r.has(s.filterId))}function $1e({dashboardInputFilterValues:e,dashboardFilterValues:t,filters:n,selectedSheetId:r}){const s=[...e],o=new Set(s.map(i=>i.filterId));for(const i of z1e({dashboardFilterValues:t,filters:n,selectedSheetId:r}))o.has(i.filterId)||(s.push(i),o.add(i.filterId));return s}function z1e({dashboardFilterValues:e,filters:t,selectedSheetId:n}){if(!n)return[];const r=new Set((t||[]).map(s=>s.id));return(e||[]).filter(s=>s.filterId.endsWith(n)&&!r.has(s.filterId))}const ob=[],vI=[],wI={},T2=[];function B1e({cards:e,dashboard:t,filters:n,dashboardControls:r,filterValues:s,controlValues:o,dashboardInputValues:i,dashboardInputValuesAreAuthoritative:a,dashboardInlineFilterValuesMap:c,editorInlineFilterValuesMap:u,dashboardCardControlValuesMap:d,interactionStates:f,filteringCards:h,selectedSheetId:m,currentDashboardId:g,isVisualEditing:b,getCardFrame:x,lastRequestPayloadMap:y,documentState:w}){U1e(e,y);const v=H1e({cards:e,isVisualEditing:b,dashboardInlineFilterValuesMap:c,editorInlineFilterValuesMap:u});return e.map(C=>V1e({card:C,dashboard:t,filters:n,dashboardControls:r,filterValues:s,controlValues:o,dashboardInputValues:i,dashboardInputValuesAreAuthoritative:a,dashboardRuntimeInlineFilterValuesMap:v,editorInlineFilterValuesMap:u,dashboardCardControlValuesMap:d,interactionStates:f,filteringCards:h,selectedSheetId:m,currentDashboardId:g,getCardFrame:x,documentState:w}))}function V1e({card:e,dashboard:t,filters:n,dashboardControls:r,filterValues:s,controlValues:o,dashboardInputValues:i,dashboardInputValuesAreAuthoritative:a,dashboardRuntimeInlineFilterValuesMap:c,editorInlineFilterValuesMap:u,dashboardCardControlValuesMap:d,interactionStates:f,filteringCards:h,selectedSheetId:m,currentDashboardId:g,getCardFrame:b,documentState:x}){var T;const y=q1e({card:e,selectedSheetId:m,editorInlineFilterValuesMap:u,documentState:x}),v=!!((T=t.inputs)!=null&&T.length)||!!t.defaultInputValues?Nl({dashboard:t,sheetId:y.isDocumentSectionRuntime?y.documentSheetId:m,sheetKind:y.isDocumentSectionRuntime?"document":void 0,sectionId:y.isDocumentSectionRuntime?y.documentSectionId:void 0,card:e,runtimeValues:{dashboardInputValues:y.documentDashboardInputValues||i,dashboardInputValuesAreAuthoritative:!!y.documentDashboardInputValues||a,filterValues:s,controlValues:o,inlineFilterValuesMap:c,cardControlValuesMap:d},mode:y.isDocumentSectionEditorRuntime?"editor":y.isDocumentSectionRuntime?"print":"interactive"}):void 0,C=v&&v.inputs.length>0?v:void 0,N=y.isDocumentSectionRuntime&&!!C,k=y.isDocumentSectionRuntime&&!N?Y1e(e,y.documentControlDefinitions):e,_=W1e({card:e,documentRuntime:y,useResolvedDocumentInputs:N,dashboardRuntimeInlineFilterValuesMap:c}),j=V0({card:k,interactionStates:y.isDocumentSectionRuntime?{}:f,currentDashboardId:g,filters:y.isDocumentSectionRuntime?[]:n,filterValues:y.isDocumentSectionRuntime?[]:s,selectedSheetId:m,inlineFilterValuesMap:_,dashboardControls:y.isDocumentSectionRuntime?[]:r,dashboardControlValues:y.isDocumentSectionRuntime?{}:o,cardControlValuesMap:G1e({card:e,documentRuntime:y,useResolvedDocumentInputs:N,dashboardCardControlValuesMap:d}),dashboardInputContext:C}),E=b(e.id),I=(E==null?void 0:E.cards)||[];return{card:k,...j,interval:t1e((e==null?void 0:e.refreshInterval)||"0"),isFilteringCard:y.isDocumentSectionRuntime?!1:(h==null?void 0:h.some(D=>D.id===e.id))||!1,isSingleCardFrame:I.length===1,isDocumentSectionRuntime:y.isDocumentSectionRuntime,missingRequiredInputLabels:y.missingRequiredInputLabels,dashboardInputMissingRequiredLabels:(C==null?void 0:C.missingRequiredInputs.map(D=>D.label))||T2,queryFilterDefinitions:C?C.inputs.flatMap(D=>D.kind==="filter"?[D.filter]:[]):y.isDocumentSectionRuntime?[]:n||[]}}function H1e({cards:e,isVisualEditing:t,dashboardInlineFilterValuesMap:n,editorInlineFilterValuesMap:r}){return t?e.reduce((s,o)=>(s[o.id]=r[o.id]??n[o.id],s),{}):n}function U1e(e,t){if(!t)return;const n=new Set(e.map(r=>r.id));for(const r of t.keys())n.has(r)||t.delete(r)}function q1e({card:e,selectedSheetId:t,editorInlineFilterValuesMap:n,documentState:r}){const s=r.editedDocumentSectionCardId===e.id,o=r.isExplicitDocumentSectionRuntime||s,i=r.explicitDocumentSheetId||(s&&r.isDocumentSectionEditing?r.editorDocumentSheetId:void 0)||t||void 0,a=r.explicitDocumentSectionId||(s&&r.isDocumentSectionEditing?r.editorDocumentSectionId:void 0),c=r.isExplicitDocumentSectionRuntime?r.explicitDocumentFilterValues||ob:s&&r.editorDocumentFilterValues||ob,u=r.isExplicitDocumentSectionRuntime?r.explicitDocumentControlValues||wI:s&&r.editorDocumentControlValues||wI,d=r.isExplicitDocumentSectionRuntime?r.explicitDocumentControlDefinitions||vI:s&&r.editorDocumentControlDefinitions||vI,f=r.isExplicitDocumentSectionRuntime?r.explicitDocumentDashboardInputValues:void 0;return{isDocumentSectionRuntime:o,isDocumentSectionEditorRuntime:s,documentSheetId:i,documentSectionId:a,documentFilterValues:c,documentControlValues:u,documentControlDefinitions:d,documentDashboardInputValues:f,missingRequiredInputLabels:s&&r.editorMissingRequiredInputLabels||T2,editorFilterValues:s&&n[e.id]||ob}}function W1e({card:e,documentRuntime:t,useResolvedDocumentInputs:n,dashboardRuntimeInlineFilterValuesMap:r}){if(!t.isDocumentSectionRuntime)return r;if(n)return{};const s=[...t.editorFilterValues,...t.documentFilterValues];return s.length?{[e.id]:s}:{}}function G1e({card:e,documentRuntime:t,useResolvedDocumentInputs:n,dashboardCardControlValuesMap:r}){return t.isDocumentSectionRuntime?n?{}:Object.keys(t.documentControlValues).length>0?{[e.id]:t.documentControlValues}:{}:r}function Y1e(e,t){if(t.length===0)return e;const n=new Map;for(const r of e.controls||[])n.set(r.id,r);for(const r of t)n.set(r.id,r);return{...e,controls:Array.from(n.values())}}function K1e(e){return{databaseName:(e==null?void 0:e.lastSelectedDatabase)||"",schemaName:(e==null?void 0:e.lastSelectedSchema)||"",tableName:(e==null?void 0:e.lastSelectedTable)||"",datamodelId:(e==null?void 0:e.datamodelId)||""}}function FK(e){return e===FR?"":e}const Z1e=["table","detailTable"],D2=e=>Z1e.includes(e.type);function X1e(e){const{id:t,...n}=e;return n}function OK(e){if(!e)return;const{id:t,conditions:n,groups:r,...s}=e;return{...s,conditions:n.map(X1e),groups:r.map(o=>OK(o))}}function Q1e(e){return JSON.stringify(e&&{...e,filters:OK(e.filters)})}function J1e(e,t){const n=new Map;for(const s of(t==null?void 0:t.controlDefinitions)||[])n.set(s.id,s.type);for(const s of(t==null?void 0:t.cardControlDefinitions)||[])n.set(s.id,s.type);const r=Object.fromEntries(Object.entries(e||{}).map(([s,o])=>n.get(s)==="multi_enum"&&Array.isArray(o)?[s,[...o].sort((i,a)=>So.stableSerialize(i).localeCompare(So.stableSerialize(a)))]:[s,o]));return So.stableSerialize(r)}function eSe(e,{finalFiltersKey:t,selectedLensId:n,cardFilterValues:r,controlValues:s,controlDefinitions:o,cardControlDefinitions:i,controlBindings:a,queryRelevantConfig:c,resolvedPrimaryDateField:u}){var w,v;const{filterColumns:d,...f}=e.queryConfig||{},h=d==null?void 0:d.filter(C=>{var N,k;return(k=(N=e.queryConfig)==null?void 0:N.filters)==null?void 0:k.some(_=>_.filterColumnName===C.name)}),m=(e==null?void 0:e.sql)||"",g=FK((e==null?void 0:e.python)||""),b=["table","aggregateTable","pivotTable","detailTable","matrixTable"].includes(e.type)?"table":e.type==="kpi"?"kpi":"chart",x=D2(e)&&p.hasValidCardConfig(e.config)||D2(e)&&e.sql&&((v=(w=e.preferences)==null?void 0:w.tablePrefs)==null?void 0:v.enableDevModePagination),y=c||MK(e.config);return["query",e==null?void 0:e.id,b,m,g,n||"",JSON.stringify(r),J1e(s,{controlDefinitions:o,cardControlDefinitions:i}),l2({controlDefinitions:o,cardControlDefinitions:i,controlBindings:a}),So.stableSerialize(u??null),JSON.stringify(f),JSON.stringify(h),Q1e(y),t,x?JSON.stringify(e.paginationConfig):""]}function Qs(e){return typeof e=="string"?e.trim():""}function Xf(e){return Array.from(new Set(e.map(Qs).filter(Boolean)))}function Th(e){var t;return(t=e.candidateDatasetNames)!=null&&t.length?Xf(e.candidateDatasetNames):Xf([e.datasetName])}function YP(e,t){const n=e||[];for(const r of Th(t)){const s=n.find(i=>Qs(i.name)===r);if(s)return s;const o=n.filter(i=>$K(i).includes(r));if(o.length===1)return o[0]}}function LK(e,t){const n=Qs(t.name);if(!n)return[];const r=$K(t).filter(s=>YP(e,{datasetName:s})===t);return Xf([n,...r])}function $K(e){const t=Qs(e.table),n=Qs(e.schema),r=Qs(e.catalog)||Qs(e.database);return t?Xf([t,n?`${n}.${t}`:"",r?`${r}.${t}`:"",r&&n?`${r}.${n}.${t}`:""]):[]}function zK(e,t,n,r=[n]){if(!t||!n)return;const s=Xf(r);e.set(`${t}:${n}:${s.join("|")}`,{domainId:t,datasetName:n,candidateDatasetNames:s})}function BK(e,t,n){var r;for(const s of((r=e.dataSource)==null?void 0:r.selectedEntities)||[])(s==null?void 0:s.type)==="dataset"&&zK(n,Qs(s.domainId)||t,Qs(s.name))}function SI(e,t,n,r){const s=HK(e,t,r);s&&zK(n,s.domainId,s.datasetName,Th(s))}function tSe(e,t,n,r){var o;const s=(o=e.config)==null?void 0:o.joinPlan;if(s){SI(s.baseEntity,t,n,r);for(const i of s.joins||[])SI(i.source,t,n,r),SI(i.target,t,n,r)}}function nSe(e,t){var s;if(!e)return;const n=Qs((s=e.dataSource)==null?void 0:s.semanticDomainId),r=VK(e);BK(e,n,t),tSe(e,n,t,r)}function VK(e){var r;if(!e)return[];const t=new Map,n=Qs((r=e.dataSource)==null?void 0:r.semanticDomainId);return BK(e,n,t),Array.from(t.values())}function rSe(e,t){var s;const n=Qs((s=e==null?void 0:e.dataSource)==null?void 0:s.semanticDomainId);if(n)return n;const r=Array.from(new Set(t.map(o=>o.domainId))).filter(Boolean);return r.length===1?r[0]:""}function HK(e,t,n=[]){if(!e)return null;const r=Qs(e.domainId)||t,s=Qs(e.name),o=Qs(e.alias),i=Qs(e.id),a=n.find(f=>f.domainId===r&&f.datasetName===s),c=n.find(f=>f.domainId===r&&f.datasetName===o);let u;a||c?u=[(a||c).datasetName]:o&&(e.type==="table"||i===o)?u=[o,s]:u=[s,o];const d=Xf(u)[0]||"";return!r||!d?null:{domainId:r,datasetName:d,candidateDatasetNames:Xf(u)}}function UK(e){const t=new Map;for(const n of e||[])nSe(n,t);return Array.from(t.values())}function sSe(e){return UK(e?[e]:[])}function ay(e){return UK(e==null?void 0:e.cards)}function oSe(e,t){var s,o;if(!e)return null;const n=VK(e);if(n.length===1)return n[0];const r=rSe(e,n);return HK((o=(s=t||e.config)==null?void 0:s.joinPlan)==null?void 0:o.baseEntity,r,n)||null}function iSe(e,t){var n;if(!e||!t)return null;for(const r of e.sheets||[]){const s=(n=r.frames)==null?void 0:n.find(o=>o.id===t);if(s)return s}return null}function s4(e){return`${e.domainId}:${e.datasetName}:${Th(e).join("|")}`}function aSe(e,t){if(e.length!==t.length)return!1;const n=new Set(t.map(s4));return e.every(r=>n.has(s4(r)))}function lSe(e,t){return aSe(ay(e),ay(t))}function cSe(e){const t=e.sourceField||e.name,n=e.entityId||e.entityName||"",r=e.qualifiedEntityName,s=e.qualifiedFieldName||((r||e.entityId)&&e.name?`${r||e.entityId}.${e.name}`:"");return!n||!t||!e.name||!s||!e.entityId||!e.entityName||!e.entityType||!e.dataType?null:{sourceDataset:n,sourceField:t,name:e.name,qualifiedFieldName:s,qualifiedEntityName:r,entityId:e.entityId,entityName:e.entityName,entityType:e.entityType,dataType:e.dataType,dateFormat:e.dateFormat,customFormat:e.customFormat}}function uSe(e){var t;return((t=e==null?void 0:e.groupByColumns)==null?void 0:t.find(n=>p.getDataType(n.dataType||"")==="date"))||null}function dSe(e){var t,n;return(n=(t=e.dataSource)==null?void 0:t.semanticDomainId)!=null&&n.trim()?!0:sSe(e).length>0}function H0(e){var r;const t=M2(e);if(t.kind==="none")return null;if(t.kind==="explicit_temporal")return cSe(t.field);const n=e.semanticExecutionPayload.domainsById[t.datasetReference.domainId];if(!n)return null;for(const s of Th(t.datasetReference)){const o=(r=n.datasetsByName[s])==null?void 0:r.primaryDateField;if(o!==void 0)return o}return null}function M2(e){var o;const{card:t,cardConfig:n=t.config}=e;if((o=t.sql)!=null&&o.trim())return{kind:"none"};if(!dSe(t))return{kind:"none"};const r=uSe(n);if(r)return{kind:"explicit_temporal",field:r};const s=oSe(t,n);return s?{kind:"semantic_fallback",datasetReference:s}:{kind:"none"}}const KP="Global Date",fSe="__global_date__",hSe="__global_date__";function U0(e){return(e==null?void 0:e.kind)==="global-date"}function Xp(e){return e==null?void 0:e.find(t=>U0(t))}function mSe(){return typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?`global-date-filter:${globalThis.crypto.randomUUID()}`:`global-date-filter:${Date.now().toString(36)}:${Math.random().toString(36).slice(2)}`}function pSe(){return{kind:"global-date",id:mSe(),title:KP,column:fSe,dataType:"date",connectionId:hSe,sql:"",operation:"between",showLabel:!0,displayMode:"inherit",toolbarWidth:220}}function gSe(e,t){const n=e?p.getDashboardCards(e):[],r=n.filter(s=>H0({card:s,cardConfig:s.config,semanticExecutionPayload:t})!==null).map(s=>s.id);return{eligibleCardIds:r,eligibleCardCount:r.length,totalCardCount:n.length,ineligibleCardCount:Math.max(0,n.length-r.length),hasEligibleCards:r.length>0}}const bSe=new Set(["between","not between","=","!=",">",">=","<","<=","is null","is not null"]);function qK(e){return bSe.has(e)}function ZP(e){const{globalDateFilter:t,globalDateFilterValue:n,resolvedPrimaryDateField:r,semanticContext:s}=e;if(!t||!n||!r||!qK(n.operation))return null;const o=n;return{filterId:t.id,name:r.qualifiedFieldName||r.name,operation:o.operation,valueType:"date",values:o.operation==="is null"||o.operation==="is not null"?[]:o.values,dataType:r.dataType||"date",fieldMeta:{name:r.name,qualifiedFieldName:r.qualifiedFieldName,qualifiedEntityName:r.qualifiedEntityName,entityId:r.entityId,entityName:r.entityName,entityType:r.entityType,dataType:r.dataType,role:"groupby"},...s?{semanticContext:s}:{},...o.relativeMeta?{relativeMeta:o.relativeMeta}:{}}}function au(e){return typeof e=="string"?e.trim():""}function xSe(e){var t;return(((t=e.semanticContext)==null?void 0:t.selectedEntities)||[]).filter(n=>typeof n=="object"&&n!==null).filter(n=>n.type==="dataset").map(n=>{var r;return{domainId:au(n.domainId)||au((r=e.semanticContext)==null?void 0:r.semanticDomainId),datasetName:au(n.name),selectedEntityId:au(n.id)}}).filter(n=>n.domainId&&n.datasetName)}function ySe(e){var c,u,d,f,h;if(U0(e)||(c=e.sql)!=null&&c.trim())return null;const t=xSe(e),n=au((u=e.semanticContext)==null?void 0:u.semanticDomainId),r=au((d=e.fieldMeta)==null?void 0:d.entityId),s=au((f=e.fieldMeta)==null?void 0:f.entityName),o=au((h=e.fieldMeta)==null?void 0:h.entityType)==="dataset",i=t.find(m=>r&&m.selectedEntityId===r);if(i)return i;const a=t.find(m=>s&&m.datasetName===s&&(!n||m.domainId===n));return a||(t.length===1?t[0]:o&&s&&n?{domainId:n,datasetName:s}:null)}function vSe(e){var s,o;const{filter:t,semanticExecutionPayload:n}=e;if(!n)return null;const r=ySe(t);return r&&((o=(s=n.domainsById[r.domainId])==null?void 0:s.datasetsByName[r.datasetName])==null?void 0:o.primaryDateField)||null}function WK(e){const t=Xp(e.filters);return t?e.filterValues.filter(n=>n.filterId!==t.id):e.filterValues}function GK(e){const t=Xp(e.filters),n=WK({filters:e.filters,filterValues:e.filterValues});if(!t||U0(e.filter))return n;const r=e.filterValues.find(i=>i.filterId===t.id),s=vSe({filter:e.filter,semanticExecutionPayload:e.semanticExecutionPayload}),o=ZP({globalDateFilter:t,globalDateFilterValue:r,resolvedPrimaryDateField:s||void 0,semanticContext:e.filter.semanticContext});return o?[o,...n]:n}function Ek(e){const t=Xp(e.filters),n=t?e.cardFilterValues.find(i=>i.filterId===t.id):void 0,r=t?e.cardFilterValues.filter(i=>i.filterId!==t.id):e.cardFilterValues,s=e.resolvedPrimaryDateField??(e.semanticExecutionPayload?H0({card:e.card,cardConfig:e.cardConfig,semanticExecutionPayload:e.semanticExecutionPayload}):null),o=ZP({globalDateFilter:t,globalDateFilterValue:n,resolvedPrimaryDateField:s||void 0});return{cardFilterValues:o?[o,...r]:r,resolvedPrimaryDateField:s}}function YK(e){const t=Xp(e.filters),n=t?e.filterValues.find(s=>s.filterId===t.id):void 0,r=WK(e);return!t||!n||!qK(n.operation)?r:[{...n,filterId:t.id,name:t.title||t.column},...r]}function XP(e,t){const n=K1e(e),{cardFilterValues:r,resolvedPrimaryDateField:s}=Ek({card:e,cardConfig:t.queryRelevantConfig,filters:t.filters,cardFilterValues:t.cardFilterValues,resolvedPrimaryDateField:t.resolvedPrimaryDateField});return{queryKey:eSe(e,{finalFiltersKey:t.finalFiltersKey,selectedLensId:t.selectedLensId,cardFilterValues:r,controlValues:t.controlValues,controlDefinitions:t.controlDefinitions,cardControlDefinitions:t.cardControlDefinitions,controlBindings:t.controlBindings,queryRelevantConfig:t.queryRelevantConfig,resolvedPrimaryDateField:s||void 0}),tableConfig:n,requestPayloadBase:{cardId:e.id,sql:(e==null?void 0:e.sql)||"",python:FK(e.python||""),active_filters:r,controlValues:t.controlValues,controlDefinitions:t.controlDefinitions,cardControlDefinitions:t.cardControlDefinitions,controlBindings:t.controlBindings,cache_config:p.getCacheConfig({card:e}),queryConfig:e.queryConfig,tableConfig:n,cardType:e.type,cardTitle:e.title||"",cardConfig:t.queryRelevantConfig,cardDataSource:e.dataSource,resolvedPrimaryDateField:s||void 0,...e.type==="matrixTable"&&{matrixResponseMode:"grid"}}}}function QP(e){return{queryKey:["datasets",e.semanticDomainId],queryFn:()=>p.getRequest(`${e.apiServiceUrl}/v1/datasets`,e.authToken,{domainId:e.semanticDomainId})}}function wSe(e,t){const{tokenProps:n}=ht(),r=p.useDashboardStore(u=>u.authToken)||t,{refetch:s,isPending:o,data:i,isLoading:a,isError:c}=Dn({...e&&(r!=null&&r.accessToken)?QP({apiServiceUrl:n.apiServiceUrl,authToken:r.accessToken,semanticDomainId:e}):{queryKey:["datasets",e],queryFn:async()=>({datasets:[]})},enabled:!!(r!=null&&r.accessToken)&&!!e});return{isPending:o,error:c,datasets:(i==null?void 0:i.datasets)||[],isDatasetsLoading:a,isDatasetsError:c,refetchDatasets:s}}function SSe(e){return{domainsById:Object.fromEntries(Object.entries(e.domainsById||{}).map(([t,n])=>[t,{datasetsByName:{...n.datasetsByName}}]))}}function CSe(e){return{datasetsByName:Object.fromEntries((e||[]).flatMap(t=>LK(e,t).map(n=>[n,{primaryDateField:t.primaryDateField??null}])))}}function NSe(e){return Object.fromEntries(e.map(t=>[t.id,{status:"ready",errorMessage:null}]))}function o4(e,t){return`${e}:${t.join("|")}`}function i4(e,t){return(t==null?void 0:t[e.id])??e.config}function Tk(e,t={}){const n=p.useDashboardStore(f=>f.semanticExecutionPayload),r=p.useDashboardStore(f=>f.authToken),{tokenProps:s,authToken:o}=ht(),i=t.authority||"runtime",a=t.queryRelevantConfigsByCardId,c=r||o,u=S.useMemo(()=>{if(i!=="editor")return[];const f=new Set;for(const h of e){const m=M2({card:h,cardConfig:i4(h,a)});m.kind==="semantic_fallback"&&f.add(m.datasetReference.domainId)}return Array.from(f.values()).sort()},[i,e,a]),d=Wp({queries:u.map(f=>({...c!=null&&c.accessToken?QP({apiServiceUrl:s.apiServiceUrl,authToken:c.accessToken,semanticDomainId:f}):{queryKey:["datasets",f],queryFn:async()=>({datasets:[]})},enabled:i==="editor"&&!!(c!=null&&c.accessToken)&&!!s.apiServiceUrl&&!!f}))});return S.useMemo(()=>{var g;if(i!=="editor"||u.length===0)return{payload:n,cardStatesById:NSe(e)};const f=SSe(n),h=new Map(u.map((b,x)=>[b,d[x]])),m={};u.forEach((b,x)=>{var w,v;const y=(v=(w=d[x])==null?void 0:w.data)==null?void 0:v.datasets;y&&(f.domainsById[b]=CSe(y))});for(const b of e){const x=M2({card:b,cardConfig:i4(b,a)});if(x.kind!=="semantic_fallback"){m[b.id]={status:"ready",errorMessage:null};continue}if(!(c!=null&&c.accessToken)||!s.apiServiceUrl){m[b.id]={status:"loading",errorMessage:null};continue}let y={status:"ready",errorMessage:null};const{domainId:w}=x.datasetReference,v=Th(x.datasetReference),C=h.get(w);if(!C||C.isPending||C.isLoading)y={status:"loading",errorMessage:null};else if(C.isError){const N=C.error instanceof Error&&C.error.message?C.error.message:"Unknown error";y={status:"error",errorMessage:`Failed to load semantic dataset metadata for ${w} (${N})`}}else{const N=YP((g=C.data)==null?void 0:g.datasets,x.datasetReference);N?N.primaryDateFieldError&&(y={status:"error",errorMessage:`Failed to resolve primary date metadata for ${o4(w,v)} (${N.primaryDateFieldError.message})`}):y={status:"error",errorMessage:`Failed to resolve semantic dataset metadata for ${o4(w,v)}`}}m[b.id]=y}return{payload:f,cardStatesById:m}},[c==null?void 0:c.accessToken,e,i,d,a,n,u,s.apiServiceUrl])}function Dh(e){return e==="print"||e==="table-print"}function Dk(e){return e==="table-print"}function kSe(e){return e==="document"}function KK({displayMode:e,renderMode:t}){return kSe(t)&&Dh(e)}const CI=1e4,_Se=500,JP=250;function yp(e){return e.type==="table"||e.type==="detailTable"}function ZK(e){var t,n,r;return!!((t=e.sql)!=null&&t.trim()&&yp(e)&&((r=(n=e.preferences)==null?void 0:n.tablePrefs)!=null&&r.enableDevModePagination))}function mw(e){return e==="export-full-with-cap"?_Se:JP}function jSe({card:e,isTablePrintMode:t,isPrintDisplayMode:n,isDocumentSectionRuntime:r,documentTableDataPolicy:s}){var u,d;const o=r&&s!==void 0&&yp(e),i=t&&!o||e.type==="pivotTable"&&n,a=p.hasValidCardConfig(e.config)&&yp(e)&&!e.sql,c=o?ZK(e):!!(e.sql&&((d=(u=e.preferences)==null?void 0:u.tablePrefs)!=null&&d.enableDevModePagination));return!i&&(a||c)}const ISe={version:1},ESe={version:1,rules:[]};function Li(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function eF(e){return e.enabled!==!1}function TSe(e){return e.kind==="topBottom"||e.kind==="colorScale"&&e.range==="auto"||e.kind==="dataBar"&&e.range==="auto"}function DSe(e){return e.columnId}function dc(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function MSe(e){return e==null||e===""}function eS(e,t,n){return!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?0:n===t?e>=n?1:0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function ASe(e){switch(e){case"bold":return 700;case"semibold":return 600;case"medium":return 500;case"normal":return 400;default:return}}function A2(e){return e?XK({fontWeight:ASe(e.fontWeight),fontStyle:e.italic?"italic":void 0,color:e.textColor,backgroundColor:e.backgroundColor,textDecoration:e.textDecoration}):{}}function Mk(...e){return Object.assign({},...e.filter(t=>!!t).map(XK))}function XK(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const QK=["body","header","footer","subtotal","grandTotal"],RSe=["eq","neq","gt","gte","lt","lte"];function Ds(e){return typeof e=="string"&&e.trim()?e:void 0}function NI(e){return e!=null&&String(e).trim()!==""}function R2(e){return typeof e=="boolean"?e:void 0}function $d(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function pw(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):void 0}function Wb(e){if(!Li(e))return;const t=Ds(e.fontWeight),n=Ds(e.textDecoration),r={fontWeight:t==="normal"||t==="medium"||t==="semibold"||t==="bold"?t:void 0,italic:R2(e.italic),textColor:Ds(e.textColor),backgroundColor:Ds(e.backgroundColor),textDecoration:n==="none"||n==="underline"||n==="line-through"?n:void 0};return Object.values(r).some(s=>s!==void 0)?r:void 0}function vx(e){if(!Li(e))return ISe;const t={};if(Li(e.tableParts))for(const r of QK){const s=Wb(e.tableParts[r]);s&&(t[r]=s)}const n={};if(Li(e.columns))for(const[r,s]of Object.entries(e.columns)){if(!Li(s))continue;const o=Wb(s.body),i=Wb(s.header),a=Wb(s.footer);(o||i||a)&&(n[r]={body:o,header:i,footer:a})}return{version:1,...Object.keys(t).length?{tableParts:t}:{},...Object.keys(n).length?{columns:n}:{}}}function PSe(e){var n;return Li(e)?{level:e.level==="row"?"row":"cell",columnIds:pw(e.columnIds),conditionColumnId:Ds(e.conditionColumnId),applyToColumnIds:pw(e.applyToColumnIds),tableParts:(n=pw(e.tableParts))==null?void 0:n.filter(r=>QK.includes(r)),rowRoles:pw(e.rowRoles),depth:$d(e.depth),includeTotals:R2(e.includeTotals),includeSubtotals:R2(e.includeSubtotals)}:void 0}function FSe(e){if(!Li(e))return;const t=Wb(e),n=Ds(e.icon),r=Li(e.dataBar)?{color:Ds(e.dataBar.color)||"#3b82f6",showValue:e.dataBar.showValue!==!1}:void 0;return{...t,icon:n==="arrowUp"||n==="arrowDown"||n==="warning"||n==="check"||n==="x"?n:void 0,dataBar:r}}function OSe(e,t={}){if(!Li(e)||typeof e.kind!="string")return;const n=Ds(e.columnId);if(n)switch(e.kind){case"comparison":{const r=Ds(e.operator);return!RSe.includes(r)||!NI(e.value)&&!t.allowIncompleteDraft?void 0:{kind:"comparison",columnId:n,operator:r,value:e.value}}case"between":return(!NI(e.min)||!NI(e.max))&&!t.allowIncompleteDraft?void 0:{kind:"between",columnId:n,min:e.min,max:e.max,inclusive:e.inclusive!==!1};case"blank":return{kind:"blank",columnId:n,isBlank:e.isBlank!==!1};case"contains":return!Ds(e.value)&&!t.allowIncompleteDraft?void 0:{kind:"contains",columnId:n,value:Ds(e.value)??"",caseSensitive:e.caseSensitive===!0,exact:e.exact===!0};case"topBottom":{const r=$d(e.count);return{kind:"topBottom",columnId:n,direction:e.direction==="bottom"?"bottom":"top",count:r&&r>0?Math.floor(r):1}}case"colorScale":return{kind:"colorScale",columnId:n,range:e.range==="manual"?"manual":"auto",min:$d(e.min),mid:$d(e.mid),max:$d(e.max),colors:Li(e.colors)?{min:Ds(e.colors.min)||"#fee2e2",mid:Ds(e.colors.mid),max:Ds(e.colors.max)||"#dcfce7"}:{min:"#fee2e2",max:"#dcfce7"}};case"dataBar":return{kind:"dataBar",columnId:n,range:e.range==="manual"?"manual":"auto",min:$d(e.min),max:$d(e.max),color:Ds(e.color)||"#3b82f6",showValue:e.showValue!==!1};default:return}}function LSe(e){if(!Li(e))return;const t=Ds(e.id),n=PSe(e.target),r=e.enabled!==!1,s=OSe(e.condition,{allowIncompleteDraft:!r});if(!(!t||!n||!s))return{id:t,name:Ds(e.name),enabled:r,target:n,condition:s,style:FSe(e.style)}}function tF(e){return Li(e)?{version:1,rules:Array.isArray(e.rules)?e.rules.map(LSe).filter(n=>!!n):[]}:ESe}function JK(e){return!!(e&&e!=="default"&&e!=="nowrap")}function $Se({textWrap:e,appearanceWrapText:t}){const n=JK(e);return{appearanceWrapText:n?void 0:t,hasColumnTextWrapOverride:n}}function zSe(e){if(e==="wrap"||e==="preserve")return e;if(e==="truncate")return"nowrap"}function nF({tableWrapText:e,textWrap:t,appearanceWrapText:n,hasColumnTextWrapOverride:r=!1}){const s=zSe(t);return r&&s?s:typeof e=="boolean"?e?"wrap":"nowrap":typeof n=="boolean"?n?"wrap":"nowrap":s??"nowrap"}function BSe({tableWrapText:e,textWrap:t,appearanceWrapText:n,hasColumnTextWrapOverride:r}){return nF({tableWrapText:e,textWrap:t,appearanceWrapText:n,hasColumnTextWrapOverride:r})!=="nowrap"}function VSe(e){return e==="preserve"?"whitespace-pre-wrap break-words":e==="wrap"?"whitespace-normal break-words":"truncate"}function HSe(e){return e?"whitespace-normal break-normal":"truncate"}function USe(e,t){if(e==="preserve")return{whiteSpace:"pre-wrap",tabSize:4,overflow:"visible",textOverflow:void 0};const n=e==="wrap";return{whiteSpace:n?"normal":"nowrap",overflow:t==="clip"||n?"visible":"hidden",textOverflow:t==="ellipsis"&&!n?"ellipsis":void 0}}function qSe(e){var n,r;const t=e==null?void 0:e.columnSettings;return t?{textAlign:t.textAlign,...USe(nF({tableWrapText:(r=(n=e==null?void 0:e.tablePreferences)==null?void 0:n.tableStyle)==null?void 0:r.wrapText,textWrap:t.textWrap,appearanceWrapText:e==null?void 0:e.appearanceWrapText,hasColumnTextWrapOverride:e==null?void 0:e.hasColumnTextWrapOverride}),t.textOverflow)}:{}}function WSe(e){return e==="header"?"header":e==="footer"||e==="grandTotal"?"footer":"body"}function eZ(e){var i,a,c;const{formatting:t,compatibility:n,columnId:r,tablePart:s}=e,o=(a=(i=t.columns)==null?void 0:i[r])==null?void 0:a[WSe(s)];return Mk(qSe(n),A2((c=t.tableParts)==null?void 0:c[s]),A2(o))}function GSe(e){var r;const t=e.rule.condition;if(t.kind!=="colorScale"&&t.kind!=="dataBar"||t.range!=="auto")return;const n=(r=e.metadataRanges)==null?void 0:r[t.columnId];if(!((n==null?void 0:n.min)==null||(n==null?void 0:n.max)==null))return{ruleId:e.rule.id,status:"ready",source:"serverMetadata",range:{min:n.min,max:n.max,mid:n.mid??void 0}}}function YSe(e){return e.renderContext.kind==="interactiveDashboard"?{ruleId:e.rule.id,status:"ready",source:"loadedRows",rows:e.rows}:e.fullRows||e.renderContext.rowSource==="fullRows"?{ruleId:e.rule.id,status:"ready",source:"fullRows",rows:e.fullRows??e.rows}:{ruleId:e.rule.id,status:"unavailableForPrint",source:"none",reason:"missingFullRowsAndMetadata"}}function tZ(e){const t={};for(const n of e.rules)if(eF(n)){if(!TSe(n.condition)){t[n.id]={ruleId:n.id,status:"notNeeded",source:"none"};continue}t[n.id]=GSe({rule:n,metadataRanges:e.metadataRanges})??YSe({rule:n,rows:e.rows,fullRows:e.fullRows,renderContext:e.renderContext})}return{byRuleId:t}}function KSe(){return{numericRanges:{},topBottom:{},unavailableRuleIds:new Set}}function a4(e,t){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const s of e){const o=dc(s[t]);o!==null&&(n=Math.min(n,o),r=Math.max(r,o))}if(!(!Number.isFinite(n)||!Number.isFinite(r)))return{min:n,max:r}}function ZSe(e,t,n,r){const s=e.map(o=>({raw:o[t],numeric:dc(o[t])})).filter(o=>o.numeric!==null&&Number.isFinite(o.numeric)).sort((o,i)=>n==="top"?i.numeric-o.numeric:o.numeric-i.numeric).slice(0,r);return new Set(s.map(o=>o.raw))}function XSe(e){return(e==null?void 0:e.status)==="ready"&&(e.source==="fullRows"||e.source==="loadedRows")?e.rows:void 0}function kI(e,t,n){(n==null?void 0:n.status)==="unavailableForPrint"&&e.unavailableRuleIds.add(t)}function QSe(e){const t=e.rangePlan??tZ({rules:e.rules,rows:e.rows,fullRows:e.fullRows,metadataRanges:e.metadataRanges,renderContext:e.renderContext}),n=KSe();for(const r of e.rules){if(!eF(r))continue;const s=r.condition,o=DSe(s),i=t.byRuleId[r.id],a=XSe(i);if(s.kind==="colorScale"){if(s.range==="manual"){const u=s.min,d=s.max;typeof u=="number"&&typeof d=="number"&&(n.numericRanges[r.id]={min:u,max:d,mid:s.mid});continue}if((i==null?void 0:i.status)==="ready"&&i.source==="serverMetadata"){n.numericRanges[r.id]=i.range;continue}const c=a?a4(a,o):void 0;c?n.numericRanges[r.id]=c:kI(n,r.id,i);continue}if(s.kind==="dataBar"){if(s.range==="manual"){typeof s.min=="number"&&typeof s.max=="number"&&(n.numericRanges[r.id]={min:s.min,max:s.max});continue}if((i==null?void 0:i.status)==="ready"&&i.source==="serverMetadata"){n.numericRanges[r.id]=i.range;continue}const c=a?a4(a,o):void 0;c?n.numericRanges[r.id]=c:kI(n,r.id,i);continue}s.kind==="topBottom"&&(a?n.topBottom[r.id]=ZSe(a,o,s.direction,s.count):kI(n,r.id,i))}return n}function JSe(e,t,n){const r=dc(e),s=dc(n),o=r??String(e??""),i=s??String(n??"");switch(t){case"eq":return o===i;case"neq":return o!==i;case"gt":return o>i;case"gte":return o>=i;case"lt":return o<i;case"lte":return o<=i}}function eCe(e,t,n,r){var o;const s=t[e.columnId];switch(e.kind){case"comparison":return JSe(s,e.operator,e.value);case"between":{const i=dc(s),a=dc(e.min),c=dc(e.max);return i===null||a===null||c===null?!1:e.inclusive===!1?i>a&&i<c:i>=a&&i<=c}case"blank":return MSe(s)===e.isBlank;case"contains":{const i=String(s??""),a=e.value,c=e.caseSensitive?i:i.toLocaleLowerCase(),u=e.caseSensitive?a:a.toLocaleLowerCase();return e.exact?c===u:c.includes(u)}case"topBottom":return((o=n.topBottom[r])==null?void 0:o.has(s))??!1;case"colorScale":case"dataBar":return!n.unavailableRuleIds.has(r)}}function tCe(e,t){var n;return!((n=e.target.tableParts)!=null&&n.length)||e.target.tableParts.includes(t)}function nCe(e,t){var n,r;return e.target.level==="row"?!((n=e.target.applyToColumnIds)!=null&&n.length)||e.target.applyToColumnIds.includes(t):!((r=e.target.columnIds)!=null&&r.length)||e.target.columnIds.includes(t)}function rCe(e,t){if(e.condition.kind!=="colorScale")return;const n=e.condition,r=dc(t[n.columnId]);if(r!==null)return r}function sCe(e,t,n){return e.condition.kind!=="dataBar"?0:e.condition.range!=="auto"?eS(t,n.min,n.max):n.min>0&&n.max>0?eS(t,0,n.max):eS(t,n.min,n.max)}function oCe(e,t,n){var r,s;if(e.condition.kind==="colorScale"){const o=rCe(e,t),i=n.numericRanges[e.id];if(o===void 0||!i)return{};const a=eS(o,i.min,i.max),c=i.mid;return{cellStyle:{backgroundColor:c!==void 0&&e.condition.colors.mid?o<c?e.condition.colors.min:o===c?e.condition.colors.mid:e.condition.colors.max:a<.5?e.condition.colors.min:e.condition.colors.max}}}if(e.condition.kind==="dataBar"){const o=dc(t[e.condition.columnId]),i=n.numericRanges[e.id];return o===null||!i?{}:{overlay:{kind:"dataBar",color:e.condition.color,ratio:sCe(e,o,i),showValue:e.condition.showValue!==!1}}}return{cellStyle:Mk(A2(e.style),(r=e.style)!=null&&r.textColor?{color:e.style.textColor}:void 0),overlay:(s=e.style)!=null&&s.icon?{kind:"icon",icon:e.style.icon}:void 0}}function l4(e){const t={matchedRuleIds:[]};for(const n of e.formatting.rules){if(!eF(n)||!tCe(n,e.tablePart)||!nCe(n,e.columnId)||!eCe(n.condition,e.row,e.range,n.id))continue;const r=oCe(n,e.row,e.range),s=n.target.level==="row"?"rowStyle":"cellStyle";t[s]=Mk(t[s],r.cellStyle),r.overlay&&(t.overlay=r.overlay),t.matchedRuleIds.push(n.id)}return t}function iCe(e){return Mk(e.base,e.conditional.rowStyle,e.conditional.cellStyle)}function aCe(e){const t=vx(e.tablePreferences.baseFormatting),n=tF(e.tablePreferences.conditionalFormatting),r=e.tablePreferences.columnSettingsMap||{},o=e.tableKind==="table"?n:{...n,rules:[]},i=tZ({rules:o.rules,rows:e.rows,fullRows:e.fullRows,metadataRanges:e.metadataRanges,renderContext:e.renderContext});return{tableKind:e.tableKind,renderContext:e.renderContext,renderedColumnIds:e.renderedColumnIds,columns:e.columns,rows:e.rows,fullRows:e.fullRows,baseFormatting:t,conditionalFormatting:o,columnSettingsByColumnId:r,rangePlan:i,range:QSe({rules:o.rules,rows:e.rows,fullRows:e.fullRows,metadataRanges:e.metadataRanges,renderContext:e.renderContext,rangePlan:i})}}function lCe(e){if(!e.name)return;const t=e.entityName&&e.entityName!=="SEMAPHOR_CALCULATED_FIELD"?e.entityName:void 0;if(e.role==="metric"){let n="aggregate"in e&&typeof e.aggregate=="string"?e.aggregate:"metric";if("expression"in e&&typeof e.expression=="string"){const r=e.expression.match(/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i);n=r?r[1].toLowerCase():"expr"}else n=n.toLowerCase();return t&&t!==e.name?`${t}_${e.name}_${n}`:`${e.name}_${n}`}return t&&t!==e.name?`${t}_${e.name}`:e.name}function rF(e){return Array.from(new Set([e.id,e.alias,e.label,e.name,e.qualifiedFieldName,lCe(e)].map(t=>typeof t=="string"?t.trim():"").filter(Boolean)))}function sF(e){var s,o,i;const t=((s=e.config)==null?void 0:s.detailColumns)||[],n=((o=e.config)==null?void 0:o.groupByColumns)||[],r=((i=e.config)==null?void 0:i.metricColumns)||[];return[...t.map(a=>({...a,role:"detail"})),...n.map(a=>({...a,role:"groupby"})),...r.map(a=>({...a,role:"metric"}))].filter(a=>!!a.id)}function cCe(e,t){return t?!rF(e).some(n=>t[n]===!1):!0}function c4(e,t){for(const n of rF(e))if(t!=null&&t[n])return n;return e.label||e.name||e.alias||e.id}function Qp(e){var t;return e.type==="table"&&!((t=e.sql)!=null&&t.trim())&&!!e.config}function q0(e){var t,n,r,s;return((s=(r=(n=(t=e.preferences)==null?void 0:t.tablePrefs)==null?void 0:n.tableStyle)==null?void 0:r.totals)==null?void 0:s.enabled)===!0}function uCe(e){return Qp(e)?q0(e):!1}function dCe(e){var t,n,r,s,o,i;return Qp(e)?{...e,preferences:{...e.preferences,tablePrefs:{...(t=e.preferences)==null?void 0:t.tablePrefs,tableStyle:{...(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.tableStyle,totals:{...(i=(o=(s=e.preferences)==null?void 0:s.tablePrefs)==null?void 0:o.tableStyle)==null?void 0:i.totals,enabled:!0}}}}}:e}function nZ(e){if(!Qp(e)||!q0(e))return;const t=sF(e),n=[];let r=!1;for(const s of t){if(s.role!=="metric"&&!r){n.push({fieldId:s.id,role:s.role,behavior:"label",label:"Total"}),r=!0;continue}s.role==="metric"&&n.push({fieldId:s.id,role:s.role,behavior:"sum"})}return n.length?{source:"documentFlatTable",columns:n}:void 0}function fCe(e){var t,n,r,s,o,i;return{...e,preferences:{...e.preferences,tablePrefs:{...(t=e.preferences)==null?void 0:t.tablePrefs,tableStyle:{...(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.tableStyle,totals:{...(i=(o=(s=e.preferences)==null?void 0:s.tablePrefs)==null?void 0:o.tableStyle)==null?void 0:i.totals,enabled:!1}}}}}}const _I=[],jI=[],II={},u4=[];function rZ(e){return p.getRequestErrorSql(e)??(e&&typeof e=="object"&&"errorSql"in e&&typeof e.errorSql=="string"?e.errorSql:"")??""}function hCe(e){const t=p.getRequestErrorMessage(e,""),n=rZ(e);if(t)return{error:t,sql:n}}function d4(e){return{error:p.getRequestErrorMessage(e,"Unknown error",{preserveSyntheticMessage:!0}),sql:rZ(e)}}function mCe(e){if(!e)return"";let t=5381;for(let n=0;n<e.length;n+=1)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)}function pCe(e,t,n){var r;return t&&n||e.sql?e.connectionId:((r=e.dataSource)==null?void 0:r.connectionId)||e.connectionId}function tS(e,t){return p.hasValidCardConfig(e.config)?!((t==null?void 0:t.some(r=>r.sourceCardId===e.id))&&!(t==null?void 0:t.some(s=>s.sourceCardId===e.id&&s.filterSourceCard))):!1}function gCe({data:e,cardId:t,enabled:n,card:r,appliedClickFilters:s,lastDataMap:o}){var d;const i=t?o.get(t):void 0;if(e!==void 0)return t&&o.set(t,e),e;const a=!!((d=r==null?void 0:r.sql)!=null&&d.trim()),c=r?tS(r,s):!1;return(n||a||c)&&i!==void 0?i:(t&&o.delete(t),e)}function bCe(e,t={}){const{authToken:n,tokenProps:r}=ht(),s=p.useDashboardStore(P=>P.filteringCards),o=p.useDashboardStore(P=>P.isVisualEditing),i=p.useDashboardStore(P=>P.actions.getCardFrame),a=p.useDashboardStore(P=>P.authToken),{displayPreferences:c}=Cl(),u=p.useEditorStore(P=>P.isDevMode),d=p.useInteractionStore(P=>P.interactionStates),f=p.useDashboardStore(P=>P.dashboard.filters),h=p.useDashboardStore(P=>P.dashboard),m=p.useDashboardStore(P=>P.dashboard.controls),g=p.useDashboardStore(P=>P.filterValues),b=p.useDashboardStore(P=>P.controlValues),x=p.useDashboardStore(P=>P.selectedSheetId),y=p.useDashboardStore(P=>P.selectedLensId),w=p.useDashboardStore(P=>{var H;return(H=P.dashboard)==null?void 0:H.id}),v=p.useDashboardStore(P=>P.inlineFilterValuesMap),C=p.useDashboardStore(P=>P.cardControlValuesMap),N=p.useDashboardStore(P=>P.dashboardInputValues),k=p.useDashboardStore(P=>P.dashboardInputValuesAreAuthoritative),_=p.useEditorStore(P=>P.inlineFilterValuesMap),j=p.useEditorStore(P=>P.editorContext),E=(j==null?void 0:j.type)==="documentSection",I=t.runtimeContext==="documentSection",T=E&&j.documentFilterValues||_I,D=E&&j.documentControlValues||II,R=E&&j.documentControlDefinitions||jI,F=E&&j.missingRequiredInputLabels||u4,A=E?j.cardId:void 0,U=t.documentFilterValues||_I,$=t.documentControlValues||II,q=t.documentControlDefinitions||jI,W=t.documentDashboardInputValues,O=S.useMemo(()=>new Map,[]),Z=S.useMemo(()=>new Map,[]),Y=S.useMemo(()=>mCe((n==null?void 0:n.accessToken)||(a==null?void 0:a.accessToken)),[n==null?void 0:n.accessToken,a==null?void 0:a.accessToken]),M=S.useMemo(()=>B1e({cards:e,dashboard:h,filters:f,dashboardControls:m,filterValues:g,controlValues:b,dashboardInputValues:N,dashboardInputValuesAreAuthoritative:k,dashboardInlineFilterValuesMap:v,editorInlineFilterValuesMap:_,dashboardCardControlValuesMap:C,interactionStates:d,filteringCards:s,selectedSheetId:x,currentDashboardId:w,isVisualEditing:o,getCardFrame:i,lastRequestPayloadMap:Z,documentState:{isExplicitDocumentSectionRuntime:I,isDocumentSectionEditing:E,editedDocumentSectionCardId:A,editorDocumentSheetId:E?j.sheetId:void 0,editorDocumentSectionId:E?j.sectionId:void 0,explicitDocumentSheetId:t.documentSheetId,explicitDocumentSectionId:t.documentSectionId,editorDocumentFilterValues:T,editorDocumentControlDefinitions:R,editorDocumentControlValues:D,editorMissingRequiredInputLabels:F,explicitDocumentFilterValues:U,explicitDocumentControlDefinitions:q,explicitDocumentControlValues:$,explicitDocumentDashboardInputValues:W}}),[e,d,s,i,o,h,f,m,g,b,N,k,C,v,_,A,T,R,D,F,U,q,$,W,I,E,j,t.documentSheetId,t.documentSectionId,x,w,Z]),K=S.useMemo(()=>Object.fromEntries(M.map(({card:P,queryRelevantConfig:H})=>[P.id,H])),[M]),L=Tk(e,{authority:t.semanticPayloadAuthority||"runtime",queryRelevantConfigsByCardId:K}),z=L.payload,B=S.useMemo(()=>M.map(P=>{var dt,vt,st,Dt,Ee,Ze,Qe;const{card:H,cardFilterValues:G,controlValues:X,controlDefinitions:ne,cardControlDefinitions:de,controlBindings:he,resolvedFilters:pe,finalConfig:xe,queryRelevantConfig:se,finalFiltersKey:ge,appliedClickFilters:ie,interval:Te,isFilteringCard:re,isSingleCardFrame:me,isDocumentSectionRuntime:ve,missingRequiredInputLabels:J,dashboardInputMissingRequiredLabels:ee,queryFilterDefinitions:te}=P,ue=ee.length>0?ee:J,le=ve&&ue.length>0,ke=H0({card:H,cardConfig:se,semanticExecutionPayload:z}),Se=XP(H,{finalFiltersKey:ge,selectedLensId:y,cardFilterValues:G,controlValues:X,controlDefinitions:ne,cardControlDefinitions:de,controlBindings:he,queryRelevantConfig:se,filters:te,resolvedPrimaryDateField:ke}),oe=t.tableTotalsRequest??(ve?void 0:nZ(H)),je=oe?["tableTotals",JSON.stringify(oe)]:[],Ne=[...Se.queryKey,"auth",Y,...ve?[]:je],Oe=ve?[...Ne,"documentSection",...t.documentTableDataPolicy?["documentTableDataPolicy",t.documentTableDataPolicy]:[],...je]:Ne,Ge=o?{}:{refetchInterval:Te},Le=Se.tableConfig,Be=H.dataSource,Ke=L.cardStatesById[H.id]||{status:"ready",errorMessage:null},Ce=!!((dt=H==null?void 0:H.sql)!=null&&dt.trim()),Je=tS(H,ie),Pe=ve&&t.documentTableDataPolicy&&((vt=H.sql)==null?void 0:vt.trim())&&yp(H)&&!ZK(H),He=H!=null&&H.connectionId||(st=H==null?void 0:H.dataSource)!=null&&st.connectionId?pCe(H,o,u):void 0,tt=Dk(c.mode),Ae=jSe({card:H,isTablePrintMode:tt,isPrintDisplayMode:Dh(c.mode),isDocumentSectionRuntime:ve,documentTableDataPolicy:t.documentTableDataPolicy}),Ie=!le&&!Pe&&He&&(Ce||Je)?{connection_id:He,...Se.requestPayloadBase,cardDataSource:Be,...oe?{tableTotalsRequest:oe}:{},...Ae?{pagination:{page:((Dt=H.paginationConfig)==null?void 0:Dt.page)||1,pageSize:((Ee=H.paginationConfig)==null?void 0:Ee.pageSize)||((Qe=(Ze=H.preferences)==null?void 0:Ze.tablePrefs)==null?void 0:Qe.pageSize)||50}}:{}}:void 0,We=async()=>{if(le)return Z.delete(H.id),null;if(Ke.status==="error"&&Ke.errorMessage){if(Z.delete(H.id),!o)throw new Error(Ke.errorMessage);return{records:[],error:Ke.errorMessage,errorSql:""}}if(!He||!Ce&&!Je)return Z.delete(H.id),null;if(Pe)return Z.delete(H.id),{records:[],error:"Enable SQL pagination to use this SQL table in a paginated report.",errorSql:""};try{return Ie?(Z.set(H.id,Ie),await p.postRequest(`${r.apiServiceUrl}/v1/query`,(n==null?void 0:n.accessToken)||(a==null?void 0:a.accessToken)||"",Ie)):(Z.delete(H.id),null)}catch(nt){if(!o)throw nt;const yt=d4(nt);return{records:[],error:yt.error,errorSql:yt.sql}}},xt=()=>{var nt,yt;return!(n!=null&&n.accessToken)||le||re&&me?!1:(H!=null&&H.connectionId||(nt=H==null?void 0:H.dataSource)!=null&&nt.connectionId)&&((yt=H==null?void 0:H.sql)!=null&&yt.trim()||tS(H,ie))&&!o?!0:tS(H,ie)&&o&&!u?!(t.semanticPayloadAuthority==="editor"&&Ke.status==="loading"):!1},bt=xt();return bt||Z.delete(H.id),{card:H,queryKey:Oe,queryFn:We,config:Ge,isFilteringCard:re,isSingleCardFrame:me,appliedClickFilters:ie,tableConfig:Le,finalConfig:xe,resolvedFilters:pe,resolvedPrimaryDateField:ke,queryRequestPayload:Ie,isEnabled:xt,enabled:bt,isDocumentSectionQueryBlocked:le}}),[M,o,u,c.mode,y,z,L.cardStatesById,t.semanticPayloadAuthority,t.documentTableDataPolicy,t.tableTotalsRequest,Y,n==null?void 0:n.accessToken,a==null?void 0:a.accessToken,r.apiServiceUrl,Z]),V=Wp({queries:B.map(P=>({queryKey:P.queryKey,queryFn:P.queryFn,placeholderData:Sme,enabled:P.enabled,...P.config,retryOnMount:!1}))});return S.useMemo(()=>V.map((P,H)=>{var J,ee;const G=B[H],X=P.data,ne=G==null?void 0:G.card.id,de=(G==null?void 0:G.enabled)??!0,he=G!=null&&G.isDocumentSectionQueryBlocked?null:gCe({data:X,cardId:ne,enabled:de,card:G==null?void 0:G.card,appliedClickFilters:G==null?void 0:G.appliedClickFilters,lastDataMap:O});G!=null&&G.isDocumentSectionQueryBlocked&&ne&&O.delete(ne);const pe=P.error?d4(P.error):void 0,xe=hCe(he),se=(pe==null?void 0:pe.error)??(xe==null?void 0:xe.error)??(typeof(he==null?void 0:he.error)=="string"?he.error:void 0)??"",ge=(pe==null?void 0:pe.sql)??(xe==null?void 0:xe.sql)??(typeof(he==null?void 0:he.errorSql)=="string"?he.errorSql:void 0)??"",ie=he==null?void 0:he.pagination,Te=(J=he==null?void 0:he.metadata)!=null&&J.autoResolved?{resolvedJoinPlan:he.metadata.resolvedJoinPlan,autoResolved:he.metadata.autoResolved,relationshipsUsed:he.metadata.relationshipsUsed}:void 0,re=(ee=he==null?void 0:he.metadata)!=null&&ee.comparisonMetadata?he.metadata.comparisonMetadata:void 0,me=ne&&G!=null&&G.enabled?G.queryRequestPayload??Z.get(ne):void 0;return{...P,data:he,queryKey:(G==null?void 0:G.queryKey)??[],isFilteringCard:(G==null?void 0:G.isFilteringCard)??!1,isSingleCardFrame:(G==null?void 0:G.isSingleCardFrame)??!1,errorMessage:se,errorSql:ge,pagination:ie,autoJoinMetadata:Te,comparisonMetadata:re,queryRequestPayload:me,resolvedPrimaryDateField:G==null?void 0:G.resolvedPrimaryDateField}}),[V,B,O,Z])}function yc(e,t={}){const n=bCe([e],t);if(n.length===0)throw new Error("useDashboardFrameQuery returned no results for the supplied dashboard card.");return n[0]}function Ak(e){const t=p.useEditorStore(r=>r.editorContext),n=(t==null?void 0:t.type)==="documentSection"&&t.cardId===e.id?t:void 0;return yc(e,n?{semanticPayloadAuthority:"editor",runtimeContext:"documentSection",documentSheetId:n.sheetId,documentSectionId:n.sectionId,documentFilterValues:n.documentFilterValues,documentControlDefinitions:n.documentControlDefinitions,documentControlValues:n.documentControlValues}:{semanticPayloadAuthority:"editor"})}function Mc(e){const{tokenProps:t}=ht(),n=p.useDashboardStore(h=>h.authToken)||e,r=p.useEditorStore(h=>h.selectedConnectionId),s=p.useEditorStore(h=>{var m,g;return(g=(m=h==null?void 0:h.card)==null?void 0:m.dataSource)==null?void 0:g.connectionId}),o=r||s,{refetch:i,isPending:a,data:c,isLoading:u,isError:d}=Dn({queryKey:[t.project_id,"connections"],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/connections`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)}),f=c==null?void 0:c.connections.find(h=>h.id===o);return{isPending:a,error:d,connectionsData:c,connections:(c==null?void 0:c.connections)||[],isConnectionsLoading:u,isConnectionsError:d,refetchConnections:i,selectedConnection:f}}function sZ(e){const{connections:t}=Mc(e),n=p.useEditorStore(o=>o.selectedConnectionId),r=t.find(o=>o.id===n),s=r==null?void 0:r.capabilities.path.includes("schema");return{selectedConnection:r,capabilities:r==null?void 0:r.capabilities,connectionType:r==null?void 0:r.type,hasSchemaSupport:s}}const xCe=["#3b82f6","#10b981","#ef4444","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#84cc16","#06b6d4"];function Mh(){var n,r;const e=p.useDashboardStore.getState().themeStyle,t=(r=(n=e==null?void 0:e.chart)==null?void 0:n.dataset)==null?void 0:r.backgroundColor;return t&&t.length>0?t:xCe}function P2(e,t,n){var s;if((s=n==null?void 0:n.segments)!=null&&s[e])return n.segments[e];const r=Mh();return r[t%r.length]}function yCe(e,t){const n=Mh(),r=n[t%n.length];return e===r}function Jp(e){if(!e||e.length===0)return!1;const t=e[0];return Object.keys(t).some(r=>r.includes("(Previous)")||r.includes("(Last Year)")||r.includes("(Start)")||r.includes("(Target)"))}function vCe(e){return/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/.test(e)}function f4(e,t=1){if(!vCe(e)||t===1)return e;e=e.replace(/^#/,"");const n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16);return t=Math.min(Math.max(t,0),1),`rgba(${n}, ${r}, ${s}, ${t})`}function eg(e,t,n,r=1,s="none",o,i=!1,a=!1){var m,g,b,x;const c=n==null?void 0:n.datasetOptions,u=p.useDashboardStore.getState().themeStyle,d=(g=(m=u==null?void 0:u.chart)==null?void 0:m.dataset)==null?void 0:g.backgroundColor,f=(x=(b=u==null?void 0:u.chart)==null?void 0:b.dataset)==null?void 0:x.borderColor;return e.map((y,w)=>{var D,R,F;const v=c==null?void 0:c.find(A=>A.idx===w),C=(R=(D=n==null?void 0:n.colorConfig)==null?void 0:D.segments)==null?void 0:R[y],N=f4(C||(d==null?void 0:d[w%d.length]),r),k=C||(f==null?void 0:f[w%f.length]),_=C||(f==null?void 0:f[w%f.length]),j=t.some(A=>A._forecast),E={borderWidth:2,pointRadius:2,segment:{borderDash:A=>{const U=A.p0DataIndex;return t[U]._forecast?[2,4]:void 0},borderColor:A=>{const U=t[A.p0DataIndex]._forecast,$=p.useDashboardStore.getState().theme==="dark";return U?$?"white":"black":_}},pointBackgroundColor:A=>{const U=p.useDashboardStore.getState().theme==="dark";return t[A.dataIndex]._forecast?U?"white":"gray":k},pointBorderColor:A=>{const U=p.useDashboardStore.getState().theme==="dark";return t[A.dataIndex]._forecast?U?"white":"gray":k}},I={backgroundColor:A=>{var $;return(($=t[A.dataIndex])==null?void 0:$._forecast)?N+"20":N}};return{label:y.charAt(0).toUpperCase()+y.slice(1),data:t.map(A=>A[y]),...v,datalabels:n!=null&&n.dataLabelsConfig?v==null?void 0:v.datalabels:{...v==null?void 0:v.datalabels,color:wCe((F=v==null?void 0:v.datalabels)==null?void 0:F.align,N)},backgroundColor:i?f4(P2(y,w,n==null?void 0:n.colorConfig),r):N,borderColor:i?P2(y,w,n==null?void 0:n.colorConfig):_,...s==="line"&&j?E:s==="line"?{borderWidth:2,pointRadius:1.5}:{},...s==="bar"&&j?I:{},...a&&{stack:y.includes("(Previous)")||y.includes("(Last Year)")||y.includes("(Start)")||y.includes("(Target)")?"comparison":"current"}}})}function wCe(e,t){return e==="top"||e==="bottom"||e==="end"?n=>{var r;return p.getContrastColor(p.getCanvasBackgroundColor((r=n==null?void 0:n.chart)==null?void 0:r.canvas))}:n=>{var r;return p.getContrastColor(t,{baseColor:p.getCanvasBackgroundColor((r=n==null?void 0:n.chart)==null?void 0:r.canvas)})}}function oZ(e,t,n,r){var c,u,d,f;const s=p.useDashboardStore.getState().themeStyle,o=(u=(c=s==null?void 0:s.chart)==null?void 0:c.dataset)==null?void 0:u.backgroundColor,i=(f=(d=s==null?void 0:s.chart)==null?void 0:d.dataset)==null?void 0:f.borderColor;return e.map(h=>({label:h?h.charAt(0).toUpperCase()+h.slice(1):"",data:t.map(m=>m[h]),backgroundColor:t.map((m,g)=>{var b,x;return r&&((x=(b=n==null?void 0:n.colorConfig)==null?void 0:b.segments)!=null&&x[m[r]])?n.colorConfig.segments[m[r]]:(m==null?void 0:m._color)||(o==null?void 0:o[g%o.length])}),borderColor:t.map((m,g)=>{var b,x;return r&&((x=(b=n==null?void 0:n.colorConfig)==null?void 0:b.segments)!=null&&x[m[r]])?n.colorConfig.segments[m[r]]:(m==null?void 0:m._color)||(i==null?void 0:i[g%i.length])})}))}function SCe(e){const t=new Set;return e.forEach(n=>{Object.keys(n).forEach(r=>t.add(r))}),Array.from(t)}function CCe(e){let t=-1,n=0;return e.forEach((r,s)=>{const o=Object.keys(r).length;o>n&&(t=s,n=o)}),t}function ly(e){return e.length===1?[e[0]]:e.slice(1).filter(t=>!p.METADATA_KEYS.includes(t))}function lr(e){if(!e||e.length===0)return{keys:[],dimensionKeys:[],metricKeys:[]};const t=CCe(e),n=SCe(e),r=n.filter(o=>{var i,a,c,u,d,f,h,m;return!!(typeof((i=e==null?void 0:e[t])==null?void 0:i[o])&&typeof((a=e==null?void 0:e[t])==null?void 0:a[o])=="string"||typeof((c=e==null?void 0:e[0])==null?void 0:c[o])&&typeof((u=e==null?void 0:e[0])==null?void 0:u[o])=="string"||typeof((d=e==null?void 0:e[1])==null?void 0:d[o])&&typeof((f=e==null?void 0:e[1])==null?void 0:f[o])=="string"||typeof((h=e==null?void 0:e[2])==null?void 0:h[o])&&typeof((m=e==null?void 0:e[2])==null?void 0:m[o])=="string")});r.length===0&&r.push(n[0]);const s=n.filter(o=>{var i,a;return((i=e==null?void 0:e[t])==null?void 0:i[o])===+((a=e==null?void 0:e[t])==null?void 0:a[o])});return{keys:n,dimensionKeys:r,metricKeys:s}}function wa(e,t){var r;const n=(r=t==null?void 0:t.data)==null?void 0:r.datasets;return n&&n.length>0?e.map((o,i)=>({...o,...n==null?void 0:n[i],data:o.data,label:o.label})):e}function NCe(e,t="asc"){function n(r){return Object.entries(r).slice(1).reduce((i,[a,c])=>{const u=typeof c=="number"?c:parseFloat(c);return i+(isNaN(u)?0:u)},0)}return e.sort((r,s)=>{const o=n(r),i=n(s);return t==="asc"?o-i:i-o})}function W0({dataArray:e,groupKey:t,pivotKey:n,valueKey:r,sortChart:s}){const o=e.reduce((c,u)=>{const d=u[t],f=u[n],h=u[r];return c[d]||(c[d]={[t]:d}),c[d][f]=h,c},{});let i=Object.values(o);return s!=="none"&&s!==void 0&&(i=NCe(i,s)),i.map(c=>Object.fromEntries(Object.entries(c).filter(([u,d])=>d!==0)))}function Wr(e,t){var c;const n=p.useDashboardStore.getState().themeStyle,r=(c=n==null?void 0:n.chart)==null?void 0:c.options,s=dl({},e,t),o=$o(r),i=kCe(o,s);return dl({},i,e,t)}function h4(e,t){if(!e.scales||!t)return e;const n=Object.entries(e.scales).reduce((r,[s,o])=>{if(!o)return r;const i=t[s];return r[s]=i?dl({},i,o):o,r},{});return{...e,scales:n}}function kCe(e,t){if(!(e!=null&&e.scales))return e;const n=Object.entries(t.scales??{}).filter(([,s])=>!!s).map(([s])=>s);if(n.length===0){const{scales:s,...o}=e;return o}const r=n.reduce((s,o)=>{const i=e.scales[o];return i&&(s[o]=i),s},{});return{...e,scales:r}}function Ac(e,t){return e.map(n=>n[t]?n[t]:"BLANK")}function _Ce(e,t,n){if(!(e!=null&&e.sheets)||!t||!n)return null;const r=e.sheets.find(i=>i.id===t);if(!(r!=null&&r.frames))return null;const s=r.frames.find(i=>i.id===n);return s!=null&&s.cards&&(s.cards.find(i=>i.id===s.activeCardId)||s.cards[0])||null}function jCe(e,t){return!(e!=null&&e.sheets)||!t?null:e.sheets.find(n=>n.id===t)||null}function ICe(e){if(!(e!=null&&e.sheets))return null;for(const t of e.sheets)if(t!=null&&t.frames){for(const n of t.frames)if(n!=null&&n.cards){for(const r of n.cards)if(r!=null&&r.dataSource)return r.dataSource}}return null}function gw(e,t,n,r){if(e!=null&&e.dataSource)return e.dataSource;if(r){const s=_Ce(t,n,r);if(s!=null&&s.dataSource)return s.dataSource}return ICe(t)}function Rk(e){var $,q;const{frame:t,card:n,visualId:r,setFrame:s,setCard:o,setIsDevMode:i,initializeModeDrafts:a,setActiveTabCardId:c,updateDataSource:u,setQueryResultColumns:d,setSelectedConnectionId:f,setSelectedDatabaseName:h,setSelectedSchemaName:m,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:x,setInlineFilterValuesMap:y,setApplyFilters:w,setIsDashboardEditing:v,setIsVisualEditing:C,dashboard:N,selectedSheetId:k,selectedFrameId:_,filterValues:j,dataRecords:E,inlineFilterValuesMap:I,currentSelections:T={}}=e,D=jCe(N,k),R=p.getEditableSheetCalculatedFields(D,t.id),A=!!D&&!p.hasSheetCalculatedFieldStore(D)&&R.length===0?t.calculatedFields:D?R:t.calculatedFields,U={...t,...r?{visualId:r}:{},calculatedFields:A};if(s(U),o(n),a?a(n):i(!!n.sql),c&&t.activeCardId&&c(t.activeCardId),u&&N){const W=gw(n,N,k||null,_||null);W&&u(W)}if(f){const W=N?gw(n,N,k||null,_||null):null;f((n==null?void 0:n.connectionId)||(W==null?void 0:W.connectionId)||T.connectionId||"")}if(h&&b){const W=N?gw(n,N,k||null,_||null):null;n!=null&&n.datamodelId&&n.datamodelId!=="none"?(b(n.datamodelId),h("")):n!=null&&n.lastSelectedDatabase&&n.lastSelectedDatabase!=="none"?(h(n.lastSelectedDatabase),b("")):($=W==null?void 0:W.dbSelection)!=null&&$.database?(h(W.dbSelection.database),b("")):(h(T.databaseName||""),b(T.datamodelId||""))}if(m){const W=N?gw(n,N,k||null,_||null):null;m((n==null?void 0:n.lastSelectedSchema)||((q=W==null?void 0:W.dbSelection)==null?void 0:q.schema)||T.schemaName||"")}if(g&&g((n==null?void 0:n.lastSelectedTable)||T.tableName||""),d&&E){const{dimensionKeys:W}=lr(E);d(W)}if(x&&w&&j&&(x(j),w(!0)),y){const W=Object.fromEntries(t.cards.map(O=>[O.id,I==null?void 0:I[O.id]]).filter(O=>!!O[1]));y(W)}v(!0),C(!0)}function ECe(e){const t=p.useDashboardStore(q=>q.filterValues),n=p.useDashboardStore(q=>q.inlineFilterValuesMap),r=p.useDashboardStore(q=>q.isVisualEditing),s=p.useDashboardStore(q=>q.selectedSheetId),o=p.useDashboardStore(q=>q.selectedFrameId),i=p.useDashboardStore(q=>q.dashboard),{selectedConnection:a}=Mc(),{selectedDatabaseName:c,selectedSchemaName:u,selectedTableName:d,selectedDatamodelId:f}=mj(),{clearSelectedVisual:h}=vh(),m=p.useDashboardStore(q=>q.actions.setIsVisualEditing),g=p.useEditorStore(q=>q.actions.setFilterValues),b=p.useEditorStore(q=>q.actions.setApplyFilters),x=p.useEditorStore(q=>q.actions.setInlineFilterValuesMap),{setCard:y,setFrame:w,setQueryResultColumns:v,setActiveTabCardId:C,setIsDevMode:N,initializeModeDrafts:k,updateDataSource:_,clearEditorContext:j}=p.useEditorActions(),{setSelectedFrameId:E}=p.useDashboardActions(),I=p.useEditorStore(q=>q.actions.setSelectedConnectionId),T=p.useEditorStore(q=>q.actions.setSelectedDatamodelId),D=p.useEditorStore(q=>q.actions.setSelectedDatabaseName),R=p.useEditorStore(q=>q.actions.setSelectedSchemaName),F=p.useEditorStore(q=>q.actions.setSelectedTableName),A=e.cards.find(q=>q.id===e.activeCardId),{data:U}=yc(A);function $(q=!1){E(e.id),h(),j(),q||m(!r),Rk({frame:e,card:A,setFrame:w,setCard:y,setIsDevMode:N,initializeModeDrafts:k,setActiveTabCardId:C,updateDataSource:_,setQueryResultColumns:v,setSelectedConnectionId:I,setSelectedDatabaseName:D,setSelectedSchemaName:R,setSelectedTableName:F,setSelectedDatamodelId:T,setFilterValues:g,setInlineFilterValuesMap:x,setApplyFilters:b,setIsDashboardEditing:()=>{},setIsVisualEditing:()=>{},dashboard:i,selectedSheetId:s,selectedFrameId:o,filterValues:t,inlineFilterValuesMap:n,dataRecords:U==null?void 0:U.records,currentSelections:{connectionId:a==null?void 0:a.id,databaseName:c,schemaName:u,tableName:d,datamodelId:f}})}return{handleEditVisual:$,card:A,data:U}}const TCe={open:!1,frameId:null,cardId:null,triggerElement:null,anchorPosition:null,openPopover:()=>null,closePopover:()=>null},iZ=S.createContext(TCe);function DCe({children:e}){const[t,n]=S.useState(!1),[r,s]=S.useState(null),[o,i]=S.useState(null),[a,c]=S.useState(null),[u,d]=S.useState(null),m={open:t,frameId:r,cardId:o,triggerElement:a,anchorPosition:u,openPopover:(g,b,x)=>{const y=x.getBoundingClientRect(),w=x.closest('[role="dashboard-frame-container"], [role="card-frame"], .semaphor-card-frame');if(w){const v=w.getBoundingClientRect();d({left:v.right,top:v.top,width:1,height:v.height})}else d({left:y.right,top:y.top,width:1,height:y.height});s(g),i(b),c(x),n(!0)},closePopover:()=>{n(!1),setTimeout(()=>{s(null),i(null),c(null),d(null)},200)}};return l.jsx(iZ.Provider,{value:m,children:e})}function oF(){const e=S.useContext(iZ);if(e===void 0)throw new Error("useInteractionsPopover must be used within an InteractionsPopoverProvider");return e}const iF=1200;function aZ(e){if(["text-right","text-end","numeric","text-center"].some(r=>e.classList.contains(r)))return!0;const n=e.style.textAlign||e.style.getPropertyValue("text-align");return n==="right"||n==="center"}function fc(e){return e.map(t=>{var s;const n=((s=t.textContent)==null?void 0:s.trim())||"",r=t.getBoundingClientRect();return{text:n,colspan:t.colSpan||1,rowspan:t.rowSpan||1,className:t.className||void 0,columnId:t.getAttribute("data-column-id"),isHeader:t.tagName==="TH",isNumeric:aZ(t),isButton:!!t.querySelector("button"),measuredWidthPx:Number.isFinite(r.width)?Math.round(r.width):void 0}})}function aF(e){const t=Array.from(e.querySelectorAll("thead tr")),n=t[t.length-1];return(n?Array.from(n.querySelectorAll("th, td")):Array.from(e.querySelectorAll("tbody tr:first-child td, tbody tr:first-child th"))).map((s,o)=>{var a;const i=s.getBoundingClientRect();return{index:o,columnId:s.getAttribute("data-column-id"),label:((a=s.textContent)==null?void 0:a.trim())||`Column ${o+1}`,isNumeric:aZ(s),measuredWidthPx:Number.isFinite(i.width)?Math.round(i.width):void 0}})}function MCe(e){var a,c;if(!e)return null;const t=e.querySelector('table[data-table-type="data"]');if(!t)return null;const n=Array.from(t.querySelectorAll("thead tr")).map(u=>{const d=Array.from(u.querySelectorAll("th, td"));return{cells:fc(d)}}),r=Array.from(t.querySelectorAll("tbody tr")).map((u,d)=>{const f=Array.from(u.querySelectorAll("td, th"));return{type:"data",index:d,cells:fc(f)}}),s=t.querySelector("tfoot tr"),o=s?{cells:fc(Array.from(s.querySelectorAll("td, th")))}:null,i={totalRows:Number(t.getAttribute("data-total-rows")||r.length),totalColumns:Number(t.getAttribute("data-total-columns")||(((a=r[0])==null?void 0:a.cells.length)??0)),tableType:"data",hasGrandTotal:!!o,columnOrder:(((c=n[0])==null?void 0:c.cells)||[]).map(u=>u.columnId||u.text),columns:aF(t)};return{headers:n,rows:r,grandTotal:o,metadata:i}}function ACe(e){var a;if(!e)return null;const t=e.querySelector('table[data-table-type="aggregate"]');if(!t)return null;const n=Array.from(t.querySelectorAll("thead tr")).map(c=>{const u=Array.from(c.querySelectorAll("th, td"));return{cells:fc(u)}}),r=Array.from(t.querySelectorAll("tbody tr")).map((c,u)=>{const d=Array.from(c.querySelectorAll("td, th"));return{type:c.getAttribute("data-row-type")||void 0,subtotalLevel:c.getAttribute("data-subtotal-level"),index:u,cells:fc(d)}}),s=t.querySelector("tfoot tr"),o=s?{cells:fc(Array.from(s.querySelectorAll("td, th")))}:null,i={groupByCount:Number(t.getAttribute("data-group-by-count")||0),hasGrandTotal:t.getAttribute("data-has-grand-total")==="true",totalRows:r.length,tableType:"aggregate",columnOrder:(((a=n[0])==null?void 0:a.cells)||[]).map(c=>c.columnId||c.text),columns:aF(t)};return{headers:n,rows:r,grandTotal:o,metadata:i}}function RCe(e){var a;if(!e)return null;const t=e.querySelector('table[data-pivot-table="true"]');if(!t)return null;const n=Array.from(t.querySelectorAll("thead tr")).map((c,u)=>{const d=Array.from(c.querySelectorAll("th, td"));return{headerType:c.getAttribute("data-header-type"),headerRowIndex:Number(c.getAttribute("data-header-row-index")||u),repeatHeader:c.getAttribute("data-repeat-header")==="true",cells:fc(d)}}),r=Array.from(t.querySelectorAll("tbody tr")).map((c,u)=>{const d=Array.from(c.querySelectorAll("td, th"));return{type:c.getAttribute("data-row-type")||void 0,subtotalLevel:c.getAttribute("data-subtotal-level"),index:u,cells:fc(d)}}),s=t.querySelector("tfoot tr"),o=s?{cells:fc(Array.from(s.querySelectorAll("td, th")))}:null,i={rowLevels:t.getAttribute("data-row-levels"),pivotLevels:t.getAttribute("data-pivot-levels"),totalRows:r.length,hasGrandTotal:!!o,tableType:"pivot",columnOrder:(((a=n[n.length-1])==null?void 0:a.cells)||[]).map(c=>c.columnId||c.text),columns:aF(t)};return{headers:n,rows:r,grandTotal:o,metadata:i}}function lZ(e,t){if(!e||!t)return null;const n=document.querySelector(`[role="card-frame"][data-frame-id="${e}"]`);if(!n)return null;switch(t){case"aggregateTable":return ACe(n);case"pivotTable":return RCe(n);case"table":case"detailTable":default:return MCe(n)}}function PCe(e){var h;const{cardType:t,reportTitle:n,tableStructure:r,filterLine:s,timezone:o,pageSize:i,orientation:a,wideTableStrategy:c,password:u,rowCount:d}=e,f=d??((h=r==null?void 0:r.rows)==null?void 0:h.length)??0;return{cardType:t,reportTitle:n,tableStructure:r,filterLine:s,timezone:o,pageSize:i,orientation:a,wideTableStrategy:c,password:u,rowCount:f}}function vp(e){return e.replace(/"/g,"")}function m4(e){return e.replace(/"/g,"")}function ud(e,t){return e?e.filter(n=>n.sheetId&&n.sheetId!==t?!1:n.applyToSheetIds!==void 0?n.applyToSheetIds.includes(t):n.excludeSheetIds!==void 0?!n.excludeSheetIds.includes(t):!0):[]}function FCe(e,t){return t?e.endsWith(t):e.startsWith("summary:")}function cy(e,t,n,r={}){if(!(t!=null&&t.length))return[];const s=r.includeCardScoped??!0,o=ud(e,n).filter(a=>{var c,u;return s||!((c=a.applyToCardIds)!=null&&c.length)&&!((u=a.excludeCardIds)!=null&&u.length)}),i=new Set(o.map(a=>a.id));return t.filter(a=>i.has(a.filterId)||FCe(a.filterId,n))}function OCe(e,t,n,r){const s=ud(e,r),o=n?m4(n):void 0;return s.find(i=>vp(i.column)===vp(t)&&(!i.qualifiedTableName||!o||m4(i.qualifiedTableName)===o))}function lF({dashboard:e,filterValues:t,selectedSheetId:n,sheetSelection:r="current",dashboardControlValues:s,cardControlValuesMap:o}){const i=e==null?void 0:e.filters,a=n??null,c=r==="all"?Array.from(new Map(((e==null?void 0:e.sheets)||[]).flatMap(f=>cy(i,t,f.id).map(h=>[h.filterId,h]))).values()):cy(i,t,a),u={...s||{}},d=r==="all"?p.getDashboardCardEntries({sheets:(e==null?void 0:e.sheets)||[]}):a?p.getDashboardCardEntries({sheets:(e==null?void 0:e.sheets)||[]}).filter(f=>f.sheet.id===a):[];for(const f of d)Object.assign(u,(o==null?void 0:o[f.card.id])||{});return{selectedSheetId:a,filterValues:c,controlValues:u}}function cZ({dashboard:e,cardId:t,interactionStates:n,currentDashboardId:r,semanticExecutionPayload:s,filters:o,filterValues:i,inlineFilterValuesMap:a,dashboardControls:c,dashboardControlValues:u,cardControlValuesMap:d}){if(!e)return null;const f=p.findCardLocationById(e,t);if(!f)return null;const h=V0({card:f.card,interactionStates:n,currentDashboardId:r??e.id,filters:o,filterValues:i,selectedSheetId:f.sheet.id,inlineFilterValuesMap:a,dashboardControls:c,dashboardControlValues:u,cardControlValuesMap:d}),{cardFilterValues:m}=Ek({card:f.card,cardConfig:h.queryRelevantConfig,filters:o,cardFilterValues:h.cardFilterValues,semanticExecutionPayload:s});return{card:f.card,sheetId:f.sheet.id,queryContext:{...h,cardFilterValues:m}}}function uZ({dashboardInputValues:e,dashboard:t,filterValues:n,sheetId:r,cardId:s,sectionId:o,sheetKind:i}){var u;if(!((u=t.inputs)!=null&&u.length))return e;const a=new Map(n.map(d=>[d.filterId,d]));let c=e||{};for(const d of t.inputs){if(d.kind!=="filter"||!xp(d,{sheetId:r,cardId:s,sectionId:o,sheetKind:i}))continue;const f=a.get(d.filter.id),h=f?p.createFilterDashboardInputSlot(f):void 0;c=p.setDashboardInputRuntimeSlot(c,d,{sheetId:r,cardId:s,sectionId:o},h||{status:"cleared"})}return c}function vu({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,mode:o,runtimeValues:i,generatedAt:a,timezone:c}){const u=nS({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,mode:o,runtimeValues:i,timezone:c});return{context:u,snapshot:{...t?{sheetId:t}:{},...n!=null&&n.id?{cardId:n.id}:{},mode:o,dashboardInputValues:$Ce({inputs:u.inputs,context:u,sheetId:t,cardId:n==null?void 0:n.id,sectionId:r}),generatedAt:a,timezone:c}}}function dZ({sectionIds:e,...t}){const n=new Set,r=s=>{for(const o of s.missingRequiredInputs)n.add(o.label)};r(nS(t));for(const s of e)r(nS({...t,sectionId:s}));for(const{sectionId:s,card:o}of mZ(t.dashboard,t.sheetId,e))r(nS({...t,sectionId:s,card:o}));return Array.from(n)}function fZ({sheetIds:e,sheetKind:t="dashboard",...n}){const r=e.map(a=>vu({...n,sheetId:a,sheetKind:t})),s=e.flatMap(a=>LCe(n.dashboard,a).map(c=>vu({...n,sheetId:a,card:c,sheetKind:t}))),o=r[0]||s[0]||vu({...n,sheetKind:t}),i=pZ(...r.map(a=>a.snapshot.dashboardInputValues),...s.map(a=>a.snapshot.dashboardInputValues));return{context:o.context,snapshot:{...e.length===1?{sheetId:e[0]}:{},mode:n.mode,dashboardInputValues:i,generatedAt:n.generatedAt,timezone:n.timezone}}}function LCe(e,t){var i;const n=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),r=[],s=new Set,o=a=>{!(a!=null&&a.id)||s.has(a.id)||(s.add(a.id),r.push(a))};for(const a of(n==null?void 0:n.cards)||[])o(a);for(const a of(n==null?void 0:n.frames)||[])for(const c of(a==null?void 0:a.cards)||[])o(c);return r}function hZ({sectionIds:e,...t}){const n=vu(t),r=e.map(o=>vu({...t,sectionId:o})),s=mZ(t.dashboard,t.sheetId,e).map(({sectionId:o,card:i})=>vu({...t,sectionId:o,card:i}));return{...n,snapshot:{...n.snapshot,dashboardInputValues:pZ(n.snapshot.dashboardInputValues,...r.map(o=>o.snapshot.dashboardInputValues),...s.map(o=>o.snapshot.dashboardInputValues))}}}function mZ(e,t,n){var i,a;const r=new Set(n),s=(i=e.sheets)==null?void 0:i.find(c=>c.id===t);return(((a=s==null?void 0:s.document)==null?void 0:a.sections)||[]).flatMap(c=>c.id&&r.has(c.id)&&c.card?[{sectionId:c.id,card:c.card}]:[])}function $Ce({inputs:e,context:t,sheetId:n,cardId:r,sectionId:s}){const o=new Map(t.resolvedInputs.map(a=>[a.id,a]));let i={};for(const a of e){const c=o.get(a.id),u=(c==null?void 0:c.slot)||{status:"cleared"};i=p.setDashboardInputRuntimeSlot(i,a,{sheetId:n,cardId:r,sectionId:s},u)}return p.compactDashboardInputValues(i)}function zCe(e){return e==="document"||e==="visual"?"export":"print"}function nS({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,mode:o,runtimeValues:i,timezone:a}){return Nl({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,runtimeValues:i,mode:zCe(o),timezone:a})}function pZ(...e){const t={};for(const n of e)n.shared&&(t.shared={...t.shared,...n.shared}),EI(t,"bySheetId",n.bySheetId),EI(t,"byCardId",n.byCardId),EI(t,"byDocumentSectionId",n.byDocumentSectionId);return p.compactDashboardInputValues(t)}function EI(e,t,n){if(n){e[t]||(e[t]={});for(const[r,s]of Object.entries(n))e[t][r]={...e[t][r],...s}}}const p4=700,BCe=/https?:\/\/\S+/g,VCe=/([?&](?:authToken|accessToken|refreshToken|token|password)=)[^&\s]+/gi,Pk="max-h-[12.5rem] min-w-0 max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words pr-2 [overflow-wrap:anywhere]";function g4(e){if(!e||typeof e!="object")return;const{error:t,message:n,detail:r}=e;for(const s of[t,n,r])if(typeof s=="string"&&s.trim())return s.trim()}async function gZ(e){const t=`PDF request failed: ${e.status} ${e.statusText}`.trim(),n=e.headers.get("content-type")||"";try{if(n.includes("application/json")){const s=await e.json();return g4(s)||t}const r=await e.text();if(!r.trim())return t;try{return g4(JSON.parse(r))||r.trim()}catch{return r.trim()}}catch{return t}}function Fk(e,t="Failed to download PDF"){let n;if(e instanceof Error&&e.message.trim()?n=e.message.trim():typeof e=="string"&&e.trim()&&(n=e.trim()),!n)return t;const r=n.replace(VCe,"$1[redacted]").replace(BCe,"[print render URL redacted]");return r.length<=p4?r:`${r.slice(0,p4).trimEnd()}...`}function bZ(e,t){t.controlDefinitions!==void 0&&e.set("controlDefinitions",JSON.stringify(t.controlDefinitions)),t.cardControlDefinitions!==void 0&&e.set("cardControlDefinitions",JSON.stringify(t.cardControlDefinitions)),t.controlBindings!==void 0&&e.set("controlBindings",JSON.stringify(t.controlBindings))}async function cF(e,t){var i;if(p.useDashboardStore.getState().isDownloadingPdf)return;const r=Intl.DateTimeFormat().resolvedOptions().timeZone,s=new URLSearchParams;s.set("theme",t.theme),s.set("filterValues",JSON.stringify(t.filterValues)),s.set("controlValues",JSON.stringify(t.defaultControlValues||{})),s.set("dashboardId",t.dashboardId),bZ(s,{controlDefinitions:t.controlDefinitions,cardControlDefinitions:t.cardControlDefinitions,controlBindings:t.controlBindings}),t.selectedSheetId!==void 0&&s.set("selectedSheetId",t.selectedSheetId),t.dashboardTitle!==void 0&&s.set("dashboardTitle",t.dashboardTitle),t.visualId!==void 0&&s.set("visualId",t.visualId),t.frameId!==void 0&&s.set("frameId",t.frameId),t.tableMode!==void 0&&s.set("tableMode",String(t.tableMode)),t.pdfMode&&s.set("pdfMode",t.pdfMode),t.documentSheetId&&s.set("documentSheetId",t.documentSheetId),t.documentInputValues&&s.set("documentInputValues",JSON.stringify(t.documentInputValues)),t.dashboardInputExecutionSnapshot&&s.set("dashboardInputExecutionSnapshot",JSON.stringify(t.dashboardInputExecutionSnapshot)),t.cardType!==void 0&&s.set("cardType",t.cardType),t.cardTitle!==void 0&&s.set("reportTitle",t.cardTitle),t.password&&s.set("password",t.password),t.pageSize&&s.set("pageSize",t.pageSize),t.orientation&&s.set("orientation",t.orientation),s.set("wideTableStrategy",t.wideTableStrategy||"auto"),t.filterLine&&s.set("filterLine",t.filterLine),s.set("timezone",t.timezone||r),t.sheetSelection&&s.set("sheetSelection",t.sheetSelection),t.expandedState&&Object.keys(t.expandedState).length>0&&s.set("expandedState",JSON.stringify(t.expandedState));const o=`${e}/v1/pdf?params=${encodeURIComponent(s.toString())}`;p.useDashboardStore.setState({isDownloadingPdf:!0});try{const a=await fetch(o,{method:"GET",headers:{Authorization:`Bearer ${(i=t.authToken)==null?void 0:i.accessToken}`}});if(!a.ok)throw new Error(await gZ(a));const c=await a.json();if(c.error)throw new Error(c.error);if(!c.url)throw new Error("No download URL received from server");const u=c.url,d=document.createElement("a");return d.href=u,d.download=t.fileName,d.click(),p.useDashboardStore.setState({isDownloadingPdf:!1}),c}catch(a){throw p.useDashboardStore.setState({isDownloadingPdf:!1}),a}}function HCe(e,t){var u,d;const n=p.useDashboardStore.getState(),r=(u=n.dashboard)==null?void 0:u.id,s=n.theme,o=(t==null?void 0:t.sheetSelection)==="all"&&n.dashboard?{...n.dashboard,sheets:p.getDashboardExportSheets(n.dashboard.sheets)}:n.dashboard,a=t&&Object.prototype.hasOwnProperty.call(t,"selectedSheetId")&&(t==null?void 0:t.sheetSelection)==="all"?t.selectedSheetId??void 0:(t==null?void 0:t.selectedSheetId)??n.selectedSheetId,c=lF({dashboard:o,filterValues:n.filterValues,selectedSheetId:a,sheetSelection:t==null?void 0:t.sheetSelection,dashboardControlValues:n.controlValues,cardControlValuesMap:n.cardControlValuesMap});return{authToken:e,dashboardId:r||"",theme:s||"light",filterValues:c.filterValues,defaultControlValues:c.controlValues,controlDefinitions:((d=n.dashboard)==null?void 0:d.controls)||[]}}function xZ(){var e,t;return!!((t=(e=p.useDashboardStore.getState().dashboard)==null?void 0:e.inputs)!=null&&t.length)}function F2(e){const t=p.useDashboardStore.getState();return{dashboardInputValues:(e==null?void 0:e.dashboardInputValues)??t.dashboardInputValues,filterValues:(e==null?void 0:e.filterValues)??t.filterValues,controlValues:t.controlValues,inlineFilterValuesMap:t.inlineFilterValuesMap,cardControlValuesMap:t.cardControlValuesMap}}function yZ(){return typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0}function UCe({selectedSheetId:e,sheetSelection:t}){const n=p.useDashboardStore.getState();if(!n.dashboard||!xZ())return;const r=t==="all"?p.getDashboardExportSheets(n.dashboard.sheets).map(s=>s.id):e?[e]:[];if(r.length!==0)return fZ({dashboard:n.dashboard,sheetIds:r,sheetKind:"dashboard",mode:"dashboard",runtimeValues:F2(),generatedAt:new Date().toISOString(),timezone:yZ()}).snapshot}function qCe(e,t){const n=p.useDashboardStore.getState();if(!n.dashboard||!xZ())return;const r=p.findFrameCardLocationById(n.dashboard,e),s=(r==null?void 0:r.sheet.id)||n.selectedSheetId||void 0,o=F2(),i=(t==null?void 0:t.filterValues)!==void 0?uZ({dashboardInputValues:o.dashboardInputValues,dashboard:n.dashboard,filterValues:t.filterValues,sheetId:s,cardId:r==null?void 0:r.card.id,sheetKind:"dashboard"}):o.dashboardInputValues;return vu({dashboard:n.dashboard,sheetId:s,card:(r==null?void 0:r.card)||null,sheetKind:"dashboard",mode:"visual",runtimeValues:F2({dashboardInputValues:i,filterValues:t==null?void 0:t.filterValues}),generatedAt:new Date().toISOString(),timezone:yZ()}).snapshot}function WCe(e,t){var f,h,m,g,b;const n=p.useDashboardStore.getState(),r=(f=n.dashboard)==null?void 0:f.title,s=(t==null?void 0:t.sheetSelection)||"current",o=t&&Object.prototype.hasOwnProperty.call(t,"selectedSheetId"),i=(t==null?void 0:t.selectedSheetId)===null||t==null?void 0:t.selectedSheetId,a=n.selectedSheetId===null?void 0:n.selectedSheetId,c=o&&(t==null?void 0:t.sheetSelection)==="all"?i:i??a,u=(m=(h=n.dashboard)==null?void 0:h.sheets)==null?void 0:m.find(x=>x.id===c);if(s==="current"&&p.isDocumentSheet(u))throw new Error("Document sheets cannot be exported through dashboard PDF export");if(s==="all"&&((b=(g=n.dashboard)==null?void 0:g.sheets)!=null&&b.length)&&p.getDashboardExportSheets(n.dashboard.sheets).length===0)throw new Error("No dashboard sheets are available for dashboard PDF export");return{...HCe(e,{selectedSheetId:c,sheetSelection:s}),dashboardTitle:r||"",...c!==void 0?{selectedSheetId:c}:{},dashboardInputExecutionSnapshot:UCe({selectedSheetId:c,sheetSelection:s})}}function GCe(e,t="current"){return WCe(e,{sheetSelection:t,...t==="all"?{selectedSheetId:void 0}:{}})}async function vZ(e,t,n,r,s){const{theme:o,filterValues:i,dashboardTitle:a,selectedSheetId:c,dashboardId:u,defaultControlValues:d,controlDefinitions:f,dashboardInputExecutionSnapshot:h}=GCe(t,r),m=`${a}-${new Date().toISOString()}.pdf`;await cF(e,{authToken:t,theme:o,filterValues:i,defaultControlValues:d,controlDefinitions:f,dashboardId:u,fileName:m,password:n,dashboardTitle:a,selectedSheetId:c,sheetSelection:r,dashboardInputExecutionSnapshot:h,expandedState:s,wideTableStrategy:"auto"})}async function uF(e,t,n){var a,c,u;const r=p.useDashboardStore.getState(),s=(a=r.dashboard)==null?void 0:a.id;if(!s)throw new Error("Dashboard ID is required for document PDF export");const o=((c=n.title)==null?void 0:c.trim())||"Document",i=`${o}-${new Date().toISOString()}.pdf`;await cF(e,{authToken:t,theme:r.theme||"light",filterValues:[],defaultControlValues:{},dashboardId:s,fileName:i,password:n.password,dashboardTitle:((u=r.dashboard)==null?void 0:u.title)||"",selectedSheetId:n.sheetId,pdfMode:"document",documentSheetId:n.sheetId,...n.inputSnapshot?{dashboardInputExecutionSnapshot:{...n.inputSnapshot,sheetId:n.inputSnapshot.sheetId||n.sheetId}}:{},...n.inputValues?{documentInputValues:{...n.inputValues,sheetId:n.sheetId}}:{},pageSize:n.pageSize,orientation:n.orientation,cardTitle:o,timezone:n.timezone,wideTableStrategy:"auto"})}function wZ(e,t,n,r,s){var b,x,y,w,v;const o=p.useDashboardStore.getState(),i=(b=o.dashboard)==null?void 0:b.id,a=o.theme,c=o.selectedSheetId,u=(s==null?void 0:s.filterValues)??o.filterValues,d=o.dashboard?p.findFrameCardLocationById(o.dashboard,t):void 0,f=(d==null?void 0:d.sheet.id)||c||void 0,h=cZ({dashboard:o.dashboard,cardId:t,interactionStates:p.useInteractionStore.getState().interactionStates,currentDashboardId:(x=o.dashboard)==null?void 0:x.id,semanticExecutionPayload:o.semanticExecutionPayload,filters:(y=o.dashboard)==null?void 0:y.filters,filterValues:u,inlineFilterValuesMap:o.inlineFilterValuesMap,dashboardControls:(w=o.dashboard)==null?void 0:w.controls,dashboardControlValues:o.controlValues,cardControlValuesMap:o.cardControlValuesMap}),m=lF({dashboard:o.dashboard,filterValues:u,selectedSheetId:f,sheetSelection:"current",dashboardControlValues:o.controlValues}),g=(h==null?void 0:h.queryContext.controlValues)||m.controlValues;return{authToken:e,dashboardId:i||"",theme:a||"light",filterValues:(s==null?void 0:s.filterValues)??((h==null?void 0:h.queryContext.cardFilterValues)||m.filterValues),defaultControlValues:g,controlDefinitions:(h==null?void 0:h.queryContext.controlDefinitions)||((v=o.dashboard)==null?void 0:v.controls)||[],cardControlDefinitions:(h==null?void 0:h.queryContext.cardControlDefinitions)||(d==null?void 0:d.card.controls)||[],controlBindings:(h==null?void 0:h.queryContext.controlBindings)||(d==null?void 0:d.card.controlBindings)||[],selectedSheetId:f||"",cardId:t||"",frameId:n||"",cardTitle:r||"",dashboardInputExecutionSnapshot:qCe(t,s)}}async function SZ(e,t,n,r,s,o,i,a,c,u,d,f){const h=wZ(t,n,r,s,d!==void 0?{filterValues:d}:void 0),{theme:m,dashboardId:g,defaultControlValues:b,controlDefinitions:x,cardControlDefinitions:y,controlBindings:w,selectedSheetId:v,dashboardInputExecutionSnapshot:C}=h,N=d??h.filterValues,k=`${s}-${new Date().toISOString()}.pdf`,_=["table","aggregateTable","pivotTable","detailTable"].includes(o||"");return cF(e,{authToken:t,cardTitle:s,theme:m,filterValues:N,defaultControlValues:b,controlDefinitions:x,cardControlDefinitions:y,controlBindings:w,dashboardId:g,fileName:k,password:i,selectedSheetId:v,visualId:n,frameId:r,tableMode:_,cardType:o,pageSize:a,orientation:c,filterLine:u,dashboardInputExecutionSnapshot:C,expandedState:f,wideTableStrategy:"auto"})}async function YCe(e,t,n,r,s,o,i,a,c,u,d,f){await SZ(e,t,n,r,s,o,i,a,c,u,d,f)}async function KCe(e,t,n,r,s,o,i,a,c,u,d,f){return SZ(e,t,n,r,s,o,i,a,c,u,d,f)}async function ZCe(e,t,n,r,s,o,i){if(!(t!=null&&t.accessToken))throw new Error("Missing auth token for PDF export");let a=i.tableStructure??null;if(!a&&o!=="pivotTable"&&(a=lZ(r,o)),o==="pivotTable"&&!a)throw new Error("Pivot fast-path PDF requires a prebuilt table structure");if(!a||a.rows.length===0)throw new Error("Unable to build table structure for fast-path PDF");const c=Intl.DateTimeFormat().resolvedOptions().timeZone,u=PCe({cardType:o,reportTitle:s,tableStructure:a,filterLine:i.filterLine,timezone:c,pageSize:i.pageSize,orientation:i.orientation,wideTableStrategy:i.wideTableStrategy||"auto",password:i.password,rowCount:i.rowCount??a.rows.length});if(u.rowCount>iF)throw new Error("Fast-path row count exceeds threshold");const d=await fetch(`${e}/v1/pdf`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify(u)});if(!d.ok)throw new Error(await gZ(d));const f=await d.json();if(f.error)throw new Error(f.error);if(!(f!=null&&f.url))throw new Error("Fast-path PDF response missing download URL");const h=document.createElement("a");return h.href=f.url,h.download=`${s}-${new Date().toISOString()}.pdf`,h.click(),f}async function XCe(e,t,n,r,s,o,i={}){if(!["table","aggregateTable","pivotTable","detailTable"].includes(o))return{success:!1};const a=i.rowCount??0;if(a&&a>iF)return{success:!1};if(p.useDashboardStore.getState().isDownloadingPdf)return{success:!1};p.useDashboardStore.setState({isDownloadingPdf:!0});try{return{success:!0,layoutApplied:(await ZCe(e,t,n,r,s,o,i)).layoutApplied??null}}catch(u){return console.warn("Fast-path PDF generation failed, falling back to URL path",u),{success:!1}}finally{p.useDashboardStore.setState({isDownloadingPdf:!1})}}var Ok="Checkbox",[QCe]=p.createContextScope(Ok),[JCe,dF]=QCe(Ok);function eNe(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:o,form:i,name:a,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=p.useControllableState({prop:n,defaultProp:s??!1,onChange:c,caller:Ok}),[g,b]=Q.useState(null),[x,y]=Q.useState(null),w=Q.useRef(!1),v=g?!!i||!!g.closest("form"):!0,C={checked:h,disabled:o,setChecked:m,control:g,setControl:b,name:a,form:i,value:d,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:wu(s)?!1:s,isFormControl:v,bubbleInput:x,setBubbleInput:y};return l.jsx(JCe,{scope:t,...C,children:tNe(f)?f(C):r})}var CZ="CheckboxTrigger",NZ=Q.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:o,value:i,disabled:a,checked:c,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:h,isFormControl:m,bubbleInput:g}=dF(CZ,e),b=p.useComposedRefs(s,d),x=Q.useRef(c);return Q.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const w=()=>f(x.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[o,f]),l.jsx(p.Primitive.button,{type:"button",role:"checkbox","aria-checked":wu(c)?"mixed":c,"aria-required":u,"data-state":EZ(c),"data-disabled":a?"":void 0,disabled:a,value:i,...r,ref:b,onKeyDown:p.composeEventHandlers(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:p.composeEventHandlers(n,y=>{f(w=>wu(w)?!0:!w),g&&m&&(h.current=y.isPropagationStopped(),h.current||y.stopPropagation())})})});NZ.displayName=CZ;var fF=Q.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:o,required:i,disabled:a,value:c,onCheckedChange:u,form:d,...f}=e;return l.jsx(eNe,{__scopeCheckbox:n,checked:s,defaultChecked:o,disabled:a,required:i,onCheckedChange:u,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:h})=>l.jsxs(l.Fragment,{children:[l.jsx(NZ,{...f,ref:t,__scopeCheckbox:n}),h&&l.jsx(IZ,{__scopeCheckbox:n})]})})});fF.displayName=Ok;var kZ="CheckboxIndicator",_Z=Q.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,o=dF(kZ,n);return l.jsx(p.Presence,{present:r||wu(o.checked)||o.checked===!0,children:l.jsx(p.Primitive.span,{"data-state":EZ(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});_Z.displayName=kZ;var jZ="CheckboxBubbleInput",IZ=Q.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:i,required:a,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:m}=dF(jZ,e),g=p.useComposedRefs(n,m),b=p.usePrevious(o),x=p.useSize(r);Q.useEffect(()=>{const w=h;if(!w)return;const v=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(v,"checked").set,k=!s.current;if(b!==o&&N){const _=new Event("click",{bubbles:k});w.indeterminate=wu(o),N.call(w,wu(o)?!1:o),w.dispatchEvent(_)}},[h,b,o,s]);const y=Q.useRef(wu(o)?!1:o);return l.jsx(p.Primitive.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??y.current,required:a,disabled:c,name:u,value:d,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});IZ.displayName=jZ;function tNe(e){return typeof e=="function"}function wu(e){return e==="indeterminate"}function EZ(e){return wu(e)?"indeterminate":e?"checked":"unchecked"}const Mn=Q.forwardRef(({className:e,...t},n)=>{const r=t.checked==="indeterminate";return l.jsx(fF,{ref:n,className:p.cn("peer h-4 w-4 shrink-0 rounded-control border border-input bg-background ring-offset-background transition-colors hover:border-muted-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",e),...t,children:l.jsx(_Z,{className:p.cn("flex items-center justify-center text-current"),children:r?l.jsx(Yl,{className:"h-3 w-3",strokeWidth:3}):l.jsx(p.Check,{className:"h-3 w-3",strokeWidth:3})})})});Mn.displayName=fF.displayName;var hF="Radio",[nNe,TZ]=p.createContextScope(hF),[rNe,sNe]=nNe(hF),DZ=Q.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:s=!1,required:o,disabled:i,value:a="on",onCheck:c,form:u,...d}=e,[f,h]=Q.useState(null),m=p.useComposedRefs(t,x=>h(x)),g=Q.useRef(!1),b=f?u||!!f.closest("form"):!0;return l.jsxs(rNe,{scope:n,checked:s,disabled:i,children:[l.jsx(p.Primitive.button,{type:"button",role:"radio","aria-checked":s,"data-state":PZ(s),"data-disabled":i?"":void 0,disabled:i,value:a,...d,ref:m,onClick:p.composeEventHandlers(e.onClick,x=>{s||c==null||c(),b&&(g.current=x.isPropagationStopped(),g.current||x.stopPropagation())})}),b&&l.jsx(RZ,{control:f,bubbles:!g.current,name:r,value:a,checked:s,required:o,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});DZ.displayName=hF;var MZ="RadioIndicator",AZ=Q.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...s}=e,o=sNe(MZ,n);return l.jsx(p.Presence,{present:r||o.checked,children:l.jsx(p.Primitive.span,{"data-state":PZ(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:t})})});AZ.displayName=MZ;var oNe="RadioBubbleInput",RZ=Q.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...s},o)=>{const i=Q.useRef(null),a=p.useComposedRefs(i,o),c=p.usePrevious(n),u=p.useSize(t);return Q.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const g=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(g)}},[c,n,r]),l.jsx(p.Primitive.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:a,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});RZ.displayName=oNe;function PZ(e){return e?"checked":"unchecked"}var iNe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Lk="RadioGroup",[aNe]=p.createContextScope(Lk,[p.createRovingFocusGroupScope,TZ]),FZ=p.createRovingFocusGroupScope(),OZ=TZ(),[lNe,cNe]=aNe(Lk),LZ=Q.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:s,value:o,required:i=!1,disabled:a=!1,orientation:c,dir:u,loop:d=!0,onValueChange:f,...h}=e,m=FZ(n),g=p.useDirection(u),[b,x]=p.useControllableState({prop:o,defaultProp:s??null,onChange:f,caller:Lk});return l.jsx(lNe,{scope:n,name:r,required:i,disabled:a,value:b,onValueChange:x,children:l.jsx(p.Root,{asChild:!0,...m,orientation:c,dir:g,loop:d,children:l.jsx(p.Primitive.div,{role:"radiogroup","aria-required":i,"aria-orientation":c,"data-disabled":a?"":void 0,dir:g,...h,ref:t})})})});LZ.displayName=Lk;var $Z="RadioGroupItem",zZ=Q.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...s}=e,o=cNe($Z,n),i=o.disabled||r,a=FZ(n),c=OZ(n),u=Q.useRef(null),d=p.useComposedRefs(t,u),f=o.value===s.value,h=Q.useRef(!1);return Q.useEffect(()=>{const m=b=>{iNe.includes(b.key)&&(h.current=!0)},g=()=>h.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),l.jsx(p.Item,{asChild:!0,...a,focusable:!i,active:f,children:l.jsx(DZ,{disabled:i,required:o.required,checked:f,...c,...s,name:o.name,ref:d,onCheck:()=>o.onValueChange(s.value),onKeyDown:p.composeEventHandlers(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:p.composeEventHandlers(s.onFocus,()=>{var m;h.current&&((m=u.current)==null||m.click())})})})});zZ.displayName=$Z;var uNe="RadioGroupIndicator",BZ=Q.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,s=OZ(n);return l.jsx(AZ,{...s,...r,ref:t})});BZ.displayName=uNe;var VZ=LZ,HZ=zZ,dNe=BZ;const Sa=Q.forwardRef(({className:e,...t},n)=>l.jsx(VZ,{className:p.cn("grid gap-2",e),...t,ref:n}));Sa.displayName=VZ.displayName;const ws=Q.forwardRef(({className:e,...t},n)=>l.jsx(HZ,{ref:n,className:p.cn("aspect-square h-4 w-4 rounded-full border border-input bg-background text-foreground transition-colors hover:border-muted-foreground focus-visible:outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-foreground",e),...t,children:l.jsx(dNe,{className:"flex items-center justify-center",children:l.jsx(KR,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ws.displayName=HZ.displayName;const fNe=p.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),mF=Q.forwardRef(({className:e,variant:t,...n},r)=>l.jsx("div",{ref:r,role:"alert",className:p.cn(fNe({variant:t}),e),...n}));mF.displayName="Alert";const UZ=Q.forwardRef(({className:e,...t},n)=>l.jsx("h5",{ref:n,className:p.cn("mb-1 font-medium leading-none tracking-tight",e),...t}));UZ.displayName="AlertTitle";const pF=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("text-sm [&_p]:leading-relaxed",e),...t}));pF.displayName="AlertDescription";function qZ(e){const t=e.split(".");return t[t.length-1].replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")}function b4(e){const{name:t,operation:n,values:r,valueType:s}=e,o=qZ(t);if(!r||r.length===0)return n==="is null"?`${o} is empty`:n==="is not null"?`${o} is not empty`:"";const i=a=>{if(s==="date"&&a){const c=new Date(a);if(!isNaN(c.getTime()))return c.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}return String(a)};switch(n){case"=":return`${o}: ${i(r[0])}`;case"!=":return`${o} ≠ ${i(r[0])}`;case">":return`${o} > ${i(r[0])}`;case"<":return`${o} < ${i(r[0])}`;case">=":return`${o} ≥ ${i(r[0])}`;case"<=":return`${o} ≤ ${i(r[0])}`;case"between":case"not between":{const a=`${i(r[0])} - ${i(r[1])}`;return n==="between"?`${o}: ${a}`:`${o} not in ${a}`}case"in":{if(r.length===1)return`${o}: ${i(r[0])}`;const a=r.map(i).join(", ");return`${o}: ${a}`}case"not in":{const a=r.map(i).join(", ");return`${o} not in (${a})`}case"like":return`${o} contains "${r[0]}"`;case"not like":return`${o} doesn't contain "${r[0]}"`;default:return`${o}: ${r.map(i).join(", ")}`}}function WZ(e){if(!e||e.length===0)return"";const t=new Map;e.forEach(r=>{const s=t.get(r.name)||[];s.push(r),t.set(r.name,s)});const n=[];return t.forEach((r,s)=>{if(r.length===1){const o=b4(r[0]);o&&n.push(o)}else{const o=qZ(s),i=r.map(a=>b4(a).replace(`${o}: `,"").replace(`${o} `,"")).filter(Boolean);i.length>0&&n.push(`${o}: ${i.join(" and ")}`)}}),n.join(" | ")}function GZ(e,t){const n=typeof e.decimalPlaces=="number",r=typeof e.minimumFractionDigits=="number"?e.minimumFractionDigits:n?e.decimalPlaces:t.min,s=typeof e.maximumFractionDigits=="number"?e.maximumFractionDigits:n?e.decimalPlaces:t.max;return{minimumFractionDigits:r,maximumFractionDigits:Math.max(r,s)}}function rC(e,t){const n=GZ(e,t),r=typeof e.suffix=="string"&&e.suffix.length>0;return{style:"decimal",locale:e.locale,currency:e.currency,minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits,useGrouping:e.useGrouping,useSuffix:!!(e.useSuffix&&!r),prefix:e.prefix,suffix:e.suffix,negativeInParentheses:e.negativeInParentheses,multiplyBy:e.multiplyBy,percentValueMode:e.percentValueMode}}function In(e,t="auto",n={}){switch(t==="auto"&&(t=bNe(e,n)),t){case"number":return YZ(e,n);case"currency":return KZ(e,n);case"percent":return hNe(e,n);case"date":return mNe(e,n);case"scientific":return pNe(e,n);case"duration":return gNe(e,n);default:return String(e)}}function YZ(e,t={}){return e<0&&!!t.prefix&&!t.negativeInParentheses?`-${On.formatNumber(Math.abs(e),rC(t,{min:0,max:0}))}`:On.formatNumber(e,rC(t,{min:0,max:0}))}function KZ(e,t={}){return On.formatCurrency(e,{...rC(t,{min:2,max:2}),style:"currency",currency:t.currency||"USD"})}function hNe(e,t={}){const n=GZ(t,{min:1,max:1}),s=typeof t.multiplyBy=="number"&&Number.isFinite(t.multiplyBy)?t.multiplyBy:t.percentValueMode==="whole"?1:100,o=e*s;return On.formatNumber(o,{locale:t.locale,minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits,useGrouping:t.useGrouping,prefix:t.prefix,suffix:t.suffix||"%",negativeInParentheses:t.negativeInParentheses,useSuffix:!1})}function mNe(e,t={}){const{locale:n="en-US"}=t;try{const r=new Date(e);return isNaN(r.getTime())?String(e):new Intl.DateTimeFormat(n,{dateStyle:"short"}).format(r)}catch{return String(e)}}function pNe(e,t={}){return On.formatScientific(e,rC(t,{min:2,max:2}))}function gNe(e,t={}){return On.formatDuration(e,{inputUnit:t.durationInputUnit,outputStyle:t.durationDisplayStyle,largestUnit:t.durationLargestUnit,smallestUnit:t.durationSmallestUnit,maxUnits:t.durationMaxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeInParentheses})}function bNe(e,t){return t.currency?"currency":typeof e=="string"&&!isNaN(Date.parse(e))?"date":"number"}function xNe(e,t={}){return n=>In(n,e,t)}function uy({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:s="",locale:o="en-US"}){if(s){const i=KZ(e,{currency:s,decimalPlaces:t,locale:o,useSuffix:n&&!r});return n&&r?`${i}${r}`:i}return YZ(e,{decimalPlaces:t,useSuffix:n&&!r,suffix:r,locale:o})}const yNe=e=>{e=e.replace("#","");const t=Number.parseInt(e.substr(0,2),16),n=Number.parseInt(e.substr(2,2),16),r=Number.parseInt(e.substr(4,2),16);return(.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"},Ba=()=>({urlTemplate:"{value}",labelType:"value",staticLabel:"",labelColumn:"",openInNewTab:!0}),Js=()=>({type:"none",inheritMetricFormat:!0,textAlign:"left",width:150,minWidth:50,maxWidth:500,textOverflow:"ellipsis",textWrap:"default",numberFormat:{style:"decimal",currency:"USD",locale:"en-US",minimumFractionDigits:0,maximumFractionDigits:2,useGrouping:!0,percentValueMode:"whole",showDataBar:!1,showHeatmap:!1,dataBarColor:"#3b82f6",dataBarMinValue:void 0,dataBarMaxValue:void 0},dateFormat:{format:"MM/dd/yyyy",useCustomFormat:!1,customFormat:"yyyy-MM-dd'T'HH:mm:ss",useRelativeTime:!1,timezone:"auto",sourceTimezone:"auto"},linkFormat:Ba(),colorRanges:[]});function gF(e,t,n,r){return t&&t!=="auto"?t:e?n:r||n}const sC=e=>!e||e==="auto"?"local time":{"America/New_York":"Eastern Time","America/Chicago":"Central Time","America/Denver":"Mountain Time","America/Los_Angeles":"Pacific Time","Europe/London":"London Time","Europe/Paris":"Central European Time","Asia/Tokyo":"Japan Time","Asia/Shanghai":"China Time",UTC:"UTC"}[e]||e;function wx(e){return e?Object.entries(e).some(([t,n])=>n==null||n===""?!1:t==="type"?n!=="auto":!0):!1}function ZZ(e){if(e)return e.alias||e.label||e.name}function Du(e,t){var r;return(((r=e==null?void 0:e.config)==null?void 0:r.metricColumns)||[]).find(s=>{const o=ZZ(s);return t.metricId&&s.id===t.metricId||t.metricAlias&&o===t.metricAlias||t.metricAlias&&s.alias===t.metricAlias||t.columnId&&o===t.columnId||t.columnId&&s.alias===t.columnId||t.columnId&&s.label===t.columnId||t.columnId&&s.name===t.columnId})}function TI(e){if(e)return e.trim().toLowerCase()}const XZ=/\s*(?:\((?:previous|last year|start|target|comparison)\)|δ)\s*$/i;function vNe(e){const t=e==null?void 0:e.trim();return t?t.replace(XZ,"").trim()||t:void 0}function wNe(e){const t=e==null?void 0:e.trim();return t?XZ.test(t):!1}function dy(e){var m;const{card:t,datasetIndex:n,datasetLabel:r,metricKey:s}=e,o=((m=t==null?void 0:t.config)==null?void 0:m.metricColumns)||[];if(o.length===1)return o[0];const i=[s,r];if(!i.some(g=>wNe(g))&&typeof n=="number"&&n>=0&&n<o.length)return o[n];const c=i.filter(g=>!!g);for(const g of c){const b=Du(t,{columnId:g,metricAlias:g});if(b)return b}const u=c.map(g=>TI(g)).filter(g=>!!g),d=c.map(g=>vNe(g)).filter(g=>!!g);for(const g of d){const b=Du(t,{columnId:g,metricAlias:g});if(b)return b}const f=d.map(g=>TI(g)).filter(g=>!!g),h=[...u,...f];if(h.length!==0)return o.find(g=>{const b=[g.alias,g.label,g.name,ZZ(g)].map(x=>TI(x)).filter(x=>!!x);return h.some(x=>b.includes(x))})}function $k(e){const t=p.fromSemanticFormat(e==null?void 0:e.format);return p.toTFormatOptions(t)}function x4(e,t){if(t)return Du(e,{columnId:t,metricAlias:t})}function y4(e){const t=p.fromTFormatOptions(e);if(t)return JSON.stringify(t)}function SNe(e,t){const n=y4(e),r=y4(t);return!!(n&&r&&n===r)}function CNe(e){if(e.length===0)return;const t=e.map(i=>$k(i));if(!t.every(i=>wx(i)))return;const r=t,[s]=r;return r.every(i=>SNe(s,i))?s:void 0}function QZ(e){const t=e.formatMode||e.legacyMode;return t==="override"?"override":t==="inherit"?"inherit":e.legacyMode&&e.legacyMode!=="auto"&&e.legacyMode!=="inherit"&&e.legacyMode!=="override"||wx(e.formatOptions)?"override":"inherit"}function zk(e){const t=QZ({formatMode:e.formatMode,legacyMode:e.legacyMode,formatOptions:e.overrideFormatOptions});if(t==="override"&&wx(e.overrideFormatOptions))return{formatOptions:e.overrideFormatOptions||void 0,source:"override"};if(t==="override"&&e.legacyMode==="none")return{formatOptions:void 0,source:"override",rawValue:!0};const n=CNe(e.metrics||[]);if(wx(n))return{formatOptions:n,source:"metric"};const r=Z0(e.preferences);return wx(r)?{formatOptions:r,source:"legacy"}:{formatOptions:void 0,source:"auto"}}function JZ(e){var u,d,f,h;const{card:t,chartType:n,axis:r,preferences:s}=e,o=((u=t==null?void 0:t.config)==null?void 0:u.metricColumns)||[],i=(s==null?void 0:s.datasetOptions)||[];if(!o.length)return[];if(n==="combo")return r==="x"?[]:o.filter((m,g)=>{const b=i.find(y=>y.idx===g);return((b==null?void 0:b.yAxisId)==="y2"?"y2":"y")===r});if(n==="bubble"||n==="scatter"){if(r==="y2")return[];const m=x4(t,(d=s==null?void 0:s.bubbleScatterConfig)==null?void 0:d.xMetricKey)||o[0],g=x4(t,(f=s==null?void 0:s.bubbleScatterConfig)==null?void 0:f.yMetricKey)||o[1]||o[0];return r==="x"?m?[m]:[]:g?[g]:[]}const c=((h=s==null?void 0:s.chartOptions)==null?void 0:h.indexAxis)==="y"||n==="horizontalBar"?"x":"y";return n==="radar"?r==="y"?o:[]:r!==c?[]:o}function tg(e){const{card:t,chartType:n,axis:r,preferences:s,axisConfig:o}=e;return zk({formatMode:o==null?void 0:o.formatMode,overrideFormatOptions:o==null?void 0:o.formatOptions,metrics:JZ({card:t,chartType:n,axis:r,preferences:s}),preferences:s})}function eX(e,t){if(!e&&(!t||t==="auto"||t==="none"))return;const n={...e||{}};return t&&t!=="auto"&&t!=="none"&&!n.type&&(n.type=t),n}function Bk(e){const{preferences:t,metric:n}=e,r=t==null?void 0:t.tooltipConfig;return zk({formatMode:r==null?void 0:r.formatMode,legacyMode:r==null?void 0:r.mode,overrideFormatOptions:r==null?void 0:r.formatOptions,metrics:n?[n]:[],preferences:t})}function bF(e,t){return t==="x"?e==null?void 0:e.xAxisConfig:t==="y2"?e==null?void 0:e.secondaryYAxisConfig:e==null?void 0:e.yAxisConfig}function xF(e){var s;const{chartType:t,preferences:n}=e,r=((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y";return t==="bubble"||t==="scatter"?"y":r?"x":"y"}function tX(e){switch(e){case"pie":case"doughnut":case"polarArea":case"funnel":case"treemap":case"heatmap":return!1;default:return!0}}function yF(e){const{card:t,chartType:n,preferences:r,metric:s}=e,o=Bk({preferences:r,metric:s});if(o.source==="override")return o;const i=e.axis||xF({chartType:n,preferences:r}),a=tg({card:t,chartType:n,axis:i,preferences:r,axisConfig:bF(r,i)});return a.source==="override"?a:o}function G0(e){const{card:t,chartType:n,preferences:r,dataLabelsConfig:s}=e,o=n||(t==null?void 0:t.type),i=xF({chartType:o,preferences:r}),a=zk({formatMode:s==null?void 0:s.formatMode,legacyMode:s==null?void 0:s.format,overrideFormatOptions:eX(s==null?void 0:s.formatOptions,s==null?void 0:s.format),metrics:JZ({card:t,chartType:o,axis:i,preferences:r}),preferences:r});if(a.source==="override"||!tX(o))return a;const c=tg({card:t,chartType:o,axis:i,preferences:r,axisConfig:bF(r,i)});return c.source==="override"?c:a}function nX(e){const{preferences:t,dataLabelsConfig:n,metric:r}=e;return zk({formatMode:n==null?void 0:n.formatMode,legacyMode:n==null?void 0:n.format,overrideFormatOptions:eX(n==null?void 0:n.formatOptions,n==null?void 0:n.format),metrics:r?[r]:[],preferences:t})}function Y0(e){var i,a;const t=dy({card:e.card,datasetIndex:e.datasetIndex,datasetLabel:e.datasetLabel,metricKey:e.metricKey}),n=nX({preferences:e.preferences,dataLabelsConfig:e.dataLabelsConfig,metric:t});if(n.source==="override")return n;const r=(i=e.card)==null?void 0:i.type;if(!tX(r))return n;let s=xF({chartType:r,preferences:e.preferences});if(r==="combo"&&typeof e.datasetIndex=="number"){const u=(((a=e.preferences)==null?void 0:a.datasetOptions)||[]).find(d=>d.idx===e.datasetIndex);s=(u==null?void 0:u.yAxisId)==="y2"?"y2":"y"}const o=tg({card:e.card,chartType:r,axis:s,preferences:e.preferences,axisConfig:bF(e.preferences,s)});return o.source==="override"?o:n}function ng(e){return(e==null?void 0:e.rawValue)===!0}function bw(e){const t=e==null?void 0:e.numberFormat;if(!t)return;const n=t.style==="currency"?"currency":t.style==="percent"?"percent":t.style==="scientific"?"scientific":"number",r=t.minimumFractionDigits,s=t.maximumFractionDigits;return{type:n,currency:n==="currency"?t.currency:void 0,locale:t.locale,decimalPlaces:r===s?s:void 0,minimumFractionDigits:r,maximumFractionDigits:s,useGrouping:t.useGrouping,percentValueMode:n==="percent"?t.percentValueMode:void 0}}function rX(e,t){const n=p.fromSemanticFormat(e==null?void 0:e.format),r=p.toColumnNumberFormat(n);if(!r)return;const s=t||Js(),o=s.numberFormat,i=s.type&&s.type!=="none";return{...s,type:i?s.type:"number",inheritMetricFormat:s.inheritMetricFormat??!0,textAlign:i?s.textAlign:"right",numberFormat:{...o,...r,showDataBar:o.showDataBar,showHeatmap:o.showHeatmap,dataBarColor:o.dataBarColor,dataBarMinValue:o.dataBarMinValue,dataBarMaxValue:o.dataBarMaxValue}}}function Mu(e){const{card:t,columnId:n,existingSettings:r,fallbackSettings:s,metricId:o,metricAlias:i}=e;if(r&&r.inheritMetricFormat!==!0)return r;const a=Du(t,{columnId:n,metricId:o,metricAlias:i});return rX(a,r||s)||r||s}function K0(e){const{card:t,columnId:n,existingSettings:r,fallbackSettings:s,metricId:o,metricAlias:i}=e;if(r&&r.inheritMetricFormat!==!0)return bw(r)||bw(s);const a=Du(t,{columnId:n,metricId:o,metricAlias:i});return $k(a)||bw(r)||bw(s)}function Z0(e){var g,b,x,y,w,v,C;const t=(g=e==null?void 0:e.formatNumber)==null?void 0:g.enabled,n=typeof t=="string"?t.trim().toLowerCase()!=="false":t!==!1,r=p.fromNumberAxisFormat(e==null?void 0:e.numberAxisFormat)||(n?p.fromLegacyFormatNumber(e==null?void 0:e.formatNumber):void 0),s=p.toTFormatOptions(r);if(!s||!s.type||s.type==="auto")return s;const o=(b=e==null?void 0:e.numberAxisFormat)==null?void 0:b.decimalPlaces,i=n?(x=e==null?void 0:e.formatNumber)==null?void 0:x.decimalPlaces:void 0,a=typeof o=="number"?o:typeof i=="number"?i:void 0,c=(y=e==null?void 0:e.numberAxisFormat)==null?void 0:y.minimumFractionDigits,u=(w=e==null?void 0:e.numberAxisFormat)==null?void 0:w.maximumFractionDigits,d=n?(v=e==null?void 0:e.formatNumber)==null?void 0:v.minimumFractionDigits:void 0,f=n?(C=e==null?void 0:e.formatNumber)==null?void 0:C.maximumFractionDigits:void 0,h=typeof a=="number"?a:typeof c=="number"?c:typeof d=="number"?d:0,m=typeof a=="number"?a:typeof u=="number"?u:typeof f=="number"?f:0;return{...s,decimalPlaces:h===m?m:s.decimalPlaces,minimumFractionDigits:h,maximumFractionDigits:Math.max(h,m)}}function fy(e){var s,o,i,a,c;const{value:t,formatOptions:n,preferences:r}=e;return n!=null&&n.type&&n.type!=="auto"?In(t,n.type,n):uy({number:t,decimalPlaces:((s=r==null?void 0:r.numberAxisFormat)==null?void 0:s.decimalPlaces)??0,useSuffix:!!((o=r==null?void 0:r.numberAxisFormat)!=null&&o.suffix),customSuffix:((i=r==null?void 0:r.numberAxisFormat)==null?void 0:i.suffix)||"",locale:((a=r==null?void 0:r.numberAxisFormat)==null?void 0:a.locale)||"en-US",currency:((c=r==null?void 0:r.numberAxisFormat)==null?void 0:c.currency)||""})}function v4(e,t,n,r,s){if(!e||e.length===0){console.warn("No data to export");return}const o=(s==null?void 0:s.delimiter)||",",i=(s==null?void 0:s.includeHeaders)!==!1,a=Object.keys(e[0]);let c=a;if(n!=null&&n.columnVisibility&&(c=a.filter(d=>{var f;return((f=n.columnVisibility)==null?void 0:f[d])!==!1})),n!=null&&n.columnSizing){const d=Object.keys(n.columnSizing),f=d.filter(m=>c.includes(m)),h=c.filter(m=>!d.includes(m));c=[...f,...h]}let u="";if(i){const d=c.map(f=>ib(f,o));u+=d.join(o)+`
723
+ `,e.getElementsByTagName("head")[0].appendChild(t)),e.body&&iK(e.body,"react-draggable-transparent-selection")}function mve(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{V$(e)}):V$(e)}function V$(e){if(e)try{if(e.body&&aK(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&t.type!=="Caret"&&t.removeAllRanges()}}catch{}}function iK(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function aK(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp(`(?:^|\\s)${t}(?!\\S)`,"g"),"")}var Sl={};Object.defineProperty(Sl,"__esModule",{value:!0});Sl.canDragX=bve;Sl.canDragY=xve;Sl.createCoreData=vve;Sl.createDraggableData=wve;Sl.getBoundPosition=pve;Sl.getControlPosition=yve;Sl.snapToGrid=gve;var Jo=wl,Tm=Ur;function pve(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r=="string"?r:Sve(r);const s=RP(e);if(typeof r=="string"){const{ownerDocument:o}=s,i=o.defaultView;let a;if(r==="parent"?a=s.parentNode:a=s.getRootNode().querySelector(r),!(a instanceof i.HTMLElement))throw new Error('Bounds selector "'+r+'" could not find an element.');const c=a,u=i.getComputedStyle(s),d=i.getComputedStyle(c);r={left:-s.offsetLeft+(0,Jo.int)(d.paddingLeft)+(0,Jo.int)(u.marginLeft),top:-s.offsetTop+(0,Jo.int)(d.paddingTop)+(0,Jo.int)(u.marginTop),right:(0,Tm.innerWidth)(c)-(0,Tm.outerWidth)(s)-s.offsetLeft+(0,Jo.int)(d.paddingRight)-(0,Jo.int)(u.marginRight),bottom:(0,Tm.innerHeight)(c)-(0,Tm.outerHeight)(s)-s.offsetTop+(0,Jo.int)(d.paddingBottom)-(0,Jo.int)(u.marginBottom)}}return(0,Jo.isNum)(r.right)&&(t=Math.min(t,r.right)),(0,Jo.isNum)(r.bottom)&&(n=Math.min(n,r.bottom)),(0,Jo.isNum)(r.left)&&(t=Math.max(t,r.left)),(0,Jo.isNum)(r.top)&&(n=Math.max(n,r.top)),[t,n]}function gve(e,t,n){const r=Math.round(t/e[0])*e[0],s=Math.round(n/e[1])*e[1];return[r,s]}function bve(e){return e.props.axis==="both"||e.props.axis==="x"}function xve(e){return e.props.axis==="both"||e.props.axis==="y"}function yve(e,t,n){const r=typeof t=="number"?(0,Tm.getTouch)(e,t):null;if(typeof t=="number"&&!r)return null;const s=RP(n),o=n.props.offsetParent||s.offsetParent||s.ownerDocument.body;return(0,Tm.offsetXYFromParent)(r||e,o,n.props.scale)}function vve(e,t,n){const r=!(0,Jo.isNum)(e.lastX),s=RP(e);return r?{node:s,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:s,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function wve(e,t){const n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Sve(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function RP(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}var vk={},wk={};Object.defineProperty(wk,"__esModule",{value:!0});wk.default=Cve;function Cve(){}Object.defineProperty(vk,"__esModule",{value:!0});vk.default=void 0;var hI=lK(S),uo=PP(cd),Nve=PP(gr),Us=Ur,Vc=Sl,mI=wl,nb=PP(wk);function PP(e){return e&&e.__esModule?e:{default:e}}function lK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(lK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function go(e,t,n){return(t=kve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kve(e){var t=_ve(e,"string");return typeof t=="symbol"?t:t+""}function _ve(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const sa={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let Hc=sa.mouse,Sk=class extends hI.Component{constructor(){super(...arguments),go(this,"dragging",!1),go(this,"lastX",NaN),go(this,"lastY",NaN),go(this,"touchIdentifier",null),go(this,"mounted",!1),go(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&typeof t.button=="number"&&t.button!==0)return!1;const n=this.findDOMNode();if(!n||!n.ownerDocument||!n.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=n;if(this.props.disabled||!(t.target instanceof r.defaultView.Node)||this.props.handle&&!(0,Us.matchesSelectorAndParentsTo)(t.target,this.props.handle,n)||this.props.cancel&&(0,Us.matchesSelectorAndParentsTo)(t.target,this.props.cancel,n))return;t.type==="touchstart"&&!this.props.allowMobileScroll&&t.preventDefault();const s=(0,Us.getTouchIdentifier)(t);this.touchIdentifier=s;const o=(0,Vc.getControlPosition)(t,s,this);if(o==null)return;const{x:i,y:a}=o,c=(0,Vc.createCoreData)(this,i,a);(0,nb.default)("DraggableCore: handleDragStart: %j",c),(0,nb.default)("calling",this.props.onStart),!(this.props.onStart(t,c)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,Us.addUserSelectStyles)(r),this.dragging=!0,this.lastX=i,this.lastY=a,(0,Us.addEvent)(r,Hc.move,this.handleDrag),(0,Us.addEvent)(r,Hc.stop,this.handleDragStop))}),go(this,"handleDrag",t=>{const n=(0,Vc.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:s}=n;if(Array.isArray(this.props.grid)){let a=r-this.lastX,c=s-this.lastY;if([a,c]=(0,Vc.snapToGrid)(this.props.grid,a,c),!a&&!c)return;r=this.lastX+a,s=this.lastY+c}const o=(0,Vc.createCoreData)(this,r,s);if((0,nb.default)("DraggableCore: handleDrag: %j",o),this.props.onDrag(t,o)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const c=document.createEvent("MouseEvents");c.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(c)}return}this.lastX=r,this.lastY=s}),go(this,"handleDragStop",t=>{if(!this.dragging)return;const n=(0,Vc.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:s}=n;if(Array.isArray(this.props.grid)){let c=r-this.lastX||0,u=s-this.lastY||0;[c,u]=(0,Vc.snapToGrid)(this.props.grid,c,u),r=this.lastX+c,s=this.lastY+u}const o=(0,Vc.createCoreData)(this,r,s);if(this.props.onStop(t,o)===!1||this.mounted===!1)return!1;const a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,Us.scheduleRemoveUserSelectStyles)(a.ownerDocument),(0,nb.default)("DraggableCore: handleDragStop: %j",o),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,nb.default)("DraggableCore: Removing handlers"),(0,Us.removeEvent)(a.ownerDocument,Hc.move,this.handleDrag),(0,Us.removeEvent)(a.ownerDocument,Hc.stop,this.handleDragStop))}),go(this,"onMouseDown",t=>(Hc=sa.mouse,this.handleDragStart(t))),go(this,"onMouseUp",t=>(Hc=sa.mouse,this.handleDragStop(t))),go(this,"onTouchStart",t=>(Hc=sa.touch,this.handleDragStart(t))),go(this,"onTouchEnd",t=>(Hc=sa.touch,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;const t=this.findDOMNode();t&&(0,Us.addEvent)(t,sa.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const t=this.findDOMNode();if(t){const{ownerDocument:n}=t;(0,Us.removeEvent)(n,sa.mouse.move,this.handleDrag),(0,Us.removeEvent)(n,sa.touch.move,this.handleDrag),(0,Us.removeEvent)(n,sa.mouse.stop,this.handleDragStop),(0,Us.removeEvent)(n,sa.touch.stop,this.handleDragStop),(0,Us.removeEvent)(t,sa.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,Us.scheduleRemoveUserSelectStyles)(n)}}findDOMNode(){var t,n,r;return(t=this.props)!=null&&t.nodeRef?(r=(n=this.props)==null?void 0:n.nodeRef)==null?void 0:r.current:Nve.default.findDOMNode(this)}render(){return hI.cloneElement(hI.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};vk.default=Sk;go(Sk,"displayName","DraggableCore");go(Sk,"propTypes",{allowAnyClick:uo.default.bool,allowMobileScroll:uo.default.bool,children:uo.default.node.isRequired,disabled:uo.default.bool,enableUserSelectHack:uo.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:uo.default.arrayOf(uo.default.number),handle:uo.default.string,cancel:uo.default.string,nodeRef:uo.default.object,onStart:uo.default.func,onDrag:uo.default.func,onStop:uo.default.func,onMouseDown:uo.default.func,scale:uo.default.number,className:mI.dontSetMe,style:mI.dontSetMe,transform:mI.dontSetMe});go(Sk,"defaultProps",{allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1});(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return c.default}}),e.default=void 0;var t=f(S),n=d(cd),r=d(gr),s=pk,o=Ur,i=Sl,a=wl,c=d(vk),u=d(wk);function d(y){return y&&y.__esModule?y:{default:y}}function f(y,w){if(typeof WeakMap=="function")var v=new WeakMap,C=new WeakMap;return(f=function(N,k){if(!k&&N&&N.__esModule)return N;var _,j,E={__proto__:null,default:N};if(N===null||typeof N!="object"&&typeof N!="function")return E;if(_=k?C:v){if(_.has(N))return _.get(N);_.set(N,E)}for(const I in N)I!=="default"&&{}.hasOwnProperty.call(N,I)&&((j=(_=Object.defineProperty)&&Object.getOwnPropertyDescriptor(N,I))&&(j.get||j.set)?_(E,I,j):E[I]=N[I]);return E})(y,w)}function h(){return h=Object.assign?Object.assign.bind():function(y){for(var w=1;w<arguments.length;w++){var v=arguments[w];for(var C in v)({}).hasOwnProperty.call(v,C)&&(y[C]=v[C])}return y},h.apply(null,arguments)}function m(y,w,v){return(w=g(w))in y?Object.defineProperty(y,w,{value:v,enumerable:!0,configurable:!0,writable:!0}):y[w]=v,y}function g(y){var w=b(y,"string");return typeof w=="symbol"?w:w+""}function b(y,w){if(typeof y!="object"||!y)return y;var v=y[Symbol.toPrimitive];if(v!==void 0){var C=v.call(y,w);if(typeof C!="object")return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return(w==="string"?String:Number)(y)}class x extends t.Component{static getDerivedStateFromProps(w,v){let{position:C}=w,{prevPropsPosition:N}=v;return C&&(!N||C.x!==N.x||C.y!==N.y)?((0,u.default)("Draggable: getDerivedStateFromProps %j",{position:C,prevPropsPosition:N}),{x:C.x,y:C.y,prevPropsPosition:{...C}}):null}constructor(w){super(w),m(this,"onDragStart",(v,C)=>{if((0,u.default)("Draggable: onDragStart: %j",C),this.props.onStart(v,(0,i.createDraggableData)(this,C))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),m(this,"onDrag",(v,C)=>{if(!this.state.dragging)return!1;(0,u.default)("Draggable: onDrag: %j",C);const N=(0,i.createDraggableData)(this,C),k={x:N.x,y:N.y,slackX:0,slackY:0};if(this.props.bounds){const{x:j,y:E}=k;k.x+=this.state.slackX,k.y+=this.state.slackY;const[I,T]=(0,i.getBoundPosition)(this,k.x,k.y);k.x=I,k.y=T,k.slackX=this.state.slackX+(j-k.x),k.slackY=this.state.slackY+(E-k.y),N.x=k.x,N.y=k.y,N.deltaX=k.x-this.state.x,N.deltaY=k.y-this.state.y}if(this.props.onDrag(v,N)===!1)return!1;this.setState(k)}),m(this,"onDragStop",(v,C)=>{if(!this.state.dragging||this.props.onStop(v,(0,i.createDraggableData)(this,C))===!1)return!1;(0,u.default)("Draggable: onDragStop: %j",C);const k={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:j,y:E}=this.props.position;k.x=j,k.y=E}this.setState(k)}),this.state={dragging:!1,dragged:!1,x:w.position?w.position.x:w.defaultPosition.x,y:w.position?w.position.y:w.defaultPosition.y,prevPropsPosition:{...w.position},slackX:0,slackY:0,isElementSVG:!1},w.position&&!(w.onDrag||w.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){var w,v;return((v=(w=this.props)==null?void 0:w.nodeRef)==null?void 0:v.current)??r.default.findDOMNode(this)}render(){const{axis:w,bounds:v,children:C,defaultPosition:N,defaultClassName:k,defaultClassNameDragging:_,defaultClassNameDragged:j,position:E,positionOffset:I,scale:T,...D}=this.props;let R={},F=null;const U=!!!E||this.state.dragging,$=E||N,q={x:(0,i.canDragX)(this)&&U?this.state.x:$.x,y:(0,i.canDragY)(this)&&U?this.state.y:$.y};this.state.isElementSVG?F=(0,o.createSVGTransform)(q,I):R=(0,o.createCSSTransform)(q,I);const W=(0,s.clsx)(C.props.className||"",k,{[_]:this.state.dragging,[j]:this.state.dragged});return t.createElement(c.default,h({},D,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(C),{className:W,style:{...C.props.style,...R},transform:F}))}}e.default=x,m(x,"displayName","Draggable"),m(x,"propTypes",{...c.default.propTypes,axis:n.default.oneOf(["both","x","y","none"]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),m(x,"defaultProps",{...c.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})})(tK);const{default:cK,DraggableCore:jve}=tK;yk.exports=cK;yk.exports.default=cK;yk.exports.DraggableCore=jve;var uK=yk.exports,Ck={exports:{}},$0={},FP={};FP.__esModule=!0;FP.cloneElement=Ave;var Ive=Eve(S);function Eve(e){return e&&e.__esModule?e:{default:e}}function H$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function U$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?H$(Object(n),!0).forEach(function(r){Tve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Tve(e,t,n){return t=Dve(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dve(e){var t=Mve(e,"string");return typeof t=="symbol"?t:String(t)}function Mve(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ave(e,t){return t.style&&e.props.style&&(t.style=U$(U$({},e.props.style),t.style)),t.className&&e.props.className&&(t.className=e.props.className+" "+t.className),Ive.default.cloneElement(e,t)}var z0={};z0.__esModule=!0;z0.resizableProps=void 0;var rn=Rve(cd);function Rve(e){return e&&e.__esModule?e:{default:e}}var Pve={axis:rn.default.oneOf(["both","x","y","none"]),className:rn.default.string,children:rn.default.element.isRequired,draggableOpts:rn.default.shape({allowAnyClick:rn.default.bool,cancel:rn.default.string,children:rn.default.node,disabled:rn.default.bool,enableUserSelectHack:rn.default.bool,offsetParent:rn.default.node,grid:rn.default.arrayOf(rn.default.number),handle:rn.default.string,nodeRef:rn.default.object,onStart:rn.default.func,onDrag:rn.default.func,onStop:rn.default.func,onMouseDown:rn.default.func,scale:rn.default.number}),height:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var s=n[0];if(s.axis==="both"||s.axis==="y"){var o;return(o=rn.default.number).isRequired.apply(o,n)}return rn.default.number.apply(rn.default,n)},handle:rn.default.oneOfType([rn.default.node,rn.default.func]),handleSize:rn.default.arrayOf(rn.default.number),lockAspectRatio:rn.default.bool,maxConstraints:rn.default.arrayOf(rn.default.number),minConstraints:rn.default.arrayOf(rn.default.number),onResizeStop:rn.default.func,onResizeStart:rn.default.func,onResize:rn.default.func,resizeHandles:rn.default.arrayOf(rn.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:rn.default.number,width:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var s=n[0];if(s.axis==="both"||s.axis==="x"){var o;return(o=rn.default.number).isRequired.apply(o,n)}return rn.default.number.apply(rn.default,n)}};z0.resizableProps=Pve;$0.__esModule=!0;$0.default=void 0;var rb=zve(S),Fve=uK,Ove=FP,Lve=z0,$ve=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function dK(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(dK=function(s){return s?n:t})(e)}function zve(e,t){if(e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=dK(t);if(n&&n.has(e))return n.get(e);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(o!=="default"&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function S2(){return S2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S2.apply(this,arguments)}function Bve(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function q$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function pI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?q$(Object(n),!0).forEach(function(r){Vve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Vve(e,t,n){return t=Hve(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hve(e){var t=Uve(e,"string");return typeof t=="symbol"?t:String(t)}function Uve(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qve(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,C2(e,t)}function C2(e,t){return C2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},C2(e,t)}var OP=function(e){qve(t,e);function t(){for(var r,s=arguments.length,o=new Array(s),i=0;i<s;i++)o[i]=arguments[i];return r=e.call.apply(e,[this].concat(o))||this,r.handleRefs={},r.lastHandleRect=null,r.slack=null,r}var n=t.prototype;return n.componentWillUnmount=function(){this.resetData()},n.resetData=function(){this.lastHandleRect=this.slack=null},n.runConstraints=function(s,o){var i=this.props,a=i.minConstraints,c=i.maxConstraints,u=i.lockAspectRatio;if(!a&&!c&&!u)return[s,o];if(u){var d=this.props.width/this.props.height,f=s-this.props.width,h=o-this.props.height;Math.abs(f)>Math.abs(h*d)?o=s/d:s=o*d}var m=s,g=o,b=this.slack||[0,0],x=b[0],y=b[1];return s+=x,o+=y,a&&(s=Math.max(a[0],s),o=Math.max(a[1],o)),c&&(s=Math.min(c[0],s),o=Math.min(c[1],o)),this.slack=[x+(m-s),y+(g-o)],[s,o]},n.resizeHandler=function(s,o){var i=this;return function(a,c){var u=c.node,d=c.deltaX,f=c.deltaY;s==="onResizeStart"&&i.resetData();var h=(i.props.axis==="both"||i.props.axis==="x")&&o!=="n"&&o!=="s",m=(i.props.axis==="both"||i.props.axis==="y")&&o!=="e"&&o!=="w";if(!(!h&&!m)){var g=o[0],b=o[o.length-1],x=u.getBoundingClientRect();if(i.lastHandleRect!=null){if(b==="w"){var y=x.left-i.lastHandleRect.left;d+=y}if(g==="n"){var w=x.top-i.lastHandleRect.top;f+=w}}i.lastHandleRect=x,b==="w"&&(d=-d),g==="n"&&(f=-f);var v=i.props.width+(h?d/i.props.transformScale:0),C=i.props.height+(m?f/i.props.transformScale:0),N=i.runConstraints(v,C);v=N[0],C=N[1];var k=v!==i.props.width||C!==i.props.height,_=typeof i.props[s]=="function"?i.props[s]:null,j=s==="onResize"&&!k;_&&!j&&(a.persist==null||a.persist(),_(a,{node:u,size:{width:v,height:C},handle:o})),s==="onResizeStop"&&i.resetData()}}},n.renderResizeHandle=function(s,o){var i=this.props.handle;if(!i)return rb.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+s,ref:o});if(typeof i=="function")return i(s,o);var a=typeof i.type=="string",c=pI({ref:o},a?{}:{handleAxis:s});return rb.cloneElement(i,c)},n.render=function(){var s=this,o=this.props,i=o.children,a=o.className,c=o.draggableOpts;o.width,o.height,o.handle,o.handleSize,o.lockAspectRatio,o.axis,o.minConstraints,o.maxConstraints,o.onResize,o.onResizeStop,o.onResizeStart;var u=o.resizeHandles;o.transformScale;var d=Bve(o,$ve);return(0,Ove.cloneElement)(i,pI(pI({},d),{},{className:(a?a+" ":"")+"react-resizable",children:[].concat(i.props.children,u.map(function(f){var h,m=(h=s.handleRefs[f])!=null?h:s.handleRefs[f]=rb.createRef();return rb.createElement(Fve.DraggableCore,S2({},c,{nodeRef:m,key:"resizableHandle-"+f,onStop:s.resizeHandler("onResizeStop",f),onStart:s.resizeHandler("onResizeStart",f),onDrag:s.resizeHandler("onResize",f)}),s.renderResizeHandle(f,m))}))}))},t}(rb.Component);$0.default=OP;OP.propTypes=Lve.resizableProps;OP.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1};var Nk={};Nk.__esModule=!0;Nk.default=void 0;var gI=Zve(S),Wve=fK(cd),Gve=fK($0),Yve=z0,Kve=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function fK(e){return e&&e.__esModule?e:{default:e}}function hK(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(hK=function(s){return s?n:t})(e)}function Zve(e,t){if(e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=hK(t);if(n&&n.has(e))return n.get(e);var r={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(o!=="default"&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function N2(){return N2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},N2.apply(this,arguments)}function W$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function JS(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?W$(Object(n),!0).forEach(function(r){Xve(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Xve(e,t,n){return t=Qve(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qve(e){var t=Jve(e,"string");return typeof t=="symbol"?t:String(t)}function Jve(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ewe(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function twe(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,k2(e,t)}function k2(e,t){return k2=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},k2(e,t)}var mK=function(e){twe(t,e);function t(){for(var r,s=arguments.length,o=new Array(s),i=0;i<s;i++)o[i]=arguments[i];return r=e.call.apply(e,[this].concat(o))||this,r.state={width:r.props.width,height:r.props.height,propsWidth:r.props.width,propsHeight:r.props.height},r.onResize=function(a,c){var u=c.size;r.props.onResize?(a.persist==null||a.persist(),r.setState(u,function(){return r.props.onResize&&r.props.onResize(a,c)})):r.setState(u)},r}t.getDerivedStateFromProps=function(s,o){return o.propsWidth!==s.width||o.propsHeight!==s.height?{width:s.width,height:s.height,propsWidth:s.width,propsHeight:s.height}:null};var n=t.prototype;return n.render=function(){var s=this.props,o=s.handle,i=s.handleSize;s.onResize;var a=s.onResizeStart,c=s.onResizeStop,u=s.draggableOpts,d=s.minConstraints,f=s.maxConstraints,h=s.lockAspectRatio,m=s.axis;s.width,s.height;var g=s.resizeHandles,b=s.style,x=s.transformScale,y=ewe(s,Kve);return gI.createElement(Gve.default,{axis:m,draggableOpts:u,handle:o,handleSize:i,height:this.state.height,lockAspectRatio:h,maxConstraints:f,minConstraints:d,onResizeStart:a,onResize:this.onResize,onResizeStop:c,resizeHandles:g,transformScale:x,width:this.state.width},gI.createElement("div",N2({},y,{style:JS(JS({},b),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},t}(gI.Component);Nk.default=mK;mK.propTypes=JS(JS({},Yve.resizableProps),{},{children:Wve.default.element});Ck.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")};Ck.exports.Resizable=$0.default;Ck.exports.ResizableBox=Nk.default;var nwe=Ck.exports,uc={};Object.defineProperty(uc,"__esModule",{value:!0});uc.resizeHandleType=uc.resizeHandleAxesType=uc.default=void 0;var ln=pK(cd),rwe=pK(S);function pK(e){return e&&e.__esModule?e:{default:e}}const swe=uc.resizeHandleAxesType=ln.default.arrayOf(ln.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),owe=uc.resizeHandleType=ln.default.oneOfType([ln.default.node,ln.default.func]);uc.default={className:ln.default.string,style:ln.default.object,width:ln.default.number,autoSize:ln.default.bool,cols:ln.default.number,draggableCancel:ln.default.string,draggableHandle:ln.default.string,verticalCompact:function(e){e.verticalCompact===!1&&process.env.NODE_ENV!=="production"&&console.warn('`verticalCompact` on <ReactGridLayout> is deprecated and will be removed soon. Use `compactType`: "horizontal" | "vertical" | null.')},compactType:ln.default.oneOf(["vertical","horizontal"]),layout:function(e){var t=e.layout;t!==void 0&&bn.validateLayout(t,"layout")},margin:ln.default.arrayOf(ln.default.number),containerPadding:ln.default.arrayOf(ln.default.number),rowHeight:ln.default.number,maxRows:ln.default.number,isBounded:ln.default.bool,isDraggable:ln.default.bool,isResizable:ln.default.bool,allowOverlap:ln.default.bool,preventCollision:ln.default.bool,useCSSTransforms:ln.default.bool,transformScale:ln.default.number,isDroppable:ln.default.bool,resizeHandles:swe,resizeHandle:owe,onLayoutChange:ln.default.func,onDragStart:ln.default.func,onDrag:ln.default.func,onDragStop:ln.default.func,onResizeStart:ln.default.func,onResize:ln.default.func,onResizeStop:ln.default.func,onDrop:ln.default.func,droppingItem:ln.default.shape({i:ln.default.string.isRequired,w:ln.default.number.isRequired,h:ln.default.number.isRequired}),children:function(e,t){const n=e[t],r={};rwe.default.Children.forEach(n,function(s){if((s==null?void 0:s.key)!=null){if(r[s.key])throw new Error('Duplicate child key "'+s.key+'" found! This will cause problems in ReactGridLayout.');r[s.key]=!0}})},innerRef:ln.default.any};Object.defineProperty(xk,"__esModule",{value:!0});xk.default=void 0;var Yh=LP(S),G$=gr,zn=LP(cd),iwe=uK,awe=nwe,Kh=bn,js=vl,Y$=uc,lwe=LP(pk);function LP(e){return e&&e.__esModule?e:{default:e}}function za(e,t,n){return(t=cwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cwe(e){var t=uwe(e,"string");return typeof t=="symbol"?t:t+""}function uwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class $P extends Yh.default.Component{constructor(){super(...arguments),za(this,"state",{resizing:null,dragging:null,className:""}),za(this,"elementRef",Yh.default.createRef()),za(this,"onDragStart",(t,n)=>{let{node:r}=n;const{onDragStart:s,transformScale:o}=this.props;if(!s)return;const i={top:0,left:0},{offsetParent:a}=r;if(!a)return;const c=a.getBoundingClientRect(),u=r.getBoundingClientRect(),d=u.left/o,f=c.left/o,h=u.top/o,m=c.top/o;i.left=d-f+a.scrollLeft,i.top=h-m+a.scrollTop,this.setState({dragging:i});const{x:g,y:b}=(0,js.calcXY)(this.getPositionParams(),i.top,i.left,this.props.w,this.props.h);return s.call(this,this.props.i,g,b,{e:t,node:r,newPosition:i})}),za(this,"onDrag",(t,n,r)=>{let{node:s,deltaX:o,deltaY:i}=n;const{onDrag:a}=this.props;if(!a)return;if(!this.state.dragging)throw new Error("onDrag called before onDragStart.");let c=this.state.dragging.top+i,u=this.state.dragging.left+o;const{isBounded:d,i:f,w:h,h:m,containerWidth:g}=this.props,b=this.getPositionParams();if(d){const{offsetParent:v}=s;if(v){const{margin:C,rowHeight:N}=this.props,k=v.clientHeight-(0,js.calcGridItemWHPx)(m,N,C[1]);c=(0,js.clamp)(c,0,k);const _=(0,js.calcGridColWidth)(b),j=g-(0,js.calcGridItemWHPx)(h,_,C[0]);u=(0,js.clamp)(u,0,j)}}const x={top:c,left:u};r?this.setState({dragging:x}):(0,G$.flushSync)(()=>{this.setState({dragging:x})});const{x:y,y:w}=(0,js.calcXY)(b,c,u,h,m);return a.call(this,f,y,w,{e:t,node:s,newPosition:x})}),za(this,"onDragStop",(t,n)=>{let{node:r}=n;const{onDragStop:s}=this.props;if(!s)return;if(!this.state.dragging)throw new Error("onDragEnd called before onDragStart.");const{w:o,h:i,i:a}=this.props,{left:c,top:u}=this.state.dragging,d={top:u,left:c};this.setState({dragging:null});const{x:f,y:h}=(0,js.calcXY)(this.getPositionParams(),u,c,o,i);return s.call(this,a,f,h,{e:t,node:r,newPosition:d})}),za(this,"onResizeStop",(t,n,r)=>this.onResizeHandler(t,n,r,"onResizeStop")),za(this,"onResizeStart",(t,n,r)=>this.onResizeHandler(t,n,r,"onResizeStart")),za(this,"onResize",(t,n,r)=>this.onResizeHandler(t,n,r,"onResize"))}shouldComponentUpdate(t,n){if(this.props.children!==t.children||this.props.droppingPosition!==t.droppingPosition)return!0;const r=(0,js.calcGridItemPosition)(this.getPositionParams(this.props),this.props.x,this.props.y,this.props.w,this.props.h,this.state),s=(0,js.calcGridItemPosition)(this.getPositionParams(t),t.x,t.y,t.w,t.h,n);return!(0,Kh.fastPositionEqual)(r,s)||this.props.useCSSTransforms!==t.useCSSTransforms}componentDidMount(){this.moveDroppingItem({})}componentDidUpdate(t){this.moveDroppingItem(t)}moveDroppingItem(t){const{droppingPosition:n}=this.props;if(!n)return;const r=this.elementRef.current;if(!r)return;const s=t.droppingPosition||{left:0,top:0},{dragging:o}=this.state,i=o&&n.left!==s.left||n.top!==s.top;if(!o)this.onDragStart(n.e,{node:r,deltaX:n.left,deltaY:n.top});else if(i){const a=n.left-o.left,c=n.top-o.top;this.onDrag(n.e,{node:r,deltaX:a,deltaY:c},!0)}}getPositionParams(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return{cols:t.cols,containerPadding:t.containerPadding,containerWidth:t.containerWidth,margin:t.margin,maxRows:t.maxRows,rowHeight:t.rowHeight}}createStyle(t){const{usePercentages:n,containerWidth:r,useCSSTransforms:s}=this.props;let o;return s?o=(0,Kh.setTransform)(t):(o=(0,Kh.setTopLeft)(t),n&&(o.left=(0,Kh.perc)(t.left/r),o.width=(0,Kh.perc)(t.width/r))),o}mixinDraggable(t,n){return Yh.default.createElement(iwe.DraggableCore,{disabled:!n,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,handle:this.props.handle,cancel:".react-resizable-handle"+(this.props.cancel?","+this.props.cancel:""),scale:this.props.transformScale,nodeRef:this.elementRef},t)}curryResizeHandler(t,n){return(r,s)=>n(r,s,t)}mixinResizable(t,n,r){const{cols:s,minW:o,minH:i,maxW:a,maxH:c,transformScale:u,resizeHandles:d,resizeHandle:f}=this.props,h=this.getPositionParams(),m=(0,js.calcGridItemPosition)(h,0,0,s,0).width,g=(0,js.calcGridItemPosition)(h,0,0,o,i),b=(0,js.calcGridItemPosition)(h,0,0,a,c),x=[g.width,g.height],y=[Math.min(b.width,m),Math.min(b.height,1/0)];return Yh.default.createElement(awe.Resizable,{draggableOpts:{disabled:!r},className:r?void 0:"react-resizable-hide",width:n.width,height:n.height,minConstraints:x,maxConstraints:y,onResizeStop:this.curryResizeHandler(n,this.onResizeStop),onResizeStart:this.curryResizeHandler(n,this.onResizeStart),onResize:this.curryResizeHandler(n,this.onResize),transformScale:u,resizeHandles:d,handle:f},t)}onResizeHandler(t,n,r,s){let{node:o,size:i,handle:a}=n;const c=this.props[s];if(!c)return;const{x:u,y:d,i:f,maxH:h,minH:m,containerWidth:g}=this.props,{minW:b,maxW:x}=this.props;let y=i;o&&(y=(0,Kh.resizeItemInDirection)(a,r,i,g),(0,G$.flushSync)(()=>{this.setState({resizing:s==="onResizeStop"?null:y})}));let{w,h:v}=(0,js.calcWH)(this.getPositionParams(),y.width,y.height,u,d,a);w=(0,js.clamp)(w,Math.max(b,1),x),v=(0,js.clamp)(v,m,h),c.call(this,f,w,v,{e:t,node:o,size:y,handle:a})}render(){const{x:t,y:n,w:r,h:s,isDraggable:o,isResizable:i,droppingPosition:a,useCSSTransforms:c}=this.props,u=(0,js.calcGridItemPosition)(this.getPositionParams(),t,n,r,s,this.state),d=Yh.default.Children.only(this.props.children);let f=Yh.default.cloneElement(d,{ref:this.elementRef,className:(0,lwe.default)("react-grid-item",d.props.className,this.props.className,{static:this.props.static,resizing:!!this.state.resizing,"react-draggable":o,"react-draggable-dragging":!!this.state.dragging,dropping:!!a,cssTransforms:c}),style:{...this.props.style,...d.props.style,...this.createStyle(u)}});return f=this.mixinResizable(f,u,i),f=this.mixinDraggable(f,o),f}}xk.default=$P;za($P,"propTypes",{children:zn.default.element,cols:zn.default.number.isRequired,containerWidth:zn.default.number.isRequired,rowHeight:zn.default.number.isRequired,margin:zn.default.array.isRequired,maxRows:zn.default.number.isRequired,containerPadding:zn.default.array.isRequired,x:zn.default.number.isRequired,y:zn.default.number.isRequired,w:zn.default.number.isRequired,h:zn.default.number.isRequired,minW:function(e,t){const n=e[t];if(typeof n!="number")return new Error("minWidth not Number");if(n>e.w||n>e.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(e,t){const n=e[t];if(typeof n!="number")return new Error("maxWidth not Number");if(n<e.w||n<e.minW)return new Error("maxWidth smaller than item width/minWidth")},minH:function(e,t){const n=e[t];if(typeof n!="number")return new Error("minHeight not Number");if(n>e.h||n>e.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(e,t){const n=e[t];if(typeof n!="number")return new Error("maxHeight not Number");if(n<e.h||n<e.minH)return new Error("maxHeight smaller than item height/minHeight")},i:zn.default.string.isRequired,resizeHandles:Y$.resizeHandleAxesType,resizeHandle:Y$.resizeHandleType,onDragStop:zn.default.func,onDragStart:zn.default.func,onDrag:zn.default.func,onResizeStop:zn.default.func,onResizeStart:zn.default.func,onResize:zn.default.func,isDraggable:zn.default.bool.isRequired,isResizable:zn.default.bool.isRequired,isBounded:zn.default.bool.isRequired,static:zn.default.bool,useCSSTransforms:zn.default.bool.isRequired,transformScale:zn.default.number,className:zn.default.string,handle:zn.default.string,cancel:zn.default.string,droppingPosition:zn.default.shape({e:zn.default.object.isRequired,left:zn.default.number.isRequired,top:zn.default.number.isRequired})});za($P,"defaultProps",{className:"",cancel:"",handle:"",minH:1,minW:1,maxH:1/0,maxW:1/0,transformScale:1});Object.defineProperty(L0,"__esModule",{value:!0});L0.default=void 0;var Nd=gK(S),bI=SP,dwe=zP(pk),Wt=bn,fwe=vl,K$=zP(xk),hwe=zP(uc);function zP(e){return e&&e.__esModule?e:{default:e}}function gK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(gK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function Ws(e,t,n){return(t=mwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mwe(e){var t=pwe(e,"string");return typeof t=="symbol"?t:t+""}function pwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Z$="react-grid-layout";let bK=!1;try{bK=/firefox/i.test(navigator.userAgent)}catch{}class kk extends Nd.Component{constructor(){super(...arguments),Ws(this,"state",{activeDrag:null,layout:(0,Wt.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,(0,Wt.compactType)(this.props),this.props.allowOverlap),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null,resizing:!1,droppingDOMNode:null,children:[]}),Ws(this,"dragEnterCounter",0),Ws(this,"onDragStart",(t,n,r,s)=>{let{e:o,node:i}=s;const{layout:a}=this.state,c=(0,Wt.getLayoutItem)(a,t);if(!c)return;const u={w:c.w,h:c.h,x:c.x,y:c.y,placeholder:!0,i:t};return this.setState({oldDragItem:(0,Wt.cloneLayoutItem)(c),oldLayout:a,activeDrag:u}),this.props.onDragStart(a,c,c,null,o,i)}),Ws(this,"onDrag",(t,n,r,s)=>{let{e:o,node:i}=s;const{oldDragItem:a}=this.state;let{layout:c}=this.state;const{cols:u,allowOverlap:d,preventCollision:f}=this.props,h=(0,Wt.getLayoutItem)(c,t);if(!h)return;const m={w:h.w,h:h.h,x:h.x,y:h.y,placeholder:!0,i:t};c=(0,Wt.moveElement)(c,h,n,r,!0,f,(0,Wt.compactType)(this.props),u,d),this.props.onDrag(c,a,h,m,o,i),this.setState({layout:d?c:(0,Wt.compact)(c,(0,Wt.compactType)(this.props),u),activeDrag:m})}),Ws(this,"onDragStop",(t,n,r,s)=>{let{e:o,node:i}=s;if(!this.state.activeDrag)return;const{oldDragItem:a}=this.state;let{layout:c}=this.state;const{cols:u,preventCollision:d,allowOverlap:f}=this.props,h=(0,Wt.getLayoutItem)(c,t);if(!h)return;c=(0,Wt.moveElement)(c,h,n,r,!0,d,(0,Wt.compactType)(this.props),u,f);const g=f?c:(0,Wt.compact)(c,(0,Wt.compactType)(this.props),u);this.props.onDragStop(g,a,h,null,o,i);const{oldLayout:b}=this.state;this.setState({activeDrag:null,layout:g,oldDragItem:null,oldLayout:null}),this.onLayoutMaybeChanged(g,b)}),Ws(this,"onResizeStart",(t,n,r,s)=>{let{e:o,node:i}=s;const{layout:a}=this.state,c=(0,Wt.getLayoutItem)(a,t);c&&(this.setState({oldResizeItem:(0,Wt.cloneLayoutItem)(c),oldLayout:this.state.layout,resizing:!0}),this.props.onResizeStart(a,c,c,null,o,i))}),Ws(this,"onResize",(t,n,r,s)=>{let{e:o,node:i,size:a,handle:c}=s;const{oldResizeItem:u}=this.state,{layout:d}=this.state,{cols:f,preventCollision:h,allowOverlap:m}=this.props;let g=!1,b,x,y;const[w,v]=(0,Wt.withLayoutItem)(d,t,N=>{let k;return x=N.x,y=N.y,["sw","w","nw","n","ne"].indexOf(c)!==-1&&(["sw","nw","w"].indexOf(c)!==-1&&(x=N.x+(N.w-n),n=N.x!==x&&x<0?N.w:n,x=x<0?0:x),["ne","n","nw"].indexOf(c)!==-1&&(y=N.y+(N.h-r),r=N.y!==y&&y<0?N.h:r,y=y<0?0:y),g=!0),h&&!m&&(k=(0,Wt.getAllCollisions)(d,{...N,w:n,h:r,x,y}).filter(j=>j.i!==N.i).length>0,k&&(y=N.y,r=N.h,x=N.x,n=N.w,g=!1)),N.w=n,N.h=r,N});if(!v)return;b=w,g&&(b=(0,Wt.moveElement)(w,v,x,y,!0,this.props.preventCollision,(0,Wt.compactType)(this.props),f,m));const C={w:v.w,h:v.h,x:v.x,y:v.y,static:!0,i:t};this.props.onResize(b,u,v,C,o,i),this.setState({layout:m?b:(0,Wt.compact)(b,(0,Wt.compactType)(this.props),f),activeDrag:C})}),Ws(this,"onResizeStop",(t,n,r,s)=>{let{e:o,node:i}=s;const{layout:a,oldResizeItem:c}=this.state,{cols:u,allowOverlap:d}=this.props,f=(0,Wt.getLayoutItem)(a,t),h=d?a:(0,Wt.compact)(a,(0,Wt.compactType)(this.props),u);this.props.onResizeStop(h,c,f,null,o,i);const{oldLayout:m}=this.state;this.setState({activeDrag:null,layout:h,oldResizeItem:null,oldLayout:null,resizing:!1}),this.onLayoutMaybeChanged(h,m)}),Ws(this,"onDragOver",t=>{var w;if(t.preventDefault(),t.stopPropagation(),bK&&!((w=t.nativeEvent.target)!=null&&w.classList.contains(Z$)))return!1;const{droppingItem:n,onDropDragOver:r,margin:s,cols:o,rowHeight:i,maxRows:a,width:c,containerPadding:u,transformScale:d}=this.props,f=r==null?void 0:r(t);if(f===!1)return this.state.droppingDOMNode&&this.removeDroppingPlaceholder(),!1;const h={...n,...f},{layout:m}=this.state,g=t.currentTarget.getBoundingClientRect(),b=t.clientX-g.left,x=t.clientY-g.top,y={left:b/d,top:x/d,e:t};if(this.state.droppingDOMNode){if(this.state.droppingPosition){const{left:v,top:C}=this.state.droppingPosition;(v!=b||C!=x)&&this.setState({droppingPosition:y})}}else{const v={cols:o,margin:s,maxRows:a,rowHeight:i,containerWidth:c,containerPadding:u||s},C=(0,fwe.calcXY)(v,x,b,h.w,h.h);this.setState({droppingDOMNode:Nd.createElement("div",{key:h.i}),droppingPosition:y,layout:[...m,{...h,x:C.x,y:C.y,static:!1,isDraggable:!0}]})}}),Ws(this,"removeDroppingPlaceholder",()=>{const{droppingItem:t,cols:n}=this.props,{layout:r}=this.state,s=(0,Wt.compact)(r.filter(o=>o.i!==t.i),(0,Wt.compactType)(this.props),n,this.props.allowOverlap);this.setState({layout:s,droppingDOMNode:null,activeDrag:null,droppingPosition:void 0})}),Ws(this,"onDragLeave",t=>{t.preventDefault(),t.stopPropagation(),this.dragEnterCounter--,this.dragEnterCounter===0&&this.removeDroppingPlaceholder()}),Ws(this,"onDragEnter",t=>{t.preventDefault(),t.stopPropagation(),this.dragEnterCounter++}),Ws(this,"onDrop",t=>{t.preventDefault(),t.stopPropagation();const{droppingItem:n}=this.props,{layout:r}=this.state,s=r.find(o=>o.i===n.i);this.dragEnterCounter=0,this.removeDroppingPlaceholder(),this.props.onDrop(r,s,t)})}componentDidMount(){this.setState({mounted:!0}),this.onLayoutMaybeChanged(this.state.layout,this.props.layout)}static getDerivedStateFromProps(t,n){let r;return n.activeDrag?null:(!(0,bI.deepEqual)(t.layout,n.propsLayout)||t.compactType!==n.compactType?r=t.layout:(0,Wt.childrenEqual)(t.children,n.children)||(r=n.layout),r?{layout:(0,Wt.synchronizeLayoutWithChildren)(r,t.children,t.cols,(0,Wt.compactType)(t),t.allowOverlap),compactType:t.compactType,children:t.children,propsLayout:t.layout}:null)}shouldComponentUpdate(t,n){return this.props.children!==t.children||!(0,Wt.fastRGLPropsEqual)(this.props,t,bI.deepEqual)||this.state.activeDrag!==n.activeDrag||this.state.mounted!==n.mounted||this.state.droppingPosition!==n.droppingPosition}componentDidUpdate(t,n){if(!this.state.activeDrag){const r=this.state.layout,s=n.layout;this.onLayoutMaybeChanged(r,s)}}containerHeight(){if(!this.props.autoSize)return;const t=(0,Wt.bottom)(this.state.layout),n=this.props.containerPadding?this.props.containerPadding[1]:this.props.margin[1];return t*this.props.rowHeight+(t-1)*this.props.margin[1]+n*2+"px"}onLayoutMaybeChanged(t,n){n||(n=this.state.layout),(0,bI.deepEqual)(n,t)||this.props.onLayoutChange(t)}placeholder(){const{activeDrag:t}=this.state;if(!t)return null;const{width:n,cols:r,margin:s,containerPadding:o,rowHeight:i,maxRows:a,useCSSTransforms:c,transformScale:u}=this.props;return Nd.createElement(K$.default,{w:t.w,h:t.h,x:t.x,y:t.y,i:t.i,className:`react-grid-placeholder ${this.state.resizing?"placeholder-resizing":""}`,containerWidth:n,cols:r,margin:s,containerPadding:o||s,maxRows:a,rowHeight:i,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:c,transformScale:u},Nd.createElement("div",null))}processGridItem(t,n){if(!t||!t.key)return;const r=(0,Wt.getLayoutItem)(this.state.layout,String(t.key));if(!r)return null;const{width:s,cols:o,margin:i,containerPadding:a,rowHeight:c,maxRows:u,isDraggable:d,isResizable:f,isBounded:h,useCSSTransforms:m,transformScale:g,draggableCancel:b,draggableHandle:x,resizeHandles:y,resizeHandle:w}=this.props,{mounted:v,droppingPosition:C}=this.state,N=typeof r.isDraggable=="boolean"?r.isDraggable:!r.static&&d,k=typeof r.isResizable=="boolean"?r.isResizable:!r.static&&f,_=r.resizeHandles||y,j=N&&h&&r.isBounded!==!1;return Nd.createElement(K$.default,{containerWidth:s,cols:o,margin:i,containerPadding:a||i,maxRows:u,rowHeight:c,cancel:b,handle:x,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:N,isResizable:k,isBounded:j,useCSSTransforms:m&&v,usePercentages:!v,transformScale:g,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:n?C:void 0,resizeHandles:_,resizeHandle:w},t)}render(){const{className:t,style:n,isDroppable:r,innerRef:s}=this.props,o=(0,dwe.default)(Z$,t),i={height:this.containerHeight(),...n};return Nd.createElement("div",{ref:s,className:o,style:i,onDrop:r?this.onDrop:Wt.noop,onDragLeave:r?this.onDragLeave:Wt.noop,onDragEnter:r?this.onDragEnter:Wt.noop,onDragOver:r?this.onDragOver:Wt.noop},Nd.Children.map(this.props.children,a=>this.processGridItem(a)),r&&this.state.droppingDOMNode&&this.processGridItem(this.state.droppingDOMNode,!0),this.placeholder())}}L0.default=kk;Ws(kk,"displayName","ReactGridLayout");Ws(kk,"propTypes",hwe.default);Ws(kk,"defaultProps",{autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isBounded:!1,isDraggable:!0,isResizable:!0,allowOverlap:!1,isDroppable:!1,useCSSTransforms:!0,transformScale:1,verticalCompact:!0,compactType:"vertical",preventCollision:!1,droppingItem:{i:"__dropping-elem__",h:1,w:1},resizeHandles:["se"],onLayoutChange:Wt.noop,onDragStart:Wt.noop,onDrag:Wt.noop,onDragStop:Wt.noop,onResizeStart:Wt.noop,onResize:Wt.noop,onResizeStop:Wt.noop,onDrop:Wt.noop,onDropDragOver:Wt.noop});var _k={},Eh={};Object.defineProperty(Eh,"__esModule",{value:!0});Eh.findOrGenerateResponsiveLayout=xwe;Eh.getBreakpointFromWidth=gwe;Eh.getColsFromBreakpoint=bwe;Eh.sortBreakpoints=BP;var uw=bn;function gwe(e,t){const n=BP(e);let r=n[0];for(let s=1,o=n.length;s<o;s++){const i=n[s];t>e[i]&&(r=i)}return r}function bwe(e,t){if(!t[e])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+e+" is missing!");return t[e]}function xwe(e,t,n,r,s,o){if(e[n])return(0,uw.cloneLayout)(e[n]);let i=e[r];const a=BP(t),c=a.slice(a.indexOf(n));for(let u=0,d=c.length;u<d;u++){const f=c[u];if(e[f]){i=e[f];break}}return i=(0,uw.cloneLayout)(i||[]),(0,uw.compact)((0,uw.correctBounds)(i,{cols:s}),o,s)}function BP(e){return Object.keys(e).sort(function(n,r){return e[n]-e[r]})}Object.defineProperty(_k,"__esModule",{value:!0});_k.default=void 0;var X$=yK(S),To=xK(cd),xI=SP,zm=bn,kd=Eh,ywe=xK(L0);function xK(e){return e&&e.__esModule?e:{default:e}}function yK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(yK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function _2(){return _2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_2.apply(null,arguments)}function eC(e,t,n){return(t=vwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vwe(e){var t=wwe(e,"string");return typeof t=="symbol"?t:t+""}function wwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Q$=e=>Object.prototype.toString.call(e);function dw(e,t){return e==null?null:Array.isArray(e)?e:e[t]}class VP extends X$.Component{constructor(){super(...arguments),eC(this,"state",this.generateInitialState()),eC(this,"onLayoutChange",t=>{this.props.onLayoutChange(t,{...this.props.layouts,[this.state.breakpoint]:t})})}generateInitialState(){const{width:t,breakpoints:n,layouts:r,cols:s}=this.props,o=(0,kd.getBreakpointFromWidth)(n,t),i=(0,kd.getColsFromBreakpoint)(o,s),a=this.props.verticalCompact===!1?null:this.props.compactType;return{layout:(0,kd.findOrGenerateResponsiveLayout)(r,n,o,o,i,a),breakpoint:o,cols:i}}static getDerivedStateFromProps(t,n){if(!(0,xI.deepEqual)(t.layouts,n.layouts)){const{breakpoint:r,cols:s}=n;return{layout:(0,kd.findOrGenerateResponsiveLayout)(t.layouts,t.breakpoints,r,r,s,t.compactType),layouts:t.layouts}}return null}componentDidUpdate(t){(this.props.width!=t.width||this.props.breakpoint!==t.breakpoint||!(0,xI.deepEqual)(this.props.breakpoints,t.breakpoints)||!(0,xI.deepEqual)(this.props.cols,t.cols))&&this.onWidthChange(t)}onWidthChange(t){const{breakpoints:n,cols:r,layouts:s,compactType:o}=this.props,i=this.props.breakpoint||(0,kd.getBreakpointFromWidth)(this.props.breakpoints,this.props.width),a=this.state.breakpoint,c=(0,kd.getColsFromBreakpoint)(i,r),u={...s};if(a!==i||t.breakpoints!==n||t.cols!==r){a in u||(u[a]=(0,zm.cloneLayout)(this.state.layout));let h=(0,kd.findOrGenerateResponsiveLayout)(u,n,i,a,c,o);h=(0,zm.synchronizeLayoutWithChildren)(h,this.props.children,c,o,this.props.allowOverlap),u[i]=h,this.props.onBreakpointChange(i,c),this.props.onLayoutChange(h,u),this.setState({breakpoint:i,layout:h,cols:c})}const d=dw(this.props.margin,i),f=dw(this.props.containerPadding,i);this.props.onWidthChange(this.props.width,d,c,f)}render(){const{breakpoint:t,breakpoints:n,cols:r,layouts:s,margin:o,containerPadding:i,onBreakpointChange:a,onLayoutChange:c,onWidthChange:u,...d}=this.props;return X$.createElement(ywe.default,_2({},d,{margin:dw(o,this.state.breakpoint),containerPadding:dw(i,this.state.breakpoint),onLayoutChange:this.onLayoutChange,layout:this.state.layout,cols:this.state.cols}))}}_k.default=VP;eC(VP,"propTypes",{breakpoint:To.default.string,breakpoints:To.default.object,allowOverlap:To.default.bool,cols:To.default.object,margin:To.default.oneOfType([To.default.array,To.default.object]),containerPadding:To.default.oneOfType([To.default.array,To.default.object]),layouts(e,t){if(Q$(e[t])!=="[object Object]")throw new Error("Layout property must be an object. Received: "+Q$(e[t]));Object.keys(e[t]).forEach(n=>{if(!(n in e.breakpoints))throw new Error("Each key in layouts must align with a key in breakpoints.");(0,zm.validateLayout)(e.layouts[n],"layouts."+n)})},width:To.default.number.isRequired,onBreakpointChange:To.default.func,onLayoutChange:To.default.func,onWidthChange:To.default.func});eC(VP,"defaultProps",{breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},containerPadding:{lg:null,md:null,sm:null,xs:null,xxs:null},layouts:{},margin:[10,10],allowOverlap:!1,onBreakpointChange:zm.noop,onLayoutChange:zm.noop,onWidthChange:zm.noop});var HP={},vK=function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(s,o){return s[0]===n?(r=o,!0):!1}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),s=this.__entries__[r];return s&&s[1]},t.prototype.set=function(n,r){var s=e(this.__entries__,n);~s?this.__entries__[s][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,s=e(r,n);~s&&r.splice(s,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var s=0,o=this.__entries__;s<o.length;s++){var i=o[s];n.call(r,i[1],i[0])}},t}()}(),j2=typeof window<"u"&&typeof document<"u"&&window.document===document,tC=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),Swe=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(tC):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),Cwe=2;function Nwe(e,t){var n=!1,r=!1,s=0;function o(){n&&(n=!1,e()),r&&a()}function i(){Swe(o)}function a(){var c=Date.now();if(n){if(c-s<Cwe)return;r=!0}else n=!0,r=!1,setTimeout(i,t);s=c}return a}var kwe=20,_we=["top","right","bottom","left","width","height","size","weight"],jwe=typeof MutationObserver<"u",Iwe=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=Nwe(this.refresh.bind(this),kwe)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!j2||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),jwe?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!j2||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,s=_we.some(function(o){return!!~r.indexOf(o)});s&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),wK=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var s=r[n];Object.defineProperty(e,s,{value:t[s],enumerable:!1,writable:!1,configurable:!0})}return e},mp=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||tC},SK=jk(0,0,0,0);function nC(e){return parseFloat(e)||0}function J$(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,s){var o=e["border-"+s+"-width"];return r+nC(o)},0)}function Ewe(e){for(var t=["top","right","bottom","left"],n={},r=0,s=t;r<s.length;r++){var o=s[r],i=e["padding-"+o];n[o]=nC(i)}return n}function Twe(e){var t=e.getBBox();return jk(0,0,t.width,t.height)}function Dwe(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return SK;var r=mp(e).getComputedStyle(e),s=Ewe(r),o=s.left+s.right,i=s.top+s.bottom,a=nC(r.width),c=nC(r.height);if(r.boxSizing==="border-box"&&(Math.round(a+o)!==t&&(a-=J$(r,"left","right")+o),Math.round(c+i)!==n&&(c-=J$(r,"top","bottom")+i)),!Awe(e)){var u=Math.round(a+o)-t,d=Math.round(c+i)-n;Math.abs(u)!==1&&(a-=u),Math.abs(d)!==1&&(c-=d)}return jk(s.left,s.top,a,c)}var Mwe=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof mp(e).SVGGraphicsElement}:function(e){return e instanceof mp(e).SVGElement&&typeof e.getBBox=="function"}}();function Awe(e){return e===mp(e).document.documentElement}function Rwe(e){return j2?Mwe(e)?Twe(e):Dwe(e):SK}function Pwe(e){var t=e.x,n=e.y,r=e.width,s=e.height,o=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,i=Object.create(o.prototype);return wK(i,{x:t,y:n,width:r,height:s,top:n,right:t+r,bottom:s+n,left:t}),i}function jk(e,t,n,r){return{x:e,y:t,width:n,height:r}}var Fwe=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=jk(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=Rwe(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),Owe=function(){function e(t,n){var r=Pwe(n);wK(this,{target:t,contentRect:r})}return e}(),Lwe=function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new vK,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof mp(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new Fwe(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof mp(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new Owe(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),CK=typeof WeakMap<"u"?new WeakMap:new vK,NK=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=Iwe.getInstance(),r=new Lwe(t,n,this);CK.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){NK.prototype[e]=function(){var t;return(t=CK.get(this))[e].apply(t,arguments)}});var $we=function(){return typeof tC.ResizeObserver<"u"?tC.ResizeObserver:NK}();const zwe=Object.freeze(Object.defineProperty({__proto__:null,default:$we},Symbol.toStringTag,{value:"Module"})),Bwe=p.getAugmentedNamespace(zwe);Object.defineProperty(HP,"__esModule",{value:!0});HP.default=Ywe;var fw=kK(S),Vwe=UP(cd),Hwe=UP(Bwe),Uwe=UP(pk);function UP(e){return e&&e.__esModule?e:{default:e}}function kK(e,t){if(typeof WeakMap=="function")var n=new WeakMap,r=new WeakMap;return(kK=function(s,o){if(!o&&s&&s.__esModule)return s;var i,a,c={__proto__:null,default:s};if(s===null||typeof s!="object"&&typeof s!="function")return c;if(i=o?r:n){if(i.has(s))return i.get(s);i.set(s,c)}for(const u in s)u!=="default"&&{}.hasOwnProperty.call(s,u)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(s,u))&&(a.get||a.set)?i(c,u,a):c[u]=s[u]);return c})(e,t)}function I2(){return I2=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I2.apply(null,arguments)}function Zh(e,t,n){return(t=qwe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qwe(e){var t=Wwe(e,"string");return typeof t=="symbol"?t:t+""}function Wwe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Gwe="react-grid-layout";function Ywe(e){var t;return t=class extends fw.Component{constructor(){super(...arguments),Zh(this,"state",{width:1280}),Zh(this,"elementRef",fw.createRef()),Zh(this,"mounted",!1),Zh(this,"resizeObserver",void 0)}componentDidMount(){this.mounted=!0,this.resizeObserver=new Hwe.default(s=>{if(this.elementRef.current instanceof HTMLElement){const i=s[0].contentRect.width;this.setState({width:i})}});const r=this.elementRef.current;r instanceof HTMLElement&&this.resizeObserver.observe(r)}componentWillUnmount(){this.mounted=!1;const r=this.elementRef.current;r instanceof HTMLElement&&this.resizeObserver.unobserve(r),this.resizeObserver.disconnect()}render(){const{measureBeforeMount:r,...s}=this.props;return r&&!this.mounted?fw.createElement("div",{className:(0,Uwe.default)(this.props.className,Gwe),style:this.props.style,ref:this.elementRef}):fw.createElement(e,I2({innerRef:this.elementRef},s,this.state))}},Zh(t,"defaultProps",{measureBeforeMount:!1}),Zh(t,"propTypes",{measureBeforeMount:Vwe.default.bool}),t}(function(e){e.exports=L0.default,e.exports.utils=bn,e.exports.calculateUtils=vl,e.exports.Responsive=_k.default,e.exports.Responsive.utils=Eh,e.exports.WidthProvider=HP.default})(zY);var e4=zY.exports;const _K=S.createContext(void 0);function Cl(){const e=S.useContext(_K);return e||{displayPreferences:{mode:"full"},shouldShowElement:()=>!0}}var pp=1e3,gp=pp*60,bp=gp*60,Zf=bp*24,Kwe=Zf*7,Zwe=Zf*365.25,Xwe=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return Qwe(e);if(n==="number"&&isFinite(e))return t.long?e1e(e):Jwe(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Qwe(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*Zwe;case"weeks":case"week":case"w":return n*Kwe;case"days":case"day":case"d":return n*Zf;case"hours":case"hour":case"hrs":case"hr":case"h":return n*bp;case"minutes":case"minute":case"mins":case"min":case"m":return n*gp;case"seconds":case"second":case"secs":case"sec":case"s":return n*pp;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function Jwe(e){var t=Math.abs(e);return t>=Zf?Math.round(e/Zf)+"d":t>=bp?Math.round(e/bp)+"h":t>=gp?Math.round(e/gp)+"m":t>=pp?Math.round(e/pp)+"s":e+"ms"}function e1e(e){var t=Math.abs(e);return t>=Zf?hw(e,t,Zf,"day"):t>=bp?hw(e,t,bp,"hour"):t>=gp?hw(e,t,gp,"minute"):t>=pp?hw(e,t,pp,"second"):e+" ms"}function hw(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}const t1e=p.getDefaultExportFromCjs(Xwe);function n1e(e,t={}){if(!e)return[];const n=[],r=[...t.existingInputs||[]];for(const s of e.inlineFilters||[]){const o=s.title||s.column||s.id,i=o1e(s),a={id:r1e(e.id,s.id),kind:"filter",label:o,variableName:s.variableName?Eu(s.variableName,r):UR(o,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:{placement:"card_header"},filter:i,exports:qR(i),compatibility:{source:"cardInlineFilter",cardId:e.id,filterId:s.id}};r.push(a),n.push(a)}for(const s of e.controls||[]){const o=s.label||s.id,i={id:s1e(e.id,s.id),kind:"control",label:o,variableName:Eu(s.id,r),scope:{kind:"cards",cardIds:[e.id]},runtimeScope:"perCard",presentation:Vq(s),control:s,exports:WR(s),requiredAtExecution:s.requiredAtExecution,compatibility:{source:"cardControl",cardId:e.id,controlId:s.id}};r.push(i),n.push(i)}return n}function r1e(e,t){return`compat-inline-filter:${e}:${t}`}function s1e(e,t){return`compat-card-control:${e}:${t}`}function o1e(e){return{kind:"field",id:e.id,variableName:e.variableName,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel,toolbarWidth:e.width,displayMode:"toolbar"}}function i1e(e,t={}){const n=[],r=[...t.existingInputs||[]];for(const s of e.controls||[]){const o=s.label||s.id,i={id:jK(s.id),kind:"control",label:o,variableName:Eu(s.id,r),scope:{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:Vq(s),control:s,exports:WR(s),requiredAtExecution:s.requiredAtExecution,compatibility:{source:"dashboardControl",controlId:s.id}};r.push(i),n.push(i)}return n}function jK(e){return`compat-control:${e}`}function a1e(e,t={}){const n=[],r=[...t.existingInputs||[]],s=t.availableSheetIds||(e.sheets||[]).filter(u=>u.kind!=="document").map(u=>u.id),o=p.getDashboardCardEntries({sheets:e.sheets}),i=t.availableCardIds?new Set(t.availableCardIds):void 0,a=o.filter(u=>!i||i.has(u.card.id)),c=t.availableCardIds||a.map(u=>u.card.id);for(const u of e.filters||[]){const d=u.title||u.column||u.id,f={id:qP(u.id),kind:"filter",label:d,variableName:u.variableName?Eu(u.variableName,r):UR(d,r),scope:l1e(u,{availableDashboardSheetIds:s,availableCardEntries:a,availableCardIds:c}),runtimeScope:"shared",presentation:tpe(u),filter:u,exports:qR(u),compatibility:{source:"dashboardFilter",filterId:u.id}};r.push(f),n.push(f)}return n}function qP(e){return`compat-filter:${e}`}function l1e(e,t){if(e.applyToCardIds!==void 0){const n=new Set(t4(e,t));return{kind:"cards",cardIds:e.applyToCardIds.filter(r=>n.has(r))}}if(e.excludeCardIds!==void 0){const n=new Set(e.excludeCardIds);return{kind:"cards",cardIds:t4(e,t).filter(s=>!n.has(s))}}if(e.sheetId)return{kind:"sheets",sheetIds:[e.sheetId]};if(e.applyToSheetIds!==void 0)return{kind:"sheets",sheetIds:e.applyToSheetIds};if(e.excludeSheetIds!==void 0){const n=new Set(e.excludeSheetIds);return{kind:"sheets",sheetIds:t.availableDashboardSheetIds.filter(r=>!n.has(r))}}return{kind:"allSheets",sheetKinds:["dashboard"]}}function t4(e,t){return!e.sheetId&&e.applyToSheetIds===void 0&&e.excludeSheetIds===void 0?t.availableCardIds:t.availableCardEntries.filter(n=>c1e(e,n.sheet.id)).map(n=>n.card.id)}function c1e(e,t){return e.sheetId&&e.sheetId!==t?!1:e.applyToSheetIds!==void 0?e.applyToSheetIds.includes(t):e.excludeSheetIds!==void 0?!e.excludeSheetIds.includes(t):!0}function Ik({dashboard:e,card:t,availableSheetIds:n,availableCardIds:r}){const s=e.inputs||[],o=[],i=[...s],a=a1e(e,{existingInputs:i,availableSheetIds:n,availableCardIds:r});o.push(...a),i.push(...a);const c=i1e(e,{existingInputs:i});o.push(...c),i.push(...c);const u=n1e(t,{existingInputs:i});return o.push(...u),{authoredInputs:s,compatibilityInputs:o,allInputs:[...s,...o]}}function Nl({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,runtimeValues:o,mode:i="interactive",timezone:a}){const c={sheetId:t,cardId:n==null?void 0:n.id,sectionId:r,sheetKind:s||w1e(e,t)},u=Ik({dashboard:e,card:n}),d=IK(u.allInputs.filter(g=>xp(g,c)));v1e(d);const f=d.map(g=>d1e({dashboard:e,input:g,runtimeValues:o,target:c,timezone:a})),h=h1e({resolvedInputs:f,card:n}),m=m1e(f);return{inputs:d,resolvedInputs:f,...h,...m,missingRequiredInputs:f.filter(g=>g.missingRequiredValue)}}function xp(e,t){var n;if(!u1e(e,t))return!1;switch(e.scope.kind){case"allSheets":return(n=e.scope.sheetKinds)!=null&&n.length?t.sheetKind?e.scope.sheetKinds.includes(t.sheetKind):!1:!!t.sheetId||!!t.cardId;case"sheets":return!!t.sheetId&&e.scope.sheetIds.includes(t.sheetId);case"cards":return!!t.cardId&&e.scope.cardIds.includes(t.cardId);case"documentSections":return!!t.sheetId&&!!t.sectionId&&e.scope.sheetId===t.sheetId&&e.scope.sectionIds.includes(t.sectionId);default:return!1}}function u1e(e,t){return t.sheetKind!=="document"||!e.compatibility||e.compatibility.source==="documentInput"?!0:e.compatibility.source==="cardInlineFilter"||e.compatibility.source==="cardControl"?!!t.cardId&&e.compatibility.cardId===t.cardId:!1}function IK(e){const t=new Set(e.filter(n=>!WS(n)).map(g$));return e.filter(n=>!WS(n)||!t.has(g$(n)))}function d1e(e){var a;const t=!!e.runtimeValues.dashboardInputValuesAreAuthoritative,n=!t&&WS(e.input)&&((a=e.input.compatibility)==null?void 0:a.source)!=="documentInput",r=t?p.getDashboardInputRuntimeSlot(e.runtimeValues.dashboardInputValues,e.input,e.target):n?p1e(e):p.hydrateAuthoredDashboardInputSlot({dashboard:e.dashboard,input:e.input,runtimeValues:e.runtimeValues.dashboardInputValues,target:e.target,timezone:e.timezone}),s=(r==null?void 0:r.status)==="set"&&r.value.kind===e.input.kind?r.value:void 0;if(e.input.kind==="filter"){const c=(s==null?void 0:s.kind)==="filter"?EK(e.input,s.filterValue):void 0,u=b1e({input:e.input,filterValue:c,timezone:e.timezone});return{id:e.input.id,kind:"filter",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:r,rawValue:c?S1e(c.values):void 0,displayValue:n4(u.label??u.value),exports:u,filter:e.input.filter,filterValue:c,missingRequiredValue:!!e.input.requiredAtExecution&&!c}}const o=(s==null?void 0:s.kind)==="control"?s.value:void 0,i=x1e({input:e.input,value:o});return{id:e.input.id,kind:"control",label:e.input.label,variableName:e.input.variableName,requiredAtExecution:!!e.input.requiredAtExecution,slot:r,rawValue:o,displayValue:n4(i.label??i.value),exports:i,control:e.input.control,controlValue:o,missingRequiredValue:!!e.input.requiredAtExecution&&!f1e(o)}}function f1e(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0}function h1e({resolvedInputs:e,card:t}){const n=[],r=new Map,s=new Map,o={};for(const c of e){if(c.kind==="filter"){c.filter&&c.filterValue&&n.push(c.filterValue);continue}c.control&&(y1e(c)?s.set(c.control.id,c.control):r.set(c.control.id,c.control),c.controlValue!==void 0&&(o[c.control.id]=c.controlValue))}const i=new Set([...r.keys(),...s.keys()]),a=((t==null?void 0:t.controlBindings)||[]).filter(c=>i.has(c.controlId));return{activeFilters:n,controlDefinitions:Array.from(r.values()),cardControlDefinitions:Array.from(s.values()),controlBindings:a,controlValues:o}}function m1e(e){const t={},n={};for(const r of e)n[r.id]=r,t[r.variableName]=r;return{variablesByName:t,variablesById:n}}function p1e(e){var s,o,i,a;const t=(s=e.input.compatibility)==null?void 0:s.source;if(e.input.kind==="filter"){const c=e.input.filter.id,u=t==="cardInlineFilter"?e.target.cardId?(i=(o=e.runtimeValues.inlineFilterValuesMap)==null?void 0:o[e.target.cardId])==null?void 0:i.find(d=>d.filterId===c):void 0:(a=e.runtimeValues.filterValues)==null?void 0:a.find(d=>d.filterId===c);return u?p.createFilterDashboardInputSlot(EK(e.input,u)):void 0}const n=e.input.control.id,r=g1e({source:t,target:e.target,runtimeValues:e.runtimeValues});if(r.values&&Object.prototype.hasOwnProperty.call(r.values,n))return p.createControlDashboardInputSlot(r.values[n]);if(!r.isExplicit)return t==="dashboardControl"?p.createControlDashboardInputSlot(p.resolveSavedDefaultValue(e.input.control,e.dashboard.defaultControlValues)):p.getBackingDefaultSlot(e.input,e.timezone)}function g1e({source:e,target:t,runtimeValues:n}){var r;return e==="cardControl"&&t.cardId?{values:(r=n.cardControlValuesMap)==null?void 0:r[t.cardId],isExplicit:!!(n.cardControlValuesMap&&Object.prototype.hasOwnProperty.call(n.cardControlValuesMap,t.cardId))}:{values:n.controlValues,isExplicit:n.controlValues!==void 0}}function EK(e,t){const n=t.filterId===e.filter.id?t:{...t,filterId:e.filter.id};return p.isCompatibleFilterValue(e.filter,n)?n:void 0}function b1e({input:e,filterValue:t,timezone:n}){const r=e.exports||qR(e.filter),s=(t==null?void 0:t.values)||[],o=p.getDataType(e.filter.dataType)==="date",i=s.map(k1e),a=o?i.length>1?`${i[0]} - ${i[1]}`:i[0]||"":i.join(", "),c={};for(const u of r)u==="start"?c.start=i[0]||null:u==="end"?c.end=i[1]||null:u==="range"?c.range=a||null:c[u]=a||null;return c}function x1e({input:e,value:t}){const n=e.exports||WR(e.control),r=C1e(t),s=r.map(a=>N1e(e.control,a)).join(", "),o=r.map(TK).join(", "),i={};for(const a of n)i[a]=a==="label"?s||null:o||null;return i}function y1e(e){return e.control?e.control.scope==="card"||e.id.startsWith("compat-card-control:"):!1}function v1e(e){const t=new Map;for(const n of e){if(WS(n))continue;const r=t.get(n.variableName);if(r)throw new Error(`Duplicate dashboard input variableName "${n.variableName}" for inputs "${r}" and "${n.id}" in the same resolved scope.`);t.set(n.variableName,n.id)}}function w1e(e,t){var r;if(!t)return;const n=(r=e.sheets)==null?void 0:r.find(s=>s.id===t);return(n==null?void 0:n.kind)==="document"?"document":"dashboard"}function S1e(e){return e.length>1?e:e[0]??null}function C1e(e){return e==null?[]:Array.isArray(e)?e:[e]}function N1e(e,t){var r;const n=TK(t);return e.source.kind==="manual"&&((r=e.source.options.find(s=>s.value===n))==null?void 0:r.label)||n}function TK(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function k1e(e){return e instanceof Date?e.toISOString():typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e==null?"":JSON.stringify(e)}function n4(e){return e==null?"":String(e)}function WP(e,t,n,r){const s=e==null?void 0:e.filter(a=>a.sheetId&&a.sheetId!==n?!1:a.applyToSheetIds!==void 0?a.applyToSheetIds.includes(n):a.excludeSheetIds!==void 0?!a.excludeSheetIds.includes(n):!0),o=s==null?void 0:s.filter(a=>a.applyToCardIds!==void 0?a.applyToCardIds.includes(r):a.excludeCardIds!==void 0?!a.excludeCardIds.includes(r):!0),i=t==null?void 0:t.filter(a=>(o==null?void 0:o.some(c=>c.id===a.filterId))||a.filterId.endsWith(n));return{cardFilters:o,cardFilterValues:i}}function B0({card:e,interactionStates:t,currentDashboardId:n,filters:r,filterValues:s,selectedSheetId:o}){const i=t==null?void 0:t.__DRILL_CONTEXT__,c=(i==null?void 0:i.targetDashboardId)===n?i==null?void 0:i.contextMode:void 0,u=t==null?void 0:t[e.id],d=u==null?void 0:u.contextMode,f=c||d,h=!f||f==="full",{cardFilters:m,cardFilterValues:g}=h?WP(r,s,o,e.id):{cardFilters:void 0,cardFilterValues:void 0};return{cardFilters:m,cardFilterValues:g,shouldApplyDashboardFilters:h,contextMode:f}}function sb(e){return e==null?void 0:e.map(({format:t,...n})=>n)}function DK(e){if(!e)return;const{format:t,...n}=e;return mm(n)}function _1e(e){return{...e,field:DK(e.field)}}function GP(e){if(e)return{...e,conditions:e.conditions.map(_1e),groups:e.groups.map(t=>GP(t))}}function mm(e){var n,r;const t={...e};return(n=t.calculatedFormula)!=null&&n.inputFields&&(t.calculatedFormula={...t.calculatedFormula,inputFields:t.calculatedFormula.inputFields.map(s=>DK(s))}),(r=t.parameters)!=null&&r.filters&&(t.parameters={...t.parameters,filters:GP(t.parameters.filters)}),t}function MK(e,t={}){var r,s,o,i,a;if(!e)return;const n={...e,groupByColumns:(r=sb(e.groupByColumns))==null?void 0:r.map(mm),metricColumns:(s=sb(e.metricColumns))==null?void 0:s.map(mm),pivotByColumns:(o=sb(e.pivotByColumns))==null?void 0:o.map(mm),sortByColumns:(i=sb(e.sortByColumns))==null?void 0:i.map(mm),detailColumns:(a=sb(e.detailColumns))==null?void 0:a.map(mm),filters:GP(e.filters)};return t.cardType!=="matrixTable"?n:j1e({outputConfig:n,shelfConfig:e,dataSource:t.dataSource})}function j1e(e){const{outputConfig:t,shelfConfig:n,dataSource:r}=e,s=E1e(t),o=T1e(r)||(s==null?void 0:s.source)||t.source;if(!o)return t;const i=Array.isArray(t.groupByColumns),a=Array.isArray(t.pivotByColumns),c=Array.isArray(t.metricColumns),u=i||a||c,d=i?r4(t.groupByColumns||[],o):(s==null?void 0:s.rows)||t.rows||[],f=a?r4(t.pivotByColumns||[],o):(s==null?void 0:s.columns)||t.columns||[],h=c?D1e(n.metricColumns||[],o):(s==null?void 0:s.values)||t.values||[],m=I1e({existingTotals:t.totals||(u||s==null?void 0:s.totals),hasColumnAxis:f.length>0}),g={kind:"matrix",version:1,source:o,rows:d,columns:f,values:h,...s!=null&&s.filters?{filters:s.filters}:{},...s!=null&&s.inputs||t.inputs?{inputs:(s==null?void 0:s.inputs)||t.inputs}:{},totals:m,...s!=null&&s.sort||t.sort?{sort:(s==null?void 0:s.sort)||t.sort}:{},...s!=null&&s.expansion||t.expansion?{expansion:(s==null?void 0:s.expansion)||t.expansion}:{},...s!=null&&s.layout||t.layout?{layout:(s==null?void 0:s.layout)||t.layout}:{},...s!=null&&s.displayLimits||t.displayLimits?{displayLimits:(s==null?void 0:s.displayLimits)||t.displayLimits}:{}},{source:b,rows:x,columns:y,values:w,inputs:v,totals:C,sort:N,expansion:k,layout:_,displayLimits:j,version:E,...I}=t;return{...I,matrixIntent:g}}function I1e(e){var t,n,r;return{rows:((t=e.existingTotals)==null?void 0:t.rows)??!0,columns:((n=e.existingTotals)==null?void 0:n.columns)??e.hasColumnAxis,grandTotal:((r=e.existingTotals)==null?void 0:r.grandTotal)??!0}}function E1e(e){var t;if(((t=e.matrixIntent)==null?void 0:t.kind)==="matrix")return e.matrixIntent;if(!(!e.source||!e.rows||!e.values))return{kind:"matrix",version:e.version||1,source:e.source,rows:e.rows,columns:e.columns,values:e.values,...e.inputs?{inputs:e.inputs}:{},...e.totals?{totals:e.totals}:{},...e.sort?{sort:e.sort}:{},...e.expansion?{expansion:e.expansion}:{},...e.layout?{layout:e.layout}:{},...e.displayLimits?{displayLimits:e.displayLimits}:{}}}function T1e(e){var n;const t=(n=e==null?void 0:e.selectedEntities)==null?void 0:n[0];if(!(!e||!t)){if(e.mode==="semanticDomain"&&e.semanticDomainId)return{kind:"semantic",domainId:e.semanticDomainId,datasetName:t.name,..."id"in t&&t.id?{datasetId:t.id}:{},..."label"in t&&t.label?{label:t.label}:{},connectionId:t.connectionId||e.connectionId};if(e.mode==="database")return{kind:"physical",connectionId:t.connectionId||e.connectionId,connectionType:t.connectionType||e.connectionType,tableName:t.name,databaseName:t.database,schemaName:t.schema,..."label"in t&&t.label?{label:t.label}:{},dialect:t.dialect}}}function r4(e,t){const n=RK();return e.map((r,s)=>M1e(r,s,t,n))}function D1e(e,t){const n=RK();return e.map((r,s)=>A1e(r,s,t,n))}function M1e(e,t,n,r){return{id:r(e,t,{kind:"axis",grain:yI(e.granularity)}),field:AK(e,n),...yI(e.granularity)?{grain:yI(e.granularity)}:{},label:e.label||e.name}}function A1e(e,t,n,r){return{id:r(e,t,{kind:"value",aggregate:E2(e.aggregate)}),field:AK(e,n),aggregate:E2(e.aggregate),label:e.label||e.name,...e.format?{format:e.format}:{}}}function AK(e,t){return{name:e.sourceField||e.name,label:e.label||e.name,role:F1e(e),dataType:PK(e.dataType),source:R1e(e,t),...e.aggregate?{aggregate:E2(e.aggregate)}:{}}}function R1e(e,t){if(t.kind!=="semantic"||!e.entityName)return t;const n=e.entityId,r=e.entityName;return n&&n===t.datasetId||r===t.datasetName?t:{kind:"semantic",domainId:t.domainId,datasetName:r,...n?{datasetId:n}:{}}}function RK(){const e=new Set;return(t,n,r)=>{const s=P1e(t,n),o=[s];r.kind==="axis"&&r.grain&&o.push(`${s}-${r.grain}`),r.kind==="value"&&o.push(`${s}-${r.aggregate.toLowerCase()}`),o.push(`${s}-${n+1}`);for(const c of o)if(!e.has(c))return e.add(c),c;let i=n+1,a=`${s}-${i}`;for(;e.has(a);)i+=1,a=`${s}-${i}`;return e.add(a),a}}function P1e(e,t){return e.id||e.alias||e.name||`field_${t+1}`}function F1e(e){if(e.role==="metric")return"measure";const t=PK(e.dataType);return t==="date"||t==="datetime"?"date":"dimension"}function PK(e){const t=The.normalizeAnalyticsCatalogDataType(e);return t==="string"||t==="number"||t==="boolean"||t==="date"||t==="datetime"?t:"unknown"}function yI(e){if(e==="hour"||e==="day"||e==="week"||e==="month"||e==="quarter"||e==="year")return e}function E2(e){return e==="COUNT"||e==="SUM"||e==="AVG"||e==="MIN"||e==="MAX"||e==="MEDIAN"||e==="DISTINCT"?e:"SUM"}function O1e(e){const t=e.card.controlBindings||[],n=e.card.controls||[],s=e.dashboardControls||[],o=n,i=new Set([...s.map(u=>u.id),...o.map(u=>u.id)]),a=t.filter(u=>i.has(u.controlId));return{controlValues:p.mergeRelevantControlValues({relevantControlIds:i,dashboardValues:e.dashboardControlValues,cardValues:e.cardControlValues}),controlDefinitions:s,cardControlDefinitions:o,controlBindings:a}}function V0({card:e,interactionStates:t,currentDashboardId:n,filters:r,filterValues:s,selectedSheetId:o,inlineFilterValuesMap:i,dashboardControls:a,dashboardControlValues:c,cardControlValuesMap:u,dashboardInputContext:d}){var N;const{cardFilterValues:f,shouldApplyDashboardFilters:h}=B0({card:e,interactionStates:t,currentDashboardId:n,filters:r,filterValues:s,selectedSheetId:o}),m=d?$1e({dashboardInputFilterValues:L1e({dashboardInputContext:d,cardId:e.id,shouldApplyDashboardFilters:h}),dashboardFilterValues:f,filters:r,selectedSheetId:o}):[...f||[],...(i==null?void 0:i[e.id])||[]],g=t||{},b=p.resolveFiltersFromInteractionStates(e,g,n),x=p.resolveCardConfigFromInteractionStates(e,g,b),y=MK(x,{cardType:e.type,dataSource:e.dataSource})||x,w=p.getFinalFilterGroupKeyFromInteractionStates(e,g,b)||"",v=(N=g==null?void 0:g[e.id])==null?void 0:N.appliedClickFilters,C=d?{controlValues:d.controlValues,controlDefinitions:d.controlDefinitions,cardControlDefinitions:d.cardControlDefinitions,controlBindings:d.controlBindings}:O1e({card:e,dashboardControls:a,dashboardControlValues:c,cardControlValues:u==null?void 0:u[e.id]});return{cardFilterValues:m,...C,resolvedFilters:b,finalConfig:x,queryRelevantConfig:y,finalFiltersKey:w,appliedClickFilters:v}}function L1e({dashboardInputContext:e,cardId:t,shouldApplyDashboardFilters:n}){if(n)return e.activeFilters;const r=new Set(e.inputs.filter(s=>s.kind==="filter"&&s.scope.kind==="cards"&&s.scope.cardIds.includes(t)&&(!s.compatibility||s.compatibility.source==="cardInlineFilter")).map(s=>s.kind==="filter"&&s.filter.id).filter(s=>!!s));return e.activeFilters.filter(s=>r.has(s.filterId))}function $1e({dashboardInputFilterValues:e,dashboardFilterValues:t,filters:n,selectedSheetId:r}){const s=[...e],o=new Set(s.map(i=>i.filterId));for(const i of z1e({dashboardFilterValues:t,filters:n,selectedSheetId:r}))o.has(i.filterId)||(s.push(i),o.add(i.filterId));return s}function z1e({dashboardFilterValues:e,filters:t,selectedSheetId:n}){if(!n)return[];const r=new Set((t||[]).map(s=>s.id));return(e||[]).filter(s=>s.filterId.endsWith(n)&&!r.has(s.filterId))}const ob=[],vI=[],wI={},T2=[];function B1e({cards:e,dashboard:t,filters:n,dashboardControls:r,filterValues:s,controlValues:o,dashboardInputValues:i,dashboardInputValuesAreAuthoritative:a,dashboardInlineFilterValuesMap:c,editorInlineFilterValuesMap:u,dashboardCardControlValuesMap:d,interactionStates:f,filteringCards:h,selectedSheetId:m,currentDashboardId:g,isVisualEditing:b,getCardFrame:x,lastRequestPayloadMap:y,documentState:w}){U1e(e,y);const v=H1e({cards:e,isVisualEditing:b,dashboardInlineFilterValuesMap:c,editorInlineFilterValuesMap:u});return e.map(C=>V1e({card:C,dashboard:t,filters:n,dashboardControls:r,filterValues:s,controlValues:o,dashboardInputValues:i,dashboardInputValuesAreAuthoritative:a,dashboardRuntimeInlineFilterValuesMap:v,editorInlineFilterValuesMap:u,dashboardCardControlValuesMap:d,interactionStates:f,filteringCards:h,selectedSheetId:m,currentDashboardId:g,getCardFrame:x,documentState:w}))}function V1e({card:e,dashboard:t,filters:n,dashboardControls:r,filterValues:s,controlValues:o,dashboardInputValues:i,dashboardInputValuesAreAuthoritative:a,dashboardRuntimeInlineFilterValuesMap:c,editorInlineFilterValuesMap:u,dashboardCardControlValuesMap:d,interactionStates:f,filteringCards:h,selectedSheetId:m,currentDashboardId:g,getCardFrame:b,documentState:x}){var T;const y=q1e({card:e,selectedSheetId:m,editorInlineFilterValuesMap:u,documentState:x}),v=!!((T=t.inputs)!=null&&T.length)||!!t.defaultInputValues?Nl({dashboard:t,sheetId:y.isDocumentSectionRuntime?y.documentSheetId:m,sheetKind:y.isDocumentSectionRuntime?"document":void 0,sectionId:y.isDocumentSectionRuntime?y.documentSectionId:void 0,card:e,runtimeValues:{dashboardInputValues:y.documentDashboardInputValues||i,dashboardInputValuesAreAuthoritative:!!y.documentDashboardInputValues||a,filterValues:s,controlValues:o,inlineFilterValuesMap:c,cardControlValuesMap:d},mode:y.isDocumentSectionEditorRuntime?"editor":y.isDocumentSectionRuntime?"print":"interactive"}):void 0,C=v&&v.inputs.length>0?v:void 0,N=y.isDocumentSectionRuntime&&!!C,k=y.isDocumentSectionRuntime&&!N?Y1e(e,y.documentControlDefinitions):e,_=W1e({card:e,documentRuntime:y,useResolvedDocumentInputs:N,dashboardRuntimeInlineFilterValuesMap:c}),j=V0({card:k,interactionStates:y.isDocumentSectionRuntime?{}:f,currentDashboardId:g,filters:y.isDocumentSectionRuntime?[]:n,filterValues:y.isDocumentSectionRuntime?[]:s,selectedSheetId:m,inlineFilterValuesMap:_,dashboardControls:y.isDocumentSectionRuntime?[]:r,dashboardControlValues:y.isDocumentSectionRuntime?{}:o,cardControlValuesMap:G1e({card:e,documentRuntime:y,useResolvedDocumentInputs:N,dashboardCardControlValuesMap:d}),dashboardInputContext:C}),E=b(e.id),I=(E==null?void 0:E.cards)||[];return{card:k,...j,interval:t1e((e==null?void 0:e.refreshInterval)||"0"),isFilteringCard:y.isDocumentSectionRuntime?!1:(h==null?void 0:h.some(D=>D.id===e.id))||!1,isSingleCardFrame:I.length===1,isDocumentSectionRuntime:y.isDocumentSectionRuntime,missingRequiredInputLabels:y.missingRequiredInputLabels,dashboardInputMissingRequiredLabels:(C==null?void 0:C.missingRequiredInputs.map(D=>D.label))||T2,queryFilterDefinitions:C?C.inputs.flatMap(D=>D.kind==="filter"?[D.filter]:[]):y.isDocumentSectionRuntime?[]:n||[]}}function H1e({cards:e,isVisualEditing:t,dashboardInlineFilterValuesMap:n,editorInlineFilterValuesMap:r}){return t?e.reduce((s,o)=>(s[o.id]=r[o.id]??n[o.id],s),{}):n}function U1e(e,t){if(!t)return;const n=new Set(e.map(r=>r.id));for(const r of t.keys())n.has(r)||t.delete(r)}function q1e({card:e,selectedSheetId:t,editorInlineFilterValuesMap:n,documentState:r}){const s=r.editedDocumentSectionCardId===e.id,o=r.isExplicitDocumentSectionRuntime||s,i=r.explicitDocumentSheetId||(s&&r.isDocumentSectionEditing?r.editorDocumentSheetId:void 0)||t||void 0,a=r.explicitDocumentSectionId||(s&&r.isDocumentSectionEditing?r.editorDocumentSectionId:void 0),c=r.isExplicitDocumentSectionRuntime?r.explicitDocumentFilterValues||ob:s&&r.editorDocumentFilterValues||ob,u=r.isExplicitDocumentSectionRuntime?r.explicitDocumentControlValues||wI:s&&r.editorDocumentControlValues||wI,d=r.isExplicitDocumentSectionRuntime?r.explicitDocumentControlDefinitions||vI:s&&r.editorDocumentControlDefinitions||vI,f=r.isExplicitDocumentSectionRuntime?r.explicitDocumentDashboardInputValues:void 0;return{isDocumentSectionRuntime:o,isDocumentSectionEditorRuntime:s,documentSheetId:i,documentSectionId:a,documentFilterValues:c,documentControlValues:u,documentControlDefinitions:d,documentDashboardInputValues:f,missingRequiredInputLabels:s&&r.editorMissingRequiredInputLabels||T2,editorFilterValues:s&&n[e.id]||ob}}function W1e({card:e,documentRuntime:t,useResolvedDocumentInputs:n,dashboardRuntimeInlineFilterValuesMap:r}){if(!t.isDocumentSectionRuntime)return r;if(n)return{};const s=[...t.editorFilterValues,...t.documentFilterValues];return s.length?{[e.id]:s}:{}}function G1e({card:e,documentRuntime:t,useResolvedDocumentInputs:n,dashboardCardControlValuesMap:r}){return t.isDocumentSectionRuntime?n?{}:Object.keys(t.documentControlValues).length>0?{[e.id]:t.documentControlValues}:{}:r}function Y1e(e,t){if(t.length===0)return e;const n=new Map;for(const r of e.controls||[])n.set(r.id,r);for(const r of t)n.set(r.id,r);return{...e,controls:Array.from(n.values())}}function K1e(e){return{databaseName:(e==null?void 0:e.lastSelectedDatabase)||"",schemaName:(e==null?void 0:e.lastSelectedSchema)||"",tableName:(e==null?void 0:e.lastSelectedTable)||"",datamodelId:(e==null?void 0:e.datamodelId)||""}}function FK(e){return e===FR?"":e}const Z1e=["table","detailTable"],D2=e=>Z1e.includes(e.type);function X1e(e){const{id:t,...n}=e;return n}function OK(e){if(!e)return;const{id:t,conditions:n,groups:r,...s}=e;return{...s,conditions:n.map(X1e),groups:r.map(o=>OK(o))}}function Q1e(e){return JSON.stringify(e&&{...e,filters:OK(e.filters)})}function J1e(e,t){const n=new Map;for(const s of(t==null?void 0:t.controlDefinitions)||[])n.set(s.id,s.type);for(const s of(t==null?void 0:t.cardControlDefinitions)||[])n.set(s.id,s.type);const r=Object.fromEntries(Object.entries(e||{}).map(([s,o])=>n.get(s)==="multi_enum"&&Array.isArray(o)?[s,[...o].sort((i,a)=>So.stableSerialize(i).localeCompare(So.stableSerialize(a)))]:[s,o]));return So.stableSerialize(r)}function eSe(e,{finalFiltersKey:t,selectedLensId:n,cardFilterValues:r,controlValues:s,controlDefinitions:o,cardControlDefinitions:i,controlBindings:a,queryRelevantConfig:c,resolvedPrimaryDateField:u}){var w,v;const{filterColumns:d,...f}=e.queryConfig||{},h=d==null?void 0:d.filter(C=>{var N,k;return(k=(N=e.queryConfig)==null?void 0:N.filters)==null?void 0:k.some(_=>_.filterColumnName===C.name)}),m=(e==null?void 0:e.sql)||"",g=FK((e==null?void 0:e.python)||""),b=["table","aggregateTable","pivotTable","detailTable","matrixTable"].includes(e.type)?"table":e.type==="kpi"?"kpi":"chart",x=D2(e)&&p.hasValidCardConfig(e.config)||D2(e)&&e.sql&&((v=(w=e.preferences)==null?void 0:w.tablePrefs)==null?void 0:v.enableDevModePagination),y=c||MK(e.config);return["query",e==null?void 0:e.id,b,m,g,n||"",JSON.stringify(r),J1e(s,{controlDefinitions:o,cardControlDefinitions:i}),l2({controlDefinitions:o,cardControlDefinitions:i,controlBindings:a}),So.stableSerialize(u??null),JSON.stringify(f),JSON.stringify(h),Q1e(y),t,x?JSON.stringify(e.paginationConfig):""]}function Qs(e){return typeof e=="string"?e.trim():""}function Xf(e){return Array.from(new Set(e.map(Qs).filter(Boolean)))}function Th(e){var t;return(t=e.candidateDatasetNames)!=null&&t.length?Xf(e.candidateDatasetNames):Xf([e.datasetName])}function YP(e,t){const n=e||[];for(const r of Th(t)){const s=n.find(i=>Qs(i.name)===r);if(s)return s;const o=n.filter(i=>$K(i).includes(r));if(o.length===1)return o[0]}}function LK(e,t){const n=Qs(t.name);if(!n)return[];const r=$K(t).filter(s=>YP(e,{datasetName:s})===t);return Xf([n,...r])}function $K(e){const t=Qs(e.table),n=Qs(e.schema),r=Qs(e.catalog)||Qs(e.database);return t?Xf([t,n?`${n}.${t}`:"",r?`${r}.${t}`:"",r&&n?`${r}.${n}.${t}`:""]):[]}function zK(e,t,n,r=[n]){if(!t||!n)return;const s=Xf(r);e.set(`${t}:${n}:${s.join("|")}`,{domainId:t,datasetName:n,candidateDatasetNames:s})}function BK(e,t,n){var r;for(const s of((r=e.dataSource)==null?void 0:r.selectedEntities)||[])(s==null?void 0:s.type)==="dataset"&&zK(n,Qs(s.domainId)||t,Qs(s.name))}function SI(e,t,n,r){const s=HK(e,t,r);s&&zK(n,s.domainId,s.datasetName,Th(s))}function tSe(e,t,n,r){var o;const s=(o=e.config)==null?void 0:o.joinPlan;if(s){SI(s.baseEntity,t,n,r);for(const i of s.joins||[])SI(i.source,t,n,r),SI(i.target,t,n,r)}}function nSe(e,t){var s;if(!e)return;const n=Qs((s=e.dataSource)==null?void 0:s.semanticDomainId),r=VK(e);BK(e,n,t),tSe(e,n,t,r)}function VK(e){var r;if(!e)return[];const t=new Map,n=Qs((r=e.dataSource)==null?void 0:r.semanticDomainId);return BK(e,n,t),Array.from(t.values())}function rSe(e,t){var s;const n=Qs((s=e==null?void 0:e.dataSource)==null?void 0:s.semanticDomainId);if(n)return n;const r=Array.from(new Set(t.map(o=>o.domainId))).filter(Boolean);return r.length===1?r[0]:""}function HK(e,t,n=[]){if(!e)return null;const r=Qs(e.domainId)||t,s=Qs(e.name),o=Qs(e.alias),i=Qs(e.id),a=n.find(f=>f.domainId===r&&f.datasetName===s),c=n.find(f=>f.domainId===r&&f.datasetName===o);let u;a||c?u=[(a||c).datasetName]:o&&(e.type==="table"||i===o)?u=[o,s]:u=[s,o];const d=Xf(u)[0]||"";return!r||!d?null:{domainId:r,datasetName:d,candidateDatasetNames:Xf(u)}}function UK(e){const t=new Map;for(const n of e||[])nSe(n,t);return Array.from(t.values())}function sSe(e){return UK(e?[e]:[])}function ay(e){return UK(e==null?void 0:e.cards)}function oSe(e,t){var s,o;if(!e)return null;const n=VK(e);if(n.length===1)return n[0];const r=rSe(e,n);return HK((o=(s=t||e.config)==null?void 0:s.joinPlan)==null?void 0:o.baseEntity,r,n)||null}function iSe(e,t){var n;if(!e||!t)return null;for(const r of e.sheets||[]){const s=(n=r.frames)==null?void 0:n.find(o=>o.id===t);if(s)return s}return null}function s4(e){return`${e.domainId}:${e.datasetName}:${Th(e).join("|")}`}function aSe(e,t){if(e.length!==t.length)return!1;const n=new Set(t.map(s4));return e.every(r=>n.has(s4(r)))}function lSe(e,t){return aSe(ay(e),ay(t))}function cSe(e){const t=e.sourceField||e.name,n=e.entityId||e.entityName||"",r=e.qualifiedEntityName,s=e.qualifiedFieldName||((r||e.entityId)&&e.name?`${r||e.entityId}.${e.name}`:"");return!n||!t||!e.name||!s||!e.entityId||!e.entityName||!e.entityType||!e.dataType?null:{sourceDataset:n,sourceField:t,name:e.name,qualifiedFieldName:s,qualifiedEntityName:r,entityId:e.entityId,entityName:e.entityName,entityType:e.entityType,dataType:e.dataType,dateFormat:e.dateFormat,customFormat:e.customFormat}}function uSe(e){var t;return((t=e==null?void 0:e.groupByColumns)==null?void 0:t.find(n=>p.getDataType(n.dataType||"")==="date"))||null}function dSe(e){var t,n;return(n=(t=e.dataSource)==null?void 0:t.semanticDomainId)!=null&&n.trim()?!0:sSe(e).length>0}function H0(e){var r;const t=M2(e);if(t.kind==="none")return null;if(t.kind==="explicit_temporal")return cSe(t.field);const n=e.semanticExecutionPayload.domainsById[t.datasetReference.domainId];if(!n)return null;for(const s of Th(t.datasetReference)){const o=(r=n.datasetsByName[s])==null?void 0:r.primaryDateField;if(o!==void 0)return o}return null}function M2(e){var o;const{card:t,cardConfig:n=t.config}=e;if((o=t.sql)!=null&&o.trim())return{kind:"none"};if(!dSe(t))return{kind:"none"};const r=uSe(n);if(r)return{kind:"explicit_temporal",field:r};const s=oSe(t,n);return s?{kind:"semantic_fallback",datasetReference:s}:{kind:"none"}}const KP="Global Date",fSe="__global_date__",hSe="__global_date__";function U0(e){return(e==null?void 0:e.kind)==="global-date"}function Xp(e){return e==null?void 0:e.find(t=>U0(t))}function mSe(){return typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?`global-date-filter:${globalThis.crypto.randomUUID()}`:`global-date-filter:${Date.now().toString(36)}:${Math.random().toString(36).slice(2)}`}function pSe(){return{kind:"global-date",id:mSe(),title:KP,column:fSe,dataType:"date",connectionId:hSe,sql:"",operation:"between",showLabel:!0,displayMode:"inherit",toolbarWidth:220}}function gSe(e,t){const n=e?p.getDashboardCards(e):[],r=n.filter(s=>H0({card:s,cardConfig:s.config,semanticExecutionPayload:t})!==null).map(s=>s.id);return{eligibleCardIds:r,eligibleCardCount:r.length,totalCardCount:n.length,ineligibleCardCount:Math.max(0,n.length-r.length),hasEligibleCards:r.length>0}}const bSe=new Set(["between","not between","=","!=",">",">=","<","<=","is null","is not null"]);function qK(e){return bSe.has(e)}function ZP(e){const{globalDateFilter:t,globalDateFilterValue:n,resolvedPrimaryDateField:r,semanticContext:s}=e;if(!t||!n||!r||!qK(n.operation))return null;const o=n;return{filterId:t.id,name:r.qualifiedFieldName||r.name,operation:o.operation,valueType:"date",values:o.operation==="is null"||o.operation==="is not null"?[]:o.values,dataType:r.dataType||"date",fieldMeta:{name:r.name,qualifiedFieldName:r.qualifiedFieldName,qualifiedEntityName:r.qualifiedEntityName,entityId:r.entityId,entityName:r.entityName,entityType:r.entityType,dataType:r.dataType,role:"groupby"},...s?{semanticContext:s}:{},...o.relativeMeta?{relativeMeta:o.relativeMeta}:{}}}function au(e){return typeof e=="string"?e.trim():""}function xSe(e){var t;return(((t=e.semanticContext)==null?void 0:t.selectedEntities)||[]).filter(n=>typeof n=="object"&&n!==null).filter(n=>n.type==="dataset").map(n=>{var r;return{domainId:au(n.domainId)||au((r=e.semanticContext)==null?void 0:r.semanticDomainId),datasetName:au(n.name),selectedEntityId:au(n.id)}}).filter(n=>n.domainId&&n.datasetName)}function ySe(e){var c,u,d,f,h;if(U0(e)||(c=e.sql)!=null&&c.trim())return null;const t=xSe(e),n=au((u=e.semanticContext)==null?void 0:u.semanticDomainId),r=au((d=e.fieldMeta)==null?void 0:d.entityId),s=au((f=e.fieldMeta)==null?void 0:f.entityName),o=au((h=e.fieldMeta)==null?void 0:h.entityType)==="dataset",i=t.find(m=>r&&m.selectedEntityId===r);if(i)return i;const a=t.find(m=>s&&m.datasetName===s&&(!n||m.domainId===n));return a||(t.length===1?t[0]:o&&s&&n?{domainId:n,datasetName:s}:null)}function vSe(e){var s,o;const{filter:t,semanticExecutionPayload:n}=e;if(!n)return null;const r=ySe(t);return r&&((o=(s=n.domainsById[r.domainId])==null?void 0:s.datasetsByName[r.datasetName])==null?void 0:o.primaryDateField)||null}function WK(e){const t=Xp(e.filters);return t?e.filterValues.filter(n=>n.filterId!==t.id):e.filterValues}function GK(e){const t=Xp(e.filters),n=WK({filters:e.filters,filterValues:e.filterValues});if(!t||U0(e.filter))return n;const r=e.filterValues.find(i=>i.filterId===t.id),s=vSe({filter:e.filter,semanticExecutionPayload:e.semanticExecutionPayload}),o=ZP({globalDateFilter:t,globalDateFilterValue:r,resolvedPrimaryDateField:s||void 0,semanticContext:e.filter.semanticContext});return o?[o,...n]:n}function Ek(e){const t=Xp(e.filters),n=t?e.cardFilterValues.find(i=>i.filterId===t.id):void 0,r=t?e.cardFilterValues.filter(i=>i.filterId!==t.id):e.cardFilterValues,s=e.resolvedPrimaryDateField??(e.semanticExecutionPayload?H0({card:e.card,cardConfig:e.cardConfig,semanticExecutionPayload:e.semanticExecutionPayload}):null),o=ZP({globalDateFilter:t,globalDateFilterValue:n,resolvedPrimaryDateField:s||void 0});return{cardFilterValues:o?[o,...r]:r,resolvedPrimaryDateField:s}}function YK(e){const t=Xp(e.filters),n=t?e.filterValues.find(s=>s.filterId===t.id):void 0,r=WK(e);return!t||!n||!qK(n.operation)?r:[{...n,filterId:t.id,name:t.title||t.column},...r]}function XP(e,t){const n=K1e(e),{cardFilterValues:r,resolvedPrimaryDateField:s}=Ek({card:e,cardConfig:t.queryRelevantConfig,filters:t.filters,cardFilterValues:t.cardFilterValues,resolvedPrimaryDateField:t.resolvedPrimaryDateField});return{queryKey:eSe(e,{finalFiltersKey:t.finalFiltersKey,selectedLensId:t.selectedLensId,cardFilterValues:r,controlValues:t.controlValues,controlDefinitions:t.controlDefinitions,cardControlDefinitions:t.cardControlDefinitions,controlBindings:t.controlBindings,queryRelevantConfig:t.queryRelevantConfig,resolvedPrimaryDateField:s||void 0}),tableConfig:n,requestPayloadBase:{cardId:e.id,sql:(e==null?void 0:e.sql)||"",python:FK(e.python||""),active_filters:r,controlValues:t.controlValues,controlDefinitions:t.controlDefinitions,cardControlDefinitions:t.cardControlDefinitions,controlBindings:t.controlBindings,cache_config:p.getCacheConfig({card:e}),queryConfig:e.queryConfig,tableConfig:n,cardType:e.type,cardTitle:e.title||"",cardConfig:t.queryRelevantConfig,cardDataSource:e.dataSource,resolvedPrimaryDateField:s||void 0,...e.type==="matrixTable"&&{matrixResponseMode:"grid"}}}}function QP(e){return{queryKey:["datasets",e.semanticDomainId],queryFn:()=>p.getRequest(`${e.apiServiceUrl}/v1/datasets`,e.authToken,{domainId:e.semanticDomainId})}}function wSe(e,t){const{tokenProps:n}=ht(),r=p.useDashboardStore(u=>u.authToken)||t,{refetch:s,isPending:o,data:i,isLoading:a,isError:c}=Dn({...e&&(r!=null&&r.accessToken)?QP({apiServiceUrl:n.apiServiceUrl,authToken:r.accessToken,semanticDomainId:e}):{queryKey:["datasets",e],queryFn:async()=>({datasets:[]})},enabled:!!(r!=null&&r.accessToken)&&!!e});return{isPending:o,error:c,datasets:(i==null?void 0:i.datasets)||[],isDatasetsLoading:a,isDatasetsError:c,refetchDatasets:s}}function SSe(e){return{domainsById:Object.fromEntries(Object.entries(e.domainsById||{}).map(([t,n])=>[t,{datasetsByName:{...n.datasetsByName}}]))}}function CSe(e){return{datasetsByName:Object.fromEntries((e||[]).flatMap(t=>LK(e,t).map(n=>[n,{primaryDateField:t.primaryDateField??null}])))}}function NSe(e){return Object.fromEntries(e.map(t=>[t.id,{status:"ready",errorMessage:null}]))}function o4(e,t){return`${e}:${t.join("|")}`}function i4(e,t){return(t==null?void 0:t[e.id])??e.config}function Tk(e,t={}){const n=p.useDashboardStore(f=>f.semanticExecutionPayload),r=p.useDashboardStore(f=>f.authToken),{tokenProps:s,authToken:o}=ht(),i=t.authority||"runtime",a=t.queryRelevantConfigsByCardId,c=r||o,u=S.useMemo(()=>{if(i!=="editor")return[];const f=new Set;for(const h of e){const m=M2({card:h,cardConfig:i4(h,a)});m.kind==="semantic_fallback"&&f.add(m.datasetReference.domainId)}return Array.from(f.values()).sort()},[i,e,a]),d=Wp({queries:u.map(f=>({...c!=null&&c.accessToken?QP({apiServiceUrl:s.apiServiceUrl,authToken:c.accessToken,semanticDomainId:f}):{queryKey:["datasets",f],queryFn:async()=>({datasets:[]})},enabled:i==="editor"&&!!(c!=null&&c.accessToken)&&!!s.apiServiceUrl&&!!f}))});return S.useMemo(()=>{var g;if(i!=="editor"||u.length===0)return{payload:n,cardStatesById:NSe(e)};const f=SSe(n),h=new Map(u.map((b,x)=>[b,d[x]])),m={};u.forEach((b,x)=>{var w,v;const y=(v=(w=d[x])==null?void 0:w.data)==null?void 0:v.datasets;y&&(f.domainsById[b]=CSe(y))});for(const b of e){const x=M2({card:b,cardConfig:i4(b,a)});if(x.kind!=="semantic_fallback"){m[b.id]={status:"ready",errorMessage:null};continue}if(!(c!=null&&c.accessToken)||!s.apiServiceUrl){m[b.id]={status:"loading",errorMessage:null};continue}let y={status:"ready",errorMessage:null};const{domainId:w}=x.datasetReference,v=Th(x.datasetReference),C=h.get(w);if(!C||C.isPending||C.isLoading)y={status:"loading",errorMessage:null};else if(C.isError){const N=C.error instanceof Error&&C.error.message?C.error.message:"Unknown error";y={status:"error",errorMessage:`Failed to load semantic dataset metadata for ${w} (${N})`}}else{const N=YP((g=C.data)==null?void 0:g.datasets,x.datasetReference);N?N.primaryDateFieldError&&(y={status:"error",errorMessage:`Failed to resolve primary date metadata for ${o4(w,v)} (${N.primaryDateFieldError.message})`}):y={status:"error",errorMessage:`Failed to resolve semantic dataset metadata for ${o4(w,v)}`}}m[b.id]=y}return{payload:f,cardStatesById:m}},[c==null?void 0:c.accessToken,e,i,d,a,n,u,s.apiServiceUrl])}function Dh(e){return e==="print"||e==="table-print"}function Dk(e){return e==="table-print"}function kSe(e){return e==="document"}function KK({displayMode:e,renderMode:t}){return kSe(t)&&Dh(e)}const CI=1e4,_Se=500,JP=250;function yp(e){return e.type==="table"||e.type==="detailTable"}function ZK(e){var t,n,r;return!!((t=e.sql)!=null&&t.trim()&&yp(e)&&((r=(n=e.preferences)==null?void 0:n.tablePrefs)!=null&&r.enableDevModePagination))}function mw(e){return e==="export-full-with-cap"?_Se:JP}function jSe({card:e,isTablePrintMode:t,isPrintDisplayMode:n,isDocumentSectionRuntime:r,documentTableDataPolicy:s}){var u,d;const o=r&&s!==void 0&&yp(e),i=t&&!o||e.type==="pivotTable"&&n,a=p.hasValidCardConfig(e.config)&&yp(e)&&!e.sql,c=o?ZK(e):!!(e.sql&&((d=(u=e.preferences)==null?void 0:u.tablePrefs)!=null&&d.enableDevModePagination));return!i&&(a||c)}const ISe={version:1},ESe={version:1,rules:[]};function Li(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function eF(e){return e.enabled!==!1}function TSe(e){return e.kind==="topBottom"||e.kind==="colorScale"&&e.range==="auto"||e.kind==="dataBar"&&e.range==="auto"}function DSe(e){return e.columnId}function dc(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function MSe(e){return e==null||e===""}function eS(e,t,n){return!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?0:n===t?e>=n?1:0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function ASe(e){switch(e){case"bold":return 700;case"semibold":return 600;case"medium":return 500;case"normal":return 400;default:return}}function A2(e){return e?XK({fontWeight:ASe(e.fontWeight),fontStyle:e.italic?"italic":void 0,color:e.textColor,backgroundColor:e.backgroundColor,textDecoration:e.textDecoration}):{}}function Mk(...e){return Object.assign({},...e.filter(t=>!!t).map(XK))}function XK(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const QK=["body","header","footer","subtotal","grandTotal"],RSe=["eq","neq","gt","gte","lt","lte"];function Ds(e){return typeof e=="string"&&e.trim()?e:void 0}function NI(e){return e!=null&&String(e).trim()!==""}function R2(e){return typeof e=="boolean"?e:void 0}function $d(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function pw(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):void 0}function Wb(e){if(!Li(e))return;const t=Ds(e.fontWeight),n=Ds(e.textDecoration),r={fontWeight:t==="normal"||t==="medium"||t==="semibold"||t==="bold"?t:void 0,italic:R2(e.italic),textColor:Ds(e.textColor),backgroundColor:Ds(e.backgroundColor),textDecoration:n==="none"||n==="underline"||n==="line-through"?n:void 0};return Object.values(r).some(s=>s!==void 0)?r:void 0}function vx(e){if(!Li(e))return ISe;const t={};if(Li(e.tableParts))for(const r of QK){const s=Wb(e.tableParts[r]);s&&(t[r]=s)}const n={};if(Li(e.columns))for(const[r,s]of Object.entries(e.columns)){if(!Li(s))continue;const o=Wb(s.body),i=Wb(s.header),a=Wb(s.footer);(o||i||a)&&(n[r]={body:o,header:i,footer:a})}return{version:1,...Object.keys(t).length?{tableParts:t}:{},...Object.keys(n).length?{columns:n}:{}}}function PSe(e){var n;return Li(e)?{level:e.level==="row"?"row":"cell",columnIds:pw(e.columnIds),conditionColumnId:Ds(e.conditionColumnId),applyToColumnIds:pw(e.applyToColumnIds),tableParts:(n=pw(e.tableParts))==null?void 0:n.filter(r=>QK.includes(r)),rowRoles:pw(e.rowRoles),depth:$d(e.depth),includeTotals:R2(e.includeTotals),includeSubtotals:R2(e.includeSubtotals)}:void 0}function FSe(e){if(!Li(e))return;const t=Wb(e),n=Ds(e.icon),r=Li(e.dataBar)?{color:Ds(e.dataBar.color)||"#3b82f6",showValue:e.dataBar.showValue!==!1}:void 0;return{...t,icon:n==="arrowUp"||n==="arrowDown"||n==="warning"||n==="check"||n==="x"?n:void 0,dataBar:r}}function OSe(e,t={}){if(!Li(e)||typeof e.kind!="string")return;const n=Ds(e.columnId);if(n)switch(e.kind){case"comparison":{const r=Ds(e.operator);return!RSe.includes(r)||!NI(e.value)&&!t.allowIncompleteDraft?void 0:{kind:"comparison",columnId:n,operator:r,value:e.value}}case"between":return(!NI(e.min)||!NI(e.max))&&!t.allowIncompleteDraft?void 0:{kind:"between",columnId:n,min:e.min,max:e.max,inclusive:e.inclusive!==!1};case"blank":return{kind:"blank",columnId:n,isBlank:e.isBlank!==!1};case"contains":return!Ds(e.value)&&!t.allowIncompleteDraft?void 0:{kind:"contains",columnId:n,value:Ds(e.value)??"",caseSensitive:e.caseSensitive===!0,exact:e.exact===!0};case"topBottom":{const r=$d(e.count);return{kind:"topBottom",columnId:n,direction:e.direction==="bottom"?"bottom":"top",count:r&&r>0?Math.floor(r):1}}case"colorScale":return{kind:"colorScale",columnId:n,range:e.range==="manual"?"manual":"auto",min:$d(e.min),mid:$d(e.mid),max:$d(e.max),colors:Li(e.colors)?{min:Ds(e.colors.min)||"#fee2e2",mid:Ds(e.colors.mid),max:Ds(e.colors.max)||"#dcfce7"}:{min:"#fee2e2",max:"#dcfce7"}};case"dataBar":return{kind:"dataBar",columnId:n,range:e.range==="manual"?"manual":"auto",min:$d(e.min),max:$d(e.max),color:Ds(e.color)||"#3b82f6",showValue:e.showValue!==!1};default:return}}function LSe(e){if(!Li(e))return;const t=Ds(e.id),n=PSe(e.target),r=e.enabled!==!1,s=OSe(e.condition,{allowIncompleteDraft:!r});if(!(!t||!n||!s))return{id:t,name:Ds(e.name),enabled:r,target:n,condition:s,style:FSe(e.style)}}function tF(e){return Li(e)?{version:1,rules:Array.isArray(e.rules)?e.rules.map(LSe).filter(n=>!!n):[]}:ESe}function JK(e){return!!(e&&e!=="default"&&e!=="nowrap")}function $Se({textWrap:e,appearanceWrapText:t}){const n=JK(e);return{appearanceWrapText:n?void 0:t,hasColumnTextWrapOverride:n}}function zSe(e){if(e==="wrap"||e==="preserve")return e;if(e==="truncate")return"nowrap"}function nF({tableWrapText:e,textWrap:t,appearanceWrapText:n,hasColumnTextWrapOverride:r=!1}){const s=zSe(t);return r&&s?s:typeof e=="boolean"?e?"wrap":"nowrap":typeof n=="boolean"?n?"wrap":"nowrap":s??"nowrap"}function BSe({tableWrapText:e,textWrap:t,appearanceWrapText:n,hasColumnTextWrapOverride:r}){return nF({tableWrapText:e,textWrap:t,appearanceWrapText:n,hasColumnTextWrapOverride:r})!=="nowrap"}function VSe(e){return e==="preserve"?"whitespace-pre-wrap break-words":e==="wrap"?"whitespace-normal break-words":"truncate"}function HSe(e){return e?"whitespace-normal break-normal":"truncate"}function USe(e,t){if(e==="preserve")return{whiteSpace:"pre-wrap",tabSize:4,overflow:"visible",textOverflow:void 0};const n=e==="wrap";return{whiteSpace:n?"normal":"nowrap",overflow:t==="clip"||n?"visible":"hidden",textOverflow:t==="ellipsis"&&!n?"ellipsis":void 0}}function qSe(e){var n,r;const t=e==null?void 0:e.columnSettings;return t?{textAlign:t.textAlign,...USe(nF({tableWrapText:(r=(n=e==null?void 0:e.tablePreferences)==null?void 0:n.tableStyle)==null?void 0:r.wrapText,textWrap:t.textWrap,appearanceWrapText:e==null?void 0:e.appearanceWrapText,hasColumnTextWrapOverride:e==null?void 0:e.hasColumnTextWrapOverride}),t.textOverflow)}:{}}function WSe(e){return e==="header"?"header":e==="footer"||e==="grandTotal"?"footer":"body"}function eZ(e){var i,a,c;const{formatting:t,compatibility:n,columnId:r,tablePart:s}=e,o=(a=(i=t.columns)==null?void 0:i[r])==null?void 0:a[WSe(s)];return Mk(qSe(n),A2((c=t.tableParts)==null?void 0:c[s]),A2(o))}function GSe(e){var r;const t=e.rule.condition;if(t.kind!=="colorScale"&&t.kind!=="dataBar"||t.range!=="auto")return;const n=(r=e.metadataRanges)==null?void 0:r[t.columnId];if(!((n==null?void 0:n.min)==null||(n==null?void 0:n.max)==null))return{ruleId:e.rule.id,status:"ready",source:"serverMetadata",range:{min:n.min,max:n.max,mid:n.mid??void 0}}}function YSe(e){return e.renderContext.kind==="interactiveDashboard"?{ruleId:e.rule.id,status:"ready",source:"loadedRows",rows:e.rows}:e.fullRows||e.renderContext.rowSource==="fullRows"?{ruleId:e.rule.id,status:"ready",source:"fullRows",rows:e.fullRows??e.rows}:{ruleId:e.rule.id,status:"unavailableForPrint",source:"none",reason:"missingFullRowsAndMetadata"}}function tZ(e){const t={};for(const n of e.rules)if(eF(n)){if(!TSe(n.condition)){t[n.id]={ruleId:n.id,status:"notNeeded",source:"none"};continue}t[n.id]=GSe({rule:n,metadataRanges:e.metadataRanges})??YSe({rule:n,rows:e.rows,fullRows:e.fullRows,renderContext:e.renderContext})}return{byRuleId:t}}function KSe(){return{numericRanges:{},topBottom:{},unavailableRuleIds:new Set}}function a4(e,t){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const s of e){const o=dc(s[t]);o!==null&&(n=Math.min(n,o),r=Math.max(r,o))}if(!(!Number.isFinite(n)||!Number.isFinite(r)))return{min:n,max:r}}function ZSe(e,t,n,r){const s=e.map(o=>({raw:o[t],numeric:dc(o[t])})).filter(o=>o.numeric!==null&&Number.isFinite(o.numeric)).sort((o,i)=>n==="top"?i.numeric-o.numeric:o.numeric-i.numeric).slice(0,r);return new Set(s.map(o=>o.raw))}function XSe(e){return(e==null?void 0:e.status)==="ready"&&(e.source==="fullRows"||e.source==="loadedRows")?e.rows:void 0}function kI(e,t,n){(n==null?void 0:n.status)==="unavailableForPrint"&&e.unavailableRuleIds.add(t)}function QSe(e){const t=e.rangePlan??tZ({rules:e.rules,rows:e.rows,fullRows:e.fullRows,metadataRanges:e.metadataRanges,renderContext:e.renderContext}),n=KSe();for(const r of e.rules){if(!eF(r))continue;const s=r.condition,o=DSe(s),i=t.byRuleId[r.id],a=XSe(i);if(s.kind==="colorScale"){if(s.range==="manual"){const u=s.min,d=s.max;typeof u=="number"&&typeof d=="number"&&(n.numericRanges[r.id]={min:u,max:d,mid:s.mid});continue}if((i==null?void 0:i.status)==="ready"&&i.source==="serverMetadata"){n.numericRanges[r.id]=i.range;continue}const c=a?a4(a,o):void 0;c?n.numericRanges[r.id]=c:kI(n,r.id,i);continue}if(s.kind==="dataBar"){if(s.range==="manual"){typeof s.min=="number"&&typeof s.max=="number"&&(n.numericRanges[r.id]={min:s.min,max:s.max});continue}if((i==null?void 0:i.status)==="ready"&&i.source==="serverMetadata"){n.numericRanges[r.id]=i.range;continue}const c=a?a4(a,o):void 0;c?n.numericRanges[r.id]=c:kI(n,r.id,i);continue}s.kind==="topBottom"&&(a?n.topBottom[r.id]=ZSe(a,o,s.direction,s.count):kI(n,r.id,i))}return n}function JSe(e,t,n){const r=dc(e),s=dc(n),o=r??String(e??""),i=s??String(n??"");switch(t){case"eq":return o===i;case"neq":return o!==i;case"gt":return o>i;case"gte":return o>=i;case"lt":return o<i;case"lte":return o<=i}}function eCe(e,t,n,r){var o;const s=t[e.columnId];switch(e.kind){case"comparison":return JSe(s,e.operator,e.value);case"between":{const i=dc(s),a=dc(e.min),c=dc(e.max);return i===null||a===null||c===null?!1:e.inclusive===!1?i>a&&i<c:i>=a&&i<=c}case"blank":return MSe(s)===e.isBlank;case"contains":{const i=String(s??""),a=e.value,c=e.caseSensitive?i:i.toLocaleLowerCase(),u=e.caseSensitive?a:a.toLocaleLowerCase();return e.exact?c===u:c.includes(u)}case"topBottom":return((o=n.topBottom[r])==null?void 0:o.has(s))??!1;case"colorScale":case"dataBar":return!n.unavailableRuleIds.has(r)}}function tCe(e,t){var n;return!((n=e.target.tableParts)!=null&&n.length)||e.target.tableParts.includes(t)}function nCe(e,t){var n,r;return e.target.level==="row"?!((n=e.target.applyToColumnIds)!=null&&n.length)||e.target.applyToColumnIds.includes(t):!((r=e.target.columnIds)!=null&&r.length)||e.target.columnIds.includes(t)}function rCe(e,t){if(e.condition.kind!=="colorScale")return;const n=e.condition,r=dc(t[n.columnId]);if(r!==null)return r}function sCe(e,t,n){return e.condition.kind!=="dataBar"?0:e.condition.range!=="auto"?eS(t,n.min,n.max):n.min>0&&n.max>0?eS(t,0,n.max):eS(t,n.min,n.max)}function oCe(e,t,n){var r,s;if(e.condition.kind==="colorScale"){const o=rCe(e,t),i=n.numericRanges[e.id];if(o===void 0||!i)return{};const a=eS(o,i.min,i.max),c=i.mid;return{cellStyle:{backgroundColor:c!==void 0&&e.condition.colors.mid?o<c?e.condition.colors.min:o===c?e.condition.colors.mid:e.condition.colors.max:a<.5?e.condition.colors.min:e.condition.colors.max}}}if(e.condition.kind==="dataBar"){const o=dc(t[e.condition.columnId]),i=n.numericRanges[e.id];return o===null||!i?{}:{overlay:{kind:"dataBar",color:e.condition.color,ratio:sCe(e,o,i),showValue:e.condition.showValue!==!1}}}return{cellStyle:Mk(A2(e.style),(r=e.style)!=null&&r.textColor?{color:e.style.textColor}:void 0),overlay:(s=e.style)!=null&&s.icon?{kind:"icon",icon:e.style.icon}:void 0}}function l4(e){const t={matchedRuleIds:[]};for(const n of e.formatting.rules){if(!eF(n)||!tCe(n,e.tablePart)||!nCe(n,e.columnId)||!eCe(n.condition,e.row,e.range,n.id))continue;const r=oCe(n,e.row,e.range),s=n.target.level==="row"?"rowStyle":"cellStyle";t[s]=Mk(t[s],r.cellStyle),r.overlay&&(t.overlay=r.overlay),t.matchedRuleIds.push(n.id)}return t}function iCe(e){return Mk(e.base,e.conditional.rowStyle,e.conditional.cellStyle)}function aCe(e){const t=vx(e.tablePreferences.baseFormatting),n=tF(e.tablePreferences.conditionalFormatting),r=e.tablePreferences.columnSettingsMap||{},o=e.tableKind==="table"?n:{...n,rules:[]},i=tZ({rules:o.rules,rows:e.rows,fullRows:e.fullRows,metadataRanges:e.metadataRanges,renderContext:e.renderContext});return{tableKind:e.tableKind,renderContext:e.renderContext,renderedColumnIds:e.renderedColumnIds,columns:e.columns,rows:e.rows,fullRows:e.fullRows,baseFormatting:t,conditionalFormatting:o,columnSettingsByColumnId:r,rangePlan:i,range:QSe({rules:o.rules,rows:e.rows,fullRows:e.fullRows,metadataRanges:e.metadataRanges,renderContext:e.renderContext,rangePlan:i})}}function lCe(e){if(!e.name)return;const t=e.entityName&&e.entityName!=="SEMAPHOR_CALCULATED_FIELD"?e.entityName:void 0;if(e.role==="metric"){let n="aggregate"in e&&typeof e.aggregate=="string"?e.aggregate:"metric";if("expression"in e&&typeof e.expression=="string"){const r=e.expression.match(/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i);n=r?r[1].toLowerCase():"expr"}else n=n.toLowerCase();return t&&t!==e.name?`${t}_${e.name}_${n}`:`${e.name}_${n}`}return t&&t!==e.name?`${t}_${e.name}`:e.name}function rF(e){return Array.from(new Set([e.id,e.alias,e.label,e.name,e.qualifiedFieldName,lCe(e)].map(t=>typeof t=="string"?t.trim():"").filter(Boolean)))}function sF(e){var s,o,i;const t=((s=e.config)==null?void 0:s.detailColumns)||[],n=((o=e.config)==null?void 0:o.groupByColumns)||[],r=((i=e.config)==null?void 0:i.metricColumns)||[];return[...t.map(a=>({...a,role:"detail"})),...n.map(a=>({...a,role:"groupby"})),...r.map(a=>({...a,role:"metric"}))].filter(a=>!!a.id)}function cCe(e,t){return t?!rF(e).some(n=>t[n]===!1):!0}function c4(e,t){for(const n of rF(e))if(t!=null&&t[n])return n;return e.label||e.name||e.alias||e.id}function Qp(e){var t;return e.type==="table"&&!((t=e.sql)!=null&&t.trim())&&!!e.config}function q0(e){var t,n,r,s;return((s=(r=(n=(t=e.preferences)==null?void 0:t.tablePrefs)==null?void 0:n.tableStyle)==null?void 0:r.totals)==null?void 0:s.enabled)===!0}function uCe(e){return Qp(e)?q0(e):!1}function dCe(e){var t,n,r,s,o,i;return Qp(e)?{...e,preferences:{...e.preferences,tablePrefs:{...(t=e.preferences)==null?void 0:t.tablePrefs,tableStyle:{...(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.tableStyle,totals:{...(i=(o=(s=e.preferences)==null?void 0:s.tablePrefs)==null?void 0:o.tableStyle)==null?void 0:i.totals,enabled:!0}}}}}:e}function nZ(e){if(!Qp(e)||!q0(e))return;const t=sF(e),n=[];let r=!1;for(const s of t){if(s.role!=="metric"&&!r){n.push({fieldId:s.id,role:s.role,behavior:"label",label:"Total"}),r=!0;continue}s.role==="metric"&&n.push({fieldId:s.id,role:s.role,behavior:"sum"})}return n.length?{source:"documentFlatTable",columns:n}:void 0}function fCe(e){var t,n,r,s,o,i;return{...e,preferences:{...e.preferences,tablePrefs:{...(t=e.preferences)==null?void 0:t.tablePrefs,tableStyle:{...(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.tableStyle,totals:{...(i=(o=(s=e.preferences)==null?void 0:s.tablePrefs)==null?void 0:o.tableStyle)==null?void 0:i.totals,enabled:!1}}}}}}const _I=[],jI=[],II={},u4=[];function rZ(e){return p.getRequestErrorSql(e)??(e&&typeof e=="object"&&"errorSql"in e&&typeof e.errorSql=="string"?e.errorSql:"")??""}function hCe(e){const t=p.getRequestErrorMessage(e,""),n=rZ(e);if(t)return{error:t,sql:n}}function d4(e){return{error:p.getRequestErrorMessage(e,"Unknown error",{preserveSyntheticMessage:!0}),sql:rZ(e)}}function mCe(e){if(!e)return"";let t=5381;for(let n=0;n<e.length;n+=1)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)}function pCe(e,t,n){var r;return t&&n||e.sql?e.connectionId:((r=e.dataSource)==null?void 0:r.connectionId)||e.connectionId}function tS(e,t){return p.hasValidCardConfig(e.config)?!((t==null?void 0:t.some(r=>r.sourceCardId===e.id))&&!(t==null?void 0:t.some(s=>s.sourceCardId===e.id&&s.filterSourceCard))):!1}function gCe({data:e,cardId:t,enabled:n,card:r,appliedClickFilters:s,lastDataMap:o}){var d;const i=t?o.get(t):void 0;if(e!==void 0)return t&&o.set(t,e),e;const a=!!((d=r==null?void 0:r.sql)!=null&&d.trim()),c=r?tS(r,s):!1;return(n||a||c)&&i!==void 0?i:(t&&o.delete(t),e)}function bCe(e,t={}){const{authToken:n,tokenProps:r}=ht(),s=p.useDashboardStore(P=>P.filteringCards),o=p.useDashboardStore(P=>P.isVisualEditing),i=p.useDashboardStore(P=>P.actions.getCardFrame),a=p.useDashboardStore(P=>P.authToken),{displayPreferences:c}=Cl(),u=p.useEditorStore(P=>P.isDevMode),d=p.useInteractionStore(P=>P.interactionStates),f=p.useDashboardStore(P=>P.dashboard.filters),h=p.useDashboardStore(P=>P.dashboard),m=p.useDashboardStore(P=>P.dashboard.controls),g=p.useDashboardStore(P=>P.filterValues),b=p.useDashboardStore(P=>P.controlValues),x=p.useDashboardStore(P=>P.selectedSheetId),y=p.useDashboardStore(P=>P.selectedLensId),w=p.useDashboardStore(P=>{var H;return(H=P.dashboard)==null?void 0:H.id}),v=p.useDashboardStore(P=>P.inlineFilterValuesMap),C=p.useDashboardStore(P=>P.cardControlValuesMap),N=p.useDashboardStore(P=>P.dashboardInputValues),k=p.useDashboardStore(P=>P.dashboardInputValuesAreAuthoritative),_=p.useEditorStore(P=>P.inlineFilterValuesMap),j=p.useEditorStore(P=>P.editorContext),E=(j==null?void 0:j.type)==="documentSection",I=t.runtimeContext==="documentSection",T=E&&j.documentFilterValues||_I,D=E&&j.documentControlValues||II,R=E&&j.documentControlDefinitions||jI,F=E&&j.missingRequiredInputLabels||u4,A=E?j.cardId:void 0,U=t.documentFilterValues||_I,$=t.documentControlValues||II,q=t.documentControlDefinitions||jI,W=t.documentDashboardInputValues,O=S.useMemo(()=>new Map,[]),Z=S.useMemo(()=>new Map,[]),Y=S.useMemo(()=>mCe((n==null?void 0:n.accessToken)||(a==null?void 0:a.accessToken)),[n==null?void 0:n.accessToken,a==null?void 0:a.accessToken]),M=S.useMemo(()=>B1e({cards:e,dashboard:h,filters:f,dashboardControls:m,filterValues:g,controlValues:b,dashboardInputValues:N,dashboardInputValuesAreAuthoritative:k,dashboardInlineFilterValuesMap:v,editorInlineFilterValuesMap:_,dashboardCardControlValuesMap:C,interactionStates:d,filteringCards:s,selectedSheetId:x,currentDashboardId:w,isVisualEditing:o,getCardFrame:i,lastRequestPayloadMap:Z,documentState:{isExplicitDocumentSectionRuntime:I,isDocumentSectionEditing:E,editedDocumentSectionCardId:A,editorDocumentSheetId:E?j.sheetId:void 0,editorDocumentSectionId:E?j.sectionId:void 0,explicitDocumentSheetId:t.documentSheetId,explicitDocumentSectionId:t.documentSectionId,editorDocumentFilterValues:T,editorDocumentControlDefinitions:R,editorDocumentControlValues:D,editorMissingRequiredInputLabels:F,explicitDocumentFilterValues:U,explicitDocumentControlDefinitions:q,explicitDocumentControlValues:$,explicitDocumentDashboardInputValues:W}}),[e,d,s,i,o,h,f,m,g,b,N,k,C,v,_,A,T,R,D,F,U,q,$,W,I,E,j,t.documentSheetId,t.documentSectionId,x,w,Z]),K=S.useMemo(()=>Object.fromEntries(M.map(({card:P,queryRelevantConfig:H})=>[P.id,H])),[M]),L=Tk(e,{authority:t.semanticPayloadAuthority||"runtime",queryRelevantConfigsByCardId:K}),z=L.payload,B=S.useMemo(()=>M.map(P=>{var dt,vt,st,Dt,Ee,Ze,Qe;const{card:H,cardFilterValues:G,controlValues:X,controlDefinitions:ne,cardControlDefinitions:de,controlBindings:he,resolvedFilters:pe,finalConfig:xe,queryRelevantConfig:se,finalFiltersKey:ge,appliedClickFilters:ie,interval:Te,isFilteringCard:re,isSingleCardFrame:me,isDocumentSectionRuntime:ve,missingRequiredInputLabels:J,dashboardInputMissingRequiredLabels:ee,queryFilterDefinitions:te}=P,ue=ee.length>0?ee:J,le=ve&&ue.length>0,ke=H0({card:H,cardConfig:se,semanticExecutionPayload:z}),Se=XP(H,{finalFiltersKey:ge,selectedLensId:y,cardFilterValues:G,controlValues:X,controlDefinitions:ne,cardControlDefinitions:de,controlBindings:he,queryRelevantConfig:se,filters:te,resolvedPrimaryDateField:ke}),oe=t.tableTotalsRequest??(ve?void 0:nZ(H)),je=oe?["tableTotals",JSON.stringify(oe)]:[],Ne=[...Se.queryKey,"auth",Y,...ve?[]:je],Oe=ve?[...Ne,"documentSection",...t.documentTableDataPolicy?["documentTableDataPolicy",t.documentTableDataPolicy]:[],...je]:Ne,Ge=o?{}:{refetchInterval:Te},Le=Se.tableConfig,Be=H.dataSource,Ke=L.cardStatesById[H.id]||{status:"ready",errorMessage:null},Ce=!!((dt=H==null?void 0:H.sql)!=null&&dt.trim()),Je=tS(H,ie),Pe=ve&&t.documentTableDataPolicy&&((vt=H.sql)==null?void 0:vt.trim())&&yp(H)&&!ZK(H),He=H!=null&&H.connectionId||(st=H==null?void 0:H.dataSource)!=null&&st.connectionId?pCe(H,o,u):void 0,tt=Dk(c.mode),Ae=jSe({card:H,isTablePrintMode:tt,isPrintDisplayMode:Dh(c.mode),isDocumentSectionRuntime:ve,documentTableDataPolicy:t.documentTableDataPolicy}),Ie=!le&&!Pe&&He&&(Ce||Je)?{connection_id:He,...Se.requestPayloadBase,cardDataSource:Be,...oe?{tableTotalsRequest:oe}:{},...Ae?{pagination:{page:((Dt=H.paginationConfig)==null?void 0:Dt.page)||1,pageSize:((Ee=H.paginationConfig)==null?void 0:Ee.pageSize)||((Qe=(Ze=H.preferences)==null?void 0:Ze.tablePrefs)==null?void 0:Qe.pageSize)||50}}:{}}:void 0,We=async()=>{if(le)return Z.delete(H.id),null;if(Ke.status==="error"&&Ke.errorMessage){if(Z.delete(H.id),!o)throw new Error(Ke.errorMessage);return{records:[],error:Ke.errorMessage,errorSql:""}}if(!He||!Ce&&!Je)return Z.delete(H.id),null;if(Pe)return Z.delete(H.id),{records:[],error:"Enable SQL pagination to use this SQL table in a paginated report.",errorSql:""};try{return Ie?(Z.set(H.id,Ie),await p.postRequest(`${r.apiServiceUrl}/v1/query`,(n==null?void 0:n.accessToken)||(a==null?void 0:a.accessToken)||"",Ie)):(Z.delete(H.id),null)}catch(nt){if(!o)throw nt;const yt=d4(nt);return{records:[],error:yt.error,errorSql:yt.sql}}},xt=()=>{var nt,yt;return!(n!=null&&n.accessToken)||le||re&&me?!1:(H!=null&&H.connectionId||(nt=H==null?void 0:H.dataSource)!=null&&nt.connectionId)&&((yt=H==null?void 0:H.sql)!=null&&yt.trim()||tS(H,ie))&&!o?!0:tS(H,ie)&&o&&!u?!(t.semanticPayloadAuthority==="editor"&&Ke.status==="loading"):!1},bt=xt();return bt||Z.delete(H.id),{card:H,queryKey:Oe,queryFn:We,config:Ge,isFilteringCard:re,isSingleCardFrame:me,appliedClickFilters:ie,tableConfig:Le,finalConfig:xe,resolvedFilters:pe,resolvedPrimaryDateField:ke,queryRequestPayload:Ie,isEnabled:xt,enabled:bt,isDocumentSectionQueryBlocked:le}}),[M,o,u,c.mode,y,z,L.cardStatesById,t.semanticPayloadAuthority,t.documentTableDataPolicy,t.tableTotalsRequest,Y,n==null?void 0:n.accessToken,a==null?void 0:a.accessToken,r.apiServiceUrl,Z]),V=Wp({queries:B.map(P=>({queryKey:P.queryKey,queryFn:P.queryFn,placeholderData:Sme,enabled:P.enabled,...P.config,retryOnMount:!1}))});return S.useMemo(()=>V.map((P,H)=>{var J,ee;const G=B[H],X=P.data,ne=G==null?void 0:G.card.id,de=(G==null?void 0:G.enabled)??!0,he=G!=null&&G.isDocumentSectionQueryBlocked?null:gCe({data:X,cardId:ne,enabled:de,card:G==null?void 0:G.card,appliedClickFilters:G==null?void 0:G.appliedClickFilters,lastDataMap:O});G!=null&&G.isDocumentSectionQueryBlocked&&ne&&O.delete(ne);const pe=P.error?d4(P.error):void 0,xe=hCe(he),se=(pe==null?void 0:pe.error)??(xe==null?void 0:xe.error)??(typeof(he==null?void 0:he.error)=="string"?he.error:void 0)??"",ge=(pe==null?void 0:pe.sql)??(xe==null?void 0:xe.sql)??(typeof(he==null?void 0:he.errorSql)=="string"?he.errorSql:void 0)??"",ie=he==null?void 0:he.pagination,Te=(J=he==null?void 0:he.metadata)!=null&&J.autoResolved?{resolvedJoinPlan:he.metadata.resolvedJoinPlan,autoResolved:he.metadata.autoResolved,relationshipsUsed:he.metadata.relationshipsUsed}:void 0,re=(ee=he==null?void 0:he.metadata)!=null&&ee.comparisonMetadata?he.metadata.comparisonMetadata:void 0,me=ne&&G!=null&&G.enabled?G.queryRequestPayload??Z.get(ne):void 0;return{...P,data:he,queryKey:(G==null?void 0:G.queryKey)??[],isFilteringCard:(G==null?void 0:G.isFilteringCard)??!1,isSingleCardFrame:(G==null?void 0:G.isSingleCardFrame)??!1,errorMessage:se,errorSql:ge,pagination:ie,autoJoinMetadata:Te,comparisonMetadata:re,queryRequestPayload:me,resolvedPrimaryDateField:G==null?void 0:G.resolvedPrimaryDateField}}),[V,B,O,Z])}function yc(e,t={}){const n=bCe([e],t);if(n.length===0)throw new Error("useDashboardFrameQuery returned no results for the supplied dashboard card.");return n[0]}function Ak(e){const t=p.useEditorStore(r=>r.editorContext),n=(t==null?void 0:t.type)==="documentSection"&&t.cardId===e.id?t:void 0;return yc(e,n?{semanticPayloadAuthority:"editor",runtimeContext:"documentSection",documentSheetId:n.sheetId,documentSectionId:n.sectionId,documentFilterValues:n.documentFilterValues,documentControlDefinitions:n.documentControlDefinitions,documentControlValues:n.documentControlValues}:{semanticPayloadAuthority:"editor"})}function Mc(e){const{tokenProps:t}=ht(),n=p.useDashboardStore(h=>h.authToken)||e,r=p.useEditorStore(h=>h.selectedConnectionId),s=p.useEditorStore(h=>{var m,g;return(g=(m=h==null?void 0:h.card)==null?void 0:m.dataSource)==null?void 0:g.connectionId}),o=r||s,{refetch:i,isPending:a,data:c,isLoading:u,isError:d}=Dn({queryKey:[t.project_id,"connections"],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/connections`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)}),f=c==null?void 0:c.connections.find(h=>h.id===o);return{isPending:a,error:d,connectionsData:c,connections:(c==null?void 0:c.connections)||[],isConnectionsLoading:u,isConnectionsError:d,refetchConnections:i,selectedConnection:f}}function sZ(e){const{connections:t}=Mc(e),n=p.useEditorStore(o=>o.selectedConnectionId),r=t.find(o=>o.id===n),s=r==null?void 0:r.capabilities.path.includes("schema");return{selectedConnection:r,capabilities:r==null?void 0:r.capabilities,connectionType:r==null?void 0:r.type,hasSchemaSupport:s}}const xCe=["#3b82f6","#10b981","#ef4444","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#84cc16","#06b6d4"];function Mh(){var n,r;const e=p.useDashboardStore.getState().themeStyle,t=(r=(n=e==null?void 0:e.chart)==null?void 0:n.dataset)==null?void 0:r.backgroundColor;return t&&t.length>0?t:xCe}function P2(e,t,n){var s;if((s=n==null?void 0:n.segments)!=null&&s[e])return n.segments[e];const r=Mh();return r[t%r.length]}function yCe(e,t){const n=Mh(),r=n[t%n.length];return e===r}function Jp(e){if(!e||e.length===0)return!1;const t=e[0];return Object.keys(t).some(r=>r.includes("(Previous)")||r.includes("(Last Year)")||r.includes("(Start)")||r.includes("(Target)"))}function vCe(e){return/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/.test(e)}function f4(e,t=1){if(!vCe(e)||t===1)return e;e=e.replace(/^#/,"");const n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),s=parseInt(e.substring(4,6),16);return t=Math.min(Math.max(t,0),1),`rgba(${n}, ${r}, ${s}, ${t})`}function eg(e,t,n,r=1,s="none",o,i=!1,a=!1){var m,g,b,x;const c=n==null?void 0:n.datasetOptions,u=p.useDashboardStore.getState().themeStyle,d=(g=(m=u==null?void 0:u.chart)==null?void 0:m.dataset)==null?void 0:g.backgroundColor,f=(x=(b=u==null?void 0:u.chart)==null?void 0:b.dataset)==null?void 0:x.borderColor;return e.map((y,w)=>{var D,R,F;const v=c==null?void 0:c.find(A=>A.idx===w),C=(R=(D=n==null?void 0:n.colorConfig)==null?void 0:D.segments)==null?void 0:R[y],N=f4(C||(d==null?void 0:d[w%d.length]),r),k=C||(f==null?void 0:f[w%f.length]),_=C||(f==null?void 0:f[w%f.length]),j=t.some(A=>A._forecast),E={borderWidth:2,pointRadius:2,segment:{borderDash:A=>{const U=A.p0DataIndex;return t[U]._forecast?[2,4]:void 0},borderColor:A=>{const U=t[A.p0DataIndex]._forecast,$=p.useDashboardStore.getState().theme==="dark";return U?$?"white":"black":_}},pointBackgroundColor:A=>{const U=p.useDashboardStore.getState().theme==="dark";return t[A.dataIndex]._forecast?U?"white":"gray":k},pointBorderColor:A=>{const U=p.useDashboardStore.getState().theme==="dark";return t[A.dataIndex]._forecast?U?"white":"gray":k}},I={backgroundColor:A=>{var $;return(($=t[A.dataIndex])==null?void 0:$._forecast)?N+"20":N}};return{label:y.charAt(0).toUpperCase()+y.slice(1),data:t.map(A=>A[y]),...v,datalabels:n!=null&&n.dataLabelsConfig?v==null?void 0:v.datalabels:{...v==null?void 0:v.datalabels,color:wCe((F=v==null?void 0:v.datalabels)==null?void 0:F.align,N)},backgroundColor:i?f4(P2(y,w,n==null?void 0:n.colorConfig),r):N,borderColor:i?P2(y,w,n==null?void 0:n.colorConfig):_,...s==="line"&&j?E:s==="line"?{borderWidth:2,pointRadius:1.5}:{},...s==="bar"&&j?I:{},...a&&{stack:y.includes("(Previous)")||y.includes("(Last Year)")||y.includes("(Start)")||y.includes("(Target)")?"comparison":"current"}}})}function wCe(e,t){return e==="top"||e==="bottom"||e==="end"?n=>{var r;return p.getContrastColor(p.getCanvasBackgroundColor((r=n==null?void 0:n.chart)==null?void 0:r.canvas))}:n=>{var r;return p.getContrastColor(t,{baseColor:p.getCanvasBackgroundColor((r=n==null?void 0:n.chart)==null?void 0:r.canvas)})}}function oZ(e,t,n,r){var c,u,d,f;const s=p.useDashboardStore.getState().themeStyle,o=(u=(c=s==null?void 0:s.chart)==null?void 0:c.dataset)==null?void 0:u.backgroundColor,i=(f=(d=s==null?void 0:s.chart)==null?void 0:d.dataset)==null?void 0:f.borderColor;return e.map(h=>({label:h?h.charAt(0).toUpperCase()+h.slice(1):"",data:t.map(m=>m[h]),backgroundColor:t.map((m,g)=>{var b,x;return r&&((x=(b=n==null?void 0:n.colorConfig)==null?void 0:b.segments)!=null&&x[m[r]])?n.colorConfig.segments[m[r]]:(m==null?void 0:m._color)||(o==null?void 0:o[g%o.length])}),borderColor:t.map((m,g)=>{var b,x;return r&&((x=(b=n==null?void 0:n.colorConfig)==null?void 0:b.segments)!=null&&x[m[r]])?n.colorConfig.segments[m[r]]:(m==null?void 0:m._color)||(i==null?void 0:i[g%i.length])})}))}function SCe(e){const t=new Set;return e.forEach(n=>{Object.keys(n).forEach(r=>t.add(r))}),Array.from(t)}function CCe(e){let t=-1,n=0;return e.forEach((r,s)=>{const o=Object.keys(r).length;o>n&&(t=s,n=o)}),t}function ly(e){return e.length===1?[e[0]]:e.slice(1).filter(t=>!p.METADATA_KEYS.includes(t))}function lr(e){if(!e||e.length===0)return{keys:[],dimensionKeys:[],metricKeys:[]};const t=CCe(e),n=SCe(e),r=n.filter(o=>{var i,a,c,u,d,f,h,m;return!!(typeof((i=e==null?void 0:e[t])==null?void 0:i[o])&&typeof((a=e==null?void 0:e[t])==null?void 0:a[o])=="string"||typeof((c=e==null?void 0:e[0])==null?void 0:c[o])&&typeof((u=e==null?void 0:e[0])==null?void 0:u[o])=="string"||typeof((d=e==null?void 0:e[1])==null?void 0:d[o])&&typeof((f=e==null?void 0:e[1])==null?void 0:f[o])=="string"||typeof((h=e==null?void 0:e[2])==null?void 0:h[o])&&typeof((m=e==null?void 0:e[2])==null?void 0:m[o])=="string")});r.length===0&&r.push(n[0]);const s=n.filter(o=>{var i,a;return((i=e==null?void 0:e[t])==null?void 0:i[o])===+((a=e==null?void 0:e[t])==null?void 0:a[o])});return{keys:n,dimensionKeys:r,metricKeys:s}}function wa(e,t){var r;const n=(r=t==null?void 0:t.data)==null?void 0:r.datasets;return n&&n.length>0?e.map((o,i)=>({...o,...n==null?void 0:n[i],data:o.data,label:o.label})):e}function NCe(e,t="asc"){function n(r){return Object.entries(r).slice(1).reduce((i,[a,c])=>{const u=typeof c=="number"?c:parseFloat(c);return i+(isNaN(u)?0:u)},0)}return e.sort((r,s)=>{const o=n(r),i=n(s);return t==="asc"?o-i:i-o})}function W0({dataArray:e,groupKey:t,pivotKey:n,valueKey:r,sortChart:s}){const o=e.reduce((c,u)=>{const d=u[t],f=u[n],h=u[r];return c[d]||(c[d]={[t]:d}),c[d][f]=h,c},{});let i=Object.values(o);return s!=="none"&&s!==void 0&&(i=NCe(i,s)),i.map(c=>Object.fromEntries(Object.entries(c).filter(([u,d])=>d!==0)))}function Wr(e,t){var c;const n=p.useDashboardStore.getState().themeStyle,r=(c=n==null?void 0:n.chart)==null?void 0:c.options,s=dl({},e,t),o=$o(r),i=kCe(o,s);return dl({},i,e,t)}function h4(e,t){if(!e.scales||!t)return e;const n=Object.entries(e.scales).reduce((r,[s,o])=>{if(!o)return r;const i=t[s];return r[s]=i?dl({},i,o):o,r},{});return{...e,scales:n}}function kCe(e,t){if(!(e!=null&&e.scales))return e;const n=Object.entries(t.scales??{}).filter(([,s])=>!!s).map(([s])=>s);if(n.length===0){const{scales:s,...o}=e;return o}const r=n.reduce((s,o)=>{const i=e.scales[o];return i&&(s[o]=i),s},{});return{...e,scales:r}}function Ac(e,t){return e.map(n=>n[t]?n[t]:"BLANK")}function _Ce(e,t,n){if(!(e!=null&&e.sheets)||!t||!n)return null;const r=e.sheets.find(i=>i.id===t);if(!(r!=null&&r.frames))return null;const s=r.frames.find(i=>i.id===n);return s!=null&&s.cards&&(s.cards.find(i=>i.id===s.activeCardId)||s.cards[0])||null}function jCe(e,t){return!(e!=null&&e.sheets)||!t?null:e.sheets.find(n=>n.id===t)||null}function ICe(e){if(!(e!=null&&e.sheets))return null;for(const t of e.sheets)if(t!=null&&t.frames){for(const n of t.frames)if(n!=null&&n.cards){for(const r of n.cards)if(r!=null&&r.dataSource)return r.dataSource}}return null}function gw(e,t,n,r){if(e!=null&&e.dataSource)return e.dataSource;if(r){const s=_Ce(t,n,r);if(s!=null&&s.dataSource)return s.dataSource}return ICe(t)}function Rk(e){var $,q;const{frame:t,card:n,visualId:r,setFrame:s,setCard:o,setIsDevMode:i,initializeModeDrafts:a,setActiveTabCardId:c,updateDataSource:u,setQueryResultColumns:d,setSelectedConnectionId:f,setSelectedDatabaseName:h,setSelectedSchemaName:m,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:x,setInlineFilterValuesMap:y,setApplyFilters:w,setIsDashboardEditing:v,setIsVisualEditing:C,dashboard:N,selectedSheetId:k,selectedFrameId:_,filterValues:j,dataRecords:E,inlineFilterValuesMap:I,currentSelections:T={}}=e,D=jCe(N,k),R=p.getEditableSheetCalculatedFields(D,t.id),A=!!D&&!p.hasSheetCalculatedFieldStore(D)&&R.length===0?t.calculatedFields:D?R:t.calculatedFields,U={...t,...r?{visualId:r}:{},calculatedFields:A};if(s(U),o(n),a?a(n):i(!!n.sql),c&&t.activeCardId&&c(t.activeCardId),u&&N){const W=gw(n,N,k||null,_||null);W&&u(W)}if(f){const W=N?gw(n,N,k||null,_||null):null;f((n==null?void 0:n.connectionId)||(W==null?void 0:W.connectionId)||T.connectionId||"")}if(h&&b){const W=N?gw(n,N,k||null,_||null):null;n!=null&&n.datamodelId&&n.datamodelId!=="none"?(b(n.datamodelId),h("")):n!=null&&n.lastSelectedDatabase&&n.lastSelectedDatabase!=="none"?(h(n.lastSelectedDatabase),b("")):($=W==null?void 0:W.dbSelection)!=null&&$.database?(h(W.dbSelection.database),b("")):(h(T.databaseName||""),b(T.datamodelId||""))}if(m){const W=N?gw(n,N,k||null,_||null):null;m((n==null?void 0:n.lastSelectedSchema)||((q=W==null?void 0:W.dbSelection)==null?void 0:q.schema)||T.schemaName||"")}if(g&&g((n==null?void 0:n.lastSelectedTable)||T.tableName||""),d&&E){const{dimensionKeys:W}=lr(E);d(W)}if(x&&w&&j&&(x(j),w(!0)),y){const W=Object.fromEntries(t.cards.map(O=>[O.id,I==null?void 0:I[O.id]]).filter(O=>!!O[1]));y(W)}v(!0),C(!0)}function ECe(e){const t=p.useDashboardStore(q=>q.filterValues),n=p.useDashboardStore(q=>q.inlineFilterValuesMap),r=p.useDashboardStore(q=>q.isVisualEditing),s=p.useDashboardStore(q=>q.selectedSheetId),o=p.useDashboardStore(q=>q.selectedFrameId),i=p.useDashboardStore(q=>q.dashboard),{selectedConnection:a}=Mc(),{selectedDatabaseName:c,selectedSchemaName:u,selectedTableName:d,selectedDatamodelId:f}=mj(),{clearSelectedVisual:h}=vh(),m=p.useDashboardStore(q=>q.actions.setIsVisualEditing),g=p.useEditorStore(q=>q.actions.setFilterValues),b=p.useEditorStore(q=>q.actions.setApplyFilters),x=p.useEditorStore(q=>q.actions.setInlineFilterValuesMap),{setCard:y,setFrame:w,setQueryResultColumns:v,setActiveTabCardId:C,setIsDevMode:N,initializeModeDrafts:k,updateDataSource:_,clearEditorContext:j}=p.useEditorActions(),{setSelectedFrameId:E}=p.useDashboardActions(),I=p.useEditorStore(q=>q.actions.setSelectedConnectionId),T=p.useEditorStore(q=>q.actions.setSelectedDatamodelId),D=p.useEditorStore(q=>q.actions.setSelectedDatabaseName),R=p.useEditorStore(q=>q.actions.setSelectedSchemaName),F=p.useEditorStore(q=>q.actions.setSelectedTableName),A=e.cards.find(q=>q.id===e.activeCardId),{data:U}=yc(A);function $(q=!1){E(e.id),h(),j(),q||m(!r),Rk({frame:e,card:A,setFrame:w,setCard:y,setIsDevMode:N,initializeModeDrafts:k,setActiveTabCardId:C,updateDataSource:_,setQueryResultColumns:v,setSelectedConnectionId:I,setSelectedDatabaseName:D,setSelectedSchemaName:R,setSelectedTableName:F,setSelectedDatamodelId:T,setFilterValues:g,setInlineFilterValuesMap:x,setApplyFilters:b,setIsDashboardEditing:()=>{},setIsVisualEditing:()=>{},dashboard:i,selectedSheetId:s,selectedFrameId:o,filterValues:t,inlineFilterValuesMap:n,dataRecords:U==null?void 0:U.records,currentSelections:{connectionId:a==null?void 0:a.id,databaseName:c,schemaName:u,tableName:d,datamodelId:f}})}return{handleEditVisual:$,card:A,data:U}}const TCe={open:!1,frameId:null,cardId:null,triggerElement:null,anchorPosition:null,openPopover:()=>null,closePopover:()=>null},iZ=S.createContext(TCe);function DCe({children:e}){const[t,n]=S.useState(!1),[r,s]=S.useState(null),[o,i]=S.useState(null),[a,c]=S.useState(null),[u,d]=S.useState(null),m={open:t,frameId:r,cardId:o,triggerElement:a,anchorPosition:u,openPopover:(g,b,x)=>{const y=x.getBoundingClientRect(),w=x.closest('[role="dashboard-frame-container"], [role="card-frame"], .semaphor-card-frame');if(w){const v=w.getBoundingClientRect();d({left:v.right,top:v.top,width:1,height:v.height})}else d({left:y.right,top:y.top,width:1,height:y.height});s(g),i(b),c(x),n(!0)},closePopover:()=>{n(!1),setTimeout(()=>{s(null),i(null),c(null),d(null)},200)}};return l.jsx(iZ.Provider,{value:m,children:e})}function oF(){const e=S.useContext(iZ);if(e===void 0)throw new Error("useInteractionsPopover must be used within an InteractionsPopoverProvider");return e}const iF=1200;function aZ(e){if(["text-right","text-end","numeric","text-center"].some(r=>e.classList.contains(r)))return!0;const n=e.style.textAlign||e.style.getPropertyValue("text-align");return n==="right"||n==="center"}function fc(e){return e.map(t=>{var s;const n=((s=t.textContent)==null?void 0:s.trim())||"",r=t.getBoundingClientRect();return{text:n,colspan:t.colSpan||1,rowspan:t.rowSpan||1,className:t.className||void 0,columnId:t.getAttribute("data-column-id"),isHeader:t.tagName==="TH",isNumeric:aZ(t),isButton:!!t.querySelector("button"),measuredWidthPx:Number.isFinite(r.width)?Math.round(r.width):void 0}})}function aF(e){const t=Array.from(e.querySelectorAll("thead tr")),n=t[t.length-1];return(n?Array.from(n.querySelectorAll("th, td")):Array.from(e.querySelectorAll("tbody tr:first-child td, tbody tr:first-child th"))).map((s,o)=>{var a;const i=s.getBoundingClientRect();return{index:o,columnId:s.getAttribute("data-column-id"),label:((a=s.textContent)==null?void 0:a.trim())||`Column ${o+1}`,isNumeric:aZ(s),measuredWidthPx:Number.isFinite(i.width)?Math.round(i.width):void 0}})}function MCe(e){var a,c;if(!e)return null;const t=e.querySelector('table[data-table-type="data"]');if(!t)return null;const n=Array.from(t.querySelectorAll("thead tr")).map(u=>{const d=Array.from(u.querySelectorAll("th, td"));return{cells:fc(d)}}),r=Array.from(t.querySelectorAll("tbody tr")).map((u,d)=>{const f=Array.from(u.querySelectorAll("td, th"));return{type:"data",index:d,cells:fc(f)}}),s=t.querySelector("tfoot tr"),o=s?{cells:fc(Array.from(s.querySelectorAll("td, th")))}:null,i={totalRows:Number(t.getAttribute("data-total-rows")||r.length),totalColumns:Number(t.getAttribute("data-total-columns")||(((a=r[0])==null?void 0:a.cells.length)??0)),tableType:"data",hasGrandTotal:!!o,columnOrder:(((c=n[0])==null?void 0:c.cells)||[]).map(u=>u.columnId||u.text),columns:aF(t)};return{headers:n,rows:r,grandTotal:o,metadata:i}}function ACe(e){var a;if(!e)return null;const t=e.querySelector('table[data-table-type="aggregate"]');if(!t)return null;const n=Array.from(t.querySelectorAll("thead tr")).map(c=>{const u=Array.from(c.querySelectorAll("th, td"));return{cells:fc(u)}}),r=Array.from(t.querySelectorAll("tbody tr")).map((c,u)=>{const d=Array.from(c.querySelectorAll("td, th"));return{type:c.getAttribute("data-row-type")||void 0,subtotalLevel:c.getAttribute("data-subtotal-level"),index:u,cells:fc(d)}}),s=t.querySelector("tfoot tr"),o=s?{cells:fc(Array.from(s.querySelectorAll("td, th")))}:null,i={groupByCount:Number(t.getAttribute("data-group-by-count")||0),hasGrandTotal:t.getAttribute("data-has-grand-total")==="true",totalRows:r.length,tableType:"aggregate",columnOrder:(((a=n[0])==null?void 0:a.cells)||[]).map(c=>c.columnId||c.text),columns:aF(t)};return{headers:n,rows:r,grandTotal:o,metadata:i}}function RCe(e){var a;if(!e)return null;const t=e.querySelector('table[data-pivot-table="true"]');if(!t)return null;const n=Array.from(t.querySelectorAll("thead tr")).map((c,u)=>{const d=Array.from(c.querySelectorAll("th, td"));return{headerType:c.getAttribute("data-header-type"),headerRowIndex:Number(c.getAttribute("data-header-row-index")||u),repeatHeader:c.getAttribute("data-repeat-header")==="true",cells:fc(d)}}),r=Array.from(t.querySelectorAll("tbody tr")).map((c,u)=>{const d=Array.from(c.querySelectorAll("td, th"));return{type:c.getAttribute("data-row-type")||void 0,subtotalLevel:c.getAttribute("data-subtotal-level"),index:u,cells:fc(d)}}),s=t.querySelector("tfoot tr"),o=s?{cells:fc(Array.from(s.querySelectorAll("td, th")))}:null,i={rowLevels:t.getAttribute("data-row-levels"),pivotLevels:t.getAttribute("data-pivot-levels"),totalRows:r.length,hasGrandTotal:!!o,tableType:"pivot",columnOrder:(((a=n[n.length-1])==null?void 0:a.cells)||[]).map(c=>c.columnId||c.text),columns:aF(t)};return{headers:n,rows:r,grandTotal:o,metadata:i}}function lZ(e,t){if(!e||!t)return null;const n=document.querySelector(`[role="card-frame"][data-frame-id="${e}"]`);if(!n)return null;switch(t){case"aggregateTable":return ACe(n);case"pivotTable":return RCe(n);case"table":case"detailTable":default:return MCe(n)}}function PCe(e){var h;const{cardType:t,reportTitle:n,tableStructure:r,filterLine:s,timezone:o,pageSize:i,orientation:a,wideTableStrategy:c,password:u,rowCount:d}=e,f=d??((h=r==null?void 0:r.rows)==null?void 0:h.length)??0;return{cardType:t,reportTitle:n,tableStructure:r,filterLine:s,timezone:o,pageSize:i,orientation:a,wideTableStrategy:c,password:u,rowCount:f}}function vp(e){return e.replace(/"/g,"")}function m4(e){return e.replace(/"/g,"")}function ud(e,t){return e?e.filter(n=>n.sheetId&&n.sheetId!==t?!1:n.applyToSheetIds!==void 0?n.applyToSheetIds.includes(t):n.excludeSheetIds!==void 0?!n.excludeSheetIds.includes(t):!0):[]}function FCe(e,t){return t?e.endsWith(t):e.startsWith("summary:")}function cy(e,t,n,r={}){if(!(t!=null&&t.length))return[];const s=r.includeCardScoped??!0,o=ud(e,n).filter(a=>{var c,u;return s||!((c=a.applyToCardIds)!=null&&c.length)&&!((u=a.excludeCardIds)!=null&&u.length)}),i=new Set(o.map(a=>a.id));return t.filter(a=>i.has(a.filterId)||FCe(a.filterId,n))}function OCe(e,t,n,r){const s=ud(e,r),o=n?m4(n):void 0;return s.find(i=>vp(i.column)===vp(t)&&(!i.qualifiedTableName||!o||m4(i.qualifiedTableName)===o))}function lF({dashboard:e,filterValues:t,selectedSheetId:n,sheetSelection:r="current",dashboardControlValues:s,cardControlValuesMap:o}){const i=e==null?void 0:e.filters,a=n??null,c=r==="all"?Array.from(new Map(((e==null?void 0:e.sheets)||[]).flatMap(f=>cy(i,t,f.id).map(h=>[h.filterId,h]))).values()):cy(i,t,a),u={...s||{}},d=r==="all"?p.getDashboardCardEntries({sheets:(e==null?void 0:e.sheets)||[]}):a?p.getDashboardCardEntries({sheets:(e==null?void 0:e.sheets)||[]}).filter(f=>f.sheet.id===a):[];for(const f of d)Object.assign(u,(o==null?void 0:o[f.card.id])||{});return{selectedSheetId:a,filterValues:c,controlValues:u}}function cZ({dashboard:e,cardId:t,interactionStates:n,currentDashboardId:r,semanticExecutionPayload:s,filters:o,filterValues:i,inlineFilterValuesMap:a,dashboardControls:c,dashboardControlValues:u,cardControlValuesMap:d}){if(!e)return null;const f=p.findCardLocationById(e,t);if(!f)return null;const h=V0({card:f.card,interactionStates:n,currentDashboardId:r??e.id,filters:o,filterValues:i,selectedSheetId:f.sheet.id,inlineFilterValuesMap:a,dashboardControls:c,dashboardControlValues:u,cardControlValuesMap:d}),{cardFilterValues:m}=Ek({card:f.card,cardConfig:h.queryRelevantConfig,filters:o,cardFilterValues:h.cardFilterValues,semanticExecutionPayload:s});return{card:f.card,sheetId:f.sheet.id,queryContext:{...h,cardFilterValues:m}}}function uZ({dashboardInputValues:e,dashboard:t,filterValues:n,sheetId:r,cardId:s,sectionId:o,sheetKind:i}){var u;if(!((u=t.inputs)!=null&&u.length))return e;const a=new Map(n.map(d=>[d.filterId,d]));let c=e||{};for(const d of t.inputs){if(d.kind!=="filter"||!xp(d,{sheetId:r,cardId:s,sectionId:o,sheetKind:i}))continue;const f=a.get(d.filter.id),h=f?p.createFilterDashboardInputSlot(f):void 0;c=p.setDashboardInputRuntimeSlot(c,d,{sheetId:r,cardId:s,sectionId:o},h||{status:"cleared"})}return c}function vu({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,mode:o,runtimeValues:i,generatedAt:a,timezone:c}){const u=nS({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,mode:o,runtimeValues:i,timezone:c});return{context:u,snapshot:{...t?{sheetId:t}:{},...n!=null&&n.id?{cardId:n.id}:{},mode:o,dashboardInputValues:$Ce({inputs:u.inputs,context:u,sheetId:t,cardId:n==null?void 0:n.id,sectionId:r}),generatedAt:a,timezone:c}}}function dZ({sectionIds:e,...t}){const n=new Set,r=s=>{for(const o of s.missingRequiredInputs)n.add(o.label)};r(nS(t));for(const s of e)r(nS({...t,sectionId:s}));for(const{sectionId:s,card:o}of mZ(t.dashboard,t.sheetId,e))r(nS({...t,sectionId:s,card:o}));return Array.from(n)}function fZ({sheetIds:e,sheetKind:t="dashboard",...n}){const r=e.map(a=>vu({...n,sheetId:a,sheetKind:t})),s=e.flatMap(a=>LCe(n.dashboard,a).map(c=>vu({...n,sheetId:a,card:c,sheetKind:t}))),o=r[0]||s[0]||vu({...n,sheetKind:t}),i=pZ(...r.map(a=>a.snapshot.dashboardInputValues),...s.map(a=>a.snapshot.dashboardInputValues));return{context:o.context,snapshot:{...e.length===1?{sheetId:e[0]}:{},mode:n.mode,dashboardInputValues:i,generatedAt:n.generatedAt,timezone:n.timezone}}}function LCe(e,t){var i;const n=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),r=[],s=new Set,o=a=>{!(a!=null&&a.id)||s.has(a.id)||(s.add(a.id),r.push(a))};for(const a of(n==null?void 0:n.cards)||[])o(a);for(const a of(n==null?void 0:n.frames)||[])for(const c of(a==null?void 0:a.cards)||[])o(c);return r}function hZ({sectionIds:e,...t}){const n=vu(t),r=e.map(o=>vu({...t,sectionId:o})),s=mZ(t.dashboard,t.sheetId,e).map(({sectionId:o,card:i})=>vu({...t,sectionId:o,card:i}));return{...n,snapshot:{...n.snapshot,dashboardInputValues:pZ(n.snapshot.dashboardInputValues,...r.map(o=>o.snapshot.dashboardInputValues),...s.map(o=>o.snapshot.dashboardInputValues))}}}function mZ(e,t,n){var i,a;const r=new Set(n),s=(i=e.sheets)==null?void 0:i.find(c=>c.id===t);return(((a=s==null?void 0:s.document)==null?void 0:a.sections)||[]).flatMap(c=>c.id&&r.has(c.id)&&c.card?[{sectionId:c.id,card:c.card}]:[])}function $Ce({inputs:e,context:t,sheetId:n,cardId:r,sectionId:s}){const o=new Map(t.resolvedInputs.map(a=>[a.id,a]));let i={};for(const a of e){const c=o.get(a.id),u=(c==null?void 0:c.slot)||{status:"cleared"};i=p.setDashboardInputRuntimeSlot(i,a,{sheetId:n,cardId:r,sectionId:s},u)}return p.compactDashboardInputValues(i)}function zCe(e){return e==="document"||e==="visual"?"export":"print"}function nS({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,mode:o,runtimeValues:i,timezone:a}){return Nl({dashboard:e,sheetId:t,card:n,sectionId:r,sheetKind:s,runtimeValues:i,mode:zCe(o),timezone:a})}function pZ(...e){const t={};for(const n of e)n.shared&&(t.shared={...t.shared,...n.shared}),EI(t,"bySheetId",n.bySheetId),EI(t,"byCardId",n.byCardId),EI(t,"byDocumentSectionId",n.byDocumentSectionId);return p.compactDashboardInputValues(t)}function EI(e,t,n){if(n){e[t]||(e[t]={});for(const[r,s]of Object.entries(n))e[t][r]={...e[t][r],...s}}}const p4=700,BCe=/https?:\/\/\S+/g,VCe=/([?&](?:authToken|accessToken|refreshToken|token|password)=)[^&\s]+/gi,Pk="max-h-[12.5rem] min-w-0 max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words pr-2 [overflow-wrap:anywhere]";function g4(e){if(!e||typeof e!="object")return;const{error:t,message:n,detail:r}=e;for(const s of[t,n,r])if(typeof s=="string"&&s.trim())return s.trim()}async function gZ(e){const t=`PDF request failed: ${e.status} ${e.statusText}`.trim(),n=e.headers.get("content-type")||"";try{if(n.includes("application/json")){const s=await e.json();return g4(s)||t}const r=await e.text();if(!r.trim())return t;try{return g4(JSON.parse(r))||r.trim()}catch{return r.trim()}}catch{return t}}function Fk(e,t="Failed to download PDF"){let n;if(e instanceof Error&&e.message.trim()?n=e.message.trim():typeof e=="string"&&e.trim()&&(n=e.trim()),!n)return t;const r=n.replace(VCe,"$1[redacted]").replace(BCe,"[print render URL redacted]");return r.length<=p4?r:`${r.slice(0,p4).trimEnd()}...`}function bZ(e,t){t.controlDefinitions!==void 0&&e.set("controlDefinitions",JSON.stringify(t.controlDefinitions)),t.cardControlDefinitions!==void 0&&e.set("cardControlDefinitions",JSON.stringify(t.cardControlDefinitions)),t.controlBindings!==void 0&&e.set("controlBindings",JSON.stringify(t.controlBindings))}async function cF(e,t){var i;if(p.useDashboardStore.getState().isDownloadingPdf)return;const r=Intl.DateTimeFormat().resolvedOptions().timeZone,s=new URLSearchParams;s.set("theme",t.theme),s.set("filterValues",JSON.stringify(t.filterValues)),s.set("controlValues",JSON.stringify(t.defaultControlValues||{})),s.set("dashboardId",t.dashboardId),bZ(s,{controlDefinitions:t.controlDefinitions,cardControlDefinitions:t.cardControlDefinitions,controlBindings:t.controlBindings}),t.selectedSheetId!==void 0&&s.set("selectedSheetId",t.selectedSheetId),t.dashboardTitle!==void 0&&s.set("dashboardTitle",t.dashboardTitle),t.visualId!==void 0&&s.set("visualId",t.visualId),t.frameId!==void 0&&s.set("frameId",t.frameId),t.tableMode!==void 0&&s.set("tableMode",String(t.tableMode)),t.pdfMode&&s.set("pdfMode",t.pdfMode),t.documentSheetId&&s.set("documentSheetId",t.documentSheetId),t.documentInputValues&&s.set("documentInputValues",JSON.stringify(t.documentInputValues)),t.dashboardInputExecutionSnapshot&&s.set("dashboardInputExecutionSnapshot",JSON.stringify(t.dashboardInputExecutionSnapshot)),t.cardType!==void 0&&s.set("cardType",t.cardType),t.cardTitle!==void 0&&s.set("reportTitle",t.cardTitle),t.password&&s.set("password",t.password),t.pageSize&&s.set("pageSize",t.pageSize),t.orientation&&s.set("orientation",t.orientation),s.set("wideTableStrategy",t.wideTableStrategy||"auto"),t.filterLine&&s.set("filterLine",t.filterLine),s.set("timezone",t.timezone||r),t.sheetSelection&&s.set("sheetSelection",t.sheetSelection),t.expandedState&&Object.keys(t.expandedState).length>0&&s.set("expandedState",JSON.stringify(t.expandedState));const o=`${e}/v1/pdf?params=${encodeURIComponent(s.toString())}`;p.useDashboardStore.setState({isDownloadingPdf:!0});try{const a=await fetch(o,{method:"GET",headers:{Authorization:`Bearer ${(i=t.authToken)==null?void 0:i.accessToken}`}});if(!a.ok)throw new Error(await gZ(a));const c=await a.json();if(c.error)throw new Error(c.error);if(!c.url)throw new Error("No download URL received from server");const u=c.url,d=document.createElement("a");return d.href=u,d.download=t.fileName,d.click(),p.useDashboardStore.setState({isDownloadingPdf:!1}),c}catch(a){throw p.useDashboardStore.setState({isDownloadingPdf:!1}),a}}function HCe(e,t){var u,d;const n=p.useDashboardStore.getState(),r=(u=n.dashboard)==null?void 0:u.id,s=n.theme,o=(t==null?void 0:t.sheetSelection)==="all"&&n.dashboard?{...n.dashboard,sheets:p.getDashboardExportSheets(n.dashboard.sheets)}:n.dashboard,a=t&&Object.prototype.hasOwnProperty.call(t,"selectedSheetId")&&(t==null?void 0:t.sheetSelection)==="all"?t.selectedSheetId??void 0:(t==null?void 0:t.selectedSheetId)??n.selectedSheetId,c=lF({dashboard:o,filterValues:n.filterValues,selectedSheetId:a,sheetSelection:t==null?void 0:t.sheetSelection,dashboardControlValues:n.controlValues,cardControlValuesMap:n.cardControlValuesMap});return{authToken:e,dashboardId:r||"",theme:s||"light",filterValues:c.filterValues,defaultControlValues:c.controlValues,controlDefinitions:((d=n.dashboard)==null?void 0:d.controls)||[]}}function xZ(){var e,t;return!!((t=(e=p.useDashboardStore.getState().dashboard)==null?void 0:e.inputs)!=null&&t.length)}function F2(e){const t=p.useDashboardStore.getState();return{dashboardInputValues:(e==null?void 0:e.dashboardInputValues)??t.dashboardInputValues,filterValues:(e==null?void 0:e.filterValues)??t.filterValues,controlValues:t.controlValues,inlineFilterValuesMap:t.inlineFilterValuesMap,cardControlValuesMap:t.cardControlValuesMap}}function yZ(){return typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0}function UCe({selectedSheetId:e,sheetSelection:t}){const n=p.useDashboardStore.getState();if(!n.dashboard||!xZ())return;const r=t==="all"?p.getDashboardExportSheets(n.dashboard.sheets).map(s=>s.id):e?[e]:[];if(r.length!==0)return fZ({dashboard:n.dashboard,sheetIds:r,sheetKind:"dashboard",mode:"dashboard",runtimeValues:F2(),generatedAt:new Date().toISOString(),timezone:yZ()}).snapshot}function qCe(e,t){const n=p.useDashboardStore.getState();if(!n.dashboard||!xZ())return;const r=p.findFrameCardLocationById(n.dashboard,e),s=(r==null?void 0:r.sheet.id)||n.selectedSheetId||void 0,o=F2(),i=(t==null?void 0:t.filterValues)!==void 0?uZ({dashboardInputValues:o.dashboardInputValues,dashboard:n.dashboard,filterValues:t.filterValues,sheetId:s,cardId:r==null?void 0:r.card.id,sheetKind:"dashboard"}):o.dashboardInputValues;return vu({dashboard:n.dashboard,sheetId:s,card:(r==null?void 0:r.card)||null,sheetKind:"dashboard",mode:"visual",runtimeValues:F2({dashboardInputValues:i,filterValues:t==null?void 0:t.filterValues}),generatedAt:new Date().toISOString(),timezone:yZ()}).snapshot}function WCe(e,t){var f,h,m,g,b;const n=p.useDashboardStore.getState(),r=(f=n.dashboard)==null?void 0:f.title,s=(t==null?void 0:t.sheetSelection)||"current",o=t&&Object.prototype.hasOwnProperty.call(t,"selectedSheetId"),i=(t==null?void 0:t.selectedSheetId)===null||t==null?void 0:t.selectedSheetId,a=n.selectedSheetId===null?void 0:n.selectedSheetId,c=o&&(t==null?void 0:t.sheetSelection)==="all"?i:i??a,u=(m=(h=n.dashboard)==null?void 0:h.sheets)==null?void 0:m.find(x=>x.id===c);if(s==="current"&&p.isDocumentSheet(u))throw new Error("Document sheets cannot be exported through dashboard PDF export");if(s==="all"&&((b=(g=n.dashboard)==null?void 0:g.sheets)!=null&&b.length)&&p.getDashboardExportSheets(n.dashboard.sheets).length===0)throw new Error("No dashboard sheets are available for dashboard PDF export");return{...HCe(e,{selectedSheetId:c,sheetSelection:s}),dashboardTitle:r||"",...c!==void 0?{selectedSheetId:c}:{},dashboardInputExecutionSnapshot:UCe({selectedSheetId:c,sheetSelection:s})}}function GCe(e,t="current"){return WCe(e,{sheetSelection:t,...t==="all"?{selectedSheetId:void 0}:{}})}async function vZ(e,t,n,r,s){const{theme:o,filterValues:i,dashboardTitle:a,selectedSheetId:c,dashboardId:u,defaultControlValues:d,controlDefinitions:f,dashboardInputExecutionSnapshot:h}=GCe(t,r),m=`${a}-${new Date().toISOString()}.pdf`;await cF(e,{authToken:t,theme:o,filterValues:i,defaultControlValues:d,controlDefinitions:f,dashboardId:u,fileName:m,password:n,dashboardTitle:a,selectedSheetId:c,sheetSelection:r,dashboardInputExecutionSnapshot:h,expandedState:s,wideTableStrategy:"auto"})}async function uF(e,t,n){var a,c,u;const r=p.useDashboardStore.getState(),s=(a=r.dashboard)==null?void 0:a.id;if(!s)throw new Error("Dashboard ID is required for document PDF export");const o=((c=n.title)==null?void 0:c.trim())||"Document",i=`${o}-${new Date().toISOString()}.pdf`;await cF(e,{authToken:t,theme:r.theme||"light",filterValues:[],defaultControlValues:{},dashboardId:s,fileName:i,password:n.password,dashboardTitle:((u=r.dashboard)==null?void 0:u.title)||"",selectedSheetId:n.sheetId,pdfMode:"document",documentSheetId:n.sheetId,...n.inputSnapshot?{dashboardInputExecutionSnapshot:{...n.inputSnapshot,sheetId:n.inputSnapshot.sheetId||n.sheetId}}:{},...n.inputValues?{documentInputValues:{...n.inputValues,sheetId:n.sheetId}}:{},pageSize:n.pageSize,orientation:n.orientation,cardTitle:o,timezone:n.timezone,wideTableStrategy:"auto"})}function wZ(e,t,n,r,s){var b,x,y,w,v;const o=p.useDashboardStore.getState(),i=(b=o.dashboard)==null?void 0:b.id,a=o.theme,c=o.selectedSheetId,u=(s==null?void 0:s.filterValues)??o.filterValues,d=o.dashboard?p.findFrameCardLocationById(o.dashboard,t):void 0,f=(d==null?void 0:d.sheet.id)||c||void 0,h=cZ({dashboard:o.dashboard,cardId:t,interactionStates:p.useInteractionStore.getState().interactionStates,currentDashboardId:(x=o.dashboard)==null?void 0:x.id,semanticExecutionPayload:o.semanticExecutionPayload,filters:(y=o.dashboard)==null?void 0:y.filters,filterValues:u,inlineFilterValuesMap:o.inlineFilterValuesMap,dashboardControls:(w=o.dashboard)==null?void 0:w.controls,dashboardControlValues:o.controlValues,cardControlValuesMap:o.cardControlValuesMap}),m=lF({dashboard:o.dashboard,filterValues:u,selectedSheetId:f,sheetSelection:"current",dashboardControlValues:o.controlValues}),g=(h==null?void 0:h.queryContext.controlValues)||m.controlValues;return{authToken:e,dashboardId:i||"",theme:a||"light",filterValues:(s==null?void 0:s.filterValues)??((h==null?void 0:h.queryContext.cardFilterValues)||m.filterValues),defaultControlValues:g,controlDefinitions:(h==null?void 0:h.queryContext.controlDefinitions)||((v=o.dashboard)==null?void 0:v.controls)||[],cardControlDefinitions:(h==null?void 0:h.queryContext.cardControlDefinitions)||(d==null?void 0:d.card.controls)||[],controlBindings:(h==null?void 0:h.queryContext.controlBindings)||(d==null?void 0:d.card.controlBindings)||[],selectedSheetId:f||"",cardId:t||"",frameId:n||"",cardTitle:r||"",dashboardInputExecutionSnapshot:qCe(t,s)}}async function SZ(e,t,n,r,s,o,i,a,c,u,d,f){const h=wZ(t,n,r,s,d!==void 0?{filterValues:d}:void 0),{theme:m,dashboardId:g,defaultControlValues:b,controlDefinitions:x,cardControlDefinitions:y,controlBindings:w,selectedSheetId:v,dashboardInputExecutionSnapshot:C}=h,N=d??h.filterValues,k=`${s}-${new Date().toISOString()}.pdf`,_=["table","aggregateTable","pivotTable","detailTable"].includes(o||"");return cF(e,{authToken:t,cardTitle:s,theme:m,filterValues:N,defaultControlValues:b,controlDefinitions:x,cardControlDefinitions:y,controlBindings:w,dashboardId:g,fileName:k,password:i,selectedSheetId:v,visualId:n,frameId:r,tableMode:_,cardType:o,pageSize:a,orientation:c,filterLine:u,dashboardInputExecutionSnapshot:C,expandedState:f,wideTableStrategy:"auto"})}async function YCe(e,t,n,r,s,o,i,a,c,u,d,f){await SZ(e,t,n,r,s,o,i,a,c,u,d,f)}async function KCe(e,t,n,r,s,o,i,a,c,u,d,f){return SZ(e,t,n,r,s,o,i,a,c,u,d,f)}async function ZCe(e,t,n,r,s,o,i){if(!(t!=null&&t.accessToken))throw new Error("Missing auth token for PDF export");let a=i.tableStructure??null;if(!a&&o!=="pivotTable"&&(a=lZ(r,o)),o==="pivotTable"&&!a)throw new Error("Pivot fast-path PDF requires a prebuilt table structure");if(!a||a.rows.length===0)throw new Error("Unable to build table structure for fast-path PDF");const c=Intl.DateTimeFormat().resolvedOptions().timeZone,u=PCe({cardType:o,reportTitle:s,tableStructure:a,filterLine:i.filterLine,timezone:c,pageSize:i.pageSize,orientation:i.orientation,wideTableStrategy:i.wideTableStrategy||"auto",password:i.password,rowCount:i.rowCount??a.rows.length});if(u.rowCount>iF)throw new Error("Fast-path row count exceeds threshold");const d=await fetch(`${e}/v1/pdf`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify(u)});if(!d.ok)throw new Error(await gZ(d));const f=await d.json();if(f.error)throw new Error(f.error);if(!(f!=null&&f.url))throw new Error("Fast-path PDF response missing download URL");const h=document.createElement("a");return h.href=f.url,h.download=`${s}-${new Date().toISOString()}.pdf`,h.click(),f}async function XCe(e,t,n,r,s,o,i={}){if(!["table","aggregateTable","pivotTable","detailTable"].includes(o))return{success:!1};const a=i.rowCount??0;if(a&&a>iF)return{success:!1};if(p.useDashboardStore.getState().isDownloadingPdf)return{success:!1};p.useDashboardStore.setState({isDownloadingPdf:!0});try{return{success:!0,layoutApplied:(await ZCe(e,t,n,r,s,o,i)).layoutApplied??null}}catch(u){return console.warn("Fast-path PDF generation failed, falling back to URL path",u),{success:!1}}finally{p.useDashboardStore.setState({isDownloadingPdf:!1})}}var Ok="Checkbox",[QCe]=p.createContextScope(Ok),[JCe,dF]=QCe(Ok);function eNe(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:o,form:i,name:a,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:f}=e,[h,m]=p.useControllableState({prop:n,defaultProp:s??!1,onChange:c,caller:Ok}),[g,b]=Q.useState(null),[x,y]=Q.useState(null),w=Q.useRef(!1),v=g?!!i||!!g.closest("form"):!0,C={checked:h,disabled:o,setChecked:m,control:g,setControl:b,name:a,form:i,value:d,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:wu(s)?!1:s,isFormControl:v,bubbleInput:x,setBubbleInput:y};return l.jsx(JCe,{scope:t,...C,children:tNe(f)?f(C):r})}var CZ="CheckboxTrigger",NZ=Q.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:o,value:i,disabled:a,checked:c,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:h,isFormControl:m,bubbleInput:g}=dF(CZ,e),b=p.useComposedRefs(s,d),x=Q.useRef(c);return Q.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const w=()=>f(x.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[o,f]),l.jsx(p.Primitive.button,{type:"button",role:"checkbox","aria-checked":wu(c)?"mixed":c,"aria-required":u,"data-state":EZ(c),"data-disabled":a?"":void 0,disabled:a,value:i,...r,ref:b,onKeyDown:p.composeEventHandlers(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:p.composeEventHandlers(n,y=>{f(w=>wu(w)?!0:!w),g&&m&&(h.current=y.isPropagationStopped(),h.current||y.stopPropagation())})})});NZ.displayName=CZ;var fF=Q.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:o,required:i,disabled:a,value:c,onCheckedChange:u,form:d,...f}=e;return l.jsx(eNe,{__scopeCheckbox:n,checked:s,defaultChecked:o,disabled:a,required:i,onCheckedChange:u,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:h})=>l.jsxs(l.Fragment,{children:[l.jsx(NZ,{...f,ref:t,__scopeCheckbox:n}),h&&l.jsx(IZ,{__scopeCheckbox:n})]})})});fF.displayName=Ok;var kZ="CheckboxIndicator",_Z=Q.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,o=dF(kZ,n);return l.jsx(p.Presence,{present:r||wu(o.checked)||o.checked===!0,children:l.jsx(p.Primitive.span,{"data-state":EZ(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});_Z.displayName=kZ;var jZ="CheckboxBubbleInput",IZ=Q.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:i,required:a,disabled:c,name:u,value:d,form:f,bubbleInput:h,setBubbleInput:m}=dF(jZ,e),g=p.useComposedRefs(n,m),b=p.usePrevious(o),x=p.useSize(r);Q.useEffect(()=>{const w=h;if(!w)return;const v=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(v,"checked").set,k=!s.current;if(b!==o&&N){const _=new Event("click",{bubbles:k});w.indeterminate=wu(o),N.call(w,wu(o)?!1:o),w.dispatchEvent(_)}},[h,b,o,s]);const y=Q.useRef(wu(o)?!1:o);return l.jsx(p.Primitive.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??y.current,required:a,disabled:c,name:u,value:d,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});IZ.displayName=jZ;function tNe(e){return typeof e=="function"}function wu(e){return e==="indeterminate"}function EZ(e){return wu(e)?"indeterminate":e?"checked":"unchecked"}const Mn=Q.forwardRef(({className:e,...t},n)=>{const r=t.checked==="indeterminate";return l.jsx(fF,{ref:n,className:p.cn("peer h-4 w-4 shrink-0 rounded-control border border-input bg-background ring-offset-background transition-colors hover:border-muted-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",e),...t,children:l.jsx(_Z,{className:p.cn("flex items-center justify-center text-current"),children:r?l.jsx(Yl,{className:"h-3 w-3",strokeWidth:3}):l.jsx(p.Check,{className:"h-3 w-3",strokeWidth:3})})})});Mn.displayName=fF.displayName;var hF="Radio",[nNe,TZ]=p.createContextScope(hF),[rNe,sNe]=nNe(hF),DZ=Q.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:s=!1,required:o,disabled:i,value:a="on",onCheck:c,form:u,...d}=e,[f,h]=Q.useState(null),m=p.useComposedRefs(t,x=>h(x)),g=Q.useRef(!1),b=f?u||!!f.closest("form"):!0;return l.jsxs(rNe,{scope:n,checked:s,disabled:i,children:[l.jsx(p.Primitive.button,{type:"button",role:"radio","aria-checked":s,"data-state":PZ(s),"data-disabled":i?"":void 0,disabled:i,value:a,...d,ref:m,onClick:p.composeEventHandlers(e.onClick,x=>{s||c==null||c(),b&&(g.current=x.isPropagationStopped(),g.current||x.stopPropagation())})}),b&&l.jsx(RZ,{control:f,bubbles:!g.current,name:r,value:a,checked:s,required:o,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});DZ.displayName=hF;var MZ="RadioIndicator",AZ=Q.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...s}=e,o=sNe(MZ,n);return l.jsx(p.Presence,{present:r||o.checked,children:l.jsx(p.Primitive.span,{"data-state":PZ(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:t})})});AZ.displayName=MZ;var oNe="RadioBubbleInput",RZ=Q.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...s},o)=>{const i=Q.useRef(null),a=p.useComposedRefs(i,o),c=p.usePrevious(n),u=p.useSize(t);return Q.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const g=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(g)}},[c,n,r]),l.jsx(p.Primitive.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:a,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});RZ.displayName=oNe;function PZ(e){return e?"checked":"unchecked"}var iNe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Lk="RadioGroup",[aNe]=p.createContextScope(Lk,[p.createRovingFocusGroupScope,TZ]),FZ=p.createRovingFocusGroupScope(),OZ=TZ(),[lNe,cNe]=aNe(Lk),LZ=Q.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:s,value:o,required:i=!1,disabled:a=!1,orientation:c,dir:u,loop:d=!0,onValueChange:f,...h}=e,m=FZ(n),g=p.useDirection(u),[b,x]=p.useControllableState({prop:o,defaultProp:s??null,onChange:f,caller:Lk});return l.jsx(lNe,{scope:n,name:r,required:i,disabled:a,value:b,onValueChange:x,children:l.jsx(p.Root,{asChild:!0,...m,orientation:c,dir:g,loop:d,children:l.jsx(p.Primitive.div,{role:"radiogroup","aria-required":i,"aria-orientation":c,"data-disabled":a?"":void 0,dir:g,...h,ref:t})})})});LZ.displayName=Lk;var $Z="RadioGroupItem",zZ=Q.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...s}=e,o=cNe($Z,n),i=o.disabled||r,a=FZ(n),c=OZ(n),u=Q.useRef(null),d=p.useComposedRefs(t,u),f=o.value===s.value,h=Q.useRef(!1);return Q.useEffect(()=>{const m=b=>{iNe.includes(b.key)&&(h.current=!0)},g=()=>h.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),l.jsx(p.Item,{asChild:!0,...a,focusable:!i,active:f,children:l.jsx(DZ,{disabled:i,required:o.required,checked:f,...c,...s,name:o.name,ref:d,onCheck:()=>o.onValueChange(s.value),onKeyDown:p.composeEventHandlers(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:p.composeEventHandlers(s.onFocus,()=>{var m;h.current&&((m=u.current)==null||m.click())})})})});zZ.displayName=$Z;var uNe="RadioGroupIndicator",BZ=Q.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,s=OZ(n);return l.jsx(AZ,{...s,...r,ref:t})});BZ.displayName=uNe;var VZ=LZ,HZ=zZ,dNe=BZ;const Sa=Q.forwardRef(({className:e,...t},n)=>l.jsx(VZ,{className:p.cn("grid gap-2",e),...t,ref:n}));Sa.displayName=VZ.displayName;const ws=Q.forwardRef(({className:e,...t},n)=>l.jsx(HZ,{ref:n,className:p.cn("aspect-square h-4 w-4 rounded-full border border-input bg-background text-foreground transition-colors hover:border-muted-foreground focus-visible:outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-foreground",e),...t,children:l.jsx(dNe,{className:"flex items-center justify-center",children:l.jsx(KR,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ws.displayName=HZ.displayName;const fNe=p.cva("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),mF=Q.forwardRef(({className:e,variant:t,...n},r)=>l.jsx("div",{ref:r,role:"alert",className:p.cn(fNe({variant:t}),e),...n}));mF.displayName="Alert";const UZ=Q.forwardRef(({className:e,...t},n)=>l.jsx("h5",{ref:n,className:p.cn("mb-1 font-medium leading-none tracking-tight",e),...t}));UZ.displayName="AlertTitle";const pF=Q.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:p.cn("text-sm [&_p]:leading-relaxed",e),...t}));pF.displayName="AlertDescription";function qZ(e){const t=e.split(".");return t[t.length-1].replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")}function b4(e){const{name:t,operation:n,values:r,valueType:s}=e,o=qZ(t);if(!r||r.length===0)return n==="is null"?`${o} is empty`:n==="is not null"?`${o} is not empty`:"";const i=a=>{if(s==="date"&&a){const c=new Date(a);if(!isNaN(c.getTime()))return c.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}return String(a)};switch(n){case"=":return`${o}: ${i(r[0])}`;case"!=":return`${o} ≠ ${i(r[0])}`;case">":return`${o} > ${i(r[0])}`;case"<":return`${o} < ${i(r[0])}`;case">=":return`${o} ≥ ${i(r[0])}`;case"<=":return`${o} ≤ ${i(r[0])}`;case"between":case"not between":{const a=`${i(r[0])} - ${i(r[1])}`;return n==="between"?`${o}: ${a}`:`${o} not in ${a}`}case"in":{if(r.length===1)return`${o}: ${i(r[0])}`;const a=r.map(i).join(", ");return`${o}: ${a}`}case"not in":{const a=r.map(i).join(", ");return`${o} not in (${a})`}case"like":return`${o} contains "${r[0]}"`;case"not like":return`${o} doesn't contain "${r[0]}"`;default:return`${o}: ${r.map(i).join(", ")}`}}function WZ(e){if(!e||e.length===0)return"";const t=new Map;e.forEach(r=>{const s=t.get(r.name)||[];s.push(r),t.set(r.name,s)});const n=[];return t.forEach((r,s)=>{if(r.length===1){const o=b4(r[0]);o&&n.push(o)}else{const o=qZ(s),i=r.map(a=>b4(a).replace(`${o}: `,"").replace(`${o} `,"")).filter(Boolean);i.length>0&&n.push(`${o}: ${i.join(" and ")}`)}}),n.join(" | ")}function GZ(e,t){const n=typeof e.decimalPlaces=="number",r=typeof e.minimumFractionDigits=="number"?e.minimumFractionDigits:n?e.decimalPlaces:t.min,s=typeof e.maximumFractionDigits=="number"?e.maximumFractionDigits:n?e.decimalPlaces:t.max;return{minimumFractionDigits:r,maximumFractionDigits:Math.max(r,s)}}function rC(e,t){const n=GZ(e,t),r=typeof e.suffix=="string"&&e.suffix.length>0;return{style:"decimal",locale:e.locale,currency:e.currency,minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits,useGrouping:e.useGrouping,useSuffix:!!(e.useSuffix&&!r),prefix:e.prefix,suffix:e.suffix,negativeInParentheses:e.negativeInParentheses,multiplyBy:e.multiplyBy,percentValueMode:e.percentValueMode}}function In(e,t="auto",n={}){switch(t==="auto"&&(t=bNe(e,n)),t){case"number":return YZ(e,n);case"currency":return KZ(e,n);case"percent":return hNe(e,n);case"date":return mNe(e,n);case"scientific":return pNe(e,n);case"duration":return gNe(e,n);default:return String(e)}}function YZ(e,t={}){return e<0&&!!t.prefix&&!t.negativeInParentheses?`-${On.formatNumber(Math.abs(e),rC(t,{min:0,max:0}))}`:On.formatNumber(e,rC(t,{min:0,max:0}))}function KZ(e,t={}){return On.formatCurrency(e,{...rC(t,{min:2,max:2}),style:"currency",currency:t.currency||"USD"})}function hNe(e,t={}){const n=GZ(t,{min:1,max:1}),s=typeof t.multiplyBy=="number"&&Number.isFinite(t.multiplyBy)?t.multiplyBy:t.percentValueMode==="whole"?1:100,o=e*s;return On.formatNumber(o,{locale:t.locale,minimumFractionDigits:n.minimumFractionDigits,maximumFractionDigits:n.maximumFractionDigits,useGrouping:t.useGrouping,prefix:t.prefix,suffix:t.suffix||"%",negativeInParentheses:t.negativeInParentheses,useSuffix:!1})}function mNe(e,t={}){const{locale:n="en-US"}=t;try{const r=new Date(e);return isNaN(r.getTime())?String(e):new Intl.DateTimeFormat(n,{dateStyle:"short"}).format(r)}catch{return String(e)}}function pNe(e,t={}){return On.formatScientific(e,rC(t,{min:2,max:2}))}function gNe(e,t={}){return On.formatDuration(e,{inputUnit:t.durationInputUnit,outputStyle:t.durationDisplayStyle,largestUnit:t.durationLargestUnit,smallestUnit:t.durationSmallestUnit,maxUnits:t.durationMaxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeInParentheses})}function bNe(e,t){return t.currency?"currency":typeof e=="string"&&!isNaN(Date.parse(e))?"date":"number"}function xNe(e,t={}){return n=>In(n,e,t)}function uy({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:s="",locale:o="en-US"}){if(s){const i=KZ(e,{currency:s,decimalPlaces:t,locale:o,useSuffix:n&&!r});return n&&r?`${i}${r}`:i}return YZ(e,{decimalPlaces:t,useSuffix:n&&!r,suffix:r,locale:o})}const yNe=e=>{e=e.replace("#","");const t=Number.parseInt(e.substr(0,2),16),n=Number.parseInt(e.substr(2,2),16),r=Number.parseInt(e.substr(4,2),16);return(.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"},Ba=()=>({urlTemplate:"{value}",labelType:"value",staticLabel:"",labelColumn:"",openInNewTab:!0}),Js=()=>({type:"none",inheritMetricFormat:!0,textAlign:"left",width:150,minWidth:50,maxWidth:500,textOverflow:"ellipsis",textWrap:"default",numberFormat:{style:"decimal",currency:"USD",locale:"en-US",minimumFractionDigits:0,maximumFractionDigits:2,useGrouping:!0,percentValueMode:"whole",showDataBar:!1,showHeatmap:!1,dataBarColor:"#3b82f6",dataBarMinValue:void 0,dataBarMaxValue:void 0},dateFormat:{format:"MM/dd/yyyy",useCustomFormat:!1,customFormat:"yyyy-MM-dd'T'HH:mm:ss",useRelativeTime:!1,timezone:"auto",sourceTimezone:"auto"},linkFormat:Ba(),colorRanges:[]});function gF(e,t,n,r){return t&&t!=="auto"?t:e?n:r||n}const sC=e=>!e||e==="auto"?"local time":{"America/New_York":"Eastern Time","America/Chicago":"Central Time","America/Denver":"Mountain Time","America/Los_Angeles":"Pacific Time","Europe/London":"London Time","Europe/Paris":"Central European Time","Asia/Tokyo":"Japan Time","Asia/Shanghai":"China Time",UTC:"UTC"}[e]||e;function wx(e){return e?Object.entries(e).some(([t,n])=>n==null||n===""?!1:t==="type"?n!=="auto":!0):!1}function ZZ(e){if(e)return e.alias||e.label||e.name}function Du(e,t){var r;return(((r=e==null?void 0:e.config)==null?void 0:r.metricColumns)||[]).find(s=>{const o=ZZ(s);return t.metricId&&s.id===t.metricId||t.metricAlias&&o===t.metricAlias||t.metricAlias&&s.alias===t.metricAlias||t.columnId&&o===t.columnId||t.columnId&&s.alias===t.columnId||t.columnId&&s.label===t.columnId||t.columnId&&s.name===t.columnId})}function TI(e){if(e)return e.trim().toLowerCase()}const XZ=/\s*(?:\((?:previous|last year|start|target|comparison)\)|δ)\s*$/i;function vNe(e){const t=e==null?void 0:e.trim();return t?t.replace(XZ,"").trim()||t:void 0}function wNe(e){const t=e==null?void 0:e.trim();return t?XZ.test(t):!1}function dy(e){var m;const{card:t,datasetIndex:n,datasetLabel:r,metricKey:s}=e,o=((m=t==null?void 0:t.config)==null?void 0:m.metricColumns)||[];if(o.length===1)return o[0];const i=[s,r];if(!i.some(g=>wNe(g))&&typeof n=="number"&&n>=0&&n<o.length)return o[n];const c=i.filter(g=>!!g);for(const g of c){const b=Du(t,{columnId:g,metricAlias:g});if(b)return b}const u=c.map(g=>TI(g)).filter(g=>!!g),d=c.map(g=>vNe(g)).filter(g=>!!g);for(const g of d){const b=Du(t,{columnId:g,metricAlias:g});if(b)return b}const f=d.map(g=>TI(g)).filter(g=>!!g),h=[...u,...f];if(h.length!==0)return o.find(g=>{const b=[g.alias,g.label,g.name,ZZ(g)].map(x=>TI(x)).filter(x=>!!x);return h.some(x=>b.includes(x))})}function $k(e){const t=p.fromSemanticFormat(e==null?void 0:e.format);return p.toTFormatOptions(t)}function x4(e,t){if(t)return Du(e,{columnId:t,metricAlias:t})}function y4(e){const t=p.fromTFormatOptions(e);if(t)return JSON.stringify(t)}function SNe(e,t){const n=y4(e),r=y4(t);return!!(n&&r&&n===r)}function CNe(e){if(e.length===0)return;const t=e.map(i=>$k(i));if(!t.every(i=>wx(i)))return;const r=t,[s]=r;return r.every(i=>SNe(s,i))?s:void 0}function QZ(e){const t=e.formatMode||e.legacyMode;return t==="override"?"override":t==="inherit"?"inherit":e.legacyMode&&e.legacyMode!=="auto"&&e.legacyMode!=="inherit"&&e.legacyMode!=="override"||wx(e.formatOptions)?"override":"inherit"}function zk(e){const t=QZ({formatMode:e.formatMode,legacyMode:e.legacyMode,formatOptions:e.overrideFormatOptions});if(t==="override"&&wx(e.overrideFormatOptions))return{formatOptions:e.overrideFormatOptions||void 0,source:"override"};if(t==="override"&&e.legacyMode==="none")return{formatOptions:void 0,source:"override",rawValue:!0};const n=CNe(e.metrics||[]);if(wx(n))return{formatOptions:n,source:"metric"};const r=Z0(e.preferences);return wx(r)?{formatOptions:r,source:"legacy"}:{formatOptions:void 0,source:"auto"}}function JZ(e){var u,d,f,h;const{card:t,chartType:n,axis:r,preferences:s}=e,o=((u=t==null?void 0:t.config)==null?void 0:u.metricColumns)||[],i=(s==null?void 0:s.datasetOptions)||[];if(!o.length)return[];if(n==="combo")return r==="x"?[]:o.filter((m,g)=>{const b=i.find(y=>y.idx===g);return((b==null?void 0:b.yAxisId)==="y2"?"y2":"y")===r});if(n==="bubble"||n==="scatter"){if(r==="y2")return[];const m=x4(t,(d=s==null?void 0:s.bubbleScatterConfig)==null?void 0:d.xMetricKey)||o[0],g=x4(t,(f=s==null?void 0:s.bubbleScatterConfig)==null?void 0:f.yMetricKey)||o[1]||o[0];return r==="x"?m?[m]:[]:g?[g]:[]}const c=((h=s==null?void 0:s.chartOptions)==null?void 0:h.indexAxis)==="y"||n==="horizontalBar"?"x":"y";return n==="radar"?r==="y"?o:[]:r!==c?[]:o}function tg(e){const{card:t,chartType:n,axis:r,preferences:s,axisConfig:o}=e;return zk({formatMode:o==null?void 0:o.formatMode,overrideFormatOptions:o==null?void 0:o.formatOptions,metrics:JZ({card:t,chartType:n,axis:r,preferences:s}),preferences:s})}function eX(e,t){if(!e&&(!t||t==="auto"||t==="none"))return;const n={...e||{}};return t&&t!=="auto"&&t!=="none"&&!n.type&&(n.type=t),n}function Bk(e){const{preferences:t,metric:n}=e,r=t==null?void 0:t.tooltipConfig;return zk({formatMode:r==null?void 0:r.formatMode,legacyMode:r==null?void 0:r.mode,overrideFormatOptions:r==null?void 0:r.formatOptions,metrics:n?[n]:[],preferences:t})}function bF(e,t){return t==="x"?e==null?void 0:e.xAxisConfig:t==="y2"?e==null?void 0:e.secondaryYAxisConfig:e==null?void 0:e.yAxisConfig}function xF(e){var s;const{chartType:t,preferences:n}=e,r=((s=n==null?void 0:n.chartOptions)==null?void 0:s.indexAxis)==="y";return t==="bubble"||t==="scatter"?"y":r?"x":"y"}function tX(e){switch(e){case"pie":case"doughnut":case"polarArea":case"funnel":case"treemap":case"heatmap":return!1;default:return!0}}function yF(e){const{card:t,chartType:n,preferences:r,metric:s}=e,o=Bk({preferences:r,metric:s});if(o.source==="override")return o;const i=e.axis||xF({chartType:n,preferences:r}),a=tg({card:t,chartType:n,axis:i,preferences:r,axisConfig:bF(r,i)});return a.source==="override"?a:o}function G0(e){const{card:t,chartType:n,preferences:r,dataLabelsConfig:s}=e,o=n||(t==null?void 0:t.type),i=xF({chartType:o,preferences:r}),a=zk({formatMode:s==null?void 0:s.formatMode,legacyMode:s==null?void 0:s.format,overrideFormatOptions:eX(s==null?void 0:s.formatOptions,s==null?void 0:s.format),metrics:JZ({card:t,chartType:o,axis:i,preferences:r}),preferences:r});if(a.source==="override"||!tX(o))return a;const c=tg({card:t,chartType:o,axis:i,preferences:r,axisConfig:bF(r,i)});return c.source==="override"?c:a}function nX(e){const{preferences:t,dataLabelsConfig:n,metric:r}=e;return zk({formatMode:n==null?void 0:n.formatMode,legacyMode:n==null?void 0:n.format,overrideFormatOptions:eX(n==null?void 0:n.formatOptions,n==null?void 0:n.format),metrics:r?[r]:[],preferences:t})}function Y0(e){var i,a;const t=dy({card:e.card,datasetIndex:e.datasetIndex,datasetLabel:e.datasetLabel,metricKey:e.metricKey}),n=nX({preferences:e.preferences,dataLabelsConfig:e.dataLabelsConfig,metric:t});if(n.source==="override")return n;const r=(i=e.card)==null?void 0:i.type;if(!tX(r))return n;let s=xF({chartType:r,preferences:e.preferences});if(r==="combo"&&typeof e.datasetIndex=="number"){const u=(((a=e.preferences)==null?void 0:a.datasetOptions)||[]).find(d=>d.idx===e.datasetIndex);s=(u==null?void 0:u.yAxisId)==="y2"?"y2":"y"}const o=tg({card:e.card,chartType:r,axis:s,preferences:e.preferences,axisConfig:bF(e.preferences,s)});return o.source==="override"?o:n}function ng(e){return(e==null?void 0:e.rawValue)===!0}function bw(e){const t=e==null?void 0:e.numberFormat;if(!t)return;const n=t.style==="currency"?"currency":t.style==="percent"?"percent":t.style==="scientific"?"scientific":"number",r=t.minimumFractionDigits,s=t.maximumFractionDigits;return{type:n,currency:n==="currency"?t.currency:void 0,locale:t.locale,decimalPlaces:r===s?s:void 0,minimumFractionDigits:r,maximumFractionDigits:s,useGrouping:t.useGrouping,percentValueMode:n==="percent"?t.percentValueMode:void 0}}function rX(e,t){const n=p.fromSemanticFormat(e==null?void 0:e.format),r=p.toColumnNumberFormat(n);if(!r)return;const s=t||Js(),o=s.numberFormat,i=s.type&&s.type!=="none";return{...s,type:i?s.type:"number",inheritMetricFormat:s.inheritMetricFormat??!0,textAlign:i?s.textAlign:"right",numberFormat:{...o,...r,showDataBar:o.showDataBar,showHeatmap:o.showHeatmap,dataBarColor:o.dataBarColor,dataBarMinValue:o.dataBarMinValue,dataBarMaxValue:o.dataBarMaxValue}}}function Mu(e){const{card:t,columnId:n,existingSettings:r,fallbackSettings:s,metricId:o,metricAlias:i}=e;if(r&&r.inheritMetricFormat!==!0)return r;const a=Du(t,{columnId:n,metricId:o,metricAlias:i});return rX(a,r||s)||r||s}function K0(e){const{card:t,columnId:n,existingSettings:r,fallbackSettings:s,metricId:o,metricAlias:i}=e;if(r&&r.inheritMetricFormat!==!0)return bw(r)||bw(s);const a=Du(t,{columnId:n,metricId:o,metricAlias:i});return $k(a)||bw(r)||bw(s)}function Z0(e){var g,b,x,y,w,v,C;const t=(g=e==null?void 0:e.formatNumber)==null?void 0:g.enabled,n=typeof t=="string"?t.trim().toLowerCase()!=="false":t!==!1,r=p.fromNumberAxisFormat(e==null?void 0:e.numberAxisFormat)||(n?p.fromLegacyFormatNumber(e==null?void 0:e.formatNumber):void 0),s=p.toTFormatOptions(r);if(!s||!s.type||s.type==="auto")return s;const o=(b=e==null?void 0:e.numberAxisFormat)==null?void 0:b.decimalPlaces,i=n?(x=e==null?void 0:e.formatNumber)==null?void 0:x.decimalPlaces:void 0,a=typeof o=="number"?o:typeof i=="number"?i:void 0,c=(y=e==null?void 0:e.numberAxisFormat)==null?void 0:y.minimumFractionDigits,u=(w=e==null?void 0:e.numberAxisFormat)==null?void 0:w.maximumFractionDigits,d=n?(v=e==null?void 0:e.formatNumber)==null?void 0:v.minimumFractionDigits:void 0,f=n?(C=e==null?void 0:e.formatNumber)==null?void 0:C.maximumFractionDigits:void 0,h=typeof a=="number"?a:typeof c=="number"?c:typeof d=="number"?d:0,m=typeof a=="number"?a:typeof u=="number"?u:typeof f=="number"?f:0;return{...s,decimalPlaces:h===m?m:s.decimalPlaces,minimumFractionDigits:h,maximumFractionDigits:Math.max(h,m)}}function fy(e){var s,o,i,a,c;const{value:t,formatOptions:n,preferences:r}=e;return n!=null&&n.type&&n.type!=="auto"?In(t,n.type,n):uy({number:t,decimalPlaces:((s=r==null?void 0:r.numberAxisFormat)==null?void 0:s.decimalPlaces)??0,useSuffix:!!((o=r==null?void 0:r.numberAxisFormat)!=null&&o.suffix),customSuffix:((i=r==null?void 0:r.numberAxisFormat)==null?void 0:i.suffix)||"",locale:((a=r==null?void 0:r.numberAxisFormat)==null?void 0:a.locale)||"en-US",currency:((c=r==null?void 0:r.numberAxisFormat)==null?void 0:c.currency)||""})}function v4(e,t,n,r,s){if(!e||e.length===0){console.warn("No data to export");return}const o=(s==null?void 0:s.delimiter)||",",i=(s==null?void 0:s.includeHeaders)!==!1,a=Object.keys(e[0]);let c=a;if(n!=null&&n.columnVisibility&&(c=a.filter(d=>{var f;return((f=n.columnVisibility)==null?void 0:f[d])!==!1})),n!=null&&n.columnSizing){const d=Object.keys(n.columnSizing),f=d.filter(m=>c.includes(m)),h=c.filter(m=>!d.includes(m));c=[...f,...h]}let u="";if(i){const d=c.map(f=>ib(f,o));u+=d.join(o)+`
724
724
  `}e.forEach(d=>{const f=c.map(h=>{var g;const m=d[h];if(m==null)return"";if(s!=null&&s.useFormattedValues){const b=(g=n==null?void 0:n.columnSettingsMap)==null?void 0:g[h];if(typeof m=="number"){const x=K0({card:r,columnId:h,existingSettings:b});if(x!=null&&x.type&&x.type!=="auto")return ib(In(m,x.type,x),o);if((b==null?void 0:b.type)==="number")return ib(On.formatNumberWithColumnSettings(m,b.numberFormat),o)}if((b==null?void 0:b.type)==="date"&&(m instanceof Date||typeof m=="string")){const x=m instanceof Date?m:new Date(m);if(!isNaN(x.getTime()))return ib(x.toLocaleDateString(),o)}}return ib(String(m),o)});u+=f.join(o)+`
725
725
  `}),NNe(u,t)}function ib(e,t){return e.includes(t)||e.includes('"')||e.includes(`
726
726
  `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function NNe(e,t){const n=t.endsWith(".csv")?t:`${t}.csv`,r="\uFEFF",s=new Blob([r+e],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function kNe(e){return e.type==="number"}function _Ne(e,t,n){var o;const r=(o=e.preferences)==null?void 0:o.columnSettings;if(!(r!=null&&r.length))return;const s=n+t;for(const i of r)if(kNe(i)&&i.columnIdx===s)return i}function jNe(e){const t=Js(),n=e.options||{locale:t.numberFormat.locale,options:{}},r=n.options||{},s=typeof r.minimumFractionDigits=="number"?r.minimumFractionDigits:t.numberFormat.minimumFractionDigits,o=typeof r.maximumFractionDigits=="number"?r.maximumFractionDigits:Math.max(s,t.numberFormat.maximumFractionDigits),i=r.style==="currency"||r.style==="percent"?r.style:"decimal";return{...t,type:"number",textAlign:e.textAlign||"right",numberFormat:{...t.numberFormat,style:i,currency:n.currency||t.numberFormat.currency,locale:n.locale||t.numberFormat.locale,minimumFractionDigits:s,maximumFractionDigits:o,useGrouping:typeof r.useGrouping=="boolean"?r.useGrouping:t.numberFormat.useGrouping,percentValueMode:i==="percent"?"whole":t.numberFormat.percentValueMode}}}function Gb(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function w4(e){return Gb(e)==="%"}function INe(e){var y,w;const t=Js(),n=(y=e.preferences)==null?void 0:y.formatNumber,r=(w=e.preferences)==null?void 0:w.numberAxisFormat,s=n==null?void 0:n.enabled;if(!(s!==!1&&s!=="false"))return{...t,type:"none",textAlign:"right"};const i=Gb(n==null?void 0:n.currency)||Gb(r==null?void 0:r.currency),a=Gb(n==null?void 0:n.locale)||Gb(r==null?void 0:r.locale),c=w4(n==null?void 0:n.suffix)||w4(r==null?void 0:r.suffix),u=(n==null?void 0:n.decimalPlaces)??(r==null?void 0:r.decimalPlaces),d=(n==null?void 0:n.minimumFractionDigits)??(r==null?void 0:r.minimumFractionDigits),f=(n==null?void 0:n.maximumFractionDigits)??(r==null?void 0:r.maximumFractionDigits),h=typeof(n==null?void 0:n.useGrouping)=="boolean"?n.useGrouping:typeof(r==null?void 0:r.useGrouping)=="boolean"?r.useGrouping:t.numberFormat.useGrouping,m=c?"percent":i?"currency":t.numberFormat.style,g=(n==null?void 0:n.percentValueMode)??(r==null?void 0:r.percentValueMode),b=typeof u=="number"?u:d??t.numberFormat.minimumFractionDigits,x=typeof u=="number"?u:Math.max(b,f??t.numberFormat.maximumFractionDigits);return{...t,type:"number",textAlign:"right",numberFormat:{...t.numberFormat,style:m,locale:a||t.numberFormat.locale,currency:i||t.numberFormat.currency,useGrouping:h,percentValueMode:m==="percent"?g||"whole":t.numberFormat.percentValueMode,minimumFractionDigits:b,maximumFractionDigits:x}}}function Su({card:e,columnId:t,metricIndex:n,groupByColumnCount:r,columnSettingsMap:s}){var u,d;const o=s==null?void 0:s[t],i=(d=(u=e.config)==null?void 0:u.metricColumns)==null?void 0:d[n];if(o)return Mu({card:e,columnId:t,existingSettings:o,metricId:i==null?void 0:i.id,metricAlias:i==null?void 0:i.alias})||o;const a=rX(i);if(a)return a;const c=_Ne(e,n,r);return c?jNe(c):INe(e)}function vF(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string")return null;const t=e.trim();if(!t)return null;if(/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(t)){const o=Number(t);return Number.isFinite(o)?o:null}if(!/^[+-]?(?:\d{1,3}(?:,\d{3})+)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t))return null;const r=t.replace(/,/g,""),s=Number(r);return Number.isFinite(s)?s:null}function wF(e,t){if(!t||t.type!=="number")return null;const n=vF(e);if(n===null||typeof e=="string"&&Math.abs(n)>Number.MAX_SAFE_INTEGER)return null;const{numberFormat:r}=t;try{return On.formatNumberWithColumnSettings(n,r,r.locale||"en-US")||null}catch{return n.toLocaleString()}}function sX(e,t,n,r,s,o){if(!e||e.length===0)return"";const i=[],a=r.filter(u=>u.isMetricColumn),c=[];if(n.forEach(u=>{c.push(u.label||u.name)}),a.forEach(u=>{c.push(u.displayLabel||u.metricLabel||u.metricName||"")}),i.push(c.map(MI).join(",")),e.forEach(u=>{const d=[];if(u.isSubtotal&&!u.isGrandTotal){const f=u.subtotalLevel,h=n.findIndex(m=>m.alias===f);n.forEach((m,g)=>{var x,y,w,v;const b=m.alias||m.name;if(g===h){const C=u.aggregate||"SUM",N=(w=(y=(x=s==null?void 0:s.config)==null?void 0:x.rowAggregates)==null?void 0:y.find(k=>k.groupLevel===u.subtotalLevel&&k.function===C))==null?void 0:w.label;if(N)d.push(N);else{const _=(((v=u.subtotalContext)==null?void 0:v.groupByValues)||{})[b],j=C==="SUM"?"Total":C.charAt(0).toUpperCase()+C.slice(1).toLowerCase();_&&_!=="__TOTAL__"?d.push(`Subtotal (${_})`):d.push(`Subtotal ${j}`)}}else if(g<h){const C=u[b];d.push(C&&C!=="__TOTAL__"?String(C):"")}else d.push("")}),a.forEach((m,g)=>{const b=u[m.alias],x=Su({card:s,columnId:m.alias,metricIndex:g,groupByColumnCount:n.length,columnSettingsMap:o});d.push(DI(b,x))})}else n.forEach(f=>{const h=f.alias||f.name,m=u[h];d.push(m?String(m):"")}),a.forEach((f,h)=>{const m=u[f.alias],g=Su({card:s,columnId:f.alias,metricIndex:h,groupByColumnCount:n.length,columnSettingsMap:o});d.push(DI(m,g))});i.push(d.map(MI).join(","))}),t){const u=[];n.forEach((d,f)=>{var h,m;if(f===0){const g=(m=(h=s==null?void 0:s.config)==null?void 0:h.rowAggregates)==null?void 0:m.find(b=>b.groupLevel==="ALL");if(g!=null&&g.label)u.push(g.label);else{const b=t.aggregate||"SUM",x=b==="SUM"?"Total":b.charAt(0).toUpperCase()+b.slice(1).toLowerCase();u.push(`Grand ${x}`)}}else u.push("")}),a.forEach((d,f)=>{const h=t[d.alias],m=Su({card:s,columnId:d.alias,metricIndex:f,groupByColumnCount:n.length,columnSettingsMap:o});u.push(DI(h,m))}),i.push(u.map(MI).join(","))}return i.join(`
@@ -1323,7 +1323,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
1323
1323
  - less than the value passed to \`max\` (or ${w3} if no \`max\` prop is set)
1324
1324
  - \`null\` or \`undefined\` if the progress is indeterminate.
1325
1325
 
1326
- Defaulting to \`null\`.`}var cde=ode,Fdt=ade;const S3=Q.forwardRef(({className:e,value:t,...n},r)=>l.jsx(cde,{ref:r,className:p.cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:l.jsx(Fdt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));S3.displayName=cde.displayName;function Odt({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const s=o=>Hg.includes(o)?Spe:o.includes("pdf")||o.includes("text")?di:o.includes("javascript")||o.includes("typescript")||o.includes("python")||o.includes("sql")?cW:Npe;return l.jsx("div",{className:`flex flex-wrap gap-1.5 ${r}`,children:e.map(o=>{const i=s(o.type);return l.jsxs("div",{className:"group inline-flex h-7 items-center gap-1.5 rounded-control border border-border/60 bg-background px-1.5 text-[11px]",children:[l.jsx("span",{className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] bg-muted",children:l.jsx(i,{className:"h-2.5 w-2.5 text-muted-foreground"})}),l.jsx("span",{className:"max-w-[140px] truncate text-foreground/85",children:o.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:h0(o.size)}),o.uploadProgress!==void 0&&o.uploadProgress<100&&l.jsx(S3,{value:o.uploadProgress,className:"h-0.5 w-12 shrink-0"}),n&&t&&l.jsx("button",{type:"button",onClick:()=>t(o.id),className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${o.name}`,children:l.jsx(p.X,{className:"h-3 w-3"})})]},o.id)})})}function Ldt({file:e,className:t=""}){return Hg.includes(e.type)&&e.preview?l.jsxs("div",{className:`inline-block ${t}`,children:[l.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-card border border-border"}),l.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",h0(e.size)]})]}):l.jsxs("div",{className:`inline-flex items-center gap-1.5 rounded-control border border-border/60 bg-muted/30 px-2 py-1 ${t}`,children:[l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[12px] text-foreground/85",children:e.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:h0(e.size)})]})}function $dt({children:e,onFilesDropped:t,disabled:n=!1,currentFileCount:r=0,className:s}){const[o,i]=S.useState(!1),a=S.useCallback(f=>{f.preventDefault(),f.stopPropagation(),n||i(!0)},[n]),c=S.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.currentTarget.getBoundingClientRect(),m=f.clientX,g=f.clientY;(m<h.left||m>=h.right||g<h.top||g>=h.bottom)&&i(!1)},[]),u=S.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),d=S.useCallback(async f=>{if(f.preventDefault(),f.stopPropagation(),i(!1),n)return;const h=Array.from(f.dataTransfer.files);if(h.length===0)return;const m=Hl-r;if(h.length>m){et.error(`You can only attach ${Hl} files per message. You have ${m} slot(s) remaining.`);return}const{valid:g,errors:b}=rde(h);if(b.forEach(({file:x,error:y})=>{et.error(`${x.name}: ${y}`)}),g.length>0)try{const x=await Promise.all(g.map(y=>y3(y)));t(x),et.success(`${x.length} file(s) attached successfully`)}catch(x){console.error("Failed to process files:",x),et.error("Failed to process one or more files")}},[n,r,t]);return l.jsxs("div",{className:p.cn("relative",s),onDragEnter:a,onDragLeave:c,onDragOver:u,onDrop:d,children:[e,o&&!n&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-control border-2 border-dashed border-primary bg-primary/5 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(p.Upload,{className:"h-8 w-8 text-primary"}),l.jsx("p",{className:"text-sm font-medium text-primary",children:"Drop files here to upload"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[Hl-r," slot(s) available"]})]})})]})}function zdt(e,t,n){switch(e){case"none":return!1;case"include":return n.includes(t);case"exclude":return!n.includes(t);case"all":default:return!0}}function Bdt({mode:e,currentDomainId:t,scopedDomainIds:n,hasSelectedEntities:r}){return e==="all"?!1:e==="none"?!!t||r:t?!zdt(e,t,n):r}function ude(e){const{tokenProps:t}=ht(),n=p.useDashboardStore(c=>c.authToken)||e;p.useEditorStore(c=>c.selectedConnectionId),p.useEditorStore(c=>{var u,d;return(d=(u=c==null?void 0:c.card)==null?void 0:u.dataSource)==null?void 0:d.connectionId});const{refetch:r,isPending:s,data:o,isLoading:i,isError:a}=Dn({queryKey:["semantic-domains"],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/domains`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)});return{isPending:s,error:a,semanticDomainsData:o,semanticDomains:(o==null?void 0:o.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:a,refetchSemanticDomains:r}}function Vdt({domainAccess:e,search:t,scopeDomainId:n,selectedEntities:r,onSelectionChange:s}){const{semanticDomains:o,isSemanticDomainsLoading:i}=ude(),a=S.useMemo(()=>Udt(o,e),[o,e]),c=S.useMemo(()=>n?a.filter(d=>d.id===n):a,[a,n]);if(i&&c.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading semantic domains…"});if(c.length===0)return null;const u=!!n;return l.jsxs("div",{children:[l.jsx(dde,{label:"Semantic Domains"}),c.map(d=>l.jsx(Hdt,{domain:d,search:t,forceExpanded:u,selectedEntities:r,onSelectionChange:s},d.id))]})}function Hdt({domain:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){const[o,i]=S.useState(!1),a=o||t.length>0||!!n,{datasets:c,isPending:u}=wSe(a?e.id:void 0),d=S.useMemo(()=>{if(!t)return c;const v=t.trim().toLowerCase();return c.filter(C=>`${C.label??""} ${C.name??""} ${C.description??""}`.toLowerCase().includes(v))},[c,t]),f=t.length>0&&d.length>0,h=o||f||!!n,m=c.length,g=S.useMemo(()=>d.filter(v=>r.some(C=>Qn(C,z1(v)))).length,[d,r]),b=S.useMemo(()=>d.map(z1),[d]),x=b.length>0&&b.every(v=>r.some(C=>Qn(C,v))),y=()=>{if(b.length===0)return;if(x){s(r.filter(C=>!b.some(N=>Qn(C,N))));return}const v=[...r];for(const C of b)v.some(N=>Qn(N,C))||v.push(C);s(v)},w=v=>{const C=z1(v),N=r.some(k=>Qn(k,C));s(N?r.filter(k=>!Qn(k,C)):[...r,C])};return t.length>0&&!f&&!u?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center rounded-[4px] px-3 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l.jsx(Bn,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.label||e.name}),m>0&&l.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",m," dataset",m===1?"":"s"," · curated"]})]}),h&&!u&&b.length>0&&l.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-background hover:text-foreground",children:x?"Clear":"Select all"}),l.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground",children:g>0?g:""})]}),h&&l.jsx("ul",{className:"space-y-px pb-1",children:u&&c.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"Loading datasets…"}):d.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"No datasets in this domain."}):d.map(v=>{const C=z1(v),N=r.some(k=>Qn(k,C));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-[4px] px-9 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(Mn,{checked:N,onCheckedChange:()=>w(v),className:"mt-[3px] h-3.5 w-3.5 shrink-0"}),l.jsx(zi,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground",children:v.label||v.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:v.type==="virtual"?"virtual":"dataset"})]}),v.description&&l.jsx("p",{className:"mt-0.5 text-[11px] leading-[1.4] text-muted-foreground",children:v.description})]})]})},v.id)})})]})}function dde({label:e}){return l.jsx("div",{className:"px-3 pb-1.5 pt-2.5",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})})}function Udt(e,t){if(!t||t.mode==="all")return e;const n=new Set(t.domainIds??[]);return t.mode==="include"?e.filter(r=>n.has(r.id)):t.mode==="exclude"?e.filter(r=>!n.has(r.id)):[]}function z1(e){return{id:e.id,datasetType:e.type,name:e.name||e.table,label:e.label,domainId:e.domainId,description:e.description,database:e.database,schema:e.schema,table:e.table,type:"dataset",connectionId:e.connectionId,connectionType:e.connectionType,dialect:e.dialect,datamodelId:e.datamodelId,sql:e.sql}}function qdt({search:e,scopeConnectionId:t,selectedEntities:n,onSelectionChange:r}){const{connections:s,isConnectionsLoading:o}=Mc(),i=S.useMemo(()=>t?s.filter(c=>c.id===t):s,[s,t]);if(o&&i.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading connections…"});if(i.length===0)return null;const a=!!t;return l.jsxs("div",{children:[l.jsx(dde,{label:"Direct Sources"}),i.map(c=>l.jsx(Wdt,{connection:c,search:e,forceExpanded:a,selectedEntities:n,onSelectionChange:r},c.id))]})}function Wdt({connection:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){var g;const[o,i]=S.useState(!1),a=o||t.length>0||!!n,c=((g=e.capabilities)==null?void 0:g.path)??[],u=c.includes("database"),d=c.includes("schema"),f=e.type==="upload",h=e.type==="url",m=S.useMemo(()=>r.filter(b=>b.connectionId===e.id).length,[r,e.id]);return l.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[l.jsxs("button",{type:"button",onClick:()=>i(b=>!b),className:"flex w-full items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-muted/40",children:[l.jsx(Bn,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground/90",children:e.name}),l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["· ",e.type]}),l.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground",children:m>0?m:""})]}),a&&l.jsxs(l.Fragment,{children:[f?l.jsx(Gdt,{connection:e,selectedEntities:r,onSelectionChange:s}):h?l.jsx(Ydt,{connection:e,selectedEntities:r,onSelectionChange:s}):u?l.jsx(Kdt,{connection:e,requiresSchema:d,search:t,selectedEntities:r,onSelectionChange:s}):d?l.jsx(fde,{connection:e,databaseName:"",search:t,selectedEntities:r,onSelectionChange:s}):l.jsx(C3,{connection:e,databaseName:"",schemaName:"",search:t,selectedEntities:r,onSelectionChange:s}),!f&&!h&&l.jsx(Zdt,{connection:e,search:t,selectedEntities:r,onSelectionChange:s})]})]})}function Gdt({connection:e,selectedEntities:t,onSelectionChange:n}){const r=`upload-source-${e.id}`,s=t.filter(a=>a.connectionId===e.id&&(a.type==="upload"||a.type==="file")),o=a=>{if(!(a!=null&&a.length))return;const c=Array.from(a).map(u=>({id:`file-${Date.now()}-${Math.random()}`,name:u.name,type:"upload",connectionId:e.id,connectionType:e.type,label:u.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:u.name,file:u}));n([...t,...c])},i=a=>{n(t.filter(c=>!("id"in c&&c.id===a&&c.connectionId===e.id&&(c.type==="upload"||c.type==="file"))))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"rounded-[6px] border border-dashed border-border bg-muted/20 p-4 text-center",children:[l.jsx(p.Upload,{className:"mx-auto mb-2 h-5 w-5 text-muted-foreground"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Add CSV, JSON, or Excel files."}),l.jsx("input",{id:r,type:"file",multiple:!0,className:"hidden",onChange:a=>o(a.target.files),accept:".csv,.json,.xlsx,.xls"}),l.jsx(p.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 text-[12px]",onClick:()=>{var a;return(a=document.getElementById(r))==null?void 0:a.click()},children:"Select files"})]}),s.length>0&&l.jsx("ul",{className:"space-y-1",children:s.map(a=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(di,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:a.originalName||a.name}),l.jsx("button",{type:"button","aria-label":`Remove ${a.originalName||a.name}`,onClick:()=>i(a.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3 w-3"})})]},a.id))})]})}function Ydt({connection:e,selectedEntities:t,onSelectionChange:n}){const[r,s]=S.useState(""),[o,i]=S.useState(""),[a,c]=S.useState("api"),u=t.filter(h=>h.connectionId===e.id&&h.type==="url"),d=()=>{const h=r.trim(),m=o.trim();if(!h||!m)return;const g={id:`url-${Date.now()}-${Math.random()}`,name:h,type:"url",connectionId:e.id,connectionType:e.type,label:h,description:`URL source of type ${a}`,originalName:h,url:m,sourceType:a};n([...t,g]),s(""),i(""),c("api")},f=h=>{n(t.filter(m=>!("id"in m&&m.id===h&&m.connectionId===e.id&&m.type==="url")))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"space-y-2 rounded-[6px] border border-border bg-muted/20 p-3",children:[l.jsx(p.Input,{value:r,onChange:h=>s(h.target.value),placeholder:"Source name",className:"h-7 text-[12px]"}),l.jsx(p.Input,{value:o,onChange:h=>i(h.target.value),placeholder:"https://api.example.com/data",className:"h-7 text-[12px]"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:a,onChange:h=>c(h.target.value),className:"h-7 flex-1 rounded-control border border-input bg-background px-2 text-[12px]",children:[l.jsx("option",{value:"api",children:"API endpoint"}),l.jsx("option",{value:"csv",children:"CSV file"}),l.jsx("option",{value:"json",children:"JSON file"})]}),l.jsxs(p.Button,{type:"button",size:"sm",className:"h-7 text-[12px]",disabled:!r.trim()||!o.trim(),onClick:d,children:[l.jsx(kr,{className:"mr-1 h-3 w-3"}),"Add"]})]})]}),u.length>0&&l.jsx("ul",{className:"space-y-1",children:u.map(h=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(Ch,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[12px]",children:h.name}),l.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:h.url})]}),l.jsx("button",{type:"button","aria-label":`Remove ${h.name}`,onClick:()=>f(h.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3 w-3"})})]},h.id))})]})}function Kdt({connection:e,requiresSchema:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=Pj("/v1/databases",{connection_id:e.id},["databases",e.id]);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading databases…"});const i=((a=o.data)==null?void 0:a.databases)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No databases."}):l.jsx("div",{children:i.map(c=>l.jsx(hde,{label:c.database_name,indentLevel:1,search:n,renderChildren:u=>u&&(t?l.jsx(fde,{connection:e,databaseName:c.database_name,search:n,selectedEntities:r,onSelectionChange:s}):l.jsx(C3,{connection:e,databaseName:c.database_name,schemaName:"",search:n,selectedEntities:r,onSelectionChange:s}))},c.database_name))})}function fde({connection:e,databaseName:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=Pj("/v1/schemas",{connection_id:e.id,database_name:t||"NA"},["schemas",e.id,t],!!e.id);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading schemas…"});const i=((a=o.data)==null?void 0:a.schemas)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No schemas."}):l.jsx("div",{children:i.map(c=>l.jsx(hde,{label:c.schema_name,indentLevel:t?2:1,search:n,renderChildren:u=>u&&l.jsx(C3,{connection:e,databaseName:t,schemaName:c.schema_name,search:n,selectedEntities:r,onSelectionChange:s})},c.schema_name))})}function C3({connection:e,databaseName:t,schemaName:n,search:r,selectedEntities:s,onSelectionChange:o}){const i=Pj("/v1/tables",{connection_id:e.id,database_name:t||void 0,schema_name:n||void 0},["tables",e.id,t,n]),a=S.useMemo(()=>{var b;const m=((b=i.data)==null?void 0:b.tables)??[];if(!r)return m;const g=r.trim().toLowerCase();return m.filter(x=>x.table_name.toLowerCase().includes(g))},[i.data,r]),c=(m,g)=>({connectionId:e.id,connectionType:e.type,type:"table",dialect:e.dialect,database:t||void 0,schema:n||void 0,name:m,dbObjectType:g==null?void 0:g.toLowerCase()});if(i.isLoading)return l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"Loading tables…"});if(a.length===0)return r?null:l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"No tables."});const u=a.map(m=>c(m.table_name,m.table_type)),d=u.length>0&&u.every(m=>s.some(g=>Qn(g,m))),f=(m,g)=>{const b=c(m,g),x=s.some(y=>Qn(y,b));o(x?s.filter(y=>!Qn(y,b)):[...s,b])},h=()=>{if(u.length===0)return;if(d){o(s.filter(g=>!u.some(b=>Qn(g,b))));return}const m=[...s];for(const g of u)m.some(b=>Qn(b,g))||m.push(g);o(m)};return l.jsxs("ul",{children:[l.jsxs("li",{className:"flex items-center justify-between gap-2 py-1 pl-12 pr-4",children:[l.jsxs("span",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:[a.length," table",a.length===1?"":"s"]}),l.jsx("button",{type:"button",onClick:h,className:"rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:d?"Clear":"Select all"})]}),a.map(m=>{const g=c(m.table_name,m.table_type),b=s.some(x=>Qn(x,g));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Mn,{checked:b,onCheckedChange:()=>f(m.table_name,m.table_type),className:"h-3.5 w-3.5 shrink-0"}),l.jsx(p.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:m.table_name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:m.table_type??"table"})]})]})},m.table_name)})]})}function Zdt({connection:e,search:t,selectedEntities:n,onSelectionChange:r}){const s=Pj("/v1/datamodels",{connection_id:e.id},["datamodels",e.id]),o=S.useMemo(()=>{var u;const a=((u=s.data)==null?void 0:u.datamodels)??[];if(!t)return a;const c=t.trim().toLowerCase();return a.filter(d=>`${d.label??""} ${d.name??""} ${d.description??""}`.toLowerCase().includes(c))},[s.data,t]);if(s.isLoading||o.length===0)return null;const i=a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Qn(d,c));r(u?n.filter(d=>!Qn(d,c)):[...n,c])};return l.jsxs("div",{children:[l.jsx("div",{className:"px-8 pb-1 pt-2",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data models"})}),l.jsx("ul",{children:o.map(a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Qn(d,c));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Mn,{checked:u,onCheckedChange:()=>i(a),className:"mt-[2px] h-3.5 w-3.5 shrink-0"}),l.jsx(gpe,{className:"mt-[2px] h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:a.label||a.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:"model"})]}),a.description&&l.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:a.description})]})]})},a.id)})})]})}function hde({label:e,indentLevel:t,search:n,renderChildren:r}){const[s,o]=S.useState(!1),i=s||n.length>0,a=t===1?"pl-8":"pl-10";return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>o(c=>!c),className:p.cn("flex h-6 w-full items-center gap-1.5 pr-4 text-left transition-colors hover:bg-muted/40",a),children:[l.jsx(Bn,{className:p.cn("h-2.5 w-2.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e})]}),r(i)]})}function Pj(e,t,n,r=!0){const{tokenProps:s}=ht(),o=p.useDashboardStore(a=>a.authToken),i=S.useMemo(()=>Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0)),[t]);return Dn({queryKey:n,queryFn:()=>p.getRequest(`${s.apiServiceUrl}${e}`,(o==null?void 0:o.accessToken)||"",i),enabled:r&&!!(o!=null&&o.accessToken)&&Object.values(i).every(a=>a.length>0)})}function LH(e){return e.type==="dataset"&&e.label||e.name}function Xdt({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-input bg-muted/50 py-0.5 pl-1.5 pr-0.5 text-[11px] text-foreground/80",children:[l.jsx("span",{className:"max-w-[180px] truncate",children:LH(n)}),l.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),t(n)},"aria-label":`Remove ${LH(n)}`,className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]},`${n.type}-${n.name}-${r}`))})}function $H(e){const t=new Set;for(const n of e||[])"domainId"in n&&typeof n.domainId=="string"&&t.add(n.domainId);if(t.size===1)return[...t][0]}function SD(e){if(e!=null&&e.length)return e.every(t=>t.type==="dataset")?"semanticDomain":e.every(t=>t.type==="url")?"url":e.every(t=>t.type==="upload"||t.type==="file")?"upload":"database"}function N3({open:e,onOpenChange:t,dataSource:n,dialogMode:r,incomingSelectedEntities:s,onSaveSelectedEntities:o,saveAsDashboardDefault:i=!1}){var se,ge;const{tokenProps:a}=ht(),c=a.config,u=a.semanticDomainAccess||The.DEFAULT_SEMANTIC_DOMAIN_ACCESS,[d,f]=S.useState([]),[h,m]=S.useState(void 0),[g,b]=S.useState(""),[x,y]=S.useState("all"),[w,v]=S.useState(void 0),C=S.useRef(!1),{updateDataSource:N}=p.useEditorActions(),k=p.useDashboardStore(ie=>ie.isVisualEditing),_=p.useDashboardStore(ie=>ie.dashboard.aiContext),{setAiContext:j}=p.useDashboardActions(),E=u.mode,I=(c==null?void 0:c.showDirectSource)!==!1,T=E==="include"||E==="exclude"||!I,D=E!=="all",R=I&&!T,F=T?"semanticDomain":n.mode,A=r==="dataSource"&&!I,U=E==="include"&&(((se=u.domainIds)==null?void 0:se.length)||0)===1?(ge=u.domainIds)==null?void 0:ge[0]:void 0,$=S.useCallback(ie=>{C.current=!0,N({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:ie,selectedEntities:(n==null?void 0:n.selectedEntities)||[],...ie!=="semanticDomain"&&{semanticDomainId:void 0}})},[n,N]),q=S.useCallback(ie=>{N({...n,...ie})},[n,N]),W=S.useCallback(ie=>{if(r==="aiContext"){"semanticDomainId"in ie&&m(ie.semanticDomainId);return}q(ie)},[r,q]),O=r==="aiContext"?h:n.semanticDomainId;r==="aiContext"&&{...n},S.useEffect(()=>{if(r==="aiContext"&&!e)return;if(T&&n.mode!=="semanticDomain"&&r==="dataSource"){$("semanticDomain");return}if(!D||F!=="semanticDomain")return;const ie=O,Te=u.domainIds??[],re=r==="aiContext"?d:n.selectedEntities,me=((re==null?void 0:re.length)??0)>0,ve=((d==null?void 0:d.length)??0)>0;Bdt({mode:E,currentDomainId:ie,scopedDomainIds:Te,hasSelectedEntities:me})&&(r==="dataSource"?q({semanticDomainId:void 0,selectedEntities:[]}):m(void 0),ve&&f([]))},[T,D,F,n.mode,O,n.selectedEntities,r,h,d,e,u.domainIds,E,I,q,$]),S.useEffect(()=>{U&&!O&&W({semanticDomainId:U})},[U,O,W]),S.useEffect(()=>{if(!e){C.current=!1,b(""),v(void 0),y(T?"semantic":"all");return}if(C.current)return;f([...s||[]]);const ie=r==="aiContext"?$H(s):void 0;m(n.semanticDomainId||ie),v(SD(s))},[e,r,s,n.semanticDomainId,T]);const Z=ie=>{C.current=!0,f(d.filter(Te=>!Qn(Te,ie)))},Y=S.useCallback((ie,Te)=>{C.current=!0,f(ie),v(Te??SD(ie))},[]),M=()=>{var Te,re;if(r==="aiContext"){if(k&&N(n),i){const me={..._,selectedEntities:d,mode:d.length>0?"fixed":"auto"};j(me)}o==null||o(d),t(!1);return}const ie=SD(d)??w??F;if(ie==="semanticDomain"){const me=$H(d)||h||n.semanticDomainId,ve=((Te=d==null?void 0:d[0])==null?void 0:Te.connectionId)||n.connectionId,J=((re=d==null?void 0:d[0])==null?void 0:re.connectionType)||n.connectionType;N({...n,mode:"semanticDomain",semanticDomainId:me,connectionId:ve,connectionType:J,selectedEntities:d})}else if(ie==="upload"||ie==="url"){const me=d==null?void 0:d[0];N({...n,mode:ie,semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}else{const me=d==null?void 0:d[0];N({...n,mode:"database",semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}t(!1)},{semanticDomains:K}=ude(),{connections:L}=Mc(),z=ie=>{y(ie),ie==="semantic"||ie.startsWith("domain:")?n.mode!=="semanticDomain"&&$("semanticDomain"):(ie==="direct"||ie.startsWith("conn:"))&&n.mode==="semanticDomain"&&$("database")},B=x.startsWith("domain:"),V=x.startsWith("conn:"),P=B?x.slice(7):void 0,H=V?x.slice(5):void 0,G=!R||x==="all"||x==="semantic"||B,X=I&&!T&&(x==="all"||x==="direct"||V),ne=((s==null?void 0:s.length)??0)>0,de=d.length===0&&!ne,he=d.length===0&&ne?"Clear":"Add",pe=r==="aiContext"?"Data context":A?"Select dataset":"Add data",xe=r==="aiContext"?"Set the overall data scope for the dashboard":A?"Choose a curated dataset to analyze":"Search your semantic domains and connections";return l.jsx(_o,{open:e,onOpenChange:t,children:l.jsxs(ao,{showCloseButton:!1,className:"flex h-[560px] w-[620px] max-w-[620px] flex-col gap-0 overflow-hidden rounded-[6px] border border-border bg-popover p-0",children:[l.jsx(p.VisuallyHidden,{children:l.jsx(lo,{children:pe})}),l.jsxs("div",{className:"flex items-start justify-between border-b border-border px-4 py-2.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[14px] font-semibold text-foreground",children:pe}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:xe})]}),l.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3.5 w-3.5"})})]}),l.jsxs("div",{className:"border-b border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[l.jsx($s,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:g,onChange:ie=>b(ie.target.value),placeholder:"Search datasets, tables, views, models",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),g&&l.jsx("button",{type:"button",onClick:()=>b(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3 w-3"})})]}),R&&l.jsx("div",{className:"-mx-4 mt-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:l.jsxs("div",{className:"flex w-max items-center gap-1",children:[l.jsx(Ob,{label:"All",active:x==="all",onClick:()=>z("all")}),(K.length>0||L.length>0)&&l.jsxs(l.Fragment,{children:[l.jsx(Ob,{label:"Semantic",active:x==="semantic",onClick:()=>z("semantic")}),l.jsx(Ob,{label:"Direct",active:x==="direct",onClick:()=>z("direct")}),l.jsx("span",{className:"shrink-0 px-0.5 text-muted-foreground/50",children:"·"})]}),K.map(ie=>l.jsx(Ob,{label:ie.label||ie.name,active:x===`domain:${ie.id}`,onClick:()=>z(`domain:${ie.id}`)},`domain:${ie.id}`)),L.map(ie=>l.jsx(Ob,{label:ie.name,active:x===`conn:${ie.id}`,onClick:()=>z(`conn:${ie.id}`)},`conn:${ie.id}`))]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[G&&l.jsx(Vdt,{domainAccess:u,search:g,scopeDomainId:P,selectedEntities:d,onSelectionChange:ie=>Y(ie,"semanticDomain")}),X&&l.jsx(qdt,{search:g,scopeConnectionId:H,selectedEntities:d,onSelectionChange:ie=>Y(ie)})]}),l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Selected"}),l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["· ",d.length]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex h-7 items-center rounded-control px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Cancel"}),l.jsxs("button",{type:"button",onClick:M,disabled:de,className:p.cn("inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition-colors hover:bg-primary/90",de&&"cursor-not-allowed opacity-50 hover:bg-primary"),children:[l.jsx("span",{children:he}),d.length>0&&l.jsxs("span",{className:"font-mono tabular-nums text-primary-foreground/70",children:["· ",d.length]})]})]})]}),d.length>0&&l.jsx(Xdt,{selectedEntities:d,onDeselectEntity:Z})]})]})})}function Ob({label:e,active:t,onClick:n}){return l.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:p.cn("inline-flex h-6 shrink-0 items-center whitespace-nowrap rounded-control px-2 text-[11px] font-medium transition-colors",t?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}const Up={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]};function BN(e,t={}){const{size:n="h-4 w-4"}=t,r=n;switch(e){case"table":return l.jsx(nP,{className:r});case"view":return l.jsx(E0,{className:r});case"materialized view":return l.jsx(wpe,{className:r});case"model":return l.jsx(T0,{className:r});case"file":return l.jsx(di,{className:r});case"dataset":return l.jsx(zi,{className:r});case"upload":return l.jsx(p.Upload,{className:r});case"url":return l.jsx(XR,{className:r});default:return l.jsx(Ch,{className:r})}}const yx=e=>e.name||e.name,Qdt=e=>{const t=yx(e),n="description"in e?e.description:"",r=e.database||"",s=e.schema||"",o=[e.type,r,s].filter(Boolean);return l.jsxs("div",{className:"max-w-[260px] space-y-1",children:[l.jsx("div",{className:"break-all font-mono text-[11px] font-medium leading-[1.35]",children:t}),n&&l.jsx("div",{className:"text-[11px] leading-[1.45] text-background/70",children:n}),o.length>0&&l.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-background/60",children:o.join(" · ")})]})};function Jdt({entities:e,availableEntities:t,onRemoveEntity:n,onRemoveEntities:r,className:s}){const[o,i]=S.useState(!1),a=e.length>0,c=e.length>=3?e.slice(0,2):e,u=e.length>=3?e.slice(2):[],d=u.length>0;return l.jsx(p.TooltipProvider,{children:l.jsx("div",{className:s,children:a&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.map((f,h)=>{const m="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group relative inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 font-mono text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",children:[l.jsx("span",{className:"grid h-3 w-3 place-items-center text-muted-foreground transition-colors group-hover:text-background/60",children:BN(f.type,{size:"h-3 w-3"})}),l.jsx("span",{className:"max-w-24 truncate",children:yx(f)}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>n(f),"aria-label":`Remove ${yx(f)}`,children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,children:Qdt(f)})]},m)}),d&&l.jsxs(p.Tooltip,{open:o,onOpenChange:i,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",onClick:()=>i(!0),children:[l.jsx(ui,{className:"h-3 w-3"}),l.jsxs("span",{children:[u.length," more"]}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>r(u),"aria-label":"Remove all extra entities",children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,className:"max-h-60 w-[260px] overflow-y-auto p-1.5",children:l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("div",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-background/60",children:"More entities"}),l.jsx("div",{className:"space-y-0.5",children:u.map(f=>{const h="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[3px] px-1 py-1 hover:bg-background/10",children:[l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-background/60",children:BN(f.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11px]",children:yx(f)}),l.jsx("div",{className:"truncate text-[10px] text-background/60",children:[f.type,f.database].filter(Boolean).join(" · ")})]}),l.jsx("button",{type:"button",onClick:()=>{n(f),u.length===1&&i(!1)},className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-background/60 opacity-0 transition-opacity hover:bg-background/10 hover:text-background group-hover:opacity-100","aria-label":`Remove ${yx(f)}`,children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]},h)})})]})})]})]})})})}const B1=e=>e.label||(e==null?void 0:e.name),zH=e=>"description"in e?e.description:`${e.type} from ${e.database||"database"}`;function eft({isOpen:e,onSelect:t,onDeselect:n,onClose:r,availableEntities:s,selectedEntities:o,onTabComplete:i,onSelectAll:a,onRemoveAll:c,onAddContext:u}){const{tokenProps:d}=ht(),f=(d==null?void 0:d.type)==="dashboard",[h,m]=S.useState(""),[g,b]=S.useState(""),x=s.filter(k=>{if(!h)return!0;const _=B1(k).toLowerCase(),j=(zH(k)||"").toLowerCase(),E=h.toLowerCase();return _.includes(E)||j.includes(E)});S.useEffect(()=>{e||(m(""),b(""))},[e]),S.useEffect(()=>{x.length>0&&!g&&b(B1(x[0]))},[x,g]);const y=()=>{if(!g)return;const k=x.find(_=>B1(_)===g);k&&(o.some(j=>"id"in k&&"id"in j?k.id===j.id:k.name===j.name&&k.connectionId===j.connectionId)||t(k),i(k),r())},w=k=>{(k.key==="Tab"||k.key==="Enter")&&(k.preventDefault(),y())};if(!e)return null;const v=k=>o.some(_=>"id"in k&&"id"in _?k.id===_.id:k.name===_.name&&k.connectionId===_.connectionId),C=o.length===s.length,N=o.length>0;return l.jsx(l.Fragment,{children:l.jsxs(cj,{shouldFilter:!1,value:g,onValueChange:b,onKeyDown:w,children:[s.length>0&&l.jsxs("div",{"cmdk-input-wrapper":"",className:"flex h-8 items-center gap-1.5 border-b border-border/60 px-2",children:[l.jsx($s,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(Io.Input,{placeholder:"Search entities",value:h,onValueChange:m,autoFocus:!0,className:"flex h-full min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed disabled:opacity-50"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[3px] border border-border/60 px-1.5 text-[10px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",children:[l.jsx(kr,{className:"h-2.5 w-2.5"}),"Add"]})]}),s.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-2 py-1 text-[10px] text-muted-foreground",children:[l.jsxs("span",{children:[o.length," selected"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),a==null||a()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},disabled:C,className:"hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:"Select all"}),N&&l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),c==null||c()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"hover:text-foreground",children:"Clear"})]})]}),l.jsxs(uj,{className:"max-h-60 min-h-[120px]",children:[l.jsx(dj,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No entities found"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 px-2 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(kr,{className:"h-3 w-3"}),"Add datasets"]})]})}),l.jsx(fj,{className:"p-0.5",children:x.map((k,_)=>{const j=v(k),E="id"in k?k.id:`${k.connectionId}-${k.name}`,I=B1(k);return l.jsxs(hj,{value:I,onSelect:()=>{j?n==null||n(k):t(k)},onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},className:p.cn("flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1.5 data-[selected=true]:bg-muted/60"),children:[l.jsx("span",{className:"grid h-3.5 w-3.5 shrink-0 place-items-center rounded-[3px] border border-border/60 bg-background",children:j&&l.jsx(p.Check,{className:"h-2.5 w-2.5 text-foreground"})}),l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-muted-foreground",children:BN(k.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] font-medium leading-tight text-foreground",children:I}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] leading-tight text-muted-foreground",children:zH(k)})]})]},E)})})]})]})})}function bR({mode:e="full",compact:t=!1,inlineLayout:n=!1,inlineTriggerFirst:r=!1,syncOnOpen:s=!1,open:o,onOpenChange:i,onEntityMention:a,onEntityRemoved:c,onEntitiesRemoved:u,onSelectionChange:d,className:f,triggerClassName:h,triggerVariant:m="secondary",triggerLabel:g="Add entity",triggerIconOnly:b=!0,assistantType:x}){const[y,w]=S.useState(!1),[v,C]=S.useState(!1),N=o??y,k=o!==void 0,_=S.useRef(!1),E=p.useEditorStore(P=>P.card.dataSource)??Up,{selectedEntities:I,availableEntities:T,syncWithGlobalContext:D,setSelectedEntities:R,applyDashboardDefaultEntities:F,isEntitySelected:A}=ej(x),U=e==="full"||e==="display",$=e==="full"||e==="trigger",q=S.useMemo(()=>b&&I.length>0?`Add entity (${I.length})`:g,[I.length,b,g]);S.useEffect(()=>{N&&!_.current&&s&&D(),_.current=N},[N,s,D]);const W=S.useCallback(P=>{k||w(P),i==null||i(P)},[k,i]),O=S.useCallback(P=>{const H=I.filter(G=>!Qn(G,P));R(H),c==null||c(P),d==null||d(H)},[c,d,I,R]),Z=S.useCallback(P=>{if(P.length===0)return;const H=I.filter(G=>!P.some(X=>Qn(G,X)));R(H),u==null||u(P),d==null||d(H)},[u,d,I,R]),Y=S.useCallback(P=>{const H=A(P)?I.filter(G=>!Qn(G,P)):[...I,P];R(H),d==null||d(H)},[A,d,I,R]),M=S.useCallback(()=>{R(T),d==null||d(T)},[T,d,R]),K=S.useCallback(()=>{R([]),d==null||d([])},[d,R]),L=S.useCallback(P=>{x==="dashboard"?F():R(P),d==null||d(P)},[F,x,d,R]),z=S.useCallback(P=>{const H=I.some(G=>Qn(G,P))?I:[...I,P];R(H),a==null||a(P),d==null||d(H),W(!1)},[a,d,I,W,R]),B=U?l.jsx(Jdt,{className:p.cn(n?"contents":"space-y-2"),entities:I,availableEntities:T,onRemoveEntity:O,onRemoveEntities:Z}):null,V=$?l.jsxs(l.Fragment,{children:[l.jsxs(p.Popover,{open:N,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:m,size:"xs",className:p.cn(t&&"h-6 gap-1.5 px-2 text-[11px] font-medium",h),title:g,children:[l.jsx(Uq,{className:"h-3 w-3 text-muted-foreground"}),!b&&l.jsx("span",{children:q})]})}),l.jsx(p.PopoverContent,{className:p.cn("w-80 p-0",t&&"w-72"),align:"start",side:"top",sideOffset:8,onOpenAutoFocus:P=>P.preventDefault(),children:l.jsx(eft,{isOpen:!0,onSelect:Y,onDeselect:Y,onClose:()=>W(!1),availableEntities:T,selectedEntities:I,onTabComplete:z,onSelectAll:M,onRemoveAll:K,onAddContext:()=>{W(!1),C(!0)}})})]}),l.jsx(N3,{incomingSelectedEntities:I,open:v,onOpenChange:C,dataSource:E,dialogMode:"aiContext",onSaveSelectedEntities:L,saveAsDashboardDefault:x==="dashboard"})]}):null;return l.jsx("div",{className:p.cn(n?"flex flex-wrap items-center gap-1":"",!n&&U?"space-y-2":"",f),children:n&&r?l.jsxs(l.Fragment,{children:[V,B]}):l.jsxs(l.Fragment,{children:[B,V]})})}const k3=S.forwardRef(({input:e,setInput:t,handleInputChange:n,handleSubmit:r,isLoading:s,stop:o,onFocus:i,status:a,assistantType:c},u)=>{const[d,f]=S.useState(!1),h=S.useRef(null),{queueMessage:m}=p.useQueueActions(),{addFileAttachment:g,removeFileAttachment:b,clearFileAttachments:x}=p.useFileActions(),y=p.useFileAttachments(c);S.useEffect(()=>{u&&"current"in u&&(u.current=h.current)},[u]);const w=S.useCallback(()=>{const D=h.current;if(D){if(!e||e.length===0){D.style.height="10px";return}D.style.height="auto";const R=Math.min(Math.max(D.scrollHeight,10),200);D.style.height=`${R}px`}},[e]);S.useEffect(()=>{w()},[w]),S.useEffect(()=>{const D=setTimeout(()=>{w()},0);return()=>clearTimeout(D)},[w]);const v=()=>{const D=e.trim();!D&&y.length===0||(a!=="ready"?(m(c,D,y),t(""),x(c)):r({preventDefault:()=>{}}))},C=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),v()),D.key==="@"&&f(!0)},N=S.useCallback(D=>{const R=kdt(D.nativeEvent);R.length>0&&(D.preventDefault(),R.forEach(async F=>{const A=await y3(F);g(c,A)}))},[g,c]),k=S.useCallback(D=>{D.forEach(R=>{g(c,R)})},[g,c]),_=S.useCallback(D=>{D.forEach(R=>{g(c,R)})},[g,c]),j=S.useCallback(D=>{b(c,D)},[b,c]),E=S.useCallback(D=>{const R=`@${D}`;e.includes(R)&&t(e.replace(R,"").replace(/\s{2,}/g," ").trim())},[e,t]),I=!e.trim()&&y.length===0,T=a!=="ready"&&!s;return l.jsxs($dt,{onFilesDropped:k,currentFileCount:y.length,disabled:s,className:"space-y-2",children:[l.jsx(bR,{mode:"display",assistantType:c,onEntityRemoved:D=>{const R="label"in D?D.label:D.name;E(R)},onEntitiesRemoved:D=>{let R=e;D.forEach(F=>{const A="label"in F?F.label:F.name;R=R.replace(`@${A}`,"")}),R!==e&&t(R.replace(/\s{2,}/g," ").trim())}}),y.length>0&&l.jsx(Odt,{files:y,onRemove:j,showRemove:!s}),l.jsxs("div",{className:"rounded-control border border-border bg-background transition-colors focus-within:border-foreground/40",children:[l.jsx("textarea",{ref:h,value:e,onChange:n,onKeyDown:C,onPaste:N,onFocus:()=>{w(),i==null||i()},placeholder:T?"Will be queued":"Ask about this dashboard",className:"block max-h-[200px] min-h-[40px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 pb-1 pt-2 text-[13px] leading-[1.55] text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-0",style:{height:"40px"}}),l.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/60 px-1.5 py-1.5",children:[l.jsx(bR,{mode:"trigger",assistantType:c,syncOnOpen:c==="dashboard",open:d,onOpenChange:f,onEntityMention:D=>{var F;const R="label"in D?D.label:D.name;t(`${e}@${R} `),(F=h.current)==null||F.focus()},triggerVariant:"ghost",triggerIconOnly:!0,triggerClassName:"h-6 w-6 rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",triggerLabel:"Add entity"}),l.jsx(_dt,{onFilesSelected:_,disabled:s,currentFileCount:y.length}),l.jsx("div",{className:"ml-auto"}),s?l.jsx("button",{type:"button",onClick:o,title:"Stop",className:"grid h-7 w-7 place-items-center rounded-control border border-border text-foreground transition-colors hover:bg-muted",children:l.jsx(tP,{className:"h-3 w-3 fill-current"})}):l.jsx("button",{type:"button",disabled:I,onClick:v,title:T?"Message will be queued":"Send",className:T?"grid h-7 w-7 place-items-center rounded-control border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40":"grid h-7 w-7 place-items-center rounded-control bg-foreground text-background transition-colors hover:bg-foreground/85 disabled:cursor-not-allowed disabled:opacity-40",children:l.jsx(wW,{className:"h-3 w-3"})})]})]})]})});k3.displayName="ChatInputWithContext";function mde({assistantType:e,className:t}){const n=p.useMessageQueue(e),{removeFromQueue:r}=p.useQueueActions();return n.length===0?null:l.jsxs("div",{className:p.cn("rounded-control border border-dashed border-border bg-muted/30 p-2",t),children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(ZR,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Queued · ",n.length]})]}),l.jsx("div",{className:"space-y-1",children:n.map(s=>l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[4px] bg-background px-2 py-1 text-[12px] text-foreground/85 animate-in fade-in-0 slide-in-from-bottom-1",children:[l.jsx("span",{className:"flex-1 break-words",children:s.text}),l.jsx("button",{type:"button",onClick:()=>r(e,s.id),title:"Remove from queue",className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100",children:l.jsx(p.X,{className:"h-3 w-3"})})]},s.id))})]})}function pde({assistantType:e,status:t,isLoading:n,sendMessage:r}){const s=p.useMessageQueue(e),{dequeueMessage:o}=p.useQueueActions();S.useEffect(()=>{if(t!=="ready"||n||!(s&&s.length>0))return;const a=o(e);a&&r({role:"user",parts:[{type:"text",text:a.text}]})},[t,n,s,o,r,e])}const BH={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-generateDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Generating dynamic visual..."},"tool-generateDynamicVisualFromData":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-inspectDashboard":{"input-streaming":"Inspecting dashboard...","input-available":"Reading dashboard context..."},"tool-inspectDataContext":{"input-streaming":"Inspecting data context...","input-available":"Reading grounded fields..."},"tool-runDashboardAnalysis":{"input-streaming":"Planning governed analysis...","input-available":"Fetching governed results..."},"tool-runAdvancedAnalysis":{"input-streaming":"Planning advanced analysis...","input-available":"Fetching governed results..."},"tool-renderDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function tft(e,t){var r;if((r=BH[e])!=null&&r[t])return BH[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function gde(e){var n;if(!e||e.length===0)return{hasActiveTools:!1};const t=e[e.length-1];if(!(t!=null&&t.parts))return{hasActiveTools:!1};for(const r of t.parts){if(r.type==="reasoning"&&"state"in r&&r.state==="streaming")return{hasActiveTools:!0,activeToolText:"Reasoning...",toolType:"reasoning"};if(((n=r.type)!=null&&n.startsWith("tool-")||r.type==="dynamic-tool")&&"state"in r&&["input-streaming","input-available"].includes(r.state)){const s=r,o=s.state;return{hasActiveTools:!0,activeToolText:tft(s.type,o),toolType:s.type}}}return{hasActiveTools:!1}}function nft({children:e}){return l.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function rft(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const sft=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,oft=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ift={};function VH(e,t){return(ift.jsx?oft:sft).test(e)}const aft=/[ \t\n\f\r]/g;function lft(e){return typeof e=="object"?e.type==="text"?HH(e.value):!1:HH(e)}function HH(e){return e.replace(aft,"")===""}class Gv{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Gv.prototype.normal={};Gv.prototype.property={};Gv.prototype.space=void 0;function bde(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Gv(n,r,t)}function xR(e){return e.toLowerCase()}class Ko{constructor(t,n){this.attribute=n,this.property=t}}Ko.prototype.attribute="";Ko.prototype.booleanish=!1;Ko.prototype.boolean=!1;Ko.prototype.commaOrSpaceSeparated=!1;Ko.prototype.commaSeparated=!1;Ko.prototype.defined=!1;Ko.prototype.mustUseProperty=!1;Ko.prototype.number=!1;Ko.prototype.overloadedBoolean=!1;Ko.prototype.property="";Ko.prototype.spaceSeparated=!1;Ko.prototype.space=void 0;let cft=0;const on=Uh(),Jr=Uh(),yR=Uh(),ct=Uh(),mr=Uh(),Xm=Uh(),ei=Uh();function Uh(){return 2**++cft}const vR=Object.freeze(Object.defineProperty({__proto__:null,boolean:on,booleanish:Jr,commaOrSpaceSeparated:ei,commaSeparated:Xm,number:ct,overloadedBoolean:yR,spaceSeparated:mr},Symbol.toStringTag,{value:"Module"})),CD=Object.keys(vR);class _3 extends Ko{constructor(t,n,r,s){let o=-1;if(super(t,n),UH(this,"space",s),typeof r=="number")for(;++o<CD.length;){const i=CD[o];UH(this,CD[o],(r&vR[i])===vR[i])}}}_3.prototype.defined=!0;function UH(e,t,n){n&&(e[t]=n)}function Ug(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new _3(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[xR(r)]=r,n[xR(o.attribute)]=r}return new Gv(t,n,e.space)}const xde=Ug({properties:{ariaActiveDescendant:null,ariaAtomic:Jr,ariaAutoComplete:null,ariaBusy:Jr,ariaChecked:Jr,ariaColCount:ct,ariaColIndex:ct,ariaColSpan:ct,ariaControls:mr,ariaCurrent:null,ariaDescribedBy:mr,ariaDetails:null,ariaDisabled:Jr,ariaDropEffect:mr,ariaErrorMessage:null,ariaExpanded:Jr,ariaFlowTo:mr,ariaGrabbed:Jr,ariaHasPopup:null,ariaHidden:Jr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:mr,ariaLevel:ct,ariaLive:null,ariaModal:Jr,ariaMultiLine:Jr,ariaMultiSelectable:Jr,ariaOrientation:null,ariaOwns:mr,ariaPlaceholder:null,ariaPosInSet:ct,ariaPressed:Jr,ariaReadOnly:Jr,ariaRelevant:null,ariaRequired:Jr,ariaRoleDescription:mr,ariaRowCount:ct,ariaRowIndex:ct,ariaRowSpan:ct,ariaSelected:Jr,ariaSetSize:ct,ariaSort:null,ariaValueMax:ct,ariaValueMin:ct,ariaValueNow:ct,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function yde(e,t){return t in e?e[t]:t}function vde(e,t){return yde(e,t.toLowerCase())}const uft=Ug({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Xm,acceptCharset:mr,accessKey:mr,action:null,allow:null,allowFullScreen:on,allowPaymentRequest:on,allowUserMedia:on,alt:null,as:null,async:on,autoCapitalize:null,autoComplete:mr,autoFocus:on,autoPlay:on,blocking:mr,capture:null,charSet:null,checked:on,cite:null,className:mr,cols:ct,colSpan:null,content:null,contentEditable:Jr,controls:on,controlsList:mr,coords:ct|Xm,crossOrigin:null,data:null,dateTime:null,decoding:null,default:on,defer:on,dir:null,dirName:null,disabled:on,download:yR,draggable:Jr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:on,formTarget:null,headers:mr,height:ct,hidden:yR,high:ct,href:null,hrefLang:null,htmlFor:mr,httpEquiv:mr,id:null,imageSizes:null,imageSrcSet:null,inert:on,inputMode:null,integrity:null,is:null,isMap:on,itemId:null,itemProp:mr,itemRef:mr,itemScope:on,itemType:mr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:on,low:ct,manifest:null,max:null,maxLength:ct,media:null,method:null,min:null,minLength:ct,multiple:on,muted:on,name:null,nonce:null,noModule:on,noValidate:on,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:on,optimum:ct,pattern:null,ping:mr,placeholder:null,playsInline:on,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:on,referrerPolicy:null,rel:mr,required:on,reversed:on,rows:ct,rowSpan:ct,sandbox:mr,scope:null,scoped:on,seamless:on,selected:on,shadowRootClonable:on,shadowRootDelegatesFocus:on,shadowRootMode:null,shape:null,size:ct,sizes:null,slot:null,span:ct,spellCheck:Jr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ct,step:null,style:null,tabIndex:ct,target:null,title:null,translate:null,type:null,typeMustMatch:on,useMap:null,value:Jr,width:ct,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:mr,axis:null,background:null,bgColor:null,border:ct,borderColor:null,bottomMargin:ct,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:on,declare:on,event:null,face:null,frame:null,frameBorder:null,hSpace:ct,leftMargin:ct,link:null,longDesc:null,lowSrc:null,marginHeight:ct,marginWidth:ct,noResize:on,noHref:on,noShade:on,noWrap:on,object:null,profile:null,prompt:null,rev:null,rightMargin:ct,rules:null,scheme:null,scrolling:Jr,standby:null,summary:null,text:null,topMargin:ct,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ct,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:on,disableRemotePlayback:on,prefix:null,property:null,results:ct,security:null,unselectable:null},space:"html",transform:vde}),dft=Ug({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ei,accentHeight:ct,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ct,amplitude:ct,arabicForm:null,ascent:ct,attributeName:null,attributeType:null,azimuth:ct,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ct,by:null,calcMode:null,capHeight:ct,className:mr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ct,diffuseConstant:ct,direction:null,display:null,dur:null,divisor:ct,dominantBaseline:null,download:on,dx:null,dy:null,edgeMode:null,editable:null,elevation:ct,enableBackground:null,end:null,event:null,exponent:ct,externalResourcesRequired:null,fill:null,fillOpacity:ct,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Xm,g2:Xm,glyphName:Xm,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ct,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ct,horizOriginX:ct,horizOriginY:ct,id:null,ideographic:ct,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ct,k:ct,k1:ct,k2:ct,k3:ct,k4:ct,kernelMatrix:ei,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ct,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ct,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ct,overlineThickness:ct,paintOrder:null,panose1:null,path:null,pathLength:ct,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:mr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ct,pointsAtY:ct,pointsAtZ:ct,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ei,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ei,rev:ei,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ei,requiredFeatures:ei,requiredFonts:ei,requiredFormats:ei,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ct,specularExponent:ct,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ct,strikethroughThickness:ct,string:null,stroke:null,strokeDashArray:ei,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ct,strokeOpacity:ct,strokeWidth:null,style:null,surfaceScale:ct,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ei,tabIndex:ct,tableValues:null,target:null,targetX:ct,targetY:ct,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ei,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ct,underlineThickness:ct,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ct,values:null,vAlphabetic:ct,vMathematical:ct,vectorEffect:null,vHanging:ct,vIdeographic:ct,version:null,vertAdvY:ct,vertOriginX:ct,vertOriginY:ct,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ct,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yde}),wde=Ug({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Sde=Ug({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vde}),Cde=Ug({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),fft={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},hft=/[A-Z]/g,qH=/-[a-z]/g,mft=/^data[-\w.:]+$/i;function pft(e,t){const n=xR(t);let r=t,s=Ko;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&mft.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(qH,bft);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!qH.test(o)){let i=o.replace(hft,gft);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=_3}return new s(r,t)}function gft(e){return"-"+e.toLowerCase()}function bft(e){return e.charAt(1).toUpperCase()}const xft=bde([xde,uft,wde,Sde,Cde],"html"),j3=bde([xde,dft,wde,Sde,Cde],"svg");function yft(e){return e.join(" ").trim()}var I3={},WH=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,vft=/\n/g,wft=/^\s*/,Sft=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Cft=/^:\s*/,Nft=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,kft=/^[;\s]*/,_ft=/^\s+|\s+$/g,jft=`
1326
+ Defaulting to \`null\`.`}var cde=ode,Fdt=ade;const S3=Q.forwardRef(({className:e,value:t,...n},r)=>l.jsx(cde,{ref:r,className:p.cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:l.jsx(Fdt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));S3.displayName=cde.displayName;function Odt({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const s=o=>Hg.includes(o)?Spe:o.includes("pdf")||o.includes("text")?di:o.includes("javascript")||o.includes("typescript")||o.includes("python")||o.includes("sql")?cW:Npe;return l.jsx("div",{className:`flex flex-wrap gap-1.5 ${r}`,children:e.map(o=>{const i=s(o.type);return l.jsxs("div",{className:"group inline-flex h-7 items-center gap-1.5 rounded-control border border-border/60 bg-background px-1.5 text-[11px]",children:[l.jsx("span",{className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] bg-muted",children:l.jsx(i,{className:"h-2.5 w-2.5 text-muted-foreground"})}),l.jsx("span",{className:"max-w-[140px] truncate text-foreground/85",children:o.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:h0(o.size)}),o.uploadProgress!==void 0&&o.uploadProgress<100&&l.jsx(S3,{value:o.uploadProgress,className:"h-0.5 w-12 shrink-0"}),n&&t&&l.jsx("button",{type:"button",onClick:()=>t(o.id),className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${o.name}`,children:l.jsx(p.X,{className:"h-3 w-3"})})]},o.id)})})}function Ldt({file:e,className:t=""}){return Hg.includes(e.type)&&e.preview?l.jsxs("div",{className:`inline-block ${t}`,children:[l.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-card border border-border"}),l.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",h0(e.size)]})]}):l.jsxs("div",{className:`inline-flex items-center gap-1.5 rounded-control border border-border/60 bg-muted/30 px-2 py-1 ${t}`,children:[l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[12px] text-foreground/85",children:e.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:h0(e.size)})]})}function $dt({children:e,onFilesDropped:t,disabled:n=!1,currentFileCount:r=0,className:s}){const[o,i]=S.useState(!1),a=S.useCallback(f=>{f.preventDefault(),f.stopPropagation(),n||i(!0)},[n]),c=S.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.currentTarget.getBoundingClientRect(),m=f.clientX,g=f.clientY;(m<h.left||m>=h.right||g<h.top||g>=h.bottom)&&i(!1)},[]),u=S.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),d=S.useCallback(async f=>{if(f.preventDefault(),f.stopPropagation(),i(!1),n)return;const h=Array.from(f.dataTransfer.files);if(h.length===0)return;const m=Hl-r;if(h.length>m){et.error(`You can only attach ${Hl} files per message. You have ${m} slot(s) remaining.`);return}const{valid:g,errors:b}=rde(h);if(b.forEach(({file:x,error:y})=>{et.error(`${x.name}: ${y}`)}),g.length>0)try{const x=await Promise.all(g.map(y=>y3(y)));t(x),et.success(`${x.length} file(s) attached successfully`)}catch(x){console.error("Failed to process files:",x),et.error("Failed to process one or more files")}},[n,r,t]);return l.jsxs("div",{className:p.cn("relative",s),onDragEnter:a,onDragLeave:c,onDragOver:u,onDrop:d,children:[e,o&&!n&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-control border-2 border-dashed border-primary bg-primary/5 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(p.Upload,{className:"h-8 w-8 text-primary"}),l.jsx("p",{className:"text-sm font-medium text-primary",children:"Drop files here to upload"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[Hl-r," slot(s) available"]})]})})]})}function zdt(e,t,n){switch(e){case"none":return!1;case"include":return n.includes(t);case"exclude":return!n.includes(t);case"all":default:return!0}}function Bdt({mode:e,currentDomainId:t,scopedDomainIds:n,hasSelectedEntities:r}){return e==="all"?!1:e==="none"?!!t||r:t?!zdt(e,t,n):r}function ude(e){const{tokenProps:t}=ht(),n=p.useDashboardStore(c=>c.authToken)||e;p.useEditorStore(c=>c.selectedConnectionId),p.useEditorStore(c=>{var u,d;return(d=(u=c==null?void 0:c.card)==null?void 0:u.dataSource)==null?void 0:d.connectionId});const{refetch:r,isPending:s,data:o,isLoading:i,isError:a}=Dn({queryKey:["semantic-domains"],queryFn:()=>p.getRequest(`${t.apiServiceUrl}/v1/domains`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)});return{isPending:s,error:a,semanticDomainsData:o,semanticDomains:(o==null?void 0:o.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:a,refetchSemanticDomains:r}}function Vdt({domainAccess:e,search:t,scopeDomainId:n,selectedEntities:r,onSelectionChange:s}){const{semanticDomains:o,isSemanticDomainsLoading:i}=ude(),a=S.useMemo(()=>Udt(o,e),[o,e]),c=S.useMemo(()=>n?a.filter(d=>d.id===n):a,[a,n]);if(i&&c.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading semantic domains…"});if(c.length===0)return null;const u=!!n;return l.jsxs("div",{children:[l.jsx(dde,{label:"Semantic Domains"}),c.map(d=>l.jsx(Hdt,{domain:d,search:t,forceExpanded:u,selectedEntities:r,onSelectionChange:s},d.id))]})}function Hdt({domain:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){const[o,i]=S.useState(!1),a=o||t.length>0||!!n,{datasets:c,isPending:u}=wSe(a?e.id:void 0),d=S.useMemo(()=>{if(!t)return c;const v=t.trim().toLowerCase();return c.filter(C=>`${C.label??""} ${C.name??""} ${C.description??""}`.toLowerCase().includes(v))},[c,t]),f=t.length>0&&d.length>0,h=o||f||!!n,m=c.length,g=S.useMemo(()=>d.filter(v=>r.some(C=>Qn(C,z1(v)))).length,[d,r]),b=S.useMemo(()=>d.map(z1),[d]),x=b.length>0&&b.every(v=>r.some(C=>Qn(C,v))),y=()=>{if(b.length===0)return;if(x){s(r.filter(C=>!b.some(N=>Qn(C,N))));return}const v=[...r];for(const C of b)v.some(N=>Qn(N,C))||v.push(C);s(v)},w=v=>{const C=z1(v),N=r.some(k=>Qn(k,C));s(N?r.filter(k=>!Qn(k,C)):[...r,C])};return t.length>0&&!f&&!u?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center rounded-[4px] px-3 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsxs("button",{type:"button",onClick:()=>i(v=>!v),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l.jsx(Bn,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.label||e.name}),m>0&&l.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",m," dataset",m===1?"":"s"," · curated"]})]}),h&&!u&&b.length>0&&l.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-background hover:text-foreground",children:x?"Clear":"Select all"}),l.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground",children:g>0?g:""})]}),h&&l.jsx("ul",{className:"space-y-px pb-1",children:u&&c.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"Loading datasets…"}):d.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"No datasets in this domain."}):d.map(v=>{const C=z1(v),N=r.some(k=>Qn(k,C));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-[4px] px-9 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(Mn,{checked:N,onCheckedChange:()=>w(v),className:"mt-[3px] h-3.5 w-3.5 shrink-0"}),l.jsx(zi,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground",children:v.label||v.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:v.type==="virtual"?"virtual":"dataset"})]}),v.description&&l.jsx("p",{className:"mt-0.5 text-[11px] leading-[1.4] text-muted-foreground",children:v.description})]})]})},v.id)})})]})}function dde({label:e}){return l.jsx("div",{className:"px-3 pb-1.5 pt-2.5",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})})}function Udt(e,t){if(!t||t.mode==="all")return e;const n=new Set(t.domainIds??[]);return t.mode==="include"?e.filter(r=>n.has(r.id)):t.mode==="exclude"?e.filter(r=>!n.has(r.id)):[]}function z1(e){return{id:e.id,datasetType:e.type,name:e.name||e.table,label:e.label,domainId:e.domainId,description:e.description,database:e.database,schema:e.schema,table:e.table,type:"dataset",connectionId:e.connectionId,connectionType:e.connectionType,dialect:e.dialect,datamodelId:e.datamodelId,sql:e.sql}}function qdt({search:e,scopeConnectionId:t,selectedEntities:n,onSelectionChange:r}){const{connections:s,isConnectionsLoading:o}=Mc(),i=S.useMemo(()=>t?s.filter(c=>c.id===t):s,[s,t]);if(o&&i.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading connections…"});if(i.length===0)return null;const a=!!t;return l.jsxs("div",{children:[l.jsx(dde,{label:"Direct Sources"}),i.map(c=>l.jsx(Wdt,{connection:c,search:e,forceExpanded:a,selectedEntities:n,onSelectionChange:r},c.id))]})}function Wdt({connection:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){var g;const[o,i]=S.useState(!1),a=o||t.length>0||!!n,c=((g=e.capabilities)==null?void 0:g.path)??[],u=c.includes("database"),d=c.includes("schema"),f=e.type==="upload",h=e.type==="url",m=S.useMemo(()=>r.filter(b=>b.connectionId===e.id).length,[r,e.id]);return l.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[l.jsxs("button",{type:"button",onClick:()=>i(b=>!b),className:"flex w-full items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-muted/40",children:[l.jsx(Bn,{className:p.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground/90",children:e.name}),l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["· ",e.type]}),l.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground",children:m>0?m:""})]}),a&&l.jsxs(l.Fragment,{children:[f?l.jsx(Gdt,{connection:e,selectedEntities:r,onSelectionChange:s}):h?l.jsx(Ydt,{connection:e,selectedEntities:r,onSelectionChange:s}):u?l.jsx(Kdt,{connection:e,requiresSchema:d,search:t,selectedEntities:r,onSelectionChange:s}):d?l.jsx(fde,{connection:e,databaseName:"",search:t,selectedEntities:r,onSelectionChange:s}):l.jsx(C3,{connection:e,databaseName:"",schemaName:"",search:t,selectedEntities:r,onSelectionChange:s}),!f&&!h&&l.jsx(Zdt,{connection:e,search:t,selectedEntities:r,onSelectionChange:s})]})]})}function Gdt({connection:e,selectedEntities:t,onSelectionChange:n}){const r=`upload-source-${e.id}`,s=t.filter(a=>a.connectionId===e.id&&(a.type==="upload"||a.type==="file")),o=a=>{if(!(a!=null&&a.length))return;const c=Array.from(a).map(u=>({id:`file-${Date.now()}-${Math.random()}`,name:u.name,type:"upload",connectionId:e.id,connectionType:e.type,label:u.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:u.name,file:u}));n([...t,...c])},i=a=>{n(t.filter(c=>!("id"in c&&c.id===a&&c.connectionId===e.id&&(c.type==="upload"||c.type==="file"))))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"rounded-[6px] border border-dashed border-border bg-muted/20 p-4 text-center",children:[l.jsx(p.Upload,{className:"mx-auto mb-2 h-5 w-5 text-muted-foreground"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Add CSV, JSON, or Excel files."}),l.jsx("input",{id:r,type:"file",multiple:!0,className:"hidden",onChange:a=>o(a.target.files),accept:".csv,.json,.xlsx,.xls"}),l.jsx(p.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 text-[12px]",onClick:()=>{var a;return(a=document.getElementById(r))==null?void 0:a.click()},children:"Select files"})]}),s.length>0&&l.jsx("ul",{className:"space-y-1",children:s.map(a=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(di,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:a.originalName||a.name}),l.jsx("button",{type:"button","aria-label":`Remove ${a.originalName||a.name}`,onClick:()=>i(a.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3 w-3"})})]},a.id))})]})}function Ydt({connection:e,selectedEntities:t,onSelectionChange:n}){const[r,s]=S.useState(""),[o,i]=S.useState(""),[a,c]=S.useState("api"),u=t.filter(h=>h.connectionId===e.id&&h.type==="url"),d=()=>{const h=r.trim(),m=o.trim();if(!h||!m)return;const g={id:`url-${Date.now()}-${Math.random()}`,name:h,type:"url",connectionId:e.id,connectionType:e.type,label:h,description:`URL source of type ${a}`,originalName:h,url:m,sourceType:a};n([...t,g]),s(""),i(""),c("api")},f=h=>{n(t.filter(m=>!("id"in m&&m.id===h&&m.connectionId===e.id&&m.type==="url")))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"space-y-2 rounded-[6px] border border-border bg-muted/20 p-3",children:[l.jsx(p.Input,{value:r,onChange:h=>s(h.target.value),placeholder:"Source name",className:"h-7 text-[12px]"}),l.jsx(p.Input,{value:o,onChange:h=>i(h.target.value),placeholder:"https://api.example.com/data",className:"h-7 text-[12px]"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:a,onChange:h=>c(h.target.value),className:"h-7 flex-1 rounded-control border border-input bg-background px-2 text-[12px]",children:[l.jsx("option",{value:"api",children:"API endpoint"}),l.jsx("option",{value:"csv",children:"CSV file"}),l.jsx("option",{value:"json",children:"JSON file"})]}),l.jsxs(p.Button,{type:"button",size:"sm",className:"h-7 text-[12px]",disabled:!r.trim()||!o.trim(),onClick:d,children:[l.jsx(kr,{className:"mr-1 h-3 w-3"}),"Add"]})]})]}),u.length>0&&l.jsx("ul",{className:"space-y-1",children:u.map(h=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(Ch,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[12px]",children:h.name}),l.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:h.url})]}),l.jsx("button",{type:"button","aria-label":`Remove ${h.name}`,onClick:()=>f(h.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3 w-3"})})]},h.id))})]})}function Kdt({connection:e,requiresSchema:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=Pj("/v1/databases",{connection_id:e.id},["databases",e.id]);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading databases…"});const i=((a=o.data)==null?void 0:a.databases)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No databases."}):l.jsx("div",{children:i.map(c=>l.jsx(hde,{label:c.database_name,indentLevel:1,search:n,renderChildren:u=>u&&(t?l.jsx(fde,{connection:e,databaseName:c.database_name,search:n,selectedEntities:r,onSelectionChange:s}):l.jsx(C3,{connection:e,databaseName:c.database_name,schemaName:"",search:n,selectedEntities:r,onSelectionChange:s}))},c.database_name))})}function fde({connection:e,databaseName:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=Pj("/v1/schemas",{connection_id:e.id,database_name:t||"NA"},["schemas",e.id,t],!!e.id);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading schemas…"});const i=((a=o.data)==null?void 0:a.schemas)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No schemas."}):l.jsx("div",{children:i.map(c=>l.jsx(hde,{label:c.schema_name,indentLevel:t?2:1,search:n,renderChildren:u=>u&&l.jsx(C3,{connection:e,databaseName:t,schemaName:c.schema_name,search:n,selectedEntities:r,onSelectionChange:s})},c.schema_name))})}function C3({connection:e,databaseName:t,schemaName:n,search:r,selectedEntities:s,onSelectionChange:o}){const i=Pj("/v1/tables",{connection_id:e.id,database_name:t||void 0,schema_name:n||void 0},["tables",e.id,t,n]),a=S.useMemo(()=>{var b;const m=((b=i.data)==null?void 0:b.tables)??[];if(!r)return m;const g=r.trim().toLowerCase();return m.filter(x=>x.table_name.toLowerCase().includes(g))},[i.data,r]),c=(m,g)=>({connectionId:e.id,connectionType:e.type,type:"table",dialect:e.dialect,database:t||void 0,schema:n||void 0,name:m,dbObjectType:g==null?void 0:g.toLowerCase()});if(i.isLoading)return l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"Loading tables…"});if(a.length===0)return r?null:l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"No tables."});const u=a.map(m=>c(m.table_name,m.table_type)),d=u.length>0&&u.every(m=>s.some(g=>Qn(g,m))),f=(m,g)=>{const b=c(m,g),x=s.some(y=>Qn(y,b));o(x?s.filter(y=>!Qn(y,b)):[...s,b])},h=()=>{if(u.length===0)return;if(d){o(s.filter(g=>!u.some(b=>Qn(g,b))));return}const m=[...s];for(const g of u)m.some(b=>Qn(b,g))||m.push(g);o(m)};return l.jsxs("ul",{children:[l.jsxs("li",{className:"flex items-center justify-between gap-2 py-1 pl-12 pr-4",children:[l.jsxs("span",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:[a.length," table",a.length===1?"":"s"]}),l.jsx("button",{type:"button",onClick:h,className:"rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:d?"Clear":"Select all"})]}),a.map(m=>{const g=c(m.table_name,m.table_type),b=s.some(x=>Qn(x,g));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Mn,{checked:b,onCheckedChange:()=>f(m.table_name,m.table_type),className:"h-3.5 w-3.5 shrink-0"}),l.jsx(p.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:m.table_name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:m.table_type??"table"})]})]})},m.table_name)})]})}function Zdt({connection:e,search:t,selectedEntities:n,onSelectionChange:r}){const s=Pj("/v1/datamodels",{connection_id:e.id},["datamodels",e.id]),o=S.useMemo(()=>{var u;const a=((u=s.data)==null?void 0:u.datamodels)??[];if(!t)return a;const c=t.trim().toLowerCase();return a.filter(d=>`${d.label??""} ${d.name??""} ${d.description??""}`.toLowerCase().includes(c))},[s.data,t]);if(s.isLoading||o.length===0)return null;const i=a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Qn(d,c));r(u?n.filter(d=>!Qn(d,c)):[...n,c])};return l.jsxs("div",{children:[l.jsx("div",{className:"px-8 pb-1 pt-2",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data models"})}),l.jsx("ul",{children:o.map(a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>Qn(d,c));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(Mn,{checked:u,onCheckedChange:()=>i(a),className:"mt-[2px] h-3.5 w-3.5 shrink-0"}),l.jsx(gpe,{className:"mt-[2px] h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:a.label||a.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:"model"})]}),a.description&&l.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:a.description})]})]})},a.id)})})]})}function hde({label:e,indentLevel:t,search:n,renderChildren:r}){const[s,o]=S.useState(!1),i=s||n.length>0,a=t===1?"pl-8":"pl-10";return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>o(c=>!c),className:p.cn("flex h-6 w-full items-center gap-1.5 pr-4 text-left transition-colors hover:bg-muted/40",a),children:[l.jsx(Bn,{className:p.cn("h-2.5 w-2.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e})]}),r(i)]})}function Pj(e,t,n,r=!0){const{tokenProps:s}=ht(),o=p.useDashboardStore(a=>a.authToken),i=S.useMemo(()=>Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0)),[t]);return Dn({queryKey:n,queryFn:()=>p.getRequest(`${s.apiServiceUrl}${e}`,(o==null?void 0:o.accessToken)||"",i),enabled:r&&!!(o!=null&&o.accessToken)&&Object.values(i).every(a=>a.length>0)})}function LH(e){return e.type==="dataset"&&e.label||e.name}function Xdt({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-input bg-muted/50 py-0.5 pl-1.5 pr-0.5 text-[11px] text-foreground/80",children:[l.jsx("span",{className:"max-w-[180px] truncate",children:LH(n)}),l.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),t(n)},"aria-label":`Remove ${LH(n)}`,className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]},`${n.type}-${n.name}-${r}`))})}function $H(e){const t=new Set;for(const n of e||[])"domainId"in n&&typeof n.domainId=="string"&&t.add(n.domainId);if(t.size===1)return[...t][0]}function SD(e){if(e!=null&&e.length)return e.every(t=>t.type==="dataset")?"semanticDomain":e.every(t=>t.type==="url")?"url":e.every(t=>t.type==="upload"||t.type==="file")?"upload":"database"}function N3({open:e,onOpenChange:t,dataSource:n,dialogMode:r,incomingSelectedEntities:s,onSaveSelectedEntities:o,saveAsDashboardDefault:i=!1}){var se,ge;const{tokenProps:a}=ht(),c=a.config,u=a.semanticDomainAccess||Ehe.DEFAULT_SEMANTIC_DOMAIN_ACCESS,[d,f]=S.useState([]),[h,m]=S.useState(void 0),[g,b]=S.useState(""),[x,y]=S.useState("all"),[w,v]=S.useState(void 0),C=S.useRef(!1),{updateDataSource:N}=p.useEditorActions(),k=p.useDashboardStore(ie=>ie.isVisualEditing),_=p.useDashboardStore(ie=>ie.dashboard.aiContext),{setAiContext:j}=p.useDashboardActions(),E=u.mode,I=(c==null?void 0:c.showDirectSource)!==!1,T=E==="include"||E==="exclude"||!I,D=E!=="all",R=I&&!T,F=T?"semanticDomain":n.mode,A=r==="dataSource"&&!I,U=E==="include"&&(((se=u.domainIds)==null?void 0:se.length)||0)===1?(ge=u.domainIds)==null?void 0:ge[0]:void 0,$=S.useCallback(ie=>{C.current=!0,N({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:ie,selectedEntities:(n==null?void 0:n.selectedEntities)||[],...ie!=="semanticDomain"&&{semanticDomainId:void 0}})},[n,N]),q=S.useCallback(ie=>{N({...n,...ie})},[n,N]),W=S.useCallback(ie=>{if(r==="aiContext"){"semanticDomainId"in ie&&m(ie.semanticDomainId);return}q(ie)},[r,q]),O=r==="aiContext"?h:n.semanticDomainId;r==="aiContext"&&{...n},S.useEffect(()=>{if(r==="aiContext"&&!e)return;if(T&&n.mode!=="semanticDomain"&&r==="dataSource"){$("semanticDomain");return}if(!D||F!=="semanticDomain")return;const ie=O,Te=u.domainIds??[],re=r==="aiContext"?d:n.selectedEntities,me=((re==null?void 0:re.length)??0)>0,ve=((d==null?void 0:d.length)??0)>0;Bdt({mode:E,currentDomainId:ie,scopedDomainIds:Te,hasSelectedEntities:me})&&(r==="dataSource"?q({semanticDomainId:void 0,selectedEntities:[]}):m(void 0),ve&&f([]))},[T,D,F,n.mode,O,n.selectedEntities,r,h,d,e,u.domainIds,E,I,q,$]),S.useEffect(()=>{U&&!O&&W({semanticDomainId:U})},[U,O,W]),S.useEffect(()=>{if(!e){C.current=!1,b(""),v(void 0),y(T?"semantic":"all");return}if(C.current)return;f([...s||[]]);const ie=r==="aiContext"?$H(s):void 0;m(n.semanticDomainId||ie),v(SD(s))},[e,r,s,n.semanticDomainId,T]);const Z=ie=>{C.current=!0,f(d.filter(Te=>!Qn(Te,ie)))},Y=S.useCallback((ie,Te)=>{C.current=!0,f(ie),v(Te??SD(ie))},[]),M=()=>{var Te,re;if(r==="aiContext"){if(k&&N(n),i){const me={..._,selectedEntities:d,mode:d.length>0?"fixed":"auto"};j(me)}o==null||o(d),t(!1);return}const ie=SD(d)??w??F;if(ie==="semanticDomain"){const me=$H(d)||h||n.semanticDomainId,ve=((Te=d==null?void 0:d[0])==null?void 0:Te.connectionId)||n.connectionId,J=((re=d==null?void 0:d[0])==null?void 0:re.connectionType)||n.connectionType;N({...n,mode:"semanticDomain",semanticDomainId:me,connectionId:ve,connectionType:J,selectedEntities:d})}else if(ie==="upload"||ie==="url"){const me=d==null?void 0:d[0];N({...n,mode:ie,semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}else{const me=d==null?void 0:d[0];N({...n,mode:"database",semanticDomainId:void 0,connectionId:(me==null?void 0:me.connectionId)||n.connectionId,connectionType:(me==null?void 0:me.connectionType)||n.connectionType,selectedEntities:d})}t(!1)},{semanticDomains:K}=ude(),{connections:L}=Mc(),z=ie=>{y(ie),ie==="semantic"||ie.startsWith("domain:")?n.mode!=="semanticDomain"&&$("semanticDomain"):(ie==="direct"||ie.startsWith("conn:"))&&n.mode==="semanticDomain"&&$("database")},B=x.startsWith("domain:"),V=x.startsWith("conn:"),P=B?x.slice(7):void 0,H=V?x.slice(5):void 0,G=!R||x==="all"||x==="semantic"||B,X=I&&!T&&(x==="all"||x==="direct"||V),ne=((s==null?void 0:s.length)??0)>0,de=d.length===0&&!ne,he=d.length===0&&ne?"Clear":"Add",pe=r==="aiContext"?"Data context":A?"Select dataset":"Add data",xe=r==="aiContext"?"Set the overall data scope for the dashboard":A?"Choose a curated dataset to analyze":"Search your semantic domains and connections";return l.jsx(_o,{open:e,onOpenChange:t,children:l.jsxs(ao,{showCloseButton:!1,className:"flex h-[560px] w-[620px] max-w-[620px] flex-col gap-0 overflow-hidden rounded-[6px] border border-border bg-popover p-0",children:[l.jsx(p.VisuallyHidden,{children:l.jsx(lo,{children:pe})}),l.jsxs("div",{className:"flex items-start justify-between border-b border-border px-4 py-2.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[14px] font-semibold text-foreground",children:pe}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:xe})]}),l.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3.5 w-3.5"})})]}),l.jsxs("div",{className:"border-b border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[l.jsx($s,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:g,onChange:ie=>b(ie.target.value),placeholder:"Search datasets, tables, views, models",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),g&&l.jsx("button",{type:"button",onClick:()=>b(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(p.X,{className:"h-3 w-3"})})]}),R&&l.jsx("div",{className:"-mx-4 mt-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:l.jsxs("div",{className:"flex w-max items-center gap-1",children:[l.jsx(Ob,{label:"All",active:x==="all",onClick:()=>z("all")}),(K.length>0||L.length>0)&&l.jsxs(l.Fragment,{children:[l.jsx(Ob,{label:"Semantic",active:x==="semantic",onClick:()=>z("semantic")}),l.jsx(Ob,{label:"Direct",active:x==="direct",onClick:()=>z("direct")}),l.jsx("span",{className:"shrink-0 px-0.5 text-muted-foreground/50",children:"·"})]}),K.map(ie=>l.jsx(Ob,{label:ie.label||ie.name,active:x===`domain:${ie.id}`,onClick:()=>z(`domain:${ie.id}`)},`domain:${ie.id}`)),L.map(ie=>l.jsx(Ob,{label:ie.name,active:x===`conn:${ie.id}`,onClick:()=>z(`conn:${ie.id}`)},`conn:${ie.id}`))]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[G&&l.jsx(Vdt,{domainAccess:u,search:g,scopeDomainId:P,selectedEntities:d,onSelectionChange:ie=>Y(ie,"semanticDomain")}),X&&l.jsx(qdt,{search:g,scopeConnectionId:H,selectedEntities:d,onSelectionChange:ie=>Y(ie)})]}),l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Selected"}),l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["· ",d.length]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex h-7 items-center rounded-control px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Cancel"}),l.jsxs("button",{type:"button",onClick:M,disabled:de,className:p.cn("inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition-colors hover:bg-primary/90",de&&"cursor-not-allowed opacity-50 hover:bg-primary"),children:[l.jsx("span",{children:he}),d.length>0&&l.jsxs("span",{className:"font-mono tabular-nums text-primary-foreground/70",children:["· ",d.length]})]})]})]}),d.length>0&&l.jsx(Xdt,{selectedEntities:d,onDeselectEntity:Z})]})]})})}function Ob({label:e,active:t,onClick:n}){return l.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:p.cn("inline-flex h-6 shrink-0 items-center whitespace-nowrap rounded-control px-2 text-[11px] font-medium transition-colors",t?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}const Up={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]};function BN(e,t={}){const{size:n="h-4 w-4"}=t,r=n;switch(e){case"table":return l.jsx(nP,{className:r});case"view":return l.jsx(E0,{className:r});case"materialized view":return l.jsx(wpe,{className:r});case"model":return l.jsx(T0,{className:r});case"file":return l.jsx(di,{className:r});case"dataset":return l.jsx(zi,{className:r});case"upload":return l.jsx(p.Upload,{className:r});case"url":return l.jsx(XR,{className:r});default:return l.jsx(Ch,{className:r})}}const yx=e=>e.name||e.name,Qdt=e=>{const t=yx(e),n="description"in e?e.description:"",r=e.database||"",s=e.schema||"",o=[e.type,r,s].filter(Boolean);return l.jsxs("div",{className:"max-w-[260px] space-y-1",children:[l.jsx("div",{className:"break-all font-mono text-[11px] font-medium leading-[1.35]",children:t}),n&&l.jsx("div",{className:"text-[11px] leading-[1.45] text-background/70",children:n}),o.length>0&&l.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-background/60",children:o.join(" · ")})]})};function Jdt({entities:e,availableEntities:t,onRemoveEntity:n,onRemoveEntities:r,className:s}){const[o,i]=S.useState(!1),a=e.length>0,c=e.length>=3?e.slice(0,2):e,u=e.length>=3?e.slice(2):[],d=u.length>0;return l.jsx(p.TooltipProvider,{children:l.jsx("div",{className:s,children:a&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.map((f,h)=>{const m="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group relative inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 font-mono text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",children:[l.jsx("span",{className:"grid h-3 w-3 place-items-center text-muted-foreground transition-colors group-hover:text-background/60",children:BN(f.type,{size:"h-3 w-3"})}),l.jsx("span",{className:"max-w-24 truncate",children:yx(f)}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>n(f),"aria-label":`Remove ${yx(f)}`,children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,children:Qdt(f)})]},m)}),d&&l.jsxs(p.Tooltip,{open:o,onOpenChange:i,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",onClick:()=>i(!0),children:[l.jsx(ui,{className:"h-3 w-3"}),l.jsxs("span",{children:[u.length," more"]}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>r(u),"aria-label":"Remove all extra entities",children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(p.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,className:"max-h-60 w-[260px] overflow-y-auto p-1.5",children:l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("div",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-background/60",children:"More entities"}),l.jsx("div",{className:"space-y-0.5",children:u.map(f=>{const h="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[3px] px-1 py-1 hover:bg-background/10",children:[l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-background/60",children:BN(f.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11px]",children:yx(f)}),l.jsx("div",{className:"truncate text-[10px] text-background/60",children:[f.type,f.database].filter(Boolean).join(" · ")})]}),l.jsx("button",{type:"button",onClick:()=>{n(f),u.length===1&&i(!1)},className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-background/60 opacity-0 transition-opacity hover:bg-background/10 hover:text-background group-hover:opacity-100","aria-label":`Remove ${yx(f)}`,children:l.jsx(p.X,{className:"h-2.5 w-2.5"})})]},h)})})]})})]})]})})})}const B1=e=>e.label||(e==null?void 0:e.name),zH=e=>"description"in e?e.description:`${e.type} from ${e.database||"database"}`;function eft({isOpen:e,onSelect:t,onDeselect:n,onClose:r,availableEntities:s,selectedEntities:o,onTabComplete:i,onSelectAll:a,onRemoveAll:c,onAddContext:u}){const{tokenProps:d}=ht(),f=(d==null?void 0:d.type)==="dashboard",[h,m]=S.useState(""),[g,b]=S.useState(""),x=s.filter(k=>{if(!h)return!0;const _=B1(k).toLowerCase(),j=(zH(k)||"").toLowerCase(),E=h.toLowerCase();return _.includes(E)||j.includes(E)});S.useEffect(()=>{e||(m(""),b(""))},[e]),S.useEffect(()=>{x.length>0&&!g&&b(B1(x[0]))},[x,g]);const y=()=>{if(!g)return;const k=x.find(_=>B1(_)===g);k&&(o.some(j=>"id"in k&&"id"in j?k.id===j.id:k.name===j.name&&k.connectionId===j.connectionId)||t(k),i(k),r())},w=k=>{(k.key==="Tab"||k.key==="Enter")&&(k.preventDefault(),y())};if(!e)return null;const v=k=>o.some(_=>"id"in k&&"id"in _?k.id===_.id:k.name===_.name&&k.connectionId===_.connectionId),C=o.length===s.length,N=o.length>0;return l.jsx(l.Fragment,{children:l.jsxs(cj,{shouldFilter:!1,value:g,onValueChange:b,onKeyDown:w,children:[s.length>0&&l.jsxs("div",{"cmdk-input-wrapper":"",className:"flex h-8 items-center gap-1.5 border-b border-border/60 px-2",children:[l.jsx($s,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(Io.Input,{placeholder:"Search entities",value:h,onValueChange:m,autoFocus:!0,className:"flex h-full min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed disabled:opacity-50"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[3px] border border-border/60 px-1.5 text-[10px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",children:[l.jsx(kr,{className:"h-2.5 w-2.5"}),"Add"]})]}),s.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-2 py-1 text-[10px] text-muted-foreground",children:[l.jsxs("span",{children:[o.length," selected"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),a==null||a()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},disabled:C,className:"hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:"Select all"}),N&&l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),c==null||c()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"hover:text-foreground",children:"Clear"})]})]}),l.jsxs(uj,{className:"max-h-60 min-h-[120px]",children:[l.jsx(dj,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No entities found"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 px-2 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(kr,{className:"h-3 w-3"}),"Add datasets"]})]})}),l.jsx(fj,{className:"p-0.5",children:x.map((k,_)=>{const j=v(k),E="id"in k?k.id:`${k.connectionId}-${k.name}`,I=B1(k);return l.jsxs(hj,{value:I,onSelect:()=>{j?n==null||n(k):t(k)},onMouseDown:T=>{T.preventDefault(),T.stopPropagation()},className:p.cn("flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1.5 data-[selected=true]:bg-muted/60"),children:[l.jsx("span",{className:"grid h-3.5 w-3.5 shrink-0 place-items-center rounded-[3px] border border-border/60 bg-background",children:j&&l.jsx(p.Check,{className:"h-2.5 w-2.5 text-foreground"})}),l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-muted-foreground",children:BN(k.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] font-medium leading-tight text-foreground",children:I}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] leading-tight text-muted-foreground",children:zH(k)})]})]},E)})})]})]})})}function bR({mode:e="full",compact:t=!1,inlineLayout:n=!1,inlineTriggerFirst:r=!1,syncOnOpen:s=!1,open:o,onOpenChange:i,onEntityMention:a,onEntityRemoved:c,onEntitiesRemoved:u,onSelectionChange:d,className:f,triggerClassName:h,triggerVariant:m="secondary",triggerLabel:g="Add entity",triggerIconOnly:b=!0,assistantType:x}){const[y,w]=S.useState(!1),[v,C]=S.useState(!1),N=o??y,k=o!==void 0,_=S.useRef(!1),E=p.useEditorStore(P=>P.card.dataSource)??Up,{selectedEntities:I,availableEntities:T,syncWithGlobalContext:D,setSelectedEntities:R,applyDashboardDefaultEntities:F,isEntitySelected:A}=ej(x),U=e==="full"||e==="display",$=e==="full"||e==="trigger",q=S.useMemo(()=>b&&I.length>0?`Add entity (${I.length})`:g,[I.length,b,g]);S.useEffect(()=>{N&&!_.current&&s&&D(),_.current=N},[N,s,D]);const W=S.useCallback(P=>{k||w(P),i==null||i(P)},[k,i]),O=S.useCallback(P=>{const H=I.filter(G=>!Qn(G,P));R(H),c==null||c(P),d==null||d(H)},[c,d,I,R]),Z=S.useCallback(P=>{if(P.length===0)return;const H=I.filter(G=>!P.some(X=>Qn(G,X)));R(H),u==null||u(P),d==null||d(H)},[u,d,I,R]),Y=S.useCallback(P=>{const H=A(P)?I.filter(G=>!Qn(G,P)):[...I,P];R(H),d==null||d(H)},[A,d,I,R]),M=S.useCallback(()=>{R(T),d==null||d(T)},[T,d,R]),K=S.useCallback(()=>{R([]),d==null||d([])},[d,R]),L=S.useCallback(P=>{x==="dashboard"?F():R(P),d==null||d(P)},[F,x,d,R]),z=S.useCallback(P=>{const H=I.some(G=>Qn(G,P))?I:[...I,P];R(H),a==null||a(P),d==null||d(H),W(!1)},[a,d,I,W,R]),B=U?l.jsx(Jdt,{className:p.cn(n?"contents":"space-y-2"),entities:I,availableEntities:T,onRemoveEntity:O,onRemoveEntities:Z}):null,V=$?l.jsxs(l.Fragment,{children:[l.jsxs(p.Popover,{open:N,onOpenChange:W,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:m,size:"xs",className:p.cn(t&&"h-6 gap-1.5 px-2 text-[11px] font-medium",h),title:g,children:[l.jsx(Uq,{className:"h-3 w-3 text-muted-foreground"}),!b&&l.jsx("span",{children:q})]})}),l.jsx(p.PopoverContent,{className:p.cn("w-80 p-0",t&&"w-72"),align:"start",side:"top",sideOffset:8,onOpenAutoFocus:P=>P.preventDefault(),children:l.jsx(eft,{isOpen:!0,onSelect:Y,onDeselect:Y,onClose:()=>W(!1),availableEntities:T,selectedEntities:I,onTabComplete:z,onSelectAll:M,onRemoveAll:K,onAddContext:()=>{W(!1),C(!0)}})})]}),l.jsx(N3,{incomingSelectedEntities:I,open:v,onOpenChange:C,dataSource:E,dialogMode:"aiContext",onSaveSelectedEntities:L,saveAsDashboardDefault:x==="dashboard"})]}):null;return l.jsx("div",{className:p.cn(n?"flex flex-wrap items-center gap-1":"",!n&&U?"space-y-2":"",f),children:n&&r?l.jsxs(l.Fragment,{children:[V,B]}):l.jsxs(l.Fragment,{children:[B,V]})})}const k3=S.forwardRef(({input:e,setInput:t,handleInputChange:n,handleSubmit:r,isLoading:s,stop:o,onFocus:i,status:a,assistantType:c},u)=>{const[d,f]=S.useState(!1),h=S.useRef(null),{queueMessage:m}=p.useQueueActions(),{addFileAttachment:g,removeFileAttachment:b,clearFileAttachments:x}=p.useFileActions(),y=p.useFileAttachments(c);S.useEffect(()=>{u&&"current"in u&&(u.current=h.current)},[u]);const w=S.useCallback(()=>{const D=h.current;if(D){if(!e||e.length===0){D.style.height="10px";return}D.style.height="auto";const R=Math.min(Math.max(D.scrollHeight,10),200);D.style.height=`${R}px`}},[e]);S.useEffect(()=>{w()},[w]),S.useEffect(()=>{const D=setTimeout(()=>{w()},0);return()=>clearTimeout(D)},[w]);const v=()=>{const D=e.trim();!D&&y.length===0||(a!=="ready"?(m(c,D,y),t(""),x(c)):r({preventDefault:()=>{}}))},C=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),v()),D.key==="@"&&f(!0)},N=S.useCallback(D=>{const R=kdt(D.nativeEvent);R.length>0&&(D.preventDefault(),R.forEach(async F=>{const A=await y3(F);g(c,A)}))},[g,c]),k=S.useCallback(D=>{D.forEach(R=>{g(c,R)})},[g,c]),_=S.useCallback(D=>{D.forEach(R=>{g(c,R)})},[g,c]),j=S.useCallback(D=>{b(c,D)},[b,c]),E=S.useCallback(D=>{const R=`@${D}`;e.includes(R)&&t(e.replace(R,"").replace(/\s{2,}/g," ").trim())},[e,t]),I=!e.trim()&&y.length===0,T=a!=="ready"&&!s;return l.jsxs($dt,{onFilesDropped:k,currentFileCount:y.length,disabled:s,className:"space-y-2",children:[l.jsx(bR,{mode:"display",assistantType:c,onEntityRemoved:D=>{const R="label"in D?D.label:D.name;E(R)},onEntitiesRemoved:D=>{let R=e;D.forEach(F=>{const A="label"in F?F.label:F.name;R=R.replace(`@${A}`,"")}),R!==e&&t(R.replace(/\s{2,}/g," ").trim())}}),y.length>0&&l.jsx(Odt,{files:y,onRemove:j,showRemove:!s}),l.jsxs("div",{className:"rounded-control border border-border bg-background transition-colors focus-within:border-foreground/40",children:[l.jsx("textarea",{ref:h,value:e,onChange:n,onKeyDown:C,onPaste:N,onFocus:()=>{w(),i==null||i()},placeholder:T?"Will be queued":"Ask about this dashboard",className:"block max-h-[200px] min-h-[40px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 pb-1 pt-2 text-[13px] leading-[1.55] text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-0",style:{height:"40px"}}),l.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/60 px-1.5 py-1.5",children:[l.jsx(bR,{mode:"trigger",assistantType:c,syncOnOpen:c==="dashboard",open:d,onOpenChange:f,onEntityMention:D=>{var F;const R="label"in D?D.label:D.name;t(`${e}@${R} `),(F=h.current)==null||F.focus()},triggerVariant:"ghost",triggerIconOnly:!0,triggerClassName:"h-6 w-6 rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",triggerLabel:"Add entity"}),l.jsx(_dt,{onFilesSelected:_,disabled:s,currentFileCount:y.length}),l.jsx("div",{className:"ml-auto"}),s?l.jsx("button",{type:"button",onClick:o,title:"Stop",className:"grid h-7 w-7 place-items-center rounded-control border border-border text-foreground transition-colors hover:bg-muted",children:l.jsx(tP,{className:"h-3 w-3 fill-current"})}):l.jsx("button",{type:"button",disabled:I,onClick:v,title:T?"Message will be queued":"Send",className:T?"grid h-7 w-7 place-items-center rounded-control border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40":"grid h-7 w-7 place-items-center rounded-control bg-foreground text-background transition-colors hover:bg-foreground/85 disabled:cursor-not-allowed disabled:opacity-40",children:l.jsx(wW,{className:"h-3 w-3"})})]})]})]})});k3.displayName="ChatInputWithContext";function mde({assistantType:e,className:t}){const n=p.useMessageQueue(e),{removeFromQueue:r}=p.useQueueActions();return n.length===0?null:l.jsxs("div",{className:p.cn("rounded-control border border-dashed border-border bg-muted/30 p-2",t),children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(ZR,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Queued · ",n.length]})]}),l.jsx("div",{className:"space-y-1",children:n.map(s=>l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[4px] bg-background px-2 py-1 text-[12px] text-foreground/85 animate-in fade-in-0 slide-in-from-bottom-1",children:[l.jsx("span",{className:"flex-1 break-words",children:s.text}),l.jsx("button",{type:"button",onClick:()=>r(e,s.id),title:"Remove from queue",className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100",children:l.jsx(p.X,{className:"h-3 w-3"})})]},s.id))})]})}function pde({assistantType:e,status:t,isLoading:n,sendMessage:r}){const s=p.useMessageQueue(e),{dequeueMessage:o}=p.useQueueActions();S.useEffect(()=>{if(t!=="ready"||n||!(s&&s.length>0))return;const a=o(e);a&&r({role:"user",parts:[{type:"text",text:a.text}]})},[t,n,s,o,r,e])}const BH={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-generateDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Generating dynamic visual..."},"tool-generateDynamicVisualFromData":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-inspectDashboard":{"input-streaming":"Inspecting dashboard...","input-available":"Reading dashboard context..."},"tool-inspectDataContext":{"input-streaming":"Inspecting data context...","input-available":"Reading grounded fields..."},"tool-runDashboardAnalysis":{"input-streaming":"Planning governed analysis...","input-available":"Fetching governed results..."},"tool-runAdvancedAnalysis":{"input-streaming":"Planning advanced analysis...","input-available":"Fetching governed results..."},"tool-renderDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function tft(e,t){var r;if((r=BH[e])!=null&&r[t])return BH[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function gde(e){var n;if(!e||e.length===0)return{hasActiveTools:!1};const t=e[e.length-1];if(!(t!=null&&t.parts))return{hasActiveTools:!1};for(const r of t.parts){if(r.type==="reasoning"&&"state"in r&&r.state==="streaming")return{hasActiveTools:!0,activeToolText:"Reasoning...",toolType:"reasoning"};if(((n=r.type)!=null&&n.startsWith("tool-")||r.type==="dynamic-tool")&&"state"in r&&["input-streaming","input-available"].includes(r.state)){const s=r,o=s.state;return{hasActiveTools:!0,activeToolText:tft(s.type,o),toolType:s.type}}}return{hasActiveTools:!1}}function nft({children:e}){return l.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function rft(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const sft=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,oft=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ift={};function VH(e,t){return(ift.jsx?oft:sft).test(e)}const aft=/[ \t\n\f\r]/g;function lft(e){return typeof e=="object"?e.type==="text"?HH(e.value):!1:HH(e)}function HH(e){return e.replace(aft,"")===""}class Gv{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Gv.prototype.normal={};Gv.prototype.property={};Gv.prototype.space=void 0;function bde(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Gv(n,r,t)}function xR(e){return e.toLowerCase()}class Ko{constructor(t,n){this.attribute=n,this.property=t}}Ko.prototype.attribute="";Ko.prototype.booleanish=!1;Ko.prototype.boolean=!1;Ko.prototype.commaOrSpaceSeparated=!1;Ko.prototype.commaSeparated=!1;Ko.prototype.defined=!1;Ko.prototype.mustUseProperty=!1;Ko.prototype.number=!1;Ko.prototype.overloadedBoolean=!1;Ko.prototype.property="";Ko.prototype.spaceSeparated=!1;Ko.prototype.space=void 0;let cft=0;const on=Uh(),Jr=Uh(),yR=Uh(),ct=Uh(),mr=Uh(),Xm=Uh(),ei=Uh();function Uh(){return 2**++cft}const vR=Object.freeze(Object.defineProperty({__proto__:null,boolean:on,booleanish:Jr,commaOrSpaceSeparated:ei,commaSeparated:Xm,number:ct,overloadedBoolean:yR,spaceSeparated:mr},Symbol.toStringTag,{value:"Module"})),CD=Object.keys(vR);class _3 extends Ko{constructor(t,n,r,s){let o=-1;if(super(t,n),UH(this,"space",s),typeof r=="number")for(;++o<CD.length;){const i=CD[o];UH(this,CD[o],(r&vR[i])===vR[i])}}}_3.prototype.defined=!0;function UH(e,t,n){n&&(e[t]=n)}function Ug(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new _3(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[xR(r)]=r,n[xR(o.attribute)]=r}return new Gv(t,n,e.space)}const xde=Ug({properties:{ariaActiveDescendant:null,ariaAtomic:Jr,ariaAutoComplete:null,ariaBusy:Jr,ariaChecked:Jr,ariaColCount:ct,ariaColIndex:ct,ariaColSpan:ct,ariaControls:mr,ariaCurrent:null,ariaDescribedBy:mr,ariaDetails:null,ariaDisabled:Jr,ariaDropEffect:mr,ariaErrorMessage:null,ariaExpanded:Jr,ariaFlowTo:mr,ariaGrabbed:Jr,ariaHasPopup:null,ariaHidden:Jr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:mr,ariaLevel:ct,ariaLive:null,ariaModal:Jr,ariaMultiLine:Jr,ariaMultiSelectable:Jr,ariaOrientation:null,ariaOwns:mr,ariaPlaceholder:null,ariaPosInSet:ct,ariaPressed:Jr,ariaReadOnly:Jr,ariaRelevant:null,ariaRequired:Jr,ariaRoleDescription:mr,ariaRowCount:ct,ariaRowIndex:ct,ariaRowSpan:ct,ariaSelected:Jr,ariaSetSize:ct,ariaSort:null,ariaValueMax:ct,ariaValueMin:ct,ariaValueNow:ct,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function yde(e,t){return t in e?e[t]:t}function vde(e,t){return yde(e,t.toLowerCase())}const uft=Ug({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Xm,acceptCharset:mr,accessKey:mr,action:null,allow:null,allowFullScreen:on,allowPaymentRequest:on,allowUserMedia:on,alt:null,as:null,async:on,autoCapitalize:null,autoComplete:mr,autoFocus:on,autoPlay:on,blocking:mr,capture:null,charSet:null,checked:on,cite:null,className:mr,cols:ct,colSpan:null,content:null,contentEditable:Jr,controls:on,controlsList:mr,coords:ct|Xm,crossOrigin:null,data:null,dateTime:null,decoding:null,default:on,defer:on,dir:null,dirName:null,disabled:on,download:yR,draggable:Jr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:on,formTarget:null,headers:mr,height:ct,hidden:yR,high:ct,href:null,hrefLang:null,htmlFor:mr,httpEquiv:mr,id:null,imageSizes:null,imageSrcSet:null,inert:on,inputMode:null,integrity:null,is:null,isMap:on,itemId:null,itemProp:mr,itemRef:mr,itemScope:on,itemType:mr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:on,low:ct,manifest:null,max:null,maxLength:ct,media:null,method:null,min:null,minLength:ct,multiple:on,muted:on,name:null,nonce:null,noModule:on,noValidate:on,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:on,optimum:ct,pattern:null,ping:mr,placeholder:null,playsInline:on,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:on,referrerPolicy:null,rel:mr,required:on,reversed:on,rows:ct,rowSpan:ct,sandbox:mr,scope:null,scoped:on,seamless:on,selected:on,shadowRootClonable:on,shadowRootDelegatesFocus:on,shadowRootMode:null,shape:null,size:ct,sizes:null,slot:null,span:ct,spellCheck:Jr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ct,step:null,style:null,tabIndex:ct,target:null,title:null,translate:null,type:null,typeMustMatch:on,useMap:null,value:Jr,width:ct,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:mr,axis:null,background:null,bgColor:null,border:ct,borderColor:null,bottomMargin:ct,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:on,declare:on,event:null,face:null,frame:null,frameBorder:null,hSpace:ct,leftMargin:ct,link:null,longDesc:null,lowSrc:null,marginHeight:ct,marginWidth:ct,noResize:on,noHref:on,noShade:on,noWrap:on,object:null,profile:null,prompt:null,rev:null,rightMargin:ct,rules:null,scheme:null,scrolling:Jr,standby:null,summary:null,text:null,topMargin:ct,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ct,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:on,disableRemotePlayback:on,prefix:null,property:null,results:ct,security:null,unselectable:null},space:"html",transform:vde}),dft=Ug({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ei,accentHeight:ct,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ct,amplitude:ct,arabicForm:null,ascent:ct,attributeName:null,attributeType:null,azimuth:ct,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ct,by:null,calcMode:null,capHeight:ct,className:mr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ct,diffuseConstant:ct,direction:null,display:null,dur:null,divisor:ct,dominantBaseline:null,download:on,dx:null,dy:null,edgeMode:null,editable:null,elevation:ct,enableBackground:null,end:null,event:null,exponent:ct,externalResourcesRequired:null,fill:null,fillOpacity:ct,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Xm,g2:Xm,glyphName:Xm,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ct,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ct,horizOriginX:ct,horizOriginY:ct,id:null,ideographic:ct,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ct,k:ct,k1:ct,k2:ct,k3:ct,k4:ct,kernelMatrix:ei,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ct,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ct,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ct,overlineThickness:ct,paintOrder:null,panose1:null,path:null,pathLength:ct,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:mr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ct,pointsAtY:ct,pointsAtZ:ct,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ei,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ei,rev:ei,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ei,requiredFeatures:ei,requiredFonts:ei,requiredFormats:ei,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ct,specularExponent:ct,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ct,strikethroughThickness:ct,string:null,stroke:null,strokeDashArray:ei,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ct,strokeOpacity:ct,strokeWidth:null,style:null,surfaceScale:ct,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ei,tabIndex:ct,tableValues:null,target:null,targetX:ct,targetY:ct,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ei,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ct,underlineThickness:ct,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ct,values:null,vAlphabetic:ct,vMathematical:ct,vectorEffect:null,vHanging:ct,vIdeographic:ct,version:null,vertAdvY:ct,vertOriginX:ct,vertOriginY:ct,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ct,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yde}),wde=Ug({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Sde=Ug({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vde}),Cde=Ug({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),fft={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},hft=/[A-Z]/g,qH=/-[a-z]/g,mft=/^data[-\w.:]+$/i;function pft(e,t){const n=xR(t);let r=t,s=Ko;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&mft.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(qH,bft);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!qH.test(o)){let i=o.replace(hft,gft);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=_3}return new s(r,t)}function gft(e){return"-"+e.toLowerCase()}function bft(e){return e.charAt(1).toUpperCase()}const xft=bde([xde,uft,wde,Sde,Cde],"html"),j3=bde([xde,dft,wde,Sde,Cde],"svg");function yft(e){return e.join(" ").trim()}var I3={},WH=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,vft=/\n/g,wft=/^\s*/,Sft=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Cft=/^:\s*/,Nft=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,kft=/^[;\s]*/,_ft=/^\s+|\s+$/g,jft=`
1327
1327
  `,GH="/",YH="*",tf="",Ift="comment",Eft="declaration";function Tft(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var b=g.match(vft);b&&(n+=b.length);var x=g.lastIndexOf(jft);r=~x?g.length-x:r+g.length}function o(){var g={line:n,column:r};return function(b){return b.position=new i(g),u(),b}}function i(g){this.start=g,this.end={line:n,column:r},this.source=t.source}i.prototype.content=e;function a(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var x=b[0];return s(x),e=e.slice(x.length),b}}function u(){c(wft)}function d(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=o();if(!(GH!=e.charAt(0)||YH!=e.charAt(1))){for(var b=2;tf!=e.charAt(b)&&(YH!=e.charAt(b)||GH!=e.charAt(b+1));)++b;if(b+=2,tf===e.charAt(b-1))return a("End of comment missing");var x=e.slice(2,b-2);return r+=2,s(x),e=e.slice(b),r+=2,g({type:Ift,comment:x})}}function h(){var g=o(),b=c(Sft);if(b){if(f(),!c(Cft))return a("property missing ':'");var x=c(Nft),y=g({type:Eft,property:KH(b[0].replace(WH,tf)),value:x?KH(x[0].replace(WH,tf)):tf});return c(kft),y}}function m(){var g=[];d(g);for(var b;b=h();)b!==!1&&(g.push(b),d(g));return g}return u(),m()}function KH(e){return e?e.replace(_ft,tf):tf}var Dft=Tft,Mft=p.commonjsGlobal&&p.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(I3,"__esModule",{value:!0});I3.default=Rft;const Aft=Mft(Dft);function Rft(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Aft.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:i,value:a}=o;s?t(i,a,o):a&&(n=n||{},n[i]=a)}),n}var Fj={};Object.defineProperty(Fj,"__esModule",{value:!0});Fj.camelCase=void 0;var Pft=/^--[a-zA-Z0-9_-]+$/,Fft=/-([a-z])/g,Oft=/^[^-]+$/,Lft=/^-(webkit|moz|ms|o|khtml)-/,$ft=/^-(ms)-/,zft=function(e){return!e||Oft.test(e)||Pft.test(e)},Bft=function(e,t){return t.toUpperCase()},ZH=function(e,t){return"".concat(t,"-")},Vft=function(e,t){return t===void 0&&(t={}),zft(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace($ft,ZH):e=e.replace(Lft,ZH),e.replace(Fft,Bft))};Fj.camelCase=Vft;var Hft=p.commonjsGlobal&&p.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Uft=Hft(I3),qft=Fj;function wR(e,t){var n={};return!e||typeof e!="string"||(0,Uft.default)(e,function(r,s){r&&s&&(n[(0,qft.camelCase)(r,t)]=s)}),n}wR.default=wR;var Wft=wR;const Gft=p.getDefaultExportFromCjs(Wft),Nde=kde("end"),E3=kde("start");function kde(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Yft(e){const t=E3(e),n=Nde(e);if(t&&n)return{start:t,end:n}}function Qx(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?XH(e.position):"start"in e||"end"in e?XH(e):"line"in e||"column"in e?SR(e):""}function SR(e){return QH(e&&e.line)+":"+QH(e&&e.column)}function XH(e){return SR(e&&e.start)+"-"+SR(e&&e.end)}function QH(e){return e&&typeof e=="number"?e:1}class co extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},i=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(i=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=Qx(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}co.prototype.file="";co.prototype.name="";co.prototype.reason="";co.prototype.message="";co.prototype.stack="";co.prototype.column=void 0;co.prototype.line=void 0;co.prototype.ancestors=void 0;co.prototype.cause=void 0;co.prototype.fatal=void 0;co.prototype.place=void 0;co.prototype.ruleId=void 0;co.prototype.source=void 0;const T3={}.hasOwnProperty,Kft=new Map,Zft=/[A-Z]/g,Xft=new Set(["table","tbody","thead","tfoot","tr"]),Qft=new Set(["td","th"]),_de="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Jft(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=aht(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=iht(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?j3:xft,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=jde(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function jde(e,t,n){if(t.type==="element")return eht(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return tht(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return rht(e,t,n);if(t.type==="mdxjsEsm")return nht(e,t);if(t.type==="root")return sht(e,t,n);if(t.type==="text")return oht(e,t)}function eht(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=j3,e.schema=s),e.ancestors.push(t);const o=Ede(e,t.tagName,!1),i=lht(e,t);let a=M3(e,t);return Xft.has(t.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!lft(c):!0})),Ide(e,i,o,t),D3(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function tht(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}m0(e,t.position)}function nht(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);m0(e,t.position)}function rht(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=j3,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:Ede(e,t.name,!0),i=cht(e,t),a=M3(e,t);return Ide(e,i,o,t),D3(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function sht(e,t,n){const r={};return D3(r,M3(e,t)),e.create(t,e.Fragment,r,n)}function oht(e,t){return t.value}function Ide(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function D3(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function iht(e,t,n){return r;function r(s,o,i,a){const u=Array.isArray(i.children)?n:t;return a?u(o,i,a):u(o,i)}}function aht(e,t){return n;function n(r,s,o,i){const a=Array.isArray(o.children),c=E3(r);return t(s,o,i,a,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function lht(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&T3.call(t.properties,s)){const o=uht(e,s,t.properties[s]);if(o){const[i,a]=o;e.tableCellAlignToStyle&&i==="align"&&typeof a=="string"&&Qft.has(t.tagName)?r=a:n[i]=a}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function cht(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const i=o.expression;i.type;const a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else m0(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else m0(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function M3(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:Kft;for(;++r<t.children.length;){const o=t.children[r];let i;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=s.get(c)||0;i=c+"-"+u,s.set(c,u+1)}}const a=jde(e,o,i);a!==void 0&&n.push(a)}return n}function uht(e,t,n){const r=pft(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?rft(n):yft(n)),r.property==="style"){let s=typeof n=="object"?n:dht(e,String(n));return e.stylePropertyNameCase==="css"&&(s=fht(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?fft[r.property]||r.property:r.attribute,n]}}function dht(e,t){try{return Gft(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new co("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=_de+"#cannot-parse-style-attribute",s}}function Ede(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,i;for(;++o<s.length;){const a=VH(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};i=i?{type:"MemberExpression",object:i,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=i}else r=VH(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return T3.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);m0(e)}function m0(e,t){const n=new co("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=_de+"#cannot-handle-mdx-estrees-without-createevaluater",n}function fht(e){const t={};let n;for(n in e)T3.call(e,n)&&(t[hht(n)]=e[n]);return t}function hht(e){let t=e.replace(Zft,mht);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function mht(e){return"-"+e.toLowerCase()}const ND={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},pht={};function A3(e,t){const n=pht,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Tde(e,r,s)}function Tde(e,t,n){if(ght(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return JH(e.children,t,n)}return Array.isArray(e)?JH(e,t,n):""}function JH(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=Tde(e[s],t,n);return r.join("")}function ght(e){return!!(e&&typeof e=="object")}const eU=document.createElement("i");function R3(e){const t="&"+e+";";eU.innerHTML=t;const n=eU.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ci(e,t,n,r){const s=e.length;let o=0,i;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)i=r.slice(o,o+1e4),i.unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function Ri(e,t){return e.length>0?(ci(e,e.length,0,t),e):t}const tU={}.hasOwnProperty;function Dde(e){const t={};let n=-1;for(;++n<e.length;)bht(t,e[n]);return t}function bht(e,t){let n;for(n in t){const s=(tU.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let i;if(o)for(i in o){tU.call(s,i)||(s[i]=[]);const a=o[i];xht(s[i],Array.isArray(a)?a:a?[a]:[])}}}function xht(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ci(e,0,0,r)}function Mde(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function va(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const wo=wd(/[A-Za-z]/),ro=wd(/[\dA-Za-z]/),yht=wd(/[#-'*+\--9=?A-Z^-~]/);function VN(e){return e!==null&&(e<32||e===127)}const CR=wd(/\d/),vht=wd(/[\dA-Fa-f]/),wht=wd(/[!-/:-@[-`{-~]/);function $t(e){return e!==null&&e<-2}function cr(e){return e!==null&&(e<0||e===32)}function wn(e){return e===-2||e===-1||e===32}const Oj=wd(new RegExp("\\p{P}|\\p{S}","u")),xh=wd(/\s/);function wd(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function qg(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let i="";if(o===37&&ro(e.charCodeAt(n+1))&&ro(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(i=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(i=String.fromCharCode(o,a),s=1):i="�"}else i=String.fromCharCode(o);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+s+1,i=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function En(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return i;function i(c){return wn(c)?(e.enter(n),a(c)):t(c)}function a(c){return wn(c)&&o++<s?(e.consume(c),a):(e.exit(n),t(c))}}const Sht={tokenize:Cht};function Cht(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),En(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),o(a)}function o(a){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,i(a)}function i(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return $t(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),i)}}const Nht={tokenize:kht},nU={tokenize:_ht};function kht(e){const t=this,n=[];let r=0,s,o,i;return a;function a(v){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,c,u)(v)}return u(v)}function c(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&w();const C=t.events.length;let N=C,k;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){k=t.events[N][1].end;break}y(r);let _=C;for(;_<t.events.length;)t.events[_][1].end={...k},_++;return ci(t.events,N+1,0,t.events.slice(C)),t.events.length=_,u(v)}return a(v)}function u(v){if(r===n.length){if(!s)return h(v);if(s.currentConstruct&&s.currentConstruct.concrete)return g(v);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(nU,d,f)(v)}function d(v){return s&&w(),y(r),h(v)}function f(v){return t.parser.lazy[t.now().line]=r!==n.length,i=t.now().offset,g(v)}function h(v){return t.containerState={},e.attempt(nU,m,g)(v)}function m(v){return r++,n.push([t.currentConstruct,t.containerState]),h(v)}function g(v){if(v===null){s&&w(),y(0),e.consume(v);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),b(v)}function b(v){if(v===null){x(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return $t(v)?(e.consume(v),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(v),b)}function x(v,C){const N=t.sliceStream(v);if(C&&N.push(null),v.previous=o,o&&(o.next=v),o=v,s.defineSkip(v.start),s.write(N),t.parser.lazy[v.start.line]){let k=s.events.length;for(;k--;)if(s.events[k][1].start.offset<i&&(!s.events[k][1].end||s.events[k][1].end.offset>i))return;const _=t.events.length;let j=_,E,I;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if(E){I=t.events[j][1].end;break}E=!0}for(y(r),k=_;k<t.events.length;)t.events[k][1].end={...I},k++;ci(t.events,j+1,0,t.events.slice(_)),t.events.length=k}}function y(v){let C=n.length;for(;C-- >v;){const N=n[C];t.containerState=N[1],N[0].exit.call(t,e)}n.length=v}function w(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function _ht(e,t,n){return En(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function qp(e){if(e===null||cr(e)||xh(e))return 1;if(Oj(e))return 2}function Lj(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const NR={name:"attention",resolveAll:jht,tokenize:Iht};function jht(e,t){let n=-1,r,s,o,i,a,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};rU(f,-c),rU(h,c),i={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...i.start},end:{...a.end}},e[r][1].end={...i.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ri(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ri(u,[["enter",s,t],["enter",i,t],["exit",i,t],["enter",o,t]]),u=Ri(u,Lj(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ri(u,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Ri(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,ci(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Iht(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=qp(r);let o;return i;function i(c){return o=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===o)return e.consume(c),a;const u=e.exit("attentionSequence"),d=qp(c),f=!d||d===2&&s||n.includes(c),h=!s||s===2&&d||n.includes(r);return u._open=!!(o===42?f:f&&(s||!h)),u._close=!!(o===42?h:h&&(d||!f)),t(c)}}function rU(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Eht={name:"autolink",tokenize:Tht};function Tht(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(m){return wo(m)?(e.consume(m),i):m===64?n(m):u(m)}function i(m){return m===43||m===45||m===46||ro(m)?(r=1,a(m)):u(m)}function a(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||ro(m))&&r++<32?(e.consume(m),a):(r=0,u(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||VN(m)?n(m):(e.consume(m),c)}function u(m){return m===64?(e.consume(m),d):yht(m)?(e.consume(m),u):n(m)}function d(m){return ro(m)?f(m):n(m)}function f(m){return m===46?(e.consume(m),r=0,d):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):h(m)}function h(m){if((m===45||ro(m))&&r++<63){const g=m===45?h:f;return e.consume(m),g}return n(m)}}const Yv={partial:!0,tokenize:Dht};function Dht(e,t,n){return r;function r(o){return wn(o)?En(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||$t(o)?t(o):n(o)}}const Ade={continuation:{tokenize:Aht},exit:Rht,name:"blockQuote",tokenize:Mht};function Mht(e,t,n){const r=this;return s;function s(i){if(i===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),o}return n(i)}function o(i){return wn(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}function Aht(e,t,n){const r=this;return s;function s(i){return wn(i)?En(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):o(i)}function o(i){return e.attempt(Ade,t,n)(i)}}function Rht(e){e.exit("blockQuote")}const Rde={name:"characterEscape",tokenize:Pht};function Pht(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return wht(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Pde={name:"characterReference",tokenize:Fht};function Fht(e,t,n){const r=this;let s=0,o,i;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,i=ro,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=vht,d):(e.enter("characterReferenceValue"),o=7,i=CR,d(f))}function d(f){if(f===59&&s){const h=e.exit("characterReferenceValue");return i===ro&&!R3(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return i(f)&&s++<o?(e.consume(f),d):n(f)}}const sU={partial:!0,tokenize:Lht},oU={concrete:!0,name:"codeFenced",tokenize:Oht};function Oht(e,t,n){const r=this,s={partial:!0,tokenize:N};let o=0,i=0,a;return c;function c(k){return u(k)}function u(k){const _=r.events[r.events.length-1];return o=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(k)}function d(k){return k===a?(i++,e.consume(k),d):i<3?n(k):(e.exit("codeFencedFenceSequence"),wn(k)?En(e,f,"whitespace")(k):f(k))}function f(k){return k===null||$t(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(sU,b,C)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||$t(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(k)):wn(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),En(e,m,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),h)}function m(k){return k===null||$t(k)?f(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||$t(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(k)):k===96&&k===a?n(k):(e.consume(k),g)}function b(k){return e.attempt(s,C,x)(k)}function x(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),y}function y(k){return o>0&&wn(k)?En(e,w,"linePrefix",o+1)(k):w(k)}function w(k){return k===null||$t(k)?e.check(sU,b,C)(k):(e.enter("codeFlowValue"),v(k))}function v(k){return k===null||$t(k)?(e.exit("codeFlowValue"),w(k)):(e.consume(k),v)}function C(k){return e.exit("codeFenced"),t(k)}function N(k,_,j){let E=0;return I;function I(A){return k.enter("lineEnding"),k.consume(A),k.exit("lineEnding"),T}function T(A){return k.enter("codeFencedFence"),wn(A)?En(k,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):D(A)}function D(A){return A===a?(k.enter("codeFencedFenceSequence"),R(A)):j(A)}function R(A){return A===a?(E++,k.consume(A),R):E>=i?(k.exit("codeFencedFenceSequence"),wn(A)?En(k,F,"whitespace")(A):F(A)):j(A)}function F(A){return A===null||$t(A)?(k.exit("codeFencedFence"),_(A)):j(A)}}}function Lht(e,t,n){const r=this;return s;function s(i){return i===null?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}const kD={name:"codeIndented",tokenize:zht},$ht={partial:!0,tokenize:Bht};function zht(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),En(e,o,"linePrefix",5)(u)}function o(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(u):n(u)}function i(u){return u===null?c(u):$t(u)?e.attempt($ht,i,c)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||$t(u)?(e.exit("codeFlowValue"),i(u)):(e.consume(u),a)}function c(u){return e.exit("codeIndented"),t(u)}}function Bht(e,t,n){const r=this;return s;function s(i){return r.parser.lazy[r.now().line]?n(i):$t(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):En(e,o,"linePrefix",5)(i)}function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):$t(i)?s(i):n(i)}}const Vht={name:"codeText",previous:Uht,resolve:Hht,tokenize:qht};function Hht(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function Uht(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function qht(e,t,n){let r=0,s,o;return i;function i(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),s=0,d(f)):$t(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||$t(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class Wht{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Lb(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Lb(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Lb(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Lb(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Lb(this.left,n.reverse())}}}function Lb(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Fde(e){const t={};let n=-1,r,s,o,i,a,c,u;const d=new Wht(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Ght(d,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(i=d.get(o),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(s&&(d.get(s)[1].type="lineEndingBlank"),i[1].type="lineEnding",s=o);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;s&&(r[1].end={...d.get(s)[1].start},a=d.slice(s,n),a.unshift(r),d.splice(s,n-s+1,a))}}return ci(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Ght(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const a=i.events,c=[],u={};let d,f,h=-1,m=n,g=0,b=0;const x=[b];for(;m;){for(;e.get(++s)[1]!==m;);o.push(s),m._tokenizer||(d=r.sliceStream(m),m.next||d.push(null),f&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),f=m,m=m.next}for(m=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(b=h+1,x.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):x.pop(),h=x.length;h--;){const y=a.slice(x[h],x[h+1]),w=o.pop();c.push([w,w+y.length-1]),e.splice(w,2,y)}for(c.reverse(),h=-1;++h<c.length;)u[g+c[h][0]]=g+c[h][1],g+=c[h][1]-c[h][0]-1;return u}const Yht={resolve:Zht,tokenize:Xht},Kht={partial:!0,tokenize:Qht};function Zht(e){return Fde(e),e}function Xht(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?o(a):$t(a)?e.check(Kht,i,o)(a):(e.consume(a),s)}function o(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function i(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function Qht(e,t,n){const r=this;return s;function s(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),En(e,o,"linePrefix")}function o(i){if(i===null||$t(i))return n(i);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Ode(e,t,n,r,s,o,i,a,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(y),e.exit(o),h):y===null||y===32||y===41||VN(y)?n(y):(e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),b(y))}function h(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||$t(y)?n(y):(e.consume(y),y===92?g:m)}function g(y){return y===60||y===62||y===92?(e.consume(y),m):m(y)}function b(y){return!d&&(y===null||y===41||cr(y))?(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(y)):d<u&&y===40?(e.consume(y),d++,b):y===41?(e.consume(y),d--,b):y===null||y===32||y===40||VN(y)?n(y):(e.consume(y),y===92?x:b)}function x(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function Lde(e,t,n,r,s,o){const i=this;let a=0,c;return u;function u(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(o),d}function d(m){return a>999||m===null||m===91||m===93&&!c||m===94&&!a&&"_hiddenFootnoteSupport"in i.parser.constructs?n(m):m===93?(e.exit(o),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):$t(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===null||m===91||m===93||$t(m)||a++>999?(e.exit("chunkString"),d(m)):(e.consume(m),c||(c=!wn(m)),m===92?h:f)}function h(m){return m===91||m===92||m===93?(e.consume(m),a++,f):f(m)}}function $de(e,t,n,r,s,o){let i;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),i=h===40?41:h,c):n(h)}function c(h){return h===i?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(o),u(h))}function u(h){return h===i?(e.exit(o),c(i)):h===null?n(h):$t(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),En(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===i||h===null||$t(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===i||h===92?(e.consume(h),d):d(h)}}function Jx(e,t){let n;return r;function r(s){return $t(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):wn(s)?En(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const Jht={name:"definition",tokenize:tmt},emt={partial:!0,tokenize:nmt};function tmt(e,t,n){const r=this;let s;return o;function o(m){return e.enter("definition"),i(m)}function i(m){return Lde.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function a(m){return s=va(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return cr(m)?Jx(e,u)(m):u(m)}function u(m){return Ode(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return e.attempt(emt,f,f)(m)}function f(m){return wn(m)?En(e,h,"whitespace")(m):h(m)}function h(m){return m===null||$t(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function nmt(e,t,n){return r;function r(a){return cr(a)?Jx(e,s)(a):n(a)}function s(a){return $de(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return wn(a)?En(e,i,"whitespace")(a):i(a)}function i(a){return a===null||$t(a)?t(a):n(a)}}const rmt={name:"hardBreakEscape",tokenize:smt};function smt(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return $t(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const omt={name:"headingAtx",resolve:imt,tokenize:amt};function imt(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ci(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function amt(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&r++<6?(e.consume(d),i):d===null||cr(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||$t(d)?(e.exit("atxHeading"),t(d)):wn(d)?En(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||cr(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const lmt=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],iU=["pre","script","style","textarea"],cmt={concrete:!0,name:"htmlFlow",resolveTo:fmt,tokenize:hmt},umt={partial:!0,tokenize:pmt},dmt={partial:!0,tokenize:mmt};function fmt(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function hmt(e,t,n){const r=this;let s,o,i,a,c;return u;function u(M){return d(M)}function d(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),f}function f(M){return M===33?(e.consume(M),h):M===47?(e.consume(M),o=!0,b):M===63?(e.consume(M),s=3,r.interrupt?t:O):wo(M)?(e.consume(M),i=String.fromCharCode(M),x):n(M)}function h(M){return M===45?(e.consume(M),s=2,m):M===91?(e.consume(M),s=5,a=0,g):wo(M)?(e.consume(M),s=4,r.interrupt?t:O):n(M)}function m(M){return M===45?(e.consume(M),r.interrupt?t:O):n(M)}function g(M){const K="CDATA[";return M===K.charCodeAt(a++)?(e.consume(M),a===K.length?r.interrupt?t:D:g):n(M)}function b(M){return wo(M)?(e.consume(M),i=String.fromCharCode(M),x):n(M)}function x(M){if(M===null||M===47||M===62||cr(M)){const K=M===47,L=i.toLowerCase();return!K&&!o&&iU.includes(L)?(s=1,r.interrupt?t(M):D(M)):lmt.includes(i.toLowerCase())?(s=6,K?(e.consume(M),y):r.interrupt?t(M):D(M)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):o?w(M):v(M))}return M===45||ro(M)?(e.consume(M),i+=String.fromCharCode(M),x):n(M)}function y(M){return M===62?(e.consume(M),r.interrupt?t:D):n(M)}function w(M){return wn(M)?(e.consume(M),w):I(M)}function v(M){return M===47?(e.consume(M),I):M===58||M===95||wo(M)?(e.consume(M),C):wn(M)?(e.consume(M),v):I(M)}function C(M){return M===45||M===46||M===58||M===95||ro(M)?(e.consume(M),C):N(M)}function N(M){return M===61?(e.consume(M),k):wn(M)?(e.consume(M),N):v(M)}function k(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),c=M,_):wn(M)?(e.consume(M),k):j(M)}function _(M){return M===c?(e.consume(M),c=null,E):M===null||$t(M)?n(M):(e.consume(M),_)}function j(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||cr(M)?N(M):(e.consume(M),j)}function E(M){return M===47||M===62||wn(M)?v(M):n(M)}function I(M){return M===62?(e.consume(M),T):n(M)}function T(M){return M===null||$t(M)?D(M):wn(M)?(e.consume(M),T):n(M)}function D(M){return M===45&&s===2?(e.consume(M),U):M===60&&s===1?(e.consume(M),$):M===62&&s===4?(e.consume(M),Z):M===63&&s===3?(e.consume(M),O):M===93&&s===5?(e.consume(M),W):$t(M)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(umt,Y,R)(M)):M===null||$t(M)?(e.exit("htmlFlowData"),R(M)):(e.consume(M),D)}function R(M){return e.check(dmt,F,Y)(M)}function F(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),A}function A(M){return M===null||$t(M)?R(M):(e.enter("htmlFlowData"),D(M))}function U(M){return M===45?(e.consume(M),O):D(M)}function $(M){return M===47?(e.consume(M),i="",q):D(M)}function q(M){if(M===62){const K=i.toLowerCase();return iU.includes(K)?(e.consume(M),Z):D(M)}return wo(M)&&i.length<8?(e.consume(M),i+=String.fromCharCode(M),q):D(M)}function W(M){return M===93?(e.consume(M),O):D(M)}function O(M){return M===62?(e.consume(M),Z):M===45&&s===2?(e.consume(M),O):D(M)}function Z(M){return M===null||$t(M)?(e.exit("htmlFlowData"),Y(M)):(e.consume(M),Z)}function Y(M){return e.exit("htmlFlow"),t(M)}}function mmt(e,t,n){const r=this;return s;function s(i){return $t(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o):n(i)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}function pmt(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Yv,t,n)}}const gmt={name:"htmlText",tokenize:bmt};function bmt(e,t,n){const r=this;let s,o,i;return a;function a(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),c}function c(O){return O===33?(e.consume(O),u):O===47?(e.consume(O),N):O===63?(e.consume(O),v):wo(O)?(e.consume(O),j):n(O)}function u(O){return O===45?(e.consume(O),d):O===91?(e.consume(O),o=0,g):wo(O)?(e.consume(O),w):n(O)}function d(O){return O===45?(e.consume(O),m):n(O)}function f(O){return O===null?n(O):O===45?(e.consume(O),h):$t(O)?(i=f,$(O)):(e.consume(O),f)}function h(O){return O===45?(e.consume(O),m):f(O)}function m(O){return O===62?U(O):O===45?h(O):f(O)}function g(O){const Z="CDATA[";return O===Z.charCodeAt(o++)?(e.consume(O),o===Z.length?b:g):n(O)}function b(O){return O===null?n(O):O===93?(e.consume(O),x):$t(O)?(i=b,$(O)):(e.consume(O),b)}function x(O){return O===93?(e.consume(O),y):b(O)}function y(O){return O===62?U(O):O===93?(e.consume(O),y):b(O)}function w(O){return O===null||O===62?U(O):$t(O)?(i=w,$(O)):(e.consume(O),w)}function v(O){return O===null?n(O):O===63?(e.consume(O),C):$t(O)?(i=v,$(O)):(e.consume(O),v)}function C(O){return O===62?U(O):v(O)}function N(O){return wo(O)?(e.consume(O),k):n(O)}function k(O){return O===45||ro(O)?(e.consume(O),k):_(O)}function _(O){return $t(O)?(i=_,$(O)):wn(O)?(e.consume(O),_):U(O)}function j(O){return O===45||ro(O)?(e.consume(O),j):O===47||O===62||cr(O)?E(O):n(O)}function E(O){return O===47?(e.consume(O),U):O===58||O===95||wo(O)?(e.consume(O),I):$t(O)?(i=E,$(O)):wn(O)?(e.consume(O),E):U(O)}function I(O){return O===45||O===46||O===58||O===95||ro(O)?(e.consume(O),I):T(O)}function T(O){return O===61?(e.consume(O),D):$t(O)?(i=T,$(O)):wn(O)?(e.consume(O),T):E(O)}function D(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),s=O,R):$t(O)?(i=D,$(O)):wn(O)?(e.consume(O),D):(e.consume(O),F)}function R(O){return O===s?(e.consume(O),s=void 0,A):O===null?n(O):$t(O)?(i=R,$(O)):(e.consume(O),R)}function F(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||cr(O)?E(O):(e.consume(O),F)}function A(O){return O===47||O===62||cr(O)?E(O):n(O)}function U(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function $(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),q}function q(O){return wn(O)?En(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):W(O)}function W(O){return e.enter("htmlTextData"),i(O)}}const P3={name:"labelEnd",resolveAll:wmt,resolveTo:Smt,tokenize:Cmt},xmt={tokenize:Nmt},ymt={tokenize:kmt},vmt={tokenize:_mt};function wmt(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&ci(e,0,e.length,n),e}function Smt(e,t){let n=e.length,r=0,s,o,i,a;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(i){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(i=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[i-2][1].start}};return a=[["enter",c,t],["enter",u,t]],a=Ri(a,e.slice(o+1,o+r+3)),a=Ri(a,[["enter",d,t]]),a=Ri(a,Lj(t.parser.constructs.insideSpan.null,e.slice(o+r+4,i-3),t)),a=Ri(a,[["exit",d,t],e[i-2],e[i-1],["exit",u,t]]),a=Ri(a,e.slice(i+1)),a=Ri(a,[["exit",c,t]]),ci(e,o,e.length,a),e}function Cmt(e,t,n){const r=this;let s=r.events.length,o,i;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return a;function a(h){return o?o._inactive?f(h):(i=r.parser.defined.includes(va(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),c):n(h)}function c(h){return h===40?e.attempt(xmt,d,i?d:f)(h):h===91?e.attempt(ymt,d,i?u:f)(h):i?d(h):f(h)}function u(h){return e.attempt(vmt,d,f)(h)}function d(h){return t(h)}function f(h){return o._balanced=!0,n(h)}}function Nmt(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return cr(f)?Jx(e,o)(f):o(f)}function o(f){return f===41?d(f):Ode(e,i,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function i(f){return cr(f)?Jx(e,c)(f):d(f)}function a(f){return n(f)}function c(f){return f===34||f===39||f===40?$de(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return cr(f)?Jx(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function kmt(e,t,n){const r=this;return s;function s(a){return Lde.call(r,e,o,i,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(va(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function i(a){return n(a)}}function _mt(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const jmt={name:"labelStartImage",resolveAll:P3.resolveAll,tokenize:Imt};function Imt(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),i):n(a)}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Emt={name:"labelStartLink",resolveAll:P3.resolveAll,tokenize:Tmt};function Tmt(e,t,n){const r=this;return s;function s(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),o}function o(i){return i===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(i):t(i)}}const _D={name:"lineEnding",tokenize:Dmt};function Dmt(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),En(e,t,"linePrefix")}}const FS={name:"thematicBreak",tokenize:Mmt};function Mmt(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),i(u)}function i(u){return s=u,a(u)}function a(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||$t(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),wn(u)?En(e,a,"whitespace")(u):a(u))}}const Ao={continuation:{tokenize:Fmt},exit:Lmt,name:"list",tokenize:Pmt},Amt={partial:!0,tokenize:$mt},Rmt={partial:!0,tokenize:Omt};function Pmt(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,i=0;return a;function a(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:CR(m)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(FS,n,u)(m):u(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return CR(m)&&++i<10?(e.consume(m),c):(!r.interrupt||i<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),u(m)):n(m)}function u(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(Yv,r.interrupt?n:d,e.attempt(Amt,h,f))}function d(m){return r.containerState.initialBlankLine=!0,o++,h(m)}function f(m){return wn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),h):n(m)}function h(m){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function Fmt(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Yv,s,o);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,En(e,t,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!wn(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Rmt,t,i)(a))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,En(e,e.attempt(Ao,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Omt(e,t,n){const r=this;return En(e,s,"listItemIndent",r.containerState.size+1);function s(o){const i=r.events[r.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(o):n(o)}}function Lmt(e){e.exit(this.containerState.type)}function $mt(e,t,n){const r=this;return En(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const i=r.events[r.events.length-1];return!wn(o)&&i&&i[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const aU={name:"setextUnderline",resolveTo:zmt,tokenize:Bmt};function zmt(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",i,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=i,e.push(["exit",i,t]),e}function Bmt(e,t,n){const r=this;let s;return o;function o(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,i(u)):n(u)}function i(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),wn(u)?En(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||$t(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Vmt={tokenize:Hmt};function Hmt(e){const t=this,n=e.attempt(Yv,r,e.attempt(this.parser.constructs.flowInitial,s,En(e,e.attempt(this.parser.constructs.flow,s,e.attempt(Yht,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Umt={resolveAll:Bde()},qmt=zde("string"),Wmt=zde("text");function zde(e){return{resolveAll:Bde(e==="text"?Gmt:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,i,a);return i;function i(d){return u(d)?o(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let h=-1;if(f)for(;++h<f.length;){const m=f[h];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function Bde(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function Gmt(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,i=-1,a=0,c;for(;o--;){const u=s[o];if(typeof u=="string"){for(i=u.length;u.charCodeAt(i-1)===32;)a++,i--;if(i)break;i=-1}else if(u===-2)c=!0,a++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?i:r.start._bufferIndex+i,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Ymt={42:Ao,43:Ao,45:Ao,48:Ao,49:Ao,50:Ao,51:Ao,52:Ao,53:Ao,54:Ao,55:Ao,56:Ao,57:Ao,62:Ade},Kmt={91:Jht},Zmt={[-2]:kD,[-1]:kD,32:kD},Xmt={35:omt,42:FS,45:[aU,FS],60:cmt,61:aU,95:FS,96:oU,126:oU},Qmt={38:Pde,92:Rde},Jmt={[-5]:_D,[-4]:_D,[-3]:_D,33:jmt,38:Pde,42:NR,60:[Eht,gmt],91:Emt,92:[rmt,Rde],93:P3,95:NR,96:Vht},ept={null:[NR,Umt]},tpt={null:[42,95]},npt={null:[]},rpt=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:tpt,contentInitial:Kmt,disable:npt,document:Ymt,flow:Xmt,flowInitial:Zmt,insideSpan:ept,string:Qmt,text:Jmt},Symbol.toStringTag,{value:"Module"}));function spt(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let i=[],a=[];const c={attempt:_(N),check:_(k),consume:w,enter:v,exit:C,interrupt:_(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:m,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(T){return i=Ri(i,T),x(),i[i.length-1]!==null?[]:(j(t,0),u.events=Lj(o,u.events,u),u.events)}function h(T,D){return ipt(m(T),D)}function m(T){return opt(i,T)}function g(){const{_bufferIndex:T,_index:D,line:R,column:F,offset:A}=r;return{_bufferIndex:T,_index:D,line:R,column:F,offset:A}}function b(T){s[T.line]=T.column,I()}function x(){let T;for(;r._index<i.length;){const D=i[r._index];if(typeof D=="string")for(T=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===T&&r._bufferIndex<D.length;)y(D.charCodeAt(r._bufferIndex));else y(D)}}function y(T){d=d(T)}function w(T){$t(T)?(r.line++,r.column=1,r.offset+=T===-3?2:1,I()):T!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=T}function v(T,D){const R=D||{};return R.type=T,R.start=g(),u.events.push(["enter",R,u]),a.push(R),R}function C(T){const D=a.pop();return D.end=g(),u.events.push(["exit",D,u]),D}function N(T,D){j(T,D.from)}function k(T,D){D.restore()}function _(T,D){return R;function R(F,A,U){let $,q,W,O;return Array.isArray(F)?Y(F):"tokenize"in F?Y([F]):Z(F);function Z(z){return B;function B(V){const P=V!==null&&z[V],H=V!==null&&z.null,G=[...Array.isArray(P)?P:P?[P]:[],...Array.isArray(H)?H:H?[H]:[]];return Y(G)(V)}}function Y(z){return $=z,q=0,z.length===0?U:M(z[q])}function M(z){return B;function B(V){return O=E(),W=z,z.partial||(u.currentConstruct=z),z.name&&u.parser.constructs.disable.null.includes(z.name)?L():z.tokenize.call(D?Object.assign(Object.create(u),D):u,c,K,L)(V)}}function K(z){return T(W,O),A}function L(z){return O.restore(),++q<$.length?M($[q]):U}}}function j(T,D){T.resolveAll&&!o.includes(T)&&o.push(T),T.resolve&&ci(u.events,D,u.events.length-D,T.resolve(u.events.slice(D),u)),T.resolveTo&&(u.events=T.resolveTo(u.events,u))}function E(){const T=g(),D=u.previous,R=u.currentConstruct,F=u.events.length,A=Array.from(a);return{from:F,restore:U};function U(){r=T,u.previous=D,u.currentConstruct=R,u.events.length=F,a=A,I()}}function I(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function opt(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let i;if(n===s)i=[e[n].slice(r,o)];else{if(i=e.slice(n,s),r>-1){const a=i[0];typeof a=="string"?i[0]=a.slice(r):i.shift()}o>0&&i.push(e[s].slice(0,o))}return i}function ipt(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let i;if(typeof o=="string")i=o;else switch(o){case-5:{i="\r";break}case-4:{i=`
1328
1328
  `;break}case-3:{i=`\r
1329
1329
  `;break}case-2:{i=t?" ":" ";break}case-1:{if(!t&&s)continue;i=" ";break}default:i=String.fromCharCode(o)}s=o===-2,r.push(i)}return r.join("")}function apt(e){const r={constructs:Dde([rpt,...(e||{}).extensions||[]]),content:s(Sht),defined:[],document:s(Nht),flow:s(Vmt),lazy:{},string:s(qmt),text:s(Wmt)};return r;function s(o){return i;function i(a){return spt(r,o,a)}}}function lpt(e){for(;!Fde(e););return e}const lU=/[\0\t\n\r]/g;function cpt(){let e=1,t="",n=!0,r;return s;function s(o,i,a){const c=[];let u,d,f,h,m;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(i||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(lU.lastIndex=f,u=lU.exec(o),h=u&&u.index!==void 0?u.index:o.length,m=o.charCodeAt(h),!u){t=o.slice(f);break}if(m===10&&f===h&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<h&&(c.push(o.slice(f,h)),e+=h-f),m){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return a&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const upt=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function dpt(e){return e.replace(upt,fpt)}function fpt(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return Mde(n.slice(o?2:1),o?16:10)}return R3(n)||e}const Vde={}.hasOwnProperty;function hpt(e,t,n){return typeof t!="string"&&(n=t,t=void 0),mpt(n)(lpt(apt(n).document().write(cpt()(e,t,!0))))}function mpt(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(ge),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(he),blockQuote:o(H),characterEscape:E,characterReference:E,codeFenced:o(G),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(G,i),codeText:o(X,i),codeTextData:E,data:E,codeFlowValue:E,definition:o(ne),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o(de),hardBreakEscape:o(pe),hardBreakTrailing:o(pe),htmlFlow:o(xe,i),htmlFlowData:E,htmlText:o(xe,i),htmlTextData:E,image:o(se),label:i,link:o(ge),listItem:o(Te),listItemValue:h,listOrdered:o(ie,f),listUnordered:o(ie),paragraph:o(re),reference:M,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(he),strong:o(me),thematicBreak:o(J)},exit:{atxHeading:c(),atxHeadingSequence:N,autolink:c(),autolinkEmail:P,autolinkProtocol:V,blockQuote:c(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:L,characterReferenceMarkerNumeric:L,characterReferenceValue:z,characterReference:B,codeFenced:c(x),codeFencedFence:b,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:I,codeIndented:c(y),codeText:c(A),codeTextData:I,data:I,definition:c(),definitionDestinationString:C,definitionLabelString:w,definitionTitleString:v,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(R),htmlFlowData:I,htmlText:c(F),htmlTextData:I,image:c($),label:W,labelText:q,lineEnding:T,link:c(U),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:K,resourceDestinationString:O,resourceTitleString:Z,resource:Y,setextHeading:c(j),setextHeadingLineSequence:_,setextHeadingText:k,strong:c(),thematicBreak:c()}};Hde(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ee){let te={type:"root",children:[]};const ue={stack:[te],tokenStack:[],config:t,enter:a,exit:u,buffer:i,resume:d,data:n},le=[];let ke=-1;for(;++ke<ee.length;)if(ee[ke][1].type==="listOrdered"||ee[ke][1].type==="listUnordered")if(ee[ke][0]==="enter")le.push(ke);else{const Se=le.pop();ke=s(ee,Se,ke)}for(ke=-1;++ke<ee.length;){const Se=t[ee[ke][0]];Vde.call(Se,ee[ke][1].type)&&Se[ee[ke][1].type].call(Object.assign({sliceSerialize:ee[ke][2].sliceSerialize},ue),ee[ke][1])}if(ue.tokenStack.length>0){const Se=ue.tokenStack[ue.tokenStack.length-1];(Se[1]||cU).call(ue,void 0,Se[0])}for(te.position={start:qc(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:qc(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},ke=-1;++ke<t.transforms.length;)te=t.transforms[ke](te)||te;return te}function s(ee,te,ue){let le=te-1,ke=-1,Se=!1,oe,je,Ne,Oe;for(;++le<=ue;){const Ge=ee[le];switch(Ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ge[0]==="enter"?ke++:ke--,Oe=void 0;break}case"lineEndingBlank":{Ge[0]==="enter"&&(oe&&!Oe&&!ke&&!Ne&&(Ne=le),Oe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Oe=void 0}if(!ke&&Ge[0]==="enter"&&Ge[1].type==="listItemPrefix"||ke===-1&&Ge[0]==="exit"&&(Ge[1].type==="listUnordered"||Ge[1].type==="listOrdered")){if(oe){let Le=le;for(je=void 0;Le--;){const Be=ee[Le];if(Be[1].type==="lineEnding"||Be[1].type==="lineEndingBlank"){if(Be[0]==="exit")continue;je&&(ee[je][1].type="lineEndingBlank",Se=!0),Be[1].type="lineEnding",je=Le}else if(!(Be[1].type==="linePrefix"||Be[1].type==="blockQuotePrefix"||Be[1].type==="blockQuotePrefixWhitespace"||Be[1].type==="blockQuoteMarker"||Be[1].type==="listItemIndent"))break}Ne&&(!je||Ne<je)&&(oe._spread=!0),oe.end=Object.assign({},je?ee[je][1].start:Ge[1].end),ee.splice(je||le,0,["exit",oe,Ge[2]]),le++,ue++}if(Ge[1].type==="listItemPrefix"){const Le={type:"listItem",_spread:!1,start:Object.assign({},Ge[1].start),end:void 0};oe=Le,ee.splice(le,0,["enter",Le,Ge[2]]),le++,ue++,Ne=void 0,Oe=!0}}}return ee[te][1]._spread=Se,ue}function o(ee,te){return ue;function ue(le){a.call(this,ee(le),le),te&&te.call(this,le)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(ee,te,ue){this.stack[this.stack.length-1].children.push(ee),this.stack.push(ee),this.tokenStack.push([te,ue||void 0]),ee.position={start:qc(te.start),end:void 0}}function c(ee){return te;function te(ue){ee&&ee.call(this,ue),u.call(this,ue)}}function u(ee,te){const ue=this.stack.pop(),le=this.tokenStack.pop();if(le)le[0].type!==ee.type&&(te?te.call(this,ee,le[0]):(le[1]||cU).call(this,ee,le[0]));else throw new Error("Cannot close `"+ee.type+"` ("+Qx({start:ee.start,end:ee.end})+"): it’s not open");ue.position.end=qc(ee.end)}function d(){return A3(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(ee){if(this.data.expectingFirstListItemValue){const te=this.stack[this.stack.length-2];te.start=Number.parseInt(this.sliceSerialize(ee),10),this.data.expectingFirstListItemValue=void 0}}function m(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.lang=ee}function g(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.meta=ee}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee.replace(/(\r?\n|\r)$/g,"")}function w(ee){const te=this.resume(),ue=this.stack[this.stack.length-1];ue.label=te,ue.identifier=va(this.sliceSerialize(ee)).toLowerCase()}function v(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.title=ee}function C(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.url=ee}function N(ee){const te=this.stack[this.stack.length-1];if(!te.depth){const ue=this.sliceSerialize(ee).length;te.depth=ue}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function _(ee){const te=this.stack[this.stack.length-1];te.depth=this.sliceSerialize(ee).codePointAt(0)===61?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function E(ee){const ue=this.stack[this.stack.length-1].children;let le=ue[ue.length-1];(!le||le.type!=="text")&&(le=ve(),le.position={start:qc(ee.start),end:void 0},ue.push(le)),this.stack.push(le)}function I(ee){const te=this.stack.pop();te.value+=this.sliceSerialize(ee),te.position.end=qc(ee.end)}function T(ee){const te=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ue=te.children[te.children.length-1];ue.position.end=qc(ee.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(te.type)&&(E.call(this,ee),I.call(this,ee))}function D(){this.data.atHardBreak=!0}function R(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee}function F(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee}function A(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee}function U(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const te=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=te,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function $(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const te=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=te,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function q(ee){const te=this.sliceSerialize(ee),ue=this.stack[this.stack.length-2];ue.label=dpt(te),ue.identifier=va(te).toLowerCase()}function W(){const ee=this.stack[this.stack.length-1],te=this.resume(),ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,ue.type==="link"){const le=ee.children;ue.children=le}else ue.alt=te}function O(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.url=ee}function Z(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.title=ee}function Y(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function K(ee){const te=this.resume(),ue=this.stack[this.stack.length-1];ue.label=te,ue.identifier=va(this.sliceSerialize(ee)).toLowerCase(),this.data.referenceType="full"}function L(ee){this.data.characterReferenceType=ee.type}function z(ee){const te=this.sliceSerialize(ee),ue=this.data.characterReferenceType;let le;ue?(le=Mde(te,ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):le=R3(te);const ke=this.stack[this.stack.length-1];ke.value+=le}function B(ee){const te=this.stack.pop();te.position.end=qc(ee.end)}function V(ee){I.call(this,ee);const te=this.stack[this.stack.length-1];te.url=this.sliceSerialize(ee)}function P(ee){I.call(this,ee);const te=this.stack[this.stack.length-1];te.url="mailto:"+this.sliceSerialize(ee)}function H(){return{type:"blockquote",children:[]}}function G(){return{type:"code",lang:null,meta:null,value:""}}function X(){return{type:"inlineCode",value:""}}function ne(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function de(){return{type:"emphasis",children:[]}}function he(){return{type:"heading",depth:0,children:[]}}function pe(){return{type:"break"}}function xe(){return{type:"html",value:""}}function se(){return{type:"image",title:null,url:"",alt:null}}function ge(){return{type:"link",title:null,url:"",children:[]}}function ie(ee){return{type:"list",ordered:ee.type==="listOrdered",start:null,spread:ee._spread,children:[]}}function Te(ee){return{type:"listItem",spread:ee._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function J(){return{type:"thematicBreak"}}}function qc(e){return{line:e.line,column:e.column,offset:e.offset}}function Hde(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Hde(e,r):ppt(e,r)}}function ppt(e,t){let n;for(n in t)if(Vde.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function cU(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Qx({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Qx({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Qx({start:t.start,end:t.end})+") is still open")}function gpt(e){const t=this;t.parser=n;function n(r){return hpt(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function bpt(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function xpt(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -1368,4 +1368,4 @@ prismjs/prism.js:
1368
1368
  More info: ${s.docs}`:"",a=typeof s.message=="string"&&s.message.trim()?s.message.trim():typeof s.error=="string"&&s.error.trim()?s.error.trim():null;if(a){const c=o?` (code: ${o})`:"",u=o==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1369
1369
 
1370
1370
  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 s=JSON.parse(r),o=t(s);if(o)return o}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function G3({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(Bi,{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:L0t(e)})]})}function $0t({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(G3,{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 z0t({text:e,files:t}){return l.jsxs(Hfe,{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(Ldt,{file:n},n.id))})]})}function B0t({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",s=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(nft,{children:JSON.stringify(s,null,2)})]})]})}function Ufe(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")?W3(r,t):!1}})}function KU(){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 V0t({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(KU,{}),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(KU,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(G3,{errorMessage:t}):null}function H0t(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(s=>s.type==="text"&&typeof s.text=="string"&&s.text.trim().length>0))}))==null?void 0:t.id:void 0}function U0t({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:s,showSystemMessage:o=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,w,v,C;const u=H0t(n),d=e.id===u;if(e.role==="user"){const N=((y=e.parts)==null?void 0:y.filter(E=>E.type==="text"))||[],k=((w=e.parts)==null?void 0:w.filter(E=>E.type==="file"))||[],_=N.map(E=>E.text).join(`
1371
- `).trim(),j=k.map((E,I)=>{var R,F;let T="",D;if((R=E.url)!=null&&R.startsWith("data:")){const A=E.url.match(/data:[^;]+;base64,(.+)/);A&&(T=A[1],(F=E.mediaType)!=null&&F.startsWith("image/")&&(D=E.url))}return{id:`${e.id||t}-file-${I}`,name:E.filename||`File ${I+1}`,size:0,type:E.mediaType||"application/octet-stream",data:T,preview:D}});return l.jsx(z0t,{text:_||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(Sc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Cc,{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(Bn,{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(Nc,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,k)=>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:k+1}),l.jsx(BU,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${k}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,k)=>{var j;const _=`${e.id||t}-${k}`;switch(N.type){case"text":{const E=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:I,quickReplies:T}=F0t(E),D=I.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(BU,{text:I,handleRun:i,onAddToDashboard:s,messageId:e.id,messages:n}),T.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[T.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:T.map(({label:R,value:F},A)=>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(F),children:l.jsx("span",{className:"truncate",children:R})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:F})})]},`${_}-qr-${A}`))})]})]},_)}return e.role==="system"&&o?l.jsx(B0t,{text:E},_):null}case"error":{const E=N,I=E.errorText??E.error??E.message;return l.jsx("div",{className:"my-4",children:l.jsx(G3,{errorMessage:I})},_)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&W3(N,r)?l.jsx(ka,{FallbackComponent:({error:E,resetErrorBoundary:I})=>l.jsx($0t,{error:E,resetErrorBoundary:I}),children:l.jsx(D0t,{part:N,idx:_,messageId:e.id,showTools:r,onAddToDashboard:s,messages:n})},_):null}});return e.role==="assistant"?Ufe(e,r)?l.jsxs(Hfe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const q0t=8,W0t=24,G0t=20;function Y0t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function qfe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:s,onQuickReply:o,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,E]=S.useState(0),[I,T]=S.useState(W0t);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],R=Ufe(D,t),F=Y0t(a,c,u,R),A=f_({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const O=e[W];return(O==null?void 0:O.role)==="user"?88:180},getItemKey:W=>{const O=e[W];return(O==null?void 0:O.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:q0t,overscan:6,gap:20,paddingEnd:F?I+G0t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const O=W.isAtEnd();_(Z=>Z===O?Z:O),O&&E(0)}}),U=S.useCallback((W="smooth")=>{v.current!==null&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{v.current=null,A.scrollToEnd({behavior:W})}),E(0),_(!0)},[A]);S.useLayoutEffect(()=>{w.current||(w.current=!0,U("auto"))},[U]),S.useLayoutEffect(()=>{C.current&&(C.current=!1,U("auto"))},[e.length,g,U]),S.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!A.isAtEnd()&&E(O=>O+e.length-W),e.length===0&&(E(0),_(!0),w.current=!1,C.current=!1)},[e.length,A]);const $=A.getVirtualItems(),q=A.getTotalSize();return S.useEffect(()=>()=>{v.current!==null&&cancelAnimationFrame(v.current)},[]),S.useLayoutEffect(()=>{const W=x.current;if(!W||!F)return;const O=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&T(M=>M===Y?M:Y)};if(O(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(O);return Z.observe(W),()=>Z.disconnect()},[F,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:q},children:[$.map(W=>{const O=e[W.index];return O?l.jsx("div",{ref:A.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(U0t,{message:O,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i})})},W.key):null}),F&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(q-I,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(V0t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!k&&l.jsxs("button",{type:"button",onClick:()=>U("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(ps,{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 K0t(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 Z0t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function X0t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:s}){const[o,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}=Yp(),k=C||N||a,_=S.useRef(null);p.useDashboardStore(le=>le.dashboard.aiScopeTables),p.useDashboardStore(le=>le.isDashboardEditing);const j=p.useDashboardStore(le=>le.selectedSheetId),{setDataSource:E}=p.useEditorActions(),{setSelectedFrameId:I,setIsDashboardEditing:T}=p.useDashboardActions(),D=dL(),{clearAssistantMessageContexts:R}=p.useAIActions(),{clearQueue:F}=p.useQueueActions(),{clearFileAttachments:A,getFileAttachments:U}=p.useFileActions(),$=p.useFileAttachments("dashboard"),q=p.useEditorStore(le=>le.card.dataSource),{assistantProfile:W}=Que(),O=p.useDashboardStore(le=>le.handleOpenAssistantProfile),{selectedEntities:Z,applyDashboardDefaultEntities:Y}=ej("dashboard"),{sendMessage:M,isLoading:K,messages:L,setMessages:z,status:B,stop:V,errorMessage:P,clearError:H}=bdt({dynamicVisualMode:f}),G=S.useCallback(()=>{w(le=>le+1)},[]),X=S.useCallback(le=>{r==null||r(le),n===void 0&&x(le)},[n,r]),ne=S.useCallback(()=>{X(!v)},[v,X]);S.useEffect(()=>{if(!v)return;function le(ke){ke.key==="Escape"&&X(!1)}return window.addEventListener("keydown",le),()=>{window.removeEventListener("keydown",le)}},[v,X]);const[de,he]=S.useState(""),pe=le=>{he(le.target.value)};async function xe({sql:le,cardTitle:ke,connectionId:Se,cardType:oe,python:je,cardConfig:Ne,dataSource:Oe,customVisualPreferences:Ge,visualizationMode:Le,dynamicCardPreferences:Be}){if(!j)return;const Ke=Le==="dynamic",Ce=p.hasValidCardConfig(Ne),Je=Se||(Oe==null?void 0:Oe.connectionId)||"",Pe=Oe?{...Oe,connectionId:Je||Oe.connectionId,connectionType:Oe.connectionType||"",mode:Oe.mode||"database",selectedEntities:Oe.selectedEntities||[]}:Je?{connectionId:Je,connectionType:"",mode:"database",selectedEntities:[]}:Up,tt=!(Ce&&(!Ke||(Be==null?void 0:Be.provenance)==="card-config"||(Be==null?void 0:Be.provenance)==="query_spec")),Ae=tt?K0t(le):"",Ie=tt?je:"",We={id:p.v4(),title:ke||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:oe==="horizontalBar"?"y":"x"},...Ke&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:oe,sql:Ae,python:Ie,dataSource:Pe,config:Ne,connectionId:Je,visualizationMode:Le,dynamicCardPreferences:Be,customCardPreferences:Ge?{url:Ge.url,componentName:Ge.componentName,pluginChartType:Ge.pluginChartType,settings:Ge.settings,type:"component"}:void 0},xt={id:p.v4(),cards:[We],activeCardId:We.id};try{await D(j,xt,"end"),T(!0),I(xt.id)}catch(bt){console.error("Failed to add assistant visual to dashboard:",bt),et.error(bt instanceof Error?bt.message:"Failed to prepare semantic metadata for the new visual")}}const se=le=>{le.preventDefault();const ke=de.trim();if(!ke&&$.length===0)return;const Se=[];ke&&Se.push({type:"text",text:ke}),$.forEach(oe=>{oe.data&&Se.push({type:"file",mediaType:oe.type,filename:oe.name,url:`data:${oe.type};base64,${oe.data}`})}),M({role:"user",parts:Se}),he(""),A("dashboard"),G()};S.useEffect(()=>{var le;e&&((le=_.current)==null||le.focus())},[e]),pde({assistantType:"dashboard",status:B,isLoading:K,sendMessage:M});const{hasActiveTools:ge,activeToolText:ie}=gde(L);function Te(le){const ke={role:"user",parts:[{type:"text",text:le.title+" "+le.subtitle}]};M(ke),G()}function re(le){M({role:"user",parts:[{type:"text",text:le}]}),G()}function me(le){M({role:"user",parts:[{type:"text",text:le}]}),G()}const ve=S.useCallback(async()=>{const le=JSON.stringify(L??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(le),et.success("Conversation copied")}catch(ke){console.error("Failed to copy conversation",ke),et.error("Unable to copy conversation")}},[L]),J=(de==null?void 0:de.length)===0&&(L==null?void 0:L.filter(le=>le.role==="user").length)===0;function ee(){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 te(){return l.jsxs(zs,{children:[l.jsx(Bs,{asChild:!0,children:l.jsx(cc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Sh,{className:"size-3.5"})})}),l.jsxs(Ns,{align:"end",children:[l.jsx(da,{children:"Options"}),l.jsx(Ui,{}),l.jsx(Kc,{checked:o,onCheckedChange:i,children:"Token Usage"}),l.jsx(Kc,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Kc,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(Ui,{}),l.jsx(da,{children:"Dynamic Visuals"}),l.jsx(Kc,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Kc,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Kc,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ue=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:[ee(),O&&l.jsxs("button",{type:"button",onClick:O,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&&te(),k&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:ve,children:"Copy Conversation"}),l.jsx(cc,{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:ne,children:v?l.jsx(QR,{className:"h-3.5 w-3.5"}):l.jsx(ek,{className:"h-3.5 w-3.5"})}),l.jsx(cc,{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 le=L.filter(ke=>ke.role==="assistant").map(ke=>ke.id).filter(ke=>!!ke);z([]),F("dashboard"),H(),R(le)},children:l.jsx(eP,{className:"h-3.5 w-3.5"})}),l.jsx(cc,{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(p.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(qfe,{messages:L,showTools:a,showSystemMessage:u,onAddToDashboard:xe,onQuickReply:me,disableQuickReplies:K,status:B,errorMessage:P,activeToolText:K&&ge?ie: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&&J&&l.jsx(Dce,{onClick:Te,placeholders:Z0t}),J&&W&&l.jsx(Jue,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:re}),l.jsx(mde,{assistantType:"dashboard"}),l.jsx(k3,{ref:_,setInput:he,stop:V,input:de,handleInputChange:pe,handleSubmit:le=>{se(le)},isLoading:K,status:B,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(N3,{incomingSelectedEntities:Z,open:m,onOpenChange:g,dataSource:q||Up,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:le=>Y()})]});return v&&s?gr.createPortal(l.jsx(Ag,{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:ue})}),s):ue}function Q0t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),s=iie(),o=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(o==null?void 0:o[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(J0t(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),et.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=evt(m);if(g!=null&&g.id){const b=rie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await s(a,b),r(b.id),et.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)},[s,n,r,a,c,u,t])}function J0t(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 evt(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 tvt(e,t){switch(e.interactionMode){case"drillToDetail":nvt(e,t);break;case"drillThrough":rvt(e,t);break;case"drillToURL":svt(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 nvt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:s,filterGroups:o}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=o.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=o.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}s==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function rvt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:s,sourceCardId:o}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=s.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 svt(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 ovt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:s,contextMode:o,cardTitle:i,cardDescription:a}){return l.jsx(_o,{open:e,onOpenChange:t,children:l.jsxs(ao,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(Zi,{children:[l.jsx(lo,{children:i||"Insight Detail"}),l.jsx(Go,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(cie,{filters:r,filterDefinitions:s,contextMode:o}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(Cie,{insightId:n,filters:r,contextMode:o}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function ivt(){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),s=p.useInteractionStore(C=>C.setPendingDrillThrough),o=p.useInteractionStore(C=>C.pendingDrillThrough),i=p.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=vh(),d=p.useDashboardStore(C=>C.dashboard),f=p.useDashboardStore(C=>C.filterValues),{data:h,isLoading:m}=MG((o==null?void 0:o.targetDashboardId)||"",{enabled:!!(o!=null&&o.targetDashboardId)}),[g,b]=S.useState({open:!1,insightId:""}),x=Nie(g.insightId,{enabled:g.open&&!!g.insightId}),y=S.useRef(new Set),w=S.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:k})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:k})},replaceCardContent:({cardId:C,insightId:N,filters:k,contextMode:_})=>{r(C,N,k,_)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:s,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j})=>{const E={filters:C},I={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[E]},T={...p.createInitialInteractionState(),appliedClickFilters:[I],contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j};t(p.DRILL_CONTEXT_CARD_ID,T)}}),[a,r,f,c,d,s,t]);S.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const k=N.lastInteractionEvent,_=`${C}-${k.interactionMode}-${k.sourceCardId}-${Date.now()}`;if(y.current.has(_))return;y.current.add(_);try{tvt(k,w)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(_)},5e3)}}})},[e,n,w]),S.useEffect(()=>{if(!(!o||!h||m))try{u(h),c(o.targetDashboardId,o.sourceDashboardId,o.sourceDashboardTitle,o.filters,o.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[o,h,m,u,c,i]);const v=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(ovt,{open:g.open,onOpenChange:v,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),o&&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 avt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,s=lvt(t.value);return r==="="?`${n} = ${s}`:`${n} ${r} ${s}`}).join(", ")}function lvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function cvt(e){return e?`Back to ${e}`:"Back"}function uvt(){var y,w,v,C,N;const e=p.useInteractionStore(k=>k.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(k=>k.actions.goBackFromDrill),n=p.useDashboardStore(k=>k.actions.clearDrillContext),{selectDashboard:r}=vh(),[s,o]=S.useState({x:16,y:16}),[i,a]=S.useState(!1),c=S.useRef({x:0,y:0});S.useEffect(()=>{if(!i)return;const k=j=>{o({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},_=()=>{a(!1)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",_),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",_)}},[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(k){console.error("[DrillBack] Error during back navigation:",k)}},g=()=>{n()},b=k=>{k.target.closest("button")||(a(!0),c.current={x:k.clientX-s.x,y:k.clientY-s.y})};avt(f);const x=cvt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${s.x}px, ${s.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=k.field.label||k.field.name,E=String(k.value);return l.jsxs(ls,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",E]},_)})})]}),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(p.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(I0,{className:"mr-2 h-4 w-4"}),x]})})]})})}function dvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function fvt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:m,transition:g,isDragging:b}=zg({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:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const ZU="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",hvt=[];function Wfe({open:e,onOpenChange:t}){var L,z,B;const[n,r]=S.useState(!1),[s,o]=S.useState(!1),[i,a]=S.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(V=>{var P;return(P=V.dashboard)==null?void 0:P.sheets}),u=p.useDashboardStore(V=>V.dashboard),d=p.useDashboardStore(V=>V.dashboardInputValues),f=p.useDashboardStore(V=>V.filterValues),h=p.useDashboardStore(V=>V.controlValues),m=p.useDashboardStore(V=>V.inlineFilterValuesMap),g=p.useDashboardStore(V=>V.cardControlValuesMap),b=p.useDashboardStore(V=>V.selectedSheetId),x=p.useDashboardStore(V=>V.selectedSheetId?V.documentInputRuntimeBySheetId[V.selectedSheetId]:void 0),y=p.useDashboardStore(V=>V.isDownloadingPdf),{authToken:w,tokenProps:v}=ht(),C=c==null?void 0:c.find(V=>V.id===b),N=S.useMemo(()=>p.getDashboardExportSheets(c),[c]),k=p.isDocumentSheet(C),_=k&&C?C.document:void 0,j=S.useMemo(()=>k&&C?Vv(u,C.id):[],[C,k,u]),E=j.length>0,I=S.useMemo(()=>k&&C?ice(u,C.id):!1,[C,k,u]),T=S.useMemo(()=>E?j.map(Hv):(_==null?void 0:_.inputs)||hvt,[_,j,E]),D=((z=(L=v==null?void 0:v.params)==null?void 0:L.calendarContext)==null?void 0:z.tz)||((B=v==null?void 0:v.params)==null?void 0:B.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),R=S.useMemo(()=>ile(T),[T]),F=S.useMemo(()=>sle(T,D),[T,D]),A=S.useMemo(()=>ole(T),[T]),U=x?x.filterValuesByInputId:F,$=x?x.controlValuesByInputId:A,q=S.useMemo(()=>k?I&&C&&_?dZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(V=>V.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:D}):cle(T,U,$,R,R):[],[_,T,C,k,u,g,h,f,m,d,$,U,R,D,I]),W=!!C,O=N.length>0,Z=((c==null?void 0:c.length)||0)>1||k,Y=i.sheetSelection==="current"&&(!W||k&&q.length>0)||i.sheetSelection==="all"&&!O;S.useEffect(()=>{e&&i.sheetSelection==="all"&&!O&&a(V=>({...V,sheetSelection:"current"}))},[O,e,i.sheetSelection]);const M=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){et.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){et.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){et.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!O){et.error("No dashboard sheets are available to export");return}o(!0);const V=i.sheetSelection==="current"&&k,P=V?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",H=et.loading(P);try{if(V){if(!_||!C)throw new Error("Selected document sheet is missing document data");if(q.length>0){et.dismiss(H),et.error(`Set ${q.join(", ")} before exporting`);return}const X=new Date().toISOString(),ne=I?hZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(de=>de.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:X,timezone:D}).snapshot:void 0;await uF(v.apiServiceUrl,w,{sheetId:C.id,title:C.title||"Document",pageSize:_.page.size,orientation:_.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:ne,...ne?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:U,controlValuesByInputId:$,generatedAt:X}}})}else{const X=BJ();await vZ(v.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,X)}et.dismiss(H);const G=V?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!";et.success(G,{duration:2e3}),M()}catch(G){et.dismiss(H),et.error("Failed to download PDF",{description:Fk(G,"Please try again or contact support."),descriptionClassName:Pk,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{o(!1)}}return l.jsx(_o,{open:e,onOpenChange:V=>{if(!V){M();return}t(!0)},children:l.jsxs(ao,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Zi,{children:[l.jsx(lo,{className:"text-[15px]",children:k?"Export document":"Export dashboard"}),l.jsx(Go,{className:"text-[13px] leading-5",children:k?"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:[Z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:ZU,children:"Export scope"}),l.jsxs(Sa,{value:i.sheetSelection,onValueChange:V=>a({...i,sheetSelection:V}),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(ws,{value:"current",id:"scope-current",disabled:!W}),k?"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",!O&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(ws,{value:"all",id:"scope-all",disabled:!O}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),k&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:q.length>0?`Set ${q.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(Mn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:V=>{a({...i,protectPdf:V,password:V?i.password:""}),V||r(!1)}}),l.jsx(JN,{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:ZU,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:V=>a({...i,password:V.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:V=>{V.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(QN,{className:"h-3.5 w-3.5"}):l.jsx(E0,{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:M,disabled:s,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:K,disabled:s||y||Y,children:s?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(_c,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Gfe({iconClassName:e,open:t,onOpenChange:n}){const[r,s]=S.useState(!1),o=t!==void 0,i=o?t:r,a=u=>{o||s(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[o?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(_c,{className:p.cn("size-4",e)})}),l.jsx(Wfe,{open:i,onOpenChange:a})]})}function XU(e,t,n){const r=new Set(t),s=[...n];return e.map(o=>r.has(o.id)?s.shift()??o.id:o.id)}function mvt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:u}=zg({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,...s,children:l.jsx(Cle,{control:e,value:t,isEditing:n,dragListeners:n?o:void 0,onChange:r})})}function QU(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function JU(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function pvt(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 JU(t,n);const s=e.filter(a=>r.has(a)),o=new Set(s),i=JU(t,n).filter(a=>!o.has(a));return[...s,...i]}function gvt(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function bvt(e){return xp(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>xp(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function eq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function xvt(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 yvt(e){return Yfe(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 Yfe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=gvt(e.dashboard,t);return IK(Ik({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!bvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function vvt(e,t){return"toolbar"}function wvt(){const e=Tc("interactive"),t=p.useDashboardStore(z=>z.selectedSheetId),n=p.useDashboardStore(z=>z.dashboard.filters),r=p.useDashboardStore(z=>z.dashboard.filterLayout),s=p.useDashboardStore(z=>z.isDashboardEditing),o=p.useDashboardStore(z=>z.controlValues),i=p.useDashboardStore(z=>z.filterValues);p.useDashboardStore(z=>z.filteringCards);const a=p.useDashboardStore(z=>z.inlineFilterValuesMap),c=p.useDashboardStore(z=>z.dashboardInputValues),u=p.useInteractionStore(z=>z.clearAllClickFilters),d=p.useInteractionStore(z=>Object.entries(z.interactionStates).reduce((B,[V,P])=>{var H;return V===p.DRILL_CONTEXT_CARD_ID?B:B+(((H=P.appliedClickFilters)==null?void 0:H.length)??0)},0)),f=p.useDashboardStore(z=>z.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:v,upsertDashboardInput:C}=p.useDashboardActions(),N=sj(Bp(Lg,{activationConstraint:{distance:5}})),k=p.useDashboardStore(z=>z.dashboard),_=yvt({dashboard:k,selectedSheetId:t}).filter(z=>vvt(z.filter)==="toolbar"),j=Yfe({dashboard:k,selectedSheetId:t}),E=_.map(z=>z.filter),I=new Map(_.map(z=>[`filter:${z.filter.id}`,z])),T=IYe(k),D=T.filter(z=>!z.hidden&&Ky(z)==="toolbar"),R=T.filter(z=>!z.hidden&&Ky(z)==="advanced"),F=pvt(r==null?void 0:r.toolbarItemOrder,E,D),A=new Map(E.map(z=>[`filter:${z.id}`,z])),U=new Map(D.map(z=>[`control:${z.id}`,z]));function $(z){const{active:B,over:V}=z;if(!V||B.id===V.id)return;const P=String(B.id),H=String(V.id),G=F.findIndex(ge=>ge===P),X=F.findIndex(ge=>ge===H);if(G===-1||X===-1)return;const ne=$g(F,G,X);y({toolbarItemOrder:ne});const de=new Set((n||[]).map(ge=>ge.id)),he=F.filter(ge=>ge.startsWith("filter:")).map(ge=>ge.replace("filter:","")).filter(ge=>de.has(ge)),pe=ne.filter(ge=>ge.startsWith("filter:")).map(ge=>ge.replace("filter:","")).filter(ge=>de.has(ge)),xe=F.filter(ge=>ge.startsWith("control:")).map(ge=>ge.replace("control:","")),se=ne.filter(ge=>ge.startsWith("control:")).map(ge=>ge.replace("control:",""));h(XU(n||[],he,pe)),g(XU(k.controls||[],xe,se))}const q=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,O=(i==null?void 0:i.filter(z=>QU(z)).length)??0,Z=j.filter(eq),Y=Z.filter(z=>{const B=xvt({dashboardInput:z,dashboardInputValues:c,defaultInputValues:k.defaultInputValues,selectedSheetId:t});return(B==null?void 0:B.status)==="set"&&B.value.kind==="filter"&&QU(B.value.filterValue)}).length,M=a?Object.values(a).reduce((z,B)=>z+((B==null?void 0:B.length)??0),0):0,K=O+Y+M+d,L=()=>{w([]),Z.forEach(z=>{m(z,{sheetId:t})}),v([]),u(),a&&Object.entries(a).forEach(([z,B])=>{B==null||B.forEach(V=>{f(z,V.filterId)})})};return!E.length&&!D.length&&!R.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(Fv,{sensors:N,collisionDetection:Av,onDragEnd:$,children:l.jsxs("div",{className:p.cn("flex items-center",q?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(Ov,{items:F,strategy:vL,children:l.jsx(eR,{className:"gap-3 pr-0",wrap:q,children:F.map(z=>{const B=A.get(z);if(B){const P=I.get(z),H=P&&eq(P);return l.jsx(fvt,{filter:B,isEditing:s,storageOptions:H?{storageTarget:"dashboardInput",dashboardInput:P,sheetId:t??void 0}:void 0,inputVariableName:H?P.variableName:void 0,onUpdateFilter:H?(G,X)=>{C({...P,variableName:(X==null?void 0:X.variableName)||P.variableName,filter:G})}:void 0,onRemoveFilter:H?()=>{w((i||[]).filter(G=>G.filterId!==B.id)),b(P.id)}:void 0},z)}const V=U.get(z);return V?l.jsx(mvt,{control:V,value:o==null?void 0:o[V.id],isEditing:s,onChange:P=>x(V.id,P)},z):null})})}),R.length>0&&l.jsx(xie,{title:"",controls:R,values:o,onChange:(z,B)=>x(z.id,B),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>0&&l.jsxs("button",{type:"button",onClick:L,"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(p.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(Gfe,{})})]})})})}function Kfe(){var me,ve;const{showAssistant:e,tokenProps:t,renderMode:n}=ht(),r=dvt((me=t.config)==null?void 0:me.showDashboardAssistant,e),{preferences:s}=Yp(),o=(ve=s==null?void 0:s.cardDisplay)==null?void 0:ve.mode,i=Dh(o),a=KK({displayMode:o,renderMode:n}),c=S.useRef(null),u=S.useRef(null),[d,f]=S.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=sot({initialPosition:"bottom-right"}),x=kf(J=>J.setFullscreen),y=kf(J=>J.setPanelOpen),w=kf(J=>J.setContainer),v=PY("dashboard"),C=FY(),N=OY("dashboard"),k=v.isOpen,_=C==="dashboard",j=p.useDashboardStore(J=>J.isVisualEditing),E=p.useDashboardStore(J=>J.themeStyle),I=Dc(),T=p.useDashboardStore(J=>{var ee;return(ee=J.dashboard)==null?void 0:ee.sheets}),D=p.useDashboardStore(J=>J.showFilters),R=p.useDashboardStore(J=>J.isDashboardEditing),F=p.useDashboardStore(J=>J.selectedSheetId),A=T==null?void 0:T.find(J=>J.id===F),U=p.useDashboardStore(J=>{var ee,te,ue;return(ue=(te=(ee=J.dashboard)==null?void 0:ee.sheets)==null?void 0:te.find(le=>le.id===J.selectedSheetId))==null?void 0:ue.kind}),$=p.useDashboardStore(J=>{var ee,te;return((te=(ee=J.dashboard)==null?void 0:ee.summary)==null?void 0:te.position)||"top"}),q=U==="document",W=p.useDashboardStore(J=>{var ee;return(ee=J.dashboard)==null?void 0:ee.id}),{getDefaultSheetId:O,setDefaultSheetId:Z,clearDefaultSheetId:Y}=$q(W),[M,K]=S.useState(null),{setSelectedSheetId:L,setSheetTitle:z,addSheet:B,setSheets:V}=p.useDashboardActions();Q0t(u);const{setActiveAssistantType:P}=p.useAIActions();S.useEffect(()=>{if(W){const J=O();K(J)}},[W,O]),S.useEffect(()=>{k?P("dashboard"):C==="dashboard"&&x(null)},[k,P,C,x]),S.useEffect(()=>{var J;k||(J=c.current)==null||J.resize(0)},[k]);function H(J){var ee,te;J?((ee=c.current)==null||ee.resize(40),y("dashboard",!0),x("dashboard"),P("dashboard")):(y("dashboard",!1),x(null),(te=c.current)==null||te.resize(0),P(null))}function G(J="dashboard"){const ee={id:p.v4(),title:J==="document"?"New Document":"New Sheet",...J==="document"?{kind:J,document:p.createDefaultDocumentDefinition()}:{}};B(ee),L(ee.id)}function X(J,ee){if(!W)return;M===J?(Y(),K(null),et.success("Default sheet cleared")):(Z(J),K(J),et.success(`"${ee}" set as default sheet`))}function ne(J){var ee;J<1?(y("dashboard",!1),x(null),P(null),(ee=c.current)==null||ee.resize(0)):(k||y("dashboard",!0),P("dashboard"))}function de(){return(E==null?void 0:E.canvasTheme)==="muted"||!(E!=null&&E.canvasTheme)?"hsl(var(--semaphor-muted))":(E==null?void 0:E.canvasTheme)==="clear"?"":E==null?void 0:E.canvasTheme}const he=(J,ee)=>{J.dataTransfer.setData("tabIndex",ee.toString())},pe=J=>{J.preventDefault()},xe=(J,ee)=>{const te=J.dataTransfer.getData("tabIndex");if(te===ee.toString())return;const ue=Array.from(T||[]),[le]=ue.splice(parseInt(te),1);ue.splice(ee,0,le),V(ue)},se=r===!0&&!i&&!k&&!j&&!D;function ge(){if(T&&T.length>1||R)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[T==null?void 0:T.map((J,ee)=>{const te=F===J.id,ue=M===J.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:le=>he(le,ee),onDragOver:pe,onDrop:le=>xe(le,ee),onClick:()=>L(J.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:J.id,children:[J.kind==="document"&&l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(uN,{enabled:R&&te,text:J.title,onSave:le=>z(J.id,le),children:J.title},J.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ue?"Clear default sheet":"Set as default sheet",title:ue?"Clear default sheet":"Set as default sheet",onClick:le=>{le.stopPropagation(),X(J.id,J.title||"Sheet")},onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),le.stopPropagation(),X(J.id,J.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",te||ue?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(CW,{className:p.cn("h-3 w-3 transition-colors",ue?"fill-current text-amber-500":"text-muted-foreground")})}),R&&te&&T.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:le=>{le.stopPropagation(),f(!0)},onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),le.stopPropagation(),f(!0))},children:l.jsx(p.X,{className:"h-3 w-3"})})]},J.id)}),R&&l.jsxs(zs,{children:[l.jsx(Bs,{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(Ns,{align:"start",className:"w-48",children:[l.jsxs(vn,{onSelect:()=>G("dashboard"),children:[l.jsx(Gf,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(vn,{onSelect:()=>G("document"),children:[l.jsx(di,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function ie(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:T==null?void 0:T.map(J=>l.jsx(p.TabsContent,{style:{backgroundColor:de(),...I.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:J.id,children:l.jsx(G7,{sheet:J})},J.id))})}function Te(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",E==null?void 0:E.dashboardTabsContainer),onValueChange:J=>{L(J)},value:F||void 0,children:[ge(),$==="top"&&!q&&l.jsx(RA,{}),F&&!q&&l.jsx(wvt,{}),q?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:ie()}):l.jsx(Ea,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:ie()}),$==="bottom"&&!q&&l.jsx(RA,{}),l.jsx(oot,{open:d,setOpen:f})]})}const re=S.useCallback(J=>{w("dashboard",J)},[w]);return T?a&&F&&!q?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',F,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&q&&A?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(G7,{sheet:A})}):l.jsxs(l.Fragment,{children:[l.jsx(ivt,{}),l.jsx(uvt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Tce,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",_&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(oR,{children:Te()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(rot,{open:k,onTabClick:H,withHandle:!0,disabled:!k}),l.jsx(oR,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ne,defaultSize:k?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(X0t,{open:k,setOpen:H,isFullscreen:_,onFullscreenChange:J=>x(J?"dashboard":null),fullscreenContainer:N})})})]})]}),l.jsx("div",{ref:re,className:p.cn("absolute inset-0",!_&&"pointer-events-none")}),se&&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||H(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Epe,{className:"h-5 w-5"})})})]})]}):null}const Zfe=S.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:s,children:o,className:i,style:a,...c},u)=>{const d=S.useId(),f=S.useMemo(()=>Svt(d),[d]),{theme:h}=OR(),m=Cvt(h),g=S.useMemo(()=>s??kc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,s,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(Ag,{...c,ref:u,className:i,style:a,children:o})})});Zfe.displayName="AppearanceProvider";function Svt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Cvt(e){const t=BS(e),[n,r]=S.useState(()=>Nvt());return S.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const s=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!s)return;const o=()=>{r(s.matches?"dark":"light")};return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):((a=s.addListener)==null||a.call(s,o),()=>{var c;return(c=s.removeListener)==null?void 0:c.call(s,o)})},[t]),t==="system"?n:t}function Nvt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const Xfe=S.createContext({openBrandStudioPreview:()=>{}}),kvt=Xfe.Provider;function _vt(){return S.useContext(Xfe)}function jvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const s=BS(t),[o,i]=S.useState(()=>Ivt(n)||s),a=S.useCallback(u=>{const d=BS(u);Evt(n,d),i(d)},[n]),c=S.useMemo(()=>({theme:o,setTheme:a}),[o,a]);return l.jsx(bq.Provider,{...r,value:c,children:e})}function Ivt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=BS(t,"system");return n===t?n:null}catch{return null}}function Evt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const Tvt=S.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function Y3({appearance:e,children:t}){var T,D;const{authToken:n,id:r,tokenProps:s}=ht(),o=_0(),i=(T=o.data)==null?void 0:T.organizationAppearance,a=(D=s.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=`${s.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,v=Dn({queryKey:jG({resourceType:Kr.DASHBOARD,apiServiceUrl:s.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${s.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:R=>(R==null?void 0:R.organizationAppearance)??null,enabled:!o.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,k=S.useMemo(()=>kc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),_=S.useCallback(()=>{f(g??h??k),u(!0)},[g,h,k]),j=S.useCallback(()=>{u(!1)},[]);S.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const E=S.useMemo(()=>({openBrandStudioPreview:_}),[_]),I=g??h??e;return l.jsx(jvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(kvt,{value:E,children:l.jsx(Zfe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:I,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(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(Tvt,{appearance:d,onDraftChange:b,onSave:R=>{m(R),b(R),f(R)},onCancel:j})})})]})})})})}function Qfe({children:e,preferences:t}){const{currentUser:n}=Ki(),r=S.useMemo(()=>{var s,o;return{preferences:t||{},isLocalDev:((s=t==null?void 0:t.uiMode)==null?void 0:s.developer)||!1,isConsoleMode:((o=t==null?void 0:t.uiMode)==null?void 0:o.console)||!1}},[t]);return l.jsx(NG.Provider,{value:r,children:l.jsx(Q_,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Dvt(e=2e3,t=500){const n=Ume(),[r,s]=S.useState(!1),[o,i]=S.useState(!1),a=S.useRef(null);return S.useEffect(()=>{const c=setTimeout(()=>s(!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]),o}function K3({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const s=Dvt(e,t);return S.useEffect(()=>(s&&(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()}}),[s,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:s?"ready":""})}function Jfe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ka,{FallbackComponent:Z_,children:l.jsxs(HR,{dashboardProps:e,children:[l.jsx(K3,{componentType:"dashboard",componentId:e.id}),l.jsx(Y3,{appearance:e.appearance,children:l.jsx(Qfe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(wP,{...e,type:"dashboard",children:l.jsx(Kfe,{})})})})})]})})}function Mvt(e=[]){const t=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[s,o]=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);o(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:s,updateAvailableWidth:i}}function Avt({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=Yp(),r=Dh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),s=p.useDashboardStore(b=>b.filterValues),o=s==null?void 0:s.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=Mvt([t,o,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(Ho,{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(U5,{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(p.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Rvt(){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(Avt,{filter:r}),l.jsx(H_,{filter:r})]},r.id))}):null}function Pvt(){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),s=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),o=p.isDocumentSheet(s);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&&!o&&l.jsx(Rvt,{}),l.jsx(Kfe,{})]})})}const Fvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-Dyqye6fh.js"))),Ovt=S.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-yinO0yU-.js"))),Lvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-CV_LnO9x.js")));function $vt({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),s=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:o,preferences:i}=n;return l.jsx(ka,{FallbackComponent:Z_,children:l.jsxs(HR,{dashboardProps:n,children:[l.jsx(K3,{componentType:"surfboard",componentId:n.id}),l.jsxs(Y3,{appearance:o,children:[l.jsx(Pbe,{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(Qfe,{preferences:i,children:[s&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Lvt,{})}),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(Fvt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(wP,{...n,type:"dashboard",children:[r&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Ovt,{})}),l.jsx(Pvt,{})]})})})]})]})]})]})})}var zvt=Object.defineProperty,Bvt=(e,t,n)=>t in e?zvt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W1=(e,t,n)=>Bvt(e,typeof t!="symbol"?t+"":t,n);const Vvt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},Hvt={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}},Uvt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function qvt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function ehe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const Wvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const s=ehe(t);if(typeof n<"u"&&s in n.container)return n.container[s]})();return typeof r=="function"?r.bind(n):void 0}},Gvt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},Yvt={stringify:e=>e,parse:e=>e},$D={string:Yvt,number:Gvt,boolean:Vvt,function:Hvt,method:Wvt,json:Uvt},Bb=Symbol.for("r2wc.render"),G1=Symbol.for("r2wc.connected"),Od=Symbol.for("r2wc.context"),Qo=Symbol.for("r2wc.props");function Kvt(e,t,n){var r,s,o;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=qvt(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(),W1(this,o,!0),W1(this,s),W1(this,r,{}),W1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Qo].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?$D[y]:null;if(y==="method"){const v=ehe(b);Object.defineProperty(this[Qo].container,v,{enumerable:!0,configurable:!0,get(){return this[Qo][v]},set(C){this[Qo][v]=C,this[Bb]()}}),this[Qo][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Qo][g]=w.parse(x,b,this))}for(const g of a)this[Qo][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[G1]=!0,this[Bb]()}disconnectedCallback(){this[G1]=!1,this[Od]&&n.unmount(this[Od]),delete this[Od]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],v=w?$D[w]:null;y in c&&v!=null&&v.parse&&x&&(this[Qo][y]=v.parse(x,g,this),this[Bb]())}[(o=G1,s=Od,r=Qo,Bb)](){this[G1]&&(this[Od]?n.update(this[Od],this[Qo]):this[Od]=n.mount(this.container,e,this[Qo]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Qo][m]},set(x){this[Qo][m]=x;const y=b?$D[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Bb]()}})}return h}function Zvt(e,t,n){const r=Ehe.createRoot(e),s=S.createElement(t,n);return r.render(s),{root:r,ReactComponent:t}}function Xvt({root:e,ReactComponent:t},n){const r=S.createElement(t,n);e.render(r)}function Qvt({root:e}){e.unmount()}function Jvt(e,t={}){return Kvt(e,t,{mount:Zvt,update:Xvt,unmount:Qvt})}const ewt={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"},twt=Jvt(Jfe,{props:ewt}),nwt=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(UL,{context:t})," "]})}),the=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),rwt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),swt=Array.from(the).join(", "),owt=3,iwt="Self-heal",awt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function lwt({card:e}){var W,O,Z,Y,M;const[t,n]=S.useState({}),{authToken:r}=ht(),s=p.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:o}=p.useAppearance(),i=S.useMemo(()=>Nv(o),[o]),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}=$h(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(O=m==null?void 0:m.visuals)==null?void 0:O.find(K=>{var L;return K.name===((L=f.customCardPreferences)==null?void 0:L.componentName)}),b=kv(f,g)??"single",x=S.useMemo(()=>K5({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=S.useMemo(()=>{const K=x.findIndex(L=>(L==null?void 0:L.id)===e.id);return K<0?-1:qy(e,K)},[x,e]),w=S.useMemo(()=>b!=="multiple"||y<0?e.type:Ym(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}=Ak(v),N=p.useInteractionStore(K=>K.interactionStates),k=p.useDashboardStore(K=>{var L;return(L=K.dashboard)==null?void 0:L.id}),_=p.useDashboardStore(K=>K.dashboard.filters),j=p.useDashboardStore(K=>K.filterValues),E=p.useDashboardStore(K=>K.selectedSheetId),I=S.useMemo(()=>W5({card:e,sheetId:E||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,E,c,u,d]),{cardFilters:T,cardFilterValues:D}=S.useMemo(()=>B0({card:e,interactionStates:N,currentDashboardId:k,filters:_,filterValues:j,selectedSheetId:E}),[e,N,k,_,j,E]),R=S.useCallback((K,L)=>{const z=X5(L);n(B=>({...B,[K]:z}))},[]),F=(Z=f.customCardPreferences)==null?void 0:Z.componentName,A=F?h(F):null,U=lN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),$=S.useMemo(()=>Y5(x),[x]),q=S.useMemo(()=>$.map((K,L)=>Ym(K,L,g==null?void 0:g.slots)),[$,g==null?void 0:g.slots]);return F?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:[A&&b==="single"&&l.jsx(A,{editing:!0,params:s,theme:i,settings:U,cardMetadata:Foe({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:R,data:(C==null?void 0:C.records)||[],filters:T,filterValues:[...D||[],...c||[]],inlineFilters:I}),A&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,L)=>{if(!K)return null;const z=qy(K,L),B=Ym(K,z,g==null?void 0:g.slots);return l.jsx(x5,{onDataChange:R,card:K,effectiveCardType:B},`${K.id}-${z}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(A,{editing:!0,onDataChange:R,...Q5({configCard:f,slotOrderedCards:$,slotTypes:q,multiInputData:t,params:s,theme:i,chartSettings:U,filters:T,filterValues:[...D||[],...c||[]],inlineFilters:I})})})]})]},(M=f.customCardPreferences)==null?void 0:M.componentName)}):null}const cwt=S.memo(lwt,(e,t)=>{var n,r,s,o,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)&&((s=e.card.customCardPreferences)==null?void 0:s.slotSettings)===((o=t.card.customCardPreferences)==null?void 0:o.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)}),uwt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(s=>s.type===n&&s.id===r),toggleStar:n=>{e(r=>{const s=r.starredCharts.findIndex(o=>o.type===n.type&&o.id===n.id);return s>=0?{starredCharts:r.starredCharts.filter((o,i)=>i!==s)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(s=>s.type===n&&s.id===r)}),{name:"semaphor-starred-charts"}));var nhe=["PageUp","PageDown"],rhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],she={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Gg="Slider",[MR,dwt,fwt]=p.createCollection(Gg),[ohe]=p.createContextScope(Gg,[fwt]),[hwt,Wj]=ohe(Gg),ihe=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:s=100,step:o=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"?mwt:pwt,[C=[],N]=p.useControllableState({prop:d,defaultProp:u,onChange:T=>{var R;(R=[...x.current][y.current])==null||R.focus(),f(T)}}),k=Q.useRef(C);function _(T){const D=vwt(C,T);I(T,D)}function j(T){I(T,y.current)}function E(){const T=k.current[y.current];C[y.current]!==T&&h(C)}function I(T,D,{commit:R}={commit:!1}){const F=Nwt(o),A=kwt(Math.round((T-r)/o)*o+r,F),U=p.clamp(A,[r,s]);N(($=[])=>{const q=xwt($,U,D);if(Cwt(q,c*o)){y.current=q.indexOf(U);const W=String(q)!==String($);return W&&R&&h(q),W?q:$}else return $})}return l.jsx(hwt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(MR.Provider,{scope:e.__scopeSlider,children:l.jsx(MR.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||(k.current=C)}),min:r,max:s,inverted:m,onSlideStart:a?void 0:_,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:E,onHomeKeyDown:()=>!a&&I(r,0,{commit:!0}),onEndKeyDown:()=>!a&&I(s,C.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:D})=>{if(!a){const A=nhe.includes(T.key)||T.shiftKey&&rhe.includes(T.key)?10:1,U=y.current,$=C[U],q=o*A*D;I($+q,U,{commit:!0})}}})})})})});ihe.displayName=Gg;var[ahe,lhe]=ohe(Gg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),mwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:s,inverted:o,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(s),x=b==="ltr",y=x&&!o||!x&&o;function w(v){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],_=Z3(N,y?[n,r]:[r,n]);return g.current=C,_(v-C.left)}return l.jsx(ahe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(che,{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=she[y?"from-left":"from-right"].includes(v.key);u==null||u({event:v,direction:N?-1:1})}})})}),pwt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=p.useComposedRefs(t,d),h=Q.useRef(void 0),m=!s;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],v=Z3(y,m?[r,n]:[n,r]);return h.current=x,v(b-x.top)}return l.jsx(ahe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(che,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);o==null||o(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=she[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),che=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=Wj(Gg,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()):nhe.concat(rhe).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)&&s(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),uhe="SliderTrack",dhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=Wj(uhe,n);return l.jsx(p.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:t})});dhe.displayName=uhe;var AR="SliderRange",fhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=Wj(AR,n),o=lhe(AR,n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=s.values.length,u=s.values.map(h=>phe(h,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});fhe.displayName=AR;var RR="SliderThumb",hhe=Q.forwardRef((e,t)=>{const n=dwt(e.__scopeSlider),[r,s]=Q.useState(null),o=p.useComposedRefs(t,a=>s(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(gwt,{...e,ref:o,index:i})}),gwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:s,...o}=e,i=Wj(RR,n),a=lhe(RR,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:phe(m,i.min,i.max),b=ywt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?wwt(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(MR.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,...o,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(mhe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});hhe.displayName=RR;var bwt="RadioBubbleInput",mhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const s=Q.useRef(null),o=p.useComposedRefs(s,r),i=p.usePrevious(t);return Q.useEffect(()=>{const a=s.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:o,defaultValue:t})});mhe.displayName=bwt;function xwt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((s,o)=>s-o)}function phe(e,t,n){const o=100/(n-t)*(e-t);return p.clamp(o,[0,100])}function ywt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function vwt(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),r=Math.min(...n);return n.indexOf(r)}function wwt(e,t,n){const r=e/2,o=Z3([0,50],[0,r]);return(r-o(t)*n)*n}function Swt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Cwt(e,t){if(t>0){const n=Swt(e);return Math.min(...n)>=t}return!0}function Z3(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 Nwt(e){return(String(e).split(".")[1]||"").length}function kwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var ghe=ihe,_wt=dhe,jwt=fhe,Iwt=hhe;const bhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(ghe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(_wt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(jwt,{className:"absolute h-full bg-primary"})}),l.jsx(Iwt,{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"})]}));bhe.displayName=ghe.displayName;const xhe=["SUN","MON","TUE","WED","THU","FRI","SAT"],Ewt=xhe.reduce((e,t,n)=>({...e,[t]:n}),{}),Ll={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function Twt(e){if(!e||!e.trim())return{...Ll};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{...Ll,isCustom:!0};const[s,o,i,a,c]=r,u=Number(s),d=Number(o);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...Ll,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...Ll,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(m=>m.toUpperCase()).map(m=>Ewt[m]).filter(m=>typeof m=="number");if(h.length>0)return{...Ll,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...Ll,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...Ll,repeats:"monthly",hour:d,minute:u}:{...Ll,hour:d,minute:u,isCustom:!0}}function Dwt(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((s,o)=>s-o).map(s=>xhe[s]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function yhe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,s=t.toString().padStart(2,"0");return`${r}:${s} ${n}`}function Mwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Awt(e){if(e.length===7)return"every day";const t=e.slice().sort((s,o)=>s-o);if(t.length===5&&t.every(s=>s>=1&&s<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(s=>r[s]).join(", ")}function Rwt(e,t,n,r){const s=yhe(e.hour,e.minute),o=Mwt(t);let i;if(e.isCustom)i=`Custom schedule · ${s} ${o}`;else switch(e.repeats){case"daily":i=`Daily at ${s} ${o}`;break;case"weekly":i=`Weekly · ${Awt(e.weekdays)} at ${s} ${o}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${s} ${o}`;break;case"monthly":i=`Monthly on the 1st at ${s} ${o}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Pwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=FL;exports.AccordionContent=r0;exports.AccordionItem=t0;exports.AccordionTrigger=n0;exports.AddDataPicker=N3;exports.AggregateTable=x_;exports.Alert=mF;exports.AlertDescription=pF;exports.AlertDialog=kh;exports.AlertDialogAction=ad;exports.AlertDialogCancel=ld;exports.AlertDialogContent=nd;exports.AlertDialogDescription=id;exports.AlertDialogFooter=sd;exports.AlertDialogHeader=rd;exports.AlertDialogTitle=od;exports.AlertDialogTrigger=tye;exports.AlertTitle=UZ;exports.ArrowDown=ps;exports.ArrowDownIcon=Aqe;exports.ArrowLeft=I0;exports.ArrowRight=XN;exports.ArrowUp=Ms;exports.ArrowUpIcon=Pqe;exports.AssistantContextEntityControls=bR;exports.AssistantVirtualizedMessages=qfe;exports.AtSign=Uq;exports.AxisConfigurator=rg;exports.Badge=ls;exports.Bell=Z1;exports.BookType=Wq;exports.BulletChartIcon=Ofe;exports.COMMON_TIMEZONES=Pwt;exports.CSS=bi;exports.CalculatedFieldEditor=Yae;exports.Calculator=Yq;exports.Calendar=ii;exports.Calendar$1=CS;exports.CalendarRange=Kq;exports.Card=ry;exports.CardContent=YR;exports.CardHeader=GR;exports.CardSummary=BA;exports.CardTitle=Gp;exports.ChartArea=c2;exports.ChartColumnIncreasing=Zq;exports.ChartColumnStacked=Xq;exports.ChartJsVisual=gv;exports.ChartLine=Qq;exports.ChartNoAxesGantt=eW;exports.ChartPie=tW;exports.ChartScatter=nW;exports.ChatInputWithContext=k3;exports.Checkbox=Mn;exports.ChevronLeft=wh;exports.ChevronRight=Bn;exports.ChevronsUpDown=oW;exports.Circle=KR;exports.CircleAlert=qf;exports.CircleCheck=iW;exports.CircleHelp=aW;exports.Clock=ZR;exports.CodeHighlighter=Vf;exports.CodeXml=X1;exports.Collapsible=Sc;exports.CollapsibleContent=Nc;exports.CollapsibleTrigger=Cc;exports.ColorField=Ai;exports.Command=cj;exports.CommandEmpty=dj;exports.CommandGroup=fj;exports.CommandInput=NL;exports.CommandItem=hj;exports.CommandList=uj;exports.CommandSeparator=mae;exports.ComparisonMetadataBadge=pee;exports.Container=wP;exports.ControlDefaultValueEditor=gle;exports.ControlDefinitionOptionsEditor=ple;exports.ControlIdInput=dle;exports.ControlVisibilitySettings=Wet;exports.Copy=Tu;exports.CopyButton=Iu;exports.CopyPlus=d2;exports.Cross2Icon=$qe;exports.CustomFilterPopover=U5;exports.CustomScrollArea=Ea;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=bJ;exports.DEFAULT_SCHEDULE_VM=Ll;exports.Dashboard=Jfe;exports.DashboardCard=vie;exports.DashboardCreateDialogBase=eY;exports.DashboardExportDialog=Wfe;exports.DashboardPlus=$vt;exports.DashboardWC=twt;exports.DataTableConditionalFormattingSettings=sce;exports.DataTablePagination=a_;exports.Database=zi;exports.DateRangePicker=N5;exports.DefaultChatTransport=g3;exports.Dialog=_o;exports.DialogContent=ao;exports.DialogDescription=Go;exports.DialogFooter=Ic;exports.DialogHeader=Zi;exports.DialogTitle=lo;exports.DialogTrigger=XG;exports.DisplayPreferencesProvider=Q_;exports.DndContext=Fv;exports.Donut=lW;exports.Download=_c;exports.DownloadPdf=Gfe;exports.DragOverlay=eae;exports.DropdownMenu=zs;exports.DropdownMenuCheckboxItem=Kc;exports.DropdownMenuContent=Ns;exports.DropdownMenuItem=vn;exports.DropdownMenuLabel=da;exports.DropdownMenuRadioGroup=lbe;exports.DropdownMenuRadioItem=CG;exports.DropdownMenuSeparator=Ui;exports.DropdownMenuSub=fP;exports.DropdownMenuSubContent=ik;exports.DropdownMenuSubTrigger=ok;exports.DropdownMenuTrigger=Bs;exports.EMPTY_DATA_SOURCE=Up;exports.Editable=uN;exports.EditableText=Ho;exports.EditorCustomVisual=cwt;exports.Ellipsis=ui;exports.EllipsisVertical=Sh;exports.ErrorBoundary=ka;exports.ExportError=ug;exports.ExternalLink=hp;exports.Eye=E0;exports.EyeOff=QN;exports.Fallback=Z_;exports.FallbackVisual=Gy;exports.FeedbackCategory=ed;exports.FeedbackDialog=g0;exports.FieldsList=UL;exports.FieldsSection=nwt;exports.FileCode=cW;exports.FileSpreadsheet=uW;exports.FileText=di;exports.Filter=Wf;exports.FilterComponent=H_;exports.FilterInfo=OA;exports.FilterableFieldsPanel=Zae;exports.Globe=Ch;exports.Grid3x3=f2;exports.GripVertical=jc;exports.HEATMAP_PRESET_PALETTES=xM;exports.Hash=dW;exports.House=fW;exports.HoverCard=dg;exports.HoverCardContent=Bu;exports.HoverCardTrigger=fg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=the;exports.INLINE_ALLOWED_TOOL_LIST=swt;exports.INLINE_BLOCKED_MUTATING_TOOLS=rwt;exports.IconButton=cc;exports.IconForFieldType=TS;exports.InfoHover=fL;exports.InlineFilterBar=uie;exports.KPICard=Yu;exports.KeyboardSensor=Rv;exports.Layers=T0;exports.LayoutDashboard=Gf;exports.Link=XR;exports.LoadingDots=Hu;exports.Lock=JN;exports.MAX_SELF_HEAL_ATTEMPTS=owt;exports.Map=pW;exports.Markdown=Jde;exports.MatrixTableVisual=b_;exports.Maximize2=ek;exports.MdStackedLineChart=Pfe;exports.Minimize2=QR;exports.MultiInputEmptyRenderer=x5;exports.PYTHON_DEFAULT_CODE=FR;exports.PanelResizeHandle=Tj;exports.Paperclip=gW;exports.PenLine=h2;exports.Pencil=m2;exports.PendingMessagesDisplay=mde;exports.PersistedDynamicVisual=X_;exports.PiChartPolar=Dfe;exports.Pin=xW;exports.PinOff=bW;exports.PivotTableTanstack=Mg;exports.Placeholders=Dce;exports.Play=yW;exports.Plus=kr;exports.PointerSensor=Lg;exports.Progress=S3;exports.RECOVERABLE_SQL_ERROR_CODES=awt;exports.Radar=vW;exports.RadioGroup=Sa;exports.RadioGroupItem=ws;exports.RefreshCw=Yf;exports.ResizableHandle=not;exports.ResizablePanel=oR;exports.ResizablePanelGroup=Tce;exports.ResourceEditDialog=DY;exports.ResourceType=Kr;exports.SELF_HEAL_TIMELINE_STEP=iwt;exports.Search=$s;exports.SeedQuestions=Jue;exports.SemaphorContext=k0;exports.SemaphorContextProvider=HR;exports.SemaphorQueryClient=Lq;exports.SemaphorReadyIndicator=K3;exports.SemaphorStyleWrapper=Ag;exports.Send=wW;exports.Settings=JR;exports.Settings2=D0;exports.Share2=SW;exports.ShareDialog=TY;exports.Sheet=ree;exports.SheetContent=pO;exports.SheetDescription=bO;exports.SheetHeader=oee;exports.SheetTitle=gO;exports.SheetTrigger=GPe;exports.Slider=bhe;exports.SortableContext=Ov;exports.Sparkles=GS;exports.Square=tP;exports.SquarePen=eP;exports.Star=CW;exports.StructuralParticipantSelector=fle;exports.SummaryCard=RA;exports.TABLE_PRESENTATION_DEFAULT_STYLE=_u;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Fi;exports.TableBody=zu;exports.TableCell=Tn;exports.TableColumnVisibilitySettings=Wle;exports.TableHead=es;exports.TableHeader=Ph;exports.TablePresentationSettings=Yle;exports.TableRow=wr;exports.TableSkeleton=hL;exports.TableVisual=Vu;exports.TbChartBubble=Mfe;exports.TbChartFunnel=Afe;exports.TbChartTreemap=Rfe;exports.TextCard=Op;exports.Textarea=jh;exports.TiSortNumerically=Ffe;exports.Toggle=Y_;exports.Tornado=NW;exports.Trash2=fl;exports.TreePalm=rP;exports.TrendingUp=kW;exports.TriangleAlert=Bi;exports.TypeGlyph=Ev;exports.UXProvider=Y3;exports.User=_W;exports.Users=nk;exports.applyFilterOverridesToDashboardInputSlots=uZ;exports.areContextEntitiesEqual=Qn;exports.areEntitiesJoined=SJ;exports.arrayMove=$g;exports.buildCardControlUsageById=Yet;exports.buildCustomCardTheme=Nv;exports.buildDashboardCardExecutionSnapshot=cZ;exports.buildDashboardControlUsageById=Get;exports.buildDashboardExecutionSnapshot=lF;exports.buildDashboardInputExecutionSnapshot=vu;exports.buildDashboardSheetsInputExecutionSnapshot=fZ;exports.buildDashboardStructuralParticipantIdsByControlId=yle;exports.buildFilterFieldMeta=TL;exports.buildFilterSemanticContext=DL;exports.buildInlineFilterNodes=W5;exports.buildMultiInputCustomVisualProps=Q5;exports.buildScheduleExpr=Dwt;exports.buildSchedulePreview=Rwt;exports.buildSlotOrderedCards=Y5;exports.calculateContextAwareFilters=B0;exports.calculateFieldState=iO;exports.canUserAccessVisuals=a0e;exports.canUserCreateDashboards=RY;exports.canUserEdit=s0e;exports.canUserManageDashboards=i0e;exports.canUserManageGroups=l0e;exports.canUserUseFilters=o0e;exports.cancelExport=FRe;exports.chartSupportsDataLabels=mQ;exports.chartSupportsLegend=fQ;exports.chartTypes=qj;exports.cleanupKpiMetricComparisonMode=Sae;exports.cloneDeep=$o;exports.cloneLinkedFrameWithSourceMapping=XGe;exports.closestCenter=Av;exports.commitSharedCalculatedFields=Wd;exports.createAssistantConversationId=Im;exports.createAssistantRequestId=Xue;exports.createCardsFromSlots=fWe;exports.createChartConfig=cg;exports.createDashboardControlInputFromControl=Hrt;exports.createDefaultGlobalDateFilter=pSe;exports.createExport=VJ;exports.createUniqueDashboardInputVariableNameFromName=Eu;exports.dedup=Xut;exports.doesStoredFilterMatchField=Vp;exports.downloadDocumentPdf=uF;exports.downloadPdf=vZ;exports.extractSqlParamReferences=Nse;exports.extractTableMetadata=EL;exports.fieldAlreadyExists=NJ;exports.findCustomVisualConfigCard=Z5;exports.findDashboardFrameById=iSe;exports.flexRender=Bo;exports.formatDisplayFormula=zQe;exports.formatFileSize=$Re;exports.formatFilterLine=WZ;exports.formatTimeLabel=yhe;exports.getAutoDetectedChartIcon=h0t;exports.getChartGridStyle=$Ne;exports.getChartIconByType=m0t;exports.getColorForValue=P2;exports.getConfigSlotExpectedType=dWe;exports.getCoreRowModel=s_;exports.getCustomVisualInputCards=K5;exports.getDateFormatOptionsForGranularity=Jy;exports.getDefaultAxisConfig=O2;exports.getDefaultChartColors=Mh;exports.getDefaultDataLabelsConfig=J0;exports.getDefaultExportFormat=cX;exports.getDefaultFilterSql=E5;exports.getDefaultLegendConfig=HF;exports.getDefaultRunningTotalPartitionByFieldIds=Yx;exports.getDocumentSectionEditorCard=ket;exports.getDocumentSheetDashboardInputs=Vv;exports.getDownloadUrl=PRe;exports.getEffectiveCardTypeForSlot=Ym;exports.getEntityIcon=BN;exports.getErrorMessage=$ue;exports.getExportStatus=RRe;exports.getExports=ARe;exports.getExpressionFieldKind=Zu;exports.getFieldExpressionAnnotation=ML;exports.getFilterCount=pN;exports.getGlobalDateFilter=Xp;exports.getGlobalDateFilterCoverage=gSe;exports.getGranularityOptionsForFieldType=ZL;exports.getKeys=lr;exports.getMatrixVisualLoadingState=g_;exports.getMetricDisplayLabel=tRe;exports.getNewField=EJ;exports.getObjectDiff=xq;exports.getPaginationRowModel=o_;exports.getRoleBasedDisplayOverrides=AY;exports.getRunningTotalOrderByCandidates=cQe;exports.getSelectedDateFilterColumn=_se;exports.getSheetScopedFilterValues=cy;exports.getSlotDefinitionForIndex=G5;exports.getSlotExpectedChartType=W_;exports.getSlotIndexForCard=qy;exports.getSortedRowModel=tee;exports.getSupportedExportFormats=lX;exports.getTableConditionalFormattingColumnOptions=Qle;exports.getTableOutputColumnOptions=Jle;exports.getTablePageSizeOptions=$J;exports.handleAggregationChange=LA;exports.handleAggregationLabelChange=lie;exports.hasFlatTableTotalsBehavior=uCe;exports.hasMatrixResultData=rv;exports.horizontalListSortingStrategy=vL;exports.isCalculatedFilterField=e0;exports.isCardSummaryVisibleOnCard=J5;exports.isCustomVisualConfigCard=MA;exports.isDefaultColor=yCe;exports.isEligibleFlatTableTotalsCard=Qp;exports.isExportComplete=LRe;exports.isExportInProgress=ORe;exports.isInAiScopeArray=Zut;exports.isManagedCalculatedExpressionField=xa;exports.isMetricTransformEnabled=aQe;exports.isPromiseLike=gR;exports.isSubtotalEnabledAggregateTable=IL;exports.isSupportedDocumentTableCardType=_et;exports.lastAssistantMessageIsCompleteWithToolCalls=Pue;exports.merge=dl;exports.mergeAxisConfig=L2;exports.normalizeConditionalFormatting=tF;exports.normalizeContextFormatMode=QZ;exports.normalizeDashboardInputVariableName=j0;exports.normalizeMultiInputPayload=X5;exports.parseScheduleExpr=Twt;exports.pivotData=W0;exports.prepareFeedbackData=Uj;exports.purify=fA;exports.reindexSlotCards=uWe;exports.remarkGfm=jfe;exports.removeFromScopeArray=Qut;exports.resolveDashboardInputContext=Nl;exports.resolveDomainCalculatedFieldForEdit=PJe;exports.resolveMultiInputType=kv;exports.resolveMultiInputTypeFromVisual=hWe;exports.resolveTablePageSize=t_;exports.resolveTablePresentationStyle=kO;exports.sanitizeAIScope=Lue;exports.saveCalculatedFieldToCardScope=ZA;exports.saveCalculatedFieldToSharedScope=Kae;exports.saveCalculatedFieldToSheetScope=XA;exports.seedSemanticMetricFormatDefaults=Nae;exports.setTableColumnVisibility=qJ;exports.setupEditorWithCard=Rk;exports.showAllTableColumns=HRe;exports.showJoinRequiredNotification=CJ;exports.sortByColumnsToSortState=kee;exports.sortStateToSortByColumns=_ee;exports.sortableKeyboardCoordinates=SL;exports.supportsMetricTransformForMetric=Cae;exports.supportsTableConditionalFormatting=Kle;exports.toEntityArray=ba;exports.ue=et;exports.useActiveExports=g0e;exports.useActiveToolStatus=gde;exports.useAddFrameWithFreshSemanticExecutionPayload=dL;exports.useAddNewFrame=Tie;exports.useAssistantContainer=OY;exports.useAssistantContextEntities=ej;exports.useAssistantLayoutStore=kf;exports.useAssistantPanel=PY;exports.useAssistantProfile=Que;exports.useAutoSubmitQueue=pde;exports.useBrandStudioPreview=_vt;exports.useCard=hRe;exports.useCardFilterValues=DJ;exports.useCardSummary=eL;exports.useChat=Oue;exports.useColumns=kL;exports.useCreateVisualWithFrame=sxe;exports.useCurrentUserInfo=Ki;exports.useCustomVisual=$h;exports.useCustomVisualsQuery=H5;exports.useDashboardAppearance=Dc;exports.useDashboardById=MG;exports.useDashboardPreferences=Yp;exports.useDashboardQuery=_0;exports.useDashboardStructuralParticipants=vle;exports.useDashboardSummary=qoe;exports.useDataColumns=_ae;exports.useDateFilterHook=U9e;exports.useDebounce=Vx;exports.useDefaultDashboardMutation=kG;exports.useDisplayPreferences=Cl;exports.useDroppable=Jie;exports.useEditorAside=mj;exports.useEditorCardQuery=Ak;exports.useEnsureReactGlobals=Jre;exports.useExportActions=LY;exports.useExportStore=mk;exports.useFieldManagement=kae;exports.useFilterableFields=yae;exports.useFullscreenAssistant=FY;exports.useGroupMembers=iye;exports.useGroups=SY;exports.useHasDashboardId=$Y;exports.useInProgressExportsCount=b0e;exports.useJoinabilityMap=jL;exports.useManagementActions=vh;exports.useManagementStore=Os;exports.useMutation=so;exports.usePivotTableConfig=Rh;exports.usePluginQuery=Doe;exports.useQuery=Dn;exports.useQueryClient=Zr;exports.useReactTable=i_;exports.useResolveExistingFrameSemanticExecutionPayload=tYe;exports.useResourceManagement=mP;exports.useResourceUpdateState=AG;exports.useScopedFields=xae;exports.useSelectedVisual=Gme;exports.useSemaphorContext=ht;exports.useSensor=Bp;exports.useSensors=sj;exports.useSortable=zg;exports.useStarredChartsStore=uwt;exports.useSurfaceAppearance=Tc;exports.useTableQueryState=gee;exports.useTextFilterHook=t7e;exports.useTheme=OR;exports.useTopoJson=tv;exports.useUnifiedUsers=yP;exports.useUpdateResource=IG;exports.useUpdateVisualMutation=oxe;exports.useUserPreferences=tY;exports.useVisualById=lk;exports.useVisualManagement=rxe;exports.validateFieldForChartType=wae;exports.verticalListSortingStrategy=wL;
1371
+ `).trim(),j=k.map((E,I)=>{var R,F;let T="",D;if((R=E.url)!=null&&R.startsWith("data:")){const A=E.url.match(/data:[^;]+;base64,(.+)/);A&&(T=A[1],(F=E.mediaType)!=null&&F.startsWith("image/")&&(D=E.url))}return{id:`${e.id||t}-file-${I}`,name:E.filename||`File ${I+1}`,size:0,type:E.mediaType||"application/octet-stream",data:T,preview:D}});return l.jsx(z0t,{text:_||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(Sc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Cc,{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(Bn,{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(Nc,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,k)=>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:k+1}),l.jsx(BU,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${k}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,k)=>{var j;const _=`${e.id||t}-${k}`;switch(N.type){case"text":{const E=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:I,quickReplies:T}=F0t(E),D=I.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(BU,{text:I,handleRun:i,onAddToDashboard:s,messageId:e.id,messages:n}),T.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[T.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:T.map(({label:R,value:F},A)=>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(F),children:l.jsx("span",{className:"truncate",children:R})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:F})})]},`${_}-qr-${A}`))})]})]},_)}return e.role==="system"&&o?l.jsx(B0t,{text:E},_):null}case"error":{const E=N,I=E.errorText??E.error??E.message;return l.jsx("div",{className:"my-4",children:l.jsx(G3,{errorMessage:I})},_)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&W3(N,r)?l.jsx(ka,{FallbackComponent:({error:E,resetErrorBoundary:I})=>l.jsx($0t,{error:E,resetErrorBoundary:I}),children:l.jsx(D0t,{part:N,idx:_,messageId:e.id,showTools:r,onAddToDashboard:s,messages:n})},_):null}});return e.role==="assistant"?Ufe(e,r)?l.jsxs(Hfe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const q0t=8,W0t=24,G0t=20;function Y0t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function qfe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:s,onQuickReply:o,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,E]=S.useState(0),[I,T]=S.useState(W0t);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],R=Ufe(D,t),F=Y0t(a,c,u,R),A=f_({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const O=e[W];return(O==null?void 0:O.role)==="user"?88:180},getItemKey:W=>{const O=e[W];return(O==null?void 0:O.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:q0t,overscan:6,gap:20,paddingEnd:F?I+G0t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const O=W.isAtEnd();_(Z=>Z===O?Z:O),O&&E(0)}}),U=S.useCallback((W="smooth")=>{v.current!==null&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{v.current=null,A.scrollToEnd({behavior:W})}),E(0),_(!0)},[A]);S.useLayoutEffect(()=>{w.current||(w.current=!0,U("auto"))},[U]),S.useLayoutEffect(()=>{C.current&&(C.current=!1,U("auto"))},[e.length,g,U]),S.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!A.isAtEnd()&&E(O=>O+e.length-W),e.length===0&&(E(0),_(!0),w.current=!1,C.current=!1)},[e.length,A]);const $=A.getVirtualItems(),q=A.getTotalSize();return S.useEffect(()=>()=>{v.current!==null&&cancelAnimationFrame(v.current)},[]),S.useLayoutEffect(()=>{const W=x.current;if(!W||!F)return;const O=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&T(M=>M===Y?M:Y)};if(O(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(O);return Z.observe(W),()=>Z.disconnect()},[F,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:q},children:[$.map(W=>{const O=e[W.index];return O?l.jsx("div",{ref:A.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(U0t,{message:O,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i})})},W.key):null}),F&&l.jsx("div",{ref:x,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(q-I,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(V0t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!k&&l.jsxs("button",{type:"button",onClick:()=>U("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(ps,{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 K0t(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 Z0t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function X0t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:s}){const[o,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}=Yp(),k=C||N||a,_=S.useRef(null);p.useDashboardStore(le=>le.dashboard.aiScopeTables),p.useDashboardStore(le=>le.isDashboardEditing);const j=p.useDashboardStore(le=>le.selectedSheetId),{setDataSource:E}=p.useEditorActions(),{setSelectedFrameId:I,setIsDashboardEditing:T}=p.useDashboardActions(),D=dL(),{clearAssistantMessageContexts:R}=p.useAIActions(),{clearQueue:F}=p.useQueueActions(),{clearFileAttachments:A,getFileAttachments:U}=p.useFileActions(),$=p.useFileAttachments("dashboard"),q=p.useEditorStore(le=>le.card.dataSource),{assistantProfile:W}=Que(),O=p.useDashboardStore(le=>le.handleOpenAssistantProfile),{selectedEntities:Z,applyDashboardDefaultEntities:Y}=ej("dashboard"),{sendMessage:M,isLoading:K,messages:L,setMessages:z,status:B,stop:V,errorMessage:P,clearError:H}=bdt({dynamicVisualMode:f}),G=S.useCallback(()=>{w(le=>le+1)},[]),X=S.useCallback(le=>{r==null||r(le),n===void 0&&x(le)},[n,r]),ne=S.useCallback(()=>{X(!v)},[v,X]);S.useEffect(()=>{if(!v)return;function le(ke){ke.key==="Escape"&&X(!1)}return window.addEventListener("keydown",le),()=>{window.removeEventListener("keydown",le)}},[v,X]);const[de,he]=S.useState(""),pe=le=>{he(le.target.value)};async function xe({sql:le,cardTitle:ke,connectionId:Se,cardType:oe,python:je,cardConfig:Ne,dataSource:Oe,customVisualPreferences:Ge,visualizationMode:Le,dynamicCardPreferences:Be}){if(!j)return;const Ke=Le==="dynamic",Ce=p.hasValidCardConfig(Ne),Je=Se||(Oe==null?void 0:Oe.connectionId)||"",Pe=Oe?{...Oe,connectionId:Je||Oe.connectionId,connectionType:Oe.connectionType||"",mode:Oe.mode||"database",selectedEntities:Oe.selectedEntities||[]}:Je?{connectionId:Je,connectionType:"",mode:"database",selectedEntities:[]}:Up,tt=!(Ce&&(!Ke||(Be==null?void 0:Be.provenance)==="card-config"||(Be==null?void 0:Be.provenance)==="query_spec")),Ae=tt?K0t(le):"",Ie=tt?je:"",We={id:p.v4(),title:ke||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:oe==="horizontalBar"?"y":"x"},...Ke&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:oe,sql:Ae,python:Ie,dataSource:Pe,config:Ne,connectionId:Je,visualizationMode:Le,dynamicCardPreferences:Be,customCardPreferences:Ge?{url:Ge.url,componentName:Ge.componentName,pluginChartType:Ge.pluginChartType,settings:Ge.settings,type:"component"}:void 0},xt={id:p.v4(),cards:[We],activeCardId:We.id};try{await D(j,xt,"end"),T(!0),I(xt.id)}catch(bt){console.error("Failed to add assistant visual to dashboard:",bt),et.error(bt instanceof Error?bt.message:"Failed to prepare semantic metadata for the new visual")}}const se=le=>{le.preventDefault();const ke=de.trim();if(!ke&&$.length===0)return;const Se=[];ke&&Se.push({type:"text",text:ke}),$.forEach(oe=>{oe.data&&Se.push({type:"file",mediaType:oe.type,filename:oe.name,url:`data:${oe.type};base64,${oe.data}`})}),M({role:"user",parts:Se}),he(""),A("dashboard"),G()};S.useEffect(()=>{var le;e&&((le=_.current)==null||le.focus())},[e]),pde({assistantType:"dashboard",status:B,isLoading:K,sendMessage:M});const{hasActiveTools:ge,activeToolText:ie}=gde(L);function Te(le){const ke={role:"user",parts:[{type:"text",text:le.title+" "+le.subtitle}]};M(ke),G()}function re(le){M({role:"user",parts:[{type:"text",text:le}]}),G()}function me(le){M({role:"user",parts:[{type:"text",text:le}]}),G()}const ve=S.useCallback(async()=>{const le=JSON.stringify(L??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(le),et.success("Conversation copied")}catch(ke){console.error("Failed to copy conversation",ke),et.error("Unable to copy conversation")}},[L]),J=(de==null?void 0:de.length)===0&&(L==null?void 0:L.filter(le=>le.role==="user").length)===0;function ee(){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 te(){return l.jsxs(zs,{children:[l.jsx(Bs,{asChild:!0,children:l.jsx(cc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Sh,{className:"size-3.5"})})}),l.jsxs(Ns,{align:"end",children:[l.jsx(da,{children:"Options"}),l.jsx(Ui,{}),l.jsx(Kc,{checked:o,onCheckedChange:i,children:"Token Usage"}),l.jsx(Kc,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Kc,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(Ui,{}),l.jsx(da,{children:"Dynamic Visuals"}),l.jsx(Kc,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Kc,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Kc,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ue=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:[ee(),O&&l.jsxs("button",{type:"button",onClick:O,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&&te(),k&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:ve,children:"Copy Conversation"}),l.jsx(cc,{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:ne,children:v?l.jsx(QR,{className:"h-3.5 w-3.5"}):l.jsx(ek,{className:"h-3.5 w-3.5"})}),l.jsx(cc,{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 le=L.filter(ke=>ke.role==="assistant").map(ke=>ke.id).filter(ke=>!!ke);z([]),F("dashboard"),H(),R(le)},children:l.jsx(eP,{className:"h-3.5 w-3.5"})}),l.jsx(cc,{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(p.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(qfe,{messages:L,showTools:a,showSystemMessage:u,onAddToDashboard:xe,onQuickReply:me,disableQuickReplies:K,status:B,errorMessage:P,activeToolText:K&&ge?ie: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&&J&&l.jsx(Dce,{onClick:Te,placeholders:Z0t}),J&&W&&l.jsx(Jue,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:re}),l.jsx(mde,{assistantType:"dashboard"}),l.jsx(k3,{ref:_,setInput:he,stop:V,input:de,handleInputChange:pe,handleSubmit:le=>{se(le)},isLoading:K,status:B,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(N3,{incomingSelectedEntities:Z,open:m,onOpenChange:g,dataSource:q||Up,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:le=>Y()})]});return v&&s?gr.createPortal(l.jsx(Ag,{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:ue})}),s):ue}function Q0t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),s=iie(),o=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(o==null?void 0:o[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(J0t(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),et.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=evt(m);if(g!=null&&g.id){const b=rie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await s(a,b),r(b.id),et.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)},[s,n,r,a,c,u,t])}function J0t(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 evt(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 tvt(e,t){switch(e.interactionMode){case"drillToDetail":nvt(e,t);break;case"drillThrough":rvt(e,t);break;case"drillToURL":svt(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 nvt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:s,filterGroups:o}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=o.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=o.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}s==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function rvt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:s,sourceCardId:o}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=s.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 svt(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 ovt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:s,contextMode:o,cardTitle:i,cardDescription:a}){return l.jsx(_o,{open:e,onOpenChange:t,children:l.jsxs(ao,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(Zi,{children:[l.jsx(lo,{children:i||"Insight Detail"}),l.jsx(Go,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(cie,{filters:r,filterDefinitions:s,contextMode:o}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(Cie,{insightId:n,filters:r,contextMode:o}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function ivt(){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),s=p.useInteractionStore(C=>C.setPendingDrillThrough),o=p.useInteractionStore(C=>C.pendingDrillThrough),i=p.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=vh(),d=p.useDashboardStore(C=>C.dashboard),f=p.useDashboardStore(C=>C.filterValues),{data:h,isLoading:m}=MG((o==null?void 0:o.targetDashboardId)||"",{enabled:!!(o!=null&&o.targetDashboardId)}),[g,b]=S.useState({open:!1,insightId:""}),x=Nie(g.insightId,{enabled:g.open&&!!g.insightId}),y=S.useRef(new Set),w=S.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:k})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:k})},replaceCardContent:({cardId:C,insightId:N,filters:k,contextMode:_})=>{r(C,N,k,_)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:s,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j})=>{const E={filters:C},I={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[E]},T={...p.createInitialInteractionState(),appliedClickFilters:[I],contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j};t(p.DRILL_CONTEXT_CARD_ID,T)}}),[a,r,f,c,d,s,t]);S.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const k=N.lastInteractionEvent,_=`${C}-${k.interactionMode}-${k.sourceCardId}-${Date.now()}`;if(y.current.has(_))return;y.current.add(_);try{tvt(k,w)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(_)},5e3)}}})},[e,n,w]),S.useEffect(()=>{if(!(!o||!h||m))try{u(h),c(o.targetDashboardId,o.sourceDashboardId,o.sourceDashboardTitle,o.filters,o.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[o,h,m,u,c,i]);const v=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(ovt,{open:g.open,onOpenChange:v,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),o&&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 avt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,s=lvt(t.value);return r==="="?`${n} = ${s}`:`${n} ${r} ${s}`}).join(", ")}function lvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function cvt(e){return e?`Back to ${e}`:"Back"}function uvt(){var y,w,v,C,N;const e=p.useInteractionStore(k=>k.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(k=>k.actions.goBackFromDrill),n=p.useDashboardStore(k=>k.actions.clearDrillContext),{selectDashboard:r}=vh(),[s,o]=S.useState({x:16,y:16}),[i,a]=S.useState(!1),c=S.useRef({x:0,y:0});S.useEffect(()=>{if(!i)return;const k=j=>{o({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},_=()=>{a(!1)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",_),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",_)}},[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(k){console.error("[DrillBack] Error during back navigation:",k)}},g=()=>{n()},b=k=>{k.target.closest("button")||(a(!0),c.current={x:k.clientX-s.x,y:k.clientY-s.y})};avt(f);const x=cvt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${s.x}px, ${s.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=k.field.label||k.field.name,E=String(k.value);return l.jsxs(ls,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",E]},_)})})]}),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(p.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(I0,{className:"mr-2 h-4 w-4"}),x]})})]})})}function dvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function fvt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:m,transition:g,isDragging:b}=zg({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:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const ZU="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",hvt=[];function Wfe({open:e,onOpenChange:t}){var L,z,B;const[n,r]=S.useState(!1),[s,o]=S.useState(!1),[i,a]=S.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(V=>{var P;return(P=V.dashboard)==null?void 0:P.sheets}),u=p.useDashboardStore(V=>V.dashboard),d=p.useDashboardStore(V=>V.dashboardInputValues),f=p.useDashboardStore(V=>V.filterValues),h=p.useDashboardStore(V=>V.controlValues),m=p.useDashboardStore(V=>V.inlineFilterValuesMap),g=p.useDashboardStore(V=>V.cardControlValuesMap),b=p.useDashboardStore(V=>V.selectedSheetId),x=p.useDashboardStore(V=>V.selectedSheetId?V.documentInputRuntimeBySheetId[V.selectedSheetId]:void 0),y=p.useDashboardStore(V=>V.isDownloadingPdf),{authToken:w,tokenProps:v}=ht(),C=c==null?void 0:c.find(V=>V.id===b),N=S.useMemo(()=>p.getDashboardExportSheets(c),[c]),k=p.isDocumentSheet(C),_=k&&C?C.document:void 0,j=S.useMemo(()=>k&&C?Vv(u,C.id):[],[C,k,u]),E=j.length>0,I=S.useMemo(()=>k&&C?ice(u,C.id):!1,[C,k,u]),T=S.useMemo(()=>E?j.map(Hv):(_==null?void 0:_.inputs)||hvt,[_,j,E]),D=((z=(L=v==null?void 0:v.params)==null?void 0:L.calendarContext)==null?void 0:z.tz)||((B=v==null?void 0:v.params)==null?void 0:B.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),R=S.useMemo(()=>ile(T),[T]),F=S.useMemo(()=>sle(T,D),[T,D]),A=S.useMemo(()=>ole(T),[T]),U=x?x.filterValuesByInputId:F,$=x?x.controlValuesByInputId:A,q=S.useMemo(()=>k?I&&C&&_?dZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(V=>V.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:D}):cle(T,U,$,R,R):[],[_,T,C,k,u,g,h,f,m,d,$,U,R,D,I]),W=!!C,O=N.length>0,Z=((c==null?void 0:c.length)||0)>1||k,Y=i.sheetSelection==="current"&&(!W||k&&q.length>0)||i.sheetSelection==="all"&&!O;S.useEffect(()=>{e&&i.sheetSelection==="all"&&!O&&a(V=>({...V,sheetSelection:"current"}))},[O,e,i.sheetSelection]);const M=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){et.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){et.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){et.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!O){et.error("No dashboard sheets are available to export");return}o(!0);const V=i.sheetSelection==="current"&&k,P=V?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",H=et.loading(P);try{if(V){if(!_||!C)throw new Error("Selected document sheet is missing document data");if(q.length>0){et.dismiss(H),et.error(`Set ${q.join(", ")} before exporting`);return}const X=new Date().toISOString(),ne=I?hZ({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(de=>de.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:X,timezone:D}).snapshot:void 0;await uF(v.apiServiceUrl,w,{sheetId:C.id,title:C.title||"Document",pageSize:_.page.size,orientation:_.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:ne,...ne?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:U,controlValuesByInputId:$,generatedAt:X}}})}else{const X=BJ();await vZ(v.apiServiceUrl,w,i.protectPdf?i.password:void 0,i.sheetSelection,X)}et.dismiss(H);const G=V?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!";et.success(G,{duration:2e3}),M()}catch(G){et.dismiss(H),et.error("Failed to download PDF",{description:Fk(G,"Please try again or contact support."),descriptionClassName:Pk,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{o(!1)}}return l.jsx(_o,{open:e,onOpenChange:V=>{if(!V){M();return}t(!0)},children:l.jsxs(ao,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Zi,{children:[l.jsx(lo,{className:"text-[15px]",children:k?"Export document":"Export dashboard"}),l.jsx(Go,{className:"text-[13px] leading-5",children:k?"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:[Z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:ZU,children:"Export scope"}),l.jsxs(Sa,{value:i.sheetSelection,onValueChange:V=>a({...i,sheetSelection:V}),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(ws,{value:"current",id:"scope-current",disabled:!W}),k?"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",!O&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(ws,{value:"all",id:"scope-all",disabled:!O}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),k&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:q.length>0?`Set ${q.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(Mn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:V=>{a({...i,protectPdf:V,password:V?i.password:""}),V||r(!1)}}),l.jsx(JN,{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:ZU,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:V=>a({...i,password:V.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:V=>{V.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(QN,{className:"h-3.5 w-3.5"}):l.jsx(E0,{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:M,disabled:s,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:K,disabled:s||y||Y,children:s?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(_c,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Gfe({iconClassName:e,open:t,onOpenChange:n}){const[r,s]=S.useState(!1),o=t!==void 0,i=o?t:r,a=u=>{o||s(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[o?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(_c,{className:p.cn("size-4",e)})}),l.jsx(Wfe,{open:i,onOpenChange:a})]})}function XU(e,t,n){const r=new Set(t),s=[...n];return e.map(o=>r.has(o.id)?s.shift()??o.id:o.id)}function mvt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:u}=zg({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,...s,children:l.jsx(Cle,{control:e,value:t,isEditing:n,dragListeners:n?o:void 0,onChange:r})})}function QU(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function JU(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function pvt(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 JU(t,n);const s=e.filter(a=>r.has(a)),o=new Set(s),i=JU(t,n).filter(a=>!o.has(a));return[...s,...i]}function gvt(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function bvt(e){return xp(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>xp(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function eq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function xvt(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 yvt(e){return Yfe(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 Yfe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=gvt(e.dashboard,t);return IK(Ik({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!bvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function vvt(e,t){return"toolbar"}function wvt(){const e=Tc("interactive"),t=p.useDashboardStore(z=>z.selectedSheetId),n=p.useDashboardStore(z=>z.dashboard.filters),r=p.useDashboardStore(z=>z.dashboard.filterLayout),s=p.useDashboardStore(z=>z.isDashboardEditing),o=p.useDashboardStore(z=>z.controlValues),i=p.useDashboardStore(z=>z.filterValues);p.useDashboardStore(z=>z.filteringCards);const a=p.useDashboardStore(z=>z.inlineFilterValuesMap),c=p.useDashboardStore(z=>z.dashboardInputValues),u=p.useInteractionStore(z=>z.clearAllClickFilters),d=p.useInteractionStore(z=>Object.entries(z.interactionStates).reduce((B,[V,P])=>{var H;return V===p.DRILL_CONTEXT_CARD_ID?B:B+(((H=P.appliedClickFilters)==null?void 0:H.length)??0)},0)),f=p.useDashboardStore(z=>z.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:w,setFilteringCards:v,upsertDashboardInput:C}=p.useDashboardActions(),N=sj(Bp(Lg,{activationConstraint:{distance:5}})),k=p.useDashboardStore(z=>z.dashboard),_=yvt({dashboard:k,selectedSheetId:t}).filter(z=>vvt(z.filter)==="toolbar"),j=Yfe({dashboard:k,selectedSheetId:t}),E=_.map(z=>z.filter),I=new Map(_.map(z=>[`filter:${z.filter.id}`,z])),T=IYe(k),D=T.filter(z=>!z.hidden&&Ky(z)==="toolbar"),R=T.filter(z=>!z.hidden&&Ky(z)==="advanced"),F=pvt(r==null?void 0:r.toolbarItemOrder,E,D),A=new Map(E.map(z=>[`filter:${z.id}`,z])),U=new Map(D.map(z=>[`control:${z.id}`,z]));function $(z){const{active:B,over:V}=z;if(!V||B.id===V.id)return;const P=String(B.id),H=String(V.id),G=F.findIndex(ge=>ge===P),X=F.findIndex(ge=>ge===H);if(G===-1||X===-1)return;const ne=$g(F,G,X);y({toolbarItemOrder:ne});const de=new Set((n||[]).map(ge=>ge.id)),he=F.filter(ge=>ge.startsWith("filter:")).map(ge=>ge.replace("filter:","")).filter(ge=>de.has(ge)),pe=ne.filter(ge=>ge.startsWith("filter:")).map(ge=>ge.replace("filter:","")).filter(ge=>de.has(ge)),xe=F.filter(ge=>ge.startsWith("control:")).map(ge=>ge.replace("control:","")),se=ne.filter(ge=>ge.startsWith("control:")).map(ge=>ge.replace("control:",""));h(XU(n||[],he,pe)),g(XU(k.controls||[],xe,se))}const q=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,O=(i==null?void 0:i.filter(z=>QU(z)).length)??0,Z=j.filter(eq),Y=Z.filter(z=>{const B=xvt({dashboardInput:z,dashboardInputValues:c,defaultInputValues:k.defaultInputValues,selectedSheetId:t});return(B==null?void 0:B.status)==="set"&&B.value.kind==="filter"&&QU(B.value.filterValue)}).length,M=a?Object.values(a).reduce((z,B)=>z+((B==null?void 0:B.length)??0),0):0,K=O+Y+M+d,L=()=>{w([]),Z.forEach(z=>{m(z,{sheetId:t})}),v([]),u(),a&&Object.entries(a).forEach(([z,B])=>{B==null||B.forEach(V=>{f(z,V.filterId)})})};return!E.length&&!D.length&&!R.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(Fv,{sensors:N,collisionDetection:Av,onDragEnd:$,children:l.jsxs("div",{className:p.cn("flex items-center",q?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(Ov,{items:F,strategy:vL,children:l.jsx(eR,{className:"gap-3 pr-0",wrap:q,children:F.map(z=>{const B=A.get(z);if(B){const P=I.get(z),H=P&&eq(P);return l.jsx(fvt,{filter:B,isEditing:s,storageOptions:H?{storageTarget:"dashboardInput",dashboardInput:P,sheetId:t??void 0}:void 0,inputVariableName:H?P.variableName:void 0,onUpdateFilter:H?(G,X)=>{C({...P,variableName:(X==null?void 0:X.variableName)||P.variableName,filter:G})}:void 0,onRemoveFilter:H?()=>{w((i||[]).filter(G=>G.filterId!==B.id)),b(P.id)}:void 0},z)}const V=U.get(z);return V?l.jsx(mvt,{control:V,value:o==null?void 0:o[V.id],isEditing:s,onChange:P=>x(V.id,P)},z):null})})}),R.length>0&&l.jsx(xie,{title:"",controls:R,values:o,onChange:(z,B)=>x(z.id,B),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>0&&l.jsxs("button",{type:"button",onClick:L,"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(p.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(Gfe,{})})]})})})}function Kfe(){var me,ve;const{showAssistant:e,tokenProps:t,renderMode:n}=ht(),r=dvt((me=t.config)==null?void 0:me.showDashboardAssistant,e),{preferences:s}=Yp(),o=(ve=s==null?void 0:s.cardDisplay)==null?void 0:ve.mode,i=Dh(o),a=KK({displayMode:o,renderMode:n}),c=S.useRef(null),u=S.useRef(null),[d,f]=S.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:b}=sot({initialPosition:"bottom-right"}),x=kf(J=>J.setFullscreen),y=kf(J=>J.setPanelOpen),w=kf(J=>J.setContainer),v=PY("dashboard"),C=FY(),N=OY("dashboard"),k=v.isOpen,_=C==="dashboard",j=p.useDashboardStore(J=>J.isVisualEditing),E=p.useDashboardStore(J=>J.themeStyle),I=Dc(),T=p.useDashboardStore(J=>{var ee;return(ee=J.dashboard)==null?void 0:ee.sheets}),D=p.useDashboardStore(J=>J.showFilters),R=p.useDashboardStore(J=>J.isDashboardEditing),F=p.useDashboardStore(J=>J.selectedSheetId),A=T==null?void 0:T.find(J=>J.id===F),U=p.useDashboardStore(J=>{var ee,te,ue;return(ue=(te=(ee=J.dashboard)==null?void 0:ee.sheets)==null?void 0:te.find(le=>le.id===J.selectedSheetId))==null?void 0:ue.kind}),$=p.useDashboardStore(J=>{var ee,te;return((te=(ee=J.dashboard)==null?void 0:ee.summary)==null?void 0:te.position)||"top"}),q=U==="document",W=p.useDashboardStore(J=>{var ee;return(ee=J.dashboard)==null?void 0:ee.id}),{getDefaultSheetId:O,setDefaultSheetId:Z,clearDefaultSheetId:Y}=$q(W),[M,K]=S.useState(null),{setSelectedSheetId:L,setSheetTitle:z,addSheet:B,setSheets:V}=p.useDashboardActions();Q0t(u);const{setActiveAssistantType:P}=p.useAIActions();S.useEffect(()=>{if(W){const J=O();K(J)}},[W,O]),S.useEffect(()=>{k?P("dashboard"):C==="dashboard"&&x(null)},[k,P,C,x]),S.useEffect(()=>{var J;k||(J=c.current)==null||J.resize(0)},[k]);function H(J){var ee,te;J?((ee=c.current)==null||ee.resize(40),y("dashboard",!0),x("dashboard"),P("dashboard")):(y("dashboard",!1),x(null),(te=c.current)==null||te.resize(0),P(null))}function G(J="dashboard"){const ee={id:p.v4(),title:J==="document"?"New Document":"New Sheet",...J==="document"?{kind:J,document:p.createDefaultDocumentDefinition()}:{}};B(ee),L(ee.id)}function X(J,ee){if(!W)return;M===J?(Y(),K(null),et.success("Default sheet cleared")):(Z(J),K(J),et.success(`"${ee}" set as default sheet`))}function ne(J){var ee;J<1?(y("dashboard",!1),x(null),P(null),(ee=c.current)==null||ee.resize(0)):(k||y("dashboard",!0),P("dashboard"))}function de(){return(E==null?void 0:E.canvasTheme)==="muted"||!(E!=null&&E.canvasTheme)?"hsl(var(--semaphor-muted))":(E==null?void 0:E.canvasTheme)==="clear"?"":E==null?void 0:E.canvasTheme}const he=(J,ee)=>{J.dataTransfer.setData("tabIndex",ee.toString())},pe=J=>{J.preventDefault()},xe=(J,ee)=>{const te=J.dataTransfer.getData("tabIndex");if(te===ee.toString())return;const ue=Array.from(T||[]),[le]=ue.splice(parseInt(te),1);ue.splice(ee,0,le),V(ue)},se=r===!0&&!i&&!k&&!j&&!D;function ge(){if(T&&T.length>1||R)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[T==null?void 0:T.map((J,ee)=>{const te=F===J.id,ue=M===J.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:le=>he(le,ee),onDragOver:pe,onDrop:le=>xe(le,ee),onClick:()=>L(J.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:J.id,children:[J.kind==="document"&&l.jsx(di,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(uN,{enabled:R&&te,text:J.title,onSave:le=>z(J.id,le),children:J.title},J.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ue?"Clear default sheet":"Set as default sheet",title:ue?"Clear default sheet":"Set as default sheet",onClick:le=>{le.stopPropagation(),X(J.id,J.title||"Sheet")},onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),le.stopPropagation(),X(J.id,J.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",te||ue?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(CW,{className:p.cn("h-3 w-3 transition-colors",ue?"fill-current text-amber-500":"text-muted-foreground")})}),R&&te&&T.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:le=>{le.stopPropagation(),f(!0)},onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),le.stopPropagation(),f(!0))},children:l.jsx(p.X,{className:"h-3 w-3"})})]},J.id)}),R&&l.jsxs(zs,{children:[l.jsx(Bs,{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(Ns,{align:"start",className:"w-48",children:[l.jsxs(vn,{onSelect:()=>G("dashboard"),children:[l.jsx(Gf,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(vn,{onSelect:()=>G("document"),children:[l.jsx(di,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function ie(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:T==null?void 0:T.map(J=>l.jsx(p.TabsContent,{style:{backgroundColor:de(),...I.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:J.id,children:l.jsx(G7,{sheet:J})},J.id))})}function Te(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",E==null?void 0:E.dashboardTabsContainer),onValueChange:J=>{L(J)},value:F||void 0,children:[ge(),$==="top"&&!q&&l.jsx(RA,{}),F&&!q&&l.jsx(wvt,{}),q?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:ie()}):l.jsx(Ea,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:ie()}),$==="bottom"&&!q&&l.jsx(RA,{}),l.jsx(oot,{open:d,setOpen:f})]})}const re=S.useCallback(J=>{w("dashboard",J)},[w]);return T?a&&F&&!q?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',F,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&q&&A?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(G7,{sheet:A})}):l.jsxs(l.Fragment,{children:[l.jsx(ivt,{}),l.jsx(uvt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Tce,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",_&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(oR,{children:Te()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(rot,{open:k,onTabClick:H,withHandle:!0,disabled:!k}),l.jsx(oR,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ne,defaultSize:k?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(X0t,{open:k,setOpen:H,isFullscreen:_,onFullscreenChange:J=>x(J?"dashboard":null),fullscreenContainer:N})})})]})]}),l.jsx("div",{ref:re,className:p.cn("absolute inset-0",!_&&"pointer-events-none")}),se&&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||H(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Epe,{className:"h-5 w-5"})})})]})]}):null}const Zfe=S.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:s,children:o,className:i,style:a,...c},u)=>{const d=S.useId(),f=S.useMemo(()=>Svt(d),[d]),{theme:h}=OR(),m=Cvt(h),g=S.useMemo(()=>s??kc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,s,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(Ag,{...c,ref:u,className:i,style:a,children:o})})});Zfe.displayName="AppearanceProvider";function Svt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function Cvt(e){const t=BS(e),[n,r]=S.useState(()=>Nvt());return S.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const s=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!s)return;const o=()=>{r(s.matches?"dark":"light")};return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):((a=s.addListener)==null||a.call(s,o),()=>{var c;return(c=s.removeListener)==null?void 0:c.call(s,o)})},[t]),t==="system"?n:t}function Nvt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const Xfe=S.createContext({openBrandStudioPreview:()=>{}}),kvt=Xfe.Provider;function _vt(){return S.useContext(Xfe)}function jvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const s=BS(t),[o,i]=S.useState(()=>Ivt(n)||s),a=S.useCallback(u=>{const d=BS(u);Evt(n,d),i(d)},[n]),c=S.useMemo(()=>({theme:o,setTheme:a}),[o,a]);return l.jsx(bq.Provider,{...r,value:c,children:e})}function Ivt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=BS(t,"system");return n===t?n:null}catch{return null}}function Evt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const Tvt=S.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function Y3({appearance:e,children:t}){var T,D;const{authToken:n,id:r,tokenProps:s}=ht(),o=_0(),i=(T=o.data)==null?void 0:T.organizationAppearance,a=(D=s.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=`${s.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,v=Dn({queryKey:jG({resourceType:Kr.DASHBOARD,apiServiceUrl:s.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${s.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:R=>(R==null?void 0:R.organizationAppearance)??null,enabled:!o.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,k=S.useMemo(()=>kc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),_=S.useCallback(()=>{f(g??h??k),u(!0)},[g,h,k]),j=S.useCallback(()=>{u(!1)},[]);S.useEffect(()=>{f(null),m(null),b(null),u(!1)},[r]);const E=S.useMemo(()=>({openBrandStudioPreview:_}),[_]),I=g??h??e;return l.jsx(jvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(kvt,{value:E,children:l.jsx(Zfe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:I,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(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(Tvt,{appearance:d,onDraftChange:b,onSave:R=>{m(R),b(R),f(R)},onCancel:j})})})]})})})})}function Qfe({children:e,preferences:t}){const{currentUser:n}=Ki(),r=S.useMemo(()=>{var s,o;return{preferences:t||{},isLocalDev:((s=t==null?void 0:t.uiMode)==null?void 0:s.developer)||!1,isConsoleMode:((o=t==null?void 0:t.uiMode)==null?void 0:o.console)||!1}},[t]);return l.jsx(NG.Provider,{value:r,children:l.jsx(Q_,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Dvt(e=2e3,t=500){const n=Ume(),[r,s]=S.useState(!1),[o,i]=S.useState(!1),a=S.useRef(null);return S.useEffect(()=>{const c=setTimeout(()=>s(!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]),o}function K3({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const s=Dvt(e,t);return S.useEffect(()=>(s&&(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()}}),[s,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:s?"ready":""})}function Jfe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ka,{FallbackComponent:Z_,children:l.jsxs(HR,{dashboardProps:e,children:[l.jsx(K3,{componentType:"dashboard",componentId:e.id}),l.jsx(Y3,{appearance:e.appearance,children:l.jsx(Qfe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(wP,{...e,type:"dashboard",children:l.jsx(Kfe,{})})})})})]})})}function Mvt(e=[]){const t=S.useRef(null),n=S.useRef(null),r=S.useRef(null),[s,o]=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);o(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:s,updateAvailableWidth:i}}function Avt({filter:e}){var g;const t=p.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=Yp(),r=Dh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),s=p.useDashboardStore(b=>b.filterValues),o=s==null?void 0:s.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=Mvt([t,o,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(Ho,{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(U5,{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(p.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Rvt(){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(Avt,{filter:r}),l.jsx(H_,{filter:r})]},r.id))}):null}function Pvt(){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),s=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),o=p.isDocumentSheet(s);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&&!o&&l.jsx(Rvt,{}),l.jsx(Kfe,{})]})})}const Fvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-CRqnPibB.js"))),Ovt=S.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-wDOcHak3.js"))),Lvt=S.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-DEQqRR1x.js")));function $vt({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),s=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:o,preferences:i}=n;return l.jsx(ka,{FallbackComponent:Z_,children:l.jsxs(HR,{dashboardProps:n,children:[l.jsx(K3,{componentType:"surfboard",componentId:n.id}),l.jsxs(Y3,{appearance:o,children:[l.jsx(Pbe,{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(Qfe,{preferences:i,children:[s&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Lvt,{})}),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(Fvt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(wP,{...n,type:"dashboard",children:[r&&l.jsx(S.Suspense,{fallback:null,children:l.jsx(Ovt,{})}),l.jsx(Pvt,{})]})})})]})]})]})]})})}var zvt=Object.defineProperty,Bvt=(e,t,n)=>t in e?zvt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W1=(e,t,n)=>Bvt(e,typeof t!="symbol"?t+"":t,n);const Vvt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},Hvt={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}},Uvt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function qvt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function ehe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const Wvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const s=ehe(t);if(typeof n<"u"&&s in n.container)return n.container[s]})();return typeof r=="function"?r.bind(n):void 0}},Gvt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},Yvt={stringify:e=>e,parse:e=>e},$D={string:Yvt,number:Gvt,boolean:Vvt,function:Hvt,method:Wvt,json:Uvt},Bb=Symbol.for("r2wc.render"),G1=Symbol.for("r2wc.connected"),Od=Symbol.for("r2wc.context"),Qo=Symbol.for("r2wc.props");function Kvt(e,t,n){var r,s,o;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=qvt(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(),W1(this,o,!0),W1(this,s),W1(this,r,{}),W1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Qo].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?$D[y]:null;if(y==="method"){const v=ehe(b);Object.defineProperty(this[Qo].container,v,{enumerable:!0,configurable:!0,get(){return this[Qo][v]},set(C){this[Qo][v]=C,this[Bb]()}}),this[Qo][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Qo][g]=w.parse(x,b,this))}for(const g of a)this[Qo][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[G1]=!0,this[Bb]()}disconnectedCallback(){this[G1]=!1,this[Od]&&n.unmount(this[Od]),delete this[Od]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],v=w?$D[w]:null;y in c&&v!=null&&v.parse&&x&&(this[Qo][y]=v.parse(x,g,this),this[Bb]())}[(o=G1,s=Od,r=Qo,Bb)](){this[G1]&&(this[Od]?n.update(this[Od],this[Qo]):this[Od]=n.mount(this.container,e,this[Qo]))}}for(const m of i){const g=d[m],b=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Qo][m]},set(x){this[Qo][m]=x;const y=b?$D[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[Bb]()}})}return h}function Zvt(e,t,n){const r=Ihe.createRoot(e),s=S.createElement(t,n);return r.render(s),{root:r,ReactComponent:t}}function Xvt({root:e,ReactComponent:t},n){const r=S.createElement(t,n);e.render(r)}function Qvt({root:e}){e.unmount()}function Jvt(e,t={}){return Kvt(e,t,{mount:Zvt,update:Xvt,unmount:Qvt})}const ewt={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"},twt=Jvt(Jfe,{props:ewt}),nwt=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(UL,{context:t})," "]})}),the=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),rwt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),swt=Array.from(the).join(", "),owt=3,iwt="Self-heal",awt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function lwt({card:e}){var W,O,Z,Y,M;const[t,n]=S.useState({}),{authToken:r}=ht(),s=p.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:o}=p.useAppearance(),i=S.useMemo(()=>Nv(o),[o]),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}=$h(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(O=m==null?void 0:m.visuals)==null?void 0:O.find(K=>{var L;return K.name===((L=f.customCardPreferences)==null?void 0:L.componentName)}),b=kv(f,g)??"single",x=S.useMemo(()=>K5({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=S.useMemo(()=>{const K=x.findIndex(L=>(L==null?void 0:L.id)===e.id);return K<0?-1:qy(e,K)},[x,e]),w=S.useMemo(()=>b!=="multiple"||y<0?e.type:Ym(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}=Ak(v),N=p.useInteractionStore(K=>K.interactionStates),k=p.useDashboardStore(K=>{var L;return(L=K.dashboard)==null?void 0:L.id}),_=p.useDashboardStore(K=>K.dashboard.filters),j=p.useDashboardStore(K=>K.filterValues),E=p.useDashboardStore(K=>K.selectedSheetId),I=S.useMemo(()=>W5({card:e,sheetId:E||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,E,c,u,d]),{cardFilters:T,cardFilterValues:D}=S.useMemo(()=>B0({card:e,interactionStates:N,currentDashboardId:k,filters:_,filterValues:j,selectedSheetId:E}),[e,N,k,_,j,E]),R=S.useCallback((K,L)=>{const z=X5(L);n(B=>({...B,[K]:z}))},[]),F=(Z=f.customCardPreferences)==null?void 0:Z.componentName,A=F?h(F):null,U=lN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),$=S.useMemo(()=>Y5(x),[x]),q=S.useMemo(()=>$.map((K,L)=>Ym(K,L,g==null?void 0:g.slots)),[$,g==null?void 0:g.slots]);return F?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:[A&&b==="single"&&l.jsx(A,{editing:!0,params:s,theme:i,settings:U,cardMetadata:Foe({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:R,data:(C==null?void 0:C.records)||[],filters:T,filterValues:[...D||[],...c||[]],inlineFilters:I}),A&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,L)=>{if(!K)return null;const z=qy(K,L),B=Ym(K,z,g==null?void 0:g.slots);return l.jsx(x5,{onDataChange:R,card:K,effectiveCardType:B},`${K.id}-${z}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(A,{editing:!0,onDataChange:R,...Q5({configCard:f,slotOrderedCards:$,slotTypes:q,multiInputData:t,params:s,theme:i,chartSettings:U,filters:T,filterValues:[...D||[],...c||[]],inlineFilters:I})})})]})]},(M=f.customCardPreferences)==null?void 0:M.componentName)}):null}const cwt=S.memo(lwt,(e,t)=>{var n,r,s,o,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)&&((s=e.card.customCardPreferences)==null?void 0:s.slotSettings)===((o=t.card.customCardPreferences)==null?void 0:o.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)}),uwt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(s=>s.type===n&&s.id===r),toggleStar:n=>{e(r=>{const s=r.starredCharts.findIndex(o=>o.type===n.type&&o.id===n.id);return s>=0?{starredCharts:r.starredCharts.filter((o,i)=>i!==s)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(s=>s.type===n&&s.id===r)}),{name:"semaphor-starred-charts"}));var nhe=["PageUp","PageDown"],rhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],she={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Gg="Slider",[MR,dwt,fwt]=p.createCollection(Gg),[ohe]=p.createContextScope(Gg,[fwt]),[hwt,Wj]=ohe(Gg),ihe=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:s=100,step:o=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"?mwt:pwt,[C=[],N]=p.useControllableState({prop:d,defaultProp:u,onChange:T=>{var R;(R=[...x.current][y.current])==null||R.focus(),f(T)}}),k=Q.useRef(C);function _(T){const D=vwt(C,T);I(T,D)}function j(T){I(T,y.current)}function E(){const T=k.current[y.current];C[y.current]!==T&&h(C)}function I(T,D,{commit:R}={commit:!1}){const F=Nwt(o),A=kwt(Math.round((T-r)/o)*o+r,F),U=p.clamp(A,[r,s]);N(($=[])=>{const q=xwt($,U,D);if(Cwt(q,c*o)){y.current=q.indexOf(U);const W=String(q)!==String($);return W&&R&&h(q),W?q:$}else return $})}return l.jsx(hwt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(MR.Provider,{scope:e.__scopeSlider,children:l.jsx(MR.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||(k.current=C)}),min:r,max:s,inverted:m,onSlideStart:a?void 0:_,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:E,onHomeKeyDown:()=>!a&&I(r,0,{commit:!0}),onEndKeyDown:()=>!a&&I(s,C.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:D})=>{if(!a){const A=nhe.includes(T.key)||T.shiftKey&&rhe.includes(T.key)?10:1,U=y.current,$=C[U],q=o*A*D;I($+q,U,{commit:!0})}}})})})})});ihe.displayName=Gg;var[ahe,lhe]=ohe(Gg,{startEdge:"left",endEdge:"right",size:"width",direction:1}),mwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:s,inverted:o,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(s),x=b==="ltr",y=x&&!o||!x&&o;function w(v){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],_=Z3(N,y?[n,r]:[r,n]);return g.current=C,_(v-C.left)}return l.jsx(ahe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(che,{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=she[y?"from-left":"from-right"].includes(v.key);u==null||u({event:v,direction:N?-1:1})}})})}),pwt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=p.useComposedRefs(t,d),h=Q.useRef(void 0),m=!s;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],v=Z3(y,m?[r,n]:[n,r]);return h.current=x,v(b-x.top)}return l.jsx(ahe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(che,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);o==null||o(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=she[m?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),che=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=Wj(Gg,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()):nhe.concat(rhe).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)&&s(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),uhe="SliderTrack",dhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=Wj(uhe,n);return l.jsx(p.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:t})});dhe.displayName=uhe;var AR="SliderRange",fhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=Wj(AR,n),o=lhe(AR,n),i=Q.useRef(null),a=p.useComposedRefs(t,i),c=s.values.length,u=s.values.map(h=>phe(h,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});fhe.displayName=AR;var RR="SliderThumb",hhe=Q.forwardRef((e,t)=>{const n=dwt(e.__scopeSlider),[r,s]=Q.useState(null),o=p.useComposedRefs(t,a=>s(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(gwt,{...e,ref:o,index:i})}),gwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:s,...o}=e,i=Wj(RR,n),a=lhe(RR,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:phe(m,i.min,i.max),b=ywt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?wwt(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(MR.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,...o,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(mhe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});hhe.displayName=RR;var bwt="RadioBubbleInput",mhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const s=Q.useRef(null),o=p.useComposedRefs(s,r),i=p.usePrevious(t);return Q.useEffect(()=>{const a=s.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:o,defaultValue:t})});mhe.displayName=bwt;function xwt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((s,o)=>s-o)}function phe(e,t,n){const o=100/(n-t)*(e-t);return p.clamp(o,[0,100])}function ywt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function vwt(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),r=Math.min(...n);return n.indexOf(r)}function wwt(e,t,n){const r=e/2,o=Z3([0,50],[0,r]);return(r-o(t)*n)*n}function Swt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Cwt(e,t){if(t>0){const n=Swt(e);return Math.min(...n)>=t}return!0}function Z3(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 Nwt(e){return(String(e).split(".")[1]||"").length}function kwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var ghe=ihe,_wt=dhe,jwt=fhe,Iwt=hhe;const bhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(ghe,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(_wt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(jwt,{className:"absolute h-full bg-primary"})}),l.jsx(Iwt,{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"})]}));bhe.displayName=ghe.displayName;const xhe=["SUN","MON","TUE","WED","THU","FRI","SAT"],Ewt=xhe.reduce((e,t,n)=>({...e,[t]:n}),{}),Ll={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function Twt(e){if(!e||!e.trim())return{...Ll};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{...Ll,isCustom:!0};const[s,o,i,a,c]=r,u=Number(s),d=Number(o);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...Ll,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...Ll,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(m=>m.toUpperCase()).map(m=>Ewt[m]).filter(m=>typeof m=="number");if(h.length>0)return{...Ll,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...Ll,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...Ll,repeats:"monthly",hour:d,minute:u}:{...Ll,hour:d,minute:u,isCustom:!0}}function Dwt(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((s,o)=>s-o).map(s=>xhe[s]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function yhe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,s=t.toString().padStart(2,"0");return`${r}:${s} ${n}`}function Mwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Awt(e){if(e.length===7)return"every day";const t=e.slice().sort((s,o)=>s-o);if(t.length===5&&t.every(s=>s>=1&&s<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(s=>r[s]).join(", ")}function Rwt(e,t,n,r){const s=yhe(e.hour,e.minute),o=Mwt(t);let i;if(e.isCustom)i=`Custom schedule · ${s} ${o}`;else switch(e.repeats){case"daily":i=`Daily at ${s} ${o}`;break;case"weekly":i=`Weekly · ${Awt(e.weekdays)} at ${s} ${o}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${s} ${o}`;break;case"monthly":i=`Monthly on the 1st at ${s} ${o}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Pwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=FL;exports.AccordionContent=r0;exports.AccordionItem=t0;exports.AccordionTrigger=n0;exports.AddDataPicker=N3;exports.AggregateTable=x_;exports.Alert=mF;exports.AlertDescription=pF;exports.AlertDialog=kh;exports.AlertDialogAction=ad;exports.AlertDialogCancel=ld;exports.AlertDialogContent=nd;exports.AlertDialogDescription=id;exports.AlertDialogFooter=sd;exports.AlertDialogHeader=rd;exports.AlertDialogTitle=od;exports.AlertDialogTrigger=tye;exports.AlertTitle=UZ;exports.ArrowDown=ps;exports.ArrowDownIcon=Aqe;exports.ArrowLeft=I0;exports.ArrowRight=XN;exports.ArrowUp=Ms;exports.ArrowUpIcon=Pqe;exports.AssistantContextEntityControls=bR;exports.AssistantVirtualizedMessages=qfe;exports.AtSign=Uq;exports.AxisConfigurator=rg;exports.Badge=ls;exports.Bell=Z1;exports.BookType=Wq;exports.BulletChartIcon=Ofe;exports.COMMON_TIMEZONES=Pwt;exports.CSS=bi;exports.CalculatedFieldEditor=Yae;exports.Calculator=Yq;exports.Calendar=ii;exports.Calendar$1=CS;exports.CalendarRange=Kq;exports.Card=ry;exports.CardContent=YR;exports.CardHeader=GR;exports.CardSummary=BA;exports.CardTitle=Gp;exports.ChartArea=c2;exports.ChartColumnIncreasing=Zq;exports.ChartColumnStacked=Xq;exports.ChartJsVisual=gv;exports.ChartLine=Qq;exports.ChartNoAxesGantt=eW;exports.ChartPie=tW;exports.ChartScatter=nW;exports.ChatInputWithContext=k3;exports.Checkbox=Mn;exports.ChevronLeft=wh;exports.ChevronRight=Bn;exports.ChevronsUpDown=oW;exports.Circle=KR;exports.CircleAlert=qf;exports.CircleCheck=iW;exports.CircleHelp=aW;exports.Clock=ZR;exports.CodeHighlighter=Vf;exports.CodeXml=X1;exports.Collapsible=Sc;exports.CollapsibleContent=Nc;exports.CollapsibleTrigger=Cc;exports.ColorField=Ai;exports.Command=cj;exports.CommandEmpty=dj;exports.CommandGroup=fj;exports.CommandInput=NL;exports.CommandItem=hj;exports.CommandList=uj;exports.CommandSeparator=mae;exports.ComparisonMetadataBadge=pee;exports.Container=wP;exports.ControlDefaultValueEditor=gle;exports.ControlDefinitionOptionsEditor=ple;exports.ControlIdInput=dle;exports.ControlVisibilitySettings=Wet;exports.Copy=Tu;exports.CopyButton=Iu;exports.CopyPlus=d2;exports.Cross2Icon=$qe;exports.CustomFilterPopover=U5;exports.CustomScrollArea=Ea;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=bJ;exports.DEFAULT_SCHEDULE_VM=Ll;exports.Dashboard=Jfe;exports.DashboardCard=vie;exports.DashboardCreateDialogBase=eY;exports.DashboardExportDialog=Wfe;exports.DashboardPlus=$vt;exports.DashboardWC=twt;exports.DataTableConditionalFormattingSettings=sce;exports.DataTablePagination=a_;exports.Database=zi;exports.DateRangePicker=N5;exports.DefaultChatTransport=g3;exports.Dialog=_o;exports.DialogContent=ao;exports.DialogDescription=Go;exports.DialogFooter=Ic;exports.DialogHeader=Zi;exports.DialogTitle=lo;exports.DialogTrigger=XG;exports.DisplayPreferencesProvider=Q_;exports.DndContext=Fv;exports.Donut=lW;exports.Download=_c;exports.DownloadPdf=Gfe;exports.DragOverlay=eae;exports.DropdownMenu=zs;exports.DropdownMenuCheckboxItem=Kc;exports.DropdownMenuContent=Ns;exports.DropdownMenuItem=vn;exports.DropdownMenuLabel=da;exports.DropdownMenuRadioGroup=lbe;exports.DropdownMenuRadioItem=CG;exports.DropdownMenuSeparator=Ui;exports.DropdownMenuSub=fP;exports.DropdownMenuSubContent=ik;exports.DropdownMenuSubTrigger=ok;exports.DropdownMenuTrigger=Bs;exports.EMPTY_DATA_SOURCE=Up;exports.Editable=uN;exports.EditableText=Ho;exports.EditorCustomVisual=cwt;exports.Ellipsis=ui;exports.EllipsisVertical=Sh;exports.ErrorBoundary=ka;exports.ExportError=ug;exports.ExternalLink=hp;exports.Eye=E0;exports.EyeOff=QN;exports.Fallback=Z_;exports.FallbackVisual=Gy;exports.FeedbackCategory=ed;exports.FeedbackDialog=g0;exports.FieldsList=UL;exports.FieldsSection=nwt;exports.FileCode=cW;exports.FileSpreadsheet=uW;exports.FileText=di;exports.Filter=Wf;exports.FilterComponent=H_;exports.FilterInfo=OA;exports.FilterableFieldsPanel=Zae;exports.Globe=Ch;exports.Grid3x3=f2;exports.GripVertical=jc;exports.HEATMAP_PRESET_PALETTES=xM;exports.Hash=dW;exports.House=fW;exports.HoverCard=dg;exports.HoverCardContent=Bu;exports.HoverCardTrigger=fg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=the;exports.INLINE_ALLOWED_TOOL_LIST=swt;exports.INLINE_BLOCKED_MUTATING_TOOLS=rwt;exports.IconButton=cc;exports.IconForFieldType=TS;exports.InfoHover=fL;exports.InlineFilterBar=uie;exports.KPICard=Yu;exports.KeyboardSensor=Rv;exports.Layers=T0;exports.LayoutDashboard=Gf;exports.Link=XR;exports.LoadingDots=Hu;exports.Lock=JN;exports.MAX_SELF_HEAL_ATTEMPTS=owt;exports.Map=pW;exports.Markdown=Jde;exports.MatrixTableVisual=b_;exports.Maximize2=ek;exports.MdStackedLineChart=Pfe;exports.Minimize2=QR;exports.MultiInputEmptyRenderer=x5;exports.PYTHON_DEFAULT_CODE=FR;exports.PanelResizeHandle=Tj;exports.Paperclip=gW;exports.PenLine=h2;exports.Pencil=m2;exports.PendingMessagesDisplay=mde;exports.PersistedDynamicVisual=X_;exports.PiChartPolar=Dfe;exports.Pin=xW;exports.PinOff=bW;exports.PivotTableTanstack=Mg;exports.Placeholders=Dce;exports.Play=yW;exports.Plus=kr;exports.PointerSensor=Lg;exports.Progress=S3;exports.RECOVERABLE_SQL_ERROR_CODES=awt;exports.Radar=vW;exports.RadioGroup=Sa;exports.RadioGroupItem=ws;exports.RefreshCw=Yf;exports.ResizableHandle=not;exports.ResizablePanel=oR;exports.ResizablePanelGroup=Tce;exports.ResourceEditDialog=DY;exports.ResourceType=Kr;exports.SELF_HEAL_TIMELINE_STEP=iwt;exports.Search=$s;exports.SeedQuestions=Jue;exports.SemaphorContext=k0;exports.SemaphorContextProvider=HR;exports.SemaphorQueryClient=Lq;exports.SemaphorReadyIndicator=K3;exports.SemaphorStyleWrapper=Ag;exports.Send=wW;exports.Settings=JR;exports.Settings2=D0;exports.Share2=SW;exports.ShareDialog=TY;exports.Sheet=ree;exports.SheetContent=pO;exports.SheetDescription=bO;exports.SheetHeader=oee;exports.SheetTitle=gO;exports.SheetTrigger=GPe;exports.Slider=bhe;exports.SortableContext=Ov;exports.Sparkles=GS;exports.Square=tP;exports.SquarePen=eP;exports.Star=CW;exports.StructuralParticipantSelector=fle;exports.SummaryCard=RA;exports.TABLE_PRESENTATION_DEFAULT_STYLE=_u;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Fi;exports.TableBody=zu;exports.TableCell=Tn;exports.TableColumnVisibilitySettings=Wle;exports.TableHead=es;exports.TableHeader=Ph;exports.TablePresentationSettings=Yle;exports.TableRow=wr;exports.TableSkeleton=hL;exports.TableVisual=Vu;exports.TbChartBubble=Mfe;exports.TbChartFunnel=Afe;exports.TbChartTreemap=Rfe;exports.TextCard=Op;exports.Textarea=jh;exports.TiSortNumerically=Ffe;exports.Toggle=Y_;exports.Tornado=NW;exports.Trash2=fl;exports.TreePalm=rP;exports.TrendingUp=kW;exports.TriangleAlert=Bi;exports.TypeGlyph=Ev;exports.UXProvider=Y3;exports.User=_W;exports.Users=nk;exports.applyFilterOverridesToDashboardInputSlots=uZ;exports.areContextEntitiesEqual=Qn;exports.areEntitiesJoined=SJ;exports.arrayMove=$g;exports.buildCardControlUsageById=Yet;exports.buildCustomCardTheme=Nv;exports.buildDashboardCardExecutionSnapshot=cZ;exports.buildDashboardControlUsageById=Get;exports.buildDashboardExecutionSnapshot=lF;exports.buildDashboardInputExecutionSnapshot=vu;exports.buildDashboardSheetsInputExecutionSnapshot=fZ;exports.buildDashboardStructuralParticipantIdsByControlId=yle;exports.buildFilterFieldMeta=TL;exports.buildFilterSemanticContext=DL;exports.buildInlineFilterNodes=W5;exports.buildMultiInputCustomVisualProps=Q5;exports.buildScheduleExpr=Dwt;exports.buildSchedulePreview=Rwt;exports.buildSlotOrderedCards=Y5;exports.calculateContextAwareFilters=B0;exports.calculateFieldState=iO;exports.canUserAccessVisuals=a0e;exports.canUserCreateDashboards=RY;exports.canUserEdit=s0e;exports.canUserManageDashboards=i0e;exports.canUserManageGroups=l0e;exports.canUserUseFilters=o0e;exports.cancelExport=FRe;exports.chartSupportsDataLabels=mQ;exports.chartSupportsLegend=fQ;exports.chartTypes=qj;exports.cleanupKpiMetricComparisonMode=Sae;exports.cloneDeep=$o;exports.cloneLinkedFrameWithSourceMapping=XGe;exports.closestCenter=Av;exports.commitSharedCalculatedFields=Wd;exports.createAssistantConversationId=Im;exports.createAssistantRequestId=Xue;exports.createCardsFromSlots=fWe;exports.createChartConfig=cg;exports.createDashboardControlInputFromControl=Hrt;exports.createDefaultGlobalDateFilter=pSe;exports.createExport=VJ;exports.createUniqueDashboardInputVariableNameFromName=Eu;exports.dedup=Xut;exports.doesStoredFilterMatchField=Vp;exports.downloadDocumentPdf=uF;exports.downloadPdf=vZ;exports.extractSqlParamReferences=Nse;exports.extractTableMetadata=EL;exports.fieldAlreadyExists=NJ;exports.findCustomVisualConfigCard=Z5;exports.findDashboardFrameById=iSe;exports.flexRender=Bo;exports.formatDisplayFormula=zQe;exports.formatFileSize=$Re;exports.formatFilterLine=WZ;exports.formatTimeLabel=yhe;exports.getAutoDetectedChartIcon=h0t;exports.getChartGridStyle=$Ne;exports.getChartIconByType=m0t;exports.getColorForValue=P2;exports.getConfigSlotExpectedType=dWe;exports.getCoreRowModel=s_;exports.getCustomVisualInputCards=K5;exports.getDateFormatOptionsForGranularity=Jy;exports.getDefaultAxisConfig=O2;exports.getDefaultChartColors=Mh;exports.getDefaultDataLabelsConfig=J0;exports.getDefaultExportFormat=cX;exports.getDefaultFilterSql=E5;exports.getDefaultLegendConfig=HF;exports.getDefaultRunningTotalPartitionByFieldIds=Yx;exports.getDocumentSectionEditorCard=ket;exports.getDocumentSheetDashboardInputs=Vv;exports.getDownloadUrl=PRe;exports.getEffectiveCardTypeForSlot=Ym;exports.getEntityIcon=BN;exports.getErrorMessage=$ue;exports.getExportStatus=RRe;exports.getExports=ARe;exports.getExpressionFieldKind=Zu;exports.getFieldExpressionAnnotation=ML;exports.getFilterCount=pN;exports.getGlobalDateFilter=Xp;exports.getGlobalDateFilterCoverage=gSe;exports.getGranularityOptionsForFieldType=ZL;exports.getKeys=lr;exports.getMatrixVisualLoadingState=g_;exports.getMetricDisplayLabel=tRe;exports.getNewField=EJ;exports.getObjectDiff=xq;exports.getPaginationRowModel=o_;exports.getRoleBasedDisplayOverrides=AY;exports.getRunningTotalOrderByCandidates=cQe;exports.getSelectedDateFilterColumn=_se;exports.getSheetScopedFilterValues=cy;exports.getSlotDefinitionForIndex=G5;exports.getSlotExpectedChartType=W_;exports.getSlotIndexForCard=qy;exports.getSortedRowModel=tee;exports.getSupportedExportFormats=lX;exports.getTableConditionalFormattingColumnOptions=Qle;exports.getTableOutputColumnOptions=Jle;exports.getTablePageSizeOptions=$J;exports.handleAggregationChange=LA;exports.handleAggregationLabelChange=lie;exports.hasFlatTableTotalsBehavior=uCe;exports.hasMatrixResultData=rv;exports.horizontalListSortingStrategy=vL;exports.isCalculatedFilterField=e0;exports.isCardSummaryVisibleOnCard=J5;exports.isCustomVisualConfigCard=MA;exports.isDefaultColor=yCe;exports.isEligibleFlatTableTotalsCard=Qp;exports.isExportComplete=LRe;exports.isExportInProgress=ORe;exports.isInAiScopeArray=Zut;exports.isManagedCalculatedExpressionField=xa;exports.isMetricTransformEnabled=aQe;exports.isPromiseLike=gR;exports.isSubtotalEnabledAggregateTable=IL;exports.isSupportedDocumentTableCardType=_et;exports.lastAssistantMessageIsCompleteWithToolCalls=Pue;exports.merge=dl;exports.mergeAxisConfig=L2;exports.normalizeConditionalFormatting=tF;exports.normalizeContextFormatMode=QZ;exports.normalizeDashboardInputVariableName=j0;exports.normalizeMultiInputPayload=X5;exports.parseScheduleExpr=Twt;exports.pivotData=W0;exports.prepareFeedbackData=Uj;exports.purify=fA;exports.reindexSlotCards=uWe;exports.remarkGfm=jfe;exports.removeFromScopeArray=Qut;exports.resolveDashboardInputContext=Nl;exports.resolveDomainCalculatedFieldForEdit=PJe;exports.resolveMultiInputType=kv;exports.resolveMultiInputTypeFromVisual=hWe;exports.resolveTablePageSize=t_;exports.resolveTablePresentationStyle=kO;exports.sanitizeAIScope=Lue;exports.saveCalculatedFieldToCardScope=ZA;exports.saveCalculatedFieldToSharedScope=Kae;exports.saveCalculatedFieldToSheetScope=XA;exports.seedSemanticMetricFormatDefaults=Nae;exports.setTableColumnVisibility=qJ;exports.setupEditorWithCard=Rk;exports.showAllTableColumns=HRe;exports.showJoinRequiredNotification=CJ;exports.sortByColumnsToSortState=kee;exports.sortStateToSortByColumns=_ee;exports.sortableKeyboardCoordinates=SL;exports.supportsMetricTransformForMetric=Cae;exports.supportsTableConditionalFormatting=Kle;exports.toEntityArray=ba;exports.ue=et;exports.useActiveExports=g0e;exports.useActiveToolStatus=gde;exports.useAddFrameWithFreshSemanticExecutionPayload=dL;exports.useAddNewFrame=Tie;exports.useAssistantContainer=OY;exports.useAssistantContextEntities=ej;exports.useAssistantLayoutStore=kf;exports.useAssistantPanel=PY;exports.useAssistantProfile=Que;exports.useAutoSubmitQueue=pde;exports.useBrandStudioPreview=_vt;exports.useCard=hRe;exports.useCardFilterValues=DJ;exports.useCardSummary=eL;exports.useChat=Oue;exports.useColumns=kL;exports.useCreateVisualWithFrame=sxe;exports.useCurrentUserInfo=Ki;exports.useCustomVisual=$h;exports.useCustomVisualsQuery=H5;exports.useDashboardAppearance=Dc;exports.useDashboardById=MG;exports.useDashboardPreferences=Yp;exports.useDashboardQuery=_0;exports.useDashboardStructuralParticipants=vle;exports.useDashboardSummary=qoe;exports.useDataColumns=_ae;exports.useDateFilterHook=U9e;exports.useDebounce=Vx;exports.useDefaultDashboardMutation=kG;exports.useDisplayPreferences=Cl;exports.useDroppable=Jie;exports.useEditorAside=mj;exports.useEditorCardQuery=Ak;exports.useEnsureReactGlobals=Jre;exports.useExportActions=LY;exports.useExportStore=mk;exports.useFieldManagement=kae;exports.useFilterableFields=yae;exports.useFullscreenAssistant=FY;exports.useGroupMembers=iye;exports.useGroups=SY;exports.useHasDashboardId=$Y;exports.useInProgressExportsCount=b0e;exports.useJoinabilityMap=jL;exports.useManagementActions=vh;exports.useManagementStore=Os;exports.useMutation=so;exports.usePivotTableConfig=Rh;exports.usePluginQuery=Doe;exports.useQuery=Dn;exports.useQueryClient=Zr;exports.useReactTable=i_;exports.useResolveExistingFrameSemanticExecutionPayload=tYe;exports.useResourceManagement=mP;exports.useResourceUpdateState=AG;exports.useScopedFields=xae;exports.useSelectedVisual=Gme;exports.useSemaphorContext=ht;exports.useSensor=Bp;exports.useSensors=sj;exports.useSortable=zg;exports.useStarredChartsStore=uwt;exports.useSurfaceAppearance=Tc;exports.useTableQueryState=gee;exports.useTextFilterHook=t7e;exports.useTheme=OR;exports.useTopoJson=tv;exports.useUnifiedUsers=yP;exports.useUpdateResource=IG;exports.useUpdateVisualMutation=oxe;exports.useUserPreferences=tY;exports.useVisualById=lk;exports.useVisualManagement=rxe;exports.validateFieldForChartType=wae;exports.verticalListSortingStrategy=wL;