react-semaphor 0.0.399 → 0.0.400
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{index-CdM_qEx2.js → index-BQjgev3I.js} +5 -0
- package/dist/chunks/{index-CW6yUvdJ.js → index-BsAoJTv_.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +3 -3
- package/dist/types/dashboard.d.ts +8 -0
- package/dist/types/main.d.ts +11 -0
- package/dist/types/surfboard.d.ts +8 -0
- package/dist/types/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -4189,6 +4189,11 @@ const ae = lP()(
|
|
|
4189
4189
|
}, n.showContext = !1, n.selectedSheetId = null, n.selectedCardId = null, n.selectedFrameId = null, n.selectedCard = null, n.showFilters = !1, n.isDashboardEditing = !1, n.isVisualEditing = !1, n.showDashboardJSON = !1, n.filteringCards = [], n.selectedLensId = void 0, n.filterValues = void 0;
|
|
4190
4190
|
});
|
|
4191
4191
|
},
|
|
4192
|
+
updateEmailSettings: (n) => {
|
|
4193
|
+
e((r) => {
|
|
4194
|
+
r.dashboard.emailSettings = n;
|
|
4195
|
+
});
|
|
4196
|
+
},
|
|
4192
4197
|
setIsDownloadingPdf: (n) => {
|
|
4193
4198
|
e((r) => {
|
|
4194
4199
|
r.isDownloadingPdf = n;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*/var bC;function J6(){return bC||(bC=1,process.env.NODE_ENV!=="production"&&function(){function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=E,n=fx(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;Bm.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=a(function(){function y(S){if(!x){if(x=!0,v=S,S=h(S),f!==void 0&&g.hasValue){var R=g.value;if(f(R,S))return _=R}return _=S}if(R=_,r(v,S))return R;var P=h(S);return f!==void 0&&f(R,P)?(v=S,R):(v=S,_=P)}var x=!1,v,_,w=d===void 0?null:d;return[function(){return y(u())},w===null?void 0:function(){return y(w())}]},[u,d,h,f]);var m=o(c,p[0],p[1]);return s(function(){g.hasValue=!0,g.value=m},[m]),l(m),m},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Bm}process.env.NODE_ENV==="production"?Ay.exports=Z6():Ay.exports=J6();var e8=Ay.exports;const t8=Qi(e8),dP={},{useDebugValue:n8}=E,{useSyncExternalStoreWithSelector:r8}=t8;let yC=!1;const o8=e=>e;function i8(e,t=o8,n){(dP?"production":void 0)!=="production"&&n&&!yC&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),yC=!0);const r=r8(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return n8(r),r}const s8=e=>{(dP?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?K6(e):e,n=(r,o)=>i8(t,r,o);return Object.assign(n,t),n},fP=e=>s8;var hP=Symbol.for("immer-nothing"),vC=Symbol.for("immer-draftable"),mr=Symbol.for("immer-state"),a8=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Un(e,...t){if(process.env.NODE_ENV!=="production"){const n=a8[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ol=Object.getPrototypeOf;function Tl(e){return!!e&&!!e[mr]}function na(e){var t;return e?pP(e)||Array.isArray(e)||!!e[vC]||!!((t=e.constructor)!=null&&t[vC])||Bp(e)||Vp(e):!1}var l8=Object.prototype.constructor.toString();function pP(e){if(!e||typeof e!="object")return!1;const t=Ol(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===l8}function Mh(e,t){zp(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function zp(e){const t=e[mr];return t?t.type_:Array.isArray(e)?1:Bp(e)?2:Vp(e)?3:0}function Ny(e,t){return zp(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function gP(e,t,n){const r=zp(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function c8(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Bp(e){return e instanceof Map}function Vp(e){return e instanceof Set}function ys(e){return e.copy_||e.base_}function Fy(e,t){if(Bp(e))return new Map(e);if(Vp(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=pP(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[mr];let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++){const s=o[i],a=r[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create(Ol(e),r)}else{const r=Ol(e);if(r!==null&&n)return{...e};const o=Object.create(r);return Object.assign(o,e)}}function hx(e,t=!1){return Hp(e)||Tl(e)||!na(e)||(zp(e)>1&&(e.set=e.add=e.clear=e.delete=u8),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>hx(r,!0))),e}function u8(){Un(2)}function Hp(e){return Object.isFrozen(e)}var d8={};function ra(e){const t=d8[e];return t||Un(0,e),t}var ku;function mP(){return ku}function f8(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function xC(e,t){t&&(ra("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function jy(e){Ly(e),e.drafts_.forEach(h8),e.drafts_=null}function Ly(e){e===ku&&(ku=e.parent_)}function wC(e){return ku=f8(ku,e)}function h8(e){const t=e[mr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function SC(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[mr].modified_&&(jy(t),Un(4)),na(e)&&(e=Oh(t,e),t.parent_||Th(t,e)),t.patches_&&ra("Patches").generateReplacementPatches_(n[mr].base_,e,t.patches_,t.inversePatches_)):e=Oh(t,n,[]),jy(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==hP?e:void 0}function Oh(e,t,n){if(Hp(t))return t;const r=t[mr];if(!r)return Mh(t,(o,i)=>CC(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Th(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let i=o,s=!1;r.type_===3&&(i=new Set(o),o.clear(),s=!0),Mh(i,(a,l)=>CC(e,r,o,a,l,n,s)),Th(e,o,!1),n&&e.patches_&&ra("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function CC(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&Un(5),Tl(o)){const a=i&&t&&t.type_!==3&&!Ny(t.assigned_,r)?i.concat(r):void 0,l=Oh(e,o,a);if(gP(n,r,l),Tl(l))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(na(o)&&!Hp(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Oh(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&Th(e,o)}}function Th(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&hx(t,n)}function p8(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:mP(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=px;n&&(o=[r],i=Pu);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var px={get(e,t){if(t===mr)return e;const n=ys(e);if(!Ny(n,t))return g8(e,n,t);const r=n[t];return e.finalized_||!na(r)?r:r===Vm(e.base_,t)?(Hm(e),e.copy_[t]=zy(r,e)):r},has(e,t){return t in ys(e)},ownKeys(e){return Reflect.ownKeys(ys(e))},set(e,t,n){const r=bP(ys(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Vm(ys(e),t),i=o==null?void 0:o[mr];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(c8(n,o)&&(n!==void 0||Ny(e.base_,t)))return!0;Hm(e),$y(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Vm(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Hm(e),$y(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ys(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Un(11)},getPrototypeOf(e){return Ol(e.base_)},setPrototypeOf(){Un(12)}},Pu={};Mh(px,(e,t)=>{Pu[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Pu.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Un(13),Pu.set.call(this,e,t,void 0)};Pu.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Un(14),px.set.call(this,e[0],t,n,e[0])};function Vm(e,t){const n=e[mr];return(n?ys(n):e)[t]}function g8(e,t,n){var o;const r=bP(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function bP(e,t){if(!(t in e))return;let n=Ol(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ol(n)}}function $y(e){e.modified_||(e.modified_=!0,e.parent_&&$y(e.parent_))}function Hm(e){e.copy_||(e.copy_=Fy(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var m8=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(l=i,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Un(6),r!==void 0&&typeof r!="function"&&Un(7);let o;if(na(t)){const i=wC(this),s=zy(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?jy(i):Ly(i)}return xC(i,r),SC(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===hP&&(o=void 0),this.autoFreeze_&&hx(o,!0),r){const i=[],s=[];ra("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else Un(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let r,o;return[this.produce(t,n,(s,a)=>{r=s,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){na(e)||Un(8),Tl(e)&&(e=b8(e));const t=wC(this),n=zy(e,void 0);return n[mr].isManual_=!0,Ly(t),n}finishDraft(e,t){const n=e&&e[mr];(!n||!n.isManual_)&&Un(9);const{scope_:r}=n;return xC(r,t),SC(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=ra("Patches").applyPatches_;return Tl(e)?r(e,t):this.produce(e,o=>r(o,t))}};function zy(e,t){const n=Bp(e)?ra("MapSet").proxyMap_(e,t):Vp(e)?ra("MapSet").proxySet_(e,t):p8(e,t);return(t?t.scope_:mP()).drafts_.push(n),n}function b8(e){return Tl(e)||Un(10,e),yP(e)}function yP(e){if(!na(e)||Hp(e))return e;const t=e[mr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Fy(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Fy(e,!0);return Mh(n,(r,o)=>{gP(n,r,yP(o))}),t&&(t.finalized_=!1),n}var br=new m8,y8=br.produce;br.produceWithPatches.bind(br);br.setAutoFreeze.bind(br);br.setUseStrictShallowCopy.bind(br);br.applyPatches.bind(br);br.createDraft.bind(br);br.finishDraft.bind(br);const v8=e=>(t,n,r)=>(r.setState=(o,i,...s)=>{const a=typeof o=="function"?y8(o):o;return t(a,i,...s)},e(r.setState,n,r)),vP=v8;var By,of=mn;if(process.env.NODE_ENV==="production")By=of.createRoot,of.hydrateRoot;else{var _C=of.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;By=function(e,t){_C.usingClientEntryPoint=!0;try{return of.createRoot(e,t)}finally{_C.usingClientEntryPoint=!1}}}var xP={},wP={},gx={exports:{}},$e=String,SP=function(){return{isColorSupported:!1,reset:$e,bold:$e,dim:$e,italic:$e,underline:$e,inverse:$e,hidden:$e,strikethrough:$e,black:$e,red:$e,green:$e,yellow:$e,blue:$e,magenta:$e,cyan:$e,white:$e,gray:$e,bgBlack:$e,bgRed:$e,bgGreen:$e,bgYellow:$e,bgBlue:$e,bgMagenta:$e,bgCyan:$e,bgWhite:$e,blackBright:$e,redBright:$e,greenBright:$e,yellowBright:$e,blueBright:$e,magentaBright:$e,cyanBright:$e,whiteBright:$e,bgBlackBright:$e,bgRedBright:$e,bgGreenBright:$e,bgYellowBright:$e,bgBlueBright:$e,bgMagentaBright:$e,bgCyanBright:$e,bgWhiteBright:$e}};gx.exports=SP();gx.exports.createColors=SP;var x8=gx.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,c){for(var u in c)Object.defineProperty(l,u,{enumerable:!0,get:c[u]})}t(e,{dim:function(){return s},default:function(){return a}});const n=r(x8);function r(l){return l&&l.__esModule?l:{default:l}}let o=new Set;function i(l,c,u){typeof process<"u"&&process.env.JEST_WORKER_ID||u&&o.has(u)||(u&&o.add(u),console.warn(""),c.forEach(d=>console.warn(l,"-",d)))}function s(l){return n.default.dim(l)}const a={info(l,c){i(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[c,l])},warn(l,c){i(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[c,l])},risk(l,c){i(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[c,l])}}})(wP);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const t=n(wP);function n(i){return i&&i.__esModule?i:{default:i}}function r({version:i,from:s,to:a}){t.default.warn(`${s}-color-renamed`,[`As of Tailwind CSS ${i}, \`${s}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const o={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}})(xP);let Wm=xP;var w8=(Wm.__esModule?Wm:{default:Wm}).default;const Qe=Qi(w8),S8=!1,mx=`import pandas as pd
|
|
34
34
|
df = pd.DataFrame(data) # 'data' contains the query result
|
|
35
35
|
result = df.to_dict('records') # must return 'result' as [dict] type
|
|
36
|
-
`,Dh="dm",Vy=[{locale:"en-US",currency:"USD",currencyName:"US Dollar"},{locale:"en-GB",currency:"GBP",currencyName:"British Pound"},{locale:"en-CA",currency:"CAD",currencyName:"Canadian Dollar"},{locale:"en-AU",currency:"AUD",currencyName:"Australian Dollar"},{locale:"en-IN",currency:"INR",currencyName:"Indian Rupee"},{locale:"ja-JP",currency:"JPY",currencyName:"Japanese Yen"},{locale:"de-DE",currency:"EUR",currencyName:"Germany (Eurozone)"},{locale:"fr-FR",currency:"EUR",currencyName:"France (Eurozone)"},{locale:"es-ES",currency:"EUR",currencyName:"Spain (Eurozone)"},{locale:"it-IT",currency:"EUR",currencyName:"Italy (Eurozone)"},{locale:"fi-FI",currency:"EUR",currencyName:"Finland (Eurozone)"},{locale:"nl-NL",currency:"EUR",currencyName:"Netherlands (Eurozone)"},{locale:"zh-CN",currency:"CNY",currencyName:"Chinese Yuan"},{locale:"ru-RU",currency:"RUB",currencyName:"Russian Ruble"},{locale:"pt-BR",currency:"BRL",currencyName:"Brazilian Real"},{locale:"ko-KR",currency:"KRW",currencyName:"South Korean Won"},{locale:"ar-SA",currency:"SAR",currencyName:"Saudi Riyal"},{locale:"sv-SE",currency:"SEK",currencyName:"Swedish Krona"},{locale:"no-NO",currency:"NOK",currencyName:"Norwegian Krone"},{locale:"da-DK",currency:"DKK",currencyName:"Danish Krone"},{locale:"pl-PL",currency:"PLN",currencyName:"Polish Zloty"},{locale:"tr-TR",currency:"TRY",currencyName:"Turkish Lira"},{locale:"he-IL",currency:"ILS",currencyName:"Israeli Shekel"},{locale:"th-TH",currency:"THB",currencyName:"Thai Baht"},{locale:"vi-VN",currency:"VND",currencyName:"Vietnamese Dong"},{locale:"id-ID",currency:"IDR",currencyName:"Indonesian Rupiah"},{locale:"mx-MX",currency:"MXN",currencyName:"Mexican Peso"},{locale:"za-ZA",currency:"ZAR",currencyName:"South African Rand"},{locale:"sg-SG",currency:"SGD",currencyName:"Singapore Dollar"},{locale:"hk-HK",currency:"HKD",currencyName:"Hong Kong Dollar"},{locale:"ch-CH",currency:"CHF",currencyName:"Swiss Franc"},{locale:"my-MY",currency:"MYR",currencyName:"Malaysian Ringgit"},{locale:"ph-PH",currency:"PHP",currencyName:"Philippine Peso"},{locale:"eg-EG",currency:"EGP",currencyName:"Egyptian Pound"},{locale:"nz-NZ",currency:"NZD",currencyName:"New Zealand Dollar"}],C8=[{label:"English",locales:[{code:"en-US",name:"US English"},{code:"en-GB",name:"British English"},{code:"en-AU",name:"Australian English"},{code:"en-CA",name:"Canadian English"}]},{label:"French",locales:[{code:"fr-FR",name:"France French"},{code:"fr-CA",name:"Canadian French"}]},{label:"Spanish",locales:[{code:"es-ES",name:"Spain Spanish"},{code:"es-MX",name:"Mexican Spanish"},{code:"es-419",name:"Latin American Spanish"}]},{label:"German",locales:[{code:"de-DE",name:"Germany German"},{code:"de-CH",name:"Swiss German"}]},{label:"Chinese",locales:[{code:"zh-CN",name:"Simplified Chinese (China)"},{code:"zh-TW",name:"Traditional Chinese (Taiwan)"},{code:"zh-HK",name:"Hong Kong Chinese"}]},{label:"Japanese",locales:[{code:"ja-JP",name:"Japanese"}]},{label:"Arabic",locales:[{code:"ar-EG",name:"Egypt Arabic"},{code:"ar-SA",name:"Saudi Arabia Arabic"}]},{label:"Russian",locales:[{code:"ru-RU",name:"Russian"}]},{label:"Portuguese",locales:[{code:"pt-PT",name:"Portugal Portuguese"},{code:"pt-BR",name:"Brazil Portuguese"}]},{label:"Indian Languages",locales:[{code:"hi-IN",name:"Hindi (India)"},{code:"ta-IN",name:"Tamil (India)"}]},{label:"Korean",locales:[{code:"ko-KR",name:"Korean"}]},{label:"Italian",locales:[{code:"it-IT",name:"Italian (Italy)"}]},{label:"Dutch",locales:[{code:"nl-NL",name:"Dutch (Netherlands)"}]},{label:"Swedish",locales:[{code:"sv-SE",name:"Swedish (Sweden)"}]},{label:"Turkish",locales:[{code:"tr-TR",name:"Turkish (Turkey)"}]},{label:"Hebrew",locales:[{code:"he-IL",name:"Hebrew (Israel)"}]},{label:"Thai",locales:[{code:"th-TH",name:"Thai (Thailand)"}]},{label:"Polish",locales:[{code:"pl-PL",name:"Polish (Poland)"}]},{label:"Greek",locales:[{code:"el-GR",name:"Greek (Greece)"}]},{label:"Norwegian",locales:[{code:"no-NO",name:"Norwegian (Norway)"}]}],bx=["lg","md","sm","xs","xxs"],Ih={default:{dashboardPanel:"",dashboardTabsContainer:"",gridLayout:{className:""},chart:{font:{family:"Open Sans, Arial, sans-serif"},dataset:{backgroundColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]],borderColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]]},options:{interaction:{mode:"index"},plugins:{datalabels:{display:!1,color:Hy},title:{display:!0},tooltip:{backgroundColor:"#fff",bodyColor:"#000",borderWidth:.25,titleColor:"#000",borderColor:"rgb(128,131,139)",cornerRadius:4,usePointStyle:!0,pointStyle:"rectRounded",boxPadding:4},legend:{position:"top",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},scales:{y:{grid:{display:!0},title:{display:!0,text:""},beginAtZero:!0,ticks:{precision:0}},x:{grid:{display:!0},title:{display:!0}}},layout:{padding:{top:-40}},borderRadius:2,responsive:!0,maintainAspectRatio:!1}}},dark:{chart:{dataset:{backgroundColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]],borderColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]],datalables:{color:Hy}},options:{plugins:{tooltip:{backgroundColor:"#000",bodyColor:"#fff",borderWidth:.25,titleColor:"#fff",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4}},datalabels:{display:!1},scales:{x:{grid:{display:!0,color:Qe.slate[800]}},y:{grid:{display:!0,color:Qe.slate[800]}}}}}}};function Hy(e){var r,o,i,s,a,l;const t=(a=(s=(i=(o=(r=e==null?void 0:e.chart)==null?void 0:r.config)==null?void 0:o._config)==null?void 0:i.options)==null?void 0:s.plugins)==null?void 0:a.datalabels;let n=(l=e==null?void 0:e.dataset)==null?void 0:l.backgroundColor;return(t==null?void 0:t.align)==="end"&&(t==null?void 0:t.anchor)==="end"&&(n=Mu()),(t==null?void 0:t.align)==="start"&&(t==null?void 0:t.anchor)==="start"&&(n=Mu()),Dl(n)}function Mu(){return ie.getState().theme==="dark"?"#000000":"#FFFFFF"}function Dl(e){let t=0,n=0,r=0,o=0;const i=u=>{if(!u)return Qe.gray[500];const d=u.replace("#",""),h=parseInt(d.substring(0,2),16),f=parseInt(d.substring(2,4),16),p=parseInt(d.substring(4,6),16);t+=h,n+=f,r+=p,o++};Array.isArray(e)?e.forEach(u=>{i(u)}):i(e);const s=t/o,a=n/o,l=r/o;return(s*299+a*587+l*114)/1e3>=180?"black":"white"}const _8=["text","name","enum","varchar","nvarchar","nvarchar2","char","character","longtext","nchar","char varying","nchar varying","character varying","string"],E8=["number","integer","int","int64","bigint","smallint","tinyint","byteint","numeric","decimal","dec","double","real","double precision","float","float4","float8","float64"],R8=["date","datetime","time","timestamp","timestamp without time zone","timestamp_ns"],k8=["boolean"];function yx(e){return e.match(/[A-Z]/)?`"${e}"`:e}function Wp(e){return _8.includes(e.toLowerCase())||/varchar/i.test(e)}function pd(e){return E8.includes(e.toLowerCase())||/int|decimal|float|double/i.test(e)}function tc(e){return R8.includes(e.toLowerCase())||/date|time|timestamp/i.test(e)}function vx(e){return k8.includes(e.toLowerCase())||/boolean/i.test(e)}function P8(e,t,n,r,o){const{measures:i,dimensions:s}=e,a=i==null?void 0:i.map(d=>`${d.calc}(${d.name}) as ${d.calc}_${d.name.replace(/"/g,"")}`).join(", "),l=(s==null?void 0:s.join(", "))||"";let c="";const u=r?`${Dh}.${r}`:xx(t,n,o);if(a&&l)return c=`SELECT ${l}, COUNT(*) as count, ${a} FROM ${u} GROUP BY ${l} ORDER BY ${l} DESC LIMIT 100`,c;if(!a&&l)return c=`SELECT ${l}, COUNT(*) as count FROM ${u} GROUP BY ${l} ORDER BY ${l} DESC LIMIT 100`,c;if(a&&!l)return c=`SELECT ${a} FROM ${u} LIMIT 100`,c}function M8(e,t,n="AVG"){var i,s,a,l;let r={};const o=yx(e.column_name);return Wp(e.data_type)&&(((i=t.dimensions)==null?void 0:i.includes(o))?r={...t,dimensions:(s=t.dimensions)==null?void 0:s.filter(u=>u!==o)}:r={...t,dimensions:[...t.dimensions||[],o]}),pd(e.data_type)&&(((a=t.measures)==null?void 0:a.some(u=>u.name===o&&u.calc===n))?r={...t,measures:(l=t.measures)==null?void 0:l.filter(u=>!(u.name===o&&u.calc===n))}:r={...t,measures:[...t.measures||[],{name:o,calc:n||"SUM"}]}),r}function el(e){return Wp(e.dataType)?"string":pd(e.dataType)?"number":tc(e.dataType)?"date":vx(e.dataType)?"boolean":"string"}function O8(e){let t;const n=e.data_type.toLowerCase();return Wp(n)?t="T":pd(n)?t="#":tc(n)?t="D":vx(n)?t="B":t="?",t}function T8(e,t){const{dimensions:n,measures:r}=t,o=n==null?void 0:n.includes(e.column_name),i=r==null?void 0:r.some(s=>s.name===e.column_name);return o||i}function CP(e){return e?e!=null&&e.startsWith(`${Dh}.`)?e:`${Dh}.${e}`:""}function _P({schemaName:e,tableName:t,modelName:n,connectionType:r}){let o=xx(e,t,r);n&&(o=CP(n));let i=o;return(a=>/[A-Z]/.test(a))(t)&&(i=i.split(".").map(l=>`"${l}"`).join(".")),i}function xx(e,t,n){return t==="api"||e===yx("NA")||n==="S3"||n==="API"?t:e?`${e}.${t}`:`${t}`}const D8=e=>{const t=new Date(e);return!isNaN(t.getTime())},I8=e=>!isNaN(Number(e))&&!isNaN(parseFloat(e)),Up=e=>{let t;return typeof e=="number"?t="number":typeof e=="string"?D8(e)?t="date":I8(e)?t="number":t="string":typeof e=="boolean"?t="boolean":e instanceof Date?t="date":t="unknown",t};function A8({get:e,dataPoint:t,card:n}){var h;const{addOrUpdateFilterValue:r,addFilteringCard:o,removeFilterValues:i,replaceFilterValue:s,removeFilteringCard:a}=e().actions,l=e().filteringCards,{columnName:c,columnValue:u}=t,d={filterId:n.id,connectionId:n==null?void 0:n.connectionId,tableName:n.lastSelectedTable,name:c,expression:(h=n.preferences)==null?void 0:h.filterOnClickField,valueType:Up(u),operation:"=",values:[u]};if(l!=null&&l.find(f=>f.id===n.id)){const f=n.id;if(u==null){a(n),i(f);return}else s(d)}o(n),r(d)}function EC({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10},l=t?{...t}:{};return bx.forEach(c=>{l[c]||(l[c]=[]);const u=l[c].reduce((d,h)=>Math.max(d,h.y+h.h),0);a.y=a.y===1/0?u:a.y,l[c].push({...a})}),l}function RC(e,t){if(!t)return;const n={...t};return bx.forEach(r=>{n[r]&&(n[r]=n[r].filter(o=>o.i!==e))}),n}function wx(e){const t=ie.getState().dashboard.globalCacheConfig,{card:n,filter:r}=e;return t}const ie=fP()(vP((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:Ih},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{setInitStore:()=>{e(n=>{n.isSessionExpired=!1,n.currentBreakpoint="lg",n.dashboard={id:"",style:Ih},n.showContext=!1,n.selectedSheetId=null,n.selectedCardId=null,n.selectedFrameId=null,n.selectedCard=null,n.showFilters=!1,n.isDashboardEditing=!1,n.isVisualEditing=!1,n.showDashboardJSON=!1,n.filteringCards=[],n.selectedLensId=void 0,n.filterValues=void 0})},setIsDownloadingPdf:n=>{e(r=>{r.isDownloadingPdf=n})},setGlobalCacheConfig:n=>{e(r=>{r.dashboard.globalCacheConfig=n})},setLenses:n=>{e(r=>{r.lenses=n})},setSelectedLensId:n=>{e(r=>{r.selectedLensId=n})},deleteSheet:n=>{e(r=>{var i,s,a,l,c,u,d,h;const o=(i=r.dashboard.sheets)==null?void 0:i.findIndex(f=>f.id===n);if(o!==void 0&&o>-1){(s=r.dashboard.sheets)==null||s.splice(o,1);const f=(a=r.dashboard.filters)==null?void 0:a.filter(g=>g.sheetId===n),p=(l=r.filterValues)==null?void 0:l.filter(g=>f==null?void 0:f.some(m=>m.id===g.filterId));r.filterValues=(c=r.filterValues)==null?void 0:c.filter(g=>!(p!=null&&p.some(m=>m.filterId===g.filterId))),r.dashboard.filters=(u=r.dashboard.filters)==null?void 0:u.filter(g=>g.sheetId!==n),r.selectedSheetId=(h=(d=r.dashboard.sheets)==null?void 0:d[0])==null?void 0:h.id}})},addSheet:n=>{e(r=>{r.dashboard.sheets||(r.dashboard.sheets=[]);const o=r.dashboard.filters;let i={};o==null||o.forEach(a=>{bx.forEach(l=>{i!=null&&i[l]||(i={...i,[l]:[]});const c={i:a.id,x:0,y:0,w:10,h:8};i[l].push(c)})});const s={...n,layouts:i};r.dashboard.sheets.push(s)})},setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},addToAIScope:n=>{e(r=>{const{connectionId:o,connectionType:i,databaseName:s,schemaName:a,tableName:l,datamodelName:c,datamodelId:u}=n,d={connectionId:o||"",connectionType:i||"",databaseName:s||"",schemaName:a||"",tableName:l||"",datamodelName:c||"",datamodelId:u||""};let f=[...r.dashboard.aiScopeTables||[],d];f=f.filter((p,g,m)=>m.findIndex(y=>y.tableName===p.tableName&&y.datamodelName===p.datamodelName)===g),r.dashboard.aiScopeTables=f})},removeFromAIScope:n=>{e(r=>{const{connectionId:o,tableName:i,datamodelName:s}=n,a=r.dashboard.aiScopeTables||[];if(s){const l=a.filter(c=>!(c.datamodelName===s&&c.connectionId===o));r.dashboard.aiScopeTables=l}else if(i){const l=a.filter(c=>!(c.tableName===i&&c.connectionId===o));r.dashboard.aiScopeTables=l}})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===o.selectedSheetId);i&&((l=i==null?void 0:i.frames)==null||l.forEach(c=>{var d;const u=(d=c.cards)==null?void 0:d.find(h=>h.id===n);u&&(u.python=r)}))})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},setFilteringCards:n=>{e(()=>({filteringCards:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setDashboardWithFilterValues:(n,r)=>{e(o=>{o.dashboard=n,o.filterValues=r})},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.title=r)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l,c;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(u=>u.id===n);s&&((c=s==null?void 0:s.frames)==null||c.forEach(u=>{var h;const d=(h=u.cards)==null?void 0:h.find(f=>f.id===r);d&&(d.title=o)}))})},setCardInfo:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===o.selectedSheetId);i&&((l=i==null?void 0:i.frames)==null||l.forEach(c=>{var d;const u=(d=c.cards)==null?void 0:d.find(h=>h.id===n);u&&(u.info=r)}))})},setCardDescription:(n,r,o)=>{e(i=>{var a,l,c;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(u=>u.id===n);s&&((c=s==null?void 0:s.frames)==null||c.forEach(u=>{var h;const d=(h=u.cards)==null?void 0:h.find(f=>f.id===r);d&&(d.description=o)}))})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(d=>d.id===n);if(s){const d=(c=s.cards)==null?void 0:c.find(h=>h.id===r);d&&(d.sql=o,(u=i.onUpdateCard)==null||u.call(i,d,n))}})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValues:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n],(s=r.dashboard.sheets)==null||s.find(a=>a.id===r.selectedSheetId);const o=r.dashboard.sheets;o==null||o.forEach(a=>{EC({id:n.id,layouts:a.layouts,y:0,initialHeight:8,minH:7,w:10})})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1),(s=r.dashboard.sheets)==null||s.find(c=>c.id===r.selectedSheetId);const l=r.dashboard.sheets;l==null||l.forEach(c=>{const u=RC(n,c.layouts);c.layouts=u})}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,d,h;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(f=>f.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(f=>f.id===r);if(a){const f=(d=a.cards)==null?void 0:d.findIndex(p=>p.id===o.id);f>-1&&((h=a.cards)==null||h.splice(f,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},updateFilterId:(n,r)=>{e(o=>{var a,l;const i=(a=o.dashboard.filters)==null?void 0:a.find(c=>c.id===n),s=(l=o.dashboard.filters)==null?void 0:l.some(c=>c.id===r);i&&!s&&(i.id=r)})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(d=>d.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let d=1/0;const h=0;o==="start"&&(d=0);const f=EC({id:r.id,layouts:s.layouts,minH:10,x:h,y:d});s.layouts=f,(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(d=>d.id===n);if(i){const d=(l=i.frames)==null?void 0:l.findIndex(h=>h.id===r);console.log(d),typeof d=="number"&&d>-1&&((c=i.frames)==null||c.splice(d,1),(u=i.layout)==null||u.splice(d,1),RC(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u,d;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r)),(d=o.onAcceptChanges)==null||d.call(o,r,o.dashboard)})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,d;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(d=o.onUpdateCard)==null||d.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,d,h;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(f=>f.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(d=i.layout)==null||d.splice(s,1),(h=o.onRemoveCard)==null||h.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnAcceptChanges:n=>{e(()=>({onAcceptChanges:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getCardFrame:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return a[l]}}},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},getCardSheet(n){var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return r[s]}}},handleDataPointClickAction:(n,r)=>{A8({card:n,dataPoint:r,get:t})}}}))),Vt=()=>ie(e=>e.actions);async function N8(e,t){const n=t.slice(0,16),r=new TextEncoder,o=await window.crypto.subtle.importKey("raw",r.encode(n),{name:"PBKDF2"},!1,["deriveKey"]),i=await window.crypto.subtle.deriveKey({name:"PBKDF2",salt:r.encode(n),iterations:1e5,hash:"SHA-256"},o,{name:"AES-GCM",length:256},!1,["encrypt"]),s=window.crypto.getRandomValues(new Uint8Array(12)),a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,r.encode(e)),l=new Uint8Array(s.length+a.byteLength);return l.set(s,0),l.set(new Uint8Array(a),s.length),{payload:btoa(String.fromCharCode(...l))}}async function EP(e,t){const n=t.slice(0,16),r=new TextEncoder,o=new TextDecoder,i=await window.crypto.subtle.importKey("raw",r.encode(n),{name:"PBKDF2"},!1,["deriveKey"]),s=await window.crypto.subtle.deriveKey({name:"PBKDF2",salt:r.encode(n),iterations:1e5,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!1,["decrypt"]),a=Uint8Array.from(atob(e),h=>h.charCodeAt(0)),l=a.slice(0,12),c=a.slice(a.length-16),u=a.slice(12,a.length-16),d=new Uint8Array(u.length+c.length);d.set(u),d.set(c,u.length);try{const h=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:l},s,d);return{decryptedData:o.decode(h)}}catch(h){throw new Error(`Decryption failed: ${h}`)}}function se(...e){return U6(Ml(e))}const F8=e=>Object.keys(e).length===0;async function j8(e,t,n={}){try{const r=new URLSearchParams(n).toString(),o=`${e}?${r}`,i=await fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(!i.ok){const a=await i.json();throw new Error((a==null?void 0:a.error)||`HTTP error! status: ${i.status}`)}return await i.json()}catch(r){throw console.error("Error during fetch:",r),r}}async function Gp(e,t,n={}){try{const r=JSON.stringify(n),o=await N8(r,t),i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(o)});if(!i.ok)return i.json().then(a=>{throw console.log(a.detail||"Unknown error occurred"),new Error((a==null?void 0:a.error)||`HTTP error! status: ${i.status}`)});const s=await i.json();if(s.payload){const a=await EP(s.payload,t);return JSON.parse(a.decryptedData)}return s}catch(r){throw console.error("Error during fetch:",r),r}}async function L8(e,t,n={}){try{const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return r.ok?await r.json():r.json().then(i=>{throw console.log(i.detail||"Unknown error occurred"),new Error((i==null?void 0:i.error)||`HTTP error! status: ${r.status}`)})}catch(r){throw console.error("Error during fetch:",r),r}}function $8(e){if(!e)return{tenantId:"",endUserId:""};const t=ux(e);return{tenantId:t==null?void 0:t.tenantId,endUserId:t==null?void 0:t.endUserId}}function z8(e){if(!e)return;const t=ux(e);if(t.params&&t.params.currencyFormat)return t.params.currencyFormat}function RP(e){return e?ux(e).params:void 0}function B8(e){return e.charAt(0).toUpperCase()+e.slice(1)}const iu="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";async function V8(){var o,i;const e=(i=(o=ie.getState())==null?void 0:o.authToken)==null?void 0:i.accessToken;if(!e)return;const n=await fetch("https://semaphor.cloud/api/v1/invalidate-token",{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!n.ok)throw new Error("Failed to invalidate token");const r=await n.json();return console.log("invalidateToken",r),r}async function H8(e,t={}){if(!e)return null;let n="https://semaphor.cloud/api/v1/dashboard";const r=Object.fromEntries(Object.entries(t).filter(([a,l])=>l!==void 0)),o=new URLSearchParams(r).toString();o&&(n+=`?${o}`);let s=await(await fetch(n,{headers:{Authorization:`Bearer ${e}`}})).json();if("payload"in s){const a=await EP(atob(s.payload),e);s=JSON.parse(a.decryptedData)}return s}async function W8(e){return e?await(await fetch("https://semaphor.cloud/api/v1/plugins",{headers:{Authorization:`Bearer ${e}`}})).json():null}var Ah={exports:{}};Ah.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=800,i=16,s=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",h="[object Error]",f="[object Function]",p="[object GeneratorFunction]",g="[object Map]",m="[object Number]",y="[object Null]",x="[object Object]",v="[object Proxy]",_="[object RegExp]",w="[object Set]",S="[object String]",R="[object Undefined]",P="[object WeakMap]",O="[object ArrayBuffer]",D="[object DataView]",N="[object Float32Array]",A="[object Float64Array]",U="[object Int8Array]",$="[object Int16Array]",T="[object Int32Array]",F="[object Uint8Array]",I="[object Uint8ClampedArray]",j="[object Uint16Array]",H="[object Uint32Array]",M=/[\\^$.*+?()[\]{}|]/g,B=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,k={};k[N]=k[A]=k[U]=k[$]=k[T]=k[F]=k[I]=k[j]=k[H]=!0,k[a]=k[l]=k[O]=k[u]=k[D]=k[d]=k[h]=k[f]=k[g]=k[m]=k[x]=k[_]=k[w]=k[S]=k[P]=!1;var G=typeof ei=="object"&&ei&&ei.Object===Object&&ei,q=typeof self=="object"&&self&&self.Object===Object&&self,Y=G||q||Function("return this")(),V=t&&!t.nodeType&&t,W=V&&!0&&e&&!e.nodeType&&e,X=W&&W.exports===V,J=X&&G.process,ne=function(){try{var z=W&&W.require&&W.require("util").types;return z||J&&J.binding&&J.binding("util")}catch{}}(),Z=ne&&ne.isTypedArray;function oe(z,Q,re){switch(re.length){case 0:return z.call(Q);case 1:return z.call(Q,re[0]);case 2:return z.call(Q,re[0],re[1]);case 3:return z.call(Q,re[0],re[1],re[2])}return z.apply(Q,re)}function ee(z,Q){for(var re=-1,ye=Array(z);++re<z;)ye[re]=Q(re);return ye}function de(z){return function(Q){return z(Q)}}function fe(z,Q){return z==null?void 0:z[Q]}function xe(z,Q){return function(re){return z(Q(re))}}var pe=Array.prototype,be=Function.prototype,je=Object.prototype,tt=Y["__core-js_shared__"],Ht=be.toString,Ge=je.hasOwnProperty,er=function(){var z=/[^.]+$/.exec(tt&&tt.keys&&tt.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),St=je.toString,te=Ht.call(Object),ce=RegExp("^"+Ht.call(Ge).replace(M,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ve=X?Y.Buffer:void 0,ke=Y.Symbol,He=Y.Uint8Array;ve&&ve.allocUnsafe;var an=xe(Object.getPrototypeOf,Object),tr=Object.create,Sn=je.propertyIsEnumerable,In=pe.splice,ln=ke?ke.toStringTag:void 0,Ct=function(){try{var z=Pm(Object,"defineProperty");return z({},"",{}),z}catch{}}(),Zr=ve?ve.isBuffer:void 0,An=Math.max,Qd=Date.now,vc=Pm(Y,"Map"),as=Pm(Object,"create"),xc=function(){function z(){}return function(Q){if(!ls(Q))return{};if(tr)return tr(Q);z.prototype=Q;var re=new z;return z.prototype=void 0,re}}();function cn(z){var Q=-1,re=z==null?0:z.length;for(this.clear();++Q<re;){var ye=z[Q];this.set(ye[0],ye[1])}}function Em(){this.__data__=as?as(null):{},this.size=0}function De(z){var Q=this.has(z)&&delete this.__data__[z];return this.size-=Q?1:0,Q}function at(z){var Q=this.__data__;if(as){var re=Q[z];return re===r?void 0:re}return Ge.call(Q,z)?Q[z]:void 0}function yt(z){var Q=this.__data__;return as?Q[z]!==void 0:Ge.call(Q,z)}function nr(z,Q){var re=this.__data__;return this.size+=this.has(z)?0:1,re[z]=as&&Q===void 0?r:Q,this}cn.prototype.clear=Em,cn.prototype.delete=De,cn.prototype.get=at,cn.prototype.has=yt,cn.prototype.set=nr;function $t(z){var Q=-1,re=z==null?0:z.length;for(this.clear();++Q<re;){var ye=z[Q];this.set(ye[0],ye[1])}}function Jr(){this.__data__=[],this.size=0}function jo(z){var Q=this.__data__,re=Zd(Q,z);if(re<0)return!1;var ye=Q.length-1;return re==ye?Q.pop():In.call(Q,re,1),--this.size,!0}function rr(z){var Q=this.__data__,re=Zd(Q,z);return re<0?void 0:Q[re][1]}function eo(z){return Zd(this.__data__,z)>-1}function w3(z,Q){var re=this.__data__,ye=Zd(re,z);return ye<0?(++this.size,re.push([z,Q])):re[ye][1]=Q,this}$t.prototype.clear=Jr,$t.prototype.delete=jo,$t.prototype.get=rr,$t.prototype.has=eo,$t.prototype.set=w3;function Pa(z){var Q=-1,re=z==null?0:z.length;for(this.clear();++Q<re;){var ye=z[Q];this.set(ye[0],ye[1])}}function S3(){this.size=0,this.__data__={hash:new cn,map:new(vc||$t),string:new cn}}function C3(z){var Q=ef(this,z).delete(z);return this.size-=Q?1:0,Q}function _3(z){return ef(this,z).get(z)}function E3(z){return ef(this,z).has(z)}function R3(z,Q){var re=ef(this,z),ye=re.size;return re.set(z,Q),this.size+=re.size==ye?0:1,this}Pa.prototype.clear=S3,Pa.prototype.delete=C3,Pa.prototype.get=_3,Pa.prototype.has=E3,Pa.prototype.set=R3;function Ma(z){var Q=this.__data__=new $t(z);this.size=Q.size}function k3(){this.__data__=new $t,this.size=0}function P3(z){var Q=this.__data__,re=Q.delete(z);return this.size=Q.size,re}function M3(z){return this.__data__.get(z)}function O3(z){return this.__data__.has(z)}function T3(z,Q){var re=this.__data__;if(re instanceof $t){var ye=re.__data__;if(!vc||ye.length<n-1)return ye.push([z,Q]),this.size=++re.size,this;re=this.__data__=new Pa(ye)}return re.set(z,Q),this.size=re.size,this}Ma.prototype.clear=k3,Ma.prototype.delete=P3,Ma.prototype.get=M3,Ma.prototype.has=O3,Ma.prototype.set=T3;function D3(z,Q){var re=Tm(z),ye=!re&&Om(z),Xe=!re&&!ye&&nC(z),mt=!re&&!ye&&!Xe&&oC(z),Ot=re||ye||Xe||mt,rt=Ot?ee(z.length,String):[],Tt=rt.length;for(var Ar in z)Ot&&(Ar=="length"||Xe&&(Ar=="offset"||Ar=="parent")||mt&&(Ar=="buffer"||Ar=="byteLength"||Ar=="byteOffset")||eC(Ar,Tt))||rt.push(Ar);return rt}function Rm(z,Q,re){(re!==void 0&&!tf(z[Q],re)||re===void 0&&!(Q in z))&&km(z,Q,re)}function I3(z,Q,re){var ye=z[Q];(!(Ge.call(z,Q)&&tf(ye,re))||re===void 0&&!(Q in z))&&km(z,Q,re)}function Zd(z,Q){for(var re=z.length;re--;)if(tf(z[re][0],Q))return re;return-1}function km(z,Q,re){Q=="__proto__"&&Ct?Ct(z,Q,{configurable:!0,enumerable:!0,value:re,writable:!0}):z[Q]=re}var A3=q3();function Jd(z){return z==null?z===void 0?R:y:ln&&ln in Object(z)?Y3(z):e6(z)}function ZS(z){return wc(z)&&Jd(z)==a}function N3(z){if(!ls(z)||Z3(z))return!1;var Q=Im(z)?ce:B;return Q.test(o6(z))}function F3(z){return wc(z)&&rC(z.length)&&!!k[Jd(z)]}function j3(z){if(!ls(z))return J3(z);var Q=tC(z),re=[];for(var ye in z)ye=="constructor"&&(Q||!Ge.call(z,ye))||re.push(ye);return re}function JS(z,Q,re,ye,Xe){z!==Q&&A3(Q,function(mt,Ot){if(Xe||(Xe=new Ma),ls(mt))L3(z,Q,Ot,re,JS,ye,Xe);else{var rt=ye?ye(Mm(z,Ot),mt,Ot+"",z,Q,Xe):void 0;rt===void 0&&(rt=mt),Rm(z,Ot,rt)}},iC)}function L3(z,Q,re,ye,Xe,mt,Ot){var rt=Mm(z,re),Tt=Mm(Q,re),Ar=Ot.get(Tt);if(Ar){Rm(z,re,Ar);return}var or=mt?mt(rt,Tt,re+"",z,Q,Ot):void 0,Sc=or===void 0;if(Sc){var Am=Tm(Tt),Nm=!Am&&nC(Tt),aC=!Am&&!Nm&&oC(Tt);or=Tt,Am||Nm||aC?Tm(rt)?or=rt:i6(rt)?or=W3(rt):Nm?(Sc=!1,or=B3(Tt)):aC?(Sc=!1,or=H3(Tt)):or=[]:s6(Tt)||Om(Tt)?(or=rt,Om(rt)?or=a6(rt):(!ls(rt)||Im(rt))&&(or=K3(Tt))):Sc=!1}Sc&&(Ot.set(Tt,or),Xe(or,Tt,ye,mt,Ot),Ot.delete(Tt)),Rm(z,re,or)}function $3(z,Q){return n6(t6(z,Q,sC),z+"")}var z3=Ct?function(z,Q){return Ct(z,"toString",{configurable:!0,enumerable:!1,value:c6(Q),writable:!0})}:sC;function B3(z,Q){return z.slice()}function V3(z){var Q=new z.constructor(z.byteLength);return new He(Q).set(new He(z)),Q}function H3(z,Q){var re=V3(z.buffer);return new z.constructor(re,z.byteOffset,z.length)}function W3(z,Q){var re=-1,ye=z.length;for(Q||(Q=Array(ye));++re<ye;)Q[re]=z[re];return Q}function U3(z,Q,re,ye){var Xe=!re;re||(re={});for(var mt=-1,Ot=Q.length;++mt<Ot;){var rt=Q[mt],Tt=void 0;Tt===void 0&&(Tt=z[rt]),Xe?km(re,rt,Tt):I3(re,rt,Tt)}return re}function G3(z){return $3(function(Q,re){var ye=-1,Xe=re.length,mt=Xe>1?re[Xe-1]:void 0,Ot=Xe>2?re[2]:void 0;for(mt=z.length>3&&typeof mt=="function"?(Xe--,mt):void 0,Ot&&X3(re[0],re[1],Ot)&&(mt=Xe<3?void 0:mt,Xe=1),Q=Object(Q);++ye<Xe;){var rt=re[ye];rt&&z(Q,rt,ye,mt)}return Q})}function q3(z){return function(Q,re,ye){for(var Xe=-1,mt=Object(Q),Ot=ye(Q),rt=Ot.length;rt--;){var Tt=Ot[++Xe];if(re(mt[Tt],Tt,mt)===!1)break}return Q}}function ef(z,Q){var re=z.__data__;return Q3(Q)?re[typeof Q=="string"?"string":"hash"]:re.map}function Pm(z,Q){var re=fe(z,Q);return N3(re)?re:void 0}function Y3(z){var Q=Ge.call(z,ln),re=z[ln];try{z[ln]=void 0;var ye=!0}catch{}var Xe=St.call(z);return ye&&(Q?z[ln]=re:delete z[ln]),Xe}function K3(z){return typeof z.constructor=="function"&&!tC(z)?xc(an(z)):{}}function eC(z,Q){var re=typeof z;return Q=Q??s,!!Q&&(re=="number"||re!="symbol"&&L.test(z))&&z>-1&&z%1==0&&z<Q}function X3(z,Q,re){if(!ls(re))return!1;var ye=typeof Q;return(ye=="number"?Dm(re)&&eC(Q,re.length):ye=="string"&&Q in re)?tf(re[Q],z):!1}function Q3(z){var Q=typeof z;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?z!=="__proto__":z===null}function Z3(z){return!!er&&er in z}function tC(z){var Q=z&&z.constructor,re=typeof Q=="function"&&Q.prototype||je;return z===re}function J3(z){var Q=[];if(z!=null)for(var re in Object(z))Q.push(re);return Q}function e6(z){return St.call(z)}function t6(z,Q,re){return Q=An(Q===void 0?z.length-1:Q,0),function(){for(var ye=arguments,Xe=-1,mt=An(ye.length-Q,0),Ot=Array(mt);++Xe<mt;)Ot[Xe]=ye[Q+Xe];Xe=-1;for(var rt=Array(Q+1);++Xe<Q;)rt[Xe]=ye[Xe];return rt[Q]=re(Ot),oe(z,this,rt)}}function Mm(z,Q){if(!(Q==="constructor"&&typeof z[Q]=="function")&&Q!="__proto__")return z[Q]}var n6=r6(z3);function r6(z){var Q=0,re=0;return function(){var ye=Qd(),Xe=i-(ye-re);if(re=ye,Xe>0){if(++Q>=o)return arguments[0]}else Q=0;return z.apply(void 0,arguments)}}function o6(z){if(z!=null){try{return Ht.call(z)}catch{}try{return z+""}catch{}}return""}function tf(z,Q){return z===Q||z!==z&&Q!==Q}var Om=ZS(function(){return arguments}())?ZS:function(z){return wc(z)&&Ge.call(z,"callee")&&!Sn.call(z,"callee")},Tm=Array.isArray;function Dm(z){return z!=null&&rC(z.length)&&!Im(z)}function i6(z){return wc(z)&&Dm(z)}var nC=Zr||u6;function Im(z){if(!ls(z))return!1;var Q=Jd(z);return Q==f||Q==p||Q==c||Q==v}function rC(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=s}function ls(z){var Q=typeof z;return z!=null&&(Q=="object"||Q=="function")}function wc(z){return z!=null&&typeof z=="object"}function s6(z){if(!wc(z)||Jd(z)!=x)return!1;var Q=an(z);if(Q===null)return!0;var re=Ge.call(Q,"constructor")&&Q.constructor;return typeof re=="function"&&re instanceof re&&Ht.call(re)==te}var oC=Z?de(Z):F3;function a6(z){return U3(z,iC(z))}function iC(z){return Dm(z)?D3(z):j3(z)}var l6=G3(function(z,Q,re){JS(z,Q,re)});function c6(z){return function(){return z}}function sC(z){return z}function u6(){return!1}e.exports=l6})(Ah,Ah.exports);var U8=Ah.exports;const Ou=Qi(U8),G8={theme:"system",setTheme:()=>null},kP=E.createContext(G8);function q8({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=E.useState(()=>localStorage.getItem(n)||t);E.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return b.jsx(kP.Provider,{...r,value:s,children:e})}const PP=()=>{const e=E.useContext(kP);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};var gd=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(){}},oa=typeof window>"u"||"Deno"in globalThis;function _r(){}function Y8(e,t){return typeof e=="function"?e(t):e}function Wy(e){return typeof e=="number"&&e>=0&&e!==1/0}function MP(e,t){return Math.max(e+(t||0)-Date.now(),0)}function tl(e,t){return typeof e=="function"?e(t):e}function zr(e,t){return typeof e=="function"?e(t):e}function kC(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==Sx(s,t.options))return!1}else if(!Du(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function PC(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Tu(t.options.mutationKey)!==Tu(i))return!1}else if(!Du(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function Sx(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tu)(e)}function Tu(e){return JSON.stringify(e,(t,n)=>qy(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Du(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Du(e[n],t[n])):!1}function Uy(e,t){if(e===t)return e;const n=MC(e)&&MC(t);if(n||qy(e)&&qy(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(a[u]=void 0,l++):(a[u]=Uy(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function Gy(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 MC(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qy(e){if(!OC(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!OC(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function OC(e){return Object.prototype.toString.call(e)==="[object Object]"}function K8(e){return new Promise(t=>{setTimeout(t,e)})}function Yy(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 Uy(e,t)}catch(r){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}`)}return Uy(e,t)}return t}function X8(e){return e}function Q8(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Z8(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Nh=Symbol();function OP(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Nh&&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===Nh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Ns,Ci,ml,X2,J8=(X2=class extends gd{constructor(){super();Ee(this,Ns);Ee(this,Ci);Ee(this,ml);me(this,ml,t=>{if(!oa&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){K(this,Ci)||this.setEventListener(K(this,ml))}onUnsubscribe(){var t;this.hasListeners()||((t=K(this,Ci))==null||t.call(this),me(this,Ci,void 0))}setEventListener(t){var n;me(this,ml,t),(n=K(this,Ci))==null||n.call(this),me(this,Ci,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){K(this,Ns)!==t&&(me(this,Ns,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof K(this,Ns)=="boolean"?K(this,Ns):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ns=new WeakMap,Ci=new WeakMap,ml=new WeakMap,X2),Cx=new J8,bl,_i,yl,Q2,e$=(Q2=class extends gd{constructor(){super();Ee(this,bl,!0);Ee(this,_i);Ee(this,yl);me(this,yl,t=>{if(!oa&&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(){K(this,_i)||this.setEventListener(K(this,yl))}onUnsubscribe(){var t;this.hasListeners()||((t=K(this,_i))==null||t.call(this),me(this,_i,void 0))}setEventListener(t){var n;me(this,yl,t),(n=K(this,_i))==null||n.call(this),me(this,_i,t(this.setOnline.bind(this)))}setOnline(t){K(this,bl)!==t&&(me(this,bl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return K(this,bl)}},bl=new WeakMap,_i=new WeakMap,yl=new WeakMap,Q2),Fh=new e$;function Ky(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function t$(e){return Math.min(1e3*2**e,3e4)}function TP(e){return(e??"online")==="online"?Fh.isOnline():!0}var DP=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Um(e){return e instanceof DP}function IP(e){let t=!1,n=0,r=!1,o;const i=Ky(),s=g=>{var m;r||(h(new DP(g)),(m=e.abort)==null||m.call(e))},a=()=>{t=!0},l=()=>{t=!1},c=()=>Cx.isFocused()&&(e.networkMode==="always"||Fh.isOnline())&&e.canRun(),u=()=>TP(e.networkMode)&&e.canRun(),d=g=>{var m;r||(r=!0,(m=e.onSuccess)==null||m.call(e,g),o==null||o(),i.resolve(g))},h=g=>{var m;r||(r=!0,(m=e.onError)==null||m.call(e,g),o==null||o(),i.reject(g))},f=()=>new Promise(g=>{var m;o=y=>{(r||c())&&g(y)},(m=e.onPause)==null||m.call(e)}).then(()=>{var g;o=void 0,r||(g=e.onContinue)==null||g.call(e)}),p=()=>{if(r)return;let g;const m=n===0?e.initialPromise:void 0;try{g=m??e.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(d).catch(y=>{var S;if(r)return;const x=e.retry??(oa?0:3),v=e.retryDelay??t$,_=typeof v=="function"?v(n,y):v,w=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,y);if(t||!w){h(y);return}n++,(S=e.onFail)==null||S.call(e,n,y),K8(_).then(()=>c()?void 0:f()).then(()=>{t?h(y):p()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:l,canStart:u,start:()=>(u()?p():f().then(p),i)}}function n$(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=a=>setTimeout(a,0);const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||s()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var rn=n$(),Fs,Z2,AP=(Z2=class{constructor(){Ee(this,Fs)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Wy(this.gcTime)&&me(this,Fs,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(oa?1/0:5*60*1e3))}clearGcTimeout(){K(this,Fs)&&(clearTimeout(K(this,Fs)),me(this,Fs,void 0))}},Fs=new WeakMap,Z2),vl,xl,Cr,js,hn,ud,Ls,Lr,Vo,J2,r$=(J2=class extends AP{constructor(t){super();Ee(this,Lr);Ee(this,vl);Ee(this,xl);Ee(this,Cr);Ee(this,js);Ee(this,hn);Ee(this,ud);Ee(this,Ls);me(this,Ls,!1),me(this,ud,t.defaultOptions),this.setOptions(t.options),this.observers=[],me(this,js,t.client),me(this,Cr,K(this,js).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,me(this,vl,o$(this.options)),this.state=t.state??K(this,vl),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=K(this,hn))==null?void 0:t.promise}setOptions(t){this.options={...K(this,ud),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&K(this,Cr).remove(this)}setData(t,n){const r=Yy(this.state.data,t,this.options);return Ye(this,Lr,Vo).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ye(this,Lr,Vo).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=K(this,hn))==null?void 0:r.promise;return(o=K(this,hn))==null||o.cancel(t),n?n.then(_r).catch(_r):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(K(this,vl))}isActive(){return this.observers.some(t=>zr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Nh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!MP(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=K(this,hn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=K(this,hn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),K(this,Cr).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(K(this,hn)&&(K(this,Ls)?K(this,hn).cancel({revert:!0}):K(this,hn).cancelRetry()),this.scheduleGc()),K(this,Cr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ye(this,Lr,Vo).call(this,{type:"invalidate"})}fetch(t,n){var l,c,u;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(K(this,hn))return K(this,hn).continueRetry(),K(this,hn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const d=this.observers.find(h=>h.options.queryFn);d&&this.setOptions(d.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(me(this,Ls,!0),r.signal)})},i=()=>{const d=OP(this.options,n),h={client:K(this,js),queryKey:this.queryKey,meta:this.meta};return o(h),me(this,Ls,!1),this.options.persister?this.options.persister(d,h,this):d(h)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:K(this,js),state:this.state,fetchFn:i};o(s),(l=this.options.behavior)==null||l.onFetch(s,this),me(this,xl,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=s.fetchOptions)==null?void 0:c.meta))&&Ye(this,Lr,Vo).call(this,{type:"fetch",meta:(u=s.fetchOptions)==null?void 0:u.meta});const a=d=>{var h,f,p,g;Um(d)&&d.silent||Ye(this,Lr,Vo).call(this,{type:"error",error:d}),Um(d)||((f=(h=K(this,Cr).config).onError)==null||f.call(h,d,this),(g=(p=K(this,Cr).config).onSettled)==null||g.call(p,this.state.data,d,this)),this.scheduleGc()};return me(this,hn,IP({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:d=>{var h,f,p,g;if(d===void 0){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}`),a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(d)}catch(m){a(m);return}(f=(h=K(this,Cr).config).onSuccess)==null||f.call(h,d,this),(g=(p=K(this,Cr).config).onSettled)==null||g.call(p,d,this.state.error,this),this.scheduleGc()},onError:a,onFail:(d,h)=>{Ye(this,Lr,Vo).call(this,{type:"failed",failureCount:d,error:h})},onPause:()=>{Ye(this,Lr,Vo).call(this,{type:"pause"})},onContinue:()=>{Ye(this,Lr,Vo).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),K(this,hn).start()}},vl=new WeakMap,xl=new WeakMap,Cr=new WeakMap,js=new WeakMap,hn=new WeakMap,ud=new WeakMap,Ls=new WeakMap,Lr=new WeakSet,Vo=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,...NP(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Um(o)&&o.revert&&K(this,xl)?{...K(this,xl),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),rn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),K(this,Cr).notify({query:this,type:"updated",action:t})})},J2);function NP(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:TP(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function o$(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 so,eP,FP=(eP=class extends gd{constructor(t={}){super();Ee(this,so);this.config=t,me(this,so,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??Sx(o,n);let s=this.get(i);return s||(s=new r$({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){K(this,so).has(t.queryHash)||(K(this,so).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=K(this,so).get(t.queryHash);n&&(t.destroy(),n===t&&K(this,so).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){rn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return K(this,so).get(t)}getAll(){return[...K(this,so).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>kC(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>kC(t,r)):n}notify(t){rn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){rn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){rn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},so=new WeakMap,eP),ao,_n,$s,lo,vi,tP,i$=(tP=class extends AP{constructor(t){super();Ee(this,lo);Ee(this,ao);Ee(this,_n);Ee(this,$s);this.mutationId=t.mutationId,me(this,_n,t.mutationCache),me(this,ao,[]),this.state=t.state||s$(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){K(this,ao).includes(t)||(K(this,ao).push(t),this.clearGcTimeout(),K(this,_n).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){me(this,ao,K(this,ao).filter(n=>n!==t)),this.scheduleGc(),K(this,_n).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){K(this,ao).length||(this.state.status==="pending"?this.scheduleGc():K(this,_n).remove(this))}continue(){var t;return((t=K(this,$s))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,d,h,f,p,g,m,y,x,v,_,w,S,R;me(this,$s,IP({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(P,O)=>{Ye(this,lo,vi).call(this,{type:"failed",failureCount:P,error:O})},onPause:()=>{Ye(this,lo,vi).call(this,{type:"pause"})},onContinue:()=>{Ye(this,lo,vi).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>K(this,_n).canRun(this)}));const n=this.state.status==="pending",r=!K(this,$s).canStart();try{if(!n){Ye(this,lo,vi).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=K(this,_n).config).onMutate)==null?void 0:i.call(o,t,this));const O=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));O!==this.state.context&&Ye(this,lo,vi).call(this,{type:"pending",context:O,variables:t,isPaused:r})}const P=await K(this,$s).start();return await((c=(l=K(this,_n).config).onSuccess)==null?void 0:c.call(l,P,t,this.state.context,this)),await((d=(u=this.options).onSuccess)==null?void 0:d.call(u,P,t,this.state.context)),await((f=(h=K(this,_n).config).onSettled)==null?void 0:f.call(h,P,null,this.state.variables,this.state.context,this)),await((g=(p=this.options).onSettled)==null?void 0:g.call(p,P,null,t,this.state.context)),Ye(this,lo,vi).call(this,{type:"success",data:P}),P}catch(P){try{throw await((y=(m=K(this,_n).config).onError)==null?void 0:y.call(m,P,t,this.state.context,this)),await((v=(x=this.options).onError)==null?void 0:v.call(x,P,t,this.state.context)),await((w=(_=K(this,_n).config).onSettled)==null?void 0:w.call(_,void 0,P,this.state.variables,this.state.context,this)),await((R=(S=this.options).onSettled)==null?void 0:R.call(S,void 0,P,t,this.state.context)),P}finally{Ye(this,lo,vi).call(this,{type:"error",error:P})}}finally{K(this,_n).runNext(this)}}},ao=new WeakMap,_n=new WeakMap,$s=new WeakMap,lo=new WeakSet,vi=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),rn.batch(()=>{K(this,ao).forEach(r=>{r.onMutationUpdate(t)}),K(this,_n).notify({mutation:this,type:"updated",action:t})})},tP);function s$(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ko,$r,dd,nP,a$=(nP=class extends gd{constructor(t={}){super();Ee(this,Ko);Ee(this,$r);Ee(this,dd);this.config=t,me(this,Ko,new Set),me(this,$r,new Map),me(this,dd,0)}build(t,n,r){const o=new i$({mutationCache:this,mutationId:++nf(this,dd)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){K(this,Ko).add(t);const n=sf(t);if(typeof n=="string"){const r=K(this,$r).get(n);r?r.push(t):K(this,$r).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(K(this,Ko).delete(t)){const n=sf(t);if(typeof n=="string"){const r=K(this,$r).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&K(this,$r).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=sf(t);if(typeof n=="string"){const r=K(this,$r).get(n),o=r==null?void 0:r.find(i=>i.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=sf(t);if(typeof n=="string"){const o=(r=K(this,$r).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){rn.batch(()=>{K(this,Ko).forEach(t=>{this.notify({type:"removed",mutation:t})}),K(this,Ko).clear(),K(this,$r).clear()})}getAll(){return Array.from(K(this,Ko))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>PC(n,r))}findAll(t={}){return this.getAll().filter(n=>PC(t,n))}notify(t){rn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return rn.batch(()=>Promise.all(t.map(n=>n.continue().catch(_r))))}},Ko=new WeakMap,$r=new WeakMap,dd=new WeakMap,nP);function sf(e){var t;return(t=e.options.scope)==null?void 0:t.id}function TC(e){return{onFetch:(t,n)=>{var u,d,h,f,p;const r=t.options,o=(h=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],s=((p=t.state.data)==null?void 0:p.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let g=!1;const m=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},y=OP(t.options,t.fetchOptions),x=async(v,_,w)=>{if(g)return Promise.reject();if(_==null&&v.pages.length)return Promise.resolve(v);const S={client:t.client,queryKey:t.queryKey,pageParam:_,direction:w?"backward":"forward",meta:t.options.meta};m(S);const R=await y(S),{maxPages:P}=t.options,O=w?Z8:Q8;return{pages:O(v.pages,R,P),pageParams:O(v.pageParams,_,P)}};if(o&&i.length){const v=o==="backward",_=v?l$:DC,w={pages:i,pageParams:s},S=_(r,w);a=await x(w,S,v)}else{const v=e??i.length;do{const _=l===0?s[0]??r.initialPageParam:DC(r,a);if(l>0&&_==null)break;a=await x(a,_),l++}while(l<v)}return a};t.options.persister?t.fetchFn=()=>{var g,m;return(m=(g=t.options).persister)==null?void 0:m.call(g,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function DC(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 l$(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 At,Ei,Ri,wl,Sl,ki,Cl,_l,rP,c$=(rP=class{constructor(e={}){Ee(this,At);Ee(this,Ei);Ee(this,Ri);Ee(this,wl);Ee(this,Sl);Ee(this,ki);Ee(this,Cl);Ee(this,_l);me(this,At,e.queryCache||new FP),me(this,Ei,e.mutationCache||new a$),me(this,Ri,e.defaultOptions||{}),me(this,wl,new Map),me(this,Sl,new Map),me(this,ki,0)}mount(){nf(this,ki)._++,K(this,ki)===1&&(me(this,Cl,Cx.subscribe(async e=>{e&&(await this.resumePausedMutations(),K(this,At).onFocus())})),me(this,_l,Fh.subscribe(async e=>{e&&(await this.resumePausedMutations(),K(this,At).onOnline())})))}unmount(){var e,t;nf(this,ki)._--,K(this,ki)===0&&((e=K(this,Cl))==null||e.call(this),me(this,Cl,void 0),(t=K(this,_l))==null||t.call(this),me(this,_l,void 0))}isFetching(e){return K(this,At).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return K(this,Ei).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=K(this,At).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=K(this,At).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(tl(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return K(this,At).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=K(this,At).get(r.queryHash),i=o==null?void 0:o.state.data,s=Y8(t,i);if(s!==void 0)return K(this,At).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return rn.batch(()=>K(this,At).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=K(this,At).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=K(this,At);rn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=K(this,At);return rn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=rn.batch(()=>K(this,At).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(_r).catch(_r)}invalidateQueries(e,t={}){return rn.batch(()=>(K(this,At).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=rn.batch(()=>K(this,At).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(_r)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(_r)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=K(this,At).build(this,t);return n.isStaleByTime(tl(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(_r).catch(_r)}fetchInfiniteQuery(e){return e.behavior=TC(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(_r).catch(_r)}ensureInfiniteQueryData(e){return e.behavior=TC(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Fh.isOnline()?K(this,Ei).resumePausedMutations():Promise.resolve()}getQueryCache(){return K(this,At)}getMutationCache(){return K(this,Ei)}getDefaultOptions(){return K(this,Ri)}setDefaultOptions(e){me(this,Ri,e)}setQueryDefaults(e,t){K(this,wl).set(Tu(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...K(this,wl).values()],n={};return t.forEach(r=>{Du(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){K(this,Sl).set(Tu(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...K(this,Sl).values()],n={};return t.forEach(r=>{Du(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...K(this,Ri).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Sx(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===Nh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...K(this,Ri).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){K(this,At).clear(),K(this,Ei).clear()}},At=new WeakMap,Ei=new WeakMap,Ri=new WeakMap,wl=new WeakMap,Sl=new WeakMap,ki=new WeakMap,Cl=new WeakMap,_l=new WeakMap,rP),Bn,Ke,fd,En,zs,El,Pi,co,hd,Rl,kl,Bs,Vs,Mi,Pl,dt,Vc,Xy,Qy,Zy,Jy,e0,t0,n0,jP,oP,u$=(oP=class extends gd{constructor(t,n){super();Ee(this,dt);Ee(this,Bn);Ee(this,Ke);Ee(this,fd);Ee(this,En);Ee(this,zs);Ee(this,El);Ee(this,Pi);Ee(this,co);Ee(this,hd);Ee(this,Rl);Ee(this,kl);Ee(this,Bs);Ee(this,Vs);Ee(this,Mi);Ee(this,Pl,new Set);this.options=n,me(this,Bn,t),me(this,co,null),me(this,Pi,Ky()),this.options.experimental_prefetchInRender||K(this,Pi).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(K(this,Ke).addObserver(this),IC(K(this,Ke),this.options)?Ye(this,dt,Vc).call(this):this.updateResult(),Ye(this,dt,Jy).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return r0(K(this,Ke),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return r0(K(this,Ke),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ye(this,dt,e0).call(this),Ye(this,dt,t0).call(this),K(this,Ke).removeObserver(this)}setOptions(t,n){const r=this.options,o=K(this,Ke);if(this.options=K(this,Bn).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof zr(this.options.enabled,K(this,Ke))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ye(this,dt,n0).call(this),K(this,Ke).setOptions(this.options),r._defaulted&&!Gy(this.options,r)&&K(this,Bn).getQueryCache().notify({type:"observerOptionsUpdated",query:K(this,Ke),observer:this});const i=this.hasListeners();i&&AC(K(this,Ke),o,this.options,r)&&Ye(this,dt,Vc).call(this),this.updateResult(n),i&&(K(this,Ke)!==o||zr(this.options.enabled,K(this,Ke))!==zr(r.enabled,K(this,Ke))||tl(this.options.staleTime,K(this,Ke))!==tl(r.staleTime,K(this,Ke)))&&Ye(this,dt,Xy).call(this);const s=Ye(this,dt,Qy).call(this);i&&(K(this,Ke)!==o||zr(this.options.enabled,K(this,Ke))!==zr(r.enabled,K(this,Ke))||s!==K(this,Mi))&&Ye(this,dt,Zy).call(this,s)}getOptimisticResult(t){const n=K(this,Bn).getQueryCache().build(K(this,Bn),t),r=this.createResult(n,t);return f$(this,r)&&(me(this,En,r),me(this,El,this.options),me(this,zs,K(this,Ke).state)),r}getCurrentResult(){return K(this,En)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){K(this,Pl).add(t)}getCurrentQuery(){return K(this,Ke)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=K(this,Bn).defaultQueryOptions(t),r=K(this,Bn).getQueryCache().build(K(this,Bn),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ye(this,dt,Vc).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),K(this,En)))}createResult(t,n){var P;const r=K(this,Ke),o=this.options,i=K(this,En),s=K(this,zs),a=K(this,El),c=t!==r?t.state:K(this,fd),{state:u}=t;let d={...u},h=!1,f;if(n._optimisticResults){const O=this.hasListeners(),D=!O&&IC(t,n),N=O&&AC(t,r,n,o);(D||N)&&(d={...d,...NP(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:m}=d;if(n.select&&d.data!==void 0)if(i&&d.data===(s==null?void 0:s.data)&&n.select===K(this,hd))f=K(this,Rl);else try{me(this,hd,n.select),f=n.select(d.data),f=Yy(i==null?void 0:i.data,f,n),me(this,Rl,f),me(this,co,null)}catch(O){me(this,co,O)}else f=d.data;if(n.placeholderData!==void 0&&f===void 0&&m==="pending"){let O;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))O=i.data;else if(O=typeof n.placeholderData=="function"?n.placeholderData((P=K(this,kl))==null?void 0:P.state.data,K(this,kl)):n.placeholderData,n.select&&O!==void 0)try{O=n.select(O),me(this,co,null)}catch(D){me(this,co,D)}O!==void 0&&(m="success",f=Yy(i==null?void 0:i.data,O,n),h=!0)}K(this,co)&&(p=K(this,co),f=K(this,Rl),g=Date.now(),m="error");const y=d.fetchStatus==="fetching",x=m==="pending",v=m==="error",_=x&&y,w=f!==void 0,R={status:m,fetchStatus:d.fetchStatus,isPending:x,isSuccess:m==="success",isError:v,isInitialLoading:_,isLoading:_,data:f,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:v&&!w,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:v&&w,isStale:_x(t,n),refetch:this.refetch,promise:K(this,Pi)};if(this.options.experimental_prefetchInRender){const O=A=>{R.status==="error"?A.reject(R.error):R.data!==void 0&&A.resolve(R.data)},D=()=>{const A=me(this,Pi,R.promise=Ky());O(A)},N=K(this,Pi);switch(N.status){case"pending":t.queryHash===r.queryHash&&O(N);break;case"fulfilled":(R.status==="error"||R.data!==N.value)&&D();break;case"rejected":(R.status!=="error"||R.error!==N.reason)&&D();break}}return R}updateResult(t){const n=K(this,En),r=this.createResult(K(this,Ke),this.options);if(me(this,zs,K(this,Ke).state),me(this,El,this.options),K(this,zs).data!==void 0&&me(this,kl,K(this,Ke)),Gy(r,n))return;me(this,En,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!K(this,Pl).size)return!0;const l=new Set(a??K(this,Pl));return this.options.throwOnError&&l.add("error"),Object.keys(K(this,En)).some(c=>{const u=c;return K(this,En)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),Ye(this,dt,jP).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ye(this,dt,Jy).call(this)}},Bn=new WeakMap,Ke=new WeakMap,fd=new WeakMap,En=new WeakMap,zs=new WeakMap,El=new WeakMap,Pi=new WeakMap,co=new WeakMap,hd=new WeakMap,Rl=new WeakMap,kl=new WeakMap,Bs=new WeakMap,Vs=new WeakMap,Mi=new WeakMap,Pl=new WeakMap,dt=new WeakSet,Vc=function(t){Ye(this,dt,n0).call(this);let n=K(this,Ke).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(_r)),n},Xy=function(){Ye(this,dt,e0).call(this);const t=tl(this.options.staleTime,K(this,Ke));if(oa||K(this,En).isStale||!Wy(t))return;const r=MP(K(this,En).dataUpdatedAt,t)+1;me(this,Bs,setTimeout(()=>{K(this,En).isStale||this.updateResult()},r))},Qy=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(K(this,Ke)):this.options.refetchInterval)??!1},Zy=function(t){Ye(this,dt,t0).call(this),me(this,Mi,t),!(oa||zr(this.options.enabled,K(this,Ke))===!1||!Wy(K(this,Mi))||K(this,Mi)===0)&&me(this,Vs,setInterval(()=>{(this.options.refetchIntervalInBackground||Cx.isFocused())&&Ye(this,dt,Vc).call(this)},K(this,Mi)))},Jy=function(){Ye(this,dt,Xy).call(this),Ye(this,dt,Zy).call(this,Ye(this,dt,Qy).call(this))},e0=function(){K(this,Bs)&&(clearTimeout(K(this,Bs)),me(this,Bs,void 0))},t0=function(){K(this,Vs)&&(clearInterval(K(this,Vs)),me(this,Vs,void 0))},n0=function(){const t=K(this,Bn).getQueryCache().build(K(this,Bn),this.options);if(t===K(this,Ke))return;const n=K(this,Ke);me(this,Ke,t),me(this,fd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},jP=function(t){rn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(K(this,En))}),K(this,Bn).getQueryCache().notify({query:K(this,Ke),type:"observerResultsUpdated"})})},oP);function d$(e,t){return zr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function IC(e,t){return d$(e,t)||e.state.data!==void 0&&r0(e,t,t.refetchOnMount)}function r0(e,t,n){if(zr(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&_x(e,t)}return!1}function AC(e,t,n,r){return(e!==t||zr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&_x(e,n)}function _x(e,t){return zr(t.enabled,e)!==!1&&e.isStaleByTime(tl(t.staleTime,e))}function f$(e,t){return!Gy(e.getCurrentResult(),t)}var Ex=C.createContext(void 0),Rx=e=>{const t=C.useContext(Ex);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},h$=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Ex.Provider,{value:e,children:t})),LP=C.createContext(!1),p$=()=>C.useContext(LP);LP.Provider;function g$(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var m$=C.createContext(g$()),b$=()=>C.useContext(m$);function y$(e,t){return typeof e=="function"?e(...t):!!e}function NC(){}var v$=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},x$=e=>{C.useEffect(()=>{e.clearReset()},[e])},w$=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||y$(n,[e.error,r])),S$=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},C$=(e,t)=>e.isLoading&&e.isFetching&&!t,_$=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,FC=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function E$(e,t,n){var d,h,f,p,g;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=Rx(),o=p$(),i=b$(),s=r.defaultQueryOptions(e);(h=(d=r.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||h.call(d,s),process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.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`)),s._optimisticResults=o?"isRestoring":"optimistic",S$(s),v$(s,i),x$(i);const a=!r.getQueryCache().get(s.queryHash),[l]=C.useState(()=>new t(r,s)),c=l.getOptimisticResult(s),u=!o&&e.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(m=>{const y=u?l.subscribe(rn.batchCalls(m)):NC;return l.updateResult(),y},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),C.useEffect(()=>{l.setOptions(s,{listeners:!1})},[s,l]),_$(s,c))throw FC(s,l,i);if(w$({result:c,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw c.error;if((p=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||p.call(f,s,c),s.experimental_prefetchInRender&&!oa&&C$(c,o)){const m=a?FC(s,l,i):(g=r.getQueryCache().get(s.queryHash))==null?void 0:g.promise;m==null||m.catch(NC).finally(()=>{l.updateResult()})}return s.notifyOnChangeProps?c:l.trackResult(c)}function md(e,t){return E$(e,u$)}function R$(){const e=E.useContext(Ex);if(e&&e.isSemaphorClient)return e}function $P({children:e}){const{setIsSessionExpired:t}=Vt(),n=R$(),[r]=E.useState(()=>{const o=new c$({queryCache:new FP({onError:i=>{i instanceof Error?(console.error(`Something went wrong: ${i.message}`),i.message==="invalid token"&&t(!0)):console.error("Something went wrong:",i)}}),defaultOptions:{queries:{gcTime:36e5,staleTime:3e5,refetchOnWindowFocus:!1,retry:1}}});return o.isSemaphorClient=!0,o});return n?b.jsx(b.Fragment,{children:e}):b.jsx(h$,{client:r,children:e})}const Zi=E.forwardRef(({children:e,className:t,...n},r)=>b.jsx("div",{className:se("semaphor-scope",t),ref:r,...n,children:e})),k$={id:"",authToken:void 0},zP=E.createContext(k$),BP=({children:e,dashboardProps:t})=>b.jsx($P,{children:b.jsx(zP.Provider,{value:t,children:b.jsx(Zi,{style:{height:"100%"},children:e})})});function xr(){const e=E.useContext(zP);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}function P$(){const{authToken:e,version:t}=xr(),n=ie(l=>l.selectedLensId);function r(){if(!(e!=null&&e.accessToken))return!1}const{data:o,isLoading:i,isFetching:s,isError:a}=md({queryKey:["dashboard",n,e==null?void 0:e.accessToken],queryFn:()=>H8(e==null?void 0:e.accessToken,{lensId:n,version:t}),enabled:r()});return{data:o,isLoading:i,isFetching:s,isError:a}}function M$(){const{authToken:e}=xr(),t=ie(r=>r.authToken),{setAuthToken:n}=Vt();return E.useEffect(()=>{e&&(e==null?void 0:e.toString())!==(t==null?void 0:t.toString())&&n(e)},[e,t,n]),e}const VP=(e,t)=>{const n={};if(e===null||t===null)return t;const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const o of r){if(!(o in e)&&o in t){n[o]=t[o];continue}if(o in e&&!(o in t)){n[o]=void 0;continue}const i=e[o],s=t[o];if(!o0(i,s))if(Array.isArray(i)&&Array.isArray(s))n[o]=s;else if(jC(i)&&jC(s)){const a=VP(i,s);Object.keys(a).length>0&&(n[o]=a)}else n[o]=s}return n},o0=(e,t)=>{if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((o,i)=>o0(o,t[i]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(o=>o0(e[o],t[o]))}return!1},jC=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),jh=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=>jh(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=jh(e[n]));return t};function HP(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function LC(e,t){const n=HP(e);return n==="dark"?Ou({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function O$({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o,selectedSheetId:i,onFilterValuesChange:s}){const{authToken:a}=xr();M$();const l=ie(F=>F.selectedLensId),{data:c,isLoading:u,isFetching:d,isError:h}=P$(),[f,p]=E.useState(o||[]),{theme:g,setTheme:m}=PP(),y=ie(F=>F.dashboard.globalStyle),{setDashboard:x,setDashboardWithFilterValues:v,setSelectedSheetId:_,setStyle:w,setOnSaveFunction:S,setLenses:R,setSelectedLensId:P,setInitStore:O}=Vt();ie(F=>F.actions.setCustomCards);const D=ie(F=>F.actions.setFilterValues),N=ie(F=>F.filterValues),A=ie(F=>F.actions.setThemeStyle),U=ie(F=>F.actions.setDashboardTheme),$=ie(F=>F.actions.setOnEvent);E.useEffect(()=>{a&&O()},[a,O]),E.useEffect(()=>{if(g){const F=HP(g);U(F)}},[g,U]),E.useEffect(()=>{t&&m(t)},[t,m]);const T=E.useCallback(()=>{const F=jh(Ih),I=Ou(F,y);if(e){const j=Ou(I,e),H=LC(g,j);A(H),w(j)}else{const j=LC(g,I);A(j),w(Ih)}},[g,e,y,A,w]);return E.useEffect(()=>{c&&c.dashboard&&T()},[g,e,y,T,c]),E.useEffect(()=>{var L,k;function F(G,q){const Y=G.filters||[],V=[];for(const W of q){const X=Y.find(J=>J.id===W.filterId);X&&V.push({filterId:W.filterId,connectionType:X.database==="NA"?"api":"database",name:X.column,operation:X.operation,valueType:el(X),values:W.values})}return V}if(!c||!c.dashboard)return;const{dashboard:I,filterValues:j,defaultLensId:H,lenses:M}=c,B=F(I,f||[]);v(I,(!j||(j==null?void 0:j.length)===0?B:j)||[]),M&&R(M),H&&P(H),_(i||((k=(L=I==null?void 0:I.sheets)==null?void 0:L[0])==null?void 0:k.id)||null)},[c,x,_,D,l,R,v,P,f,i]),E.useEffect(()=>{s&&N&&s(N)},[N,s]),E.useEffect(()=>{n&&S(n),r&&$(r)},[n,S,r,$]),{isFetching:d,isLoading:u,isError:h}}function nl({className:e,...t}){return b.jsx("div",{className:se("animate-pulse rounded-md bg-muted",e),...t})}const WP=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));WP.displayName="Card";const qp=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("flex flex-col space-y-1.5 p-6",e),...t}));qp.displayName="CardHeader";const nc=C.forwardRef(({className:e,...t},n)=>b.jsx("h3",{ref:n,className:se("text-2xl font-semibold leading-none tracking-tight",e),...t}));nc.displayName="CardTitle";const kx=C.forwardRef(({className:e,...t},n)=>b.jsx("p",{ref:n,className:se("text-sm text-muted-foreground",e),...t}));kx.displayName="CardDescription";const Yp=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("px-6 pt-0",e),...t}));Yp.displayName="CardContent";const UP=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("flex items-center p-6 pt-0",e),...t}));UP.displayName="CardFooter";function GP({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:d,showAssistant:h,defaultFilterValues:f,onFilterValuesChange:p,selectedSheetId:g,...m}){const{placeholders:y}=xr(),x=ie(S=>S.themeStyle),v=ie(S=>S.isSessionExpired),{isLoading:_,isError:w}=O$({customStyle:t,currentTheme:c,onSave:n,onEvent:r,defaultFilterValues:f,onFilterValuesChange:p,selectedSheetId:g});return _||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?b.jsx(o,{message:"loading"}):b.jsx("div",{className:"flex items-center gap-3",children:b.jsx(nl,{className:"h-1 w-full dark:h-[2px]"})})):w?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),b.jsx(i,{})):b.jsx("div",{children:"Error"})):v?(r==null||r({type:"error",message:"Session Expired"}),y!=null&&y.SessionExpired?b.jsx("div",{className:"flex h-full items-center justify-center",children:b.jsx("div",{children:y.SessionExpired})}):b.jsx("div",{className:"flex h-full items-center justify-center",children:b.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[b.jsx(nc,{children:"Session Expired"}),b.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):b.jsx("div",{className:se("isolate flex h-full flex-col justify-between",x==null?void 0:x.dashboardPanel,e),style:{},"data-role":"dashboard-panel",...m})}function le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function T$(e,t){const n=C.createContext(t),r=i=>{const{children:s,...a}=i,l=C.useMemo(()=>a,Object.values(a));return b.jsx(n.Provider,{value:l,children:s})};r.displayName=e+"Provider";function o(i){const s=C.useContext(n);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Xt(e,t=[]){let n=[];function r(i,s){const a=C.createContext(s),l=n.length;n=[...n,s];const c=d=>{var y;const{scope:h,children:f,...p}=d,g=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,m=C.useMemo(()=>p,Object.values(p));return b.jsx(g.Provider,{value:m,children:f})};c.displayName=i+"Provider";function u(d,h){var g;const f=((g=h==null?void 0:h[e])==null?void 0:g[l])||a,p=C.useContext(f);if(p)return p;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>C.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return C.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,D$(o,...t)]}function D$(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return C.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function $C(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Kp(...e){return t=>{let n=!1;const r=e.map(o=>{const i=$C(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():$C(e[o],null)}}}}function Te(...e){return C.useCallback(Kp(...e),e)}var si=C.forwardRef((e,t)=>{const{children:n,...r}=e,o=C.Children.toArray(n),i=o.find(I$);if(i){const s=i.props.children,a=o.map(l=>l===i?C.Children.count(s)>1?C.Children.only(null):C.isValidElement(s)?s.props.children:null:l);return b.jsx(i0,{...r,ref:t,children:C.isValidElement(s)?C.cloneElement(s,void 0,a):null})}return b.jsx(i0,{...r,ref:t,children:n})});si.displayName="Slot";var i0=C.forwardRef((e,t)=>{const{children:n,...r}=e;if(C.isValidElement(n)){const o=N$(n),i=A$(r,n.props);return n.type!==C.Fragment&&(i.ref=t?Kp(t,o):o),C.cloneElement(n,i)}return C.Children.count(n)>1?C.Children.only(null):null});i0.displayName="SlotClone";var Px=({children:e})=>b.jsx(b.Fragment,{children:e});function I$(e){return C.isValidElement(e)&&e.type===Px}function A$(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function N$(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Xp(e){const t=e+"CollectionProvider",[n,r]=Xt(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=f=>{const{scope:p,children:g}=f,m=E.useRef(null),y=E.useRef(new Map).current;return b.jsx(o,{scope:p,itemMap:y,collectionRef:m,children:g})};s.displayName=t;const a=e+"CollectionSlot",l=E.forwardRef((f,p)=>{const{scope:g,children:m}=f,y=i(a,g),x=Te(p,y.collectionRef);return b.jsx(si,{ref:x,children:m})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",d=E.forwardRef((f,p)=>{const{scope:g,children:m,...y}=f,x=E.useRef(null),v=Te(p,x),_=i(c,g);return E.useEffect(()=>(_.itemMap.set(x,{ref:x,...y}),()=>void _.itemMap.delete(x))),b.jsx(si,{[u]:"",ref:v,children:m})});d.displayName=c;function h(f){const p=i(e+"CollectionConsumer",f);return E.useCallback(()=>{const m=p.collectionRef.current;if(!m)return[];const y=Array.from(m.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((_,w)=>y.indexOf(_.ref.current)-y.indexOf(w.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},h,r]}var on=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{},F$=C.useId||(()=>{}),j$=0;function qt(e){const[t,n]=C.useState(F$());return on(()=>{n(r=>r??String(j$++))},[e]),t?`radix-${t}`:""}var L$=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ge=L$.reduce((e,t)=>{const n=C.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?si:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),b.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function qP(e,t){e&&ta.flushSync(()=>e.dispatchEvent(t))}function Kt(e){const t=C.useRef(e);return C.useEffect(()=>{t.current=e}),C.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function xn({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=$$({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Kt(n),l=C.useCallback(c=>{if(i){const d=typeof c=="function"?c(e):c;d!==e&&a(d)}else o(c)},[i,e,o,a]);return[s,l]}function $$({defaultProp:e,onChange:t}){const n=C.useState(e),[r]=n,o=C.useRef(r),i=Kt(t);return C.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}var z$=C.createContext(void 0);function ya(e){const t=C.useContext(z$);return e||t||"ltr"}var Gm="rovingFocusGroup.onEntryFocus",B$={bubbles:!1,cancelable:!0},Qp="RovingFocusGroup",[s0,YP,V$]=Xp(Qp),[H$,rc]=Xt(Qp,[V$]),[W$,U$]=H$(Qp),KP=C.forwardRef((e,t)=>b.jsx(s0.Provider,{scope:e.__scopeRovingFocusGroup,children:b.jsx(s0.Slot,{scope:e.__scopeRovingFocusGroup,children:b.jsx(G$,{...e,ref:t})})}));KP.displayName=Qp;var G$=C.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,h=C.useRef(null),f=Te(t,h),p=ya(i),[g=null,m]=xn({prop:s,defaultProp:a,onChange:l}),[y,x]=C.useState(!1),v=Kt(c),_=YP(n),w=C.useRef(!1),[S,R]=C.useState(0);return C.useEffect(()=>{const P=h.current;if(P)return P.addEventListener(Gm,v),()=>P.removeEventListener(Gm,v)},[v]),b.jsx(W$,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:g,onItemFocus:C.useCallback(P=>m(P),[m]),onItemShiftTab:C.useCallback(()=>x(!0),[]),onFocusableItemAdd:C.useCallback(()=>R(P=>P+1),[]),onFocusableItemRemove:C.useCallback(()=>R(P=>P-1),[]),children:b.jsx(ge.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{w.current=!0}),onFocus:le(e.onFocus,P=>{const O=!w.current;if(P.target===P.currentTarget&&O&&!y){const D=new CustomEvent(Gm,B$);if(P.currentTarget.dispatchEvent(D),!D.defaultPrevented){const N=_().filter(F=>F.focusable),A=N.find(F=>F.active),U=N.find(F=>F.id===g),T=[A,U,...N].filter(Boolean).map(F=>F.ref.current);ZP(T,u)}}w.current=!1}),onBlur:le(e.onBlur,()=>x(!1))})})}),XP="RovingFocusGroupItem",QP=C.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=qt(),l=i||a,c=U$(XP,n),u=c.currentTabStopId===l,d=YP(n),{onFocusableItemAdd:h,onFocusableItemRemove:f}=c;return C.useEffect(()=>{if(r)return h(),()=>f()},[r,h,f]),b.jsx(s0.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:b.jsx(ge.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:le(e.onMouseDown,p=>{r?c.onItemFocus(l):p.preventDefault()}),onFocus:le(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:le(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){c.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const g=K$(p,c.orientation,c.dir);if(g!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let y=d().filter(x=>x.focusable).map(x=>x.ref.current);if(g==="last")y.reverse();else if(g==="prev"||g==="next"){g==="prev"&&y.reverse();const x=y.indexOf(p.currentTarget);y=c.loop?X$(y,x+1):y.slice(x+1)}setTimeout(()=>ZP(y))}})})})});QP.displayName=XP;var q$={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Y$(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function K$(e,t,n){const r=Y$(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return q$[r]}function ZP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function X$(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Mx=KP,Ox=QP;function Q$(e,t){return C.useReducer((n,r)=>t[n][r]??n,e)}var Yt=e=>{const{present:t,children:n}=e,r=Z$(t),o=typeof n=="function"?n({present:r.isPresent}):C.Children.only(n),i=Te(r.ref,J$(o));return typeof n=="function"||r.isPresent?C.cloneElement(o,{ref:i}):null};Yt.displayName="Presence";function Z$(e){const[t,n]=C.useState(),r=C.useRef({}),o=C.useRef(e),i=C.useRef("none"),s=e?"mounted":"unmounted",[a,l]=Q$(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const c=af(r.current);i.current=a==="mounted"?c:"none"},[a]),on(()=>{const c=r.current,u=o.current;if(u!==e){const h=i.current,f=af(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),on(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=f=>{const g=af(r.current).includes(f.animationName);if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},h=f=>{f.target===t&&(i.current=af(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:C.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function af(e){return(e==null?void 0:e.animationName)||"none"}function J$(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Tx="Tabs",[e9,vve]=Xt(Tx,[rc]),JP=rc(),[t9,Dx]=e9(Tx),eM=C.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=ya(a),[d,h]=xn({prop:r,onChange:o,defaultProp:i});return b.jsx(t9,{scope:n,baseId:qt(),value:d,onValueChange:h,orientation:s,dir:u,activationMode:l,children:b.jsx(ge.div,{dir:u,"data-orientation":s,...c,ref:t})})});eM.displayName=Tx;var tM="TabsList",nM=C.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Dx(tM,n),s=JP(n);return b.jsx(Mx,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:b.jsx(ge.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});nM.displayName=tM;var rM="TabsTrigger",oM=C.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Dx(rM,n),a=JP(n),l=aM(s.baseId,r),c=lM(s.baseId,r),u=r===s.value;return b.jsx(Ox,{asChild:!0,...a,focusable:!o,active:u,children:b.jsx(ge.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...i,ref:t,onMouseDown:le(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?s.onValueChange(r):d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(r)}),onFocus:le(e.onFocus,()=>{const d=s.activationMode!=="manual";!u&&!o&&d&&s.onValueChange(r)})})})});oM.displayName=rM;var iM="TabsContent",sM=C.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Dx(iM,n),l=aM(a.baseId,r),c=lM(a.baseId,r),u=r===a.value,d=C.useRef(u);return C.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),b.jsx(Yt,{present:o||u,children:({present:h})=>b.jsx(ge.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:h&&i})})});sM.displayName=iM;function aM(e,t){return`${e}-trigger-${t}`}function lM(e,t){return`${e}-content-${t}`}var n9=eM,cM=nM,uM=oM,dM=sM;const Ix=n9,Zp=C.forwardRef(({className:e,...t},n)=>b.jsx(cM,{ref:n,className:se("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Zp.displayName=cM.displayName;const Jp=C.forwardRef(({className:e,...t},n)=>b.jsx(uM,{ref:n,className:se("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Jp.displayName=uM.displayName;const Ax=C.forwardRef(({className:e,...t},n)=>b.jsx(dM,{ref:n,className:se("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ax.displayName=dM.displayName;var fM={exports:{}},bd={},a0={exports:{}};(function(e,t){(function(n,r){r(t)})(ei,function(n){function r(W){return function(J,ne,Z,oe,ee,de,fe){return W(J,ne,fe)}}function o(W){return function(J,ne,Z,oe){if(!J||!ne||typeof J!="object"||typeof ne!="object")return W(J,ne,Z,oe);var ee=oe.get(J),de=oe.get(ne);if(ee&&de)return ee===ne&&de===J;oe.set(J,ne),oe.set(ne,J);var fe=W(J,ne,Z,oe);return oe.delete(J),oe.delete(ne),fe}}function i(W,X){var J={};for(var ne in W)J[ne]=W[ne];for(var ne in X)J[ne]=X[ne];return J}function s(W){return W.constructor===Object||W.constructor==null}function a(W){return typeof W.then=="function"}function l(W,X){return W===X||W!==W&&X!==X}var c="[object Arguments]",u="[object Boolean]",d="[object Date]",h="[object RegExp]",f="[object Map]",p="[object Number]",g="[object Object]",m="[object Set]",y="[object String]",x=Object.prototype.toString;function v(W){var X=W.areArraysEqual,J=W.areDatesEqual,ne=W.areMapsEqual,Z=W.areObjectsEqual,oe=W.areRegExpsEqual,ee=W.areSetsEqual,de=W.createIsNestedEqual,fe=de(xe);function xe(pe,be,je){if(pe===be)return!0;if(!pe||!be||typeof pe!="object"||typeof be!="object")return pe!==pe&&be!==be;if(s(pe)&&s(be))return Z(pe,be,fe,je);var tt=Array.isArray(pe),Ht=Array.isArray(be);if(tt||Ht)return tt===Ht&&X(pe,be,fe,je);var Ge=x.call(pe);return Ge!==x.call(be)?!1:Ge===d?J(pe,be,fe,je):Ge===h?oe(pe,be,fe,je):Ge===f?ne(pe,be,fe,je):Ge===m?ee(pe,be,fe,je):Ge===g||Ge===c?a(pe)||a(be)?!1:Z(pe,be,fe,je):Ge===u||Ge===p||Ge===y?l(pe.valueOf(),be.valueOf()):!1}return xe}function _(W,X,J,ne){var Z=W.length;if(X.length!==Z)return!1;for(;Z-- >0;)if(!J(W[Z],X[Z],Z,Z,W,X,ne))return!1;return!0}var w=o(_);function S(W,X){return l(W.valueOf(),X.valueOf())}function R(W,X,J,ne){var Z=W.size===X.size;if(!Z)return!1;if(!W.size)return!0;var oe={},ee=0;return W.forEach(function(de,fe){if(Z){var xe=!1,pe=0;X.forEach(function(be,je){!xe&&!oe[pe]&&(xe=J(fe,je,ee,pe,W,X,ne)&&J(de,be,fe,je,W,X,ne))&&(oe[pe]=!0),pe++}),ee++,Z=xe}}),Z}var P=o(R),O="_owner",D=Object.prototype.hasOwnProperty;function N(W,X,J,ne){var Z=Object.keys(W),oe=Z.length;if(Object.keys(X).length!==oe)return!1;for(var ee;oe-- >0;){if(ee=Z[oe],ee===O){var de=!!W.$$typeof,fe=!!X.$$typeof;if((de||fe)&&de!==fe)return!1}if(!D.call(X,ee)||!J(W[ee],X[ee],ee,ee,W,X,ne))return!1}return!0}var A=o(N);function U(W,X){return W.source===X.source&&W.flags===X.flags}function $(W,X,J,ne){var Z=W.size===X.size;if(!Z)return!1;if(!W.size)return!0;var oe={};return W.forEach(function(ee,de){if(Z){var fe=!1,xe=0;X.forEach(function(pe,be){!fe&&!oe[xe]&&(fe=J(ee,pe,de,be,W,X,ne))&&(oe[xe]=!0),xe++}),Z=fe}}),Z}var T=o($),F=Object.freeze({areArraysEqual:_,areDatesEqual:S,areMapsEqual:R,areObjectsEqual:N,areRegExpsEqual:U,areSetsEqual:$,createIsNestedEqual:r}),I=Object.freeze({areArraysEqual:w,areDatesEqual:S,areMapsEqual:P,areObjectsEqual:A,areRegExpsEqual:U,areSetsEqual:T,createIsNestedEqual:r}),j=v(F);function H(W,X){return j(W,X,void 0)}var M=v(i(F,{createIsNestedEqual:function(){return l}}));function B(W,X){return M(W,X,void 0)}var L=v(I);function k(W,X){return L(W,X,new WeakMap)}var G=v(i(I,{createIsNestedEqual:function(){return l}}));function q(W,X){return G(W,X,new WeakMap)}function Y(W){return v(i(F,W(F)))}function V(W){var X=v(i(I,W(I)));return function(J,ne,Z){return Z===void 0&&(Z=new WeakMap),X(J,ne,Z)}}n.circularDeepEqual=k,n.circularShallowEqual=q,n.createCustomCircularEqual=V,n.createCustomEqual=Y,n.deepEqual=H,n.sameValueZeroEqual=l,n.shallowEqual=B,Object.defineProperty(n,"__esModule",{value:!0})})})(a0,a0.exports);var Nx=a0.exports;const Fx=dx(h6);var Ue={},r9=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.bottom=jx;Ue.childrenEqual=a9;Ue.cloneLayout=hM;Ue.cloneLayoutItem=Hs;Ue.collides=eg;Ue.compact=gM;Ue.compactItem=mM;Ue.compactType=x9;Ue.correctBounds=bM;Ue.fastPositionEqual=l9;Ue.fastRGLPropsEqual=void 0;Ue.getAllCollisions=yM;Ue.getFirstCollision=ks;Ue.getLayoutItem=Lx;Ue.getStatics=$x;Ue.modifyLayout=pM;Ue.moveElement=Wc;Ue.moveElementAwayFromCollision=c0;Ue.noop=void 0;Ue.perc=u9;Ue.resizeItemInDirection=m9;Ue.setTopLeft=y9;Ue.setTransform=b9;Ue.sortLayoutItems=Ux;Ue.sortLayoutItemsByColRow=CM;Ue.sortLayoutItemsByRowCol=SM;Ue.synchronizeLayoutWithChildren=v9;Ue.validateLayout=_M;Ue.withLayoutItem=s9;var zC=Nx,Hc=o9(E);function o9(e){return e&&e.__esModule?e:{default:e}}const i9=process.env.NODE_ENV==="production";function jx(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function hM(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=Hs(e[n]);return t}function pM(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function s9(e,t,n){let r=Lx(e,t);return r?(r=n(Hs(r)),e=pM(e,r),[e,r]):[e,null]}function Hs(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function a9(e,t){return(0,zC.deepEqual)(Hc.default.Children.map(e,n=>n==null?void 0:n.key),Hc.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,zC.deepEqual)(Hc.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),Hc.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}Ue.fastRGLPropsEqual=r9;function l9(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function eg(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function gM(e,t,n,r){const o=$x(e),i=Ux(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=Hs(i[a]);c.static||(c=mM(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const c9={x:"w",y:"h"};function l0(e,t,n,r){const o=c9[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;eg(t,a)&&l0(e,a,n+t[o],r)}}t[r]=n}function mM(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min(jx(e),t.y);t.y>0&&!ks(e,t);)t.y--;else if(a)for(;t.x>0&&!ks(e,t);)t.x--;let l;for(;(l=ks(e,t))&&!(n===null&&i);)if(a?l0(o,t,l.x+l.w,"x"):l0(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!ks(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function bM(e,t){const n=$x(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;ks(n,i);)i.y++}return e}function Lx(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function ks(e,t){for(let n=0,r=e.length;n<r;n++)if(eg(e[n],t))return e[n]}function yM(e,t){return e.filter(n=>eg(n,t))}function $x(e){return e.filter(t=>t.static)}function Wc(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;`${t.i}${String(n)}${String(r)}${t.x}${t.y}`;const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let d=Ux(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(d=d.reverse());const f=yM(d,t),p=f.length>0;if(p&&l)return hM(e);if(p&&i)return`${t.i}`,t.x=c,t.y=u,t.moved=!1,e;for(let g=0,m=f.length;g<m;g++){const y=f[g];`${t.i}${t.x}${t.y}${y.i}${y.x}${y.y}`,!y.moved&&(y.static?e=c0(e,y,t,o,s):e=c0(e,t,y,o,s))}return e}function c0(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const d={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=ks(e,d),f=h&&h.y+h.h>t.y,p=h&&t.x+t.w>h.x;if(h){if(f&&a)return Wc(e,n,void 0,t.y+1,r,l,o);if(f&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(p&&s)return Wc(e,t,n.x,void 0,r,l,o)}else return`${n.i}${d.x}${d.y}`,Wc(e,n,s?d.x:void 0,a?d.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:Wc(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function u9(e){return e*100+"%"}const vM=(e,t,n,r)=>e+n>r?t:n,xM=(e,t,n)=>e<0?t:n,wM=e=>Math.max(0,e),zx=e=>Math.max(0,e),Bx=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:xM(s,e.height,o),top:zx(s)}},Vx=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:vM(e.left,e.width,s,n),left:wM(o)}},Hx=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:vM(e.left,e.width,i,n),top:zx(r),left:wM(s)}},Wx=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:xM(r,e.height,i),top:zx(r)}},d9=function(){return Bx(arguments.length<=0?void 0:arguments[0],Vx(...arguments))},f9=function(){return Bx(arguments.length<=0?void 0:arguments[0],Hx(...arguments))},h9=function(){return Wx(arguments.length<=0?void 0:arguments[0],Vx(...arguments))},p9=function(){return Wx(arguments.length<=0?void 0:arguments[0],Hx(...arguments))},g9={n:Bx,ne:d9,e:Vx,se:h9,s:Wx,sw:p9,w:Hx,nw:f9};function m9(e,t,n,r){const o=g9[e];return o?o(t,{...t,...n},r):n}function b9(e){let{top:t,left:n,width:r,height:o}=e;const i=`translate(${n}px,${t}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${r}px`,height:`${o}px`,position:"absolute"}}function y9(e){let{top:t,left:n,width:r,height:o}=e;return{top:`${t}px`,left:`${n}px`,width:`${r}px`,height:`${o}px`,position:"absolute"}}function Ux(e,t){return t==="horizontal"?CM(e):t==="vertical"?SM(e):e}function SM(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function CM(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function v9(e,t,n,r,o){e=e||[];const i=[];Hc.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=Lx(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(Hs(l)):c?(i9||_M([c],"ReactGridLayout.children"),i.push(Hs({...c,i:a.key}))):i.push(Hs({w:1,h:1,x:0,y:jx(i),i:String(a.key)}))});const s=bM(i,{cols:n});return o?s:gM(s,r,n)}function _M(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++){const a=n[s],l=i[a];if(typeof l!="number"||Number.isNaN(l))throw new Error(`ReactGridLayout: ${t}[${r}].${a} must be a number! Received: ${l} (${typeof l})`)}if(typeof i.i<"u"&&typeof i.i!="string")throw new Error(`ReactGridLayout: ${t}[${r}].i must be a string! Received: ${i.i} (${typeof i.i})`)}}function x9(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const w9=()=>{};Ue.noop=w9;var Oo={};Object.defineProperty(Oo,"__esModule",{value:!0});Oo.calcGridColWidth=tg;Oo.calcGridItemPosition=S9;Oo.calcGridItemWHPx=u0;Oo.calcWH=_9;Oo.calcXY=C9;Oo.clamp=Ps;function tg(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function u0(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function S9(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=tg(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=u0(r,c,s[0]),u.height=u0(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function C9(e,t,n,r,o){const{margin:i,containerPadding:s,cols:a,rowHeight:l,maxRows:c}=e,u=tg(e);let d=Math.round((n-s[0])/(u+i[0])),h=Math.round((t-s[1])/(l+i[1]));return d=Ps(d,0,a-r),h=Ps(h,0,c-o),{x:d,y:h}}function _9(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=tg(e);let d=Math.round((t+s[0])/(u+s[0])),h=Math.round((n+s[1])/(c+s[1])),f=Ps(d,0,l-r),p=Ps(h,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(f=Ps(d,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(p=Ps(h,0,a)),{w:f,h:p}}function Ps(e,t,n){return Math.max(Math.min(e,n),t)}var ng={},d0={exports:{}},lf={exports:{}},lt={};/** @license React v16.13.1
|
|
36
|
+
`,Dh="dm",Vy=[{locale:"en-US",currency:"USD",currencyName:"US Dollar"},{locale:"en-GB",currency:"GBP",currencyName:"British Pound"},{locale:"en-CA",currency:"CAD",currencyName:"Canadian Dollar"},{locale:"en-AU",currency:"AUD",currencyName:"Australian Dollar"},{locale:"en-IN",currency:"INR",currencyName:"Indian Rupee"},{locale:"ja-JP",currency:"JPY",currencyName:"Japanese Yen"},{locale:"de-DE",currency:"EUR",currencyName:"Germany (Eurozone)"},{locale:"fr-FR",currency:"EUR",currencyName:"France (Eurozone)"},{locale:"es-ES",currency:"EUR",currencyName:"Spain (Eurozone)"},{locale:"it-IT",currency:"EUR",currencyName:"Italy (Eurozone)"},{locale:"fi-FI",currency:"EUR",currencyName:"Finland (Eurozone)"},{locale:"nl-NL",currency:"EUR",currencyName:"Netherlands (Eurozone)"},{locale:"zh-CN",currency:"CNY",currencyName:"Chinese Yuan"},{locale:"ru-RU",currency:"RUB",currencyName:"Russian Ruble"},{locale:"pt-BR",currency:"BRL",currencyName:"Brazilian Real"},{locale:"ko-KR",currency:"KRW",currencyName:"South Korean Won"},{locale:"ar-SA",currency:"SAR",currencyName:"Saudi Riyal"},{locale:"sv-SE",currency:"SEK",currencyName:"Swedish Krona"},{locale:"no-NO",currency:"NOK",currencyName:"Norwegian Krone"},{locale:"da-DK",currency:"DKK",currencyName:"Danish Krone"},{locale:"pl-PL",currency:"PLN",currencyName:"Polish Zloty"},{locale:"tr-TR",currency:"TRY",currencyName:"Turkish Lira"},{locale:"he-IL",currency:"ILS",currencyName:"Israeli Shekel"},{locale:"th-TH",currency:"THB",currencyName:"Thai Baht"},{locale:"vi-VN",currency:"VND",currencyName:"Vietnamese Dong"},{locale:"id-ID",currency:"IDR",currencyName:"Indonesian Rupiah"},{locale:"mx-MX",currency:"MXN",currencyName:"Mexican Peso"},{locale:"za-ZA",currency:"ZAR",currencyName:"South African Rand"},{locale:"sg-SG",currency:"SGD",currencyName:"Singapore Dollar"},{locale:"hk-HK",currency:"HKD",currencyName:"Hong Kong Dollar"},{locale:"ch-CH",currency:"CHF",currencyName:"Swiss Franc"},{locale:"my-MY",currency:"MYR",currencyName:"Malaysian Ringgit"},{locale:"ph-PH",currency:"PHP",currencyName:"Philippine Peso"},{locale:"eg-EG",currency:"EGP",currencyName:"Egyptian Pound"},{locale:"nz-NZ",currency:"NZD",currencyName:"New Zealand Dollar"}],C8=[{label:"English",locales:[{code:"en-US",name:"US English"},{code:"en-GB",name:"British English"},{code:"en-AU",name:"Australian English"},{code:"en-CA",name:"Canadian English"}]},{label:"French",locales:[{code:"fr-FR",name:"France French"},{code:"fr-CA",name:"Canadian French"}]},{label:"Spanish",locales:[{code:"es-ES",name:"Spain Spanish"},{code:"es-MX",name:"Mexican Spanish"},{code:"es-419",name:"Latin American Spanish"}]},{label:"German",locales:[{code:"de-DE",name:"Germany German"},{code:"de-CH",name:"Swiss German"}]},{label:"Chinese",locales:[{code:"zh-CN",name:"Simplified Chinese (China)"},{code:"zh-TW",name:"Traditional Chinese (Taiwan)"},{code:"zh-HK",name:"Hong Kong Chinese"}]},{label:"Japanese",locales:[{code:"ja-JP",name:"Japanese"}]},{label:"Arabic",locales:[{code:"ar-EG",name:"Egypt Arabic"},{code:"ar-SA",name:"Saudi Arabia Arabic"}]},{label:"Russian",locales:[{code:"ru-RU",name:"Russian"}]},{label:"Portuguese",locales:[{code:"pt-PT",name:"Portugal Portuguese"},{code:"pt-BR",name:"Brazil Portuguese"}]},{label:"Indian Languages",locales:[{code:"hi-IN",name:"Hindi (India)"},{code:"ta-IN",name:"Tamil (India)"}]},{label:"Korean",locales:[{code:"ko-KR",name:"Korean"}]},{label:"Italian",locales:[{code:"it-IT",name:"Italian (Italy)"}]},{label:"Dutch",locales:[{code:"nl-NL",name:"Dutch (Netherlands)"}]},{label:"Swedish",locales:[{code:"sv-SE",name:"Swedish (Sweden)"}]},{label:"Turkish",locales:[{code:"tr-TR",name:"Turkish (Turkey)"}]},{label:"Hebrew",locales:[{code:"he-IL",name:"Hebrew (Israel)"}]},{label:"Thai",locales:[{code:"th-TH",name:"Thai (Thailand)"}]},{label:"Polish",locales:[{code:"pl-PL",name:"Polish (Poland)"}]},{label:"Greek",locales:[{code:"el-GR",name:"Greek (Greece)"}]},{label:"Norwegian",locales:[{code:"no-NO",name:"Norwegian (Norway)"}]}],bx=["lg","md","sm","xs","xxs"],Ih={default:{dashboardPanel:"",dashboardTabsContainer:"",gridLayout:{className:""},chart:{font:{family:"Open Sans, Arial, sans-serif"},dataset:{backgroundColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]],borderColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]]},options:{interaction:{mode:"index"},plugins:{datalabels:{display:!1,color:Hy},title:{display:!0},tooltip:{backgroundColor:"#fff",bodyColor:"#000",borderWidth:.25,titleColor:"#000",borderColor:"rgb(128,131,139)",cornerRadius:4,usePointStyle:!0,pointStyle:"rectRounded",boxPadding:4},legend:{position:"top",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},scales:{y:{grid:{display:!0},title:{display:!0,text:""},beginAtZero:!0,ticks:{precision:0}},x:{grid:{display:!0},title:{display:!0}}},layout:{padding:{top:-40}},borderRadius:2,responsive:!0,maintainAspectRatio:!1}}},dark:{chart:{dataset:{backgroundColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]],borderColor:[Qe.blue[500],Qe.teal[500],Qe.amber[500],Qe.red[500],Qe.indigo[500],Qe.green[500]],datalables:{color:Hy}},options:{plugins:{tooltip:{backgroundColor:"#000",bodyColor:"#fff",borderWidth:.25,titleColor:"#fff",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4}},datalabels:{display:!1},scales:{x:{grid:{display:!0,color:Qe.slate[800]}},y:{grid:{display:!0,color:Qe.slate[800]}}}}}}};function Hy(e){var r,o,i,s,a,l;const t=(a=(s=(i=(o=(r=e==null?void 0:e.chart)==null?void 0:r.config)==null?void 0:o._config)==null?void 0:i.options)==null?void 0:s.plugins)==null?void 0:a.datalabels;let n=(l=e==null?void 0:e.dataset)==null?void 0:l.backgroundColor;return(t==null?void 0:t.align)==="end"&&(t==null?void 0:t.anchor)==="end"&&(n=Mu()),(t==null?void 0:t.align)==="start"&&(t==null?void 0:t.anchor)==="start"&&(n=Mu()),Dl(n)}function Mu(){return ie.getState().theme==="dark"?"#000000":"#FFFFFF"}function Dl(e){let t=0,n=0,r=0,o=0;const i=u=>{if(!u)return Qe.gray[500];const d=u.replace("#",""),h=parseInt(d.substring(0,2),16),f=parseInt(d.substring(2,4),16),p=parseInt(d.substring(4,6),16);t+=h,n+=f,r+=p,o++};Array.isArray(e)?e.forEach(u=>{i(u)}):i(e);const s=t/o,a=n/o,l=r/o;return(s*299+a*587+l*114)/1e3>=180?"black":"white"}const _8=["text","name","enum","varchar","nvarchar","nvarchar2","char","character","longtext","nchar","char varying","nchar varying","character varying","string"],E8=["number","integer","int","int64","bigint","smallint","tinyint","byteint","numeric","decimal","dec","double","real","double precision","float","float4","float8","float64"],R8=["date","datetime","time","timestamp","timestamp without time zone","timestamp_ns"],k8=["boolean"];function yx(e){return e.match(/[A-Z]/)?`"${e}"`:e}function Wp(e){return _8.includes(e.toLowerCase())||/varchar/i.test(e)}function pd(e){return E8.includes(e.toLowerCase())||/int|decimal|float|double/i.test(e)}function tc(e){return R8.includes(e.toLowerCase())||/date|time|timestamp/i.test(e)}function vx(e){return k8.includes(e.toLowerCase())||/boolean/i.test(e)}function P8(e,t,n,r,o){const{measures:i,dimensions:s}=e,a=i==null?void 0:i.map(d=>`${d.calc}(${d.name}) as ${d.calc}_${d.name.replace(/"/g,"")}`).join(", "),l=(s==null?void 0:s.join(", "))||"";let c="";const u=r?`${Dh}.${r}`:xx(t,n,o);if(a&&l)return c=`SELECT ${l}, COUNT(*) as count, ${a} FROM ${u} GROUP BY ${l} ORDER BY ${l} DESC LIMIT 100`,c;if(!a&&l)return c=`SELECT ${l}, COUNT(*) as count FROM ${u} GROUP BY ${l} ORDER BY ${l} DESC LIMIT 100`,c;if(a&&!l)return c=`SELECT ${a} FROM ${u} LIMIT 100`,c}function M8(e,t,n="AVG"){var i,s,a,l;let r={};const o=yx(e.column_name);return Wp(e.data_type)&&(((i=t.dimensions)==null?void 0:i.includes(o))?r={...t,dimensions:(s=t.dimensions)==null?void 0:s.filter(u=>u!==o)}:r={...t,dimensions:[...t.dimensions||[],o]}),pd(e.data_type)&&(((a=t.measures)==null?void 0:a.some(u=>u.name===o&&u.calc===n))?r={...t,measures:(l=t.measures)==null?void 0:l.filter(u=>!(u.name===o&&u.calc===n))}:r={...t,measures:[...t.measures||[],{name:o,calc:n||"SUM"}]}),r}function el(e){return Wp(e.dataType)?"string":pd(e.dataType)?"number":tc(e.dataType)?"date":vx(e.dataType)?"boolean":"string"}function O8(e){let t;const n=e.data_type.toLowerCase();return Wp(n)?t="T":pd(n)?t="#":tc(n)?t="D":vx(n)?t="B":t="?",t}function T8(e,t){const{dimensions:n,measures:r}=t,o=n==null?void 0:n.includes(e.column_name),i=r==null?void 0:r.some(s=>s.name===e.column_name);return o||i}function CP(e){return e?e!=null&&e.startsWith(`${Dh}.`)?e:`${Dh}.${e}`:""}function _P({schemaName:e,tableName:t,modelName:n,connectionType:r}){let o=xx(e,t,r);n&&(o=CP(n));let i=o;return(a=>/[A-Z]/.test(a))(t)&&(i=i.split(".").map(l=>`"${l}"`).join(".")),i}function xx(e,t,n){return t==="api"||e===yx("NA")||n==="S3"||n==="API"?t:e?`${e}.${t}`:`${t}`}const D8=e=>{const t=new Date(e);return!isNaN(t.getTime())},I8=e=>!isNaN(Number(e))&&!isNaN(parseFloat(e)),Up=e=>{let t;return typeof e=="number"?t="number":typeof e=="string"?D8(e)?t="date":I8(e)?t="number":t="string":typeof e=="boolean"?t="boolean":e instanceof Date?t="date":t="unknown",t};function A8({get:e,dataPoint:t,card:n}){var h;const{addOrUpdateFilterValue:r,addFilteringCard:o,removeFilterValues:i,replaceFilterValue:s,removeFilteringCard:a}=e().actions,l=e().filteringCards,{columnName:c,columnValue:u}=t,d={filterId:n.id,connectionId:n==null?void 0:n.connectionId,tableName:n.lastSelectedTable,name:c,expression:(h=n.preferences)==null?void 0:h.filterOnClickField,valueType:Up(u),operation:"=",values:[u]};if(l!=null&&l.find(f=>f.id===n.id)){const f=n.id;if(u==null){a(n),i(f);return}else s(d)}o(n),r(d)}function EC({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10},l=t?{...t}:{};return bx.forEach(c=>{l[c]||(l[c]=[]);const u=l[c].reduce((d,h)=>Math.max(d,h.y+h.h),0);a.y=a.y===1/0?u:a.y,l[c].push({...a})}),l}function RC(e,t){if(!t)return;const n={...t};return bx.forEach(r=>{n[r]&&(n[r]=n[r].filter(o=>o.i!==e))}),n}function wx(e){const t=ie.getState().dashboard.globalCacheConfig,{card:n,filter:r}=e;return t}const ie=fP()(vP((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:Ih},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{setInitStore:()=>{e(n=>{n.isSessionExpired=!1,n.currentBreakpoint="lg",n.dashboard={id:"",style:Ih},n.showContext=!1,n.selectedSheetId=null,n.selectedCardId=null,n.selectedFrameId=null,n.selectedCard=null,n.showFilters=!1,n.isDashboardEditing=!1,n.isVisualEditing=!1,n.showDashboardJSON=!1,n.filteringCards=[],n.selectedLensId=void 0,n.filterValues=void 0})},updateEmailSettings:n=>{e(r=>{r.dashboard.emailSettings=n})},setIsDownloadingPdf:n=>{e(r=>{r.isDownloadingPdf=n})},setGlobalCacheConfig:n=>{e(r=>{r.dashboard.globalCacheConfig=n})},setLenses:n=>{e(r=>{r.lenses=n})},setSelectedLensId:n=>{e(r=>{r.selectedLensId=n})},deleteSheet:n=>{e(r=>{var i,s,a,l,c,u,d,h;const o=(i=r.dashboard.sheets)==null?void 0:i.findIndex(f=>f.id===n);if(o!==void 0&&o>-1){(s=r.dashboard.sheets)==null||s.splice(o,1);const f=(a=r.dashboard.filters)==null?void 0:a.filter(g=>g.sheetId===n),p=(l=r.filterValues)==null?void 0:l.filter(g=>f==null?void 0:f.some(m=>m.id===g.filterId));r.filterValues=(c=r.filterValues)==null?void 0:c.filter(g=>!(p!=null&&p.some(m=>m.filterId===g.filterId))),r.dashboard.filters=(u=r.dashboard.filters)==null?void 0:u.filter(g=>g.sheetId!==n),r.selectedSheetId=(h=(d=r.dashboard.sheets)==null?void 0:d[0])==null?void 0:h.id}})},addSheet:n=>{e(r=>{r.dashboard.sheets||(r.dashboard.sheets=[]);const o=r.dashboard.filters;let i={};o==null||o.forEach(a=>{bx.forEach(l=>{i!=null&&i[l]||(i={...i,[l]:[]});const c={i:a.id,x:0,y:0,w:10,h:8};i[l].push(c)})});const s={...n,layouts:i};r.dashboard.sheets.push(s)})},setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},addToAIScope:n=>{e(r=>{const{connectionId:o,connectionType:i,databaseName:s,schemaName:a,tableName:l,datamodelName:c,datamodelId:u}=n,d={connectionId:o||"",connectionType:i||"",databaseName:s||"",schemaName:a||"",tableName:l||"",datamodelName:c||"",datamodelId:u||""};let f=[...r.dashboard.aiScopeTables||[],d];f=f.filter((p,g,m)=>m.findIndex(y=>y.tableName===p.tableName&&y.datamodelName===p.datamodelName)===g),r.dashboard.aiScopeTables=f})},removeFromAIScope:n=>{e(r=>{const{connectionId:o,tableName:i,datamodelName:s}=n,a=r.dashboard.aiScopeTables||[];if(s){const l=a.filter(c=>!(c.datamodelName===s&&c.connectionId===o));r.dashboard.aiScopeTables=l}else if(i){const l=a.filter(c=>!(c.tableName===i&&c.connectionId===o));r.dashboard.aiScopeTables=l}})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===o.selectedSheetId);i&&((l=i==null?void 0:i.frames)==null||l.forEach(c=>{var d;const u=(d=c.cards)==null?void 0:d.find(h=>h.id===n);u&&(u.python=r)}))})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},setFilteringCards:n=>{e(()=>({filteringCards:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setDashboardWithFilterValues:(n,r)=>{e(o=>{o.dashboard=n,o.filterValues=r})},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.title=r)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l,c;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(u=>u.id===n);s&&((c=s==null?void 0:s.frames)==null||c.forEach(u=>{var h;const d=(h=u.cards)==null?void 0:h.find(f=>f.id===r);d&&(d.title=o)}))})},setCardInfo:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===o.selectedSheetId);i&&((l=i==null?void 0:i.frames)==null||l.forEach(c=>{var d;const u=(d=c.cards)==null?void 0:d.find(h=>h.id===n);u&&(u.info=r)}))})},setCardDescription:(n,r,o)=>{e(i=>{var a,l,c;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(u=>u.id===n);s&&((c=s==null?void 0:s.frames)==null||c.forEach(u=>{var h;const d=(h=u.cards)==null?void 0:h.find(f=>f.id===r);d&&(d.description=o)}))})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(d=>d.id===n);if(s){const d=(c=s.cards)==null?void 0:c.find(h=>h.id===r);d&&(d.sql=o,(u=i.onUpdateCard)==null||u.call(i,d,n))}})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValues:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n],(s=r.dashboard.sheets)==null||s.find(a=>a.id===r.selectedSheetId);const o=r.dashboard.sheets;o==null||o.forEach(a=>{EC({id:n.id,layouts:a.layouts,y:0,initialHeight:8,minH:7,w:10})})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1),(s=r.dashboard.sheets)==null||s.find(c=>c.id===r.selectedSheetId);const l=r.dashboard.sheets;l==null||l.forEach(c=>{const u=RC(n,c.layouts);c.layouts=u})}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,d,h;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(f=>f.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(f=>f.id===r);if(a){const f=(d=a.cards)==null?void 0:d.findIndex(p=>p.id===o.id);f>-1&&((h=a.cards)==null||h.splice(f,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},updateFilterId:(n,r)=>{e(o=>{var a,l;const i=(a=o.dashboard.filters)==null?void 0:a.find(c=>c.id===n),s=(l=o.dashboard.filters)==null?void 0:l.some(c=>c.id===r);i&&!s&&(i.id=r)})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(d=>d.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let d=1/0;const h=0;o==="start"&&(d=0);const f=EC({id:r.id,layouts:s.layouts,minH:10,x:h,y:d});s.layouts=f,(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(d=>d.id===n);if(i){const d=(l=i.frames)==null?void 0:l.findIndex(h=>h.id===r);console.log(d),typeof d=="number"&&d>-1&&((c=i.frames)==null||c.splice(d,1),(u=i.layout)==null||u.splice(d,1),RC(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u,d;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r)),(d=o.onAcceptChanges)==null||d.call(o,r,o.dashboard)})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,d;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(d=o.onUpdateCard)==null||d.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,d,h;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(f=>f.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(d=i.layout)==null||d.splice(s,1),(h=o.onRemoveCard)==null||h.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnAcceptChanges:n=>{e(()=>({onAcceptChanges:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getCardFrame:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return a[l]}}},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},getCardSheet(n){var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return r[s]}}},handleDataPointClickAction:(n,r)=>{A8({card:n,dataPoint:r,get:t})}}}))),Vt=()=>ie(e=>e.actions);async function N8(e,t){const n=t.slice(0,16),r=new TextEncoder,o=await window.crypto.subtle.importKey("raw",r.encode(n),{name:"PBKDF2"},!1,["deriveKey"]),i=await window.crypto.subtle.deriveKey({name:"PBKDF2",salt:r.encode(n),iterations:1e5,hash:"SHA-256"},o,{name:"AES-GCM",length:256},!1,["encrypt"]),s=window.crypto.getRandomValues(new Uint8Array(12)),a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,r.encode(e)),l=new Uint8Array(s.length+a.byteLength);return l.set(s,0),l.set(new Uint8Array(a),s.length),{payload:btoa(String.fromCharCode(...l))}}async function EP(e,t){const n=t.slice(0,16),r=new TextEncoder,o=new TextDecoder,i=await window.crypto.subtle.importKey("raw",r.encode(n),{name:"PBKDF2"},!1,["deriveKey"]),s=await window.crypto.subtle.deriveKey({name:"PBKDF2",salt:r.encode(n),iterations:1e5,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!1,["decrypt"]),a=Uint8Array.from(atob(e),h=>h.charCodeAt(0)),l=a.slice(0,12),c=a.slice(a.length-16),u=a.slice(12,a.length-16),d=new Uint8Array(u.length+c.length);d.set(u),d.set(c,u.length);try{const h=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:l},s,d);return{decryptedData:o.decode(h)}}catch(h){throw new Error(`Decryption failed: ${h}`)}}function se(...e){return U6(Ml(e))}const F8=e=>Object.keys(e).length===0;async function j8(e,t,n={}){try{const r=new URLSearchParams(n).toString(),o=`${e}?${r}`,i=await fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(!i.ok){const a=await i.json();throw new Error((a==null?void 0:a.error)||`HTTP error! status: ${i.status}`)}return await i.json()}catch(r){throw console.error("Error during fetch:",r),r}}async function Gp(e,t,n={}){try{const r=JSON.stringify(n),o=await N8(r,t),i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(o)});if(!i.ok)return i.json().then(a=>{throw console.log(a.detail||"Unknown error occurred"),new Error((a==null?void 0:a.error)||`HTTP error! status: ${i.status}`)});const s=await i.json();if(s.payload){const a=await EP(s.payload,t);return JSON.parse(a.decryptedData)}return s}catch(r){throw console.error("Error during fetch:",r),r}}async function L8(e,t,n={}){try{const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n)});return r.ok?await r.json():r.json().then(i=>{throw console.log(i.detail||"Unknown error occurred"),new Error((i==null?void 0:i.error)||`HTTP error! status: ${r.status}`)})}catch(r){throw console.error("Error during fetch:",r),r}}function $8(e){if(!e)return{tenantId:"",endUserId:""};const t=ux(e);return{tenantId:t==null?void 0:t.tenantId,endUserId:t==null?void 0:t.endUserId}}function z8(e){if(!e)return;const t=ux(e);if(t.params&&t.params.currencyFormat)return t.params.currencyFormat}function RP(e){return e?ux(e).params:void 0}function B8(e){return e.charAt(0).toUpperCase()+e.slice(1)}const iu="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";async function V8(){var o,i;const e=(i=(o=ie.getState())==null?void 0:o.authToken)==null?void 0:i.accessToken;if(!e)return;const n=await fetch("https://semaphor.cloud/api/v1/invalidate-token",{method:"POST",headers:{Authorization:`Bearer ${e}`}});if(!n.ok)throw new Error("Failed to invalidate token");const r=await n.json();return console.log("invalidateToken",r),r}async function H8(e,t={}){if(!e)return null;let n="https://semaphor.cloud/api/v1/dashboard";const r=Object.fromEntries(Object.entries(t).filter(([a,l])=>l!==void 0)),o=new URLSearchParams(r).toString();o&&(n+=`?${o}`);let s=await(await fetch(n,{headers:{Authorization:`Bearer ${e}`}})).json();if("payload"in s){const a=await EP(atob(s.payload),e);s=JSON.parse(a.decryptedData)}return s}async function W8(e){return e?await(await fetch("https://semaphor.cloud/api/v1/plugins",{headers:{Authorization:`Bearer ${e}`}})).json():null}var Ah={exports:{}};Ah.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=800,i=16,s=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",h="[object Error]",f="[object Function]",p="[object GeneratorFunction]",g="[object Map]",m="[object Number]",y="[object Null]",x="[object Object]",v="[object Proxy]",_="[object RegExp]",w="[object Set]",S="[object String]",R="[object Undefined]",P="[object WeakMap]",O="[object ArrayBuffer]",D="[object DataView]",N="[object Float32Array]",A="[object Float64Array]",U="[object Int8Array]",$="[object Int16Array]",T="[object Int32Array]",F="[object Uint8Array]",I="[object Uint8ClampedArray]",j="[object Uint16Array]",H="[object Uint32Array]",M=/[\\^$.*+?()[\]{}|]/g,B=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,k={};k[N]=k[A]=k[U]=k[$]=k[T]=k[F]=k[I]=k[j]=k[H]=!0,k[a]=k[l]=k[O]=k[u]=k[D]=k[d]=k[h]=k[f]=k[g]=k[m]=k[x]=k[_]=k[w]=k[S]=k[P]=!1;var G=typeof ei=="object"&&ei&&ei.Object===Object&&ei,q=typeof self=="object"&&self&&self.Object===Object&&self,Y=G||q||Function("return this")(),V=t&&!t.nodeType&&t,W=V&&!0&&e&&!e.nodeType&&e,X=W&&W.exports===V,J=X&&G.process,ne=function(){try{var z=W&&W.require&&W.require("util").types;return z||J&&J.binding&&J.binding("util")}catch{}}(),Z=ne&&ne.isTypedArray;function oe(z,Q,re){switch(re.length){case 0:return z.call(Q);case 1:return z.call(Q,re[0]);case 2:return z.call(Q,re[0],re[1]);case 3:return z.call(Q,re[0],re[1],re[2])}return z.apply(Q,re)}function ee(z,Q){for(var re=-1,ye=Array(z);++re<z;)ye[re]=Q(re);return ye}function de(z){return function(Q){return z(Q)}}function fe(z,Q){return z==null?void 0:z[Q]}function xe(z,Q){return function(re){return z(Q(re))}}var pe=Array.prototype,be=Function.prototype,je=Object.prototype,tt=Y["__core-js_shared__"],Ht=be.toString,Ge=je.hasOwnProperty,er=function(){var z=/[^.]+$/.exec(tt&&tt.keys&&tt.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),St=je.toString,te=Ht.call(Object),ce=RegExp("^"+Ht.call(Ge).replace(M,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ve=X?Y.Buffer:void 0,ke=Y.Symbol,He=Y.Uint8Array;ve&&ve.allocUnsafe;var an=xe(Object.getPrototypeOf,Object),tr=Object.create,Sn=je.propertyIsEnumerable,In=pe.splice,ln=ke?ke.toStringTag:void 0,Ct=function(){try{var z=Pm(Object,"defineProperty");return z({},"",{}),z}catch{}}(),Zr=ve?ve.isBuffer:void 0,An=Math.max,Qd=Date.now,vc=Pm(Y,"Map"),as=Pm(Object,"create"),xc=function(){function z(){}return function(Q){if(!ls(Q))return{};if(tr)return tr(Q);z.prototype=Q;var re=new z;return z.prototype=void 0,re}}();function cn(z){var Q=-1,re=z==null?0:z.length;for(this.clear();++Q<re;){var ye=z[Q];this.set(ye[0],ye[1])}}function Em(){this.__data__=as?as(null):{},this.size=0}function De(z){var Q=this.has(z)&&delete this.__data__[z];return this.size-=Q?1:0,Q}function at(z){var Q=this.__data__;if(as){var re=Q[z];return re===r?void 0:re}return Ge.call(Q,z)?Q[z]:void 0}function yt(z){var Q=this.__data__;return as?Q[z]!==void 0:Ge.call(Q,z)}function nr(z,Q){var re=this.__data__;return this.size+=this.has(z)?0:1,re[z]=as&&Q===void 0?r:Q,this}cn.prototype.clear=Em,cn.prototype.delete=De,cn.prototype.get=at,cn.prototype.has=yt,cn.prototype.set=nr;function $t(z){var Q=-1,re=z==null?0:z.length;for(this.clear();++Q<re;){var ye=z[Q];this.set(ye[0],ye[1])}}function Jr(){this.__data__=[],this.size=0}function jo(z){var Q=this.__data__,re=Zd(Q,z);if(re<0)return!1;var ye=Q.length-1;return re==ye?Q.pop():In.call(Q,re,1),--this.size,!0}function rr(z){var Q=this.__data__,re=Zd(Q,z);return re<0?void 0:Q[re][1]}function eo(z){return Zd(this.__data__,z)>-1}function w3(z,Q){var re=this.__data__,ye=Zd(re,z);return ye<0?(++this.size,re.push([z,Q])):re[ye][1]=Q,this}$t.prototype.clear=Jr,$t.prototype.delete=jo,$t.prototype.get=rr,$t.prototype.has=eo,$t.prototype.set=w3;function Pa(z){var Q=-1,re=z==null?0:z.length;for(this.clear();++Q<re;){var ye=z[Q];this.set(ye[0],ye[1])}}function S3(){this.size=0,this.__data__={hash:new cn,map:new(vc||$t),string:new cn}}function C3(z){var Q=ef(this,z).delete(z);return this.size-=Q?1:0,Q}function _3(z){return ef(this,z).get(z)}function E3(z){return ef(this,z).has(z)}function R3(z,Q){var re=ef(this,z),ye=re.size;return re.set(z,Q),this.size+=re.size==ye?0:1,this}Pa.prototype.clear=S3,Pa.prototype.delete=C3,Pa.prototype.get=_3,Pa.prototype.has=E3,Pa.prototype.set=R3;function Ma(z){var Q=this.__data__=new $t(z);this.size=Q.size}function k3(){this.__data__=new $t,this.size=0}function P3(z){var Q=this.__data__,re=Q.delete(z);return this.size=Q.size,re}function M3(z){return this.__data__.get(z)}function O3(z){return this.__data__.has(z)}function T3(z,Q){var re=this.__data__;if(re instanceof $t){var ye=re.__data__;if(!vc||ye.length<n-1)return ye.push([z,Q]),this.size=++re.size,this;re=this.__data__=new Pa(ye)}return re.set(z,Q),this.size=re.size,this}Ma.prototype.clear=k3,Ma.prototype.delete=P3,Ma.prototype.get=M3,Ma.prototype.has=O3,Ma.prototype.set=T3;function D3(z,Q){var re=Tm(z),ye=!re&&Om(z),Xe=!re&&!ye&&nC(z),mt=!re&&!ye&&!Xe&&oC(z),Ot=re||ye||Xe||mt,rt=Ot?ee(z.length,String):[],Tt=rt.length;for(var Ar in z)Ot&&(Ar=="length"||Xe&&(Ar=="offset"||Ar=="parent")||mt&&(Ar=="buffer"||Ar=="byteLength"||Ar=="byteOffset")||eC(Ar,Tt))||rt.push(Ar);return rt}function Rm(z,Q,re){(re!==void 0&&!tf(z[Q],re)||re===void 0&&!(Q in z))&&km(z,Q,re)}function I3(z,Q,re){var ye=z[Q];(!(Ge.call(z,Q)&&tf(ye,re))||re===void 0&&!(Q in z))&&km(z,Q,re)}function Zd(z,Q){for(var re=z.length;re--;)if(tf(z[re][0],Q))return re;return-1}function km(z,Q,re){Q=="__proto__"&&Ct?Ct(z,Q,{configurable:!0,enumerable:!0,value:re,writable:!0}):z[Q]=re}var A3=q3();function Jd(z){return z==null?z===void 0?R:y:ln&&ln in Object(z)?Y3(z):e6(z)}function ZS(z){return wc(z)&&Jd(z)==a}function N3(z){if(!ls(z)||Z3(z))return!1;var Q=Im(z)?ce:B;return Q.test(o6(z))}function F3(z){return wc(z)&&rC(z.length)&&!!k[Jd(z)]}function j3(z){if(!ls(z))return J3(z);var Q=tC(z),re=[];for(var ye in z)ye=="constructor"&&(Q||!Ge.call(z,ye))||re.push(ye);return re}function JS(z,Q,re,ye,Xe){z!==Q&&A3(Q,function(mt,Ot){if(Xe||(Xe=new Ma),ls(mt))L3(z,Q,Ot,re,JS,ye,Xe);else{var rt=ye?ye(Mm(z,Ot),mt,Ot+"",z,Q,Xe):void 0;rt===void 0&&(rt=mt),Rm(z,Ot,rt)}},iC)}function L3(z,Q,re,ye,Xe,mt,Ot){var rt=Mm(z,re),Tt=Mm(Q,re),Ar=Ot.get(Tt);if(Ar){Rm(z,re,Ar);return}var or=mt?mt(rt,Tt,re+"",z,Q,Ot):void 0,Sc=or===void 0;if(Sc){var Am=Tm(Tt),Nm=!Am&&nC(Tt),aC=!Am&&!Nm&&oC(Tt);or=Tt,Am||Nm||aC?Tm(rt)?or=rt:i6(rt)?or=W3(rt):Nm?(Sc=!1,or=B3(Tt)):aC?(Sc=!1,or=H3(Tt)):or=[]:s6(Tt)||Om(Tt)?(or=rt,Om(rt)?or=a6(rt):(!ls(rt)||Im(rt))&&(or=K3(Tt))):Sc=!1}Sc&&(Ot.set(Tt,or),Xe(or,Tt,ye,mt,Ot),Ot.delete(Tt)),Rm(z,re,or)}function $3(z,Q){return n6(t6(z,Q,sC),z+"")}var z3=Ct?function(z,Q){return Ct(z,"toString",{configurable:!0,enumerable:!1,value:c6(Q),writable:!0})}:sC;function B3(z,Q){return z.slice()}function V3(z){var Q=new z.constructor(z.byteLength);return new He(Q).set(new He(z)),Q}function H3(z,Q){var re=V3(z.buffer);return new z.constructor(re,z.byteOffset,z.length)}function W3(z,Q){var re=-1,ye=z.length;for(Q||(Q=Array(ye));++re<ye;)Q[re]=z[re];return Q}function U3(z,Q,re,ye){var Xe=!re;re||(re={});for(var mt=-1,Ot=Q.length;++mt<Ot;){var rt=Q[mt],Tt=void 0;Tt===void 0&&(Tt=z[rt]),Xe?km(re,rt,Tt):I3(re,rt,Tt)}return re}function G3(z){return $3(function(Q,re){var ye=-1,Xe=re.length,mt=Xe>1?re[Xe-1]:void 0,Ot=Xe>2?re[2]:void 0;for(mt=z.length>3&&typeof mt=="function"?(Xe--,mt):void 0,Ot&&X3(re[0],re[1],Ot)&&(mt=Xe<3?void 0:mt,Xe=1),Q=Object(Q);++ye<Xe;){var rt=re[ye];rt&&z(Q,rt,ye,mt)}return Q})}function q3(z){return function(Q,re,ye){for(var Xe=-1,mt=Object(Q),Ot=ye(Q),rt=Ot.length;rt--;){var Tt=Ot[++Xe];if(re(mt[Tt],Tt,mt)===!1)break}return Q}}function ef(z,Q){var re=z.__data__;return Q3(Q)?re[typeof Q=="string"?"string":"hash"]:re.map}function Pm(z,Q){var re=fe(z,Q);return N3(re)?re:void 0}function Y3(z){var Q=Ge.call(z,ln),re=z[ln];try{z[ln]=void 0;var ye=!0}catch{}var Xe=St.call(z);return ye&&(Q?z[ln]=re:delete z[ln]),Xe}function K3(z){return typeof z.constructor=="function"&&!tC(z)?xc(an(z)):{}}function eC(z,Q){var re=typeof z;return Q=Q??s,!!Q&&(re=="number"||re!="symbol"&&L.test(z))&&z>-1&&z%1==0&&z<Q}function X3(z,Q,re){if(!ls(re))return!1;var ye=typeof Q;return(ye=="number"?Dm(re)&&eC(Q,re.length):ye=="string"&&Q in re)?tf(re[Q],z):!1}function Q3(z){var Q=typeof z;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?z!=="__proto__":z===null}function Z3(z){return!!er&&er in z}function tC(z){var Q=z&&z.constructor,re=typeof Q=="function"&&Q.prototype||je;return z===re}function J3(z){var Q=[];if(z!=null)for(var re in Object(z))Q.push(re);return Q}function e6(z){return St.call(z)}function t6(z,Q,re){return Q=An(Q===void 0?z.length-1:Q,0),function(){for(var ye=arguments,Xe=-1,mt=An(ye.length-Q,0),Ot=Array(mt);++Xe<mt;)Ot[Xe]=ye[Q+Xe];Xe=-1;for(var rt=Array(Q+1);++Xe<Q;)rt[Xe]=ye[Xe];return rt[Q]=re(Ot),oe(z,this,rt)}}function Mm(z,Q){if(!(Q==="constructor"&&typeof z[Q]=="function")&&Q!="__proto__")return z[Q]}var n6=r6(z3);function r6(z){var Q=0,re=0;return function(){var ye=Qd(),Xe=i-(ye-re);if(re=ye,Xe>0){if(++Q>=o)return arguments[0]}else Q=0;return z.apply(void 0,arguments)}}function o6(z){if(z!=null){try{return Ht.call(z)}catch{}try{return z+""}catch{}}return""}function tf(z,Q){return z===Q||z!==z&&Q!==Q}var Om=ZS(function(){return arguments}())?ZS:function(z){return wc(z)&&Ge.call(z,"callee")&&!Sn.call(z,"callee")},Tm=Array.isArray;function Dm(z){return z!=null&&rC(z.length)&&!Im(z)}function i6(z){return wc(z)&&Dm(z)}var nC=Zr||u6;function Im(z){if(!ls(z))return!1;var Q=Jd(z);return Q==f||Q==p||Q==c||Q==v}function rC(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=s}function ls(z){var Q=typeof z;return z!=null&&(Q=="object"||Q=="function")}function wc(z){return z!=null&&typeof z=="object"}function s6(z){if(!wc(z)||Jd(z)!=x)return!1;var Q=an(z);if(Q===null)return!0;var re=Ge.call(Q,"constructor")&&Q.constructor;return typeof re=="function"&&re instanceof re&&Ht.call(re)==te}var oC=Z?de(Z):F3;function a6(z){return U3(z,iC(z))}function iC(z){return Dm(z)?D3(z):j3(z)}var l6=G3(function(z,Q,re){JS(z,Q,re)});function c6(z){return function(){return z}}function sC(z){return z}function u6(){return!1}e.exports=l6})(Ah,Ah.exports);var U8=Ah.exports;const Ou=Qi(U8),G8={theme:"system",setTheme:()=>null},kP=E.createContext(G8);function q8({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=E.useState(()=>localStorage.getItem(n)||t);E.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return b.jsx(kP.Provider,{...r,value:s,children:e})}const PP=()=>{const e=E.useContext(kP);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};var gd=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(){}},oa=typeof window>"u"||"Deno"in globalThis;function _r(){}function Y8(e,t){return typeof e=="function"?e(t):e}function Wy(e){return typeof e=="number"&&e>=0&&e!==1/0}function MP(e,t){return Math.max(e+(t||0)-Date.now(),0)}function tl(e,t){return typeof e=="function"?e(t):e}function zr(e,t){return typeof e=="function"?e(t):e}function kC(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==Sx(s,t.options))return!1}else if(!Du(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||o&&o!==t.state.fetchStatus||i&&!i(t))}function PC(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Tu(t.options.mutationKey)!==Tu(i))return!1}else if(!Du(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function Sx(e,t){return((t==null?void 0:t.queryKeyHashFn)||Tu)(e)}function Tu(e){return JSON.stringify(e,(t,n)=>qy(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Du(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Du(e[n],t[n])):!1}function Uy(e,t){if(e===t)return e;const n=MC(e)&&MC(t);if(n||qy(e)&&qy(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(a[u]=void 0,l++):(a[u]=Uy(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function Gy(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 MC(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qy(e){if(!OC(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!OC(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function OC(e){return Object.prototype.toString.call(e)==="[object Object]"}function K8(e){return new Promise(t=>{setTimeout(t,e)})}function Yy(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 Uy(e,t)}catch(r){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}`)}return Uy(e,t)}return t}function X8(e){return e}function Q8(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Z8(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Nh=Symbol();function OP(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Nh&&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===Nh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var Ns,Ci,ml,X2,J8=(X2=class extends gd{constructor(){super();Ee(this,Ns);Ee(this,Ci);Ee(this,ml);me(this,ml,t=>{if(!oa&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){K(this,Ci)||this.setEventListener(K(this,ml))}onUnsubscribe(){var t;this.hasListeners()||((t=K(this,Ci))==null||t.call(this),me(this,Ci,void 0))}setEventListener(t){var n;me(this,ml,t),(n=K(this,Ci))==null||n.call(this),me(this,Ci,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){K(this,Ns)!==t&&(me(this,Ns,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof K(this,Ns)=="boolean"?K(this,Ns):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ns=new WeakMap,Ci=new WeakMap,ml=new WeakMap,X2),Cx=new J8,bl,_i,yl,Q2,e$=(Q2=class extends gd{constructor(){super();Ee(this,bl,!0);Ee(this,_i);Ee(this,yl);me(this,yl,t=>{if(!oa&&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(){K(this,_i)||this.setEventListener(K(this,yl))}onUnsubscribe(){var t;this.hasListeners()||((t=K(this,_i))==null||t.call(this),me(this,_i,void 0))}setEventListener(t){var n;me(this,yl,t),(n=K(this,_i))==null||n.call(this),me(this,_i,t(this.setOnline.bind(this)))}setOnline(t){K(this,bl)!==t&&(me(this,bl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return K(this,bl)}},bl=new WeakMap,_i=new WeakMap,yl=new WeakMap,Q2),Fh=new e$;function Ky(){let e,t;const n=new Promise((o,i)=>{e=o,t=i});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}function t$(e){return Math.min(1e3*2**e,3e4)}function TP(e){return(e??"online")==="online"?Fh.isOnline():!0}var DP=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Um(e){return e instanceof DP}function IP(e){let t=!1,n=0,r=!1,o;const i=Ky(),s=g=>{var m;r||(h(new DP(g)),(m=e.abort)==null||m.call(e))},a=()=>{t=!0},l=()=>{t=!1},c=()=>Cx.isFocused()&&(e.networkMode==="always"||Fh.isOnline())&&e.canRun(),u=()=>TP(e.networkMode)&&e.canRun(),d=g=>{var m;r||(r=!0,(m=e.onSuccess)==null||m.call(e,g),o==null||o(),i.resolve(g))},h=g=>{var m;r||(r=!0,(m=e.onError)==null||m.call(e,g),o==null||o(),i.reject(g))},f=()=>new Promise(g=>{var m;o=y=>{(r||c())&&g(y)},(m=e.onPause)==null||m.call(e)}).then(()=>{var g;o=void 0,r||(g=e.onContinue)==null||g.call(e)}),p=()=>{if(r)return;let g;const m=n===0?e.initialPromise:void 0;try{g=m??e.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(d).catch(y=>{var S;if(r)return;const x=e.retry??(oa?0:3),v=e.retryDelay??t$,_=typeof v=="function"?v(n,y):v,w=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,y);if(t||!w){h(y);return}n++,(S=e.onFail)==null||S.call(e,n,y),K8(_).then(()=>c()?void 0:f()).then(()=>{t?h(y):p()})})};return{promise:i,cancel:s,continue:()=>(o==null||o(),i),cancelRetry:a,continueRetry:l,canStart:u,start:()=>(u()?p():f().then(p),i)}}function n$(){let e=[],t=0,n=a=>{a()},r=a=>{a()},o=a=>setTimeout(a,0);const i=a=>{t?e.push(a):o(()=>{n(a)})},s=()=>{const a=e;e=[],a.length&&o(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||s()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{o=a}}}var rn=n$(),Fs,Z2,AP=(Z2=class{constructor(){Ee(this,Fs)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Wy(this.gcTime)&&me(this,Fs,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(oa?1/0:5*60*1e3))}clearGcTimeout(){K(this,Fs)&&(clearTimeout(K(this,Fs)),me(this,Fs,void 0))}},Fs=new WeakMap,Z2),vl,xl,Cr,js,hn,ud,Ls,Lr,Vo,J2,r$=(J2=class extends AP{constructor(t){super();Ee(this,Lr);Ee(this,vl);Ee(this,xl);Ee(this,Cr);Ee(this,js);Ee(this,hn);Ee(this,ud);Ee(this,Ls);me(this,Ls,!1),me(this,ud,t.defaultOptions),this.setOptions(t.options),this.observers=[],me(this,js,t.client),me(this,Cr,K(this,js).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,me(this,vl,o$(this.options)),this.state=t.state??K(this,vl),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=K(this,hn))==null?void 0:t.promise}setOptions(t){this.options={...K(this,ud),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&K(this,Cr).remove(this)}setData(t,n){const r=Yy(this.state.data,t,this.options);return Ye(this,Lr,Vo).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ye(this,Lr,Vo).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=K(this,hn))==null?void 0:r.promise;return(o=K(this,hn))==null||o.cancel(t),n?n.then(_r).catch(_r):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(K(this,vl))}isActive(){return this.observers.some(t=>zr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Nh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(t=0){return this.state.isInvalidated||this.state.data===void 0||!MP(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=K(this,hn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=K(this,hn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),K(this,Cr).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(K(this,hn)&&(K(this,Ls)?K(this,hn).cancel({revert:!0}):K(this,hn).cancelRetry()),this.scheduleGc()),K(this,Cr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ye(this,Lr,Vo).call(this,{type:"invalidate"})}fetch(t,n){var l,c,u;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(K(this,hn))return K(this,hn).continueRetry(),K(this,hn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const d=this.observers.find(h=>h.options.queryFn);d&&this.setOptions(d.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(me(this,Ls,!0),r.signal)})},i=()=>{const d=OP(this.options,n),h={client:K(this,js),queryKey:this.queryKey,meta:this.meta};return o(h),me(this,Ls,!1),this.options.persister?this.options.persister(d,h,this):d(h)},s={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:K(this,js),state:this.state,fetchFn:i};o(s),(l=this.options.behavior)==null||l.onFetch(s,this),me(this,xl,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((c=s.fetchOptions)==null?void 0:c.meta))&&Ye(this,Lr,Vo).call(this,{type:"fetch",meta:(u=s.fetchOptions)==null?void 0:u.meta});const a=d=>{var h,f,p,g;Um(d)&&d.silent||Ye(this,Lr,Vo).call(this,{type:"error",error:d}),Um(d)||((f=(h=K(this,Cr).config).onError)==null||f.call(h,d,this),(g=(p=K(this,Cr).config).onSettled)==null||g.call(p,this.state.data,d,this)),this.scheduleGc()};return me(this,hn,IP({initialPromise:n==null?void 0:n.initialPromise,fn:s.fetchFn,abort:r.abort.bind(r),onSuccess:d=>{var h,f,p,g;if(d===void 0){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}`),a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(d)}catch(m){a(m);return}(f=(h=K(this,Cr).config).onSuccess)==null||f.call(h,d,this),(g=(p=K(this,Cr).config).onSettled)==null||g.call(p,d,this.state.error,this),this.scheduleGc()},onError:a,onFail:(d,h)=>{Ye(this,Lr,Vo).call(this,{type:"failed",failureCount:d,error:h})},onPause:()=>{Ye(this,Lr,Vo).call(this,{type:"pause"})},onContinue:()=>{Ye(this,Lr,Vo).call(this,{type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0})),K(this,hn).start()}},vl=new WeakMap,xl=new WeakMap,Cr=new WeakMap,js=new WeakMap,hn=new WeakMap,ud=new WeakMap,Ls=new WeakMap,Lr=new WeakSet,Vo=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,...NP(r.data,this.options),fetchMeta:t.meta??null};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return Um(o)&&o.revert&&K(this,xl)?{...K(this,xl),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),rn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),K(this,Cr).notify({query:this,type:"updated",action:t})})},J2);function NP(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:TP(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function o$(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 so,eP,FP=(eP=class extends gd{constructor(t={}){super();Ee(this,so);this.config=t,me(this,so,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??Sx(o,n);let s=this.get(i);return s||(s=new r$({client:t,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){K(this,so).has(t.queryHash)||(K(this,so).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=K(this,so).get(t.queryHash);n&&(t.destroy(),n===t&&K(this,so).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){rn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return K(this,so).get(t)}getAll(){return[...K(this,so).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>kC(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>kC(t,r)):n}notify(t){rn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){rn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){rn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},so=new WeakMap,eP),ao,_n,$s,lo,vi,tP,i$=(tP=class extends AP{constructor(t){super();Ee(this,lo);Ee(this,ao);Ee(this,_n);Ee(this,$s);this.mutationId=t.mutationId,me(this,_n,t.mutationCache),me(this,ao,[]),this.state=t.state||s$(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){K(this,ao).includes(t)||(K(this,ao).push(t),this.clearGcTimeout(),K(this,_n).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){me(this,ao,K(this,ao).filter(n=>n!==t)),this.scheduleGc(),K(this,_n).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){K(this,ao).length||(this.state.status==="pending"?this.scheduleGc():K(this,_n).remove(this))}continue(){var t;return((t=K(this,$s))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,d,h,f,p,g,m,y,x,v,_,w,S,R;me(this,$s,IP({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(P,O)=>{Ye(this,lo,vi).call(this,{type:"failed",failureCount:P,error:O})},onPause:()=>{Ye(this,lo,vi).call(this,{type:"pause"})},onContinue:()=>{Ye(this,lo,vi).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>K(this,_n).canRun(this)}));const n=this.state.status==="pending",r=!K(this,$s).canStart();try{if(!n){Ye(this,lo,vi).call(this,{type:"pending",variables:t,isPaused:r}),await((i=(o=K(this,_n).config).onMutate)==null?void 0:i.call(o,t,this));const O=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));O!==this.state.context&&Ye(this,lo,vi).call(this,{type:"pending",context:O,variables:t,isPaused:r})}const P=await K(this,$s).start();return await((c=(l=K(this,_n).config).onSuccess)==null?void 0:c.call(l,P,t,this.state.context,this)),await((d=(u=this.options).onSuccess)==null?void 0:d.call(u,P,t,this.state.context)),await((f=(h=K(this,_n).config).onSettled)==null?void 0:f.call(h,P,null,this.state.variables,this.state.context,this)),await((g=(p=this.options).onSettled)==null?void 0:g.call(p,P,null,t,this.state.context)),Ye(this,lo,vi).call(this,{type:"success",data:P}),P}catch(P){try{throw await((y=(m=K(this,_n).config).onError)==null?void 0:y.call(m,P,t,this.state.context,this)),await((v=(x=this.options).onError)==null?void 0:v.call(x,P,t,this.state.context)),await((w=(_=K(this,_n).config).onSettled)==null?void 0:w.call(_,void 0,P,this.state.variables,this.state.context,this)),await((R=(S=this.options).onSettled)==null?void 0:R.call(S,void 0,P,t,this.state.context)),P}finally{Ye(this,lo,vi).call(this,{type:"error",error:P})}}finally{K(this,_n).runNext(this)}}},ao=new WeakMap,_n=new WeakMap,$s=new WeakMap,lo=new WeakSet,vi=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),rn.batch(()=>{K(this,ao).forEach(r=>{r.onMutationUpdate(t)}),K(this,_n).notify({mutation:this,type:"updated",action:t})})},tP);function s$(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ko,$r,dd,nP,a$=(nP=class extends gd{constructor(t={}){super();Ee(this,Ko);Ee(this,$r);Ee(this,dd);this.config=t,me(this,Ko,new Set),me(this,$r,new Map),me(this,dd,0)}build(t,n,r){const o=new i$({mutationCache:this,mutationId:++nf(this,dd)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){K(this,Ko).add(t);const n=sf(t);if(typeof n=="string"){const r=K(this,$r).get(n);r?r.push(t):K(this,$r).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(K(this,Ko).delete(t)){const n=sf(t);if(typeof n=="string"){const r=K(this,$r).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&K(this,$r).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=sf(t);if(typeof n=="string"){const r=K(this,$r).get(n),o=r==null?void 0:r.find(i=>i.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=sf(t);if(typeof n=="string"){const o=(r=K(this,$r).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){rn.batch(()=>{K(this,Ko).forEach(t=>{this.notify({type:"removed",mutation:t})}),K(this,Ko).clear(),K(this,$r).clear()})}getAll(){return Array.from(K(this,Ko))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>PC(n,r))}findAll(t={}){return this.getAll().filter(n=>PC(t,n))}notify(t){rn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return rn.batch(()=>Promise.all(t.map(n=>n.continue().catch(_r))))}},Ko=new WeakMap,$r=new WeakMap,dd=new WeakMap,nP);function sf(e){var t;return(t=e.options.scope)==null?void 0:t.id}function TC(e){return{onFetch:(t,n)=>{var u,d,h,f,p;const r=t.options,o=(h=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:h.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],s=((p=t.state.data)==null?void 0:p.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let g=!1;const m=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},y=OP(t.options,t.fetchOptions),x=async(v,_,w)=>{if(g)return Promise.reject();if(_==null&&v.pages.length)return Promise.resolve(v);const S={client:t.client,queryKey:t.queryKey,pageParam:_,direction:w?"backward":"forward",meta:t.options.meta};m(S);const R=await y(S),{maxPages:P}=t.options,O=w?Z8:Q8;return{pages:O(v.pages,R,P),pageParams:O(v.pageParams,_,P)}};if(o&&i.length){const v=o==="backward",_=v?l$:DC,w={pages:i,pageParams:s},S=_(r,w);a=await x(w,S,v)}else{const v=e??i.length;do{const _=l===0?s[0]??r.initialPageParam:DC(r,a);if(l>0&&_==null)break;a=await x(a,_),l++}while(l<v)}return a};t.options.persister?t.fetchFn=()=>{var g,m;return(m=(g=t.options).persister)==null?void 0:m.call(g,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function DC(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 l$(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 At,Ei,Ri,wl,Sl,ki,Cl,_l,rP,c$=(rP=class{constructor(e={}){Ee(this,At);Ee(this,Ei);Ee(this,Ri);Ee(this,wl);Ee(this,Sl);Ee(this,ki);Ee(this,Cl);Ee(this,_l);me(this,At,e.queryCache||new FP),me(this,Ei,e.mutationCache||new a$),me(this,Ri,e.defaultOptions||{}),me(this,wl,new Map),me(this,Sl,new Map),me(this,ki,0)}mount(){nf(this,ki)._++,K(this,ki)===1&&(me(this,Cl,Cx.subscribe(async e=>{e&&(await this.resumePausedMutations(),K(this,At).onFocus())})),me(this,_l,Fh.subscribe(async e=>{e&&(await this.resumePausedMutations(),K(this,At).onOnline())})))}unmount(){var e,t;nf(this,ki)._--,K(this,ki)===0&&((e=K(this,Cl))==null||e.call(this),me(this,Cl,void 0),(t=K(this,_l))==null||t.call(this),me(this,_l,void 0))}isFetching(e){return K(this,At).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return K(this,Ei).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=K(this,At).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=K(this,At).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(tl(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return K(this,At).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=K(this,At).get(r.queryHash),i=o==null?void 0:o.state.data,s=Y8(t,i);if(s!==void 0)return K(this,At).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return rn.batch(()=>K(this,At).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=K(this,At).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=K(this,At);rn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=K(this,At);return rn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=rn.batch(()=>K(this,At).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(_r).catch(_r)}invalidateQueries(e,t={}){return rn.batch(()=>(K(this,At).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=rn.batch(()=>K(this,At).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(_r)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(_r)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=K(this,At).build(this,t);return n.isStaleByTime(tl(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(_r).catch(_r)}fetchInfiniteQuery(e){return e.behavior=TC(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(_r).catch(_r)}ensureInfiniteQueryData(e){return e.behavior=TC(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Fh.isOnline()?K(this,Ei).resumePausedMutations():Promise.resolve()}getQueryCache(){return K(this,At)}getMutationCache(){return K(this,Ei)}getDefaultOptions(){return K(this,Ri)}setDefaultOptions(e){me(this,Ri,e)}setQueryDefaults(e,t){K(this,wl).set(Tu(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...K(this,wl).values()],n={};return t.forEach(r=>{Du(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){K(this,Sl).set(Tu(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...K(this,Sl).values()],n={};return t.forEach(r=>{Du(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...K(this,Ri).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Sx(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===Nh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...K(this,Ri).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){K(this,At).clear(),K(this,Ei).clear()}},At=new WeakMap,Ei=new WeakMap,Ri=new WeakMap,wl=new WeakMap,Sl=new WeakMap,ki=new WeakMap,Cl=new WeakMap,_l=new WeakMap,rP),Bn,Ke,fd,En,zs,El,Pi,co,hd,Rl,kl,Bs,Vs,Mi,Pl,dt,Vc,Xy,Qy,Zy,Jy,e0,t0,n0,jP,oP,u$=(oP=class extends gd{constructor(t,n){super();Ee(this,dt);Ee(this,Bn);Ee(this,Ke);Ee(this,fd);Ee(this,En);Ee(this,zs);Ee(this,El);Ee(this,Pi);Ee(this,co);Ee(this,hd);Ee(this,Rl);Ee(this,kl);Ee(this,Bs);Ee(this,Vs);Ee(this,Mi);Ee(this,Pl,new Set);this.options=n,me(this,Bn,t),me(this,co,null),me(this,Pi,Ky()),this.options.experimental_prefetchInRender||K(this,Pi).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(K(this,Ke).addObserver(this),IC(K(this,Ke),this.options)?Ye(this,dt,Vc).call(this):this.updateResult(),Ye(this,dt,Jy).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return r0(K(this,Ke),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return r0(K(this,Ke),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ye(this,dt,e0).call(this),Ye(this,dt,t0).call(this),K(this,Ke).removeObserver(this)}setOptions(t,n){const r=this.options,o=K(this,Ke);if(this.options=K(this,Bn).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof zr(this.options.enabled,K(this,Ke))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ye(this,dt,n0).call(this),K(this,Ke).setOptions(this.options),r._defaulted&&!Gy(this.options,r)&&K(this,Bn).getQueryCache().notify({type:"observerOptionsUpdated",query:K(this,Ke),observer:this});const i=this.hasListeners();i&&AC(K(this,Ke),o,this.options,r)&&Ye(this,dt,Vc).call(this),this.updateResult(n),i&&(K(this,Ke)!==o||zr(this.options.enabled,K(this,Ke))!==zr(r.enabled,K(this,Ke))||tl(this.options.staleTime,K(this,Ke))!==tl(r.staleTime,K(this,Ke)))&&Ye(this,dt,Xy).call(this);const s=Ye(this,dt,Qy).call(this);i&&(K(this,Ke)!==o||zr(this.options.enabled,K(this,Ke))!==zr(r.enabled,K(this,Ke))||s!==K(this,Mi))&&Ye(this,dt,Zy).call(this,s)}getOptimisticResult(t){const n=K(this,Bn).getQueryCache().build(K(this,Bn),t),r=this.createResult(n,t);return f$(this,r)&&(me(this,En,r),me(this,El,this.options),me(this,zs,K(this,Ke).state)),r}getCurrentResult(){return K(this,En)}trackResult(t,n){const r={};return Object.keys(t).forEach(o=>{Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(o),n==null||n(o),t[o])})}),r}trackProp(t){K(this,Pl).add(t)}getCurrentQuery(){return K(this,Ke)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=K(this,Bn).defaultQueryOptions(t),r=K(this,Bn).getQueryCache().build(K(this,Bn),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ye(this,dt,Vc).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),K(this,En)))}createResult(t,n){var P;const r=K(this,Ke),o=this.options,i=K(this,En),s=K(this,zs),a=K(this,El),c=t!==r?t.state:K(this,fd),{state:u}=t;let d={...u},h=!1,f;if(n._optimisticResults){const O=this.hasListeners(),D=!O&&IC(t,n),N=O&&AC(t,r,n,o);(D||N)&&(d={...d,...NP(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:m}=d;if(n.select&&d.data!==void 0)if(i&&d.data===(s==null?void 0:s.data)&&n.select===K(this,hd))f=K(this,Rl);else try{me(this,hd,n.select),f=n.select(d.data),f=Yy(i==null?void 0:i.data,f,n),me(this,Rl,f),me(this,co,null)}catch(O){me(this,co,O)}else f=d.data;if(n.placeholderData!==void 0&&f===void 0&&m==="pending"){let O;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))O=i.data;else if(O=typeof n.placeholderData=="function"?n.placeholderData((P=K(this,kl))==null?void 0:P.state.data,K(this,kl)):n.placeholderData,n.select&&O!==void 0)try{O=n.select(O),me(this,co,null)}catch(D){me(this,co,D)}O!==void 0&&(m="success",f=Yy(i==null?void 0:i.data,O,n),h=!0)}K(this,co)&&(p=K(this,co),f=K(this,Rl),g=Date.now(),m="error");const y=d.fetchStatus==="fetching",x=m==="pending",v=m==="error",_=x&&y,w=f!==void 0,R={status:m,fetchStatus:d.fetchStatus,isPending:x,isSuccess:m==="success",isError:v,isInitialLoading:_,isLoading:_,data:f,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:v&&!w,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:v&&w,isStale:_x(t,n),refetch:this.refetch,promise:K(this,Pi)};if(this.options.experimental_prefetchInRender){const O=A=>{R.status==="error"?A.reject(R.error):R.data!==void 0&&A.resolve(R.data)},D=()=>{const A=me(this,Pi,R.promise=Ky());O(A)},N=K(this,Pi);switch(N.status){case"pending":t.queryHash===r.queryHash&&O(N);break;case"fulfilled":(R.status==="error"||R.data!==N.value)&&D();break;case"rejected":(R.status!=="error"||R.error!==N.reason)&&D();break}}return R}updateResult(t){const n=K(this,En),r=this.createResult(K(this,Ke),this.options);if(me(this,zs,K(this,Ke).state),me(this,El,this.options),K(this,zs).data!==void 0&&me(this,kl,K(this,Ke)),Gy(r,n))return;me(this,En,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!K(this,Pl).size)return!0;const l=new Set(a??K(this,Pl));return this.options.throwOnError&&l.add("error"),Object.keys(K(this,En)).some(c=>{const u=c;return K(this,En)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),Ye(this,dt,jP).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ye(this,dt,Jy).call(this)}},Bn=new WeakMap,Ke=new WeakMap,fd=new WeakMap,En=new WeakMap,zs=new WeakMap,El=new WeakMap,Pi=new WeakMap,co=new WeakMap,hd=new WeakMap,Rl=new WeakMap,kl=new WeakMap,Bs=new WeakMap,Vs=new WeakMap,Mi=new WeakMap,Pl=new WeakMap,dt=new WeakSet,Vc=function(t){Ye(this,dt,n0).call(this);let n=K(this,Ke).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(_r)),n},Xy=function(){Ye(this,dt,e0).call(this);const t=tl(this.options.staleTime,K(this,Ke));if(oa||K(this,En).isStale||!Wy(t))return;const r=MP(K(this,En).dataUpdatedAt,t)+1;me(this,Bs,setTimeout(()=>{K(this,En).isStale||this.updateResult()},r))},Qy=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(K(this,Ke)):this.options.refetchInterval)??!1},Zy=function(t){Ye(this,dt,t0).call(this),me(this,Mi,t),!(oa||zr(this.options.enabled,K(this,Ke))===!1||!Wy(K(this,Mi))||K(this,Mi)===0)&&me(this,Vs,setInterval(()=>{(this.options.refetchIntervalInBackground||Cx.isFocused())&&Ye(this,dt,Vc).call(this)},K(this,Mi)))},Jy=function(){Ye(this,dt,Xy).call(this),Ye(this,dt,Zy).call(this,Ye(this,dt,Qy).call(this))},e0=function(){K(this,Bs)&&(clearTimeout(K(this,Bs)),me(this,Bs,void 0))},t0=function(){K(this,Vs)&&(clearInterval(K(this,Vs)),me(this,Vs,void 0))},n0=function(){const t=K(this,Bn).getQueryCache().build(K(this,Bn),this.options);if(t===K(this,Ke))return;const n=K(this,Ke);me(this,Ke,t),me(this,fd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},jP=function(t){rn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(K(this,En))}),K(this,Bn).getQueryCache().notify({query:K(this,Ke),type:"observerResultsUpdated"})})},oP);function d$(e,t){return zr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function IC(e,t){return d$(e,t)||e.state.data!==void 0&&r0(e,t,t.refetchOnMount)}function r0(e,t,n){if(zr(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&_x(e,t)}return!1}function AC(e,t,n,r){return(e!==t||zr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&_x(e,n)}function _x(e,t){return zr(t.enabled,e)!==!1&&e.isStaleByTime(tl(t.staleTime,e))}function f$(e,t){return!Gy(e.getCurrentResult(),t)}var Ex=C.createContext(void 0),Rx=e=>{const t=C.useContext(Ex);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},h$=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),b.jsx(Ex.Provider,{value:e,children:t})),LP=C.createContext(!1),p$=()=>C.useContext(LP);LP.Provider;function g$(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var m$=C.createContext(g$()),b$=()=>C.useContext(m$);function y$(e,t){return typeof e=="function"?e(...t):!!e}function NC(){}var v$=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},x$=e=>{C.useEffect(()=>{e.clearReset()},[e])},w$=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||y$(n,[e.error,r])),S$=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},C$=(e,t)=>e.isLoading&&e.isFetching&&!t,_$=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,FC=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function E$(e,t,n){var d,h,f,p,g;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=Rx(),o=p$(),i=b$(),s=r.defaultQueryOptions(e);(h=(d=r.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||h.call(d,s),process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.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`)),s._optimisticResults=o?"isRestoring":"optimistic",S$(s),v$(s,i),x$(i);const a=!r.getQueryCache().get(s.queryHash),[l]=C.useState(()=>new t(r,s)),c=l.getOptimisticResult(s),u=!o&&e.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(m=>{const y=u?l.subscribe(rn.batchCalls(m)):NC;return l.updateResult(),y},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),C.useEffect(()=>{l.setOptions(s,{listeners:!1})},[s,l]),_$(s,c))throw FC(s,l,i);if(w$({result:c,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw c.error;if((p=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||p.call(f,s,c),s.experimental_prefetchInRender&&!oa&&C$(c,o)){const m=a?FC(s,l,i):(g=r.getQueryCache().get(s.queryHash))==null?void 0:g.promise;m==null||m.catch(NC).finally(()=>{l.updateResult()})}return s.notifyOnChangeProps?c:l.trackResult(c)}function md(e,t){return E$(e,u$)}function R$(){const e=E.useContext(Ex);if(e&&e.isSemaphorClient)return e}function $P({children:e}){const{setIsSessionExpired:t}=Vt(),n=R$(),[r]=E.useState(()=>{const o=new c$({queryCache:new FP({onError:i=>{i instanceof Error?(console.error(`Something went wrong: ${i.message}`),i.message==="invalid token"&&t(!0)):console.error("Something went wrong:",i)}}),defaultOptions:{queries:{gcTime:36e5,staleTime:3e5,refetchOnWindowFocus:!1,retry:1}}});return o.isSemaphorClient=!0,o});return n?b.jsx(b.Fragment,{children:e}):b.jsx(h$,{client:r,children:e})}const Zi=E.forwardRef(({children:e,className:t,...n},r)=>b.jsx("div",{className:se("semaphor-scope",t),ref:r,...n,children:e})),k$={id:"",authToken:void 0},zP=E.createContext(k$),BP=({children:e,dashboardProps:t})=>b.jsx($P,{children:b.jsx(zP.Provider,{value:t,children:b.jsx(Zi,{style:{height:"100%"},children:e})})});function xr(){const e=E.useContext(zP);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}function P$(){const{authToken:e,version:t}=xr(),n=ie(l=>l.selectedLensId);function r(){if(!(e!=null&&e.accessToken))return!1}const{data:o,isLoading:i,isFetching:s,isError:a}=md({queryKey:["dashboard",n,e==null?void 0:e.accessToken],queryFn:()=>H8(e==null?void 0:e.accessToken,{lensId:n,version:t}),enabled:r()});return{data:o,isLoading:i,isFetching:s,isError:a}}function M$(){const{authToken:e}=xr(),t=ie(r=>r.authToken),{setAuthToken:n}=Vt();return E.useEffect(()=>{e&&(e==null?void 0:e.toString())!==(t==null?void 0:t.toString())&&n(e)},[e,t,n]),e}const VP=(e,t)=>{const n={};if(e===null||t===null)return t;const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const o of r){if(!(o in e)&&o in t){n[o]=t[o];continue}if(o in e&&!(o in t)){n[o]=void 0;continue}const i=e[o],s=t[o];if(!o0(i,s))if(Array.isArray(i)&&Array.isArray(s))n[o]=s;else if(jC(i)&&jC(s)){const a=VP(i,s);Object.keys(a).length>0&&(n[o]=a)}else n[o]=s}return n},o0=(e,t)=>{if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((o,i)=>o0(o,t[i]));const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(o=>o0(e[o],t[o]))}return!1},jC=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),jh=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=>jh(n));const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=jh(e[n]));return t};function HP(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function LC(e,t){const n=HP(e);return n==="dark"?Ou({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function O$({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o,selectedSheetId:i,onFilterValuesChange:s}){const{authToken:a}=xr();M$();const l=ie(F=>F.selectedLensId),{data:c,isLoading:u,isFetching:d,isError:h}=P$(),[f,p]=E.useState(o||[]),{theme:g,setTheme:m}=PP(),y=ie(F=>F.dashboard.globalStyle),{setDashboard:x,setDashboardWithFilterValues:v,setSelectedSheetId:_,setStyle:w,setOnSaveFunction:S,setLenses:R,setSelectedLensId:P,setInitStore:O}=Vt();ie(F=>F.actions.setCustomCards);const D=ie(F=>F.actions.setFilterValues),N=ie(F=>F.filterValues),A=ie(F=>F.actions.setThemeStyle),U=ie(F=>F.actions.setDashboardTheme),$=ie(F=>F.actions.setOnEvent);E.useEffect(()=>{a&&O()},[a,O]),E.useEffect(()=>{if(g){const F=HP(g);U(F)}},[g,U]),E.useEffect(()=>{t&&m(t)},[t,m]);const T=E.useCallback(()=>{const F=jh(Ih),I=Ou(F,y);if(e){const j=Ou(I,e),H=LC(g,j);A(H),w(j)}else{const j=LC(g,I);A(j),w(Ih)}},[g,e,y,A,w]);return E.useEffect(()=>{c&&c.dashboard&&T()},[g,e,y,T,c]),E.useEffect(()=>{var L,k;function F(G,q){const Y=G.filters||[],V=[];for(const W of q){const X=Y.find(J=>J.id===W.filterId);X&&V.push({filterId:W.filterId,connectionType:X.database==="NA"?"api":"database",name:X.column,operation:X.operation,valueType:el(X),values:W.values})}return V}if(!c||!c.dashboard)return;const{dashboard:I,filterValues:j,defaultLensId:H,lenses:M}=c,B=F(I,f||[]);v(I,(!j||(j==null?void 0:j.length)===0?B:j)||[]),M&&R(M),H&&P(H),_(i||((k=(L=I==null?void 0:I.sheets)==null?void 0:L[0])==null?void 0:k.id)||null)},[c,x,_,D,l,R,v,P,f,i]),E.useEffect(()=>{s&&N&&s(N)},[N,s]),E.useEffect(()=>{n&&S(n),r&&$(r)},[n,S,r,$]),{isFetching:d,isLoading:u,isError:h}}function nl({className:e,...t}){return b.jsx("div",{className:se("animate-pulse rounded-md bg-muted",e),...t})}const WP=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));WP.displayName="Card";const qp=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("flex flex-col space-y-1.5 p-6",e),...t}));qp.displayName="CardHeader";const nc=C.forwardRef(({className:e,...t},n)=>b.jsx("h3",{ref:n,className:se("text-2xl font-semibold leading-none tracking-tight",e),...t}));nc.displayName="CardTitle";const kx=C.forwardRef(({className:e,...t},n)=>b.jsx("p",{ref:n,className:se("text-sm text-muted-foreground",e),...t}));kx.displayName="CardDescription";const Yp=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("px-6 pt-0",e),...t}));Yp.displayName="CardContent";const UP=C.forwardRef(({className:e,...t},n)=>b.jsx("div",{ref:n,className:se("flex items-center p-6 pt-0",e),...t}));UP.displayName="CardFooter";function GP({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:d,showAssistant:h,defaultFilterValues:f,onFilterValuesChange:p,selectedSheetId:g,...m}){const{placeholders:y}=xr(),x=ie(S=>S.themeStyle),v=ie(S=>S.isSessionExpired),{isLoading:_,isError:w}=O$({customStyle:t,currentTheme:c,onSave:n,onEvent:r,defaultFilterValues:f,onFilterValuesChange:p,selectedSheetId:g});return _||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?b.jsx(o,{message:"loading"}):b.jsx("div",{className:"flex items-center gap-3",children:b.jsx(nl,{className:"h-1 w-full dark:h-[2px]"})})):w?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),b.jsx(i,{})):b.jsx("div",{children:"Error"})):v?(r==null||r({type:"error",message:"Session Expired"}),y!=null&&y.SessionExpired?b.jsx("div",{className:"flex h-full items-center justify-center",children:b.jsx("div",{children:y.SessionExpired})}):b.jsx("div",{className:"flex h-full items-center justify-center",children:b.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[b.jsx(nc,{children:"Session Expired"}),b.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):b.jsx("div",{className:se("isolate flex h-full flex-col justify-between",x==null?void 0:x.dashboardPanel,e),style:{},"data-role":"dashboard-panel",...m})}function le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function T$(e,t){const n=C.createContext(t),r=i=>{const{children:s,...a}=i,l=C.useMemo(()=>a,Object.values(a));return b.jsx(n.Provider,{value:l,children:s})};r.displayName=e+"Provider";function o(i){const s=C.useContext(n);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Xt(e,t=[]){let n=[];function r(i,s){const a=C.createContext(s),l=n.length;n=[...n,s];const c=d=>{var y;const{scope:h,children:f,...p}=d,g=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,m=C.useMemo(()=>p,Object.values(p));return b.jsx(g.Provider,{value:m,children:f})};c.displayName=i+"Provider";function u(d,h){var g;const f=((g=h==null?void 0:h[e])==null?void 0:g[l])||a,p=C.useContext(f);if(p)return p;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>C.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return C.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,D$(o,...t)]}function D$(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return C.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function $C(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Kp(...e){return t=>{let n=!1;const r=e.map(o=>{const i=$C(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():$C(e[o],null)}}}}function Te(...e){return C.useCallback(Kp(...e),e)}var si=C.forwardRef((e,t)=>{const{children:n,...r}=e,o=C.Children.toArray(n),i=o.find(I$);if(i){const s=i.props.children,a=o.map(l=>l===i?C.Children.count(s)>1?C.Children.only(null):C.isValidElement(s)?s.props.children:null:l);return b.jsx(i0,{...r,ref:t,children:C.isValidElement(s)?C.cloneElement(s,void 0,a):null})}return b.jsx(i0,{...r,ref:t,children:n})});si.displayName="Slot";var i0=C.forwardRef((e,t)=>{const{children:n,...r}=e;if(C.isValidElement(n)){const o=N$(n),i=A$(r,n.props);return n.type!==C.Fragment&&(i.ref=t?Kp(t,o):o),C.cloneElement(n,i)}return C.Children.count(n)>1?C.Children.only(null):null});i0.displayName="SlotClone";var Px=({children:e})=>b.jsx(b.Fragment,{children:e});function I$(e){return C.isValidElement(e)&&e.type===Px}function A$(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function N$(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Xp(e){const t=e+"CollectionProvider",[n,r]=Xt(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=f=>{const{scope:p,children:g}=f,m=E.useRef(null),y=E.useRef(new Map).current;return b.jsx(o,{scope:p,itemMap:y,collectionRef:m,children:g})};s.displayName=t;const a=e+"CollectionSlot",l=E.forwardRef((f,p)=>{const{scope:g,children:m}=f,y=i(a,g),x=Te(p,y.collectionRef);return b.jsx(si,{ref:x,children:m})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",d=E.forwardRef((f,p)=>{const{scope:g,children:m,...y}=f,x=E.useRef(null),v=Te(p,x),_=i(c,g);return E.useEffect(()=>(_.itemMap.set(x,{ref:x,...y}),()=>void _.itemMap.delete(x))),b.jsx(si,{[u]:"",ref:v,children:m})});d.displayName=c;function h(f){const p=i(e+"CollectionConsumer",f);return E.useCallback(()=>{const m=p.collectionRef.current;if(!m)return[];const y=Array.from(m.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((_,w)=>y.indexOf(_.ref.current)-y.indexOf(w.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},h,r]}var on=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{},F$=C.useId||(()=>{}),j$=0;function qt(e){const[t,n]=C.useState(F$());return on(()=>{n(r=>r??String(j$++))},[e]),t?`radix-${t}`:""}var L$=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ge=L$.reduce((e,t)=>{const n=C.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?si:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),b.jsx(a,{...s,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function qP(e,t){e&&ta.flushSync(()=>e.dispatchEvent(t))}function Kt(e){const t=C.useRef(e);return C.useEffect(()=>{t.current=e}),C.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function xn({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=$$({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=Kt(n),l=C.useCallback(c=>{if(i){const d=typeof c=="function"?c(e):c;d!==e&&a(d)}else o(c)},[i,e,o,a]);return[s,l]}function $$({defaultProp:e,onChange:t}){const n=C.useState(e),[r]=n,o=C.useRef(r),i=Kt(t);return C.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}var z$=C.createContext(void 0);function ya(e){const t=C.useContext(z$);return e||t||"ltr"}var Gm="rovingFocusGroup.onEntryFocus",B$={bubbles:!1,cancelable:!0},Qp="RovingFocusGroup",[s0,YP,V$]=Xp(Qp),[H$,rc]=Xt(Qp,[V$]),[W$,U$]=H$(Qp),KP=C.forwardRef((e,t)=>b.jsx(s0.Provider,{scope:e.__scopeRovingFocusGroup,children:b.jsx(s0.Slot,{scope:e.__scopeRovingFocusGroup,children:b.jsx(G$,{...e,ref:t})})}));KP.displayName=Qp;var G$=C.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,h=C.useRef(null),f=Te(t,h),p=ya(i),[g=null,m]=xn({prop:s,defaultProp:a,onChange:l}),[y,x]=C.useState(!1),v=Kt(c),_=YP(n),w=C.useRef(!1),[S,R]=C.useState(0);return C.useEffect(()=>{const P=h.current;if(P)return P.addEventListener(Gm,v),()=>P.removeEventListener(Gm,v)},[v]),b.jsx(W$,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:g,onItemFocus:C.useCallback(P=>m(P),[m]),onItemShiftTab:C.useCallback(()=>x(!0),[]),onFocusableItemAdd:C.useCallback(()=>R(P=>P+1),[]),onFocusableItemRemove:C.useCallback(()=>R(P=>P-1),[]),children:b.jsx(ge.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{w.current=!0}),onFocus:le(e.onFocus,P=>{const O=!w.current;if(P.target===P.currentTarget&&O&&!y){const D=new CustomEvent(Gm,B$);if(P.currentTarget.dispatchEvent(D),!D.defaultPrevented){const N=_().filter(F=>F.focusable),A=N.find(F=>F.active),U=N.find(F=>F.id===g),T=[A,U,...N].filter(Boolean).map(F=>F.ref.current);ZP(T,u)}}w.current=!1}),onBlur:le(e.onBlur,()=>x(!1))})})}),XP="RovingFocusGroupItem",QP=C.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=qt(),l=i||a,c=U$(XP,n),u=c.currentTabStopId===l,d=YP(n),{onFocusableItemAdd:h,onFocusableItemRemove:f}=c;return C.useEffect(()=>{if(r)return h(),()=>f()},[r,h,f]),b.jsx(s0.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:b.jsx(ge.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:le(e.onMouseDown,p=>{r?c.onItemFocus(l):p.preventDefault()}),onFocus:le(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:le(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){c.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const g=K$(p,c.orientation,c.dir);if(g!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let y=d().filter(x=>x.focusable).map(x=>x.ref.current);if(g==="last")y.reverse();else if(g==="prev"||g==="next"){g==="prev"&&y.reverse();const x=y.indexOf(p.currentTarget);y=c.loop?X$(y,x+1):y.slice(x+1)}setTimeout(()=>ZP(y))}})})})});QP.displayName=XP;var q$={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Y$(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function K$(e,t,n){const r=Y$(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return q$[r]}function ZP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function X$(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Mx=KP,Ox=QP;function Q$(e,t){return C.useReducer((n,r)=>t[n][r]??n,e)}var Yt=e=>{const{present:t,children:n}=e,r=Z$(t),o=typeof n=="function"?n({present:r.isPresent}):C.Children.only(n),i=Te(r.ref,J$(o));return typeof n=="function"||r.isPresent?C.cloneElement(o,{ref:i}):null};Yt.displayName="Presence";function Z$(e){const[t,n]=C.useState(),r=C.useRef({}),o=C.useRef(e),i=C.useRef("none"),s=e?"mounted":"unmounted",[a,l]=Q$(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const c=af(r.current);i.current=a==="mounted"?c:"none"},[a]),on(()=>{const c=r.current,u=o.current;if(u!==e){const h=i.current,f=af(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),on(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=f=>{const g=af(r.current).includes(f.animationName);if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},h=f=>{f.target===t&&(i.current=af(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:C.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function af(e){return(e==null?void 0:e.animationName)||"none"}function J$(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Tx="Tabs",[e9,vve]=Xt(Tx,[rc]),JP=rc(),[t9,Dx]=e9(Tx),eM=C.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=ya(a),[d,h]=xn({prop:r,onChange:o,defaultProp:i});return b.jsx(t9,{scope:n,baseId:qt(),value:d,onValueChange:h,orientation:s,dir:u,activationMode:l,children:b.jsx(ge.div,{dir:u,"data-orientation":s,...c,ref:t})})});eM.displayName=Tx;var tM="TabsList",nM=C.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Dx(tM,n),s=JP(n);return b.jsx(Mx,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:b.jsx(ge.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});nM.displayName=tM;var rM="TabsTrigger",oM=C.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Dx(rM,n),a=JP(n),l=aM(s.baseId,r),c=lM(s.baseId,r),u=r===s.value;return b.jsx(Ox,{asChild:!0,...a,focusable:!o,active:u,children:b.jsx(ge.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...i,ref:t,onMouseDown:le(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?s.onValueChange(r):d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(r)}),onFocus:le(e.onFocus,()=>{const d=s.activationMode!=="manual";!u&&!o&&d&&s.onValueChange(r)})})})});oM.displayName=rM;var iM="TabsContent",sM=C.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Dx(iM,n),l=aM(a.baseId,r),c=lM(a.baseId,r),u=r===a.value,d=C.useRef(u);return C.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),b.jsx(Yt,{present:o||u,children:({present:h})=>b.jsx(ge.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:h&&i})})});sM.displayName=iM;function aM(e,t){return`${e}-trigger-${t}`}function lM(e,t){return`${e}-content-${t}`}var n9=eM,cM=nM,uM=oM,dM=sM;const Ix=n9,Zp=C.forwardRef(({className:e,...t},n)=>b.jsx(cM,{ref:n,className:se("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Zp.displayName=cM.displayName;const Jp=C.forwardRef(({className:e,...t},n)=>b.jsx(uM,{ref:n,className:se("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Jp.displayName=uM.displayName;const Ax=C.forwardRef(({className:e,...t},n)=>b.jsx(dM,{ref:n,className:se("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ax.displayName=dM.displayName;var fM={exports:{}},bd={},a0={exports:{}};(function(e,t){(function(n,r){r(t)})(ei,function(n){function r(W){return function(J,ne,Z,oe,ee,de,fe){return W(J,ne,fe)}}function o(W){return function(J,ne,Z,oe){if(!J||!ne||typeof J!="object"||typeof ne!="object")return W(J,ne,Z,oe);var ee=oe.get(J),de=oe.get(ne);if(ee&&de)return ee===ne&&de===J;oe.set(J,ne),oe.set(ne,J);var fe=W(J,ne,Z,oe);return oe.delete(J),oe.delete(ne),fe}}function i(W,X){var J={};for(var ne in W)J[ne]=W[ne];for(var ne in X)J[ne]=X[ne];return J}function s(W){return W.constructor===Object||W.constructor==null}function a(W){return typeof W.then=="function"}function l(W,X){return W===X||W!==W&&X!==X}var c="[object Arguments]",u="[object Boolean]",d="[object Date]",h="[object RegExp]",f="[object Map]",p="[object Number]",g="[object Object]",m="[object Set]",y="[object String]",x=Object.prototype.toString;function v(W){var X=W.areArraysEqual,J=W.areDatesEqual,ne=W.areMapsEqual,Z=W.areObjectsEqual,oe=W.areRegExpsEqual,ee=W.areSetsEqual,de=W.createIsNestedEqual,fe=de(xe);function xe(pe,be,je){if(pe===be)return!0;if(!pe||!be||typeof pe!="object"||typeof be!="object")return pe!==pe&&be!==be;if(s(pe)&&s(be))return Z(pe,be,fe,je);var tt=Array.isArray(pe),Ht=Array.isArray(be);if(tt||Ht)return tt===Ht&&X(pe,be,fe,je);var Ge=x.call(pe);return Ge!==x.call(be)?!1:Ge===d?J(pe,be,fe,je):Ge===h?oe(pe,be,fe,je):Ge===f?ne(pe,be,fe,je):Ge===m?ee(pe,be,fe,je):Ge===g||Ge===c?a(pe)||a(be)?!1:Z(pe,be,fe,je):Ge===u||Ge===p||Ge===y?l(pe.valueOf(),be.valueOf()):!1}return xe}function _(W,X,J,ne){var Z=W.length;if(X.length!==Z)return!1;for(;Z-- >0;)if(!J(W[Z],X[Z],Z,Z,W,X,ne))return!1;return!0}var w=o(_);function S(W,X){return l(W.valueOf(),X.valueOf())}function R(W,X,J,ne){var Z=W.size===X.size;if(!Z)return!1;if(!W.size)return!0;var oe={},ee=0;return W.forEach(function(de,fe){if(Z){var xe=!1,pe=0;X.forEach(function(be,je){!xe&&!oe[pe]&&(xe=J(fe,je,ee,pe,W,X,ne)&&J(de,be,fe,je,W,X,ne))&&(oe[pe]=!0),pe++}),ee++,Z=xe}}),Z}var P=o(R),O="_owner",D=Object.prototype.hasOwnProperty;function N(W,X,J,ne){var Z=Object.keys(W),oe=Z.length;if(Object.keys(X).length!==oe)return!1;for(var ee;oe-- >0;){if(ee=Z[oe],ee===O){var de=!!W.$$typeof,fe=!!X.$$typeof;if((de||fe)&&de!==fe)return!1}if(!D.call(X,ee)||!J(W[ee],X[ee],ee,ee,W,X,ne))return!1}return!0}var A=o(N);function U(W,X){return W.source===X.source&&W.flags===X.flags}function $(W,X,J,ne){var Z=W.size===X.size;if(!Z)return!1;if(!W.size)return!0;var oe={};return W.forEach(function(ee,de){if(Z){var fe=!1,xe=0;X.forEach(function(pe,be){!fe&&!oe[xe]&&(fe=J(ee,pe,de,be,W,X,ne))&&(oe[xe]=!0),xe++}),Z=fe}}),Z}var T=o($),F=Object.freeze({areArraysEqual:_,areDatesEqual:S,areMapsEqual:R,areObjectsEqual:N,areRegExpsEqual:U,areSetsEqual:$,createIsNestedEqual:r}),I=Object.freeze({areArraysEqual:w,areDatesEqual:S,areMapsEqual:P,areObjectsEqual:A,areRegExpsEqual:U,areSetsEqual:T,createIsNestedEqual:r}),j=v(F);function H(W,X){return j(W,X,void 0)}var M=v(i(F,{createIsNestedEqual:function(){return l}}));function B(W,X){return M(W,X,void 0)}var L=v(I);function k(W,X){return L(W,X,new WeakMap)}var G=v(i(I,{createIsNestedEqual:function(){return l}}));function q(W,X){return G(W,X,new WeakMap)}function Y(W){return v(i(F,W(F)))}function V(W){var X=v(i(I,W(I)));return function(J,ne,Z){return Z===void 0&&(Z=new WeakMap),X(J,ne,Z)}}n.circularDeepEqual=k,n.circularShallowEqual=q,n.createCustomCircularEqual=V,n.createCustomEqual=Y,n.deepEqual=H,n.sameValueZeroEqual=l,n.shallowEqual=B,Object.defineProperty(n,"__esModule",{value:!0})})})(a0,a0.exports);var Nx=a0.exports;const Fx=dx(h6);var Ue={},r9=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.bottom=jx;Ue.childrenEqual=a9;Ue.cloneLayout=hM;Ue.cloneLayoutItem=Hs;Ue.collides=eg;Ue.compact=gM;Ue.compactItem=mM;Ue.compactType=x9;Ue.correctBounds=bM;Ue.fastPositionEqual=l9;Ue.fastRGLPropsEqual=void 0;Ue.getAllCollisions=yM;Ue.getFirstCollision=ks;Ue.getLayoutItem=Lx;Ue.getStatics=$x;Ue.modifyLayout=pM;Ue.moveElement=Wc;Ue.moveElementAwayFromCollision=c0;Ue.noop=void 0;Ue.perc=u9;Ue.resizeItemInDirection=m9;Ue.setTopLeft=y9;Ue.setTransform=b9;Ue.sortLayoutItems=Ux;Ue.sortLayoutItemsByColRow=CM;Ue.sortLayoutItemsByRowCol=SM;Ue.synchronizeLayoutWithChildren=v9;Ue.validateLayout=_M;Ue.withLayoutItem=s9;var zC=Nx,Hc=o9(E);function o9(e){return e&&e.__esModule?e:{default:e}}const i9=process.env.NODE_ENV==="production";function jx(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function hM(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=Hs(e[n]);return t}function pM(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function s9(e,t,n){let r=Lx(e,t);return r?(r=n(Hs(r)),e=pM(e,r),[e,r]):[e,null]}function Hs(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function a9(e,t){return(0,zC.deepEqual)(Hc.default.Children.map(e,n=>n==null?void 0:n.key),Hc.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,zC.deepEqual)(Hc.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),Hc.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}Ue.fastRGLPropsEqual=r9;function l9(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function eg(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function gM(e,t,n,r){const o=$x(e),i=Ux(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=Hs(i[a]);c.static||(c=mM(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const c9={x:"w",y:"h"};function l0(e,t,n,r){const o=c9[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;eg(t,a)&&l0(e,a,n+t[o],r)}}t[r]=n}function mM(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min(jx(e),t.y);t.y>0&&!ks(e,t);)t.y--;else if(a)for(;t.x>0&&!ks(e,t);)t.x--;let l;for(;(l=ks(e,t))&&!(n===null&&i);)if(a?l0(o,t,l.x+l.w,"x"):l0(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!ks(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function bM(e,t){const n=$x(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;ks(n,i);)i.y++}return e}function Lx(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function ks(e,t){for(let n=0,r=e.length;n<r;n++)if(eg(e[n],t))return e[n]}function yM(e,t){return e.filter(n=>eg(n,t))}function $x(e){return e.filter(t=>t.static)}function Wc(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;`${t.i}${String(n)}${String(r)}${t.x}${t.y}`;const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let d=Ux(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(d=d.reverse());const f=yM(d,t),p=f.length>0;if(p&&l)return hM(e);if(p&&i)return`${t.i}`,t.x=c,t.y=u,t.moved=!1,e;for(let g=0,m=f.length;g<m;g++){const y=f[g];`${t.i}${t.x}${t.y}${y.i}${y.x}${y.y}`,!y.moved&&(y.static?e=c0(e,y,t,o,s):e=c0(e,t,y,o,s))}return e}function c0(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const d={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=ks(e,d),f=h&&h.y+h.h>t.y,p=h&&t.x+t.w>h.x;if(h){if(f&&a)return Wc(e,n,void 0,t.y+1,r,l,o);if(f&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(p&&s)return Wc(e,t,n.x,void 0,r,l,o)}else return`${n.i}${d.x}${d.y}`,Wc(e,n,s?d.x:void 0,a?d.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:Wc(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function u9(e){return e*100+"%"}const vM=(e,t,n,r)=>e+n>r?t:n,xM=(e,t,n)=>e<0?t:n,wM=e=>Math.max(0,e),zx=e=>Math.max(0,e),Bx=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:xM(s,e.height,o),top:zx(s)}},Vx=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:vM(e.left,e.width,s,n),left:wM(o)}},Hx=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:vM(e.left,e.width,i,n),top:zx(r),left:wM(s)}},Wx=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:xM(r,e.height,i),top:zx(r)}},d9=function(){return Bx(arguments.length<=0?void 0:arguments[0],Vx(...arguments))},f9=function(){return Bx(arguments.length<=0?void 0:arguments[0],Hx(...arguments))},h9=function(){return Wx(arguments.length<=0?void 0:arguments[0],Vx(...arguments))},p9=function(){return Wx(arguments.length<=0?void 0:arguments[0],Hx(...arguments))},g9={n:Bx,ne:d9,e:Vx,se:h9,s:Wx,sw:p9,w:Hx,nw:f9};function m9(e,t,n,r){const o=g9[e];return o?o(t,{...t,...n},r):n}function b9(e){let{top:t,left:n,width:r,height:o}=e;const i=`translate(${n}px,${t}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${r}px`,height:`${o}px`,position:"absolute"}}function y9(e){let{top:t,left:n,width:r,height:o}=e;return{top:`${t}px`,left:`${n}px`,width:`${r}px`,height:`${o}px`,position:"absolute"}}function Ux(e,t){return t==="horizontal"?CM(e):t==="vertical"?SM(e):e}function SM(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function CM(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function v9(e,t,n,r,o){e=e||[];const i=[];Hc.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=Lx(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(Hs(l)):c?(i9||_M([c],"ReactGridLayout.children"),i.push(Hs({...c,i:a.key}))):i.push(Hs({w:1,h:1,x:0,y:jx(i),i:String(a.key)}))});const s=bM(i,{cols:n});return o?s:gM(s,r,n)}function _M(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++){const a=n[s],l=i[a];if(typeof l!="number"||Number.isNaN(l))throw new Error(`ReactGridLayout: ${t}[${r}].${a} must be a number! Received: ${l} (${typeof l})`)}if(typeof i.i<"u"&&typeof i.i!="string")throw new Error(`ReactGridLayout: ${t}[${r}].i must be a string! Received: ${i.i} (${typeof i.i})`)}}function x9(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const w9=()=>{};Ue.noop=w9;var Oo={};Object.defineProperty(Oo,"__esModule",{value:!0});Oo.calcGridColWidth=tg;Oo.calcGridItemPosition=S9;Oo.calcGridItemWHPx=u0;Oo.calcWH=_9;Oo.calcXY=C9;Oo.clamp=Ps;function tg(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function u0(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function S9(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=tg(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=u0(r,c,s[0]),u.height=u0(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function C9(e,t,n,r,o){const{margin:i,containerPadding:s,cols:a,rowHeight:l,maxRows:c}=e,u=tg(e);let d=Math.round((n-s[0])/(u+i[0])),h=Math.round((t-s[1])/(l+i[1]));return d=Ps(d,0,a-r),h=Ps(h,0,c-o),{x:d,y:h}}function _9(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=tg(e);let d=Math.round((t+s[0])/(u+s[0])),h=Math.round((n+s[1])/(c+s[1])),f=Ps(d,0,l-r),p=Ps(h,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(f=Ps(d,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(p=Ps(h,0,a)),{w:f,h:p}}function Ps(e,t,n){return Math.max(Math.min(e,n),t)}var ng={},d0={exports:{}},lf={exports:{}},lt={};/** @license React v16.13.1
|
|
37
37
|
* react-is.production.min.js
|
|
38
38
|
*
|
|
39
39
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-BsAoJTv_.js");exports.Dashboard=e.Dashboard;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/index-BsAoJTv_.js"),e=require("react/jsx-runtime"),C=require("react");require("react-dom");function Cs(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const ue=Cs(C);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
*
|
|
304
304
|
* This source code is licensed under the ISC license.
|
|
305
305
|
* See the LICENSE file in the root directory of this source tree.
|
|
306
|
-
*/const es=s.createLucideIcon("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);function Ie(t){var n;return{...t,sheets:(n=t==null?void 0:t.sheets)==null?void 0:n.map(a=>{var r;return{...a,frames:(r=a.frames)==null?void 0:r.map(o=>{var l;return{...o,cards:(l=o.cards)==null?void 0:l.map(i=>ss(i))}})}})}}function ss(t){var n,a,r,o;return{...t,cfg:{...t.cfg,data:{...(n=t.cfg)==null?void 0:n.data,labels:[],datasets:(o=(r=(a=t.cfg)==null?void 0:a.data)==null?void 0:r.datasets)==null?void 0:o.map(l=>({...l,data:[]}))}},customCfg:mt(t.customCfg),data:[]}}function mt(t){var n,a;return t?{...t,data:{...t==null?void 0:t.data,labels:[],datasets:(a=(n=t==null?void 0:t.data)==null?void 0:n.datasets)==null?void 0:a.map(r=>({...r,data:[]}))}}:null}async function xt(t,n,a,r){if(!r)return null;const o=JSON.stringify(n);return await s.postRequest("https://semaphor.cloud/api/v1/lens",r,{name:t,template:o,filterValues:a,operation:"create"})}async function ve(t,n){if(!n)return null;const{id:a,template:r,filterValues:o,isDefault:l,shared:i}=t;return await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{lensId:a,template:r,filterValues:o,isDefault:l,shared:i,operation:"update"})}async function pt(t,n){return n?await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{operation:"delete",lensId:t}):null}function ft(){const[t,n]=C.useState(""),[a,r]=C.useState(!1),o=s.useDashboardStore(g=>g.lenses),{setLenses:l,setSelectedLensId:i}=s.useDashboardActions(),[d,h]=C.useState(!1),[f,u]=C.useState(!1),p=s.useDashboardStore(g=>g.dashboard),b=s.useDashboardStore(g=>g.filterValues),{authToken:c}=s.useSemaphorContext();async function m(){h(!0);const g=Ie(p),S=await xt(t,g,b,c==null?void 0:c.accessToken);S&&(l([...o||[],S]),i(S.id),u(!1)),h(!1)}return e.jsxs(s.Dialog,{open:f,onOpenChange:u,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:g=>{n(g.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:m,disabled:d,children:d?"Creating...":"Add"})})]})]})}function gt(){const[t,n]=C.useState(!1),a=s.useDashboardStore(u=>u.lenses),r=s.useDashboardStore(u=>u.selectedLensId),{setLenses:o,setSelectedLensId:l}=s.useDashboardActions(),{authToken:i}=s.useSemaphorContext();async function d(u){l(u)}async function h(u){if(await pt(u,i==null?void 0:i.accessToken)){const b=a==null?void 0:a.filter(c=>c.id!==u);o(b||[]),l("original")}}async function f(u){const p=a==null?void 0:a.map(m=>m.id===u.id?{...m,isDefault:!u.isDefault}:{...m,isDefault:!1});o(p||[]);const b={...u,isDefault:!u.isDefault};await ve(b,i==null?void 0:i.accessToken);const c=a==null?void 0:a.find(m=>m.isDefault);if(c&&c.id!==u.id){const m={...c,isDefault:!1};await ve(m,i==null?void 0:i.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(_s,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:d,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(u=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:u.id,children:[e.jsx("p",{children:u.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(Us,{onClick:p=>{p.preventDefault(),f(u)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!u.isDefault,"text-green-500":u.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:p=>{p.preventDefault(),h(u.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},u.id))]})]})]})}function ts(){var l;const t=s.useDashboardStore.getState().authToken,n=s.useDashboardStore.getState().theme,a=s.useDashboardStore.getState().filterValues,r=(l=s.useDashboardStore.getState().dashboard)==null?void 0:l.title,o=s.useDashboardStore.getState().selectedSheetId;return{authToken:t,theme:n||"light",filterValues:a,dashboardTitle:r||"",selectedSheetId:o||""}}async function as(){const t=s.useDashboardStore.getState().isDownloadingPdf,{authToken:n,theme:a,filterValues:r,dashboardTitle:o,selectedSheetId:l}=ts();if(t)return;const i=new URLSearchParams;i.set("token",(n==null?void 0:n.accessToken)||""),i.set("theme",a),i.set("filterValues",JSON.stringify(r)),i.set("selectedSheetId",l||"");const d=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(i.toString())}`;s.useDashboardStore.setState({isDownloadingPdf:!0});const u=(await(await fetch(d,{method:"GET",headers:{Authorization:`Bearer ${n==null?void 0:n.accessToken}`}})).json()).url,p=document.createElement("a");p.href=u;const b=`${o}-${new Date().toISOString()}.pdf`;p.download=b,p.click(),s.useDashboardStore.setState({isDownloadingPdf:!1})}function jt({iconClassName:t}){const{authToken:n}=s.useSemaphorContext();s.useDashboardStore(o=>{var l;return(l=o.dashboard)==null?void 0:l.title}),s.useDashboardStore(o=>o.theme),s.useDashboardStore(o=>o.filterValues);const a=s.useDashboardStore(o=>o.isDownloadingPdf);async function r(){await as()}return e.jsx(s.IconButton,{tooltip:"Download PDF",className:"h-7 p-2",onClick:r,children:a?e.jsx(ie,{className:s.cn("size-3.5 animate-spin",t)}):e.jsx(s.Download,{className:s.cn("size-4",t)})})}function ee({defaultValue:t,label:n,options:a,value:r,onValueChange:o,className:l}){return e.jsxs(s.Select,{defaultValue:t,value:r,onValueChange:o,children:[e.jsx(s.SelectTrigger,{className:s.cn("w-full focus:ring-0 focus:ring-offset-0",l),children:e.jsx(s.SelectValue,{placeholder:n})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:n}),a.map(i=>e.jsx(s.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}const Oe=[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-Weekly"},{value:"monthly",label:"Monthly"}];function ns(){const{data:t,handleScheduleSubscription:n,handleDeleteSubscription:a,status:r,error:o,isDeleting:l}=bt(),[i,d]=C.useState(""),[h,f]=C.useState(Oe[0].value),[u,p]=C.useState("00:00"),[b,c]=C.useState("");return e.jsx(s.TooltipProvider,{delayDuration:0,children:e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Schedule Dashboard",className:"h-7 p-2",children:e.jsx(Os,{className:"size-4"})})}),e.jsx(s.PopoverContent,{align:"end",className:"w-80",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Schedule Subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribe to receive dashboard via email"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"email",children:"Email"}),e.jsx(s.Input,{id:"email",value:i,onChange:m=>d(m.target.value),className:`col-span-2 h-8 ${s.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"subject",children:"Subject"}),e.jsx(s.Input,{id:"subject",placeholder:"Monthly Sales Report",value:b,onChange:m=>{c(m.target.value.replace(/[^a-zA-Z0-9\s-_]/g,""))},className:`col-span-2 h-8 ${s.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"frequency",children:"Frequency"}),e.jsx(ee,{className:"col-span-2 h-8",label:"Select Frequency",options:Oe,value:h,onValueChange:m=>f(m)})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"time",children:"Time"}),e.jsx(s.Input,{id:"time",type:"time",value:u,onChange:m=>p(m.target.value),className:`col-span-2 h-8 ${s.removeRing}`})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs(s.Button,{onClick:async()=>{await n({email:i,frequency:h,time:u,subject:b}),p("00:00"),d(""),c("")},className:"h-8 p-2",disabled:r==="loading"||!i,children:[r==="loading"&&e.jsx(ie,{className:"mr-2 size-4 animate-spin"}),r==="success"&&e.jsx(s.Check,{className:"mr-2 size-4"}),r==="error"&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsx(Ue,{className:"mr-2 size-4 text-destructive"})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:o})})]}),"Schedule"]})}),t&&t.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(s.Separator,{className:"my-2"}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium leading-none",children:"Subscriptions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active email subscriptions"})]}),s.isDev]})}),e.jsx("div",{className:"grid gap-2",children:t==null?void 0:t.map(m=>e.jsxs("div",{className:"group grid grid-cols-5 gap-3",children:[e.jsx("div",{className:"col-span-3 text-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"boder-border rounded-md border bg-muted px-2 py-1",children:[s.titleCase(m.frequency)," "]}),e.jsx(s.Label,{children:m.time})]})}),e.jsxs("div",{className:"col-span-2 flex items-center justify-end gap-4",children:[e.jsx(Fe,{tooltip:`Next Run: ${new Date(m.nextRun).toLocaleString()} ${m.timezone}`,children:e.jsx(zs,{className:"size-3.5"})}),e.jsx(Fe,{tooltip:`${m.endUserEmail}`,children:e.jsx(Ys,{className:"size-3.5"})}),l===m.id?e.jsx(ie,{className:"size-3.5 animate-spin"}):e.jsx(ht,{onClick:()=>a(m.id),className:"size-3.5 cursor-pointer"})]})]},m.id))})]})]})]})})]})})}const Fe=({children:t,tooltip:n})=>e.jsx(s.TooltipProvider,{delayDuration:0,children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:t}),e.jsx(s.TooltipContent,{children:n})]})});function bt(){const[t,n]=C.useState("idle"),[a,r]=C.useState(""),[o,l]=C.useState(null),i=s.useDashboardStore(y=>y.authToken),d=s.useDashboardStore(y=>y.dashboard.id),h=s.useDashboardStore(y=>y.dashboard.title),{endUserId:f}=s.getTenantAndEndUserId((i==null?void 0:i.accessToken)||""),u="https://semaphor.cloud/api/v1/subscriptions/get",p={dashboardId:d,endUserId:f},{data:b,isLoading:c,isError:m,isFetching:g,refetch:S}=s.useQuery({queryKey:["subscriptions",d,f],queryFn:()=>s.getRequest(u,(i==null?void 0:i.accessToken)||"",p),enabled:!!(i!=null&&i.accessToken)&&!!d&&!!f});async function j({email:y,subject:D,frequency:E,time:O}){const{authToken:V,...R}=ts(),B=Intl.DateTimeFormat().resolvedOptions().timeZone,x={email:y,frequency:E,time:O,timezone:B,endUserId:f,endUserEmail:y,subject:D||h||"Scheduled Dashboard",dashboardId:d,dashboardParams:R};n("loading");const T="https://semaphor.cloud/api/v1/subscriptions/create";try{const q=await s.postRequestRegular(T,(V==null?void 0:V.accessToken)||"",{...x});n("success"),r(""),S(),setTimeout(()=>{n("idle")},2e3)}catch(q){console.error(q),n("error"),r(q.message)}}async function I(y){const D="https://semaphor.cloud/api/v1/subscriptions/delete";l(y);try{await s.postRequestRegular(D,(i==null?void 0:i.accessToken)||"",{id:y}),S(),setTimeout(()=>{l(null)},2e3)}catch(E){console.error(E),l(null),n("error"),r(E.message)}}return{data:b,isLoading:c,isFetching:g,isError:m,isDeleting:o,refetch:S,handleScheduleSubscription:j,handleDeleteSubscription:I,status:t,error:a}}function yt(){const{authToken:t}=s.useSemaphorContext();s.useDashboardStore(x=>x.theme);const n=s.useDashboardStore(x=>x.lenses),a=s.useDashboardStore(x=>x.selectedLensId),r=n==null?void 0:n.find(x=>x.id===a),o=s.useDashboardStore(x=>x.dashboard);s.useDashboardStore(x=>x.selectedSheetId);const l=s.useDashboardStore(x=>x.isDashboardEditing),i=s.useEditorStore(x=>x.selectedConnectionId),[d,h]=C.useState(!1),f=s.useDashboardStore(x=>x.filterValues),u=s.useDashboardStore(x=>x.isVisualEditing),p=s.useDashboardStore(x=>x.showFilters);s.useDashboardStore(x=>x.showDashboardJSON);const b=s.useDashboardStore(x=>x.onSaveFunction),c=s.useDashboardStore(x=>x.actions.setShowFilters),{addFrame:m,setSelectedFrameId:g}=s.useDashboardStore(x=>x.actions),{getSelectedSheet:S,setIsDashboardEditing:j,setShowDashboardJSON:I}=s.useDashboardStore(x=>x.actions),y=S(),{tenantId:D,endUserId:E}=C.useMemo(()=>s.getTenantAndEndUserId(t==null?void 0:t.accessToken),[t==null?void 0:t.accessToken]),O=C.useMemo(()=>D||E,[D,E]),V=()=>{if(!l||!y)return;const x={connectionId:i,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},T={id:s.v4(),cards:[x],activeCardId:x.id};m(y.id,T),g(T.id)},R=()=>{j(!0)};async function B(){if(h(!0),!a||!r)return;const x=Ie(o),T=JSON.stringify(x),q={...r,template:T,filterValues:f};await ve(q,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),b==null||b(x),h(!1)}return u?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b py-2 pl-3 pr-2",role:"dashboard-controls",children:[!u&&e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(s.Label,{children:r==null?void 0:r.name})}),e.jsxs("div",{className:"flex gap-2",children:[!1,!u&&e.jsx(jt,{}),!u&&e.jsx(ns,{}),l&&!u&&O&&e.jsx(ft,{}),!u&&O&&e.jsx(gt,{}),l&&!u&&e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!l,onClick:V,children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Frame"]}),!l&&e.jsx(s.Button,{variant:"ghost",className:"h-7 p-2",onClick:R,size:"sm",children:e.jsx(s.Pencil,{className:"h-4 w-4"})}),l&&!u&&e.jsx(s.IconButton,{className:"h-7 p-2",onClick:()=>{j(!1),I(!1)},children:e.jsx(s.Cross2Icon,{className:"h-4 w-4"})}),l&&!u&&O&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",disabled:d,onClick:B,size:"sm",children:e.jsx(ot,{className:"h-4 w-4"})}),!p&&!u&&l&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>c(!0),size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),!u&&l&&!1,!u&&!1]})]})}function St({name:t,items:n,value:a,onChange:r,isLoading:o,isError:l,refetch:i,className:d,showNone:h=!1}){const f=ue.useRef(null),[u,p]=ue.useState(!1),[b,c]=ue.useState("100%"),m=h?[...n||[],{id:"none",name:"None"}]:n;ue.useLayoutEffect(()=>{f.current&&c(f.current.offsetWidth)},[]);function g(){var j;return o?"Loading...":l?"Error":a?(j=n==null?void 0:n.find(I=>I.id===a))==null?void 0:j.name:`Select ${t}`}function S(j,I){r(I),p(!1)}return e.jsxs(s.Popover,{open:u,onOpenChange:p,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":u,className:s.cn("flex h-9 w-full max-w-[226px] justify-between",d),children:[e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:g()}),e.jsx(s.ChevronDown,{className:"size-4 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:e.jsxs(s.Command,{children:[e.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[e.jsx(s.CommandInput,{className:"h-9",placeholder:"Search..."}),e.jsx(s.IconButton,{className:"h-7",onClick:i,children:e.jsx(Ze,{className:s.cn("size-3.5 opacity-50",o&&"animate-spin")})})]}),e.jsxs(s.CommandList,{children:[e.jsxs(s.CommandEmpty,{children:["No ",t==null?void 0:t.toLowerCase()," found."]}),e.jsx(s.CommandGroup,{children:m==null?void 0:m.map(j=>e.jsx(s.CommandItem,{className:"overflow-x-auto",value:j.name,onSelect:I=>S(I,j.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Check,{className:s.cn("size-4",a===j.id?"opacity-100":"opacity-0")}),e.jsx("div",{title:j.name,children:j.name})]})},j.id))})]})]})})]})}function de({title:t,items:n,value:a,isLoading:r,isError:o,refetch:l,connectionTooltip:i,onChange:d,showNone:h=!1,className:f,showIcon:u=!0,disabled:p=!1,type:b="combobox"}){const c=r?"Loading...":o?"Error":a;function m(){if(t==="Connection")return e.jsx(at,{className:"size-4 rotate-90"});if(t==="Database")return e.jsx(Vs,{className:"size-4"});if(t==="Schema")return e.jsx(tt,{className:"size-4"});if(t==="Table")return e.jsx(ke,{className:"size-4"});if(t==="Model")return e.jsx(Ls,{className:"size-4"})}function g(){return e.jsxs(s.Select,{disabled:p,value:c,onValueChange:d,children:[e.jsx(s.SelectTrigger,{className:s.cn("h-9 w-full border-muted focus:ring-1 focus:ring-offset-0",f),children:e.jsx(s.SelectValue,{placeholder:r?"Loading...":o?"Error":`Select ${t}`})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[r?e.jsx(s.SelectLabel,{children:"Loading..."}):e.jsxs(s.SelectLabel,{className:"flex items-center justify-between gap-2",children:[t,e.jsx(Ze,{className:s.cn("mr-1 size-3 cursor-pointer text-muted-foreground hover:text-foreground",r&&"animate-spin"),onClick:l})]}),e.jsxs(e.Fragment,{children:[h&&e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((j,I)=>e.jsx(s.SelectItem,{value:j.id,children:j.name},I))]}),(r||o)&&e.jsx(s.SelectItem,{value:c,children:c})]})})]})}function S(){return e.jsx(St,{items:n,value:c,onChange:d||(()=>{}),isLoading:r,isError:o,refetch:l,name:t,showNone:h})}return e.jsx(s.TooltipProvider$1,{delayDuration:0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsx("div",{className:"shrink-0",children:i?e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:m()}),e.jsx(s.TooltipContent,{className:"text-xs",align:"start",children:i})]}):m()}),b==="select"?g():S()]})})}function Ct({column:t}){const[n,a]=C.useState(!1),r=s.useEditorStore(m=>m.selectedTableName),o=s.useEditorStore(m=>m.selectedSchemaName),l=s.useEditorStore(m=>m.selectedDatamodelId),i=s.useEditorStore(m=>m.sqlGen),{modelItems:d,connectionType:h}=ae(),f=s.useEditorStore(m=>m.actions.setSqlGen),u=s.useEditorStore(m=>m.actions.setCardSql),p=s.useEditorStore(m=>m.actions.setRunSql);function b(m,g){var y;const S=s.createSqlGenConfig(m,i,g),j=(y=d==null?void 0:d.find(D=>D.id===l))==null?void 0:y.name;f(S);const I=s.getSql(S,s.fmt(o||""),s.fmt(r),j,h);I&&(u(I),p(!0)),a(!1)}function c(){return e.jsxs("ul",{className:"text-xs",children:[e.jsx("li",{onClick:()=>b(t,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsx("li",{onClick:()=>b(t,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsx("li",{onClick:()=>b(t,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsx("li",{onClick:()=>b(t,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsx("li",{onClick:()=>b(t,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxs(s.HoverCard,{openDelay:0,open:n,onOpenChange:a,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(Je,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsx(s.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:c()})]})}function rs({column:t}){return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger$1,{asChild:!0,children:s.isTextDataType(t.data_type)?e.jsx(es,{className:"size-3"}):s.isNumberDataType(t.data_type)?e.jsx($s,{className:"size-3"}):s.isDateDataType(t.data_type)?e.jsx(s.Calendar,{className:"size-3"}):s.isBooleanDataType(t.data_type)?e.jsx(ut,{className:"size-3"}):t.data_type.toLowerCase()==="json"?e.jsx(As,{className:"size-3"}):e.jsx(it,{className:"size-3"})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{className:"font-mono text-xs",children:t.data_type})})]})}function vt({schemaName:t,tableName:n,columns:a,status:r}){const o=s.useEditorStore(x=>x.sqlGen),l=s.useEditorStore(x=>x.selectedConnectionId),i=s.useEditorStore(x=>x.selectedDatabaseName),d=s.useEditorStore(x=>x.selectedSchemaName),h=s.useEditorStore(x=>x.selectedTableName),f=s.useEditorStore(x=>x.selectedDatamodelId),u=s.useDashboardStore(x=>x.dashboard.aiScopeTables),{addToAIScope:p,removeFromAIScope:b}=s.useDashboardActions(),{setAIScopeTables:c}=s.useDashboardStore(x=>x.actions),m=s.useEditorStore(x=>x.actions.setRunSql),g=s.useEditorStore(x=>x.actions.setSqlGen),S=s.useEditorStore(x=>x.actions.setIsShowingVisual),j=s.useEditorStore(x=>x.actions.setCardSql),{connectionType:I,modelItems:y,selectedDatamodelName:D}=ae();function E(x){var P;const T=s.createSqlGenConfig(x,o);g(T);const q=(P=y==null?void 0:y.find(G=>G.id===f))==null?void 0:P.name,z=s.getSql(T,s.fmt(t),s.fmt(n),q,I);z&&(j(z),m(!0))}function O(){return(u==null?void 0:u.find(x=>x.connectionId===l&&(x.tableName===h||x.datamodelName===D)))!==void 0}function V(x){x===!0&&(h||D)&&l?(p({connectionId:l,connectionType:I==="S3"||I==="API"?"DuckDb":I,databaseName:i||"",schemaName:d||"",tableName:h||"",datamodelName:s.resolveDatamodelName(D),datamodelId:f||""}),s.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(b({connectionId:l||"",connectionType:I||"",tableName:h||"",datamodelName:s.resolveDatamodelName(D),datamodelId:f||"",databaseName:i||"",schemaName:d||""}),s.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function R(){const x=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:D,connectionType:I});S(!1);const T=I==="MSSQL"?`SELECT top 10 * FROM ${x}`:`SELECT * FROM ${x} LIMIT 10`;j(T),m(!0)}function B(){const x=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:D,connectionType:I});j(`SELECT COUNT(*) as count FROM ${x}`),m(!0)}return e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-center gap-2",children:[e.jsxs(s.Toggle,{title:`${O()?"Remove from":"Add to"} Assistant Scope`,pressed:O(),onPressedChange:V,variant:"outline",className:s.cn("h-9 px-2",{}),children:[e.jsx(s.Plus,{className:s.cn("mr-1 size-4",{"text-green-400":O(),"text-muted-foreground":!O()})}),"AI"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:R,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Zs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:B,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(lt,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxs(s.ScrollArea,{className:"flex-1 basis-0 border-b border-t border-muted py-3",children:[e.jsx("div",{className:"flex flex-col gap-1",children:a==null?void 0:a.map(x=>e.jsxs("div",{onClick:()=>E(x),className:s.cn("group mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-1 text-sm transition-colors hover:bg-muted/50",{"border border-dashed border-muted-foreground bg-muted":s.isColumnInSqlGen(x,o)}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(rs,{column:x}),e.jsx("span",{children:x.column_name})]}),e.jsx("div",{onClick:T=>T.stopPropagation(),className:"flex items-center justify-end",children:s.isNumberDataType(x.data_type)&&e.jsx(Ct,{column:x})})]},x.column_name))}),e.jsx(s.ScrollBar,{orientation:"vertical"}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function ae(t,n){var De,Te,Le,Ae,Me,ze;let a=C.useMemo(()=>[],[]);const r=s.useSemaphorContext().authToken||t,o=s.useEditorStore(w=>w.selectedConnectionId),l=s.useEditorStore(w=>w.selectedDatamodelId),i=s.useEditorStore(w=>w.selectedDatabaseName),d=s.useEditorStore(w=>w.selectedSchemaName),h=s.useEditorStore(w=>w.selectedTableName),f=s.useEditorStore(w=>w.actions.setCurrentColumns),u=s.useEditorStore(w=>w.actions.setSelectedConnectionId),p=s.useEditorStore(w=>w.actions.setSelectedDatamodelId),b=s.useEditorStore(w=>w.actions.setSelectedDatabaseName),c=s.useEditorStore(w=>w.actions.setSelectedSchemaName),m=s.useEditorStore(w=>w.actions.setSelectedTableName);s.useEditorStore(w=>w.actions.setCardSql);function g(w){return o&&i&&d&&i!=="NA"?!0:o&&w==="API"?!1:!!(o&&w==="S3")}function S(w){return!!(o&&i&&i!=="NA"&&d&&h||o&&(w==="S3"||w==="API")||l&&l)}function j(w){return o&&w?!(w==="API"||w==="S3"):!1}const{refetch:I,data:y,isLoading:D,isError:E}=s.useQuery({queryKey:["connections"],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{refetch:O,data:V,isLoading:R,isError:B}=s.useQuery({queryKey:["models",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:!!(r!=null&&r.accessToken)&&!!o}),x=y==null?void 0:y.connections.find(w=>w.id===o),T=x==null?void 0:x.type,q=(x==null?void 0:x.type)==="API"||(x==null?void 0:x.type)==="S3",{data:z,isLoading:P,isFetching:G,isError:v,refetch:N}=s.useQuery({queryKey:["databases",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:j(T)}),{data:L,isLoading:H,isFetching:U,isError:Q,refetch:F}=s.useQuery({queryKey:["schemas",o,i],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:i}),enabled:!!o&&!!i&&!q&&i!=="NA"}),{data:M,isLoading:J,isFetching:k,isError:_,refetch:W}=s.useQuery({queryKey:["tables",o,i,d],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:i,schema_name:d}),enabled:g(T)}),{data:K,isLoading:te,isFetching:se,isError:$,refetch:Z}=s.useQuery({queryKey:["columns",o,i,l,d,h],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:o,datamodel_id:l||"",database_name:i,schema_name:d,table_name:h}),enabled:S(T)});C.useEffect(()=>{f(a)},[K,f,a]),C.useEffect(()=>{(T==="S3"||T==="API")&&(b(""),c(""),p(""),T==="API"&&m("api"))},[T,m,b,c,p]);const ce=(x==null?void 0:x.type)==="API"?(De=x==null?void 0:x.type)==null?void 0:De.toLowerCase():h||"",ne=q?"":d||"";function re(w){c(w),m("")}function A(w){b(w==="none"?"":w),c(""),m(""),w!=="none"&&w!==""&&p("")}function Y(w){u(w)}function oe(w){p(w==="none"?"":w),w!=="none"&&w!==""&&b("")}z&&((Te=z==null?void 0:z.databases)==null?void 0:Te.length)>0,L&&((Le=L==null?void 0:L.schemas)==null?void 0:Le.length)>0,K&&((Ae=K==null?void 0:K.columns)==null?void 0:Ae.length)>0&&(a=K.columns.map(w=>({...w,data_type:w.data_type.toLowerCase()}))),v&&(a=[]),($||E)&&(a=[]);const X=y==null?void 0:y.connections.map(w=>({id:w.id,name:w.name,type:w.type})),xe=(Me=V==null?void 0:V.datamodels)==null?void 0:Me.map(w=>({id:w.id,name:w.name})),Se=z==null?void 0:z.databases.map(w=>({id:w.database_name,name:w.database_name})),fe=L==null?void 0:L.schemas.map(w=>({id:w.schema_name,name:w.schema_name})),Ce=M==null?void 0:M.tables.map(w=>({id:w.table_name,name:w.table_name})),Ss=(ze=V==null?void 0:V.datamodels.find(w=>w.id===l))==null?void 0:ze.name;return{connectionItems:X,isConnectionsLoading:D,isConnectionsError:E,modelItems:xe,selectedDatamodelId:l,selectedDatamodelName:Ss,isModelsLoading:R,isModelsError:B,databaseItems:Se,isDatabasesLoadingOrFetching:P||G,isDatabaseError:v,schemaItems:fe,isSchemaLoadingOrFetching:H||U,isSchemaError:Q,tableItems:Ce,isTableLoadingOrFetching:J||k,isTableError:_,columns:a,isColumnsLoadingOrFetching:te||se,isColumnsError:$,isNonDbConnection:q,connectionType:T,tableName:ce,schemaName:ne,refetchConnections:I,refetchModels:O,refetchDatabases:N,refetchSchemas:F,refetchTables:W,refetchColumns:Z,handleConnectionChange:Y,handleDatamodelChange:oe,handleDatabaseChange:A,handleSchemaChange:re}}function os({ColumnsComponent:t}){var se;const n=s.useEditorStore($=>$.selectedConnectionId),a=s.useEditorStore($=>$.selectedDatamodelId),r=s.useEditorStore($=>$.selectedDatabaseName),o=s.useEditorStore($=>$.selectedSchemaName),l=s.useEditorStore($=>$.selectedTableName),i=s.useEditorStore($=>$.actions.setSelectedTableName),{connectionItems:d,modelItems:h,schemaItems:f,databaseItems:u,tableItems:p,columns:b,isConnectionsLoading:c,isModelsLoading:m,isConnectionsError:g,isModelsError:S,isDatabasesLoadingOrFetching:j,isDatabaseError:I,isSchemaLoadingOrFetching:y,isSchemaError:D,isColumnsError:E,isColumnsLoadingOrFetching:O,isTableLoadingOrFetching:V,isTableError:R,connectionType:B,isNonDbConnection:x,refetchDatabases:T,refetchModels:q,refetchSchemas:z,refetchTables:P,refetchColumns:G,refetchConnections:v,handleConnectionChange:N,handleDatabaseChange:L,handleSchemaChange:H,handleDatamodelChange:U,tableName:Q,schemaName:F}=ae();function M(){return t?t(F,Q,b):e.jsx(vt,{schemaName:F,tableName:Q,columns:b,status:O?"Loading...":E?"Error":"Success"})}function J(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function k(){if(!n||B==="S3"||B==="API")return null;if(!a||a==="none")return e.jsx(de,{refetch:T,showNone:!0,onChange:L,isError:I,isLoading:j,items:u,value:r||"",title:"Database",type:"combobox"})}function _(){if(n&&!x&&(!r||r==="none")&&(!a||a==="none"))return e.jsxs("div",{className:"grid grid-cols-3",children:[e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Label,{children:"OR"})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})})]})}function W(){if(!n||B==="S3"||B==="API")return null;if(!r||r==="none")return e.jsx(de,{refetch:q,showNone:!0,onChange:U,isError:S,isLoading:m,items:h,value:a||"",title:"Model",type:"combobox"})}function K(){return!n||B==="S3"||B==="API"||!r||r==="none"?null:e.jsx(de,{refetch:z,onChange:H,isError:D,isLoading:y,items:f,value:o||"",title:"Schema",type:"combobox"})}function te(){function $(){let Z=!1;return B==="API"?(Z=!1,Z):((B==="S3"||n&&r&&r!=="none"&&o)&&(Z=!0),Z)}return $()?e.jsx(de,{refetch:P,onChange:i,isError:R,items:p,isLoading:V,value:l||"",title:"Table",type:"combobox"}):null}return e.jsxs("aside",{className:"flex h-full min-w-[300px] flex-col justify-between rounded-none border-r-[1px]",children:[e.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsx(de,{refetch:v,items:d,title:"Connection",value:n||"",onChange:N,isLoading:c,isError:g,type:"combobox",connectionTooltip:((se=d==null?void 0:d.find($=>$.id===n))==null?void 0:se.type)||""}),k(),_(),W(),K(),te()]}),M(),e.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxs(s.Button,{onClick:J,size:"sm",variant:"secondary",className:"w-full",children:[e.jsx(Xs,{className:"mr-2 size-4"}),"Help"]})})]})}function Nt(t){const n=t.toUpperCase().indexOf("WHERE"),a=t.toUpperCase().indexOf("GROUP BY"),r=t.toUpperCase().indexOf("LIMIT"),o=t.toUpperCase().indexOf("ORDER BY");let l=t.length;if(o!==-1&&(l=o),r!==-1&&r<l&&(l=r),n!==-1){const i=t.substring(0,n),d=t.substring(n);return`${i} {{ filters | where }} AND ${d.substring(6)}`}else if(a!==-1){const i=t.substring(0,a),d=t.substring(a);return`${i} {{ filters | where }} ${d}`}else{const i=t.substring(0,l),d=t.substring(l);return console.log("beforeClause",i),console.log("afterClause",d),d?`${i} {{ filters | where }} ${d}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function wt({sql:t,error:n,onClick:a}){return!t&&!n?null:e.jsxs(s.HoverCard,{openDelay:n?0:500,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"link",className:"h-5 p-0",children:n?e.jsx(Ue,{className:"h-4 w-4 text-red-500"}):e.jsx(s.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(s.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxs(s.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll text-xs leading-relaxed text-foreground/80",children:[n&&n,t&&e.jsxs("div",{className:"flex flex-col space-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Resolved SQL"}),e.jsx("span",{className:"font-mono",children:t})]})]}),n&&e.jsxs(s.Button,{onClick:a,size:"sm",variant:"secondary",children:[e.jsx(Gs,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}var is={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Re=C.createContext&&C.createContext(is),kt=["attr","size","title"];function It(t,n){if(t==null)return{};var a=Et(t,n),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(o=0;o<l.length;o++)r=l[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function Et(t,n){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(n.indexOf(r)>=0)continue;a[r]=t[r]}return a}function be(){return be=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},be.apply(this,arguments)}function Ve(t,n){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),a.push.apply(a,r)}return a}function ye(t){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?Ve(Object(a),!0).forEach(function(r){Dt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Ve(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Dt(t,n,a){return n=Tt(n),n in t?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,t}function Tt(t){var n=Lt(t,"string");return typeof n=="symbol"?n:n+""}function Lt(t,n){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,n);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function ls(t){return t&&t.map((n,a)=>C.createElement(n.tag,ye({key:a},n.attr),ls(n.child)))}function he(t){return n=>C.createElement(At,be({attr:ye({},t.attr)},n),ls(t.child))}function At(t){var n=a=>{var{attr:r,size:o,title:l}=t,i=It(t,kt),d=o||a.size||"1em",h;return a.className&&(h=a.className),t.className&&(h=(h?h+" ":"")+t.className),C.createElement("svg",be({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,i,{className:h,style:ye(ye({color:t.color||a.color},a.style),t.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),l&&C.createElement("title",null,l),t.children)};return Re!==void 0?C.createElement(Re.Consumer,null,a=>n(a)):n(is)}function Mt(t){return he({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(t)}function cs(t){const{theme:n}=s.useTheme(),a=s.useDashboardStore(g=>g.theme),r=s.useEditorStore(g=>g.frame),o=s.useEditorStore(g=>g.card),l=s.useEditorStore(g=>g.activeTabCardId),i=s.Le(),{refetch:d}=s.useDashboardCardQuery(o),{updateCardTab:h,setRunSql:f}=s.useEditorActions(),u=C.useRef(),p=C.useRef({}),b=r.cards.find(g=>g.id===l),c=C.useCallback(()=>{let g="";return t==="python"&&(g=(b==null?void 0:b.python)||s.PYTHON_DEFAULT_CODE),t==="sql"&&(g=(b==null?void 0:b.sql)||""),g},[t,b]);C.useEffect(()=>{if(l&&o.id&&o.id!==l){if(u.current&&i){const g=u.current.getModel();g&&(p.current[o.id]=g);let S=p.current[l];if(!S){const j=c();S=i.editor.createModel(j,t),p.current[l]=S}u.current.setModel(S)}h(l,o),f(!0)}},[l,o,h,i,f,t,c]),C.useEffect(()=>{if(!i)return;const g=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",S=a==="system"?g:a;i.editor.defineTheme("default",{base:S==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":S==="light"?"#ffffff":s.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[n,a,i]),C.useEffect(()=>{const g=u.current;g&&i&&o&&g.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return d(),!1})},[i,d,o]);function m(g,S){if(u.current=g,!p.current[o.id]){const j=g.getModel(),I=c();p.current[o.id]=j||(S==null?void 0:S.editor.createModel(I,t))||g.getModel()}g.setModel(p.current[o.id])}return{handleEditorDidMount:m}}function zt(){const t=s.useEditorStore(i=>i.card.sql),n=s.useEditorStore(i=>i.sqlGen),{setCardSql:a,setSqlGen:r}=s.useEditorActions(),{handleEditorDidMount:o}=cs("sql");function l(i){a(i),s.isObjectEmpty(n)||r({})}return e.jsx(s.Ft,{theme:"default",className:"pt-3",onChange:l,value:t||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function Ot(){const t=s.useEditorStore(o=>o.card.python),{setCardPython:n}=s.useEditorActions(),{handleEditorDidMount:a}=cs("python");function r(o){n(o)}return e.jsx(s.Ft,{className:"pt-3",theme:"default",onChange:r,value:t||s.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:a})}function Ft({jsonString:t}){return e.jsx(s.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:t,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function ds(t){const[n,a]=C.useState(""),[r,o]=C.useState(null),{authToken:l}=s.useSemaphorContext(),i=s.useEditorStore(k=>{var _;return(_=k==null?void 0:k.card)==null?void 0:_.sql}),d=s.useEditorStore(k=>{var _;return(_=k==null?void 0:k.card)==null?void 0:_.python}),h=s.useEditorStore(k=>k.actions.setCardSql),f=s.useEditorStore(k=>k.actions.setRunSql),u=s.useEditorStore(k=>k.actions.switchCardType),p=s.useEditorStore(k=>k.currentAssitantScope)||[],b=s.useEditorStore(k=>k.userInputForAI),c=s.useEditorStore(k=>k.triggerAIRun),m=s.useEditorStore(k=>k.selectedDatabaseName),g=s.useEditorStore(k=>k.selectedTableName),S=s.useEditorStore(k=>k.selectedConnectionId),j=s.useEditorStore(k=>k.selectedSchemaName),I=s.useDashboardStore(k=>k.dashboard.aiScopeTables),{setTriggerAIRun:y,setCurrentAssitantScope:D}=s.useEditorActions(),{selectedDatamodelName:E,connectionType:O,selectedDatamodelId:V}=ae(),{messages:R,setMessages:B,reload:x,append:T,input:q,setInput:z,status:P,handleInputChange:G,handleSubmit:v,stop:N}=s.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${l==null?void 0:l.accessToken}`},body:{random:Math.random()},maxSteps:10,onToolCall:L,onFinish(k,_){H(_.usage),a(""),_.finishReason==="stop"&&a("")}});C.useEffect(()=>{c&&b&&(G({target:{value:b}}),setTimeout(()=>{v(),y(!1)},100))},[c,v,b,y,G]);async function L({toolCall:k}){if(k.toolName==="createChart"){const _=k.args.sql,W=k.args.chartType;return u(W),h(_),f(!0),{status:"success",message:"Let the user know that chart is created"}}else if(k.toolName==="getTableColumns")a("Getting table columns...");else{if(k.toolName==="getUserSql")return i?{status:"success",sql:i,python:d||""}:{status:"error",message:"No SQL found"};if(k.toolName==="getCurrentTableScope")return a("Getting table scope..."),M(),{status:"success",tables:p};a("Analyzing...")}}function H(k){o(_=>_?{promptTokens:_.promptTokens+k.promptTokens,completionTokens:_.completionTokens+k.completionTokens,totalTokens:_.totalTokens+k.totalTokens}:k)}function U(k){const _=s.removeFromScopeArray(p,k);Q(_)}function Q(k){const _=s.sanitizeAIScope(k);D(_),B(W=>[...W,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(_)}`}])}function F(){const k={databaseName:m||"",schemaName:j||"",tableName:g||"",datamodelId:V||"",datamodelName:s.resolveDatamodelName(E),connectionId:S||"",connectionType:O||""},_=s.dedup([...p,k]);Q(_)}function M(){const k={databaseName:m||"",schemaName:j||"",tableName:g||"",datamodelName:s.resolveDatamodelName(E),connectionId:S||"",connectionType:O||"",datamodelId:V||""};if(!s.isInAiScopeArray([...I||[],...p],k)||p.length===0){const W=s.dedup([...I||[],...p,k]).filter(K=>K.connectionId===k.connectionId);Q(W)}}const J=!["ready","error"].includes(P);return{messages:R,setMessages:B,reload:x,append:T,input:q,setInput:z,isLoading:J,handleSetAIScope:M,handleAddCurrentTableToScope:F,removeFromCurrentSelections:U,currentAssitantScope:p,setCurrentAssitantScope:D,handleInputChange:G,handleSubmit:v,stop:N,chatStatus:P,toolStatus:n,llmUsage:r,onFinish:t}}function Rt(){var re;const[t,n]=C.useState({queryKey:[],queryData:null}),a=s.useQueryClient(),[r,o]=C.useState(!1),[l,i]=C.useState(!1),d=s.useEditorStore(A=>A.frame),h=s.useEditorStore(A=>A.card),f=s.useEditorStore(A=>A.isShowingVisual),u=s.useEditorStore(A=>A.selectedConnectionId),p=s.useEditorStore(A=>A.selectedDatabaseName),b=s.useEditorStore(A=>A.selectedDatamodelId),c=s.useEditorStore(A=>A.selectedSchemaName),m=s.useEditorStore(A=>A.showAIDialog),g=s.useEditorStore(A=>A.selectedTableName),S=s.useEditorStore(A=>{var Y;return(Y=A==null?void 0:A.card)==null?void 0:Y.sql}),{sheetFilterValues:j}=s.useSheetFilterValues(),{setCardCustomCfg:I,setQueryResultColumns:y,setCardSql:D,setPythonStdOut:E,setCardPreferences:O,setCardType:V,setCardPython:R,runAssistant:B,setShowAIDialog:x}=s.useEditorActions(),T=s.useEditorStore(A=>A.onSave),q=s.useEditorStore(A=>A.onClose),z=s.useEditorStore(A=>A.actions.setSqlGen),P=s.useEditorStore(A=>A.runSql),G=s.useEditorStore(A=>A.actions.setRunSql),v=s.useEditorStore(A=>A.actions.setCardCfg),N=s.useEditorStore(A=>A.actions.setIsSqlRunning),{data:L,isLoading:H,isFetching:U,isSuccess:Q,isError:F,error:M,queryKey:J,refetch:k}=s.useDashboardCardQuery(h),{handleSetAIScope:_}=ds();C.useEffect(()=>{if(L&&(L.rowLimitExceeded&&s.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((L==null?void 0:L.output)||""),L.records.length>0)){const{dimensionKeys:A}=s.getKeys(L.records);y(A)}},[L,y,E]),C.useEffect(()=>{(H||U)&&N(!0),(F||Q)&&N(!1),F&&(y([]),E(""))},[H,U,L,E,F,Q,N,y,M]),C.useEffect(()=>{P&&(a.getQueryData(J)||k(),G(!1))},[P,k,G,J,a]);function W(){const A=a.getQueryData(J);t.queryData||n({queryKey:J,queryData:A}),a.setQueryData(J,null),a.removeQueries({queryKey:J,exact:!0}),D(""),z({}),R(""),v(void 0),I(""),O({}),V("bar")}function K(A,Y){if(A.length===0)return"";if(Y){const oe=A.find(X=>X.id===Y);if(oe){const X=oe.tabTitle;if(X=="All__Header")return A[0].id;if(X&&X.endsWith("__Header")){const Se=X.split("__")[0],fe=A.find(Ce=>Ce.tabTitle===Se);return fe?fe.id:A[0].id}return Y}}return A[0].id}function te(){let A=S;S&&!S.includes("{{")&&(A=Nt(S),D(A));const Y={...h,lastSelectedSchema:c,lastSelectedDatamodelId:b,lastSelectedDatabase:p,lastSelectedTable:g,connectionId:u,type:f?h.type:"table",sql:A,customCfg:f?h.customCfg:null},oe=d.cards.map(xe=>xe.id===h.id?Y:xe),X={...d,cards:oe,activeCardId:K(oe,d.activeCardId)};T==null||T(X)}function se(){const{queryKey:A,queryData:Y}=t;A&&Y&&a.setQueryData(A,Y),z({}),q==null||q()}async function $(){const A=`Can you help me debug this query in the current table scope?
|
|
306
|
+
*/const es=s.createLucideIcon("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);function Ie(t){var n;return{...t,sheets:(n=t==null?void 0:t.sheets)==null?void 0:n.map(a=>{var r;return{...a,frames:(r=a.frames)==null?void 0:r.map(o=>{var l;return{...o,cards:(l=o.cards)==null?void 0:l.map(i=>ss(i))}})}})}}function ss(t){var n,a,r,o;return{...t,cfg:{...t.cfg,data:{...(n=t.cfg)==null?void 0:n.data,labels:[],datasets:(o=(r=(a=t.cfg)==null?void 0:a.data)==null?void 0:r.datasets)==null?void 0:o.map(l=>({...l,data:[]}))}},customCfg:mt(t.customCfg),data:[]}}function mt(t){var n,a;return t?{...t,data:{...t==null?void 0:t.data,labels:[],datasets:(a=(n=t==null?void 0:t.data)==null?void 0:n.datasets)==null?void 0:a.map(r=>({...r,data:[]}))}}:null}async function xt(t,n,a,r){if(!r)return null;const o=JSON.stringify(n);return await s.postRequest("https://semaphor.cloud/api/v1/lens",r,{name:t,template:o,filterValues:a,operation:"create"})}async function ve(t,n){if(!n)return null;const{id:a,template:r,filterValues:o,isDefault:l,shared:i}=t;return await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{lensId:a,template:r,filterValues:o,isDefault:l,shared:i,operation:"update"})}async function pt(t,n){return n?await s.postRequest("https://semaphor.cloud/api/v1/lens",n,{operation:"delete",lensId:t}):null}function ft(){const[t,n]=C.useState(""),[a,r]=C.useState(!1),o=s.useDashboardStore(g=>g.lenses),{setLenses:l,setSelectedLensId:i}=s.useDashboardActions(),[d,h]=C.useState(!1),[f,u]=C.useState(!1),p=s.useDashboardStore(g=>g.dashboard),b=s.useDashboardStore(g=>g.filterValues),{authToken:c}=s.useSemaphorContext();async function m(){h(!0);const g=Ie(p),S=await xt(t,g,b,c==null?void 0:c.accessToken);S&&(l([...o||[],S]),i(S.id),u(!1)),h(!1)}return e.jsxs(s.Dialog,{open:f,onOpenChange:u,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:g=>{n(g.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:m,disabled:d,children:d?"Creating...":"Add"})})]})]})}function gt(){const[t,n]=C.useState(!1),a=s.useDashboardStore(u=>u.lenses),r=s.useDashboardStore(u=>u.selectedLensId),{setLenses:o,setSelectedLensId:l}=s.useDashboardActions(),{authToken:i}=s.useSemaphorContext();async function d(u){l(u)}async function h(u){if(await pt(u,i==null?void 0:i.accessToken)){const b=a==null?void 0:a.filter(c=>c.id!==u);o(b||[]),l("original")}}async function f(u){const p=a==null?void 0:a.map(m=>m.id===u.id?{...m,isDefault:!u.isDefault}:{...m,isDefault:!1});o(p||[]);const b={...u,isDefault:!u.isDefault};await ve(b,i==null?void 0:i.accessToken);const c=a==null?void 0:a.find(m=>m.isDefault);if(c&&c.id!==u.id){const m={...c,isDefault:!1};await ve(m,i==null?void 0:i.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(_s,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:d,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(u=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:u.id,children:[e.jsx("p",{children:u.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(Us,{onClick:p=>{p.preventDefault(),f(u)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!u.isDefault,"text-green-500":u.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:p=>{p.preventDefault(),h(u.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},u.id))]})]})]})}function ts(){var l;const t=s.useDashboardStore.getState().authToken,n=s.useDashboardStore.getState().theme,a=s.useDashboardStore.getState().filterValues,r=(l=s.useDashboardStore.getState().dashboard)==null?void 0:l.title,o=s.useDashboardStore.getState().selectedSheetId;return{authToken:t,theme:n||"light",filterValues:a,dashboardTitle:r||"",selectedSheetId:o||""}}async function as(){const t=s.useDashboardStore.getState().isDownloadingPdf,{authToken:n,theme:a,filterValues:r,dashboardTitle:o,selectedSheetId:l}=ts();if(t)return;const i=new URLSearchParams;i.set("token",(n==null?void 0:n.accessToken)||""),i.set("theme",a),i.set("filterValues",JSON.stringify(r)),i.set("selectedSheetId",l||"");const d=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(i.toString())}`;s.useDashboardStore.setState({isDownloadingPdf:!0});const u=(await(await fetch(d,{method:"GET",headers:{Authorization:`Bearer ${n==null?void 0:n.accessToken}`}})).json()).url,p=document.createElement("a");p.href=u;const b=`${o}-${new Date().toISOString()}.pdf`;p.download=b,p.click(),s.useDashboardStore.setState({isDownloadingPdf:!1})}function jt({iconClassName:t}){const{authToken:n}=s.useSemaphorContext();s.useDashboardStore(o=>{var l;return(l=o.dashboard)==null?void 0:l.title}),s.useDashboardStore(o=>o.theme),s.useDashboardStore(o=>o.filterValues);const a=s.useDashboardStore(o=>o.isDownloadingPdf);async function r(){await as()}return e.jsx(s.IconButton,{tooltip:"Download PDF",className:"h-7 p-2",onClick:r,children:a?e.jsx(ie,{className:s.cn("size-3.5 animate-spin",t)}):e.jsx(s.Download,{className:s.cn("size-4",t)})})}function ee({defaultValue:t,label:n,options:a,value:r,onValueChange:o,className:l}){return e.jsxs(s.Select,{defaultValue:t,value:r,onValueChange:o,children:[e.jsx(s.SelectTrigger,{className:s.cn("w-full focus:ring-0 focus:ring-offset-0",l),children:e.jsx(s.SelectValue,{placeholder:n})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:n}),a.map(i=>e.jsx(s.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}const Oe=[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-Weekly"},{value:"monthly",label:"Monthly"}];function ns(){const{data:t,handleScheduleSubscription:n,handleDeleteSubscription:a,status:r,error:o,isDeleting:l}=bt(),[i,d]=C.useState(""),[h,f]=C.useState(Oe[0].value),[u,p]=C.useState("00:00"),[b,c]=C.useState("");return e.jsx(s.TooltipProvider,{delayDuration:0,children:e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Schedule Dashboard",className:"h-7 p-2",children:e.jsx(Os,{className:"size-4"})})}),e.jsx(s.PopoverContent,{align:"end",className:"w-80",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Schedule Subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribe to receive dashboard via email"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"email",children:"Email"}),e.jsx(s.Input,{id:"email",value:i,onChange:m=>d(m.target.value),className:`col-span-2 h-8 ${s.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"subject",children:"Subject"}),e.jsx(s.Input,{id:"subject",placeholder:"Monthly Sales Report",value:b,onChange:m=>{c(m.target.value.replace(/[^a-zA-Z0-9\s-_]/g,""))},className:`col-span-2 h-8 ${s.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"frequency",children:"Frequency"}),e.jsx(ee,{className:"col-span-2 h-8",label:"Select Frequency",options:Oe,value:h,onValueChange:m=>f(m)})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"time",children:"Time"}),e.jsx(s.Input,{id:"time",type:"time",value:u,onChange:m=>p(m.target.value),className:`col-span-2 h-8 ${s.removeRing}`})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs(s.Button,{onClick:async()=>{await n({email:i,frequency:h,time:u,subject:b}),p("00:00"),d(""),c("")},className:"h-8 p-2",disabled:r==="loading"||!i,children:[r==="loading"&&e.jsx(ie,{className:"mr-2 size-4 animate-spin"}),r==="success"&&e.jsx(s.Check,{className:"mr-2 size-4"}),r==="error"&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsx(Ue,{className:"mr-2 size-4 text-destructive"})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:o})})]}),"Schedule"]})}),t&&t.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(s.Separator,{className:"my-2"}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Subscriptions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active email subscriptions"})]}),s.isDev]})}),e.jsx("div",{className:"grid gap-2",children:t==null?void 0:t.map(m=>e.jsxs("div",{className:"group grid grid-cols-5 gap-3",children:[e.jsx("div",{className:"col-span-3 text-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"boder-border rounded-md border bg-muted px-2 py-1",children:[s.titleCase(m.frequency)," "]}),e.jsx(s.Label,{children:m.time})]})}),e.jsxs("div",{className:"col-span-2 flex items-center justify-end gap-4",children:[e.jsx(Fe,{tooltip:`Next Run: ${new Date(m.nextRun).toLocaleString()} ${m.timezone}`,children:e.jsx(zs,{className:"size-3.5"})}),e.jsx(Fe,{tooltip:`${m.endUserEmail}`,children:e.jsx(Ys,{className:"size-3.5"})}),l===m.id?e.jsx(ie,{className:"size-3.5 animate-spin"}):e.jsx(ht,{onClick:()=>a(m.id),className:"size-3.5 cursor-pointer"})]})]},m.id))})]})]})]})})]})})}const Fe=({children:t,tooltip:n})=>e.jsx(s.TooltipProvider,{delayDuration:0,children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:t}),e.jsx(s.TooltipContent,{children:n})]})});function bt(){const[t,n]=C.useState("idle"),[a,r]=C.useState(""),[o,l]=C.useState(null),i=s.useDashboardStore(y=>y.authToken),d=s.useDashboardStore(y=>y.dashboard.id),h=s.useDashboardStore(y=>y.dashboard.title),{endUserId:f}=s.getTenantAndEndUserId((i==null?void 0:i.accessToken)||""),u="https://semaphor.cloud/api/v1/subscriptions/get",p={dashboardId:d,endUserId:f},{data:b,isLoading:c,isError:m,isFetching:g,refetch:S}=s.useQuery({queryKey:["subscriptions",d,f],queryFn:()=>s.getRequest(u,(i==null?void 0:i.accessToken)||"",p),enabled:!!(i!=null&&i.accessToken)&&!!d&&!!f});async function j({email:y,subject:D,frequency:E,time:O}){const{authToken:V,...R}=ts(),B=Intl.DateTimeFormat().resolvedOptions().timeZone,x={email:y,frequency:E,time:O,timezone:B,endUserId:f,endUserEmail:y,subject:D||h||"Scheduled Dashboard",dashboardId:d,dashboardParams:R};n("loading");const T="https://semaphor.cloud/api/v1/subscriptions/create";try{const q=await s.postRequestRegular(T,(V==null?void 0:V.accessToken)||"",{...x});n("success"),r(""),S(),setTimeout(()=>{n("idle")},2e3)}catch(q){console.error(q),n("error"),r(q.message)}}async function I(y){const D="https://semaphor.cloud/api/v1/subscriptions/delete";l(y);try{await s.postRequestRegular(D,(i==null?void 0:i.accessToken)||"",{id:y}),S(),setTimeout(()=>{l(null)},2e3)}catch(E){console.error(E),l(null),n("error"),r(E.message)}}return{data:b,isLoading:c,isFetching:g,isError:m,isDeleting:o,refetch:S,handleScheduleSubscription:j,handleDeleteSubscription:I,status:t,error:a}}function yt(){const{authToken:t}=s.useSemaphorContext();s.useDashboardStore(x=>x.theme);const n=s.useDashboardStore(x=>x.lenses),a=s.useDashboardStore(x=>x.selectedLensId),r=n==null?void 0:n.find(x=>x.id===a),o=s.useDashboardStore(x=>x.dashboard);s.useDashboardStore(x=>x.selectedSheetId);const l=s.useDashboardStore(x=>x.isDashboardEditing),i=s.useEditorStore(x=>x.selectedConnectionId),[d,h]=C.useState(!1),f=s.useDashboardStore(x=>x.filterValues),u=s.useDashboardStore(x=>x.isVisualEditing),p=s.useDashboardStore(x=>x.showFilters);s.useDashboardStore(x=>x.showDashboardJSON);const b=s.useDashboardStore(x=>x.onSaveFunction),c=s.useDashboardStore(x=>x.actions.setShowFilters),{addFrame:m,setSelectedFrameId:g}=s.useDashboardStore(x=>x.actions),{getSelectedSheet:S,setIsDashboardEditing:j,setShowDashboardJSON:I}=s.useDashboardStore(x=>x.actions),y=S(),{tenantId:D,endUserId:E}=C.useMemo(()=>s.getTenantAndEndUserId(t==null?void 0:t.accessToken),[t==null?void 0:t.accessToken]),O=C.useMemo(()=>D||E,[D,E]),V=()=>{if(!l||!y)return;const x={connectionId:i,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},T={id:s.v4(),cards:[x],activeCardId:x.id};m(y.id,T),g(T.id)},R=()=>{j(!0)};async function B(){if(h(!0),!a||!r)return;const x=Ie(o),T=JSON.stringify(x),q={...r,template:T,filterValues:f};await ve(q,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),b==null||b(x),h(!1)}return u?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b py-2 pl-3 pr-2",role:"dashboard-controls",children:[!u&&e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(s.Label,{children:r==null?void 0:r.name})}),e.jsxs("div",{className:"flex gap-2",children:[!1,!u&&e.jsx(jt,{}),!u&&e.jsx(ns,{}),l&&!u&&O&&e.jsx(ft,{}),!u&&O&&e.jsx(gt,{}),l&&!u&&e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!l,onClick:V,children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Frame"]}),!l&&e.jsx(s.Button,{variant:"ghost",className:"h-7 p-2",onClick:R,size:"sm",children:e.jsx(s.Pencil,{className:"h-4 w-4"})}),l&&!u&&e.jsx(s.IconButton,{className:"h-7 p-2",onClick:()=>{j(!1),I(!1)},children:e.jsx(s.Cross2Icon,{className:"h-4 w-4"})}),l&&!u&&O&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",disabled:d,onClick:B,size:"sm",children:e.jsx(ot,{className:"h-4 w-4"})}),!p&&!u&&l&&e.jsx(s.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>c(!0),size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),!u&&l&&!1,!u&&!1]})]})}function St({name:t,items:n,value:a,onChange:r,isLoading:o,isError:l,refetch:i,className:d,showNone:h=!1}){const f=ue.useRef(null),[u,p]=ue.useState(!1),[b,c]=ue.useState("100%"),m=h?[...n||[],{id:"none",name:"None"}]:n;ue.useLayoutEffect(()=>{f.current&&c(f.current.offsetWidth)},[]);function g(){var j;return o?"Loading...":l?"Error":a?(j=n==null?void 0:n.find(I=>I.id===a))==null?void 0:j.name:`Select ${t}`}function S(j,I){r(I),p(!1)}return e.jsxs(s.Popover,{open:u,onOpenChange:p,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":u,className:s.cn("flex h-9 w-full max-w-[226px] justify-between",d),children:[e.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:g()}),e.jsx(s.ChevronDown,{className:"size-4 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:e.jsxs(s.Command,{children:[e.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[e.jsx(s.CommandInput,{className:"h-9",placeholder:"Search..."}),e.jsx(s.IconButton,{className:"h-7",onClick:i,children:e.jsx(Ze,{className:s.cn("size-3.5 opacity-50",o&&"animate-spin")})})]}),e.jsxs(s.CommandList,{children:[e.jsxs(s.CommandEmpty,{children:["No ",t==null?void 0:t.toLowerCase()," found."]}),e.jsx(s.CommandGroup,{children:m==null?void 0:m.map(j=>e.jsx(s.CommandItem,{className:"overflow-x-auto",value:j.name,onSelect:I=>S(I,j.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Check,{className:s.cn("size-4",a===j.id?"opacity-100":"opacity-0")}),e.jsx("div",{title:j.name,children:j.name})]})},j.id))})]})]})})]})}function de({title:t,items:n,value:a,isLoading:r,isError:o,refetch:l,connectionTooltip:i,onChange:d,showNone:h=!1,className:f,showIcon:u=!0,disabled:p=!1,type:b="combobox"}){const c=r?"Loading...":o?"Error":a;function m(){if(t==="Connection")return e.jsx(at,{className:"size-4 rotate-90"});if(t==="Database")return e.jsx(Vs,{className:"size-4"});if(t==="Schema")return e.jsx(tt,{className:"size-4"});if(t==="Table")return e.jsx(ke,{className:"size-4"});if(t==="Model")return e.jsx(Ls,{className:"size-4"})}function g(){return e.jsxs(s.Select,{disabled:p,value:c,onValueChange:d,children:[e.jsx(s.SelectTrigger,{className:s.cn("h-9 w-full border-muted focus:ring-1 focus:ring-offset-0",f),children:e.jsx(s.SelectValue,{placeholder:r?"Loading...":o?"Error":`Select ${t}`})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[r?e.jsx(s.SelectLabel,{children:"Loading..."}):e.jsxs(s.SelectLabel,{className:"flex items-center justify-between gap-2",children:[t,e.jsx(Ze,{className:s.cn("mr-1 size-3 cursor-pointer text-muted-foreground hover:text-foreground",r&&"animate-spin"),onClick:l})]}),e.jsxs(e.Fragment,{children:[h&&e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((j,I)=>e.jsx(s.SelectItem,{value:j.id,children:j.name},I))]}),(r||o)&&e.jsx(s.SelectItem,{value:c,children:c})]})})]})}function S(){return e.jsx(St,{items:n,value:c,onChange:d||(()=>{}),isLoading:r,isError:o,refetch:l,name:t,showNone:h})}return e.jsx(s.TooltipProvider$1,{delayDuration:0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsx("div",{className:"shrink-0",children:i?e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:m()}),e.jsx(s.TooltipContent,{className:"text-xs",align:"start",children:i})]}):m()}),b==="select"?g():S()]})})}function Ct({column:t}){const[n,a]=C.useState(!1),r=s.useEditorStore(m=>m.selectedTableName),o=s.useEditorStore(m=>m.selectedSchemaName),l=s.useEditorStore(m=>m.selectedDatamodelId),i=s.useEditorStore(m=>m.sqlGen),{modelItems:d,connectionType:h}=ae(),f=s.useEditorStore(m=>m.actions.setSqlGen),u=s.useEditorStore(m=>m.actions.setCardSql),p=s.useEditorStore(m=>m.actions.setRunSql);function b(m,g){var y;const S=s.createSqlGenConfig(m,i,g),j=(y=d==null?void 0:d.find(D=>D.id===l))==null?void 0:y.name;f(S);const I=s.getSql(S,s.fmt(o||""),s.fmt(r),j,h);I&&(u(I),p(!0)),a(!1)}function c(){return e.jsxs("ul",{className:"text-xs",children:[e.jsx("li",{onClick:()=>b(t,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsx("li",{onClick:()=>b(t,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsx("li",{onClick:()=>b(t,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsx("li",{onClick:()=>b(t,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsx("li",{onClick:()=>b(t,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxs(s.HoverCard,{openDelay:0,open:n,onOpenChange:a,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(Je,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsx(s.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:c()})]})}function rs({column:t}){return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger$1,{asChild:!0,children:s.isTextDataType(t.data_type)?e.jsx(es,{className:"size-3"}):s.isNumberDataType(t.data_type)?e.jsx($s,{className:"size-3"}):s.isDateDataType(t.data_type)?e.jsx(s.Calendar,{className:"size-3"}):s.isBooleanDataType(t.data_type)?e.jsx(ut,{className:"size-3"}):t.data_type.toLowerCase()==="json"?e.jsx(As,{className:"size-3"}):e.jsx(it,{className:"size-3"})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{className:"font-mono text-xs",children:t.data_type})})]})}function vt({schemaName:t,tableName:n,columns:a,status:r}){const o=s.useEditorStore(x=>x.sqlGen),l=s.useEditorStore(x=>x.selectedConnectionId),i=s.useEditorStore(x=>x.selectedDatabaseName),d=s.useEditorStore(x=>x.selectedSchemaName),h=s.useEditorStore(x=>x.selectedTableName),f=s.useEditorStore(x=>x.selectedDatamodelId),u=s.useDashboardStore(x=>x.dashboard.aiScopeTables),{addToAIScope:p,removeFromAIScope:b}=s.useDashboardActions(),{setAIScopeTables:c}=s.useDashboardStore(x=>x.actions),m=s.useEditorStore(x=>x.actions.setRunSql),g=s.useEditorStore(x=>x.actions.setSqlGen),S=s.useEditorStore(x=>x.actions.setIsShowingVisual),j=s.useEditorStore(x=>x.actions.setCardSql),{connectionType:I,modelItems:y,selectedDatamodelName:D}=ae();function E(x){var P;const T=s.createSqlGenConfig(x,o);g(T);const q=(P=y==null?void 0:y.find(G=>G.id===f))==null?void 0:P.name,z=s.getSql(T,s.fmt(t),s.fmt(n),q,I);z&&(j(z),m(!0))}function O(){return(u==null?void 0:u.find(x=>x.connectionId===l&&(x.tableName===h||x.datamodelName===D)))!==void 0}function V(x){x===!0&&(h||D)&&l?(p({connectionId:l,connectionType:I==="S3"||I==="API"?"DuckDb":I,databaseName:i||"",schemaName:d||"",tableName:h||"",datamodelName:s.resolveDatamodelName(D),datamodelId:f||""}),s.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(b({connectionId:l||"",connectionType:I||"",tableName:h||"",datamodelName:s.resolveDatamodelName(D),datamodelId:f||"",databaseName:i||"",schemaName:d||""}),s.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function R(){const x=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:D,connectionType:I});S(!1);const T=I==="MSSQL"?`SELECT top 10 * FROM ${x}`:`SELECT * FROM ${x} LIMIT 10`;j(T),m(!0)}function B(){const x=s.getFormattedTableNameForQuery({schemaName:t,tableName:n,modelName:D,connectionType:I});j(`SELECT COUNT(*) as count FROM ${x}`),m(!0)}return e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-center gap-2",children:[e.jsxs(s.Toggle,{title:`${O()?"Remove from":"Add to"} Assistant Scope`,pressed:O(),onPressedChange:V,variant:"outline",className:s.cn("h-9 px-2",{}),children:[e.jsx(s.Plus,{className:s.cn("mr-1 size-4",{"text-green-400":O(),"text-muted-foreground":!O()})}),"AI"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:R,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Zs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(s.Button,{disabled:r!=="Success",onClick:B,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(ie,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(lt,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxs(s.ScrollArea,{className:"flex-1 basis-0 border-b border-t border-muted py-3",children:[e.jsx("div",{className:"flex flex-col gap-1",children:a==null?void 0:a.map(x=>e.jsxs("div",{onClick:()=>E(x),className:s.cn("group mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-1 text-sm transition-colors hover:bg-muted/50",{"border border-dashed border-muted-foreground bg-muted":s.isColumnInSqlGen(x,o)}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(rs,{column:x}),e.jsx("span",{children:x.column_name})]}),e.jsx("div",{onClick:T=>T.stopPropagation(),className:"flex items-center justify-end",children:s.isNumberDataType(x.data_type)&&e.jsx(Ct,{column:x})})]},x.column_name))}),e.jsx(s.ScrollBar,{orientation:"vertical"}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function ae(t,n){var De,Te,Le,Ae,Me,ze;let a=C.useMemo(()=>[],[]);const r=s.useSemaphorContext().authToken||t,o=s.useEditorStore(w=>w.selectedConnectionId),l=s.useEditorStore(w=>w.selectedDatamodelId),i=s.useEditorStore(w=>w.selectedDatabaseName),d=s.useEditorStore(w=>w.selectedSchemaName),h=s.useEditorStore(w=>w.selectedTableName),f=s.useEditorStore(w=>w.actions.setCurrentColumns),u=s.useEditorStore(w=>w.actions.setSelectedConnectionId),p=s.useEditorStore(w=>w.actions.setSelectedDatamodelId),b=s.useEditorStore(w=>w.actions.setSelectedDatabaseName),c=s.useEditorStore(w=>w.actions.setSelectedSchemaName),m=s.useEditorStore(w=>w.actions.setSelectedTableName);s.useEditorStore(w=>w.actions.setCardSql);function g(w){return o&&i&&d&&i!=="NA"?!0:o&&w==="API"?!1:!!(o&&w==="S3")}function S(w){return!!(o&&i&&i!=="NA"&&d&&h||o&&(w==="S3"||w==="API")||l&&l)}function j(w){return o&&w?!(w==="API"||w==="S3"):!1}const{refetch:I,data:y,isLoading:D,isError:E}=s.useQuery({queryKey:["connections"],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{refetch:O,data:V,isLoading:R,isError:B}=s.useQuery({queryKey:["models",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:!!(r!=null&&r.accessToken)&&!!o}),x=y==null?void 0:y.connections.find(w=>w.id===o),T=x==null?void 0:x.type,q=(x==null?void 0:x.type)==="API"||(x==null?void 0:x.type)==="S3",{data:z,isLoading:P,isFetching:G,isError:v,refetch:N}=s.useQuery({queryKey:["databases",o],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:o}),enabled:j(T)}),{data:L,isLoading:H,isFetching:U,isError:Q,refetch:F}=s.useQuery({queryKey:["schemas",o,i],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:i}),enabled:!!o&&!!i&&!q&&i!=="NA"}),{data:M,isLoading:J,isFetching:k,isError:_,refetch:W}=s.useQuery({queryKey:["tables",o,i,d],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:o,database_name:i,schema_name:d}),enabled:g(T)}),{data:K,isLoading:te,isFetching:se,isError:$,refetch:Z}=s.useQuery({queryKey:["columns",o,i,l,d,h],queryFn:()=>s.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:o,datamodel_id:l||"",database_name:i,schema_name:d,table_name:h}),enabled:S(T)});C.useEffect(()=>{f(a)},[K,f,a]),C.useEffect(()=>{(T==="S3"||T==="API")&&(b(""),c(""),p(""),T==="API"&&m("api"))},[T,m,b,c,p]);const ce=(x==null?void 0:x.type)==="API"?(De=x==null?void 0:x.type)==null?void 0:De.toLowerCase():h||"",ne=q?"":d||"";function re(w){c(w),m("")}function A(w){b(w==="none"?"":w),c(""),m(""),w!=="none"&&w!==""&&p("")}function Y(w){u(w)}function oe(w){p(w==="none"?"":w),w!=="none"&&w!==""&&b("")}z&&((Te=z==null?void 0:z.databases)==null?void 0:Te.length)>0,L&&((Le=L==null?void 0:L.schemas)==null?void 0:Le.length)>0,K&&((Ae=K==null?void 0:K.columns)==null?void 0:Ae.length)>0&&(a=K.columns.map(w=>({...w,data_type:w.data_type.toLowerCase()}))),v&&(a=[]),($||E)&&(a=[]);const X=y==null?void 0:y.connections.map(w=>({id:w.id,name:w.name,type:w.type})),xe=(Me=V==null?void 0:V.datamodels)==null?void 0:Me.map(w=>({id:w.id,name:w.name})),Se=z==null?void 0:z.databases.map(w=>({id:w.database_name,name:w.database_name})),fe=L==null?void 0:L.schemas.map(w=>({id:w.schema_name,name:w.schema_name})),Ce=M==null?void 0:M.tables.map(w=>({id:w.table_name,name:w.table_name})),Ss=(ze=V==null?void 0:V.datamodels.find(w=>w.id===l))==null?void 0:ze.name;return{connectionItems:X,isConnectionsLoading:D,isConnectionsError:E,modelItems:xe,selectedDatamodelId:l,selectedDatamodelName:Ss,isModelsLoading:R,isModelsError:B,databaseItems:Se,isDatabasesLoadingOrFetching:P||G,isDatabaseError:v,schemaItems:fe,isSchemaLoadingOrFetching:H||U,isSchemaError:Q,tableItems:Ce,isTableLoadingOrFetching:J||k,isTableError:_,columns:a,isColumnsLoadingOrFetching:te||se,isColumnsError:$,isNonDbConnection:q,connectionType:T,tableName:ce,schemaName:ne,refetchConnections:I,refetchModels:O,refetchDatabases:N,refetchSchemas:F,refetchTables:W,refetchColumns:Z,handleConnectionChange:Y,handleDatamodelChange:oe,handleDatabaseChange:A,handleSchemaChange:re}}function os({ColumnsComponent:t}){var se;const n=s.useEditorStore($=>$.selectedConnectionId),a=s.useEditorStore($=>$.selectedDatamodelId),r=s.useEditorStore($=>$.selectedDatabaseName),o=s.useEditorStore($=>$.selectedSchemaName),l=s.useEditorStore($=>$.selectedTableName),i=s.useEditorStore($=>$.actions.setSelectedTableName),{connectionItems:d,modelItems:h,schemaItems:f,databaseItems:u,tableItems:p,columns:b,isConnectionsLoading:c,isModelsLoading:m,isConnectionsError:g,isModelsError:S,isDatabasesLoadingOrFetching:j,isDatabaseError:I,isSchemaLoadingOrFetching:y,isSchemaError:D,isColumnsError:E,isColumnsLoadingOrFetching:O,isTableLoadingOrFetching:V,isTableError:R,connectionType:B,isNonDbConnection:x,refetchDatabases:T,refetchModels:q,refetchSchemas:z,refetchTables:P,refetchColumns:G,refetchConnections:v,handleConnectionChange:N,handleDatabaseChange:L,handleSchemaChange:H,handleDatamodelChange:U,tableName:Q,schemaName:F}=ae();function M(){return t?t(F,Q,b):e.jsx(vt,{schemaName:F,tableName:Q,columns:b,status:O?"Loading...":E?"Error":"Success"})}function J(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function k(){if(!n||B==="S3"||B==="API")return null;if(!a||a==="none")return e.jsx(de,{refetch:T,showNone:!0,onChange:L,isError:I,isLoading:j,items:u,value:r||"",title:"Database",type:"combobox"})}function _(){if(n&&!x&&(!r||r==="none")&&(!a||a==="none"))return e.jsxs("div",{className:"grid grid-cols-3",children:[e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Label,{children:"OR"})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(s.Separator,{})})]})}function W(){if(!n||B==="S3"||B==="API")return null;if(!r||r==="none")return e.jsx(de,{refetch:q,showNone:!0,onChange:U,isError:S,isLoading:m,items:h,value:a||"",title:"Model",type:"combobox"})}function K(){return!n||B==="S3"||B==="API"||!r||r==="none"?null:e.jsx(de,{refetch:z,onChange:H,isError:D,isLoading:y,items:f,value:o||"",title:"Schema",type:"combobox"})}function te(){function $(){let Z=!1;return B==="API"?(Z=!1,Z):((B==="S3"||n&&r&&r!=="none"&&o)&&(Z=!0),Z)}return $()?e.jsx(de,{refetch:P,onChange:i,isError:R,items:p,isLoading:V,value:l||"",title:"Table",type:"combobox"}):null}return e.jsxs("aside",{className:"flex h-full min-w-[300px] flex-col justify-between rounded-none border-r-[1px]",children:[e.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsx(de,{refetch:v,items:d,title:"Connection",value:n||"",onChange:N,isLoading:c,isError:g,type:"combobox",connectionTooltip:((se=d==null?void 0:d.find($=>$.id===n))==null?void 0:se.type)||""}),k(),_(),W(),K(),te()]}),M(),e.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxs(s.Button,{onClick:J,size:"sm",variant:"secondary",className:"w-full",children:[e.jsx(Xs,{className:"mr-2 size-4"}),"Help"]})})]})}function Nt(t){const n=t.toUpperCase().indexOf("WHERE"),a=t.toUpperCase().indexOf("GROUP BY"),r=t.toUpperCase().indexOf("LIMIT"),o=t.toUpperCase().indexOf("ORDER BY");let l=t.length;if(o!==-1&&(l=o),r!==-1&&r<l&&(l=r),n!==-1){const i=t.substring(0,n),d=t.substring(n);return`${i} {{ filters | where }} AND ${d.substring(6)}`}else if(a!==-1){const i=t.substring(0,a),d=t.substring(a);return`${i} {{ filters | where }} ${d}`}else{const i=t.substring(0,l),d=t.substring(l);return console.log("beforeClause",i),console.log("afterClause",d),d?`${i} {{ filters | where }} ${d}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function wt({sql:t,error:n,onClick:a}){return!t&&!n?null:e.jsxs(s.HoverCard,{openDelay:n?0:500,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"link",className:"h-5 p-0",children:n?e.jsx(Ue,{className:"h-4 w-4 text-red-500"}):e.jsx(s.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(s.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxs(s.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll text-xs leading-relaxed text-foreground/80",children:[n&&n,t&&e.jsxs("div",{className:"flex flex-col space-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Resolved SQL"}),e.jsx("span",{className:"font-mono",children:t})]})]}),n&&e.jsxs(s.Button,{onClick:a,size:"sm",variant:"secondary",children:[e.jsx(Gs,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}var is={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Re=C.createContext&&C.createContext(is),kt=["attr","size","title"];function It(t,n){if(t==null)return{};var a=Et(t,n),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(o=0;o<l.length;o++)r=l[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(a[r]=t[r])}return a}function Et(t,n){if(t==null)return{};var a={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(n.indexOf(r)>=0)continue;a[r]=t[r]}return a}function be(){return be=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(t[r]=a[r])}return t},be.apply(this,arguments)}function Ve(t,n){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),a.push.apply(a,r)}return a}function ye(t){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?Ve(Object(a),!0).forEach(function(r){Dt(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Ve(Object(a)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(a,r))})}return t}function Dt(t,n,a){return n=Tt(n),n in t?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,t}function Tt(t){var n=Lt(t,"string");return typeof n=="symbol"?n:n+""}function Lt(t,n){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var r=a.call(t,n);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function ls(t){return t&&t.map((n,a)=>C.createElement(n.tag,ye({key:a},n.attr),ls(n.child)))}function he(t){return n=>C.createElement(At,be({attr:ye({},t.attr)},n),ls(t.child))}function At(t){var n=a=>{var{attr:r,size:o,title:l}=t,i=It(t,kt),d=o||a.size||"1em",h;return a.className&&(h=a.className),t.className&&(h=(h?h+" ":"")+t.className),C.createElement("svg",be({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,i,{className:h,style:ye(ye({color:t.color||a.color},a.style),t.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),l&&C.createElement("title",null,l),t.children)};return Re!==void 0?C.createElement(Re.Consumer,null,a=>n(a)):n(is)}function Mt(t){return he({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(t)}function cs(t){const{theme:n}=s.useTheme(),a=s.useDashboardStore(g=>g.theme),r=s.useEditorStore(g=>g.frame),o=s.useEditorStore(g=>g.card),l=s.useEditorStore(g=>g.activeTabCardId),i=s.Le(),{refetch:d}=s.useDashboardCardQuery(o),{updateCardTab:h,setRunSql:f}=s.useEditorActions(),u=C.useRef(),p=C.useRef({}),b=r.cards.find(g=>g.id===l),c=C.useCallback(()=>{let g="";return t==="python"&&(g=(b==null?void 0:b.python)||s.PYTHON_DEFAULT_CODE),t==="sql"&&(g=(b==null?void 0:b.sql)||""),g},[t,b]);C.useEffect(()=>{if(l&&o.id&&o.id!==l){if(u.current&&i){const g=u.current.getModel();g&&(p.current[o.id]=g);let S=p.current[l];if(!S){const j=c();S=i.editor.createModel(j,t),p.current[l]=S}u.current.setModel(S)}h(l,o),f(!0)}},[l,o,h,i,f,t,c]),C.useEffect(()=>{if(!i)return;const g=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",S=a==="system"?g:a;i.editor.defineTheme("default",{base:S==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":S==="light"?"#ffffff":s.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[n,a,i]),C.useEffect(()=>{const g=u.current;g&&i&&o&&g.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return d(),!1})},[i,d,o]);function m(g,S){if(u.current=g,!p.current[o.id]){const j=g.getModel(),I=c();p.current[o.id]=j||(S==null?void 0:S.editor.createModel(I,t))||g.getModel()}g.setModel(p.current[o.id])}return{handleEditorDidMount:m}}function zt(){const t=s.useEditorStore(i=>i.card.sql),n=s.useEditorStore(i=>i.sqlGen),{setCardSql:a,setSqlGen:r}=s.useEditorActions(),{handleEditorDidMount:o}=cs("sql");function l(i){a(i),s.isObjectEmpty(n)||r({})}return e.jsx(s.Ft,{theme:"default",className:"pt-3",onChange:l,value:t||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function Ot(){const t=s.useEditorStore(o=>o.card.python),{setCardPython:n}=s.useEditorActions(),{handleEditorDidMount:a}=cs("python");function r(o){n(o)}return e.jsx(s.Ft,{className:"pt-3",theme:"default",onChange:r,value:t||s.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:a})}function Ft({jsonString:t}){return e.jsx(s.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:t,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function ds(t){const[n,a]=C.useState(""),[r,o]=C.useState(null),{authToken:l}=s.useSemaphorContext(),i=s.useEditorStore(k=>{var _;return(_=k==null?void 0:k.card)==null?void 0:_.sql}),d=s.useEditorStore(k=>{var _;return(_=k==null?void 0:k.card)==null?void 0:_.python}),h=s.useEditorStore(k=>k.actions.setCardSql),f=s.useEditorStore(k=>k.actions.setRunSql),u=s.useEditorStore(k=>k.actions.switchCardType),p=s.useEditorStore(k=>k.currentAssitantScope)||[],b=s.useEditorStore(k=>k.userInputForAI),c=s.useEditorStore(k=>k.triggerAIRun),m=s.useEditorStore(k=>k.selectedDatabaseName),g=s.useEditorStore(k=>k.selectedTableName),S=s.useEditorStore(k=>k.selectedConnectionId),j=s.useEditorStore(k=>k.selectedSchemaName),I=s.useDashboardStore(k=>k.dashboard.aiScopeTables),{setTriggerAIRun:y,setCurrentAssitantScope:D}=s.useEditorActions(),{selectedDatamodelName:E,connectionType:O,selectedDatamodelId:V}=ae(),{messages:R,setMessages:B,reload:x,append:T,input:q,setInput:z,status:P,handleInputChange:G,handleSubmit:v,stop:N}=s.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${l==null?void 0:l.accessToken}`},body:{random:Math.random()},maxSteps:10,onToolCall:L,onFinish(k,_){H(_.usage),a(""),_.finishReason==="stop"&&a("")}});C.useEffect(()=>{c&&b&&(G({target:{value:b}}),setTimeout(()=>{v(),y(!1)},100))},[c,v,b,y,G]);async function L({toolCall:k}){if(k.toolName==="createChart"){const _=k.args.sql,W=k.args.chartType;return u(W),h(_),f(!0),{status:"success",message:"Let the user know that chart is created"}}else if(k.toolName==="getTableColumns")a("Getting table columns...");else{if(k.toolName==="getUserSql")return i?{status:"success",sql:i,python:d||""}:{status:"error",message:"No SQL found"};if(k.toolName==="getCurrentTableScope")return a("Getting table scope..."),M(),{status:"success",tables:p};a("Analyzing...")}}function H(k){o(_=>_?{promptTokens:_.promptTokens+k.promptTokens,completionTokens:_.completionTokens+k.completionTokens,totalTokens:_.totalTokens+k.totalTokens}:k)}function U(k){const _=s.removeFromScopeArray(p,k);Q(_)}function Q(k){const _=s.sanitizeAIScope(k);D(_),B(W=>[...W,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(_)}`}])}function F(){const k={databaseName:m||"",schemaName:j||"",tableName:g||"",datamodelId:V||"",datamodelName:s.resolveDatamodelName(E),connectionId:S||"",connectionType:O||""},_=s.dedup([...p,k]);Q(_)}function M(){const k={databaseName:m||"",schemaName:j||"",tableName:g||"",datamodelName:s.resolveDatamodelName(E),connectionId:S||"",connectionType:O||"",datamodelId:V||""};if(!s.isInAiScopeArray([...I||[],...p],k)||p.length===0){const W=s.dedup([...I||[],...p,k]).filter(K=>K.connectionId===k.connectionId);Q(W)}}const J=!["ready","error"].includes(P);return{messages:R,setMessages:B,reload:x,append:T,input:q,setInput:z,isLoading:J,handleSetAIScope:M,handleAddCurrentTableToScope:F,removeFromCurrentSelections:U,currentAssitantScope:p,setCurrentAssitantScope:D,handleInputChange:G,handleSubmit:v,stop:N,chatStatus:P,toolStatus:n,llmUsage:r,onFinish:t}}function Rt(){var re;const[t,n]=C.useState({queryKey:[],queryData:null}),a=s.useQueryClient(),[r,o]=C.useState(!1),[l,i]=C.useState(!1),d=s.useEditorStore(A=>A.frame),h=s.useEditorStore(A=>A.card),f=s.useEditorStore(A=>A.isShowingVisual),u=s.useEditorStore(A=>A.selectedConnectionId),p=s.useEditorStore(A=>A.selectedDatabaseName),b=s.useEditorStore(A=>A.selectedDatamodelId),c=s.useEditorStore(A=>A.selectedSchemaName),m=s.useEditorStore(A=>A.showAIDialog),g=s.useEditorStore(A=>A.selectedTableName),S=s.useEditorStore(A=>{var Y;return(Y=A==null?void 0:A.card)==null?void 0:Y.sql}),{sheetFilterValues:j}=s.useSheetFilterValues(),{setCardCustomCfg:I,setQueryResultColumns:y,setCardSql:D,setPythonStdOut:E,setCardPreferences:O,setCardType:V,setCardPython:R,runAssistant:B,setShowAIDialog:x}=s.useEditorActions(),T=s.useEditorStore(A=>A.onSave),q=s.useEditorStore(A=>A.onClose),z=s.useEditorStore(A=>A.actions.setSqlGen),P=s.useEditorStore(A=>A.runSql),G=s.useEditorStore(A=>A.actions.setRunSql),v=s.useEditorStore(A=>A.actions.setCardCfg),N=s.useEditorStore(A=>A.actions.setIsSqlRunning),{data:L,isLoading:H,isFetching:U,isSuccess:Q,isError:F,error:M,queryKey:J,refetch:k}=s.useDashboardCardQuery(h),{handleSetAIScope:_}=ds();C.useEffect(()=>{if(L&&(L.rowLimitExceeded&&s.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((L==null?void 0:L.output)||""),L.records.length>0)){const{dimensionKeys:A}=s.getKeys(L.records);y(A)}},[L,y,E]),C.useEffect(()=>{(H||U)&&N(!0),(F||Q)&&N(!1),F&&(y([]),E(""))},[H,U,L,E,F,Q,N,y,M]),C.useEffect(()=>{P&&(a.getQueryData(J)||k(),G(!1))},[P,k,G,J,a]);function W(){const A=a.getQueryData(J);t.queryData||n({queryKey:J,queryData:A}),a.setQueryData(J,null),a.removeQueries({queryKey:J,exact:!0}),D(""),z({}),R(""),v(void 0),I(""),O({}),V("bar")}function K(A,Y){if(A.length===0)return"";if(Y){const oe=A.find(X=>X.id===Y);if(oe){const X=oe.tabTitle;if(X=="All__Header")return A[0].id;if(X&&X.endsWith("__Header")){const Se=X.split("__")[0],fe=A.find(Ce=>Ce.tabTitle===Se);return fe?fe.id:A[0].id}return Y}}return A[0].id}function te(){let A=S;S&&!S.includes("{{")&&(A=Nt(S),D(A));const Y={...h,lastSelectedSchema:c,lastSelectedDatamodelId:b,lastSelectedDatabase:p,lastSelectedTable:g,connectionId:u,type:f?h.type:"table",sql:A,customCfg:f?h.customCfg:null},oe=d.cards.map(xe=>xe.id===h.id?Y:xe),X={...d,cards:oe,activeCardId:K(oe,d.activeCardId)};T==null||T(X)}function se(){const{queryKey:A,queryData:Y}=t;A&&Y&&a.setQueryData(A,Y),z({}),q==null||q()}async function $(){const A=`Can you help me debug this query in the current table scope?
|
|
307
307
|
|
|
308
308
|
Error:
|
|
309
309
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as L, p as Tt, u as O, a as Ke, b as Te, d as oa, e as ca, B as $, P as nt, f as da, g as ha, h as ua, i as ma, L as H, I as de, j as pa, k as fa, l as ga, m as G, n as ya, o as ba, q as xa, r as zs, s as Kt, t as Y, C as pt, v as Is, S as xe, w as ve, x as Ne, y as Ce, z as ze, A as Se, E as ie, T as va, F as qe, G as Re, H as ft, J as De, K as At, M as gt, N as Lt, O as yt, Q as we, R as Os, U as bt, V as Na, W as Me, X as Qt, Y as Ee, Z as m, _ as Ca, $ as Sa, a0 as et, a1 as ct, a2 as Ts, a3 as wa, a4 as ka, a5 as Ma, a6 as Da, a7 as za, a8 as Ia, a9 as As, aa as Oa, ab as Ta, ac as Aa, ad as La, ae as Fa, af as be, ag as Ls, ah as Fs, ai as Ea, aj as Es, ak as Vs, al as qs, am as Va, an as Oe, ao as Rs, ap as Ue, aq as dt, ar as kt, as as js, at as _s, au as Hs, av as je, aw as ne, ax as qa, ay as Ps, az as xt, aA as $s, aB as Bs, aC as Us, aD as Wt, aE as Gs, aF as Js, aG as Ks, aH as Qs, aI as Mt, aJ as Ws, aK as Ge, aL as tt, aM as fe, aN as at, aO as Zs, aP as Ys, aQ as Xs, aR as en, aS as St, aT as tn, aU as Zt, aV as an, aW as Yt, aX as sn, aY as nn, aZ as ln, a_ as rn, a$ as Ra, b0 as on, b1 as Ft, b2 as ja, b3 as cn, b4 as dn, b5 as ot, b6 as hn, b7 as un, b8 as _a, b9 as mn, ba as pn, bb as fn, bc as gn, bd as yn, be as vt, bf as Ha, bg as bn, bh as Pa, bi as $a, bj as Dt, bk as zt, bl as xn, bm as vn, bn as Nn, bo as Et, bp as Ba, bq as Vt, br as st, bs as Cn, bt as ht, bu as Ua, bv as Sn, bw as Ga, bx as wn, by as kn, bz as Mn, bA as Dn, bB as zn, bC as qt, bD as In, bE as On, bF as Tn, bG as An, bH as Xt, bI as ea, bJ as Ja, bK as Ln, bL as Fn, bM as _e, bN as ee, bO as te, bP as ae, bQ as En, bR as Vn, bS as qn, bT as Rn, bU as jn, bV as _n, bW as Hn, bX as Pn, bY as $n, bZ as wt, b_ as Ka, b$ as Bn, c0 as Un, c1 as Gn, c2 as Jn, c3 as Kn, c4 as Qn } from "./chunks/index-
|
|
2
|
-
import { D as vr, c9 as Nr, c7 as Cr, c7 as Sr, cc as wr, cb as kr, ca as Mr, cd as Dr, c8 as zr, c5 as Ir, c6 as Or } from "./chunks/index-
|
|
1
|
+
import { c as L, p as Tt, u as O, a as Ke, b as Te, d as oa, e as ca, B as $, P as nt, f as da, g as ha, h as ua, i as ma, L as H, I as de, j as pa, k as fa, l as ga, m as G, n as ya, o as ba, q as xa, r as zs, s as Kt, t as Y, C as pt, v as Is, S as xe, w as ve, x as Ne, y as Ce, z as ze, A as Se, E as ie, T as va, F as qe, G as Re, H as ft, J as De, K as At, M as gt, N as Lt, O as yt, Q as we, R as Os, U as bt, V as Na, W as Me, X as Qt, Y as Ee, Z as m, _ as Ca, $ as Sa, a0 as et, a1 as ct, a2 as Ts, a3 as wa, a4 as ka, a5 as Ma, a6 as Da, a7 as za, a8 as Ia, a9 as As, aa as Oa, ab as Ta, ac as Aa, ad as La, ae as Fa, af as be, ag as Ls, ah as Fs, ai as Ea, aj as Es, ak as Vs, al as qs, am as Va, an as Oe, ao as Rs, ap as Ue, aq as dt, ar as kt, as as js, at as _s, au as Hs, av as je, aw as ne, ax as qa, ay as Ps, az as xt, aA as $s, aB as Bs, aC as Us, aD as Wt, aE as Gs, aF as Js, aG as Ks, aH as Qs, aI as Mt, aJ as Ws, aK as Ge, aL as tt, aM as fe, aN as at, aO as Zs, aP as Ys, aQ as Xs, aR as en, aS as St, aT as tn, aU as Zt, aV as an, aW as Yt, aX as sn, aY as nn, aZ as ln, a_ as rn, a$ as Ra, b0 as on, b1 as Ft, b2 as ja, b3 as cn, b4 as dn, b5 as ot, b6 as hn, b7 as un, b8 as _a, b9 as mn, ba as pn, bb as fn, bc as gn, bd as yn, be as vt, bf as Ha, bg as bn, bh as Pa, bi as $a, bj as Dt, bk as zt, bl as xn, bm as vn, bn as Nn, bo as Et, bp as Ba, bq as Vt, br as st, bs as Cn, bt as ht, bu as Ua, bv as Sn, bw as Ga, bx as wn, by as kn, bz as Mn, bA as Dn, bB as zn, bC as qt, bD as In, bE as On, bF as Tn, bG as An, bH as Xt, bI as ea, bJ as Ja, bK as Ln, bL as Fn, bM as _e, bN as ee, bO as te, bP as ae, bQ as En, bR as Vn, bS as qn, bT as Rn, bU as jn, bV as _n, bW as Hn, bX as Pn, bY as $n, bZ as wt, b_ as Ka, b$ as Bn, c0 as Un, c1 as Gn, c2 as Jn, c3 as Kn, c4 as Qn } from "./chunks/index-BQjgev3I.js";
|
|
2
|
+
import { D as vr, c9 as Nr, c7 as Cr, c7 as Sr, cc as wr, cb as kr, ca as Mr, cd as Dr, c8 as zr, c5 as Ir, c6 as Or } from "./chunks/index-BQjgev3I.js";
|
|
3
3
|
import { jsxs as n, jsx as e, Fragment as se } from "react/jsx-runtime";
|
|
4
4
|
import * as Be from "react";
|
|
5
5
|
import Ie, { useState as j, useMemo as It, useEffect as oe, useRef as Je, useCallback as Qa, Suspense as Wn } from "react";
|
|
@@ -1241,7 +1241,7 @@ function Ql() {
|
|
|
1241
1241
|
t && t.length > 0 && /* @__PURE__ */ n("div", { className: "space-y-4", children: [
|
|
1242
1242
|
/* @__PURE__ */ e(we, { className: "my-2" }),
|
|
1243
1243
|
/* @__PURE__ */ e("div", { className: "space-y-2", children: /* @__PURE__ */ n("div", { className: "flex items-start justify-between", children: [
|
|
1244
|
-
/* @__PURE__ */ n("div", { children: [
|
|
1244
|
+
/* @__PURE__ */ n("div", { className: "space-y-2", children: [
|
|
1245
1245
|
/* @__PURE__ */ e("h4", { className: "font-medium leading-none", children: "Subscriptions" }),
|
|
1246
1246
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Active email subscriptions" })
|
|
1247
1247
|
] }),
|
|
@@ -114,6 +114,13 @@ export declare type DateOptions = {
|
|
|
114
114
|
|
|
115
115
|
export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
|
|
116
116
|
|
|
117
|
+
export declare type EmailSettings = {
|
|
118
|
+
companyName: string;
|
|
119
|
+
dashboardUrl: string;
|
|
120
|
+
supportEmail: string;
|
|
121
|
+
senderTitle: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
117
124
|
export declare type ErrorProps = {
|
|
118
125
|
message?: string;
|
|
119
126
|
};
|
|
@@ -416,6 +423,7 @@ export declare type TDashboard = {
|
|
|
416
423
|
aiScopeTables?: AIScopeTable[];
|
|
417
424
|
globalStyle?: TStyle;
|
|
418
425
|
globalCacheConfig?: CacheConfig;
|
|
426
|
+
emailSettings?: EmailSettings;
|
|
419
427
|
};
|
|
420
428
|
|
|
421
429
|
export declare type TDataColumn = {
|
package/dist/types/main.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ChartConfiguration } from 'chart.js';
|
|
|
5
5
|
import { CustomCard as CustomCard_2 } from '..';
|
|
6
6
|
import { DateRange } from 'react-day-picker';
|
|
7
7
|
import { default as default_2 } from 'react-grid-layout';
|
|
8
|
+
import { EmailSettings as EmailSettings_2 } from '..';
|
|
8
9
|
import { FontSpec } from 'chart.js';
|
|
9
10
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
10
11
|
import { QueryObserverResult } from '@tanstack/query-core';
|
|
@@ -19,6 +20,7 @@ import { WritableDraft } from 'immer';
|
|
|
19
20
|
declare type Actions = {
|
|
20
21
|
setInitStore: () => void;
|
|
21
22
|
setGlobalStyle: (style: TStyle) => void;
|
|
23
|
+
updateEmailSettings: (emailSettings: EmailSettings) => void;
|
|
22
24
|
setIsDownloadingPdf: (isDownloadingPdf: boolean) => void;
|
|
23
25
|
setLenses: (lenses: TLens[]) => void;
|
|
24
26
|
setSelectedLensId: (lensId: string) => void;
|
|
@@ -339,6 +341,13 @@ declare type EditorStore = {
|
|
|
339
341
|
onClose?: () => void;
|
|
340
342
|
};
|
|
341
343
|
|
|
344
|
+
export declare type EmailSettings = {
|
|
345
|
+
companyName: string;
|
|
346
|
+
dashboardUrl: string;
|
|
347
|
+
supportEmail: string;
|
|
348
|
+
senderTitle: string;
|
|
349
|
+
};
|
|
350
|
+
|
|
342
351
|
export declare type ErrorProps = {
|
|
343
352
|
message?: string;
|
|
344
353
|
};
|
|
@@ -409,6 +418,7 @@ export declare function getDashbaordStateWithoutData(dashboardState: TDashboard)
|
|
|
409
418
|
aiScopeTables?: AIScopeTable_2[];
|
|
410
419
|
globalStyle?: TStyle_2;
|
|
411
420
|
globalCacheConfig?: CacheConfig_2;
|
|
421
|
+
emailSettings?: EmailSettings_2;
|
|
412
422
|
};
|
|
413
423
|
|
|
414
424
|
export declare type GetDashboardResponse = {
|
|
@@ -734,6 +744,7 @@ export declare type TDashboard = {
|
|
|
734
744
|
aiScopeTables?: AIScopeTable[];
|
|
735
745
|
globalStyle?: TStyle;
|
|
736
746
|
globalCacheConfig?: CacheConfig;
|
|
747
|
+
emailSettings?: EmailSettings;
|
|
737
748
|
};
|
|
738
749
|
|
|
739
750
|
export declare type TDataColumn = {
|
|
@@ -117,6 +117,13 @@ export declare type DateOptions = {
|
|
|
117
117
|
|
|
118
118
|
export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
|
|
119
119
|
|
|
120
|
+
export declare type EmailSettings = {
|
|
121
|
+
companyName: string;
|
|
122
|
+
dashboardUrl: string;
|
|
123
|
+
supportEmail: string;
|
|
124
|
+
senderTitle: string;
|
|
125
|
+
};
|
|
126
|
+
|
|
120
127
|
export declare type ErrorProps = {
|
|
121
128
|
message?: string;
|
|
122
129
|
};
|
|
@@ -421,6 +428,7 @@ export declare type TDashboard = {
|
|
|
421
428
|
aiScopeTables?: AIScopeTable[];
|
|
422
429
|
globalStyle?: TStyle;
|
|
423
430
|
globalCacheConfig?: CacheConfig;
|
|
431
|
+
emailSettings?: EmailSettings;
|
|
424
432
|
};
|
|
425
433
|
|
|
426
434
|
export declare type TDataColumn = {
|
package/dist/types/types.d.ts
CHANGED
|
@@ -111,6 +111,13 @@ export declare type DateOptions = {
|
|
|
111
111
|
|
|
112
112
|
export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
|
|
113
113
|
|
|
114
|
+
export declare type EmailSettings = {
|
|
115
|
+
companyName: string;
|
|
116
|
+
dashboardUrl: string;
|
|
117
|
+
supportEmail: string;
|
|
118
|
+
senderTitle: string;
|
|
119
|
+
};
|
|
120
|
+
|
|
114
121
|
export declare type ErrorProps = {
|
|
115
122
|
message?: string;
|
|
116
123
|
};
|
|
@@ -413,6 +420,7 @@ export declare type TDashboard = {
|
|
|
413
420
|
aiScopeTables?: AIScopeTable[];
|
|
414
421
|
globalStyle?: TStyle;
|
|
415
422
|
globalCacheConfig?: CacheConfig;
|
|
423
|
+
emailSettings?: EmailSettings;
|
|
416
424
|
};
|
|
417
425
|
|
|
418
426
|
export declare type TDataColumn = {
|